@swan-io/shared-business 13.7.14 → 13.9.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-io/shared-business",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.9.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">22.12.0"
|
|
6
6
|
},
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@swan-io/lake": "13.
|
|
28
|
+
"@swan-io/lake": "13.9.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@formatjs/intl": "^4.1.2",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
"@types/react-dom": "^19.2.3",
|
|
51
51
|
"@types/react-native": "^0.72.8",
|
|
52
52
|
"type-fest": "^5.4.3",
|
|
53
|
-
"@swan-io/lake": "13.
|
|
53
|
+
"@swan-io/lake": "13.9.0"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ColorVariants } from "@swan-io/lake/src/constants/design";
|
|
1
2
|
import { ReactNode } from "react";
|
|
2
3
|
type Props<T> = {
|
|
3
4
|
items: T[];
|
|
@@ -7,7 +8,7 @@ type Props<T> = {
|
|
|
7
8
|
getId?: (item: T) => unknown;
|
|
8
9
|
onChange: (value: T) => void;
|
|
9
10
|
disabled?: boolean;
|
|
10
|
-
|
|
11
|
+
tileColor?: ColorVariants;
|
|
11
12
|
};
|
|
12
|
-
export declare const ChoicePicker: <T>({
|
|
13
|
+
export declare const ChoicePicker: <T>({ tileColor, items, getId, large, renderItem, value, disabled, onChange, }: Props<T>) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -4,9 +4,8 @@ import { LakeRadio } from "@swan-io/lake/src/components/LakeRadio";
|
|
|
4
4
|
import { Pressable } from "@swan-io/lake/src/components/Pressable";
|
|
5
5
|
import { ScrollView } from "@swan-io/lake/src/components/ScrollView";
|
|
6
6
|
import { Space } from "@swan-io/lake/src/components/Space";
|
|
7
|
-
import { Tile } from "@swan-io/lake/src/components/Tile";
|
|
8
7
|
import { commonStyles } from "@swan-io/lake/src/constants/commonStyles";
|
|
9
|
-
import { breakpoints, negativeSpacings, spacings } from "@swan-io/lake/src/constants/design";
|
|
8
|
+
import { breakpoints, colors, invariantColors, negativeSpacings, radii, shadows, spacings, } from "@swan-io/lake/src/constants/design";
|
|
10
9
|
import { useResponsive } from "@swan-io/lake/src/hooks/useResponsive";
|
|
11
10
|
import { clampValue } from "@swan-io/lake/src/utils/math";
|
|
12
11
|
import { detectScrollAnimationEnd } from "@swan-io/lake/src/utils/viewport";
|
|
@@ -42,7 +41,6 @@ const styles = StyleSheet.create({
|
|
|
42
41
|
item: {
|
|
43
42
|
flexGrow: 0,
|
|
44
43
|
flexBasis: "33.333%",
|
|
45
|
-
maxWidth: 300,
|
|
46
44
|
padding: spacings[12],
|
|
47
45
|
},
|
|
48
46
|
itemAnimation: {
|
|
@@ -63,20 +61,29 @@ const styles = StyleSheet.create({
|
|
|
63
61
|
},
|
|
64
62
|
itemLarge: {
|
|
65
63
|
flexBasis: "50%",
|
|
66
|
-
maxWidth: "none",
|
|
67
64
|
},
|
|
68
65
|
itemSmallViewport: {
|
|
69
66
|
width: "100%",
|
|
70
67
|
flexBasis: "auto",
|
|
71
|
-
maxWidth: "none",
|
|
72
68
|
scrollSnapAlign: "center",
|
|
73
69
|
},
|
|
74
|
-
|
|
70
|
+
tile: {
|
|
71
|
+
paddingVertical: spacings[32],
|
|
72
|
+
paddingHorizontal: spacings[32],
|
|
73
|
+
borderRadius: radii[8],
|
|
74
|
+
borderWidth: 1,
|
|
75
|
+
borderColor: colors.gray[100],
|
|
76
|
+
flexGrow: 1,
|
|
77
|
+
},
|
|
78
|
+
tileHover: {
|
|
79
|
+
boxShadow: shadows.tileHover,
|
|
80
|
+
},
|
|
81
|
+
content: {
|
|
75
82
|
alignItems: "center",
|
|
76
83
|
alignSelf: "stretch",
|
|
77
84
|
flexGrow: 1,
|
|
78
85
|
},
|
|
79
|
-
|
|
86
|
+
renderedContents: {
|
|
80
87
|
alignItems: "center",
|
|
81
88
|
alignSelf: "stretch",
|
|
82
89
|
flexGrow: 1,
|
|
@@ -103,7 +110,7 @@ const styles = StyleSheet.create({
|
|
|
103
110
|
},
|
|
104
111
|
});
|
|
105
112
|
const identity = (x) => x;
|
|
106
|
-
export const ChoicePicker = ({
|
|
113
|
+
export const ChoicePicker = ({ tileColor, items, getId = identity, large = false, renderItem, value, disabled = false, onChange, }) => {
|
|
107
114
|
const containerRef = useRef(null);
|
|
108
115
|
const { desktop } = useResponsive(breakpoints.medium);
|
|
109
116
|
const [mobilePosition, setMobilePosition] = useState("start");
|
|
@@ -206,7 +213,15 @@ export const ChoicePicker = ({ tile = true, items, getId = identity, large = fal
|
|
|
206
213
|
!desktop && styles.itemSmallViewport,
|
|
207
214
|
!desktop && { width: `${100 / items.length}%` },
|
|
208
215
|
], onPress: () => onChange(item), children: ({ hovered }) => {
|
|
209
|
-
const
|
|
210
|
-
|
|
216
|
+
const selected = value != null && getId(item) === getId(value);
|
|
217
|
+
const tileContent = (_jsxs(View, { style: styles.content, children: [_jsx(View, { style: styles.renderedContents, children: renderItem(item) }), tileColor == null && desktop && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 24 }), _jsx(LakeRadio, { value: selected })] }))] }));
|
|
218
|
+
return tileColor != null ? (_jsx(View, { style: [
|
|
219
|
+
styles.tile,
|
|
220
|
+
hovered && styles.tileHover,
|
|
221
|
+
selected && {
|
|
222
|
+
backgroundColor: invariantColors.white,
|
|
223
|
+
borderColor: colors[tileColor][500],
|
|
224
|
+
},
|
|
225
|
+
], children: tileContent })) : (tileContent);
|
|
211
226
|
} }, String(index)))) }) }), !desktop && (_jsx(LakeButton, { icon: "chevron-left-filled", mode: "secondary", forceBackground: true, onPress: onPressPrevious, disabled: mobilePosition === "start" || disabled, style: styles.leftButton, ariaLabel: t("common.previous") })), !desktop && (_jsx(LakeButton, { icon: "chevron-right-filled", mode: "secondary", forceBackground: true, onPress: onPressNext, disabled: mobilePosition === "end" || disabled, style: styles.rightButton, ariaLabel: t("common.next") }))] }));
|
|
212
227
|
};
|