@volverjs/ui-vue 0.0.10-beta.40 → 0.0.10-beta.41
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/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +12 -3
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.es.js +183 -125
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +6 -0
- package/dist/components/VvCombobox/index.d.ts +54 -22
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +12 -3
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.es.js +79 -46
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +3 -0
- package/dist/components/VvSelect/index.d.ts +14 -0
- package/dist/components/index.es.js +183 -122
- package/dist/components/index.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/stories/Combobox/Combobox.stories.d.ts +1 -0
- package/dist/stories/Combobox/ComboboxMultiple.stories.d.ts +1 -0
- package/dist/stories/Select/Select.stories.d.ts +1 -0
- package/package.json +18 -18
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvCombobox/VvCombobox.vue +105 -97
- package/src/components/VvCombobox/index.ts +19 -2
- package/src/components/VvSelect/VvSelect.vue +66 -46
- package/src/components/VvSelect/index.ts +8 -1
- package/src/composables/useOptions.ts +12 -11
- package/src/stories/Combobox/Combobox.settings.ts +18 -3
- package/src/stories/Combobox/Combobox.stories.ts +8 -0
- package/src/stories/Combobox/Combobox.test.ts +6 -4
- package/src/stories/Combobox/ComboboxMultiple.stories.ts +9 -0
- package/src/stories/Combobox/ComboboxOptions.stories.ts +9 -13
- package/src/stories/Select/Select.stories.ts +8 -0
- package/src/stories/Select/Select.test.ts +5 -3
|
@@ -2410,18 +2410,6 @@ function resolveFieldData(data, field) {
|
|
|
2410
2410
|
return null;
|
|
2411
2411
|
}
|
|
2412
2412
|
}
|
|
2413
|
-
function findIndexInList(value, list) {
|
|
2414
|
-
let index = -1;
|
|
2415
|
-
if (list) {
|
|
2416
|
-
for (let i = 0; i < list.length; i++) {
|
|
2417
|
-
if (equals(list[i], value)) {
|
|
2418
|
-
index = i;
|
|
2419
|
-
break;
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
return index;
|
|
2424
|
-
}
|
|
2425
2413
|
function contains(value, list) {
|
|
2426
2414
|
if (value != null && list && list.length) {
|
|
2427
2415
|
for (const val of list) {
|
|
@@ -2435,14 +2423,6 @@ function contains(value, list) {
|
|
|
2435
2423
|
function isEmpty(value) {
|
|
2436
2424
|
return ((value2) => value2 === null || value2 === void 0 || value2 === "" || Array.isArray(value2) && value2.length === 0 || !(value2 instanceof Date) && typeof value2 === "object" && Object.keys(value2).length === 0)(unref(value));
|
|
2437
2425
|
}
|
|
2438
|
-
function removeFromList(value, list) {
|
|
2439
|
-
const indexElToRemove = findIndexInList(value, list);
|
|
2440
|
-
if (indexElToRemove > -1) {
|
|
2441
|
-
return list.filter((el, elIndex) => elIndex !== indexElToRemove);
|
|
2442
|
-
} else {
|
|
2443
|
-
return list;
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
2426
|
function isString(value) {
|
|
2447
2427
|
return typeof value === "string" || value instanceof String;
|
|
2448
2428
|
}
|
|
@@ -3188,21 +3168,30 @@ function useOptions(props) {
|
|
|
3188
3168
|
if (typeof option === "string") {
|
|
3189
3169
|
return option;
|
|
3190
3170
|
}
|
|
3171
|
+
if (typeof labelKey.value === "function") {
|
|
3172
|
+
return labelKey.value(option);
|
|
3173
|
+
}
|
|
3191
3174
|
return String(
|
|
3192
|
-
|
|
3175
|
+
labelKey.value ? get(option, labelKey.value) : option
|
|
3193
3176
|
);
|
|
3194
3177
|
};
|
|
3195
3178
|
const getOptionValue = (option) => {
|
|
3196
3179
|
if (typeof option === "string") {
|
|
3197
3180
|
return option;
|
|
3198
3181
|
}
|
|
3199
|
-
|
|
3182
|
+
if (typeof valueKey.value === "function") {
|
|
3183
|
+
return valueKey.value(option);
|
|
3184
|
+
}
|
|
3185
|
+
return valueKey.value ? get(option, valueKey.value) : option;
|
|
3200
3186
|
};
|
|
3201
3187
|
const isOptionDisabled = (option) => {
|
|
3202
3188
|
if (typeof option === "string") {
|
|
3203
3189
|
return false;
|
|
3204
3190
|
}
|
|
3205
|
-
|
|
3191
|
+
if (typeof disabledKey.value === "function") {
|
|
3192
|
+
return disabledKey.value(option);
|
|
3193
|
+
}
|
|
3194
|
+
return disabledKey.value ? get(option, disabledKey.value) : false;
|
|
3206
3195
|
};
|
|
3207
3196
|
const getOptionGrouped = (option) => {
|
|
3208
3197
|
if (typeof option == "string") {
|
|
@@ -4045,6 +4034,13 @@ const VvSelectProps = {
|
|
|
4045
4034
|
type: [String, Number, Boolean, Object, Array],
|
|
4046
4035
|
default: void 0
|
|
4047
4036
|
},
|
|
4037
|
+
/**
|
|
4038
|
+
* Select first option automatically
|
|
4039
|
+
*/
|
|
4040
|
+
autoselectFirst: {
|
|
4041
|
+
type: Boolean,
|
|
4042
|
+
default: false
|
|
4043
|
+
},
|
|
4048
4044
|
/**
|
|
4049
4045
|
* Select placeholder
|
|
4050
4046
|
*/
|
|
@@ -4102,13 +4098,21 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
4102
4098
|
VvSelectProps2,
|
|
4103
4099
|
props
|
|
4104
4100
|
);
|
|
4105
|
-
const
|
|
4101
|
+
const selectEl = ref();
|
|
4106
4102
|
const {
|
|
4107
4103
|
HintSlot,
|
|
4108
4104
|
hasHintLabelOrSlot,
|
|
4109
4105
|
hasInvalidLabelOrSlot,
|
|
4110
4106
|
hintSlotScope
|
|
4111
4107
|
} = HintSlotFactory(propsDefaults, slots);
|
|
4108
|
+
const { focused } = useComponentFocus(selectEl, emit);
|
|
4109
|
+
function isGroup(option) {
|
|
4110
|
+
var _a;
|
|
4111
|
+
if (typeof option === "string") {
|
|
4112
|
+
return false;
|
|
4113
|
+
}
|
|
4114
|
+
return (_a = option.options) == null ? void 0 : _a.length;
|
|
4115
|
+
}
|
|
4112
4116
|
const {
|
|
4113
4117
|
id,
|
|
4114
4118
|
modifiers,
|
|
@@ -4124,19 +4128,38 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
4124
4128
|
} = toRefs(props);
|
|
4125
4129
|
const hasId = useUniqueId(id);
|
|
4126
4130
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
4127
|
-
const
|
|
4128
|
-
const
|
|
4131
|
+
const isDisabledOrReadonly = computed(() => props.disabled || props.readonly);
|
|
4132
|
+
const hasTabindex = computed(() => {
|
|
4133
|
+
return isDisabledOrReadonly.value ? -1 : props.tabindex;
|
|
4134
|
+
});
|
|
4135
|
+
const localModelValue = computed({
|
|
4136
|
+
get: () => {
|
|
4137
|
+
return props.modelValue;
|
|
4138
|
+
},
|
|
4139
|
+
set: (newValue) => {
|
|
4140
|
+
if (Array.isArray(newValue)) {
|
|
4141
|
+
newValue = newValue.filter((item) => item !== void 0);
|
|
4142
|
+
if (newValue.length === 0 && !props.unselectable) {
|
|
4143
|
+
selectEl.value.value = props.modelValue;
|
|
4144
|
+
return;
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
emit("update:modelValue", newValue);
|
|
4148
|
+
}
|
|
4149
|
+
});
|
|
4150
|
+
const isDirty = computed(() => {
|
|
4151
|
+
if (Array.isArray(localModelValue.value)) {
|
|
4152
|
+
return localModelValue.value.length > 0;
|
|
4153
|
+
}
|
|
4154
|
+
return localModelValue.value !== void 0 && localModelValue.value !== null;
|
|
4155
|
+
});
|
|
4156
|
+
const isVisible = useElementVisibility(selectEl);
|
|
4129
4157
|
watch(isVisible, (newValue) => {
|
|
4130
4158
|
if (newValue && props.autofocus) {
|
|
4131
4159
|
focused.value = true;
|
|
4132
4160
|
}
|
|
4133
4161
|
});
|
|
4134
4162
|
const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition);
|
|
4135
|
-
const isDirty = computed(() => !isEmpty(props.modelValue));
|
|
4136
|
-
const isDisabled = computed(() => props.disabled || props.readonly);
|
|
4137
|
-
const hasTabindex = computed(() => {
|
|
4138
|
-
return isDisabled.value ? -1 : props.tabindex;
|
|
4139
|
-
});
|
|
4140
4163
|
const isInvalid = computed(() => {
|
|
4141
4164
|
if (props.invalid === true) {
|
|
4142
4165
|
return true;
|
|
@@ -4163,11 +4186,27 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
4163
4186
|
"multiple": multiple.value
|
|
4164
4187
|
}))
|
|
4165
4188
|
);
|
|
4189
|
+
const {
|
|
4190
|
+
getOptionLabel,
|
|
4191
|
+
getOptionValue,
|
|
4192
|
+
isOptionDisabled,
|
|
4193
|
+
getOptionGrouped
|
|
4194
|
+
} = useOptions(props);
|
|
4195
|
+
watch(
|
|
4196
|
+
() => props.options,
|
|
4197
|
+
(newValue) => {
|
|
4198
|
+
if ((newValue == null ? void 0 : newValue.length) && props.autoselectFirst && !isDirty.value) {
|
|
4199
|
+
const firstOptionValue = getOptionValue(newValue[0]);
|
|
4200
|
+
localModelValue.value = props.multiple ? [firstOptionValue] : firstOptionValue;
|
|
4201
|
+
}
|
|
4202
|
+
},
|
|
4203
|
+
{ immediate: true }
|
|
4204
|
+
);
|
|
4166
4205
|
const hasAttrs = computed(() => {
|
|
4167
4206
|
return {
|
|
4168
4207
|
"name": props.name,
|
|
4169
4208
|
"tabindex": hasTabindex.value,
|
|
4170
|
-
"disabled":
|
|
4209
|
+
"disabled": isDisabledOrReadonly.value,
|
|
4171
4210
|
"required": props.required,
|
|
4172
4211
|
"size": props.size,
|
|
4173
4212
|
"autocomplete": props.autocomplete,
|
|
@@ -4182,30 +4221,6 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
4182
4221
|
invalid: props.invalid,
|
|
4183
4222
|
modelValue: props.modelValue
|
|
4184
4223
|
}));
|
|
4185
|
-
const {
|
|
4186
|
-
getOptionLabel,
|
|
4187
|
-
getOptionValue,
|
|
4188
|
-
isOptionDisabled,
|
|
4189
|
-
getOptionGrouped
|
|
4190
|
-
} = useOptions(props);
|
|
4191
|
-
const localModelValue = computed({
|
|
4192
|
-
get: () => {
|
|
4193
|
-
return props.modelValue;
|
|
4194
|
-
},
|
|
4195
|
-
set: (newValue) => {
|
|
4196
|
-
if (Array.isArray(newValue)) {
|
|
4197
|
-
newValue = newValue.filter((item) => item !== void 0);
|
|
4198
|
-
}
|
|
4199
|
-
emit("update:modelValue", newValue);
|
|
4200
|
-
}
|
|
4201
|
-
});
|
|
4202
|
-
function isGroup(option) {
|
|
4203
|
-
var _a;
|
|
4204
|
-
if (typeof option === "string") {
|
|
4205
|
-
return false;
|
|
4206
|
-
}
|
|
4207
|
-
return (_a = option.options) == null ? void 0 : _a.length;
|
|
4208
|
-
}
|
|
4209
4224
|
return (_ctx, _cache) => {
|
|
4210
4225
|
return openBlock(), createElementBlock(
|
|
4211
4226
|
"div",
|
|
@@ -4231,10 +4246,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
4231
4246
|
)) : createCommentVNode("v-if", true),
|
|
4232
4247
|
withDirectives(createElementVNode("select", mergeProps({
|
|
4233
4248
|
id: unref(hasId),
|
|
4234
|
-
ref_key: "
|
|
4235
|
-
ref:
|
|
4249
|
+
ref_key: "selectEl",
|
|
4250
|
+
ref: selectEl
|
|
4251
|
+
}, unref(hasAttrs), {
|
|
4236
4252
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(localModelValue) ? localModelValue.value = $event : null)
|
|
4237
|
-
}
|
|
4253
|
+
}), [
|
|
4238
4254
|
_ctx.placeholder ? (openBlock(), createElementBlock("option", {
|
|
4239
4255
|
key: 0,
|
|
4240
4256
|
value: void 0,
|
|
@@ -4351,7 +4367,6 @@ const VvComboboxProps = {
|
|
|
4351
4367
|
...OptionsProps,
|
|
4352
4368
|
...IconProps,
|
|
4353
4369
|
...FloatingLabelProps,
|
|
4354
|
-
...UnselectableProps,
|
|
4355
4370
|
...DropdownProps,
|
|
4356
4371
|
...LabelProps,
|
|
4357
4372
|
/**
|
|
@@ -4429,10 +4444,22 @@ const VvComboboxProps = {
|
|
|
4429
4444
|
* Manage modelValue as string[] or object[]
|
|
4430
4445
|
*/
|
|
4431
4446
|
multiple: Boolean,
|
|
4447
|
+
/**
|
|
4448
|
+
* The min number of selected values
|
|
4449
|
+
*/
|
|
4450
|
+
minValues: {
|
|
4451
|
+
type: [Number, String],
|
|
4452
|
+
default: 0
|
|
4453
|
+
},
|
|
4432
4454
|
/**
|
|
4433
4455
|
* The max number of selected values
|
|
4434
4456
|
*/
|
|
4435
4457
|
maxValues: [Number, String],
|
|
4458
|
+
/**
|
|
4459
|
+
* If true the input will be unselectable
|
|
4460
|
+
* @deprecated use minValues instead
|
|
4461
|
+
*/
|
|
4462
|
+
unselectable: { type: Boolean, default: true },
|
|
4436
4463
|
/**
|
|
4437
4464
|
* The select label separator visible to the user
|
|
4438
4465
|
*/
|
|
@@ -4473,6 +4500,13 @@ const VvComboboxProps = {
|
|
|
4473
4500
|
type: Boolean,
|
|
4474
4501
|
default: false
|
|
4475
4502
|
},
|
|
4503
|
+
/**
|
|
4504
|
+
* Select first option automatically
|
|
4505
|
+
*/
|
|
4506
|
+
autoselectFirst: {
|
|
4507
|
+
type: Boolean,
|
|
4508
|
+
default: false
|
|
4509
|
+
},
|
|
4476
4510
|
/**
|
|
4477
4511
|
* Keep open dropdown on single select
|
|
4478
4512
|
*/
|
|
@@ -4535,22 +4569,16 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4535
4569
|
VvComboboxProps2,
|
|
4536
4570
|
props
|
|
4537
4571
|
);
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
}
|
|
4543
|
-
return (_a = option.options) == null ? void 0 : _a.length;
|
|
4544
|
-
}
|
|
4572
|
+
const inputEl = ref(null);
|
|
4573
|
+
const inputSearchEl = ref(null);
|
|
4574
|
+
const wrapperEl = ref(null);
|
|
4575
|
+
const dropdownEl = ref(null);
|
|
4545
4576
|
const {
|
|
4546
4577
|
HintSlot,
|
|
4547
4578
|
hasHintLabelOrSlot,
|
|
4548
4579
|
hasInvalidLabelOrSlot,
|
|
4549
4580
|
hintSlotScope
|
|
4550
4581
|
} = HintSlotFactory(propsDefaults, slots);
|
|
4551
|
-
const inputEl = ref(null);
|
|
4552
|
-
const inputSearchEl = ref(null);
|
|
4553
|
-
const wrapperEl = ref(null);
|
|
4554
4582
|
const { focused } = useComponentFocus(inputEl, emit);
|
|
4555
4583
|
const { focused: focusedWithin } = useFocusWithin(wrapperEl);
|
|
4556
4584
|
watch(focused, (newValue) => {
|
|
@@ -4581,17 +4609,17 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4581
4609
|
});
|
|
4582
4610
|
const expanded = ref(false);
|
|
4583
4611
|
function toggleExpanded() {
|
|
4584
|
-
if (
|
|
4612
|
+
if (isDisabledOrReadonly.value)
|
|
4585
4613
|
return;
|
|
4586
4614
|
expanded.value = !expanded.value;
|
|
4587
4615
|
}
|
|
4588
4616
|
function expand() {
|
|
4589
|
-
if (
|
|
4617
|
+
if (isDisabledOrReadonly.value || expanded.value)
|
|
4590
4618
|
return;
|
|
4591
4619
|
expanded.value = true;
|
|
4592
4620
|
}
|
|
4593
4621
|
function collapse() {
|
|
4594
|
-
if (
|
|
4622
|
+
if (isDisabledOrReadonly.value || !expanded.value)
|
|
4595
4623
|
return;
|
|
4596
4624
|
expanded.value = false;
|
|
4597
4625
|
}
|
|
@@ -4609,6 +4637,13 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4609
4637
|
searchText.value = "";
|
|
4610
4638
|
}
|
|
4611
4639
|
}
|
|
4640
|
+
function isGroup(option) {
|
|
4641
|
+
var _a;
|
|
4642
|
+
if (typeof option === "string") {
|
|
4643
|
+
return false;
|
|
4644
|
+
}
|
|
4645
|
+
return (_a = option.options) == null ? void 0 : _a.length;
|
|
4646
|
+
}
|
|
4612
4647
|
const {
|
|
4613
4648
|
id,
|
|
4614
4649
|
icon,
|
|
@@ -4626,14 +4661,53 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4626
4661
|
const hasDropdownId = computed(() => `${hasId.value}-dropdown`);
|
|
4627
4662
|
const hasSearchId = computed(() => `${hasId.value}-search`);
|
|
4628
4663
|
const hasLabelId = computed(() => `${hasId.value}-label`);
|
|
4664
|
+
const isDisabledOrReadonly = computed(() => props.disabled || props.readonly);
|
|
4665
|
+
const hasTabindex = computed(() => {
|
|
4666
|
+
return isDisabledOrReadonly.value ? -1 : props.tabindex;
|
|
4667
|
+
});
|
|
4668
|
+
const localModelValue = computed({
|
|
4669
|
+
get: () => {
|
|
4670
|
+
if (Array.isArray(props.modelValue)) {
|
|
4671
|
+
return new Set(props.modelValue);
|
|
4672
|
+
}
|
|
4673
|
+
return props.modelValue !== void 0 && props.modelValue !== null ? /* @__PURE__ */ new Set([props.modelValue]) : /* @__PURE__ */ new Set();
|
|
4674
|
+
},
|
|
4675
|
+
set: (value) => {
|
|
4676
|
+
emit("update:modelValue", props.multiple ? [...value] : [...value].pop());
|
|
4677
|
+
}
|
|
4678
|
+
});
|
|
4679
|
+
const sizeOfModelValue = computed(() => localModelValue.value.size);
|
|
4680
|
+
const isDirty = computed(() => sizeOfModelValue.value > 0);
|
|
4681
|
+
const hasMaxValues = computed(() => {
|
|
4682
|
+
if (!props.multiple) {
|
|
4683
|
+
return 1;
|
|
4684
|
+
}
|
|
4685
|
+
if (props.maxValues === void 0) {
|
|
4686
|
+
return Infinity;
|
|
4687
|
+
}
|
|
4688
|
+
return Number(props.maxValues);
|
|
4689
|
+
});
|
|
4690
|
+
const isUnselectable = computed(() => {
|
|
4691
|
+
if (isDisabledOrReadonly.value) {
|
|
4692
|
+
return false;
|
|
4693
|
+
}
|
|
4694
|
+
if (!props.unselectable) {
|
|
4695
|
+
return false;
|
|
4696
|
+
}
|
|
4697
|
+
return sizeOfModelValue.value > Number(props.minValues);
|
|
4698
|
+
});
|
|
4699
|
+
const isSelectable = computed(() => {
|
|
4700
|
+
if (isDisabledOrReadonly.value) {
|
|
4701
|
+
return false;
|
|
4702
|
+
}
|
|
4703
|
+
if (!props.multiple) {
|
|
4704
|
+
return true;
|
|
4705
|
+
}
|
|
4706
|
+
return sizeOfModelValue.value < hasMaxValues.value;
|
|
4707
|
+
});
|
|
4629
4708
|
const localLoading = ref(false);
|
|
4630
4709
|
const isLoading = computed(() => localLoading.value || loading.value);
|
|
4631
|
-
const dropdownEl = ref();
|
|
4632
4710
|
const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition);
|
|
4633
|
-
const isDirty = computed(() => !isEmpty(props.modelValue));
|
|
4634
|
-
const hasTabindex = computed(() => {
|
|
4635
|
-
return disabled.value || readonly.value ? -1 : props.tabindex;
|
|
4636
|
-
});
|
|
4637
4711
|
const bemCssClasses = useModifiers(
|
|
4638
4712
|
"vv-select",
|
|
4639
4713
|
modifiers,
|
|
@@ -4657,6 +4731,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4657
4731
|
getOptionGrouped,
|
|
4658
4732
|
isOptionDisabled
|
|
4659
4733
|
} = useOptions(props);
|
|
4734
|
+
function isOptionDisabledOrNotSelectable(option) {
|
|
4735
|
+
return isOptionDisabled(option) || !isSelectable.value && !isOptionSelected(option);
|
|
4736
|
+
}
|
|
4660
4737
|
const filteredOptions = computedAsync(async () => {
|
|
4661
4738
|
var _a;
|
|
4662
4739
|
if (propsDefaults.value.searchFunction) {
|
|
@@ -4675,10 +4752,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4675
4752
|
});
|
|
4676
4753
|
});
|
|
4677
4754
|
function isOptionSelected(option) {
|
|
4678
|
-
|
|
4679
|
-
return contains(option, props.modelValue) || contains(getOptionValue(option), props.modelValue);
|
|
4680
|
-
}
|
|
4681
|
-
return equals(option, props.modelValue) || equals(getOptionValue(option), props.modelValue);
|
|
4755
|
+
return localModelValue.value.has(getOptionValue(option));
|
|
4682
4756
|
}
|
|
4683
4757
|
const selectedOptions = computed(() => {
|
|
4684
4758
|
const options = props.options.reduce(
|
|
@@ -4701,40 +4775,26 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4701
4775
|
props.autoOpen ? expand() : toggleExpanded();
|
|
4702
4776
|
}
|
|
4703
4777
|
function onInput(option) {
|
|
4704
|
-
|
|
4705
|
-
if (
|
|
4706
|
-
|
|
4707
|
-
}
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
if (props.maxValues !== void 0 && maxValues >= 0 && ((_a = props.modelValue) == null ? void 0 : _a.length) >= maxValues) {
|
|
4714
|
-
if (!contains(value, props.modelValue)) {
|
|
4715
|
-
return;
|
|
4716
|
-
}
|
|
4717
|
-
}
|
|
4718
|
-
toReturn = contains(value, props.modelValue) ? removeFromList(value, props.modelValue) : [...props.modelValue, value];
|
|
4719
|
-
} else {
|
|
4720
|
-
toReturn = [value];
|
|
4721
|
-
}
|
|
4722
|
-
} else {
|
|
4723
|
-
if (!props.keepOpen) {
|
|
4724
|
-
collapse();
|
|
4725
|
-
}
|
|
4726
|
-
if (Array.isArray(props.modelValue)) {
|
|
4727
|
-
if (props.unselectable && props.modelValue.includes(value)) {
|
|
4728
|
-
toReturn = [];
|
|
4729
|
-
} else {
|
|
4730
|
-
toReturn = [value];
|
|
4731
|
-
}
|
|
4732
|
-
} else if (props.unselectable && value === props.modelValue) {
|
|
4733
|
-
toReturn = void 0;
|
|
4734
|
-
}
|
|
4778
|
+
const isSelected = isOptionSelected(option);
|
|
4779
|
+
if (isSelected && isUnselectable.value) {
|
|
4780
|
+
localModelValue.value.delete(getOptionValue(option));
|
|
4781
|
+
} else if (!isSelected && isSelectable.value) {
|
|
4782
|
+
localModelValue.value.add(getOptionValue(option));
|
|
4783
|
+
}
|
|
4784
|
+
localModelValue.value = new Set(localModelValue.value);
|
|
4785
|
+
if (!props.multiple && !props.keepOpen) {
|
|
4786
|
+
collapse();
|
|
4735
4787
|
}
|
|
4736
|
-
emit("update:modelValue", toReturn);
|
|
4737
4788
|
}
|
|
4789
|
+
watch(
|
|
4790
|
+
() => props.options,
|
|
4791
|
+
(newValue) => {
|
|
4792
|
+
if ((newValue == null ? void 0 : newValue.length) && props.autoselectFirst && !isDirty.value) {
|
|
4793
|
+
onInput(newValue[0]);
|
|
4794
|
+
}
|
|
4795
|
+
},
|
|
4796
|
+
{ immediate: true }
|
|
4797
|
+
);
|
|
4738
4798
|
const selectProps = computed(() => ({
|
|
4739
4799
|
id: hasId.value,
|
|
4740
4800
|
name: props.name,
|
|
@@ -4755,7 +4815,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4755
4815
|
icon: propsDefaults.value.icon,
|
|
4756
4816
|
iconPosition: propsDefaults.value.iconPosition,
|
|
4757
4817
|
floating: propsDefaults.value.floating,
|
|
4758
|
-
unselectable:
|
|
4818
|
+
unselectable: isUnselectable.value,
|
|
4819
|
+
autoselectFirst: propsDefaults.value.autoselectFirst,
|
|
4759
4820
|
multiple: propsDefaults.value.multiple,
|
|
4760
4821
|
label: propsDefaults.value.label,
|
|
4761
4822
|
placeholder: propsDefaults.value.placeholder,
|
|
@@ -4876,7 +4937,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4876
4937
|
1
|
|
4877
4938
|
/* TEXT */
|
|
4878
4939
|
),
|
|
4879
|
-
|
|
4940
|
+
unref(isUnselectable) ? (openBlock(), createElementBlock("button", {
|
|
4880
4941
|
key: 0,
|
|
4881
4942
|
"aria-label": unref(propsDefaults).deselectActionLabel,
|
|
4882
4943
|
type: "button",
|
|
@@ -4948,8 +5009,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4948
5009
|
), (item, i) => {
|
|
4949
5010
|
return openBlock(), createBlock(_sfc_main$g, mergeProps({ ref_for: true }, {
|
|
4950
5011
|
selected: isOptionSelected(item),
|
|
4951
|
-
disabled:
|
|
4952
|
-
unselectable:
|
|
5012
|
+
disabled: isOptionDisabledOrNotSelectable(item),
|
|
5013
|
+
unselectable: unref(isUnselectable),
|
|
4953
5014
|
deselectHintLabel: unref(propsDefaults).deselectHintLabel,
|
|
4954
5015
|
selectHintLabel: unref(propsDefaults).selectHintLabel,
|
|
4955
5016
|
selectedHintLabel: unref(propsDefaults).selectedHintLabel
|
|
@@ -4964,7 +5025,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4964
5025
|
option,
|
|
4965
5026
|
selectedOptions: unref(selectedOptions),
|
|
4966
5027
|
selected: isOptionSelected(item),
|
|
4967
|
-
disabled:
|
|
5028
|
+
disabled: isOptionDisabledOrNotSelectable(item)
|
|
4968
5029
|
}), () => [
|
|
4969
5030
|
createTextVNode(
|
|
4970
5031
|
toDisplayString(unref(getOptionLabel)(item)),
|
|
@@ -4988,8 +5049,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4988
5049
|
ref_for: true
|
|
4989
5050
|
}, {
|
|
4990
5051
|
selected: isOptionSelected(option),
|
|
4991
|
-
disabled:
|
|
4992
|
-
unselectable:
|
|
5052
|
+
disabled: isOptionDisabledOrNotSelectable(option),
|
|
5053
|
+
unselectable: unref(isUnselectable),
|
|
4993
5054
|
deselectHintLabel: unref(propsDefaults).deselectHintLabel,
|
|
4994
5055
|
selectHintLabel: unref(propsDefaults).selectHintLabel,
|
|
4995
5056
|
selectedHintLabel: unref(propsDefaults).selectedHintLabel
|
|
@@ -5003,7 +5064,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
5003
5064
|
option,
|
|
5004
5065
|
selectedOptions: unref(selectedOptions),
|
|
5005
5066
|
selected: isOptionSelected(option),
|
|
5006
|
-
disabled:
|
|
5067
|
+
disabled: isOptionDisabledOrNotSelectable(option)
|
|
5007
5068
|
}), () => [
|
|
5008
5069
|
createTextVNode(
|
|
5009
5070
|
toDisplayString(unref(getOptionLabel)(option)),
|