viewkitjs 0.31.0 → 0.32.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 +129 -0
- package/MIGRATION.md +40 -6
- package/README.md +1 -1
- package/fields/dist/query/index.d.ts +2 -0
- package/fields/dist/query/index.js +2 -0
- package/fields/dist/query/list-request.d.ts +148 -0
- package/fields/dist/query/list-request.js +125 -0
- package/fields/dist/query/saved-view.d.ts +15 -0
- package/fields/dist/query/saved-view.js +11 -0
- package/fields/dist/query/settings.d.ts +9 -0
- package/fields/dist/query/settings.js +9 -0
- package/fields/docs/reference/query.md +66 -0
- package/package.json +5 -1
- package/postgres/README.md +1 -0
- package/postgres/dist/handler.d.ts +53 -0
- package/postgres/dist/handler.js +211 -0
- package/postgres/dist/ids.d.ts +1 -1
- package/postgres/dist/ids.js +19 -1
- package/postgres/dist/index.d.ts +1 -0
- package/postgres/dist/index.js +1 -0
- package/postgres/dist/limits.d.ts +3 -1
- package/postgres/dist/limits.js +1 -1
- package/postgres/dist/list-fields.d.ts +10 -0
- package/postgres/dist/list-fields.js +36 -0
- package/postgres/dist/readable.d.ts +4 -0
- package/postgres/dist/readable.js +4 -0
- package/postgres/dist/refusals.d.ts +9 -2
- package/postgres/dist/refusals.js +6 -0
- package/postgres/docs/guides/field-map.md +2 -2
- package/postgres/docs/guides/list-handler.md +99 -0
- package/postgres/docs/index.md +1 -0
- package/postgres/docs/reference/postgres.md +11 -3
- package/views/README.md +2 -2
- package/views/dist/atoms/RowMenu.d.ts +7 -0
- package/views/dist/atoms/RowMenu.js +18 -16
- package/views/dist/atoms/carried.d.ts +5 -0
- package/views/dist/atoms/carried.js +7 -0
- package/views/dist/atoms/types.d.ts +3 -0
- package/views/dist/contract.d.ts +26 -6
- package/views/dist/contract.js +25 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
- package/views/dist/controls/atoms.d.ts +2 -0
- package/views/dist/controls/atoms.js +2 -0
- package/views/dist/controls/avatar/avatar.d.ts +3 -3
- package/views/dist/controls/avatar/avatar.js +1 -1
- package/views/dist/controls/avatar/tokens.d.ts +44 -0
- package/views/dist/controls/avatar/tokens.js +11 -0
- package/views/dist/controls/avatar.css +22 -5
- package/views/dist/controls/choice/tokens.d.ts +0 -4
- package/views/dist/controls/choice/tokens.js +0 -1
- package/views/dist/controls/choice.css +3 -3
- package/views/dist/controls/controls.d.ts +6 -0
- package/views/dist/controls/controls.js +10 -2
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +19 -4
- package/views/dist/controls/field/field.js +63 -5
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +41 -16
- package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
- package/views/dist/controls/glyphs/glyphs.js +173 -0
- package/views/dist/controls/index.d.ts +2 -1
- package/views/dist/controls/index.js +2 -1
- package/views/dist/controls/input/input.js +5 -2
- package/views/dist/controls/input/tokens.d.ts +4 -0
- package/views/dist/controls/input/tokens.js +1 -0
- package/views/dist/controls/input.css +31 -3
- package/views/dist/controls/internal/icons.js +10 -0
- package/views/dist/controls/internal/keep-focus.d.ts +2 -0
- package/views/dist/controls/internal/keep-focus.js +17 -0
- package/views/dist/controls/internal/watch-frame.d.ts +2 -0
- package/views/dist/controls/internal/watch-frame.js +33 -0
- package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
- package/views/dist/controls/markdown/map-markdown.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/menu-list/menu-list.d.ts +3 -0
- package/views/dist/controls/menu-list/menu-list.js +5 -4
- package/views/dist/controls/modal/modal.js +5 -1
- package/views/dist/controls/pane/pane.js +2 -1
- package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
- package/views/dist/controls/phone-header/header-bar.js +2 -2
- package/views/dist/controls/phone-header.css +11 -1
- package/views/dist/controls/picker/map-picker.js +3 -0
- package/views/dist/controls/picker/picker.d.ts +14 -0
- package/views/dist/controls/picker/picker.js +30 -10
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/radio/radio.d.ts +5 -3
- package/views/dist/controls/radio/radio.js +18 -2
- package/views/dist/controls/radio/tokens.d.ts +44 -0
- package/views/dist/controls/radio/tokens.js +11 -0
- package/views/dist/controls/radio.css +79 -1
- package/views/dist/controls/select/select.d.ts +4 -0
- package/views/dist/controls/select/select.js +11 -5
- package/views/dist/controls/select/tokens.d.ts +8 -0
- package/views/dist/controls/select/tokens.js +2 -0
- package/views/dist/controls/select.css +17 -0
- package/views/dist/controls/setting-row/looks.d.ts +1 -1
- package/views/dist/controls/setting-row/looks.js +9 -4
- package/views/dist/controls/setting-row/setting-row.d.ts +45 -10
- package/views/dist/controls/setting-row/setting-row.js +82 -15
- package/views/dist/controls/setting-row/tokens.d.ts +74 -2
- package/views/dist/controls/setting-row/tokens.js +19 -1
- package/views/dist/controls/setting-row.css +135 -14
- package/views/dist/controls/sheet/bottom-sheet.d.ts +10 -2
- package/views/dist/controls/sheet/bottom-sheet.js +6 -3
- package/views/dist/controls/sheet.css +4 -1
- package/views/dist/controls/sort-editor/sort-editor.js +3 -2
- package/views/dist/controls/sort-editor.css +8 -2
- package/views/dist/controls/switch-row/tokens.d.ts +0 -12
- package/views/dist/controls/switch-row/tokens.js +0 -3
- package/views/dist/controls/switch-row.css +3 -7
- package/views/dist/controls/switch.css +17 -7
- package/views/dist/controls/tag/tag.d.ts +3 -1
- package/views/dist/controls/tag/tag.js +2 -2
- package/views/dist/controls/tag/tokens.d.ts +4 -0
- package/views/dist/controls/tag/tokens.js +1 -0
- package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
- package/views/dist/controls/tag-field/tag-field.js +11 -5
- package/views/dist/controls/tag-field/tokens.d.ts +16 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +19 -0
- package/views/dist/controls/tag.css +2 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
- package/views/dist/controls/toolbar/toolbar.js +22 -15
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
- package/views/dist/controls/toolbar-button.css +4 -0
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
- package/views/dist/controls/views-list/map-view-menu.js +25 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
- package/views/dist/controls/views-list/map-views-list-body.js +39 -21
- package/views/dist/controls/views-list/rules.d.ts +2 -0
- package/views/dist/controls/views-list/view-menu.d.ts +7 -0
- package/views/dist/controls/views-list/view-menu.js +28 -24
- package/views/dist/controls/views-list/words.d.ts +2 -0
- package/views/dist/controls/views-list/words.js +1 -1
- package/views/dist/editors/EditorPanel.js +2 -1
- package/views/dist/editors/edit-session.js +2 -5
- package/views/dist/field-row/FieldRow.d.ts +4 -2
- package/views/dist/field-row/FieldRow.js +67 -20
- package/views/dist/field-row/FieldRowLane.d.ts +7 -2
- package/views/dist/field-row/FieldRowLane.js +4 -3
- package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
- package/views/dist/field-row/editors/RowEditor.js +31 -1
- package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
- package/views/dist/field-row/field-row-button.d.ts +5 -0
- package/views/dist/field-row/field-row-button.js +2 -0
- package/views/dist/fields/binding.d.ts +3 -2
- package/views/dist/fields/binding.js +38 -5
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
- package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
- package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +6 -5
- package/views/dist/grid/chrome/GridRowCells.js +6 -9
- package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
- package/views/dist/grid/chrome/GridStructure.js +4 -4
- package/views/dist/grid/chrome/GridTable.js +5 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
- package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
- package/views/dist/grid/chrome/grid-row-menu-items.js +92 -6
- package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
- package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
- package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
- package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
- package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +15 -9
- package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +11 -5
- package/views/dist/grid/core/commit-model.d.ts +20 -2
- package/views/dist/grid/core/editing-controller.d.ts +18 -0
- package/views/dist/grid/core/editing-controller.js +188 -42
- package/views/dist/grid/core/editing-model.d.ts +3 -0
- package/views/dist/grid/core/editing-model.js +3 -0
- package/views/dist/grid/core/save-path.d.ts +24 -0
- package/views/dist/grid/core/save-path.js +122 -0
- package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
- package/views/dist/grid/core/spreadsheet-operations.js +23 -0
- package/views/dist/grid/index.d.ts +3 -2
- package/views/dist/grid/index.js +1 -0
- package/views/dist/internal/field-rows.d.ts +26 -0
- package/views/dist/internal/field-rows.js +8 -0
- package/views/dist/internal/page-close.d.ts +7 -0
- package/views/dist/internal/page-close.js +43 -0
- package/views/dist/list/browser-views-store.d.ts +10 -0
- package/views/dist/list/browser-views-store.js +182 -0
- package/views/dist/list/index.d.ts +23 -0
- package/views/dist/list/index.js +8 -0
- package/views/dist/list/menu.d.ts +31 -0
- package/views/dist/list/menu.js +76 -0
- package/views/dist/list/parts.d.ts +6 -0
- package/views/dist/list/parts.js +59 -0
- package/views/dist/list/registry.d.ts +11 -0
- package/views/dist/list/registry.js +31 -0
- package/views/dist/list/root.d.ts +40 -0
- package/views/dist/list/root.js +128 -0
- package/views/dist/list/slot.d.ts +14 -0
- package/views/dist/list/slot.js +22 -0
- package/views/dist/list/source.d.ts +11 -0
- package/views/dist/list/source.js +31 -0
- package/views/dist/list/store.d.ts +87 -0
- package/views/dist/list/store.js +115 -0
- package/views/dist/list/toolbar.d.ts +6 -0
- package/views/dist/list/toolbar.js +359 -0
- package/views/dist/list/views-axis.d.ts +5 -0
- package/views/dist/list/views-axis.js +96 -0
- package/views/dist/list/views-store.d.ts +41 -0
- package/views/dist/list/views-store.js +1 -0
- package/views/dist/list/views.d.ts +67 -0
- package/views/dist/list/views.js +400 -0
- package/views/dist/model/preferences.js +1 -1
- package/views/dist/model/prefs-buckets.js +1 -1
- package/views/dist/panels/index.d.ts +3 -1
- package/views/dist/panels/index.js +1 -0
- package/views/dist/panels/react/customize-body.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +41 -4
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +9 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +34 -23
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +10 -2
- package/views/dist/panels/react/toolbar/context.js +3 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
- package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
- package/views/dist/panels/react/views-row/PillGroup.js +16 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
- package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
- package/views/dist/panels/react.d.ts +2 -2
- package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
- package/views/dist/panels/toolbar/edit-view.js +14 -0
- package/views/dist/panels/toolbar/model.d.ts +5 -0
- package/views/dist/panels/toolbar/model.js +7 -3
- package/views/dist/panels/view-state.d.ts +5 -3
- package/views/dist/panels/views-row/model.d.ts +19 -2
- package/views/dist/panels/views-row/model.js +14 -0
- package/views/dist/provider/ViewsProvider.d.ts +16 -7
- package/views/dist/provider/ViewsProvider.js +23 -5
- package/views/dist/provider/components.d.ts +43 -2
- package/views/dist/provider/context.d.ts +2 -1
- package/views/dist/provider/context.js +1 -1
- package/views/dist/provider/ports.d.ts +19 -12
- package/views/dist/provider/ports.js +69 -1
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +418 -59
- package/views/dist/styles.unlayered.css +418 -59
- package/views/docs/contract.md +42 -31
- package/views/docs/controls/avatar.md +11 -0
- package/views/docs/controls/choice.md +0 -1
- package/views/docs/controls/field.md +3 -0
- package/views/docs/controls/input.md +1 -0
- package/views/docs/controls/radio.md +16 -1
- package/views/docs/controls/select.md +2 -0
- package/views/docs/controls/setting-row.md +18 -0
- package/views/docs/controls/switch-row.md +0 -3
- package/views/docs/controls/tag-field.md +4 -0
- package/views/docs/controls/tag.md +1 -0
- package/views/docs/getting-started.md +2 -2
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/columns.md +1 -1
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/the-grid.md +34 -7
- package/views/docs/guides/the-provider.md +4 -2
- package/views/docs/index.md +1 -0
- package/views/docs/reference/controls.md +35 -25
- package/views/docs/reference/editors-session.md +1 -1
- package/views/docs/reference/field-row.md +9 -1
- package/views/docs/reference/grid.md +14 -8
- package/views/docs/reference/list.md +227 -0
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +17 -12
- package/views/docs/reference/panels.md +8 -5
- package/views/docs/reference/react.md +11 -9
- package/views/docs/reference/views.md +2 -2
- package/views/skills/views/SKILL.md +9 -6
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import { cx } from "../../internal/cx.js";
|
|
4
|
+
import { FieldRowsCardContext } from "../../internal/field-rows.js";
|
|
3
5
|
import { Field } from "../field/field.js";
|
|
4
6
|
import { Input, InputGroup } from "../input/input.js";
|
|
5
7
|
import { Tag } from "../tag/tag.js";
|
|
6
|
-
export function TagField({ label, note, error, disabled, defaultValue = [], onValueChange, placeholder = "Add a tag", className, "data-force": force }) {
|
|
7
|
-
const [tags, setTags] = React.useState(defaultValue), [draft, setDraft] = React.useState("");
|
|
8
|
+
export function TagField({ label, note, error, disabled, defaultValue = [], fixed = [], asides, onValueChange, placeholder = "Add a tag", className, "data-force": force }) {
|
|
9
|
+
const [tags, setTags] = React.useState(() => [...fixed, ...defaultValue.filter((t) => !fixed.includes(t))]), [draft, setDraft] = React.useState("");
|
|
10
|
+
const loose = tags.filter((t) => !fixed.includes(t));
|
|
8
11
|
const set = (next) => { setTags(next); onValueChange?.(next); };
|
|
12
|
+
const inRows = React.useContext(FieldRowsCardContext) != null;
|
|
9
13
|
const add = () => { const w = draft.trim(); if (w && !tags.includes(w))
|
|
10
14
|
set([...tags, w]); setDraft(""); };
|
|
11
|
-
return (_jsx(Field, { label: label, note: note, error: error, disabled: disabled, className: className, children: _jsxs(InputGroup, { className: "o-tag-field", "data-force": force, children: [tags.map((t) => _jsx(Tag, { onRemove: disabled ? undefined : () => set(tags.filter((x) => x !== t)), children: t }, t)), _jsx(Input, { className: "o-tag-field-input", value: draft, placeholder: placeholder, autoComplete: "off", onChange: (e) => setDraft(e.currentTarget.value), onBlur: add, onKeyDown: (e) => {
|
|
15
|
+
return (_jsx(Field, { label: label, note: note, error: error, disabled: disabled, className: cx(inRows && "o-tag-field-row", className), children: _jsxs(InputGroup, { className: "o-tag-field", "data-force": force, children: [tags.map((t) => _jsx(Tag, { aside: asides?.[t], onRemove: disabled || fixed.includes(t) ? undefined : () => set(tags.filter((x) => x !== t)), children: t }, t)), _jsx(Input, { className: "o-tag-field-input", value: draft, placeholder: placeholder, autoComplete: "off", onChange: (e) => setDraft(e.currentTarget.value), onBlur: add, onKeyDown: (e) => {
|
|
12
16
|
if (e.key === "Enter" || e.key === ",") {
|
|
13
17
|
e.preventDefault();
|
|
14
18
|
add();
|
|
15
19
|
}
|
|
16
|
-
else if (e.key === "Backspace" && !draft &&
|
|
17
|
-
|
|
20
|
+
else if (e.key === "Backspace" && !draft && loose.length) {
|
|
21
|
+
const last = loose[loose.length - 1];
|
|
22
|
+
set(tags.filter((x) => x !== last));
|
|
23
|
+
}
|
|
18
24
|
} })] }) }));
|
|
19
25
|
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
export declare const TAG_FIELD_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-border-width";
|
|
3
|
+
readonly kind: "size";
|
|
4
|
+
readonly outright: "--border-width";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-font-weight-normal";
|
|
7
|
+
readonly kind: "size";
|
|
8
|
+
readonly outright: "--font-weight-normal";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-neutral";
|
|
11
|
+
readonly kind: "colour";
|
|
12
|
+
readonly outright: "--background-neutral";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-radius-full";
|
|
15
|
+
readonly kind: "size";
|
|
16
|
+
readonly outright: "--radius-full";
|
|
17
|
+
}, {
|
|
2
18
|
readonly name: "--vk-spacing";
|
|
3
19
|
readonly kind: "size";
|
|
4
20
|
readonly outright: "--spacing";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const TAG_FIELD_TOKENS = [
|
|
2
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
3
|
+
{ name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
|
|
4
|
+
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
5
|
+
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
2
6
|
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
3
7
|
];
|
|
4
8
|
export const TAG_FIELD_PRIVATE = [];
|
|
@@ -10,4 +10,23 @@
|
|
|
10
10
|
.o-input.o-input-group.o-tag-field { flex-wrap: wrap; height: auto; min-height: calc(var(--vk-spacing) * 9); padding-block: calc(var(--vk-spacing) * 1.5); }
|
|
11
11
|
.o-input.o-input-group.o-tag-field:where([data-vk-phone], [data-vk-phone] *) { min-height: calc(var(--vk-spacing) * 11); padding-block: calc(var(--vk-spacing) * 2.5); }
|
|
12
12
|
.o-input-control.o-tag-field-input { align-self: center; min-width: calc(var(--vk-spacing) * 20); }
|
|
13
|
+
|
|
14
|
+
/* ── In a row of Field rows (VK-978; the settings canvas, round 3: look-ios.mjs .tok, .caret): the card's row as iOS draws a To
|
|
15
|
+
field. Its tokens fill the row from its words' inset, 6 apart, 12 above and below, wrapping as they grow, the caret after the
|
|
16
|
+
last (the Input typed in place, input.css). Its label names the box but stands out of sight: its place titles the group. Each
|
|
17
|
+
token is the Tag as iOS draws it: 30 tall, a pill on the neutral ground, no edge, no icon and no smoothing, the row's words in the normal
|
|
18
|
+
weight, as wide as the row lets it; its remove button stays, quiet. Its rules outweigh the box's and the phone's above, and
|
|
19
|
+
the Tag's own. ── */
|
|
20
|
+
.o-field.o-field-row.o-tag-field-row { position: relative; }
|
|
21
|
+
.o-tag-field-row > .o-field-row-label { position: absolute; width: var(--vk-border-width); height: var(--vk-border-width); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
22
|
+
.o-input.o-input-inrow.o-tag-field.o-tag-field { flex-wrap: wrap; align-content: center; gap: calc(var(--vk-spacing) * 1.5); min-height: 0; padding-block: calc(var(--vk-spacing) * 3); }
|
|
23
|
+
.o-input.o-input-inrow.o-tag-field > .o-tag.o-tag {
|
|
24
|
+
--tag-h: calc(var(--vk-spacing) * 7.5); --tag-r: var(--vk-radius-full);
|
|
25
|
+
max-width: 100%; padding: 0 calc(var(--vk-spacing) * 2.5); border-radius: var(--tag-r); background-color: var(--vk-neutral); box-shadow: none;
|
|
26
|
+
font-size: inherit; font-weight: var(--vk-font-weight-normal);
|
|
27
|
+
}
|
|
28
|
+
/* A pill has no corner to smooth: the token paints its own ground, and its cut (the smooth ground and edge) stands down. */
|
|
29
|
+
.o-input-inrow.o-tag-field > .o-tag > :is(.o-tag-cut, .o-tag-icon) { display: none; }
|
|
30
|
+
/* Once a token stands, the caret alone after it: the placeholder only asks while the row is empty. */
|
|
31
|
+
.o-input-inrow.o-tag-field:has(> .o-tag) > .o-tag-field-input::placeholder { color: transparent; }
|
|
13
32
|
}
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
/* Its word is cropped so a long one ends in "…". The box that crops it stands as tall as the chip, never only as tall as its
|
|
21
21
|
letters: at the chip's line-height of 1 the crop took the foot of every g, y and p. The word stays where it was. */
|
|
22
22
|
.o-tag-word { overflow: hidden; text-overflow: ellipsis; line-height: var(--tag-h); }
|
|
23
|
+
/* A quiet word after its name ("main"): the quieter colour, the normal weight. */
|
|
24
|
+
.o-tag-aside { flex: none; color: var(--vk-fg-subtle); font-weight: var(--vk-font-weight-normal); line-height: var(--tag-h); }
|
|
23
25
|
.o-tag-icon { flex: none; width: calc(var(--vk-spacing) * 3); height: calc(var(--vk-spacing) * 3); margin-left: calc(var(--vk-spacing) * -0.25); fill: none; stroke: var(--vk-fg-subtle); stroke-linecap: round; stroke-linejoin: round; }
|
|
24
26
|
/* Small, in dense rows; a count for the rest, its number in the quieter colour. */
|
|
25
27
|
.o-tag.o-tag-sm { --tag-h: calc(var(--vk-spacing) * 5); padding: 0 calc(var(--vk-spacing) * 1.5); }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
3
3
|
import { type InputProps } from "../input/input.js";
|
|
4
|
+
import { type MenuEntry } from "../menu/menu.js";
|
|
4
5
|
import { type ToolbarPicks } from "./looks.js";
|
|
5
6
|
import { type ToolbarWords } from "./words.js";
|
|
6
7
|
/** Where a list's part stands: on the row (where it begins), on the row's right, on the filter bar, or on a phone's one line. */
|
|
@@ -56,6 +57,13 @@ export interface ToolbarProps extends Omit<BaseToolbar.Root.Props, "className" |
|
|
|
56
57
|
spacing?: number;
|
|
57
58
|
/** Whether what doesn't fit gives way (words to icons, then into ⋯); otherwise it runs past its end. */
|
|
58
59
|
fold?: boolean;
|
|
60
|
+
/** Its row's worded buttons grow to share the row's width, its square ones keeping theirs (a record's actions, Attio's way);
|
|
61
|
+
* what doesn't fit still gives way, the first worded button with an icon keeping its words to the last. The filter bar under
|
|
62
|
+
* it draws as without. */
|
|
63
|
+
fill?: boolean;
|
|
64
|
+
/** What ⋯ at the row's end always holds, after what folded into it: a row of actions with more than it shows (a record's).
|
|
65
|
+
* Given, ⋯ stands at the row's end even when nothing folded, what folds joining it in the row's order. */
|
|
66
|
+
more?: MenuEntry[];
|
|
59
67
|
/** Holds every line as it stands, giving way no further and taking no step back: while what a folded item opened stands open
|
|
60
68
|
* under the button that holds it ("+N filters", ⋯), so that button keeps its place (KIT-624). */
|
|
61
69
|
holds?: boolean;
|
|
@@ -86,12 +94,13 @@ export interface ToolbarFoldsProps {
|
|
|
86
94
|
export declare function ToolbarFolds({ children }: ToolbarFoldsProps): React.ReactNode;
|
|
87
95
|
/** The steps a line takes as it narrows, in order: words to icons from its end; then the view tabs fold into "+N" from their end,
|
|
88
96
|
* the views giving way before the tools, as the portal's row does; then the filters fold into "+N filters" from their end, only
|
|
89
|
-
* once nothing else gives words up (KIT-624); then the rest folds into ⋯ from its end.
|
|
90
|
-
|
|
97
|
+
* once nothing else gives words up (KIT-624); then the rest folds into ⋯ from its end. Filling its row (`fill`), its first worded
|
|
98
|
+
* button with an icon leads: it keeps its words while the others give theirs up and fold, then turns to its icon and folds last. */
|
|
99
|
+
declare function stepsOf(items: React.ReactElement[], fill?: boolean): Step[];
|
|
91
100
|
/** The steps a line takes as it narrows, for a test (stepsOf). */
|
|
92
101
|
export declare const toolbarSteps: typeof stepsOf;
|
|
93
102
|
/** The row and, under it, the filter bar: Base UI's toolbar, one Tab stop for the whole of it, the arrows inside. */
|
|
94
|
-
export declare function ToolbarControl({ label, children, bar, barLabel: barNamed, words: given, views, settings, search, add, sort, filter, filters, save, quick, added, picks: said, size, barSize, spacing, fold, holds, form, onMoreViews, moreViewsOpen, className, style, onKeyDown, ...props }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
103
|
+
export declare function ToolbarControl({ label, children, bar, barLabel: barNamed, words: given, views, settings, search, add, sort, filter, filters, save, quick, added, picks: said, size, barSize, spacing, fold, fill, more, holds, form, onMoreViews, moreViewsOpen, className, style, onKeyDown, ...props }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
95
104
|
/** A line between what belongs together and what doesn't, across a line. */
|
|
96
105
|
export declare function ToolbarSeparatorControl({ className }: {
|
|
97
106
|
className?: string;
|
|
@@ -101,6 +110,9 @@ export declare function ToolbarSpacer(): import("react/jsx-runtime").JSX.Element
|
|
|
101
110
|
export interface ToolbarInputProps extends InputProps {
|
|
102
111
|
/** An icon at its start side, inside the field: the search's. */
|
|
103
112
|
icon?: React.ReactNode;
|
|
113
|
+
/** The search's button, shut: `both` shows "Search" beside its icon as the buttons on the right show their words; absent or
|
|
114
|
+
* `icon`, its icon alone (VK-967). */
|
|
115
|
+
words?: "both" | "icon";
|
|
104
116
|
}
|
|
105
117
|
/** The text box in the Toolbar: the Input, one of its stops, at its line's height unless it says its own (the search, its icon at
|
|
106
118
|
* its start side). It keeps its width, giving some up down to its narrowest when the line is tight. The arrows move its caret,
|
|
@@ -8,6 +8,7 @@ import { Button, ButtonGroup } from "../button/button.js";
|
|
|
8
8
|
import { Input, InputGroup, InputGroupAddon, InputGroupButton } from "../input/input.js";
|
|
9
9
|
import { Icon } from "../internal/icons.js";
|
|
10
10
|
import { PhoneHost, usePhone } from "../internal/phone.js";
|
|
11
|
+
import { watchFrame } from "../internal/watch-frame.js";
|
|
11
12
|
import { Menu } from "../menu/menu.js";
|
|
12
13
|
import { ToggleGroup } from "../toggle/toggle.js";
|
|
13
14
|
import { InToolbar, ToolbarButtonControl as ToolbarButton, useToolbarButtonWorn } from "../toolbar-button/toolbar-button.js";
|
|
@@ -27,9 +28,7 @@ export function useToolbarWorn(el) {
|
|
|
27
28
|
React.useLayoutEffect(() => {
|
|
28
29
|
const read = () => setPicks((was) => { const now = toolbarWornOf(el); return samePicks(was, now) ? was : now; });
|
|
29
30
|
read();
|
|
30
|
-
|
|
31
|
-
watch.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: TOOLBAR_ATTRS });
|
|
32
|
-
return () => watch.disconnect();
|
|
31
|
+
return watchFrame(TOOLBAR_ATTRS, read);
|
|
33
32
|
}, [el]);
|
|
34
33
|
return picks;
|
|
35
34
|
}
|
|
@@ -63,12 +62,14 @@ const isJoined = (el) => isGroup(el) && !!el.props["aria-label"] && flat(el.prop
|
|
|
63
62
|
const folds = (el) => (isToolbarButton(el) && !el.props.stays)
|
|
64
63
|
|| (isJoined(el) && el.props["data-open"] == null);
|
|
65
64
|
const isFilter = (el) => !!el && (isJoined(el) || (isToolbarButton(el) && !!el.props.filter));
|
|
66
|
-
function stepsOf(items) {
|
|
67
|
-
const
|
|
65
|
+
function stepsOf(items, fill = false) {
|
|
66
|
+
const lead = fill ? items.findIndex((el) => sheds(el) && !isTab(el) && !isFilter(el)) : -1;
|
|
67
|
+
const from = (test, to) => items.flatMap((el, i) => (i !== lead && test(el) ? [{ i, to }] : [])).reverse();
|
|
68
68
|
const held = (kind) => (el, i) => isFolds(el) && el.props.kind === kind ? Array.from({ length: Math.max(0, el.props.count) }, () => ({ i, to: "fold" })) : [];
|
|
69
69
|
const fromWith = (test, kind) => items.flatMap((el, i) => (test(el) ? [{ i, to: "fold" }] : held(kind)(el, i))).reverse();
|
|
70
|
+
const last = lead < 0 ? [] : [{ i: lead, to: "icon" }, ...(folds(items[lead]) ? [{ i: lead, to: "fold" }] : [])];
|
|
70
71
|
return [...from(sheds, "icon"), ...fromWith((el) => folds(el) && isTab(el), "tabs"), ...fromWith((el) => folds(el) && isFilter(el), "filters"),
|
|
71
|
-
...from((el) => folds(el) && !isTab(el) && !isFilter(el), "fold")];
|
|
72
|
+
...from((el) => folds(el) && !isTab(el) && !isFilter(el), "fold"), ...last];
|
|
72
73
|
}
|
|
73
74
|
export const toolbarSteps = stepsOf;
|
|
74
75
|
function overflows(line) {
|
|
@@ -157,7 +158,7 @@ function useGiveWay(line, max, on, holds = false) {
|
|
|
157
158
|
}, [line, on, look]);
|
|
158
159
|
return stage;
|
|
159
160
|
}
|
|
160
|
-
export function ToolbarControl({ label, children, bar, barLabel: barNamed, words: given, views, settings, search, add, sort, filter, filters, save, quick, added = false, picks: said, size, barSize, spacing, fold = true, holds = false, form, onMoreViews, moreViewsOpen, className, style, onKeyDown, ...props }) {
|
|
161
|
+
export function ToolbarControl({ label, children, bar, barLabel: barNamed, words: given, views, settings, search, add, sort, filter, filters, save, quick, added = false, picks: said, size, barSize, spacing, fold = true, fill = false, more, holds = false, form, onMoreViews, moreViewsOpen, className, style, onKeyDown, ...props }) {
|
|
161
162
|
const spoken = toolbarWords(given), barLabel = barNamed ?? spoken.bar;
|
|
162
163
|
const host = React.useContext(PhoneHost), narrow = usePhone();
|
|
163
164
|
const phone = form ? form === "phone" : host != null || narrow;
|
|
@@ -179,7 +180,7 @@ export function ToolbarControl({ label, children, bar, barLabel: barNamed, words
|
|
|
179
180
|
const searchForm = phone ? picks.searchphone : picks.search;
|
|
180
181
|
const opens = searchForm === "button";
|
|
181
182
|
const rightWords = picks.words === "both" ? "both" : "icon";
|
|
182
|
-
const searchEl = search && (_jsx(InSearch.Provider, { value: { form: opens ? "button" : "input",
|
|
183
|
+
const searchEl = search && (_jsx(InSearch.Provider, { value: { form: opens ? "button" : "input", rightWords: phone ? "icon" : rightWords, open: searching, setOpen: setSearching }, children: search }, "search"));
|
|
183
184
|
const spacer = (key) => _jsx(ToolbarSpacer, {}, key);
|
|
184
185
|
if (phone) {
|
|
185
186
|
const right = picks.sortfilterphone === "right";
|
|
@@ -226,7 +227,7 @@ export function ToolbarControl({ label, children, bar, barLabel: barNamed, words
|
|
|
226
227
|
e.preventDefault();
|
|
227
228
|
to.focus();
|
|
228
229
|
};
|
|
229
|
-
return (_jsx(BaseToolbar.Root, { ref: setRoot, "aria-label": label, orientation: "horizontal", className: cn("o-toolbar", className), "data-kit": "toolbar", "data-screen": phone ? "phone" : "computer", "data-size": height, "data-lines": listed && !phone ? picks.lines : undefined, style: spacing != null ? { ...style, "--toolbar-spacing": spacing } : style, onKeyDown: ends, ...props, children: _jsx(Said.Provider, { value: spoken, children: lines.map((l) => (_jsx(InToolbar.Provider, { value: { size: l.size, form: phone ? "phone" : "computer" }, children: _jsx(Line, { id: l.id, label: l.label, items: l.items, size: l.size, fold: fold, holds: holds, more: onMoreViews ? { press: onMoreViews, open: !!moreViewsOpen } : undefined }) }, l.id))) }) }));
|
|
230
|
+
return (_jsx(BaseToolbar.Root, { ref: setRoot, "aria-label": label, orientation: "horizontal", className: cn("o-toolbar", className), "data-kit": "toolbar", "data-screen": phone ? "phone" : "computer", "data-size": height, "data-lines": listed && !phone ? picks.lines : undefined, "data-fill": fill ? "" : undefined, style: spacing != null ? { ...style, "--toolbar-spacing": spacing } : style, onKeyDown: ends, ...props, children: _jsx(Said.Provider, { value: spoken, children: lines.map((l) => (_jsx(InToolbar.Provider, { value: { size: l.size, form: phone ? "phone" : "computer" }, children: _jsx(Line, { id: l.id, label: l.label, items: l.items, size: l.size, fold: fold, fill: fill && l.id === "row", entries: l.id === "row" ? more : undefined, holds: holds, more: onMoreViews ? { press: onMoreViews, open: !!moreViewsOpen } : undefined }) }, l.id))) }) }));
|
|
230
231
|
}
|
|
231
232
|
function dressNew(el, form, ground) {
|
|
232
233
|
if (!isButton(el))
|
|
@@ -235,10 +236,10 @@ function dressNew(el, form, ground) {
|
|
|
235
236
|
const kind = form.startsWith("primary") ? "primary" : form.startsWith("outline") ? "outline" : KIND_OF_GROUND[ground];
|
|
236
237
|
return React.cloneElement(el, { kind, ...(form.endsWith("-icon") ? { shape: "icon", children: undefined, "aria-label": p["aria-label"] ?? said ?? undefined } : {}) });
|
|
237
238
|
}
|
|
238
|
-
function Line({ id, label, items, size, fold, holds, more: moreViews }) {
|
|
239
|
+
function Line({ id, label, items, size, fold, fill, entries, holds, more: moreViews }) {
|
|
239
240
|
const [line, setLine] = React.useState(null);
|
|
240
241
|
const said = React.useContext(Said);
|
|
241
|
-
const steps = fold ? stepsOf(items) : [];
|
|
242
|
+
const steps = fold ? stepsOf(items, fill) : [];
|
|
242
243
|
const stage = useGiveWay(line, steps.length, fold, holds);
|
|
243
244
|
const iconAlone = new Set(), folded = new Set(), foldedIn = new Map();
|
|
244
245
|
for (const s of steps.slice(0, stage)) {
|
|
@@ -262,7 +263,11 @@ function Line({ id, label, items, size, fold, holds, more: moreViews }) {
|
|
|
262
263
|
return [{ icon: p.icon ?? null, label: words(p.children) ?? p.label, count: p.count, disabled: p.disabled ? said.cantUse : undefined,
|
|
263
264
|
onSelect: () => pressAt(p.onClick, line?.querySelector(at)) }];
|
|
264
265
|
};
|
|
265
|
-
const
|
|
266
|
+
const given = entries != null, always = !!entries?.length;
|
|
267
|
+
const moreEntries = given
|
|
268
|
+
? [...[...otherFolded].sort((a, b) => a - b).flatMap((i) => entryOf(items[i], "[data-more]")), ...entries]
|
|
269
|
+
: otherFolded.flatMap((i) => entryOf(items[i], "[data-more]"));
|
|
270
|
+
const more = (_jsx(Menu, { label: said.moreOf(label), align: "end", entries: moreEntries, trigger: _jsx(ToolbarButton, { label: said.more, icon: _jsx(Icon, { name: "dots" }), words: "icon", stays: true, "data-more": "" }) }, "more"));
|
|
266
271
|
const firstTab = items.find(isTab);
|
|
267
272
|
const plusN = (p = {}) => (_jsx(ToolbarButton, { label: said.moreViews(tabFolded.length), words: "word", current: false, stays: true, "data-more-tabs": "", ground: firstTab?.props.ground, corners: firstTab?.props.corners, ...p, children: `+${tabFolded.length}` }, "more-tabs"));
|
|
268
273
|
const moreTabs = !tabFolded.length ? null : moreViews
|
|
@@ -273,7 +278,7 @@ function Line({ id, label, items, size, fold, holds, more: moreViews }) {
|
|
|
273
278
|
const drawn = [];
|
|
274
279
|
items.forEach((el, i) => {
|
|
275
280
|
if (folded.has(i)) {
|
|
276
|
-
if (i === moreAt)
|
|
281
|
+
if (i === moreAt && !given)
|
|
277
282
|
drawn.push(more);
|
|
278
283
|
if (i === tabsAt)
|
|
279
284
|
drawn.push(moreTabs);
|
|
@@ -287,6 +292,8 @@ function Line({ id, label, items, size, fold, holds, more: moreViews }) {
|
|
|
287
292
|
}
|
|
288
293
|
drawn.push(dress(el, iconAlone.has(i), size));
|
|
289
294
|
});
|
|
295
|
+
if (always || (given && otherFolded.length > 0))
|
|
296
|
+
drawn.push(more);
|
|
290
297
|
const shown = drawn.filter((n, k) => {
|
|
291
298
|
if (!isSeparator(n))
|
|
292
299
|
return true;
|
|
@@ -340,7 +347,7 @@ export function ToolbarSeparatorControl({ className }) {
|
|
|
340
347
|
export function ToolbarSpacer() {
|
|
341
348
|
return _jsx("span", { className: "o-toolbar-spacer", "aria-hidden": "true" });
|
|
342
349
|
}
|
|
343
|
-
export const ToolbarInput = React.forwardRef(function ToolbarInput({ size, icon, className, onKeyDown, onBlur, ...props }, ref) {
|
|
350
|
+
export const ToolbarInput = React.forwardRef(function ToolbarInput({ size, icon, words, className, onKeyDown, onBlur, ...props }, ref) {
|
|
344
351
|
const row = React.useContext(InToolbar), search = React.useContext(InSearch), said = React.useContext(Said);
|
|
345
352
|
const z = size ?? (row ? INPUT_SIZE[row.size] : undefined);
|
|
346
353
|
const opens = search?.form === "button" && icon != null;
|
|
@@ -351,7 +358,7 @@ export const ToolbarInput = React.forwardRef(function ToolbarInput({ size, icon,
|
|
|
351
358
|
} }, [iconEl]);
|
|
352
359
|
const name = props["aria-label"] ?? props.placeholder ?? said.search;
|
|
353
360
|
if (opens && !search.open)
|
|
354
|
-
return _jsx(ToolbarButton, { ref: setIconEl, label: name, icon: icon, words: search.
|
|
361
|
+
return _jsx(ToolbarButton, { ref: setIconEl, label: name, icon: icon, words: words === "both" ? search.rightWords : "icon", stays: true, onClick: () => search.setOpen(true), children: said.search });
|
|
355
362
|
const close = opens ? () => { if (props.value != null)
|
|
356
363
|
props.onValueChange?.("", undefined); search.setOpen(false); } : null;
|
|
357
364
|
const input = (_jsx(Input, { ref: ref, size: z, className: cn("o-toolbar-input", className), ...(row ? { render: _jsx(BaseToolbar.Input, {}) } : {}), ...(close ? { autoFocus: true } : {}), onKeyDown: (e) => { onKeyDown?.(e); if (close && e.key === "Escape") {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ViewsToolbarButtonPart, ViewsToolbarButtonProps } from "../../atoms/types.js";
|
|
2
|
+
import { type ToolbarButtonGround, type ToolbarButtonProps } from "./toolbar-button.js";
|
|
3
|
+
/** How the Toolbar's own page dresses each of the toolbar's parts, on a phone or a computer, its tabs on the ground "The tabs"
|
|
4
|
+
* picks: the view switcher with its words and ▾ (on a phone, current and in the brand where the views are tabs, its words alone
|
|
5
|
+
* where they are one button); a tab its corners full, its words beside its icon, the open one current; "+N" an unopened tab's
|
|
6
|
+
* dress with its word; + its icon alone, ghost; Clear the ghost and Save the bordered, each its word. */
|
|
7
|
+
export declare function toolbarPartDress(part: ViewsToolbarButtonPart, { current, phone, tabs, ground }: {
|
|
8
|
+
current?: boolean;
|
|
9
|
+
phone: boolean;
|
|
10
|
+
tabs: boolean;
|
|
11
|
+
ground: ToolbarButtonGround;
|
|
12
|
+
}): Partial<ToolbarButtonProps>;
|
|
13
|
+
/** The ToolbarButton atom as the toolbar button. ViewKit's own `size` is not read: in a Toolbar a button takes its line's. */
|
|
14
|
+
export declare function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, onContextMenu, onClick, onPointerDown, ref }: ViewsToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
5
|
+
import { Button } from "../button/button.js";
|
|
6
|
+
import { Icon } from "../internal/icons.js";
|
|
7
|
+
import { useToolbarWorn } from "../toolbar/toolbar.js";
|
|
8
|
+
import { InToolbar, ToolbarButtonControl } from "./toolbar-button.js";
|
|
9
|
+
const BUTTON_SIZE = { "28": "xs", "32": "sm", "36": "md", "44": "44" };
|
|
10
|
+
const PART_SLOT = {
|
|
11
|
+
"views-chip": "vk-views-chip", "views-tab": "vk-views-tab", "views-more": "vk-views-more", "views-add": "vk-views-add",
|
|
12
|
+
clear: "vk-toolbar-clear", save: "vk-toolbar-save-button",
|
|
13
|
+
};
|
|
14
|
+
export function toolbarPartDress(part, { current, phone, tabs, ground }) {
|
|
15
|
+
switch (part) {
|
|
16
|
+
case "views-chip": return phone && !tabs ? { words: "both" } : { words: "both", iconEnd: _jsx(Icon, { name: "down" }), ...(phone ? { current: true, lit: true } : {}) };
|
|
17
|
+
case "views-tab": return { ground, corners: "full", words: "both", current: !!current };
|
|
18
|
+
case "views-more": return { ground, corners: "full", words: "word", current: false };
|
|
19
|
+
case "views-add": return { ground: "ghost", corners: "full", words: "icon" };
|
|
20
|
+
case "clear": return { ground: "ghost", words: "word" };
|
|
21
|
+
case "save": return { ground: "bordered", words: "word" };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, onContextMenu, onClick, onPointerDown, ref }) {
|
|
25
|
+
const row = React.useContext(InToolbar);
|
|
26
|
+
const [el, setEl] = React.useState(null);
|
|
27
|
+
const picks = useToolbarWorn(el);
|
|
28
|
+
const own = React.useCallback((node) => {
|
|
29
|
+
setEl(node);
|
|
30
|
+
if (typeof ref === "function")
|
|
31
|
+
ref(node);
|
|
32
|
+
else if (ref)
|
|
33
|
+
ref.current = node;
|
|
34
|
+
}, [ref]);
|
|
35
|
+
const opens = popup ? { "aria-haspopup": popup, "aria-expanded": !!open } : {};
|
|
36
|
+
const text = children ?? (typeof word === "string" ? word : undefined);
|
|
37
|
+
const said = waits && text != null ? _jsx("span", { className: "o-toolbar-button-waits", children: text }) : text;
|
|
38
|
+
if (foot)
|
|
39
|
+
return _jsx(Button, { ref: own, kind: "primary", shape: "round", size: "44", icon: icon, "aria-label": label, disabled: disabled, onClick: onClick, onPointerDown: onPointerDown, ...opens });
|
|
40
|
+
if (edge && !picks.add.startsWith("like")) {
|
|
41
|
+
const alone = word === null || picks.add.endsWith("-icon");
|
|
42
|
+
const button = (_jsx(Button, { ref: own, kind: picks.add.startsWith("primary") ? "primary" : "outline", size: BUTTON_SIZE[row?.size ?? "32"], icon: icon, shape: alone ? "icon" : undefined, "aria-label": alone ? label : undefined, disabled: disabled, onClick: onClick, onPointerDown: onPointerDown, ...opens, children: alone ? undefined : (said ?? label) }));
|
|
43
|
+
return row ? _jsx(BaseToolbar.Button, { render: button, disabled: disabled }) : button;
|
|
44
|
+
}
|
|
45
|
+
const words = iconAlone || (edge && picks.add === "like-icon") || word === null ? "icon" : undefined;
|
|
46
|
+
if (part) {
|
|
47
|
+
return (_jsx(ToolbarButtonControl, { ref: own, label: label, icon: icon, "data-slot": PART_SLOT[part], ...toolbarPartDress(part, { current, phone: row?.form === "phone", tabs: picks.views === "tabs", ground: picks.tabs ?? "ghost" }), disabled: disabled, focusableWhenDisabled: !!disabledReason, onClick: onClick, onPointerDown: onPointerDown, onContextMenu: onContextMenu, ...opens, children: said }));
|
|
48
|
+
}
|
|
49
|
+
const counted = !dot && typeof count === "number" && count > 0 ? count : more;
|
|
50
|
+
return (_jsx(ToolbarButtonControl, { ref: own, label: label, icon: icon, words: words, count: counted, dot: dot, empty: empty, lit: changed, aside: aside, stays: edge, joined: joined, ...(waits ? { "data-waits": "" } : {}), disabled: disabled, focusableWhenDisabled: !!disabledReason, onClick: onClick, onPointerDown: onPointerDown, ...opens, children: said }));
|
|
51
|
+
}
|
|
@@ -17,7 +17,7 @@ export declare const InToolbar: React.Context<{
|
|
|
17
17
|
form: "computer" | "phone";
|
|
18
18
|
} | null>;
|
|
19
19
|
/** Its options as worn around `el`, kept up to date as the frame's attributes change: what a toolbar reads too, for its row's
|
|
20
|
-
* height. */
|
|
20
|
+
* height. Every reader shares one observer on the page (watch-frame.ts), so a toolbar of them opens one, not one per button. */
|
|
21
21
|
export declare function useToolbarButtonWorn(el: HTMLElement | null, phone: boolean): Worn;
|
|
22
22
|
export interface ToolbarButtonProps extends Omit<ButtonProps, "kind" | "size" | "shape" | "look" | "children"> {
|
|
23
23
|
/** Its name: its word, unless `children` says more, and its name to a screen reader when its icon stands alone. */
|
|
@@ -5,6 +5,7 @@ import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
|
5
5
|
import { cx } from "../../internal/cx.js";
|
|
6
6
|
import { Button } from "../button/button.js";
|
|
7
7
|
import { PhoneHost, usePhone } from "../internal/phone.js";
|
|
8
|
+
import { watchFrame } from "../internal/watch-frame.js";
|
|
8
9
|
import { TOOLBAR_BUTTON_LOOKS } from "./looks.js";
|
|
9
10
|
const KIND = { ghost: "quiet", bordered: "outline", filled: "soft" };
|
|
10
11
|
const SIZE = { "28": "xs", "32": "sm", "36": "md", "44": "44" };
|
|
@@ -23,9 +24,7 @@ export function useToolbarButtonWorn(el, phone) {
|
|
|
23
24
|
React.useLayoutEffect(() => {
|
|
24
25
|
const read = () => setWorn((was) => { const now = wornOf(el, phone); return same(was, now) ? was : now; });
|
|
25
26
|
read();
|
|
26
|
-
|
|
27
|
-
watch.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: ATTRS });
|
|
28
|
-
return () => watch.disconnect();
|
|
27
|
+
return watchFrame(ATTRS, read);
|
|
29
28
|
}, [el, phone]);
|
|
30
29
|
return worn;
|
|
31
30
|
}
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
.o-toolbar-button-count { margin-left: var(--vk-spacing); color: var(--vk-fg-subtle); font-variant-numeric: tabular-nums; }
|
|
37
37
|
.o-toolbar-button-count[data-alone] { margin-left: 0; }
|
|
38
38
|
|
|
39
|
+
/* The words of a value it waits for (a filter's "Choose"), in the placeholder's colour: ViewKit's ToolbarButton atom drawn with it
|
|
40
|
+
(CONTROL_ATOMS) wraps them. */
|
|
41
|
+
.o-toolbar-button-waits { color: var(--vk-fg-subtle); }
|
|
42
|
+
|
|
39
43
|
/* A dot at its top end corner, in the brand: something applied with no number. Drawn with ::before, since the pressing area takes
|
|
40
44
|
::after on a phone (its pressing area). */
|
|
41
45
|
.o-button.o-toolbar-button[data-dot]::before {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
search on its own line (data-line="search"), above it
|
|
7
7
|
data-screen computer · phone the room between what a line holds; a phone's is one line
|
|
8
8
|
data-lines across · none a list's lines in bands with a line across under each, or not
|
|
9
|
+
data-fill (set) · none its row's worded buttons grow to share it (a record's actions)
|
|
9
10
|
--toolbar-spacing how far apart what a line holds stands, in spacing steps, when what holds it says so
|
|
10
11
|
--toolbar-inset the room at each side of each line, when what holds it gives one (0 unless said)
|
|
11
12
|
|
|
@@ -28,6 +29,10 @@
|
|
|
28
29
|
|
|
29
30
|
/* What a line holds keeps its width; only a text box gives some up, from its own width down to its narrowest. */
|
|
30
31
|
.o-toolbar-line > * { flex: none; }
|
|
32
|
+
/* Filling its row (fill: a record's actions, Attio's way): the row's worded buttons grow from their own width to share the line, their
|
|
33
|
+
words in their middle; a square one (its icon alone) keeps its own. None shrinks under its own width, so what doesn't fit still
|
|
34
|
+
gives way. */
|
|
35
|
+
.o-toolbar[data-fill] > .o-toolbar-line[data-line="row"] > .o-button:not(.o-button-icon, .o-button-round) { flex: 1 0 auto; }
|
|
31
36
|
.o-toolbar-line > :is(.o-toolbar-input, .o-input-group:has(.o-toolbar-input)) { flex: 0 1 calc(var(--vk-spacing) * 55); min-width: calc(var(--vk-spacing) * 30); }
|
|
32
37
|
|
|
33
38
|
/* A list's search: on a phone's line of its own it fills it; open on a phone's one line it takes the room the others left. */
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ViewsViewMenuProps } from "../../provider/components.js";
|
|
2
|
+
/** ViewKit's view menu at a views row's pill. */
|
|
3
|
+
export declare function MapViewMenu({ open, onOpenChange, anchor, align, view, views, value, verbs, onDone, onHold }: ViewsViewMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ViewsContext } from "../../provider/context.js";
|
|
5
|
+
import { PhoneHost, usePhone } from "../internal/phone.js";
|
|
6
|
+
import { MapMenu } from "../menu/map-menu.js";
|
|
7
|
+
import { useVerbsMenu } from "./map-views-list-body.js";
|
|
8
|
+
export function MapViewMenu({ open, onOpenChange, anchor, align, view, views, value, verbs, onDone, onHold }) {
|
|
9
|
+
const Menu = React.useContext(ViewsContext)?.components.Menu ?? MapMenu;
|
|
10
|
+
const screen = React.useContext(PhoneHost), small = usePhone();
|
|
11
|
+
const creating = view === undefined;
|
|
12
|
+
const menu = useVerbsMenu({
|
|
13
|
+
views, value, verbs, form: screen || small ? "phone" : "computer",
|
|
14
|
+
...(onDone ? { onDone } : {}), ...(onHold ? { onHold } : {}), ...(creating && open ? { shows: { what: "new" } } : {}),
|
|
15
|
+
});
|
|
16
|
+
const { asking } = menu;
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
if (creating && !asking)
|
|
19
|
+
onOpenChange(false);
|
|
20
|
+
}, [creating, asking, onOpenChange]);
|
|
21
|
+
if (creating)
|
|
22
|
+
return _jsx(_Fragment, { children: menu.dialogs });
|
|
23
|
+
const label = views.find((v) => v.value === view)?.label ?? "";
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx(Menu, { open: open, onOpenChange: onOpenChange, anchor: anchor, align: align ?? "start", label: label, items: open ? menu.items(view) : [] }), menu.dialogs] }));
|
|
25
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type ViewsMessageResolver } from "../../contract.js";
|
|
3
|
-
import type { ViewsViewsListBodyProps, ViewsViewsListItem } from "../../provider/components.js";
|
|
3
|
+
import type { ViewsViewsListBodyProps, ViewsViewsListItem, ViewsViewVerbs } from "../../provider/components.js";
|
|
4
|
+
import { type ViewMenuParts, type ViewMenuShows } from "./view-menu.js";
|
|
4
5
|
import type { ViewMenuWords } from "./words.js";
|
|
6
|
+
import type { ListView, ViewsListChange, ViewsListLayout } from "./rules.js";
|
|
5
7
|
import { type ViewsListProps } from "./views-list.js";
|
|
6
8
|
import type { ViewsListWords } from "./words.js";
|
|
7
9
|
type AppIcon = React.ComponentType<{
|
|
@@ -19,4 +21,29 @@ export declare function viewsListPropsOf(p: ViewsViewsListBodyProps, words: View
|
|
|
19
21
|
export declare function viewMenuWordsOf(say: ViewsMessageResolver): ViewMenuWords;
|
|
20
22
|
/** ViewKit's views list body, drawn as the views list. */
|
|
21
23
|
export declare function MapViewsListBody(props: ViewsViewsListBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
/** What a view's menu drawn from the axis's verbs is handed: the views list body's (VK-823), and a pill's (`ViewMenu`, VK-947). */
|
|
25
|
+
export type VerbsMenuProps = {
|
|
26
|
+
views: readonly ViewsViewsListItem[];
|
|
27
|
+
/** The view in use. */
|
|
28
|
+
value: string;
|
|
29
|
+
verbs: ViewsViewVerbs;
|
|
30
|
+
form: "computer" | "phone";
|
|
31
|
+
/** A phone's menu and what it opens are steps of its holder's one Sheet (the list body's). */
|
|
32
|
+
steps?: boolean;
|
|
33
|
+
/** A pick and an order, which only a list makes: a menu alone hands on neither. */
|
|
34
|
+
onListChange?: (change: Extract<ViewsListChange, {
|
|
35
|
+
kind: "open" | "order";
|
|
36
|
+
}>) => void;
|
|
37
|
+
onDone?: () => void;
|
|
38
|
+
onHold?: (holding: boolean) => void;
|
|
39
|
+
/** What stands open as it mounts (useViewMenu's `shows`): New view's Modal, for the views row's + (VK-971). */
|
|
40
|
+
shows?: ViewMenuShows;
|
|
41
|
+
};
|
|
42
|
+
/** A view's menu from the axis's verbs (useViewMenu): the views as the menu reads them, their layouts (the verbs', a view's
|
|
43
|
+
* icon else), the app's own shape of the menu (`verbs.menu`, VK-741), its `confirm` on a computer and its `toast`; every change
|
|
44
|
+
* but a pick and an order goes to `verbs.onChange`. */
|
|
45
|
+
export declare function useVerbsMenu(p: VerbsMenuProps): ViewMenuParts & {
|
|
46
|
+
views: ListView[];
|
|
47
|
+
layouts: ViewsListLayout[];
|
|
48
|
+
};
|
|
22
49
|
export {};
|
|
@@ -73,6 +73,7 @@ export function viewMenuWordsOf(say) {
|
|
|
73
73
|
edit: say({ key: "views.panels.view-edit" }),
|
|
74
74
|
privateView: say({ key: "views.panels.view-private-toggle" }),
|
|
75
75
|
saveEveryone: say({ key: "views.panels.view-save-everyone" }),
|
|
76
|
+
saveOwn: say({ key: "views.panels.view-save-own" }),
|
|
76
77
|
reset: say({ key: "views.panels.view-reset" }),
|
|
77
78
|
saveNew: say({ key: "views.panels.view-save-new" }),
|
|
78
79
|
copyLink: say({ key: "views.panels.copy-link" }),
|
|
@@ -137,53 +138,70 @@ function Plain(props) {
|
|
|
137
138
|
function leavingFirst(list, leave) {
|
|
138
139
|
return list.map((e) => e.kind === undefined || e.kind === "action" ? { ...e, onSelect: () => { leave(); e.onSelect?.(); } } : e.kind === "group" ? { ...e, entries: leavingFirst(e.entries, leave) } : e);
|
|
139
140
|
}
|
|
140
|
-
function
|
|
141
|
-
const { verbs } =
|
|
141
|
+
export function useVerbsMenu(p) {
|
|
142
|
+
const { verbs } = p;
|
|
142
143
|
const context = React.useContext(ViewsContext);
|
|
143
144
|
const say = context?.messages ?? resolveViewsMessage;
|
|
144
145
|
const AppIcon = context?.components.AppIcon;
|
|
145
|
-
const words = React.useMemo(() => ({ ...viewsListWordsOf(say, props.createLabel), back: say({ key: "views.panels.back" }) }), [say, props.createLabel]);
|
|
146
146
|
const menuWords = React.useMemo(() => viewMenuWordsOf(say), [say]);
|
|
147
|
-
const
|
|
147
|
+
const icons = [...new Set(p.views.flatMap((v) => (v.icon ? [v.icon] : [])))];
|
|
148
148
|
const layouts = [
|
|
149
149
|
...verbs.layouts.map((l) => ({ id: l.id, name: l.name, line: l.line, ...(l.columns ? { columns: true } : {}), mark: AppIcon ? _jsx(AppIcon, { name: l.icon }) : null })),
|
|
150
|
-
...
|
|
150
|
+
...(AppIcon ? icons.filter((icon) => !verbs.layouts.some((v) => v.id === icon)).map((icon) => ({ id: icon, name: icon, line: "", mark: _jsx(AppIcon, { name: icon }) })) : []),
|
|
151
151
|
];
|
|
152
|
-
const views =
|
|
152
|
+
const views = p.views.map((v) => ({
|
|
153
153
|
id: v.value, name: v.label, layout: v.layout ?? v.icon ?? "",
|
|
154
154
|
...(v.private ? { private: true } : {}), ...(v.favorite ? { favorite: true } : {}), ...(v.changed ? { changed: true } : {}),
|
|
155
|
-
...(typeof v.count === "number" ? { count: v.count } : {}),
|
|
155
|
+
...(v.readOnly ? { readOnly: true } : {}), ...(typeof v.count === "number" ? { count: v.count } : {}),
|
|
156
156
|
}));
|
|
157
157
|
const ports = context?.ports;
|
|
158
|
-
const computer = props.form === "computer";
|
|
159
158
|
const menu = useViewMenu({
|
|
160
|
-
views, open:
|
|
159
|
+
views, open: p.value, layouts,
|
|
161
160
|
...(verbs.columns ? { columns: { fields: verbs.columns.fields.map((f) => ({ value: f.value, label: f.label })), value: verbs.columns.value } } : {}),
|
|
162
161
|
records: verbs.records,
|
|
163
162
|
onChange: (c) => {
|
|
164
|
-
if (c.kind === "open")
|
|
165
|
-
|
|
166
|
-
else if (c.kind === "order") {
|
|
167
|
-
const block = orderToWrite(props.views, c.ids, props.canDrag);
|
|
168
|
-
if (block)
|
|
169
|
-
props.onReorder?.(block);
|
|
170
|
-
}
|
|
163
|
+
if (c.kind === "open" || c.kind === "order")
|
|
164
|
+
p.onListChange?.(c);
|
|
171
165
|
else
|
|
172
166
|
verbs.onChange(c);
|
|
173
167
|
},
|
|
174
|
-
onDone:
|
|
175
|
-
...(
|
|
176
|
-
|
|
168
|
+
...(p.onDone ? { onDone: p.onDone } : {}), ...(p.shows ? { shows: p.shows } : {}), form: p.form, ...(p.steps ? { steps: true } : {}), words: menuWords,
|
|
169
|
+
...(verbs.menu ? { reshape: (items, id) => {
|
|
170
|
+
const view = p.views.find((v) => v.value === id);
|
|
171
|
+
return view && verbs.menu ? verbs.menu(items, { view }) : items;
|
|
172
|
+
} } : {}),
|
|
173
|
+
...(p.form === "computer" && ports && !context.confirmFallback ? { ask: async (request) => {
|
|
174
|
+
p.onHold?.(true);
|
|
177
175
|
try {
|
|
178
176
|
return await ports.confirm(request);
|
|
179
177
|
}
|
|
180
178
|
finally {
|
|
181
|
-
requestAnimationFrame(() =>
|
|
179
|
+
requestAnimationFrame(() => p.onHold?.(false));
|
|
182
180
|
}
|
|
183
181
|
} } : {}),
|
|
184
182
|
...(ports && !context.toastFallback ? { report: (message, options) => ports.toast.success(message, options) } : {}),
|
|
185
183
|
});
|
|
186
|
-
|
|
184
|
+
return { ...menu, views, layouts };
|
|
185
|
+
}
|
|
186
|
+
function WithVerbs(props) {
|
|
187
|
+
const context = React.useContext(ViewsContext);
|
|
188
|
+
const say = context?.messages ?? resolveViewsMessage;
|
|
189
|
+
const words = React.useMemo(() => ({ ...viewsListWordsOf(say, props.createLabel), back: say({ key: "views.panels.back" }) }), [say, props.createLabel]);
|
|
190
|
+
const base = viewsListPropsOf(props, words, say({ key: "views.menus.not-now" }), context?.components.AppIcon);
|
|
191
|
+
const menu = useVerbsMenu({
|
|
192
|
+
views: props.views, value: props.value, verbs: props.verbs, form: props.form, steps: true,
|
|
193
|
+
onListChange: (c) => {
|
|
194
|
+
if (c.kind === "open")
|
|
195
|
+
props.onViewChange(c.id);
|
|
196
|
+
else {
|
|
197
|
+
const block = orderToWrite(props.views, c.ids, props.canDrag);
|
|
198
|
+
if (block)
|
|
199
|
+
props.onReorder?.(block);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
onDone: props.onDone, ...(props.onHold ? { onHold: props.onHold } : {}),
|
|
203
|
+
});
|
|
204
|
+
const list = useViewsList({ ...base, layouts: menu.layouts, views: menu.views, entries: menu.entries, ...(props.onCreate ? { onNew: () => menu.startNew() } : {}), onMenu: menu.openMenu, step: menu.step });
|
|
187
205
|
const head = useStepHead(menu.step, props);
|
|
188
206
|
return _jsxs(_Fragment, { children: [head, list.body, menu.dialogs] });
|
|
189
207
|
}
|
|
@@ -8,6 +8,8 @@ export interface ListView {
|
|
|
8
8
|
favorite?: boolean;
|
|
9
9
|
changed?: boolean;
|
|
10
10
|
count?: number;
|
|
11
|
+
/** A view this reader can't change: no Rename, Delete, Private view or Save in its menu; Reset, Save as new view, Copy link and Duplicate stay. */
|
|
12
|
+
readOnly?: boolean;
|
|
11
13
|
}
|
|
12
14
|
/** A layout a new view can take: its mark, its name, its one line; `columns` where it asks which field makes its columns (a board). */
|
|
13
15
|
export interface ViewsListLayout {
|