@swan-io/lake 1.0.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 (288) hide show
  1. package/HISTORY.md +3 -0
  2. package/LICENSE +21 -0
  3. package/README.md +49 -0
  4. package/package.json +60 -0
  5. package/src/components/Alert.d.ts +10 -0
  6. package/src/components/Alert.js +36 -0
  7. package/src/components/AppOpeningAnimation.d.ts +10 -0
  8. package/src/components/AppOpeningAnimation.js +50 -0
  9. package/src/components/AutoWidthImage.d.ts +8 -0
  10. package/src/components/AutoWidthImage.js +26 -0
  11. package/src/components/Avatar.d.ts +7 -0
  12. package/src/components/Avatar.js +42 -0
  13. package/src/components/BorderedButton.d.ts +16 -0
  14. package/src/components/BorderedButton.js +98 -0
  15. package/src/components/BorderedIcon.d.ts +12 -0
  16. package/src/components/BorderedIcon.js +25 -0
  17. package/src/components/BottomPanel.d.ts +9 -0
  18. package/src/components/BottomPanel.js +94 -0
  19. package/src/components/Box.d.ts +65 -0
  20. package/src/components/Box.js +31 -0
  21. package/src/components/Breadcrumbs.d.ts +18 -0
  22. package/src/components/Breadcrumbs.js +362 -0
  23. package/src/components/Button.d.ts +15 -0
  24. package/src/components/Button.js +83 -0
  25. package/src/components/Caption.d.ts +6 -0
  26. package/src/components/Caption.js +11 -0
  27. package/src/components/Checkbox.d.ts +12 -0
  28. package/src/components/Checkbox.js +83 -0
  29. package/src/components/ChoicePicker.d.ts +11 -0
  30. package/src/components/ChoicePicker.js +99 -0
  31. package/src/components/Combobox.d.ts +29 -0
  32. package/src/components/Combobox.js +182 -0
  33. package/src/components/FailureIcon.d.ts +8 -0
  34. package/src/components/FailureIcon.js +4 -0
  35. package/src/components/FileTile.d.ts +11 -0
  36. package/src/components/FileTile.js +37 -0
  37. package/src/components/Fill.d.ts +8 -0
  38. package/src/components/Fill.js +24 -0
  39. package/src/components/FilterChooser.d.ts +15 -0
  40. package/src/components/FilterChooser.js +52 -0
  41. package/src/components/Filters.d.ts +57 -0
  42. package/src/components/Filters.js +229 -0
  43. package/src/components/FixedListView.d.ts +104 -0
  44. package/src/components/FixedListView.js +821 -0
  45. package/src/components/FixedListViewCells.d.ts +55 -0
  46. package/src/components/FixedListViewCells.js +157 -0
  47. package/src/components/Flag.d.ts +8 -0
  48. package/src/components/Flag.js +36 -0
  49. package/src/components/FlowPresentation.d.ts +12 -0
  50. package/src/components/FlowPresentation.js +70 -0
  51. package/src/components/FocusTrap.d.ts +16 -0
  52. package/src/components/FocusTrap.js +90 -0
  53. package/src/components/Form.d.ts +8 -0
  54. package/src/components/Form.js +17 -0
  55. package/src/components/FullViewportLayer.d.ts +7 -0
  56. package/src/components/FullViewportLayer.js +91 -0
  57. package/src/components/Grid.d.ts +13 -0
  58. package/src/components/Grid.js +33 -0
  59. package/src/components/Heading.d.ts +61 -0
  60. package/src/components/Heading.js +27 -0
  61. package/src/components/Icon.d.ts +191 -0
  62. package/src/components/Icon.js +11 -0
  63. package/src/components/Input.d.ts +34 -0
  64. package/src/components/Input.js +115 -0
  65. package/src/components/InputError.d.ts +8 -0
  66. package/src/components/InputError.js +16 -0
  67. package/src/components/Label.d.ts +10 -0
  68. package/src/components/Label.js +19 -0
  69. package/src/components/LakeAlert.d.ts +14 -0
  70. package/src/components/LakeAlert.js +75 -0
  71. package/src/components/LakeButton.d.ts +36 -0
  72. package/src/components/LakeButton.js +171 -0
  73. package/src/components/LakeCheckbox.d.ts +16 -0
  74. package/src/components/LakeCheckbox.js +54 -0
  75. package/src/components/LakeCombobox.d.ts +28 -0
  76. package/src/components/LakeCombobox.js +166 -0
  77. package/src/components/LakeCopyButton.d.ts +10 -0
  78. package/src/components/LakeCopyButton.js +16 -0
  79. package/src/components/LakeDownloadButton.d.ts +8 -0
  80. package/src/components/LakeDownloadButton.js +6 -0
  81. package/src/components/LakeHeading.d.ts +10 -0
  82. package/src/components/LakeHeading.js +19 -0
  83. package/src/components/LakeLabel.d.ts +19 -0
  84. package/src/components/LakeLabel.js +43 -0
  85. package/src/components/LakeModal.d.ts +14 -0
  86. package/src/components/LakeModal.js +132 -0
  87. package/src/components/LakeRadio.d.ts +9 -0
  88. package/src/components/LakeRadio.js +44 -0
  89. package/src/components/LakeScrollView.d.ts +10 -0
  90. package/src/components/LakeScrollView.js +35 -0
  91. package/src/components/LakeSearchField.d.ts +10 -0
  92. package/src/components/LakeSearchField.js +111 -0
  93. package/src/components/LakeSelect.d.ts +30 -0
  94. package/src/components/LakeSelect.js +183 -0
  95. package/src/components/LakeSlider.d.ts +12 -0
  96. package/src/components/LakeSlider.js +31 -0
  97. package/src/components/LakeStepper.d.ts +21 -0
  98. package/src/components/LakeStepper.js +134 -0
  99. package/src/components/LakeText.d.ts +19 -0
  100. package/src/components/LakeText.js +20 -0
  101. package/src/components/LakeTextInput.d.ts +36 -0
  102. package/src/components/LakeTextInput.js +154 -0
  103. package/src/components/LakeTooltip.d.ts +24 -0
  104. package/src/components/LakeTooltip.js +188 -0
  105. package/src/components/Link.d.ts +138 -0
  106. package/src/components/Link.js +23 -0
  107. package/src/components/ListRightPanel.d.ts +17 -0
  108. package/src/components/ListRightPanel.js +79 -0
  109. package/src/components/LoadingView.d.ts +9 -0
  110. package/src/components/LoadingView.js +24 -0
  111. package/src/components/Modal.d.ts +12 -0
  112. package/src/components/Modal.js +80 -0
  113. package/src/components/MultiSelect.d.ts +27 -0
  114. package/src/components/MultiSelect.js +223 -0
  115. package/src/components/MultilineInput.d.ts +15 -0
  116. package/src/components/MultilineInput.js +55 -0
  117. package/src/components/Picker.d.ts +26 -0
  118. package/src/components/Picker.js +116 -0
  119. package/src/components/PlainListView.d.ts +36 -0
  120. package/src/components/PlainListView.js +208 -0
  121. package/src/components/Popover.d.ts +23 -0
  122. package/src/components/Popover.js +147 -0
  123. package/src/components/PopoverContent.d.ts +8 -0
  124. package/src/components/PopoverContent.js +9 -0
  125. package/src/components/Portal.d.ts +7 -0
  126. package/src/components/Portal.js +9 -0
  127. package/src/components/Pressable.d.ts +348 -0
  128. package/src/components/Pressable.js +91 -0
  129. package/src/components/ProgressBar.d.ts +11 -0
  130. package/src/components/ProgressBar.js +46 -0
  131. package/src/components/ProjectEnvTag.d.ts +7 -0
  132. package/src/components/ProjectEnvTag.js +12 -0
  133. package/src/components/QuickActions.d.ts +15 -0
  134. package/src/components/QuickActions.js +38 -0
  135. package/src/components/RadioGroup.d.ts +16 -0
  136. package/src/components/RadioGroup.js +34 -0
  137. package/src/components/ReadOnlyFieldList.d.ts +6 -0
  138. package/src/components/ReadOnlyFieldList.js +8 -0
  139. package/src/components/ResponsiveContainer.d.ts +13 -0
  140. package/src/components/ResponsiveContainer.js +23 -0
  141. package/src/components/RightPanel.d.ts +10 -0
  142. package/src/components/RightPanel.js +102 -0
  143. package/src/components/SegmentedControl.d.ts +19 -0
  144. package/src/components/SegmentedControl.js +74 -0
  145. package/src/components/Separator.d.ts +10 -0
  146. package/src/components/Separator.js +19 -0
  147. package/src/components/SidebarNavigationTracker.d.ts +13 -0
  148. package/src/components/SidebarNavigationTracker.js +93 -0
  149. package/src/components/Slider.d.ts +11 -0
  150. package/src/components/Slider.js +119 -0
  151. package/src/components/SmsOpeningAnimation.d.ts +8 -0
  152. package/src/components/SmsOpeningAnimation.js +52 -0
  153. package/src/components/Space.d.ts +10 -0
  154. package/src/components/Space.js +23 -0
  155. package/src/components/Stack.d.ts +12 -0
  156. package/src/components/Stack.js +23 -0
  157. package/src/components/StepDots.d.ts +7 -0
  158. package/src/components/StepDots.js +24 -0
  159. package/src/components/Stepper.d.ts +9 -0
  160. package/src/components/Stepper.js +67 -0
  161. package/src/components/SuccessIcon.d.ts +8 -0
  162. package/src/components/SuccessIcon.js +4 -0
  163. package/src/components/Svg.d.ts +145 -0
  164. package/src/components/Svg.js +24 -0
  165. package/src/components/SwanLogo.d.ts +8 -0
  166. package/src/components/SwanLogo.js +11 -0
  167. package/src/components/Switch.d.ts +9 -0
  168. package/src/components/Switch.js +74 -0
  169. package/src/components/TabView.d.ts +16 -0
  170. package/src/components/TabView.js +398 -0
  171. package/src/components/Table.d.ts +34 -0
  172. package/src/components/Table.js +79 -0
  173. package/src/components/Tag.d.ts +17 -0
  174. package/src/components/Tag.js +76 -0
  175. package/src/components/Tile.d.ts +34 -0
  176. package/src/components/Tile.js +130 -0
  177. package/src/components/TilePlaceholder.d.ts +6 -0
  178. package/src/components/TilePlaceholder.js +51 -0
  179. package/src/components/ToastStack.d.ts +2 -0
  180. package/src/components/ToastStack.js +96 -0
  181. package/src/components/Tooltip.d.ts +18 -0
  182. package/src/components/Tooltip.js +162 -0
  183. package/src/components/TransitionGroupView.d.ts +12 -0
  184. package/src/components/TransitionGroupView.js +43 -0
  185. package/src/components/TransitionView.d.ts +12 -0
  186. package/src/components/TransitionView.js +43 -0
  187. package/src/components/WithCurrentColor.d.ts +12 -0
  188. package/src/components/WithCurrentColor.js +65 -0
  189. package/src/components/WithPartnerAccentColor.d.ts +7 -0
  190. package/src/components/WithPartnerAccentColor.js +91 -0
  191. package/src/constants/colors.d.ts +42 -0
  192. package/src/constants/colors.js +42 -0
  193. package/src/constants/commonStyles.d.ts +66 -0
  194. package/src/constants/commonStyles.js +45 -0
  195. package/src/constants/design.d.ts +168 -0
  196. package/src/constants/design.js +564 -0
  197. package/src/constants/insets.d.ts +10 -0
  198. package/src/constants/insets.js +22 -0
  199. package/src/constants/typography.d.ts +26 -0
  200. package/src/constants/typography.js +54 -0
  201. package/src/hooks/useAnimatedValue.d.ts +2 -0
  202. package/src/hooks/useAnimatedValue.js +3 -0
  203. package/src/hooks/useBodyClassName.d.ts +3 -0
  204. package/src/hooks/useBodyClassName.js +14 -0
  205. package/src/hooks/useBoolean.d.ts +8 -0
  206. package/src/hooks/useBoolean.js +12 -0
  207. package/src/hooks/useComputedColors.d.ts +10 -0
  208. package/src/hooks/useComputedColors.js +42 -0
  209. package/src/hooks/useDebounce.d.ts +1 -0
  210. package/src/hooks/useDebounce.js +12 -0
  211. package/src/hooks/useDisclosure.d.ts +8 -0
  212. package/src/hooks/useDisclosure.js +12 -0
  213. package/src/hooks/useFirstMountState.d.ts +1 -0
  214. package/src/hooks/useFirstMountState.js +9 -0
  215. package/src/hooks/useForceableState.d.ts +1 -0
  216. package/src/hooks/useForceableState.js +6 -0
  217. package/src/hooks/useHover.d.ts +11 -0
  218. package/src/hooks/useHover.js +4 -0
  219. package/src/hooks/useInterval.d.ts +1 -0
  220. package/src/hooks/useInterval.js +11 -0
  221. package/src/hooks/useLazyRef.d.ts +2 -0
  222. package/src/hooks/useLazyRef.js +9 -0
  223. package/src/hooks/useMergeRefs.d.ts +2 -0
  224. package/src/hooks/useMergeRefs.js +5 -0
  225. package/src/hooks/useNativeProp.d.ts +2 -0
  226. package/src/hooks/useNativeProp.js +9 -0
  227. package/src/hooks/useOutsideClick.d.ts +8 -0
  228. package/src/hooks/useOutsideClick.js +54 -0
  229. package/src/hooks/usePersistedState.d.ts +1 -0
  230. package/src/hooks/usePersistedState.js +21 -0
  231. package/src/hooks/usePressEvents.d.ts +31 -0
  232. package/src/hooks/usePressEvents.js +4 -0
  233. package/src/hooks/usePreviousValue.d.ts +1 -0
  234. package/src/hooks/usePreviousValue.js +8 -0
  235. package/src/hooks/useResponsive.d.ts +7 -0
  236. package/src/hooks/useResponsive.js +20 -0
  237. package/src/hooks/useUpdateEffect.d.ts +2 -0
  238. package/src/hooks/useUpdateEffect.js +10 -0
  239. package/src/hooks/useUrqlMutation.d.ts +4 -0
  240. package/src/hooks/useUrqlMutation.js +30 -0
  241. package/src/hooks/useUrqlQuery.d.ts +19 -0
  242. package/src/hooks/useUrqlQuery.js +73 -0
  243. package/src/state/toasts.d.ts +21 -0
  244. package/src/state/toasts.js +61 -0
  245. package/src/utils/__tests__/array.test.d.ts +1 -0
  246. package/src/utils/__tests__/array.test.js +127 -0
  247. package/src/utils/__tests__/base64.test.d.ts +1 -0
  248. package/src/utils/__tests__/base64.test.js +27 -0
  249. package/src/utils/__tests__/function.test.d.ts +1 -0
  250. package/src/utils/__tests__/function.test.js +36 -0
  251. package/src/utils/__tests__/object.test.d.ts +1 -0
  252. package/src/utils/__tests__/object.test.js +17 -0
  253. package/src/utils/__tests__/rifm.test.d.ts +1 -0
  254. package/src/utils/__tests__/rifm.test.js +124 -0
  255. package/src/utils/__tests__/string.test.d.ts +1 -0
  256. package/src/utils/__tests__/string.test.js +16 -0
  257. package/src/utils/a11y.d.ts +1 -0
  258. package/src/utils/a11y.js +18 -0
  259. package/src/utils/array.d.ts +6 -0
  260. package/src/utils/array.js +71 -0
  261. package/src/utils/base64.d.ts +2 -0
  262. package/src/utils/base64.js +20 -0
  263. package/src/utils/file.d.ts +2 -0
  264. package/src/utils/file.js +10 -0
  265. package/src/utils/flagCountry.d.ts +1 -0
  266. package/src/utils/flagCountry.js +1 -0
  267. package/src/utils/function.d.ts +4 -0
  268. package/src/utils/function.js +19 -0
  269. package/src/utils/math.d.ts +16 -0
  270. package/src/utils/math.js +47 -0
  271. package/src/utils/nullish.d.ts +10 -0
  272. package/src/utils/nullish.js +8 -0
  273. package/src/utils/object.d.ts +2 -0
  274. package/src/utils/object.js +7 -0
  275. package/src/utils/popper.d.ts +3 -0
  276. package/src/utils/popper.js +30 -0
  277. package/src/utils/rifm.d.ts +14 -0
  278. package/src/utils/rifm.js +53 -0
  279. package/src/utils/string.d.ts +4 -0
  280. package/src/utils/string.js +233 -0
  281. package/src/utils/timer.d.ts +11 -0
  282. package/src/utils/timer.js +46 -0
  283. package/src/utils/types.d.ts +8 -0
  284. package/src/utils/types.js +1 -0
  285. package/src/utils/userAgent.d.ts +4 -0
  286. package/src/utils/userAgent.js +9 -0
  287. package/src/utils/viewport.d.ts +1 -0
  288. package/src/utils/viewport.js +12 -0
@@ -0,0 +1,130 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Children, cloneElement, Fragment, useCallback, useState, } from "react";
3
+ import { StyleSheet, Text, View } from "react-native";
4
+ import { backgroundColor, colors, negativeSpacings, radii, shadows, spacings, texts, } from "../constants/design";
5
+ import { isNotNullish } from "../utils/nullish";
6
+ import { Box } from "./Box";
7
+ import { LakeText } from "./LakeText";
8
+ import { Space } from "./Space";
9
+ const styles = StyleSheet.create({
10
+ container: {
11
+ backgroundColor: backgroundColor.accented,
12
+ borderRadius: radii[8],
13
+ boxShadow: shadows.tile,
14
+ overflow: "hidden",
15
+ },
16
+ unselectedContainer: {
17
+ backgroundColor: backgroundColor.default,
18
+ boxShadow: `0 0 0 1px ${colors.gray[100]}`,
19
+ },
20
+ unselectedHoveredContainer: {
21
+ backgroundColor: backgroundColor.default,
22
+ boxShadow: `0 0 0 1px ${colors.gray[500]}`,
23
+ },
24
+ disabled: {
25
+ opacity: 0.5,
26
+ },
27
+ hoveredContainer: {
28
+ boxShadow: shadows.tileHover,
29
+ },
30
+ headerContainer: {
31
+ zIndex: 1,
32
+ },
33
+ header: {
34
+ flexDirection: "row",
35
+ alignItems: "flex-start",
36
+ justifyContent: "space-between",
37
+ },
38
+ title: {
39
+ ...texts.h3,
40
+ flexGrow: 1,
41
+ flexDirection: "row",
42
+ alignItems: "center",
43
+ },
44
+ fullWidthContent: {
45
+ marginHorizontal: negativeSpacings[32],
46
+ },
47
+ fitToBottom: {
48
+ marginBottom: negativeSpacings[32],
49
+ },
50
+ column: {
51
+ flexGrow: 1,
52
+ },
53
+ descriptionContainer: {
54
+ flexDirection: "row",
55
+ alignItems: "center",
56
+ justifyContent: "flex-start",
57
+ },
58
+ description: {
59
+ width: 1,
60
+ flexGrow: 1,
61
+ },
62
+ headerTitleIcon: {
63
+ flexGrow: 1,
64
+ },
65
+ row: {
66
+ alignItems: "stretch",
67
+ marginHorizontal: negativeSpacings[12],
68
+ },
69
+ rowCol: {
70
+ flexGrow: 1,
71
+ padding: spacings[12],
72
+ },
73
+ footer: {
74
+ marginHorizontal: negativeSpacings[32],
75
+ alignSelf: "stretch",
76
+ },
77
+ });
78
+ export const Tile = ({ icon, title, description, headerEnd, footer, flexBasis, children, numberOfLines, paddingVertical = 32, paddingHorizontal = 32, hovered = false, flexGrow = 0, flexShrink = 0, disabled = false, selected, style, }) => {
79
+ return (_jsxs(View, { accessibilityRole: "region", style: [
80
+ styles.container,
81
+ selected === false && styles.unselectedContainer,
82
+ {
83
+ paddingVertical: spacings[paddingVertical],
84
+ paddingHorizontal: spacings[paddingHorizontal],
85
+ flexGrow,
86
+ flexShrink,
87
+ flexBasis,
88
+ },
89
+ hovered && styles.hoveredContainer,
90
+ selected === false && hovered && styles.unselectedHoveredContainer,
91
+ disabled && styles.disabled,
92
+ style,
93
+ ], children: [(isNotNullish(title) || isNotNullish(headerEnd) || isNotNullish(description)) && (_jsxs(View, { style: styles.headerContainer, children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTitleIcon, children: [isNotNullish(icon) && (_jsxs(_Fragment, { children: [icon, _jsx(Space, { height: 12 })] })), isNotNullish(title) && (_jsx(Text, { style: styles.title, accessibilityRole: "header", accessibilityLevel: 3, children: title }))] }), isNotNullish(headerEnd) ? _jsx(View, { children: headerEnd }) : null] }), isNotNullish(description) && (_jsxs(_Fragment, { children: [isNotNullish(title) && _jsx(Space, { height: 12 }), _jsx(View, { style: styles.descriptionContainer, children: _jsx(LakeText, { numberOfLines: numberOfLines, style: styles.description, children: description }) })] })), isNotNullish(children) && _jsx(Space, { height: 24 })] })), children, isNotNullish(footer) && (_jsx(View, { style: [styles.footer, { marginTop: paddingVertical, marginBottom: -paddingVertical }], children: footer }))] }));
94
+ };
95
+ export const TileFullWidthContent = ({ children, flexGrow, fitToBottom = false, }) => {
96
+ return (_jsx(View, { style: [styles.fullWidthContent, fitToBottom && styles.fitToBottom, { flexGrow }], children: children }));
97
+ };
98
+ const SPACE = _jsx(Space, { height: 24 });
99
+ export const TileGrid = ({ children, breakpoint = 1000 }) => {
100
+ const [flexDirection, setFlexDirection] = useState("row");
101
+ const onLayout = useCallback(({ nativeEvent: { layout: { width }, }, }) => {
102
+ setFlexDirection(() => (width < breakpoint ? "column" : "row"));
103
+ }, [breakpoint]);
104
+ const childrenArray = Children.toArray(children);
105
+ const leftColumn = [];
106
+ const rightColumn = [];
107
+ const nonNullChildren = childrenArray.filter(isNotNullish);
108
+ nonNullChildren.forEach((item, index) => {
109
+ if (flexDirection === "column" || index % 2 === 0) {
110
+ leftColumn.push(_jsxs(Fragment, { children: [item, SPACE] }, index));
111
+ }
112
+ else {
113
+ rightColumn.push(_jsxs(Fragment, { children: [item, SPACE] }, index));
114
+ }
115
+ });
116
+ const isRow = flexDirection === "row";
117
+ return (_jsxs(Box, { direction: flexDirection, onLayout: onLayout, children: [_jsx(View, { style: [isRow && styles.column, isRow && { flexBasis: breakpoint / 2 }], children: leftColumn }), _jsx(Space, { width: 24 }), _jsx(View, { style: [isRow && styles.column, isRow && { flexBasis: breakpoint / 2 }], children: rightColumn })] }));
118
+ };
119
+ export const TileRows = ({ children, breakpoint = 1000 }) => {
120
+ const [flexDirection, setFlexDirection] = useState("row");
121
+ const onLayout = useCallback(({ nativeEvent: { layout: { width }, }, }) => {
122
+ setFlexDirection(() => (width < breakpoint ? "column" : "row"));
123
+ }, [breakpoint]);
124
+ const childrenArray = Children.toArray(children);
125
+ const nonNullChildren = childrenArray.filter(isNotNullish);
126
+ const isRow = flexDirection === "row";
127
+ return (_jsx(Box, { direction: flexDirection, onLayout: onLayout, style: styles.row, children: nonNullChildren.map((item, index) => {
128
+ return (_jsx(View, { style: [styles.rowCol, isRow && { flexBasis: breakpoint / 2 }], children: cloneElement(item, { flexGrow: 1 }) }, index));
129
+ }) }));
130
+ };
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const TilePlaceholder: () => JSX.Element;
3
+ export declare const TileGridPlaceholder: ({ numberOfItems, withTabs, }: {
4
+ numberOfItems?: number | undefined;
5
+ withTabs?: boolean | undefined;
6
+ }) => JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { StyleSheet, View } from "react-native";
4
+ import { colors, radii } from "../constants/design";
5
+ import { Tile, TileGrid } from "./Tile";
6
+ const styles = StyleSheet.create({
7
+ placeholderTitle: {
8
+ height: 14,
9
+ width: "40%",
10
+ backgroundColor: colors.gray[200],
11
+ borderRadius: radii[6],
12
+ animationKeyframes: {
13
+ "50%": {
14
+ opacity: 0.6,
15
+ },
16
+ },
17
+ animationDuration: "2000ms",
18
+ animationTimingFunction: "linear",
19
+ animationIterationCount: "infinite",
20
+ },
21
+ placeholderText: {
22
+ height: 10,
23
+ width: "50%",
24
+ backgroundColor: colors.gray[100],
25
+ borderRadius: radii[6],
26
+ marginVertical: 24,
27
+ },
28
+ content: {
29
+ animationKeyframes: {
30
+ "50%": {
31
+ opacity: 0.6,
32
+ },
33
+ },
34
+ animationDuration: "2000ms",
35
+ animationTimingFunction: "linear",
36
+ animationIterationCount: "infinite",
37
+ },
38
+ withTabs: {
39
+ // This is the actual height of spacing + tab bar
40
+ // TODO: Make a shared (non-per-app) TabView for that, and providing Link/Router from outside
41
+ paddingTop: 61,
42
+ },
43
+ });
44
+ export const TilePlaceholder = () => {
45
+ return (_jsx(Tile, { title: _jsx(View, { style: styles.placeholderTitle }), children: _jsxs(View, { style: styles.content, children: [_jsx(View, { style: styles.placeholderText }), _jsx(View, { style: styles.placeholderText }), _jsx(View, { style: styles.placeholderText }), _jsx(View, { style: styles.placeholderText })] }) }));
46
+ };
47
+ export const TileGridPlaceholder = ({ numberOfItems = 2, withTabs = true, }) => {
48
+ return (_jsx(View, { style: withTabs && styles.withTabs, children: _jsx(TileGrid, { children: useMemo(() => Array(numberOfItems)
49
+ .fill(null)
50
+ .map((_, index) => _jsx(TilePlaceholder, {}, `placeholder-${index}`)), [numberOfItems]) }) }));
51
+ };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const ToastStack: () => JSX.Element | null;
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Box } from "@swan-io/lake/src/components/Box";
3
+ import { Portal } from "@swan-io/lake/src/components/Portal";
4
+ import { animations, colors, shadows } from "@swan-io/lake/src/constants/design";
5
+ import { memo, useEffect, useState } from "react";
6
+ import { Animated, StyleSheet, View } from "react-native";
7
+ import { match } from "ts-pattern";
8
+ import { hideToast, useToasts } from "../state/toasts";
9
+ import { Icon } from "./Icon";
10
+ import { LakeText } from "./LakeText";
11
+ import { Pressable } from "./Pressable";
12
+ import { Space } from "./Space";
13
+ import { TransitionGroupView } from "./TransitionGroupView";
14
+ const styles = StyleSheet.create({
15
+ list: {
16
+ position: "absolute",
17
+ right: 0,
18
+ bottom: 0,
19
+ maxHeight: "100%",
20
+ maxWidth: 400,
21
+ paddingVertical: 8,
22
+ width: "100%",
23
+ zIndex: 10,
24
+ },
25
+ toastWrapper: {
26
+ paddingHorizontal: 16,
27
+ paddingVertical: 8,
28
+ },
29
+ toast: {
30
+ padding: 24,
31
+ borderRadius: 4,
32
+ borderWidth: 1,
33
+ borderLeftWidth: 4,
34
+ overflow: "hidden",
35
+ boxShadow: shadows.modal,
36
+ },
37
+ contentContainer: {
38
+ paddingRight: 36, // 24 for close button + 12 for spacing
39
+ },
40
+ closeButton: {
41
+ zIndex: 1,
42
+ position: "absolute",
43
+ width: 24,
44
+ height: 24,
45
+ right: 24,
46
+ top: 0,
47
+ bottom: 0,
48
+ margin: "auto",
49
+ },
50
+ progressBar: {
51
+ height: 2,
52
+ transformOrigin: "left",
53
+ },
54
+ });
55
+ const Toast = memo(({ variant, uid, title, description, progress, onClose }) => {
56
+ const colorVariation = match(variant)
57
+ .with("success", () => "positive")
58
+ .with("error", () => "negative")
59
+ .with("info", () => "shakespear")
60
+ .with("warning", () => "warning")
61
+ .exhaustive();
62
+ return (_jsx(View, { style: styles.toastWrapper, children: _jsxs(View, { style: [
63
+ styles.toast,
64
+ {
65
+ borderColor: colors[colorVariation][200],
66
+ borderLeftColor: colors[colorVariation][500],
67
+ backgroundColor: colors[colorVariation][0],
68
+ },
69
+ ], children: [_jsxs(Box, { style: styles.contentContainer, children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [match(variant)
70
+ .with("success", () => (_jsx(Icon, { name: "checkmark-circle-regular", size: 20, color: colors[colorVariation][700] })))
71
+ .with("error", () => (_jsx(Icon, { name: "dismiss-circle-regular", size: 20, color: colors[colorVariation][700] })))
72
+ .with("info", () => (_jsx(Icon, { name: "info-regular", size: 20, color: colors[colorVariation][700] })))
73
+ .with("warning", () => (_jsx(Icon, { name: "warning-regular", size: 20, color: colors[colorVariation][700] })))
74
+ .exhaustive(), _jsx(Space, { width: 12 }), _jsx(LakeText, { variant: "regular", color: colors[colorVariation][700], children: title })] }), description != null && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 8 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[700], children: description })] }))] }), _jsx(Pressable, { onPress: () => onClose(uid), style: styles.closeButton, children: _jsx(Icon, { name: "lake-close", size: 24, color: colors.gray[500] }) }), progress != null && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 24 }), _jsx(Animated.View, { accessibilityRole: "progressbar", style: [
75
+ styles.progressBar,
76
+ { backgroundColor: colors[colorVariation][500] },
77
+ { transform: [{ scaleX: progress }] },
78
+ ] })] }))] }) }));
79
+ });
80
+ export const ToastStack = () => {
81
+ const toasts = useToasts();
82
+ const [rootElement, setRootElement] = useState(() => undefined);
83
+ useEffect(() => {
84
+ const rootElement = document.createElement("div");
85
+ document.body.append(rootElement);
86
+ setRootElement(rootElement);
87
+ return () => {
88
+ rootElement.remove();
89
+ setRootElement(undefined);
90
+ };
91
+ }, []);
92
+ if (rootElement == null) {
93
+ return null;
94
+ }
95
+ return (_jsx(Portal, { container: rootElement, children: _jsx(TransitionGroupView, { style: styles.list, enter: animations.fadeAndSlideInFromRight.enter, leave: animations.fadeAndSlideInFromRight.leave, children: toasts.map(toast => (_jsx(Toast, { uid: toast.uid, variant: toast.variant, progress: toast.progress, title: toast.title, description: toast.description, onClose: hideToast }, toast.uid))) }) }));
96
+ };
@@ -0,0 +1,18 @@
1
+ import { ReactNode, RefObject } from "react";
2
+ type Props = {
3
+ children: ReactNode;
4
+ describedBy?: string;
5
+ matchReferenceWidth?: boolean;
6
+ onHide?: () => void;
7
+ onShow?: () => void;
8
+ placement: "top" | "bottom";
9
+ referenceRef: RefObject<unknown>;
10
+ width?: number;
11
+ togglableOnFocus?: boolean;
12
+ };
13
+ export type TooltipRef = {
14
+ show: () => void;
15
+ hide: () => void;
16
+ };
17
+ export declare const Tooltip: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<TooltipRef>>>;
18
+ export {};
@@ -0,0 +1,162 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from "react";
3
+ import { StyleSheet, Text, View } from "react-native";
4
+ import { usePopper } from "react-popper";
5
+ import { colors } from "../constants/colors";
6
+ import { shadows } from "../constants/design";
7
+ import { typography } from "../constants/typography";
8
+ import { useHover } from "../hooks/useHover";
9
+ import { isNullish } from "../utils/nullish";
10
+ import { getRootElement, matchReferenceWidthModifier } from "../utils/popper";
11
+ import { Portal } from "./Portal";
12
+ const { matches: canHover } = window.matchMedia("(hover: hover)");
13
+ const styles = StyleSheet.create({
14
+ base: {
15
+ alignItems: "center",
16
+ },
17
+ baseTop: {
18
+ marginBottom: 8,
19
+ },
20
+ baseBottom: {
21
+ marginTop: 8,
22
+ },
23
+ content: {
24
+ padding: 8,
25
+ backgroundColor: colors.white,
26
+ color: colors.gray[80],
27
+ borderRadius: 4,
28
+ borderWidth: 1,
29
+ borderColor: colors.gray[10],
30
+ boxShadow: shadows.modal,
31
+ },
32
+ text: {
33
+ ...typography.bodySmall,
34
+ fontWeight: typography.fontWeights.book,
35
+ lineHeight: typography.lineHeights.input,
36
+ color: colors.gray[80],
37
+ textAlign: "center",
38
+ },
39
+ arrowContainer: {
40
+ position: "absolute",
41
+ left: 0,
42
+ right: 0,
43
+ margin: "auto",
44
+ width: 14,
45
+ height: 10,
46
+ overflow: "hidden",
47
+ },
48
+ arrowContainerTop: {
49
+ bottom: -7,
50
+ },
51
+ arrowContainerBottom: {
52
+ top: -7,
53
+ },
54
+ arrow: {
55
+ position: "relative",
56
+ top: -7,
57
+ height: 14,
58
+ width: 14,
59
+ backgroundColor: colors.white,
60
+ borderWidth: 1,
61
+ borderColor: colors.gray[10],
62
+ transform: [{ rotate: "45deg" }],
63
+ },
64
+ });
65
+ const isReactText = (node) => ["string", "number"].includes(typeof node);
66
+ export const Tooltip = memo(forwardRef(({ children, describedBy, matchReferenceWidth = false, onHide, onShow, placement, referenceRef, width, togglableOnFocus = false, }, forwardedRef) => {
67
+ const rootElement = getRootElement(referenceRef.current);
68
+ const [popperElement, setPopperElement] = useState(null);
69
+ const timeoutRef = useRef(0);
70
+ const [visible, setVisible] = useState(false);
71
+ const [, setMounted] = useState(false);
72
+ useEffect(() => {
73
+ setMounted(true);
74
+ }, []);
75
+ useImperativeHandle(forwardedRef, () => ({
76
+ show: () => setVisible(true),
77
+ hide: () => setVisible(false),
78
+ }));
79
+ useHover(referenceRef, {
80
+ disabled: !canHover,
81
+ contain: true,
82
+ onHoverChange: nextVisible => {
83
+ nextVisible ? onShow?.() : onHide?.();
84
+ setVisible(nextVisible);
85
+ },
86
+ });
87
+ const { attributes, update, styles: popperStyles, state, } = usePopper(referenceRef.current, popperElement, {
88
+ placement,
89
+ modifiers: useMemo(() => [
90
+ { name: "preventOverflow", enabled: true },
91
+ { name: "flip", enabled: false },
92
+ { name: "hide", enabled: true },
93
+ { ...matchReferenceWidthModifier, enabled: matchReferenceWidth },
94
+ ], [matchReferenceWidth]),
95
+ });
96
+ const overflowOffset = state?.modifiersData.preventOverflow?.x ?? 0;
97
+ useEffect(() => {
98
+ const node = referenceRef.current;
99
+ if (!(node instanceof Element)) {
100
+ return;
101
+ }
102
+ const onFocus = (event) => {
103
+ event.preventDefault();
104
+ setVisible(true);
105
+ };
106
+ const onBlur = (event) => {
107
+ event.preventDefault();
108
+ const { target } = event;
109
+ if (target instanceof Element && (node === target || node.contains(target))) {
110
+ onHide?.();
111
+ setVisible(false);
112
+ }
113
+ };
114
+ const onPress = (event) => {
115
+ event.preventDefault();
116
+ if (!canHover) {
117
+ clearTimeout(timeoutRef.current);
118
+ setVisible(true);
119
+ timeoutRef.current = setTimeout(() => {
120
+ setVisible(false);
121
+ }, 1500);
122
+ }
123
+ };
124
+ if (togglableOnFocus) {
125
+ node.addEventListener("focus", onFocus);
126
+ node.addEventListener("blur", onBlur);
127
+ }
128
+ node.addEventListener("mousedown", onPress);
129
+ return () => {
130
+ if (togglableOnFocus) {
131
+ node.removeEventListener("focus", onFocus);
132
+ node.removeEventListener("blur", onBlur);
133
+ }
134
+ node.removeEventListener("mousedown", onPress);
135
+ };
136
+ }, [referenceRef, togglableOnFocus, setVisible, onHide]);
137
+ useEffect(() => {
138
+ return () => clearTimeout(timeoutRef.current);
139
+ }, []);
140
+ useLayoutEffect(() => {
141
+ void update?.();
142
+ // eslint-disable-next-line react-hooks/exhaustive-deps
143
+ }, [children]);
144
+ if (isNullish(rootElement) || !visible) {
145
+ return null;
146
+ }
147
+ return (_jsx(Portal, { container: rootElement, children: _jsx("div", { ref: setPopperElement, style: popperStyles.popper, ...attributes.popper, role: "tooltip", "aria-describedby": describedBy, children: _jsxs(View, { style: [
148
+ styles.base,
149
+ state?.placement === "top" && styles.baseTop,
150
+ state?.placement === "bottom" && styles.baseBottom,
151
+ ], children: [_jsx(View, { style: [styles.content, { width }], children: isReactText(children) ? _jsx(Text, { style: styles.text, children: children }) : children }), _jsx(View, { accessibilityRole: "none", style: [
152
+ styles.arrowContainer,
153
+ state?.placement === "top" && styles.arrowContainerTop,
154
+ state?.placement === "bottom" && styles.arrowContainerBottom,
155
+ {
156
+ transform: [
157
+ { translateX: -overflowOffset },
158
+ { rotate: state?.placement === "bottom" ? "180deg" : "0deg" },
159
+ ],
160
+ },
161
+ ], children: _jsx(View, { style: styles.arrow }) })] }) }) }));
162
+ }));
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from "react";
2
+ import { AnimationStyles, StyleProp, ViewProps, ViewStyle } from "react-native";
3
+ type Props = {
4
+ enter?: AnimationStyles;
5
+ leave?: AnimationStyles;
6
+ style?: StyleProp<ViewStyle>;
7
+ childStyle?: StyleProp<ViewStyle>;
8
+ pointerEvents?: ViewProps["pointerEvents"];
9
+ children: ReactNode;
10
+ };
11
+ export declare const TransitionGroupView: ({ children, enter, leave, style, childStyle, pointerEvents, }: Props) => JSX.Element;
12
+ export {};
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Array, Option } from "@swan-io/boxed";
3
+ import { Children, useMemo, useReducer, useRef } from "react";
4
+ import { View } from "react-native";
5
+ import { match, P } from "ts-pattern";
6
+ import { usePreviousValue } from "../hooks/usePreviousValue";
7
+ import { TransitionView } from "./TransitionView";
8
+ export const TransitionGroupView = ({ children, enter, leave, style, childStyle, pointerEvents, }) => {
9
+ const leavingKeysAndIndicesRef = useRef([]);
10
+ const [, forceUpdate] = useReducer(() => [], []);
11
+ const onLeave = (key) => {
12
+ leavingKeysAndIndicesRef.current = leavingKeysAndIndicesRef.current.filter(leavingKey => leavingKey.key !== key);
13
+ forceUpdate();
14
+ };
15
+ const cleanedUpChildren = useMemo(() => Array.keepMap(Children.toArray(children), child => match(child)
16
+ .with({ key: P.string }, child => Option.Some({ key: child.key, child }))
17
+ .otherwise(() => Option.None())), [children]);
18
+ const previousChildren = usePreviousValue(cleanedUpChildren);
19
+ const newKeys = new Set(cleanedUpChildren.map(item => item.key));
20
+ leavingKeysAndIndicesRef.current = [
21
+ ...leavingKeysAndIndicesRef.current,
22
+ ...Array.keepMap(previousChildren.map((item, index) => ({ item, index })), ({ item, index }) => newKeys.has(item.key) ||
23
+ leavingKeysAndIndicesRef.current.find(prev => prev.key === item.key)
24
+ ? Option.None()
25
+ : Option.Some({ key: item.key, index })),
26
+ ];
27
+ const childrenToRender = [];
28
+ cleanedUpChildren.forEach((item, index) => {
29
+ childrenToRender.push({ key: item.key, originalIndex: index, child: item.child });
30
+ });
31
+ leavingKeysAndIndicesRef.current.forEach(({ index, key }) => {
32
+ const closerIndex = childrenToRender.findIndex(item => item.originalIndex === index);
33
+ if (closerIndex === -1) {
34
+ childrenToRender.push({ key, originalIndex: index, child: null });
35
+ }
36
+ else {
37
+ childrenToRender.splice(closerIndex, 0, { key, originalIndex: index, child: null });
38
+ }
39
+ });
40
+ return (_jsx(View, { style: style, children: childrenToRender.map(({ key, child }) => {
41
+ return (_jsx(TransitionView, { enter: enter, leave: leave, style: childStyle, pointerEvents: pointerEvents, onLeave: () => onLeave(key), children: child }, key));
42
+ }) }));
43
+ };
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from "react";
2
+ import { AnimationStyles, StyleProp, ViewProps, ViewStyle } from "react-native";
3
+ type Props = {
4
+ enter?: AnimationStyles;
5
+ leave?: AnimationStyles;
6
+ style?: StyleProp<ViewStyle>;
7
+ pointerEvents?: ViewProps["pointerEvents"];
8
+ children: ReactNode | null;
9
+ onLeave?: () => void;
10
+ };
11
+ export declare const TransitionView: ({ enter, leave, style, children, pointerEvents, onLeave, }: Props) => JSX.Element | null;
12
+ export {};
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useLayoutEffect, useReducer, useRef } from "react";
3
+ import { StyleSheet, View } from "react-native";
4
+ import { usePreviousValue } from "../hooks/usePreviousValue";
5
+ import { isNotNullish, isNullish } from "../utils/nullish";
6
+ const styles = StyleSheet.create({
7
+ base: {
8
+ animationFillMode: "forwards",
9
+ },
10
+ });
11
+ export const TransitionView = ({ enter, leave, style, children, pointerEvents, onLeave, }) => {
12
+ const viewRef = useRef(null);
13
+ const childrenForLeaveAnimationRef = useRef(null);
14
+ const [, forceUpdate] = useReducer(() => [], []);
15
+ const previousChildren = usePreviousValue(children);
16
+ if (isNullish(children) && isNotNullish(previousChildren) && isNotNullish(leave)) {
17
+ childrenForLeaveAnimationRef.current = previousChildren;
18
+ }
19
+ // Cleanup in case children reappear before the animation has performed
20
+ if (isNotNullish(children) && isNullish(previousChildren)) {
21
+ childrenForLeaveAnimationRef.current = null;
22
+ }
23
+ useLayoutEffect(() => {
24
+ if (isNullish(children) && isNotNullish(leave) && isNotNullish(viewRef.current)) {
25
+ const element = viewRef.current;
26
+ const onAnimationEnd = () => {
27
+ childrenForLeaveAnimationRef.current = null;
28
+ forceUpdate();
29
+ onLeave?.();
30
+ element.removeEventListener("animationend", onAnimationEnd);
31
+ };
32
+ element.addEventListener("animationend", onAnimationEnd);
33
+ return () => element.removeEventListener("animationend", onAnimationEnd);
34
+ }
35
+ }, [children, leave, onLeave]);
36
+ const hasChildrenToDisplay = isNotNullish(children) || isNotNullish(childrenForLeaveAnimationRef.current);
37
+ return hasChildrenToDisplay ? (_jsx(View, { pointerEvents: pointerEvents, ref: viewRef, style: [
38
+ styles.base,
39
+ style,
40
+ enter,
41
+ isNotNullish(childrenForLeaveAnimationRef.current) && leave,
42
+ ], children: children ?? childrenForLeaveAnimationRef.current })) : null;
43
+ };
@@ -0,0 +1,12 @@
1
+ import { MutableRefObject, ReactElement } from "react";
2
+ import { ViewProps } from "react-native";
3
+ import { ColorVariants } from "../constants/design";
4
+ type Props = {
5
+ variant?: ColorVariants;
6
+ style?: ViewProps["style"];
7
+ children: ReactElement;
8
+ };
9
+ export declare const CurrentColorContext: import("react").Context<"warning" | "current" | "gray" | "live" | "sandbox" | "positive" | "negative" | "partner" | "swan" | "shakespear" | "darkPink" | "sunglow" | "mediumSladeBlue" | undefined>;
10
+ export declare const useCurrentColor: (containerRef: MutableRefObject<HTMLElement | null>, variant: ColorVariants | undefined) => void;
11
+ export declare const WithCurrentColor: ({ variant, style, children }: Props) => JSX.Element;
12
+ export {};
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useLayoutEffect, useRef } from "react";
3
+ import { StyleSheet, View } from "react-native";
4
+ import { colors } from "../constants/design";
5
+ import { isNotNullish } from "../utils/nullish";
6
+ const styles = StyleSheet.create({
7
+ container: {
8
+ flexGrow: 1,
9
+ flexDirection: "column",
10
+ alignItems: "stretch",
11
+ flexBasis: "0%",
12
+ },
13
+ });
14
+ export const CurrentColorContext = createContext(undefined);
15
+ export const useCurrentColor = (containerRef, variant) => {
16
+ useLayoutEffect(() => {
17
+ if (isNotNullish(containerRef.current) && variant != null) {
18
+ const element = containerRef.current;
19
+ const colorScale = colors[variant];
20
+ const style = element.style;
21
+ const original = {
22
+ "--color-current-900": style.getPropertyValue("--color-current-900"),
23
+ "--color-current-800": style.getPropertyValue("--color-current-800"),
24
+ "--color-current-700": style.getPropertyValue("--color-current-700"),
25
+ "--color-current-600": style.getPropertyValue("--color-current-600"),
26
+ "--color-current-500": style.getPropertyValue("--color-current-500"),
27
+ "--color-current-400": style.getPropertyValue("--color-current-400"),
28
+ "--color-current-300": style.getPropertyValue("--color-current-300"),
29
+ "--color-current-200": style.getPropertyValue("--color-current-200"),
30
+ "--color-current-100": style.getPropertyValue("--color-current-100"),
31
+ "--color-current-primary": style.getPropertyValue("--color-current-primary"),
32
+ "--color-current-secondary": style.getPropertyValue("--color-current-secondary"),
33
+ "--color-current-contrast": style.getPropertyValue("--color-current-contrast"),
34
+ };
35
+ style.setProperty("--color-current-900", colorScale[900], "");
36
+ style.setProperty("--color-current-800", colorScale[800], "");
37
+ style.setProperty("--color-current-700", colorScale[700], "");
38
+ style.setProperty("--color-current-600", colorScale[600], "");
39
+ style.setProperty("--color-current-500", colorScale[500], "");
40
+ style.setProperty("--color-current-400", colorScale[400], "");
41
+ style.setProperty("--color-current-300", colorScale[300], "");
42
+ style.setProperty("--color-current-200", colorScale[200], "");
43
+ style.setProperty("--color-current-100", colorScale[100], "");
44
+ style.setProperty("--color-current-50", colorScale[50], "");
45
+ style.setProperty("--color-current-primary", colorScale.primary, "");
46
+ style.setProperty("--color-current-secondary", colorScale.secondary, "");
47
+ style.setProperty("--color-current-contrast", colorScale.contrast, "");
48
+ return () => {
49
+ Object.entries(original).forEach(([key, value]) => {
50
+ if (value == null) {
51
+ style.removeProperty(key);
52
+ }
53
+ else {
54
+ style.setProperty(key, value, "");
55
+ }
56
+ });
57
+ };
58
+ }
59
+ }, [containerRef, variant]);
60
+ };
61
+ export const WithCurrentColor = ({ variant, style, children }) => {
62
+ const containerRef = useRef(null);
63
+ useCurrentColor(containerRef, variant);
64
+ return (_jsx(CurrentColorContext.Provider, { value: variant, children: _jsx(View, { style: style ?? styles.container, ref: containerRef, children: children }) }));
65
+ };