@opentiny/vue-renderless 3.22.0 → 3.23.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.
@@ -61,6 +61,9 @@ const handleFocus = ({
61
61
  }
62
62
  };
63
63
  const handleBlur = ({ emit, state, dispatch, props }) => () => {
64
+ if (!state.activated) {
65
+ return;
66
+ }
64
67
  state.suggestionDisabled = true;
65
68
  emit("blur");
66
69
  if (state.validateEvent) {
@@ -222,7 +222,6 @@ const getResultOfSetSelected = ({ state, api, props }) => {
222
222
  return result;
223
223
  };
224
224
  const setSelected = ({ api, nextTick, props, vm, state }) => () => {
225
- var _a, _b, _c, _d;
226
225
  if (!props.multiple) {
227
226
  const option = getOptionOfSetSelected({ api, props });
228
227
  state.selected = option;
@@ -231,7 +230,7 @@ const setSelected = ({ api, nextTick, props, vm, state }) => () => {
231
230
  } else {
232
231
  const result = getResultOfSetSelected({ state, props, api });
233
232
  state.selectCls = result.length ? result.length === state.options.length ? "checked-sur" : "halfselect" : "check";
234
- if (!((_b = (_a = state.selected) == null ? void 0 : _a[0]) == null ? void 0 : _b.isTree) && !((_d = (_c = state.selected) == null ? void 0 : _c[0]) == null ? void 0 : _d.isGrid)) {
233
+ if (!vm.$slots.panel) {
235
234
  state.selected = result;
236
235
  }
237
236
  state.selected.length && (state.selectedLabel = "");
@@ -233,7 +233,16 @@ function splitEvent(props, event) {
233
233
  }
234
234
  return result;
235
235
  }
236
- const selectDay = ({ state, emit }) => (day, i) => {
236
+ const computedSelectDay = ({ state }) => (day) => {
237
+ if (!day || !day.value || day.disabled)
238
+ return false;
239
+ if (state.multiSelect) {
240
+ return state.selectedDates.includes(day.value);
241
+ } else {
242
+ return state.selectedDate === day.value;
243
+ }
244
+ };
245
+ const selectDay = ({ props, state, emit, api }) => (day, i) => {
237
246
  if (!day || !day.value || day.disabled)
238
247
  return;
239
248
  state.activedWeekIndex = i;
@@ -247,9 +256,10 @@ const selectDay = ({ state, emit }) => (day, i) => {
247
256
  } else {
248
257
  state.selectedDates.push(date);
249
258
  }
259
+ const dateEvent = dealEvents(props, api, state.selectedDates);
250
260
  emit("update:modelValue", state.selectedDates);
251
261
  emit("selected-date-change", state.selectedDates);
252
- emit("date-click", date);
262
+ emit("date-click", state.selectedDates, dateEvent);
253
263
  } else {
254
264
  if (day.isNext) {
255
265
  const { year, month } = nextMonth(state.activeYear, state.activeMonth);
@@ -263,10 +273,21 @@ const selectDay = ({ state, emit }) => (day, i) => {
263
273
  }
264
274
  state.selectedDate = day.value.toString().length > 2 ? day.value : `${state.activeYear}-${state.activeMonth}-${day.value}`;
265
275
  state.showSelectedDateEvents = true;
276
+ const dateEvent = dealEvents(props, api, [state.selectedDate]);
266
277
  emit("update:modelValue", state.selectedDate);
267
- emit("date-click", state.selectedDate);
278
+ emit("date-click", state.selectedDate, dateEvent[0]);
268
279
  }
269
280
  };
281
+ const dealEvents = (props, api, date) => {
282
+ return date.map((item) => {
283
+ let event = api.getEventByTime(item, props._constants.DAY_START_TIME, props._constants.DAY_END_TIME);
284
+ event.forEach((e) => {
285
+ delete e.dayArr;
286
+ delete e.dayNumber;
287
+ });
288
+ return event;
289
+ });
290
+ };
270
291
  const getEventByMonth = ({ state }) => (year, month) => {
271
292
  const result = [];
272
293
  const days = getDays(Number(year), Number(month));
@@ -608,6 +629,7 @@ function resetTouchStatus(state) {
608
629
  export {
609
630
  computeCascaderOptions,
610
631
  computedCalendar,
632
+ computedSelectDay,
611
633
  currentDateChange,
612
634
  dateIsToday,
613
635
  genDayTimes,
@@ -2,6 +2,7 @@ import "../chunk-G2ADBYYC.js";
2
2
  import {
3
3
  computedCalendar,
4
4
  handleEvents,
5
+ computedSelectDay,
5
6
  selectDay,
6
7
  getEventByTime,
7
8
  isToday,
@@ -47,6 +48,7 @@ const api = [
47
48
  "isToday",
48
49
  "dateIsToday",
49
50
  "getEventByTime",
51
+ "computedSelectDay",
50
52
  "selectDay",
51
53
  "toToday",
52
54
  "getPrevWeek",
@@ -254,7 +256,8 @@ const initApi = ({ vm, api: api2, state, t, props, emit, nextTick }) => {
254
256
  computeCascaderOptions: computeCascaderOptions(t),
255
257
  isToday: isToday(state),
256
258
  dateIsToday: dateIsToday(),
257
- selectDay: selectDay({ state, emit }),
259
+ selectDay: selectDay({ props, state, emit, api: api2 }),
260
+ computedSelectDay: computedSelectDay({ state }),
258
261
  getEventByTime: getEventByTime({ props, state }),
259
262
  toToday: toToday({ state, api: api2, nextTick }),
260
263
  getAllWednesdaysInYear: getAllWednesdaysInYear({ state }),
@@ -8,7 +8,7 @@ import {
8
8
  handleNodeClick
9
9
  } from "./index";
10
10
  const api = ["state", "handleMultiCheckChange", "handleCheckChange", "handleExpand", "handleNodeClick"];
11
- const renderless = (props, { computed, reactive, inject }, { dispatch }) => {
11
+ const renderless = (props, { computed, reactive, inject, watch }, { dispatch }) => {
12
12
  const parent = inject("panel");
13
13
  const api2 = {};
14
14
  const state = reactive({
@@ -24,6 +24,16 @@ const renderless = (props, { computed, reactive, inject }, { dispatch }) => {
24
24
  return parent.state.renderLabelFn ? parent.state.renderLabelFn({ node: props.node, data: props.node.data }) : props.node.label;
25
25
  })
26
26
  });
27
+ if (parent.state.config.expandTrigger !== "click") {
28
+ watch(
29
+ () => state.checkedValue,
30
+ (checkedValue) => {
31
+ if (checkedValue.includes(props.node.value)) {
32
+ api2.handleExpand();
33
+ }
34
+ }
35
+ );
36
+ }
27
37
  Object.assign(api2, {
28
38
  state,
29
39
  isInPath: isInPath(props),
@@ -453,7 +453,13 @@ const getRenderTz = ({ state }) => (value) => {
453
453
  if (!state.showTimezone || !value) {
454
454
  return;
455
455
  }
456
- state.renderTzdata = value[state.lang];
456
+ const lang = state.lang.replace(/[-_]/g, "").toLowerCase();
457
+ Object.keys(value).forEach((key) => {
458
+ if (key.replace(/[-_]/g, "").toLowerCase() === lang) {
459
+ value[lang] = value[key];
460
+ }
461
+ });
462
+ state.renderTzdata = value[lang];
457
463
  if (state.renderTzdata) {
458
464
  const { isServiceTimezone, to } = state.timezone;
459
465
  const selectedTz = state.selectedTz || {};
@@ -396,6 +396,9 @@ const handleConfirm = ({ api, emit, state, props, t }) => (visible = false) => {
396
396
  emit("update:modelValue", [start, end]);
397
397
  emit("select-change", [start, end]);
398
398
  }
399
+ if (state.minDate && !state.maxDate) {
400
+ emit("pick", [state.minDate, state.maxDate], visible, true);
401
+ }
399
402
  };
400
403
  const isValidValue = ({ state }) => (value) => Array.isArray(value) && value && value[0] && value[1] && toDate1(value[0]) && toDate1(value[1]) && value[0].getTime() <= value[1].getTime() && (typeof state.disabledDate === "function" ? !state.disabledDate(value[0]) && !state.disabledDate(value[1]) : true);
401
404
  const resetView = ({ state }) => () => {
@@ -44,7 +44,8 @@ const queryGridData = ({ api, props, state }) => () => {
44
44
  }
45
45
  }
46
46
  };
47
- const multiGridSelectAll = ({ api, props, state }) => ({ selection, checked }) => {
47
+ const multiGridSelectAll = ({ api, props, state }) => ({ selection, checked, $table }, event) => {
48
+ var _a, _b;
48
49
  if (checked) {
49
50
  arrayEach(selection, (item) => {
50
51
  const index = findIndexOf(state.selectedValues, (val) => val === item[props.valueField]);
@@ -67,9 +68,12 @@ const multiGridSelectAll = ({ api, props, state }) => ({ selection, checked }) =
67
68
  state.selectedChanged = true;
68
69
  }
69
70
  api.selectedBoxInit();
71
+ if ((_b = (_a = props.gridOp) == null ? void 0 : _a.events) == null ? void 0 : _b.selectAll) {
72
+ props.gridOp.events.selectAll({ selection, checked, $table }, event);
73
+ }
70
74
  };
71
- const multiGridSelectChange = ({ api, props, state, vm }) => ({ row, checked }) => {
72
- var _a, _b, _c, _d, _e;
75
+ const multiGridSelectChange = ({ api, props, state, vm }) => ({ row, checked, $table }, event) => {
76
+ var _a, _b, _c, _d, _e, _f, _g;
73
77
  const property = props.valueField;
74
78
  const grid = (_a = vm.$refs) == null ? void 0 : _a.multiGrid;
75
79
  const selectedRows = grid.getSelectRecords();
@@ -103,6 +107,9 @@ const multiGridSelectChange = ({ api, props, state, vm }) => ({ row, checked })
103
107
  }
104
108
  }
105
109
  api.selectedBoxInit();
110
+ if ((_g = (_f = props.gridOp) == null ? void 0 : _f.events) == null ? void 0 : _g.selectChange) {
111
+ props.gridOp.events.selectChange({ row, checked, $table }, event);
112
+ }
106
113
  };
107
114
  const selectedBoxInit = ({ props, vm, nextTick }) => () => {
108
115
  const { multi, showSelectedBox } = props;
@@ -420,10 +427,14 @@ const multiTreeRadio = ({ api, props }) => () => {
420
427
  api.multiTreeCheck();
421
428
  }
422
429
  };
423
- const multiGridRadioChange = ({ props, state }) => ({ row }) => {
430
+ const multiGridRadioChange = ({ props, state }) => ({ row, $table }, event) => {
431
+ var _a, _b;
424
432
  state.selectedValues = [row[props.valueField]];
425
433
  state.selectedDatas = [row];
426
434
  state.selectedChanged = true;
435
+ if ((_b = (_a = props.gridOp) == null ? void 0 : _a.events) == null ? void 0 : _b.radioChange) {
436
+ props.gridOp.events.radioChange({ row, $table }, event);
437
+ }
427
438
  };
428
439
  const watchMulti = ({ api, state, props }) => () => {
429
440
  state.splitValue = props.multi ? 0.7 : 1;
@@ -39,6 +39,12 @@ const getCsvContent = ($table, opts, oColumns, oData) => {
39
39
  const { columns, datas } = getCsvData(opts, oData, oColumns, tableEl);
40
40
  let content = "\uFEFF";
41
41
  const transfrom = (str) => {
42
+ if (str === null || str === void 0) {
43
+ return "" + tab;
44
+ }
45
+ if (typeof str === "number" && isNaN(str)) {
46
+ return "-" + tab;
47
+ }
42
48
  if (typeof str === "string" && str.replace(/ /g, "").match(/[\s,"]/)) {
43
49
  str = '"' + str.replace(/"/g, '""') + '"';
44
50
  }
@@ -210,7 +210,7 @@ const initWatch = ({ watch, state, api: api2, props, nextTick, vm }) => {
210
210
  () => {
211
211
  state.urlList = props.urlList;
212
212
  },
213
- { deep: true }
213
+ { deep: true, immediate: true }
214
214
  );
215
215
  };
216
216
  const renderless = (props, { computed, onMounted, onBeforeUnmount, onUpdated, reactive, watch, inject, provide }, { t, parent, nextTick, emit, constants, vm, mode }) => {
@@ -135,6 +135,9 @@ const handleConfirm = ({ api, emit, state, props, t }) => (visible = false) => {
135
135
  emit("update:modelValue", [start, end]);
136
136
  emit("select-change", [start, end]);
137
137
  }
138
+ if (state.minDate && !state.maxDate) {
139
+ emit("pick", [state.minDate, state.maxDate], visible, true);
140
+ }
138
141
  };
139
142
  const isValidValue = (state) => (value) => Array.isArray(value) && value && value[1] && value[0] && isDate(value[1]) && isDate(value[0]) && value[0].getTime() <= value[1].getTime() && (typeof state.disabledDate === "function" ? !state.disabledDate(value[1]) && !state.disabledDate(value[0]) : true);
140
143
  const resetView = (state) => () => {
@@ -0,0 +1,53 @@
1
+ import "../chunk-G2ADBYYC.js";
2
+ const onFinish = ({ emit, props, state }) => () => {
3
+ state.value = props.to;
4
+ state.animating = false;
5
+ emit("finish");
6
+ };
7
+ const easeOut = (t) => 1 - (1 - t) ** 5;
8
+ const play = ({ props, state, api }) => () => {
9
+ animate(state, props, api);
10
+ };
11
+ const animate = (state, props, api) => {
12
+ state.animating = true;
13
+ state.value = props.from;
14
+ if (props.from !== props.to) {
15
+ const startTime = performance.now();
16
+ const tick = () => {
17
+ const current = performance.now();
18
+ const elapsedTime = Math.min(current - startTime, props.duration);
19
+ const currentValue = props.from + (props.to - props.from) * easeOut(elapsedTime / props.duration);
20
+ if (elapsedTime === props.duration) {
21
+ api.onFinish();
22
+ return;
23
+ }
24
+ state.value = currentValue;
25
+ requestAnimationFrame(tick);
26
+ };
27
+ tick();
28
+ }
29
+ };
30
+ const formattedValue = ({ state, props }) => () => {
31
+ if (typeof state.value !== "number" && typeof state.value !== "string")
32
+ return;
33
+ if (typeof props.precision !== "number")
34
+ return;
35
+ const numValue = Number(state.value);
36
+ if (isNaN(numValue) || !isFinite(numValue))
37
+ return;
38
+ if (numValue === 0) {
39
+ return numValue.toFixed(props.precision);
40
+ }
41
+ let formatValue = numValue.toFixed(props.precision);
42
+ if (typeof props.separator === "string" && props.separator !== "") {
43
+ const [integerPart, decimalPart] = formatValue.split(".");
44
+ formatValue = integerPart.replace(/(\d)(?=(\d{3})+$)/g, "$1" + props.separator) + (decimalPart ? "." + decimalPart : "");
45
+ }
46
+ return formatValue;
47
+ };
48
+ export {
49
+ animate,
50
+ formattedValue,
51
+ onFinish,
52
+ play
53
+ };
@@ -0,0 +1,27 @@
1
+ import "../chunk-G2ADBYYC.js";
2
+ import { play, formattedValue, onFinish } from "./index";
3
+ const api = ["state", "play", "formattedValue", "onFinish"];
4
+ const renderless = (props, { onMounted, computed, reactive }, { emit }) => {
5
+ const api2 = {};
6
+ const state = reactive({
7
+ animating: true,
8
+ value: props.from,
9
+ showValue: computed(() => api2.formattedValue(state, props))
10
+ });
11
+ onMounted(() => {
12
+ if (props.active) {
13
+ api2.play(props, state);
14
+ }
15
+ });
16
+ Object.assign(api2, {
17
+ state,
18
+ play: play({ props, state, api: api2 }),
19
+ formattedValue: formattedValue({ state, props }),
20
+ onFinish: onFinish({ emit, props, state })
21
+ });
22
+ return api2;
23
+ };
24
+ export {
25
+ api,
26
+ renderless
27
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/vue-renderless",
3
- "version": "3.22.0",
3
+ "version": "3.23.0",
4
4
  "description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
5
5
  "author": "OpenTiny Team",
6
6
  "license": "MIT",
@@ -25,8 +25,8 @@
25
25
  ],
26
26
  "sideEffects": false,
27
27
  "dependencies": {
28
- "@opentiny/utils": "~3.22.0",
29
- "@opentiny/vue-hooks": "~3.22.0",
28
+ "@opentiny/utils": "~3.23.0",
29
+ "@opentiny/vue-hooks": "~3.23.0",
30
30
  "color": "4.2.3"
31
31
  },
32
32
  "devDependencies": {
package/picker/index.js CHANGED
@@ -46,8 +46,8 @@ const watchMobileVisible = ({ api, props, state, nextTick }) => ([dateMobileVisi
46
46
  });
47
47
  }
48
48
  };
49
- const watchPickerVisible = ({ api, vm, dispatch, emit, props, state, nextTick }) => (value) => {
50
- if (props.readonly || state.pickerDisabled || state.isMobileScreen)
49
+ const watchPickerVisible = ({ api, vm, dispatch, emit, props, state, nextTick, isPCMode }) => (value) => {
50
+ if (props.readonly || state.pickerDisabled || state.isMobileScreen && !isPCMode)
51
51
  return;
52
52
  if (value) {
53
53
  api.showPicker();
@@ -704,18 +704,18 @@ const handleClose = ({ api, props, state }) => () => {
704
704
  api.emitInput(oldValue, true);
705
705
  }
706
706
  };
707
- const handleFocus = ({ emit, vm, state, api, props }) => () => {
707
+ const handleFocus = ({ emit, vm, state, api, props, isPCMode }) => () => {
708
708
  const type = state.type;
709
709
  if (props.readonly || state.pickerDisabled) {
710
710
  return;
711
711
  }
712
712
  if (DATEPICKER.TriggerTypes.includes(type)) {
713
- if (state.isMobileScreen && state.isDateMobileComponent) {
713
+ if (!state.isMobileScreen || isPCMode) {
714
+ state.pickerVisible = true;
715
+ } else if (state.isDateMobileComponent) {
714
716
  api.dateMobileToggle(true);
715
- } else if (state.isMobileScreen && state.isTimeMobileComponent) {
717
+ } else if (state.isTimeMobileComponent) {
716
718
  api.timeMobileToggle(true);
717
- } else {
718
- state.pickerVisible = true;
719
719
  }
720
720
  }
721
721
  emit("focus", vm.$refs.reference);
@@ -786,14 +786,19 @@ const showPicker = ({ api, nextTick, updatePopper, state }) => () => {
786
786
  state.picker.adjustSpinners && state.picker.adjustSpinners();
787
787
  });
788
788
  };
789
- const handlePick = ({ state, api }) => (date = "", visible = false) => {
789
+ const handlePick = ({ state, api }) => (date = "", visible = false, chooseOne = false) => {
790
790
  if (!state.picker)
791
791
  return;
792
- state.userInput = null;
793
- state.pickerVisible = state.picker.state.visible = visible;
794
- api.emitInput(date, visible);
795
- state.date = date;
796
- state.picker.resetView && state.picker.resetView();
792
+ if (chooseOne) {
793
+ const minDate = date && date[0] || "";
794
+ state.userInput = [api.formatToString(minDate), null];
795
+ } else {
796
+ state.userInput = null;
797
+ state.pickerVisible = state.picker.state.visible = visible;
798
+ api.emitInput(date, visible);
799
+ state.date = date;
800
+ state.picker.resetView && state.picker.resetView();
801
+ }
797
802
  };
798
803
  const handleSelectRange = (state) => (start, end, pos) => {
799
804
  if (state.refInput.length === 0) {
package/picker/vue.js CHANGED
@@ -154,7 +154,7 @@ const initState = ({ api: api2, reactive, vm, computed, props, utils, parent, br
154
154
  });
155
155
  return state;
156
156
  };
157
- const initApi = ({ api: api2, props, hooks, state, vnode, others, utils, parent }) => {
157
+ const initApi = ({ api: api2, props, hooks, state, vnode, others, utils, parent, isPCMode }) => {
158
158
  const { t, emit, dispatch, nextTick, vm } = vnode;
159
159
  const { TimePanel, TimeRangePanel } = others;
160
160
  const { destroyPopper, popperElm, updatePopper } = initPopper({ props, hooks, vnode });
@@ -166,7 +166,7 @@ const initApi = ({ api: api2, props, hooks, state, vnode, others, utils, parent
166
166
  hidePicker: hidePicker({ destroyPopper, state }),
167
167
  handleSelectChange: ({ tz, date }) => !state.ranged && emit("select-change", { tz, date }),
168
168
  getPanel: getPanel(others),
169
- handleFocus: handleFocus({ emit, vm, state, api: api2, props }),
169
+ handleFocus: handleFocus({ emit, vm, state, api: api2, props, isPCMode }),
170
170
  getTimezone: getTimezone({ props, utils }),
171
171
  emitChange: emitChange({ api: api2, dispatch, emit, props, state }),
172
172
  parsedValue: parsedValue({ api: api2, props, state, t }),
@@ -189,7 +189,7 @@ const initApi = ({ api: api2, props, hooks, state, vnode, others, utils, parent
189
189
  handleClose: handleClose({ api: api2, props, state }),
190
190
  displayValue: displayValue({ api: api2, props, state }),
191
191
  handlePick: handlePick({ api: api2, state }),
192
- watchPickerVisible: watchPickerVisible({ api: api2, vm, dispatch, emit, props, state, nextTick }),
192
+ watchPickerVisible: watchPickerVisible({ api: api2, vm, dispatch, emit, props, state, nextTick, isPCMode }),
193
193
  watchMobileVisible: watchMobileVisible({ api: api2, props, state, nextTick }),
194
194
  formatToString: formatToString({ api: api2, state }),
195
195
  watchIsRange: watchIsRange({ api: api2, state, TimePanel, TimeRangePanel }),
@@ -263,12 +263,12 @@ const initWatch = ({ api: api2, state, props, watch, markRaw }) => {
263
263
  const renderless = (props, hooks, vnode, others) => {
264
264
  const api2 = {};
265
265
  const { reactive, computed, watch, onBeforeUnmount, inject, markRaw, onMounted } = hooks;
266
- const { vm, service, parent, useBreakpoint } = vnode;
266
+ const { vm, service, parent, useBreakpoint, isPCMode } = vnode;
267
267
  const { utils = {} } = service || {};
268
268
  const breakpoint = useBreakpoint();
269
269
  const state = initState({ api: api2, reactive, vm, computed, props, utils, parent, inject, breakpoint });
270
270
  parent.tinyForm = parent.tinyForm || inject("form", null);
271
- initApi({ api: api2, props, hooks, state, vnode, others, utils, parent });
271
+ initApi({ api: api2, props, hooks, state, vnode, others, utils, parent, isPCMode });
272
272
  initWatch({ api: api2, state, props, watch, markRaw });
273
273
  api2.initGlobalTimezone();
274
274
  onMounted(() => {
package/tabs-mf/index.js CHANGED
@@ -204,6 +204,9 @@ const wheelListener = ({ vm, api, tabs, state }) => debounce(10, (e) => {
204
204
  });
205
205
  const getBoundRect = (vm) => () => vm.$el.getBoundingClientRect();
206
206
  const handleClickDropdownItem = (tabs) => (name) => tabs.clickMore(name);
207
+ const scrollToLeft = (tabs) => () => {
208
+ tabs.scrollTo(tabs.state.navs[0].name);
209
+ };
207
210
  const key = (opt) => opt.name + "-" + random();
208
211
  const emitAdd = (tabs) => () => {
209
212
  tabs.$emit("edit", null, "add");
@@ -279,6 +282,7 @@ export {
279
282
  onTouchstart,
280
283
  removeItem,
281
284
  scrollTo,
285
+ scrollToLeft,
282
286
  setActive,
283
287
  sortItem,
284
288
  unobserveTabSwipeSize,
@@ -1,9 +1,9 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
2
  import { addResizeListener, removeResizeListener } from "@opentiny/utils";
3
- import { wheelListener, getBoundRect, handleClickDropdownItem, key, emitAdd } from "./index";
3
+ import { wheelListener, getBoundRect, handleClickDropdownItem, key, emitAdd, scrollToLeft } from "./index";
4
4
  import { getAddWheelListener } from "./wheel";
5
5
  const { addWheelListener, removeWheelListener } = getAddWheelListener(window, document);
6
- const api = ["state", "wheelListener", "handleClickDropdownItem", "key", "emitAdd"];
6
+ const api = ["state", "wheelListener", "handleClickDropdownItem", "key", "emitAdd", "scrollToLeft"];
7
7
  const renderless = (props, { onMounted, onBeforeUnmount, reactive, watch, inject, computed }, { vm }) => {
8
8
  const tabs = inject("tabs", null);
9
9
  const state = reactive({
@@ -21,7 +21,8 @@ const renderless = (props, { onMounted, onBeforeUnmount, reactive, watch, inject
21
21
  getBoundRect: getBoundRect(vm),
22
22
  handleClickDropdownItem: handleClickDropdownItem(tabs),
23
23
  key,
24
- emitAdd: emitAdd(tabs)
24
+ emitAdd: emitAdd(tabs),
25
+ scrollToLeft: scrollToLeft(tabs)
25
26
  };
26
27
  Object.assign(api2, {
27
28
  state,
package/transfer/index.js CHANGED
@@ -202,6 +202,44 @@ const sortableEvent = ({
202
202
  };
203
203
  const getLeftCheckedData = ({ props, state }) => () => state.sourceData.filter((item) => !item[props.props.disabled]);
204
204
  const getRightCheckedData = ({ props, state }) => () => state.targetData.filter((item) => !item[props.props.disabled]);
205
+ const recurseTreeDataToDisabled = (treeData, childrenProp, idProp, currentValue = []) => {
206
+ treeData.forEach((item) => {
207
+ if (item[childrenProp]) {
208
+ recurseTreeDataToDisabled(item[childrenProp], childrenProp, idProp, currentValue);
209
+ }
210
+ if (currentValue.includes(item[idProp])) {
211
+ item.disabled = true;
212
+ } else if (item.__disabled) {
213
+ item.disabled = true;
214
+ } else {
215
+ item.disabled = false;
216
+ }
217
+ });
218
+ };
219
+ const recurseTreeDataToFlagInitDisabled = (treeData, childrenProp, idProp, modelValue) => {
220
+ if (treeData.__inited)
221
+ return;
222
+ treeData.__inited = true;
223
+ treeData.forEach((item) => {
224
+ if (item[childrenProp]) {
225
+ recurseTreeDataToFlagInitDisabled(item[childrenProp], childrenProp, idProp, modelValue);
226
+ }
227
+ if (item.disabled) {
228
+ item.__disabled = true;
229
+ }
230
+ if (modelValue.includes(item[idProp])) {
231
+ item.disabled = true;
232
+ }
233
+ });
234
+ };
235
+ const setCheckedOnMounted = ({ props, vm, Tree }) => () => {
236
+ if (props.render && props.render.plugin.name === Tree) {
237
+ setTimeout(() => {
238
+ var _a, _b, _c;
239
+ (_c = (_b = (_a = vm.$refs.leftPanel) == null ? void 0 : _a.$refs) == null ? void 0 : _b.plugin) == null ? void 0 : _c.setCheckedKeys(props.modelValue);
240
+ }, 50);
241
+ }
242
+ };
205
243
  export {
206
244
  addToLeft,
207
245
  addToRight,
@@ -215,5 +253,8 @@ export {
215
253
  logicFun,
216
254
  onSourceCheckedChange,
217
255
  onTargetCheckedChange,
256
+ recurseTreeDataToDisabled,
257
+ recurseTreeDataToFlagInitDisabled,
258
+ setCheckedOnMounted,
218
259
  sortableEvent
219
260
  };
package/transfer/vue.js CHANGED
@@ -11,34 +11,48 @@ import {
11
11
  addToLeft,
12
12
  addToRight,
13
13
  clearQuery,
14
- sortableEvent
14
+ sortableEvent,
15
+ recurseTreeDataToFlagInitDisabled,
16
+ recurseTreeDataToDisabled,
17
+ setCheckedOnMounted
15
18
  } from "./index";
16
19
  const api = ["state", "onSourceCheckedChange", "onTargetCheckedChange", "addToLeft", "addToRight", "clearQuery"];
17
- const initState = ({ reactive, computed, api: api2, props, h, slots }) => reactive({
18
- leftChecked: [],
19
- rightChecked: [],
20
- rightData: computed(() => api2.getRightCheckedData()),
21
- leftData: computed(() => api2.getLeftCheckedData()),
22
- dataObj: computed(() => api2.getObj()),
23
- sourceData: computed(() => api2.getSourceData()),
24
- targetData: computed(() => api2.getTargetData()),
25
- hasButtonTexts: computed(() => props.buttonTexts.length === 2),
26
- isToLeft: false,
27
- optionRender: computed(() => (option) => {
28
- if (props.renderContent) {
29
- return props.renderContent(h, option);
30
- }
31
- if (slots.default) {
32
- return slots.default({ option });
33
- }
34
- return h("span", option[props.props.label] || option[props.props.key]);
35
- })
36
- });
37
- const renderless = (props, { computed, onMounted, reactive, h }, { $prefix, emit, refs, parent, slots, vm }) => {
20
+ const initState = ({ reactive, computed, api: api2, props, h, slots, Tree }) => {
21
+ const state = reactive({
22
+ leftChecked: [],
23
+ rightChecked: [],
24
+ rightData: computed(() => api2.getRightCheckedData()),
25
+ leftData: computed(() => api2.getLeftCheckedData()),
26
+ dataObj: computed(() => api2.getObj()),
27
+ sourceData: computed(() => api2.getSourceData()),
28
+ targetData: computed(() => api2.getTargetData()),
29
+ hasButtonTexts: computed(() => props.buttonTexts.length === 2),
30
+ isToLeft: false,
31
+ optionRender: computed(() => (option) => {
32
+ if (props.renderContent) {
33
+ return props.renderContent(h, option);
34
+ }
35
+ if (slots.default) {
36
+ return slots.default({ option });
37
+ }
38
+ return h("span", option[props.props.label] || option[props.props.key]);
39
+ }),
40
+ isToLeftBtnDisabled: computed(() => {
41
+ var _a, _b;
42
+ if (((_b = (_a = props.render) == null ? void 0 : _a.plugin) == null ? void 0 : _b.name) === Tree) {
43
+ return props.toLeftDisable && state.leftChecked.length <= props.modelValue.length;
44
+ }
45
+ return props.toLeftDisable && state.leftChecked.length === 0;
46
+ })
47
+ });
48
+ return state;
49
+ };
50
+ const renderless = (props, { computed, onMounted, reactive, h, watch }, { $prefix, emit, refs, parent, slots, vm }) => {
51
+ var _a, _b;
38
52
  const api2 = {};
39
53
  const Tree = $prefix + "Tree";
40
54
  const Table = $prefix + "Table";
41
- const state = initState({ reactive, computed, api: api2, props, h, slots });
55
+ const state = initState({ reactive, computed, api: api2, props, h, slots, Tree });
42
56
  const { DROPPANEL, TRANSFERPANEL } = parent.$constants;
43
57
  Object.assign(api2, {
44
58
  state,
@@ -53,9 +67,35 @@ const renderless = (props, { computed, onMounted, reactive, h }, { $prefix, emit
53
67
  onSourceCheckedChange: onSourceCheckedChange({ emit, state }),
54
68
  logicFun: logicFun({ props, emit, state, vm }),
55
69
  getTargetData: getTargetData({ props, state, Tree, Table }),
56
- sortableEvent: sortableEvent({ api: api2, droppanel: DROPPANEL, props, queryDom: TRANSFERPANEL, refs })
70
+ sortableEvent: sortableEvent({ api: api2, droppanel: DROPPANEL, props, queryDom: TRANSFERPANEL, refs }),
71
+ setCheckedOnMounted: setCheckedOnMounted({ props, vm, Tree })
57
72
  });
73
+ if (((_b = (_a = props.render) == null ? void 0 : _a.plugin) == null ? void 0 : _b.name) === Tree) {
74
+ watch(
75
+ props.data,
76
+ (value) => {
77
+ recurseTreeDataToFlagInitDisabled(
78
+ value,
79
+ props.props.children || "children",
80
+ props.props.key || "key",
81
+ props.modelValue
82
+ );
83
+ },
84
+ { immediate: true }
85
+ );
86
+ watch(
87
+ () => props.modelValue,
88
+ (value) => {
89
+ var _a2, _b2;
90
+ if (((_b2 = (_a2 = props.render) == null ? void 0 : _a2.plugin) == null ? void 0 : _b2.name) === Tree) {
91
+ recurseTreeDataToDisabled(props.data, props.props.children || "children", props.props.key || "key", value);
92
+ api2.setCheckedOnMounted();
93
+ }
94
+ }
95
+ );
96
+ }
58
97
  onMounted(api2.sortableEvent);
98
+ onMounted(api2.setCheckedOnMounted);
59
99
  return api2;
60
100
  };
61
101
  export {
@@ -185,6 +185,11 @@ const handlePageChange = (state) => (currentPage) => {
185
185
  const getFilterTreeData = ({ props, state }) => (data) => {
186
186
  const getChild = (data2, query) => {
187
187
  data2.forEach((node) => {
188
+ if (node.__disabled) {
189
+ node.disabled = true;
190
+ } else if (!props.showLeft) {
191
+ node.disabled = false;
192
+ }
188
193
  const label = node[state.labelProp];
189
194
  if (typeof props.treeOp.filterNodeMethod === "function") {
190
195
  const result = props.treeOp.filterNodeMethod(state.query, node);
@@ -28,8 +28,7 @@ const check = ({ props, vm, emit }) => (data, { checkedNodes }) => {
28
28
  currentValue.push(node[props.valueField]);
29
29
  return __spreadProps(__spreadValues({}, node), {
30
30
  currentLabel: node[props.textField],
31
- value: node[props.valueField],
32
- isTree: true
31
+ value: node[props.valueField]
33
32
  });
34
33
  })
35
34
  );
@@ -63,40 +62,51 @@ const getPluginOption = ({ api, props, state }) => (value) => {
63
62
  }
64
63
  return items;
65
64
  };
66
- const getCheckedData = ({ props, state }) => () => {
65
+ const getCheckedData = ({ props, state }) => (selected) => {
67
66
  const checkedKey = [];
68
- if (!Array.isArray(state.selected)) {
69
- return props.modelValue ? [props.modelValue] : [state.selected[props.valueField]];
67
+ if (!Array.isArray(selected)) {
68
+ return props.modelValue ? [props.modelValue] : [selected[props.valueField]];
70
69
  } else {
71
- state.selected.length > 0 && state.selected.forEach((item) => {
70
+ selected.length > 0 && selected.forEach((item) => {
72
71
  checkedKey.push(item[props.valueField]);
73
72
  });
74
73
  return checkedKey;
75
74
  }
76
75
  };
76
+ const getChildValue = () => (childNodes, key) => {
77
+ const ids = [];
78
+ const getChild = (nodes) => {
79
+ nodes.forEach((node) => {
80
+ ids.push(node.data[key]);
81
+ if (node.childNodes.length > 0) {
82
+ getChild(node.childNodes);
83
+ }
84
+ });
85
+ };
86
+ getChild(childNodes);
87
+ return ids;
88
+ };
77
89
  const mounted = ({ api, state, props, vm }) => () => {
78
- if (!state.value || state.value.length === 0)
90
+ if (!state.modelValue || state.modelValue.length === 0)
79
91
  return;
80
92
  if (props.multiple) {
81
93
  let initialNodes = [];
82
- if (Array.isArray(state.value)) {
83
- state.value.forEach((value) => {
94
+ if (Array.isArray(state.modelValue)) {
95
+ state.modelValue.forEach((value) => {
84
96
  const option = api.getPluginOption(value);
85
97
  initialNodes = initialNodes.concat(option);
86
98
  });
87
99
  }
88
- vm.$refs.baseSelectRef.updateSelectedData(
89
- initialNodes.map((node) => {
90
- return __spreadProps(__spreadValues({}, node), {
91
- currentLabel: node[props.textField],
92
- value: node[props.valueField],
93
- isTree: true
94
- });
95
- })
96
- );
97
- state.defaultCheckedKeys = api.getCheckedData()[0];
100
+ const selected = initialNodes.map((node) => {
101
+ return __spreadProps(__spreadValues({}, node), {
102
+ currentLabel: node[props.textField],
103
+ value: node[props.valueField]
104
+ });
105
+ });
106
+ vm.$refs.baseSelectRef.updateSelectedData(selected);
107
+ state.defaultCheckedKeys = api.getCheckedData(selected);
98
108
  } else {
99
- const data = api.getPluginOption(state.value)[0];
109
+ const data = api.getPluginOption(state.modelValue)[0];
100
110
  vm.$refs.baseSelectRef.updateSelectedData(__spreadProps(__spreadValues({}, data), {
101
111
  currentLabel: data[props.textField],
102
112
  value: data[props.valueField],
@@ -107,12 +117,48 @@ const mounted = ({ api, state, props, vm }) => () => {
107
117
  state.currentKey = data[props.valueField];
108
118
  }
109
119
  };
120
+ const watchValue = ({ api, props, vm, state }) => (newValue, oldValue) => {
121
+ if (props.multiple) {
122
+ const xorResult = oldValue.filter((item) => !newValue.includes(item));
123
+ const tagId = xorResult[0];
124
+ const treeIds = [tagId];
125
+ let checkedKeys = newValue;
126
+ if (xorResult.length === 1 && !props.treeOp.checkStrictly) {
127
+ let node = vm.$refs.treeRef.getNode(tagId);
128
+ if (!node.isLeaf) {
129
+ treeIds.push(...api.getChildValue(node.childNodes, props.valueField));
130
+ }
131
+ while (node.parent && !Array.isArray(node.parent.data)) {
132
+ node.parent.data && treeIds.push(node.parent.data[props.valueField]);
133
+ node = node.parent;
134
+ }
135
+ checkedKeys = newValue.filter((item) => !treeIds.includes(item));
136
+ }
137
+ let initialNodes = [];
138
+ if (Array.isArray(checkedKeys)) {
139
+ checkedKeys.forEach((value) => {
140
+ const option = api.getPluginOption(value);
141
+ initialNodes = initialNodes.concat(option);
142
+ });
143
+ }
144
+ const selected = initialNodes.map((node) => {
145
+ return __spreadProps(__spreadValues({}, node), {
146
+ currentLabel: node[props.textField],
147
+ value: node[props.valueField]
148
+ });
149
+ });
150
+ vm.$refs.baseSelectRef.updateSelectedData(selected);
151
+ vm.$refs.treeRef.setCheckedKeys(checkedKeys);
152
+ }
153
+ };
110
154
  export {
111
155
  check,
112
156
  filter,
113
157
  getCheckedData,
158
+ getChildValue,
114
159
  getPluginOption,
115
160
  getTreeData,
116
161
  mounted,
117
- nodeClick
162
+ nodeClick,
163
+ watchValue
118
164
  };
@@ -1,5 +1,15 @@
1
1
  import "../chunk-G2ADBYYC.js";
2
- import { check, filter, getCheckedData, getPluginOption, getTreeData, mounted, nodeClick } from "./index";
2
+ import {
3
+ check,
4
+ filter,
5
+ getCheckedData,
6
+ getPluginOption,
7
+ getTreeData,
8
+ mounted,
9
+ nodeClick,
10
+ watchValue,
11
+ getChildValue
12
+ } from "./index";
3
13
  const api = ["state", "check", "filter", "nodeClick"];
4
14
  const renderless = (props, { reactive, computed, watch, onMounted }, { vm, emit }) => {
5
15
  const api2 = {};
@@ -9,7 +19,7 @@ const renderless = (props, { reactive, computed, watch, onMounted }, { vm, emit
9
19
  defaultCheckedKeys: [],
10
20
  remoteData: [],
11
21
  treeData: props.treeOp.data,
12
- value: computed(() => props.modelValue)
22
+ modelValue: []
13
23
  });
14
24
  Object.assign(api2, {
15
25
  state,
@@ -19,13 +29,27 @@ const renderless = (props, { reactive, computed, watch, onMounted }, { vm, emit
19
29
  getPluginOption: getPluginOption({ api: api2, props, state }),
20
30
  getTreeData: getTreeData({ props, state }),
21
31
  mounted: mounted({ api: api2, state, props, vm }),
22
- nodeClick: nodeClick({ props, vm, emit })
32
+ nodeClick: nodeClick({ props, vm, emit }),
33
+ watchValue: watchValue({ api: api2, props, vm, state }),
34
+ getChildValue: getChildValue()
23
35
  });
24
36
  watch(
25
37
  () => props.treeOp.data,
26
38
  (data) => data && (state.treeData = data),
27
39
  { immediate: true, deep: true }
28
40
  );
41
+ watch(
42
+ () => props.modelValue,
43
+ () => {
44
+ if (props.multiple && Array.isArray(props.modelValue)) {
45
+ state.modelValue = [...props.modelValue];
46
+ } else {
47
+ state.modelValue = props.modelValue;
48
+ }
49
+ },
50
+ { immediate: true, deep: true }
51
+ );
52
+ watch(() => state.modelValue, api2.watchValue);
29
53
  onMounted(api2.mounted);
30
54
  return api2;
31
55
  };
@@ -75,7 +75,7 @@ declare const buttonProps: {
75
75
  type: PropType<(ev: MouseEvent) => void>;
76
76
  };
77
77
  tiny_mode: StringConstructor;
78
- tiny_mode_root: BooleanConstructor;
78
+ tiny_mode_root: BooleanConstructor; /** 是否圆角按钮 */
79
79
  tiny_template: (FunctionConstructor | ObjectConstructor)[];
80
80
  tiny_renderless: FunctionConstructor;
81
81
  tiny_theme: StringConstructor;
@@ -93,6 +93,9 @@ declare const transferProps: {
93
93
  };
94
94
  treeOp: ObjectConstructor;
95
95
  beforeTransfer: FunctionConstructor;
96
+ panelStyle: ObjectConstructor;
97
+ panelBodyStyle: ObjectConstructor;
98
+ panelTableHeight: StringConstructor;
96
99
  tiny_mode: StringConstructor;
97
100
  tiny_mode_root: BooleanConstructor;
98
101
  tiny_template: (FunctionConstructor | ObjectConstructor)[];
@@ -6,7 +6,10 @@ const getIsDefault = ({ props }) => (year) => {
6
6
  return Array.isArray(defaultValue) ? defaultValue.some((v) => v && v.getFullYear() === year) : defaultValue && defaultValue.getFullYear() === year;
7
7
  };
8
8
  const getIsDisabled = ({ props }) => (year) => {
9
- return typeof props.disabledDate === "function" ? props.disabledDate(new Date(year, 0, 1, 0)) : false;
9
+ const MONTHS = Array.from({ length: 12 }, (_, i) => i);
10
+ return typeof props.disabledDate === "function" ? MONTHS.every(
11
+ (month) => props.disabledDate(new Date(year, month, 1))
12
+ ) : false;
10
13
  };
11
14
  const getIsCurrent = ({ props }) => (year) => {
12
15
  const execDate = typeof props.value === "object" ? props.value : toDate1(props.value);