@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.
@@ -1,17 +1,17 @@
1
1
  import { InputOption } from '../../models';
2
2
  import { FieldComponentProps } from '../../plugins/field/field-component.model';
3
3
  export interface Props extends FieldComponentProps {
4
- options: InputOption[];
4
+ options: InputOption[] | string[];
5
5
  placeholder?: string;
6
6
  }
7
7
  type __VLS_Props = Props;
8
8
  type __VLS_PublicProps = {
9
- 'modelValue': InputOption[];
9
+ 'modelValue'?: string[] | null;
10
10
  } & __VLS_Props;
11
11
  declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
12
- "update:modelValue": (value: InputOption[]) => any;
12
+ "update:modelValue": (value: string[] | null) => any;
13
13
  }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
- "onUpdate:modelValue"?: ((value: InputOption[]) => any) | undefined;
14
+ "onUpdate:modelValue"?: ((value: string[] | null) => any) | undefined;
15
15
  }>, {
16
16
  label: string;
17
17
  required: boolean;
@@ -1188,28 +1188,28 @@ input[type=radio][data-v-c0c9efa3]:checked::before {
1188
1188
  --field-border-color: var(--bms-grey-25);
1189
1189
  --input-background-color: var(--bms-grey-25);
1190
1190
  pointer-events: none;
1191
- }.tags[data-v-05d9b16f] {
1191
+ }.tags[data-v-aece870d] {
1192
1192
  display: flex;
1193
1193
  gap: 0.5em;
1194
1194
  padding: var(--field-margin);
1195
1195
  flex-wrap: wrap;
1196
1196
  width: 100%;
1197
1197
  }
1198
- .tags .search[data-v-05d9b16f] {
1198
+ .tags .search[data-v-aece870d] {
1199
1199
  outline: none;
1200
1200
  border: none;
1201
1201
  background-color: transparent;
1202
1202
  flex-grow: 1;
1203
1203
  }
1204
- .icon-container[data-v-05d9b16f] {
1204
+ .icon-container[data-v-aece870d] {
1205
1205
  height: 100%;
1206
1206
  display: flex;
1207
1207
  align-items: center;
1208
1208
  }
1209
- .icon-container[data-v-05d9b16f]:hover {
1209
+ .icon-container[data-v-aece870d]:hover {
1210
1210
  cursor: pointer;
1211
1211
  }
1212
- .icon-container .icon[data-v-05d9b16f] {
1212
+ .icon-container .icon[data-v-aece870d] {
1213
1213
  display: block;
1214
1214
  width: 1em;
1215
1215
  height: 1em;
@@ -68458,9 +68458,7 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
68458
68458
  disabled: { type: Boolean, default: false },
68459
68459
  small: { type: Boolean }
68460
68460
  }, {
68461
- "modelValue": {
68462
- required: true
68463
- },
68461
+ "modelValue": { default: [] },
68464
68462
  "modelModifiers": {}
68465
68463
  }),
68466
68464
  emits: ["update:modelValue"],
@@ -68472,8 +68470,12 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
68472
68470
  const openDatalist = () => isDatalistOpen.value = true;
68473
68471
  const searching = ref("");
68474
68472
  const modelValue = useModel(__props, "modelValue");
68473
+ onClickOutside(inputElement, closeDatalist, {
68474
+ ignore: [".datalist-option", ".icon-toggle-button"]
68475
+ });
68475
68476
  const onBackspace = () => {
68476
- modelValue.value.splice(-1);
68477
+ if (searching.value.length === 0 && modelValue.value && modelValue.value.length > 0)
68478
+ modelValue.value.splice(-1);
68477
68479
  };
68478
68480
  const setFocus = () => {
68479
68481
  if (inputElement.value) {
@@ -68481,38 +68483,50 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
68481
68483
  }
68482
68484
  };
68483
68485
  const onSelect = (option) => {
68484
- modelValue.value.push(option);
68486
+ if (typeof option === "string") {
68487
+ modelValue.value = (modelValue.value ?? []).concat(option);
68488
+ } else if (option.value) {
68489
+ modelValue.value = (modelValue.value ?? []).concat(option.value);
68490
+ }
68485
68491
  searching.value = "";
68486
68492
  setFocus();
68487
68493
  closeDatalist();
68488
68494
  };
68489
68495
  const removeOption = (value) => {
68490
- modelValue.value = modelValue.value.filter((o) => o.value !== value);
68496
+ modelValue.value = (modelValue.value ?? []).filter((o) => o !== value);
68491
68497
  };
68492
68498
  const clearInput = () => {
68493
68499
  modelValue.value = [];
68494
68500
  searching.value = "";
68495
68501
  };
68496
- const displayedOptions = computed(
68497
- () => props.options.filter((o) => searchString(o.label, searching.value)).filter(
68498
- (o) => !modelValue.value.find((option) => option.value === o.value)
68499
- )
68502
+ const selectedItems = computed(() => {
68503
+ if (!modelValue.value) return [];
68504
+ const items = [];
68505
+ modelValue.value.forEach((selectedValue) => {
68506
+ const item = optionsLabelValue.value.find(
68507
+ (option) => option.value === selectedValue
68508
+ );
68509
+ if (item) items.push(item);
68510
+ });
68511
+ return items;
68512
+ });
68513
+ const optionsLabelValue = computed(
68514
+ () => Array.isArray(props.options) && !!props.options.length && typeof props.options[0] === "string" ? props.options.map((o) => ({ label: o, value: o })) : props.options
68500
68515
  );
68501
- const displayValues = computed(
68502
- () => modelValue.value.filter(
68503
- (o) => props.options.find((option) => option.value === o.value)
68504
- )
68516
+ const filteredOptions = computed(
68517
+ () => optionsLabelValue.value.filter((o) => searchString(o.label, searching.value))
68505
68518
  );
68506
68519
  return (_ctx, _cache) => {
68507
68520
  return openBlock(), createBlock(RawSelect, mergeProps(_ctx.$props, {
68508
- options: displayedOptions.value,
68521
+ options: filteredOptions.value,
68509
68522
  "model-value": modelValue.value,
68510
68523
  open: isDatalistOpen.value,
68511
- onSelect
68524
+ onSelect,
68525
+ onClick: setFocus
68512
68526
  }), {
68513
68527
  input: withCtx(() => [
68514
68528
  createElementVNode("div", _hoisted_1$F, [
68515
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayValues.value, (tag) => {
68529
+ (openBlock(true), createElementBlock(Fragment, null, renderList(selectedItems.value, (tag) => {
68516
68530
  return openBlock(), createBlock(BmsTag, {
68517
68531
  small: _ctx.small,
68518
68532
  active: "",
@@ -68543,7 +68557,7 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
68543
68557
  ])
68544
68558
  ]),
68545
68559
  createElementVNode("span", _hoisted_2$r, [
68546
- modelValue.value.length ? (openBlock(), createBlock(unref(X), {
68560
+ modelValue.value && modelValue.value?.length ? (openBlock(), createBlock(unref(X), {
68547
68561
  key: 0,
68548
68562
  class: "icon icon-clear",
68549
68563
  onClick: withModifiers(clearInput, ["stop"])
@@ -68578,7 +68592,7 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
68578
68592
  }
68579
68593
  });
68580
68594
 
68581
- const BmsMultiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$O, [["__scopeId", "data-v-05d9b16f"]]);
68595
+ const BmsMultiSelect = /* @__PURE__ */ _export_sfc(_sfc_main$O, [["__scopeId", "data-v-aece870d"]]);
68582
68596
 
68583
68597
  const _sfc_main$N = /* @__PURE__ */ defineComponent({
68584
68598
  __name: "BmsSearch",