@btndprojects/loam-ui-native 0.0.0-stage → 0.1.1
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/README.md +55 -2
- 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-423B7SPN.js +993 -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-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-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-FMYDDECK.js +1521 -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-HET4LLMX.js +129 -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-HZ6CNMAF.js +870 -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-JNY4ZHAR.js +634 -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-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-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-YTFKPRUK.js +845 -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
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { CopyButton } from './chunk-4ZAHCY44.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { View, Text, ScrollView } from 'react-native';
|
|
4
|
+
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function CodeBlock({
|
|
8
|
+
code,
|
|
9
|
+
language,
|
|
10
|
+
showLineNumbers = true,
|
|
11
|
+
wrap = false,
|
|
12
|
+
copyable = true,
|
|
13
|
+
onCopy,
|
|
14
|
+
caption,
|
|
15
|
+
filename,
|
|
16
|
+
maxHeight,
|
|
17
|
+
highlightLines,
|
|
18
|
+
// `motion` is accepted for API parity only — a code block never animates.
|
|
19
|
+
motion: _motion
|
|
20
|
+
}) {
|
|
21
|
+
const { styles } = useStyles(sheet);
|
|
22
|
+
const theme = useLoamTheme();
|
|
23
|
+
const lines = code.split("\n");
|
|
24
|
+
const label = filename ?? caption;
|
|
25
|
+
const hasHeader = Boolean(label || language);
|
|
26
|
+
const highlighted = React.useMemo(() => new Set(highlightLines ?? []), [highlightLines]);
|
|
27
|
+
const rows = lines.map((line, i) => {
|
|
28
|
+
const n = i + 1;
|
|
29
|
+
const isHot = highlighted.has(n);
|
|
30
|
+
const contentStyle = wrap ? styles.codeWrap : styles.codeNoWrap;
|
|
31
|
+
return /* @__PURE__ */ jsxs(
|
|
32
|
+
View,
|
|
33
|
+
{
|
|
34
|
+
style: [
|
|
35
|
+
styles.line,
|
|
36
|
+
!showLineNumbers && styles.lineInset,
|
|
37
|
+
isHot && { backgroundColor: theme.state.selected }
|
|
38
|
+
],
|
|
39
|
+
children: [
|
|
40
|
+
showLineNumbers ? /* @__PURE__ */ jsx(
|
|
41
|
+
Text,
|
|
42
|
+
{
|
|
43
|
+
testID: "code-block-gutter",
|
|
44
|
+
style: [styles.gutter, isHot && { color: theme.code.fg }],
|
|
45
|
+
importantForAccessibility: "no",
|
|
46
|
+
accessibilityElementsHidden: true,
|
|
47
|
+
children: n
|
|
48
|
+
}
|
|
49
|
+
) : null,
|
|
50
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.code, contentStyle], selectable: true, children: line.length ? line : " " })
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
i
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.root, children: [
|
|
57
|
+
hasHeader ? /* @__PURE__ */ jsxs(View, { style: styles.header, children: [
|
|
58
|
+
/* @__PURE__ */ jsxs(View, { style: styles.headerLabels, children: [
|
|
59
|
+
label ? /* @__PURE__ */ jsx(Text, { style: styles.filename, numberOfLines: 1, children: label }) : null,
|
|
60
|
+
language ? /* @__PURE__ */ jsx(Text, { style: styles.language, children: language.toUpperCase() }) : null
|
|
61
|
+
] }),
|
|
62
|
+
copyable ? /* @__PURE__ */ jsx(CopyButton, { value: code, onCopy, accessibilityLabel: "Copy code" }) : null
|
|
63
|
+
] }) : copyable ? /* @__PURE__ */ jsx(View, { style: styles.corner, children: /* @__PURE__ */ jsx(CopyButton, { value: code, onCopy, accessibilityLabel: "Copy code" }) }) : null,
|
|
64
|
+
/* @__PURE__ */ jsx(ScrollView, { focusable: true, style: maxHeight ? { maxHeight } : void 0, contentContainerStyle: styles.body, children: wrap ? /* @__PURE__ */ jsx(View, { style: styles.lines, children: rows }) : /* @__PURE__ */ jsx(ScrollView, { horizontal: true, focusable: true, contentContainerStyle: styles.lines, children: rows }) })
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
var sheet = createStyleSheet((theme) => ({
|
|
68
|
+
root: {
|
|
69
|
+
position: "relative",
|
|
70
|
+
borderRadius: theme.radius.lg,
|
|
71
|
+
borderWidth: theme.borderWidth.base,
|
|
72
|
+
borderColor: theme.color.border,
|
|
73
|
+
backgroundColor: theme.code.bg,
|
|
74
|
+
overflow: "hidden"
|
|
75
|
+
},
|
|
76
|
+
header: {
|
|
77
|
+
flexDirection: "row",
|
|
78
|
+
alignItems: "center",
|
|
79
|
+
justifyContent: "space-between",
|
|
80
|
+
gap: theme.space.s3,
|
|
81
|
+
paddingStart: theme.space.s4,
|
|
82
|
+
paddingEnd: theme.space.s2,
|
|
83
|
+
paddingVertical: theme.space.s2,
|
|
84
|
+
borderBottomWidth: theme.borderWidth.base,
|
|
85
|
+
borderBottomColor: theme.color.border
|
|
86
|
+
},
|
|
87
|
+
headerLabels: {
|
|
88
|
+
flexShrink: 1,
|
|
89
|
+
flexDirection: "row",
|
|
90
|
+
alignItems: "baseline",
|
|
91
|
+
gap: theme.space.s2
|
|
92
|
+
},
|
|
93
|
+
filename: {
|
|
94
|
+
flexShrink: 1,
|
|
95
|
+
fontFamily: theme.font.mono,
|
|
96
|
+
fontSize: theme.type.footnote.fontSize,
|
|
97
|
+
color: theme.code.fg
|
|
98
|
+
},
|
|
99
|
+
language: {
|
|
100
|
+
fontFamily: theme.font.mono,
|
|
101
|
+
fontSize: theme.type.caption1.fontSize,
|
|
102
|
+
letterSpacing: 1,
|
|
103
|
+
color: theme.code.fg,
|
|
104
|
+
opacity: theme.opacity[80]
|
|
105
|
+
},
|
|
106
|
+
corner: {
|
|
107
|
+
position: "absolute",
|
|
108
|
+
top: theme.space.s1,
|
|
109
|
+
end: theme.space.s1,
|
|
110
|
+
zIndex: theme.z.raised
|
|
111
|
+
},
|
|
112
|
+
body: { paddingVertical: theme.space.s3 },
|
|
113
|
+
lines: { flexDirection: "column" },
|
|
114
|
+
line: { flexDirection: "row", alignItems: "flex-start" },
|
|
115
|
+
// No gutter → the code needs the leading inset the gutter would have carried.
|
|
116
|
+
lineInset: { paddingStart: theme.space.s4 },
|
|
117
|
+
gutter: {
|
|
118
|
+
minWidth: theme.space.s6,
|
|
119
|
+
paddingStart: theme.space.s4,
|
|
120
|
+
paddingEnd: theme.space.s3,
|
|
121
|
+
textAlign: "right",
|
|
122
|
+
fontFamily: theme.font.mono,
|
|
123
|
+
fontSize: theme.type.footnote.fontSize,
|
|
124
|
+
lineHeight: theme.code.lineH,
|
|
125
|
+
// A muted gutter ink that still clears AA (4.5:1) on code.bg: code.fg at 70%
|
|
126
|
+
// alpha (~5.6:1 light / ~7.2:1 dark). `theme.code.com` is short in dark
|
|
127
|
+
// (~4.1:1), and `aria-hidden` does not exempt the gutter from axe here.
|
|
128
|
+
color: `${theme.code.fg}b3`
|
|
129
|
+
},
|
|
130
|
+
code: {
|
|
131
|
+
fontFamily: theme.font.mono,
|
|
132
|
+
fontSize: theme.type.footnote.fontSize,
|
|
133
|
+
lineHeight: theme.code.lineH,
|
|
134
|
+
color: theme.code.fg,
|
|
135
|
+
paddingEnd: theme.space.s4
|
|
136
|
+
},
|
|
137
|
+
// Wrapped lines take the remaining width so the Text engine can break them.
|
|
138
|
+
codeWrap: { flex: 1 },
|
|
139
|
+
// Non-wrapped lines size to their intrinsic width inside the horizontal
|
|
140
|
+
// ScrollView, so a long line scrolls rather than wrapping.
|
|
141
|
+
codeNoWrap: {}
|
|
142
|
+
}));
|
|
143
|
+
|
|
144
|
+
export { CodeBlock };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, Text } from 'react-native';
|
|
3
|
+
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/description-list/description-list.tsx
|
|
7
|
+
var DescriptionListContext = React.createContext({
|
|
8
|
+
layout: "stacked",
|
|
9
|
+
density: "comfortable"
|
|
10
|
+
});
|
|
11
|
+
function DescriptionList({
|
|
12
|
+
layout = "stacked",
|
|
13
|
+
density = "comfortable",
|
|
14
|
+
dividers = false,
|
|
15
|
+
items,
|
|
16
|
+
// Accepted for API consistency; static data drives no motion.
|
|
17
|
+
motion: _motion,
|
|
18
|
+
children
|
|
19
|
+
}) {
|
|
20
|
+
const { styles } = useStyles(sheet);
|
|
21
|
+
const ctx = React.useMemo(
|
|
22
|
+
() => ({ layout, density }),
|
|
23
|
+
[layout, density]
|
|
24
|
+
);
|
|
25
|
+
const rows = [
|
|
26
|
+
...items?.map((entry, i) => /* @__PURE__ */ jsx(DescriptionItem, { term: entry.term, description: entry.description }, `item-${i}`)) ?? [],
|
|
27
|
+
...React.Children.toArray(children)
|
|
28
|
+
];
|
|
29
|
+
const content = dividers ? rows.flatMap(
|
|
30
|
+
(row, i) => i === 0 ? [row] : [/* @__PURE__ */ jsx(View, { style: styles.divider }, `divider-${i}`), row]
|
|
31
|
+
) : rows;
|
|
32
|
+
return /* @__PURE__ */ jsx(DescriptionListContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(View, { style: styles.root, children: content }) });
|
|
33
|
+
}
|
|
34
|
+
function DescriptionItem({
|
|
35
|
+
term,
|
|
36
|
+
description
|
|
37
|
+
}) {
|
|
38
|
+
const { layout, density } = React.useContext(DescriptionListContext);
|
|
39
|
+
const { styles } = useStyles(sheet, { layout, density });
|
|
40
|
+
const theme = useLoamTheme();
|
|
41
|
+
const isInline = layout === "inline";
|
|
42
|
+
const pairLabel = typeof term === "string" && typeof description === "string" ? `${term}, ${description}` : void 0;
|
|
43
|
+
return /* @__PURE__ */ jsxs(
|
|
44
|
+
View,
|
|
45
|
+
{
|
|
46
|
+
style: styles.container,
|
|
47
|
+
accessible: pairLabel !== void 0,
|
|
48
|
+
accessibilityLabel: pairLabel,
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.term, isInline && termInlineStyle], children: term }),
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
Text,
|
|
53
|
+
{
|
|
54
|
+
style: [
|
|
55
|
+
styles.value,
|
|
56
|
+
isInline && { flexShrink: 1, textAlign: theme.rtl ? "left" : "right" }
|
|
57
|
+
],
|
|
58
|
+
children: description
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
var termInlineStyle = { flexShrink: 0 };
|
|
66
|
+
var sheet = createStyleSheet((theme) => ({
|
|
67
|
+
root: { alignSelf: "stretch" },
|
|
68
|
+
container: {
|
|
69
|
+
alignSelf: "stretch",
|
|
70
|
+
variants: {
|
|
71
|
+
layout: {
|
|
72
|
+
stacked: { flexDirection: "column", alignItems: "stretch", gap: theme.space.s1 },
|
|
73
|
+
inline: {
|
|
74
|
+
flexDirection: "row",
|
|
75
|
+
justifyContent: "space-between",
|
|
76
|
+
alignItems: "baseline",
|
|
77
|
+
gap: theme.space.s4
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
density: {
|
|
81
|
+
comfortable: { paddingVertical: theme.space.s2 },
|
|
82
|
+
compact: { paddingVertical: theme.space.s1 }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
// Muted secondary ink — measured to clear AA on a surface.
|
|
87
|
+
term: {
|
|
88
|
+
fontFamily: theme.font.sans,
|
|
89
|
+
fontWeight: theme.fontWeight.medium,
|
|
90
|
+
color: theme.color.text2,
|
|
91
|
+
fontSize: theme.type.footnote.fontSize,
|
|
92
|
+
lineHeight: theme.type.footnote.lineHeight,
|
|
93
|
+
letterSpacing: theme.type.footnote.letterSpacing
|
|
94
|
+
},
|
|
95
|
+
// Primary ink, with a measure cap so long values stay legible.
|
|
96
|
+
value: {
|
|
97
|
+
fontFamily: theme.font.sans,
|
|
98
|
+
fontWeight: theme.fontWeight.regular,
|
|
99
|
+
color: theme.color.text,
|
|
100
|
+
fontSize: theme.type.subheadline.fontSize,
|
|
101
|
+
lineHeight: theme.type.subheadline.lineHeight,
|
|
102
|
+
letterSpacing: theme.type.subheadline.letterSpacing,
|
|
103
|
+
maxWidth: Math.round(theme.type.subheadline.fontSize * 0.5 * theme.measure.base)
|
|
104
|
+
},
|
|
105
|
+
divider: {
|
|
106
|
+
alignSelf: "stretch",
|
|
107
|
+
height: theme.borderWidth.base,
|
|
108
|
+
backgroundColor: theme.color.border
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
export { DescriptionItem, DescriptionList };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Card } from './chunk-KMI5ML5I.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Animated, View, Text, Pressable, StyleSheet } from 'react-native';
|
|
4
|
+
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var FAMILY = {
|
|
8
|
+
small: { width: 168, aspectRatio: 1 },
|
|
9
|
+
medium: { width: 344, aspectRatio: 2 },
|
|
10
|
+
large: { width: 344, aspectRatio: 0.86 }
|
|
11
|
+
};
|
|
12
|
+
function useToneStyles(tone, accent) {
|
|
13
|
+
const theme = useLoamTheme();
|
|
14
|
+
if (tone === "neutral") {
|
|
15
|
+
return { surface: void 0, titleColor: theme.color.text };
|
|
16
|
+
}
|
|
17
|
+
const ink = {
|
|
18
|
+
accent: theme.color.accentOnSoft,
|
|
19
|
+
good: theme.color.goodOnSoft,
|
|
20
|
+
warn: theme.color.warnOnSoft,
|
|
21
|
+
danger: theme.color.dangerOnSoft,
|
|
22
|
+
info: theme.color.infoOnSoft
|
|
23
|
+
}[tone];
|
|
24
|
+
const line = {
|
|
25
|
+
accent: theme.color.accent,
|
|
26
|
+
good: theme.color.good,
|
|
27
|
+
warn: theme.color.warn,
|
|
28
|
+
danger: theme.color.danger,
|
|
29
|
+
info: theme.color.info
|
|
30
|
+
}[tone];
|
|
31
|
+
return {
|
|
32
|
+
surface: accent ? { borderColor: line, borderWidth: theme.borderWidth.thick } : void 0,
|
|
33
|
+
titleColor: ink
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function Widget({
|
|
37
|
+
size = "medium",
|
|
38
|
+
title,
|
|
39
|
+
children,
|
|
40
|
+
tone = "neutral",
|
|
41
|
+
accent = false,
|
|
42
|
+
footer,
|
|
43
|
+
onPress,
|
|
44
|
+
motion = "full",
|
|
45
|
+
accessibilityLabel
|
|
46
|
+
}) {
|
|
47
|
+
const { styles } = useStyles(sheet, { size });
|
|
48
|
+
const theme = useLoamTheme();
|
|
49
|
+
const { surface, titleColor } = useToneStyles(tone, accent);
|
|
50
|
+
const announced = accessibilityLabel ?? title;
|
|
51
|
+
const pressScale = theme.reduceMotion ? 1 : motion === "full" ? 0.97 : motion === "reduced" ? 0.99 : 1;
|
|
52
|
+
const scale = React.useRef(new Animated.Value(1)).current;
|
|
53
|
+
const spring = (to) => Animated.spring(scale, { toValue: to, useNativeDriver: true, speed: 40, bounciness: 6 }).start();
|
|
54
|
+
const body = /* @__PURE__ */ jsxs(View, { "aria-hidden": true, style: styles.content, children: [
|
|
55
|
+
title !== void 0 ? /* @__PURE__ */ jsx(Text, { style: [styles.title, { color: titleColor }], numberOfLines: size === "small" ? 2 : 3, children: title }) : null,
|
|
56
|
+
/* @__PURE__ */ jsx(View, { style: styles.glance, children }),
|
|
57
|
+
footer !== void 0 ? /* @__PURE__ */ jsx(View, { style: styles.footer, children: footer }) : null
|
|
58
|
+
] });
|
|
59
|
+
if (onPress) {
|
|
60
|
+
return /* @__PURE__ */ jsxs(Animated.View, { style: [styles.box, { transform: [{ scale }] }], children: [
|
|
61
|
+
/* @__PURE__ */ jsx(Card, { style: [styles.surface, surface], children: body }),
|
|
62
|
+
/* @__PURE__ */ jsx(
|
|
63
|
+
Pressable,
|
|
64
|
+
{
|
|
65
|
+
accessibilityRole: "button",
|
|
66
|
+
accessibilityLabel: announced,
|
|
67
|
+
onPress,
|
|
68
|
+
onPressIn: pressScale === 1 ? void 0 : () => spring(pressScale),
|
|
69
|
+
onPressOut: pressScale === 1 ? void 0 : () => spring(1),
|
|
70
|
+
style: StyleSheet.absoluteFill
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
] });
|
|
74
|
+
}
|
|
75
|
+
return /* @__PURE__ */ jsx(View, { style: styles.box, children: /* @__PURE__ */ jsx(Card, { style: [styles.surface, surface], accessibilityLabel: announced, children: body }) });
|
|
76
|
+
}
|
|
77
|
+
var sheet = createStyleSheet((theme) => ({
|
|
78
|
+
// The family box. `width` + `aspectRatio` give the fixed-ratio tile; `maxWidth`
|
|
79
|
+
// keeps it inside a narrow phone frame.
|
|
80
|
+
box: {
|
|
81
|
+
maxWidth: "100%",
|
|
82
|
+
variants: {
|
|
83
|
+
size: {
|
|
84
|
+
small: { width: FAMILY.small.width, aspectRatio: FAMILY.small.aspectRatio },
|
|
85
|
+
medium: { width: FAMILY.medium.width, aspectRatio: FAMILY.medium.aspectRatio },
|
|
86
|
+
large: { width: FAMILY.large.width, aspectRatio: FAMILY.large.aspectRatio }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
// Fill the box; the Card recipe (surface, hairline border, radius.xl, subtle
|
|
91
|
+
// shadow) comes from the Card component's own base style.
|
|
92
|
+
surface: { flex: 1 },
|
|
93
|
+
// Column: title pins to the top, the glance takes the slack, the footer sits at
|
|
94
|
+
// the bottom. Padding tightens on the small tile, where margin is precious.
|
|
95
|
+
content: {
|
|
96
|
+
flex: 1,
|
|
97
|
+
variants: {
|
|
98
|
+
size: {
|
|
99
|
+
small: { padding: theme.space.s3, gap: theme.space.s2 },
|
|
100
|
+
medium: { padding: theme.space.s4, gap: theme.space.s2 },
|
|
101
|
+
large: { padding: theme.space.s4, gap: theme.space.s3 }
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
// Brand display face, stepping up with the family.
|
|
106
|
+
title: {
|
|
107
|
+
fontFamily: theme.font.display,
|
|
108
|
+
fontWeight: `${theme.font.displayWeight}`,
|
|
109
|
+
variants: {
|
|
110
|
+
size: {
|
|
111
|
+
small: {
|
|
112
|
+
fontSize: theme.type.subheadline.fontSize,
|
|
113
|
+
lineHeight: theme.type.subheadline.lineHeight,
|
|
114
|
+
letterSpacing: theme.type.subheadline.letterSpacing
|
|
115
|
+
},
|
|
116
|
+
medium: {
|
|
117
|
+
fontSize: theme.type.title3.fontSize,
|
|
118
|
+
lineHeight: theme.type.title3.lineHeight,
|
|
119
|
+
letterSpacing: theme.type.title3.letterSpacing
|
|
120
|
+
},
|
|
121
|
+
large: {
|
|
122
|
+
fontSize: theme.type.title2.fontSize,
|
|
123
|
+
lineHeight: theme.type.title2.lineHeight,
|
|
124
|
+
letterSpacing: theme.type.title2.letterSpacing
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
// Takes the slack between title and footer so the glance sits where the family
|
|
130
|
+
// has room for it.
|
|
131
|
+
glance: { flex: 1, justifyContent: "center" },
|
|
132
|
+
// A hairline rule sets the footer off from the glance.
|
|
133
|
+
footer: {
|
|
134
|
+
paddingTop: theme.space.s2,
|
|
135
|
+
borderTopWidth: theme.borderWidth.base,
|
|
136
|
+
borderTopColor: theme.color.border
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
|
|
140
|
+
export { Widget };
|