@swan-io/lake 8.7.2 → 8.8.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
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
import { ReactElement, ReactNode } from "react";
|
|
37
37
|
import { IconName } from "./Icon";
|
|
38
|
+
import { SpacingValue } from "./Space";
|
|
38
39
|
export type ColumnTitleConfig<ExtraInfo> = {
|
|
39
40
|
title: string;
|
|
40
41
|
extraInfo: ExtraInfo;
|
|
@@ -99,9 +100,10 @@ export declare const PlainListViewPlaceholder: ({ count, rowHeight, rowVerticalS
|
|
|
99
100
|
type EmptyProps = {
|
|
100
101
|
icon: IconName;
|
|
101
102
|
borderedIcon?: boolean;
|
|
103
|
+
borderedIconPadding?: SpacingValue | 0;
|
|
102
104
|
title?: string;
|
|
103
105
|
subtitle?: ReactNode;
|
|
104
106
|
children?: ReactNode;
|
|
105
107
|
};
|
|
106
|
-
export declare const FixedListViewEmpty: ({ icon, borderedIcon, title, subtitle, children, }: EmptyProps) => import("react/jsx-runtime").JSX.Element;
|
|
108
|
+
export declare const FixedListViewEmpty: ({ icon, borderedIcon, borderedIconPadding, title, subtitle, children, }: EmptyProps) => import("react/jsx-runtime").JSX.Element;
|
|
107
109
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* ## FixedListView
|
|
4
4
|
*
|
|
@@ -828,4 +828,4 @@ export const PlainListViewPlaceholder = ({ count, rowHeight, rowVerticalSpacing,
|
|
|
828
828
|
], children: [_jsx(View, { style: styles.placeholderRow }), _jsx(Space, { width: 32 }), _jsx(View, { style: [styles.placeholderRow, styles.smallPlaceholderRow] }), _jsx(Space, { width: 32 }), _jsx(View, { style: styles.placeholderRowEnd, children: _jsx(View, { style: [styles.placeholderRow, styles.smallPlaceholderRow] }) })] }, String(index))] }, String(index)));
|
|
829
829
|
}) })] }));
|
|
830
830
|
};
|
|
831
|
-
export const FixedListViewEmpty = ({ icon, borderedIcon = false, title, subtitle, children, }) => (_jsxs(View, { style: styles.emptyList, children: [borderedIcon ? (_jsx(BorderedIcon, { name: icon })) : (_jsx(Icon, { name: icon, size: 96, color: colors.current.primary })), _jsx(Space, { height:
|
|
831
|
+
export const FixedListViewEmpty = ({ icon, borderedIcon = false, borderedIconPadding, title, subtitle, children, }) => (_jsxs(View, { style: styles.emptyList, children: [borderedIcon ? (_jsx(BorderedIcon, { name: icon, padding: borderedIconPadding })) : (_jsx(Icon, { name: icon, size: 96, color: colors.current.primary })), _jsx(Space, { height: 24 }), isNotNullish(title) && (_jsxs(_Fragment, { children: [_jsx(LakeHeading, { align: "center", level: 3, variant: "h5", children: title }), _jsx(Space, { height: 8 })] })), isNotNullish(subtitle) && _jsx(LakeText, { align: "center", children: subtitle }), children] }));
|
|
@@ -7,6 +7,7 @@ export type ButtonProps = {
|
|
|
7
7
|
ariaExpanded?: boolean;
|
|
8
8
|
color?: ColorVariants;
|
|
9
9
|
disabled?: boolean;
|
|
10
|
+
direction?: "column" | "row";
|
|
10
11
|
loading?: boolean;
|
|
11
12
|
grow?: boolean;
|
|
12
13
|
icon?: IconName;
|
|
@@ -14,6 +15,7 @@ export type ButtonProps = {
|
|
|
14
15
|
mode?: "primary" | "secondary" | "tertiary";
|
|
15
16
|
onPress?: (event: GestureResponderEvent) => void;
|
|
16
17
|
size?: "large" | "small";
|
|
18
|
+
iconSize?: number;
|
|
17
19
|
style?: StyleProp<ViewStyle> | ((props: PressableStateCallbackType) => StyleProp<ViewStyle>);
|
|
18
20
|
forceBackground?: boolean;
|
|
19
21
|
href?: string;
|
|
@@ -5,6 +5,7 @@ import { match } from "ts-pattern";
|
|
|
5
5
|
import { commonStyles } from "../constants/commonStyles";
|
|
6
6
|
import { backgroundColor, colors, invariantColors, radii, spacings, texts, } from "../constants/design";
|
|
7
7
|
import { isNotNullish, isNullish } from "../utils/nullish";
|
|
8
|
+
import { Box } from "./Box";
|
|
8
9
|
import { Icon } from "./Icon";
|
|
9
10
|
import { LakeText } from "./LakeText";
|
|
10
11
|
import { Pressable } from "./Pressable";
|
|
@@ -81,7 +82,6 @@ const styles = StyleSheet.create({
|
|
|
81
82
|
alignItems: "center",
|
|
82
83
|
justifyContent: "center",
|
|
83
84
|
transform: "translateZ(0px)",
|
|
84
|
-
borderRadius: radii[6],
|
|
85
85
|
},
|
|
86
86
|
group: {
|
|
87
87
|
flexDirection: "row",
|
|
@@ -99,16 +99,32 @@ const styles = StyleSheet.create({
|
|
|
99
99
|
top: -3,
|
|
100
100
|
right: -3,
|
|
101
101
|
},
|
|
102
|
+
vertical: {
|
|
103
|
+
flexDirection: "column",
|
|
104
|
+
height: "auto",
|
|
105
|
+
paddingVertical: spacings[12],
|
|
106
|
+
},
|
|
107
|
+
verticalSmall: {
|
|
108
|
+
paddingVertical: spacings[8],
|
|
109
|
+
},
|
|
110
|
+
hidden: {
|
|
111
|
+
visibility: "hidden",
|
|
112
|
+
},
|
|
102
113
|
});
|
|
103
|
-
export const LakeButton = memo(forwardRef(({ ariaControls, ariaExpanded, ariaLabel, children, color = "gray", disabled = false, icon, grow = false, iconPosition = "start", loading = false, mode = "primary", onPress, size = "large", style, forceBackground = false, href, hrefAttrs, pill, }, forwardedRef) => {
|
|
114
|
+
export const LakeButton = memo(forwardRef(({ ariaControls, ariaExpanded, ariaLabel, children, color = "gray", direction = "row", disabled = false, icon, grow = false, iconPosition = "start", loading = false, mode = "primary", onPress, size = "large", iconSize = size === "small" ? 18 : 20, style, forceBackground = false, href, hrefAttrs, pill = false, }, forwardedRef) => {
|
|
115
|
+
const isPrimary = mode === "primary";
|
|
104
116
|
const isSmall = size === "small";
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
117
|
+
const vertical = direction === "column";
|
|
118
|
+
const spaceHeight = vertical ? 4 : undefined;
|
|
119
|
+
const spaceWidth = vertical ? undefined : isSmall ? 8 : 12;
|
|
120
|
+
const hasIcon = isNotNullish(icon);
|
|
121
|
+
const hasIconStart = hasIcon && iconPosition === "start";
|
|
122
|
+
const hasIconEnd = hasIcon && iconPosition === "end";
|
|
123
|
+
const hasOnlyIcon = hasIcon && isNullish(children);
|
|
109
124
|
return (_jsx(Pressable, { href: href, hrefAttrs: hrefAttrs, role: href != null ? "link" : "button", "aria-busy": loading, "aria-disabled": disabled, "aria-controls": ariaControls, "aria-expanded": ariaExpanded, "aria-label": ariaLabel, disabled: loading || disabled, ref: forwardedRef, onPress: onPress, style: ({ hovered, pressed, focused }) => [
|
|
110
125
|
styles.base,
|
|
111
126
|
isSmall && styles.small,
|
|
127
|
+
vertical && [styles.vertical, isSmall && styles.verticalSmall],
|
|
112
128
|
hasIconStart && isSmall ? styles.withIconStartSmall : styles.withIconStart,
|
|
113
129
|
hasIconEnd && (isSmall ? styles.withIconEndSmall : styles.withIconEnd),
|
|
114
130
|
hasOnlyIcon && (isSmall ? styles.iconSmallOnly : styles.iconOnly),
|
|
@@ -150,23 +166,18 @@ export const LakeButton = memo(forwardRef(({ ariaControls, ariaExpanded, ariaLab
|
|
|
150
166
|
.exhaustive(),
|
|
151
167
|
typeof style == "function" ? style({ hovered, pressed, focused }) : style,
|
|
152
168
|
], children: ({ pressed, hovered }) => {
|
|
153
|
-
const textColor =
|
|
154
|
-
?
|
|
169
|
+
const textColor = isPrimary
|
|
170
|
+
? colors[color].contrast
|
|
171
|
+
: disabled && forceBackground
|
|
155
172
|
? colors[color][300]
|
|
156
173
|
: hovered || pressed
|
|
157
174
|
? colors[color][700]
|
|
158
|
-
: colors[color][600]
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
styles.
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
? backgroundColor.accented
|
|
165
|
-
: colors[color].primary,
|
|
166
|
-
},
|
|
167
|
-
], children: _jsx(ActivityIndicator, { color: mode === "secondary" || mode === "tertiary"
|
|
168
|
-
? colors[color].primary
|
|
169
|
-
: colors[color].contrast, size: iconSize }) })), _jsx(View, { style: [styles.hiddenView, pressed && mode === "primary" && styles.pressed] }), pill === true ? _jsx(View, { style: styles.pill }) : null] }));
|
|
175
|
+
: colors[color][600];
|
|
176
|
+
return (_jsxs(_Fragment, { children: [hasIconStart && (_jsxs(_Fragment, { children: [_jsx(Icon, { color: textColor, name: icon, size: iconSize, style: loading && styles.hidden }), isNotNullish(children) && _jsx(Space, { height: spaceHeight, width: spaceWidth })] })), typeof children === "string" || typeof children === "number" ? (_jsx(LakeText, { numberOfLines: 1, userSelect: "none", style: [
|
|
177
|
+
isSmall ? styles.textSmall : styles.text,
|
|
178
|
+
loading && styles.hidden,
|
|
179
|
+
{ color: textColor },
|
|
180
|
+
], children: children })) : (_jsx(Box, { alignItems: "center", justifyContent: "center", style: [vertical && styles.vertical, loading && styles.hidden], children: children })), hasIconEnd && (_jsxs(_Fragment, { children: [isNotNullish(children) && _jsx(Space, { height: spaceHeight, width: spaceWidth }), _jsx(Icon, { color: textColor, name: icon, size: iconSize, style: loading && styles.hidden })] })), loading && (_jsx(View, { style: styles.loaderContainer, children: _jsx(ActivityIndicator, { color: isPrimary ? colors[color].contrast : colors[color].primary, size: iconSize }) })), isPrimary && _jsx(View, { style: [styles.hiddenView, pressed && styles.pressed] }), pill && _jsx(View, { style: styles.pill })] }));
|
|
170
181
|
} }));
|
|
171
182
|
}));
|
|
172
183
|
LakeButton.displayName = "Button";
|