@silver-formily/element-plus 4.0.2 → 5.0.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.
- package/esm/__builtins__/shared/loading.mjs.map +1 -1
- package/esm/__builtins__/shared/transform-component.mjs +1 -1
- package/esm/__builtins__/shared/transform-component.mjs.map +1 -1
- package/esm/__builtins__/shared/utils.mjs +11 -6
- package/esm/__builtins__/shared/utils.mjs.map +1 -1
- package/esm/array-base/array-base-inner.mjs.map +1 -1
- package/esm/array-base/array-base-move-down.mjs +1 -1
- package/esm/array-base/array-base-move-down.mjs.map +1 -1
- package/esm/array-base/array-base-move-up.mjs +1 -1
- package/esm/array-base/array-base-move-up.mjs.map +1 -1
- package/esm/array-base/array-base-remove.mjs +1 -1
- package/esm/array-base/array-base-remove.mjs.map +1 -1
- package/esm/array-base/types.d.ts +2 -2
- package/esm/array-base/utils.d.ts +1 -1
- package/esm/array-base/utils.mjs +1 -1
- package/esm/array-base/utils.mjs.map +1 -1
- package/esm/array-cards/array-cards.mjs +1 -1
- package/esm/array-cards/array-cards.mjs.map +1 -1
- package/esm/array-collapse/array-collapse-item.mjs +1 -1
- package/esm/array-collapse/array-collapse-item.mjs.map +1 -1
- package/esm/array-collapse/array-collapse.mjs +3 -4
- package/esm/array-collapse/array-collapse.mjs.map +1 -1
- package/esm/array-items/array-items.mjs +3 -8
- package/esm/array-items/array-items.mjs.map +1 -1
- package/esm/array-list-tabs/array-list-tabs.mjs +57 -51
- package/esm/array-list-tabs/array-list-tabs.mjs.map +1 -1
- package/esm/array-list-tabs/utils.mjs.map +1 -1
- package/esm/array-table/array-table.mjs +4 -18
- package/esm/array-table/array-table.mjs.map +1 -1
- package/esm/array-table/utils.mjs.map +1 -1
- package/esm/array-tabs/array-tabs.mjs +1 -1
- package/esm/array-tabs/array-tabs.mjs.map +1 -1
- package/esm/autocomplete/autocomplete.mjs.map +1 -1
- package/esm/autocomplete/index.d.ts +3 -4
- package/esm/checkbox/checkbox-group.mjs +1 -1
- package/esm/checkbox/checkbox-group.mjs.map +1 -1
- package/esm/checkbox/index.d.ts +57 -57
- package/esm/color-picker/index.d.ts +20 -20
- package/esm/color-picker-panel/index.d.ts +9 -9
- package/esm/date-picker-panel/index.d.ts +1 -1
- package/esm/editable/editable-popover.mjs +1 -1
- package/esm/editable/editable-popover.mjs.map +1 -1
- package/esm/editable/editable.mjs +1 -1
- package/esm/editable/editable.mjs.map +1 -1
- package/esm/form/form.mjs.map +1 -1
- package/esm/form/form.vue.d.ts +1 -1
- package/esm/form-collapse/form-collapse.mjs +1 -1
- package/esm/form-collapse/form-collapse.mjs.map +1 -1
- package/esm/form-collapse/utils.d.ts +2 -2
- package/esm/form-collapse/utils.mjs +2 -2
- package/esm/form-collapse/utils.mjs.map +1 -1
- package/esm/form-dialog/dialog-content.mjs +1 -1
- package/esm/form-dialog/dialog-content.mjs.map +1 -1
- package/esm/form-dialog/index.mjs +3 -3
- package/esm/form-dialog/index.mjs.map +1 -1
- package/esm/form-dialog/types.d.ts +2 -2
- package/esm/form-drawer/drawer-content.mjs +1 -1
- package/esm/form-drawer/drawer-content.mjs.map +1 -1
- package/esm/form-drawer/index.mjs +3 -3
- package/esm/form-drawer/index.mjs.map +1 -1
- package/esm/form-drawer/types.d.ts +2 -2
- package/esm/form-grid/form-grid-column.mjs +6 -4
- package/esm/form-grid/form-grid-column.mjs.map +1 -1
- package/esm/form-item/form-item.mjs +1 -1
- package/esm/form-item/form-item.mjs.map +1 -1
- package/esm/form-item/index.mjs +1 -1
- package/esm/form-item/index.mjs.map +1 -1
- package/esm/form-item/utils.mjs +1 -1
- package/esm/form-item/utils.mjs.map +1 -1
- package/esm/form-layout/form-layout.mjs +1 -1
- package/esm/form-layout/form-layout.mjs.map +1 -1
- package/esm/form-layout/form-layout.vue.d.ts +1 -1
- package/esm/form-layout/utils.mjs +1 -1
- package/esm/form-layout/utils.mjs.map +1 -1
- package/esm/form-step/form-step.mjs +1 -1
- package/esm/form-step/form-step.mjs.map +1 -1
- package/esm/form-step/types.d.ts +1 -1
- package/esm/form-step/utils.d.ts +1 -1
- package/esm/form-step/utils.mjs +1 -1
- package/esm/form-step/utils.mjs.map +1 -1
- package/esm/form-tab/hooks.mjs.map +1 -1
- package/esm/form-tab/utils.mjs +1 -1
- package/esm/form-tab/utils.mjs.map +1 -1
- package/esm/input-number/index.d.ts +21 -21
- package/esm/input-tag/index.d.ts +1 -2
- package/esm/input-tag/input-tag.mjs.map +1 -1
- package/esm/mention/index.d.ts +3 -4
- package/esm/mention/mention.mjs.map +1 -1
- package/esm/pagination/components/pager2.mjs.map +1 -1
- package/esm/pagination/components/sizes2.mjs +1 -1
- package/esm/pagination/components/sizes2.mjs.map +1 -1
- package/esm/picker-select/picker-select.mjs +1 -1
- package/esm/picker-select/picker-select.mjs.map +1 -1
- package/esm/picker-select/types.d.ts +1 -1
- package/esm/preview-text/cascader.mjs.map +1 -1
- package/esm/preview-text/color-picker.mjs +1 -1
- package/esm/preview-text/color-picker.mjs.map +1 -1
- package/esm/preview-text/input.mjs +1 -1
- package/esm/preview-text/input.mjs.map +1 -1
- package/esm/preview-text/rate.mjs +1 -1
- package/esm/preview-text/rate.mjs.map +1 -1
- package/esm/preview-text/select.mjs +9 -4
- package/esm/preview-text/select.mjs.map +1 -1
- package/esm/preview-text/time-picker.mjs +1 -1
- package/esm/preview-text/time-picker.mjs.map +1 -1
- package/esm/preview-text/tree.mjs.map +1 -1
- package/esm/query-form/hooks.mjs +1 -1
- package/esm/query-form/hooks.mjs.map +1 -1
- package/esm/query-form/index.d.ts +5 -5
- package/esm/query-form/query-form-light.mjs +14 -7
- package/esm/query-form/query-form-light.mjs.map +1 -1
- package/esm/query-form/query-form.mjs +14 -7
- package/esm/query-form/query-form.mjs.map +1 -1
- package/esm/query-form/types.d.ts +9 -2
- package/esm/query-form-item/index.d.ts +4 -4
- package/esm/query-form-item/query-form-item.mjs +2 -2
- package/esm/query-form-item/query-form-item.mjs.map +1 -1
- package/esm/query-form-item/types.d.ts +2 -2
- package/esm/radio/index.d.ts +60 -60
- package/esm/radio/radio-group.mjs +5 -3
- package/esm/radio/radio-group.mjs.map +1 -1
- package/esm/rate/index.d.ts +10 -10
- package/esm/select/index.d.ts +7 -7
- package/esm/select-table/index.d.ts +3 -3
- package/esm/select-table/select-table.mjs +1 -1
- package/esm/select-table/select-table.mjs.map +1 -1
- package/esm/select-table/types.d.ts +1 -1
- package/esm/submit/submit.mjs.map +1 -1
- package/esm/switch/index.d.ts +27 -27
- package/esm/time-select/index.d.ts +20 -20
- package/esm/transfer/index.d.ts +21 -21
- package/esm/tree/tree.mjs +1 -1
- package/esm/tree/tree.mjs.map +1 -1
- package/esm/tree-select/tree-select.mjs.map +1 -1
- package/esm/upload/upload.mjs +1 -1
- package/esm/upload/upload.mjs.map +1 -1
- package/package.json +18 -14
|
@@ -2,10 +2,11 @@ import { lt } from "../__builtins__/shared/simple-version-compare.mjs";
|
|
|
2
2
|
import { useCleanAttrs } from "../__builtins__/shared/utils.mjs";
|
|
3
3
|
import { ElRadio, ElRadioButton, ElRadioGroup, version } from "element-plus";
|
|
4
4
|
import { Fragment, computed, createBlock, createElementBlock, createTextVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useSlots, withCtx } from "vue";
|
|
5
|
-
import { isPlainObj } from "@formily/shared";
|
|
5
|
+
import { isPlainObj } from "@silver-formily/shared";
|
|
6
6
|
//#region src/radio/radio-group.vue
|
|
7
7
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
8
|
name: "FRadioGroup",
|
|
9
|
+
inheritAttrs: false,
|
|
9
10
|
__name: "radio-group",
|
|
10
11
|
props: {
|
|
11
12
|
options: {
|
|
@@ -20,6 +21,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
20
21
|
setup(__props) {
|
|
21
22
|
const props = __props;
|
|
22
23
|
const { props: radioProps } = useCleanAttrs();
|
|
24
|
+
const normalizedOptions = computed(() => Array.isArray(props.options) ? props.options : []);
|
|
23
25
|
const OptionType = computed(() => {
|
|
24
26
|
return props.optionType === "button" ? ElRadioButton : ElRadio;
|
|
25
27
|
});
|
|
@@ -28,11 +30,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
28
30
|
return isPlainObj(option);
|
|
29
31
|
}
|
|
30
32
|
function getOptionLabel(option, index) {
|
|
31
|
-
if (isRadioPropsObject(
|
|
33
|
+
if (isRadioPropsObject(normalizedOptions.value[index])) return normalizedOptions.value[index].label;
|
|
32
34
|
return option.label;
|
|
33
35
|
}
|
|
34
36
|
const compatiableProps = computed(() => {
|
|
35
|
-
return
|
|
37
|
+
return normalizedOptions.value.map((option) => {
|
|
36
38
|
if (!isRadioPropsObject(option)) return {
|
|
37
39
|
label: option,
|
|
38
40
|
value: option
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.mjs","names":[],"sources":["../../src/radio/radio-group.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { RadioProps } from 'element-plus'\nimport type { PropType } from 'vue'\nimport { isPlainObj } from '@formily/shared'\nimport { ElRadio, ElRadioButton, ElRadioGroup, version } from 'element-plus'\nimport { computed, useSlots } from 'vue'\nimport { lt, useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FRadioGroup',\n})\n\nconst props = defineProps({\n options: {\n type: Array as PropType<Array<RadioProps | string | number>>,\n default: () => [],\n },\n optionType: {\n type: String as PropType<'default' | 'button'>,\n default: 'default',\n },\n})\n\nconst { props: radioProps } = useCleanAttrs()\n\nconst OptionType = computed(() => {\n return props.optionType === 'button' ? ElRadioButton : ElRadio\n})\nconst IS_LESS_THAN_2_6_0 = lt(version, '2.6.0')\n\nfunction isRadioPropsObject(option: any): option is RadioProps {\n return isPlainObj(option)\n}\n\nfunction getOptionLabel(option: any, index: number) {\n if (isRadioPropsObject(
|
|
1
|
+
{"version":3,"file":"radio-group.mjs","names":[],"sources":["../../src/radio/radio-group.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { RadioProps } from 'element-plus'\nimport type { PropType } from 'vue'\nimport { isPlainObj } from '@silver-formily/shared'\nimport { ElRadio, ElRadioButton, ElRadioGroup, version } from 'element-plus'\nimport { computed, useSlots } from 'vue'\nimport { lt, useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FRadioGroup',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n options: {\n type: Array as PropType<Array<RadioProps | string | number>>,\n default: () => [],\n },\n optionType: {\n type: String as PropType<'default' | 'button'>,\n default: 'default',\n },\n})\n\nconst { props: radioProps } = useCleanAttrs()\nconst normalizedOptions = computed(() => Array.isArray(props.options) ? props.options : [])\n\nconst OptionType = computed(() => {\n return props.optionType === 'button' ? ElRadioButton : ElRadio\n})\nconst IS_LESS_THAN_2_6_0 = lt(version, '2.6.0')\n\nfunction isRadioPropsObject(option: any): option is RadioProps {\n return isPlainObj(option)\n}\n\nfunction getOptionLabel(option: any, index: number) {\n if (isRadioPropsObject(normalizedOptions.value[index])) {\n return normalizedOptions.value[index].label\n }\n return option.label\n}\n\nconst compatiableProps = computed(() => {\n return normalizedOptions.value.map((option) => {\n if (!isRadioPropsObject(option)) {\n return {\n label: option,\n value: option,\n }\n }\n /* istanbul ignore if -- @preserve */\n if (IS_LESS_THAN_2_6_0) {\n return {\n ...option,\n label: option.value,\n }\n }\n return option\n })\n})\n\nconst slots = useSlots()\n</script>\n\n<template>\n <ElRadioGroup v-bind=\"radioProps\">\n <template v-if=\"!slots.option\">\n <component :is=\"OptionType\" v-for=\"(option, index) of compatiableProps\" :key=\"index\" v-bind=\"option\">\n {{ getOptionLabel(option, index) }}\n </component>\n </template>\n <template v-else>\n <component :is=\"OptionType\" v-for=\"(option, index) of compatiableProps\" :key=\"index\" v-bind=\"option\">\n <slot name=\"option\" :option=\"option\" />\n </component>\n </template>\n </ElRadioGroup>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;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AA,SAAA,MAAA,EAAU,OAAM,EAAA;6BAC1D,CAAvC,WAAuC,KAAA,QAAA,UAAA,EAAV,QAAM,CAAA,CAAA,CAAA"}
|
package/esm/rate/index.d.ts
CHANGED
|
@@ -5,16 +5,16 @@ import * as _$element_plus_es_utils_index_mjs0 from "element-plus/es/utils/index
|
|
|
5
5
|
//#region src/rate/index.d.ts
|
|
6
6
|
type RateProps = typeof ElRate;
|
|
7
7
|
declare const Rate: _$element_plus_es_utils_index_mjs0.SFCWithInstall<_$vue.DefineComponent<{
|
|
8
|
-
|
|
9
|
-
type: _$vue.PropType<
|
|
10
|
-
default: number;
|
|
8
|
+
size: {
|
|
9
|
+
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
11
10
|
};
|
|
12
11
|
disabled: {
|
|
13
12
|
type: _$vue.PropType<boolean>;
|
|
14
13
|
default: undefined;
|
|
15
14
|
};
|
|
16
|
-
|
|
17
|
-
type: _$vue.PropType<
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: _$vue.PropType<number>;
|
|
17
|
+
default: number;
|
|
18
18
|
};
|
|
19
19
|
clearable: {
|
|
20
20
|
type: _$vue.PropType<boolean>;
|
|
@@ -90,16 +90,16 @@ declare const Rate: _$element_plus_es_utils_index_mjs0.SFCWithInstall<_$vue.Defi
|
|
|
90
90
|
"update:modelValue": (value: number) => void;
|
|
91
91
|
change: (value: number) => void;
|
|
92
92
|
}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
|
93
|
-
|
|
94
|
-
type: _$vue.PropType<
|
|
95
|
-
default: number;
|
|
93
|
+
size: {
|
|
94
|
+
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
96
95
|
};
|
|
97
96
|
disabled: {
|
|
98
97
|
type: _$vue.PropType<boolean>;
|
|
99
98
|
default: undefined;
|
|
100
99
|
};
|
|
101
|
-
|
|
102
|
-
type: _$vue.PropType<
|
|
100
|
+
modelValue: {
|
|
101
|
+
type: _$vue.PropType<number>;
|
|
102
|
+
default: number;
|
|
103
103
|
};
|
|
104
104
|
clearable: {
|
|
105
105
|
type: _$vue.PropType<boolean>;
|
package/esm/select/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare const Select: {
|
|
|
8
8
|
disabled: boolean;
|
|
9
9
|
created: boolean;
|
|
10
10
|
}> & Omit<{
|
|
11
|
-
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(
|
|
11
|
+
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | ObjectConstructor | BooleanConstructor | NumberConstructor)[], unknown, unknown>;
|
|
12
12
|
readonly disabled: boolean;
|
|
13
13
|
readonly created: boolean;
|
|
14
14
|
readonly label?: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | NumberConstructor)[], unknown, unknown>;
|
|
@@ -22,7 +22,7 @@ declare const Select: {
|
|
|
22
22
|
disabled: boolean;
|
|
23
23
|
created: boolean;
|
|
24
24
|
}> & Omit<{
|
|
25
|
-
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(
|
|
25
|
+
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | ObjectConstructor | BooleanConstructor | NumberConstructor)[], unknown, unknown>;
|
|
26
26
|
readonly disabled: boolean;
|
|
27
27
|
readonly created: boolean;
|
|
28
28
|
readonly label?: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | NumberConstructor)[], unknown, unknown>;
|
|
@@ -40,7 +40,7 @@ declare const Select: {
|
|
|
40
40
|
disabled: boolean;
|
|
41
41
|
created: boolean;
|
|
42
42
|
}> & Omit<{
|
|
43
|
-
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(
|
|
43
|
+
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | ObjectConstructor | BooleanConstructor | NumberConstructor)[], unknown, unknown>;
|
|
44
44
|
readonly disabled: boolean;
|
|
45
45
|
readonly created: boolean;
|
|
46
46
|
readonly label?: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | NumberConstructor)[], unknown, unknown>;
|
|
@@ -54,7 +54,7 @@ declare const Select: {
|
|
|
54
54
|
disabled: boolean;
|
|
55
55
|
created: boolean;
|
|
56
56
|
}> & Omit<{
|
|
57
|
-
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(
|
|
57
|
+
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | ObjectConstructor | BooleanConstructor | NumberConstructor)[], unknown, unknown>;
|
|
58
58
|
readonly disabled: boolean;
|
|
59
59
|
readonly created: boolean;
|
|
60
60
|
readonly label?: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | NumberConstructor)[], unknown, unknown>;
|
|
@@ -69,7 +69,7 @@ declare const Select: {
|
|
|
69
69
|
disabled: boolean;
|
|
70
70
|
created: boolean;
|
|
71
71
|
}> & Omit<{
|
|
72
|
-
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(
|
|
72
|
+
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | ObjectConstructor | BooleanConstructor | NumberConstructor)[], unknown, unknown>;
|
|
73
73
|
readonly disabled: boolean;
|
|
74
74
|
readonly created: boolean;
|
|
75
75
|
readonly label?: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | NumberConstructor)[], unknown, unknown>;
|
|
@@ -83,7 +83,7 @@ declare const Select: {
|
|
|
83
83
|
disabled: boolean;
|
|
84
84
|
created: boolean;
|
|
85
85
|
}> & Omit<{
|
|
86
|
-
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(
|
|
86
|
+
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | ObjectConstructor | BooleanConstructor | NumberConstructor)[], unknown, unknown>;
|
|
87
87
|
readonly disabled: boolean;
|
|
88
88
|
readonly created: boolean;
|
|
89
89
|
readonly label?: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | NumberConstructor)[], unknown, unknown>;
|
|
@@ -96,7 +96,7 @@ declare const Select: {
|
|
|
96
96
|
disabled: boolean;
|
|
97
97
|
created: boolean;
|
|
98
98
|
}> & Omit<{
|
|
99
|
-
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(
|
|
99
|
+
readonly value: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | ObjectConstructor | BooleanConstructor | NumberConstructor)[], unknown, unknown>;
|
|
100
100
|
readonly disabled: boolean;
|
|
101
101
|
readonly created: boolean;
|
|
102
102
|
readonly label?: _$element_plus_es_utils_index_mjs0.EpPropMergeType<(StringConstructor | NumberConstructor)[], unknown, unknown>;
|
|
@@ -9,10 +9,10 @@ declare const SelectTable: {
|
|
|
9
9
|
}>, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
|
|
10
10
|
"update:modelValue": (...args: any[]) => void;
|
|
11
11
|
}, _$vue.PublicProps, {
|
|
12
|
-
loading: boolean;
|
|
13
12
|
dataSource: any[];
|
|
14
13
|
valueType: "all" | "parent" | "child" | "path";
|
|
15
14
|
mode: "multiple" | "single";
|
|
15
|
+
loading: boolean;
|
|
16
16
|
columns: _$element_plus0.Column<any>[];
|
|
17
17
|
optionAsValue: boolean;
|
|
18
18
|
clickRowToSelect: boolean;
|
|
@@ -28,10 +28,10 @@ declare const SelectTable: {
|
|
|
28
28
|
}, Readonly<ISelectTableProps> & Readonly<{
|
|
29
29
|
"onUpdate:modelValue"?: (...args: any[]) => any;
|
|
30
30
|
}>, {}, {}, {}, {}, {
|
|
31
|
-
loading: boolean;
|
|
32
31
|
dataSource: any[];
|
|
33
32
|
valueType: "all" | "parent" | "child" | "path";
|
|
34
33
|
mode: "multiple" | "single";
|
|
34
|
+
loading: boolean;
|
|
35
35
|
columns: _$element_plus0.Column<any>[];
|
|
36
36
|
optionAsValue: boolean;
|
|
37
37
|
clickRowToSelect: boolean;
|
|
@@ -46,10 +46,10 @@ declare const SelectTable: {
|
|
|
46
46
|
}>, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
|
|
47
47
|
"update:modelValue": (...args: any[]) => void;
|
|
48
48
|
}, string, {
|
|
49
|
-
loading: boolean;
|
|
50
49
|
dataSource: any[];
|
|
51
50
|
valueType: "all" | "parent" | "child" | "path";
|
|
52
51
|
mode: "multiple" | "single";
|
|
52
|
+
loading: boolean;
|
|
53
53
|
columns: _$element_plus0.Column<any>[];
|
|
54
54
|
optionAsValue: boolean;
|
|
55
55
|
clickRowToSelect: boolean;
|
|
@@ -3,7 +3,7 @@ import { stylePrefix } from "../__builtins__/configs/index.mjs";
|
|
|
3
3
|
import { ElLink, ElRadio, ElRadioGroup, ElTable, ElTableColumn, useAttrs, vLoading, version } from "element-plus";
|
|
4
4
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, normalizeClass, openBlock, ref, renderList, renderSlot, toDisplayString, unref, watch, withCtx, withDirectives } from "vue";
|
|
5
5
|
import { useField } from "@silver-formily/vue";
|
|
6
|
-
import { isEqual, isFn, isValid } from "@formily/shared";
|
|
6
|
+
import { isEqual, isFn, isValid } from "@silver-formily/shared";
|
|
7
7
|
import { differenceWith, remove, uniq, uniqWith, xor } from "lodash-es";
|
|
8
8
|
//#region src/select-table/select-table.vue
|
|
9
9
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-table.mjs","names":[],"sources":["../../src/select-table/select-table.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { TableInstance } from 'element-plus'\nimport type { ISelectTableProps } from './types'\nimport { isEqual, isFn, isValid } from '@formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport {\n ElLink,\n ElRadio,\n ElRadioGroup,\n ElTable,\n ElTableColumn,\n useAttrs,\n version,\n vLoading,\n} from 'element-plus'\nimport { differenceWith, remove, uniq, uniqWith, xor } from 'lodash-es'\nimport { computed, nextTick, ref, watch } from 'vue'\nimport { lt, stylePrefix } from '../__builtins__'\n\ndefineOptions({\n name: 'FSelectTable',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<ISelectTableProps>(), {\n columns: () => [],\n mode: 'multiple',\n dataSource: () => [],\n optionAsValue: false,\n valueType: 'all',\n loading: false,\n clickRowToSelect: true,\n showAlertToolbar: true,\n ignoreSelectable: true,\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst elTableProps = useAttrs()\nconst field = useField()\nconst elTableRef = ref<TableInstance>()\nconst radioSelectedKey = ref()\n\nfunction requireRowKey() {\n if (!props.rowKey) {\n throw new Error('rowKey is required')\n }\n return props.rowKey\n}\n\nfunction getRowValue(item?: Record<string, any> | null) {\n if (!props.rowKey || !item) {\n return undefined\n }\n return item[props.rowKey]\n}\n\nfunction getSingleSelectedKey(value: any) {\n if (!isValid(value)) {\n return null\n }\n return props.optionAsValue ? getRowValue(value) ?? null : value\n}\n\nfunction getMultipleSelectedKeys(value: any) {\n if (!Array.isArray(value)) {\n return []\n }\n return value\n .map(item => props.optionAsValue ? getRowValue(item) : item)\n .filter(isValid)\n}\n\nfunction syncRadioSelection(item?: Record<string, any> | null) {\n radioSelectedKey.value = getRowValue(item) ?? null\n elTableRef.value?.setCurrentRow(item)\n}\n\nfunction compatibleRadioValue(key: string) {\n return lt(version, '2.6.0') ? { label: key } : { value: key }\n}\n\nfunction getInitialSelectedList() {\n if (!isValid(props.modelValue)) {\n return []\n }\n\n if (props.mode === 'multiple') {\n if (!Array.isArray(props.modelValue)) {\n return []\n }\n\n return props.modelValue.map((item) => {\n if (!props.optionAsValue) {\n if (!props.rowKey) {\n return null\n }\n return {\n [props.rowKey]: item,\n }\n }\n return item\n }).filter(isValid)\n }\n else {\n if (props.optionAsValue) {\n return [props.modelValue]\n }\n if (!props.rowKey) {\n return []\n }\n return [{ [props.rowKey]: props.modelValue }]\n }\n}\nconst initialSelectedList = getInitialSelectedList()\nconst selectedFlatDataSource = ref(initialSelectedList)\n// 为了获取移除的项而缓存的当前页面的前一次选择。由于element-plus没有获取移除项的方法,需要通过这种方式移除field中移除的项\nlet prevSelection = []\n\nconst currentSelectLength = computed(() => {\n if (props.mode === 'multiple') {\n return Array.isArray(props.modelValue) ? props.modelValue.length : 0\n }\n else {\n return isValid(radioSelectedKey.value) ? 1 : 0\n }\n})\n\nwatch(\n () => props.dataSource,\n async () => {\n const selectedKeys = uniq(\n selectedFlatDataSource.value.map(item => getRowValue(item)).filter(isValid),\n )\n await nextTick()\n for (const item of props.dataSource) {\n const itemKey = getRowValue(item)\n if (isValid(itemKey) && selectedKeys.includes(itemKey)) {\n if (props.mode === 'multiple') {\n elTableRef.value?.toggleRowSelection(item, true, props.ignoreSelectable)\n }\n else {\n syncRadioSelection(item)\n }\n }\n await nextTick()\n prevSelection = elTableRef.value?.getSelectionRows() ?? []\n }\n },\n { immediate: true },\n)\n\nwatch(\n () => [props.modelValue, props.loading],\n async ([value, loading]) => {\n if (loading) {\n return\n }\n if (props.mode === 'single') {\n const selectedKey = getSingleSelectedKey(value)\n radioSelectedKey.value = selectedKey\n const selectedItem = props.dataSource.find(item => getRowValue(item) === selectedKey)\n elTableRef.value?.setCurrentRow(selectedItem)\n }\n else {\n await nextTick()\n const currentDisplayDataKeys = elTableRef.value\n ?.getSelectionRows()\n .map(item => getRowValue(item))\n .filter(isValid) ?? []\n const valueKeys = getMultipleSelectedKeys(value)\n selectedFlatDataSource.value = selectedFlatDataSource.value.filter(\n item => valueKeys.includes(getRowValue(item)),\n )\n if (isEqual(valueKeys, currentDisplayDataKeys)) {\n return\n }\n const diffItems = xor(valueKeys, currentDisplayDataKeys)\n for (const tableItem of props.dataSource) {\n const itemKey = getRowValue(tableItem)\n if (isValid(itemKey) && diffItems.includes(itemKey)) {\n const shouldSelect = valueKeys.includes(itemKey)\n elTableRef.value?.toggleRowSelection(tableItem, shouldSelect, props.ignoreSelectable)\n }\n }\n }\n },\n {\n immediate: true,\n },\n)\n\nfunction onSelect(newSelection: Record<string, any>[]) {\n const rowKey = requireRowKey()\n\n const removedItemList\n = prevSelection.length > newSelection.length\n ? differenceWith(\n prevSelection,\n newSelection,\n (itemPrev, itemNext) => {\n return itemPrev[rowKey] === itemNext[rowKey]\n },\n )\n : []\n prevSelection = [...newSelection]\n selectedFlatDataSource.value = uniqWith(\n [...selectedFlatDataSource.value, ...newSelection],\n (itemPrev, itemNext) => {\n return itemPrev[rowKey] === itemNext[rowKey]\n },\n )\n if (removedItemList.length > 0) {\n const removedKeys = uniq(removedItemList.map(item => item[rowKey]))\n remove(selectedFlatDataSource.value, item =>\n removedKeys.includes(item[rowKey]))\n }\n\n if (props.optionAsValue) {\n emit('update:modelValue', selectedFlatDataSource.value)\n }\n else {\n const selectedKeys = selectedFlatDataSource.value.map(\n item => item[rowKey],\n )\n emit('update:modelValue', selectedKeys)\n }\n}\n\nfunction onRadioClick(item) {\n const rowKey = requireRowKey()\n syncRadioSelection(item)\n if (props.optionAsValue) {\n emit('update:modelValue', item)\n }\n else {\n emit('update:modelValue', item[rowKey])\n }\n}\n\nfunction onRowClick(row: Record<string, any>, _, event: Event) {\n if (!props.clickRowToSelect)\n return\n\n if (props.mode === 'multiple') {\n const checkboxDOM = (event.target as Element)\n .closest('tr')\n .querySelector('input[type=\"checkbox\"]')\n if (checkboxDOM instanceof HTMLElement) {\n checkboxDOM.click()\n }\n }\n else {\n const radioDOM = (event.target as Element)\n .closest('tr')\n .querySelector('input[type=\"radio\"]')\n if (radioDOM instanceof HTMLElement) {\n radioDOM.click()\n }\n }\n}\n\nfunction onClearSelectionClick() {\n if (props.mode === 'multiple') {\n emit('update:modelValue', [])\n selectedFlatDataSource.value = []\n }\n else {\n syncRadioSelection(null)\n emit('update:modelValue', null)\n }\n}\n\nfunction selectable(row: Record<string, any>, index: number) {\n if (props.selectable && isFn(props.selectable)) {\n return props.selectable(row, index, field.value)\n }\n return true\n}\n</script>\n\n<template>\n <div :class=\"`${stylePrefix}-select-table`\">\n <div\n v-if=\"currentSelectLength > 0 && props.showAlertToolbar\"\n :class=\"`${stylePrefix}-select-table-alert-container`\"\n >\n <span>已选择 {{ currentSelectLength }} 项</span>\n <ElLink\n type=\"primary\"\n :underline=\"lt(version, '2.9.9') ? false : 'never'\"\n style=\"margin-left: 8px;\"\n @click=\"onClearSelectionClick\"\n >\n 取消选择\n </ElLink>\n </div>\n <ElTable\n ref=\"elTableRef\"\n v-loading=\"props.loading\"\n v-bind=\"elTableProps\"\n :row-key=\"rowKey\"\n :row-class-name=\"props.clickRowToSelect ? `--click-row-select` : ''\"\n :data=\"props.dataSource\"\n :highlight-current-row=\"props.mode === 'single'\"\n @select=\"onSelect\"\n @select-all=\"onSelect\"\n @row-click=\"onRowClick\"\n >\n <ElTableColumn\n v-if=\"props.mode === 'multiple'\"\n type=\"selection\"\n :selectable=\"selectable\"\n />\n <ElTableColumn\n v-else\n width=\"46\"\n >\n <template #default=\"{ row }\">\n <ElRadioGroup v-model=\"radioSelectedKey\" style=\"width: 100%;\">\n <ElRadio\n v-bind=\"compatibleRadioValue(row[rowKey])\"\n @change=\"() => onRadioClick(row)\"\n >\n \n </ElRadio>\n </ElRadioGroup>\n </template>\n </ElTableColumn>\n <template v-if=\"props.columns.length === 0\">\n <slot />\n </template>\n <template v-else>\n <ElTableColumn\n v-for=\"colItem of props.columns\"\n v-bind=\"colItem\"\n :key=\"colItem.prop || colItem.type\"\n />\n </template>\n </ElTable>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBA,MAAM,QAAQ;EAYd,MAAM,OAAO;EAEb,MAAM,eAAe,UAAS;EAC9B,MAAM,QAAQ,UAAS;EACvB,MAAM,aAAa,KAAmB;EACtC,MAAM,mBAAmB,KAAI;EAE7B,SAAS,gBAAgB;AACvB,OAAI,CAAC,MAAM,OACT,OAAM,IAAI,MAAM,qBAA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B,YAOe,MAAA,aAAA,EAAA;kBAPQ,iBAAA;mEAAA,iBAAgB,QAAA;MAAE,OAAA,EAAA,SAAA,QAAoB;;6BAMjD,CALV,YAKU,MAAA,QAAA,EALV,WACU,qBAAqB,IAAI,QAAA,QAAM,EAAA,EACtC,gBAAc,aAAa,IAAG,EAAA,CAAA,EAAA;8BAGjC,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAFC,UAED,GAAA,CAAA,EAAA,CAAA;;;;;;SAIU,MAAM,QAAQ,WAAM,IAClC,WAAQ,KAAA,QAAA,WAAA,EAAA,KAAA,GAAA,CAAA,IAAA,UAAA,KAAA,EAGR,mBAIE,UAAA,EAAA,KAAA,GAAA,EAAA,WAHkB,MAAM,UAAjB,YAAO;yBADhB,YAIE,MAAA,cAAA,EAJF,WAIE,EAAA,SAAA,MAAA,EAFQ,SAAO,EACd,KAAK,QAAQ,QAAQ,QAAQ,MAAA,CAAA,EAAA,MAAA,GAAA;;;;;;;;2BArCvB,MAAM,QAAO,CAAA,CAAA,CAAA,EAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"select-table.mjs","names":[],"sources":["../../src/select-table/select-table.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { TableInstance } from 'element-plus'\nimport type { ISelectTableProps } from './types'\nimport { isEqual, isFn, isValid } from '@silver-formily/shared'\nimport { useField } from '@silver-formily/vue'\nimport {\n ElLink,\n ElRadio,\n ElRadioGroup,\n ElTable,\n ElTableColumn,\n useAttrs,\n version,\n vLoading,\n} from 'element-plus'\nimport { differenceWith, remove, uniq, uniqWith, xor } from 'lodash-es'\nimport { computed, nextTick, ref, watch } from 'vue'\nimport { lt, stylePrefix } from '../__builtins__'\n\ndefineOptions({\n name: 'FSelectTable',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<ISelectTableProps>(), {\n columns: () => [],\n mode: 'multiple',\n dataSource: () => [],\n optionAsValue: false,\n valueType: 'all',\n loading: false,\n clickRowToSelect: true,\n showAlertToolbar: true,\n ignoreSelectable: true,\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst elTableProps = useAttrs()\nconst field = useField()\nconst elTableRef = ref<TableInstance>()\nconst radioSelectedKey = ref()\n\nfunction requireRowKey() {\n if (!props.rowKey) {\n throw new Error('rowKey is required')\n }\n return props.rowKey\n}\n\nfunction getRowValue(item?: Record<string, any> | null) {\n if (!props.rowKey || !item) {\n return undefined\n }\n return item[props.rowKey]\n}\n\nfunction getSingleSelectedKey(value: any) {\n if (!isValid(value)) {\n return null\n }\n return props.optionAsValue ? getRowValue(value) ?? null : value\n}\n\nfunction getMultipleSelectedKeys(value: any) {\n if (!Array.isArray(value)) {\n return []\n }\n return value\n .map(item => props.optionAsValue ? getRowValue(item) : item)\n .filter(isValid)\n}\n\nfunction syncRadioSelection(item?: Record<string, any> | null) {\n radioSelectedKey.value = getRowValue(item) ?? null\n elTableRef.value?.setCurrentRow(item)\n}\n\nfunction compatibleRadioValue(key: string) {\n return lt(version, '2.6.0') ? { label: key } : { value: key }\n}\n\nfunction getInitialSelectedList() {\n if (!isValid(props.modelValue)) {\n return []\n }\n\n if (props.mode === 'multiple') {\n if (!Array.isArray(props.modelValue)) {\n return []\n }\n\n return props.modelValue.map((item) => {\n if (!props.optionAsValue) {\n if (!props.rowKey) {\n return null\n }\n return {\n [props.rowKey]: item,\n }\n }\n return item\n }).filter(isValid)\n }\n else {\n if (props.optionAsValue) {\n return [props.modelValue]\n }\n if (!props.rowKey) {\n return []\n }\n return [{ [props.rowKey]: props.modelValue }]\n }\n}\nconst initialSelectedList = getInitialSelectedList()\nconst selectedFlatDataSource = ref(initialSelectedList)\n// 为了获取移除的项而缓存的当前页面的前一次选择。由于element-plus没有获取移除项的方法,需要通过这种方式移除field中移除的项\nlet prevSelection = []\n\nconst currentSelectLength = computed(() => {\n if (props.mode === 'multiple') {\n return Array.isArray(props.modelValue) ? props.modelValue.length : 0\n }\n else {\n return isValid(radioSelectedKey.value) ? 1 : 0\n }\n})\n\nwatch(\n () => props.dataSource,\n async () => {\n const selectedKeys = uniq(\n selectedFlatDataSource.value.map(item => getRowValue(item)).filter(isValid),\n )\n await nextTick()\n for (const item of props.dataSource) {\n const itemKey = getRowValue(item)\n if (isValid(itemKey) && selectedKeys.includes(itemKey)) {\n if (props.mode === 'multiple') {\n elTableRef.value?.toggleRowSelection(item, true, props.ignoreSelectable)\n }\n else {\n syncRadioSelection(item)\n }\n }\n await nextTick()\n prevSelection = elTableRef.value?.getSelectionRows() ?? []\n }\n },\n { immediate: true },\n)\n\nwatch(\n () => [props.modelValue, props.loading],\n async ([value, loading]) => {\n if (loading) {\n return\n }\n if (props.mode === 'single') {\n const selectedKey = getSingleSelectedKey(value)\n radioSelectedKey.value = selectedKey\n const selectedItem = props.dataSource.find(item => getRowValue(item) === selectedKey)\n elTableRef.value?.setCurrentRow(selectedItem)\n }\n else {\n await nextTick()\n const currentDisplayDataKeys = elTableRef.value\n ?.getSelectionRows()\n .map(item => getRowValue(item))\n .filter(isValid) ?? []\n const valueKeys = getMultipleSelectedKeys(value)\n selectedFlatDataSource.value = selectedFlatDataSource.value.filter(\n item => valueKeys.includes(getRowValue(item)),\n )\n if (isEqual(valueKeys, currentDisplayDataKeys)) {\n return\n }\n const diffItems = xor(valueKeys, currentDisplayDataKeys)\n for (const tableItem of props.dataSource) {\n const itemKey = getRowValue(tableItem)\n if (isValid(itemKey) && diffItems.includes(itemKey)) {\n const shouldSelect = valueKeys.includes(itemKey)\n elTableRef.value?.toggleRowSelection(tableItem, shouldSelect, props.ignoreSelectable)\n }\n }\n }\n },\n {\n immediate: true,\n },\n)\n\nfunction onSelect(newSelection: Record<string, any>[]) {\n const rowKey = requireRowKey()\n\n const removedItemList\n = prevSelection.length > newSelection.length\n ? differenceWith(\n prevSelection,\n newSelection,\n (itemPrev, itemNext) => {\n return itemPrev[rowKey] === itemNext[rowKey]\n },\n )\n : []\n prevSelection = [...newSelection]\n selectedFlatDataSource.value = uniqWith(\n [...selectedFlatDataSource.value, ...newSelection],\n (itemPrev, itemNext) => {\n return itemPrev[rowKey] === itemNext[rowKey]\n },\n )\n if (removedItemList.length > 0) {\n const removedKeys = uniq(removedItemList.map(item => item[rowKey]))\n remove(selectedFlatDataSource.value, item =>\n removedKeys.includes(item[rowKey]))\n }\n\n if (props.optionAsValue) {\n emit('update:modelValue', selectedFlatDataSource.value)\n }\n else {\n const selectedKeys = selectedFlatDataSource.value.map(\n item => item[rowKey],\n )\n emit('update:modelValue', selectedKeys)\n }\n}\n\nfunction onRadioClick(item) {\n const rowKey = requireRowKey()\n syncRadioSelection(item)\n if (props.optionAsValue) {\n emit('update:modelValue', item)\n }\n else {\n emit('update:modelValue', item[rowKey])\n }\n}\n\nfunction onRowClick(row: Record<string, any>, _, event: Event) {\n if (!props.clickRowToSelect)\n return\n\n if (props.mode === 'multiple') {\n const checkboxDOM = (event.target as Element)\n .closest('tr')\n .querySelector('input[type=\"checkbox\"]')\n if (checkboxDOM instanceof HTMLElement) {\n checkboxDOM.click()\n }\n }\n else {\n const radioDOM = (event.target as Element)\n .closest('tr')\n .querySelector('input[type=\"radio\"]')\n if (radioDOM instanceof HTMLElement) {\n radioDOM.click()\n }\n }\n}\n\nfunction onClearSelectionClick() {\n if (props.mode === 'multiple') {\n emit('update:modelValue', [])\n selectedFlatDataSource.value = []\n }\n else {\n syncRadioSelection(null)\n emit('update:modelValue', null)\n }\n}\n\nfunction selectable(row: Record<string, any>, index: number) {\n if (props.selectable && isFn(props.selectable)) {\n return props.selectable(row, index, field.value)\n }\n return true\n}\n</script>\n\n<template>\n <div :class=\"`${stylePrefix}-select-table`\">\n <div\n v-if=\"currentSelectLength > 0 && props.showAlertToolbar\"\n :class=\"`${stylePrefix}-select-table-alert-container`\"\n >\n <span>已选择 {{ currentSelectLength }} 项</span>\n <ElLink\n type=\"primary\"\n :underline=\"lt(version, '2.9.9') ? false : 'never'\"\n style=\"margin-left: 8px;\"\n @click=\"onClearSelectionClick\"\n >\n 取消选择\n </ElLink>\n </div>\n <ElTable\n ref=\"elTableRef\"\n v-loading=\"props.loading\"\n v-bind=\"elTableProps\"\n :row-key=\"rowKey\"\n :row-class-name=\"props.clickRowToSelect ? `--click-row-select` : ''\"\n :data=\"props.dataSource\"\n :highlight-current-row=\"props.mode === 'single'\"\n @select=\"onSelect\"\n @select-all=\"onSelect\"\n @row-click=\"onRowClick\"\n >\n <ElTableColumn\n v-if=\"props.mode === 'multiple'\"\n type=\"selection\"\n :selectable=\"selectable\"\n />\n <ElTableColumn\n v-else\n width=\"46\"\n >\n <template #default=\"{ row }\">\n <ElRadioGroup v-model=\"radioSelectedKey\" style=\"width: 100%;\">\n <ElRadio\n v-bind=\"compatibleRadioValue(row[rowKey])\"\n @change=\"() => onRadioClick(row)\"\n >\n \n </ElRadio>\n </ElRadioGroup>\n </template>\n </ElTableColumn>\n <template v-if=\"props.columns.length === 0\">\n <slot />\n </template>\n <template v-else>\n <ElTableColumn\n v-for=\"colItem of props.columns\"\n v-bind=\"colItem\"\n :key=\"colItem.prop || colItem.type\"\n />\n </template>\n </ElTable>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBA,MAAM,QAAQ;EAYd,MAAM,OAAO;EAEb,MAAM,eAAe,UAAS;EAC9B,MAAM,QAAQ,UAAS;EACvB,MAAM,aAAa,KAAmB;EACtC,MAAM,mBAAmB,KAAI;EAE7B,SAAS,gBAAgB;AACvB,OAAI,CAAC,MAAM,OACT,OAAM,IAAI,MAAM,qBAAoB;AAEtC,UAAO,MAAM;;EAGf,SAAS,YAAY,MAAmC;AACtD,OAAI,CAAC,MAAM,UAAU,CAAC,KACpB;AAEF,UAAO,KAAK,MAAM;;EAGpB,SAAS,qBAAqB,OAAY;AACxC,OAAI,CAAC,QAAQ,MAAM,CACjB,QAAO;AAET,UAAO,MAAM,gBAAgB,YAAY,MAAM,IAAI,OAAO;;EAG5D,SAAS,wBAAwB,OAAY;AAC3C,OAA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AAA,CAAA,EAAA,CAAA;;;;;;SAIU,MAAM,QAAQ,WAAM,IAClC,WAAQ,KAAA,QAAA,WAAA,EAAA,KAAA,GAAA,CAAA,IAAA,UAAA,KAAA,EAGR,mBAIE,UAAA,EAAA,KAAA,GAAA,EAAA,WAHkB,MAAM,UAAjB,YAAO;yBADhB,YAIE,MAAA,cAAA,EAJF,WAIE,EAAA,SAAA,MAAA,EAFQ,SAAO,EACd,KAAK,QAAQ,QAAQ,QAAQ,MAAA,CAAA,EAAA,MAAA,GAAA;;;;;;;;2BArCvB,MAAM,QAAO,CAAA,CAAA,CAAA,EAAA,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit.mjs","names":["$attrs"],"sources":["../../src/submit/submit.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { IFormFeedback } from '@formily/core'\nimport type { PropType } from 'vue'\nimport { useParentForm } from '@silver-formily/vue'\nimport { ElButton } from 'element-plus'\n\ndefineOptions({\n name: 'FSubmit',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n onClick: Function as PropType<(e: MouseEvent) => any>,\n onSubmit: Function as PropType<(values: any) => Promise<any>>,\n onSubmitSuccess: Function as PropType<(payload: any) => void>,\n onSubmitFailed: Function as PropType<(feedbacks: IFormFeedback[]) => void>,\n submit: Boolean,\n loading: Boolean,\n})\n\nconst formRef = useParentForm()\n\nfunction handleClick(e: MouseEvent) {\n if (props.onClick?.(e) === false)\n return\n if (props.onSubmit) {\n const form = formRef?.value\n form?.submit(props.onSubmit)\n .then(props.onSubmitSuccess)\n .catch(props.onSubmitFailed ?? console.error)\n }\n}\n</script>\n\n<template>\n <ElButton\n :native-type=\"props.submit ? 'button' : 'submit'\"\n type=\"primary\"\n v-bind=\"$attrs\"\n :loading=\"formRef?.submitting ?? props.loading\"\n @click=\"handleClick\"\n >\n <template #default>\n <slot />\n </template>\n </ElButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAWA,MAAM,QAAQ;EASd,MAAM,UAAU,eAAc;EAE9B,SAAS,YAAY,GAAe;AAClC,OAAI,MAAM,UAAU,EAAE,KAAK,MACzB;AACF,OAAI,MAAM,SAER,EADa,SAAS,QAChB,OAAO,MAAM,SAAQ,CACxB,KAAK,MAAM,gBAAe,CAC1B,MAAM,MAAM,kBAAkB,QAAQ,MAAK;;;uBAMhD,YAUW,MAAA,SAAA,EAVX,WAUW;IATR,eAAa,MAAM,SAAM,WAAA;IAC1B,MAAK;MACGA,KAAAA,QAAM;IACb,SAAS,MAAA,QAAO,EAAE,cAAc,MAAM;IACtC,SAAO;;IAEG,SAAO,cACR,CAAR,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"submit.mjs","names":["$attrs"],"sources":["../../src/submit/submit.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { IFormFeedback } from '@silver-formily/core'\nimport type { PropType } from 'vue'\nimport { useParentForm } from '@silver-formily/vue'\nimport { ElButton } from 'element-plus'\n\ndefineOptions({\n name: 'FSubmit',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n onClick: Function as PropType<(e: MouseEvent) => any>,\n onSubmit: Function as PropType<(values: any) => Promise<any>>,\n onSubmitSuccess: Function as PropType<(payload: any) => void>,\n onSubmitFailed: Function as PropType<(feedbacks: IFormFeedback[]) => void>,\n submit: Boolean,\n loading: Boolean,\n})\n\nconst formRef = useParentForm()\n\nfunction handleClick(e: MouseEvent) {\n if (props.onClick?.(e) === false)\n return\n if (props.onSubmit) {\n const form = formRef?.value\n form?.submit(props.onSubmit)\n .then(props.onSubmitSuccess)\n .catch(props.onSubmitFailed ?? console.error)\n }\n}\n</script>\n\n<template>\n <ElButton\n :native-type=\"props.submit ? 'button' : 'submit'\"\n type=\"primary\"\n v-bind=\"$attrs\"\n :loading=\"formRef?.submitting ?? props.loading\"\n @click=\"handleClick\"\n >\n <template #default>\n <slot />\n </template>\n </ElButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAWA,MAAM,QAAQ;EASd,MAAM,UAAU,eAAc;EAE9B,SAAS,YAAY,GAAe;AAClC,OAAI,MAAM,UAAU,EAAE,KAAK,MACzB;AACF,OAAI,MAAM,SAER,EADa,SAAS,QAChB,OAAO,MAAM,SAAQ,CACxB,KAAK,MAAM,gBAAe,CAC1B,MAAM,MAAM,kBAAkB,QAAQ,MAAK;;;uBAMhD,YAUW,MAAA,SAAA,EAVX,WAUW;IATR,eAAa,MAAM,SAAM,WAAA;IAC1B,MAAK;MACGA,KAAAA,QAAM;IACb,SAAS,MAAA,QAAO,EAAE,cAAc,MAAM;IACtC,SAAO;;IAEG,SAAO,cACR,CAAR,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA"}
|
package/esm/switch/index.d.ts
CHANGED
|
@@ -6,23 +6,20 @@ import * as _$element_plus_es_utils_index_mjs0 from "element-plus/es/utils/index
|
|
|
6
6
|
type SwitchProps = typeof ElSwitch;
|
|
7
7
|
declare const Switch: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
8
8
|
new (...args: any[]): _$vue.CreateComponentPublicInstanceWithMixins<Readonly<_$vue.ExtractPropTypes<{
|
|
9
|
-
modelValue: {
|
|
10
|
-
type: _$vue.PropType<string | number | boolean>;
|
|
11
|
-
default: boolean;
|
|
12
|
-
};
|
|
13
9
|
name: {
|
|
14
10
|
type: _$vue.PropType<string>;
|
|
15
11
|
default: string;
|
|
16
12
|
};
|
|
17
|
-
disabled: {
|
|
18
|
-
type: _$vue.PropType<boolean>;
|
|
19
|
-
default: undefined;
|
|
20
|
-
};
|
|
21
13
|
size: {
|
|
22
14
|
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
23
15
|
};
|
|
24
|
-
|
|
16
|
+
disabled: {
|
|
25
17
|
type: _$vue.PropType<boolean>;
|
|
18
|
+
default: undefined;
|
|
19
|
+
};
|
|
20
|
+
modelValue: {
|
|
21
|
+
type: _$vue.PropType<string | number | boolean>;
|
|
22
|
+
default: boolean;
|
|
26
23
|
};
|
|
27
24
|
validateEvent: {
|
|
28
25
|
type: _$vue.PropType<boolean>;
|
|
@@ -37,6 +34,9 @@ declare const Switch: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
37
34
|
tabindex: {
|
|
38
35
|
type: _$vue.PropType<string | number>;
|
|
39
36
|
};
|
|
37
|
+
loading: {
|
|
38
|
+
type: _$vue.PropType<boolean>;
|
|
39
|
+
};
|
|
40
40
|
width: {
|
|
41
41
|
type: _$vue.PropType<string | number>;
|
|
42
42
|
default: string;
|
|
@@ -104,23 +104,20 @@ declare const Switch: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
104
104
|
M: {};
|
|
105
105
|
Defaults: {};
|
|
106
106
|
}, Readonly<_$vue.ExtractPropTypes<{
|
|
107
|
-
modelValue: {
|
|
108
|
-
type: _$vue.PropType<string | number | boolean>;
|
|
109
|
-
default: boolean;
|
|
110
|
-
};
|
|
111
107
|
name: {
|
|
112
108
|
type: _$vue.PropType<string>;
|
|
113
109
|
default: string;
|
|
114
110
|
};
|
|
115
|
-
disabled: {
|
|
116
|
-
type: _$vue.PropType<boolean>;
|
|
117
|
-
default: undefined;
|
|
118
|
-
};
|
|
119
111
|
size: {
|
|
120
112
|
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
121
113
|
};
|
|
122
|
-
|
|
114
|
+
disabled: {
|
|
123
115
|
type: _$vue.PropType<boolean>;
|
|
116
|
+
default: undefined;
|
|
117
|
+
};
|
|
118
|
+
modelValue: {
|
|
119
|
+
type: _$vue.PropType<string | number | boolean>;
|
|
120
|
+
default: boolean;
|
|
124
121
|
};
|
|
125
122
|
validateEvent: {
|
|
126
123
|
type: _$vue.PropType<boolean>;
|
|
@@ -135,6 +132,9 @@ declare const Switch: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
135
132
|
tabindex: {
|
|
136
133
|
type: _$vue.PropType<string | number>;
|
|
137
134
|
};
|
|
135
|
+
loading: {
|
|
136
|
+
type: _$vue.PropType<boolean>;
|
|
137
|
+
};
|
|
138
138
|
width: {
|
|
139
139
|
type: _$vue.PropType<string | number>;
|
|
140
140
|
default: string;
|
|
@@ -195,23 +195,20 @@ declare const Switch: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
195
195
|
__isTeleport?: never;
|
|
196
196
|
__isSuspense?: never;
|
|
197
197
|
} & _$vue.ComponentOptionsBase<Readonly<_$vue.ExtractPropTypes<{
|
|
198
|
-
modelValue: {
|
|
199
|
-
type: _$vue.PropType<string | number | boolean>;
|
|
200
|
-
default: boolean;
|
|
201
|
-
};
|
|
202
198
|
name: {
|
|
203
199
|
type: _$vue.PropType<string>;
|
|
204
200
|
default: string;
|
|
205
201
|
};
|
|
206
|
-
disabled: {
|
|
207
|
-
type: _$vue.PropType<boolean>;
|
|
208
|
-
default: undefined;
|
|
209
|
-
};
|
|
210
202
|
size: {
|
|
211
203
|
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
212
204
|
};
|
|
213
|
-
|
|
205
|
+
disabled: {
|
|
214
206
|
type: _$vue.PropType<boolean>;
|
|
207
|
+
default: undefined;
|
|
208
|
+
};
|
|
209
|
+
modelValue: {
|
|
210
|
+
type: _$vue.PropType<string | number | boolean>;
|
|
211
|
+
default: boolean;
|
|
215
212
|
};
|
|
216
213
|
validateEvent: {
|
|
217
214
|
type: _$vue.PropType<boolean>;
|
|
@@ -226,6 +223,9 @@ declare const Switch: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
226
223
|
tabindex: {
|
|
227
224
|
type: _$vue.PropType<string | number>;
|
|
228
225
|
};
|
|
226
|
+
loading: {
|
|
227
|
+
type: _$vue.PropType<boolean>;
|
|
228
|
+
};
|
|
229
229
|
width: {
|
|
230
230
|
type: _$vue.PropType<string | number>;
|
|
231
231
|
default: string;
|
|
@@ -4,16 +4,19 @@ import * as _$element_plus_es_utils_index_mjs0 from "element-plus/es/utils/index
|
|
|
4
4
|
|
|
5
5
|
//#region src/time-select/index.d.ts
|
|
6
6
|
declare const TimeSelect: _$element_plus_es_utils_index_mjs0.SFCWithInstall<_$vue.DefineComponent<{
|
|
7
|
-
modelValue: {
|
|
8
|
-
type: _$vue.PropType<string>;
|
|
9
|
-
};
|
|
10
7
|
name: {
|
|
11
8
|
type: _$vue.PropType<string>;
|
|
12
9
|
};
|
|
10
|
+
size: {
|
|
11
|
+
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
12
|
+
};
|
|
13
13
|
disabled: {
|
|
14
14
|
type: _$vue.PropType<boolean>;
|
|
15
15
|
default: undefined;
|
|
16
16
|
};
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: _$vue.PropType<string>;
|
|
19
|
+
};
|
|
17
20
|
popperClass: {
|
|
18
21
|
type: _$vue.PropType<string>;
|
|
19
22
|
default: string;
|
|
@@ -22,13 +25,6 @@ declare const TimeSelect: _$element_plus_es_utils_index_mjs0.SFCWithInstall<_$vu
|
|
|
22
25
|
type: _$vue.PropType<string | _$vue.CSSProperties>;
|
|
23
26
|
default: undefined;
|
|
24
27
|
};
|
|
25
|
-
size: {
|
|
26
|
-
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
27
|
-
};
|
|
28
|
-
editable: {
|
|
29
|
-
type: _$vue.PropType<boolean>;
|
|
30
|
-
default: boolean;
|
|
31
|
-
};
|
|
32
28
|
placeholder: {
|
|
33
29
|
type: _$vue.PropType<string>;
|
|
34
30
|
};
|
|
@@ -59,6 +55,10 @@ declare const TimeSelect: _$element_plus_es_utils_index_mjs0.SFCWithInstall<_$vu
|
|
|
59
55
|
type: _$vue.PropType<string>;
|
|
60
56
|
default: string;
|
|
61
57
|
};
|
|
58
|
+
editable: {
|
|
59
|
+
type: _$vue.PropType<boolean>;
|
|
60
|
+
default: boolean;
|
|
61
|
+
};
|
|
62
62
|
step: {
|
|
63
63
|
type: _$vue.PropType<string>;
|
|
64
64
|
default: string;
|
|
@@ -90,16 +90,19 @@ declare const TimeSelect: _$element_plus_es_utils_index_mjs0.SFCWithInstall<_$vu
|
|
|
90
90
|
clear: (...args: any[]) => void;
|
|
91
91
|
blur: (...args: any[]) => void;
|
|
92
92
|
}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
|
93
|
-
modelValue: {
|
|
94
|
-
type: _$vue.PropType<string>;
|
|
95
|
-
};
|
|
96
93
|
name: {
|
|
97
94
|
type: _$vue.PropType<string>;
|
|
98
95
|
};
|
|
96
|
+
size: {
|
|
97
|
+
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
98
|
+
};
|
|
99
99
|
disabled: {
|
|
100
100
|
type: _$vue.PropType<boolean>;
|
|
101
101
|
default: undefined;
|
|
102
102
|
};
|
|
103
|
+
modelValue: {
|
|
104
|
+
type: _$vue.PropType<string>;
|
|
105
|
+
};
|
|
103
106
|
popperClass: {
|
|
104
107
|
type: _$vue.PropType<string>;
|
|
105
108
|
default: string;
|
|
@@ -108,13 +111,6 @@ declare const TimeSelect: _$element_plus_es_utils_index_mjs0.SFCWithInstall<_$vu
|
|
|
108
111
|
type: _$vue.PropType<string | _$vue.CSSProperties>;
|
|
109
112
|
default: undefined;
|
|
110
113
|
};
|
|
111
|
-
size: {
|
|
112
|
-
type: _$vue.PropType<"" | "default" | "small" | "large">;
|
|
113
|
-
};
|
|
114
|
-
editable: {
|
|
115
|
-
type: _$vue.PropType<boolean>;
|
|
116
|
-
default: boolean;
|
|
117
|
-
};
|
|
118
114
|
placeholder: {
|
|
119
115
|
type: _$vue.PropType<string>;
|
|
120
116
|
};
|
|
@@ -145,6 +141,10 @@ declare const TimeSelect: _$element_plus_es_utils_index_mjs0.SFCWithInstall<_$vu
|
|
|
145
141
|
type: _$vue.PropType<string>;
|
|
146
142
|
default: string;
|
|
147
143
|
};
|
|
144
|
+
editable: {
|
|
145
|
+
type: _$vue.PropType<boolean>;
|
|
146
|
+
default: boolean;
|
|
147
|
+
};
|
|
148
148
|
step: {
|
|
149
149
|
type: _$vue.PropType<string>;
|
|
150
150
|
default: string;
|
package/esm/transfer/index.d.ts
CHANGED
|
@@ -8,10 +8,6 @@ import * as _$element_plus_es_components_transfer_src_transfer_panel_mjs0 from "
|
|
|
8
8
|
type TransferProps = typeof ElTransfer;
|
|
9
9
|
declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
10
10
|
new (...args: any[]): _$vue.CreateComponentPublicInstanceWithMixins<Readonly<_$vue.ExtractPropTypes<{
|
|
11
|
-
modelValue: {
|
|
12
|
-
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
13
|
-
default: () => never[];
|
|
14
|
-
};
|
|
15
11
|
props: {
|
|
16
12
|
type: _$vue.PropType<_$element_plus0.TransferPropsAlias>;
|
|
17
13
|
default: () => {
|
|
@@ -24,6 +20,10 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
24
20
|
type: _$vue.PropType<_$element_plus0.TransferDataItem[]>;
|
|
25
21
|
default: () => never[];
|
|
26
22
|
};
|
|
23
|
+
modelValue: {
|
|
24
|
+
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
25
|
+
default: () => never[];
|
|
26
|
+
};
|
|
27
27
|
filterable: {
|
|
28
28
|
type: _$vue.PropType<boolean>;
|
|
29
29
|
};
|
|
@@ -38,9 +38,6 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
38
38
|
type: _$vue.PropType<_$element_plus0.TransferFormat>;
|
|
39
39
|
default: () => {};
|
|
40
40
|
};
|
|
41
|
-
renderContent: {
|
|
42
|
-
type: _$vue.PropType<_$element_plus0.renderContent>;
|
|
43
|
-
};
|
|
44
41
|
titles: {
|
|
45
42
|
type: _$vue.PropType<[string, string]>;
|
|
46
43
|
default: () => [string, string];
|
|
@@ -60,6 +57,9 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
60
57
|
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
61
58
|
default: () => never[];
|
|
62
59
|
};
|
|
60
|
+
renderContent: {
|
|
61
|
+
type: _$vue.PropType<_$element_plus0.renderContent>;
|
|
62
|
+
};
|
|
63
63
|
targetOrder: {
|
|
64
64
|
type: _$vue.PropType<"push" | "unshift" | "original">;
|
|
65
65
|
default: string;
|
|
@@ -97,10 +97,6 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
97
97
|
M: {};
|
|
98
98
|
Defaults: {};
|
|
99
99
|
}, Readonly<_$vue.ExtractPropTypes<{
|
|
100
|
-
modelValue: {
|
|
101
|
-
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
102
|
-
default: () => never[];
|
|
103
|
-
};
|
|
104
100
|
props: {
|
|
105
101
|
type: _$vue.PropType<_$element_plus0.TransferPropsAlias>;
|
|
106
102
|
default: () => {
|
|
@@ -113,6 +109,10 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
113
109
|
type: _$vue.PropType<_$element_plus0.TransferDataItem[]>;
|
|
114
110
|
default: () => never[];
|
|
115
111
|
};
|
|
112
|
+
modelValue: {
|
|
113
|
+
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
114
|
+
default: () => never[];
|
|
115
|
+
};
|
|
116
116
|
filterable: {
|
|
117
117
|
type: _$vue.PropType<boolean>;
|
|
118
118
|
};
|
|
@@ -127,9 +127,6 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
127
127
|
type: _$vue.PropType<_$element_plus0.TransferFormat>;
|
|
128
128
|
default: () => {};
|
|
129
129
|
};
|
|
130
|
-
renderContent: {
|
|
131
|
-
type: _$vue.PropType<_$element_plus0.renderContent>;
|
|
132
|
-
};
|
|
133
130
|
titles: {
|
|
134
131
|
type: _$vue.PropType<[string, string]>;
|
|
135
132
|
default: () => [string, string];
|
|
@@ -149,6 +146,9 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
149
146
|
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
150
147
|
default: () => never[];
|
|
151
148
|
};
|
|
149
|
+
renderContent: {
|
|
150
|
+
type: _$vue.PropType<_$element_plus0.renderContent>;
|
|
151
|
+
};
|
|
152
152
|
targetOrder: {
|
|
153
153
|
type: _$vue.PropType<"push" | "unshift" | "original">;
|
|
154
154
|
default: string;
|
|
@@ -178,10 +178,6 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
178
178
|
__isTeleport?: never;
|
|
179
179
|
__isSuspense?: never;
|
|
180
180
|
} & _$vue.ComponentOptionsBase<Readonly<_$vue.ExtractPropTypes<{
|
|
181
|
-
modelValue: {
|
|
182
|
-
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
183
|
-
default: () => never[];
|
|
184
|
-
};
|
|
185
181
|
props: {
|
|
186
182
|
type: _$vue.PropType<_$element_plus0.TransferPropsAlias>;
|
|
187
183
|
default: () => {
|
|
@@ -194,6 +190,10 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
194
190
|
type: _$vue.PropType<_$element_plus0.TransferDataItem[]>;
|
|
195
191
|
default: () => never[];
|
|
196
192
|
};
|
|
193
|
+
modelValue: {
|
|
194
|
+
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
195
|
+
default: () => never[];
|
|
196
|
+
};
|
|
197
197
|
filterable: {
|
|
198
198
|
type: _$vue.PropType<boolean>;
|
|
199
199
|
};
|
|
@@ -208,9 +208,6 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
208
208
|
type: _$vue.PropType<_$element_plus0.TransferFormat>;
|
|
209
209
|
default: () => {};
|
|
210
210
|
};
|
|
211
|
-
renderContent: {
|
|
212
|
-
type: _$vue.PropType<_$element_plus0.renderContent>;
|
|
213
|
-
};
|
|
214
211
|
titles: {
|
|
215
212
|
type: _$vue.PropType<[string, string]>;
|
|
216
213
|
default: () => [string, string];
|
|
@@ -230,6 +227,9 @@ declare const Transfer: _$element_plus_es_utils_index_mjs0.SFCWithInstall<{
|
|
|
230
227
|
type: _$vue.PropType<_$element_plus0.TransferKey[]>;
|
|
231
228
|
default: () => never[];
|
|
232
229
|
};
|
|
230
|
+
renderContent: {
|
|
231
|
+
type: _$vue.PropType<_$element_plus0.renderContent>;
|
|
232
|
+
};
|
|
233
233
|
targetOrder: {
|
|
234
234
|
type: _$vue.PropType<"push" | "unshift" | "original">;
|
|
235
235
|
default: string;
|
package/esm/tree/tree.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { addDisabledToNodes, flattenTree, getInputKeys, getOutputData } from "./
|
|
|
3
3
|
import { ElScrollbar, ElTree, vLoading } from "element-plus";
|
|
4
4
|
import { computed, createBlock, createSlots, defineComponent, guardReactiveProps, mergeProps, nextTick, normalizeProps, openBlock, ref, renderList, renderSlot, unref, useSlots, watch, withCtx, withDirectives } from "vue";
|
|
5
5
|
import { useField } from "@silver-formily/vue";
|
|
6
|
-
import { isFn } from "@formily/shared";
|
|
6
|
+
import { isFn } from "@silver-formily/shared";
|
|
7
7
|
//#region src/tree/tree.vue
|
|
8
8
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
9
9
|
name: "Tree",
|