@vendure-io/ui 3.0.0-next.4 → 3.0.0-next.6
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/package.json +12 -11
- package/src/components/atoms/alert-dialog.tsx +1 -4
- package/src/components/atoms/alert.tsx +59 -35
- package/src/components/atoms/badge.tsx +2 -2
- package/src/components/atoms/breadcrumb.tsx +154 -59
- package/src/components/atoms/button-group.tsx +1 -1
- package/src/components/atoms/button.tsx +2 -2
- package/src/components/atoms/calendar.tsx +2 -2
- package/src/components/atoms/card.tsx +15 -2
- package/src/components/atoms/carousel.tsx +33 -7
- package/src/components/atoms/chart.tsx +3 -3
- package/src/components/atoms/checkbox.tsx +1 -1
- package/src/components/atoms/combobox.tsx +60 -36
- package/src/components/atoms/command.tsx +17 -7
- package/src/components/atoms/context-menu.tsx +5 -5
- package/src/components/atoms/dialog.tsx +30 -14
- package/src/components/atoms/dropdown-menu.tsx +1 -1
- package/src/components/atoms/hover-card.tsx +1 -1
- package/src/components/atoms/input-group.tsx +30 -12
- package/src/components/atoms/input-otp.tsx +2 -2
- package/src/components/atoms/input.tsx +13 -3
- package/src/components/atoms/menubar.tsx +2 -2
- package/src/components/atoms/native-select.tsx +1 -1
- package/src/components/atoms/navigation-menu.tsx +3 -3
- package/src/components/atoms/pagination.tsx +52 -15
- package/src/components/atoms/popover.tsx +1 -1
- package/src/components/atoms/select.tsx +3 -3
- package/src/components/atoms/sheet.tsx +35 -15
- package/src/components/atoms/sidebar.tsx +224 -36
- package/src/components/atoms/skeleton.tsx +6 -3
- package/src/components/atoms/spinner.tsx +7 -2
- package/src/components/atoms/tabs.tsx +6 -2
- package/src/components/atoms/textarea.tsx +1 -1
- package/src/components/atoms/toggle.tsx +1 -1
- package/src/components/molecules/action-needed.tsx +483 -0
- package/src/components/molecules/anonymized-token.tsx +70 -25
- package/src/components/molecules/app-shell.tsx +14 -5
- package/src/components/molecules/checklist/checklist.tsx +47 -17
- package/src/components/molecules/chip.tsx +37 -19
- package/src/components/molecules/choice-card.tsx +117 -9
- package/src/components/molecules/code-block/package-manager-storage.ts +50 -0
- package/src/components/molecules/code-block/process-code.ts +1 -1
- package/src/components/molecules/code-block.tsx +58 -47
- package/src/components/molecules/combobox-free-text.tsx +75 -20
- package/src/components/molecules/confirm-dialog.tsx +17 -5
- package/src/components/molecules/copyable-text.tsx +10 -8
- package/src/components/molecules/data-table/data-table-filters.tsx +36 -6
- package/src/components/molecules/data-table/data-table-helpers.tsx +109 -3
- package/src/components/molecules/data-table/data-table-row-count-storage.tsx +88 -0
- package/src/components/molecules/data-table/data-table-selection-storage.tsx +33 -15
- package/src/components/molecules/data-table/data-table-types.tsx +156 -29
- package/src/components/molecules/data-table/data-table-view-options.tsx +14 -4
- package/src/components/molecules/data-table/data-table.tsx +156 -75
- package/src/components/molecules/data-table/table-pagination.tsx +142 -38
- package/src/components/molecules/date-picker.tsx +58 -25
- package/src/components/molecules/date-range-picker.tsx +59 -24
- package/src/components/molecules/date-time-picker.tsx +63 -25
- package/src/components/molecules/date-time.tsx +38 -3
- package/src/components/molecules/elapsed-time.tsx +61 -12
- package/src/components/molecules/file-dropzone.tsx +151 -40
- package/src/components/molecules/format-provider.tsx +14 -4
- package/src/components/molecules/id-chip-chrome.tsx +114 -0
- package/src/components/molecules/id-chip.tsx +13 -115
- package/src/components/molecules/issued-secret.tsx +35 -25
- package/src/components/molecules/live-indicator.tsx +1 -1
- package/src/components/molecules/money.tsx +44 -3
- package/src/components/molecules/multi-select.tsx +62 -16
- package/src/components/molecules/page-header.tsx +6 -2
- package/src/components/molecules/password-input.tsx +11 -10
- package/src/components/molecules/relative-time.tsx +88 -16
- package/src/components/molecules/search-trigger.tsx +5 -3
- package/src/components/molecules/secret-value.tsx +35 -19
- package/src/components/molecules/skip-link.tsx +11 -9
- package/src/components/molecules/stat-card.tsx +145 -33
- package/src/components/molecules/state-views/empty-state.tsx +16 -12
- package/src/components/molecules/state-views/error-state.tsx +36 -20
- package/src/components/molecules/state-views/loading-state.tsx +18 -6
- package/src/components/molecules/state-views/skeleton-parts.tsx +6 -4
- package/src/components/molecules/status-badge.tsx +11 -35
- package/src/components/molecules/time-tooltip.tsx +55 -1
- package/src/hooks/use-copy.ts +3 -1
- package/src/lib/deprecated.ts +71 -0
- package/src/lib/field-surface.ts +7 -7
- package/src/lib/format-messages.ts +368 -0
- package/src/lib/highlight.ts +1 -1
- package/src/lib/menu-item.tsx +1 -1
- package/src/lib/tint-recipes.ts +10 -5
- package/src/lib/utils.ts +19 -1
- package/src/lib/dialog-padding.ts +0 -48
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { useFormatSettings } from '@vendure-io/ui/components/molecules/format-provider';
|
|
2
|
+
|
|
3
|
+
// Every English default text in the library, nested by component. A component
|
|
4
|
+
// that gains a text adds its group here; the `FormatMessages` type follows.
|
|
5
|
+
// List the new texts in the FormatProvider section of `docs/ui-components.md`.
|
|
6
|
+
const defaultMessages = {
|
|
7
|
+
breadcrumb: {
|
|
8
|
+
/** The loading row of a crumb menu, and the pending crumb's status. */
|
|
9
|
+
loading: 'Loading…',
|
|
10
|
+
/** The row of a BreadcrumbSearchMenu that reads the options again. */
|
|
11
|
+
retry: 'Retry',
|
|
12
|
+
/** BreadcrumbSearchMenu's row when the search matches no option. */
|
|
13
|
+
empty: 'No results.',
|
|
14
|
+
/** BreadcrumbSearchMenu's search placeholder. `{label}` is the menu's `label`, in lower case. */
|
|
15
|
+
search: 'Find {label}…',
|
|
16
|
+
/** Screen-reader text of BreadcrumbEllipsis. */
|
|
17
|
+
more: 'More',
|
|
18
|
+
/** Accessible name of the Breadcrumb landmark. */
|
|
19
|
+
nav: 'breadcrumb',
|
|
20
|
+
},
|
|
21
|
+
codeBlock: {
|
|
22
|
+
copyCode: 'Copy code',
|
|
23
|
+
copied: 'Copied!',
|
|
24
|
+
/** Header of a shell block with no filename and no package-manager tabs. */
|
|
25
|
+
terminal: 'Terminal',
|
|
26
|
+
/** Header of a block with no filename and no language. */
|
|
27
|
+
code: 'Code',
|
|
28
|
+
showLess: 'Show less',
|
|
29
|
+
/** `{count}` is the number of hidden lines, formatted with `FormatProvider`'s `locale`. */
|
|
30
|
+
showMore: 'Show {count} more lines',
|
|
31
|
+
},
|
|
32
|
+
combobox: {
|
|
33
|
+
/** Announced while a page of options loads. */
|
|
34
|
+
loading: 'Loading…',
|
|
35
|
+
/** Accessible name of ComboboxInput's icon-only open button. */
|
|
36
|
+
open: 'Open options',
|
|
37
|
+
/** Accessible name of the icon-only clear button. */
|
|
38
|
+
clear: 'Clear',
|
|
39
|
+
/** Accessible name of a ComboboxChip's remove button. */
|
|
40
|
+
remove: 'Remove',
|
|
41
|
+
},
|
|
42
|
+
comboboxFreeText: {
|
|
43
|
+
/** Announced by the field's spinner while suggestions load. */
|
|
44
|
+
loading: 'Loading…',
|
|
45
|
+
},
|
|
46
|
+
confirmDialog: {
|
|
47
|
+
/** Screen-reader text of the spinner while the confirm action runs. */
|
|
48
|
+
loading: 'Loading',
|
|
49
|
+
confirm: 'Confirm',
|
|
50
|
+
cancel: 'Cancel',
|
|
51
|
+
},
|
|
52
|
+
copyButton: {
|
|
53
|
+
copy: 'Copy',
|
|
54
|
+
copied: 'Copied',
|
|
55
|
+
},
|
|
56
|
+
loadingState: {
|
|
57
|
+
/** Screen-reader text of the loading region. */
|
|
58
|
+
loading: 'Loading…',
|
|
59
|
+
},
|
|
60
|
+
multiSelect: {
|
|
61
|
+
/** Stands in for the selected values while the options load. */
|
|
62
|
+
loading: 'Loading…',
|
|
63
|
+
/** The trigger's text when nothing is selected. */
|
|
64
|
+
placeholder: 'Select…',
|
|
65
|
+
},
|
|
66
|
+
passwordInput: {
|
|
67
|
+
showPassword: 'Show password',
|
|
68
|
+
hidePassword: 'Hide password',
|
|
69
|
+
},
|
|
70
|
+
secretValue: {
|
|
71
|
+
/** Screen-reader text of the spinner while the value loads. */
|
|
72
|
+
loading: 'Loading',
|
|
73
|
+
/** Accessible name while the value is masked. */
|
|
74
|
+
hidden: 'Hidden value',
|
|
75
|
+
/** Accessible name of the reveal button. */
|
|
76
|
+
show: 'Show value',
|
|
77
|
+
/** Accessible name of the button that masks the value again. */
|
|
78
|
+
hide: 'Hide value',
|
|
79
|
+
copy: 'Copy value',
|
|
80
|
+
copied: 'Value copied',
|
|
81
|
+
/** Shown when `loadValue` rejects. */
|
|
82
|
+
loadError: "Couldn't load the value.",
|
|
83
|
+
},
|
|
84
|
+
searchTrigger: {
|
|
85
|
+
label: 'Search',
|
|
86
|
+
/** Added to the accessible name in brackets: "Search (command palette)". */
|
|
87
|
+
commandPalette: 'command palette',
|
|
88
|
+
},
|
|
89
|
+
statCard: {
|
|
90
|
+
/** Read before the delta when it rose; the arrow is visual-only. */
|
|
91
|
+
up: 'up',
|
|
92
|
+
/** Read before the delta when it fell. */
|
|
93
|
+
down: 'down',
|
|
94
|
+
/** Screen-reader text while the value loads (`value={undefined}`). */
|
|
95
|
+
loading: 'Loading value',
|
|
96
|
+
},
|
|
97
|
+
money: {
|
|
98
|
+
/** Screen-reader text while the amount loads (`value={undefined}`). */
|
|
99
|
+
loading: 'Loading amount',
|
|
100
|
+
},
|
|
101
|
+
anonymizedToken: {
|
|
102
|
+
/** Screen-reader text while the token loads (`value={undefined}`). */
|
|
103
|
+
loading: 'Loading token',
|
|
104
|
+
/** Accessible name while the preview is blurred. */
|
|
105
|
+
obscured: 'Partially obscured token',
|
|
106
|
+
/** Accessible name while the preview is sharp. */
|
|
107
|
+
preview: 'Partially visible token',
|
|
108
|
+
copy: 'Copy token',
|
|
109
|
+
copied: 'Token copied',
|
|
110
|
+
},
|
|
111
|
+
dateTime: {
|
|
112
|
+
/** Screen-reader text while the date loads (`value={undefined}`). */
|
|
113
|
+
loading: 'Loading date',
|
|
114
|
+
},
|
|
115
|
+
relativeTime: {
|
|
116
|
+
/** Screen-reader text while the time loads (`value={undefined}`). */
|
|
117
|
+
loading: 'Loading time',
|
|
118
|
+
},
|
|
119
|
+
elapsedTime: {
|
|
120
|
+
/** Screen-reader text while the start loads (`from={undefined}`). */
|
|
121
|
+
loading: 'Loading duration',
|
|
122
|
+
},
|
|
123
|
+
datePicker: {
|
|
124
|
+
/** Accessible name of the button that clears the date. */
|
|
125
|
+
clear: 'Clear date',
|
|
126
|
+
/** The trigger's text with no date. */
|
|
127
|
+
placeholder: 'Pick a date',
|
|
128
|
+
},
|
|
129
|
+
dateTimePicker: {
|
|
130
|
+
/** Accessible name of the button that clears the date and time. */
|
|
131
|
+
clear: 'Clear date and time',
|
|
132
|
+
/** Accessible name of the time field. */
|
|
133
|
+
time: 'Time',
|
|
134
|
+
/** The trigger's text with no date. */
|
|
135
|
+
placeholder: 'Pick a date and time',
|
|
136
|
+
},
|
|
137
|
+
dateRangePicker: {
|
|
138
|
+
/** Accessible name of the button that clears the range. */
|
|
139
|
+
clear: 'Clear date range',
|
|
140
|
+
/** The trigger's text with no range. */
|
|
141
|
+
placeholder: 'Pick a date range',
|
|
142
|
+
},
|
|
143
|
+
fileDropzone: {
|
|
144
|
+
typeNotAccepted: 'This file type is not accepted.',
|
|
145
|
+
/** `{size}` is the largest allowed size, in the `byte`, `kilobyte` or `megabyte` unit. */
|
|
146
|
+
fileTooLarge: 'File size must be {size} or smaller.',
|
|
147
|
+
/** `{max}` is the file limit. Used when it is more than one. */
|
|
148
|
+
tooManyFiles: 'You can select up to {max} files.',
|
|
149
|
+
/** `{max}` is the file limit. Used when it is one. */
|
|
150
|
+
tooManyFilesOne: 'You can select up to {max} file.',
|
|
151
|
+
/** Shown when `validateFile` throws. */
|
|
152
|
+
validationFailed: 'This file could not be validated.',
|
|
153
|
+
/** Replaces the drop prompt while `validateFile` runs. */
|
|
154
|
+
checking: 'Checking files…',
|
|
155
|
+
/** Placed before the `accept` list. */
|
|
156
|
+
accepted: 'Accepted:',
|
|
157
|
+
/** Accessible name of a file's remove button. `{name}` is the file name. */
|
|
158
|
+
remove: 'Remove {name}',
|
|
159
|
+
/** File size units. The number follows `FormatProvider`'s `locale`. */
|
|
160
|
+
byte: 'B',
|
|
161
|
+
kilobyte: 'KB',
|
|
162
|
+
megabyte: 'MB',
|
|
163
|
+
/** The field's label. */
|
|
164
|
+
label: 'Upload files',
|
|
165
|
+
/** The drop prompt. */
|
|
166
|
+
empty: 'Drag and drop files here, or choose files',
|
|
167
|
+
/** The drop prompt while files are dragged over. */
|
|
168
|
+
drag: 'Drop files to add them',
|
|
169
|
+
},
|
|
170
|
+
dataTable: {
|
|
171
|
+
/** Placeholder and accessible name of the filter editor's default value input. */
|
|
172
|
+
filterValue: 'Value',
|
|
173
|
+
/** The row of a loaded table with no rows. */
|
|
174
|
+
empty: 'No results',
|
|
175
|
+
/** Accessible name of the header checkbox. */
|
|
176
|
+
selectAllRows: 'Select all rows',
|
|
177
|
+
/** Tooltip on the header checkbox while not every row on the page is selected. */
|
|
178
|
+
selectAllOnPage: 'Select all on this page',
|
|
179
|
+
/** Tooltip on the header checkbox while every row on the page is selected. */
|
|
180
|
+
clearPageSelection: 'Clear selection on this page',
|
|
181
|
+
/** Accessible name of a row's checkbox. `{row}` is the 1-based row number. */
|
|
182
|
+
selectRow: 'Select row {row}',
|
|
183
|
+
/** Screen-reader header of the row actions column. */
|
|
184
|
+
rowActions: 'Open row actions',
|
|
185
|
+
/** DataTableViewOptions' trigger. */
|
|
186
|
+
columnsTrigger: 'Columns',
|
|
187
|
+
/** DataTableViewOptions' menu heading. */
|
|
188
|
+
columnsHeading: 'Toggle columns',
|
|
189
|
+
/** DataTableAddFilter's trigger. */
|
|
190
|
+
addFilter: 'Add filter',
|
|
191
|
+
/** The button that clears every filter. */
|
|
192
|
+
clearFilters: 'Clear filters',
|
|
193
|
+
/** Accessible name of an applied filter's remove button. `{column}` is the column's label. */
|
|
194
|
+
removeFilter: 'Remove {column} filter',
|
|
195
|
+
/** Accessible name of a sortable header. `{column}` is the column's label. */
|
|
196
|
+
sortLabel: 'Sort by {column}',
|
|
197
|
+
/** The chip that holds the filters past `inlineChipLimit`. `{count}` is their number. */
|
|
198
|
+
filtersCollapsed: '{count} filters',
|
|
199
|
+
},
|
|
200
|
+
tablePagination: {
|
|
201
|
+
/** Accessible name of the prev/next navigation landmark. */
|
|
202
|
+
nav: 'Pagination',
|
|
203
|
+
/** Accessible name of the previous-page control. */
|
|
204
|
+
previous: 'Go to previous page',
|
|
205
|
+
/** Accessible name of the next-page control. */
|
|
206
|
+
next: 'Go to next page',
|
|
207
|
+
/** Visible and accessible name of the page-size selector. */
|
|
208
|
+
pageSize: 'Items per page',
|
|
209
|
+
/** The range text. `{start}`, `{end}` and `{total}` are formatted numbers. */
|
|
210
|
+
range: '{start}–{end} of {total}',
|
|
211
|
+
/** The range text of an empty list. */
|
|
212
|
+
rangeEmpty: '0 of 0',
|
|
213
|
+
},
|
|
214
|
+
checklist: {
|
|
215
|
+
/** Accessible name of the dismiss button. */
|
|
216
|
+
dismiss: 'Dismiss checklist',
|
|
217
|
+
/** Label of the group of finished steps. */
|
|
218
|
+
completed: 'Completed',
|
|
219
|
+
/** Read after a done step's label in system mode. */
|
|
220
|
+
stepDone: 'done',
|
|
221
|
+
/** Read after an open step's label in system mode. */
|
|
222
|
+
stepOpen: 'not done',
|
|
223
|
+
/** The count beside the title. `{done}` and `{total}` are step counts. */
|
|
224
|
+
count: '{done} of {total}',
|
|
225
|
+
/** Announced when the count changes. */
|
|
226
|
+
announcement: '{done} of {total} steps done',
|
|
227
|
+
},
|
|
228
|
+
errorState: {
|
|
229
|
+
/** The headline. */
|
|
230
|
+
title: 'Something went wrong',
|
|
231
|
+
/** The retry button. */
|
|
232
|
+
retry: 'Try again',
|
|
233
|
+
},
|
|
234
|
+
idChip: {
|
|
235
|
+
/** The tooltip before copying. The copy button's name adds the shown text: "Copy 9f2c4e1". */
|
|
236
|
+
copy: 'Copy',
|
|
237
|
+
copied: 'Copied',
|
|
238
|
+
},
|
|
239
|
+
issuedSecret: {
|
|
240
|
+
/** The copy button with one value. `{secret}` is the `secretName`. */
|
|
241
|
+
copy: 'Copy {secret}',
|
|
242
|
+
copied: 'Copied',
|
|
243
|
+
/** `{secret}` is the `secretName`. */
|
|
244
|
+
notice: 'You can copy the {secret} only now.',
|
|
245
|
+
/** `{secret}` is the `secretName`. */
|
|
246
|
+
fallbackDescription: 'The clipboard is not available. Select the {secret} and copy it by hand.',
|
|
247
|
+
/** `{secret}` is the `secretName`. */
|
|
248
|
+
warningTitle: 'The {secret} is not copied',
|
|
249
|
+
warningDescription:
|
|
250
|
+
'You cannot copy it after you close. Copy it now, or close without copying.',
|
|
251
|
+
/** IssuedSecretFooter's button. */
|
|
252
|
+
done: 'Done',
|
|
253
|
+
/** IssuedSecretFooter's button after the warning. */
|
|
254
|
+
closeAnyway: 'Close without copying',
|
|
255
|
+
},
|
|
256
|
+
pagination: {
|
|
257
|
+
/** Accessible name of the Pagination landmark. */
|
|
258
|
+
nav: 'pagination',
|
|
259
|
+
/** Accessible name of PaginationPrevious. */
|
|
260
|
+
previous: 'Go to previous page',
|
|
261
|
+
/** Visible text of PaginationPrevious. */
|
|
262
|
+
previousText: 'Previous',
|
|
263
|
+
/** Accessible name of PaginationNext. */
|
|
264
|
+
next: 'Go to next page',
|
|
265
|
+
/** Visible text of PaginationNext. */
|
|
266
|
+
nextText: 'Next',
|
|
267
|
+
/** Screen-reader text of PaginationEllipsis. */
|
|
268
|
+
more: 'More pages',
|
|
269
|
+
},
|
|
270
|
+
skipLink: {
|
|
271
|
+
label: 'Skip to main content',
|
|
272
|
+
},
|
|
273
|
+
spinner: {
|
|
274
|
+
/** The spinner's accessible name. */
|
|
275
|
+
loading: 'Loading',
|
|
276
|
+
},
|
|
277
|
+
dialog: {
|
|
278
|
+
/** Accessible name of the ✕, and the text of DialogFooter's Close button. */
|
|
279
|
+
close: 'Close',
|
|
280
|
+
},
|
|
281
|
+
sheet: {
|
|
282
|
+
/** Accessible name of the ✕. */
|
|
283
|
+
close: 'Close',
|
|
284
|
+
},
|
|
285
|
+
sidebar: {
|
|
286
|
+
/** Screen-reader title of the mobile Sidebar's sheet. */
|
|
287
|
+
mobileTitle: 'Sidebar',
|
|
288
|
+
/** Screen-reader description of the mobile Sidebar's sheet. */
|
|
289
|
+
mobileDescription: 'Displays the mobile sidebar.',
|
|
290
|
+
/** Accessible name of SidebarTrigger and SidebarRail, and SidebarRail's tooltip. */
|
|
291
|
+
toggle: 'Toggle Sidebar',
|
|
292
|
+
},
|
|
293
|
+
carousel: {
|
|
294
|
+
/** Screen-reader text of CarouselPrevious. */
|
|
295
|
+
previous: 'Previous slide',
|
|
296
|
+
/** Screen-reader text of CarouselNext. */
|
|
297
|
+
next: 'Next slide',
|
|
298
|
+
/** The Carousel region's `aria-roledescription`. */
|
|
299
|
+
region: 'carousel',
|
|
300
|
+
/** A CarouselItem's `aria-roledescription`. */
|
|
301
|
+
slide: 'slide',
|
|
302
|
+
},
|
|
303
|
+
command: {
|
|
304
|
+
/** Screen-reader title of CommandDialog. */
|
|
305
|
+
title: 'Command Palette',
|
|
306
|
+
/** Screen-reader description of CommandDialog. */
|
|
307
|
+
description: 'Search for a command to run...',
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
type DefaultMessages = typeof defaultMessages;
|
|
312
|
+
type MessageGroup = keyof DefaultMessages;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* The texts an app passes to `FormatProvider`'s `messages`. Every group and
|
|
316
|
+
* every text is optional; a missing one falls back to English. An unknown
|
|
317
|
+
* group or text is a type error.
|
|
318
|
+
*/
|
|
319
|
+
type FormatMessages = {
|
|
320
|
+
[Group in MessageGroup]?: { [Key in keyof DefaultMessages[Group]]?: string };
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
type ResolvedMessages<Group extends MessageGroup> = {
|
|
324
|
+
[Key in keyof DefaultMessages[Group]]: string;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* The texts of one component, resolved in a fixed order: the component's own
|
|
329
|
+
* label prop (`overrides`) → `FormatProvider`'s `messages` → the English
|
|
330
|
+
* default. Without a provider it returns the English defaults, so it is safe
|
|
331
|
+
* on the server and in tests.
|
|
332
|
+
*
|
|
333
|
+
* ```tsx
|
|
334
|
+
* const t = useMessages('passwordInput', {
|
|
335
|
+
* showPassword: showPasswordLabel,
|
|
336
|
+
* hidePassword: hidePasswordLabel,
|
|
337
|
+
* });
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
function useMessages<Group extends MessageGroup>(
|
|
341
|
+
group: Group,
|
|
342
|
+
overrides?: Partial<Record<keyof DefaultMessages[Group], string | undefined>>,
|
|
343
|
+
): ResolvedMessages<Group> {
|
|
344
|
+
const fromProvider = useFormatSettings().messages?.[group];
|
|
345
|
+
const resolved = { ...defaultMessages[group] } as Record<string, string>;
|
|
346
|
+
for (const layer of [fromProvider, overrides] as (
|
|
347
|
+
| Record<string, string | undefined>
|
|
348
|
+
| undefined
|
|
349
|
+
)[]) {
|
|
350
|
+
if (!layer) continue;
|
|
351
|
+
for (const [key, text] of Object.entries(layer)) {
|
|
352
|
+
if (text !== undefined) resolved[key] = text;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return resolved as ResolvedMessages<Group>;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export { defaultMessages, useMessages };
|
|
359
|
+
export type { FormatMessages };
|
|
360
|
+
|
|
361
|
+
/** Replaces each `{key}` in a message with its value. An unknown key stays as written. */
|
|
362
|
+
function fillMessage(template: string, values: Record<string, string | number>): string {
|
|
363
|
+
return template.replace(/\{(\w+)\}/g, (match, key: string) =>
|
|
364
|
+
key in values ? String(values[key]) : match,
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export { fillMessage };
|
package/src/lib/highlight.ts
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
transformerNotationHighlight,
|
|
6
6
|
transformerNotationWordHighlight,
|
|
7
7
|
} from '@shikijs/transformers';
|
|
8
|
-
import { githubLightReplacements } from '@vendure-io/ui/lib/syntax-colors';
|
|
9
8
|
import { createHighlighterCore } from 'shiki/core';
|
|
10
9
|
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
|
10
|
+
import { githubLightReplacements } from './syntax-colors.ts';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The design system's Shiki setup: a lazy shared highlighter with the DS themes
|
package/src/lib/menu-item.tsx
CHANGED
|
@@ -21,7 +21,7 @@ export const menuItemDisabled =
|
|
|
21
21
|
*/
|
|
22
22
|
export const menuItem = cn(
|
|
23
23
|
menuItemDisabled,
|
|
24
|
-
"not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2.5 rounded-
|
|
24
|
+
"not-data-disabled:focus:bg-muted not-data-disabled:focus:text-accent-foreground relative flex min-h-8.5 cursor-default items-center gap-2.5 rounded-[calc(var(--radius-2xl)-5px)] px-2 py-1.5 text-sm text-foreground-secondary outline-hidden select-none focus-visible:outline-solid focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.75 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:focus:[&>svg:not([class*='opacity-'])]:opacity-85",
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
/**
|
package/src/lib/tint-recipes.ts
CHANGED
|
@@ -57,12 +57,17 @@ export const alertTint =
|
|
|
57
57
|
'text-foreground [--alert-fill:color-mix(in_oklab,var(--alert-tone)_7%,var(--card))] [--alert-border:color-mix(in_oklab,var(--alert-tone)_14%,var(--border))] dark:[--alert-fill:color-mix(in_oklab,var(--alert-tone)_10%,transparent)] dark:[--alert-border:color-mix(in_oklab,var(--alert-tone)_30%,transparent)] bg-(color:--alert-fill) border-(color:--alert-border)';
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* The tone and icon colour of each
|
|
61
|
-
*
|
|
62
|
-
*
|
|
60
|
+
* The tone and icon colour of each Alert tone, keyed by the state dictionary's
|
|
61
|
+
* tones. The tones match StatusBadge: `critical` tints with `destructive-text`
|
|
62
|
+
* and `progress` with `info-text`. Warning tints with the brighter
|
|
63
|
+
* `warning-indicator` (an amber text colour mixes to brown) and takes its icon
|
|
64
|
+
* from `warning-text`.
|
|
63
65
|
*/
|
|
64
66
|
export const alertToneVars = {
|
|
65
|
-
|
|
66
|
-
warning: '[--alert-tone:var(--warning-indicator)] *:[svg]:text-warning-text',
|
|
67
|
+
neutral: '[--alert-tone:var(--neutral-text)] *:[svg]:text-neutral-text',
|
|
67
68
|
info: '[--alert-tone:var(--info-text)] *:[svg]:text-info-text',
|
|
69
|
+
success: '[--alert-tone:var(--success-text)] *:[svg]:text-success-text',
|
|
70
|
+
warning: '[--alert-tone:var(--warning-indicator)] *:[svg]:text-warning-text',
|
|
71
|
+
critical: '[--alert-tone:var(--destructive-text)] *:[svg]:text-destructive-text',
|
|
72
|
+
progress: '[--alert-tone:var(--info-text)] *:[svg]:text-info-text',
|
|
68
73
|
};
|
package/src/lib/utils.ts
CHANGED
|
@@ -12,7 +12,17 @@ const twMerge = extendTailwindMerge<'text-style'>({
|
|
|
12
12
|
extend: {
|
|
13
13
|
theme: {
|
|
14
14
|
shadow: ['control', 'overlay', 'scrolled'],
|
|
15
|
-
ease: [
|
|
15
|
+
ease: [
|
|
16
|
+
'default',
|
|
17
|
+
'spring',
|
|
18
|
+
'drawer',
|
|
19
|
+
'drawer-content',
|
|
20
|
+
'height',
|
|
21
|
+
'press',
|
|
22
|
+
'soft',
|
|
23
|
+
'flash',
|
|
24
|
+
'fold',
|
|
25
|
+
],
|
|
16
26
|
animate: [
|
|
17
27
|
'shimmer',
|
|
18
28
|
'spin-slow',
|
|
@@ -63,6 +73,14 @@ const twMerge = extendTailwindMerge<'text-style'>({
|
|
|
63
73
|
'drawer-slide',
|
|
64
74
|
'drawer-swipe',
|
|
65
75
|
'alert-enter',
|
|
76
|
+
'fold-open',
|
|
77
|
+
'fold-close',
|
|
78
|
+
'fold-row-in',
|
|
79
|
+
'fold-row-out',
|
|
80
|
+
'fold-badge-in',
|
|
81
|
+
'fold-hand-off',
|
|
82
|
+
'fold-stagger',
|
|
83
|
+
'fold-step',
|
|
66
84
|
'button-icon-turn',
|
|
67
85
|
'external-arrow',
|
|
68
86
|
'page-fade',
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type * as React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The value of the last unconditional `p-*` or `px-*` class in `className`,
|
|
5
|
-
* as CSS: `p-0` → `0px`, `p-4` → `calc(var(--spacing) * 4)`, `p-px` → `1px`,
|
|
6
|
-
* `p-[24px]` → `24px`, `p-(--gap)` → `var(--gap)`. `undefined` when there is
|
|
7
|
-
* none. Classes with a variant (`sm:p-0`) are skipped: an inline style
|
|
8
|
-
* cannot follow a breakpoint.
|
|
9
|
-
*/
|
|
10
|
-
export function paddingFromClassName(className: unknown): string | undefined {
|
|
11
|
-
if (typeof className !== 'string') return undefined;
|
|
12
|
-
let value: string | undefined;
|
|
13
|
-
for (const token of className.split(/\s+/)) {
|
|
14
|
-
const match = /^!?px?-(.+?)!?$/.exec(token);
|
|
15
|
-
if (!match || token.includes(':')) continue;
|
|
16
|
-
const raw = match[1] as string;
|
|
17
|
-
if (raw === 'px') value = '1px';
|
|
18
|
-
else if (/^\d+(\.\d+)?$/.test(raw))
|
|
19
|
-
value = raw === '0' ? '0px' : `calc(var(--spacing) * ${raw})`;
|
|
20
|
-
else if (raw.startsWith('[') && raw.endsWith(']')) value = raw.slice(1, -1).replace(/_/g, ' ');
|
|
21
|
-
else if (raw.startsWith('(--') && raw.endsWith(')')) value = `var(${raw.slice(1, -1)})`;
|
|
22
|
-
}
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type StyleProp<State> =
|
|
27
|
-
| React.CSSProperties
|
|
28
|
-
| ((state: State) => React.CSSProperties | undefined)
|
|
29
|
-
| undefined;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Sets `--dialog-padding` from a `p-*` or `px-*` class on the dialog, so the
|
|
33
|
-
* pinned header and footer, which reach over the padding with negative
|
|
34
|
-
* margins, stay flush with the dialog's edge. Code written for 2.x sets the
|
|
35
|
-
* dialog's padding with a class (`p-0` around a full-bleed picker); without
|
|
36
|
-
* this, its header and footer would stick out by the default 20px. A
|
|
37
|
-
* `[--dialog-padding:…]` class still works: with no `p-*` class, nothing is set.
|
|
38
|
-
*/
|
|
39
|
-
export function dialogPaddingStyle<State>(
|
|
40
|
-
className: unknown,
|
|
41
|
-
style: StyleProp<State>,
|
|
42
|
-
): StyleProp<State> {
|
|
43
|
-
const padding = paddingFromClassName(className);
|
|
44
|
-
if (padding === undefined) return style;
|
|
45
|
-
const variable = { '--dialog-padding': padding } as React.CSSProperties;
|
|
46
|
-
if (typeof style === 'function') return (state: State) => ({ ...variable, ...style(state) });
|
|
47
|
-
return { ...variable, ...style };
|
|
48
|
-
}
|