@ouestfrance/sipa-bms-ui 8.9.0 → 8.9.1
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/form/BmsMultiSelect.vue.d.ts +4 -4
- package/dist/sipa-bms-ui.css +5 -5
- package/dist/sipa-bms-ui.es.js +33 -19
- package/dist/sipa-bms-ui.es.js.map +1 -1
- package/dist/sipa-bms-ui.umd.js +33 -19
- package/dist/sipa-bms-ui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/BmsMultiSelect.stories.js +6 -6
- package/src/components/form/BmsMultiSelect.vue +45 -20
- package/src/showroom/pages/autocomplete.vue +12 -2
package/dist/sipa-bms-ui.umd.js
CHANGED
|
@@ -68461,9 +68461,7 @@
|
|
|
68461
68461
|
disabled: { type: Boolean, default: false },
|
|
68462
68462
|
small: { type: Boolean }
|
|
68463
68463
|
}, {
|
|
68464
|
-
"modelValue": {
|
|
68465
|
-
required: true
|
|
68466
|
-
},
|
|
68464
|
+
"modelValue": { default: [] },
|
|
68467
68465
|
"modelModifiers": {}
|
|
68468
68466
|
}),
|
|
68469
68467
|
emits: ["update:modelValue"],
|
|
@@ -68475,8 +68473,12 @@
|
|
|
68475
68473
|
const openDatalist = () => isDatalistOpen.value = true;
|
|
68476
68474
|
const searching = vue.ref("");
|
|
68477
68475
|
const modelValue = vue.useModel(__props, "modelValue");
|
|
68476
|
+
onClickOutside(inputElement, closeDatalist, {
|
|
68477
|
+
ignore: [".datalist-option", ".icon-toggle-button"]
|
|
68478
|
+
});
|
|
68478
68479
|
const onBackspace = () => {
|
|
68479
|
-
modelValue.value.
|
|
68480
|
+
if (searching.value.length === 0 && modelValue.value && modelValue.value.length > 0)
|
|
68481
|
+
modelValue.value.splice(-1);
|
|
68480
68482
|
};
|
|
68481
68483
|
const setFocus = () => {
|
|
68482
68484
|
if (inputElement.value) {
|
|
@@ -68484,38 +68486,50 @@
|
|
|
68484
68486
|
}
|
|
68485
68487
|
};
|
|
68486
68488
|
const onSelect = (option) => {
|
|
68487
|
-
|
|
68489
|
+
if (typeof option === "string") {
|
|
68490
|
+
modelValue.value = (modelValue.value ?? []).concat(option);
|
|
68491
|
+
} else if (option.value) {
|
|
68492
|
+
modelValue.value = (modelValue.value ?? []).concat(option.value);
|
|
68493
|
+
}
|
|
68488
68494
|
searching.value = "";
|
|
68489
68495
|
setFocus();
|
|
68490
68496
|
closeDatalist();
|
|
68491
68497
|
};
|
|
68492
68498
|
const removeOption = (value) => {
|
|
68493
|
-
modelValue.value = modelValue.value.filter((o) => o
|
|
68499
|
+
modelValue.value = (modelValue.value ?? []).filter((o) => o !== value);
|
|
68494
68500
|
};
|
|
68495
68501
|
const clearInput = () => {
|
|
68496
68502
|
modelValue.value = [];
|
|
68497
68503
|
searching.value = "";
|
|
68498
68504
|
};
|
|
68499
|
-
const
|
|
68500
|
-
(
|
|
68501
|
-
|
|
68502
|
-
)
|
|
68505
|
+
const selectedItems = vue.computed(() => {
|
|
68506
|
+
if (!modelValue.value) return [];
|
|
68507
|
+
const items = [];
|
|
68508
|
+
modelValue.value.forEach((selectedValue) => {
|
|
68509
|
+
const item = optionsLabelValue.value.find(
|
|
68510
|
+
(option) => option.value === selectedValue
|
|
68511
|
+
);
|
|
68512
|
+
if (item) items.push(item);
|
|
68513
|
+
});
|
|
68514
|
+
return items;
|
|
68515
|
+
});
|
|
68516
|
+
const optionsLabelValue = vue.computed(
|
|
68517
|
+
() => Array.isArray(props.options) && !!props.options.length && typeof props.options[0] === "string" ? props.options.map((o) => ({ label: o, value: o })) : props.options
|
|
68503
68518
|
);
|
|
68504
|
-
const
|
|
68505
|
-
() =>
|
|
68506
|
-
(o) => props.options.find((option) => option.value === o.value)
|
|
68507
|
-
)
|
|
68519
|
+
const filteredOptions = vue.computed(
|
|
68520
|
+
() => optionsLabelValue.value.filter((o) => searchString(o.label, searching.value))
|
|
68508
68521
|
);
|
|
68509
68522
|
return (_ctx, _cache) => {
|
|
68510
68523
|
return vue.openBlock(), vue.createBlock(RawSelect, vue.mergeProps(_ctx.$props, {
|
|
68511
|
-
options:
|
|
68524
|
+
options: filteredOptions.value,
|
|
68512
68525
|
"model-value": modelValue.value,
|
|
68513
68526
|
open: isDatalistOpen.value,
|
|
68514
|
-
onSelect
|
|
68527
|
+
onSelect,
|
|
68528
|
+
onClick: setFocus
|
|
68515
68529
|
}), {
|
|
68516
68530
|
input: vue.withCtx(() => [
|
|
68517
68531
|
vue.createElementVNode("div", _hoisted_1$F, [
|
|
68518
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(
|
|
68532
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(selectedItems.value, (tag) => {
|
|
68519
68533
|
return vue.openBlock(), vue.createBlock(BmsTag, {
|
|
68520
68534
|
small: _ctx.small,
|
|
68521
68535
|
active: "",
|
|
@@ -68546,7 +68560,7 @@
|
|
|
68546
68560
|
])
|
|
68547
68561
|
]),
|
|
68548
68562
|
vue.createElementVNode("span", _hoisted_2$r, [
|
|
68549
|
-
modelValue.value.length ? (vue.openBlock(), vue.createBlock(vue.unref(X), {
|
|
68563
|
+
modelValue.value && modelValue.value?.length ? (vue.openBlock(), vue.createBlock(vue.unref(X), {
|
|
68550
68564
|
key: 0,
|
|
68551
68565
|
class: "icon icon-clear",
|
|
68552
68566
|
onClick: vue.withModifiers(clearInput, ["stop"])
|
|
@@ -68581,7 +68595,7 @@
|
|
|
68581
68595
|
}
|
|
68582
68596
|
});
|
|
68583
68597
|
|
|
68584
|
-
const BmsMultiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$O, [["__scopeId", "data-v-
|
|
68598
|
+
const BmsMultiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$O, [["__scopeId", "data-v-aece870d"]]);
|
|
68585
68599
|
|
|
68586
68600
|
const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
|
|
68587
68601
|
__name: "BmsSearch",
|