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,243 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import { glyph } from "../internal/editor-parts.js";
|
|
6
|
+
import { Icon } from "../internal/icons.js";
|
|
7
|
+
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
8
|
+
import { Input, InputGroup, InputGroupAddon } from "../input/input.js";
|
|
9
|
+
import { MENU_LIST_CARD_FRAME } from "../menu-list/looks.js";
|
|
10
|
+
import { MenuList, MenuListPanelRows } from "../menu-list/menu-list.js";
|
|
11
|
+
import { Notice } from "../notice/notice.js";
|
|
12
|
+
import { InPane, PaneBody, PaneClose, PaneFoot, PaneHead, PaneTitle } from "../pane/pane.js";
|
|
13
|
+
import { Radio, RadioGroup } from "../radio/radio.js";
|
|
14
|
+
import { SheetStep } from "../sheet/bottom-sheet.js";
|
|
15
|
+
import { reduced, slideTime, useGlide } from "./glide.js";
|
|
16
|
+
import { CUSTOMIZE_ATTRS, customizeWornOf } from "./looks.js";
|
|
17
|
+
import { columnsSay, findColumns, moveColumn, setShown } from "./rules.js";
|
|
18
|
+
import { customizeWords } from "./words.js";
|
|
19
|
+
export function useCustomizeWorn() {
|
|
20
|
+
const [el, setEl] = React.useState(null), [worn, setWorn] = React.useState(() => customizeWornOf(null));
|
|
21
|
+
React.useLayoutEffect(() => {
|
|
22
|
+
if (!el)
|
|
23
|
+
return;
|
|
24
|
+
const read = () => setWorn((now) => { const next = customizeWornOf(el); return now.head === next.head && now.columns === next.columns ? now : next; });
|
|
25
|
+
read();
|
|
26
|
+
const watch = new MutationObserver(read);
|
|
27
|
+
watch.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: CUSTOMIZE_ATTRS });
|
|
28
|
+
return () => watch.disconnect();
|
|
29
|
+
}, [el]);
|
|
30
|
+
return [setEl, worn];
|
|
31
|
+
}
|
|
32
|
+
const COLUMNS = glyph(["M6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2z", "M9 4v16", "M15 4v16"]);
|
|
33
|
+
const GROUP = glyph(["M5.5 4h13a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1 -1.5 1.5h-13a1.5 1.5 0 0 1 -1.5 -1.5v-3a1.5 1.5 0 0 1 1.5 -1.5z", "M5.5 14h13a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1 -1.5 1.5h-13a1.5 1.5 0 0 1 -1.5 -1.5v-3a1.5 1.5 0 0 1 1.5 -1.5z"]);
|
|
34
|
+
const LAYOUT_MARKS = {
|
|
35
|
+
table: "M6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2zM4 10h16M10 4v16",
|
|
36
|
+
board: "M5.5 4h3a1.5 1.5 0 0 1 1.5 1.5v13a1.5 1.5 0 0 1 -1.5 1.5h-3a1.5 1.5 0 0 1 -1.5 -1.5v-13a1.5 1.5 0 0 1 1.5 -1.5zM15.5 4h3a1.5 1.5 0 0 1 1.5 1.5v7a1.5 1.5 0 0 1 -1.5 1.5h-3a1.5 1.5 0 0 1 -1.5 -1.5v-7a1.5 1.5 0 0 1 1.5 -1.5z",
|
|
37
|
+
list: "M9 6h11M9 12h11M9 18h11M5 6h.01M5 12h.01M5 18h.01",
|
|
38
|
+
calendar: "M6 5h12a2 2 0 0 1 2 2v11a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2M4 10h16M9 3v4M15 3v4",
|
|
39
|
+
timeline: "M4 7h9M8 12h10M6 17h7",
|
|
40
|
+
};
|
|
41
|
+
export const layoutMark = (id) => (LAYOUT_MARKS[id] ? glyph([LAYOUT_MARKS[id]]) : undefined);
|
|
42
|
+
export function useCustomize(props) {
|
|
43
|
+
const { view, onViewChange, layouts, filter, sort, group, changed = false, onReset, onSave, pending = false, stale = false, exportCount, onCopyLink, onExport, toggles, layoutSettings, columnsReset, onClose, onScreenChange } = props;
|
|
44
|
+
const w = customizeWords(props.words);
|
|
45
|
+
const host = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (host || small ? "phone" : "computer")) === "phone";
|
|
46
|
+
const inPane = React.useContext(InPane);
|
|
47
|
+
const [place, worn] = useCustomizeWorn();
|
|
48
|
+
const now = React.useRef(view);
|
|
49
|
+
React.useLayoutEffect(() => { now.current = view; });
|
|
50
|
+
const latest = React.useMemo(() => ({ get view() { return now.current; } }), []);
|
|
51
|
+
const change = (next) => { now.current = next; onViewChange(next); };
|
|
52
|
+
const NAMES = { layout: w.layout, columns: w.columns, filter: w.filter, sort: w.sort, group: w.group };
|
|
53
|
+
const SCREEN_OF = { [w.layout]: "layout", [w.columns]: "columns", [w.filter]: "filter", [w.sort]: "sort", [w.group]: "group" };
|
|
54
|
+
const handed = { filter, sort, group };
|
|
55
|
+
const hasLayout = layouts.length > 0 || !!layoutSettings, hasColumns = view.columns.length > 0;
|
|
56
|
+
const opens = (to) => to === "list" || (to === "layout" ? hasLayout : to === "columns" ? hasColumns : handed[to]?.opens != null);
|
|
57
|
+
const [screen, setScreen] = React.useState(() => (props.screen && opens(props.screen) ? props.screen : "list")), [back, setBack] = React.useState(false);
|
|
58
|
+
const [choosing, setChoosing] = React.useState(null);
|
|
59
|
+
const [find, setFind] = React.useState("");
|
|
60
|
+
const [focusTo, setFocusTo] = React.useState(null), root = React.useRef(null), backButton = React.useRef(null);
|
|
61
|
+
const go = (to) => {
|
|
62
|
+
if (!opens(to))
|
|
63
|
+
return;
|
|
64
|
+
setBack(false);
|
|
65
|
+
setScreen(to);
|
|
66
|
+
setChoosing(null);
|
|
67
|
+
setFocusTo("back");
|
|
68
|
+
setFind("");
|
|
69
|
+
onScreenChange?.(to);
|
|
70
|
+
};
|
|
71
|
+
const goBack = () => { const from = screen; setBack(true); setScreen("list"); setChoosing(null); setFocusTo(from === "list" ? null : NAMES[from]); setFind(""); onScreenChange?.("list"); };
|
|
72
|
+
React.useLayoutEffect(() => {
|
|
73
|
+
if (!focusTo || phone)
|
|
74
|
+
return;
|
|
75
|
+
setFocusTo(null);
|
|
76
|
+
if (focusTo === "back") {
|
|
77
|
+
backButton.current?.focus({ preventScroll: true });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const row = [...(root.current?.querySelectorAll("[data-item]") ?? [])].find((r) => r.querySelector(".o-menu-name")?.textContent === focusTo);
|
|
81
|
+
row?.focus({ preventScroll: true });
|
|
82
|
+
}, [focusTo, phone]);
|
|
83
|
+
const placeRoot = React.useCallback((el) => { root.current = el; place(el); }, [place]);
|
|
84
|
+
const glide = useGlide(root);
|
|
85
|
+
const [held, setHeld] = React.useState({});
|
|
86
|
+
const holds = React.useRef([]);
|
|
87
|
+
const press = (ids, on) => {
|
|
88
|
+
const land = (these) => change({ ...latest.view, columns: these.reduce((cols, id) => setShown(cols, id, on), latest.view.columns) });
|
|
89
|
+
if (!ids.length)
|
|
90
|
+
return;
|
|
91
|
+
if (reduced()) {
|
|
92
|
+
land(ids);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
for (const h of holds.current)
|
|
96
|
+
h.ids = h.ids.filter((id) => !ids.includes(id));
|
|
97
|
+
setHeld((was) => ({ ...was, ...Object.fromEntries(ids.map((id) => [id, on])) }));
|
|
98
|
+
const hold = { ids, land: () => land(hold.ids), timer: 0 };
|
|
99
|
+
hold.timer = window.setTimeout(() => {
|
|
100
|
+
holds.current = holds.current.filter((h) => h !== hold);
|
|
101
|
+
glide(() => {
|
|
102
|
+
if (hold.ids.length)
|
|
103
|
+
hold.land();
|
|
104
|
+
setHeld((was) => { const next = { ...was }; for (const id of hold.ids)
|
|
105
|
+
delete next[id]; return next; });
|
|
106
|
+
}, latest.view.columns.filter((c) => hold.ids.includes(c.id)).map((c) => c.label));
|
|
107
|
+
}, slideTime(root.current));
|
|
108
|
+
holds.current.push(hold);
|
|
109
|
+
};
|
|
110
|
+
React.useEffect(() => () => { for (const h of holds.current) {
|
|
111
|
+
window.clearTimeout(h.timer);
|
|
112
|
+
if (h.ids.length)
|
|
113
|
+
h.land();
|
|
114
|
+
} holds.current = []; }, []);
|
|
115
|
+
const layout = layouts.find((l) => l.id === view.layout) ?? layouts[0];
|
|
116
|
+
const section = (label, icon, s) => s ? [{ kind: "actions", icon, label, detail: s.says, inForce: s.inForce, entries: [] }] : [];
|
|
117
|
+
const toggleRows = (ts) => ts.flatMap((t) => [
|
|
118
|
+
{ kind: "check", label: t.label, checked: t.value, onCheckedChange: (on) => t.onChange(on), ...(t.icon != null && { icon: t.icon }) },
|
|
119
|
+
...(t.reset ? [{ icon: null, label: w.toggleReset(t.label), onSelect: t.reset }] : []),
|
|
120
|
+
]);
|
|
121
|
+
const sectionsOfToggles = (ts) => [...new Set(ts.flatMap((t) => (t.section ? [t.section] : [])))];
|
|
122
|
+
const checks = toggles
|
|
123
|
+
? [...toggleRows(toggles.filter((t) => !t.section)),
|
|
124
|
+
...sectionsOfToggles(toggles).map((s) => ({ kind: "group", heading: s, entries: toggleRows(toggles.filter((t) => t.section === s)) }))]
|
|
125
|
+
: [{ kind: "check", label: w.showCounts, checked: view.counts, onCheckedChange: (c) => change({ ...latest.view, counts: c }) }];
|
|
126
|
+
const sections = [
|
|
127
|
+
...(hasLayout ? [{ kind: "actions", icon: layout?.mark, label: w.layout, detail: layout?.name, entries: [] }] : []),
|
|
128
|
+
...(hasColumns ? [{ kind: "actions", icon: COLUMNS, label: w.columns, detail: columnsSay(view.columns, w), entries: [] }] : []),
|
|
129
|
+
...section(w.filter, _jsx(Icon, { name: "filter" }), filter), ...section(w.sort, _jsx(Icon, { name: "sort" }), sort), ...section(w.group, GROUP, group),
|
|
130
|
+
...(checks.length ? [{ kind: "separator" }, ...checks] : []),
|
|
131
|
+
];
|
|
132
|
+
const opened = (e) => { if ("label" in e && SCREEN_OF[e.label])
|
|
133
|
+
go(SCREEN_OF[e.label]); };
|
|
134
|
+
const footer = [
|
|
135
|
+
...(onCopyLink ? [{ icon: _jsx(Icon, { name: "link" }), label: w.copyLink, onSelect: onCopyLink }] : []),
|
|
136
|
+
...(onExport ? [{ icon: _jsx(Icon, { name: "export" }), label: w.export, ...(exportCount != null ? { count: exportCount } : {}), onSelect: onExport }] : []),
|
|
137
|
+
];
|
|
138
|
+
const words = (size) => (_jsxs(_Fragment, { children: [stale && _jsx(Notice, { className: "o-customize-stale", children: w.stale }), _jsxs("div", { className: "o-customize-words", children: [_jsx(Button, { kind: "link", size: size, onClick: onReset, disabled: pending, children: w.reset }), onSave && _jsx(Button, { kind: "link", size: size, onClick: onSave, disabled: pending, children: w.save })] })] }));
|
|
139
|
+
const allChoices = layoutSettings ? [...layoutSettings.choices, ...(layoutSettings.personal?.choices ?? [])] : [];
|
|
140
|
+
const choiceRows = new Map();
|
|
141
|
+
const choiceOpened = (e) => { const c = choiceRows.get(e); if (c) {
|
|
142
|
+
setBack(false);
|
|
143
|
+
setChoosing(c.key);
|
|
144
|
+
} };
|
|
145
|
+
const rowsList = (label, rows) => (phone
|
|
146
|
+
? _jsx(MenuList, { label: label, entries: rows, onOpen: choiceOpened, words: w.rows })
|
|
147
|
+
: _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "switch", onOpen: choiceOpened, words: w.rows }));
|
|
148
|
+
const choiceRow = (c) => {
|
|
149
|
+
const entry = { kind: "choices", icon: null, label: c.label, value: c.value, choices: c.options.map((o) => ({ value: o.value, label: o.label })),
|
|
150
|
+
detail: c.options.find((o) => o.value === c.value)?.label };
|
|
151
|
+
choiceRows.set(entry, c);
|
|
152
|
+
return entry;
|
|
153
|
+
};
|
|
154
|
+
const choice = screen === "layout" ? allChoices.find((c) => c.key === choosing) : undefined;
|
|
155
|
+
const backFromChoice = () => { setBack(true); setFocusTo(choice?.label ?? null); setChoosing(null); };
|
|
156
|
+
const choiceLevel = choice && (() => {
|
|
157
|
+
const rows = [{ kind: "pick", value: choice.value, choices: choice.options.map((o) => ({ value: o.value, label: o.label })),
|
|
158
|
+
onChoose: (v) => { if (v !== choice.value)
|
|
159
|
+
choice.onChange(v); backFromChoice(); } }];
|
|
160
|
+
return phone ? _jsx(MenuList, { label: choice.label, entries: rows, words: w.rows }) : _jsx(MenuListPanelRows, { label: choice.label, entries: rows, words: w.rows });
|
|
161
|
+
})();
|
|
162
|
+
const heading = (label, act) => (_jsxs("div", { className: "o-customize-heading", children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: label }), act?.map((a) => _jsx(Button, { kind: "link", size: "line", onClick: a.onPress, children: a.label }, a.label))] }));
|
|
163
|
+
const ownSettings = (settings, name) => {
|
|
164
|
+
const bare = settings.toggles.filter((t) => !t.section), sectioned = sectionsOfToggles(settings.toggles);
|
|
165
|
+
const first = [...settings.choices.map(choiceRow), ...toggleRows(bare)];
|
|
166
|
+
const you = settings.personal, yours = you ? [...you.choices.map(choiceRow), ...toggleRows(you.toggles), ...(you.onReset ? [{ icon: null, label: w.personalReset, onSelect: you.onReset }] : [])] : [];
|
|
167
|
+
return _jsxs(_Fragment, { children: [first.length > 0 && _jsxs(_Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: name }), rowsList(w.layoutSettings(name), first)] }), sectioned.map((s) => _jsxs(React.Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: s }), rowsList(s, toggleRows(settings.toggles.filter((t) => t.section === s)))] }, s)), you && yours.length > 0 && _jsxs(_Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: you.label }), rowsList(you.label, yours)] })] });
|
|
168
|
+
};
|
|
169
|
+
const layoutScreen = (_jsxs(_Fragment, { children: [_jsx(RadioGroup, { tiles: true, "aria-label": w.layout, value: view.layout, onValueChange: (v) => { if (typeof v === "string")
|
|
170
|
+
change({ ...latest.view, layout: v }); }, children: layouts.map((l) => _jsx(Radio, { value: l.id, mark: l.mark, label: l.name, disabled: l.later }, l.id)) }), layoutSettings ? ownSettings(layoutSettings, layout?.name ?? w.layout) : layout?.id === "table" && _jsxs(_Fragment, { children: [_jsx("p", { className: "o-list-heading o-customize-heading-words", children: layout.name }), rowsList(w.layoutSettings(layout.name), [
|
|
171
|
+
{ kind: "check", label: w.freeze, checked: view.freeze, onCheckedChange: (c) => change({ ...latest.view, freeze: c }) },
|
|
172
|
+
{ kind: "check", label: w.wrap, checked: view.wrap, onCheckedChange: (c) => change({ ...latest.view, wrap: c }) },
|
|
173
|
+
])] })] }));
|
|
174
|
+
const searching = find.trim() !== "", eyes = worn.columns === "eye";
|
|
175
|
+
const found = findColumns(view.columns, find);
|
|
176
|
+
const gripped = (columns, shown) => (searching || (!shown && !eyes) ? [] : columns.filter((c) => c.shown === shown && !c.locked));
|
|
177
|
+
const block = (shown) => {
|
|
178
|
+
const grips = new Set(gripped(found, shown).map((c) => c.id));
|
|
179
|
+
return found.filter((c) => c.shown === shown).map((c) => ({ kind: "check", label: c.label, icon: c.mark, checked: held[c.id] ?? c.shown, grip: grips.has(c.id),
|
|
180
|
+
disabled: c.locked ? w.alwaysShown : undefined, onCheckedChange: (on) => press([c.id], on) }));
|
|
181
|
+
};
|
|
182
|
+
const moveIn = (shown) => (from, to) => {
|
|
183
|
+
const g = gripped(latest.view.columns, shown);
|
|
184
|
+
if (g[from] && g[to])
|
|
185
|
+
change({ ...latest.view, columns: moveColumn(latest.view.columns, g[from].id, g[to].id) });
|
|
186
|
+
};
|
|
187
|
+
const ticks = eyes ? "eye" : "switch";
|
|
188
|
+
const rowsOf = (label, shown) => phone
|
|
189
|
+
? _jsx(MenuList, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), words: w.rows })
|
|
190
|
+
: _jsx(MenuListPanelRows, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), words: w.rows });
|
|
191
|
+
const canHide = view.columns.some((c) => c.shown && !c.locked), canShow = view.columns.some((c) => !c.shown);
|
|
192
|
+
const shownHere = found.some((c) => c.shown), hiddenHere = found.some((c) => !c.shown);
|
|
193
|
+
const typed = (e) => setFind(e.target.value);
|
|
194
|
+
const columnsBox = (_jsxs(InputGroup, { size: phone ? "lg" : "sm", chrome: "soft", children: [_jsx(InputGroupAddon, { children: _jsx(Icon, { name: "search" }) }), _jsx(Input, { value: find, onChange: typed, placeholder: phone ? w.findColumn : w.searchColumns, "aria-label": phone ? w.findColumn : w.searchColumns })] }));
|
|
195
|
+
const columnsSearch = phone ? columnsBox : _jsx("div", { className: "o-customize-search", children: columnsBox });
|
|
196
|
+
const shownActs = [
|
|
197
|
+
...(!searching && canHide ? [{ label: w.hideAll, onPress: () => press(latest.view.columns.filter((c) => c.shown && !c.locked).map((c) => c.id), false) }] : []),
|
|
198
|
+
...(!searching && columnsReset ? [{ label: w.columnsReset, onPress: columnsReset }] : []),
|
|
199
|
+
];
|
|
200
|
+
const columnsScreen = (_jsxs(_Fragment, { children: [phone && columnsSearch, shownHere && _jsxs(_Fragment, { children: [heading(w.shownHeading, shownActs), rowsOf(w.shownHeading, true)] }), hiddenHere && _jsxs(_Fragment, { children: [heading(w.hiddenHeading, !searching && canShow ? [{ label: w.showAll, onPress: () => press(latest.view.columns.filter((c) => !c.shown).map((c) => c.id), true) }] : undefined), rowsOf(w.hiddenHeading, false)] }), !found.length && _jsx("p", { className: "o-customize-none", children: w.noColumn(find.trim()) })] }));
|
|
201
|
+
const content = screen === "list"
|
|
202
|
+
? phone ? _jsx(MenuList, { label: w.list, entries: sections, onOpen: opened, words: w.rows }) : _jsx(MenuListPanelRows, { label: w.list, entries: sections, ticks: "switch", onOpen: opened, words: w.rows })
|
|
203
|
+
: screen === "layout" ? choiceLevel ?? layoutScreen : screen === "columns" ? columnsScreen : handed[screen]?.opens;
|
|
204
|
+
const form = phone ? "phone" : "computer";
|
|
205
|
+
const level = choice ? { name: choice.label, back: backFromChoice } : screen !== "list" ? handed[screen]?.level ?? null : null, backTo = level?.back ?? goBack;
|
|
206
|
+
const named = worn.head === "name" && view.name !== "";
|
|
207
|
+
const name = screen === "list" ? (named ? view.name : w.title) : level?.name ?? NAMES[screen];
|
|
208
|
+
const titled = !named;
|
|
209
|
+
if (phone) {
|
|
210
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(SheetStep, { step: choice ? `layout:${choice.key}` : screen, back: back, children: _jsx("div", { className: "o-customize-step", children: content }) }) }));
|
|
211
|
+
const foot = screen === "list" && (changed || footer.length) ? (_jsxs("div", { className: "o-customize-foot", ...MENU_LIST_CARD_FRAME, children: [changed && words("44"), footer.length > 0 && _jsx(MenuList, { label: w.share, entries: footer, words: w.rows })] })) : undefined;
|
|
212
|
+
return { body, title: name, head: screen === "list" ? { close: true } : { onBack: backTo, close: titled }, foot };
|
|
213
|
+
}
|
|
214
|
+
const title = (words) => (inPane ? _jsx(PaneTitle, { children: words }) : _jsx("h2", { className: "o-pane-title", children: words }));
|
|
215
|
+
const xButton = (extra) => _jsx(Button, { kind: "quiet", shape: "icon", size: "sm", "aria-label": w.close, icon: _jsx(Icon, { name: "x" }), ...extra });
|
|
216
|
+
const close = inPane ? _jsx(PaneClose, { render: xButton() }) : onClose ? xButton({ onClick: onClose }) : null;
|
|
217
|
+
const head = screen !== "list" ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-screen", children: [_jsx(Button, { ref: backButton, kind: "quiet", shape: "icon", size: "sm", "aria-label": w.back, icon: _jsx(Icon, { name: "left" }), onClick: backTo }), _jsx("span", { className: "o-customize-title", children: title(name) }), titled && close] })) : titled ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-title", children: [_jsx("span", { className: "o-customize-title", children: title(w.title) }), close] })) : (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-name", children: [hasLayout && _jsx(Button, { kind: "outline", shape: "icon", size: "sm", "aria-label": w.layoutButton(layout?.name ?? ""), icon: layout?.mark, onClick: () => go("layout") }), _jsx(ViewName, { name: view.name, label: w.viewName, onRename: (n) => change({ ...latest.view, name: n }) })] }));
|
|
218
|
+
const parts = (_jsxs(_Fragment, { children: [head, screen === "columns" && columnsSearch, _jsx(PaneBody, { children: _jsx("div", { ref: placeRoot, className: "o-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: content }) }), screen === "list" && changed && words("xs"), footer.length > 0 && _jsx(PaneFoot, { children: _jsx(MenuListPanelRows, { label: w.share, entries: footer, words: w.rows }) })] }));
|
|
219
|
+
return { body: inPane ? parts : _jsx("div", { className: "o-customize-frame", children: parts }), title: name, head: {} };
|
|
220
|
+
}
|
|
221
|
+
function ViewName({ name, label, onRename }) {
|
|
222
|
+
const [draft, setDraft] = React.useState(name);
|
|
223
|
+
React.useEffect(() => setDraft(name), [name]);
|
|
224
|
+
const keep = () => { const n = draft.trim(); if (!n)
|
|
225
|
+
setDraft(name);
|
|
226
|
+
else if (n !== name)
|
|
227
|
+
onRename(n);
|
|
228
|
+
else
|
|
229
|
+
setDraft(name); };
|
|
230
|
+
return (_jsx("span", { className: "o-customize-name", children: _jsx(Input, { size: "sm", "aria-label": label, value: draft, onChange: (e) => setDraft(e.target.value), onBlur: keep, onKeyDown: (e) => {
|
|
231
|
+
if (e.key === "Enter") {
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
keep();
|
|
234
|
+
}
|
|
235
|
+
if (e.key === "Escape" && draft !== name) {
|
|
236
|
+
e.preventDefault();
|
|
237
|
+
setDraft(name);
|
|
238
|
+
}
|
|
239
|
+
} }) }));
|
|
240
|
+
}
|
|
241
|
+
export function Customize(props) {
|
|
242
|
+
return _jsx(_Fragment, { children: useCustomize({ ...props, form: props.form ?? "computer" }).body });
|
|
243
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export declare const groundOf: (el: Element) => string;
|
|
3
|
+
/** Whether the person asked for less motion. */
|
|
4
|
+
export declare const reduced: () => boolean;
|
|
5
|
+
/** How long a tick takes to show its new state: the Switch's own slide (its thumb's longest transition, whichever Motion it wears),
|
|
6
|
+
* or, where the ticks are eyes, the eye's slash being drawn (KIT-826); `--customize-tick` (`--vk-duration-fast`) where it finds neither. */
|
|
7
|
+
export declare function slideTime(root: HTMLElement | null): number;
|
|
8
|
+
/** A change that glides: `apply` hands it on, and once it is drawn every row and heading in `root` that moved slides from where it
|
|
9
|
+
* stood, and one that is new fades in; the rows named in `lead` (the ones pressed) over the others. */
|
|
10
|
+
export declare function useGlide(root: React.RefObject<HTMLElement | null>): (apply: () => void, lead?: string[]) => void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const MOVES = "[data-item], .o-menu-list-row, .o-customize-heading";
|
|
3
|
+
const keyOf = (el) => `${el.matches(".o-customize-heading") ? "h" : "r"}:${el.querySelector(".o-list-heading, .o-menu-name, .o-menu-list-name > span:first-child")?.textContent ?? ""}`;
|
|
4
|
+
const ms = (v) => { const t = v.trim(); return t.endsWith("ms") ? parseFloat(t) : t.endsWith("s") ? parseFloat(t) * 1000 : parseFloat(t) || 0; };
|
|
5
|
+
const token = (name, el) => getComputedStyle(el ?? document.documentElement).getPropertyValue(name);
|
|
6
|
+
const alphaOf = (colour) => {
|
|
7
|
+
const c = colour.trim();
|
|
8
|
+
if (!c || c === "transparent")
|
|
9
|
+
return 0;
|
|
10
|
+
const commas = /^(?:rgb|hsl)a?\(([^)/]*)\)$/.exec(c)?.[1]?.split(",");
|
|
11
|
+
const said = /\/\s*([\d.]+)(%?)\s*\)$/.exec(c) ?? (commas?.length === 4 ? /([\d.]+)(%?)\s*$/.exec(commas[3]) : null);
|
|
12
|
+
return said ? parseFloat(said[1]) / (said[2] ? 100 : 1) : 1;
|
|
13
|
+
};
|
|
14
|
+
export const groundOf = (el) => {
|
|
15
|
+
for (let n = el.parentElement; n; n = n.parentElement) {
|
|
16
|
+
const c = getComputedStyle(n).backgroundColor;
|
|
17
|
+
if (alphaOf(c) >= 1)
|
|
18
|
+
return c;
|
|
19
|
+
}
|
|
20
|
+
return token("--customize-ground", el).trim();
|
|
21
|
+
};
|
|
22
|
+
export const reduced = () => typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
23
|
+
export function slideTime(root) {
|
|
24
|
+
const tick = root?.querySelector(".o-switch-thumb, .o-eye-slash");
|
|
25
|
+
if (tick)
|
|
26
|
+
return Math.max(0, ...getComputedStyle(tick).transitionDuration.split(",").map(ms));
|
|
27
|
+
return ms(token("--customize-tick", root));
|
|
28
|
+
}
|
|
29
|
+
export function useGlide(root) {
|
|
30
|
+
const before = React.useRef(null);
|
|
31
|
+
React.useLayoutEffect(() => {
|
|
32
|
+
const was = before.current;
|
|
33
|
+
if (!was || !root.current)
|
|
34
|
+
return;
|
|
35
|
+
before.current = null;
|
|
36
|
+
const duration = ms(token("--customize-glide", root.current)), easing = token("--customize-glide-ease", root.current).trim() || "ease-in-out";
|
|
37
|
+
for (const el of root.current.querySelectorAll(MOVES)) {
|
|
38
|
+
const key = keyOf(el), from = was.at.get(key), dy = from === undefined ? 0 : from - el.getBoundingClientRect().top;
|
|
39
|
+
const over = was.lead.has(key) ? { position: "relative", zIndex: "1", backgroundColor: groundOf(el) } : {};
|
|
40
|
+
if (from === undefined)
|
|
41
|
+
el.animate([{ opacity: 0 }, { opacity: 1 }], { duration, easing });
|
|
42
|
+
else if (Math.abs(dy) > 0.5)
|
|
43
|
+
el.animate([{ transform: `translateY(${dy}px)`, ...over }, { transform: "none", ...over }], { duration, easing });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return (apply, lead = []) => {
|
|
47
|
+
if (root.current && !reduced()) {
|
|
48
|
+
const at = new Map();
|
|
49
|
+
for (const el of root.current.querySelectorAll(MOVES))
|
|
50
|
+
at.set(keyOf(el), el.getBoundingClientRect().top);
|
|
51
|
+
before.current = { at, lead: new Set(lead.map((name) => `r:${name}`)) };
|
|
52
|
+
}
|
|
53
|
+
apply();
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PieceLooks } from "../../looks/looks.js";
|
|
2
|
+
export type CustomizeOptionId = "head" | "columns";
|
|
3
|
+
/** What Customize reads from the frame round it. */
|
|
4
|
+
export interface CustomizeWorn {
|
|
5
|
+
head: "name" | "title";
|
|
6
|
+
columns: "switch" | "eye";
|
|
7
|
+
}
|
|
8
|
+
/** Customize's options; it has no looks. */
|
|
9
|
+
export declare const CUSTOMIZE_LOOKS: PieceLooks<CustomizeOptionId>;
|
|
10
|
+
/** The options worn round `el`, each from the nearest frame that picks it; outside any frame, the defaults. */
|
|
11
|
+
export declare function customizeWornOf(el: Element | null): CustomizeWorn;
|
|
12
|
+
/** The attributes Customize watches, so an option changed while it is open reaches it. */
|
|
13
|
+
export declare const CUSTOMIZE_ATTRS: string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { lookWornOf } from "../../looks/looks.js";
|
|
2
|
+
const options = [
|
|
3
|
+
{ id: "head", name: "Its head", def: "title", values: [{ id: "name", name: "The view's name" }, { id: "title", name: "A title" }] },
|
|
4
|
+
{ id: "columns", name: "Columns", def: "switch", values: [{ id: "switch", name: "Switches" }, { id: "eye", name: "Eyes" }] },
|
|
5
|
+
];
|
|
6
|
+
export const CUSTOMIZE_LOOKS = { id: "customize", name: "Customize", options, looks: [] };
|
|
7
|
+
export function customizeWornOf(el) {
|
|
8
|
+
const worn = lookWornOf(CUSTOMIZE_LOOKS, el, ["head", "columns"]);
|
|
9
|
+
return { head: worn.head === "title" ? "title" : "name", columns: worn.columns === "eye" ? "eye" : "switch" };
|
|
10
|
+
}
|
|
11
|
+
export const CUSTOMIZE_ATTRS = CUSTOMIZE_LOOKS.options.map((o) => `data-customize-${o.id}`);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ViewsMessageResolver } from "../../contract.js";
|
|
2
|
+
import type { ViewsCustomizeBodyProps } from "../../provider/components.js";
|
|
3
|
+
import { type CustomizeView } from "./customize.js";
|
|
4
|
+
import type { CustomizeWords } from "./words.js";
|
|
5
|
+
/** The view's name and its rename, Copy link, and Export CSV with its count: what the toolbar hands Customize's body, each drawn
|
|
6
|
+
* only where handed. */
|
|
7
|
+
export type CustomizeBodyOwn = Pick<ViewsCustomizeBodyProps, "name" | "onRename" | "exportCount" | "onCopyLink" | "onExport">;
|
|
8
|
+
/** Customize's words in the app's: ViewKit's key wherever its word is the kit's, a key of its own where it differs. */
|
|
9
|
+
export declare function customizeWordsOf(say: ViewsMessageResolver): CustomizeWords;
|
|
10
|
+
/** The one write a change of Customize's view makes, or null, compared with the view as drawn (a second change built before it
|
|
11
|
+
* draws again, two moves of one drag, still writes whole and right): the first of its name, its layout (one the list offers; a
|
|
12
|
+
* refused one writes nothing) and its columns that differs. Columns, one or several shown or hidden (Hide all, Show all) or moved,
|
|
13
|
+
* through ViewKit's own, in one change. */
|
|
14
|
+
export declare function customizeWriteOf(p: ViewsCustomizeBodyProps, own: CustomizeBodyOwn, now: CustomizeView, next: CustomizeView): (() => void) | null;
|
|
15
|
+
/** What the kit's Customize can't draw, which ViewKit's own Customize does: a column with its own settings, the field editor's rows,
|
|
16
|
+
* a card layout's line breaks. */
|
|
17
|
+
export declare function customizeStepsAside(p: ViewsCustomizeBodyProps): boolean;
|
|
18
|
+
export declare function MapCustomizeBody(props: ViewsCustomizeBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,160 @@
|
|
|
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 { resolveViewsMessage } from "../../contract.js";
|
|
5
|
+
import { ViewsContext } from "../../provider/context.js";
|
|
6
|
+
import { useFilterEditor } from "../filter-editor/filter-editor.js";
|
|
7
|
+
import { filterWordsOf, useMapFilterBody } from "../filter-editor/map-filter-body.js";
|
|
8
|
+
import { rulesOf } from "../filter-editor/rules.js";
|
|
9
|
+
import { useGroupEditor } from "../group-editor/group-editor.js";
|
|
10
|
+
import { groupEditorPropsOf, groupEditorWordsOf } from "../group-editor/map-group-body.js";
|
|
11
|
+
import { groupLabel } from "../group-editor/rules.js";
|
|
12
|
+
import { glyph, X } from "../internal/editor-parts.js";
|
|
13
|
+
import { useToldStep } from "../internal/told-step.js";
|
|
14
|
+
import { HeaderBar } from "../phone-header/header-bar.js";
|
|
15
|
+
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
16
|
+
import { SheetPartsFrom } from "../sheet/sheet-parts.js";
|
|
17
|
+
import { sortEditorPropsOf, sortEditorWordsOf } from "../sort-editor/map-sort-body.js";
|
|
18
|
+
import { sortLabel } from "../sort-editor/rules.js";
|
|
19
|
+
import { useSortEditor } from "../sort-editor/sort-editor.js";
|
|
20
|
+
import { layoutMark, useCustomize } from "./customize.js";
|
|
21
|
+
const BACK = ["M5 12l14 0", "M5 12l6 6", "M5 12l6 -6"];
|
|
22
|
+
export function customizeWordsOf(say) {
|
|
23
|
+
return {
|
|
24
|
+
title: say({ key: "views.panels.customize-title" }),
|
|
25
|
+
list: say({ key: "views.panels.customize-list" }),
|
|
26
|
+
layout: say({ key: "views.panels.layout" }),
|
|
27
|
+
columns: say({ key: "views.panels.columns" }),
|
|
28
|
+
filter: say({ key: "views.panels.filter" }),
|
|
29
|
+
sort: say({ key: "views.panels.sort" }),
|
|
30
|
+
group: say({ key: "views.panels.group" }),
|
|
31
|
+
showCounts: say({ key: "views.panels.show-counts" }),
|
|
32
|
+
shown: (count) => say({ key: "views.panels.columns-shown", values: { count } }),
|
|
33
|
+
none: say({ key: "views.panels.group-none" }),
|
|
34
|
+
shownHeading: say({ key: "views.panels.customize-shown" }),
|
|
35
|
+
hiddenHeading: say({ key: "views.panels.customize-hidden" }),
|
|
36
|
+
hideAll: say({ key: "views.panels.groups-hide-all" }),
|
|
37
|
+
showAll: say({ key: "views.panels.groups-show-all" }),
|
|
38
|
+
searchColumns: say({ key: "views.panels.customize-search" }),
|
|
39
|
+
findColumn: say({ key: "views.panels.customize-find" }),
|
|
40
|
+
noColumn: (words) => say({ key: "views.panels.customize-no-column", values: { words } }),
|
|
41
|
+
alwaysShown: say({ key: "views.panels.customize-always-shown" }),
|
|
42
|
+
reset: say({ key: "views.panels.view-reset" }),
|
|
43
|
+
save: say({ key: "views.panels.view-publish" }),
|
|
44
|
+
viewName: say({ key: "views.panels.customize-view-name" }),
|
|
45
|
+
layoutButton: (name) => say({ key: "views.panels.customize-layout-button", values: { name } }),
|
|
46
|
+
layoutSettings: (name) => say({ key: "views.panels.customize-layout-settings", values: { name } }),
|
|
47
|
+
share: say({ key: "views.panels.customize-share" }),
|
|
48
|
+
copyLink: say({ key: "views.panels.copy-link" }),
|
|
49
|
+
export: say({ key: "views.panels.export-csv" }),
|
|
50
|
+
back: say({ key: "views.panels.back" }),
|
|
51
|
+
close: say({ key: "views.panels.close" }),
|
|
52
|
+
freeze: "Freeze first column",
|
|
53
|
+
wrap: "Wrap text",
|
|
54
|
+
personalReset: say({ key: "views.panels.personal-reset" }),
|
|
55
|
+
columnsReset: say({ key: "views.panels.columns-reset" }),
|
|
56
|
+
toggleReset: (label) => say({ key: "views.panels.toggle-reset", values: { label } }),
|
|
57
|
+
stale: say({ key: "views.panels.view-stale" }),
|
|
58
|
+
rows: {
|
|
59
|
+
move: (label) => say({ key: "views.panels.sort-move", values: { label } }),
|
|
60
|
+
howKeys: say({ key: "views.panels.list-move-keys" }),
|
|
61
|
+
howHold: say({ key: "views.panels.list-move-hold" }),
|
|
62
|
+
movedTo: (label, at, of) => say({ key: "views.panels.list-moved", values: { label, at, of } }),
|
|
63
|
+
on: say({ key: "views.panels.toggle-on" }),
|
|
64
|
+
off: say({ key: "views.panels.toggle-off" }),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const columnsOf = (p) => (p.columns?.items ?? []).map((c) => ({ id: c.id, label: c.label, shown: !c.hidden, locked: !c.hideable || !!c.fixed, mark: c.icon }));
|
|
69
|
+
export function customizeWriteOf(p, own, now, next) {
|
|
70
|
+
if (next.name !== now.name)
|
|
71
|
+
return own.onRename ? () => own.onRename(next.name) : null;
|
|
72
|
+
if (next.layout !== now.layout) {
|
|
73
|
+
const layout = p.layout;
|
|
74
|
+
return layout?.options.some((o) => o.value === next.layout) ? () => layout.onLayoutChange(next.layout) : null;
|
|
75
|
+
}
|
|
76
|
+
const was = new Map(now.columns.map((c) => [c.id, c.shown]));
|
|
77
|
+
const flipped = next.columns.some((c) => was.get(c.id) !== c.shown), moved = next.columns.some((c, at) => c.id !== now.columns[at]?.id);
|
|
78
|
+
const viewKit = p.columns;
|
|
79
|
+
if (!viewKit || (!flipped && !moved))
|
|
80
|
+
return null;
|
|
81
|
+
return () => viewKit.onColumnsChange(next.columns.map((c) => ({ id: c.id, hidden: !c.shown })));
|
|
82
|
+
}
|
|
83
|
+
export function customizeStepsAside(p) {
|
|
84
|
+
const cols = p.columns;
|
|
85
|
+
return !!cols && (cols.items.some((c) => !!c.settings && (c.settings.choices.length > 0 || c.settings.toggles.length > 0))
|
|
86
|
+
|| !!cols.columnMenu || cols.footer != null || !!cols.onStartsLineChange);
|
|
87
|
+
}
|
|
88
|
+
const toggleOf = (t) => ({ key: t.key, label: t.label, value: t.value, onChange: t.onChange, ...(t.icon != null && { icon: t.icon }), ...(t.reset && { reset: t.reset }), ...(t.section && { section: t.section }) });
|
|
89
|
+
const choiceOf = (c) => ({ key: c.key, label: c.label, value: c.value, options: [...c.options], onChange: c.onChange });
|
|
90
|
+
function layoutSettingsOf(layout) {
|
|
91
|
+
return {
|
|
92
|
+
choices: [...(layout.density ? [choiceOf(layout.density)] : []), ...layout.choices.map(choiceOf)],
|
|
93
|
+
toggles: layout.toggles.map(toggleOf),
|
|
94
|
+
...(layout.personal && { personal: { label: layout.personal.label, toggles: layout.personal.toggles.map(toggleOf), choices: layout.personal.choices.map(choiceOf),
|
|
95
|
+
...(layout.personal.onReset && { onReset: layout.personal.onReset }) } }),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const NO_SORT = { label: "", options: [], rules: [], setAside: [], max: 1, addSort: true, onRulesChange() { } };
|
|
99
|
+
const NO_FILTER = { label: "", fields: [], filter: { op: "and", items: [] }, levels: 1, excludable: false, onFilterChange() { }, ruleValue: () => null };
|
|
100
|
+
const NO_GROUP = { label: "", dimensions: [], group: { value: "none" }, manualOrder: false, onGroupChange() { } };
|
|
101
|
+
const stay = () => undefined;
|
|
102
|
+
const levelOf = (parts) => parts.title !== undefined && parts.head.onBack ? { name: parts.title, back: parts.head.onBack } : null;
|
|
103
|
+
export function MapCustomizeBody(props) {
|
|
104
|
+
const { name, onRename, exportCount, onCopyLink, onExport, ...p } = props;
|
|
105
|
+
const views = React.useContext(ViewsContext);
|
|
106
|
+
const say = views?.messages ?? resolveViewsMessage;
|
|
107
|
+
const phone = p.form === "phone";
|
|
108
|
+
const w = React.useMemo(() => customizeWordsOf(say), [say]);
|
|
109
|
+
const sortWords = React.useMemo(() => sortEditorWordsOf(say), [say]);
|
|
110
|
+
const filterWords = React.useMemo(() => filterWordsOf(say), [say]);
|
|
111
|
+
const groupWords = React.useMemo(() => groupEditorWordsOf(say), [say]);
|
|
112
|
+
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
113
|
+
const editorForm = phone ? "phone" : "narrow";
|
|
114
|
+
const sortProps = sortEditorPropsOf({ ...(p.sort ?? NO_SORT), form: p.form, onDone: stay }, sortWords, say);
|
|
115
|
+
const sorting = useSortEditor({ ...sortProps, form: editorForm, onDone: undefined });
|
|
116
|
+
const sortSaid = sortLabel(sortProps.rules, sortProps.fields);
|
|
117
|
+
const sort = p.sort && { says: sortSaid ? `${sortSaid.first}${sortSaid.more ? ` +${sortSaid.more}` : ""}` : w.none, inForce: !!sortSaid,
|
|
118
|
+
opens: sorting.body, level: levelOf(sorting) };
|
|
119
|
+
const filterHanded = { ...(p.filter ?? NO_FILTER), form: p.form, onDone: stay };
|
|
120
|
+
const map = useMapFilterBody(filterHanded, filterWords, say, views?.components.AppIcon, wayWord);
|
|
121
|
+
const filtering = useFilterEditor({ label: filterHanded.label, fields: map.kit.fields, filter: map.filter, levels: filterHanded.levels, form: editorForm, onFilterChange: map.change,
|
|
122
|
+
own: map.own, words: filterWords });
|
|
123
|
+
const ruleCount = rulesOf(map.filter).length;
|
|
124
|
+
const filter = p.filter && { says: ruleCount > 0 ? String(ruleCount) : w.none, inForce: ruleCount > 0, opens: filtering.body, level: levelOf(filtering) };
|
|
125
|
+
const groupProps = groupEditorPropsOf({ ...(p.group ?? NO_GROUP), form: p.form, onDone: stay }, groupWords);
|
|
126
|
+
const grouping = useGroupEditor(groupProps);
|
|
127
|
+
const group = p.group && { says: groupLabel(groupProps.group, groupProps.fields, w.none), inForce: p.group.group.value !== "none",
|
|
128
|
+
opens: grouping.body, level: grouping.level };
|
|
129
|
+
const view = { name: onRename ? name ?? "" : "", layout: p.layout?.value ?? "", columns: columnsOf(p), counts: false, freeze: false, wrap: false };
|
|
130
|
+
const shared = p.view, kit = p.foot === "kit";
|
|
131
|
+
const foot = shared ? (shared.changes > 0 && p.foot !== "none" ? {
|
|
132
|
+
changed: true, onReset: shared.onReset, ...(shared.canPublish && { onSave: shared.onPublish }), pending: shared.pending, stale: shared.stale,
|
|
133
|
+
words: { reset: say({ key: kit ? "views.panels.view-clear" : "views.panels.view-reset" }), save: say({ key: kit ? "views.panels.view-save" : "views.panels.view-publish" }) },
|
|
134
|
+
} : {}) : p.onClear && p.foot !== "none" ? { changed: true, onReset: p.onClear, words: { reset: say({ key: "views.panels.view-clear" }) } } : {};
|
|
135
|
+
const { words: footWords, ...footProps } = foot;
|
|
136
|
+
const level = p.page === "group" ? group?.level : p.page === "sort" ? sort?.level : p.page === "filter" ? filter?.level : null;
|
|
137
|
+
useToldStep({ head: { onBack: phone ? level?.back : undefined }, title: level?.name }, p.onStepChange);
|
|
138
|
+
const parts = useCustomize({
|
|
139
|
+
view, onViewChange: (next) => customizeWriteOf(p, { onRename }, view, next)?.(),
|
|
140
|
+
layouts: [...(p.layout?.options ?? []).map((o) => ({ id: o.value, name: o.label, mark: layoutMark(o.value) })),
|
|
141
|
+
...(p.layout?.refused ?? []).map((o) => ({ id: o.value, name: o.label, mark: layoutMark(o.value), later: true }))],
|
|
142
|
+
filter, sort, group,
|
|
143
|
+
toggles: p.toggles.map(toggleOf),
|
|
144
|
+
...(p.layout && { layoutSettings: layoutSettingsOf(p.layout) }),
|
|
145
|
+
...(p.columns?.reset && { columnsReset: p.columns.reset }),
|
|
146
|
+
...footProps,
|
|
147
|
+
...(exportCount !== undefined && { exportCount }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }),
|
|
148
|
+
onClose: p.onDone, onScreenChange: p.onPageChange, screen: p.page, form: p.form,
|
|
149
|
+
words: { ...w, ...(p.layout && { layout: p.layout.label }), ...(p.columns && { columns: p.columns.label }),
|
|
150
|
+
...(p.layout && p.layout.value !== "table" && { shownHeading: say({ key: "views.panels.customize-shown-fields" }) }), ...footWords },
|
|
151
|
+
});
|
|
152
|
+
const setParts = React.useContext(SheetPartsFrom);
|
|
153
|
+
React.useLayoutEffect(() => { if (phone && setParts)
|
|
154
|
+
setParts({ title: parts.title, head: parts.head, foot: parts.foot }); });
|
|
155
|
+
React.useLayoutEffect(() => () => setParts?.(null), [setParts]);
|
|
156
|
+
if (!phone || setParts)
|
|
157
|
+
return _jsx(_Fragment, { children: parts.body });
|
|
158
|
+
const { onBack, close } = parts.head;
|
|
159
|
+
return (_jsxs(_Fragment, { children: [_jsx(HeaderBar, { className: "o-customize-own-head", title: parts.title, left: onBack ? _jsx(SheetButton, { "aria-label": w.back, className: "o-sheet-back", icon: glyph(BACK), onClick: onBack }) : close ? _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: p.onDone }) : _jsx("span", {}), right: close && onBack ? _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: p.onDone }) : _jsx("span", {}) }), parts.body, parts.foot] }));
|
|
160
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { CustomizeWords } from "./words.js";
|
|
3
|
+
/** A column of the view: its id, its name, whether it is shown, whether it is locked (always shown, never moved), its type's mark. */
|
|
4
|
+
export interface CustomizeColumn {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
shown: boolean;
|
|
8
|
+
locked?: boolean;
|
|
9
|
+
mark?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** What the Columns section says on Customize's list: how many are shown ("6 shown"), in the handed words. */
|
|
12
|
+
export declare const columnsSay: (columns: CustomizeColumn[], words?: Pick<CustomizeWords, "shown">) => string;
|
|
13
|
+
/** The columns with one shown or hidden, in its place; a locked column stays shown. */
|
|
14
|
+
export declare const setShown: (columns: CustomizeColumn[], id: string, shown: boolean) => CustomizeColumn[];
|
|
15
|
+
/** Every column hidden but the locked ones. */
|
|
16
|
+
export declare const hideAll: (columns: CustomizeColumn[]) => CustomizeColumn[];
|
|
17
|
+
/** Every column shown. */
|
|
18
|
+
export declare const showAll: (columns: CustomizeColumn[]) => CustomizeColumn[];
|
|
19
|
+
/** The columns with `id` moved to `over`'s place in the whole order: before it moving up, after it moving down. A locked column
|
|
20
|
+
* never moves, nor is moved past. */
|
|
21
|
+
export declare function moveColumn(columns: CustomizeColumn[], id: string, over: string): CustomizeColumn[];
|
|
22
|
+
/** The columns whose name holds the words, trimmed and whatever their case; no words, every column. */
|
|
23
|
+
export declare function findColumns(columns: CustomizeColumn[], words: string): CustomizeColumn[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const columnsSay = (columns, words) => {
|
|
2
|
+
const n = columns.filter((c) => c.shown).length;
|
|
3
|
+
return words ? words.shown(n) : `${n} shown`;
|
|
4
|
+
};
|
|
5
|
+
export const setShown = (columns, id, shown) => columns.map((c) => (c.id === id && !c.locked ? { ...c, shown } : c));
|
|
6
|
+
export const hideAll = (columns) => columns.map((c) => (c.locked ? c : { ...c, shown: false }));
|
|
7
|
+
export const showAll = (columns) => columns.map((c) => ({ ...c, shown: true }));
|
|
8
|
+
export function moveColumn(columns, id, over) {
|
|
9
|
+
const from = columns.findIndex((c) => c.id === id), to = columns.findIndex((c) => c.id === over);
|
|
10
|
+
if (from < 0 || to < 0 || from === to || columns[from].locked || columns[to].locked)
|
|
11
|
+
return columns;
|
|
12
|
+
const next = [...columns], [moving] = next.splice(from, 1);
|
|
13
|
+
next.splice(to, 0, moving);
|
|
14
|
+
return next;
|
|
15
|
+
}
|
|
16
|
+
export function findColumns(columns, words) {
|
|
17
|
+
const w = words.trim().toLowerCase();
|
|
18
|
+
return w ? columns.filter((c) => c.label.toLowerCase().includes(w)) : columns;
|
|
19
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const CUSTOMIZE_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-border";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--border";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-duration-base";
|
|
7
|
+
readonly kind: "motion";
|
|
8
|
+
readonly outright: "--duration-base";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-duration-fast";
|
|
11
|
+
readonly kind: "motion";
|
|
12
|
+
readonly outright: "--duration-fast";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-ease-in-out";
|
|
15
|
+
readonly kind: "motion";
|
|
16
|
+
readonly outright: "--ease-in-out";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-fg-subtle";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--text-subtle";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-font-size-sm";
|
|
23
|
+
readonly kind: "size";
|
|
24
|
+
readonly outright: "--text-sm";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-line-height-sm";
|
|
27
|
+
readonly kind: "size";
|
|
28
|
+
readonly outright: "--text-sm--line-height";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-overlay";
|
|
31
|
+
readonly kind: "colour";
|
|
32
|
+
readonly outright: "--surface-overlay";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-spacing";
|
|
35
|
+
readonly kind: "size";
|
|
36
|
+
readonly outright: "--spacing";
|
|
37
|
+
}];
|
|
38
|
+
/** The prefixes of Customize's own machinery, set and read by it alone: its glide's timing (`--customize-`). Its frame sets the
|
|
39
|
+
* Pane's own `--pane-pad` and `--pane-edge`, the Pane's private names, for the Pane's parts it draws outside one. */
|
|
40
|
+
export declare const CUSTOMIZE_PRIVATE: readonly ["--customize-"];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const CUSTOMIZE_TOKENS = [
|
|
2
|
+
{ name: "--vk-border", kind: "colour", outright: "--border" },
|
|
3
|
+
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
4
|
+
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
5
|
+
{ name: "--vk-ease-in-out", kind: "motion", outright: "--ease-in-out" },
|
|
6
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
7
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
8
|
+
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
9
|
+
{ name: "--vk-overlay", kind: "colour", outright: "--surface-overlay" },
|
|
10
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
11
|
+
];
|
|
12
|
+
export const CUSTOMIZE_PRIVATE = ["--customize-"];
|