@btndprojects/loam-ui-native 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 +21 -0
- package/dist/accordion/index.js +3 -0
- package/dist/adaptive/index.js +2 -0
- package/dist/alert/index.js +3 -0
- package/dist/analyzer/index.js +6 -0
- package/dist/announcement/index.js +6 -0
- package/dist/audio-player/index.js +3 -0
- package/dist/avatar/index.js +3 -0
- package/dist/avatar-group/index.js +3 -0
- package/dist/badge/index.js +5 -0
- package/dist/banner/index.js +2 -0
- package/dist/board/index.js +7 -0
- package/dist/button/index.js +5 -0
- package/dist/camera-permission/index.js +13 -0
- package/dist/capture-result/index.js +18 -0
- package/dist/card/index.js +4 -0
- package/dist/card-form/index.js +10 -0
- package/dist/carousel/index.js +2 -0
- package/dist/chart/index.js +6 -0
- package/dist/charts/index.js +7 -0
- package/dist/checkbox/index.js +7 -0
- package/dist/checklist/index.js +10 -0
- package/dist/checkout/index.js +13 -0
- package/dist/chip/index.js +7 -0
- package/dist/chunk-223Q2T2Q.js +229 -0
- package/dist/chunk-2A5NIQAK.js +254 -0
- package/dist/chunk-2GK6PHGE.js +363 -0
- package/dist/chunk-2WUTXHMU.js +1 -0
- package/dist/chunk-2ZZ7TDJ4.js +324 -0
- package/dist/chunk-35OFI3JG.js +499 -0
- package/dist/chunk-3ARE4TES.js +195 -0
- package/dist/chunk-3ECPOSKO.js +1 -0
- package/dist/chunk-3ENTMPQY.js +229 -0
- package/dist/chunk-3HJH6FF4.js +98 -0
- package/dist/chunk-3NMD74ZU.js +4 -0
- package/dist/chunk-3WPW4KUN.js +182 -0
- package/dist/chunk-47FWHGUN.js +394 -0
- package/dist/chunk-4BXMXBJO.js +141 -0
- package/dist/chunk-4DS5ZWVC.js +83 -0
- package/dist/chunk-4GBOGOTV.js +295 -0
- package/dist/chunk-4SZYY6AN.js +99 -0
- package/dist/chunk-4YIP3CWS.js +237 -0
- package/dist/chunk-4YQOR7JM.js +204 -0
- package/dist/chunk-4ZAHCY44.js +177 -0
- package/dist/chunk-52X2VYTD.js +228 -0
- package/dist/chunk-5P26LBDL.js +1 -0
- package/dist/chunk-5XLRYDAX.js +1 -0
- package/dist/chunk-5YNTNN5A.js +177 -0
- package/dist/chunk-66SG2H23.js +129 -0
- package/dist/chunk-6HT2LP62.js +504 -0
- package/dist/chunk-6N33LFQA.js +35 -0
- package/dist/chunk-6X6PQ443.js +432 -0
- package/dist/chunk-7CFF4HXS.js +126 -0
- package/dist/chunk-7O2FMUPT.js +755 -0
- package/dist/chunk-AI4DWZCD.js +162 -0
- package/dist/chunk-AWJOCGFZ.js +213 -0
- package/dist/chunk-AZRX6SAC.js +285 -0
- package/dist/chunk-B54QE2FN.js +1 -0
- package/dist/chunk-BC475SJH.js +1 -0
- package/dist/chunk-BEDBFJND.js +202 -0
- package/dist/chunk-BTTFCMKG.js +166 -0
- package/dist/chunk-BV3B2HYZ.js +1635 -0
- package/dist/chunk-C2NTXVWM.js +98 -0
- package/dist/chunk-CDRZHT42.js +424 -0
- package/dist/chunk-CJ5EOYZE.js +62 -0
- package/dist/chunk-CUMUNPXY.js +128 -0
- package/dist/chunk-CUS3ZSCU.js +1 -0
- package/dist/chunk-CYRBHQQZ.js +411 -0
- package/dist/chunk-DHWADYZX.js +144 -0
- package/dist/chunk-DKCSPATL.js +1 -0
- package/dist/chunk-DM5QUKKO.js +326 -0
- package/dist/chunk-DSJBXLUG.js +845 -0
- package/dist/chunk-DYBH2I6W.js +1 -0
- package/dist/chunk-DZ255O2F.js +1 -0
- package/dist/chunk-E35BPSGW.js +1 -0
- package/dist/chunk-EJBDRVIH.js +166 -0
- package/dist/chunk-F43NP42L.js +1 -0
- package/dist/chunk-F5XNPWS7.js +1024 -0
- package/dist/chunk-FIF2M24N.js +1521 -0
- package/dist/chunk-FOKG57CR.js +993 -0
- package/dist/chunk-G3HOYSF7.js +1 -0
- package/dist/chunk-GDKZTW34.js +395 -0
- package/dist/chunk-GL7B2DOW.js +134 -0
- package/dist/chunk-GNNJ4GCC.js +471 -0
- package/dist/chunk-GNZ56EUI.js +1 -0
- package/dist/chunk-H6NIOQHK.js +346 -0
- package/dist/chunk-H6PC7RDA.js +1 -0
- package/dist/chunk-HPPW424V.js +334 -0
- package/dist/chunk-HQOQIBJI.js +1 -0
- package/dist/chunk-HU2EQNRZ.js +44 -0
- package/dist/chunk-IIQTAY3J.js +715 -0
- package/dist/chunk-ITTYJZWX.js +271 -0
- package/dist/chunk-IVNRBPGC.js +1018 -0
- package/dist/chunk-J4KLDGI4.js +1 -0
- package/dist/chunk-J7Q7VCVC.js +254 -0
- package/dist/chunk-JDEOITQ2.js +1 -0
- package/dist/chunk-JNH2TYIN.js +96 -0
- package/dist/chunk-JRLTGLN4.js +1 -0
- package/dist/chunk-JTRJJLKL.js +1 -0
- package/dist/chunk-JUAMLEHX.js +379 -0
- package/dist/chunk-JXJB2X6M.js +131 -0
- package/dist/chunk-KMI5ML5I.js +262 -0
- package/dist/chunk-KTAC4MGE.js +4 -0
- package/dist/chunk-LAECSR4H.js +178 -0
- package/dist/chunk-LK4BCSGX.js +1 -0
- package/dist/chunk-LOE5YNN3.js +470 -0
- package/dist/chunk-LRJNDEIA.js +302 -0
- package/dist/chunk-LSS54GLJ.js +116 -0
- package/dist/chunk-LZLHELAG.js +137 -0
- package/dist/chunk-M2LUXGKZ.js +1 -0
- package/dist/chunk-MOUJOP55.js +425 -0
- package/dist/chunk-N32RGOA5.js +159 -0
- package/dist/chunk-N5ZNE2YE.js +1 -0
- package/dist/chunk-NBNCBML6.js +1 -0
- package/dist/chunk-NKB7BZYK.js +167 -0
- package/dist/chunk-NQYBUO3K.js +1795 -0
- package/dist/chunk-NY2U3PBI.js +59 -0
- package/dist/chunk-O4AEHWII.js +464 -0
- package/dist/chunk-O7AE6DAF.js +146 -0
- package/dist/chunk-OETCUXQP.js +134 -0
- package/dist/chunk-OOPPQH27.js +179 -0
- package/dist/chunk-OPXFZ4Y5.js +204 -0
- package/dist/chunk-P23EQNRQ.js +338 -0
- package/dist/chunk-PJXUJYS6.js +248 -0
- package/dist/chunk-PNWUWOBF.js +1 -0
- package/dist/chunk-PUPM2YGF.js +376 -0
- package/dist/chunk-PZXZJBMP.js +620 -0
- package/dist/chunk-Q72LJOVE.js +169 -0
- package/dist/chunk-QCDXZBC5.js +247 -0
- package/dist/chunk-QDYDBCFP.js +197 -0
- package/dist/chunk-QJJ6MADV.js +274 -0
- package/dist/chunk-QKXCPTFS.js +349 -0
- package/dist/chunk-QWCMU5B2.js +860 -0
- package/dist/chunk-RGQWWKLA.js +634 -0
- package/dist/chunk-RIBDXGUG.js +108 -0
- package/dist/chunk-RJQOOHT2.js +214 -0
- package/dist/chunk-RNGLIHFA.js +191 -0
- package/dist/chunk-RQ3HASCC.js +6 -0
- package/dist/chunk-RSOJT5YW.js +124 -0
- package/dist/chunk-RTIKSY6A.js +1 -0
- package/dist/chunk-RUZHTGKB.js +237 -0
- package/dist/chunk-RW6ZL2FQ.js +284 -0
- package/dist/chunk-S7F6XLTK.js +540 -0
- package/dist/chunk-SBMNWWBV.js +155 -0
- package/dist/chunk-SDTQPRRB.js +1 -0
- package/dist/chunk-SYNOJOQO.js +377 -0
- package/dist/chunk-T753XT36.js +1 -0
- package/dist/chunk-TKQYWZ5V.js +196 -0
- package/dist/chunk-TKVFVF5D.js +95 -0
- package/dist/chunk-TOXAGRDQ.js +144 -0
- package/dist/chunk-TUTI5HOZ.js +112 -0
- package/dist/chunk-U7TFM2JA.js +140 -0
- package/dist/chunk-UC2WGUP3.js +627 -0
- package/dist/chunk-UWFLYMAR.js +1126 -0
- package/dist/chunk-UWSZB7BJ.js +1 -0
- package/dist/chunk-UYG5L34B.js +87 -0
- package/dist/chunk-VBOXAEPI.js +336 -0
- package/dist/chunk-VCDBXW5H.js +188 -0
- package/dist/chunk-VCXPHHDS.js +1 -0
- package/dist/chunk-VEAYTRPX.js +414 -0
- package/dist/chunk-VFCUIDRT.js +1 -0
- package/dist/chunk-VQHPQEUH.js +273 -0
- package/dist/chunk-VXDZFJGP.js +874 -0
- package/dist/chunk-WS56BL3D.js +1 -0
- package/dist/chunk-WSW6ZFAQ.js +98 -0
- package/dist/chunk-WVKKJA6U.js +870 -0
- package/dist/chunk-XNUVB5OL.js +375 -0
- package/dist/chunk-XOSCY2CW.js +242 -0
- package/dist/chunk-XXXEFXY5.js +99 -0
- package/dist/chunk-Y5CSSPV4.js +1 -0
- package/dist/chunk-Y6DU4J47.js +1 -0
- package/dist/chunk-YC6WORFL.js +535 -0
- package/dist/chunk-YDGVJETP.js +60 -0
- package/dist/chunk-YF4NSSMT.js +366 -0
- package/dist/chunk-YG3ZJHGU.js +223 -0
- package/dist/chunk-YIJ55TBC.js +1 -0
- package/dist/chunk-YKZ4RZZF.js +1 -0
- package/dist/chunk-YLLCXTMC.js +37 -0
- package/dist/chunk-YTA74UZR.js +1 -0
- package/dist/chunk-Z7H7VSFZ.js +323 -0
- package/dist/chunk-ZK2H4O5P.js +1 -0
- package/dist/chunk-ZVFE5QGU.js +524 -0
- package/dist/coachmark/index.js +4 -0
- package/dist/code-block/index.js +4 -0
- package/dist/color-field/index.js +7 -0
- package/dist/commerce/index.js +20 -0
- package/dist/connectivity/index.js +2 -0
- package/dist/context-menu/index.js +5 -0
- package/dist/copy-button/index.js +3 -0
- package/dist/data-grid/index.js +24 -0
- package/dist/date-range-picker/index.js +13 -0
- package/dist/description-list/index.js +2 -0
- package/dist/dialog/index.js +3 -0
- package/dist/empty-state/index.js +3 -0
- package/dist/error-summary/index.js +3 -0
- package/dist/fab/index.js +2 -0
- package/dist/file-upload/index.js +9 -0
- package/dist/filter-bar/index.js +8 -0
- package/dist/flow-run/index.js +14 -0
- package/dist/form/index.js +3 -0
- package/dist/gallery/index.js +2 -0
- package/dist/header/index.js +5 -0
- package/dist/hold-to-confirm/index.js +4 -0
- package/dist/index.d.ts +22883 -0
- package/dist/index.js +158 -0
- package/dist/infinite-list/index.js +2 -0
- package/dist/inline-edit/index.js +5 -0
- package/dist/input/index.js +5 -0
- package/dist/interactions/index.js +2 -0
- package/dist/invoice/index.js +10 -0
- package/dist/kbd/index.js +1 -0
- package/dist/keyboard/index.js +3 -0
- package/dist/list-row/index.js +7 -0
- package/dist/log-viewer/index.js +2 -0
- package/dist/map-view/index.js +3 -0
- package/dist/markdown/index.js +6 -0
- package/dist/metric/index.js +4 -0
- package/dist/money/index.js +3 -0
- package/dist/nav-drawer/index.js +2 -0
- package/dist/navigation/index.js +2 -0
- package/dist/notification-center/index.js +16 -0
- package/dist/number-roll/index.js +3 -0
- package/dist/one-handed/index.js +5 -0
- package/dist/os-surfaces/index.js +3 -0
- package/dist/otp/index.js +7 -0
- package/dist/page-header/index.js +1 -0
- package/dist/payment-method/index.js +12 -0
- package/dist/payment-status/index.js +16 -0
- package/dist/permission/index.js +2 -0
- package/dist/picker/index.js +7 -0
- package/dist/progress/index.js +5 -0
- package/dist/pull-to-refresh/index.js +4 -0
- package/dist/radio-group/index.js +6 -0
- package/dist/rating/index.js +2 -0
- package/dist/receivables/index.js +20 -0
- package/dist/refund/index.js +16 -0
- package/dist/save-status/index.js +3 -0
- package/dist/scroll-area/index.js +1 -0
- package/dist/search-bar/index.js +5 -0
- package/dist/segmented-control/index.js +5 -0
- package/dist/sheet/index.js +4 -0
- package/dist/skeleton/index.js +2 -0
- package/dist/slider/index.js +5 -0
- package/dist/spinner/index.js +2 -0
- package/dist/split-button/index.js +7 -0
- package/dist/spotlight/index.js +2 -0
- package/dist/stage-timeline/index.js +4 -0
- package/dist/status-dot/index.js +2 -0
- package/dist/stepper/index.js +6 -0
- package/dist/streaming-text/index.js +3 -0
- package/dist/survey/index.js +19 -0
- package/dist/switch/index.js +5 -0
- package/dist/system-state/index.js +4 -0
- package/dist/tab-bar/index.js +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/textarea/index.js +6 -0
- package/dist/thinking/index.js +2 -0
- package/dist/timeline/index.js +4 -0
- package/dist/toast/index.js +2 -0
- package/dist/toolbar/index.js +2 -0
- package/dist/tour/index.js +11 -0
- package/dist/truncation-notice/index.js +2 -0
- package/dist/update-notice/index.js +11 -0
- package/dist/video-player/index.js +2 -0
- package/dist/viewfinder/index.js +5 -0
- package/dist/widget/index.js +4 -0
- package/dist/wizard/index.js +6 -0
- package/package.json +76 -3
- package/README.md +0 -3
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import { Thinking } from './chunk-XXXEFXY5.js';
|
|
2
|
+
import { Spinner } from './chunk-O7AE6DAF.js';
|
|
3
|
+
import { Icon } from './chunk-TKVFVF5D.js';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { StyleSheet, View, Text, Pressable } from 'react-native';
|
|
6
|
+
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
7
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var SYSTEM_STATE_META = {
|
|
10
|
+
"404": { tone: "muted", icon: "search", code: "404" },
|
|
11
|
+
"403": { tone: "warn", icon: "lock", code: "403" },
|
|
12
|
+
"500": { tone: "danger", icon: "alert-triangle", code: "500" },
|
|
13
|
+
maintenance: { tone: "warn", icon: "wrench", code: "Soon" },
|
|
14
|
+
offline: { tone: "info", icon: "wifi-off", code: "Offline" }
|
|
15
|
+
};
|
|
16
|
+
function useTone(tone) {
|
|
17
|
+
const theme = useLoamTheme();
|
|
18
|
+
switch (tone) {
|
|
19
|
+
case "danger":
|
|
20
|
+
return theme.color.dangerOnSoft;
|
|
21
|
+
case "warn":
|
|
22
|
+
return theme.color.warnOnSoft;
|
|
23
|
+
case "info":
|
|
24
|
+
return theme.color.infoOnSoft;
|
|
25
|
+
default:
|
|
26
|
+
return theme.color.text2;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function SystemState({
|
|
30
|
+
variant = "404",
|
|
31
|
+
code,
|
|
32
|
+
icon,
|
|
33
|
+
title,
|
|
34
|
+
description,
|
|
35
|
+
primaryLabel,
|
|
36
|
+
onPrimary,
|
|
37
|
+
secondaryLabel,
|
|
38
|
+
onSecondary,
|
|
39
|
+
errorId,
|
|
40
|
+
onCopyErrorId
|
|
41
|
+
}) {
|
|
42
|
+
const meta = SYSTEM_STATE_META[variant];
|
|
43
|
+
const { styles } = useStyles(sheet, { tone: meta.tone });
|
|
44
|
+
const theme = useLoamTheme();
|
|
45
|
+
const tone = useTone(meta.tone);
|
|
46
|
+
if (process.env.NODE_ENV !== "production" && !primaryLabel && !secondaryLabel) {
|
|
47
|
+
console.warn(
|
|
48
|
+
`[loam] <SystemState variant="${variant}"> has no action. Every system state must offer a route back to a working screen.`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.base, accessibilityRole: "alert", children: [
|
|
52
|
+
/* @__PURE__ */ jsxs(View, { style: styles.body, children: [
|
|
53
|
+
/* @__PURE__ */ jsx(View, { style: styles.tile, children: /* @__PURE__ */ jsx(Icon, { name: icon ?? meta.icon, size: theme.icon.xl, color: tone }) }),
|
|
54
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.code, { color: tone }], children: code ?? meta.code }),
|
|
55
|
+
/* @__PURE__ */ jsx(Text, { style: styles.title, children: title }),
|
|
56
|
+
description ? /* @__PURE__ */ jsx(Text, { style: styles.description, children: description }) : null,
|
|
57
|
+
errorId ? /* @__PURE__ */ jsxs(
|
|
58
|
+
Pressable,
|
|
59
|
+
{
|
|
60
|
+
accessibilityRole: "button",
|
|
61
|
+
accessibilityLabel: `Copy error id ${errorId}`,
|
|
62
|
+
onPress: onCopyErrorId ? () => onCopyErrorId(errorId) : void 0,
|
|
63
|
+
style: ({ pressed }) => [styles.errorChip, pressed && styles.pressed],
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Icon, { name: "copy", size: theme.icon.xs, color: theme.color.text2 }),
|
|
66
|
+
/* @__PURE__ */ jsx(Text, { style: styles.errorId, children: errorId })
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
) : null
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ jsxs(View, { style: styles.actions, children: [
|
|
72
|
+
primaryLabel ? /* @__PURE__ */ jsx(
|
|
73
|
+
Pressable,
|
|
74
|
+
{
|
|
75
|
+
accessibilityRole: "button",
|
|
76
|
+
accessibilityLabel: primaryLabel,
|
|
77
|
+
onPress: onPrimary,
|
|
78
|
+
style: ({ pressed }) => [styles.primary, pressed && styles.pressed],
|
|
79
|
+
children: /* @__PURE__ */ jsx(Text, { style: styles.primaryLabel, children: primaryLabel })
|
|
80
|
+
}
|
|
81
|
+
) : null,
|
|
82
|
+
secondaryLabel ? /* @__PURE__ */ jsx(
|
|
83
|
+
Pressable,
|
|
84
|
+
{
|
|
85
|
+
accessibilityRole: "button",
|
|
86
|
+
accessibilityLabel: secondaryLabel,
|
|
87
|
+
onPress: onSecondary,
|
|
88
|
+
style: ({ pressed }) => [styles.secondary, pressed && styles.pressed],
|
|
89
|
+
children: /* @__PURE__ */ jsx(Text, { style: styles.secondaryLabel, children: secondaryLabel })
|
|
90
|
+
}
|
|
91
|
+
) : null
|
|
92
|
+
] })
|
|
93
|
+
] });
|
|
94
|
+
}
|
|
95
|
+
var sheet = createStyleSheet((theme) => ({
|
|
96
|
+
base: {
|
|
97
|
+
flex: 1,
|
|
98
|
+
padding: theme.space.s5,
|
|
99
|
+
gap: theme.space.s5,
|
|
100
|
+
backgroundColor: theme.color.bg,
|
|
101
|
+
justifyContent: "space-between"
|
|
102
|
+
},
|
|
103
|
+
body: {
|
|
104
|
+
flex: 1,
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
justifyContent: "center",
|
|
107
|
+
gap: theme.space.s3
|
|
108
|
+
},
|
|
109
|
+
// The tone tile: a soft tint plus an `edge` outline. At normal contrast the
|
|
110
|
+
// edge is transparent; under high contrast the tint collapses to the surface
|
|
111
|
+
// and the outline is what carries the meaning.
|
|
112
|
+
tile: {
|
|
113
|
+
width: theme.space.s8 + theme.space.s3,
|
|
114
|
+
height: theme.space.s8 + theme.space.s3,
|
|
115
|
+
borderRadius: theme.radius.full,
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
justifyContent: "center",
|
|
118
|
+
borderWidth: theme.borderWidth.base,
|
|
119
|
+
variants: {
|
|
120
|
+
tone: {
|
|
121
|
+
muted: { backgroundColor: theme.color.surface2, borderColor: theme.edge.neutral },
|
|
122
|
+
danger: { backgroundColor: theme.color.dangerSoft, borderColor: theme.edge.danger },
|
|
123
|
+
warn: { backgroundColor: theme.color.warnSoft, borderColor: theme.edge.warn },
|
|
124
|
+
info: { backgroundColor: theme.color.infoSoft, borderColor: theme.edge.info }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
code: {
|
|
129
|
+
fontFamily: theme.font.mono,
|
|
130
|
+
fontSize: theme.type.caption2.fontSize,
|
|
131
|
+
lineHeight: theme.type.caption2.lineHeight,
|
|
132
|
+
// `tracking` steps are `em` multiples, so they have to be multiplied by the
|
|
133
|
+
// size — the previous literal was the same value written out by hand.
|
|
134
|
+
letterSpacing: theme.type.caption2.fontSize * theme.tracking.caps,
|
|
135
|
+
textTransform: "uppercase"
|
|
136
|
+
},
|
|
137
|
+
// `type.title2`, not a hand-written 24/1.15: 24 is not a step on either ramp
|
|
138
|
+
// and the ratio was a raw multiplier rather than a `lineHeight` token.
|
|
139
|
+
title: {
|
|
140
|
+
fontFamily: theme.font.display,
|
|
141
|
+
fontWeight: theme.font.displayWeight,
|
|
142
|
+
fontSize: theme.type.title2.fontSize,
|
|
143
|
+
lineHeight: theme.type.title2.lineHeight,
|
|
144
|
+
letterSpacing: theme.type.title2.letterSpacing,
|
|
145
|
+
color: theme.color.text,
|
|
146
|
+
textAlign: "center"
|
|
147
|
+
},
|
|
148
|
+
description: {
|
|
149
|
+
fontFamily: theme.font.sans,
|
|
150
|
+
fontSize: theme.type.subheadline.fontSize,
|
|
151
|
+
lineHeight: theme.type.subheadline.lineHeight,
|
|
152
|
+
color: theme.color.text2,
|
|
153
|
+
textAlign: "center"
|
|
154
|
+
},
|
|
155
|
+
errorChip: {
|
|
156
|
+
flexDirection: "row",
|
|
157
|
+
alignItems: "center",
|
|
158
|
+
gap: theme.space.s2,
|
|
159
|
+
minHeight: theme.tapMin,
|
|
160
|
+
paddingHorizontal: theme.space.s3,
|
|
161
|
+
borderRadius: theme.radius.md,
|
|
162
|
+
borderWidth: theme.borderWidth.base,
|
|
163
|
+
borderColor: theme.color.border,
|
|
164
|
+
backgroundColor: theme.color.surface2
|
|
165
|
+
},
|
|
166
|
+
errorId: {
|
|
167
|
+
fontFamily: theme.font.mono,
|
|
168
|
+
fontSize: theme.type.footnote.fontSize,
|
|
169
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
170
|
+
color: theme.color.text2
|
|
171
|
+
},
|
|
172
|
+
actions: { gap: theme.space.s3 },
|
|
173
|
+
primary: {
|
|
174
|
+
minHeight: theme.tapMin,
|
|
175
|
+
alignItems: "center",
|
|
176
|
+
justifyContent: "center",
|
|
177
|
+
borderRadius: theme.radius.md,
|
|
178
|
+
backgroundColor: theme.color.accent,
|
|
179
|
+
paddingHorizontal: theme.space.s4
|
|
180
|
+
},
|
|
181
|
+
primaryLabel: {
|
|
182
|
+
fontFamily: theme.font.sans,
|
|
183
|
+
fontWeight: theme.fontWeight.bold,
|
|
184
|
+
fontSize: theme.type.subheadline.fontSize,
|
|
185
|
+
lineHeight: theme.type.subheadline.lineHeight,
|
|
186
|
+
color: theme.color.accentInk
|
|
187
|
+
},
|
|
188
|
+
secondary: {
|
|
189
|
+
minHeight: theme.tapMin,
|
|
190
|
+
alignItems: "center",
|
|
191
|
+
justifyContent: "center",
|
|
192
|
+
borderRadius: theme.radius.md,
|
|
193
|
+
borderWidth: theme.borderWidth.strong,
|
|
194
|
+
borderColor: theme.color.borderStrong,
|
|
195
|
+
paddingHorizontal: theme.space.s4
|
|
196
|
+
},
|
|
197
|
+
secondaryLabel: {
|
|
198
|
+
fontFamily: theme.font.sans,
|
|
199
|
+
fontWeight: theme.fontWeight.semibold,
|
|
200
|
+
fontSize: theme.type.subheadline.fontSize,
|
|
201
|
+
lineHeight: theme.type.subheadline.lineHeight,
|
|
202
|
+
color: theme.color.text
|
|
203
|
+
},
|
|
204
|
+
pressed: { opacity: theme.state.pressedOpacity }
|
|
205
|
+
}));
|
|
206
|
+
function useLoadingFloor(active, floor) {
|
|
207
|
+
const [shown, setShown] = React.useState(false);
|
|
208
|
+
const shownAt = React.useRef(null);
|
|
209
|
+
React.useEffect(() => {
|
|
210
|
+
if (active && !shown) {
|
|
211
|
+
const t = setTimeout(() => {
|
|
212
|
+
shownAt.current = Date.now();
|
|
213
|
+
setShown(true);
|
|
214
|
+
}, floor);
|
|
215
|
+
return () => clearTimeout(t);
|
|
216
|
+
}
|
|
217
|
+
if (!active && shown) {
|
|
218
|
+
const elapsed = shownAt.current == null ? floor : Date.now() - shownAt.current;
|
|
219
|
+
const remaining = Math.max(0, floor - elapsed);
|
|
220
|
+
if (remaining === 0) {
|
|
221
|
+
shownAt.current = null;
|
|
222
|
+
setShown(false);
|
|
223
|
+
return void 0;
|
|
224
|
+
}
|
|
225
|
+
const t = setTimeout(() => {
|
|
226
|
+
shownAt.current = null;
|
|
227
|
+
setShown(false);
|
|
228
|
+
}, remaining);
|
|
229
|
+
return () => clearTimeout(t);
|
|
230
|
+
}
|
|
231
|
+
return void 0;
|
|
232
|
+
}, [active, shown, floor]);
|
|
233
|
+
return shown;
|
|
234
|
+
}
|
|
235
|
+
function useLate(active, after) {
|
|
236
|
+
const [late, setLate] = React.useState(false);
|
|
237
|
+
React.useEffect(() => {
|
|
238
|
+
if (!active) {
|
|
239
|
+
setLate(false);
|
|
240
|
+
return void 0;
|
|
241
|
+
}
|
|
242
|
+
const t = setTimeout(() => setLate(true), after);
|
|
243
|
+
return () => clearTimeout(t);
|
|
244
|
+
}, [active, after]);
|
|
245
|
+
return late;
|
|
246
|
+
}
|
|
247
|
+
function AreaState({
|
|
248
|
+
state = "idle",
|
|
249
|
+
children,
|
|
250
|
+
minHeight = 160,
|
|
251
|
+
loadingContent,
|
|
252
|
+
loadingLabel = "Loading",
|
|
253
|
+
lateLabel = "Still working\u2026",
|
|
254
|
+
loadingFloor,
|
|
255
|
+
lateAfter,
|
|
256
|
+
empty,
|
|
257
|
+
error,
|
|
258
|
+
errorTitle = "Couldn\u2019t load this",
|
|
259
|
+
errorDescription,
|
|
260
|
+
retryLabel = "Try again",
|
|
261
|
+
onRetry,
|
|
262
|
+
staleLabel,
|
|
263
|
+
refreshLabel = "Refresh",
|
|
264
|
+
onRefresh,
|
|
265
|
+
refreshing = false,
|
|
266
|
+
idle,
|
|
267
|
+
motion = "full"
|
|
268
|
+
}) {
|
|
269
|
+
const theme = useLoamTheme();
|
|
270
|
+
const { styles } = useStyles(areaSheet);
|
|
271
|
+
const floor = loadingFloor ?? theme.timing.loadingFloor;
|
|
272
|
+
const lateMs = lateAfter ?? theme.timing.lateAfter;
|
|
273
|
+
const isLoading = state === "loading";
|
|
274
|
+
const showLoading = useLoadingFloor(isLoading, floor);
|
|
275
|
+
const late = useLate(isLoading, lateMs);
|
|
276
|
+
const busy = isLoading || showLoading;
|
|
277
|
+
const loadingView = /* @__PURE__ */ jsxs(View, { style: styles.center, children: [
|
|
278
|
+
loadingContent ?? /* @__PURE__ */ jsx(Spinner, { size: "lg", accessibilityLabel: loadingLabel, motion }),
|
|
279
|
+
late ? (
|
|
280
|
+
// The late escalation is the `thinking` recipe's loading label: a gently
|
|
281
|
+
// pulsing "Still working…" line (its own polite live region announces the
|
|
282
|
+
// escalation). Reduced motion holds it solid — the text still carries it.
|
|
283
|
+
/* @__PURE__ */ jsx(Thinking, { label: lateLabel, tone: "neutral", size: "sm", motion })
|
|
284
|
+
) : null
|
|
285
|
+
] });
|
|
286
|
+
const errorView = error ?? /* @__PURE__ */ jsxs(View, { accessibilityRole: "alert", style: styles.center, children: [
|
|
287
|
+
/* @__PURE__ */ jsx(View, { style: styles.errorTile, children: /* @__PURE__ */ jsx(Icon, { name: "alert-triangle", size: theme.icon.lg, color: theme.color.dangerOnSoft }) }),
|
|
288
|
+
/* @__PURE__ */ jsx(Text, { style: styles.errorTitle, children: errorTitle }),
|
|
289
|
+
errorDescription ? /* @__PURE__ */ jsx(Text, { style: styles.errorBody, children: errorDescription }) : null,
|
|
290
|
+
onRetry ? /* @__PURE__ */ jsxs(
|
|
291
|
+
Pressable,
|
|
292
|
+
{
|
|
293
|
+
accessibilityRole: "button",
|
|
294
|
+
accessibilityLabel: retryLabel,
|
|
295
|
+
onPress: onRetry,
|
|
296
|
+
style: ({ pressed }) => [styles.retry, pressed && styles.pressed],
|
|
297
|
+
children: [
|
|
298
|
+
/* @__PURE__ */ jsx(Icon, { name: "refresh", size: theme.icon.sm, color: theme.color.accentInk }),
|
|
299
|
+
/* @__PURE__ */ jsx(Text, { style: styles.retryLabel, children: retryLabel })
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
) : null
|
|
303
|
+
] });
|
|
304
|
+
let body;
|
|
305
|
+
if (showLoading) {
|
|
306
|
+
body = loadingView;
|
|
307
|
+
} else {
|
|
308
|
+
switch (state) {
|
|
309
|
+
case "loading":
|
|
310
|
+
body = /* @__PURE__ */ jsx(View, { style: styles.fill });
|
|
311
|
+
break;
|
|
312
|
+
case "empty":
|
|
313
|
+
body = empty ?? /* @__PURE__ */ jsx(View, { style: styles.center, children: /* @__PURE__ */ jsx(Text, { style: styles.errorBody, children: "Nothing here yet." }) });
|
|
314
|
+
break;
|
|
315
|
+
case "error":
|
|
316
|
+
body = errorView;
|
|
317
|
+
break;
|
|
318
|
+
case "stale":
|
|
319
|
+
body = /* @__PURE__ */ jsxs(View, { style: styles.fill, children: [
|
|
320
|
+
/* @__PURE__ */ jsx(View, { style: styles.fill, children }),
|
|
321
|
+
/* @__PURE__ */ jsx(
|
|
322
|
+
View,
|
|
323
|
+
{
|
|
324
|
+
style: styles.staleScrim,
|
|
325
|
+
accessibilityElementsHidden: true,
|
|
326
|
+
importantForAccessibility: "no-hide-descendants"
|
|
327
|
+
}
|
|
328
|
+
),
|
|
329
|
+
/* @__PURE__ */ jsxs(View, { style: styles.staleBanner, children: [
|
|
330
|
+
/* @__PURE__ */ jsx(Icon, { name: "clock", size: theme.icon.xs, color: theme.color.text2 }),
|
|
331
|
+
staleLabel ? /* @__PURE__ */ jsx(Text, { style: styles.staleText, numberOfLines: 1, children: staleLabel }) : null,
|
|
332
|
+
onRefresh ? /* @__PURE__ */ jsxs(
|
|
333
|
+
Pressable,
|
|
334
|
+
{
|
|
335
|
+
accessibilityRole: "button",
|
|
336
|
+
accessibilityLabel: refreshing ? `${refreshLabel}\u2026` : refreshLabel,
|
|
337
|
+
accessibilityState: { busy: refreshing, disabled: refreshing },
|
|
338
|
+
disabled: refreshing,
|
|
339
|
+
onPress: refreshing ? void 0 : onRefresh,
|
|
340
|
+
style: ({ pressed }) => [styles.refresh, pressed && styles.pressed],
|
|
341
|
+
children: [
|
|
342
|
+
refreshing ? /* @__PURE__ */ jsx(Spinner, { size: "sm", accessibilityLabel: `${refreshLabel}\u2026` }) : /* @__PURE__ */ jsx(Icon, { name: "refresh", size: theme.icon.xs, color: theme.color.text }),
|
|
343
|
+
/* @__PURE__ */ jsx(Text, { style: styles.refreshLabel, children: refreshLabel })
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
) : null
|
|
347
|
+
] })
|
|
348
|
+
] });
|
|
349
|
+
break;
|
|
350
|
+
case "ready":
|
|
351
|
+
body = children;
|
|
352
|
+
break;
|
|
353
|
+
case "idle":
|
|
354
|
+
default:
|
|
355
|
+
body = idle ?? /* @__PURE__ */ jsx(View, { style: styles.fill });
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return /* @__PURE__ */ jsx(
|
|
360
|
+
View,
|
|
361
|
+
{
|
|
362
|
+
style: [styles.base, { minHeight }],
|
|
363
|
+
accessibilityLiveRegion: "polite",
|
|
364
|
+
"aria-busy": busy,
|
|
365
|
+
accessibilityState: { busy },
|
|
366
|
+
...{ "aria-live": "polite" },
|
|
367
|
+
children: body
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
var areaSheet = createStyleSheet((theme) => ({
|
|
372
|
+
base: {
|
|
373
|
+
position: "relative",
|
|
374
|
+
backgroundColor: theme.color.surface,
|
|
375
|
+
borderRadius: theme.radius.lg
|
|
376
|
+
},
|
|
377
|
+
fill: { flex: 1 },
|
|
378
|
+
center: {
|
|
379
|
+
flex: 1,
|
|
380
|
+
alignItems: "center",
|
|
381
|
+
justifyContent: "center",
|
|
382
|
+
gap: theme.space.s3,
|
|
383
|
+
padding: theme.space.s5
|
|
384
|
+
},
|
|
385
|
+
latePill: {
|
|
386
|
+
alignSelf: "center",
|
|
387
|
+
flexDirection: "row",
|
|
388
|
+
alignItems: "center",
|
|
389
|
+
backgroundColor: theme.color.warnSoft,
|
|
390
|
+
borderColor: theme.edge.warn,
|
|
391
|
+
borderWidth: theme.borderWidth.base,
|
|
392
|
+
borderRadius: theme.radius.full,
|
|
393
|
+
paddingHorizontal: theme.space.s2,
|
|
394
|
+
paddingVertical: theme.space[2]
|
|
395
|
+
},
|
|
396
|
+
lateText: {
|
|
397
|
+
fontFamily: theme.font.sans,
|
|
398
|
+
color: theme.color.warnOnSoft,
|
|
399
|
+
fontSize: theme.type.caption1.fontSize,
|
|
400
|
+
lineHeight: theme.type.caption1.lineHeight,
|
|
401
|
+
letterSpacing: theme.type.caption1.letterSpacing
|
|
402
|
+
},
|
|
403
|
+
errorTile: {
|
|
404
|
+
width: theme.space.s7,
|
|
405
|
+
height: theme.space.s7,
|
|
406
|
+
borderRadius: theme.radius.full,
|
|
407
|
+
alignItems: "center",
|
|
408
|
+
justifyContent: "center",
|
|
409
|
+
borderWidth: theme.borderWidth.base,
|
|
410
|
+
backgroundColor: theme.color.dangerSoft,
|
|
411
|
+
borderColor: theme.edge.danger
|
|
412
|
+
},
|
|
413
|
+
errorTitle: {
|
|
414
|
+
fontFamily: theme.font.display,
|
|
415
|
+
fontWeight: theme.font.displayWeight,
|
|
416
|
+
fontSize: theme.type.headline.fontSize,
|
|
417
|
+
lineHeight: theme.type.headline.lineHeight,
|
|
418
|
+
letterSpacing: theme.type.headline.letterSpacing,
|
|
419
|
+
color: theme.color.text,
|
|
420
|
+
textAlign: "center"
|
|
421
|
+
},
|
|
422
|
+
errorBody: {
|
|
423
|
+
fontFamily: theme.font.sans,
|
|
424
|
+
fontSize: theme.type.subheadline.fontSize,
|
|
425
|
+
lineHeight: theme.type.subheadline.lineHeight,
|
|
426
|
+
color: theme.color.text2,
|
|
427
|
+
textAlign: "center"
|
|
428
|
+
},
|
|
429
|
+
retry: {
|
|
430
|
+
flexDirection: "row",
|
|
431
|
+
alignItems: "center",
|
|
432
|
+
gap: theme.space.s2,
|
|
433
|
+
minHeight: theme.tapMin,
|
|
434
|
+
paddingHorizontal: theme.space.s4,
|
|
435
|
+
borderRadius: theme.radius.md,
|
|
436
|
+
backgroundColor: theme.color.accent
|
|
437
|
+
},
|
|
438
|
+
retryLabel: {
|
|
439
|
+
fontFamily: theme.font.sans,
|
|
440
|
+
fontWeight: theme.fontWeight.bold,
|
|
441
|
+
fontSize: theme.type.subheadline.fontSize,
|
|
442
|
+
lineHeight: theme.type.subheadline.lineHeight,
|
|
443
|
+
color: theme.color.accentInk
|
|
444
|
+
},
|
|
445
|
+
// A translucent surface wash — dims the stale content without touching the
|
|
446
|
+
// text's own contrast, and without blocking taps (`pointerEvents: none`).
|
|
447
|
+
staleScrim: {
|
|
448
|
+
...StyleSheet.absoluteFillObject,
|
|
449
|
+
backgroundColor: theme.color.surface,
|
|
450
|
+
opacity: theme.opacity[48],
|
|
451
|
+
pointerEvents: "none",
|
|
452
|
+
borderRadius: theme.radius.lg
|
|
453
|
+
},
|
|
454
|
+
// The stale marker + refresh, floated at the top edge above the scrim on its
|
|
455
|
+
// own solid surface so its text keeps full AA contrast.
|
|
456
|
+
staleBanner: {
|
|
457
|
+
position: "absolute",
|
|
458
|
+
top: theme.space.s2,
|
|
459
|
+
start: theme.space.s2,
|
|
460
|
+
end: theme.space.s2,
|
|
461
|
+
flexDirection: "row",
|
|
462
|
+
alignItems: "center",
|
|
463
|
+
gap: theme.space.s2,
|
|
464
|
+
paddingHorizontal: theme.space.s3,
|
|
465
|
+
paddingVertical: theme.space.s1,
|
|
466
|
+
borderRadius: theme.radius.full,
|
|
467
|
+
borderWidth: theme.borderWidth.base,
|
|
468
|
+
borderColor: theme.color.border,
|
|
469
|
+
backgroundColor: theme.color.surface2
|
|
470
|
+
},
|
|
471
|
+
staleText: {
|
|
472
|
+
flex: 1,
|
|
473
|
+
fontFamily: theme.font.sans,
|
|
474
|
+
fontSize: theme.type.caption1.fontSize,
|
|
475
|
+
lineHeight: theme.type.caption1.lineHeight,
|
|
476
|
+
color: theme.color.text2
|
|
477
|
+
},
|
|
478
|
+
refresh: {
|
|
479
|
+
flexDirection: "row",
|
|
480
|
+
alignItems: "center",
|
|
481
|
+
gap: theme.space.s2,
|
|
482
|
+
minHeight: theme.tapMin,
|
|
483
|
+
paddingHorizontal: theme.space.s3,
|
|
484
|
+
borderRadius: theme.radius.full,
|
|
485
|
+
borderWidth: theme.borderWidth.base,
|
|
486
|
+
borderColor: theme.color.borderStrong,
|
|
487
|
+
backgroundColor: theme.color.surface
|
|
488
|
+
},
|
|
489
|
+
refreshLabel: {
|
|
490
|
+
fontFamily: theme.font.sans,
|
|
491
|
+
fontWeight: theme.fontWeight.semibold,
|
|
492
|
+
fontSize: theme.type.caption1.fontSize,
|
|
493
|
+
lineHeight: theme.type.caption1.lineHeight,
|
|
494
|
+
color: theme.color.text
|
|
495
|
+
},
|
|
496
|
+
pressed: { opacity: theme.state.pressedOpacity }
|
|
497
|
+
}));
|
|
498
|
+
|
|
499
|
+
export { AreaState, SYSTEM_STATE_META, SystemState };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { HoldToConfirm } from './chunk-AWJOCGFZ.js';
|
|
2
|
+
import { Icon } from './chunk-TKVFVF5D.js';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Animated, Pressable, ActivityIndicator, Text } from 'react-native';
|
|
5
|
+
import { createStyleSheet, useLoamTheme, useStyles } from '@btndprojects/loam-theme-native';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
function holdSizeFor(size) {
|
|
9
|
+
return size === "xs" ? "sm" : size;
|
|
10
|
+
}
|
|
11
|
+
function useForeground(variant, disabled) {
|
|
12
|
+
const theme = useLoamTheme();
|
|
13
|
+
if (disabled) return theme.color.text3;
|
|
14
|
+
switch (variant) {
|
|
15
|
+
case "primary":
|
|
16
|
+
return theme.color.accentInk;
|
|
17
|
+
case "tonal":
|
|
18
|
+
return theme.color.accentOnSoft;
|
|
19
|
+
// v2 on-inks: measured against the danger fill instead of assuming white.
|
|
20
|
+
case "danger":
|
|
21
|
+
return theme.color.dangerInk;
|
|
22
|
+
default:
|
|
23
|
+
return theme.color.text;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function Button({
|
|
27
|
+
children,
|
|
28
|
+
variant = "primary",
|
|
29
|
+
size = "md",
|
|
30
|
+
loading = false,
|
|
31
|
+
disabled = false,
|
|
32
|
+
fullWidth = false,
|
|
33
|
+
leadingIcon,
|
|
34
|
+
trailingIcon,
|
|
35
|
+
onPress,
|
|
36
|
+
accessibilityLabel,
|
|
37
|
+
motion = "full",
|
|
38
|
+
hold = false,
|
|
39
|
+
onConfirm,
|
|
40
|
+
holdDuration,
|
|
41
|
+
confirmingLabel
|
|
42
|
+
}) {
|
|
43
|
+
const theme = useLoamTheme();
|
|
44
|
+
const { styles } = useStyles(sheet, { variant, size, disabled, fullWidth });
|
|
45
|
+
const fg = useForeground(variant, disabled);
|
|
46
|
+
const scale = React.useRef(new Animated.Value(1)).current;
|
|
47
|
+
if (hold && variant === "danger") {
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
HoldToConfirm,
|
|
50
|
+
{
|
|
51
|
+
variant: "danger",
|
|
52
|
+
size: holdSizeFor(size),
|
|
53
|
+
fullWidth,
|
|
54
|
+
disabled,
|
|
55
|
+
leadingIcon,
|
|
56
|
+
motion,
|
|
57
|
+
duration: holdDuration,
|
|
58
|
+
confirmingLabel,
|
|
59
|
+
accessibilityLabel,
|
|
60
|
+
onConfirm: onConfirm ?? (() => {
|
|
61
|
+
}),
|
|
62
|
+
children
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
const busy = loading;
|
|
67
|
+
const interactive = !disabled && !busy;
|
|
68
|
+
const iconSize = theme.ctl.icon[size];
|
|
69
|
+
const slopY = Math.max(0, (theme.hit[size] - theme.ctl[size]) / 2);
|
|
70
|
+
const animatePress = motion === "full" && !theme.reduceMotion;
|
|
71
|
+
const spring = (to) => Animated.spring(scale, {
|
|
72
|
+
toValue: to,
|
|
73
|
+
useNativeDriver: true,
|
|
74
|
+
speed: 40,
|
|
75
|
+
bounciness: 6
|
|
76
|
+
}).start();
|
|
77
|
+
return /* @__PURE__ */ jsx(
|
|
78
|
+
Pressable,
|
|
79
|
+
{
|
|
80
|
+
accessibilityRole: "button",
|
|
81
|
+
accessibilityLabel,
|
|
82
|
+
accessibilityState: { disabled, busy },
|
|
83
|
+
disabled,
|
|
84
|
+
onPress: interactive ? onPress : void 0,
|
|
85
|
+
onPressIn: interactive && animatePress ? () => spring(0.97) : void 0,
|
|
86
|
+
onPressOut: interactive && animatePress ? () => spring(1) : void 0,
|
|
87
|
+
hitSlop: { top: slopY, bottom: slopY },
|
|
88
|
+
style: fullWidth ? fullWidthStyle : void 0,
|
|
89
|
+
children: /* @__PURE__ */ jsxs(Animated.View, { style: [styles.base, { transform: [{ scale }] }], children: [
|
|
90
|
+
loading ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: fg, accessibilityLabel: "Loading" }) : leadingIcon ? /* @__PURE__ */ jsx(Icon, { name: leadingIcon, size: iconSize, color: fg }) : null,
|
|
91
|
+
typeof children === "string" ? /* @__PURE__ */ jsx(Text, { style: [styles.label, { color: fg }], children }) : children,
|
|
92
|
+
!loading && trailingIcon ? /* @__PURE__ */ jsx(Icon, { name: trailingIcon, size: iconSize, color: fg }) : null
|
|
93
|
+
] })
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
var fullWidthStyle = { alignSelf: "stretch" };
|
|
98
|
+
var sheet = createStyleSheet((theme) => ({
|
|
99
|
+
base: {
|
|
100
|
+
flexDirection: "row",
|
|
101
|
+
alignItems: "center",
|
|
102
|
+
justifyContent: "center",
|
|
103
|
+
variants: {
|
|
104
|
+
variant: {
|
|
105
|
+
primary: { backgroundColor: theme.color.accent },
|
|
106
|
+
// `accentSoft` collapses to the plain surface under high contrast, which
|
|
107
|
+
// would leave a tonal button indistinguishable from a ghost one. The
|
|
108
|
+
// accent edge is what separates them there; it is `transparent` at
|
|
109
|
+
// normal contrast, and gives `tonal` the same bordered box as `outline`.
|
|
110
|
+
tonal: {
|
|
111
|
+
backgroundColor: theme.color.accentSoft,
|
|
112
|
+
borderWidth: theme.borderWidth.base,
|
|
113
|
+
borderColor: theme.edge.accent
|
|
114
|
+
},
|
|
115
|
+
outline: {
|
|
116
|
+
backgroundColor: "transparent",
|
|
117
|
+
borderWidth: theme.borderWidth.thin,
|
|
118
|
+
borderColor: theme.color.borderStrong
|
|
119
|
+
},
|
|
120
|
+
ghost: { backgroundColor: "transparent" },
|
|
121
|
+
danger: { backgroundColor: theme.color.danger }
|
|
122
|
+
},
|
|
123
|
+
// Height, horizontal padding, gap and radius all resolve from the same
|
|
124
|
+
// control-size tier — one ramp, four steps (26 / 30 / 36 / 44).
|
|
125
|
+
size: {
|
|
126
|
+
xs: {
|
|
127
|
+
height: theme.ctl.xs,
|
|
128
|
+
paddingHorizontal: theme.ctl.px.xs,
|
|
129
|
+
gap: theme.ctl.gap.xs,
|
|
130
|
+
borderRadius: theme.ctl.r.xs
|
|
131
|
+
},
|
|
132
|
+
sm: {
|
|
133
|
+
height: theme.ctl.sm,
|
|
134
|
+
paddingHorizontal: theme.ctl.px.sm,
|
|
135
|
+
gap: theme.ctl.gap.sm,
|
|
136
|
+
borderRadius: theme.ctl.r.sm
|
|
137
|
+
},
|
|
138
|
+
md: {
|
|
139
|
+
height: theme.ctl.md,
|
|
140
|
+
paddingHorizontal: theme.ctl.px.md,
|
|
141
|
+
gap: theme.ctl.gap.md,
|
|
142
|
+
borderRadius: theme.ctl.r.md
|
|
143
|
+
},
|
|
144
|
+
lg: {
|
|
145
|
+
height: theme.ctl.lg,
|
|
146
|
+
paddingHorizontal: theme.ctl.px.lg,
|
|
147
|
+
gap: theme.ctl.gap.lg,
|
|
148
|
+
borderRadius: theme.ctl.r.lg
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
// Only a real `disabled` greys the fill — `loading` keeps the variant
|
|
152
|
+
// colour (R8: busy ≠ disabled).
|
|
153
|
+
disabled: {
|
|
154
|
+
true: { backgroundColor: theme.color.surface3, borderWidth: 0 },
|
|
155
|
+
false: {}
|
|
156
|
+
},
|
|
157
|
+
fullWidth: { true: { alignSelf: "stretch" }, false: {} }
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
// Bold sans label; size/line-height/tracking come from the overhauled
|
|
161
|
+
// semantic ramp (footnote → subheadline → body as the button grows).
|
|
162
|
+
label: {
|
|
163
|
+
fontFamily: theme.font.sans,
|
|
164
|
+
fontWeight: theme.fontWeight.bold,
|
|
165
|
+
variants: {
|
|
166
|
+
size: {
|
|
167
|
+
xs: {
|
|
168
|
+
fontSize: theme.type.caption1.fontSize,
|
|
169
|
+
lineHeight: theme.type.caption1.lineHeight,
|
|
170
|
+
letterSpacing: theme.type.caption1.letterSpacing
|
|
171
|
+
},
|
|
172
|
+
sm: {
|
|
173
|
+
fontSize: theme.type.footnote.fontSize,
|
|
174
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
175
|
+
letterSpacing: theme.type.footnote.letterSpacing
|
|
176
|
+
},
|
|
177
|
+
md: {
|
|
178
|
+
fontSize: theme.type.subheadline.fontSize,
|
|
179
|
+
lineHeight: theme.type.subheadline.lineHeight,
|
|
180
|
+
letterSpacing: theme.type.subheadline.letterSpacing
|
|
181
|
+
},
|
|
182
|
+
lg: {
|
|
183
|
+
fontSize: theme.type.body.fontSize,
|
|
184
|
+
lineHeight: theme.type.body.lineHeight,
|
|
185
|
+
letterSpacing: theme.type.body.letterSpacing
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
variant: {},
|
|
189
|
+
disabled: {},
|
|
190
|
+
fullWidth: {}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}));
|
|
194
|
+
|
|
195
|
+
export { Button };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|