react-native-molecules 0.5.0-beta.0 → 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 (164) hide show
  1. package/README.md +87 -0
  2. package/components/Accordion/AccordionItem.tsx +3 -2
  3. package/components/Accordion/AccordionItemContent.tsx +1 -0
  4. package/components/Accordion/AccordionItemHeader.tsx +6 -5
  5. package/components/Accordion/index.tsx +8 -14
  6. package/components/Accordion/utils.ts +17 -14
  7. package/components/ActivityIndicator/ActivityIndicator.tsx +12 -20
  8. package/components/ActivityIndicator/index.tsx +1 -5
  9. package/components/Appbar/index.tsx +1 -4
  10. package/components/Appbar/utils.ts +33 -21
  11. package/components/Avatar/index.tsx +1 -5
  12. package/components/Avatar/utils.ts +2 -6
  13. package/components/Backdrop/Backdrop.tsx +2 -2
  14. package/components/Backdrop/index.tsx +1 -5
  15. package/components/Backdrop/utils.ts +5 -6
  16. package/components/Badge/index.tsx +1 -5
  17. package/components/Badge/utils.ts +2 -6
  18. package/components/Button/Button.tsx +211 -264
  19. package/components/Button/index.tsx +9 -7
  20. package/components/Button/types.ts +16 -2
  21. package/components/Button/utils.ts +231 -212
  22. package/components/Card/Card.tsx +8 -4
  23. package/components/Card/CardContent.tsx +5 -4
  24. package/components/Card/CardHeader.tsx +5 -3
  25. package/components/Card/CardMedia.tsx +5 -3
  26. package/components/Card/CardTypography.tsx +5 -3
  27. package/components/Card/index.tsx +1 -5
  28. package/components/Card/utils.ts +5 -6
  29. package/components/Checkbox/Checkbox.tsx +1 -0
  30. package/components/Checkbox/CheckboxBase.ios.tsx +1 -0
  31. package/components/Checkbox/CheckboxBase.tsx +1 -0
  32. package/components/Checkbox/index.tsx +1 -5
  33. package/components/Checkbox/utils.ts +6 -6
  34. package/components/Chip/Chip.tsx +40 -52
  35. package/components/Chip/index.tsx +1 -5
  36. package/components/Chip/utils.ts +5 -13
  37. package/components/DatePickerDocked/index.tsx +1 -5
  38. package/components/DatePickerDocked/utils.ts +21 -19
  39. package/components/DatePickerInline/index.tsx +1 -5
  40. package/components/DatePickerInline/utils.ts +41 -28
  41. package/components/DatePickerInput/index.tsx +2 -6
  42. package/components/DatePickerInput/utils.ts +5 -6
  43. package/components/DatePickerModal/DatePickerModalHeader.tsx +1 -1
  44. package/components/DatePickerModal/index.tsx +1 -5
  45. package/components/DatePickerModal/utils.ts +17 -16
  46. package/components/DateTimePicker/index.tsx +1 -5
  47. package/components/DateTimePicker/utils.ts +5 -6
  48. package/components/Dialog/index.tsx +1 -5
  49. package/components/Dialog/utils.ts +22 -16
  50. package/components/Drawer/Collapsible/utils.ts +13 -13
  51. package/components/Drawer/Drawer.tsx +2 -3
  52. package/components/Drawer/DrawerContent.tsx +5 -3
  53. package/components/Drawer/DrawerFooter.tsx +5 -4
  54. package/components/Drawer/DrawerHeader.tsx +5 -4
  55. package/components/Drawer/DrawerItem.tsx +5 -3
  56. package/components/Drawer/DrawerItemGroup.tsx +5 -4
  57. package/components/Drawer/index.tsx +1 -5
  58. package/components/Drawer/utils.ts +7 -7
  59. package/components/ElementGroup/ElementGroup.tsx +16 -14
  60. package/components/ElementGroup/index.tsx +1 -5
  61. package/components/ElementGroup/utils.ts +5 -6
  62. package/components/FAB/index.tsx +1 -5
  63. package/components/FAB/utils.ts +3 -7
  64. package/components/FilePicker/index.tsx +1 -5
  65. package/components/FilePicker/utils.ts +5 -6
  66. package/components/HelperText/index.tsx +1 -5
  67. package/components/HelperText/utils.ts +5 -7
  68. package/components/HorizontalDivider/HorizontalDivider.tsx +5 -3
  69. package/components/HorizontalDivider/index.tsx +1 -5
  70. package/components/Icon/CrossFadeIcon.tsx +3 -5
  71. package/components/Icon/Icon.tsx +3 -14
  72. package/components/Icon/iconFactory.tsx +3 -3
  73. package/components/Icon/index.tsx +2 -6
  74. package/components/Icon/types.ts +17 -6
  75. package/components/IconButton/IconButton.tsx +45 -58
  76. package/components/IconButton/index.tsx +1 -5
  77. package/components/IconButton/utils.ts +15 -26
  78. package/components/If/index.tsx +1 -5
  79. package/components/InputAddon/index.tsx +1 -5
  80. package/components/InputAddon/utils.ts +5 -6
  81. package/components/Link/index.tsx +1 -5
  82. package/components/Link/utils.ts +7 -9
  83. package/components/ListItem/index.tsx +1 -5
  84. package/components/ListItem/utils.ts +13 -11
  85. package/components/LoadingIndicator/LoadingIndicator.tsx +253 -0
  86. package/components/LoadingIndicator/LoadingIndicator.web.tsx +136 -0
  87. package/components/LoadingIndicator/index.tsx +13 -0
  88. package/components/LoadingIndicator/utils.ts +117 -0
  89. package/components/Menu/index.tsx +1 -5
  90. package/components/Menu/utils.ts +6 -8
  91. package/components/Modal/index.tsx +1 -5
  92. package/components/Modal/utils.ts +2 -6
  93. package/components/NavigationRail/NavigationRailHeader.tsx +1 -1
  94. package/components/NavigationRail/NavigationRailItem.tsx +2 -1
  95. package/components/NavigationRail/index.tsx +1 -5
  96. package/components/NavigationRail/utils.ts +21 -17
  97. package/components/NavigationStack/index.tsx +1 -5
  98. package/components/NavigationStack/utils.tsx +7 -1
  99. package/components/Portal/index.tsx +1 -5
  100. package/components/RadioButton/index.ts +5 -10
  101. package/components/RadioButton/utils.ts +9 -8
  102. package/components/Rating/RatingItem.tsx +2 -1
  103. package/components/Rating/index.tsx +1 -5
  104. package/components/Rating/utils.ts +6 -8
  105. package/components/Select/Select.tsx +360 -501
  106. package/components/Select/index.ts +7 -14
  107. package/components/Select/types.ts +2 -4
  108. package/components/Select/utils.ts +215 -0
  109. package/components/Slot/Slot.tsx +244 -0
  110. package/components/Slot/compose-refs.tsx +60 -0
  111. package/components/Slot/index.tsx +8 -0
  112. package/components/StateLayer/index.tsx +1 -5
  113. package/components/StateLayer/utils.ts +5 -6
  114. package/components/Surface/Surface.android.tsx +34 -8
  115. package/components/Surface/Surface.ios.tsx +36 -29
  116. package/components/Surface/Surface.tsx +31 -4
  117. package/components/Surface/index.tsx +1 -5
  118. package/components/Surface/utils.ts +49 -36
  119. package/components/Switch/Switch.tsx +8 -2
  120. package/components/Switch/index.tsx +1 -5
  121. package/components/Switch/utils.ts +2 -6
  122. package/components/Tabs/Tabs.tsx +14 -13
  123. package/components/Tabs/index.tsx +1 -5
  124. package/components/Tabs/utils.ts +10 -10
  125. package/components/Text/Text.tsx +2 -8
  126. package/components/TextInput/TextInput.tsx +5 -4
  127. package/components/TextInput/index.tsx +1 -5
  128. package/components/TextInput/utils.ts +8 -15
  129. package/components/TextInputWithMask/index.tsx +1 -5
  130. package/components/TimePicker/AmPmSwitcher.tsx +1 -1
  131. package/components/TimePicker/index.tsx +1 -5
  132. package/components/TimePicker/utils.ts +29 -21
  133. package/components/TimePickerField/index.tsx +1 -5
  134. package/components/TimePickerField/utils.ts +5 -6
  135. package/components/TimePickerModal/TimePickerModal.tsx +6 -2
  136. package/components/TimePickerModal/index.tsx +1 -5
  137. package/components/TimePickerModal/utils.ts +5 -6
  138. package/components/Tooltip/TooltipTrigger.tsx +25 -16
  139. package/components/Tooltip/index.tsx +5 -9
  140. package/components/Tooltip/utils.ts +5 -6
  141. package/components/TouchableRipple/TouchableRipple.native.tsx +49 -13
  142. package/components/TouchableRipple/TouchableRipple.tsx +136 -46
  143. package/components/TouchableRipple/index.tsx +1 -5
  144. package/components/TouchableRipple/utils.ts +5 -6
  145. package/components/VerticalDivider/VerticalDivider.tsx +9 -8
  146. package/components/VerticalDivider/index.tsx +1 -5
  147. package/core/componentsRegistry.ts +31 -19
  148. package/hocs/withPortal.tsx +1 -1
  149. package/hooks/index.tsx +0 -1
  150. package/hooks/useControlledValue.tsx +20 -4
  151. package/hooks/useSubcomponents.tsx +56 -22
  152. package/hooks/useWhatHasUpdated.tsx +48 -0
  153. package/package.json +10 -13
  154. package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +5 -2
  155. package/shortcuts-manager/ShortcutsManager/utils.tsx +3 -2
  156. package/shortcuts-manager/useShortcut/index.tsx +1 -1
  157. package/shortcuts-manager/useShortcut/useShortcut.tsx +1 -1
  158. package/styles/shadow.ts +2 -1
  159. package/styles/themes/LightTheme.tsx +1 -1
  160. package/utils/extractPropertiesFromStyles.ts +25 -0
  161. package/utils/lodash.ts +77 -6
  162. package/utils/repository.ts +2 -52
  163. package/utils/tokenStylesParser.ts +3 -1
  164. package/hooks/useBreakpoints.tsx +0 -7
@@ -1,19 +1,11 @@
1
- import EventEmitter, {
2
- type ConstructorOptions,
3
- type event as Event,
4
- type eventNS,
5
- } from 'eventemitter2';
6
-
7
- import { debounce } from './lodash';
8
-
9
- interface RepositoryConstructor<T> extends ConstructorOptions {
1
+ interface RepositoryConstructor<T> {
10
2
  onRegister?: (arg: T, name: string, registery: Record<string, T>) => T;
11
3
  name?: string;
12
4
  }
13
5
 
14
6
  let id = Date.now();
15
7
 
16
- export class Repository<T> extends EventEmitter {
8
+ export class Repository<T> {
17
9
  private registry: Record<string, T> = {};
18
10
  readonly #name!: string;
19
11
 
@@ -30,9 +22,7 @@ export class Repository<T> extends EventEmitter {
30
22
  constructor({
31
23
  onRegister = arg => arg,
32
24
  name = Repository.uniqueId,
33
- ...options
34
25
  }: RepositoryConstructor<T> = {}) {
35
- super(options);
36
26
  this.#onRegister = onRegister;
37
27
  this.#name = name;
38
28
  }
@@ -41,11 +31,6 @@ export class Repository<T> extends EventEmitter {
41
31
  return !!this.registry[itemName];
42
32
  };
43
33
 
44
- emit(event: eventNS | Event, ...values: any[]) {
45
- event = typeof event === 'string' ? `${this.#name}::event` : event;
46
- return super.emit(event, ...values);
47
- }
48
-
49
34
  /**
50
35
  * Register a item with the src.
51
36
  */
@@ -57,8 +42,6 @@ export class Repository<T> extends EventEmitter {
57
42
  ...this.registry,
58
43
  [itemName]: updatedItem,
59
44
  };
60
-
61
- this.emit('item_registered', itemName);
62
45
  };
63
46
 
64
47
  /**
@@ -67,37 +50,4 @@ export class Repository<T> extends EventEmitter {
67
50
  getAll = () => {
68
51
  return this.registry;
69
52
  };
70
-
71
- /**
72
- * Register a listener to the module registry.
73
- * Return value returns a function that removes the listener.
74
- */
75
- listen = (
76
- callback: (events: string[]) => void,
77
- { throttle = 100 }: { throttle?: number } = {},
78
- ) => {
79
- let cached: string[] = [];
80
-
81
- const wrappedCallback = () => {
82
- callback(cached);
83
- cached = [];
84
- };
85
-
86
- const debouncedCallback = !throttle
87
- ? wrappedCallback
88
- : debounce(wrappedCallback, Math.abs(throttle), {
89
- trailing: true,
90
- leading: false,
91
- });
92
-
93
- const handledCallback = (itemName: string) => {
94
- cached.push(itemName);
95
- debouncedCallback();
96
- };
97
-
98
- this.on('item_registered', handledCallback);
99
- return () => {
100
- this.off('item_registered', handledCallback);
101
- };
102
- };
103
53
  }
@@ -2,6 +2,8 @@ import { StyleSheet } from 'react-native-unistyles';
2
2
 
3
3
  export const tokenStylesParser = StyleSheet.create(theme => ({
4
4
  getColor: (color: string | undefined, propertyName: string = 'color') => ({
5
- ...(color ? { [propertyName]: theme.colors[color] ?? color } : {}),
5
+ ...(color
6
+ ? { [propertyName]: theme.colors[color as keyof typeof theme.colors] ?? color }
7
+ : {}),
6
8
  }),
7
9
  }));
@@ -1,7 +0,0 @@
1
- import { useTheme } from './useTheme';
2
-
3
- const useBreakpoints = () => {
4
- return useTheme().grid.breakpoints;
5
- };
6
-
7
- export default useBreakpoints;