Skip to content
This repository was archived by the owner on Aug 7, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion packages/oui-select-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,25 @@
disabled></oui-select-picker>
```

### Sections
### Sections using `oui-select-picker-section`

```html:preview
<oui-select-picker label="Checked"
match="name"
description="Checked select picker">
<oui-select-picker-section>Section 1</oui-select-picker-section>
<oui-select-picker-section>Section 2</oui-select-picker-section>
</oui-select-picker>
<oui-select-picker label="Disabled"
match="name"
description="Disabled select picker"
disabled>
<oui-select-picker-section>Section 1</oui-select-picker-section>
<oui-select-picker-section>Section 2</oui-select-picker-section>
</oui-select-picker>
```

### Sections using `span`

```html:preview
<oui-select-picker label="Checked"
Expand All @@ -57,6 +75,8 @@
</oui-select-picker>
```

**Note**: This use is **deprecated** and will be removed in the next major version

### On change

```html:preview
Expand Down
4 changes: 3 additions & 1 deletion packages/oui-select-picker/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import SelectPicker from "./select-picker.component.js";
import SelectPicker from "./select-picker.component";
import SelectPickerSection from "./section/select-picker-section.component";

export default angular
.module("oui.select-picker", [])
.component("ouiSelectPicker", SelectPicker)
.component("ouiSelectPickerSection", SelectPickerSection)
.name;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
controller: class {
constructor ($element, $timeout) {
"ngInject";

this.$element = $element;
this.$timeout = $timeout;
}

$postLink () {
this.$timeout(() =>
this.$element.addClass("oui-select-picker__section")
);
}
}
};
3 changes: 2 additions & 1 deletion packages/oui-select-picker/src/select-picker.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default {
template,
controller,
transclude: {
sectionSlot: "?span"
sectionSlot: "?ouiSelectPickerSection",
deprecatedSlot: "?span" // Deprecated: Replaced by "oui-select-picker-section"
},
bindings: {
model: "=?",
Expand Down
3 changes: 2 additions & 1 deletion packages/oui-select-picker/src/select-picker.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default class SelectPickerController {
}
}

this.transcludeSection = this.$transclude.isSlotFilled("sectionSlot");
this.sectionTransclude = this.$transclude.isSlotFilled("sectionSlot");
this.deprecatedTransclude = this.$transclude.isSlotFilled("deprecatedSlot");
}

$postLink () {
Expand Down
59 changes: 31 additions & 28 deletions packages/oui-select-picker/src/select-picker.html
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
<input type="radio" class="oui-select-picker__input"
name="{{:: $ctrl.name }}"
ng-attr-aria-labelledby="{{:: $ctrl.id }}Label"
ng-attr-aria-describedby="{{:: $ctrl.description && $ctrl.id + 'Description' || undefined }}"
ng-attr-id="{{:: $ctrl.id }}"
ng-change="$ctrl.onRadioModelChange({ modelValue: $ctrl.model })"
ng-disabled="$ctrl.disabled"
ng-model="$ctrl.model"
ng-required="$ctrl.required"
ng-value="$ctrl.selectedValue">
name="{{:: $ctrl.name }}"
ng-attr-aria-labelledby="{{:: $ctrl.id }}Label"
ng-attr-aria-describedby="{{:: $ctrl.description && $ctrl.id + 'Description' || undefined }}"
ng-attr-id="{{:: $ctrl.id }}"
ng-change="$ctrl.onRadioModelChange({ modelValue: $ctrl.model })"
ng-disabled="$ctrl.disabled"
ng-model="$ctrl.model"
ng-required="$ctrl.required"
ng-value="$ctrl.selectedValue">
<label class="oui-select-picker__label-container" for="{{:: $ctrl.id }}">
<span class="oui-select-picker__picture-container"
ng-if="$ctrl.picture">
ng-if="$ctrl.picture">
<img class="oui-select-picker__picture" alt="" aria-hidden="true"
ng-if="$ctrl.isImgPath"
ng-src="{{ :: $ctrl.picture }}">
ng-if="$ctrl.isImgPath"
ng-src="{{ :: $ctrl.picture }}">
<span class="oui-select-picker__picture" aria-hidden="true"
ng-class=":: $ctrl.picture"
ng-if="!$ctrl.isImgPath"></span>
ng-class=":: $ctrl.picture"
ng-if="!$ctrl.isImgPath"></span>
</span>
<span class="oui-select-picker__label">
<span id="{{:: $ctrl.id }}Label"
ng-bind="$ctrl.label">
</span>
</span>
<span class="oui-select-picker__description"
id="{{:: $ctrl.id }}Description"
ng-bind=":: $ctrl.description"
ng-if="$ctrl.description"></span>
id="{{:: $ctrl.id }}Description"
ng-bind=":: $ctrl.description"
ng-if="$ctrl.description"></span>
<span class="oui-select-picker__value-container oui-select-picker__section"
ng-if="$ctrl.values.length === 1 && $ctrl.match">
ng-if="$ctrl.values.length === 1 && $ctrl.match">
<span class="oui-select-picker__value"
ng-bind=":: $ctrl.getFirstValueMatch($ctrl.match)">
ng-bind=":: $ctrl.getFirstValueMatch($ctrl.match)">
</span>
</span>
<span class="oui-select-picker__value-container oui-select-picker__section"
ng-if="$ctrl.values.length > 1">
<oui-select name="{{:: $ctrl.name }}"
disabled="$ctrl.disabled"
items="$ctrl.values"
match="{{ $ctrl.match }}"
model="$ctrl.selectedValue"
on-change="$ctrl.onSelectModelChange({ modelValue: $ctrl.selectedValue })"
placeholder="{{:: $ctrl.placeholder || ' - ' }}"
data-align="end">
disabled="$ctrl.disabled"
items="$ctrl.values"
match="{{ $ctrl.match }}"
model="$ctrl.selectedValue"
on-change="$ctrl.onSelectModelChange({ modelValue: $ctrl.selectedValue })"
placeholder="{{:: $ctrl.placeholder || ' - ' }}"
data-align="end">
<span ng-if="$ctrl.match" ng-bind=":: $ctrl.$scope.$parent.getItemValue($item, $ctrl.match)"></span>
<span ng-if="!$ctrl.match" ng-bind=":: $item"></span>
</oui-select>
</span>
<span class="oui-select-picker__transclude-container"
ng-if="$ctrl.transcludeSection"
ng-transclude="sectionSlot"></span>
ng-if="$ctrl.sectionTransclude"
ng-transclude="sectionSlot"></span>
<span class="oui-select-picker__transclude-container"
ng-if="$ctrl.deprecatedTransclude"
ng-transclude="deprecatedSlot"></span>
</label>