viewkitjs 0.26.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 +95 -0
- package/MIGRATION.md +122 -7
- 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 +240 -3
- package/views/dist/contract.js +238 -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/map-parts-body.js +2 -1
- package/views/dist/controls/compound-editor/name-parts.js +10 -2
- package/views/dist/controls/compound-editor/place-parts.js +5 -1
- package/views/dist/controls/compound-editor/place.d.ts +2 -1
- package/views/dist/controls/compound-editor/place.js +2 -0
- package/views/dist/controls/controls.d.ts +17 -0
- package/views/dist/controls/controls.js +17 -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 +35 -1
- package/views/dist/controls/index.js +35 -1
- package/views/dist/controls/internal/editor-parts.d.ts +47 -0
- package/views/dist/controls/internal/editor-parts.js +48 -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 +80 -0
- package/views/dist/controls/links-editor/links-editor.js +329 -0
- package/views/dist/controls/links-editor/links.d.ts +62 -0
- package/views/dist/controls/links-editor/links.js +50 -0
- package/views/dist/controls/links-editor/map-links-body.d.ts +10 -0
- package/views/dist/controls/links-editor/map-links-body.js +74 -0
- package/views/dist/controls/links-editor/tokens.d.ts +71 -0
- package/views/dist/controls/links-editor/tokens.js +20 -0
- package/views/dist/controls/links-editor/words.d.ts +56 -0
- package/views/dist/controls/links-editor/words.js +33 -0
- package/views/dist/controls/links-editor.css +132 -0
- 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/format.d.ts +31 -0
- package/views/dist/controls/number-editor/format.js +79 -0
- package/views/dist/controls/number-editor/looks.d.ts +14 -0
- package/views/dist/controls/number-editor/looks.js +17 -0
- package/views/dist/controls/number-editor/map-number-body.d.ts +16 -0
- package/views/dist/controls/number-editor/map-number-body.js +57 -0
- package/views/dist/controls/number-editor/number-editor.d.ts +72 -0
- package/views/dist/controls/number-editor/number-editor.js +202 -0
- package/views/dist/controls/number-editor/tokens.d.ts +28 -0
- package/views/dist/controls/number-editor/tokens.js +9 -0
- package/views/dist/controls/number-editor/words.d.ts +23 -0
- package/views/dist/controls/number-editor/words.js +13 -0
- package/views/dist/controls/number-editor.css +37 -0
- package/views/dist/controls/number-field/number-field.js +57 -5
- 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/radio/radio.d.ts +33 -0
- package/views/dist/controls/radio/radio.js +19 -0
- package/views/dist/controls/radio/tokens.d.ts +127 -0
- package/views/dist/controls/radio/tokens.js +34 -0
- package/views/dist/controls/radio.css +104 -0
- 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/text-editor/phone-number.d.ts +4 -0
- package/views/dist/controls/text-editor/phone-number.js +20 -0
- package/views/dist/controls/text-editor/text-editor.js +2 -19
- 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 +30 -0
- package/views/dist/controls/values-editor/looks.d.ts +16 -0
- package/views/dist/controls/values-editor/looks.js +19 -0
- package/views/dist/controls/values-editor/map-values-body.d.ts +12 -0
- package/views/dist/controls/values-editor/map-values-body.js +71 -0
- package/views/dist/controls/values-editor/tokens.d.ts +132 -0
- package/views/dist/controls/values-editor/tokens.js +35 -0
- package/views/dist/controls/values-editor/values-editor.d.ts +62 -0
- package/views/dist/controls/values-editor/values-editor.js +441 -0
- package/views/dist/controls/values-editor/values.d.ts +71 -0
- package/views/dist/controls/values-editor/values.js +59 -0
- package/views/dist/controls/values-editor/words.d.ts +50 -0
- package/views/dist/controls/values-editor/words.js +29 -0
- package/views/dist/controls/values-editor.css +207 -0
- package/views/dist/controls/views-list/looks.d.ts +13 -0
- package/views/dist/controls/views-list/looks.js +12 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +19 -0
- package/views/dist/controls/views-list/map-views-list-body.js +65 -0
- package/views/dist/controls/views-list/rules.d.ts +72 -0
- package/views/dist/controls/views-list/rules.js +4 -0
- package/views/dist/controls/views-list/tokens.d.ts +11 -0
- package/views/dist/controls/views-list/tokens.js +5 -0
- package/views/dist/controls/views-list/views-list.d.ts +44 -0
- package/views/dist/controls/views-list/views-list.js +57 -0
- package/views/dist/controls/views-list/words.d.ts +22 -0
- package/views/dist/controls/views-list/words.js +3 -0
- package/views/dist/controls/views-list.css +8 -0
- 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/NumberEditor.js +3 -1
- 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 +3 -3
- 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/GridDateEditor.d.ts +3 -1
- package/views/dist/grid/chrome/GridDateEditor.js +2 -1
- 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 +8 -0
- package/views/dist/looks/index.js +8 -0
- package/views/dist/looks/pieces.js +16 -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 +34 -4
- package/views/dist/provider/moment.d.ts +6 -0
- package/views/dist/provider/moment.js +10 -0
- package/views/dist/styles.css +1276 -51
- package/views/dist/styles.unlayered.css +1277 -51
- package/views/docs/contract.md +23 -15
- 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/links-editor.md +25 -0
- package/views/docs/controls/modal.md +55 -0
- package/views/docs/controls/notice.md +32 -0
- package/views/docs/controls/number-editor.md +12 -0
- package/views/docs/controls/pane.md +25 -0
- package/views/docs/controls/radio.md +39 -0
- package/views/docs/controls/sort-editor.md +27 -0
- package/views/docs/controls/toast.md +32 -0
- package/views/docs/controls/values-editor.md +40 -0
- package/views/docs/controls/views-list.md +8 -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 +326 -8
- package/views/docs/reference/display.md +2 -2
- package/views/docs/reference/editors-relation.md +1 -1
- package/views/docs/reference/looks.md +20 -3
- package/views/docs/reference/panels-react.md +7 -6
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +8 -8
- package/views/docs/reference/views.md +1 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* The Alert. Every value it draws with is a public name (controls/alert/tokens.ts); this file only says which name each part takes. Its options
|
|
2
|
+
(looks.ts) are data attributes on the frame around it, and each one only chooses other names:
|
|
3
|
+
|
|
4
|
+
data-alert-buttons end · full its buttons on a computer: at the end, or filling its foot
|
|
5
|
+
data-alert-pair side · stacked its buttons on the phone, which always fill its foot
|
|
6
|
+
data-alert-mark none · shown a round mark over its words, which centres them
|
|
7
|
+
data-alert-size 32 · 36 · 44 its buttons' height on a computer
|
|
8
|
+
data-alert-phone panel · sheet what it stands in on the phone, which the Alert Dialog reads
|
|
9
|
+
|
|
10
|
+
data-screen on it says where it stands, phone or computer, and data-shell what it stands in, the Alert Dialog's panel or a sheet.
|
|
11
|
+
How far its words stand from the panel's edge is the panel's (--alert-padding, alert-dialog.css), 24 where nothing sets it.
|
|
12
|
+
|
|
13
|
+
The rules sit in the components layer, so a utility class still wins. */
|
|
14
|
+
@layer components {
|
|
15
|
+
|
|
16
|
+
/* ── What it says ────────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
17
|
+
.o-alert-body { position: relative; display: grid; min-width: 0; color: var(--vk-fg); }
|
|
18
|
+
.o-alert-body[data-shell="panel"] { padding: var(--alert-padding, calc(var(--vk-spacing) * 6)); }
|
|
19
|
+
.o-alert-body[data-shell="sheet"] { padding: calc(var(--vk-spacing) * 2); }
|
|
20
|
+
.o-alert-title { margin: 0; font-size: var(--vk-font-size-lg); line-height: calc(var(--vk-font-size-base) * var(--vk-line-height-base)); font-weight: var(--vk-font-weight-semibold); text-wrap: balance; overflow-wrap: anywhere; }
|
|
21
|
+
.o-alert-line { margin: calc(var(--vk-spacing) * 1) 0 0; font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); color: var(--vk-fg-subtle); text-wrap: pretty; }
|
|
22
|
+
.o-alert-line.o-alert-wrong { color: var(--vk-danger); }
|
|
23
|
+
.o-alert-body[data-screen="phone"] .o-alert-line { font-size: var(--vk-font-size-base); line-height: calc(var(--vk-font-size-base) * var(--vk-line-height-base)); }
|
|
24
|
+
|
|
25
|
+
/* ── Its buttons: at the end on a computer unless they fill its foot, as they always do on the phone. A foot that fills stands 12 from a
|
|
26
|
+
panel's edge, so a 24 corner and a 12 button nest, and the way out stands on the overlay's card ────────────────────────────────── */
|
|
27
|
+
.o-alert-foot { display: flex; justify-content: flex-end; gap: calc(var(--vk-spacing) * 2); margin-top: calc(var(--vk-spacing) * 5); }
|
|
28
|
+
:is([data-alert-buttons="full"] .o-alert-body, .o-alert-body[data-screen="phone"]) .o-alert-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
29
|
+
:is([data-alert-buttons="full"] .o-alert-body, .o-alert-body[data-screen="phone"]) .o-alert-foot > .o-button { width: 100%; padding-inline: 0; }
|
|
30
|
+
:is([data-alert-buttons="full"] .o-alert-body, .o-alert-body[data-screen="phone"])[data-shell="panel"] { padding-bottom: calc(var(--vk-spacing) * 3); }
|
|
31
|
+
:is([data-alert-buttons="full"] .o-alert-body, .o-alert-body[data-screen="phone"])[data-shell="panel"] .o-alert-foot { margin-inline: calc(var(--vk-spacing) * 3 - var(--alert-padding, calc(var(--vk-spacing) * 6))); }
|
|
32
|
+
:is([data-alert-buttons="full"] .o-alert-body, .o-alert-body[data-screen="phone"]) .o-alert-cancel:not(:disabled) { border-color: transparent; background-color: var(--vk-overlay-card); }
|
|
33
|
+
/* 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. */
|
|
34
|
+
:is([data-alert-buttons="full"] .o-alert-body, .o-alert-body[data-screen="phone"]) .o-alert-cancel:active:not(:disabled) { border-color: transparent; background-color: var(--vk-overlay-card-pressed); }
|
|
35
|
+
@media (hover: hover) { :is([data-alert-buttons="full"] .o-alert-body, .o-alert-body[data-screen="phone"]) .o-alert-cancel:hover:not(:disabled) { border-color: transparent; background-color: var(--vk-overlay-card-pressed); } }
|
|
36
|
+
[data-alert-size="32"] .o-alert-body[data-screen="computer"] .o-alert-foot > .o-button { height: calc(var(--vk-spacing) * 8); --button-side: calc(var(--vk-spacing) * 8); padding-inline: calc(var(--vk-spacing) * 3); }
|
|
37
|
+
[data-alert-size="44"] .o-alert-body[data-screen="computer"] .o-alert-foot > .o-button { height: calc(var(--vk-spacing) * 11); --button-side: calc(var(--vk-spacing) * 11); padding-inline: calc(var(--vk-spacing) * 5); font-size: var(--vk-font-size-base); }
|
|
38
|
+
[data-alert-pair="stacked"] .o-alert-body[data-screen="phone"] .o-alert-foot { grid-template-columns: minmax(0, 1fr); }
|
|
39
|
+
[data-alert-pair="stacked"] .o-alert-body[data-screen="phone"] .o-alert-foot > .o-alert-cancel { order: 1; }
|
|
40
|
+
|
|
41
|
+
/* ── Its mark: round, in its action's colour, its words centred under it ─────────────────────────────────────────────────────────── */
|
|
42
|
+
.o-alert-mark { display: none; }
|
|
43
|
+
[data-alert-mark="shown"] .o-alert-mark { display: grid; place-items: center; justify-self: center; width: calc(var(--vk-spacing) * 12); height: calc(var(--vk-spacing) * 12); margin-bottom: calc(var(--vk-spacing) * 3); border-radius: var(--vk-radius-full); background-color: var(--vk-brand-subtler); color: var(--vk-fg-accent); }
|
|
44
|
+
[data-alert-mark="shown"] .o-alert-body[data-screen="phone"] .o-alert-mark { width: calc(var(--vk-spacing) * 14); height: calc(var(--vk-spacing) * 14); margin-bottom: calc(var(--vk-spacing) * 4); }
|
|
45
|
+
[data-alert-mark="shown"] .o-alert-body[data-kind="information"] .o-alert-mark { background-color: var(--vk-info-subtler); color: var(--vk-info); }
|
|
46
|
+
[data-alert-mark="shown"] .o-alert-body[data-kind="success"] .o-alert-mark { background-color: var(--vk-success-subtler); color: var(--vk-success); }
|
|
47
|
+
[data-alert-mark="shown"] .o-alert-body[data-kind="warning"] .o-alert-mark { background-color: var(--vk-warning-subtler); color: var(--vk-warning); }
|
|
48
|
+
[data-alert-mark="shown"] .o-alert-body[data-kind="danger"] .o-alert-mark { background-color: var(--vk-danger-subtler); color: var(--vk-danger); }
|
|
49
|
+
.o-alert-mark > svg { width: calc(var(--vk-spacing) * 6); height: calc(var(--vk-spacing) * 6); }
|
|
50
|
+
[data-alert-mark="shown"] :is(.o-alert-title, .o-alert-line) { text-align: center; }
|
|
51
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface CollapsibleProps {
|
|
3
|
+
/** Open, when it is set from outside (a grid's group, a filter's details); with onOpenChange. */
|
|
4
|
+
open?: boolean;
|
|
5
|
+
/** Open at first, when it keeps its own state. */
|
|
6
|
+
defaultOpen?: boolean;
|
|
7
|
+
/** Its trigger was pressed: whether it opens or closes. */
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
/** It can't be opened or closed: its trigger is off, and the part stays as it is. */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Its trigger and its part (CollapsibleTrigger, CollapsiblePanel), or the part alone when it is set open from outside. */
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/** One part that opens and closes in place, under its trigger or set open from outside. */
|
|
16
|
+
export declare function Collapsible({ open, defaultOpen, onOpenChange, disabled, className, children }: CollapsibleProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export interface CollapsibleTriggerProps {
|
|
18
|
+
/** What opens: its name, and what it holds when that helps ("Closed deals", "12"). */
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
/** Your own element in place of the plain row (a Button, a heading's button): it keeps its look and gains the behaviour. */
|
|
21
|
+
render?: React.ReactElement;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
/** What opens and closes it, plain: its name after a chevron, which turns down when the part is open; 32 high, 44 on a phone. A place
|
|
25
|
+
* that draws its own (a heading, a Button, a row) hands it as `render`. */
|
|
26
|
+
export declare function CollapsibleTrigger({ children, render, className }: CollapsibleTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export interface CollapsiblePanelProps {
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
/** A class on what it holds, inside the box that crops. */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** A class on the box that crops while it moves, so a bleed or a padding there isn't shaved (a row's outline). */
|
|
32
|
+
clipClassName?: string;
|
|
33
|
+
/** Its time in ms, opening and closing alike, where the motion names' isn't right (a grid's own). Reduced motion still wins. */
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
/** It stays on the page while closed, hidden until the browser's find reaches it, which opens it. */
|
|
36
|
+
hiddenUntilFound?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** The part that opens and closes: the box that crops it while its height moves, and what it holds inside. */
|
|
39
|
+
export declare function CollapsiblePanel({ children, className, clipClassName, durationMs, hiddenUntilFound }: CollapsiblePanelProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible";
|
|
3
|
+
import { cx } from "../../internal/cx.js";
|
|
4
|
+
import { phoneMark, usePhoneForm } from "../internal/phone.js";
|
|
5
|
+
export function Collapsible({ open, defaultOpen, onOpenChange, disabled, className, children }) {
|
|
6
|
+
const phone = usePhoneForm();
|
|
7
|
+
return (_jsx(BaseCollapsible.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: onOpenChange ? (next) => onOpenChange(next) : undefined, disabled: disabled, className: cx("o-collapsible", className), "data-kit": "collapsible", ...phoneMark(phone), children: children }));
|
|
8
|
+
}
|
|
9
|
+
const CHEVRON = "M9 6l6 6l-6 6";
|
|
10
|
+
export function CollapsibleTrigger({ children, render, className }) {
|
|
11
|
+
if (render)
|
|
12
|
+
return _jsx(BaseCollapsible.Trigger, { render: render, className: className, children: children });
|
|
13
|
+
return (_jsxs(BaseCollapsible.Trigger, { className: cx("o-collapsible-trigger", className), children: [_jsx("svg", { className: "o-collapsible-chevron", viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsx("path", { d: CHEVRON }) }), children] }));
|
|
14
|
+
}
|
|
15
|
+
export function CollapsiblePanel({ children, className, clipClassName, durationMs, hiddenUntilFound }) {
|
|
16
|
+
const style = durationMs === undefined ? undefined : { "--o-collapsible-time": `${durationMs}ms` };
|
|
17
|
+
return (_jsx(BaseCollapsible.Panel, { className: cx("o-collapsible-panel", clipClassName), style: style, hiddenUntilFound: hiddenUntilFound, children: _jsx("div", { className: cx("o-collapsible-body", className), children: children }) }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const options = [
|
|
2
|
+
{ id: "content", name: "Content", def: "fade", values: [{ id: "still", name: "Stands still" }, { id: "fade", name: "Fades" }, { id: "slide", name: "Slides out" }] },
|
|
3
|
+
{ id: "curve", name: "Curve", def: "soft", values: [{ id: "soft", name: "Soft" }, { id: "sharp", name: "Sharp" }] },
|
|
4
|
+
];
|
|
5
|
+
export const COLLAPSIBLE_LOOKS = { id: "collapsible", name: "Collapsible", options, looks: [] };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Collapsible, CollapsiblePanel } from "./collapsible.js";
|
|
4
|
+
export function MapCollapse({ open, children, className, clipClassName, durationMs }) {
|
|
5
|
+
return (_jsx(Collapsible, { open: open, className: className, children: _jsx(CollapsiblePanel, { clipClassName: clipClassName, durationMs: durationMs, children: children }) }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare const COLLAPSIBLE_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-ease-out-sharp";
|
|
3
|
+
readonly kind: "motion";
|
|
4
|
+
readonly outright: "--ease-out-sharp";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-spacing";
|
|
7
|
+
readonly kind: "size";
|
|
8
|
+
readonly outright: "--spacing";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-radius-sm";
|
|
11
|
+
readonly kind: "size";
|
|
12
|
+
readonly outright: "--radius-sm";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-fg";
|
|
15
|
+
readonly kind: "colour";
|
|
16
|
+
readonly outright: "--text";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-font-size-sm";
|
|
19
|
+
readonly kind: "size";
|
|
20
|
+
readonly outright: "--text-sm";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-line-height-sm";
|
|
23
|
+
readonly kind: "size";
|
|
24
|
+
readonly outright: "--text-sm--line-height";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-font-weight-medium";
|
|
27
|
+
readonly kind: "size";
|
|
28
|
+
readonly outright: "--font-weight-medium";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-focus-width";
|
|
31
|
+
readonly kind: "size";
|
|
32
|
+
readonly outright: "--focus-width";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-border-brand";
|
|
35
|
+
readonly kind: "colour";
|
|
36
|
+
readonly outright: "--border-focused";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-focus-offset";
|
|
39
|
+
readonly kind: "size";
|
|
40
|
+
readonly outright: "--focus-offset";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-fg-disabled";
|
|
43
|
+
readonly kind: "colour";
|
|
44
|
+
readonly outright: "--text-disabled";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-fg-subtle";
|
|
47
|
+
readonly kind: "colour";
|
|
48
|
+
readonly outright: "--text-subtle";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-duration-fast";
|
|
51
|
+
readonly kind: "motion";
|
|
52
|
+
readonly outright: "--duration-fast";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-ease-out";
|
|
55
|
+
readonly kind: "motion";
|
|
56
|
+
readonly outright: "--ease-out";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-duration-base";
|
|
59
|
+
readonly kind: "motion";
|
|
60
|
+
readonly outright: "--duration-base";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-duration-slow";
|
|
63
|
+
readonly kind: "motion";
|
|
64
|
+
readonly outright: "--duration-slow";
|
|
65
|
+
}];
|
|
66
|
+
/** The Collapsible's own machinery: its times and curve, its part's height (Base UI's `--collapsible-panel-height`), the
|
|
67
|
+
* time an app hands (`--o-collapsible-time`) and its trigger's height. */
|
|
68
|
+
export declare const COLLAPSIBLE_PRIVATE: readonly ["--o-collapsible-", "--collapsible-"];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const COLLAPSIBLE_TOKENS = [
|
|
2
|
+
{ name: "--vk-ease-out-sharp", kind: "motion", outright: "--ease-out-sharp" },
|
|
3
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
4
|
+
{ name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
|
|
5
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
6
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
7
|
+
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
8
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
9
|
+
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
10
|
+
{ name: "--vk-border-brand", kind: "colour", outright: "--border-focused" },
|
|
11
|
+
{ name: "--vk-focus-offset", kind: "size", outright: "--focus-offset" },
|
|
12
|
+
{ name: "--vk-fg-disabled", kind: "colour", outright: "--text-disabled" },
|
|
13
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
14
|
+
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
15
|
+
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
16
|
+
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
17
|
+
{ name: "--vk-duration-slow", kind: "motion", outright: "--duration-slow" },
|
|
18
|
+
];
|
|
19
|
+
export const COLLAPSIBLE_PRIVATE = ["--o-collapsible-", "--collapsible-"];
|