viewkitjs 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/MIGRATION.md +40 -3
- package/package.json +1 -1
- package/views/dist/cells/cell-format.d.ts +3 -1
- package/views/dist/cells/cell-format.js +2 -2
- package/views/dist/cells/use-cell-format.d.ts +8 -1
- package/views/dist/cells/use-cell-format.js +13 -2
- package/views/dist/contract.d.ts +70 -3
- package/views/dist/contract.js +76 -0
- package/views/dist/controls/alert/alert.d.ts +46 -0
- package/views/dist/controls/alert/alert.js +11 -0
- package/views/dist/controls/alert/looks.d.ts +4 -0
- package/views/dist/controls/alert/looks.js +19 -0
- package/views/dist/controls/alert/tokens.d.ts +92 -0
- package/views/dist/controls/alert/tokens.js +25 -0
- package/views/dist/controls/alert-dialog/alert-dialog.d.ts +50 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +67 -0
- package/views/dist/controls/alert-dialog/confirm.d.ts +13 -0
- package/views/dist/controls/alert-dialog/confirm.js +11 -0
- package/views/dist/controls/alert-dialog/looks.d.ts +4 -0
- package/views/dist/controls/alert-dialog/looks.js +17 -0
- package/views/dist/controls/alert-dialog/tokens.d.ts +119 -0
- package/views/dist/controls/alert-dialog/tokens.js +32 -0
- package/views/dist/controls/alert-dialog.css +95 -0
- package/views/dist/controls/alert.css +51 -0
- package/views/dist/controls/collapsible/collapsible.d.ts +39 -0
- package/views/dist/controls/collapsible/collapsible.js +18 -0
- package/views/dist/controls/collapsible/looks.d.ts +4 -0
- package/views/dist/controls/collapsible/looks.js +5 -0
- package/views/dist/controls/collapsible/map-collapse.d.ts +2 -0
- package/views/dist/controls/collapsible/map-collapse.js +6 -0
- package/views/dist/controls/collapsible/tokens.d.ts +68 -0
- package/views/dist/controls/collapsible/tokens.js +19 -0
- package/views/dist/controls/collapsible.css +83 -0
- package/views/dist/controls/compound-editor/place-parts.js +5 -1
- package/views/dist/controls/controls.d.ts +9 -0
- package/views/dist/controls/controls.js +9 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +2 -1
- package/views/dist/controls/date-editor/map-calendar.js +3 -1
- package/views/dist/controls/filter-editor/filter-editor.d.ts +56 -0
- package/views/dist/controls/filter-editor/filter-editor.js +208 -0
- package/views/dist/controls/filter-editor/how.d.ts +23 -0
- package/views/dist/controls/filter-editor/how.js +13 -0
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +18 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +164 -0
- package/views/dist/controls/filter-editor/map-rules.d.ts +85 -0
- package/views/dist/controls/filter-editor/map-rules.js +273 -0
- package/views/dist/controls/filter-editor/parts.d.ts +46 -0
- package/views/dist/controls/filter-editor/parts.js +75 -0
- package/views/dist/controls/filter-editor/rules.d.ts +104 -0
- package/views/dist/controls/filter-editor/rules.js +148 -0
- package/views/dist/controls/filter-editor/tokens.d.ts +83 -0
- package/views/dist/controls/filter-editor/tokens.js +23 -0
- package/views/dist/controls/filter-editor/words.d.ts +59 -0
- package/views/dist/controls/filter-editor/words.js +40 -0
- package/views/dist/controls/filter-editor.css +124 -0
- package/views/dist/controls/group-editor/group-editor.d.ts +56 -0
- package/views/dist/controls/group-editor/group-editor.js +126 -0
- package/views/dist/controls/group-editor/map-group-body.d.ts +19 -0
- package/views/dist/controls/group-editor/map-group-body.js +106 -0
- package/views/dist/controls/group-editor/rules.d.ts +48 -0
- package/views/dist/controls/group-editor/rules.js +41 -0
- package/views/dist/controls/group-editor/tokens.d.ts +15 -0
- package/views/dist/controls/group-editor/tokens.js +6 -0
- package/views/dist/controls/group-editor/words.d.ts +39 -0
- package/views/dist/controls/group-editor/words.js +21 -0
- package/views/dist/controls/group-editor.css +20 -0
- package/views/dist/controls/index.d.ts +19 -1
- package/views/dist/controls/index.js +19 -1
- package/views/dist/controls/internal/editor-parts.d.ts +8 -1
- package/views/dist/controls/internal/editor-parts.js +5 -0
- package/views/dist/controls/internal/step-return.d.ts +9 -0
- package/views/dist/controls/internal/step-return.js +27 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +5 -3
- package/views/dist/controls/links-editor/links-editor.js +38 -17
- package/views/dist/controls/links-editor/map-links-body.js +4 -1
- package/views/dist/controls/links-editor.css +1 -1
- package/views/dist/controls/menu-list/menu-list.d.ts +17 -2
- package/views/dist/controls/menu-list/menu-list.js +25 -16
- package/views/dist/controls/modal/looks.d.ts +4 -0
- package/views/dist/controls/modal/looks.js +25 -0
- package/views/dist/controls/modal/modal.d.ts +69 -0
- package/views/dist/controls/modal/modal.js +62 -0
- package/views/dist/controls/modal/tokens.d.ts +192 -0
- package/views/dist/controls/modal/tokens.js +50 -0
- package/views/dist/controls/modal.css +130 -0
- package/views/dist/controls/notice/notice.d.ts +49 -0
- package/views/dist/controls/notice/notice.js +35 -0
- package/views/dist/controls/notice/tokens.d.ts +99 -0
- package/views/dist/controls/notice/tokens.js +27 -0
- package/views/dist/controls/notice.css +100 -0
- package/views/dist/controls/number-editor/number-editor.js +1 -1
- package/views/dist/controls/pane/looks.d.ts +4 -0
- package/views/dist/controls/pane/looks.js +11 -0
- package/views/dist/controls/pane/pane.d.ts +63 -0
- package/views/dist/controls/pane/pane.js +98 -0
- package/views/dist/controls/pane/state.d.ts +14 -0
- package/views/dist/controls/pane/state.js +7 -0
- package/views/dist/controls/pane/tokens.d.ts +79 -0
- package/views/dist/controls/pane/tokens.js +22 -0
- package/views/dist/controls/pane.css +104 -0
- package/views/dist/controls/picker/rows.d.ts +4 -2
- package/views/dist/controls/picker/rows.js +4 -3
- package/views/dist/controls/sort-editor/map-sort-body.d.ts +9 -0
- package/views/dist/controls/sort-editor/map-sort-body.js +81 -0
- package/views/dist/controls/sort-editor/rules.d.ts +48 -0
- package/views/dist/controls/sort-editor/rules.js +24 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +58 -0
- package/views/dist/controls/sort-editor/sort-editor.js +180 -0
- package/views/dist/controls/sort-editor/tokens.d.ts +79 -0
- package/views/dist/controls/sort-editor/tokens.js +22 -0
- package/views/dist/controls/sort-editor/words.d.ts +48 -0
- package/views/dist/controls/sort-editor/words.js +25 -0
- package/views/dist/controls/sort-editor.css +96 -0
- package/views/dist/controls/toast/toast.d.ts +75 -0
- package/views/dist/controls/toast/toast.js +99 -0
- package/views/dist/controls/toast/tokens.d.ts +100 -0
- package/views/dist/controls/toast/tokens.js +27 -0
- package/views/dist/controls/toast.css +93 -0
- package/views/dist/controls/tokens.js +20 -0
- package/views/dist/controls/values-editor/values-editor.js +7 -1
- package/views/dist/display/date.js +2 -2
- package/views/dist/display/format.js +10 -2
- package/views/dist/display/options.d.ts +3 -1
- package/views/dist/display/use-display-options.d.ts +3 -0
- package/views/dist/display/use-display-options.js +10 -2
- package/views/dist/display/viewer.d.ts +1 -1
- package/views/dist/display/viewer.js +1 -1
- package/views/dist/editors/DateEditor.js +11 -9
- package/views/dist/editors/relation-panel.js +7 -1
- package/views/dist/editors/relation-picker.d.ts +2 -1
- package/views/dist/editors/relation-picker.js +4 -3
- package/views/dist/editors/relation-source.d.ts +4 -1
- package/views/dist/editors/relation-source.js +5 -2
- package/views/dist/field-row/editors/RowNumberEditor.js +2 -2
- package/views/dist/fields/number-edit.d.ts +6 -0
- package/views/dist/fields/number-edit.js +8 -1
- package/views/dist/grid/chrome/GridCellEditors.js +2 -2
- package/views/dist/grid/chrome/GridColumnDateSection.d.ts +4 -3
- package/views/dist/grid/chrome/GridColumnDateSection.js +4 -4
- package/views/dist/grid/chrome/GridColumnDurationSection.js +2 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +6 -4
- package/views/dist/grid/chrome/GridFooter.js +2 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +4 -2
- package/views/dist/grid/chrome/useGridBandFigures.js +2 -2
- package/views/dist/grid/chrome/useGridFittedWidths.d.ts +3 -0
- package/views/dist/grid/chrome/useGridFittedWidths.js +9 -3
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +5 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -1
- package/views/dist/grid/core/commit-model.d.ts +7 -0
- package/views/dist/grid/core/commit-model.js +5 -1
- package/views/dist/grid/core/editing-controller.js +10 -2
- package/views/dist/grid/core/editing-model.js +3 -7
- package/views/dist/grid/core/undo-owner.d.ts +6 -0
- package/views/dist/grid/core/undo-owner.js +13 -0
- package/views/dist/grid/core/useGridEditing.d.ts +2 -0
- package/views/dist/grid/core/useGridEditing.js +4 -0
- package/views/dist/looks/index.d.ts +5 -0
- package/views/dist/looks/index.js +5 -0
- package/views/dist/looks/pieces.js +10 -0
- package/views/dist/panels/model.d.ts +6 -1
- package/views/dist/panels/react/customize-body.d.ts +4 -2
- package/views/dist/panels/react/customize-body.js +3 -3
- package/views/dist/panels/react/customize.js +4 -2
- package/views/dist/panels/react/filter/FilterEditor.js +2 -2
- package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +8 -2
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +9 -6
- package/views/dist/panels/react/filter/filter-body.d.ts +8 -5
- package/views/dist/panels/react/filter/filter-body.js +17 -6
- package/views/dist/panels/react/filter/filter-part-body.d.ts +4 -1
- package/views/dist/panels/react/filter/filter-part-body.js +3 -1
- package/views/dist/panels/react/panel-sheet.d.ts +5 -1
- package/views/dist/panels/react/panel-sheet.js +6 -2
- package/views/dist/panels/react/panel-step.d.ts +12 -0
- package/views/dist/panels/react/panel-step.js +26 -0
- package/views/dist/panels/react/sort/SortEditor.d.ts +4 -0
- package/views/dist/panels/react/sort/SortEditor.js +5 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +8 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +84 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +16 -0
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +49 -0
- package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +36 -21
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +15 -6
- package/views/dist/panels/react/toolbar/panel-part.d.ts +5 -1
- package/views/dist/panels/react/toolbar/panel-part.js +2 -2
- package/views/dist/panels/react/toolbar/use-filter-add.d.ts +16 -0
- package/views/dist/panels/react/toolbar/use-filter-add.js +32 -0
- package/views/dist/panels/react.d.ts +1 -0
- package/views/dist/panels/react.js +1 -0
- package/views/dist/panels/settings/filter-groups.js +35 -1
- package/views/dist/panels/settings/group-buckets.js +1 -0
- package/views/dist/provider/ViewsProvider.d.ts +7 -1
- package/views/dist/provider/ViewsProvider.js +23 -3
- package/views/dist/provider/components.d.ts +30 -4
- package/views/dist/provider/moment.d.ts +6 -0
- package/views/dist/provider/moment.js +10 -0
- package/views/dist/styles.css +847 -52
- package/views/dist/styles.unlayered.css +848 -52
- package/views/docs/contract.md +15 -9
- package/views/docs/controls/alert-dialog.md +37 -0
- package/views/docs/controls/alert.md +30 -0
- package/views/docs/controls/collapsible.md +22 -0
- package/views/docs/controls/filter-editor.md +28 -0
- package/views/docs/controls/group-editor.md +11 -0
- package/views/docs/controls/modal.md +55 -0
- package/views/docs/controls/notice.md +32 -0
- package/views/docs/controls/pane.md +25 -0
- package/views/docs/controls/sort-editor.md +27 -0
- package/views/docs/controls/toast.md +32 -0
- package/views/docs/guides/cells.md +1 -1
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/the-grid.md +1 -1
- package/views/docs/guides/the-provider.md +19 -0
- package/views/docs/reference/cells.md +2 -2
- package/views/docs/reference/controls.md +213 -7
- package/views/docs/reference/display.md +2 -2
- package/views/docs/reference/editors-relation.md +1 -1
- package/views/docs/reference/looks.md +10 -0
- package/views/docs/reference/panels-react.md +7 -6
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +7 -7
- package/views/docs/reference/views.md +1 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* The sort editor: what a list's sort opens (KIT-623), after Attio's (the toolbar canvas's round 3 Sort board and round 11 PhoneSort
|
|
2
|
+
board). Every value is a public --vk-* name (sort-editor/tokens.ts). On a computer, what the Popover holds: the rules, each a row 28 high, 8 apart (its
|
|
3
|
+
grip, the field's box 208 wide, the direction's 152, ×: as wide as its two boxes need, Company › Industry and Descending whole,
|
|
4
|
+
Mihai, 17 Nov 2026), then 12 under them its foot, the filter editor's (KIT-794): a row, Add sort at its start, Clear all sorts at
|
|
5
|
+
its end. A rule held by its grip lifts on the overlay's ground with a shadow. On a phone, what the Sheet holds: Field rows' card, each rule 56 high (its field's mark, its name
|
|
6
|
+
and its direction under it, ⋯), or, with none, what it says; then Add sort and Clear all, the whole width. Its narrow form
|
|
7
|
+
(KIT-672), what Customize's Sort holds in the Pane on a computer: the phone's structure at a computer's sizes (Mihai, 19 Nov
|
|
8
|
+
2026), the rows on the Pane's ground with no card, each 44 (its mark 16, its name text-sm, its direction text-xs under it, ⋮ 28),
|
|
9
|
+
its hover the overlay's on the whole row, ⋮ inside it (KIT-819); Add sort and Clear all at 32, the whole width.
|
|
10
|
+
|
|
11
|
+
The rules sit in the components layer, so a utility class still wins. */
|
|
12
|
+
@layer components {
|
|
13
|
+
|
|
14
|
+
.o-sort-editor { position: relative; display: flex; flex-direction: column; min-width: 0; color: var(--vk-fg); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
|
|
15
|
+
.o-sort-editor:focus { outline: none; }
|
|
16
|
+
.o-sort-editor-mark { display: inline-flex; flex: none; align-items: center; color: var(--vk-fg-subtle); }
|
|
17
|
+
.o-sort-editor-mark svg { width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4); }
|
|
18
|
+
|
|
19
|
+
/* ── On a computer: the rules ────────────────────────────────────────────────────────────────────────────────────── */
|
|
20
|
+
.o-sort-editor[data-sort-form="computer"] { width: max-content; max-width: 100%; gap: calc(var(--vk-spacing) * 3); }
|
|
21
|
+
.o-sort-editor-foot { display: flex; align-items: center; gap: calc(var(--vk-spacing) * 2); }
|
|
22
|
+
.o-sort-editor-foot .o-sort-editor-clear { margin-left: auto; }
|
|
23
|
+
.o-sort-editor-rules { display: flex; flex-direction: column; gap: calc(var(--vk-spacing) * 2); }
|
|
24
|
+
.o-sort-editor-rule { display: flex; align-items: center; gap: calc(var(--vk-spacing) * 2); min-width: 0; border-radius: var(--vk-radius-md); }
|
|
25
|
+
.o-sort-editor-rule[data-lifted] { position: relative; z-index: var(--vk-layer-popup); background-color: var(--vk-overlay); box-shadow: var(--vk-shadow-lg); }
|
|
26
|
+
.o-sort-editor-rule[data-lifted] .o-sort-editor-grip { cursor: grabbing; }
|
|
27
|
+
.o-sort-editor-grip { flex: none; touch-action: none; }
|
|
28
|
+
.o-sort-editor-field, .o-sort-editor-direction { position: relative; flex: none; min-width: 0; }
|
|
29
|
+
.o-sort-editor-field { width: calc(var(--vk-spacing) * 52); }
|
|
30
|
+
.o-sort-editor-direction { width: calc(var(--vk-spacing) * 38); }
|
|
31
|
+
.o-sort-editor-field > .o-select, .o-sort-editor-direction > .o-select { width: 100%; }
|
|
32
|
+
.o-sort-editor-remove { flex: none; }
|
|
33
|
+
|
|
34
|
+
/* Add sort's fields, and in the narrow form a rule's direction, in the Popover under what was pressed: as wide as its rows, never
|
|
35
|
+
under 192 (the kit's w-fit and min-w-48, written here since an app compiles no utilities of ViewKit's). */
|
|
36
|
+
.o-popover.o-sort-editor-pop { width: fit-content; min-width: calc(var(--vk-spacing) * 48); }
|
|
37
|
+
|
|
38
|
+
/* A list a page shows standing open: under what opens it, over the rules, as the Select's list stands, as wide as its rows, never
|
|
39
|
+
under 192 nor its box, never past 288 (listWidth, select.css). Scoped to the editor, so it wins over the smooth list's own
|
|
40
|
+
`position: relative` (list.css), which would stand it in the row and push the row's boxes apart (Mihai, 18 Nov 2026). */
|
|
41
|
+
.o-sort-editor .o-sort-editor-shown { position: absolute; z-index: var(--vk-layer-popup); top: 100%; left: 0; }
|
|
42
|
+
.o-sort-editor .o-sort-editor-shown[data-sort-shown="list"] {
|
|
43
|
+
top: calc(100% + var(--vk-spacing)); display: flex; flex-direction: column;
|
|
44
|
+
width: max-content; min-width: max(100%, calc(var(--vk-spacing) * 48)); max-width: calc(var(--vk-spacing) * 72);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* ── On a phone: the rules in their card, or what it says with none; Add sort and Clear all ─────────────────────── */
|
|
48
|
+
.o-sort-editor[data-sort-form="phone"] { gap: calc(var(--vk-spacing) * 3); font-size: var(--vk-font-size-base); line-height: calc(var(--vk-font-size-base) * var(--vk-line-height-base)); }
|
|
49
|
+
.o-sort-editor-none { display: grid; gap: calc(var(--vk-spacing) * 0.5); padding: 0 calc(var(--vk-spacing) * 1); }
|
|
50
|
+
.o-sort-editor-none p { margin: 0; }
|
|
51
|
+
.o-sort-editor-none-head { font-weight: var(--vk-font-weight-medium); }
|
|
52
|
+
.o-sort-editor-none-line { color: var(--vk-fg-subtle); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
|
|
53
|
+
[data-sort-form="narrow"] .o-sort-editor-none-line { font-size: var(--vk-font-size-xs); line-height: calc(var(--vk-font-size-xs) * var(--vk-line-height-xs)); }
|
|
54
|
+
.o-sort-editor-card .o-sort-editor-rule { gap: 0; padding-right: calc(var(--vk-spacing) * 1); border-radius: 0; }
|
|
55
|
+
.o-sort-editor-card .o-sort-editor-rule[data-lifted] { background-color: var(--vk-overlay); }
|
|
56
|
+
.o-sort-editor-press {
|
|
57
|
+
display: flex; flex: 1; align-items: center; gap: calc(var(--vk-spacing) * 3); align-self: stretch; min-width: 0; margin: 0; padding: 0;
|
|
58
|
+
border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent;
|
|
59
|
+
}
|
|
60
|
+
.o-sort-editor-press:focus-visible { outline: var(--vk-border-width) solid var(--vk-border-brand); outline-offset: calc(var(--vk-border-width) * -2); }
|
|
61
|
+
[data-sort-form="phone"] .o-sort-editor-press .o-sort-editor-mark svg { width: calc(var(--vk-spacing) * 5); height: calc(var(--vk-spacing) * 5); }
|
|
62
|
+
.o-sort-editor-words { display: grid; min-width: 0; }
|
|
63
|
+
.o-sort-editor-name, .o-sort-editor-way { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
64
|
+
.o-sort-editor-way { color: var(--vk-fg-subtle); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
|
|
65
|
+
[data-sort-form="narrow"] .o-sort-editor-way { font-size: var(--vk-font-size-xs); line-height: calc(var(--vk-font-size-xs) * var(--vk-line-height-xs)); }
|
|
66
|
+
.o-sort-editor-more { flex: none; }
|
|
67
|
+
.o-sort-editor-acts { display: grid; gap: calc(var(--vk-spacing) * 2); }
|
|
68
|
+
.o-sort-editor-acts .o-button { width: 100%; }
|
|
69
|
+
|
|
70
|
+
/* ── The narrow form: the phone's rows on the Pane's ground at a computer's sizes; Add sort and Clear all at 32 ─────────────── */
|
|
71
|
+
.o-sort-editor[data-sort-form="narrow"] { gap: calc(var(--vk-spacing) * 3); }
|
|
72
|
+
[data-sort-form="narrow"] .o-sort-editor-rules { gap: 0; }
|
|
73
|
+
/* A rule's row is lit whole, ⋮ inside its ground at its end, as the Picker's row (KIT-676, KIT-819): under the pointer, lifted, and
|
|
74
|
+
while ⋮'s menu is open; a direction's list a page shows standing in the row never lights it. The press keeps its room and its
|
|
75
|
+
corners, for its focus ring, and has no ground of its own. */
|
|
76
|
+
[data-sort-form="narrow"] .o-sort-editor-rule { position: relative; gap: var(--vk-spacing); padding-right: var(--vk-spacing); border-radius: var(--vk-radius-md); }
|
|
77
|
+
[data-sort-form="narrow"] .o-sort-editor-press {
|
|
78
|
+
min-height: calc(var(--vk-spacing) * 11); padding: var(--vk-spacing) calc(var(--vk-spacing) * 2); gap: calc(var(--vk-spacing) * 2.5); border-radius: var(--vk-radius-md);
|
|
79
|
+
}
|
|
80
|
+
[data-sort-form="narrow"] .o-sort-editor-rule:is([data-lifted], :has(.o-sort-editor-more:is([aria-expanded="true"], [data-popup-open]))) { background-color: var(--vk-overlay-hovered); }
|
|
81
|
+
@media (hover: hover) { [data-sort-form="narrow"] .o-sort-editor-rule:hover:not(:has(.o-sort-editor-shown:hover)) { background-color: var(--vk-overlay-hovered); } }
|
|
82
|
+
[data-sort-form="narrow"] .o-sort-editor-none { padding: 0 calc(var(--vk-spacing) * 2); }
|
|
83
|
+
/* A list a page shows standing open, under its rule: never wider than the Pane's column. */
|
|
84
|
+
.o-sort-editor[data-sort-form="narrow"] .o-sort-editor-shown[data-sort-shown="list"] { min-width: min(100%, calc(var(--vk-spacing) * 48)); max-width: 100%; }
|
|
85
|
+
|
|
86
|
+
/* ── A sort set aside (its field deleted or hidden), after the rules (Mihai, 27 Nov 2026) ─────────────────────────────── */
|
|
87
|
+
/* On a computer an empty place where the grip stands; its field's box dashed in the warning colour, its words too; its
|
|
88
|
+
direction greyed. On a phone and in the narrow form its why stands under its name in the warning colour. */
|
|
89
|
+
.o-sort-editor-grip-place { flex: none; width: calc(var(--vk-spacing) * 5); }
|
|
90
|
+
.o-sort-editor-why { display: flex; width: 100%; }
|
|
91
|
+
.o-sort-editor-why > .o-select { width: 100%; }
|
|
92
|
+
/* --input-edge is the Input's own edge colour (input.css), which the Select's box draws its edge with. */
|
|
93
|
+
.o-sort-editor-aside .o-sort-editor-field .o-select-field { --input-edge: var(--vk-border-warning); border-style: dashed; color: var(--vk-warning); }
|
|
94
|
+
.o-sort-editor-aside .o-sort-editor-field .o-select-placeholder { color: var(--vk-warning); }
|
|
95
|
+
.o-sort-editor-aside .o-sort-editor-way { color: var(--vk-warning); }
|
|
96
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Toast as BaseToast } from "@base-ui/react/toast";
|
|
3
|
+
import { type NoticeMeaning } from "../notice/notice.js";
|
|
4
|
+
export interface ToastOptions {
|
|
5
|
+
/** What just happened, in the past tense, naming the thing ("3 deals moved to Won"); no full stop, no
|
|
6
|
+
* "Successfully". Working, it ends in "…" ("Moving 3 deals to Won…"). */
|
|
7
|
+
words: string;
|
|
8
|
+
/** A name over the words, in the medium weight, when they need one ("Import finished"). */
|
|
9
|
+
title?: string;
|
|
10
|
+
/** The action can be taken back: "Undo" at the end puts it back, and ⌘Z does the same while it shows. */
|
|
11
|
+
undo?: () => void;
|
|
12
|
+
/** Any other one word that does something about it: "Open" for something just made, "Try again". */
|
|
13
|
+
action?: string;
|
|
14
|
+
onAction?: () => void;
|
|
15
|
+
/** Working: a spinner in front, no time limit, until it is turned into its result. */
|
|
16
|
+
working?: boolean;
|
|
17
|
+
/** Failed: a circled ! in the danger colour in front; the words say what didn't happen. */
|
|
18
|
+
failed?: boolean;
|
|
19
|
+
/** What it means, as a Notice's: its icon in front, in the meaning's colour (danger is failed). */
|
|
20
|
+
meaning?: NoticeMeaning;
|
|
21
|
+
/** A × at its end that closes it at once. */
|
|
22
|
+
closable?: boolean;
|
|
23
|
+
/** How long it stays, in ms; four seconds unless said (toast-duration), and a working one until it is
|
|
24
|
+
* turned into its result. */
|
|
25
|
+
duration?: number;
|
|
26
|
+
}
|
|
27
|
+
/** The words a toast draws of its own: Undo, and its ×'s name. */
|
|
28
|
+
export type ToastWords = {
|
|
29
|
+
undo: string;
|
|
30
|
+
close: string;
|
|
31
|
+
};
|
|
32
|
+
/** Its words in English. */
|
|
33
|
+
export declare const TOAST_WORDS: ToastWords;
|
|
34
|
+
type Base = ReturnType<typeof BaseToast.createToastManager>;
|
|
35
|
+
/** Toasts called from anywhere (an event, a fetch, code outside React): a Toast given it with `manager`
|
|
36
|
+
* shows what it sends. */
|
|
37
|
+
export interface ToastManager {
|
|
38
|
+
/** Shows a toast; its id, to change or close it later. */
|
|
39
|
+
show(o: ToastOptions): string;
|
|
40
|
+
/** Changes a toast where it stands: its words, its title, a working one into its result. */
|
|
41
|
+
update(id: string, o: ToastOptions): void;
|
|
42
|
+
/** Closes it at once; with no id, every one. */
|
|
43
|
+
close(id?: string): void;
|
|
44
|
+
/** A working toast while the promise runs, turned into its result where it stands once it settles. */
|
|
45
|
+
promise<T>(p: Promise<T>, o: {
|
|
46
|
+
working: string;
|
|
47
|
+
done: string | ((value: T) => string);
|
|
48
|
+
failed: string | ((error: unknown) => string);
|
|
49
|
+
title?: string;
|
|
50
|
+
}): Promise<T>;
|
|
51
|
+
/** Base UI's own manager, for the Toast that shows them. */
|
|
52
|
+
readonly base: Base;
|
|
53
|
+
}
|
|
54
|
+
/** A manager of toasts to call from anywhere; give it to the Toast that shows them. */
|
|
55
|
+
export declare function createToastManager(words?: Partial<ToastWords>): ToastManager;
|
|
56
|
+
/** Where toasts are made and where they rise: everything inside can show one (useToast), and they rise
|
|
57
|
+
* centred at the bottom of the screen, 16px up, at most 460px wide. `inside`: at the bottom of the
|
|
58
|
+
* element around it instead (a sample on a page that shows how it looks). `manager`: show the toasts a
|
|
59
|
+
* ToastManager sends from anywhere. One at a time unless `stack`: then several, the newest in front, the
|
|
60
|
+
* two before it peeking above, spread out under the pointer. Put it round the app once. */
|
|
61
|
+
export declare function Toast({ inside, manager, stack, words, children }: {
|
|
62
|
+
inside?: boolean;
|
|
63
|
+
manager?: ToastManager;
|
|
64
|
+
stack?: boolean;
|
|
65
|
+
words?: Partial<ToastWords>;
|
|
66
|
+
children: React.ReactNode;
|
|
67
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
/** Shows a toast: one at a time (unless the Toast stacks them), a working one turned into its result in place. */
|
|
69
|
+
export declare function useToast(): (o: ToastOptions) => string;
|
|
70
|
+
/** A toast standing still in the page, for a page that shows how it looks: it never times out or moves. */
|
|
71
|
+
export declare function ToastShown({ words, title, undo, action, working, failed, meaning, closable, said: own }: Omit<ToastOptions, "undo" | "onAction" | "duration"> & {
|
|
72
|
+
undo?: boolean;
|
|
73
|
+
said?: Partial<ToastWords>;
|
|
74
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Toast as BaseToast } from "@base-ui/react/toast";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { Button } from "../button/button.js";
|
|
6
|
+
import { msOf } from "../internal/read-token.js";
|
|
7
|
+
import { NOTICE_ICONS } from "../notice/notice.js";
|
|
8
|
+
import { Spinner } from "../spinner/spinner.js";
|
|
9
|
+
const glyph = (paths, className) => _jsx("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) });
|
|
10
|
+
const wrong = glyph(NOTICE_ICONS.danger, "o-toast-mark");
|
|
11
|
+
const X = ["M18 6l-12 12", "M6 6l12 12"];
|
|
12
|
+
export const TOAST_WORDS = { undo: "Undo", close: "Close" };
|
|
13
|
+
function toastWait() {
|
|
14
|
+
if (typeof document === "undefined")
|
|
15
|
+
return 4000;
|
|
16
|
+
return msOf(document.querySelector(".o-toast-viewport"), "--toast-wait") || msOf(document.documentElement, "--vk-toast-duration") || 4000;
|
|
17
|
+
}
|
|
18
|
+
function toBase(o, id, store, words) {
|
|
19
|
+
const act = o.undo ? { label: words.undo, run: o.undo } : o.action ? { label: o.action, run: o.onAction } : null;
|
|
20
|
+
const meaning = o.failed ? "danger" : o.meaning;
|
|
21
|
+
return {
|
|
22
|
+
id, title: o.title, description: o.words, type: o.working ? "working" : meaning === "danger" ? "failed" : meaning,
|
|
23
|
+
timeout: o.working ? 0 : o.duration ?? toastWait(), data: { undo: !!o.undo, closable: !!o.closable },
|
|
24
|
+
actionProps: act ? { children: act.label, onClick: () => { store.close(id); act.run?.(); } } : undefined,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
let made = 0;
|
|
28
|
+
export function createToastManager(words) {
|
|
29
|
+
const base = BaseToast.createToastManager(), shown = new Set(), said = { ...TOAST_WORDS, ...words };
|
|
30
|
+
const show = (o) => { const id = `toast-${++made}`; shown.add(id); base.add(toBase(o, id, base, said)); return id; };
|
|
31
|
+
const update = (id, o) => base.update(id, toBase(o, id, base, said));
|
|
32
|
+
return {
|
|
33
|
+
base, show, update,
|
|
34
|
+
close: (id) => { for (const one of id ? [id] : [...shown]) {
|
|
35
|
+
base.close(one);
|
|
36
|
+
shown.delete(one);
|
|
37
|
+
} },
|
|
38
|
+
promise: (p, o) => {
|
|
39
|
+
const id = show({ words: o.working, title: o.title, working: true });
|
|
40
|
+
p.then((v) => update(id, { words: typeof o.done === "function" ? o.done(v) : o.done, title: o.title, meaning: "success" }), (e) => update(id, { words: typeof o.failed === "function" ? o.failed(e) : o.failed, title: o.title, failed: true }));
|
|
41
|
+
return p;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const Stacked = React.createContext(false);
|
|
46
|
+
const Said = React.createContext(TOAST_WORDS);
|
|
47
|
+
export function Toast({ inside = false, manager, stack = false, words, children }) {
|
|
48
|
+
const said = React.useMemo(() => ({ ...TOAST_WORDS, ...words }), [words]);
|
|
49
|
+
return _jsx(Said.Provider, { value: said, children: _jsx(Stacked.Provider, { value: stack, children: _jsxs(BaseToast.Provider, { toastManager: manager?.base, children: [children, _jsx(Viewport, { inside: inside, stack: stack })] }) }) });
|
|
50
|
+
}
|
|
51
|
+
export function useToast() {
|
|
52
|
+
const m = BaseToast.useToastManager(), live = React.useRef(m.toasts), stack = React.useContext(Stacked), said = React.useContext(Said);
|
|
53
|
+
live.current = m.toasts;
|
|
54
|
+
return React.useCallback((o) => {
|
|
55
|
+
const now = live.current.find((t) => t.transitionStatus !== "ending");
|
|
56
|
+
if (now && now.type !== "working" && !stack)
|
|
57
|
+
m.close(now.id);
|
|
58
|
+
const id = now?.type === "working" ? now.id : `toast-${++made}`;
|
|
59
|
+
const made2 = m.add(toBase(o, id, m, said));
|
|
60
|
+
return made2;
|
|
61
|
+
}, [m, stack, said]);
|
|
62
|
+
}
|
|
63
|
+
function Viewport({ inside, stack }) {
|
|
64
|
+
const { toasts, close } = BaseToast.useToastManager(), said = React.useContext(Said);
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
if (stack)
|
|
67
|
+
return;
|
|
68
|
+
toasts.filter((t) => t.transitionStatus !== "ending").slice(1).forEach((t) => close(t.id));
|
|
69
|
+
}, [toasts, close, stack]);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
const now = toasts.find((t) => t.transitionStatus !== "ending");
|
|
72
|
+
if (!now)
|
|
73
|
+
return;
|
|
74
|
+
const key = (e) => {
|
|
75
|
+
if (e.key === "Escape")
|
|
76
|
+
close(now.id);
|
|
77
|
+
else if ((e.metaKey || e.ctrlKey) && !e.shiftKey && e.key.toLowerCase() === "z" && now.data?.undo && !e.target.closest?.("input, textarea, [contenteditable]")) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
now.actionProps?.onClick?.(e);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
document.addEventListener("keydown", key);
|
|
83
|
+
return () => document.removeEventListener("keydown", key);
|
|
84
|
+
}, [toasts, close]);
|
|
85
|
+
return (_jsx(BaseToast.Viewport, { className: cx("o-toast-viewport", inside && "o-toast-viewport-inside"), ...(stack ? { "data-stack": "" } : {}), children: toasts.map((t) => (_jsxs(BaseToast.Root, { toast: t, className: "o-toast o-smooth o-smooth-ease", swipeDirection: "down", "data-kit": "toast", children: [_jsx(Mark, { type: t.type }), t.title ? _jsxs("span", { className: "o-toast-text", children: [_jsx(BaseToast.Title, { className: "o-toast-title" }), _jsx(BaseToast.Description, { className: "o-toast-words" })] }) : _jsx(BaseToast.Description, { className: "o-toast-words" }), _jsx(BaseToast.Action, { render: _jsx(Button, { kind: "text", size: "xs", className: "o-toast-act" }) }), t.data?.closable && _jsx(BaseToast.Close, { render: _jsx(Button, { kind: "quiet", size: "xs", shape: "icon", className: "o-toast-act o-toast-close", "aria-label": said.close, icon: glyph(X, "") }) })] }, t.id))) }));
|
|
86
|
+
}
|
|
87
|
+
function Mark({ type }) {
|
|
88
|
+
if (type === "working")
|
|
89
|
+
return _jsx(Spinner, { size: 14, label: "" });
|
|
90
|
+
if (type === "failed")
|
|
91
|
+
return wrong;
|
|
92
|
+
if (type && type in NOTICE_ICONS)
|
|
93
|
+
return glyph(NOTICE_ICONS[type], "o-toast-mark");
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
export function ToastShown({ words, title, undo, action, working, failed, meaning, closable, said: own }) {
|
|
97
|
+
const said = { ...TOAST_WORDS, ...own }, label = undo ? said.undo : action, type = working ? "working" : failed || meaning === "danger" ? "failed" : meaning;
|
|
98
|
+
return (_jsxs("div", { className: "o-toast o-toast-shown o-smooth o-smooth-ease", role: "status", "data-type": type, "data-kit": "toast", children: [_jsx(Mark, { type: type }), title ? _jsxs("span", { className: "o-toast-text", children: [_jsx("span", { className: "o-toast-title", children: title }), _jsx("span", { className: "o-toast-words", children: words })] }) : _jsx("span", { className: "o-toast-words", children: words }), label && _jsx(Button, { kind: "text", size: "xs", className: "o-toast-act", tabIndex: -1, children: label }), closable && _jsx(Button, { kind: "quiet", size: "xs", shape: "icon", className: "o-toast-act o-toast-close", tabIndex: -1, "aria-label": said.close, icon: glyph(X, "") })] }));
|
|
99
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export declare const TOAST_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-layer-popup";
|
|
3
|
+
readonly kind: "size";
|
|
4
|
+
readonly outright: "--layer-popup";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-spacing";
|
|
7
|
+
readonly kind: "size";
|
|
8
|
+
readonly outright: "--spacing";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-radius-lg";
|
|
11
|
+
readonly kind: "size";
|
|
12
|
+
readonly outright: "--radius-lg";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-fg";
|
|
15
|
+
readonly kind: "colour";
|
|
16
|
+
readonly outright: "--text";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-ground";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--surface";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-shadow-lg";
|
|
23
|
+
readonly kind: "shadow";
|
|
24
|
+
readonly outright: "--shadow-lg";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-font-size-sm";
|
|
27
|
+
readonly kind: "size";
|
|
28
|
+
readonly outright: "--text-sm";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-line-height-sm";
|
|
31
|
+
readonly kind: "size";
|
|
32
|
+
readonly outright: "--text-sm--line-height";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-duration-base";
|
|
35
|
+
readonly kind: "motion";
|
|
36
|
+
readonly outright: "--duration-base";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-ease-out";
|
|
39
|
+
readonly kind: "motion";
|
|
40
|
+
readonly outright: "--ease-out";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-focus-width";
|
|
43
|
+
readonly kind: "size";
|
|
44
|
+
readonly outright: "--focus-width";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-border-brand";
|
|
47
|
+
readonly kind: "colour";
|
|
48
|
+
readonly outright: "--border-focused";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-focus-offset";
|
|
51
|
+
readonly kind: "size";
|
|
52
|
+
readonly outright: "--focus-offset";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-duration-fast";
|
|
55
|
+
readonly kind: "motion";
|
|
56
|
+
readonly outright: "--duration-fast";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-ease-in";
|
|
59
|
+
readonly kind: "motion";
|
|
60
|
+
readonly outright: "--ease-in";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-font-weight-semibold";
|
|
63
|
+
readonly kind: "size";
|
|
64
|
+
readonly outright: "--font-weight-semibold";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-danger";
|
|
67
|
+
readonly kind: "colour";
|
|
68
|
+
readonly outright: "--text-danger";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-font-weight-medium";
|
|
71
|
+
readonly kind: "size";
|
|
72
|
+
readonly outright: "--font-weight-medium";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-info";
|
|
75
|
+
readonly kind: "colour";
|
|
76
|
+
readonly outright: "--text-information";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-success";
|
|
79
|
+
readonly kind: "colour";
|
|
80
|
+
readonly outright: "--text-success";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "--vk-warning";
|
|
83
|
+
readonly kind: "colour";
|
|
84
|
+
readonly outright: "--text-warning";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-press-scale";
|
|
87
|
+
readonly kind: "motion";
|
|
88
|
+
readonly outright: "--press-scale";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "--vk-corner-smoothing";
|
|
91
|
+
readonly kind: "size";
|
|
92
|
+
readonly outright: "--corner-smoothing";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "--vk-toast-duration";
|
|
95
|
+
readonly kind: "motion";
|
|
96
|
+
readonly outright: "--toast-duration";
|
|
97
|
+
}];
|
|
98
|
+
/** The Toast's own machinery: Base UI's stack (`--toast-index`, `--toast-offset-y`, `--toast-height`, `--toast-frontmost-height`),
|
|
99
|
+
* how it fits its action, and how long it stays (`--toast-wait`, which its script reads off its viewport). */
|
|
100
|
+
export declare const TOAST_PRIVATE: readonly ["--toast-"];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const TOAST_TOKENS = [
|
|
2
|
+
{ name: "--vk-layer-popup", kind: "size", outright: "--layer-popup" },
|
|
3
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
4
|
+
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
5
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
6
|
+
{ name: "--vk-ground", kind: "colour", outright: "--surface" },
|
|
7
|
+
{ name: "--vk-shadow-lg", kind: "shadow", outright: "--shadow-lg" },
|
|
8
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
9
|
+
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
10
|
+
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
11
|
+
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
12
|
+
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
13
|
+
{ name: "--vk-border-brand", kind: "colour", outright: "--border-focused" },
|
|
14
|
+
{ name: "--vk-focus-offset", kind: "size", outright: "--focus-offset" },
|
|
15
|
+
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
16
|
+
{ name: "--vk-ease-in", kind: "motion", outright: "--ease-in" },
|
|
17
|
+
{ name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
|
|
18
|
+
{ name: "--vk-danger", kind: "colour", outright: "--text-danger" },
|
|
19
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
20
|
+
{ name: "--vk-info", kind: "colour", outright: "--text-information" },
|
|
21
|
+
{ name: "--vk-success", kind: "colour", outright: "--text-success" },
|
|
22
|
+
{ name: "--vk-warning", kind: "colour", outright: "--text-warning" },
|
|
23
|
+
{ name: "--vk-press-scale", kind: "motion", outright: "--press-scale" },
|
|
24
|
+
{ name: "--vk-corner-smoothing", kind: "size", outright: "--corner-smoothing" },
|
|
25
|
+
{ name: "--vk-toast-duration", kind: "motion", outright: "--toast-duration" },
|
|
26
|
+
];
|
|
27
|
+
export const TOAST_PRIVATE = ["--toast-"];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* The Toast. Every value it draws with is a public name (controls/toast/tokens.ts); this file only says which name
|
|
2
|
+
each part takes. Base UI marks a toast
|
|
3
|
+
data-starting-style and data-ending-style as it comes and goes, data-type working, failed or a meaning,
|
|
4
|
+
and, stacked, gives each its --toast-index, --toast-offset-y and heights, and data-expanded. Its
|
|
5
|
+
action is the Button's text kind and its × the quiet Button, both in its colours turned round.
|
|
6
|
+
|
|
7
|
+
The rules sit in the components layer, so a utility class on a toast still wins. */
|
|
8
|
+
@layer components {
|
|
9
|
+
|
|
10
|
+
/* How long a toast stays, read by its script off the viewport (toastWait). */
|
|
11
|
+
.o-toast-viewport { --toast-wait: var(--vk-toast-duration); }
|
|
12
|
+
|
|
13
|
+
/* ── Where it rises: centred at the bottom, 16px up; a toast that leaves and the one taking its place sit
|
|
14
|
+
in the same spot ────────────────────────────────────────────────────────────────────────────────── */
|
|
15
|
+
.o-toast-viewport {
|
|
16
|
+
position: fixed; z-index: var(--vk-layer-popup); left: 0; right: 0; bottom: calc(var(--vk-spacing) * 4);
|
|
17
|
+
display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-items: end; padding: 0 calc(var(--vk-spacing) * 4); pointer-events: none; outline: none;
|
|
18
|
+
}
|
|
19
|
+
.o-toast-viewport.o-toast-viewport-inside { position: absolute; }
|
|
20
|
+
.o-toast-viewport > .o-toast { grid-area: 1 / 1; }
|
|
21
|
+
|
|
22
|
+
/* ── The toast: the page's colours turned round, like the Tooltip, so it reads at once in both themes;
|
|
23
|
+
the radius's corners, 40px tall, 16px in on the left; it floats, so it casts the large shadow ─────── */
|
|
24
|
+
.o-toast {
|
|
25
|
+
display: inline-flex; align-items: center; gap: calc(var(--vk-spacing) * 3); box-sizing: border-box;
|
|
26
|
+
width: max-content; max-width: min(calc(var(--vk-spacing) * 115), 100%); min-height: calc(var(--vk-spacing) * 10);
|
|
27
|
+
padding: calc(var(--vk-spacing) * 1.5) calc(var(--vk-spacing) * 1.5) calc(var(--vk-spacing) * 1.5) calc(var(--vk-spacing) * 4);
|
|
28
|
+
border-radius: var(--vk-radius-lg); background-color: var(--vk-fg); color: var(--vk-ground); box-shadow: var(--vk-shadow-lg);
|
|
29
|
+
font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); pointer-events: auto; outline: none;
|
|
30
|
+
transition: opacity var(--vk-duration-base) var(--vk-ease-out), translate var(--vk-duration-base) var(--vk-ease-out);
|
|
31
|
+
}
|
|
32
|
+
.o-toast:not(:has(.o-toast-act)) { padding-right: calc(var(--vk-spacing) * 4); }
|
|
33
|
+
.o-toast:focus-visible { outline: var(--vk-focus-width) solid var(--vk-border-brand); outline-offset: var(--vk-focus-offset); }
|
|
34
|
+
/* It rises 16px and fades in; it fades out, quicker. */
|
|
35
|
+
.o-toast[data-starting-style] { opacity: 0; translate: 0 calc(var(--vk-spacing) * 4); }
|
|
36
|
+
.o-toast[data-ending-style] { opacity: 0; transition: opacity var(--vk-duration-fast) var(--vk-ease-in); }
|
|
37
|
+
|
|
38
|
+
/* ── Its words, then what to do about it: one word in the toast's words colour, semibold ─────────────── */
|
|
39
|
+
.o-toast-words { min-width: 0; margin: 0; }
|
|
40
|
+
.o-button.o-toast-act { color: var(--vk-ground); font-weight: var(--vk-font-weight-semibold); }
|
|
41
|
+
/* Its focus ring hugs it, as the text kind's does. */
|
|
42
|
+
.o-button.o-toast-act:is(:focus-visible, [data-force="focus"]) { outline-offset: 0; }
|
|
43
|
+
|
|
44
|
+
/* ── Working: the 14px spinner in front; failed: a circled ! in the danger colour ────────────────────── */
|
|
45
|
+
.o-toast > .o-spinner { margin-right: calc(var(--vk-spacing) * -0.75); }
|
|
46
|
+
.o-toast-mark { flex: none; width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4); margin-right: calc(var(--vk-spacing) * -1); color: var(--vk-danger); }
|
|
47
|
+
|
|
48
|
+
/* ── A title over its words, in the medium weight ─────────────────────────────────────────────────── */
|
|
49
|
+
.o-toast-text { display: grid; gap: calc(var(--vk-spacing) * 0.5); min-width: 0; padding: calc(var(--vk-spacing) * 1) 0; }
|
|
50
|
+
.o-toast-title { font-size: inherit; line-height: inherit; font-weight: var(--vk-font-weight-medium); }
|
|
51
|
+
|
|
52
|
+
/* ── Its meaning, as a Notice's: the meaning's icon in front, in its colour (failed is the danger one) ─ */
|
|
53
|
+
.o-toast[data-type="information"] > .o-toast-mark { color: var(--vk-info); }
|
|
54
|
+
.o-toast[data-type="success"] > .o-toast-mark { color: var(--vk-success); }
|
|
55
|
+
.o-toast[data-type="warning"] > .o-toast-mark { color: var(--vk-warning); }
|
|
56
|
+
|
|
57
|
+
/* ── A × at its end: the quiet Button, its 16px icon in the toast's colours; the pointer gives it no fill,
|
|
58
|
+
whatever the Button's look ─────────────────────────────────────────── */
|
|
59
|
+
/* A hover only on a screen with a pointer (iOS keeps :hover on what was last tapped); a press and the forced state stay out. */
|
|
60
|
+
.o-toast .o-button.o-button-quiet.o-toast-close:is([data-force="hover"], :active, [data-force="press"]) { --button-ground: transparent; --button-light: none; --button-depth: none; translate: none; color: var(--vk-ground); }
|
|
61
|
+
@media (hover: hover) { .o-toast .o-button.o-button-quiet.o-toast-close:hover { --button-ground: transparent; --button-light: none; --button-depth: none; translate: none; color: var(--vk-ground); } }
|
|
62
|
+
|
|
63
|
+
/* ── Several at once: each 460px or the width it has; the newest in front, the two before it the front
|
|
64
|
+
one's height, peeking 8px above it each, each a little narrower (twice the press's step, from its top
|
|
65
|
+
edge) so their edges show; the pointer or focus on them spreads them out, 8px apart, each its own
|
|
66
|
+
height and width ───────────────────────────────────────────────────────────────────────────────────── */
|
|
67
|
+
.o-toast-viewport[data-stack] > .o-toast {
|
|
68
|
+
width: min(calc(var(--vk-spacing) * 115), 100%); z-index: calc(var(--toast-index) * -1); overflow: hidden;
|
|
69
|
+
transition: opacity var(--vk-duration-base) var(--vk-ease-out), translate var(--vk-duration-base) var(--vk-ease-out), scale var(--vk-duration-base) var(--vk-ease-out), height var(--vk-duration-base) var(--vk-ease-out);
|
|
70
|
+
}
|
|
71
|
+
.o-toast-viewport[data-stack] > .o-toast:not([data-expanded]) { height: var(--toast-frontmost-height, auto); translate: 0 calc(var(--toast-index) * var(--vk-spacing) * -2); scale: calc(1 - (1 - var(--vk-press-scale)) * var(--toast-index) * 2); transform-origin: top center; }
|
|
72
|
+
.o-toast-viewport[data-stack] > .o-toast[data-expanded] { height: var(--toast-height, auto); translate: 0 calc((var(--toast-offset-y) + var(--toast-index) * var(--vk-spacing) * 2) * -1); }
|
|
73
|
+
.o-toast-viewport[data-stack] > .o-toast[data-limited] { opacity: 0; pointer-events: none; }
|
|
74
|
+
.o-toast-viewport[data-stack] > .o-toast[data-starting-style] { translate: 0 calc(var(--vk-spacing) * 4); }
|
|
75
|
+
|
|
76
|
+
/* Under reduced motion it appears and goes without moving. */
|
|
77
|
+
@media (prefers-reduced-motion: reduce) { .o-toast, .o-toast-viewport[data-stack] > .o-toast { transition: none; } .o-toast[data-starting-style] { translate: none; } }
|
|
78
|
+
/* ── Its corners smooth: following corner-smoothing, drawn with the smooth outline
|
|
79
|
+
(smooth.css) in every browser that knows shape(); one that doesn't keeps the corners above. Its round part is fitted to its
|
|
80
|
+
40px, as a control's is. It casts a shadow and its focus ring stands outside it, so it is never clipped: its ground is a layer
|
|
81
|
+
inside it (::before), clipped, as the Popover's is, the shadow and the ring on itself. ── */
|
|
82
|
+
@supports (clip-path: shape(evenodd from 0 0, curve by 1px 1px with 1px 0 / 1px 0, close, move to 0 0, hline to 1px, close)) and (width: calc(tan(atan2(1px, 1px)) * 1px)) {
|
|
83
|
+
.o-toast {
|
|
84
|
+
--smooth-amount: var(--vk-corner-smoothing); --smooth-side: calc(var(--vk-spacing) * 10);
|
|
85
|
+
--toast-fit: min(var(--vk-radius-lg), var(--vk-spacing) * 10 / (2 + 2 * var(--smooth-amount, 0.7))); --smooth-t: var(--toast-fit);
|
|
86
|
+
position: relative; isolation: isolate; border-radius: var(--toast-fit); background-color: transparent;
|
|
87
|
+
}
|
|
88
|
+
.o-toast::before {
|
|
89
|
+
content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
|
|
90
|
+
background-color: var(--vk-fg); clip-path: shape(var(--smooth-outline));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -24,8 +24,18 @@ import { SELECT_PRIVATE, SELECT_TOKENS } from "./select/tokens.js";
|
|
|
24
24
|
import { PICKER_PRIVATE, PICKER_TOKENS } from "./picker/tokens.js";
|
|
25
25
|
import { AVATAR_PRIVATE, AVATAR_TOKENS } from "./avatar/tokens.js";
|
|
26
26
|
import { POPUP_LINE_PRIVATE, POPUP_LINE_TOKENS } from "./popup-line/tokens.js";
|
|
27
|
+
import { PANE_PRIVATE, PANE_TOKENS } from "./pane/tokens.js";
|
|
27
28
|
import { RADIO_PRIVATE, RADIO_TOKENS } from "./radio/tokens.js";
|
|
29
|
+
import { SORT_EDITOR_PRIVATE, SORT_EDITOR_TOKENS } from "./sort-editor/tokens.js";
|
|
28
30
|
import { VIEWS_LIST_PRIVATE, VIEWS_LIST_TOKENS } from "./views-list/tokens.js";
|
|
31
|
+
import { FILTER_EDITOR_PRIVATE, FILTER_EDITOR_TOKENS } from "./filter-editor/tokens.js";
|
|
32
|
+
import { GROUP_EDITOR_PRIVATE, GROUP_EDITOR_TOKENS } from "./group-editor/tokens.js";
|
|
33
|
+
import { MODAL_PRIVATE, MODAL_TOKENS } from "./modal/tokens.js";
|
|
34
|
+
import { ALERT_DIALOG_PRIVATE, ALERT_DIALOG_TOKENS } from "./alert-dialog/tokens.js";
|
|
35
|
+
import { TOAST_PRIVATE, TOAST_TOKENS } from "./toast/tokens.js";
|
|
36
|
+
import { COLLAPSIBLE_PRIVATE, COLLAPSIBLE_TOKENS } from "./collapsible/tokens.js";
|
|
37
|
+
import { ALERT_PRIVATE, ALERT_TOKENS } from "./alert/tokens.js";
|
|
38
|
+
import { NOTICE_PRIVATE, NOTICE_TOKENS } from "./notice/tokens.js";
|
|
29
39
|
import { TEXT_EDITOR_PRIVATE, TEXT_EDITOR_TOKENS } from "./text-editor/tokens.js";
|
|
30
40
|
import { DATE_EDITOR_PRIVATE, DATE_EDITOR_TOKENS } from "./date-editor/tokens.js";
|
|
31
41
|
import { COMPOUND_EDITOR_PRIVATE, COMPOUND_EDITOR_TOKENS } from "./compound-editor/tokens.js";
|
|
@@ -60,8 +70,18 @@ const CONTROLS_OWN = {
|
|
|
60
70
|
select: { tokens: SELECT_TOKENS, private: SELECT_PRIVATE },
|
|
61
71
|
picker: { tokens: PICKER_TOKENS, private: PICKER_PRIVATE },
|
|
62
72
|
avatar: { tokens: AVATAR_TOKENS, private: AVATAR_PRIVATE },
|
|
73
|
+
pane: { tokens: PANE_TOKENS, private: PANE_PRIVATE },
|
|
63
74
|
radio: { tokens: RADIO_TOKENS, private: RADIO_PRIVATE },
|
|
75
|
+
"sort-editor": { tokens: SORT_EDITOR_TOKENS, private: SORT_EDITOR_PRIVATE },
|
|
64
76
|
"views-list": { tokens: VIEWS_LIST_TOKENS, private: VIEWS_LIST_PRIVATE },
|
|
77
|
+
"filter-editor": { tokens: FILTER_EDITOR_TOKENS, private: FILTER_EDITOR_PRIVATE },
|
|
78
|
+
"group-editor": { tokens: GROUP_EDITOR_TOKENS, private: GROUP_EDITOR_PRIVATE },
|
|
79
|
+
modal: { tokens: MODAL_TOKENS, private: MODAL_PRIVATE },
|
|
80
|
+
"alert-dialog": { tokens: ALERT_DIALOG_TOKENS, private: ALERT_DIALOG_PRIVATE },
|
|
81
|
+
toast: { tokens: TOAST_TOKENS, private: TOAST_PRIVATE },
|
|
82
|
+
collapsible: { tokens: COLLAPSIBLE_TOKENS, private: COLLAPSIBLE_PRIVATE },
|
|
83
|
+
alert: { tokens: ALERT_TOKENS, private: ALERT_PRIVATE },
|
|
84
|
+
notice: { tokens: NOTICE_TOKENS, private: NOTICE_PRIVATE },
|
|
65
85
|
"text-editor": { tokens: TEXT_EDITOR_TOKENS, private: TEXT_EDITOR_PRIVATE },
|
|
66
86
|
"date-editor": { tokens: DATE_EDITOR_TOKENS, private: DATE_EDITOR_PRIVATE },
|
|
67
87
|
"compound-editor": { tokens: COMPOUND_EDITOR_TOKENS, private: COMPOUND_EDITOR_PRIVATE },
|
|
@@ -19,6 +19,7 @@ import { cx } from "../../internal/cx.js";
|
|
|
19
19
|
import { moved, useReorder } from "../internal/reorder.js";
|
|
20
20
|
import { useShellHand } from "../internal/shell-hand.js";
|
|
21
21
|
import { spacingPx } from "../internal/read-token.js";
|
|
22
|
+
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
22
23
|
import { EDITOR_INNER_ESCAPE } from "../../editors/inner-escape.js";
|
|
23
24
|
const ROW_28 = { "--inline-input-row": "calc(var(--vk-spacing) * 7)" };
|
|
24
25
|
const ROW_40 = { "--inline-input-row": "calc(var(--vk-spacing) * 10)" };
|
|
@@ -243,10 +244,15 @@ export function useValuesEditor(props) {
|
|
|
243
244
|
hold();
|
|
244
245
|
if (row != null)
|
|
245
246
|
setLabelOf(row);
|
|
247
|
+
if (phone && to === "rows")
|
|
248
|
+
requestAnimationFrame(() => { swapping.current = false; });
|
|
246
249
|
setView(to);
|
|
247
|
-
setFocusTo(to === "rows" ? (editing != null ? ".o-values-editor-edit input" : ".o-values-editor-line-input") : ".o-picker-input, [role='option']");
|
|
250
|
+
setFocusTo(to === "rows" ? (phone ? null : editing != null ? ".o-values-editor-edit input" : ".o-values-editor-line-input") : ".o-picker-input, [role='option']");
|
|
248
251
|
};
|
|
249
252
|
const back = () => go("rows");
|
|
253
|
+
const labelRow = labelOf != null ? rows[labelOf] : undefined;
|
|
254
|
+
useStepReturn(root, !phone ? [] : view === "label" && labelRow ? [openerAt(() => `[data-row="${CSS.escape(String(labelRow.id))}"] :is(.o-values-editor-label, .o-values-editor-edit-label)`)]
|
|
255
|
+
: view === "dial" ? [".o-values-editor-code"] : []);
|
|
250
256
|
const labelItems = [...labels, ...(labelOf != null && rows[labelOf]?.label && !labels.includes(rows[labelOf].label) ? [rows[labelOf].label] : [])].map((l) => ({ value: l, label: l }));
|
|
251
257
|
const setLabel = (l) => { if (typeof l === "string" && labelOf != null)
|
|
252
258
|
setRows((rs) => rs.map((r, i) => (i === labelOf ? { ...r, label: l } : r))); };
|
|
@@ -6,12 +6,12 @@ import { cx } from "../internal/cx.js";
|
|
|
6
6
|
import { useViews } from "../provider/context.js";
|
|
7
7
|
import { formatDateValue } from "./format.js";
|
|
8
8
|
import { cellTextClass } from "./text-class.js";
|
|
9
|
-
import {
|
|
9
|
+
import { useDateDisplayOptions } from "./use-display-options.js";
|
|
10
10
|
export function renderDate(field, value, opts) {
|
|
11
11
|
return _jsx(DateValue, { field: field, value: value, opts: opts });
|
|
12
12
|
}
|
|
13
13
|
function DateValue({ field, value, opts: given, }) {
|
|
14
|
-
const opts =
|
|
14
|
+
const opts = useDateDisplayOptions(given);
|
|
15
15
|
const { Tooltip } = useViews().components;
|
|
16
16
|
const [pointed, setPointed] = useState(false);
|
|
17
17
|
const [pressed, setPressed] = useState(false);
|
|
@@ -52,6 +52,8 @@ function numberFormat(locale, options) {
|
|
|
52
52
|
return format;
|
|
53
53
|
}
|
|
54
54
|
function viewerToday(context) {
|
|
55
|
+
if (!context.now)
|
|
56
|
+
return null;
|
|
55
57
|
const parts = dateFormat("en-US", {
|
|
56
58
|
timeZone: context.timeZone ?? DEFAULT_CONVENTIONS.timeZone,
|
|
57
59
|
year: "numeric",
|
|
@@ -85,7 +87,7 @@ function absoluteDay({ year, month, day }, style, today, context, time) {
|
|
|
85
87
|
? `${pad2(day)}/${pad2(month)}/${year}`
|
|
86
88
|
: style === "long"
|
|
87
89
|
? `${day} ${name("long")} ${year}`
|
|
88
|
-
: `${pad2(day)} ${name("short")}${year === today
|
|
90
|
+
: `${pad2(day)} ${name("short")}${year === today?.year ? "" : ` ${year}`}`;
|
|
89
91
|
return time ? `${date}, ${time}` : date;
|
|
90
92
|
}
|
|
91
93
|
function instantParts(instant, timeZone) {
|
|
@@ -176,7 +178,13 @@ export function formatDateValue(value, dateStyle, withTime, kind = "datetime", o
|
|
|
176
178
|
const { implementation, context } = presentation(opts);
|
|
177
179
|
const day = typeof value === "string" ? value : toDayKey(d);
|
|
178
180
|
let out;
|
|
179
|
-
if (style === "relative") {
|
|
181
|
+
if (style === "relative" && !context.now) {
|
|
182
|
+
out =
|
|
183
|
+
kind === "date"
|
|
184
|
+
? implementation.calendarDay({ day, style: "short", context })
|
|
185
|
+
: implementation.instant({ instant: d, style: "short", withTime: true, context });
|
|
186
|
+
}
|
|
187
|
+
else if (style === "relative") {
|
|
180
188
|
out =
|
|
181
189
|
kind === "date"
|
|
182
190
|
? implementation.relativeCalendarDay({ day, context })
|
|
@@ -52,7 +52,9 @@ export type FieldViewerContext = {
|
|
|
52
52
|
timeZone?: string;
|
|
53
53
|
/** The viewer's country, from the conventions: a phone of that country is written as at home. */
|
|
54
54
|
region?: string;
|
|
55
|
-
|
|
55
|
+
/** The moment relative dates count from: the provider's. Absent before the provider has one (`ViewsProvider`'s
|
|
56
|
+
* `now`, or its one read after mount): a date that needs it draws its full form. */
|
|
57
|
+
now?: Date;
|
|
56
58
|
/** Fields' own words (`time.ago`). Default: fields' English. */
|
|
57
59
|
fieldMessages?: FieldMessageResolver;
|
|
58
60
|
/** The views package's words (`views.display.*`). Default: the package's English. */
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { DisplayOptions } from "./options.js";
|
|
2
|
+
/** For a value that draws no date: its viewer carries no moment, so a minute's read of the clock doesn't redraw it. */
|
|
2
3
|
export declare function useDisplayOptions(opts: DisplayOptions | undefined): DisplayOptions;
|
|
4
|
+
/** For a date: its viewer counts from the provider's moment, and redraws when it moves. */
|
|
5
|
+
export declare function useDateDisplayOptions(opts: DisplayOptions | undefined): DisplayOptions;
|