naive-ui 2.41.0 → 2.42.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/dist/index.js +930 -428
- package/dist/index.mjs +927 -430
- package/dist/index.prod.js +1 -1
- package/dist/index.prod.mjs +1 -1
- package/es/_internal/icon/src/styles/index.cssr.mjs +0 -1
- package/es/_internal/selection/src/Selection.d.ts +1 -1
- package/es/_mixins/use-form-item.d.ts +1 -1
- package/es/_utils/dom/download.d.ts +1 -0
- package/es/_utils/dom/download.mjs +3 -0
- package/es/_utils/index.d.ts +1 -1
- package/es/_utils/index.mjs +1 -1
- package/es/_utils/naive/index.d.ts +1 -0
- package/es/_utils/naive/index.mjs +1 -0
- package/es/_utils/naive/value.d.ts +1 -0
- package/es/_utils/naive/value.mjs +13 -0
- package/es/anchor/index.d.ts +1 -0
- package/es/anchor/src/Link.d.ts +3 -2
- package/es/anchor/src/Link.mjs +5 -2
- package/es/anchor/src/public-types.d.ts +5 -0
- package/es/anchor/src/public-types.mjs +1 -0
- package/es/auto-complete/src/AutoComplete.d.ts +1 -1
- package/es/cascader/src/Cascader.d.ts +1 -1
- package/es/components.d.ts +1 -0
- package/es/components.mjs +1 -0
- package/es/config-provider/src/internal-interface.d.ts +2 -0
- package/es/data-table/src/DataTable.d.ts +6 -6
- package/es/data-table/src/DataTable.mjs +6 -6
- package/es/data-table/src/styles/index.cssr.mjs +1 -0
- package/es/date-picker/src/DatePicker.d.ts +5 -5
- package/es/date-picker/src/DatePicker.mjs +1 -1
- package/es/date-picker/src/panel/date.d.ts +2 -2
- package/es/date-picker/src/panel/daterange.d.ts +3 -3
- package/es/date-picker/src/panel/datetime.d.ts +2 -2
- package/es/date-picker/src/panel/datetime.mjs +1 -1
- package/es/date-picker/src/panel/datetimerange.d.ts +3 -3
- package/es/date-picker/src/panel/datetimerange.mjs +2 -2
- package/es/date-picker/src/panel/month.d.ts +2 -2
- package/es/date-picker/src/panel/monthrange.d.ts +3 -3
- package/es/date-picker/src/panel/panelHeader.d.ts +4 -4
- package/es/date-picker/src/panel/use-calendar.d.ts +1 -1
- package/es/date-picker/src/panel/use-dual-calendar.d.ts +2 -2
- package/es/date-picker/src/panel/use-dual-calendar.mjs +3 -3
- package/es/date-picker/src/panel/use-panel-common.d.ts +1 -1
- package/es/date-picker/src/panel/use-panel-common.mjs +1 -1
- package/es/date-picker/src/props.d.ts +2 -2
- package/es/date-picker/src/props.mjs +1 -1
- package/es/descriptions/src/Descriptions.d.ts +1 -1
- package/es/form/index.d.ts +1 -0
- package/es/form/src/FormItem.d.ts +1 -1
- package/es/form/src/FormItemCol.d.ts +1 -1
- package/es/form/src/FormItemGridItem.d.ts +1 -1
- package/es/form/src/interface.d.ts +0 -1
- package/es/form/src/public-types.d.ts +1 -0
- package/es/form/src/public-types.mjs +1 -0
- package/es/icon/src/styles/index.cssr.mjs +0 -1
- package/es/input/src/Input.d.ts +1 -1
- package/es/input/src/Input.mjs +1 -8
- package/es/input-number/src/InputNumber.d.ts +1 -1
- package/es/input-otp/index.d.ts +3 -0
- package/es/input-otp/index.mjs +1 -0
- package/es/input-otp/src/InputOtp.d.ts +875 -0
- package/es/input-otp/src/InputOtp.mjs +322 -0
- package/es/input-otp/src/public-types.d.ts +24 -0
- package/es/input-otp/src/public-types.mjs +1 -0
- package/es/input-otp/src/styles/index.cssr.d.ts +2 -0
- package/es/input-otp/src/styles/index.cssr.mjs +20 -0
- package/es/input-otp/src/styles/input-otp-rtl.cssr.d.ts +2 -0
- package/es/input-otp/src/styles/input-otp-rtl.cssr.mjs +5 -0
- package/es/input-otp/styles/dark.d.ts +3 -0
- package/es/input-otp/styles/dark.mjs +12 -0
- package/es/input-otp/styles/index.d.ts +4 -0
- package/es/input-otp/styles/index.mjs +3 -0
- package/es/input-otp/styles/light.d.ts +81 -0
- package/es/input-otp/styles/light.mjs +22 -0
- package/es/input-otp/styles/rtl.d.ts +2 -0
- package/es/input-otp/styles/rtl.mjs +5 -0
- package/es/mention/src/Mention.d.ts +1 -1
- package/es/progress/src/Circle.d.ts +1 -1
- package/es/progress/src/MultipleCircle.d.ts +1 -1
- package/es/progress/src/Progress.d.ts +2 -2
- package/es/radio/src/Radio.mjs +5 -5
- package/es/radio/src/styles/radio.cssr.mjs +3 -7
- package/es/select/src/Select.d.ts +1 -1
- package/es/styles.d.ts +1 -0
- package/es/styles.mjs +1 -0
- package/es/tabs/src/TabPane.d.ts +1 -0
- package/es/themes/dark.mjs +2 -1
- package/es/themes/light.mjs +2 -0
- package/es/time-picker/src/TimePicker.d.ts +1 -1
- package/es/transfer/src/Transfer.d.ts +1 -1
- package/es/tree/src/Tree.d.ts +21 -17
- package/es/tree/src/Tree.mjs +4 -4
- package/es/tree/src/styles/index.cssr.mjs +0 -1
- package/es/tree-select/src/TreeSelect.d.ts +14 -1
- package/es/tree-select/src/TreeSelect.mjs +1 -0
- package/es/typography/src/text.d.ts +1 -1
- package/es/upload/index.d.ts +1 -0
- package/es/upload/index.mjs +1 -0
- package/es/upload/src/Upload.d.ts +11 -8
- package/es/upload/src/Upload.mjs +2 -0
- package/es/upload/src/UploadFile.mjs +8 -1
- package/es/upload/src/interface.d.ts +1 -0
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/watermark/src/Watermark.d.ts +1 -1
- package/lib/_internal/icon/src/styles/index.cssr.js +0 -1
- package/lib/_internal/selection/src/Selection.d.ts +1 -1
- package/lib/_mixins/use-form-item.d.ts +1 -1
- package/lib/_utils/dom/download.d.ts +1 -0
- package/lib/_utils/dom/download.js +4 -0
- package/lib/_utils/index.d.ts +1 -1
- package/lib/_utils/index.js +2 -1
- package/lib/_utils/naive/index.d.ts +1 -0
- package/lib/_utils/naive/index.js +3 -1
- package/lib/_utils/naive/value.d.ts +1 -0
- package/lib/_utils/naive/value.js +18 -0
- package/lib/anchor/index.d.ts +1 -0
- package/lib/anchor/src/Link.d.ts +3 -2
- package/lib/anchor/src/Link.js +4 -1
- package/lib/anchor/src/public-types.d.ts +5 -0
- package/lib/anchor/src/public-types.js +2 -0
- package/lib/auto-complete/src/AutoComplete.d.ts +1 -1
- package/lib/cascader/src/Cascader.d.ts +1 -1
- package/lib/components.d.ts +1 -0
- package/lib/components.js +1 -0
- package/lib/config-provider/src/internal-interface.d.ts +2 -0
- package/lib/data-table/src/DataTable.d.ts +6 -6
- package/lib/data-table/src/DataTable.js +6 -6
- package/lib/data-table/src/styles/index.cssr.js +1 -0
- package/lib/date-picker/src/DatePicker.d.ts +5 -5
- package/lib/date-picker/src/DatePicker.js +1 -1
- package/lib/date-picker/src/panel/date.d.ts +2 -2
- package/lib/date-picker/src/panel/daterange.d.ts +3 -3
- package/lib/date-picker/src/panel/datetime.d.ts +2 -2
- package/lib/date-picker/src/panel/datetime.js +1 -1
- package/lib/date-picker/src/panel/datetimerange.d.ts +3 -3
- package/lib/date-picker/src/panel/datetimerange.js +2 -2
- package/lib/date-picker/src/panel/month.d.ts +2 -2
- package/lib/date-picker/src/panel/monthrange.d.ts +3 -3
- package/lib/date-picker/src/panel/panelHeader.d.ts +4 -4
- package/lib/date-picker/src/panel/use-calendar.d.ts +1 -1
- package/lib/date-picker/src/panel/use-dual-calendar.d.ts +2 -2
- package/lib/date-picker/src/panel/use-dual-calendar.js +3 -3
- package/lib/date-picker/src/panel/use-panel-common.d.ts +1 -1
- package/lib/date-picker/src/panel/use-panel-common.js +1 -1
- package/lib/date-picker/src/props.d.ts +2 -2
- package/lib/date-picker/src/props.js +1 -1
- package/lib/descriptions/src/Descriptions.d.ts +1 -1
- package/lib/form/index.d.ts +1 -0
- package/lib/form/src/FormItem.d.ts +1 -1
- package/lib/form/src/FormItemCol.d.ts +1 -1
- package/lib/form/src/FormItemGridItem.d.ts +1 -1
- package/lib/form/src/interface.d.ts +0 -1
- package/lib/form/src/public-types.d.ts +1 -0
- package/lib/form/src/public-types.js +2 -0
- package/lib/icon/src/styles/index.cssr.js +0 -1
- package/lib/input/src/Input.d.ts +1 -1
- package/lib/input/src/Input.js +0 -7
- package/lib/input-number/src/InputNumber.d.ts +1 -1
- package/lib/input-otp/index.d.ts +3 -0
- package/lib/input-otp/index.js +9 -0
- package/lib/input-otp/src/InputOtp.d.ts +875 -0
- package/lib/input-otp/src/InputOtp.js +248 -0
- package/lib/input-otp/src/public-types.d.ts +24 -0
- package/lib/input-otp/src/public-types.js +2 -0
- package/lib/input-otp/src/styles/index.cssr.d.ts +2 -0
- package/lib/input-otp/src/styles/index.cssr.js +25 -0
- package/lib/input-otp/src/styles/input-otp-rtl.cssr.d.ts +2 -0
- package/lib/input-otp/src/styles/input-otp-rtl.cssr.js +10 -0
- package/lib/input-otp/styles/dark.d.ts +3 -0
- package/lib/input-otp/styles/dark.js +14 -0
- package/lib/input-otp/styles/index.d.ts +4 -0
- package/lib/input-otp/styles/index.js +12 -0
- package/lib/input-otp/styles/light.d.ts +81 -0
- package/lib/input-otp/styles/light.js +25 -0
- package/lib/input-otp/styles/rtl.d.ts +2 -0
- package/lib/input-otp/styles/rtl.js +11 -0
- package/lib/mention/src/Mention.d.ts +1 -1
- package/lib/progress/src/Circle.d.ts +1 -1
- package/lib/progress/src/MultipleCircle.d.ts +1 -1
- package/lib/progress/src/Progress.d.ts +2 -2
- package/lib/radio/src/Radio.js +2 -2
- package/lib/radio/src/styles/radio.cssr.js +3 -7
- package/lib/select/src/Select.d.ts +1 -1
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +99 -96
- package/lib/tabs/src/TabPane.d.ts +1 -0
- package/lib/themes/dark.js +1 -0
- package/lib/themes/light.js +92 -90
- package/lib/time-picker/src/TimePicker.d.ts +1 -1
- package/lib/transfer/src/Transfer.d.ts +1 -1
- package/lib/tree/src/Tree.d.ts +21 -17
- package/lib/tree/src/Tree.js +5 -4
- package/lib/tree/src/styles/index.cssr.js +0 -1
- package/lib/tree-select/src/TreeSelect.d.ts +14 -1
- package/lib/tree-select/src/TreeSelect.js +1 -1
- package/lib/typography/src/text.d.ts +1 -1
- package/lib/upload/index.d.ts +1 -0
- package/lib/upload/index.js +3 -1
- package/lib/upload/src/Upload.d.ts +11 -8
- package/lib/upload/src/Upload.js +2 -1
- package/lib/upload/src/UploadFile.js +7 -2
- package/lib/upload/src/interface.d.ts +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/watermark/src/Watermark.d.ts +1 -1
- package/package.json +1 -1
- package/volar.d.ts +3 -2
- package/web-types.json +139 -10
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
4
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
5
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
6
|
+
}
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
import { pxfy, repeat } from 'seemly';
|
|
10
|
+
import { useMergedState } from 'vooks';
|
|
11
|
+
import { computed, defineComponent, h, ref, toRef } from 'vue';
|
|
12
|
+
import { useConfig, useFormItem, useRtl, useTheme, useThemeClass } from "../../_mixins/index.mjs";
|
|
13
|
+
import { call, createKey, isArrayShallowEqual, resolveSlotWithTypedProps } from "../../_utils/index.mjs";
|
|
14
|
+
import { NInput } from "../../input/index.mjs";
|
|
15
|
+
import inputOtpLight from "../styles/light.mjs";
|
|
16
|
+
import style from "./styles/index.cssr.mjs";
|
|
17
|
+
export const inputOtpProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
18
|
+
defaultValue: {
|
|
19
|
+
type: Array,
|
|
20
|
+
default: []
|
|
21
|
+
},
|
|
22
|
+
value: Array,
|
|
23
|
+
length: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 6
|
|
26
|
+
},
|
|
27
|
+
block: Boolean,
|
|
28
|
+
size: String,
|
|
29
|
+
disabled: Boolean,
|
|
30
|
+
mask: Boolean,
|
|
31
|
+
readonly: Boolean,
|
|
32
|
+
status: String,
|
|
33
|
+
gap: [String, Number],
|
|
34
|
+
placeholder: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ''
|
|
37
|
+
},
|
|
38
|
+
allowInput: Function,
|
|
39
|
+
onBlur: [Function, Array],
|
|
40
|
+
onFocus: [Function, Array],
|
|
41
|
+
'onUpdate:value': [Function, Array],
|
|
42
|
+
onUpdateValue: [Function, Array],
|
|
43
|
+
onFinish: [Function, Array]
|
|
44
|
+
});
|
|
45
|
+
export default defineComponent({
|
|
46
|
+
name: 'InputOtp',
|
|
47
|
+
props: inputOtpProps,
|
|
48
|
+
slots: Object,
|
|
49
|
+
setup(props) {
|
|
50
|
+
const {
|
|
51
|
+
mergedClsPrefixRef,
|
|
52
|
+
mergedRtlRef,
|
|
53
|
+
inlineThemeDisabled
|
|
54
|
+
} = useConfig(props);
|
|
55
|
+
const themeRef = useTheme('InputOtp', '-input-otp', style, inputOtpLight, props, mergedClsPrefixRef);
|
|
56
|
+
const rtlEnabledRef = useRtl('InputOtp', mergedRtlRef, mergedClsPrefixRef);
|
|
57
|
+
// form-item
|
|
58
|
+
const formItem = useFormItem(props);
|
|
59
|
+
const {
|
|
60
|
+
mergedSizeRef,
|
|
61
|
+
mergedDisabledRef,
|
|
62
|
+
mergedStatusRef
|
|
63
|
+
} = formItem;
|
|
64
|
+
const cssVarsRef = computed(() => {
|
|
65
|
+
const {
|
|
66
|
+
value: size
|
|
67
|
+
} = mergedSizeRef;
|
|
68
|
+
const {
|
|
69
|
+
gap: propGap
|
|
70
|
+
} = props;
|
|
71
|
+
const {
|
|
72
|
+
self: {
|
|
73
|
+
[createKey('inputWidth', size)]: inputWidth,
|
|
74
|
+
[createKey('gap', size)]: gap
|
|
75
|
+
}
|
|
76
|
+
} = themeRef.value;
|
|
77
|
+
return {
|
|
78
|
+
'--n-gap': propGap === undefined ? gap : typeof propGap === 'number' ? pxfy(propGap) : propGap,
|
|
79
|
+
'--n-input-width': inputWidth
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
const themeClassHandle = inlineThemeDisabled ? useThemeClass('input-otp', computed(() => {
|
|
83
|
+
const {
|
|
84
|
+
value: size
|
|
85
|
+
} = mergedSizeRef;
|
|
86
|
+
return size[0];
|
|
87
|
+
}), cssVarsRef, props) : undefined;
|
|
88
|
+
const uncontrolledValueRef = ref(props.defaultValue);
|
|
89
|
+
const controlledValueRef = toRef(props, 'value');
|
|
90
|
+
const mergedValueRef = useMergedState(controlledValueRef, uncontrolledValueRef);
|
|
91
|
+
const inputRefList = ref([]);
|
|
92
|
+
const inputTypeRef = computed(() => props.mask ? 'password' : 'text');
|
|
93
|
+
const handleFocus = (e, index) => {
|
|
94
|
+
// If it's focused from other input element inside the component, returns
|
|
95
|
+
if (inputRefList === null || inputRefList === void 0 ? void 0 : inputRefList.value.some(inputInst => inputInst.inputElRef === e.relatedTarget)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const {
|
|
99
|
+
onFocus
|
|
100
|
+
} = props;
|
|
101
|
+
if (onFocus) {
|
|
102
|
+
call(onFocus, e, index);
|
|
103
|
+
}
|
|
104
|
+
const {
|
|
105
|
+
nTriggerFormFocus
|
|
106
|
+
} = formItem;
|
|
107
|
+
nTriggerFormFocus();
|
|
108
|
+
};
|
|
109
|
+
const handleBlur = (e, index) => {
|
|
110
|
+
// If it's blured to other input element inside the component, returns
|
|
111
|
+
if (inputRefList === null || inputRefList === void 0 ? void 0 : inputRefList.value.some(inputInst => inputInst.inputElRef === e.relatedTarget)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const {
|
|
115
|
+
onBlur
|
|
116
|
+
} = props;
|
|
117
|
+
const {
|
|
118
|
+
nTriggerFormBlur
|
|
119
|
+
} = formItem;
|
|
120
|
+
if (onBlur) call(onBlur, e, index);
|
|
121
|
+
nTriggerFormBlur();
|
|
122
|
+
};
|
|
123
|
+
const focusOnChar = charIndex => {
|
|
124
|
+
if (charIndex >= props.length) return;
|
|
125
|
+
if (charIndex < 0) return;
|
|
126
|
+
inputRefList === null || inputRefList === void 0 ? void 0 : inputRefList.value[charIndex].focus();
|
|
127
|
+
inputRefList === null || inputRefList === void 0 ? void 0 : inputRefList.value[charIndex].select();
|
|
128
|
+
};
|
|
129
|
+
const focusOnNextChar = currentIndex => {
|
|
130
|
+
if (currentIndex >= props.length - 1) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
focusOnChar(currentIndex + 1);
|
|
134
|
+
};
|
|
135
|
+
const focusOnPrevChar = currentIndex => {
|
|
136
|
+
if (currentIndex <= 0) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
focusOnChar(currentIndex - 1);
|
|
140
|
+
};
|
|
141
|
+
const justifyValue = value => {
|
|
142
|
+
const justifiedValue = value ? Array.from(value) : [];
|
|
143
|
+
const length = props.length;
|
|
144
|
+
while (justifiedValue.length > length) {
|
|
145
|
+
justifiedValue.pop();
|
|
146
|
+
}
|
|
147
|
+
while (justifiedValue.length < length) {
|
|
148
|
+
justifiedValue.push('');
|
|
149
|
+
}
|
|
150
|
+
return justifiedValue;
|
|
151
|
+
};
|
|
152
|
+
function doUpdateValue(value, meta) {
|
|
153
|
+
const {
|
|
154
|
+
nTriggerFormInput,
|
|
155
|
+
nTriggerFormChange
|
|
156
|
+
} = formItem;
|
|
157
|
+
if (isArrayShallowEqual(value, mergedValueRef.value)) {
|
|
158
|
+
nTriggerFormInput();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const {
|
|
162
|
+
'onUpdate:value': _onUpdateValue,
|
|
163
|
+
onUpdateValue,
|
|
164
|
+
length,
|
|
165
|
+
onFinish
|
|
166
|
+
} = props;
|
|
167
|
+
if (_onUpdateValue) call(_onUpdateValue, value, meta);
|
|
168
|
+
if (onUpdateValue) call(onUpdateValue, value, meta);
|
|
169
|
+
if (value.filter(v => v).length === length && onFinish) {
|
|
170
|
+
call(onFinish, value);
|
|
171
|
+
}
|
|
172
|
+
uncontrolledValueRef.value = value;
|
|
173
|
+
nTriggerFormInput();
|
|
174
|
+
nTriggerFormChange();
|
|
175
|
+
}
|
|
176
|
+
const handlePaste = (e, index) => {
|
|
177
|
+
if (props.readonly || mergedDisabledRef.value) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
const {
|
|
182
|
+
clipboardData
|
|
183
|
+
} = e;
|
|
184
|
+
const text = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.getData('text');
|
|
185
|
+
if (!text) return;
|
|
186
|
+
const currentValue = justifyValue(mergedValueRef.value);
|
|
187
|
+
let startIndex = index;
|
|
188
|
+
const allowInput = props.allowInput;
|
|
189
|
+
let pasteApplied = false;
|
|
190
|
+
let appendedText = '';
|
|
191
|
+
for (let i = 0; i < text.length; ++i) {
|
|
192
|
+
if (allowInput && !allowInput(text[i], startIndex, currentValue)) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
pasteApplied = true;
|
|
196
|
+
currentValue[startIndex] = text[i];
|
|
197
|
+
appendedText += text[i];
|
|
198
|
+
startIndex++;
|
|
199
|
+
if (startIndex >= currentValue.length) {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (pasteApplied) {
|
|
204
|
+
focusOnChar(startIndex);
|
|
205
|
+
doUpdateValue(currentValue, {
|
|
206
|
+
diff: appendedText,
|
|
207
|
+
index: startIndex,
|
|
208
|
+
source: 'paste'
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const handleKeydown = (e, index) => {
|
|
213
|
+
if (mergedDisabledRef.value) return;
|
|
214
|
+
const keyCode = e.code || e.key;
|
|
215
|
+
const currentValue = justifyValue(mergedValueRef.value);
|
|
216
|
+
if (keyCode === 'Backspace' && !props.readonly) {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
currentValue[Math.max(index, 0)] = '';
|
|
219
|
+
doUpdateValue(currentValue, {
|
|
220
|
+
diff: '',
|
|
221
|
+
index,
|
|
222
|
+
source: 'delete'
|
|
223
|
+
});
|
|
224
|
+
focusOnPrevChar(index);
|
|
225
|
+
} else if (keyCode === 'ArrowLeft') {
|
|
226
|
+
e.preventDefault();
|
|
227
|
+
focusOnPrevChar(index);
|
|
228
|
+
} else if (keyCode === 'ArrowRight') {
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
focusOnNextChar(index);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const handleInput = (value, index) => {
|
|
234
|
+
const currentValue = justifyValue(mergedValueRef.value);
|
|
235
|
+
const currentValueAtIndex = currentValue[index];
|
|
236
|
+
const diff = value.replace(currentValueAtIndex, '');
|
|
237
|
+
const char = diff[diff.length - 1] || value[value.length - 1] || '';
|
|
238
|
+
const allowInput = props.allowInput;
|
|
239
|
+
if (allowInput && !allowInput(char, index, currentValue)) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
currentValue[index] = char;
|
|
243
|
+
doUpdateValue(currentValue, {
|
|
244
|
+
diff: char,
|
|
245
|
+
index,
|
|
246
|
+
source: 'input'
|
|
247
|
+
});
|
|
248
|
+
focusOnNextChar(index);
|
|
249
|
+
};
|
|
250
|
+
const getTemplateEvents = index => {
|
|
251
|
+
return {
|
|
252
|
+
onInput: value => handleInput(value, index),
|
|
253
|
+
onPaste: event => handlePaste(event, index),
|
|
254
|
+
onKeydown: event => handleKeydown(event, index),
|
|
255
|
+
onFocus: event => handleFocus(event, index),
|
|
256
|
+
onBlur: event => handleBlur(event, index)
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
return {
|
|
260
|
+
mergedTheme: themeRef,
|
|
261
|
+
perItemValueArray: computed(() => justifyValue(mergedValueRef.value)),
|
|
262
|
+
mergedClsPrefix: mergedClsPrefixRef,
|
|
263
|
+
inputRefList,
|
|
264
|
+
inputType: inputTypeRef,
|
|
265
|
+
rtlEnabled: rtlEnabledRef,
|
|
266
|
+
mergedStatus: mergedStatusRef,
|
|
267
|
+
mergedDisabled: mergedDisabledRef,
|
|
268
|
+
cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
|
|
269
|
+
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
270
|
+
getTemplateEvents,
|
|
271
|
+
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
272
|
+
};
|
|
273
|
+
},
|
|
274
|
+
render() {
|
|
275
|
+
const {
|
|
276
|
+
mergedTheme,
|
|
277
|
+
mergedClsPrefix,
|
|
278
|
+
perItemValueArray,
|
|
279
|
+
size,
|
|
280
|
+
placeholder,
|
|
281
|
+
mergedDisabled,
|
|
282
|
+
mergedStatus,
|
|
283
|
+
readonly,
|
|
284
|
+
inputType,
|
|
285
|
+
$slots,
|
|
286
|
+
getTemplateEvents,
|
|
287
|
+
themeClass,
|
|
288
|
+
onRender
|
|
289
|
+
} = this;
|
|
290
|
+
onRender === null || onRender === void 0 ? void 0 : onRender();
|
|
291
|
+
return h("div", {
|
|
292
|
+
style: this.cssVars,
|
|
293
|
+
class: [`${mergedClsPrefix}-input-otp`, themeClass, this.rtlEnabled && `${mergedClsPrefix}-input-otp--rtl`, this.block && `${mergedClsPrefix}-input-otp--block`]
|
|
294
|
+
}, repeat(this.length, undefined).map((_, index) => resolveSlotWithTypedProps($slots.default, Object.assign({
|
|
295
|
+
index,
|
|
296
|
+
value: perItemValueArray[index],
|
|
297
|
+
type: inputType,
|
|
298
|
+
size,
|
|
299
|
+
placeholder,
|
|
300
|
+
disabled: mergedDisabled,
|
|
301
|
+
readonly,
|
|
302
|
+
status: mergedStatus,
|
|
303
|
+
builtinThemeOverrides: {
|
|
304
|
+
paddingTiny: '0',
|
|
305
|
+
paddingSmall: '0',
|
|
306
|
+
paddingMedium: '0',
|
|
307
|
+
paddingLarge: '0'
|
|
308
|
+
},
|
|
309
|
+
theme: mergedTheme.peers.Input,
|
|
310
|
+
themeOverrides: mergedTheme.peerOverrides.Input,
|
|
311
|
+
ref: el => this.inputRefList[index] = el
|
|
312
|
+
}, getTemplateEvents(index)), _a => {
|
|
313
|
+
var {
|
|
314
|
+
index
|
|
315
|
+
} = _a,
|
|
316
|
+
restProps = __rest(_a, ["index"]);
|
|
317
|
+
return [h(NInput, Object.assign({}, restProps, {
|
|
318
|
+
key: index
|
|
319
|
+
}))];
|
|
320
|
+
})));
|
|
321
|
+
}
|
|
322
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
2
|
+
import type { InputInst } from '../../components';
|
|
3
|
+
import type { InputProps } from '../../input/src/Input';
|
|
4
|
+
export type InputOtpAllowInput = (char: string, index: number, currentValue: string[]) => boolean;
|
|
5
|
+
export type InputOtpSize = 'small' | 'medium' | 'large';
|
|
6
|
+
export type InputOtpOnUpdateValue = (value: string[], meta: InputOtpOnUpdateValueMeta) => void;
|
|
7
|
+
export type InputOtpOnFocus = (e: FocusEvent, index: number) => void;
|
|
8
|
+
export type InputOtpOnBlur = (e: FocusEvent, index: number) => void;
|
|
9
|
+
export interface InputOtpSlots {
|
|
10
|
+
default?: InputOtpDefaultSlot;
|
|
11
|
+
}
|
|
12
|
+
export type InputOtpDefaultSlot = (props: InputProps & {
|
|
13
|
+
index: number;
|
|
14
|
+
ref: (inst: InputInst) => void;
|
|
15
|
+
}) => VNode[];
|
|
16
|
+
export type InputOtpOnFinish = (value: string[]) => void;
|
|
17
|
+
export interface InputOtpOnUpdateValueMeta {
|
|
18
|
+
diff: string;
|
|
19
|
+
index: number;
|
|
20
|
+
source: InputOtpOnUpdateValueMetaSource;
|
|
21
|
+
}
|
|
22
|
+
export type InputOtpOnUpdateValueMetaSource = 'paste' | 'input' | 'delete';
|
|
23
|
+
export interface InputOtpInst {
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { c, cB, cM, cNotM } from "../../../_utils/cssr/index.mjs";
|
|
2
|
+
// --n-input-width
|
|
3
|
+
// --n-gap
|
|
4
|
+
export default c([cB('input-otp', `
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: var(--n-gap);
|
|
8
|
+
`, [cM('block', ``, [cB('input', ``, [cNotM('autosize', `
|
|
9
|
+
text-align: center;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
`), cM('autosize', `
|
|
12
|
+
text-align: center;
|
|
13
|
+
min-width: 0;
|
|
14
|
+
`)])]), cNotM('block', ``, [cB('input', ``, [cNotM('autosize', `
|
|
15
|
+
width: var(--n-input-width);
|
|
16
|
+
text-align: center;
|
|
17
|
+
`), cM('autosize', `
|
|
18
|
+
width: var(--n-input-width);
|
|
19
|
+
text-align: center;
|
|
20
|
+
`)])])])]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { commonDark } from "../../_styles/common/index.mjs";
|
|
2
|
+
import { inputDark } from "../../styles.mjs";
|
|
3
|
+
import { self } from "./light.mjs";
|
|
4
|
+
const inputOtpDark = {
|
|
5
|
+
name: 'InputOtp',
|
|
6
|
+
common: commonDark,
|
|
7
|
+
peers: {
|
|
8
|
+
Input: inputDark
|
|
9
|
+
},
|
|
10
|
+
self
|
|
11
|
+
};
|
|
12
|
+
export default inputOtpDark;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export declare function self(): {
|
|
2
|
+
inputWidthSmall: string;
|
|
3
|
+
inputWidthMedium: string;
|
|
4
|
+
inputWidthLarge: string;
|
|
5
|
+
gapSmall: string;
|
|
6
|
+
gapMedium: string;
|
|
7
|
+
gapLarge: string;
|
|
8
|
+
};
|
|
9
|
+
declare const inputOtpLight: import("../../_mixins").Theme<"InputOtp", {
|
|
10
|
+
inputWidthSmall: string;
|
|
11
|
+
inputWidthMedium: string;
|
|
12
|
+
inputWidthLarge: string;
|
|
13
|
+
gapSmall: string;
|
|
14
|
+
gapMedium: string;
|
|
15
|
+
gapLarge: string;
|
|
16
|
+
}, {
|
|
17
|
+
Input: import("../../_mixins").Theme<"Input", {
|
|
18
|
+
fontWeight: string;
|
|
19
|
+
countTextColorDisabled: string;
|
|
20
|
+
countTextColor: string;
|
|
21
|
+
heightTiny: string;
|
|
22
|
+
heightSmall: string;
|
|
23
|
+
heightMedium: string;
|
|
24
|
+
heightLarge: string;
|
|
25
|
+
fontSizeTiny: string;
|
|
26
|
+
fontSizeSmall: string;
|
|
27
|
+
fontSizeMedium: string;
|
|
28
|
+
fontSizeLarge: string;
|
|
29
|
+
lineHeight: string;
|
|
30
|
+
lineHeightTextarea: string;
|
|
31
|
+
borderRadius: string;
|
|
32
|
+
iconSize: string;
|
|
33
|
+
groupLabelColor: string;
|
|
34
|
+
groupLabelTextColor: string;
|
|
35
|
+
textColor: string;
|
|
36
|
+
textColorDisabled: string;
|
|
37
|
+
textDecorationColor: string;
|
|
38
|
+
caretColor: string;
|
|
39
|
+
placeholderColor: string;
|
|
40
|
+
placeholderColorDisabled: string;
|
|
41
|
+
color: string;
|
|
42
|
+
colorDisabled: string;
|
|
43
|
+
colorFocus: string;
|
|
44
|
+
groupLabelBorder: string;
|
|
45
|
+
border: string;
|
|
46
|
+
borderHover: string;
|
|
47
|
+
borderDisabled: string;
|
|
48
|
+
borderFocus: string;
|
|
49
|
+
boxShadowFocus: string;
|
|
50
|
+
loadingColor: string;
|
|
51
|
+
loadingColorWarning: string;
|
|
52
|
+
borderWarning: string;
|
|
53
|
+
borderHoverWarning: string;
|
|
54
|
+
colorFocusWarning: string;
|
|
55
|
+
borderFocusWarning: string;
|
|
56
|
+
boxShadowFocusWarning: string;
|
|
57
|
+
caretColorWarning: string;
|
|
58
|
+
loadingColorError: string;
|
|
59
|
+
borderError: string;
|
|
60
|
+
borderHoverError: string;
|
|
61
|
+
colorFocusError: string;
|
|
62
|
+
borderFocusError: string;
|
|
63
|
+
boxShadowFocusError: string;
|
|
64
|
+
caretColorError: string;
|
|
65
|
+
clearColor: string;
|
|
66
|
+
clearColorHover: string;
|
|
67
|
+
clearColorPressed: string;
|
|
68
|
+
iconColor: string;
|
|
69
|
+
iconColorDisabled: string;
|
|
70
|
+
iconColorHover: string;
|
|
71
|
+
iconColorPressed: string;
|
|
72
|
+
suffixTextColor: string;
|
|
73
|
+
paddingTiny: string;
|
|
74
|
+
paddingSmall: string;
|
|
75
|
+
paddingMedium: string;
|
|
76
|
+
paddingLarge: string;
|
|
77
|
+
clearSize: string;
|
|
78
|
+
}, any>;
|
|
79
|
+
}>;
|
|
80
|
+
export default inputOtpLight;
|
|
81
|
+
export type InputOtpTheme = typeof inputOtpLight;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createTheme } from "../../_mixins/index.mjs";
|
|
2
|
+
import { commonLight } from "../../_styles/common/index.mjs";
|
|
3
|
+
import { inputLight } from "../../input/styles/index.mjs";
|
|
4
|
+
export function self() {
|
|
5
|
+
return {
|
|
6
|
+
inputWidthSmall: '24px',
|
|
7
|
+
inputWidthMedium: '30px',
|
|
8
|
+
inputWidthLarge: '36px',
|
|
9
|
+
gapSmall: '8px',
|
|
10
|
+
gapMedium: '8px',
|
|
11
|
+
gapLarge: '8px'
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const inputOtpLight = createTheme({
|
|
15
|
+
name: 'InputOtp',
|
|
16
|
+
common: commonLight,
|
|
17
|
+
peers: {
|
|
18
|
+
Input: inputLight
|
|
19
|
+
},
|
|
20
|
+
self
|
|
21
|
+
});
|
|
22
|
+
export default inputOtpLight;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RenderLabel } from '../../_internal/select-menu/src/interface';
|
|
2
2
|
import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils';
|
|
3
|
-
import type { FormValidationStatus } from '../../form/src/
|
|
3
|
+
import type { FormValidationStatus } from '../../form/src/public-types';
|
|
4
4
|
import type { Size as InputSize } from '../../input/src/interface';
|
|
5
5
|
import type { SelectBaseOption, SelectGroupOption, SelectIgnoredOption } from '../../select/src/interface';
|
|
6
6
|
import type { MentionOption } from './interface';
|
|
@@ -85,8 +85,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
85
85
|
default: number;
|
|
86
86
|
};
|
|
87
87
|
}>> & Readonly<{}>, {
|
|
88
|
+
gapOffsetDegree: number;
|
|
88
89
|
percentage: number;
|
|
89
90
|
offsetDegree: number;
|
|
90
|
-
gapOffsetDegree: number;
|
|
91
91
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
92
92
|
export default _default;
|
|
@@ -77,7 +77,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
77
77
|
}>> & Readonly<{}>, {
|
|
78
78
|
railColor: string[];
|
|
79
79
|
fillColor: string[] | ProgressGradient[];
|
|
80
|
-
percentage: number[];
|
|
81
80
|
railStyle: (string | CSSProperties)[];
|
|
81
|
+
percentage: number[];
|
|
82
82
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
83
83
|
export default _default;
|
|
@@ -385,10 +385,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
385
385
|
readonly strokeWidth: number;
|
|
386
386
|
readonly unit: string;
|
|
387
387
|
readonly processing: boolean;
|
|
388
|
-
readonly showIndicator: boolean;
|
|
389
388
|
readonly viewBoxWidth: number;
|
|
389
|
+
readonly showIndicator: boolean;
|
|
390
|
+
readonly indicatorPosition: "inside" | "outside";
|
|
390
391
|
readonly indicatorPlacement: "inside" | "outside";
|
|
391
392
|
readonly circleGap: number;
|
|
392
|
-
readonly indicatorPosition: "inside" | "outside";
|
|
393
393
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
394
394
|
export default _default;
|
package/es/radio/src/Radio.mjs
CHANGED
|
@@ -88,7 +88,11 @@ export default defineComponent({
|
|
|
88
88
|
return h("label", {
|
|
89
89
|
class: [`${mergedClsPrefix}-radio`, this.themeClass, this.rtlEnabled && `${mergedClsPrefix}-radio--rtl`, this.mergedDisabled && `${mergedClsPrefix}-radio--disabled`, this.renderSafeChecked && `${mergedClsPrefix}-radio--checked`, this.focus && `${mergedClsPrefix}-radio--focus`],
|
|
90
90
|
style: this.cssVars
|
|
91
|
-
}, h("
|
|
91
|
+
}, h("div", {
|
|
92
|
+
class: `${mergedClsPrefix}-radio__dot-wrapper`
|
|
93
|
+
}, "\u00A0", h("div", {
|
|
94
|
+
class: [`${mergedClsPrefix}-radio__dot`, this.renderSafeChecked && `${mergedClsPrefix}-radio__dot--checked`]
|
|
95
|
+
}), h("input", {
|
|
92
96
|
ref: "inputRef",
|
|
93
97
|
type: "radio",
|
|
94
98
|
class: `${mergedClsPrefix}-radio-input`,
|
|
@@ -99,10 +103,6 @@ export default defineComponent({
|
|
|
99
103
|
onChange: this.handleRadioInputChange,
|
|
100
104
|
onFocus: this.handleRadioInputFocus,
|
|
101
105
|
onBlur: this.handleRadioInputBlur
|
|
102
|
-
}), h("div", {
|
|
103
|
-
class: `${mergedClsPrefix}-radio__dot-wrapper`
|
|
104
|
-
}, "\u00A0", h("div", {
|
|
105
|
-
class: [`${mergedClsPrefix}-radio__dot`, this.renderSafeChecked && `${mergedClsPrefix}-radio__dot--checked`]
|
|
106
106
|
})), resolveWrappedSlot($slots.default, children => {
|
|
107
107
|
if (!children && !label) return null;
|
|
108
108
|
return h("div", {
|
|
@@ -38,14 +38,10 @@ export default cB('radio', `
|
|
|
38
38
|
`), cB('radio-input', `
|
|
39
39
|
position: absolute;
|
|
40
40
|
border: 0;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
right: 0;
|
|
44
|
-
top: 0;
|
|
45
|
-
bottom: 0;
|
|
41
|
+
width: 0;
|
|
42
|
+
height: 0;
|
|
46
43
|
opacity: 0;
|
|
47
|
-
|
|
48
|
-
cursor: pointer;
|
|
44
|
+
margin: 0;
|
|
49
45
|
`), cE('dot', `
|
|
50
46
|
position: absolute;
|
|
51
47
|
top: 50%;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NodeProps, RenderLabel, RenderOption } from '../../_internal/select-menu/src/interface';
|
|
2
2
|
import type { RenderTag } from '../../_internal/selection/src/interface';
|
|
3
3
|
import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils';
|
|
4
|
-
import type { FormValidationStatus } from '../../form/src/
|
|
4
|
+
import type { FormValidationStatus } from '../../form/src/public-types';
|
|
5
5
|
import type { PopoverProps } from '../../popover';
|
|
6
6
|
import type { OnUpdateValue, SelectBaseOption, SelectFallbackOption, SelectFilter, SelectGroupOption, SelectIgnoredOption, SelectMixedOption, SelectOption, Size, Value, ValueAtom } from './interface';
|
|
7
7
|
import { type TreeNode } from 'treemate';
|
package/es/styles.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export { formDark } from './form/styles';
|
|
|
36
36
|
export { gradientTextDark } from './gradient-text/styles';
|
|
37
37
|
export { iconDark } from './icon/styles';
|
|
38
38
|
export { inputNumberDark, inputNumberRtl as unstableInputNumberRtl } from './input-number/styles';
|
|
39
|
+
export { inputOtpDark, inputOtpRtl as unstableInputOtpRtl } from './input-otp/styles';
|
|
39
40
|
export { inputDark, inputRtl as unstableInputRtl } from './input/styles';
|
|
40
41
|
export { layoutDark } from './layout/styles';
|
|
41
42
|
export { rowRtl as unstableRowRtl } from './legacy-grid/styles';
|
package/es/styles.mjs
CHANGED
|
@@ -37,6 +37,7 @@ export { formDark } from "./form/styles/index.mjs";
|
|
|
37
37
|
export { gradientTextDark } from "./gradient-text/styles/index.mjs";
|
|
38
38
|
export { iconDark } from "./icon/styles/index.mjs";
|
|
39
39
|
export { inputNumberDark, inputNumberRtl as unstableInputNumberRtl } from "./input-number/styles/index.mjs";
|
|
40
|
+
export { inputOtpDark, inputOtpRtl as unstableInputOtpRtl } from "./input-otp/styles/index.mjs";
|
|
40
41
|
export { inputDark, inputRtl as unstableInputRtl } from "./input/styles/index.mjs";
|
|
41
42
|
export { layoutDark } from "./layout/styles/index.mjs";
|
|
42
43
|
export { rowRtl as unstableRowRtl } from "./legacy-grid/styles/index.mjs";
|
package/es/tabs/src/TabPane.d.ts
CHANGED
package/es/themes/dark.mjs
CHANGED
|
@@ -71,7 +71,7 @@ import { spinDark } from "../spin/styles/index.mjs";
|
|
|
71
71
|
import { splitDark } from "../split/styles/index.mjs";
|
|
72
72
|
import { statisticDark } from "../statistic/styles/index.mjs";
|
|
73
73
|
import { stepsDark } from "../steps/styles/index.mjs";
|
|
74
|
-
import { flexDark } from "../styles.mjs";
|
|
74
|
+
import { flexDark, inputOtpDark } from "../styles.mjs";
|
|
75
75
|
import { switchDark } from "../switch/styles/index.mjs";
|
|
76
76
|
import { tableDark } from "../table/styles/index.mjs";
|
|
77
77
|
import { tabsDark } from "../tabs/styles/index.mjs";
|
|
@@ -129,6 +129,7 @@ export const darkTheme = {
|
|
|
129
129
|
Image: imageDark,
|
|
130
130
|
Input: inputDark,
|
|
131
131
|
InputNumber: inputNumberDark,
|
|
132
|
+
InputOtp: inputOtpDark,
|
|
132
133
|
LegacyTransfer: legacyTransferDark,
|
|
133
134
|
Layout: layoutDark,
|
|
134
135
|
List: listDark,
|