@tristan2828/ui-foundation 4.140.0 → 4.142.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/conventions/docs/add-an-entity.md +32 -28
- package/conventions/docs/cell-patterns.md +6 -5
- package/conventions/docs/design-language.md +105 -43
- package/conventions/docs/entity-plan-template.md +2 -1
- package/dist/components/app/app-shell-nav.d.ts +13 -5
- package/dist/components/app/app-shell-nav.js +14 -7
- package/dist/components/app/app-shell.d.ts +12 -1
- package/dist/components/app/app-shell.js +7 -5
- package/dist/components/app/date-field.d.ts +3 -0
- package/dist/components/app/date-field.js +12 -6
- package/dist/components/app/edit-in-place-presets.d.ts +2 -0
- package/dist/components/app/edit-in-place-presets.js +2 -2
- package/dist/components/app/fill-in-field.d.ts +7 -2
- package/dist/components/app/fill-in-field.js +4 -4
- package/dist/components/app/filter-date.d.ts +4 -1
- package/dist/components/app/filter-date.js +2 -2
- package/dist/components/app/foundation-providers.d.ts +7 -5
- package/dist/components/app/look-settings.d.ts +24 -0
- package/dist/components/app/look-settings.js +50 -0
- package/dist/components/app/settings-page.d.ts +75 -0
- package/dist/components/app/settings-page.js +69 -0
- package/dist/components/ui/calendar.d.ts +1 -1
- package/dist/components/ui/calendar.js +6 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/palettes.js +3 -3
- package/dist/lib/rows.js +3 -3
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
- Step 8: Add Playwright specs for all three screens · lines 255–335
|
|
17
17
|
- Step 9: Register the nav entry and route names · lines 336–349
|
|
18
18
|
- Step 10: `npm run verify`. · lines 350–351
|
|
19
|
-
- [Step 6 in detail](#step-6-in-detail) · lines 353–
|
|
19
|
+
- [Step 6 in detail](#step-6-in-detail) · lines 353–933
|
|
20
20
|
- [A `reference`](#a-reference) · lines 358–360
|
|
21
21
|
- [A `single choice`](#a-single-choice) · lines 362–368
|
|
22
22
|
- [A `date-time`](#a-date-time) · lines 370–373
|
|
@@ -25,32 +25,32 @@
|
|
|
25
25
|
- [A `multi reference`](#a-multi-reference) · lines 393–405
|
|
26
26
|
- [Sub-records](#sub-records) · lines 407–423
|
|
27
27
|
- [A `computed` field](#a-computed-field) · lines 425–434
|
|
28
|
-
- [A `date`](#a-date) · lines 436–
|
|
29
|
-
- [A `month-day`](#a-month-day) · lines
|
|
30
|
-
- [A `recurrence`](#a-recurrence) · lines
|
|
31
|
-
- [An image on a record](#an-image-on-a-record) · lines
|
|
32
|
-
- [A `reference` inside a sub-record item](#a-reference-inside-a-sub-record-item) · lines
|
|
33
|
-
- [A `yes/no` marked `toggle`](#a-yesno-marked-toggle) · lines
|
|
34
|
-
- [Keep column definitions stable](#keep-column-definitions-stable) · lines
|
|
35
|
-
- [The view](#the-view) · lines
|
|
36
|
-
- [The view: long text and notes](#the-view-long-text-and-notes) · lines
|
|
37
|
-
- [The view: quick actions and editing in place](#the-view-quick-actions-and-editing-in-place) · lines
|
|
38
|
-
- [The table opens the view, and the form returns to it](#the-table-opens-the-view-and-the-form-returns-to-it) · lines
|
|
39
|
-
- [`<SelectValue>` shows the value, not the label](#selectvalue-shows-the-value-not-the-label) · lines
|
|
40
|
-
- [Choosing how each column looks](#choosing-how-each-column-looks) · lines
|
|
41
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines
|
|
42
|
-
- [The record view](#the-record-view) · lines
|
|
43
|
-
- [Forms](#forms) · lines
|
|
44
|
-
- [Dialogs](#dialogs) · lines
|
|
45
|
-
- [Toasts and feedback](#toasts-and-feedback) · lines
|
|
46
|
-
- [What not to copy](#what-not-to-copy) · lines
|
|
47
|
-
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines
|
|
48
|
-
- [Saves that don't overwrite](#saves-that-dont-overwrite) · lines
|
|
49
|
-
- [Deleting](#deleting) · lines
|
|
50
|
-
- [Fields only a script writes](#fields-only-a-script-writes) · lines
|
|
51
|
-
- [Searching one part of the app](#searching-one-part-of-the-app) · lines
|
|
52
|
-
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines
|
|
53
|
-
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines
|
|
28
|
+
- [A `date`](#a-date) · lines 436–457
|
|
29
|
+
- [A `month-day`](#a-month-day) · lines 459–479
|
|
30
|
+
- [A `recurrence`](#a-recurrence) · lines 481–502
|
|
31
|
+
- [An image on a record](#an-image-on-a-record) · lines 504–532
|
|
32
|
+
- [A `reference` inside a sub-record item](#a-reference-inside-a-sub-record-item) · lines 534–593
|
|
33
|
+
- [A `yes/no` marked `toggle`](#a-yesno-marked-toggle) · lines 595–610
|
|
34
|
+
- [Keep column definitions stable](#keep-column-definitions-stable) · lines 612–620
|
|
35
|
+
- [The view](#the-view) · lines 622–740
|
|
36
|
+
- [The view: long text and notes](#the-view-long-text-and-notes) · lines 742–796
|
|
37
|
+
- [The view: quick actions and editing in place](#the-view-quick-actions-and-editing-in-place) · lines 798–856
|
|
38
|
+
- [The table opens the view, and the form returns to it](#the-table-opens-the-view-and-the-form-returns-to-it) · lines 858–869
|
|
39
|
+
- [`<SelectValue>` shows the value, not the label](#selectvalue-shows-the-value-not-the-label) · lines 871–917
|
|
40
|
+
- [Choosing how each column looks](#choosing-how-each-column-looks) · lines 919–933
|
|
41
|
+
- [How a list opens a record](#how-a-list-opens-a-record) · lines 935–1439
|
|
42
|
+
- [The record view](#the-record-view) · lines 1078–1258
|
|
43
|
+
- [Forms](#forms) · lines 1260–1343
|
|
44
|
+
- [Dialogs](#dialogs) · lines 1345–1378
|
|
45
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1380–1439
|
|
46
|
+
- [What not to copy](#what-not-to-copy) · lines 1441–1468
|
|
47
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1470–1487
|
|
48
|
+
- [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1489–1549
|
|
49
|
+
- [Deleting](#deleting) · lines 1551–1581
|
|
50
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1583–1602
|
|
51
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1604–1613
|
|
52
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1616–1658
|
|
53
|
+
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1660–1693
|
|
54
54
|
|
|
55
55
|
<!-- /index -->
|
|
56
56
|
|
|
@@ -449,7 +449,11 @@ date like 3/14 or Mar 14" and gives `''`. Editing in place is
|
|
|
449
449
|
`inPlace.date({ value, save })`: Enter or leaving saves the day typed,
|
|
450
450
|
a day picked in the calendar saves at once. (`typing={false}` is the
|
|
451
451
|
button alone; in place then `editInPlace({ kind: 'choice', ... })` with
|
|
452
|
-
`defaultOpen`, `modal={false}` and `onChange={(day) => props.commit(day)}`.) The
|
|
452
|
+
`defaultOpen`, `modal={false}` and `onChange={(day) => props.commit(day)}`.) The calendar's weeks
|
|
453
|
+
start on Monday. An app whose weeks start on Sunday gives `DateField`,
|
|
454
|
+
`inPlace.date`, `FilterDate` and `FillInField` `weekStart="SU"`, the
|
|
455
|
+
`weekStart` it gives `MonthCalendar` and `RecurrenceField` (a `Calendar`
|
|
456
|
+
of its own takes react-day-picker's `weekStartsOn={0}`). The backend column
|
|
453
457
|
is a SQL `date` (`datetime.date` in the model).
|
|
454
458
|
|
|
455
459
|
### A `month-day`
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1843–1894
|
|
42
42
|
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1896–1970
|
|
43
43
|
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 1916–1970
|
|
44
|
-
- [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1972–
|
|
45
|
-
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines
|
|
46
|
-
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines
|
|
47
|
-
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines
|
|
44
|
+
- [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1972–2184
|
|
45
|
+
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2133–2184
|
|
46
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2186–2220
|
|
47
|
+
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2222–2269
|
|
48
48
|
|
|
49
49
|
<!-- /index -->
|
|
50
50
|
|
|
@@ -2094,7 +2094,8 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
|
|
|
2094
2094
|
inclusive plain days (`{ to: yesterday }`, `{ from: today }`), read
|
|
2095
2095
|
against today when the list loads; its chip's words are
|
|
2096
2096
|
`dateFilterText(value)`. A list filtered in the browser (or a mock) uses
|
|
2097
|
-
`dateFilterKeeps(value, day)`.
|
|
2097
|
+
`dateFilterKeeps(value, day)`. Its calendars' weeks start on Monday,
|
|
2098
|
+
`weekStart="SU"` for Sunday.
|
|
2098
2099
|
|
|
2099
2100
|
```tsx
|
|
2100
2101
|
const VIEWS = {
|
|
@@ -3,47 +3,48 @@
|
|
|
3
3
|
<!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
|
|
4
4
|
## Index
|
|
5
5
|
|
|
6
|
-
- [Palettes](#palettes) · lines
|
|
7
|
-
- [Glow](#glow) · lines
|
|
8
|
-
- [Semantic tones](#semantic-tones) · lines
|
|
9
|
-
- [The three badge styles](#the-three-badge-styles) · lines
|
|
10
|
-
- [Status marks](#status-marks) · lines
|
|
11
|
-
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines
|
|
12
|
-
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines
|
|
13
|
-
- [Logos and brand marks](#logos-and-brand-marks) · lines
|
|
14
|
-
- [Categorical colour](#categorical-colour) · lines
|
|
15
|
-
- [Heat scale](#heat-scale) · lines
|
|
16
|
-
- [Depth ramps](#depth-ramps) · lines
|
|
17
|
-
- [A stored colour](#a-stored-colour) · lines
|
|
18
|
-
- [Shapes and sizes](#shapes-and-sizes) · lines
|
|
19
|
-
- [Typography](#typography) · lines
|
|
20
|
-
- [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines
|
|
21
|
-
- [Written text (notes)](#written-text-notes) · lines
|
|
22
|
-
- [Density](#density) · lines
|
|
23
|
-
- [Rows on this device](#rows-on-this-device) · lines
|
|
24
|
-
- [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines
|
|
25
|
-
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines
|
|
26
|
-
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines
|
|
27
|
-
- [Notices](#notices) · lines
|
|
28
|
-
- [A value over time](#a-value-over-time) · lines
|
|
29
|
-
- [Several values over time](#several-values-over-time) · lines
|
|
30
|
-
- [Parts of a whole over time](#parts-of-a-whole-over-time) · lines
|
|
31
|
-
- [A list as a board](#a-list-as-a-board) · lines
|
|
32
|
-
- [Order, groups and the header](#order-groups-and-the-header) · lines
|
|
33
|
-
- [A list as cards](#a-list-as-cards) · lines
|
|
34
|
-
- [Images full screen](#images-full-screen) · lines
|
|
35
|
-
- [Key numbers on a record](#key-numbers-on-a-record) · lines
|
|
36
|
-
- [Parts of the page standards](#parts-of-the-page-standards) · lines
|
|
37
|
-
- [A few equal things](#a-few-equal-things) · lines
|
|
38
|
-
- [An overview page](#an-overview-page) · lines
|
|
39
|
-
- [A record's header and empty values](#a-records-header-and-empty-values) · lines
|
|
40
|
-
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines
|
|
41
|
-
- [Picking at random](#picking-at-random) · lines
|
|
42
|
-
- [Filling in what's missing](#filling-in-whats-missing) · lines
|
|
43
|
-
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines
|
|
44
|
-
- [A quick add line](#a-quick-add-line) · lines
|
|
45
|
-
- [A month calendar](#a-month-calendar) · lines
|
|
46
|
-
- [
|
|
6
|
+
- [Palettes](#palettes) · lines 57–140
|
|
7
|
+
- [Glow](#glow) · lines 142–161
|
|
8
|
+
- [Semantic tones](#semantic-tones) · lines 163–191
|
|
9
|
+
- [The three badge styles](#the-three-badge-styles) · lines 193–210
|
|
10
|
+
- [Status marks](#status-marks) · lines 212–255
|
|
11
|
+
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 257–286
|
|
12
|
+
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 288–299
|
|
13
|
+
- [Logos and brand marks](#logos-and-brand-marks) · lines 301–341
|
|
14
|
+
- [Categorical colour](#categorical-colour) · lines 343–408
|
|
15
|
+
- [Heat scale](#heat-scale) · lines 410–462
|
|
16
|
+
- [Depth ramps](#depth-ramps) · lines 464–531
|
|
17
|
+
- [A stored colour](#a-stored-colour) · lines 533–580
|
|
18
|
+
- [Shapes and sizes](#shapes-and-sizes) · lines 582–603
|
|
19
|
+
- [Typography](#typography) · lines 605–775
|
|
20
|
+
- [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 639–671
|
|
21
|
+
- [Written text (notes)](#written-text-notes) · lines 673–775
|
|
22
|
+
- [Density](#density) · lines 777–899
|
|
23
|
+
- [Rows on this device](#rows-on-this-device) · lines 844–872
|
|
24
|
+
- [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 874–899
|
|
25
|
+
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 901–1011
|
|
26
|
+
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1013–1085
|
|
27
|
+
- [Notices](#notices) · lines 1087–1114
|
|
28
|
+
- [A value over time](#a-value-over-time) · lines 1116–1246
|
|
29
|
+
- [Several values over time](#several-values-over-time) · lines 1165–1203
|
|
30
|
+
- [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1205–1246
|
|
31
|
+
- [A list as a board](#a-list-as-a-board) · lines 1248–1358
|
|
32
|
+
- [Order, groups and the header](#order-groups-and-the-header) · lines 1301–1358
|
|
33
|
+
- [A list as cards](#a-list-as-cards) · lines 1360–1407
|
|
34
|
+
- [Images full screen](#images-full-screen) · lines 1409–1455
|
|
35
|
+
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1457–1493
|
|
36
|
+
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1495–1531
|
|
37
|
+
- [A few equal things](#a-few-equal-things) · lines 1533–1648
|
|
38
|
+
- [An overview page](#an-overview-page) · lines 1650–1715
|
|
39
|
+
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1717–1780
|
|
40
|
+
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1782–1869
|
|
41
|
+
- [Picking at random](#picking-at-random) · lines 1871–1902
|
|
42
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1904–1971
|
|
43
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1973–1992
|
|
44
|
+
- [A quick add line](#a-quick-add-line) · lines 1994–2022
|
|
45
|
+
- [A month calendar](#a-month-calendar) · lines 2024–2054
|
|
46
|
+
- [A settings page](#a-settings-page) · lines 2056–2113
|
|
47
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2115–2174
|
|
47
48
|
|
|
48
49
|
<!-- /index -->
|
|
49
50
|
|
|
@@ -73,7 +74,8 @@ And one light one, which an app opts into by name (`LIGHT_PALETTES`):
|
|
|
73
74
|
|
|
74
75
|
**How an app picks one.** `<FoundationProviders palette="indigo-cyan">`
|
|
75
76
|
names the app's default. Add `palettePicker` and the app shell's header
|
|
76
|
-
offers the four dark ones (with swatches)
|
|
77
|
+
offers the four dark ones (with swatches), or a page does, as tiles
|
|
78
|
+
(`PaletteSetting`, "A settings page"); the one picked is remembered
|
|
77
79
|
on that device, and a new device starts on the default. `usePalette()`
|
|
78
80
|
reads the palette on screen. Without `palette`, nothing changes: light and
|
|
79
81
|
dark follow the system, with the toggle in the header.
|
|
@@ -844,7 +846,8 @@ set, not a `DataTable` prop:
|
|
|
844
846
|
An app can let each device choose its table rows: `rowsPicker` on
|
|
845
847
|
`FoundationProviders` adds **Rows on this device** to the shell's look
|
|
846
848
|
menu (under the palettes, or a menu of its own beside the light/dark
|
|
847
|
-
toggle in an app without a palette).
|
|
849
|
+
toggle in an app without a palette). `RowsSetting` offers the same choice
|
|
850
|
+
on a page ("A settings page").
|
|
848
851
|
|
|
849
852
|
```tsx
|
|
850
853
|
<FoundationProviders palette="indigo-cyan" palettePicker rowsPicker …>
|
|
@@ -2050,6 +2053,65 @@ package's `MonthCalendar`. Not a date picker, which is
|
|
|
2050
2053
|
- `today` comes from the app's own day (`todayIn`); every day is a plain
|
|
2051
2054
|
`'YYYY-MM-DD'`, so no zone moves one.
|
|
2052
2055
|
|
|
2056
|
+
## A settings page
|
|
2057
|
+
|
|
2058
|
+
One page for what an app lets a person choose: the groups listed down the
|
|
2059
|
+
side, the one you're on beside them as a card of rows. Parts the app puts
|
|
2060
|
+
together, so a group's routes, its rows and where a choice is kept are the
|
|
2061
|
+
app's:
|
|
2062
|
+
|
|
2063
|
+
```tsx
|
|
2064
|
+
const GROUPS = [
|
|
2065
|
+
{ to: '/settings', label: 'Look' },
|
|
2066
|
+
{ to: '/settings/notifications', label: 'Notifications' },
|
|
2067
|
+
]
|
|
2068
|
+
|
|
2069
|
+
// the layout route
|
|
2070
|
+
<SettingsPage title="Settings" groups={GROUPS}><Outlet /></SettingsPage>
|
|
2071
|
+
|
|
2072
|
+
// a group's route
|
|
2073
|
+
<SettingsCard>
|
|
2074
|
+
<SettingsRow
|
|
2075
|
+
label="Text Size"
|
|
2076
|
+
help="For this browser only."
|
|
2077
|
+
control={(aria) => <ChoiceButtons {...aria} options={SIZES} value={size} onValueChange={save} />}
|
|
2078
|
+
/>
|
|
2079
|
+
<PaletteSetting />
|
|
2080
|
+
<RowsSetting />
|
|
2081
|
+
</SettingsCard>
|
|
2082
|
+
```
|
|
2083
|
+
|
|
2084
|
+
- **Each group is a route**, so it has an address, Back and a deep link.
|
|
2085
|
+
The first is the layout's index route, at the page's own address. A
|
|
2086
|
+
group that holds nothing is left out, and has no route: send an unknown
|
|
2087
|
+
path under the page to the first group.
|
|
2088
|
+
- **The current group** is marked as the sidebar marks its entry, a tint
|
|
2089
|
+
and a 3px bar, and stays marked on a page below it. Past the first, the
|
|
2090
|
+
bar's trail reads "Settings / Notifications" and a phone's back arrow
|
|
2091
|
+
goes to the first; a page below a group puts up its own trail.
|
|
2092
|
+
- **In a box under 40rem** (a phone, or a window the sidebar has narrowed)
|
|
2093
|
+
the groups wrap in a row above the card, each 40px tall.
|
|
2094
|
+
- **A row** is its label, one short line of help and its control. Spread
|
|
2095
|
+
what the `control` function is handed on the control: it names it by the
|
|
2096
|
+
label and the help. A control that is one thing (a select, a switch)
|
|
2097
|
+
also gets an `id`, and the row its `htmlFor`.
|
|
2098
|
+
- **`layout="below"`** is for a control with a size of its own: tiles, a
|
|
2099
|
+
list to order. Everything that fits on a line stays beside its label;
|
|
2100
|
+
it drops under the words by itself where it doesn't fit.
|
|
2101
|
+
- **A table goes after the card**, as any framed list: a
|
|
2102
|
+
`DataTable look="framed"` under its `ListHeader`. The card stops at 832px
|
|
2103
|
+
and the table doesn't.
|
|
2104
|
+
- **A choice kept on the device says so** in its help: "For this browser
|
|
2105
|
+
only." A row has no saving state: a device's choice saves at once, and a
|
|
2106
|
+
control that saves to a server shows its own.
|
|
2107
|
+
- **`PaletteSetting` and `RowsSetting`** are the shell's look menu as rows,
|
|
2108
|
+
kept under the same keys. Each draws nothing where the app doesn't let a
|
|
2109
|
+
device pick, so a page can always render them.
|
|
2110
|
+
- **With both on a page, `<AppShell lookMenu={false}>`** takes the look menu
|
|
2111
|
+
out of the header. `palettePicker` and `rowsPicker` stay on: they say a
|
|
2112
|
+
device may choose, and its choice applies. Don't turn the menu off before
|
|
2113
|
+
the page has the two: a device that picked would have no way back.
|
|
2114
|
+
|
|
2053
2115
|
## The sidebar and the phone's bar
|
|
2054
2116
|
|
|
2055
2117
|
`AppShell`'s navigation, all set in the app's `nav` and `bottomBar`, and
|
|
@@ -52,7 +52,8 @@ One or two sentences: what one record is, and who uses the screens.
|
|
|
52
52
|
check).
|
|
53
53
|
- *From the package, no Widget example:* `date` (a calendar day, no
|
|
54
54
|
time: OpenAPI `format: date`; the foundation's `DateField`; say
|
|
55
|
-
whether it's optional
|
|
55
|
+
whether it's optional, and the day the app's weeks start on when it
|
|
56
|
+
isn't Monday (`weekStart`)), `month-day` (a day that comes round every
|
|
56
57
|
year, no year: `'MM-DD'`; the foundation's `MonthDayField`; say
|
|
57
58
|
whether it's optional), `recurrence` (how it repeats: the
|
|
58
59
|
foundation's `Recurrence` schema and `RecurrenceField`; say whether
|
|
@@ -128,11 +128,19 @@ export declare function navPathname(to: string): string;
|
|
|
128
128
|
/** Every `to` in a nav, each once, in order: the pages its sidebar links. */
|
|
129
129
|
export declare function navTargets(nav: readonly NavEntry[]): string[];
|
|
130
130
|
/**
|
|
131
|
-
* The one
|
|
132
|
-
* of its `to` (its query string
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
|
|
131
|
+
* The one of a list of links that `pathname` is at or under: the most
|
|
132
|
+
* specific that matches, by the path of its `to` (its query string
|
|
133
|
+
* ignored). Of two with the same path, the first. The rule for the nav's
|
|
134
|
+
* entries (activeNavItem) and for a settings page's groups.
|
|
135
|
+
*/
|
|
136
|
+
export declare function mostSpecificTo<T extends {
|
|
137
|
+
to: string;
|
|
138
|
+
end?: boolean;
|
|
139
|
+
}>(items: readonly T[], pathname: string): T | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* The one entry to mark active: the most specific that matches
|
|
142
|
+
* (mostSpecificTo). With '/tasks' and '/tasks/categories' both in the nav,
|
|
143
|
+
* '/tasks/categories/2' marks Categories only, and '/tasks/3' marks Tasks.
|
|
136
144
|
*/
|
|
137
145
|
export declare function activeNavItem(nav: readonly NavEntry[], pathname: string): NavItem | undefined;
|
|
138
146
|
/** The `to` of the one entry to mark active (`activeNavItem`). */
|
|
@@ -89,16 +89,15 @@ function matches(path, end, pathname) {
|
|
|
89
89
|
return pathname.startsWith(path.endsWith('/') ? path : `${path}/`);
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* The one
|
|
93
|
-
* of its `to` (its query string
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* path, the first.
|
|
92
|
+
* The one of a list of links that `pathname` is at or under: the most
|
|
93
|
+
* specific that matches, by the path of its `to` (its query string
|
|
94
|
+
* ignored). Of two with the same path, the first. The rule for the nav's
|
|
95
|
+
* entries (activeNavItem) and for a settings page's groups.
|
|
97
96
|
*/
|
|
98
|
-
export function
|
|
97
|
+
export function mostSpecificTo(items, pathname) {
|
|
99
98
|
let best;
|
|
100
99
|
let bestLength = -1;
|
|
101
|
-
for (const item of
|
|
100
|
+
for (const item of items) {
|
|
102
101
|
const path = navPathname(item.to);
|
|
103
102
|
if (matches(path, item.end, pathname) && path.length > bestLength) {
|
|
104
103
|
best = item;
|
|
@@ -107,6 +106,14 @@ export function activeNavItem(nav, pathname) {
|
|
|
107
106
|
}
|
|
108
107
|
return best;
|
|
109
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The one entry to mark active: the most specific that matches
|
|
111
|
+
* (mostSpecificTo). With '/tasks' and '/tasks/categories' both in the nav,
|
|
112
|
+
* '/tasks/categories/2' marks Categories only, and '/tasks/3' marks Tasks.
|
|
113
|
+
*/
|
|
114
|
+
export function activeNavItem(nav, pathname) {
|
|
115
|
+
return mostSpecificTo(navItems(nav), pathname);
|
|
116
|
+
}
|
|
110
117
|
/** The `to` of the one entry to mark active (`activeNavItem`). */
|
|
111
118
|
export function activeNavTo(nav, pathname) {
|
|
112
119
|
return activeNavItem(nav, pathname)?.to;
|
|
@@ -86,6 +86,17 @@ export type AppShellProps = {
|
|
|
86
86
|
* pages under them. Keep the labels short: a word or two.
|
|
87
87
|
*/
|
|
88
88
|
navLook?: NavLook;
|
|
89
|
+
/**
|
|
90
|
+
* The header's look menu: the palettes and the table rows, for a device
|
|
91
|
+
* to pick from. Drawn where the app lets a device pick
|
|
92
|
+
* (`FoundationProviders`' `palettePicker` and `rowsPicker`). `false`
|
|
93
|
+
* draws none, for an app that offers them on a settings page instead;
|
|
94
|
+
* what a device picked still applies. Put `PaletteSetting` and
|
|
95
|
+
* `RowsSetting` on a page first: with the menu off and neither on a
|
|
96
|
+
* page, a device that picked has no way to change back. The light/dark
|
|
97
|
+
* toggle of an app without a palette isn't part of it and stays.
|
|
98
|
+
*/
|
|
99
|
+
lookMenu?: boolean;
|
|
89
100
|
/**
|
|
90
101
|
* Search in the header: a box ("Search", or `placeholder`) from
|
|
91
102
|
* md up and a button on a phone (the bottom bar's Search instead, where
|
|
@@ -96,4 +107,4 @@ export type AppShellProps = {
|
|
|
96
107
|
*/
|
|
97
108
|
search?: AppShellSearch;
|
|
98
109
|
};
|
|
99
|
-
export declare function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen, version, bottomBar, navLook, search, }: AppShellProps): import("react").JSX.Element;
|
|
110
|
+
export declare function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen, version, bottomBar, navLook, lookMenu, search, }: AppShellProps): import("react").JSX.Element;
|
|
@@ -50,12 +50,14 @@ function CloseMobileSidebarOnNavigate() {
|
|
|
50
50
|
// with a light palette, always light), so it has no light/dark toggle, and with the picker on it gets the look menu
|
|
51
51
|
// in its place (design-language.md "Palettes"). With the rows picker the
|
|
52
52
|
// same menu offers the table rows (design-language.md "Density"); an app
|
|
53
|
-
// without a palette keeps its toggle beside it.
|
|
54
|
-
|
|
53
|
+
// without a palette keeps its toggle beside it. With `menu` off (AppShell's
|
|
54
|
+
// `lookMenu`) only the toggle is left, and the choices are a settings
|
|
55
|
+
// page's (look-settings.tsx).
|
|
56
|
+
function LookControl({ menu }) {
|
|
55
57
|
const { palette, picker } = usePalette();
|
|
56
58
|
const rows = useRows();
|
|
57
59
|
const pickPalette = picker && isPaletteName(palette) ? palette : null;
|
|
58
|
-
return (_jsxs(_Fragment, { children: [!palette && _jsx(ThemeToggle, {}), (pickPalette || rows.picker) && _jsx(LookMenu, { palette: pickPalette })] }));
|
|
60
|
+
return (_jsxs(_Fragment, { children: [!palette && _jsx(ThemeToggle, {}), menu && (pickPalette || rows.picker) && _jsx(LookMenu, { palette: pickPalette })] }));
|
|
59
61
|
}
|
|
60
62
|
// Each palette's swatch is its own background with its accent and second
|
|
61
63
|
// colour on it, read from the palette primitives, so the menu shows all
|
|
@@ -219,7 +221,7 @@ function PhoneBack({ back }) {
|
|
|
219
221
|
function AppShellSkeleton() {
|
|
220
222
|
return (_jsxs("div", { className: "flex h-screen w-full gap-4 p-4", "data-state": "loading", children: [_jsx(Skeleton, { className: "h-full w-56 shrink-0" }), _jsxs("div", { className: "flex-1 space-y-4 pt-2", children: [_jsx(Skeleton, { className: "h-8 w-64" }), _jsx(Skeleton, { className: "h-40 w-full" })] })] }));
|
|
221
223
|
}
|
|
222
|
-
export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen = true, version, bottomBar, navLook = 'list', search, }) {
|
|
224
|
+
export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen = true, version, bottomBar, navLook = 'list', lookMenu = true, search, }) {
|
|
223
225
|
const { user, status, error, retry, logout } = useAuth();
|
|
224
226
|
const location = useLocation();
|
|
225
227
|
const reporter = useErrorReporter();
|
|
@@ -272,5 +274,5 @@ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarO
|
|
|
272
274
|
// (AuthProvider), so this stays a deliberate logout: a
|
|
273
275
|
// clean /login, never the previous user's page as `from`.
|
|
274
276
|
logout().catch(() => { });
|
|
275
|
-
}, children: _jsx(LogOutIcon, {}) })] })] })] }) }), _jsx(PageTrailContext.Provider, { value: trailSlot, children: _jsxs("div", { "data-slot": "app-shell-column", className: "flex w-full min-w-0 flex-1 flex-col bg-background", children: [_jsxs("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-border px-4", children: [back && _jsx(PhoneBack, { back: back }), _jsx(SidebarTrigger, { className: cn(back && hasBar && 'max-md:hidden') }), _jsx("div", { "data-slot": "app-shell-trail", className: "min-w-0 flex-1", children: trail.length > 0 && _jsx(PageTrail, { crumbs: trail, "aria-label": "You are here", className: "max-md:hidden" }) }), search && _jsx(SearchPalette, { ref: paletteRef, search: search, nav: nav, onBar: bottomBarHasSearch(barItems) }), _jsx(LookControl, {})] }), _jsx(OfflineNotice, {}), _jsx(SidebarInset, { className: "min-w-0", children: _jsx("div", { className: cn('flex-1 p-6', hasBar && BOTTOM_BAR_PADDING), children: _jsx(Outlet, {}) }) })] }) }), hasBar && (_jsx(BottomBar, { items: barItems, nav: nav, activeTo: activeTo, navLook: navLook, onSearch: (opener) => paletteRef.current?.openFrom(opener) }))] }), _jsx(Toaster, {})] }));
|
|
277
|
+
}, children: _jsx(LogOutIcon, {}) })] })] })] }) }), _jsx(PageTrailContext.Provider, { value: trailSlot, children: _jsxs("div", { "data-slot": "app-shell-column", className: "flex w-full min-w-0 flex-1 flex-col bg-background", children: [_jsxs("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-border px-4", children: [back && _jsx(PhoneBack, { back: back }), _jsx(SidebarTrigger, { className: cn(back && hasBar && 'max-md:hidden') }), _jsx("div", { "data-slot": "app-shell-trail", className: "min-w-0 flex-1", children: trail.length > 0 && _jsx(PageTrail, { crumbs: trail, "aria-label": "You are here", className: "max-md:hidden" }) }), search && _jsx(SearchPalette, { ref: paletteRef, search: search, nav: nav, onBar: bottomBarHasSearch(barItems) }), _jsx(LookControl, { menu: lookMenu })] }), _jsx(OfflineNotice, {}), _jsx(SidebarInset, { className: "min-w-0", children: _jsx("div", { className: cn('flex-1 p-6', hasBar && BOTTOM_BAR_PADDING), children: _jsx(Outlet, {}) }) })] }) }), hasBar && (_jsx(BottomBar, { items: barItems, nav: nav, activeTo: activeTo, navLook: navLook, onSearch: (opener) => paletteRef.current?.openFrom(opener) }))] }), _jsx(Toaster, {})] }));
|
|
276
278
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PlainDate } from '../../lib/plain-date.js';
|
|
2
|
+
import type { WeekdayCode } from '../../lib/recurrence.js';
|
|
2
3
|
export type DateFieldProps = {
|
|
3
4
|
/** The box's id (the button's with `typing={false}`), for the field's `<FieldLabel htmlFor>`. */
|
|
4
5
|
id?: string;
|
|
@@ -41,6 +42,8 @@ export type DateFieldProps = {
|
|
|
41
42
|
onOpenChange?: (open: boolean) => void;
|
|
42
43
|
/** How the day is shown. Defaults to `{ dateStyle: 'medium' }`. */
|
|
43
44
|
format?: Intl.DateTimeFormatOptions;
|
|
45
|
+
/** The day the calendar's weeks start on (`'MO'` to `'SU'`; Monday when left out). */
|
|
46
|
+
weekStart?: WeekdayCode;
|
|
44
47
|
locale?: string;
|
|
45
48
|
className?: string;
|
|
46
49
|
'aria-label'?: string;
|
|
@@ -14,6 +14,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
// `clearable` adds Clear to the calendar for an optional field. Either way
|
|
15
15
|
// the control carries `data-kind="date"`, so two dates keep sharing a row
|
|
16
16
|
// on a phone without their Field saying `kind="date"`.
|
|
17
|
+
//
|
|
18
|
+
// The calendar's weeks start on Monday, MonthCalendar's and
|
|
19
|
+
// RecurrenceField's default; `weekStart="SU"` for an app whose weeks start
|
|
20
|
+
// on Sunday.
|
|
17
21
|
import { useId, useRef, useState } from 'react';
|
|
18
22
|
import { CalendarIcon } from 'lucide-react';
|
|
19
23
|
import { cn } from 'cn';
|
|
@@ -25,7 +29,9 @@ import { formatPlainDate, localToPlainDate, parsePlainDate, plainDateExamples, p
|
|
|
25
29
|
export function DateField({ typing = true, onProblem, ...props }) {
|
|
26
30
|
return typing ? _jsx(TypedDate, { ...props, onProblem: onProblem }) : _jsx(DateButton, { ...props });
|
|
27
31
|
}
|
|
28
|
-
|
|
32
|
+
// Calendar's `weekStartsOn` by code. Left out, it's Calendar's own default (Monday).
|
|
33
|
+
const WEEK_STARTS_ON = { SU: 0, MO: 1, TU: 2, WE: 3, TH: 4, FR: 5, SA: 6 };
|
|
34
|
+
function TypedDate({ id, value, onChange, onPick, onProblem, placeholder, clearable = false, invalid = false, readOnly = false, defaultOpen = false, modal, onOpenChange, format, weekStart, locale, className, 'aria-describedby': describedBy, ...aria }) {
|
|
29
35
|
const messageId = useId();
|
|
30
36
|
const [open, setOpen] = useState(defaultOpen && !readOnly);
|
|
31
37
|
const box = useRef(null);
|
|
@@ -100,15 +106,15 @@ function TypedDate({ id, value, onChange, onPick, onProblem, placeholder, cleara
|
|
|
100
106
|
};
|
|
101
107
|
const selected = plainDateToLocal(given);
|
|
102
108
|
const showProblem = told && problem !== null;
|
|
103
|
-
return (_jsxs("div", { "data-slot": "date-field", "data-kind": "date", className: cn('flex w-full min-w-0 flex-col gap-1.5', className), children: [_jsxs(InputGroup, { ref: group, children: [_jsx(InputGroupInput, { ref: box, id: id, value: text, onChange: (event) => type(event.target.value), onBlur: settle, onKeyDown: onKeyDown, placeholder: placeholder ?? plainDateExamples(locale), readOnly: readOnly, autoComplete: "off", "aria-invalid": invalid || showProblem || undefined, "aria-describedby": [showProblem ? messageId : null, describedBy].filter(Boolean).join(' ') || undefined, ...aria }), _jsx(InputGroupAddon, { align: "inline-end", children: _jsxs(Popover, { open: open, onOpenChange: changeOpen, modal: modal, children: [_jsx(PopoverTrigger, { render: _jsx(InputGroupButton, { type: "button", size: "icon-xs", variant: "ghost", disabled: readOnly, "aria-label": "Open Calendar" }), children: _jsx(CalendarIcon, { "aria-hidden": "true" }) }), _jsxs(PopoverContent, { ref: popup, anchor: group, align: "start", className: "w-auto p-0", "data-slot": "date-field-calendar",
|
|
109
|
+
return (_jsxs("div", { "data-slot": "date-field", "data-kind": "date", className: cn('flex w-full min-w-0 flex-col gap-1.5', className), children: [_jsxs(InputGroup, { ref: group, children: [_jsx(InputGroupInput, { ref: box, id: id, value: text, onChange: (event) => type(event.target.value), onBlur: settle, onKeyDown: onKeyDown, placeholder: placeholder ?? plainDateExamples(locale), readOnly: readOnly, autoComplete: "off", "aria-invalid": invalid || showProblem || undefined, "aria-describedby": [showProblem ? messageId : null, describedBy].filter(Boolean).join(' ') || undefined, ...aria }), _jsx(InputGroupAddon, { align: "inline-end", children: _jsxs(Popover, { open: open, onOpenChange: changeOpen, modal: modal, children: [_jsx(PopoverTrigger, { render: _jsx(InputGroupButton, { type: "button", size: "icon-xs", variant: "ghost", disabled: readOnly, "aria-label": "Open Calendar" }), children: _jsx(CalendarIcon, { "aria-hidden": "true" }) }), _jsxs(PopoverContent, { ref: popup, anchor: group, align: "start", className: "w-auto p-0", "data-slot": "date-field-calendar", "aria-label": "Calendar",
|
|
104
110
|
// The day the keyboard starts from (the chosen one, else today).
|
|
105
111
|
initialFocus: () => popup.current?.querySelector('button[data-day][tabindex="0"]') ?? true,
|
|
106
112
|
// Back to the box, where typing goes on.
|
|
107
113
|
finalFocus: box, children: [_jsx(Calendar, { mode: "single",
|
|
108
114
|
// Picking the chosen day again keeps it (and closes), never unsets it: Clear does that.
|
|
109
|
-
required: true, selected: selected, defaultMonth: selected, onSelect: (date) => pick(localToPlainDate(date)) }), clearable && given && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }) })] }), showProblem && (_jsx("p", { id: messageId, "data-slot": "date-field-problem", className: "type-caption text-destructive-text", children: problem }))] }));
|
|
115
|
+
required: true, selected: selected, defaultMonth: selected, weekStartsOn: weekStart && WEEK_STARTS_ON[weekStart], onSelect: (date) => pick(localToPlainDate(date)) }), clearable && given && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }) })] }), showProblem && (_jsx("p", { id: messageId, "data-slot": "date-field-problem", className: "type-caption text-destructive-text", children: problem }))] }));
|
|
110
116
|
}
|
|
111
|
-
function DateButton({ id, value, onChange, onPick, placeholder = 'Pick a date', clearable = false, invalid = false, readOnly = false, defaultOpen = false, modal, onOpenChange, format, locale, className, ...aria }) {
|
|
117
|
+
function DateButton({ id, value, onChange, onPick, placeholder = 'Pick a date', clearable = false, invalid = false, readOnly = false, defaultOpen = false, modal, onOpenChange, format, weekStart, locale, className, ...aria }) {
|
|
112
118
|
const [open, setOpen] = useState(defaultOpen && !readOnly);
|
|
113
119
|
const popup = useRef(null);
|
|
114
120
|
const selected = plainDateToLocal(value);
|
|
@@ -124,11 +130,11 @@ function DateButton({ id, value, onChange, onPick, placeholder = 'Pick a date',
|
|
|
124
130
|
(onPick ?? onChange)(next);
|
|
125
131
|
changeOpen(false);
|
|
126
132
|
};
|
|
127
|
-
return (_jsxs(Popover, { open: open, onOpenChange: changeOpen, modal: modal, children: [_jsxs(PopoverTrigger, { render: _jsx(Button, { id: id, type: "button", variant: "outline", "data-kind": "date", "aria-invalid": invalid || undefined, "aria-readonly": readOnly || undefined, className: cn('w-full justify-start font-normal', !shown && 'text-muted-foreground', className), ...aria }), children: [_jsx(CalendarIcon, { "aria-hidden": "true", className: "size-4" }), shown || placeholder] }), _jsxs(PopoverContent, { ref: popup, className: "w-auto p-0", "data-slot": "date-field-calendar",
|
|
133
|
+
return (_jsxs(Popover, { open: open, onOpenChange: changeOpen, modal: modal, children: [_jsxs(PopoverTrigger, { render: _jsx(Button, { id: id, type: "button", variant: "outline", "data-kind": "date", "aria-invalid": invalid || undefined, "aria-readonly": readOnly || undefined, className: cn('w-full justify-start font-normal', !shown && 'text-muted-foreground', className), ...aria }), children: [_jsx(CalendarIcon, { "aria-hidden": "true", className: "size-4" }), shown || placeholder] }), _jsxs(PopoverContent, { ref: popup, className: "w-auto p-0", "data-slot": "date-field-calendar", "aria-label": "Calendar",
|
|
128
134
|
// The day the keyboard starts from (the chosen one, else today):
|
|
129
135
|
// the one day react-day-picker makes tabbable. The popup would
|
|
130
136
|
// otherwise take focus itself, past the Calendar's autoFocus.
|
|
131
137
|
initialFocus: () => popup.current?.querySelector('button[data-day][tabindex="0"]') ?? true, children: [_jsx(Calendar, { mode: "single",
|
|
132
138
|
// Picking the chosen day again keeps it (and closes), never unsets it: Clear does that.
|
|
133
|
-
required: true, selected: selected, defaultMonth: selected, onSelect: (date) => pick(localToPlainDate(date)) }), clearable && value && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }));
|
|
139
|
+
required: true, selected: selected, defaultMonth: selected, weekStartsOn: weekStart && WEEK_STARTS_ON[weekStart], onSelect: (date) => pick(localToPlainDate(date)) }), clearable && value && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }));
|
|
134
140
|
}
|
|
@@ -66,6 +66,8 @@ export type InPlaceDateConfig<TRequired extends boolean = boolean> = {
|
|
|
66
66
|
typing?: boolean;
|
|
67
67
|
/** How the day reads. Defaults to `{ dateStyle: 'medium' }`. */
|
|
68
68
|
format?: Intl.DateTimeFormatOptions;
|
|
69
|
+
/** DateField's `weekStart`: `'SU'` for an app whose weeks start on Sunday. */
|
|
70
|
+
weekStart?: WeekdayCode;
|
|
69
71
|
locale?: string;
|
|
70
72
|
placeholder?: string;
|
|
71
73
|
};
|
|
@@ -135,7 +135,7 @@ function dateKind(config) {
|
|
|
135
135
|
control: (props, alone) => (_jsx(DateField, { id: props.id, value: props.value,
|
|
136
136
|
// Alone, a pick saves and the calendar opens with the field; closing
|
|
137
137
|
// it with nothing picked gives up (a pick has already saved by then).
|
|
138
|
-
onChange: alone ? (day) => props.commit(day) : props.onChange, clearable: !config.required, placeholder: config.placeholder, format: config.format, locale: config.locale, invalid: props.invalid, readOnly: props.disabled, defaultOpen: alone, modal: alone ? false : undefined, onOpenChange: alone
|
|
138
|
+
onChange: alone ? (day) => props.commit(day) : props.onChange, clearable: !config.required, placeholder: config.placeholder, format: config.format, weekStart: config.weekStart, locale: config.locale, invalid: props.invalid, readOnly: props.disabled, defaultOpen: alone, modal: alone ? false : undefined, onOpenChange: alone
|
|
139
139
|
? (open) => {
|
|
140
140
|
if (!open)
|
|
141
141
|
props.cancel();
|
|
@@ -156,7 +156,7 @@ function typedDateKind(config) {
|
|
|
156
156
|
return formatPlainDate(draft) === '' ? { ok: false, message: unreadableDateMessage(config.locale) } : { ok: true, value: draft };
|
|
157
157
|
},
|
|
158
158
|
show: (value) => (value ? formatPlainDate(value, config.format, config.locale) || value : null),
|
|
159
|
-
control: (props, alone) => (_jsx(DateField, { id: props.id, value: props.value, onChange: props.onChange, onPick: alone ? (day) => props.commit(day) : props.onChange, onProblem: props.onProblem, clearable: !config.required, placeholder: config.placeholder, format: config.format, locale: config.locale, invalid: props.invalid, readOnly: props.disabled, modal: false, "aria-label": props.label, "aria-describedby": props.describedBy })),
|
|
159
|
+
control: (props, alone) => (_jsx(DateField, { id: props.id, value: props.value, onChange: props.onChange, onPick: alone ? (day) => props.commit(day) : props.onChange, onProblem: props.onProblem, clearable: !config.required, placeholder: config.placeholder, format: config.format, weekStart: config.weekStart, locale: config.locale, invalid: props.invalid, readOnly: props.disabled, modal: false, "aria-label": props.label, "aria-describedby": props.describedBy })),
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
function monthDayKind(config) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import type { WeekdayCode } from '../../lib/recurrence.js';
|
|
2
3
|
export type FillInInputKind = 'text' | 'longText' | 'number' | 'money' | 'date';
|
|
3
4
|
export interface FillInSuggestion<V> {
|
|
4
5
|
value: V;
|
|
@@ -15,12 +16,14 @@ export interface FillInInputProps {
|
|
|
15
16
|
suggestion?: FillInSuggestion<string>;
|
|
16
17
|
/** The currency of a money value, for its symbol and the suggestion. Default "USD". */
|
|
17
18
|
currency?: string;
|
|
19
|
+
/** DateField's `weekStart`, for a date's calendar. */
|
|
20
|
+
weekStart?: WeekdayCode;
|
|
18
21
|
locale?: string;
|
|
19
22
|
placeholder?: string;
|
|
20
23
|
className?: string;
|
|
21
24
|
}
|
|
22
25
|
/** One text, number, money or date field of a FillInQueue record. */
|
|
23
|
-
export declare function FillInInput({ label, kind, value, onChange, suggestion, currency, locale, placeholder, className, }: FillInInputProps): import("react").JSX.Element;
|
|
26
|
+
export declare function FillInInput({ label, kind, value, onChange, suggestion, currency, weekStart, locale, placeholder, className, }: FillInInputProps): import("react").JSX.Element;
|
|
24
27
|
export interface FillInSelectProps<V extends string | number> {
|
|
25
28
|
label: string;
|
|
26
29
|
choices: readonly {
|
|
@@ -58,8 +61,10 @@ export interface FillInFieldProps {
|
|
|
58
61
|
/** The number keys pick in this field when it's drawn as a row of choices. One per record. */
|
|
59
62
|
shortcut?: boolean;
|
|
60
63
|
currency?: string;
|
|
64
|
+
/** DateField's `weekStart`, for a date's calendar. */
|
|
65
|
+
weekStart?: WeekdayCode;
|
|
61
66
|
locale?: string;
|
|
62
67
|
className?: string;
|
|
63
68
|
}
|
|
64
69
|
/** The row a field's kind calls for: FillInChoice, FillInSelect or FillInInput. */
|
|
65
|
-
export declare function FillInField({ field, value, onChange, shortcut, currency, locale, className }: FillInFieldProps): import("react").JSX.Element;
|
|
70
|
+
export declare function FillInField({ field, value, onChange, shortcut, currency, weekStart, locale, className }: FillInFieldProps): import("react").JSX.Element;
|
|
@@ -38,12 +38,12 @@ function shown(kind, value, currency, locale) {
|
|
|
38
38
|
return value;
|
|
39
39
|
}
|
|
40
40
|
/** One text, number, money or date field of a FillInQueue record. */
|
|
41
|
-
export function FillInInput({ label, kind, value, onChange, suggestion, currency = 'USD', locale, placeholder, className, }) {
|
|
41
|
+
export function FillInInput({ label, kind, value, onChange, suggestion, currency = 'USD', weekStart, locale, placeholder, className, }) {
|
|
42
42
|
const id = useId();
|
|
43
43
|
const control = (() => {
|
|
44
44
|
switch (kind) {
|
|
45
45
|
case 'date':
|
|
46
|
-
return _jsx(DateField, { id: id, value: value, onChange: onChange, clearable: true, locale: locale });
|
|
46
|
+
return _jsx(DateField, { id: id, value: value, onChange: onChange, clearable: true, weekStart: weekStart, locale: locale });
|
|
47
47
|
case 'longText':
|
|
48
48
|
return _jsx(Textarea, { id: id, value: value, placeholder: placeholder, onChange: (event) => onChange(event.target.value) });
|
|
49
49
|
case 'money':
|
|
@@ -70,7 +70,7 @@ function SuggestionButton({ text, note, used, onUse }) {
|
|
|
70
70
|
const isNumeric = (kind) => kind === 'number' || kind === 'money';
|
|
71
71
|
const toText = (value) => (value === null || value === undefined ? '' : String(value));
|
|
72
72
|
/** The row a field's kind calls for: FillInChoice, FillInSelect or FillInInput. */
|
|
73
|
-
export function FillInField({ field, value, onChange, shortcut, currency, locale, className }) {
|
|
73
|
+
export function FillInField({ field, value, onChange, shortcut, currency, weekStart, locale, className }) {
|
|
74
74
|
const { kind, label, choices = [], suggestion } = field;
|
|
75
75
|
// A number's text as typed ("1." on the way to "1.5"), kept while it
|
|
76
76
|
// still reads as the draft's value; replaced when the draft changes.
|
|
@@ -95,5 +95,5 @@ export function FillInField({ field, value, onChange, shortcut, currency, locale
|
|
|
95
95
|
setText(next);
|
|
96
96
|
const number = Number(next);
|
|
97
97
|
onChange(next.trim() === '' || !Number.isFinite(number) ? null : number);
|
|
98
|
-
}, suggestion: suggestion === undefined ? undefined : { value: String(suggestion.value), note: suggestion.note }, currency: currency, locale: locale, className: className }));
|
|
98
|
+
}, suggestion: suggestion === undefined ? undefined : { value: String(suggestion.value), note: suggestion.note }, currency: currency, weekStart: weekStart, locale: locale, className: className }));
|
|
99
99
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type DateFilterPreset } from '../../lib/date-filter.js';
|
|
2
|
+
import type { WeekdayCode } from '../../lib/recurrence.js';
|
|
2
3
|
export type FilterDateProps = {
|
|
3
4
|
/** What it filters ("Due"): the prefix of the value it shows ("Due: Before today"). */
|
|
4
5
|
label: string;
|
|
@@ -13,6 +14,8 @@ export type FilterDateProps = {
|
|
|
13
14
|
anyLabel?: string;
|
|
14
15
|
/** How a range's days are shown. Defaults to `{ dateStyle: 'medium' }`. */
|
|
15
16
|
format?: Intl.DateTimeFormatOptions;
|
|
17
|
+
/** DateField's `weekStart`, for the From and To days' calendars. */
|
|
18
|
+
weekStart?: WeekdayCode;
|
|
16
19
|
locale?: string;
|
|
17
20
|
className?: string;
|
|
18
21
|
};
|
|
@@ -21,4 +24,4 @@ export type FilterDateProps = {
|
|
|
21
24
|
* today" with a preset, "Due: Nov 1 – Nov 30, 2026" with a range, whose
|
|
22
25
|
* From and To days show beside it.
|
|
23
26
|
*/
|
|
24
|
-
export declare function FilterDate({ label, value, onValueChange, presets, range, anyLabel, format, locale, className, }: FilterDateProps): import("react").JSX.Element;
|
|
27
|
+
export declare function FilterDate({ label, value, onValueChange, presets, range, anyLabel, format, weekStart, locale, className, }: FilterDateProps): import("react").JSX.Element;
|
|
@@ -20,7 +20,7 @@ const RANGE = '__range__';
|
|
|
20
20
|
* today" with a preset, "Due: Nov 1 – Nov 30, 2026" with a range, whose
|
|
21
21
|
* From and To days show beside it.
|
|
22
22
|
*/
|
|
23
|
-
export function FilterDate({ label, value, onValueChange, presets = DATE_FILTER_PRESETS, range = true, anyLabel, format, locale, className, }) {
|
|
23
|
+
export function FilterDate({ label, value, onValueChange, presets = DATE_FILTER_PRESETS, range = true, anyLabel, format, weekStart, locale, className, }) {
|
|
24
24
|
const filter = parseDateFilter(value);
|
|
25
25
|
// Between dates picked, before either day is: the days show, the value stays ''.
|
|
26
26
|
const [ranging, setRanging] = useState(false);
|
|
@@ -42,5 +42,5 @@ export function FilterDate({ label, value, onValueChange, presets = DATE_FILTER_
|
|
|
42
42
|
const setEnd = (end, day) => {
|
|
43
43
|
onValueChange(dateRangeValue({ ...bounds, [end]: day || undefined }));
|
|
44
44
|
};
|
|
45
|
-
return (_jsxs("div", { "data-slot": "filter-date", className: cn('flex flex-wrap items-center gap-2', className), children: [_jsxs(Select, { value: picked, onValueChange: (next) => pick(next === null ? ANY : String(next)), children: [_jsx(SelectTrigger, { "aria-label": filterName(label, shown), "data-slot": "filter-date-select", "data-active": filter ? true : undefined, children: _jsx(SelectValue, { children: () => shown }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: ANY, children: any }), presets.map((preset) => (_jsx(SelectItem, { value: preset, children: DATE_FILTER_PRESET_LABELS[preset] }, preset))), range && (_jsxs(_Fragment, { children: [_jsx(SelectSeparator, {}), _jsx(SelectItem, { value: RANGE, children: "Between dates" })] }))] })] }), showRange && (_jsxs("div", { "data-slot": "filter-date-range", className: "flex flex-wrap items-center gap-2", children: [_jsx(DateField, { value: bounds?.from ?? '', onChange: (day) => setEnd('from', day), "aria-label": `${label} From`, placeholder: "From", format: format, locale: locale, className: "w-40" }), _jsx(DateField, { value: bounds?.to ?? '', onChange: (day) => setEnd('to', day), "aria-label": `${label} To`, placeholder: "To", format: format, locale: locale, className: "w-40" })] }))] }));
|
|
45
|
+
return (_jsxs("div", { "data-slot": "filter-date", className: cn('flex flex-wrap items-center gap-2', className), children: [_jsxs(Select, { value: picked, onValueChange: (next) => pick(next === null ? ANY : String(next)), children: [_jsx(SelectTrigger, { "aria-label": filterName(label, shown), "data-slot": "filter-date-select", "data-active": filter ? true : undefined, children: _jsx(SelectValue, { children: () => shown }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: ANY, children: any }), presets.map((preset) => (_jsx(SelectItem, { value: preset, children: DATE_FILTER_PRESET_LABELS[preset] }, preset))), range && (_jsxs(_Fragment, { children: [_jsx(SelectSeparator, {}), _jsx(SelectItem, { value: RANGE, children: "Between dates" })] }))] })] }), showRange && (_jsxs("div", { "data-slot": "filter-date-range", className: "flex flex-wrap items-center gap-2", children: [_jsx(DateField, { value: bounds?.from ?? '', onChange: (day) => setEnd('from', day), "aria-label": `${label} From`, placeholder: "From", format: format, weekStart: weekStart, locale: locale, className: "w-40" }), _jsx(DateField, { value: bounds?.to ?? '', onChange: (day) => setEnd('to', day), "aria-label": `${label} To`, placeholder: "To", format: format, weekStart: weekStart, locale: locale, className: "w-40" })] }))] }));
|
|
46
46
|
}
|
|
@@ -23,15 +23,17 @@ export declare function FoundationProviders({ mockMode, queryClient, errorReport
|
|
|
23
23
|
*/
|
|
24
24
|
palette?: AppPaletteName;
|
|
25
25
|
/**
|
|
26
|
-
* With `palette`:
|
|
27
|
-
*
|
|
26
|
+
* With `palette`: a device may pick any of the four palettes, in the
|
|
27
|
+
* shell's look menu or on a settings page (`PaletteSetting`), and the one
|
|
28
|
+
* picked is remembered on this device. A new device starts on `palette`.
|
|
28
29
|
* Ignored with a light palette, which is never in the picker.
|
|
29
30
|
*/
|
|
30
31
|
palettePicker?: boolean;
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* A device may pick its table rows, Compact (the default) or Regular, in
|
|
34
|
+
* the shell's look menu or on a settings page (`RowsSetting`), remembered
|
|
35
|
+
* on this device (design-language.md "Density", "Rows on this device").
|
|
36
|
+
* Off, every device is compact.
|
|
35
37
|
*/
|
|
36
38
|
rowsPicker?: boolean;
|
|
37
39
|
children: ReactNode;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type PaletteSettingProps = {
|
|
3
|
+
/** Defaults to "Palette". */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Defaults to "For this browser only." */
|
|
6
|
+
help?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* This device's palette, as a settings row of tiles, each a small page in
|
|
10
|
+
* its palette's colours: one radio group, the page changing at once. Draws
|
|
11
|
+
* nothing unless the app lets a device pick (`palettePicker`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function PaletteSetting({ label, help }: PaletteSettingProps): import("react").JSX.Element | null;
|
|
14
|
+
export type RowsSettingProps = {
|
|
15
|
+
/** Defaults to "Table Rows". */
|
|
16
|
+
label?: string;
|
|
17
|
+
/** Defaults to "For this browser only." */
|
|
18
|
+
help?: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* This device's table rows, Compact or Regular, as a settings row. Draws
|
|
22
|
+
* nothing unless the app lets a device pick (`rowsPicker`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function RowsSetting({ label, help }: RowsSettingProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from 'cn';
|
|
3
|
+
import { RadioGroup, RadioGroupItem } from '../ui/radio-group.js';
|
|
4
|
+
import { usePalette } from '../../hooks/use-palette.js';
|
|
5
|
+
import { useRows } from '../../hooks/use-rows.js';
|
|
6
|
+
import { isPaletteName, PALETTE_LABELS, PALETTES } from '../../lib/palettes.js';
|
|
7
|
+
import { ROWS, ROWS_LABELS } from '../../lib/rows.js';
|
|
8
|
+
import { ChoiceButtons } from './choice-buttons.js';
|
|
9
|
+
import { SettingsRow } from './settings-page.js';
|
|
10
|
+
const THIS_BROWSER = 'For this browser only.';
|
|
11
|
+
// A tile: the preview and its name, one radio. The picked one's edge is
|
|
12
|
+
// twice as thick as well as another colour; the focused one wears the
|
|
13
|
+
// focus ring.
|
|
14
|
+
const TILE = cn('relative cursor-pointer overflow-hidden rounded-lg border border-border bg-card', 'has-data-checked:border-primary has-data-checked:ring-1 has-data-checked:ring-primary', 'has-[:focus-visible]:border-ring has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/50');
|
|
15
|
+
// A small page in the palette's own colours: a sidebar's strip, then a
|
|
16
|
+
// title, a line and a button. Read from the palette primitives, so every
|
|
17
|
+
// tile shows its own whichever palette is on screen.
|
|
18
|
+
function PalettePreview({ name }) {
|
|
19
|
+
const colour = (part) => `var(--palette-${name}-${part})`;
|
|
20
|
+
const bar = (part, className) => (_jsx("span", { className: cn('h-1.25 rounded-full', className), style: { background: colour(part) } }));
|
|
21
|
+
return (_jsxs("span", { "aria-hidden": true, className: "grid h-16 grid-cols-[--spacing(8.5)_minmax(0,1fr)] border-b border-border", style: { background: colour('background') }, children: [_jsxs("span", { className: "flex flex-col gap-1.25 px-1.5 py-2", style: { background: colour('panel') }, children: [bar('accent'), bar('dim'), bar('dim')] }), _jsxs("span", { className: "flex flex-col gap-1.5 p-2.25", children: [bar('dim', 'w-[70%]'), bar('second', 'w-[40%]'), bar('accent', 'h-2.5 w-[28%]')] })] }));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* This device's palette, as a settings row of tiles, each a small page in
|
|
25
|
+
* its palette's colours: one radio group, the page changing at once. Draws
|
|
26
|
+
* nothing unless the app lets a device pick (`palettePicker`).
|
|
27
|
+
*/
|
|
28
|
+
export function PaletteSetting({ label = 'Palette', help = THIS_BROWSER }) {
|
|
29
|
+
const { palette, picker, setPalette } = usePalette();
|
|
30
|
+
if (!picker)
|
|
31
|
+
return null;
|
|
32
|
+
return (_jsx(SettingsRow, { label: label, help: help, layout: "below", control: (aria) => (_jsx(RadioGroup, { ...aria, "data-slot": "palette-tiles", value: palette, onValueChange: (next) => {
|
|
33
|
+
if (isPaletteName(next))
|
|
34
|
+
setPalette(next);
|
|
35
|
+
}, className: "max-w-180 grid-cols-[repeat(auto-fit,minmax(min(100%,--spacing(35)),1fr))] gap-3", children: PALETTES.map((name) => (_jsxs("label", { "data-slot": "palette-tile", className: TILE, children: [_jsx(RadioGroupItem, { value: name, className: "sr-only!" }), _jsx(PalettePreview, { name: name }), _jsx("span", { className: "block px-2.5 py-2 type-caption", children: PALETTE_LABELS[name] })] }, name))) })) }));
|
|
36
|
+
}
|
|
37
|
+
const ROWS_OPTIONS = ROWS.map((value) => ({ value, label: ROWS_LABELS[value] }));
|
|
38
|
+
/**
|
|
39
|
+
* This device's table rows, Compact or Regular, as a settings row. Draws
|
|
40
|
+
* nothing unless the app lets a device pick (`rowsPicker`).
|
|
41
|
+
*/
|
|
42
|
+
export function RowsSetting({ label = 'Table Rows', help = THIS_BROWSER }) {
|
|
43
|
+
const { rows, picker, setRows } = useRows();
|
|
44
|
+
if (!picker)
|
|
45
|
+
return null;
|
|
46
|
+
return (_jsx(SettingsRow, { label: label, help: help, control: (aria) => (_jsx(ChoiceButtons, { ...aria, options: ROWS_OPTIONS, value: rows, onValueChange: (next) => {
|
|
47
|
+
if (next)
|
|
48
|
+
setRows(next);
|
|
49
|
+
} })) }));
|
|
50
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** One group of settings: the address its route is at, and its name. */
|
|
3
|
+
export type SettingsGroup = {
|
|
4
|
+
to: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
export type SettingsPageProps = {
|
|
8
|
+
/** The page's name: its heading, the groups' landmark and the top of the trail. */
|
|
9
|
+
title: string;
|
|
10
|
+
/**
|
|
11
|
+
* The groups, in order, each at its own route under the page. The first
|
|
12
|
+
* is at the page's own address (the layout's index route). Leave out a
|
|
13
|
+
* group that holds nothing.
|
|
14
|
+
*/
|
|
15
|
+
groups: readonly SettingsGroup[];
|
|
16
|
+
/** The current group: the layout route's `<Outlet />`. */
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The layout of a settings page, inside a router: `title`, the links to
|
|
22
|
+
* `groups` down the side (in a row above, in a box under 40rem), and the
|
|
23
|
+
* current group. Past the first group it puts the page's trail in the
|
|
24
|
+
* shell's bar.
|
|
25
|
+
*
|
|
26
|
+
* <Route path="settings" element={<SettingsPage title="Settings" groups={GROUPS}><Outlet /></SettingsPage>}>
|
|
27
|
+
* <Route index element={<LookSettings />} />
|
|
28
|
+
* <Route path="notifications" element={<NotificationSettings />} />
|
|
29
|
+
* </Route>
|
|
30
|
+
*/
|
|
31
|
+
export declare function SettingsPage({ title, groups, children, className }: SettingsPageProps): import("react").JSX.Element;
|
|
32
|
+
export type SettingsCardProps = {
|
|
33
|
+
/** The group's `SettingsRow`s. */
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
className?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A group's rows, in a bordered card that stops growing at 832px (a step
|
|
39
|
+
* of the spacing scale, so it grows with the density). It has no heading:
|
|
40
|
+
* the group's name is the link beside it. A table the group holds goes
|
|
41
|
+
* after it.
|
|
42
|
+
*/
|
|
43
|
+
export declare function SettingsCard({ children, className }: SettingsCardProps): import("react").JSX.Element;
|
|
44
|
+
/** What names a row's control: spread it on the control. */
|
|
45
|
+
export type SettingsRowAria = {
|
|
46
|
+
'aria-labelledby': string;
|
|
47
|
+
/** Only with `help`. */
|
|
48
|
+
'aria-describedby'?: string;
|
|
49
|
+
};
|
|
50
|
+
export type SettingsRowProps = {
|
|
51
|
+
label: string;
|
|
52
|
+
/** One short line under the label. */
|
|
53
|
+
help?: ReactNode;
|
|
54
|
+
/**
|
|
55
|
+
* The setting's control, or a function handed the `aria-*` that name it
|
|
56
|
+
* by the row's label and help, to spread on it.
|
|
57
|
+
*/
|
|
58
|
+
control: ReactNode | ((aria: SettingsRowAria) => ReactNode);
|
|
59
|
+
/**
|
|
60
|
+
* `'beside'` (the default): the control at the row's end, dropping under
|
|
61
|
+
* the words where they don't fit on a line. `'below'`: always under
|
|
62
|
+
* them, at the row's full width, for a control with a size of its own
|
|
63
|
+
* (tiles, a list).
|
|
64
|
+
*/
|
|
65
|
+
layout?: 'beside' | 'below';
|
|
66
|
+
/**
|
|
67
|
+
* The control's id, where it is one thing a label can name (a select, a
|
|
68
|
+
* switch): the label is then its `<label>`, and a click on the words
|
|
69
|
+
* reaches it. A group of buttons or radios has none.
|
|
70
|
+
*/
|
|
71
|
+
htmlFor?: string;
|
|
72
|
+
className?: string;
|
|
73
|
+
};
|
|
74
|
+
/** One setting in a `SettingsCard`: what it is, and its control. */
|
|
75
|
+
export declare function SettingsRow({ label, help, control, layout, htmlFor, className }: SettingsRowProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// A settings page: its groups listed down the side, the one you're on
|
|
3
|
+
// beside them as a card of rows (design-language.md "A settings page").
|
|
4
|
+
// Parts an app puts together, not one component from a list:
|
|
5
|
+
//
|
|
6
|
+
// - SettingsPage is the layout route: the title, the groups' links and the
|
|
7
|
+
// current group's content. The routes are the app's, one per group, the
|
|
8
|
+
// first at the page's own address.
|
|
9
|
+
// - SettingsCard holds a group's rows; what else the group has (a table)
|
|
10
|
+
// goes after it.
|
|
11
|
+
// - SettingsRow is one setting: its label and help, and its control beside
|
|
12
|
+
// them or, with `layout="below"`, under them.
|
|
13
|
+
//
|
|
14
|
+
// Where a choice is kept, and any saving, is the control's own.
|
|
15
|
+
import { useId } from 'react';
|
|
16
|
+
import { Link, useLocation } from 'react-router';
|
|
17
|
+
import { cn } from 'cn';
|
|
18
|
+
import { Card } from '../ui/card.js';
|
|
19
|
+
import { mostSpecificTo, navPathname } from './app-shell-nav.js';
|
|
20
|
+
import { usePageTrail } from './page-trail-context.js';
|
|
21
|
+
// A group's link: marked as the sidebar marks its current entry, a tint and
|
|
22
|
+
// a 3px bar in the accent at its start. In a narrow box it is a finger's
|
|
23
|
+
// target.
|
|
24
|
+
const GROUP = cn('flex items-center rounded-md px-2.5 py-1.75 type-body text-foreground outline-none', 'focus-visible:ring-3 focus-visible:ring-ring/50', '@max-[40rem]/settings:min-h-10');
|
|
25
|
+
const CURRENT_GROUP = 'bg-primary/15 shadow-[inset_3px_0_0_0_var(--primary)]';
|
|
26
|
+
/**
|
|
27
|
+
* The layout of a settings page, inside a router: `title`, the links to
|
|
28
|
+
* `groups` down the side (in a row above, in a box under 40rem), and the
|
|
29
|
+
* current group. Past the first group it puts the page's trail in the
|
|
30
|
+
* shell's bar.
|
|
31
|
+
*
|
|
32
|
+
* <Route path="settings" element={<SettingsPage title="Settings" groups={GROUPS}><Outlet /></SettingsPage>}>
|
|
33
|
+
* <Route index element={<LookSettings />} />
|
|
34
|
+
* <Route path="notifications" element={<NotificationSettings />} />
|
|
35
|
+
* </Route>
|
|
36
|
+
*/
|
|
37
|
+
export function SettingsPage({ title, groups, children, className }) {
|
|
38
|
+
const id = useId();
|
|
39
|
+
const { pathname } = useLocation();
|
|
40
|
+
const current = mostSpecificTo(groups, pathname);
|
|
41
|
+
const currentId = current && `${id}-${groups.indexOf(current)}`;
|
|
42
|
+
// On a group's own page only: a page below one puts up its own trail,
|
|
43
|
+
// which a parent's would win over.
|
|
44
|
+
const trimmed = pathname.length > 1 ? pathname.replace(/\/+$/, '') : pathname;
|
|
45
|
+
const onGroup = current && current !== groups[0] && navPathname(current.to) === trimmed;
|
|
46
|
+
usePageTrail(onGroup ? [{ label: title, href: groups[0].to }, { label: current.label }] : null);
|
|
47
|
+
return (_jsxs("div", { "data-slot": "settings-page", className: cn('@container/settings w-full min-w-0', className), children: [_jsx("h1", { className: "mb-4 type-page-title text-foreground", children: title }), _jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)] gap-4 @min-[40rem]/settings:grid-cols-[--spacing(45)_minmax(0,1fr)] @min-[40rem]/settings:gap-7", children: [_jsx("nav", { "data-slot": "settings-groups", "aria-label": title, children: _jsx("ul", { className: "flex flex-wrap gap-1 @min-[40rem]/settings:flex-col @min-[40rem]/settings:gap-0.5", children: groups.map((group, index) => {
|
|
48
|
+
const isCurrent = group === current;
|
|
49
|
+
return (_jsx("li", { children: _jsx(Link, { to: group.to, id: `${id}-${index}`, "data-slot": "settings-group", "aria-current": isCurrent ? 'page' : undefined, className: cn(GROUP, isCurrent ? CURRENT_GROUP : 'hover:bg-muted'), children: group.label }) }, group.to));
|
|
50
|
+
}) }) }), _jsx("section", { "data-slot": "settings-content", "aria-labelledby": currentId, className: "flex min-w-0 flex-col gap-4", children: children })] })] }));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A group's rows, in a bordered card that stops growing at 832px (a step
|
|
54
|
+
* of the spacing scale, so it grows with the density). It has no heading:
|
|
55
|
+
* the group's name is the link beside it. A table the group holds goes
|
|
56
|
+
* after it.
|
|
57
|
+
*/
|
|
58
|
+
export function SettingsCard({ children, className }) {
|
|
59
|
+
return (_jsx(Card, { "data-slot": "settings-card", className: cn('max-w-208 gap-0 divide-y divide-border py-0', className), children: children }));
|
|
60
|
+
}
|
|
61
|
+
/** One setting in a `SettingsCard`: what it is, and its control. */
|
|
62
|
+
export function SettingsRow({ label, help, control, layout = 'beside', htmlFor, className }) {
|
|
63
|
+
const id = useId();
|
|
64
|
+
const labelId = `${id}-label`;
|
|
65
|
+
const helpId = `${id}-help`;
|
|
66
|
+
const aria = { 'aria-labelledby': labelId, ...(help ? { 'aria-describedby': helpId } : {}) };
|
|
67
|
+
const below = layout === 'below';
|
|
68
|
+
return (_jsxs("div", { "data-slot": "settings-row", "data-layout": layout, className: cn('flex px-4 py-3', below ? 'flex-col gap-2.5' : 'flex-wrap items-center justify-between gap-x-5 gap-y-2', className), children: [_jsxs("div", { className: cn('flex min-w-0 flex-col items-start gap-0.5', !below && 'flex-[1_1_--spacing(60)]'), children: [htmlFor ? (_jsx("label", { id: labelId, htmlFor: htmlFor, className: "type-body font-medium", children: label })) : (_jsx("span", { id: labelId, className: "type-body font-medium", children: label })), help && (_jsx("div", { id: helpId, className: "type-caption text-muted-foreground", children: help }))] }), _jsx("div", { "data-slot": "settings-row-control", className: below ? 'w-full min-w-0' : 'max-w-full', children: typeof control === 'function' ? control(aria) : control })] }));
|
|
69
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { DayPicker, type DayButton, type Locale } from "react-day-picker";
|
|
3
3
|
import { Button } from "./button.js";
|
|
4
|
-
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, locale, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
|
|
4
|
+
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, weekStartsOn, locale, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
|
|
5
5
|
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
|
|
6
6
|
}): React.JSX.Element;
|
|
7
7
|
declare function CalendarDayButton({ className, day, modifiers, locale, ...props }: React.ComponentProps<typeof DayButton> & {
|
|
@@ -5,9 +5,13 @@ import { cn } from "cn";
|
|
|
5
5
|
import { DayPicker, getDefaultClassNames, } from "react-day-picker";
|
|
6
6
|
import { Button, buttonVariants } from "./button.js";
|
|
7
7
|
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react";
|
|
8
|
-
function Calendar({ className, classNames, showOutsideDays = true, captionLayout = "label", buttonVariant = "ghost",
|
|
8
|
+
function Calendar({ className, classNames, showOutsideDays = true, captionLayout = "label", buttonVariant = "ghost",
|
|
9
|
+
// Patched (ui-foundation): upstream leaves this to react-day-picker, which
|
|
10
|
+
// starts weeks on Sunday. Monday unless the caller says, the default of
|
|
11
|
+
// MonthCalendar, RecurrenceField and byDay; a `locale` doesn't change it.
|
|
12
|
+
weekStartsOn = 1, locale, formatters, components, ...props }) {
|
|
9
13
|
const defaultClassNames = getDefaultClassNames();
|
|
10
|
-
return (_jsx(DayPicker, { showOutsideDays: showOutsideDays, className: cn("group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent", String.raw `rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw `rtl:**:[.rdp-button\_previous>svg]:rotate-180`, className), captionLayout: captionLayout, locale: locale, formatters: {
|
|
14
|
+
return (_jsx(DayPicker, { showOutsideDays: showOutsideDays, className: cn("group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent", String.raw `rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw `rtl:**:[.rdp-button\_previous>svg]:rotate-180`, className), captionLayout: captionLayout, weekStartsOn: weekStartsOn, locale: locale, formatters: {
|
|
11
15
|
formatMonthDropdown: (date) => date.toLocaleString(locale?.code, { month: "short" }),
|
|
12
16
|
...formatters,
|
|
13
17
|
}, classNames: {
|
package/dist/index.d.ts
CHANGED
|
@@ -84,6 +84,8 @@ export { StageCircle, type StageCircleProps, type StageCircleStage, type StageCi
|
|
|
84
84
|
export { Notice, type NoticeProps, type NoticeTone } from './components/app/notice.js';
|
|
85
85
|
export { ValueList, type ValueListItem, type ValueListProps } from './components/app/value-list.js';
|
|
86
86
|
export { ListHeader, type ListHeaderAction, type ListHeaderLink, type ListHeaderProps, type ListHeaderSecondaryAction, type ListHeaderSibling, } from './components/app/list-header.js';
|
|
87
|
+
export { SettingsCard, SettingsPage, SettingsRow, type SettingsCardProps, type SettingsGroup, type SettingsPageProps, type SettingsRowAria, type SettingsRowProps, } from './components/app/settings-page.js';
|
|
88
|
+
export { PaletteSetting, RowsSetting, type PaletteSettingProps, type RowsSettingProps } from './components/app/look-settings.js';
|
|
87
89
|
export { Timeline, type TimelineItem, type TimelineProps } from './components/app/timeline.js';
|
|
88
90
|
export { EqualItems, type EqualItem, type EqualItemField, type EqualItemState, type EqualItemStep, type EqualItemTone, type EqualItemsLook, type EqualItemsProps, } from './components/app/equal-items.js';
|
|
89
91
|
export { StepTrack, type StepTrackProps, type StepTrackState, type StepTrackStep, } from './components/app/step-track.js';
|
package/dist/index.js
CHANGED
|
@@ -95,6 +95,8 @@ export { StageCircle, } from './components/app/stage-circle.js';
|
|
|
95
95
|
export { Notice } from './components/app/notice.js';
|
|
96
96
|
export { ValueList } from './components/app/value-list.js';
|
|
97
97
|
export { ListHeader, } from './components/app/list-header.js';
|
|
98
|
+
export { SettingsCard, SettingsPage, SettingsRow, } from './components/app/settings-page.js';
|
|
99
|
+
export { PaletteSetting, RowsSetting } from './components/app/look-settings.js';
|
|
98
100
|
export { Timeline } from './components/app/timeline.js';
|
|
99
101
|
export { EqualItems, } from './components/app/equal-items.js';
|
|
100
102
|
export { StepTrack, } from './components/app/step-track.js';
|
package/dist/lib/palettes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// The four palettes (design-language.md "Palettes"): an app's own dark
|
|
2
2
|
// look, one of those the shared style guide chose. FoundationProviders'
|
|
3
|
-
// `palette` names the app's default; with `palettePicker` the app shell
|
|
4
|
-
//
|
|
5
|
-
// (localStorage, this store). A new device starts on the default. The
|
|
3
|
+
// `palette` names the app's default; with `palettePicker` the app shell's
|
|
4
|
+
// look menu or a settings page (PaletteSetting) offers all four and the
|
|
5
|
+
// choice is remembered on this device (localStorage, this store). A new device starts on the default. The
|
|
6
6
|
// palette rides on <html> as data-palette, so popups portaled to <body>
|
|
7
7
|
// wear it too, and styles/theme.css's `.dark[data-palette]` blocks do the
|
|
8
8
|
// rest (components/app/palette-provider.tsx, hooks/use-palette.ts).
|
package/dist/lib/rows.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// How tall a table's rows are on this device (design-language.md
|
|
2
2
|
// "Density", "Rows on this device"). Compact is the default; with
|
|
3
|
-
// FoundationProviders' `rowsPicker` the app shell's look menu
|
|
4
|
-
// Regular too, remembered on this device
|
|
5
|
-
// choice rides on <html> as data-rows, and styles/theme.css's
|
|
3
|
+
// FoundationProviders' `rowsPicker` the app shell's look menu or a settings
|
|
4
|
+
// page (RowsSetting) offers Regular too, remembered on this device
|
|
5
|
+
// (localStorage, this store). The choice rides on <html> as data-rows, and styles/theme.css's
|
|
6
6
|
// [data-rows="regular"] retunes every table's cells under it: DataTable,
|
|
7
7
|
// the Table primitive and tables in notes. A data-density on a nearer
|
|
8
8
|
// ancestor (a hub's compact wrapper) still wins there.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.142.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|