@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,134 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Option } from "@swan-io/boxed";
3
+ import { Link } from "@swan-io/chicane";
4
+ import { StyleSheet, View } from "react-native";
5
+ import { match, P } from "ts-pattern";
6
+ import { colors } from "../constants/design";
7
+ import { Box } from "./Box";
8
+ import { Grid } from "./Grid";
9
+ import { LakeHeading } from "./LakeHeading";
10
+ import { LakeText } from "./LakeText";
11
+ import { Space } from "./Space";
12
+ const linkStyle = {
13
+ textDecoration: "none",
14
+ };
15
+ const styles = StyleSheet.create({
16
+ bar: {
17
+ width: "100%",
18
+ height: 4,
19
+ borderRadius: 2,
20
+ backgroundColor: colors.gray[100],
21
+ overflow: "hidden",
22
+ transformOrigin: "bottom",
23
+ transform: [{ scaleY: 0.5 }],
24
+ transitionDuration: "300ms",
25
+ transitionProperty: "transform",
26
+ },
27
+ barActive: {
28
+ transform: [{ scaleY: 1 }],
29
+ },
30
+ progressBar: {
31
+ width: "100%",
32
+ height: "100%",
33
+ backgroundColor: colors.current[500],
34
+ transformOrigin: "left",
35
+ transform: [{ scaleX: 0 }],
36
+ transitionDuration: "300ms",
37
+ },
38
+ progressBarDone: {
39
+ transform: [{ scaleX: 1 }],
40
+ },
41
+ progressBarError: {
42
+ backgroundColor: colors.negative[500],
43
+ },
44
+ mobileContainer: {
45
+ borderBottomWidth: 1,
46
+ borderBottomColor: colors.gray[100],
47
+ paddingBottom: 10,
48
+ },
49
+ mobileNumber: {
50
+ minWidth: 28,
51
+ height: 24,
52
+ borderRadius: 12,
53
+ borderWidth: 1,
54
+ borderColor: colors.current[100],
55
+ backgroundColor: colors.current[50],
56
+ },
57
+ mobileNumberError: {
58
+ borderColor: colors.negative[100],
59
+ backgroundColor: colors.negative[50],
60
+ },
61
+ });
62
+ const StepLink = ({ to, disabled, style, children }) => {
63
+ return disabled ? (_jsx("span", { style: style, children: children })) : (_jsx(Link, { to: to, style: style, children: children }));
64
+ };
65
+ export const LakeStepper = ({ steps, activeStepId, style }) => {
66
+ const stepIds = steps
67
+ .map(step => match(step)
68
+ .with({ id: P.string }, ({ id }) => [id])
69
+ .with({ children: P.array(P.any) }, ({ children }) => children.map(({ id }) => id))
70
+ .exhaustive())
71
+ .flat();
72
+ const activeStepIndex = stepIds.indexOf(activeStepId);
73
+ return (_jsx(Grid, { numColumns: steps.length, horizontalSpace: 12, style: style, children: steps.map((step, index) => {
74
+ const stepNumber = index + 1;
75
+ const currentId = match(step)
76
+ .with({ id: P.string }, ({ id }) => id)
77
+ .with({ children: P.array(P.any) }, ({ children }) => children[0]?.id ?? "")
78
+ .exhaustive();
79
+ const isActive = match(step)
80
+ .with({ id: activeStepId }, () => true)
81
+ .with({ children: P.array(P.any) }, ({ children }) => children.some(({ id }) => id === activeStepId))
82
+ .otherwise(() => false);
83
+ const isDone = match(step)
84
+ .with({ id: P.string }, ({ id }) => stepIds.indexOf(id) < activeStepIndex)
85
+ .with({ children: P.array(P.any) }, ({ children }) => children.every(({ id }) => stepIds.indexOf(id) < activeStepIndex))
86
+ .exhaustive();
87
+ const hasErrors = match(step)
88
+ .with({ hasErrors: true }, () => true)
89
+ .with({ children: P.array(P.any) }, ({ children }) => children.some(({ hasErrors }) => hasErrors))
90
+ .otherwise(() => false);
91
+ const stepUrl = match(step)
92
+ .with({ id: P.string }, ({ url }) => url)
93
+ .with({ children: P.array(P.any) }, ({ children }) => children[0]?.url ?? "")
94
+ .exhaustive();
95
+ const subSteps = match(step)
96
+ .with({ id: P.string }, step => [step])
97
+ .with({ children: P.array(P.any) }, ({ children }) => children)
98
+ .exhaustive();
99
+ return (_jsxs(StepLink, { to: stepUrl, disabled: !isDone, style: linkStyle, children: [_jsxs(LakeText, { variant: isActive ? "medium" : "regular", color: hasErrors && (isDone || isActive)
100
+ ? colors.negative[500]
101
+ : isActive || isDone
102
+ ? colors.current[500]
103
+ : colors.gray[300], children: [stepNumber, ". ", step.label] }), _jsx(Space, { height: 12 }), _jsx(Grid, { numColumns: subSteps.length, horizontalSpace: 12, children: subSteps.map(subStep => {
104
+ const isActive = subStep.id === activeStepId;
105
+ const isDone = stepIds.indexOf(subStep.id) < activeStepIndex;
106
+ const hasErrors = subStep.hasErrors === true;
107
+ return (_jsx(View, { style: [styles.bar, isActive && styles.barActive], children: _jsx(View, { style: [
108
+ styles.progressBar,
109
+ (isActive || isDone) && styles.progressBarDone,
110
+ hasErrors && styles.progressBarError,
111
+ ] }) }, subStep.id));
112
+ }) })] }, currentId));
113
+ }) }));
114
+ };
115
+ export const MobileStepTitle = ({ steps, activeStepId }) => {
116
+ const currentStep = Option.fromNullable(steps
117
+ .map((step, index) => match(step)
118
+ .with({ id: P.string }, step => ({ ...step, number: `${index + 1}` }))
119
+ .with({ children: P.array(P.any) }, ({ children }) => children.map((child, subIndex) => ({
120
+ ...child,
121
+ number: `${index + 1}.${subIndex + 1}`,
122
+ })))
123
+ .exhaustive())
124
+ .flat()
125
+ .find(({ id }) => id === activeStepId)).map(({ label, hasErrors, number }) => ({
126
+ number,
127
+ label,
128
+ isErrorState: hasErrors === true,
129
+ }));
130
+ return currentStep.match({
131
+ Some: ({ number, label, isErrorState }) => (_jsxs(Box, { direction: "row", alignItems: "center", justifyContent: "center", style: styles.mobileContainer, children: [_jsx(Box, { alignItems: "center", justifyContent: "center", style: [styles.mobileNumber, isErrorState && styles.mobileNumberError], children: _jsx(LakeText, { variant: "smallMedium", color: isErrorState ? colors.negative[500] : colors.current[500], children: number }) }), _jsx(Space, { width: 8 }), _jsx(LakeHeading, { level: 4, variant: "h4", color: isErrorState ? colors.negative[500] : colors.current[500], children: label })] })),
132
+ None: () => null,
133
+ });
134
+ };
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from "react";
2
+ import { Text, TextProps } from "react-native";
3
+ declare const variants: {
4
+ semibold: import("react-native").TextStyle;
5
+ medium: import("react-native").TextStyle;
6
+ regular: import("react-native").TextStyle;
7
+ light: import("react-native").TextStyle;
8
+ smallSemibold: import("react-native").TextStyle;
9
+ smallMedium: import("react-native").TextStyle;
10
+ smallRegular: import("react-native").TextStyle;
11
+ };
12
+ export type TextVariant = keyof typeof variants;
13
+ export declare const LakeText: import("react").ForwardRefExoticComponent<TextProps & {
14
+ align?: "center" | "left" | "right" | undefined;
15
+ children: ReactNode;
16
+ color?: string | undefined;
17
+ variant?: "semibold" | "medium" | "regular" | "light" | "smallSemibold" | "smallMedium" | "smallRegular" | undefined;
18
+ } & import("react").RefAttributes<Text>>;
19
+ export {};
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { StyleSheet, Text } from "react-native";
4
+ import { texts } from "../constants/design";
5
+ import { isNotNullish } from "../utils/nullish";
6
+ const alignments = StyleSheet.create({
7
+ center: { textAlign: "center" },
8
+ left: { textAlign: "left" },
9
+ right: { textAlign: "right" },
10
+ });
11
+ const variants = StyleSheet.create({
12
+ semibold: texts.semibold,
13
+ medium: texts.medium,
14
+ regular: texts.regular,
15
+ light: texts.light,
16
+ smallSemibold: texts.smallSemibold,
17
+ smallMedium: texts.smallMedium,
18
+ smallRegular: texts.smallRegular,
19
+ });
20
+ export const LakeText = forwardRef(({ align = "left", children, color, style, variant = "regular", ...props }, forwardedRef) => (_jsx(Text, { ref: forwardedRef, style: [variants[variant], alignments[align], isNotNullish(color) && { color }, style], ...props, children: children })));
@@ -0,0 +1,36 @@
1
+ import { ChangeEventHandler, ReactNode } from "react";
2
+ import { TextInput, TextInputProps } from "react-native";
3
+ import { ColorVariants } from "../constants/design";
4
+ import { IconName } from "./Icon";
5
+ export type LakeTextInputProps = Omit<TextInputProps, "editable" | "onChange"> & {
6
+ error?: string;
7
+ readOnly?: boolean;
8
+ valid?: boolean;
9
+ disabled?: boolean;
10
+ color?: ColorVariants;
11
+ multiline?: boolean;
12
+ icon?: IconName;
13
+ unit?: string;
14
+ keyboardType?: TextInputProps["keyboardType"];
15
+ pattern?: string;
16
+ children?: ReactNode;
17
+ hideErrors?: boolean;
18
+ style?: TextInputProps["style"];
19
+ onChange?: ChangeEventHandler<HTMLInputElement>;
20
+ };
21
+ export declare const LakeTextInput: import("react").ForwardRefExoticComponent<Omit<TextInputProps, "editable" | "onChange"> & {
22
+ error?: string | undefined;
23
+ readOnly?: boolean | undefined;
24
+ valid?: boolean | undefined;
25
+ disabled?: boolean | undefined;
26
+ color?: "warning" | "current" | "gray" | "live" | "sandbox" | "positive" | "negative" | "partner" | "swan" | "shakespear" | "darkPink" | "sunglow" | "mediumSladeBlue" | undefined;
27
+ multiline?: boolean | undefined;
28
+ icon?: "lake-calendar-arrow-swap" | "lake-card" | "lake-card-one-off" | "lake-card-physical" | "lake-card-recurring" | "lake-card-single-use" | "lake-card-virtual" | "lake-chevron-double" | "lake-clipboard-bullet" | "lake-clock" | "lake-clock-arrow-swap" | "lake-close" | "lake-currencies" | "lake-delivery-grouped" | "lake-delivery-individual" | "lake-document-csv" | "lake-document-jpg" | "lake-document-pdf" | "lake-document-png" | "lake-document-xls" | "lake-email" | "lake-id-card" | "lake-inbox-empty" | "lake-menu" | "lake-people" | "lake-person-arrow-swap" | "lake-phone" | "lake-receipt" | "lake-settings" | "lake-signature" | "lake-transfer" | "lake-world-map" | "add-circle-filled" | "add-circle-regular" | "add-filled" | "approvals-app-filled" | "apps-list-filled" | "apps-list-regular" | "arrow-counterclockwise-filled" | "arrow-down-filled" | "arrow-down-regular" | "arrow-download-filled" | "arrow-left-filled" | "arrow-left-regular" | "arrow-right-filled" | "arrow-right-regular" | "arrow-swap-filled" | "arrow-swap-regular" | "arrow-up-filled" | "arrow-up-regular" | "beaker-filled" | "beaker-regular" | "board-regular" | "box-regular" | "building-bank-filled" | "building-bank-regular" | "building-filled" | "building-multiple-regular" | "building-regular" | "building-shop-regular" | "calendar-ltr-regular" | "cart-regular" | "chat-help-filled" | "chat-help-regular" | "checkmark-circle-regular" | "checkmark-filled" | "chevron-down-filled" | "chevron-left-filled" | "chevron-right-filled" | "chevron-up-down-regular" | "chevron-up-filled" | "clipboard-search-regular" | "clock-filled" | "clock-regular" | "cloud-sync-filled" | "cloud-sync-regular" | "code-filled" | "code-regular" | "color-regular" | "comment-note-regular" | "copy-filled" | "copy-regular" | "cursor-click-regular" | "database-filled" | "database-regular" | "delete-filled" | "delete-regular" | "desktop-regular" | "device-meeting-room-regular" | "dismiss-circle-regular" | "dismiss-filled" | "dismiss-regular" | "document-regular" | "earth-regular" | "edit-filled" | "edit-regular" | "error-circle-filled" | "error-circle-regular" | "eye-filled" | "eye-off-filled" | "eye-regular" | "filter-filled" | "flag-filled" | "flag-regular" | "flash-filled" | "flash-regular" | "form-new-filled" | "form-new-regular" | "hand-right-regular" | "image-add-filled" | "image-add-regular" | "image-filled" | "image-regular" | "info-filled" | "info-regular" | "key-regular" | "link-filled" | "live-filled" | "live-regular" | "lock-closed-filled" | "lock-closed-regular" | "lock-open-filled" | "lock-open-regular" | "mail-filled" | "mail-regular" | "money-regular" | "more-vertical-filled" | "open-filled" | "open-regular" | "options-regular" | "paint-brush-filled" | "paint-brush-regular" | "pause-regular" | "payment-filled" | "payment-regular" | "people-add-regular" | "people-community-filled" | "people-community-regular" | "people-filled" | "people-regular" | "people-team-regular" | "person-accounts-filled" | "person-accounts-regular" | "person-add-regular" | "person-call-filled" | "person-call-regular" | "person-filled" | "person-lock-regular" | "person-regular" | "phone-filled" | "phone-regular" | "pin-regular" | "play-filled" | "play-regular" | "preview-link-filled" | "question-circle-regular" | "rocket-regular" | "search-filled" | "send-filled" | "send-regular" | "settings-filled" | "settings-regular" | "shield-checkmark-filled" | "shield-checkmark-regular" | "shield-error-regular" | "shield-regular" | "sign-out-regular" | "signature-filled" | "signature-regular" | "subtract-circle-filled" | "subtract-circle-regular" | "target-arrow-regular" | "warning-filled" | "warning-regular" | "window-dev-tools-filled" | "window-dev-tools-regular" | undefined;
29
+ unit?: string | undefined;
30
+ keyboardType?: TextInputProps["keyboardType"];
31
+ pattern?: string | undefined;
32
+ children?: ReactNode;
33
+ hideErrors?: boolean | undefined;
34
+ style?: TextInputProps["style"];
35
+ onChange?: ChangeEventHandler<HTMLInputElement> | undefined;
36
+ } & import("react").RefAttributes<TextInput | null>>;
@@ -0,0 +1,154 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useRef, useState } from "react";
3
+ import { StyleSheet, TextInput, View, } from "react-native";
4
+ import { commonStyles } from "../constants/commonStyles";
5
+ import { backgroundColor, colors, radii, shadows, spacings, texts, } from "../constants/design";
6
+ import { useHover } from "../hooks/useHover";
7
+ import { useMergeRefs } from "../hooks/useMergeRefs";
8
+ import { useNativeProp } from "../hooks/useNativeProp";
9
+ import { isNotNullish, isNotNullishOrEmpty, isNullish } from "../utils/nullish";
10
+ import { Icon } from "./Icon";
11
+ import { LakeText } from "./LakeText";
12
+ const TRANSPARENT = "transparent";
13
+ const styles = StyleSheet.create({
14
+ root: {
15
+ flexGrow: 1,
16
+ flexDirection: "row",
17
+ },
18
+ container: {
19
+ flexGrow: 1,
20
+ flexShrink: 1,
21
+ flexDirection: "row",
22
+ alignItems: "stretch",
23
+ },
24
+ contents: {
25
+ flexGrow: 1,
26
+ flexShrink: 1,
27
+ flexDirection: "row",
28
+ alignItems: "stretch",
29
+ },
30
+ input: {
31
+ ...texts.regular,
32
+ paddingHorizontal: spacings[16],
33
+ outlineStyle: "none",
34
+ height: 40,
35
+ borderColor: colors.gray[100],
36
+ placeholderTextColor: colors.gray[400],
37
+ borderWidth: 1,
38
+ borderRadius: radii[6],
39
+ backgroundColor: backgroundColor.accented,
40
+ color: colors.gray[900],
41
+ width: "100%",
42
+ flexShrink: 1,
43
+ },
44
+ multilineInput: {
45
+ height: "auto",
46
+ padding: spacings[8],
47
+ },
48
+ inputWithUnit: {
49
+ borderTopRightRadius: 0,
50
+ borderBottomRightRadius: 0,
51
+ },
52
+ hovered: {
53
+ boxShadow: shadows.tile,
54
+ },
55
+ disabled: {
56
+ backgroundColor: colors.gray[50],
57
+ borderColor: colors.gray[50],
58
+ color: colors.gray[900],
59
+ cursor: "not-allowed",
60
+ },
61
+ readOnly: {
62
+ backgroundColor: colors.gray[50],
63
+ borderColor: colors.gray[50],
64
+ color: colors.gray[900],
65
+ },
66
+ withIcon: {
67
+ paddingLeft: spacings[48],
68
+ },
69
+ error: {
70
+ borderColor: colors.negative[400],
71
+ paddingRight: spacings[48],
72
+ },
73
+ valid: {
74
+ borderColor: colors.positive[500],
75
+ paddingRight: spacings[48],
76
+ },
77
+ readOnlyError: {
78
+ borderColor: TRANSPARENT,
79
+ paddingRight: spacings[32],
80
+ },
81
+ endIcon: {
82
+ position: "absolute",
83
+ right: spacings[16],
84
+ top: "50%",
85
+ transform: [{ translateY: "-50%" }],
86
+ },
87
+ icon: {
88
+ position: "absolute",
89
+ left: spacings[16],
90
+ top: "50%",
91
+ transform: [{ translateY: "-50%" }],
92
+ },
93
+ readOnlyEndIcon: {
94
+ right: 0,
95
+ },
96
+ errorText: {
97
+ paddingTop: spacings[4],
98
+ },
99
+ unit: {
100
+ backgroundColor: colors.gray[50],
101
+ paddingHorizontal: spacings[16],
102
+ paddingVertical: spacings[8],
103
+ maxHeight: 40,
104
+ borderTopRightRadius: radii[6],
105
+ borderBottomRightRadius: radii[6],
106
+ borderColor: colors.gray[100],
107
+ borderWidth: 1,
108
+ borderLeftWidth: 0,
109
+ flexShrink: 0,
110
+ },
111
+ unitDisabled: {
112
+ borderColor: colors.gray[50],
113
+ },
114
+ focused: {
115
+ borderColor: colors.gray[500],
116
+ boxShadow: shadows.tile,
117
+ },
118
+ });
119
+ export const LakeTextInput = forwardRef(({ error, disabled = false, valid = false, readOnly = false, icon, children, unit, color = "gray", keyboardType = "default", hideErrors = false, onChange, pattern, style: stylesFromProps, onFocus: originalOnFocus, onBlur: originalOnBlur, value, defaultValue, multiline = false, ...props }, forwardRef) => {
120
+ const inputRef = useRef(null);
121
+ const [isHovered, setIsHovered] = useState(false);
122
+ const [isFocused, setIsFocused] = useState(false);
123
+ useNativeProp(inputRef, "pattern", pattern);
124
+ useHover(inputRef, {
125
+ onHoverStart: () => setIsHovered(true),
126
+ onHoverEnd: () => setIsHovered(false),
127
+ });
128
+ const onFocus = useCallback((event) => {
129
+ setIsFocused(true);
130
+ originalOnFocus?.(event);
131
+ }, [originalOnFocus]);
132
+ const onBlur = useCallback((event) => {
133
+ setIsFocused(false);
134
+ originalOnBlur?.(event);
135
+ }, [originalOnBlur]);
136
+ const mergedRef = useMergeRefs(inputRef, forwardRef);
137
+ const isInteractive = !disabled && !readOnly;
138
+ const hasError = isNotNullishOrEmpty(error);
139
+ return (_jsxs(View, { style: commonStyles.fill, children: [_jsxs(View, { style: styles.root, accessibilityErrorMessage: error, children: [_jsxs(View, { style: styles.container, children: [_jsxs(View, { style: styles.contents, children: [_jsx(TextInput, { keyboardType: keyboardType, ref: mergedRef, ...props, defaultValue: defaultValue, value: isNullish(defaultValue) ? value ?? "" : value, onFocus: onFocus, onBlur: onBlur, editable: isInteractive, onChange: onChange, multiline: multiline, style: [
140
+ styles.input,
141
+ multiline && styles.multilineInput,
142
+ hasError && styles.error,
143
+ valid && styles.valid,
144
+ isNotNullish(icon) && styles.withIcon,
145
+ readOnly && hasError && styles.readOnlyError,
146
+ disabled && styles.disabled,
147
+ readOnly && styles.readOnly,
148
+ isHovered && isInteractive && styles.hovered,
149
+ isNotNullish(unit) && styles.inputWithUnit,
150
+ isFocused && styles.focused,
151
+ isFocused && { borderColor: colors[color][500] },
152
+ stylesFromProps,
153
+ ] }), hasError && (_jsx(Icon, { name: "warning-regular", size: 20, color: colors.negative[400], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] })), !hasError && valid && (_jsx(Icon, { name: "checkmark-filled", size: 20, color: colors.positive[400], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] })), isNotNullish(icon) && (_jsx(Icon, { name: icon, size: 20, color: colors.current.primary, style: styles.icon }))] }), isNotNullish(unit) && (_jsx(LakeText, { color: colors.gray[900], style: [styles.unit, (disabled || readOnly) && styles.unitDisabled], children: unit }))] }), children] }), !hideErrors && (_jsx(LakeText, { color: colors.negative[400], style: styles.errorText, children: error ?? " " }))] }));
154
+ });
@@ -0,0 +1,24 @@
1
+ import { ReactNode } from "react";
2
+ import { ViewStyle } from "react-native";
3
+ type Props = {
4
+ children: ReactNode;
5
+ content: ReactNode;
6
+ describedBy?: string;
7
+ matchReferenceWidth?: boolean;
8
+ hideArrow?: boolean;
9
+ onHide?: () => void;
10
+ onShow?: () => void;
11
+ placement: "left" | "top" | "bottom" | "right";
12
+ width?: number;
13
+ togglableOnFocus?: boolean;
14
+ containerStyle?: ViewStyle;
15
+ };
16
+ type TooltipRef = {
17
+ show: () => void;
18
+ hide: () => void;
19
+ };
20
+ export declare const LakeTooltip: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<TooltipRef>>>;
21
+ export declare const InformationTooltip: ({ text }: {
22
+ text: string;
23
+ }) => JSX.Element;
24
+ export {};
@@ -0,0 +1,188 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from "react";
3
+ import { StyleSheet, View } from "react-native";
4
+ import { usePopper } from "react-popper";
5
+ import { match } from "ts-pattern";
6
+ import { colors, shadows } from "../constants/design";
7
+ import { useHover } from "../hooks/useHover";
8
+ import { isNullish } from "../utils/nullish";
9
+ import { getRootElement, matchReferenceWidthModifier } from "../utils/popper";
10
+ import { Icon } from "./Icon";
11
+ import { LakeText } from "./LakeText";
12
+ import { Portal } from "./Portal";
13
+ const { matches: canHover } = window.matchMedia("(hover: hover)");
14
+ const styles = StyleSheet.create({
15
+ base: {
16
+ alignItems: "center",
17
+ },
18
+ baseTop: {
19
+ marginBottom: 8,
20
+ },
21
+ baseBottom: {
22
+ marginTop: 8,
23
+ },
24
+ baseRight: {
25
+ marginLeft: 8,
26
+ },
27
+ baseLeft: {
28
+ marginRight: 8,
29
+ },
30
+ content: {
31
+ paddingVertical: 12,
32
+ paddingHorizontal: 20,
33
+ backgroundColor: colors.gray[900],
34
+ color: colors.gray.contrast,
35
+ borderRadius: 4,
36
+ borderWidth: 1,
37
+ borderColor: colors.gray[900],
38
+ boxShadow: shadows.modal,
39
+ },
40
+ arrowContainer: {
41
+ position: "absolute",
42
+ left: 0,
43
+ right: 0,
44
+ margin: "auto",
45
+ width: 14,
46
+ height: 10,
47
+ overflow: "hidden",
48
+ },
49
+ arrowContainerHorizontal: {
50
+ position: "absolute",
51
+ top: 0,
52
+ bottom: 0,
53
+ margin: "auto",
54
+ width: 14,
55
+ height: 10,
56
+ overflow: "hidden",
57
+ },
58
+ arrowContainerTop: {
59
+ bottom: -7,
60
+ },
61
+ arrowContainerBottom: {
62
+ top: -7,
63
+ },
64
+ arrowContainerRight: {
65
+ left: -7,
66
+ },
67
+ arrowContainerLeft: {
68
+ right: -7,
69
+ },
70
+ arrow: {
71
+ position: "relative",
72
+ top: -7,
73
+ height: 14,
74
+ width: 14,
75
+ backgroundColor: colors.gray[900],
76
+ borderWidth: 1,
77
+ borderColor: colors.gray[900],
78
+ transform: [{ rotate: "45deg" }],
79
+ },
80
+ info: {
81
+ flexGrow: 0,
82
+ },
83
+ });
84
+ const isReactText = (node) => ["string", "number"].includes(typeof node);
85
+ const MAX_WIDTH = "calc(100vw - 20px)";
86
+ export const LakeTooltip = memo(forwardRef(({ children, content, describedBy, matchReferenceWidth = false, hideArrow = false, onHide, onShow, placement, width, togglableOnFocus = false, containerStyle, }, forwardedRef) => {
87
+ const referenceRef = useRef(null);
88
+ const rootElement = getRootElement(referenceRef.current);
89
+ const [popperElement, setPopperElement] = useState(null);
90
+ const timeoutRef = useRef(0);
91
+ const [visible, setVisible] = useState(false);
92
+ useImperativeHandle(forwardedRef, () => ({
93
+ show: () => setVisible(true),
94
+ hide: () => setVisible(false),
95
+ }));
96
+ useHover(referenceRef, {
97
+ disabled: !canHover,
98
+ onHoverChange: nextVisible => {
99
+ nextVisible ? onShow?.() : onHide?.();
100
+ setVisible(nextVisible);
101
+ },
102
+ });
103
+ const { attributes, update, styles: popperStyles, state, } = usePopper(referenceRef.current, popperElement, {
104
+ placement,
105
+ modifiers: useMemo(() => [
106
+ { name: "preventOverflow", enabled: true, options: { padding: 10 } },
107
+ { name: "flip", enabled: false },
108
+ { name: "hide", enabled: true },
109
+ { ...matchReferenceWidthModifier, enabled: matchReferenceWidth },
110
+ ], [matchReferenceWidth]),
111
+ });
112
+ const overflowOffset = state?.modifiersData.preventOverflow?.x ?? 0;
113
+ useEffect(() => {
114
+ const node = referenceRef.current;
115
+ if (!(node instanceof Element)) {
116
+ return;
117
+ }
118
+ const onFocus = (event) => {
119
+ event.preventDefault();
120
+ setVisible(true);
121
+ };
122
+ const onBlur = (event) => {
123
+ event.preventDefault();
124
+ const { target } = event;
125
+ if (target instanceof Element && (node === target || node.contains(target))) {
126
+ onHide?.();
127
+ setVisible(false);
128
+ }
129
+ };
130
+ const onPress = (event) => {
131
+ event.preventDefault();
132
+ if (!canHover) {
133
+ clearTimeout(timeoutRef.current);
134
+ setVisible(true);
135
+ timeoutRef.current = setTimeout(() => {
136
+ setVisible(false);
137
+ }, 1500);
138
+ }
139
+ };
140
+ if (togglableOnFocus) {
141
+ node.addEventListener("focusin", onFocus);
142
+ node.addEventListener("focusout", onBlur);
143
+ }
144
+ node.addEventListener("mousedown", onPress);
145
+ return () => {
146
+ if (togglableOnFocus) {
147
+ node.removeEventListener("focusin", onFocus);
148
+ node.removeEventListener("focusout", onBlur);
149
+ }
150
+ node.removeEventListener("mousedown", onPress);
151
+ };
152
+ }, [referenceRef, togglableOnFocus, setVisible, onHide]);
153
+ useEffect(() => {
154
+ return () => clearTimeout(timeoutRef.current);
155
+ }, []);
156
+ useLayoutEffect(() => {
157
+ void update?.();
158
+ // eslint-disable-next-line react-hooks/exhaustive-deps
159
+ }, [content]);
160
+ return (_jsxs(_Fragment, { children: [_jsx(View, { ref: referenceRef, style: containerStyle, children: children }), isNullish(rootElement) || !visible ? null : (_jsx(Portal, { container: rootElement, children: _jsx("div", { ref: setPopperElement, style: { ...popperStyles.popper, maxWidth: MAX_WIDTH }, ...attributes.popper, role: "tooltip", "aria-describedby": describedBy, children: _jsxs(View, { style: [
161
+ styles.base,
162
+ state?.placement === "top" && styles.baseTop,
163
+ state?.placement === "bottom" && styles.baseBottom,
164
+ state?.placement === "right" && styles.baseRight,
165
+ state?.placement === "left" && styles.baseLeft,
166
+ ], children: [_jsx(View, { style: [styles.content, { width, maxWidth: MAX_WIDTH }], children: isReactText(content) ? (_jsx(LakeText, { align: "center", color: colors.gray.contrast, children: content })) : (content) }), !hideArrow && (_jsx(View, { accessibilityRole: "none", style: [
167
+ state?.placement === "right" || state?.placement === "left"
168
+ ? styles.arrowContainerHorizontal
169
+ : styles.arrowContainer,
170
+ state?.placement === "top" && styles.arrowContainerTop,
171
+ state?.placement === "bottom" && styles.arrowContainerBottom,
172
+ state?.placement === "right" && styles.arrowContainerRight,
173
+ state?.placement === "left" && styles.arrowContainerLeft,
174
+ {
175
+ transform: [
176
+ { translateX: -overflowOffset },
177
+ {
178
+ rotate: match(state?.placement)
179
+ .with("bottom", () => "180deg")
180
+ .with("left", () => "-90deg")
181
+ .with("right", () => "90deg")
182
+ .otherwise(() => "0deg"),
183
+ },
184
+ ],
185
+ },
186
+ ], children: _jsx(View, { style: styles.arrow }) }))] }) }) }))] }));
187
+ }));
188
+ export const InformationTooltip = ({ text }) => (_jsx(LakeTooltip, { describedBy: "copy", placement: "bottom", togglableOnFocus: true, width: 300, content: text, children: _jsx(View, { style: styles.info, children: _jsx(Icon, { name: "info-regular", size: 24, color: colors.gray[900] }) }) }));