@opentiny/vue-renderless 3.12.0 → 3.13.0-alpha.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/index.js +20 -13
- package/action-sheet/vue.js +8 -7
- package/alert/index.js +50 -1
- package/alert/vue.js +36 -9
- package/amount/index.js +100 -25
- package/amount/vue.js +102 -26
- package/anchor/index.js +1 -0
- package/area/index.js +8 -8
- package/area/vue.js +5 -5
- package/async-flowchart/index.js +16 -3
- package/autocomplete/index.js +58 -14
- package/autocomplete/vue.js +40 -12
- package/badge/index.js +12 -0
- package/badge/vue.js +6 -4
- package/breadcrumb/vue.js +3 -1
- package/breadcrumb-item/vue.js +6 -2
- package/button/index.js +5 -1
- package/calendar/index.js +2 -86
- package/calendar-bar/index.js +20 -6
- package/calendar-view/index.js +10 -12
- package/calendar-view/vue.js +17 -4
- package/cascader/index.js +80 -34
- package/cascader/vue.js +49 -19
- package/cascader-menu/index.js +7 -7
- package/cascader-menu/vue.js +2 -3
- package/cascader-mobile/index.js +37 -24
- package/cascader-mobile/vue.js +7 -1
- package/cascader-node/index.js +13 -1
- package/cascader-node/vue.js +15 -4
- package/cascader-panel/index.js +1 -1
- package/cascader-select/column-index.js +150 -0
- package/cascader-select/column.js +120 -0
- package/cascader-select/index.js +29 -165
- package/cascader-select/usePicker.js +251 -0
- package/cascader-select/useTouch.js +65 -0
- package/cascader-select/vue.js +35 -47
- package/cascader-view/index.js +1 -1
- package/cell/vue.js +2 -1
- package/chart-bar/index.js +2 -3
- package/chart-core/deps/constants.js +43 -43
- package/chart-core/index.js +1 -1
- package/chart-gauge/index.js +2 -2
- package/chart-heatmap/index.js +17 -10
- package/chart-line/index.js +8 -9
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +4 -6
- package/checkbox/index.js +17 -0
- package/checkbox/vue.js +16 -7
- package/checkbox-group/vue.js +2 -0
- package/col/index.js +7 -2
- package/col/vue.js +1 -1
- package/collapse/index.js +3 -3
- package/color-select-panel/vue.js +0 -7
- package/column-list-item/index.js +17 -1
- package/column-list-item/vue.js +8 -3
- package/common/date.js +2 -0
- package/common/deps/dom.js +19 -4
- package/common/deps/popper.js +48 -5
- package/common/deps/touch-emulator.js +4 -1
- package/common/deps/tree-model/node.js +1 -1
- package/common/deps/tree-model/tree-store.js +2 -13
- package/common/deps/useRect.js +25 -0
- package/common/deps/vue-popper.js +22 -10
- package/common/index.js +1 -1
- package/common/runtime.js +1 -1
- package/common/type.js +2 -1
- package/common/validate/rules/enum.js +1 -1
- package/common/validate/rules/pattern.js +2 -2
- package/common/validate/rules/range.js +8 -5
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +5 -5
- package/common/validate/rules/whitespace.js +1 -1
- package/common/validate/util.js +15 -16
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/container/index.js +17 -1
- package/container/vue.js +12 -3
- package/currency/index.js +74 -7
- package/currency/vue.js +21 -5
- package/date-panel/index.js +16 -0
- package/date-panel/vue.js +8 -2
- package/date-picker-mobile/index.js +12 -0
- package/date-picker-mobile/vue.js +7 -1
- package/date-range/vue.js +12 -5
- package/date-table/index.js +5 -0
- package/date-table/vue.js +3 -1
- package/dialog-box/index.js +17 -6
- package/dialog-select/index.js +6 -3
- package/dialog-select/vue.js +8 -4
- package/drawer/index.js +26 -5
- package/drawer/vue.js +13 -7
- package/dropdown/index.js +7 -7
- package/dropdown/vue.js +6 -2
- package/dropdown-item/index.js +9 -1
- package/dropdown-item/mf.js +6 -10
- package/dropdown-item/vue.js +21 -8
- package/dropdown-menu/index.js +20 -7
- package/dropdown-menu/vue.js +4 -3
- package/exception/index.js +2 -7
- package/exception/vue.js +7 -10
- package/fall-menu/index.js +5 -1
- package/fall-menu/vue.js +13 -2
- package/file-upload/index.js +47 -12
- package/file-upload/vue.js +38 -8
- package/filter-box/index.js +1 -0
- package/floating-button/index.js +62 -16
- package/floating-button/vue.js +27 -9
- package/flowchart/index.js +134 -25
- package/flowchart/node.js +13 -4
- package/flowchart/vue.js +16 -4
- package/form/vue.js +3 -1
- package/form-item/index.js +4 -4
- package/form-item/vue.js +3 -1
- package/fullscreen/index.js +5 -5
- package/fullscreen/vue.js +3 -3
- package/grid/utils/common.js +10 -5
- package/grid/utils/dom.js +7 -1
- package/image/index.js +6 -0
- package/image/vue.js +6 -3
- package/image-viewer/index.js +62 -51
- package/image-viewer/vue.js +17 -5
- package/input/index.js +89 -22
- package/input/vue.js +52 -21
- package/ip-address/index.js +61 -19
- package/ip-address/vue.js +22 -4
- package/label/index.js +56 -0
- package/label/vue.js +26 -0
- package/link/vue.js +3 -1
- package/loading/vue.js +8 -2
- package/logout/index.js +1 -1
- package/mask/index.js +13 -0
- package/mask/vue.js +18 -0
- package/mind-map/index.js +47 -0
- package/mind-map/vue.js +53 -0
- package/multi-select/index.js +150 -10
- package/multi-select/vue.js +46 -11
- package/multi-select-item/index.js +17 -0
- package/multi-select-item/vue.js +31 -0
- package/numeric/index.js +51 -9
- package/numeric/vue.js +44 -14
- package/option/index.js +12 -5
- package/option/vue.js +15 -7
- package/option-group/index.js +3 -3
- package/package.json +1 -1
- package/pager/index.js +372 -0
- package/pager/vue.js +125 -2
- package/picker/index.js +253 -48
- package/picker/mb.js +42 -0
- package/picker/vue.js +70 -17
- package/picker-column/index.js +1 -1
- package/pop-upload/index.js +0 -2
- package/pop-upload/vue.js +3 -4
- package/popconfirm/index.js +3 -6
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +55 -24
- package/popeditor/vue.js +15 -11
- package/popover/index.js +4 -4
- package/popover/vue.js +6 -6
- package/popup/index.js +3 -3
- package/popup/vue.js +5 -5
- package/pull-refresh/index.js +57 -65
- package/pull-refresh/vue.js +23 -7
- package/radio/index.js +0 -17
- package/radio/vue.js +4 -10
- package/rate/index.js +1 -1
- package/rate/vue.js +0 -2
- package/record/index.js +4 -1
- package/{rich-text-edtior → rich-text-editor}/index.js +2 -2
- package/{rich-text-edtior → rich-text-editor}/vue.js +2 -5
- package/scrollbar/index.js +11 -11
- package/scrollbar/vue-bar.js +3 -3
- package/scrollbar/vue.js +5 -5
- package/search/index.js +1 -1
- package/search/vue.js +3 -1
- package/select/index.js +185 -113
- package/select/vue.js +105 -20
- package/select-dropdown/index.js +62 -4
- package/select-dropdown/vue.js +85 -8
- package/select-view/index.js +3 -1
- package/signature/index.js +241 -0
- package/signature/vue.js +88 -0
- package/skeleton/index.js +14 -0
- package/skeleton/vue.js +15 -0
- package/skeleton-item/vue.js +15 -0
- package/slider/index.js +27 -7
- package/slider/vue.js +26 -7
- package/split/index.js +1 -1
- package/split/vue.js +4 -6
- package/standard-list-item/index.js +15 -1
- package/standard-list-item/vue.js +6 -5
- package/steps/index.js +25 -2
- package/steps/slide-bar.js +8 -1
- package/steps/vue.js +15 -3
- package/tab-item-mf/vue.js +14 -8
- package/tab-nav/index.js +9 -4
- package/tab-nav/vue.js +6 -2
- package/tabbar/vue.js +9 -3
- package/tabbar-item/vue.js +3 -2
- package/tabs/index.js +1 -1
- package/tabs/vue.js +1 -0
- package/tabs-mf/index.js +20 -6
- package/tabs-mf/vue-nav.js +26 -11
- package/tabs-mf/vue.js +7 -7
- package/tag/index.js +1 -1
- package/tag/vue.js +5 -1
- package/tag-group/index.js +2 -1
- package/tall-storage/index.js +4 -5
- package/time/index.js +4 -1
- package/time/vue.js +1 -1
- package/time-line/vue.js +1 -1
- package/time-picker-mobile/index.js +24 -5
- package/time-picker-mobile/vue.js +17 -7
- package/time-range/index.js +2 -0
- package/time-spinner/index.js +0 -3
- package/time-spinner/vue.js +2 -3
- package/timeline-item/vue.js +1 -1
- package/tooltip/index.js +1 -2
- package/tooltip/vue.js +3 -3
- package/transfer/index.js +20 -22
- package/transfer/vue.js +1 -6
- package/transfer-panel/vue.js +3 -5
- package/tree/index.js +21 -4
- package/tree/vue.js +10 -8
- package/tree-menu/index.js +27 -3
- package/tree-menu/vue.js +27 -14
- package/tree-node/index.js +12 -10
- package/tree-node/vue.js +6 -5
- package/types/action-menu.type.d.ts +5 -0
- package/types/action-sheet.type.d.ts +118 -1
- package/types/alert.type.d.ts +16 -1
- package/types/amount.type.d.ts +168 -1
- package/types/area.type.d.ts +134 -1
- package/types/async-flowchart.type.d.ts +72 -0
- package/types/autocomplete.type.d.ts +199 -1
- package/types/badge.type.d.ts +3 -1
- package/types/breadcrumb-item.type.d.ts +2 -0
- package/types/breadcrumb.type.d.ts +2 -0
- package/types/button.type.d.ts +5 -0
- package/types/cascader-menu.type.d.ts +3 -4
- package/types/cascader-node.type.d.ts +5 -2
- package/types/cascader-panel.type-2bd03be3.d.ts +241 -0
- package/types/cascader-panel.type.d.ts +3 -241
- package/types/cascader.type.d.ts +327 -1
- package/types/checkbox.type.d.ts +9 -0
- package/types/collapse.type.d.ts +19 -2
- package/types/date-picker.type.d.ts +33 -0
- package/types/dialog-box.type.d.ts +5 -1
- package/types/drawer.type.d.ts +132 -1
- package/types/{dropdown-item.type-bf83e929.d.ts → dropdown-item.type-8475a549.d.ts} +8 -14
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/dropdown.type.d.ts +2 -5
- package/types/fall-menu.type.d.ts +94 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-d0fd42f3.d.ts → form.type-d88482e4.d.ts} +3 -0
- package/types/form.type.d.ts +1 -1
- package/types/input.type.d.ts +23 -9
- package/types/ip-address.type.d.ts +160 -1
- package/types/label.type.d.ts +81 -0
- package/types/link.type.d.ts +6 -3
- package/types/mind-map.type.d.ts +20 -0
- package/types/modal.type.d.ts +4 -2
- package/types/numeric.type.d.ts +36 -9
- package/types/pager.type.d.ts +171 -1
- package/types/picker.type.d.ts +14 -0
- package/types/popconfirm.type.d.ts +85 -1
- package/types/popeditor.type.d.ts +4 -0
- package/types/popover.type.d.ts +3 -3
- package/types/radio.type.d.ts +0 -4
- package/types/rate.type.d.ts +236 -1
- package/types/search.type.d.ts +88 -1
- package/types/shared.type.d.ts +1 -1
- package/types/skeleton-item.type.d.ts +38 -0
- package/types/skeleton.type.d.ts +45 -0
- package/types/slider.type.d.ts +8 -1
- package/types/steps.type.d.ts +14 -3
- package/types/tab-item.type.d.ts +0 -1
- package/types/tab-nav.type.d.ts +6 -1
- package/types/tabs.type.d.ts +5 -0
- package/types/tag-group.type.d.ts +64 -1
- package/types/tag.type.d.ts +12 -0
- package/types/tooltip.type.d.ts +1 -1
- package/types/transfer.type.d.ts +183 -1
- package/types/tree-menu.type.d.ts +210 -1
- package/types/upload-dragger.type.d.ts +1 -1
- package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-1078fba2.d.ts} +27 -6
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/wizard.type.d.ts +1 -0
- package/upload/index.js +59 -29
- package/upload/vue.js +6 -4
- package/upload-list/index.js +14 -14
- package/upload-list/vue.js +5 -2
- package/user/index.js +5 -4
- package/user-head/index.js +1 -1
- package/wheel/index.js +3 -0
- package/wizard/vue.js +4 -2
package/option/vue.js
CHANGED
|
@@ -16,7 +16,7 @@ const initState = ({ reactive, computed, props, api: api2, markRaw, select, pare
|
|
|
16
16
|
created: computed(() => props.created),
|
|
17
17
|
index: -1,
|
|
18
18
|
select: markRaw(select),
|
|
19
|
-
hover: false,
|
|
19
|
+
hover: computed(() => !state.select.optimization && state.select.state.hoverIndex === state.index || false),
|
|
20
20
|
visible: true,
|
|
21
21
|
hitState: false,
|
|
22
22
|
groupDisabled: false,
|
|
@@ -24,17 +24,18 @@ const initState = ({ reactive, computed, props, api: api2, markRaw, select, pare
|
|
|
24
24
|
isObject: computed(() => Object.prototype.toString.call(props.value).toLowerCase() === "[object object]"),
|
|
25
25
|
currentLabel: computed(() => props.label || (state.isObject ? "" : props.value)),
|
|
26
26
|
currentValue: computed(() => props.value || props.label || ""),
|
|
27
|
+
showTitle: false,
|
|
27
28
|
itemSelected: computed(() => {
|
|
28
29
|
if (!select.multiple) {
|
|
29
|
-
return api2.isEqual(props.value, select.modelValue);
|
|
30
|
+
return api2.isEqual(props.value, select.state.modelValue);
|
|
30
31
|
} else {
|
|
31
|
-
return api2.contains(select.modelValue, props.value);
|
|
32
|
+
return api2.contains(select.state.modelValue, props.value);
|
|
32
33
|
}
|
|
33
34
|
}),
|
|
34
35
|
limitReached: computed(() => {
|
|
35
36
|
if (select.multiple) {
|
|
36
37
|
const multipleLimit = select.state.multipleLimit;
|
|
37
|
-
return !state.itemSelected && (select.modelValue || []).length >= multipleLimit && multipleLimit > 0;
|
|
38
|
+
return !state.itemSelected && (select.state.modelValue || []).length >= multipleLimit && multipleLimit > 0;
|
|
38
39
|
} else {
|
|
39
40
|
return false;
|
|
40
41
|
}
|
|
@@ -49,9 +50,9 @@ const initApi = ({ api: api2, props, state, select, constants, vm }) => {
|
|
|
49
50
|
isEqual: isEqual({ select, state }),
|
|
50
51
|
contains: contains({ select, state }),
|
|
51
52
|
hoverItem: hoverItem({ select, vm, props, state }),
|
|
52
|
-
queryChange: queryChange({
|
|
53
|
+
queryChange: queryChange({ props, state }),
|
|
53
54
|
selectOptionClick: selectOptionClick({ constants, vm, props, state, select }),
|
|
54
|
-
handleGroupDisabled: handleGroupDisabled(state),
|
|
55
|
+
handleGroupDisabled: handleGroupDisabled({ state, vm }),
|
|
55
56
|
initValue: initValue({ select, props, constants, vm })
|
|
56
57
|
});
|
|
57
58
|
};
|
|
@@ -76,6 +77,12 @@ const initWatch = ({ watch, props, state, select, constants }) => {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
);
|
|
80
|
+
watch(
|
|
81
|
+
() => state.visible,
|
|
82
|
+
() => {
|
|
83
|
+
select.state.filteredOptionsCount += state.visible ? 1 : -1;
|
|
84
|
+
}
|
|
85
|
+
);
|
|
79
86
|
};
|
|
80
87
|
const initOnMounted = ({ onMounted, props, api: api2, vm, state, constants, select }) => {
|
|
81
88
|
onMounted(() => {
|
|
@@ -106,9 +113,10 @@ const renderless = (props, { computed, onMounted, onBeforeUnmount, reactive, wat
|
|
|
106
113
|
initOnBeforeUnmount({ onBeforeUnmount, props, select, vm });
|
|
107
114
|
select.state.options.push(markRaw(vm));
|
|
108
115
|
select.state.cachedOptions.push(markRaw(vm));
|
|
116
|
+
state.index = select.state.optionsCount;
|
|
109
117
|
select.state.optionsCount++;
|
|
110
118
|
select.state.filteredOptionsCount++;
|
|
111
|
-
|
|
119
|
+
parent.$on(constants.EVENT_NAME.handleGroupDisabled, api2.handleGroupDisabled);
|
|
112
120
|
return api2;
|
|
113
121
|
};
|
|
114
122
|
export {
|
package/option-group/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import "../chunk-G2ADBYYC.js";
|
|
|
2
2
|
const queryChange = ({ select, state, vm }) => () => {
|
|
3
3
|
state.visible = true;
|
|
4
4
|
if (Array.isArray(select.state.options)) {
|
|
5
|
-
const groupOptions = select.state.options.filter(
|
|
6
|
-
|
|
7
|
-
);
|
|
5
|
+
const groupOptions = select.state.options.filter((option) => {
|
|
6
|
+
return option.state.parent.$parent && vm && option.state.parent.$parent.label === vm.label;
|
|
7
|
+
});
|
|
8
8
|
if (Array.isArray(groupOptions)) {
|
|
9
9
|
state.visible = groupOptions.some((option) => option.visible === true);
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/vue-renderless",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0-alpha.0",
|
|
4
4
|
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
|
|
5
5
|
"homepage": "https://opentiny.design/tiny-vue",
|
|
6
6
|
"keywords": [
|
package/pager/index.js
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues
|
|
3
|
+
} from "../chunk-G2ADBYYC.js";
|
|
4
|
+
import { emitEvent } from "../common/event";
|
|
5
|
+
const computedShowPager = ({ props, state }) => () => {
|
|
6
|
+
const hidePager = props.hideOnSinglePage && (!state.internalPageCount || state.internalPageCount === 1);
|
|
7
|
+
return state.internalLayout.length > 0 && !hidePager;
|
|
8
|
+
};
|
|
9
|
+
const computedInternalLayout = ({ props }) => () => {
|
|
10
|
+
let layout = "";
|
|
11
|
+
if (props.mode && !props.layout) {
|
|
12
|
+
props.mode === "number" && (layout = "total, sizes, prev, pager, next, jumper");
|
|
13
|
+
props.mode === "simple" && (layout = "sizes, total, prev, current, next");
|
|
14
|
+
props.mode === "complete" && (layout = "sizes, total, prev, pager, next, jumper");
|
|
15
|
+
props.mode === "fixed" && (layout = "prev,pager,next");
|
|
16
|
+
} else if (!props.mode && props.layout || props.mode && props.layout) {
|
|
17
|
+
layout = props.layout;
|
|
18
|
+
} else {
|
|
19
|
+
layout = "total, prev, pager, next, jumper";
|
|
20
|
+
}
|
|
21
|
+
if (!layout) {
|
|
22
|
+
return [];
|
|
23
|
+
} else {
|
|
24
|
+
const components = layout.split(",").map((item) => item.trim());
|
|
25
|
+
return components;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const computedTotalText = ({ props, t }) => () => {
|
|
29
|
+
if (typeof props.customTotal === "string")
|
|
30
|
+
return props.customTotal;
|
|
31
|
+
const totals = Number(props.total);
|
|
32
|
+
if (isNaN(totals))
|
|
33
|
+
return "0";
|
|
34
|
+
const HUNDRED_THOUSAND = 1e5;
|
|
35
|
+
const MILLION = 1e6;
|
|
36
|
+
const TEN_MILLION = 1e7;
|
|
37
|
+
if (totals < HUNDRED_THOUSAND) {
|
|
38
|
+
return String(totals);
|
|
39
|
+
} else if (totals < MILLION) {
|
|
40
|
+
return t("ui.page.hundredThousand");
|
|
41
|
+
} else if (totals < TEN_MILLION) {
|
|
42
|
+
return t("ui.page.million");
|
|
43
|
+
} else {
|
|
44
|
+
return t("ui.page.tenMillion");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const computedInternalPageCount = ({ props, state }) => () => {
|
|
48
|
+
if (typeof props.total === "number") {
|
|
49
|
+
return Math.max(1, Math.ceil(props.total / state.internalPageSize));
|
|
50
|
+
} else if (typeof props.pageCount === "number") {
|
|
51
|
+
return Math.max(1, props.pageCount);
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
const handleJumperFocus = ({ state }) => (e) => {
|
|
56
|
+
var _a;
|
|
57
|
+
state.jumperBackup = (_a = e.target) == null ? void 0 : _a.value;
|
|
58
|
+
};
|
|
59
|
+
const watchInternalCurrentPage = ({ state, emit }) => (currentPage) => {
|
|
60
|
+
const value = String(currentPage);
|
|
61
|
+
if (state.jumperValue !== value) {
|
|
62
|
+
state.jumperValue = value;
|
|
63
|
+
}
|
|
64
|
+
emit("update:current-page", currentPage);
|
|
65
|
+
emit("current-change", currentPage);
|
|
66
|
+
state.lastEmittedPage = -1;
|
|
67
|
+
};
|
|
68
|
+
const watchPageSizes = ({ state, props }) => (newVal) => {
|
|
69
|
+
if (Array.isArray(newVal)) {
|
|
70
|
+
state.internalPageSize = newVal.includes(props.pageSize) ? props.pageSize : newVal[0];
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const watchCurrentPage = ({ state, api }) => (curPage) => {
|
|
74
|
+
state.internalCurrentPage = api.getValidCurrentPage(curPage);
|
|
75
|
+
};
|
|
76
|
+
const watchInternalPageCount = ({ state, api }) => (pageCount) => {
|
|
77
|
+
const oldCurPage = state.internalCurrentPage;
|
|
78
|
+
if (pageCount && pageCount > 0 && oldCurPage === 0) {
|
|
79
|
+
state.internalCurrentPage = 1;
|
|
80
|
+
} else if (oldCurPage > Number(pageCount)) {
|
|
81
|
+
state.internalCurrentPage = pageCount || 1;
|
|
82
|
+
state.userChangePageSize && api.emitChange();
|
|
83
|
+
}
|
|
84
|
+
state.userChangePageSize = false;
|
|
85
|
+
};
|
|
86
|
+
const watchPageSize = ({ state }) => (pageSize) => {
|
|
87
|
+
state.internalPageSize = isNaN(pageSize) ? 10 : pageSize;
|
|
88
|
+
};
|
|
89
|
+
const watchTotal = ({ state }) => (total) => {
|
|
90
|
+
state.internalTotal = total;
|
|
91
|
+
};
|
|
92
|
+
const watchShowSizes = ({ nextTick, vm }) => (newVal) => {
|
|
93
|
+
if (newVal) {
|
|
94
|
+
nextTick(() => {
|
|
95
|
+
const width = vm.$refs.pageSize[0].getBoundingClientRect().width;
|
|
96
|
+
const popover = document.querySelectorAll(".tiny-pager__selector");
|
|
97
|
+
Array.from(popover).forEach((ele) => {
|
|
98
|
+
ele.style.width = width + "px";
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const handleSizeChange = ({ props, state, api, emit, vm }) => (val) => {
|
|
104
|
+
val = Number(val);
|
|
105
|
+
if (val !== state.internalPageSize) {
|
|
106
|
+
const callback = () => {
|
|
107
|
+
if (!api.beforeChangeHandler()) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
state.internalPageSize = val;
|
|
111
|
+
state.userChangePageSize = true;
|
|
112
|
+
state.showSizes = false;
|
|
113
|
+
emit("update:pageSize", val);
|
|
114
|
+
emit("size-change", val);
|
|
115
|
+
emit("page-change", {
|
|
116
|
+
currentPage: state.internalCurrentPage,
|
|
117
|
+
pageSize: val,
|
|
118
|
+
total: state.internalTotal
|
|
119
|
+
});
|
|
120
|
+
vm.$refs.sizesList[0].state.showPopper = false;
|
|
121
|
+
};
|
|
122
|
+
if (props.isBeforePageChange) {
|
|
123
|
+
let newPageSize = val;
|
|
124
|
+
let currentPageSize = state.internalPageSize;
|
|
125
|
+
let params = { newPageSize, currentPageSize, callback };
|
|
126
|
+
api.beforeSizeChangeHandler(params);
|
|
127
|
+
} else {
|
|
128
|
+
callback();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const handleJumperInput = ({ state }) => (e) => {
|
|
133
|
+
const target = e.target;
|
|
134
|
+
if (!target.value) {
|
|
135
|
+
state.jumperValue = "";
|
|
136
|
+
} else if (/^\d+$/.test(target.value)) {
|
|
137
|
+
state.jumperValue = target.value || "1";
|
|
138
|
+
}
|
|
139
|
+
target.value = state.jumperValue;
|
|
140
|
+
};
|
|
141
|
+
const handleJumperChange = ({ props, state, api }) => () => {
|
|
142
|
+
api.parseValueNumber();
|
|
143
|
+
const callback = () => {
|
|
144
|
+
api.handleJumperClick();
|
|
145
|
+
};
|
|
146
|
+
const rollback = () => {
|
|
147
|
+
state.jumperValue = String(state.jumperBackup);
|
|
148
|
+
};
|
|
149
|
+
const newPage = state.jumperValue;
|
|
150
|
+
const currentPage = state.jumperBackup;
|
|
151
|
+
if (props.isBeforePageChange && newPage !== currentPage) {
|
|
152
|
+
const params = { newPage, currentPage, callback, rollback };
|
|
153
|
+
api.beforePagerChangeHandler(params);
|
|
154
|
+
} else {
|
|
155
|
+
callback();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const handleJumperClick = ({ props, state, api }) => () => {
|
|
159
|
+
if (!api.canJumperGo() || props.disabled)
|
|
160
|
+
return;
|
|
161
|
+
state.internalCurrentPage = api.getValidCurrentPage(state.jumperValue);
|
|
162
|
+
api.emitChange();
|
|
163
|
+
};
|
|
164
|
+
const isValueNumber = ({ state }) => () => {
|
|
165
|
+
return !isNaN(Number(state.jumperValue));
|
|
166
|
+
};
|
|
167
|
+
const parseValueNumber = ({ state }) => () => {
|
|
168
|
+
let value = Number(
|
|
169
|
+
String(state.jumperValue).split(/[^0-9-+.]/).join("")
|
|
170
|
+
);
|
|
171
|
+
if (isNaN(value)) {
|
|
172
|
+
value = 1;
|
|
173
|
+
}
|
|
174
|
+
value = Number(value.toFixed(0));
|
|
175
|
+
const min = 1;
|
|
176
|
+
const max = state.internalPageCount || 1;
|
|
177
|
+
if (value >= max) {
|
|
178
|
+
state.jumperValue = String(max);
|
|
179
|
+
} else if (value <= min) {
|
|
180
|
+
state.jumperValue = String(min);
|
|
181
|
+
} else {
|
|
182
|
+
state.jumperValue = String(value);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const handleSizeShowPopover = ({ state, props }) => () => {
|
|
186
|
+
if (props.disabled) {
|
|
187
|
+
state.showSizes = false;
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
state.showSizes = true;
|
|
191
|
+
};
|
|
192
|
+
const handleSizeHidePopover = ({ state }) => () => {
|
|
193
|
+
state.showSizes = false;
|
|
194
|
+
};
|
|
195
|
+
const canJumperGo = ({ props, state, vm }) => () => {
|
|
196
|
+
const inputValue = Number(vm.$refs.jumperInput[0].value || 0);
|
|
197
|
+
const currentPage = Number(state.internalCurrentPage || 0);
|
|
198
|
+
return props.accurateJumper ? inputValue !== currentPage : true;
|
|
199
|
+
};
|
|
200
|
+
const beforeSizeChangeHandler = ({ state, emit }) => (params) => {
|
|
201
|
+
const { newPageSize, currentPageSize, callback } = params;
|
|
202
|
+
const newPage = 1;
|
|
203
|
+
const currentPage = state.internalCurrentPage;
|
|
204
|
+
const temp = {
|
|
205
|
+
newPage,
|
|
206
|
+
newPageSize,
|
|
207
|
+
currentPage,
|
|
208
|
+
currentPageSize,
|
|
209
|
+
callback
|
|
210
|
+
};
|
|
211
|
+
emit("before-page-change", temp);
|
|
212
|
+
};
|
|
213
|
+
const beforePagerChangeHandler = ({ state, emit }) => (params) => {
|
|
214
|
+
const { newPage, currentPage, callback, rollback } = params;
|
|
215
|
+
const newPageSize = state.internalPageSize;
|
|
216
|
+
const currentPageSize = state.internalPageSize;
|
|
217
|
+
const temp = {
|
|
218
|
+
newPage,
|
|
219
|
+
newPageSize,
|
|
220
|
+
currentPage,
|
|
221
|
+
currentPageSize,
|
|
222
|
+
callback,
|
|
223
|
+
rollback
|
|
224
|
+
};
|
|
225
|
+
emit("before-page-change", temp);
|
|
226
|
+
};
|
|
227
|
+
const beforeJumperChangeHandler = ({ state, emit }) => (params) => {
|
|
228
|
+
const { newPage, currentPage, callback, rollback } = params;
|
|
229
|
+
const newPageSize = state.internalPageSize;
|
|
230
|
+
const currentPageSize = state.internalPageSize;
|
|
231
|
+
const temp = {
|
|
232
|
+
newPage,
|
|
233
|
+
newPageSize,
|
|
234
|
+
currentPage,
|
|
235
|
+
currentPageSize,
|
|
236
|
+
callback,
|
|
237
|
+
rollback
|
|
238
|
+
};
|
|
239
|
+
emit("before-page-change", temp);
|
|
240
|
+
};
|
|
241
|
+
const copyEmit = ({ emit }) => (...args) => {
|
|
242
|
+
emit(args[0], ...args.slice(1));
|
|
243
|
+
};
|
|
244
|
+
const beforeChangeHandler = ({ state, api }) => (val = -1) => {
|
|
245
|
+
return emitEvent(api.copyEmit, "before-change", state.internalCurrentPage, void 0, val);
|
|
246
|
+
};
|
|
247
|
+
const handleCurrentChange = ({ state, api }) => (val) => {
|
|
248
|
+
if (!api.beforeChangeHandler(val)) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
state.internalCurrentPage = api.getValidCurrentPage(val);
|
|
252
|
+
state.userChangePageSize = true;
|
|
253
|
+
api.emitChange();
|
|
254
|
+
};
|
|
255
|
+
const prev = ({ state, props, api, emit }) => () => {
|
|
256
|
+
const callback = () => {
|
|
257
|
+
if (props.disabled || !api.beforeChangeHandler(state.internalCurrentPage - 1)) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const newVal = state.internalCurrentPage - 1;
|
|
261
|
+
state.internalCurrentPage = api.getValidCurrentPage(newVal);
|
|
262
|
+
emit("prev-click", state.internalCurrentPage);
|
|
263
|
+
api.emitChange();
|
|
264
|
+
};
|
|
265
|
+
if (props.isBeforePageChange) {
|
|
266
|
+
const newPage = state.internalCurrentPage - 1;
|
|
267
|
+
const temp = api.buildBeforePageChangeParam({ newPage, callback });
|
|
268
|
+
emit("before-page-change", temp);
|
|
269
|
+
} else {
|
|
270
|
+
callback();
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const next = ({ props, state, api, emit }) => () => {
|
|
274
|
+
const callback = () => {
|
|
275
|
+
if (props.disabled || !api.beforeChangeHandler(state.internalCurrentPage + 1)) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const newVal = state.internalCurrentPage + 1;
|
|
279
|
+
state.internalCurrentPage = api.getValidCurrentPage(newVal);
|
|
280
|
+
emit("next-click", state.internalCurrentPage);
|
|
281
|
+
api.emitChange();
|
|
282
|
+
};
|
|
283
|
+
if (props.isBeforePageChange) {
|
|
284
|
+
const newPage = state.internalCurrentPage + 1;
|
|
285
|
+
const temp = api.buildBeforePageChangeParam({ newPage, callback });
|
|
286
|
+
emit("before-page-change", temp);
|
|
287
|
+
} else {
|
|
288
|
+
callback();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const buildBeforePageChangeParam = ({ state }) => (param) => {
|
|
292
|
+
const currentPage = state.internalCurrentPage;
|
|
293
|
+
const newPageSize = state.internalPageSize;
|
|
294
|
+
const currentPageSize = state.internalPageSize;
|
|
295
|
+
return __spreadValues({ currentPage, newPageSize, currentPageSize }, param);
|
|
296
|
+
};
|
|
297
|
+
const getValidCurrentPage = ({ state }) => (val) => {
|
|
298
|
+
const parseVal = Number(val);
|
|
299
|
+
const hasPageCount = typeof state.internalPageCount === "number";
|
|
300
|
+
let resetVal;
|
|
301
|
+
if (hasPageCount) {
|
|
302
|
+
if (parseVal < 1) {
|
|
303
|
+
resetVal = 1;
|
|
304
|
+
} else if (parseVal > (state.internalPageCount || 0)) {
|
|
305
|
+
resetVal = state.internalPageCount;
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
if (isNaN(parseVal) || parseVal < 1) {
|
|
309
|
+
resetVal = 1;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (resetVal === void 0 && isNaN(parseVal)) {
|
|
313
|
+
resetVal = 1;
|
|
314
|
+
} else if (resetVal === 0) {
|
|
315
|
+
resetVal = 1;
|
|
316
|
+
}
|
|
317
|
+
return resetVal === void 0 ? parseVal : resetVal;
|
|
318
|
+
};
|
|
319
|
+
const emitChange = ({ state, nextTick, emit }) => () => {
|
|
320
|
+
nextTick(() => {
|
|
321
|
+
if (state.internalCurrentPage !== state.lastEmittedPage || state.userChangePageSize) {
|
|
322
|
+
emit("update:current-page", state.internalCurrentPage);
|
|
323
|
+
emit("page-change", {
|
|
324
|
+
currentPage: state.internalCurrentPage,
|
|
325
|
+
pageSize: state.internalPageSize,
|
|
326
|
+
total: state.internalTotal
|
|
327
|
+
});
|
|
328
|
+
state.lastEmittedPage = state.internalCurrentPage;
|
|
329
|
+
state.userChangePageSize = false;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
const setTotal = ({ state }) => (val) => {
|
|
334
|
+
state.internalTotal = val;
|
|
335
|
+
};
|
|
336
|
+
const clickSizes = () => (e) => e.stopPropagation();
|
|
337
|
+
export {
|
|
338
|
+
beforeChangeHandler,
|
|
339
|
+
beforeJumperChangeHandler,
|
|
340
|
+
beforePagerChangeHandler,
|
|
341
|
+
beforeSizeChangeHandler,
|
|
342
|
+
buildBeforePageChangeParam,
|
|
343
|
+
canJumperGo,
|
|
344
|
+
clickSizes,
|
|
345
|
+
computedInternalLayout,
|
|
346
|
+
computedInternalPageCount,
|
|
347
|
+
computedShowPager,
|
|
348
|
+
computedTotalText,
|
|
349
|
+
copyEmit,
|
|
350
|
+
emitChange,
|
|
351
|
+
getValidCurrentPage,
|
|
352
|
+
handleCurrentChange,
|
|
353
|
+
handleJumperChange,
|
|
354
|
+
handleJumperClick,
|
|
355
|
+
handleJumperFocus,
|
|
356
|
+
handleJumperInput,
|
|
357
|
+
handleSizeChange,
|
|
358
|
+
handleSizeHidePopover,
|
|
359
|
+
handleSizeShowPopover,
|
|
360
|
+
isValueNumber,
|
|
361
|
+
next,
|
|
362
|
+
parseValueNumber,
|
|
363
|
+
prev,
|
|
364
|
+
setTotal,
|
|
365
|
+
watchCurrentPage,
|
|
366
|
+
watchInternalCurrentPage,
|
|
367
|
+
watchInternalPageCount,
|
|
368
|
+
watchPageSize,
|
|
369
|
+
watchPageSizes,
|
|
370
|
+
watchShowSizes,
|
|
371
|
+
watchTotal
|
|
372
|
+
};
|
package/pager/vue.js
CHANGED
|
@@ -1,7 +1,130 @@
|
|
|
1
1
|
import "../chunk-G2ADBYYC.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
computedShowPager,
|
|
4
|
+
computedInternalLayout,
|
|
5
|
+
computedTotalText,
|
|
6
|
+
computedInternalPageCount,
|
|
7
|
+
handleJumperFocus,
|
|
8
|
+
handleSizeChange,
|
|
9
|
+
handleJumperInput,
|
|
10
|
+
handleJumperChange,
|
|
11
|
+
handleJumperClick,
|
|
12
|
+
isValueNumber,
|
|
13
|
+
parseValueNumber,
|
|
14
|
+
handleSizeShowPopover,
|
|
15
|
+
handleSizeHidePopover,
|
|
16
|
+
canJumperGo,
|
|
17
|
+
beforeSizeChangeHandler,
|
|
18
|
+
beforePagerChangeHandler,
|
|
19
|
+
copyEmit,
|
|
20
|
+
beforeChangeHandler,
|
|
21
|
+
handleCurrentChange,
|
|
22
|
+
prev,
|
|
23
|
+
next,
|
|
24
|
+
buildBeforePageChangeParam,
|
|
25
|
+
getValidCurrentPage,
|
|
26
|
+
emitChange,
|
|
27
|
+
setTotal,
|
|
28
|
+
clickSizes,
|
|
29
|
+
watchInternalCurrentPage,
|
|
30
|
+
watchPageSizes,
|
|
31
|
+
watchCurrentPage,
|
|
32
|
+
watchInternalPageCount,
|
|
33
|
+
watchPageSize,
|
|
34
|
+
watchTotal,
|
|
35
|
+
watchShowSizes
|
|
36
|
+
} from "./index";
|
|
37
|
+
const api = [
|
|
38
|
+
"state",
|
|
39
|
+
"handleJumperFocus",
|
|
40
|
+
"handleSizeChange",
|
|
41
|
+
"handleJumperInput",
|
|
42
|
+
"handleJumperChange",
|
|
43
|
+
"handleJumperClick",
|
|
44
|
+
"isValueNumber",
|
|
45
|
+
"parseValueNumber",
|
|
46
|
+
"handleSizeShowPopover",
|
|
47
|
+
"handleSizeHidePopover",
|
|
48
|
+
"canJumperGo",
|
|
49
|
+
"beforeSizeChangeHandler",
|
|
50
|
+
"beforePagerChangeHandler",
|
|
51
|
+
"beforeJumperChangeHandler",
|
|
52
|
+
"beforeChangeHandler",
|
|
53
|
+
"handleCurrentChange",
|
|
54
|
+
"prev",
|
|
55
|
+
"next",
|
|
56
|
+
"buildBeforePageChangeParam",
|
|
57
|
+
"getValidCurrentPage",
|
|
58
|
+
"emitChange",
|
|
59
|
+
"setTotal",
|
|
60
|
+
"clickSizes"
|
|
61
|
+
];
|
|
62
|
+
const renderless = (props, { reactive, computed, watch }, { emit, vm, nextTick, t, designConfig }) => {
|
|
63
|
+
var _a, _b, _c;
|
|
4
64
|
const api2 = {};
|
|
65
|
+
const state = reactive({
|
|
66
|
+
showSizes: false,
|
|
67
|
+
internalCurrentPage: 1,
|
|
68
|
+
internalPageSize: props.pageSize,
|
|
69
|
+
lastEmittedPage: -1,
|
|
70
|
+
userChangePageSize: false,
|
|
71
|
+
internalTotal: props.total,
|
|
72
|
+
jumperValue: "1",
|
|
73
|
+
jumperBackup: "1",
|
|
74
|
+
showPager: computed(() => api2.computedShowPager()),
|
|
75
|
+
internalLayout: computed(() => api2.computedInternalLayout()),
|
|
76
|
+
totalText: computed(() => api2.computedTotalText()),
|
|
77
|
+
internalPageCount: computed(() => api2.computedInternalPageCount()),
|
|
78
|
+
showJumperSufix: (_a = designConfig == null ? void 0 : designConfig.state.showJumperSufix) != null ? _a : true,
|
|
79
|
+
align: props.align || (designConfig == null ? void 0 : designConfig.state.align) || "left",
|
|
80
|
+
totalI18n: (designConfig == null ? void 0 : designConfig.state.totalI18n) || "totals",
|
|
81
|
+
totalFixedLeft: (_c = (_b = props.totalFixedLeft) != null ? _b : designConfig == null ? void 0 : designConfig.state.totalFixedLeft) != null ? _c : false
|
|
82
|
+
});
|
|
83
|
+
Object.assign(api2, {
|
|
84
|
+
state,
|
|
85
|
+
computedShowPager: computedShowPager({ props, state }),
|
|
86
|
+
computedInternalLayout: computedInternalLayout({ props }),
|
|
87
|
+
computedTotalText: computedTotalText({ props, t }),
|
|
88
|
+
computedInternalPageCount: computedInternalPageCount({ props, state }),
|
|
89
|
+
getValidCurrentPage: getValidCurrentPage({ state }),
|
|
90
|
+
handleJumperFocus: handleJumperFocus({ state }),
|
|
91
|
+
handleSizeChange: handleSizeChange({ props, state, api: api2, emit, vm }),
|
|
92
|
+
handleJumperInput: handleJumperInput({ state }),
|
|
93
|
+
handleJumperChange: handleJumperChange({ props, state, api: api2 }),
|
|
94
|
+
handleJumperClick: handleJumperClick({ props, state, api: api2 }),
|
|
95
|
+
isValueNumber: isValueNumber({ state }),
|
|
96
|
+
parseValueNumber: parseValueNumber({ state }),
|
|
97
|
+
handleSizeShowPopover: handleSizeShowPopover({ state, props }),
|
|
98
|
+
handleSizeHidePopover: handleSizeHidePopover({ state }),
|
|
99
|
+
canJumperGo: canJumperGo({ props, state, vm }),
|
|
100
|
+
beforeSizeChangeHandler: beforeSizeChangeHandler({ state, emit }),
|
|
101
|
+
beforePagerChangeHandler: beforePagerChangeHandler({ state, emit }),
|
|
102
|
+
copyEmit: copyEmit({ emit }),
|
|
103
|
+
beforeChangeHandler: beforeChangeHandler({ state, api: api2 }),
|
|
104
|
+
handleCurrentChange: handleCurrentChange({ state, api: api2 }),
|
|
105
|
+
prev: prev({ state, props, api: api2, emit }),
|
|
106
|
+
next: next({ props, state, api: api2, emit }),
|
|
107
|
+
buildBeforePageChangeParam: buildBeforePageChangeParam({ state }),
|
|
108
|
+
emitChange: emitChange({ state, nextTick, emit }),
|
|
109
|
+
setTotal: setTotal({ state }),
|
|
110
|
+
clickSizes: clickSizes(),
|
|
111
|
+
// watch
|
|
112
|
+
watchInternalCurrentPage: watchInternalCurrentPage({ state, emit }),
|
|
113
|
+
watchPageSizes: watchPageSizes({ state, props }),
|
|
114
|
+
watchCurrentPage: watchCurrentPage({ state, api: api2 }),
|
|
115
|
+
watchInternalPageCount: watchInternalPageCount({ state, api: api2 }),
|
|
116
|
+
watchPageSize: watchPageSize({ state }),
|
|
117
|
+
watchTotal: watchTotal({ state }),
|
|
118
|
+
watchShowSizes: watchShowSizes({ nextTick, vm })
|
|
119
|
+
});
|
|
120
|
+
state.internalCurrentPage = api2.getValidCurrentPage(props.currentPage);
|
|
121
|
+
watch(() => state.internalCurrentPage, api2.watchInternalCurrentPage);
|
|
122
|
+
watch(() => props.pageSizes, api2.watchPageSizes, { immediate: true });
|
|
123
|
+
watch(() => props.currentPage, api2.watchCurrentPage);
|
|
124
|
+
watch(() => state.internalPageCount, api2.watchInternalPageCount);
|
|
125
|
+
watch(() => props.pageSize, api2.watchPageSize, { immediate: true });
|
|
126
|
+
watch(() => props.total, api2.watchTotal);
|
|
127
|
+
watch(() => state.showSizes, api2.watchShowSizes);
|
|
5
128
|
return api2;
|
|
6
129
|
};
|
|
7
130
|
export {
|