@dxos/react-input 0.11.0 → 0.12.0-next-2be9f24c465d98f4bd186aa03ece788902e6c17a
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/lib/index.mjs
CHANGED
|
@@ -12,7 +12,8 @@ var [InputProvider, useInputContext] = createInputContext(INPUT_NAME);
|
|
|
12
12
|
//#region src/InputMeta.tsx
|
|
13
13
|
var Label = forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
14
14
|
const { id } = useInputContext(INPUT_NAME, __inputScope);
|
|
15
|
-
|
|
15
|
+
const Comp = asChild ? Slot : Primitive.label;
|
|
16
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
16
17
|
...props,
|
|
17
18
|
htmlFor: id,
|
|
18
19
|
ref: forwardedRef,
|
|
@@ -21,7 +22,8 @@ var Label = forwardRef(({ __inputScope, asChild, children, ...props }, forwarded
|
|
|
21
22
|
});
|
|
22
23
|
var Description = forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
23
24
|
const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
24
|
-
|
|
25
|
+
const Comp = asChild ? Slot : Primitive.span;
|
|
26
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
25
27
|
...props,
|
|
26
28
|
...validationValence === "error" && { id: descriptionId },
|
|
27
29
|
ref: forwardedRef,
|
|
@@ -30,7 +32,8 @@ var Description = forwardRef(({ __inputScope, asChild, children, ...props }, for
|
|
|
30
32
|
});
|
|
31
33
|
var ErrorMessage = forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
32
34
|
const { errorMessageId } = useInputContext(INPUT_NAME, __inputScope);
|
|
33
|
-
|
|
35
|
+
const Comp = asChild ? Slot : Primitive.span;
|
|
36
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
34
37
|
...props,
|
|
35
38
|
id: errorMessageId,
|
|
36
39
|
ref: forwardedRef,
|
|
@@ -44,15 +47,19 @@ var Validation = forwardRef((props, forwardedRef) => {
|
|
|
44
47
|
...props,
|
|
45
48
|
ref: forwardedRef
|
|
46
49
|
});
|
|
47
|
-
else
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
else {
|
|
51
|
+
const Comp = asChild ? Slot : Primitive.span;
|
|
52
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
53
|
+
...otherProps,
|
|
54
|
+
ref: forwardedRef,
|
|
55
|
+
children
|
|
56
|
+
});
|
|
57
|
+
}
|
|
52
58
|
});
|
|
53
59
|
var DescriptionAndValidation = forwardRef(({ __inputScope, asChild, children, ...props }, forwardedRef) => {
|
|
54
60
|
const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);
|
|
55
|
-
|
|
61
|
+
const Comp = asChild ? Slot : Primitive.p;
|
|
62
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
56
63
|
...props,
|
|
57
64
|
...validationValence !== "error" && { id: descriptionId },
|
|
58
65
|
ref: forwardedRef,
|
|
@@ -62,10 +69,13 @@ var DescriptionAndValidation = forwardRef(({ __inputScope, asChild, children, ..
|
|
|
62
69
|
//#endregion
|
|
63
70
|
//#region src/Root.tsx
|
|
64
71
|
var InputRoot = ({ __inputScope, id: propsId, descriptionId: propsDescriptionId, errorMessageId: propsErrorMessageId, validationValence = "neutral", children }) => {
|
|
72
|
+
const id = useId("input", propsId);
|
|
73
|
+
const descriptionId = useId("input__description", propsDescriptionId);
|
|
74
|
+
const errorMessageId = useId("input__error-message", propsErrorMessageId);
|
|
65
75
|
return /* @__PURE__ */ jsx(InputProvider, {
|
|
66
|
-
id
|
|
67
|
-
descriptionId
|
|
68
|
-
errorMessageId
|
|
76
|
+
id,
|
|
77
|
+
descriptionId,
|
|
78
|
+
errorMessageId,
|
|
69
79
|
validationValence,
|
|
70
80
|
scope: __inputScope,
|
|
71
81
|
children
|
package/dist/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/InputContext.ts","../../src/InputMeta.tsx","../../src/Root.tsx","../../src/PinInput.tsx","../../src/TextInput.tsx","../../src/TextArea.tsx"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { type PropsWithChildren } from 'react';\n\n// Kept out of `Root.tsx`: react-refresh only fast-refreshes a module whose exports are all\n// components, so a context and its hook exported beside them force a full page reload on every edit.\n\nexport const INPUT_NAME = 'Input';\n\nexport type Valence = 'success' | 'info' | 'warning' | 'error' | 'neutral';\n\nexport type InputScopedProps<P> = P & { __inputScope?: Scope };\n\nexport type InputRootProps = PropsWithChildren<{\n id?: string;\n validationValence?: Valence;\n descriptionId?: string;\n errorMessageId?: string;\n}>;\n\nexport const [createInputContext, createInputScope] = createContextScope(INPUT_NAME, []);\n\nexport type InputContextValue = {\n id: string;\n descriptionId: string;\n errorMessageId: string;\n validationValence: Valence;\n};\n\nexport const [InputProvider, useInputContext] = createInputContext<InputContextValue>(INPUT_NAME);\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nimport { INPUT_NAME, type InputScopedProps, useInputContext } from './InputContext';\n\ntype LabelProps = ComponentPropsWithRef<typeof Primitive.label> & { asChild?: boolean };\n\nconst Label = forwardRef<HTMLLabelElement, LabelProps>(\n ({ __inputScope, asChild, children, ...props }: InputScopedProps<LabelProps>, forwardedRef) => {\n const { id } = useInputContext(INPUT_NAME, __inputScope);\n const Comp = asChild ? Slot : Primitive.label;\n return (\n <Comp {...props} htmlFor={id} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype DescriptionProps = Omit<ComponentPropsWithRef<typeof Primitive.span>, 'id'> & { asChild?: boolean };\n\nconst Description = forwardRef<HTMLSpanElement, DescriptionProps>(\n ({ __inputScope, asChild, children, ...props }: InputScopedProps<DescriptionProps>, forwardedRef) => {\n const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);\n const Comp = asChild ? Slot : Primitive.span;\n return (\n <Comp {...props} {...(validationValence === 'error' && { id: descriptionId })} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype ErrorMessageProps = Omit<ComponentPropsWithRef<typeof Primitive.span>, 'id'> & { asChild?: boolean };\n\nconst ErrorMessage = forwardRef<HTMLSpanElement, ErrorMessageProps>(\n ({ __inputScope, asChild, children, ...props }: InputScopedProps<ErrorMessageProps>, forwardedRef) => {\n const { errorMessageId } = useInputContext(INPUT_NAME, __inputScope);\n const Comp = asChild ? Slot : Primitive.span;\n return (\n <Comp {...props} id={errorMessageId} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype ValidationProps = Omit<ComponentPropsWithRef<typeof Primitive.span>, 'id'> & { asChild?: boolean };\n\nconst Validation = forwardRef<HTMLSpanElement, ValidationProps>(\n (props: InputScopedProps<ValidationProps>, forwardedRef) => {\n const { __inputScope, asChild, children, ...otherProps } = props;\n const { validationValence } = useInputContext(INPUT_NAME, __inputScope);\n if (validationValence === 'error') {\n return <ErrorMessage {...props} ref={forwardedRef} />;\n } else {\n const Comp = asChild ? Slot : Primitive.span;\n return (\n <Comp {...otherProps} ref={forwardedRef}>\n {children}\n </Comp>\n );\n }\n },\n);\n\ntype DescriptionAndValidationProps = ComponentPropsWithRef<typeof Primitive.p> & { asChild?: boolean };\n\nconst DescriptionAndValidation = forwardRef<HTMLParagraphElement, DescriptionAndValidationProps>(\n ({ __inputScope, asChild, children, ...props }: InputScopedProps<DescriptionAndValidationProps>, forwardedRef) => {\n const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);\n const Comp = asChild ? Slot : Primitive.p;\n return (\n <Comp {...props} {...(validationValence !== 'error' && { id: descriptionId })} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\nexport { Description, DescriptionAndValidation, ErrorMessage, Label, Validation };\n\nexport type { DescriptionAndValidationProps, DescriptionProps, ErrorMessageProps, LabelProps, ValidationProps };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { INPUT_NAME, InputProvider, type InputRootProps, type InputScopedProps, type Valence } from './InputContext';\n\nconst InputRoot = ({\n __inputScope,\n id: propsId,\n descriptionId: propsDescriptionId,\n errorMessageId: propsErrorMessageId,\n validationValence = 'neutral',\n children,\n}: InputScopedProps<InputRootProps>) => {\n const id = useId('input', propsId);\n const descriptionId = useId('input__description', propsDescriptionId);\n const errorMessageId = useId('input__error-message', propsErrorMessageId);\n return (\n <InputProvider {...{ id, descriptionId, errorMessageId, validationValence }} scope={__inputScope}>\n {children}\n </InputProvider>\n );\n};\n\nInputRoot.displayName = INPUT_NAME;\n\nexport { InputRoot };\n\nexport type { InputRootProps, InputScopedProps, Valence };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport React, {\n type ChangeEvent,\n type ClipboardEvent,\n type ComponentPropsWithRef,\n type KeyboardEvent,\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { useForwardedRef, useIsFocused } from '@dxos/react-hooks';\n\nimport { INPUT_NAME, type InputScopedProps, useInputContext } from './InputContext';\n\ntype PinInputProps = Omit<ComponentPropsWithRef<'input'>, 'type' | 'maxLength'> & {\n /** Class name applied to each segment div. */\n segmentClassName?: string;\n /** Number of code segments. */\n length?: number;\n};\n\nconst PinInput = forwardRef<HTMLInputElement, PinInputProps>(\n (\n {\n __inputScope,\n className,\n disabled,\n segmentClassName,\n length = 6,\n pattern,\n value: controlledValue,\n onChange,\n onPaste,\n ...props\n }: InputScopedProps<PinInputProps>,\n forwardedRef,\n ) => {\n const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);\n const inputRef = useForwardedRef(forwardedRef);\n const inputFocused = useIsFocused(inputRef);\n const [internalValue, setInternalValue] = useState('');\n const [cursorPosition, setCursorPosition] = useState(0);\n\n const value = controlledValue != null ? String(controlledValue) : internalValue;\n\n // Derive a per-character filter from the `pattern` prop (e.g., `\\\\d*` → test each char against `\\\\d`).\n const charPattern = useMemo(() => {\n if (!pattern) {\n return undefined;\n }\n try {\n // Strip quantifiers (*, +, {n}) to get the base character class.\n const base = pattern.replace(/[*+?]$|\\{\\d+,?\\d*\\}$/g, '');\n return new RegExp(`^${base}$`);\n } catch {\n return undefined;\n }\n }, [pattern]);\n\n /** Filter a string to only characters matching the pattern. */\n const filterValue = useCallback(\n (input: string) => {\n if (!charPattern) {\n return input;\n }\n return input\n .split('')\n .filter((char) => charPattern.test(char))\n .join('');\n },\n [charPattern],\n );\n\n // Sync cursor position from the hidden input's selection.\n const syncCursor = useCallback(() => {\n const pos = inputRef.current?.selectionStart ?? value.length;\n setCursorPosition(Math.min(pos, value.length));\n }, [inputRef, value.length]);\n\n // Keep cursor in sync after value changes.\n useEffect(() => {\n setCursorPosition((prev) => Math.min(prev, value.length));\n }, [value.length]);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const newValue = filterValue(event.target.value).slice(0, length);\n if (controlledValue == null) {\n setInternalValue(newValue);\n }\n setCursorPosition(event.target.selectionStart ?? newValue.length);\n onChange?.(event);\n },\n [length, controlledValue, onChange, filterValue],\n );\n\n const handlePaste = useCallback(\n (event: ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event);\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n const pasted = filterValue(event.clipboardData.getData('text/plain')).slice(0, length);\n const input = inputRef.current;\n if (!input) {\n return;\n }\n // Use native setter to trigger React's synthetic onChange.\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;\n nativeInputValueSetter?.call(input, pasted);\n input.dispatchEvent(new Event('input', { bubbles: true }));\n },\n [length, inputRef, onPaste, filterValue],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {\n // Let the native input handle cursor movement, then sync.\n requestAnimationFrame(syncCursor);\n } else if (event.key === 'Backspace' && value.length === 0) {\n event.preventDefault();\n } else if (event.key.length === 1 && !event.metaKey && !event.ctrlKey && !event.altKey) {\n // Reject characters that don't match the allow pattern.\n if (charPattern && !charPattern.test(event.key)) {\n event.preventDefault();\n props.onKeyDown?.(event);\n return;\n }\n // Overwrite mode: replace character at cursor position instead of inserting.\n const input = inputRef.current;\n const pos = input?.selectionStart ?? value.length;\n if (pos < value.length && input) {\n event.preventDefault();\n const newValue = value.slice(0, pos) + event.key + value.slice(pos + 1);\n const newPos = Math.min(pos + 1, length);\n // Update state and cursor synchronously to avoid flicker.\n if (controlledValue == null) {\n setInternalValue(newValue);\n }\n setCursorPosition(newPos);\n // Sync the native input to match.\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;\n nativeInputValueSetter?.call(input, newValue);\n input.setSelectionRange(newPos, newPos);\n // Notify consumer via onChange with a synthetic-like event.\n onChange?.({ target: input, currentTarget: input } as ChangeEvent<HTMLInputElement>);\n }\n }\n props.onKeyDown?.(event);\n },\n [value, length, props.onKeyDown, syncCursor, inputRef, charPattern, controlledValue, onChange],\n );\n\n const handleSelect = useCallback(() => {\n syncCursor();\n }, [syncCursor]);\n\n const activeIndex = Math.min(cursorPosition, value.length < length ? value.length : length - 1);\n\n return (\n <div className={`relative inline-flex items-center gap-2 ${className ?? ''}`}>\n <input\n ref={inputRef}\n id={id}\n type='text'\n value={value}\n onChange={handleChange}\n onPaste={handlePaste}\n onKeyDown={handleKeyDown}\n onSelect={handleSelect}\n maxLength={length}\n disabled={disabled}\n spellCheck={false}\n aria-describedby={descriptionId}\n {...(validationValence === 'error' && {\n 'aria-invalid': 'true' as const,\n 'aria-errormessage': errorMessageId,\n })}\n {...props}\n pattern={pattern}\n className='dx-fullscreen opacity-0'\n style={{\n caretColor: 'transparent',\n ...props.style,\n }}\n />\n {Array.from({ length }, (_, index) => {\n const char = value[index] || '\\u00A0';\n const isCursor = !!(inputFocused && index === activeIndex);\n return (\n <div key={index} className={segmentClassName} {...(isCursor && { 'data-focused': '' })} aria-hidden='true'>\n {char}\n </div>\n );\n })}\n </div>\n );\n },\n);\n\nexport { PinInput };\n\nexport type { PinInputProps };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { Primitive } from '@radix-ui/react-primitive';\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nimport { INPUT_NAME, type InputScopedProps, useInputContext } from './InputContext';\n\ntype TextInputProps = Omit<ComponentPropsWithRef<typeof Primitive.input>, 'id'>;\n\nconst TextInput = forwardRef<HTMLInputElement, TextInputProps>(\n ({ __inputScope, ...props }: InputScopedProps<TextInputProps>, forwardedRef) => {\n const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);\n return (\n <Primitive.input\n {...{\n ...props,\n id,\n 'aria-describedby': descriptionId,\n ...(validationValence === 'error' && {\n 'aria-invalid': 'true' as const,\n 'aria-errormessage': errorMessageId,\n }),\n 'ref': forwardedRef,\n }}\n />\n );\n },\n);\n\nexport { TextInput };\n\nexport type { TextInputProps };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nimport { INPUT_NAME, type InputScopedProps, useInputContext } from './InputContext';\n\ntype TextAreaProps = Omit<ComponentPropsWithRef<'textarea'>, 'id'>;\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n ({ __inputScope, ...props }: InputScopedProps<TextAreaProps>, forwardedRef) => {\n const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);\n return (\n <textarea\n {...{\n ...props,\n id,\n 'aria-describedby': descriptionId,\n ...(validationValence === 'error' && {\n 'aria-invalid': 'true' as const,\n 'aria-errormessage': errorMess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;GACvB;GACA,GAAI;GACK;GACT,WAAU;GACV,OAAO;IACL,YAAY;IACZ,GAAG,MAAM;GACX;EACD,CAAA,GACA,MAAM,KAAK,EAAE,OAAO,IAAI,GAAG,UAAU;GACpC,MAAM,OAAO,MAAM,UAAU;GAE7B,OACE,oBAAC,OAAD;IAAiB,WAAW;IAAkB,GAAK,CAFnC,EAAE,gBAAgB,UAAU,gBAEmB,EAAE,gBAAgB,GAAG;IAAI,eAAY;cACjG;GACE,GAFK,KAEL;EAET,CAAC,CACE;;AAET,CACF;;;ACnMA,IAAM,YAAY,YACf,EAAE,cAAc,GAAG,SAA2C,iBAAiB;CAC9E,MAAM,EAAE,IAAI,mBAAmB,eAAe,mBAAmB,gBAAgB,YAAY,YAAY;CACzG,OACE,oBAAC,UAAU,OAAX;EAEI,GAAG;EACH;EACA,oBAAoB;EACpB,GAAI,sBAAsB,WAAW;GACnC,gBAAgB;GAChB,qBAAqB;EACvB;EACA,OAAO;CAEV,CAAA;AAEL,CACF;;;ACnBA,IAAM,WAAW,YACd,EAAE,cAAc,GAAG,SAA0C,iBAAiB;CAC7E,MAAM,EAAE,IAAI,mBAAmB,eAAe,mBAAmB,gBAAgB,YAAY,YAAY;CACzG,OACE,oBAAC,YAAD;EAEI,GAAG;EACH;EACA,oBAAoB;EACpB,GAAI,sBAAsB,WAAW;GACnC,gBAAgB;GAChB,qBAAqB;EACvB;EACA,OAAO;CAEV,CAAA;AAEL,CACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/InputContext.ts","../../src/InputMeta.tsx","../../src/Root.tsx","../../src/PinInput.tsx","../../src/TextInput.tsx","../../src/TextArea.tsx"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { type PropsWithChildren } from 'react';\n\n// Kept out of `Root.tsx`: react-refresh only fast-refreshes a module whose exports are all\n// components, so a context and its hook exported beside them force a full page reload on every edit.\n\nexport const INPUT_NAME = 'Input';\n\nexport type Valence = 'success' | 'info' | 'warning' | 'error' | 'neutral';\n\nexport type InputScopedProps<P> = P & { __inputScope?: Scope };\n\nexport type InputRootProps = PropsWithChildren<{\n id?: string;\n validationValence?: Valence;\n descriptionId?: string;\n errorMessageId?: string;\n}>;\n\nexport const [createInputContext, createInputScope] = createContextScope(INPUT_NAME, []);\n\nexport type InputContextValue = {\n id: string;\n descriptionId: string;\n errorMessageId: string;\n validationValence: Valence;\n};\n\nexport const [InputProvider, useInputContext] = createInputContext<InputContextValue>(INPUT_NAME);\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nimport { INPUT_NAME, type InputScopedProps, useInputContext } from './InputContext';\n\ntype LabelProps = ComponentPropsWithRef<typeof Primitive.label> & { asChild?: boolean };\n\nconst Label = forwardRef<HTMLLabelElement, LabelProps>(\n ({ __inputScope, asChild, children, ...props }: InputScopedProps<LabelProps>, forwardedRef) => {\n const { id } = useInputContext(INPUT_NAME, __inputScope);\n const Comp = asChild ? Slot : Primitive.label;\n return (\n <Comp {...props} htmlFor={id} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype DescriptionProps = Omit<ComponentPropsWithRef<typeof Primitive.span>, 'id'> & { asChild?: boolean };\n\nconst Description = forwardRef<HTMLSpanElement, DescriptionProps>(\n ({ __inputScope, asChild, children, ...props }: InputScopedProps<DescriptionProps>, forwardedRef) => {\n const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);\n const Comp = asChild ? Slot : Primitive.span;\n return (\n <Comp {...props} {...(validationValence === 'error' && { id: descriptionId })} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype ErrorMessageProps = Omit<ComponentPropsWithRef<typeof Primitive.span>, 'id'> & { asChild?: boolean };\n\nconst ErrorMessage = forwardRef<HTMLSpanElement, ErrorMessageProps>(\n ({ __inputScope, asChild, children, ...props }: InputScopedProps<ErrorMessageProps>, forwardedRef) => {\n const { errorMessageId } = useInputContext(INPUT_NAME, __inputScope);\n const Comp = asChild ? Slot : Primitive.span;\n return (\n <Comp {...props} id={errorMessageId} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype ValidationProps = Omit<ComponentPropsWithRef<typeof Primitive.span>, 'id'> & { asChild?: boolean };\n\nconst Validation = forwardRef<HTMLSpanElement, ValidationProps>(\n (props: InputScopedProps<ValidationProps>, forwardedRef) => {\n const { __inputScope, asChild, children, ...otherProps } = props;\n const { validationValence } = useInputContext(INPUT_NAME, __inputScope);\n if (validationValence === 'error') {\n return <ErrorMessage {...props} ref={forwardedRef} />;\n } else {\n const Comp = asChild ? Slot : Primitive.span;\n return (\n <Comp {...otherProps} ref={forwardedRef}>\n {children}\n </Comp>\n );\n }\n },\n);\n\ntype DescriptionAndValidationProps = ComponentPropsWithRef<typeof Primitive.p> & { asChild?: boolean };\n\nconst DescriptionAndValidation = forwardRef<HTMLParagraphElement, DescriptionAndValidationProps>(\n ({ __inputScope, asChild, children, ...props }: InputScopedProps<DescriptionAndValidationProps>, forwardedRef) => {\n const { descriptionId, validationValence } = useInputContext(INPUT_NAME, __inputScope);\n const Comp = asChild ? Slot : Primitive.p;\n return (\n <Comp {...props} {...(validationValence !== 'error' && { id: descriptionId })} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\nexport { Description, DescriptionAndValidation, ErrorMessage, Label, Validation };\n\nexport type { DescriptionAndValidationProps, DescriptionProps, ErrorMessageProps, LabelProps, ValidationProps };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { INPUT_NAME, InputProvider, type InputRootProps, type InputScopedProps, type Valence } from './InputContext';\n\nconst InputRoot = ({\n __inputScope,\n id: propsId,\n descriptionId: propsDescriptionId,\n errorMessageId: propsErrorMessageId,\n validationValence = 'neutral',\n children,\n}: InputScopedProps<InputRootProps>) => {\n const id = useId('input', propsId);\n const descriptionId = useId('input__description', propsDescriptionId);\n const errorMessageId = useId('input__error-message', propsErrorMessageId);\n return (\n <InputProvider {...{ id, descriptionId, errorMessageId, validationValence }} scope={__inputScope}>\n {children}\n </InputProvider>\n );\n};\n\nInputRoot.displayName = INPUT_NAME;\n\nexport { InputRoot };\n\nexport type { InputRootProps, InputScopedProps, Valence };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport React, {\n type ChangeEvent,\n type ClipboardEvent,\n type ComponentPropsWithRef,\n type KeyboardEvent,\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport { useForwardedRef, useIsFocused } from '@dxos/react-hooks';\n\nimport { INPUT_NAME, type InputScopedProps, useInputContext } from './InputContext';\n\ntype PinInputProps = Omit<ComponentPropsWithRef<'input'>, 'type' | 'maxLength'> & {\n /** Class name applied to each segment div. */\n segmentClassName?: string;\n /** Number of code segments. */\n length?: number;\n};\n\nconst PinInput = forwardRef<HTMLInputElement, PinInputProps>(\n (\n {\n __inputScope,\n className,\n disabled,\n segmentClassName,\n length = 6,\n pattern,\n value: controlledValue,\n onChange,\n onPaste,\n ...props\n }: InputScopedProps<PinInputProps>,\n forwardedRef,\n ) => {\n const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);\n const inputRef = useForwardedRef(forwardedRef);\n const inputFocused = useIsFocused(inputRef);\n const [internalValue, setInternalValue] = useState('');\n const [cursorPosition, setCursorPosition] = useState(0);\n\n const value = controlledValue != null ? String(controlledValue) : internalValue;\n\n // Derive a per-character filter from the `pattern` prop (e.g., `\\\\d*` → test each char against `\\\\d`).\n const charPattern = useMemo(() => {\n if (!pattern) {\n return undefined;\n }\n try {\n // Strip quantifiers (*, +, {n}) to get the base character class.\n const base = pattern.replace(/[*+?]$|\\{\\d+,?\\d*\\}$/g, '');\n return new RegExp(`^${base}$`);\n } catch {\n return undefined;\n }\n }, [pattern]);\n\n /** Filter a string to only characters matching the pattern. */\n const filterValue = useCallback(\n (input: string) => {\n if (!charPattern) {\n return input;\n }\n return input\n .split('')\n .filter((char) => charPattern.test(char))\n .join('');\n },\n [charPattern],\n );\n\n // Sync cursor position from the hidden input's selection.\n const syncCursor = useCallback(() => {\n const pos = inputRef.current?.selectionStart ?? value.length;\n setCursorPosition(Math.min(pos, value.length));\n }, [inputRef, value.length]);\n\n // Keep cursor in sync after value changes.\n useEffect(() => {\n setCursorPosition((prev) => Math.min(prev, value.length));\n }, [value.length]);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const newValue = filterValue(event.target.value).slice(0, length);\n if (controlledValue == null) {\n setInternalValue(newValue);\n }\n setCursorPosition(event.target.selectionStart ?? newValue.length);\n onChange?.(event);\n },\n [length, controlledValue, onChange, filterValue],\n );\n\n const handlePaste = useCallback(\n (event: ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event);\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n const pasted = filterValue(event.clipboardData.getData('text/plain')).slice(0, length);\n const input = inputRef.current;\n if (!input) {\n return;\n }\n // Use native setter to trigger React's synthetic onChange.\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;\n nativeInputValueSetter?.call(input, pasted);\n input.dispatchEvent(new Event('input', { bubbles: true }));\n },\n [length, inputRef, onPaste, filterValue],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {\n // Let the native input handle cursor movement, then sync.\n requestAnimationFrame(syncCursor);\n } else if (event.key === 'Backspace' && value.length === 0) {\n event.preventDefault();\n } else if (event.key.length === 1 && !event.metaKey && !event.ctrlKey && !event.altKey) {\n // Reject characters that don't match the allow pattern.\n if (charPattern && !charPattern.test(event.key)) {\n event.preventDefault();\n props.onKeyDown?.(event);\n return;\n }\n // Overwrite mode: replace character at cursor position instead of inserting.\n const input = inputRef.current;\n const pos = input?.selectionStart ?? value.length;\n if (pos < value.length && input) {\n event.preventDefault();\n const newValue = value.slice(0, pos) + event.key + value.slice(pos + 1);\n const newPos = Math.min(pos + 1, length);\n // Update state and cursor synchronously to avoid flicker.\n if (controlledValue == null) {\n setInternalValue(newValue);\n }\n setCursorPosition(newPos);\n // Sync the native input to match.\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;\n nativeInputValueSetter?.call(input, newValue);\n input.setSelectionRange(newPos, newPos);\n // Notify consumer via onChange with a synthetic-like event.\n onChange?.({ target: input, currentTarget: input } as ChangeEvent<HTMLInputElement>);\n }\n }\n props.onKeyDown?.(event);\n },\n [value, length, props.onKeyDown, syncCursor, inputRef, charPattern, controlledValue, onChange],\n );\n\n const handleSelect = useCallback(() => {\n syncCursor();\n }, [syncCursor]);\n\n const activeIndex = Math.min(cursorPosition, value.length < length ? value.length : length - 1);\n\n return (\n <div className={`relative inline-flex items-center gap-2 ${className ?? ''}`}>\n <input\n ref={inputRef}\n id={id}\n type='text'\n value={value}\n onChange={handleChange}\n onPaste={handlePaste}\n onKeyDown={handleKeyDown}\n onSelect={handleSelect}\n maxLength={length}\n disabled={disabled}\n spellCheck={false}\n aria-describedby={descriptionId}\n {...(validationValence === 'error' && {\n 'aria-invalid': 'true' as const,\n 'aria-errormessage': errorMessageId,\n })}\n {...props}\n pattern={pattern}\n className='dx-fullscreen opacity-0'\n style={{\n caretColor: 'transparent',\n ...props.style,\n }}\n />\n {Array.from({ length }, (_, index) => {\n const char = value[index] || '\\u00A0';\n const isCursor = !!(inputFocused && index === activeIndex);\n return (\n <div key={index} className={segmentClassName} {...(isCursor && { 'data-focused': '' })} aria-hidden='true'>\n {char}\n </div>\n );\n })}\n </div>\n );\n },\n);\n\nexport { PinInput };\n\nexport type { PinInputProps };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { Primitive } from '@radix-ui/react-primitive';\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nimport { INPUT_NAME, type InputScopedProps, useInputContext } from './InputContext';\n\ntype TextInputProps = Omit<ComponentPropsWithRef<typeof Primitive.input>, 'id'>;\n\nconst TextInput = forwardRef<HTMLInputElement, TextInputProps>(\n ({ __inputScope, ...props }: InputScopedProps<TextInputProps>, forwardedRef) => {\n const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);\n return (\n <Primitive.input\n {...{\n ...props,\n id,\n 'aria-describedby': descriptionId,\n ...(validationValence === 'error' && {\n 'aria-invalid': 'true' as const,\n 'aria-errormessage': errorMessageId,\n }),\n 'ref': forwardedRef,\n }}\n />\n );\n },\n);\n\nexport { TextInput };\n\nexport type { TextInputProps };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nimport { INPUT_NAME, type InputScopedProps, useInputContext } from './InputContext';\n\ntype TextAreaProps = Omit<ComponentPropsWithRef<'textarea'>, 'id'>;\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n ({ __inputScope, ...props }: InputScopedProps<TextAreaProps>, forwardedRef) => {\n const { id, validationValence, descriptionId, errorMessageId } = useInputContext(INPUT_NAME, __inputScope);\n return (\n <textarea\n {...{\n ...props,\n id,\n 'aria-describedby': descriptionId,\n ...(validationValence === 'error' && {\n 'aria-invalid': 'true' as const,\n 'aria-errormessage': errorMessageId,\n }),\n 'ref': forwardedRef,\n }}\n />\n );\n },\n);\n\nexport { TextArea };\n\nexport type { TextAreaProps };\n"],"mappings":";;;;;;;AAUA,IAAa,aAAa;AAa1B,IAAa,CAAC,oBAAoB,oBAAoB,mBAAmB,YAAY,CAAC,CAAC;AASvF,IAAa,CAAC,eAAe,mBAAmB,mBAAsC,UAAU;;;ACpBhG,IAAM,QAAQ,YACX,EAAE,cAAc,SAAS,UAAU,GAAG,SAAuC,iBAAiB;CAC7F,MAAM,EAAE,OAAO,gBAAgB,YAAY,YAA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kB,GAAK,CAFnC,EAAE,gBAAgB,UAAU,gBAEmB,EAAE,gBAAgB,GAAG;IAAI,eAAY;IACjG,UAAA;GACE,GAFK,KAEL;EAET,CAAC,CACE;;AAET,CACF;;;ACnMA,IAAM,YAAY,YACf,EAAE,cAAc,GAAG,SAA2C,iBAAiB;CAC9E,MAAM,EAAE,IAAI,mBAAmB,eAAe,mBAAmB,gBAAgB,YAAY,YAAY;CACzG,OACE,oBAAC,UAAU,OAAX;EAEI,GAAG;EACH;EACA,oBAAoB;EACpB,GAAI,sBAAsB,WAAW;GACnC,gBAAgB;GAChB,qBAAqB;EACvB;EACA,OAAO;CAEV,CAAA;AAEL,CACF;;;ACnBA,IAAM,WAAW,YACd,EAAE,cAAc,GAAG,SAA0C,iBAAiB;CAC7E,MAAM,EAAE,IAAI,mBAAmB,eAAe,mBAAmB,gBAAgB,YAAY,YAAY;CACzG,OACE,oBAAC,YAAD;EAEI,GAAG;EACH;EACA,oBAAoB;EACpB,GAAI,sBAAsB,WAAW;GACnC,gBAAgB;GAChB,qBAAqB;EACvB;EACA,OAAO;CAEV,CAAA;AAEL,CACF"}
|
|
@@ -13,7 +13,7 @@ export type InputRootProps = PropsWithChildren<{
|
|
|
13
13
|
}>;
|
|
14
14
|
export declare const createInputContext: <ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [React.FC<ContextValueType & {
|
|
15
15
|
scope: Scope<ContextValueType>;
|
|
16
|
-
children:
|
|
16
|
+
children: React.ReactNode;
|
|
17
17
|
}>, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], createInputScope: import("@radix-ui/react-context").CreateScope;
|
|
18
18
|
export type InputContextValue = {
|
|
19
19
|
id: string;
|
package/dist/types/src/Root.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type InputRootProps, type InputScopedProps, type Valence } from './InputContext';
|
|
3
|
-
declare function InputRoot({ __inputScope, id: propsId, descriptionId: propsDescriptionId, errorMessageId: propsErrorMessageId, validationValence, children }: InputScopedProps<InputRootProps>): React.JSX.Element;
|
|
2
|
+
import { INPUT_NAME, type InputRootProps, type InputScopedProps, type Valence } from './InputContext';
|
|
3
|
+
declare function InputRoot({ __inputScope, id: propsId, descriptionId: propsDescriptionId, errorMessageId: propsErrorMessageId, validationValence, children, }: InputScopedProps<InputRootProps>): React.JSX.Element;
|
|
4
4
|
declare namespace InputRoot {
|
|
5
|
-
|
|
5
|
+
export { INPUT_NAME as displayName };
|
|
6
6
|
}
|
|
7
7
|
export { InputRoot };
|
|
8
8
|
export type { InputRootProps, InputScopedProps, Valence };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.d.ts","sourceRoot":"","sources":["../../../src/Root.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,
|
|
1
|
+
{"version":3,"file":"Root.d.ts","sourceRoot":"","sources":["../../../src/Root.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,UAAU,EAAiB,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;2BAElG,EACjB,YAAY,EACZ,EAAE,EAAE,OAAO,EACX,aAAa,EAAE,kBAAkB,EACjC,cAAc,EAAE,mBAAmB,EACnC,iBAA6B,EAC7B,QAAQ,GACT,EAAE,gBAAgB,CAAC,cAAc,CAAC;;aAWX,UAAU;;AAElC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC"}
|