@swan-io/lake 11.4.3 → 12.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/package.json +15 -16
- package/src/components/AutoWidthImage.d.ts +8 -105
- package/src/components/AutoWidthImage.js +4 -4
- package/src/components/AutocompleteSearchInput.d.ts +2 -2
- package/src/components/AutocompleteSearchInput.js +1 -1
- package/src/components/Avatar.d.ts +0 -7
- package/src/components/Avatar.js +3 -6
- package/src/components/Box.d.ts +3 -11
- package/src/components/Box.js +3 -5
- package/src/components/Card3dPreview.d.ts +3 -1
- package/src/components/Card3dPreview.js +4 -4
- package/src/components/Cells.d.ts +1 -66
- package/src/components/Cells.js +1 -50
- package/src/components/FlatList.d.ts +3 -5
- package/src/components/FlatList.js +3 -4
- package/src/components/FocusTrap.d.ts +6 -5
- package/src/components/FocusTrap.js +3 -3
- package/src/components/Form.d.ts +35 -9
- package/src/components/Form.js +4 -4
- package/src/components/LakeButton.d.ts +3 -2
- package/src/components/LakeButton.js +4 -4
- package/src/components/LakeCombobox.d.ts +8 -11
- package/src/components/LakeCombobox.js +7 -8
- package/src/components/LakeHeading.d.ts +7 -102
- package/src/components/LakeHeading.js +2 -3
- package/src/components/LakeSelect.d.ts +3 -6
- package/src/components/LakeSelect.js +3 -4
- package/src/components/LakeTagInput.d.ts +7 -207
- package/src/components/LakeTagInput.js +7 -9
- package/src/components/LakeText.d.ts +5 -3
- package/src/components/LakeText.js +2 -3
- package/src/components/LakeTextInput.d.ts +3 -218
- package/src/components/LakeTextInput.js +5 -5
- package/src/components/LakeTooltip.d.ts +10 -8
- package/src/components/LakeTooltip.js +8 -8
- package/src/components/Link.d.ts +3 -122
- package/src/components/Link.js +4 -4
- package/src/components/ListRightPanel.d.ts +3 -4
- package/src/components/ListRightPanel.js +2 -5
- package/src/components/LoadingView.d.ts +3 -1
- package/src/components/LoadingView.js +1 -2
- package/src/components/PlainListView.d.ts +5 -3
- package/src/components/Popover.d.ts +1 -1
- package/src/components/Pressable.d.ts +1 -0
- package/src/components/Pressable.js +6 -6
- package/src/components/RightPanel.d.ts +3 -2
- package/src/components/RightPanel.js +3 -3
- package/src/components/ScrollView.d.ts +3 -8
- package/src/components/ScrollView.js +4 -4
- package/src/components/SectionList.d.ts +3 -5
- package/src/components/SectionList.js +3 -4
- package/src/components/Stack.d.ts +7 -11
- package/src/components/Stack.js +5 -6
- package/src/components/Switch.d.ts +3 -1
- package/src/components/Switch.js +2 -4
- package/src/components/TabView.js +5 -5
- package/src/components/Tag.d.ts +2 -2
- package/src/components/Tile.js +3 -1
- package/src/components/WithCurrentColor.d.ts +3 -3
- package/src/hooks/useBreakpoint.js +1 -1
- package/src/hooks/useContextualLayer.d.ts +3 -3
- package/src/hooks/useForceableState.js +1 -1
- package/src/hooks/useHover.d.ts +2 -2
- package/src/hooks/useHover.js +1 -1
- package/src/hooks/useMergeRefs.d.ts +2 -2
- package/src/hooks/useMergeRefs.js +1 -2
- package/src/hooks/useNativeProp.d.ts +2 -2
- package/src/hooks/usePressEvents.d.ts +2 -2
- package/src/hooks/usePressEvents.js +1 -1
- package/src/utils/clipboard.js +1 -1
- package/src/utils/refs.d.ts +2 -2
- package/src/utils/windowSize.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { memo, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
3
|
import { StyleSheet, View } from "react-native";
|
|
4
4
|
import { match } from "ts-pattern";
|
|
5
5
|
import { colors, shadows, spacings } from "../constants/design";
|
|
@@ -44,13 +44,13 @@ const styles = StyleSheet.create({
|
|
|
44
44
|
flexGrow: 0,
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
|
-
export const LakeTooltip =
|
|
47
|
+
export const LakeTooltip = ({ ref, content, children, ...rest }) => {
|
|
48
48
|
if (isNullishOrEmpty(content)) {
|
|
49
49
|
return children;
|
|
50
50
|
}
|
|
51
|
-
return (_jsx(Tooltip, { ref:
|
|
52
|
-
}
|
|
53
|
-
const Tooltip = memo(
|
|
51
|
+
return (_jsx(Tooltip, { ref: ref, content: content, ...rest, children: children }));
|
|
52
|
+
};
|
|
53
|
+
const Tooltip = memo(({ ref, children, content, describedBy, matchReferenceWidth = false, hideArrow = false, onHide, onShow, placement, width, maxWidth, togglableOnFocus = false, containerStyle, disabled = false, }) => {
|
|
54
54
|
const timeoutRef = useRef(0);
|
|
55
55
|
const [visible, setVisible] = useState(false);
|
|
56
56
|
const { referenceRef, position } = useContextualLayer({
|
|
@@ -59,7 +59,7 @@ const Tooltip = memo(forwardRef(({ children, content, describedBy, matchReferenc
|
|
|
59
59
|
matchReferenceWidth,
|
|
60
60
|
});
|
|
61
61
|
const rootElement = getRootElement(referenceRef.current);
|
|
62
|
-
useImperativeHandle(
|
|
62
|
+
useImperativeHandle(ref, () => ({
|
|
63
63
|
show: () => setVisible(true),
|
|
64
64
|
hide: () => setVisible(false),
|
|
65
65
|
}));
|
|
@@ -122,5 +122,5 @@ const Tooltip = memo(forwardRef(({ children, content, describedBy, matchReferenc
|
|
|
122
122
|
.with("center", () => "center")
|
|
123
123
|
.with("right", () => "end")
|
|
124
124
|
.exhaustive(), style: [styles.arrowBar, styles.arrowBarBottom], children: _jsx(Svg, { width: 16, height: 8, viewBox: "0 0 16 8", children: _jsx(Polygon, { points: "8 8 16 0 0 0", fill: hideArrow ? "transparent" : colors.gray[900] }) }) })) : null] }) }) }))] }));
|
|
125
|
-
})
|
|
126
|
-
export const InformationTooltip =
|
|
125
|
+
});
|
|
126
|
+
export const InformationTooltip = ({ ref, text, icon = "info-regular", iconSize = 24, }) => (_jsx(LakeTooltip, { ref: ref, describedBy: "copy", placement: "right", togglableOnFocus: true, width: 300, content: text, children: _jsx(View, { style: styles.info, children: _jsx(Icon, { name: icon, size: iconSize, color: colors.gray[900] }) }) }));
|
package/src/components/Link.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Ref } from "react";
|
|
1
2
|
import { HrefAttrs, PressableStateCallbackType, Text, TextProps } from "react-native";
|
|
2
3
|
import { Except } from "type-fest";
|
|
3
4
|
import { PressableTextProps } from "./Pressable";
|
|
4
5
|
export type LinkProps = Except<PressableTextProps, "hrefAttrs" | "style" | "onPress" | "children"> & {
|
|
6
|
+
ref?: Ref<Text>;
|
|
5
7
|
to: string;
|
|
6
8
|
replace?: boolean;
|
|
7
9
|
disabled?: boolean;
|
|
@@ -16,125 +18,4 @@ export type LinkProps = Except<PressableTextProps, "hrefAttrs" | "style" | "onPr
|
|
|
16
18
|
active: boolean;
|
|
17
19
|
}) => TextProps["children"]);
|
|
18
20
|
};
|
|
19
|
-
export declare const Link: import("react").MemoExoticComponent<import("react").
|
|
20
|
-
allowFontScaling?: boolean | undefined | undefined;
|
|
21
|
-
ellipsizeMode?: "head" | "middle" | "tail" | "clip" | undefined | undefined;
|
|
22
|
-
id?: string | undefined | undefined;
|
|
23
|
-
lineBreakMode?: "head" | "middle" | "tail" | "clip" | undefined | undefined;
|
|
24
|
-
numberOfLines?: number | undefined | undefined;
|
|
25
|
-
onTextLayout?: ((event: import("react-native").NativeSyntheticEvent<import("react-native").TextLayoutEventData>) => void) | undefined | undefined;
|
|
26
|
-
testID?: string | undefined | undefined;
|
|
27
|
-
nativeID?: string | undefined | undefined;
|
|
28
|
-
maxFontSizeMultiplier?: number | null | undefined | undefined;
|
|
29
|
-
role?: import("react-native").WebRole | undefined;
|
|
30
|
-
href?: string | undefined;
|
|
31
|
-
lang?: string | undefined;
|
|
32
|
-
adjustsFontSizeToFit?: boolean | undefined | undefined;
|
|
33
|
-
dynamicTypeRamp?: "caption2" | "caption1" | "footnote" | "subheadline" | "callout" | "body" | "headline" | "title3" | "title2" | "title1" | "largeTitle" | undefined | undefined;
|
|
34
|
-
minimumFontScale?: number | undefined | undefined;
|
|
35
|
-
suppressHighlighting?: boolean | undefined | undefined;
|
|
36
|
-
lineBreakStrategyIOS?: "none" | "standard" | "hangul-word" | "push-out" | undefined | undefined;
|
|
37
|
-
selectable?: boolean | undefined | undefined;
|
|
38
|
-
selectionColor?: import("react-native").ColorValue | undefined;
|
|
39
|
-
textBreakStrategy?: "simple" | "highQuality" | "balanced" | undefined | undefined;
|
|
40
|
-
dataDetectorType?: null | "phoneNumber" | "link" | "email" | "none" | "all" | undefined | undefined;
|
|
41
|
-
android_hyphenationFrequency?: "normal" | "none" | "full" | undefined | undefined;
|
|
42
|
-
accessible?: boolean | undefined | undefined;
|
|
43
|
-
accessibilityActions?: readonly Readonly<{
|
|
44
|
-
name: import("react-native").AccessibilityActionName | string;
|
|
45
|
-
label?: string | undefined;
|
|
46
|
-
}>[] | undefined;
|
|
47
|
-
accessibilityLabel?: string | undefined | undefined;
|
|
48
|
-
"aria-label"?: string | undefined | undefined;
|
|
49
|
-
accessibilityRole?: import("react-native").AccessibilityRole | undefined;
|
|
50
|
-
accessibilityState?: import("react-native").AccessibilityState | undefined;
|
|
51
|
-
"aria-busy"?: boolean | undefined | undefined;
|
|
52
|
-
"aria-checked"?: boolean | "mixed" | undefined | undefined;
|
|
53
|
-
"aria-disabled"?: boolean | undefined | undefined;
|
|
54
|
-
"aria-expanded"?: boolean | undefined | undefined;
|
|
55
|
-
"aria-selected"?: boolean | undefined | undefined;
|
|
56
|
-
"aria-labelledby"?: string | undefined | undefined;
|
|
57
|
-
accessibilityHint?: string | undefined | undefined;
|
|
58
|
-
accessibilityValue?: import("react-native").AccessibilityValue | undefined;
|
|
59
|
-
"aria-valuemax"?: number | undefined;
|
|
60
|
-
"aria-valuemin"?: number | undefined;
|
|
61
|
-
"aria-valuenow"?: number | undefined;
|
|
62
|
-
"aria-valuetext"?: string | undefined;
|
|
63
|
-
onAccessibilityAction?: ((event: import("react-native").AccessibilityActionEvent) => void) | undefined | undefined;
|
|
64
|
-
importantForAccessibility?: ("auto" | "yes" | "no" | "no-hide-descendants") | undefined | undefined;
|
|
65
|
-
"aria-hidden"?: boolean | undefined | undefined;
|
|
66
|
-
"aria-live"?: ("polite" | "assertive" | "off") | undefined | undefined;
|
|
67
|
-
"aria-modal"?: boolean | undefined | undefined;
|
|
68
|
-
accessibilityLiveRegion?: "none" | "polite" | "assertive" | undefined | undefined;
|
|
69
|
-
accessibilityLabelledBy?: string | string[] | undefined | undefined;
|
|
70
|
-
accessibilityElementsHidden?: boolean | undefined | undefined;
|
|
71
|
-
accessibilityViewIsModal?: boolean | undefined | undefined;
|
|
72
|
-
onAccessibilityEscape?: (() => void) | undefined | undefined;
|
|
73
|
-
onAccessibilityTap?: (() => void) | undefined | undefined;
|
|
74
|
-
onMagicTap?: (() => void) | undefined | undefined;
|
|
75
|
-
accessibilityIgnoresInvertColors?: boolean | undefined | undefined;
|
|
76
|
-
accessibilityLanguage?: string | undefined | undefined;
|
|
77
|
-
tabIndex?: 0 | -1 | undefined;
|
|
78
|
-
"aria-activedescendant"?: string | undefined;
|
|
79
|
-
"aria-atomic"?: boolean | undefined;
|
|
80
|
-
"aria-autocomplete"?: string | undefined;
|
|
81
|
-
"aria-colcount"?: number | undefined;
|
|
82
|
-
"aria-colindex"?: number | undefined;
|
|
83
|
-
"aria-colspan"?: number | undefined;
|
|
84
|
-
"aria-controls"?: string | undefined;
|
|
85
|
-
"aria-current"?: boolean | "page" | "step" | "location" | "date" | "time" | undefined;
|
|
86
|
-
"aria-describedby"?: string | undefined;
|
|
87
|
-
"aria-details"?: string | undefined;
|
|
88
|
-
"aria-errormessage"?: string | undefined;
|
|
89
|
-
"aria-flowto"?: string | undefined;
|
|
90
|
-
"aria-haspopup"?: string | undefined;
|
|
91
|
-
"aria-invalid"?: boolean | undefined;
|
|
92
|
-
"aria-keyshortcuts"?: string | undefined;
|
|
93
|
-
"aria-level"?: number | undefined;
|
|
94
|
-
"aria-multiline"?: boolean | undefined;
|
|
95
|
-
"aria-multiselectable"?: boolean | undefined;
|
|
96
|
-
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
97
|
-
"aria-owns"?: string | undefined;
|
|
98
|
-
"aria-placeholder"?: string | undefined;
|
|
99
|
-
"aria-posinset"?: number | undefined;
|
|
100
|
-
"aria-pressed"?: boolean | undefined;
|
|
101
|
-
"aria-readonly"?: boolean | undefined;
|
|
102
|
-
"aria-required"?: boolean | undefined;
|
|
103
|
-
"aria-roledescription"?: string | undefined;
|
|
104
|
-
"aria-rowcount"?: number | undefined;
|
|
105
|
-
"aria-rowindex"?: number | undefined;
|
|
106
|
-
"aria-rowspan"?: number | undefined;
|
|
107
|
-
"aria-setsize"?: number | undefined;
|
|
108
|
-
"aria-sort"?: "ascending" | "descending" | "none" | "other" | undefined;
|
|
109
|
-
delayLongPress?: number | undefined;
|
|
110
|
-
delayPressIn?: number | undefined;
|
|
111
|
-
delayPressOut?: number | undefined;
|
|
112
|
-
disabled?: boolean | undefined;
|
|
113
|
-
onBlur?: ((event: import("react-native").NativeSyntheticEvent<React.FocusEvent>) => void) | undefined;
|
|
114
|
-
onContextMenu?: ((event: import("react-native").NativeSyntheticEvent<React.SyntheticEvent>) => void) | undefined;
|
|
115
|
-
onFocus?: ((event: import("react-native").NativeSyntheticEvent<React.FocusEvent>) => void) | undefined;
|
|
116
|
-
onHoverIn?: ((event: unknown) => void) | undefined;
|
|
117
|
-
onHoverOut?: ((event: unknown) => void) | undefined;
|
|
118
|
-
onKeyDown?: ((event: import("react-native").NativeSyntheticEvent<React.KeyboardEvent>) => void) | undefined;
|
|
119
|
-
onLayout?: ((event: import("react-native").LayoutChangeEvent) => void) | undefined;
|
|
120
|
-
onLongPress?: ((event: unknown) => void) | undefined;
|
|
121
|
-
onPressIn?: ((event: unknown) => void) | undefined;
|
|
122
|
-
onPressMove?: ((event: unknown) => void) | undefined;
|
|
123
|
-
onPressOut?: ((event: unknown) => void) | undefined;
|
|
124
|
-
testOnly_hovered?: boolean | undefined;
|
|
125
|
-
testOnly_pressed?: boolean | undefined;
|
|
126
|
-
} & {
|
|
127
|
-
to: string;
|
|
128
|
-
replace?: boolean;
|
|
129
|
-
disabled?: boolean;
|
|
130
|
-
download?: boolean;
|
|
131
|
-
target?: NonNullable<HrefAttrs>["target"];
|
|
132
|
-
style?: TextProps["style"] | ((state: PressableStateCallbackType & {
|
|
133
|
-
active: boolean;
|
|
134
|
-
}) => TextProps["style"]);
|
|
135
|
-
ariaCurrentValue?: "page" | "location";
|
|
136
|
-
onPress?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
137
|
-
children?: TextProps["children"] | ((state: PressableStateCallbackType & {
|
|
138
|
-
active: boolean;
|
|
139
|
-
}) => TextProps["children"]);
|
|
140
|
-
} & import("react").RefAttributes<Text>>>;
|
|
21
|
+
export declare const Link: import("react").MemoExoticComponent<({ ref, role, children, disabled, onPress, replace, download, style, target, to, ariaCurrentValue, tabIndex, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element>;
|
package/src/components/Link.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLinkProps } from "@swan-io/chicane";
|
|
3
|
-
import {
|
|
3
|
+
import { memo } from "react";
|
|
4
4
|
import { isNotNullish } from "../utils/nullish";
|
|
5
5
|
import { PressableText } from "./Pressable";
|
|
6
|
-
export const Link = memo(
|
|
6
|
+
export const Link = memo(({ ref, role = "link", children, disabled = false, onPress, replace = false, download = false, style, target, to, ariaCurrentValue = "page", tabIndex, ...props }) => {
|
|
7
7
|
const { active, onClick } = useLinkProps({ href: to, replace, target });
|
|
8
8
|
return (_jsx(PressableText, { ...props, role: role, disabled: disabled, "aria-disabled": disabled, tabIndex: isNotNullish(tabIndex) ? tabIndex : disabled ? -1 : 0, "aria-current": active ? ariaCurrentValue : undefined, href: !disabled ? to : undefined, onPress: (event) => {
|
|
9
9
|
const e = event;
|
|
@@ -14,10 +14,10 @@ export const Link = memo(forwardRef(({ role = "link", children, disabled = false
|
|
|
14
14
|
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
15
15
|
onClick(e);
|
|
16
16
|
}
|
|
17
|
-
}, ref:
|
|
17
|
+
}, ref: ref, style: typeof style === "function" ? state => style({ ...state, active }) : style, hrefAttrs: {
|
|
18
18
|
rel: target && target !== "self" ? "noopener noreferrer" : undefined,
|
|
19
19
|
download,
|
|
20
20
|
target,
|
|
21
21
|
}, children: typeof children === "function" ? state => children({ ...state, active }) : children }));
|
|
22
|
-
})
|
|
22
|
+
});
|
|
23
23
|
Link.displayName = "Link";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from "react";
|
|
2
2
|
import { StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
import { FocusTrapRef } from "./FocusTrap";
|
|
4
4
|
export declare const ListRightPanelContent: ({ children, large, style, }: {
|
|
@@ -7,6 +7,7 @@ export declare const ListRightPanelContent: ({ children, large, style, }: {
|
|
|
7
7
|
style?: StyleProp<ViewStyle>;
|
|
8
8
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
type Props<T> = {
|
|
10
|
+
ref?: Ref<FocusTrapRef>;
|
|
10
11
|
items: T[];
|
|
11
12
|
keyExtractor: (item: T) => string;
|
|
12
13
|
activeId: string | null;
|
|
@@ -17,7 +18,5 @@ type Props<T> = {
|
|
|
17
18
|
previousLabel: string;
|
|
18
19
|
nextLabel: string;
|
|
19
20
|
};
|
|
20
|
-
export declare const ListRightPanel: <T>(
|
|
21
|
-
ref?: MutableRefObject<FocusTrapRef | null>;
|
|
22
|
-
}) => React.ReactElement;
|
|
21
|
+
export declare const ListRightPanel: <T>({ ref, items, keyExtractor, activeId, onActiveIdChange, onClose, render, closeLabel, previousLabel, nextLabel, }: Props<T>) => import("react/jsx-runtime").JSX.Element;
|
|
23
22
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createElement as _createElement } from "react";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Array, Option } from "@swan-io/boxed";
|
|
4
|
-
import { forwardRef } from "react";
|
|
5
4
|
import { StyleSheet, View } from "react-native";
|
|
6
5
|
import { match } from "ts-pattern";
|
|
7
6
|
import { animations, colors, spacings } from "../constants/design";
|
|
@@ -36,7 +35,7 @@ const styles = StyleSheet.create({
|
|
|
36
35
|
export const ListRightPanelContent = ({ children, large, style, }) => {
|
|
37
36
|
return _jsx(View, { style: [large ? styles.contentLarge : styles.content, style], children: children });
|
|
38
37
|
};
|
|
39
|
-
const
|
|
38
|
+
export const ListRightPanel = ({ ref, items, keyExtractor, activeId, onActiveIdChange, onClose, render, closeLabel, previousLabel, nextLabel, }) => {
|
|
40
39
|
const activeItem = items.find(item => keyExtractor(item) === activeId);
|
|
41
40
|
// use `Array.getIndexBy` instead of `Array.findIndex` to avoid -1 value
|
|
42
41
|
const activeItemIndex = Array.findIndex(items, item => keyExtractor(item) === activeId).toUndefined();
|
|
@@ -79,6 +78,4 @@ const ListRightPanel_ = forwardRef(({ items, keyExtractor, activeId, onActiveIdC
|
|
|
79
78
|
: []),
|
|
80
79
|
]
|
|
81
80
|
: null })] })) }));
|
|
82
|
-
}
|
|
83
|
-
// @ts-expect-error this is the only way I found to use generic props with forwardRef
|
|
84
|
-
export const ListRightPanel = ListRightPanel_;
|
|
81
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { Ref } from "react";
|
|
1
2
|
import { StyleProp, View, ViewStyle } from "react-native";
|
|
2
3
|
type Props = {
|
|
4
|
+
ref?: Ref<View>;
|
|
3
5
|
color?: string;
|
|
4
6
|
delay?: number;
|
|
5
7
|
style?: StyleProp<ViewStyle>;
|
|
6
8
|
};
|
|
7
|
-
export declare const LoadingView:
|
|
9
|
+
export declare const LoadingView: ({ ref, color, delay, style, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
2
|
import { ActivityIndicator, StyleSheet, View } from "react-native";
|
|
4
3
|
import { colors } from "../constants/design";
|
|
5
4
|
const styles = StyleSheet.create({
|
|
@@ -21,4 +20,4 @@ const styles = StyleSheet.create({
|
|
|
21
20
|
},
|
|
22
21
|
});
|
|
23
22
|
const isDev = process.env.NODE_ENV === "development";
|
|
24
|
-
export const LoadingView =
|
|
23
|
+
export const LoadingView = ({ ref, color = colors.gray[400], delay = isDev ? 0 : 1000, style, }) => (_jsx(View, { ref: ref, style: [styles.base, style], children: _jsx(ActivityIndicator, { size: "small", color: color, style: [styles.indicator, delay > 0 && { animationDelay: delay.toString() + "ms" }] }) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import { ReactElement, ReactNode, Ref } from "react";
|
|
2
|
+
import { View, ViewStyle } from "react-native";
|
|
3
3
|
import { ColumnCellConfig, ColumnTitleConfig, LinkConfig } from "./VirtualizedList";
|
|
4
4
|
export type { LinkConfig } from "./VirtualizedList";
|
|
5
5
|
export type ColumnConfig<T, ExtraInfo> = {
|
|
@@ -24,7 +24,9 @@ type Props<T, ExtraInfo> = {
|
|
|
24
24
|
headerStyle?: ViewStyle | null | undefined;
|
|
25
25
|
rowStyle?: (item: T, large: boolean) => ViewStyle | null | undefined;
|
|
26
26
|
getRowLink?: (config: LinkConfig<T, ExtraInfo>) => ReactElement<{
|
|
27
|
-
children:
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
ref?: Ref<View>;
|
|
29
|
+
style?: ViewStyle;
|
|
28
30
|
}>;
|
|
29
31
|
renderEmptyList?: () => ReactNode;
|
|
30
32
|
groupBy?: (item: T) => string;
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
matchReferenceMinWidth?: boolean;
|
|
13
13
|
onDismiss?: () => void;
|
|
14
14
|
onEscapeKey?: () => void;
|
|
15
|
-
referenceRef: RefObject<View | Text>;
|
|
15
|
+
referenceRef: RefObject<View | Text | null>;
|
|
16
16
|
returnFocus?: boolean;
|
|
17
17
|
autoFocus?: boolean;
|
|
18
18
|
visible: boolean;
|
|
@@ -3,6 +3,7 @@ import { HrefAttrs, NativeSyntheticEvent, PressableProps, PressableStateCallback
|
|
|
3
3
|
import { Except, Merge } from "type-fest";
|
|
4
4
|
import { PressResponderConfig } from "../hooks/usePressEvents";
|
|
5
5
|
type Props<BaseProps extends TextProps | TextInputProps> = Merge<BaseProps, {
|
|
6
|
+
ref?: Ref<unknown>;
|
|
6
7
|
children?: ReactNode | ((state: PressableStateCallbackType) => ReactNode);
|
|
7
8
|
delayLongPress?: number;
|
|
8
9
|
delayPressIn?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// https://github.com/necolas/react-native-web/blob/0.
|
|
3
|
-
import {
|
|
2
|
+
// https://github.com/necolas/react-native-web/blob/0.20.0/packages/react-native-web/src/exports/Pressable/index.js
|
|
3
|
+
import { memo, useCallback, useMemo, useRef } from "react";
|
|
4
4
|
import { StyleSheet, Text, View, } from "react-native";
|
|
5
5
|
import { match } from "ts-pattern";
|
|
6
6
|
import { useForceableState } from "../hooks/useForceableState";
|
|
@@ -20,13 +20,13 @@ const getPressable = (
|
|
|
20
20
|
// biome-ignore lint/suspicious/noExplicitAny:
|
|
21
21
|
Component, config = {}) => {
|
|
22
22
|
const { applyPressStyle = true } = config;
|
|
23
|
-
return
|
|
24
|
-
const { children, delayLongPress, delayPressIn, delayPressOut, disabled = false, onBlur, onContextMenu, onFocus, onHoverIn, onHoverOut, onKeyDown, onLongPress, onPress, onPressIn, onPressMove, onPressOut, style, tabIndex, testOnly_hovered, testOnly_pressed, ...rest } = props;
|
|
23
|
+
return (props) => {
|
|
24
|
+
const { ref, children, delayLongPress, delayPressIn, delayPressOut, disabled = false, onBlur, onContextMenu, onFocus, onHoverIn, onHoverOut, onKeyDown, onLongPress, onPress, onPressIn, onPressMove, onPressOut, style, tabIndex, testOnly_hovered, testOnly_pressed, ...rest } = props;
|
|
25
25
|
const [hovered, setHovered] = useForceableState(testOnly_hovered === true);
|
|
26
26
|
const [focused, setFocused] = useForceableState(false);
|
|
27
27
|
const [pressed, setPressed] = useForceableState(testOnly_pressed === true);
|
|
28
28
|
const hostRef = useRef(null);
|
|
29
|
-
const setRef = useMergeRefs(
|
|
29
|
+
const setRef = useMergeRefs(ref, hostRef);
|
|
30
30
|
const pressConfig = useMemo(() => ({
|
|
31
31
|
delayLongPress,
|
|
32
32
|
delayPressStart: delayPressIn,
|
|
@@ -98,7 +98,7 @@ Component, config = {}) => {
|
|
|
98
98
|
.otherwise(() => null),
|
|
99
99
|
typeof style === "function" ? style(interactionState) : style,
|
|
100
100
|
], tabIndex: _tabIndex, children: typeof children === "function" ? children(interactionState) : children }));
|
|
101
|
-
}
|
|
101
|
+
};
|
|
102
102
|
};
|
|
103
103
|
export const Pressable = memo(getPressable(View, { applyPressStyle: true }));
|
|
104
104
|
export const PressableText = memo(getPressable(Text, { applyPressStyle: true }));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { ReactNode, Ref } from "react";
|
|
2
2
|
import { FocusTrapRef } from "./FocusTrap";
|
|
3
3
|
import { Context } from "./ResponsiveContainer";
|
|
4
4
|
type Props = {
|
|
5
|
+
ref?: Ref<FocusTrapRef>;
|
|
5
6
|
visible: boolean;
|
|
6
7
|
children: ReactNode | ((context: Context) => ReactNode);
|
|
7
8
|
onPressClose?: () => void;
|
|
8
9
|
};
|
|
9
|
-
export declare const RightPanel:
|
|
10
|
+
export declare const RightPanel: ({ ref, visible, children, onPressClose }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
import { StyleSheet, View } from "react-native";
|
|
4
4
|
import { backgroundColor, breakpoints } from "../constants/design";
|
|
5
5
|
import { useBodyClassName } from "../hooks/useBodyClassName";
|
|
@@ -97,11 +97,11 @@ const styles = StyleSheet.create({
|
|
|
97
97
|
},
|
|
98
98
|
});
|
|
99
99
|
const rootNode = document.querySelector("#full-page-layer-root");
|
|
100
|
-
export const RightPanel =
|
|
100
|
+
export const RightPanel = ({ ref, visible, children, onPressClose }) => {
|
|
101
101
|
const [delayedVisible, setDelayedVisible] = useState(visible);
|
|
102
102
|
useEffect(() => {
|
|
103
103
|
setDelayedVisible(visible);
|
|
104
104
|
}, [visible]);
|
|
105
105
|
useBodyClassName("RightPanelOpen", { enabled: visible });
|
|
106
106
|
return (_jsx(Portal, { container: rootNode, children: _jsx(View, { style: [styles.root, !visible && styles.inert], children: _jsx(ResponsiveContainer, { style: styles.root, breakpoint: breakpoints.small, children: ({ large }) => (_jsxs(_Fragment, { children: [_jsx(TransitionView, { style: styles.fill, enter: styles.overlayEnter, leave: styles.overlayLeave, children: visible ? (onPressClose != null ? (_jsx(Pressable, { style: styles.overlay, onPress: onPressClose })) : (_jsx(View, { style: styles.overlay }))) : null }), _jsx(Suspendable, { fallback: _jsx(LoadingView, { color: backgroundColor.accented, delay: 0 }), children: _jsx(TransitionView, { style: [styles.fillMax, large && styles.fillMaxLarge], enter: styles.containerEnter, leave: styles.containerLeave, children: delayedVisible ? (_jsx(FocusTrap, { onEscapeKey: onPressClose, focusLock: true, autoFocus: true, returnFocus: true, ref: ref, style: styles.container, children: _jsx(TransitionView, { style: styles.contentsContainer, enter: styles.contentsEnter, leave: styles.contentsLeave, children: _jsx(View, { style: styles.contents, children: _jsx(View, { style: styles.contentsContainer, children: typeof children === "function" ? (_jsx(ResponsiveContainer, { style: styles.root, breakpoint: breakpoints.small, children: children })) : (children) }) }) }) })) : null }) })] })) }) }) }));
|
|
107
|
-
}
|
|
107
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Ref } from "react";
|
|
1
2
|
import { NativeScrollEvent, NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from "react-native";
|
|
2
3
|
export type ScrollViewRef = {
|
|
3
4
|
element: HTMLElement | null;
|
|
@@ -8,6 +9,7 @@ export type ScrollViewRef = {
|
|
|
8
9
|
}) => void;
|
|
9
10
|
};
|
|
10
11
|
export type ScrollViewProps = ViewProps & {
|
|
12
|
+
ref?: Ref<ScrollViewRef>;
|
|
11
13
|
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
12
14
|
horizontal?: boolean;
|
|
13
15
|
both?: boolean;
|
|
@@ -15,11 +17,4 @@ export type ScrollViewProps = ViewProps & {
|
|
|
15
17
|
scrollEventThrottle?: number;
|
|
16
18
|
showsScrollIndicators?: boolean;
|
|
17
19
|
};
|
|
18
|
-
export declare const ScrollView: import("react").
|
|
19
|
-
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
20
|
-
horizontal?: boolean;
|
|
21
|
-
both?: boolean;
|
|
22
|
-
onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
23
|
-
scrollEventThrottle?: number;
|
|
24
|
-
showsScrollIndicators?: boolean;
|
|
25
|
-
} & import("react").RefAttributes<ScrollViewRef>>;
|
|
20
|
+
export declare const ScrollView: ({ ref, children, contentContainerStyle, horizontal, both, onScroll, scrollEventThrottle, showsScrollIndicators, style, ...viewProps }: ScrollViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback, useImperativeHandle, useRef } from "react";
|
|
3
3
|
import { StyleSheet, View, } from "react-native";
|
|
4
4
|
const styles = StyleSheet.create({
|
|
5
5
|
base: {
|
|
@@ -60,7 +60,7 @@ const normalizeScrollEvent = (event) => {
|
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
const shouldEmitScrollEvent = (state, eventThrottle) => !state.scrolling || (eventThrottle > 0 && Date.now() - state.lastTick >= eventThrottle);
|
|
63
|
-
export const ScrollView =
|
|
63
|
+
export const ScrollView = ({ ref, children, contentContainerStyle, horizontal = false, both = false, onScroll, scrollEventThrottle = 16, showsScrollIndicators = true, style, ...viewProps }) => {
|
|
64
64
|
const innerRef = useRef(null);
|
|
65
65
|
const stateRef = useRef({ lastTick: 0, scrolling: false });
|
|
66
66
|
const timeoutRef = useRef(null);
|
|
@@ -92,7 +92,7 @@ export const ScrollView = forwardRef(({ children, contentContainerStyle, horizon
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}, []);
|
|
95
|
-
useImperativeHandle(
|
|
95
|
+
useImperativeHandle(ref, () => ({
|
|
96
96
|
element: innerRef.current,
|
|
97
97
|
scrollTo,
|
|
98
98
|
}));
|
|
@@ -103,4 +103,4 @@ export const ScrollView = forwardRef(({ children, contentContainerStyle, horizon
|
|
|
103
103
|
both && styles.both,
|
|
104
104
|
!showsScrollIndicators && styles.hideScrollbars,
|
|
105
105
|
], children: _jsx(View, { style: [horizontal && styles.contentHorizontal, contentContainerStyle], children: children }) }));
|
|
106
|
-
}
|
|
106
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode, Ref } from "react";
|
|
2
2
|
import { StyleProp, ViewStyle, WebRole } from "react-native";
|
|
3
3
|
import { ListRenderItemInfo } from "./FlatList";
|
|
4
4
|
import { ScrollViewProps, ScrollViewRef } from "./ScrollView";
|
|
@@ -8,6 +8,7 @@ type Section<T> = {
|
|
|
8
8
|
data: T[];
|
|
9
9
|
};
|
|
10
10
|
type Props<T> = {
|
|
11
|
+
ref?: Ref<SectionListRef>;
|
|
11
12
|
ItemSeparatorComponent?: ReactNode;
|
|
12
13
|
ListEmptyComponent?: ReactNode;
|
|
13
14
|
ListFooterComponent?: ReactNode;
|
|
@@ -27,8 +28,5 @@ type Props<T> = {
|
|
|
27
28
|
showsScrollIndicators?: boolean;
|
|
28
29
|
style?: StyleProp<ViewStyle>;
|
|
29
30
|
};
|
|
30
|
-
declare const
|
|
31
|
-
export declare const SectionList: <T>(props: Props<T> & {
|
|
32
|
-
ref?: ForwardedRef<SectionListRef>;
|
|
33
|
-
}) => ReturnType<typeof SectionListWithRef>;
|
|
31
|
+
export declare const SectionList: <T>({ ref, ItemSeparatorComponent, ListEmptyComponent, ListFooterComponent, ListHeaderComponent, contentContainerStyle, horizontal, keyExtractor, onEndReached, onEndReachedThresholdPx, onKeyDown, onScroll, renderItem, renderSectionHeader, role, scrollEventThrottle, sections, showsScrollIndicators, style, }: Props<T>) => import("react/jsx-runtime").JSX.Element;
|
|
34
32
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment,
|
|
2
|
+
import { Fragment, useEffect, useId, useRef } from "react";
|
|
3
3
|
import { StyleSheet, View } from "react-native";
|
|
4
4
|
import { ScrollView } from "./ScrollView";
|
|
5
5
|
const styles = StyleSheet.create({
|
|
@@ -10,7 +10,7 @@ const styles = StyleSheet.create({
|
|
|
10
10
|
bottom: 0,
|
|
11
11
|
},
|
|
12
12
|
});
|
|
13
|
-
const
|
|
13
|
+
export const SectionList = ({ ref, ItemSeparatorComponent, ListEmptyComponent, ListFooterComponent, ListHeaderComponent, contentContainerStyle, horizontal = false, keyExtractor, onEndReached, onEndReachedThresholdPx = 200, onKeyDown, onScroll, renderItem, renderSectionHeader, role, scrollEventThrottle = 16, sections, showsScrollIndicators = true, style, }) => {
|
|
14
14
|
const groupId = useId();
|
|
15
15
|
const scrollTrackerRef = useRef(null);
|
|
16
16
|
const scrollTrackerStyle = horizontal
|
|
@@ -35,8 +35,7 @@ const SectionListWithRef = ({ ItemSeparatorComponent, ListEmptyComponent, ListFo
|
|
|
35
35
|
}
|
|
36
36
|
// re-create an observer only on list length change
|
|
37
37
|
}, [sections.length]);
|
|
38
|
-
return (_jsxs(ScrollView, { contentContainerStyle: contentContainerStyle, horizontal: horizontal, onKeyDown: onKeyDown, onScroll: onScroll, ref:
|
|
38
|
+
return (_jsxs(ScrollView, { contentContainerStyle: contentContainerStyle, horizontal: horizontal, onKeyDown: onKeyDown, onScroll: onScroll, ref: ref, role: role, scrollEventThrottle: scrollEventThrottle, showsScrollIndicators: showsScrollIndicators, style: style, children: [ListHeaderComponent, sections.length <= 0
|
|
39
39
|
? ListEmptyComponent
|
|
40
40
|
: sections.map(section => (_jsxs(Fragment, { children: [renderSectionHeader === null || renderSectionHeader === void 0 ? void 0 : renderSectionHeader(section), section.data.map((item, index) => (_jsxs(Fragment, { children: [index !== 0 && ItemSeparatorComponent, renderItem({ item, index })] }, keyExtractor(item, index))))] }, `group-${groupId}-${section.title}`))), ListFooterComponent, _jsx(View, { role: "none", ref: scrollTrackerRef, style: [styles.scrollTracker, scrollTrackerStyle] })] }));
|
|
41
41
|
};
|
|
42
|
-
export const SectionList = forwardRef(SectionListWithRef);
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import { Ref } from "react";
|
|
1
2
|
import { View } from "react-native";
|
|
3
|
+
import { BoxProps } from "./Box";
|
|
2
4
|
import { SpacingValue } from "./Space";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
children?: import("react").ReactNode;
|
|
6
|
-
direction?: "row" | "column" | "columnReverse" | "rowReverse";
|
|
7
|
-
justifyContent?: "end" | "start" | "normal" | "center" | "spaceBetween" | "spaceAround" | "spaceEvenly";
|
|
8
|
-
wrap?: "nowrap" | "wrap" | "wrapReverse";
|
|
9
|
-
grow?: number;
|
|
10
|
-
shrink?: number;
|
|
11
|
-
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
12
|
-
} & {
|
|
5
|
+
type Props = BoxProps & {
|
|
6
|
+
ref?: Ref<View>;
|
|
13
7
|
space?: SpacingValue;
|
|
14
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare const Stack: ({ ref, children, space, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
package/src/components/Stack.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Children,
|
|
2
|
+
import { Children, Fragment } from "react";
|
|
3
3
|
import { isNullish } from "../utils/nullish";
|
|
4
4
|
import { Box } from "./Box";
|
|
5
5
|
import { Space } from "./Space";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
({ children, space, ...props }, forwardedRef) => {
|
|
6
|
+
// Default <View /> styles https://github.com/necolas/react-native-web/blob/0.20.0/packages/react-native-web/src/exports/View/index.js#L149
|
|
7
|
+
export const Stack = ({ ref, children, space, ...props }) => {
|
|
9
8
|
const { direction = "column" } = props;
|
|
10
9
|
const horizontal = direction === "row" || direction === "rowReverse";
|
|
11
|
-
return (_jsx(Box, { ref:
|
|
10
|
+
return (_jsx(Box, { ref: ref, ...props, children: Children.map(children, (child, index) => {
|
|
12
11
|
// null, undefined, true and false are valid children. They simply don’t render
|
|
13
12
|
if (isNullish(child) || typeof child === "boolean") {
|
|
14
13
|
return child;
|
|
15
14
|
}
|
|
16
15
|
return (_jsxs(Fragment, { children: [index !== 0 && (horizontal ? _jsx(Space, { width: space }) : _jsx(Space, { height: space })), child] }));
|
|
17
16
|
}) }));
|
|
18
|
-
}
|
|
17
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { Ref } from "react";
|
|
1
2
|
import { View } from "react-native";
|
|
2
3
|
type Props = {
|
|
4
|
+
ref?: Ref<View>;
|
|
3
5
|
value: boolean;
|
|
4
6
|
onValueChange?: (value: boolean) => void;
|
|
5
7
|
disabled?: boolean;
|
|
6
8
|
};
|
|
7
|
-
export declare const Switch: import("react").MemoExoticComponent<
|
|
9
|
+
export declare const Switch: import("react").MemoExoticComponent<({ ref, value, disabled, onValueChange }: Props) => import("react/jsx-runtime").JSX.Element>;
|
|
8
10
|
export {};
|
package/src/components/Switch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { memo } from "react";
|
|
3
3
|
import { Pressable, StyleSheet, View } from "react-native";
|
|
4
4
|
import { backgroundColor, colors, shadows } from "../constants/design";
|
|
5
5
|
import { Icon } from "./Icon";
|
|
@@ -61,6 +61,4 @@ const styles = StyleSheet.create({
|
|
|
61
61
|
transitionDuration: "250ms",
|
|
62
62
|
},
|
|
63
63
|
});
|
|
64
|
-
export const Switch = memo(
|
|
65
|
-
return (_jsx(Pressable, { ref: ref, role: "switch", "aria-checked": value, disabled: disabled, onPress: () => onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(!value), children: ({ hovered }) => (_jsxs(_Fragment, { children: [_jsx(View, { style: [styles.shadow, hovered && styles.opaque] }), _jsx(View, { style: [styles.base, value && styles.active, disabled && styles.disabled], children: _jsx(View, { style: [styles.button, value && styles.buttonActive], children: _jsx(Icon, { color: colors.positive[400], name: "checkmark-filled", size: 10, style: [styles.icon, value && styles.opaque] }) }) })] })) }));
|
|
66
|
-
}));
|
|
64
|
+
export const Switch = memo(({ ref, value, disabled = false, onValueChange }) => (_jsx(Pressable, { ref: ref, role: "switch", "aria-checked": value, disabled: disabled, onPress: () => onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(!value), children: ({ hovered }) => (_jsxs(_Fragment, { children: [_jsx(View, { style: [styles.shadow, hovered && styles.opaque] }), _jsx(View, { style: [styles.base, value && styles.active, disabled && styles.disabled], children: _jsx(View, { style: [styles.button, value && styles.buttonActive], children: _jsx(Icon, { color: colors.positive[400], name: "checkmark-filled", size: 10, style: [styles.icon, value && styles.opaque] }) }) })] })) })));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useLocation } from "@swan-io/chicane";
|
|
3
|
-
import { Fragment,
|
|
3
|
+
import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, } from "react";
|
|
4
4
|
import { StyleSheet, Text, View, } from "react-native";
|
|
5
5
|
import { P, match } from "ts-pattern";
|
|
6
6
|
import { animations, backgroundColor, colors, negativeSpacings, radii, shadows, spacings, texts, } from "../constants/design";
|
|
@@ -121,7 +121,7 @@ const styles = StyleSheet.create({
|
|
|
121
121
|
top: -1,
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
|
-
const TabViewLink =
|
|
124
|
+
const TabViewLink = ({ ref, children, style, tab, onChange, activeTabId, onBlur, onFocus, onPress, }) => {
|
|
125
125
|
return match(tab)
|
|
126
126
|
.with({ url: P.string }, ({ url }) => (_jsx(Link, { ref: ref, to: url, style: style, onFocus: onFocus, onBlur: onBlur, onPress: onPress, children: children })))
|
|
127
127
|
.with({ id: P.string }, ({ id }) => {
|
|
@@ -132,7 +132,7 @@ const TabViewLink = forwardRef(({ children, style, tab, onChange, activeTabId, o
|
|
|
132
132
|
}, onFocus: onFocus, onBlur: onBlur, children: children }));
|
|
133
133
|
})
|
|
134
134
|
.exhaustive();
|
|
135
|
-
}
|
|
135
|
+
};
|
|
136
136
|
const Dropdown = ({ tabs, onHoverStart, onHoverEnd, onLinkFocus, onLinkBlur, onLinkPress, activeTabId, onChange, }) => {
|
|
137
137
|
const containerRef = useRef(null);
|
|
138
138
|
useHover(containerRef, {
|
|
@@ -151,7 +151,7 @@ const Dropdown = ({ tabs, onHoverStart, onHoverEnd, onLinkFocus, onLinkBlur, onL
|
|
|
151
151
|
const SHOULD_AUTOFOCUS = new Set(["ForcedOpen", "OpenFromFocus"]);
|
|
152
152
|
const SHOULD_OPEN = new Set(["Open", "ForcedOpen", "OpenFromFocus"]);
|
|
153
153
|
const SHOULD_LOCK_FOCUS = new Set(["ForcedOpen"]);
|
|
154
|
-
const DropdownItems =
|
|
154
|
+
const DropdownItems = ({ ref, tabs, otherLabel, currentUrl, activeTabId, onChange, }) => {
|
|
155
155
|
const [openingStatus, dispatch] = useReducer((state, action) => {
|
|
156
156
|
return match([action, state])
|
|
157
157
|
.returnType()
|
|
@@ -269,7 +269,7 @@ const DropdownItems = forwardRef(({ tabs, otherLabel, currentUrl, activeTabId, o
|
|
|
269
269
|
styles.link,
|
|
270
270
|
isNotNullish(activeTab) ? styles.activeLink : hovered ? styles.hoveredLink : null,
|
|
271
271
|
], children: [_jsx(Text, { children: otherLabel }), _jsx(Space, { width: 8 }), _jsx(Text, { style: styles.count, children: tabs.length }), _jsx(Space, { width: 4 }), _jsx(Icon, { name: "chevron-down-filled", size: 12 })] }), _jsx(TransitionView, { ...animations.fadeAndSlideInFromBottom, style: styles.dropdownPlacement, children: shouldOpen ? (_jsx(FocusTrap, { autoFocus: shouldAutoFocus, focusLock: shouldLockFocus, returnFocus: shouldLockFocus, onClickOutside: onPressOutside, onEscapeKey: shouldLockFocus ? onEscapeKey : undefined, children: _jsx(Dropdown, { onChange: onChange, activeTabId: activeTabId, tabs: tabs, onHoverStart: onHoverStart, onHoverEnd: onHoverEnd, onLinkFocus: onLinkFocus, onLinkBlur: onAnyBlur, onLinkPress: onEscapeKey }) })) : null })] }));
|
|
272
|
-
}
|
|
272
|
+
};
|
|
273
273
|
const isTabActive = ({ tab, activeTabId, currentLocationURL }) => match(tab)
|
|
274
274
|
.with({ url: P.string }, ({ url }) => currentLocationURL.startsWith(url))
|
|
275
275
|
.with({ id: P.string }, ({ id }) => isNotNullish(activeTabId) && id === activeTabId)
|