@opentiny/vue-renderless 3.9.2 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action-sheet/vue.js +25 -2
- package/anchor/index.js +3 -3
- package/anchor/vue.js +7 -1
- package/area/index.js +4 -4
- package/button/vue.js +4 -2
- package/button-group/index.js +8 -1
- package/button-group/vue.js +5 -10
- package/calendar/index.js +14 -14
- package/calendar-bar/index.js +3 -3
- package/carousel-item/index.js +1 -1
- package/cascader/vue.js +1 -1
- package/cascader-mobile/index.js +299 -0
- package/cascader-mobile/vue.js +102 -0
- package/cascader-panel/store.js +3 -1
- package/chart-boxplot/index.js +0 -1
- package/chart-core/deps/constants.js +20 -2
- package/chart-core/index.js +9 -1
- package/chart-core/modules/extend.js +14 -1
- package/chart-gauge/index.js +3 -1
- package/chart-graph/index.js +3 -1
- package/chart-map/index.js +11 -1
- package/chart-scatter/index.js +10 -2
- package/chart-waterfall/index.js +4 -1
- package/checkbox/index.js +16 -14
- package/checkbox/vue.js +14 -10
- package/checkbox-button/vue.js +7 -3
- package/column-list-item/vue.js +10 -1
- package/common/bigInt.js +4 -11
- package/common/date.js +2 -2
- package/common/deps/ResizeObserver.js +3 -1
- package/common/deps/date-util.js +9 -1
- package/common/deps/date.js +18 -5
- package/common/deps/fastdom/async.js +41 -0
- package/common/deps/fastdom/index.js +9 -0
- package/common/deps/fastdom/sandbox.js +53 -0
- package/common/deps/fastdom/singleton.js +80 -0
- package/common/deps/fullscreen/screenfull.js +16 -2
- package/common/deps/memorize.js +3 -3
- package/common/deps/popup-manager.js +0 -1
- package/common/deps/requestAnimationFrame.js +1 -1
- package/common/deps/throttle.js +2 -2
- package/common/deps/tree-model/node.js +23 -11
- package/common/deps/tree-model/tree-store.js +28 -7
- package/common/deps/vue-popper.js +14 -2
- package/common/deps/vue-popup.js +16 -23
- package/common/index.js +7 -35
- package/common/runtime.js +1 -1
- package/common/validate/rules/type.js +3 -1
- package/credit-card-form/vue.js +2 -2
- package/date-panel/index.js +35 -31
- package/date-panel/vue.js +12 -12
- package/date-picker/index.js +9 -5
- package/date-picker/vue.js +20 -8
- package/date-picker-mobile/index.js +3 -3
- package/date-range/index.js +91 -19
- package/date-range/vue.js +19 -11
- package/date-table/index.js +39 -6
- package/date-table/vue.js +2 -2
- package/dept/index.js +1 -1
- package/detail-page/vue.js +9 -1
- package/dialog-box/index.js +11 -2
- package/dialog-box/vue.js +30 -6
- package/dialog-select/index.js +27 -5
- package/dialog-select/vue.js +11 -4
- package/drop-roles/index.js +3 -1
- package/dropdown/index.js +28 -7
- package/dropdown/vue.js +12 -7
- package/dropdown-item/index.js +9 -1
- package/dropdown-item/mf.js +3 -3
- package/dropdown-item/vue.js +12 -10
- package/dropdown-menu/index.js +13 -14
- package/dropdown-menu/vue.js +8 -7
- package/espace/vue.js +9 -1
- package/fall-menu/vue.js +12 -1
- package/file-upload/index.js +137 -89
- package/file-upload/vue.js +24 -14
- package/filter/index.js +1 -1
- package/filter/vue.js +1 -3
- package/floating-button/index.js +73 -0
- package/floating-button/vue.js +35 -0
- package/form/index.js +13 -4
- package/form/vue.js +7 -2
- package/form-item/index.js +4 -1
- package/form-item/vue.js +6 -3
- package/fullscreen/vue.js +24 -3
- package/grid/plugins/exportExcel.js +54 -8
- package/grid/static/base/helperGetHGSKeys.js +1 -4
- package/grid/utils/common.js +15 -11
- package/grid/utils/dom.js +5 -1
- package/guide/index.js +2 -3
- package/hrapprover/index.js +3 -1
- package/index-bar/vue.js +8 -1
- package/input/index.js +1 -11
- package/input/vue.js +6 -12
- package/ip-address/index.js +66 -33
- package/ip-address/vue.js +8 -1
- package/link-menu/vue.js +22 -2
- package/locales/index.js +4 -2
- package/logon-user/index.js +3 -1
- package/logout/index.js +6 -2
- package/milestone/vue.js +1 -1
- package/mini-picker/index.js +12 -10
- package/mini-picker/vue.js +10 -10
- package/modal/index.js +5 -3
- package/modal/vue.js +4 -2
- package/month-range/index.js +18 -18
- package/month-range/vue.js +16 -4
- package/month-table/index.js +7 -3
- package/multi-select/vue.js +1 -9
- package/nav-menu/index.js +33 -4
- package/nav-menu/vue.js +9 -1
- package/notify/vue.js +12 -1
- package/numeric/vue.js +6 -2
- package/option/index.js +10 -2
- package/option/vue.js +20 -9
- package/option-group/index.js +3 -1
- package/package.json +2 -1
- package/picker/index.js +88 -17
- package/picker/vue.js +42 -17
- package/picker-column/index.js +6 -6
- package/picker-column/vue.js +5 -5
- package/popconfirm/vue.js +3 -1
- package/popeditor/index.js +55 -13
- package/popeditor/vue.js +23 -7
- package/popover/vue.js +1 -2
- package/popup/vue.js +15 -2
- package/progress/index.js +9 -7
- package/progress/vue.js +12 -4
- package/pull-refresh/vue.js +10 -1
- package/query-builder/index.js +9 -0
- package/query-builder/vue.js +18 -0
- package/radio/vue.js +3 -1
- package/radio-button/vue.js +1 -1
- package/rate/index.js +8 -2
- package/rate/vue.js +27 -4
- package/recycle-scroller/index.js +0 -1
- package/scrollbar/vue-bar.js +18 -2
- package/search/index.js +12 -5
- package/search/vue.js +7 -5
- package/select/index.js +596 -304
- package/select/vue.js +167 -101
- package/select-dropdown/vue.js +8 -6
- package/select-mobile/index.js +26 -13
- package/select-mobile/vue.js +14 -5
- package/select-view/index.js +5 -21
- package/select-view/vue.js +0 -3
- package/selected-box/index.js +3 -1
- package/slider/index.js +5 -5
- package/slider/vue.js +16 -0
- package/slider-button/index.js +41 -0
- package/slider-button/vue.js +36 -0
- package/slider-button-group/slide-button.js +142 -0
- package/slider-button-group/vue.js +52 -0
- package/steps/slide-bar.js +0 -1
- package/switch/index.js +1 -1
- package/switch/vue.js +1 -1
- package/tab-bar/index.js +8 -6
- package/tab-nav/index.js +19 -13
- package/tab-nav/vue.js +10 -9
- package/tabs/index.js +21 -17
- package/tabs/vue.js +1 -4
- package/tag/vue.js +2 -1
- package/tag-group/index.js +23 -10
- package/tag-group/vue.js +5 -4
- package/time/index.js +8 -8
- package/time/vue.js +9 -9
- package/time-line/index.js +24 -2
- package/time-line/vue.js +30 -4
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +2 -2
- package/time-range/index.js +24 -21
- package/time-range/vue.js +26 -16
- package/time-spinner/index.js +32 -21
- package/time-spinner/vue.js +37 -12
- package/timeline-item/index.js +77 -0
- package/timeline-item/vue.js +44 -0
- package/toggle-menu/vue.js +0 -1
- package/tooltip/index.js +11 -12
- package/tooltip/vue.js +11 -1
- package/top-box/vue.js +13 -1
- package/tree/index.js +228 -15
- package/tree/vue.js +119 -15
- package/tree-menu/index.js +35 -0
- package/tree-menu/vue.js +27 -5
- package/tree-node/index.js +75 -10
- package/tree-node/vue.js +45 -23
- package/upload/index.js +90 -49
- package/upload/vue.js +22 -10
- package/upload-dragger/index.js +4 -3
- package/upload-list/index.js +67 -16
- package/upload-list/vue.js +26 -9
- package/user/index.js +7 -4
- package/user-link/index.js +2 -1
- package/wizard/index.js +4 -1
- package/wizard/vue.js +19 -2
- package/year-range/index.js +1 -1
- package/year-range/vue.js +3 -3
- package/year-table/index.js +2 -2
package/time-spinner/vue.js
CHANGED
|
@@ -19,7 +19,16 @@ import {
|
|
|
19
19
|
emitSelectRange
|
|
20
20
|
} from "./index";
|
|
21
21
|
import { getRangeHours, getRangeMinutes } from "../common/deps/date-util";
|
|
22
|
-
const api = [
|
|
22
|
+
const api = [
|
|
23
|
+
"state",
|
|
24
|
+
"emitSelectRange",
|
|
25
|
+
"adjustCurrentSpinner",
|
|
26
|
+
"handleClick",
|
|
27
|
+
"decrease",
|
|
28
|
+
"increase",
|
|
29
|
+
"amPm",
|
|
30
|
+
"adjustSpinners"
|
|
31
|
+
];
|
|
23
32
|
const initState = ({ reactive, computed, props, api: api2 }) => {
|
|
24
33
|
const state = reactive({
|
|
25
34
|
selectableRange: [],
|
|
@@ -27,16 +36,28 @@ const initState = ({ reactive, computed, props, api: api2 }) => {
|
|
|
27
36
|
hours: computed(() => props.date.getHours()),
|
|
28
37
|
minutes: computed(() => props.date.getMinutes()),
|
|
29
38
|
seconds: computed(() => props.date.getSeconds()),
|
|
30
|
-
hoursList: computed(
|
|
31
|
-
|
|
39
|
+
hoursList: computed(
|
|
40
|
+
() => Array.from(getRangeHours(state.selectableRange)).map((disabled, hour) => ({ disabled, hour })).filter(({ hour }) => !(hour % state.step.hours))
|
|
41
|
+
),
|
|
42
|
+
minutesList: computed(
|
|
43
|
+
() => Array.from(getRangeMinutes(state.selectableRange, state.hours)).map((disabled, minute) => ({ disabled, minute })).filter(({ minute }) => !(minute % state.step.minutes))
|
|
44
|
+
),
|
|
45
|
+
secondsList: computed(
|
|
46
|
+
() => Array.from(new Array(60)).map((item, second) => ({ second })).filter(({ second }) => !(second % state.step.seconds))
|
|
47
|
+
),
|
|
32
48
|
arrowHourList: computed(() => api2.getArrowHourList()),
|
|
33
49
|
arrowMinuteList: computed(() => api2.getArrowMinuteList()),
|
|
34
50
|
arrowSecondList: computed(() => api2.getArrowSecondList()),
|
|
35
|
-
animationName: ""
|
|
51
|
+
animationName: "",
|
|
52
|
+
step: computed(() => ({
|
|
53
|
+
hours: props.step.hour * 1 || 1,
|
|
54
|
+
minutes: props.step.minute * 1 || 1,
|
|
55
|
+
seconds: props.step.second * 1 || 1
|
|
56
|
+
}))
|
|
36
57
|
});
|
|
37
58
|
return state;
|
|
38
59
|
};
|
|
39
|
-
const renderless = (props, { computed, onMounted, reactive, watch, nextTick }, { emit,
|
|
60
|
+
const renderless = (props, { computed, onMounted, reactive, watch, nextTick }, { emit, vm, constants }) => {
|
|
40
61
|
const api2 = {};
|
|
41
62
|
const state = initState({ reactive, computed, props, api: api2 });
|
|
42
63
|
onMounted(() => {
|
|
@@ -45,26 +66,30 @@ const renderless = (props, { computed, onMounted, reactive, watch, nextTick }, {
|
|
|
45
66
|
Object.assign(api2, {
|
|
46
67
|
state,
|
|
47
68
|
amPm: amPm(props),
|
|
48
|
-
typeItemHeight: typeItemHeight({
|
|
49
|
-
scrollBarHeight: scrollBarHeight(
|
|
69
|
+
typeItemHeight: typeItemHeight({ vm }),
|
|
70
|
+
scrollBarHeight: scrollBarHeight(vm),
|
|
50
71
|
getArrowHourList: getArrowHourList(state),
|
|
51
72
|
getArrowSecondList: getArrowSecondList(state),
|
|
52
73
|
getArrowMinuteList: getArrowMinuteList(state),
|
|
53
74
|
emitSelectRange: emitSelectRange({ emit, state }),
|
|
54
75
|
modifyDateField: modifyDateField({ emit, props, state }),
|
|
55
|
-
bindScrollEvent: bindScrollEvent({ api: api2,
|
|
76
|
+
bindScrollEvent: bindScrollEvent({ api: api2, vm }),
|
|
56
77
|
adjustSpinners: adjustSpinners({ api: api2, state }),
|
|
57
|
-
adjustSpinner: adjustSpinner({ api: api2, props,
|
|
58
|
-
increase: increase(api2),
|
|
59
|
-
decrease: decrease(api2),
|
|
78
|
+
adjustSpinner: adjustSpinner({ api: api2, props, vm, state }),
|
|
79
|
+
increase: increase(api2, state),
|
|
80
|
+
decrease: decrease(api2, state),
|
|
60
81
|
handleClick: handleClick(api2),
|
|
61
82
|
scrollDown: scrollDown({ api: api2, state }),
|
|
62
|
-
handleScroll: handleScroll({ api: api2,
|
|
83
|
+
handleScroll: handleScroll({ api: api2, vm, state }),
|
|
63
84
|
adjustCurrentSpinner: adjustCurrentSpinner({ api: api2, state })
|
|
64
85
|
});
|
|
65
86
|
watch(
|
|
66
87
|
() => props.date,
|
|
67
88
|
() => {
|
|
89
|
+
const timeType = ["hours", "minutes", "seconds"];
|
|
90
|
+
timeType.forEach((type) => {
|
|
91
|
+
api2.modifyDateField(type, Math.round(state[type] / state.step[type]) * state.step[type]);
|
|
92
|
+
});
|
|
68
93
|
nextTick(api2.adjustSpinners);
|
|
69
94
|
},
|
|
70
95
|
{ immediate: true }
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
import { format } from "../common/date";
|
|
3
|
+
const getDate = (dateTime) => ({
|
|
4
|
+
date: format(dateTime, "yyyy-MM-dd"),
|
|
5
|
+
time: format(dateTime, "hh:mm")
|
|
6
|
+
});
|
|
7
|
+
const getStatus = ({ state, t }) => (value) => {
|
|
8
|
+
const status = state.current - value;
|
|
9
|
+
return status > 0 ? t("ui.steps.done") : status === 0 ? t("ui.steps.doing") : t("ui.steps.wait");
|
|
10
|
+
};
|
|
11
|
+
const computedSpace = ({ props, api }) => () => {
|
|
12
|
+
const space = props.space || api.rootProps.space;
|
|
13
|
+
if (/^\d+$/.test(space)) {
|
|
14
|
+
return `${space}px`;
|
|
15
|
+
}
|
|
16
|
+
return space;
|
|
17
|
+
};
|
|
18
|
+
const handleClick = ({ emit, state }) => (node) => {
|
|
19
|
+
const { index } = node || {};
|
|
20
|
+
if (!node.disabled) {
|
|
21
|
+
emit("click", state.isReverse ? state.nodesLength - index - 1 : index, node);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const getStatusCls = ({ constants, state }) => (node) => {
|
|
25
|
+
const { index } = node || {};
|
|
26
|
+
const { PROCESS_DONE_CLS, PROCESS_CUR_CLS, PROCESS_WAIT_CLS, PROCESS_DISABLED_CLS, PROCESS_ERROR_CLS } = constants;
|
|
27
|
+
const cls = {};
|
|
28
|
+
const reverse = state.isReverse;
|
|
29
|
+
if (node == null ? void 0 : node.disabled) {
|
|
30
|
+
cls[PROCESS_DISABLED_CLS] = true;
|
|
31
|
+
} else if (node == null ? void 0 : node.error) {
|
|
32
|
+
cls[PROCESS_ERROR_CLS] = true;
|
|
33
|
+
} else {
|
|
34
|
+
cls[PROCESS_DONE_CLS] = reverse ? index > state.current : index < state.current;
|
|
35
|
+
cls[PROCESS_CUR_CLS] = index === state.current;
|
|
36
|
+
cls[PROCESS_WAIT_CLS] = reverse ? index < state.current : index > state.current;
|
|
37
|
+
}
|
|
38
|
+
return cls;
|
|
39
|
+
};
|
|
40
|
+
const computedCurrent = ({ state, api }) => () => state.isReverse ? state.nodesLength - api.rootProps.active - 1 : api.rootProps.active;
|
|
41
|
+
const computedIsReverse = (api) => () => api.rootProps.reverse && api.rootProps.vertical;
|
|
42
|
+
const computedItemCls = ({ props, api }) => () => {
|
|
43
|
+
const itemClass = [];
|
|
44
|
+
if (api.rootProps.vertical) {
|
|
45
|
+
itemClass.push("timeline");
|
|
46
|
+
} else {
|
|
47
|
+
itemClass.push("normal");
|
|
48
|
+
}
|
|
49
|
+
itemClass.push(api.getStatusCls(props.node));
|
|
50
|
+
return itemClass;
|
|
51
|
+
};
|
|
52
|
+
const computedItemStyle = ({ props, state, api }) => () => {
|
|
53
|
+
const { index } = props.node;
|
|
54
|
+
const { computedSpace: computedSpace2, nodesLength } = state;
|
|
55
|
+
const { textPosition, vertical } = api.rootProps;
|
|
56
|
+
if (vertical) {
|
|
57
|
+
return { height: index === nodesLength - 1 ? "" : computedSpace2 || "88px" };
|
|
58
|
+
}
|
|
59
|
+
if (textPosition === "right") {
|
|
60
|
+
if (computedSpace2) {
|
|
61
|
+
return { flex: `0 0 ${computedSpace2}` };
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return { width: computedSpace2 || 100 / nodesLength + "%" };
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
computedCurrent,
|
|
69
|
+
computedIsReverse,
|
|
70
|
+
computedItemCls,
|
|
71
|
+
computedItemStyle,
|
|
72
|
+
computedSpace,
|
|
73
|
+
getDate,
|
|
74
|
+
getStatus,
|
|
75
|
+
getStatusCls,
|
|
76
|
+
handleClick
|
|
77
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
import {
|
|
3
|
+
handleClick,
|
|
4
|
+
getStatusCls,
|
|
5
|
+
computedItemCls,
|
|
6
|
+
getStatus,
|
|
7
|
+
getDate,
|
|
8
|
+
computedCurrent,
|
|
9
|
+
computedIsReverse,
|
|
10
|
+
computedSpace,
|
|
11
|
+
computedItemStyle
|
|
12
|
+
} from "./index";
|
|
13
|
+
const api = ["state", "handleClick", "getStatusCls", "getStatus", "getDate", "rootProps"];
|
|
14
|
+
const renderless = (props, { computed, reactive, inject }, { t, emit, constants }) => {
|
|
15
|
+
const api2 = {};
|
|
16
|
+
const { timelineItems, nodes, props: rootProps } = inject("nodesInject");
|
|
17
|
+
timelineItems.push(props.node);
|
|
18
|
+
const state = reactive({
|
|
19
|
+
nodesLength: computed(() => nodes.length),
|
|
20
|
+
current: computed(() => api2.computedCurrent()),
|
|
21
|
+
isReverse: computed(() => api2.computedIsReverse()),
|
|
22
|
+
computedSpace: computed(() => api2.computedSpace()),
|
|
23
|
+
computedItemCls: computed(() => api2.computedItemCls()),
|
|
24
|
+
computedItemStyle: computed(() => api2.computedItemStyle())
|
|
25
|
+
});
|
|
26
|
+
Object.assign(api2, {
|
|
27
|
+
state,
|
|
28
|
+
rootProps,
|
|
29
|
+
getDate,
|
|
30
|
+
computedCurrent: computedCurrent({ state, api: api2 }),
|
|
31
|
+
computedIsReverse: computedIsReverse(api2),
|
|
32
|
+
computedItemCls: computedItemCls({ props, api: api2 }),
|
|
33
|
+
computedItemStyle: computedItemStyle({ props, state, api: api2 }),
|
|
34
|
+
computedSpace: computedSpace({ props, api: api2 }),
|
|
35
|
+
getStatus: getStatus({ state, t }),
|
|
36
|
+
handleClick: handleClick({ emit, state }),
|
|
37
|
+
getStatusCls: getStatusCls({ constants, state })
|
|
38
|
+
});
|
|
39
|
+
return api2;
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
api,
|
|
43
|
+
renderless
|
|
44
|
+
};
|
package/toggle-menu/vue.js
CHANGED
|
@@ -47,7 +47,6 @@ const renderless = (props, { reactive, watch, computed, onMounted }, { t, servic
|
|
|
47
47
|
service = service || { base: {} };
|
|
48
48
|
service = {
|
|
49
49
|
getMenuDataSync: props.getMenuDataSync || service.base.getMenuDataSync,
|
|
50
|
-
// deprecated v3.4.0废弃, v3.16.0移除;移除原因:如果是同步数据则和:data功能重复
|
|
51
50
|
getMenuDataAsync: props.getMenuDataAsync
|
|
52
51
|
};
|
|
53
52
|
Object.assign(api2, {
|
package/tooltip/index.js
CHANGED
|
@@ -144,19 +144,18 @@ const observeCallback = ({ state, popperVmRef }) => (mutationsList) => {
|
|
|
144
144
|
};
|
|
145
145
|
const bindPopper = ({ vm, refs, nextTick, popperVmRef }) => (el) => {
|
|
146
146
|
nextTick(() => vm.bindEvent(el));
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
refs.popper || (refs.popper = vm.popperVM.$el);
|
|
154
|
-
nextTick(() => {
|
|
155
|
-
if (vm.modelValue) {
|
|
156
|
-
vm.updatePopper();
|
|
157
|
-
}
|
|
158
|
-
});
|
|
147
|
+
let popperVM = vm.popperVM;
|
|
148
|
+
if (!vm.$refs.popper) {
|
|
149
|
+
popperVmRef.popper = popperVM.$el;
|
|
150
|
+
} else {
|
|
151
|
+
popperVmRef.popper = vm.$refs.popper;
|
|
159
152
|
}
|
|
153
|
+
refs.popper || (refs.popper = popperVM.$el);
|
|
154
|
+
nextTick(() => {
|
|
155
|
+
if (vm.modelValue) {
|
|
156
|
+
vm.updatePopper();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
160
159
|
};
|
|
161
160
|
export {
|
|
162
161
|
bindEvent,
|
package/tooltip/vue.js
CHANGED
|
@@ -49,7 +49,17 @@ const initState = ({ reactive, showPopper, popperElm, referenceElm, props, markR
|
|
|
49
49
|
showContent: inject("showContent", null),
|
|
50
50
|
tipsMaxWidth: inject("tips-max-width", null)
|
|
51
51
|
});
|
|
52
|
-
const renderless = (props, {
|
|
52
|
+
const renderless = (props, {
|
|
53
|
+
watch,
|
|
54
|
+
toRefs,
|
|
55
|
+
reactive,
|
|
56
|
+
onBeforeUnmount,
|
|
57
|
+
onDeactivated,
|
|
58
|
+
onMounted,
|
|
59
|
+
onUnmounted,
|
|
60
|
+
markRaw,
|
|
61
|
+
inject
|
|
62
|
+
}, { vm, emit, refs, slots, nextTick, parent }) => {
|
|
53
63
|
const api2 = {};
|
|
54
64
|
const popperParam = { emit, props, nextTick, toRefs, reactive, parent: parent.$parent, refs };
|
|
55
65
|
const popperVmRef = {};
|
package/top-box/vue.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import "../chunk-PKUHTIDK.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
clearTimer,
|
|
4
|
+
startTimer,
|
|
5
|
+
close,
|
|
6
|
+
handleAfterLeave,
|
|
7
|
+
bindEvent,
|
|
8
|
+
unBindEvent,
|
|
9
|
+
destroy,
|
|
10
|
+
watchClosed,
|
|
11
|
+
getTypeClass,
|
|
12
|
+
getOffsetStyle,
|
|
13
|
+
getZindex
|
|
14
|
+
} from "./index";
|
|
3
15
|
const api = ["state", "handleAfterLeave", "clearTimer", "startTimer", "close", "getZindex"];
|
|
4
16
|
const renderless = (props, { computed, onBeforeUnmount, onMounted, reactive, watch }, { vm, parent, constants }) => {
|
|
5
17
|
const api2 = {};
|
package/tree/index.js
CHANGED
|
@@ -5,13 +5,14 @@ import TreeStore from "../common/deps/tree-model/tree-store";
|
|
|
5
5
|
import { addClass, removeClass } from "../common/deps/dom";
|
|
6
6
|
import { on, off } from "../common/deps/dom";
|
|
7
7
|
import { getDataset } from "../common/dataset";
|
|
8
|
+
import { copyArray } from "../common/object";
|
|
8
9
|
const setChildren = (props) => (data) => props.data = data;
|
|
9
10
|
const getChildren = () => (props) => props.data;
|
|
10
11
|
const computedTreeItemArray = () => (props, state) => Array.prototype.slice.call(state.treeItems);
|
|
11
12
|
const computedShowEmptyText = ({ constants, t }) => (props) => props.emptyText || t(constants.EMPTY_TEXT_LOCAL);
|
|
12
13
|
const computedIsEmpty = () => (props, state) => {
|
|
13
14
|
const { childNodes } = state.root;
|
|
14
|
-
return !childNodes || childNodes.length === 0 || childNodes.every(({ visible }) => !visible);
|
|
15
|
+
return !childNodes || childNodes.length === 0 || childNodes.every(({ visible }) => !visible) || props.viewType === "plain" && state.plainNodeStore.filteredNodes.length === 0;
|
|
15
16
|
};
|
|
16
17
|
const watchDefaultCheckedKeys = (state) => (value) => {
|
|
17
18
|
state.store.setDefaultCheckedKey(value);
|
|
@@ -24,8 +25,8 @@ const watchDefaultExpandedKeys = ({ state, api, nextTick }) => (value) => {
|
|
|
24
25
|
api.initIsCurrent();
|
|
25
26
|
});
|
|
26
27
|
};
|
|
27
|
-
const watchData = (state) => (
|
|
28
|
-
state.store.setData(
|
|
28
|
+
const watchData = ({ state }) => (data) => {
|
|
29
|
+
state.store.setData(data);
|
|
29
30
|
};
|
|
30
31
|
const watchCheckboxItems = () => (value) => {
|
|
31
32
|
Array.prototype.forEach.call(value, (checkbox) => {
|
|
@@ -68,8 +69,9 @@ const getDropType = (dropPrev, dropInner, dropNext, dropNode) => {
|
|
|
68
69
|
}
|
|
69
70
|
return dropType;
|
|
70
71
|
};
|
|
71
|
-
const setDropIndicatorTop = (dropNode,
|
|
72
|
+
const setDropIndicatorTop = (dropNode, parent, dropType) => {
|
|
72
73
|
const iconElement = dropNode.$el.querySelector(".tiny-tree-node");
|
|
74
|
+
const dropIndicator = parent.$refs.dropIndicator;
|
|
73
75
|
if (iconElement) {
|
|
74
76
|
const treePosition = parent.$el.getBoundingClientRect();
|
|
75
77
|
const iconPosition = iconElement.getBoundingClientRect();
|
|
@@ -118,7 +120,7 @@ const getDragDir = ({ draggingNode, dropNode, allowDrop, emit, dragState }) => {
|
|
|
118
120
|
}
|
|
119
121
|
return { dropPrev, dropInner, dropNext, userAllowDropInner };
|
|
120
122
|
};
|
|
121
|
-
const dragOver = ({ state, emit, props,
|
|
123
|
+
const dragOver = ({ state, emit, props, vm }) => (event2, dropNode) => {
|
|
122
124
|
const dragState = state.dragState;
|
|
123
125
|
const oldDropNode = dragState.dropNode;
|
|
124
126
|
if (oldDropNode && oldDropNode !== dropNode) {
|
|
@@ -136,7 +138,7 @@ const dragOver = ({ state, emit, props, refs, vm }) => (event2, dropNode) => {
|
|
|
136
138
|
dragState
|
|
137
139
|
});
|
|
138
140
|
const dropType = getDropType(dropPrev, dropInner, dropNext, dropNode);
|
|
139
|
-
setDropIndicatorTop(dropNode,
|
|
141
|
+
setDropIndicatorTop(dropNode, vm, dropType);
|
|
140
142
|
dragState.showDropIndicator = dropType === "before" || dropType === "after";
|
|
141
143
|
dragState.allowDrop = dragState.showDropIndicator || userAllowDropInner;
|
|
142
144
|
dragState.dropType = dropType;
|
|
@@ -174,9 +176,8 @@ const dragEnd = ({ state, emit }) => (event2) => {
|
|
|
174
176
|
dragState.allowDrop = true;
|
|
175
177
|
dragState.showDropIndicator = false;
|
|
176
178
|
};
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
const { nodeKey, data, lazy, load, currentNodeKey, checkStrictly, checkDescendants } = props;
|
|
179
|
+
const initTreeStore = ({ api, props, state, emit }) => () => {
|
|
180
|
+
const { nodeKey, data, lazy, load, afterLoad, currentNodeKey, checkStrictly, checkDescendants } = props;
|
|
180
181
|
const { defaultCheckedKeys, defaultExpandedKeys, autoExpandParent, defaultExpandAll, filterNodeMethod } = props;
|
|
181
182
|
state.store = new TreeStore({
|
|
182
183
|
key: nodeKey,
|
|
@@ -184,6 +185,11 @@ const created = ({ api, props, state }) => () => {
|
|
|
184
185
|
lazy,
|
|
185
186
|
props: props.props,
|
|
186
187
|
load,
|
|
188
|
+
afterLoad(params) {
|
|
189
|
+
!state.loaded && (state.loaded = true);
|
|
190
|
+
emit("load-data", params);
|
|
191
|
+
afterLoad && afterLoad(params);
|
|
192
|
+
},
|
|
187
193
|
currentNodeKey,
|
|
188
194
|
checkStrictly,
|
|
189
195
|
checkDescendants,
|
|
@@ -195,9 +201,18 @@ const created = ({ api, props, state }) => () => {
|
|
|
195
201
|
});
|
|
196
202
|
state.root = state.store.root;
|
|
197
203
|
api.initIsCurrent();
|
|
204
|
+
api.initPlainNodeStore();
|
|
205
|
+
};
|
|
206
|
+
const created = ({ api, state }) => () => {
|
|
207
|
+
state.isTree = true;
|
|
208
|
+
api.initTreeStore();
|
|
198
209
|
state.emitter.on("tree-node-drag-start", api.dragStart);
|
|
199
210
|
state.emitter.on("tree-node-drag-over", api.dragOver);
|
|
200
211
|
state.emitter.on("tree-node-drag-end", api.dragEnd);
|
|
212
|
+
state.emitter.on("tree-node-save", api.saveNode);
|
|
213
|
+
state.emitter.on("tree-node-edit", api.editNode);
|
|
214
|
+
state.emitter.on("tree-node-delete", api.deleteConfirm);
|
|
215
|
+
state.emitter.on("tree-node-add", api.addNode);
|
|
201
216
|
};
|
|
202
217
|
const doClearCurrentStore = (state) => {
|
|
203
218
|
if (state.currentStore.node) {
|
|
@@ -228,15 +243,22 @@ const initIsCurrent = ({ props, state }) => () => {
|
|
|
228
243
|
if (state.store.getCurrentNode() && props.defaultExpandedKeysHighlight) {
|
|
229
244
|
state.store.setCurrentNode(null);
|
|
230
245
|
}
|
|
231
|
-
if (props.defaultExpandedKeysHighlight && Array.isArray(props.defaultExpandedKeys) && ~props.defaultExpandedKeys.indexOf(props.defaultExpandedKeysHighlight)) {
|
|
232
|
-
setIsCurrent(
|
|
246
|
+
if (props.defaultExpandedKeysHighlight && Array.isArray(props.defaultExpandedKeys) && (~props.defaultExpandedKeys.indexOf(props.defaultExpandedKeysHighlight) || props.lazyCurrent)) {
|
|
247
|
+
setIsCurrent(
|
|
248
|
+
state.root,
|
|
249
|
+
props.defaultExpandedKeys,
|
|
250
|
+
props.defaultExpandedKeysHighlight,
|
|
251
|
+
state.currentStore,
|
|
252
|
+
props.nodeKey
|
|
253
|
+
);
|
|
233
254
|
}
|
|
234
255
|
};
|
|
235
256
|
const mounted = ({ api, vm }) => () => {
|
|
236
257
|
api.initTabIndex();
|
|
237
258
|
on(vm.$el, "keydown", api.handleKeydown);
|
|
238
259
|
};
|
|
239
|
-
const beforeUnmount = ({ api, vm }) => () => {
|
|
260
|
+
const beforeUnmount = ({ api, vm, state }) => () => {
|
|
261
|
+
state.action.popoverVisible = false;
|
|
240
262
|
off(vm.$el, "keydown", api.handleKeydown);
|
|
241
263
|
};
|
|
242
264
|
const wrapMounted = ({ api, props, service }) => () => {
|
|
@@ -321,11 +343,11 @@ const setCurrentKey = ({ props, state }) => (key) => {
|
|
|
321
343
|
state.store.setCurrentNodeKey(key);
|
|
322
344
|
};
|
|
323
345
|
const getNode = (state) => (data) => state.store.getNode(data);
|
|
324
|
-
const remove = (state) => (data) => {
|
|
325
|
-
state.store.remove(data);
|
|
346
|
+
const remove = (state) => (data, isSaveChildNode, isNode) => {
|
|
347
|
+
state.store.remove(data, isSaveChildNode, isNode);
|
|
326
348
|
};
|
|
327
349
|
const append = (state) => (data, parentNode) => {
|
|
328
|
-
state.store.append(data, parentNode);
|
|
350
|
+
state.store.append(data, parentNode, 0);
|
|
329
351
|
};
|
|
330
352
|
const insertBefore = (state) => (data, refNode) => {
|
|
331
353
|
state.store.insertBefore(data, refNode);
|
|
@@ -459,18 +481,195 @@ const expandAllNodes = ({ state }) => (expandFlag) => {
|
|
|
459
481
|
});
|
|
460
482
|
}
|
|
461
483
|
};
|
|
484
|
+
const switchToggle = ({ state }) => (val) => {
|
|
485
|
+
state.checkEasily = val;
|
|
486
|
+
};
|
|
487
|
+
const getSameDataIndex = (list, data, key = "$treeNodeId") => {
|
|
488
|
+
let index = -1;
|
|
489
|
+
list.forEach((item, i) => {
|
|
490
|
+
if (item[key] === data[key]) {
|
|
491
|
+
index = i;
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
return index;
|
|
495
|
+
};
|
|
496
|
+
const editNode = ({ state }) => (node) => {
|
|
497
|
+
state.action.type = "edit";
|
|
498
|
+
state.action.label = node && node.data.label || "";
|
|
499
|
+
state.action.node = node;
|
|
500
|
+
state.action.popoverVisible = false;
|
|
501
|
+
};
|
|
502
|
+
const saveNode = ({ state, emit, api }) => () => {
|
|
503
|
+
const node = state.action.node;
|
|
504
|
+
if (!node) {
|
|
505
|
+
return;
|
|
506
|
+
} else if (state.action.label) {
|
|
507
|
+
node.data.label = state.action.label;
|
|
508
|
+
if (node.data._isNewNode) {
|
|
509
|
+
const index = api.getSameDataIndex(state.treeEdit.addData, node.data);
|
|
510
|
+
index === -1 ? state.treeEdit.addData.push(node.data) : state.treeEdit.addData.splice(index, 1, node.data);
|
|
511
|
+
emit("add-node", node);
|
|
512
|
+
} else {
|
|
513
|
+
const index = api.getSameDataIndex(state.treeEdit.editData, node.data);
|
|
514
|
+
index === -1 ? state.treeEdit.editData.push(node.data) : state.treeEdit.editData.splice(index, 1, node.data);
|
|
515
|
+
emit("edit-node", node);
|
|
516
|
+
}
|
|
517
|
+
} else if (node && node.data && node.data._isNewNode) {
|
|
518
|
+
api.remove(node, false, true);
|
|
519
|
+
}
|
|
520
|
+
state.action.node = null;
|
|
521
|
+
};
|
|
522
|
+
const addNode = ({ api }) => (node) => {
|
|
523
|
+
const newNode = { label: "" };
|
|
524
|
+
Object.defineProperty(newNode, "_isNewNode", {
|
|
525
|
+
value: true,
|
|
526
|
+
enumerable: false,
|
|
527
|
+
configurable: false,
|
|
528
|
+
writable: false
|
|
529
|
+
});
|
|
530
|
+
api.append(newNode, node.data);
|
|
531
|
+
setTimeout(() => {
|
|
532
|
+
const childs = node.childNodes;
|
|
533
|
+
const child = childs[0];
|
|
534
|
+
api.editNode(child);
|
|
535
|
+
}, 100);
|
|
536
|
+
};
|
|
537
|
+
const cancelDelete = ({ state }) => () => {
|
|
538
|
+
state.action.referenceElm = null;
|
|
539
|
+
state.action.popoverVisible = false;
|
|
540
|
+
};
|
|
541
|
+
const loopGetTreeData = (result = [], nodes = [], childKey = "childNodes") => {
|
|
542
|
+
nodes.forEach((node) => {
|
|
543
|
+
const index = getSameDataIndex(result, node.data);
|
|
544
|
+
index === -1 && result.push(node.data);
|
|
545
|
+
if (node[childKey] && node[childKey].length) {
|
|
546
|
+
result = loopGetTreeData(result, node[childKey]);
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
return result;
|
|
550
|
+
};
|
|
551
|
+
const deleteAction = ({ state, api, emit }) => () => {
|
|
552
|
+
const { node, isSaveChildNode } = state.action;
|
|
553
|
+
state.action.referenceElm = null;
|
|
554
|
+
state.action.popoverVisible = false;
|
|
555
|
+
if (!node.data._isNewNode) {
|
|
556
|
+
state.treeEdit.deleteData.push(node.data);
|
|
557
|
+
if (!isSaveChildNode) {
|
|
558
|
+
state.treeEdit.deleteData = loopGetTreeData(state.treeEdit.deleteData, node.childNodes);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
emit("delete-node", node);
|
|
562
|
+
api.remove(state.action.node, isSaveChildNode, true);
|
|
563
|
+
};
|
|
564
|
+
const deleteConfirm = ({ state }) => (event2, node) => {
|
|
565
|
+
state.action.type = "delete";
|
|
566
|
+
state.action.node = node;
|
|
567
|
+
state.action.isLeaf = !node.childNodes || !node.childNodes.length;
|
|
568
|
+
state.action.referenceElm = event2.currentTarget;
|
|
569
|
+
state.action.popoverVisible = false;
|
|
570
|
+
state.action.isSaveChildNode = false;
|
|
571
|
+
setTimeout(() => {
|
|
572
|
+
state.action.popoverVisible = true;
|
|
573
|
+
}, 300);
|
|
574
|
+
};
|
|
575
|
+
const openEdit = ({ props, state, api, emit }) => () => {
|
|
576
|
+
state.action.show = true;
|
|
577
|
+
state.action.data = copyArray(props.data);
|
|
578
|
+
api.watchData(state.action.data);
|
|
579
|
+
emit("open-edit");
|
|
580
|
+
};
|
|
581
|
+
const closeEdit = ({ props, state, api, emit }) => () => {
|
|
582
|
+
state.action.show = false;
|
|
583
|
+
state.action.popoverVisible = false;
|
|
584
|
+
api.watchData(props.data);
|
|
585
|
+
emit("close-edit");
|
|
586
|
+
state.treeEdit = { addData: [], deleteData: [], editData: [] };
|
|
587
|
+
};
|
|
588
|
+
const saveEdit = ({ state, emit, props }) => () => {
|
|
589
|
+
const data = copyArray(state.action.show ? state.action.data : props.data);
|
|
590
|
+
state.action.show = false;
|
|
591
|
+
state.action.popoverVisible = false;
|
|
592
|
+
emit("save-edit", state.treeEdit, data);
|
|
593
|
+
state.treeEdit = { addData: [], deleteData: [], editData: [] };
|
|
594
|
+
return data;
|
|
595
|
+
};
|
|
596
|
+
const setAddDisabledKeys = ({ state }) => (data) => {
|
|
597
|
+
state.action.addDisabled = data || [];
|
|
598
|
+
};
|
|
599
|
+
const setEditDisabledKeys = ({ state }) => (data) => {
|
|
600
|
+
state.action.editDisabled = data || [];
|
|
601
|
+
};
|
|
602
|
+
const setDeleteDisabledKeys = ({ state }) => (data) => {
|
|
603
|
+
state.action.deleteDisabled = data || [];
|
|
604
|
+
};
|
|
605
|
+
const initPlainNodeStore = ({ props, state }) => () => {
|
|
606
|
+
const { nodeKey, pathSplit, filterPlainMethod } = props;
|
|
607
|
+
const prefixReg = new RegExp(`^\\${pathSplit}+`);
|
|
608
|
+
const plainNodeStore = { nodes: [], filteredNodes: [] };
|
|
609
|
+
const walkTree = (node, labelPath, nodeKeyPath) => {
|
|
610
|
+
if (node && node.data) {
|
|
611
|
+
labelPath += `${pathSplit}${node.data.label || ""}`;
|
|
612
|
+
nodeKeyPath += `${pathSplit}${node.data[nodeKey] || ""}`;
|
|
613
|
+
labelPath = labelPath.replace(prefixReg, "");
|
|
614
|
+
nodeKeyPath = nodeKeyPath.replace(prefixReg, "");
|
|
615
|
+
if (labelPath) {
|
|
616
|
+
const plainNode = { labelPath, nodeKeyPath, node };
|
|
617
|
+
const paths = labelPath.split(pathSplit);
|
|
618
|
+
const nodeKeyType = typeof node.data[nodeKey];
|
|
619
|
+
const nodeKeys = nodeKeyPath.split(pathSplit).map(nodeKeyType === "number" ? Number : String);
|
|
620
|
+
plainNode.title = paths[paths.length - 1];
|
|
621
|
+
plainNode.auxi = paths.slice(0, paths.length - 1).join(pathSplit);
|
|
622
|
+
plainNode.nodeKeyType = nodeKeyType;
|
|
623
|
+
plainNode.nodeKey = node.data[nodeKey];
|
|
624
|
+
plainNode.nodeKeys = nodeKeys;
|
|
625
|
+
plainNode.parentNodeKeys = nodeKeys.slice(0, nodeKeys.length - 1);
|
|
626
|
+
plainNodeStore.nodes.push(plainNode);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (node.childNodes && node.childNodes.length) {
|
|
630
|
+
node.childNodes.forEach((n) => walkTree(n, labelPath, nodeKeyPath));
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
walkTree(state.root, "", "");
|
|
634
|
+
const filterPlainNode = (data) => !filterPlainMethod || typeof filterPlainMethod === "function" && filterPlainMethod(data);
|
|
635
|
+
plainNodeStore.filteredNodes = plainNodeStore.nodes.filter(
|
|
636
|
+
(plainNode) => plainNode.node.visible && filterPlainNode(plainNode.node.data)
|
|
637
|
+
);
|
|
638
|
+
state.plainNodeStore = plainNodeStore;
|
|
639
|
+
};
|
|
640
|
+
const handleCheckPlainNode = ({ props, emit }) => (e, plainNode) => {
|
|
641
|
+
plainNode.node.setChecked(e, !props.checkStrictly);
|
|
642
|
+
emit("check-plain", plainNode, e);
|
|
643
|
+
};
|
|
644
|
+
const handleClickPlainNode = (emit) => (e, plainNode) => {
|
|
645
|
+
emit("leave-plain-view", plainNode, e);
|
|
646
|
+
};
|
|
647
|
+
const setCheckedByNodeKey = ({ props, state }) => (key, checked) => {
|
|
648
|
+
const { nodeKey, checkStrictly } = props;
|
|
649
|
+
const { nodes: plainNodes } = state.plainNodeStore;
|
|
650
|
+
const plainNode = plainNodes.find((plainNode2) => plainNode2.node.data[nodeKey] === key);
|
|
651
|
+
if (plainNode) {
|
|
652
|
+
plainNode.node.setChecked(checked, !checkStrictly);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
462
655
|
export {
|
|
656
|
+
addNode,
|
|
463
657
|
append,
|
|
464
658
|
beforeUnmount,
|
|
659
|
+
cancelDelete,
|
|
465
660
|
clearCurrentStore,
|
|
661
|
+
closeEdit,
|
|
466
662
|
closeMenu,
|
|
467
663
|
computedIsEmpty,
|
|
468
664
|
computedShowEmptyText,
|
|
469
665
|
computedTreeItemArray,
|
|
470
666
|
created,
|
|
667
|
+
deleteAction,
|
|
668
|
+
deleteConfirm,
|
|
471
669
|
dragEnd,
|
|
472
670
|
dragOver,
|
|
473
671
|
dragStart,
|
|
672
|
+
editNode,
|
|
474
673
|
expandAllNodes,
|
|
475
674
|
filter,
|
|
476
675
|
getCheckedKeys,
|
|
@@ -483,21 +682,35 @@ export {
|
|
|
483
682
|
getNode,
|
|
484
683
|
getNodeKey,
|
|
485
684
|
getNodePath,
|
|
685
|
+
getSameDataIndex,
|
|
686
|
+
handleCheckPlainNode,
|
|
687
|
+
handleClickPlainNode,
|
|
486
688
|
handleKeydown,
|
|
487
689
|
handleNodeExpand,
|
|
488
690
|
initIsCurrent,
|
|
691
|
+
initPlainNodeStore,
|
|
489
692
|
initTabIndex,
|
|
693
|
+
initTreeStore,
|
|
490
694
|
insertAfter,
|
|
491
695
|
insertBefore,
|
|
696
|
+
loopGetTreeData,
|
|
492
697
|
mounted,
|
|
698
|
+
openEdit,
|
|
493
699
|
remove,
|
|
700
|
+
saveEdit,
|
|
701
|
+
saveNode,
|
|
702
|
+
setAddDisabledKeys,
|
|
494
703
|
setChecked,
|
|
704
|
+
setCheckedByNodeKey,
|
|
495
705
|
setCheckedKeys,
|
|
496
706
|
setCheckedNodes,
|
|
497
707
|
setChildren,
|
|
498
708
|
setCurrentKey,
|
|
499
709
|
setCurrentNode,
|
|
500
710
|
setCurrentRadio,
|
|
711
|
+
setDeleteDisabledKeys,
|
|
712
|
+
setEditDisabledKeys,
|
|
713
|
+
switchToggle,
|
|
501
714
|
updateKeyChildren,
|
|
502
715
|
updated,
|
|
503
716
|
watchCheckStrictly,
|