@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.
- package/HISTORY.md +3 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/package.json +60 -0
- package/src/components/Alert.d.ts +10 -0
- package/src/components/Alert.js +36 -0
- package/src/components/AppOpeningAnimation.d.ts +10 -0
- package/src/components/AppOpeningAnimation.js +50 -0
- package/src/components/AutoWidthImage.d.ts +8 -0
- package/src/components/AutoWidthImage.js +26 -0
- package/src/components/Avatar.d.ts +7 -0
- package/src/components/Avatar.js +42 -0
- package/src/components/BorderedButton.d.ts +16 -0
- package/src/components/BorderedButton.js +98 -0
- package/src/components/BorderedIcon.d.ts +12 -0
- package/src/components/BorderedIcon.js +25 -0
- package/src/components/BottomPanel.d.ts +9 -0
- package/src/components/BottomPanel.js +94 -0
- package/src/components/Box.d.ts +65 -0
- package/src/components/Box.js +31 -0
- package/src/components/Breadcrumbs.d.ts +18 -0
- package/src/components/Breadcrumbs.js +362 -0
- package/src/components/Button.d.ts +15 -0
- package/src/components/Button.js +83 -0
- package/src/components/Caption.d.ts +6 -0
- package/src/components/Caption.js +11 -0
- package/src/components/Checkbox.d.ts +12 -0
- package/src/components/Checkbox.js +83 -0
- package/src/components/ChoicePicker.d.ts +11 -0
- package/src/components/ChoicePicker.js +99 -0
- package/src/components/Combobox.d.ts +29 -0
- package/src/components/Combobox.js +182 -0
- package/src/components/FailureIcon.d.ts +8 -0
- package/src/components/FailureIcon.js +4 -0
- package/src/components/FileTile.d.ts +11 -0
- package/src/components/FileTile.js +37 -0
- package/src/components/Fill.d.ts +8 -0
- package/src/components/Fill.js +24 -0
- package/src/components/FilterChooser.d.ts +15 -0
- package/src/components/FilterChooser.js +52 -0
- package/src/components/Filters.d.ts +57 -0
- package/src/components/Filters.js +229 -0
- package/src/components/FixedListView.d.ts +104 -0
- package/src/components/FixedListView.js +821 -0
- package/src/components/FixedListViewCells.d.ts +55 -0
- package/src/components/FixedListViewCells.js +157 -0
- package/src/components/Flag.d.ts +8 -0
- package/src/components/Flag.js +36 -0
- package/src/components/FlowPresentation.d.ts +12 -0
- package/src/components/FlowPresentation.js +70 -0
- package/src/components/FocusTrap.d.ts +16 -0
- package/src/components/FocusTrap.js +90 -0
- package/src/components/Form.d.ts +8 -0
- package/src/components/Form.js +17 -0
- package/src/components/FullViewportLayer.d.ts +7 -0
- package/src/components/FullViewportLayer.js +91 -0
- package/src/components/Grid.d.ts +13 -0
- package/src/components/Grid.js +33 -0
- package/src/components/Heading.d.ts +61 -0
- package/src/components/Heading.js +27 -0
- package/src/components/Icon.d.ts +191 -0
- package/src/components/Icon.js +11 -0
- package/src/components/Input.d.ts +34 -0
- package/src/components/Input.js +115 -0
- package/src/components/InputError.d.ts +8 -0
- package/src/components/InputError.js +16 -0
- package/src/components/Label.d.ts +10 -0
- package/src/components/Label.js +19 -0
- package/src/components/LakeAlert.d.ts +14 -0
- package/src/components/LakeAlert.js +75 -0
- package/src/components/LakeButton.d.ts +36 -0
- package/src/components/LakeButton.js +171 -0
- package/src/components/LakeCheckbox.d.ts +16 -0
- package/src/components/LakeCheckbox.js +54 -0
- package/src/components/LakeCombobox.d.ts +28 -0
- package/src/components/LakeCombobox.js +166 -0
- package/src/components/LakeCopyButton.d.ts +10 -0
- package/src/components/LakeCopyButton.js +16 -0
- package/src/components/LakeDownloadButton.d.ts +8 -0
- package/src/components/LakeDownloadButton.js +6 -0
- package/src/components/LakeHeading.d.ts +10 -0
- package/src/components/LakeHeading.js +19 -0
- package/src/components/LakeLabel.d.ts +19 -0
- package/src/components/LakeLabel.js +43 -0
- package/src/components/LakeModal.d.ts +14 -0
- package/src/components/LakeModal.js +132 -0
- package/src/components/LakeRadio.d.ts +9 -0
- package/src/components/LakeRadio.js +44 -0
- package/src/components/LakeScrollView.d.ts +10 -0
- package/src/components/LakeScrollView.js +35 -0
- package/src/components/LakeSearchField.d.ts +10 -0
- package/src/components/LakeSearchField.js +111 -0
- package/src/components/LakeSelect.d.ts +30 -0
- package/src/components/LakeSelect.js +183 -0
- package/src/components/LakeSlider.d.ts +12 -0
- package/src/components/LakeSlider.js +31 -0
- package/src/components/LakeStepper.d.ts +21 -0
- package/src/components/LakeStepper.js +134 -0
- package/src/components/LakeText.d.ts +19 -0
- package/src/components/LakeText.js +20 -0
- package/src/components/LakeTextInput.d.ts +36 -0
- package/src/components/LakeTextInput.js +154 -0
- package/src/components/LakeTooltip.d.ts +24 -0
- package/src/components/LakeTooltip.js +188 -0
- package/src/components/Link.d.ts +138 -0
- package/src/components/Link.js +23 -0
- package/src/components/ListRightPanel.d.ts +17 -0
- package/src/components/ListRightPanel.js +79 -0
- package/src/components/LoadingView.d.ts +9 -0
- package/src/components/LoadingView.js +24 -0
- package/src/components/Modal.d.ts +12 -0
- package/src/components/Modal.js +80 -0
- package/src/components/MultiSelect.d.ts +27 -0
- package/src/components/MultiSelect.js +223 -0
- package/src/components/MultilineInput.d.ts +15 -0
- package/src/components/MultilineInput.js +55 -0
- package/src/components/Picker.d.ts +26 -0
- package/src/components/Picker.js +116 -0
- package/src/components/PlainListView.d.ts +36 -0
- package/src/components/PlainListView.js +208 -0
- package/src/components/Popover.d.ts +23 -0
- package/src/components/Popover.js +147 -0
- package/src/components/PopoverContent.d.ts +8 -0
- package/src/components/PopoverContent.js +9 -0
- package/src/components/Portal.d.ts +7 -0
- package/src/components/Portal.js +9 -0
- package/src/components/Pressable.d.ts +348 -0
- package/src/components/Pressable.js +91 -0
- package/src/components/ProgressBar.d.ts +11 -0
- package/src/components/ProgressBar.js +46 -0
- package/src/components/ProjectEnvTag.d.ts +7 -0
- package/src/components/ProjectEnvTag.js +12 -0
- package/src/components/QuickActions.d.ts +15 -0
- package/src/components/QuickActions.js +38 -0
- package/src/components/RadioGroup.d.ts +16 -0
- package/src/components/RadioGroup.js +34 -0
- package/src/components/ReadOnlyFieldList.d.ts +6 -0
- package/src/components/ReadOnlyFieldList.js +8 -0
- package/src/components/ResponsiveContainer.d.ts +13 -0
- package/src/components/ResponsiveContainer.js +23 -0
- package/src/components/RightPanel.d.ts +10 -0
- package/src/components/RightPanel.js +102 -0
- package/src/components/SegmentedControl.d.ts +19 -0
- package/src/components/SegmentedControl.js +74 -0
- package/src/components/Separator.d.ts +10 -0
- package/src/components/Separator.js +19 -0
- package/src/components/SidebarNavigationTracker.d.ts +13 -0
- package/src/components/SidebarNavigationTracker.js +93 -0
- package/src/components/Slider.d.ts +11 -0
- package/src/components/Slider.js +119 -0
- package/src/components/SmsOpeningAnimation.d.ts +8 -0
- package/src/components/SmsOpeningAnimation.js +52 -0
- package/src/components/Space.d.ts +10 -0
- package/src/components/Space.js +23 -0
- package/src/components/Stack.d.ts +12 -0
- package/src/components/Stack.js +23 -0
- package/src/components/StepDots.d.ts +7 -0
- package/src/components/StepDots.js +24 -0
- package/src/components/Stepper.d.ts +9 -0
- package/src/components/Stepper.js +67 -0
- package/src/components/SuccessIcon.d.ts +8 -0
- package/src/components/SuccessIcon.js +4 -0
- package/src/components/Svg.d.ts +145 -0
- package/src/components/Svg.js +24 -0
- package/src/components/SwanLogo.d.ts +8 -0
- package/src/components/SwanLogo.js +11 -0
- package/src/components/Switch.d.ts +9 -0
- package/src/components/Switch.js +74 -0
- package/src/components/TabView.d.ts +16 -0
- package/src/components/TabView.js +398 -0
- package/src/components/Table.d.ts +34 -0
- package/src/components/Table.js +79 -0
- package/src/components/Tag.d.ts +17 -0
- package/src/components/Tag.js +76 -0
- package/src/components/Tile.d.ts +34 -0
- package/src/components/Tile.js +130 -0
- package/src/components/TilePlaceholder.d.ts +6 -0
- package/src/components/TilePlaceholder.js +51 -0
- package/src/components/ToastStack.d.ts +2 -0
- package/src/components/ToastStack.js +96 -0
- package/src/components/Tooltip.d.ts +18 -0
- package/src/components/Tooltip.js +162 -0
- package/src/components/TransitionGroupView.d.ts +12 -0
- package/src/components/TransitionGroupView.js +43 -0
- package/src/components/TransitionView.d.ts +12 -0
- package/src/components/TransitionView.js +43 -0
- package/src/components/WithCurrentColor.d.ts +12 -0
- package/src/components/WithCurrentColor.js +65 -0
- package/src/components/WithPartnerAccentColor.d.ts +7 -0
- package/src/components/WithPartnerAccentColor.js +91 -0
- package/src/constants/colors.d.ts +42 -0
- package/src/constants/colors.js +42 -0
- package/src/constants/commonStyles.d.ts +66 -0
- package/src/constants/commonStyles.js +45 -0
- package/src/constants/design.d.ts +168 -0
- package/src/constants/design.js +564 -0
- package/src/constants/insets.d.ts +10 -0
- package/src/constants/insets.js +22 -0
- package/src/constants/typography.d.ts +26 -0
- package/src/constants/typography.js +54 -0
- package/src/hooks/useAnimatedValue.d.ts +2 -0
- package/src/hooks/useAnimatedValue.js +3 -0
- package/src/hooks/useBodyClassName.d.ts +3 -0
- package/src/hooks/useBodyClassName.js +14 -0
- package/src/hooks/useBoolean.d.ts +8 -0
- package/src/hooks/useBoolean.js +12 -0
- package/src/hooks/useComputedColors.d.ts +10 -0
- package/src/hooks/useComputedColors.js +42 -0
- package/src/hooks/useDebounce.d.ts +1 -0
- package/src/hooks/useDebounce.js +12 -0
- package/src/hooks/useDisclosure.d.ts +8 -0
- package/src/hooks/useDisclosure.js +12 -0
- package/src/hooks/useFirstMountState.d.ts +1 -0
- package/src/hooks/useFirstMountState.js +9 -0
- package/src/hooks/useForceableState.d.ts +1 -0
- package/src/hooks/useForceableState.js +6 -0
- package/src/hooks/useHover.d.ts +11 -0
- package/src/hooks/useHover.js +4 -0
- package/src/hooks/useInterval.d.ts +1 -0
- package/src/hooks/useInterval.js +11 -0
- package/src/hooks/useLazyRef.d.ts +2 -0
- package/src/hooks/useLazyRef.js +9 -0
- package/src/hooks/useMergeRefs.d.ts +2 -0
- package/src/hooks/useMergeRefs.js +5 -0
- package/src/hooks/useNativeProp.d.ts +2 -0
- package/src/hooks/useNativeProp.js +9 -0
- package/src/hooks/useOutsideClick.d.ts +8 -0
- package/src/hooks/useOutsideClick.js +54 -0
- package/src/hooks/usePersistedState.d.ts +1 -0
- package/src/hooks/usePersistedState.js +21 -0
- package/src/hooks/usePressEvents.d.ts +31 -0
- package/src/hooks/usePressEvents.js +4 -0
- package/src/hooks/usePreviousValue.d.ts +1 -0
- package/src/hooks/usePreviousValue.js +8 -0
- package/src/hooks/useResponsive.d.ts +7 -0
- package/src/hooks/useResponsive.js +20 -0
- package/src/hooks/useUpdateEffect.d.ts +2 -0
- package/src/hooks/useUpdateEffect.js +10 -0
- package/src/hooks/useUrqlMutation.d.ts +4 -0
- package/src/hooks/useUrqlMutation.js +30 -0
- package/src/hooks/useUrqlQuery.d.ts +19 -0
- package/src/hooks/useUrqlQuery.js +73 -0
- package/src/state/toasts.d.ts +21 -0
- package/src/state/toasts.js +61 -0
- package/src/utils/__tests__/array.test.d.ts +1 -0
- package/src/utils/__tests__/array.test.js +127 -0
- package/src/utils/__tests__/base64.test.d.ts +1 -0
- package/src/utils/__tests__/base64.test.js +27 -0
- package/src/utils/__tests__/function.test.d.ts +1 -0
- package/src/utils/__tests__/function.test.js +36 -0
- package/src/utils/__tests__/object.test.d.ts +1 -0
- package/src/utils/__tests__/object.test.js +17 -0
- package/src/utils/__tests__/rifm.test.d.ts +1 -0
- package/src/utils/__tests__/rifm.test.js +124 -0
- package/src/utils/__tests__/string.test.d.ts +1 -0
- package/src/utils/__tests__/string.test.js +16 -0
- package/src/utils/a11y.d.ts +1 -0
- package/src/utils/a11y.js +18 -0
- package/src/utils/array.d.ts +6 -0
- package/src/utils/array.js +71 -0
- package/src/utils/base64.d.ts +2 -0
- package/src/utils/base64.js +20 -0
- package/src/utils/file.d.ts +2 -0
- package/src/utils/file.js +10 -0
- package/src/utils/flagCountry.d.ts +1 -0
- package/src/utils/flagCountry.js +1 -0
- package/src/utils/function.d.ts +4 -0
- package/src/utils/function.js +19 -0
- package/src/utils/math.d.ts +16 -0
- package/src/utils/math.js +47 -0
- package/src/utils/nullish.d.ts +10 -0
- package/src/utils/nullish.js +8 -0
- package/src/utils/object.d.ts +2 -0
- package/src/utils/object.js +7 -0
- package/src/utils/popper.d.ts +3 -0
- package/src/utils/popper.js +30 -0
- package/src/utils/rifm.d.ts +14 -0
- package/src/utils/rifm.js +53 -0
- package/src/utils/string.d.ts +4 -0
- package/src/utils/string.js +233 -0
- package/src/utils/timer.d.ts +11 -0
- package/src/utils/timer.js +46 -0
- package/src/utils/types.d.ts +8 -0
- package/src/utils/types.js +1 -0
- package/src/utils/userAgent.d.ts +4 -0
- package/src/utils/userAgent.js +9 -0
- package/src/utils/viewport.d.ts +1 -0
- package/src/utils/viewport.js +12 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, useEffect, useState } from "react";
|
|
3
|
+
import { ScrollView, StyleSheet, View } from "react-native";
|
|
4
|
+
import { commonStyles } from "../constants/commonStyles";
|
|
5
|
+
import { backgroundColor, breakpoints, colors, negativeSpacings, shadows, spacings, } from "../constants/design";
|
|
6
|
+
import { useBodyClassName } from "../hooks/useBodyClassName";
|
|
7
|
+
import { FocusTrap } from "./FocusTrap";
|
|
8
|
+
import { Icon } from "./Icon";
|
|
9
|
+
import { LakeButton } from "./LakeButton";
|
|
10
|
+
import { LakeHeading } from "./LakeHeading";
|
|
11
|
+
import { LoadingView } from "./LoadingView";
|
|
12
|
+
import { Portal } from "./Portal";
|
|
13
|
+
import { Pressable } from "./Pressable";
|
|
14
|
+
import { ResponsiveContainer } from "./ResponsiveContainer";
|
|
15
|
+
import { Space } from "./Space";
|
|
16
|
+
import { TransitionView } from "./TransitionView";
|
|
17
|
+
const BACKGROUND_COLOR = "rgba(0, 0, 0, 0.6)";
|
|
18
|
+
const styles = StyleSheet.create({
|
|
19
|
+
root: {
|
|
20
|
+
...StyleSheet.absoluteFillObject,
|
|
21
|
+
},
|
|
22
|
+
container: {
|
|
23
|
+
...StyleSheet.absoluteFillObject,
|
|
24
|
+
},
|
|
25
|
+
fill: {
|
|
26
|
+
...StyleSheet.absoluteFillObject,
|
|
27
|
+
animationFillMode: "forwards",
|
|
28
|
+
},
|
|
29
|
+
overlay: {
|
|
30
|
+
...StyleSheet.absoluteFillObject,
|
|
31
|
+
backgroundColor: BACKGROUND_COLOR,
|
|
32
|
+
},
|
|
33
|
+
overlayEnter: {
|
|
34
|
+
animationKeyframes: {
|
|
35
|
+
"0%": { opacity: 0 },
|
|
36
|
+
},
|
|
37
|
+
animationDuration: "200ms",
|
|
38
|
+
animationTimingFunction: "ease-in-out",
|
|
39
|
+
},
|
|
40
|
+
overlayLeave: {
|
|
41
|
+
animationKeyframes: {
|
|
42
|
+
"100%": { opacity: 0 },
|
|
43
|
+
},
|
|
44
|
+
animationDuration: "200ms",
|
|
45
|
+
animationTimingFunction: "ease-in-out",
|
|
46
|
+
},
|
|
47
|
+
modalEnter: {
|
|
48
|
+
animationKeyframes: {
|
|
49
|
+
"0%": {
|
|
50
|
+
opacity: 0,
|
|
51
|
+
transform: [{ translateY: -20 }],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
animationDuration: "300ms",
|
|
55
|
+
animationTimingFunction: "ease-in-out",
|
|
56
|
+
},
|
|
57
|
+
modalLeave: {
|
|
58
|
+
animationKeyframes: {
|
|
59
|
+
"100%": {
|
|
60
|
+
opacity: 0,
|
|
61
|
+
transform: [{ translateY: -20 }],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
animationDuration: "300ms",
|
|
65
|
+
animationTimingFunction: "ease-in-out",
|
|
66
|
+
},
|
|
67
|
+
modalContainer: {
|
|
68
|
+
...StyleSheet.absoluteFillObject,
|
|
69
|
+
},
|
|
70
|
+
modalContentContainer: {
|
|
71
|
+
padding: spacings[24],
|
|
72
|
+
justifyContent: "center",
|
|
73
|
+
flexGrow: 1,
|
|
74
|
+
},
|
|
75
|
+
modalContentContainerSmall: {
|
|
76
|
+
padding: spacings[8],
|
|
77
|
+
flexGrow: 1,
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
},
|
|
80
|
+
modal: {
|
|
81
|
+
backgroundColor: backgroundColor.default,
|
|
82
|
+
borderRadius: 24,
|
|
83
|
+
padding: spacings[48],
|
|
84
|
+
boxShadow: shadows.modal,
|
|
85
|
+
alignSelf: "stretch",
|
|
86
|
+
width: "100%",
|
|
87
|
+
marginHorizontal: "auto",
|
|
88
|
+
},
|
|
89
|
+
modalSmall: {
|
|
90
|
+
borderRadius: 16,
|
|
91
|
+
backgroundColor: backgroundColor.default,
|
|
92
|
+
width: "100%",
|
|
93
|
+
padding: spacings[24],
|
|
94
|
+
alignSelf: "stretch",
|
|
95
|
+
marginHorizontal: "auto",
|
|
96
|
+
},
|
|
97
|
+
modalHeader: {
|
|
98
|
+
display: "flex",
|
|
99
|
+
flexDirection: "row",
|
|
100
|
+
justifyContent: "space-between",
|
|
101
|
+
},
|
|
102
|
+
modalIconTitle: {
|
|
103
|
+
...commonStyles.fill,
|
|
104
|
+
},
|
|
105
|
+
trap: {
|
|
106
|
+
...commonStyles.fill,
|
|
107
|
+
},
|
|
108
|
+
pressableOverlay: {
|
|
109
|
+
...StyleSheet.absoluteFillObject,
|
|
110
|
+
},
|
|
111
|
+
closeButton: {
|
|
112
|
+
top: negativeSpacings[4],
|
|
113
|
+
right: negativeSpacings[4],
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
export const LakeModal = ({ visible, icon, title, color = "current", children, maxWidth = 570, onPressClose, }) => {
|
|
117
|
+
const [rootElement, setRootElement] = useState(() => undefined);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
const rootElement = document.createElement("div");
|
|
120
|
+
document.body.append(rootElement);
|
|
121
|
+
setRootElement(rootElement);
|
|
122
|
+
return () => {
|
|
123
|
+
rootElement.remove();
|
|
124
|
+
setRootElement(undefined);
|
|
125
|
+
};
|
|
126
|
+
}, []);
|
|
127
|
+
useBodyClassName("ModalOpen", { enabled: visible });
|
|
128
|
+
if (rootElement == null) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
return (_jsx(Portal, { container: rootElement, children: _jsxs(View, { accessibilityModal: true, style: styles.container, pointerEvents: visible ? "auto" : "none", children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? _jsx(View, { style: styles.overlay }) : null }), _jsx(Suspense, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: styles.fill, enter: styles.modalEnter, leave: styles.modalLeave, children: visible ? (_jsx(ResponsiveContainer, { style: styles.root, breakpoint: breakpoints.tiny, children: ({ large, small }) => (_jsx(FocusTrap, { autoFocus: true, focusLock: true, returnFocus: true, onEscapeKey: onPressClose, style: styles.trap, children: _jsxs(ScrollView, { style: styles.modalContainer, contentContainerStyle: large ? styles.modalContentContainer : styles.modalContentContainerSmall, children: [onPressClose != null ? (_jsx(Pressable, { onPress: onPressClose, style: styles.pressableOverlay })) : null, _jsxs(View, { style: [large ? styles.modal : styles.modalSmall, { maxWidth }], children: [_jsxs(View, { style: styles.modalHeader, children: [_jsxs(View, { style: styles.modalIconTitle, children: [icon != null ? (_jsx(Icon, { name: icon, size: large ? 40 : 32, color: colors[color].primary })) : null, icon != null && title != null ? _jsx(Space, { height: 12 }) : null, title != null ? (_jsxs(_Fragment, { children: [_jsx(LakeHeading, { level: 2, variant: "h3", children: title }), _jsx(Space, { height: 12 })] })) : null, icon != null && title != null ? _jsx(Space, { height: 8 }) : null] }), onPressClose != null ? (_jsx(LakeButton, { style: styles.closeButton, mode: "tertiary", onPress: onPressClose, icon: "lake-close" })) : null] }), typeof children == "function" ? children({ large, small }) : children] })] }) })) })) : null }) })] }) }));
|
|
132
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ColorVariants } from "../constants/design";
|
|
3
|
+
type Props = {
|
|
4
|
+
value: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
color?: ColorVariants;
|
|
7
|
+
};
|
|
8
|
+
export declare const LakeRadio: ({ value, disabled, color }: Props) => JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
import { backgroundColor, colors } from "../constants/design";
|
|
4
|
+
const OUTER_CIRCLE_SIZE = 16;
|
|
5
|
+
const INNER_CIRCLE_SIZE = 8;
|
|
6
|
+
const styles = StyleSheet.create({
|
|
7
|
+
outerCircle: {
|
|
8
|
+
backgroundColor: backgroundColor.accented,
|
|
9
|
+
justifyContent: "center",
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
height: OUTER_CIRCLE_SIZE,
|
|
12
|
+
width: OUTER_CIRCLE_SIZE,
|
|
13
|
+
borderRadius: OUTER_CIRCLE_SIZE / 2,
|
|
14
|
+
borderWidth: 1,
|
|
15
|
+
borderColor: colors.gray[500],
|
|
16
|
+
},
|
|
17
|
+
innerCircle: {
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
height: INNER_CIRCLE_SIZE,
|
|
21
|
+
width: INNER_CIRCLE_SIZE,
|
|
22
|
+
borderRadius: INNER_CIRCLE_SIZE / 2,
|
|
23
|
+
transform: [{ scale: 0 }],
|
|
24
|
+
transitionProperty: "transform",
|
|
25
|
+
transitionDuration: "100ms",
|
|
26
|
+
},
|
|
27
|
+
innerCircleDisplay: {
|
|
28
|
+
transform: [{ scale: 1 }],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
export const LakeRadio = ({ value, disabled = false, color = "current" }) => (_jsx(View, { style: [
|
|
32
|
+
styles.outerCircle,
|
|
33
|
+
value && { borderColor: colors[color].primary },
|
|
34
|
+
disabled && {
|
|
35
|
+
borderColor: colors.gray[300],
|
|
36
|
+
},
|
|
37
|
+
], accessibilityRole: "none", children: _jsx(View, { accessibilityHidden: !value, style: [
|
|
38
|
+
styles.innerCircle,
|
|
39
|
+
{ backgroundColor: colors[color].primary },
|
|
40
|
+
disabled && {
|
|
41
|
+
backgroundColor: colors.gray[200],
|
|
42
|
+
},
|
|
43
|
+
value && styles.innerCircleDisplay,
|
|
44
|
+
] }) }));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ViewProps } from "react-native";
|
|
3
|
+
type Props = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
style?: ViewProps["style"];
|
|
6
|
+
contentContainerStyle?: ViewProps["style"];
|
|
7
|
+
horizontalSafeArea?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const LakeScrollView: ({ children, horizontalSafeArea, style, contentContainerStyle, }: Props) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { ScrollView, StyleSheet, View, } from "react-native";
|
|
4
|
+
import { backgroundColor } from "../constants/design";
|
|
5
|
+
const HORIZONTAL_SAFE_AREA = 20;
|
|
6
|
+
const styles = StyleSheet.create({
|
|
7
|
+
root: {
|
|
8
|
+
height: 1,
|
|
9
|
+
flexGrow: 1,
|
|
10
|
+
},
|
|
11
|
+
container: {
|
|
12
|
+
height: 1,
|
|
13
|
+
flexGrow: 1,
|
|
14
|
+
},
|
|
15
|
+
topGradient: {
|
|
16
|
+
height: 30,
|
|
17
|
+
position: "absolute",
|
|
18
|
+
left: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
top: 0,
|
|
21
|
+
backgroundImage: `linear-gradient(to bottom, ${backgroundColor.default}, ${backgroundColor.defaultTransparent})`,
|
|
22
|
+
opacity: 0,
|
|
23
|
+
transition: "200ms ease-in-out opacity",
|
|
24
|
+
},
|
|
25
|
+
visibleTopGradient: {
|
|
26
|
+
opacity: 1,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export const LakeScrollView = ({ children, horizontalSafeArea = HORIZONTAL_SAFE_AREA, style, contentContainerStyle, }) => {
|
|
30
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
31
|
+
const onScroll = useCallback((event) => {
|
|
32
|
+
setIsScrolled(event.nativeEvent.contentOffset.y > 0);
|
|
33
|
+
}, []);
|
|
34
|
+
return (_jsxs(View, { style: styles.root, children: [_jsx(ScrollView, { onScroll: onScroll, scrollEventThrottle: 16, style: [styles.container, { marginHorizontal: -horizontalSafeArea }, style], contentContainerStyle: [{ paddingHorizontal: horizontalSafeArea }, contentContainerStyle], children: children }), _jsx(View, { style: [styles.topGradient, isScrolled && styles.visibleTopGradient], pointerEvents: "none" })] }));
|
|
35
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Props = {
|
|
3
|
+
initialValue: string;
|
|
4
|
+
placeholder: string;
|
|
5
|
+
onChangeText: (text: string) => void;
|
|
6
|
+
debounceDuration?: number;
|
|
7
|
+
maxWidth?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const LakeSearchField: ({ initialValue, placeholder, onChangeText, debounceDuration, maxWidth, }: Props) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
import { Pressable, StyleSheet, View } from "react-native";
|
|
4
|
+
import { animations, backgroundColor, colors, radii } from "../constants/design";
|
|
5
|
+
import { useBoolean } from "../hooks/useBoolean";
|
|
6
|
+
import { useDebounce } from "../hooks/useDebounce";
|
|
7
|
+
import { LakeButton } from "./LakeButton";
|
|
8
|
+
import { LakeTextInput } from "./LakeTextInput";
|
|
9
|
+
import { ResponsiveContainer } from "./ResponsiveContainer";
|
|
10
|
+
import { Line, Svg } from "./Svg";
|
|
11
|
+
import { TransitionView } from "./TransitionView";
|
|
12
|
+
const styles = StyleSheet.create({
|
|
13
|
+
root: {
|
|
14
|
+
flexGrow: 1,
|
|
15
|
+
flexShrink: 1,
|
|
16
|
+
// ResponsiveContainer uses a 200 breaking,
|
|
17
|
+
// we give the opportunity to the component to grow 2px more
|
|
18
|
+
// to trigger the change
|
|
19
|
+
maxWidth: 202,
|
|
20
|
+
minWidth: 38,
|
|
21
|
+
},
|
|
22
|
+
container: {
|
|
23
|
+
width: "100%",
|
|
24
|
+
flexGrow: 1,
|
|
25
|
+
flexShrink: 0,
|
|
26
|
+
alignSelf: "flex-end",
|
|
27
|
+
},
|
|
28
|
+
input: {
|
|
29
|
+
paddingRight: 50,
|
|
30
|
+
minWidth: 200,
|
|
31
|
+
// fixes a responsiveness bug where the default input width is too large
|
|
32
|
+
width: 1,
|
|
33
|
+
flexGrow: 1,
|
|
34
|
+
transition: "300ms ease-in-out border-color",
|
|
35
|
+
},
|
|
36
|
+
focus: {
|
|
37
|
+
outlineStyle: "none",
|
|
38
|
+
borderColor: colors.current.primary,
|
|
39
|
+
},
|
|
40
|
+
clearButton: {
|
|
41
|
+
position: "absolute",
|
|
42
|
+
right: 0,
|
|
43
|
+
top: "50%",
|
|
44
|
+
transform: [{ translateY: "-50%" }],
|
|
45
|
+
padding: 16,
|
|
46
|
+
},
|
|
47
|
+
clear: {
|
|
48
|
+
width: 8,
|
|
49
|
+
height: 8,
|
|
50
|
+
display: "flex",
|
|
51
|
+
},
|
|
52
|
+
smallButtonContainer: {
|
|
53
|
+
flexDirection: "row",
|
|
54
|
+
justifyContent: "flex-end",
|
|
55
|
+
},
|
|
56
|
+
openSearchFieldContainer: {
|
|
57
|
+
position: "absolute",
|
|
58
|
+
right: 0,
|
|
59
|
+
top: 0,
|
|
60
|
+
bottom: 0,
|
|
61
|
+
},
|
|
62
|
+
openSearchField: {
|
|
63
|
+
position: "absolute",
|
|
64
|
+
right: 0,
|
|
65
|
+
top: 0,
|
|
66
|
+
bottom: 0,
|
|
67
|
+
boxShadow: `0 0 20px 20px ${backgroundColor.default}`,
|
|
68
|
+
borderRadius: radii[6],
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const CollapsibleSeachField = ({ inputRef, placeholder, initialValue, onChange, setFocused, hasFocus, clear, currentValue, }) => {
|
|
72
|
+
return (_jsxs(View, { children: [_jsx(LakeButton, { mode: "secondary", size: "small", accessibilityLabel: placeholder, icon: "search-filled", onPress: () => {
|
|
73
|
+
setFocused.on();
|
|
74
|
+
}, pill: currentValue !== "" }), _jsx(TransitionView, { style: styles.openSearchFieldContainer, ...animations.fadeAndSlideInFromRight, children: hasFocus ? (_jsx(View, { style: styles.openSearchField, children: _jsx(ExpandedSearchField, { inputRef: inputRef, placeholder: placeholder, initialValue: initialValue, onChange: onChange, setFocused: setFocused, hasFocus: hasFocus, clear: clear, currentValue: currentValue }) })) : null })] }));
|
|
75
|
+
};
|
|
76
|
+
const ExpandedSearchField = ({ inputRef, placeholder, initialValue, onChange, setFocused, hasFocus, clear, }) => {
|
|
77
|
+
const timeoutRef = useRef(null);
|
|
78
|
+
return (_jsxs(View, { style: styles.container, children: [_jsx(LakeTextInput, { ref: inputRef, autoFocus: hasFocus, icon: "search-filled", placeholder: placeholder, defaultValue: initialValue, keyboardType: "web-search", onChangeText: onChange, hideErrors: true, onFocus: () => {
|
|
79
|
+
if (timeoutRef.current != null) {
|
|
80
|
+
clearTimeout(timeoutRef.current);
|
|
81
|
+
}
|
|
82
|
+
setFocused.on();
|
|
83
|
+
}, onBlur: () => {
|
|
84
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
85
|
+
setFocused.off();
|
|
86
|
+
}, 300);
|
|
87
|
+
}, style: [styles.input, hasFocus ? styles.focus : null] }), _jsx(Pressable, { onPress: () => {
|
|
88
|
+
if (timeoutRef.current != null) {
|
|
89
|
+
clearTimeout(timeoutRef.current);
|
|
90
|
+
}
|
|
91
|
+
clear();
|
|
92
|
+
}, style: styles.clearButton, children: _jsx(Svg, { viewBox: "0 0 16 16", style: styles.clear, children: _jsxs(_Fragment, { children: [_jsx(Line, { x1: "0", x2: "16", y1: "0", y2: "16", strokeLinecap: "round", stroke: colors.gray[500], strokeWidth: 2 }), _jsx(Line, { x1: "0", x2: "16", y1: "16", y2: "0", strokeLinecap: "round", stroke: colors.gray[500], strokeWidth: 2 })] }) }) })] }));
|
|
93
|
+
};
|
|
94
|
+
export const LakeSearchField = ({ initialValue, placeholder, onChangeText, debounceDuration = 500, maxWidth, }) => {
|
|
95
|
+
const [hasFocus, setFocused] = useBoolean(false);
|
|
96
|
+
const inputRef = useRef(null);
|
|
97
|
+
const [currentValue, setCurrentValue] = useState(initialValue);
|
|
98
|
+
const onChange = useDebounce((value) => {
|
|
99
|
+
onChangeText(value);
|
|
100
|
+
setCurrentValue(value.trim());
|
|
101
|
+
}, debounceDuration);
|
|
102
|
+
const clear = useCallback(() => {
|
|
103
|
+
if (inputRef.current instanceof HTMLInputElement) {
|
|
104
|
+
inputRef.current.clear();
|
|
105
|
+
inputRef.current.focus();
|
|
106
|
+
onChangeText("");
|
|
107
|
+
setCurrentValue("");
|
|
108
|
+
}
|
|
109
|
+
}, [onChangeText]);
|
|
110
|
+
return (_jsx(ResponsiveContainer, { breakpoint: 200, style: [styles.root, maxWidth != null && { maxWidth }], children: ({ large }) => large ? (_jsx(ExpandedSearchField, { inputRef: inputRef, placeholder: placeholder, initialValue: initialValue, onChange: onChange, setFocused: setFocused, hasFocus: hasFocus, clear: clear, currentValue: currentValue })) : (_jsx(View, { style: styles.smallButtonContainer, children: _jsx(CollapsibleSeachField, { inputRef: inputRef, placeholder: placeholder, initialValue: initialValue, onChange: onChange, setFocused: setFocused, hasFocus: hasFocus, clear: clear, currentValue: currentValue }) })) }));
|
|
111
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
|
+
import { ColorVariants } from "../constants/design";
|
|
4
|
+
import { IconName } from "./Icon";
|
|
5
|
+
export type Item<V> = {
|
|
6
|
+
name: string;
|
|
7
|
+
value: V;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
export type SelectProps<V> = {
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
items: Item<V>[];
|
|
13
|
+
matchReferenceWidth?: boolean;
|
|
14
|
+
mode?: "normal" | "borderless";
|
|
15
|
+
title?: string;
|
|
16
|
+
valueStyle?: StyleProp<TextStyle>;
|
|
17
|
+
PopoverFooter?: ReactElement;
|
|
18
|
+
size?: "small" | "large";
|
|
19
|
+
icon?: IconName;
|
|
20
|
+
color?: ColorVariants;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
value?: V;
|
|
23
|
+
onValueChange: (value: V) => void;
|
|
24
|
+
hideErrors?: boolean;
|
|
25
|
+
nativeID?: string;
|
|
26
|
+
error?: string;
|
|
27
|
+
readOnly?: boolean;
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
};
|
|
30
|
+
export declare function LakeSelect<V>({ title, items, valueStyle, size, color, disabled, mode, placeholder, readOnly, nativeID, matchReferenceWidth, value, error, hideErrors, icon, onValueChange, PopoverFooter, style, }: SelectProps<V>): JSX.Element;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
import { FlatList, StyleSheet, View, } from "react-native";
|
|
4
|
+
import { match } from "ts-pattern";
|
|
5
|
+
import { commonStyles } from "../constants/commonStyles";
|
|
6
|
+
import { colors, invariantColors, radii, shadows, spacings, texts, } from "../constants/design";
|
|
7
|
+
import { useDisclosure } from "../hooks/useDisclosure";
|
|
8
|
+
import { getFocusableElements } from "../utils/a11y";
|
|
9
|
+
import { isNotNullish } from "../utils/nullish";
|
|
10
|
+
import { Box } from "./Box";
|
|
11
|
+
import { Fill } from "./Fill";
|
|
12
|
+
import { Icon } from "./Icon";
|
|
13
|
+
import { LakeText } from "./LakeText";
|
|
14
|
+
import { Popover } from "./Popover";
|
|
15
|
+
import { Pressable } from "./Pressable";
|
|
16
|
+
import { Separator } from "./Separator";
|
|
17
|
+
import { Space } from "./Space";
|
|
18
|
+
const styles = StyleSheet.create({
|
|
19
|
+
normal: {
|
|
20
|
+
backgroundColor: colors.gray.contrast,
|
|
21
|
+
borderColor: colors.gray[100],
|
|
22
|
+
borderRadius: radii[6],
|
|
23
|
+
borderWidth: 1,
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
minWidth: 100,
|
|
26
|
+
paddingHorizontal: spacings[16],
|
|
27
|
+
height: 40,
|
|
28
|
+
},
|
|
29
|
+
borderless: {
|
|
30
|
+
justifyContent: "center",
|
|
31
|
+
height: 40,
|
|
32
|
+
paddingHorizontal: spacings[16],
|
|
33
|
+
},
|
|
34
|
+
small: {
|
|
35
|
+
paddingVertical: 5,
|
|
36
|
+
},
|
|
37
|
+
shadowed: {
|
|
38
|
+
position: "absolute",
|
|
39
|
+
opacity: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
top: 0,
|
|
42
|
+
width: "100%",
|
|
43
|
+
height: "100%",
|
|
44
|
+
borderRadius: radii[6],
|
|
45
|
+
boxShadow: shadows.tile,
|
|
46
|
+
transitionDuration: "150ms",
|
|
47
|
+
transitionProperty: "opacity",
|
|
48
|
+
},
|
|
49
|
+
hovered: {
|
|
50
|
+
opacity: 1,
|
|
51
|
+
},
|
|
52
|
+
selectPlaceholder: texts.placeholder,
|
|
53
|
+
selectSmallPlaceholder: texts.smallPlaceholder,
|
|
54
|
+
selected: {
|
|
55
|
+
color: colors.gray[800],
|
|
56
|
+
},
|
|
57
|
+
inputDisabled: {
|
|
58
|
+
backgroundColor: colors.gray[50],
|
|
59
|
+
borderColor: colors.gray[50],
|
|
60
|
+
cursor: "not-allowed",
|
|
61
|
+
},
|
|
62
|
+
listContent: {
|
|
63
|
+
paddingVertical: 12,
|
|
64
|
+
},
|
|
65
|
+
item: {
|
|
66
|
+
display: "flex",
|
|
67
|
+
paddingHorizontal: spacings[24],
|
|
68
|
+
paddingVertical: spacings[8],
|
|
69
|
+
flexDirection: "row",
|
|
70
|
+
justifyContent: "space-between",
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
},
|
|
73
|
+
itemHighlighted: {
|
|
74
|
+
backgroundColor: colors.gray[50],
|
|
75
|
+
},
|
|
76
|
+
itemFocused: {
|
|
77
|
+
boxShadow: `inset 0 0 0 1px ${colors.gray[500]}`,
|
|
78
|
+
borderRadius: radii[4],
|
|
79
|
+
outlineStyle: "none",
|
|
80
|
+
},
|
|
81
|
+
selectListTitle: {
|
|
82
|
+
paddingHorizontal: spacings[24],
|
|
83
|
+
paddingVertical: spacings[12],
|
|
84
|
+
},
|
|
85
|
+
inputBorderlessDisabled: {
|
|
86
|
+
backgroundColor: invariantColors.transparent,
|
|
87
|
+
},
|
|
88
|
+
itemText: {
|
|
89
|
+
display: "flex",
|
|
90
|
+
flexDirection: "row",
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
},
|
|
93
|
+
errorText: {
|
|
94
|
+
paddingTop: spacings[4],
|
|
95
|
+
},
|
|
96
|
+
focusedInput: {
|
|
97
|
+
borderColor: colors.gray[500],
|
|
98
|
+
boxShadow: shadows.tile,
|
|
99
|
+
outlineStyle: "none",
|
|
100
|
+
},
|
|
101
|
+
focusedWithoutShadow: {
|
|
102
|
+
boxShadow: "none",
|
|
103
|
+
},
|
|
104
|
+
errorContainer: {
|
|
105
|
+
borderColor: colors.negative[500],
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
export function LakeSelect({ title, items, valueStyle, size, color = "current", disabled = false, mode = "normal", placeholder, readOnly = false, nativeID, matchReferenceWidth = true, value, error, hideErrors = false, icon, onValueChange, PopoverFooter, style, }) {
|
|
109
|
+
const inputRef = useRef(null);
|
|
110
|
+
const listRef = useRef(null);
|
|
111
|
+
const typingTimeoutRef = useRef(undefined);
|
|
112
|
+
const currentlyTypedRef = useRef(undefined);
|
|
113
|
+
const listItemRefs = useRef(Array(items.length));
|
|
114
|
+
const [visible, { close, toggle }] = useDisclosure(false);
|
|
115
|
+
const hasValue = isNotNullish(value);
|
|
116
|
+
const isSmall = size === "small";
|
|
117
|
+
const itemValue = items.find(i => i.value === value);
|
|
118
|
+
const onKeyDown = useCallback((event) => {
|
|
119
|
+
if (event.nativeEvent.key.length === 1) {
|
|
120
|
+
const currentlyTyped = `${currentlyTypedRef.current ?? ""}${event.nativeEvent.key.toLowerCase()}`;
|
|
121
|
+
currentlyTypedRef.current = currentlyTyped;
|
|
122
|
+
const selectedIndex = items.findIndex(item => item.name.toLowerCase().startsWith(currentlyTyped));
|
|
123
|
+
const selected = items[selectedIndex];
|
|
124
|
+
if (selected != null) {
|
|
125
|
+
if (visible) {
|
|
126
|
+
const listElement = listRef.current;
|
|
127
|
+
if (listElement != null) {
|
|
128
|
+
listItemRefs.current[selectedIndex]?.focus();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
onValueChange(selected.value);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (typingTimeoutRef.current != null) {
|
|
137
|
+
window.clearTimeout(typingTimeoutRef.current);
|
|
138
|
+
}
|
|
139
|
+
typingTimeoutRef.current = window.setTimeout(() => {
|
|
140
|
+
currentlyTypedRef.current = undefined;
|
|
141
|
+
}, 300);
|
|
142
|
+
}, [items, onValueChange, visible]);
|
|
143
|
+
const name = itemValue?.name ?? value;
|
|
144
|
+
return (_jsxs(View, { style: commonStyles.fill, children: [_jsx(Pressable, { nativeID: nativeID, ref: inputRef, accessibilityHasPopup: "listbox", accessibilityRole: "button", accessibilityExpanded: visible, disabled: readOnly || disabled, style: ({ focused }) => [
|
|
145
|
+
mode === "normal" ? styles.normal : styles.borderless,
|
|
146
|
+
size === "small" && styles.small,
|
|
147
|
+
(disabled || readOnly) && styles.inputDisabled,
|
|
148
|
+
(visible || focused) && styles.focusedInput,
|
|
149
|
+
mode === "borderless" && styles.focusedWithoutShadow,
|
|
150
|
+
mode !== "borderless" && error != null && styles.errorContainer,
|
|
151
|
+
(disabled || readOnly) && mode === "borderless" && styles.inputBorderlessDisabled,
|
|
152
|
+
style,
|
|
153
|
+
], onPress: toggle, onKeyDown: onKeyDown, accessibilityErrorMessage: error, children: ({ hovered }) => (_jsxs(_Fragment, { children: [mode === "normal" && _jsx(View, { style: [styles.shadowed, hovered && styles.hovered] }), _jsxs(Box, { direction: "row", justifyContent: "spaceBetween", alignItems: "center", children: [_jsxs(Box, { direction: "row", alignItems: "center", children: [icon && (_jsxs(_Fragment, { children: [_jsx(Icon, { color: colors[color].primary, name: icon, size: isSmall ? 16 : 18 }), _jsx(Space, { width: 8 })] })), hasValue ? (_jsxs(LakeText, { color: colors.gray[900], variant: isSmall ? "smallRegular" : "regular", style: [styles.itemText, valueStyle], children: [isNotNullish(itemValue?.icon) && (_jsxs(_Fragment, { children: [itemValue?.icon, _jsx(Space, { width: 12 })] })), name] })) : (_jsx(LakeText, { style: [styles.selectPlaceholder, isSmall && styles.selectSmallPlaceholder], children: placeholder ?? " " }))] }), _jsx(Fill, { minWidth: 8 }), !disabled && (_jsx(Icon, { color: colors.gray[900], name: visible ? "chevron-up-filled" : "chevron-down-filled", size: 16 }))] })] })) }), !hideErrors && (_jsx(LakeText, { color: colors.negative[400], style: styles.errorText, children: error ?? " " })), _jsxs(Popover, { role: "listbox", matchReferenceMinWidth: matchReferenceWidth, onDismiss: close, referenceRef: inputRef, returnFocus: true, visible: visible, children: [isNotNullish(title) && (_jsxs(_Fragment, { children: [_jsx(LakeText, { variant: "semibold", color: colors.gray[900], style: styles.selectListTitle, children: title }), _jsx(Separator, {})] })), _jsx(FlatList, { accessibilityRole: "list", data: items, ref: listRef, contentContainerStyle: styles.listContent, onKeyDown: e => {
|
|
154
|
+
match(e.nativeEvent.key)
|
|
155
|
+
.with("ArrowDown", () => {
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
if (isNotNullish(e.currentTarget)) {
|
|
158
|
+
const focusableElements = getFocusableElements(e.currentTarget);
|
|
159
|
+
const current = focusableElements.indexOf(e.target);
|
|
160
|
+
focusableElements[current + 1]?.focus();
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
.with("ArrowUp", () => {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
if (isNotNullish(e.currentTarget)) {
|
|
166
|
+
const focusableElements = getFocusableElements(e.currentTarget);
|
|
167
|
+
const current = focusableElements.indexOf(e.target);
|
|
168
|
+
focusableElements[current - 1]?.focus();
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
.otherwise(() => { });
|
|
172
|
+
}, keyExtractor: (_, index) => `select-item-${index}`, renderItem: ({ item, index }) => {
|
|
173
|
+
const isSelected = value === item.value;
|
|
174
|
+
return (_jsxs(Pressable, { ref: element => (listItemRefs.current[index] = element), onKeyDown: onKeyDown, style: ({ hovered, focused }) => [
|
|
175
|
+
styles.item,
|
|
176
|
+
(hovered || isSelected) && styles.itemHighlighted,
|
|
177
|
+
focused && styles.itemFocused,
|
|
178
|
+
], accessibilityRole: "option", accessibilitySelected: true, onPress: () => {
|
|
179
|
+
onValueChange(item.value);
|
|
180
|
+
close();
|
|
181
|
+
}, children: [_jsxs(LakeText, { color: colors.gray[900], numberOfLines: 1, style: [styles.itemText, isSelected && styles.selected], children: [isNotNullish(item.icon) && (_jsxs(_Fragment, { children: [item.icon, _jsx(Space, { width: 12 })] })), item.name] }), isSelected && (_jsx(Icon, { color: colors.positive[500], name: "checkmark-filled", size: 14 }))] }));
|
|
182
|
+
} }), PopoverFooter] })] }));
|
|
183
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type SliderProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: number;
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
step: number;
|
|
8
|
+
unit: string;
|
|
9
|
+
onChange: (value: number) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const sliderBreakpoint: number;
|
|
12
|
+
export declare const LakeSlider: ({ label, value, min, max, step, unit, onChange }: SliderProps) => JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
|
+
import { breakpoints } from "../constants/design";
|
|
5
|
+
import { Box } from "./Box";
|
|
6
|
+
import { LakeLabel } from "./LakeLabel";
|
|
7
|
+
import { LakeTextInput } from "./LakeTextInput";
|
|
8
|
+
import { ResponsiveContainer } from "./ResponsiveContainer";
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
zIndex: 1,
|
|
12
|
+
},
|
|
13
|
+
input: {
|
|
14
|
+
maxWidth: 120,
|
|
15
|
+
zIndex: 1,
|
|
16
|
+
position: "relative",
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
export const sliderBreakpoint = breakpoints.tiny;
|
|
20
|
+
export const LakeSlider = ({ label, value, min, max, step, unit, onChange }) => {
|
|
21
|
+
const [dirtyValue, setDirtyValue] = useState(String(value));
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setDirtyValue(String(value));
|
|
24
|
+
}, [value]);
|
|
25
|
+
const sanitizeInput = useCallback(() => {
|
|
26
|
+
const cleanValue = Math.max(Math.min(Number(dirtyValue), max), min);
|
|
27
|
+
setDirtyValue(String(cleanValue));
|
|
28
|
+
onChange(cleanValue);
|
|
29
|
+
}, [min, max, dirtyValue, onChange]);
|
|
30
|
+
return (_jsx(ResponsiveContainer, { breakpoint: sliderBreakpoint, style: styles.container, children: ({ large }) => (_jsx(_Fragment, { children: large ? (_jsxs(_Fragment, { children: [_jsx(Box, { direction: "row", justifyContent: "end", children: _jsx(View, { children: _jsx(LakeTextInput, { style: styles.input, unit: unit, value: dirtyValue, onChangeText: setDirtyValue, onBlur: sanitizeInput, keyboardType: "decimal-pad" }) }) }), _jsx("input", { type: "range", min: min, max: max, step: step, value: value, onChange: event => onChange(Number(event.target.value)), style: { backgroundSize: `${((value - min) / (max - min)) * 100}% 100%` } })] })) : (_jsx(LakeLabel, { label: label, render: id => (_jsx(LakeTextInput, { nativeID: id, unit: unit, value: dirtyValue, onChangeText: setDirtyValue, onBlur: sanitizeInput, keyboardType: "decimal-pad" })) })) })) }));
|
|
31
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
export type Step = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
url: string;
|
|
7
|
+
hasErrors?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type StepWithChildren = {
|
|
10
|
+
label: string;
|
|
11
|
+
children: Step[];
|
|
12
|
+
};
|
|
13
|
+
export type TopLevelStep = Step | StepWithChildren;
|
|
14
|
+
type Props = {
|
|
15
|
+
steps: TopLevelStep[];
|
|
16
|
+
activeStepId: string;
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
};
|
|
19
|
+
export declare const LakeStepper: ({ steps, activeStepId, style }: Props) => JSX.Element;
|
|
20
|
+
export declare const MobileStepTitle: ({ steps, activeStepId }: Props) => JSX.Element | null;
|
|
21
|
+
export {};
|