@ezpg/app-ui 0.12.0 → 0.13.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/CHANGELOG.md +15 -0
- package/lib/module/blocks/action-grid/action-grid.js +1 -1
- package/lib/module/blocks/action-grid/action-grid.js.map +1 -1
- package/lib/module/blocks/bulk-ship-list/bulk-ship-list.js +33 -149
- package/lib/module/blocks/bulk-ship-list/bulk-ship-list.js.map +1 -1
- package/lib/module/blocks/index.js +4 -0
- package/lib/module/blocks/index.js.map +1 -1
- package/lib/module/blocks/photo-grid/index.js +4 -0
- package/lib/module/blocks/photo-grid/index.js.map +1 -0
- package/lib/module/blocks/photo-grid/photo-grid.js +99 -0
- package/lib/module/blocks/photo-grid/photo-grid.js.map +1 -0
- package/lib/module/blocks/quick-actions/quick-actions.js +1 -1
- package/lib/module/blocks/quick-actions/quick-actions.js.map +1 -1
- package/lib/module/blocks/request-card/index.js +4 -0
- package/lib/module/blocks/request-card/index.js.map +1 -0
- package/lib/module/blocks/request-card/request-card.js +96 -0
- package/lib/module/blocks/request-card/request-card.js.map +1 -0
- package/lib/module/blocks/scan-modal/index.js +4 -0
- package/lib/module/blocks/scan-modal/index.js.map +1 -0
- package/lib/module/blocks/scan-modal/scan-modal.js +67 -0
- package/lib/module/blocks/scan-modal/scan-modal.js.map +1 -0
- package/lib/module/blocks/summary-cards/index.js +4 -0
- package/lib/module/blocks/summary-cards/index.js.map +1 -0
- package/lib/module/blocks/summary-cards/summary-cards.js +468 -0
- package/lib/module/blocks/summary-cards/summary-cards.js.map +1 -0
- package/lib/module/components/dialog/dialog.js +23 -5
- package/lib/module/components/dialog/dialog.js.map +1 -1
- package/lib/module/components/field/field.js +12 -1
- package/lib/module/components/field/field.js.map +1 -1
- package/lib/module/components/list-row/list-row.js +45 -2
- package/lib/module/components/list-row/list-row.js.map +1 -1
- package/lib/module/components/progress-bar/progress-bar.js +2 -1
- package/lib/module/components/progress-bar/progress-bar.js.map +1 -1
- package/lib/module/components/status-badge/status-badge.js +1 -0
- package/lib/module/components/status-badge/status-badge.js.map +1 -1
- package/lib/module/components/stepper/index.js +4 -0
- package/lib/module/components/stepper/index.js.map +1 -0
- package/lib/module/components/stepper/stepper.js +93 -0
- package/lib/module/components/stepper/stepper.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/glyphs.js +44 -0
- package/lib/module/internal/glyphs.js.map +1 -1
- package/lib/module/templates/index.js +2 -0
- package/lib/module/templates/index.js.map +1 -1
- package/lib/module/templates/parts.js +11 -0
- package/lib/module/templates/parts.js.map +1 -1
- package/lib/module/templates/preview-template.js +77 -0
- package/lib/module/templates/preview-template.js.map +1 -0
- package/lib/module/templates/selection-template.js +24 -0
- package/lib/module/templates/selection-template.js.map +1 -0
- package/lib/typescript/src/blocks/bulk-ship-list/bulk-ship-list.d.ts +0 -1
- package/lib/typescript/src/blocks/bulk-ship-list/bulk-ship-list.d.ts.map +1 -1
- package/lib/typescript/src/blocks/index.d.ts +4 -0
- package/lib/typescript/src/blocks/index.d.ts.map +1 -1
- package/lib/typescript/src/blocks/photo-grid/index.d.ts +2 -0
- package/lib/typescript/src/blocks/photo-grid/index.d.ts.map +1 -0
- package/lib/typescript/src/blocks/photo-grid/photo-grid.d.ts +14 -0
- package/lib/typescript/src/blocks/photo-grid/photo-grid.d.ts.map +1 -0
- package/lib/typescript/src/blocks/request-card/index.d.ts +2 -0
- package/lib/typescript/src/blocks/request-card/index.d.ts.map +1 -0
- package/lib/typescript/src/blocks/request-card/request-card.d.ts +15 -0
- package/lib/typescript/src/blocks/request-card/request-card.d.ts.map +1 -0
- package/lib/typescript/src/blocks/scan-modal/index.d.ts +2 -0
- package/lib/typescript/src/blocks/scan-modal/index.d.ts.map +1 -0
- package/lib/typescript/src/blocks/scan-modal/scan-modal.d.ts +14 -0
- package/lib/typescript/src/blocks/scan-modal/scan-modal.d.ts.map +1 -0
- package/lib/typescript/src/blocks/summary-cards/index.d.ts +2 -0
- package/lib/typescript/src/blocks/summary-cards/index.d.ts.map +1 -0
- package/lib/typescript/src/blocks/summary-cards/summary-cards.d.ts +93 -0
- package/lib/typescript/src/blocks/summary-cards/summary-cards.d.ts.map +1 -0
- package/lib/typescript/src/components/dialog/dialog.d.ts +2 -1
- package/lib/typescript/src/components/dialog/dialog.d.ts.map +1 -1
- package/lib/typescript/src/components/field/field.d.ts +3 -1
- package/lib/typescript/src/components/field/field.d.ts.map +1 -1
- package/lib/typescript/src/components/list-row/list-row.d.ts +4 -1
- package/lib/typescript/src/components/list-row/list-row.d.ts.map +1 -1
- package/lib/typescript/src/components/progress-bar/progress-bar.d.ts +2 -1
- package/lib/typescript/src/components/progress-bar/progress-bar.d.ts.map +1 -1
- package/lib/typescript/src/components/status-badge/status-badge.d.ts +1 -1
- package/lib/typescript/src/components/status-badge/status-badge.d.ts.map +1 -1
- package/lib/typescript/src/components/stepper/index.d.ts +2 -0
- package/lib/typescript/src/components/stepper/index.d.ts.map +1 -0
- package/lib/typescript/src/components/stepper/stepper.d.ts +13 -0
- package/lib/typescript/src/components/stepper/stepper.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/internal/glyphs.d.ts +1 -0
- package/lib/typescript/src/internal/glyphs.d.ts.map +1 -1
- package/lib/typescript/src/templates/index.d.ts +4 -0
- package/lib/typescript/src/templates/index.d.ts.map +1 -1
- package/lib/typescript/src/templates/parts.d.ts +2 -1
- package/lib/typescript/src/templates/parts.d.ts.map +1 -1
- package/lib/typescript/src/templates/preview-template.d.ts +18 -0
- package/lib/typescript/src/templates/preview-template.d.ts.map +1 -0
- package/lib/typescript/src/templates/selection-template.d.ts +7 -0
- package/lib/typescript/src/templates/selection-template.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/blocks/action-grid/action-grid.tsx +1 -1
- package/src/blocks/bulk-ship-list/bulk-ship-list.tsx +30 -126
- package/src/blocks/index.tsx +4 -0
- package/src/blocks/photo-grid/index.ts +5 -0
- package/src/blocks/photo-grid/photo-grid.tsx +96 -0
- package/src/blocks/quick-actions/quick-actions.tsx +1 -1
- package/src/blocks/request-card/index.ts +1 -0
- package/src/blocks/request-card/request-card.tsx +94 -0
- package/src/blocks/scan-modal/index.ts +1 -0
- package/src/blocks/scan-modal/scan-modal.tsx +61 -0
- package/src/blocks/summary-cards/index.ts +1 -0
- package/src/blocks/summary-cards/summary-cards.tsx +484 -0
- package/src/components/dialog/dialog.tsx +27 -7
- package/src/components/field/field.tsx +14 -1
- package/src/components/list-row/list-row.tsx +53 -2
- package/src/components/progress-bar/progress-bar.tsx +23 -14
- package/src/components/status-badge/status-badge.tsx +2 -1
- package/src/components/stepper/index.ts +1 -0
- package/src/components/stepper/stepper.tsx +85 -0
- package/src/index.tsx +2 -0
- package/src/internal/glyphs.tsx +37 -0
- package/src/templates/index.ts +7 -0
- package/src/templates/parts.tsx +9 -0
- package/src/templates/preview-template.tsx +88 -0
- package/src/templates/selection-template.tsx +22 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { Avatar } from '../../components/avatar/avatar';
|
|
4
|
+
import { Button } from '../../components/button/button';
|
|
5
|
+
import { Photo } from '../../components/photo/photo';
|
|
6
|
+
import { ProgressBar } from '../../components/progress-bar/progress-bar';
|
|
7
|
+
import { StatusBadge } from '../../components/status-badge/status-badge';
|
|
8
|
+
import { Switch } from '../../components/switch/switch';
|
|
9
|
+
import { Text } from '../../components/text/text';
|
|
10
|
+
import { UsersGlyph } from '../../internal/glyphs';
|
|
11
|
+
import { PressableBase } from '../../internal/pressable-base';
|
|
12
|
+
import { useTheme } from '../../theme/theme-provider';
|
|
13
|
+
import { makeStyles } from '../../utils/styles';
|
|
14
|
+
|
|
15
|
+
const LONG_ANSWER = 24;
|
|
16
|
+
|
|
17
|
+
const useStyles = makeStyles((t) => ({
|
|
18
|
+
panel: {
|
|
19
|
+
marginTop: t.layout.groupGap,
|
|
20
|
+
marginHorizontal: t.layout.screenX,
|
|
21
|
+
padding: t.space[4],
|
|
22
|
+
gap: t.space[3],
|
|
23
|
+
borderRadius: t.radius.lg,
|
|
24
|
+
backgroundColor: t.colors.surface,
|
|
25
|
+
},
|
|
26
|
+
row: { flexDirection: 'row', alignItems: 'center', gap: t.space[3] },
|
|
27
|
+
between: {
|
|
28
|
+
flexDirection: 'row',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
justifyContent: 'space-between',
|
|
31
|
+
gap: t.space[3],
|
|
32
|
+
},
|
|
33
|
+
grow: { flex: 1, gap: t.space[1] },
|
|
34
|
+
buttons: { flexDirection: 'row', gap: t.space[2] },
|
|
35
|
+
meta: { flexDirection: 'row', alignItems: 'center', gap: t.space[1] },
|
|
36
|
+
thumb: { width: 72 },
|
|
37
|
+
side: { flex: 1, gap: t.space[1] },
|
|
38
|
+
end: { alignItems: 'flex-end' },
|
|
39
|
+
tiles: {
|
|
40
|
+
flexDirection: 'row',
|
|
41
|
+
flexWrap: 'wrap',
|
|
42
|
+
gap: t.layout.itemGap,
|
|
43
|
+
marginTop: t.layout.groupGap,
|
|
44
|
+
paddingHorizontal: t.layout.screenX,
|
|
45
|
+
},
|
|
46
|
+
tile: {
|
|
47
|
+
flexBasis: '48%',
|
|
48
|
+
flexGrow: 1,
|
|
49
|
+
gap: t.space[1],
|
|
50
|
+
padding: t.space[3],
|
|
51
|
+
borderRadius: t.radius.lg,
|
|
52
|
+
backgroundColor: t.colors.surface,
|
|
53
|
+
},
|
|
54
|
+
pressed: { backgroundColor: t.colors.muted },
|
|
55
|
+
band: { flexDirection: 'row', gap: t.space[1] },
|
|
56
|
+
month: { flex: 1, alignItems: 'center', gap: t.space[1] },
|
|
57
|
+
cell: { alignSelf: 'stretch', height: 28, borderRadius: t.radius.sm },
|
|
58
|
+
on: { backgroundColor: t.colors.primary },
|
|
59
|
+
off: { backgroundColor: t.colors.muted },
|
|
60
|
+
chips: { flexDirection: 'row', flexWrap: 'wrap', gap: t.space[1] },
|
|
61
|
+
answer: { gap: t.space[1] },
|
|
62
|
+
step: { flexDirection: 'row', gap: t.space[3] },
|
|
63
|
+
rail: { alignItems: 'center' },
|
|
64
|
+
dot: {
|
|
65
|
+
width: 12,
|
|
66
|
+
height: 12,
|
|
67
|
+
marginTop: t.space[1],
|
|
68
|
+
borderRadius: t.radius.full,
|
|
69
|
+
},
|
|
70
|
+
line: { flex: 1, width: 2, backgroundColor: t.colors.muted },
|
|
71
|
+
stepBody: { flex: 1, paddingBottom: t.space[3] },
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
export type PanelProps = {
|
|
75
|
+
children: ReactNode;
|
|
76
|
+
style?: StyleProp<ViewStyle>;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export function Panel({ children, style }: PanelProps) {
|
|
80
|
+
const s = useStyles();
|
|
81
|
+
return <View style={[s.panel, style]}>{children}</View>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type SummaryHeaderProps = {
|
|
85
|
+
title: string;
|
|
86
|
+
image?: string | null;
|
|
87
|
+
seed?: string;
|
|
88
|
+
avatar?: string;
|
|
89
|
+
badge?: string;
|
|
90
|
+
subtitle?: string;
|
|
91
|
+
people?: string;
|
|
92
|
+
actions?: readonly { key: string; label: string; onPress: () => void }[];
|
|
93
|
+
children?: ReactNode;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export function SummaryHeader({
|
|
97
|
+
title,
|
|
98
|
+
image,
|
|
99
|
+
seed,
|
|
100
|
+
avatar,
|
|
101
|
+
badge,
|
|
102
|
+
subtitle,
|
|
103
|
+
people,
|
|
104
|
+
actions,
|
|
105
|
+
children,
|
|
106
|
+
}: SummaryHeaderProps) {
|
|
107
|
+
const t = useTheme();
|
|
108
|
+
const s = useStyles();
|
|
109
|
+
return (
|
|
110
|
+
<Panel>
|
|
111
|
+
<View style={s.row}>
|
|
112
|
+
{image !== undefined ? (
|
|
113
|
+
<Photo
|
|
114
|
+
source={{ uri: image ?? '' }}
|
|
115
|
+
seed={seed ?? title}
|
|
116
|
+
radius={t.radius.md}
|
|
117
|
+
style={s.thumb}
|
|
118
|
+
/>
|
|
119
|
+
) : null}
|
|
120
|
+
{avatar !== undefined ? <Avatar size="md" uri={avatar} /> : null}
|
|
121
|
+
<View style={s.grow}>
|
|
122
|
+
<Text variant="title" weight="bold" numberOfLines={1}>
|
|
123
|
+
{title}
|
|
124
|
+
</Text>
|
|
125
|
+
{subtitle ? (
|
|
126
|
+
<Text variant="label" tone="muted" numberOfLines={1}>
|
|
127
|
+
{subtitle}
|
|
128
|
+
</Text>
|
|
129
|
+
) : null}
|
|
130
|
+
{people ? (
|
|
131
|
+
<View style={s.meta}>
|
|
132
|
+
<UsersGlyph
|
|
133
|
+
color={t.colors.mutedForeground}
|
|
134
|
+
size={t.iconSize.sm}
|
|
135
|
+
/>
|
|
136
|
+
<Text variant="label" tone="muted" numberOfLines={1}>
|
|
137
|
+
{people}
|
|
138
|
+
</Text>
|
|
139
|
+
</View>
|
|
140
|
+
) : null}
|
|
141
|
+
</View>
|
|
142
|
+
{badge ? <StatusBadge tone="point">{badge}</StatusBadge> : null}
|
|
143
|
+
</View>
|
|
144
|
+
{actions?.length ? (
|
|
145
|
+
<View style={s.buttons}>
|
|
146
|
+
{actions.map((item) => (
|
|
147
|
+
<Button
|
|
148
|
+
key={item.key}
|
|
149
|
+
variant="outline"
|
|
150
|
+
size="sm"
|
|
151
|
+
style={s.side}
|
|
152
|
+
onPress={item.onPress}
|
|
153
|
+
>
|
|
154
|
+
{item.label}
|
|
155
|
+
</Button>
|
|
156
|
+
))}
|
|
157
|
+
</View>
|
|
158
|
+
) : null}
|
|
159
|
+
{children}
|
|
160
|
+
</Panel>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type MetricCardProps = {
|
|
165
|
+
label: string;
|
|
166
|
+
value: string;
|
|
167
|
+
caption?: string;
|
|
168
|
+
aside?: string;
|
|
169
|
+
emphasis?: boolean;
|
|
170
|
+
action?: ReactNode;
|
|
171
|
+
children?: ReactNode;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export function MetricCard({
|
|
175
|
+
label,
|
|
176
|
+
value,
|
|
177
|
+
caption,
|
|
178
|
+
aside,
|
|
179
|
+
emphasis = false,
|
|
180
|
+
action,
|
|
181
|
+
children,
|
|
182
|
+
}: MetricCardProps) {
|
|
183
|
+
const s = useStyles();
|
|
184
|
+
return (
|
|
185
|
+
<Panel>
|
|
186
|
+
<View style={s.between}>
|
|
187
|
+
<View style={s.grow}>
|
|
188
|
+
<Text variant="label" tone="muted">
|
|
189
|
+
{label}
|
|
190
|
+
</Text>
|
|
191
|
+
<Text
|
|
192
|
+
variant={emphasis ? 'screenTitle' : 'title'}
|
|
193
|
+
weight="bold"
|
|
194
|
+
tone={emphasis ? 'point' : undefined}
|
|
195
|
+
>
|
|
196
|
+
{value}
|
|
197
|
+
</Text>
|
|
198
|
+
{caption ? (
|
|
199
|
+
<Text variant="label" tone="muted">
|
|
200
|
+
{caption}
|
|
201
|
+
</Text>
|
|
202
|
+
) : null}
|
|
203
|
+
</View>
|
|
204
|
+
{aside ? (
|
|
205
|
+
<Text variant="bodyLg" weight="bold" tone="point">
|
|
206
|
+
{aside}
|
|
207
|
+
</Text>
|
|
208
|
+
) : null}
|
|
209
|
+
{action}
|
|
210
|
+
</View>
|
|
211
|
+
{children}
|
|
212
|
+
</Panel>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type ValueTile = {
|
|
217
|
+
key: string;
|
|
218
|
+
label: string;
|
|
219
|
+
value: string;
|
|
220
|
+
emphasis?: boolean;
|
|
221
|
+
onPress?: () => void;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export type ValueTilesProps = { items: readonly ValueTile[] };
|
|
225
|
+
|
|
226
|
+
export function ValueTiles({ items }: ValueTilesProps) {
|
|
227
|
+
const s = useStyles();
|
|
228
|
+
return (
|
|
229
|
+
<View style={s.tiles}>
|
|
230
|
+
{items.map((item) => {
|
|
231
|
+
const body = (
|
|
232
|
+
<>
|
|
233
|
+
<Text variant="label" tone="muted" numberOfLines={1}>
|
|
234
|
+
{item.label}
|
|
235
|
+
</Text>
|
|
236
|
+
<Text
|
|
237
|
+
variant="bodyLg"
|
|
238
|
+
weight="bold"
|
|
239
|
+
tone={item.emphasis ? 'point' : undefined}
|
|
240
|
+
numberOfLines={1}
|
|
241
|
+
>
|
|
242
|
+
{item.value}
|
|
243
|
+
</Text>
|
|
244
|
+
</>
|
|
245
|
+
);
|
|
246
|
+
return item.onPress ? (
|
|
247
|
+
<PressableBase
|
|
248
|
+
key={item.key}
|
|
249
|
+
accessibilityRole="button"
|
|
250
|
+
accessibilityLabel={`${item.label} ${item.value}`}
|
|
251
|
+
onPress={item.onPress}
|
|
252
|
+
pressedStyle={s.pressed}
|
|
253
|
+
style={s.tile}
|
|
254
|
+
>
|
|
255
|
+
{body}
|
|
256
|
+
</PressableBase>
|
|
257
|
+
) : (
|
|
258
|
+
<View key={item.key} style={s.tile}>
|
|
259
|
+
{body}
|
|
260
|
+
</View>
|
|
261
|
+
);
|
|
262
|
+
})}
|
|
263
|
+
</View>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export type TimeSpanCardProps = {
|
|
268
|
+
startLabel: string;
|
|
269
|
+
start: string;
|
|
270
|
+
endLabel: string;
|
|
271
|
+
end: string;
|
|
272
|
+
middle: string;
|
|
273
|
+
onStartPress?: () => void;
|
|
274
|
+
onEndPress?: () => void;
|
|
275
|
+
onMiddlePress?: () => void;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export function TimeSpanCard({
|
|
279
|
+
startLabel,
|
|
280
|
+
start,
|
|
281
|
+
endLabel,
|
|
282
|
+
end,
|
|
283
|
+
middle,
|
|
284
|
+
onStartPress,
|
|
285
|
+
onEndPress,
|
|
286
|
+
onMiddlePress,
|
|
287
|
+
}: TimeSpanCardProps) {
|
|
288
|
+
const s = useStyles();
|
|
289
|
+
return (
|
|
290
|
+
<Panel>
|
|
291
|
+
<View style={s.row}>
|
|
292
|
+
<PressableBase
|
|
293
|
+
accessibilityRole="button"
|
|
294
|
+
accessibilityLabel={`${startLabel} ${start}`}
|
|
295
|
+
onPress={onStartPress}
|
|
296
|
+
style={s.side}
|
|
297
|
+
>
|
|
298
|
+
<Text variant="label" tone="muted">
|
|
299
|
+
{startLabel}
|
|
300
|
+
</Text>
|
|
301
|
+
<Text variant="title" weight="bold">
|
|
302
|
+
{start}
|
|
303
|
+
</Text>
|
|
304
|
+
</PressableBase>
|
|
305
|
+
<PressableBase
|
|
306
|
+
accessibilityRole="button"
|
|
307
|
+
accessibilityLabel={middle}
|
|
308
|
+
onPress={onMiddlePress}
|
|
309
|
+
>
|
|
310
|
+
<StatusBadge>{middle}</StatusBadge>
|
|
311
|
+
</PressableBase>
|
|
312
|
+
<PressableBase
|
|
313
|
+
accessibilityRole="button"
|
|
314
|
+
accessibilityLabel={`${endLabel} ${end}`}
|
|
315
|
+
onPress={onEndPress}
|
|
316
|
+
style={[s.side, s.end]}
|
|
317
|
+
>
|
|
318
|
+
<Text variant="label" tone="muted">
|
|
319
|
+
{endLabel}
|
|
320
|
+
</Text>
|
|
321
|
+
<Text variant="title" weight="bold">
|
|
322
|
+
{end}
|
|
323
|
+
</Text>
|
|
324
|
+
</PressableBase>
|
|
325
|
+
</View>
|
|
326
|
+
</Panel>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export type YearBandProps = {
|
|
331
|
+
label: string;
|
|
332
|
+
months: readonly boolean[];
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export function YearBand({ label, months }: YearBandProps) {
|
|
336
|
+
const s = useStyles();
|
|
337
|
+
return (
|
|
338
|
+
<Panel>
|
|
339
|
+
<Text variant="label" tone="muted">
|
|
340
|
+
{label}
|
|
341
|
+
</Text>
|
|
342
|
+
<View style={s.band}>
|
|
343
|
+
{months.map((on, index) => (
|
|
344
|
+
<View key={index} style={s.month}>
|
|
345
|
+
<View style={[s.cell, on ? s.on : s.off]} />
|
|
346
|
+
<Text variant="caption" tone="muted">
|
|
347
|
+
{`${index + 1}`}
|
|
348
|
+
</Text>
|
|
349
|
+
</View>
|
|
350
|
+
))}
|
|
351
|
+
</View>
|
|
352
|
+
</Panel>
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export type AnswerChipsProps = {
|
|
357
|
+
items: readonly { key: string; label: string; values: readonly string[] }[];
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
export function AnswerChips({ items }: AnswerChipsProps) {
|
|
361
|
+
const s = useStyles();
|
|
362
|
+
return (
|
|
363
|
+
<Panel>
|
|
364
|
+
{items.map((item) => (
|
|
365
|
+
<View key={item.key} style={s.answer}>
|
|
366
|
+
<Text variant="label" tone="muted">
|
|
367
|
+
{item.label}
|
|
368
|
+
</Text>
|
|
369
|
+
<View style={s.chips}>
|
|
370
|
+
{item.values.map((value) =>
|
|
371
|
+
value.length > LONG_ANSWER ? (
|
|
372
|
+
<Text key={value} variant="body">
|
|
373
|
+
{value}
|
|
374
|
+
</Text>
|
|
375
|
+
) : (
|
|
376
|
+
<StatusBadge key={value}>{value}</StatusBadge>
|
|
377
|
+
)
|
|
378
|
+
)}
|
|
379
|
+
</View>
|
|
380
|
+
</View>
|
|
381
|
+
))}
|
|
382
|
+
</Panel>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export type HistoryListProps = {
|
|
387
|
+
items: readonly { key: string; title: string; at?: string; done: boolean }[];
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
export function HistoryList({ items }: HistoryListProps) {
|
|
391
|
+
const s = useStyles();
|
|
392
|
+
return (
|
|
393
|
+
<Panel>
|
|
394
|
+
<View>
|
|
395
|
+
{items.map((item, index) => (
|
|
396
|
+
<View key={item.key} style={s.step}>
|
|
397
|
+
<View style={s.rail}>
|
|
398
|
+
<View style={[s.dot, item.done ? s.on : s.off]} />
|
|
399
|
+
{index < items.length - 1 ? <View style={s.line} /> : null}
|
|
400
|
+
</View>
|
|
401
|
+
<View style={[s.between, s.stepBody]}>
|
|
402
|
+
<Text
|
|
403
|
+
variant="label"
|
|
404
|
+
weight={item.done ? 'semibold' : undefined}
|
|
405
|
+
tone={item.done ? undefined : 'muted'}
|
|
406
|
+
>
|
|
407
|
+
{item.title}
|
|
408
|
+
</Text>
|
|
409
|
+
{item.at ? (
|
|
410
|
+
<Text variant="caption" tone="muted">
|
|
411
|
+
{item.at}
|
|
412
|
+
</Text>
|
|
413
|
+
) : null}
|
|
414
|
+
</View>
|
|
415
|
+
</View>
|
|
416
|
+
))}
|
|
417
|
+
</View>
|
|
418
|
+
</Panel>
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export type UsageCardProps = {
|
|
423
|
+
title: string;
|
|
424
|
+
used: number;
|
|
425
|
+
total: number;
|
|
426
|
+
caption: string;
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
export function UsageCard({ title, used, total, caption }: UsageCardProps) {
|
|
430
|
+
const s = useStyles();
|
|
431
|
+
return (
|
|
432
|
+
<Panel>
|
|
433
|
+
<View style={s.between}>
|
|
434
|
+
<Text variant="bodyLg" weight="semibold">
|
|
435
|
+
{title}
|
|
436
|
+
</Text>
|
|
437
|
+
<Text variant="label" tone="muted">
|
|
438
|
+
{caption}
|
|
439
|
+
</Text>
|
|
440
|
+
</View>
|
|
441
|
+
<ProgressBar done={used} total={total} plain />
|
|
442
|
+
</Panel>
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export type ToggleCardProps = {
|
|
447
|
+
title: string;
|
|
448
|
+
description?: string;
|
|
449
|
+
value: boolean;
|
|
450
|
+
disabled?: boolean;
|
|
451
|
+
onValueChange: (value: boolean) => void;
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
export function ToggleCard({
|
|
455
|
+
title,
|
|
456
|
+
description,
|
|
457
|
+
value,
|
|
458
|
+
disabled,
|
|
459
|
+
onValueChange,
|
|
460
|
+
}: ToggleCardProps) {
|
|
461
|
+
const s = useStyles();
|
|
462
|
+
return (
|
|
463
|
+
<Panel>
|
|
464
|
+
<View style={s.between}>
|
|
465
|
+
<View style={s.grow}>
|
|
466
|
+
<Text variant="bodyLg" weight="bold">
|
|
467
|
+
{title}
|
|
468
|
+
</Text>
|
|
469
|
+
{description ? (
|
|
470
|
+
<Text variant="label" tone="muted">
|
|
471
|
+
{description}
|
|
472
|
+
</Text>
|
|
473
|
+
) : null}
|
|
474
|
+
</View>
|
|
475
|
+
<Switch
|
|
476
|
+
accessibilityLabel={title}
|
|
477
|
+
value={value}
|
|
478
|
+
disabled={disabled}
|
|
479
|
+
onValueChange={onValueChange}
|
|
480
|
+
/>
|
|
481
|
+
</View>
|
|
482
|
+
</Panel>
|
|
483
|
+
);
|
|
484
|
+
}
|
|
@@ -9,6 +9,7 @@ export type DialogProps = {
|
|
|
9
9
|
open: boolean;
|
|
10
10
|
onOpenChange: (open: boolean) => void;
|
|
11
11
|
title: string;
|
|
12
|
+
description?: string;
|
|
12
13
|
onConfirm: () => void;
|
|
13
14
|
confirmLabel?: string;
|
|
14
15
|
cancelLabel?: string;
|
|
@@ -39,6 +40,14 @@ const useStyles = makeStyles((t) => ({
|
|
|
39
40
|
textAlign: 'center',
|
|
40
41
|
color: t.colors.foreground,
|
|
41
42
|
},
|
|
43
|
+
copy: { gap: t.space[2] },
|
|
44
|
+
description: {
|
|
45
|
+
fontFamily: t.fontFamily,
|
|
46
|
+
fontSize: t.typography.body.fontSize,
|
|
47
|
+
lineHeight: t.typography.body.lineHeight,
|
|
48
|
+
textAlign: 'center',
|
|
49
|
+
color: t.colors.mutedForeground,
|
|
50
|
+
},
|
|
42
51
|
actions: { flexDirection: 'row', gap: t.space[2] },
|
|
43
52
|
action: { flex: 1, borderRadius: t.radius.lg },
|
|
44
53
|
}));
|
|
@@ -47,6 +56,7 @@ export function Dialog({
|
|
|
47
56
|
open,
|
|
48
57
|
onOpenChange,
|
|
49
58
|
title,
|
|
59
|
+
description,
|
|
50
60
|
onConfirm,
|
|
51
61
|
confirmLabel = '확인',
|
|
52
62
|
cancelLabel = '취소',
|
|
@@ -91,13 +101,23 @@ export function Dialog({
|
|
|
91
101
|
},
|
|
92
102
|
]}
|
|
93
103
|
>
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
<View style={s.copy}>
|
|
105
|
+
<Text
|
|
106
|
+
accessibilityRole="header"
|
|
107
|
+
maxFontSizeMultiplier={t.maxFontScale}
|
|
108
|
+
style={s.title}
|
|
109
|
+
>
|
|
110
|
+
{title}
|
|
111
|
+
</Text>
|
|
112
|
+
{description ? (
|
|
113
|
+
<Text
|
|
114
|
+
maxFontSizeMultiplier={t.maxFontScale}
|
|
115
|
+
style={s.description}
|
|
116
|
+
>
|
|
117
|
+
{description}
|
|
118
|
+
</Text>
|
|
119
|
+
) : null}
|
|
120
|
+
</View>
|
|
101
121
|
<View style={s.actions}>
|
|
102
122
|
<Button
|
|
103
123
|
variant="secondary"
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import { AlertGlyph } from '../../internal/glyphs';
|
|
11
11
|
import { renderIcon, type IconSlot } from '../../internal/icon';
|
|
12
|
+
import { PressableBase } from '../../internal/pressable-base';
|
|
12
13
|
import { useTheme } from '../../theme/theme-provider';
|
|
13
14
|
import { makeStyles } from '../../utils/styles';
|
|
14
15
|
|
|
@@ -21,6 +22,8 @@ export type FieldProps = Omit<TextInputProps, 'style'> & {
|
|
|
21
22
|
warning?: string;
|
|
22
23
|
leading?: IconSlot;
|
|
23
24
|
trailing?: IconSlot;
|
|
25
|
+
onTrailingPress?: () => void;
|
|
26
|
+
trailingLabel?: string;
|
|
24
27
|
style?: StyleProp<ViewStyle>;
|
|
25
28
|
};
|
|
26
29
|
|
|
@@ -107,6 +110,8 @@ export function Field({
|
|
|
107
110
|
warning,
|
|
108
111
|
leading,
|
|
109
112
|
trailing,
|
|
113
|
+
onTrailingPress,
|
|
114
|
+
trailingLabel,
|
|
110
115
|
style,
|
|
111
116
|
editable = true,
|
|
112
117
|
onFocus,
|
|
@@ -158,7 +163,15 @@ export function Field({
|
|
|
158
163
|
onBlur?.(e);
|
|
159
164
|
}}
|
|
160
165
|
/>
|
|
161
|
-
{
|
|
166
|
+
{trailing && onTrailingPress ? (
|
|
167
|
+
<PressableBase
|
|
168
|
+
accessibilityRole="button"
|
|
169
|
+
accessibilityLabel={trailingLabel}
|
|
170
|
+
onPress={onTrailingPress}
|
|
171
|
+
>
|
|
172
|
+
{renderIcon(trailing, { ...icon, color: t.colors.foreground })}
|
|
173
|
+
</PressableBase>
|
|
174
|
+
) : error ? (
|
|
162
175
|
<AlertGlyph
|
|
163
176
|
filled
|
|
164
177
|
color={t.colors.danger}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Text, View } from 'react-native';
|
|
2
|
-
import { ChevronGlyph } from '../../internal/glyphs';
|
|
2
|
+
import { CheckGlyph, ChevronGlyph } from '../../internal/glyphs';
|
|
3
3
|
import { renderIcon, type IconSlot } from '../../internal/icon';
|
|
4
4
|
import {
|
|
5
5
|
PressableBase,
|
|
@@ -28,9 +28,13 @@ export type ListRowProps = Omit<
|
|
|
28
28
|
highlighted?: boolean;
|
|
29
29
|
strong?: boolean;
|
|
30
30
|
titleLines?: number;
|
|
31
|
+
selection?: 'check' | 'radio';
|
|
32
|
+
selected?: boolean;
|
|
33
|
+
leadingTone?: 'muted' | 'point';
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
const IMAGE = 48;
|
|
37
|
+
const MARK = 22;
|
|
34
38
|
|
|
35
39
|
const useStyles = makeStyles((t) => ({
|
|
36
40
|
row: {
|
|
@@ -80,6 +84,19 @@ const useStyles = makeStyles((t) => ({
|
|
|
80
84
|
color: t.colors.mutedForeground,
|
|
81
85
|
},
|
|
82
86
|
trailing: { flexDirection: 'row', alignItems: 'center', gap: t.space[2] },
|
|
87
|
+
mark: {
|
|
88
|
+
width: MARK,
|
|
89
|
+
height: MARK,
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
borderWidth: 1.5,
|
|
93
|
+
borderColor: t.colors.input,
|
|
94
|
+
backgroundColor: t.colors.surface,
|
|
95
|
+
},
|
|
96
|
+
check: { borderRadius: t.radius.sm },
|
|
97
|
+
radio: { borderRadius: t.radius.full },
|
|
98
|
+
checkOn: { borderColor: t.colors.primary, backgroundColor: t.colors.primary },
|
|
99
|
+
radioOn: { borderWidth: 6, borderColor: t.colors.primary },
|
|
83
100
|
strong: { color: t.colors.foreground, fontWeight: '700' },
|
|
84
101
|
}));
|
|
85
102
|
|
|
@@ -97,6 +114,9 @@ export function ListRow({
|
|
|
97
114
|
highlighted = false,
|
|
98
115
|
strong = false,
|
|
99
116
|
titleLines = 1,
|
|
117
|
+
selection,
|
|
118
|
+
selected = false,
|
|
119
|
+
leadingTone = 'muted',
|
|
100
120
|
onPress,
|
|
101
121
|
style,
|
|
102
122
|
...rest
|
|
@@ -108,9 +128,39 @@ export function ListRow({
|
|
|
108
128
|
const lines = [overline, description].filter(Boolean).length;
|
|
109
129
|
const height = lines === 2 ? s.threeLine : lines === 1 ? s.twoLine : null;
|
|
110
130
|
|
|
131
|
+
const selectionProps = selection
|
|
132
|
+
? ({
|
|
133
|
+
accessibilityRole: selection === 'check' ? 'checkbox' : 'radio',
|
|
134
|
+
accessibilityState: { checked: selected },
|
|
135
|
+
} as const)
|
|
136
|
+
: undefined;
|
|
137
|
+
|
|
111
138
|
const content = (
|
|
112
139
|
<>
|
|
113
|
-
{
|
|
140
|
+
{selection ? (
|
|
141
|
+
<View
|
|
142
|
+
style={[
|
|
143
|
+
s.mark,
|
|
144
|
+
s[selection],
|
|
145
|
+
selected && (selection === 'check' ? s.checkOn : s.radioOn),
|
|
146
|
+
]}
|
|
147
|
+
>
|
|
148
|
+
{selected && selection === 'check' ? (
|
|
149
|
+
<CheckGlyph
|
|
150
|
+
color={t.colors.primaryForeground}
|
|
151
|
+
size={t.iconSize.sm}
|
|
152
|
+
/>
|
|
153
|
+
) : null}
|
|
154
|
+
</View>
|
|
155
|
+
) : null}
|
|
156
|
+
{leading
|
|
157
|
+
? renderIcon(
|
|
158
|
+
leading,
|
|
159
|
+
leadingTone === 'point'
|
|
160
|
+
? { ...icon, color: t.colors.primary }
|
|
161
|
+
: icon
|
|
162
|
+
)
|
|
163
|
+
: null}
|
|
114
164
|
{image !== undefined ? (
|
|
115
165
|
<Photo
|
|
116
166
|
source={{ uri: image ?? '' }}
|
|
@@ -191,6 +241,7 @@ export function ListRow({
|
|
|
191
241
|
return (
|
|
192
242
|
<PressableBase
|
|
193
243
|
{...rest}
|
|
244
|
+
{...selectionProps}
|
|
194
245
|
onPress={onPress}
|
|
195
246
|
pressedStyle={s.pressed}
|
|
196
247
|
style={[
|