@dao-style/core 0.5.3 → 0.6.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.
@@ -1 +1 @@
1
- export declare type ModelValueAnyType = string | number | boolean | bigint | symbol | Record<string | symbol, unknown> | unknown[] | Set<unknown>;
1
+ export declare type ModelValueAnyType = string | number | boolean | symbol | Record<string | symbol, unknown> | unknown[] | Set<unknown>;
@@ -0,0 +1,33 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ type: {
3
+ type: import("vue").PropType<"normal" | "full">;
4
+ default: string;
5
+ validator: (value: "normal" | "full") => boolean;
6
+ };
7
+ title: {
8
+ type: import("vue").PropType<string>;
9
+ default: undefined;
10
+ };
11
+ helper: {
12
+ type: import("vue").PropType<string>;
13
+ default: undefined;
14
+ };
15
+ }, {
16
+ formattedTitle: import("vue").ComputedRef<string>;
17
+ titleClassName: string;
18
+ helperClassName: string;
19
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
20
+ type?: unknown;
21
+ title?: unknown;
22
+ helper?: unknown;
23
+ } & {
24
+ type: "normal" | "full";
25
+ } & {
26
+ title?: string | undefined;
27
+ helper?: string | undefined;
28
+ }>, {
29
+ type: "normal" | "full";
30
+ title: string;
31
+ helper: string;
32
+ }>;
33
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as DaoEmpty } from './empty.vue';
2
+ export * from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { PropType, ExtractPropTypes } from 'vue';
2
+ declare const emptyType: readonly ["normal", "full"];
3
+ export declare type EmptyType = typeof emptyType[number];
4
+ export declare const emptyProps: {
5
+ type: {
6
+ type: PropType<"normal" | "full">;
7
+ default: string;
8
+ validator: (value: EmptyType) => boolean;
9
+ };
10
+ title: {
11
+ type: PropType<string>;
12
+ default: undefined;
13
+ };
14
+ helper: {
15
+ type: PropType<string>;
16
+ default: undefined;
17
+ };
18
+ };
19
+ export declare type EmptyProps = ExtractPropTypes<typeof emptyProps>;
20
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { ExtractPropTypes, PropType } from 'vue';
2
2
  import type Transfer from './transfer.vue';
3
3
  export declare type DataItem = Record<string, unknown>;
4
- declare type Key = DataItem[number];
4
+ export declare type Key = DataItem[number];
5
5
  declare type FilterMethod = (query: string, item: DataItem) => boolean;
6
6
  declare type Props = {
7
7
  key: string;
@@ -85,13 +85,6 @@ export declare const transferPanelProp: {
85
85
  type: PropType<Props>;
86
86
  default: () => {};
87
87
  };
88
- checkedStatus: {
89
- type: ObjectConstructor;
90
- default: () => {
91
- checked: boolean;
92
- indeterminate: boolean;
93
- };
94
- };
95
88
  };
96
89
  export declare type TransferProps = ExtractPropTypes<typeof transferProps>;
97
90
  export declare type TransferInstance = InstanceType<typeof Transfer>;
@@ -37,13 +37,6 @@ declare const _default: import("vue").DefineComponent<{
37
37
  }>;
38
38
  default: () => {};
39
39
  };
40
- checkedStatus: {
41
- type: ObjectConstructor;
42
- default: () => {
43
- checked: boolean;
44
- indeterminate: boolean;
45
- };
46
- };
47
40
  }, {
48
41
  ns: string;
49
42
  t: import("vue-i18n").ComposerTranslation<{
@@ -52,12 +45,18 @@ declare const _default: import("vue").DefineComponent<{
52
45
  [x: string]: import("vue-i18n").LocaleMessageValue<import("vue-i18n").VueMessageType>;
53
46
  }>, never, string, string>;
54
47
  query: import("vue").Ref<string>;
48
+ checkedStatus: {
49
+ checked: boolean;
50
+ indeterminate: boolean;
51
+ checkableList: unknown[];
52
+ };
55
53
  labelProp: import("vue").ComputedRef<string>;
56
54
  keyProp: import("vue").ComputedRef<string>;
57
55
  descProp: import("vue").ComputedRef<string>;
58
56
  filteredData: import("vue").ComputedRef<import("./props").DataItem[]>;
59
57
  isSource: import("vue").ComputedRef<boolean>;
60
58
  isEmpty: import("vue").ComputedRef<boolean>;
59
+ isDisabledCheckAll: import("vue").ComputedRef<boolean>;
61
60
  hasFooter: import("vue").ComputedRef<boolean>;
62
61
  handleCheckAll: (checked: boolean) => void;
63
62
  handleItemEvent: (action: 'remove' | 'check', row: import("./props").DataItem) => void;
@@ -71,7 +70,6 @@ declare const _default: import("vue").DefineComponent<{
71
70
  filterPlaceholder?: unknown;
72
71
  hideDesc?: unknown;
73
72
  props?: unknown;
74
- checkedStatus?: unknown;
75
73
  } & {
76
74
  props: {
77
75
  key: string;
@@ -84,7 +82,6 @@ declare const _default: import("vue").DefineComponent<{
84
82
  filterable: boolean;
85
83
  hideDesc: boolean;
86
84
  checkedKeys: unknown[];
87
- checkedStatus: Record<string, any>;
88
85
  } & {
89
86
  filterMethod?: ((query: string, item: import("./props").DataItem) => boolean) | undefined;
90
87
  filterPlaceholder?: string | undefined;
@@ -104,6 +101,5 @@ declare const _default: import("vue").DefineComponent<{
104
101
  filterable: boolean;
105
102
  hideDesc: boolean;
106
103
  checkedKeys: unknown[];
107
- checkedStatus: Record<string, any>;
108
104
  }>;
109
105
  export default _default;
@@ -1,4 +1,4 @@
1
- import { DataItem } from './props';
1
+ import type { DataItem, Key } from './props';
2
2
  declare const _default: import("vue").DefineComponent<{
3
3
  source: {
4
4
  type: import("vue").PropType<DataItem[]>;
@@ -51,22 +51,17 @@ declare const _default: import("vue").DefineComponent<{
51
51
  [x: string]: import("vue-i18n").LocaleMessageValue<import("vue-i18n").VueMessageType>;
52
52
  }>, never, string, string>;
53
53
  sourceData: import("vue").ComputedRef<DataItem[]>;
54
- targetData: import("vue").Ref<{
55
- [x: string]: unknown;
56
- }[]>;
54
+ targetData: import("vue").ComputedRef<DataItem[]>;
57
55
  selectedKeys: import("vue").WritableComputedRef<unknown[]> | import("vue").Ref<unknown[]>;
58
- checkedStatus: {
59
- checked: boolean;
60
- indeterminate: boolean;
61
- canCheckArr: string[];
62
- disabledCheck: string[];
63
- };
64
56
  onChange: ({ direction, row, }: {
65
57
  direction: 'left' | 'right';
66
58
  row: DataItem;
67
59
  }) => void;
68
60
  onClear: () => void;
69
- onCheckAll: (checked: boolean) => void;
61
+ onCheckAll: ({ checked, checkableList, }: {
62
+ checked: boolean;
63
+ checkableList: Key[];
64
+ }) => void;
70
65
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "change" | "add" | "refresh" | "clear" | "checkAll")[], "update:modelValue" | "change" | "add" | "clear" | "refresh" | "checkAll", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
71
66
  source?: unknown;
72
67
  modelValue?: unknown;
@@ -578,7 +578,7 @@ const ExpansionStateKey = Symbol("expansionProps");
578
578
  const DialogConfirmKey = Symbol("dialogConfirm");
579
579
  const DialogCancelKey = Symbol("dialogCancel");
580
580
  var checkbox_vue_vue_type_style_index_0_lang = "";
581
- const modelValueAny = [String, Number, Boolean, BigInt, Symbol, Object, Set, Array];
581
+ const modelValueAny = [String, Number, Boolean, Symbol, Object, Set, Array];
582
582
  function getUnrefItem(set, item) {
583
583
  const tempArray = Array.from(set);
584
584
  const index2 = looseIndexOf(tempArray, item);
@@ -8667,14 +8667,7 @@ const transferPanelProp = {
8667
8667
  type: String
8668
8668
  },
8669
8669
  hideDesc: transferProps.hideDesc,
8670
- props: transferProps.props,
8671
- checkedStatus: {
8672
- type: Object,
8673
- default: () => ({
8674
- checked: false,
8675
- indeterminate: false
8676
- })
8677
- }
8670
+ props: transferProps.props
8678
8671
  };
8679
8672
  const _sfc_main$1 = defineComponent({
8680
8673
  name: "DaoTransferPanel",
@@ -8704,19 +8697,58 @@ const _sfc_main$1 = defineComponent({
8704
8697
  const label = item[labelProp.value] || item[keyProp.value];
8705
8698
  return String(label).toLowerCase().includes(query.value.toLowerCase());
8706
8699
  }));
8700
+ const checkedStatus = reactive({
8701
+ checked: false,
8702
+ indeterminate: false,
8703
+ checkableList: []
8704
+ });
8705
+ watchEffect(() => {
8706
+ const _selectedKeys = new Set(props.checkedKeys);
8707
+ const _disabledKeys = new Set(props.disabledKeys);
8708
+ const _keyProp = keyProp.value;
8709
+ const _checkedStatus = {
8710
+ checked: false,
8711
+ indeterminate: false,
8712
+ hasNoChecked: false,
8713
+ checkableList: []
8714
+ };
8715
+ filteredData.value.forEach((item) => {
8716
+ const key = item == null ? void 0 : item[_keyProp];
8717
+ const disabled = _disabledKeys.has(key);
8718
+ const checked = _selectedKeys.has(key);
8719
+ if (checked) {
8720
+ _checkedStatus.checked = true;
8721
+ } else {
8722
+ _checkedStatus.indeterminate = true;
8723
+ }
8724
+ if (!disabled) {
8725
+ _checkedStatus.checkableList.push(key);
8726
+ if (!checked) {
8727
+ _checkedStatus.hasNoChecked = true;
8728
+ }
8729
+ }
8730
+ });
8731
+ checkedStatus.checkableList = _checkedStatus.checkableList;
8732
+ checkedStatus.checked = !_checkedStatus.hasNoChecked;
8733
+ checkedStatus.indeterminate = _checkedStatus.checked && _checkedStatus.indeterminate;
8734
+ });
8707
8735
  const hasNoMatch = computed(() => query.value.length > 0 && filteredData.value.length === 0);
8708
8736
  const isEmpty2 = computed(() => hasNoMatch.value || props.data.length === 0);
8709
- const hasFooter = computed(() => {
8710
- var _a2;
8711
- return !!((_a2 = slots.footer) == null ? void 0 : _a2.call(slots));
8712
- });
8737
+ const isDisabledCheckAll = computed(() => filteredData.value.every((item) => props.disabledKeys.includes(item[keyProp.value])) || isEmpty2.value);
8738
+ const hasFooter = computed(() => !!slots.footer);
8713
8739
  function handleCheckAll(checked) {
8714
- emit("checkAll", checked);
8740
+ emit("checkAll", {
8741
+ checked,
8742
+ checkableList: checkedStatus.checkableList
8743
+ });
8715
8744
  }
8716
8745
  function handleItemEvent(action, row) {
8717
8746
  let direction = "";
8718
8747
  const key = row[keyProp.value];
8719
8748
  const isDisabled = (props.disabledKeys || []).includes(key);
8749
+ if (isDisabled) {
8750
+ return;
8751
+ }
8720
8752
  const isChecked = (props.checkedKeys || []).includes(key);
8721
8753
  switch (action) {
8722
8754
  case "remove":
@@ -8726,20 +8758,20 @@ const _sfc_main$1 = defineComponent({
8726
8758
  direction = isChecked ? "left" : "right";
8727
8759
  break;
8728
8760
  }
8729
- if (!isDisabled) {
8730
- emit("selectedChange", { direction, row });
8731
- }
8761
+ emit("selectedChange", { direction, row });
8732
8762
  }
8733
8763
  return {
8734
8764
  ns: "dao-transfer-panel",
8735
8765
  t,
8736
8766
  query,
8767
+ checkedStatus,
8737
8768
  labelProp,
8738
8769
  keyProp,
8739
8770
  descProp,
8740
8771
  filteredData,
8741
8772
  isSource,
8742
8773
  isEmpty: isEmpty2,
8774
+ isDisabledCheckAll,
8743
8775
  hasFooter,
8744
8776
  handleCheckAll,
8745
8777
  handleItemEvent
@@ -8812,13 +8844,14 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
8812
8844
  createVNode(_component_dao_checkbox, {
8813
8845
  checked: _ctx.checkedStatus.checked,
8814
8846
  indeterminate: _ctx.checkedStatus.indeterminate && !_ctx.checkedStatus.checked,
8847
+ disabled: _ctx.isDisabledCheckAll,
8815
8848
  onChange: _ctx.handleCheckAll
8816
8849
  }, {
8817
8850
  default: withCtx(() => [
8818
8851
  createTextVNode(toDisplayString(_ctx.t("core.transfer.checkAll")), 1)
8819
8852
  ]),
8820
8853
  _: 1
8821
- }, 8, ["checked", "indeterminate", "onChange"])
8854
+ }, 8, ["checked", "indeterminate", "disabled", "onChange"])
8822
8855
  ], 2)
8823
8856
  ]) : createCommentVNode("", true),
8824
8857
  createElementVNode("div", {
@@ -8919,57 +8952,15 @@ const _sfc_main = defineComponent({
8919
8952
  const selectedKeys = useVModel(props, "modelValue", emit, {
8920
8953
  passive: true
8921
8954
  });
8922
- const targetData = ref([]);
8923
- const checkedStatus = reactive({
8924
- checked: false,
8925
- indeterminate: false,
8926
- canCheckArr: [],
8927
- disabledCheck: []
8928
- });
8929
- watchEffect(() => {
8930
- const _targetData = [];
8955
+ const targetData = computed(() => {
8931
8956
  const _selectedKeys = new Set(selectedKeys.value);
8932
- const _disabledKeys = new Set(props.disabledKeys);
8933
- const _keyProp = keyProp.value;
8934
- const _checkedStatus = {
8935
- checked: false,
8936
- indeterminate: false,
8937
- notChecked: false,
8938
- canCheckArr: [],
8939
- disabledCheck: []
8940
- };
8941
- sourceData.value.forEach((item) => {
8942
- const key = item == null ? void 0 : item[_keyProp];
8943
- const disabled = _disabledKeys.has(key);
8944
- const checked = _selectedKeys.has(key);
8945
- if (checked) {
8946
- _targetData.push(item);
8947
- _selectedKeys.delete(key);
8948
- _checkedStatus.checked = true;
8949
- } else {
8950
- _checkedStatus.indeterminate = true;
8957
+ return sourceData.value.reduce((pre, cur) => {
8958
+ const key = cur == null ? void 0 : cur[keyProp.value];
8959
+ if (_selectedKeys.has(key)) {
8960
+ pre.push(cur);
8951
8961
  }
8952
- if (!disabled) {
8953
- _checkedStatus.canCheckArr.push(key);
8954
- if (!checked) {
8955
- _checkedStatus.notChecked = true;
8956
- }
8957
- }
8958
- if (disabled && checked) {
8959
- _checkedStatus.disabledCheck.push(key);
8960
- }
8961
- });
8962
- targetData.value = _targetData;
8963
- checkedStatus.canCheckArr = _checkedStatus.canCheckArr;
8964
- checkedStatus.disabledCheck = _checkedStatus.disabledCheck;
8965
- checkedStatus.checked = !_checkedStatus.notChecked;
8966
- checkedStatus.indeterminate = _checkedStatus.checked && _checkedStatus.indeterminate;
8967
- if (_selectedKeys.size) {
8968
- const disabledArr = [...selectedKeys.value].filter((key) => !_selectedKeys.has(key));
8969
- selectedKeys.value = disabledArr;
8970
- }
8971
- }, {
8972
- flush: "pre"
8962
+ return pre;
8963
+ }, []);
8973
8964
  });
8974
8965
  const onChange = ({
8975
8966
  direction,
@@ -8993,27 +8984,29 @@ const _sfc_main = defineComponent({
8993
8984
  emit("change", { direction, rows: [row] });
8994
8985
  };
8995
8986
  const onClear = () => {
8996
- selectedKeys.value = [...checkedStatus.disabledCheck];
8987
+ const _disabledKeys = new Set(props.disabledKeys);
8988
+ selectedKeys.value = selectedKeys.value.filter((key) => _disabledKeys.has(key));
8997
8989
  emit("clear", selectedKeys.value);
8998
8990
  };
8999
- const checkAll = () => {
9000
- const checkArr = checkedStatus.canCheckArr.concat(checkedStatus.disabledCheck);
9001
- selectedKeys.value = checkArr;
9002
- emit("checkAll", selectedKeys.value);
9003
- };
9004
- const onCheckAll = (checked) => {
8991
+ const onCheckAll = ({
8992
+ checked,
8993
+ checkableList
8994
+ }) => {
8995
+ const curOperatingKeys = checkableList;
9005
8996
  if (checked) {
9006
- checkAll();
8997
+ const selectedKeysSet = new Set(selectedKeys.value.concat(curOperatingKeys));
8998
+ selectedKeys.value = [...selectedKeysSet];
9007
8999
  } else {
9008
- onClear();
9000
+ selectedKeys.value = selectedKeys.value.filter((key) => !curOperatingKeys.includes(key));
9001
+ emit("clear", selectedKeys.value);
9009
9002
  }
9003
+ emit("checkAll", selectedKeys.value);
9010
9004
  };
9011
9005
  return {
9012
9006
  t,
9013
9007
  sourceData,
9014
9008
  targetData,
9015
9009
  selectedKeys,
9016
- checkedStatus,
9017
9010
  onChange,
9018
9011
  onClear,
9019
9012
  onCheckAll
@@ -9037,10 +9030,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
9037
9030
  "filter-placeholder": (_c = _ctx.filterPlaceholder) == null ? void 0 : _c[0],
9038
9031
  "disabled-keys": _ctx.disabledKeys,
9039
9032
  props: _ctx.props,
9040
- "checked-status": {
9041
- checked: _ctx.checkedStatus.checked,
9042
- indeterminate: _ctx.checkedStatus.indeterminate
9043
- },
9044
9033
  onSelectedChange: _ctx.onChange,
9045
9034
  onRefresh: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("refresh")),
9046
9035
  onCheckAll: _ctx.onCheckAll
@@ -9082,7 +9071,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
9082
9071
  renderSlot(_ctx.$slots, "left-footer")
9083
9072
  ])
9084
9073
  } : void 0
9085
- ]), 1032, ["hide-desc", "data", "checked-keys", "filterable", "filter-method", "filter-placeholder", "disabled-keys", "props", "checked-status", "onSelectedChange", "onCheckAll"]),
9074
+ ]), 1032, ["hide-desc", "data", "checked-keys", "filterable", "filter-method", "filter-placeholder", "disabled-keys", "props", "onSelectedChange", "onCheckAll"]),
9086
9075
  createVNode(_component_transfer_panel, {
9087
9076
  ref: "rightPanel",
9088
9077
  type: "target",
@@ -9255,6 +9244,9 @@ var enUS = {
9255
9244
  removeText: "Delete",
9256
9245
  deselectText: "Deselect",
9257
9246
  selectedFormat: "{n} item selected | {n} items selected"
9247
+ },
9248
+ empty: {
9249
+ title: "No data"
9258
9250
  }
9259
9251
  }
9260
9252
  };
@@ -9301,6 +9293,9 @@ var zhCN = {
9301
9293
  removeText: "\u5220\u9664",
9302
9294
  deselectText: "\u53D6\u6D88\u9009\u4E2D",
9303
9295
  selectedFormat: "\u9009\u4E2D {n} \u9879"
9296
+ },
9297
+ empty: {
9298
+ title: "\u6682\u65E0\u6570\u636E"
9304
9299
  }
9305
9300
  }
9306
9301
  };