@opentiny/vue-renderless 3.6.7 → 3.8.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 +28 -1
- package/action-sheet/vue.js +10 -4
- package/alert/index.js +24 -2
- package/alert/vue.js +15 -11
- package/amount/index.js +4 -4
- package/anchor/index.js +1 -1
- package/autocomplete/vue.js +3 -3
- package/autonavi-map/index.js +1 -1
- package/badge/vue.js +6 -6
- package/baidu-map/index.js +1 -1
- package/bulletin-board/index.js +1 -1
- package/calendar/index.js +2 -2
- package/calendar-bar/index.js +268 -0
- package/calendar-bar/vue.js +87 -0
- package/card/index.js +84 -0
- package/card/vue.js +70 -0
- package/card-group/index.js +16 -0
- package/card-group/vue.js +21 -0
- package/card-template/index.js +1 -1
- package/carousel/index.js +89 -2
- package/carousel/vue.js +14 -5
- package/carousel-item/index.js +8 -0
- package/carousel-item/vue.js +7 -3
- package/cascader/index.js +6 -6
- package/cascader/vue.js +3 -3
- package/cascader-menu/vue.js +2 -2
- package/cascader-panel/index.js +4 -4
- package/cascader-panel/node.js +4 -4
- package/cascader-panel/vue.js +2 -2
- package/cascader-select/index.js +179 -0
- package/cascader-select/vue.js +74 -0
- package/cell/vue.js +16 -0
- package/chart-bar/index.js +3 -3
- package/chart-boxplot/index.js +2 -2
- package/chart-candle/index.js +3 -3
- package/chart-core/deps/utils.js +7 -7
- package/chart-core/index.js +2 -2
- package/chart-funnel/index.js +3 -3
- package/chart-gauge/index.js +3 -3
- package/chart-graph/index.js +1 -1
- package/chart-heatmap/index.js +2 -2
- package/chart-line/index.js +3 -3
- package/chart-liquidfill/index.js +2 -2
- package/chart-map/index.js +3 -3
- package/chart-pie/index.js +3 -3
- package/chart-radar/index.js +3 -3
- package/chart-sankey/index.js +3 -3
- package/chart-scatter/index.js +4 -4
- package/chart-sunburst/index.js +1 -1
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +3 -3
- package/chart-wordcloud/index.js +2 -2
- package/checkbox/index.js +21 -0
- package/checkbox/vue.js +16 -3
- package/checkbox-button/vue.js +1 -1
- package/collapse-item/vue.js +1 -1
- package/column-list-group/index.js +0 -0
- package/column-list-group/vue.js +14 -0
- package/column-list-item/index.js +50 -0
- package/column-list-item/vue.js +39 -0
- package/common/array.js +3 -3
- package/common/bigInt.js +5 -2
- package/common/dataset/index.js +3 -3
- package/common/date.js +2 -2
- package/common/deps/ResizeObserver.js +1 -1
- package/common/deps/clickoutside.js +1 -1
- package/common/deps/date-util.js +4 -4
- package/common/deps/date.js +2 -2
- package/common/deps/debounce.js +1 -1
- package/common/deps/dom.js +1 -1
- package/common/deps/fullscreen/apis.js +3 -3
- package/common/deps/fullscreen/screenfull.js +1 -1
- package/common/deps/infinite-scroll.js +176 -0
- package/common/deps/letter-only.js +1 -1
- package/common/deps/number-only.js +1 -1
- package/common/deps/observe-visibility.js +106 -0
- package/common/deps/popper.js +20 -22
- package/common/deps/popup-manager.js +2 -2
- package/common/deps/repeat-click.js +1 -1
- package/common/deps/resize-event.js +1 -1
- package/common/deps/tree-model/node.js +5 -5
- package/common/deps/tree-model/tree-store.js +3 -3
- package/common/deps/upload-ajax.js +2 -2
- package/common/deps/vue-popper.js +4 -4
- package/common/deps/vue-popup.js +4 -4
- package/common/index.js +2 -2
- package/common/object.js +1 -1
- package/common/runtime.js +24 -24
- package/common/string.js +23 -4
- package/common/validate/rules/range.js +2 -2
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +3 -3
- package/common/validate/schema.js +1 -1
- package/common/validate/util.js +1 -1
- package/common/validate/validations/array.js +1 -1
- package/common/validate/validations/date.js +1 -1
- package/common/validate/validations/enum.js +1 -1
- package/common/validate/validations/float.js +1 -1
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/common/validate/validations/number.js +1 -1
- package/common/validate/validations/pattern.js +1 -1
- package/common/validate/validations/string.js +1 -1
- package/common/validate/validations/type.js +1 -1
- package/container/index.js +1 -1
- package/crop/index.js +2 -2
- package/currency/index.js +2 -2
- package/date-panel/index.js +7 -7
- package/date-panel/vue.js +3 -2
- package/date-picker-mobile/index.js +250 -0
- package/date-picker-mobile/vue.js +86 -0
- package/date-range/index.js +1 -1
- package/date-range/vue.js +1 -1
- package/date-table/index.js +3 -3
- package/date-table/vue.js +1 -1
- package/dialog-box/index.js +10 -6
- package/dialog-box/vue.js +1 -1
- package/dialog-select/index.js +345 -0
- package/dialog-select/vue.js +110 -0
- package/drawer/index.js +83 -0
- package/drawer/vue.js +51 -0
- package/drop-times/index.js +1 -1
- package/dropdown/index.js +2 -2
- package/dropdown/vue.js +1 -1
- package/dropdown-item/index.js +1 -1
- package/dropdown-item/mf.js +79 -0
- package/dropdown-menu/index.js +30 -1
- package/dropdown-menu/vue.js +17 -7
- package/dynamic-scroller/index.js +117 -0
- package/dynamic-scroller/vue.js +88 -0
- package/dynamic-scroller-item/index.js +147 -0
- package/dynamic-scroller-item/vue.js +92 -0
- package/espace/index.js +1 -1
- package/espace/vue.js +1 -1
- package/exception/vue.js +3 -1
- package/fall-menu/index.js +4 -4
- package/file-upload/index.js +872 -408
- package/file-upload/vue.js +87 -36
- package/filter/index.js +131 -0
- package/filter/tag-group.js +43 -0
- package/filter/vue.js +73 -0
- package/filter-bar/index.js +9 -0
- package/filter-bar/vue.js +16 -0
- package/filter-box/index.js +17 -0
- package/filter-box/vue.js +19 -0
- package/filter-panel/index.js +42 -0
- package/filter-panel/vue.js +33 -0
- package/floatbar/index.js +1 -1
- package/flowchart/index.js +721 -0
- package/flowchart/vue.js +81 -0
- package/form/index.js +15 -1
- package/form/vue.js +10 -4
- package/form-item/index.js +46 -6
- package/form-item/vue.js +27 -3
- package/fullscreen/index.js +1 -1
- package/fullscreen/vue.js +1 -1
- package/grid/plugins/export.js +2 -2
- package/grid/plugins/exportExcel.js +2 -2
- package/grid/plugins/resize.js +1 -1
- package/grid/static/base/helperEqualCompare.js +1 -1
- package/grid/static/base/isPlainObject.js +1 -1
- package/grid/utils/common.js +3 -3
- package/grid/utils/dom.js +3 -3
- package/grid/utils/event.js +2 -2
- package/guide/index.js +168 -0
- package/guide/vue.js +36 -0
- package/hrapprover/index.js +1 -1
- package/image/index.js +8 -4
- package/image/vue.js +12 -6
- package/image-viewer/index.js +3 -3
- package/image-viewer/vue.js +16 -6
- package/input/index.js +34 -1
- package/input/vue.js +22 -6
- package/ip-address/index.js +1 -1
- package/ip-address/vue.js +1 -1
- package/link-menu/index.js +2 -2
- package/link-menu/vue.js +2 -2
- package/loading/index.js +2 -2
- package/loading/vue.js +2 -1
- package/locales/index.js +1 -1
- package/logout/index.js +1 -1
- package/milestone/index.js +5 -1
- package/modal/index.js +68 -39
- package/modal/vue.js +15 -12
- package/month-range/index.js +1 -1
- package/month-range/vue.js +1 -1
- package/month-table/index.js +5 -5
- package/month-table/vue.js +1 -1
- package/multi-select/index.js +5 -2
- package/multi-select/vue.js +4 -5
- package/nav-menu/index.js +6 -6
- package/notify/index.js +3 -3
- package/numeric/index.js +15 -5
- package/numeric/vue.js +15 -6
- package/option/index.js +1 -1
- package/package.json +2 -1
- package/pager-item/index.js +1 -1
- package/panel/index.js +1 -1
- package/picker/index.js +7 -7
- package/picker/vue.js +1 -1
- package/picker-column/index.js +1 -1
- package/popconfirm/index.js +25 -0
- package/popconfirm/vue.js +22 -0
- package/popeditor/index.js +7 -7
- package/popeditor/vue.js +2 -2
- package/popover/index.js +11 -3
- package/popover/vue.js +33 -10
- package/popup/index.js +4 -4
- package/pull-refresh/index.js +8 -11
- package/pull-refresh/vue.js +7 -7
- package/radio/index.js +17 -0
- package/radio/vue.js +18 -3
- package/radio-button/index.js +8 -0
- package/radio-button/vue.js +19 -4
- package/radio-group/index.js +1 -1
- package/radio-group/vue.js +5 -2
- package/rate/index.js +4 -2
- package/rate/vue.js +1 -1
- package/record/index.js +190 -0
- package/record/vue.js +44 -0
- package/recycle-scroller/index.js +470 -0
- package/recycle-scroller/vue.js +135 -0
- package/river/index.js +371 -0
- package/river/river.js +352 -0
- package/river/vue.js +77 -0
- package/roles/index.js +1 -1
- package/scrollbar/vue-bar.js +1 -1
- package/scrollbar/vue.js +1 -1
- package/search/index.js +3 -3
- package/select/index.js +17 -14
- package/select/vue.js +14 -8
- package/select-dropdown/vue.js +1 -1
- package/select-mobile/index.js +111 -0
- package/select-mobile/vue.js +58 -0
- package/select-view/index.js +170 -0
- package/select-view/vue.js +82 -0
- package/selected-box/index.js +216 -0
- package/selected-box/vue.js +98 -0
- package/slide-bar/index.js +1 -1
- package/slider/index.js +49 -4
- package/slider/vue.js +15 -4
- package/split/vue.js +1 -1
- package/standard-list-item/index.js +18 -0
- package/standard-list-item/vue.js +22 -0
- package/steps/index.js +30 -0
- package/steps/slide-bar.js +122 -0
- package/steps/vue.js +15 -3
- package/switch/index.js +1 -1
- package/switch/vue.js +2 -1
- package/tab-bar/index.js +2 -2
- package/tab-item/index.js +2 -2
- package/tab-item/vue.js +1 -1
- package/tab-item-mf/index.js +0 -0
- package/tab-item-mf/vue.js +16 -0
- package/tab-nav/index.js +78 -4
- package/tab-nav/vue.js +11 -3
- package/tabbar-item/index.js +1 -1
- package/tabbar-item/vue.js +1 -1
- package/tabs/index.js +8 -9
- package/tabs/vue.js +1 -1
- package/tabs-mf/index.js +109 -0
- package/tabs-mf/vue-bar.js +49 -0
- package/tabs-mf/vue-nav-item.js +22 -0
- package/tabs-mf/vue-nav.js +13 -0
- package/tabs-mf/vue.js +45 -0
- package/tabs-mf/wheel.js +71 -0
- package/tag/index.js +8 -2
- package/tag/vue.js +13 -5
- package/tag-group/index.js +24 -0
- package/tag-group/vue.js +29 -0
- package/tall-storage/index.js +1 -1
- package/tall-storage/vue.js +1 -1
- package/time/index.js +1 -1
- package/time/vue.js +2 -2
- package/time-line/index.js +28 -7
- package/time-line/vue.js +9 -4
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +1 -1
- package/time-picker-mobile/index.js +30 -0
- package/time-picker-mobile/vue.js +30 -0
- package/time-range/index.js +1 -1
- package/time-range/vue.js +1 -1
- package/time-spinner/index.js +2 -2
- package/time-spinner/vue.js +1 -1
- package/toggle-menu/index.js +2 -2
- package/toggle-menu/vue.js +1 -1
- package/tooltip/index.js +30 -3
- package/tooltip/vue.js +33 -12
- package/top-box/index.js +3 -3
- package/transfer/index.js +1 -1
- package/transfer-panel/index.js +2 -2
- package/tree/index.js +6 -6
- package/tree/vue.js +1 -1
- package/tree-node/index.js +1 -1
- package/upload/index.js +1 -2
- package/upload/vue.js +2 -2
- package/upload-dragger/index.js +5 -1
- package/upload-dragger/vue.js +9 -3
- package/upload-list/index.js +158 -8
- package/upload-list/vue.js +77 -25
- package/user/index.js +86 -70
- package/user/vue.js +15 -5
- package/user-account/vue.js +1 -1
- package/user-contact/index.js +49 -3
- package/user-contact/vue.js +17 -8
- package/user-head-group/vue.js +17 -0
- package/user-link/index.js +10 -2
- package/user-link/vue.js +11 -6
- package/wheel/index.js +1 -1
- package/wizard/index.js +3 -3
- package/year-range/index.js +125 -0
- package/year-range/vue.js +88 -0
- package/year-table/index.js +175 -11
- package/year-table/vue.js +17 -5
package/user-link/vue.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../chunk-PKUHTIDK.js";
|
|
2
|
-
import { getUsers, cacheUser, saveCache, initService } from "
|
|
3
|
-
import { initUser, showCard, showDetail } from "./index";
|
|
2
|
+
import { getUsers, cacheUser, saveCache, initService, syncCacheIds } from "../user";
|
|
3
|
+
import { initUser, showCard, showDetail, computedTextField, computedValueField } from "./index";
|
|
4
4
|
const api = ["state", "showCard", "showDetail"];
|
|
5
|
-
const renderless = (props, { reactive, watch }, { service }) => {
|
|
5
|
+
const renderless = (props, { reactive, watch, computed }, { service }) => {
|
|
6
6
|
service = initService({ props, service });
|
|
7
7
|
const api2 = {};
|
|
8
8
|
const state = reactive({
|
|
@@ -14,19 +14,24 @@ const renderless = (props, { reactive, watch }, { service }) => {
|
|
|
14
14
|
data: {},
|
|
15
15
|
spinner: true,
|
|
16
16
|
imgUrl: "",
|
|
17
|
-
batch: props.batch === false ? false : props.batch || service.batch
|
|
17
|
+
batch: props.batch === false ? false : props.batch || service.batch,
|
|
18
|
+
textField: computed(() => api2.computedTextField()),
|
|
19
|
+
valueField: computed(() => api2.computedValueField())
|
|
18
20
|
});
|
|
19
21
|
Object.assign(api2, {
|
|
20
22
|
state,
|
|
21
23
|
showDetail: showDetail(state),
|
|
22
24
|
saveCache: saveCache({ props }),
|
|
23
|
-
|
|
25
|
+
syncCacheIds: syncCacheIds({ props, state }),
|
|
26
|
+
cacheUser: cacheUser({ api: api2, props, service, state }),
|
|
24
27
|
initUser: initUser({ api: api2, props, state }),
|
|
25
28
|
getUsers: getUsers({ api: api2, props, state }),
|
|
26
29
|
showCard: showCard({ api: api2, service, state }),
|
|
27
30
|
getUserImageUrl: service.getUserImageUrl,
|
|
28
31
|
fetchW3Accounts: service.fetchW3Accounts,
|
|
29
|
-
fetchUserByUserId: service.fetchUserByUserId
|
|
32
|
+
fetchUserByUserId: service.fetchUserByUserId,
|
|
33
|
+
computedTextField: computedTextField({ service, props }),
|
|
34
|
+
computedValueField: computedValueField({ service, props })
|
|
30
35
|
});
|
|
31
36
|
watch(() => props.modelValue, api2.initUser, { immediate: true });
|
|
32
37
|
return api2;
|
package/wheel/index.js
CHANGED
package/wizard/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../chunk-PKUHTIDK.js";
|
|
2
|
-
import { format } from "
|
|
3
|
-
import { copyArray, extend } from "
|
|
4
|
-
import { isObject } from "
|
|
2
|
+
import { format } from "../common/date";
|
|
3
|
+
import { copyArray, extend } from "../common/object";
|
|
4
|
+
import { isObject } from "../common/type";
|
|
5
5
|
const lastStepHandle = ({ state, emit }) => () => {
|
|
6
6
|
for (let i = 0; i < state.datas.length; i++) {
|
|
7
7
|
if (state.datas[0].status === state.doing) {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
import { isDate, nextYear, nextMonth } from "../common/deps/date-util";
|
|
3
|
+
import { DATEPICKER } from "../common";
|
|
4
|
+
const calcDefaultValue = (value) => {
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
return [new Date(value[0]), new Date(value[1])];
|
|
7
|
+
} else if (value) {
|
|
8
|
+
return [new Date(value), nextMonth(new Date(value))];
|
|
9
|
+
}
|
|
10
|
+
return [/* @__PURE__ */ new Date(), nextMonth(/* @__PURE__ */ new Date())];
|
|
11
|
+
};
|
|
12
|
+
const watchValue = ({ state }) => (data) => {
|
|
13
|
+
if (!data) {
|
|
14
|
+
state.minDate = null;
|
|
15
|
+
state.maxDate = null;
|
|
16
|
+
} else if (Array.isArray(data)) {
|
|
17
|
+
if (isDate(data[1])) {
|
|
18
|
+
state.maxDate = new Date(data[1]);
|
|
19
|
+
} else {
|
|
20
|
+
state.maxDate = null;
|
|
21
|
+
}
|
|
22
|
+
if (isDate(data[0])) {
|
|
23
|
+
state.minDate = new Date(data[0]);
|
|
24
|
+
} else {
|
|
25
|
+
state.minDate = null;
|
|
26
|
+
}
|
|
27
|
+
if (!state.minDate) {
|
|
28
|
+
state.leftDate = calcDefaultValue(state.defaultValue)[0];
|
|
29
|
+
state.rightDate = nextYear(state.leftDate);
|
|
30
|
+
} else {
|
|
31
|
+
state.leftDate = state.minDate;
|
|
32
|
+
if (state.maxDate && state.unlinkPanels) {
|
|
33
|
+
const minDateYear = state.minDate.getFullYear();
|
|
34
|
+
const maxDateYear = state.maxDate.getFullYear();
|
|
35
|
+
state.rightDate = maxDateYear === minDateYear ? nextYear(state.maxDate) : state.maxDate;
|
|
36
|
+
} else {
|
|
37
|
+
state.rightDate = nextYear(state.leftDate);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const handleClear = ({ emit, state }) => () => {
|
|
43
|
+
state.maxDate = null;
|
|
44
|
+
state.minDate = null;
|
|
45
|
+
state.leftDate = calcDefaultValue(state.defaultValue)[0];
|
|
46
|
+
state.rightDate = nextYear(state.leftDate);
|
|
47
|
+
emit("pick", null);
|
|
48
|
+
};
|
|
49
|
+
const handleChangeRange = (state) => (val) => {
|
|
50
|
+
state.rangeState = val.rangeState;
|
|
51
|
+
state.minDate = val.minDate;
|
|
52
|
+
state.maxDate = val.maxDate;
|
|
53
|
+
};
|
|
54
|
+
const watchDefaultValue = ({ state }) => (data) => {
|
|
55
|
+
if (!Array.isArray(state.value)) {
|
|
56
|
+
const [left, right] = calcDefaultValue(data);
|
|
57
|
+
state.leftDate = left;
|
|
58
|
+
state.rightDate = data && data[1] && left.getFullYear() !== right.getFullYear() && state.unlinkPanels ? right : nextYear(state.leftDate);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const handleRangePick = ({ api, state }) => (val, close = true) => {
|
|
62
|
+
const maxDate = val.maxDate;
|
|
63
|
+
const minDate = val.minDate;
|
|
64
|
+
if (state.minDate === minDate && state.maxDate === maxDate) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (state.onPick) {
|
|
68
|
+
state.onPick(val);
|
|
69
|
+
}
|
|
70
|
+
state.minDate = minDate;
|
|
71
|
+
state.maxDate = maxDate;
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
state.minDate = minDate;
|
|
74
|
+
state.maxDate = maxDate;
|
|
75
|
+
}, 10);
|
|
76
|
+
if (!close) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
api.handleConfirm();
|
|
80
|
+
};
|
|
81
|
+
const handleShortcutClick = (api) => (shortcutEvent) => {
|
|
82
|
+
if (shortcutEvent.onClick) {
|
|
83
|
+
const choose = {
|
|
84
|
+
$emit: (type, [start, end]) => {
|
|
85
|
+
api.doPick(start, end);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
shortcutEvent.onClick(choose);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const doPick = (emit) => (begin, end) => {
|
|
92
|
+
emit("pick", [begin, end], false);
|
|
93
|
+
};
|
|
94
|
+
const leftPrevYear = (state) => () => {
|
|
95
|
+
state.leftStartYear = state.leftStartYear - DATEPICKER.PanelYearNum * 2;
|
|
96
|
+
};
|
|
97
|
+
const rightNextYear = (state) => () => {
|
|
98
|
+
state.leftStartYear = state.leftStartYear + DATEPICKER.PanelYearNum * 2;
|
|
99
|
+
};
|
|
100
|
+
const handleConfirm = ({ api, emit, state }) => (show = false) => {
|
|
101
|
+
const { minDate, maxDate } = state;
|
|
102
|
+
api.isValidValue([minDate, maxDate]) && emit("pick", [new Date(minDate, 0, 2), new Date(maxDate, 0, 2)], show);
|
|
103
|
+
};
|
|
104
|
+
const isValidValue = (state) => (data) => {
|
|
105
|
+
return data && Array.isArray(data) && data[1] && data[0] && isDate(data[1]) && isDate(data[0]) && data[0] <= data[1] && (typeof state.disabledDate === "function" ? !state.disabledDate(data[1]) && !state.disabledDate(data[0]) : true);
|
|
106
|
+
};
|
|
107
|
+
const resetView = (state) => () => {
|
|
108
|
+
state.maxDate = state.value && isDate(state.value[0]) ? new Date(state.value[1]) : null;
|
|
109
|
+
state.minDate = state.value && isDate(state.value[0]) ? new Date(state.value[0]) : null;
|
|
110
|
+
};
|
|
111
|
+
export {
|
|
112
|
+
calcDefaultValue,
|
|
113
|
+
doPick,
|
|
114
|
+
handleChangeRange,
|
|
115
|
+
handleClear,
|
|
116
|
+
handleConfirm,
|
|
117
|
+
handleRangePick,
|
|
118
|
+
handleShortcutClick,
|
|
119
|
+
isValidValue,
|
|
120
|
+
leftPrevYear,
|
|
121
|
+
resetView,
|
|
122
|
+
rightNextYear,
|
|
123
|
+
watchDefaultValue,
|
|
124
|
+
watchValue
|
|
125
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
import {
|
|
3
|
+
handleChangeRange,
|
|
4
|
+
resetView,
|
|
5
|
+
rightNextYear,
|
|
6
|
+
isValidValue,
|
|
7
|
+
handleConfirm,
|
|
8
|
+
leftPrevYear,
|
|
9
|
+
watchValue,
|
|
10
|
+
handleShortcutClick,
|
|
11
|
+
watchDefaultValue,
|
|
12
|
+
handleRangePick,
|
|
13
|
+
handleClear,
|
|
14
|
+
doPick
|
|
15
|
+
} from "./index";
|
|
16
|
+
import { DATEPICKER } from "../common";
|
|
17
|
+
import { nextYear } from "../common/deps/date-util";
|
|
18
|
+
const api = [
|
|
19
|
+
"state",
|
|
20
|
+
"rightNextYear",
|
|
21
|
+
"handleRangePick",
|
|
22
|
+
"handleShortcutClick",
|
|
23
|
+
"handleChangeRange",
|
|
24
|
+
"leftPrevYear"
|
|
25
|
+
];
|
|
26
|
+
const initState = ({ reactive, computed, api: api2, t }) => {
|
|
27
|
+
const state = reactive({
|
|
28
|
+
selectionMode: DATEPICKER.YearRange,
|
|
29
|
+
popperClass: "",
|
|
30
|
+
value: [],
|
|
31
|
+
defaultValue: null,
|
|
32
|
+
defaultTime: null,
|
|
33
|
+
minDate: "",
|
|
34
|
+
maxDate: "",
|
|
35
|
+
leftDate: /* @__PURE__ */ new Date(),
|
|
36
|
+
rightDate: nextYear(/* @__PURE__ */ new Date()),
|
|
37
|
+
rangeState: { startDate: null, endDate: null, selecting: false, row: null, column: null },
|
|
38
|
+
shortcuts: "",
|
|
39
|
+
visible: "",
|
|
40
|
+
disabledDate: "",
|
|
41
|
+
format: "",
|
|
42
|
+
arrowControl: false,
|
|
43
|
+
unlinkPanels: false,
|
|
44
|
+
leftStartYear: Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 10) * 10,
|
|
45
|
+
rightStartYear: computed(() => state.leftStartYear + DATEPICKER.PanelYearNum),
|
|
46
|
+
btnDisabled: computed(
|
|
47
|
+
() => !(state.minDate && state.maxDate && !state.selecting && api2.isValidValue([state.minDate, state.maxDate]))
|
|
48
|
+
),
|
|
49
|
+
leftLabel: computed(
|
|
50
|
+
() => `${state.leftStartYear} ${t("ui.datepicker.year")} - ${state.leftStartYear + DATEPICKER.PanelYearNum - 1} ${t(
|
|
51
|
+
"ui.datepicker.year"
|
|
52
|
+
)}`
|
|
53
|
+
),
|
|
54
|
+
rightLabel: computed(
|
|
55
|
+
() => `${state.rightStartYear} ${t("ui.datepicker.year")} - ${state.rightStartYear + DATEPICKER.PanelYearNum - 1} ${t(
|
|
56
|
+
"ui.datepicker.year"
|
|
57
|
+
)}`
|
|
58
|
+
)
|
|
59
|
+
});
|
|
60
|
+
return state;
|
|
61
|
+
};
|
|
62
|
+
const renderless = (props, { computed, reactive, watch }, { t, emit: $emit }) => {
|
|
63
|
+
const emit = props.emitter ? props.emitter.emit : $emit;
|
|
64
|
+
const api2 = {};
|
|
65
|
+
const state = initState({ reactive, computed, api: api2, t });
|
|
66
|
+
Object.assign(api2, {
|
|
67
|
+
state,
|
|
68
|
+
doPick: doPick(emit),
|
|
69
|
+
resetView: resetView(state),
|
|
70
|
+
watchValue: watchValue({ state }),
|
|
71
|
+
isValidValue: isValidValue(state),
|
|
72
|
+
leftPrevYear: leftPrevYear(state),
|
|
73
|
+
rightNextYear: rightNextYear(state),
|
|
74
|
+
handleClear: handleClear({ emit, state }),
|
|
75
|
+
handleChangeRange: handleChangeRange(state),
|
|
76
|
+
handleShortcutClick: handleShortcutClick(api2),
|
|
77
|
+
watchDefaultValue: watchDefaultValue({ state }),
|
|
78
|
+
handleConfirm: handleConfirm({ api: api2, emit, state }),
|
|
79
|
+
handleRangePick: handleRangePick({ api: api2, state, t })
|
|
80
|
+
});
|
|
81
|
+
watch(() => state.value, api2.watchValue);
|
|
82
|
+
watch(() => state.defaultValue, api2.watchDefaultValue);
|
|
83
|
+
return api2;
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
api,
|
|
87
|
+
renderless
|
|
88
|
+
};
|
package/year-table/index.js
CHANGED
|
@@ -1,34 +1,198 @@
|
|
|
1
1
|
import "../chunk-PKUHTIDK.js";
|
|
2
|
-
import { toDate } from "
|
|
3
|
-
import { hasClass } from "
|
|
4
|
-
import { range, nextDate, getDayCountOfYear } from "
|
|
5
|
-
import { arrayFindIndex, coerceTruthyValueToArray } from "
|
|
2
|
+
import { toDate } from "../common/date";
|
|
3
|
+
import { hasClass } from "../common/deps/dom";
|
|
4
|
+
import { range, nextDate, getDayCountOfYear } from "../common/deps/date-util";
|
|
5
|
+
import { arrayFindIndex, coerceTruthyValueToArray, arrayFind } from "../date-table";
|
|
6
|
+
import { DATEPICKER } from "../common";
|
|
6
7
|
const datesInYear = (year) => {
|
|
7
8
|
const numOfDays = getDayCountOfYear(year);
|
|
8
9
|
const firstDay = new Date(year, 0, 1);
|
|
9
10
|
return range(numOfDays).map((n) => nextDate(firstDay, n));
|
|
10
11
|
};
|
|
11
|
-
const getCellStyle = ({ props }) => (
|
|
12
|
+
const getCellStyle = ({ props }) => (cell) => {
|
|
13
|
+
const { defaultValue } = props;
|
|
14
|
+
const year = cell.text;
|
|
12
15
|
const style = {};
|
|
13
16
|
const today = /* @__PURE__ */ new Date();
|
|
14
17
|
style.disabled = typeof props.disabledDate === "function" ? datesInYear(year).every(props.disabledDate) : false;
|
|
15
18
|
const execDate = typeof props.value === "object" ? props.value : toDate(props.value);
|
|
16
19
|
style.current = arrayFindIndex(coerceTruthyValueToArray(execDate), (date) => date.getFullYear() === year) >= 0;
|
|
17
20
|
style.today = today.getFullYear() === year;
|
|
18
|
-
style.default =
|
|
21
|
+
style.default = Array.isArray(defaultValue) ? defaultValue.some((v) => v && v.getFullYear() === year) : defaultValue && defaultValue.getFullYear() === year;
|
|
22
|
+
if (cell.inRange) {
|
|
23
|
+
style[DATEPICKER.InRange] = true;
|
|
24
|
+
}
|
|
25
|
+
if (cell.start) {
|
|
26
|
+
style[DATEPICKER.StartDate] = true;
|
|
27
|
+
}
|
|
28
|
+
if (cell.end) {
|
|
29
|
+
style[DATEPICKER.EndDate] = true;
|
|
30
|
+
}
|
|
19
31
|
return style;
|
|
20
32
|
};
|
|
21
|
-
const
|
|
33
|
+
const clearDate = (date) => {
|
|
34
|
+
return new Date(date.getFullYear(), date.getMonth());
|
|
35
|
+
};
|
|
36
|
+
const getMonthTimestamp = (time) => {
|
|
37
|
+
if (typeof time === "number" || typeof time === "string") {
|
|
38
|
+
return clearDate(new Date(time)).getTime();
|
|
39
|
+
}
|
|
40
|
+
if (time instanceof Date) {
|
|
41
|
+
return clearDate(time).getTime();
|
|
42
|
+
}
|
|
43
|
+
return NaN;
|
|
44
|
+
};
|
|
45
|
+
const getRows = ({ props, state, vm }) => () => {
|
|
46
|
+
const { tableRows } = state;
|
|
47
|
+
const { minDate, maxDate, disabledDate, startYear, selectionMode } = props;
|
|
48
|
+
const selectedDate = [];
|
|
49
|
+
const now = (/* @__PURE__ */ new Date()).getFullYear();
|
|
50
|
+
for (let i = 0; i < 3; i++) {
|
|
51
|
+
const row = tableRows[i];
|
|
52
|
+
for (let j = 0; j < 4; j++) {
|
|
53
|
+
let cell = row[j];
|
|
54
|
+
if (!cell) {
|
|
55
|
+
cell = {
|
|
56
|
+
type: DATEPICKER.Normal,
|
|
57
|
+
row: i,
|
|
58
|
+
column: j,
|
|
59
|
+
inRange: false,
|
|
60
|
+
start: false,
|
|
61
|
+
end: false
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const year = startYear + (cell.row * 4 + cell.column);
|
|
65
|
+
const isToday = year === now;
|
|
66
|
+
cell.text = year;
|
|
67
|
+
cell.type = isToday ? DATEPICKER.Today : DATEPICKER.Normal;
|
|
68
|
+
cell.disabled = typeof disabledDate === "function" && disabledDate(new Date(year, 0, 1));
|
|
69
|
+
if (selectionMode === DATEPICKER.YearRange) {
|
|
70
|
+
const minYear = typeof minDate === "object" && minDate ? minDate.getFullYear() : minDate;
|
|
71
|
+
const maxYear = typeof maxDate === "object" && maxDate ? maxDate.getFullYear() : maxDate;
|
|
72
|
+
cell.start = minYear === year;
|
|
73
|
+
cell.end = maxYear === year;
|
|
74
|
+
cell.inRange = year > minYear && year < maxYear || [minYear, maxYear].includes(year);
|
|
75
|
+
cell.selected = arrayFind(
|
|
76
|
+
selectedDate,
|
|
77
|
+
(item) => (typeof item === "object" ? item.getFullYear() : item) === year
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
vm.$set(row, j, cell);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return tableRows;
|
|
84
|
+
};
|
|
85
|
+
const markRange = ({ props, state }) => (min, max) => {
|
|
86
|
+
const rows = state.rows;
|
|
87
|
+
const [minDate, maxDate] = [min, max].sort((a, b) => a && a < b ? -1 : 1);
|
|
88
|
+
const minYear = typeof minDate === "object" && minDate ? minDate.getFullYear() : minDate;
|
|
89
|
+
const maxYear = typeof maxDate === "object" && maxDate ? maxDate.getFullYear() : maxDate;
|
|
90
|
+
if (props.selectionMode === DATEPICKER.YearRange) {
|
|
91
|
+
for (let i = 0, len = rows.length; i < len; i++) {
|
|
92
|
+
const row = rows[i];
|
|
93
|
+
for (let j = 0, l = row.length; j < l; j++) {
|
|
94
|
+
const cell = row[j];
|
|
95
|
+
const year = cell.text;
|
|
96
|
+
cell.start = minYear && minYear === year;
|
|
97
|
+
cell.end = maxYear && maxYear === year;
|
|
98
|
+
cell.inRange = year > minYear && year < maxYear || cell.start || cell.end;
|
|
99
|
+
cell.selected = cell.inRange;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const watchDate = ({ api, props }) => (value, oldvalue) => {
|
|
105
|
+
if (value !== oldvalue) {
|
|
106
|
+
api.markRange(props.minDate, props.maxDate);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const handleYearTableClick = ({ emit, props }) => (event) => {
|
|
22
110
|
const target = event.target;
|
|
111
|
+
const { selectionMode } = props;
|
|
23
112
|
if (target.tagName === "A") {
|
|
24
|
-
if (hasClass(target.parentNode, "disabled")) {
|
|
113
|
+
if (hasClass(target.parentNode.parentNode, "disabled")) {
|
|
25
114
|
return;
|
|
26
115
|
}
|
|
27
|
-
const year = target.textContent || target.innerText;
|
|
28
|
-
|
|
116
|
+
const year = Number(target.textContent || target.innerText);
|
|
117
|
+
if (selectionMode === DATEPICKER.Years) {
|
|
118
|
+
const years = Array.isArray(props.value) ? props.value.map((v) => v.getFullYear()) : [];
|
|
119
|
+
const index = years.indexOf(year);
|
|
120
|
+
if (index === -1) {
|
|
121
|
+
years.push(year);
|
|
122
|
+
} else {
|
|
123
|
+
years.splice(index, 1);
|
|
124
|
+
}
|
|
125
|
+
emit("pick", years.slice());
|
|
126
|
+
} else if (selectionMode === DATEPICKER.YearRange) {
|
|
127
|
+
let { minDate, maxDate } = props;
|
|
128
|
+
if (props.rangeState.selecting) {
|
|
129
|
+
props.rangeState.selecting = false;
|
|
130
|
+
if (year < minDate) {
|
|
131
|
+
maxDate = minDate;
|
|
132
|
+
minDate = year;
|
|
133
|
+
} else {
|
|
134
|
+
maxDate = year;
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
props.rangeState.selecting = true;
|
|
138
|
+
minDate = year;
|
|
139
|
+
maxDate = null;
|
|
140
|
+
}
|
|
141
|
+
emit("pick", { minDate, maxDate });
|
|
142
|
+
} else {
|
|
143
|
+
emit("pick", year);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const getTarget = (evt) => {
|
|
148
|
+
let target = evt.target;
|
|
149
|
+
const tagName = target.tagName;
|
|
150
|
+
if (tagName === "A") {
|
|
151
|
+
target = target.parentNode.parentNode;
|
|
152
|
+
}
|
|
153
|
+
if (tagName === "DIV") {
|
|
154
|
+
target = target.parentNode;
|
|
155
|
+
}
|
|
156
|
+
if (tagName !== "TD") {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
return target;
|
|
160
|
+
};
|
|
161
|
+
const handleMouseMove = ({ emit, props, state }) => (event) => {
|
|
162
|
+
const { selectionMode, startYear, rangeState, minDate, maxDate } = props;
|
|
163
|
+
if (selectionMode !== DATEPICKER.YearRange || !rangeState.selecting) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const target = getTarget(event);
|
|
167
|
+
if (!target) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const row = target.parentNode.rowIndex;
|
|
171
|
+
const column = target.cellIndex;
|
|
172
|
+
if (state.rows[row][column].disabled || minDate === maxDate) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (row !== state.lastRow || column !== state.lastColumn) {
|
|
176
|
+
state.lastColumn = column;
|
|
177
|
+
state.lastRow = row;
|
|
178
|
+
const year = startYear + row * 4 + column;
|
|
179
|
+
emit("changerange", {
|
|
180
|
+
minDate,
|
|
181
|
+
maxDate,
|
|
182
|
+
rangeState: {
|
|
183
|
+
selecting: true,
|
|
184
|
+
endDate: year
|
|
185
|
+
}
|
|
186
|
+
});
|
|
29
187
|
}
|
|
30
188
|
};
|
|
31
189
|
export {
|
|
190
|
+
clearDate,
|
|
32
191
|
getCellStyle,
|
|
33
|
-
|
|
192
|
+
getMonthTimestamp,
|
|
193
|
+
getRows,
|
|
194
|
+
handleMouseMove,
|
|
195
|
+
handleYearTableClick,
|
|
196
|
+
markRange,
|
|
197
|
+
watchDate
|
|
34
198
|
};
|
package/year-table/vue.js
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import "../chunk-PKUHTIDK.js";
|
|
2
|
-
import { getCellStyle, handleYearTableClick } from "./index";
|
|
3
|
-
const api = ["state", "handleYearTableClick", "getCellStyle"];
|
|
4
|
-
const renderless = (props, { computed, reactive }, { emit }) => {
|
|
2
|
+
import { getRows, getCellStyle, handleYearTableClick, watchDate, markRange, handleMouseMove } from "./index";
|
|
3
|
+
const api = ["state", "handleYearTableClick", "getCellStyle", "handleMouseMove"];
|
|
4
|
+
const renderless = (props, { computed, reactive, watch }, { emit, vm }) => {
|
|
5
5
|
const api2 = {};
|
|
6
6
|
const state = reactive({
|
|
7
|
-
|
|
7
|
+
tableRows: [[], [], []],
|
|
8
|
+
rows: computed(() => api2.getRows())
|
|
8
9
|
});
|
|
9
10
|
Object.assign(api2, {
|
|
10
11
|
state,
|
|
11
12
|
getCellStyle: getCellStyle({ props }),
|
|
12
|
-
handleYearTableClick: handleYearTableClick({ emit })
|
|
13
|
+
handleYearTableClick: handleYearTableClick({ emit, props, state }),
|
|
14
|
+
markRange: markRange({ props, state }),
|
|
15
|
+
watchDate: watchDate({ api: api2, props }),
|
|
16
|
+
getRows: getRows({ props, state, vm }),
|
|
17
|
+
handleMouseMove: handleMouseMove({ api: api2, emit, props, state })
|
|
13
18
|
});
|
|
19
|
+
watch(
|
|
20
|
+
() => props.rangeState,
|
|
21
|
+
(value, oldValue) => value !== oldValue && api2.markRange(props.minDate, value.endDate),
|
|
22
|
+
{ deep: true }
|
|
23
|
+
);
|
|
24
|
+
watch(() => props.minDate, api2.watchDate);
|
|
25
|
+
watch(() => props.maxDate, api2.watchDate);
|
|
14
26
|
return api2;
|
|
15
27
|
};
|
|
16
28
|
export {
|