@swan-io/lake 4.10.1 → 5.0.1

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 (43) hide show
  1. package/package.json +2 -2
  2. package/src/components/Box.d.ts +27 -12
  3. package/src/components/Box.js +18 -8
  4. package/src/components/Filters.d.ts +1 -1
  5. package/src/components/Filters.js +11 -9
  6. package/src/components/FixedListViewCells.d.ts +3 -3
  7. package/src/components/LakeButton.js +1 -2
  8. package/src/components/LakeCombobox.js +1 -2
  9. package/src/components/LakeSelect.d.ts +5 -2
  10. package/src/components/LakeSelect.js +5 -5
  11. package/src/components/LakeSlider.d.ts +6 -6
  12. package/src/components/LakeSlider.js +7 -28
  13. package/src/components/LakeText.d.ts +1 -1
  14. package/src/components/LakeTooltip.d.ts +7 -3
  15. package/src/components/LakeTooltip.js +5 -6
  16. package/src/components/Stack.d.ts +3 -1
  17. package/src/components/Stack.js +3 -9
  18. package/src/utils/function.d.ts +0 -2
  19. package/src/utils/function.js +0 -5
  20. package/src/components/BorderedButton.d.ts +0 -16
  21. package/src/components/BorderedButton.js +0 -100
  22. package/src/components/Caption.d.ts +0 -6
  23. package/src/components/Caption.js +0 -11
  24. package/src/components/FailureIcon.d.ts +0 -7
  25. package/src/components/FailureIcon.js +0 -4
  26. package/src/components/Heading.d.ts +0 -158
  27. package/src/components/Heading.js +0 -27
  28. package/src/components/Input.d.ts +0 -34
  29. package/src/components/Input.js +0 -110
  30. package/src/components/Label.d.ts +0 -10
  31. package/src/components/Label.js +0 -19
  32. package/src/components/Modal.d.ts +0 -12
  33. package/src/components/Modal.js +0 -90
  34. package/src/components/Slider.d.ts +0 -11
  35. package/src/components/Slider.js +0 -136
  36. package/src/components/SuccessIcon.d.ts +0 -7
  37. package/src/components/SuccessIcon.js +0 -4
  38. package/src/components/Tooltip.d.ts +0 -18
  39. package/src/components/Tooltip.js +0 -160
  40. package/src/constants/colors.d.ts +0 -42
  41. package/src/constants/colors.js +0 -42
  42. package/src/constants/typography.d.ts +0 -26
  43. package/src/constants/typography.js +0 -54
@@ -1,18 +0,0 @@
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 {};
@@ -1,160 +0,0 @@
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
- var _a, _b;
68
- const rootElement = getRootElement(referenceRef.current);
69
- const [popperElement, setPopperElement] = useState(null);
70
- const timeoutRef = useRef(0);
71
- const [visible, setVisible] = useState(false);
72
- const [, setMounted] = useState(false);
73
- useEffect(() => {
74
- setMounted(true);
75
- }, []);
76
- useImperativeHandle(forwardedRef, () => ({
77
- show: () => setVisible(true),
78
- hide: () => setVisible(false),
79
- }));
80
- useHover(referenceRef, {
81
- disabled: !canHover,
82
- contain: true,
83
- onHoverChange: nextVisible => {
84
- nextVisible ? onShow === null || onShow === void 0 ? void 0 : onShow() : onHide === null || onHide === void 0 ? void 0 : onHide();
85
- setVisible(nextVisible);
86
- },
87
- });
88
- const { attributes, update, styles: popperStyles, state, } = usePopper(referenceRef.current, popperElement, {
89
- placement,
90
- modifiers: useMemo(() => [
91
- { name: "preventOverflow", enabled: true },
92
- { name: "flip", enabled: false },
93
- { name: "hide", enabled: true },
94
- { ...matchReferenceWidthModifier, enabled: matchReferenceWidth },
95
- ], [matchReferenceWidth]),
96
- });
97
- const overflowOffset = (_b = (_a = state === null || state === void 0 ? void 0 : state.modifiersData.preventOverflow) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : 0;
98
- useEffect(() => {
99
- const node = referenceRef.current;
100
- if (!(node instanceof Element)) {
101
- return;
102
- }
103
- const onFocus = (event) => {
104
- event.preventDefault();
105
- setVisible(true);
106
- };
107
- const onBlur = (event) => {
108
- event.preventDefault();
109
- const { target } = event;
110
- if (target instanceof Element && (node === target || node.contains(target))) {
111
- onHide === null || onHide === void 0 ? void 0 : onHide();
112
- setVisible(false);
113
- }
114
- };
115
- const onPress = (event) => {
116
- event.preventDefault();
117
- if (!canHover) {
118
- clearTimeout(timeoutRef.current);
119
- setVisible(true);
120
- timeoutRef.current = setTimeout(() => {
121
- setVisible(false);
122
- }, 1500);
123
- }
124
- };
125
- if (togglableOnFocus) {
126
- node.addEventListener("focus", onFocus);
127
- node.addEventListener("blur", onBlur);
128
- }
129
- node.addEventListener("mousedown", onPress);
130
- return () => {
131
- if (togglableOnFocus) {
132
- node.removeEventListener("focus", onFocus);
133
- node.removeEventListener("blur", onBlur);
134
- }
135
- node.removeEventListener("mousedown", onPress);
136
- };
137
- }, [referenceRef, togglableOnFocus, setVisible, onHide]);
138
- useEffect(() => {
139
- return () => clearTimeout(timeoutRef.current);
140
- }, []);
141
- useLayoutEffect(() => {
142
- void (update === null || update === void 0 ? void 0 : update());
143
- // eslint-disable-next-line react-hooks/exhaustive-deps
144
- }, [children]);
145
- if (isNullish(rootElement) || !visible) {
146
- return null;
147
- }
148
- return (_jsx(Portal, { container: rootElement, children: _jsx("div", { ref: setPopperElement, style: popperStyles.popper, ...attributes.popper, role: "tooltip", "aria-describedby": describedBy, children: _jsxs(View, { style: [
149
- styles.base,
150
- (state === null || state === void 0 ? void 0 : state.placement) === "top" && styles.baseTop,
151
- (state === null || state === void 0 ? void 0 : state.placement) === "bottom" && styles.baseBottom,
152
- ], children: [_jsx(View, { style: [styles.content, { width }], children: isReactText(children) ? _jsx(Text, { style: styles.text, children: children }) : children }), _jsx(View, { role: "none", style: [
153
- styles.arrowContainer,
154
- (state === null || state === void 0 ? void 0 : state.placement) === "top" && styles.arrowContainerTop,
155
- (state === null || state === void 0 ? void 0 : state.placement) === "bottom" && styles.arrowContainerBottom,
156
- {
157
- transform: `translateX(${-overflowOffset}px) rotate(${(state === null || state === void 0 ? void 0 : state.placement) === "bottom" ? "180deg" : "0deg"})`,
158
- },
159
- ], children: _jsx(View, { style: styles.arrow }) })] }) }) }));
160
- }));
@@ -1,42 +0,0 @@
1
- export declare const colors: {
2
- transparent: string;
3
- black: string;
4
- white: string;
5
- gray: {
6
- 3: string;
7
- 10: string;
8
- 20: string;
9
- 30: string;
10
- 40: string;
11
- 50: string;
12
- 60: string;
13
- 70: string;
14
- 80: string;
15
- 90: string;
16
- 100: string;
17
- };
18
- purple: {
19
- 3: string;
20
- 10: string;
21
- 30: string;
22
- 50: string;
23
- 80: string;
24
- 100: string;
25
- };
26
- green: {
27
- 3: string;
28
- 10: string;
29
- 100: string;
30
- };
31
- orange: {
32
- 3: string;
33
- 10: string;
34
- 100: string;
35
- };
36
- red: {
37
- 3: string;
38
- 10: string;
39
- 100: string;
40
- };
41
- };
42
- export declare const defaultAccentColor: string;
@@ -1,42 +0,0 @@
1
- export const colors = {
2
- transparent: "transparent",
3
- black: "#000000",
4
- white: "#ffffff",
5
- gray: {
6
- 3: "#f7f8f8",
7
- 10: "#e7e8e8",
8
- 20: "#d0d1d1",
9
- 30: "#b8baba",
10
- 40: "#a1a3a3",
11
- 50: "#898c8c",
12
- 60: "#727575",
13
- 70: "#5a5e5e",
14
- 80: "#434747",
15
- 90: "#2b2f30",
16
- 100: "#14191a",
17
- },
18
- purple: {
19
- 3: "#faf9fc",
20
- 10: "#efebf7",
21
- 30: "#cfc5e8",
22
- 50: "#b09fda",
23
- 80: "#8166c4",
24
- 100: "#6240b5",
25
- },
26
- green: {
27
- 3: "#f8fdfb",
28
- 10: "#e8faf2",
29
- 100: "#1fd286",
30
- },
31
- orange: {
32
- 3: "#fffcf7",
33
- 10: "#fff5e5",
34
- 100: "#ff9f00",
35
- },
36
- red: {
37
- 3: "#fef8f9",
38
- 10: "#fde9ec",
39
- 100: "#f12b43",
40
- },
41
- };
42
- export const defaultAccentColor = colors.purple[100];
@@ -1,26 +0,0 @@
1
- import { TextStyle } from "react-native";
2
- export declare const typography: {
3
- fontWeights: {
4
- book: "400";
5
- demi: "600";
6
- };
7
- lineHeights: {
8
- title: number;
9
- body: number;
10
- input: number;
11
- };
12
- interFont: {
13
- fontFamily: string;
14
- letterSpacing: number;
15
- };
16
- baseStyle: {
17
- color: string;
18
- fontWeight: "400";
19
- lineHeight: number;
20
- fontFamily: string;
21
- letterSpacing: number;
22
- };
23
- bodyLarge: TextStyle;
24
- bodySmall: TextStyle;
25
- caption: TextStyle;
26
- };
@@ -1,54 +0,0 @@
1
- import { colors } from "./colors";
2
- const fontWeights = {
3
- book: "400",
4
- demi: "600",
5
- };
6
- const lineHeights = {
7
- title: "1.25",
8
- body: "1.65",
9
- input: "1.25",
10
- };
11
- const interFont = {
12
- fontFamily: [
13
- "Inter",
14
- "-apple-system",
15
- "system-ui",
16
- "BlinkMacSystemFont",
17
- "Segoe UI",
18
- "Helvetica",
19
- "Arial",
20
- "sans-serif",
21
- "Apple Color Emoji",
22
- "Segoe UI Emoji",
23
- "Segoe UI Symbol",
24
- "Noto Color Emoji",
25
- ].join(","),
26
- // Computed by Inter dynamic metrics tool
27
- letterSpacing: "-0.011em",
28
- };
29
- // TODO: Create a styled <Text /> component with size: "small" | "large"
30
- const baseStyle = {
31
- ...interFont,
32
- color: colors.gray[90],
33
- fontWeight: fontWeights.book,
34
- lineHeight: lineHeights.body,
35
- };
36
- const bodyLarge = { ...baseStyle, fontSize: 16 };
37
- const bodySmall = { ...baseStyle, fontSize: 14 };
38
- const caption = {
39
- ...baseStyle,
40
- fontSize: 13,
41
- fontWeight: fontWeights.demi,
42
- letterSpacing: "0.011em",
43
- textTransform: "uppercase",
44
- };
45
- export const typography = {
46
- fontWeights,
47
- lineHeights,
48
- interFont,
49
- // TODO: Delete all this exports
50
- baseStyle,
51
- bodyLarge,
52
- bodySmall,
53
- caption,
54
- };