@ouestfrance/sipa-bms-ui 8.16.0 → 8.17.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.
@@ -53,6 +53,7 @@
53
53
  var SelectMode = /* @__PURE__ */ ((SelectMode2) => {
54
54
  SelectMode2["ALL"] = "all";
55
55
  SelectMode2["DEFAULT"] = "default";
56
+ SelectMode2["SINGLE"] = "single";
56
57
  return SelectMode2;
57
58
  })(SelectMode || {});
58
59
 
@@ -311,6 +312,23 @@
311
312
  console.error("Table component cannot have multiple action columns ");
312
313
  return headers.filter((h) => !h?.action).concat(actionsHeaders.length ? actionsHeaders[0] : []);
313
314
  };
315
+ const getAlignClass = (header) => {
316
+ const align = !header.align ? "start" : header.align;
317
+ return `u-text-align-${align}`;
318
+ };
319
+ const getHeaderClasses = (header, sort) => {
320
+ const classes = [getAlignClass(header), "bms-table__header-cell"];
321
+ if (header.class) {
322
+ classes.push(header.class);
323
+ }
324
+ if (header.sortable) {
325
+ classes.push("sortable");
326
+ }
327
+ if (sort.key === header.key) {
328
+ classes.push("sorted");
329
+ }
330
+ return classes;
331
+ };
314
332
 
315
333
  const _hoisted_1$$ = ["href", "target"];
316
334
  const _hoisted_2$G = ["href", "onClick", "target"];
@@ -95738,6 +95756,9 @@
95738
95756
  setup(__props, { emit: __emit }) {
95739
95757
  const props = __props;
95740
95758
  const emits = __emit;
95759
+ const currentItem = vue.computed(
95760
+ () => props.isChildElement ? props.item.childElement : props.item
95761
+ );
95741
95762
  const isItemSelected = (item) => {
95742
95763
  return props.selectMode === SelectMode.ALL || !!props.selectedItems.find((it) => _isEqual(item, it));
95743
95764
  };
@@ -95748,7 +95769,7 @@
95748
95769
  return (_ctx, _cache) => {
95749
95770
  return vue.openBlock(), vue.createElementBlock("tr", {
95750
95771
  class: vue.normalizeClass(["bms-table__row", {
95751
- "bms-table__row--selected": isItemSelected(__props.item),
95772
+ "bms-table__row--selected": isItemSelected(currentItem.value),
95752
95773
  "bms-table__row--disabled": __props.isChildElement,
95753
95774
  "bms-table__row--dense": __props.dense
95754
95775
  }])
@@ -95760,12 +95781,20 @@
95760
95781
  activated: __props.selectMode === vue.unref(SelectMode).ALL
95761
95782
  }, {
95762
95783
  default: vue.withCtx(() => [
95763
- vue.createVNode(UiBmsInputCheckbox, {
95784
+ __props.selectMode === vue.unref(SelectMode).SINGLE ? (vue.openBlock(), vue.createBlock(BmsInputRadio, {
95785
+ key: 0,
95786
+ name: vue.unref(v4)(),
95787
+ disabled: __props.selectableDisabled,
95788
+ value: currentItem.value,
95789
+ "model-value": isItemSelected(currentItem.value) ? currentItem.value : null,
95790
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => emits("select", currentItem.value))
95791
+ }, null, 8, ["name", "disabled", "value", "model-value"])) : (vue.openBlock(), vue.createBlock(UiBmsInputCheckbox, {
95792
+ key: 1,
95764
95793
  name: vue.unref(v4)(),
95765
95794
  disabled: __props.selectMode === vue.unref(SelectMode).ALL || __props.selectableDisabled,
95766
- "model-value": isItemSelected(__props.item),
95767
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => emits("select", __props.item))
95768
- }, null, 8, ["name", "disabled", "model-value"])
95795
+ "model-value": isItemSelected(currentItem.value),
95796
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => emits("select", currentItem.value))
95797
+ }, null, 8, ["name", "disabled", "model-value"]))
95769
95798
  ]),
95770
95799
  _: 1
95771
95800
  }, 8, ["direction", "activated"])
@@ -95813,7 +95842,7 @@
95813
95842
  }
95814
95843
  });
95815
95844
 
95816
- const UiBmsTableRow = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-c6304837"]]);
95845
+ const UiBmsTableRow = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-2ab3888f"]]);
95817
95846
 
95818
95847
  const _hoisted_1$b = { class: "bms-table" };
95819
95848
  const _hoisted_2$9 = { class: "bms-table__actions" };
@@ -95831,16 +95860,20 @@
95831
95860
  key: 0,
95832
95861
  class: "bms-table__loader"
95833
95862
  };
95834
- const _hoisted_11$1 = { class: "bms-table__headers bms-table__row" };
95835
- const _hoisted_12$1 = { key: 0 };
95836
- const _hoisted_13$1 = ["onClick"];
95837
- const _hoisted_14$1 = { class: "header-content" };
95838
- const _hoisted_15$1 = { class: "bms-table__body" };
95839
- const _hoisted_16$1 = {
95863
+ const _hoisted_11$1 = {
95864
+ ref: "thead",
95865
+ class: "bms-table__header"
95866
+ };
95867
+ const _hoisted_12$1 = { class: "bms-table__headers bms-table__row" };
95868
+ const _hoisted_13$1 = { key: 0 };
95869
+ const _hoisted_14$1 = ["onClick"];
95870
+ const _hoisted_15$1 = { class: "header-content" };
95871
+ const _hoisted_16$1 = { class: "bms-table__body" };
95872
+ const _hoisted_17 = {
95840
95873
  key: 1,
95841
95874
  class: "bms-table__row"
95842
95875
  };
95843
- const _hoisted_17 = ["colspan"];
95876
+ const _hoisted_18 = ["colspan"];
95844
95877
  const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
95845
95878
  __name: "UiBmsTable",
95846
95879
  props: /* @__PURE__ */ vue.mergeModels({
@@ -95871,31 +95904,23 @@
95871
95904
  const selectedItems = vue.useModel(__props, "selectedItems");
95872
95905
  const emits = __emit;
95873
95906
  const pagination = vue.ref(null);
95874
- const isHeaderStuck = vue.ref(false);
95875
- const thead = vue.ref(null);
95876
- const filteredHeaders = vue.computed(() => {
95877
- return enforceActionsColumnHeader(props.headers);
95878
- });
95907
+ const isFocusOnPagination = () => pagination.value?.contains(document.activeElement);
95908
+ vue.watch(
95909
+ () => props.items,
95910
+ async function keepFocusOnPaginationWhenUsed(newVal, oldVal) {
95911
+ if (oldVal.length > 0 && newVal.length > 0 && isFocusOnPagination()) {
95912
+ await vue.nextTick();
95913
+ pagination.value?.focus();
95914
+ }
95915
+ },
95916
+ { deep: true }
95917
+ );
95918
+ const filteredHeaders = vue.computed(
95919
+ () => enforceActionsColumnHeader(props.headers)
95920
+ );
95879
95921
  const tableClass = vue.computed(
95880
95922
  () => `bms-table__table bms-table__table--${props.mode}`
95881
95923
  );
95882
- const getAlignClass = (header) => {
95883
- const align = !header.align ? "start" : header.align;
95884
- return `u-text-align-${align}`;
95885
- };
95886
- const getHeaderClasses = (header) => {
95887
- const classes = [getAlignClass(header), "bms-table__header-cell"];
95888
- if (header.class) {
95889
- classes.push(header.class);
95890
- }
95891
- if (header.sortable) {
95892
- classes.push("sortable");
95893
- }
95894
- if (props.sort.key === header.key) {
95895
- classes.push("sorted");
95896
- }
95897
- return classes;
95898
- };
95899
95924
  const getSortComponent = (header) => {
95900
95925
  if (!props.sort.key || header.key !== props.sort.key) {
95901
95926
  return ChevronsUpDown;
@@ -95909,41 +95934,19 @@
95909
95934
  return ChevronsUpDown;
95910
95935
  }
95911
95936
  };
95912
- const isFocusOnPagination = () => {
95913
- return pagination.value?.contains(document.activeElement);
95914
- };
95915
- vue.watch(
95916
- () => props.items,
95917
- async (newVal, oldVal) => {
95918
- if (oldVal.length > 0 && newVal.length > 0 && isFocusOnPagination()) {
95919
- await vue.nextTick();
95920
- pagination.value?.focus();
95921
- }
95922
- },
95923
- { deep: true }
95924
- );
95925
- onscroll = () => {
95926
- if (thead.value) {
95927
- const { top: theadTop } = thead.value.getBoundingClientRect();
95928
- const headers = document.getElementsByTagName("header");
95929
- if (headers.length > 0) {
95930
- const header = headers[0];
95931
- const { height: headerHeight } = header.getBoundingClientRect();
95932
- isHeaderStuck.value = headerHeight === theadTop;
95933
- }
95934
- }
95935
- };
95936
- const isItemSelected = (item) => {
95937
- return props.selectMode === SelectMode.ALL || !!selectedItems.value.find((it) => _isEqual(item, it));
95938
- };
95937
+ const isItemSelected = (item) => props.selectMode === SelectMode.ALL || !!selectedItems.value.find((it) => _isEqual(item, it));
95939
95938
  const onItemSelect = (item) => {
95940
- if (isItemSelected(item)) {
95941
- selectedItems.value = selectedItems.value.filter(
95942
- (it) => !_isEqual(item, it)
95943
- );
95944
- areAllCurrentItemsSelected.value = false;
95939
+ if (props.selectMode === SelectMode.SINGLE) {
95940
+ selectedItems.value = [item];
95945
95941
  } else {
95946
- selectedItems.value.push(item);
95942
+ if (isItemSelected(item)) {
95943
+ selectedItems.value = selectedItems.value.filter(
95944
+ (it) => !_isEqual(item, it)
95945
+ );
95946
+ areAllCurrentItemsSelected.value = false;
95947
+ } else {
95948
+ selectedItems.value.push(item);
95949
+ }
95947
95950
  }
95948
95951
  };
95949
95952
  const areAllCurrentItemsSelected = vue.ref(props.selectMode === SelectMode.ALL);
@@ -95955,7 +95958,7 @@
95955
95958
  if (props.selectMode === SelectMode.ALL) {
95956
95959
  emits("clearSelection");
95957
95960
  }
95958
- if (selectedItems.value.length > props.items.length) {
95961
+ if (selectedItems.value.length > props.totalSize) {
95959
95962
  selectedItems.value = [];
95960
95963
  } else {
95961
95964
  if (!areAllCurrentItemsSelected.value) {
@@ -95963,11 +95966,12 @@
95963
95966
  if (!isItemSelected(item)) {
95964
95967
  selectedItems.value.push(item);
95965
95968
  }
95969
+ if (item?.childElement && !isItemSelected(item?.childElement)) {
95970
+ selectedItems.value.push(item.childElement);
95971
+ }
95966
95972
  });
95967
95973
  } else {
95968
- selectedItems.value = selectedItems.value.filter(
95969
- (selectedItem) => !props.items.find((item) => _isEqual(item, selectedItem))
95970
- );
95974
+ selectedItems.value = [];
95971
95975
  }
95972
95976
  }
95973
95977
  };
@@ -96040,7 +96044,7 @@
96040
96044
  _cache[1] || (_cache[1] = vue.createElementVNode("strong", null, "1", -1)),
96041
96045
  _cache[2] || (_cache[2] = vue.createTextVNode(" élément du tableau est sélectionné. ", -1))
96042
96046
  ], 64)) : (vue.openBlock(), vue.createElementBlock("strong", _hoisted_8$2, vue.toDisplayString(selectedItems.value.length) + " éléments du tableau sont sélectionnés. ", 1)),
96043
- __props.totalSize < __props.maxSelectedSize ? (vue.openBlock(), vue.createElementBlock("span", {
96047
+ __props.totalSize < __props.maxSelectedSize && __props.selectMode !== vue.unref(SelectMode).SINGLE ? (vue.openBlock(), vue.createElementBlock("span", {
96044
96048
  key: 2,
96045
96049
  class: "select-mode-all",
96046
96050
  onClick: selectAll
@@ -96074,14 +96078,11 @@
96074
96078
  ref_key: "mainComponent",
96075
96079
  ref: mainComponent
96076
96080
  }, [
96077
- vue.createElementVNode("thead", {
96078
- ref_key: "thead",
96079
- ref: thead,
96080
- class: vue.normalizeClass(["bms-table__header", { stuck: isHeaderStuck.value }])
96081
- }, [
96082
- vue.createElementVNode("tr", _hoisted_11$1, [
96083
- __props.selectable ? (vue.openBlock(), vue.createElementBlock("th", _hoisted_12$1, [
96084
- vue.createVNode(UiBmsInputCheckbox, {
96081
+ vue.createElementVNode("thead", _hoisted_11$1, [
96082
+ vue.createElementVNode("tr", _hoisted_12$1, [
96083
+ __props.selectable ? (vue.openBlock(), vue.createElementBlock("th", _hoisted_13$1, [
96084
+ __props.selectMode !== vue.unref(SelectMode).SINGLE ? (vue.openBlock(), vue.createBlock(UiBmsInputCheckbox, {
96085
+ key: 0,
96085
96086
  name: "select-all",
96086
96087
  disabled: __props.items.length === 0 || __props.selectableDisabled,
96087
96088
  "onUpdate:modelValue": [
@@ -96089,18 +96090,18 @@
96089
96090
  _cache[0] || (_cache[0] = ($event) => areAllCurrentItemsSelected.value = $event)
96090
96091
  ],
96091
96092
  modelValue: areAllCurrentItemsSelected.value
96092
- }, null, 8, ["disabled", "modelValue"])
96093
+ }, null, 8, ["disabled", "modelValue"])) : vue.createCommentVNode("", true)
96093
96094
  ])) : vue.createCommentVNode("", true),
96094
96095
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(filteredHeaders.value, (header) => {
96095
96096
  return vue.openBlock(), vue.createElementBlock("th", {
96096
96097
  style: vue.normalizeStyle({
96097
96098
  "--table-cell-width": header?.width || void 0
96098
96099
  }),
96099
- class: vue.normalizeClass(getHeaderClasses(header)),
96100
+ class: vue.normalizeClass(vue.unref(getHeaderClasses)(header, __props.sort)),
96100
96101
  key: header.label,
96101
96102
  onClick: ($event) => emits("clickHeader", header)
96102
96103
  }, [
96103
- vue.createElementVNode("span", _hoisted_14$1, [
96104
+ vue.createElementVNode("span", _hoisted_15$1, [
96104
96105
  vue.createTextVNode(vue.toDisplayString(header.label) + " ", 1),
96105
96106
  header.sortable ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(getSortComponent(header)), {
96106
96107
  key: 0,
@@ -96108,11 +96109,11 @@
96108
96109
  class: "header-content-sort"
96109
96110
  })) : vue.createCommentVNode("", true)
96110
96111
  ])
96111
- ], 14, _hoisted_13$1);
96112
+ ], 14, _hoisted_14$1);
96112
96113
  }), 128))
96113
96114
  ])
96114
- ], 2),
96115
- vue.createElementVNode("tbody", _hoisted_15$1, [
96115
+ ], 512),
96116
+ vue.createElementVNode("tbody", _hoisted_16$1, [
96116
96117
  __props.items.length ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(__props.items, (item) => {
96117
96118
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: item }, [
96118
96119
  vue.createVNode(UiBmsTableRow, {
@@ -96147,7 +96148,8 @@
96147
96148
  selectable: __props.selectable,
96148
96149
  headers: filteredHeaders.value,
96149
96150
  "select-mode": __props.selectMode,
96150
- "selectable-disabled": __props.selectableDisabled
96151
+ "selectable-disabled": __props.selectableDisabled,
96152
+ onSelect: onItemSelect
96151
96153
  }, vue.createSlots({ _: 2 }, [
96152
96154
  vue.renderList(__props.headers, (cell) => {
96153
96155
  return {
@@ -96160,7 +96162,7 @@
96160
96162
  ]), 1032, ["item", "selected-items", "selectable", "headers", "select-mode", "selectable-disabled"])
96161
96163
  ], true) : vue.createCommentVNode("", true)
96162
96164
  ], 64);
96163
- }), 128)) : (vue.openBlock(), vue.createElementBlock("tr", _hoisted_16$1, [
96165
+ }), 128)) : (vue.openBlock(), vue.createElementBlock("tr", _hoisted_17, [
96164
96166
  vue.createElementVNode("td", {
96165
96167
  colspan: __props.selectable ? filteredHeaders.value.length + 1 : filteredHeaders.value.length,
96166
96168
  class: "bms-table__cell bms-table__cell--empty"
@@ -96168,7 +96170,7 @@
96168
96170
  !props.loading ? vue.renderSlot(_ctx.$slots, "empty", { key: 0 }, () => [
96169
96171
  _cache[3] || (_cache[3] = vue.createTextVNode("Aucune donnée", -1))
96170
96172
  ], true) : vue.createCommentVNode("", true)
96171
- ], 8, _hoisted_17)
96173
+ ], 8, _hoisted_18)
96172
96174
  ]))
96173
96175
  ])
96174
96176
  ], 2)) : vue.createCommentVNode("", true),
@@ -96186,7 +96188,7 @@
96186
96188
  }
96187
96189
  });
96188
96190
 
96189
- const UiBmsTable = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-9cbfc981"]]);
96191
+ const UiBmsTable = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-45f34152"]]);
96190
96192
 
96191
96193
  const _hoisted_1$a = { class: "filter-button-container" };
96192
96194
  const _hoisted_2$8 = {
@@ -102804,7 +102806,8 @@
102804
102806
  value: SortValue.default
102805
102807
  }) },
102806
102808
  selectable: { type: Boolean, default: false },
102807
- selectableDisabled: { type: Boolean, default: false }
102809
+ selectableDisabled: { type: Boolean, default: false },
102810
+ selectMode: { default: SelectMode.DEFAULT }
102808
102811
  }, {
102809
102812
  "selectedItems": {
102810
102813
  required: false,
@@ -102937,9 +102940,14 @@
102937
102940
  const onClickHeader = (header) => {
102938
102941
  changeSort(header);
102939
102942
  };
102943
+ const elementsAndChildElements = vue.computed(() => {
102944
+ const childElements = items.value.map((item) => item.childElement).filter((childElement) => !!childElement);
102945
+ return [...items.value, ...childElements];
102946
+ });
102940
102947
  const onSelectAll = () => {
102941
- selectedItems.value = items.value;
102948
+ selectedItems.value = elementsAndChildElements.value;
102942
102949
  };
102950
+ const totalSize = vue.computed(() => elementsAndChildElements.value.length);
102943
102951
  return (_ctx, _cache) => {
102944
102952
  return vue.openBlock(), vue.createBlock(UiBmsTable, {
102945
102953
  selectedItems: selectedItems.value,
@@ -102952,7 +102960,8 @@
102952
102960
  sort: vue.unref(sort),
102953
102961
  selectable: __props.selectable,
102954
102962
  selectableDisabled: __props.selectableDisabled,
102955
- totalSize: vue.unref(items).length,
102963
+ totalSize: totalSize.value,
102964
+ selectMode: __props.selectMode,
102956
102965
  onClickHeader,
102957
102966
  onSelectAll
102958
102967
  }, vue.createSlots({
@@ -103047,12 +103056,12 @@
103047
103056
  ])
103048
103057
  };
103049
103058
  })
103050
- ]), 1032, ["selectedItems", "loading", "items", "headers", "mode", "hasFilters", "sort", "selectable", "selectableDisabled", "totalSize"]);
103059
+ ]), 1032, ["selectedItems", "loading", "items", "headers", "mode", "hasFilters", "sort", "selectable", "selectableDisabled", "totalSize", "selectMode"]);
103051
103060
  };
103052
103061
  }
103053
103062
  });
103054
103063
 
103055
- const BmsTable = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-2f003e4e"]]);
103064
+ const BmsTable = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-704a7453"]]);
103056
103065
 
103057
103066
  const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
103058
103067
  __name: "BmsCocarde",
@@ -106043,6 +106052,7 @@
106043
106052
  exports.getCurrentHistory = getCurrentHistory;
106044
106053
  exports.getCurrentLocation = getCurrentLocation;
106045
106054
  exports.getFiltersAsQueryParams = getFiltersAsQueryParams;
106055
+ exports.getHeaderClasses = getHeaderClasses;
106046
106056
  exports.getImageFromFile = getImageFromFile;
106047
106057
  exports.getNumberFromPathQuery = getNumberFromPathQuery;
106048
106058
  exports.getStringFromPathQuery = getStringFromPathQuery;