@kanso-labs/react-native-kanso-ui 0.0.0-stage → 0.1.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/LICENSE.md +20 -0
- package/README.md +205 -2
- package/dist/button/index.d.ts +56 -0
- package/dist/button/index.js +169 -0
- package/dist/button/index.js.map +1 -0
- package/dist/button/palettes.js +47 -0
- package/dist/button/palettes.js.map +1 -0
- package/dist/chip/index.js +194 -0
- package/dist/chip/index.js.map +1 -0
- package/dist/chip/styles.js +36 -0
- package/dist/chip/styles.js.map +1 -0
- package/dist/clipboard/index.js +58 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/components/avatar/index.d.ts +82 -0
- package/dist/components/avatar/index.js +62 -0
- package/dist/components/avatar/index.js.map +1 -0
- package/dist/components/button/index.d.ts +87 -0
- package/dist/components/button/index.js +377 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/card/index.d.ts +78 -0
- package/dist/components/card/index.js +315 -0
- package/dist/components/card/index.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +76 -0
- package/dist/components/checkbox/index.js +360 -0
- package/dist/components/checkbox/index.js.map +1 -0
- package/dist/components/chip/index.d.ts +84 -0
- package/dist/components/chip/index.js +257 -0
- package/dist/components/chip/index.js.map +1 -0
- package/dist/components/chip-group/index.d.ts +143 -0
- package/dist/components/chip-group/index.js +669 -0
- package/dist/components/chip-group/index.js.map +1 -0
- package/dist/components/copy-field/index.d.ts +60 -0
- package/dist/components/copy-field/index.js +277 -0
- package/dist/components/copy-field/index.js.map +1 -0
- package/dist/components/currency/index.d.ts +69 -0
- package/dist/components/currency/index.js +162 -0
- package/dist/components/currency/index.js.map +1 -0
- package/dist/components/form/index.d.ts +84 -0
- package/dist/components/form/index.js +95 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/icon-button/index.d.ts +68 -0
- package/dist/components/icon-button/index.js +289 -0
- package/dist/components/icon-button/index.js.map +1 -0
- package/dist/components/link/index.d.ts +59 -0
- package/dist/components/link/index.js +191 -0
- package/dist/components/link/index.js.map +1 -0
- package/dist/components/number-field/index.d.ts +151 -0
- package/dist/components/number-field/index.js +832 -0
- package/dist/components/number-field/index.js.map +1 -0
- package/dist/components/product-icon/index.d.ts +70 -0
- package/dist/components/product-icon/index.js +60 -0
- package/dist/components/product-icon/index.js.map +1 -0
- package/dist/components/radio-group/index.d.ts +105 -0
- package/dist/components/radio-group/index.js +597 -0
- package/dist/components/radio-group/index.js.map +1 -0
- package/dist/components/search-field/index.d.ts +98 -0
- package/dist/components/search-field/index.js +521 -0
- package/dist/components/search-field/index.js.map +1 -0
- package/dist/components/segmented-button/index.d.ts +113 -0
- package/dist/components/segmented-button/index.js +937 -0
- package/dist/components/segmented-button/index.js.map +1 -0
- package/dist/components/separator/index.d.ts +45 -0
- package/dist/components/separator/index.js +109 -0
- package/dist/components/separator/index.js.map +1 -0
- package/dist/components/stack/index.d.ts +70 -0
- package/dist/components/stack/index.js +107 -0
- package/dist/components/stack/index.js.map +1 -0
- package/dist/components/switch/index.d.ts +76 -0
- package/dist/components/switch/index.js +591 -0
- package/dist/components/switch/index.js.map +1 -0
- package/dist/components/text/index.d.ts +44 -0
- package/dist/components/text/index.js +78 -0
- package/dist/components/text/index.js.map +1 -0
- package/dist/components/text-field/index.d.ts +146 -0
- package/dist/components/text-field/index.js +228 -0
- package/dist/components/text-field/index.js.map +1 -0
- package/dist/control/index.js +117 -0
- package/dist/control/index.js.map +1 -0
- package/dist/control/styles.js +36 -0
- package/dist/control/styles.js.map +1 -0
- package/dist/field/index.d.ts +13 -0
- package/dist/field/index.js +1007 -0
- package/dist/field/index.js.map +1 -0
- package/dist/field/styles.js +131 -0
- package/dist/field/styles.js.map +1 -0
- package/dist/form/index.d.ts +24 -0
- package/dist/form/index.js +209 -0
- package/dist/form/index.js.map +1 -0
- package/dist/glyphs/icon-style.d.ts +25 -0
- package/dist/glyphs/icon-style.js +22 -0
- package/dist/glyphs/icon-style.js.map +1 -0
- package/dist/glyphs/index.js +170 -0
- package/dist/glyphs/index.js.map +1 -0
- package/dist/glyphs/styles.js +7 -0
- package/dist/glyphs/styles.js.map +1 -0
- package/dist/hooks/useWindowSizeClass.d.ts +25 -0
- package/dist/hooks/useWindowSizeClass.js +39 -0
- package/dist/hooks/useWindowSizeClass.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +27 -0
- package/dist/mark/image.js +61 -0
- package/dist/mark/image.js.map +1 -0
- package/dist/mark/index.d.ts +9 -0
- package/dist/mark/index.js +234 -0
- package/dist/mark/index.js.map +1 -0
- package/dist/mark/initials.js +65 -0
- package/dist/mark/initials.js.map +1 -0
- package/dist/mark/styles.d.ts +1 -0
- package/dist/mark/styles.js +73 -0
- package/dist/mark/styles.js.map +1 -0
- package/dist/number/parser.js +321 -0
- package/dist/number/parser.js.map +1 -0
- package/dist/number/state.js +235 -0
- package/dist/number/state.js.map +1 -0
- package/dist/overlay/host.js +111 -0
- package/dist/overlay/host.js.map +1 -0
- package/dist/press/index.js +350 -0
- package/dist/press/index.js.map +1 -0
- package/dist/press/styles.js +31 -0
- package/dist/press/styles.js.map +1 -0
- package/dist/router/index.d.ts +28 -0
- package/dist/router/index.js +82 -0
- package/dist/router/index.js.map +1 -0
- package/dist/theme/color.js +25 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/resolve.d.ts +6 -0
- package/dist/theme/resolve.js +310 -0
- package/dist/theme/resolve.js.map +1 -0
- package/dist/theme/scope.d.ts +42 -0
- package/dist/theme/scope.js +80 -0
- package/dist/theme/scope.js.map +1 -0
- package/dist/theme/styles.js +39 -0
- package/dist/theme/styles.js.map +1 -0
- package/dist/theme-scope.d.ts +56 -0
- package/dist/theme-scope.js +127 -0
- package/dist/theme-scope.js.map +1 -0
- package/dist/tokens/defaults.d.ts +407 -0
- package/dist/tokens/defaults.js +403 -0
- package/dist/tokens/defaults.js.map +1 -0
- package/dist/typography/fonts.js +84 -0
- package/dist/typography/fonts.js.map +1 -0
- package/dist/typography/roles.d.ts +10 -0
- package/dist/typography/roles.js +82 -0
- package/dist/typography/roles.js.map +1 -0
- package/package.json +132 -4
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { IconStyleContext } from "../../glyphs/icon-style.js";
|
|
2
|
+
import { useTheme } from "../../theme/scope.js";
|
|
3
|
+
import { composeStyles, themedStyles } from "../../theme/styles.js";
|
|
4
|
+
import { useTypeRole } from "../../typography/roles.js";
|
|
5
|
+
import { AnimatedPressable, HEIGHTS, OUTLINE_WIDTHS, PRESSED_CORNERS, buttonStyles, toggleState, useButtonAction, useCorner } from "../../button/index.js";
|
|
6
|
+
import { palettesOf } from "../../button/palettes.js";
|
|
7
|
+
import { hitSlop, usePressFeedback } from "../../press/index.js";
|
|
8
|
+
import { c } from "react/compiler-runtime";
|
|
9
|
+
import { StyleSheet, Text } from "react-native";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import Animated from "react-native-reanimated";
|
|
12
|
+
//#region src/components/button/index.tsx
|
|
13
|
+
const DISABLED = {
|
|
14
|
+
elevated: "filledDisabled",
|
|
15
|
+
filled: "filledDisabled",
|
|
16
|
+
outlined: "outlinedDisabled",
|
|
17
|
+
text: "textDisabled",
|
|
18
|
+
tonal: "filledDisabled"
|
|
19
|
+
};
|
|
20
|
+
const ICON_SIZES = {
|
|
21
|
+
lg: 24,
|
|
22
|
+
md: 20,
|
|
23
|
+
xl: 32,
|
|
24
|
+
xs: 20,
|
|
25
|
+
xxl: 40
|
|
26
|
+
};
|
|
27
|
+
const ROLES = {
|
|
28
|
+
lg: "titleMedium",
|
|
29
|
+
md: "labelLarge",
|
|
30
|
+
xl: "headlineSmall",
|
|
31
|
+
xs: "labelLarge",
|
|
32
|
+
xxl: "headlineLarge"
|
|
33
|
+
};
|
|
34
|
+
const SQUARE_CORNERS = {
|
|
35
|
+
lg: "lg",
|
|
36
|
+
md: "md",
|
|
37
|
+
xl: "xl",
|
|
38
|
+
xs: "md",
|
|
39
|
+
xxl: "xl"
|
|
40
|
+
};
|
|
41
|
+
const TOGGLE_PALETTES = {
|
|
42
|
+
elevated: {
|
|
43
|
+
selected: "elevatedToggleSelected",
|
|
44
|
+
unselected: "elevated"
|
|
45
|
+
},
|
|
46
|
+
filled: {
|
|
47
|
+
selected: "filledToggleSelected",
|
|
48
|
+
unselected: "filledToggle"
|
|
49
|
+
},
|
|
50
|
+
outlined: {
|
|
51
|
+
selected: "outlinedToggleSelected",
|
|
52
|
+
unselected: "outlined"
|
|
53
|
+
},
|
|
54
|
+
tonal: {
|
|
55
|
+
selected: "tonalToggleSelected",
|
|
56
|
+
unselected: "tonal"
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const styles = StyleSheet.create({
|
|
60
|
+
base: {
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
flexDirection: "row",
|
|
63
|
+
justifyContent: "center",
|
|
64
|
+
maxWidth: "100%"
|
|
65
|
+
},
|
|
66
|
+
icon: {
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
flexShrink: 0,
|
|
69
|
+
justifyContent: "center"
|
|
70
|
+
},
|
|
71
|
+
label: {
|
|
72
|
+
flexShrink: 1,
|
|
73
|
+
textAlign: "center"
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
function inlinePaddings({ spacing }) {
|
|
77
|
+
return {
|
|
78
|
+
lg: spacing.xl,
|
|
79
|
+
md: spacing.lg,
|
|
80
|
+
xl: 48,
|
|
81
|
+
xs: spacing.md,
|
|
82
|
+
xxl: 64
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const shadowsOf = themedStyles(({ shadows }) => StyleSheet.create({
|
|
86
|
+
elevation1: { boxShadow: shadows.elevation1 },
|
|
87
|
+
elevation2: { boxShadow: shadows.elevation2 }
|
|
88
|
+
}));
|
|
89
|
+
const sizesOf = themedStyles((theme) => {
|
|
90
|
+
const { sizing, spacing } = theme;
|
|
91
|
+
const inline = inlinePaddings(theme);
|
|
92
|
+
return StyleSheet.create({
|
|
93
|
+
lg: {
|
|
94
|
+
gap: spacing.sm,
|
|
95
|
+
minHeight: sizing.controlLg,
|
|
96
|
+
paddingHorizontal: inline.lg,
|
|
97
|
+
paddingVertical: spacing.md
|
|
98
|
+
},
|
|
99
|
+
md: {
|
|
100
|
+
gap: spacing.sm,
|
|
101
|
+
minHeight: sizing.controlSm,
|
|
102
|
+
paddingHorizontal: inline.md,
|
|
103
|
+
paddingVertical: spacing.sm
|
|
104
|
+
},
|
|
105
|
+
xl: {
|
|
106
|
+
gap: spacing.md,
|
|
107
|
+
minHeight: sizing.controlXl,
|
|
108
|
+
paddingHorizontal: inline.xl,
|
|
109
|
+
paddingVertical: spacing.xl
|
|
110
|
+
},
|
|
111
|
+
xs: {
|
|
112
|
+
gap: spacing.sm,
|
|
113
|
+
minHeight: sizing.controlXs,
|
|
114
|
+
paddingHorizontal: inline.xs,
|
|
115
|
+
paddingVertical: spacing.xs
|
|
116
|
+
},
|
|
117
|
+
xxl: {
|
|
118
|
+
gap: spacing.lg,
|
|
119
|
+
minHeight: sizing.controlXxl,
|
|
120
|
+
paddingHorizontal: inline.xxl,
|
|
121
|
+
paddingVertical: spacing.xxl
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
const outlinedSizesOf = themedStyles((theme) => {
|
|
126
|
+
const inline = inlinePaddings(theme);
|
|
127
|
+
function outlined(size) {
|
|
128
|
+
return {
|
|
129
|
+
borderWidth: OUTLINE_WIDTHS[size],
|
|
130
|
+
paddingHorizontal: inline[size] - OUTLINE_WIDTHS[size]
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return StyleSheet.create({
|
|
134
|
+
lg: outlined("lg"),
|
|
135
|
+
md: outlined("md"),
|
|
136
|
+
xl: outlined("xl"),
|
|
137
|
+
xs: outlined("xs"),
|
|
138
|
+
xxl: outlined("xxl")
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* The design's button, at five emphasis levels and five control heights,
|
|
143
|
+
* round or square, with web's props and values. Given `href` it is a link with
|
|
144
|
+
* the same appearance, and given `isSelected`, `defaultSelected` or
|
|
145
|
+
* `onChange` it is a toggle, which reports its state to a screen reader and
|
|
146
|
+
* draws the page's second pair of colour roles for its variant.
|
|
147
|
+
*
|
|
148
|
+
* ```tsx
|
|
149
|
+
* <Button defaultSelected variant="tonal">
|
|
150
|
+
* Label
|
|
151
|
+
* </Button>
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* A column stretches a button across it, as it does any view, and as a flex
|
|
155
|
+
* column does a button on web; a column that should hold its buttons at their
|
|
156
|
+
* labels' width says so with `alignItems`.
|
|
157
|
+
*
|
|
158
|
+
* The two sizes under 48dp tall, `xs` and `md`, take presses over a 48dp
|
|
159
|
+
* target through `hitSlop`, which a `hitSlop` of the call site's own replaces.
|
|
160
|
+
* `style`, `ref` and `testID` land on the `Pressable`.
|
|
161
|
+
*/
|
|
162
|
+
function Button(t0) {
|
|
163
|
+
const $ = c(58);
|
|
164
|
+
let children;
|
|
165
|
+
let defaultSelected;
|
|
166
|
+
let href;
|
|
167
|
+
let icon;
|
|
168
|
+
let isSelected;
|
|
169
|
+
let onBlur;
|
|
170
|
+
let onChange;
|
|
171
|
+
let onFocus;
|
|
172
|
+
let onHoverIn;
|
|
173
|
+
let onHoverOut;
|
|
174
|
+
let onLayout;
|
|
175
|
+
let onPress;
|
|
176
|
+
let onPressIn;
|
|
177
|
+
let onPressOut;
|
|
178
|
+
let ownHitSlop;
|
|
179
|
+
let props;
|
|
180
|
+
let style;
|
|
181
|
+
let t1;
|
|
182
|
+
let t2;
|
|
183
|
+
let t3;
|
|
184
|
+
let t4;
|
|
185
|
+
let t5;
|
|
186
|
+
let type;
|
|
187
|
+
if ($[0] !== t0) {
|
|
188
|
+
({children, defaultSelected, disableRipple: t1, hitSlop: ownHitSlop, href, icon, isDisabled: t2, isSelected, onBlur, onChange, onFocus, onHoverIn, onHoverOut, onLayout, onPress, onPressIn, onPressOut, shape: t3, size: t4, style, type, variant: t5, ...props} = t0);
|
|
189
|
+
$[0] = t0;
|
|
190
|
+
$[1] = children;
|
|
191
|
+
$[2] = defaultSelected;
|
|
192
|
+
$[3] = href;
|
|
193
|
+
$[4] = icon;
|
|
194
|
+
$[5] = isSelected;
|
|
195
|
+
$[6] = onBlur;
|
|
196
|
+
$[7] = onChange;
|
|
197
|
+
$[8] = onFocus;
|
|
198
|
+
$[9] = onHoverIn;
|
|
199
|
+
$[10] = onHoverOut;
|
|
200
|
+
$[11] = onLayout;
|
|
201
|
+
$[12] = onPress;
|
|
202
|
+
$[13] = onPressIn;
|
|
203
|
+
$[14] = onPressOut;
|
|
204
|
+
$[15] = ownHitSlop;
|
|
205
|
+
$[16] = props;
|
|
206
|
+
$[17] = style;
|
|
207
|
+
$[18] = t1;
|
|
208
|
+
$[19] = t2;
|
|
209
|
+
$[20] = t3;
|
|
210
|
+
$[21] = t4;
|
|
211
|
+
$[22] = t5;
|
|
212
|
+
$[23] = type;
|
|
213
|
+
} else {
|
|
214
|
+
children = $[1];
|
|
215
|
+
defaultSelected = $[2];
|
|
216
|
+
href = $[3];
|
|
217
|
+
icon = $[4];
|
|
218
|
+
isSelected = $[5];
|
|
219
|
+
onBlur = $[6];
|
|
220
|
+
onChange = $[7];
|
|
221
|
+
onFocus = $[8];
|
|
222
|
+
onHoverIn = $[9];
|
|
223
|
+
onHoverOut = $[10];
|
|
224
|
+
onLayout = $[11];
|
|
225
|
+
onPress = $[12];
|
|
226
|
+
onPressIn = $[13];
|
|
227
|
+
onPressOut = $[14];
|
|
228
|
+
ownHitSlop = $[15];
|
|
229
|
+
props = $[16];
|
|
230
|
+
style = $[17];
|
|
231
|
+
t1 = $[18];
|
|
232
|
+
t2 = $[19];
|
|
233
|
+
t3 = $[20];
|
|
234
|
+
t4 = $[21];
|
|
235
|
+
t5 = $[22];
|
|
236
|
+
type = $[23];
|
|
237
|
+
}
|
|
238
|
+
const disableRipple = t1 === void 0 ? false : t1;
|
|
239
|
+
const isDisabled = t2 === void 0 ? false : t2;
|
|
240
|
+
const shape = t3 === void 0 ? "round" : t3;
|
|
241
|
+
const size = t4 === void 0 ? "md" : t4;
|
|
242
|
+
const variant = t5 === void 0 ? "filled" : t5;
|
|
243
|
+
const theme = useTheme();
|
|
244
|
+
const role = useTypeRole(ROLES[size]);
|
|
245
|
+
const isToggle = variant !== "text" && (defaultSelected !== void 0 || isSelected !== void 0 || onChange !== void 0);
|
|
246
|
+
let t6;
|
|
247
|
+
if ($[24] !== defaultSelected || $[25] !== href || $[26] !== isSelected || $[27] !== isToggle || $[28] !== onChange || $[29] !== onPress || $[30] !== type) {
|
|
248
|
+
t6 = {
|
|
249
|
+
defaultSelected,
|
|
250
|
+
href,
|
|
251
|
+
isSelected,
|
|
252
|
+
isToggle,
|
|
253
|
+
onChange,
|
|
254
|
+
onPress,
|
|
255
|
+
type
|
|
256
|
+
};
|
|
257
|
+
$[24] = defaultSelected;
|
|
258
|
+
$[25] = href;
|
|
259
|
+
$[26] = isSelected;
|
|
260
|
+
$[27] = isToggle;
|
|
261
|
+
$[28] = onChange;
|
|
262
|
+
$[29] = onPress;
|
|
263
|
+
$[30] = type;
|
|
264
|
+
$[31] = t6;
|
|
265
|
+
} else t6 = $[31];
|
|
266
|
+
const action = useButtonAction(t6);
|
|
267
|
+
const colors = palettesOf(theme)[isDisabled ? DISABLED[variant] : variant !== "text" && isToggle ? TOGGLE_PALETTES[variant][action.selected ? "selected" : "unselected"] : variant];
|
|
268
|
+
const feedback = usePressFeedback({
|
|
269
|
+
color: colors.content,
|
|
270
|
+
disabled: isDisabled,
|
|
271
|
+
disableRipple,
|
|
272
|
+
onBlur,
|
|
273
|
+
onFocus,
|
|
274
|
+
onHoverIn,
|
|
275
|
+
onHoverOut,
|
|
276
|
+
onPressIn,
|
|
277
|
+
onPressOut
|
|
278
|
+
});
|
|
279
|
+
const { radii } = theme;
|
|
280
|
+
const resting = shape === "square" !== action.selected ? radii[SQUARE_CORNERS[size]] : radii.pill;
|
|
281
|
+
const shaped = useCorner(feedback.pressed ? radii[PRESSED_CORNERS[size]] : resting, onLayout);
|
|
282
|
+
const T0 = AnimatedPressable;
|
|
283
|
+
const t7 = href === void 0 ? "button" : "link";
|
|
284
|
+
let t8;
|
|
285
|
+
if ($[32] !== action.selected || $[33] !== isToggle) {
|
|
286
|
+
t8 = isToggle ? toggleState(action.selected) : void 0;
|
|
287
|
+
$[32] = action.selected;
|
|
288
|
+
$[33] = isToggle;
|
|
289
|
+
$[34] = t8;
|
|
290
|
+
} else t8 = $[34];
|
|
291
|
+
const t9 = feedback.handlers;
|
|
292
|
+
let t10;
|
|
293
|
+
if ($[35] !== ownHitSlop || $[36] !== size || $[37] !== theme.sizing) {
|
|
294
|
+
t10 = ownHitSlop ?? hitSlop(theme.sizing[HEIGHTS[size]]);
|
|
295
|
+
$[35] = ownHitSlop;
|
|
296
|
+
$[36] = size;
|
|
297
|
+
$[37] = theme.sizing;
|
|
298
|
+
$[38] = t10;
|
|
299
|
+
} else t10 = $[38];
|
|
300
|
+
const t11 = shaped.onLayout;
|
|
301
|
+
const t12 = action.onPress;
|
|
302
|
+
const t13 = composeStyles(styles.base, sizesOf(theme)[size], variant === "outlined" ? outlinedSizesOf(theme)[size] : void 0, colors.container, shadowOf(variant, feedback, isDisabled, theme), shaped.corner, feedback.ring, style);
|
|
303
|
+
let t14;
|
|
304
|
+
if ($[39] !== shaped.corner) {
|
|
305
|
+
t14 = composeStyles(buttonStyles.clip, shaped.corner);
|
|
306
|
+
$[39] = shaped.corner;
|
|
307
|
+
$[40] = t14;
|
|
308
|
+
} else t14 = $[40];
|
|
309
|
+
let t15;
|
|
310
|
+
if ($[41] !== feedback.layer || $[42] !== t14) {
|
|
311
|
+
t15 = /* @__PURE__ */ jsx(Animated.View, {
|
|
312
|
+
style: t14,
|
|
313
|
+
children: feedback.layer
|
|
314
|
+
});
|
|
315
|
+
$[41] = feedback.layer;
|
|
316
|
+
$[42] = t14;
|
|
317
|
+
$[43] = t15;
|
|
318
|
+
} else t15 = $[43];
|
|
319
|
+
const t16 = icon === void 0 ? null : /* @__PURE__ */ jsx(IconStyleContext, {
|
|
320
|
+
value: iconStyleOf(colors.content, size),
|
|
321
|
+
children: icon
|
|
322
|
+
});
|
|
323
|
+
const t17 = children === void 0 ? null : /* @__PURE__ */ jsx(Text, {
|
|
324
|
+
style: composeStyles(role, styles.label, colors.label),
|
|
325
|
+
children
|
|
326
|
+
});
|
|
327
|
+
let t18;
|
|
328
|
+
if ($[44] !== T0 || $[45] !== action.onPress || $[46] !== feedback.handlers || $[47] !== isDisabled || $[48] !== props || $[49] !== shaped.onLayout || $[50] !== t10 || $[51] !== t13 || $[52] !== t15 || $[53] !== t16 || $[54] !== t17 || $[55] !== t7 || $[56] !== t8) {
|
|
329
|
+
t18 = /* @__PURE__ */ jsxs(T0, {
|
|
330
|
+
role: t7,
|
|
331
|
+
...t8,
|
|
332
|
+
...props,
|
|
333
|
+
...t9,
|
|
334
|
+
disabled: isDisabled,
|
|
335
|
+
hitSlop: t10,
|
|
336
|
+
onLayout: t11,
|
|
337
|
+
onPress: t12,
|
|
338
|
+
style: t13,
|
|
339
|
+
children: [
|
|
340
|
+
t15,
|
|
341
|
+
t16,
|
|
342
|
+
t17
|
|
343
|
+
]
|
|
344
|
+
});
|
|
345
|
+
$[44] = T0;
|
|
346
|
+
$[45] = action.onPress;
|
|
347
|
+
$[46] = feedback.handlers;
|
|
348
|
+
$[47] = isDisabled;
|
|
349
|
+
$[48] = props;
|
|
350
|
+
$[49] = shaped.onLayout;
|
|
351
|
+
$[50] = t10;
|
|
352
|
+
$[51] = t13;
|
|
353
|
+
$[52] = t15;
|
|
354
|
+
$[53] = t16;
|
|
355
|
+
$[54] = t17;
|
|
356
|
+
$[55] = t7;
|
|
357
|
+
$[56] = t8;
|
|
358
|
+
$[57] = t18;
|
|
359
|
+
} else t18 = $[57];
|
|
360
|
+
return t18;
|
|
361
|
+
}
|
|
362
|
+
function iconStyleOf(color, size) {
|
|
363
|
+
return {
|
|
364
|
+
color,
|
|
365
|
+
size: ICON_SIZES[size]
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function shadowOf(variant, { hovered, pressed }, isDisabled, theme) {
|
|
369
|
+
const lifted = hovered && !pressed;
|
|
370
|
+
if (isDisabled) return;
|
|
371
|
+
if (variant === "elevated") return shadowsOf(theme)[lifted ? "elevation2" : "elevation1"];
|
|
372
|
+
return (variant === "filled" || variant === "tonal") && lifted ? shadowsOf(theme).elevation1 : void 0;
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
export { Button };
|
|
376
|
+
|
|
377
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","Ref","PressableProps","StyleProp","TextStyle","View","ViewStyle","AnimatedStyle","Text","NativeText","StyleSheet","Animated","ButtonLinkForm","ButtonPressForm","ButtonToggleForm","PaletteName","IconStyle","ResolvedTheme","TypeRole","AnimatedPressable","buttonStyles","HEIGHTS","OUTLINE_WIDTHS","PRESSED_CORNERS","toggleState","useButtonAction","useCorner","palettesOf","IconStyleContext","hitSlop","usePressFeedback","useTheme","composeStyles","themedStyles","useTypeRole","ButtonForm","variant","Exclude","ButtonVariant","ButtonProps","Omit","children","disableRipple","icon","isDisabled","ref","shape","ButtonShape","size","ButtonSize","style","ToggleVariant","DISABLED","Readonly","Record","elevated","filled","outlined","text","tonal","ICON_SIZES","lg","md","xl","xs","xxl","ROLES","SQUARE_CORNERS","const","TOGGLE_PALETTES","selected","unselected","styles","create","base","alignItems","flexDirection","justifyContent","maxWidth","flexShrink","label","textAlign","inlinePaddings","spacing","shadowsOf","shadows","elevation1","boxShadow","elevation2","sizesOf","theme","sizing","inline","gap","sm","minHeight","controlLg","paddingHorizontal","paddingVertical","controlSm","controlXl","controlXs","controlXxl","outlinedSizesOf","borderWidth","Button","t0","$","_c","defaultSelected","href","isSelected","onBlur","onChange","onFocus","onHoverIn","onHoverOut","onLayout","onPress","onPressIn","onPressOut","ownHitSlop","props","t1","t2","t3","t4","t5","type","undefined","role","isToggle","t6","action","colors","feedback","color","content","disabled","radii","resting","pill","shaped","pressed","T0","t7","t8","t9","handlers","t10","t11","t12","t13","container","shadowOf","corner","ring","t14","clip","t15","layer","t16","iconStyleOf","t17","t18","hovered","lifted","_c","NativeText"],"sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react'\nimport type {\n PressableProps,\n StyleProp,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\n\nimport { Text as NativeText, StyleSheet } from 'react-native'\nimport Animated from 'react-native-reanimated'\n\nimport type {\n ButtonLinkForm,\n ButtonPressForm,\n ButtonToggleForm,\n} from '../../button'\nimport type { PaletteName } from '../../button/palettes'\nimport type { IconStyle } from '../../glyphs/icon-style'\nimport type { ResolvedTheme } from '../../theme/scope'\nimport type { TypeRole } from '../../typography/roles'\n\nimport {\n AnimatedPressable,\n buttonStyles,\n HEIGHTS,\n OUTLINE_WIDTHS,\n PRESSED_CORNERS,\n toggleState,\n useButtonAction,\n useCorner,\n} from '../../button'\nimport { palettesOf } from '../../button/palettes'\nimport { IconStyleContext } from '../../glyphs/icon-style'\nimport { hitSlop, usePressFeedback } from '../../press'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\n\n// The buttons spec page's five colour styles, five sizes and two shapes, as\n// kanso-ui's Button draws them. The variant carries colour and the size\n// carries geometry, so the two never argue: the padding belongs to the size\n// alone, and a text button is as wide as a filled one at the same size.\n//\n// The colour pairs are the page's: filled on primary, tonal on secondary\n// container, outlined with an outline-variant rule and an on-surface-variant\n// label, text on primary, and elevated on surface container low with a\n// primary label. Elevated is the one variant whose shadow is part of it: it\n// rests at elevation 1, rises to 2 under a pointer and settles back while\n// pressed, where filled and tonal rest flat and lift to 1 under a pointer\n// only. The shadow is the theme's `boxShadow` value, which React Native draws\n// on iOS and Android as React Native Web draws it in a browser.\n//\n// The state layers, the ripple and the focus ring are src/press's, drawn in\n// the label's colour over the container, as on web.\n//\n// **Disabled is the page's colour at an opacity, translucent.** A container\n// is on-surface at the `disabledContainer` opacity, and the label on-surface\n// at `disabledContent`, over whatever the button sits on rather than mixed\n// over the surface role as web's are; src/button/palettes.ts gives the\n// reason. Disabled drops the shadow, since a shadow says a control is there\n// to press.\n//\n// **A toggle is the same button reporting a state.** Given `isSelected`,\n// `defaultSelected` or `onChange` it takes the page's second pair of colour\n// roles for its variant: a filled toggle rests on surface container with an\n// on-surface-variant label and takes primary once selected, a tonal one moves\n// from the secondary container pair to secondary, an elevated one keeps its\n// low surface until it takes primary, and an outlined one swaps its rule for\n// the inverse surface pair. The page gives text no pair, so a text button\n// given those props stays a plain one.\n//\n// **The corner is a shape the button morphs between.** `round` rests as the\n// pill and `square` at the size's square corner: 12dp up to the page's S,\n// 16dp at M and 28dp above. A press tightens either to the size's pressed\n// corner, 8dp, 12dp or 16dp, and a toggle trades its shape for the other\n// once selected. The corner eases through Reanimated, as src/button's\n// `useCorner` sets out.\n//\n// The forms, the toggle's state, what a press does and the corner's ease are\n// src/button's, shared with IconButton.\n\ntype ButtonForm =\n | ButtonLinkForm\n | ButtonPressForm\n | (ButtonToggleForm & {\n /**\n * A toggle takes any variant but `text`, which the page gives no\n * selected colours.\n */\n readonly variant?: Exclude<ButtonVariant, 'text'>\n })\n\ntype ButtonProps = ButtonForm &\n Omit<PressableProps, 'children' | 'disabled' | 'style'> & {\n /** The label. */\n readonly children?: ReactNode\n /**\n * Draws no press ripple. The state layer is unaffected.\n * @default false\n */\n readonly disableRipple?: boolean\n /**\n * An icon before the label, at the page's icon size for the button's\n * size: 20dp at `xs` and `md`, 24dp at `lg`, 32dp at `xl` and 40dp at\n * `xxl`. The slot hands it the label's colour and that size through\n * `useIconStyle()`.\n */\n readonly icon?: ReactNode\n /**\n * Draws the button disabled, and takes no presses.\n * @default false\n */\n readonly isDisabled?: boolean\n readonly ref?: Ref<View>\n /**\n * The corner the button rests at: `round` is the pill, `square` the\n * page's rounded rectangle, 12dp up to `md`, 16dp at `lg` and 28dp above.\n * Either tightens while pressed, and a toggle trades one for the other\n * once selected.\n * @default 'round'\n */\n readonly shape?: ButtonShape\n /**\n * Control height: `xs` 32dp, `md` 40dp, `lg` 56dp, `xl` 96dp, `xxl` 136dp,\n * the buttons spec page's XS, S, M, L and XL, each with its own padding\n * and type role. `md` is the page's default. The height is a floor, so a\n * label that wraps, or that the device's text size enlarges, grows the\n * button rather than running out of it.\n * @default 'md'\n */\n readonly size?: ButtonSize\n readonly style?: StyleProp<ViewStyle>\n /**\n * How much weight the button pulls. `filled` and `tonal` carry a container\n * of their own; `outlined` and `text` sit on the page; `elevated` sits on\n * a low surface and lifts off it with a shadow, for a button that has to\n * separate from a busy background rather than from the page.\n * @default 'filled'\n */\n readonly variant?: ButtonVariant\n }\n\ntype ButtonShape = 'round' | 'square'\n\ntype ButtonSize = 'lg' | 'md' | 'xl' | 'xs' | 'xxl'\n\ntype ButtonVariant = 'elevated' | 'filled' | 'outlined' | 'text' | 'tonal'\n\ntype ToggleVariant = Exclude<ButtonVariant, 'text'>\n\n// The disabled container each variant draws. Filled, tonal and elevated share\n// one, which is the page's single disabled container for all three.\nconst DISABLED: Readonly<Record<ButtonVariant, PaletteName>> = {\n elevated: 'filledDisabled',\n filled: 'filledDisabled',\n outlined: 'outlinedDisabled',\n text: 'textDisabled',\n tonal: 'filledDisabled',\n}\n\n// The icon each size draws, from the page's size token sets. Literals, as on\n// web: they are icon sizes, which the theme has no scale for.\nconst ICON_SIZES: Readonly<Record<ButtonSize, number>> = {\n lg: 24,\n md: 20,\n xl: 32,\n xs: 20,\n xxl: 40,\n}\n\n// The type role each size sets its label in, taken whole: label-large for the\n// two small sizes, then title-medium, headline-small and headline-large.\nconst ROLES: Readonly<Record<ButtonSize, TypeRole>> = {\n lg: 'titleMedium',\n md: 'labelLarge',\n xl: 'headlineSmall',\n xs: 'labelLarge',\n xxl: 'headlineLarge',\n}\n\n// The square corner each size rests at, and a round toggle takes once\n// selected.\nconst SQUARE_CORNERS = {\n lg: 'lg',\n md: 'md',\n xl: 'xl',\n xs: 'md',\n xxl: 'xl',\n} as const satisfies Record<ButtonSize, keyof ResolvedTheme['radii']>\n\n// Which container a toggle draws, selected and not.\nconst TOGGLE_PALETTES: Readonly<\n Record<\n ToggleVariant,\n Readonly<Record<'selected' | 'unselected', PaletteName>>\n >\n> = {\n elevated: { selected: 'elevatedToggleSelected', unselected: 'elevated' },\n filled: { selected: 'filledToggleSelected', unselected: 'filledToggle' },\n outlined: { selected: 'outlinedToggleSelected', unselected: 'outlined' },\n tonal: { selected: 'tonalToggleSelected', unselected: 'tonal' },\n}\n\nconst styles = StyleSheet.create({\n // The label sits in the middle of a button wider than it, one stretched by\n // a column or given a width, as the page draws every button, and a button\n // is never wider than what holds it.\n base: {\n alignItems: 'center',\n flexDirection: 'row',\n justifyContent: 'center',\n maxWidth: '100%',\n },\n icon: {\n alignItems: 'center',\n flexShrink: 0,\n justifyContent: 'center',\n },\n // A label too long for the row wraps, its lines centred, and grows the\n // button with it.\n label: {\n flexShrink: 1,\n textAlign: 'center',\n },\n})\n\n// Each size's inline padding. The two largest are literals: 48 and 64 are not\n// steps of the spacing scale, and the scale should not grow to fit one\n// component. `xs` pads 12 a side, the extra-small token set's leading and\n// trailing space.\nfunction inlinePaddings({\n spacing,\n}: ResolvedTheme): Readonly<Record<ButtonSize, number>> {\n return { lg: spacing.xl, md: spacing.lg, xl: 48, xs: spacing.md, xxl: 64 }\n}\n\nconst shadowsOf = themedStyles(({ shadows }) =>\n StyleSheet.create({\n elevation1: { boxShadow: shadows.elevation1 },\n elevation2: { boxShadow: shadows.elevation2 },\n }),\n)\n\n// The five sizes, from the page's size token sets: the container height, the\n// padding, and the gap before an icon. The height is a floor rather than a\n// fixed size, and the block padding is what keeps a wrapped label off the\n// pill's edge: a step short of a single line's own inset, so a label on one\n// line still draws exactly the page's height.\nconst sizesOf = themedStyles((theme) => {\n const { sizing, spacing } = theme\n const inline = inlinePaddings(theme)\n\n return StyleSheet.create({\n lg: {\n gap: spacing.sm,\n minHeight: sizing.controlLg,\n paddingHorizontal: inline.lg,\n paddingVertical: spacing.md,\n },\n md: {\n gap: spacing.sm,\n minHeight: sizing.controlSm,\n paddingHorizontal: inline.md,\n paddingVertical: spacing.sm,\n },\n xl: {\n gap: spacing.md,\n minHeight: sizing.controlXl,\n paddingHorizontal: inline.xl,\n paddingVertical: spacing.xl,\n },\n xs: {\n gap: spacing.sm,\n minHeight: sizing.controlXs,\n paddingHorizontal: inline.xs,\n paddingVertical: spacing.xs,\n },\n xxl: {\n gap: spacing.lg,\n minHeight: sizing.controlXxl,\n paddingHorizontal: inline.xxl,\n paddingVertical: spacing.xxl,\n },\n })\n})\n\n// The outlined button draws its rule inside the width the other variants\n// take, as the page's buttons do: the padding gives up what the rule takes,\n// so an outlined and a filled button with one label are one width.\nconst outlinedSizesOf = themedStyles((theme) => {\n const inline = inlinePaddings(theme)\n\n function outlined(size: ButtonSize): ViewStyle {\n return {\n borderWidth: OUTLINE_WIDTHS[size],\n paddingHorizontal: inline[size] - OUTLINE_WIDTHS[size],\n }\n }\n\n return StyleSheet.create({\n lg: outlined('lg'),\n md: outlined('md'),\n xl: outlined('xl'),\n xs: outlined('xs'),\n xxl: outlined('xxl'),\n })\n})\n\n/**\n * The design's button, at five emphasis levels and five control heights,\n * round or square, with web's props and values. Given `href` it is a link with\n * the same appearance, and given `isSelected`, `defaultSelected` or\n * `onChange` it is a toggle, which reports its state to a screen reader and\n * draws the page's second pair of colour roles for its variant.\n *\n * ```tsx\n * <Button defaultSelected variant=\"tonal\">\n * Label\n * </Button>\n * ```\n *\n * A column stretches a button across it, as it does any view, and as a flex\n * column does a button on web; a column that should hold its buttons at their\n * labels' width says so with `alignItems`.\n *\n * The two sizes under 48dp tall, `xs` and `md`, take presses over a 48dp\n * target through `hitSlop`, which a `hitSlop` of the call site's own replaces.\n * `style`, `ref` and `testID` land on the `Pressable`.\n */\nfunction Button({\n children,\n defaultSelected,\n disableRipple = false,\n hitSlop: ownHitSlop,\n href,\n icon,\n isDisabled = false,\n isSelected,\n onBlur,\n onChange,\n onFocus,\n onHoverIn,\n onHoverOut,\n onLayout,\n onPress,\n onPressIn,\n onPressOut,\n shape = 'round',\n size = 'md',\n style,\n type,\n variant = 'filled',\n ...props\n}: ButtonProps) {\n const theme = useTheme()\n const role = useTypeRole(ROLES[size])\n\n // The three props that make this a toggle, read as web reads them. The\n // types keep them off a `text` button; the check here keeps a call site\n // that slipped past them a plain button.\n const isToggle =\n variant !== 'text' &&\n (defaultSelected !== undefined ||\n isSelected !== undefined ||\n onChange !== undefined)\n const action = useButtonAction({\n defaultSelected,\n href,\n isSelected,\n isToggle,\n onChange,\n onPress,\n type,\n })\n const colors =\n palettesOf(theme)[\n isDisabled\n ? DISABLED[variant]\n : variant !== 'text' && isToggle\n ? TOGGLE_PALETTES[variant][\n action.selected ? 'selected' : 'unselected'\n ]\n : variant\n ]\n\n const feedback = usePressFeedback({\n color: colors.content,\n disabled: isDisabled,\n disableRipple,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n })\n\n const { radii } = theme\n const resting =\n (shape === 'square') !== action.selected\n ? radii[SQUARE_CORNERS[size]]\n : radii.pill\n const shaped = useCorner(\n feedback.pressed ? radii[PRESSED_CORNERS[size]] : resting,\n onLayout,\n )\n\n return (\n <AnimatedPressable\n role={href === undefined ? 'button' : 'link'}\n {...(isToggle ? toggleState(action.selected) : undefined)}\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n hitSlop={ownHitSlop ?? hitSlop(theme.sizing[HEIGHTS[size]])}\n onLayout={shaped.onLayout}\n onPress={action.onPress}\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n styles.base,\n sizesOf(theme)[size],\n variant === 'outlined' ? outlinedSizesOf(theme)[size] : undefined,\n colors.container,\n shadowOf(variant, feedback, isDisabled, theme),\n shaped.corner,\n feedback.ring,\n style,\n )}\n >\n <Animated.View\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n buttonStyles.clip,\n shaped.corner,\n )}\n >\n {feedback.layer}\n </Animated.View>\n {icon === undefined ? null : (\n <IconStyleContext value={iconStyleOf(colors.content, size)}>\n {icon}\n </IconStyleContext>\n )}\n {children === undefined ? null : (\n <NativeText\n style={composeStyles<TextStyle>(role, styles.label, colors.label)}\n >\n {children}\n </NativeText>\n )}\n </AnimatedPressable>\n )\n}\n\nfunction iconStyleOf(color: string, size: ButtonSize): IconStyle {\n return { color, size: ICON_SIZES[size] }\n}\n\n// The shadow a variant draws in its state: elevated rests at 1 and rises to 2\n// under a pointer, filled and tonal rest flat and rise to 1, and a press\n// brings each back to where it rests.\nfunction shadowOf(\n variant: ButtonVariant,\n {\n hovered,\n pressed,\n }: { readonly hovered: boolean; readonly pressed: boolean },\n isDisabled: boolean,\n theme: ResolvedTheme,\n): undefined | ViewStyle {\n const lifted = hovered && !pressed\n\n if (isDisabled) {\n return undefined\n }\n\n if (variant === 'elevated') {\n return shadowsOf(theme)[lifted ? 'elevation2' : 'elevation1']\n }\n\n return (variant === 'filled' || variant === 'tonal') && lifted\n ? shadowsOf(theme).elevation1\n : undefined\n}\n\nexport { Button }\nexport type { ButtonProps, ButtonShape, ButtonSize, ButtonVariant }\n"],"mappings":";;;;;;;;;;;;AA0JA,MAAMoD,WAAyD;CAC7DG,UAAU;CACVC,QAAQ;CACRC,UAAU;CACVC,MAAM;CACNC,OAAO;AACT;AAIA,MAAMC,aAAmD;CACvDC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,KAAK;AACP;AAIA,MAAMC,QAAgD;CACpDL,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,KAAK;AACP;AAIA,MAAME,iBAAiB;CACrB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,OAAAzB;EAAAV,EAAA,MAAA0C;EAAA1C,EAAA,MAAA6C;EAAA7C,EAAA,MAAAoD;EAAApD,EAAA,MAAAsD;EAAAtD,EAAA,MAAAwD;EAAAxD,EAAA,MAAAsC;EAAAtC,EAAA,MAAAuC;EAAAvC,EAAA,MAAAyD;CAAA,OAAAA,MAAAzD,EAAA;CAAA,OAxCpByD;AAwCoB;AAIxB,SAASF,YAAY1B,OAAexF,MAA6B;CAC/D,OAAO;EAAEwF;EAAOxF,MAAMY,WAAWZ;CAAM;AACzC;AAKA,SAAS0G,SACPtH,SACA,EACEiI,SACAtB,WAEFnG,YACA8C,OACuB;CACvB,MAAM4E,SAASD,WAAW,CAACtB;CAE3B,IAAInG,YACF;CAGF,IAAIR,YAAY,YACd,OAAOgD,UAAUM,KAAK,CAAC,CAAC4E,SAAS,eAAe;CAGlD,QAAQlI,YAAY,YAAYA,YAAY,YAAYkI,SACpDlF,UAAUM,KAAK,CAAC,CAACJ,aACjB2C,KAAAA;AACN"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { PressableProps, StyleProp, View, ViewProps, ViewStyle } from "react-native";
|
|
2
|
+
import { ReactNode, Ref } from "react";
|
|
3
|
+
//#region src/components/card/index.d.ts
|
|
4
|
+
type CardBaseProps = {
|
|
5
|
+
readonly children?: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Turns an interactive card off: it fades as the cards page draws a
|
|
8
|
+
* disabled card, and takes no press. It is still announced, as disabled.
|
|
9
|
+
* Has no effect on a card that is not `interactive`, which cannot be
|
|
10
|
+
* pressed to begin with.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
readonly isDisabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* `none` removes the card's own padding, for a card whose children run to
|
|
16
|
+
* its edges, such as a list of rows separated by rules.
|
|
17
|
+
* @default 'default'
|
|
18
|
+
*/
|
|
19
|
+
readonly padding?: 'default' | 'none';
|
|
20
|
+
readonly ref?: Ref<View>;
|
|
21
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
22
|
+
/**
|
|
23
|
+
* How the card separates itself from the page: `elevated` casts a shadow,
|
|
24
|
+
* `filled` sits on a darker surface, `outlined` draws a border.
|
|
25
|
+
* @default 'elevated'
|
|
26
|
+
*/
|
|
27
|
+
readonly variant?: CardVariant;
|
|
28
|
+
};
|
|
29
|
+
type CardProps = CardBaseProps & (InteractiveCardForm | StaticCardForm);
|
|
30
|
+
type CardVariant = 'elevated' | 'filled' | 'outlined';
|
|
31
|
+
/**
|
|
32
|
+
* A card that presses as a whole: a `Pressable` announced as a button, or as
|
|
33
|
+
* a link given `href`.
|
|
34
|
+
*/
|
|
35
|
+
type InteractiveCardForm = Omit<PressableProps, 'children' | 'disabled' | 'style'> & {
|
|
36
|
+
/**
|
|
37
|
+
* Where the card leads. A press opens it through the `RouterProvider`
|
|
38
|
+
* around the card, or through the platform for a URL with a scheme of its
|
|
39
|
+
* own, after the call site's own `onPress`, and the card is announced as a
|
|
40
|
+
* link.
|
|
41
|
+
*/
|
|
42
|
+
readonly href?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Makes the card the thing you press: it ripples, draws the state layers,
|
|
45
|
+
* lifts under a pointer and takes a focus ring. Leave it off for a card
|
|
46
|
+
* that merely holds content, including one holding buttons of its own.
|
|
47
|
+
*/
|
|
48
|
+
readonly interactive: true;
|
|
49
|
+
};
|
|
50
|
+
/** A card that holds content and takes no press: a `View` with no role. */
|
|
51
|
+
type StaticCardForm = Omit<ViewProps, 'children' | 'style'> & {
|
|
52
|
+
readonly href?: never;
|
|
53
|
+
readonly interactive?: false;
|
|
54
|
+
readonly onPress?: never;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A surface holding related content.
|
|
58
|
+
*
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <Card interactive onPress={open}>
|
|
61
|
+
* <Text variant="titleMedium">Headline</Text>
|
|
62
|
+
* </Card>
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* A card is a `View` with no role, unless it is `interactive`: then it is a
|
|
66
|
+
* `Pressable` announced as a button, or as a link given `href`, which presses
|
|
67
|
+
* as a whole. Web's `render` has no counterpart, since native has no element
|
|
68
|
+
* to choose, and `href` is how a card leads somewhere instead. The press
|
|
69
|
+
* props belong to an interactive card alone, so a static card given
|
|
70
|
+
* `onPress` is a compile error rather than a press that never fires.
|
|
71
|
+
*
|
|
72
|
+
* A card fills the column it sits in, as any view in a React Native column
|
|
73
|
+
* does. `style`, `ref` and `testID` land on the card's own view.
|
|
74
|
+
*/
|
|
75
|
+
declare function Card(props: CardProps): import("react").JSX.Element;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { Card, type CardProps, type CardVariant };
|
|
78
|
+
//# sourceMappingURL=index.d.ts.map
|