@gitlab/ui 137.3.1 → 138.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -12
- package/dist/components/base/alert/alert.js +0 -1
- package/dist/components/base/drawer/drawer.js +0 -1
- package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +1 -1
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +0 -1
- package/dist/components/base/form/form_group/form_group.js +0 -1
- package/dist/components/base/form/form_select/form_select.js +322 -6
- package/dist/components/base/modal/modal.js +1 -5
- package/dist/components/base/new_dropdowns/base_dropdown/dropdown_container.js +1 -1
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +1 -3
- package/dist/components/base/toast/index.js +1 -1
- package/dist/components/base/toggle/toggle.js +0 -1
- package/dist/components/mixins/tooltip_mixin.js +1 -1
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/tailwind.css.map +1 -1
- package/dist/tokens/build/js/tokens.dark.js +299 -299
- package/dist/tokens/build/js/tokens.js +302 -302
- package/dist/utils/confetti/confetti.js +189 -0
- package/dist/utils/confetti/constants.js +36 -0
- package/dist/utils/confetti/field.js +114 -0
- package/dist/utils/confetti/palette.js +6 -0
- package/dist/utils/confetti/particles.js +92 -0
- package/dist/utils/matrix/columns.js +54 -0
- package/dist/utils/matrix/constants.js +19 -0
- package/dist/utils/matrix/matrix.js +157 -0
- package/dist/utils/matrix/palette.js +9 -0
- package/dist/utils.js +2 -0
- package/dist/vendor/bootstrap-vue/src/components/popover/helpers/bv-popover-template.js +4 -2
- package/dist/vendor/bootstrap-vue/src/components/tooltip/helpers/bv-tooltip-template.js +3 -1
- package/dist/vendor/bootstrap-vue/src/constants/components.js +1 -4
- package/package.json +4 -11
- package/src/components/base/alert/alert.vue +0 -1
- package/src/components/base/drawer/drawer.vue +0 -1
- package/src/components/base/filtered_search/filtered_search_suggestion_list.vue +2 -1
- package/src/components/base/filtered_search/filtered_search_token_segment.vue +0 -1
- package/src/components/base/form/form_group/form_group.vue +0 -2
- package/src/components/base/form/form_select/form_select.vue +389 -10
- package/src/components/base/modal/modal.vue +0 -3
- package/src/components/base/new_dropdowns/base_dropdown/dropdown_container.js +1 -1
- package/src/components/base/new_dropdowns/disclosure/disclosure_dropdown.vue +0 -1
- package/src/components/base/tabs/tabs/scrollable_tabs.vue +0 -1
- package/src/components/base/tabs/tabs/tabs.vue +0 -1
- package/src/components/base/toast/index.js +1 -1
- package/src/components/base/toggle/toggle.vue +0 -1
- package/src/components/charts/heatmap/index.js +1 -1
- package/src/components/mixins/tooltip_mixin.js +1 -1
- package/src/tokens/build/css/tokens.css +74 -74
- package/src/tokens/build/css/tokens.dark.css +70 -70
- package/src/tokens/build/docs/tokens-tailwind-docs.dark.json +303 -303
- package/src/tokens/build/docs/tokens-tailwind-docs.json +323 -323
- package/src/tokens/build/figma/constants.dark.json +207 -207
- package/src/tokens/build/figma/constants.json +207 -207
- package/src/tokens/build/figma/mode.dark.json +37 -37
- package/src/tokens/build/figma/mode.json +35 -35
- package/src/tokens/build/js/tokens.dark.js +299 -300
- package/src/tokens/build/js/tokens.js +302 -303
- package/src/tokens/build/json/tokens.dark.json +369 -369
- package/src/tokens/build/json/tokens.json +376 -376
- package/src/tokens/build/scss/_tokens.dark.scss +70 -70
- package/src/tokens/build/scss/_tokens.scss +74 -74
- package/src/tokens/constant/color.blue.tokens.json +39 -39
- package/src/tokens/constant/color.green.tokens.json +41 -41
- package/src/tokens/constant/color.orange.tokens.json +43 -43
- package/src/tokens/constant/color.purple.tokens.json +40 -40
- package/src/tokens/constant/color.red.tokens.json +44 -44
- package/src/tokens/contextual/avatar.tokens.json +13 -13
- package/src/tokens/contextual/button.tokens.json +22 -22
- package/src/tokens/contextual/chart.tokens.json +3 -3
- package/src/tokens/semantic/action.tokens.json +18 -18
- package/src/utils/confetti/confetti.js +191 -0
- package/src/utils/confetti/constants.js +42 -0
- package/src/utils/confetti/field.js +134 -0
- package/src/utils/confetti/palette.js +15 -0
- package/src/utils/confetti/particles.js +98 -0
- package/src/utils/matrix/columns.js +53 -0
- package/src/utils/matrix/constants.js +19 -0
- package/src/utils/matrix/matrix.js +185 -0
- package/src/utils/matrix/palette.js +18 -0
- package/src/utils.js +2 -0
- package/src/vendor/bootstrap-vue/src/components/popover/helpers/bv-popover-template.js +7 -2
- package/src/vendor/bootstrap-vue/src/components/tooltip/helpers/bv-tooltip-template.js +2 -1
- package/src/vendor/bootstrap-vue/src/constants/components.js +0 -3
- package/translations.js +1 -1
- package/dist/vendor/bootstrap-vue/src/components/form-select/form-select-option-group.js +0 -51
- package/dist/vendor/bootstrap-vue/src/components/form-select/form-select-option.js +0 -41
- package/dist/vendor/bootstrap-vue/src/components/form-select/form-select.js +0 -153
- package/dist/vendor/bootstrap-vue/src/components/form-select/helpers/mixin-options.js +0 -63
- package/dist/vendor/bootstrap-vue/src/components/form-select/index.js +0 -3
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select-option-group.js +0 -46
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select-option.js +0 -35
- package/src/vendor/bootstrap-vue/src/components/form-select/form-select.js +0 -156
- package/src/vendor/bootstrap-vue/src/components/form-select/helpers/mixin-options.js +0 -60
- package/src/vendor/bootstrap-vue/src/components/form-select/index.js +0 -5
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { extend, mergeData } from '../../vue';
|
|
2
|
-
import { NAME_FORM_SELECT_OPTION } from '../../constants/components';
|
|
3
|
-
|
|
4
|
-
// --- Props ---
|
|
5
|
-
|
|
6
|
-
const props = {
|
|
7
|
-
disabled: {
|
|
8
|
-
type: Boolean,
|
|
9
|
-
required: false,
|
|
10
|
-
default: false
|
|
11
|
-
},
|
|
12
|
-
value: {
|
|
13
|
-
required: true
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// --- Main component ---
|
|
18
|
-
|
|
19
|
-
// @vue/component
|
|
20
|
-
const BFormSelectOption = /*#__PURE__*/extend({
|
|
21
|
-
name: NAME_FORM_SELECT_OPTION,
|
|
22
|
-
functional: true,
|
|
23
|
-
props,
|
|
24
|
-
render(h, _ref) {
|
|
25
|
-
let props = _ref.props,
|
|
26
|
-
data = _ref.data,
|
|
27
|
-
children = _ref.children;
|
|
28
|
-
const value = props.value,
|
|
29
|
-
disabled = props.disabled;
|
|
30
|
-
return h('option', mergeData(data, {
|
|
31
|
-
attrs: {
|
|
32
|
-
disabled
|
|
33
|
-
},
|
|
34
|
-
domProps: {
|
|
35
|
-
value
|
|
36
|
-
}
|
|
37
|
-
}), children);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export { BFormSelectOption, props };
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { extend } from '../../vue';
|
|
2
|
-
import { NAME_FORM_SELECT } from '../../constants/components';
|
|
3
|
-
import { EVENT_NAME_CHANGE, EVENT_NAME_INPUT } from '../../constants/events';
|
|
4
|
-
import { SLOT_NAME_FIRST } from '../../constants/slots';
|
|
5
|
-
import { from } from '../../utils/array';
|
|
6
|
-
import { attemptFocus, attemptBlur } from '../../utils/dom';
|
|
7
|
-
import { htmlOrText } from '../../utils/html';
|
|
8
|
-
import { isArray } from '../../utils/inspect';
|
|
9
|
-
import { sortKeys } from '../../utils/object';
|
|
10
|
-
import { props as props$2, formControlMixin } from '../../mixins/form-control';
|
|
11
|
-
import { props as props$3, formCustomMixin } from '../../mixins/form-custom';
|
|
12
|
-
import { props as props$4, formSizeMixin } from '../../mixins/form-size';
|
|
13
|
-
import { props as props$5, formStateMixin } from '../../mixins/form-state';
|
|
14
|
-
import { normalizeSlotMixin } from '../../mixins/normalize-slot';
|
|
15
|
-
import { props as props$1, idMixin } from '../../mixins/id';
|
|
16
|
-
import { optionsMixin } from './helpers/mixin-options';
|
|
17
|
-
import { BFormSelectOption } from './form-select-option';
|
|
18
|
-
import { BFormSelectOptionGroup } from './form-select-option-group';
|
|
19
|
-
|
|
20
|
-
const MODEL_PROP_NAME = 'value';
|
|
21
|
-
const MODEL_EVENT_NAME = EVENT_NAME_INPUT;
|
|
22
|
-
|
|
23
|
-
// --- Props ---
|
|
24
|
-
|
|
25
|
-
const props = sortKeys({
|
|
26
|
-
...props$1,
|
|
27
|
-
[MODEL_PROP_NAME]: {},
|
|
28
|
-
...props$2,
|
|
29
|
-
...props$3,
|
|
30
|
-
...props$4,
|
|
31
|
-
...props$5,
|
|
32
|
-
ariaInvalid: {
|
|
33
|
-
type: [Boolean, String],
|
|
34
|
-
required: false,
|
|
35
|
-
default: false
|
|
36
|
-
},
|
|
37
|
-
multiple: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
required: false,
|
|
40
|
-
default: false
|
|
41
|
-
},
|
|
42
|
-
// Browsers default size to `0`, which shows 4 rows in most browsers in multiple mode
|
|
43
|
-
// Size of `1` can bork out Firefox
|
|
44
|
-
selectSize: {
|
|
45
|
-
type: Number,
|
|
46
|
-
required: false,
|
|
47
|
-
default: 0
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// --- Main component ---
|
|
52
|
-
|
|
53
|
-
// @vue/component
|
|
54
|
-
const BFormSelect = /*#__PURE__*/extend({
|
|
55
|
-
name: NAME_FORM_SELECT,
|
|
56
|
-
mixins: [idMixin, formControlMixin, formSizeMixin, formStateMixin, formCustomMixin, optionsMixin, normalizeSlotMixin],
|
|
57
|
-
model: {
|
|
58
|
-
prop: MODEL_PROP_NAME,
|
|
59
|
-
event: MODEL_EVENT_NAME
|
|
60
|
-
},
|
|
61
|
-
props,
|
|
62
|
-
data() {
|
|
63
|
-
return {
|
|
64
|
-
localValue: this[MODEL_PROP_NAME]
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
computed: {
|
|
68
|
-
computedSelectSize() {
|
|
69
|
-
// Custom selects with a size of zero causes the arrows to be hidden,
|
|
70
|
-
// so dont render the size attribute in this case
|
|
71
|
-
return !this.plain && this.selectSize === 0 ? null : this.selectSize;
|
|
72
|
-
},
|
|
73
|
-
inputClass() {
|
|
74
|
-
return [this.plain ? 'form-control' : 'custom-select', this.size && this.plain ? `form-control-${this.size}` : null, this.size && !this.plain ? `custom-select-${this.size}` : null, this.stateClass];
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
watch: {
|
|
78
|
-
value(newValue) {
|
|
79
|
-
this.localValue = newValue;
|
|
80
|
-
},
|
|
81
|
-
localValue() {
|
|
82
|
-
this.$emit(MODEL_EVENT_NAME, this.localValue);
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
methods: {
|
|
86
|
-
focus() {
|
|
87
|
-
attemptFocus(this.$refs.input);
|
|
88
|
-
},
|
|
89
|
-
blur() {
|
|
90
|
-
attemptBlur(this.$refs.input);
|
|
91
|
-
},
|
|
92
|
-
onChange(event) {
|
|
93
|
-
const target = event.target;
|
|
94
|
-
const selectedValue = from(target.options).filter(o => o.selected).map(o => '_value' in o ? o._value : o.value);
|
|
95
|
-
this.localValue = target.multiple ? selectedValue : selectedValue[0];
|
|
96
|
-
this.$nextTick(() => {
|
|
97
|
-
this.$emit(EVENT_NAME_CHANGE, this.localValue);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
render(h) {
|
|
102
|
-
const name = this.name,
|
|
103
|
-
disabled = this.disabled,
|
|
104
|
-
required = this.required,
|
|
105
|
-
size = this.computedSelectSize,
|
|
106
|
-
value = this.localValue;
|
|
107
|
-
const $options = this.formOptions.map((option, index) => {
|
|
108
|
-
const value = option.value,
|
|
109
|
-
label = option.label,
|
|
110
|
-
options = option.options,
|
|
111
|
-
disabled = option.disabled;
|
|
112
|
-
const key = `option_${index}`;
|
|
113
|
-
return isArray(options) ? h(BFormSelectOptionGroup, {
|
|
114
|
-
props: {
|
|
115
|
-
label,
|
|
116
|
-
options
|
|
117
|
-
},
|
|
118
|
-
key
|
|
119
|
-
}) : h(BFormSelectOption, {
|
|
120
|
-
props: {
|
|
121
|
-
value,
|
|
122
|
-
disabled
|
|
123
|
-
},
|
|
124
|
-
domProps: htmlOrText(option.html, option.text),
|
|
125
|
-
key
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
return h('select', {
|
|
129
|
-
class: this.inputClass,
|
|
130
|
-
attrs: {
|
|
131
|
-
id: this.safeId(),
|
|
132
|
-
name,
|
|
133
|
-
form: this.form || null,
|
|
134
|
-
multiple: this.multiple || null,
|
|
135
|
-
size,
|
|
136
|
-
disabled,
|
|
137
|
-
required,
|
|
138
|
-
'aria-required': required ? 'true' : null,
|
|
139
|
-
'aria-invalid': this.computedAriaInvalid
|
|
140
|
-
},
|
|
141
|
-
on: {
|
|
142
|
-
change: this.onChange
|
|
143
|
-
},
|
|
144
|
-
directives: [{
|
|
145
|
-
name: 'model',
|
|
146
|
-
value
|
|
147
|
-
}],
|
|
148
|
-
ref: 'input'
|
|
149
|
-
}, [this.normalizeSlot(SLOT_NAME_FIRST), $options, this.normalizeSlot()]);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
export { BFormSelect, props };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { extend } from '../../../vue';
|
|
2
|
-
import { PROP_TYPE_STRING } from '../../../constants/props';
|
|
3
|
-
import { get } from '../../../utils/get';
|
|
4
|
-
import { isPlainObject, isNull, isUndefined } from '../../../utils/inspect';
|
|
5
|
-
import { sortKeys } from '../../../utils/object';
|
|
6
|
-
import { props as props$1, formOptionsMixin } from '../../../mixins/form-options';
|
|
7
|
-
|
|
8
|
-
// --- Props ---
|
|
9
|
-
|
|
10
|
-
const props = sortKeys({
|
|
11
|
-
...props$1,
|
|
12
|
-
labelField: {
|
|
13
|
-
type: PROP_TYPE_STRING,
|
|
14
|
-
required: false,
|
|
15
|
-
default: 'label'
|
|
16
|
-
},
|
|
17
|
-
optionsField: {
|
|
18
|
-
type: PROP_TYPE_STRING,
|
|
19
|
-
required: false,
|
|
20
|
-
default: 'options'
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// --- Mixin ---
|
|
25
|
-
|
|
26
|
-
// @vue/component
|
|
27
|
-
const optionsMixin = extend({
|
|
28
|
-
mixins: [formOptionsMixin],
|
|
29
|
-
props,
|
|
30
|
-
methods: {
|
|
31
|
-
normalizeOption(option) {
|
|
32
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
33
|
-
// When the option is an object, normalize it
|
|
34
|
-
if (isPlainObject(option)) {
|
|
35
|
-
const value = get(option, this.valueField);
|
|
36
|
-
const text = get(option, this.textField);
|
|
37
|
-
const options = get(option, this.optionsField, null);
|
|
38
|
-
// When it has options, create an `<optgroup>` object
|
|
39
|
-
if (!isNull(options)) {
|
|
40
|
-
return {
|
|
41
|
-
label: String(get(option, this.labelField) || text),
|
|
42
|
-
options: this.normalizeOptions(options)
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
// Otherwise create an `<option>` object
|
|
46
|
-
return {
|
|
47
|
-
value: isUndefined(value) ? key || text : value,
|
|
48
|
-
text: String(isUndefined(text) ? key : text),
|
|
49
|
-
html: get(option, this.htmlField),
|
|
50
|
-
disabled: Boolean(get(option, this.disabledField))
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
// Otherwise create an `<option>` object from the given value
|
|
54
|
-
return {
|
|
55
|
-
value: key || option,
|
|
56
|
-
text: String(option),
|
|
57
|
-
disabled: false
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
export { optionsMixin, props };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { extend } from '../../vue'
|
|
2
|
-
import { NAME_FORM_SELECT_OPTION_GROUP } from '../../constants/components'
|
|
3
|
-
import { SLOT_NAME_FIRST } from '../../constants/slots'
|
|
4
|
-
import { htmlOrText } from '../../utils/html'
|
|
5
|
-
import { sortKeys } from '../../utils/object'
|
|
6
|
-
import { formOptionsMixin, props as formOptionsProps } from '../../mixins/form-options'
|
|
7
|
-
import { normalizeSlotMixin } from '../../mixins/normalize-slot'
|
|
8
|
-
import { BFormSelectOption } from './form-select-option'
|
|
9
|
-
|
|
10
|
-
// --- Props ---
|
|
11
|
-
|
|
12
|
-
export const props = sortKeys({
|
|
13
|
-
...formOptionsProps,
|
|
14
|
-
label: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
// --- Main component ---
|
|
21
|
-
|
|
22
|
-
// @vue/component
|
|
23
|
-
export const BFormSelectOptionGroup = /*#__PURE__*/ extend({
|
|
24
|
-
name: NAME_FORM_SELECT_OPTION_GROUP,
|
|
25
|
-
mixins: [normalizeSlotMixin, formOptionsMixin],
|
|
26
|
-
props,
|
|
27
|
-
render(h) {
|
|
28
|
-
const { label } = this
|
|
29
|
-
|
|
30
|
-
const $options = this.formOptions.map((option, index) => {
|
|
31
|
-
const { value, text, html, disabled } = option
|
|
32
|
-
|
|
33
|
-
return h(BFormSelectOption, {
|
|
34
|
-
attrs: { value, disabled },
|
|
35
|
-
domProps: htmlOrText(html, text),
|
|
36
|
-
key: `option_${index}`
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
return h('optgroup', { attrs: { label } }, [
|
|
41
|
-
this.normalizeSlot(SLOT_NAME_FIRST),
|
|
42
|
-
$options,
|
|
43
|
-
this.normalizeSlot()
|
|
44
|
-
])
|
|
45
|
-
}
|
|
46
|
-
})
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { extend, mergeData } from '../../vue'
|
|
2
|
-
import { NAME_FORM_SELECT_OPTION } from '../../constants/components'
|
|
3
|
-
// --- Props ---
|
|
4
|
-
|
|
5
|
-
export const props = {
|
|
6
|
-
disabled: {
|
|
7
|
-
type: Boolean,
|
|
8
|
-
required: false,
|
|
9
|
-
default: false
|
|
10
|
-
},
|
|
11
|
-
value: {
|
|
12
|
-
required: true
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// --- Main component ---
|
|
17
|
-
|
|
18
|
-
// @vue/component
|
|
19
|
-
export const BFormSelectOption = /*#__PURE__*/ extend({
|
|
20
|
-
name: NAME_FORM_SELECT_OPTION,
|
|
21
|
-
functional: true,
|
|
22
|
-
props,
|
|
23
|
-
render(h, { props, data, children }) {
|
|
24
|
-
const { value, disabled } = props
|
|
25
|
-
|
|
26
|
-
return h(
|
|
27
|
-
'option',
|
|
28
|
-
mergeData(data, {
|
|
29
|
-
attrs: { disabled },
|
|
30
|
-
domProps: { value }
|
|
31
|
-
}),
|
|
32
|
-
children
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
})
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { extend } from '../../vue'
|
|
2
|
-
import { NAME_FORM_SELECT } from '../../constants/components'
|
|
3
|
-
import { EVENT_NAME_CHANGE, EVENT_NAME_INPUT } from '../../constants/events'
|
|
4
|
-
import { SLOT_NAME_FIRST } from '../../constants/slots'
|
|
5
|
-
import { from as arrayFrom } from '../../utils/array'
|
|
6
|
-
import { attemptBlur, attemptFocus } from '../../utils/dom'
|
|
7
|
-
import { htmlOrText } from '../../utils/html'
|
|
8
|
-
import { isArray } from '../../utils/inspect'
|
|
9
|
-
import { sortKeys } from '../../utils/object'
|
|
10
|
-
import { formControlMixin, props as formControlProps } from '../../mixins/form-control'
|
|
11
|
-
import { formCustomMixin, props as formCustomProps } from '../../mixins/form-custom'
|
|
12
|
-
import { formSizeMixin, props as formSizeProps } from '../../mixins/form-size'
|
|
13
|
-
import { formStateMixin, props as formStateProps } from '../../mixins/form-state'
|
|
14
|
-
import { normalizeSlotMixin } from '../../mixins/normalize-slot'
|
|
15
|
-
import { idMixin, props as idProps } from '../../mixins/id'
|
|
16
|
-
import { optionsMixin } from './helpers/mixin-options'
|
|
17
|
-
import { BFormSelectOption } from './form-select-option'
|
|
18
|
-
import { BFormSelectOptionGroup } from './form-select-option-group'
|
|
19
|
-
|
|
20
|
-
const MODEL_PROP_NAME = 'value'
|
|
21
|
-
const MODEL_EVENT_NAME = EVENT_NAME_INPUT
|
|
22
|
-
|
|
23
|
-
// --- Props ---
|
|
24
|
-
|
|
25
|
-
export const props = sortKeys({
|
|
26
|
-
...idProps,
|
|
27
|
-
[MODEL_PROP_NAME]: {},
|
|
28
|
-
...formControlProps,
|
|
29
|
-
...formCustomProps,
|
|
30
|
-
...formSizeProps,
|
|
31
|
-
...formStateProps,
|
|
32
|
-
ariaInvalid: {
|
|
33
|
-
type: [Boolean, String],
|
|
34
|
-
required: false,
|
|
35
|
-
default: false
|
|
36
|
-
},
|
|
37
|
-
multiple: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
required: false,
|
|
40
|
-
default: false
|
|
41
|
-
},
|
|
42
|
-
// Browsers default size to `0`, which shows 4 rows in most browsers in multiple mode
|
|
43
|
-
// Size of `1` can bork out Firefox
|
|
44
|
-
selectSize: {
|
|
45
|
-
type: Number,
|
|
46
|
-
required: false,
|
|
47
|
-
default: 0
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
// --- Main component ---
|
|
52
|
-
|
|
53
|
-
// @vue/component
|
|
54
|
-
export const BFormSelect = /*#__PURE__*/ extend({
|
|
55
|
-
name: NAME_FORM_SELECT,
|
|
56
|
-
mixins: [
|
|
57
|
-
idMixin,
|
|
58
|
-
formControlMixin,
|
|
59
|
-
formSizeMixin,
|
|
60
|
-
formStateMixin,
|
|
61
|
-
formCustomMixin,
|
|
62
|
-
optionsMixin,
|
|
63
|
-
normalizeSlotMixin
|
|
64
|
-
],
|
|
65
|
-
model: {
|
|
66
|
-
prop: MODEL_PROP_NAME,
|
|
67
|
-
event: MODEL_EVENT_NAME
|
|
68
|
-
},
|
|
69
|
-
props,
|
|
70
|
-
data() {
|
|
71
|
-
return {
|
|
72
|
-
localValue: this[MODEL_PROP_NAME]
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
computed: {
|
|
76
|
-
computedSelectSize() {
|
|
77
|
-
// Custom selects with a size of zero causes the arrows to be hidden,
|
|
78
|
-
// so dont render the size attribute in this case
|
|
79
|
-
return !this.plain && this.selectSize === 0 ? null : this.selectSize
|
|
80
|
-
},
|
|
81
|
-
inputClass() {
|
|
82
|
-
return [
|
|
83
|
-
this.plain ? 'form-control' : 'custom-select',
|
|
84
|
-
this.size && this.plain ? `form-control-${this.size}` : null,
|
|
85
|
-
this.size && !this.plain ? `custom-select-${this.size}` : null,
|
|
86
|
-
this.stateClass
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
watch: {
|
|
91
|
-
value(newValue) {
|
|
92
|
-
this.localValue = newValue
|
|
93
|
-
},
|
|
94
|
-
localValue() {
|
|
95
|
-
this.$emit(MODEL_EVENT_NAME, this.localValue)
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
methods: {
|
|
99
|
-
focus() {
|
|
100
|
-
attemptFocus(this.$refs.input)
|
|
101
|
-
},
|
|
102
|
-
blur() {
|
|
103
|
-
attemptBlur(this.$refs.input)
|
|
104
|
-
},
|
|
105
|
-
onChange(event) {
|
|
106
|
-
const { target } = event
|
|
107
|
-
const selectedValue = arrayFrom(target.options)
|
|
108
|
-
.filter(o => o.selected)
|
|
109
|
-
.map(o => ('_value' in o ? o._value : o.value))
|
|
110
|
-
|
|
111
|
-
this.localValue = target.multiple ? selectedValue : selectedValue[0]
|
|
112
|
-
|
|
113
|
-
this.$nextTick(() => {
|
|
114
|
-
this.$emit(EVENT_NAME_CHANGE, this.localValue)
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
render(h) {
|
|
119
|
-
const { name, disabled, required, computedSelectSize: size, localValue: value } = this
|
|
120
|
-
|
|
121
|
-
const $options = this.formOptions.map((option, index) => {
|
|
122
|
-
const { value, label, options, disabled } = option
|
|
123
|
-
const key = `option_${index}`
|
|
124
|
-
|
|
125
|
-
return isArray(options)
|
|
126
|
-
? h(BFormSelectOptionGroup, { props: { label, options }, key })
|
|
127
|
-
: h(BFormSelectOption, {
|
|
128
|
-
props: { value, disabled },
|
|
129
|
-
domProps: htmlOrText(option.html, option.text),
|
|
130
|
-
key
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
return h(
|
|
135
|
-
'select',
|
|
136
|
-
{
|
|
137
|
-
class: this.inputClass,
|
|
138
|
-
attrs: {
|
|
139
|
-
id: this.safeId(),
|
|
140
|
-
name,
|
|
141
|
-
form: this.form || null,
|
|
142
|
-
multiple: this.multiple || null,
|
|
143
|
-
size,
|
|
144
|
-
disabled,
|
|
145
|
-
required,
|
|
146
|
-
'aria-required': required ? 'true' : null,
|
|
147
|
-
'aria-invalid': this.computedAriaInvalid
|
|
148
|
-
},
|
|
149
|
-
on: { change: this.onChange },
|
|
150
|
-
directives: [{ name: 'model', value }],
|
|
151
|
-
ref: 'input'
|
|
152
|
-
},
|
|
153
|
-
[this.normalizeSlot(SLOT_NAME_FIRST), $options, this.normalizeSlot()]
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
})
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { extend } from '../../../vue'
|
|
2
|
-
import { PROP_TYPE_STRING } from '../../../constants/props'
|
|
3
|
-
import { get } from '../../../utils/get'
|
|
4
|
-
import { isNull, isPlainObject, isUndefined } from '../../../utils/inspect'
|
|
5
|
-
import { sortKeys } from '../../../utils/object'
|
|
6
|
-
import { formOptionsMixin, props as formOptionsProps } from '../../../mixins/form-options'
|
|
7
|
-
|
|
8
|
-
// --- Props ---
|
|
9
|
-
|
|
10
|
-
export const props = sortKeys({
|
|
11
|
-
...formOptionsProps,
|
|
12
|
-
labelField: {
|
|
13
|
-
type: PROP_TYPE_STRING,
|
|
14
|
-
required: false,
|
|
15
|
-
default: 'label'
|
|
16
|
-
},
|
|
17
|
-
optionsField: {
|
|
18
|
-
type: PROP_TYPE_STRING,
|
|
19
|
-
required: false,
|
|
20
|
-
default: 'options'
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// --- Mixin ---
|
|
25
|
-
|
|
26
|
-
// @vue/component
|
|
27
|
-
export const optionsMixin = extend({
|
|
28
|
-
mixins: [formOptionsMixin],
|
|
29
|
-
props,
|
|
30
|
-
methods: {
|
|
31
|
-
normalizeOption(option, key = null) {
|
|
32
|
-
// When the option is an object, normalize it
|
|
33
|
-
if (isPlainObject(option)) {
|
|
34
|
-
const value = get(option, this.valueField)
|
|
35
|
-
const text = get(option, this.textField)
|
|
36
|
-
const options = get(option, this.optionsField, null)
|
|
37
|
-
// When it has options, create an `<optgroup>` object
|
|
38
|
-
if (!isNull(options)) {
|
|
39
|
-
return {
|
|
40
|
-
label: String(get(option, this.labelField) || text),
|
|
41
|
-
options: this.normalizeOptions(options)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Otherwise create an `<option>` object
|
|
45
|
-
return {
|
|
46
|
-
value: isUndefined(value) ? key || text : value,
|
|
47
|
-
text: String(isUndefined(text) ? key : text),
|
|
48
|
-
html: get(option, this.htmlField),
|
|
49
|
-
disabled: Boolean(get(option, this.disabledField))
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Otherwise create an `<option>` object from the given value
|
|
53
|
-
return {
|
|
54
|
-
value: key || option,
|
|
55
|
-
text: String(option),
|
|
56
|
-
disabled: false
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
})
|