@opentiny/vue-renderless 3.6.8 → 3.8.2
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/button-group/vue.js +5 -4
- 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 +6 -6
- 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 +6 -4
- 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 +4 -3
- package/dropdown-item/index.js +5 -1
- package/dropdown-item/mf.js +79 -0
- package/dropdown-item/vue.js +9 -6
- 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/vue.js +10 -0
- 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 +21 -14
- package/select/vue.js +38 -15
- 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 +3 -3
- package/tab-item/vue.js +4 -3
- 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 +34 -13
- 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 -1
- 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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
const hide = ({ state, emit }) => () => {
|
|
3
|
+
state.search.show = false;
|
|
4
|
+
emit("update:visible", false);
|
|
5
|
+
emit("close", false);
|
|
6
|
+
};
|
|
7
|
+
const watchVisible = ({ emit, state, props, api }) => (bool) => {
|
|
8
|
+
const { multiple, modelValue } = props;
|
|
9
|
+
if (bool && multiple) {
|
|
10
|
+
api.watchModelValue(modelValue);
|
|
11
|
+
}
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
state.toggle = bool;
|
|
14
|
+
}, 0);
|
|
15
|
+
emit("update:visible", bool);
|
|
16
|
+
};
|
|
17
|
+
const watchModelValue = ({ props, state, emit }) => (value) => {
|
|
18
|
+
const { multiple, menus, valueField, textField, textSplit } = props;
|
|
19
|
+
if (multiple) {
|
|
20
|
+
const ids = menus.map((option) => option[valueField]);
|
|
21
|
+
state.checkList = (value || []).map((id) => {
|
|
22
|
+
return ids.indexOf(id) > -1 ? menus[ids.indexOf(id)] : { [valueField]: id, [textField]: id };
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const text = multiple ? state.checkList.map((item) => item[textField]) : menus.filter((item) => item[valueField] === value).map((item) => item[textField]);
|
|
26
|
+
emit("update:text", text.join(textSplit));
|
|
27
|
+
};
|
|
28
|
+
const includeOptionIndex = (props) => (list, option) => {
|
|
29
|
+
const { valueField } = props;
|
|
30
|
+
let index = -1;
|
|
31
|
+
list.some((item, i) => {
|
|
32
|
+
const isEqual = item[valueField] === option[valueField];
|
|
33
|
+
isEqual && (index = i);
|
|
34
|
+
return isEqual;
|
|
35
|
+
});
|
|
36
|
+
return index;
|
|
37
|
+
};
|
|
38
|
+
const selectOption = ({ emit, state, props, api }) => (option) => {
|
|
39
|
+
const { valueField, multiple } = props;
|
|
40
|
+
if (multiple) {
|
|
41
|
+
const index = api.includeOptionIndex(state.checkList, option);
|
|
42
|
+
index > -1 ? state.checkList.splice(index, 1) : state.checkList.push(option);
|
|
43
|
+
} else {
|
|
44
|
+
emit("update:visible", false);
|
|
45
|
+
emit("update:modelValue", option[valueField]);
|
|
46
|
+
}
|
|
47
|
+
emit("click", option);
|
|
48
|
+
};
|
|
49
|
+
const confirm = ({ emit, state, props, api }) => () => {
|
|
50
|
+
if (state.search.show) {
|
|
51
|
+
api.searchBoxToggle(false);
|
|
52
|
+
} else {
|
|
53
|
+
emit("confirm", state);
|
|
54
|
+
emit("update:visible", false);
|
|
55
|
+
props.multiple && emit("update:modelValue", state.checkIds);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const searchMethod = ({ state, props }) => () => {
|
|
59
|
+
const { searchConfig, textField } = props;
|
|
60
|
+
const { input, options } = state.search;
|
|
61
|
+
let list;
|
|
62
|
+
if (searchConfig && searchConfig.searchMethod) {
|
|
63
|
+
list = searchConfig.searchMethod({ input, options }) || [];
|
|
64
|
+
} else {
|
|
65
|
+
list = options.filter((item) => item[textField].indexOf(input) > -1);
|
|
66
|
+
}
|
|
67
|
+
if (list.then === "function") {
|
|
68
|
+
list.then((data) => state.search.filterOptions = data);
|
|
69
|
+
} else {
|
|
70
|
+
state.search.filterOptions = list;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const searchBoxToggle = ({ state, props, api }) => (bool) => {
|
|
74
|
+
const { menus, searchConfig } = props;
|
|
75
|
+
state.search.show = bool;
|
|
76
|
+
state.search.input = "";
|
|
77
|
+
if (bool) {
|
|
78
|
+
state.search.options = !searchConfig.options || !searchConfig.options.length ? menus : searchConfig.options;
|
|
79
|
+
api.searchMethod();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const allCheckHandler = ({ state, props }) => () => {
|
|
83
|
+
if (state.checkList.length === props.menus.length) {
|
|
84
|
+
state.checkList = [];
|
|
85
|
+
} else {
|
|
86
|
+
state.checkList = props.menus.slice();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const searchSelectHandler = ({ state, emit, api, props }) => (option) => {
|
|
90
|
+
const { valueField, multiple } = props;
|
|
91
|
+
if (multiple) {
|
|
92
|
+
const index = api.includeOptionIndex(state.checkList, option);
|
|
93
|
+
index > -1 ? state.checkList.splice(index, 1) : state.checkList.push(option);
|
|
94
|
+
} else {
|
|
95
|
+
api.searchBoxToggle(false);
|
|
96
|
+
emit("update:modelValue", option[valueField]);
|
|
97
|
+
}
|
|
98
|
+
emit("search-click", option);
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
allCheckHandler,
|
|
102
|
+
confirm,
|
|
103
|
+
hide,
|
|
104
|
+
includeOptionIndex,
|
|
105
|
+
searchBoxToggle,
|
|
106
|
+
searchMethod,
|
|
107
|
+
searchSelectHandler,
|
|
108
|
+
selectOption,
|
|
109
|
+
watchModelValue,
|
|
110
|
+
watchVisible
|
|
111
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
import {
|
|
3
|
+
hide,
|
|
4
|
+
watchVisible,
|
|
5
|
+
selectOption,
|
|
6
|
+
confirm,
|
|
7
|
+
searchMethod,
|
|
8
|
+
searchSelectHandler,
|
|
9
|
+
searchBoxToggle,
|
|
10
|
+
watchModelValue,
|
|
11
|
+
includeOptionIndex,
|
|
12
|
+
allCheckHandler
|
|
13
|
+
} from "./index";
|
|
14
|
+
const api = [
|
|
15
|
+
"state",
|
|
16
|
+
"hide",
|
|
17
|
+
"selectOption",
|
|
18
|
+
"confirm",
|
|
19
|
+
"searchMethod",
|
|
20
|
+
"searchSelectHandler",
|
|
21
|
+
"searchBoxToggle",
|
|
22
|
+
"includeOptionIndex",
|
|
23
|
+
"allCheckHandler"
|
|
24
|
+
];
|
|
25
|
+
const renderless = (props, { computed, reactive, watch }, { emit }) => {
|
|
26
|
+
const api2 = {};
|
|
27
|
+
const state = reactive({
|
|
28
|
+
toggle: false,
|
|
29
|
+
checkList: [],
|
|
30
|
+
search: {
|
|
31
|
+
show: false,
|
|
32
|
+
input: "",
|
|
33
|
+
options: [],
|
|
34
|
+
filterOptions: []
|
|
35
|
+
},
|
|
36
|
+
checkIds: computed(() => state.checkList.map((option) => option[props.valueField]))
|
|
37
|
+
});
|
|
38
|
+
Object.assign(api2, {
|
|
39
|
+
state,
|
|
40
|
+
confirm: confirm({ state, emit, props, api: api2 }),
|
|
41
|
+
selectOption: selectOption({ state, emit, props, api: api2 }),
|
|
42
|
+
hide: hide({ state, emit }),
|
|
43
|
+
watchVisible: watchVisible({ emit, state, props, api: api2 }),
|
|
44
|
+
watchModelValue: watchModelValue({ props, state, emit }),
|
|
45
|
+
searchMethod: searchMethod({ state, props, api: api2 }),
|
|
46
|
+
searchSelectHandler: searchSelectHandler({ state, emit, api: api2, props }),
|
|
47
|
+
searchBoxToggle: searchBoxToggle({ state, props, api: api2 }),
|
|
48
|
+
allCheckHandler: allCheckHandler({ state, props }),
|
|
49
|
+
includeOptionIndex: includeOptionIndex(props)
|
|
50
|
+
});
|
|
51
|
+
watch(() => props.visible, api2.watchVisible);
|
|
52
|
+
watch(() => props.modelValue, api2.watchModelValue, { immediate: true });
|
|
53
|
+
return api2;
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
api,
|
|
57
|
+
renderless
|
|
58
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
const close = ({ state, emit, vm }) => () => {
|
|
3
|
+
state.search.input = "";
|
|
4
|
+
vm.$refs.actionSheet.close();
|
|
5
|
+
emit("close", false);
|
|
6
|
+
};
|
|
7
|
+
const watchVisible = ({ emit, state, props, api }) => (bool) => {
|
|
8
|
+
const { multiple, modelValue, menus } = props;
|
|
9
|
+
if (bool) {
|
|
10
|
+
if (!state.lazy) {
|
|
11
|
+
state.search.options = menus;
|
|
12
|
+
}
|
|
13
|
+
api.searchMethod();
|
|
14
|
+
multiple && api.watchModelValue(modelValue);
|
|
15
|
+
}
|
|
16
|
+
emit("update:visible", bool);
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
state.toggle = bool;
|
|
19
|
+
}, 0);
|
|
20
|
+
};
|
|
21
|
+
const watchModelValue = ({ props, state, emit }) => (value) => {
|
|
22
|
+
const { multiple, menus, valueField, textField, textSplit } = props;
|
|
23
|
+
if (multiple) {
|
|
24
|
+
const ids = menus.map((option) => option[valueField]);
|
|
25
|
+
state.checkList = (value || []).map((id) => {
|
|
26
|
+
return ids.indexOf(id) > -1 ? menus[ids.indexOf(id)] : { [valueField]: id, [textField]: id };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const textStr = multiple ? state.checkList.map((data) => data[textField]) : menus.filter((data) => data[valueField] === value).map((data) => data[textField]);
|
|
30
|
+
emit("update:text", textStr.join(textSplit));
|
|
31
|
+
};
|
|
32
|
+
const includeOptionIndex = (props) => (list, option) => {
|
|
33
|
+
const { valueField } = props;
|
|
34
|
+
let OptionIndex = -1;
|
|
35
|
+
list.some((data, i) => {
|
|
36
|
+
const isEqual = data[valueField] === option[valueField];
|
|
37
|
+
isEqual && (OptionIndex = i);
|
|
38
|
+
return isEqual;
|
|
39
|
+
});
|
|
40
|
+
return OptionIndex;
|
|
41
|
+
};
|
|
42
|
+
const selectOption = ({ emit, state, props, api }) => (data) => {
|
|
43
|
+
const { valueField, multiple } = props;
|
|
44
|
+
if (multiple) {
|
|
45
|
+
const index = api.includeOptionIndex(state.checkList, data);
|
|
46
|
+
index > -1 ? state.checkList.splice(index, 1) : state.checkList.push(data);
|
|
47
|
+
} else {
|
|
48
|
+
emit("update:visible", false);
|
|
49
|
+
emit("update:modelValue", data[valueField]);
|
|
50
|
+
}
|
|
51
|
+
emit("click", data);
|
|
52
|
+
};
|
|
53
|
+
const confirm = ({ state, props, api, emit }) => () => {
|
|
54
|
+
const { search, checkIds } = state;
|
|
55
|
+
if (!search.show) {
|
|
56
|
+
emit("confirm", state);
|
|
57
|
+
emit("update:visible", false);
|
|
58
|
+
props.multiple && emit("update:modelValue", checkIds);
|
|
59
|
+
} else {
|
|
60
|
+
api.searchBoxToggle(false);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const searchMethod = ({ state, props }) => () => {
|
|
64
|
+
const { input, options } = state.search;
|
|
65
|
+
const { searchConfig, textField, valueField, topConfig } = props;
|
|
66
|
+
const topOptionIds = (topConfig.options || []).map((item) => item[valueField]);
|
|
67
|
+
let list;
|
|
68
|
+
if (searchConfig && searchConfig.searchMethod) {
|
|
69
|
+
list = searchConfig.searchMethod({ input, options }) || [];
|
|
70
|
+
} else {
|
|
71
|
+
list = options.filter(
|
|
72
|
+
(item) => item[textField].indexOf(input) > -1 && topOptionIds.indexOf(item[valueField]) === -1
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (typeof list.then === "function") {
|
|
76
|
+
list.then((data) => state.search.filterOptions = data);
|
|
77
|
+
} else {
|
|
78
|
+
state.search.filterOptions = list;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const searchBoxToggle = ({ state, props, api }) => (bool) => {
|
|
82
|
+
const { menus } = props;
|
|
83
|
+
state.search.input = "";
|
|
84
|
+
if (bool) {
|
|
85
|
+
if (!state.lazy) {
|
|
86
|
+
state.search.options = menus;
|
|
87
|
+
}
|
|
88
|
+
api.searchMethod();
|
|
89
|
+
} else {
|
|
90
|
+
api.close();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const allCheckHandler = ({ state, props }) => () => {
|
|
94
|
+
state.checkList = state.checkList.length === props.menus.length ? [] : props.menus.slice();
|
|
95
|
+
};
|
|
96
|
+
const searchSelectHandler = ({ state, emit, api, props }) => (option) => {
|
|
97
|
+
const { valueField, multiple, requiredSelectedList } = props;
|
|
98
|
+
if (multiple) {
|
|
99
|
+
const index = api.includeOptionIndex(state.checkList, option);
|
|
100
|
+
if (index > -1 && requiredSelectedList.indexOf(option[valueField]) !== -1) {
|
|
101
|
+
emit("search-click", option, false);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
index > -1 ? state.checkList.splice(index, 1) : state.checkList.push(option);
|
|
105
|
+
} else {
|
|
106
|
+
api.searchBoxToggle(false);
|
|
107
|
+
emit("update:modelValue", option[valueField]);
|
|
108
|
+
}
|
|
109
|
+
emit("search-click", option, true);
|
|
110
|
+
};
|
|
111
|
+
const toggleCheckList = ({ state }) => (value) => {
|
|
112
|
+
if (!state.checkList.length) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
state.selected.show = value;
|
|
116
|
+
if (value) {
|
|
117
|
+
state.selected.options = state.checkList.slice();
|
|
118
|
+
} else {
|
|
119
|
+
state.checkList = state.selected.options.slice();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const clean = ({ state, props }) => () => {
|
|
123
|
+
const { valueField, requiredSelectedList } = props;
|
|
124
|
+
state.selected.options = state.selected.options.filter(
|
|
125
|
+
(item) => requiredSelectedList.indexOf(item[valueField]) !== -1
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
const selectedOptionHandler = ({ state, api }) => (option) => {
|
|
129
|
+
const index = api.includeOptionIndex(state.selected.options, option);
|
|
130
|
+
if (index > -1) {
|
|
131
|
+
state.selected.options.splice(index, 1);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const load = ({ state, props, api }) => () => {
|
|
135
|
+
const { infiniteScroll } = props;
|
|
136
|
+
const { search } = state;
|
|
137
|
+
if (!infiniteScroll.load || state.search.loading) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const list = infiniteScroll.load({ input: search.input, options: search.options });
|
|
141
|
+
if (!list) {
|
|
142
|
+
return;
|
|
143
|
+
} else if (typeof list.then === "function") {
|
|
144
|
+
state.search.loading = true;
|
|
145
|
+
list.then((data) => {
|
|
146
|
+
state.search.loading = false;
|
|
147
|
+
state.search.options = search.options.concat(data);
|
|
148
|
+
api.searchMethod();
|
|
149
|
+
});
|
|
150
|
+
} else {
|
|
151
|
+
state.search.options = search.options.concat(list);
|
|
152
|
+
api.searchMethod();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
export {
|
|
156
|
+
allCheckHandler,
|
|
157
|
+
clean,
|
|
158
|
+
close,
|
|
159
|
+
confirm,
|
|
160
|
+
includeOptionIndex,
|
|
161
|
+
load,
|
|
162
|
+
searchBoxToggle,
|
|
163
|
+
searchMethod,
|
|
164
|
+
searchSelectHandler,
|
|
165
|
+
selectOption,
|
|
166
|
+
selectedOptionHandler,
|
|
167
|
+
toggleCheckList,
|
|
168
|
+
watchModelValue,
|
|
169
|
+
watchVisible
|
|
170
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
import {
|
|
3
|
+
close,
|
|
4
|
+
watchVisible,
|
|
5
|
+
selectOption,
|
|
6
|
+
confirm,
|
|
7
|
+
searchMethod,
|
|
8
|
+
searchSelectHandler,
|
|
9
|
+
searchBoxToggle,
|
|
10
|
+
watchModelValue,
|
|
11
|
+
includeOptionIndex,
|
|
12
|
+
allCheckHandler,
|
|
13
|
+
toggleCheckList,
|
|
14
|
+
clean,
|
|
15
|
+
load,
|
|
16
|
+
selectedOptionHandler
|
|
17
|
+
} from "./index";
|
|
18
|
+
const api = [
|
|
19
|
+
"state",
|
|
20
|
+
"allCheckHandler",
|
|
21
|
+
"close",
|
|
22
|
+
"selectOption",
|
|
23
|
+
"confirm",
|
|
24
|
+
"searchMethod",
|
|
25
|
+
"searchSelectHandler",
|
|
26
|
+
"searchBoxToggle",
|
|
27
|
+
"includeOptionIndex",
|
|
28
|
+
"clean",
|
|
29
|
+
"load",
|
|
30
|
+
"selectedOptionHandler",
|
|
31
|
+
"toggleCheckList"
|
|
32
|
+
];
|
|
33
|
+
const renderless = (props, { computed, reactive, watch }, { emit, vm }) => {
|
|
34
|
+
const api2 = {};
|
|
35
|
+
const state = reactive({
|
|
36
|
+
toggle: false,
|
|
37
|
+
checkList: [],
|
|
38
|
+
selected: {
|
|
39
|
+
show: false,
|
|
40
|
+
options: []
|
|
41
|
+
},
|
|
42
|
+
search: {
|
|
43
|
+
filterOptions: [],
|
|
44
|
+
input: "",
|
|
45
|
+
options: props.menus || [],
|
|
46
|
+
loading: false
|
|
47
|
+
},
|
|
48
|
+
checkIds: computed(() => state.checkList.map((option) => option[props.valueField])),
|
|
49
|
+
lazy: computed(() => !props.infiniteScroll.disabled && typeof props.infiniteScroll.load === "function")
|
|
50
|
+
});
|
|
51
|
+
Object.assign(api2, {
|
|
52
|
+
state,
|
|
53
|
+
confirm: confirm({ state, emit, props, api: api2 }),
|
|
54
|
+
selectOption: selectOption({ state, emit, props, api: api2 }),
|
|
55
|
+
close: close({ state, emit, vm }),
|
|
56
|
+
watchVisible: watchVisible({ emit, state, props, api: api2 }),
|
|
57
|
+
watchModelValue: watchModelValue({ props, state, emit }),
|
|
58
|
+
searchMethod: searchMethod({ state, props, api: api2 }),
|
|
59
|
+
searchSelectHandler: searchSelectHandler({ state, emit, api: api2, props }),
|
|
60
|
+
searchBoxToggle: searchBoxToggle({ state, props, api: api2 }),
|
|
61
|
+
allCheckHandler: allCheckHandler({ state, props }),
|
|
62
|
+
toggleCheckList: toggleCheckList({ state }),
|
|
63
|
+
clean: clean({ state, props }),
|
|
64
|
+
load: load({ state, props, api: api2 }),
|
|
65
|
+
selectedOptionHandler: selectedOptionHandler({ state, api: api2 }),
|
|
66
|
+
includeOptionIndex: includeOptionIndex(props)
|
|
67
|
+
});
|
|
68
|
+
watch(() => props.visible, api2.watchVisible, { immediate: true });
|
|
69
|
+
watch(() => props.modelValue, api2.watchModelValue, { immediate: true });
|
|
70
|
+
watch(
|
|
71
|
+
() => props.menus,
|
|
72
|
+
(value) => {
|
|
73
|
+
state.search.options = value;
|
|
74
|
+
api2.searchMethod();
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
return api2;
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
api,
|
|
81
|
+
renderless
|
|
82
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import "../chunk-PKUHTIDK.js";
|
|
2
|
+
import { omitText } from "../common/string";
|
|
3
|
+
const normal = (n) => n < 0 ? 0 : n;
|
|
4
|
+
const init = ({ props, state }) => () => {
|
|
5
|
+
const { inverse, total, select } = props;
|
|
6
|
+
state.inverse = !!inverse;
|
|
7
|
+
state.total = state.inverse ? normal(total - select.length) : select.length;
|
|
8
|
+
state.select = select.slice(0);
|
|
9
|
+
};
|
|
10
|
+
const submitSelection = ({ api, state }) => (option, oper = "add") => {
|
|
11
|
+
const { inverse, total, select } = state;
|
|
12
|
+
if (oper === "add") {
|
|
13
|
+
const index = select.findIndex((opt) => api.keyOption(opt) === api.keyOption(option));
|
|
14
|
+
if (index === -1) {
|
|
15
|
+
state.select = [...select, option];
|
|
16
|
+
state.total = total + (inverse ? -1 : 1);
|
|
17
|
+
api.emitChange();
|
|
18
|
+
}
|
|
19
|
+
} else if (oper === "remove") {
|
|
20
|
+
const index = select.findIndex((opt) => api.keyOption(opt) === api.keyOption(option));
|
|
21
|
+
if (index > -1) {
|
|
22
|
+
state.select = [...select.slice(0, index), ...select.slice(index + 1)];
|
|
23
|
+
state.total = total + (inverse ? 1 : -1);
|
|
24
|
+
api.emitChange();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const validArray = (arr) => Array.isArray(arr) && arr.length;
|
|
29
|
+
const arrayMinus = (api) => (arr1, arr2) => {
|
|
30
|
+
let res = [];
|
|
31
|
+
if (validArray(arr1) && validArray(arr2)) {
|
|
32
|
+
arr1.forEach((item1) => {
|
|
33
|
+
if (arr2.findIndex((item2) => api.keyOption(item1) === api.keyOption(item2)) === -1) {
|
|
34
|
+
res.push(item1);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
} else if (validArray(arr1) && !validArray(arr2)) {
|
|
38
|
+
res = [...arr1];
|
|
39
|
+
}
|
|
40
|
+
return res;
|
|
41
|
+
};
|
|
42
|
+
const batchSubmit = ({ api, state }) => (options, oper = "add") => {
|
|
43
|
+
const { inverse, total, select } = state;
|
|
44
|
+
if (oper === "add") {
|
|
45
|
+
const toPlus = api.arrayMinus(options, select);
|
|
46
|
+
if (validArray(toPlus)) {
|
|
47
|
+
state.select = [...select, ...toPlus];
|
|
48
|
+
state.total = total + (inverse ? -1 : 1) * toPlus.length;
|
|
49
|
+
api.emitChange();
|
|
50
|
+
}
|
|
51
|
+
} else if (oper === "remove") {
|
|
52
|
+
const toMinus = api.arrayMinus(select, api.arrayMinus(select, options));
|
|
53
|
+
if (validArray(toMinus)) {
|
|
54
|
+
let tmpSelect = select;
|
|
55
|
+
toMinus.map((opt1) => select.findIndex((opt2) => api.keyOption(opt1) === api.keyOption(opt2))).sort((a, b) => a - b).reverse().forEach((i) => tmpSelect = [...tmpSelect.slice(0, i), ...tmpSelect.slice(i + 1)]);
|
|
56
|
+
state.select = [...tmpSelect];
|
|
57
|
+
state.total = total + (inverse ? 1 : -1) * toMinus.length;
|
|
58
|
+
api.emitChange();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const coverSubmit = ({ api, props, state }) => (options) => {
|
|
63
|
+
const { total } = props;
|
|
64
|
+
const { inverse, select } = state;
|
|
65
|
+
if (Array.isArray(options)) {
|
|
66
|
+
const t0 = api.arrayMinus(select, api.arrayMinus(select, options));
|
|
67
|
+
const t1 = api.arrayMinus(options, select);
|
|
68
|
+
state.select = [...t0, ...t1];
|
|
69
|
+
state.total = inverse ? normal(total - options.length) : options.length;
|
|
70
|
+
api.emitChange();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const getSelection = ({ api, state }) => () => {
|
|
74
|
+
const { inverse, select } = state;
|
|
75
|
+
return { flag: !inverse, selection: select, state: api.getParams() };
|
|
76
|
+
};
|
|
77
|
+
const i18nSelected = ({ state, t }) => () => {
|
|
78
|
+
const { inverse, total } = state;
|
|
79
|
+
const template = inverse ? t("ui.selectedBox.allSelect") : t("ui.selectedBox.select");
|
|
80
|
+
return template.replace("%s", total);
|
|
81
|
+
};
|
|
82
|
+
const computedShowAuxi = (props) => () => {
|
|
83
|
+
const { config } = props;
|
|
84
|
+
const { showField } = config || {};
|
|
85
|
+
return Array.isArray(showField) && showField.length > 1;
|
|
86
|
+
};
|
|
87
|
+
const textPrimary = (props) => (option) => {
|
|
88
|
+
const { config } = props;
|
|
89
|
+
const { showField } = config || {};
|
|
90
|
+
let primaryText = "";
|
|
91
|
+
if (typeof showField === "string") {
|
|
92
|
+
primaryText = option[showField];
|
|
93
|
+
} else if (Array.isArray(showField) && typeof showField[0] === "string") {
|
|
94
|
+
primaryText = option[showField[0]];
|
|
95
|
+
}
|
|
96
|
+
return primaryText;
|
|
97
|
+
};
|
|
98
|
+
const textAuxi = (props) => (option) => {
|
|
99
|
+
const { config } = props;
|
|
100
|
+
const { showField } = config || {};
|
|
101
|
+
let auxiText = "";
|
|
102
|
+
if (Array.isArray(showField) && typeof showField[1] === "string") {
|
|
103
|
+
auxiText = option[showField[1]];
|
|
104
|
+
}
|
|
105
|
+
return auxiText;
|
|
106
|
+
};
|
|
107
|
+
const handleMouseenter = ({ state, vm }) => (e) => {
|
|
108
|
+
const dom = e.target;
|
|
109
|
+
const text = dom.textContent;
|
|
110
|
+
const font = window.getComputedStyle(dom).font;
|
|
111
|
+
const rect = dom.getBoundingClientRect();
|
|
112
|
+
const res = omitText(text, font, rect.width);
|
|
113
|
+
const popover = vm.$refs.popover;
|
|
114
|
+
if (res.o) {
|
|
115
|
+
popover.state.referenceElm = dom;
|
|
116
|
+
popover.state.popperElm && (popover.state.popperElm.style.display = "none");
|
|
117
|
+
popover.doDestroy();
|
|
118
|
+
state.popoverContent = text;
|
|
119
|
+
state.popoverVisible = true;
|
|
120
|
+
setTimeout(popover.updatePopper, 20);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const handleMouseleave = (state) => () => {
|
|
124
|
+
state.popoverContent = "";
|
|
125
|
+
state.popoverVisible = false;
|
|
126
|
+
};
|
|
127
|
+
const handleClear = ({ api, emit, props, state }) => () => {
|
|
128
|
+
const { total } = props;
|
|
129
|
+
const { inverse, select } = state;
|
|
130
|
+
if (Array.isArray(select) && select.length) {
|
|
131
|
+
state.select = [];
|
|
132
|
+
state.total = inverse ? normal(total) : 0;
|
|
133
|
+
api.emitChange();
|
|
134
|
+
emit("clear", { state: api.getParams() });
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const handleDelete = ({ api, emit, state }) => (option) => {
|
|
138
|
+
const { inverse, total, select } = state;
|
|
139
|
+
const index = select.findIndex((opt) => api.keyOption(opt) === api.keyOption(option));
|
|
140
|
+
if (index > -1) {
|
|
141
|
+
state.select = [...select.slice(0, index), ...select.slice(index + 1)];
|
|
142
|
+
state.total = total + (inverse ? 1 : -1);
|
|
143
|
+
api.emitChange();
|
|
144
|
+
emit("delete", { option, state: api.getParams() });
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const getParams = (state) => () => {
|
|
148
|
+
const { inverse, total, select } = state;
|
|
149
|
+
return { inverse, total, select };
|
|
150
|
+
};
|
|
151
|
+
const emitChange = ({ api, emit }) => () => emit("change", api.getSelection());
|
|
152
|
+
const keyOption = ({ api, props }) => (option) => {
|
|
153
|
+
const { config } = props;
|
|
154
|
+
const { pkField = "id" } = config || {};
|
|
155
|
+
return api.keyType(option[pkField]);
|
|
156
|
+
};
|
|
157
|
+
const keyType = (props) => (keyValue) => {
|
|
158
|
+
const { config } = props;
|
|
159
|
+
const { pkFieldType = "number" } = config || {};
|
|
160
|
+
const typeFn = pkFieldType === "number" ? Number : String;
|
|
161
|
+
return typeFn(keyValue);
|
|
162
|
+
};
|
|
163
|
+
const initDrag = ({ api, emit, markRaw, props, state, vm }) => () => {
|
|
164
|
+
const { config } = props;
|
|
165
|
+
const { plugin } = config || {};
|
|
166
|
+
const { optionSelector, dragAnimation } = state;
|
|
167
|
+
const handleUpdate = (e) => {
|
|
168
|
+
const { from, to, oldIndex, newIndex } = e;
|
|
169
|
+
const { select } = state;
|
|
170
|
+
if (from === to && oldIndex !== newIndex) {
|
|
171
|
+
const optDoms = Array.from(vm.$el.querySelectorAll(optionSelector));
|
|
172
|
+
const slct = optDoms.map((optDom) => select.find((opt) => api.keyOption(opt) === api.keyType(optDom.dataset.key)));
|
|
173
|
+
state.select = slct;
|
|
174
|
+
state.refresh += 1;
|
|
175
|
+
api.emitChange();
|
|
176
|
+
emit("drag", { state: api.getParams() });
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
if (!plugin)
|
|
180
|
+
return;
|
|
181
|
+
const dragInstance = plugin.create(vm.$refs.list, {
|
|
182
|
+
animation: dragAnimation,
|
|
183
|
+
draggable: optionSelector,
|
|
184
|
+
onUpdate: handleUpdate
|
|
185
|
+
});
|
|
186
|
+
state.dragInstance = markRaw(dragInstance);
|
|
187
|
+
};
|
|
188
|
+
const unmount = (state) => () => {
|
|
189
|
+
const { dragInstance } = state;
|
|
190
|
+
if (dragInstance && typeof dragInstance.destroy === "function") {
|
|
191
|
+
dragInstance.destroy();
|
|
192
|
+
state.dragInstance = null;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
export {
|
|
196
|
+
arrayMinus,
|
|
197
|
+
batchSubmit,
|
|
198
|
+
computedShowAuxi,
|
|
199
|
+
coverSubmit,
|
|
200
|
+
emitChange,
|
|
201
|
+
getParams,
|
|
202
|
+
getSelection,
|
|
203
|
+
handleClear,
|
|
204
|
+
handleDelete,
|
|
205
|
+
handleMouseenter,
|
|
206
|
+
handleMouseleave,
|
|
207
|
+
i18nSelected,
|
|
208
|
+
init,
|
|
209
|
+
initDrag,
|
|
210
|
+
keyOption,
|
|
211
|
+
keyType,
|
|
212
|
+
submitSelection,
|
|
213
|
+
textAuxi,
|
|
214
|
+
textPrimary,
|
|
215
|
+
unmount
|
|
216
|
+
};
|