viewkitjs 0.28.0 → 0.29.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 +107 -0
- package/MIGRATION.md +85 -4
- package/fields/dist/derived.d.ts +2 -1
- package/fields/dist/derived.js +9 -3
- package/fields/dist/entities.js +41 -3
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/messages.d.ts +8 -2
- package/fields/dist/messages.js +3 -0
- package/fields/dist/range.d.ts +6 -0
- package/fields/dist/range.js +8 -0
- package/fields/dist/registry.js +11 -1
- package/fields/dist/spec-changes.js +1 -0
- package/fields/dist/types.d.ts +23 -1
- package/fields/docs/guides/derived-fields.md +7 -5
- package/fields/docs/guides/field-types.md +2 -2
- package/fields/docs/guides/the-index.md +1 -1
- package/fields/docs/reference/fields.md +3 -1
- package/fields/docs/reference/types.md +3 -1
- package/fields/skills/viewkit/SKILL.md +1 -1
- package/package.json +2 -1
- package/postgres/dist/definitions/build.js +29 -5
- package/postgres/dist/definitions/label.d.ts +7 -0
- package/postgres/dist/definitions/label.js +9 -1
- package/postgres/dist/definitions/lookup.js +6 -2
- package/postgres/dist/definitions/place.d.ts +6 -3
- package/postgres/dist/definitions/rollup.js +5 -1
- package/postgres/dist/definitions/storage.d.ts +15 -0
- package/postgres/dist/definitions/storage.js +52 -1
- package/postgres/dist/definitions/stored.js +21 -0
- package/postgres/dist/phone.d.ts +13 -1
- package/postgres/dist/phone.js +23 -3
- package/postgres/dist/search-indexes.d.ts +6 -1
- package/postgres/dist/search-indexes.js +71 -25
- package/postgres/dist/search.js +3 -3
- package/postgres/docs/guides/definitions.md +22 -5
- package/postgres/docs/guides/field-map.md +5 -4
- package/postgres/docs/reference/definitions.md +3 -3
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/cells/cell-format.js +2 -2
- package/views/dist/cells/cell-values.js +9 -10
- package/views/dist/contract.d.ts +149 -3
- package/views/dist/contract.js +157 -1
- package/views/dist/controls/bulk-bar/bulk-bar-of.d.ts +66 -0
- package/views/dist/controls/bulk-bar/bulk-bar-of.js +22 -0
- package/views/dist/controls/bulk-bar/bulk-bar.d.ts +40 -0
- package/views/dist/controls/bulk-bar/bulk-bar.js +278 -0
- package/views/dist/controls/bulk-bar/looks.d.ts +10 -0
- package/views/dist/controls/bulk-bar/looks.js +14 -0
- package/views/dist/controls/bulk-bar/map-selection-bar.d.ts +19 -0
- package/views/dist/controls/bulk-bar/map-selection-bar.js +57 -0
- package/views/dist/controls/bulk-bar/tokens.d.ts +136 -0
- package/views/dist/controls/bulk-bar/tokens.js +36 -0
- package/views/dist/controls/bulk-bar/words.d.ts +50 -0
- package/views/dist/controls/bulk-bar/words.js +19 -0
- package/views/dist/controls/bulk-bar.css +96 -0
- package/views/dist/controls/button/button.js +3 -1
- package/views/dist/controls/button.css +5 -4
- package/views/dist/controls/checkbox/checkbox.js +3 -1
- package/views/dist/controls/checkbox.css +1 -1
- package/views/dist/controls/choice/tokens.d.ts +79 -0
- package/views/dist/controls/choice/tokens.js +22 -0
- package/views/dist/controls/choice.css +31 -0
- package/views/dist/controls/compound-editor/looks.js +1 -1
- package/views/dist/controls/controls.d.ts +10 -0
- package/views/dist/controls/controls.js +8 -0
- package/views/dist/controls/customize/customize.d.ts +125 -0
- package/views/dist/controls/customize/customize.js +243 -0
- package/views/dist/controls/customize/glide.d.ts +10 -0
- package/views/dist/controls/customize/glide.js +55 -0
- package/views/dist/controls/customize/looks.d.ts +13 -0
- package/views/dist/controls/customize/looks.js +11 -0
- package/views/dist/controls/customize/map-customize-body.d.ts +18 -0
- package/views/dist/controls/customize/map-customize-body.js +160 -0
- package/views/dist/controls/customize/rules.d.ts +23 -0
- package/views/dist/controls/customize/rules.js +19 -0
- package/views/dist/controls/customize/tokens.d.ts +40 -0
- package/views/dist/controls/customize/tokens.js +12 -0
- package/views/dist/controls/customize/words.d.ts +58 -0
- package/views/dist/controls/customize/words.js +37 -0
- package/views/dist/controls/customize.css +54 -0
- package/views/dist/controls/date-editor/looks.js +1 -1
- package/views/dist/controls/filter-editor/block.d.ts +31 -0
- package/views/dist/controls/filter-editor/block.js +27 -0
- package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +85 -43
- package/views/dist/controls/filter-editor/how.d.ts +1 -1
- package/views/dist/controls/filter-editor/how.js +1 -0
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +16 -1
- package/views/dist/controls/filter-editor/map-filter-body.js +39 -13
- package/views/dist/controls/filter-editor/map-rules.d.ts +27 -11
- package/views/dist/controls/filter-editor/map-rules.js +73 -42
- package/views/dist/controls/filter-editor/rules.d.ts +43 -5
- package/views/dist/controls/filter-editor/rules.js +55 -2
- package/views/dist/controls/filter-editor/words.d.ts +15 -0
- package/views/dist/controls/filter-editor/words.js +6 -0
- package/views/dist/controls/filter-editor.css +18 -0
- package/views/dist/controls/index.d.ts +26 -2
- package/views/dist/controls/index.js +25 -2
- package/views/dist/controls/inline-input/looks.js +1 -1
- package/views/dist/controls/input/input.js +10 -4
- package/views/dist/controls/internal/phone.d.ts +5 -4
- package/views/dist/controls/internal/phone.js +7 -7
- package/views/dist/controls/internal/scroll.js +5 -1
- package/views/dist/controls/internal/typed-run.d.ts +2 -0
- package/views/dist/controls/internal/typed-run.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/number-editor/looks.js +1 -1
- package/views/dist/controls/option/option.js +3 -1
- package/views/dist/controls/option.css +1 -1
- package/views/dist/controls/pane/pane.d.ts +4 -0
- package/views/dist/controls/pane/pane.js +2 -1
- package/views/dist/controls/picker/looks.js +1 -1
- package/views/dist/controls/picker/map-picker.d.ts +6 -2
- package/views/dist/controls/picker/map-picker.js +4 -2
- package/views/dist/controls/picker/picker.d.ts +7 -0
- package/views/dist/controls/picker/picker.js +57 -8
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +2 -2
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/popover.css +3 -0
- package/views/dist/controls/ports-host/map-ports-host.d.ts +7 -0
- package/views/dist/controls/ports-host/map-ports-host.js +43 -0
- package/views/dist/controls/press/tokens.d.ts +8 -0
- package/views/dist/controls/press/tokens.js +4 -0
- package/views/dist/controls/press.css +44 -0
- package/views/dist/controls/quick-filters/looks.d.ts +11 -0
- package/views/dist/controls/quick-filters/looks.js +9 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +31 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +56 -0
- package/views/dist/controls/quick-filters/quick-filters.d.ts +37 -0
- package/views/dist/controls/quick-filters/quick-filters.js +89 -0
- package/views/dist/controls/quick-filters/reminder.d.ts +18 -0
- package/views/dist/controls/quick-filters/reminder.js +41 -0
- package/views/dist/controls/quick-filters/rules.d.ts +89 -0
- package/views/dist/controls/quick-filters/rules.js +52 -0
- package/views/dist/controls/quick-filters/tokens.d.ts +112 -0
- package/views/dist/controls/quick-filters/tokens.js +30 -0
- package/views/dist/controls/quick-filters/words.d.ts +25 -0
- package/views/dist/controls/quick-filters/words.js +13 -0
- package/views/dist/controls/quick-filters.css +118 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +9 -4
- package/views/dist/controls/sheet/bottom-sheet.js +4 -4
- package/views/dist/controls/sheet/map-sheet.d.ts +4 -1
- package/views/dist/controls/sheet/map-sheet.js +19 -6
- package/views/dist/controls/sheet/sheet-parts.d.ts +10 -0
- package/views/dist/controls/sheet/sheet-parts.js +2 -0
- package/views/dist/controls/switch-row/switch-row.d.ts +15 -0
- package/views/dist/controls/switch-row/switch-row.js +9 -0
- package/views/dist/controls/switch-row/tokens.d.ts +51 -0
- package/views/dist/controls/switch-row/tokens.js +15 -0
- package/views/dist/controls/switch-row.css +39 -0
- package/views/dist/controls/switch.css +1 -1
- package/views/dist/controls/tag/tag.js +3 -1
- package/views/dist/controls/tag-field/tag-field.d.ts +20 -0
- package/views/dist/controls/tag-field/tag-field.js +19 -0
- package/views/dist/controls/tag-field/tokens.d.ts +7 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +13 -0
- package/views/dist/controls/text-editor/looks.js +1 -1
- package/views/dist/controls/text-editor/text-editor.js +1 -5
- package/views/dist/controls/toast/toast.d.ts +5 -1
- package/views/dist/controls/toast/toast.js +5 -3
- package/views/dist/controls/tokens.js +18 -0
- package/views/dist/controls/toolbar/keys.d.ts +3 -0
- package/views/dist/controls/toolbar/keys.js +11 -0
- package/views/dist/controls/toolbar/looks.d.ts +10 -0
- package/views/dist/controls/toolbar/looks.js +40 -0
- package/views/dist/controls/toolbar/tokens.d.ts +28 -0
- package/views/dist/controls/toolbar/tokens.js +9 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +111 -0
- package/views/dist/controls/toolbar/toolbar.js +370 -0
- package/views/dist/controls/toolbar/words.d.ts +28 -0
- package/views/dist/controls/toolbar/words.js +17 -0
- package/views/dist/controls/toolbar-button/looks.d.ts +4 -0
- package/views/dist/controls/toolbar-button/looks.js +21 -0
- package/views/dist/controls/toolbar-button/tokens.d.ts +103 -0
- package/views/dist/controls/toolbar-button/tokens.js +28 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +66 -0
- package/views/dist/controls/toolbar-button/toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button.css +75 -0
- package/views/dist/controls/toolbar.css +65 -0
- package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
- package/views/dist/controls/tooltip/map-tooltip.js +2 -2
- package/views/dist/controls/tooltip/tooltip.d.ts +3 -1
- package/views/dist/controls/tooltip/tooltip.js +2 -2
- package/views/dist/controls/values-editor/looks.js +1 -1
- package/views/dist/controls/views-list/map-views-list-body.d.ts +4 -1
- package/views/dist/controls/views-list/map-views-list-body.js +128 -4
- package/views/dist/controls/views-list/rules.d.ts +26 -0
- package/views/dist/controls/views-list/rules.js +63 -0
- package/views/dist/controls/views-list/view-menu.d.ts +84 -0
- package/views/dist/controls/views-list/view-menu.js +201 -0
- package/views/dist/controls/views-list/views-list.d.ts +8 -1
- package/views/dist/controls/views-list/views-list.js +18 -3
- package/views/dist/controls/views-list/words.d.ts +54 -0
- package/views/dist/controls/views-list/words.js +10 -1
- package/views/dist/controls/views-list.css +5 -1
- package/views/dist/display/date.js +3 -3
- package/views/dist/display/format.d.ts +6 -0
- package/views/dist/display/format.js +3 -0
- package/views/dist/display/index.d.ts +1 -1
- package/views/dist/display/index.js +1 -1
- package/views/dist/display/range.d.ts +2 -1
- package/views/dist/display/range.js +4 -1
- package/views/dist/grid/chrome/GridHeader.js +2 -1
- package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +2 -1
- package/views/dist/grid/chrome/GridTextEditor.js +2 -2
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +5 -1
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +7 -1
- package/views/dist/grid/chrome/grid-fitted-box.js +4 -4
- package/views/dist/grid/core/clipboard-model.js +9 -4
- package/views/dist/grid/grid.css +240 -0
- package/views/dist/grid/looks.d.ts +5 -1
- package/views/dist/grid/looks.js +20 -12
- package/views/dist/grid-tokens.d.ts +109 -0
- package/views/dist/grid-tokens.js +29 -0
- package/views/dist/looks/index.d.ts +5 -0
- package/views/dist/looks/index.js +5 -0
- package/views/dist/looks/pieces.js +10 -0
- package/views/dist/model/column-capabilities.d.ts +2 -0
- package/views/dist/model/column-filters.d.ts +2 -1
- package/views/dist/model/column-from.js +2 -2
- package/views/dist/model/relation-filters.d.ts +2 -0
- package/views/dist/panels/index.d.ts +2 -2
- package/views/dist/panels/index.js +2 -2
- package/views/dist/panels/labels.d.ts +4 -0
- package/views/dist/panels/labels.js +8 -0
- package/views/dist/panels/model.d.ts +10 -2
- package/views/dist/panels/quick/model.d.ts +4 -0
- package/views/dist/panels/react/customize-body.d.ts +9 -4
- package/views/dist/panels/react/customize-body.js +39 -11
- package/views/dist/panels/react/customize.d.ts +8 -1
- package/views/dist/panels/react/customize.js +9 -6
- package/views/dist/panels/react/filter/FilterEditor.js +4 -4
- package/views/dist/panels/react/filter/FilterFieldList.js +10 -2
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +3 -3
- package/views/dist/panels/react/filter/filter-body.js +5 -2
- package/views/dist/panels/react/panel-step.d.ts +3 -0
- package/views/dist/panels/react/panel-step.js +2 -1
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -3
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +10 -3
- package/views/dist/panels/react/toolbar/Toolbar.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +13 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +3 -3
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +12 -4
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -2
- package/views/dist/panels/react/view-footer.d.ts +1 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +25 -4
- package/views/dist/panels/settings/filter-groups.d.ts +3 -0
- package/views/dist/panels/settings/filter-groups.js +40 -9
- package/views/dist/panels/settings/filters.d.ts +5 -0
- package/views/dist/panels/settings/filters.js +12 -6
- package/views/dist/panels/views-row/model.d.ts +10 -1
- package/views/dist/provider/ViewsProvider.js +29 -5
- package/views/dist/provider/components.d.ts +149 -8
- package/views/dist/provider/context.d.ts +6 -0
- package/views/dist/provider/ports.d.ts +18 -6
- package/views/dist/provider/ports.js +2 -1
- package/views/dist/react.d.ts +2 -2
- package/views/dist/react.js +1 -1
- package/views/dist/selection/SelectionBar.d.ts +2 -16
- package/views/dist/selection/SelectionBar.js +4 -1
- package/views/dist/selection/bar-props.d.ts +26 -0
- package/views/dist/selection/bar-props.js +1 -0
- package/views/dist/selection/index.d.ts +1 -1
- package/views/dist/selection/verbs.d.ts +32 -5
- package/views/dist/styles.css +656 -25
- package/views/dist/styles.unlayered.css +653 -22
- package/views/docs/contract.md +44 -17
- package/views/docs/controls/bulk-bar.md +41 -0
- package/views/docs/controls/choice.md +25 -0
- package/views/docs/controls/customize.md +17 -0
- package/views/docs/controls/popover.md +2 -0
- package/views/docs/controls/press.md +9 -0
- package/views/docs/controls/quick-filters.md +35 -0
- package/views/docs/controls/radio.md +1 -1
- package/views/docs/controls/switch-row.md +18 -0
- package/views/docs/controls/tag-field.md +7 -0
- package/views/docs/controls/toolbar-button.md +31 -0
- package/views/docs/controls/toolbar.md +14 -0
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/cells.md +2 -2
- package/views/docs/guides/display.md +2 -2
- package/views/docs/guides/looks.md +8 -2
- package/views/docs/guides/ports.md +6 -6
- package/views/docs/guides/selection.md +5 -1
- package/views/docs/guides/the-grid.md +1 -1
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/install.md +4 -1
- package/views/docs/reference/cells.md +1 -1
- package/views/docs/reference/controls.md +194 -13
- package/views/docs/reference/display.md +1 -0
- package/views/docs/reference/looks.md +25 -11
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/panels.md +8 -6
- package/views/docs/reference/react.md +13 -6
- package/views/docs/reference/selection.md +4 -2
- package/views/docs/reference/views.md +7 -6
- package/views/skills/views/SKILL.md +2 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type PickerItem } from "../picker/picker.js";
|
|
3
|
+
import { type BulkNoun, type BulkRun, type BulkVerbItemOf, type BulkVerbOf } from "./bulk-bar-of.js";
|
|
4
|
+
import { type BulkBarPicks } from "./looks.js";
|
|
5
|
+
import { type BulkBarWords } from "./words.js";
|
|
6
|
+
export type { BulkDone, BulkNoun, BulkRun } from "./bulk-bar-of.js";
|
|
7
|
+
export type BulkVerb = BulkVerbOf<React.ReactNode, PickerItem>;
|
|
8
|
+
export type BulkVerbItem = BulkVerbItemOf<React.ReactNode>;
|
|
9
|
+
export interface BulkBarProps {
|
|
10
|
+
/** How many rows are picked; at 0 it leaves. */
|
|
11
|
+
count: number;
|
|
12
|
+
/** What a row is, one and many ("deal", "deals"): its words ("3 deals selected", "Delete 3 deals"). Left out, `words.noun`. */
|
|
13
|
+
noun?: BulkNoun;
|
|
14
|
+
/** Clears the selection: the count, Escape, and after Delete. */
|
|
15
|
+
onClear: () => void;
|
|
16
|
+
/** What can be done to every picked row, in order: on the bar, the rest (`more`) in More. */
|
|
17
|
+
verbs: readonly BulkVerb[];
|
|
18
|
+
/** Deletes the picked rows, after the Alert Dialog asks; left out, no Delete. */
|
|
19
|
+
onDelete?: BulkRun;
|
|
20
|
+
/** The Alert's line under "Delete 3 deals?" ("They move to the trash. You can bring them back for 30 days."). */
|
|
21
|
+
deleteLine?: React.ReactNode;
|
|
22
|
+
/** Delete's name, in place of "Delete 3 deals". */
|
|
23
|
+
deleteLabel?: string;
|
|
24
|
+
/** A batch is running: every control can't be used until it ends. */
|
|
25
|
+
busy?: boolean;
|
|
26
|
+
/** Which form of the bar itself; by default the phone's in a phone's window or a PhoneHost screen, else the computer's. What it
|
|
27
|
+
* opens (its Menus, its question) takes its own form from the window or the screen, as every popup of the kit does. */
|
|
28
|
+
form?: "computer" | "phone";
|
|
29
|
+
/** It stands on a page that shows it (a component's page): what it opens leaves the page round it live, as the Menu's standing
|
|
30
|
+
* does, and its Picker's Popover takes no focus as it opens. In an app what it opens is modal. */
|
|
31
|
+
standing?: boolean;
|
|
32
|
+
className?: string;
|
|
33
|
+
/** Its words, over the English. */
|
|
34
|
+
words?: Partial<BulkBarWords>;
|
|
35
|
+
}
|
|
36
|
+
type Worn = BulkBarPicks;
|
|
37
|
+
/** The bar's options as the frame round `el` picks them, kept up to date as they change. */
|
|
38
|
+
export declare function useBulkBarWorn(el: Element | null): Worn;
|
|
39
|
+
/** What picked rows bring: how many are picked, and what can be done to all of them at once. */
|
|
40
|
+
export declare function BulkBar({ count, noun: given, onClear, verbs, onDelete, deleteLine, deleteLabel, busy, form, standing, className, words: said }: BulkBarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
4
|
+
import { cx as cn } from "../../internal/cx.js";
|
|
5
|
+
import { AlertDialog } from "../alert-dialog/alert-dialog.js";
|
|
6
|
+
import { Avatar } from "../avatar/avatar.js";
|
|
7
|
+
import { Button } from "../button/button.js";
|
|
8
|
+
import { Menu } from "../menu/menu.js";
|
|
9
|
+
import { Picker, usePicker } from "../picker/picker.js";
|
|
10
|
+
import { Popover } from "../popover/popover.js";
|
|
11
|
+
import { Sheet, SheetBody, SheetHead } from "../sheet/bottom-sheet.js";
|
|
12
|
+
import { StatusGlyph } from "../status/status.js";
|
|
13
|
+
import { Toast, createToastManager } from "../toast/toast.js";
|
|
14
|
+
import { ToolbarControl, ToolbarSeparatorControl } from "../toolbar/toolbar.js";
|
|
15
|
+
import { Icon } from "../internal/icons.js";
|
|
16
|
+
import { PhoneHost, usePhone } from "../internal/phone.js";
|
|
17
|
+
import { spacingPx } from "../internal/read-token.js";
|
|
18
|
+
import { fitOnBar, moreRows, wordsOf } from "./bulk-bar-of.js";
|
|
19
|
+
import { BULK_BAR_ATTRS, bulkBarWornOf } from "./looks.js";
|
|
20
|
+
import { bulkBarWords } from "./words.js";
|
|
21
|
+
const DEF = bulkBarWornOf(null);
|
|
22
|
+
const same = (a, b) => Object.keys(a).every((k) => a[k] === b[k]);
|
|
23
|
+
export function useBulkBarWorn(el) {
|
|
24
|
+
const [worn, setWorn] = React.useState(DEF);
|
|
25
|
+
React.useLayoutEffect(() => {
|
|
26
|
+
const read = () => setWorn((was) => { const now = bulkBarWornOf(el); return same(was, now) ? was : now; });
|
|
27
|
+
read();
|
|
28
|
+
const watch = new MutationObserver(read);
|
|
29
|
+
watch.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: BULK_BAR_ATTRS });
|
|
30
|
+
return () => watch.disconnect();
|
|
31
|
+
}, [el]);
|
|
32
|
+
return worn;
|
|
33
|
+
}
|
|
34
|
+
const up = (_jsx("svg", { viewBox: "0 0 24 24", width: "15", height: "15", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M6 15l6 -6l6 6" }) }));
|
|
35
|
+
function markOf(as, label) {
|
|
36
|
+
if (!as)
|
|
37
|
+
return undefined;
|
|
38
|
+
if ("avatar" in as)
|
|
39
|
+
return _jsx(Avatar, { name: label, kind: as.avatar === "company" ? "thing" : "person", id: as.id, src: as.src, size: 20 });
|
|
40
|
+
if ("status" in as)
|
|
41
|
+
return _jsx(StatusGlyph, { place: as.status, quarters: as.quarters });
|
|
42
|
+
if ("mark" in as)
|
|
43
|
+
return as.mark;
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const EMPTY = "\u0000empty", DIFFER = "\u0000differ";
|
|
47
|
+
export function BulkBar({ count, noun: given, onClear, verbs, onDelete, deleteLine, deleteLabel, busy = false, form, standing = false, className, words: said }) {
|
|
48
|
+
const w = React.useMemo(() => bulkBarWords(said), [said]);
|
|
49
|
+
const noun = given ?? w.noun;
|
|
50
|
+
const host = React.useContext(PhoneHost), narrow = usePhone();
|
|
51
|
+
const phone = form ? form === "phone" : host != null || narrow;
|
|
52
|
+
const [root, setRoot] = React.useState(null);
|
|
53
|
+
const worn = useBulkBarWorn(root);
|
|
54
|
+
const shape = !phone ? "computer" : worn.phone === "pill" ? "pill" : "tray";
|
|
55
|
+
const last = React.useRef(count);
|
|
56
|
+
if (count > 0)
|
|
57
|
+
last.current = count;
|
|
58
|
+
const shown = count > 0, counted = wordsOf(last.current, noun, w), words = deleteLabel ? { ...counted, del: deleteLabel } : counted;
|
|
59
|
+
const onBar = verbs.filter((v) => !v.more), kept = verbs.filter((v) => v.more);
|
|
60
|
+
const delOwn = !phone && !!onDelete && worn.delete === "own";
|
|
61
|
+
const delInMore = !phone && !!onDelete && !delOwn;
|
|
62
|
+
const [measure, setMeasure] = React.useState(null);
|
|
63
|
+
const [fitted, setFitted] = React.useState(onBar.length);
|
|
64
|
+
const moreAnyway = kept.length > 0 || delInMore;
|
|
65
|
+
React.useLayoutEffect(() => {
|
|
66
|
+
if (!root || !measure || shape === "pill")
|
|
67
|
+
return;
|
|
68
|
+
const holder = root.parentElement;
|
|
69
|
+
if (!holder)
|
|
70
|
+
return;
|
|
71
|
+
const fit = () => {
|
|
72
|
+
const of = (m) => [...measure.querySelectorAll(`[data-m="${m}"]`)].map((el) => el.getBoundingClientRect().width);
|
|
73
|
+
const gap = parseFloat(getComputedStyle(measure).columnGap) || 0, cs = getComputedStyle(root);
|
|
74
|
+
const sides = parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight) + parseFloat(cs.borderLeftWidth) + parseFloat(cs.borderRightWidth);
|
|
75
|
+
const box = root.offsetParent ?? holder;
|
|
76
|
+
const room = box.clientWidth - spacingPx(8, root) - sides;
|
|
77
|
+
const fixedParts = [...of("count"), ...of("sep"), ...of("del")];
|
|
78
|
+
const fixed = fixedParts.reduce((a, w) => a + w, 0) + Math.max(0, fixedParts.length - 1) * gap;
|
|
79
|
+
const widths = of("verb");
|
|
80
|
+
if (!widths.length || widths.every((w) => w === 0))
|
|
81
|
+
return;
|
|
82
|
+
setFitted(fitOnBar(widths, room, fixed, of("more")[0] ?? 0, gap, shape === "computer" ? moreAnyway : kept.length > 0));
|
|
83
|
+
};
|
|
84
|
+
fit();
|
|
85
|
+
const sized = new ResizeObserver(fit);
|
|
86
|
+
sized.observe(holder);
|
|
87
|
+
sized.observe(measure);
|
|
88
|
+
return () => sized.disconnect();
|
|
89
|
+
}, [root, measure, shape, moreAnyway, kept.length, onBar.length, shown]);
|
|
90
|
+
const fits = onBar.slice(0, fitted), folded = onBar.length - fits.length;
|
|
91
|
+
const [opened, setOpened] = React.useState(null);
|
|
92
|
+
const shut = React.useRef(null);
|
|
93
|
+
const close = (reason) => {
|
|
94
|
+
if (opened && reason === "outside-press")
|
|
95
|
+
shut.current = { what: opened.what, t: performance.now() };
|
|
96
|
+
setOpened(null);
|
|
97
|
+
};
|
|
98
|
+
const open = (what) => (e) => {
|
|
99
|
+
const at = e.currentTarget, s = shut.current;
|
|
100
|
+
if (s && s.what === what && performance.now() - s.t < 400) {
|
|
101
|
+
shut.current = null;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
setOpened((o) => (o && o.what === what ? null : { what, at }));
|
|
105
|
+
};
|
|
106
|
+
const undoWord = w.toast?.undo, closeWord = w.toast?.close;
|
|
107
|
+
const toasts = React.useMemo(() => createToastManager({ ...(undoWord ? { undo: undoWord } : {}), ...(closeWord ? { close: closeWord } : {}) }), [undoWord, closeWord]);
|
|
108
|
+
const after = React.useCallback(async (run) => {
|
|
109
|
+
let done;
|
|
110
|
+
try {
|
|
111
|
+
done = await run();
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
toasts.show({ words: w.failed, failed: true });
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (done)
|
|
118
|
+
toasts.show({ words: done.words, undo: done.undo });
|
|
119
|
+
}, [toasts, w.failed]);
|
|
120
|
+
const [asking, setAsking] = React.useState(false);
|
|
121
|
+
const deleted = React.useRef(null);
|
|
122
|
+
const ask = () => { setOpened(null); setAsking(true); };
|
|
123
|
+
if (!shown && (opened != null || asking)) {
|
|
124
|
+
setOpened(null);
|
|
125
|
+
setAsking(false);
|
|
126
|
+
}
|
|
127
|
+
const quiet = opened != null || asking;
|
|
128
|
+
React.useEffect(() => {
|
|
129
|
+
const holder = root?.parentElement;
|
|
130
|
+
if (!holder || !shown || quiet || busy)
|
|
131
|
+
return;
|
|
132
|
+
const key = (e) => {
|
|
133
|
+
if (e.key !== "Escape" || e.defaultPrevented)
|
|
134
|
+
return;
|
|
135
|
+
if (e.target?.closest?.("input, textarea, [contenteditable]"))
|
|
136
|
+
return;
|
|
137
|
+
onClear();
|
|
138
|
+
};
|
|
139
|
+
holder.addEventListener("keydown", key);
|
|
140
|
+
return () => holder.removeEventListener("keydown", key);
|
|
141
|
+
}, [root, shown, quiet, busy, onClear]);
|
|
142
|
+
const lastOutside = React.useRef(null);
|
|
143
|
+
React.useEffect(() => {
|
|
144
|
+
const holder = root?.parentElement;
|
|
145
|
+
if (!holder || !root)
|
|
146
|
+
return;
|
|
147
|
+
const seen = (e) => {
|
|
148
|
+
if (e.target instanceof HTMLElement && !root.contains(e.target) && !e.target.closest(".o-bulk-bar-toasts"))
|
|
149
|
+
lastOutside.current = e.target;
|
|
150
|
+
};
|
|
151
|
+
holder.addEventListener("focusin", seen);
|
|
152
|
+
return () => holder.removeEventListener("focusin", seen);
|
|
153
|
+
}, [root]);
|
|
154
|
+
const wasShown = React.useRef(shown), hadFocus = React.useRef(false);
|
|
155
|
+
if (wasShown.current && !shown && root && typeof document !== "undefined" && root.contains(document.activeElement))
|
|
156
|
+
hadFocus.current = true;
|
|
157
|
+
const giveBack = React.useCallback(() => {
|
|
158
|
+
if (!root)
|
|
159
|
+
return () => { };
|
|
160
|
+
let frame = 0, tries = 0;
|
|
161
|
+
const back = () => {
|
|
162
|
+
if (document.querySelector("[role='alertdialog']") && tries++ < 60) {
|
|
163
|
+
frame = requestAnimationFrame(back);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const now = document.activeElement;
|
|
167
|
+
if (now && now !== document.body && !root.contains(now))
|
|
168
|
+
return;
|
|
169
|
+
const to = lastOutside.current, holder = root.parentElement;
|
|
170
|
+
if (to?.isConnected && !to.closest("[inert]")) {
|
|
171
|
+
to.focus({ preventScroll: true });
|
|
172
|
+
if (document.activeElement === to)
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!holder)
|
|
176
|
+
return;
|
|
177
|
+
if (!holder.hasAttribute("tabindex"))
|
|
178
|
+
holder.tabIndex = -1;
|
|
179
|
+
holder.focus({ preventScroll: true });
|
|
180
|
+
};
|
|
181
|
+
frame = requestAnimationFrame(back);
|
|
182
|
+
return () => cancelAnimationFrame(frame);
|
|
183
|
+
}, [root]);
|
|
184
|
+
React.useEffect(() => {
|
|
185
|
+
const left = wasShown.current && !shown;
|
|
186
|
+
wasShown.current = shown;
|
|
187
|
+
if (!left || !root || !hadFocus.current)
|
|
188
|
+
return;
|
|
189
|
+
hadFocus.current = false;
|
|
190
|
+
return giveBack();
|
|
191
|
+
}, [shown, root, giveBack]);
|
|
192
|
+
const itemEntry = (i) => ({ icon: i.icon ?? null, label: i.label, danger: i.destructive, disabled: i.disabled ? i.disabledReason ?? w.cantUse : undefined,
|
|
193
|
+
onSelect: () => { void after(i.onClick); } });
|
|
194
|
+
const entryOf = (v) => {
|
|
195
|
+
if (v.disabled)
|
|
196
|
+
return { icon: v.icon ?? null, label: v.label, disabled: v.disabledReason ?? w.cantUse };
|
|
197
|
+
if (v.kind === "action")
|
|
198
|
+
return itemEntry(v);
|
|
199
|
+
if (v.kind === "group")
|
|
200
|
+
return { kind: "actions", icon: v.icon ?? null, label: v.label,
|
|
201
|
+
entries: v.items.map((i) => itemEntry(i.disabledReason == null && v.disabledReason ? { ...i, disabledReason: v.disabledReason } : i)) };
|
|
202
|
+
const choices = [...(v.empty ? [{ value: EMPTY, label: v.empty }] : []),
|
|
203
|
+
...v.options.map((o) => ({ value: o.value, label: o.label, mark: markOf(o.as, o.label) }))];
|
|
204
|
+
return { kind: "choices", icon: v.icon ?? null, label: v.label, value: v.value === undefined ? DIFFER : v.value === null ? EMPTY : v.value, choices,
|
|
205
|
+
onChoose: (value) => { void after(() => v.onSelect(value === EMPTY ? null : value)); } };
|
|
206
|
+
};
|
|
207
|
+
const trash = _jsx(Icon, { name: "trash" });
|
|
208
|
+
const delEntry = { icon: trash, label: words.del, danger: true, onSelect: ask };
|
|
209
|
+
const separator = { kind: "separator" };
|
|
210
|
+
const press = (v, i) => (e) => {
|
|
211
|
+
if (v.kind === "action") {
|
|
212
|
+
setOpened(null);
|
|
213
|
+
void after(v.onClick);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
open(i)(e);
|
|
217
|
+
};
|
|
218
|
+
const expanded = (v, i) => (v.kind === "action" ? {} : { "aria-haspopup": (v.kind === "group" ? "menu" : "dialog"), "aria-expanded": opened?.what === i });
|
|
219
|
+
const index = (v) => verbs.indexOf(v);
|
|
220
|
+
const toolbarItems = [];
|
|
221
|
+
const measured = [];
|
|
222
|
+
const outline = (v, size, key, extra) => (_jsx(Button, { kind: "outline", size: size, icon: v.icon, disabled: busy || v.disabled, onClick: press(v, index(v)), ...expanded(v, index(v)), ...extra, children: v.label }, key));
|
|
223
|
+
if (shape === "computer") {
|
|
224
|
+
const moreShown = kept.length > 0 || folded > 0 || delInMore;
|
|
225
|
+
toolbarItems.push(_jsxs(BaseToolbar.Button, { className: "o-bulk-bar-count", "aria-label": w.clear, disabled: busy, onClick: onClear, children: [_jsx("span", { className: "o-bulk-bar-number", children: last.current }), w.count, _jsx(Icon, { name: "x", size: 14 })] }, "count"), _jsx(ToolbarSeparatorControl, {}, "sep"), ...fits.map((v) => outline(v, "sm", `v-${index(v)}`)), ...(delOwn ? [_jsx(Button, { kind: "danger", shape: "icon", size: "sm", "aria-label": words.del, icon: trash, disabled: busy, onClick: ask }, "del")] : []), ...(moreShown ? [_jsx(Button, { kind: "outline", size: "sm", iconEnd: up, disabled: busy, "aria-haspopup": "menu", "aria-expanded": opened?.what === "more", onClick: open("more"), children: w.more }, "more")] : []));
|
|
226
|
+
measured.push(_jsxs("span", { "data-m": "count", className: "o-bulk-bar-count", children: [_jsx("span", { className: "o-bulk-bar-number", children: last.current }), w.count, _jsx(Icon, { name: "x", size: 14 })] }, "count"), _jsx("span", { "data-m": "sep", children: _jsx(ToolbarSeparatorControl, {}) }, "sep"), ...onBar.map((v) => _jsx(Button, { "data-m": "verb", kind: "outline", size: "sm", icon: v.icon, tabIndex: -1, children: v.label }, `v-${index(v)}`)), ...(delOwn ? [_jsx(Button, { "data-m": "del", kind: "danger", shape: "icon", size: "sm", "aria-label": words.del, icon: trash, tabIndex: -1 }, "del")] : []), _jsx(Button, { "data-m": "more", kind: "outline", size: "sm", iconEnd: up, tabIndex: -1, children: w.more }, "more"));
|
|
227
|
+
}
|
|
228
|
+
else if (shape === "tray") {
|
|
229
|
+
const moreShown = kept.length > 0 || folded > 0;
|
|
230
|
+
toolbarItems.push(...fits.map((v) => outline(v, "44", `v-${index(v)}`)), ...(onDelete ? [_jsx(Button, { kind: "outline", size: "44", icon: trash, disabled: busy, onClick: ask, children: w.delete }, "del")] : []), ...(moreShown ? [_jsx(Button, { kind: "outline", size: "44", shape: "icon", "aria-label": w.more, icon: _jsx(Icon, { name: "dots" }), disabled: busy, "aria-haspopup": "menu", "aria-expanded": opened?.what === "more", onClick: open("more") }, "more")] : []));
|
|
231
|
+
measured.push(...onBar.map((v) => _jsx(Button, { "data-m": "verb", kind: "outline", size: "44", icon: v.icon, tabIndex: -1, children: v.label }, `v-${index(v)}`)), ...(onDelete ? [_jsx(Button, { "data-m": "del", kind: "outline", size: "44", icon: trash, tabIndex: -1, children: w.delete }, "del")] : []), _jsx(Button, { "data-m": "more", kind: "outline", size: "44", shape: "icon", "aria-label": w.more, icon: _jsx(Icon, { name: "dots" }), tabIndex: -1 }, "more"));
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
toolbarItems.push(_jsxs("span", { className: "o-bulk-bar-words", children: [_jsx("b", { className: "o-bulk-bar-number", children: last.current }), ` ${w.pill}`] }, "count"), _jsx(Button, { kind: "quiet", shape: "icon", size: "44", "aria-label": w.clear, icon: _jsx(Icon, { name: "x", size: 18 }), disabled: busy, onClick: onClear }, "clear"), _jsx(ToolbarSeparatorControl, {}, "sep"), _jsx(Button, { kind: "quiet", size: "44", iconEnd: up, disabled: busy, "aria-haspopup": "menu", "aria-expanded": opened?.what === "more", onClick: open("more"), children: w.actions }, "actions"));
|
|
235
|
+
}
|
|
236
|
+
const now = opened == null ? null : opened.what === "more" ? "more" : verbs[opened.what];
|
|
237
|
+
const menuLabel = `${words.many}: ${now === "more" ? (shape === "pill" ? w.actions : w.more) : now?.label ?? ""}`;
|
|
238
|
+
const moreEntries = shape === "pill"
|
|
239
|
+
? [...verbs.map(entryOf), ...(onDelete ? [separator, delEntry] : [])]
|
|
240
|
+
: moreRows(onBar, kept, fitted, entryOf, delInMore ? delEntry : null, separator);
|
|
241
|
+
let popup = null;
|
|
242
|
+
if (opened && now === "more") {
|
|
243
|
+
popup = _jsx(Menu, { label: menuLabel, words: w.menu, anchor: opened.at, open: true, standing: standing, side: "top", align: "end", onOpenChange: (o, d) => { if (!o)
|
|
244
|
+
close(d.reason); }, entries: moreEntries }, "more");
|
|
245
|
+
}
|
|
246
|
+
else if (opened && now && now !== "more" && now.kind === "group") {
|
|
247
|
+
popup = _jsx(Menu, { label: menuLabel, words: w.menu, anchor: opened.at, open: true, standing: standing, side: "top", align: "start", onOpenChange: (o, d) => { if (!o)
|
|
248
|
+
close(d.reason); }, entries: now.items.map(itemEntry) }, `g-${opened.what}`);
|
|
249
|
+
}
|
|
250
|
+
else if (opened && now && now !== "more" && now.kind === "options") {
|
|
251
|
+
const v = now;
|
|
252
|
+
const set = (value) => { void after(() => v.onSelect(typeof value === "string" ? value : null)); };
|
|
253
|
+
const pick = (value) => { setOpened(null); set(value); };
|
|
254
|
+
popup = phone
|
|
255
|
+
? _jsx(FieldSheet, { verb: v, many: words.many, words: w, onPick: set, onClose: () => setOpened(null), container: host ?? undefined, standing: standing || !!host }, `f-${opened.what}`)
|
|
256
|
+
: (_jsx(Popover, { open: true, anchor: opened.at, side: "top", align: "start", ...(standing ? { initialFocus: false } : {}), sideOffset: spacingPx(1, opened.at), "aria-label": v.label, onOpenChange: (o, d) => { if (!o)
|
|
257
|
+
close(d.reason); }, style: { width: "fit-content", minWidth: "calc(var(--vk-spacing) * 48)" }, children: _jsx(Picker, { label: v.label, items: v.options, value: v.value ?? null, empty: v.empty, search: v.search, searchShown: !!v.search, form: "computer", ...(w.picker ? { words: w.picker } : {}), onValueChange: pick, onDone: () => setOpened(null) }) }, `f-${opened.what}`));
|
|
258
|
+
}
|
|
259
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: setRoot, className: cn("o-bulk-bar", className), "data-kit": "bulk-bar", "data-form": shape, "data-shown": shown ? "" : undefined, inert: !shown, children: [_jsx(ToolbarControl, { label: words.selected, size: "32", spacing: shape === "pill" ? 1 : shape === "tray" ? 2 : 1.5, fold: false, form: phone ? "phone" : "computer", children: toolbarItems }), measured.length > 0 && _jsx("div", { className: "o-bulk-bar-measure", "aria-hidden": "true", inert: true, children: _jsx("div", { ref: setMeasure, children: measured }) })] }), _jsx("div", { className: "o-bulk-bar-toasts", "data-form": shape, children: _jsx(Toast, { inside: true, manager: toasts, ...(w.toast ? { words: w.toast } : {}), children: null }) }), popup, onDelete && (_jsx(AlertDialog, { open: asking, title: words.ask, line: deleteLine, action: w.delete, cancel: w.cancel, kind: "danger", ...(w.dialog ? { words: w.dialog } : {}), run: async () => { deleted.current = (await onDelete()) ?? null; }, onAnswer: (yes) => {
|
|
260
|
+
setAsking(false);
|
|
261
|
+
if (!yes)
|
|
262
|
+
return;
|
|
263
|
+
onClear();
|
|
264
|
+
giveBack();
|
|
265
|
+
const done = deleted.current;
|
|
266
|
+
deleted.current = null;
|
|
267
|
+
if (done)
|
|
268
|
+
toasts.show({ words: done.words, undo: done.undo });
|
|
269
|
+
} }))] }));
|
|
270
|
+
}
|
|
271
|
+
function FieldSheet({ verb, many, words, onPick, onClose, container, standing }) {
|
|
272
|
+
const [open, setOpen] = React.useState(true);
|
|
273
|
+
const parts = usePicker({ label: verb.label, items: verb.options, value: verb.value ?? null, empty: verb.empty, search: verb.search, form: "phone", ...(words.picker ? { words: words.picker } : {}),
|
|
274
|
+
onValueChange: (v) => { setOpen(false); onPick(v); }, onDone: () => setOpen(false) });
|
|
275
|
+
return (_jsxs(Sheet, { open: open, onOpenChange: (o) => { if (!o)
|
|
276
|
+
setOpen(false); }, onOpenChangeComplete: (o) => { if (!o)
|
|
277
|
+
onClose(); }, label: verb.label, form: "full", container: container, standing: standing, children: [_jsx(SheetHead, { title: verb.label, description: many, ...parts.head, ...(words.sheet ? { words: words.sheet } : {}) }), _jsx(SheetBody, { children: parts.body })] }));
|
|
278
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PieceLooks } from "../../looks/looks.js";
|
|
2
|
+
export type BulkBarOptionId = "delete" | "phone" | "picked";
|
|
3
|
+
/** One value for every option. */
|
|
4
|
+
export type BulkBarPicks = Record<BulkBarOptionId, string>;
|
|
5
|
+
/** The bulk bar's options and look. */
|
|
6
|
+
export declare const BULK_BAR_LOOKS: PieceLooks<BulkBarOptionId>;
|
|
7
|
+
/** The options worn round `el`, each from the nearest frame that picks it; outside any frame, or a value it lacks, its default. */
|
|
8
|
+
export declare function bulkBarWornOf(el: Element | null): BulkBarPicks;
|
|
9
|
+
/** The attributes the bar watches, so an option changed while it stands reaches it. */
|
|
10
|
+
export declare const BULK_BAR_ATTRS: string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { lookWornOf } from "../../looks/looks.js";
|
|
2
|
+
const ATTIO = { delete: "more", phone: "tray", picked: "plain" };
|
|
3
|
+
const options = [
|
|
4
|
+
{ id: "delete", name: "Delete", def: ATTIO.delete, values: [{ id: "more", name: "In More" }, { id: "own", name: "Its own button" }] },
|
|
5
|
+
{ id: "phone", name: "Form", device: "phone", def: ATTIO.phone, values: [{ id: "tray", name: "Tray" }, { id: "pill", name: "Pill" }] },
|
|
6
|
+
{ id: "picked", name: "Picked rows", device: "phone", def: ATTIO.picked, values: [{ id: "plain", name: "Plain" }, { id: "ground", name: "On the selection's ground" }] },
|
|
7
|
+
];
|
|
8
|
+
const looks = [{ id: "attio", name: "Attio", picks: ATTIO }];
|
|
9
|
+
export const BULK_BAR_LOOKS = { id: "bulk-bar", name: "Bulk bar", options, looks };
|
|
10
|
+
const IDS = options.map((o) => o.id);
|
|
11
|
+
export function bulkBarWornOf(el) {
|
|
12
|
+
return lookWornOf(BULK_BAR_LOOKS, el, IDS);
|
|
13
|
+
}
|
|
14
|
+
export const BULK_BAR_ATTRS = IDS.map((id) => `data-bulk-bar-${id}`);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import { type ViewsMessageResolver } from "../../contract.js";
|
|
3
|
+
import type { ViewsSelectionBarProps } from "../../provider/components.js";
|
|
4
|
+
import type { SelectionRun, SelectionVerb } from "../../selection/verbs.js";
|
|
5
|
+
import { type BulkRun, type BulkVerb } from "./bulk-bar.js";
|
|
6
|
+
import type { BulkBarWords } from "./words.js";
|
|
7
|
+
/** The bar's words in the app's messages. */
|
|
8
|
+
export declare function bulkBarWordsOf(say: ViewsMessageResolver): BulkBarWords;
|
|
9
|
+
type AppIcon = ComponentType<{
|
|
10
|
+
name: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
}>;
|
|
13
|
+
/** An app's press as the bar's: what it hands back read by `doneOf`, at once or once its promise settles. */
|
|
14
|
+
export declare function runOf(press: SelectionRun): BulkRun;
|
|
15
|
+
/** ViewKit's verbs as the bar's: each press read by `runOf`, an options verb's values read as the Picker's rows (an option's glyph
|
|
16
|
+
* drawn by the app's `AppIcon`). */
|
|
17
|
+
export declare function bulkVerbsOf(verbs: readonly SelectionVerb[], AppIcon?: AppIcon): BulkVerb[];
|
|
18
|
+
export declare function MapSelectionBar({ count, noun, onClear, verbs, busy, onDelete, deleteLabel, deleteLine }: ViewsSelectionBarProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { resolveViewsMessage } from "../../contract.js";
|
|
5
|
+
import { ViewsContext } from "../../provider/context.js";
|
|
6
|
+
import { menuWordsOf, pickerItemsOf, pickerWordsOf } from "../picker/map-picker.js";
|
|
7
|
+
import { BulkBar } from "./bulk-bar.js";
|
|
8
|
+
export function bulkBarWordsOf(say) {
|
|
9
|
+
return {
|
|
10
|
+
many: (count, noun) => say({ key: "views.selection.many", values: { count, one: noun.one, other: noun.other } }),
|
|
11
|
+
selected: (many) => say({ key: "views.selection.bar-label", values: { many } }),
|
|
12
|
+
del: (many) => say({ key: "views.selection.delete-many", values: { many } }),
|
|
13
|
+
ask: (many) => say({ key: "views.selection.delete-ask", values: { many } }),
|
|
14
|
+
noun: { one: say({ key: "views.selection.noun-one" }), other: say({ key: "views.selection.noun-other" }) },
|
|
15
|
+
count: say({ key: "views.selection.bar-count" }),
|
|
16
|
+
pill: say({ key: "views.selection.selected" }),
|
|
17
|
+
clear: say({ key: "views.selection.clear-the" }),
|
|
18
|
+
more: say({ key: "views.selection.more" }),
|
|
19
|
+
actions: say({ key: "views.selection.actions" }),
|
|
20
|
+
delete: say({ key: "views.selection.delete-button" }),
|
|
21
|
+
cancel: say({ key: "views.picker.cancel" }),
|
|
22
|
+
failed: say({ key: "views.panels.alert-failed" }),
|
|
23
|
+
cantUse: say({ key: "views.selection.cant-use" }),
|
|
24
|
+
picker: pickerWordsOf(say),
|
|
25
|
+
menu: menuWordsOf(say),
|
|
26
|
+
toast: { undo: say({ key: "views.panels.toast-undo" }), close: say({ key: "views.panels.close" }), region: say({ key: "views.panels.toast-region" }) },
|
|
27
|
+
dialog: { close: say({ key: "views.panels.close" }), failed: say({ key: "views.panels.alert-failed" }), tryAgain: say({ key: "views.picker.retry" }) },
|
|
28
|
+
sheet: { close: say({ key: "views.panels.close" }), back: say({ key: "views.panels.back" }) },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const doneOf = (out) => out && typeof out === "object" && typeof out.words === "string" ? out : undefined;
|
|
32
|
+
const isThenable = (out) => !!out && typeof out.then === "function";
|
|
33
|
+
export function runOf(press) {
|
|
34
|
+
return () => { const out = press(); return isThenable(out) ? Promise.resolve(out).then(doneOf) : doneOf(out); };
|
|
35
|
+
}
|
|
36
|
+
export function bulkVerbsOf(verbs, AppIcon) {
|
|
37
|
+
return verbs.map((v) => {
|
|
38
|
+
if (v.kind === "action")
|
|
39
|
+
return { ...v, onClick: runOf(v.onClick) };
|
|
40
|
+
if (v.kind === "group")
|
|
41
|
+
return { ...v, items: v.items.map((i) => ({ ...i, onClick: runOf(i.onClick) })) };
|
|
42
|
+
const { options, onSelect, onEmpty, ...rest } = v;
|
|
43
|
+
return {
|
|
44
|
+
...rest, options: pickerItemsOf(options, AppIcon ? { AppIcon } : {}),
|
|
45
|
+
...(rest.empty !== undefined && !onEmpty ? { empty: undefined } : {}),
|
|
46
|
+
onSelect: (value) => runOf(() => (value === null ? onEmpty?.() : onSelect(value)))(),
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function MapSelectionBar({ count, noun, onClear, verbs, busy, onDelete, deleteLabel, deleteLine }) {
|
|
51
|
+
const views = React.useContext(ViewsContext);
|
|
52
|
+
const messages = views?.messages ?? resolveViewsMessage;
|
|
53
|
+
const words = React.useMemo(() => bulkBarWordsOf(messages), [messages]);
|
|
54
|
+
const AppIcon = views?.components.AppIcon;
|
|
55
|
+
const bulk = React.useMemo(() => bulkVerbsOf(verbs, AppIcon), [verbs, AppIcon]);
|
|
56
|
+
return (_jsx(BulkBar, { count: count, onClear: onClear, verbs: bulk, words: words, ...(noun ? { noun } : {}), ...(busy !== undefined ? { busy } : {}), ...(onDelete ? { onDelete: runOf(onDelete) } : {}), ...(deleteLabel !== undefined ? { deleteLabel } : {}), ...(deleteLine !== undefined ? { deleteLine } : {}) }));
|
|
57
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export declare const BULK_BAR_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-border";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--border";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-border-brand";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--border-focused";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-border-input";
|
|
11
|
+
readonly kind: "colour";
|
|
12
|
+
readonly outright: "--border-input";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-border-width";
|
|
15
|
+
readonly kind: "size";
|
|
16
|
+
readonly outright: "--border-width";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-brand";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--background-brand-bold";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-duration-base";
|
|
23
|
+
readonly kind: "motion";
|
|
24
|
+
readonly outright: "--duration-base";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-ease-out";
|
|
27
|
+
readonly kind: "motion";
|
|
28
|
+
readonly outright: "--ease-out";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-fg";
|
|
31
|
+
readonly kind: "colour";
|
|
32
|
+
readonly outright: "--text";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-fg-accent";
|
|
35
|
+
readonly kind: "colour";
|
|
36
|
+
readonly outright: "--text-brand";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-fg-disabled";
|
|
39
|
+
readonly kind: "colour";
|
|
40
|
+
readonly outright: "--text-disabled";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-fg-on-brand";
|
|
43
|
+
readonly kind: "colour";
|
|
44
|
+
readonly outright: "--text-brand-inverse";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-fg-subtle";
|
|
47
|
+
readonly kind: "colour";
|
|
48
|
+
readonly outright: "--text-subtle";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-fg-subtlest";
|
|
51
|
+
readonly kind: "colour";
|
|
52
|
+
readonly outright: "--text-subtlest";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-focus-offset";
|
|
55
|
+
readonly kind: "size";
|
|
56
|
+
readonly outright: "--focus-offset";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-focus-width";
|
|
59
|
+
readonly kind: "size";
|
|
60
|
+
readonly outright: "--focus-width";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-font-size-base";
|
|
63
|
+
readonly kind: "size";
|
|
64
|
+
readonly outright: "--text-base";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-font-size-sm";
|
|
67
|
+
readonly kind: "size";
|
|
68
|
+
readonly outright: "--text-sm";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-font-size-xs";
|
|
71
|
+
readonly kind: "size";
|
|
72
|
+
readonly outright: "--text-xs";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-font-weight-medium";
|
|
75
|
+
readonly kind: "size";
|
|
76
|
+
readonly outright: "--font-weight-medium";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-font-weight-semibold";
|
|
79
|
+
readonly kind: "size";
|
|
80
|
+
readonly outright: "--font-weight-semibold";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "--vk-layer-sticky";
|
|
83
|
+
readonly kind: "size";
|
|
84
|
+
readonly outright: "--layer-sticky";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-line-height-base";
|
|
87
|
+
readonly kind: "size";
|
|
88
|
+
readonly outright: "--text-base--line-height";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "--vk-line-height-sm";
|
|
91
|
+
readonly kind: "size";
|
|
92
|
+
readonly outright: "--text-sm--line-height";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "--vk-neutral-hovered";
|
|
95
|
+
readonly kind: "colour";
|
|
96
|
+
readonly outright: "--background-neutral-hovered";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "--vk-overlay";
|
|
99
|
+
readonly kind: "colour";
|
|
100
|
+
readonly outright: "--surface-overlay";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "--vk-radius-2xl";
|
|
103
|
+
readonly kind: "size";
|
|
104
|
+
readonly outright: "--radius-2xl";
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "--vk-radius-full";
|
|
107
|
+
readonly kind: "size";
|
|
108
|
+
readonly outright: "--radius-full";
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "--vk-radius-lg";
|
|
111
|
+
readonly kind: "size";
|
|
112
|
+
readonly outright: "--radius-lg";
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "--vk-radius-sm";
|
|
115
|
+
readonly kind: "size";
|
|
116
|
+
readonly outright: "--radius-sm";
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "--vk-radius-xl";
|
|
119
|
+
readonly kind: "size";
|
|
120
|
+
readonly outright: "--radius-xl";
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: "--vk-shadow-lg";
|
|
123
|
+
readonly kind: "shadow";
|
|
124
|
+
readonly outright: "--shadow-lg";
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "--vk-shadow-menu";
|
|
127
|
+
readonly kind: "shadow";
|
|
128
|
+
readonly outright: "--shadow-menu";
|
|
129
|
+
}, {
|
|
130
|
+
readonly name: "--vk-spacing";
|
|
131
|
+
readonly kind: "size";
|
|
132
|
+
readonly outright: "--spacing";
|
|
133
|
+
}];
|
|
134
|
+
/** The bar's own machinery: where it stands and how tall it is (`--bulk-bar-bottom`, `--bulk-bar-height`) and the room it hands its
|
|
135
|
+
* holder (`--bulk-bar-room`); and the phone's safe area at its foot, as the Sheet reads it (`--safe-area-bottom`). */
|
|
136
|
+
export declare const BULK_BAR_PRIVATE: readonly ["--bulk-bar-", "--safe-area-"];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const BULK_BAR_TOKENS = [
|
|
2
|
+
{ name: "--vk-border", kind: "colour", outright: "--border" },
|
|
3
|
+
{ name: "--vk-border-brand", kind: "colour", outright: "--border-focused" },
|
|
4
|
+
{ name: "--vk-border-input", kind: "colour", outright: "--border-input" },
|
|
5
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
6
|
+
{ name: "--vk-brand", kind: "colour", outright: "--background-brand-bold" },
|
|
7
|
+
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
8
|
+
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
9
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
10
|
+
{ name: "--vk-fg-accent", kind: "colour", outright: "--text-brand" },
|
|
11
|
+
{ name: "--vk-fg-disabled", kind: "colour", outright: "--text-disabled" },
|
|
12
|
+
{ name: "--vk-fg-on-brand", kind: "colour", outright: "--text-brand-inverse" },
|
|
13
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
14
|
+
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
15
|
+
{ name: "--vk-focus-offset", kind: "size", outright: "--focus-offset" },
|
|
16
|
+
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
17
|
+
{ name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
|
|
18
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
19
|
+
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
20
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
21
|
+
{ name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
|
|
22
|
+
{ name: "--vk-layer-sticky", kind: "size", outright: "--layer-sticky" },
|
|
23
|
+
{ name: "--vk-line-height-base", kind: "size", outright: "--text-base--line-height" },
|
|
24
|
+
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
25
|
+
{ name: "--vk-neutral-hovered", kind: "colour", outright: "--background-neutral-hovered" },
|
|
26
|
+
{ name: "--vk-overlay", kind: "colour", outright: "--surface-overlay" },
|
|
27
|
+
{ name: "--vk-radius-2xl", kind: "size", outright: "--radius-2xl" },
|
|
28
|
+
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
29
|
+
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
30
|
+
{ name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
|
|
31
|
+
{ name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
|
|
32
|
+
{ name: "--vk-shadow-lg", kind: "shadow", outright: "--shadow-lg" },
|
|
33
|
+
{ name: "--vk-shadow-menu", kind: "shadow", outright: "--shadow-menu" },
|
|
34
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
35
|
+
];
|
|
36
|
+
export const BULK_BAR_PRIVATE = ["--bulk-bar-", "--safe-area-"];
|