@kine-design/core 0.0.1-beta.1
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/dist/components/base/affix/api.d.ts +3 -0
- package/dist/components/base/affix/index.d.ts +5 -0
- package/dist/components/base/affix/useAffix.d.ts +7 -0
- package/dist/components/base/alert/api.d.ts +3 -0
- package/dist/components/base/alert/index.d.ts +4 -0
- package/dist/components/base/anchor/api.d.ts +4 -0
- package/dist/components/base/anchor/index.d.ts +6 -0
- package/dist/components/base/anchor/useAnchor.d.ts +7 -0
- package/dist/components/base/autoComplete/api.d.ts +3 -0
- package/dist/components/base/autoComplete/index.d.ts +6 -0
- package/dist/components/base/autoComplete/useAutoComplete.d.ts +13 -0
- package/dist/components/base/avatar/api.d.ts +3 -0
- package/dist/components/base/avatar/index.d.ts +3 -0
- package/dist/components/base/backTop/api.d.ts +3 -0
- package/dist/components/base/backTop/index.d.ts +5 -0
- package/dist/components/base/backTop/useBackTop.d.ts +5 -0
- package/dist/components/base/badge/api.d.ts +3 -0
- package/dist/components/base/badge/index.d.ts +4 -0
- package/dist/components/base/button/api.d.ts +3 -0
- package/dist/components/base/button/index.d.ts +24 -0
- package/dist/components/base/button/useButton.d.ts +22 -0
- package/dist/components/base/card/api.d.ts +3 -0
- package/dist/components/base/card/index.d.ts +4 -0
- package/dist/components/base/carousel/api.d.ts +3 -0
- package/dist/components/base/carousel/index.d.ts +6 -0
- package/dist/components/base/carousel/useCarousel.d.ts +10 -0
- package/dist/components/base/cascader/api.d.ts +3 -0
- package/dist/components/base/cascader/index.d.ts +7 -0
- package/dist/components/base/cascader/useCascader.d.ts +31 -0
- package/dist/components/base/checkbox/api.d.ts +4 -0
- package/dist/components/base/checkbox/index.d.ts +5 -0
- package/dist/components/base/checkbox/useCheckbox.d.ts +9 -0
- package/dist/components/base/collapse/api.d.ts +4 -0
- package/dist/components/base/collapse/index.d.ts +6 -0
- package/dist/components/base/collapse/useCollapse.d.ts +16 -0
- package/dist/components/base/datePicker/api.d.ts +3 -0
- package/dist/components/base/datePicker/index.d.ts +8 -0
- package/dist/components/base/datePicker/useDatePicker.d.ts +52 -0
- package/dist/components/base/divider/api.d.ts +3 -0
- package/dist/components/base/divider/index.d.ts +4 -0
- package/dist/components/base/dropdown/api.d.ts +4 -0
- package/dist/components/base/dropdown/index.d.ts +6 -0
- package/dist/components/base/dropdown/useDropdown.d.ts +22 -0
- package/dist/components/base/empty/api.d.ts +3 -0
- package/dist/components/base/empty/index.d.ts +4 -0
- package/dist/components/base/image/api.d.ts +3 -0
- package/dist/components/base/image/index.d.ts +7 -0
- package/dist/components/base/image/useImage.d.ts +19 -0
- package/dist/components/base/input/api.d.ts +3 -0
- package/dist/components/base/input/index.d.ts +5 -0
- package/dist/components/base/input/useInput.d.ts +22 -0
- package/dist/components/base/inputNumber/api.d.ts +3 -0
- package/dist/components/base/inputNumber/index.d.ts +5 -0
- package/dist/components/base/inputNumber/useInputNumber.d.ts +12 -0
- package/dist/components/base/li/api.d.ts +3 -0
- package/dist/components/base/li/index.d.ts +3 -0
- package/dist/components/base/list/api.d.ts +3 -0
- package/dist/components/base/list/index.d.ts +5 -0
- package/dist/components/base/list/useList.d.ts +12 -0
- package/dist/components/base/loading/api.d.ts +3 -0
- package/dist/components/base/loading/index.d.ts +4 -0
- package/dist/components/base/popover/api.d.ts +3 -0
- package/dist/components/base/popover/index.d.ts +5 -0
- package/dist/components/base/popover/usePopover.d.ts +45 -0
- package/dist/components/base/progress/api.d.ts +3 -0
- package/dist/components/base/progress/index.d.ts +5 -0
- package/dist/components/base/progress/useProgress.d.ts +4 -0
- package/dist/components/base/radio/api.d.ts +3 -0
- package/dist/components/base/radio/index.d.ts +14 -0
- package/dist/components/base/radio/useRadio.d.ts +10 -0
- package/dist/components/base/rate/api.d.ts +3 -0
- package/dist/components/base/rate/index.d.ts +5 -0
- package/dist/components/base/rate/useRate.d.ts +9 -0
- package/dist/components/base/result/api.d.ts +3 -0
- package/dist/components/base/result/index.d.ts +4 -0
- package/dist/components/base/select/api.d.ts +3 -0
- package/dist/components/base/select/index.d.ts +7 -0
- package/dist/components/base/select/useSelect.d.ts +31 -0
- package/dist/components/base/select/useSelectTools.d.ts +8 -0
- package/dist/components/base/skeleton/api.d.ts +3 -0
- package/dist/components/base/skeleton/index.d.ts +4 -0
- package/dist/components/base/slider/api.d.ts +3 -0
- package/dist/components/base/slider/index.d.ts +5 -0
- package/dist/components/base/slider/useSlider.d.ts +6 -0
- package/dist/components/base/space/api.d.ts +3 -0
- package/dist/components/base/space/index.d.ts +4 -0
- package/dist/components/base/steps/api.d.ts +10 -0
- package/dist/components/base/steps/index.d.ts +11 -0
- package/dist/components/base/steps/useSteps.d.ts +44 -0
- package/dist/components/base/switch/api.d.ts +3 -0
- package/dist/components/base/switch/index.d.ts +7 -0
- package/dist/components/base/switch/useSwitch.d.ts +9 -0
- package/dist/components/base/tabs/api.d.ts +4 -0
- package/dist/components/base/tabs/index.d.ts +7 -0
- package/dist/components/base/tabs/useTabs.d.ts +9 -0
- package/dist/components/base/tag/api.d.ts +3 -0
- package/dist/components/base/tag/index.d.ts +3 -0
- package/dist/components/base/timePicker/api.d.ts +3 -0
- package/dist/components/base/timePicker/index.d.ts +7 -0
- package/dist/components/base/timePicker/useTimePicker.d.ts +21 -0
- package/dist/components/base/timeline/api.d.ts +4 -0
- package/dist/components/base/timeline/index.d.ts +5 -0
- package/dist/components/base/tooltip/api.d.ts +3 -0
- package/dist/components/base/tooltip/index.d.ts +6 -0
- package/dist/components/base/tooltip/useTooltip.d.ts +15 -0
- package/dist/components/base/transfer/api.d.ts +3 -0
- package/dist/components/base/transfer/index.d.ts +6 -0
- package/dist/components/base/transfer/useTransfer.d.ts +23 -0
- package/dist/components/base/tree/api.d.ts +8 -0
- package/dist/components/base/tree/index.d.ts +15 -0
- package/dist/components/base/tree/tree.d.ts +46 -0
- package/dist/components/base/tree/useTree.d.ts +32 -0
- package/dist/components/message/confirm/api.d.ts +3 -0
- package/dist/components/message/confirm/index.d.ts +4 -0
- package/dist/components/message/dialog/api.d.ts +3 -0
- package/dist/components/message/dialog/index.d.ts +4 -0
- package/dist/components/message/drawer/api.d.ts +3 -0
- package/dist/components/message/drawer/index.d.ts +4 -0
- package/dist/components/message/message/api.d.ts +10 -0
- package/dist/components/message/message/index.d.ts +9 -0
- package/dist/components/message/message/useMessage.d.ts +23 -0
- package/dist/components/message/notification/api.d.ts +6 -0
- package/dist/components/message/notification/index.d.ts +8 -0
- package/dist/components/message/notification/useNotification.d.ts +33 -0
- package/dist/components/message/popover/MPopover.d.ts +2 -0
- package/dist/components/message/popover/api.d.ts +3 -0
- package/dist/components/message/popover/index.d.ts +6 -0
- package/dist/components/message/popover/usePopover.d.ts +56 -0
- package/dist/components/other/darkMode/api.d.ts +3 -0
- package/dist/components/other/darkMode/index.d.ts +6 -0
- package/dist/components/other/darkMode/useDarkMode.d.ts +11 -0
- package/dist/components/template/border/api.d.ts +3 -0
- package/dist/components/template/border/index.d.ts +4 -0
- package/dist/components/template/breadcrumb/api.d.ts +3 -0
- package/dist/components/template/breadcrumb/index.d.ts +4 -0
- package/dist/components/template/descriptions/api.d.ts +4 -0
- package/dist/components/template/descriptions/index.d.ts +5 -0
- package/dist/components/template/form/api.d.ts +4 -0
- package/dist/components/template/form/index.d.ts +9 -0
- package/dist/components/template/grid/api.d.ts +3 -0
- package/dist/components/template/grid/index.d.ts +4 -0
- package/dist/components/template/menu/api.d.ts +8 -0
- package/dist/components/template/menu/index.d.ts +9 -0
- package/dist/components/template/menu/useMenu.d.ts +12 -0
- package/dist/components/template/pagination/api.d.ts +3 -0
- package/dist/components/template/pagination/index.d.ts +7 -0
- package/dist/components/template/pagination/usePagination.d.ts +27 -0
- package/dist/components/template/table/api.d.ts +3 -0
- package/dist/components/template/table/index.d.ts +7 -0
- package/dist/components/template/table/useTable.d.ts +51 -0
- package/dist/components/template/tableColumn/api.d.ts +3 -0
- package/dist/components/template/tableColumn/index.d.ts +4 -0
- package/dist/components/template/virtualList/api.d.ts +3 -0
- package/dist/components/template/virtualList/index.d.ts +7 -0
- package/dist/components/template/virtualList/useVirtualList.d.ts +15 -0
- package/dist/compositions/common/defineCore.d.ts +25 -0
- package/dist/compositions/common/useDebounceFn.d.ts +12 -0
- package/dist/compositions/common/useDrag.d.ts +28 -0
- package/dist/compositions/common/useElementSize.d.ts +5 -0
- package/dist/compositions/common/useEventListener.d.ts +19 -0
- package/dist/compositions/common/usePopover.d.ts +9 -0
- package/dist/compositions/common/useResizeObserver.d.ts +4 -0
- package/dist/compositions/common/useTeleport.d.ts +7 -0
- package/dist/compositions/input/useBooleanInput.d.ts +9 -0
- package/dist/compositions/modal/useModal.d.ts +14 -0
- package/dist/compositions/popper/useClickAway.d.ts +9 -0
- package/dist/compositions/popper/usePopper.d.ts +19 -0
- package/dist/compositions/utils/filters.d.ts +41 -0
- package/dist/compositions/virtualList/enums.d.ts +49 -0
- package/dist/compositions/virtualList/useContainerObserver.d.ts +9 -0
- package/dist/compositions/virtualList/useEntries.d.ts +29 -0
- package/dist/compositions/virtualList/useHeightCache.d.ts +26 -0
- package/dist/compositions/virtualList/useSentinelObserver.d.ts +14 -0
- package/dist/core.js +4270 -0
- package/dist/index.d.ts +65 -0
- package/dist/runtime/defineHook.d.ts +3 -0
- package/dist/tools/empty.d.ts +18 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/types.d.ts +9 -0
- package/dist/vite.config.build.d.ts +2 -0
- package/package.json +32 -0
package/dist/core.js
ADDED
|
@@ -0,0 +1,4270 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
+
var _source, _cacheMap, _config, _initialConfig, _Tree_instances, genTreeNodeData_fn, clearCache_fn, init_fn, genCacheMap_fn, getCacheList_fn, setParentChecked_fn, setChildrenStatus_fn;
|
|
13
|
+
import { toRef, ref, computed, watch, onBeforeUnmount, onMounted, shallowRef, onBeforeMount, nextTick, onUnmounted, triggerRef, inject, provide } from "vue";
|
|
14
|
+
import * as _interactjsModule from "interactjs";
|
|
15
|
+
import { autoUpdate, arrow, computePosition } from "@floating-ui/dom";
|
|
16
|
+
import dayjs from "dayjs";
|
|
17
|
+
const props$O = {
|
|
18
|
+
shape: { type: String, default: "circle" },
|
|
19
|
+
size: { type: String, default: "medium" },
|
|
20
|
+
src: { type: String, default: "" },
|
|
21
|
+
alt: { type: String, default: "" }
|
|
22
|
+
};
|
|
23
|
+
const AvatarCore = {
|
|
24
|
+
props: props$O
|
|
25
|
+
};
|
|
26
|
+
const props$N = {
|
|
27
|
+
type: { type: String, default: "text" },
|
|
28
|
+
placeholder: { type: String, default: "" },
|
|
29
|
+
modelValue: { type: [String, Number], default: "" },
|
|
30
|
+
readonly: { type: Boolean, default: false },
|
|
31
|
+
disabled: { type: Boolean, default: false },
|
|
32
|
+
autofocus: { type: Boolean, default: false }
|
|
33
|
+
};
|
|
34
|
+
function useInput(props2, ctx) {
|
|
35
|
+
const isInput = props2.type !== "textarea";
|
|
36
|
+
const inputType = isInput ? "input" : "textarea";
|
|
37
|
+
const inputClass = isInput ? "m-input-inner" : "m-textarea-inner";
|
|
38
|
+
const rowInfo = isInput ? {} : { rows: 10 };
|
|
39
|
+
const baseProps = {
|
|
40
|
+
autofocus: props2.autofocus,
|
|
41
|
+
value: props2.modelValue,
|
|
42
|
+
placeholder: props2.placeholder,
|
|
43
|
+
disabled: props2.disabled,
|
|
44
|
+
type: props2.type,
|
|
45
|
+
readOnly: props2.readonly
|
|
46
|
+
};
|
|
47
|
+
const onInput = (e) => {
|
|
48
|
+
ctx.emit("update:modelValue", e.target.value);
|
|
49
|
+
ctx.emit("input", e.target.value);
|
|
50
|
+
};
|
|
51
|
+
const onFocus = (e) => {
|
|
52
|
+
ctx.emit("focus", e);
|
|
53
|
+
};
|
|
54
|
+
const onBlur = (e) => {
|
|
55
|
+
ctx.emit("blur", e);
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
baseProps,
|
|
59
|
+
inputType,
|
|
60
|
+
inputClass,
|
|
61
|
+
rowInfo,
|
|
62
|
+
onInput,
|
|
63
|
+
onFocus,
|
|
64
|
+
onBlur
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const InputCore = {
|
|
68
|
+
props: props$N,
|
|
69
|
+
useInput
|
|
70
|
+
};
|
|
71
|
+
const props$M = {
|
|
72
|
+
text: { type: String, default: "" },
|
|
73
|
+
link: { type: Boolean, default: false },
|
|
74
|
+
disabled: { type: Boolean, default: false },
|
|
75
|
+
loading: { type: Boolean, default: false },
|
|
76
|
+
plain: { type: Boolean, default: false },
|
|
77
|
+
type: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: "default",
|
|
80
|
+
enum: ["default", "primary", "success", "warning", "danger", "info"]
|
|
81
|
+
},
|
|
82
|
+
size: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: "medium",
|
|
85
|
+
enum: ["large", "medium", "small"]
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const defineHook = (hook) => {
|
|
89
|
+
return hook;
|
|
90
|
+
};
|
|
91
|
+
const useButton = defineHook((props2, { slots }) => {
|
|
92
|
+
var _a;
|
|
93
|
+
const domType = props2.link ? "a" : "button";
|
|
94
|
+
const slot = ((_a = slots.default) == null ? void 0 : _a.call(slots)) ?? props2.text;
|
|
95
|
+
const isDisabled = props2.disabled || props2.loading;
|
|
96
|
+
const domProps = {
|
|
97
|
+
class: [
|
|
98
|
+
"m-button",
|
|
99
|
+
{ "m-button-disabled": isDisabled },
|
|
100
|
+
{ "m-button-loading": props2.loading },
|
|
101
|
+
{ "m-button-plain": props2.plain },
|
|
102
|
+
`m-button-${props2.type ?? "default"}`,
|
|
103
|
+
`m-button-${props2.size ?? "medium"}`
|
|
104
|
+
],
|
|
105
|
+
disabled: isDisabled
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
domType,
|
|
109
|
+
slot,
|
|
110
|
+
domProps,
|
|
111
|
+
isDisabled
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
const ButtonCore = {
|
|
115
|
+
props: props$M,
|
|
116
|
+
useButton
|
|
117
|
+
};
|
|
118
|
+
const props$L = {
|
|
119
|
+
modelValue: { type: void 0, default: "" },
|
|
120
|
+
options: { type: Array, default: () => [] },
|
|
121
|
+
inputParam: { type: String, default: void 0 },
|
|
122
|
+
optionParam: { type: String, default: void 0 },
|
|
123
|
+
valueParam: { type: String, default: void 0 },
|
|
124
|
+
readonly: { type: Boolean, default: true },
|
|
125
|
+
disabled: { type: Boolean, default: false },
|
|
126
|
+
placeholder: { type: String, default: "请选择..." },
|
|
127
|
+
toMatch: { type: Function, default: void 0 },
|
|
128
|
+
multiple: { type: Boolean, default: false },
|
|
129
|
+
checkbox: { type: Boolean, default: true },
|
|
130
|
+
filterable: { type: Boolean, default: false },
|
|
131
|
+
filter: { type: Function, default: void 0 },
|
|
132
|
+
optionsH: { type: [Number, String], default: void 0 },
|
|
133
|
+
needFetch: { type: Boolean, default: false },
|
|
134
|
+
fetch: { type: Function, default: void 0 }
|
|
135
|
+
};
|
|
136
|
+
function useSelectTools(props2) {
|
|
137
|
+
const getInfoWithKey = (option, key) => {
|
|
138
|
+
const paramKey = props2[key];
|
|
139
|
+
if (!paramKey) {
|
|
140
|
+
if (option && typeof option === "object") {
|
|
141
|
+
if ("label" in option) return option.label;
|
|
142
|
+
if ("name" in option) return option.name;
|
|
143
|
+
if ("text" in option) return option.text;
|
|
144
|
+
}
|
|
145
|
+
return option;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
return option[paramKey];
|
|
149
|
+
} catch {
|
|
150
|
+
return option;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const getInputValue = (option) => {
|
|
154
|
+
return String(getInfoWithKey(option, "inputParam") ?? "");
|
|
155
|
+
};
|
|
156
|
+
const getOptionValue = (option) => {
|
|
157
|
+
return String(getInfoWithKey(option, "optionParam") ?? "");
|
|
158
|
+
};
|
|
159
|
+
const getModelValue = (option) => {
|
|
160
|
+
if (props2.valueParam) {
|
|
161
|
+
return getInfoWithKey(option, "valueParam");
|
|
162
|
+
}
|
|
163
|
+
return option;
|
|
164
|
+
};
|
|
165
|
+
return { getInfoWithKey, getInputValue, getOptionValue, getModelValue };
|
|
166
|
+
}
|
|
167
|
+
function useSelect(props2, ctx) {
|
|
168
|
+
const tools = useSelectTools(props2);
|
|
169
|
+
const optionsRef = toRef(() => props2.options ?? []);
|
|
170
|
+
const modelValueRef = toRef(() => props2.modelValue);
|
|
171
|
+
const multipleRef = toRef(() => props2.multiple ?? false);
|
|
172
|
+
const inputReadonly = toRef(() => props2.filterable ? false : props2.readonly ?? true);
|
|
173
|
+
const inputValue = ref("");
|
|
174
|
+
const isOpen = ref(false);
|
|
175
|
+
const fetchLoading = ref(false);
|
|
176
|
+
const selectedIndices = ref(/* @__PURE__ */ new Set());
|
|
177
|
+
const isSelected = (option, index) => {
|
|
178
|
+
if (multipleRef.value) {
|
|
179
|
+
return selectedIndices.value.has(index);
|
|
180
|
+
}
|
|
181
|
+
if (props2.toMatch) {
|
|
182
|
+
return props2.toMatch(option, modelValueRef.value);
|
|
183
|
+
}
|
|
184
|
+
return modelValueRef.value === tools.getModelValue(option);
|
|
185
|
+
};
|
|
186
|
+
const allOptions = computed(() => {
|
|
187
|
+
return optionsRef.value.map((o, i) => ({
|
|
188
|
+
value: o,
|
|
189
|
+
index: i,
|
|
190
|
+
isSelected: isSelected(o, i)
|
|
191
|
+
}));
|
|
192
|
+
});
|
|
193
|
+
const displayOptions = computed(() => {
|
|
194
|
+
return allOptions.value.filter((o) => {
|
|
195
|
+
if (inputReadonly.value) return true;
|
|
196
|
+
if (!inputValue.value) return true;
|
|
197
|
+
if (props2.filter) {
|
|
198
|
+
return props2.filter(o.value, inputValue.value);
|
|
199
|
+
}
|
|
200
|
+
return tools.getOptionValue(o.value).toLowerCase().includes(inputValue.value.toLowerCase());
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
const selectedTags = computed(() => {
|
|
204
|
+
if (!multipleRef.value) return [];
|
|
205
|
+
return allOptions.value.filter((o) => o.isSelected);
|
|
206
|
+
});
|
|
207
|
+
const syncInputFromModelValue = () => {
|
|
208
|
+
if (multipleRef.value) {
|
|
209
|
+
inputValue.value = "";
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const mv = modelValueRef.value;
|
|
213
|
+
if (mv == null || mv === "") {
|
|
214
|
+
inputValue.value = "";
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const found = optionsRef.value.find((o) => {
|
|
218
|
+
if (props2.toMatch) return props2.toMatch(o, mv);
|
|
219
|
+
return tools.getModelValue(o) === mv;
|
|
220
|
+
});
|
|
221
|
+
inputValue.value = found ? tools.getInputValue(found) : "";
|
|
222
|
+
};
|
|
223
|
+
const syncSelectedFromModelValue = () => {
|
|
224
|
+
if (!multipleRef.value) return;
|
|
225
|
+
const mv = modelValueRef.value;
|
|
226
|
+
const newSet = /* @__PURE__ */ new Set();
|
|
227
|
+
if (Array.isArray(mv)) {
|
|
228
|
+
optionsRef.value.forEach((o, i) => {
|
|
229
|
+
const val = tools.getModelValue(o);
|
|
230
|
+
if (mv.includes(val)) {
|
|
231
|
+
newSet.add(i);
|
|
232
|
+
}
|
|
233
|
+
if (props2.toMatch && mv.some((v) => props2.toMatch(o, v))) {
|
|
234
|
+
newSet.add(i);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
selectedIndices.value = newSet;
|
|
239
|
+
};
|
|
240
|
+
syncSelectedFromModelValue();
|
|
241
|
+
syncInputFromModelValue();
|
|
242
|
+
const onSelect = (index) => {
|
|
243
|
+
const option = optionsRef.value[index];
|
|
244
|
+
if (!option) return;
|
|
245
|
+
if (multipleRef.value) {
|
|
246
|
+
const newSet = new Set(selectedIndices.value);
|
|
247
|
+
if (newSet.has(index)) {
|
|
248
|
+
newSet.delete(index);
|
|
249
|
+
} else {
|
|
250
|
+
newSet.add(index);
|
|
251
|
+
}
|
|
252
|
+
selectedIndices.value = newSet;
|
|
253
|
+
inputValue.value = "";
|
|
254
|
+
const newModelValue = optionsRef.value.filter((_, i) => newSet.has(i)).map((o) => tools.getModelValue(o));
|
|
255
|
+
ctx.emit("update:modelValue", newModelValue);
|
|
256
|
+
ctx.emit("select", option);
|
|
257
|
+
} else {
|
|
258
|
+
inputValue.value = tools.getInputValue(option);
|
|
259
|
+
ctx.emit("update:modelValue", tools.getModelValue(option));
|
|
260
|
+
ctx.emit("select", option);
|
|
261
|
+
isOpen.value = false;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const onDeleteTag = (index) => {
|
|
265
|
+
const newSet = new Set(selectedIndices.value);
|
|
266
|
+
newSet.delete(index);
|
|
267
|
+
selectedIndices.value = newSet;
|
|
268
|
+
const newModelValue = optionsRef.value.filter((_, i) => newSet.has(i)).map((o) => tools.getModelValue(o));
|
|
269
|
+
ctx.emit("update:modelValue", newModelValue);
|
|
270
|
+
};
|
|
271
|
+
const onInput = () => {
|
|
272
|
+
ctx.emit("input", inputValue.value);
|
|
273
|
+
};
|
|
274
|
+
const onFocus = (e) => {
|
|
275
|
+
if (inputReadonly.value) return;
|
|
276
|
+
ctx.emit("focus", e, inputValue.value);
|
|
277
|
+
};
|
|
278
|
+
const onBlur = (e) => {
|
|
279
|
+
if (inputReadonly.value) return;
|
|
280
|
+
ctx.emit("blur", e, inputValue.value);
|
|
281
|
+
if (!multipleRef.value) {
|
|
282
|
+
const matched = displayOptions.value.find((o) => o.isSelected);
|
|
283
|
+
if (matched && inputValue.value === tools.getInputValue(matched.value)) return;
|
|
284
|
+
if (!inputValue.value) {
|
|
285
|
+
ctx.emit("update:modelValue", void 0);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
const lastOptionRef = ref(null);
|
|
290
|
+
const optionsContainerRef = ref(null);
|
|
291
|
+
let fetchObserver;
|
|
292
|
+
const cleanupFetchObserver = () => {
|
|
293
|
+
if (fetchObserver) {
|
|
294
|
+
fetchObserver.disconnect();
|
|
295
|
+
fetchObserver = void 0;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const updateFetchObserver = () => {
|
|
299
|
+
cleanupFetchObserver();
|
|
300
|
+
if (!props2.needFetch || !lastOptionRef.value || !optionsContainerRef.value) return;
|
|
301
|
+
fetchObserver = new IntersectionObserver(
|
|
302
|
+
async (entries) => {
|
|
303
|
+
var _a;
|
|
304
|
+
const entry = entries[0];
|
|
305
|
+
if ((entry == null ? void 0 : entry.isIntersecting) && props2.needFetch) {
|
|
306
|
+
fetchLoading.value = true;
|
|
307
|
+
await ((_a = props2.fetch) == null ? void 0 : _a.call(props2));
|
|
308
|
+
fetchLoading.value = false;
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{ root: optionsContainerRef.value, threshold: 1 }
|
|
312
|
+
);
|
|
313
|
+
fetchObserver.observe(lastOptionRef.value);
|
|
314
|
+
};
|
|
315
|
+
watch(modelValueRef, () => {
|
|
316
|
+
syncSelectedFromModelValue();
|
|
317
|
+
syncInputFromModelValue();
|
|
318
|
+
});
|
|
319
|
+
watch(optionsRef, () => {
|
|
320
|
+
syncSelectedFromModelValue();
|
|
321
|
+
syncInputFromModelValue();
|
|
322
|
+
}, { deep: true });
|
|
323
|
+
watch(lastOptionRef, () => {
|
|
324
|
+
updateFetchObserver();
|
|
325
|
+
});
|
|
326
|
+
onBeforeUnmount(cleanupFetchObserver);
|
|
327
|
+
return {
|
|
328
|
+
// 状态
|
|
329
|
+
inputValue,
|
|
330
|
+
isOpen,
|
|
331
|
+
fetchLoading,
|
|
332
|
+
// 输入框是否只读(filterable=true 时为 false)
|
|
333
|
+
inputReadonly,
|
|
334
|
+
// 列表
|
|
335
|
+
displayOptions,
|
|
336
|
+
selectedTags,
|
|
337
|
+
// DOM refs(fetch 用)
|
|
338
|
+
lastOptionRef,
|
|
339
|
+
optionsContainerRef,
|
|
340
|
+
// 事件
|
|
341
|
+
onSelect,
|
|
342
|
+
onDeleteTag,
|
|
343
|
+
onInput,
|
|
344
|
+
onFocus,
|
|
345
|
+
onBlur,
|
|
346
|
+
// 工具
|
|
347
|
+
tools,
|
|
348
|
+
// fetch
|
|
349
|
+
updateFetchObserver
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
const SelectCore = {
|
|
353
|
+
props: props$L,
|
|
354
|
+
useSelect
|
|
355
|
+
};
|
|
356
|
+
const props$K = {
|
|
357
|
+
label: { type: String, default: "" },
|
|
358
|
+
checked: { type: Boolean, default: void 0 },
|
|
359
|
+
value: { type: null, default: void 0 },
|
|
360
|
+
modelValue: { type: null, default: void 0 },
|
|
361
|
+
indeterminate: { type: Boolean, default: false },
|
|
362
|
+
disabled: { type: Boolean, default: false }
|
|
363
|
+
};
|
|
364
|
+
const notEmpty = (value) => {
|
|
365
|
+
if (value === void 0 || value === null) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
const valueType = typeof value;
|
|
369
|
+
if (valueType === "string") {
|
|
370
|
+
return value !== "";
|
|
371
|
+
}
|
|
372
|
+
if (valueType === "number" || valueType === "bigint" || valueType === "boolean" || valueType === "function") {
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
if (valueType === "symbol") {
|
|
376
|
+
return value.toString() !== "Symbol()";
|
|
377
|
+
}
|
|
378
|
+
if (valueType === "object") {
|
|
379
|
+
if (value instanceof String || value instanceof Array) {
|
|
380
|
+
return value.length !== 0;
|
|
381
|
+
}
|
|
382
|
+
if (value instanceof Number || value instanceof Boolean) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
if (value instanceof Map || value instanceof Set) {
|
|
386
|
+
return value.size > 0;
|
|
387
|
+
}
|
|
388
|
+
if (value instanceof WeakMap || value instanceof WeakSet) {
|
|
389
|
+
console.error("WeakMap和WeakSet无法以通用的方式判断是否为空。");
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
if (value instanceof RegExp) {
|
|
393
|
+
return value.toString() !== "/(?:)/";
|
|
394
|
+
}
|
|
395
|
+
if (value instanceof Date) {
|
|
396
|
+
return value.toString() !== "Invalid Date";
|
|
397
|
+
}
|
|
398
|
+
const typedArrayTypes = [
|
|
399
|
+
Int8Array,
|
|
400
|
+
Uint8Array,
|
|
401
|
+
Uint8ClampedArray,
|
|
402
|
+
Int16Array,
|
|
403
|
+
Uint16Array,
|
|
404
|
+
Int32Array,
|
|
405
|
+
Uint32Array,
|
|
406
|
+
Float32Array,
|
|
407
|
+
Float64Array
|
|
408
|
+
];
|
|
409
|
+
for (const arrayType of typedArrayTypes) {
|
|
410
|
+
if (value instanceof arrayType) {
|
|
411
|
+
return value.length;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return Object.keys(value).length > 0;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const isEmpty$1 = (value) => !notEmpty(value);
|
|
418
|
+
const isBoolean = (val) => typeof val === "boolean";
|
|
419
|
+
const initChecked = (props2) => {
|
|
420
|
+
if (props2.checked) {
|
|
421
|
+
return props2.checked;
|
|
422
|
+
}
|
|
423
|
+
if (notEmpty(props2.modelValue)) {
|
|
424
|
+
if (notEmpty(props2.value)) {
|
|
425
|
+
if (Array.isArray(props2.modelValue)) {
|
|
426
|
+
return props2.modelValue.includes(props2.value);
|
|
427
|
+
}
|
|
428
|
+
return props2.value === props2.modelValue;
|
|
429
|
+
}
|
|
430
|
+
if (isBoolean(props2.modelValue)) {
|
|
431
|
+
return props2.modelValue;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return false;
|
|
435
|
+
};
|
|
436
|
+
const getNewModelValue = (props2, checked) => {
|
|
437
|
+
if (props2.value) {
|
|
438
|
+
if (Array.isArray(props2.modelValue)) {
|
|
439
|
+
const arr = [...props2.modelValue];
|
|
440
|
+
if (checked) {
|
|
441
|
+
if (!arr.includes(props2.value)) arr.push(props2.value);
|
|
442
|
+
} else {
|
|
443
|
+
const idx = arr.indexOf(props2.value);
|
|
444
|
+
if (idx !== -1) arr.splice(idx, 1);
|
|
445
|
+
}
|
|
446
|
+
return arr;
|
|
447
|
+
}
|
|
448
|
+
return checked ? props2.value : void 0;
|
|
449
|
+
}
|
|
450
|
+
return checked;
|
|
451
|
+
};
|
|
452
|
+
function useCheckbox(props2, ctx) {
|
|
453
|
+
const checkboxClass = ["m-checkbox", { "m-disabled": props2.disabled }];
|
|
454
|
+
const checked = ref(initChecked(props2));
|
|
455
|
+
watch(() => props2.modelValue, () => {
|
|
456
|
+
checked.value = initChecked(props2);
|
|
457
|
+
});
|
|
458
|
+
const onClick = (e) => {
|
|
459
|
+
e.stopPropagation();
|
|
460
|
+
if (props2.disabled) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
checked.value = !checked.value;
|
|
464
|
+
const newVal = getNewModelValue(props2, checked.value);
|
|
465
|
+
ctx.emit("change", newVal);
|
|
466
|
+
ctx.emit("update:modelValue", newVal);
|
|
467
|
+
};
|
|
468
|
+
return {
|
|
469
|
+
checkboxClass,
|
|
470
|
+
checked,
|
|
471
|
+
onClick
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const CheckboxCore = {
|
|
475
|
+
props: props$K,
|
|
476
|
+
useCheckbox
|
|
477
|
+
};
|
|
478
|
+
const props$J = {
|
|
479
|
+
modelValue: { type: void 0, required: true },
|
|
480
|
+
disabled: { type: Boolean, default: false },
|
|
481
|
+
loading: { type: Boolean, default: false },
|
|
482
|
+
activeInfo: { type: String, default: "" },
|
|
483
|
+
inactiveInfo: { type: String, default: "" },
|
|
484
|
+
activeValue: { type: void 0, default: void 0 },
|
|
485
|
+
inactiveValue: { type: void 0, default: void 0 },
|
|
486
|
+
onControl: { type: Boolean, default: false }
|
|
487
|
+
};
|
|
488
|
+
const switchIsBoolean = (value) => {
|
|
489
|
+
return typeof value === "boolean";
|
|
490
|
+
};
|
|
491
|
+
const getIsActive = (value, activeValue) => {
|
|
492
|
+
return value === activeValue;
|
|
493
|
+
};
|
|
494
|
+
function useSwitch(props2, ctx) {
|
|
495
|
+
const activeValue = ref(props2.activeValue);
|
|
496
|
+
const inactiveValue = ref(props2.inactiveValue);
|
|
497
|
+
const { slots, emit } = ctx;
|
|
498
|
+
const isBoolean2 = computed(() => switchIsBoolean(props2.modelValue));
|
|
499
|
+
if (isBoolean2.value) {
|
|
500
|
+
if (isEmpty$1(props2.activeValue) && isEmpty$1(props2.inactiveValue)) {
|
|
501
|
+
activeValue.value = true;
|
|
502
|
+
inactiveValue.value = false;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
const isActive = computed(() => getIsActive(props2.modelValue, activeValue.value));
|
|
506
|
+
const changeSwitch = () => {
|
|
507
|
+
if (props2.disabled || props2.loading) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
if (!props2.onControl) {
|
|
511
|
+
if (isBoolean2.value) {
|
|
512
|
+
emit("update:modelValue", !props2.modelValue);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
emit("change", !isActive.value ? props2.activeValue ?? true : inactiveValue ?? false);
|
|
516
|
+
};
|
|
517
|
+
const getInfo = (key) => {
|
|
518
|
+
if (slots[key]) {
|
|
519
|
+
return slots[key]();
|
|
520
|
+
}
|
|
521
|
+
const info = props2[key];
|
|
522
|
+
if (!info) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
return /* @__PURE__ */ React.createElement("span", { class: "m-switch-span" }, info);
|
|
526
|
+
};
|
|
527
|
+
const switchClass = computed(() => [
|
|
528
|
+
"m-switch",
|
|
529
|
+
isActive.value ? "m-switch-active" : "m-switch-inactive",
|
|
530
|
+
{ "m-switch-loading": props2.loading },
|
|
531
|
+
{ "m-switch-disabled": props2.disabled }
|
|
532
|
+
]);
|
|
533
|
+
return {
|
|
534
|
+
getInfo,
|
|
535
|
+
changeSwitch,
|
|
536
|
+
switchClass
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
const SwitchCore = {
|
|
540
|
+
props: props$J,
|
|
541
|
+
switchIsBoolean,
|
|
542
|
+
getIsActive,
|
|
543
|
+
useSwitch
|
|
544
|
+
};
|
|
545
|
+
const props$I = {
|
|
546
|
+
type: { type: String, default: "default" },
|
|
547
|
+
size: { type: String, default: "medium" },
|
|
548
|
+
closable: { type: Boolean, default: false },
|
|
549
|
+
disabled: { type: Boolean, default: false }
|
|
550
|
+
};
|
|
551
|
+
const TagCore = {
|
|
552
|
+
props: props$I
|
|
553
|
+
};
|
|
554
|
+
const props$H = {
|
|
555
|
+
value: { type: Number, default: 0 },
|
|
556
|
+
max: { type: Number, default: 100 },
|
|
557
|
+
showInfo: { type: Boolean, default: true },
|
|
558
|
+
status: { type: String, default: "default" },
|
|
559
|
+
strokeWidth: { type: Number, default: 4 }
|
|
560
|
+
};
|
|
561
|
+
const clearZero = (num) => {
|
|
562
|
+
const str = num.toString();
|
|
563
|
+
const index = str.indexOf(".");
|
|
564
|
+
if (index === -1) {
|
|
565
|
+
return num;
|
|
566
|
+
}
|
|
567
|
+
return str.slice(0, index + 3);
|
|
568
|
+
};
|
|
569
|
+
function useProgress(props2) {
|
|
570
|
+
const percentage = computed(() => clearZero(props2.value * 100 / props2.max));
|
|
571
|
+
return {
|
|
572
|
+
percentage
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
const ProgressCore = {
|
|
576
|
+
props: props$H,
|
|
577
|
+
useProgress
|
|
578
|
+
};
|
|
579
|
+
const props$G = {
|
|
580
|
+
data: { type: Array, default: () => [] },
|
|
581
|
+
autoActive: { type: Boolean, default: false },
|
|
582
|
+
loading: { type: Boolean, default: false }
|
|
583
|
+
};
|
|
584
|
+
const baseRender = (item) => {
|
|
585
|
+
if (["string", "number"].includes(typeof item)) {
|
|
586
|
+
return String(item);
|
|
587
|
+
}
|
|
588
|
+
if (typeof item === "object") {
|
|
589
|
+
return JSON.stringify(item);
|
|
590
|
+
}
|
|
591
|
+
return "";
|
|
592
|
+
};
|
|
593
|
+
function useList() {
|
|
594
|
+
const dataValidate = (data) => {
|
|
595
|
+
if (!Array.isArray(data)) {
|
|
596
|
+
console.warn("[shuimo-list] data必须是数组");
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
return true;
|
|
600
|
+
};
|
|
601
|
+
return {
|
|
602
|
+
baseRender,
|
|
603
|
+
dataValidate
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
const ListCore = {
|
|
607
|
+
props: props$G,
|
|
608
|
+
useList
|
|
609
|
+
};
|
|
610
|
+
const props$F = {
|
|
611
|
+
label: { type: [String, Number], default: "" },
|
|
612
|
+
name: { type: String, default: void 0 },
|
|
613
|
+
checked: { type: Boolean, default: void 0 },
|
|
614
|
+
value: { type: [String, Number], default: "" },
|
|
615
|
+
modelValue: { type: null, default: "" }
|
|
616
|
+
};
|
|
617
|
+
const createRadioId = () => `m-radio-${Math.random().toString(36).substring(2)}`;
|
|
618
|
+
const RadioCore = {
|
|
619
|
+
props: props$F,
|
|
620
|
+
initChecked,
|
|
621
|
+
getNewModelValue,
|
|
622
|
+
createRadioId
|
|
623
|
+
};
|
|
624
|
+
const props$E = {
|
|
625
|
+
active: { type: Boolean, default: false },
|
|
626
|
+
marker: { type: Boolean, default: true }
|
|
627
|
+
};
|
|
628
|
+
const LiCore = {
|
|
629
|
+
props: props$E
|
|
630
|
+
};
|
|
631
|
+
const props$D = {
|
|
632
|
+
modelValue: { type: [Number, String], default: "", required: true },
|
|
633
|
+
placeholder: { type: String, default: "" },
|
|
634
|
+
max: { type: Number, default: Infinity },
|
|
635
|
+
min: { type: Number, default: -Infinity },
|
|
636
|
+
disabled: { type: Boolean, default: false },
|
|
637
|
+
readonly: { type: Boolean, default: false },
|
|
638
|
+
step: { type: Number, default: 1 },
|
|
639
|
+
precision: { type: Number, default: 0 }
|
|
640
|
+
};
|
|
641
|
+
function useInputNumber(props2, ctx) {
|
|
642
|
+
const currentValue = ref(props2.modelValue);
|
|
643
|
+
const updateInput = (oldVal) => {
|
|
644
|
+
ctx.emit("update:modelValue", currentValue.value);
|
|
645
|
+
ctx.emit("change", currentValue.value, oldVal);
|
|
646
|
+
};
|
|
647
|
+
const setCurrentValue = (newVal, e) => {
|
|
648
|
+
const oldVal = currentValue.value;
|
|
649
|
+
const { min, max, precision } = props2;
|
|
650
|
+
if (oldVal === newVal) {
|
|
651
|
+
return;
|
|
652
|
+
} else if (+newVal >= +max) {
|
|
653
|
+
newVal = max;
|
|
654
|
+
} else if (+newVal <= +min) {
|
|
655
|
+
newVal = min;
|
|
656
|
+
} else if (precision !== 0 && String(newVal).includes(".") && `${newVal}`.length - (`${newVal}`.indexOf(".") + 1) >= precision) {
|
|
657
|
+
newVal = Number(`${newVal}`.substring(0, `${newVal}`.indexOf(".") + (precision + 1)));
|
|
658
|
+
}
|
|
659
|
+
if (e) {
|
|
660
|
+
e.target.value = String(newVal);
|
|
661
|
+
}
|
|
662
|
+
currentValue.value = newVal;
|
|
663
|
+
updateInput(oldVal);
|
|
664
|
+
};
|
|
665
|
+
const validate = (value, e) => {
|
|
666
|
+
if (!isNaN(+value) || value === "" || value === "-") {
|
|
667
|
+
setCurrentValue(value, e);
|
|
668
|
+
} else {
|
|
669
|
+
if (e) e.target.value = String(currentValue.value);
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
const handleInputChange = (e) => {
|
|
673
|
+
let val = e.target.value;
|
|
674
|
+
if (val.indexOf(".") === 0) {
|
|
675
|
+
val = val.replace(/^\./g, "0.");
|
|
676
|
+
}
|
|
677
|
+
if (/^-?\d+$/.test(val) && val.indexOf("0") === 0) {
|
|
678
|
+
val = `${Number(val)}`;
|
|
679
|
+
e.target.value = val;
|
|
680
|
+
}
|
|
681
|
+
validate(val, e);
|
|
682
|
+
};
|
|
683
|
+
const handleInputBlur = () => {
|
|
684
|
+
if (currentValue.value === "-") {
|
|
685
|
+
currentValue.value = "";
|
|
686
|
+
} else if (currentValue.value === "-0") {
|
|
687
|
+
currentValue.value = 0;
|
|
688
|
+
}
|
|
689
|
+
const oldVal = currentValue.value;
|
|
690
|
+
const str = String(currentValue.value);
|
|
691
|
+
currentValue.value = str.indexOf(".") === str.length - 1 ? str.replace(/\.$/g, "") : currentValue.value;
|
|
692
|
+
updateInput(oldVal);
|
|
693
|
+
};
|
|
694
|
+
const increment = () => {
|
|
695
|
+
if (props2.disabled || props2.readonly) {
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
const base = currentValue.value === "" ? 0 : +currentValue.value;
|
|
699
|
+
const next = base + props2.step;
|
|
700
|
+
validate(next);
|
|
701
|
+
};
|
|
702
|
+
const decrement = () => {
|
|
703
|
+
if (props2.disabled || props2.readonly) {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
const base = currentValue.value === "" ? 0 : +currentValue.value;
|
|
707
|
+
const next = base - props2.step;
|
|
708
|
+
validate(next);
|
|
709
|
+
};
|
|
710
|
+
const handleKeydown = (e) => {
|
|
711
|
+
if (e.key === "ArrowUp") {
|
|
712
|
+
e.preventDefault();
|
|
713
|
+
increment();
|
|
714
|
+
} else if (e.key === "ArrowDown") {
|
|
715
|
+
e.preventDefault();
|
|
716
|
+
decrement();
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
watch(() => props2.modelValue, (val) => {
|
|
720
|
+
validate(val);
|
|
721
|
+
});
|
|
722
|
+
return {
|
|
723
|
+
currentValue,
|
|
724
|
+
handleInputChange,
|
|
725
|
+
handleInputBlur,
|
|
726
|
+
handleKeydown,
|
|
727
|
+
increment,
|
|
728
|
+
decrement,
|
|
729
|
+
validate
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
const InputNumberCore = {
|
|
733
|
+
props: props$D,
|
|
734
|
+
useInputNumber
|
|
735
|
+
};
|
|
736
|
+
const props$C = {
|
|
737
|
+
modelValue: { type: Number, default: 0 },
|
|
738
|
+
min: { type: Number, default: 0 },
|
|
739
|
+
max: { type: Number, default: 100 },
|
|
740
|
+
step: { type: Number, default: 1 },
|
|
741
|
+
disabled: { type: Boolean, default: false },
|
|
742
|
+
showInfo: { type: Boolean, default: false },
|
|
743
|
+
showStops: { type: Boolean, default: false }
|
|
744
|
+
};
|
|
745
|
+
function useResizeObserver(target, callback, options = {}) {
|
|
746
|
+
let observer;
|
|
747
|
+
const cleanup = () => {
|
|
748
|
+
if (observer) {
|
|
749
|
+
observer.disconnect();
|
|
750
|
+
observer = void 0;
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
watch(target, () => {
|
|
754
|
+
if (target.value) {
|
|
755
|
+
cleanup();
|
|
756
|
+
observer = new ResizeObserver(callback);
|
|
757
|
+
observer.observe(target.value, options);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
return {
|
|
761
|
+
cleanup
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function useElementSize(target) {
|
|
765
|
+
const w = ref(0);
|
|
766
|
+
const h = ref(0);
|
|
767
|
+
useResizeObserver(target, () => {
|
|
768
|
+
const ele = target.value;
|
|
769
|
+
if (window && ele) {
|
|
770
|
+
const styles = window.getComputedStyle(ele);
|
|
771
|
+
w.value = Number.parseFloat(styles.width);
|
|
772
|
+
h.value = Number.parseFloat(styles.height);
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
return {
|
|
776
|
+
w,
|
|
777
|
+
h
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
const interactjs = _interactjsModule.default ?? _interactjsModule;
|
|
781
|
+
function useDrag(config) {
|
|
782
|
+
var _a;
|
|
783
|
+
const domRef = ((_a = config.value) == null ? void 0 : _a.domRef) ?? ref();
|
|
784
|
+
const init = (basePosition) => {
|
|
785
|
+
var _a2, _b;
|
|
786
|
+
if (!domRef.value) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
const position = { x: (basePosition == null ? void 0 : basePosition.x) ?? 0, y: (basePosition == null ? void 0 : basePosition.y) ?? 0 };
|
|
790
|
+
return interactjs(domRef.value).styleCursor(false).draggable({
|
|
791
|
+
...(_b = (_a2 = config.event) == null ? void 0 : _a2.getOption) == null ? void 0 : _b.call(_a2),
|
|
792
|
+
listeners: {
|
|
793
|
+
end: (event2) => {
|
|
794
|
+
var _a3, _b2;
|
|
795
|
+
(_b2 = (_a3 = config.event) == null ? void 0 : _a3.onDragLeave) == null ? void 0 : _b2.call(_a3, event2);
|
|
796
|
+
},
|
|
797
|
+
move: (event2) => {
|
|
798
|
+
var _a3, _b2;
|
|
799
|
+
const { x, y } = ((_b2 = (_a3 = config.event) == null ? void 0 : _a3.movePositionHandler) == null ? void 0 : _b2.call(_a3, event2, position)) ?? {
|
|
800
|
+
x: position.x + event2.dx,
|
|
801
|
+
y: position.y + event2.dy
|
|
802
|
+
};
|
|
803
|
+
position.x = x;
|
|
804
|
+
position.y = y;
|
|
805
|
+
event2.target.style.transform = `translate(${position.x}px, ${position.y}px)`;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
return {
|
|
811
|
+
domRef,
|
|
812
|
+
init
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
function useSlider(props2, ctx) {
|
|
816
|
+
const sliderRef = ref(null);
|
|
817
|
+
const sliderSize = useElementSize(sliderRef);
|
|
818
|
+
const perRef = ref(0);
|
|
819
|
+
const option = { startAxis: "x", lockAxis: "x" };
|
|
820
|
+
const btnW = 20;
|
|
821
|
+
const sub = props2.max - props2.min;
|
|
822
|
+
const movePositionHandler = (event2, position) => {
|
|
823
|
+
const totalW = sliderSize.w.value - btnW;
|
|
824
|
+
let positionX = position.x + event2.dx;
|
|
825
|
+
if (positionX > totalW) {
|
|
826
|
+
positionX = totalW;
|
|
827
|
+
} else if (positionX < 0) {
|
|
828
|
+
positionX = 0;
|
|
829
|
+
}
|
|
830
|
+
perRef.value = positionX / totalW;
|
|
831
|
+
ctx.emit("update:modelValue", getValue());
|
|
832
|
+
return { x: positionX > 0 ? positionX : 0, y: 0 };
|
|
833
|
+
};
|
|
834
|
+
const getValue = () => {
|
|
835
|
+
const addStep = Math.round(perRef.value * sub / props2.step) * props2.step;
|
|
836
|
+
return props2.min + addStep;
|
|
837
|
+
};
|
|
838
|
+
const { init: initDrag, domRef: btnRef } = useDrag({
|
|
839
|
+
event: {
|
|
840
|
+
getOption: () => option,
|
|
841
|
+
movePositionHandler
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
const init = () => {
|
|
845
|
+
if (btnRef.value) {
|
|
846
|
+
const { max, min, modelValue } = props2;
|
|
847
|
+
const per = (modelValue - min) / (max - min);
|
|
848
|
+
if (window && sliderRef.value) {
|
|
849
|
+
const w = Number.parseFloat(window.getComputedStyle(sliderRef.value).width);
|
|
850
|
+
const totalW = w - btnW;
|
|
851
|
+
perRef.value = per;
|
|
852
|
+
const x = per * totalW;
|
|
853
|
+
btnRef.value.style.transform = `translate(${x}px, 0)`;
|
|
854
|
+
initDrag({ x });
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
onMounted(() => {
|
|
859
|
+
init();
|
|
860
|
+
});
|
|
861
|
+
return {
|
|
862
|
+
btnRef,
|
|
863
|
+
sliderRef,
|
|
864
|
+
perRef
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
const SliderCore = {
|
|
868
|
+
props: props$C,
|
|
869
|
+
useSlider
|
|
870
|
+
};
|
|
871
|
+
const messageProps = {
|
|
872
|
+
content: { type: String, required: true },
|
|
873
|
+
type: { type: String, default: "info" },
|
|
874
|
+
duration: { type: Number, default: 3e3 },
|
|
875
|
+
direction: { type: String, default: "top-right" }
|
|
876
|
+
};
|
|
877
|
+
const messageListProps = {
|
|
878
|
+
direction: { type: String, default: "top-right" }
|
|
879
|
+
};
|
|
880
|
+
function useMessageQueue() {
|
|
881
|
+
const messages = ref([]);
|
|
882
|
+
let nextId = 0;
|
|
883
|
+
const add = (props2) => {
|
|
884
|
+
const id = nextId++;
|
|
885
|
+
const item = {
|
|
886
|
+
id,
|
|
887
|
+
type: props2.type ?? "info",
|
|
888
|
+
content: props2.content,
|
|
889
|
+
duration: props2.duration ?? 3e3
|
|
890
|
+
};
|
|
891
|
+
messages.value.push(item);
|
|
892
|
+
if (item.duration > 0) {
|
|
893
|
+
setTimeout(() => remove(id), item.duration);
|
|
894
|
+
}
|
|
895
|
+
return id;
|
|
896
|
+
};
|
|
897
|
+
const remove = (id) => {
|
|
898
|
+
const idx = messages.value.findIndex((m) => m.id === id);
|
|
899
|
+
if (idx !== -1) {
|
|
900
|
+
messages.value.splice(idx, 1);
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
return { messages, add, remove };
|
|
904
|
+
}
|
|
905
|
+
const MessageCore = {
|
|
906
|
+
messageProps,
|
|
907
|
+
messageListProps,
|
|
908
|
+
useMessageQueue
|
|
909
|
+
};
|
|
910
|
+
const formProps = {
|
|
911
|
+
inline: { type: Boolean, default: false },
|
|
912
|
+
submit: { type: Boolean, default: false },
|
|
913
|
+
model: { type: Object, default: void 0 },
|
|
914
|
+
labelWidth: { type: String, default: void 0 }
|
|
915
|
+
};
|
|
916
|
+
const formItemProps = {
|
|
917
|
+
label: { type: String, default: "" },
|
|
918
|
+
prop: { type: String, default: "" },
|
|
919
|
+
required: { type: Boolean, default: false }
|
|
920
|
+
};
|
|
921
|
+
const FormCore = {
|
|
922
|
+
props: formProps,
|
|
923
|
+
formItemProps
|
|
924
|
+
};
|
|
925
|
+
const props$B = {
|
|
926
|
+
placement: {
|
|
927
|
+
type: String,
|
|
928
|
+
default: "bottom"
|
|
929
|
+
},
|
|
930
|
+
mountRender: { type: Boolean, default: false },
|
|
931
|
+
disableClickAway: { type: Boolean, default: false },
|
|
932
|
+
hover: { type: Boolean, default: false },
|
|
933
|
+
show: { type: Boolean, default: null },
|
|
934
|
+
content: { type: String, default: "" },
|
|
935
|
+
popper: {
|
|
936
|
+
type: Object,
|
|
937
|
+
default: () => ({})
|
|
938
|
+
},
|
|
939
|
+
teleport: { type: [Object, Boolean], default: void 0 },
|
|
940
|
+
title: { type: String, default: void 0 }
|
|
941
|
+
};
|
|
942
|
+
const usePopper = (triggerNode, popperNode, update, arrowNode, config) => {
|
|
943
|
+
const getPositionStyle = async () => {
|
|
944
|
+
var _a, _b;
|
|
945
|
+
if (arrowNode && (config == null ? void 0 : config.middleware)) {
|
|
946
|
+
config.middleware.push(arrow({ element: arrowNode }));
|
|
947
|
+
}
|
|
948
|
+
const { x, y, placement, middlewareData } = await computePosition(triggerNode, popperNode, config);
|
|
949
|
+
const res = {
|
|
950
|
+
style: {
|
|
951
|
+
left: `${x}px`,
|
|
952
|
+
top: `${y}px`,
|
|
953
|
+
display: "block",
|
|
954
|
+
position: "absolute"
|
|
955
|
+
},
|
|
956
|
+
arrowStyle: {
|
|
957
|
+
left: `${((_a = middlewareData.arrow) == null ? void 0 : _a.x) ?? 0}px`,
|
|
958
|
+
top: `${((_b = middlewareData.arrow) == null ? void 0 : _b.y) ?? 0}px`,
|
|
959
|
+
display: "block",
|
|
960
|
+
position: "absolute"
|
|
961
|
+
},
|
|
962
|
+
placement
|
|
963
|
+
};
|
|
964
|
+
update(res);
|
|
965
|
+
return res;
|
|
966
|
+
};
|
|
967
|
+
const clear = autoUpdate(triggerNode, popperNode, getPositionStyle);
|
|
968
|
+
return {
|
|
969
|
+
getPositionStyle,
|
|
970
|
+
clear
|
|
971
|
+
};
|
|
972
|
+
};
|
|
973
|
+
function useEventListener(options) {
|
|
974
|
+
const getTarget = () => {
|
|
975
|
+
if (typeof options.target === "function") {
|
|
976
|
+
return options.target();
|
|
977
|
+
}
|
|
978
|
+
return options.target;
|
|
979
|
+
};
|
|
980
|
+
const add = () => {
|
|
981
|
+
getTarget().addEventListener(options.event, options.handler);
|
|
982
|
+
};
|
|
983
|
+
const remove = () => {
|
|
984
|
+
getTarget().removeEventListener(options.event, options.handler);
|
|
985
|
+
};
|
|
986
|
+
const onMounted2 = () => {
|
|
987
|
+
add();
|
|
988
|
+
};
|
|
989
|
+
const onBeforeDestroy = () => {
|
|
990
|
+
remove();
|
|
991
|
+
};
|
|
992
|
+
return {
|
|
993
|
+
add,
|
|
994
|
+
remove,
|
|
995
|
+
onMounted: onMounted2,
|
|
996
|
+
onBeforeDestroy
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
const event = "pointerdown";
|
|
1000
|
+
function useClickAway(options) {
|
|
1001
|
+
if (typeof window === "undefined" || !window) {
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
const listener = (event2) => {
|
|
1005
|
+
const el = typeof options.target === "function" ? options.target() : options.target;
|
|
1006
|
+
if (!el) {
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
if (el === event2.target || event2.composedPath().includes(el)) {
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
options.handler(event2);
|
|
1013
|
+
};
|
|
1014
|
+
return useEventListener({
|
|
1015
|
+
target: window,
|
|
1016
|
+
event,
|
|
1017
|
+
handler: listener
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
let PopoverImpl$1 = class PopoverImpl {
|
|
1021
|
+
constructor(val, active, content, arrow2, config, lifecycle) {
|
|
1022
|
+
__publicField(this, "_active");
|
|
1023
|
+
__publicField(this, "_content");
|
|
1024
|
+
__publicField(this, "_arrow");
|
|
1025
|
+
__publicField(this, "popperInstance");
|
|
1026
|
+
__publicField(this, "style");
|
|
1027
|
+
__publicField(this, "arrowStyle");
|
|
1028
|
+
__publicField(this, "placement");
|
|
1029
|
+
__publicField(this, "visible", false);
|
|
1030
|
+
__publicField(this, "onShow");
|
|
1031
|
+
__publicField(this, "onHide");
|
|
1032
|
+
if (!content) {
|
|
1033
|
+
throw new Error("MPopover: content is required");
|
|
1034
|
+
}
|
|
1035
|
+
if (!active) {
|
|
1036
|
+
throw new Error("MPopover: active is required");
|
|
1037
|
+
}
|
|
1038
|
+
this._active = active;
|
|
1039
|
+
this._content = content;
|
|
1040
|
+
this._arrow = arrow2;
|
|
1041
|
+
this.popperInstance = usePopper(
|
|
1042
|
+
this._active,
|
|
1043
|
+
this._content,
|
|
1044
|
+
(positionStyle) => this.update(positionStyle),
|
|
1045
|
+
this._arrow,
|
|
1046
|
+
config
|
|
1047
|
+
);
|
|
1048
|
+
this.style = val.style;
|
|
1049
|
+
this.arrowStyle = val.arrowStyle;
|
|
1050
|
+
this.placement = val.placement;
|
|
1051
|
+
this.visible = val.show;
|
|
1052
|
+
this.onShow = lifecycle == null ? void 0 : lifecycle.onShow;
|
|
1053
|
+
this.onHide = lifecycle == null ? void 0 : lifecycle.onHide;
|
|
1054
|
+
}
|
|
1055
|
+
get content() {
|
|
1056
|
+
return this._content;
|
|
1057
|
+
}
|
|
1058
|
+
async show() {
|
|
1059
|
+
var _a;
|
|
1060
|
+
this.style.value = { display: "block", opacity: "0" };
|
|
1061
|
+
this.arrowStyle.value = { display: "block", opacity: "0" };
|
|
1062
|
+
this.visible = true;
|
|
1063
|
+
await this.popperInstance.getPositionStyle();
|
|
1064
|
+
(_a = this.onShow) == null ? void 0 : _a.call(this);
|
|
1065
|
+
}
|
|
1066
|
+
update(positionStyle) {
|
|
1067
|
+
if (!this.visible) {
|
|
1068
|
+
this.hide();
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
this.style.value = positionStyle.style;
|
|
1072
|
+
this.arrowStyle.value = positionStyle.arrowStyle;
|
|
1073
|
+
this.placement.value = positionStyle.placement;
|
|
1074
|
+
}
|
|
1075
|
+
hide() {
|
|
1076
|
+
var _a;
|
|
1077
|
+
this.style.value = void 0;
|
|
1078
|
+
this.arrowStyle.value = void 0;
|
|
1079
|
+
this.visible = false;
|
|
1080
|
+
(_a = this.onHide) == null ? void 0 : _a.call(this);
|
|
1081
|
+
}
|
|
1082
|
+
async toggle() {
|
|
1083
|
+
if (this.visible) {
|
|
1084
|
+
this.hide();
|
|
1085
|
+
} else {
|
|
1086
|
+
await this.show();
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
destroy() {
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
function usePopover$1(props2, ctx) {
|
|
1093
|
+
const style = ref();
|
|
1094
|
+
const arrowStyle = ref();
|
|
1095
|
+
const placement = ref(props2.placement);
|
|
1096
|
+
let instance = null;
|
|
1097
|
+
let clickAwayInstance;
|
|
1098
|
+
const popperInstance = shallowRef();
|
|
1099
|
+
const popoverRef = ref();
|
|
1100
|
+
const contentRef = ref();
|
|
1101
|
+
const arrowRef = ref();
|
|
1102
|
+
const createPopover = (active, content, arrow2, config) => {
|
|
1103
|
+
instance = new PopoverImpl$1(
|
|
1104
|
+
{ style, arrowStyle, placement, show: props2.show },
|
|
1105
|
+
active,
|
|
1106
|
+
content,
|
|
1107
|
+
arrow2,
|
|
1108
|
+
config,
|
|
1109
|
+
{
|
|
1110
|
+
onShow: () => {
|
|
1111
|
+
clickAwayInstance == null ? void 0 : clickAwayInstance.add();
|
|
1112
|
+
ctx.emit("update:show", true);
|
|
1113
|
+
},
|
|
1114
|
+
onHide: () => {
|
|
1115
|
+
clickAwayInstance == null ? void 0 : clickAwayInstance.remove();
|
|
1116
|
+
ctx.emit("update:show", false);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
return instance;
|
|
1121
|
+
};
|
|
1122
|
+
const popoverEnter = () => {
|
|
1123
|
+
if (props2.hover) {
|
|
1124
|
+
instance == null ? void 0 : instance.show();
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
const popoverLeave = () => {
|
|
1128
|
+
if (props2.hover) {
|
|
1129
|
+
instance == null ? void 0 : instance.hide();
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
onMounted(() => {
|
|
1133
|
+
if (!popoverRef.value || !contentRef.value) {
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
popperInstance.value = createPopover(popoverRef.value, contentRef.value, arrowRef.value, {
|
|
1137
|
+
...props2.popper,
|
|
1138
|
+
placement: props2.placement
|
|
1139
|
+
});
|
|
1140
|
+
if (props2.disableClickAway) {
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
clickAwayInstance = useClickAway({
|
|
1144
|
+
target: () => {
|
|
1145
|
+
var _a;
|
|
1146
|
+
return (_a = instance == null ? void 0 : instance.content) == null ? void 0 : _a.parentElement;
|
|
1147
|
+
},
|
|
1148
|
+
handler: () => {
|
|
1149
|
+
instance == null ? void 0 : instance.hide();
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
});
|
|
1153
|
+
onBeforeMount(() => {
|
|
1154
|
+
if (clickAwayInstance) {
|
|
1155
|
+
const { onBeforeDestroy } = clickAwayInstance;
|
|
1156
|
+
onBeforeDestroy();
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
return {
|
|
1160
|
+
popoverEnter,
|
|
1161
|
+
popoverLeave,
|
|
1162
|
+
popoverRef,
|
|
1163
|
+
contentRef,
|
|
1164
|
+
arrowRef,
|
|
1165
|
+
popperInstance,
|
|
1166
|
+
style,
|
|
1167
|
+
arrowStyle,
|
|
1168
|
+
placement
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
const PopoverCore = {
|
|
1172
|
+
props: props$B,
|
|
1173
|
+
usePopover: usePopover$1
|
|
1174
|
+
};
|
|
1175
|
+
const props$A = {
|
|
1176
|
+
content: { type: String, default: "" },
|
|
1177
|
+
placement: {
|
|
1178
|
+
type: String,
|
|
1179
|
+
default: "top"
|
|
1180
|
+
},
|
|
1181
|
+
disabled: { type: Boolean, default: false }
|
|
1182
|
+
};
|
|
1183
|
+
function calcPosition(rect, tooltipEl, placement) {
|
|
1184
|
+
const gap = 8;
|
|
1185
|
+
const tooltipRect = tooltipEl.getBoundingClientRect();
|
|
1186
|
+
let left = 0;
|
|
1187
|
+
let top = 0;
|
|
1188
|
+
switch (placement) {
|
|
1189
|
+
case "top":
|
|
1190
|
+
left = rect.left + rect.width / 2 - tooltipRect.width / 2;
|
|
1191
|
+
top = rect.top - tooltipRect.height - gap;
|
|
1192
|
+
break;
|
|
1193
|
+
case "bottom":
|
|
1194
|
+
left = rect.left + rect.width / 2 - tooltipRect.width / 2;
|
|
1195
|
+
top = rect.bottom + gap;
|
|
1196
|
+
break;
|
|
1197
|
+
case "left":
|
|
1198
|
+
left = rect.left - tooltipRect.width - gap;
|
|
1199
|
+
top = rect.top + rect.height / 2 - tooltipRect.height / 2;
|
|
1200
|
+
break;
|
|
1201
|
+
case "right":
|
|
1202
|
+
left = rect.right + gap;
|
|
1203
|
+
top = rect.top + rect.height / 2 - tooltipRect.height / 2;
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
return {
|
|
1207
|
+
position: "fixed",
|
|
1208
|
+
left: `${left}px`,
|
|
1209
|
+
top: `${top}px`,
|
|
1210
|
+
zIndex: "9999"
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
function useTooltip(props2) {
|
|
1214
|
+
const visible = ref(false);
|
|
1215
|
+
const tooltipStyle = ref({});
|
|
1216
|
+
const triggerRef2 = ref(null);
|
|
1217
|
+
const tooltipRef = ref(null);
|
|
1218
|
+
const show = async () => {
|
|
1219
|
+
if (props2.disabled) return;
|
|
1220
|
+
visible.value = true;
|
|
1221
|
+
await nextTick();
|
|
1222
|
+
if (!triggerRef2.value || !tooltipRef.value) return;
|
|
1223
|
+
const rect = triggerRef2.value.getBoundingClientRect();
|
|
1224
|
+
tooltipStyle.value = calcPosition(rect, tooltipRef.value, props2.placement);
|
|
1225
|
+
};
|
|
1226
|
+
const hide = () => {
|
|
1227
|
+
visible.value = false;
|
|
1228
|
+
tooltipStyle.value = {};
|
|
1229
|
+
};
|
|
1230
|
+
return {
|
|
1231
|
+
visible,
|
|
1232
|
+
tooltipStyle,
|
|
1233
|
+
triggerRef: triggerRef2,
|
|
1234
|
+
tooltipRef,
|
|
1235
|
+
show,
|
|
1236
|
+
hide
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
const TooltipCore = {
|
|
1240
|
+
props: props$A,
|
|
1241
|
+
useTooltip
|
|
1242
|
+
};
|
|
1243
|
+
const props$z = {
|
|
1244
|
+
vertical: { type: Boolean, default: false },
|
|
1245
|
+
align: { type: String, default: "center" }
|
|
1246
|
+
};
|
|
1247
|
+
const DividerCore = {
|
|
1248
|
+
props: props$z
|
|
1249
|
+
};
|
|
1250
|
+
const props$y = {
|
|
1251
|
+
modelValue: { type: Boolean, default: false },
|
|
1252
|
+
size: { type: String, default: "medium" },
|
|
1253
|
+
mask: { type: Boolean, default: false },
|
|
1254
|
+
text: { type: String, default: void 0 }
|
|
1255
|
+
};
|
|
1256
|
+
const LoadingCore = {
|
|
1257
|
+
props: props$y
|
|
1258
|
+
};
|
|
1259
|
+
const props$x = {
|
|
1260
|
+
visible: { type: Boolean, default: false },
|
|
1261
|
+
mask: { type: Object, default: () => ({ show: true, clickClose: true }) },
|
|
1262
|
+
closeBtn: { type: Boolean, default: true },
|
|
1263
|
+
teleport: { type: Object, default: () => ({ to: "body" }) },
|
|
1264
|
+
title: { type: String, default: void 0 },
|
|
1265
|
+
width: { type: String, default: void 0 }
|
|
1266
|
+
};
|
|
1267
|
+
const DialogCore = {
|
|
1268
|
+
props: props$x
|
|
1269
|
+
};
|
|
1270
|
+
const props$w = {
|
|
1271
|
+
visible: { type: Boolean, default: false },
|
|
1272
|
+
mask: {
|
|
1273
|
+
type: Object,
|
|
1274
|
+
default: () => ({ show: true, clickClose: true })
|
|
1275
|
+
},
|
|
1276
|
+
drawerClass: { type: Array, default: () => [] },
|
|
1277
|
+
direction: {
|
|
1278
|
+
type: String,
|
|
1279
|
+
default: "right"
|
|
1280
|
+
},
|
|
1281
|
+
teleport: {
|
|
1282
|
+
type: Object,
|
|
1283
|
+
default: () => ({ to: "body" })
|
|
1284
|
+
},
|
|
1285
|
+
title: { type: String, default: void 0 },
|
|
1286
|
+
width: { type: String, default: void 0 },
|
|
1287
|
+
height: { type: String, default: void 0 }
|
|
1288
|
+
};
|
|
1289
|
+
const DrawerCore = {
|
|
1290
|
+
props: props$w
|
|
1291
|
+
};
|
|
1292
|
+
const props$v = {
|
|
1293
|
+
visible: { type: Boolean, default: false },
|
|
1294
|
+
mask: { type: Object, default: () => ({ show: true, clickClose: false }) },
|
|
1295
|
+
teleport: { type: Object, default: () => ({ to: "body" }) },
|
|
1296
|
+
content: { type: String, default: "" },
|
|
1297
|
+
confirmText: { type: String, default: "确定" },
|
|
1298
|
+
cancelText: { type: String, default: "取消" },
|
|
1299
|
+
title: { type: String, default: void 0 },
|
|
1300
|
+
loading: { type: Boolean, default: false }
|
|
1301
|
+
};
|
|
1302
|
+
const ConfirmCore = {
|
|
1303
|
+
props: props$v
|
|
1304
|
+
};
|
|
1305
|
+
const props$u = {
|
|
1306
|
+
modelValue: { type: Boolean, default: false },
|
|
1307
|
+
autoMode: { type: Boolean, default: false },
|
|
1308
|
+
initHandler: { type: Function, default: void 0 },
|
|
1309
|
+
storageKey: { type: String, default: void 0 }
|
|
1310
|
+
};
|
|
1311
|
+
function applyDarkAttr(isDark) {
|
|
1312
|
+
if (typeof document === "undefined") return;
|
|
1313
|
+
const html = document.querySelector("html");
|
|
1314
|
+
if (!html) return;
|
|
1315
|
+
if (isDark) {
|
|
1316
|
+
html.setAttribute("dark", "");
|
|
1317
|
+
} else {
|
|
1318
|
+
html.removeAttribute("dark");
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
function readStorage(storageKey) {
|
|
1322
|
+
if (typeof window === "undefined") return null;
|
|
1323
|
+
const stored = localStorage.getItem(storageKey);
|
|
1324
|
+
if (stored === null) return null;
|
|
1325
|
+
return stored === "true";
|
|
1326
|
+
}
|
|
1327
|
+
function writeStorage(storageKey, isDark) {
|
|
1328
|
+
if (typeof window === "undefined") return;
|
|
1329
|
+
localStorage.setItem(storageKey, isDark.toString());
|
|
1330
|
+
}
|
|
1331
|
+
function useDarkMode(props2, ctx) {
|
|
1332
|
+
const isDark = ref(props2.modelValue ?? false);
|
|
1333
|
+
const toggle = () => {
|
|
1334
|
+
isDark.value = !isDark.value;
|
|
1335
|
+
ctx.emit("update:modelValue", isDark.value);
|
|
1336
|
+
ctx.emit("change", isDark.value);
|
|
1337
|
+
};
|
|
1338
|
+
watch(
|
|
1339
|
+
() => props2.modelValue,
|
|
1340
|
+
(val) => {
|
|
1341
|
+
if (val !== void 0 && val !== isDark.value) {
|
|
1342
|
+
isDark.value = val;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
);
|
|
1346
|
+
watch(isDark, (val) => {
|
|
1347
|
+
applyDarkAttr(val);
|
|
1348
|
+
if (props2.storageKey) {
|
|
1349
|
+
writeStorage(props2.storageKey, val);
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
let mediaQuery = null;
|
|
1353
|
+
const onSystemChange = (event2) => {
|
|
1354
|
+
isDark.value = event2.matches;
|
|
1355
|
+
ctx.emit("update:modelValue", isDark.value);
|
|
1356
|
+
ctx.emit("change", isDark.value);
|
|
1357
|
+
};
|
|
1358
|
+
onMounted(() => {
|
|
1359
|
+
if (props2.initHandler) {
|
|
1360
|
+
const shouldAutoInit = props2.initHandler();
|
|
1361
|
+
if (!shouldAutoInit) {
|
|
1362
|
+
applyDarkAttr(isDark.value);
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
} else if (props2.storageKey) {
|
|
1366
|
+
const stored = readStorage(props2.storageKey);
|
|
1367
|
+
if (stored !== null) {
|
|
1368
|
+
isDark.value = stored;
|
|
1369
|
+
applyDarkAttr(isDark.value);
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
if (props2.autoMode && typeof window !== "undefined") {
|
|
1374
|
+
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1375
|
+
isDark.value = mediaQuery.matches;
|
|
1376
|
+
ctx.emit("update:modelValue", isDark.value);
|
|
1377
|
+
ctx.emit("change", isDark.value);
|
|
1378
|
+
mediaQuery.addEventListener("change", onSystemChange);
|
|
1379
|
+
}
|
|
1380
|
+
applyDarkAttr(isDark.value);
|
|
1381
|
+
});
|
|
1382
|
+
onUnmounted(() => {
|
|
1383
|
+
if (mediaQuery) {
|
|
1384
|
+
mediaQuery.removeEventListener("change", onSystemChange);
|
|
1385
|
+
mediaQuery = null;
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
return {
|
|
1389
|
+
isDark,
|
|
1390
|
+
toggle,
|
|
1391
|
+
applyDarkAttr
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
const DarkModeCore = {
|
|
1395
|
+
props: props$u,
|
|
1396
|
+
useDarkMode
|
|
1397
|
+
};
|
|
1398
|
+
const props$t = {
|
|
1399
|
+
separator: { type: String, default: "/" },
|
|
1400
|
+
items: { type: Array, default: () => [] }
|
|
1401
|
+
};
|
|
1402
|
+
const BreadcrumbCore = {
|
|
1403
|
+
props: props$t
|
|
1404
|
+
};
|
|
1405
|
+
const props$s = {
|
|
1406
|
+
h: { type: Number, default: void 0 },
|
|
1407
|
+
w: { type: Number, default: void 0 },
|
|
1408
|
+
gap: { type: [Number, String], default: 0 },
|
|
1409
|
+
colGap: { type: [Number, String], default: void 0 },
|
|
1410
|
+
rowGap: { type: [Number, String], default: void 0 },
|
|
1411
|
+
direction: { type: String, default: "row" },
|
|
1412
|
+
cols: { type: Number, default: void 0 }
|
|
1413
|
+
};
|
|
1414
|
+
const GridCore = {
|
|
1415
|
+
props: props$s
|
|
1416
|
+
};
|
|
1417
|
+
const props$r = {
|
|
1418
|
+
total: { type: Number, default: 0 },
|
|
1419
|
+
modelValue: { type: Number, default: void 0 },
|
|
1420
|
+
defaultCurrent: { type: Number, default: 1 },
|
|
1421
|
+
pageSize: { type: Number, default: 10 },
|
|
1422
|
+
pageSizes: { type: Array, default: () => [10, 20, 30, 40, 50, 100] },
|
|
1423
|
+
layout: { type: String, default: "prev, pager, next, total" },
|
|
1424
|
+
foldedMaxPageBtn: { type: Number, default: 5 },
|
|
1425
|
+
maxPageBtn: { type: Number, default: 10 },
|
|
1426
|
+
showEdgePageNum: { type: Boolean, default: true }
|
|
1427
|
+
};
|
|
1428
|
+
const oddNum = (num) => {
|
|
1429
|
+
return num % 2 === 0 ? num + 1 : num;
|
|
1430
|
+
};
|
|
1431
|
+
function usePagination(props2, currentValue) {
|
|
1432
|
+
const getPageBtnLength = () => {
|
|
1433
|
+
const total = props2.total ?? 0;
|
|
1434
|
+
const pageSize = props2.pageSize ?? 10;
|
|
1435
|
+
return Math.ceil(total / pageSize);
|
|
1436
|
+
};
|
|
1437
|
+
const toPager = (value, config) => {
|
|
1438
|
+
return {
|
|
1439
|
+
value,
|
|
1440
|
+
type: (config == null ? void 0 : config.type) ?? "number",
|
|
1441
|
+
isCurrent: currentValue.value === value,
|
|
1442
|
+
jump: (config == null ? void 0 : config.jump) ?? value
|
|
1443
|
+
};
|
|
1444
|
+
};
|
|
1445
|
+
const toFoldedPager = (jump) => {
|
|
1446
|
+
return toPager("...", { type: "folded", jump });
|
|
1447
|
+
};
|
|
1448
|
+
const getPageNumListRange = (start, length) => {
|
|
1449
|
+
return Array.from({ length }, (_, i) => toPager(i + start));
|
|
1450
|
+
};
|
|
1451
|
+
const getPageNumList = () => {
|
|
1452
|
+
const pageBtnLength = getPageBtnLength();
|
|
1453
|
+
const total = props2.total ?? 0;
|
|
1454
|
+
const pageSize = props2.pageSize ?? 10;
|
|
1455
|
+
const foldedMaxPageBtn = props2.foldedMaxPageBtn ?? 5;
|
|
1456
|
+
const maxPageBtn = props2.maxPageBtn ?? 10;
|
|
1457
|
+
const showEdgePageNum = props2.showEdgePageNum ?? true;
|
|
1458
|
+
if (total <= pageSize) {
|
|
1459
|
+
return [toPager(1)];
|
|
1460
|
+
}
|
|
1461
|
+
if (!maxPageBtn || pageBtnLength <= maxPageBtn || foldedMaxPageBtn && foldedMaxPageBtn >= pageBtnLength - 1) {
|
|
1462
|
+
return getPageNumListRange(1, pageBtnLength);
|
|
1463
|
+
}
|
|
1464
|
+
const foldedMaxPageBtnOdd = Math.max(oddNum(foldedMaxPageBtn ?? 5), 1);
|
|
1465
|
+
const edgeConfig = {
|
|
1466
|
+
// showEdgePageNum 时首尾各占 1 个槽位
|
|
1467
|
+
length: showEdgePageNum ? 1 : 0,
|
|
1468
|
+
// 右侧起始位置的偏移修正
|
|
1469
|
+
rightStartSub: showEdgePageNum ? 0 : 1
|
|
1470
|
+
};
|
|
1471
|
+
const btnNumWithoutEdge = foldedMaxPageBtnOdd - (showEdgePageNum ? 2 : 0);
|
|
1472
|
+
const pageEdge = (btnNumWithoutEdge - 1) / 2;
|
|
1473
|
+
const leftEdgeNum = pageEdge + 2;
|
|
1474
|
+
const rightEdgeNum = pageBtnLength - pageEdge - 1;
|
|
1475
|
+
const rightStart = pageBtnLength - foldedMaxPageBtnOdd + 2 - edgeConfig.rightStartSub;
|
|
1476
|
+
if (currentValue.value <= leftEdgeNum) {
|
|
1477
|
+
const numLength = foldedMaxPageBtnOdd - edgeConfig.length;
|
|
1478
|
+
const res2 = [
|
|
1479
|
+
...getPageNumListRange(1, numLength),
|
|
1480
|
+
toFoldedPager(1 + numLength)
|
|
1481
|
+
];
|
|
1482
|
+
if (showEdgePageNum) {
|
|
1483
|
+
res2.push(toPager(pageBtnLength));
|
|
1484
|
+
}
|
|
1485
|
+
return res2;
|
|
1486
|
+
}
|
|
1487
|
+
if (currentValue.value >= rightEdgeNum) {
|
|
1488
|
+
const res2 = [];
|
|
1489
|
+
if (showEdgePageNum) {
|
|
1490
|
+
res2.push(toPager(1));
|
|
1491
|
+
}
|
|
1492
|
+
res2.push(toFoldedPager(rightStart - 1), ...getPageNumListRange(rightStart, foldedMaxPageBtnOdd - edgeConfig.length));
|
|
1493
|
+
return res2;
|
|
1494
|
+
}
|
|
1495
|
+
const leftStart = currentValue.value - pageEdge;
|
|
1496
|
+
const rightEnd = currentValue.value + pageEdge;
|
|
1497
|
+
const leftFolded = Math.abs(leftStart - 1) > 2 || !showEdgePageNum ? toFoldedPager(leftStart - 1) : toPager(showEdgePageNum ? 2 : 1);
|
|
1498
|
+
const rightFolded = Math.abs(rightEnd - pageBtnLength) > 2 || !showEdgePageNum ? toFoldedPager(rightEnd + 1) : toPager(showEdgePageNum ? pageBtnLength - 1 : pageBtnLength);
|
|
1499
|
+
const res = [];
|
|
1500
|
+
if (showEdgePageNum) {
|
|
1501
|
+
res.push(toPager(1));
|
|
1502
|
+
}
|
|
1503
|
+
res.push(
|
|
1504
|
+
leftFolded,
|
|
1505
|
+
...getPageNumListRange(leftStart, foldedMaxPageBtnOdd - edgeConfig.length * 2),
|
|
1506
|
+
rightFolded
|
|
1507
|
+
);
|
|
1508
|
+
if (showEdgePageNum) {
|
|
1509
|
+
res.push(toPager(pageBtnLength));
|
|
1510
|
+
}
|
|
1511
|
+
return res;
|
|
1512
|
+
};
|
|
1513
|
+
return {
|
|
1514
|
+
getPageNumList,
|
|
1515
|
+
getPageBtnLength
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
const PaginationCore = {
|
|
1519
|
+
props: props$r,
|
|
1520
|
+
usePagination
|
|
1521
|
+
};
|
|
1522
|
+
const DEFAULT_MENU_CONFIG = {
|
|
1523
|
+
key: "key",
|
|
1524
|
+
label: "label",
|
|
1525
|
+
children: "children"
|
|
1526
|
+
};
|
|
1527
|
+
const props$q = {
|
|
1528
|
+
data: { type: Array, default: () => [] },
|
|
1529
|
+
config: { type: Object, default: () => ({ ...DEFAULT_MENU_CONFIG }) },
|
|
1530
|
+
checkbox: { type: Boolean, default: false },
|
|
1531
|
+
defaultExpandAll: { type: Boolean, default: false },
|
|
1532
|
+
checkedKeys: { type: Array, default: () => [] },
|
|
1533
|
+
mode: { type: String, default: "vertical" },
|
|
1534
|
+
active: { type: [String, Number], default: void 0 }
|
|
1535
|
+
};
|
|
1536
|
+
const DEFAULT_CONFIG$1 = { key: "key", label: "label", children: "children" };
|
|
1537
|
+
function buildNodes(data, config, nodeMap, defaultExpandAll = false, parent) {
|
|
1538
|
+
return data.map((item) => {
|
|
1539
|
+
const key = item[config.key];
|
|
1540
|
+
const childrenKey = config.children;
|
|
1541
|
+
const node = {
|
|
1542
|
+
...item,
|
|
1543
|
+
expand: defaultExpandAll,
|
|
1544
|
+
isActive: false,
|
|
1545
|
+
checked: false,
|
|
1546
|
+
indeterminate: false,
|
|
1547
|
+
parent,
|
|
1548
|
+
isRoot: !parent
|
|
1549
|
+
};
|
|
1550
|
+
nodeMap.set(key, node);
|
|
1551
|
+
const rawChildren = item[childrenKey];
|
|
1552
|
+
if (Array.isArray(rawChildren) && rawChildren.length > 0) {
|
|
1553
|
+
node.children = buildNodes(
|
|
1554
|
+
rawChildren,
|
|
1555
|
+
config,
|
|
1556
|
+
nodeMap,
|
|
1557
|
+
defaultExpandAll,
|
|
1558
|
+
node
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
return node;
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
function useMenu(props2, emit) {
|
|
1565
|
+
const config = { ...DEFAULT_CONFIG$1, ...props2.config };
|
|
1566
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
1567
|
+
const nodesRef = shallowRef([]);
|
|
1568
|
+
const initNodes = (data = []) => {
|
|
1569
|
+
var _a;
|
|
1570
|
+
nodeMap.clear();
|
|
1571
|
+
nodesRef.value = buildNodes(data, config, nodeMap, props2.defaultExpandAll ?? false, null);
|
|
1572
|
+
if ((_a = props2.checkedKeys) == null ? void 0 : _a.length) {
|
|
1573
|
+
props2.checkedKeys.forEach((key) => {
|
|
1574
|
+
const node = nodeMap.get(key);
|
|
1575
|
+
if (node) {
|
|
1576
|
+
node.checked = true;
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
triggerRef(nodesRef);
|
|
1581
|
+
};
|
|
1582
|
+
initNodes(props2.data ?? []);
|
|
1583
|
+
if (props2.active !== void 0) {
|
|
1584
|
+
const activeNode = nodeMap.get(props2.active);
|
|
1585
|
+
if (activeNode) {
|
|
1586
|
+
activeNode.isActive = true;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
const toggleExpand = (node) => {
|
|
1590
|
+
node.expand = !node.expand;
|
|
1591
|
+
triggerRef(nodesRef);
|
|
1592
|
+
};
|
|
1593
|
+
const setActive = (node) => {
|
|
1594
|
+
nodeMap.forEach((n) => {
|
|
1595
|
+
n.isActive = false;
|
|
1596
|
+
});
|
|
1597
|
+
node.isActive = true;
|
|
1598
|
+
triggerRef(nodesRef);
|
|
1599
|
+
if (emit) {
|
|
1600
|
+
const key = node[config.key];
|
|
1601
|
+
emit("update:active", key);
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
const toggleChecked = (node, checked) => {
|
|
1605
|
+
node.checked = checked;
|
|
1606
|
+
node.indeterminate = false;
|
|
1607
|
+
triggerRef(nodesRef);
|
|
1608
|
+
};
|
|
1609
|
+
const getCheckedKeys = () => {
|
|
1610
|
+
const keys = [];
|
|
1611
|
+
nodeMap.forEach((node, key) => {
|
|
1612
|
+
if (node.checked && !node.indeterminate) {
|
|
1613
|
+
keys.push(key);
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
return keys;
|
|
1617
|
+
};
|
|
1618
|
+
const getNodesByKeys = (keys) => {
|
|
1619
|
+
return keys.map((key) => nodeMap.get(key)).filter((n) => n !== void 0);
|
|
1620
|
+
};
|
|
1621
|
+
return {
|
|
1622
|
+
nodesRef,
|
|
1623
|
+
nodeMap,
|
|
1624
|
+
initNodes,
|
|
1625
|
+
toggleExpand,
|
|
1626
|
+
setActive,
|
|
1627
|
+
toggleChecked,
|
|
1628
|
+
getCheckedKeys,
|
|
1629
|
+
getNodesByKeys,
|
|
1630
|
+
config
|
|
1631
|
+
};
|
|
1632
|
+
}
|
|
1633
|
+
const MenuCore = {
|
|
1634
|
+
props: props$q,
|
|
1635
|
+
useMenu
|
|
1636
|
+
};
|
|
1637
|
+
const props$p = {
|
|
1638
|
+
modelValue: { type: [String, Date], default: "" },
|
|
1639
|
+
placeholder: { type: String, default: "请选择日期..." },
|
|
1640
|
+
format: { type: String, default: void 0 },
|
|
1641
|
+
type: { type: String, default: "date" },
|
|
1642
|
+
disabled: { type: Boolean, default: false }
|
|
1643
|
+
};
|
|
1644
|
+
const BASE_WEEK_NAME = [
|
|
1645
|
+
{ day: "日", isCurrentMonth: true },
|
|
1646
|
+
{ day: "壹", isCurrentMonth: true },
|
|
1647
|
+
{ day: "贰", isCurrentMonth: true },
|
|
1648
|
+
{ day: "叁", isCurrentMonth: true },
|
|
1649
|
+
{ day: "肆", isCurrentMonth: true },
|
|
1650
|
+
{ day: "伍", isCurrentMonth: true },
|
|
1651
|
+
{ day: "陆", isCurrentMonth: true }
|
|
1652
|
+
];
|
|
1653
|
+
const BASE_MONTH_NAME = [
|
|
1654
|
+
"1月",
|
|
1655
|
+
"2月",
|
|
1656
|
+
"3月",
|
|
1657
|
+
"4月",
|
|
1658
|
+
"5月",
|
|
1659
|
+
"6月",
|
|
1660
|
+
"7月",
|
|
1661
|
+
"8月",
|
|
1662
|
+
"9月",
|
|
1663
|
+
"10月",
|
|
1664
|
+
"11月",
|
|
1665
|
+
"12月"
|
|
1666
|
+
];
|
|
1667
|
+
const toDayjs = (value) => {
|
|
1668
|
+
return dayjs(value);
|
|
1669
|
+
};
|
|
1670
|
+
const isEmpty = (value) => {
|
|
1671
|
+
return value === "" || value === null || value === void 0;
|
|
1672
|
+
};
|
|
1673
|
+
const generateTimeColumn = (max, step) => {
|
|
1674
|
+
const result = [];
|
|
1675
|
+
for (let i = 0; i < max; i += step) {
|
|
1676
|
+
result.push(i);
|
|
1677
|
+
}
|
|
1678
|
+
return result;
|
|
1679
|
+
};
|
|
1680
|
+
function useDatePicker(props2) {
|
|
1681
|
+
const today = dayjs();
|
|
1682
|
+
const dateRef = ref({
|
|
1683
|
+
year: today.year(),
|
|
1684
|
+
month: today.month() + 1,
|
|
1685
|
+
day: today.date()
|
|
1686
|
+
});
|
|
1687
|
+
const displayValue = ref("");
|
|
1688
|
+
const spanClass = ref([]);
|
|
1689
|
+
const currentRef = ref(toDayjs(props2.modelValue));
|
|
1690
|
+
const calendarTypeRef = ref(
|
|
1691
|
+
props2.type === "datetime" ? "date" : props2.type ?? "date"
|
|
1692
|
+
);
|
|
1693
|
+
const yearsRef = ref([]);
|
|
1694
|
+
let needPlaceholder = false;
|
|
1695
|
+
const format = computed(() => {
|
|
1696
|
+
if (props2.format) return props2.format;
|
|
1697
|
+
switch (props2.type) {
|
|
1698
|
+
case "month":
|
|
1699
|
+
return "YYYY-MM";
|
|
1700
|
+
case "datetime":
|
|
1701
|
+
return "YYYY-MM-DD HH:mm:ss";
|
|
1702
|
+
case "date":
|
|
1703
|
+
default:
|
|
1704
|
+
return "YYYY-MM-DD";
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
const timeRef = ref({ hours: 0, minutes: 0, seconds: 0 });
|
|
1708
|
+
const updateDateRef = (value) => {
|
|
1709
|
+
if (isEmpty(value)) {
|
|
1710
|
+
displayValue.value = props2.placeholder ?? "请选择日期...";
|
|
1711
|
+
needPlaceholder = true;
|
|
1712
|
+
} else {
|
|
1713
|
+
needPlaceholder = false;
|
|
1714
|
+
const dayjsValue = dayjs(value);
|
|
1715
|
+
if (dayjsValue.isValid()) {
|
|
1716
|
+
displayValue.value = dayjsValue.format(format.value).toString();
|
|
1717
|
+
dateRef.value = {
|
|
1718
|
+
year: dayjsValue.year(),
|
|
1719
|
+
month: dayjsValue.month() + 1,
|
|
1720
|
+
day: dayjsValue.date()
|
|
1721
|
+
};
|
|
1722
|
+
if (props2.type === "datetime") {
|
|
1723
|
+
timeRef.value = {
|
|
1724
|
+
hours: dayjsValue.hour(),
|
|
1725
|
+
minutes: dayjsValue.minute(),
|
|
1726
|
+
seconds: dayjsValue.second()
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
spanClass.value = [
|
|
1732
|
+
"m-date-picker-span",
|
|
1733
|
+
needPlaceholder ? "m-date-picker-placeholder" : void 0
|
|
1734
|
+
];
|
|
1735
|
+
};
|
|
1736
|
+
updateDateRef(props2.modelValue);
|
|
1737
|
+
const getCalendar = (MDateRefValue) => {
|
|
1738
|
+
const dr = MDateRefValue.value;
|
|
1739
|
+
const monthDayjs = dayjs().set("year", dr.year).set("month", dr.month - 1);
|
|
1740
|
+
const dateDayjs = monthDayjs.set("date", dr.day);
|
|
1741
|
+
const firstDayWeek = dateDayjs.startOf("month");
|
|
1742
|
+
const firstDayWeekDay = firstDayWeek.day();
|
|
1743
|
+
const prevDaysYear = dr.month === 1 ? dr.year - 1 : dr.year;
|
|
1744
|
+
const lastMonthDayjs = dateDayjs.subtract(1, "month");
|
|
1745
|
+
const lastMonth = lastMonthDayjs.month() + 1;
|
|
1746
|
+
const prevDays = Array.from({ length: firstDayWeekDay }, (_, i) => {
|
|
1747
|
+
const day = firstDayWeek.subtract(firstDayWeekDay - i, "day").date();
|
|
1748
|
+
return { day, isCurrentMonth: false, month: lastMonth, year: prevDaysYear };
|
|
1749
|
+
});
|
|
1750
|
+
const isCurrent = (dayNum) => {
|
|
1751
|
+
if (dr.year !== currentRef.value.year()) return false;
|
|
1752
|
+
if (dr.month !== currentRef.value.month() + 1) return false;
|
|
1753
|
+
return dayNum === currentRef.value.date();
|
|
1754
|
+
};
|
|
1755
|
+
const currentDays = Array.from({ length: monthDayjs.daysInMonth() }, (_, i) => ({
|
|
1756
|
+
day: i + 1,
|
|
1757
|
+
isCurrentMonth: true,
|
|
1758
|
+
isCurrent: isCurrent(i + 1),
|
|
1759
|
+
month: dr.month,
|
|
1760
|
+
year: dr.year
|
|
1761
|
+
}));
|
|
1762
|
+
const nextDaysYear = dr.month === 12 ? dr.year + 1 : dr.year;
|
|
1763
|
+
const lastDayOfMonth = dayjs(`${dr.year}-${dr.month}`).daysInMonth();
|
|
1764
|
+
const lastDayWeekDay = dayjs(`${dr.year}-${dr.month}-${lastDayOfMonth}`).day();
|
|
1765
|
+
const nextDays = Array.from({ length: 6 - lastDayWeekDay }, (_, i) => ({
|
|
1766
|
+
day: i + 1,
|
|
1767
|
+
isCurrentMonth: false,
|
|
1768
|
+
month: dr.month === 12 ? 1 : dr.month + 1,
|
|
1769
|
+
year: nextDaysYear
|
|
1770
|
+
}));
|
|
1771
|
+
if (prevDays.length + currentDays.length + nextDays.length < 42) {
|
|
1772
|
+
if (firstDayWeekDay === 0) {
|
|
1773
|
+
const lastMonthDays = lastMonthDayjs.daysInMonth();
|
|
1774
|
+
prevDays.unshift(...Array.from({ length: 7 }, (_, i) => ({
|
|
1775
|
+
day: lastMonthDays - 6 + i,
|
|
1776
|
+
isCurrentMonth: false,
|
|
1777
|
+
month: lastMonth,
|
|
1778
|
+
year: prevDaysYear
|
|
1779
|
+
})));
|
|
1780
|
+
} else {
|
|
1781
|
+
const nextMonth = dateDayjs.add(1, "month");
|
|
1782
|
+
const nextMonthFirstDayWeek = nextMonth.set("date", 1).day();
|
|
1783
|
+
const baseDay = nextMonthFirstDayWeek === 0 ? 0 : 6 - nextMonthFirstDayWeek;
|
|
1784
|
+
nextDays.push(...Array.from({ length: 7 }, (_, i) => ({
|
|
1785
|
+
day: i + baseDay + 1,
|
|
1786
|
+
isCurrentMonth: false,
|
|
1787
|
+
month: dr.month === 12 ? 1 : dr.month + 1,
|
|
1788
|
+
year: nextDaysYear
|
|
1789
|
+
})));
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
const allDays = [...prevDays, ...currentDays, ...nextDays];
|
|
1793
|
+
const result = [];
|
|
1794
|
+
for (let i = 0; i < allDays.length; i += 7) {
|
|
1795
|
+
result.push(allDays.slice(i, i + 7));
|
|
1796
|
+
}
|
|
1797
|
+
return result;
|
|
1798
|
+
};
|
|
1799
|
+
const toPrevMonth = () => {
|
|
1800
|
+
if (!dateRef.value) return;
|
|
1801
|
+
dateRef.value.month -= 1;
|
|
1802
|
+
if (dateRef.value.month === 0) {
|
|
1803
|
+
dateRef.value.month = 12;
|
|
1804
|
+
dateRef.value.year -= 1;
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
const toNextMonth = () => {
|
|
1808
|
+
if (!dateRef.value) return;
|
|
1809
|
+
dateRef.value.month += 1;
|
|
1810
|
+
if (dateRef.value.month === 13) {
|
|
1811
|
+
dateRef.value.month = 1;
|
|
1812
|
+
dateRef.value.year += 1;
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
const toNextYear = () => {
|
|
1816
|
+
if (!dateRef.value) return;
|
|
1817
|
+
dateRef.value.year += 1;
|
|
1818
|
+
if (calendarTypeRef.value === "year") {
|
|
1819
|
+
if (!yearsRef.value.includes(dateRef.value.year)) {
|
|
1820
|
+
const startYear = dateRef.value.year;
|
|
1821
|
+
yearsRef.value = Array.from({ length: 12 }, (_, i) => startYear + i);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
const toPrevYear = () => {
|
|
1826
|
+
if (!dateRef.value) return;
|
|
1827
|
+
dateRef.value.year -= 1;
|
|
1828
|
+
if (calendarTypeRef.value === "year") {
|
|
1829
|
+
if (!yearsRef.value.includes(dateRef.value.year)) {
|
|
1830
|
+
const startYear = dateRef.value.year - 11;
|
|
1831
|
+
yearsRef.value = Array.from({ length: 12 }, (_, i) => startYear + i);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
const getValue = (item) => {
|
|
1836
|
+
let d = dayjs().set("year", item.year).set("month", item.month - 1).set("date", Number(item.day));
|
|
1837
|
+
if (props2.type === "datetime") {
|
|
1838
|
+
d = d.set("hour", timeRef.value.hours).set("minute", timeRef.value.minutes).set("second", timeRef.value.seconds);
|
|
1839
|
+
}
|
|
1840
|
+
return d.format(format.value);
|
|
1841
|
+
};
|
|
1842
|
+
const getDateTimeValue = () => {
|
|
1843
|
+
return dayjs().set("year", dateRef.value.year).set("month", dateRef.value.month - 1).set("date", dateRef.value.day).set("hour", timeRef.value.hours).set("minute", timeRef.value.minutes).set("second", timeRef.value.seconds).format(format.value);
|
|
1844
|
+
};
|
|
1845
|
+
const selectHour = (hour) => {
|
|
1846
|
+
timeRef.value = { ...timeRef.value, hours: hour };
|
|
1847
|
+
};
|
|
1848
|
+
const selectMinute = (minute) => {
|
|
1849
|
+
timeRef.value = { ...timeRef.value, minutes: minute };
|
|
1850
|
+
};
|
|
1851
|
+
const selectSecond = (second) => {
|
|
1852
|
+
timeRef.value = { ...timeRef.value, seconds: second };
|
|
1853
|
+
};
|
|
1854
|
+
const clickCurrentYear = (year) => {
|
|
1855
|
+
calendarTypeRef.value = "year";
|
|
1856
|
+
const startYear = year - 6;
|
|
1857
|
+
const endYear = year + 5;
|
|
1858
|
+
yearsRef.value = Array.from({ length: endYear - startYear + 1 }, (_, i) => startYear + i);
|
|
1859
|
+
};
|
|
1860
|
+
const clickYearItem = (year) => {
|
|
1861
|
+
if (!dateRef.value) return;
|
|
1862
|
+
dateRef.value.year = year;
|
|
1863
|
+
if (props2.type === "date" || props2.type === "datetime") calendarTypeRef.value = "date";
|
|
1864
|
+
else if (props2.type === "month") calendarTypeRef.value = "month";
|
|
1865
|
+
};
|
|
1866
|
+
const clickCurrentMonth = (_month) => {
|
|
1867
|
+
calendarTypeRef.value = "month";
|
|
1868
|
+
};
|
|
1869
|
+
const clickMonthItem = (month) => {
|
|
1870
|
+
dateRef.value.month = month;
|
|
1871
|
+
if (props2.type === "date" || props2.type === "datetime") calendarTypeRef.value = "date";
|
|
1872
|
+
};
|
|
1873
|
+
return {
|
|
1874
|
+
// 状态
|
|
1875
|
+
dateRef,
|
|
1876
|
+
displayValue,
|
|
1877
|
+
spanClass,
|
|
1878
|
+
currentRef,
|
|
1879
|
+
calendarTypeRef,
|
|
1880
|
+
yearsRef,
|
|
1881
|
+
// datetime 时间状态
|
|
1882
|
+
timeRef,
|
|
1883
|
+
// 方法
|
|
1884
|
+
updateDateRef,
|
|
1885
|
+
getCalendar,
|
|
1886
|
+
toPrevMonth,
|
|
1887
|
+
toNextMonth,
|
|
1888
|
+
toPrevYear,
|
|
1889
|
+
toNextYear,
|
|
1890
|
+
getValue,
|
|
1891
|
+
getDateTimeValue,
|
|
1892
|
+
clickCurrentYear,
|
|
1893
|
+
clickYearItem,
|
|
1894
|
+
clickCurrentMonth,
|
|
1895
|
+
clickMonthItem,
|
|
1896
|
+
// datetime 时间选择方法
|
|
1897
|
+
selectHour,
|
|
1898
|
+
selectMinute,
|
|
1899
|
+
selectSecond,
|
|
1900
|
+
// 工具
|
|
1901
|
+
toDayjs
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
const DatePickerCore = {
|
|
1905
|
+
props: props$p,
|
|
1906
|
+
useDatePicker
|
|
1907
|
+
};
|
|
1908
|
+
const DEFAULT_CONFIG = {
|
|
1909
|
+
key: "key",
|
|
1910
|
+
label: "label",
|
|
1911
|
+
value: "value",
|
|
1912
|
+
children: "children",
|
|
1913
|
+
expand: "expand"
|
|
1914
|
+
};
|
|
1915
|
+
const mergeConfig = (config) => {
|
|
1916
|
+
if (config === DEFAULT_CONFIG) {
|
|
1917
|
+
return DEFAULT_CONFIG;
|
|
1918
|
+
}
|
|
1919
|
+
return {
|
|
1920
|
+
key: config.key ?? DEFAULT_CONFIG.key,
|
|
1921
|
+
label: config.label ?? DEFAULT_CONFIG.label,
|
|
1922
|
+
value: config.value ?? DEFAULT_CONFIG.value,
|
|
1923
|
+
children: config.children ?? DEFAULT_CONFIG.children,
|
|
1924
|
+
expand: config.expand ?? DEFAULT_CONFIG.expand
|
|
1925
|
+
};
|
|
1926
|
+
};
|
|
1927
|
+
class Tree {
|
|
1928
|
+
constructor(options) {
|
|
1929
|
+
__privateAdd(this, _Tree_instances);
|
|
1930
|
+
/** 源数据(已深拷贝) */
|
|
1931
|
+
__privateAdd(this, _source);
|
|
1932
|
+
/** 节点缓存 Map,key 为节点标识 */
|
|
1933
|
+
__privateAdd(this, _cacheMap);
|
|
1934
|
+
/** 字段映射配置 */
|
|
1935
|
+
__privateAdd(this, _config, DEFAULT_CONFIG);
|
|
1936
|
+
/** 初始化配置(defaultExpandAll / checkStrictly) */
|
|
1937
|
+
__privateAdd(this, _initialConfig);
|
|
1938
|
+
const {
|
|
1939
|
+
data,
|
|
1940
|
+
config = DEFAULT_CONFIG,
|
|
1941
|
+
defaultExpandAll = false,
|
|
1942
|
+
checkStrictly = true
|
|
1943
|
+
} = options;
|
|
1944
|
+
__privateSet(this, _cacheMap, /* @__PURE__ */ new Map());
|
|
1945
|
+
__privateSet(this, _source, Array.isArray(data) ? data : [data]);
|
|
1946
|
+
__privateSet(this, _config, mergeConfig(config));
|
|
1947
|
+
__privateSet(this, _initialConfig, { defaultExpandAll, checkStrictly });
|
|
1948
|
+
__privateMethod(this, _Tree_instances, init_fn).call(this);
|
|
1949
|
+
}
|
|
1950
|
+
/** 暴露配置,供组件层读取 */
|
|
1951
|
+
get config() {
|
|
1952
|
+
return __privateGet(this, _config);
|
|
1953
|
+
}
|
|
1954
|
+
// ==================== 公开方法 ====================
|
|
1955
|
+
/** 获取某节点的直接子节点 key 列表 */
|
|
1956
|
+
getChildrenKeys(node) {
|
|
1957
|
+
const { children: c, key: k } = __privateGet(this, _config);
|
|
1958
|
+
const children = node[c];
|
|
1959
|
+
if (children) {
|
|
1960
|
+
return children.map((it) => it[k]);
|
|
1961
|
+
}
|
|
1962
|
+
return [];
|
|
1963
|
+
}
|
|
1964
|
+
/** 根据 key 数组批量获取节点 */
|
|
1965
|
+
getNodesByKeys(keys) {
|
|
1966
|
+
return keys.map((key) => __privateGet(this, _cacheMap).get(key));
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* 获取树形数据
|
|
1970
|
+
* @param keys 若传入则返回对应 key 的节点列表,否则返回所有根节点
|
|
1971
|
+
*/
|
|
1972
|
+
getTreeData(keys) {
|
|
1973
|
+
if (keys) {
|
|
1974
|
+
return this.getNodesByKeys(keys);
|
|
1975
|
+
}
|
|
1976
|
+
return __privateMethod(this, _Tree_instances, getCacheList_fn).call(this).filter((it) => it.isRoot);
|
|
1977
|
+
}
|
|
1978
|
+
/** 获取当前所有选中 key 和展开 key */
|
|
1979
|
+
getKeys() {
|
|
1980
|
+
const expandKeys = [];
|
|
1981
|
+
const checkedKeys = [];
|
|
1982
|
+
const iterator = __privateGet(this, _cacheMap)[Symbol.iterator]();
|
|
1983
|
+
let next = iterator.next();
|
|
1984
|
+
while (!next.done) {
|
|
1985
|
+
const [, node] = next.value;
|
|
1986
|
+
const key = Reflect.get(node, __privateGet(this, _config).key);
|
|
1987
|
+
if (node.checked && !node.indeterminate) {
|
|
1988
|
+
checkedKeys.push(key);
|
|
1989
|
+
}
|
|
1990
|
+
if (node.children && node.expand) {
|
|
1991
|
+
expandKeys.push(key);
|
|
1992
|
+
}
|
|
1993
|
+
next = iterator.next();
|
|
1994
|
+
}
|
|
1995
|
+
return { checkedKeys, expandKeys };
|
|
1996
|
+
}
|
|
1997
|
+
/** 切换节点展开/收起状态 */
|
|
1998
|
+
toggleExpand(node, value) {
|
|
1999
|
+
if (value !== void 0) {
|
|
2000
|
+
node.expand = value;
|
|
2001
|
+
} else {
|
|
2002
|
+
node.expand = !node.expand;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* 设置节点 checkbox 选中状态
|
|
2007
|
+
* checkStrictly=true(默认)时级联更新子节点和父节点状态
|
|
2008
|
+
*/
|
|
2009
|
+
setNodeCheckbox(node, checked) {
|
|
2010
|
+
node.checked = checked;
|
|
2011
|
+
node.indeterminate = false;
|
|
2012
|
+
const { checkStrictly } = __privateGet(this, _initialConfig);
|
|
2013
|
+
if (!checkStrictly) {
|
|
2014
|
+
return;
|
|
2015
|
+
}
|
|
2016
|
+
if (node.children) {
|
|
2017
|
+
__privateMethod(this, _Tree_instances, setChildrenStatus_fn).call(this, "checked", node.children, checked);
|
|
2018
|
+
}
|
|
2019
|
+
if (node.parent) {
|
|
2020
|
+
__privateMethod(this, _Tree_instances, setParentChecked_fn).call(this, node.parent);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
/** 根据 key 数组批量设置节点为选中状态 */
|
|
2024
|
+
setCheckedByKeys(keys) {
|
|
2025
|
+
const nodes = this.getNodesByKeys(keys);
|
|
2026
|
+
nodes.forEach((node) => {
|
|
2027
|
+
if (node) {
|
|
2028
|
+
this.setNodeCheckbox(node, true);
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
_source = new WeakMap();
|
|
2034
|
+
_cacheMap = new WeakMap();
|
|
2035
|
+
_config = new WeakMap();
|
|
2036
|
+
_initialConfig = new WeakMap();
|
|
2037
|
+
_Tree_instances = new WeakSet();
|
|
2038
|
+
/** 递归生成单个 TreeNodeData,并写入 cacheMap */
|
|
2039
|
+
genTreeNodeData_fn = function(data, parentKey) {
|
|
2040
|
+
const { defaultExpandAll } = __privateGet(this, _initialConfig);
|
|
2041
|
+
const { key: k, children: c, expand: e } = __privateGet(this, _config);
|
|
2042
|
+
const node = {
|
|
2043
|
+
...data,
|
|
2044
|
+
expand: defaultExpandAll || !!data[e],
|
|
2045
|
+
selected: false,
|
|
2046
|
+
checked: false,
|
|
2047
|
+
indeterminate: false,
|
|
2048
|
+
parent: parentKey ? __privateGet(this, _cacheMap).get(parentKey) : void 0,
|
|
2049
|
+
isRoot: !parentKey
|
|
2050
|
+
};
|
|
2051
|
+
__privateGet(this, _cacheMap).set(node[k], node);
|
|
2052
|
+
const nodeChildren = node[c];
|
|
2053
|
+
if (nodeChildren && nodeChildren.length > 0) {
|
|
2054
|
+
node[c] = __privateMethod(this, _Tree_instances, genCacheMap_fn).call(this, nodeChildren, node[k]);
|
|
2055
|
+
}
|
|
2056
|
+
return node;
|
|
2057
|
+
};
|
|
2058
|
+
/** 清空缓存 */
|
|
2059
|
+
clearCache_fn = function() {
|
|
2060
|
+
__privateGet(this, _cacheMap).clear();
|
|
2061
|
+
};
|
|
2062
|
+
/** 初始化:清空缓存后重新构建 */
|
|
2063
|
+
init_fn = function() {
|
|
2064
|
+
__privateMethod(this, _Tree_instances, clearCache_fn).call(this);
|
|
2065
|
+
__privateMethod(this, _Tree_instances, genCacheMap_fn).call(this);
|
|
2066
|
+
};
|
|
2067
|
+
/** 递归批量构建节点并填充 cacheMap */
|
|
2068
|
+
genCacheMap_fn = function(data = __privateGet(this, _source), parentKey) {
|
|
2069
|
+
const len = data.length;
|
|
2070
|
+
const treeNodeData = [];
|
|
2071
|
+
for (let i = 0; i < len; i++) {
|
|
2072
|
+
const treeNode = __privateMethod(this, _Tree_instances, genTreeNodeData_fn).call(this, data[i], parentKey);
|
|
2073
|
+
treeNodeData.push(treeNode);
|
|
2074
|
+
}
|
|
2075
|
+
return treeNodeData;
|
|
2076
|
+
};
|
|
2077
|
+
/** 获取所有缓存节点列表 */
|
|
2078
|
+
getCacheList_fn = function() {
|
|
2079
|
+
return Array.from(__privateGet(this, _cacheMap).values());
|
|
2080
|
+
};
|
|
2081
|
+
/**
|
|
2082
|
+
* 向上递归更新父节点的选中/半选状态
|
|
2083
|
+
* 规则:所有子节点选中 → 父节点选中;部分选中或有半选 → 父节点半选
|
|
2084
|
+
*/
|
|
2085
|
+
setParentChecked_fn = function(parent) {
|
|
2086
|
+
if (parent.disabled) {
|
|
2087
|
+
return;
|
|
2088
|
+
}
|
|
2089
|
+
const { children: c } = __privateGet(this, _config);
|
|
2090
|
+
const children = parent[c] ?? [];
|
|
2091
|
+
const allChecked = children.every((child) => child.checked);
|
|
2092
|
+
const oneChecked = children.some((child) => child.checked);
|
|
2093
|
+
const onIndeterminate = children.some((child) => child.indeterminate);
|
|
2094
|
+
if (allChecked) {
|
|
2095
|
+
parent.indeterminate = false;
|
|
2096
|
+
parent.checked = true;
|
|
2097
|
+
} else {
|
|
2098
|
+
parent.indeterminate = oneChecked || onIndeterminate;
|
|
2099
|
+
parent.checked = false;
|
|
2100
|
+
}
|
|
2101
|
+
if (parent.parent) {
|
|
2102
|
+
__privateMethod(this, _Tree_instances, setParentChecked_fn).call(this, parent.parent);
|
|
2103
|
+
}
|
|
2104
|
+
};
|
|
2105
|
+
/** 递归设置子节点的某个状态字段 */
|
|
2106
|
+
setChildrenStatus_fn = function(statusKey, nodes, value) {
|
|
2107
|
+
const { children: c } = __privateGet(this, _config);
|
|
2108
|
+
nodes.forEach((node) => {
|
|
2109
|
+
if (node.disabled) {
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
node[statusKey] = value;
|
|
2113
|
+
const nodeChildren = node[c];
|
|
2114
|
+
if (nodeChildren) {
|
|
2115
|
+
__privateMethod(this, _Tree_instances, setChildrenStatus_fn).call(this, statusKey, nodeChildren, value);
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
};
|
|
2119
|
+
const DEFAULT_TREE_CONFIG = DEFAULT_CONFIG;
|
|
2120
|
+
const props$o = {
|
|
2121
|
+
data: { type: [Object, Array], default: () => [] },
|
|
2122
|
+
config: { type: Object, default: () => DEFAULT_CONFIG },
|
|
2123
|
+
checkbox: { type: Boolean, default: false },
|
|
2124
|
+
defaultExpandAll: { type: Boolean, default: false },
|
|
2125
|
+
checkedKeys: { type: Array, default: () => [] },
|
|
2126
|
+
checkStrictly: { type: Boolean, default: true }
|
|
2127
|
+
};
|
|
2128
|
+
const treeNodeProps = {
|
|
2129
|
+
data: { type: Array, default: () => [] },
|
|
2130
|
+
config: { type: Object, default: () => DEFAULT_CONFIG },
|
|
2131
|
+
checkbox: { type: Boolean, default: false },
|
|
2132
|
+
getNodesByKeys: {
|
|
2133
|
+
type: Function,
|
|
2134
|
+
required: true
|
|
2135
|
+
},
|
|
2136
|
+
handleCheck: {
|
|
2137
|
+
type: Function,
|
|
2138
|
+
required: true
|
|
2139
|
+
},
|
|
2140
|
+
handleExpand: {
|
|
2141
|
+
type: Function,
|
|
2142
|
+
required: true
|
|
2143
|
+
},
|
|
2144
|
+
handleItemClick: {
|
|
2145
|
+
type: Function,
|
|
2146
|
+
required: true
|
|
2147
|
+
}
|
|
2148
|
+
};
|
|
2149
|
+
const _fixKey = (data, key = "key", prefixKey) => {
|
|
2150
|
+
let keyStart = 0;
|
|
2151
|
+
return data.map((d) => {
|
|
2152
|
+
if (!d[key]) {
|
|
2153
|
+
d[key] = `${prefixKey}${keyStart++}`;
|
|
2154
|
+
}
|
|
2155
|
+
if (d.children) {
|
|
2156
|
+
d.children = _fixKey(d.children, key, d[key]);
|
|
2157
|
+
}
|
|
2158
|
+
return d;
|
|
2159
|
+
});
|
|
2160
|
+
};
|
|
2161
|
+
const fixKey = (data, key, prefixKey = "") => {
|
|
2162
|
+
return Array.isArray(data) ? _fixKey(data, key ?? "key", prefixKey) : _fixKey([data], key ?? "key", prefixKey)[0];
|
|
2163
|
+
};
|
|
2164
|
+
const useTree = (options) => {
|
|
2165
|
+
const { props: props2, event: event2 } = options;
|
|
2166
|
+
const treeRef = shallowRef();
|
|
2167
|
+
const initTreeRef = (data = props2.data) => {
|
|
2168
|
+
var _a;
|
|
2169
|
+
const rawArr = Array.isArray(data) ? data : data ? [data] : [];
|
|
2170
|
+
const cloned = JSON.parse(JSON.stringify(rawArr));
|
|
2171
|
+
const keyField = ((_a = props2.config) == null ? void 0 : _a.key) ?? "key";
|
|
2172
|
+
const fixed = fixKey(cloned, keyField);
|
|
2173
|
+
treeRef.value = new Tree({
|
|
2174
|
+
data: fixed,
|
|
2175
|
+
config: props2.config,
|
|
2176
|
+
defaultExpandAll: props2.defaultExpandAll,
|
|
2177
|
+
checkStrictly: props2.checkStrictly
|
|
2178
|
+
});
|
|
2179
|
+
};
|
|
2180
|
+
initTreeRef();
|
|
2181
|
+
const handleToggleExpand = (node, e) => {
|
|
2182
|
+
var _a;
|
|
2183
|
+
e.stopPropagation();
|
|
2184
|
+
(_a = treeRef.value) == null ? void 0 : _a.toggleExpand(node);
|
|
2185
|
+
event2.triggerTree();
|
|
2186
|
+
};
|
|
2187
|
+
const handleToggleChecked = (node, checked) => {
|
|
2188
|
+
var _a;
|
|
2189
|
+
(_a = treeRef.value) == null ? void 0 : _a.setNodeCheckbox(node, checked);
|
|
2190
|
+
event2.triggerTree();
|
|
2191
|
+
};
|
|
2192
|
+
const getNodesByKeys = (keys) => {
|
|
2193
|
+
return treeRef.value.getTreeData(keys);
|
|
2194
|
+
};
|
|
2195
|
+
return {
|
|
2196
|
+
treeRef,
|
|
2197
|
+
getNodesByKeys,
|
|
2198
|
+
handleToggleExpand,
|
|
2199
|
+
handleToggleChecked,
|
|
2200
|
+
initTreeRef
|
|
2201
|
+
};
|
|
2202
|
+
};
|
|
2203
|
+
const TreeCore = {
|
|
2204
|
+
props: props$o,
|
|
2205
|
+
treeNodeProps,
|
|
2206
|
+
useTree
|
|
2207
|
+
};
|
|
2208
|
+
const props$n = {
|
|
2209
|
+
data: { type: Array, default: () => [] },
|
|
2210
|
+
height: { type: String, default: null },
|
|
2211
|
+
paramClass: { type: Boolean, default: false },
|
|
2212
|
+
loading: { type: Boolean, default: false }
|
|
2213
|
+
};
|
|
2214
|
+
function useTable() {
|
|
2215
|
+
const error = (msg) => console.warn(`[水墨UI表格组件] ${msg}`);
|
|
2216
|
+
const initTable = (renders, columns, data) => {
|
|
2217
|
+
const tbodyTrList = [];
|
|
2218
|
+
data.forEach(() => {
|
|
2219
|
+
tbodyTrList.push([]);
|
|
2220
|
+
});
|
|
2221
|
+
const getData = (i, param) => {
|
|
2222
|
+
if (data[i] && data[i][param]) {
|
|
2223
|
+
return data[i][param];
|
|
2224
|
+
}
|
|
2225
|
+
return "";
|
|
2226
|
+
};
|
|
2227
|
+
const pushTd = (param, bodySlot, style) => {
|
|
2228
|
+
if (param) {
|
|
2229
|
+
tbodyTrList.forEach((t, i) => {
|
|
2230
|
+
t.push(renders.tbodyTr({
|
|
2231
|
+
data: getData(i, param),
|
|
2232
|
+
style,
|
|
2233
|
+
param,
|
|
2234
|
+
slot: bodySlot,
|
|
2235
|
+
slotInfo: {
|
|
2236
|
+
data: data[i],
|
|
2237
|
+
index: i
|
|
2238
|
+
}
|
|
2239
|
+
}));
|
|
2240
|
+
});
|
|
2241
|
+
} else {
|
|
2242
|
+
error("param is undefined, column without param will be ignored!");
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
const getStyle = (options) => {
|
|
2246
|
+
if (!options || !options.width) {
|
|
2247
|
+
return {};
|
|
2248
|
+
}
|
|
2249
|
+
const numberWidth = Number(options.width);
|
|
2250
|
+
if (!isNaN(numberWidth)) {
|
|
2251
|
+
return { width: numberWidth + "px" };
|
|
2252
|
+
}
|
|
2253
|
+
return { width: options.width };
|
|
2254
|
+
};
|
|
2255
|
+
const initTHead = () => {
|
|
2256
|
+
const ths = (columns ?? []).filter((column) => {
|
|
2257
|
+
if (!column.props) {
|
|
2258
|
+
error("column.props is undefined, column without param will be ignored!");
|
|
2259
|
+
return false;
|
|
2260
|
+
}
|
|
2261
|
+
return true;
|
|
2262
|
+
}).map((column) => {
|
|
2263
|
+
const slots = renders.initSlot(column);
|
|
2264
|
+
let bodySlot;
|
|
2265
|
+
let headSlot;
|
|
2266
|
+
const style = getStyle(column.props);
|
|
2267
|
+
if (slots) {
|
|
2268
|
+
bodySlot = slots.body;
|
|
2269
|
+
headSlot = slots.head;
|
|
2270
|
+
}
|
|
2271
|
+
pushTd(column.props.param, bodySlot, style);
|
|
2272
|
+
return renders.theadTh({
|
|
2273
|
+
label: column.props.label,
|
|
2274
|
+
param: column.props.param,
|
|
2275
|
+
slot: headSlot,
|
|
2276
|
+
style
|
|
2277
|
+
});
|
|
2278
|
+
});
|
|
2279
|
+
return renders.thead(ths);
|
|
2280
|
+
};
|
|
2281
|
+
const thead = initTHead();
|
|
2282
|
+
const tbody = tbodyTrList.length > 0 ? renders.tbody(tbodyTrList.map((tds, i) => renders.tbodyTrs(tds, i))) : renders.empty;
|
|
2283
|
+
return {
|
|
2284
|
+
thead,
|
|
2285
|
+
tbody
|
|
2286
|
+
};
|
|
2287
|
+
};
|
|
2288
|
+
return {
|
|
2289
|
+
initTable,
|
|
2290
|
+
error
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
const TableCore = {
|
|
2294
|
+
props: props$n,
|
|
2295
|
+
useTable
|
|
2296
|
+
};
|
|
2297
|
+
const props$m = {
|
|
2298
|
+
width: { type: String, default: "" },
|
|
2299
|
+
param: { type: String, default: "" },
|
|
2300
|
+
label: { type: String, default: "" }
|
|
2301
|
+
};
|
|
2302
|
+
const TableColumnCore = {
|
|
2303
|
+
props: props$m
|
|
2304
|
+
};
|
|
2305
|
+
const props$l = {
|
|
2306
|
+
top: { type: [Boolean, String], default: true },
|
|
2307
|
+
right: { type: [Boolean, String], default: true },
|
|
2308
|
+
bottom: { type: [Boolean, String], default: true },
|
|
2309
|
+
left: { type: [Boolean, String], default: true },
|
|
2310
|
+
insteadMain: { type: [Boolean, String], default: false }
|
|
2311
|
+
};
|
|
2312
|
+
const BorderCore = {
|
|
2313
|
+
props: props$l
|
|
2314
|
+
};
|
|
2315
|
+
const props$k = {
|
|
2316
|
+
list: { type: Array, default: () => [] },
|
|
2317
|
+
estimatedHeight: { type: Number, default: 40 },
|
|
2318
|
+
overScan: { type: Number, default: 1 }
|
|
2319
|
+
};
|
|
2320
|
+
function createHeightCache(total, estimatedHeight) {
|
|
2321
|
+
const heights = new Array(total).fill(null);
|
|
2322
|
+
const getHeight = (index) => {
|
|
2323
|
+
return heights[index] ?? estimatedHeight;
|
|
2324
|
+
};
|
|
2325
|
+
const update = (index, height) => {
|
|
2326
|
+
if (index >= 0 && index < heights.length) {
|
|
2327
|
+
heights[index] = height;
|
|
2328
|
+
}
|
|
2329
|
+
};
|
|
2330
|
+
const getOffset = (index) => {
|
|
2331
|
+
let offset = 0;
|
|
2332
|
+
const end = Math.min(index, heights.length);
|
|
2333
|
+
for (let i = 0; i < end; i++) {
|
|
2334
|
+
offset += getHeight(i);
|
|
2335
|
+
}
|
|
2336
|
+
return offset;
|
|
2337
|
+
};
|
|
2338
|
+
const getTotalHeight = () => {
|
|
2339
|
+
return getOffset(heights.length);
|
|
2340
|
+
};
|
|
2341
|
+
const findIndex = (scrollTop) => {
|
|
2342
|
+
let low = 0;
|
|
2343
|
+
let high = heights.length - 1;
|
|
2344
|
+
while (low <= high) {
|
|
2345
|
+
const mid = low + high >>> 1;
|
|
2346
|
+
const offset = getOffset(mid);
|
|
2347
|
+
const offsetEnd = offset + getHeight(mid);
|
|
2348
|
+
if (offsetEnd <= scrollTop) {
|
|
2349
|
+
low = mid + 1;
|
|
2350
|
+
} else if (offset > scrollTop) {
|
|
2351
|
+
high = mid - 1;
|
|
2352
|
+
} else {
|
|
2353
|
+
return mid;
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
return Math.min(low, heights.length - 1);
|
|
2357
|
+
};
|
|
2358
|
+
const reset = (newTotal) => {
|
|
2359
|
+
heights.length = newTotal;
|
|
2360
|
+
heights.fill(null);
|
|
2361
|
+
};
|
|
2362
|
+
return { update, getHeight, getOffset, getTotalHeight, findIndex, reset };
|
|
2363
|
+
}
|
|
2364
|
+
function useSentinelObserver(options) {
|
|
2365
|
+
let ob;
|
|
2366
|
+
const cleanup = () => {
|
|
2367
|
+
if (ob) {
|
|
2368
|
+
ob.disconnect();
|
|
2369
|
+
ob = void 0;
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
const initObserver = () => {
|
|
2373
|
+
const container = options.containerRef.value;
|
|
2374
|
+
if (!container) return;
|
|
2375
|
+
cleanup();
|
|
2376
|
+
ob = new IntersectionObserver(
|
|
2377
|
+
(entries) => {
|
|
2378
|
+
var _a;
|
|
2379
|
+
for (const entry of entries) {
|
|
2380
|
+
if (!entry.isIntersecting) continue;
|
|
2381
|
+
if (entry.target === options.bottomSentinelRef.value) {
|
|
2382
|
+
options.onUpdate();
|
|
2383
|
+
(_a = options.onReachBottom) == null ? void 0 : _a.call(options);
|
|
2384
|
+
} else if (entry.target === options.topSentinelRef.value) {
|
|
2385
|
+
options.onUpdate();
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
},
|
|
2389
|
+
{
|
|
2390
|
+
root: container,
|
|
2391
|
+
threshold: 0
|
|
2392
|
+
}
|
|
2393
|
+
);
|
|
2394
|
+
if (options.topSentinelRef.value) {
|
|
2395
|
+
ob.observe(options.topSentinelRef.value);
|
|
2396
|
+
}
|
|
2397
|
+
if (options.bottomSentinelRef.value) {
|
|
2398
|
+
ob.observe(options.bottomSentinelRef.value);
|
|
2399
|
+
}
|
|
2400
|
+
};
|
|
2401
|
+
const reobserve = () => {
|
|
2402
|
+
initObserver();
|
|
2403
|
+
};
|
|
2404
|
+
watch(options.containerRef, () => {
|
|
2405
|
+
if (options.containerRef.value) {
|
|
2406
|
+
initObserver();
|
|
2407
|
+
}
|
|
2408
|
+
});
|
|
2409
|
+
onBeforeUnmount(cleanup);
|
|
2410
|
+
return { reobserve, cleanup };
|
|
2411
|
+
}
|
|
2412
|
+
function useVirtualList(options) {
|
|
2413
|
+
const { props: props2, onReachBottom } = options;
|
|
2414
|
+
const containerRef = ref(null);
|
|
2415
|
+
const wrapperRef = ref(null);
|
|
2416
|
+
const topSentinelRef = ref(null);
|
|
2417
|
+
const bottomSentinelRef = ref(null);
|
|
2418
|
+
const listRef = toRef(() => props2.list ?? []);
|
|
2419
|
+
const estimatedHeight = props2.estimatedHeight ?? 40;
|
|
2420
|
+
const overScan = props2.overScan ?? 1;
|
|
2421
|
+
const heightCache = createHeightCache(listRef.value.length, estimatedHeight);
|
|
2422
|
+
const renderFrom = ref(0);
|
|
2423
|
+
const renderEnd = ref(0);
|
|
2424
|
+
const totalHeight = ref(0);
|
|
2425
|
+
const offsetY = ref(0);
|
|
2426
|
+
const calcRange = () => {
|
|
2427
|
+
const container = containerRef.value;
|
|
2428
|
+
if (!container) return;
|
|
2429
|
+
const list = listRef.value;
|
|
2430
|
+
const total = list.length;
|
|
2431
|
+
if (total === 0) {
|
|
2432
|
+
renderFrom.value = 0;
|
|
2433
|
+
renderEnd.value = 0;
|
|
2434
|
+
totalHeight.value = 0;
|
|
2435
|
+
offsetY.value = 0;
|
|
2436
|
+
return;
|
|
2437
|
+
}
|
|
2438
|
+
const scrollTop = container.scrollTop;
|
|
2439
|
+
const containerHeight = container.clientHeight;
|
|
2440
|
+
const startIndex = heightCache.findIndex(scrollTop);
|
|
2441
|
+
let visibleEnd = startIndex;
|
|
2442
|
+
let accHeight = 0;
|
|
2443
|
+
while (visibleEnd < total && accHeight < containerHeight) {
|
|
2444
|
+
accHeight += heightCache.getHeight(visibleEnd);
|
|
2445
|
+
visibleEnd++;
|
|
2446
|
+
}
|
|
2447
|
+
const visibleCount = visibleEnd - startIndex;
|
|
2448
|
+
const overScanCount = Math.max(1, Math.floor(visibleCount * overScan));
|
|
2449
|
+
const from = Math.max(0, startIndex - overScanCount);
|
|
2450
|
+
const end = Math.min(total, visibleEnd + overScanCount);
|
|
2451
|
+
renderFrom.value = from;
|
|
2452
|
+
renderEnd.value = end;
|
|
2453
|
+
totalHeight.value = heightCache.getTotalHeight();
|
|
2454
|
+
offsetY.value = heightCache.getOffset(from);
|
|
2455
|
+
};
|
|
2456
|
+
const displayList = computed(() => {
|
|
2457
|
+
const list = listRef.value;
|
|
2458
|
+
return list.slice(renderFrom.value, renderEnd.value).map((d, i) => ({ data: d, index: i + renderFrom.value }));
|
|
2459
|
+
});
|
|
2460
|
+
const measureItems = () => {
|
|
2461
|
+
const wrapper = wrapperRef.value;
|
|
2462
|
+
const container = containerRef.value;
|
|
2463
|
+
if (!wrapper || !container) return;
|
|
2464
|
+
const scrollTop = container.scrollTop;
|
|
2465
|
+
const firstVisibleIndex = heightCache.findIndex(scrollTop);
|
|
2466
|
+
const oldOffset = heightCache.getOffset(firstVisibleIndex);
|
|
2467
|
+
const children = wrapper.children;
|
|
2468
|
+
let hasChange = false;
|
|
2469
|
+
for (let i = 1; i < children.length - 1; i++) {
|
|
2470
|
+
const child = children[i];
|
|
2471
|
+
const index = renderFrom.value + (i - 1);
|
|
2472
|
+
const height = child.getBoundingClientRect().height;
|
|
2473
|
+
if (height > 0) {
|
|
2474
|
+
const oldHeight = heightCache.getHeight(index);
|
|
2475
|
+
if (Math.abs(oldHeight - height) > 0.5) {
|
|
2476
|
+
heightCache.update(index, height);
|
|
2477
|
+
hasChange = true;
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
if (hasChange) {
|
|
2482
|
+
const newOffset = heightCache.getOffset(firstVisibleIndex);
|
|
2483
|
+
const delta = newOffset - oldOffset;
|
|
2484
|
+
if (Math.abs(delta) > 0.5) {
|
|
2485
|
+
container.scrollTop = scrollTop + delta;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
totalHeight.value = heightCache.getTotalHeight();
|
|
2489
|
+
};
|
|
2490
|
+
const update = () => {
|
|
2491
|
+
measureItems();
|
|
2492
|
+
calcRange();
|
|
2493
|
+
nextTick(() => {
|
|
2494
|
+
measureItems();
|
|
2495
|
+
});
|
|
2496
|
+
};
|
|
2497
|
+
const { reobserve } = useSentinelObserver({
|
|
2498
|
+
containerRef,
|
|
2499
|
+
topSentinelRef,
|
|
2500
|
+
bottomSentinelRef,
|
|
2501
|
+
onUpdate: update,
|
|
2502
|
+
onReachBottom
|
|
2503
|
+
});
|
|
2504
|
+
let rafId = null;
|
|
2505
|
+
let scrollHandler;
|
|
2506
|
+
let scrollendHandler;
|
|
2507
|
+
const setupScrollListener = () => {
|
|
2508
|
+
const container = containerRef.value;
|
|
2509
|
+
if (!container) return;
|
|
2510
|
+
scrollHandler = () => {
|
|
2511
|
+
if (rafId !== null) return;
|
|
2512
|
+
rafId = requestAnimationFrame(() => {
|
|
2513
|
+
rafId = null;
|
|
2514
|
+
calcRange();
|
|
2515
|
+
});
|
|
2516
|
+
};
|
|
2517
|
+
container.addEventListener("scroll", scrollHandler, { passive: true });
|
|
2518
|
+
scrollendHandler = () => {
|
|
2519
|
+
measureItems();
|
|
2520
|
+
calcRange();
|
|
2521
|
+
};
|
|
2522
|
+
container.addEventListener("scrollend", scrollendHandler);
|
|
2523
|
+
};
|
|
2524
|
+
const cleanupScrollListener = () => {
|
|
2525
|
+
const container = containerRef.value;
|
|
2526
|
+
if (container) {
|
|
2527
|
+
if (scrollHandler) container.removeEventListener("scroll", scrollHandler);
|
|
2528
|
+
if (scrollendHandler) container.removeEventListener("scrollend", scrollendHandler);
|
|
2529
|
+
}
|
|
2530
|
+
if (rafId !== null) {
|
|
2531
|
+
cancelAnimationFrame(rafId);
|
|
2532
|
+
rafId = null;
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
onMounted(() => {
|
|
2536
|
+
const list = listRef.value;
|
|
2537
|
+
heightCache.reset(list.length);
|
|
2538
|
+
calcRange();
|
|
2539
|
+
nextTick(() => {
|
|
2540
|
+
measureItems();
|
|
2541
|
+
calcRange();
|
|
2542
|
+
reobserve();
|
|
2543
|
+
setupScrollListener();
|
|
2544
|
+
});
|
|
2545
|
+
});
|
|
2546
|
+
watch(listRef, (newList) => {
|
|
2547
|
+
heightCache.reset(newList.length);
|
|
2548
|
+
if (containerRef.value) {
|
|
2549
|
+
containerRef.value.scrollTop = 0;
|
|
2550
|
+
}
|
|
2551
|
+
calcRange();
|
|
2552
|
+
nextTick(() => {
|
|
2553
|
+
measureItems();
|
|
2554
|
+
calcRange();
|
|
2555
|
+
reobserve();
|
|
2556
|
+
});
|
|
2557
|
+
});
|
|
2558
|
+
onBeforeUnmount(cleanupScrollListener);
|
|
2559
|
+
return {
|
|
2560
|
+
displayList,
|
|
2561
|
+
containerRef,
|
|
2562
|
+
wrapperRef,
|
|
2563
|
+
topSentinelRef,
|
|
2564
|
+
bottomSentinelRef,
|
|
2565
|
+
totalHeight,
|
|
2566
|
+
offsetY
|
|
2567
|
+
};
|
|
2568
|
+
}
|
|
2569
|
+
const VirtualListCore = {
|
|
2570
|
+
props: props$k,
|
|
2571
|
+
useVirtualList
|
|
2572
|
+
};
|
|
2573
|
+
const props$j = {
|
|
2574
|
+
placement: {
|
|
2575
|
+
type: String,
|
|
2576
|
+
default: "bottom"
|
|
2577
|
+
// validator: (value: string) =>
|
|
2578
|
+
// [
|
|
2579
|
+
// 'auto',
|
|
2580
|
+
// 'auto-start',
|
|
2581
|
+
// 'auto-end',
|
|
2582
|
+
// 'top',
|
|
2583
|
+
// 'top-start',
|
|
2584
|
+
// 'top-end',
|
|
2585
|
+
// 'bottom',
|
|
2586
|
+
// 'bottom-start',
|
|
2587
|
+
// 'bottom-end',
|
|
2588
|
+
// 'right',
|
|
2589
|
+
// 'right-start',
|
|
2590
|
+
// 'right-end',
|
|
2591
|
+
// 'left',
|
|
2592
|
+
// 'left-start',
|
|
2593
|
+
// 'left-end'
|
|
2594
|
+
// ].includes(value)
|
|
2595
|
+
},
|
|
2596
|
+
mountRender: { type: Boolean, default: false },
|
|
2597
|
+
disableClickAway: { type: Boolean, default: false },
|
|
2598
|
+
// offsetSkid: { type: String, default: '0' },
|
|
2599
|
+
// offsetDistance: { type: String, default: '0' },
|
|
2600
|
+
hover: { type: Boolean, default: false },
|
|
2601
|
+
show: { type: Boolean, default: null },
|
|
2602
|
+
// disabled: { type: Boolean, default: false },
|
|
2603
|
+
// openDelay: { type: Number, default: 0 },
|
|
2604
|
+
// closeDelay: { type: Number, default: 0 },
|
|
2605
|
+
// interactive: { type: Boolean, default: true },
|
|
2606
|
+
// locked: { type: Boolean, default: false },
|
|
2607
|
+
content: { type: String, default: "" },
|
|
2608
|
+
popper: {
|
|
2609
|
+
type: Object,
|
|
2610
|
+
default: () => ({})
|
|
2611
|
+
},
|
|
2612
|
+
teleport: { type: [Object, Boolean], default: void 0 },
|
|
2613
|
+
title: { type: String, default: void 0 }
|
|
2614
|
+
};
|
|
2615
|
+
class PopoverImpl2 {
|
|
2616
|
+
constructor(val, active, content, arrow2, config, lifecycle) {
|
|
2617
|
+
__publicField(this, "_active");
|
|
2618
|
+
__publicField(this, "_content");
|
|
2619
|
+
__publicField(this, "_arrow");
|
|
2620
|
+
__publicField(this, "popperInstance");
|
|
2621
|
+
__publicField(this, "style");
|
|
2622
|
+
__publicField(this, "arrowStyle");
|
|
2623
|
+
__publicField(this, "placement");
|
|
2624
|
+
__publicField(this, "visible", false);
|
|
2625
|
+
__publicField(this, "onShow");
|
|
2626
|
+
__publicField(this, "onHide");
|
|
2627
|
+
if (!content) {
|
|
2628
|
+
throw new Error("MPopover: content is required");
|
|
2629
|
+
}
|
|
2630
|
+
if (!active) {
|
|
2631
|
+
throw new Error("MPopover: active is required");
|
|
2632
|
+
}
|
|
2633
|
+
this._active = active;
|
|
2634
|
+
this._content = content;
|
|
2635
|
+
this._arrow = arrow2;
|
|
2636
|
+
this.popperInstance = usePopper(
|
|
2637
|
+
this._active,
|
|
2638
|
+
this._content,
|
|
2639
|
+
(positionStyle) => this.update(positionStyle),
|
|
2640
|
+
this._arrow,
|
|
2641
|
+
config
|
|
2642
|
+
);
|
|
2643
|
+
this.style = val.style;
|
|
2644
|
+
this.arrowStyle = val.arrowStyle;
|
|
2645
|
+
this.placement = val.placement;
|
|
2646
|
+
this.visible = val.show;
|
|
2647
|
+
this.onShow = lifecycle == null ? void 0 : lifecycle.onShow;
|
|
2648
|
+
this.onHide = lifecycle == null ? void 0 : lifecycle.onHide;
|
|
2649
|
+
}
|
|
2650
|
+
get content() {
|
|
2651
|
+
return this._content;
|
|
2652
|
+
}
|
|
2653
|
+
async show() {
|
|
2654
|
+
var _a;
|
|
2655
|
+
this.style.value = { display: "block", opacity: "0" };
|
|
2656
|
+
this.arrowStyle.value = { display: "block", opacity: "0" };
|
|
2657
|
+
this.visible = true;
|
|
2658
|
+
await this.popperInstance.getPositionStyle();
|
|
2659
|
+
(_a = this.onShow) == null ? void 0 : _a.call(this);
|
|
2660
|
+
}
|
|
2661
|
+
update(positionStyle) {
|
|
2662
|
+
if (!this.visible) {
|
|
2663
|
+
this.hide();
|
|
2664
|
+
return;
|
|
2665
|
+
}
|
|
2666
|
+
this.style.value = positionStyle.style;
|
|
2667
|
+
this.arrowStyle.value = positionStyle.arrowStyle;
|
|
2668
|
+
this.placement.value = positionStyle.placement;
|
|
2669
|
+
}
|
|
2670
|
+
hide() {
|
|
2671
|
+
var _a;
|
|
2672
|
+
this.style.value = void 0;
|
|
2673
|
+
this.arrowStyle.value = void 0;
|
|
2674
|
+
this.visible = false;
|
|
2675
|
+
(_a = this.onHide) == null ? void 0 : _a.call(this);
|
|
2676
|
+
}
|
|
2677
|
+
async toggle() {
|
|
2678
|
+
if (this.visible) {
|
|
2679
|
+
this.hide();
|
|
2680
|
+
} else {
|
|
2681
|
+
await this.show();
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
destroy() {
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
function usePopover(options, lifecycle) {
|
|
2688
|
+
const style = ref();
|
|
2689
|
+
const arrowStyle = ref();
|
|
2690
|
+
const placement = ref(options.value.placement);
|
|
2691
|
+
let instance = null;
|
|
2692
|
+
let clickAwayInstance;
|
|
2693
|
+
const popperInstance = shallowRef();
|
|
2694
|
+
const popoverRef = ref();
|
|
2695
|
+
const contentRef = ref();
|
|
2696
|
+
const arrowRef = ref();
|
|
2697
|
+
const createPopover = (active, content, arrow2, config) => {
|
|
2698
|
+
instance = new PopoverImpl2(
|
|
2699
|
+
{ style, arrowStyle, placement, show: options.props.show },
|
|
2700
|
+
active,
|
|
2701
|
+
content,
|
|
2702
|
+
arrow2,
|
|
2703
|
+
config,
|
|
2704
|
+
{
|
|
2705
|
+
onShow: () => {
|
|
2706
|
+
var _a;
|
|
2707
|
+
clickAwayInstance == null ? void 0 : clickAwayInstance.add();
|
|
2708
|
+
(_a = lifecycle == null ? void 0 : lifecycle.onShow) == null ? void 0 : _a.call(lifecycle);
|
|
2709
|
+
},
|
|
2710
|
+
onHide: () => {
|
|
2711
|
+
var _a;
|
|
2712
|
+
clickAwayInstance == null ? void 0 : clickAwayInstance.remove();
|
|
2713
|
+
(_a = lifecycle == null ? void 0 : lifecycle.onHide) == null ? void 0 : _a.call(lifecycle);
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
);
|
|
2717
|
+
return instance;
|
|
2718
|
+
};
|
|
2719
|
+
const props2 = options.props;
|
|
2720
|
+
const popoverEnter = () => {
|
|
2721
|
+
if (props2.hover) {
|
|
2722
|
+
instance == null ? void 0 : instance.show();
|
|
2723
|
+
}
|
|
2724
|
+
};
|
|
2725
|
+
const popoverLeave = () => {
|
|
2726
|
+
if (props2.hover) {
|
|
2727
|
+
instance == null ? void 0 : instance.hide();
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2730
|
+
const onBeforeDestroyEvents = [];
|
|
2731
|
+
onMounted(() => {
|
|
2732
|
+
if (!popoverRef.value || !contentRef.value) {
|
|
2733
|
+
return;
|
|
2734
|
+
}
|
|
2735
|
+
popperInstance.value = createPopover(popoverRef.value, contentRef.value, arrowRef.value, {
|
|
2736
|
+
...props2.popper,
|
|
2737
|
+
placement: props2.placement
|
|
2738
|
+
});
|
|
2739
|
+
if (options.props.disableClickAway) {
|
|
2740
|
+
return;
|
|
2741
|
+
}
|
|
2742
|
+
clickAwayInstance = useClickAway({
|
|
2743
|
+
target: () => {
|
|
2744
|
+
var _a;
|
|
2745
|
+
return (_a = instance == null ? void 0 : instance.content) == null ? void 0 : _a.parentElement;
|
|
2746
|
+
},
|
|
2747
|
+
handler: () => {
|
|
2748
|
+
instance == null ? void 0 : instance.hide();
|
|
2749
|
+
}
|
|
2750
|
+
});
|
|
2751
|
+
});
|
|
2752
|
+
onBeforeMount(() => {
|
|
2753
|
+
if (clickAwayInstance) {
|
|
2754
|
+
const { onBeforeDestroy } = clickAwayInstance;
|
|
2755
|
+
onBeforeDestroy();
|
|
2756
|
+
}
|
|
2757
|
+
});
|
|
2758
|
+
const getContent = (props22, getContentSlot, useTeleport, _instance = instance) => {
|
|
2759
|
+
const contentTeleportWrapper = () => {
|
|
2760
|
+
if (props22.teleport) {
|
|
2761
|
+
return useTeleport({
|
|
2762
|
+
teleportProps: props22.teleport,
|
|
2763
|
+
slot: getContentSlot()
|
|
2764
|
+
});
|
|
2765
|
+
}
|
|
2766
|
+
return getContentSlot();
|
|
2767
|
+
};
|
|
2768
|
+
if (props22.mountRender) {
|
|
2769
|
+
return contentTeleportWrapper();
|
|
2770
|
+
}
|
|
2771
|
+
if (!_instance || !_instance.visible) {
|
|
2772
|
+
return null;
|
|
2773
|
+
}
|
|
2774
|
+
return contentTeleportWrapper();
|
|
2775
|
+
};
|
|
2776
|
+
return {
|
|
2777
|
+
getContent,
|
|
2778
|
+
popoverEnter,
|
|
2779
|
+
popoverLeave,
|
|
2780
|
+
popoverRef,
|
|
2781
|
+
contentRef,
|
|
2782
|
+
arrowRef,
|
|
2783
|
+
popperInstance,
|
|
2784
|
+
style,
|
|
2785
|
+
arrowStyle,
|
|
2786
|
+
lifecycle: {
|
|
2787
|
+
onBeforeDestroyEvents
|
|
2788
|
+
}
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
const MessagePopoverCore = {
|
|
2792
|
+
props: props$j,
|
|
2793
|
+
usePopover
|
|
2794
|
+
};
|
|
2795
|
+
const props$i = {
|
|
2796
|
+
modelValue: { type: [String, Number], required: true },
|
|
2797
|
+
items: { type: Array, default: () => [] },
|
|
2798
|
+
type: { type: String, default: "line" }
|
|
2799
|
+
};
|
|
2800
|
+
const tabPaneProps = {
|
|
2801
|
+
label: { type: String, required: true },
|
|
2802
|
+
name: { type: [String, Number], required: true },
|
|
2803
|
+
disabled: { type: Boolean, default: false },
|
|
2804
|
+
lazy: { type: Boolean, default: false }
|
|
2805
|
+
};
|
|
2806
|
+
function useTabs(props2, ctx) {
|
|
2807
|
+
const { emit } = ctx;
|
|
2808
|
+
const activeTab = computed(() => props2.modelValue);
|
|
2809
|
+
const isActive = (name) => activeTab.value === name;
|
|
2810
|
+
const switchTab = (name, disabled) => {
|
|
2811
|
+
if (disabled) {
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
if (name === activeTab.value) {
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
emit("update:modelValue", name);
|
|
2818
|
+
emit("change", name);
|
|
2819
|
+
};
|
|
2820
|
+
const tabsClass = computed(() => {
|
|
2821
|
+
const type = props2.type ?? "line";
|
|
2822
|
+
return [
|
|
2823
|
+
"m-tabs",
|
|
2824
|
+
`m-tabs-${type}`
|
|
2825
|
+
];
|
|
2826
|
+
});
|
|
2827
|
+
const navClass = "m-tabs-nav";
|
|
2828
|
+
const getNavItemClass = (name, disabled) => [
|
|
2829
|
+
"m-tabs-nav-item",
|
|
2830
|
+
isActive(name) ? "m-tabs-nav-item-active" : "",
|
|
2831
|
+
disabled ? "m-tabs-nav-item-disabled" : ""
|
|
2832
|
+
].filter(Boolean);
|
|
2833
|
+
const contentClass = "m-tabs-content";
|
|
2834
|
+
return {
|
|
2835
|
+
activeTab,
|
|
2836
|
+
isActive,
|
|
2837
|
+
switchTab,
|
|
2838
|
+
tabsClass,
|
|
2839
|
+
navClass,
|
|
2840
|
+
getNavItemClass,
|
|
2841
|
+
contentClass
|
|
2842
|
+
};
|
|
2843
|
+
}
|
|
2844
|
+
const TabsCore = {
|
|
2845
|
+
props: props$i,
|
|
2846
|
+
tabPaneProps,
|
|
2847
|
+
useTabs
|
|
2848
|
+
};
|
|
2849
|
+
const props$h = {
|
|
2850
|
+
trigger: {
|
|
2851
|
+
type: String,
|
|
2852
|
+
default: "click"
|
|
2853
|
+
},
|
|
2854
|
+
placement: {
|
|
2855
|
+
type: String,
|
|
2856
|
+
default: "bottom"
|
|
2857
|
+
},
|
|
2858
|
+
disabled: { type: Boolean, default: false }
|
|
2859
|
+
};
|
|
2860
|
+
const itemProps$1 = {
|
|
2861
|
+
label: { type: String, default: "" },
|
|
2862
|
+
disabled: { type: Boolean, default: false },
|
|
2863
|
+
divided: { type: Boolean, default: false },
|
|
2864
|
+
command: { type: [String, Number], default: void 0 },
|
|
2865
|
+
type: {
|
|
2866
|
+
type: String,
|
|
2867
|
+
default: "default"
|
|
2868
|
+
}
|
|
2869
|
+
};
|
|
2870
|
+
function useDropdown(props2, ctx) {
|
|
2871
|
+
const { emit } = ctx;
|
|
2872
|
+
const visible = ref(false);
|
|
2873
|
+
const triggerRef2 = ref();
|
|
2874
|
+
const menuRef = ref();
|
|
2875
|
+
const open = () => {
|
|
2876
|
+
if (props2.disabled) {
|
|
2877
|
+
return;
|
|
2878
|
+
}
|
|
2879
|
+
visible.value = true;
|
|
2880
|
+
};
|
|
2881
|
+
const close = () => {
|
|
2882
|
+
visible.value = false;
|
|
2883
|
+
};
|
|
2884
|
+
const toggle = () => {
|
|
2885
|
+
if (visible.value) {
|
|
2886
|
+
close();
|
|
2887
|
+
} else {
|
|
2888
|
+
open();
|
|
2889
|
+
}
|
|
2890
|
+
};
|
|
2891
|
+
let clickAwayInstance;
|
|
2892
|
+
onMounted(() => {
|
|
2893
|
+
clickAwayInstance = useClickAway({
|
|
2894
|
+
// 以 trigger 容器为边界,点击 trigger 或 menu 内部不触发关闭
|
|
2895
|
+
target: () => {
|
|
2896
|
+
var _a;
|
|
2897
|
+
return (_a = triggerRef2.value) == null ? void 0 : _a.parentElement;
|
|
2898
|
+
},
|
|
2899
|
+
handler: () => {
|
|
2900
|
+
close();
|
|
2901
|
+
}
|
|
2902
|
+
});
|
|
2903
|
+
clickAwayInstance == null ? void 0 : clickAwayInstance.add();
|
|
2904
|
+
});
|
|
2905
|
+
onBeforeUnmount(() => {
|
|
2906
|
+
clickAwayInstance == null ? void 0 : clickAwayInstance.remove();
|
|
2907
|
+
});
|
|
2908
|
+
const handleTriggerClick = () => {
|
|
2909
|
+
if (props2.trigger !== "click") {
|
|
2910
|
+
return;
|
|
2911
|
+
}
|
|
2912
|
+
toggle();
|
|
2913
|
+
};
|
|
2914
|
+
const handleMouseenter = () => {
|
|
2915
|
+
if (props2.trigger !== "hover") {
|
|
2916
|
+
return;
|
|
2917
|
+
}
|
|
2918
|
+
open();
|
|
2919
|
+
};
|
|
2920
|
+
const handleMouseleave = () => {
|
|
2921
|
+
if (props2.trigger !== "hover") {
|
|
2922
|
+
return;
|
|
2923
|
+
}
|
|
2924
|
+
close();
|
|
2925
|
+
};
|
|
2926
|
+
const handleItemClick = (item) => {
|
|
2927
|
+
if (item.disabled) {
|
|
2928
|
+
return;
|
|
2929
|
+
}
|
|
2930
|
+
emit("command", item.command);
|
|
2931
|
+
close();
|
|
2932
|
+
};
|
|
2933
|
+
const dropdownClass = computed(() => [
|
|
2934
|
+
"m-dropdown",
|
|
2935
|
+
{ "m-dropdown-open": visible.value },
|
|
2936
|
+
{ "m-dropdown-disabled": props2.disabled }
|
|
2937
|
+
]);
|
|
2938
|
+
const menuClass = computed(() => ["m-dropdown-menu"]);
|
|
2939
|
+
const getItemClass = (item) => [
|
|
2940
|
+
"m-dropdown-item",
|
|
2941
|
+
{ "m-dropdown-item-disabled": item.disabled },
|
|
2942
|
+
{ "m-dropdown-item-divided": item.divided }
|
|
2943
|
+
];
|
|
2944
|
+
return {
|
|
2945
|
+
visible,
|
|
2946
|
+
triggerRef: triggerRef2,
|
|
2947
|
+
menuRef,
|
|
2948
|
+
open,
|
|
2949
|
+
close,
|
|
2950
|
+
toggle,
|
|
2951
|
+
handleTriggerClick,
|
|
2952
|
+
handleMouseenter,
|
|
2953
|
+
handleMouseleave,
|
|
2954
|
+
handleItemClick,
|
|
2955
|
+
dropdownClass,
|
|
2956
|
+
menuClass,
|
|
2957
|
+
getItemClass
|
|
2958
|
+
};
|
|
2959
|
+
}
|
|
2960
|
+
const DropdownCore = {
|
|
2961
|
+
props: props$h,
|
|
2962
|
+
itemProps: itemProps$1,
|
|
2963
|
+
useDropdown
|
|
2964
|
+
};
|
|
2965
|
+
const props$g = {
|
|
2966
|
+
modelValue: { type: [Array, String, Number], required: true },
|
|
2967
|
+
accordion: { type: Boolean, default: false }
|
|
2968
|
+
};
|
|
2969
|
+
const itemProps = {
|
|
2970
|
+
name: { type: [String, Number], required: true },
|
|
2971
|
+
title: { type: String, default: "" },
|
|
2972
|
+
disabled: { type: Boolean, default: false }
|
|
2973
|
+
};
|
|
2974
|
+
function useCollapse(props2, ctx) {
|
|
2975
|
+
const { emit } = ctx;
|
|
2976
|
+
const activeNames = computed(() => {
|
|
2977
|
+
const val = props2.modelValue;
|
|
2978
|
+
if (Array.isArray(val)) {
|
|
2979
|
+
return val;
|
|
2980
|
+
}
|
|
2981
|
+
if (val === void 0 || val === null || val === "") {
|
|
2982
|
+
return [];
|
|
2983
|
+
}
|
|
2984
|
+
return [val];
|
|
2985
|
+
});
|
|
2986
|
+
const isActive = (name) => {
|
|
2987
|
+
return activeNames.value.includes(name);
|
|
2988
|
+
};
|
|
2989
|
+
const toggle = (name, disabled) => {
|
|
2990
|
+
if (disabled) {
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2993
|
+
let next;
|
|
2994
|
+
if (props2.accordion) {
|
|
2995
|
+
next = isActive(name) ? [] : [name];
|
|
2996
|
+
} else {
|
|
2997
|
+
if (isActive(name)) {
|
|
2998
|
+
next = activeNames.value.filter((n) => n !== name);
|
|
2999
|
+
} else {
|
|
3000
|
+
next = [...activeNames.value, name];
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
emit("update:modelValue", props2.accordion ? next[0] ?? "" : next);
|
|
3004
|
+
emit("change", next);
|
|
3005
|
+
};
|
|
3006
|
+
const collapseClass = computed(() => ["m-collapse"]);
|
|
3007
|
+
const getItemClass = (name, disabled) => [
|
|
3008
|
+
"m-collapse-item",
|
|
3009
|
+
{ "m-collapse-item-active": isActive(name) },
|
|
3010
|
+
{ "m-collapse-item-disabled": disabled }
|
|
3011
|
+
];
|
|
3012
|
+
const headerClass = ["m-collapse-header"];
|
|
3013
|
+
const contentClass = ["m-collapse-content"];
|
|
3014
|
+
return {
|
|
3015
|
+
activeNames,
|
|
3016
|
+
isActive,
|
|
3017
|
+
toggle,
|
|
3018
|
+
collapseClass,
|
|
3019
|
+
getItemClass,
|
|
3020
|
+
headerClass,
|
|
3021
|
+
contentClass
|
|
3022
|
+
};
|
|
3023
|
+
}
|
|
3024
|
+
const CollapseCore = {
|
|
3025
|
+
props: props$g,
|
|
3026
|
+
itemProps,
|
|
3027
|
+
useCollapse
|
|
3028
|
+
};
|
|
3029
|
+
const stepsProps = {
|
|
3030
|
+
active: { type: Number, default: 0 },
|
|
3031
|
+
direction: { type: String, default: "horizontal" },
|
|
3032
|
+
finishStatus: { type: String, default: "finish" },
|
|
3033
|
+
processStatus: { type: String, default: "process" }
|
|
3034
|
+
};
|
|
3035
|
+
const stepProps = {
|
|
3036
|
+
title: { type: String, required: true },
|
|
3037
|
+
description: { type: String, default: "" },
|
|
3038
|
+
icon: { type: String, default: "" },
|
|
3039
|
+
status: { type: String, default: void 0 }
|
|
3040
|
+
};
|
|
3041
|
+
const stepsContextKey = Symbol("stepsContext");
|
|
3042
|
+
function useSteps(props2) {
|
|
3043
|
+
const context = {
|
|
3044
|
+
get active() {
|
|
3045
|
+
return props2.active ?? 0;
|
|
3046
|
+
},
|
|
3047
|
+
get finishStatus() {
|
|
3048
|
+
return props2.finishStatus ?? "finish";
|
|
3049
|
+
},
|
|
3050
|
+
get processStatus() {
|
|
3051
|
+
return props2.processStatus ?? "process";
|
|
3052
|
+
},
|
|
3053
|
+
get direction() {
|
|
3054
|
+
return props2.direction ?? "horizontal";
|
|
3055
|
+
},
|
|
3056
|
+
total: 0
|
|
3057
|
+
};
|
|
3058
|
+
provide(stepsContextKey, context);
|
|
3059
|
+
const stepsClass = computed(() => [
|
|
3060
|
+
"m-steps",
|
|
3061
|
+
`m-steps-${props2.direction ?? "horizontal"}`
|
|
3062
|
+
]);
|
|
3063
|
+
return { stepsClass, context };
|
|
3064
|
+
}
|
|
3065
|
+
function resolveStepStatus(index, overrideStatus, ctx) {
|
|
3066
|
+
if (overrideStatus) return overrideStatus;
|
|
3067
|
+
const active = ctx.active;
|
|
3068
|
+
if (index < active) return ctx.finishStatus;
|
|
3069
|
+
if (index === active) return ctx.processStatus;
|
|
3070
|
+
return "wait";
|
|
3071
|
+
}
|
|
3072
|
+
function useStep(index, overrideStatus) {
|
|
3073
|
+
const ctx = inject(stepsContextKey, null);
|
|
3074
|
+
const status = computed(() => {
|
|
3075
|
+
if (!ctx) {
|
|
3076
|
+
return overrideStatus ?? "wait";
|
|
3077
|
+
}
|
|
3078
|
+
return resolveStepStatus(index, overrideStatus, ctx);
|
|
3079
|
+
});
|
|
3080
|
+
const stepClass = computed(() => [
|
|
3081
|
+
"m-step",
|
|
3082
|
+
`m-step-${status.value}`
|
|
3083
|
+
]);
|
|
3084
|
+
const isLast = computed(() => {
|
|
3085
|
+
if (!ctx) return true;
|
|
3086
|
+
return index >= ctx.total - 1;
|
|
3087
|
+
});
|
|
3088
|
+
return { status, stepClass, isLast, ctx };
|
|
3089
|
+
}
|
|
3090
|
+
const StepsCore = {
|
|
3091
|
+
stepsProps,
|
|
3092
|
+
stepProps,
|
|
3093
|
+
useSteps,
|
|
3094
|
+
useStep,
|
|
3095
|
+
stepsContextKey,
|
|
3096
|
+
resolveStepStatus
|
|
3097
|
+
};
|
|
3098
|
+
const notificationProps = {
|
|
3099
|
+
title: { type: String, required: true },
|
|
3100
|
+
message: { type: String, default: "" },
|
|
3101
|
+
type: { type: String, default: "info" },
|
|
3102
|
+
duration: { type: Number, default: 4500 },
|
|
3103
|
+
position: { type: String, default: "top-right" },
|
|
3104
|
+
closable: { type: Boolean, default: true },
|
|
3105
|
+
offset: { type: Number, default: 16 }
|
|
3106
|
+
};
|
|
3107
|
+
function useNotificationQueue() {
|
|
3108
|
+
const notifications = ref([]);
|
|
3109
|
+
let nextId = 0;
|
|
3110
|
+
const add = (options) => {
|
|
3111
|
+
const id = nextId++;
|
|
3112
|
+
const item = {
|
|
3113
|
+
id,
|
|
3114
|
+
title: options.title,
|
|
3115
|
+
message: options.message ?? "",
|
|
3116
|
+
type: options.type ?? "info",
|
|
3117
|
+
duration: options.duration ?? 4500,
|
|
3118
|
+
position: options.position ?? "top-right",
|
|
3119
|
+
closable: options.closable ?? true
|
|
3120
|
+
};
|
|
3121
|
+
notifications.value.push(item);
|
|
3122
|
+
if (item.duration > 0) {
|
|
3123
|
+
setTimeout(() => remove(id), item.duration);
|
|
3124
|
+
}
|
|
3125
|
+
return id;
|
|
3126
|
+
};
|
|
3127
|
+
const remove = (id) => {
|
|
3128
|
+
const idx = notifications.value.findIndex((n) => n.id === id);
|
|
3129
|
+
if (idx !== -1) {
|
|
3130
|
+
notifications.value.splice(idx, 1);
|
|
3131
|
+
}
|
|
3132
|
+
};
|
|
3133
|
+
return { notifications, add, remove };
|
|
3134
|
+
}
|
|
3135
|
+
const NotificationCore = {
|
|
3136
|
+
notificationProps,
|
|
3137
|
+
useNotificationQueue
|
|
3138
|
+
};
|
|
3139
|
+
const props$f = {
|
|
3140
|
+
loading: { type: Boolean, default: true },
|
|
3141
|
+
rows: { type: Number, default: 3 },
|
|
3142
|
+
animated: { type: Boolean, default: true },
|
|
3143
|
+
avatar: { type: Boolean, default: false },
|
|
3144
|
+
title: { type: Boolean, default: true }
|
|
3145
|
+
};
|
|
3146
|
+
const SkeletonCore = {
|
|
3147
|
+
props: props$f
|
|
3148
|
+
};
|
|
3149
|
+
const timelineProps = {
|
|
3150
|
+
reverse: { type: Boolean, default: false }
|
|
3151
|
+
};
|
|
3152
|
+
const timelineItemProps = {
|
|
3153
|
+
timestamp: { type: String, default: "" },
|
|
3154
|
+
hideTimestamp: { type: Boolean, default: false },
|
|
3155
|
+
placement: { type: String, default: "bottom" },
|
|
3156
|
+
type: { type: String, default: "primary" },
|
|
3157
|
+
size: { type: String, default: "normal" },
|
|
3158
|
+
icon: { type: String, default: "" },
|
|
3159
|
+
hollow: { type: Boolean, default: false }
|
|
3160
|
+
};
|
|
3161
|
+
const TimelineCore = {
|
|
3162
|
+
timelineProps,
|
|
3163
|
+
timelineItemProps
|
|
3164
|
+
};
|
|
3165
|
+
const descriptionsProps = {
|
|
3166
|
+
title: { type: String, default: "" },
|
|
3167
|
+
column: { type: Number, default: 3 },
|
|
3168
|
+
direction: { type: String, default: "horizontal" },
|
|
3169
|
+
border: { type: Boolean, default: false },
|
|
3170
|
+
size: { type: String, default: "medium" }
|
|
3171
|
+
};
|
|
3172
|
+
const descriptionsItemProps = {
|
|
3173
|
+
label: { type: String, required: true },
|
|
3174
|
+
span: { type: Number, default: 1 }
|
|
3175
|
+
};
|
|
3176
|
+
const DescriptionsCore = {
|
|
3177
|
+
descriptionsProps,
|
|
3178
|
+
descriptionsItemProps
|
|
3179
|
+
};
|
|
3180
|
+
const props$e = {
|
|
3181
|
+
title: { type: String, default: void 0 },
|
|
3182
|
+
shadow: { type: String, default: "never" },
|
|
3183
|
+
bodyStyle: { type: Object, default: void 0 },
|
|
3184
|
+
bordered: { type: Boolean, default: true }
|
|
3185
|
+
};
|
|
3186
|
+
const CardCore = {
|
|
3187
|
+
props: props$e
|
|
3188
|
+
};
|
|
3189
|
+
const props$d = {
|
|
3190
|
+
type: { type: String, default: "info" },
|
|
3191
|
+
title: { type: String, default: void 0 },
|
|
3192
|
+
description: { type: String, default: void 0 },
|
|
3193
|
+
closable: { type: Boolean, default: false },
|
|
3194
|
+
showIcon: { type: Boolean, default: false }
|
|
3195
|
+
};
|
|
3196
|
+
const AlertCore = {
|
|
3197
|
+
props: props$d
|
|
3198
|
+
};
|
|
3199
|
+
const props$c = {
|
|
3200
|
+
value: { type: [String, Number], default: void 0 },
|
|
3201
|
+
max: { type: Number, default: 99 },
|
|
3202
|
+
dot: { type: Boolean, default: false },
|
|
3203
|
+
hidden: { type: Boolean, default: false },
|
|
3204
|
+
showZero: { type: Boolean, default: false },
|
|
3205
|
+
type: {
|
|
3206
|
+
type: String,
|
|
3207
|
+
default: "danger"
|
|
3208
|
+
}
|
|
3209
|
+
};
|
|
3210
|
+
const BadgeCore = {
|
|
3211
|
+
props: props$c
|
|
3212
|
+
};
|
|
3213
|
+
const props$b = {
|
|
3214
|
+
description: { type: String, default: "暂无数据" },
|
|
3215
|
+
image: { type: String, default: void 0 }
|
|
3216
|
+
};
|
|
3217
|
+
const EmptyCore = {
|
|
3218
|
+
props: props$b
|
|
3219
|
+
};
|
|
3220
|
+
const props$a = {
|
|
3221
|
+
direction: { type: String, default: "horizontal" },
|
|
3222
|
+
size: { type: [String, Number], default: "medium" },
|
|
3223
|
+
wrap: { type: Boolean, default: false },
|
|
3224
|
+
align: { type: String, default: "center" }
|
|
3225
|
+
};
|
|
3226
|
+
const SpaceCore = {
|
|
3227
|
+
props: props$a
|
|
3228
|
+
};
|
|
3229
|
+
const props$9 = {
|
|
3230
|
+
modelValue: { type: String, default: "" },
|
|
3231
|
+
placeholder: { type: String, default: "请输入..." },
|
|
3232
|
+
disabled: { type: Boolean, default: false },
|
|
3233
|
+
clearable: { type: Boolean, default: false },
|
|
3234
|
+
debounce: { type: Number, default: 300 },
|
|
3235
|
+
fetchSuggestions: {
|
|
3236
|
+
type: Function,
|
|
3237
|
+
default: void 0
|
|
3238
|
+
},
|
|
3239
|
+
triggerOnFocus: { type: Boolean, default: false },
|
|
3240
|
+
highlight: { type: Boolean, default: false }
|
|
3241
|
+
};
|
|
3242
|
+
function useAutoComplete(props2, ctx) {
|
|
3243
|
+
const modelValueRef = toRef(() => props2.modelValue ?? "");
|
|
3244
|
+
const inputValue = ref(modelValueRef.value);
|
|
3245
|
+
const isOpen = ref(false);
|
|
3246
|
+
const loading = ref(false);
|
|
3247
|
+
const suggestions = ref([]);
|
|
3248
|
+
let debounceTimer;
|
|
3249
|
+
const clearDebounce = () => {
|
|
3250
|
+
if (debounceTimer !== void 0) {
|
|
3251
|
+
clearTimeout(debounceTimer);
|
|
3252
|
+
debounceTimer = void 0;
|
|
3253
|
+
}
|
|
3254
|
+
};
|
|
3255
|
+
const doSearch = async (query) => {
|
|
3256
|
+
if (!props2.fetchSuggestions) return;
|
|
3257
|
+
loading.value = true;
|
|
3258
|
+
try {
|
|
3259
|
+
const result = await props2.fetchSuggestions(query);
|
|
3260
|
+
suggestions.value = result ?? [];
|
|
3261
|
+
isOpen.value = true;
|
|
3262
|
+
} catch {
|
|
3263
|
+
suggestions.value = [];
|
|
3264
|
+
} finally {
|
|
3265
|
+
loading.value = false;
|
|
3266
|
+
}
|
|
3267
|
+
};
|
|
3268
|
+
const debouncedSearch = (query) => {
|
|
3269
|
+
clearDebounce();
|
|
3270
|
+
const delay = props2.debounce ?? 300;
|
|
3271
|
+
debounceTimer = setTimeout(() => {
|
|
3272
|
+
doSearch(query);
|
|
3273
|
+
ctx.emit("search", query);
|
|
3274
|
+
}, delay);
|
|
3275
|
+
};
|
|
3276
|
+
const onInput = (e) => {
|
|
3277
|
+
const value = e.target.value;
|
|
3278
|
+
inputValue.value = value;
|
|
3279
|
+
ctx.emit("update:modelValue", value);
|
|
3280
|
+
debouncedSearch(value);
|
|
3281
|
+
};
|
|
3282
|
+
const onFocus = (e) => {
|
|
3283
|
+
if (props2.disabled) return;
|
|
3284
|
+
ctx.emit("focus", e);
|
|
3285
|
+
if (props2.triggerOnFocus) {
|
|
3286
|
+
doSearch(inputValue.value);
|
|
3287
|
+
ctx.emit("search", inputValue.value);
|
|
3288
|
+
}
|
|
3289
|
+
};
|
|
3290
|
+
const onBlur = (e) => {
|
|
3291
|
+
if (props2.disabled) return;
|
|
3292
|
+
setTimeout(() => {
|
|
3293
|
+
isOpen.value = false;
|
|
3294
|
+
}, 150);
|
|
3295
|
+
ctx.emit("blur", e);
|
|
3296
|
+
};
|
|
3297
|
+
const onSelect = (item) => {
|
|
3298
|
+
inputValue.value = item.value;
|
|
3299
|
+
ctx.emit("update:modelValue", item.value);
|
|
3300
|
+
ctx.emit("select", item);
|
|
3301
|
+
isOpen.value = false;
|
|
3302
|
+
clearDebounce();
|
|
3303
|
+
};
|
|
3304
|
+
const onClear = () => {
|
|
3305
|
+
inputValue.value = "";
|
|
3306
|
+
suggestions.value = [];
|
|
3307
|
+
isOpen.value = false;
|
|
3308
|
+
clearDebounce();
|
|
3309
|
+
ctx.emit("update:modelValue", "");
|
|
3310
|
+
};
|
|
3311
|
+
const close = () => {
|
|
3312
|
+
isOpen.value = false;
|
|
3313
|
+
};
|
|
3314
|
+
onBeforeUnmount(() => {
|
|
3315
|
+
clearDebounce();
|
|
3316
|
+
});
|
|
3317
|
+
return {
|
|
3318
|
+
// 状态
|
|
3319
|
+
inputValue,
|
|
3320
|
+
isOpen,
|
|
3321
|
+
loading,
|
|
3322
|
+
suggestions,
|
|
3323
|
+
// 事件
|
|
3324
|
+
onInput,
|
|
3325
|
+
onFocus,
|
|
3326
|
+
onBlur,
|
|
3327
|
+
onSelect,
|
|
3328
|
+
onClear,
|
|
3329
|
+
close
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
const AutoCompleteCore = {
|
|
3333
|
+
props: props$9,
|
|
3334
|
+
useAutoComplete
|
|
3335
|
+
};
|
|
3336
|
+
const props$8 = {
|
|
3337
|
+
autoplay: { type: Boolean, default: true },
|
|
3338
|
+
interval: { type: Number, default: 3e3 },
|
|
3339
|
+
loop: { type: Boolean, default: true },
|
|
3340
|
+
direction: {
|
|
3341
|
+
type: String,
|
|
3342
|
+
default: "horizontal",
|
|
3343
|
+
enum: ["horizontal", "vertical"]
|
|
3344
|
+
},
|
|
3345
|
+
initialIndex: { type: Number, default: 0 },
|
|
3346
|
+
showIndicators: { type: Boolean, default: true },
|
|
3347
|
+
showArrows: {
|
|
3348
|
+
type: [Boolean, String],
|
|
3349
|
+
default: "hover"
|
|
3350
|
+
}
|
|
3351
|
+
};
|
|
3352
|
+
function useCarousel(props2, emit, count) {
|
|
3353
|
+
const activeIndex = ref(props2.initialIndex);
|
|
3354
|
+
let timer = null;
|
|
3355
|
+
const setActive = (index) => {
|
|
3356
|
+
const total = count();
|
|
3357
|
+
if (total === 0) {
|
|
3358
|
+
return;
|
|
3359
|
+
}
|
|
3360
|
+
let next2 = index;
|
|
3361
|
+
if (props2.loop) {
|
|
3362
|
+
next2 = (index % total + total) % total;
|
|
3363
|
+
} else {
|
|
3364
|
+
next2 = Math.max(0, Math.min(index, total - 1));
|
|
3365
|
+
}
|
|
3366
|
+
if (next2 !== activeIndex.value) {
|
|
3367
|
+
activeIndex.value = next2;
|
|
3368
|
+
emit("change", next2);
|
|
3369
|
+
}
|
|
3370
|
+
};
|
|
3371
|
+
const prev = () => setActive(activeIndex.value - 1);
|
|
3372
|
+
const next = () => setActive(activeIndex.value + 1);
|
|
3373
|
+
const startAutoplay = () => {
|
|
3374
|
+
if (!props2.autoplay || props2.interval <= 0) {
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
timer = setInterval(next, props2.interval);
|
|
3378
|
+
};
|
|
3379
|
+
const stopAutoplay = () => {
|
|
3380
|
+
if (timer !== null) {
|
|
3381
|
+
clearInterval(timer);
|
|
3382
|
+
timer = null;
|
|
3383
|
+
}
|
|
3384
|
+
};
|
|
3385
|
+
watch(() => props2.autoplay, (val) => {
|
|
3386
|
+
val ? startAutoplay() : stopAutoplay();
|
|
3387
|
+
});
|
|
3388
|
+
onMounted(startAutoplay);
|
|
3389
|
+
onUnmounted(stopAutoplay);
|
|
3390
|
+
const arrowsClass = computed(() => {
|
|
3391
|
+
if (props2.showArrows === "hover") {
|
|
3392
|
+
return "k-carousel-arrows-hover";
|
|
3393
|
+
}
|
|
3394
|
+
if (props2.showArrows === false) {
|
|
3395
|
+
return "k-carousel-arrows-hidden";
|
|
3396
|
+
}
|
|
3397
|
+
return "k-carousel-arrows-always";
|
|
3398
|
+
});
|
|
3399
|
+
return {
|
|
3400
|
+
activeIndex,
|
|
3401
|
+
prev,
|
|
3402
|
+
next,
|
|
3403
|
+
setActive,
|
|
3404
|
+
startAutoplay,
|
|
3405
|
+
stopAutoplay,
|
|
3406
|
+
arrowsClass
|
|
3407
|
+
};
|
|
3408
|
+
}
|
|
3409
|
+
const CarouselCore = {
|
|
3410
|
+
props: props$8,
|
|
3411
|
+
useCarousel
|
|
3412
|
+
};
|
|
3413
|
+
const props$7 = {
|
|
3414
|
+
src: { type: String, required: true },
|
|
3415
|
+
alt: { type: String, default: "" },
|
|
3416
|
+
fit: {
|
|
3417
|
+
type: String,
|
|
3418
|
+
default: "cover",
|
|
3419
|
+
enum: ["contain", "cover", "fill", "none", "scale-down"]
|
|
3420
|
+
},
|
|
3421
|
+
lazy: { type: Boolean, default: false },
|
|
3422
|
+
previewSrcList: { type: Array, default: () => [] },
|
|
3423
|
+
zIndex: { type: Number, default: 2e3 }
|
|
3424
|
+
};
|
|
3425
|
+
function useImage(props2, emit) {
|
|
3426
|
+
const status = ref("loading");
|
|
3427
|
+
const previewVisible = ref(false);
|
|
3428
|
+
const previewIndex = ref(0);
|
|
3429
|
+
const previewScale = ref(1);
|
|
3430
|
+
const previewRotate = ref(0);
|
|
3431
|
+
const reset = () => {
|
|
3432
|
+
status.value = "loading";
|
|
3433
|
+
};
|
|
3434
|
+
const handleLoad = (e) => {
|
|
3435
|
+
status.value = "loaded";
|
|
3436
|
+
emit("load", e);
|
|
3437
|
+
};
|
|
3438
|
+
const handleError = (e) => {
|
|
3439
|
+
status.value = "error";
|
|
3440
|
+
emit("error", e);
|
|
3441
|
+
};
|
|
3442
|
+
const openPreview = () => {
|
|
3443
|
+
if (!props2.previewSrcList || props2.previewSrcList.length === 0) {
|
|
3444
|
+
return;
|
|
3445
|
+
}
|
|
3446
|
+
const idx = props2.previewSrcList.indexOf(props2.src);
|
|
3447
|
+
previewIndex.value = idx >= 0 ? idx : 0;
|
|
3448
|
+
previewScale.value = 1;
|
|
3449
|
+
previewRotate.value = 0;
|
|
3450
|
+
previewVisible.value = true;
|
|
3451
|
+
};
|
|
3452
|
+
const closePreview = () => {
|
|
3453
|
+
previewVisible.value = false;
|
|
3454
|
+
};
|
|
3455
|
+
const previewPrev = () => {
|
|
3456
|
+
const total = props2.previewSrcList.length;
|
|
3457
|
+
if (total === 0) {
|
|
3458
|
+
return;
|
|
3459
|
+
}
|
|
3460
|
+
previewIndex.value = (previewIndex.value - 1 + total) % total;
|
|
3461
|
+
previewScale.value = 1;
|
|
3462
|
+
previewRotate.value = 0;
|
|
3463
|
+
emit("switch", previewIndex.value);
|
|
3464
|
+
};
|
|
3465
|
+
const previewNext = () => {
|
|
3466
|
+
const total = props2.previewSrcList.length;
|
|
3467
|
+
if (total === 0) {
|
|
3468
|
+
return;
|
|
3469
|
+
}
|
|
3470
|
+
previewIndex.value = (previewIndex.value + 1) % total;
|
|
3471
|
+
previewScale.value = 1;
|
|
3472
|
+
previewRotate.value = 0;
|
|
3473
|
+
emit("switch", previewIndex.value);
|
|
3474
|
+
};
|
|
3475
|
+
const zoomIn = () => {
|
|
3476
|
+
previewScale.value = Math.min(previewScale.value + 0.25, 5);
|
|
3477
|
+
};
|
|
3478
|
+
const zoomOut = () => {
|
|
3479
|
+
previewScale.value = Math.max(previewScale.value - 0.25, 0.25);
|
|
3480
|
+
};
|
|
3481
|
+
const rotate = () => {
|
|
3482
|
+
previewRotate.value = (previewRotate.value + 90) % 360;
|
|
3483
|
+
};
|
|
3484
|
+
watch(() => props2.src, reset);
|
|
3485
|
+
onMounted(() => {
|
|
3486
|
+
if (props2.lazy) {
|
|
3487
|
+
status.value = "loading";
|
|
3488
|
+
}
|
|
3489
|
+
});
|
|
3490
|
+
return {
|
|
3491
|
+
status,
|
|
3492
|
+
previewVisible,
|
|
3493
|
+
previewIndex,
|
|
3494
|
+
previewScale,
|
|
3495
|
+
previewRotate,
|
|
3496
|
+
handleLoad,
|
|
3497
|
+
handleError,
|
|
3498
|
+
openPreview,
|
|
3499
|
+
closePreview,
|
|
3500
|
+
previewPrev,
|
|
3501
|
+
previewNext,
|
|
3502
|
+
zoomIn,
|
|
3503
|
+
zoomOut,
|
|
3504
|
+
rotate
|
|
3505
|
+
};
|
|
3506
|
+
}
|
|
3507
|
+
const ImageCore = {
|
|
3508
|
+
props: props$7,
|
|
3509
|
+
useImage
|
|
3510
|
+
};
|
|
3511
|
+
const props$6 = {
|
|
3512
|
+
status: {
|
|
3513
|
+
type: String,
|
|
3514
|
+
default: "info",
|
|
3515
|
+
enum: ["success", "warning", "error", "info", "404"]
|
|
3516
|
+
},
|
|
3517
|
+
title: { type: String, default: "" },
|
|
3518
|
+
subTitle: { type: String, default: "" }
|
|
3519
|
+
};
|
|
3520
|
+
const ResultCore = {
|
|
3521
|
+
props: props$6
|
|
3522
|
+
};
|
|
3523
|
+
const props$5 = {
|
|
3524
|
+
modelValue: { type: void 0, default: () => [] },
|
|
3525
|
+
options: { type: Array, default: () => [] },
|
|
3526
|
+
placeholder: { type: String, default: "请选择" },
|
|
3527
|
+
disabled: { type: Boolean, default: false },
|
|
3528
|
+
clearable: { type: Boolean, default: false },
|
|
3529
|
+
filterable: { type: Boolean, default: false },
|
|
3530
|
+
separator: { type: String, default: "/" },
|
|
3531
|
+
expandTrigger: { type: String, default: "click" },
|
|
3532
|
+
showAllLevels: { type: Boolean, default: true },
|
|
3533
|
+
multiple: { type: Boolean, default: false }
|
|
3534
|
+
};
|
|
3535
|
+
const flattenOptions = (options, path = []) => {
|
|
3536
|
+
const result = [];
|
|
3537
|
+
for (const option of options) {
|
|
3538
|
+
const currentPath = [...path, option];
|
|
3539
|
+
if (!option.children || option.children.length === 0 || option.leaf) {
|
|
3540
|
+
result.push({
|
|
3541
|
+
path: currentPath,
|
|
3542
|
+
pathLabel: currentPath.map((o) => o.label).join(" ")
|
|
3543
|
+
});
|
|
3544
|
+
} else {
|
|
3545
|
+
result.push(...flattenOptions(option.children, currentPath));
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
return result;
|
|
3549
|
+
};
|
|
3550
|
+
const findPathByValues = (options, values) => {
|
|
3551
|
+
var _a;
|
|
3552
|
+
if (!values.length) return null;
|
|
3553
|
+
const [head, ...rest] = values;
|
|
3554
|
+
const found = options.find((o) => o.value === head);
|
|
3555
|
+
if (!found) return null;
|
|
3556
|
+
if (!rest.length) return [found];
|
|
3557
|
+
if (!((_a = found.children) == null ? void 0 : _a.length)) return null;
|
|
3558
|
+
const subPath = findPathByValues(found.children, rest);
|
|
3559
|
+
return subPath ? [found, ...subPath] : null;
|
|
3560
|
+
};
|
|
3561
|
+
function useCascader(props2, ctx) {
|
|
3562
|
+
const optionsRef = toRef(() => props2.options ?? []);
|
|
3563
|
+
const modelValueRef = toRef(() => props2.modelValue ?? []);
|
|
3564
|
+
const multipleRef = toRef(() => props2.multiple ?? false);
|
|
3565
|
+
const isOpen = ref(false);
|
|
3566
|
+
const searchQuery = ref("");
|
|
3567
|
+
const activePath = ref([]);
|
|
3568
|
+
const columns = computed(() => {
|
|
3569
|
+
var _a;
|
|
3570
|
+
const cols = [optionsRef.value];
|
|
3571
|
+
for (const node of activePath.value) {
|
|
3572
|
+
if ((_a = node.children) == null ? void 0 : _a.length) {
|
|
3573
|
+
cols.push(node.children);
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
return cols;
|
|
3577
|
+
});
|
|
3578
|
+
const flatOptions = computed(() => {
|
|
3579
|
+
if (!props2.filterable) return [];
|
|
3580
|
+
return flattenOptions(optionsRef.value);
|
|
3581
|
+
});
|
|
3582
|
+
const filteredOptions = computed(() => {
|
|
3583
|
+
if (!searchQuery.value) return flatOptions.value;
|
|
3584
|
+
const q = searchQuery.value.toLowerCase();
|
|
3585
|
+
return flatOptions.value.filter(
|
|
3586
|
+
(item) => item.pathLabel.toLowerCase().includes(q)
|
|
3587
|
+
);
|
|
3588
|
+
});
|
|
3589
|
+
const isSearching = computed(() => props2.filterable && searchQuery.value.length > 0);
|
|
3590
|
+
const selectedPath = computed(() => {
|
|
3591
|
+
if (multipleRef.value) return [];
|
|
3592
|
+
const mv = modelValueRef.value;
|
|
3593
|
+
if (!mv.length) return [];
|
|
3594
|
+
return findPathByValues(optionsRef.value, mv) ?? [];
|
|
3595
|
+
});
|
|
3596
|
+
const selectedPaths = computed(() => {
|
|
3597
|
+
if (!multipleRef.value) return [];
|
|
3598
|
+
const mv = modelValueRef.value;
|
|
3599
|
+
return mv.map((vals) => findPathByValues(optionsRef.value, vals)).filter((p) => p !== null);
|
|
3600
|
+
});
|
|
3601
|
+
const displayLabel = computed(() => {
|
|
3602
|
+
var _a;
|
|
3603
|
+
if (multipleRef.value) return "";
|
|
3604
|
+
if (!selectedPath.value.length) return "";
|
|
3605
|
+
if (props2.showAllLevels) {
|
|
3606
|
+
return selectedPath.value.map((o) => o.label).join(` ${props2.separator ?? "/"} `);
|
|
3607
|
+
}
|
|
3608
|
+
return ((_a = selectedPath.value[selectedPath.value.length - 1]) == null ? void 0 : _a.label) ?? "";
|
|
3609
|
+
});
|
|
3610
|
+
const selectedTags = computed(() => {
|
|
3611
|
+
if (!multipleRef.value) return [];
|
|
3612
|
+
return selectedPaths.value.map((path) => {
|
|
3613
|
+
var _a;
|
|
3614
|
+
if (props2.showAllLevels) {
|
|
3615
|
+
return path.map((o) => o.label).join(` ${props2.separator ?? "/"} `);
|
|
3616
|
+
}
|
|
3617
|
+
return ((_a = path[path.length - 1]) == null ? void 0 : _a.label) ?? "";
|
|
3618
|
+
});
|
|
3619
|
+
});
|
|
3620
|
+
const initActivePath = () => {
|
|
3621
|
+
if (multipleRef.value || !selectedPath.value.length) {
|
|
3622
|
+
activePath.value = [];
|
|
3623
|
+
return;
|
|
3624
|
+
}
|
|
3625
|
+
activePath.value = selectedPath.value.slice(0, -1);
|
|
3626
|
+
};
|
|
3627
|
+
const open = () => {
|
|
3628
|
+
if (props2.disabled) return;
|
|
3629
|
+
initActivePath();
|
|
3630
|
+
isOpen.value = true;
|
|
3631
|
+
};
|
|
3632
|
+
const close = () => {
|
|
3633
|
+
isOpen.value = false;
|
|
3634
|
+
searchQuery.value = "";
|
|
3635
|
+
};
|
|
3636
|
+
const onTriggerClick = () => {
|
|
3637
|
+
if (isOpen.value) {
|
|
3638
|
+
close();
|
|
3639
|
+
} else {
|
|
3640
|
+
open();
|
|
3641
|
+
}
|
|
3642
|
+
};
|
|
3643
|
+
const onOptionEnter = (option, colIndex) => {
|
|
3644
|
+
if (option.disabled) return;
|
|
3645
|
+
activePath.value = [...activePath.value.slice(0, colIndex), option];
|
|
3646
|
+
};
|
|
3647
|
+
const onOptionClick = (option, colIndex) => {
|
|
3648
|
+
var _a;
|
|
3649
|
+
if (option.disabled) return;
|
|
3650
|
+
onOptionEnter(option, colIndex);
|
|
3651
|
+
const isLeaf = !((_a = option.children) == null ? void 0 : _a.length) || option.leaf;
|
|
3652
|
+
if (!isLeaf) return;
|
|
3653
|
+
const fullPath = [...activePath.value.slice(0, colIndex), option];
|
|
3654
|
+
const valuePath = fullPath.map((o) => o.value);
|
|
3655
|
+
if (multipleRef.value) {
|
|
3656
|
+
const currentMv = modelValueRef.value ?? [];
|
|
3657
|
+
const existIndex = currentMv.findIndex(
|
|
3658
|
+
(p) => p.length === valuePath.length && p.every((v, i) => v === valuePath[i])
|
|
3659
|
+
);
|
|
3660
|
+
let newMv;
|
|
3661
|
+
if (existIndex >= 0) {
|
|
3662
|
+
newMv = currentMv.filter((_, i) => i !== existIndex);
|
|
3663
|
+
} else {
|
|
3664
|
+
newMv = [...currentMv, valuePath];
|
|
3665
|
+
}
|
|
3666
|
+
ctx.emit("update:modelValue", newMv);
|
|
3667
|
+
ctx.emit("change", newMv);
|
|
3668
|
+
} else {
|
|
3669
|
+
ctx.emit("update:modelValue", valuePath);
|
|
3670
|
+
ctx.emit("change", valuePath);
|
|
3671
|
+
close();
|
|
3672
|
+
}
|
|
3673
|
+
};
|
|
3674
|
+
const onFlatOptionClick = (item) => {
|
|
3675
|
+
const valuePath = item.path.map((o) => o.value);
|
|
3676
|
+
if (multipleRef.value) {
|
|
3677
|
+
const currentMv = modelValueRef.value ?? [];
|
|
3678
|
+
const existIndex = currentMv.findIndex(
|
|
3679
|
+
(p) => p.length === valuePath.length && p.every((v, i) => v === valuePath[i])
|
|
3680
|
+
);
|
|
3681
|
+
let newMv;
|
|
3682
|
+
if (existIndex >= 0) {
|
|
3683
|
+
newMv = currentMv.filter((_, i) => i !== existIndex);
|
|
3684
|
+
} else {
|
|
3685
|
+
newMv = [...currentMv, valuePath];
|
|
3686
|
+
}
|
|
3687
|
+
ctx.emit("update:modelValue", newMv);
|
|
3688
|
+
ctx.emit("change", newMv);
|
|
3689
|
+
} else {
|
|
3690
|
+
ctx.emit("update:modelValue", valuePath);
|
|
3691
|
+
ctx.emit("change", valuePath);
|
|
3692
|
+
close();
|
|
3693
|
+
}
|
|
3694
|
+
};
|
|
3695
|
+
const onDeleteTag = (tagIndex) => {
|
|
3696
|
+
const currentMv = modelValueRef.value ?? [];
|
|
3697
|
+
const newMv = currentMv.filter((_, i) => i !== tagIndex);
|
|
3698
|
+
ctx.emit("update:modelValue", newMv);
|
|
3699
|
+
ctx.emit("change", newMv);
|
|
3700
|
+
};
|
|
3701
|
+
const onClear = (e) => {
|
|
3702
|
+
e.stopPropagation();
|
|
3703
|
+
const emptyValue = multipleRef.value ? [] : [];
|
|
3704
|
+
ctx.emit("update:modelValue", emptyValue);
|
|
3705
|
+
ctx.emit("change", emptyValue);
|
|
3706
|
+
close();
|
|
3707
|
+
};
|
|
3708
|
+
const isActiveOption = (option, colIndex) => {
|
|
3709
|
+
var _a;
|
|
3710
|
+
return ((_a = activePath.value[colIndex]) == null ? void 0 : _a.value) === option.value;
|
|
3711
|
+
};
|
|
3712
|
+
const isSelectedOption = (option, colIndex) => {
|
|
3713
|
+
var _a;
|
|
3714
|
+
if (multipleRef.value) {
|
|
3715
|
+
return selectedPaths.value.some((path) => {
|
|
3716
|
+
var _a2;
|
|
3717
|
+
return ((_a2 = path[colIndex]) == null ? void 0 : _a2.value) === option.value;
|
|
3718
|
+
});
|
|
3719
|
+
}
|
|
3720
|
+
return ((_a = selectedPath.value[colIndex]) == null ? void 0 : _a.value) === option.value;
|
|
3721
|
+
};
|
|
3722
|
+
const isFlatOptionSelected = (item) => {
|
|
3723
|
+
const valuePath = item.path.map((o) => o.value);
|
|
3724
|
+
if (multipleRef.value) {
|
|
3725
|
+
const currentMv = modelValueRef.value ?? [];
|
|
3726
|
+
return currentMv.some(
|
|
3727
|
+
(p) => p.length === valuePath.length && p.every((v, i) => v === valuePath[i])
|
|
3728
|
+
);
|
|
3729
|
+
}
|
|
3730
|
+
const mv = modelValueRef.value;
|
|
3731
|
+
return mv.length === valuePath.length && valuePath.every((v, i) => v === mv[i]);
|
|
3732
|
+
};
|
|
3733
|
+
watch(activePath, (newPath) => {
|
|
3734
|
+
ctx.emit("expandChange", newPath.map((o) => o.value));
|
|
3735
|
+
});
|
|
3736
|
+
return {
|
|
3737
|
+
// 状态
|
|
3738
|
+
isOpen,
|
|
3739
|
+
searchQuery,
|
|
3740
|
+
activePath,
|
|
3741
|
+
// 计算
|
|
3742
|
+
columns,
|
|
3743
|
+
filteredOptions,
|
|
3744
|
+
isSearching,
|
|
3745
|
+
selectedPath,
|
|
3746
|
+
selectedPaths,
|
|
3747
|
+
displayLabel,
|
|
3748
|
+
selectedTags,
|
|
3749
|
+
// 事件
|
|
3750
|
+
open,
|
|
3751
|
+
close,
|
|
3752
|
+
onTriggerClick,
|
|
3753
|
+
onOptionEnter,
|
|
3754
|
+
onOptionClick,
|
|
3755
|
+
onFlatOptionClick,
|
|
3756
|
+
onDeleteTag,
|
|
3757
|
+
onClear,
|
|
3758
|
+
// 工具
|
|
3759
|
+
isActiveOption,
|
|
3760
|
+
isSelectedOption,
|
|
3761
|
+
isFlatOptionSelected
|
|
3762
|
+
};
|
|
3763
|
+
}
|
|
3764
|
+
const CascaderCore = {
|
|
3765
|
+
props: props$5,
|
|
3766
|
+
useCascader
|
|
3767
|
+
};
|
|
3768
|
+
const props$4 = {
|
|
3769
|
+
modelValue: { type: Array, default: () => [] },
|
|
3770
|
+
data: { type: Array, default: () => [] },
|
|
3771
|
+
titles: { type: Array, default: () => ["源列表", "目标列表"] },
|
|
3772
|
+
filterable: { type: Boolean, default: false },
|
|
3773
|
+
filterPlaceholder: { type: String, default: "请输入搜索内容" }
|
|
3774
|
+
};
|
|
3775
|
+
function useTransfer(props2, ctx) {
|
|
3776
|
+
const dataRef = toRef(() => props2.data ?? []);
|
|
3777
|
+
const modelValueRef = toRef(() => props2.modelValue ?? []);
|
|
3778
|
+
const leftSearch = ref("");
|
|
3779
|
+
const rightSearch = ref("");
|
|
3780
|
+
const leftChecked = ref(/* @__PURE__ */ new Set());
|
|
3781
|
+
const rightChecked = ref(/* @__PURE__ */ new Set());
|
|
3782
|
+
const rightData = computed(() => {
|
|
3783
|
+
const rightKeys = new Set(modelValueRef.value);
|
|
3784
|
+
return dataRef.value.filter((item) => rightKeys.has(item.key));
|
|
3785
|
+
});
|
|
3786
|
+
const leftData = computed(() => {
|
|
3787
|
+
const rightKeys = new Set(modelValueRef.value);
|
|
3788
|
+
return dataRef.value.filter((item) => !rightKeys.has(item.key));
|
|
3789
|
+
});
|
|
3790
|
+
const filteredLeftData = computed(() => {
|
|
3791
|
+
if (!props2.filterable || !leftSearch.value) return leftData.value;
|
|
3792
|
+
const q = leftSearch.value.toLowerCase();
|
|
3793
|
+
return leftData.value.filter((item) => item.label.toLowerCase().includes(q));
|
|
3794
|
+
});
|
|
3795
|
+
const filteredRightData = computed(() => {
|
|
3796
|
+
if (!props2.filterable || !rightSearch.value) return rightData.value;
|
|
3797
|
+
const q = rightSearch.value.toLowerCase();
|
|
3798
|
+
return rightData.value.filter((item) => item.label.toLowerCase().includes(q));
|
|
3799
|
+
});
|
|
3800
|
+
const isLeftAllChecked = computed(() => {
|
|
3801
|
+
const checkable = filteredLeftData.value.filter((item) => !item.disabled);
|
|
3802
|
+
return checkable.length > 0 && checkable.every((item) => leftChecked.value.has(item.key));
|
|
3803
|
+
});
|
|
3804
|
+
const isLeftIndeterminate = computed(() => {
|
|
3805
|
+
const checkable = filteredLeftData.value.filter((item) => !item.disabled);
|
|
3806
|
+
const checkedCount = checkable.filter((item) => leftChecked.value.has(item.key)).length;
|
|
3807
|
+
return checkedCount > 0 && checkedCount < checkable.length;
|
|
3808
|
+
});
|
|
3809
|
+
const isRightAllChecked = computed(() => {
|
|
3810
|
+
const checkable = filteredRightData.value.filter((item) => !item.disabled);
|
|
3811
|
+
return checkable.length > 0 && checkable.every((item) => rightChecked.value.has(item.key));
|
|
3812
|
+
});
|
|
3813
|
+
const isRightIndeterminate = computed(() => {
|
|
3814
|
+
const checkable = filteredRightData.value.filter((item) => !item.disabled);
|
|
3815
|
+
const checkedCount = checkable.filter((item) => rightChecked.value.has(item.key)).length;
|
|
3816
|
+
return checkedCount > 0 && checkedCount < checkable.length;
|
|
3817
|
+
});
|
|
3818
|
+
const toggleLeftCheck = (key, disabled) => {
|
|
3819
|
+
if (disabled) return;
|
|
3820
|
+
const newSet = new Set(leftChecked.value);
|
|
3821
|
+
if (newSet.has(key)) {
|
|
3822
|
+
newSet.delete(key);
|
|
3823
|
+
} else {
|
|
3824
|
+
newSet.add(key);
|
|
3825
|
+
}
|
|
3826
|
+
leftChecked.value = newSet;
|
|
3827
|
+
};
|
|
3828
|
+
const toggleRightCheck = (key, disabled) => {
|
|
3829
|
+
if (disabled) return;
|
|
3830
|
+
const newSet = new Set(rightChecked.value);
|
|
3831
|
+
if (newSet.has(key)) {
|
|
3832
|
+
newSet.delete(key);
|
|
3833
|
+
} else {
|
|
3834
|
+
newSet.add(key);
|
|
3835
|
+
}
|
|
3836
|
+
rightChecked.value = newSet;
|
|
3837
|
+
};
|
|
3838
|
+
const toggleLeftAll = () => {
|
|
3839
|
+
const checkable = filteredLeftData.value.filter((item) => !item.disabled);
|
|
3840
|
+
if (isLeftAllChecked.value) {
|
|
3841
|
+
const newSet = new Set(leftChecked.value);
|
|
3842
|
+
checkable.forEach((item) => newSet.delete(item.key));
|
|
3843
|
+
leftChecked.value = newSet;
|
|
3844
|
+
} else {
|
|
3845
|
+
const newSet = new Set(leftChecked.value);
|
|
3846
|
+
checkable.forEach((item) => newSet.add(item.key));
|
|
3847
|
+
leftChecked.value = newSet;
|
|
3848
|
+
}
|
|
3849
|
+
};
|
|
3850
|
+
const toggleRightAll = () => {
|
|
3851
|
+
const checkable = filteredRightData.value.filter((item) => !item.disabled);
|
|
3852
|
+
if (isRightAllChecked.value) {
|
|
3853
|
+
const newSet = new Set(rightChecked.value);
|
|
3854
|
+
checkable.forEach((item) => newSet.delete(item.key));
|
|
3855
|
+
rightChecked.value = newSet;
|
|
3856
|
+
} else {
|
|
3857
|
+
const newSet = new Set(rightChecked.value);
|
|
3858
|
+
checkable.forEach((item) => newSet.add(item.key));
|
|
3859
|
+
rightChecked.value = newSet;
|
|
3860
|
+
}
|
|
3861
|
+
};
|
|
3862
|
+
const moveToRight = () => {
|
|
3863
|
+
if (!leftChecked.value.size) return;
|
|
3864
|
+
const movedKeys = [...leftChecked.value];
|
|
3865
|
+
const newModelValue = [...modelValueRef.value, ...movedKeys];
|
|
3866
|
+
ctx.emit("update:modelValue", newModelValue);
|
|
3867
|
+
ctx.emit("change", newModelValue, "right", movedKeys);
|
|
3868
|
+
leftChecked.value = /* @__PURE__ */ new Set();
|
|
3869
|
+
};
|
|
3870
|
+
const moveToLeft = () => {
|
|
3871
|
+
if (!rightChecked.value.size) return;
|
|
3872
|
+
const movedKeys = [...rightChecked.value];
|
|
3873
|
+
const movedSet = new Set(movedKeys);
|
|
3874
|
+
const newModelValue = modelValueRef.value.filter((key) => !movedSet.has(key));
|
|
3875
|
+
ctx.emit("update:modelValue", newModelValue);
|
|
3876
|
+
ctx.emit("change", newModelValue, "left", movedKeys);
|
|
3877
|
+
rightChecked.value = /* @__PURE__ */ new Set();
|
|
3878
|
+
};
|
|
3879
|
+
const hasLeftChecked = computed(() => leftChecked.value.size > 0);
|
|
3880
|
+
const hasRightChecked = computed(() => rightChecked.value.size > 0);
|
|
3881
|
+
return {
|
|
3882
|
+
// 搜索
|
|
3883
|
+
leftSearch,
|
|
3884
|
+
rightSearch,
|
|
3885
|
+
// 数据
|
|
3886
|
+
leftData,
|
|
3887
|
+
rightData,
|
|
3888
|
+
filteredLeftData,
|
|
3889
|
+
filteredRightData,
|
|
3890
|
+
// 勾选状态
|
|
3891
|
+
leftChecked,
|
|
3892
|
+
rightChecked,
|
|
3893
|
+
hasLeftChecked,
|
|
3894
|
+
hasRightChecked,
|
|
3895
|
+
// 全选
|
|
3896
|
+
isLeftAllChecked,
|
|
3897
|
+
isLeftIndeterminate,
|
|
3898
|
+
isRightAllChecked,
|
|
3899
|
+
isRightIndeterminate,
|
|
3900
|
+
// 事件
|
|
3901
|
+
toggleLeftCheck,
|
|
3902
|
+
toggleRightCheck,
|
|
3903
|
+
toggleLeftAll,
|
|
3904
|
+
toggleRightAll,
|
|
3905
|
+
moveToRight,
|
|
3906
|
+
moveToLeft
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
const TransferCore = {
|
|
3910
|
+
props: props$4,
|
|
3911
|
+
useTransfer
|
|
3912
|
+
};
|
|
3913
|
+
const props$3 = {
|
|
3914
|
+
modelValue: { type: Number, default: 0 },
|
|
3915
|
+
count: { type: Number, default: 5 },
|
|
3916
|
+
allowHalf: { type: Boolean, default: false },
|
|
3917
|
+
readonly: { type: Boolean, default: false },
|
|
3918
|
+
disabled: { type: Boolean, default: false }
|
|
3919
|
+
};
|
|
3920
|
+
function useRate(props2, emit) {
|
|
3921
|
+
const hoverValue = ref(null);
|
|
3922
|
+
const getValueFromEvent = (e, index) => {
|
|
3923
|
+
if (!props2.allowHalf) {
|
|
3924
|
+
return index + 1;
|
|
3925
|
+
}
|
|
3926
|
+
const target = e.currentTarget;
|
|
3927
|
+
const { left, width } = target.getBoundingClientRect();
|
|
3928
|
+
const isHalf = (e.clientX - left) / width <= 0.5;
|
|
3929
|
+
return isHalf ? index + 0.5 : index + 1;
|
|
3930
|
+
};
|
|
3931
|
+
const onMouseEnter = (e, index) => {
|
|
3932
|
+
if (props2.disabled || props2.readonly) {
|
|
3933
|
+
return;
|
|
3934
|
+
}
|
|
3935
|
+
hoverValue.value = getValueFromEvent(e, index);
|
|
3936
|
+
};
|
|
3937
|
+
const onMouseMove = (e, index) => {
|
|
3938
|
+
if (props2.disabled || props2.readonly) {
|
|
3939
|
+
return;
|
|
3940
|
+
}
|
|
3941
|
+
hoverValue.value = getValueFromEvent(e, index);
|
|
3942
|
+
};
|
|
3943
|
+
const onMouseLeave = () => {
|
|
3944
|
+
if (props2.disabled || props2.readonly) {
|
|
3945
|
+
return;
|
|
3946
|
+
}
|
|
3947
|
+
hoverValue.value = null;
|
|
3948
|
+
};
|
|
3949
|
+
const onClick = (e, index) => {
|
|
3950
|
+
if (props2.disabled || props2.readonly) {
|
|
3951
|
+
return;
|
|
3952
|
+
}
|
|
3953
|
+
const value = getValueFromEvent(e, index);
|
|
3954
|
+
emit("update:modelValue", value);
|
|
3955
|
+
emit("change", value);
|
|
3956
|
+
};
|
|
3957
|
+
const getStarState = (index) => {
|
|
3958
|
+
const current = hoverValue.value ?? props2.modelValue;
|
|
3959
|
+
const starValue = index + 1;
|
|
3960
|
+
if (current >= starValue) {
|
|
3961
|
+
return "full";
|
|
3962
|
+
}
|
|
3963
|
+
if (props2.allowHalf && current >= starValue - 0.5) {
|
|
3964
|
+
return "half";
|
|
3965
|
+
}
|
|
3966
|
+
return "empty";
|
|
3967
|
+
};
|
|
3968
|
+
return {
|
|
3969
|
+
hoverValue,
|
|
3970
|
+
getStarState,
|
|
3971
|
+
onMouseEnter,
|
|
3972
|
+
onMouseMove,
|
|
3973
|
+
onMouseLeave,
|
|
3974
|
+
onClick
|
|
3975
|
+
};
|
|
3976
|
+
}
|
|
3977
|
+
const RateCore = {
|
|
3978
|
+
props: props$3,
|
|
3979
|
+
useRate
|
|
3980
|
+
};
|
|
3981
|
+
const props$2 = {
|
|
3982
|
+
target: { type: String, default: "" },
|
|
3983
|
+
visibilityHeight: { type: Number, default: 200 },
|
|
3984
|
+
right: { type: Number, default: 40 },
|
|
3985
|
+
bottom: { type: Number, default: 40 }
|
|
3986
|
+
};
|
|
3987
|
+
function useBackTop(props2) {
|
|
3988
|
+
const visible = ref(false);
|
|
3989
|
+
const getScrollTarget = () => {
|
|
3990
|
+
if (props2.target) {
|
|
3991
|
+
const el = document.querySelector(props2.target);
|
|
3992
|
+
if (el) {
|
|
3993
|
+
return el;
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
return window;
|
|
3997
|
+
};
|
|
3998
|
+
const getScrollTop = () => {
|
|
3999
|
+
const target = getScrollTarget();
|
|
4000
|
+
if (target === window) {
|
|
4001
|
+
return window.scrollY;
|
|
4002
|
+
}
|
|
4003
|
+
return target.scrollTop;
|
|
4004
|
+
};
|
|
4005
|
+
const onScroll = () => {
|
|
4006
|
+
visible.value = getScrollTop() >= props2.visibilityHeight;
|
|
4007
|
+
};
|
|
4008
|
+
const scrollToTop = () => {
|
|
4009
|
+
const target = getScrollTarget();
|
|
4010
|
+
if (target === window) {
|
|
4011
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
4012
|
+
} else {
|
|
4013
|
+
target.scrollTo({ top: 0, behavior: "smooth" });
|
|
4014
|
+
}
|
|
4015
|
+
};
|
|
4016
|
+
onMounted(() => {
|
|
4017
|
+
const target = getScrollTarget();
|
|
4018
|
+
target.addEventListener("scroll", onScroll, { passive: true });
|
|
4019
|
+
onScroll();
|
|
4020
|
+
});
|
|
4021
|
+
onUnmounted(() => {
|
|
4022
|
+
const target = getScrollTarget();
|
|
4023
|
+
target.removeEventListener("scroll", onScroll);
|
|
4024
|
+
});
|
|
4025
|
+
return {
|
|
4026
|
+
visible,
|
|
4027
|
+
scrollToTop
|
|
4028
|
+
};
|
|
4029
|
+
}
|
|
4030
|
+
const BackTopCore = {
|
|
4031
|
+
props: props$2,
|
|
4032
|
+
useBackTop
|
|
4033
|
+
};
|
|
4034
|
+
const props$1 = {
|
|
4035
|
+
offsetTop: { type: Number, default: void 0 },
|
|
4036
|
+
offsetBottom: { type: Number, default: void 0 },
|
|
4037
|
+
target: { type: String, default: "" }
|
|
4038
|
+
};
|
|
4039
|
+
function useAffix(props2, emit) {
|
|
4040
|
+
const affixed = ref(false);
|
|
4041
|
+
const placeholderHeight = ref(0);
|
|
4042
|
+
const affixStyle = ref({});
|
|
4043
|
+
const wrapRef = ref(null);
|
|
4044
|
+
const getScrollTarget = () => {
|
|
4045
|
+
if (props2.target) {
|
|
4046
|
+
const el = document.querySelector(props2.target);
|
|
4047
|
+
if (el) {
|
|
4048
|
+
return el;
|
|
4049
|
+
}
|
|
4050
|
+
}
|
|
4051
|
+
return window;
|
|
4052
|
+
};
|
|
4053
|
+
const getContainerRect = () => {
|
|
4054
|
+
const t = getScrollTarget();
|
|
4055
|
+
if (t === window) {
|
|
4056
|
+
return new DOMRect(0, 0, window.innerWidth, window.innerHeight);
|
|
4057
|
+
}
|
|
4058
|
+
return t.getBoundingClientRect();
|
|
4059
|
+
};
|
|
4060
|
+
const update = () => {
|
|
4061
|
+
if (!wrapRef.value) {
|
|
4062
|
+
return;
|
|
4063
|
+
}
|
|
4064
|
+
const wrapRect = wrapRef.value.getBoundingClientRect();
|
|
4065
|
+
const containerRect = getContainerRect();
|
|
4066
|
+
let shouldAffix = false;
|
|
4067
|
+
const style = {};
|
|
4068
|
+
if (props2.offsetTop !== void 0) {
|
|
4069
|
+
const threshold = containerRect.top + props2.offsetTop;
|
|
4070
|
+
if (wrapRect.top < threshold) {
|
|
4071
|
+
shouldAffix = true;
|
|
4072
|
+
style.position = "fixed";
|
|
4073
|
+
style.top = `${containerRect.top + props2.offsetTop}px`;
|
|
4074
|
+
style.width = `${wrapRect.width}px`;
|
|
4075
|
+
style.zIndex = "100";
|
|
4076
|
+
}
|
|
4077
|
+
} else if (props2.offsetBottom !== void 0) {
|
|
4078
|
+
const threshold = containerRect.bottom - props2.offsetBottom;
|
|
4079
|
+
if (wrapRect.bottom > threshold) {
|
|
4080
|
+
shouldAffix = true;
|
|
4081
|
+
style.position = "fixed";
|
|
4082
|
+
style.bottom = `${window.innerHeight - containerRect.bottom + props2.offsetBottom}px`;
|
|
4083
|
+
style.width = `${wrapRect.width}px`;
|
|
4084
|
+
style.zIndex = "100";
|
|
4085
|
+
}
|
|
4086
|
+
}
|
|
4087
|
+
if (shouldAffix !== affixed.value) {
|
|
4088
|
+
if (shouldAffix) {
|
|
4089
|
+
placeholderHeight.value = wrapRect.height;
|
|
4090
|
+
} else {
|
|
4091
|
+
placeholderHeight.value = 0;
|
|
4092
|
+
}
|
|
4093
|
+
affixed.value = shouldAffix;
|
|
4094
|
+
emit("change", shouldAffix);
|
|
4095
|
+
}
|
|
4096
|
+
affixStyle.value = shouldAffix ? style : {};
|
|
4097
|
+
};
|
|
4098
|
+
onMounted(() => {
|
|
4099
|
+
const target = getScrollTarget();
|
|
4100
|
+
target.addEventListener("scroll", update, { passive: true });
|
|
4101
|
+
window.addEventListener("resize", update, { passive: true });
|
|
4102
|
+
update();
|
|
4103
|
+
});
|
|
4104
|
+
onUnmounted(() => {
|
|
4105
|
+
const target = getScrollTarget();
|
|
4106
|
+
target.removeEventListener("scroll", update);
|
|
4107
|
+
window.removeEventListener("resize", update);
|
|
4108
|
+
});
|
|
4109
|
+
return {
|
|
4110
|
+
wrapRef,
|
|
4111
|
+
affixed,
|
|
4112
|
+
affixStyle,
|
|
4113
|
+
placeholderHeight
|
|
4114
|
+
};
|
|
4115
|
+
}
|
|
4116
|
+
const AffixCore = {
|
|
4117
|
+
props: props$1,
|
|
4118
|
+
useAffix
|
|
4119
|
+
};
|
|
4120
|
+
const props = {
|
|
4121
|
+
offsetTop: { type: Number, default: 0 },
|
|
4122
|
+
bounds: { type: Number, default: 5 }
|
|
4123
|
+
};
|
|
4124
|
+
const anchorLinkProps = {
|
|
4125
|
+
href: { type: String, required: true },
|
|
4126
|
+
title: { type: String, default: "" }
|
|
4127
|
+
};
|
|
4128
|
+
function useAnchor(props2, emit) {
|
|
4129
|
+
const currentLink = ref("");
|
|
4130
|
+
const links = ref([]);
|
|
4131
|
+
const registerLink = (href) => {
|
|
4132
|
+
if (!links.value.includes(href)) {
|
|
4133
|
+
links.value.push(href);
|
|
4134
|
+
}
|
|
4135
|
+
};
|
|
4136
|
+
const unregisterLink = (href) => {
|
|
4137
|
+
const idx = links.value.indexOf(href);
|
|
4138
|
+
if (idx !== -1) {
|
|
4139
|
+
links.value.splice(idx, 1);
|
|
4140
|
+
}
|
|
4141
|
+
};
|
|
4142
|
+
const getTargetEl = (href) => {
|
|
4143
|
+
if (!href.startsWith("#")) {
|
|
4144
|
+
return null;
|
|
4145
|
+
}
|
|
4146
|
+
return document.querySelector(href);
|
|
4147
|
+
};
|
|
4148
|
+
const onScroll = () => {
|
|
4149
|
+
const scrollTop = window.scrollY + props2.offsetTop + props2.bounds;
|
|
4150
|
+
let active = "";
|
|
4151
|
+
for (let i = links.value.length - 1; i >= 0; i--) {
|
|
4152
|
+
const href = links.value[i];
|
|
4153
|
+
const el = getTargetEl(href);
|
|
4154
|
+
if (el && el.offsetTop <= scrollTop) {
|
|
4155
|
+
active = href;
|
|
4156
|
+
break;
|
|
4157
|
+
}
|
|
4158
|
+
}
|
|
4159
|
+
if (active !== currentLink.value) {
|
|
4160
|
+
currentLink.value = active;
|
|
4161
|
+
emit("change", active);
|
|
4162
|
+
}
|
|
4163
|
+
};
|
|
4164
|
+
const handleClick = (href) => {
|
|
4165
|
+
emit("click", href);
|
|
4166
|
+
const el = getTargetEl(href);
|
|
4167
|
+
if (el) {
|
|
4168
|
+
const top = el.offsetTop - props2.offsetTop;
|
|
4169
|
+
window.scrollTo({ top, behavior: "smooth" });
|
|
4170
|
+
}
|
|
4171
|
+
};
|
|
4172
|
+
onMounted(() => {
|
|
4173
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
4174
|
+
onScroll();
|
|
4175
|
+
});
|
|
4176
|
+
onUnmounted(() => {
|
|
4177
|
+
window.removeEventListener("scroll", onScroll);
|
|
4178
|
+
});
|
|
4179
|
+
return {
|
|
4180
|
+
currentLink,
|
|
4181
|
+
registerLink,
|
|
4182
|
+
unregisterLink,
|
|
4183
|
+
handleClick
|
|
4184
|
+
};
|
|
4185
|
+
}
|
|
4186
|
+
const AnchorCore = {
|
|
4187
|
+
props,
|
|
4188
|
+
anchorLinkProps,
|
|
4189
|
+
useAnchor
|
|
4190
|
+
};
|
|
4191
|
+
export {
|
|
4192
|
+
AffixCore,
|
|
4193
|
+
AlertCore,
|
|
4194
|
+
AnchorCore,
|
|
4195
|
+
AutoCompleteCore,
|
|
4196
|
+
AvatarCore,
|
|
4197
|
+
BASE_MONTH_NAME,
|
|
4198
|
+
BASE_WEEK_NAME,
|
|
4199
|
+
BackTopCore,
|
|
4200
|
+
BadgeCore,
|
|
4201
|
+
BorderCore,
|
|
4202
|
+
BreadcrumbCore,
|
|
4203
|
+
ButtonCore,
|
|
4204
|
+
CardCore,
|
|
4205
|
+
CarouselCore,
|
|
4206
|
+
CascaderCore,
|
|
4207
|
+
CheckboxCore,
|
|
4208
|
+
CollapseCore,
|
|
4209
|
+
ConfirmCore,
|
|
4210
|
+
DEFAULT_MENU_CONFIG,
|
|
4211
|
+
DEFAULT_TREE_CONFIG,
|
|
4212
|
+
DarkModeCore,
|
|
4213
|
+
DatePickerCore,
|
|
4214
|
+
DescriptionsCore,
|
|
4215
|
+
DialogCore,
|
|
4216
|
+
DividerCore,
|
|
4217
|
+
DrawerCore,
|
|
4218
|
+
DropdownCore,
|
|
4219
|
+
EmptyCore,
|
|
4220
|
+
FormCore,
|
|
4221
|
+
GridCore,
|
|
4222
|
+
ImageCore,
|
|
4223
|
+
InputCore,
|
|
4224
|
+
InputNumberCore,
|
|
4225
|
+
LiCore,
|
|
4226
|
+
ListCore,
|
|
4227
|
+
LoadingCore,
|
|
4228
|
+
MenuCore,
|
|
4229
|
+
MessageCore,
|
|
4230
|
+
MessagePopoverCore,
|
|
4231
|
+
NotificationCore,
|
|
4232
|
+
PaginationCore,
|
|
4233
|
+
PopoverCore,
|
|
4234
|
+
ProgressCore,
|
|
4235
|
+
RadioCore,
|
|
4236
|
+
RateCore,
|
|
4237
|
+
ResultCore,
|
|
4238
|
+
SelectCore,
|
|
4239
|
+
SkeletonCore,
|
|
4240
|
+
SliderCore,
|
|
4241
|
+
SpaceCore,
|
|
4242
|
+
StepsCore,
|
|
4243
|
+
SwitchCore,
|
|
4244
|
+
TableColumnCore,
|
|
4245
|
+
TableCore,
|
|
4246
|
+
TabsCore,
|
|
4247
|
+
TagCore,
|
|
4248
|
+
TimelineCore,
|
|
4249
|
+
TooltipCore,
|
|
4250
|
+
TransferCore,
|
|
4251
|
+
Tree,
|
|
4252
|
+
TreeCore,
|
|
4253
|
+
VirtualListCore,
|
|
4254
|
+
createRadioId,
|
|
4255
|
+
fixKey,
|
|
4256
|
+
generateTimeColumn,
|
|
4257
|
+
getNewModelValue,
|
|
4258
|
+
initChecked,
|
|
4259
|
+
toDayjs,
|
|
4260
|
+
treeNodeProps,
|
|
4261
|
+
props$o as treeProps,
|
|
4262
|
+
useDatePicker,
|
|
4263
|
+
useMenu,
|
|
4264
|
+
useMessageQueue,
|
|
4265
|
+
useNotificationQueue,
|
|
4266
|
+
usePagination,
|
|
4267
|
+
useTable,
|
|
4268
|
+
useTree,
|
|
4269
|
+
useVirtualList
|
|
4270
|
+
};
|