@ouestfrance/sipa-bms-ui 8.9.0 → 8.9.2

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.
@@ -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.splice(-1);
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
- modelValue.value.push(option);
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.value !== value);
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 displayedOptions = vue.computed(
68500
- () => props.options.filter((o) => searchString(o.label, searching.value)).filter(
68501
- (o) => !modelValue.value.find((option) => option.value === o.value)
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 displayValues = vue.computed(
68505
- () => modelValue.value.filter(
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: displayedOptions.value,
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(displayValues.value, (tag) => {
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-05d9b16f"]]);
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",
@@ -89587,7 +89601,7 @@
89587
89601
  }
89588
89602
  });
89589
89603
 
89590
- const BmsStepper = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-c872a497"]]);
89604
+ const BmsStepper = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-c132d5cd"]]);
89591
89605
 
89592
89606
  const historyRoutes = vue.ref([]);
89593
89607
  const useRouterHistory = () => {