@hai-dev/ui-kit 1.0.11 → 1.1.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/{Box-D8oKffw9.js → Box-CykjCaXY.js} +21 -22
- package/dist/{Button-BBF8hp7e.js → Button-CcvrOEKV.js} +6 -5
- package/dist/{ButtonBase-T2KH9jsD.js → ButtonBase-DPLf5-lz.js} +226 -279
- package/dist/{CircularProgress-BQQkuSse.js → CircularProgress-CrHaMZDC.js} +4 -3
- package/dist/{Dialog-B97c7WYP.js → Dialog-DqFOpJyx.js} +118 -125
- package/dist/{DialogTitle-Du4tqTs0.js → DialogTitle-CeM_Z851.js} +4 -4
- package/dist/{Typography-r_TXEM1e.js → Typography-DDVoglvI.js} +38 -40
- package/dist/assets/centered-decorator.css +1 -0
- package/dist/assets/circular-progress-loader.css +1 -1
- package/dist/assets/code-input.css +1 -0
- package/dist/assets/dark-decorator.css +1 -0
- package/dist/assets/upload-dialog-errors.css +1 -1
- package/dist/chainPropTypes-C04Ex8aP.js +413 -0
- package/dist/components/button/button.js +1 -1
- package/dist/components/circular-progress-loader/circular-progress-loader.js +29 -27
- package/dist/components/circular-progress-loader/constants.d.ts +3 -1
- package/dist/components/circular-progress-loader/constants.js +4 -2
- package/dist/components/code-input/code-input.d.ts +3 -0
- package/dist/components/code-input/code-input.js +934 -0
- package/dist/components/code-input/code-input.stories.d.ts +7 -0
- package/dist/components/code-input/constants.d.ts +8 -0
- package/dist/components/code-input/constants.js +11 -0
- package/dist/components/code-input/index.d.ts +1 -0
- package/dist/components/code-input/index.js +4 -0
- package/dist/components/code-input/types.d.ts +11 -0
- package/dist/components/code-input/utils/get-code-input-label.d.ts +2 -0
- package/dist/components/code-input/utils/get-code-input-label.js +5 -0
- package/dist/components/code-input/utils/index.d.ts +2 -0
- package/dist/components/code-input/utils/index.js +6 -0
- package/dist/components/code-input/utils/slide-down-animate.d.ts +1 -0
- package/dist/components/code-input/utils/slide-down-animate.js +10 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +4 -2
- package/dist/components/photo-crop-uploader/components/error-upload-dialog/error-upload-dialog.js +6 -6
- package/dist/components/photo-crop-uploader/components/photo-list/photo-list.js +1 -1
- package/dist/components/photo-crop-uploader/components/upload-button/upload-button.js +1 -1
- package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog-errors.js +2 -2
- package/dist/components/photo-crop-uploader/components/upload-dialog/upload-dialog.js +12 -10
- package/dist/components/photo-crop-uploader/photo-crop-uploader.d.ts +2 -2
- package/dist/components/photo-crop-uploader/photo-crop-uploader.js +183 -168
- package/dist/components/photo-crop-uploader/types.d.ts +8 -7
- package/dist/components/photo-crop-uploader/utils/draw-cropped-image.js +28 -29
- package/dist/components/photo-crop-uploader/utils/get-default-cropped-photo.d.ts +4 -2
- package/dist/components/photo-crop-uploader/utils/get-default-cropped-photo.js +34 -32
- package/dist/createSimplePaletteValueFilter-B7--0ryQ.js +17 -0
- package/dist/{createTheme-RvzX1VSA.js → createTheme-RRQUOQoF.js} +182 -178
- package/dist/decorators/centered-decorator/centered-decorator.js +7 -0
- package/dist/decorators/centered-decorator/index.d.ts +2 -0
- package/dist/decorators/centered-decorator/index.js +4 -0
- package/dist/decorators/centered-decorator/types.js +1 -0
- package/dist/decorators/dark-decorator/dark-decorator.d.ts +3 -0
- package/dist/decorators/dark-decorator/dark-decorator.js +7 -0
- package/dist/decorators/dark-decorator/index.d.ts +2 -0
- package/dist/decorators/dark-decorator/index.js +4 -0
- package/dist/decorators/dark-decorator/types.d.ts +4 -0
- package/dist/decorators/dark-decorator/types.js +1 -0
- package/dist/decorators/index.d.ts +2 -1
- package/dist/decorators/index.js +4 -2
- package/dist/extendSxProp-VC2-7DJw.js +49 -0
- package/dist/index-BMkXyDFs.js +91 -0
- package/dist/isHostComponent-Dm_U9uOy.js +14 -0
- package/dist/memoTheme-5A7c_y33.js +15 -0
- package/dist/refType-CCKoQjVR.js +61 -0
- package/dist/{upload-dialog-errors-ku54UrUb.js → upload-dialog-errors-Bxun25O-.js} +41 -41
- package/package.json +1 -1
- package/dist/chainPropTypes-KIxDwPzf.js +0 -387
- package/dist/createSimplePaletteValueFilter-nb0wSOzC.js +0 -30
- package/dist/decorators/centered-decorator.js +0 -16
- package/dist/extendSxProp-BW9e6LtL.js +0 -36
- package/dist/useTheme-CsjkCBFJ.js +0 -16
- /package/dist/{decorators → components/code-input}/types.js +0 -0
- /package/dist/decorators/{centered-decorator.d.ts → centered-decorator/centered-decorator.d.ts} +0 -0
- /package/dist/decorators/{types.d.ts → centered-decorator/types.d.ts} +0 -0
|
@@ -0,0 +1,934 @@
|
|
|
1
|
+
import { jsxs as te, jsx as D } from "react/jsx-runtime";
|
|
2
|
+
import * as h from "react";
|
|
3
|
+
import { useState as Ve, useRef as Pe, useEffect as he } from "react";
|
|
4
|
+
import { c as We } from "../../index-B2JRaoNz.js";
|
|
5
|
+
import { DEFAULT_CODE_LENGTH as je, NOT_CODE_REGEX as Ke, BACKSPACE_KEY as qe, ARROW_LEFT_KEY as Ue, ARROW_RIGHT_KEY as Ge, ENTER_KEY as $e, CODE_REGEX as Q, TAB_KEY as Ye } from "./constants.js";
|
|
6
|
+
import { RU_LOCALE as Xe } from "../../constants.js";
|
|
7
|
+
import { P as e, a as Ze, g as Je, c as ye, b as ne, l as Qe } from "../../createTheme-RRQUOQoF.js";
|
|
8
|
+
import { g as et } from "../../index-BMkXyDFs.js";
|
|
9
|
+
import { m as ve } from "../../memoTheme-5A7c_y33.js";
|
|
10
|
+
import { u as tt, s as Ie, c as nt } from "../../chainPropTypes-C04Ex8aP.js";
|
|
11
|
+
import { u as Te, a as ot, b as oe, r as rt, e as it } from "../../refType-CCKoQjVR.js";
|
|
12
|
+
import { o as ge, i as be } from "../../isHostComponent-Dm_U9uOy.js";
|
|
13
|
+
import { getCodeInputLabel as at } from "./utils/get-code-input-label.js";
|
|
14
|
+
import { slideDownAnimation as ee } from "./utils/slide-down-animate.js";
|
|
15
|
+
import '../../assets/code-input.css';function st(n, r = 166) {
|
|
16
|
+
let i;
|
|
17
|
+
function d(...s) {
|
|
18
|
+
const y = () => {
|
|
19
|
+
n.apply(this, s);
|
|
20
|
+
};
|
|
21
|
+
clearTimeout(i), i = setTimeout(y, r);
|
|
22
|
+
}
|
|
23
|
+
return d.clear = () => {
|
|
24
|
+
clearTimeout(i);
|
|
25
|
+
}, d;
|
|
26
|
+
}
|
|
27
|
+
function P(n) {
|
|
28
|
+
return parseInt(n, 10) || 0;
|
|
29
|
+
}
|
|
30
|
+
const lt = {
|
|
31
|
+
shadow: {
|
|
32
|
+
// Visibility needed to hide the extra text area on iPads
|
|
33
|
+
visibility: "hidden",
|
|
34
|
+
// Remove from the content flow
|
|
35
|
+
position: "absolute",
|
|
36
|
+
// Ignore the scrollbar width
|
|
37
|
+
overflow: "hidden",
|
|
38
|
+
height: 0,
|
|
39
|
+
top: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
// Create a new layer, increase the isolation of the computed values
|
|
42
|
+
transform: "translateZ(0)"
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
function ut(n) {
|
|
46
|
+
for (const r in n)
|
|
47
|
+
return !1;
|
|
48
|
+
return !0;
|
|
49
|
+
}
|
|
50
|
+
function we(n) {
|
|
51
|
+
return ut(n) || n.outerHeightStyle === 0 && !n.overflowing;
|
|
52
|
+
}
|
|
53
|
+
const Oe = /* @__PURE__ */ h.forwardRef(function(r, i) {
|
|
54
|
+
const {
|
|
55
|
+
onChange: d,
|
|
56
|
+
maxRows: s,
|
|
57
|
+
minRows: y = 1,
|
|
58
|
+
style: E,
|
|
59
|
+
value: I,
|
|
60
|
+
...z
|
|
61
|
+
} = r, {
|
|
62
|
+
current: b
|
|
63
|
+
} = h.useRef(I != null), g = h.useRef(null), p = Te(i, g), w = h.useRef(null), O = h.useRef(null), S = h.useCallback(() => {
|
|
64
|
+
const t = g.current, o = O.current;
|
|
65
|
+
if (!t || !o)
|
|
66
|
+
return;
|
|
67
|
+
const c = ge(t).getComputedStyle(t);
|
|
68
|
+
if (c.width === "0px")
|
|
69
|
+
return {
|
|
70
|
+
outerHeightStyle: 0,
|
|
71
|
+
overflowing: !1
|
|
72
|
+
};
|
|
73
|
+
o.style.width = c.width, o.value = t.value || r.placeholder || "x", o.value.slice(-1) === `
|
|
74
|
+
` && (o.value += " ");
|
|
75
|
+
const C = c.boxSizing, T = P(c.paddingBottom) + P(c.paddingTop), W = P(c.borderBottomWidth) + P(c.borderTopWidth), A = o.scrollHeight;
|
|
76
|
+
o.value = "x";
|
|
77
|
+
const M = o.scrollHeight;
|
|
78
|
+
let R = A;
|
|
79
|
+
y && (R = Math.max(Number(y) * M, R)), s && (R = Math.min(Number(s) * M, R)), R = Math.max(R, M);
|
|
80
|
+
const H = R + (C === "border-box" ? T + W : 0), j = Math.abs(R - A) <= 1;
|
|
81
|
+
return {
|
|
82
|
+
outerHeightStyle: H,
|
|
83
|
+
overflowing: j
|
|
84
|
+
};
|
|
85
|
+
}, [s, y, r.placeholder]), N = ot(() => {
|
|
86
|
+
const t = g.current, o = S();
|
|
87
|
+
if (!t || !o || we(o))
|
|
88
|
+
return !1;
|
|
89
|
+
const u = o.outerHeightStyle;
|
|
90
|
+
return w.current != null && w.current !== u;
|
|
91
|
+
}), k = h.useCallback(() => {
|
|
92
|
+
const t = g.current, o = S();
|
|
93
|
+
if (!t || !o || we(o))
|
|
94
|
+
return;
|
|
95
|
+
const u = o.outerHeightStyle;
|
|
96
|
+
w.current !== u && (w.current = u, t.style.height = `${u}px`), t.style.overflow = o.overflowing ? "hidden" : "";
|
|
97
|
+
}, [S]), l = h.useRef(-1);
|
|
98
|
+
oe(() => {
|
|
99
|
+
const t = st(k), o = g?.current;
|
|
100
|
+
if (!o)
|
|
101
|
+
return;
|
|
102
|
+
const u = ge(o);
|
|
103
|
+
u.addEventListener("resize", t);
|
|
104
|
+
let c;
|
|
105
|
+
return typeof ResizeObserver < "u" && (c = new ResizeObserver(() => {
|
|
106
|
+
N() && (c.unobserve(o), cancelAnimationFrame(l.current), k(), l.current = requestAnimationFrame(() => {
|
|
107
|
+
c.observe(o);
|
|
108
|
+
}));
|
|
109
|
+
}), c.observe(o)), () => {
|
|
110
|
+
t.clear(), cancelAnimationFrame(l.current), u.removeEventListener("resize", t), c && c.disconnect();
|
|
111
|
+
};
|
|
112
|
+
}, [S, k, N]), oe(() => {
|
|
113
|
+
k();
|
|
114
|
+
});
|
|
115
|
+
const a = (t) => {
|
|
116
|
+
b || k();
|
|
117
|
+
const o = t.target, u = o.value.length, c = o.value.endsWith(`
|
|
118
|
+
`), C = o.selectionStart === u;
|
|
119
|
+
c && C && o.setSelectionRange(u, u), d && d(t);
|
|
120
|
+
};
|
|
121
|
+
return /* @__PURE__ */ te(h.Fragment, {
|
|
122
|
+
children: [/* @__PURE__ */ D("textarea", {
|
|
123
|
+
value: I,
|
|
124
|
+
onChange: a,
|
|
125
|
+
ref: p,
|
|
126
|
+
rows: y,
|
|
127
|
+
style: E,
|
|
128
|
+
...z
|
|
129
|
+
}), /* @__PURE__ */ D("textarea", {
|
|
130
|
+
"aria-hidden": !0,
|
|
131
|
+
className: r.className,
|
|
132
|
+
readOnly: !0,
|
|
133
|
+
ref: O,
|
|
134
|
+
tabIndex: -1,
|
|
135
|
+
style: {
|
|
136
|
+
...lt.shadow,
|
|
137
|
+
...E,
|
|
138
|
+
paddingTop: 0,
|
|
139
|
+
paddingBottom: 0
|
|
140
|
+
}
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
process.env.NODE_ENV !== "production" && (Oe.propTypes = {
|
|
145
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
146
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
147
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
148
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
149
|
+
/**
|
|
150
|
+
* @ignore
|
|
151
|
+
*/
|
|
152
|
+
className: e.string,
|
|
153
|
+
/**
|
|
154
|
+
* Maximum number of rows to display.
|
|
155
|
+
*/
|
|
156
|
+
maxRows: e.oneOfType([e.number, e.string]),
|
|
157
|
+
/**
|
|
158
|
+
* Minimum number of rows to display.
|
|
159
|
+
* @default 1
|
|
160
|
+
*/
|
|
161
|
+
minRows: e.oneOfType([e.number, e.string]),
|
|
162
|
+
/**
|
|
163
|
+
* @ignore
|
|
164
|
+
*/
|
|
165
|
+
onChange: e.func,
|
|
166
|
+
/**
|
|
167
|
+
* @ignore
|
|
168
|
+
*/
|
|
169
|
+
placeholder: e.string,
|
|
170
|
+
/**
|
|
171
|
+
* @ignore
|
|
172
|
+
*/
|
|
173
|
+
style: e.object,
|
|
174
|
+
/**
|
|
175
|
+
* @ignore
|
|
176
|
+
*/
|
|
177
|
+
value: e.oneOfType([e.arrayOf(e.string), e.number, e.string])
|
|
178
|
+
});
|
|
179
|
+
function ct({
|
|
180
|
+
props: n,
|
|
181
|
+
states: r,
|
|
182
|
+
muiFormControl: i
|
|
183
|
+
}) {
|
|
184
|
+
return r.reduce((d, s) => (d[s] = n[s], i && typeof n[s] > "u" && (d[s] = i[s]), d), {});
|
|
185
|
+
}
|
|
186
|
+
const ie = /* @__PURE__ */ h.createContext(void 0);
|
|
187
|
+
process.env.NODE_ENV !== "production" && (ie.displayName = "FormControlContext");
|
|
188
|
+
function dt() {
|
|
189
|
+
return h.useContext(ie);
|
|
190
|
+
}
|
|
191
|
+
function Ce(n) {
|
|
192
|
+
return n != null && !(Array.isArray(n) && n.length === 0);
|
|
193
|
+
}
|
|
194
|
+
function pt(n, r = !1) {
|
|
195
|
+
return n && (Ce(n.value) && n.value !== "" || r && Ce(n.defaultValue) && n.defaultValue !== "");
|
|
196
|
+
}
|
|
197
|
+
function ft(n) {
|
|
198
|
+
return Je("MuiInputBase", n);
|
|
199
|
+
}
|
|
200
|
+
const re = Ze("MuiInputBase", ["root", "formControl", "focused", "disabled", "adornedStart", "adornedEnd", "error", "sizeSmall", "multiline", "colorSecondary", "fullWidth", "hiddenLabel", "readOnly", "input", "inputSizeSmall", "inputMultiline", "inputTypeSearch", "inputAdornedStart", "inputAdornedEnd", "inputHiddenLabel"]);
|
|
201
|
+
var Ee;
|
|
202
|
+
const mt = (n, r) => {
|
|
203
|
+
const {
|
|
204
|
+
ownerState: i
|
|
205
|
+
} = n;
|
|
206
|
+
return [r.root, i.formControl && r.formControl, i.startAdornment && r.adornedStart, i.endAdornment && r.adornedEnd, i.error && r.error, i.size === "small" && r.sizeSmall, i.multiline && r.multiline, i.color && r[`color${ne(i.color)}`], i.fullWidth && r.fullWidth, i.hiddenLabel && r.hiddenLabel];
|
|
207
|
+
}, ht = (n, r) => {
|
|
208
|
+
const {
|
|
209
|
+
ownerState: i
|
|
210
|
+
} = n;
|
|
211
|
+
return [r.input, i.size === "small" && r.inputSizeSmall, i.multiline && r.inputMultiline, i.type === "search" && r.inputTypeSearch, i.startAdornment && r.inputAdornedStart, i.endAdornment && r.inputAdornedEnd, i.hiddenLabel && r.inputHiddenLabel];
|
|
212
|
+
}, yt = (n) => {
|
|
213
|
+
const {
|
|
214
|
+
classes: r,
|
|
215
|
+
color: i,
|
|
216
|
+
disabled: d,
|
|
217
|
+
error: s,
|
|
218
|
+
endAdornment: y,
|
|
219
|
+
focused: E,
|
|
220
|
+
formControl: I,
|
|
221
|
+
fullWidth: z,
|
|
222
|
+
hiddenLabel: b,
|
|
223
|
+
multiline: g,
|
|
224
|
+
readOnly: p,
|
|
225
|
+
size: w,
|
|
226
|
+
startAdornment: O,
|
|
227
|
+
type: S
|
|
228
|
+
} = n, N = {
|
|
229
|
+
root: ["root", `color${ne(i)}`, d && "disabled", s && "error", z && "fullWidth", E && "focused", I && "formControl", w && w !== "medium" && `size${ne(w)}`, g && "multiline", O && "adornedStart", y && "adornedEnd", b && "hiddenLabel", p && "readOnly"],
|
|
230
|
+
input: ["input", d && "disabled", S === "search" && "inputTypeSearch", g && "inputMultiline", w === "small" && "inputSizeSmall", b && "inputHiddenLabel", O && "inputAdornedStart", y && "inputAdornedEnd", p && "readOnly"]
|
|
231
|
+
};
|
|
232
|
+
return nt(N, ft, r);
|
|
233
|
+
}, gt = Ie("div", {
|
|
234
|
+
name: "MuiInputBase",
|
|
235
|
+
slot: "Root",
|
|
236
|
+
overridesResolver: mt
|
|
237
|
+
})(ve(({
|
|
238
|
+
theme: n
|
|
239
|
+
}) => ({
|
|
240
|
+
...n.typography.body1,
|
|
241
|
+
color: (n.vars || n).palette.text.primary,
|
|
242
|
+
lineHeight: "1.4375em",
|
|
243
|
+
// 23px
|
|
244
|
+
boxSizing: "border-box",
|
|
245
|
+
// Prevent padding issue with fullWidth.
|
|
246
|
+
position: "relative",
|
|
247
|
+
cursor: "text",
|
|
248
|
+
display: "inline-flex",
|
|
249
|
+
alignItems: "center",
|
|
250
|
+
[`&.${re.disabled}`]: {
|
|
251
|
+
color: (n.vars || n).palette.text.disabled,
|
|
252
|
+
cursor: "default"
|
|
253
|
+
},
|
|
254
|
+
variants: [{
|
|
255
|
+
props: ({
|
|
256
|
+
ownerState: r
|
|
257
|
+
}) => r.multiline,
|
|
258
|
+
style: {
|
|
259
|
+
padding: "4px 0 5px"
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
props: ({
|
|
263
|
+
ownerState: r,
|
|
264
|
+
size: i
|
|
265
|
+
}) => r.multiline && i === "small",
|
|
266
|
+
style: {
|
|
267
|
+
paddingTop: 1
|
|
268
|
+
}
|
|
269
|
+
}, {
|
|
270
|
+
props: ({
|
|
271
|
+
ownerState: r
|
|
272
|
+
}) => r.fullWidth,
|
|
273
|
+
style: {
|
|
274
|
+
width: "100%"
|
|
275
|
+
}
|
|
276
|
+
}]
|
|
277
|
+
}))), bt = Ie("input", {
|
|
278
|
+
name: "MuiInputBase",
|
|
279
|
+
slot: "Input",
|
|
280
|
+
overridesResolver: ht
|
|
281
|
+
})(ve(({
|
|
282
|
+
theme: n
|
|
283
|
+
}) => {
|
|
284
|
+
const r = n.palette.mode === "light", i = {
|
|
285
|
+
color: "currentColor",
|
|
286
|
+
...n.vars ? {
|
|
287
|
+
opacity: n.vars.opacity.inputPlaceholder
|
|
288
|
+
} : {
|
|
289
|
+
opacity: r ? 0.42 : 0.5
|
|
290
|
+
},
|
|
291
|
+
transition: n.transitions.create("opacity", {
|
|
292
|
+
duration: n.transitions.duration.shorter
|
|
293
|
+
})
|
|
294
|
+
}, d = {
|
|
295
|
+
opacity: "0 !important"
|
|
296
|
+
}, s = n.vars ? {
|
|
297
|
+
opacity: n.vars.opacity.inputPlaceholder
|
|
298
|
+
} : {
|
|
299
|
+
opacity: r ? 0.42 : 0.5
|
|
300
|
+
};
|
|
301
|
+
return {
|
|
302
|
+
font: "inherit",
|
|
303
|
+
letterSpacing: "inherit",
|
|
304
|
+
color: "currentColor",
|
|
305
|
+
padding: "4px 0 5px",
|
|
306
|
+
border: 0,
|
|
307
|
+
boxSizing: "content-box",
|
|
308
|
+
background: "none",
|
|
309
|
+
height: "1.4375em",
|
|
310
|
+
// Reset 23pxthe native input line-height
|
|
311
|
+
margin: 0,
|
|
312
|
+
// Reset for Safari
|
|
313
|
+
WebkitTapHighlightColor: "transparent",
|
|
314
|
+
display: "block",
|
|
315
|
+
// Make the flex item shrink with Firefox
|
|
316
|
+
minWidth: 0,
|
|
317
|
+
width: "100%",
|
|
318
|
+
"&::-webkit-input-placeholder": i,
|
|
319
|
+
"&::-moz-placeholder": i,
|
|
320
|
+
// Firefox 19+
|
|
321
|
+
"&::-ms-input-placeholder": i,
|
|
322
|
+
// Edge
|
|
323
|
+
"&:focus": {
|
|
324
|
+
outline: 0
|
|
325
|
+
},
|
|
326
|
+
// Reset Firefox invalid required input style
|
|
327
|
+
"&:invalid": {
|
|
328
|
+
boxShadow: "none"
|
|
329
|
+
},
|
|
330
|
+
"&::-webkit-search-decoration": {
|
|
331
|
+
// Remove the padding when type=search.
|
|
332
|
+
WebkitAppearance: "none"
|
|
333
|
+
},
|
|
334
|
+
// Show and hide the placeholder logic
|
|
335
|
+
[`label[data-shrink=false] + .${re.formControl} &`]: {
|
|
336
|
+
"&::-webkit-input-placeholder": d,
|
|
337
|
+
"&::-moz-placeholder": d,
|
|
338
|
+
// Firefox 19+
|
|
339
|
+
"&::-ms-input-placeholder": d,
|
|
340
|
+
// Edge
|
|
341
|
+
"&:focus::-webkit-input-placeholder": s,
|
|
342
|
+
"&:focus::-moz-placeholder": s,
|
|
343
|
+
// Firefox 19+
|
|
344
|
+
"&:focus::-ms-input-placeholder": s
|
|
345
|
+
// Edge
|
|
346
|
+
},
|
|
347
|
+
[`&.${re.disabled}`]: {
|
|
348
|
+
opacity: 1,
|
|
349
|
+
// Reset iOS opacity
|
|
350
|
+
WebkitTextFillColor: (n.vars || n).palette.text.disabled
|
|
351
|
+
// Fix opacity Safari bug
|
|
352
|
+
},
|
|
353
|
+
variants: [{
|
|
354
|
+
props: ({
|
|
355
|
+
ownerState: y
|
|
356
|
+
}) => !y.disableInjectingGlobalStyles,
|
|
357
|
+
style: {
|
|
358
|
+
animationName: "mui-auto-fill-cancel",
|
|
359
|
+
animationDuration: "10ms",
|
|
360
|
+
"&:-webkit-autofill": {
|
|
361
|
+
animationDuration: "5000s",
|
|
362
|
+
animationName: "mui-auto-fill"
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}, {
|
|
366
|
+
props: {
|
|
367
|
+
size: "small"
|
|
368
|
+
},
|
|
369
|
+
style: {
|
|
370
|
+
paddingTop: 1
|
|
371
|
+
}
|
|
372
|
+
}, {
|
|
373
|
+
props: ({
|
|
374
|
+
ownerState: y
|
|
375
|
+
}) => y.multiline,
|
|
376
|
+
style: {
|
|
377
|
+
height: "auto",
|
|
378
|
+
resize: "none",
|
|
379
|
+
padding: 0,
|
|
380
|
+
paddingTop: 0
|
|
381
|
+
}
|
|
382
|
+
}, {
|
|
383
|
+
props: {
|
|
384
|
+
type: "search"
|
|
385
|
+
},
|
|
386
|
+
style: {
|
|
387
|
+
MozAppearance: "textfield"
|
|
388
|
+
// Improve type search style.
|
|
389
|
+
}
|
|
390
|
+
}]
|
|
391
|
+
};
|
|
392
|
+
})), Se = et({
|
|
393
|
+
"@keyframes mui-auto-fill": {
|
|
394
|
+
from: {
|
|
395
|
+
display: "block"
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
"@keyframes mui-auto-fill-cancel": {
|
|
399
|
+
from: {
|
|
400
|
+
display: "block"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}), ke = /* @__PURE__ */ h.forwardRef(function(r, i) {
|
|
404
|
+
const d = tt({
|
|
405
|
+
props: r,
|
|
406
|
+
name: "MuiInputBase"
|
|
407
|
+
}), {
|
|
408
|
+
"aria-describedby": s,
|
|
409
|
+
autoComplete: y,
|
|
410
|
+
autoFocus: E,
|
|
411
|
+
className: I,
|
|
412
|
+
color: z,
|
|
413
|
+
components: b = {},
|
|
414
|
+
componentsProps: g = {},
|
|
415
|
+
defaultValue: p,
|
|
416
|
+
disabled: w,
|
|
417
|
+
disableInjectingGlobalStyles: O,
|
|
418
|
+
endAdornment: S,
|
|
419
|
+
error: N,
|
|
420
|
+
fullWidth: k = !1,
|
|
421
|
+
id: l,
|
|
422
|
+
inputComponent: a = "input",
|
|
423
|
+
inputProps: t = {},
|
|
424
|
+
inputRef: o,
|
|
425
|
+
margin: u,
|
|
426
|
+
maxRows: c,
|
|
427
|
+
minRows: C,
|
|
428
|
+
multiline: T = !1,
|
|
429
|
+
name: W,
|
|
430
|
+
onBlur: A,
|
|
431
|
+
onChange: M,
|
|
432
|
+
onClick: R,
|
|
433
|
+
onFocus: H,
|
|
434
|
+
onKeyDown: j,
|
|
435
|
+
onKeyUp: xe,
|
|
436
|
+
placeholder: Ae,
|
|
437
|
+
readOnly: K,
|
|
438
|
+
renderSuffix: ae,
|
|
439
|
+
rows: L,
|
|
440
|
+
size: Et,
|
|
441
|
+
slotProps: se = {},
|
|
442
|
+
slots: le = {},
|
|
443
|
+
startAdornment: _,
|
|
444
|
+
type: ue = "text",
|
|
445
|
+
value: Ne,
|
|
446
|
+
...De
|
|
447
|
+
} = d, V = t.value != null ? t.value : Ne, {
|
|
448
|
+
current: q
|
|
449
|
+
} = h.useRef(V != null), F = h.useRef(), ze = h.useCallback((f) => {
|
|
450
|
+
process.env.NODE_ENV !== "production" && f && f.nodeName !== "INPUT" && !f.focus && console.error(["MUI: You have provided a `inputComponent` to the input component", "that does not correctly handle the `ref` prop.", "Make sure the `ref` prop is called with a HTMLInputElement."].join(`
|
|
451
|
+
`));
|
|
452
|
+
}, []), Me = Te(F, o, t.ref, ze), [U, G] = h.useState(!1), m = dt();
|
|
453
|
+
process.env.NODE_ENV !== "production" && h.useEffect(() => {
|
|
454
|
+
if (m)
|
|
455
|
+
return m.registerEffect();
|
|
456
|
+
}, [m]);
|
|
457
|
+
const v = ct({
|
|
458
|
+
props: d,
|
|
459
|
+
muiFormControl: m,
|
|
460
|
+
states: ["color", "disabled", "error", "hiddenLabel", "size", "required", "filled"]
|
|
461
|
+
});
|
|
462
|
+
v.focused = m ? m.focused : U, h.useEffect(() => {
|
|
463
|
+
!m && w && U && (G(!1), A && A());
|
|
464
|
+
}, [m, w, U, A]);
|
|
465
|
+
const $ = m && m.onFilled, Y = m && m.onEmpty, B = h.useCallback((f) => {
|
|
466
|
+
pt(f) ? $ && $() : Y && Y();
|
|
467
|
+
}, [$, Y]);
|
|
468
|
+
oe(() => {
|
|
469
|
+
q && B({
|
|
470
|
+
value: V
|
|
471
|
+
});
|
|
472
|
+
}, [V, B, q]);
|
|
473
|
+
const Fe = (f) => {
|
|
474
|
+
H && H(f), t.onFocus && t.onFocus(f), m && m.onFocus ? m.onFocus(f) : G(!0);
|
|
475
|
+
}, _e = (f) => {
|
|
476
|
+
A && A(f), t.onBlur && t.onBlur(f), m && m.onBlur ? m.onBlur(f) : G(!1);
|
|
477
|
+
}, Be = (f, ...fe) => {
|
|
478
|
+
if (!q) {
|
|
479
|
+
const me = f.target || F.current;
|
|
480
|
+
if (me == null)
|
|
481
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "MUI: Expected valid input target. Did you use a custom `inputComponent` and forget to forward refs? See https://mui.com/r/input-component-ref-interface for more info." : Qe(1));
|
|
482
|
+
B({
|
|
483
|
+
value: me.value
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
t.onChange && t.onChange(f, ...fe), M && M(f, ...fe);
|
|
487
|
+
};
|
|
488
|
+
h.useEffect(() => {
|
|
489
|
+
B(F.current);
|
|
490
|
+
}, []);
|
|
491
|
+
const He = (f) => {
|
|
492
|
+
F.current && f.currentTarget === f.target && F.current.focus(), R && R(f);
|
|
493
|
+
};
|
|
494
|
+
let X = a, x = t;
|
|
495
|
+
T && X === "input" && (L ? (process.env.NODE_ENV !== "production" && (C || c) && console.warn("MUI: You can not use the `minRows` or `maxRows` props when the input `rows` prop is set."), x = {
|
|
496
|
+
type: void 0,
|
|
497
|
+
minRows: L,
|
|
498
|
+
maxRows: L,
|
|
499
|
+
...x
|
|
500
|
+
}) : x = {
|
|
501
|
+
type: void 0,
|
|
502
|
+
maxRows: c,
|
|
503
|
+
minRows: C,
|
|
504
|
+
...x
|
|
505
|
+
}, X = Oe);
|
|
506
|
+
const Le = (f) => {
|
|
507
|
+
B(f.animationName === "mui-auto-fill-cancel" ? F.current : {
|
|
508
|
+
value: "x"
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
h.useEffect(() => {
|
|
512
|
+
m && m.setAdornedStart(!!_);
|
|
513
|
+
}, [m, _]);
|
|
514
|
+
const Z = {
|
|
515
|
+
...d,
|
|
516
|
+
color: v.color || "primary",
|
|
517
|
+
disabled: v.disabled,
|
|
518
|
+
endAdornment: S,
|
|
519
|
+
error: v.error,
|
|
520
|
+
focused: v.focused,
|
|
521
|
+
formControl: m,
|
|
522
|
+
fullWidth: k,
|
|
523
|
+
hiddenLabel: v.hiddenLabel,
|
|
524
|
+
multiline: T,
|
|
525
|
+
size: v.size,
|
|
526
|
+
startAdornment: _,
|
|
527
|
+
type: ue
|
|
528
|
+
}, ce = yt(Z), de = le.root || b.Root || gt, J = se.root || g.root || {}, pe = le.input || b.Input || bt;
|
|
529
|
+
return x = {
|
|
530
|
+
...x,
|
|
531
|
+
...se.input ?? g.input
|
|
532
|
+
}, /* @__PURE__ */ te(h.Fragment, {
|
|
533
|
+
children: [!O && typeof Se == "function" && // For Emotion/Styled-components, InputGlobalStyles will be a function
|
|
534
|
+
// For Pigment CSS, this has no effect because the InputGlobalStyles will be null.
|
|
535
|
+
(Ee || (Ee = /* @__PURE__ */ D(Se, {}))), /* @__PURE__ */ te(de, {
|
|
536
|
+
...J,
|
|
537
|
+
ref: i,
|
|
538
|
+
onClick: He,
|
|
539
|
+
...De,
|
|
540
|
+
...!be(de) && {
|
|
541
|
+
ownerState: {
|
|
542
|
+
...Z,
|
|
543
|
+
...J.ownerState
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
className: ye(ce.root, J.className, I, K && "MuiInputBase-readOnly"),
|
|
547
|
+
children: [_, /* @__PURE__ */ D(ie.Provider, {
|
|
548
|
+
value: null,
|
|
549
|
+
children: /* @__PURE__ */ D(pe, {
|
|
550
|
+
"aria-invalid": v.error,
|
|
551
|
+
"aria-describedby": s,
|
|
552
|
+
autoComplete: y,
|
|
553
|
+
autoFocus: E,
|
|
554
|
+
defaultValue: p,
|
|
555
|
+
disabled: v.disabled,
|
|
556
|
+
id: l,
|
|
557
|
+
onAnimationStart: Le,
|
|
558
|
+
name: W,
|
|
559
|
+
placeholder: Ae,
|
|
560
|
+
readOnly: K,
|
|
561
|
+
required: v.required,
|
|
562
|
+
rows: L,
|
|
563
|
+
value: V,
|
|
564
|
+
onKeyDown: j,
|
|
565
|
+
onKeyUp: xe,
|
|
566
|
+
type: ue,
|
|
567
|
+
...x,
|
|
568
|
+
...!be(pe) && {
|
|
569
|
+
as: X,
|
|
570
|
+
ownerState: {
|
|
571
|
+
...Z,
|
|
572
|
+
...x.ownerState
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
ref: Me,
|
|
576
|
+
className: ye(ce.input, x.className, K && "MuiInputBase-readOnly"),
|
|
577
|
+
onBlur: _e,
|
|
578
|
+
onChange: Be,
|
|
579
|
+
onFocus: Fe
|
|
580
|
+
})
|
|
581
|
+
}), S, ae ? ae({
|
|
582
|
+
...v,
|
|
583
|
+
startAdornment: _
|
|
584
|
+
}) : null]
|
|
585
|
+
})]
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
process.env.NODE_ENV !== "production" && (ke.propTypes = {
|
|
589
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
590
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
591
|
+
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
592
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
593
|
+
/**
|
|
594
|
+
* @ignore
|
|
595
|
+
*/
|
|
596
|
+
"aria-describedby": e.string,
|
|
597
|
+
/**
|
|
598
|
+
* This prop helps users to fill forms faster, especially on mobile devices.
|
|
599
|
+
* The name can be confusing, as it's more like an autofill.
|
|
600
|
+
* You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).
|
|
601
|
+
*/
|
|
602
|
+
autoComplete: e.string,
|
|
603
|
+
/**
|
|
604
|
+
* If `true`, the `input` element is focused during the first mount.
|
|
605
|
+
*/
|
|
606
|
+
autoFocus: e.bool,
|
|
607
|
+
/**
|
|
608
|
+
* Override or extend the styles applied to the component.
|
|
609
|
+
*/
|
|
610
|
+
classes: e.object,
|
|
611
|
+
/**
|
|
612
|
+
* @ignore
|
|
613
|
+
*/
|
|
614
|
+
className: e.string,
|
|
615
|
+
/**
|
|
616
|
+
* The color of the component.
|
|
617
|
+
* It supports both default and custom theme colors, which can be added as shown in the
|
|
618
|
+
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
|
619
|
+
* The prop defaults to the value (`'primary'`) inherited from the parent FormControl component.
|
|
620
|
+
*/
|
|
621
|
+
color: e.oneOfType([e.oneOf(["primary", "secondary", "error", "info", "success", "warning"]), e.string]),
|
|
622
|
+
/**
|
|
623
|
+
* The components used for each slot inside.
|
|
624
|
+
*
|
|
625
|
+
* @deprecated use the `slots` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
626
|
+
*
|
|
627
|
+
* @default {}
|
|
628
|
+
*/
|
|
629
|
+
components: e.shape({
|
|
630
|
+
Input: e.elementType,
|
|
631
|
+
Root: e.elementType
|
|
632
|
+
}),
|
|
633
|
+
/**
|
|
634
|
+
* The extra props for the slot components.
|
|
635
|
+
* You can override the existing props or add new ones.
|
|
636
|
+
*
|
|
637
|
+
* @deprecated use the `slotProps` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
638
|
+
*
|
|
639
|
+
* @default {}
|
|
640
|
+
*/
|
|
641
|
+
componentsProps: e.shape({
|
|
642
|
+
input: e.object,
|
|
643
|
+
root: e.object
|
|
644
|
+
}),
|
|
645
|
+
/**
|
|
646
|
+
* The default value. Use when the component is not controlled.
|
|
647
|
+
*/
|
|
648
|
+
defaultValue: e.any,
|
|
649
|
+
/**
|
|
650
|
+
* If `true`, the component is disabled.
|
|
651
|
+
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
|
652
|
+
*/
|
|
653
|
+
disabled: e.bool,
|
|
654
|
+
/**
|
|
655
|
+
* If `true`, GlobalStyles for the auto-fill keyframes will not be injected/removed on mount/unmount. Make sure to inject them at the top of your application.
|
|
656
|
+
* This option is intended to help with boosting the initial rendering performance if you are loading a big amount of Input components at once.
|
|
657
|
+
* @default false
|
|
658
|
+
*/
|
|
659
|
+
disableInjectingGlobalStyles: e.bool,
|
|
660
|
+
/**
|
|
661
|
+
* End `InputAdornment` for this component.
|
|
662
|
+
*/
|
|
663
|
+
endAdornment: e.node,
|
|
664
|
+
/**
|
|
665
|
+
* If `true`, the `input` will indicate an error.
|
|
666
|
+
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
|
667
|
+
*/
|
|
668
|
+
error: e.bool,
|
|
669
|
+
/**
|
|
670
|
+
* If `true`, the `input` will take up the full width of its container.
|
|
671
|
+
* @default false
|
|
672
|
+
*/
|
|
673
|
+
fullWidth: e.bool,
|
|
674
|
+
/**
|
|
675
|
+
* The id of the `input` element.
|
|
676
|
+
*/
|
|
677
|
+
id: e.string,
|
|
678
|
+
/**
|
|
679
|
+
* The component used for the `input` element.
|
|
680
|
+
* Either a string to use a HTML element or a component.
|
|
681
|
+
* @default 'input'
|
|
682
|
+
*/
|
|
683
|
+
inputComponent: it,
|
|
684
|
+
/**
|
|
685
|
+
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#attributes) applied to the `input` element.
|
|
686
|
+
* @default {}
|
|
687
|
+
*/
|
|
688
|
+
inputProps: e.object,
|
|
689
|
+
/**
|
|
690
|
+
* Pass a ref to the `input` element.
|
|
691
|
+
*/
|
|
692
|
+
inputRef: rt,
|
|
693
|
+
/**
|
|
694
|
+
* If `dense`, will adjust vertical spacing. This is normally obtained via context from
|
|
695
|
+
* FormControl.
|
|
696
|
+
* The prop defaults to the value (`'none'`) inherited from the parent FormControl component.
|
|
697
|
+
*/
|
|
698
|
+
margin: e.oneOf(["dense", "none"]),
|
|
699
|
+
/**
|
|
700
|
+
* Maximum number of rows to display when multiline option is set to true.
|
|
701
|
+
*/
|
|
702
|
+
maxRows: e.oneOfType([e.number, e.string]),
|
|
703
|
+
/**
|
|
704
|
+
* Minimum number of rows to display when multiline option is set to true.
|
|
705
|
+
*/
|
|
706
|
+
minRows: e.oneOfType([e.number, e.string]),
|
|
707
|
+
/**
|
|
708
|
+
* If `true`, a [TextareaAutosize](https://mui.com/material-ui/react-textarea-autosize/) element is rendered.
|
|
709
|
+
* @default false
|
|
710
|
+
*/
|
|
711
|
+
multiline: e.bool,
|
|
712
|
+
/**
|
|
713
|
+
* Name attribute of the `input` element.
|
|
714
|
+
*/
|
|
715
|
+
name: e.string,
|
|
716
|
+
/**
|
|
717
|
+
* Callback fired when the `input` is blurred.
|
|
718
|
+
*
|
|
719
|
+
* Notice that the first argument (event) might be undefined.
|
|
720
|
+
*/
|
|
721
|
+
onBlur: e.func,
|
|
722
|
+
/**
|
|
723
|
+
* Callback fired when the value is changed.
|
|
724
|
+
*
|
|
725
|
+
* @param {React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>} event The event source of the callback.
|
|
726
|
+
* You can pull out the new value by accessing `event.target.value` (string).
|
|
727
|
+
*/
|
|
728
|
+
onChange: e.func,
|
|
729
|
+
/**
|
|
730
|
+
* @ignore
|
|
731
|
+
*/
|
|
732
|
+
onClick: e.func,
|
|
733
|
+
/**
|
|
734
|
+
* @ignore
|
|
735
|
+
*/
|
|
736
|
+
onFocus: e.func,
|
|
737
|
+
/**
|
|
738
|
+
* Callback fired when the `input` doesn't satisfy its constraints.
|
|
739
|
+
*/
|
|
740
|
+
onInvalid: e.func,
|
|
741
|
+
/**
|
|
742
|
+
* @ignore
|
|
743
|
+
*/
|
|
744
|
+
onKeyDown: e.func,
|
|
745
|
+
/**
|
|
746
|
+
* @ignore
|
|
747
|
+
*/
|
|
748
|
+
onKeyUp: e.func,
|
|
749
|
+
/**
|
|
750
|
+
* The short hint displayed in the `input` before the user enters a value.
|
|
751
|
+
*/
|
|
752
|
+
placeholder: e.string,
|
|
753
|
+
/**
|
|
754
|
+
* It prevents the user from changing the value of the field
|
|
755
|
+
* (not from interacting with the field).
|
|
756
|
+
*/
|
|
757
|
+
readOnly: e.bool,
|
|
758
|
+
/**
|
|
759
|
+
* @ignore
|
|
760
|
+
*/
|
|
761
|
+
renderSuffix: e.func,
|
|
762
|
+
/**
|
|
763
|
+
* If `true`, the `input` element is required.
|
|
764
|
+
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
|
|
765
|
+
*/
|
|
766
|
+
required: e.bool,
|
|
767
|
+
/**
|
|
768
|
+
* Number of rows to display when multiline option is set to true.
|
|
769
|
+
*/
|
|
770
|
+
rows: e.oneOfType([e.number, e.string]),
|
|
771
|
+
/**
|
|
772
|
+
* The size of the component.
|
|
773
|
+
*/
|
|
774
|
+
size: e.oneOfType([e.oneOf(["medium", "small"]), e.string]),
|
|
775
|
+
/**
|
|
776
|
+
* The extra props for the slot components.
|
|
777
|
+
* You can override the existing props or add new ones.
|
|
778
|
+
*
|
|
779
|
+
* This prop is an alias for the `componentsProps` prop, which will be deprecated in the future.
|
|
780
|
+
*
|
|
781
|
+
* @default {}
|
|
782
|
+
*/
|
|
783
|
+
slotProps: e.shape({
|
|
784
|
+
input: e.object,
|
|
785
|
+
root: e.object
|
|
786
|
+
}),
|
|
787
|
+
/**
|
|
788
|
+
* The components used for each slot inside.
|
|
789
|
+
*
|
|
790
|
+
* This prop is an alias for the `components` prop, which will be deprecated in the future.
|
|
791
|
+
*
|
|
792
|
+
* @default {}
|
|
793
|
+
*/
|
|
794
|
+
slots: e.shape({
|
|
795
|
+
input: e.elementType,
|
|
796
|
+
root: e.elementType
|
|
797
|
+
}),
|
|
798
|
+
/**
|
|
799
|
+
* Start `InputAdornment` for this component.
|
|
800
|
+
*/
|
|
801
|
+
startAdornment: e.node,
|
|
802
|
+
/**
|
|
803
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
804
|
+
*/
|
|
805
|
+
sx: e.oneOfType([e.arrayOf(e.oneOfType([e.func, e.object, e.bool])), e.func, e.object]),
|
|
806
|
+
/**
|
|
807
|
+
* Type of the `input` element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#input_types).
|
|
808
|
+
* @default 'text'
|
|
809
|
+
*/
|
|
810
|
+
type: e.string,
|
|
811
|
+
/**
|
|
812
|
+
* The value of the `input` element, required for a controlled component.
|
|
813
|
+
*/
|
|
814
|
+
value: e.any
|
|
815
|
+
});
|
|
816
|
+
const wt = "_codeInput_4y25h_1", Ct = "_codeInputItem_4y25h_5", Re = {
|
|
817
|
+
codeInput: wt,
|
|
818
|
+
codeInputItem: Ct
|
|
819
|
+
}, Ft = (n) => {
|
|
820
|
+
const {
|
|
821
|
+
className: r,
|
|
822
|
+
autoFocus: i,
|
|
823
|
+
value: d = "",
|
|
824
|
+
length: s = je,
|
|
825
|
+
disabled: y,
|
|
826
|
+
onChange: E,
|
|
827
|
+
onComplete: I,
|
|
828
|
+
locale: z = Xe
|
|
829
|
+
} = n, [b, g] = Ve(
|
|
830
|
+
d.split("").slice(0, s)
|
|
831
|
+
), p = Pe([]);
|
|
832
|
+
he(() => {
|
|
833
|
+
g((l) => {
|
|
834
|
+
if (d === l.join("")) return l;
|
|
835
|
+
const a = d.split("").slice(0, s);
|
|
836
|
+
for (; a.length < s; )
|
|
837
|
+
a.push("");
|
|
838
|
+
return a;
|
|
839
|
+
});
|
|
840
|
+
}, [d, s]), he(() => {
|
|
841
|
+
i && p.current[0] && !y && p.current[0]?.focus();
|
|
842
|
+
}, [i, y]);
|
|
843
|
+
const w = (l, a) => {
|
|
844
|
+
const t = l.target.value;
|
|
845
|
+
if (t && !Q.test(t))
|
|
846
|
+
return;
|
|
847
|
+
const o = t.slice(-1), u = [...b];
|
|
848
|
+
u[a] = o, g(u), ee(p.current[a]);
|
|
849
|
+
const c = u.join("");
|
|
850
|
+
E?.(c), o && a < s - 1 && queueMicrotask(() => p.current[a + 1]?.focus()), c.length === s && !o.includes("") && I?.(c);
|
|
851
|
+
}, O = (l, a) => {
|
|
852
|
+
if (l.key === qe) {
|
|
853
|
+
if (!b[a] && a > 0) {
|
|
854
|
+
const t = [...b];
|
|
855
|
+
t[a - 1] = "", g(t), queueMicrotask(() => p.current[a - 1]?.focus()), E?.(t.join(""));
|
|
856
|
+
} else if (b[a]) {
|
|
857
|
+
const t = [...b];
|
|
858
|
+
t[a] = "", g(t), E?.(t.join(""));
|
|
859
|
+
}
|
|
860
|
+
l.preventDefault();
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
if (l.key === Ue && a > 0) {
|
|
864
|
+
queueMicrotask(() => p.current[a - 1]?.focus()), l.preventDefault();
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
if (l.key === Ge && a < s - 1) {
|
|
868
|
+
queueMicrotask(() => p.current[a + 1]?.focus()), l.preventDefault();
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
if (l.key === $e) {
|
|
872
|
+
const t = b.findIndex((o) => !o);
|
|
873
|
+
queueMicrotask(t !== -1 ? () => p.current[t]?.focus() : () => p.current[a - 1]?.focus()), l.preventDefault();
|
|
874
|
+
}
|
|
875
|
+
if (Q.test(l.key)) {
|
|
876
|
+
l.preventDefault();
|
|
877
|
+
const t = l.key, o = [...b];
|
|
878
|
+
o[a] = t, g(o), ee(p.current[a]);
|
|
879
|
+
const u = o.join("");
|
|
880
|
+
E?.(u), a < s - 1 && queueMicrotask(() => p.current[a + 1]?.focus()), u.length === s && !t.includes("") && I?.(u);
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
!l.ctrlKey && !l.metaKey && l.key !== Ye && !Q.test(l.key) && l.preventDefault();
|
|
884
|
+
}, S = (l) => {
|
|
885
|
+
l.preventDefault();
|
|
886
|
+
const t = l.clipboardData.getData("text").trim().replace(Ke, "").slice(0, s);
|
|
887
|
+
if (!t)
|
|
888
|
+
return;
|
|
889
|
+
const o = [...b];
|
|
890
|
+
t.split("").forEach((C, T) => {
|
|
891
|
+
T < s && (o[T] = C, ee(p.current[T]));
|
|
892
|
+
});
|
|
893
|
+
for (let C = t.length; C < s; C++)
|
|
894
|
+
o[C] = "";
|
|
895
|
+
g(o);
|
|
896
|
+
const u = o.join("");
|
|
897
|
+
E?.(u);
|
|
898
|
+
const c = o.findIndex(
|
|
899
|
+
(C, T) => T >= t.length && !C
|
|
900
|
+
);
|
|
901
|
+
queueMicrotask(c !== -1 ? () => p.current[c]?.focus() : () => p.current[Math.min(t.length, s - 1)]?.focus()), u.length === s && !o.includes("") && I?.(u);
|
|
902
|
+
}, N = (l) => {
|
|
903
|
+
y || p.current[l]?.select();
|
|
904
|
+
}, k = (l) => {
|
|
905
|
+
y || p.current[l]?.select();
|
|
906
|
+
};
|
|
907
|
+
return /* @__PURE__ */ D("div", { className: We(Re.codeInput, r), children: Array.from({ length: s }, (l, a) => /* @__PURE__ */ D(
|
|
908
|
+
ke,
|
|
909
|
+
{
|
|
910
|
+
className: Re.codeInputItem,
|
|
911
|
+
inputRef: (t) => {
|
|
912
|
+
p.current[a] = t;
|
|
913
|
+
},
|
|
914
|
+
inputProps: {
|
|
915
|
+
pattern: "[0-9]*",
|
|
916
|
+
maxLength: 1
|
|
917
|
+
},
|
|
918
|
+
type: "text",
|
|
919
|
+
inputMode: "numeric",
|
|
920
|
+
value: b[a] || "",
|
|
921
|
+
disabled: y,
|
|
922
|
+
onSelect: () => k(a),
|
|
923
|
+
onFocus: () => N(a),
|
|
924
|
+
onChange: (t) => w(t, a),
|
|
925
|
+
onKeyDown: (t) => O(t, a),
|
|
926
|
+
onPaste: S,
|
|
927
|
+
"aria-label": at(a, s, z)
|
|
928
|
+
},
|
|
929
|
+
a
|
|
930
|
+
)) });
|
|
931
|
+
};
|
|
932
|
+
export {
|
|
933
|
+
Ft as CodeInput
|
|
934
|
+
};
|