@hai-dev/ui-kit 1.2.1 → 1.2.2

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