niuma-ui 2.0.3 → 2.0.4
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/CHANGELOG.md +38 -0
- package/dist/components/_shared/src/reka.d.ts +1 -1
- package/dist/components/_shared/src/reka.js +2 -2
- package/dist/components/anchor/index.d.ts +1 -1
- package/dist/components/anchor/src/RsAnchor.css +63 -32
- package/dist/components/anchor/src/RsAnchor.d.ts +29 -2
- package/dist/components/anchor/src/RsAnchor.impl.js +199 -81
- package/dist/components/anchor/src/RsAnchor.js +1 -1
- package/dist/components/anchor/src/anchor-utils.d.ts +36 -4
- package/dist/components/anchor/src/anchor-utils.js +81 -19
- package/dist/components/auto-complete/index.d.ts +2 -0
- package/dist/components/auto-complete/src/RsAutoComplete.css +122 -0
- package/dist/components/auto-complete/src/RsAutoComplete.d.ts +47 -7
- package/dist/components/auto-complete/src/RsAutoComplete.impl.js +180 -72
- package/dist/components/auto-complete/src/RsAutoComplete.js +4 -1
- package/dist/components/auto-complete/src/auto-complete-utils.d.ts +7 -0
- package/dist/components/auto-complete/src/auto-complete-utils.js +17 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/avatar/src/RsAvatar.css +36 -19
- package/dist/components/avatar/src/RsAvatar.d.ts +9 -3
- package/dist/components/avatar/src/RsAvatar.impl.js +57 -33
- package/dist/components/avatar/src/RsAvatar.js +2 -1
- package/dist/components/avatar/src/avatar-utils.d.ts +16 -7
- package/dist/components/avatar/src/avatar-utils.js +41 -3
- package/dist/components/breadcrumb/index.d.ts +1 -1
- package/dist/components/breadcrumb/src/RsBreadcrumb.css +50 -17
- package/dist/components/breadcrumb/src/RsBreadcrumb.d.ts +45 -6
- package/dist/components/breadcrumb/src/RsBreadcrumb.impl.js +111 -12
- package/dist/components/breadcrumb/src/RsBreadcrumb.js +2 -1
- package/dist/components/breadcrumb/src/breadcrumb-utils.d.ts +37 -5
- package/dist/components/breadcrumb/src/breadcrumb-utils.js +70 -9
- package/dist/components/calendar-grid/index.d.ts +2 -0
- package/dist/components/calendar-grid/src/RsCalendarGrid.css +105 -45
- package/dist/components/calendar-grid/src/RsCalendarGrid.d.ts +62 -2
- package/dist/components/calendar-grid/src/RsCalendarGrid.impl.js +265 -94
- package/dist/components/calendar-grid/src/RsCalendarGrid.js +1 -1
- package/dist/components/calendar-grid/src/calendar-grid-utils.d.ts +72 -0
- package/dist/components/calendar-grid/src/calendar-grid-utils.js +122 -0
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/card/src/RsCard.css +108 -98
- package/dist/components/card/src/RsCard.d.ts +3 -12
- package/dist/components/card/src/RsCard.impl.js +29 -25
- package/dist/components/card/src/RsCard.js +2 -1
- package/dist/components/card/src/card-utils.d.ts +25 -0
- package/dist/components/card/src/card-utils.js +10 -0
- package/dist/components/cascader/index.d.ts +1 -0
- package/dist/components/cascader/src/RsCascader.css +175 -30
- package/dist/components/cascader/src/RsCascader.d.ts +15 -3
- package/dist/components/cascader/src/RsCascader.impl.js +277 -48
- package/dist/components/cascader/src/RsCascader.js +1 -1
- package/dist/components/cascader/src/cascader-utils.d.ts +2 -0
- package/dist/components/cascader/src/cascader-utils.js +8 -1
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/src/RsCheckbox.css +46 -23
- package/dist/components/checkbox/src/RsCheckbox.d.ts +11 -1
- package/dist/components/checkbox/src/RsCheckbox.impl.js +37 -9
- package/dist/components/checkbox/src/RsCheckbox.js +2 -1
- package/dist/components/checkbox/src/checkbox-utils.d.ts +4 -0
- package/dist/components/checkbox/src/checkbox-utils.js +12 -0
- package/dist/components/container/index.d.ts +1 -1
- package/dist/components/container/src/RsContainer.css +11 -11
- package/dist/components/container/src/RsContainer.d.ts +2 -12
- package/dist/components/container/src/RsContainer.impl.js +10 -57
- package/dist/components/container/src/RsContainer.js +1 -1
- package/dist/components/container/src/container-utils.d.ts +23 -0
- package/dist/components/container/src/container-utils.js +51 -0
- package/dist/components/date-picker/index.d.ts +4 -2
- package/dist/components/date-picker/src/RsDatePicker.css +42 -22
- package/dist/components/date-picker/src/RsDatePicker.d.ts +44 -20
- package/dist/components/date-picker/src/RsDatePicker.impl.js +484 -222
- package/dist/components/date-picker/src/RsDatePicker.js +1 -3
- package/dist/components/date-picker/src/RsDateTimePicker.d.ts +33 -6
- package/dist/components/date-picker/src/RsDateTimePicker.impl.js +47 -6
- package/dist/components/date-picker/src/date-picker-utils.d.ts +19 -0
- package/dist/components/date-picker/src/date-picker-utils.js +33 -10
- package/dist/components/dynamic-tags/index.d.ts +1 -1
- package/dist/components/dynamic-tags/src/RsDynamicTags.css +115 -38
- package/dist/components/dynamic-tags/src/RsDynamicTags.d.ts +58 -17
- package/dist/components/dynamic-tags/src/RsDynamicTags.impl.js +269 -106
- package/dist/components/dynamic-tags/src/RsDynamicTags.js +1 -1
- package/dist/components/dynamic-tags/src/dynamic-tags-utils.d.ts +19 -0
- package/dist/components/dynamic-tags/src/dynamic-tags-utils.js +60 -0
- package/dist/components/fieldset/src/RsFieldset.css +71 -41
- package/dist/components/fieldset/src/RsFieldset.d.ts +21 -2
- package/dist/components/fieldset/src/RsFieldset.impl.js +93 -26
- package/dist/components/fieldset/src/RsFieldset.js +1 -1
- package/dist/components/fieldset/src/fieldset-utils.d.ts +4 -0
- package/dist/components/fieldset/src/fieldset-utils.js +9 -1
- package/dist/components/form/index.d.ts +1 -0
- package/dist/components/form/src/RsForm.css +15 -12
- package/dist/components/form/src/RsForm.d.ts +20 -22
- package/dist/components/form/src/RsForm.impl.js +33 -20
- package/dist/components/form/src/RsForm.js +1 -1
- package/dist/components/form/src/form-utils.d.ts +7 -0
- package/dist/components/form/src/form-utils.js +28 -1
- package/dist/components/input/index.d.ts +1 -1
- package/dist/components/input/src/RsInput.css +78 -260
- package/dist/components/input/src/RsInput.d.ts +5 -3
- package/dist/components/input/src/RsInput.impl.js +8 -16
- package/dist/components/input/src/RsInput.js +1 -1
- package/dist/components/input/src/input-utils.d.ts +11 -0
- package/dist/components/input/src/input-utils.js +22 -0
- package/dist/components/input-number/index.d.ts +1 -0
- package/dist/components/input-number/src/RsInputNumber.css +31 -31
- package/dist/components/input-number/src/RsInputNumber.d.ts +15 -13
- package/dist/components/input-number/src/RsInputNumber.impl.js +17 -4
- package/dist/components/input-number/src/RsInputNumber.js +1 -1
- package/dist/components/label/src/RsLabel.css +30 -11
- package/dist/components/label/src/RsLabel.d.ts +18 -1
- package/dist/components/label/src/RsLabel.impl.js +63 -10
- package/dist/components/label/src/RsLabel.js +1 -1
- package/dist/components/label/src/label-utils.d.ts +6 -0
- package/dist/components/label/src/label-utils.js +16 -0
- package/dist/components/link/src/RsLink.d.ts +2 -2
- package/dist/components/loading/src/RsLoading.d.ts +1 -1
- package/dist/components/mentions/index.d.ts +2 -1
- package/dist/components/mentions/src/RsMentions.css +119 -3
- package/dist/components/mentions/src/RsMentions.d.ts +56 -4
- package/dist/components/mentions/src/RsMentions.impl.js +298 -79
- package/dist/components/mentions/src/RsMentions.js +1 -3
- package/dist/components/mentions/src/mentions-utils.d.ts +5 -1
- package/dist/components/mentions/src/mentions-utils.js +28 -9
- package/dist/components/popover/src/RsPopover.d.ts +1 -1
- package/dist/components/radio/index.d.ts +1 -1
- package/dist/components/radio/src/RsRadio.css +7 -6
- package/dist/components/radio/src/RsRadio.d.ts +8 -5
- package/dist/components/radio/src/RsRadio.impl.js +34 -24
- package/dist/components/radio/src/RsRadio.js +2 -1
- package/dist/components/radio/src/RsRadioItem.css +61 -44
- package/dist/components/radio/src/RsRadioItem.d.ts +2 -2
- package/dist/components/radio/src/RsRadioItem.impl.js +53 -20
- package/dist/components/radio/src/RsRadioItem.js +2 -1
- package/dist/components/radio/src/radio-utils.d.ts +12 -1
- package/dist/components/radio/src/radio-utils.js +15 -1
- package/dist/components/scrollbar/src/RsScrollbar.css +71 -24
- package/dist/components/scrollbar/src/RsScrollbar.d.ts +9 -5
- package/dist/components/scrollbar/src/RsScrollbar.impl.js +372 -47
- package/dist/components/scrollbar/src/RsScrollbar.js +2 -1
- package/dist/components/scrollbar/src/scrollbar-utils.d.ts +34 -2
- package/dist/components/scrollbar/src/scrollbar-utils.js +64 -1
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/src/RsSelect.css +54 -42
- package/dist/components/select/src/RsSelect.d.ts +19 -2
- package/dist/components/select/src/RsSelect.impl.js +727 -312
- package/dist/components/select/src/RsSelect.js +1 -1
- package/dist/components/select/src/select-utils.d.ts +4 -2
- package/dist/components/select/src/select-utils.js +8 -3
- package/dist/components/select/src/use-rs-select.d.ts +1 -0
- package/dist/components/select/src/use-rs-select.js +23 -17
- package/dist/components/switch/index.d.ts +2 -1
- package/dist/components/switch/src/RsSwitch.css +36 -18
- package/dist/components/switch/src/RsSwitch.d.ts +18 -5
- package/dist/components/switch/src/RsSwitch.impl.js +61 -29
- package/dist/components/switch/src/RsSwitch.js +2 -1
- package/dist/components/switch/src/switch-utils.d.ts +4 -0
- package/dist/components/switch/src/switch-utils.js +9 -0
- package/dist/components/textarea/src/RsTextarea.css +23 -23
- package/dist/components/textarea/src/RsTextarea.d.ts +6 -12
- package/dist/components/textarea/src/RsTextarea.impl.js +37 -46
- package/dist/components/textarea/src/RsTextarea.js +1 -1
- package/dist/components/textarea/src/textarea-utils.d.ts +27 -0
- package/dist/components/textarea/src/textarea-utils.js +61 -0
- package/dist/components/time-picker/index.d.ts +3 -2
- package/dist/components/time-picker/src/RsTimePicker.css +41 -24
- package/dist/components/time-picker/src/RsTimePicker.d.ts +52 -7
- package/dist/components/time-picker/src/RsTimePicker.impl.js +520 -156
- package/dist/components/time-picker/src/RsTimePicker.js +1 -3
- package/dist/components/time-picker/src/RsTimePickerColumns.css +26 -18
- package/dist/components/time-picker/src/RsTimePickerColumns.d.ts +3 -1
- package/dist/components/time-picker/src/RsTimePickerColumns.impl.js +62 -9
- package/dist/components/time-picker/src/RsTimePickerColumns.js +1 -1
- package/dist/components/time-picker/src/time-picker-utils.d.ts +38 -0
- package/dist/components/time-picker/src/time-picker-utils.js +97 -5
- package/dist/components/toaster/src/RsToaster.d.ts +1 -1
- package/dist/components/tooltip/src/RsTooltip.d.ts +1 -1
- package/dist/components/tree/src/RsTree.d.ts +3 -3
- package/dist/components/tree-select/index.d.ts +2 -0
- package/dist/components/tree-select/src/RsTreeSelect.css +100 -25
- package/dist/components/tree-select/src/RsTreeSelect.d.ts +91 -7
- package/dist/components/tree-select/src/RsTreeSelect.impl.js +464 -79
- package/dist/components/tree-select/src/RsTreeSelect.js +1 -1
- package/dist/components/tree-select/src/tree-select-utils.d.ts +20 -0
- package/dist/components/tree-select/src/tree-select-utils.js +60 -0
- package/dist/components/upload/index.d.ts +2 -1
- package/dist/components/upload/src/RsUpload.css +223 -75
- package/dist/components/upload/src/RsUpload.d.ts +77 -1
- package/dist/components/upload/src/RsUpload.impl.js +404 -90
- package/dist/components/upload/src/RsUpload.js +1 -1
- package/dist/components/upload/src/upload-utils.d.ts +21 -2
- package/dist/components/upload/src/upload-utils.js +139 -9
- package/dist/index.d.ts +21 -11
- package/dist/index.js +6 -0
- package/dist/locale/messages.js +46 -2
- package/dist/styles.css +518 -154
- package/dist/theme/brand.example.css +1 -1
- package/package.json +1 -1
- package/dist/components/breadcrumb/src/RsBreadcrumbItems.d.ts +0 -8
- package/dist/components/breadcrumb/src/RsBreadcrumbItems.impl.js +0 -40
- package/dist/components/breadcrumb/src/RsBreadcrumbItems.js +0 -5
- package/dist/components/date-picker/src/RsDatePicker-1.css +0 -157
- package/dist/components/mentions/src/RsMentions-1.css +0 -29
- package/dist/components/time-picker/src/RsTimePicker-1.css +0 -98
|
@@ -1,22 +1,59 @@
|
|
|
1
|
+
import { RS_COMPONENT_SIZE_ICON_PX } from "../../../theme/types.js";
|
|
1
2
|
import { useRsI18n } from "../../../composables/useRsI18n.js";
|
|
2
3
|
import RsIcon_default from "../../icon/src/RsIcon.js";
|
|
4
|
+
import { useRsFormContext } from "../../form/src/form-utils.js";
|
|
3
5
|
import { useResolvedRsComponentSize } from "../../_shared/src/resolve-size.js";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
+
import { rsRadiusCss, useResolvedRsRadius } from "../../_shared/src/resolve-radius.js";
|
|
7
|
+
import { placeAnchoredPopup } from "../../_shared/src/overlay-utils.js";
|
|
6
8
|
import RsTree_default from "../../tree/src/RsTree.js";
|
|
7
|
-
import {
|
|
9
|
+
import { buildTreeSelectIndex, emptyTreeSelectValue, formatTreeSelectDisplay, isTreeSelectMultiValue, normalizeTreeSelectKeys, packTreeSelectValue, resolveTreeSelectDisplayKeys, resolveTreeSelectLabels, resolveTreeSelectPortalTarget, treeSelectHasValue } from "./tree-select-utils.js";
|
|
10
|
+
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createVNode, defineComponent, guardReactiveProps, mergeModels, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef, watch, withCtx, withModifiers } from "vue";
|
|
8
11
|
//#region src/components/tree-select/src/RsTreeSelect.vue?vue&type=script&setup=true&lang.ts
|
|
9
|
-
var _hoisted_1 = ["
|
|
10
|
-
var _hoisted_2 =
|
|
12
|
+
var _hoisted_1 = ["name", "value"];
|
|
13
|
+
var _hoisted_2 = ["name", "value"];
|
|
14
|
+
var _hoisted_3 = [
|
|
15
|
+
"id",
|
|
16
|
+
"disabled",
|
|
17
|
+
"aria-label",
|
|
18
|
+
"aria-expanded",
|
|
19
|
+
"aria-controls"
|
|
20
|
+
];
|
|
21
|
+
var _hoisted_4 = {
|
|
11
22
|
key: 0,
|
|
12
|
-
class: "rs-tree-
|
|
23
|
+
class: "rs-tree-select__prefix"
|
|
13
24
|
};
|
|
14
|
-
var
|
|
25
|
+
var _hoisted_5 = {
|
|
15
26
|
key: 1,
|
|
27
|
+
class: "rs-tree-select__value"
|
|
28
|
+
};
|
|
29
|
+
var _hoisted_6 = {
|
|
30
|
+
key: 2,
|
|
16
31
|
class: "rs-tree-select__placeholder"
|
|
17
32
|
};
|
|
18
|
-
var
|
|
19
|
-
var
|
|
33
|
+
var _hoisted_7 = { class: "rs-tree-select__icon" };
|
|
34
|
+
var _hoisted_8 = ["aria-label"];
|
|
35
|
+
var _hoisted_9 = [
|
|
36
|
+
"id",
|
|
37
|
+
"data-placement",
|
|
38
|
+
"data-rs-theme"
|
|
39
|
+
];
|
|
40
|
+
var _hoisted_10 = {
|
|
41
|
+
key: 0,
|
|
42
|
+
class: "rs-tree-select__header"
|
|
43
|
+
};
|
|
44
|
+
var _hoisted_11 = {
|
|
45
|
+
key: 1,
|
|
46
|
+
class: "rs-tree-select__search-wrap"
|
|
47
|
+
};
|
|
48
|
+
var _hoisted_12 = [
|
|
49
|
+
"value",
|
|
50
|
+
"placeholder",
|
|
51
|
+
"aria-label"
|
|
52
|
+
];
|
|
53
|
+
var _hoisted_13 = {
|
|
54
|
+
key: 2,
|
|
55
|
+
class: "rs-tree-select__footer"
|
|
56
|
+
};
|
|
20
57
|
var RsTreeSelect_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
21
58
|
name: "RsTreeSelect",
|
|
22
59
|
__name: "RsTreeSelect",
|
|
@@ -44,7 +81,55 @@ var RsTreeSelect_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
44
81
|
type: Boolean,
|
|
45
82
|
default: false
|
|
46
83
|
},
|
|
47
|
-
size: {}
|
|
84
|
+
size: {},
|
|
85
|
+
radius: {},
|
|
86
|
+
checkStrictly: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false
|
|
89
|
+
},
|
|
90
|
+
onlyCheckLeaf: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: false
|
|
93
|
+
},
|
|
94
|
+
checkOnClickNode: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: true
|
|
97
|
+
},
|
|
98
|
+
defaultExpandAll: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: true
|
|
101
|
+
},
|
|
102
|
+
showLine: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
default: false
|
|
105
|
+
},
|
|
106
|
+
filterNode: {},
|
|
107
|
+
highlight: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
default: true
|
|
110
|
+
},
|
|
111
|
+
lazy: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: false
|
|
114
|
+
},
|
|
115
|
+
loadData: {},
|
|
116
|
+
virtual: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: false
|
|
119
|
+
},
|
|
120
|
+
virtualThreshold: { default: 100 },
|
|
121
|
+
listHeight: { default: 256 },
|
|
122
|
+
showCheckedStrategy: { default: "SHOW_ALL" },
|
|
123
|
+
maxTagCount: {},
|
|
124
|
+
getPopupContainer: {},
|
|
125
|
+
matchTriggerWidth: {
|
|
126
|
+
type: Boolean,
|
|
127
|
+
default: false
|
|
128
|
+
},
|
|
129
|
+
name: {},
|
|
130
|
+
id: {},
|
|
131
|
+
ariaLabel: {},
|
|
132
|
+
searchPlaceholder: {}
|
|
48
133
|
}, {
|
|
49
134
|
"modelValue": { default: "" },
|
|
50
135
|
"modelModifiers": {},
|
|
@@ -54,90 +139,390 @@ var RsTreeSelect_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
54
139
|
},
|
|
55
140
|
"openModifiers": {}
|
|
56
141
|
}),
|
|
57
|
-
emits: [
|
|
58
|
-
|
|
142
|
+
emits: /*@__PURE__*/ mergeModels([
|
|
143
|
+
"change",
|
|
144
|
+
"select",
|
|
145
|
+
"search",
|
|
146
|
+
"clear",
|
|
147
|
+
"dropdownVisibleChange",
|
|
148
|
+
"focus",
|
|
149
|
+
"blur"
|
|
150
|
+
], ["update:modelValue", "update:open"]),
|
|
151
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
59
152
|
const model = useModel(__props, "modelValue");
|
|
60
153
|
const open = useModel(__props, "open");
|
|
61
154
|
const props = __props;
|
|
155
|
+
const emit = __emit;
|
|
62
156
|
const { t } = useRsI18n();
|
|
157
|
+
const formContext = useRsFormContext();
|
|
63
158
|
const resolvedSize = useResolvedRsComponentSize(() => props.size);
|
|
159
|
+
const resolvedRadius = useResolvedRsRadius(() => props.radius, "sm");
|
|
160
|
+
const resolvedDisabled = computed(() => props.disabled || Boolean(formContext?.disabled.value));
|
|
161
|
+
const isMulti = computed(() => isTreeSelectMultiValue(props.multiple, props.checkable));
|
|
162
|
+
const panelId = useId();
|
|
163
|
+
const triggerId = computed(() => props.id || panelId);
|
|
164
|
+
const rootRef = useTemplateRef("rootRef");
|
|
165
|
+
const triggerRef = useTemplateRef("triggerRef");
|
|
166
|
+
const panelRef = useTemplateRef("panelRef");
|
|
167
|
+
const searchInputRef = useTemplateRef("searchInputRef");
|
|
64
168
|
const filter = ref("");
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const display = computed(() => {
|
|
72
|
-
return selectedKeys.value.map((key) => {
|
|
73
|
-
const entry = index.value.get(key);
|
|
74
|
-
return entry ? getTreeLabel(entry.node, names.value) : key;
|
|
75
|
-
}).join(", ");
|
|
169
|
+
const panelTheme = ref();
|
|
170
|
+
const popup = ref({
|
|
171
|
+
top: 0,
|
|
172
|
+
left: 0,
|
|
173
|
+
width: 0,
|
|
174
|
+
placement: "bottom"
|
|
76
175
|
});
|
|
176
|
+
const chevronSize = computed(() => RS_COMPONENT_SIZE_ICON_PX[resolvedSize.value]);
|
|
177
|
+
const clearIconSize = RS_COMPONENT_SIZE_ICON_PX.ssm;
|
|
178
|
+
const selectedKeys = computed(() => normalizeTreeSelectKeys(model.value));
|
|
179
|
+
const nodeIndex = computed(() => buildTreeSelectIndex(props.treeData, props.fieldNames, props.lazy));
|
|
180
|
+
const displayKeys = computed(() => resolveTreeSelectDisplayKeys(selectedKeys.value, nodeIndex.value, props.showCheckedStrategy, props.checkStrictly));
|
|
181
|
+
const displayLabels = computed(() => resolveTreeSelectLabels(displayKeys.value, nodeIndex.value, props.fieldNames));
|
|
182
|
+
const display = computed(() => formatTreeSelectDisplay(displayLabels.value, props.maxTagCount, props.maxTagCount != null && displayLabels.value.length > props.maxTagCount ? t("select.maxTagPlaceholder", { count: displayLabels.value.length - props.maxTagCount }) : void 0));
|
|
183
|
+
const hasValue = computed(() => treeSelectHasValue(selectedKeys.value));
|
|
184
|
+
const treeModel = computed(() => props.checkable ? "" : packTreeSelectValue(selectedKeys.value, props.multiple));
|
|
185
|
+
const portalTo = computed(() => resolveTreeSelectPortalTarget(props.getPopupContainer, triggerRef.value));
|
|
186
|
+
const resolvedPlaceholder = computed(() => props.placeholder ?? t("select.placeholder"));
|
|
187
|
+
const resolvedSearchPlaceholder = computed(() => props.searchPlaceholder ?? t("select.searchPlaceholder"));
|
|
188
|
+
const triggerClass = computed(() => [
|
|
189
|
+
"rs-tree-select",
|
|
190
|
+
`rs-tree-select--${resolvedSize.value}`,
|
|
191
|
+
{
|
|
192
|
+
"rs-tree-select--disabled": resolvedDisabled.value,
|
|
193
|
+
"rs-tree-select--open": open.value
|
|
194
|
+
}
|
|
195
|
+
]);
|
|
196
|
+
const rootStyle = computed(() => ({ "--rs-tree-select-radius": rsRadiusCss(resolvedRadius.value) }));
|
|
197
|
+
const panelStyle = computed(() => ({
|
|
198
|
+
position: "fixed",
|
|
199
|
+
top: `${popup.value.top}px`,
|
|
200
|
+
left: `${popup.value.left}px`,
|
|
201
|
+
"--rs-tree-select-radius": rsRadiusCss(resolvedRadius.value),
|
|
202
|
+
"--rs-tree-select-list-height": `${props.listHeight}px`,
|
|
203
|
+
"--rs-tree-select-trigger-width": `${popup.value.width}px`,
|
|
204
|
+
minWidth: `${popup.value.width}px`,
|
|
205
|
+
...props.matchTriggerWidth ? { width: `${popup.value.width}px` } : {}
|
|
206
|
+
}));
|
|
207
|
+
function commit(keys, closeSingle, selectedKey, node) {
|
|
208
|
+
if (resolvedDisabled.value) return;
|
|
209
|
+
const next = packTreeSelectValue(keys, isMulti.value);
|
|
210
|
+
model.value = next;
|
|
211
|
+
emit("change", next);
|
|
212
|
+
if (selectedKey) emit("select", selectedKey, node);
|
|
213
|
+
if (closeSingle && !isMulti.value) open.value = false;
|
|
214
|
+
}
|
|
77
215
|
function onTreeUpdate(value) {
|
|
78
|
-
|
|
79
|
-
|
|
216
|
+
if (props.checkable) return;
|
|
217
|
+
const keys = normalizeTreeSelectKeys(value);
|
|
218
|
+
const prev = new Set(selectedKeys.value);
|
|
219
|
+
const picked = keys.find((key) => !prev.has(key)) ?? keys[keys.length - 1];
|
|
220
|
+
commit(keys, true, picked, picked ? nodeIndex.value.get(picked)?.node : void 0);
|
|
221
|
+
}
|
|
222
|
+
function onCheck(keys, _half, node, key) {
|
|
223
|
+
commit(keys, false, key, node);
|
|
224
|
+
}
|
|
225
|
+
function onSearchInput(event) {
|
|
226
|
+
const value = event.target.value;
|
|
227
|
+
filter.value = value;
|
|
228
|
+
emit("search", value);
|
|
80
229
|
}
|
|
81
230
|
function onClear() {
|
|
82
|
-
|
|
231
|
+
if (resolvedDisabled.value) return;
|
|
232
|
+
model.value = emptyTreeSelectValue(isMulti.value);
|
|
233
|
+
emit("change", model.value);
|
|
234
|
+
emit("clear");
|
|
83
235
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
236
|
+
function focus() {
|
|
237
|
+
triggerRef.value?.focus();
|
|
238
|
+
}
|
|
239
|
+
function blur() {
|
|
240
|
+
triggerRef.value?.blur();
|
|
241
|
+
searchInputRef.value?.blur();
|
|
242
|
+
}
|
|
243
|
+
function toggleOpen() {
|
|
244
|
+
if (resolvedDisabled.value) return;
|
|
245
|
+
open.value = !open.value;
|
|
246
|
+
}
|
|
247
|
+
function syncPanelTheme() {
|
|
248
|
+
const el = triggerRef.value ?? rootRef.value;
|
|
249
|
+
if (!el) {
|
|
250
|
+
panelTheme.value = void 0;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const themed = el.closest("[data-rs-theme]");
|
|
254
|
+
panelTheme.value = themed instanceof HTMLElement ? themed.dataset.rsTheme : void 0;
|
|
255
|
+
}
|
|
256
|
+
function placePopup() {
|
|
257
|
+
const trigger = triggerRef.value;
|
|
258
|
+
const panel = panelRef.value;
|
|
259
|
+
if (!trigger || !open.value || typeof window === "undefined") return;
|
|
260
|
+
const anchor = trigger.getBoundingClientRect();
|
|
261
|
+
const measured = panel?.getBoundingClientRect();
|
|
262
|
+
const prefWidth = props.matchTriggerWidth ? anchor.width : Math.max(anchor.width, measured?.width || anchor.width);
|
|
263
|
+
popup.value = placeAnchoredPopup({
|
|
264
|
+
top: anchor.top,
|
|
265
|
+
left: anchor.left,
|
|
266
|
+
height: anchor.height,
|
|
267
|
+
width: anchor.width
|
|
91
268
|
}, {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
269
|
+
width: prefWidth,
|
|
270
|
+
height: measured?.height || props.listHeight
|
|
271
|
+
}, {
|
|
272
|
+
width: window.innerWidth,
|
|
273
|
+
height: window.innerHeight
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
let frame = 0;
|
|
277
|
+
function requestPlace() {
|
|
278
|
+
if (typeof window === "undefined") return;
|
|
279
|
+
if (frame) return;
|
|
280
|
+
frame = window.requestAnimationFrame(() => {
|
|
281
|
+
frame = 0;
|
|
282
|
+
placePopup();
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function onDocPointerDown(event) {
|
|
286
|
+
const target = event.target;
|
|
287
|
+
if (!target) return;
|
|
288
|
+
if (rootRef.value?.contains(target)) return;
|
|
289
|
+
if (panelRef.value?.contains(target)) return;
|
|
290
|
+
open.value = false;
|
|
291
|
+
}
|
|
292
|
+
function onWindowChange() {
|
|
293
|
+
if (open.value) requestPlace();
|
|
294
|
+
}
|
|
295
|
+
let panelResize;
|
|
296
|
+
function attachPanelObserver() {
|
|
297
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
298
|
+
panelResize?.disconnect();
|
|
299
|
+
if (!panelRef.value) return;
|
|
300
|
+
panelResize = new ResizeObserver(() => requestPlace());
|
|
301
|
+
panelResize.observe(panelRef.value);
|
|
302
|
+
}
|
|
303
|
+
function focusTree() {
|
|
304
|
+
panelRef.value?.querySelector(".rs-tree")?.focus();
|
|
305
|
+
}
|
|
306
|
+
function detachOverlay() {
|
|
307
|
+
panelResize?.disconnect();
|
|
308
|
+
panelResize = void 0;
|
|
309
|
+
if (frame && typeof window !== "undefined") {
|
|
310
|
+
window.cancelAnimationFrame(frame);
|
|
311
|
+
frame = 0;
|
|
312
|
+
}
|
|
313
|
+
if (typeof document !== "undefined") document.removeEventListener("pointerdown", onDocPointerDown);
|
|
314
|
+
if (typeof window !== "undefined") {
|
|
315
|
+
window.removeEventListener("resize", onWindowChange);
|
|
316
|
+
window.removeEventListener("scroll", onWindowChange, true);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function onTriggerKeydown(event) {
|
|
320
|
+
if (resolvedDisabled.value || event.isComposing) return;
|
|
321
|
+
if (event.key === "Escape") {
|
|
322
|
+
if (!open.value) return;
|
|
323
|
+
event.preventDefault();
|
|
324
|
+
open.value = false;
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (!open.value) {
|
|
328
|
+
if (event.key === "ArrowDown" || event.key === "Enter" || event.key === " ") {
|
|
329
|
+
event.preventDefault();
|
|
330
|
+
open.value = true;
|
|
331
|
+
}
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (event.key === "ArrowDown") {
|
|
335
|
+
event.preventDefault();
|
|
336
|
+
if (props.searchable) searchInputRef.value?.focus();
|
|
337
|
+
else focusTree();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function onSearchKeydown(event) {
|
|
341
|
+
if (event.isComposing) return;
|
|
342
|
+
if (event.key === "Escape") {
|
|
343
|
+
event.preventDefault();
|
|
344
|
+
open.value = false;
|
|
345
|
+
triggerRef.value?.focus();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (event.key === "ArrowDown") {
|
|
349
|
+
event.preventDefault();
|
|
350
|
+
focusTree();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
watch(open, (isOpen, wasOpen) => {
|
|
354
|
+
if (wasOpen !== void 0) emit("dropdownVisibleChange", isOpen);
|
|
355
|
+
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
356
|
+
if (isOpen) {
|
|
357
|
+
if (resolvedDisabled.value) {
|
|
358
|
+
open.value = false;
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
syncPanelTheme();
|
|
362
|
+
document.addEventListener("pointerdown", onDocPointerDown);
|
|
363
|
+
window.addEventListener("resize", onWindowChange);
|
|
364
|
+
window.addEventListener("scroll", onWindowChange, true);
|
|
365
|
+
nextTick(() => {
|
|
366
|
+
requestPlace();
|
|
367
|
+
attachPanelObserver();
|
|
368
|
+
if (props.searchable) searchInputRef.value?.focus();
|
|
369
|
+
else focusTree();
|
|
370
|
+
});
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
detachOverlay();
|
|
374
|
+
filter.value = "";
|
|
375
|
+
}, { immediate: true });
|
|
376
|
+
watch(resolvedDisabled, (disabled) => {
|
|
377
|
+
if (disabled && open.value) open.value = false;
|
|
378
|
+
});
|
|
379
|
+
onBeforeUnmount(detachOverlay);
|
|
380
|
+
__expose({
|
|
381
|
+
focus,
|
|
382
|
+
blur
|
|
383
|
+
});
|
|
384
|
+
return (_ctx, _cache) => {
|
|
385
|
+
return openBlock(), createElementBlock("div", {
|
|
386
|
+
ref_key: "rootRef",
|
|
387
|
+
ref: rootRef,
|
|
388
|
+
class: normalizeClass(["rs-tree-select-wrap", { "rs-tree-select-wrap--clearable": __props.allowClear && hasValue.value && !resolvedDisabled.value }]),
|
|
389
|
+
style: normalizeStyle(rootStyle.value)
|
|
390
|
+
}, [
|
|
391
|
+
__props.name ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [isMulti.value ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(selectedKeys.value, (key) => {
|
|
392
|
+
return openBlock(), createElementBlock("input", {
|
|
393
|
+
key,
|
|
394
|
+
type: "hidden",
|
|
395
|
+
name: __props.name,
|
|
396
|
+
value: key
|
|
397
|
+
}, null, 8, _hoisted_1);
|
|
398
|
+
}), 128)) : (openBlock(), createElementBlock("input", {
|
|
399
|
+
key: 1,
|
|
400
|
+
type: "hidden",
|
|
401
|
+
name: __props.name,
|
|
402
|
+
value: selectedKeys.value[0] ?? ""
|
|
403
|
+
}, null, 8, _hoisted_2))], 64)) : createCommentVNode("", true),
|
|
404
|
+
createElementVNode("button", {
|
|
405
|
+
id: triggerId.value,
|
|
406
|
+
ref_key: "triggerRef",
|
|
407
|
+
ref: triggerRef,
|
|
119
408
|
type: "button",
|
|
120
|
-
class: normalizeClass(
|
|
121
|
-
disabled:
|
|
409
|
+
class: normalizeClass(triggerClass.value),
|
|
410
|
+
disabled: resolvedDisabled.value,
|
|
411
|
+
"aria-label": __props.ariaLabel,
|
|
412
|
+
"aria-haspopup": "tree",
|
|
413
|
+
"aria-expanded": open.value ? "true" : "false",
|
|
414
|
+
"aria-controls": open.value ? unref(panelId) : void 0,
|
|
415
|
+
onClick: toggleOpen,
|
|
416
|
+
onKeydown: onTriggerKeydown,
|
|
417
|
+
onFocus: _cache[0] || (_cache[0] = ($event) => emit("focus", $event)),
|
|
418
|
+
onBlur: _cache[1] || (_cache[1] = ($event) => emit("blur", $event))
|
|
122
419
|
}, [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
type: "button",
|
|
127
|
-
class: "rs-tree-select__clear",
|
|
128
|
-
"aria-label": unref(t)("select.clear"),
|
|
129
|
-
onClick: withModifiers(onClear, ["stop"])
|
|
130
|
-
}, [createVNode(RsIcon_default, {
|
|
131
|
-
name: "x",
|
|
132
|
-
size: 12
|
|
133
|
-
})], 8, _hoisted_4)) : createCommentVNode("", true),
|
|
134
|
-
createVNode(RsIcon_default, {
|
|
420
|
+
_ctx.$slots.prefix ? (openBlock(), createElementBlock("span", _hoisted_4, [renderSlot(_ctx.$slots, "prefix", {}, void 0, true)])) : createCommentVNode("", true),
|
|
421
|
+
display.value ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(display.value), 1)) : (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(resolvedPlaceholder.value), 1)),
|
|
422
|
+
createElementVNode("span", _hoisted_7, [renderSlot(_ctx.$slots, "suffixIcon", {}, () => [createVNode(RsIcon_default, {
|
|
135
423
|
name: "chevron-down",
|
|
136
|
-
size:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
424
|
+
size: chevronSize.value,
|
|
425
|
+
"aria-hidden": "true"
|
|
426
|
+
}, null, 8, ["size"])], true)])
|
|
427
|
+
], 42, _hoisted_3),
|
|
428
|
+
__props.allowClear && hasValue.value && !resolvedDisabled.value ? (openBlock(), createElementBlock("button", {
|
|
429
|
+
key: 1,
|
|
430
|
+
type: "button",
|
|
431
|
+
class: "rs-tree-select__clear",
|
|
432
|
+
"aria-label": unref(t)("select.clear"),
|
|
433
|
+
onPointerdown: _cache[2] || (_cache[2] = withModifiers(() => {}, ["stop"])),
|
|
434
|
+
onClick: withModifiers(onClear, ["stop"])
|
|
435
|
+
}, [renderSlot(_ctx.$slots, "clearIcon", {}, () => [createVNode(RsIcon_default, {
|
|
436
|
+
name: "x",
|
|
437
|
+
size: unref(clearIconSize),
|
|
438
|
+
"aria-hidden": "true"
|
|
439
|
+
}, null, 8, ["size"])], true)], 40, _hoisted_8)) : createCommentVNode("", true),
|
|
440
|
+
(openBlock(), createBlock(Teleport, { to: portalTo.value }, [open.value && !resolvedDisabled.value ? (openBlock(), createElementBlock("div", {
|
|
441
|
+
key: 0,
|
|
442
|
+
id: unref(panelId),
|
|
443
|
+
ref_key: "panelRef",
|
|
444
|
+
ref: panelRef,
|
|
445
|
+
class: normalizeClass(["rs-tree-select__panel", {
|
|
446
|
+
"rs-tree-select__panel--virtual": __props.virtual,
|
|
447
|
+
"rs-tree-select__panel--match-trigger": __props.matchTriggerWidth
|
|
448
|
+
}]),
|
|
449
|
+
"data-placement": popup.value.placement,
|
|
450
|
+
"data-rs-theme": panelTheme.value,
|
|
451
|
+
style: normalizeStyle(panelStyle.value)
|
|
452
|
+
}, [
|
|
453
|
+
_ctx.$slots.header ? (openBlock(), createElementBlock("div", _hoisted_10, [renderSlot(_ctx.$slots, "header", {}, void 0, true)])) : createCommentVNode("", true),
|
|
454
|
+
__props.searchable ? (openBlock(), createElementBlock("div", _hoisted_11, [createVNode(RsIcon_default, {
|
|
455
|
+
name: "search",
|
|
456
|
+
size: 14,
|
|
457
|
+
class: "rs-tree-select__search-icon",
|
|
458
|
+
"aria-hidden": "true"
|
|
459
|
+
}), createElementVNode("input", {
|
|
460
|
+
ref_key: "searchInputRef",
|
|
461
|
+
ref: searchInputRef,
|
|
462
|
+
value: filter.value,
|
|
463
|
+
type: "text",
|
|
464
|
+
class: "rs-tree-select__search",
|
|
465
|
+
placeholder: resolvedSearchPlaceholder.value,
|
|
466
|
+
"aria-label": resolvedSearchPlaceholder.value,
|
|
467
|
+
autocomplete: "off",
|
|
468
|
+
onInput: onSearchInput,
|
|
469
|
+
onKeydown: onSearchKeydown
|
|
470
|
+
}, null, 40, _hoisted_12)])) : createCommentVNode("", true),
|
|
471
|
+
createElementVNode("div", { class: normalizeClass(["rs-tree-select__tree", { "rs-tree-select__tree--virtual": __props.virtual }]) }, [createVNode(RsTree_default, {
|
|
472
|
+
"model-value": treeModel.value,
|
|
473
|
+
"checked-keys": __props.checkable ? selectedKeys.value : void 0,
|
|
474
|
+
nodes: __props.treeData,
|
|
475
|
+
"field-names": __props.fieldNames,
|
|
476
|
+
size: unref(resolvedSize),
|
|
477
|
+
multiple: __props.multiple,
|
|
478
|
+
selectable: !__props.checkable,
|
|
479
|
+
checkable: __props.checkable,
|
|
480
|
+
"check-strictly": __props.checkStrictly,
|
|
481
|
+
"only-check-leaf": __props.onlyCheckLeaf,
|
|
482
|
+
"check-on-click-node": __props.checkable && __props.checkOnClickNode,
|
|
483
|
+
"default-expand-all": __props.defaultExpandAll,
|
|
484
|
+
"show-line": __props.showLine,
|
|
485
|
+
filter: filter.value,
|
|
486
|
+
"filter-node": __props.filterNode,
|
|
487
|
+
highlight: __props.highlight,
|
|
488
|
+
lazy: __props.lazy,
|
|
489
|
+
"load-data": __props.loadData,
|
|
490
|
+
virtual: __props.virtual,
|
|
491
|
+
"virtual-threshold": __props.virtualThreshold,
|
|
492
|
+
height: __props.virtual ? __props.listHeight : void 0,
|
|
493
|
+
"block-node": "",
|
|
494
|
+
"onUpdate:modelValue": onTreeUpdate,
|
|
495
|
+
onCheck
|
|
496
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.title ? {
|
|
497
|
+
name: "title",
|
|
498
|
+
fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "title", normalizeProps(guardReactiveProps(slotProps)), void 0, true)]),
|
|
499
|
+
key: "0"
|
|
500
|
+
} : void 0]), 1032, [
|
|
501
|
+
"model-value",
|
|
502
|
+
"checked-keys",
|
|
503
|
+
"nodes",
|
|
504
|
+
"field-names",
|
|
505
|
+
"size",
|
|
506
|
+
"multiple",
|
|
507
|
+
"selectable",
|
|
508
|
+
"checkable",
|
|
509
|
+
"check-strictly",
|
|
510
|
+
"only-check-leaf",
|
|
511
|
+
"check-on-click-node",
|
|
512
|
+
"default-expand-all",
|
|
513
|
+
"show-line",
|
|
514
|
+
"filter",
|
|
515
|
+
"filter-node",
|
|
516
|
+
"highlight",
|
|
517
|
+
"lazy",
|
|
518
|
+
"load-data",
|
|
519
|
+
"virtual",
|
|
520
|
+
"virtual-threshold",
|
|
521
|
+
"height"
|
|
522
|
+
])], 2),
|
|
523
|
+
_ctx.$slots.footer ? (openBlock(), createElementBlock("div", _hoisted_13, [renderSlot(_ctx.$slots, "footer", {}, void 0, true)])) : createCommentVNode("", true)
|
|
524
|
+
], 14, _hoisted_9)) : createCommentVNode("", true)], 8, ["to"]))
|
|
525
|
+
], 6);
|
|
141
526
|
};
|
|
142
527
|
}
|
|
143
528
|
});
|
|
@@ -3,6 +3,6 @@ import _plugin_vue_export_helper_default from "../../../_virtual/_plugin-vue_exp
|
|
|
3
3
|
import RsTreeSelect_vue_vue_type_script_setup_true_lang_default from "./RsTreeSelect.impl.js";
|
|
4
4
|
|
|
5
5
|
//#region src/components/tree-select/src/RsTreeSelect.vue
|
|
6
|
-
var RsTreeSelect_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsTreeSelect_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
6
|
+
var RsTreeSelect_default = /*#__PURE__*/ _plugin_vue_export_helper_default(RsTreeSelect_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-d5518d1b"]]);
|
|
7
7
|
//#endregion
|
|
8
8
|
export { RsTreeSelect_default as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RsTreeFieldNames, type RsTreeNode, type RsTreeNodeIndex } from '../../tree/src/tree-utils';
|
|
2
|
+
export type RsTreeSelectModelValue = string | string[];
|
|
3
|
+
/** 勾选回显策略。只改触发器文案,不改 v-model。 */
|
|
4
|
+
export type RsTreeSelectShowCheckedStrategy = 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD';
|
|
5
|
+
export type RsTreeSelectGetPopupContainer = (trigger?: HTMLElement) => string | HTMLElement | undefined | null;
|
|
6
|
+
export declare function isTreeSelectMultiValue(multiple: boolean, checkable: boolean): boolean;
|
|
7
|
+
export declare function normalizeTreeSelectKeys(value: RsTreeSelectModelValue | null | undefined): string[];
|
|
8
|
+
export declare function packTreeSelectValue(keys: string[], multi: boolean): RsTreeSelectModelValue;
|
|
9
|
+
export declare function emptyTreeSelectValue(multi: boolean): RsTreeSelectModelValue;
|
|
10
|
+
export declare function treeSelectHasValue(keys: readonly string[]): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 触发器要展示的 key。
|
|
13
|
+
* SHOW_PARENT:父节点已在集合里则藏子节点。
|
|
14
|
+
* SHOW_CHILD:子节点已全部在集合里则藏父节点。
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveTreeSelectDisplayKeys(keys: readonly string[], index: ReadonlyMap<string, RsTreeNodeIndex>, strategy: RsTreeSelectShowCheckedStrategy, checkStrictly: boolean): string[];
|
|
17
|
+
export declare function resolveTreeSelectLabels(keys: readonly string[], index: ReadonlyMap<string, RsTreeNodeIndex>, fieldNames?: RsTreeFieldNames): string[];
|
|
18
|
+
export declare function formatTreeSelectDisplay(labels: readonly string[], maxTagCount?: number, moreText?: string): string;
|
|
19
|
+
export declare function buildTreeSelectIndex(nodes: readonly RsTreeNode[], fieldNames?: RsTreeFieldNames, lazy?: boolean): Map<string, RsTreeNodeIndex>;
|
|
20
|
+
export declare function resolveTreeSelectPortalTarget(getPopupContainer: RsTreeSelectGetPopupContainer | undefined, trigger?: HTMLElement | null): string | HTMLElement;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { buildTreeNodeIndex, getTreeLabel, resolveTreeFieldNames } from "../../tree/src/tree-utils.js";
|
|
2
|
+
//#region src/components/tree-select/src/tree-select-utils.ts
|
|
3
|
+
function isTreeSelectMultiValue(multiple, checkable) {
|
|
4
|
+
return multiple || checkable;
|
|
5
|
+
}
|
|
6
|
+
function normalizeTreeSelectKeys(value) {
|
|
7
|
+
if (Array.isArray(value)) return value.map(String).filter((key) => key !== "");
|
|
8
|
+
if (value === "" || value == null) return [];
|
|
9
|
+
return [String(value)];
|
|
10
|
+
}
|
|
11
|
+
function packTreeSelectValue(keys, multi) {
|
|
12
|
+
return multi ? [...keys] : keys[0] ?? "";
|
|
13
|
+
}
|
|
14
|
+
function emptyTreeSelectValue(multi) {
|
|
15
|
+
return multi ? [] : "";
|
|
16
|
+
}
|
|
17
|
+
function treeSelectHasValue(keys) {
|
|
18
|
+
return keys.length > 0;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 触发器要展示的 key。
|
|
22
|
+
* SHOW_PARENT:父节点已在集合里则藏子节点。
|
|
23
|
+
* SHOW_CHILD:子节点已全部在集合里则藏父节点。
|
|
24
|
+
*/
|
|
25
|
+
function resolveTreeSelectDisplayKeys(keys, index, strategy, checkStrictly) {
|
|
26
|
+
if (checkStrictly || strategy === "SHOW_ALL" || keys.length === 0) return [...keys];
|
|
27
|
+
const set = new Set(keys);
|
|
28
|
+
if (strategy === "SHOW_PARENT") return keys.filter((key) => {
|
|
29
|
+
const parentKey = index.get(key)?.parentKey;
|
|
30
|
+
return !parentKey || !set.has(parentKey);
|
|
31
|
+
});
|
|
32
|
+
return keys.filter((key) => {
|
|
33
|
+
const children = index.get(key)?.childrenKeys ?? [];
|
|
34
|
+
if (children.length === 0) return true;
|
|
35
|
+
return !children.every((child) => set.has(child));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function resolveTreeSelectLabels(keys, index, fieldNames) {
|
|
39
|
+
const names = resolveTreeFieldNames(fieldNames);
|
|
40
|
+
return keys.map((key) => {
|
|
41
|
+
const entry = index.get(key);
|
|
42
|
+
return entry ? getTreeLabel(entry.node, names) : key;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function formatTreeSelectDisplay(labels, maxTagCount, moreText) {
|
|
46
|
+
if (maxTagCount == null || maxTagCount < 0 || labels.length <= maxTagCount) return labels.join(", ");
|
|
47
|
+
const shown = labels.slice(0, maxTagCount);
|
|
48
|
+
const omitted = labels.length - maxTagCount;
|
|
49
|
+
const more = moreText ?? `+${omitted}`;
|
|
50
|
+
return [...shown, more].join(", ");
|
|
51
|
+
}
|
|
52
|
+
function buildTreeSelectIndex(nodes, fieldNames, lazy = false) {
|
|
53
|
+
return buildTreeNodeIndex(nodes, resolveTreeFieldNames(fieldNames), lazy);
|
|
54
|
+
}
|
|
55
|
+
function resolveTreeSelectPortalTarget(getPopupContainer, trigger) {
|
|
56
|
+
if (!getPopupContainer) return "body";
|
|
57
|
+
return getPopupContainer(trigger ?? void 0) ?? "body";
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { buildTreeSelectIndex, emptyTreeSelectValue, formatTreeSelectDisplay, isTreeSelectMultiValue, normalizeTreeSelectKeys, packTreeSelectValue, resolveTreeSelectDisplayKeys, resolveTreeSelectLabels, resolveTreeSelectPortalTarget, treeSelectHasValue };
|