@kanso-labs/react-native-kanso-ui 0.1.1 → 0.3.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/dist/button/index.d.ts +32 -2
- package/dist/button/index.js +38 -26
- package/dist/button/index.js.map +1 -1
- package/dist/button/pending.js +144 -0
- package/dist/button/pending.js.map +1 -0
- package/dist/button/slots.js +7 -0
- package/dist/button/slots.js.map +1 -0
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/button/index.d.ts +3 -3
- package/dist/components/button/index.js +159 -111
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/card/index.d.ts +2 -2
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +2 -2
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.d.ts +3 -3
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/copy-field/index.d.ts +2 -2
- package/dist/components/copy-field/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +131 -0
- package/dist/components/dialog/index.js +861 -0
- package/dist/components/dialog/index.js.map +1 -0
- package/dist/components/icon-button/index.d.ts +3 -3
- package/dist/components/icon-button/index.js +165 -109
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/link/index.js +1 -1
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/meter/index.d.ts +73 -0
- package/dist/components/meter/index.js +179 -0
- package/dist/components/meter/index.js.map +1 -0
- package/dist/components/number-field/index.d.ts +3 -3
- package/dist/components/number-field/index.js +1 -9
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/product-icon/index.d.ts +2 -2
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +113 -0
- package/dist/components/progress-indicator/index.js +1024 -0
- package/dist/components/progress-indicator/index.js.map +1 -0
- package/dist/components/radio-group/index.d.ts +3 -3
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +3 -3
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +3 -3
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +120 -0
- package/dist/components/snackbar/index.js +540 -0
- package/dist/components/snackbar/index.js.map +1 -0
- package/dist/components/switch/index.d.ts +2 -2
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +3 -3
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/field/index.d.ts +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/form/index.d.ts +1 -1
- package/dist/form/index.js.map +1 -1
- package/dist/glyphs/hidden.js +13 -0
- package/dist/glyphs/hidden.js.map +1 -0
- package/dist/glyphs/index.js +2 -8
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +23 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/messages.js +41 -0
- package/dist/i18n/messages.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +7 -3
- package/dist/indicator/index.d.ts +15 -0
- package/dist/indicator/index.js +256 -0
- package/dist/indicator/index.js.map +1 -0
- package/dist/indicator/motion.js +86 -0
- package/dist/indicator/motion.js.map +1 -0
- package/dist/indicator/paths.js +72 -0
- package/dist/indicator/paths.js.map +1 -0
- package/dist/indicator/styles.js +62 -0
- package/dist/indicator/styles.js.map +1 -0
- package/dist/mark/index.d.ts +1 -1
- package/dist/mark/index.js.map +1 -1
- package/dist/number/locale.js +14 -0
- package/dist/number/locale.js.map +1 -0
- package/dist/overlay/host.js +65 -2
- package/dist/overlay/host.js.map +1 -1
- package/dist/press/index.js +63 -63
- package/dist/press/index.js.map +1 -1
- package/dist/theme/resolve.js +1 -1
- package/dist/theme/resolve.js.map +1 -1
- package/package.json +11 -11
|
@@ -4,9 +4,10 @@ import { composeStyles, themedStyles } from "../../theme/styles.js";
|
|
|
4
4
|
import { useTypeRole } from "../../typography/roles.js";
|
|
5
5
|
import { AnimatedPressable, HEIGHTS, OUTLINE_WIDTHS, PRESSED_CORNERS, buttonStyles, toggleState, useButtonAction, useCorner } from "../../button/index.js";
|
|
6
6
|
import { palettesOf } from "../../button/palettes.js";
|
|
7
|
+
import { BUSY, CONCEALED, PendingContent, PendingRing, pendingStyles, usePending } from "../../button/pending.js";
|
|
7
8
|
import { hitSlop, usePressFeedback } from "../../press/index.js";
|
|
8
9
|
import { c } from "react/compiler-runtime";
|
|
9
|
-
import { StyleSheet, Text } from "react-native";
|
|
10
|
+
import { StyleSheet, Text, useWindowDimensions } from "react-native";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import Animated from "react-native-reanimated";
|
|
12
13
|
//#region src/components/button/index.tsx
|
|
@@ -160,7 +161,7 @@ const outlinedSizesOf = themedStyles((theme) => {
|
|
|
160
161
|
* `style`, `ref` and `testID` land on the `Pressable`.
|
|
161
162
|
*/
|
|
162
163
|
function Button(t0) {
|
|
163
|
-
const $ = c(
|
|
164
|
+
const $ = c(73);
|
|
164
165
|
let children;
|
|
165
166
|
let defaultSelected;
|
|
166
167
|
let href;
|
|
@@ -172,20 +173,24 @@ function Button(t0) {
|
|
|
172
173
|
let onHoverIn;
|
|
173
174
|
let onHoverOut;
|
|
174
175
|
let onLayout;
|
|
176
|
+
let onLongPress;
|
|
175
177
|
let onPress;
|
|
176
178
|
let onPressIn;
|
|
177
179
|
let onPressOut;
|
|
178
180
|
let ownHitSlop;
|
|
181
|
+
let pendingLabel;
|
|
179
182
|
let props;
|
|
183
|
+
let slot;
|
|
180
184
|
let style;
|
|
181
185
|
let t1;
|
|
182
186
|
let t2;
|
|
183
187
|
let t3;
|
|
184
188
|
let t4;
|
|
185
189
|
let t5;
|
|
190
|
+
let t6;
|
|
186
191
|
let type;
|
|
187
192
|
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:
|
|
193
|
+
({children, defaultSelected, disableRipple: t1, hitSlop: ownHitSlop, href, icon, isDisabled: t2, isPending: t3, isSelected, onBlur, onChange, onFocus, onHoverIn, onHoverOut, onLayout, onLongPress, onPress, onPressIn, onPressOut, pendingLabel, shape: t4, size: t5, slot, style, type, variant: t6, ...props} = t0);
|
|
189
194
|
$[0] = t0;
|
|
190
195
|
$[1] = children;
|
|
191
196
|
$[2] = defaultSelected;
|
|
@@ -198,18 +203,22 @@ function Button(t0) {
|
|
|
198
203
|
$[9] = onHoverIn;
|
|
199
204
|
$[10] = onHoverOut;
|
|
200
205
|
$[11] = onLayout;
|
|
201
|
-
$[12] =
|
|
202
|
-
$[13] =
|
|
203
|
-
$[14] =
|
|
204
|
-
$[15] =
|
|
205
|
-
$[16] =
|
|
206
|
-
$[17] =
|
|
207
|
-
$[18] =
|
|
208
|
-
$[19] =
|
|
209
|
-
$[20] =
|
|
210
|
-
$[21] =
|
|
211
|
-
$[22] =
|
|
212
|
-
$[23] =
|
|
206
|
+
$[12] = onLongPress;
|
|
207
|
+
$[13] = onPress;
|
|
208
|
+
$[14] = onPressIn;
|
|
209
|
+
$[15] = onPressOut;
|
|
210
|
+
$[16] = ownHitSlop;
|
|
211
|
+
$[17] = pendingLabel;
|
|
212
|
+
$[18] = props;
|
|
213
|
+
$[19] = slot;
|
|
214
|
+
$[20] = style;
|
|
215
|
+
$[21] = t1;
|
|
216
|
+
$[22] = t2;
|
|
217
|
+
$[23] = t3;
|
|
218
|
+
$[24] = t4;
|
|
219
|
+
$[25] = t5;
|
|
220
|
+
$[26] = t6;
|
|
221
|
+
$[27] = type;
|
|
213
222
|
} else {
|
|
214
223
|
children = $[1];
|
|
215
224
|
defaultSelected = $[2];
|
|
@@ -222,48 +231,59 @@ function Button(t0) {
|
|
|
222
231
|
onHoverIn = $[9];
|
|
223
232
|
onHoverOut = $[10];
|
|
224
233
|
onLayout = $[11];
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
onLongPress = $[12];
|
|
235
|
+
onPress = $[13];
|
|
236
|
+
onPressIn = $[14];
|
|
237
|
+
onPressOut = $[15];
|
|
238
|
+
ownHitSlop = $[16];
|
|
239
|
+
pendingLabel = $[17];
|
|
240
|
+
props = $[18];
|
|
241
|
+
slot = $[19];
|
|
242
|
+
style = $[20];
|
|
243
|
+
t1 = $[21];
|
|
244
|
+
t2 = $[22];
|
|
245
|
+
t3 = $[23];
|
|
246
|
+
t4 = $[24];
|
|
247
|
+
t5 = $[25];
|
|
248
|
+
t6 = $[26];
|
|
249
|
+
type = $[27];
|
|
237
250
|
}
|
|
238
251
|
const disableRipple = t1 === void 0 ? false : t1;
|
|
239
252
|
const isDisabled = t2 === void 0 ? false : t2;
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
const
|
|
253
|
+
const isPending = t3 === void 0 ? false : t3;
|
|
254
|
+
const shape = t4 === void 0 ? "round" : t4;
|
|
255
|
+
const size = t5 === void 0 ? "md" : t5;
|
|
256
|
+
const variant = t6 === void 0 ? "filled" : t6;
|
|
243
257
|
const theme = useTheme();
|
|
244
258
|
const role = useTypeRole(ROLES[size]);
|
|
259
|
+
const { fontScale } = useWindowDimensions();
|
|
260
|
+
const pending = href === void 0 && isPending;
|
|
261
|
+
const ringLabel = usePending(pending, pendingLabel);
|
|
245
262
|
const isToggle = variant !== "text" && (defaultSelected !== void 0 || isSelected !== void 0 || onChange !== void 0);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
263
|
+
const t7 = slot ?? "default";
|
|
264
|
+
let t8;
|
|
265
|
+
if ($[28] !== defaultSelected || $[29] !== href || $[30] !== isSelected || $[31] !== isToggle || $[32] !== onChange || $[33] !== onPress || $[34] !== t7 || $[35] !== type) {
|
|
266
|
+
t8 = {
|
|
249
267
|
defaultSelected,
|
|
250
268
|
href,
|
|
251
269
|
isSelected,
|
|
252
270
|
isToggle,
|
|
253
271
|
onChange,
|
|
254
272
|
onPress,
|
|
273
|
+
slot: t7,
|
|
255
274
|
type
|
|
256
275
|
};
|
|
257
|
-
$[
|
|
258
|
-
$[
|
|
259
|
-
$[
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
265
|
-
|
|
266
|
-
|
|
276
|
+
$[28] = defaultSelected;
|
|
277
|
+
$[29] = href;
|
|
278
|
+
$[30] = isSelected;
|
|
279
|
+
$[31] = isToggle;
|
|
280
|
+
$[32] = onChange;
|
|
281
|
+
$[33] = onPress;
|
|
282
|
+
$[34] = t7;
|
|
283
|
+
$[35] = type;
|
|
284
|
+
$[36] = t8;
|
|
285
|
+
} else t8 = $[36];
|
|
286
|
+
const action = useButtonAction(t8);
|
|
267
287
|
const colors = palettesOf(theme)[isDisabled ? DISABLED[variant] : variant !== "text" && isToggle ? TOGGLE_PALETTES[variant][action.selected ? "selected" : "unselected"] : variant];
|
|
268
288
|
const feedback = usePressFeedback({
|
|
269
289
|
color: colors.content,
|
|
@@ -274,90 +294,118 @@ function Button(t0) {
|
|
|
274
294
|
onHoverIn,
|
|
275
295
|
onHoverOut,
|
|
276
296
|
onPressIn,
|
|
277
|
-
onPressOut
|
|
297
|
+
onPressOut,
|
|
298
|
+
pending
|
|
278
299
|
});
|
|
279
300
|
const { radii } = theme;
|
|
280
301
|
const resting = shape === "square" !== action.selected ? radii[SQUARE_CORNERS[size]] : radii.pill;
|
|
281
302
|
const shaped = useCorner(feedback.pressed ? radii[PRESSED_CORNERS[size]] : resting, onLayout);
|
|
282
303
|
const T0 = AnimatedPressable;
|
|
283
|
-
const
|
|
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;
|
|
304
|
+
const t9 = href === void 0 ? "button" : "link";
|
|
292
305
|
let t10;
|
|
293
|
-
if ($[
|
|
294
|
-
t10 =
|
|
295
|
-
$[
|
|
296
|
-
$[
|
|
297
|
-
$[
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
$[
|
|
307
|
-
$[
|
|
308
|
-
} else
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
306
|
+
if ($[37] !== action.selected || $[38] !== isToggle) {
|
|
307
|
+
t10 = isToggle ? toggleState(action.selected) : void 0;
|
|
308
|
+
$[37] = action.selected;
|
|
309
|
+
$[38] = isToggle;
|
|
310
|
+
$[39] = t10;
|
|
311
|
+
} else t10 = $[39];
|
|
312
|
+
const t11 = pending ? BUSY : void 0;
|
|
313
|
+
const t12 = feedback.handlers;
|
|
314
|
+
let t13;
|
|
315
|
+
if ($[40] !== ownHitSlop || $[41] !== size || $[42] !== theme.sizing) {
|
|
316
|
+
t13 = ownHitSlop ?? hitSlop(theme.sizing[HEIGHTS[size]]);
|
|
317
|
+
$[40] = ownHitSlop;
|
|
318
|
+
$[41] = size;
|
|
319
|
+
$[42] = theme.sizing;
|
|
320
|
+
$[43] = t13;
|
|
321
|
+
} else t13 = $[43];
|
|
322
|
+
const t14 = shaped.onLayout;
|
|
323
|
+
const t15 = pending ? void 0 : onLongPress;
|
|
324
|
+
const t16 = pending ? void 0 : action.onPress;
|
|
325
|
+
const t17 = 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);
|
|
326
|
+
let t18;
|
|
327
|
+
if ($[44] !== shaped.corner) {
|
|
328
|
+
t18 = composeStyles(buttonStyles.clip, shaped.corner);
|
|
329
|
+
$[44] = shaped.corner;
|
|
330
|
+
$[45] = t18;
|
|
331
|
+
} else t18 = $[45];
|
|
332
|
+
let t19;
|
|
333
|
+
if ($[46] !== feedback.layer || $[47] !== t18) {
|
|
334
|
+
t19 = /* @__PURE__ */ jsx(Animated.View, {
|
|
335
|
+
style: t18,
|
|
313
336
|
children: feedback.layer
|
|
314
337
|
});
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
} else
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
children:
|
|
338
|
+
$[46] = feedback.layer;
|
|
339
|
+
$[47] = t18;
|
|
340
|
+
$[48] = t19;
|
|
341
|
+
} else t19 = $[48];
|
|
342
|
+
const t20 = icon === void 0 ? null : /* @__PURE__ */ jsx(PendingContent, {
|
|
343
|
+
isPending: pending,
|
|
344
|
+
children: /* @__PURE__ */ jsx(IconStyleContext, {
|
|
345
|
+
value: iconStyleOf(colors.content, size),
|
|
346
|
+
children: icon
|
|
347
|
+
})
|
|
322
348
|
});
|
|
323
|
-
const
|
|
324
|
-
|
|
349
|
+
const t21 = children === void 0 ? null : /* @__PURE__ */ jsx(Text, {
|
|
350
|
+
...pending ? CONCEALED : void 0,
|
|
351
|
+
style: composeStyles(role, styles.label, colors.label, pending ? pendingStyles.hidden : void 0),
|
|
325
352
|
children
|
|
326
353
|
});
|
|
327
|
-
let
|
|
328
|
-
if ($[
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
354
|
+
let t22;
|
|
355
|
+
if ($[49] !== colors || $[50] !== fontScale || $[51] !== pending || $[52] !== ringLabel || $[53] !== size || $[54] !== theme.typography) {
|
|
356
|
+
t22 = pending ? /* @__PURE__ */ jsx(PendingRing, {
|
|
357
|
+
color: colors.content,
|
|
358
|
+
diameter: theme.typography[`${ROLES[size]}Size`] * fontScale,
|
|
359
|
+
label: ringLabel
|
|
360
|
+
}) : null;
|
|
361
|
+
$[49] = colors;
|
|
362
|
+
$[50] = fontScale;
|
|
363
|
+
$[51] = pending;
|
|
364
|
+
$[52] = ringLabel;
|
|
365
|
+
$[53] = size;
|
|
366
|
+
$[54] = theme.typography;
|
|
367
|
+
$[55] = t22;
|
|
368
|
+
} else t22 = $[55];
|
|
369
|
+
let t23;
|
|
370
|
+
if ($[56] !== T0 || $[57] !== feedback.handlers || $[58] !== isDisabled || $[59] !== props || $[60] !== shaped.onLayout || $[61] !== t10 || $[62] !== t11 || $[63] !== t13 || $[64] !== t15 || $[65] !== t16 || $[66] !== t17 || $[67] !== t19 || $[68] !== t20 || $[69] !== t21 || $[70] !== t22 || $[71] !== t9) {
|
|
371
|
+
t23 = /* @__PURE__ */ jsxs(T0, {
|
|
372
|
+
role: t9,
|
|
373
|
+
...t10,
|
|
374
|
+
...t11,
|
|
332
375
|
...props,
|
|
333
|
-
...
|
|
376
|
+
...t12,
|
|
334
377
|
disabled: isDisabled,
|
|
335
|
-
hitSlop:
|
|
336
|
-
onLayout:
|
|
337
|
-
|
|
338
|
-
|
|
378
|
+
hitSlop: t13,
|
|
379
|
+
onLayout: t14,
|
|
380
|
+
onLongPress: t15,
|
|
381
|
+
onPress: t16,
|
|
382
|
+
style: t17,
|
|
339
383
|
children: [
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
384
|
+
t19,
|
|
385
|
+
t20,
|
|
386
|
+
t21,
|
|
387
|
+
t22
|
|
343
388
|
]
|
|
344
389
|
});
|
|
345
|
-
$[
|
|
346
|
-
$[
|
|
347
|
-
$[
|
|
348
|
-
$[
|
|
349
|
-
$[
|
|
350
|
-
$[
|
|
351
|
-
$[
|
|
352
|
-
$[
|
|
353
|
-
$[
|
|
354
|
-
$[
|
|
355
|
-
$[
|
|
356
|
-
$[
|
|
357
|
-
$[
|
|
358
|
-
$[
|
|
359
|
-
|
|
360
|
-
|
|
390
|
+
$[56] = T0;
|
|
391
|
+
$[57] = feedback.handlers;
|
|
392
|
+
$[58] = isDisabled;
|
|
393
|
+
$[59] = props;
|
|
394
|
+
$[60] = shaped.onLayout;
|
|
395
|
+
$[61] = t10;
|
|
396
|
+
$[62] = t11;
|
|
397
|
+
$[63] = t13;
|
|
398
|
+
$[64] = t15;
|
|
399
|
+
$[65] = t16;
|
|
400
|
+
$[66] = t17;
|
|
401
|
+
$[67] = t19;
|
|
402
|
+
$[68] = t20;
|
|
403
|
+
$[69] = t21;
|
|
404
|
+
$[70] = t22;
|
|
405
|
+
$[71] = t9;
|
|
406
|
+
$[72] = t23;
|
|
407
|
+
} else t23 = $[72];
|
|
408
|
+
return t23;
|
|
361
409
|
}
|
|
362
410
|
function iconStyleOf(color, size) {
|
|
363
411
|
return {
|
|
@@ -1 +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;CACpD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EAAA,MAAA4B,SAAAa;EAAAzC,EAAA,MAAA/D;EAAA+D,EAAA,MAAAe;EAAAf,EAAA,MAAAmC,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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","PressableProps","StyleProp","TextStyle","View","ViewStyle","AnimatedStyle","Text","NativeText","StyleSheet","useWindowDimensions","Animated","ButtonLinkForm","ButtonPressForm","ButtonToggleForm","PaletteName","IconStyle","ResolvedTheme","TypeRole","AnimatedPressable","buttonStyles","HEIGHTS","OUTLINE_WIDTHS","PRESSED_CORNERS","toggleState","useButtonAction","useCorner","palettesOf","BUSY","CONCEALED","PendingContent","PendingRing","pendingStyles","usePending","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","onLongPress","onPress","onPressIn","onPressOut","ownHitSlop","pendingLabel","props","slot","t1","t2","t3","t4","t5","t6","type","isPending","undefined","role","fontScale","pending","ringLabel","isToggle","t7","t8","action","colors","feedback","color","content","disabled","radii","resting","pill","shaped","pressed","T0","t9","t10","t11","t12","handlers","t13","t14","t15","t16","t17","container","shadowOf","corner","ring","t18","clip","t19","layer","t20","iconStyleOf","t21","hidden","t22","typography","t23","hovered","lifted","_c","NativeText"],"sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import type { ComponentRef, 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 {\n Text as NativeText,\n StyleSheet,\n useWindowDimensions,\n} 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 {\n BUSY,\n CONCEALED,\n PendingContent,\n PendingRing,\n pendingStyles,\n usePending,\n} from '../../button/pending'\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// **A pending button keeps its place.** Given `isPending` the label and the\n// icon are hidden where they stand, so the button keeps its width, and an\n// indeterminate ring is drawn over them in the label's colour, at the label's\n// type size times the device's text size, which is what web's `1em` reads.\n// The button keeps its focus and its ring and takes no press, so a double tap\n// cannot run the action twice: neither `onPress` nor `onLongPress` is called,\n// and a toggle keeps its state until it clears. It reports itself busy, and\n// src/button's pending.tsx says the change out loud.\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<ComponentRef<typeof 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 isPending = false,\n isSelected,\n onBlur,\n onChange,\n onFocus,\n onHoverIn,\n onHoverOut,\n onLayout,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n pendingLabel,\n shape = 'round',\n size = 'md',\n slot,\n style,\n type,\n variant = 'filled',\n ...props\n}: ButtonProps) {\n const theme = useTheme()\n const role = useTypeRole(ROLES[size])\n const { fontScale } = useWindowDimensions()\n // A link is never pending, as on web, where its props have no such state.\n const pending = href === undefined && isPending\n const ringLabel = usePending(pending, pendingLabel)\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 slot: slot ?? 'default',\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 pending,\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 {...(pending ? BUSY : undefined)}\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n hitSlop={ownHitSlop ?? hitSlop(theme.sizing[HEIGHTS[size]])}\n onLayout={shaped.onLayout}\n onLongPress={pending ? undefined : onLongPress}\n onPress={pending ? undefined : 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 <PendingContent isPending={pending}>\n <IconStyleContext value={iconStyleOf(colors.content, size)}>\n {icon}\n </IconStyleContext>\n </PendingContent>\n )}\n {children === undefined ? null : (\n <NativeText\n {...(pending ? CONCEALED : undefined)}\n style={composeStyles<TextStyle>(\n role,\n styles.label,\n colors.label,\n pending ? pendingStyles.hidden : undefined,\n )}\n >\n {children}\n </NativeText>\n )}\n {pending ? (\n <PendingRing\n color={colors.content}\n diameter={theme.typography[`${ROLES[size]}Size`] * fontScale}\n label={ringLabel}\n />\n ) : null}\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":";;;;;;;;;;;;;AA+KA,MAAM4D,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;CACrBN,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,IAAI;CACJC,KAAK;AACP;AAGA,MAAMI,kBAKF;CACFd,UAAU;EAA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AA,MAAA/D;EAAA+D,EAAA,MAAAiB;EAAAjB,EAAA,MAAA4C,OAAAlC;EAAAV,EAAA,MAAAgD;EAAAhD,EAAA,MAAAiD;EAAAjD,EAAA,MAAAoD;EAAApD,EAAA,MAAAsD;EAAAtD,EAAA,MAAAuD;EAAAvD,EAAA,MAAAwD;EAAAxD,EAAA,MAAA+D;EAAA/D,EAAA,MAAAiE;EAAAjE,EAAA,MAAAmE;EAAAnE,EAAA,MAAAqE;EAAArE,EAAA,MAAA+C;EAAA/C,EAAA,MAAAuE;CAAA,OAAAA,MAAAvE,EAAA;CAAA,OAzDpBuE;AAyDoB;AAIxB,SAASL,YAAY5B,OAAejG,MAA6B;CAC/D,OAAO;EAAEiG;EAAOjG,MAAMY,WAAWZ;CAAM;AACzC;AAKA,SAASqH,SACPjI,SACA,EACE+I,SACA3B,WAEF5G,YACA8C,OACuB;CACvB,MAAM0F,SAASD,WAAW,CAAC3B;CAE3B,IAAI5G,YACF;CAGF,IAAIR,YAAY,YACd,OAAOgD,UAAUM,KAAK,CAAC,CAAC0F,SAAS,eAAe;CAGlD,QAAQhJ,YAAY,YAAYA,YAAY,YAAYgJ,SACpDhG,UAAUM,KAAK,CAAC,CAACJ,aACjBgD,KAAAA;AACN"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PressableProps, StyleProp, View, ViewProps, ViewStyle } from "react-native";
|
|
2
|
-
import { ReactNode, Ref } from "react";
|
|
2
|
+
import { ComponentRef, ReactNode, Ref } from "react";
|
|
3
3
|
//#region src/components/card/index.d.ts
|
|
4
4
|
type CardBaseProps = {
|
|
5
5
|
readonly children?: ReactNode;
|
|
@@ -17,7 +17,7 @@ type CardBaseProps = {
|
|
|
17
17
|
* @default 'default'
|
|
18
18
|
*/
|
|
19
19
|
readonly padding?: 'default' | 'none';
|
|
20
|
-
readonly ref?: Ref<View
|
|
20
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
21
21
|
readonly style?: StyleProp<ViewStyle>;
|
|
22
22
|
/**
|
|
23
23
|
* How the card separates itself from the page: `elevated` casts a shadow,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReactNode","Ref","PressableProps","StyleProp","ViewProps","ViewStyle","Pressable","StyleSheet","View","usePressFeedback","useLinkPress","withOpacity","useTheme","composeStyles","themedStyles","CardBaseProps","children","isDisabled","padding","ref","style","variant","CardVariant","CardProps","InteractiveCardForm","StaticCardForm","Omit","href","interactive","onPress","paddings","spacing","create","default","lg","none","stylesOf","colors","radii","shadows","base","borderRadius","md","overflow","elevated","backgroundColor","surfaceContainerLow","filled","surfaceContainerHighest","lifted","boxShadow","elevation2","outlined","surface","borderColor","outlineVariant","borderWidth","resting","elevation1","disabledStylesOf","stateLayerOpacity","content","opacity","disabledContent","outline","disabledContainer","styles","flexGrow","Card","props","$","_c","t0","InteractiveCard","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","t1","t2","t3","t4","t5","_interactive","t6","t7","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","undefined","theme","press","onSurface","color","disabled","feedback","T0","handlers","hovered","pressed","ring","own","layer","StaticCard","_isDisabled","_c"],"sources":["../../../src/components/card/index.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react'\nimport type {\n PressableProps,\n StyleProp,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport { Pressable, StyleSheet, View } from 'react-native'\n\nimport { usePressFeedback } from '../../press'\nimport { useLinkPress } from '../../router'\nimport { withOpacity } from '../../theme/color'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\n\n// The cards spec page's three variants, as kanso-ui's Card draws them. They\n// differ only in how they separate themselves from the page: elevated casts\n// the level 1 shadow over the low container, filled sits on the highest\n// container, and outlined draws an outline-variant rule over the surface. The\n// corner is the page's 12dp, the medium shape, and content runs 16dp in from\n// it unless `padding` is `none`.\n//\n// An interactive card draws the state layers, the ripple and the focus ring\n// from src/press, in on-surface, the colour web mixes over its container.\n// They lie over the card's content rather than under it, so a child that\n// fills the card, an image or a row with a fill of its own, still shows the\n// press. Under a pointer the elevated card rises to level 2 and settles back\n// to 1 while pressed, as the page and web have it, and switches at once, since\n// web's runs no transition either; the other two stay flat. A phone has no\n// pointer, so there the press itself is what shows.\n//\n// Disabled is the page's: each container at 38%, the outlined card's rule\n// in the outline role at 12%, what the card holds faded to 38%, and the\n// elevated card flat. A card's content is the call site's, so no colour role\n// reaches all of it, and an opacity is the one fade that does.\n\ntype CardBaseProps = {\n readonly children?: ReactNode\n /**\n * Turns an interactive card off: it fades as the cards page draws a\n * disabled card, and takes no press. It is still announced, as disabled.\n * Has no effect on a card that is not `interactive`, which cannot be\n * pressed to begin with.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * `none` removes the card's own padding, for a card whose children run to\n * its edges, such as a list of rows separated by rules.\n * @default 'default'\n */\n readonly padding?: 'default' | 'none'\n readonly ref?: Ref<View>\n readonly style?: StyleProp<ViewStyle>\n /**\n * How the card separates itself from the page: `elevated` casts a shadow,\n * `filled` sits on a darker surface, `outlined` draws a border.\n * @default 'elevated'\n */\n readonly variant?: CardVariant\n}\n\ntype CardProps = CardBaseProps & (InteractiveCardForm | StaticCardForm)\n\ntype CardVariant = 'elevated' | 'filled' | 'outlined'\n\n/**\n * A card that presses as a whole: a `Pressable` announced as a button, or as\n * a link given `href`.\n */\ntype InteractiveCardForm = Omit<\n PressableProps,\n 'children' | 'disabled' | 'style'\n> & {\n /**\n * Where the card leads. A press opens it through the `RouterProvider`\n * around the card, or through the platform for a URL with a scheme of its\n * own, after the call site's own `onPress`, and the card is announced as a\n * link.\n */\n readonly href?: string\n /**\n * Makes the card the thing you press: it ripples, draws the state layers,\n * lifts under a pointer and takes a focus ring. Leave it off for a card\n * that merely holds content, including one holding buttons of its own.\n */\n readonly interactive: true\n}\n\n/** A card that holds content and takes no press: a `View` with no role. */\ntype StaticCardForm = Omit<ViewProps, 'children' | 'style'> & {\n readonly href?: never\n readonly interactive?: false\n readonly onPress?: never\n}\n\nconst paddings = themedStyles(({ spacing }) =>\n StyleSheet.create({\n default: { padding: spacing.lg },\n none: { padding: 0 },\n }),\n)\n\nconst stylesOf = themedStyles(({ colors, radii, shadows }) =>\n StyleSheet.create({\n // The corner clips what the card holds, so a child running to the edges\n // is rounded with it. The shadow and the focus ring are drawn outside the\n // card and are not clipped.\n base: {\n borderRadius: radii.md,\n overflow: 'hidden',\n },\n elevated: {\n backgroundColor: colors.surfaceContainerLow,\n },\n filled: {\n backgroundColor: colors.surfaceContainerHighest,\n },\n // Under a pointer, the elevated card's level 2.\n lifted: {\n boxShadow: shadows.elevation2,\n },\n outlined: {\n backgroundColor: colors.surface,\n borderColor: colors.outlineVariant,\n borderWidth: 1,\n },\n // The elevated card's level 1, which no other variant casts.\n resting: {\n boxShadow: shadows.elevation1,\n },\n }),\n)\n\nconst disabledStylesOf = themedStyles(({ colors, stateLayerOpacity }) =>\n StyleSheet.create({\n content: {\n opacity: stateLayerOpacity.disabledContent,\n },\n elevated: {\n backgroundColor: withOpacity(\n colors.surfaceContainerLow,\n stateLayerOpacity.disabledContent,\n ),\n },\n filled: {\n backgroundColor: withOpacity(\n colors.surfaceContainerHighest,\n stateLayerOpacity.disabledContent,\n ),\n },\n outlined: {\n borderColor: withOpacity(\n colors.outline,\n stateLayerOpacity.disabledContainer,\n ),\n },\n }),\n)\n\nconst styles = StyleSheet.create({\n // What an interactive card's children sit in, filling a card stretched\n // taller than them, as a static card's children are laid out in the card\n // itself. It is what fades while disabled, apart from the container.\n content: {\n flexGrow: 1,\n },\n})\n\n/**\n * A surface holding related content.\n *\n * ```tsx\n * <Card interactive onPress={open}>\n * <Text variant=\"titleMedium\">Headline</Text>\n * </Card>\n * ```\n *\n * A card is a `View` with no role, unless it is `interactive`: then it is a\n * `Pressable` announced as a button, or as a link given `href`, which presses\n * as a whole. Web's `render` has no counterpart, since native has no element\n * to choose, and `href` is how a card leads somewhere instead. The press\n * props belong to an interactive card alone, so a static card given\n * `onPress` is a compile error rather than a press that never fires.\n *\n * A card fills the column it sits in, as any view in a React Native column\n * does. `style`, `ref` and `testID` land on the card's own view.\n */\nfunction Card(props: CardProps) {\n return props.interactive === true ? (\n <InteractiveCard {...props} />\n ) : (\n <StaticCard {...props} />\n )\n}\n\nfunction InteractiveCard({\n children,\n href,\n interactive: _interactive,\n isDisabled = false,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPress,\n onPressIn,\n onPressOut,\n padding = 'default',\n style,\n variant = 'elevated',\n ...props\n}: CardBaseProps & InteractiveCardForm) {\n const theme = useTheme()\n const press = useLinkPress(href, onPress)\n const feedback = usePressFeedback({\n color: theme.colors.onSurface,\n disabled: isDisabled,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n })\n\n const own = stylesOf(theme)\n const disabled = disabledStylesOf(theme)\n const lifted = feedback.hovered && !feedback.pressed\n\n return (\n <Pressable\n role={href === undefined ? 'button' : 'link'}\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n onPress={press}\n style={composeStyles<ViewStyle>(\n own.base,\n own[variant],\n paddings(theme)[padding],\n variant === 'elevated' && !isDisabled\n ? own[lifted ? 'lifted' : 'resting']\n : undefined,\n isDisabled && disabled[variant],\n feedback.ring,\n style,\n )}\n >\n <View\n style={composeStyles<ViewStyle>(\n styles.content,\n isDisabled && disabled.content,\n )}\n >\n {children}\n </View>\n {feedback.layer}\n </Pressable>\n )\n}\n\nfunction StaticCard({\n interactive: _interactive,\n isDisabled: _isDisabled,\n padding = 'default',\n style,\n variant = 'elevated',\n ...props\n}: CardBaseProps & StaticCardForm) {\n const theme = useTheme()\n const own = stylesOf(theme)\n\n return (\n <View\n {...props}\n style={composeStyles<ViewStyle>(\n own.base,\n own[variant],\n variant === 'elevated' ? own.resting : undefined,\n paddings(theme)[padding],\n style,\n )}\n />\n )\n}\n\nexport type { CardProps, CardVariant }\n\nexport { Card }\n"],"mappings":";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AApD;EAAAoD,EAAA,KAAAD;EAAAC,EAAA,KAAAlD;EAAAkD,EAAA,KAAA6B;EAAA7B,EAAA,KAAAjD;EAAAiD,EAAA,MAAAmC;EAAAnC,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;CAAA,OAAA;EAAAsB,KAAAnC,EAAA;EAAAY,KAAAZ,EAAA;EAAAa,KAAAb,EAAA;CAAA;CAAA,IAAAc;CAAA,IAAAd,EAAA,QAAAmC,MAAAnC,EAAA,QAAAY,MAAAZ,EAAA,QAAAa,IAAA;EARHC,KAAA,oBAAC,IAAD;GAAK,GACCf;GACG,OAAAc;EAMN,CAAA;EACDb,EAAA,MAAAmC;EAAAnC,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,OATFc;AASE"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","PressableProps","StyleProp","ViewProps","ViewStyle","Pressable","StyleSheet","View","usePressFeedback","useLinkPress","withOpacity","useTheme","composeStyles","themedStyles","CardBaseProps","children","isDisabled","padding","ref","style","variant","CardVariant","CardProps","InteractiveCardForm","StaticCardForm","Omit","href","interactive","onPress","paddings","spacing","create","default","lg","none","stylesOf","colors","radii","shadows","base","borderRadius","md","overflow","elevated","backgroundColor","surfaceContainerLow","filled","surfaceContainerHighest","lifted","boxShadow","elevation2","outlined","surface","borderColor","outlineVariant","borderWidth","resting","elevation1","disabledStylesOf","stateLayerOpacity","content","opacity","disabledContent","outline","disabledContainer","styles","flexGrow","Card","props","$","_c","t0","InteractiveCard","onBlur","onFocus","onHoverIn","onHoverOut","onPressIn","onPressOut","t1","t2","t3","t4","t5","_interactive","t6","t7","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","undefined","theme","press","onSurface","color","disabled","feedback","T0","handlers","hovered","pressed","ring","own","layer","StaticCard","_isDisabled","_c"],"sources":["../../../src/components/card/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n PressableProps,\n StyleProp,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport { Pressable, StyleSheet, View } from 'react-native'\n\nimport { usePressFeedback } from '../../press'\nimport { useLinkPress } from '../../router'\nimport { withOpacity } from '../../theme/color'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\n\n// The cards spec page's three variants, as kanso-ui's Card draws them. They\n// differ only in how they separate themselves from the page: elevated casts\n// the level 1 shadow over the low container, filled sits on the highest\n// container, and outlined draws an outline-variant rule over the surface. The\n// corner is the page's 12dp, the medium shape, and content runs 16dp in from\n// it unless `padding` is `none`.\n//\n// An interactive card draws the state layers, the ripple and the focus ring\n// from src/press, in on-surface, the colour web mixes over its container.\n// They lie over the card's content rather than under it, so a child that\n// fills the card, an image or a row with a fill of its own, still shows the\n// press. Under a pointer the elevated card rises to level 2 and settles back\n// to 1 while pressed, as the page and web have it, and switches at once, since\n// web's runs no transition either; the other two stay flat. A phone has no\n// pointer, so there the press itself is what shows.\n//\n// Disabled is the page's: each container at 38%, the outlined card's rule\n// in the outline role at 12%, what the card holds faded to 38%, and the\n// elevated card flat. A card's content is the call site's, so no colour role\n// reaches all of it, and an opacity is the one fade that does.\n\ntype CardBaseProps = {\n readonly children?: ReactNode\n /**\n * Turns an interactive card off: it fades as the cards page draws a\n * disabled card, and takes no press. It is still announced, as disabled.\n * Has no effect on a card that is not `interactive`, which cannot be\n * pressed to begin with.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * `none` removes the card's own padding, for a card whose children run to\n * its edges, such as a list of rows separated by rules.\n * @default 'default'\n */\n readonly padding?: 'default' | 'none'\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n /**\n * How the card separates itself from the page: `elevated` casts a shadow,\n * `filled` sits on a darker surface, `outlined` draws a border.\n * @default 'elevated'\n */\n readonly variant?: CardVariant\n}\n\ntype CardProps = CardBaseProps & (InteractiveCardForm | StaticCardForm)\n\ntype CardVariant = 'elevated' | 'filled' | 'outlined'\n\n/**\n * A card that presses as a whole: a `Pressable` announced as a button, or as\n * a link given `href`.\n */\ntype InteractiveCardForm = Omit<\n PressableProps,\n 'children' | 'disabled' | 'style'\n> & {\n /**\n * Where the card leads. A press opens it through the `RouterProvider`\n * around the card, or through the platform for a URL with a scheme of its\n * own, after the call site's own `onPress`, and the card is announced as a\n * link.\n */\n readonly href?: string\n /**\n * Makes the card the thing you press: it ripples, draws the state layers,\n * lifts under a pointer and takes a focus ring. Leave it off for a card\n * that merely holds content, including one holding buttons of its own.\n */\n readonly interactive: true\n}\n\n/** A card that holds content and takes no press: a `View` with no role. */\ntype StaticCardForm = Omit<ViewProps, 'children' | 'style'> & {\n readonly href?: never\n readonly interactive?: false\n readonly onPress?: never\n}\n\nconst paddings = themedStyles(({ spacing }) =>\n StyleSheet.create({\n default: { padding: spacing.lg },\n none: { padding: 0 },\n }),\n)\n\nconst stylesOf = themedStyles(({ colors, radii, shadows }) =>\n StyleSheet.create({\n // The corner clips what the card holds, so a child running to the edges\n // is rounded with it. The shadow and the focus ring are drawn outside the\n // card and are not clipped.\n base: {\n borderRadius: radii.md,\n overflow: 'hidden',\n },\n elevated: {\n backgroundColor: colors.surfaceContainerLow,\n },\n filled: {\n backgroundColor: colors.surfaceContainerHighest,\n },\n // Under a pointer, the elevated card's level 2.\n lifted: {\n boxShadow: shadows.elevation2,\n },\n outlined: {\n backgroundColor: colors.surface,\n borderColor: colors.outlineVariant,\n borderWidth: 1,\n },\n // The elevated card's level 1, which no other variant casts.\n resting: {\n boxShadow: shadows.elevation1,\n },\n }),\n)\n\nconst disabledStylesOf = themedStyles(({ colors, stateLayerOpacity }) =>\n StyleSheet.create({\n content: {\n opacity: stateLayerOpacity.disabledContent,\n },\n elevated: {\n backgroundColor: withOpacity(\n colors.surfaceContainerLow,\n stateLayerOpacity.disabledContent,\n ),\n },\n filled: {\n backgroundColor: withOpacity(\n colors.surfaceContainerHighest,\n stateLayerOpacity.disabledContent,\n ),\n },\n outlined: {\n borderColor: withOpacity(\n colors.outline,\n stateLayerOpacity.disabledContainer,\n ),\n },\n }),\n)\n\nconst styles = StyleSheet.create({\n // What an interactive card's children sit in, filling a card stretched\n // taller than them, as a static card's children are laid out in the card\n // itself. It is what fades while disabled, apart from the container.\n content: {\n flexGrow: 1,\n },\n})\n\n/**\n * A surface holding related content.\n *\n * ```tsx\n * <Card interactive onPress={open}>\n * <Text variant=\"titleMedium\">Headline</Text>\n * </Card>\n * ```\n *\n * A card is a `View` with no role, unless it is `interactive`: then it is a\n * `Pressable` announced as a button, or as a link given `href`, which presses\n * as a whole. Web's `render` has no counterpart, since native has no element\n * to choose, and `href` is how a card leads somewhere instead. The press\n * props belong to an interactive card alone, so a static card given\n * `onPress` is a compile error rather than a press that never fires.\n *\n * A card fills the column it sits in, as any view in a React Native column\n * does. `style`, `ref` and `testID` land on the card's own view.\n */\nfunction Card(props: CardProps) {\n return props.interactive === true ? (\n <InteractiveCard {...props} />\n ) : (\n <StaticCard {...props} />\n )\n}\n\nfunction InteractiveCard({\n children,\n href,\n interactive: _interactive,\n isDisabled = false,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPress,\n onPressIn,\n onPressOut,\n padding = 'default',\n style,\n variant = 'elevated',\n ...props\n}: CardBaseProps & InteractiveCardForm) {\n const theme = useTheme()\n const press = useLinkPress(href, onPress)\n const feedback = usePressFeedback({\n color: theme.colors.onSurface,\n disabled: isDisabled,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n })\n\n const own = stylesOf(theme)\n const disabled = disabledStylesOf(theme)\n const lifted = feedback.hovered && !feedback.pressed\n\n return (\n <Pressable\n role={href === undefined ? 'button' : 'link'}\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n onPress={press}\n style={composeStyles<ViewStyle>(\n own.base,\n own[variant],\n paddings(theme)[padding],\n variant === 'elevated' && !isDisabled\n ? own[lifted ? 'lifted' : 'resting']\n : undefined,\n isDisabled && disabled[variant],\n feedback.ring,\n style,\n )}\n >\n <View\n style={composeStyles<ViewStyle>(\n styles.content,\n isDisabled && disabled.content,\n )}\n >\n {children}\n </View>\n {feedback.layer}\n </Pressable>\n )\n}\n\nfunction StaticCard({\n interactive: _interactive,\n isDisabled: _isDisabled,\n padding = 'default',\n style,\n variant = 'elevated',\n ...props\n}: CardBaseProps & StaticCardForm) {\n const theme = useTheme()\n const own = stylesOf(theme)\n\n return (\n <View\n {...props}\n style={composeStyles<ViewStyle>(\n own.base,\n own[variant],\n variant === 'elevated' ? own.resting : undefined,\n paddings(theme)[padding],\n style,\n )}\n />\n )\n}\n\nexport type { CardProps, CardVariant }\n\nexport { Card }\n"],"mappings":";;;;;;;;;AAiGA,MAAM+B,WAAWhB,cAAc,EAAEiB,cAC/BxB,WAAWyB,OAAO;CAChBC,SAAS,EAAEf,SAASa,QAAQG,GAAG;CAC/BC,MAAM,EAAEjB,SAAS,EAAE;AACrB,CAAC,CACH;AAEA,MAAMkB,WAAWtB,cAAc,EAAEuB,QAAQC,OAAOC,cAC9ChC,WAAWyB,OAAO;CAIhBQ,MAAM;EACJC,cAAcH,MAAMI;EACpBC,UAAU;CACZ;CACAC,UAAU,EACRC,iBAAiBR,OAAOS,oBAC1B;CACAC,QAAQ,EACNF,iBAAiBR,OAAOW,wBAC1B;CAEAC,QAAQ,EACNC,WAAWX,QAAQY,WACrB;CACAC,UAAU;EACRP,iBAAiBR,OAAOgB;EACxBC,aAAajB,OAAOkB;EACpBC,aAAa;CACf;CAEAC,SAAS,EACPP,WAAWX,QAAQmB,WACrB;AACF,CAAC,CACH;AAEA,MAAMC,mBAAmB7C,cAAc,EAAEuB,QAAQuB,wBAC/CrD,WAAWyB,OAAO;CAChB6B,SAAS,EACPC,SAASF,kBAAkBG,gBAC7B;CACAnB,UAAU,EACRC,iBAAiBlC,YACf0B,OAAOS,qBACPc,kBAAkBG,eACpB,EACF;CACAhB,QAAQ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,YAAAlB;CAEA,MAAA3D,UAAA4D,OAAAiB,KAAAA,IAAA,aAAAjB;CAGA,MAAAkB,QAAcvF,SAAS;CAAC,IAAA6F;CAAA,IAAAvB;CAAA,IAAAC;CAAA,IAAAb,EAAA,OAAApD,WAAAoD,EAAA,OAAAD,SAAAC,EAAA,OAAAlD,SAAAkD,EAAA,OAAA6B,SAAA7B,EAAA,OAAAjD,SAAA;EACxB,MAAAyF,MAAY1E,SAAS+D,KAAK;EAGvBM,KAAAjG;EACK6D,KAAAA;EACGc,KAAAtE,cACLiG,IAAGtE,MACHsE,IAAIzF,UACJA,YAAY,aAAayF,IAAGrD,UAA5ByC,KAAAA,GACApE,SAASqE,KAAK,CAAC,CAACjF,UAChBE,KACF;EAACkD,EAAA,KAAApD;EAAAoD,EAAA,KAAAD;EAAAC,EAAA,KAAAlD;EAAAkD,EAAA,KAAA6B;EAAA7B,EAAA,KAAAjD;EAAAiD,EAAA,MAAAmC;EAAAnC,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;CAAA,OAAA;EAAAsB,KAAAnC,EAAA;EAAAY,KAAAZ,EAAA;EAAAa,KAAAb,EAAA;CAAA;CAAA,IAAAc;CAAA,IAAAd,EAAA,QAAAmC,MAAAnC,EAAA,QAAAY,MAAAZ,EAAA,QAAAa,IAAA;EARHC,KAAA,oBAAC,IAAD;GAAK,GACCf;GACG,OAAAc;EAMN,CAAA;EACDb,EAAA,MAAAmC;EAAAnC,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,OATFc;AASE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleProp, View, ViewProps, ViewStyle } from "react-native";
|
|
2
|
-
import { ReactNode, Ref } from "react";
|
|
2
|
+
import { ComponentRef, ReactNode, Ref } from "react";
|
|
3
3
|
//#region src/components/checkbox/index.d.ts
|
|
4
4
|
type CheckboxProps = Omit<ViewProps, 'children' | 'style'> & {
|
|
5
5
|
/**
|
|
@@ -47,7 +47,7 @@ type CheckboxProps = Omit<ViewProps, 'children' | 'style'> & {
|
|
|
47
47
|
readonly isSelected?: boolean;
|
|
48
48
|
/** Called with the new state whenever a press changes it. */
|
|
49
49
|
readonly onChange?: (isSelected: boolean) => void;
|
|
50
|
-
readonly ref?: Ref<View
|
|
50
|
+
readonly ref?: Ref<ComponentRef<typeof View>>;
|
|
51
51
|
readonly style?: StyleProp<ViewStyle>;
|
|
52
52
|
};
|
|
53
53
|
/**
|