@swan-io/lake 4.10.0 → 5.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 (37) hide show
  1. package/package.json +7 -7
  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/LakeSelect.d.ts +5 -2
  7. package/src/components/LakeSelect.js +5 -5
  8. package/src/components/LakeSlider.d.ts +6 -6
  9. package/src/components/LakeSlider.js +7 -28
  10. package/src/components/Stack.d.ts +3 -1
  11. package/src/components/Stack.js +3 -9
  12. package/src/utils/function.d.ts +0 -2
  13. package/src/utils/function.js +0 -5
  14. package/src/components/BorderedButton.d.ts +0 -16
  15. package/src/components/BorderedButton.js +0 -100
  16. package/src/components/Caption.d.ts +0 -6
  17. package/src/components/Caption.js +0 -11
  18. package/src/components/FailureIcon.d.ts +0 -7
  19. package/src/components/FailureIcon.js +0 -4
  20. package/src/components/Heading.d.ts +0 -158
  21. package/src/components/Heading.js +0 -27
  22. package/src/components/Input.d.ts +0 -34
  23. package/src/components/Input.js +0 -110
  24. package/src/components/Label.d.ts +0 -10
  25. package/src/components/Label.js +0 -19
  26. package/src/components/Modal.d.ts +0 -12
  27. package/src/components/Modal.js +0 -90
  28. package/src/components/Slider.d.ts +0 -11
  29. package/src/components/Slider.js +0 -136
  30. package/src/components/SuccessIcon.d.ts +0 -7
  31. package/src/components/SuccessIcon.js +0 -4
  32. package/src/components/Tooltip.d.ts +0 -18
  33. package/src/components/Tooltip.js +0 -160
  34. package/src/constants/colors.d.ts +0 -42
  35. package/src/constants/colors.js +0 -42
  36. package/src/constants/typography.d.ts +0 -26
  37. package/src/constants/typography.js +0 -54
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/lake",
3
- "version": "4.10.0",
3
+ "version": "5.0.0",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -27,9 +27,9 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@popperjs/core": "^2.11.8",
30
- "@react-three/drei": "^9.97.5",
30
+ "@react-three/drei": "^9.99.4",
31
31
  "@react-three/fiber": "^8.15.16",
32
- "@swan-io/boxed": "^2.0.0",
32
+ "@swan-io/boxed": "^2.0.1",
33
33
  "@swan-io/chicane": "^1.4.1",
34
34
  "dayjs": "^1.11.10",
35
35
  "polished": "^4.3.1",
@@ -39,7 +39,7 @@
39
39
  "react-dom": "^18.2.0",
40
40
  "react-native-web": "^0.19.10",
41
41
  "react-popper": "^2.3.0",
42
- "react-ux-form": "^1.5.0",
42
+ "@swan-io/use-form": "^2.0.0-rc.2",
43
43
  "rifm": "^0.12.1",
44
44
  "three": "^0.161.0",
45
45
  "ts-dedent": "^2.2.0",
@@ -48,12 +48,12 @@
48
48
  "uuid": "^9.0.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@types/react": "^18.2.55",
51
+ "@types/react": "^18.2.60",
52
52
  "@types/react-dom": "^18.2.19",
53
53
  "@types/react-native": "^0.72.8",
54
54
  "@types/three": "^0.161.2",
55
55
  "@types/uuid": "^9.0.8",
56
- "jsdom": "^23.2.0",
57
- "type-fest": "^4.10.2"
56
+ "jsdom": "^24.0.0",
57
+ "type-fest": "^4.10.3"
58
58
  }
59
59
  }
@@ -1,16 +1,5 @@
1
1
  import { ReactNode } from "react";
2
2
  import { StyleProp, View, ViewProps, ViewStyle } from "react-native";
3
- declare const directionStyles: {
4
- columnReverse: {
5
- flexDirection: "column-reverse";
6
- };
7
- row: {
8
- flexDirection: "row";
9
- };
10
- rowReverse: {
11
- flexDirection: "row-reverse";
12
- };
13
- };
14
3
  declare const alignItemsStyles: {
15
4
  baseline: {
16
5
  alignItems: "baseline";
@@ -25,6 +14,17 @@ declare const alignItemsStyles: {
25
14
  alignItems: "flex-start";
26
15
  };
27
16
  };
17
+ declare const directionStyles: {
18
+ columnReverse: {
19
+ flexDirection: "column-reverse";
20
+ };
21
+ row: {
22
+ flexDirection: "row";
23
+ };
24
+ rowReverse: {
25
+ flexDirection: "row-reverse";
26
+ };
27
+ };
28
28
  declare const justifyContentStyles: {
29
29
  center: {
30
30
  justifyContent: "center";
@@ -45,14 +45,26 @@ declare const justifyContentStyles: {
45
45
  justifyContent: "space-evenly";
46
46
  };
47
47
  };
48
- type BoxDirection = keyof typeof directionStyles | "column";
48
+ declare const wrapStyles: {
49
+ wrap: {
50
+ flexWrap: "wrap";
51
+ };
52
+ wrapReverse: {
53
+ flexWrap: "wrap-reverse";
54
+ };
55
+ };
49
56
  type BoxAlignItems = keyof typeof alignItemsStyles | "stretch";
57
+ type BoxDirection = keyof typeof directionStyles | "column";
50
58
  type BoxJustifyContent = keyof typeof justifyContentStyles | "normal";
59
+ type BoxWrap = keyof typeof wrapStyles | "nowrap";
51
60
  export type BoxProps = ViewProps & {
52
61
  alignItems?: BoxAlignItems;
53
62
  children?: ReactNode;
54
63
  direction?: BoxDirection;
55
64
  justifyContent?: BoxJustifyContent;
65
+ wrap?: BoxWrap;
66
+ grow?: number;
67
+ shrink?: number;
56
68
  style?: StyleProp<ViewStyle>;
57
69
  };
58
70
  export declare const Box: import("react").ForwardRefExoticComponent<ViewProps & {
@@ -60,6 +72,9 @@ export declare const Box: import("react").ForwardRefExoticComponent<ViewProps &
60
72
  children?: ReactNode;
61
73
  direction?: BoxDirection | undefined;
62
74
  justifyContent?: BoxJustifyContent | undefined;
75
+ wrap?: BoxWrap | undefined;
76
+ grow?: number | undefined;
77
+ shrink?: number | undefined;
63
78
  style?: StyleProp<ViewStyle>;
64
79
  } & import("react").RefAttributes<View>>;
65
80
  export {};
@@ -1,18 +1,17 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { StyleSheet, View } from "react-native";
4
- /* eslint-disable react-native/no-unused-styles */
5
- const directionStyles = StyleSheet.create({
6
- columnReverse: { flexDirection: "column-reverse" },
7
- row: { flexDirection: "row" },
8
- rowReverse: { flexDirection: "row-reverse" },
9
- });
10
4
  const alignItemsStyles = StyleSheet.create({
11
5
  baseline: { alignItems: "baseline" },
12
6
  center: { alignItems: "center" },
13
7
  end: { alignItems: "flex-end" },
14
8
  start: { alignItems: "flex-start" },
15
9
  });
10
+ const directionStyles = StyleSheet.create({
11
+ columnReverse: { flexDirection: "column-reverse" },
12
+ row: { flexDirection: "row" },
13
+ rowReverse: { flexDirection: "row-reverse" },
14
+ });
16
15
  const justifyContentStyles = StyleSheet.create({
17
16
  center: { justifyContent: "center" },
18
17
  end: { justifyContent: "flex-end" },
@@ -21,11 +20,22 @@ const justifyContentStyles = StyleSheet.create({
21
20
  spaceAround: { justifyContent: "space-around" },
22
21
  spaceEvenly: { justifyContent: "space-evenly" },
23
22
  });
23
+ const wrapStyles = StyleSheet.create({
24
+ wrap: { flexWrap: "wrap" },
25
+ wrapReverse: { flexWrap: "wrap-reverse" },
26
+ });
27
+ const otherStyles = StyleSheet.create({
28
+ grow1: { flexGrow: 1 },
29
+ shrink1: { flexShrink: 1 },
30
+ });
24
31
  export const Box = forwardRef((
25
- // Default <View /> styles https://github.com/necolas/react-native-web/blob/0.19.1/packages/react-native-web/src/exports/View/index.js#L146
26
- { alignItems = "stretch", direction = "column", justifyContent = "normal", style, ...props }, forwardedRef) => (_jsx(View, { ref: forwardedRef, ...props, style: [
32
+ // Default <View /> styles https://github.com/necolas/react-native-web/blob/0.19.10/packages/react-native-web/src/exports/View/index.js#L146
33
+ { alignItems = "stretch", direction = "column", justifyContent = "normal", wrap = "nowrap", grow = 0, shrink = 0, style, ...props }, forwardedRef) => (_jsx(View, { ref: forwardedRef, ...props, style: [
27
34
  alignItems !== "stretch" && alignItemsStyles[alignItems],
28
35
  direction !== "column" && directionStyles[direction],
29
36
  justifyContent !== "normal" && justifyContentStyles[justifyContent],
37
+ wrap !== "nowrap" && wrapStyles[wrap],
38
+ grow !== 0 && (grow === 1 ? otherStyles.grow1 : { flexGrow: grow }),
39
+ shrink !== 0 && (shrink === 1 ? otherStyles.shrink1 : { flexShrink: shrink }),
30
40
  style,
31
41
  ] })));
@@ -1,5 +1,5 @@
1
1
  import { DateFormat, DatePickerDate } from "@swan-io/shared-business/src/components/DatePicker";
2
- import { ValidatorResult } from "react-ux-form";
2
+ import { ValidatorResult } from "@swan-io/use-form";
3
3
  import { Simplify } from "type-fest";
4
4
  type Item<T> = {
5
5
  label: string;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { DatePickerModal, } from "@swan-io/shared-business/src/components/DatePicker";
3
+ import { useForm } from "@swan-io/use-form";
3
4
  import dayjs from "dayjs";
4
5
  import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
5
6
  import { FlatList, Pressable, StyleSheet, Text, View } from "react-native";
6
- import { hasDefinedKeys, useForm } from "react-ux-form";
7
7
  import { P, match } from "ts-pattern";
8
8
  import { colors, shadows, spacings } from "../constants/design";
9
9
  import { useDisclosure } from "../hooks/useDisclosure";
@@ -161,7 +161,7 @@ function FilterDate({ label, initialValue, noValueText, cancelText, submitText,
161
161
  return (_jsxs(View, { style: styles.container, children: [_jsx(FilterTag, { label: label, onPress: toggle, ref: inputRef, onPressRemove: onPressRemove, isActive: visible, value: isNotNullish(initialValue) ? dayjs(initialValue).format(dateFormat) : noValueText }), _jsx(DatePickerModal, { visible: visible, format: dateFormat, firstWeekDay: "monday", label: label, cancelLabel: cancelText, confirmLabel: submitText, value: value, isSelectable: isSelectable, validate: validate, onChange: value => {
162
162
  const formattedValue = dayjs(value, dateFormat, true).toJSON();
163
163
  onSave(formattedValue);
164
- }, onDissmiss: close })] }));
164
+ }, onDismiss: close })] }));
165
165
  }
166
166
  function FilterInput({ label, initialValue = "", noValueText, submitText, autoOpen = false, placeholder, validate, onSave, onPressRemove, }) {
167
167
  const inputRef = useRef(null);
@@ -174,12 +174,14 @@ function FilterInput({ label, initialValue = "", noValueText, submitText, autoOp
174
174
  },
175
175
  });
176
176
  const onSubmit = () => {
177
- submitForm(values => {
178
- if (hasDefinedKeys(values, ["input"])) {
179
- setValue(values.input);
180
- onSave(values.input);
181
- close();
182
- }
177
+ submitForm({
178
+ onSuccess: ({ input }) => {
179
+ if (input.isSome()) {
180
+ setValue(input.get());
181
+ onSave(input.get());
182
+ close();
183
+ }
184
+ },
183
185
  });
184
186
  };
185
187
  return (_jsxs(View, { style: styles.container, children: [_jsx(FilterTag, { label: label, onPress: toggle, ref: inputRef, onPressRemove: onPressRemove, isActive: visible, value: value === "" ? noValueText : value }), _jsx(Popover, { role: "listbox", matchReferenceWidth: false, onDismiss: close, referenceRef: inputRef, returnFocus: false, visible: visible, children: _jsxs(View, { style: [styles.dropdown, styles.inputContent], children: [_jsx(Field, { name: "input", children: ({ error, value, onChange }) => (_jsx(LakeLabel, { label: label, render: id => (_jsx(LakeTextInput, { id: id, error: error, style: styles.input, placeholder: placeholder, value: value, onChangeText: onChange, onSubmitEditing: onSubmit })) })) }), _jsx(LakeButton, { size: "small", color: "current", onPress: onSubmit, children: submitText })] }) })] }));
@@ -197,7 +199,7 @@ export const FiltersStack = ({ filters, openedFilters, definition, onChangeOpene
197
199
  if (openedFilters.length === 0) {
198
200
  return null;
199
201
  }
200
- return (_jsx(Stack, { direction: "row", wrap: true, children: openedFilters.map(filterName => {
202
+ return (_jsx(Stack, { direction: "row", wrap: "wrap", children: openedFilters.map(filterName => {
201
203
  const filterDefinition = definition[filterName];
202
204
  if (typeof filterName !== "string" || filterDefinition == null) {
203
205
  return null;
@@ -21,14 +21,17 @@ export type SelectProps<V> = {
21
21
  disabled?: boolean;
22
22
  value?: V;
23
23
  onValueChange: (value: V) => void;
24
- isItemDisabled?: (value: V) => boolean | string;
24
+ disabledItems?: {
25
+ value: V;
26
+ message?: string;
27
+ }[];
25
28
  hideErrors?: boolean;
26
29
  id?: string;
27
30
  error?: string;
28
31
  readOnly?: boolean;
29
32
  style?: StyleProp<ViewStyle>;
30
33
  };
31
- declare const LakeSelectWithRef: <V>({ title, items, valueStyle, size, color, disabled, mode, placeholder, readOnly, id, matchReferenceWidth, value, error, hideErrors, icon, onValueChange, isItemDisabled, PopoverFooter, style, }: SelectProps<V>, forwardedRef: ForwardedRef<View>) => import("react/jsx-runtime").JSX.Element;
34
+ declare const LakeSelectWithRef: <V>({ title, items, valueStyle, size, color, disabled, mode, placeholder, readOnly, id, matchReferenceWidth, value, error, hideErrors, icon, onValueChange, disabledItems, PopoverFooter, style, }: SelectProps<V>, forwardedRef: ForwardedRef<View>) => import("react/jsx-runtime").JSX.Element;
32
35
  export declare const LakeSelect: <I>(props: SelectProps<I> & {
33
36
  ref?: ForwardedRef<View> | undefined;
34
37
  }) => ReturnType<typeof LakeSelectWithRef>;
@@ -6,7 +6,7 @@ import { colors, invariantColors, radii, shadows, spacings, texts, } from "../co
6
6
  import { useDisclosure } from "../hooks/useDisclosure";
7
7
  import { useMergeRefs } from "../hooks/useMergeRefs";
8
8
  import { getFocusableElements } from "../utils/a11y";
9
- import { isNotNullish } from "../utils/nullish";
9
+ import { isNotNullish, isNullishOrEmpty } from "../utils/nullish";
10
10
  import { Box } from "./Box";
11
11
  import { Fill } from "./Fill";
12
12
  import { Icon } from "./Icon";
@@ -111,7 +111,7 @@ const styles = StyleSheet.create({
111
111
  borderColor: colors.negative[500],
112
112
  },
113
113
  });
114
- const LakeSelectWithRef = ({ title, items, valueStyle, size, color = "current", disabled = false, mode = "normal", placeholder, readOnly = false, id, matchReferenceWidth = true, value, error, hideErrors = false, icon, onValueChange, isItemDisabled, PopoverFooter, style, }, forwardedRef) => {
114
+ const LakeSelectWithRef = ({ title, items, valueStyle, size, color = "current", disabled = false, mode = "normal", placeholder, readOnly = false, id, matchReferenceWidth = true, value, error, hideErrors = false, icon, onValueChange, disabledItems = [], PopoverFooter, style, }, forwardedRef) => {
115
115
  var _a;
116
116
  const inputRef = useRef(null);
117
117
  const listRef = useRef(null);
@@ -188,12 +188,12 @@ const LakeSelectWithRef = ({ title, items, valueStyle, size, color = "current",
188
188
  }
189
189
  }, keyExtractor: (_, index) => `select-item-${index}`, renderItem: ({ item, index }) => {
190
190
  const isSelected = value === item.value;
191
- const isDisabled = isNotNullish(isItemDisabled) && isItemDisabled(item.value);
192
- return (_jsx(LakeTooltip, { placement: "right", content: isDisabled, disabled: typeof isDisabled !== "string", children: _jsxs(Pressable, { ref: element => (listItemRefs.current[index] = element), onKeyDown: onKeyDown, disabled: isDisabled !== false, style: ({ hovered, focused }) => [
191
+ const disablement = disabledItems.find(({ value }) => value === item.value);
192
+ return (_jsx(LakeTooltip, { placement: "right", content: disablement === null || disablement === void 0 ? void 0 : disablement.message, disabled: isNullishOrEmpty(disablement === null || disablement === void 0 ? void 0 : disablement.message), children: _jsxs(Pressable, { ref: element => (listItemRefs.current[index] = element), onKeyDown: onKeyDown, disabled: isNotNullish(disablement), style: ({ hovered, focused }) => [
193
193
  styles.item,
194
194
  (hovered || isSelected) && styles.itemHighlighted,
195
195
  focused && styles.itemFocused,
196
- isDisabled !== false && styles.itemDisabled,
196
+ isNotNullish(disablement) && styles.itemDisabled,
197
197
  ], role: "option", "aria-selected": true, onPress: () => {
198
198
  onValueChange(item.value);
199
199
  close();
@@ -1,12 +1,12 @@
1
- export type SliderProps = {
2
- label: string;
3
- value: number;
1
+ import { ViewProps } from "react-native";
2
+ type Props = {
4
3
  min: number;
5
4
  max: number;
5
+ value: number;
6
6
  step: number;
7
- unit: string;
8
7
  disabled?: boolean;
8
+ style?: ViewProps["style"];
9
9
  onChange: (value: number) => void;
10
10
  };
11
- export declare const sliderBreakpoint: number;
12
- export declare const LakeSlider: ({ label, value, min, max, step, unit, disabled, onChange, }: SliderProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const LakeSlider: ({ min, max, value, step, disabled, style, onChange }: Props) => import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -1,35 +1,14 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useState } from "react";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
3
  import { StyleSheet, View } from "react-native";
4
4
  import { commonStyles } from "../constants/commonStyles";
5
- import { breakpoints } from "../constants/design";
6
- import { Box } from "./Box";
7
- import { LakeLabel } from "./LakeLabel";
8
- import { LakeTextInput } from "./LakeTextInput";
9
- import { ResponsiveContainer } from "./ResponsiveContainer";
10
5
  const styles = StyleSheet.create({
11
6
  container: {
7
+ paddingHorizontal: 10, // the slider thumb has a 20px size
12
8
  zIndex: 1,
13
9
  },
14
- input: {
15
- maxWidth: 120,
16
- zIndex: 1,
17
- position: "relative",
18
- },
19
10
  });
20
- export const sliderBreakpoint = breakpoints.tiny;
21
- export const LakeSlider = ({ label, value, min, max, step, unit, disabled = false, onChange, }) => {
22
- const [dirtyValue, setDirtyValue] = useState(String(value));
23
- useEffect(() => {
24
- setDirtyValue(String(value));
25
- }, [value]);
26
- const sanitizeInput = useCallback(() => {
27
- const cleanValue = Math.max(Math.min(Number(dirtyValue), max), min);
28
- setDirtyValue(String(cleanValue));
29
- onChange(cleanValue);
30
- }, [min, max, dirtyValue, onChange]);
31
- 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, inputMode: "decimal", disabled: disabled }) }) }), _jsx("input", { type: "range", min: min, max: max, step: step, value: value, disabled: disabled, onChange: event => onChange(Number(event.target.value)), style: {
32
- backgroundSize: `${((value - min) / (max - min)) * 100}% 100%`,
33
- ...(disabled ? commonStyles.disabled : {}),
34
- } })] })) : (_jsx(LakeLabel, { label: label, render: id => (_jsx(LakeTextInput, { id: id, unit: unit, value: dirtyValue, onChangeText: setDirtyValue, onBlur: sanitizeInput, inputMode: "decimal", disabled: disabled })) })) })) }));
35
- };
11
+ export const LakeSlider = ({ min, max, value, step, disabled = false, style, onChange }) => (_jsx(View, { style: [styles.container, style], children: _jsx("input", { type: "range", min: min, max: max, value: value, step: step, disabled: disabled, onChange: useCallback((event) => onChange(Number(event.target.value)), [onChange]), style: {
12
+ backgroundSize: `${((value - min) / (max - min)) * 100}% 100%`,
13
+ ...(disabled ? commonStyles.disabled : {}),
14
+ } }) }));
@@ -5,8 +5,10 @@ export declare const Stack: import("react").ForwardRefExoticComponent<import("re
5
5
  children?: import("react").ReactNode;
6
6
  direction?: ("row" | "column" | "columnReverse" | "rowReverse") | undefined;
7
7
  justifyContent?: ("end" | "start" | "normal" | "center" | "spaceBetween" | "spaceAround" | "spaceEvenly") | undefined;
8
+ wrap?: ("nowrap" | "wrap" | "wrapReverse") | undefined;
9
+ grow?: number | undefined;
10
+ shrink?: number | undefined;
8
11
  style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
9
12
  } & {
10
13
  space?: 4 | 16 | 8 | 12 | 20 | 24 | 32 | 40 | 48 | 72 | 96 | undefined;
11
- wrap?: boolean | undefined;
12
14
  } & import("react").RefAttributes<View>>;
@@ -1,20 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Children, forwardRef, Fragment } from "react";
3
- import { StyleSheet } from "react-native";
4
3
  import { isNullish } from "../utils/nullish";
5
4
  import { Box } from "./Box";
6
5
  import { Space } from "./Space";
7
- const styles = StyleSheet.create({
8
- wrap: {
9
- flexWrap: "wrap",
10
- },
11
- });
12
6
  export const Stack = forwardRef(
13
- // Default <View /> styles https://github.com/necolas/react-native-web/blob/0.19.1/packages/react-native-web/src/exports/View/index.js#L146
14
- ({ children, space, wrap = false, ...props }, forwardedRef) => {
7
+ // Default <View /> styles https://github.com/necolas/react-native-web/blob/0.19.10/packages/react-native-web/src/exports/View/index.js#L146
8
+ ({ children, space, ...props }, forwardedRef) => {
15
9
  const { direction = "column" } = props;
16
10
  const horizontal = direction === "row" || direction === "rowReverse";
17
- return (_jsx(Box, { style: wrap && styles.wrap, ref: forwardedRef, ...props, children: Children.map(children, (child, index) => {
11
+ return (_jsx(Box, { ref: forwardedRef, ...props, children: Children.map(children, (child, index) => {
18
12
  if (isNullish(child)) {
19
13
  return child;
20
14
  }
@@ -2,8 +2,6 @@ export declare const identity: <T>(value: T) => T;
2
2
  export declare const noop: () => void;
3
3
  export declare const stubFalse: () => false;
4
4
  export declare const stubTrue: () => true;
5
- export declare const unionToArray: <T extends PropertyKey>(object: Record<T, true>) => T[];
6
- export declare const getUnionGuard: <T extends PropertyKey>(object: Record<T, true>) => (value: unknown) => value is T;
7
5
  export declare const deriveUnion: <T extends PropertyKey>(object: Record<T, true>) => {
8
6
  array: T[];
9
7
  set: Set<T>;
@@ -4,11 +4,6 @@ export const identity = (value) => value;
4
4
  export const noop = () => { };
5
5
  export const stubFalse = () => false;
6
6
  export const stubTrue = () => true;
7
- export const unionToArray = (object) => Dict.keys(object);
8
- export const getUnionGuard = (object) => {
9
- const set = new Set(unionToArray(object));
10
- return (value) => set.has(value);
11
- };
12
7
  export const deriveUnion = (object) => {
13
8
  const array = Dict.keys(object);
14
9
  const set = new Set(array);
@@ -1,16 +0,0 @@
1
- import { ReactText } from "react";
2
- import { GestureResponderEvent, StyleProp, View, ViewStyle } from "react-native";
3
- import { IconName } from "./Icon";
4
- type Props = {
5
- ariaLabel?: string;
6
- children?: ReactText;
7
- color?: string;
8
- disabled?: boolean;
9
- loading?: boolean;
10
- icon?: IconName;
11
- onPress?: (event: GestureResponderEvent) => void;
12
- size?: "large" | "small";
13
- style?: StyleProp<ViewStyle>;
14
- };
15
- export declare const BorderedButton: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<View>>>;
16
- export {};
@@ -1,100 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, memo } from "react";
3
- import { ActivityIndicator, Pressable, StyleSheet, Text, View, } from "react-native";
4
- import { colors } from "../constants/colors";
5
- import { typography } from "../constants/typography";
6
- import { isNotNullish } from "../utils/nullish";
7
- import { Icon } from "./Icon";
8
- import { Space } from "./Space";
9
- const styles = StyleSheet.create({
10
- base: {
11
- alignItems: "center",
12
- backgroundColor: colors.white,
13
- borderColor: colors.gray[10],
14
- borderRadius: 4,
15
- borderWidth: 1,
16
- flexDirection: "row",
17
- flexShrink: 1,
18
- height: 48,
19
- justifyContent: "center",
20
- overflow: "hidden",
21
- paddingLeft: 20,
22
- paddingRight: 20,
23
- transitionDuration: "150ms",
24
- transitionProperty: "background-color",
25
- },
26
- small: {
27
- height: 40,
28
- paddingLeft: 16,
29
- paddingRight: 16,
30
- },
31
- withIcon: {
32
- paddingLeft: 18,
33
- },
34
- withIconSmall: {
35
- paddingLeft: 14,
36
- },
37
- iconOnly: {
38
- paddingLeft: 13,
39
- paddingRight: 13,
40
- },
41
- iconOnlySmall: {
42
- paddingLeft: 10,
43
- paddingRight: 10,
44
- },
45
- hovered: {
46
- backgroundColor: colors.gray[3],
47
- },
48
- pressed: {
49
- backgroundColor: colors.gray[10],
50
- },
51
- disabled: {
52
- backgroundColor: colors.gray[3],
53
- borderColor: colors.gray[3],
54
- cursor: "not-allowed",
55
- },
56
- text: {
57
- ...typography.bodyLarge,
58
- fontWeight: typography.fontWeights.demi,
59
- lineHeight: 48,
60
- userSelect: "none",
61
- },
62
- textSmall: {
63
- ...typography.bodySmall,
64
- fontWeight: typography.fontWeights.demi,
65
- lineHeight: 40,
66
- userSelect: "none",
67
- },
68
- textDisabled: {
69
- color: colors.gray[50],
70
- },
71
- loaderContainer: {
72
- ...StyleSheet.absoluteFillObject,
73
- alignItems: "center",
74
- backgroundColor: colors.white,
75
- justifyContent: "center",
76
- },
77
- });
78
- export const BorderedButton = memo(forwardRef(({ ariaLabel, children = "", color = colors.gray[100], disabled = false, loading = false, icon, onPress, size = "large", style, }, forwardedRef) => {
79
- const hasText = children !== "";
80
- const isSmall = size === "small";
81
- const iconSize = isSmall ? 18 : 20;
82
- return (_jsxs(Pressable, { role: "button", "aria-label": ariaLabel, "aria-busy": loading, "aria-disabled": disabled, disabled: loading || disabled, ref: forwardedRef, onPress: onPress, style: ({ hovered, pressed }) => [
83
- styles.base,
84
- isSmall && styles.small,
85
- isNotNullish(icon) && (isSmall ? styles.withIconSmall : styles.withIcon),
86
- !hasText && (isSmall ? styles.iconOnlySmall : styles.iconOnly),
87
- disabled
88
- ? styles.disabled
89
- : pressed
90
- ? styles.pressed
91
- : hovered
92
- ? styles.hovered
93
- : false,
94
- style,
95
- ], children: [icon && _jsx(Icon, { color: color, name: icon, size: iconSize }), hasText && isNotNullish(icon) && _jsx(Space, { width: isSmall ? 8 : 12 }), hasText && (_jsx(Text, { numberOfLines: 1, style: [
96
- isSmall ? styles.textSmall : styles.text,
97
- disabled ? styles.textDisabled : { color },
98
- ], children: children })), loading && (_jsx(View, { role: "none", style: styles.loaderContainer, children: _jsx(ActivityIndicator, { color: disabled ? colors.gray[50] : colors.gray[100], size: iconSize }) }))] }));
99
- }));
100
- BorderedButton.displayName = "BorderedButton";
@@ -1,6 +0,0 @@
1
- import { ReactText } from "react";
2
- import { Text, TextProps } from "react-native";
3
- export declare const Caption: import("react").ForwardRefExoticComponent<TextProps & {
4
- align?: "left" | "right" | "center" | undefined;
5
- children: ReactText;
6
- } & import("react").RefAttributes<Text>>;
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { StyleSheet, Text } from "react-native";
4
- import { typography } from "../constants/typography";
5
- /* eslint-disable react-native/no-unused-styles */
6
- const styles = StyleSheet.create({
7
- center: { ...typography.caption, textAlign: "center" },
8
- left: { ...typography.caption, textAlign: "left" },
9
- right: { ...typography.caption, textAlign: "right" },
10
- });
11
- export const Caption = forwardRef(({ children, align = "left", style, ...props }, forwardedRef) => (_jsx(Text, { ref: forwardedRef, style: [styles[align], style], ...props, children: children })));
@@ -1,7 +0,0 @@
1
- import { StyleProp, ViewStyle } from "react-native";
2
- type Props = {
3
- size: number;
4
- style?: StyleProp<ViewStyle>;
5
- };
6
- export declare const FailureIcon: ({ size, style }: Props) => import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,4 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { colors } from "../constants/colors";
3
- import { Path, Svg } from "./Svg";
4
- export const FailureIcon = ({ size, style }) => (_jsx(Svg, { viewBox: "0 0 24 24", style: [{ height: size, width: size }, style], children: _jsx(Path, { d: "M12 0a12 12 0 110 24 12 12 0 010-24zM8.9 7.57A.95.95 0 007.58 8.9l3.08 3.1-3.1 3.1a.95.95 0 101.35 1.33L12 13.34l3.1 3.1a.95.95 0 101.33-1.35L13.34 12l3.1-3.1a.95.95 0 10-1.35-1.33L12 10.66z", fill: colors.red[100] }) }));