react-native-mantine 0.5.0 → 0.6.0

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 (248) hide show
  1. package/README.md +0 -357
  2. package/lib/commonjs/components/Button/Button.styles.js +4 -4
  3. package/lib/commonjs/components/Button/Button.styles.js.map +1 -1
  4. package/lib/commonjs/components/Button/index.js +15 -14
  5. package/lib/commonjs/components/Button/index.js.map +1 -1
  6. package/lib/commonjs/components/Chip/index.js.map +1 -1
  7. package/lib/commonjs/components/CloseButton/index.js +5 -30
  8. package/lib/commonjs/components/CloseButton/index.js.map +1 -1
  9. package/lib/commonjs/components/Collapse/index.js +10 -2
  10. package/lib/commonjs/components/Collapse/index.js.map +1 -1
  11. package/lib/commonjs/components/Dialog/index.js +51 -8
  12. package/lib/commonjs/components/Dialog/index.js.map +1 -1
  13. package/lib/commonjs/components/Drawer/index.js +4 -13
  14. package/lib/commonjs/components/Drawer/index.js.map +1 -1
  15. package/lib/commonjs/components/Icon/index.js +53 -0
  16. package/lib/commonjs/components/Icon/index.js.map +1 -0
  17. package/lib/commonjs/components/List/index.js.map +1 -1
  18. package/lib/commonjs/components/Menu/index.js +11 -10
  19. package/lib/commonjs/components/Menu/index.js.map +1 -1
  20. package/lib/commonjs/components/Modal/index.js +10 -16
  21. package/lib/commonjs/components/Modal/index.js.map +1 -1
  22. package/lib/commonjs/components/Notification/index.js +12 -5
  23. package/lib/commonjs/components/Notification/index.js.map +1 -1
  24. package/lib/commonjs/components/NumberInput/index.js +2 -1
  25. package/lib/commonjs/components/NumberInput/index.js.map +1 -1
  26. package/lib/commonjs/components/PasswordInput/index.js +5 -6
  27. package/lib/commonjs/components/PasswordInput/index.js.map +1 -1
  28. package/lib/commonjs/components/PinInput/index.js +7 -2
  29. package/lib/commonjs/components/PinInput/index.js.map +1 -1
  30. package/lib/commonjs/components/Popover/index.js +8 -7
  31. package/lib/commonjs/components/Popover/index.js.map +1 -1
  32. package/lib/commonjs/components/RingProgress/index.js +49 -7
  33. package/lib/commonjs/components/RingProgress/index.js.map +1 -1
  34. package/lib/commonjs/components/SegmentedControl/index.js +7 -4
  35. package/lib/commonjs/components/SegmentedControl/index.js.map +1 -1
  36. package/lib/commonjs/components/Slider/index.js +28 -3
  37. package/lib/commonjs/components/Slider/index.js.map +1 -1
  38. package/lib/commonjs/components/Stepper/index.js.map +1 -1
  39. package/lib/commonjs/components/Table/index.js +22 -20
  40. package/lib/commonjs/components/Table/index.js.map +1 -1
  41. package/lib/commonjs/components/TextInput/index.js +2 -2
  42. package/lib/commonjs/components/TextInput/index.js.map +1 -1
  43. package/lib/commonjs/components/Timeline/index.js +12 -5
  44. package/lib/commonjs/components/Timeline/index.js.map +1 -1
  45. package/lib/commonjs/components/Tooltip/index.js +12 -11
  46. package/lib/commonjs/components/Tooltip/index.js.map +1 -1
  47. package/lib/commonjs/components/TransferList/index.js +3 -8
  48. package/lib/commonjs/components/TransferList/index.js.map +1 -1
  49. package/lib/commonjs/components/Transition/index.js +4 -0
  50. package/lib/commonjs/components/Transition/index.js.map +1 -1
  51. package/lib/commonjs/components/UnstyledButton/UnstyledButton.js +4 -0
  52. package/lib/commonjs/components/UnstyledButton/UnstyledButton.js.map +1 -1
  53. package/lib/commonjs/components/index.js +22 -22
  54. package/lib/commonjs/components/index.js.map +1 -1
  55. package/lib/commonjs/theme/functions/attach-functions.js +3 -0
  56. package/lib/commonjs/theme/functions/attach-functions.js.map +1 -1
  57. package/lib/commonjs/theme/functions/fns/helpers.js +12 -1
  58. package/lib/commonjs/theme/functions/fns/helpers.js.map +1 -1
  59. package/lib/commonjs/theme/functions/fns/index.js +4 -0
  60. package/lib/commonjs/theme/functions/fns/index.js.map +1 -1
  61. package/lib/commonjs/theme/functions/fns/rgba.js +50 -0
  62. package/lib/commonjs/theme/functions/fns/rgba.js.map +1 -0
  63. package/lib/commonjs/theme/functions/fns/size.js +19 -0
  64. package/lib/commonjs/theme/functions/fns/size.js.map +1 -0
  65. package/lib/module/components/Button/Button.styles.js +4 -4
  66. package/lib/module/components/Button/Button.styles.js.map +1 -1
  67. package/lib/module/components/Button/index.js +15 -14
  68. package/lib/module/components/Button/index.js.map +1 -1
  69. package/lib/module/components/Chip/index.js.map +1 -1
  70. package/lib/module/components/CloseButton/index.js +6 -31
  71. package/lib/module/components/CloseButton/index.js.map +1 -1
  72. package/lib/module/components/Collapse/index.js +10 -2
  73. package/lib/module/components/Collapse/index.js.map +1 -1
  74. package/lib/module/components/Dialog/index.js +52 -9
  75. package/lib/module/components/Dialog/index.js.map +1 -1
  76. package/lib/module/components/Drawer/index.js +4 -13
  77. package/lib/module/components/Drawer/index.js.map +1 -1
  78. package/lib/module/components/Icon/index.js +48 -0
  79. package/lib/module/components/Icon/index.js.map +1 -0
  80. package/lib/module/components/List/index.js.map +1 -1
  81. package/lib/module/components/Menu/index.js +9 -8
  82. package/lib/module/components/Menu/index.js.map +1 -1
  83. package/lib/module/components/Modal/index.js +10 -16
  84. package/lib/module/components/Modal/index.js.map +1 -1
  85. package/lib/module/components/Notification/index.js +12 -5
  86. package/lib/module/components/Notification/index.js.map +1 -1
  87. package/lib/module/components/NumberInput/index.js +2 -1
  88. package/lib/module/components/NumberInput/index.js.map +1 -1
  89. package/lib/module/components/PasswordInput/index.js +5 -6
  90. package/lib/module/components/PasswordInput/index.js.map +1 -1
  91. package/lib/module/components/PinInput/index.js +7 -2
  92. package/lib/module/components/PinInput/index.js.map +1 -1
  93. package/lib/module/components/Popover/index.js +9 -8
  94. package/lib/module/components/Popover/index.js.map +1 -1
  95. package/lib/module/components/RingProgress/index.js +51 -9
  96. package/lib/module/components/RingProgress/index.js.map +1 -1
  97. package/lib/module/components/SegmentedControl/index.js +7 -4
  98. package/lib/module/components/SegmentedControl/index.js.map +1 -1
  99. package/lib/module/components/Slider/index.js +28 -3
  100. package/lib/module/components/Slider/index.js.map +1 -1
  101. package/lib/module/components/Stepper/index.js.map +1 -1
  102. package/lib/module/components/Table/index.js +22 -19
  103. package/lib/module/components/Table/index.js.map +1 -1
  104. package/lib/module/components/TextInput/index.js +2 -2
  105. package/lib/module/components/TextInput/index.js.map +1 -1
  106. package/lib/module/components/Timeline/index.js +12 -5
  107. package/lib/module/components/Timeline/index.js.map +1 -1
  108. package/lib/module/components/Tooltip/index.js +11 -10
  109. package/lib/module/components/Tooltip/index.js.map +1 -1
  110. package/lib/module/components/TransferList/index.js +4 -9
  111. package/lib/module/components/TransferList/index.js.map +1 -1
  112. package/lib/module/components/Transition/index.js +5 -1
  113. package/lib/module/components/Transition/index.js.map +1 -1
  114. package/lib/module/components/UnstyledButton/UnstyledButton.js +4 -0
  115. package/lib/module/components/UnstyledButton/UnstyledButton.js.map +1 -1
  116. package/lib/module/components/index.js +1 -1
  117. package/lib/module/components/index.js.map +1 -1
  118. package/lib/module/theme/functions/attach-functions.js +3 -0
  119. package/lib/module/theme/functions/attach-functions.js.map +1 -1
  120. package/lib/module/theme/functions/fns/helpers.js +10 -0
  121. package/lib/module/theme/functions/fns/helpers.js.map +1 -1
  122. package/lib/module/theme/functions/fns/index.js +4 -0
  123. package/lib/module/theme/functions/fns/index.js.map +1 -1
  124. package/lib/module/theme/functions/fns/rgba.js +46 -0
  125. package/lib/module/theme/functions/fns/rgba.js.map +1 -0
  126. package/lib/module/theme/functions/fns/size.js +15 -0
  127. package/lib/module/theme/functions/fns/size.js.map +1 -0
  128. package/lib/typescript/commonjs/src/components/Button/index.d.ts +1 -0
  129. package/lib/typescript/commonjs/src/components/Button/index.d.ts.map +1 -1
  130. package/lib/typescript/commonjs/src/components/CloseButton/index.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/src/components/Collapse/index.d.ts.map +1 -1
  132. package/lib/typescript/commonjs/src/components/Dialog/index.d.ts +2 -0
  133. package/lib/typescript/commonjs/src/components/Dialog/index.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/src/components/Drawer/index.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/src/components/Icon/index.d.ts +26 -0
  136. package/lib/typescript/commonjs/src/components/Icon/index.d.ts.map +1 -0
  137. package/lib/typescript/commonjs/src/components/Menu/index.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/src/components/Modal/index.d.ts.map +1 -1
  139. package/lib/typescript/commonjs/src/components/Notification/index.d.ts.map +1 -1
  140. package/lib/typescript/commonjs/src/components/NumberInput/index.d.ts.map +1 -1
  141. package/lib/typescript/commonjs/src/components/PinInput/index.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/components/Popover/index.d.ts.map +1 -1
  143. package/lib/typescript/commonjs/src/components/RingProgress/index.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/components/SegmentedControl/index.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/components/Slider/index.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/src/components/Stepper/index.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/components/Table/index.d.ts +16 -7
  148. package/lib/typescript/commonjs/src/components/Table/index.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/components/TextInput/index.d.ts.map +1 -1
  150. package/lib/typescript/commonjs/src/components/Timeline/index.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/src/components/Tooltip/index.d.ts.map +1 -1
  152. package/lib/typescript/commonjs/src/components/TransferList/index.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/src/components/Transition/index.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/src/components/UnstyledButton/UnstyledButton.d.ts +2 -0
  155. package/lib/typescript/commonjs/src/components/UnstyledButton/UnstyledButton.d.ts.map +1 -1
  156. package/lib/typescript/commonjs/src/components/index.d.ts +1 -1
  157. package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -1
  158. package/lib/typescript/commonjs/src/theme/functions/attach-functions.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/src/theme/functions/fns/helpers.d.ts +7 -0
  160. package/lib/typescript/commonjs/src/theme/functions/fns/helpers.d.ts.map +1 -1
  161. package/lib/typescript/commonjs/src/theme/functions/fns/index.d.ts +7 -0
  162. package/lib/typescript/commonjs/src/theme/functions/fns/index.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/src/theme/functions/fns/rgba.d.ts +8 -0
  164. package/lib/typescript/commonjs/src/theme/functions/fns/rgba.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/src/theme/functions/fns/size.d.ts +6 -0
  166. package/lib/typescript/commonjs/src/theme/functions/fns/size.d.ts.map +1 -0
  167. package/lib/typescript/module/src/components/Button/index.d.ts +1 -0
  168. package/lib/typescript/module/src/components/Button/index.d.ts.map +1 -1
  169. package/lib/typescript/module/src/components/CloseButton/index.d.ts.map +1 -1
  170. package/lib/typescript/module/src/components/Collapse/index.d.ts.map +1 -1
  171. package/lib/typescript/module/src/components/Dialog/index.d.ts +2 -0
  172. package/lib/typescript/module/src/components/Dialog/index.d.ts.map +1 -1
  173. package/lib/typescript/module/src/components/Drawer/index.d.ts.map +1 -1
  174. package/lib/typescript/module/src/components/Icon/index.d.ts +26 -0
  175. package/lib/typescript/module/src/components/Icon/index.d.ts.map +1 -0
  176. package/lib/typescript/module/src/components/Menu/index.d.ts.map +1 -1
  177. package/lib/typescript/module/src/components/Modal/index.d.ts.map +1 -1
  178. package/lib/typescript/module/src/components/Notification/index.d.ts.map +1 -1
  179. package/lib/typescript/module/src/components/NumberInput/index.d.ts.map +1 -1
  180. package/lib/typescript/module/src/components/PinInput/index.d.ts.map +1 -1
  181. package/lib/typescript/module/src/components/Popover/index.d.ts.map +1 -1
  182. package/lib/typescript/module/src/components/RingProgress/index.d.ts.map +1 -1
  183. package/lib/typescript/module/src/components/SegmentedControl/index.d.ts.map +1 -1
  184. package/lib/typescript/module/src/components/Slider/index.d.ts.map +1 -1
  185. package/lib/typescript/module/src/components/Stepper/index.d.ts.map +1 -1
  186. package/lib/typescript/module/src/components/Table/index.d.ts +16 -7
  187. package/lib/typescript/module/src/components/Table/index.d.ts.map +1 -1
  188. package/lib/typescript/module/src/components/TextInput/index.d.ts.map +1 -1
  189. package/lib/typescript/module/src/components/Timeline/index.d.ts.map +1 -1
  190. package/lib/typescript/module/src/components/Tooltip/index.d.ts.map +1 -1
  191. package/lib/typescript/module/src/components/TransferList/index.d.ts.map +1 -1
  192. package/lib/typescript/module/src/components/Transition/index.d.ts.map +1 -1
  193. package/lib/typescript/module/src/components/UnstyledButton/UnstyledButton.d.ts +2 -0
  194. package/lib/typescript/module/src/components/UnstyledButton/UnstyledButton.d.ts.map +1 -1
  195. package/lib/typescript/module/src/components/index.d.ts +1 -1
  196. package/lib/typescript/module/src/components/index.d.ts.map +1 -1
  197. package/lib/typescript/module/src/theme/functions/attach-functions.d.ts.map +1 -1
  198. package/lib/typescript/module/src/theme/functions/fns/helpers.d.ts +7 -0
  199. package/lib/typescript/module/src/theme/functions/fns/helpers.d.ts.map +1 -1
  200. package/lib/typescript/module/src/theme/functions/fns/index.d.ts +7 -0
  201. package/lib/typescript/module/src/theme/functions/fns/index.d.ts.map +1 -1
  202. package/lib/typescript/module/src/theme/functions/fns/rgba.d.ts +8 -0
  203. package/lib/typescript/module/src/theme/functions/fns/rgba.d.ts.map +1 -0
  204. package/lib/typescript/module/src/theme/functions/fns/size.d.ts +6 -0
  205. package/lib/typescript/module/src/theme/functions/fns/size.d.ts.map +1 -0
  206. package/package.json +12 -9
  207. package/src/components/Button/Button.styles.ts +3 -3
  208. package/src/components/Button/index.tsx +56 -61
  209. package/src/components/Chip/index.tsx +3 -3
  210. package/src/components/CloseButton/index.tsx +2 -23
  211. package/src/components/Collapse/index.tsx +11 -2
  212. package/src/components/Dialog/index.tsx +54 -9
  213. package/src/components/Drawer/index.tsx +7 -13
  214. package/src/components/Icon/index.tsx +74 -0
  215. package/src/components/List/index.tsx +1 -1
  216. package/src/components/Menu/index.tsx +13 -10
  217. package/src/components/Modal/index.tsx +11 -16
  218. package/src/components/Notification/index.tsx +10 -2
  219. package/src/components/NumberInput/index.tsx +57 -15
  220. package/src/components/PasswordInput/index.tsx +2 -2
  221. package/src/components/PinInput/index.tsx +24 -9
  222. package/src/components/Popover/index.tsx +13 -10
  223. package/src/components/RingProgress/index.tsx +51 -8
  224. package/src/components/SegmentedControl/index.tsx +6 -4
  225. package/src/components/Slider/index.tsx +14 -3
  226. package/src/components/Stepper/index.tsx +5 -4
  227. package/src/components/Table/index.tsx +73 -36
  228. package/src/components/TextInput/index.tsx +93 -66
  229. package/src/components/Timeline/index.tsx +19 -12
  230. package/src/components/Tooltip/index.tsx +13 -10
  231. package/src/components/TransferList/index.tsx +1 -5
  232. package/src/components/Transition/index.tsx +14 -2
  233. package/src/components/UnstyledButton/UnstyledButton.tsx +5 -1
  234. package/src/components/index.tsx +1 -1
  235. package/src/theme/functions/attach-functions.ts +3 -0
  236. package/src/theme/functions/fns/helpers.ts +19 -7
  237. package/src/theme/functions/fns/index.ts +4 -0
  238. package/src/theme/functions/fns/rgba.ts +45 -0
  239. package/src/theme/functions/fns/size.ts +14 -0
  240. package/lib/commonjs/components/Portal/index.js +0 -69
  241. package/lib/commonjs/components/Portal/index.js.map +0 -1
  242. package/lib/module/components/Portal/index.js +0 -62
  243. package/lib/module/components/Portal/index.js.map +0 -1
  244. package/lib/typescript/commonjs/src/components/Portal/index.d.ts +0 -10
  245. package/lib/typescript/commonjs/src/components/Portal/index.d.ts.map +0 -1
  246. package/lib/typescript/module/src/components/Portal/index.d.ts +0 -10
  247. package/lib/typescript/module/src/components/Portal/index.d.ts.map +0 -1
  248. package/src/components/Portal/index.tsx +0 -75
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useEffect, useRef } from 'react';
1
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
2
2
  import { Animated, Easing } from 'react-native';
3
3
  import type { DefaultProps } from '../../theme/types';
4
4
  import { useComponentDefaultProps } from '../../theme/theme-provider';
@@ -83,6 +83,7 @@ export const Transition = forwardRef<any, TransitionProps>((props, ref) => {
83
83
 
84
84
  const animation = useRef(new Animated.Value(mounted ? 1 : 0)).current;
85
85
  const shouldRender = useRef(mounted);
86
+ const [_exited, setExited] = useState(true);
86
87
 
87
88
  useEffect(() => {
88
89
  if (mounted) {
@@ -96,6 +97,7 @@ export const Transition = forwardRef<any, TransitionProps>((props, ref) => {
96
97
  if (finished && onEntered) {
97
98
  onEntered();
98
99
  }
100
+ setExited(false);
99
101
  });
100
102
  } else {
101
103
  Animated.timing(animation, {
@@ -104,15 +106,25 @@ export const Transition = forwardRef<any, TransitionProps>((props, ref) => {
104
106
  easing: getEasing(timingFunction || 'ease'),
105
107
  useNativeDriver: true,
106
108
  }).start(({ finished }) => {
109
+ console.log('finished', finished);
107
110
  if (finished) {
108
111
  shouldRender.current = false;
109
112
  if (onExited) {
110
113
  onExited();
111
114
  }
115
+ setExited(true);
112
116
  }
113
117
  });
114
118
  }
115
- }, [mounted, duration, exitDuration, timingFunction, onEntered, onExited, animation]);
119
+ }, [
120
+ mounted,
121
+ duration,
122
+ exitDuration,
123
+ timingFunction,
124
+ onEntered,
125
+ onExited,
126
+ animation,
127
+ ]);
116
128
 
117
129
  const getTransformStyle = () => {
118
130
  switch (transition) {
@@ -8,13 +8,15 @@ export interface UnstyledButtonProps {
8
8
  variant?: string;
9
9
  children?: React.ReactNode;
10
10
  onPress?: (payload: any) => void;
11
+ disabled?: boolean;
12
+ activeOpacity?: number;
11
13
  }
12
14
 
13
15
  export const UnstyledButton = forwardRef<
14
16
  any,
15
17
  UnstyledButtonProps & { style?: any }
16
18
  >((props, ref) => {
17
- const { variant, style, children, onPress, ...others } =
19
+ const { variant, style, children, onPress, disabled, activeOpacity, ...others } =
18
20
  useComponentDefaultProps('UnstyledButton', {}, props);
19
21
 
20
22
  const { styles } = useStyles({
@@ -24,6 +26,8 @@ export const UnstyledButton = forwardRef<
24
26
  return (
25
27
  <TouchableOpacity
26
28
  onPress={typeof onPress === 'function' ? onPress : () => {}}
29
+ disabled={disabled}
30
+ activeOpacity={activeOpacity !== undefined ? activeOpacity : 0.7}
27
31
  >
28
32
  <BoxView ref={ref} style={[styles.root, style]} {...others}>
29
33
  {children}
@@ -6,6 +6,7 @@ export * from './Button';
6
6
  export * from './UnstyledButton';
7
7
  export * from './ActionIcon';
8
8
  export * from './Loader';
9
+ export * from './Icon';
9
10
 
10
11
  // Phase 1 components
11
12
  export * from './Center';
@@ -35,7 +36,6 @@ export * from './Radio';
35
36
 
36
37
  // Phase 3 components - Foundation & Utilities
37
38
  export * from './Overlay';
38
- export * from './Portal';
39
39
 
40
40
  // Phase 3 components - Interactive Components
41
41
  export * from './Modal';
@@ -5,10 +5,13 @@ export function attachFunctions(themeBase: any): any {
5
5
  ...themeBase,
6
6
  fn: {
7
7
  radius: fns.radius(themeBase),
8
+ rgba: fns.rgba(themeBase),
9
+ size: fns.size(themeBase),
8
10
  variant: fns.variant(themeBase),
9
11
  themeColor: (color: string, shade?: number) =>
10
12
  fns.themeColor({ theme: themeBase, color, shade }),
11
13
  fontStyles: fns.fontStyles(themeBase),
14
+ inputFontStyles: fns.inputFontStyles(themeBase),
12
15
  focusStyles: fns.focusStyles(themeBase),
13
16
  placeholderStyles: fns.placeholderStyles(themeBase),
14
17
  cover: fns.cover(themeBase),
@@ -4,6 +4,16 @@ export const fontStyles = (theme: MantineTheme) => () => ({
4
4
  fontFamily: theme.fontFamily,
5
5
  });
6
6
 
7
+ /**
8
+ * Returns font styles specifically for input components
9
+ * Uses fontFamilyInput if available, otherwise falls back to fontFamily
10
+ */
11
+ export const inputFontStyles = (theme: MantineTheme) => () => {
12
+ return {
13
+ fontFamily: theme.fontFamilyInput || theme.fontFamily,
14
+ };
15
+ };
16
+
7
17
  export const focusStyles = (_theme: MantineTheme) => () => ({
8
18
  // Focus styles for accessibility
9
19
  // In React Native, we typically don't use outline
@@ -15,13 +25,15 @@ export const placeholderStyles = (_theme: MantineTheme) => () => ({
15
25
  opacity: 0.6,
16
26
  });
17
27
 
18
- export const cover = (_theme: MantineTheme) => (offset: number = 0) => ({
19
- position: 'absolute' as const,
20
- top: offset,
21
- right: offset,
22
- bottom: offset,
23
- left: offset,
24
- });
28
+ export const cover =
29
+ (_theme: MantineTheme) =>
30
+ (offset: number = 0) => ({
31
+ position: 'absolute' as const,
32
+ top: offset,
33
+ right: offset,
34
+ bottom: offset,
35
+ left: offset,
36
+ });
25
37
 
26
38
  export const hover = (_theme: MantineTheme) => (styles: any) => ({
27
39
  // Hover styles (primarily for web, limited support in React Native)
@@ -1,10 +1,14 @@
1
1
  import { radius } from './radius';
2
+ import { rgba } from './rgba';
3
+ import { size } from './size';
2
4
  import { themeColor } from './theme-color/theme-color';
3
5
  import { variant } from './variant';
4
6
  import * as helpers from './helpers';
5
7
 
6
8
  export const fns = {
7
9
  radius,
10
+ rgba,
11
+ size,
8
12
  variant,
9
13
  themeColor,
10
14
  ...helpers,
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Converts a hex or rgb color string to rgba with the specified alpha value
3
+ * @param color - The color string (hex or rgb)
4
+ * @param alpha - Alpha value between 0 and 1
5
+ * @returns rgba color string
6
+ */
7
+ export function rgba(_theme: any) {
8
+ return (color: string, alpha: number): string => {
9
+ // If it's already an rgba string, replace the alpha
10
+ if (color.startsWith('rgba')) {
11
+ return color.replace(/[\d.]+\)$/g, `${alpha})`);
12
+ }
13
+
14
+ // If it's an rgb string, convert to rgba
15
+ if (color.startsWith('rgb(')) {
16
+ return color.replace('rgb(', 'rgba(').replace(')', `, ${alpha})`);
17
+ }
18
+
19
+ // If it's a hex color, convert to rgba
20
+ if (color.startsWith('#')) {
21
+ const hex = color.replace('#', '');
22
+ let r = 0;
23
+ let g = 0;
24
+ let b = 0;
25
+
26
+ if (hex.length === 3) {
27
+ r = parseInt(hex[0]! + hex[0]!, 16);
28
+ g = parseInt(hex[1]! + hex[1]!, 16);
29
+ b = parseInt(hex[2]! + hex[2]!, 16);
30
+ } else if (hex.length === 6) {
31
+ r = parseInt(hex.slice(0, 2), 16);
32
+ g = parseInt(hex.slice(2, 4), 16);
33
+ b = parseInt(hex.slice(4, 6), 16);
34
+ } else {
35
+ // Invalid hex, return as is with alpha
36
+ return `rgba(0, 0, 0, ${alpha})`;
37
+ }
38
+
39
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
40
+ }
41
+
42
+ // If we can't parse it, return as is
43
+ return color;
44
+ };
45
+ }
@@ -0,0 +1,14 @@
1
+ import type { MantineNumberSize } from '../../types';
2
+ import { getSize } from '../../get-size';
3
+
4
+ export function size(_theme: any) {
5
+ return <Sizes extends Record<any, any>>({
6
+ size,
7
+ sizes,
8
+ }: {
9
+ size: MantineNumberSize;
10
+ sizes: Sizes;
11
+ }): number => {
12
+ return getSize({ size, sizes }) as number;
13
+ };
14
+ }
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PortalProvider = exports.Portal = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _jsxRuntime = require("react/jsx-runtime");
10
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
- const PortalContext = /*#__PURE__*/(0, _react.createContext)(null);
12
- const PortalProvider = ({
13
- children
14
- }) => {
15
- const [portals, setPortals] = (0, _react.useState)(new Map());
16
- const nextKey = _react.default.useRef(0);
17
- const mount = (0, _react.useCallback)(child => {
18
- const key = nextKey.current++;
19
- setPortals(prev => {
20
- const next = new Map(prev);
21
- next.set(key, child);
22
- return next;
23
- });
24
- return key;
25
- }, []);
26
- const unmount = (0, _react.useCallback)(key => {
27
- setPortals(prev => {
28
- const next = new Map(prev);
29
- next.delete(key);
30
- return next;
31
- });
32
- }, []);
33
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PortalContext.Provider, {
34
- value: {
35
- mount,
36
- unmount
37
- },
38
- children: [children, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
39
- style: _reactNative.StyleSheet.absoluteFill,
40
- pointerEvents: "box-none",
41
- children: Array.from(portals.entries()).map(([key, child]) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
42
- children: child
43
- }, key))
44
- })]
45
- });
46
- };
47
- exports.PortalProvider = PortalProvider;
48
- const Portal = ({
49
- children
50
- }) => {
51
- const context = (0, _react.useContext)(PortalContext);
52
- const [, setKey] = (0, _react.useState)(null);
53
- _react.default.useEffect(() => {
54
- if (!context) {
55
- console.warn('Portal used without PortalProvider');
56
- return;
57
- }
58
- const portalKey = context.mount(children);
59
- setKey(portalKey);
60
- return () => {
61
- context.unmount(portalKey);
62
- };
63
- }, [children, context]);
64
- return null;
65
- };
66
- exports.Portal = Portal;
67
- Portal.displayName = 'Portal';
68
- PortalProvider.displayName = 'PortalProvider';
69
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PortalContext","createContext","PortalProvider","children","portals","setPortals","useState","Map","nextKey","React","useRef","mount","useCallback","child","key","current","prev","next","unmount","delete","jsxs","Provider","value","jsx","View","style","StyleSheet","absoluteFill","pointerEvents","Array","from","entries","map","Fragment","exports","Portal","context","useContext","setKey","useEffect","console","warn","portalKey","displayName"],"sourceRoot":"../../../../src","sources":["components/Portal/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAgD,IAAAE,WAAA,GAAAF,OAA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AA,GAAAA,cAAA;AAMK,MAAMiC,MAA6B,GAAGA,CAAC;EAAEhC;AAAS,CAAC,KAAK;EAC7D,MAAMiC,OAAO,GAAG,IAAAC,iBAAU,EAACrC,aAAa,CAAC;EACzC,MAAM,GAAGsC,MAAM,CAAC,GAAG,IAAAhC,eAAQ,EAAgB,IAAI,CAAC;EAEhDG,cAAK,CAAC8B,SAAS,CAAC,MAAM;IACpB,IAAI,CAACH,OAAO,EAAE;MACZI,OAAO,CAACC,IAAI,CAAC,oCAAoC,CAAC;MAClD;IACF;IAEA,MAAMC,SAAS,GAAGN,OAAO,CAACzB,KAAK,CAACR,QAAQ,CAAC;IACzCmC,MAAM,CAACI,SAAS,CAAC;IAEjB,OAAO,MAAM;MACXN,OAAO,CAAClB,OAAO,CAACwB,SAAS,CAAC;IAC5B,CAAC;EACH,CAAC,EAAE,CAACvC,QAAQ,EAAEiC,OAAO,CAAC,CAAC;EAEvB,OAAO,IAAI;AACb,CAAC;AAACF,OAAA,CAAAC,MAAA,GAAAA,MAAA;AAEFA,MAAM,CAACQ,WAAW,GAAG,QAAQ;AAC7BzC,cAAc,CAACyC,WAAW,GAAG,gBAAgB","ignoreList":[]}
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- import React, { createContext, useContext, useState, useCallback } from 'react';
4
- import { View, StyleSheet } from 'react-native';
5
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
- const PortalContext = /*#__PURE__*/createContext(null);
7
- export const PortalProvider = ({
8
- children
9
- }) => {
10
- const [portals, setPortals] = useState(new Map());
11
- const nextKey = React.useRef(0);
12
- const mount = useCallback(child => {
13
- const key = nextKey.current++;
14
- setPortals(prev => {
15
- const next = new Map(prev);
16
- next.set(key, child);
17
- return next;
18
- });
19
- return key;
20
- }, []);
21
- const unmount = useCallback(key => {
22
- setPortals(prev => {
23
- const next = new Map(prev);
24
- next.delete(key);
25
- return next;
26
- });
27
- }, []);
28
- return /*#__PURE__*/_jsxs(PortalContext.Provider, {
29
- value: {
30
- mount,
31
- unmount
32
- },
33
- children: [children, /*#__PURE__*/_jsx(View, {
34
- style: StyleSheet.absoluteFill,
35
- pointerEvents: "box-none",
36
- children: Array.from(portals.entries()).map(([key, child]) => /*#__PURE__*/_jsx(React.Fragment, {
37
- children: child
38
- }, key))
39
- })]
40
- });
41
- };
42
- export const Portal = ({
43
- children
44
- }) => {
45
- const context = useContext(PortalContext);
46
- const [, setKey] = useState(null);
47
- React.useEffect(() => {
48
- if (!context) {
49
- console.warn('Portal used without PortalProvider');
50
- return;
51
- }
52
- const portalKey = context.mount(children);
53
- setKey(portalKey);
54
- return () => {
55
- context.unmount(portalKey);
56
- };
57
- }, [children, context]);
58
- return null;
59
- };
60
- Portal.displayName = 'Portal';
61
- PortalProvider.displayName = 'PortalProvider';
62
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","createContext","useContext","useState","useCallback","View","StyleSheet","jsx","_jsx","jsxs","_jsxs","PortalContext","PortalProvider","children","portals","setPortals","Map","nextKey","useRef","mount","child","key","current","prev","next","set","unmount","delete","Provider","value","style","absoluteFill","pointerEvents","Array","from","entries","map","Fragment","Portal","context","setKey","useEffect","console","warn","portalKey","displayName"],"sourceRoot":"../../../../src","sources":["components/Portal/index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,OAAO;AAC/E,SAASC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAOhD,MAAMC,aAAa,gBAAGV,aAAa,CAA4B,IAAI,CAAC;AAMpE,OAAO,MAAMW,cAA6C,GAAGA,CAAC;EAAEC;AAAS,CAAC,KAAK;EAC7E,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGZ,QAAQ,CAA+B,IAAIa,GAAG,CAAC,CAAC,CAAC;EAC/E,MAAMC,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AAGrC,UAAU,CAACS,aAAa,CAAC;EACzC,MAAM,GAAG6B,MAAM,CAAC,GAAGrC,QAAQ,CAAgB,IAAI,CAAC;EAEhDH,KAAK,CAACyC,SAAS,CAAC,MAAM;IACpB,IAAI,CAACF,OAAO,EAAE;MACZG,OAAO,CAACC,IAAI,CAAC,oCAAoC,CAAC;MAClD;IACF;IAEA,MAAMC,SAAS,GAAGL,OAAO,CAACpB,KAAK,CAACN,QAAQ,CAAC;IACzC2B,MAAM,CAACI,SAAS,CAAC;IAEjB,OAAO,MAAM;MACXL,OAAO,CAACb,OAAO,CAACkB,SAAS,CAAC;IAC5B,CAAC;EACH,CAAC,EAAE,CAAC/B,QAAQ,EAAE0B,OAAO,CAAC,CAAC;EAEvB,OAAO,IAAI;AACb,CAAC;AAEDD,MAAM,CAACO,WAAW,GAAG,QAAQ;AAC7BjC,cAAc,CAACiC,WAAW,GAAG,gBAAgB","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- export interface PortalProviderProps {
3
- children: React.ReactNode;
4
- }
5
- export declare const PortalProvider: React.FC<PortalProviderProps>;
6
- export interface PortalProps {
7
- children: React.ReactNode;
8
- }
9
- export declare const Portal: React.FC<PortalProps>;
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Portal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAUhF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAgCxD,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAmBxC,CAAC"}
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- export interface PortalProviderProps {
3
- children: React.ReactNode;
4
- }
5
- export declare const PortalProvider: React.FC<PortalProviderProps>;
6
- export interface PortalProps {
7
- children: React.ReactNode;
8
- }
9
- export declare const Portal: React.FC<PortalProps>;
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Portal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAUhF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAgCxD,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAmBxC,CAAC"}
@@ -1,75 +0,0 @@
1
- import React, { createContext, useContext, useState, useCallback } from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
-
4
- interface PortalContextValue {
5
- mount: (child: React.ReactNode) => number;
6
- unmount: (key: number) => void;
7
- }
8
-
9
- const PortalContext = createContext<PortalContextValue | null>(null);
10
-
11
- export interface PortalProviderProps {
12
- children: React.ReactNode;
13
- }
14
-
15
- export const PortalProvider: React.FC<PortalProviderProps> = ({ children }) => {
16
- const [portals, setPortals] = useState<Map<number, React.ReactNode>>(new Map());
17
- const nextKey = React.useRef(0);
18
-
19
- const mount = useCallback((child: React.ReactNode) => {
20
- const key = nextKey.current++;
21
- setPortals((prev) => {
22
- const next = new Map(prev);
23
- next.set(key, child);
24
- return next;
25
- });
26
- return key;
27
- }, []);
28
-
29
- const unmount = useCallback((key: number) => {
30
- setPortals((prev) => {
31
- const next = new Map(prev);
32
- next.delete(key);
33
- return next;
34
- });
35
- }, []);
36
-
37
- return (
38
- <PortalContext.Provider value={{ mount, unmount }}>
39
- {children}
40
- <View style={StyleSheet.absoluteFill} pointerEvents="box-none">
41
- {Array.from(portals.entries()).map(([key, child]) => (
42
- <React.Fragment key={key}>{child}</React.Fragment>
43
- ))}
44
- </View>
45
- </PortalContext.Provider>
46
- );
47
- };
48
-
49
- export interface PortalProps {
50
- children: React.ReactNode;
51
- }
52
-
53
- export const Portal: React.FC<PortalProps> = ({ children }) => {
54
- const context = useContext(PortalContext);
55
- const [, setKey] = useState<number | null>(null);
56
-
57
- React.useEffect(() => {
58
- if (!context) {
59
- console.warn('Portal used without PortalProvider');
60
- return;
61
- }
62
-
63
- const portalKey = context.mount(children);
64
- setKey(portalKey);
65
-
66
- return () => {
67
- context.unmount(portalKey);
68
- };
69
- }, [children, context]);
70
-
71
- return null;
72
- };
73
-
74
- Portal.displayName = 'Portal';
75
- PortalProvider.displayName = 'PortalProvider';