vxe-pc-ui 4.11.28 → 4.11.30

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.
Files changed (233) hide show
  1. package/README.md +6 -0
  2. package/es/backtop/index.js +12 -0
  3. package/es/backtop/src/backtop.js +231 -0
  4. package/es/backtop/style.css +90 -0
  5. package/es/backtop/style.min.css +1 -0
  6. package/es/cascader/index.js +12 -0
  7. package/es/cascader/src/cascader.js +669 -0
  8. package/es/cascader/style.css +168 -0
  9. package/es/cascader/style.min.css +1 -0
  10. package/es/components.js +18 -0
  11. package/es/icon/{iconfont.1767178201934.ttf → iconfont.1767491587367.ttf} +0 -0
  12. package/es/icon/iconfont.1767491587367.woff +0 -0
  13. package/es/icon/iconfont.1767491587367.woff2 +0 -0
  14. package/es/icon/style.css +9 -1
  15. package/es/icon/style.min.css +1 -1
  16. package/{lib/icon/style/iconfont.1767178201934.ttf → es/iconfont.1767491587367.ttf} +0 -0
  17. package/es/iconfont.1767491587367.woff +0 -0
  18. package/es/iconfont.1767491587367.woff2 +0 -0
  19. package/es/layout-body/src/layout-body.js +39 -6
  20. package/es/mention/index.js +12 -0
  21. package/es/mention/src/mention.js +51 -0
  22. package/es/mention/style.css +0 -0
  23. package/es/mention/style.min.css +0 -0
  24. package/es/segmented/index.js +12 -0
  25. package/es/segmented/src/segmented.js +228 -0
  26. package/es/segmented/style.css +197 -0
  27. package/es/segmented/style.min.css +1 -0
  28. package/es/style.css +1 -1
  29. package/es/style.min.css +1 -1
  30. package/es/tabs/src/tabs.js +1 -4
  31. package/es/timeline/index.js +12 -0
  32. package/es/timeline/src/timeline-item.js +46 -0
  33. package/es/timeline/src/timeline.js +51 -0
  34. package/es/timeline/style.css +0 -0
  35. package/es/timeline/style.min.css +0 -0
  36. package/es/timeline-item/index.js +12 -0
  37. package/es/timeline-item/style.css +0 -0
  38. package/es/timeline-item/style.min.css +0 -0
  39. package/es/tour/index.js +12 -0
  40. package/es/tour/src/tour.js +51 -0
  41. package/es/tour/style.css +0 -0
  42. package/es/tour/style.min.css +0 -0
  43. package/es/ui/index.js +15 -2
  44. package/es/ui/src/log.js +1 -1
  45. package/es/vxe-backtop/index.js +3 -0
  46. package/es/vxe-backtop/style.css +90 -0
  47. package/es/vxe-backtop/style.min.css +1 -0
  48. package/es/vxe-cascader/index.js +3 -0
  49. package/es/vxe-cascader/style.css +168 -0
  50. package/es/vxe-cascader/style.min.css +1 -0
  51. package/es/vxe-icon/style.css +9 -1
  52. package/es/vxe-icon/style.min.css +1 -1
  53. package/es/vxe-mention/index.js +3 -0
  54. package/es/vxe-mention/style.css +0 -0
  55. package/es/vxe-mention/style.min.css +0 -0
  56. package/es/vxe-segmented/index.js +3 -0
  57. package/es/vxe-segmented/style.css +197 -0
  58. package/es/vxe-segmented/style.min.css +1 -0
  59. package/es/vxe-timeline/index.js +3 -0
  60. package/es/vxe-timeline/style.css +0 -0
  61. package/es/vxe-timeline/style.min.css +0 -0
  62. package/es/vxe-timeline-item/index.js +3 -0
  63. package/es/vxe-timeline-item/style.css +0 -0
  64. package/es/vxe-timeline-item/style.min.css +0 -0
  65. package/es/vxe-tour/index.js +3 -0
  66. package/es/vxe-tour/style.css +0 -0
  67. package/es/vxe-tour/style.min.css +0 -0
  68. package/lib/backtop/index.js +19 -0
  69. package/lib/backtop/index.min.js +1 -0
  70. package/lib/backtop/src/backtop.js +256 -0
  71. package/lib/backtop/src/backtop.min.js +1 -0
  72. package/lib/backtop/style/index.js +1 -0
  73. package/lib/backtop/style/style.css +90 -0
  74. package/lib/backtop/style/style.min.css +1 -0
  75. package/lib/cascader/index.js +19 -0
  76. package/lib/cascader/index.min.js +1 -0
  77. package/lib/cascader/src/cascader.js +723 -0
  78. package/lib/cascader/src/cascader.min.js +1 -0
  79. package/lib/cascader/style/index.js +1 -0
  80. package/lib/cascader/style/style.css +168 -0
  81. package/lib/cascader/style/style.min.css +1 -0
  82. package/lib/components.js +73 -1
  83. package/lib/components.min.js +1 -1
  84. package/lib/{iconfont.1767178201934.ttf → icon/style/iconfont.1767491587367.ttf} +0 -0
  85. package/lib/icon/style/iconfont.1767491587367.woff +0 -0
  86. package/lib/icon/style/iconfont.1767491587367.woff2 +0 -0
  87. package/lib/icon/style/style.css +9 -1
  88. package/lib/icon/style/style.min.css +9 -1
  89. package/{es/iconfont.1767178201934.ttf → lib/iconfont.1767491587367.ttf} +0 -0
  90. package/lib/iconfont.1767491587367.woff +0 -0
  91. package/lib/iconfont.1767491587367.woff2 +0 -0
  92. package/lib/index.umd.js +5263 -3740
  93. package/lib/index.umd.min.js +1 -1
  94. package/lib/layout-body/src/layout-body.js +34 -4
  95. package/lib/layout-body/src/layout-body.min.js +1 -1
  96. package/lib/mention/index.js +19 -0
  97. package/lib/mention/index.min.js +1 -0
  98. package/lib/mention/src/mention.js +62 -0
  99. package/lib/mention/src/mention.min.js +1 -0
  100. package/lib/mention/style/index.js +1 -0
  101. package/lib/mention/style/style.css +0 -0
  102. package/lib/mention/style/style.min.css +0 -0
  103. package/lib/segmented/index.js +19 -0
  104. package/lib/segmented/index.min.js +1 -0
  105. package/lib/segmented/src/segmented.js +245 -0
  106. package/lib/segmented/src/segmented.min.js +1 -0
  107. package/lib/segmented/style/index.js +1 -0
  108. package/lib/segmented/style/style.css +197 -0
  109. package/lib/segmented/style/style.min.css +1 -0
  110. package/lib/style.css +1 -1
  111. package/lib/style.min.css +1 -1
  112. package/lib/tabs/src/tabs.js +1 -5
  113. package/lib/tabs/src/tabs.min.js +1 -1
  114. package/lib/timeline/index.js +19 -0
  115. package/lib/timeline/index.min.js +1 -0
  116. package/lib/timeline/src/timeline-item.js +57 -0
  117. package/lib/timeline/src/timeline-item.min.js +1 -0
  118. package/lib/timeline/src/timeline.js +62 -0
  119. package/lib/timeline/src/timeline.min.js +1 -0
  120. package/lib/timeline/style/index.js +1 -0
  121. package/lib/timeline/style/style.css +0 -0
  122. package/lib/timeline/style/style.min.css +0 -0
  123. package/lib/timeline-item/index.js +19 -0
  124. package/lib/timeline-item/index.min.js +1 -0
  125. package/lib/timeline-item/style/index.js +1 -0
  126. package/lib/timeline-item/style/style.css +0 -0
  127. package/lib/timeline-item/style/style.min.css +0 -0
  128. package/lib/tour/index.js +19 -0
  129. package/lib/tour/index.min.js +1 -0
  130. package/lib/tour/src/tour.js +62 -0
  131. package/lib/tour/src/tour.min.js +1 -0
  132. package/lib/tour/style/index.js +1 -0
  133. package/lib/tour/style/style.css +0 -0
  134. package/lib/tour/style/style.min.css +0 -0
  135. package/lib/ui/index.js +15 -2
  136. package/lib/ui/index.min.js +1 -1
  137. package/lib/ui/src/log.js +1 -1
  138. package/lib/ui/src/log.min.js +1 -1
  139. package/lib/vxe-backtop/index.js +22 -0
  140. package/lib/vxe-backtop/index.min.js +1 -0
  141. package/lib/vxe-backtop/style/index.js +1 -0
  142. package/lib/vxe-backtop/style/style.css +90 -0
  143. package/lib/vxe-backtop/style/style.min.css +1 -0
  144. package/lib/vxe-cascader/index.js +22 -0
  145. package/lib/vxe-cascader/index.min.js +1 -0
  146. package/lib/vxe-cascader/style/index.js +1 -0
  147. package/lib/vxe-cascader/style/style.css +168 -0
  148. package/lib/vxe-cascader/style/style.min.css +1 -0
  149. package/lib/vxe-icon/style/style.css +9 -1
  150. package/lib/vxe-icon/style/style.min.css +1 -1
  151. package/lib/vxe-mention/index.js +22 -0
  152. package/lib/vxe-mention/index.min.js +1 -0
  153. package/lib/vxe-mention/style/index.js +1 -0
  154. package/lib/vxe-mention/style/style.css +0 -0
  155. package/lib/vxe-mention/style/style.min.css +0 -0
  156. package/lib/vxe-segmented/index.js +22 -0
  157. package/lib/vxe-segmented/index.min.js +1 -0
  158. package/lib/vxe-segmented/style/index.js +1 -0
  159. package/lib/vxe-segmented/style/style.css +197 -0
  160. package/lib/vxe-segmented/style/style.min.css +1 -0
  161. package/lib/vxe-timeline/index.js +22 -0
  162. package/lib/vxe-timeline/index.min.js +1 -0
  163. package/lib/vxe-timeline/style/index.js +1 -0
  164. package/lib/vxe-timeline/style/style.css +0 -0
  165. package/lib/vxe-timeline/style/style.min.css +0 -0
  166. package/lib/vxe-timeline-item/index.js +22 -0
  167. package/lib/vxe-timeline-item/index.min.js +1 -0
  168. package/lib/vxe-timeline-item/style/index.js +1 -0
  169. package/lib/vxe-timeline-item/style/style.css +0 -0
  170. package/lib/vxe-timeline-item/style/style.min.css +0 -0
  171. package/lib/vxe-tour/index.js +22 -0
  172. package/lib/vxe-tour/index.min.js +1 -0
  173. package/lib/vxe-tour/style/index.js +1 -0
  174. package/lib/vxe-tour/style/style.css +0 -0
  175. package/lib/vxe-tour/style/style.min.css +0 -0
  176. package/package.json +1 -1
  177. package/packages/backtop/index.ts +16 -0
  178. package/packages/backtop/src/backtop.ts +264 -0
  179. package/packages/cascader/index.ts +16 -0
  180. package/packages/cascader/src/cascader.ts +739 -0
  181. package/packages/components.ts +18 -0
  182. package/packages/layout-body/src/layout-body.ts +43 -9
  183. package/packages/mention/index.ts +16 -0
  184. package/packages/mention/src/mention.ts +71 -0
  185. package/packages/segmented/index.ts +16 -0
  186. package/packages/segmented/src/segmented.ts +264 -0
  187. package/packages/tabs/src/tabs.ts +1 -4
  188. package/packages/timeline/index.ts +16 -0
  189. package/packages/timeline/src/timeline-item.ts +67 -0
  190. package/packages/timeline/src/timeline.ts +71 -0
  191. package/packages/timeline-item/index.ts +16 -0
  192. package/packages/tour/index.ts +16 -0
  193. package/packages/tour/src/tour.ts +71 -0
  194. package/packages/ui/index.ts +15 -1
  195. package/styles/all.scss +7 -0
  196. package/styles/components/backtop.scss +111 -0
  197. package/styles/components/cascader.scss +140 -0
  198. package/styles/components/icon.scss +9 -2
  199. package/styles/components/mention.scss +0 -0
  200. package/styles/components/segmented.scss +216 -0
  201. package/styles/components/timeline-item.scss +0 -0
  202. package/styles/components/timeline.scss +0 -0
  203. package/styles/components/tour.scss +0 -0
  204. package/styles/icon/iconfont.ttf +0 -0
  205. package/styles/icon/iconfont.woff +0 -0
  206. package/styles/icon/iconfont.woff2 +0 -0
  207. package/styles/theme/base.scss +4 -0
  208. package/types/all.d.ts +21 -0
  209. package/types/components/backtop.d.ts +111 -0
  210. package/types/components/cascader.d.ts +255 -0
  211. package/types/components/icon.d.ts +2 -2
  212. package/types/components/layout-body.d.ts +9 -0
  213. package/types/components/list.d.ts +2 -2
  214. package/types/components/mention.d.ts +77 -0
  215. package/types/components/rate.d.ts +1 -1
  216. package/types/components/segmented.d.ts +123 -0
  217. package/types/components/select.d.ts +1 -1
  218. package/types/components/table.d.ts +4 -4
  219. package/types/components/timeline-item.d.ts +75 -0
  220. package/types/components/timeline.d.ts +77 -0
  221. package/types/components/tour.d.ts +77 -0
  222. package/types/components/tree-select.d.ts +1 -1
  223. package/types/components/tree.d.ts +1 -1
  224. package/types/ui/global-config.d.ts +14 -0
  225. package/types/ui/global-icon.d.ts +3 -0
  226. package/es/icon/iconfont.1767178201934.woff +0 -0
  227. package/es/icon/iconfont.1767178201934.woff2 +0 -0
  228. package/es/iconfont.1767178201934.woff +0 -0
  229. package/es/iconfont.1767178201934.woff2 +0 -0
  230. package/lib/icon/style/iconfont.1767178201934.woff +0 -0
  231. package/lib/icon/style/iconfont.1767178201934.woff2 +0 -0
  232. package/lib/iconfont.1767178201934.woff +0 -0
  233. package/lib/iconfont.1767178201934.woff2 +0 -0
@@ -0,0 +1,669 @@
1
+ import { ref, computed, h, nextTick, inject, provide, reactive, Teleport, onMounted, onUnmounted, watch } from 'vue';
2
+ import { defineVxeComponent } from '../../ui/src/comp';
3
+ import { getConfig, getI18n, getIcon, globalEvents, createEvent, useSize, renderEmptyElement } from '../../ui';
4
+ import { getEventTargetNode, updatePanelPlacement, toCssUnit } from '../../ui/src/dom';
5
+ import { getLastZIndex, nextZIndex } from '../../ui/src/utils';
6
+ import { deNodeValue } from '../../tree/src/util';
7
+ import { errLog } from '../../ui/src/log';
8
+ import XEUtils from 'xe-utils';
9
+ import VxeInputComponent from '../../input/src/input';
10
+ import VxeButtonComponent from '../../button/src/button';
11
+ function getOptUniqueId() {
12
+ return XEUtils.uniqueId('node_');
13
+ }
14
+ function createInternalData() {
15
+ return {
16
+ // hpTimeout: undefined,
17
+ fullOptionList: [],
18
+ fullNodeMaps: {}
19
+ };
20
+ }
21
+ export default defineVxeComponent({
22
+ name: 'VxeCascader',
23
+ props: {
24
+ modelValue: [String, Number, Array],
25
+ clearable: Boolean,
26
+ placeholder: {
27
+ type: String,
28
+ default: () => XEUtils.eqNull(getConfig().cascader.placeholder) ? getI18n('vxe.base.pleaseSelect') : getConfig().cascader.placeholder
29
+ },
30
+ readonly: {
31
+ type: Boolean,
32
+ default: null
33
+ },
34
+ loading: Boolean,
35
+ disabled: {
36
+ type: Boolean,
37
+ default: null
38
+ },
39
+ filterable: Boolean,
40
+ filterConfig: Object,
41
+ multiple: Boolean,
42
+ className: [String, Function],
43
+ prefixIcon: String,
44
+ placement: String,
45
+ transform: Boolean,
46
+ lazyOptions: Array,
47
+ options: Array,
48
+ optionProps: Object,
49
+ zIndex: Number,
50
+ size: {
51
+ type: String,
52
+ default: () => getConfig().cascader.size || getConfig().size
53
+ },
54
+ remote: Boolean,
55
+ remoteConfig: Function,
56
+ popupConfig: Object,
57
+ autoClose: {
58
+ type: Boolean,
59
+ default: () => getConfig().cascader.autoClose
60
+ },
61
+ showTotalButoon: {
62
+ type: Boolean,
63
+ default: () => getConfig().cascader.showTotalButoon
64
+ },
65
+ showCheckedButoon: {
66
+ type: Boolean,
67
+ default: () => getConfig().cascader.showCheckedButoon
68
+ },
69
+ showClearButton: {
70
+ type: Boolean,
71
+ default: () => getConfig().cascader.showClearButton
72
+ },
73
+ transfer: {
74
+ type: Boolean,
75
+ default: null
76
+ },
77
+ /**
78
+ * 已废弃,被 remote-config.queryMethod 替换
79
+ * @deprecated
80
+ */
81
+ remoteMethod: Function
82
+ },
83
+ emits: [
84
+ 'update:modelValue',
85
+ 'change',
86
+ 'all-change',
87
+ 'clear',
88
+ 'blur',
89
+ 'focus',
90
+ 'click',
91
+ 'node-click'
92
+ ],
93
+ setup(props, context) {
94
+ const { emit, slots } = context;
95
+ const $xeModal = inject('$xeModal', null);
96
+ const $xeDrawer = inject('$xeDrawer', null);
97
+ const $xeTable = inject('$xeTable', null);
98
+ const $xeForm = inject('$xeForm', null);
99
+ const formItemInfo = inject('xeFormItemInfo', null);
100
+ const xID = XEUtils.uniqueId();
101
+ const { computeSize } = useSize(props);
102
+ const refElem = ref();
103
+ const refInput = ref();
104
+ const refInpSearch = ref();
105
+ const refTreeWrapper = ref();
106
+ const refOptionPanel = ref();
107
+ const refTree = ref();
108
+ const reactData = reactive({
109
+ initialized: false,
110
+ searchValue: '',
111
+ searchLoading: false,
112
+ panelIndex: 0,
113
+ panelStyle: {},
114
+ panelPlacement: null,
115
+ triggerFocusPanel: false,
116
+ visiblePanel: false,
117
+ isAniVisible: false,
118
+ isActivated: false
119
+ });
120
+ const internalData = createInternalData();
121
+ const refMaps = {
122
+ refElem
123
+ };
124
+ const computeFormReadonly = computed(() => {
125
+ const { readonly } = props;
126
+ if (readonly === null) {
127
+ if ($xeForm) {
128
+ return $xeForm.props.readonly;
129
+ }
130
+ return false;
131
+ }
132
+ return readonly;
133
+ });
134
+ const computeIsDisabled = computed(() => {
135
+ const { disabled } = props;
136
+ if (disabled === null) {
137
+ if ($xeForm) {
138
+ return $xeForm.props.disabled;
139
+ }
140
+ return false;
141
+ }
142
+ return disabled;
143
+ });
144
+ const computeBtnTransfer = computed(() => {
145
+ const { transfer } = props;
146
+ if (transfer === null) {
147
+ const globalTransfer = getConfig().select.transfer;
148
+ if (XEUtils.isBoolean(globalTransfer)) {
149
+ return globalTransfer;
150
+ }
151
+ if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
152
+ return true;
153
+ }
154
+ }
155
+ return transfer;
156
+ });
157
+ const computePopupOpts = computed(() => {
158
+ return Object.assign({}, getConfig().cascader.popupConfig, props.popupConfig);
159
+ });
160
+ const computePropsOpts = computed(() => {
161
+ return props.optionProps || {};
162
+ });
163
+ const computeNodeKeyField = computed(() => {
164
+ const valueField = computeValueField.value;
165
+ return valueField;
166
+ });
167
+ const computeLabelField = computed(() => {
168
+ const propsOpts = computePropsOpts.value;
169
+ return propsOpts.label || 'label';
170
+ });
171
+ const computeValueField = computed(() => {
172
+ const propsOpts = computePropsOpts.value;
173
+ return propsOpts.value || 'value';
174
+ });
175
+ const computeChildrenField = computed(() => {
176
+ const propsOpts = computePropsOpts.value;
177
+ return propsOpts.children || 'children';
178
+ });
179
+ const computeRemoteOpts = computed(() => {
180
+ return Object.assign({}, getConfig().cascader.remoteConfig, props.remoteConfig);
181
+ });
182
+ const computeSelectLabel = computed(() => {
183
+ const { modelValue, lazyOptions } = props;
184
+ const { fullNodeMaps } = internalData;
185
+ const valueField = computeValueField.value;
186
+ const labelField = computeLabelField.value;
187
+ const selectVals = XEUtils.eqNull(modelValue) ? [] : (XEUtils.isArray(modelValue) ? modelValue : [modelValue]);
188
+ return selectVals.map(val => {
189
+ const cacheItem = fullNodeMaps[val];
190
+ if (cacheItem) {
191
+ return cacheItem.item[labelField];
192
+ }
193
+ if (lazyOptions) {
194
+ const lazyItem = lazyOptions.find(item => item[valueField] === val);
195
+ if (lazyItem) {
196
+ return lazyItem[labelField];
197
+ }
198
+ }
199
+ return val;
200
+ }).join(', ');
201
+ });
202
+ const computePopupWrapperStyle = computed(() => {
203
+ const popupOpts = computePopupOpts.value;
204
+ const { height, width } = popupOpts;
205
+ const stys = {};
206
+ if (width) {
207
+ stys.width = toCssUnit(width);
208
+ }
209
+ if (height) {
210
+ stys.height = toCssUnit(height);
211
+ stys.maxHeight = toCssUnit(height);
212
+ }
213
+ return stys;
214
+ });
215
+ const computeMaps = {};
216
+ const $xeCascader = {
217
+ xID,
218
+ props,
219
+ context,
220
+ reactData,
221
+ internalData,
222
+ getRefMaps: () => refMaps,
223
+ getComputeMaps: () => computeMaps
224
+ };
225
+ const dispatchEvent = (type, params, evnt) => {
226
+ emit(type, createEvent(evnt, { $cascader: $xeCascader }, params));
227
+ };
228
+ const emitModel = (value) => {
229
+ emit('update:modelValue', value);
230
+ };
231
+ const cascaderMethods = {
232
+ dispatchEvent
233
+ };
234
+ const getNodeid = (option) => {
235
+ const nodeKeyField = computeNodeKeyField.value;
236
+ const nodeid = option[nodeKeyField];
237
+ return nodeid ? encodeURIComponent(nodeid) : '';
238
+ };
239
+ const cacheDataMap = () => {
240
+ const { transform, options } = props;
241
+ const nodeKeyField = computeNodeKeyField.value;
242
+ const childrenField = computeChildrenField.value;
243
+ const valueField = computeValueField.value;
244
+ const nodeMaps = {};
245
+ const keyMaps = {};
246
+ const handleOptNode = (item, index, items, path, parent, nodes) => {
247
+ let nodeid = getNodeid(item);
248
+ if (!nodeid) {
249
+ nodeid = getOptUniqueId();
250
+ }
251
+ if (keyMaps[nodeid]) {
252
+ errLog('vxe.error.repeatKey', [`[tree-select] ${nodeKeyField}`, nodeid]);
253
+ }
254
+ keyMaps[nodeid] = true;
255
+ const value = item[valueField];
256
+ if (nodeMaps[value]) {
257
+ errLog('vxe.error.repeatKey', [`[tree-select] ${valueField}`, value]);
258
+ }
259
+ nodeMaps[value] = { item, index, items, parent, nodes };
260
+ };
261
+ if (options) {
262
+ if (transform) {
263
+ options.forEach((item, index, items) => {
264
+ handleOptNode(item, index, items, [], null, []);
265
+ });
266
+ }
267
+ else {
268
+ XEUtils.eachTree(options, handleOptNode, { children: childrenField });
269
+ }
270
+ }
271
+ internalData.fullOptionList = options || [];
272
+ internalData.fullNodeMaps = nodeMaps;
273
+ };
274
+ const updateZindex = () => {
275
+ const { zIndex } = props;
276
+ if (zIndex) {
277
+ reactData.panelIndex = zIndex;
278
+ }
279
+ else if (reactData.panelIndex < getLastZIndex()) {
280
+ reactData.panelIndex = nextZIndex();
281
+ }
282
+ };
283
+ const updatePlacement = () => {
284
+ const { placement } = props;
285
+ const { panelIndex } = reactData;
286
+ const targetElem = refElem.value;
287
+ const panelElem = refOptionPanel.value;
288
+ const btnTransfer = computeBtnTransfer.value;
289
+ const handleStyle = () => {
290
+ const ppObj = updatePanelPlacement(targetElem, panelElem, {
291
+ placement,
292
+ teleportTo: btnTransfer
293
+ });
294
+ const panelStyle = Object.assign(ppObj.style, {
295
+ zIndex: panelIndex
296
+ });
297
+ reactData.panelStyle = panelStyle;
298
+ reactData.panelPlacement = ppObj.placement;
299
+ };
300
+ handleStyle();
301
+ return nextTick().then(handleStyle);
302
+ };
303
+ const showOptionPanel = () => {
304
+ const { loading, remote, filterable } = props;
305
+ const { fullOptionList } = internalData;
306
+ const isDisabled = computeIsDisabled.value;
307
+ const remoteOpts = computeRemoteOpts.value;
308
+ if (!loading && !isDisabled) {
309
+ clearTimeout(internalData.hpTimeout);
310
+ if (!reactData.initialized) {
311
+ reactData.initialized = true;
312
+ }
313
+ reactData.isActivated = true;
314
+ reactData.isAniVisible = true;
315
+ if (filterable) {
316
+ if (remote && remoteOpts.enabled && remoteOpts.autoLoad && !fullOptionList.length) {
317
+ handleSearchEvent();
318
+ }
319
+ }
320
+ setTimeout(() => {
321
+ reactData.visiblePanel = true;
322
+ handleFocusSearch();
323
+ }, 10);
324
+ updateZindex();
325
+ updatePlacement();
326
+ }
327
+ };
328
+ const hideOptionPanel = () => {
329
+ reactData.visiblePanel = false;
330
+ internalData.hpTimeout = setTimeout(() => {
331
+ reactData.isAniVisible = false;
332
+ }, 350);
333
+ };
334
+ const changeEvent = (evnt, selectValue, node) => {
335
+ const value = XEUtils.isArray(selectValue) ? selectValue.map(deNodeValue) : deNodeValue(selectValue);
336
+ emitModel(value);
337
+ if (value !== props.modelValue) {
338
+ dispatchEvent('change', { value, node, option: node }, evnt);
339
+ // 自动更新校验状态
340
+ if ($xeForm && formItemInfo) {
341
+ $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value);
342
+ }
343
+ }
344
+ };
345
+ const clearValueEvent = (evnt, selectValue) => {
346
+ changeEvent(evnt, selectValue, null);
347
+ dispatchEvent('clear', { value: selectValue }, evnt);
348
+ };
349
+ const clearEvent = (params, evnt) => {
350
+ clearValueEvent(evnt, null);
351
+ hideOptionPanel();
352
+ };
353
+ const allCheckedPanelEvent = (params) => {
354
+ const { $event } = params;
355
+ const { multiple, autoClose } = props;
356
+ const $tree = refTree.value;
357
+ if (multiple) {
358
+ if ($tree) {
359
+ $tree.setAllCheckboxNode(true).then(({ checkNodeKeys, checkNodes }) => {
360
+ changeEvent($event, checkNodeKeys, checkNodes[0]);
361
+ dispatchEvent('all-change', { value: checkNodeKeys }, $event);
362
+ if (autoClose) {
363
+ hideOptionPanel();
364
+ }
365
+ });
366
+ }
367
+ }
368
+ };
369
+ const clearCheckedPanelEvent = (params) => {
370
+ const { $event } = params;
371
+ const { multiple, autoClose } = props;
372
+ const $tree = refTree.value;
373
+ if ($tree) {
374
+ const value = multiple ? [] : null;
375
+ $tree.clearCheckboxNode().then(() => {
376
+ if (autoClose) {
377
+ hideOptionPanel();
378
+ }
379
+ });
380
+ changeEvent($event, value, null);
381
+ dispatchEvent('clear', { value }, $event);
382
+ }
383
+ };
384
+ const handleGlobalMousewheelEvent = (evnt) => {
385
+ const { visiblePanel } = reactData;
386
+ const isDisabled = computeIsDisabled.value;
387
+ if (!isDisabled) {
388
+ if (visiblePanel) {
389
+ const panelElem = refOptionPanel.value;
390
+ if (getEventTargetNode(evnt, panelElem).flag) {
391
+ updatePlacement();
392
+ }
393
+ else {
394
+ hideOptionPanel();
395
+ }
396
+ }
397
+ }
398
+ };
399
+ const handleGlobalMousedownEvent = (evnt) => {
400
+ const { visiblePanel } = reactData;
401
+ const isDisabled = computeIsDisabled.value;
402
+ if (!isDisabled) {
403
+ const el = refElem.value;
404
+ const panelElem = refOptionPanel.value;
405
+ reactData.isActivated = getEventTargetNode(evnt, el).flag || getEventTargetNode(evnt, panelElem).flag;
406
+ if (visiblePanel && !reactData.isActivated) {
407
+ hideOptionPanel();
408
+ }
409
+ }
410
+ };
411
+ const handleGlobalBlurEvent = () => {
412
+ const { visiblePanel, isActivated } = reactData;
413
+ if (visiblePanel) {
414
+ hideOptionPanel();
415
+ }
416
+ if (isActivated) {
417
+ reactData.isActivated = false;
418
+ }
419
+ if (visiblePanel || isActivated) {
420
+ const $input = refInput.value;
421
+ if ($input) {
422
+ $input.blur();
423
+ }
424
+ }
425
+ };
426
+ const handleGlobalResizeEvent = () => {
427
+ const { visiblePanel } = reactData;
428
+ if (visiblePanel) {
429
+ updatePlacement();
430
+ }
431
+ };
432
+ const handleFocusSearch = () => {
433
+ if (props.filterable) {
434
+ nextTick(() => {
435
+ const inpSearch = refInpSearch.value;
436
+ if (inpSearch) {
437
+ inpSearch.focus();
438
+ }
439
+ });
440
+ }
441
+ };
442
+ const focusEvent = (evnt) => {
443
+ const isDisabled = computeIsDisabled.value;
444
+ if (!isDisabled) {
445
+ if (!reactData.visiblePanel) {
446
+ reactData.triggerFocusPanel = true;
447
+ showOptionPanel();
448
+ setTimeout(() => {
449
+ reactData.triggerFocusPanel = false;
450
+ }, 150);
451
+ }
452
+ }
453
+ dispatchEvent('focus', {}, evnt);
454
+ };
455
+ const clickEvent = (evnt) => {
456
+ togglePanelEvent(evnt);
457
+ dispatchEvent('click', {}, evnt);
458
+ };
459
+ const blurEvent = (evnt) => {
460
+ reactData.isActivated = false;
461
+ dispatchEvent('blur', {}, evnt);
462
+ };
463
+ const modelSearchEvent = (value) => {
464
+ reactData.searchValue = value;
465
+ };
466
+ const handleSearchEvent = () => {
467
+ const { modelValue, remote, remoteMethod } = props;
468
+ const { searchValue } = reactData;
469
+ const remoteOpts = computeRemoteOpts.value;
470
+ const queryMethod = remoteOpts.queryMethod || remoteMethod;
471
+ if (remote && queryMethod && remoteOpts.enabled) {
472
+ reactData.searchLoading = true;
473
+ Promise.resolve(queryMethod({ $cascader: $xeCascader, searchValue, value: modelValue })).then(() => nextTick())
474
+ .catch(() => nextTick())
475
+ .finally(() => {
476
+ reactData.searchLoading = false;
477
+ });
478
+ }
479
+ };
480
+ const togglePanelEvent = (params) => {
481
+ const { $event } = params;
482
+ $event.preventDefault();
483
+ if (reactData.triggerFocusPanel) {
484
+ reactData.triggerFocusPanel = false;
485
+ }
486
+ else {
487
+ if (reactData.visiblePanel) {
488
+ hideOptionPanel();
489
+ }
490
+ else {
491
+ showOptionPanel();
492
+ }
493
+ }
494
+ };
495
+ const cascaderPrivateMethods = {};
496
+ Object.assign($xeCascader, cascaderMethods, cascaderPrivateMethods);
497
+ const renderVN = () => {
498
+ const { className, modelValue, multiple, loading, filterable, showTotalButoon, showCheckedButoon, showClearButton } = props;
499
+ const { initialized, isActivated, isAniVisible, visiblePanel, searchValue } = reactData;
500
+ const vSize = computeSize.value;
501
+ const isDisabled = computeIsDisabled.value;
502
+ const selectLabel = computeSelectLabel.value;
503
+ const btnTransfer = computeBtnTransfer.value;
504
+ const formReadonly = computeFormReadonly.value;
505
+ const popupWrapperStyle = computePopupWrapperStyle.value;
506
+ const headerSlot = slots.header;
507
+ const footerSlot = slots.footer;
508
+ const prefixSlot = slots.prefix;
509
+ const popupOpts = computePopupOpts.value;
510
+ const popupClassName = popupOpts.className;
511
+ if (formReadonly) {
512
+ return h('div', {
513
+ ref: refElem,
514
+ class: ['vxe-cascader--readonly', className]
515
+ }, [
516
+ h('span', {
517
+ class: 'vxe-cascader-label'
518
+ }, selectLabel)
519
+ ]);
520
+ }
521
+ const selectVals = XEUtils.eqNull(modelValue) ? [] : (XEUtils.isArray(modelValue) ? modelValue : [modelValue]);
522
+ return h('div', {
523
+ ref: refElem,
524
+ class: ['vxe-cascader', className ? (XEUtils.isFunction(className) ? className({ $cascader: $xeCascader }) : className) : '', {
525
+ [`size--${vSize}`]: vSize,
526
+ 'is--filterable': filterable,
527
+ 'is--visible': visiblePanel,
528
+ 'is--disabled': isDisabled,
529
+ 'is--loading': loading,
530
+ 'is--active': isActivated
531
+ }]
532
+ }, [
533
+ h(VxeInputComponent, {
534
+ ref: refInput,
535
+ clearable: props.clearable,
536
+ placeholder: loading ? getI18n('vxe.select.loadingText') : props.placeholder,
537
+ readonly: true,
538
+ disabled: isDisabled,
539
+ type: 'text',
540
+ prefixIcon: props.prefixIcon,
541
+ suffixIcon: loading ? getIcon().TREE_SELECT_LOADED : (visiblePanel ? getIcon().TREE_SELECT_OPEN : getIcon().TREE_SELECT_CLOSE),
542
+ modelValue: loading ? '' : selectLabel,
543
+ title: selectLabel,
544
+ onClear: clearEvent,
545
+ onClick: clickEvent,
546
+ onFocus: focusEvent,
547
+ onBlur: blurEvent,
548
+ onSuffixClick: togglePanelEvent
549
+ }, prefixSlot
550
+ ? {
551
+ prefix: () => prefixSlot({})
552
+ }
553
+ : {}),
554
+ h(Teleport, {
555
+ to: 'body',
556
+ disabled: btnTransfer ? !initialized : true
557
+ }, [
558
+ h('div', {
559
+ ref: refOptionPanel,
560
+ class: ['vxe-table--ignore-clear vxe-cascader--panel', popupClassName ? (XEUtils.isFunction(popupClassName) ? popupClassName({ $cascader: $xeCascader }) : popupClassName) : '', {
561
+ [`size--${vSize}`]: vSize,
562
+ 'is--transfer': btnTransfer,
563
+ 'ani--leave': !loading && isAniVisible,
564
+ 'ani--enter': !loading && visiblePanel
565
+ }],
566
+ placement: reactData.panelPlacement,
567
+ style: reactData.panelStyle
568
+ }, initialized
569
+ ? [
570
+ h('div', {
571
+ class: 'vxe-cascader--panel-wrapper'
572
+ }, [
573
+ filterable
574
+ ? h('div', {
575
+ class: 'vxe-cascader--panel-search'
576
+ }, [
577
+ h(VxeInputComponent, {
578
+ ref: refInpSearch,
579
+ class: 'vxe-cascader-search--input',
580
+ modelValue: searchValue,
581
+ clearable: true,
582
+ disabled: false,
583
+ readonly: false,
584
+ placeholder: getI18n('vxe.cascader.search'),
585
+ prefixIcon: getIcon().INPUT_SEARCH,
586
+ 'onUpdate:modelValue': modelSearchEvent
587
+ })
588
+ ])
589
+ : renderEmptyElement($xeCascader),
590
+ showTotalButoon || (showCheckedButoon && multiple) || showClearButton || headerSlot
591
+ ? h('div', {
592
+ class: 'vxe-cascader--panel-header'
593
+ }, headerSlot
594
+ ? headerSlot({})
595
+ : [
596
+ h('div', {
597
+ class: 'vxe-cascader--header-button'
598
+ }, [
599
+ showTotalButoon
600
+ ? h('div', {
601
+ class: 'vxe-cascader--header-total'
602
+ }, getI18n('vxe.cascader.total', [selectVals.length]))
603
+ : renderEmptyElement($xeCascader),
604
+ h('div', {
605
+ class: 'vxe-cascader--header-btns'
606
+ }, [
607
+ (showCheckedButoon && multiple)
608
+ ? h(VxeButtonComponent, {
609
+ content: getI18n('vxe.cascader.allChecked'),
610
+ mode: 'text',
611
+ onClick: allCheckedPanelEvent
612
+ })
613
+ : renderEmptyElement($xeCascader),
614
+ showClearButton
615
+ ? h(VxeButtonComponent, {
616
+ content: getI18n('vxe.cascader.clearChecked'),
617
+ mode: 'text',
618
+ onClick: clearCheckedPanelEvent
619
+ })
620
+ : renderEmptyElement($xeCascader)
621
+ ])
622
+ ])
623
+ ])
624
+ : renderEmptyElement($xeCascader),
625
+ h('div', {
626
+ class: 'vxe-cascader--panel-body'
627
+ }, [
628
+ h('div', {
629
+ ref: refTreeWrapper,
630
+ class: 'vxe-cascader-tree--wrapper',
631
+ style: popupWrapperStyle
632
+ }, [])
633
+ ]),
634
+ footerSlot
635
+ ? h('div', {
636
+ class: 'vxe-cascader--panel-footer'
637
+ }, footerSlot({}))
638
+ : renderEmptyElement($xeCascader)
639
+ ])
640
+ ]
641
+ : [])
642
+ ])
643
+ ]);
644
+ };
645
+ watch(() => props.options, () => {
646
+ cacheDataMap();
647
+ });
648
+ cacheDataMap();
649
+ onMounted(() => {
650
+ globalEvents.on($xeCascader, 'mousewheel', handleGlobalMousewheelEvent);
651
+ globalEvents.on($xeCascader, 'mousedown', handleGlobalMousedownEvent);
652
+ globalEvents.on($xeCascader, 'blur', handleGlobalBlurEvent);
653
+ globalEvents.on($xeCascader, 'resize', handleGlobalResizeEvent);
654
+ });
655
+ onUnmounted(() => {
656
+ globalEvents.off($xeCascader, 'mousewheel');
657
+ globalEvents.off($xeCascader, 'mousedown');
658
+ globalEvents.off($xeCascader, 'blur');
659
+ globalEvents.off($xeCascader, 'resize');
660
+ XEUtils.assign(internalData, createInternalData());
661
+ });
662
+ provide('$xeCascader', $xeCascader);
663
+ $xeCascader.renderVN = renderVN;
664
+ return $xeCascader;
665
+ },
666
+ render() {
667
+ return this.renderVN();
668
+ }
669
+ });