@hero-design/rn-work-uikit 1.2.0-alpha.1 → 1.2.0-alpha.2

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,12 @@ import SuffixComponent from './SuffixComponent';
21
21
  import MaxLengthMessage from './MaxLengthMessage';
22
22
  import FloatingLabel from './FloatingLabel';
23
23
  import InputRow from './InputRow';
24
- import type { TextInputHandles, TextInputProps } from './types';
24
+ import type {
25
+ InternalTextInputProps,
26
+ TextInputHandles,
27
+ TextInputProps,
28
+ } from './types';
29
+ import Group from './Group';
25
30
 
26
31
  export type {
27
32
  TextInputHandles,
@@ -117,7 +122,10 @@ const extractBorderStyles = (style: StyleProp<ViewStyle>) => {
117
122
  * Note: StyledBorder uses StyleSheet.absoluteFillObject to overlay the entire
118
123
  * StyledContainer, providing the border and background styling.
119
124
  */
120
- const TextInput = forwardRef<TextInputHandles, TextInputProps>(
125
+ export const InternalTextInput = forwardRef<
126
+ TextInputHandles,
127
+ InternalTextInputProps
128
+ >(
121
129
  (
122
130
  {
123
131
  label,
@@ -140,10 +148,13 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
140
148
  renderInputValue,
141
149
  allowFontScaling = false,
142
150
  variant = 'text',
151
+ accessibilityLabel,
152
+ enableGroupStyle = false,
143
153
  ...nativeProps
144
- }: TextInputProps,
154
+ }: InternalTextInputProps,
145
155
  ref?: React.Ref<TextInputHandles>
146
156
  ) => {
157
+ const { onFocus, onBlur, onChangeText, ...restOfNativeProps } = nativeProps;
147
158
  // Inline the simple getDisplayText function
148
159
  const displayText = (value !== undefined ? value : defaultValue) ?? '';
149
160
  const isEmptyValue = displayText.length === 0;
@@ -189,27 +200,28 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
189
200
  const handleFocus = useCallback(
190
201
  (event: NativeSyntheticEvent<TextInputFocusEventData>) => {
191
202
  setIsFocused(true);
192
- nativeProps.onFocus?.(event);
203
+ onFocus?.(event);
193
204
  },
194
- [nativeProps]
205
+ [onFocus]
195
206
  );
196
207
 
197
208
  const handleBlur = useCallback(
198
209
  (event: NativeSyntheticEvent<TextInputFocusEventData>) => {
199
210
  setIsFocused(false);
200
- nativeProps.onBlur?.(event);
211
+ onBlur?.(event);
201
212
  },
202
- [nativeProps]
213
+ [onBlur]
203
214
  );
204
215
 
205
216
  const handleChangeText = useCallback(
206
217
  (text: string) => {
207
- nativeProps.onChangeText?.(text);
218
+ if (editable) {
219
+ onChangeText?.(text);
220
+ }
208
221
  },
209
- [nativeProps]
222
+ [onChangeText, editable]
210
223
  );
211
224
 
212
- // Simplified callbacks - these don't need memoization as they're stable
213
225
  const handleContainerPress = () => {
214
226
  innerTextInput.current?.focus();
215
227
  };
@@ -234,11 +246,9 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
234
246
  accessibilityState: {
235
247
  disabled: state === 'disabled' || state === 'readonly',
236
248
  },
237
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
238
- // @ts-ignore
239
249
  accessibilityLabelledBy,
240
250
  allowFontScaling,
241
- ...nativeProps,
251
+ ...restOfNativeProps,
242
252
  onFocus: handleFocus,
243
253
  onBlur: handleBlur,
244
254
  onChangeText: handleChangeText,
@@ -250,6 +260,7 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
250
260
  isFocused || label === undefined
251
261
  ? nativeProps.placeholder
252
262
  : EMPTY_PLACEHOLDER_VALUE,
263
+ accessibilityLabel,
253
264
  };
254
265
 
255
266
  // Create container style without background color
@@ -268,6 +279,9 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
268
279
  accessibilityState={{
269
280
  disabled: isDisabledOrReadonly,
270
281
  }}
282
+ themeFocused={isFocused}
283
+ themeHasError={!!error}
284
+ themeUseGroupStyleEnabled={enableGroupStyle}
271
285
  testID={testID}
272
286
  >
273
287
  {/*
@@ -296,14 +310,14 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
296
310
  />
297
311
  )}
298
312
  <InputRow
313
+ ref={innerTextInput}
299
314
  state={state}
300
- isFocused={isFocused}
301
315
  prefix={prefix}
302
316
  variant={variant}
303
- nativeInputProps={nativeInputProps}
304
317
  renderInputValue={renderInputValue}
305
- ref={innerTextInput}
306
318
  isEmptyValue={isEmptyValue}
319
+ nativeInputProps={nativeInputProps}
320
+ shouldShowWhenUnfocused={!label}
307
321
  />
308
322
 
309
323
  <StyledBottomContainer>
@@ -324,4 +338,12 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
324
338
  }
325
339
  );
326
340
 
327
- export default TextInput;
341
+ const TextInput = React.forwardRef<TextInputHandles, TextInputProps>(
342
+ (props, ref) => <InternalTextInput {...props} ref={ref} />
343
+ );
344
+
345
+ TextInput.displayName = 'TextInput';
346
+
347
+ export default Object.assign(TextInput, {
348
+ Group,
349
+ });
@@ -93,3 +93,10 @@ export interface TextInputProps extends NativeTextInputProps {
93
93
  */
94
94
  variant?: TextInputVariant;
95
95
  }
96
+
97
+ export interface InternalTextInputProps extends TextInputProps {
98
+ /**
99
+ * Whether to use the group style.
100
+ */
101
+ enableGroupStyle?: boolean;
102
+ }