@intlayer/design-system 7.1.4 → 7.1.6
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/esm/components/Browser/Browser.content.mjs +10 -5
- package/dist/esm/components/Browser/Browser.content.mjs.map +1 -1
- package/dist/esm/libs/auth.mjs.map +1 -1
- package/dist/types/components/Breadcrumb/breadcrumb.content.d.ts +3 -3
- package/dist/types/components/Breadcrumb/breadcrumb.content.d.ts.map +1 -1
- package/dist/types/components/Breadcrumb/index.d.ts.map +1 -1
- package/dist/types/components/Browser/Browser.content.d.ts +21 -11
- package/dist/types/components/Browser/Browser.content.d.ts.map +1 -1
- package/dist/types/components/Button/Button.d.ts +5 -5
- package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +4 -4
- package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts.map +1 -1
- package/dist/types/components/Command/index.d.ts +2 -2
- package/dist/types/components/Container/index.d.ts +9 -9
- package/dist/types/components/Container/index.d.ts.map +1 -1
- package/dist/types/components/CopyButton/CopyButton.content.d.ts +3 -3
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts +25 -25
- package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.content.d.ts +9 -9
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +33 -33
- package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.d.ts +25 -25
- package/dist/types/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +25 -25
- package/dist/types/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +33 -33
- package/dist/types/components/DictionaryFieldEditor/StructureView/structureView.content.d.ts +9 -9
- package/dist/types/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.d.ts +7 -7
- package/dist/types/components/DictionaryFieldEditor/dictionaryFieldEditor.content.d.ts +5 -5
- package/dist/types/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts +31 -31
- package/dist/types/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts.map +1 -1
- package/dist/types/components/ExpandCollapse/expandCollapse.content.d.ts +3 -3
- package/dist/types/components/Form/FormBase.d.ts +2 -2
- package/dist/types/components/Form/FormBase.d.ts.map +1 -1
- package/dist/types/components/Form/FormField.d.ts +2 -2
- package/dist/types/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/components/Form/FormItem.d.ts +2 -2
- package/dist/types/components/Form/elements/EditableFieldInputElement.d.ts +2 -2
- package/dist/types/components/Form/elements/EditableFieldTextAreaElement.d.ts +2 -2
- package/dist/types/components/Form/elements/FormElement.d.ts +2 -2
- package/dist/types/components/Form/elements/OTPElement.d.ts +2 -2
- package/dist/types/components/Form/elements/SelectElement.d.ts +2 -2
- package/dist/types/components/Form/elements/SwitchSelectorElement.d.ts +2 -2
- package/dist/types/components/IDE/CodeContext.d.ts +2 -2
- package/dist/types/components/IDE/code.content.d.ts +5 -5
- package/dist/types/components/IDE/code.content.d.ts.map +1 -1
- package/dist/types/components/IDE/copyCode.content.d.ts +5 -5
- package/dist/types/components/Input/Checkbox.d.ts +4 -4
- package/dist/types/components/Input/Checkbox.d.ts.map +1 -1
- package/dist/types/components/Input/Input.d.ts +2 -2
- package/dist/types/components/Input/OTPInput.d.ts +5 -5
- package/dist/types/components/Input/SearchInput.d.ts +2 -2
- package/dist/types/components/Link/Link.d.ts +3 -3
- package/dist/types/components/Link/Link.d.ts.map +1 -1
- package/dist/types/components/Loader/index.content.d.ts +3 -3
- package/dist/types/components/Loader/index.content.d.ts.map +1 -1
- package/dist/types/components/Loader/spinner.d.ts +2 -2
- package/dist/types/components/Loader/spinner.d.ts.map +1 -1
- package/dist/types/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts +17 -17
- package/dist/types/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts.map +1 -1
- package/dist/types/components/LocaleSwitcherDropDown/localeSwitcher.content.d.ts +13 -13
- package/dist/types/components/LocaleSwitcherDropDown/localeSwitcher.content.d.ts.map +1 -1
- package/dist/types/components/Navbar/Burger.d.ts +2 -2
- package/dist/types/components/Navbar/DesktopNavbar.d.ts +2 -2
- package/dist/types/components/Navbar/DesktopNavbar.d.ts.map +1 -1
- package/dist/types/components/Navbar/MobileNavbar.d.ts +2 -2
- package/dist/types/components/Navbar/index.d.ts +2 -2
- package/dist/types/components/Navbar/index.d.ts.map +1 -1
- package/dist/types/components/Pagination/Pagination.d.ts +4 -4
- package/dist/types/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/types/components/Pagination/pagination.content.d.ts +11 -11
- package/dist/types/components/Popover/static.d.ts +3 -3
- package/dist/types/components/RightDrawer/useRightDrawerStore.d.ts +2 -2
- package/dist/types/components/Select/Select.d.ts +3 -3
- package/dist/types/components/SocialNetworks/index.d.ts +2 -2
- package/dist/types/components/SocialNetworks/index.d.ts.map +1 -1
- package/dist/types/components/SwitchSelector/index.d.ts +7 -7
- package/dist/types/components/SwitchSelector/index.d.ts.map +1 -1
- package/dist/types/components/Tab/Tab.d.ts +5 -5
- package/dist/types/components/Tab/Tab.d.ts.map +1 -1
- package/dist/types/components/Tab/TabContext.d.ts +2 -2
- package/dist/types/components/TabSelector/TabSelector.d.ts +3 -3
- package/dist/types/components/TabSelector/TabSelector.d.ts.map +1 -1
- package/dist/types/components/Table/table.content.d.ts +3 -3
- package/dist/types/components/Table/table.content.d.ts.map +1 -1
- package/dist/types/components/Tag/index.d.ts +5 -5
- package/dist/types/components/Tag/index.d.ts.map +1 -1
- package/dist/types/components/Toaster/Toast.d.ts +3 -3
- package/dist/types/components/Toaster/Toast.d.ts.map +1 -1
- package/dist/types/components/Toaster/Toaster.d.ts +2 -2
- package/dist/types/components/Toaster/Toaster.d.ts.map +1 -1
- package/dist/types/hooks/reactQuery.d.ts +73 -1257
- package/dist/types/hooks/reactQuery.d.ts.map +1 -1
- package/dist/types/hooks/useAuth/useOAuth2.d.ts +1 -2
- package/dist/types/hooks/useAuth/useOAuth2.d.ts.map +1 -1
- package/dist/types/hooks/useScrollBlockage/useScrollBlockageStore.d.ts +2 -2
- package/dist/types/hooks/useUser/index.d.ts +3 -20
- package/dist/types/hooks/useUser/index.d.ts.map +1 -1
- package/dist/types/libs/auth.d.ts +5574 -2316
- package/dist/types/libs/auth.d.ts.map +1 -1
- package/package.json +15 -14
- package/dist/esm/components/Form/elements/CodeInputElement.mjs +0 -40
- package/dist/esm/components/Form/elements/CodeInputElement.mjs.map +0 -1
- package/dist/esm/components/Input/CodeInput.mjs +0 -84
- package/dist/esm/components/Input/CodeInput.mjs.map +0 -1
- package/dist/esm/components/Input/OTPInput/Input.mjs +0 -426
- package/dist/esm/components/Input/OTPInput/Input.mjs.map +0 -1
- package/dist/esm/components/Input/OTPInput/index.mjs +0 -495
- package/dist/esm/components/Input/OTPInput/index.mjs.map +0 -1
- package/dist/types/Checkbox.d.ts +0 -2
- package/dist/types/Input.d.ts +0 -16
- package/dist/types/Input.d.ts.map +0 -1
- package/dist/types/InputPassword.d.ts +0 -2
- package/dist/types/OTPElement.d.ts +0 -30
- package/dist/types/OTPElement.d.ts.map +0 -1
- package/dist/types/OTPInput.d.ts +0 -3
- package/dist/types/SearchInput.d.ts +0 -1
- package/dist/types/components/Input/OTPInput/Input.d.ts +0 -57
- package/dist/types/components/Input/OTPInput/Input.d.ts.map +0 -1
- package/dist/types/components/Input/OTPInput/index.d.ts +0 -78
- package/dist/types/components/Input/OTPInput/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -5
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { cn } from "../../../utils/cn.mjs";
|
|
5
|
-
import { Button } from "../../Button/Button.mjs";
|
|
6
|
-
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
7
|
-
import { MinusIcon } from "lucide-react";
|
|
8
|
-
import { cva } from "class-variance-authority";
|
|
9
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
|
|
11
|
-
//#region src/components/Input/OTPInput/index.tsx
|
|
12
|
-
/**
|
|
13
|
-
* This component is a fork of https://github.com/guilhermerodz/input-otp
|
|
14
|
-
*/
|
|
15
|
-
const syncTimeouts = (cb) => {
|
|
16
|
-
return [
|
|
17
|
-
setTimeout(cb, 0),
|
|
18
|
-
setTimeout(cb, 10),
|
|
19
|
-
setTimeout(cb, 50)
|
|
20
|
-
];
|
|
21
|
-
};
|
|
22
|
-
const safeInsertRule = (sheet, rule) => {
|
|
23
|
-
try {
|
|
24
|
-
sheet.insertRule(rule);
|
|
25
|
-
} catch {
|
|
26
|
-
console.error("input-otp could not insert CSS rule:", rule);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const NOSCRIPT_CSS_FALLBACK = `
|
|
30
|
-
[data-input-otp] {
|
|
31
|
-
--nojs-bg: white !important;
|
|
32
|
-
--nojs-fg: black !important;
|
|
33
|
-
|
|
34
|
-
background-color: var(--nojs-bg) !important;
|
|
35
|
-
color: var(--nojs-fg) !important;
|
|
36
|
-
caret-color: var(--nojs-fg) !important;
|
|
37
|
-
letter-spacing: .25em !important;
|
|
38
|
-
text-align: center !important;
|
|
39
|
-
border: 1px solid var(--nojs-fg) !important;
|
|
40
|
-
border-radius: 4px !important;
|
|
41
|
-
width: 100% !important;
|
|
42
|
-
}
|
|
43
|
-
@media (prefers-color-scheme: dark) {
|
|
44
|
-
[data-input-otp] {
|
|
45
|
-
--nojs-bg: black !important;
|
|
46
|
-
--nojs-fg: white !important;
|
|
47
|
-
}
|
|
48
|
-
}`;
|
|
49
|
-
const PWM_BADGE_MARGIN_RIGHT = 18;
|
|
50
|
-
const PWM_BADGE_SPACE_WIDTH_PX = 40;
|
|
51
|
-
const PWM_BADGE_SPACE_WIDTH = `${PWM_BADGE_SPACE_WIDTH_PX}px`;
|
|
52
|
-
const PASSWORD_MANAGERS_SELECTORS = [
|
|
53
|
-
"[data-lastpass-icon-root]",
|
|
54
|
-
"com-1password-button",
|
|
55
|
-
"[data-dashlanecreated]",
|
|
56
|
-
"[style$=\"2147483647 !important;\"]"
|
|
57
|
-
].join(",");
|
|
58
|
-
const usePasswordManagerBadge = ({ containerRef, inputRef, pushPasswordManagerStrategy, isFocused }) => {
|
|
59
|
-
/** Password managers have a badge
|
|
60
|
-
* and I'll use this state to push them
|
|
61
|
-
* outside the input */
|
|
62
|
-
const [hasPWMBadge, setHasPWMBadge] = useState(false);
|
|
63
|
-
const [hasPWMBadgeSpace, setHasPWMBadgeSpace] = useState(false);
|
|
64
|
-
const [done, setDone] = useState(false);
|
|
65
|
-
const willPushPWMBadge = pushPasswordManagerStrategy === "none" ? false : (pushPasswordManagerStrategy === "increase-width" || pushPasswordManagerStrategy === "experimental-no-flickering") && hasPWMBadge && hasPWMBadgeSpace;
|
|
66
|
-
const trackPWMBadge = () => {
|
|
67
|
-
const container = containerRef.current;
|
|
68
|
-
const input = inputRef.current;
|
|
69
|
-
if (!container || !input || done || pushPasswordManagerStrategy === "none") return;
|
|
70
|
-
const elementToCompare = container;
|
|
71
|
-
const rightCornerX = elementToCompare.getBoundingClientRect().left + elementToCompare.offsetWidth;
|
|
72
|
-
const centereredY = elementToCompare.getBoundingClientRect().top + elementToCompare.offsetHeight / 2;
|
|
73
|
-
const x = rightCornerX - PWM_BADGE_MARGIN_RIGHT;
|
|
74
|
-
const y = centereredY;
|
|
75
|
-
if (document.querySelectorAll(PASSWORD_MANAGERS_SELECTORS).length === 0) {
|
|
76
|
-
if (document.elementFromPoint(x, y) === container) return;
|
|
77
|
-
}
|
|
78
|
-
setHasPWMBadge(true);
|
|
79
|
-
setDone(true);
|
|
80
|
-
};
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
const container = containerRef.current;
|
|
83
|
-
if (!container || pushPasswordManagerStrategy === "none") return;
|
|
84
|
-
const checkHasSpace = () => {
|
|
85
|
-
setHasPWMBadgeSpace(window.innerWidth - container.getBoundingClientRect().right >= PWM_BADGE_SPACE_WIDTH_PX);
|
|
86
|
-
};
|
|
87
|
-
checkHasSpace();
|
|
88
|
-
const interval = setInterval(checkHasSpace, 1e3);
|
|
89
|
-
return () => {
|
|
90
|
-
clearInterval(interval);
|
|
91
|
-
};
|
|
92
|
-
}, [containerRef, pushPasswordManagerStrategy]);
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
const _isFocused = isFocused || document.activeElement === inputRef.current;
|
|
95
|
-
if (pushPasswordManagerStrategy === "none" || !_isFocused) return;
|
|
96
|
-
const t1 = setTimeout(trackPWMBadge, 0);
|
|
97
|
-
const t2 = setTimeout(trackPWMBadge, 2e3);
|
|
98
|
-
const t3 = setTimeout(trackPWMBadge, 5e3);
|
|
99
|
-
const t4 = setTimeout(() => {
|
|
100
|
-
setDone(true);
|
|
101
|
-
}, 6e3);
|
|
102
|
-
return () => {
|
|
103
|
-
clearTimeout(t1);
|
|
104
|
-
clearTimeout(t2);
|
|
105
|
-
clearTimeout(t3);
|
|
106
|
-
clearTimeout(t4);
|
|
107
|
-
};
|
|
108
|
-
}, [
|
|
109
|
-
inputRef,
|
|
110
|
-
isFocused,
|
|
111
|
-
pushPasswordManagerStrategy
|
|
112
|
-
]);
|
|
113
|
-
return {
|
|
114
|
-
hasPWMBadge,
|
|
115
|
-
willPushPWMBadge,
|
|
116
|
-
PWM_BADGE_SPACE_WIDTH
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
const usePrevious = (value) => {
|
|
120
|
-
const ref = useRef(void 0);
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
ref.current = value;
|
|
123
|
-
});
|
|
124
|
-
return ref.current;
|
|
125
|
-
};
|
|
126
|
-
const OTPInputContext = createContext({});
|
|
127
|
-
const OTPInput = ({ value: uncheckedValue, onChange: uncheckedOnChange, maxLength, pattern, placeholder, inputMode = "numeric", onComplete, onActiveSlotChange, pushPasswordManagerStrategy = "increase-width", pasteTransformer, containerClassName, noScriptCSSFallback = NOSCRIPT_CSS_FALLBACK, render, children, ...props }) => {
|
|
128
|
-
const [internalValue, setInternalValue] = useState(typeof props.defaultValue === "string" ? props.defaultValue : "");
|
|
129
|
-
const value = uncheckedValue ?? internalValue;
|
|
130
|
-
const previousValue = usePrevious(value);
|
|
131
|
-
const onChange = (newValue) => {
|
|
132
|
-
uncheckedOnChange?.(newValue);
|
|
133
|
-
setInternalValue(newValue);
|
|
134
|
-
};
|
|
135
|
-
const regexp = pattern !== void 0 ? typeof pattern === "string" ? new RegExp(pattern) : pattern : null;
|
|
136
|
-
/** useRef */
|
|
137
|
-
const inputRef = useRef(null);
|
|
138
|
-
const containerRef = useRef(null);
|
|
139
|
-
const initialLoadRef = useRef({
|
|
140
|
-
value,
|
|
141
|
-
onChange,
|
|
142
|
-
isIOS: typeof window !== "undefined" && window?.CSS?.supports?.("-webkit-touch-callout", "none")
|
|
143
|
-
});
|
|
144
|
-
const inputMetadataRef = useRef({ prev: [
|
|
145
|
-
inputRef.current?.selectionStart ?? null,
|
|
146
|
-
inputRef.current?.selectionEnd ?? null,
|
|
147
|
-
inputRef.current?.selectionDirection ?? "none"
|
|
148
|
-
] });
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
const input = inputRef.current;
|
|
151
|
-
const container = containerRef.current;
|
|
152
|
-
if (!input || !container) return;
|
|
153
|
-
if (initialLoadRef.current.value !== input.value) initialLoadRef.current.onChange(input.value);
|
|
154
|
-
inputMetadataRef.current.prev = [
|
|
155
|
-
input.selectionStart,
|
|
156
|
-
input.selectionEnd,
|
|
157
|
-
input.selectionDirection ?? "none"
|
|
158
|
-
];
|
|
159
|
-
const onDocumentSelectionChange = () => {
|
|
160
|
-
if (document.activeElement !== input) {
|
|
161
|
-
setMirrorSelectionStart(null);
|
|
162
|
-
setMirrorSelectionEnd(null);
|
|
163
|
-
setActualCaretPosition(null);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const selectionStart = input.selectionStart;
|
|
167
|
-
const selectionEnd = input.selectionEnd;
|
|
168
|
-
const selectionDirection = input.selectionDirection;
|
|
169
|
-
const maxLength$1 = input.maxLength;
|
|
170
|
-
const value$1 = input.value;
|
|
171
|
-
const previousSelection = inputMetadataRef.current.prev;
|
|
172
|
-
let calculatedStart = -1;
|
|
173
|
-
let calculatedEnd = -1;
|
|
174
|
-
let calculatedDirection = selectionDirection ?? "none";
|
|
175
|
-
if (value$1.length !== 0 && selectionStart !== null && selectionEnd !== null) {
|
|
176
|
-
const isSingleCaret = selectionStart === selectionEnd;
|
|
177
|
-
const isInsertMode = selectionStart === value$1.length && value$1.length < maxLength$1;
|
|
178
|
-
if (isSingleCaret && !isInsertMode) {
|
|
179
|
-
const caretPosition = selectionStart;
|
|
180
|
-
if (caretPosition === 0) {
|
|
181
|
-
calculatedStart = 0;
|
|
182
|
-
calculatedEnd = 1;
|
|
183
|
-
calculatedDirection = "forward";
|
|
184
|
-
} else if (caretPosition === maxLength$1) {
|
|
185
|
-
calculatedStart = caretPosition - 1;
|
|
186
|
-
calculatedEnd = caretPosition;
|
|
187
|
-
calculatedDirection = "backward";
|
|
188
|
-
} else if (maxLength$1 > 1 && value$1.length > 1) {
|
|
189
|
-
let offset = 0;
|
|
190
|
-
if (previousSelection[0] !== null && previousSelection[1] !== null) {
|
|
191
|
-
calculatedDirection = caretPosition < previousSelection[1] ? "backward" : "forward";
|
|
192
|
-
const wasPreviouslyInserting = previousSelection[0] === previousSelection[1] && previousSelection[0] < maxLength$1;
|
|
193
|
-
if (calculatedDirection === "backward" && !wasPreviouslyInserting) offset = -1;
|
|
194
|
-
}
|
|
195
|
-
calculatedStart = offset + caretPosition;
|
|
196
|
-
calculatedEnd = offset + caretPosition + 1;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
if (calculatedStart !== -1 && calculatedEnd !== -1 && calculatedStart !== calculatedEnd) inputRef.current?.setSelectionRange(calculatedStart, calculatedEnd, calculatedDirection);
|
|
200
|
-
}
|
|
201
|
-
const finalSelectionStart = calculatedStart !== -1 ? calculatedStart : selectionStart;
|
|
202
|
-
const finalSelectionEnd = calculatedEnd !== -1 ? calculatedEnd : selectionEnd;
|
|
203
|
-
const finalDirection = calculatedDirection;
|
|
204
|
-
if (selectionStart !== null && selectionEnd !== null) if (selectionStart === selectionEnd) setActualCaretPosition(selectionStart);
|
|
205
|
-
else setActualCaretPosition(finalSelectionStart);
|
|
206
|
-
else setActualCaretPosition(null);
|
|
207
|
-
setMirrorSelectionStart(finalSelectionStart);
|
|
208
|
-
setMirrorSelectionEnd(finalSelectionEnd);
|
|
209
|
-
inputMetadataRef.current.prev = [
|
|
210
|
-
finalSelectionStart,
|
|
211
|
-
finalSelectionEnd,
|
|
212
|
-
finalDirection
|
|
213
|
-
];
|
|
214
|
-
};
|
|
215
|
-
document.addEventListener("selectionchange", onDocumentSelectionChange, { capture: true });
|
|
216
|
-
onDocumentSelectionChange();
|
|
217
|
-
if (document.activeElement === input) setIsFocused(true);
|
|
218
|
-
if (!document.getElementById("input-otp-style")) {
|
|
219
|
-
const styleEl = document.createElement("style");
|
|
220
|
-
styleEl.id = "input-otp-style";
|
|
221
|
-
document.head.appendChild(styleEl);
|
|
222
|
-
if (styleEl.sheet) {
|
|
223
|
-
const autofillStyles = "background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";
|
|
224
|
-
safeInsertRule(styleEl.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }");
|
|
225
|
-
safeInsertRule(styleEl.sheet, `[data-input-otp]:autofill { ${autofillStyles} }`);
|
|
226
|
-
safeInsertRule(styleEl.sheet, `[data-input-otp]:-webkit-autofill { ${autofillStyles} }`);
|
|
227
|
-
safeInsertRule(styleEl.sheet, `@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`);
|
|
228
|
-
safeInsertRule(styleEl.sheet, `[data-input-otp] + * { pointer-events: all !important; }`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
const updateRootHeight = () => {
|
|
232
|
-
if (container) container.style.setProperty("--root-height", `${input.clientHeight}px`);
|
|
233
|
-
};
|
|
234
|
-
updateRootHeight();
|
|
235
|
-
const resizeObserver = new ResizeObserver(updateRootHeight);
|
|
236
|
-
resizeObserver.observe(input);
|
|
237
|
-
return () => {
|
|
238
|
-
document.removeEventListener("selectionchange", onDocumentSelectionChange, { capture: true });
|
|
239
|
-
resizeObserver.disconnect();
|
|
240
|
-
};
|
|
241
|
-
}, []);
|
|
242
|
-
/** Mirrors for UI rendering purpose only */
|
|
243
|
-
const [isHoveringInput, setIsHoveringInput] = useState(false);
|
|
244
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
245
|
-
const [mirrorSelectionStart, setMirrorSelectionStart] = useState(null);
|
|
246
|
-
const [mirrorSelectionEnd, setMirrorSelectionEnd] = useState(null);
|
|
247
|
-
const [actualCaretPosition, setActualCaretPosition] = useState(null);
|
|
248
|
-
/** Effects */
|
|
249
|
-
useEffect(() => {
|
|
250
|
-
syncTimeouts(() => {
|
|
251
|
-
inputRef.current?.dispatchEvent(new Event("input"));
|
|
252
|
-
const s = inputRef.current?.selectionStart ?? null;
|
|
253
|
-
const e = inputRef.current?.selectionEnd ?? null;
|
|
254
|
-
const dir = inputRef.current?.selectionDirection ?? "none";
|
|
255
|
-
if (s !== null && e !== null) {
|
|
256
|
-
setMirrorSelectionStart(s);
|
|
257
|
-
setMirrorSelectionEnd(e);
|
|
258
|
-
setActualCaretPosition(s);
|
|
259
|
-
inputMetadataRef.current.prev = [
|
|
260
|
-
s,
|
|
261
|
-
e,
|
|
262
|
-
dir
|
|
263
|
-
];
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}, [value, isFocused]);
|
|
267
|
-
useEffect(() => {
|
|
268
|
-
if (previousValue === void 0) return;
|
|
269
|
-
if (value !== previousValue && previousValue.length < maxLength && value.length === maxLength) onComplete?.(value);
|
|
270
|
-
}, [
|
|
271
|
-
maxLength,
|
|
272
|
-
onComplete,
|
|
273
|
-
previousValue,
|
|
274
|
-
value
|
|
275
|
-
]);
|
|
276
|
-
const previousActiveSlot = useRef(null);
|
|
277
|
-
useEffect(() => {
|
|
278
|
-
const activeSlotIndex = isFocused && actualCaretPosition !== null ? actualCaretPosition : null;
|
|
279
|
-
if (activeSlotIndex !== previousActiveSlot.current) {
|
|
280
|
-
previousActiveSlot.current = activeSlotIndex;
|
|
281
|
-
onActiveSlotChange?.(activeSlotIndex);
|
|
282
|
-
}
|
|
283
|
-
}, [
|
|
284
|
-
isFocused,
|
|
285
|
-
actualCaretPosition,
|
|
286
|
-
onActiveSlotChange
|
|
287
|
-
]);
|
|
288
|
-
const pwmb = usePasswordManagerBadge({
|
|
289
|
-
containerRef,
|
|
290
|
-
inputRef,
|
|
291
|
-
pushPasswordManagerStrategy,
|
|
292
|
-
isFocused
|
|
293
|
-
});
|
|
294
|
-
/** Event handlers */
|
|
295
|
-
const _changeListener = (e) => {
|
|
296
|
-
const newValue = e.currentTarget.value.slice(0, maxLength);
|
|
297
|
-
if (newValue.length > 0 && regexp && !regexp.test(newValue)) {
|
|
298
|
-
e.preventDefault();
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
if (typeof previousValue === "string" && newValue.length < previousValue.length) document.dispatchEvent(new Event("selectionchange"));
|
|
302
|
-
onChange(newValue);
|
|
303
|
-
};
|
|
304
|
-
const _focusListener = () => {
|
|
305
|
-
if (inputRef.current) {
|
|
306
|
-
const start = Math.min(inputRef.current.value.length, maxLength - 1);
|
|
307
|
-
const end = inputRef.current.value.length;
|
|
308
|
-
inputRef.current?.setSelectionRange(start, end);
|
|
309
|
-
setMirrorSelectionStart(start);
|
|
310
|
-
setMirrorSelectionEnd(end);
|
|
311
|
-
}
|
|
312
|
-
setIsFocused(true);
|
|
313
|
-
};
|
|
314
|
-
const _pasteListener = (e) => {
|
|
315
|
-
const input = inputRef.current;
|
|
316
|
-
if (!pasteTransformer && (!initialLoadRef.current.isIOS || !e.clipboardData || !input)) return;
|
|
317
|
-
const _content = e.clipboardData.getData("text/plain");
|
|
318
|
-
const content = pasteTransformer ? pasteTransformer(_content) : _content;
|
|
319
|
-
e.preventDefault();
|
|
320
|
-
const start = inputRef.current?.selectionStart;
|
|
321
|
-
const end = inputRef.current?.selectionEnd;
|
|
322
|
-
const newValue = (start !== end ? value.slice(0, start ?? 0) + content + value.slice(end ?? 0) : value.slice(0, start ?? 0) + content + value.slice(start ?? 0)).slice(0, maxLength);
|
|
323
|
-
if (newValue.length > 0 && regexp && !regexp.test(newValue)) return;
|
|
324
|
-
if (input) {
|
|
325
|
-
input.value = newValue;
|
|
326
|
-
onChange(newValue);
|
|
327
|
-
const _start = Math.min(newValue.length, maxLength - 1);
|
|
328
|
-
const _end = newValue.length;
|
|
329
|
-
input.setSelectionRange(_start, _end);
|
|
330
|
-
setMirrorSelectionStart(_start);
|
|
331
|
-
setMirrorSelectionEnd(_end);
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
/** Styles - dynamic styles that can't be converted to Tailwind */
|
|
335
|
-
const dynamicInputStyle = {
|
|
336
|
-
width: pwmb.willPushPWMBadge ? `calc(100% + ${pwmb.PWM_BADGE_SPACE_WIDTH})` : "100%",
|
|
337
|
-
clipPath: pwmb.willPushPWMBadge ? `inset(0 ${pwmb.PWM_BADGE_SPACE_WIDTH} 0 0)` : void 0,
|
|
338
|
-
fontSize: "var(--root-height)"
|
|
339
|
-
};
|
|
340
|
-
/** Rendering */
|
|
341
|
-
const renderedInput = /* @__PURE__ */ jsx("input", {
|
|
342
|
-
autoComplete: props.autoComplete || "one-time-code",
|
|
343
|
-
...props,
|
|
344
|
-
"data-input-otp": true,
|
|
345
|
-
"data-input-otp-placeholder-shown": value.length === 0 || void 0,
|
|
346
|
-
"data-input-otp-mss": mirrorSelectionStart,
|
|
347
|
-
"data-input-otp-mse": mirrorSelectionEnd,
|
|
348
|
-
inputMode,
|
|
349
|
-
pattern: regexp?.source,
|
|
350
|
-
"aria-placeholder": placeholder,
|
|
351
|
-
className: "-z-10 pointer-events-auto absolute inset-0 flex h-full border-0 border-transparent bg-transparent text-center font-mono text-transparent tabular-nums leading-none tracking-[-.5em] caret-transparent opacity-100 shadow-none outline-none",
|
|
352
|
-
style: dynamicInputStyle,
|
|
353
|
-
maxLength,
|
|
354
|
-
value,
|
|
355
|
-
ref: inputRef,
|
|
356
|
-
onPaste: (e) => {
|
|
357
|
-
_pasteListener(e);
|
|
358
|
-
props.onPaste?.(e);
|
|
359
|
-
},
|
|
360
|
-
onChange: _changeListener,
|
|
361
|
-
onMouseOver: (e) => {
|
|
362
|
-
setIsHoveringInput(true);
|
|
363
|
-
props.onMouseOver?.(e);
|
|
364
|
-
},
|
|
365
|
-
onMouseLeave: (e) => {
|
|
366
|
-
setIsHoveringInput(false);
|
|
367
|
-
props.onMouseLeave?.(e);
|
|
368
|
-
},
|
|
369
|
-
onKeyDown: (e) => {
|
|
370
|
-
if (e.key === "ArrowLeft" || e.key === "ArrowRight") requestAnimationFrame(() => {
|
|
371
|
-
const input = inputRef.current;
|
|
372
|
-
if (input && document.activeElement === input) {
|
|
373
|
-
const s = input.selectionStart;
|
|
374
|
-
const end = input.selectionEnd;
|
|
375
|
-
if (s !== null && end !== null) setActualCaretPosition(s);
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
props.onKeyDown?.(e);
|
|
379
|
-
},
|
|
380
|
-
onFocus: (e) => {
|
|
381
|
-
_focusListener();
|
|
382
|
-
props.onFocus?.(e);
|
|
383
|
-
},
|
|
384
|
-
onBlur: (e) => {
|
|
385
|
-
setIsFocused(false);
|
|
386
|
-
props.onBlur?.(e);
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
const setSelection = (index) => {
|
|
390
|
-
const input = inputRef.current;
|
|
391
|
-
if (!input || props.disabled) return;
|
|
392
|
-
const clampedIndex = Math.max(0, Math.min(index, maxLength - 1));
|
|
393
|
-
if (document.activeElement !== input) input.focus();
|
|
394
|
-
const hasChar = value[clampedIndex] !== void 0;
|
|
395
|
-
const start = clampedIndex;
|
|
396
|
-
const end = hasChar ? clampedIndex + 1 : clampedIndex;
|
|
397
|
-
input.setSelectionRange(start, end);
|
|
398
|
-
setMirrorSelectionStart(start);
|
|
399
|
-
setMirrorSelectionEnd(end);
|
|
400
|
-
setIsFocused(true);
|
|
401
|
-
};
|
|
402
|
-
const contextValue = {
|
|
403
|
-
slots: Array.from({ length: maxLength }).map((_, slotIdx) => {
|
|
404
|
-
const isActive = isFocused && mirrorSelectionStart !== null && mirrorSelectionEnd !== null && (mirrorSelectionStart === mirrorSelectionEnd && slotIdx === mirrorSelectionStart || slotIdx >= mirrorSelectionStart && slotIdx < mirrorSelectionEnd);
|
|
405
|
-
const char = value[slotIdx] !== void 0 ? value[slotIdx] : null;
|
|
406
|
-
return {
|
|
407
|
-
char,
|
|
408
|
-
placeholderChar: value[0] !== void 0 ? null : placeholder?.[slotIdx] ?? null,
|
|
409
|
-
isActive,
|
|
410
|
-
hasFakeCaret: isActive && char === null
|
|
411
|
-
};
|
|
412
|
-
}),
|
|
413
|
-
isFocused,
|
|
414
|
-
isHovering: !props.disabled && isHoveringInput,
|
|
415
|
-
setSelection
|
|
416
|
-
};
|
|
417
|
-
const renderedChildren = render !== void 0 ? render(contextValue) : /* @__PURE__ */ jsx(OTPInputContext.Provider, {
|
|
418
|
-
value: contextValue,
|
|
419
|
-
children
|
|
420
|
-
});
|
|
421
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [noScriptCSSFallback !== null && /* @__PURE__ */ jsx("noscript", { children: /* @__PURE__ */ jsx("style", { children: noScriptCSSFallback }) }), /* @__PURE__ */ jsxs("div", {
|
|
422
|
-
ref: containerRef,
|
|
423
|
-
className: cn("relative", props.disabled ? "cursor-default" : "cursor-text", containerClassName),
|
|
424
|
-
children: [renderedChildren, /* @__PURE__ */ jsx("div", {
|
|
425
|
-
className: "absolute inset-0",
|
|
426
|
-
children: renderedInput
|
|
427
|
-
})]
|
|
428
|
-
})] });
|
|
429
|
-
};
|
|
430
|
-
const inputSlotVariants = cva("block text-center", {
|
|
431
|
-
variants: { size: {
|
|
432
|
-
sm: "h-4 w-3 text-sm",
|
|
433
|
-
md: "h-5 w-4 text-base",
|
|
434
|
-
lg: "h-6 w-5 text-lg",
|
|
435
|
-
xl: "h-7 w-6 text-xl"
|
|
436
|
-
} },
|
|
437
|
-
defaultVariants: { size: "md" }
|
|
438
|
-
});
|
|
439
|
-
const InputOTP = ({ className, render, ...props }) => /* @__PURE__ */ jsx(OTPInput, {
|
|
440
|
-
containerClassName: "relative flex items-center gap-2 has-disabled:opacity-50",
|
|
441
|
-
className: cn("disabled:cursor-not-allowed", className),
|
|
442
|
-
render,
|
|
443
|
-
...props
|
|
444
|
-
});
|
|
445
|
-
const InputOTPGroup = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
446
|
-
className: cn("z-10 flex items-center gap-3", className),
|
|
447
|
-
...props
|
|
448
|
-
});
|
|
449
|
-
const InputOTPSlot = ({ index, className, onClick, onKeyDown, ...props }) => {
|
|
450
|
-
const inputOTPContext = useContext(OTPInputContext);
|
|
451
|
-
const { char, isActive } = inputOTPContext?.slots[index] ?? {};
|
|
452
|
-
const { setSelection } = inputOTPContext ?? {};
|
|
453
|
-
const handleClick = (e) => {
|
|
454
|
-
setSelection?.(index);
|
|
455
|
-
onClick?.(e);
|
|
456
|
-
};
|
|
457
|
-
const handleKeyDown = (e) => {
|
|
458
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
459
|
-
e.preventDefault();
|
|
460
|
-
setSelection?.(index);
|
|
461
|
-
}
|
|
462
|
-
onKeyDown?.(e);
|
|
463
|
-
};
|
|
464
|
-
return /* @__PURE__ */ jsx(Button, {
|
|
465
|
-
"aria-active": isActive,
|
|
466
|
-
variant: "input",
|
|
467
|
-
color: "custom",
|
|
468
|
-
tabIndex: -1,
|
|
469
|
-
className: cn("relative z-10 px-2!", isActive && "ring-4!", className),
|
|
470
|
-
onClick: handleClick,
|
|
471
|
-
onKeyDown: handleKeyDown,
|
|
472
|
-
label: null,
|
|
473
|
-
...props,
|
|
474
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
475
|
-
className: "relative z-10 flex h-6 w-4 items-center justify-center",
|
|
476
|
-
children: char
|
|
477
|
-
})
|
|
478
|
-
});
|
|
479
|
-
};
|
|
480
|
-
const InputOTPSeparator = (props) => /* @__PURE__ */ jsx("div", {
|
|
481
|
-
"aria-hidden": true,
|
|
482
|
-
className: "z-0 table h-0.5 w-3 rounded-full bg-border text-neutral",
|
|
483
|
-
...props,
|
|
484
|
-
children: /* @__PURE__ */ jsx(MinusIcon, {})
|
|
485
|
-
});
|
|
486
|
-
const InputIndicator = ({ ref, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
487
|
-
"data-indicator": true,
|
|
488
|
-
className: "absolute top-0 z-[-1] h-8 h-full w-auto rounded-xl bg-neutral-100 ring-4 ring-neutral-100 transition-[left,width] duration-300 ease-in-out motion-reduce:transition-none dark:bg-neutral-700 dark:ring-neutral-700",
|
|
489
|
-
ref,
|
|
490
|
-
...props
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
//#endregion
|
|
494
|
-
export { InputIndicator, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, OTPInput, OTPInputContext, inputSlotVariants, usePasswordManagerBadge, usePrevious };
|
|
495
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["OTPInput: FC<OTPInputProps>","maxLength","value","calculatedDirection: 'forward' | 'backward' | 'none'","dynamicInputStyle: CSSProperties","contextValue: RenderProps","InputOTP: FC<InputOTPProps>","InputOTPSlot: FC<InputOTPSlotProps>","InputOTPSeparator: FC<ComponentProps<'div'>>","InputIndicator: FC<\n ComponentProps<'div'> & { ref: RefObject<HTMLDivElement | null> }\n>"],"sources":["../../../../../src/components/Input/OTPInput/index.tsx"],"sourcesContent":["'use client';\n\n/**\n * This component is a fork of https://github.com/guilhermerodz/input-otp\n */\n\nimport { cva } from 'class-variance-authority';\nimport { MinusIcon } from 'lucide-react';\nimport {\n type ChangeEvent,\n type ClipboardEvent,\n type ComponentProps,\n type CSSProperties,\n createContext,\n type FC,\n type InputHTMLAttributes,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { cn } from '../../../utils/cn';\nimport { Button, type ButtonProps } from '../../Button';\n\n// ---------------- Utilities ----------------\n\nconst syncTimeouts = (cb: (...args: any[]) => unknown): number[] => {\n const t1 = setTimeout(cb, 0); // For faster machines\n const t2 = setTimeout(cb, 1_0);\n const t3 = setTimeout(cb, 5_0);\n return [t1, t2, t3];\n};\n\nconst safeInsertRule = (sheet: CSSStyleSheet, rule: string) => {\n try {\n sheet.insertRule(rule);\n } catch {\n console.error('input-otp could not insert CSS rule:', rule);\n }\n};\n\n// Decided to go with <noscript>\n// instead of `scripting` CSS media query\n// because it's a fallback for initial page load\n// and the <script> tag won't be loaded\n// unless the user has JS disabled.\nconst NOSCRIPT_CSS_FALLBACK = `\n[data-input-otp] {\n --nojs-bg: white !important;\n --nojs-fg: black !important;\n\n background-color: var(--nojs-bg) !important;\n color: var(--nojs-fg) !important;\n caret-color: var(--nojs-fg) !important;\n letter-spacing: .25em !important;\n text-align: center !important;\n border: 1px solid var(--nojs-fg) !important;\n border-radius: 4px !important;\n width: 100% !important;\n}\n@media (prefers-color-scheme: dark) {\n [data-input-otp] {\n --nojs-bg: black !important;\n --nojs-fg: white !important;\n }\n}`;\n\n// ---------------- Constants ----------------\n\nconst PWM_BADGE_MARGIN_RIGHT = 18;\nconst PWM_BADGE_SPACE_WIDTH_PX = 40;\nconst PWM_BADGE_SPACE_WIDTH = `${PWM_BADGE_SPACE_WIDTH_PX}px` as const;\n\nconst PASSWORD_MANAGERS_SELECTORS = [\n '[data-lastpass-icon-root]', // LastPass\n 'com-1password-button', // 1Password\n '[data-dashlanecreated]', // Dashlane\n '[style$=\"2147483647 !important;\"]', // Bitwarden\n].join(',');\n\n// ---------------- Types ----------------\n\nexport type SlotProps = {\n isActive: boolean;\n char: string | null;\n placeholderChar: string | null;\n hasFakeCaret: boolean;\n};\n\nexport type RenderProps = {\n slots: SlotProps[];\n isFocused: boolean;\n isHovering: boolean;\n setSelection: (index: number) => void;\n};\n\ntype OverrideProps<T, R> = Omit<T, keyof R> & R;\n\ntype OTPInputBaseProps = OverrideProps<\n InputHTMLAttributes<HTMLInputElement>,\n {\n value?: string;\n onChange?: (newValue: string) => unknown;\n\n maxLength: number;\n\n onComplete?: (...args: any[]) => unknown;\n onActiveSlotChange?: (activeSlotIndex: number | null) => unknown;\n pushPasswordManagerStrategy?: 'increase-width' | 'none';\n pasteTransformer?: (pasted: string) => string;\n\n containerClassName?: string;\n\n noScriptCSSFallback?: string | null;\n }\n>;\n\ntype InputOTPRenderFn = (props: RenderProps) => ReactNode;\n\nexport type OTPInputProps = OTPInputBaseProps &\n (\n | {\n render: InputOTPRenderFn;\n children?: never;\n }\n | {\n render?: never;\n children: ReactNode;\n }\n );\n\n// ---------------- Hooks ----------------\n\nexport const usePasswordManagerBadge = ({\n containerRef,\n inputRef,\n pushPasswordManagerStrategy,\n isFocused,\n}: {\n containerRef: RefObject<HTMLDivElement | null>;\n inputRef: RefObject<HTMLInputElement | null>;\n pushPasswordManagerStrategy: OTPInputProps['pushPasswordManagerStrategy'];\n isFocused: boolean;\n}) => {\n /** Password managers have a badge\n * and I'll use this state to push them\n * outside the input */\n const [hasPWMBadge, setHasPWMBadge] = useState(false);\n const [hasPWMBadgeSpace, setHasPWMBadgeSpace] = useState(false);\n const [done, setDone] = useState(false);\n\n const willPushPWMBadge =\n pushPasswordManagerStrategy === 'none'\n ? false\n : (pushPasswordManagerStrategy === 'increase-width' ||\n // TODO: remove 'experimental-no-flickering' support in 2.0.0\n pushPasswordManagerStrategy === 'experimental-no-flickering') &&\n hasPWMBadge &&\n hasPWMBadgeSpace;\n\n const trackPWMBadge = () => {\n const container = containerRef.current;\n const input = inputRef.current;\n if (\n !container ||\n !input ||\n done ||\n pushPasswordManagerStrategy === 'none'\n ) {\n return;\n }\n\n const elementToCompare = container;\n\n // Get the top right-center point of the container.\n // That is usually where most password managers place their badge.\n const rightCornerX =\n elementToCompare.getBoundingClientRect().left +\n elementToCompare.offsetWidth;\n const centereredY =\n elementToCompare.getBoundingClientRect().top +\n elementToCompare.offsetHeight / 2;\n const x = rightCornerX - PWM_BADGE_MARGIN_RIGHT;\n const y = centereredY;\n\n // Do an extra search to check for famous password managers\n const pmws = document.querySelectorAll(PASSWORD_MANAGERS_SELECTORS);\n\n // If no password manager is automatically detect,\n // we'll try to dispatch document.elementFromPoint\n // to identify badges\n if (pmws.length === 0) {\n const maybeBadgeEl = document.elementFromPoint(x, y);\n\n // If the found element is the input itself,\n // then we assume it's not a password manager badge.\n // We are not sure. Most times that means there isn't a badge.\n if (maybeBadgeEl === container) {\n return;\n }\n }\n\n setHasPWMBadge(true);\n setDone(true);\n };\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container || pushPasswordManagerStrategy === 'none') {\n return;\n }\n\n // Check if the PWM area is 100% visible\n const checkHasSpace = () => {\n const viewportWidth = window.innerWidth;\n const distanceToRightEdge =\n viewportWidth - container.getBoundingClientRect().right;\n setHasPWMBadgeSpace(distanceToRightEdge >= PWM_BADGE_SPACE_WIDTH_PX);\n };\n\n checkHasSpace();\n const interval = setInterval(checkHasSpace, 1000);\n\n return () => {\n clearInterval(interval);\n };\n }, [containerRef, pushPasswordManagerStrategy]);\n\n useEffect(() => {\n const _isFocused = isFocused || document.activeElement === inputRef.current;\n\n if (pushPasswordManagerStrategy === 'none' || !_isFocused) {\n return;\n }\n const t1 = setTimeout(trackPWMBadge, 0);\n const t2 = setTimeout(trackPWMBadge, 2000);\n const t3 = setTimeout(trackPWMBadge, 5000);\n const t4 = setTimeout(() => {\n setDone(true);\n }, 6000);\n return () => {\n clearTimeout(t1);\n clearTimeout(t2);\n clearTimeout(t3);\n clearTimeout(t4);\n };\n }, [inputRef, isFocused, pushPasswordManagerStrategy]);\n\n return { hasPWMBadge, willPushPWMBadge, PWM_BADGE_SPACE_WIDTH };\n};\n\nexport const usePrevious = <T,>(value: T): T | undefined => {\n const ref = useRef<T | undefined>(undefined);\n useEffect(() => {\n ref.current = value;\n });\n return ref.current;\n};\n\n// ---------------- Context ----------------\n\nexport const OTPInputContext = createContext<RenderProps>({} as RenderProps);\n\n// ---------------- Core Component ----------------\n\nexport const OTPInput: FC<OTPInputProps> = ({\n value: uncheckedValue,\n onChange: uncheckedOnChange,\n maxLength,\n pattern,\n placeholder,\n inputMode = 'numeric',\n onComplete,\n onActiveSlotChange,\n pushPasswordManagerStrategy = 'increase-width',\n pasteTransformer,\n containerClassName,\n noScriptCSSFallback = NOSCRIPT_CSS_FALLBACK,\n render,\n children,\n ...props\n}) => {\n // Only used when `value` state is not provided\n const [internalValue, setInternalValue] = useState(\n typeof props.defaultValue === 'string' ? props.defaultValue : ''\n );\n\n // Definitions\n const value = uncheckedValue ?? internalValue;\n const previousValue = usePrevious(value);\n const onChange = (newValue: string) => {\n uncheckedOnChange?.(newValue);\n setInternalValue(newValue);\n };\n const regexp =\n pattern !== undefined\n ? typeof pattern === 'string'\n ? new RegExp(pattern)\n : pattern\n : null;\n\n /** useRef */\n const inputRef = useRef<HTMLInputElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const initialLoadRef = useRef({\n value,\n onChange,\n isIOS:\n typeof window !== 'undefined' &&\n window?.CSS?.supports?.('-webkit-touch-callout', 'none'),\n });\n const inputMetadataRef = useRef<{\n prev: [number | null, number | null, 'none' | 'forward' | 'backward'];\n }>({\n prev: [\n inputRef.current?.selectionStart ?? null,\n inputRef.current?.selectionEnd ?? null,\n inputRef.current?.selectionDirection ?? 'none',\n ],\n });\n useEffect(() => {\n const input = inputRef.current;\n const container = containerRef.current;\n\n if (!input || !container) {\n return;\n }\n\n // Sync input value\n if (initialLoadRef.current.value !== input.value) {\n initialLoadRef.current.onChange(input.value);\n }\n\n // Previous selection\n inputMetadataRef.current.prev = [\n input.selectionStart,\n input.selectionEnd,\n input.selectionDirection ?? 'none',\n ];\n const onDocumentSelectionChange = () => {\n if (document.activeElement !== input) {\n setMirrorSelectionStart(null);\n setMirrorSelectionEnd(null);\n setActualCaretPosition(null);\n return;\n }\n\n const selectionStart = input.selectionStart;\n const selectionEnd = input.selectionEnd;\n const selectionDirection = input.selectionDirection;\n const maxLength = input.maxLength;\n const value = input.value;\n const previousSelection = inputMetadataRef.current.prev;\n\n let calculatedStart = -1;\n let calculatedEnd = -1;\n let calculatedDirection: 'forward' | 'backward' | 'none' =\n selectionDirection ?? 'none';\n\n if (\n value.length !== 0 &&\n selectionStart !== null &&\n selectionEnd !== null\n ) {\n const isSingleCaret = selectionStart === selectionEnd;\n const isInsertMode =\n selectionStart === value.length && value.length < maxLength;\n\n if (isSingleCaret && !isInsertMode) {\n const caretPosition = selectionStart;\n if (caretPosition === 0) {\n calculatedStart = 0;\n calculatedEnd = 1;\n calculatedDirection = 'forward';\n } else if (caretPosition === maxLength) {\n calculatedStart = caretPosition - 1;\n calculatedEnd = caretPosition;\n calculatedDirection = 'backward';\n } else if (maxLength > 1 && value.length > 1) {\n let offset = 0;\n if (\n previousSelection[0] !== null &&\n previousSelection[1] !== null\n ) {\n calculatedDirection =\n caretPosition < previousSelection[1] ? 'backward' : 'forward';\n const wasPreviouslyInserting =\n previousSelection[0] === previousSelection[1] &&\n previousSelection[0] < maxLength;\n if (\n calculatedDirection === 'backward' &&\n !wasPreviouslyInserting\n ) {\n offset = -1;\n }\n }\n\n calculatedStart = offset + caretPosition;\n calculatedEnd = offset + caretPosition + 1;\n }\n }\n\n if (\n calculatedStart !== -1 &&\n calculatedEnd !== -1 &&\n calculatedStart !== calculatedEnd\n ) {\n inputRef.current?.setSelectionRange(\n calculatedStart,\n calculatedEnd,\n calculatedDirection\n );\n }\n }\n\n const finalSelectionStart =\n calculatedStart !== -1 ? calculatedStart : selectionStart;\n const finalSelectionEnd =\n calculatedEnd !== -1 ? calculatedEnd : selectionEnd;\n const finalDirection = calculatedDirection;\n\n // Track actual caret position (before expansion) for active slot detection\n if (selectionStart !== null && selectionEnd !== null) {\n const isSingleCaret = selectionStart === selectionEnd;\n if (isSingleCaret) {\n setActualCaretPosition(selectionStart);\n } else {\n // When selection is expanded, use the start position as the caret\n setActualCaretPosition(finalSelectionStart);\n }\n } else {\n setActualCaretPosition(null);\n }\n\n setMirrorSelectionStart(finalSelectionStart);\n setMirrorSelectionEnd(finalSelectionEnd);\n inputMetadataRef.current.prev = [\n finalSelectionStart,\n finalSelectionEnd,\n finalDirection,\n ];\n };\n document.addEventListener('selectionchange', onDocumentSelectionChange, {\n capture: true,\n });\n\n // Set initial mirror state\n onDocumentSelectionChange();\n if (document.activeElement === input) {\n setIsFocused(true);\n }\n\n // Apply needed styles\n if (!document.getElementById('input-otp-style')) {\n const styleEl = document.createElement('style');\n styleEl.id = 'input-otp-style';\n document.head.appendChild(styleEl);\n\n if (styleEl.sheet) {\n const autofillStyles =\n 'background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;';\n\n safeInsertRule(\n styleEl.sheet,\n '[data-input-otp]::selection { background: transparent !important; color: transparent !important; }'\n );\n safeInsertRule(\n styleEl.sheet,\n `[data-input-otp]:autofill { ${autofillStyles} }`\n );\n safeInsertRule(\n styleEl.sheet,\n `[data-input-otp]:-webkit-autofill { ${autofillStyles} }`\n );\n // iOS\n safeInsertRule(\n styleEl.sheet,\n `@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`\n );\n // PWM badges\n safeInsertRule(\n styleEl.sheet,\n `[data-input-otp] + * { pointer-events: all !important; }`\n );\n }\n }\n // Track root height\n const updateRootHeight = () => {\n if (container) {\n container.style.setProperty('--root-height', `${input.clientHeight}px`);\n }\n };\n updateRootHeight();\n const resizeObserver = new ResizeObserver(updateRootHeight);\n resizeObserver.observe(input);\n\n return () => {\n document.removeEventListener(\n 'selectionchange',\n onDocumentSelectionChange,\n { capture: true }\n );\n resizeObserver.disconnect();\n };\n }, []);\n\n /** Mirrors for UI rendering purpose only */\n const [isHoveringInput, setIsHoveringInput] = useState(false);\n const [isFocused, setIsFocused] = useState(false);\n const [mirrorSelectionStart, setMirrorSelectionStart] = useState<\n number | null\n >(null);\n const [mirrorSelectionEnd, setMirrorSelectionEnd] = useState<number | null>(\n null\n );\n const [actualCaretPosition, setActualCaretPosition] = useState<number | null>(\n null\n );\n\n /** Effects */\n useEffect(() => {\n syncTimeouts(() => {\n // Forcefully remove :autofill state\n inputRef.current?.dispatchEvent(new Event('input'));\n\n // Update the selection state\n const s = inputRef.current?.selectionStart ?? null;\n const e = inputRef.current?.selectionEnd ?? null;\n const dir = inputRef.current?.selectionDirection ?? 'none';\n if (s !== null && e !== null) {\n setMirrorSelectionStart(s);\n setMirrorSelectionEnd(e);\n // Track actual caret position (use start position as caret)\n setActualCaretPosition(s);\n inputMetadataRef.current.prev = [s, e, dir];\n }\n });\n }, [value, isFocused]);\n\n useEffect(() => {\n if (previousValue === undefined) {\n return;\n }\n\n if (\n value !== previousValue &&\n previousValue.length < maxLength &&\n value.length === maxLength\n ) {\n onComplete?.(value);\n }\n }, [maxLength, onComplete, previousValue, value]);\n\n // Track active slot changes\n const previousActiveSlot = useRef<number | null>(null);\n useEffect(() => {\n const activeSlotIndex =\n isFocused && actualCaretPosition !== null ? actualCaretPosition : null;\n\n if (activeSlotIndex !== previousActiveSlot.current) {\n previousActiveSlot.current = activeSlotIndex;\n onActiveSlotChange?.(activeSlotIndex);\n }\n }, [isFocused, actualCaretPosition, onActiveSlotChange]);\n\n const pwmb = usePasswordManagerBadge({\n containerRef,\n inputRef,\n pushPasswordManagerStrategy,\n isFocused,\n });\n\n /** Event handlers */\n const _changeListener = (e: ChangeEvent<HTMLInputElement>) => {\n const newValue = e.currentTarget.value.slice(0, maxLength);\n if (newValue.length > 0 && regexp && !regexp.test(newValue)) {\n e.preventDefault();\n return;\n }\n const maybeHasDeleted =\n typeof previousValue === 'string' &&\n newValue.length < previousValue.length;\n if (maybeHasDeleted) {\n // Since cutting/deleting text doesn't trigger\n // selectionchange event, we'll have to dispatch it manually.\n // NOTE: The following line also triggers when cmd+A then pasting\n // a value with smaller length, which is not ideal for performance.\n document.dispatchEvent(new Event('selectionchange'));\n }\n onChange(newValue);\n };\n const _focusListener = () => {\n if (inputRef.current) {\n const start = Math.min(inputRef.current.value.length, maxLength - 1);\n const end = inputRef.current.value.length;\n inputRef.current?.setSelectionRange(start, end);\n setMirrorSelectionStart(start);\n setMirrorSelectionEnd(end);\n }\n setIsFocused(true);\n };\n // Fix iOS pasting\n const _pasteListener = (e: ClipboardEvent<HTMLInputElement>) => {\n const input = inputRef.current;\n if (\n !pasteTransformer &&\n (!initialLoadRef.current.isIOS || !e.clipboardData || !input)\n ) {\n return;\n }\n\n const _content = e.clipboardData.getData('text/plain');\n const content = pasteTransformer ? pasteTransformer(_content) : _content;\n e.preventDefault();\n\n const start = inputRef.current?.selectionStart;\n const end = inputRef.current?.selectionEnd;\n\n const isReplacing = start !== end;\n\n const newValueUncapped = isReplacing\n ? value.slice(0, start ?? 0) + content + value.slice(end ?? 0) // Replacing\n : value.slice(0, start ?? 0) + content + value.slice(start ?? 0); // Inserting\n const newValue = newValueUncapped.slice(0, maxLength);\n\n if (newValue.length > 0 && regexp && !regexp.test(newValue)) {\n return;\n }\n\n if (input) {\n input.value = newValue;\n onChange(newValue);\n\n const _start = Math.min(newValue.length, maxLength - 1);\n const _end = newValue.length;\n\n input.setSelectionRange(_start, _end);\n setMirrorSelectionStart(_start);\n setMirrorSelectionEnd(_end);\n }\n };\n\n /** Styles - dynamic styles that can't be converted to Tailwind */\n const dynamicInputStyle: CSSProperties = {\n width: pwmb.willPushPWMBadge\n ? `calc(100% + ${pwmb.PWM_BADGE_SPACE_WIDTH})`\n : '100%',\n clipPath: pwmb.willPushPWMBadge\n ? `inset(0 ${pwmb.PWM_BADGE_SPACE_WIDTH} 0 0)`\n : undefined,\n fontSize: 'var(--root-height)',\n };\n\n /** Rendering */\n const renderedInput = (\n <input\n autoComplete={props.autoComplete || 'one-time-code'}\n {...props}\n data-input-otp\n data-input-otp-placeholder-shown={value.length === 0 || undefined}\n data-input-otp-mss={mirrorSelectionStart}\n data-input-otp-mse={mirrorSelectionEnd}\n inputMode={inputMode}\n pattern={regexp?.source}\n aria-placeholder={placeholder}\n className=\"-z-10 pointer-events-auto absolute inset-0 flex h-full border-0 border-transparent bg-transparent text-center font-mono text-transparent tabular-nums leading-none tracking-[-.5em] caret-transparent opacity-100 shadow-none outline-none\"\n style={dynamicInputStyle}\n maxLength={maxLength}\n value={value}\n ref={inputRef}\n onPaste={(e) => {\n _pasteListener(e);\n props.onPaste?.(e);\n }}\n onChange={_changeListener}\n onMouseOver={(e) => {\n setIsHoveringInput(true);\n props.onMouseOver?.(e);\n }}\n onMouseLeave={(e) => {\n setIsHoveringInput(false);\n props.onMouseLeave?.(e);\n }}\n onKeyDown={(e) => {\n // Track arrow key navigation to ensure active slot updates correctly\n if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {\n // Use requestAnimationFrame to check selection after browser has processed the key\n requestAnimationFrame(() => {\n const input = inputRef.current;\n if (input && document.activeElement === input) {\n const s = input.selectionStart;\n const end = input.selectionEnd;\n if (s !== null && end !== null) {\n // Update actual caret position - use start position as caret\n setActualCaretPosition(s);\n }\n }\n });\n }\n props.onKeyDown?.(e);\n }}\n onFocus={(e) => {\n _focusListener();\n props.onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsFocused(false);\n props.onBlur?.(e);\n }}\n />\n );\n\n const setSelection = (index: number) => {\n const input = inputRef.current;\n if (!input || props.disabled) {\n return;\n }\n\n // Clamp index to valid range\n const clampedIndex = Math.max(0, Math.min(index, maxLength - 1));\n\n // Focus the input if not already focused\n if (document.activeElement !== input) {\n input.focus();\n }\n\n // Set selection to the clicked slot\n // If there's a character at that position, select it; otherwise just position the caret\n const hasChar = value[clampedIndex] !== undefined;\n const start = clampedIndex;\n const end = hasChar ? clampedIndex + 1 : clampedIndex;\n\n input.setSelectionRange(start, end);\n setMirrorSelectionStart(start);\n setMirrorSelectionEnd(end);\n setIsFocused(true);\n };\n\n const contextValue: RenderProps = {\n slots: Array.from({ length: maxLength }).map((_, slotIdx) => {\n const isActive =\n isFocused &&\n mirrorSelectionStart !== null &&\n mirrorSelectionEnd !== null &&\n ((mirrorSelectionStart === mirrorSelectionEnd &&\n slotIdx === mirrorSelectionStart) ||\n (slotIdx >= mirrorSelectionStart && slotIdx < mirrorSelectionEnd));\n\n const char = value[slotIdx] !== undefined ? value[slotIdx] : null;\n const placeholderChar =\n value[0] !== undefined ? null : (placeholder?.[slotIdx] ?? null);\n\n return {\n char,\n placeholderChar,\n isActive,\n hasFakeCaret: isActive && char === null,\n };\n }),\n isFocused,\n isHovering: !props.disabled && isHoveringInput,\n setSelection,\n };\n\n const renderedChildren =\n render !== undefined ? (\n render(contextValue)\n ) : (\n <OTPInputContext.Provider value={contextValue}>\n {children}\n </OTPInputContext.Provider>\n );\n\n return (\n <>\n {noScriptCSSFallback !== null && (\n <noscript>\n <style>{noScriptCSSFallback}</style>\n </noscript>\n )}\n\n <div\n ref={containerRef}\n className={cn(\n 'relative',\n props.disabled ? 'cursor-default' : 'cursor-text',\n containerClassName\n )}\n >\n {renderedChildren}\n\n <div className=\"absolute inset-0\">{renderedInput}</div>\n </div>\n </>\n );\n};\n\n// ---------------- Root ----------------\n\ntype InputOTPProps = Omit<ComponentProps<typeof OTPInput>, 'children'>;\n\nexport const inputSlotVariants = cva('block text-center', {\n variants: {\n size: {\n sm: 'h-4 w-3 text-sm',\n md: 'h-5 w-4 text-base',\n lg: 'h-6 w-5 text-lg',\n xl: 'h-7 w-6 text-xl',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\nexport const InputOTP: FC<InputOTPProps> = ({\n className,\n render,\n ...props\n}) => (\n <OTPInput\n containerClassName=\"relative flex items-center gap-2 has-disabled:opacity-50\"\n className={cn('disabled:cursor-not-allowed', className)}\n render={render!}\n {...props}\n />\n);\n\n// ---------------- Group ----------------\n\nexport const InputOTPGroup = ({\n className,\n ...props\n}: ComponentProps<'div'>) => (\n <div className={cn('z-10 flex items-center gap-3', className)} {...props} />\n);\n\n// ---------------- Slot ----------------\n\ntype InputOTPSlotProps = Omit<ButtonProps, 'variant' | 'label'> & {\n index: number;\n};\n\nexport const InputOTPSlot: FC<InputOTPSlotProps> = ({\n index,\n className,\n onClick,\n onKeyDown,\n ...props\n}) => {\n const inputOTPContext = useContext(OTPInputContext);\n const { char, isActive } = inputOTPContext?.slots[index] ?? {};\n const { setSelection } = inputOTPContext ?? {};\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n setSelection?.(index);\n onClick?.(e);\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n setSelection?.(index);\n }\n onKeyDown?.(e);\n };\n\n return (\n <Button\n aria-active={isActive}\n variant=\"input\"\n color=\"custom\"\n tabIndex={-1}\n className={cn('relative z-10 px-2!', isActive && 'ring-4!', className)}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n label={null}\n {...props}\n >\n {/* value */}\n <span className=\"relative z-10 flex h-6 w-4 items-center justify-center\">\n {char}\n </span>\n </Button>\n );\n};\n\n// ---------------- Separator ----------------\n\nexport const InputOTPSeparator: FC<ComponentProps<'div'>> = (props) => (\n <div\n aria-hidden\n className=\"z-0 table h-0.5 w-3 rounded-full bg-border text-neutral\"\n {...props}\n >\n <MinusIcon />\n </div>\n);\n\nexport const InputIndicator: FC<\n ComponentProps<'div'> & { ref: RefObject<HTMLDivElement | null> }\n> = ({ ref, ...props }) => (\n <div\n data-indicator\n className=\"absolute top-0 z-[-1] h-8 h-full w-auto rounded-xl bg-neutral-100 ring-4 ring-neutral-100 transition-[left,width] duration-300 ease-in-out motion-reduce:transition-none dark:bg-neutral-700 dark:ring-neutral-700\"\n ref={ref}\n {...props}\n />\n);\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,gBAAgB,OAA8C;AAIlE,QAAO;EAHI,WAAW,IAAI,EAAE;EACjB,WAAW,IAAI,GAAI;EACnB,WAAW,IAAI,GAAI;EACX;;AAGrB,MAAM,kBAAkB,OAAsB,SAAiB;AAC7D,KAAI;AACF,QAAM,WAAW,KAAK;SAChB;AACN,UAAQ,MAAM,wCAAwC,KAAK;;;AAS/D,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;AAuB9B,MAAM,yBAAyB;AAC/B,MAAM,2BAA2B;AACjC,MAAM,wBAAwB,GAAG,yBAAyB;AAE1D,MAAM,8BAA8B;CAClC;CACA;CACA;CACA;CACD,CAAC,KAAK,IAAI;AAuDX,MAAa,2BAA2B,EACtC,cACA,UACA,6BACA,gBAMI;;;;CAIJ,MAAM,CAAC,aAAa,kBAAkB,SAAS,MAAM;CACrD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,MAAM;CAC/D,MAAM,CAAC,MAAM,WAAW,SAAS,MAAM;CAEvC,MAAM,mBACJ,gCAAgC,SAC5B,SACC,gCAAgC,oBAE/B,gCAAgC,iCAClC,eACA;CAEN,MAAM,sBAAsB;EAC1B,MAAM,YAAY,aAAa;EAC/B,MAAM,QAAQ,SAAS;AACvB,MACE,CAAC,aACD,CAAC,SACD,QACA,gCAAgC,OAEhC;EAGF,MAAM,mBAAmB;EAIzB,MAAM,eACJ,iBAAiB,uBAAuB,CAAC,OACzC,iBAAiB;EACnB,MAAM,cACJ,iB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CACA,WAAU;CACL;CACL,GAAI;EACJ"}
|
package/dist/types/Checkbox.d.ts
DELETED
package/dist/types/Input.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { DetailedHTMLProps, FC, InputHTMLAttributes } from "react";
|
|
2
|
-
import { VariantProps } from "class-variance-authority";
|
|
3
|
-
|
|
4
|
-
//#region src/components/input/Input.d.ts
|
|
5
|
-
|
|
6
|
-
declare enum InputVariant {
|
|
7
|
-
DEFAULT = "default",
|
|
8
|
-
INVISIBLE = "invisible",
|
|
9
|
-
}
|
|
10
|
-
declare enum InputSize {
|
|
11
|
-
MD = "md",
|
|
12
|
-
LG = "lg",
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { InputSize, InputVariant };
|
|
16
|
-
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","names":[],"sources":["../../src/components/Input/Input.tsx"],"sourcesContent":[],"mappings":";;;;;aA2DY,YAAA;;;;aAKA,SAAA"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { FormElementProps } from "./components/Form/elements/FormElement.js";
|
|
2
|
-
import { InputOTP } from "./components/Input/OTPInput.js";
|
|
3
|
-
import { ComponentProps, ReactNode } from "react";
|
|
4
|
-
import * as react_jsx_runtime21 from "react/jsx-runtime";
|
|
5
|
-
|
|
6
|
-
//#region src/components/Form/elements/OTPElement.d.ts
|
|
7
|
-
type OTPElementsProps = Omit<FormElementProps<typeof InputOTP>, 'Element'> & Omit<ComponentProps<typeof InputOTP>, 'children'> & {
|
|
8
|
-
name: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
placeholder?: string;
|
|
11
|
-
className?: string;
|
|
12
|
-
children?: ReactNode;
|
|
13
|
-
/** Number of OTP slots (default: 6) */
|
|
14
|
-
slots?: number;
|
|
15
|
-
};
|
|
16
|
-
declare const OTPElement: ({
|
|
17
|
-
name,
|
|
18
|
-
description,
|
|
19
|
-
label,
|
|
20
|
-
isRequired,
|
|
21
|
-
info,
|
|
22
|
-
showErrorMessage,
|
|
23
|
-
children,
|
|
24
|
-
slots,
|
|
25
|
-
maxLength,
|
|
26
|
-
...props
|
|
27
|
-
}: OTPElementsProps) => react_jsx_runtime21.JSX.Element;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { OTPElement };
|
|
30
|
-
//# sourceMappingURL=OTPElement.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OTPElement.d.ts","names":[],"sources":["../../src/components/Form/elements/OTPElement.tsx"],"sourcesContent":[],"mappings":";;;;;;KAUK,gBAAA,GAAmB,KAAK,wBAAwB,wBACnD,KAAK,sBAAsB;;;EADxB,WAAA,CAAA,EAAA,MAAgB;EAAgC,SAAA,CAAA,EAAA,MAAA;EAAxB,QAAA,CAAA,EAMd,SANc;EAAL;EACK,KAAA,CAAA,EAAA,MAAA;CAAtB;AAAL,cAsDW,UAtDX,EAAA,CAAA;EAAA,IAAA;EAAA,WAAA;EAAA,KAAA;EAAA,UAAA;EAAA,IAAA;EAAA,gBAAA;EAAA,QAAA;EAAA,KAAA;EAAA,SAAA;EAAA,GAAA;AAAA,CAAA,EAiEC,gBAjED,EAAA,GAiEiB,mBAAA,CAAA,GAAA,CAAA,OAjEjB"}
|
package/dist/types/OTPInput.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./Input.js";
|