react-native-molecules 0.5.0-beta.1 → 0.5.0-beta.10

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 (152) hide show
  1. package/README.md +87 -0
  2. package/components/Accordion/index.tsx +1 -6
  3. package/components/Accordion/utils.ts +17 -14
  4. package/components/ActivityIndicator/ActivityIndicator.tsx +12 -20
  5. package/components/ActivityIndicator/index.tsx +1 -5
  6. package/components/Appbar/index.tsx +1 -4
  7. package/components/Appbar/utils.ts +33 -21
  8. package/components/Avatar/index.tsx +1 -5
  9. package/components/Avatar/utils.ts +2 -6
  10. package/components/Backdrop/Backdrop.tsx +2 -2
  11. package/components/Backdrop/index.tsx +1 -5
  12. package/components/Backdrop/utils.ts +5 -6
  13. package/components/Badge/index.tsx +1 -5
  14. package/components/Badge/utils.ts +2 -6
  15. package/components/Button/Button.tsx +211 -264
  16. package/components/Button/index.tsx +9 -7
  17. package/components/Button/types.ts +16 -2
  18. package/components/Button/utils.ts +231 -210
  19. package/components/Card/Card.tsx +8 -4
  20. package/components/Card/CardContent.tsx +5 -4
  21. package/components/Card/CardHeader.tsx +5 -3
  22. package/components/Card/CardMedia.tsx +5 -3
  23. package/components/Card/CardTypography.tsx +5 -3
  24. package/components/Card/index.tsx +1 -5
  25. package/components/Card/utils.ts +5 -6
  26. package/components/Checkbox/Checkbox.tsx +1 -0
  27. package/components/Checkbox/CheckboxBase.ios.tsx +1 -0
  28. package/components/Checkbox/CheckboxBase.tsx +1 -0
  29. package/components/Checkbox/index.tsx +1 -5
  30. package/components/Checkbox/utils.ts +6 -6
  31. package/components/Chip/Chip.tsx +40 -52
  32. package/components/Chip/index.tsx +1 -5
  33. package/components/Chip/utils.ts +5 -13
  34. package/components/DatePickerDocked/index.tsx +1 -5
  35. package/components/DatePickerDocked/utils.ts +21 -19
  36. package/components/DatePickerInline/index.tsx +1 -5
  37. package/components/DatePickerInline/utils.ts +41 -28
  38. package/components/DatePickerInput/index.tsx +1 -5
  39. package/components/DatePickerInput/utils.ts +5 -6
  40. package/components/DatePickerModal/DatePickerModalHeader.tsx +1 -1
  41. package/components/DatePickerModal/index.tsx +1 -5
  42. package/components/DatePickerModal/utils.ts +17 -16
  43. package/components/DateTimePicker/index.tsx +1 -5
  44. package/components/DateTimePicker/utils.ts +5 -6
  45. package/components/Dialog/index.tsx +1 -5
  46. package/components/Dialog/utils.ts +22 -16
  47. package/components/Drawer/Collapsible/utils.ts +13 -13
  48. package/components/Drawer/Drawer.tsx +2 -3
  49. package/components/Drawer/DrawerContent.tsx +5 -3
  50. package/components/Drawer/DrawerFooter.tsx +5 -4
  51. package/components/Drawer/DrawerHeader.tsx +5 -4
  52. package/components/Drawer/DrawerItem.tsx +5 -3
  53. package/components/Drawer/DrawerItemGroup.tsx +5 -4
  54. package/components/Drawer/index.tsx +1 -5
  55. package/components/Drawer/utils.ts +7 -7
  56. package/components/ElementGroup/ElementGroup.tsx +16 -14
  57. package/components/ElementGroup/index.tsx +1 -5
  58. package/components/ElementGroup/utils.ts +5 -6
  59. package/components/FAB/index.tsx +1 -5
  60. package/components/FAB/utils.ts +2 -6
  61. package/components/FilePicker/index.tsx +1 -5
  62. package/components/FilePicker/utils.ts +5 -6
  63. package/components/HelperText/index.tsx +1 -5
  64. package/components/HelperText/utils.ts +5 -7
  65. package/components/HorizontalDivider/HorizontalDivider.tsx +5 -3
  66. package/components/HorizontalDivider/index.tsx +1 -5
  67. package/components/Icon/CrossFadeIcon.tsx +3 -5
  68. package/components/Icon/Icon.tsx +2 -4
  69. package/components/Icon/iconFactory.tsx +3 -3
  70. package/components/Icon/index.tsx +2 -6
  71. package/components/Icon/types.ts +17 -6
  72. package/components/IconButton/IconButton.tsx +45 -58
  73. package/components/IconButton/index.tsx +1 -5
  74. package/components/IconButton/utils.ts +15 -26
  75. package/components/If/index.tsx +1 -5
  76. package/components/InputAddon/index.tsx +1 -5
  77. package/components/InputAddon/utils.ts +5 -6
  78. package/components/Link/index.tsx +1 -5
  79. package/components/Link/utils.ts +2 -6
  80. package/components/ListItem/index.tsx +1 -5
  81. package/components/ListItem/utils.ts +13 -11
  82. package/components/LoadingIndicator/LoadingIndicator.tsx +253 -0
  83. package/components/LoadingIndicator/LoadingIndicator.web.tsx +136 -0
  84. package/components/LoadingIndicator/index.tsx +13 -0
  85. package/components/LoadingIndicator/utils.ts +117 -0
  86. package/components/Menu/index.tsx +1 -5
  87. package/components/Menu/utils.ts +6 -8
  88. package/components/Modal/index.tsx +1 -5
  89. package/components/Modal/utils.ts +2 -6
  90. package/components/NavigationRail/NavigationRailHeader.tsx +1 -1
  91. package/components/NavigationRail/index.tsx +1 -5
  92. package/components/NavigationRail/utils.ts +21 -17
  93. package/components/NavigationStack/index.tsx +1 -5
  94. package/components/NavigationStack/utils.tsx +7 -1
  95. package/components/Portal/index.tsx +1 -5
  96. package/components/RadioButton/index.ts +1 -5
  97. package/components/RadioButton/utils.ts +9 -8
  98. package/components/Rating/index.tsx +1 -5
  99. package/components/Rating/utils.ts +6 -8
  100. package/components/Select/Select.tsx +360 -501
  101. package/components/Select/index.ts +7 -14
  102. package/components/Select/types.ts +2 -4
  103. package/components/Select/utils.ts +215 -0
  104. package/components/Slot/Slot.tsx +244 -0
  105. package/components/Slot/compose-refs.tsx +60 -0
  106. package/components/Slot/index.tsx +8 -0
  107. package/components/StateLayer/index.tsx +1 -5
  108. package/components/StateLayer/utils.ts +5 -6
  109. package/components/Surface/Surface.android.tsx +34 -8
  110. package/components/Surface/Surface.ios.tsx +36 -29
  111. package/components/Surface/Surface.tsx +31 -4
  112. package/components/Surface/index.tsx +1 -5
  113. package/components/Surface/utils.ts +49 -36
  114. package/components/Switch/Switch.tsx +8 -2
  115. package/components/Switch/index.tsx +1 -5
  116. package/components/Switch/utils.ts +2 -6
  117. package/components/Tabs/index.tsx +1 -5
  118. package/components/Tabs/utils.ts +10 -10
  119. package/components/Text/Text.tsx +2 -8
  120. package/components/TextInput/TextInput.tsx +5 -4
  121. package/components/TextInput/index.tsx +1 -5
  122. package/components/TextInput/utils.ts +8 -15
  123. package/components/TextInputWithMask/index.tsx +1 -5
  124. package/components/TimePicker/AmPmSwitcher.tsx +1 -1
  125. package/components/TimePicker/index.tsx +1 -5
  126. package/components/TimePicker/utils.ts +29 -21
  127. package/components/TimePickerField/index.tsx +1 -5
  128. package/components/TimePickerField/utils.ts +5 -6
  129. package/components/TimePickerModal/TimePickerModal.tsx +6 -2
  130. package/components/TimePickerModal/index.tsx +1 -5
  131. package/components/TimePickerModal/utils.ts +5 -6
  132. package/components/Tooltip/TooltipTrigger.tsx +25 -16
  133. package/components/Tooltip/index.tsx +1 -5
  134. package/components/Tooltip/utils.ts +5 -6
  135. package/components/TouchableRipple/TouchableRipple.native.tsx +49 -13
  136. package/components/TouchableRipple/TouchableRipple.tsx +136 -46
  137. package/components/TouchableRipple/index.tsx +1 -5
  138. package/components/TouchableRipple/utils.ts +5 -6
  139. package/components/VerticalDivider/VerticalDivider.tsx +9 -8
  140. package/components/VerticalDivider/index.tsx +1 -5
  141. package/core/componentsRegistry.ts +31 -19
  142. package/hocs/withPortal.tsx +1 -1
  143. package/hooks/useControlledValue.tsx +20 -4
  144. package/hooks/useSubcomponents.tsx +56 -22
  145. package/hooks/useWhatHasUpdated.tsx +48 -0
  146. package/package.json +10 -13
  147. package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +5 -2
  148. package/styles/shadow.ts +2 -1
  149. package/styles/themes/LightTheme.tsx +1 -1
  150. package/utils/extractPropertiesFromStyles.ts +25 -0
  151. package/utils/lodash.ts +77 -6
  152. package/utils/repository.ts +2 -52
@@ -3,8 +3,12 @@ import { Animated, type StyleProp, View, type ViewStyle } from 'react-native';
3
3
  import { useUnistyles } from 'react-native-unistyles';
4
4
 
5
5
  import type { MD3Elevation } from '../../types/theme';
6
+ import { extractPropertiesFromStyles } from '../../utils/extractPropertiesFromStyles';
7
+ import { Slot } from '../Slot';
6
8
  import { BackgroundContextWrapper } from './BackgroundContextWrapper';
7
- import { defaultStyles, extractProperties, getStyleForShadowLayer } from './utils';
9
+ import { defaultStyles, getCombinedShadowStyle } from './utils';
10
+
11
+ const AnimatedView = Animated.createAnimatedComponent(View);
8
12
 
9
13
  export type Props = ComponentPropsWithRef<typeof View> & {
10
14
  /**
@@ -26,6 +30,23 @@ export type Props = ComponentPropsWithRef<typeof View> & {
26
30
  * TestID used for testing purposes
27
31
  */
28
32
  testID?: string;
33
+ /**
34
+ * When `true`, the component will not render a wrapper element. Instead, it will
35
+ * merge its props (styles, elevation shadow, ref) onto its immediate child element.
36
+ * This follows the Radix UI "Slot" pattern for flexible component composition.
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // With asChild - merges elevation styles onto the child
41
+ * <Surface asChild elevation={2}>
42
+ * <Card><Text>Content</Text></Card>
43
+ * </Surface>
44
+ * ```
45
+ *
46
+ * @note When `asChild` is `true`, only a single child element is allowed.
47
+ * @default false
48
+ */
49
+ asChild?: boolean;
29
50
  };
30
51
 
31
52
  /**
@@ -70,52 +91,38 @@ export type Props = ComponentPropsWithRef<typeof View> & {
70
91
  * });
71
92
  * ```
72
93
  */
73
- const Surface = ({ elevation = 1, style, children, testID, ...props }: Props, ref: any) => {
94
+ const Surface = (
95
+ { elevation = 1, style, children, testID, asChild = false, ...props }: Props,
96
+ ref: any,
97
+ ) => {
74
98
  const { theme } = useUnistyles();
75
99
  const backgroundColor = (() => {
76
100
  // @ts-ignore
77
101
  return theme.colors.elevation?.[`level${elevation}`];
78
102
  })();
79
103
 
80
- const { surfaceBackground, sharedStyle, layer0Style, layer1Style } = useMemo(() => {
81
- const { position, alignSelf, top, left, right, bottom, borderRadius } = extractProperties(
82
- [defaultStyles.root as ViewStyle, style],
83
- ['position', 'alignSelf', 'top', 'left', 'right', 'bottom', 'borderRadius'],
84
- );
85
- const absoluteStyle = { position, alignSelf, top, right, bottom, left };
86
-
104
+ const { surfaceBackground, combinedStyle } = useMemo(() => {
87
105
  return {
88
- surfaceBackground: extractProperties(
106
+ surfaceBackground: extractPropertiesFromStyles(
89
107
  [defaultStyles.root as ViewStyle, style],
90
108
  ['backgroundColor'],
91
109
  ).backgroundColor,
92
- sharedStyle: [
93
- { backgroundColor, borderRadius },
110
+ combinedStyle: [
111
+ { backgroundColor },
112
+ getCombinedShadowStyle(elevation),
94
113
  defaultStyles.root,
95
114
  style,
96
- {
97
- position: undefined,
98
- alignSelf: undefined,
99
- top: undefined,
100
- left: undefined,
101
- right: undefined,
102
- bottom: undefined,
103
- },
104
115
  ],
105
- layer0Style: [getStyleForShadowLayer(0, elevation), absoluteStyle, { borderRadius }],
106
- layer1Style: [getStyleForShadowLayer(1, elevation), { borderRadius }],
107
116
  };
108
117
  }, [backgroundColor, elevation, style]);
109
118
 
119
+ const Component = asChild ? Slot : AnimatedView;
120
+
110
121
  return (
111
122
  <BackgroundContextWrapper backgroundColor={surfaceBackground}>
112
- <View ref={ref} style={layer0Style}>
113
- <View style={layer1Style}>
114
- <View {...props} testID={testID} style={sharedStyle}>
115
- {children}
116
- </View>
117
- </View>
118
- </View>
123
+ <Component ref={ref} {...props} testID={testID} style={combinedStyle}>
124
+ {children}
125
+ </Component>
119
126
  </BackgroundContextWrapper>
120
127
  );
121
128
  };
@@ -1,11 +1,14 @@
1
1
  import { forwardRef, memo, type ReactNode, useMemo } from 'react';
2
- import { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';
2
+ import { Animated, type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';
3
3
 
4
4
  import shadow from '../../styles/shadow';
5
5
  import type { MD3Elevation } from '../../types/theme';
6
+ import { Slot } from '../Slot';
6
7
  import { BackgroundContextWrapper } from './BackgroundContextWrapper';
7
8
  import { defaultStyles } from './utils';
8
9
 
10
+ const AnimatedView = Animated.createAnimatedComponent(View);
11
+
9
12
  export type Props = ViewProps & {
10
13
  /**
11
14
  * Content of the `Surface`.
@@ -18,11 +21,33 @@ export type Props = ViewProps & {
18
21
  * TestID used for testing purposes
19
22
  */
20
23
  testID?: string;
24
+ /**
25
+ * When `true`, the component will not render a wrapper element. Instead, it will
26
+ * merge its props (styles, elevation shadow, ref) onto its immediate child element.
27
+ * This follows the Radix UI "Slot" pattern for flexible component composition.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * // Without asChild - renders an AnimatedView wrapper
32
+ * <Surface elevation={2}>
33
+ * <Card><Text>Content</Text></Card>
34
+ * </Surface>
35
+ *
36
+ * // With asChild - merges elevation styles onto the child
37
+ * <Surface asChild elevation={2}>
38
+ * <Card><Text>Content</Text></Card>
39
+ * </Surface>
40
+ * ```
41
+ *
42
+ * @note When `asChild` is `true`, only a single child element is allowed.
43
+ * @default false
44
+ */
45
+ asChild?: boolean;
21
46
  };
22
47
 
23
48
  // for Web
24
49
  const Surface = (
25
- { elevation = 1, style, children, testID, backgroundColor, ...props }: Props,
50
+ { elevation = 1, style, children, testID, backgroundColor, asChild = false, ...props }: Props,
26
51
  ref: any,
27
52
  ) => {
28
53
  const { surfaceStyle } = useMemo(() => {
@@ -36,11 +61,13 @@ const Surface = (
36
61
  };
37
62
  }, [backgroundColor, elevation, style]);
38
63
 
64
+ const Component = asChild ? Slot : AnimatedView;
65
+
39
66
  return (
40
67
  <BackgroundContextWrapper backgroundColor={backgroundColor!}>
41
- <View ref={ref} {...props} testID={testID} style={surfaceStyle}>
68
+ <Component ref={ref} {...props} testID={testID} style={surfaceStyle}>
42
69
  {children}
43
- </View>
70
+ </Component>
44
71
  </BackgroundContextWrapper>
45
72
  );
46
73
  };
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import SurfaceDefault from './Surface';
3
3
 
4
- registerMoleculesComponents({
5
- Surface: SurfaceDefault,
6
- });
7
-
8
4
  export const Surface = getRegisteredComponentWithFallback('Surface', SurfaceDefault);
9
5
 
10
6
  export * from './BackgroundContextWrapper';
@@ -1,7 +1,7 @@
1
1
  import type { Animated } from 'react-native';
2
2
  import { StyleSheet } from 'react-native-unistyles';
3
3
 
4
- import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
4
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
5
5
  import { inputRange } from '../../styles/shadow';
6
6
 
7
7
  const defaultStylesDefault = StyleSheet.create(theme => ({
@@ -10,35 +10,10 @@ const defaultStylesDefault = StyleSheet.create(theme => ({
10
10
  },
11
11
  }));
12
12
 
13
- registerComponentsStyles({
14
- Surface: defaultStylesDefault,
15
- });
16
-
17
- export const defaultStyles = getRegisteredMoleculesComponentStyles('Surface');
18
-
19
- // TODO - abstract this
20
- export function extractProperties(
21
- _objectsArray: Record<string, any>,
22
- propertiesToExtract: string[],
23
- ) {
24
- const extracted: Record<string, any> = {};
25
-
26
- const objectsArray = _objectsArray.flat();
27
-
28
- for (let i = objectsArray.length - 1; i >= 0; i--) {
29
- const obj = objectsArray[i];
30
-
31
- for (const prop of propertiesToExtract) {
32
- if (!obj) continue;
33
- if (prop in obj) {
34
- // @ts-ignore
35
- extracted[prop] = obj[prop];
36
- }
37
- }
38
- }
39
-
40
- return extracted;
41
- }
13
+ export const defaultStyles = getRegisteredComponentStylesWithFallback(
14
+ 'Surface',
15
+ defaultStylesDefault,
16
+ );
42
17
 
43
18
  const _shadowColor = '#000';
44
19
 
@@ -97,10 +72,48 @@ export const getStyleForShadowLayer = (
97
72
  };
98
73
  };
99
74
 
100
- export const getElevationAndroid = (
101
- elevation: number,
102
- _inputRange: number[],
103
- elevationLevel: number[],
104
- ) => {
105
- return elevationLevel[elevation];
75
+ /**
76
+ * Combines the two shadow layers into a single shadow style.
77
+ * This approximates the two-layer shadow effect using a single shadow.
78
+ */
79
+ export const getCombinedShadowStyle = (elevation: number, shadowColor = _shadowColor) => {
80
+ if (elevation === 0) {
81
+ return {
82
+ shadowColor,
83
+ shadowOpacity: 0,
84
+ shadowOffset: { width: 0, height: 0 },
85
+ shadowRadius: 0,
86
+ };
87
+ }
88
+
89
+ const layer0 = iOSShadowOutputRanges[0];
90
+ const layer1 = iOSShadowOutputRanges[1];
91
+
92
+ // Use the larger shadow offset (from layer 0)
93
+ const shadowOffsetHeight = layer0.height[elevation];
94
+
95
+ // Use the larger shadow radius (from layer 0)
96
+ const shadowRadius = layer0.shadowRadius[elevation];
97
+
98
+ // Combine opacities (additive, capped at 1.0)
99
+ // This approximates the visual effect of two overlapping shadows
100
+ const shadowOpacity = Math.min(1.0, layer0.shadowOpacity + layer1.shadowOpacity);
101
+
102
+ return {
103
+ shadowColor,
104
+ shadowOpacity,
105
+ shadowOffset: {
106
+ width: 0,
107
+ height: shadowOffsetHeight,
108
+ },
109
+ shadowRadius,
110
+ };
106
111
  };
112
+
113
+ // export const getElevationAndroid = (
114
+ // elevation: number,
115
+ // _inputRange: number[],
116
+ // elevationLevel: number[],
117
+ // ) => {
118
+ // return elevationLevel[elevation];
119
+ // };
@@ -70,6 +70,7 @@ const Switch = (
70
70
  ref,
71
71
  actionsToListen: ['focus', 'hover', 'press'],
72
72
  });
73
+ const isFirstRender = useRef(true);
73
74
 
74
75
  const [value, onChange] = useControlledValue({
75
76
  value: valueProp,
@@ -98,8 +99,8 @@ const Switch = (
98
99
  state,
99
100
  });
100
101
 
101
- const toggleMarginAnimation = useRef(new Animated.Value(value ? 0 : 1)).current;
102
- const toggleSizeAnimation = useRef(new Animated.Value(value ? 0 : 1)).current;
102
+ const toggleMarginAnimation = useRef(new Animated.Value(value ? 1 : 0)).current;
103
+ const toggleSizeAnimation = useRef(new Animated.Value(value ? 1 : 0)).current;
103
104
 
104
105
  const thumbPosition = toggleMarginAnimation.interpolate({
105
106
  inputRange: [0, 1],
@@ -130,6 +131,11 @@ const Switch = (
130
131
  });
131
132
 
132
133
  useEffect(() => {
134
+ if (isFirstRender.current) {
135
+ isFirstRender.current = false;
136
+ return;
137
+ }
138
+
133
139
  Animated.timing(toggleMarginAnimation, {
134
140
  toValue: value ? 1 : 0,
135
141
  duration: 300,
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import SwitchDefault from './Switch';
3
3
 
4
- registerMoleculesComponents({
5
- Switch: SwitchDefault,
6
- });
7
-
8
4
  export const Switch = getRegisteredComponentWithFallback('Switch', SwitchDefault);
9
5
 
10
6
  export { type Props as SwitchProps } from './Switch';
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet, useUnistyles } from 'react-native-unistyles';
2
2
 
3
- import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
3
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
4
4
 
5
5
  type States =
6
6
  | 'selected'
@@ -276,8 +276,4 @@ const switchStylesDefault = StyleSheet.create(theme => ({
276
276
  },
277
277
  }));
278
278
 
279
- registerComponentsStyles({
280
- Switch: switchStylesDefault,
281
- });
282
-
283
- export const switchStyles = getRegisteredMoleculesComponentStyles('Switch');
279
+ export const switchStyles = getRegisteredComponentStylesWithFallback('Switch', switchStylesDefault);
@@ -1,4 +1,4 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import type { TabItemProps } from './TabItem';
3
3
  import { default as TabItem } from './TabItem';
4
4
  import type { TabLabelProps } from './TabLabel';
@@ -11,10 +11,6 @@ export const TabsDefault = Object.assign(TabBase, {
11
11
  Label: TabLabel,
12
12
  });
13
13
 
14
- registerMoleculesComponents({
15
- Tabs: TabsDefault,
16
- });
17
-
18
14
  export const Tabs = getRegisteredComponentWithFallback('Tabs', TabsDefault);
19
15
 
20
16
  export type { TabItemProps, TabLabelProps, TabsProps };
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet } from 'react-native-unistyles';
2
2
 
3
- import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
3
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
4
4
 
5
5
  const tabsStylesDefault = StyleSheet.create(theme => ({
6
6
  root: {
@@ -113,14 +113,14 @@ const tabsLabelStylesDefault = StyleSheet.create(theme => ({
113
113
  },
114
114
  }));
115
115
 
116
- registerComponentsStyles({
117
- Tabs: tabsStylesDefault,
118
- Tabs_Item: tabsItemStylesDefault,
119
- Tabs_Label: tabsLabelStylesDefault,
120
- });
121
-
122
- export const tabsStyles = getRegisteredMoleculesComponentStyles('Tabs');
123
- export const tabsItemStyles = getRegisteredMoleculesComponentStyles('Tabs_Item');
124
- export const tabsLabelStyles = getRegisteredMoleculesComponentStyles('Tabs_Label');
116
+ export const tabsStyles = getRegisteredComponentStylesWithFallback('Tabs', tabsStylesDefault);
117
+ export const tabsItemStyles = getRegisteredComponentStylesWithFallback(
118
+ 'Tabs_Item',
119
+ tabsItemStylesDefault,
120
+ );
121
+ export const tabsLabelStyles = getRegisteredComponentStylesWithFallback(
122
+ 'Tabs_Label',
123
+ tabsLabelStylesDefault,
124
+ );
125
125
 
126
126
  export type States = 'hovered' | 'active' | 'activeAndHovered' | 'disabled';
@@ -1,10 +1,8 @@
1
1
  import { StyleSheet } from 'react-native-unistyles';
2
2
 
3
3
  import {
4
+ getRegisteredComponentStylesWithFallback,
4
5
  getRegisteredComponentWithFallback,
5
- getRegisteredMoleculesComponentStyles,
6
- registerComponentStyles,
7
- registerMoleculesComponent,
8
6
  } from '../../core';
9
7
  import { textFactory } from './textFactory';
10
8
 
@@ -12,12 +10,8 @@ const defaultStyles = StyleSheet.create(theme => ({
12
10
  root: { color: theme.colors.onSurface, ...theme.typescale.bodyMedium },
13
11
  }));
14
12
 
15
- registerComponentStyles('Text', defaultStyles);
16
-
17
13
  const TextDefault = textFactory(
18
- (getRegisteredMoleculesComponentStyles('Text') as any) ?? defaultStyles,
14
+ getRegisteredComponentStylesWithFallback('Text', defaultStyles) as any,
19
15
  );
20
16
 
21
- registerMoleculesComponent('Text', TextDefault);
22
-
23
17
  export default getRegisteredComponentWithFallback('Text', TextDefault);
@@ -3,7 +3,7 @@ import React, {
3
3
  memo,
4
4
  type PropsWithoutRef,
5
5
  type ReactNode,
6
- type RefObject,
6
+ type Ref,
7
7
  useCallback,
8
8
  useContext,
9
9
  useEffect,
@@ -50,7 +50,7 @@ type Element = ReactNode | ((props: ElementProps) => ReactNode);
50
50
 
51
51
  export type Props = Omit<TextInputProps, 'ref'> &
52
52
  WithElements<Element> & {
53
- ref?: RefObject<TextInputHandles | null>;
53
+ ref?: Ref<NativeTextInput | null>;
54
54
  /**
55
55
  * Variant of the TextInput.
56
56
  * - `flat` - flat input with an underline.
@@ -194,8 +194,8 @@ const DefaultComponent = (props: RenderProps) => <NativeTextInput {...props} />;
194
194
  const TextInput = forwardRef<TextInputHandles, Props>(
195
195
  (
196
196
  {
197
- variant = 'flat',
198
- size = 'md',
197
+ variant = 'outlined',
198
+ size = 'sm',
199
199
  disabled = false,
200
200
  error: errorProp = false,
201
201
  multiline = false,
@@ -432,6 +432,7 @@ const TextInput = forwardRef<TextInputHandles, Props>(
432
432
  };
433
433
  }, [onBlurRef]);
434
434
 
435
+ // @ts-ignore // TODO - fix this
435
436
  const componentStyles = styles.root;
436
437
 
437
438
  const labelWidth = labelLayout.width;
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import TextInputDefault from './TextInput';
3
3
 
4
- registerMoleculesComponents({
5
- TextInput: TextInputDefault,
6
- });
7
-
8
4
  export const TextInput = getRegisteredComponentWithFallback('TextInput', TextInputDefault);
9
5
 
10
6
  export {
@@ -1,10 +1,8 @@
1
1
  import { StyleSheet } from 'react-native-unistyles';
2
2
 
3
3
  import {
4
- getRegisteredComponentUtils,
5
- getRegisteredMoleculesComponentStyles,
6
- registerComponentsStyles,
7
- registerComponentUtils,
4
+ getRegisteredComponentStylesWithFallback,
5
+ getRegisteredComponentUtilsWithFallback,
8
6
  } from '../../core';
9
7
 
10
8
  export type States =
@@ -37,12 +35,11 @@ const getInputMinHeightDefault = (variant: string, size: string) => {
37
35
  }
38
36
  };
39
37
 
40
- registerComponentUtils('TextInput', {
41
- getInputMinHeight: getInputMinHeightDefault,
42
- });
43
-
44
- export const getInputMinHeight =
45
- getRegisteredComponentUtils('TextInput').getInputMinHeight ?? getInputMinHeightDefault;
38
+ export const getInputMinHeight = getRegisteredComponentUtilsWithFallback(
39
+ 'TextInput',
40
+ getInputMinHeightDefault,
41
+ 'getInputMinHeight',
42
+ );
46
43
 
47
44
  const textInputStylesDefault = StyleSheet.create(theme => ({
48
45
  root: {
@@ -530,11 +527,7 @@ const textInputStylesDefault = StyleSheet.create(theme => ({
530
527
  },
531
528
  }));
532
529
 
533
- registerComponentsStyles({
534
- TextInput: textInputStylesDefault,
535
- });
536
-
537
- export const styles = getRegisteredMoleculesComponentStyles('TextInput');
530
+ export const styles = getRegisteredComponentStylesWithFallback('TextInput', textInputStylesDefault);
538
531
 
539
532
  export const inputLabelStyles = StyleSheet.create({
540
533
  labelContainer: {
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import TextInputWithMaskDefault from './TextInputMask';
3
3
 
4
- registerMoleculesComponents({
5
- TextInputWithMask: TextInputWithMaskDefault,
6
- });
7
-
8
4
  export const TextInputWithMask = getRegisteredComponentWithFallback(
9
5
  'TextInputWithMask',
10
6
  TextInputWithMaskDefault,
@@ -71,7 +71,7 @@ function SwitchButton({
71
71
  disabled: boolean;
72
72
  }) {
73
73
  timePickerAmPmSwitcherStyles.useVariants({
74
- // TODO - fix ts issues
74
+ // @ts-ignore // TODO - fix this
75
75
  state: resolveStateVariant({
76
76
  selected,
77
77
  }),
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import TimePickerDefault from './TimePicker';
3
3
 
4
- registerMoleculesComponents({
5
- TimePicker: TimePickerDefault,
6
- });
7
-
8
4
  export const TimePicker = getRegisteredComponentWithFallback('TimePicker', TimePickerDefault);
9
5
 
10
6
  export type { Props as TimePickerProps } from './TimePicker';
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet } from 'react-native-unistyles';
2
2
 
3
- import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
3
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
4
4
  import { circleSize } from './timeUtils';
5
5
 
6
6
  const timePickerStylesDefault = StyleSheet.create(theme => ({
@@ -263,23 +263,31 @@ const timePickerAmPmSwitcherStylesDefault = StyleSheet.create(theme => ({
263
263
  },
264
264
  }));
265
265
 
266
- registerComponentsStyles({
267
- TimePicker: timePickerStylesDefault,
268
- TimePicker_Inputs: timePickerInputsStylesDefault,
269
- TimePicker_Input: timePickerInputStylesDefault,
270
- TimePicker_Clock: timePickerClockStylesDefault,
271
- TimePicker_ClockHours: timePickerClockHoursStylesDefault,
272
- TimePicker_ClockMinutes: timePickerClockMinutesStylesDefault,
273
- TimePicker_AmPmSwitcher: timePickerAmPmSwitcherStylesDefault,
274
- });
275
-
276
- export const timePickerStyles = getRegisteredMoleculesComponentStyles('TimePicker');
277
- export const timePickerInputsStyles = getRegisteredMoleculesComponentStyles('TimePicker_Inputs');
278
- export const timePickerInputStyles = getRegisteredMoleculesComponentStyles('TimePicker_Input');
279
- export const timePickerClockStyles = getRegisteredMoleculesComponentStyles('TimePicker_Clock');
280
- export const timePickerClockHoursStyles =
281
- getRegisteredMoleculesComponentStyles('TimePicker_ClockHours');
282
- export const timePickerClockMinutesStyles =
283
- getRegisteredMoleculesComponentStyles('TimePicker_ClockMinutes');
284
- export const timePickerAmPmSwitcherStyles =
285
- getRegisteredMoleculesComponentStyles('TimePicker_AmPmSwitcher');
266
+ export const timePickerStyles = getRegisteredComponentStylesWithFallback(
267
+ 'TimePicker',
268
+ timePickerStylesDefault,
269
+ );
270
+ export const timePickerInputsStyles = getRegisteredComponentStylesWithFallback(
271
+ 'TimePicker_Inputs',
272
+ timePickerInputsStylesDefault,
273
+ );
274
+ export const timePickerInputStyles = getRegisteredComponentStylesWithFallback(
275
+ 'TimePicker_Input',
276
+ timePickerInputStylesDefault,
277
+ );
278
+ export const timePickerClockStyles = getRegisteredComponentStylesWithFallback(
279
+ 'TimePicker_Clock',
280
+ timePickerClockStylesDefault,
281
+ );
282
+ export const timePickerClockHoursStyles = getRegisteredComponentStylesWithFallback(
283
+ 'TimePicker_ClockHours',
284
+ timePickerClockHoursStylesDefault,
285
+ );
286
+ export const timePickerClockMinutesStyles = getRegisteredComponentStylesWithFallback(
287
+ 'TimePicker_ClockMinutes',
288
+ timePickerClockMinutesStylesDefault,
289
+ );
290
+ export const timePickerAmPmSwitcherStyles = getRegisteredComponentStylesWithFallback(
291
+ 'TimePicker_AmPmSwitcher',
292
+ timePickerAmPmSwitcherStylesDefault,
293
+ );
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import TimePickerFieldDefault from './TimePickerField';
3
3
 
4
- registerMoleculesComponents({
5
- TimePickerField: TimePickerFieldDefault,
6
- });
7
-
8
4
  export const TimePickerField = getRegisteredComponentWithFallback(
9
5
  'TimePickerField',
10
6
  TimePickerFieldDefault,
@@ -5,17 +5,16 @@ export declare type MaskItem = string | RegExp | [RegExp];
5
5
  export declare type MaskArray = Array<MaskItem>;
6
6
  export declare type Mask = MaskArray | ((value?: string) => MaskArray);
7
7
 
8
- import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
8
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
9
9
 
10
10
  const timepickerFieldStylesDefault = StyleSheet.create({
11
11
  root: {},
12
12
  });
13
13
 
14
- registerComponentsStyles({
15
- TimePickerField: timepickerFieldStylesDefault,
16
- });
17
-
18
- export const styles = getRegisteredMoleculesComponentStyles('TimePickerField');
14
+ export const styles = getRegisteredComponentStylesWithFallback(
15
+ 'TimePickerField',
16
+ timepickerFieldStylesDefault,
17
+ );
19
18
 
20
19
  export const timeMask24Hour: Mask = (text: string = '') => {
21
20
  const cleanTime = text.replace(/\D+/g, '');