zartui 3.1.63 → 3.1.65

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/lib/zartui.js CHANGED
@@ -18717,6 +18717,7 @@
18717
18717
  showToolbar: truthProp,
18718
18718
  showTitle: truthProp,
18719
18719
  options: makeArrayProp(),
18720
+ filteredOptions: makeArrayProp(),
18720
18721
  toolbarPosition: makeStringProp("bottom"),
18721
18722
  textKey: makeStringProp("text"),
18722
18723
  columnCounts: makeNumberProp(3),
@@ -18736,13 +18737,33 @@
18736
18737
  const currentOptions2 = vue.ref(props.options);
18737
18738
  const currentSelectedIndex = vue.computed(() => props.selectedIndex);
18738
18739
  const currentSelectedValue = vue.computed(() => props.selectedValue);
18740
+ const allSelectedOptions = vue.ref([]);
18739
18741
  const confirmIndexes = vue.ref(props.selectedIndex);
18740
18742
  const confirmValues = vue.ref(props.selectedValue);
18743
+ const displayOptions = vue.computed(() => {
18744
+ return props.filteredOptions && props.filteredOptions.length > 0 ? props.filteredOptions : currentOptions2.value;
18745
+ });
18746
+ const displaySelectedIndexes = vue.computed(() => {
18747
+ if (!props.filteredOptions || props.filteredOptions.length === 0) {
18748
+ return confirmIndexes.value;
18749
+ }
18750
+ const selectedValues = new Set(confirmIndexes.value.filter((idx) => idx >= 0 && idx < currentOptions2.value.length).map((idx) => {
18751
+ var _a;
18752
+ return (_a = currentOptions2.value[idx]) == null ? void 0 : _a.value;
18753
+ }));
18754
+ const result = [];
18755
+ displayOptions.value.forEach((option, index2) => {
18756
+ if (selectedValues.has(option.value)) {
18757
+ result.push(index2);
18758
+ }
18759
+ });
18760
+ return result;
18761
+ });
18741
18762
  const isIndeterminate = vue.computed(() => {
18742
- return confirmIndexes.value.length > 0 && confirmIndexes.value.length < currentOptions2.value.length;
18763
+ return displaySelectedIndexes.value.length > 0 && displaySelectedIndexes.value.length < displayOptions.value.length;
18743
18764
  });
18744
18765
  const isAllSelected = vue.computed(() => {
18745
- return confirmIndexes.value.length > 0 && confirmIndexes.value.length === currentOptions2.value.length;
18766
+ return displayOptions.value.length > 0 && displaySelectedIndexes.value.length > 0 && displaySelectedIndexes.value.length === displayOptions.value.length;
18746
18767
  });
18747
18768
  const resetOptions = (props2) => {
18748
18769
  currentOptions2.value = props2.options;
@@ -18755,14 +18776,39 @@
18755
18776
  emit("update:selectedValue", confirmValues.value);
18756
18777
  };
18757
18778
  const onUpdateCurrentIndexes = (newVal) => {
18758
- confirmIndexes.value = newVal;
18759
- if (newVal.length > 0) {
18779
+ if (props.filteredOptions && props.filteredOptions.length > 0) {
18780
+ const selectedValues = newVal.filter((idx) => idx >= 0 && idx < displayOptions.value.length).map((idx) => {
18781
+ var _a;
18782
+ return (_a = displayOptions.value[idx]) == null ? void 0 : _a.value;
18783
+ });
18784
+ const newSelectedIndexes = /* @__PURE__ */ new Set();
18785
+ confirmIndexes.value.forEach((idx) => {
18786
+ var _a;
18787
+ if (idx >= 0 && idx < currentOptions2.value.length) {
18788
+ const value = (_a = currentOptions2.value[idx]) == null ? void 0 : _a.value;
18789
+ const isInFilteredList = displayOptions.value.some((opt) => opt.value === value);
18790
+ if (!isInFilteredList) {
18791
+ newSelectedIndexes.add(idx);
18792
+ }
18793
+ }
18794
+ });
18795
+ selectedValues.forEach((value) => {
18796
+ const originalIndex = currentOptions2.value.findIndex((opt) => opt.value === value);
18797
+ if (originalIndex >= 0) {
18798
+ newSelectedIndexes.add(originalIndex);
18799
+ }
18800
+ });
18801
+ confirmIndexes.value = Array.from(newSelectedIndexes);
18802
+ } else {
18803
+ confirmIndexes.value = newVal;
18804
+ }
18805
+ if (confirmIndexes.value.length > 0) {
18760
18806
  getValuesByIndexes();
18761
18807
  } else {
18762
18808
  confirmValues.value = [];
18763
18809
  }
18764
- getValuesByIndexes();
18765
18810
  emit("update:selectedValue", confirmValues.value);
18811
+ updateAllSelectedOptions();
18766
18812
  };
18767
18813
  const getIndexesByValues = () => {
18768
18814
  var _a;
@@ -18814,20 +18860,27 @@
18814
18860
  };
18815
18861
  const updateShow = (value) => emit("update:showPicker", value);
18816
18862
  const getOptions = () => {
18817
- const indexes = confirmIndexes.value;
18863
+ return allSelectedOptions.value;
18864
+ };
18865
+ const onChange = () => {
18866
+ updateAllSelectedOptions();
18867
+ emit("change", getOptions());
18868
+ };
18869
+ const updateAllSelectedOptions = () => {
18818
18870
  const result = [];
18871
+ const indexes = confirmIndexes.value;
18819
18872
  indexes == null ? void 0 : indexes.forEach((index2) => {
18820
18873
  if (index2 > -1 && index2 < currentOptions2.value.length && currentOptions2.value[index2]) {
18874
+ const option = currentOptions2.value[index2];
18821
18875
  result.push({
18822
- [props.textKey]: currentOptions2.value[index2][props.textKey],
18823
- value: currentOptions2.value[index2].value,
18876
+ [props.textKey]: option[props.textKey],
18877
+ value: option.value,
18824
18878
  initialIndex: index2
18825
18879
  });
18826
18880
  }
18827
18881
  });
18828
- return result;
18882
+ allSelectedOptions.value = result;
18829
18883
  };
18830
- const onChange = () => emit("change", getOptions());
18831
18884
  const confirm = () => {
18832
18885
  const options = getOptions();
18833
18886
  emit("confirm", options);
@@ -18903,7 +18956,6 @@
18903
18956
  "class": bem$s("toolbar-checkbox"),
18904
18957
  "shape": "square",
18905
18958
  "modelValue": isAllSelected.value,
18906
- "onUpdate:modelValue": ($event) => isAllSelected.value = $event,
18907
18959
  "indeterminate": isIndeterminate.value,
18908
18960
  "onClick": handleSelectAll
18909
18961
  }, {
@@ -18912,33 +18964,74 @@
18912
18964
  "class": bem$s("toolbar-divider")
18913
18965
  }, null), vue.createVNode("span", {
18914
18966
  "class": bem$s("toolbar-checkbox-text")
18915
- }, [vue.createTextVNode("已选 "), confirmIndexes.value.length])]);
18967
+ }, [vue.createTextVNode("已选 "), allSelectedOptions.value.length])]);
18916
18968
  const handleSelectAll = () => {
18917
- confirmIndexes.value = !isAllSelected.value ? currentOptions2.value.map((_, index2) => index2) : [];
18969
+ if (!isAllSelected.value) {
18970
+ if (props.filteredOptions && props.filteredOptions.length > 0) {
18971
+ const selectedIndexes = [];
18972
+ displayOptions.value.forEach((option) => {
18973
+ const originalIndex = currentOptions2.value.findIndex((opt) => opt.value === option.value);
18974
+ if (originalIndex >= 0) {
18975
+ selectedIndexes.push(originalIndex);
18976
+ }
18977
+ });
18978
+ confirmIndexes.value = selectedIndexes;
18979
+ } else {
18980
+ confirmIndexes.value = currentOptions2.value.map((_, index2) => index2);
18981
+ }
18982
+ } else {
18983
+ confirmIndexes.value = [];
18984
+ }
18985
+ updateAllSelectedOptions();
18918
18986
  };
18919
18987
  const onSelectOther = () => {
18920
- const temp = Array();
18921
- currentOptions2.value.forEach((_, index2) => {
18922
- if (!confirmIndexes.value.includes(index2)) {
18923
- temp.push(index2);
18924
- }
18925
- });
18926
- confirmIndexes.value = temp;
18988
+ if (props.filteredOptions && props.filteredOptions.length > 0) {
18989
+ const filteredValues = new Set(displayOptions.value.map((opt) => opt.value));
18990
+ const currentSelectedInFiltered = /* @__PURE__ */ new Set();
18991
+ confirmIndexes.value.forEach((idx) => {
18992
+ var _a;
18993
+ if (idx >= 0 && idx < currentOptions2.value.length) {
18994
+ const value = (_a = currentOptions2.value[idx]) == null ? void 0 : _a.value;
18995
+ if (filteredValues.has(value)) {
18996
+ currentSelectedInFiltered.add(idx);
18997
+ }
18998
+ }
18999
+ });
19000
+ const newSelectedIndexes = [];
19001
+ displayOptions.value.forEach((option) => {
19002
+ const originalIndex = currentOptions2.value.findIndex((opt) => opt.value === option.value);
19003
+ if (originalIndex >= 0) {
19004
+ if (!currentSelectedInFiltered.has(originalIndex)) {
19005
+ newSelectedIndexes.push(originalIndex);
19006
+ }
19007
+ }
19008
+ });
19009
+ confirmIndexes.value = newSelectedIndexes;
19010
+ } else {
19011
+ const temp = new Array();
19012
+ currentOptions2.value.forEach((_, index2) => {
19013
+ if (!confirmIndexes.value.includes(index2)) {
19014
+ temp.push(index2);
19015
+ }
19016
+ });
19017
+ confirmIndexes.value = temp;
19018
+ }
19019
+ updateAllSelectedOptions();
18927
19020
  };
18928
- const genOptionItems = vue.computed(() => {
19021
+ const genOptionItems = () => {
18929
19022
  let formatOptions = [];
18930
- if (currentOptions2.value && currentOptions2.value[0] && typeof currentOptions2.value[0] !== "object") {
18931
- formatOptions = currentOptions2.value.map((v) => ({
19023
+ if (displayOptions.value && displayOptions.value[0] && typeof displayOptions.value[0] !== "object") {
19024
+ formatOptions = displayOptions.value.map((v) => ({
18932
19025
  value: v,
18933
19026
  text: v
18934
19027
  }));
18935
19028
  } else {
18936
- formatOptions = currentOptions2.value;
19029
+ formatOptions = displayOptions.value;
18937
19030
  }
18938
19031
  return vue.createVNode(stdin_default$B, {
18939
19032
  "ref": pickerOptions,
18940
- "currentIndexes": confirmIndexes.value,
18941
- "onUpdate:currentIndexes": [($event) => confirmIndexes.value = $event, onUpdateCurrentIndexes],
19033
+ "currentIndexes": displaySelectedIndexes.value,
19034
+ "onUpdate:currentIndexes": [($event) => displaySelectedIndexes.value = $event, onUpdateCurrentIndexes],
18942
19035
  "columnCounts": props.columnCounts,
18943
19036
  "initialOptions": formatOptions,
18944
19037
  "allowHtml": props.allowHtml,
@@ -18949,10 +19042,10 @@
18949
19042
  }, {
18950
19043
  option: slots.option
18951
19044
  });
18952
- });
19045
+ };
18953
19046
  const genOptions2 = () => vue.createVNode("div", {
18954
19047
  "class": bem$s("options")
18955
- }, [genOptionItems.value]);
19048
+ }, [genOptionItems()]);
18956
19049
  const renderMultiplePicker = () => vue.createVNode("div", {
18957
19050
  "class": bem$s()
18958
19051
  }, [genTitle(), props.loading ? vue.createVNode(stdin_default$1T, {
@@ -27329,7 +27422,7 @@
27329
27422
  });
27330
27423
  }
27331
27424
  };
27332
- const version = "3.1.63";
27425
+ const version = "3.1.65";
27333
27426
  function install(app) {
27334
27427
  const components = [
27335
27428
  ActionSheet,