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,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../internal/cx.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import { NOTICE_ICONS } from "../notice/notice.js";
|
|
5
|
+
const glyph = (paths) => _jsx("svg", { 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)) });
|
|
6
|
+
export const ALERT_WORDS = { tryAgain: "Try again" };
|
|
7
|
+
const MARK = { primary: NOTICE_ICONS.information, information: NOTICE_ICONS.information, success: NOTICE_ICONS.success, warning: NOTICE_ICONS.warning, danger: NOTICE_ICONS.danger };
|
|
8
|
+
export function Alert({ title, line, action, kind = "primary", cancel = "Cancel", icon, onAnswer, state = "rest", failed, phone = false, shell = "panel", cancelRef, Title = "h2", Line = "p", words }) {
|
|
9
|
+
const working = state === "working", wrong = state === "failed", size = phone ? "lg" : undefined, says = wrong ? failed : line;
|
|
10
|
+
return (_jsxs("div", { className: "o-alert-body", "data-kind": kind, "data-screen": phone ? "phone" : "computer", "data-shell": shell, "data-kit": "alert", children: [_jsx("span", { className: "o-alert-mark", "aria-hidden": "true", children: icon ?? glyph(MARK[kind]) }), _jsx(Title, { className: "o-alert-title", children: title }), says != null && _jsx(Line, { className: cx("o-alert-line", wrong && "o-alert-wrong"), children: says }), _jsxs("div", { className: "o-alert-foot", children: [_jsx(Button, { ref: cancelRef, size: size, className: "o-alert-cancel", disabled: working, onClick: () => onAnswer(false), children: cancel }), _jsx(Button, { kind: kind, size: size, loading: working, onClick: () => onAnswer(true), children: wrong ? (words?.tryAgain ?? ALERT_WORDS.tryAgain) : action })] })] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PieceLooks } from "../../looks/looks.js";
|
|
2
|
+
export type AlertOptionId = "buttons" | "size" | "pair" | "mark" | "phone";
|
|
3
|
+
/** The Alert's options and its looks: Even has Attio's shape, Plain CloudWorks', Marked Atlas'. */
|
|
4
|
+
export declare const ALERT_LOOKS: PieceLooks<AlertOptionId>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const steps = (ids) => ids.map((id) => ({ id, name: id }));
|
|
2
|
+
const options = [
|
|
3
|
+
{ id: "buttons", name: "Buttons", device: "desktop", def: "end", values: [{ id: "end", name: "At the end" }, { id: "full", name: "Full width" }] },
|
|
4
|
+
{ id: "size", name: "Button size", device: "desktop", def: "36", kind: "steps", values: steps(["32", "36", "44"]) },
|
|
5
|
+
{ id: "pair", name: "Buttons", device: "phone", def: "side", values: [{ id: "side", name: "Side by side" }, { id: "stacked", name: "Stacked" }] },
|
|
6
|
+
{ id: "mark", name: "Mark", def: "none", values: [{ id: "none", name: "None" }, { id: "shown", name: "Shown" }] },
|
|
7
|
+
{ id: "phone", name: "Opens as", device: "phone", def: "panel", values: [{ id: "panel", name: "Panel" }, { id: "sheet", name: "Sheet" }] },
|
|
8
|
+
];
|
|
9
|
+
const shared = { size: "36", pair: "side", phone: "panel" };
|
|
10
|
+
export const ALERT_LOOKS = {
|
|
11
|
+
id: "alert",
|
|
12
|
+
name: "Alert",
|
|
13
|
+
options,
|
|
14
|
+
looks: [
|
|
15
|
+
{ id: "even", name: "Even", picks: { ...shared, buttons: "full", mark: "none" } },
|
|
16
|
+
{ id: "plain", name: "Plain", picks: { ...shared, buttons: "end", mark: "none" } },
|
|
17
|
+
{ id: "marked", name: "Marked", picks: { ...shared, buttons: "full", mark: "shown" } },
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export declare const ALERT_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-fg";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--text";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-spacing";
|
|
7
|
+
readonly kind: "size";
|
|
8
|
+
readonly outright: "--spacing";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-font-size-lg";
|
|
11
|
+
readonly kind: "size";
|
|
12
|
+
readonly outright: "--text-lg";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-font-size-base";
|
|
15
|
+
readonly kind: "size";
|
|
16
|
+
readonly outright: "--text-base";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-line-height-base";
|
|
19
|
+
readonly kind: "size";
|
|
20
|
+
readonly outright: "--text-base--line-height";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-font-weight-semibold";
|
|
23
|
+
readonly kind: "size";
|
|
24
|
+
readonly outright: "--font-weight-semibold";
|
|
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-fg-subtle";
|
|
35
|
+
readonly kind: "colour";
|
|
36
|
+
readonly outright: "--text-subtle";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-danger";
|
|
39
|
+
readonly kind: "colour";
|
|
40
|
+
readonly outright: "--text-danger";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-overlay-card";
|
|
43
|
+
readonly kind: "colour";
|
|
44
|
+
readonly outright: "--surface-overlay-card";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-overlay-card-pressed";
|
|
47
|
+
readonly kind: "colour";
|
|
48
|
+
readonly outright: "--surface-overlay-card-pressed";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-radius-full";
|
|
51
|
+
readonly kind: "size";
|
|
52
|
+
readonly outright: "--radius-full";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-brand-subtler";
|
|
55
|
+
readonly kind: "colour";
|
|
56
|
+
readonly outright: "--background-brand-subtler";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-fg-accent";
|
|
59
|
+
readonly kind: "colour";
|
|
60
|
+
readonly outright: "--text-brand";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-info-subtler";
|
|
63
|
+
readonly kind: "colour";
|
|
64
|
+
readonly outright: "--background-information-subtler";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-info";
|
|
67
|
+
readonly kind: "colour";
|
|
68
|
+
readonly outright: "--text-information";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-success-subtler";
|
|
71
|
+
readonly kind: "colour";
|
|
72
|
+
readonly outright: "--background-success-subtler";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-success";
|
|
75
|
+
readonly kind: "colour";
|
|
76
|
+
readonly outright: "--text-success";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-warning-subtler";
|
|
79
|
+
readonly kind: "colour";
|
|
80
|
+
readonly outright: "--background-warning-subtler";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "--vk-warning";
|
|
83
|
+
readonly kind: "colour";
|
|
84
|
+
readonly outright: "--text-warning";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-danger-subtler";
|
|
87
|
+
readonly kind: "colour";
|
|
88
|
+
readonly outright: "--background-danger-subtler";
|
|
89
|
+
}];
|
|
90
|
+
/** The Alert's own machinery: how far its words stand from the panel's edge (`--alert-padding`, which the alert dialog's panel
|
|
91
|
+
* sets), and the alert dialog's panel's own (its corners, margins, the edge's corner). */
|
|
92
|
+
export declare const ALERT_PRIVATE: readonly ["--alert-"];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const ALERT_TOKENS = [
|
|
2
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
3
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
4
|
+
{ name: "--vk-font-size-lg", kind: "size", outright: "--text-lg" },
|
|
5
|
+
{ name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
|
|
6
|
+
{ name: "--vk-line-height-base", kind: "size", outright: "--text-base--line-height" },
|
|
7
|
+
{ name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
|
|
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-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
11
|
+
{ name: "--vk-danger", kind: "colour", outright: "--text-danger" },
|
|
12
|
+
{ name: "--vk-overlay-card", kind: "colour", outright: "--surface-overlay-card" },
|
|
13
|
+
{ name: "--vk-overlay-card-pressed", kind: "colour", outright: "--surface-overlay-card-pressed" },
|
|
14
|
+
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
15
|
+
{ name: "--vk-brand-subtler", kind: "colour", outright: "--background-brand-subtler" },
|
|
16
|
+
{ name: "--vk-fg-accent", kind: "colour", outright: "--text-brand" },
|
|
17
|
+
{ name: "--vk-info-subtler", kind: "colour", outright: "--background-information-subtler" },
|
|
18
|
+
{ name: "--vk-info", kind: "colour", outright: "--text-information" },
|
|
19
|
+
{ name: "--vk-success-subtler", kind: "colour", outright: "--background-success-subtler" },
|
|
20
|
+
{ name: "--vk-success", kind: "colour", outright: "--text-success" },
|
|
21
|
+
{ name: "--vk-warning-subtler", kind: "colour", outright: "--background-warning-subtler" },
|
|
22
|
+
{ name: "--vk-warning", kind: "colour", outright: "--text-warning" },
|
|
23
|
+
{ name: "--vk-danger-subtler", kind: "colour", outright: "--background-danger-subtler" },
|
|
24
|
+
];
|
|
25
|
+
export const ALERT_PRIVATE = ["--alert-"];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type AlertAsk, type AlertState, type AlertWords } from "../alert/alert.js";
|
|
3
|
+
export { confirm } from "./confirm.js";
|
|
4
|
+
/** The words an alert dialog draws of its own: its X's name, what a failure says when its work threw no words, and the Alert's. */
|
|
5
|
+
export type AlertDialogWords = {
|
|
6
|
+
close: string;
|
|
7
|
+
failed: string;
|
|
8
|
+
} & AlertWords;
|
|
9
|
+
/** Its words in English. */
|
|
10
|
+
export declare const ALERT_DIALOG_WORDS: AlertDialogWords;
|
|
11
|
+
export interface AlertDialogProps extends AlertAsk {
|
|
12
|
+
open: boolean;
|
|
13
|
+
/** Told when it closes, with its answer. */
|
|
14
|
+
onAnswer: (yes: boolean) => void;
|
|
15
|
+
/** Shown as it stands, on a page that shows one. Left out, its own. */
|
|
16
|
+
state?: AlertState;
|
|
17
|
+
/** What went wrong, on a page that shows one. Left out, what its `run` threw. */
|
|
18
|
+
failed?: React.ReactNode;
|
|
19
|
+
/** Where it is drawn: over the whole page, or inside an element that holds it as a window holds a page. */
|
|
20
|
+
container?: HTMLElement | null;
|
|
21
|
+
/** It stands in `container`, a screen on a page that shows it: what's round that screen stays live. */
|
|
22
|
+
standing?: boolean;
|
|
23
|
+
/** Its own words, over the English. */
|
|
24
|
+
words?: Partial<AlertDialogWords>;
|
|
25
|
+
}
|
|
26
|
+
export interface AlertDialogPanelProps {
|
|
27
|
+
open: boolean;
|
|
28
|
+
/** Told when a way out closes it: Escape, or its X. */
|
|
29
|
+
onClose: () => void;
|
|
30
|
+
/** It stands on the phone. */
|
|
31
|
+
phone: boolean;
|
|
32
|
+
/** Its X can't be pressed: the Alert in it is working. */
|
|
33
|
+
busy?: boolean;
|
|
34
|
+
container?: HTMLElement | null;
|
|
35
|
+
standing?: boolean;
|
|
36
|
+
/** Where focus starts, when it isn't standing on a page. */
|
|
37
|
+
initialFocus?: React.RefObject<HTMLElement | null>;
|
|
38
|
+
/** Its X's name on the phone: "Close" unless said. */
|
|
39
|
+
close?: string;
|
|
40
|
+
children?: React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
/** The panel alone, round what it holds: what's behind it, the panel in the middle of the screen, and its X on the phone. */
|
|
43
|
+
export declare function AlertDialogPanel({ open, onClose, phone, busy, container, standing, initialFocus, close, children }: AlertDialogPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
/** Asks one thing, in the place an app picked: its panel, or on the phone a Sheet. `confirm()` opens one from anywhere. */
|
|
45
|
+
export declare function AlertDialog({ open, onAnswer, state, failed, container, standing, run, words, ...ask }: AlertDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
/** Where `confirm()` shows. Put it in the app once. */
|
|
47
|
+
export declare function AlertDialogHost({ container, words }: {
|
|
48
|
+
container?: HTMLElement | null;
|
|
49
|
+
words?: Partial<AlertDialogWords>;
|
|
50
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { AlertDialog as BaseAlert } from "@base-ui/react/alert-dialog";
|
|
4
|
+
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
|
|
5
|
+
import { Alert, ALERT_WORDS } from "../alert/alert.js";
|
|
6
|
+
import { Button } from "../button/button.js";
|
|
7
|
+
import { GlassButton } from "../glass-button/glass-button.js";
|
|
8
|
+
import { PhoneHost, usePhone } from "../internal/phone.js";
|
|
9
|
+
import { usePopupHost } from "../internal/popup-host.js";
|
|
10
|
+
import { Sheet, SheetBody } from "../sheet/bottom-sheet.js";
|
|
11
|
+
import { answered, asked, subscribe } from "./confirm.js";
|
|
12
|
+
export { confirm } from "./confirm.js";
|
|
13
|
+
const glyph = (paths) => _jsx("svg", { 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)) });
|
|
14
|
+
const X = ["M18 6l-12 12", "M6 6l12 12"];
|
|
15
|
+
function Held({ phone, shell, disabled, onClose, close, children }) {
|
|
16
|
+
return (_jsxs("div", { className: "o-alert-held", "data-screen": phone ? "phone" : "computer", "data-shell": shell, "data-kit": "alert-dialog", children: [children, phone && (_jsxs("span", { className: "o-alert-x", children: [_jsx(GlassButton, { "aria-label": close, className: "o-alert-x-glass", icon: glyph(X), disabled: disabled, onClick: onClose }), _jsx(Button, { kind: "quiet", shape: "icon", size: "sm", "aria-label": close, className: "o-alert-x-plain", icon: glyph(X), disabled: disabled, onClick: onClose })] }))] }));
|
|
17
|
+
}
|
|
18
|
+
const shellOf = (el) => (el?.closest("[data-alert-phone]")?.dataset.alertPhone === "sheet" ? "sheet" : "panel");
|
|
19
|
+
function useShell(frame) {
|
|
20
|
+
const [shell, setShell] = React.useState("panel");
|
|
21
|
+
React.useLayoutEffect(() => {
|
|
22
|
+
if (!frame)
|
|
23
|
+
return;
|
|
24
|
+
const read = () => setShell(shellOf(frame));
|
|
25
|
+
read();
|
|
26
|
+
const watch = new MutationObserver(read);
|
|
27
|
+
watch.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: ["data-alert-phone"] });
|
|
28
|
+
return () => watch.disconnect();
|
|
29
|
+
}, [frame]);
|
|
30
|
+
return shell;
|
|
31
|
+
}
|
|
32
|
+
export const ALERT_DIALOG_WORDS = { close: "Close", failed: "That didn't go through. Nothing changed.", ...ALERT_WORDS };
|
|
33
|
+
export function AlertDialogPanel({ open, onClose, phone, busy, container, standing, initialFocus, close = ALERT_DIALOG_WORDS.close, children }) {
|
|
34
|
+
const Root = (standing ? BaseDialog.Root : BaseAlert.Root);
|
|
35
|
+
return (_jsx(Root, { open: open, onOpenChange: (o) => { if (!o)
|
|
36
|
+
onClose(); }, ...(standing ? { modal: false, disablePointerDismissal: true } : {}), children: _jsxs(BaseAlert.Portal, { container: container, children: [_jsx(BaseAlert.Backdrop, { className: "o-alert-backdrop", "data-screen": phone ? "phone" : "computer" }), _jsx(BaseAlert.Viewport, { className: "o-alert-viewport", children: _jsx(BaseAlert.Popup, { initialFocus: standing ? false : initialFocus, className: "o-alert-dialog", "data-screen": phone ? "phone" : "computer", children: _jsx("div", { className: "o-alert-cut o-smooth", children: _jsx(Held, { phone: phone, shell: "panel", disabled: busy, onClose: onClose, close: close, children: children }) }) }) })] }) }));
|
|
37
|
+
}
|
|
38
|
+
export function AlertDialog({ open, onAnswer, state, failed, container, standing, run, words, ...ask }) {
|
|
39
|
+
const said = { ...ALERT_DIALOG_WORDS, ...words };
|
|
40
|
+
const ref = React.useRef(null), host = usePopupHost(ref), cancelRef = React.useRef(null);
|
|
41
|
+
const small = usePhone(), screen = React.useContext(PhoneHost), phone = small || !!screen;
|
|
42
|
+
const shell = useShell(screen ?? host ?? null), inSheet = phone && shell === "sheet";
|
|
43
|
+
const [own, setOwn] = React.useState("rest"), [why, setWhy] = React.useState(null), now = state ?? own;
|
|
44
|
+
const [wasOpen, setWasOpen] = React.useState(open);
|
|
45
|
+
if (open !== wasOpen) {
|
|
46
|
+
setWasOpen(open);
|
|
47
|
+
if (open) {
|
|
48
|
+
setOwn("rest");
|
|
49
|
+
setWhy(null);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const answer = (yes) => {
|
|
53
|
+
if (now === "working")
|
|
54
|
+
return;
|
|
55
|
+
if (!yes || !run)
|
|
56
|
+
return onAnswer(yes);
|
|
57
|
+
setOwn("working");
|
|
58
|
+
Promise.resolve().then(run).then(() => { setOwn("rest"); onAnswer(true); }, (e) => { setWhy(e instanceof Error && e.message ? e.message : said.failed); setOwn("failed"); });
|
|
59
|
+
};
|
|
60
|
+
const body = { ...ask, onAnswer: answer, state: now, failed: failed ?? why, phone, words: { tryAgain: said.tryAgain } }, working = now === "working";
|
|
61
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: ref, hidden: true }), inSheet ? (_jsx(Sheet, { open: open, onOpenChange: (o) => { if (!o)
|
|
62
|
+
answer(false); }, label: ask.title, form: "floating", container: container ?? screen ?? host, standing: standing, children: _jsx(SheetBody, { children: _jsx(Held, { phone: true, shell: "sheet", disabled: working, onClose: () => answer(false), close: said.close, children: _jsx(Alert, { ...body, shell: "sheet" }) }) }) })) : (_jsx(AlertDialogPanel, { open: open, onClose: () => answer(false), phone: phone, busy: working, container: container ?? screen ?? host, standing: standing, initialFocus: cancelRef, close: said.close, children: _jsx(Alert, { ...body, cancelRef: cancelRef, Title: BaseAlert.Title, Line: BaseAlert.Description }) }))] }));
|
|
63
|
+
}
|
|
64
|
+
export function AlertDialogHost({ container, words }) {
|
|
65
|
+
const { open, ask } = React.useSyncExternalStore(subscribe, asked, asked);
|
|
66
|
+
return ask ? _jsx(AlertDialog, { ...ask, open: open, onAnswer: answered, container: container, words: words }) : null;
|
|
67
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AlertAsk } from "../alert/alert.js";
|
|
2
|
+
/** What stands asked: open or closing, and its question. */
|
|
3
|
+
export type Asking = {
|
|
4
|
+
open: boolean;
|
|
5
|
+
ask: AlertAsk | null;
|
|
6
|
+
};
|
|
7
|
+
/** Asks from anywhere, through the one AlertDialogHost: true for its action, false for every way out. */
|
|
8
|
+
export declare function confirm(ask: AlertAsk): Promise<boolean>;
|
|
9
|
+
/** Its answer, from the host: the asker hears it, and the question closes. */
|
|
10
|
+
export declare const answered: (yes: boolean) => void;
|
|
11
|
+
/** For the host's useSyncExternalStore. */
|
|
12
|
+
export declare const subscribe: (l: () => void) => () => void;
|
|
13
|
+
export declare const asked: () => Asking;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let asking = { open: false, ask: null }, settle = null;
|
|
2
|
+
const listeners = new Set();
|
|
3
|
+
const tell = (next) => { asking = next; listeners.forEach((l) => l()); };
|
|
4
|
+
export function confirm(ask) {
|
|
5
|
+
const replaced = settle;
|
|
6
|
+
settle = null;
|
|
7
|
+
return new Promise((resolve) => { settle = resolve; tell({ open: true, ask }); replaced?.(false); });
|
|
8
|
+
}
|
|
9
|
+
export const answered = (yes) => { const done = settle; settle = null; tell({ open: false, ask: asking.ask }); done?.(yes); };
|
|
10
|
+
export const subscribe = (l) => { listeners.add(l); return () => { listeners.delete(l); }; };
|
|
11
|
+
export const asked = () => asking;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PieceLooks } from "../../looks/looks.js";
|
|
2
|
+
export type AlertDialogOptionId = "close" | "padding" | "behind" | "strength" | "blur" | "blurphone" | "shadow" | "shadowphone" | "margin" | "corners" | "smoothing";
|
|
3
|
+
/** The alert dialog's options. */
|
|
4
|
+
export declare const ALERT_DIALOG_LOOKS: PieceLooks<AlertDialogOptionId>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const steps = (ids) => ids.map((id) => ({ id, name: id }));
|
|
2
|
+
const BLURS = [{ id: "0", name: "None" }, ...steps(["4", "8", "12", "24"])];
|
|
3
|
+
const SHADOWS = [{ id: "none", name: "None" }, { id: "lg", name: "Large" }, { id: "xl", name: "Extra large" }, { id: "2xl", name: "Largest" }];
|
|
4
|
+
const options = [
|
|
5
|
+
{ id: "close", name: "The X", device: "phone", def: "hidden", values: [{ id: "hidden", name: "Hidden" }, { id: "shown", name: "Shown" }] },
|
|
6
|
+
{ id: "padding", name: "Padding", def: "24", kind: "steps", values: steps(["16", "20", "24", "28"]) },
|
|
7
|
+
{ id: "behind", name: "What's behind", def: "dim", values: [{ id: "dim", name: "Dim" }, { id: "veil", name: "Veil" }] },
|
|
8
|
+
{ id: "strength", name: "Strength", def: "medium", kind: "steps", values: [{ id: "light", name: "Light" }, { id: "medium", name: "Medium" }, { id: "deep", name: "Deep" }] },
|
|
9
|
+
{ id: "blur", name: "Blur", device: "desktop", def: "0", kind: "steps", values: BLURS },
|
|
10
|
+
{ id: "blurphone", name: "Blur", device: "phone", def: "0", kind: "steps", values: BLURS },
|
|
11
|
+
{ id: "shadow", name: "Shadow", device: "desktop", def: "2xl", kind: "steps", values: SHADOWS },
|
|
12
|
+
{ id: "shadowphone", name: "Shadow", device: "phone", def: "xl", kind: "steps", values: SHADOWS },
|
|
13
|
+
{ id: "margin", name: "Margins", device: "phone", def: "16", kind: "steps", values: steps(["8", "12", "16", "24", "32"]) },
|
|
14
|
+
{ id: "corners", name: "Corners", def: "2xl", kind: "steps", values: steps(["lg", "xl", "2xl", "3xl"]) },
|
|
15
|
+
{ id: "smoothing", name: "Corner smoothing", def: "smooth", values: [{ id: "round", name: "Round" }, { id: "smooth", name: "Smooth" }] },
|
|
16
|
+
];
|
|
17
|
+
export const ALERT_DIALOG_LOOKS = { id: "alert-dialog", name: "Alert Dialog", options, looks: [] };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export declare const ALERT_DIALOG_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-layer-popup";
|
|
3
|
+
readonly kind: "size";
|
|
4
|
+
readonly outright: "--layer-popup";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-backdrop-alert-medium";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--backdrop-alert-medium";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-duration-base";
|
|
11
|
+
readonly kind: "motion";
|
|
12
|
+
readonly outright: "--duration-base";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-ease-out";
|
|
15
|
+
readonly kind: "motion";
|
|
16
|
+
readonly outright: "--ease-out";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-backdrop-alert-light";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--backdrop-alert-light";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-backdrop-alert-deep";
|
|
23
|
+
readonly kind: "colour";
|
|
24
|
+
readonly outright: "--backdrop-alert-deep";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-backdrop-veil-medium";
|
|
27
|
+
readonly kind: "colour";
|
|
28
|
+
readonly outright: "--backdrop-veil-medium";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-backdrop-veil-light";
|
|
31
|
+
readonly kind: "colour";
|
|
32
|
+
readonly outright: "--backdrop-veil-light";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-backdrop-veil";
|
|
35
|
+
readonly kind: "colour";
|
|
36
|
+
readonly outright: "--backdrop-veil";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-blur-xs";
|
|
39
|
+
readonly kind: "size";
|
|
40
|
+
readonly outright: "--blur-xs";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-blur-sm";
|
|
43
|
+
readonly kind: "size";
|
|
44
|
+
readonly outright: "--blur-sm";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-blur-md";
|
|
47
|
+
readonly kind: "size";
|
|
48
|
+
readonly outright: "--blur-md";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-blur-lg";
|
|
51
|
+
readonly kind: "size";
|
|
52
|
+
readonly outright: "--blur-lg";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-spacing";
|
|
55
|
+
readonly kind: "size";
|
|
56
|
+
readonly outright: "--spacing";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-radius-2xl";
|
|
59
|
+
readonly kind: "size";
|
|
60
|
+
readonly outright: "--radius-2xl";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-container-sm";
|
|
63
|
+
readonly kind: "size";
|
|
64
|
+
readonly outright: "--container-sm";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-border-width";
|
|
67
|
+
readonly kind: "size";
|
|
68
|
+
readonly outright: "--border-width";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-border-subtle";
|
|
71
|
+
readonly kind: "colour";
|
|
72
|
+
readonly outright: "--border-subtle";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-overlay";
|
|
75
|
+
readonly kind: "colour";
|
|
76
|
+
readonly outright: "--surface-overlay";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-shadow-2xl";
|
|
79
|
+
readonly kind: "shadow";
|
|
80
|
+
readonly outright: "--shadow-2xl";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "--vk-fg";
|
|
83
|
+
readonly kind: "colour";
|
|
84
|
+
readonly outright: "--text";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-shadow-lg";
|
|
87
|
+
readonly kind: "shadow";
|
|
88
|
+
readonly outright: "--shadow-lg";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "--vk-shadow-xl";
|
|
91
|
+
readonly kind: "shadow";
|
|
92
|
+
readonly outright: "--shadow-xl";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "--vk-push-scale";
|
|
95
|
+
readonly kind: "motion";
|
|
96
|
+
readonly outright: "--push-scale";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "--vk-duration-fast";
|
|
99
|
+
readonly kind: "motion";
|
|
100
|
+
readonly outright: "--duration-fast";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "--vk-ease-in";
|
|
103
|
+
readonly kind: "motion";
|
|
104
|
+
readonly outright: "--ease-in";
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "--vk-radius-lg";
|
|
107
|
+
readonly kind: "size";
|
|
108
|
+
readonly outright: "--radius-lg";
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "--vk-radius-xl";
|
|
111
|
+
readonly kind: "size";
|
|
112
|
+
readonly outright: "--radius-xl";
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "--vk-radius-3xl";
|
|
115
|
+
readonly kind: "size";
|
|
116
|
+
readonly outright: "--radius-3xl";
|
|
117
|
+
}];
|
|
118
|
+
/** Its own machinery is the Alert's family (`--alert-`): its panel's corners, padding and margins, and the edge's corner. */
|
|
119
|
+
export declare const ALERT_DIALOG_PRIVATE: readonly [];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const ALERT_DIALOG_TOKENS = [
|
|
2
|
+
{ name: "--vk-layer-popup", kind: "size", outright: "--layer-popup" },
|
|
3
|
+
{ name: "--vk-backdrop-alert-medium", kind: "colour", outright: "--backdrop-alert-medium" },
|
|
4
|
+
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
5
|
+
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
6
|
+
{ name: "--vk-backdrop-alert-light", kind: "colour", outright: "--backdrop-alert-light" },
|
|
7
|
+
{ name: "--vk-backdrop-alert-deep", kind: "colour", outright: "--backdrop-alert-deep" },
|
|
8
|
+
{ name: "--vk-backdrop-veil-medium", kind: "colour", outright: "--backdrop-veil-medium" },
|
|
9
|
+
{ name: "--vk-backdrop-veil-light", kind: "colour", outright: "--backdrop-veil-light" },
|
|
10
|
+
{ name: "--vk-backdrop-veil", kind: "colour", outright: "--backdrop-veil" },
|
|
11
|
+
{ name: "--vk-blur-xs", kind: "size", outright: "--blur-xs" },
|
|
12
|
+
{ name: "--vk-blur-sm", kind: "size", outright: "--blur-sm" },
|
|
13
|
+
{ name: "--vk-blur-md", kind: "size", outright: "--blur-md" },
|
|
14
|
+
{ name: "--vk-blur-lg", kind: "size", outright: "--blur-lg" },
|
|
15
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
16
|
+
{ name: "--vk-radius-2xl", kind: "size", outright: "--radius-2xl" },
|
|
17
|
+
{ name: "--vk-container-sm", kind: "size", outright: "--container-sm" },
|
|
18
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
19
|
+
{ name: "--vk-border-subtle", kind: "colour", outright: "--border-subtle" },
|
|
20
|
+
{ name: "--vk-overlay", kind: "colour", outright: "--surface-overlay" },
|
|
21
|
+
{ name: "--vk-shadow-2xl", kind: "shadow", outright: "--shadow-2xl" },
|
|
22
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
23
|
+
{ name: "--vk-shadow-lg", kind: "shadow", outright: "--shadow-lg" },
|
|
24
|
+
{ name: "--vk-shadow-xl", kind: "shadow", outright: "--shadow-xl" },
|
|
25
|
+
{ name: "--vk-push-scale", kind: "motion", outright: "--push-scale" },
|
|
26
|
+
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
27
|
+
{ name: "--vk-ease-in", kind: "motion", outright: "--ease-in" },
|
|
28
|
+
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
29
|
+
{ name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
|
|
30
|
+
{ name: "--vk-radius-3xl", kind: "size", outright: "--radius-3xl" },
|
|
31
|
+
];
|
|
32
|
+
export const ALERT_DIALOG_PRIVATE = [];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* The alert dialog: the panel an Alert stands in, over the page. Every value it draws with is a public name
|
|
2
|
+
(controls/alert-dialog/tokens.ts); this file only says which name each part takes. Its options (looks.ts) are data attributes on
|
|
3
|
+
the frame around it, and each one only chooses other names:
|
|
4
|
+
|
|
5
|
+
data-alert-dialog-close hidden · shown the X in its corner, on the phone
|
|
6
|
+
data-alert-dialog-padding 16 · 20 · 24 · 28 how far the Alert's words stand from its panel's edge
|
|
7
|
+
data-alert-dialog-behind dim · veil what stands over the page behind it: dark or light
|
|
8
|
+
data-alert-dialog-strength light · medium · deep how strong that is
|
|
9
|
+
data-alert-dialog-blur 0 · 4 · 8 · 12 · 24 how far the page blurs under it, on a computer
|
|
10
|
+
data-alert-dialog-blurphone 0 · 4 · 8 · 12 · 24 and on the phone
|
|
11
|
+
data-alert-dialog-shadow none · lg · xl · 2xl its panel's shadow on a computer
|
|
12
|
+
data-alert-dialog-shadowphone none · lg · xl · 2xl and on the phone
|
|
13
|
+
data-alert-dialog-margin 8 · 12 · 16 · 24 · 32 how far its panel stands from the phone's edges
|
|
14
|
+
data-alert-dialog-corners lg · xl · 2xl · 3xl which radius its panel takes
|
|
15
|
+
data-alert-dialog-smoothing round · smooth how its panel's corners bend
|
|
16
|
+
|
|
17
|
+
What it stands in on the phone, its panel or a Sheet, is the Alert's Opens as (data-alert-phone), which alert-dialog.tsx reads.
|
|
18
|
+
data-screen on its panel and on .o-alert-held, which holds the Alert and the X, says where it stands, phone or computer.
|
|
19
|
+
|
|
20
|
+
The rules sit in the components layer, so a utility class still wins. */
|
|
21
|
+
@layer components {
|
|
22
|
+
|
|
23
|
+
/* ── What's behind it, and where it stands: in the middle of the screen, over everything ─────────────────────────────────────────── */
|
|
24
|
+
.o-alert-backdrop, .o-alert-viewport { position: fixed; inset: 0; z-index: var(--vk-layer-popup); }
|
|
25
|
+
.o-alert-backdrop { background-color: var(--vk-backdrop-alert-medium); transition: opacity var(--vk-duration-base) var(--vk-ease-out); }
|
|
26
|
+
.o-alert-backdrop:is([data-starting-style], [data-ending-style]) { opacity: 0; }
|
|
27
|
+
[data-alert-dialog-strength="light"] .o-alert-backdrop { background-color: var(--vk-backdrop-alert-light); }
|
|
28
|
+
[data-alert-dialog-strength="deep"] .o-alert-backdrop { background-color: var(--vk-backdrop-alert-deep); }
|
|
29
|
+
[data-alert-dialog-behind="veil"] .o-alert-backdrop { background-color: var(--vk-backdrop-veil-medium); }
|
|
30
|
+
[data-alert-dialog-behind="veil"][data-alert-dialog-strength="light"] .o-alert-backdrop { background-color: var(--vk-backdrop-veil-light); }
|
|
31
|
+
[data-alert-dialog-behind="veil"][data-alert-dialog-strength="deep"] .o-alert-backdrop { background-color: var(--vk-backdrop-veil); }
|
|
32
|
+
/* How far the page blurs under it, each screen's own. No blur at all at none, since blur(0) still builds a backdrop root. */
|
|
33
|
+
[data-alert-dialog-blur="4"] .o-alert-backdrop[data-screen="computer"], [data-alert-dialog-blurphone="4"] .o-alert-backdrop[data-screen="phone"] { -webkit-backdrop-filter: blur(var(--vk-blur-xs)); backdrop-filter: blur(var(--vk-blur-xs)); }
|
|
34
|
+
[data-alert-dialog-blur="8"] .o-alert-backdrop[data-screen="computer"], [data-alert-dialog-blurphone="8"] .o-alert-backdrop[data-screen="phone"] { -webkit-backdrop-filter: blur(var(--vk-blur-sm)); backdrop-filter: blur(var(--vk-blur-sm)); }
|
|
35
|
+
[data-alert-dialog-blur="12"] .o-alert-backdrop[data-screen="computer"], [data-alert-dialog-blurphone="12"] .o-alert-backdrop[data-screen="phone"] { -webkit-backdrop-filter: blur(var(--vk-blur-md)); backdrop-filter: blur(var(--vk-blur-md)); }
|
|
36
|
+
[data-alert-dialog-blur="24"] .o-alert-backdrop[data-screen="computer"], [data-alert-dialog-blurphone="24"] .o-alert-backdrop[data-screen="phone"] { -webkit-backdrop-filter: blur(var(--vk-blur-lg)); backdrop-filter: blur(var(--vk-blur-lg)); }
|
|
37
|
+
.o-alert-viewport { --alert-margin: calc(var(--vk-spacing) * 4); box-sizing: border-box; display: grid; place-items: center; padding: var(--alert-margin); overflow-y: auto; outline: none; }
|
|
38
|
+
[data-alert-dialog-margin="8"] .o-alert-viewport { --alert-margin: calc(var(--vk-spacing) * 2); }
|
|
39
|
+
[data-alert-dialog-margin="12"] .o-alert-viewport { --alert-margin: calc(var(--vk-spacing) * 3); }
|
|
40
|
+
[data-alert-dialog-margin="24"] .o-alert-viewport { --alert-margin: calc(var(--vk-spacing) * 6); }
|
|
41
|
+
[data-alert-dialog-margin="32"] .o-alert-viewport { --alert-margin: calc(var(--vk-spacing) * 8); }
|
|
42
|
+
|
|
43
|
+
/* ── Its panel: on the overlay's ground, one width on a computer, the phone's width less its margins ─────────────────────────────── */
|
|
44
|
+
.o-alert-dialog {
|
|
45
|
+
--alert-corners: var(--vk-radius-2xl); --alert-padding: calc(var(--vk-spacing) * 6);
|
|
46
|
+
box-sizing: border-box; width: 100%; max-width: var(--vk-container-sm); min-width: 0; border: var(--vk-border-width) solid var(--vk-border-subtle); border-radius: var(--alert-corners);
|
|
47
|
+
background-color: var(--vk-overlay); box-shadow: var(--vk-shadow-2xl); color: var(--vk-fg); outline: none;
|
|
48
|
+
transition: opacity var(--vk-duration-base) var(--vk-ease-out), scale var(--vk-duration-base) var(--vk-ease-out);
|
|
49
|
+
}
|
|
50
|
+
.o-alert-dialog[data-screen="phone"] { max-width: none; }
|
|
51
|
+
/* Its shadow, each screen's own. */
|
|
52
|
+
[data-alert-dialog-shadow="none"] .o-alert-dialog[data-screen="computer"], [data-alert-dialog-shadowphone="none"] .o-alert-dialog[data-screen="phone"] { box-shadow: none; }
|
|
53
|
+
[data-alert-dialog-shadow="lg"] .o-alert-dialog[data-screen="computer"], [data-alert-dialog-shadowphone="lg"] .o-alert-dialog[data-screen="phone"] { box-shadow: var(--vk-shadow-lg); }
|
|
54
|
+
[data-alert-dialog-shadow="xl"] .o-alert-dialog[data-screen="computer"], [data-alert-dialog-shadowphone="xl"] .o-alert-dialog[data-screen="phone"] { box-shadow: var(--vk-shadow-xl); }
|
|
55
|
+
.o-alert-dialog:is([data-starting-style], [data-ending-style]) { opacity: 0; scale: var(--vk-push-scale); }
|
|
56
|
+
.o-alert-dialog[data-ending-style] { transition-duration: var(--vk-duration-fast); transition-timing-function: var(--vk-ease-in); }
|
|
57
|
+
[data-alert-dialog-corners="lg"] .o-alert-dialog { --alert-corners: var(--vk-radius-lg); }
|
|
58
|
+
[data-alert-dialog-corners="xl"] .o-alert-dialog { --alert-corners: var(--vk-radius-xl); }
|
|
59
|
+
[data-alert-dialog-corners="3xl"] .o-alert-dialog { --alert-corners: var(--vk-radius-3xl); }
|
|
60
|
+
.o-alert-cut { border-radius: inherit; background-color: inherit; }
|
|
61
|
+
|
|
62
|
+
/* ── How far the Alert's words stand from its panel's edge, which the Alert reads (alert.css) ─────────────────────────────────────── */
|
|
63
|
+
[data-alert-dialog-padding="16"] .o-alert-dialog { --alert-padding: calc(var(--vk-spacing) * 4); }
|
|
64
|
+
[data-alert-dialog-padding="20"] .o-alert-dialog { --alert-padding: calc(var(--vk-spacing) * 5); }
|
|
65
|
+
[data-alert-dialog-padding="28"] .o-alert-dialog { --alert-padding: calc(var(--vk-spacing) * 7); }
|
|
66
|
+
|
|
67
|
+
/* ── The X, in its corner, on the phone only, beside the Alert in its panel or its Sheet: Glass when the phone header is Glass, or a
|
|
68
|
+
quiet Button ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
69
|
+
.o-alert-held { position: relative; min-width: 0; }
|
|
70
|
+
.o-alert-x { display: none; }
|
|
71
|
+
[data-alert-dialog-close="shown"] .o-alert-x { position: absolute; top: calc(var(--vk-spacing) * 3); right: calc(var(--vk-spacing) * 3); display: grid; }
|
|
72
|
+
[data-alert-dialog-close="shown"] .o-alert-held[data-shell="sheet"] .o-alert-x { top: 0; right: 0; }
|
|
73
|
+
[data-alert-dialog-close="shown"] .o-alert-held[data-screen="phone"] .o-alert-title { padding-right: calc(var(--vk-spacing) * 11); }
|
|
74
|
+
.o-alert-x .o-alert-x-glass { display: none; }
|
|
75
|
+
/* Glass unless the phone's surface is Flat, as ViewKit's phone header and Sheet are where nothing is picked. */
|
|
76
|
+
.o-alert-held[data-screen="phone"]:not([data-phone-header-surface="flat"] *) .o-alert-x .o-alert-x-glass { display: grid; }
|
|
77
|
+
.o-alert-held[data-screen="phone"]:not([data-phone-header-surface="flat"] *) .o-alert-x .o-alert-x-plain { display: none; }
|
|
78
|
+
|
|
79
|
+
/* ── Its corners smooth, the default (what nothing set draws), unless a frame picks Round: the smooth outline (smooth.css), Apple's curve as measured, so every browser that knows shape() shows it; one that doesn't
|
|
80
|
+
keeps the corners above. The panel keeps its shadow, which a cut would take with it, so .o-alert-cut inside it is cut instead ───── */
|
|
81
|
+
@supports (clip-path: shape(from 0 0, curve by 1px 1px with 1px 0 / 1px 0, close)) {
|
|
82
|
+
.o-alert-dialog:not([data-alert-dialog-smoothing="round"] *) { border-color: transparent; background-color: transparent; background-clip: padding-box; }
|
|
83
|
+
.o-alert-cut:not([data-alert-dialog-smoothing="round"] *) {
|
|
84
|
+
--alert-c: var(--alert-corners);
|
|
85
|
+
background-color: var(--vk-overlay);
|
|
86
|
+
--smooth-t: var(--alert-c); clip-path: shape(var(--smooth-outline));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Less motion: a fade, no scale. */
|
|
91
|
+
@media (prefers-reduced-motion: reduce) {
|
|
92
|
+
.o-alert-dialog { transition: opacity var(--vk-duration-base) var(--vk-ease-out); }
|
|
93
|
+
.o-alert-dialog:is([data-starting-style], [data-ending-style]) { scale: 1; }
|
|
94
|
+
}
|
|
95
|
+
}
|