@opentiny/vue-renderless 3.14.0 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/action-menu/index.js +44 -0
- package/action-menu/vue.js +25 -8
- package/calendar-view/index.js +21 -13
- package/calendar-view/vue.js +6 -3
- package/cascader/index.js +1 -1
- package/cascader-select/index.js +5 -0
- package/cascader-select/vue.js +3 -1
- package/common/bigInt.js +2 -2
- package/common/deps/date-util.js +4 -2
- package/common/deps/vue-popper.js +22 -2
- package/common/index.js +15 -2
- package/common/runtime.js +1 -1
- package/date-range/vue.js +1 -0
- package/date-table/index.js +30 -53
- package/date-table/vue.js +1 -1
- package/dept/index.js +8 -1
- package/dept/vue.js +10 -1
- package/dialog-box/index.js +12 -6
- package/dialog-box/vue.js +1 -1
- package/dropdown-item/mf.js +2 -2
- package/file-upload/index.js +0 -1
- package/grid/utils/dom.js +30 -10
- package/image/index.js +4 -0
- package/image/vue.js +6 -3
- package/image-viewer/vue.js +3 -1
- package/input/index.js +6 -1
- package/input/vue.js +9 -5
- package/modal/index.js +1 -1
- package/numeric/index.js +9 -20
- package/numeric/vue.js +3 -12
- package/option-group/index.js +13 -0
- package/option-group/vue.js +19 -6
- package/package.json +7 -7
- package/picker/index.js +218 -193
- package/picker/vue.js +7 -4
- package/popconfirm/index.js +6 -0
- package/popconfirm/vue.js +11 -3
- package/popeditor/index.js +2 -2
- package/popover/index.js +4 -1
- package/popover/vue.js +2 -1
- package/quarter-panel/index.js +61 -0
- package/quarter-panel/vue.js +46 -0
- package/select/index.js +111 -55
- package/select/vue.js +53 -19
- package/skeleton/vue.js +2 -2
- package/skeleton-item/vue.js +1 -1
- package/statistic/index.js +22 -0
- package/statistic/vue.js +20 -0
- package/tabs/index.js +16 -1
- package/tall-storage/index.js +1 -1
- package/time-picker-mobile/index.js +10 -1
- package/time-picker-mobile/vue.js +5 -3
- package/time-spinner/index.js +52 -1
- package/time-spinner/vue.js +4 -2
- package/timeline-item/index.js +14 -1
- package/timeline-item/vue.js +7 -4
- package/tree/index.js +8 -4
- package/tree/vue.js +3 -3
- package/tree-node/index.js +2 -2
- package/types/action-menu.type.d.ts +40 -12
- package/types/action-sheet.type.d.ts +2 -2
- package/types/alert.type.d.ts +1 -1
- package/types/checkbox.type.d.ts +3 -3
- package/types/collapse.type.d.ts +1 -1
- package/types/date-table.type.d.ts +13 -0
- package/types/dialog-box.type.d.ts +1 -1
- package/types/drawer.type.d.ts +1 -1
- package/types/{dropdown-item.type-8475a549.d.ts → dropdown-item.type-678794c9.d.ts} +4 -0
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-222799ae.d.ts → form.type-8e30b25c.d.ts} +2 -1
- package/types/form.type.d.ts +1 -1
- package/types/image.type.d.ts +4 -0
- package/types/input.type.d.ts +3 -1
- package/types/milestone.type.d.ts +1 -1
- package/types/numeric.type.d.ts +4 -5
- package/types/pager.type.d.ts +1 -1
- package/types/popconfirm.type.d.ts +8 -0
- package/types/popeditor.type.d.ts +1 -1
- package/types/popover.type.d.ts +3 -3
- package/types/progress.type.d.ts +1 -1
- package/types/skeleton.type.d.ts +1 -1
- package/types/statistic.type.d.ts +56 -0
- package/types/steps.type.d.ts +1 -1
- package/types/switch.type.d.ts +3 -3
- package/types/tag.type.d.ts +4 -1
- package/types/{time-line.type-b155cb4f.d.ts → time-line.type-1b501c41.d.ts} +7 -0
- package/types/time-line.type.d.ts +1 -1
- package/types/timeline-item.type.d.ts +1 -1
- package/types/transfer.type.d.ts +3 -3
- package/types/upload-dragger.type.d.ts +2 -2
- package/types/{upload-list.type-a29aea50.d.ts → upload-list.type-f34997c8.d.ts} +9 -5
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/user/index.js +1 -1
- package/credit-card/index.js +0 -93
- package/credit-card/vue.js +0 -62
- package/credit-card-form/index.js +0 -112
- package/credit-card-form/vue.js +0 -119
- package/detail-page/index.js +0 -79
- package/detail-page/vue.js +0 -78
- package/slide-bar/index.js +0 -67
- package/slide-bar/vue.js +0 -32
package/picker/index.js
CHANGED
|
@@ -8,10 +8,18 @@ import userPopper from "../common/deps/vue-popper";
|
|
|
8
8
|
import { DATEPICKER } from "../common";
|
|
9
9
|
import { formatDate, parseDate, isDateObject, getWeekNumber, prevDate, nextDate } from "../common/deps/date-util";
|
|
10
10
|
import { extend } from "../common/object";
|
|
11
|
-
import { isFunction } from "../common/type";
|
|
12
11
|
import globalTimezone from "./timezone";
|
|
13
12
|
const iso8601Reg = /^\d{4}-\d{2}-\d{2}(.)\d{2}:\d{2}:\d{2}(.+)$/;
|
|
14
|
-
const getPanel = ({
|
|
13
|
+
const getPanel = ({
|
|
14
|
+
DatePanel,
|
|
15
|
+
DateRangePanel,
|
|
16
|
+
MonthRangePanel,
|
|
17
|
+
YearRangePanel,
|
|
18
|
+
TimePanel,
|
|
19
|
+
TimeRangePanel,
|
|
20
|
+
QuarterPanel,
|
|
21
|
+
TimeSelect
|
|
22
|
+
}) => (type) => {
|
|
15
23
|
if (type === DATEPICKER.DateRange || type === DATEPICKER.DateTimeRange) {
|
|
16
24
|
return DateRangePanel;
|
|
17
25
|
} else if (type === DATEPICKER.MonthRange) {
|
|
@@ -24,10 +32,21 @@ const getPanel = ({ DatePanel, DateRangePanel, MonthRangePanel, YearRangePanel,
|
|
|
24
32
|
return TimePanel;
|
|
25
33
|
} else if (type === DATEPICKER.TimeSelect) {
|
|
26
34
|
return TimeSelect;
|
|
35
|
+
} else if (type === DATEPICKER.Quarter) {
|
|
36
|
+
return QuarterPanel;
|
|
27
37
|
}
|
|
28
38
|
return DatePanel;
|
|
29
39
|
};
|
|
30
|
-
const
|
|
40
|
+
const watchMobileVisible = ({ api, props, state, nextTick }) => ([dateMobileVisible, timeMobileVisible]) => {
|
|
41
|
+
if (dateMobileVisible || timeMobileVisible) {
|
|
42
|
+
state.valueOnOpen = Array.isArray(props.modelValue) ? [...props.modelValue] : props.modelValue;
|
|
43
|
+
} else {
|
|
44
|
+
nextTick(() => {
|
|
45
|
+
api.emitChange(props.modelValue);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const watchPickerVisible = ({ api, vm, dispatch, emit, props, state, nextTick }) => (value) => {
|
|
31
50
|
if (props.readonly || state.pickerDisabled || state.isMobileScreen)
|
|
32
51
|
return;
|
|
33
52
|
if (value) {
|
|
@@ -35,7 +54,9 @@ const watchPickerVisible = ({ api, vm, dispatch, emit, props, state }) => (value
|
|
|
35
54
|
state.valueOnOpen = Array.isArray(props.modelValue) ? [...props.modelValue] : props.modelValue;
|
|
36
55
|
} else {
|
|
37
56
|
api.hidePicker();
|
|
38
|
-
|
|
57
|
+
nextTick(() => {
|
|
58
|
+
api.emitChange(props.modelValue);
|
|
59
|
+
});
|
|
39
60
|
state.userInput = null;
|
|
40
61
|
if (props.validateEvent) {
|
|
41
62
|
dispatch("FormItem", "form.blur");
|
|
@@ -85,13 +106,7 @@ const displayValue = ({ api, props, state }) => () => {
|
|
|
85
106
|
const formatObj = {
|
|
86
107
|
rangeSeparator: props.rangeSeparator
|
|
87
108
|
};
|
|
88
|
-
const formattedValue = api.formatAsFormatAndType(
|
|
89
|
-
state.parsedValue,
|
|
90
|
-
state.format,
|
|
91
|
-
state.type,
|
|
92
|
-
props.rangeSeparator,
|
|
93
|
-
formatObj
|
|
94
|
-
);
|
|
109
|
+
const formattedValue = api.formatAsFormatAndType(state.parsedValue, state.format, state.type, formatObj);
|
|
95
110
|
if (Array.isArray(state.userInput)) {
|
|
96
111
|
return [
|
|
97
112
|
state.userInput[0] || formattedValue && formattedValue[0] || "",
|
|
@@ -128,9 +143,13 @@ const parsedValue = ({ api, props, state, t }) => () => {
|
|
|
128
143
|
let date = props.modelValue;
|
|
129
144
|
if (isServiceTimezone) {
|
|
130
145
|
if (Array.isArray(date)) {
|
|
131
|
-
date = [].concat(date).map((item) =>
|
|
146
|
+
date = [].concat(date).map((item) => {
|
|
147
|
+
return isDate(item) ? formatDate(item, state.valueFormat, t) : item;
|
|
148
|
+
});
|
|
132
149
|
} else {
|
|
133
|
-
|
|
150
|
+
if (state.valueFormat !== DATEPICKER.TimesTamp) {
|
|
151
|
+
date = formatDate(date, state.valueFormat, t);
|
|
152
|
+
}
|
|
134
153
|
}
|
|
135
154
|
}
|
|
136
155
|
const result = api.parseAsFormatAndType(date, state.valueFormat, state.type, props.rangeSeparator);
|
|
@@ -311,7 +330,11 @@ const typeValueResolveMap = ({ api, props, t }) => () => ({
|
|
|
311
330
|
years: getDatesOfTypeValueResolveMap(api),
|
|
312
331
|
yearrange: getDatesOfTypeValueResolveMap(api),
|
|
313
332
|
number: getNumberOfTypeValueResolveMap(),
|
|
314
|
-
dates: getDatesOfTypeValueResolveMap(api)
|
|
333
|
+
dates: getDatesOfTypeValueResolveMap(api),
|
|
334
|
+
quarter: {
|
|
335
|
+
formatter: (value) => `${value.getFullYear()}-Q${DATEPICKER.MonthQuarterMap[value.getMonth()]}`,
|
|
336
|
+
parser: api.dateParser
|
|
337
|
+
}
|
|
315
338
|
});
|
|
316
339
|
const firstInputId = ({ props, state }) => () => {
|
|
317
340
|
const obj = {};
|
|
@@ -371,6 +394,161 @@ const handleMouseEnter = ({ props, state }) => () => {
|
|
|
371
394
|
state.showClose = true;
|
|
372
395
|
}
|
|
373
396
|
};
|
|
397
|
+
const handleInput = ({ state, props, api }) => (val, event) => {
|
|
398
|
+
event = val.target ? val : event;
|
|
399
|
+
if (props.autoFormat) {
|
|
400
|
+
const value = api.formatInputValue({ event, prevValue: state.displayValue });
|
|
401
|
+
state.userInput = value;
|
|
402
|
+
} else {
|
|
403
|
+
const val2 = event.target.value;
|
|
404
|
+
state.userInput = val2;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
const formatInputValue = ({ props, state }) => ({ event, prevValue = "" }) => {
|
|
408
|
+
const val = event.target.value;
|
|
409
|
+
const inputData = event.data;
|
|
410
|
+
const format = state.type === "time-select" ? "HH:mm" : props.format || DATEPICKER.DateFormats[state.type];
|
|
411
|
+
if (inputData && inputData.charCodeAt() >= 48 && inputData.charCodeAt() <= 57) {
|
|
412
|
+
return formatText({ event, format, text: prevValue, needSelectionStart: true });
|
|
413
|
+
} else {
|
|
414
|
+
return val;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const getSelectionStart = ({ value, format, regx, event }) => {
|
|
418
|
+
const formatMatchArr = format.match(regx);
|
|
419
|
+
let selectionStart = getSelectionStartIndex(event);
|
|
420
|
+
let I = 0;
|
|
421
|
+
if (value !== "") {
|
|
422
|
+
const match = value.match(/[0-9]/g);
|
|
423
|
+
I = match === null ? 0 : match.length;
|
|
424
|
+
for (let i = 0; i < formatMatchArr.length; i++) {
|
|
425
|
+
I -= Math.max(formatMatchArr[i].length, 2);
|
|
426
|
+
}
|
|
427
|
+
I = I >= 0 ? 1 : 0;
|
|
428
|
+
I === 1 && selectionStart >= value.length && (selectionStart = value.length - 1);
|
|
429
|
+
}
|
|
430
|
+
return { selectionStart, I };
|
|
431
|
+
};
|
|
432
|
+
const getNum = (value, format, regx) => {
|
|
433
|
+
let len = value.length;
|
|
434
|
+
if (format && regx) {
|
|
435
|
+
const formatMatchArr = format.match(regx);
|
|
436
|
+
len = Math.max(len, formatMatchArr.join("").length);
|
|
437
|
+
}
|
|
438
|
+
let num = { str: "", arr: [] };
|
|
439
|
+
for (let i = 0; i < len; i++) {
|
|
440
|
+
let char = value.charAt(i) ? value.charAt(i) : "00";
|
|
441
|
+
if (/[0-9]/.test(char)) {
|
|
442
|
+
num.str += char;
|
|
443
|
+
} else {
|
|
444
|
+
num.arr[i] = 1;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return num;
|
|
448
|
+
};
|
|
449
|
+
const getSelectionStartIndex = (event) => {
|
|
450
|
+
const inputElem = event.target;
|
|
451
|
+
return inputElem.selectionStart - (event.data ? event.data.length : 0);
|
|
452
|
+
};
|
|
453
|
+
const moveStart = (inputElem, moveStartIndex) => {
|
|
454
|
+
if (inputElem.setSelectionRange) {
|
|
455
|
+
inputElem.focus();
|
|
456
|
+
setTimeout(() => {
|
|
457
|
+
inputElem.setSelectionRange(moveStartIndex, moveStartIndex);
|
|
458
|
+
}, 0);
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
const formatText = ({ event, text, format, needSelectionStart = false }) => {
|
|
462
|
+
if (!format)
|
|
463
|
+
return text;
|
|
464
|
+
let cursorOffset = 0;
|
|
465
|
+
let value = "";
|
|
466
|
+
let regx = /yyyy|yyy|yy|y|MM|M|dd|d|HH|hh|H|h|mm|m|ss|s|WW|W|w/g;
|
|
467
|
+
let startIndex = 0;
|
|
468
|
+
let { numStr, selectionStart } = getNumAndSelectionStart({
|
|
469
|
+
value: text,
|
|
470
|
+
format,
|
|
471
|
+
regx,
|
|
472
|
+
event,
|
|
473
|
+
needSelectionStart
|
|
474
|
+
});
|
|
475
|
+
let matchResult = regx.exec(format);
|
|
476
|
+
while (numStr.str !== "" && matchResult !== null) {
|
|
477
|
+
let subStr;
|
|
478
|
+
let newNum;
|
|
479
|
+
let subLen;
|
|
480
|
+
const endIndex = matchResult.index;
|
|
481
|
+
if (startIndex >= 0) {
|
|
482
|
+
value += format.substring(startIndex, endIndex);
|
|
483
|
+
}
|
|
484
|
+
selectionStart >= startIndex + cursorOffset && selectionStart <= endIndex + cursorOffset && (selectionStart = selectionStart + endIndex - startIndex);
|
|
485
|
+
startIndex = regx.lastIndex;
|
|
486
|
+
subLen = startIndex - endIndex;
|
|
487
|
+
subStr = numStr.str.substring(0, subLen);
|
|
488
|
+
const firstMatchChar = matchResult[0].charAt(0);
|
|
489
|
+
const firstChar = parseInt(subStr.charAt(0), 10);
|
|
490
|
+
if (numStr.str.length > 1) {
|
|
491
|
+
const secondChar = numStr.str.charAt(1);
|
|
492
|
+
newNum = 10 * firstChar + parseInt(secondChar, 10);
|
|
493
|
+
} else {
|
|
494
|
+
newNum = firstChar;
|
|
495
|
+
}
|
|
496
|
+
if (numStr.arr[endIndex + 1] || firstMatchChar === "M" && newNum > 12 || firstMatchChar === "d" && newNum > 31 || ["H", "h"].includes(firstMatchChar) && newNum > 23 || "ms".includes(firstMatchChar) && newNum > 59) {
|
|
497
|
+
subStr = matchResult[0].length === 2 ? "0" + firstChar : firstChar;
|
|
498
|
+
selectionStart++;
|
|
499
|
+
} else {
|
|
500
|
+
if (subLen === 1) {
|
|
501
|
+
subStr = String(newNum);
|
|
502
|
+
subLen++;
|
|
503
|
+
cursorOffset++;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
value += subStr;
|
|
507
|
+
numStr.str = numStr.str.substring(subLen);
|
|
508
|
+
matchResult = regx.exec(format);
|
|
509
|
+
}
|
|
510
|
+
const { value: val, selectionStart: cursorPos } = checkFormat({
|
|
511
|
+
value,
|
|
512
|
+
format,
|
|
513
|
+
startIndex,
|
|
514
|
+
selectionStart,
|
|
515
|
+
regx,
|
|
516
|
+
needSelectionStart
|
|
517
|
+
});
|
|
518
|
+
value = val;
|
|
519
|
+
selectionStart = cursorPos;
|
|
520
|
+
needSelectionStart && moveStart(event.target, selectionStart);
|
|
521
|
+
return value;
|
|
522
|
+
};
|
|
523
|
+
const getNumAndSelectionStart = ({ value, format, regx, event, needSelectionStart }) => {
|
|
524
|
+
if (needSelectionStart) {
|
|
525
|
+
let { selectionStart, I } = getSelectionStart({ value, format, regx, event });
|
|
526
|
+
let valueStr;
|
|
527
|
+
if (event.data) {
|
|
528
|
+
valueStr = value.substring(0, selectionStart) + event.data + value.substring(selectionStart + I);
|
|
529
|
+
selectionStart++;
|
|
530
|
+
} else {
|
|
531
|
+
valueStr = value;
|
|
532
|
+
}
|
|
533
|
+
const numStr = getNum(valueStr);
|
|
534
|
+
return { numStr, selectionStart };
|
|
535
|
+
} else {
|
|
536
|
+
const numStr = getNum(value, format, regx);
|
|
537
|
+
return { numStr };
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
const checkFormat = ({ value, format, startIndex, selectionStart, regx, needSelectionStart }) => {
|
|
541
|
+
if (!needSelectionStart && regx.lastIndex === 0 || needSelectionStart && regx.lastIndex === 0 && selectionStart >= startIndex) {
|
|
542
|
+
const subFormat = `(?<=${format.substring(0, startIndex)})(\\s*\\S*\\s*)+`;
|
|
543
|
+
const pattern = new RegExp(subFormat, "g");
|
|
544
|
+
const res = format.match(pattern);
|
|
545
|
+
if (res) {
|
|
546
|
+
value += res[0];
|
|
547
|
+
selectionStart = value.length;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return { value, selectionStart };
|
|
551
|
+
};
|
|
374
552
|
const handleChange = ({ api, state }) => () => {
|
|
375
553
|
if (state.userInput) {
|
|
376
554
|
const value = api.parseString(state.displayValue);
|
|
@@ -556,13 +734,11 @@ const handleKeydown = ({ api, state }) => (event) => {
|
|
|
556
734
|
state.picker.handleKeydown(event);
|
|
557
735
|
}
|
|
558
736
|
};
|
|
559
|
-
const hidePicker = ({
|
|
737
|
+
const hidePicker = ({ destroyPopper, state }) => () => {
|
|
560
738
|
if (state.picker) {
|
|
561
739
|
state.picker.resetView && state.picker.resetView();
|
|
562
740
|
state.pickerVisible = state.picker.visible = state.picker.state.visible = false;
|
|
563
|
-
|
|
564
|
-
doDestroy();
|
|
565
|
-
}
|
|
741
|
+
destroyPopper();
|
|
566
742
|
}
|
|
567
743
|
};
|
|
568
744
|
const showPicker = ({ api, nextTick, updatePopper, state }) => () => {
|
|
@@ -594,23 +770,22 @@ const handleSelectRange = (state) => (start, end, pos) => {
|
|
|
594
770
|
return;
|
|
595
771
|
}
|
|
596
772
|
const adjust = (value, start2, end2) => {
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
end2 = hourLength + minuteLength + secondLength + 2;
|
|
773
|
+
if (value) {
|
|
774
|
+
const valueReg = /(\d+):(\d+):(\d+)(\s+.+)?/;
|
|
775
|
+
if (valueReg.test(value)) {
|
|
776
|
+
const matched = valueReg.exec(value);
|
|
777
|
+
const hourLength = matched[1].length;
|
|
778
|
+
const minuteLength = matched[2].length;
|
|
779
|
+
const secondLength = matched[3].length;
|
|
780
|
+
if (start2 === 0) {
|
|
781
|
+
end2 = hourLength;
|
|
782
|
+
} else if (start2 === 3) {
|
|
783
|
+
start2 = hourLength + 1;
|
|
784
|
+
end2 = hourLength + minuteLength + 1;
|
|
785
|
+
} else {
|
|
786
|
+
start2 = hourLength + minuteLength + 2;
|
|
787
|
+
end2 = hourLength + minuteLength + secondLength + 2;
|
|
788
|
+
}
|
|
614
789
|
}
|
|
615
790
|
}
|
|
616
791
|
return { start: start2, end: end2 };
|
|
@@ -771,8 +946,12 @@ const computedFormat = ({ props, utils }) => () => {
|
|
|
771
946
|
}
|
|
772
947
|
return format;
|
|
773
948
|
};
|
|
774
|
-
const computedTriggerClass = ({ props, state }) => () =>
|
|
775
|
-
|
|
949
|
+
const computedTriggerClass = ({ props, state }) => () => {
|
|
950
|
+
return props.suffixIcon || props.prefixIcon || (state.type.includes(DATEPICKER.Time) ? DATEPICKER.IconTime : DATEPICKER.IconDate);
|
|
951
|
+
};
|
|
952
|
+
const computedHaveTrigger = ({ props }) => () => {
|
|
953
|
+
return typeof props.showTrigger !== "undefined" ? props.showTrigger : DATEPICKER.TriggerTypes.includes(props.type);
|
|
954
|
+
};
|
|
776
955
|
const initPopper = ({ props, hooks, vnode }) => {
|
|
777
956
|
const { reactive, watch, toRefs, onBeforeUnmount, onDeactivated } = hooks;
|
|
778
957
|
const { emit, vm, slots, nextTick } = vnode;
|
|
@@ -782,7 +961,7 @@ const initPopper = ({ props, hooks, vnode }) => {
|
|
|
782
961
|
watch,
|
|
783
962
|
emit,
|
|
784
963
|
props: __spreadProps(__spreadValues({}, props), {
|
|
785
|
-
popperOptions: { boundariesPadding: 0, gpuAcceleration: false },
|
|
964
|
+
popperOptions: Object.assign({ boundariesPadding: 0, gpuAcceleration: false }, props.popperOptions),
|
|
786
965
|
visibleArrow: true,
|
|
787
966
|
offset: 0,
|
|
788
967
|
boundariesPadding: 5,
|
|
@@ -846,161 +1025,6 @@ const setInputPaddingLeft = ({ props, state, vm, nextTick }) => () => {
|
|
|
846
1025
|
});
|
|
847
1026
|
}
|
|
848
1027
|
};
|
|
849
|
-
const getSelectionStart = ({ value, format, regx, event }) => {
|
|
850
|
-
const formatMatchArr = format.match(regx);
|
|
851
|
-
let selectionStart = getSelectionStartIndex(event);
|
|
852
|
-
let I = 0;
|
|
853
|
-
if (value !== "") {
|
|
854
|
-
const match = value.match(/[0-9]/g);
|
|
855
|
-
I = match === null ? 0 : match.length;
|
|
856
|
-
for (let i = 0; i < formatMatchArr.length; i++) {
|
|
857
|
-
I -= Math.max(formatMatchArr[i].length, 2);
|
|
858
|
-
}
|
|
859
|
-
I = I >= 0 ? 1 : 0;
|
|
860
|
-
I === 1 && selectionStart >= value.length && (selectionStart = value.length - 1);
|
|
861
|
-
}
|
|
862
|
-
return { selectionStart, I };
|
|
863
|
-
};
|
|
864
|
-
const getNum = (value, format, regx) => {
|
|
865
|
-
let len = value.length;
|
|
866
|
-
if (format && regx) {
|
|
867
|
-
const formatMatchArr = format.match(regx);
|
|
868
|
-
len = Math.max(len, formatMatchArr.join("").length);
|
|
869
|
-
}
|
|
870
|
-
let num = { str: "", arr: [] };
|
|
871
|
-
for (let i = 0; i < len; i++) {
|
|
872
|
-
let char = value.charAt(i) ? value.charAt(i) : "00";
|
|
873
|
-
if (/[0-9]/.test(char)) {
|
|
874
|
-
num.str += char;
|
|
875
|
-
} else {
|
|
876
|
-
num.arr[i] = 1;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
return num;
|
|
880
|
-
};
|
|
881
|
-
const getSelectionStartIndex = (event) => {
|
|
882
|
-
const inputElem = event.target;
|
|
883
|
-
return inputElem.selectionStart - (event.data ? event.data.length : 0);
|
|
884
|
-
};
|
|
885
|
-
const getNumAndSelectionStart = ({ value, format, regx, event, needSelectionStart }) => {
|
|
886
|
-
if (needSelectionStart) {
|
|
887
|
-
let { selectionStart, I } = getSelectionStart({ value, format, regx, event });
|
|
888
|
-
let valueStr;
|
|
889
|
-
if (event.data) {
|
|
890
|
-
valueStr = value.substring(0, selectionStart) + event.data + value.substring(selectionStart + I);
|
|
891
|
-
selectionStart++;
|
|
892
|
-
} else {
|
|
893
|
-
valueStr = value;
|
|
894
|
-
}
|
|
895
|
-
const numStr = getNum(valueStr);
|
|
896
|
-
return { numStr, selectionStart };
|
|
897
|
-
} else {
|
|
898
|
-
const numStr = getNum(value, format, regx);
|
|
899
|
-
return { numStr };
|
|
900
|
-
}
|
|
901
|
-
};
|
|
902
|
-
const checkFormat = ({ value, format, startIndex, selectionStart, regx, needSelectionStart }) => {
|
|
903
|
-
if (!needSelectionStart && regx.lastIndex === 0 || needSelectionStart && regx.lastIndex === 0 && selectionStart >= startIndex) {
|
|
904
|
-
const subFormat = `(?<=${format.substring(0, startIndex)})(\\s*\\S*\\s*)+`;
|
|
905
|
-
const pattern = new RegExp(subFormat, "g");
|
|
906
|
-
const res = format.match(pattern);
|
|
907
|
-
if (res) {
|
|
908
|
-
value += res[0];
|
|
909
|
-
selectionStart = value.length;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
return { value, selectionStart };
|
|
913
|
-
};
|
|
914
|
-
const moveStart = (inputElem, moveStartIndex) => {
|
|
915
|
-
if (inputElem.setSelectionRange) {
|
|
916
|
-
inputElem.focus();
|
|
917
|
-
setTimeout(() => {
|
|
918
|
-
inputElem.setSelectionRange(moveStartIndex, moveStartIndex);
|
|
919
|
-
}, 0);
|
|
920
|
-
}
|
|
921
|
-
};
|
|
922
|
-
const handleInput = ({ state, props, api }) => (val, event) => {
|
|
923
|
-
event = val.target ? val : event;
|
|
924
|
-
if (props.autoFormat) {
|
|
925
|
-
const value = api.formatInputValue({ event, prevValue: state.displayValue });
|
|
926
|
-
state.userInput = value;
|
|
927
|
-
} else {
|
|
928
|
-
const val2 = event.target.value;
|
|
929
|
-
state.userInput = val2;
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
const formatInputValue = ({ props, state }) => ({ event, prevValue = "" }) => {
|
|
933
|
-
const val = event.target.value;
|
|
934
|
-
const inputData = event.data;
|
|
935
|
-
const format = state.type === "time-select" ? "HH:mm" : props.format || DATEPICKER.DateFormats[state.type];
|
|
936
|
-
if (inputData && inputData.charCodeAt() >= 48 && inputData.charCodeAt() <= 57) {
|
|
937
|
-
return formatText({ event, format, text: prevValue, needSelectionStart: true });
|
|
938
|
-
} else {
|
|
939
|
-
return val;
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
const formatText = ({ event, text, format, needSelectionStart = false }) => {
|
|
943
|
-
if (!format)
|
|
944
|
-
return text;
|
|
945
|
-
let cursorOffset = 0;
|
|
946
|
-
let value = "";
|
|
947
|
-
let regx = /yyyy|yyy|yy|y|MM|M|dd|d|HH|hh|H|h|mm|m|ss|s|WW|W|w/g;
|
|
948
|
-
let startIndex = 0;
|
|
949
|
-
let { numStr, selectionStart } = getNumAndSelectionStart({
|
|
950
|
-
value: text,
|
|
951
|
-
format,
|
|
952
|
-
regx,
|
|
953
|
-
event,
|
|
954
|
-
needSelectionStart
|
|
955
|
-
});
|
|
956
|
-
let matchResult = regx.exec(format);
|
|
957
|
-
while (numStr.str !== "" && matchResult !== null) {
|
|
958
|
-
let subStr;
|
|
959
|
-
let newNum;
|
|
960
|
-
let subLen;
|
|
961
|
-
const endIndex = matchResult.index;
|
|
962
|
-
if (startIndex >= 0) {
|
|
963
|
-
value += format.substring(startIndex, endIndex);
|
|
964
|
-
}
|
|
965
|
-
selectionStart >= startIndex + cursorOffset && selectionStart <= endIndex + cursorOffset && (selectionStart = selectionStart + endIndex - startIndex);
|
|
966
|
-
startIndex = regx.lastIndex;
|
|
967
|
-
subLen = startIndex - endIndex;
|
|
968
|
-
subStr = numStr.str.substring(0, subLen);
|
|
969
|
-
const firstMatchChar = matchResult[0].charAt(0);
|
|
970
|
-
const firstChar = parseInt(subStr.charAt(0), 10);
|
|
971
|
-
if (numStr.str.length > 1) {
|
|
972
|
-
const secondChar = numStr.str.charAt(1);
|
|
973
|
-
newNum = 10 * firstChar + parseInt(secondChar, 10);
|
|
974
|
-
} else {
|
|
975
|
-
newNum = firstChar;
|
|
976
|
-
}
|
|
977
|
-
if (numStr.arr[endIndex + 1] || firstMatchChar === "M" && newNum > 12 || firstMatchChar === "d" && newNum > 31 || ["H", "h"].includes(firstMatchChar) && newNum > 23 || "ms".includes(firstMatchChar) && newNum > 59) {
|
|
978
|
-
subStr = matchResult[0].length === 2 ? "0" + firstChar : firstChar;
|
|
979
|
-
selectionStart++;
|
|
980
|
-
} else {
|
|
981
|
-
if (subLen === 1) {
|
|
982
|
-
subStr = String(newNum);
|
|
983
|
-
subLen++;
|
|
984
|
-
cursorOffset++;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
value += subStr;
|
|
988
|
-
numStr.str = numStr.str.substring(subLen);
|
|
989
|
-
matchResult = regx.exec(format);
|
|
990
|
-
}
|
|
991
|
-
const { value: val, selectionStart: cursorPos } = checkFormat({
|
|
992
|
-
value,
|
|
993
|
-
format,
|
|
994
|
-
startIndex,
|
|
995
|
-
selectionStart,
|
|
996
|
-
regx,
|
|
997
|
-
needSelectionStart
|
|
998
|
-
});
|
|
999
|
-
value = val;
|
|
1000
|
-
selectionStart = cursorPos;
|
|
1001
|
-
needSelectionStart && moveStart(event.target, selectionStart);
|
|
1002
|
-
return value;
|
|
1003
|
-
};
|
|
1004
1028
|
export {
|
|
1005
1029
|
blur,
|
|
1006
1030
|
computedFormat,
|
|
@@ -1059,6 +1083,7 @@ export {
|
|
|
1059
1083
|
updateOptions,
|
|
1060
1084
|
valueEquals,
|
|
1061
1085
|
watchIsRange,
|
|
1086
|
+
watchMobileVisible,
|
|
1062
1087
|
watchModelValue,
|
|
1063
1088
|
watchPickerVisible
|
|
1064
1089
|
};
|
package/picker/vue.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
watchIsRange,
|
|
6
6
|
parseAsFormatAndType,
|
|
7
7
|
watchPickerVisible,
|
|
8
|
+
watchMobileVisible,
|
|
8
9
|
getValueEmpty,
|
|
9
10
|
getMode,
|
|
10
11
|
displayValue,
|
|
@@ -155,13 +156,13 @@ const initState = ({ api: api2, reactive, vm, computed, props, utils, parent, br
|
|
|
155
156
|
const initApi = ({ api: api2, props, hooks, state, vnode, others, utils, parent }) => {
|
|
156
157
|
const { t, emit, dispatch, nextTick, vm } = vnode;
|
|
157
158
|
const { TimePanel, TimeRangePanel } = others;
|
|
158
|
-
const { destroyPopper, popperElm, updatePopper
|
|
159
|
+
const { destroyPopper, popperElm, updatePopper } = initPopper({ props, hooks, vnode });
|
|
159
160
|
state.popperElm = popperElm;
|
|
160
161
|
state.picker = null;
|
|
161
162
|
Object.assign(api2, {
|
|
162
163
|
destroyPopper,
|
|
163
164
|
emitDbTime: emitDbTime({ emit, state, t }),
|
|
164
|
-
hidePicker: hidePicker({
|
|
165
|
+
hidePicker: hidePicker({ destroyPopper, state }),
|
|
165
166
|
handleSelectChange: ({ tz, date }) => !state.ranged && emit("select-change", { tz, date }),
|
|
166
167
|
getPanel: getPanel(others),
|
|
167
168
|
handleFocus: handleFocus({ emit, vm, state, api: api2 }),
|
|
@@ -187,7 +188,8 @@ const initApi = ({ api: api2, props, hooks, state, vnode, others, utils, parent
|
|
|
187
188
|
handleClose: handleClose({ api: api2, props, state }),
|
|
188
189
|
displayValue: displayValue({ api: api2, props, state }),
|
|
189
190
|
handlePick: handlePick({ api: api2, state }),
|
|
190
|
-
watchPickerVisible: watchPickerVisible({ api: api2, vm, dispatch, emit, props, state }),
|
|
191
|
+
watchPickerVisible: watchPickerVisible({ api: api2, vm, dispatch, emit, props, state, nextTick }),
|
|
192
|
+
watchMobileVisible: watchMobileVisible({ api: api2, props, state, nextTick }),
|
|
191
193
|
formatToString: formatToString({ api: api2, state }),
|
|
192
194
|
watchIsRange: watchIsRange({ api: api2, state, TimePanel, TimeRangePanel }),
|
|
193
195
|
mountPicker: mountPicker({ api: api2, vm, props, state, updatePopper }),
|
|
@@ -196,7 +198,7 @@ const initApi = ({ api: api2, props, hooks, state, vnode, others, utils, parent
|
|
|
196
198
|
computedTriggerClass: computedTriggerClass({ props, state }),
|
|
197
199
|
computedHaveTrigger: computedHaveTrigger({ props }),
|
|
198
200
|
setInputPaddingLeft: setInputPaddingLeft({ props, state, vm, nextTick }),
|
|
199
|
-
formatInputValue: formatInputValue({ props, state
|
|
201
|
+
formatInputValue: formatInputValue({ props, state })
|
|
200
202
|
});
|
|
201
203
|
initApi2({ api: api2, props, state, t, parent });
|
|
202
204
|
initMobileApi({ api: api2, props, state, t, parent });
|
|
@@ -240,6 +242,7 @@ const initWatch = ({ api: api2, state, props, watch, markRaw }) => {
|
|
|
240
242
|
(type) => state.panel = markRaw(api2.getPanel(type)),
|
|
241
243
|
{ immediate: true }
|
|
242
244
|
);
|
|
245
|
+
watch(() => [state.dateMobileOption.visible, state.timeMobileOption.visible], api2.watchMobileVisible);
|
|
243
246
|
watch(() => state.pickerVisible, api2.watchPickerVisible);
|
|
244
247
|
watch(
|
|
245
248
|
() => props.defaultValue,
|
package/popconfirm/index.js
CHANGED
|
@@ -24,8 +24,14 @@ const handleEmit = ({ state, emit, vm }) => (type) => {
|
|
|
24
24
|
emit(type, state);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
const handleDocumentClick = ({ vm, api }) => (event) => {
|
|
28
|
+
if (vm.$refs.popover.handleDocumentClick(event)) {
|
|
29
|
+
api.hide();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
27
32
|
export {
|
|
28
33
|
confirm,
|
|
34
|
+
handleDocumentClick,
|
|
29
35
|
handleEmit,
|
|
30
36
|
hide,
|
|
31
37
|
show
|
package/popconfirm/vue.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "../chunk-G2ADBYYC.js";
|
|
2
|
-
import {
|
|
2
|
+
import { on, off } from "../common/deps/dom";
|
|
3
|
+
import { show, hide, confirm, handleEmit, handleDocumentClick } from "./index";
|
|
3
4
|
const api = ["state", "show", "hide", "confirm", "handleEmit"];
|
|
4
|
-
const renderless = (props, { computed, reactive }, { emit, constants, designConfig, vm }) => {
|
|
5
|
+
const renderless = (props, { computed, reactive, onMounted, onBeforeUnmount }, { emit, constants, designConfig, vm }) => {
|
|
5
6
|
var _a;
|
|
6
7
|
const api2 = {};
|
|
7
8
|
const designIcon = (_a = designConfig == null ? void 0 : designConfig.icons) == null ? void 0 : _a[props.type];
|
|
@@ -17,7 +18,14 @@ const renderless = (props, { computed, reactive }, { emit, constants, designConf
|
|
|
17
18
|
show: show({ state, emit, props }),
|
|
18
19
|
hide: hide({ state, emit }),
|
|
19
20
|
confirm: confirm({ state, api: api2 }),
|
|
20
|
-
handleEmit: handleEmit({ state, emit, vm })
|
|
21
|
+
handleEmit: handleEmit({ state, emit, vm }),
|
|
22
|
+
handleDocumentClick: handleDocumentClick({ api: api2, vm })
|
|
23
|
+
});
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
props.closeOnClickOutside && on(document, "click", api2.handleDocumentClick);
|
|
26
|
+
});
|
|
27
|
+
onBeforeUnmount(() => {
|
|
28
|
+
props.closeOnClickOutside && off(document, "click", api2.handleDocumentClick);
|
|
21
29
|
});
|
|
22
30
|
return api2;
|
|
23
31
|
};
|
package/popeditor/index.js
CHANGED
|
@@ -570,7 +570,7 @@ const doSuggesst = ({ state, props, popper, api, nextTick }) => (event) => {
|
|
|
570
570
|
const row = find(state.selectedDatas, (node) => text === node[props.textField]);
|
|
571
571
|
api.sourceGridSelectChange({ checked: false, row, confirm: false });
|
|
572
572
|
});
|
|
573
|
-
if (addtions.length) {
|
|
573
|
+
if (!state.suggestList.length || addtions.length) {
|
|
574
574
|
doQuery(query2);
|
|
575
575
|
}
|
|
576
576
|
} else {
|
|
@@ -582,7 +582,7 @@ const closeSuggestPanel = ({ state, api, vm }) => (event = false) => {
|
|
|
582
582
|
const reference = vm.$refs.reference;
|
|
583
583
|
const popper = vm.$refs.popper;
|
|
584
584
|
let keep = !event;
|
|
585
|
-
if (event.target) {
|
|
585
|
+
if (event.target && reference) {
|
|
586
586
|
keep = reference.$el.contains(event.target) || popper.contains(event.target);
|
|
587
587
|
}
|
|
588
588
|
if (!keep) {
|
package/popover/index.js
CHANGED
|
@@ -127,7 +127,10 @@ const handleDocumentClick = ({ vm, state }) => (event) => {
|
|
|
127
127
|
target = state.webCompEventTarget;
|
|
128
128
|
}
|
|
129
129
|
if (!$el || !reference || $el.contains(target) || reference.contains(target) || !popperElm || popperElm.contains(target)) {
|
|
130
|
-
return;
|
|
130
|
+
return false;
|
|
131
|
+
} else {
|
|
132
|
+
state.showPopper = false;
|
|
133
|
+
return true;
|
|
131
134
|
}
|
|
132
135
|
state.showPopper = false;
|
|
133
136
|
};
|