react-native-molecules 0.5.0-beta.3 → 0.5.0-beta.31

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 (227) hide show
  1. package/components/Accordion/Accordion.tsx +2 -6
  2. package/components/Accordion/AccordionItem.tsx +16 -12
  3. package/components/Accordion/AccordionItemContent.tsx +6 -1
  4. package/components/Accordion/AccordionItemHeader.tsx +1 -1
  5. package/components/Accordion/utils.ts +6 -0
  6. package/components/ActivityIndicator/ActivityIndicator.tsx +6 -15
  7. package/components/Appbar/AppbarBase.tsx +18 -13
  8. package/components/Button/Button.tsx +211 -264
  9. package/components/Button/index.tsx +9 -3
  10. package/components/Button/types.ts +16 -2
  11. package/components/Button/utils.ts +230 -208
  12. package/components/Card/Card.tsx +1 -1
  13. package/components/Checkbox/Checkbox.tsx +125 -88
  14. package/components/Checkbox/CheckboxBase.ios.tsx +14 -23
  15. package/components/Checkbox/CheckboxBase.tsx +21 -137
  16. package/components/Checkbox/context.tsx +14 -0
  17. package/components/Checkbox/index.tsx +11 -4
  18. package/components/Checkbox/types.ts +63 -29
  19. package/components/Checkbox/utils.ts +25 -108
  20. package/components/Chip/Chip.tsx +41 -52
  21. package/components/Chip/utils.ts +3 -7
  22. package/components/DateField/DateField.tsx +111 -0
  23. package/components/DateField/index.tsx +6 -0
  24. package/components/{DatePickerInput/inputUtils.ts → DateField/useDateFieldState.ts} +19 -51
  25. package/components/DatePicker/DateCalendar.tsx +83 -0
  26. package/components/DatePicker/DatePickerActions.tsx +73 -0
  27. package/components/DatePicker/DatePickerModal.tsx +246 -0
  28. package/components/DatePicker/DatePickerPopover.tsx +79 -0
  29. package/components/DatePicker/DatePickerProvider.tsx +158 -0
  30. package/components/DatePicker/DatePickerTrigger.tsx +23 -0
  31. package/components/DatePicker/context.tsx +83 -0
  32. package/components/DatePicker/index.tsx +45 -0
  33. package/components/DatePicker/utils.ts +295 -0
  34. package/components/DatePickerInline/DatePickerDockedHeader.tsx +117 -0
  35. package/components/DatePickerInline/DatePickerInline.tsx +17 -16
  36. package/components/DatePickerInline/DatePickerInlineBase.tsx +11 -5
  37. package/components/DatePickerInline/DatePickerInlineHeader.tsx +50 -20
  38. package/components/DatePickerInline/Day.tsx +25 -1
  39. package/components/DatePickerInline/DayNames.tsx +13 -10
  40. package/components/DatePickerInline/DayRange.tsx +2 -4
  41. package/components/DatePickerInline/HeaderItem.tsx +44 -29
  42. package/components/DatePickerInline/Month.tsx +48 -67
  43. package/components/DatePickerInline/MonthPicker.tsx +80 -92
  44. package/components/DatePickerInline/Swiper.native.tsx +21 -4
  45. package/components/DatePickerInline/Swiper.tsx +169 -14
  46. package/components/DatePickerInline/SwiperUtils.ts +1 -1
  47. package/components/DatePickerInline/Week.tsx +6 -1
  48. package/components/DatePickerInline/YearPicker.tsx +220 -78
  49. package/components/DatePickerInline/dateUtils.tsx +18 -13
  50. package/components/DatePickerInline/store.tsx +27 -0
  51. package/components/DatePickerInline/types.ts +6 -2
  52. package/components/DatePickerInline/utils.ts +66 -29
  53. package/components/Divider/Divider.tsx +192 -0
  54. package/components/Divider/index.tsx +10 -0
  55. package/components/Drawer/Drawer.tsx +17 -6
  56. package/components/Drawer/DrawerItemGroup.tsx +3 -7
  57. package/components/ElementGroup/ElementGroup.tsx +1 -1
  58. package/components/FilePicker/FilePicker.tsx +48 -78
  59. package/components/FilePicker/index.tsx +2 -1
  60. package/components/FilePicker/utils.ts +9 -0
  61. package/components/HelperText/HelperText.tsx +0 -35
  62. package/components/Icon/iconFactory.tsx +5 -4
  63. package/components/Icon/index.tsx +1 -1
  64. package/components/Icon/types.ts +17 -6
  65. package/components/IconButton/IconButton.tsx +84 -84
  66. package/components/IconButton/index.tsx +1 -0
  67. package/components/IconButton/types.ts +10 -0
  68. package/components/IconButton/utils.ts +167 -33
  69. package/components/List/List.tsx +276 -0
  70. package/components/List/context.tsx +27 -0
  71. package/components/List/index.ts +8 -0
  72. package/components/List/types.ts +117 -0
  73. package/components/List/utils.ts +79 -0
  74. package/components/LoadingIndicator/LoadingIndicator.tsx +253 -0
  75. package/components/LoadingIndicator/LoadingIndicator.web.tsx +136 -0
  76. package/components/LoadingIndicator/index.tsx +13 -0
  77. package/components/LoadingIndicator/utils.ts +117 -0
  78. package/components/Menu/Menu.tsx +162 -39
  79. package/components/Menu/index.tsx +10 -7
  80. package/components/Menu/utils.ts +21 -70
  81. package/components/NavigationRail/NavigationRail.tsx +15 -9
  82. package/components/Popover/Popover.tsx +119 -145
  83. package/components/Popover/PopoverRoot.tsx +60 -0
  84. package/components/Popover/common.ts +54 -34
  85. package/components/Popover/index.ts +12 -1
  86. package/components/Popover/usePlatformMeasure.native.ts +90 -0
  87. package/components/Popover/usePlatformMeasure.ts +120 -0
  88. package/components/Popover/utils.ts +34 -0
  89. package/components/Portal/Portal.tsx +1 -2
  90. package/components/Radio/Radio.tsx +188 -0
  91. package/components/Radio/RadioBase.ios.tsx +69 -0
  92. package/components/Radio/RadioBase.tsx +136 -0
  93. package/components/Radio/context.tsx +23 -0
  94. package/components/Radio/index.tsx +20 -0
  95. package/components/Radio/types.ts +101 -0
  96. package/components/Radio/utils.ts +115 -0
  97. package/components/Rating/Rating.tsx +1 -1
  98. package/components/Select/Select.tsx +521 -785
  99. package/components/Select/context.tsx +81 -0
  100. package/components/Select/index.ts +26 -14
  101. package/components/Select/types.ts +65 -58
  102. package/components/Select/utils.ts +126 -0
  103. package/components/Slot/Slot.tsx +224 -0
  104. package/components/Slot/compose-refs.tsx +62 -0
  105. package/components/Slot/index.tsx +8 -0
  106. package/components/Surface/Surface.android.tsx +32 -7
  107. package/components/Surface/Surface.ios.tsx +34 -29
  108. package/components/Surface/Surface.tsx +31 -4
  109. package/components/Surface/utils.ts +44 -6
  110. package/components/Switch/Switch.ios.tsx +1 -1
  111. package/components/Switch/Switch.tsx +10 -3
  112. package/components/Tabs/TabItem.tsx +35 -58
  113. package/components/Tabs/TabLabel.tsx +5 -9
  114. package/components/Tabs/Tabs.tsx +156 -150
  115. package/components/Tabs/utils.ts +15 -2
  116. package/components/Text/textFactory.tsx +17 -5
  117. package/components/TextInput/TextInput.tsx +663 -579
  118. package/components/TextInput/index.tsx +19 -3
  119. package/components/TextInput/types.ts +77 -28
  120. package/components/TextInput/utils.ts +235 -145
  121. package/components/TimeField/TimeField.tsx +75 -0
  122. package/components/TimeField/index.tsx +6 -0
  123. package/components/TimeField/useTimeFieldState.ts +70 -0
  124. package/components/{TimePickerField/sanitizeTime.ts → TimeField/utils.ts} +77 -10
  125. package/components/TimePicker/AnalogClock.tsx +1 -1
  126. package/components/TimePicker/TimeInput.tsx +87 -42
  127. package/components/TimePicker/TimeInputs.tsx +138 -50
  128. package/components/TimePicker/TimePicker.tsx +74 -11
  129. package/components/TimePicker/TimePickerModal.tsx +186 -0
  130. package/components/TimePicker/context.tsx +17 -0
  131. package/components/TimePicker/index.tsx +15 -3
  132. package/components/TimePicker/utils.ts +93 -4
  133. package/components/Tooltip/Tooltip.tsx +42 -67
  134. package/components/Tooltip/TooltipContent.tsx +32 -5
  135. package/components/Tooltip/TooltipTrigger.tsx +21 -24
  136. package/components/Tooltip/index.tsx +1 -1
  137. package/components/TouchableRipple/TouchableRipple.native.tsx +83 -16
  138. package/components/TouchableRipple/TouchableRipple.tsx +150 -102
  139. package/components/TouchableRipple/rippleFromForegroundColor.ts +21 -0
  140. package/hocs/index.tsx +1 -1
  141. package/hocs/withKeyboardAccessibility.tsx +2 -3
  142. package/hocs/withPortal.tsx +1 -1
  143. package/hooks/index.tsx +2 -12
  144. package/hooks/useActionState.tsx +19 -8
  145. package/hooks/useContrastColor.ts +1 -2
  146. package/hooks/useFilePicker.tsx +7 -17
  147. package/hooks/useHandleNumberFormat.tsx +2 -2
  148. package/hooks/useMediaQuery.tsx +1 -2
  149. package/package.json +95 -111
  150. package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +6 -3
  151. package/shortcuts-manager/ShortcutsManager/utils.tsx +1 -1
  152. package/shortcuts-manager/useSetScopes/useSetScopes.tsx +1 -1
  153. package/shortcuts-manager/useShortcut/useShortcut.tsx +1 -1
  154. package/styles/shadow.ts +2 -1
  155. package/styles/themes/LightTheme.tsx +1 -1
  156. package/utils/DocumentPicker/documentPicker.ts +78 -27
  157. package/utils/DocumentPicker/types.ts +0 -1
  158. package/utils/extractSubcomponents.ts +89 -0
  159. package/utils/extractTextStyles.ts +1 -2
  160. package/utils/formatNumberWithMask/formatNumberWithMask.ts +2 -1
  161. package/utils/index.ts +0 -3
  162. package/utils/normalizeToNumberString/normalizeToNumberString.ts +1 -1
  163. package/components/DatePickerDocked/DatePickerDocked.tsx +0 -30
  164. package/components/DatePickerDocked/DatePickerDockedHeader.tsx +0 -129
  165. package/components/DatePickerDocked/index.tsx +0 -17
  166. package/components/DatePickerDocked/types.ts +0 -11
  167. package/components/DatePickerDocked/utils.ts +0 -157
  168. package/components/DatePickerInline/DatePickerContext.tsx +0 -21
  169. package/components/DatePickerInput/DatePickerInput.tsx +0 -139
  170. package/components/DatePickerInput/DatePickerInputModal.tsx +0 -48
  171. package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +0 -77
  172. package/components/DatePickerInput/DateRangeInput.tsx +0 -88
  173. package/components/DatePickerInput/index.tsx +0 -10
  174. package/components/DatePickerInput/types.ts +0 -28
  175. package/components/DatePickerInput/utils.ts +0 -15
  176. package/components/DatePickerModal/AnimatedCrossView.tsx +0 -94
  177. package/components/DatePickerModal/CalendarEdit.tsx +0 -139
  178. package/components/DatePickerModal/DatePickerModal.tsx +0 -85
  179. package/components/DatePickerModal/DatePickerModalContent.tsx +0 -155
  180. package/components/DatePickerModal/DatePickerModalContentHeader.tsx +0 -213
  181. package/components/DatePickerModal/DatePickerModalHeader.tsx +0 -74
  182. package/components/DatePickerModal/DatePickerModalHeaderBackground.tsx +0 -13
  183. package/components/DatePickerModal/index.tsx +0 -16
  184. package/components/DatePickerModal/types.ts +0 -92
  185. package/components/DatePickerModal/utils.ts +0 -122
  186. package/components/DateTimePicker/DateTimePicker.tsx +0 -172
  187. package/components/DateTimePicker/index.tsx +0 -10
  188. package/components/DateTimePicker/utils.ts +0 -12
  189. package/components/HorizontalDivider/HorizontalDivider.tsx +0 -103
  190. package/components/HorizontalDivider/index.tsx +0 -9
  191. package/components/ListItem/ListItem.tsx +0 -136
  192. package/components/ListItem/ListItemDescription.tsx +0 -25
  193. package/components/ListItem/ListItemTitle.tsx +0 -25
  194. package/components/ListItem/index.tsx +0 -14
  195. package/components/ListItem/utils.ts +0 -115
  196. package/components/Menu/MenuDivider.tsx +0 -13
  197. package/components/Menu/MenuItem.tsx +0 -128
  198. package/components/Popover/Popover.native.tsx +0 -185
  199. package/components/RadioButton/RadioButton.tsx +0 -138
  200. package/components/RadioButton/RadioButtonAndroid.tsx +0 -188
  201. package/components/RadioButton/RadioButtonGroup.tsx +0 -98
  202. package/components/RadioButton/RadioButtonIOS.tsx +0 -106
  203. package/components/RadioButton/RadioButtonItem.tsx +0 -232
  204. package/components/RadioButton/index.ts +0 -22
  205. package/components/RadioButton/utils.ts +0 -165
  206. package/components/TimePickerField/TimePickerField.tsx +0 -152
  207. package/components/TimePickerField/index.tsx +0 -10
  208. package/components/TimePickerField/utils.ts +0 -94
  209. package/components/TimePickerModal/TimePickerModal.tsx +0 -115
  210. package/components/TimePickerModal/index.tsx +0 -10
  211. package/components/TimePickerModal/utils.ts +0 -47
  212. package/components/VerticalDivider/VerticalDivider.tsx +0 -100
  213. package/components/VerticalDivider/index.tsx +0 -9
  214. package/context-bridge/index.tsx +0 -87
  215. package/fast-context/index.tsx +0 -190
  216. package/hocs/typedMemo.tsx +0 -5
  217. package/hooks/useControlledValue.tsx +0 -68
  218. package/hooks/useLatest.tsx +0 -9
  219. package/hooks/useMergedRefs.ts +0 -14
  220. package/hooks/usePrevious.ts +0 -13
  221. package/hooks/useSearchable.tsx +0 -74
  222. package/hooks/useSubcomponents.tsx +0 -59
  223. package/hooks/useToggle.tsx +0 -24
  224. package/utils/color.ts +0 -22
  225. package/utils/compare/index.ts +0 -54
  226. package/utils/lodash.ts +0 -49
  227. package/utils/repository.ts +0 -53
@@ -1,46 +1,45 @@
1
- import type { StyleProp, TextProps, TextStyle, ViewStyle } from 'react-native';
1
+ import type { PropsWithoutRef, ReactNode } from 'react';
2
+ import type { TextProps, ViewProps } from 'react-native';
2
3
 
3
4
  import type { TouchableRippleProps } from '../TouchableRipple';
4
5
 
5
6
  export type Size = 'sm' | 'md' | 'lg';
6
7
  export type States = 'disabled' | 'checked' | 'hovered' | 'checkedAndHovered';
7
8
 
8
- export type CheckBoxBaseProps = Omit<TouchableRippleProps, 'children'> & {
9
+ /**
10
+ * Internal props for the platform control (CheckboxBase).
11
+ */
12
+ export type CheckboxBaseProps = Omit<TouchableRippleProps, 'children'> & {
9
13
  /**
10
- * value of checkbox.
14
+ * Whether the checkbox is checked.
11
15
  */
12
- value?: boolean;
16
+ value: boolean;
13
17
  /**
14
- * defaultValue of checkbox.
15
- */
16
- defaultValue?: boolean;
17
- /**
18
- * function execute when the value change i.e checkbox is press
18
+ * Called when the checkbox is pressed.
19
19
  */
20
20
  onChange?: (newValue: boolean) => void;
21
21
  /**
22
- * Whether or not if it's in the indeterminate state, if true, it will override the value
22
+ * Whether the checkbox is in the indeterminate state (overrides `value`).
23
23
  */
24
24
  indeterminate?: boolean;
25
25
  /**
26
- * Whether checkbox is disabled.
26
+ * Whether the checkbox is disabled.
27
27
  */
28
28
  disabled?: boolean;
29
29
  /**
30
- * Size of the icon.
31
- * Should be a number or a Design Token
30
+ * Size of the checkbox.
32
31
  */
33
32
  size?: Size;
34
33
  /**
35
- * Custom color for unchecked checkbox.
34
+ * Custom color for the checked checkbox.
36
35
  */
37
- uncheckedColor?: string;
36
+ color?: string;
38
37
  /**
39
- * Custom color for checkbox.
38
+ * Custom color for the unchecked checkbox.
40
39
  */
41
- color?: string;
40
+ uncheckedColor?: string;
42
41
  /**
43
- * Accessibility label for the touchable. This is read by the screen reader when the user taps the touchable.
42
+ * Accessibility label for the touchable.
44
43
  */
45
44
  accessibilityLabel?: string;
46
45
  /**
@@ -48,25 +47,60 @@ export type CheckBoxBaseProps = Omit<TouchableRippleProps, 'children'> & {
48
47
  */
49
48
  testID?: string;
50
49
  /**
51
- * Label to be displayed next to the checkbox.
50
+ * Props for the state layer.
51
+ */
52
+ stateLayerProps?: PropsWithoutRef<ViewProps>;
53
+ };
54
+
55
+ /**
56
+ * The checkbox control (the box). Use inside a CheckboxRow, or standalone with `value`/`onChange`.
57
+ */
58
+ export type CheckboxProps = Omit<CheckboxBaseProps, 'value' | 'onChange'> & {
59
+ /**
60
+ * Whether the checkbox is checked (controlled).
61
+ */
62
+ value?: boolean;
63
+ /**
64
+ * Default checked state (uncontrolled).
65
+ */
66
+ defaultValue?: boolean;
67
+ /**
68
+ * Called when the checked state changes.
52
69
  */
53
- label?: string;
70
+ onChange?: (newValue: boolean) => void;
71
+ };
72
+
73
+ export type CheckboxRowProps = ViewProps & {
54
74
  /**
55
- * Style that is passed to Label element.
75
+ * Whether the checkbox is checked (controlled).
56
76
  */
57
- labelStyle?: StyleProp<TextStyle>;
77
+ value?: boolean;
58
78
  /**
59
- * Style that is passed to Container element (when label is provided).
79
+ * Default checked state (uncontrolled).
60
80
  */
61
- containerStyle?: ViewStyle;
81
+ defaultValue?: boolean;
62
82
  /**
63
- * Props for the label text element.
83
+ * Called when the checked state changes.
64
84
  */
65
- labelProps?: Omit<TextProps, 'children' | 'style'>;
85
+ onChange?: (newValue: boolean) => void;
66
86
  /**
67
- * Checkbox control position relative to label.
87
+ * Whether the checkbox is in the indeterminate state.
68
88
  */
69
- position?: 'leading' | 'trailing';
89
+ indeterminate?: boolean;
90
+ /**
91
+ * Disables the row (control + label).
92
+ */
93
+ disabled?: boolean;
94
+ /**
95
+ * Size applied to the checkbox.
96
+ */
97
+ size?: Size;
98
+ /**
99
+ * Checkbox control and Checkbox.Label, in any order.
100
+ */
101
+ children: ReactNode;
102
+ };
70
103
 
71
- style?: StyleProp<TextStyle>;
104
+ export type CheckboxLabelProps = TextProps & {
105
+ children: ReactNode;
72
106
  };
@@ -21,17 +21,14 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
21
21
  sm: {
22
22
  padding: PADDING,
23
23
  borderRadius: 16,
24
- // iconSize: iconSizeMap.sm,
25
24
  },
26
25
  md: {
27
26
  padding: PADDING,
28
27
  borderRadius: 18,
29
- // iconSize: iconSizeMap.md,
30
28
  },
31
29
  lg: {
32
30
  padding: PADDING,
33
31
  borderRadius: 20,
34
- // iconSize: iconSizeMap.lg,
35
32
  },
36
33
  },
37
34
  },
@@ -81,82 +78,6 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
81
78
  },
82
79
  },
83
80
  },
84
- itemContainer: {
85
- flexDirection: 'row',
86
- alignItems: 'center',
87
- justifyContent: 'space-between',
88
- },
89
- label: {
90
- flexShrink: 1,
91
- flexGrow: 1,
92
- variants: {
93
- variant: {
94
- item: {
95
- color: theme.colors.onSurface,
96
- },
97
- },
98
- isLeading: {
99
- true: {
100
- textAlign: 'right',
101
- paddingLeft: 0,
102
- paddingRight: theme.spacings['2'],
103
- },
104
- false: {
105
- textAlign: 'left',
106
- paddingLeft: theme.spacings['2'],
107
- paddingRight: 0,
108
- },
109
- },
110
- },
111
- compoundVariants: [
112
- {
113
- variant: 'item',
114
- size: 'sm',
115
- styles: {
116
- ...theme.typescale.bodyMedium,
117
- },
118
- },
119
- {
120
- variant: 'item',
121
- size: 'md',
122
- styles: {
123
- ...theme.typescale.bodyMedium,
124
- },
125
- },
126
- {
127
- variant: 'item',
128
- size: 'lg',
129
- styles: {
130
- ...theme.typescale.bodyLarge,
131
- },
132
- },
133
- ],
134
- },
135
- fillContainer: {
136
- alignItems: 'center',
137
- justifyContent: 'center',
138
- },
139
- animatedFill: {
140
- width: 24 / 2 + (PADDING - 2),
141
- height: 24 / 2 + (PADDING - 2),
142
-
143
- variants: {
144
- size: {
145
- sm: {
146
- width: iconSizeMap.sm / 2 + (PADDING - 2),
147
- height: iconSizeMap.sm / 2 + (PADDING - 2),
148
- },
149
- md: {
150
- width: iconSizeMap.md / 2 + (PADDING - 2),
151
- height: iconSizeMap.md / 2 + (PADDING - 2),
152
- },
153
- lg: {
154
- width: iconSizeMap.lg / 2 + (PADDING - 2),
155
- height: iconSizeMap.lg / 2 + (PADDING - 2),
156
- },
157
- },
158
- },
159
- },
160
81
  icon: {
161
82
  color: theme.colors.onSurfaceVariant,
162
83
 
@@ -175,36 +96,32 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
175
96
  },
176
97
  },
177
98
  },
178
- // compoundVariantStyles: (variant: 'android' | 'ios' | 'item', size: Size, state: States) => {
179
- // if (variant === 'android') {
180
- // return {
181
- // root: {
182
- // ...(size === 'sm' && { width: 32, height: 32 }),
183
- // ...(size === 'md' && { width: 36, height: 36 }),
184
- // ...(size === 'lg' && { width: 40, height: 40 }),
185
- // },
186
- // stateLayer: {
187
- // ...(state === 'hovered' && {
188
- // backgroundColor: theme.colors.stateLayer.hover.onSurface,
189
- // }),
190
- // ...(state === 'checkedAndHovered' && {
191
- // backgroundColor: theme.colors.stateLayer.hover.primary,
192
- // }),
193
- // },
194
- // } as any;
195
- // }
99
+ }));
196
100
 
197
- // if (variant === 'item') {
198
- // return {
199
- // root: {
200
- // labelColor: 'colors.onSurface',
201
- // ...(size === 'sm' && { labelTypeScale: theme.typescale.bodyMedium }),
202
- // ...(size === 'md' && { labelTypeScale: theme.typescale.bodyLarge }),
203
- // ...(size === 'lg' && { labelTypeScale: theme.typescale.bodyLarge }),
204
- // },
205
- // };
206
- // }
207
- // },
101
+ const checkboxRowStylesDefault = StyleSheet.create(theme => ({
102
+ row: {
103
+ flexDirection: 'row',
104
+ alignItems: 'center',
105
+ },
106
+ label: {
107
+ flexShrink: 1,
108
+ flexGrow: 1,
109
+ color: theme.colors.onSurface,
110
+ ...theme.typescale.bodyLarge,
111
+
112
+ variants: {
113
+ state: {
114
+ checked: {},
115
+ checkedAndHovered: {},
116
+ hovered: {},
117
+ disabled: { color: theme.colors.onSurfaceDisabled },
118
+ },
119
+ },
120
+ },
208
121
  }));
209
122
 
210
123
  export const styles = getRegisteredComponentStylesWithFallback('Checkbox', checkboxStylesDefault);
124
+ export const checkboxRowStyles = getRegisteredComponentStylesWithFallback(
125
+ 'Checkbox_Row',
126
+ checkboxRowStylesDefault,
127
+ );
@@ -97,10 +97,6 @@ export type Props = Omit<TouchableRippleProps, 'children'> &
97
97
  * Whether to show the ActivityIndicator or not
98
98
  */
99
99
  loading?: boolean;
100
- /**
101
- * container style
102
- */
103
- containerStyle?: ViewStyle;
104
100
  /**
105
101
  * left element container style
106
102
  */
@@ -132,7 +128,6 @@ export type Props = Omit<TouchableRippleProps, 'children'> &
132
128
  const Chip = (
133
129
  {
134
130
  style,
135
- containerStyle: containerStyleProp,
136
131
  label: _label,
137
132
  labelCharacterLimit = 20,
138
133
  variant = 'outlined',
@@ -158,11 +153,13 @@ const Chip = (
158
153
  leftElementIconProps,
159
154
  invertLabelColor,
160
155
  backgroundColor,
156
+ onPress,
161
157
  ...rest
162
158
  }: Props,
163
159
  ref: any,
164
160
  ) => {
165
161
  const { hovered, actionsRef } = useActionState({ ref, actionsToListen: ['hover'] });
162
+ const Wrapper = onPress ? TouchableRipple : View;
166
163
 
167
164
  const state = resolveStateVariant({
168
165
  disabled: !!disabled,
@@ -192,47 +189,39 @@ const Chip = (
192
189
  // selectedColorProp ? { selectedColor: selectedColorProp } : {},
193
190
  // ]);
194
191
 
195
- const {
196
- containerStyle,
197
- touchableRippleStyle,
198
- leftElementStyle,
199
- rightElementStyle,
200
- labelStyle,
201
- stateLayerStyle,
202
- } = useMemo(() => {
203
- return {
204
- containerStyle: [
205
- styles.container,
206
- selected && selectionBackgroundColor
207
- ? { backgroundColor: selectionBackgroundColor }
208
- : {},
209
- containerStyleProp,
210
- ],
211
- touchableRippleStyle: [styles.touchableRippleContainer, style],
212
- leftElementStyle: [styles.leftElement, leftElementContainerStyle],
213
- rightElementStyle: [styles.rightElement, rightElementContainerStyle],
214
- labelStyle: [
215
- styles.label,
216
- selected && selectedColor ? { color: selectedColor } : {},
217
- labelStyleProp,
218
- ],
219
- stateLayerStyle: [styles.stateLayer, stateLayerProps?.style],
220
- };
221
- // eslint-disable-next-line react-hooks/exhaustive-deps
222
- }, [
223
- leftElementContainerStyle,
224
- rightElementContainerStyle,
225
- selected,
226
- selectedColor,
227
- selectionBackgroundColor,
228
- stateLayerProps?.style,
229
- style,
230
- containerStyleProp,
231
- labelStyleProp,
232
- state,
233
- size,
234
- variant,
235
- ]);
192
+ const { containerStyle, leftElementStyle, rightElementStyle, labelStyle, stateLayerStyle } =
193
+ useMemo(() => {
194
+ return {
195
+ containerStyle: [
196
+ styles.container,
197
+ selected && selectionBackgroundColor
198
+ ? { backgroundColor: selectionBackgroundColor }
199
+ : {},
200
+ style,
201
+ ],
202
+ leftElementStyle: [styles.leftElement, leftElementContainerStyle],
203
+ rightElementStyle: [styles.rightElement, rightElementContainerStyle],
204
+ labelStyle: [
205
+ styles.label,
206
+ selected && selectedColor ? { color: selectedColor } : {},
207
+ labelStyleProp,
208
+ ],
209
+ stateLayerStyle: [styles.stateLayer, stateLayerProps?.style],
210
+ };
211
+ // eslint-disable-next-line react-hooks/exhaustive-deps
212
+ }, [
213
+ leftElementContainerStyle,
214
+ rightElementContainerStyle,
215
+ selected,
216
+ selectedColor,
217
+ selectionBackgroundColor,
218
+ stateLayerProps?.style,
219
+ style,
220
+ labelStyleProp,
221
+ state,
222
+ size,
223
+ variant,
224
+ ]);
236
225
 
237
226
  const { accessibilityState, elevation } = useMemo(
238
227
  () => ({
@@ -251,14 +240,14 @@ const Chip = (
251
240
  {...containerProps}
252
241
  elevation={elevation}
253
242
  style={containerStyle}
254
- backgroundColor={backgroundColor}>
255
- <TouchableRipple
243
+ backgroundColor={backgroundColor}
244
+ asChild>
245
+ <Wrapper
256
246
  borderless
257
247
  {...rest}
258
248
  disabled={disabled}
259
- style={touchableRippleStyle}
249
+ onPress={onPress}
260
250
  accessibilityLabel={accessibilityLabel}
261
- accessibilityRole="button"
262
251
  accessibilityState={accessibilityState}
263
252
  ref={actionsRef}
264
253
  testID={testID}>
@@ -297,7 +286,7 @@ const Chip = (
297
286
  style={stateLayerStyle}
298
287
  />
299
288
  </>
300
- </TouchableRipple>
289
+ </Wrapper>
301
290
  </Surface>
302
291
  );
303
292
  };
@@ -362,7 +351,7 @@ const RightElement = memo(
362
351
  {onClose ? (
363
352
  <IconButtonWithContrastColor
364
353
  name="close"
365
- size={18}
354
+ size={14}
366
355
  accessibilityLabel="Close"
367
356
  disabled={disabled}
368
357
  onPress={onClose}
@@ -6,6 +6,9 @@ const chipStylesDefault = StyleSheet.create(theme => ({
6
6
  container: {
7
7
  borderRadius: theme.shapes.corner.small,
8
8
  backgroundColor: theme.colors.surface,
9
+ paddingHorizontal: theme.spacings['2'],
10
+ flexDirection: 'row',
11
+ alignItems: 'center',
9
12
 
10
13
  variants: {
11
14
  variant: {
@@ -47,13 +50,6 @@ const chipStylesDefault = StyleSheet.create(theme => ({
47
50
  },
48
51
  },
49
52
  },
50
- touchableRippleContainer: {
51
- flex: 1,
52
- paddingHorizontal: theme.spacings['2'],
53
- borderRadius: theme.shapes.corner.small,
54
- flexDirection: 'row',
55
- alignItems: 'center',
56
- },
57
53
  label: {
58
54
  display: 'flex',
59
55
  color: theme.colors.onSurfaceVariant,
@@ -0,0 +1,111 @@
1
+ import { memo, useCallback, useMemo, useRef } from 'react';
2
+
3
+ import type { DatePickerValue, RangeValue } from '../DatePicker/context';
4
+ import { useDatePickerContext } from '../DatePicker/context';
5
+ import type { TextInputProps } from '../TextInput';
6
+ import { TextInputWithMask } from '../TextInputWithMask';
7
+ import { useDateFieldState } from './useDateFieldState';
8
+
9
+ export type DateFieldInputMode = 'start' | 'end';
10
+
11
+ export type DateFieldProps = Omit<
12
+ TextInputProps,
13
+ 'value' | 'defaultValue' | 'onChangeText' | 'inputMode'
14
+ > & {
15
+ inputMode?: DateFieldInputMode;
16
+ dateFormat?: string;
17
+ mask?: string;
18
+ };
19
+
20
+ const DEFAULT_DATE_FORMAT = 'dd/MM/yyyy';
21
+
22
+ const isRange = (value: DatePickerValue): value is RangeValue =>
23
+ value !== null && typeof value === 'object' && 'start' in value && 'end' in value;
24
+
25
+ const preserveTime = (next: Date | null, prev: Date | null): Date | null => {
26
+ if (!next || !prev) return next;
27
+
28
+ const combined = new Date(next);
29
+
30
+ combined.setHours(
31
+ prev.getHours(),
32
+ prev.getMinutes(),
33
+ prev.getSeconds(),
34
+ prev.getMilliseconds(),
35
+ );
36
+ return combined;
37
+ };
38
+
39
+ function DateField({
40
+ ref,
41
+ inputMode = 'start',
42
+ dateFormat = DEFAULT_DATE_FORMAT,
43
+ disabled: disabledProp,
44
+ onBlur,
45
+ onFocus,
46
+ ...rest
47
+ }: DateFieldProps) {
48
+ const {
49
+ mode,
50
+ value,
51
+ commitValue,
52
+ validRange,
53
+ disabled: providerDisabled,
54
+ } = useDatePickerContext();
55
+ const isBlurredRef = useRef(true);
56
+
57
+ const disabled = disabledProp ?? providerDisabled;
58
+
59
+ const fieldValue = useMemo<Date | null>(() => {
60
+ if (mode === 'range') {
61
+ if (!isRange(value)) return null;
62
+ return inputMode === 'end' ? value.end : value.start;
63
+ }
64
+ return isRange(value) ? null : value;
65
+ }, [value, mode, inputMode]);
66
+
67
+ const onChange = useCallback(
68
+ (next: Date | null) => {
69
+ if (mode === 'range') {
70
+ const current: RangeValue = isRange(value) ? value : { start: null, end: null };
71
+ commitValue({ ...current, [inputMode]: next });
72
+ return;
73
+ }
74
+ commitValue(preserveTime(next, isRange(value) ? null : value));
75
+ },
76
+ [mode, value, inputMode, commitValue],
77
+ );
78
+
79
+ const {
80
+ formattedValue,
81
+ onChangeText,
82
+ onBlur: onInnerBlur,
83
+ onFocus: onInnerFocus,
84
+ } = useDateFieldState({
85
+ value: fieldValue,
86
+ validRange,
87
+ inputMode,
88
+ dateFormat,
89
+ onChange,
90
+ onBlur,
91
+ onFocus,
92
+ isBlurredRef,
93
+ });
94
+
95
+ return (
96
+ <TextInputWithMask
97
+ placeholder={dateFormat}
98
+ keyboardType="number-pad"
99
+ mask={dateFormat}
100
+ {...rest}
101
+ ref={ref}
102
+ disabled={disabled}
103
+ value={formattedValue}
104
+ onChangeText={onChangeText}
105
+ onBlur={onInnerBlur}
106
+ onFocus={onInnerFocus}
107
+ />
108
+ );
109
+ }
110
+
111
+ export default memo(DateField);
@@ -0,0 +1,6 @@
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
+ import DateFieldDefault from './DateField';
3
+
4
+ export const DateField = getRegisteredComponentWithFallback('DateField', DateFieldDefault);
5
+
6
+ export type { DateFieldInputMode, DateFieldProps } from './DateField';