bits-ui 1.0.0-next.97 → 1.0.0-next.98
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.
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
disabled = false,
|
|
22
22
|
value = $bindable(""),
|
|
23
23
|
onValueChange = noop,
|
|
24
|
-
|
|
24
|
+
pasteTransformer,
|
|
25
25
|
...restProps
|
|
26
26
|
}: PinInputRootProps = $props();
|
|
27
27
|
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
),
|
|
49
49
|
pushPasswordManagerStrategy: box.with(() => pushPasswordManagerStrategy),
|
|
50
|
-
|
|
50
|
+
pasteTransformer: box.with(() => pasteTransformer),
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
const mergedInputProps = $derived(mergeProps(restProps, rootState.inputProps));
|
|
@@ -10,7 +10,7 @@ type PinInputRootStateProps = WithRefProps<WritableBoxedValues<{
|
|
|
10
10
|
inputId: string;
|
|
11
11
|
disabled: boolean;
|
|
12
12
|
onComplete: (...args: any[]) => void;
|
|
13
|
-
|
|
13
|
+
pasteTransformer?: (text: string) => string;
|
|
14
14
|
pattern: any;
|
|
15
15
|
maxLength: number;
|
|
16
16
|
pushPasswordManagerStrategy: "increase-width" | "none";
|
|
@@ -308,7 +308,7 @@ class PinInputRootState {
|
|
|
308
308
|
const isValueInvalid = (newValue) => {
|
|
309
309
|
return newValue.length > 0 && this.#regexPattern && !this.#regexPattern.test(newValue);
|
|
310
310
|
};
|
|
311
|
-
if (!this.opts.
|
|
311
|
+
if (!this.opts.pasteTransformer?.current &&
|
|
312
312
|
(!this.#initialLoad.isIOS || !e.clipboardData || !input)) {
|
|
313
313
|
const newValue = getNewValue(e.clipboardData?.getData("text/plain"));
|
|
314
314
|
if (isValueInvalid(newValue)) {
|
|
@@ -317,7 +317,9 @@ class PinInputRootState {
|
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
319
|
const _content = e.clipboardData?.getData("text/plain") ?? "";
|
|
320
|
-
const content = this.opts.
|
|
320
|
+
const content = this.opts.pasteTransformer?.current
|
|
321
|
+
? this.opts.pasteTransformer.current(_content)
|
|
322
|
+
: _content;
|
|
321
323
|
e.preventDefault();
|
|
322
324
|
const newValue = getNewValue(content);
|
|
323
325
|
if (isValueInvalid(newValue))
|
|
@@ -24,7 +24,7 @@ export type PinInputRootPropsWithoutHTML = Omit<WithChild<{
|
|
|
24
24
|
* Use this function to clean up the pasted text, like removing hyphens or other
|
|
25
25
|
* characters that should not make it into the input.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
pasteTransformer?: (text: string) => string;
|
|
28
28
|
/**
|
|
29
29
|
* The max length of the input.
|
|
30
30
|
*/
|