Skip to content

Commit 8dae115

Browse files
committed
add input props
1 parent c7c3675 commit 8dae115

3 files changed

Lines changed: 44 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "woosign-system",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "WooBottle 'Paper & Ink' design system — cross-platform React Native + Web components (cream canvas, ink surfaces, ember CTAs, ceremonial gold).",
55
"keywords": [
66
"react",

src/components/Input/Input.web.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,51 @@ export const Input = forwardRef<HTMLInputElement | HTMLTextAreaElement, InputWeb
5151
maxLength,
5252
multiline = false,
5353
numberOfLines,
54+
inputProps,
5455
},
5556
ref
5657
) {
5758
const [isFocused, setIsFocused] = useState(false);
5859

59-
const handleFocus = useCallback(() => {
60-
setIsFocused(true);
61-
onFocus?.();
62-
}, [onFocus]);
60+
const userOnChange = inputProps?.onChange;
61+
const userOnKeyDown = inputProps?.onKeyDown;
62+
const userOnFocus = inputProps?.onFocus;
63+
const userOnBlur = inputProps?.onBlur;
6364

64-
const handleBlur = useCallback(() => {
65-
setIsFocused(false);
66-
onBlur?.();
67-
}, [onBlur]);
65+
const handleFocus = useCallback(
66+
(e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {
67+
setIsFocused(true);
68+
onFocus?.();
69+
(userOnFocus as ((e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void) | undefined)?.(e);
70+
},
71+
[onFocus, userOnFocus]
72+
);
73+
74+
const handleBlur = useCallback(
75+
(e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {
76+
setIsFocused(false);
77+
onBlur?.();
78+
(userOnBlur as ((e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void) | undefined)?.(e);
79+
},
80+
[onBlur, userOnBlur]
81+
);
6882

6983
const handleChange = useCallback(
7084
(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
7185
onChangeText?.(e.currentTarget.value);
86+
(userOnChange as ((e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void) | undefined)?.(e);
7287
},
73-
[onChangeText]
88+
[onChangeText, userOnChange]
7489
);
7590

7691
const handleKeyDown = useCallback(
7792
(e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {
7893
if (e.key === 'Enter' && !multiline && onSubmitEditing) {
7994
onSubmitEditing();
8095
}
96+
(userOnKeyDown as ((e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void) | undefined)?.(e);
8197
},
82-
[multiline, onSubmitEditing]
98+
[multiline, onSubmitEditing, userOnKeyDown]
8399
);
84100

85101
// Get variant styles
@@ -117,8 +133,13 @@ export const Input = forwardRef<HTMLInputElement | HTMLTextAreaElement, InputWeb
117133
color: placeholderColor,
118134
};
119135

120-
// Common props for input/textarea
136+
// Common props for input/textarea.
137+
// `inputProps` is spread first so user-provided pass-through props
138+
// (onPaste, onCompositionStart, data-*, aria-*, ...) apply, then internal
139+
// props/handlers override to keep variant behavior intact. The four
140+
// chained handlers above already invoke the user-supplied versions.
121141
const commonProps = {
142+
...inputProps,
122143
placeholder,
123144
value,
124145
defaultValue,

src/components/Input/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ export interface InputWebProps extends InputBaseProps {
8484
max?: number | string;
8585
/** Step value for number inputs */
8686
step?: number | string;
87+
/**
88+
* Pass-through props for the underlying <input>/<textarea>.
89+
* Use this for handlers the component doesn't expose directly
90+
* (onPaste, onCompositionStart, raw onChange/onKeyDown for OTP-style inputs, etc.).
91+
* Internal handlers (focus tracking, onChangeText, onSubmitEditing) still run alongside.
92+
*/
93+
inputProps?: Omit<
94+
React.InputHTMLAttributes<HTMLInputElement> &
95+
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
96+
'value' | 'defaultValue' | 'placeholder' | 'disabled' | 'readOnly' | 'style' | 'ref'
97+
>;
8798
}
8899

89100
// Native-specific props

0 commit comments

Comments
 (0)