@lynx-js/lynx-ui-input-otp 3.139.0 → 3.140.1
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/CHANGELOG.md +9 -0
- package/dist/InputOTP.d.ts +5 -2
- package/dist/InputOTP.d.ts.map +1 -1
- package/dist/InputOTP.jsx.map +1 -1
- package/dist/InputOTPSlot.d.ts +5 -2
- package/dist/InputOTPSlot.d.ts.map +1 -1
- package/dist/InputOTPSlot.jsx.map +1 -1
- package/dist/types/index.docs.d.ts +3 -5
- package/dist/types/index.docs.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/InputOTP.tsx +5 -8
- package/src/InputOTPSlot.tsx +5 -6
- package/src/types/index.docs.ts +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-input-otp
|
|
2
2
|
|
|
3
|
+
## 3.140.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Keep implementation-only component signatures out of public documentation ([#355](https://github.com/lynx-family/lynx-ui/pull/355))
|
|
8
|
+
types.
|
|
9
|
+
- Updated dependencies [[`20f5316`](https://github.com/lynx-family/lynx-ui/commit/20f531645f7c0e6766269d15129de93f53d9c8ea)]:
|
|
10
|
+
- @lynx-js/lynx-ui-input@3.140.1
|
|
11
|
+
|
|
3
12
|
## 3.139.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/InputOTP.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { ReactElement } from '@lynx-js/react';
|
|
2
|
+
import type { InputOTPProps } from './types/index.js';
|
|
3
|
+
type InputOTPComponent = (props: InputOTPProps) => ReactElement;
|
|
4
|
+
export declare const InputOTP: InputOTPComponent;
|
|
5
|
+
export {};
|
|
3
6
|
//# sourceMappingURL=InputOTP.d.ts.map
|
package/dist/InputOTP.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputOTP.d.ts","sourceRoot":"","sources":["../src/InputOTP.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InputOTP.d.ts","sourceRoot":"","sources":["../src/InputOTP.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAehE,OAAO,KAAK,EAAE,aAAa,EAAoC,MAAM,SAAS,CAAA;AAO9E,KAAK,iBAAiB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,YAAY,CAAA;AAgB/D,eAAO,MAAM,QAAQ,EAAqC,iBAAiB,CAAA"}
|
package/dist/InputOTP.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputOTP.jsx","sources":["../src/InputOTP.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport {\n forwardRef,\n memo,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from '@lynx-js/react'\nimport type { ForwardedRef } from '@lynx-js/react'\n\nimport { InvokeRejectError, useMemoizedFn } from '@lynx-js/lynx-ui-common'\nimport { KeyboardAwareTriggerContext } from '@lynx-js/lynx-ui-input'\nimport type {\n BaseEvent,\n CSSProperties,\n InputBlurEvent,\n InputFocusEvent,\n InputInputEvent,\n NodesRef,\n} from '@lynx-js/types'\nimport { clsx } from 'clsx'\n\nimport { InputOTPContext } from './InputOTPContext'\nimport type {\n InputOTPProps,\n InputOTPRef,\n InputOTPRenderProps,\n InputOTP as InputOTPType,\n} from './types'\nimport {\n nativeInputFilters,\n normalizeInputOTPLength,\n normalizeOTPValue,\n} from './utils'\n\nconst hiddenInputStyle: CSSProperties = {\n position: 'absolute',\n top: '0px',\n left: '0px',\n width: '1px',\n height: '1px',\n padding: '0px',\n borderWidth: '0px',\n opacity: 0,\n color: 'transparent',\n caretColor: 'transparent',\n backgroundColor: 'transparent',\n}\n\nexport const InputOTP = memo(forwardRef(InputOTPImpl)) as InputOTPType\n\nfunction reportInputError(error: unknown) {\n console.warn(\n `[lynx-ui-input-otp][InputOTP] native input command failed: ${\n String(error)\n }`,\n )\n}\n\nfunction InputOTPImpl(\n props: InputOTPProps,\n ref: ForwardedRef<InputOTPRef>,\n) {\n const {\n length = 6,\n inputType = 'numeric',\n value,\n defaultValue = '',\n autoFocus = false,\n disabled = false,\n invalid = false,\n className,\n style,\n children,\n onChange,\n onComplete,\n onFocus,\n onBlur,\n } = props\n\n const fieldLength = normalizeInputOTPLength(length)\n const isControlled = value !== undefined\n const [uncontrolledValue, setUncontrolledValue] = useState(\n normalizeOTPValue(defaultValue, fieldLength, inputType),\n )\n const [focused, setFocused] = useState(false)\n const inputRef = useRef<NodesRef>(null)\n const { onInputBlurred, onInputFocused } = useContext(\n KeyboardAwareTriggerContext,\n )\n\n const displayedValue = normalizeOTPValue(\n isControlled ? value : uncontrolledValue,\n fieldLength,\n inputType,\n )\n\n const invokeInput = useMemoizedFn(\n (\n method: 'focus' | 'blur' | 'setValue',\n nextValue?: string,\n ): Promise<void> =>\n new Promise((resolve, reject) => {\n if (!inputRef.current) {\n reject(new Error('InputOTP input is not mounted.'))\n return\n }\n\n inputRef.current\n .invoke({\n method,\n ...(method === 'setValue'\n ? {\n params: {\n value: nextValue ?? '',\n },\n }\n : {}),\n success: () => {\n resolve()\n },\n fail: (result: { code: number, data: string }) => {\n reject(new InvokeRejectError(result.code, result.data))\n },\n })\n .exec()\n }),\n )\n\n const focus = useMemoizedFn(() =>\n disabled ? Promise.resolve() : invokeInput('focus')\n )\n\n const blur = useMemoizedFn(() => invokeInput('blur'))\n\n const syncNativeValue = useMemoizedFn(\n (nextValue: string) => invokeInput('setValue', nextValue),\n )\n\n const emitValue = useMemoizedFn(\n (nextValue: string, previousValue: string) => {\n if (nextValue === previousValue) {\n return\n }\n\n onChange?.(nextValue)\n\n if (\n nextValue.length === fieldLength\n && previousValue.length !== fieldLength\n ) {\n onComplete?.(nextValue)\n }\n },\n )\n\n const setValue = useMemoizedFn((nextRawValue: string) => {\n const nextValue = normalizeOTPValue(\n nextRawValue,\n fieldLength,\n inputType,\n )\n\n if (!isControlled) {\n setUncontrolledValue(nextValue)\n }\n\n emitValue(nextValue, displayedValue)\n\n return syncNativeValue(nextValue)\n })\n\n useImperativeHandle(\n ref,\n () => ({\n focus,\n blur,\n setValue,\n clear: () => setValue(''),\n getValue: () => displayedValue,\n }),\n [blur, displayedValue, focus, setValue],\n )\n\n useEffect(() => {\n if (isControlled) {\n return\n }\n\n const nextValue = normalizeOTPValue(\n uncontrolledValue,\n fieldLength,\n inputType,\n )\n\n if (nextValue !== uncontrolledValue) {\n setUncontrolledValue(nextValue)\n }\n }, [fieldLength, inputType, isControlled, uncontrolledValue])\n\n useEffect(() => {\n void syncNativeValue(displayedValue).catch(reportInputError)\n }, [displayedValue, syncNativeValue])\n\n useEffect(() => {\n if (autoFocus && !disabled) {\n void focus().catch(reportInputError)\n }\n }, [autoFocus, disabled, focus])\n\n const handleInput = useMemoizedFn(\n (event: BaseEvent<'bindinput', InputInputEvent>) => {\n const rawValue = event.detail.value\n const nextValue = normalizeOTPValue(rawValue, fieldLength, inputType)\n\n if (!isControlled) {\n setUncontrolledValue(nextValue)\n }\n\n emitValue(nextValue, displayedValue)\n\n if (rawValue !== nextValue) {\n void syncNativeValue(nextValue).catch(reportInputError)\n }\n },\n )\n\n const handleFocus = useMemoizedFn(\n (_event: BaseEvent<'bindfocus', InputFocusEvent>) => {\n setFocused(true)\n onInputFocused?.()\n onFocus?.()\n },\n )\n\n const handleBlur = useMemoizedFn(\n (_event: BaseEvent<'bindblur', InputBlurEvent>) => {\n setFocused(false)\n onInputBlurred?.()\n onBlur?.()\n },\n )\n\n const handleTap = useMemoizedFn(() => {\n if (!disabled) {\n void focus().catch(reportInputError)\n }\n })\n\n const contextValue = useMemo<InputOTPRenderProps>(() => ({\n value: displayedValue,\n length: fieldLength,\n inputType,\n focused,\n complete: displayedValue.length === fieldLength,\n disabled,\n invalid,\n }), [\n disabled,\n displayedValue,\n fieldLength,\n focused,\n inputType,\n invalid,\n ])\n\n const renderedChildren = typeof children === 'function'\n ? children(contextValue)\n : children\n\n return (\n <InputOTPContext.Provider value={contextValue}>\n <view\n bindtap={handleTap}\n className={clsx(className, {\n 'ui-focused': focused,\n 'ui-complete': contextValue.complete,\n 'ui-disabled': disabled,\n 'ui-invalid': invalid,\n })}\n flatten={false}\n style={style}\n >\n {renderedChildren}\n <input\n ref={inputRef}\n android-fullscreen-mode={false}\n bindblur={handleBlur}\n bindfocus={handleFocus}\n bindinput={handleInput}\n confirm-type='done'\n disabled={disabled}\n ignore-focus={true}\n input-filter={nativeInputFilters[inputType]}\n ios-auto-correct={false}\n ios-spell-check={false}\n maxlength={fieldLength}\n show-soft-input-on-focus={true}\n style={hiddenInputStyle}\n type={inputType === 'numeric' ? 'number' : 'text'}\n />\n </view>\n </InputOTPContext.Provider>\n )\n}\n"],"names":["hiddenInputStyle","InputOTP","memo","forwardRef","InputOTPImpl","reportInputError","error","console","String","props","ref","length","inputType","value","defaultValue","autoFocus","disabled","invalid","className","style","children","onChange","onComplete","onFocus","onBlur","fieldLength","normalizeInputOTPLength","isControlled","undefined","uncontrolledValue","setUncontrolledValue","useState","normalizeOTPValue","focused","setFocused","inputRef","useRef","onInputBlurred","onInputFocused","useContext","KeyboardAwareTriggerContext","displayedValue","invokeInput","useMemoizedFn","method","nextValue","Promise","resolve","reject","Error","result","InvokeRejectError","focus","blur","syncNativeValue","emitValue","previousValue","setValue","nextRawValue","useImperativeHandle","useEffect","handleInput","event","rawValue","handleFocus","_event","handleBlur","handleTap","contextValue","useMemo","renderedChildren","InputOTPContext","view","clsx","input","nativeInputFilters"],"mappings":";;;;;;AAyCA,MAAMA,mBAAkC;IACtC,UAAU;IACV,KAAK;IACL,MAAM;IACN,OAAO;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AW,KAAK,CAACxC;IAE1C;IAGF,MAAM2D,cAAcrB,cAClB,CAACsB;QACC/B,WAAW;QACXI;QACAf;IACF;IAGF,MAAM2C,aAAavB,cACjB,CAACsB;QACC/B,WAAW;QACXG;QACAb;IACF;IAGF,MAAM2C,YAAYxB,cAAc;QAC9B,IAAI,CAAC3B,UACEoC,QAAQ,KAAK,CAAC/C;IAEvB;IAEA,MAAM+D,eAAeC,QAA6B,IAAO;YACvD,OAAO5B;YACP,QAAQhB;YACRb;YACAqB;YACA,UAAUQ,eAAe,MAAM,KAAKhB;YACpCT;YACAC;QACF,IAAI;QACFD;QACAyB;QACAhB;QACAQ;QACArB;QACAK;KACD;IAED,MAAMqD,mBAAmB,AAAoB,cAApB,OAAOlD,WAC5BA,SAASgD,gBACThD;IAEJ,QACGmD,gBAAgB,SAAS,OAAOH,cAAc;MAC7C,CAACI,KACC,SAASL,WACT,WAAWM,KAAKvD,WAAW;QACzB,cAAce;QACd,eAAemC,aAAa,QAAQ;QACpC,eAAepD;QACf,cAAcC;IAChB,IACA,SAAS,OACT,OAAOE,OACR;QACC,CAACmD,iBAAiB;QAClB,CAACI,MACC,KAAKvC,UACL,yBAAyB,OACzB,UAAU+B,YACV,WAAWF,aACX,WAAWH,aACX,aAAa,OACb,UAAU7C,UACV,cAAc,MACd,cAAc2D,kBAAkB,CAAC/D,UAAU,EAC3C,kBAAkB,OAClB,iBAAiB,OACjB,WAAWa,aACX,0BAA0B,MAC1B,OAAOzB,kBACP,MAAMY,AAAc,cAAdA,YAA0B,WAAW,SAC3C;MACJ,EAAE4D,KAAK;IACT,EAAED,gBAAgB;AAEtB"}
|
|
1
|
+
{"version":3,"file":"InputOTP.jsx","sources":["../src/InputOTP.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport {\n forwardRef,\n memo,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from '@lynx-js/react'\nimport type { ForwardedRef, ReactElement } from '@lynx-js/react'\n\nimport { InvokeRejectError, useMemoizedFn } from '@lynx-js/lynx-ui-common'\nimport { KeyboardAwareTriggerContext } from '@lynx-js/lynx-ui-input'\nimport type {\n BaseEvent,\n CSSProperties,\n InputBlurEvent,\n InputFocusEvent,\n InputInputEvent,\n NodesRef,\n} from '@lynx-js/types'\nimport { clsx } from 'clsx'\n\nimport { InputOTPContext } from './InputOTPContext'\nimport type { InputOTPProps, InputOTPRef, InputOTPRenderProps } from './types'\nimport {\n nativeInputFilters,\n normalizeInputOTPLength,\n normalizeOTPValue,\n} from './utils'\n\ntype InputOTPComponent = (props: InputOTPProps) => ReactElement\n\nconst hiddenInputStyle: CSSProperties = {\n position: 'absolute',\n top: '0px',\n left: '0px',\n width: '1px',\n height: '1px',\n padding: '0px',\n borderWidth: '0px',\n opacity: 0,\n color: 'transparent',\n caretColor: 'transparent',\n backgroundColor: 'transparent',\n}\n\nexport const InputOTP = memo(forwardRef(InputOTPImpl)) as InputOTPComponent\n\nfunction reportInputError(error: unknown) {\n console.warn(\n `[lynx-ui-input-otp][InputOTP] native input command failed: ${\n String(error)\n }`,\n )\n}\n\nfunction InputOTPImpl(\n props: InputOTPProps,\n ref: ForwardedRef<InputOTPRef>,\n) {\n const {\n length = 6,\n inputType = 'numeric',\n value,\n defaultValue = '',\n autoFocus = false,\n disabled = false,\n invalid = false,\n className,\n style,\n children,\n onChange,\n onComplete,\n onFocus,\n onBlur,\n } = props\n\n const fieldLength = normalizeInputOTPLength(length)\n const isControlled = value !== undefined\n const [uncontrolledValue, setUncontrolledValue] = useState(\n normalizeOTPValue(defaultValue, fieldLength, inputType),\n )\n const [focused, setFocused] = useState(false)\n const inputRef = useRef<NodesRef>(null)\n const { onInputBlurred, onInputFocused } = useContext(\n KeyboardAwareTriggerContext,\n )\n\n const displayedValue = normalizeOTPValue(\n isControlled ? value : uncontrolledValue,\n fieldLength,\n inputType,\n )\n\n const invokeInput = useMemoizedFn(\n (\n method: 'focus' | 'blur' | 'setValue',\n nextValue?: string,\n ): Promise<void> =>\n new Promise((resolve, reject) => {\n if (!inputRef.current) {\n reject(new Error('InputOTP input is not mounted.'))\n return\n }\n\n inputRef.current\n .invoke({\n method,\n ...(method === 'setValue'\n ? {\n params: {\n value: nextValue ?? '',\n },\n }\n : {}),\n success: () => {\n resolve()\n },\n fail: (result: { code: number, data: string }) => {\n reject(new InvokeRejectError(result.code, result.data))\n },\n })\n .exec()\n }),\n )\n\n const focus = useMemoizedFn(() =>\n disabled ? Promise.resolve() : invokeInput('focus')\n )\n\n const blur = useMemoizedFn(() => invokeInput('blur'))\n\n const syncNativeValue = useMemoizedFn(\n (nextValue: string) => invokeInput('setValue', nextValue),\n )\n\n const emitValue = useMemoizedFn(\n (nextValue: string, previousValue: string) => {\n if (nextValue === previousValue) {\n return\n }\n\n onChange?.(nextValue)\n\n if (\n nextValue.length === fieldLength\n && previousValue.length !== fieldLength\n ) {\n onComplete?.(nextValue)\n }\n },\n )\n\n const setValue = useMemoizedFn((nextRawValue: string) => {\n const nextValue = normalizeOTPValue(\n nextRawValue,\n fieldLength,\n inputType,\n )\n\n if (!isControlled) {\n setUncontrolledValue(nextValue)\n }\n\n emitValue(nextValue, displayedValue)\n\n return syncNativeValue(nextValue)\n })\n\n useImperativeHandle(\n ref,\n () => ({\n focus,\n blur,\n setValue,\n clear: () => setValue(''),\n getValue: () => displayedValue,\n }),\n [blur, displayedValue, focus, setValue],\n )\n\n useEffect(() => {\n if (isControlled) {\n return\n }\n\n const nextValue = normalizeOTPValue(\n uncontrolledValue,\n fieldLength,\n inputType,\n )\n\n if (nextValue !== uncontrolledValue) {\n setUncontrolledValue(nextValue)\n }\n }, [fieldLength, inputType, isControlled, uncontrolledValue])\n\n useEffect(() => {\n void syncNativeValue(displayedValue).catch(reportInputError)\n }, [displayedValue, syncNativeValue])\n\n useEffect(() => {\n if (autoFocus && !disabled) {\n void focus().catch(reportInputError)\n }\n }, [autoFocus, disabled, focus])\n\n const handleInput = useMemoizedFn(\n (event: BaseEvent<'bindinput', InputInputEvent>) => {\n const rawValue = event.detail.value\n const nextValue = normalizeOTPValue(rawValue, fieldLength, inputType)\n\n if (!isControlled) {\n setUncontrolledValue(nextValue)\n }\n\n emitValue(nextValue, displayedValue)\n\n if (rawValue !== nextValue) {\n void syncNativeValue(nextValue).catch(reportInputError)\n }\n },\n )\n\n const handleFocus = useMemoizedFn(\n (_event: BaseEvent<'bindfocus', InputFocusEvent>) => {\n setFocused(true)\n onInputFocused?.()\n onFocus?.()\n },\n )\n\n const handleBlur = useMemoizedFn(\n (_event: BaseEvent<'bindblur', InputBlurEvent>) => {\n setFocused(false)\n onInputBlurred?.()\n onBlur?.()\n },\n )\n\n const handleTap = useMemoizedFn(() => {\n if (!disabled) {\n void focus().catch(reportInputError)\n }\n })\n\n const contextValue = useMemo<InputOTPRenderProps>(() => ({\n value: displayedValue,\n length: fieldLength,\n inputType,\n focused,\n complete: displayedValue.length === fieldLength,\n disabled,\n invalid,\n }), [\n disabled,\n displayedValue,\n fieldLength,\n focused,\n inputType,\n invalid,\n ])\n\n const renderedChildren = typeof children === 'function'\n ? children(contextValue)\n : children\n\n return (\n <InputOTPContext.Provider value={contextValue}>\n <view\n bindtap={handleTap}\n className={clsx(className, {\n 'ui-focused': focused,\n 'ui-complete': contextValue.complete,\n 'ui-disabled': disabled,\n 'ui-invalid': invalid,\n })}\n flatten={false}\n style={style}\n >\n {renderedChildren}\n <input\n ref={inputRef}\n android-fullscreen-mode={false}\n bindblur={handleBlur}\n bindfocus={handleFocus}\n bindinput={handleInput}\n confirm-type='done'\n disabled={disabled}\n ignore-focus={true}\n input-filter={nativeInputFilters[inputType]}\n ios-auto-correct={false}\n ios-spell-check={false}\n maxlength={fieldLength}\n show-soft-input-on-focus={true}\n style={hiddenInputStyle}\n type={inputType === 'numeric' ? 'number' : 'text'}\n />\n </view>\n </InputOTPContext.Provider>\n )\n}\n"],"names":["hiddenInputStyle","InputOTP","memo","forwardRef","InputOTPImpl","reportInputError","error","console","String","props","ref","length","inputType","value","defaultValue","autoFocus","disabled","invalid","className","style","children","onChange","onComplete","onFocus","onBlur","fieldLength","normalizeInputOTPLength","isControlled","undefined","uncontrolledValue","setUncontrolledValue","useState","normalizeOTPValue","focused","setFocused","inputRef","useRef","onInputBlurred","onInputFocused","useContext","KeyboardAwareTriggerContext","displayedValue","invokeInput","useMemoizedFn","method","nextValue","Promise","resolve","reject","Error","result","InvokeRejectError","focus","blur","syncNativeValue","emitValue","previousValue","setValue","nextRawValue","useImperativeHandle","useEffect","handleInput","event","rawValue","handleFocus","_event","handleBlur","handleTap","contextValue","useMemo","renderedChildren","InputOTPContext","view","clsx","input","nativeInputFilters"],"mappings":";;;;;;AAsCA,MAAMA,mBAAkC;IACtC,UAAU;IACV,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,SAAS;IACT,aAAa;IACb,SAAS;IACT,OAAO;IACP,YAAY;IACZ,iBAAiB;AACnB;AAEO,MAAMC,WAAWC,KAAKC,WAAWC;AAExC,SAASC,iBAAiBC,KAAc;IACtCC,QAAQ,IAAI,CACV,CAAC,2DAA2D,EAC1DC,OAAOF,QACP;AAEN;AAEA,SAASF,aACPK,KAAoB,EACpBC,GAA8B;IAE9B,MAAM,EACJC,SAAS,CAAC,EACVC,YAAY,SAAS,EACrBC,KAAK,EACLC,eAAe,EAAE,EACjBC,YAAY,KAAK,EACjBC,WAAW,KAAK,EAChBC,UAAU,KAAK,EACfC,SAAS,EACTC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,MAAM,EACP,GAAGf;IAEJ,MAAMgB,cAAcC,wBAAwBf;IAC5C,MAAMgB,eAAed,AAAUe,WAAVf;IACrB,MAAM,CAACgB,mBAAmBC,qBAAqB,GAAGC,SAChDC,kBAAkBlB,cAAcW,aAAab;IAE/C,MAAM,CAACqB,SAASC,WAAW,GAAGH,SAAS;IAC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D,iBAAiB;QAClB,CAACI,MACC,KAAKvC,UACL,yBAAyB,OACzB,UAAU+B,YACV,WAAWF,aACX,WAAWH,aACX,aAAa,OACb,UAAU7C,UACV,cAAc,MACd,cAAc2D,kBAAkB,CAAC/D,UAAU,EAC3C,kBAAkB,OAClB,iBAAiB,OACjB,WAAWa,aACX,0BAA0B,MAC1B,OAAOzB,kBACP,MAAMY,AAAc,cAAdA,YAA0B,WAAW,SAC3C;MACJ,EAAE4D,KAAK;IACT,EAAED,gBAAgB;AAEtB"}
|
package/dist/InputOTPSlot.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { ReactElement } from '@lynx-js/react';
|
|
2
|
+
import type { InputOTPSlotProps } from './types/index.js';
|
|
3
|
+
type InputOTPSlotComponent = (props: InputOTPSlotProps) => ReactElement;
|
|
4
|
+
export declare const InputOTPSlot: InputOTPSlotComponent;
|
|
5
|
+
export {};
|
|
3
6
|
//# sourceMappingURL=InputOTPSlot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputOTPSlot.d.ts","sourceRoot":"","sources":["../src/InputOTPSlot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InputOTPSlot.d.ts","sourceRoot":"","sources":["../src/InputOTPSlot.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAKlD,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,SAAS,CAAA;AAEzE,KAAK,qBAAqB,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,YAAY,CAAA;AAEvE,eAAO,MAAM,YAAY,EAA6B,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputOTPSlot.jsx","sources":["../src/InputOTPSlot.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { memo } from '@lynx-js/react'\n\nimport { clsx } from 'clsx'\n\nimport { useInputOTPContext } from './InputOTPContext'\nimport type {
|
|
1
|
+
{"version":3,"file":"InputOTPSlot.jsx","sources":["../src/InputOTPSlot.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { memo } from '@lynx-js/react'\nimport type { ReactElement } from '@lynx-js/react'\n\nimport { clsx } from 'clsx'\n\nimport { useInputOTPContext } from './InputOTPContext'\nimport type { InputOTPSlotProps, InputOTPSlotRenderProps } from './types'\n\ntype InputOTPSlotComponent = (props: InputOTPSlotProps) => ReactElement\n\nexport const InputOTPSlot = memo(InputOTPSlotImpl) as InputOTPSlotComponent\n\nfunction InputOTPSlotImpl(props: InputOTPSlotProps) {\n const {\n index,\n className,\n style,\n children,\n } = props\n const context = useInputOTPContext()\n\n const {\n value,\n length,\n focused,\n complete,\n disabled,\n invalid,\n } = context\n const char = value[index]\n const isFilled = char !== undefined\n const hasFakeCaret = focused\n && !disabled\n && value.length < length\n && index === value.length\n const slotState: InputOTPSlotRenderProps = {\n index,\n char,\n focused: hasFakeCaret,\n filled: isFilled,\n complete,\n disabled,\n invalid,\n }\n const renderedChildren = typeof children === 'function'\n ? children(slotState)\n : children\n\n return (\n <view\n className={clsx(className, {\n 'ui-focused': hasFakeCaret,\n 'ui-filled': isFilled,\n 'ui-complete': complete,\n 'ui-disabled': disabled,\n 'ui-invalid': invalid,\n })}\n style={style}\n >\n {children === undefined\n ? (\n <>\n {char === undefined\n ? null\n : <text>{char}</text>}\n {hasFakeCaret\n ? <view />\n : null}\n </>\n )\n : renderedChildren}\n </view>\n )\n}\n"],"names":["InputOTPSlot","memo","InputOTPSlotImpl","props","index","className","style","children","context","useInputOTPContext","value","length","focused","complete","disabled","invalid","char","isFilled","undefined","hasFakeCaret","slotState","renderedChildren","view","clsx","text"],"mappings":";;;AAcO,MAAMA,eAAeC,KAAKC;AAEjC,SAASA,iBAAiBC,KAAwB;IAChD,MAAM,EACJC,KAAK,EACLC,SAAS,EACTC,KAAK,EACLC,QAAQ,EACT,GAAGJ;IACJ,MAAMK,UAAUC;IAEhB,MAAM,EACJC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACR,GAAGP;IACJ,MAAMQ,OAAON,KAAK,CAACN,MAAM;IACzB,MAAMa,WAAWD,AAASE,WAATF;IACjB,MAAMG,eAAeP,WAChB,CAACE,YACDJ,MAAM,MAAM,GAAGC,UACfP,UAAUM,MAAM,MAAM;IAC3B,MAAMU,YAAqC;QACzChB;QACAY;QACA,SAASG;QACT,QAAQF;QACRJ;QACAC;QACAC;IACF;IACA,MAAMM,mBAAmB,AAAoB,cAApB,OAAOd,WAC5BA,SAASa,aACTb;IAEJ,QACGe,KACC,WAAWC,KAAKlB,WAAW;QACzB,cAAcc;QACd,aAAaF;QACb,eAAeJ;QACf,eAAeC;QACf,cAAcC;IAChB,IACA,OAAOT,OACR;MACC,CAACC,AAAaW,WAAbX,aAEK;YACA,CAACS,AAASE,WAATF,OACG,QACCQ,MAAMR,OAAOQ,MAAM;YACxB,CAACL,gBACIG,SACD,KAAK;UACX,MAEAD,iBAAiB;IACvB,EAAEC;AAEN"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ForwardedRef,
|
|
1
|
+
import type { ForwardedRef, ReactNode } from '@lynx-js/react';
|
|
2
2
|
import type { ComponentBasicProps } from '@lynx-js/lynx-ui-common';
|
|
3
3
|
/**
|
|
4
4
|
* Positive number of slots managed by InputOTP.
|
|
@@ -258,9 +258,9 @@ export interface InputOTPProps extends ComponentBasicProps {
|
|
|
258
258
|
*/
|
|
259
259
|
disabled?: boolean;
|
|
260
260
|
/**
|
|
261
|
-
* Expose the invalid state to render props and the ui-invalid variant.
|
|
261
|
+
* Expose the invalid state to render props and the `ui-invalid` UI variant.
|
|
262
262
|
* @defaultValue false
|
|
263
|
-
* @zh 通过渲染属性和 ui-invalid variant 暴露无效状态。
|
|
263
|
+
* @zh 通过渲染属性和 `ui-invalid` UI variant 暴露无效状态。
|
|
264
264
|
* @Android
|
|
265
265
|
* @iOS
|
|
266
266
|
* @Harmony
|
|
@@ -335,6 +335,4 @@ export interface InputOTPSlotProps extends ComponentBasicProps {
|
|
|
335
335
|
*/
|
|
336
336
|
children?: ReactNode | ((state: InputOTPSlotRenderProps) => ReactNode);
|
|
337
337
|
}
|
|
338
|
-
export type InputOTP = (props: InputOTPProps) => ReactElement;
|
|
339
|
-
export type InputOTPSlot = (props: InputOTPSlotProps) => ReactElement;
|
|
340
338
|
//# sourceMappingURL=index.docs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAElE;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAA;AAEnC;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,SAAS,GACT,cAAc,CAAA;AAElB;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;;OAGG;IACH,MAAM,EAAE,cAAc,CAAA;IAEtB;;;OAGG;IACH,SAAS,EAAE,iBAAiB,CAAA;IAE5B;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAA;IAEhB;;;OAGG;IACH,QAAQ,EAA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EACL,SAAS,GACT,CAAC,CAAC,KAAK,EAAE,uBAAuB,KAAK,SAAS,CAAC,CAAA;CACpD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-input-otp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.140.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"clsx": "^2.1.1",
|
|
29
|
-
"@lynx-js/lynx-ui-
|
|
30
|
-
"@lynx-js/lynx-ui-
|
|
29
|
+
"@lynx-js/lynx-ui-input": "3.140.1",
|
|
30
|
+
"@lynx-js/lynx-ui-common": "3.139.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@lynx-js/react": "0.123.1",
|
package/src/InputOTP.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
useRef,
|
|
13
13
|
useState,
|
|
14
14
|
} from '@lynx-js/react'
|
|
15
|
-
import type { ForwardedRef } from '@lynx-js/react'
|
|
15
|
+
import type { ForwardedRef, ReactElement } from '@lynx-js/react'
|
|
16
16
|
|
|
17
17
|
import { InvokeRejectError, useMemoizedFn } from '@lynx-js/lynx-ui-common'
|
|
18
18
|
import { KeyboardAwareTriggerContext } from '@lynx-js/lynx-ui-input'
|
|
@@ -27,18 +27,15 @@ import type {
|
|
|
27
27
|
import { clsx } from 'clsx'
|
|
28
28
|
|
|
29
29
|
import { InputOTPContext } from './InputOTPContext'
|
|
30
|
-
import type {
|
|
31
|
-
InputOTPProps,
|
|
32
|
-
InputOTPRef,
|
|
33
|
-
InputOTPRenderProps,
|
|
34
|
-
InputOTP as InputOTPType,
|
|
35
|
-
} from './types'
|
|
30
|
+
import type { InputOTPProps, InputOTPRef, InputOTPRenderProps } from './types'
|
|
36
31
|
import {
|
|
37
32
|
nativeInputFilters,
|
|
38
33
|
normalizeInputOTPLength,
|
|
39
34
|
normalizeOTPValue,
|
|
40
35
|
} from './utils'
|
|
41
36
|
|
|
37
|
+
type InputOTPComponent = (props: InputOTPProps) => ReactElement
|
|
38
|
+
|
|
42
39
|
const hiddenInputStyle: CSSProperties = {
|
|
43
40
|
position: 'absolute',
|
|
44
41
|
top: '0px',
|
|
@@ -53,7 +50,7 @@ const hiddenInputStyle: CSSProperties = {
|
|
|
53
50
|
backgroundColor: 'transparent',
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
export const InputOTP = memo(forwardRef(InputOTPImpl)) as
|
|
53
|
+
export const InputOTP = memo(forwardRef(InputOTPImpl)) as InputOTPComponent
|
|
57
54
|
|
|
58
55
|
function reportInputError(error: unknown) {
|
|
59
56
|
console.warn(
|
package/src/InputOTPSlot.tsx
CHANGED
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
5
|
import { memo } from '@lynx-js/react'
|
|
6
|
+
import type { ReactElement } from '@lynx-js/react'
|
|
6
7
|
|
|
7
8
|
import { clsx } from 'clsx'
|
|
8
9
|
|
|
9
10
|
import { useInputOTPContext } from './InputOTPContext'
|
|
10
|
-
import type {
|
|
11
|
-
InputOTPSlotProps,
|
|
12
|
-
InputOTPSlotRenderProps,
|
|
13
|
-
InputOTPSlot as InputOTPSlotType,
|
|
14
|
-
} from './types'
|
|
11
|
+
import type { InputOTPSlotProps, InputOTPSlotRenderProps } from './types'
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
type InputOTPSlotComponent = (props: InputOTPSlotProps) => ReactElement
|
|
14
|
+
|
|
15
|
+
export const InputOTPSlot = memo(InputOTPSlotImpl) as InputOTPSlotComponent
|
|
17
16
|
|
|
18
17
|
function InputOTPSlotImpl(props: InputOTPSlotProps) {
|
|
19
18
|
const {
|
package/src/types/index.docs.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
import type { ForwardedRef,
|
|
5
|
+
import type { ForwardedRef, ReactNode } from '@lynx-js/react'
|
|
6
6
|
|
|
7
7
|
import type { ComponentBasicProps } from '@lynx-js/lynx-ui-common'
|
|
8
8
|
|
|
@@ -304,9 +304,9 @@ export interface InputOTPProps extends ComponentBasicProps {
|
|
|
304
304
|
disabled?: boolean
|
|
305
305
|
|
|
306
306
|
/**
|
|
307
|
-
* Expose the invalid state to render props and the ui-invalid variant.
|
|
307
|
+
* Expose the invalid state to render props and the `ui-invalid` UI variant.
|
|
308
308
|
* @defaultValue false
|
|
309
|
-
* @zh 通过渲染属性和 ui-invalid variant 暴露无效状态。
|
|
309
|
+
* @zh 通过渲染属性和 `ui-invalid` UI variant 暴露无效状态。
|
|
310
310
|
* @Android
|
|
311
311
|
* @iOS
|
|
312
312
|
* @Harmony
|
|
@@ -392,6 +392,3 @@ export interface InputOTPSlotProps extends ComponentBasicProps {
|
|
|
392
392
|
| ReactNode
|
|
393
393
|
| ((state: InputOTPSlotRenderProps) => ReactNode)
|
|
394
394
|
}
|
|
395
|
-
|
|
396
|
-
export type InputOTP = (props: InputOTPProps) => ReactElement
|
|
397
|
-
export type InputOTPSlot = (props: InputOTPSlotProps) => ReactElement
|