@wimi/ui 0.4.17 → 0.4.18

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,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs, c as commonjsGlobal } from "./index-JCi8uj7s.mjs";
1
+ import { g as getDefaultExportFromCjs, c as commonjsGlobal } from "./index-BQq5z6-F.mjs";
2
2
  function _mergeNamespaces(n, m) {
3
3
  for (var i = 0; i < m.length; i++) {
4
4
  const e = m[i];
@@ -44641,31 +44641,31 @@ async function loadDayjsLocale(lang) {
44641
44641
  let locale2;
44642
44642
  switch (lang) {
44643
44643
  case "en-US": {
44644
- locale2 = await import("./en-DUcOGCKS.mjs").then((n10) => n10.e);
44644
+ locale2 = await import("./en-gonzj404.mjs").then((n10) => n10.e);
44645
44645
  break;
44646
44646
  }
44647
44647
  case "zh-CN": {
44648
- locale2 = await import("./zh-cn-CWZ7n2ZT.mjs").then((n10) => n10.z);
44648
+ locale2 = await import("./zh-cn-rZv9VN_q.mjs").then((n10) => n10.z);
44649
44649
  break;
44650
44650
  }
44651
44651
  case "zh-TW": {
44652
- locale2 = await import("./zh-tw-CGVQS3mU.mjs").then((n10) => n10.z);
44652
+ locale2 = await import("./zh-tw-Doi3PYqg.mjs").then((n10) => n10.z);
44653
44653
  break;
44654
44654
  }
44655
44655
  case "ko-KR": {
44656
- locale2 = await import("./ko-Dpm_JHv5.mjs").then((n10) => n10.k);
44656
+ locale2 = await import("./ko-BNNzPe5h.mjs").then((n10) => n10.k);
44657
44657
  break;
44658
44658
  }
44659
44659
  case "ja-JP": {
44660
- locale2 = await import("./ja-DzmS0NEe.mjs").then((n10) => n10.j);
44660
+ locale2 = await import("./ja-CN386CXw.mjs").then((n10) => n10.j);
44661
44661
  break;
44662
44662
  }
44663
44663
  case "ru-RU": {
44664
- locale2 = await import("./ru-CY9ncGql.mjs").then((n10) => n10.r);
44664
+ locale2 = await import("./ru-CpRb9z7m.mjs").then((n10) => n10.r);
44665
44665
  break;
44666
44666
  }
44667
44667
  default: {
44668
- locale2 = await import("./zh-cn-CWZ7n2ZT.mjs").then((n10) => n10.z);
44668
+ locale2 = await import("./zh-cn-rZv9VN_q.mjs").then((n10) => n10.z);
44669
44669
  }
44670
44670
  }
44671
44671
  if (locale2) {
@@ -305585,10 +305585,24 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
305585
305585
  loading: {
305586
305586
  type: Boolean
305587
305587
  },
305588
- inputProps: {}
305588
+ inputProps: {},
305589
+ filterCheckedOnly: {
305590
+ type: Boolean,
305591
+ default: true
305592
+ },
305593
+ checkAllOnClear: {
305594
+ type: Boolean,
305595
+ default: false
305596
+ },
305597
+ defaultCheckAll: {
305598
+ type: Boolean,
305599
+ default: false
305600
+ }
305589
305601
  },
305602
+ emits: ["update:checkedKeys"],
305590
305603
  setup(__props, {
305591
- expose: __expose
305604
+ expose: __expose,
305605
+ emit: __emit
305592
305606
  }) {
305593
305607
  const ellipsisCss = vi`
305594
305608
  overflow: hidden;
@@ -305603,17 +305617,161 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
305603
305617
  }
305604
305618
  `;
305605
305619
  const props2 = __props;
305620
+ const emit = __emit;
305606
305621
  const {
305607
305622
  commonTokens
305608
305623
  } = useNaiveDesignTokens();
305609
305624
  const attrs = useAttrs();
305610
305625
  const elRef = ref();
305611
305626
  const searchValue = ref("");
305627
+ const defaultFilter = (pattern, node2) => {
305628
+ const labelField = props2.labelField || "label";
305629
+ const label = node2[labelField];
305630
+ return (label == null ? void 0 : label.toLowerCase().includes(pattern.toLowerCase())) ?? false;
305631
+ };
305632
+ const getVisibleKeys = (data, pattern) => {
305633
+ const visibleKeys = /* @__PURE__ */ new Set();
305634
+ if (!data) return visibleKeys;
305635
+ if (!pattern) {
305636
+ const collectAll = (nodes) => {
305637
+ for (const node2 of nodes) {
305638
+ const keyField2 = props2.keyField || "key";
305639
+ const childrenField2 = props2.childrenField || "children";
305640
+ visibleKeys.add(node2[keyField2]);
305641
+ const children = node2[childrenField2];
305642
+ if (children == null ? void 0 : children.length) collectAll(children);
305643
+ }
305644
+ };
305645
+ collectAll(data);
305646
+ return visibleKeys;
305647
+ }
305648
+ const keyField = props2.keyField || "key";
305649
+ const childrenField = props2.childrenField || "children";
305650
+ const filterFn = props2.filter || defaultFilter;
305651
+ const traverse2 = (nodes) => {
305652
+ let hasVisible = false;
305653
+ for (const node2 of nodes) {
305654
+ const nodeKey = node2[keyField];
305655
+ const children = node2[childrenField];
305656
+ const childrenVisible = (children == null ? void 0 : children.length) ? traverse2(children) : false;
305657
+ const selfMatch = filterFn(pattern, node2);
305658
+ if (selfMatch || childrenVisible) {
305659
+ visibleKeys.add(nodeKey);
305660
+ hasVisible = true;
305661
+ }
305662
+ }
305663
+ return hasVisible;
305664
+ };
305665
+ traverse2(data);
305666
+ return visibleKeys;
305667
+ };
305668
+ const getAllNodesData = (data) => {
305669
+ const keys2 = [];
305670
+ const options = [];
305671
+ if (!data) return {
305672
+ keys: keys2,
305673
+ options
305674
+ };
305675
+ const keyField = props2.keyField || "key";
305676
+ const childrenField = props2.childrenField || "children";
305677
+ const traverse2 = (nodes) => {
305678
+ for (const node2 of nodes) {
305679
+ keys2.push(node2[keyField]);
305680
+ options.push(node2);
305681
+ const children = node2[childrenField];
305682
+ if (children == null ? void 0 : children.length) traverse2(children);
305683
+ }
305684
+ };
305685
+ traverse2(data);
305686
+ return {
305687
+ keys: keys2,
305688
+ options
305689
+ };
305690
+ };
305691
+ const visibleKeysSet = computed(() => getVisibleKeys(props2.data, searchValue.value));
305692
+ onMounted(() => {
305693
+ var _a2;
305694
+ if (props2.checkable && props2.defaultCheckAll && ((_a2 = props2.data) == null ? void 0 : _a2.length)) {
305695
+ const {
305696
+ keys: keys2,
305697
+ options
305698
+ } = getAllNodesData(props2.data);
305699
+ emit("update:checkedKeys", keys2, options, {
305700
+ node: null,
305701
+ action: "check"
305702
+ });
305703
+ const originalHandler = props2["onUpdate:checkedKeys"] || props2.onUpdateCheckedKeys;
305704
+ if (originalHandler) {
305705
+ const handlers2 = Array.isArray(originalHandler) ? originalHandler : [originalHandler];
305706
+ handlers2.forEach((fn2) => fn2(keys2, options, {
305707
+ node: null,
305708
+ action: "check"
305709
+ }));
305710
+ }
305711
+ }
305712
+ });
305713
+ watch(searchValue, (newVal, oldVal) => {
305714
+ var _a2, _b2;
305715
+ if (!props2.filterCheckedOnly) return;
305716
+ const invokeHandler = (k10, o2, action) => {
305717
+ emit("update:checkedKeys", k10, o2, {
305718
+ node: null,
305719
+ action
305720
+ });
305721
+ const originalHandler = props2["onUpdate:checkedKeys"] || props2.onUpdateCheckedKeys;
305722
+ if (originalHandler) {
305723
+ const handlers2 = Array.isArray(originalHandler) ? originalHandler : [originalHandler];
305724
+ handlers2.forEach((fn2) => fn2(k10, o2, {
305725
+ node: null,
305726
+ action
305727
+ }));
305728
+ }
305729
+ };
305730
+ if (!newVal && oldVal && props2.checkAllOnClear) {
305731
+ const {
305732
+ keys: keys2,
305733
+ options
305734
+ } = getAllNodesData(props2.data);
305735
+ invokeHandler(keys2, options, "check");
305736
+ return;
305737
+ }
305738
+ if (!newVal) return;
305739
+ const checkedData = (_a2 = elRef.value) == null ? void 0 : _a2.getCheckedData();
305740
+ if (!((_b2 = checkedData == null ? void 0 : checkedData.keys) == null ? void 0 : _b2.length)) return;
305741
+ const visibleKeys = getVisibleKeys(props2.data, newVal);
305742
+ const filteredKeys = checkedData.keys.filter((key2) => visibleKeys.has(key2));
305743
+ if (filteredKeys.length !== checkedData.keys.length) {
305744
+ const keyField = props2.keyField || "key";
305745
+ const filteredOptions = checkedData.options.filter((opt) => visibleKeys.has(opt[keyField]));
305746
+ invokeHandler(filteredKeys, filteredOptions, "uncheck");
305747
+ }
305748
+ });
305749
+ const handleUpdateCheckedKeys = (keys2, options, meta) => {
305750
+ const invokeHandler = (k10, o2) => {
305751
+ const originalHandler = props2["onUpdate:checkedKeys"] || props2.onUpdateCheckedKeys;
305752
+ if (!originalHandler) return;
305753
+ const handlers2 = Array.isArray(originalHandler) ? originalHandler : [originalHandler];
305754
+ handlers2.forEach((fn2) => fn2(k10, o2, meta));
305755
+ };
305756
+ if (!props2.filterCheckedOnly || !searchValue.value) {
305757
+ emit("update:checkedKeys", keys2, options, meta);
305758
+ invokeHandler(keys2, options);
305759
+ return;
305760
+ }
305761
+ const filteredKeys = keys2.filter((key2) => visibleKeysSet.value.has(key2));
305762
+ const filteredOptions = options.filter((opt) => {
305763
+ const keyField = props2.keyField || "key";
305764
+ return visibleKeysSet.value.has(opt[keyField]);
305765
+ });
305766
+ emit("update:checkedKeys", filteredKeys, filteredOptions, meta);
305767
+ invokeHandler(filteredKeys, filteredOptions);
305768
+ };
305612
305769
  const getBindValue = computed(() => {
305770
+ const omitKeys = ["ellipsis", "loading", "inputProps", "filterCheckedOnly", "checkAllOnClear", "defaultCheckAll", "onUpdate:checkedKeys", "onUpdateCheckedKeys"];
305613
305771
  return omit$4({
305614
305772
  ...props2,
305615
305773
  ...attrs
305616
- }, ["ellipsis", "loading", "inputProps"]);
305774
+ }, omitKeys);
305617
305775
  });
305618
305776
  const extendedNodeProps = computed(() => {
305619
305777
  return (params) => {
@@ -305630,6 +305788,26 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
305630
305788
  };
305631
305789
  };
305632
305790
  });
305791
+ const getFilteredCheckedKeys = () => {
305792
+ var _a2, _b2;
305793
+ const checkedData = (_a2 = elRef.value) == null ? void 0 : _a2.getCheckedData();
305794
+ if (!((_b2 = checkedData == null ? void 0 : checkedData.keys) == null ? void 0 : _b2.length) || !searchValue.value) {
305795
+ return (checkedData == null ? void 0 : checkedData.keys) || [];
305796
+ }
305797
+ return checkedData.keys.filter((key2) => visibleKeysSet.value.has(key2));
305798
+ };
305799
+ const getFilteredCheckedData = () => {
305800
+ var _a2;
305801
+ const checkedData = (_a2 = elRef.value) == null ? void 0 : _a2.getCheckedData();
305802
+ if (!checkedData || !searchValue.value) {
305803
+ return checkedData;
305804
+ }
305805
+ const keyField = props2.keyField || "key";
305806
+ return {
305807
+ keys: checkedData.keys.filter((key2) => visibleKeysSet.value.has(key2)),
305808
+ options: checkedData.options.filter((opt) => visibleKeysSet.value.has(opt[keyField]))
305809
+ };
305810
+ };
305633
305811
  const exposeMthods = {
305634
305812
  scrollTo: (...args) => {
305635
305813
  var _a2;
@@ -305642,7 +305820,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
305642
305820
  getIndeterminateData: () => {
305643
305821
  var _a2;
305644
305822
  return (_a2 = elRef.value) == null ? void 0 : _a2.getIndeterminateData();
305645
- }
305823
+ },
305824
+ getFilteredCheckedKeys,
305825
+ getFilteredCheckedData,
305826
+ getSearchValue: () => searchValue.value,
305827
+ getVisibleKeys: () => visibleKeysSet.value
305646
305828
  };
305647
305829
  __expose({
305648
305830
  ...exposeMthods
@@ -305676,7 +305858,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
305676
305858
  ref: elRef
305677
305859
  }, getBindValue.value, {
305678
305860
  pattern: searchValue.value,
305679
- "node-props": extendedNodeProps.value
305861
+ "node-props": extendedNodeProps.value,
305862
+ "onUpdate:checkedKeys": handleUpdateCheckedKeys
305680
305863
  }), createSlots({
305681
305864
  empty: withCtx(() => [renderSlot(_ctx.$slots, "empty", {}, () => [createVNode(unref(Empty$1), {
305682
305865
  class: "mx-auto"
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _, ad, a2, a3, a4, aa, a5, a8, a6, a7, a9, ab, e, b, h, ae, ag, ah, ai, aj, ak, af, al, am, an, ao, ap, aq, ar, as, B, $, N, Q, R, S, q, a0, y, W, a, i, f, j, k, l, t, v, T, w, x, z, A, C, F, G, I, H, J, O, P, U, V, X, L, ac, aZ, aR, au, a1, aW, av, aw, aA, aB, aF, az, aC, at, aG, ax, ay, aH, aI, aJ, aK, aL, aM, aN, aO, aP, aQ, aS, Y, aY, aX, aV, aD, s, D, Z, o, K, aT, aU, aE, m, p, r, M, u, E, n } from "./index-JCi8uj7s.mjs";
1
+ import { _, ad, a2, a3, a4, aa, a5, a8, a6, a7, a9, ab, e, b, h, ae, ag, ah, ai, aj, ak, af, al, am, an, ao, ap, aq, ar, as, B, $, N, Q, R, S, q, a0, y, W, a, i, f, j, k, l, t, v, T, w, x, z, A, C, F, G, I, H, J, O, P, U, V, X, L, ac, aZ, aR, au, a1, aW, av, aw, aA, aB, aF, az, aC, at, aG, ax, ay, aH, aI, aJ, aK, aL, aM, aN, aO, aP, aQ, aS, Y, aY, aX, aV, aD, s, D, Z, o, K, aT, aU, aE, m, p, r, M, u, E, n } from "./index-BQq5z6-F.mjs";
2
2
  export {
3
3
  _ as ApiComponent,
4
4
  ad as Badge,