@amirjalili1374/ui-kit 1.4.39 → 1.4.43

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/ui-kit.es.js CHANGED
@@ -7,6 +7,7 @@ import axios from "axios";
7
7
  import { useDebounceFn } from "@vueuse/core";
8
8
  import { useRouter as useRouter$1 } from "vue-router";
9
9
  import { defineStore } from "pinia";
10
+ import { string } from "yup";
10
11
  import VueKeycloakJs from "@dsb-norge/vue-keycloak-js";
11
12
  function propsFactory(props, source) {
12
13
  return (defaults) => {
@@ -12638,10 +12639,6 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12638
12639
  setup(__props, { emit: __emit }) {
12639
12640
  const props = __props;
12640
12641
  const emit = __emit;
12641
- const model = computed({
12642
- get: () => props.modelValue,
12643
- set: (v) => emit("update:modelValue", v)
12644
- });
12645
12642
  function resolveTitle(item) {
12646
12643
  var _a;
12647
12644
  const titleMapper = ((_a = props.fields) == null ? void 0 : _a.title) ?? props.itemTitle;
@@ -12664,6 +12661,12 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12664
12661
  if (typeof item === "object" && item) return item[subtitleMapper];
12665
12662
  return void 0;
12666
12663
  }
12664
+ function getGroupId(item) {
12665
+ var _a;
12666
+ const groupField = ((_a = props.fields) == null ? void 0 : _a.group) ?? props.groupField;
12667
+ if (typeof item === "object" && item) return item[groupField];
12668
+ return null;
12669
+ }
12667
12670
  function getGroupMembers(mainGroupItem) {
12668
12671
  var _a, _b;
12669
12672
  const groupField = ((_a = props.fields) == null ? void 0 : _a.group) ?? props.groupField;
@@ -12678,6 +12681,115 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12678
12681
  const isMainField = ((_a = props.fields) == null ? void 0 : _a.isMainGroup) ?? props.isMainGroupField;
12679
12682
  return !!(item && item[isMainField] === true);
12680
12683
  }
12684
+ function processSelectionChange(newValue) {
12685
+ if (!props.multiple) {
12686
+ return newValue;
12687
+ }
12688
+ if (!Array.isArray(newValue)) return newValue;
12689
+ let result = [...newValue];
12690
+ newValue.forEach((selected) => {
12691
+ const selectedValue = props.returnObject ? resolveValue(selected) : selected;
12692
+ const selectedItem = props.items.find(
12693
+ (item) => resolveValue(item) === selectedValue
12694
+ );
12695
+ if (!selectedItem) return;
12696
+ const groupId = getGroupId(selectedItem);
12697
+ if (!groupId) return;
12698
+ const isMain = isMainGroup(selectedItem);
12699
+ if (isMain) {
12700
+ result = result.filter((item) => {
12701
+ const itemValue = props.returnObject ? resolveValue(item) : item;
12702
+ const itemObj = props.items.find((i) => resolveValue(i) === itemValue);
12703
+ if (!itemObj) return true;
12704
+ const itemGroupId = getGroupId(itemObj);
12705
+ const itemIsMain = isMainGroup(itemObj);
12706
+ return !(itemGroupId === groupId && !itemIsMain);
12707
+ });
12708
+ } else {
12709
+ result = result.filter((item) => {
12710
+ const itemValue = props.returnObject ? resolveValue(item) : item;
12711
+ const itemObj = props.items.find((i) => resolveValue(i) === itemValue);
12712
+ if (!itemObj) return true;
12713
+ const itemGroupId = getGroupId(itemObj);
12714
+ const itemIsMain = isMainGroup(itemObj);
12715
+ return !(itemGroupId === groupId && itemIsMain);
12716
+ });
12717
+ }
12718
+ });
12719
+ return result;
12720
+ }
12721
+ function isMainGroupSelected(groupId) {
12722
+ if (!props.multiple) {
12723
+ const selectedValue = props.returnObject ? props.modelValue : props.modelValue;
12724
+ const selectedItem = props.items.find(
12725
+ (item) => resolveValue(item) === selectedValue
12726
+ );
12727
+ return selectedItem && getGroupId(selectedItem) === groupId && isMainGroup(selectedItem);
12728
+ } else {
12729
+ return Array.isArray(props.modelValue) && props.modelValue.some((selected) => {
12730
+ const selectedValue = props.returnObject ? resolveValue(selected) : selected;
12731
+ const selectedItem = props.items.find(
12732
+ (item) => resolveValue(item) === selectedValue
12733
+ );
12734
+ return selectedItem && getGroupId(selectedItem) === groupId && isMainGroup(selectedItem);
12735
+ });
12736
+ }
12737
+ }
12738
+ function isGroupMemberSelected(groupId) {
12739
+ if (!props.multiple) {
12740
+ const selectedValue = props.returnObject ? props.modelValue : props.modelValue;
12741
+ const selectedItem = props.items.find(
12742
+ (item) => resolveValue(item) === selectedValue
12743
+ );
12744
+ return selectedItem && getGroupId(selectedItem) === groupId && !isMainGroup(selectedItem);
12745
+ } else {
12746
+ return Array.isArray(props.modelValue) && props.modelValue.some((selected) => {
12747
+ const selectedValue = props.returnObject ? resolveValue(selected) : selected;
12748
+ const selectedItem = props.items.find(
12749
+ (item) => resolveValue(item) === selectedValue
12750
+ );
12751
+ return selectedItem && getGroupId(selectedItem) === groupId && !isMainGroup(selectedItem);
12752
+ });
12753
+ }
12754
+ }
12755
+ function isItemDisabled(item) {
12756
+ if (props.disabled) return true;
12757
+ const groupId = getGroupId(item);
12758
+ if (!groupId) return false;
12759
+ const isMain = isMainGroup(item);
12760
+ if (isMain) {
12761
+ return isGroupMemberSelected(groupId);
12762
+ } else {
12763
+ return isMainGroupSelected(groupId);
12764
+ }
12765
+ }
12766
+ function customFilter(item, queryText, itemText) {
12767
+ if (isItemDisabled(item.raw ?? item)) {
12768
+ return false;
12769
+ }
12770
+ const text2 = resolveTitle(item.raw ?? item);
12771
+ const query = queryText.toLowerCase();
12772
+ return text2.toLowerCase().includes(query);
12773
+ }
12774
+ const model = computed({
12775
+ get: () => props.modelValue,
12776
+ set: (v) => {
12777
+ const processedValue = processSelectionChange(v);
12778
+ emit("update:modelValue", processedValue);
12779
+ }
12780
+ });
12781
+ watch(
12782
+ () => props.modelValue,
12783
+ (newValue, oldValue) => {
12784
+ if (props.multiple && Array.isArray(newValue)) {
12785
+ const processed = processSelectionChange(newValue);
12786
+ if (JSON.stringify(processed) !== JSON.stringify(newValue)) {
12787
+ emit("update:modelValue", processed);
12788
+ }
12789
+ }
12790
+ },
12791
+ { deep: true }
12792
+ );
12681
12793
  return (_ctx, _cache) => {
12682
12794
  return openBlock(), createBlock(VAutocomplete, mergeProps({
12683
12795
  modelValue: model.value,
@@ -12699,7 +12811,8 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12699
12811
  style: __props.maxWidth ? { maxWidth: typeof __props.maxWidth === "number" ? `${__props.maxWidth}px` : __props.maxWidth } : void 0
12700
12812
  }, _ctx.$attrs, {
12701
12813
  variant: "outlined",
12702
- "menu-props": { attach: "body", zIndex: 1e4 }
12814
+ "menu-props": { attach: "body", zIndex: 1e4 },
12815
+ filter: customFilter
12703
12816
  }), {
12704
12817
  item: withCtx(({ props: itemProps, item }) => [
12705
12818
  isMainGroup(item.raw ?? item) ? (openBlock(), createBlock(VTooltip, {
@@ -12710,12 +12823,17 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12710
12823
  text: void 0,
12711
12824
  width: "300px",
12712
12825
  height: "300px",
12713
- color: "surface"
12826
+ color: "surface",
12827
+ disabled: isItemDisabled(item.raw ?? item)
12714
12828
  }, {
12715
12829
  activator: withCtx(({ props: activatorProps }) => [
12716
12830
  createVNode(VListItem, mergeProps({ ...itemProps, ...activatorProps }, {
12717
12831
  "two-line": __props.displayStyle === "detailed",
12718
- class: { "ca-main-group": true }
12832
+ class: {
12833
+ "ca-main-group": true,
12834
+ "ca-disabled-item": isItemDisabled(item.raw ?? item)
12835
+ },
12836
+ disabled: isItemDisabled(item.raw ?? item)
12719
12837
  }), createSlots({
12720
12838
  title: withCtx(() => [
12721
12839
  createElementVNode("div", _hoisted_1$c, [
@@ -12730,7 +12848,19 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12730
12848
  createTextVNode(" گروه ", -1)
12731
12849
  ])]),
12732
12850
  _: 1
12733
- })
12851
+ }),
12852
+ isItemDisabled(item.raw ?? item) ? (openBlock(), createBlock(VChip, {
12853
+ key: 0,
12854
+ size: "small",
12855
+ color: "error",
12856
+ variant: "outlined",
12857
+ class: "ca-disabled-chip"
12858
+ }, {
12859
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [
12860
+ createTextVNode(" غیرفعال ", -1)
12861
+ ])]),
12862
+ _: 1
12863
+ })) : createCommentVNode("", true)
12734
12864
  ])
12735
12865
  ]),
12736
12866
  default: withCtx(() => [
@@ -12747,7 +12877,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12747
12877
  ]),
12748
12878
  key: "0"
12749
12879
  } : void 0
12750
- ]), 1040, ["two-line"])
12880
+ ]), 1040, ["two-line", "class", "disabled"])
12751
12881
  ]),
12752
12882
  default: withCtx(() => [
12753
12883
  renderSlot(_ctx.$slots, "tooltip", {
@@ -12763,19 +12893,47 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12763
12893
  (openBlock(true), createElementBlock(Fragment, null, renderList(getGroupMembers(item.raw ?? item), (member, idx) => {
12764
12894
  return openBlock(), createElementBlock("div", {
12765
12895
  key: `${resolveValue(member)}-${idx}`,
12766
- class: "ca-group-member"
12767
- }, toDisplayString(resolveTitle(member)), 1);
12896
+ class: normalizeClass(["ca-group-member", { "ca-disabled-member": isItemDisabled(item.raw ?? item) }])
12897
+ }, [
12898
+ createTextVNode(toDisplayString(resolveTitle(member)) + " ", 1),
12899
+ isItemDisabled(item.raw ?? item) ? (openBlock(), createBlock(VIcon, {
12900
+ key: 0,
12901
+ size: "small",
12902
+ color: "error"
12903
+ }, {
12904
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [
12905
+ createTextVNode(" mdi-block-helper ", -1)
12906
+ ])]),
12907
+ _: 1
12908
+ })) : createCommentVNode("", true)
12909
+ ], 2);
12768
12910
  }), 128))
12769
12911
  ])
12770
12912
  ])
12771
12913
  ], true)
12772
12914
  ]),
12773
12915
  _: 2
12774
- }, 1032, ["location", "open-delay", "close-delay"])) : (openBlock(), createBlock(VListItem, mergeProps({ key: 1 }, itemProps, {
12775
- "two-line": __props.displayStyle === "detailed"
12916
+ }, 1032, ["location", "open-delay", "close-delay", "disabled"])) : (openBlock(), createBlock(VListItem, mergeProps({ key: 1 }, itemProps, {
12917
+ "two-line": __props.displayStyle === "detailed",
12918
+ class: { "ca-disabled-item": isItemDisabled(item.raw ?? item) },
12919
+ disabled: isItemDisabled(item.raw ?? item)
12776
12920
  }), createSlots({
12777
12921
  title: withCtx(() => [
12778
- createElementVNode("div", _hoisted_7$2, toDisplayString(resolveTitle(item.raw ?? item)), 1)
12922
+ createElementVNode("div", _hoisted_7$2, [
12923
+ createTextVNode(toDisplayString(resolveTitle(item.raw ?? item)) + " ", 1),
12924
+ isItemDisabled(item.raw ?? item) ? (openBlock(), createBlock(VChip, {
12925
+ key: 0,
12926
+ size: "small",
12927
+ color: "error",
12928
+ variant: "outlined",
12929
+ class: "ca-disabled-chip"
12930
+ }, {
12931
+ default: withCtx(() => [..._cache[4] || (_cache[4] = [
12932
+ createTextVNode(" غیرفعال ", -1)
12933
+ ])]),
12934
+ _: 1
12935
+ })) : createCommentVNode("", true)
12936
+ ])
12779
12937
  ]),
12780
12938
  default: withCtx(() => [
12781
12939
  renderSlot(_ctx.$slots, "item-append", {
@@ -12791,22 +12949,33 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent$1({
12791
12949
  ]),
12792
12950
  key: "0"
12793
12951
  } : void 0
12794
- ]), 1040, ["two-line"]))
12952
+ ]), 1040, ["two-line", "class", "disabled"]))
12795
12953
  ]),
12796
12954
  selection: withCtx(({ item, index: index2 }) => [
12797
12955
  createVNode(VChip, {
12798
12956
  class: "ca-chip",
12799
- variant: "tonal"
12957
+ variant: "tonal",
12958
+ color: isMainGroup(item.raw ?? item) ? "primary" : "secondary"
12800
12959
  }, {
12801
12960
  default: withCtx(() => [
12802
12961
  createElementVNode("span", _hoisted_9$2, toDisplayString(resolveTitle(item.raw ?? item)), 1),
12803
12962
  __props.displayStyle === "detailed" && resolveSubtitle(item.raw ?? item) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
12804
- _cache[2] || (_cache[2] = createElementVNode("span", { class: "ca-chip-sep" }, "•", -1)),
12963
+ _cache[5] || (_cache[5] = createElementVNode("span", { class: "ca-chip-sep" }, "•", -1)),
12805
12964
  createElementVNode("span", _hoisted_10$2, toDisplayString(resolveSubtitle(item.raw ?? item)), 1)
12806
- ], 64)) : createCommentVNode("", true)
12965
+ ], 64)) : createCommentVNode("", true),
12966
+ isMainGroup(item.raw ?? item) ? (openBlock(), createBlock(VIcon, {
12967
+ key: 1,
12968
+ size: "small",
12969
+ class: "ml-1"
12970
+ }, {
12971
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [
12972
+ createTextVNode(" mdi-account-group ", -1)
12973
+ ])]),
12974
+ _: 1
12975
+ })) : createCommentVNode("", true)
12807
12976
  ]),
12808
12977
  _: 2
12809
- }, 1024)
12978
+ }, 1032, ["color"])
12810
12979
  ]),
12811
12980
  _: 3
12812
12981
  }, 16, ["modelValue", "items", "item-title", "item-value", "multiple", "clearable", "label", "placeholder", "density", "disabled", "loading", "error", "rules", "return-object", "chips", "style"]);
@@ -12820,7 +12989,7 @@ const _export_sfc$1 = (sfc, props) => {
12820
12989
  }
12821
12990
  return target;
12822
12991
  };
12823
- const CustomAutocomplete = /* @__PURE__ */ _export_sfc$1(_sfc_main$j, [["__scopeId", "data-v-61be82fe"]]);
12992
+ const CustomAutocomplete = /* @__PURE__ */ _export_sfc$1(_sfc_main$j, [["__scopeId", "data-v-54358dbd"]]);
12824
12993
  const _sfc_main$i = /* @__PURE__ */ defineComponent$1({
12825
12994
  __name: "MoneyInput",
12826
12995
  props: {
@@ -26756,11 +26925,11 @@ var lottie = { exports: {} };
26756
26925
  }
26757
26926
  return this.fonts[0];
26758
26927
  }
26759
- function getCodePoint(string) {
26928
+ function getCodePoint(string2) {
26760
26929
  var codePoint = 0;
26761
- var first = string.charCodeAt(0);
26930
+ var first = string2.charCodeAt(0);
26762
26931
  if (first >= 55296 && first <= 56319) {
26763
- var second = string.charCodeAt(1);
26932
+ var second = string2.charCodeAt(1);
26764
26933
  if (second >= 56320 && second <= 57343) {
26765
26934
  codePoint = (first - 55296) * 1024 + second - 56320 + 65536;
26766
26935
  }
@@ -26777,15 +26946,15 @@ var lottie = { exports: {} };
26777
26946
  function isVariationSelector(charCode) {
26778
26947
  return charCode === VARIATION_SELECTOR_16_CODE_POINT;
26779
26948
  }
26780
- function isRegionalCode(string) {
26781
- var codePoint = getCodePoint(string);
26949
+ function isRegionalCode(string2) {
26950
+ var codePoint = getCodePoint(string2);
26782
26951
  if (codePoint >= REGIONAL_CHARACTER_A_CODE_POINT && codePoint <= REGIONAL_CHARACTER_Z_CODE_POINT) {
26783
26952
  return true;
26784
26953
  }
26785
26954
  return false;
26786
26955
  }
26787
- function isFlagEmoji(string) {
26788
- return isRegionalCode(string.substr(0, 2)) && isRegionalCode(string.substr(2, 2));
26956
+ function isFlagEmoji(string2) {
26957
+ return isRegionalCode(string2.substr(0, 2)) && isRegionalCode(string2.substr(2, 2));
26789
26958
  }
26790
26959
  function isCombinedCharacter(_char3) {
26791
26960
  return combinedCharacters.indexOf(_char3) !== -1;
@@ -38168,7 +38337,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent$1({
38168
38337
  required: true
38169
38338
  },
38170
38339
  version: {
38171
- type: String,
38340
+ type: string,
38172
38341
  required: false
38173
38342
  }
38174
38343
  },
@@ -38236,7 +38405,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent$1({
38236
38405
  size: "small"
38237
38406
  }, {
38238
38407
  default: withCtx(() => [
38239
- createTextVNode(toDisplayString(props.version ? props.version : "نمایشی"), 1)
38408
+ createTextVNode(toDisplayString(props.version), 1)
38240
38409
  ]),
38241
38410
  _: 1
38242
38411
  })
@@ -38250,7 +38419,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent$1({
38250
38419
  };
38251
38420
  }
38252
38421
  });
38253
- const AppSidebar = /* @__PURE__ */ _export_sfc$1(_sfc_main$2, [["__scopeId", "data-v-b59df261"]]);
38422
+ const AppSidebar = /* @__PURE__ */ _export_sfc$1(_sfc_main$2, [["__scopeId", "data-v-bc098c76"]]);
38254
38423
  const makeVToolbarTitleProps = propsFactory({
38255
38424
  text: String,
38256
38425
  ...makeComponentProps(),
@@ -38996,8 +39165,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent$1({
38996
39165
  sidebarDrawer: __props.sidebar.sidebarDrawer,
38997
39166
  miniSidebar: __props.sidebar.miniSidebar,
38998
39167
  "onUpdate:sidebarDrawer": __props.sidebar["onUpdate:sidebarDrawer"],
38999
- class: "app-sidebar",
39000
- version: "1.0.0"
39168
+ class: "app-sidebar"
39001
39169
  }, null, 8, ["sidebarItems", "getFilteredSidebarItems", "logoComponent", "sidebarDrawer", "miniSidebar", "onUpdate:sidebarDrawer"]),
39002
39170
  createVNode(VMain, null, {
39003
39171
  default: withCtx(() => [
@@ -39013,7 +39181,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent$1({
39013
39181
  };
39014
39182
  }
39015
39183
  });
39016
- const AppLayout = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__scopeId", "data-v-8eddbad4"]]);
39184
+ const AppLayout = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__scopeId", "data-v-82bccb54"]]);
39017
39185
  function useDataTable(options) {
39018
39186
  const items = ref([]);
39019
39187
  const loading = ref(false);