react-native-ui-lib 8.3.4-snapshot.7813 → 8.3.4-snapshot.7824

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.
Files changed (132) hide show
  1. package/ReactNativeUiLib.podspec +22 -0
  2. package/lib/components/HighlighterOverlayView/index.d.ts +2 -2
  3. package/lib/components/HighlighterOverlayView/index.web.d.ts +2 -2
  4. package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardViewBase.d.ts +1 -1
  5. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardRegistry/index.js +1 -5
  6. package/lib/components/Keyboard/KeyboardAccessoryView/index.d.ts +2 -2
  7. package/lib/components/Keyboard/KeyboardAccessoryView/index.js +1 -3
  8. package/lib/components/Keyboard/KeyboardTrackingView/KeyboardTrackingView.ios.js +1 -3
  9. package/lib/components/Keyboard/KeyboardTrackingView/index.d.ts +2 -6
  10. package/lib/components/Keyboard/KeyboardTrackingView/index.js +4 -5
  11. package/lib/components/Keyboard/index.d.ts +1 -2
  12. package/lib/package.json +21 -20
  13. package/lib/react-native.config.js +1 -1
  14. package/package.json +163 -161
  15. package/src/commons/asBaseComponent.js +1 -2
  16. package/src/commons/baseComponent.js +8 -0
  17. package/src/commons/forwardRef.js +4 -1
  18. package/src/commons/modifiers.d.ts +6 -0
  19. package/src/commons/modifiers.js +18 -0
  20. package/src/commons/withScrollEnabler.js +4 -0
  21. package/src/commons/withScrollReached.js +4 -0
  22. package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +7 -0
  23. package/src/components/KeyboardAwareScrollView/KeyboardAwareFlatList.js +6 -0
  24. package/src/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +6 -0
  25. package/src/components/WheelPicker/WheelPicker.driver.d.ts +2 -2
  26. package/src/components/WheelPicker/index.d.ts +2 -2
  27. package/src/components/WheelPicker/index.js +1 -1
  28. package/src/components/WheelPicker/usePresenter.d.ts +1 -1
  29. package/src/components/actionSheet/index.d.ts +1 -1
  30. package/src/components/animatedImage/index.d.ts +1 -1
  31. package/src/components/animatedScanner/index.js +37 -0
  32. package/src/components/avatar/index.d.ts +1 -1
  33. package/src/components/badge/index.d.ts +4 -4
  34. package/src/components/baseInput/index.d.ts +1 -0
  35. package/src/components/baseInput/index.js +49 -1
  36. package/src/components/button/index.d.ts +4 -4
  37. package/src/components/button/types.d.ts +2 -2
  38. package/src/components/carousel/index.d.ts +8 -8
  39. package/src/components/carousel/types.d.ts +1 -4
  40. package/src/components/carousel/types.js +2 -0
  41. package/src/components/checkbox/index.d.ts +1 -1
  42. package/src/components/chip/index.d.ts +1 -1
  43. package/src/components/colorPalette/index.d.ts +1 -1
  44. package/src/components/dateTimePicker/index.d.ts +2 -2
  45. package/src/components/dateTimePicker/index.js +2 -2
  46. package/src/components/dialog/types.d.ts +4 -4
  47. package/src/components/dialog/useDialogContent.d.ts +1 -1
  48. package/src/components/drawer/index.d.ts +1 -1
  49. package/src/components/expandableSection/index.d.ts +2 -2
  50. package/src/components/fadedScrollView/index.js +1 -1
  51. package/src/components/featureHighlight/index.js +7 -5
  52. package/src/components/floatingButton/floatingButton.api.json +10 -15
  53. package/src/components/floatingButton/index.d.ts +13 -39
  54. package/src/components/floatingButton/index.js +57 -167
  55. package/src/components/gridListItem/index.d.ts +7 -7
  56. package/src/components/gridView/index.d.ts +1 -1
  57. package/src/components/hint/HintBubble.d.ts +1 -1
  58. package/src/components/hint/HintOld.d.ts +10 -10
  59. package/src/components/hint/hooks/useHintLayout.d.ts +1 -1
  60. package/src/components/hint/index.d.ts +2 -2
  61. package/src/components/hint/types.d.ts +2 -2
  62. package/src/components/icon/index.js +3 -0
  63. package/src/components/image/index.d.ts +1 -1
  64. package/src/components/image/index.js +17 -20
  65. package/src/components/loaderScreen/index.d.ts +1 -1
  66. package/src/components/loaderScreen/types.d.ts +1 -1
  67. package/src/components/maskedInput/index.d.ts +4 -21
  68. package/src/components/maskedInput/index.js +16 -78
  69. package/src/components/maskedInput/maskedInput.api.json +1 -0
  70. package/src/components/maskedInput/new.d.ts +22 -0
  71. package/src/components/maskedInput/new.js +85 -0
  72. package/src/components/maskedInput/old.js +95 -0
  73. package/src/components/modal/index.d.ts +3 -3
  74. package/src/components/numberInput/index.js +2 -2
  75. package/src/components/overlay/index.d.ts +1 -1
  76. package/src/components/picker/PickerDialog.android.js +15 -0
  77. package/src/components/picker/PickerDialog.js +7 -0
  78. package/src/components/picker/helpers/useImperativePickerHandle.d.ts +1 -1
  79. package/src/components/picker/helpers/useImperativePickerHandle.js +1 -1
  80. package/src/components/picker/types.d.ts +9 -9
  81. package/src/components/progressBar/index.d.ts +2 -2
  82. package/src/components/screenFooter/index.js +10 -7
  83. package/src/components/screenFooter/screenFooter.api.json +9 -21
  84. package/src/components/screenFooter/types.d.ts +6 -1
  85. package/src/components/scrollBar/index.d.ts +4 -11
  86. package/src/components/searchInput/index.js +1 -1
  87. package/src/components/searchInput/types.d.ts +2 -2
  88. package/src/components/sectionsWheelPicker/SectionsWheelPicker.driver.d.ts +2 -2
  89. package/src/components/skeletonView/index.d.ts +4 -4
  90. package/src/components/slider/Thumb.d.ts +1 -1
  91. package/src/components/slider/types.d.ts +1 -1
  92. package/src/components/stackAggregator/index.d.ts +1 -1
  93. package/src/components/tabController/TabBarItem.d.ts +2 -2
  94. package/src/components/tabController/TabBarItem.js +1 -1
  95. package/src/components/tabController/TabPage.d.ts +2 -2
  96. package/src/components/tabController/useScrollToItem.d.ts +1 -1
  97. package/src/components/text/Text.driver.d.ts +1 -1
  98. package/src/components/textArea/index.js +6 -0
  99. package/src/components/textField/TextField.driver.new.js +12 -7
  100. package/src/components/textField/index.js +31 -9
  101. package/src/components/textField/types.d.ts +4 -4
  102. package/src/components/textField/useImperativeInputHandle.d.ts +1 -1
  103. package/src/components/textField/useImperativeInputHandle.js +1 -1
  104. package/src/components/textField/usePreset.d.ts +36 -36
  105. package/src/components/textFieldOld/index.d.ts +71 -0
  106. package/src/components/textFieldOld/index.js +807 -0
  107. package/src/components/timeline/index.js +1 -1
  108. package/src/components/toast/index.js +69 -0
  109. package/src/components/wizard/index.d.ts +1 -1
  110. package/src/components/wizard/types.d.ts +1 -1
  111. package/src/components/wizard/wizard.api.json +1 -1
  112. package/src/helpers/DocsGenerator.js +61 -0
  113. package/src/hooks/useCombinedRefs/index.js +2 -1
  114. package/src/hooks/useDebounce/index.js +1 -1
  115. package/src/hooks/useHiddenLocation/index.js +2 -2
  116. package/src/hooks/useHiddenLocation/index.web.js +2 -2
  117. package/src/hooks/useMeasure/index.d.ts +1 -1
  118. package/src/hooks/useMeasure/index.js +1 -1
  119. package/src/hooks/useScrollTo/index.d.ts +2 -2
  120. package/src/incubator/calendar/index.js +1 -1
  121. package/src/incubator/calendar/types.d.ts +2 -2
  122. package/src/incubator/expandableOverlay/index.d.ts +2 -2
  123. package/src/incubator/slider/Track.d.ts +1 -1
  124. package/src/incubator/slider/index.d.ts +1 -1
  125. package/src/incubator/toast/helpers/useToastTimer.js +1 -1
  126. package/src/incubator/toast/index.js +1 -1
  127. package/src/incubator/toast/types.d.ts +2 -2
  128. package/src/testkit/Component.driver.d.ts +1 -1
  129. package/src/testkit/drivers/TestingLibraryDriver.d.ts +1 -1
  130. package/src/typings/module.d.ts +3 -12
  131. package/textFieldOld.d.ts +2 -0
  132. package/textFieldOld.js +1 -0
@@ -81,6 +81,11 @@
81
81
  "type": "boolean",
82
82
  "description": "If true, hides the top divider for solid background. Only applies when backgroundType is 'solid'",
83
83
  "default": "false"
84
+ },
85
+ {
86
+ "name": "contentContainerStyle",
87
+ "type": "StyleProp<ViewStyle>",
88
+ "description": "Custom style for the content container that wraps the footer's children. Can be used to override default padding, gap, or other layout properties."
84
89
  }
85
90
  ],
86
91
  "snippet": [
@@ -118,11 +123,7 @@
118
123
  },
119
124
  {
120
125
  "type": "table",
121
- "columns": [
122
- "Layout Type",
123
- "Use Case",
124
- "Example"
125
- ],
126
+ "columns": ["Layout Type", "Use Case", "Example"],
126
127
  "items": [
127
128
  {
128
129
  "title": "Horizontal - Spread",
@@ -157,11 +158,7 @@
157
158
  },
158
159
  {
159
160
  "type": "table",
160
- "columns": [
161
- "Layout Type",
162
- "Use Case",
163
- "Example"
164
- ],
161
+ "columns": ["Layout Type", "Use Case", "Example"],
165
162
  "items": [
166
163
  {
167
164
  "title": "Vertical - Fit",
@@ -187,11 +184,7 @@
187
184
  },
188
185
  {
189
186
  "type": "table",
190
- "columns": [
191
- "Background Type",
192
- "Visual",
193
- "When to Use"
194
- ],
187
+ "columns": ["Background Type", "Visual", "When to Use"],
195
188
  "items": [
196
189
  {
197
190
  "title": "Solid",
@@ -226,11 +219,7 @@
226
219
  },
227
220
  {
228
221
  "type": "table",
229
- "columns": [
230
- "Behavior",
231
- "Description",
232
- "Example"
233
- ],
222
+ "columns": ["Behavior", "Description", "Example"],
234
223
  "items": [
235
224
  {
236
225
  "title": "Sticky",
@@ -259,4 +248,3 @@
259
248
  ]
260
249
  }
261
250
  }
262
-
@@ -1,5 +1,5 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { DimensionValue } from 'react-native';
2
+ import { DimensionValue, StyleProp, ViewStyle } from 'react-native';
3
3
  export declare enum ScreenFooterLayouts {
4
4
  HORIZONTAL = "horizontal",
5
5
  VERTICAL = "vertical"
@@ -97,4 +97,9 @@ export interface ScreenFooterProps extends PropsWithChildren<{}> {
97
97
  * Only applies when backgroundType is 'solid'
98
98
  */
99
99
  hideDivider?: boolean;
100
+ /**
101
+ * Custom style for the content container that wraps the footer's children.
102
+ * Can be used to override default padding, gap, or other layout properties.
103
+ */
104
+ contentContainerStyle?: StyleProp<ViewStyle>;
100
105
  }
@@ -1,19 +1,12 @@
1
1
  import React, { Component } from 'react';
2
- import { Animated, FlatListProps, ScrollViewProps, ImageSourcePropType, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent } from 'react-native';
2
+ import { Animated, FlatListProps, ImageSourcePropType, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent } from 'react-native';
3
3
  import { ForwardRefInjectedProps } from '../../commons/new';
4
4
  import { ComponentStatics } from '../../typings/common';
5
- export type ListProps = (FlatListProps<any> & {
5
+ export interface ScrollBarProps extends FlatListProps<any> {
6
6
  /**
7
7
  * Whether to use a FlatList. NOTE: you must pass 'data' and 'renderItem' props as well
8
8
  */
9
- useList: true;
10
- }) | (ScrollViewProps & {
11
- /**
12
- * Whether to use a ScrollView. NOTE: you must pass 'contentContainerStyle' prop as well
13
- */
14
- useList?: false;
15
- });
16
- export type ScrollBarProps = ListProps & {
9
+ useList?: boolean;
17
10
  /**
18
11
  * The element to use as a container, instead of a View
19
12
  */
@@ -51,7 +44,7 @@ export type ScrollBarProps = ListProps & {
51
44
  * The index to currently focus on
52
45
  */
53
46
  focusIndex?: number;
54
- };
47
+ }
55
48
  type Props = ScrollBarProps & ForwardRefInjectedProps;
56
49
  type State = {
57
50
  gradientOpacity: Animated.Value;
@@ -32,7 +32,7 @@ const SearchInput = forwardRef((props, ref) => {
32
32
  style,
33
33
  inaccessible
34
34
  } = props;
35
- const currentAnimatedValue = useRef(undefined);
35
+ const currentAnimatedValue = useRef();
36
36
  const searchInputRef = useRef(null);
37
37
  const [hasValue, setHasValue] = useState(Boolean(controlledValue));
38
38
  const [value, setValue] = useState(controlledValue);
@@ -26,7 +26,7 @@ export type SearchInputProps = TextInputProps & {
26
26
  /**
27
27
  * Custom right element
28
28
  */
29
- customRightElement?: React.ReactElement<any>;
29
+ customRightElement?: React.ReactElement;
30
30
  /**
31
31
  * Whether to show a loader instead of the left search icon
32
32
  */
@@ -38,7 +38,7 @@ export type SearchInputProps = TextInputProps & {
38
38
  /**
39
39
  * custom loader element
40
40
  */
41
- customLoader?: React.ReactElement<any>;
41
+ customLoader?: React.ReactElement;
42
42
  /**
43
43
  * converts the colors of the search's input elements, icons and button to white
44
44
  */
@@ -7,11 +7,11 @@ export declare const SectionsWheelPickerDriver: (props: ComponentProps) => {
7
7
  moveToItem: (index: number, itemHeight?: number, numberOfRows?: number) => void;
8
8
  getLabel: () => string | (string | ReactTestInstance)[];
9
9
  scroll: (contentOffset: Partial<import("react-native/types").NativeScrollPoint>, options?: {
10
+ contentInset: import("react-native/types").NativeScrollRectangle;
11
+ zoomScale: number;
10
12
  layoutMeasurement: import("react-native/types").NativeScrollSize;
11
13
  contentSize: import("react-native/types").NativeScrollSize;
12
14
  velocity?: import("react-native/types").NativeScrollVelocity | undefined;
13
- contentInset: import("react-native/types").NativeScrollRectangle;
14
- zoomScale: number;
15
15
  targetContentOffset?: import("react-native/types").NativeScrollPoint | undefined;
16
16
  } | undefined) => void;
17
17
  triggerEvent: (eventName?: string | undefined, event?: Partial<import("react-native/types").NativeScrollEvent> | undefined) => void;
@@ -35,7 +35,7 @@ export interface SkeletonListProps {
35
35
  /**
36
36
  * Extra content to be rendered on the end of the list item
37
37
  */
38
- renderEndContent?: () => React.ReactElement<any> | undefined;
38
+ renderEndContent?: () => React.ReactElement | undefined;
39
39
  }
40
40
  export interface SkeletonViewProps extends AccessibilityProps, AlignmentModifiers, PaddingModifiers, MarginModifiers {
41
41
  /**
@@ -155,9 +155,9 @@ declare class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
155
155
  renderTextContentTemplate: () => React.JSX.Element;
156
156
  renderTemplate: () => React.JSX.Element;
157
157
  renderAdvanced: () => React.JSX.Element;
158
- renderWithFading: (skeleton: any) => string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
159
- renderSkeleton(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
158
+ renderWithFading: (skeleton: any) => string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
159
+ renderSkeleton(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
160
160
  renderNothing: () => null;
161
- render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
161
+ render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
162
162
  }
163
163
  export default SkeletonView;
@@ -26,7 +26,7 @@ export interface ThumbProps extends ViewProps {
26
26
  */
27
27
  disabled?: boolean;
28
28
  /** ref to thumb component */
29
- ref?: React.RefObject<RNView | null>;
29
+ ref?: React.RefObject<RNView>;
30
30
  }
31
31
  declare const Thumb: React.ForwardRefExoticComponent<Omit<ThumbProps, "ref"> & React.RefAttributes<unknown>>;
32
32
  export default Thumb;
@@ -44,7 +44,7 @@ export type SliderProps = Omit<ThumbProps, 'ref'> & {
44
44
  /**
45
45
  * Custom render instead of rendering the track
46
46
  */
47
- renderTrack?: () => ReactElement<any> | ReactElement<any>[];
47
+ renderTrack?: () => ReactElement | ReactElement[];
48
48
  /**
49
49
  * Callback for onValueChange
50
50
  */
@@ -1,4 +1,4 @@
1
- import React, { type JSX } from 'react';
1
+ import React from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
3
  import { ViewProps } from '../view';
4
4
  import { ButtonProps } from '../button';
@@ -47,11 +47,11 @@ export interface TabControllerItemProps extends Pick<TabControllerBarProps, 'spr
47
47
  /**
48
48
  * Pass to render a leading element
49
49
  */
50
- leadingAccessory?: ReactElement<any>;
50
+ leadingAccessory?: ReactElement;
51
51
  /**
52
52
  * Pass to render a trailing element
53
53
  */
54
- trailingAccessory?: ReactElement<any>;
54
+ trailingAccessory?: ReactElement;
55
55
  /**
56
56
  * A fixed width for the item
57
57
  */
@@ -46,7 +46,7 @@ export default function TabBarItem({
46
46
  currentPage,
47
47
  setCurrentIndex
48
48
  } = useContext(TabBarContext);
49
- const itemRef = useRef(undefined);
49
+ const itemRef = useRef();
50
50
  const itemWidth = useRef(props.width);
51
51
  const isPressed = useSharedValue(false);
52
52
  // JSON.parse(JSON.stringify is due to an issue with reanimated
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, type JSX } from 'react';
1
+ import React, { PropsWithChildren } from 'react';
2
2
  import { type StyleProp, type ViewStyle } from 'react-native';
3
3
  export interface TabControllerPageProps {
4
4
  /**
@@ -30,4 +30,4 @@ export interface TabControllerPageProps {
30
30
  * @description: TabController's TabPage
31
31
  * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/TabControllerScreen/index.tsx
32
32
  */
33
- export default function TabPage({ testID, index, lazy, renderLoading, style, lazyLoadTime, ...props }: PropsWithChildren<TabControllerPageProps>): JSX.Element;
33
+ export default function TabPage({ testID, index, lazy, renderLoading, style, lazyLoadTime, ...props }: PropsWithChildren<TabControllerPageProps>): React.JSX.Element;
@@ -8,7 +8,7 @@ export declare enum OffsetType {
8
8
  RIGHT = "RIGHT"
9
9
  }
10
10
  export type ScrollToItemProps<T extends ScrollToSupportedViews> = {
11
- scrollViewRef?: RefObject<T | null>;
11
+ scrollViewRef?: RefObject<T>;
12
12
  /**
13
13
  * The number of items
14
14
  */
@@ -2,6 +2,6 @@
2
2
  import { TextProps } from './index';
3
3
  import { ComponentDriver } from '../../testkit/Component.driver';
4
4
  export declare class TextDriver extends ComponentDriver<TextProps> {
5
- getTextContent: () => Promise<string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined>;
5
+ getTextContent: () => Promise<import("react").ReactNode>;
6
6
  isPressable: () => Promise<boolean | null>;
7
7
  }
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import {View, TextInput as RNTextInput, StyleSheet} from 'react-native';
3
+ import {TextInputPropTypes} from 'deprecated-react-native-prop-types';
3
4
  import BaseInput from '../baseInput';
4
5
  import {Colors} from '../../style';
5
6
 
@@ -14,6 +15,11 @@ import {Colors} from '../../style';
14
15
  export default class TextArea extends BaseInput {
15
16
  static displayName = 'TextArea';
16
17
 
18
+ static propTypes = {
19
+ ...TextInputPropTypes,
20
+ ...BaseInput.propTypes
21
+ };
22
+
17
23
  generateStyles() {
18
24
  this.styles = createStyles(this.props);
19
25
  }
@@ -9,6 +9,10 @@ import { ButtonDriver } from "../button/Button.driver.new";
9
9
  import { ViewDriver } from "../view/View.driver.new";
10
10
  export const TextFieldDriver = (props, options) => {
11
11
  const driver = usePressableDriver(useComponentDriver(props, options));
12
+ const inputDriver = useComponentDriver({
13
+ renderTree: props.renderTree,
14
+ testID: `${props.testID}.input`
15
+ }, options);
12
16
  const floatingPlaceholderDriver = TextDriver({
13
17
  renderTree: props.renderTree,
14
18
  testID: `${props.testID}.floatingPlaceholder`
@@ -41,30 +45,31 @@ export const TextFieldDriver = (props, options) => {
41
45
  renderTree: props.renderTree,
42
46
  testID: `${props.testID}.clearButton.container`
43
47
  });
48
+ const getInputElement = () => inputDriver.queryElement() ?? driver.getElement();
44
49
  const getValue = () => {
45
- return driver.getElement().props.value ?? driver.getElement().props.defaultValue;
50
+ return getInputElement().props.value ?? getInputElement().props.defaultValue;
46
51
  };
47
52
  const changeText = text => {
48
- fireEvent.changeText(driver.getElement(), text);
53
+ fireEvent.changeText(getInputElement(), text);
49
54
  };
50
55
  const focus = () => {
51
- fireEvent(driver.getElement(), 'focus');
56
+ fireEvent(getInputElement(), 'focus');
52
57
  };
53
58
  const blur = () => {
54
- fireEvent(driver.getElement(), 'blur');
59
+ fireEvent(getInputElement(), 'blur');
55
60
  };
56
61
  const isEnabled = () => {
57
- return !driver.getElement().props.accessibilityState?.disabled;
62
+ return !getInputElement().props.accessibilityState?.disabled;
58
63
  };
59
64
  const getPlaceholder = () => {
60
65
  const exists = () => {
61
- const hasPlaceholder = !!driver.getElement().props.placeholder;
66
+ const hasPlaceholder = !!getInputElement().props.placeholder;
62
67
  const hasText = !!getValue();
63
68
  return hasPlaceholder && (!hasText || hasText && floatingPlaceholderDriver.exists());
64
69
  };
65
70
  const getText = () => {
66
71
  if (exists()) {
67
- return driver.getElement().props.placeholder;
72
+ return getInputElement().props.placeholder;
68
73
  }
69
74
  };
70
75
  return {
@@ -78,6 +78,8 @@ const TextField = props => {
78
78
  readonly = false,
79
79
  showMandatoryIndication,
80
80
  clearButtonStyle,
81
+ testID,
82
+ accessibilityLabel: accessibilityLabelProp,
81
83
  ...others
82
84
  } = usePreset(props);
83
85
  const {
@@ -135,11 +137,31 @@ const TextField = props => {
135
137
  const hasValue = fieldState.value !== undefined; // NOTE: not pressable if centered without a value (so can't center placeholder)
136
138
  const inputStyle = useMemo(() => [typographyStyle, colorStyle, others.style, hasValue && centeredTextStyle], [typographyStyle, colorStyle, others.style, centeredTextStyle, hasValue]);
137
139
  const dummyPlaceholderStyle = useMemo(() => [inputStyle, styles.dummyPlaceholder], [inputStyle]);
140
+ const defaultAccessibilityLabel = useMemo(() => {
141
+ const parts = [];
142
+ if (label) {
143
+ parts.push(label);
144
+ }
145
+ if (context.isMandatory) {
146
+ parts.push('required');
147
+ }
148
+ parts.push('textField');
149
+ if (helperText) {
150
+ parts.push(helperText);
151
+ } else if (placeholder) {
152
+ parts.push(placeholder);
153
+ }
154
+ if (showCharCounter && others.maxLength) {
155
+ parts.push(`you can enter up to ${others.maxLength} characters`);
156
+ }
157
+ return parts.join(', ');
158
+ }, [label, context.isMandatory, helperText, placeholder, showCharCounter, others.maxLength]);
159
+ const accessibilityLabel = accessibilityLabelProp ?? defaultAccessibilityLabel;
138
160
  return <FieldContext.Provider value={context}>
139
- <View {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
161
+ <View {...containerProps} testID={testID} accessible accessibilityLabel={accessibilityLabel} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
140
162
  <View row spread style={centeredContainerStyle}>
141
- <Label label={label} labelColor={labelColor} labelStyle={_labelStyle} labelProps={labelProps} floatingPlaceholder={floatingPlaceholder} validationMessagePosition={validationMessagePosition} testID={`${props.testID}.label`} showMandatoryIndication={showMandatoryIndication} enableErrors={enableErrors} />
142
- {validationMessagePosition === ValidationMessagePosition.TOP && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace && retainTopMessageSpace} testID={`${props.testID}.validationMessage`} />}
163
+ <Label label={label} labelColor={labelColor} labelStyle={_labelStyle} labelProps={labelProps} floatingPlaceholder={floatingPlaceholder} validationMessagePosition={validationMessagePosition} testID={`${testID}.label`} showMandatoryIndication={showMandatoryIndication} enableErrors={enableErrors} />
164
+ {validationMessagePosition === ValidationMessagePosition.TOP && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace && retainTopMessageSpace} testID={`${testID}.validationMessage`} />}
143
165
  {topTrailingAccessory && <View>{topTrailingAccessory}</View>}
144
166
  </View>
145
167
  <View style={[paddings, fieldStyle]} row centerV centerH={centered}>
@@ -158,26 +180,26 @@ const TextField = props => {
158
180
  {Constants.isAndroid && centered && <Text marginR-s1 style={dummyPlaceholderStyle}>
159
181
  {placeholder}
160
182
  </Text>}
161
- {floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${props.testID}.floatingPlaceholder`} showMandatoryIndication={showMandatoryIndication} />}
183
+ {floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${testID}.floatingPlaceholder`} showMandatoryIndication={showMandatoryIndication} />}
162
184
  <Input hitSlop={{
163
185
  top: 20,
164
186
  bottom: 20
165
- }} placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor} value={fieldState.value} {...others} readonly={readonly} style={inputStyle} onFocus={onFocus} onBlur={onBlur} onChangeText={onChangeText} placeholder={placeholder} hint={hint} showMandatoryIndication={showMandatoryIndication && !label} />
187
+ }} placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor} value={fieldState.value} {...others} testID={`${testID}.input`} readonly={readonly} style={inputStyle} onFocus={onFocus} onBlur={onBlur} onChangeText={onChangeText} placeholder={placeholder} hint={hint} showMandatoryIndication={showMandatoryIndication && !label} />
166
188
  </View>}
167
- {showClearButton && <ClearButton onClear={onClear} testID={`${props.testID}.clearButton`} onChangeText={onChangeText} clearButtonStyle={clearButtonStyle} />}
189
+ {showClearButton && <ClearButton onClear={onClear} testID={`${testID}.clearButton`} onChangeText={onChangeText} clearButtonStyle={clearButtonStyle} />}
168
190
  {trailingAccessory}
169
191
  {/* </View> */}
170
192
  </View>
171
193
  <View row spread center={centered}>
172
194
  <View flex={!centered} flexG={centered} marginR-s4={showCharCounter}>
173
- {validationMessagePosition === ValidationMessagePosition.BOTTOM && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationIcon={validationIcon} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace} testID={`${props.testID}.validationMessage`} />}
174
- {helperText && <Text $textNeutralHeavy subtext marginT-s1 testID={`${props.testID}.helperText`}>
195
+ {validationMessagePosition === ValidationMessagePosition.BOTTOM && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationIcon={validationIcon} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace} testID={`${testID}.validationMessage`} />}
196
+ {helperText && <Text $textNeutralHeavy subtext marginT-s1 testID={`${testID}.helperText`}>
175
197
  {helperText}
176
198
  </Text>}
177
199
  {bottomAccessory}
178
200
  </View>
179
201
  <View>
180
- {showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle} testID={`${props.testID}.charCounter`} />}
202
+ {showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle} testID={`${testID}.charCounter`} />}
181
203
  </View>
182
204
  </View>
183
205
  </View>
@@ -171,19 +171,19 @@ export type TextFieldProps = MarginModifiers & PaddingModifiers & TypographyModi
171
171
  /**
172
172
  * Pass to render a leading element
173
173
  */
174
- leadingAccessory?: ReactElement<any>;
174
+ leadingAccessory?: ReactElement;
175
175
  /**
176
176
  * Pass to render a trailing element
177
177
  */
178
- trailingAccessory?: ReactElement<any>;
178
+ trailingAccessory?: ReactElement;
179
179
  /**
180
180
  * Pass to render a top trailing element
181
181
  */
182
- topTrailingAccessory?: ReactElement<any>;
182
+ topTrailingAccessory?: ReactElement;
183
183
  /**
184
184
  * Pass to render a bottom element below the input
185
185
  */
186
- bottomAccessory?: ReactElement<any>;
186
+ bottomAccessory?: ReactElement;
187
187
  /**
188
188
  * Should show a clear button when there is a value
189
189
  */
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { TextInput, TextInputProps } from 'react-native';
3
- declare const useImperativeInputHandle: (ref: React.Ref<any>, props: Pick<TextInputProps, 'onChangeText'>) => React.RefObject<TextInput | undefined>;
3
+ declare const useImperativeInputHandle: (ref: React.Ref<any>, props: Pick<TextInputProps, 'onChangeText'>) => React.MutableRefObject<TextInput | undefined>;
4
4
  export default useImperativeInputHandle;
@@ -2,7 +2,7 @@ import { useContext, useImperativeHandle, useRef } from 'react';
2
2
  import { findNodeHandle } from 'react-native';
3
3
  import FieldContext from "./FieldContext";
4
4
  const useImperativeInputHandle = (ref, props) => {
5
- const inputRef = useRef(undefined);
5
+ const inputRef = useRef();
6
6
  const context = useContext(FieldContext);
7
7
  useImperativeHandle(ref, () => {
8
8
  return {