@v-c/picker 1.0.0 → 1.0.1
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/package.json +9 -9
- package/dist/PickerInput/Popup/Footer.cjs +0 -115
- package/dist/PickerInput/Popup/PopupPanel.cjs +0 -413
- package/dist/PickerInput/Popup/PresetPanel.cjs +0 -54
- package/dist/PickerInput/Popup/index.cjs +0 -526
- package/dist/PickerInput/RangePicker.cjs +0 -1911
- package/dist/PickerInput/Selector/Icon.cjs +0 -89
- package/dist/PickerInput/Selector/Input.cjs +0 -376
- package/dist/PickerInput/Selector/MaskFormat.cjs +0 -72
- package/dist/PickerInput/Selector/RangeSelector.cjs +0 -1393
- package/dist/PickerInput/Selector/SingleSelector/MultipleDates.cjs +0 -110
- package/dist/PickerInput/Selector/SingleSelector/index.cjs +0 -1361
- package/dist/PickerInput/Selector/hooks/useClearIcon.cjs +0 -17
- package/dist/PickerInput/Selector/hooks/useInputHooks.cjs +0 -125
- package/dist/PickerInput/Selector/hooks/useRootProps.cjs +0 -14
- package/dist/PickerInput/Selector/util.cjs +0 -32
- package/dist/PickerInput/SinglePicker.cjs +0 -1881
- package/dist/PickerInput/context.cjs +0 -12
- package/dist/PickerInput/hooks/useCellRender.cjs +0 -25
- package/dist/PickerInput/hooks/useDelayState.cjs +0 -37
- package/dist/PickerInput/hooks/useDisabledBoundary.cjs +0 -15
- package/dist/PickerInput/hooks/useFieldFormat.cjs +0 -17
- package/dist/PickerInput/hooks/useFieldsInvalidate.cjs +0 -24
- package/dist/PickerInput/hooks/useFilledProps.cjs +0 -103
- package/dist/PickerInput/hooks/useInputReadOnly.cjs +0 -13
- package/dist/PickerInput/hooks/useInvalidate.cjs +0 -34
- package/dist/PickerInput/hooks/useLockEffect.cjs +0 -16
- package/dist/PickerInput/hooks/useOpen.cjs +0 -15
- package/dist/PickerInput/hooks/usePresets.cjs +0 -21
- package/dist/PickerInput/hooks/useRangeActive.cjs +0 -57
- package/dist/PickerInput/hooks/useRangeDisabledDate.cjs +0 -21
- package/dist/PickerInput/hooks/useRangePickerValue.cjs +0 -100
- package/dist/PickerInput/hooks/useRangeValue.cjs +0 -135
- package/dist/PickerInput/hooks/useShowNow.cjs +0 -15
- package/dist/PickerPanel/DatePanel/index.cjs +0 -294
- package/dist/PickerPanel/DateTimePanel/index.cjs +0 -180
- package/dist/PickerPanel/DecadePanel/index.cjs +0 -230
- package/dist/PickerPanel/MonthPanel/index.cjs +0 -219
- package/dist/PickerPanel/PanelBody.cjs +0 -157
- package/dist/PickerPanel/PanelHeader.cjs +0 -132
- package/dist/PickerPanel/QuarterPanel/index.cjs +0 -211
- package/dist/PickerPanel/TimePanel/TimePanelBody/TimeColumn.cjs +0 -145
- package/dist/PickerPanel/TimePanel/TimePanelBody/index.cjs +0 -286
- package/dist/PickerPanel/TimePanel/TimePanelBody/useScrollTo.cjs +0 -65
- package/dist/PickerPanel/TimePanel/index.cjs +0 -173
- package/dist/PickerPanel/WeekPanel/index.cjs +0 -179
- package/dist/PickerPanel/YearPanel/index.cjs +0 -239
- package/dist/PickerPanel/context.cjs +0 -61
- package/dist/PickerPanel/index.cjs +0 -473
- package/dist/PickerTrigger/index.cjs +0 -139
- package/dist/PickerTrigger/util.cjs +0 -13
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/generate/dateFns.cjs +0 -80
- package/dist/generate/dayjs.cjs +0 -117
- package/dist/generate/index.cjs +0 -1
- package/dist/generate/luxon.cjs +0 -75
- package/dist/generate/moment.cjs +0 -107
- package/dist/hooks/useLocale.cjs +0 -45
- package/dist/hooks/useSemantic.cjs +0 -18
- package/dist/hooks/useSyncState.cjs +0 -29
- package/dist/hooks/useTimeConfig.cjs +0 -161
- package/dist/hooks/useTimeInfo.cjs +0 -114
- package/dist/hooks/useToggleDates.cjs +0 -16
- package/dist/index.cjs +0 -12
- package/dist/interface.cjs +0 -1
- package/dist/locale/am_ET.cjs +0 -34
- package/dist/locale/ar_EG.cjs +0 -32
- package/dist/locale/az_AZ.cjs +0 -33
- package/dist/locale/bg_BG.cjs +0 -32
- package/dist/locale/bn_BD.cjs +0 -33
- package/dist/locale/by_BY.cjs +0 -33
- package/dist/locale/ca_ES.cjs +0 -32
- package/dist/locale/common.cjs +0 -8
- package/dist/locale/cs_CZ.cjs +0 -32
- package/dist/locale/da_DK.cjs +0 -32
- package/dist/locale/de_DE.cjs +0 -32
- package/dist/locale/el_GR.cjs +0 -32
- package/dist/locale/en_GB.cjs +0 -32
- package/dist/locale/en_US.cjs +0 -33
- package/dist/locale/es_ES.cjs +0 -32
- package/dist/locale/es_MX.cjs +0 -33
- package/dist/locale/et_EE.cjs +0 -32
- package/dist/locale/eu_ES.cjs +0 -34
- package/dist/locale/fa_IR.cjs +0 -32
- package/dist/locale/fi_FI.cjs +0 -32
- package/dist/locale/fr_BE.cjs +0 -32
- package/dist/locale/fr_CA.cjs +0 -33
- package/dist/locale/fr_FR.cjs +0 -33
- package/dist/locale/ga_IE.cjs +0 -33
- package/dist/locale/gl_ES.cjs +0 -32
- package/dist/locale/he_IL.cjs +0 -33
- package/dist/locale/hi_IN.cjs +0 -33
- package/dist/locale/hr_HR.cjs +0 -33
- package/dist/locale/hu_HU.cjs +0 -33
- package/dist/locale/id_ID.cjs +0 -33
- package/dist/locale/is_IS.cjs +0 -32
- package/dist/locale/it_IT.cjs +0 -55
- package/dist/locale/ja_JP.cjs +0 -35
- package/dist/locale/ka_GE.cjs +0 -33
- package/dist/locale/kk_KZ.cjs +0 -32
- package/dist/locale/km_KH.cjs +0 -34
- package/dist/locale/kmr_IQ.cjs +0 -32
- package/dist/locale/kn_IN.cjs +0 -33
- package/dist/locale/ko_KR.cjs +0 -34
- package/dist/locale/lt_LT.cjs +0 -34
- package/dist/locale/lv_LV.cjs +0 -32
- package/dist/locale/mk_MK.cjs +0 -32
- package/dist/locale/ml_IN.cjs +0 -33
- package/dist/locale/mn_MN.cjs +0 -34
- package/dist/locale/mr_IN.cjs +0 -59
- package/dist/locale/ms_MY.cjs +0 -34
- package/dist/locale/my_MM.cjs +0 -33
- package/dist/locale/nb_NO.cjs +0 -34
- package/dist/locale/ne_NP.cjs +0 -33
- package/dist/locale/nl_BE.cjs +0 -32
- package/dist/locale/nl_NL.cjs +0 -32
- package/dist/locale/pl_PL.cjs +0 -32
- package/dist/locale/pt_BR.cjs +0 -56
- package/dist/locale/pt_PT.cjs +0 -55
- package/dist/locale/ro_RO.cjs +0 -33
- package/dist/locale/ru_RU.cjs +0 -32
- package/dist/locale/si_LK.cjs +0 -34
- package/dist/locale/sk_SK.cjs +0 -32
- package/dist/locale/sl_SI.cjs +0 -32
- package/dist/locale/sr_Cyrl_RS.cjs +0 -32
- package/dist/locale/sr_RS.cjs +0 -32
- package/dist/locale/sv_SE.cjs +0 -32
- package/dist/locale/ta_IN.cjs +0 -33
- package/dist/locale/te_IN.cjs +0 -33
- package/dist/locale/th_TH.cjs +0 -32
- package/dist/locale/tk_TK.cjs +0 -32
- package/dist/locale/tr_TR.cjs +0 -55
- package/dist/locale/ug_CN.cjs +0 -35
- package/dist/locale/uk_UA.cjs +0 -32
- package/dist/locale/ur_PK.cjs +0 -33
- package/dist/locale/uz_UZ.cjs +0 -33
- package/dist/locale/vi_VN.cjs +0 -33
- package/dist/locale/zh_CN.cjs +0 -36
- package/dist/locale/zh_TW.cjs +0 -36
- package/dist/utils/dateUtil.cjs +0 -105
- package/dist/utils/getClearIcon.cjs +0 -7
- package/dist/utils/miscUtil.cjs +0 -46
- package/dist/utils/uiUtil.cjs +0 -6
- package/dist/utils/warnUtil.cjs +0 -8
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_context = require("../context.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
let _v_c_util = require("@v-c/util");
|
|
9
|
-
var Icon = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
10
|
-
const ctx = require_context.usePickerContext();
|
|
11
|
-
return () => {
|
|
12
|
-
const { icon, type } = props;
|
|
13
|
-
if (!icon) return null;
|
|
14
|
-
const { prefixCls, classNames, styles } = ctx.value;
|
|
15
|
-
const { class: attrClass, style: attrStyle, ...restAttrs } = attrs;
|
|
16
|
-
const mergedAttrStyle = attrStyle && typeof attrStyle === "object" ? attrStyle : {};
|
|
17
|
-
return (0, vue.createVNode)("span", (0, vue.mergeProps)(restAttrs, {
|
|
18
|
-
"class": (0, _v_c_util.clsx)(`${prefixCls}-${type}`, classNames.suffix, attrClass),
|
|
19
|
-
"style": {
|
|
20
|
-
...styles.suffix || {},
|
|
21
|
-
...mergedAttrStyle
|
|
22
|
-
}
|
|
23
|
-
}), [icon]);
|
|
24
|
-
};
|
|
25
|
-
}, {
|
|
26
|
-
props: {
|
|
27
|
-
icon: {
|
|
28
|
-
type: [
|
|
29
|
-
Object,
|
|
30
|
-
Function,
|
|
31
|
-
String,
|
|
32
|
-
Number,
|
|
33
|
-
null,
|
|
34
|
-
Boolean,
|
|
35
|
-
Array
|
|
36
|
-
],
|
|
37
|
-
required: false,
|
|
38
|
-
default: void 0
|
|
39
|
-
},
|
|
40
|
-
type: {
|
|
41
|
-
type: String,
|
|
42
|
-
required: true,
|
|
43
|
-
default: void 0
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
name: "Icon",
|
|
47
|
-
inheritAttrs: false
|
|
48
|
-
});
|
|
49
|
-
var Icon_default = Icon;
|
|
50
|
-
const ClearIcon = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
|
|
51
|
-
return () => {
|
|
52
|
-
return (0, vue.createVNode)(Icon, (0, vue.mergeProps)(attrs, {
|
|
53
|
-
"icon": props.icon,
|
|
54
|
-
"type": "clear",
|
|
55
|
-
"role": "button",
|
|
56
|
-
"onMousedown": (e) => {
|
|
57
|
-
e.preventDefault();
|
|
58
|
-
},
|
|
59
|
-
"onClick": (e) => {
|
|
60
|
-
e.stopPropagation();
|
|
61
|
-
props.onClear();
|
|
62
|
-
}
|
|
63
|
-
}), null);
|
|
64
|
-
};
|
|
65
|
-
}, {
|
|
66
|
-
props: {
|
|
67
|
-
onClear: {
|
|
68
|
-
required: true,
|
|
69
|
-
default: void 0
|
|
70
|
-
},
|
|
71
|
-
icon: {
|
|
72
|
-
type: [
|
|
73
|
-
Object,
|
|
74
|
-
Function,
|
|
75
|
-
String,
|
|
76
|
-
Number,
|
|
77
|
-
null,
|
|
78
|
-
Boolean,
|
|
79
|
-
Array
|
|
80
|
-
],
|
|
81
|
-
required: false,
|
|
82
|
-
default: void 0
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
name: "ClearIcon",
|
|
86
|
-
inheritAttrs: false
|
|
87
|
-
});
|
|
88
|
-
exports.ClearIcon = ClearIcon;
|
|
89
|
-
exports.default = Icon_default;
|
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_context = require("../context.cjs");
|
|
7
|
-
const require_miscUtil = require("../../utils/miscUtil.cjs");
|
|
8
|
-
const require_util = require("./util.cjs");
|
|
9
|
-
const require_useLockEffect = require("../hooks/useLockEffect.cjs");
|
|
10
|
-
const require_Icon = require("./Icon.cjs");
|
|
11
|
-
const require_MaskFormat = require("./MaskFormat.cjs");
|
|
12
|
-
let vue = require("vue");
|
|
13
|
-
let _v_c_util = require("@v-c/util");
|
|
14
|
-
var Input = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, expose }) => {
|
|
15
|
-
const pickerCtx = require_context.usePickerContext();
|
|
16
|
-
const prefixCls = (0, vue.computed)(() => pickerCtx.value.prefixCls);
|
|
17
|
-
const classNames = (0, vue.computed)(() => pickerCtx.value.classNames);
|
|
18
|
-
const styles = (0, vue.computed)(() => pickerCtx.value.styles);
|
|
19
|
-
const inputPrefixCls = (0, vue.computed)(() => `${prefixCls.value}-input`);
|
|
20
|
-
const focused = (0, vue.ref)(false);
|
|
21
|
-
const internalInputValue = (0, vue.ref)(props.value);
|
|
22
|
-
const focusCellText = (0, vue.ref)("");
|
|
23
|
-
const focusCellIndex = (0, vue.ref)(null);
|
|
24
|
-
const forceSelectionSyncMark = (0, vue.ref)(null);
|
|
25
|
-
const inputValue = (0, vue.computed)(() => internalInputValue.value || "");
|
|
26
|
-
(0, vue.watch)(() => props.value, (val) => {
|
|
27
|
-
internalInputValue.value = val;
|
|
28
|
-
});
|
|
29
|
-
const holderRef = (0, vue.ref)();
|
|
30
|
-
const inputRef = (0, vue.ref)();
|
|
31
|
-
expose({
|
|
32
|
-
get nativeElement() {
|
|
33
|
-
return holderRef.value;
|
|
34
|
-
},
|
|
35
|
-
get inputElement() {
|
|
36
|
-
return inputRef.value;
|
|
37
|
-
},
|
|
38
|
-
focus: (options) => {
|
|
39
|
-
inputRef.value?.focus(options);
|
|
40
|
-
},
|
|
41
|
-
blur: () => {
|
|
42
|
-
inputRef.value?.blur();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const maskFormat = (0, vue.computed)(() => new require_MaskFormat.default(props.format || ""));
|
|
46
|
-
const selectionRange = (0, vue.computed)(() => {
|
|
47
|
-
if (props.helped) return [0, 0];
|
|
48
|
-
return maskFormat.value.getSelection(focusCellIndex.value);
|
|
49
|
-
});
|
|
50
|
-
const selectionStart = (0, vue.computed)(() => selectionRange.value[0]);
|
|
51
|
-
const selectionEnd = (0, vue.computed)(() => selectionRange.value[1]);
|
|
52
|
-
const onModify = (text) => {
|
|
53
|
-
if (text && text !== props.format && text !== props.value) props?.onHelp?.();
|
|
54
|
-
};
|
|
55
|
-
const triggerInputChange = (text) => {
|
|
56
|
-
if (props.validateFormat?.(text)) props?.onChange?.(text);
|
|
57
|
-
internalInputValue.value = text;
|
|
58
|
-
onModify(text);
|
|
59
|
-
};
|
|
60
|
-
const onInternalChange = (event) => {
|
|
61
|
-
const target = event.target;
|
|
62
|
-
if (!props.format) {
|
|
63
|
-
const text = target.value;
|
|
64
|
-
onModify(text);
|
|
65
|
-
internalInputValue.value = text;
|
|
66
|
-
props?.onChange?.(text);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const onFormatPaste = (event) => {
|
|
70
|
-
const pasteText = event.clipboardData?.getData("text") || "";
|
|
71
|
-
if (props?.validateFormat?.(pasteText)) triggerInputChange(pasteText);
|
|
72
|
-
};
|
|
73
|
-
const mouseDownRef = (0, vue.ref)(false);
|
|
74
|
-
const onFormatMouseDown = () => {
|
|
75
|
-
mouseDownRef.value = true;
|
|
76
|
-
};
|
|
77
|
-
const onFormatMouseUp = (event) => {
|
|
78
|
-
const { selectionStart: start } = event.target;
|
|
79
|
-
focusCellIndex.value = maskFormat.value.getMaskCellIndex(start);
|
|
80
|
-
forceSelectionSyncMark.value = {};
|
|
81
|
-
props.onMouseUp?.(event);
|
|
82
|
-
mouseDownRef.value = false;
|
|
83
|
-
};
|
|
84
|
-
const onFormatFocus = (event) => {
|
|
85
|
-
focused.value = true;
|
|
86
|
-
focusCellIndex.value = 0;
|
|
87
|
-
focusCellText.value = "";
|
|
88
|
-
props.onFocus?.(event);
|
|
89
|
-
};
|
|
90
|
-
const onSharedBlur = (event) => {
|
|
91
|
-
props.onBlur?.(event);
|
|
92
|
-
};
|
|
93
|
-
const onFormatBlur = (event) => {
|
|
94
|
-
focused.value = false;
|
|
95
|
-
onSharedBlur(event);
|
|
96
|
-
};
|
|
97
|
-
require_useLockEffect.default((0, vue.toRef)(props, "active"), () => {
|
|
98
|
-
if (!props.active && !props.preserveInvalidOnBlur) internalInputValue.value = props.value;
|
|
99
|
-
});
|
|
100
|
-
const onSharedKeyDown = (event) => {
|
|
101
|
-
if (event.key === "Enter" && props?.validateFormat?.(inputValue.value)) props?.onSubmit?.();
|
|
102
|
-
props.onKeyDown?.(event);
|
|
103
|
-
};
|
|
104
|
-
const onFormatKeyDown = (event) => {
|
|
105
|
-
onSharedKeyDown(event);
|
|
106
|
-
const { key } = event;
|
|
107
|
-
let nextCellText = null;
|
|
108
|
-
let nextFillText = null;
|
|
109
|
-
const maskCellLen = selectionEnd.value - selectionStart.value;
|
|
110
|
-
const cellFormat = props.format.slice(selectionStart.value, selectionEnd.value);
|
|
111
|
-
const offsetCellIndex = (offset) => {
|
|
112
|
-
let nextIndex = focusCellIndex.value + offset;
|
|
113
|
-
nextIndex = Math.max(nextIndex, 0);
|
|
114
|
-
nextIndex = Math.min(nextIndex, maskFormat.value.size() - 1);
|
|
115
|
-
focusCellIndex.value = nextIndex;
|
|
116
|
-
};
|
|
117
|
-
const offsetCellValue = (offset) => {
|
|
118
|
-
const [rangeStart, rangeEnd, rangeDefault] = require_util.getMaskRange(cellFormat);
|
|
119
|
-
const currentText = inputValue.value.slice(selectionStart.value, selectionEnd.value);
|
|
120
|
-
const currentTextNum = Number(currentText);
|
|
121
|
-
if (Number.isNaN(currentTextNum)) return String(rangeDefault || (offset > 0 ? rangeStart : rangeEnd));
|
|
122
|
-
const num = currentTextNum + offset;
|
|
123
|
-
const range = rangeEnd - rangeStart + 1;
|
|
124
|
-
return String(rangeStart + (range + num - rangeStart) % range);
|
|
125
|
-
};
|
|
126
|
-
switch (key) {
|
|
127
|
-
case "Backspace":
|
|
128
|
-
case "Delete":
|
|
129
|
-
nextCellText = "";
|
|
130
|
-
nextFillText = cellFormat;
|
|
131
|
-
break;
|
|
132
|
-
case "ArrowLeft":
|
|
133
|
-
nextCellText = "";
|
|
134
|
-
offsetCellIndex(-1);
|
|
135
|
-
break;
|
|
136
|
-
case "ArrowRight":
|
|
137
|
-
nextCellText = "";
|
|
138
|
-
offsetCellIndex(1);
|
|
139
|
-
break;
|
|
140
|
-
case "ArrowUp":
|
|
141
|
-
nextCellText = "";
|
|
142
|
-
nextFillText = offsetCellValue(1);
|
|
143
|
-
break;
|
|
144
|
-
case "ArrowDown":
|
|
145
|
-
nextCellText = "";
|
|
146
|
-
nextFillText = offsetCellValue(-1);
|
|
147
|
-
break;
|
|
148
|
-
default:
|
|
149
|
-
if (!Number.isNaN(Number(key))) {
|
|
150
|
-
nextCellText = focusCellText.value + key;
|
|
151
|
-
nextFillText = nextCellText;
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
if (nextCellText !== null) {
|
|
156
|
-
focusCellText.value = nextCellText;
|
|
157
|
-
if (nextCellText.length >= maskCellLen) {
|
|
158
|
-
offsetCellIndex(1);
|
|
159
|
-
focusCellText.value = "";
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (nextFillText !== null) triggerInputChange((inputValue.value.slice(0, selectionStart.value) + require_miscUtil.leftPad(nextFillText, maskCellLen) + inputValue.value.slice(selectionEnd.value)).slice(0, props.format.length));
|
|
163
|
-
forceSelectionSyncMark.value = {};
|
|
164
|
-
};
|
|
165
|
-
const rafRef = (0, vue.ref)();
|
|
166
|
-
(0, vue.watch)([
|
|
167
|
-
maskFormat,
|
|
168
|
-
() => props.format,
|
|
169
|
-
focused,
|
|
170
|
-
inputValue,
|
|
171
|
-
focusCellIndex,
|
|
172
|
-
selectionStart,
|
|
173
|
-
selectionEnd,
|
|
174
|
-
forceSelectionSyncMark
|
|
175
|
-
], () => {
|
|
176
|
-
if (!focused.value || !props.format || mouseDownRef.value) return;
|
|
177
|
-
if (!maskFormat.value.match(inputValue.value)) {
|
|
178
|
-
triggerInputChange(props.format);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
inputRef.value?.setSelectionRange(selectionStart.value, selectionEnd.value);
|
|
182
|
-
rafRef.value = require_util.raf(() => {
|
|
183
|
-
inputRef.value?.setSelectionRange(selectionStart.value, selectionEnd.value);
|
|
184
|
-
});
|
|
185
|
-
}, { flush: "post" });
|
|
186
|
-
(0, vue.onBeforeUnmount)(() => {
|
|
187
|
-
require_util.raf.cancel(rafRef.value);
|
|
188
|
-
});
|
|
189
|
-
return () => {
|
|
190
|
-
const { className, active, showActiveCls, suffixIcon, format, validateFormat, onChange, onInput, helped, onHelp, onSubmit, onKeyDown, preserveInvalidOnBlur, invalid, clearIcon, ...restProps } = props;
|
|
191
|
-
const inputProps = props.format ? {
|
|
192
|
-
onFocus: onFormatFocus,
|
|
193
|
-
onBlur: onFormatBlur,
|
|
194
|
-
onKeydown: onFormatKeyDown,
|
|
195
|
-
onMousedown: onFormatMouseDown,
|
|
196
|
-
onMouseup: onFormatMouseUp,
|
|
197
|
-
onPaste: onFormatPaste
|
|
198
|
-
} : {};
|
|
199
|
-
const Component = pickerCtx.value.input ?? "input";
|
|
200
|
-
return (0, vue.createVNode)("div", {
|
|
201
|
-
"ref": holderRef,
|
|
202
|
-
"class": (0, _v_c_util.clsx)(inputPrefixCls.value, {
|
|
203
|
-
[`${inputPrefixCls.value}-active`]: props.active && props.showActiveCls,
|
|
204
|
-
[`${inputPrefixCls.value}-placeholder`]: props.helped
|
|
205
|
-
}, attrs.class),
|
|
206
|
-
"style": attrs.style
|
|
207
|
-
}, [
|
|
208
|
-
(0, vue.createVNode)(Component, (0, vue.mergeProps)({
|
|
209
|
-
"ref": inputRef,
|
|
210
|
-
"aria-invalid": props.invalid,
|
|
211
|
-
"autoComplete": "off"
|
|
212
|
-
}, attrs, restProps, {
|
|
213
|
-
"onKeydown": onSharedKeyDown,
|
|
214
|
-
"onBlur": onSharedBlur
|
|
215
|
-
}, inputProps, {
|
|
216
|
-
"value": inputValue.value,
|
|
217
|
-
"onInput": onInternalChange,
|
|
218
|
-
"class": classNames.value.input,
|
|
219
|
-
"style": styles.value.input,
|
|
220
|
-
"readonly": props.inputReadOnly
|
|
221
|
-
}), null),
|
|
222
|
-
(0, vue.createVNode)(require_Icon.default, {
|
|
223
|
-
"type": "suffix",
|
|
224
|
-
"icon": props.suffixIcon
|
|
225
|
-
}, null),
|
|
226
|
-
props.clearIcon
|
|
227
|
-
]);
|
|
228
|
-
};
|
|
229
|
-
}, {
|
|
230
|
-
props: {
|
|
231
|
-
readOnly: {
|
|
232
|
-
type: Boolean,
|
|
233
|
-
required: false,
|
|
234
|
-
default: void 0
|
|
235
|
-
},
|
|
236
|
-
required: {
|
|
237
|
-
type: Boolean,
|
|
238
|
-
required: false,
|
|
239
|
-
default: void 0
|
|
240
|
-
},
|
|
241
|
-
"aria-required": {
|
|
242
|
-
type: Boolean,
|
|
243
|
-
required: false,
|
|
244
|
-
default: void 0
|
|
245
|
-
},
|
|
246
|
-
name: {
|
|
247
|
-
type: String,
|
|
248
|
-
required: false,
|
|
249
|
-
default: void 0
|
|
250
|
-
},
|
|
251
|
-
autoComplete: {
|
|
252
|
-
type: String,
|
|
253
|
-
required: false,
|
|
254
|
-
default: void 0
|
|
255
|
-
},
|
|
256
|
-
size: {
|
|
257
|
-
type: Number,
|
|
258
|
-
required: false,
|
|
259
|
-
default: void 0
|
|
260
|
-
},
|
|
261
|
-
id: {
|
|
262
|
-
type: String,
|
|
263
|
-
required: false,
|
|
264
|
-
default: void 0
|
|
265
|
-
},
|
|
266
|
-
placeholder: {
|
|
267
|
-
type: String,
|
|
268
|
-
required: false,
|
|
269
|
-
default: void 0
|
|
270
|
-
},
|
|
271
|
-
disabled: {
|
|
272
|
-
type: Boolean,
|
|
273
|
-
required: false,
|
|
274
|
-
default: void 0
|
|
275
|
-
},
|
|
276
|
-
onFocus: {
|
|
277
|
-
type: Function,
|
|
278
|
-
required: false,
|
|
279
|
-
default: void 0
|
|
280
|
-
},
|
|
281
|
-
onBlur: {
|
|
282
|
-
type: Function,
|
|
283
|
-
required: false,
|
|
284
|
-
default: void 0
|
|
285
|
-
},
|
|
286
|
-
onKeyDown: {
|
|
287
|
-
type: Function,
|
|
288
|
-
required: false,
|
|
289
|
-
default: void 0
|
|
290
|
-
},
|
|
291
|
-
format: {
|
|
292
|
-
type: String,
|
|
293
|
-
required: false,
|
|
294
|
-
default: void 0
|
|
295
|
-
},
|
|
296
|
-
validateFormat: {
|
|
297
|
-
type: Function,
|
|
298
|
-
required: true,
|
|
299
|
-
default: void 0
|
|
300
|
-
},
|
|
301
|
-
active: {
|
|
302
|
-
type: Boolean,
|
|
303
|
-
required: false,
|
|
304
|
-
default: void 0
|
|
305
|
-
},
|
|
306
|
-
showActiveCls: {
|
|
307
|
-
type: Boolean,
|
|
308
|
-
required: false,
|
|
309
|
-
default: void 0
|
|
310
|
-
},
|
|
311
|
-
suffixIcon: {
|
|
312
|
-
type: [
|
|
313
|
-
Object,
|
|
314
|
-
Function,
|
|
315
|
-
String,
|
|
316
|
-
Number,
|
|
317
|
-
null,
|
|
318
|
-
Boolean,
|
|
319
|
-
Array
|
|
320
|
-
],
|
|
321
|
-
required: false,
|
|
322
|
-
default: void 0
|
|
323
|
-
},
|
|
324
|
-
value: {
|
|
325
|
-
type: String,
|
|
326
|
-
required: false,
|
|
327
|
-
default: void 0
|
|
328
|
-
},
|
|
329
|
-
onChange: {
|
|
330
|
-
type: Function,
|
|
331
|
-
required: true,
|
|
332
|
-
default: void 0
|
|
333
|
-
},
|
|
334
|
-
onSubmit: {
|
|
335
|
-
required: true,
|
|
336
|
-
default: void 0
|
|
337
|
-
},
|
|
338
|
-
helped: {
|
|
339
|
-
type: Boolean,
|
|
340
|
-
required: false,
|
|
341
|
-
default: void 0
|
|
342
|
-
},
|
|
343
|
-
onHelp: {
|
|
344
|
-
type: Function,
|
|
345
|
-
required: true,
|
|
346
|
-
default: void 0
|
|
347
|
-
},
|
|
348
|
-
preserveInvalidOnBlur: {
|
|
349
|
-
type: Boolean,
|
|
350
|
-
required: false,
|
|
351
|
-
default: void 0
|
|
352
|
-
},
|
|
353
|
-
invalid: {
|
|
354
|
-
type: Boolean,
|
|
355
|
-
required: false,
|
|
356
|
-
default: void 0
|
|
357
|
-
},
|
|
358
|
-
clearIcon: {
|
|
359
|
-
type: [
|
|
360
|
-
Object,
|
|
361
|
-
Function,
|
|
362
|
-
String,
|
|
363
|
-
Number,
|
|
364
|
-
null,
|
|
365
|
-
Boolean,
|
|
366
|
-
Array
|
|
367
|
-
],
|
|
368
|
-
required: false,
|
|
369
|
-
default: void 0
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
name: "Input",
|
|
373
|
-
inheritAttrs: false
|
|
374
|
-
});
|
|
375
|
-
var Input_default = Input;
|
|
376
|
-
exports.default = Input_default;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
var FORMAT_KEYS = [
|
|
6
|
-
"YYYY",
|
|
7
|
-
"MM",
|
|
8
|
-
"DD",
|
|
9
|
-
"HH",
|
|
10
|
-
"mm",
|
|
11
|
-
"ss",
|
|
12
|
-
"SSS"
|
|
13
|
-
];
|
|
14
|
-
var REPLACE_KEY = "顧";
|
|
15
|
-
var MaskFormat = class {
|
|
16
|
-
format;
|
|
17
|
-
maskFormat;
|
|
18
|
-
cells;
|
|
19
|
-
maskCells;
|
|
20
|
-
constructor(format) {
|
|
21
|
-
this.format = format;
|
|
22
|
-
const replaceKeys = FORMAT_KEYS.map((key) => `(${key})`).join("|");
|
|
23
|
-
const replaceReg = new RegExp(replaceKeys, "g");
|
|
24
|
-
this.maskFormat = format.replace(replaceReg, (key) => REPLACE_KEY.repeat(key.length));
|
|
25
|
-
const cellReg = /* @__PURE__ */ new RegExp(`(${FORMAT_KEYS.join("|")})`);
|
|
26
|
-
const strCells = (format.split(cellReg) || []).filter((str) => str);
|
|
27
|
-
let offset = 0;
|
|
28
|
-
this.cells = strCells.map((text) => {
|
|
29
|
-
const mask = FORMAT_KEYS.includes(text);
|
|
30
|
-
const start = offset;
|
|
31
|
-
const end = offset + text.length;
|
|
32
|
-
offset = end;
|
|
33
|
-
return {
|
|
34
|
-
text,
|
|
35
|
-
mask,
|
|
36
|
-
start,
|
|
37
|
-
end
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
this.maskCells = this.cells.filter((cell) => cell.mask);
|
|
41
|
-
}
|
|
42
|
-
getSelection(maskCellIndex) {
|
|
43
|
-
const { start, end } = this.maskCells[maskCellIndex] || {};
|
|
44
|
-
return [start || 0, end || 0];
|
|
45
|
-
}
|
|
46
|
-
match(text) {
|
|
47
|
-
for (let i = 0; i < this.maskFormat.length; i += 1) {
|
|
48
|
-
const maskChar = this.maskFormat[i];
|
|
49
|
-
const textChar = text[i];
|
|
50
|
-
if (!textChar || maskChar !== REPLACE_KEY && maskChar !== textChar) return false;
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
size() {
|
|
55
|
-
return this.maskCells.length;
|
|
56
|
-
}
|
|
57
|
-
getMaskCellIndex(anchorIndex) {
|
|
58
|
-
let closetDist = Number.MAX_SAFE_INTEGER;
|
|
59
|
-
let closetIndex = 0;
|
|
60
|
-
for (let i = 0; i < this.maskCells.length; i += 1) {
|
|
61
|
-
const { start, end } = this.maskCells[i];
|
|
62
|
-
if (anchorIndex >= start && anchorIndex <= end) return i;
|
|
63
|
-
const dist = Math.min(Math.abs(anchorIndex - start), Math.abs(anchorIndex - end));
|
|
64
|
-
if (dist < closetDist) {
|
|
65
|
-
closetDist = dist;
|
|
66
|
-
closetIndex = i;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return closetIndex;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
exports.default = MaskFormat;
|