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
@@ -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
  export const drawerCollapsibleStylesDefault = StyleSheet.create({
6
6
  root: {},
@@ -31,19 +31,19 @@ export const drawerCollapsibleItemContentStylesDefault = StyleSheet.create({
31
31
  root: {},
32
32
  });
33
33
 
34
- registerComponentsStyles({
35
- Drawer_Collapsible: drawerCollapsibleStylesDefault,
36
- Drawer_CollapsibleItem: drawerCollapsibleItemStylesDefault,
37
- Drawer_CollapsibleItem_Header: drawerCollapsibleItemHeaderStylesDefault,
38
- Drawer_CollapsibleItem_Content: drawerCollapsibleItemContentStylesDefault,
39
- });
40
-
41
- export const drawerCollapsibleStyles = getRegisteredMoleculesComponentStyles('Drawer_Collapsible');
42
- export const drawerCollapsibleItemStyles =
43
- getRegisteredMoleculesComponentStyles('Drawer_CollapsibleItem');
44
- export const drawerCollapsibleItemHeaderStyles = getRegisteredMoleculesComponentStyles(
34
+ export const drawerCollapsibleStyles = getRegisteredComponentStylesWithFallback(
35
+ 'Drawer_Collapsible',
36
+ drawerCollapsibleStylesDefault,
37
+ );
38
+ export const drawerCollapsibleItemStyles = getRegisteredComponentStylesWithFallback(
39
+ 'Drawer_CollapsibleItem',
40
+ drawerCollapsibleItemStylesDefault,
41
+ );
42
+ export const drawerCollapsibleItemHeaderStyles = getRegisteredComponentStylesWithFallback(
45
43
  'Drawer_CollapsibleItem_Header',
44
+ drawerCollapsibleItemHeaderStylesDefault,
46
45
  );
47
- export const drawerCollapsibleItemContentStyles = getRegisteredMoleculesComponentStyles(
46
+ export const drawerCollapsibleItemContentStyles = getRegisteredComponentStylesWithFallback(
48
47
  'Drawer_CollapsibleItem_Content',
48
+ drawerCollapsibleItemContentStylesDefault,
49
49
  );
@@ -2,7 +2,7 @@ import { memo, type ReactElement } from 'react';
2
2
  import { View, type ViewProps } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
5
- import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
5
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
6
6
  import { useSubcomponents } from '../../hooks';
7
7
 
8
8
  export type Props = Omit<ViewProps, 'children'> & {
@@ -37,7 +37,6 @@ const drawerStylesDefault = StyleSheet.create(theme => ({
37
37
  },
38
38
  }));
39
39
 
40
- registerComponentStyles('Drawer', drawerStylesDefault);
41
- export const drawerStyles = getRegisteredMoleculesComponentStyles('Drawer');
40
+ export const drawerStyles = getRegisteredComponentStylesWithFallback('Drawer', drawerStylesDefault);
42
41
 
43
42
  export default memo(Drawer);
@@ -2,7 +2,7 @@ import { type ComponentType, memo } from 'react';
2
2
  import { ScrollView, type ScrollViewProps } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
5
- import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
5
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
6
6
 
7
7
  export type Props = ScrollViewProps & {
8
8
  /**
@@ -27,8 +27,10 @@ const drawerContentStylesDefault = StyleSheet.create(theme => ({
27
27
  flex: 1,
28
28
  },
29
29
  }));
30
- registerComponentStyles('Drawer_Content', drawerContentStylesDefault);
31
- export const drawerContentStyles = getRegisteredMoleculesComponentStyles('Drawer_Content');
30
+ export const drawerContentStyles = getRegisteredComponentStylesWithFallback(
31
+ 'Drawer_Content',
32
+ drawerContentStylesDefault,
33
+ );
32
34
 
33
35
  DrawerContent.displayName = 'Drawer_Content';
34
36
 
@@ -2,7 +2,7 @@ import { memo } from 'react';
2
2
  import { View, type ViewProps } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
5
- import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
5
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
6
6
 
7
7
  export type Props = ViewProps & {};
8
8
 
@@ -20,8 +20,9 @@ const drawerFooterStylesDefault = StyleSheet.create({
20
20
  root: {},
21
21
  });
22
22
 
23
- registerComponentStyles('Drawer_Footer', drawerFooterStylesDefault);
24
-
25
- export const drawerFooterStyles = getRegisteredMoleculesComponentStyles('Drawer_Footer');
23
+ export const drawerFooterStyles = getRegisteredComponentStylesWithFallback(
24
+ 'Drawer_Footer',
25
+ drawerFooterStylesDefault,
26
+ );
26
27
 
27
28
  export default DrawerFooter;
@@ -2,7 +2,7 @@ import { memo } from 'react';
2
2
  import { View, type ViewProps } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
5
- import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
5
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
6
6
 
7
7
  export type Props = ViewProps & {};
8
8
 
@@ -20,8 +20,9 @@ const drawerHeaderStylesDefault = StyleSheet.create({
20
20
  root: {},
21
21
  });
22
22
 
23
- registerComponentStyles('Drawer_Header', drawerHeaderStylesDefault);
24
-
25
- export const drawerHeaderStyles = getRegisteredMoleculesComponentStyles('Drawer_Header');
23
+ export const drawerHeaderStyles = getRegisteredComponentStylesWithFallback(
24
+ 'Drawer_Header',
25
+ drawerHeaderStylesDefault,
26
+ );
26
27
 
27
28
  export default DrawerHeader;
@@ -2,7 +2,7 @@ import { forwardRef, memo, type ReactNode, useMemo } from 'react';
2
2
  import { type TextProps, type TextStyle, View, type ViewStyle } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
5
- import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
5
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
6
6
  import { useActionState } from '../../hooks';
7
7
  import type { WithElements } from '../../types';
8
8
  import { resolveStateVariant } from '../../utils';
@@ -200,7 +200,9 @@ const drawerItemStylesDefault = StyleSheet.create(theme => ({
200
200
  },
201
201
  }));
202
202
 
203
- registerComponentStyles('Drawer_Item', drawerItemStylesDefault);
204
- export const drawerItemStyles = getRegisteredMoleculesComponentStyles('Drawer_Item');
203
+ export const drawerItemStyles = getRegisteredComponentStylesWithFallback(
204
+ 'Drawer_Item',
205
+ drawerItemStylesDefault,
206
+ );
205
207
 
206
208
  export default memo(forwardRef(DrawerItem));
@@ -2,7 +2,7 @@ import { memo, type ReactNode, useMemo } from 'react';
2
2
  import { type TextProps, View, type ViewProps } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
5
- import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
5
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
6
6
  import { HorizontalDivider, type HorizontalDividerProps } from '../HorizontalDivider';
7
7
  import { Text } from '../Text';
8
8
 
@@ -73,9 +73,10 @@ const drawerItemGroupStylesDefault = StyleSheet.create(theme => ({
73
73
  },
74
74
  }));
75
75
 
76
- registerComponentStyles('Drawer_ItemGroup', drawerItemGroupStylesDefault);
77
-
78
- export const drawerItemGroupStyles = getRegisteredMoleculesComponentStyles('Drawer_ItemGroup');
76
+ export const drawerItemGroupStyles = getRegisteredComponentStylesWithFallback(
77
+ 'Drawer_ItemGroup',
78
+ drawerItemGroupStylesDefault,
79
+ );
79
80
 
80
81
  DrawerItemGroup.displayName = 'Drawer_ItemGroup';
81
82
 
@@ -1,4 +1,4 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import { DrawerCollapsible, DrawerCollapsibleItem } from './Collapsible';
3
3
  import DrawerComponent from './Drawer';
4
4
  import DrawerContent from './DrawerContent';
@@ -17,10 +17,6 @@ const DrawerDefault = Object.assign(DrawerComponent, {
17
17
  CollapsibleItem: DrawerCollapsibleItem,
18
18
  });
19
19
 
20
- registerMoleculesComponents({
21
- Drawer: DrawerDefault,
22
- });
23
-
24
20
  export const Drawer = getRegisteredComponentWithFallback('Drawer', DrawerDefault);
25
21
 
26
22
  export {
@@ -1,8 +1,8 @@
1
- import { registerComponentsStyles } from '../../core';
1
+ // import { registerComponentsStyles } from '../../core';
2
2
 
3
- registerComponentsStyles({
4
- // Drawer_Collapsible: drawerCollapsibleStyles,
5
- // Drawer_CollapsibleItem: drawerCollapsibleItemStyles,
6
- // Drawer_CollapsibleItem_Header: drawerCollapsibleItemHeaderStyles,
7
- // Drawer_CollapsibleItem_Content: drawerCollapsibleItemContentStyles,
8
- });
3
+ // registerComponentsStyles({
4
+ // Drawer_Collapsible: drawerCollapsibleStyles,
5
+ // Drawer_CollapsibleItem: drawerCollapsibleItemStyles,
6
+ // Drawer_CollapsibleItem_Header: drawerCollapsibleItemHeaderStyles,
7
+ // Drawer_CollapsibleItem_Content: drawerCollapsibleItemContentStyles,
8
+ // });
@@ -1,6 +1,7 @@
1
1
  import { Children, cloneElement, forwardRef, memo, type ReactElement, useMemo } from 'react';
2
2
  import { View, type ViewProps, type ViewStyle } from 'react-native';
3
3
 
4
+ import { extractPropertiesFromStyles } from '../../utils/extractPropertiesFromStyles';
4
5
  import { isNil } from '../../utils/lodash';
5
6
  import { elementGroupStyles } from './utils';
6
7
 
@@ -44,24 +45,25 @@ export const ElementGroup = (
44
45
  borderTopRightRadius,
45
46
  borderBottomLeftRadius,
46
47
  borderBottomRightRadius,
47
- ...restStyle
48
- } = elementGroupStyles.root as any;
49
- const {
50
- borderTopLeftRadius: _borderTopLeftRadius,
51
- borderTopRightRadius: _borderTopRightRadius,
52
- borderBottomLeftRadius: _borderBottomLeftRadius,
53
- borderBottomRightRadius: _borderBottomRightRadius,
54
- ..._restStyle
55
- } = style ?? {};
48
+ } = extractPropertiesFromStyles(
49
+ [elementGroupStyles.root, style],
50
+ [
51
+ 'borderRadius',
52
+ 'borderTopLeftRadius',
53
+ 'borderTopRightRadius',
54
+ 'borderBottomLeftRadius',
55
+ 'borderBottomRightRadius',
56
+ ],
57
+ );
56
58
 
57
59
  return {
58
- containerStyle: [restStyle, _restStyle],
60
+ containerStyle: [elementGroupStyles.root, style],
59
61
  borderRadius: borderRadiusProp || _borderRadius,
60
62
  borderRadiuses: {
61
- borderTopLeftRadius: borderTopLeftRadius || _borderTopLeftRadius,
62
- borderTopRightRadius: borderTopRightRadius || _borderTopRightRadius,
63
- borderBottomLeftRadius: borderBottomLeftRadius || _borderBottomLeftRadius,
64
- borderBottomRightRadius: borderBottomRightRadius || _borderBottomRightRadius,
63
+ borderTopLeftRadius: borderTopLeftRadius,
64
+ borderTopRightRadius: borderTopRightRadius,
65
+ borderBottomLeftRadius: borderBottomLeftRadius,
66
+ borderBottomRightRadius: borderBottomRightRadius,
65
67
  },
66
68
  };
67
69
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import ElementGroupDefault from './ElementGroup';
3
3
 
4
- registerMoleculesComponents({
5
- ElementGroup: ElementGroupDefault,
6
- });
7
-
8
4
  export const ElementGroup = getRegisteredComponentWithFallback('ElementGroup', ElementGroupDefault);
9
5
 
10
6
  export type { Props as ElementGroupProps } from './ElementGroup';
@@ -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 elementGroupStylesDefault = StyleSheet.create(theme => ({
6
6
  root: {
@@ -18,8 +18,7 @@ const elementGroupStylesDefault = StyleSheet.create(theme => ({
18
18
  },
19
19
  }));
20
20
 
21
- registerComponentsStyles({
22
- ElementGroup: elementGroupStylesDefault,
23
- });
24
-
25
- export const elementGroupStyles = getRegisteredMoleculesComponentStyles('ElementGroup');
21
+ export const elementGroupStyles = getRegisteredComponentStylesWithFallback(
22
+ 'ElementGroup',
23
+ elementGroupStylesDefault,
24
+ );
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import FABDefault from './FAB';
3
3
 
4
- registerMoleculesComponents({
5
- FAB: FABDefault,
6
- });
7
-
8
4
  export const FAB = getRegisteredComponentWithFallback('FAB', FABDefault);
9
5
 
10
6
  export type { Props as FABProps } from './FAB';
@@ -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
  export const iconSizeMap = {
6
6
  xs: 18,
@@ -212,10 +212,6 @@ const fabStylesDefault = StyleSheet.create(theme => ({
212
212
  },
213
213
  }));
214
214
 
215
- registerComponentsStyles({
216
- FAB: fabStylesDefault,
217
- });
218
-
219
- export const fabStyles = getRegisteredMoleculesComponentStyles('FAB');
215
+ export const fabStyles = getRegisteredComponentStylesWithFallback('FAB', fabStylesDefault);
220
216
 
221
217
  export type States = 'hovered' | 'disabled';
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import FilePickerDefault from './FilePicker';
3
3
 
4
- registerMoleculesComponents({
5
- FilePicker: FilePickerDefault,
6
- });
7
-
8
4
  export const FilePicker = getRegisteredComponentWithFallback('FilePicker', FilePickerDefault);
9
5
 
10
6
  export type { Props as FilePickerProps } from './FilePicker';
@@ -1,13 +1,12 @@
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 filePickerStylesDefault = StyleSheet.create({
6
6
  root: {},
7
7
  });
8
8
 
9
- registerComponentsStyles({
10
- FilePicker: filePickerStylesDefault,
11
- });
12
-
13
- export const defaultStyles = getRegisteredMoleculesComponentStyles('FilePicker');
9
+ export const defaultStyles = getRegisteredComponentStylesWithFallback(
10
+ 'FilePicker',
11
+ filePickerStylesDefault,
12
+ );
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import HelperTextDefault from './HelperText';
3
3
 
4
- registerMoleculesComponents({
5
- HelperText: HelperTextDefault,
6
- });
7
-
8
4
  export const HelperText = getRegisteredComponentWithFallback('HelperText', HelperTextDefault);
9
5
 
10
6
  export { type Props as HelperTextProps } from './HelperText';
@@ -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
  export const helperTextStylesDefault = StyleSheet.create(theme => ({
6
6
  root: {
@@ -21,9 +21,7 @@ export const helperTextStylesDefault = StyleSheet.create(theme => ({
21
21
  },
22
22
  }));
23
23
 
24
- registerComponentsStyles({
25
- HelperText: helperTextStylesDefault,
26
- });
27
-
28
- export const styles =
29
- getRegisteredMoleculesComponentStyles('HelperText') || helperTextStylesDefault;
24
+ export const styles = getRegisteredComponentStylesWithFallback(
25
+ 'HelperText',
26
+ helperTextStylesDefault,
27
+ );
@@ -2,7 +2,7 @@ import { memo } from 'react';
2
2
  import { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
5
- import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
5
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
6
6
 
7
7
  export type Props = Omit<ViewProps, 'children'> & {
8
8
  /**
@@ -95,7 +95,9 @@ export const horizontalDividerStylesDefault = StyleSheet.create(theme => ({
95
95
  },
96
96
  }));
97
97
 
98
- registerComponentStyles('HorizontalDivider', horizontalDividerStylesDefault);
99
- export const horizontalDividerStyles = getRegisteredMoleculesComponentStyles('HorizontalDivider');
98
+ export const horizontalDividerStyles = getRegisteredComponentStylesWithFallback(
99
+ 'HorizontalDivider',
100
+ horizontalDividerStylesDefault,
101
+ );
100
102
 
101
103
  export default memo(HorizontalDivider);
@@ -1,10 +1,6 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import HorizontalDividerDefault from './HorizontalDivider';
3
3
 
4
- registerMoleculesComponents({
5
- HorizontalDivider: HorizontalDividerDefault,
6
- });
7
-
8
4
  export const HorizontalDivider = getRegisteredComponentWithFallback(
9
5
  'HorizontalDivider',
10
6
  HorizontalDividerDefault,
@@ -1,14 +1,12 @@
1
1
  import { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Animated, StyleSheet, View } from 'react-native';
3
3
 
4
- import Icon, { styles as iconStyles } from './Icon';
4
+ import Icon from './Icon';
5
5
  import type { IconProps } from './types';
6
6
 
7
7
  type Props = IconProps;
8
8
 
9
9
  const CrossFadeIcon = ({ color, size, name, style, ...rest }: Omit<Props, 'ref'>) => {
10
- // const { animationScale: scale } = useComponentStyles('Icon', style);
11
- const { animationScale: scale } = iconStyles.root;
12
10
  const [currentIcon, setCurrentIcon] = useState<string>(name);
13
11
  const [previousIcon, setPreviousIcon] = useState<string | null>(null);
14
12
  const { current: fade } = useRef<Animated.Value>(new Animated.Value(1));
@@ -25,12 +23,12 @@ const CrossFadeIcon = ({ color, size, name, style, ...rest }: Omit<Props, 'ref'>
25
23
  fade.setValue(1);
26
24
 
27
25
  Animated.timing(fade, {
28
- duration: scale * 200,
26
+ duration: 200,
29
27
  toValue: 0,
30
28
  useNativeDriver: true,
31
29
  }).start();
32
30
  }
33
- }, [currentIcon, previousIcon, fade, scale]);
31
+ }, [currentIcon, previousIcon, fade]);
34
32
 
35
33
  const opacityPrev = fade;
36
34
  const opacityNext = previousIcon
@@ -1,7 +1,7 @@
1
1
  import { forwardRef, memo, useMemo } from 'react';
2
2
  import { StyleSheet } from 'react-native-unistyles';
3
3
 
4
- import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
4
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
5
5
  import { tokenStylesParser } from '../../utils/tokenStylesParser';
6
6
  import iconFactory from './iconFactory';
7
7
  import type { IconProps } from './types';
@@ -25,8 +25,6 @@ export const iconStylesDefault = StyleSheet.create(theme => ({
25
25
  },
26
26
  }));
27
27
 
28
- registerComponentStyles('Icon', iconStylesDefault);
29
-
30
- export const styles = getRegisteredMoleculesComponentStyles('Icon');
28
+ export const styles = getRegisteredComponentStylesWithFallback('Icon', iconStylesDefault);
31
29
 
32
30
  export default memo(forwardRef(Icon));
@@ -1,6 +1,6 @@
1
1
  // import { textFactory } from '../Text/textFactory';
2
2
  import { memoize } from '../../utils/lodash';
3
- import { IconPacks, type IconType } from './types';
3
+ import type { IconType } from './types';
4
4
 
5
5
  const customIcons: any = {};
6
6
 
@@ -10,9 +10,9 @@ export const registerCustomIconType = (id: string, customIcon: any) => {
10
10
 
11
11
  export default memoize((type: IconType) => {
12
12
  switch (type) {
13
- case IconPacks.MaterialCommunity:
13
+ case 'material-community':
14
14
  return require('@react-native-vector-icons/material-design-icons').default;
15
- case IconPacks.Feather:
15
+ case 'feather':
16
16
  return require('@react-native-vector-icons/feather').default;
17
17
  default:
18
18
  if (Object.prototype.hasOwnProperty.call(customIcons, type)) {
@@ -1,11 +1,7 @@
1
- import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
1
+ import { getRegisteredComponentWithFallback } from '../../core';
2
2
  import IconDefault from './Icon';
3
3
 
4
- registerMoleculesComponents({
5
- Icon: IconDefault,
6
- });
7
-
8
4
  export const Icon = getRegisteredComponentWithFallback('Icon', IconDefault);
9
5
 
10
6
  export { registerCustomIconType } from './iconFactory';
11
- export type { IconPacks, IconProps, IconType } from './types';
7
+ export type { CustomIconTypes, IconProps, IconType } from './types';
@@ -1,10 +1,5 @@
1
1
  import type { ColorValue, TextProps } from 'react-native';
2
2
 
3
- export enum IconPacks {
4
- MaterialCommunity = 'material-community',
5
- Feather = 'feather',
6
- }
7
-
8
3
  export interface VectorIconProps extends TextProps {
9
4
  /**
10
5
  * Size of the icon, can also be passed as fontSize in the style object.
@@ -28,7 +23,23 @@ export interface VectorIconProps extends TextProps {
28
23
  color?: ColorValue | number | undefined;
29
24
  }
30
25
 
31
- export type IconType = `${IconPacks}`; // in TS 4.1+, we can do this to make enum values as a union type
26
+ /**
27
+ * Interface for registering custom icon types.
28
+ * Users can extend this interface via declaration merging to add their own icon types.
29
+ *
30
+ * @example
31
+ * // In your app's type declarations (e.g., global.d.ts or a dedicated types file)
32
+ * declare module 'react-native-molecules' {
33
+ * interface CustomIconTypes {
34
+ * 'my-custom-icons': true;
35
+ * 'another-icon-set': true;
36
+ * }
37
+ * }
38
+ */
39
+
40
+ export interface CustomIconTypes {}
41
+
42
+ export type IconType = 'material-community' | 'feather' | keyof CustomIconTypes;
32
43
 
33
44
  export type IconProps = VectorIconProps & {
34
45
  type?: IconType;