viewkitjs 0.34.0 → 0.35.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 +110 -0
- package/package.json +1 -1
- package/views/README.md +1 -1
- package/views/dist/atoms/Avatar.js +2 -1
- package/views/dist/atoms/RelationChip.d.ts +2 -0
- package/views/dist/atoms/RelationChip.js +5 -0
- package/views/dist/atoms/RowMenu.d.ts +1 -1
- package/views/dist/atoms/RowMenu.js +15 -3
- package/views/dist/atoms/defaults.js +2 -0
- package/views/dist/atoms/types.d.ts +40 -4
- package/views/dist/cells/relation-wrap.js +9 -2
- package/views/dist/contract.d.ts +9 -6
- package/views/dist/contract.js +4 -2
- package/views/dist/controls/avatar/avatar-mark.d.ts +4 -0
- package/views/dist/controls/avatar/avatar-mark.js +5 -0
- package/views/dist/controls/avatar/avatar.d.ts +7 -4
- package/views/dist/controls/avatar/avatar.js +10 -4
- package/views/dist/controls/avatar/looks.d.ts +1 -1
- package/views/dist/controls/avatar/looks.js +3 -0
- package/views/dist/controls/avatar/record-mark.d.ts +16 -0
- package/views/dist/controls/avatar/record-mark.js +13 -0
- package/views/dist/controls/avatar/tokens.d.ts +12 -0
- package/views/dist/controls/avatar/tokens.js +3 -0
- package/views/dist/controls/avatar.css +54 -17
- package/views/dist/controls/bulk-bar/bulk-bar.js +4 -5
- package/views/dist/controls/bulk-bar/map-selection-bar.js +2 -1
- package/views/dist/controls/compound-editor/compound-editor.d.ts +3 -0
- package/views/dist/controls/compound-editor/map-parts-body.d.ts +1 -1
- package/views/dist/controls/compound-editor/map-parts-body.js +6 -1
- package/views/dist/controls/compound-editor/name-parts.js +2 -1
- package/views/dist/controls/compound-editor/place-parts.js +2 -2
- package/views/dist/controls/compound-editor/range-parts.js +10 -9
- package/views/dist/controls/customize/customize.d.ts +14 -5
- package/views/dist/controls/customize/customize.js +11 -14
- package/views/dist/controls/customize/map-customize-body.js +12 -11
- package/views/dist/controls/customize/words.d.ts +3 -3
- package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +4 -6
- package/views/dist/controls/filter-editor/parts.d.ts +1 -1
- package/views/dist/controls/filter-editor/parts.js +4 -4
- package/views/dist/controls/index.d.ts +1 -1
- package/views/dist/controls/internal/map-panel-controls.js +9 -5
- package/views/dist/controls/internal/panel-controls.d.ts +27 -3
- package/views/dist/controls/internal/panel-controls.js +141 -12
- package/views/dist/controls/links-editor/links-editor.js +5 -7
- package/views/dist/controls/links-editor/map-links-body.d.ts +1 -1
- package/views/dist/controls/links-editor/map-links-body.js +5 -1
- package/views/dist/controls/menu/menu.d.ts +3 -0
- package/views/dist/controls/menu/menu.js +2 -1
- package/views/dist/controls/picker/map-fields-body.d.ts +2 -2
- package/views/dist/controls/picker/map-fields-body.js +5 -1
- package/views/dist/controls/picker/map-picker.d.ts +8 -3
- package/views/dist/controls/picker/map-picker.js +14 -3
- package/views/dist/controls/picker/picker.js +11 -8
- package/views/dist/controls/picker/rows.d.ts +7 -2
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +2 -1
- package/views/dist/controls/quick-filters/quick-filters.js +4 -4
- package/views/dist/controls/quick-filters/reminder.js +2 -2
- package/views/dist/controls/quick-filters/rules.d.ts +4 -1
- package/views/dist/controls/quick-filters/words.d.ts +2 -0
- package/views/dist/controls/quick-filters/words.js +1 -0
- package/views/dist/controls/select/select.d.ts +3 -0
- package/views/dist/controls/select/select.js +9 -3
- package/views/dist/controls/sort-editor/sort-editor.d.ts +2 -0
- package/views/dist/controls/sort-editor/sort-editor.js +4 -5
- package/views/dist/controls/toolbar/toolbar.d.ts +25 -12
- package/views/dist/controls/toolbar/toolbar.js +15 -20
- package/views/dist/controls/toolbar.css +0 -5
- package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
- package/views/dist/controls/tooltip/map-tooltip.js +4 -2
- package/views/dist/controls/values-editor/map-values-body.d.ts +1 -2
- package/views/dist/controls/values-editor/map-values-body.js +5 -1
- package/views/dist/controls/values-editor/values-editor.js +8 -7
- package/views/dist/display/option-badges.d.ts +16 -0
- package/views/dist/display/option-badges.js +11 -0
- package/views/dist/display/relation-link.d.ts +12 -0
- package/views/dist/display/relation-link.js +17 -0
- package/views/dist/display/relation.d.ts +1 -1
- package/views/dist/display/relation.js +10 -3
- package/views/dist/display/select.js +1 -8
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/editors/RangeEditor.d.ts +3 -0
- package/views/dist/editors/RangeEditor.js +2 -2
- package/views/dist/editors/SelectEditor.d.ts +2 -2
- package/views/dist/editors/SelectEditor.js +1 -1
- package/views/dist/editors/TextEditor.js +4 -2
- package/views/dist/editors/ValueListEditor.js +2 -1
- package/views/dist/field-row/FieldRow.js +32 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +2 -1
- package/views/dist/grid/chrome/GridAddColumn.js +9 -6
- package/views/dist/grid/chrome/GridCellEditors.js +1 -1
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -1
- package/views/dist/grid/chrome/GridCellOutline.js +16 -6
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +7 -4
- package/views/dist/grid/chrome/GridFooter.d.ts +4 -1
- package/views/dist/grid/chrome/GridFooter.js +4 -4
- package/views/dist/grid/chrome/GridGroupMenu.js +39 -14
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -1
- package/views/dist/grid/chrome/GridHeader.js +1 -2
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +4 -1
- package/views/dist/grid/chrome/GridRangeEditor.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +5 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +4 -1
- package/views/dist/grid/chrome/GridRowActions.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +3 -2
- package/views/dist/grid/chrome/GridStructure.js +1 -1
- package/views/dist/grid/chrome/GridTable.js +32 -20
- package/views/dist/grid/chrome/checks.d.ts +1 -1
- package/views/dist/grid/chrome/checks.js +4 -1
- package/views/dist/grid/chrome/grid-cell-classes.d.ts +6 -2
- package/views/dist/grid/chrome/grid-cell-classes.js +10 -5
- package/views/dist/grid/chrome/grid-hover.d.ts +10 -2
- package/views/dist/grid/chrome/grid-hover.js +14 -4
- package/views/dist/grid/chrome/grid-row-props.d.ts +4 -0
- package/views/dist/grid/chrome/grid-rows-menu.js +9 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +10 -2
- package/views/dist/grid/grid.css +6 -0
- package/views/dist/grid/looks.d.ts +3 -1
- package/views/dist/grid/looks.js +10 -4
- package/views/dist/list/layer.d.ts +8 -0
- package/views/dist/list/layer.js +7 -0
- package/views/dist/list/store.d.ts +1 -1
- package/views/dist/list/toolbar.js +44 -19
- package/views/dist/list/views.js +1 -0
- package/views/dist/panels/availability.d.ts +5 -0
- package/views/dist/panels/availability.js +4 -5
- package/views/dist/panels/customize-body.d.ts +4 -0
- package/views/dist/panels/customize-body.js +13 -11
- package/views/dist/panels/model.d.ts +9 -4
- package/views/dist/panels/react/customize-body.js +5 -2
- package/views/dist/panels/react/customize.d.ts +5 -0
- package/views/dist/panels/react/filter/FilterEditor.d.ts +6 -0
- package/views/dist/panels/react/filter/FilterEditor.js +7 -0
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +3 -1
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +7 -3
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +4 -1
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +11 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +16 -6
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +6 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +12 -5
- package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +7 -3
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +18 -8
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +6 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +5 -4
- package/views/dist/panels/react/toolbar/ToolbarSort.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +6 -3
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +3 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +4 -4
- package/views/dist/panels/react/views-row/ViewPicker.js +13 -5
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/settings/layout.js +6 -38
- package/views/dist/panels/toolbar/page-resets.d.ts +17 -0
- package/views/dist/panels/toolbar/page-resets.js +62 -0
- package/views/dist/panels/toolbar/same-item.d.ts +7 -0
- package/views/dist/panels/toolbar/same-item.js +9 -0
- package/views/dist/panels/view-state.d.ts +4 -0
- package/views/dist/provider/ViewsProvider.d.ts +9 -4
- package/views/dist/provider/ViewsProvider.js +13 -2
- package/views/dist/provider/components.d.ts +27 -5
- package/views/dist/provider/components.js +1 -1
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +98 -23
- package/views/dist/styles.unlayered.css +98 -23
- package/views/docs/contract.md +38 -25
- package/views/docs/controls/avatar.md +3 -0
- package/views/docs/controls/bulk-bar.md +3 -1
- package/views/docs/controls/compound-editor.md +2 -0
- package/views/docs/controls/customize.md +1 -1
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/links-editor.md +2 -0
- package/views/docs/controls/pane.md +1 -1
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/quick-filters.md +1 -1
- package/views/docs/controls/text-editor.md +1 -1
- package/views/docs/controls/values-editor.md +2 -0
- package/views/docs/guides/atoms.md +54 -3
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +4 -2
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/index.md +2 -2
- package/views/docs/install.md +198 -104
- package/views/docs/reference/controls.md +17 -15
- package/views/docs/reference/editors-range.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +2 -1
- package/views/docs/reference/list.md +2 -2
- package/views/docs/reference/looks.md +5 -5
- package/views/docs/reference/panels-react.md +13 -12
- package/views/docs/reference/panels.md +4 -4
- package/views/docs/reference/react.md +10 -8
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +22 -6
- package/views/skills/views/SKILL.md +2 -2
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { resolveViewsMessage } from "../../contract.js";
|
|
5
5
|
import { EDITOR_INNER_ESCAPE } from "../../editors/inner-escape.js";
|
|
6
6
|
import { ViewsContext } from "../../provider/context.js";
|
|
7
7
|
import { pickerItemsOf, pickerWordsOf } from "../picker/map-picker.js";
|
|
8
8
|
import { useToldStep } from "../internal/told-step.js";
|
|
9
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
9
10
|
import { useLinksEditor } from "./links-editor.js";
|
|
10
11
|
import { heldOf } from "./links.js";
|
|
11
12
|
const ROLES = "roles";
|
|
@@ -63,6 +64,9 @@ export function linksEditorPropsOf(p, words, rolesWord, AppIcon) {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
export function MapLinksBody(props) {
|
|
67
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(LinksBodyInner, { ...props }) });
|
|
68
|
+
}
|
|
69
|
+
function LinksBodyInner(props) {
|
|
66
70
|
const views = React.useContext(ViewsContext);
|
|
67
71
|
const messages = views?.messages ?? resolveViewsMessage;
|
|
68
72
|
const makeLead = props.lead?.makeLabel;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type MenuChoice, type MenuEntry } from "../menu-list/menu-list.js";
|
|
3
|
+
import { type ButtonProps } from "../button/button.js";
|
|
3
4
|
import { type Anchor } from "../internal/anchor.js";
|
|
4
5
|
import { type CloseReason } from "../internal/close-reason.js";
|
|
5
6
|
import { type PickerWords } from "../picker/picker.js";
|
|
@@ -87,3 +88,5 @@ export declare const MenuDots: React.ForwardRefExoticComponent<{
|
|
|
87
88
|
className?: string;
|
|
88
89
|
"data-force"?: string;
|
|
89
90
|
} & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
|
|
91
|
+
/** The ⋯ button's own props, for a part that draws it through another Button (the Picker's phone row, under `panelControls`). */
|
|
92
|
+
export declare const menuDotsProps: (label: string, className?: string) => ButtonProps;
|
|
@@ -103,5 +103,6 @@ function ContextMenuPopup({ entries, label, children, className, open, onOpenCha
|
|
|
103
103
|
return (_jsxs(BaseContextMenu.Root, { open: open, onOpenChange: onOpenChange ? (o) => onOpenChange(o) : undefined, children: [_jsxs(BaseContextMenu.Trigger, { className: className, children: [_jsx("span", { ref: ref, hidden: true }), children] }), _jsx(BaseContextMenu.Portal, { container: host, className: "o-menu-portal", children: _jsx(BaseContextMenu.Positioner, { ref: setAt, className: "o-list-positioner", collisionPadding: spacingPx(2, at ?? host), children: _jsx(BaseContextMenu.Popup, { className: "o-list o-menu o-smooth o-smooth-ease", "aria-label": label, "data-kit": "menu", ...mark, children: _jsx(MenuScroll, { children: _jsx(MenuListRows, { entries: entries, host: host }) }) }) }) })] }));
|
|
104
104
|
}
|
|
105
105
|
export const MenuDots = React.forwardRef(function MenuDots({ label, className, ...props }, ref) {
|
|
106
|
-
return _jsx(Button, { ref: ref,
|
|
106
|
+
return _jsx(Button, { ref: ref, ...menuDotsProps(label, className), ...props });
|
|
107
107
|
});
|
|
108
|
+
export const menuDotsProps = (label, className) => ({ kind: "quiet", shape: "icon", size: "sm", "aria-label": label, className: cx("o-menu-dots", className), icon: glyph(DOTS, "") });
|
|
@@ -14,5 +14,5 @@ export declare function fieldsBodyHandlers({ onPick, onDone }: Pick<ViewsFieldsB
|
|
|
14
14
|
onValueChange(v: string | string[] | null): void;
|
|
15
15
|
onDone(): void;
|
|
16
16
|
};
|
|
17
|
-
/** ViewKit's field list,
|
|
18
|
-
export declare function MapFieldsBody(
|
|
17
|
+
/** ViewKit's field list, its controls the app's where the provider's `panelControls` names them (VK-1022). */
|
|
18
|
+
export declare function MapFieldsBody(props: ViewsFieldsBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { useViews } from "../../provider/context.js";
|
|
5
5
|
import { Picker } from "./picker.js";
|
|
6
6
|
import { pickerWordsOf } from "./map-picker.js";
|
|
7
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
7
8
|
const SEP = "\u0000";
|
|
8
9
|
export const farValue = (relation, key) => `${relation}${SEP}${key}`;
|
|
9
10
|
export const pickOf = (value) => {
|
|
@@ -35,7 +36,10 @@ export function fieldsBodyHandlers({ onPick, onDone }, held = { current: false }
|
|
|
35
36
|
},
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
export function MapFieldsBody(
|
|
39
|
+
export function MapFieldsBody(props) {
|
|
40
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(FieldsBodyInner, { ...props }) });
|
|
41
|
+
}
|
|
42
|
+
function FieldsBodyInner({ label, search, fields, own, form, onPick, onDone }) {
|
|
39
43
|
const { messages } = useViews();
|
|
40
44
|
const picked = React.useRef(false);
|
|
41
45
|
const on = () => fieldsBodyHandlers({ onPick, onDone }, picked);
|
|
@@ -10,14 +10,19 @@ type AppIcon = ComponentType<{
|
|
|
10
10
|
/**
|
|
11
11
|
* ViewKit's rows as the Picker's (the public rule; the editors' own `pickerItemOf` is another, internal one). The words, the
|
|
12
12
|
* second line, the group and whether it can be picked stay as they are; the kind's word comes from the badge; then how its name
|
|
13
|
-
* draws, the first that applies: an avatar where ViewKit hands one (a person, or a company by its kind
|
|
13
|
+
* draws, the first that applies: an avatar where ViewKit hands one (a person, or a company by its kind; the kind itself carried
|
|
14
|
+
* for the app's Avatar atom, so a deal stays a deal, VK-1044), the record's own glyph,
|
|
14
15
|
* a status step, an option, the app's icon (`AppIcon`; without it, none). A step between stands at its quarters among the steps
|
|
15
16
|
* between: the status's active steps when `steps` names them, so one that isn't a step (an archived option held) stands nowhere,
|
|
16
17
|
* as its cell does; else every row on a step between. A category's colour isn't drawn: the Option in the list has one look.
|
|
18
|
+
* With `cells` (ViewKit's Picker, VK-1056), a status and a category are drawn as their cells draw them instead: the app's
|
|
19
|
+
* StatusBadge at its place among the steps and the app's Tag in its colour (the colour the editor resolved, an undeclared
|
|
20
|
+
* option's derived one included), each with its icon; this needs a provider, which the Picker always stands in.
|
|
17
21
|
*/
|
|
18
|
-
export declare function pickerItemsOf(items: readonly ViewsPickerItem[], { AppIcon, steps }?: {
|
|
22
|
+
export declare function pickerItemsOf(items: readonly ViewsPickerItem[], { AppIcon, steps, cells }?: {
|
|
19
23
|
AppIcon?: AppIcon;
|
|
20
24
|
steps?: readonly string[];
|
|
25
|
+
cells?: boolean;
|
|
21
26
|
}): PickerItem[];
|
|
22
27
|
/** The Picker's words in the app's: each from its `views.picker.*` message. */
|
|
23
28
|
export declare function pickerWordsOf(say: ViewsMessageResolver): PickerWords;
|
|
@@ -26,6 +31,6 @@ export declare function pickerWordsOf(say: ViewsMessageResolver): PickerWords;
|
|
|
26
31
|
export declare const menuWordsOf: (say: ViewsMessageResolver) => MenuWords;
|
|
27
32
|
/** What the Picker is handed for ViewKit's props: its rows read as the Picker's, an action's key its id, the shell's draft, its words and its menus'. */
|
|
28
33
|
export declare function pickerPropsOf({ items, actions, steps, ...rest }: ViewsPickerProps, AppIcon?: AppIcon, words?: PickerWords, menuWords?: MenuWords): PickerProps;
|
|
29
|
-
/** ViewKit's pick list,
|
|
34
|
+
/** ViewKit's pick list, its controls the app's where the provider's `panelControls` names them, wherever it stands (VK-1022). */
|
|
30
35
|
export declare function MapPicker(props: ViewsPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
31
36
|
export {};
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useViews } from "../../provider/context.js";
|
|
4
4
|
import { quartersOf, statusPlaceOf } from "../status/atom-status-badge.js";
|
|
5
|
+
import { OptionCategory, OptionStatus } from "../../display/option-badges.js";
|
|
6
|
+
import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
|
|
5
7
|
import { Picker } from "./picker.js";
|
|
6
|
-
export function pickerItemsOf(items, { AppIcon, steps } = {}) {
|
|
8
|
+
export function pickerItemsOf(items, { AppIcon, steps, cells } = {}) {
|
|
7
9
|
const between = (i) => i.avatarUrl === undefined && !i.glyph && !!i.slot && statusPlaceOf(i.slot) === "between";
|
|
8
10
|
const onSteps = items.filter((i) => between(i) && (!steps || steps.includes(i.value)));
|
|
11
|
+
const stepOptions = items.filter((i) => i.avatarUrl === undefined && !i.glyph && !!i.slot && (!steps || steps.includes(i.value))).map((i) => ({ value: i.value, label: i.label, slot: i.slot }));
|
|
12
|
+
const placeOf = (value) => { const index = stepOptions.findIndex((o) => o.value === value); return index < 0 ? undefined : { index, options: stepOptions }; };
|
|
9
13
|
return items.map((i) => {
|
|
10
14
|
const item = { value: i.value, label: i.label };
|
|
11
15
|
if (i.line !== undefined)
|
|
@@ -17,9 +21,13 @@ export function pickerItemsOf(items, { AppIcon, steps } = {}) {
|
|
|
17
21
|
if (i.badge !== undefined)
|
|
18
22
|
item.kind = i.badge;
|
|
19
23
|
if (i.avatarUrl !== undefined)
|
|
20
|
-
item.as = { avatar: i.kind === "company" ? "company" : "person", id: i.value, ...(i.avatarUrl ? { src: i.avatarUrl } : {}) };
|
|
24
|
+
item.as = { avatar: i.kind === "company" ? "company" : "person", id: i.value, ...(i.avatarUrl ? { src: i.avatarUrl } : {}), ...(i.kind !== undefined ? { kind: i.kind } : {}) };
|
|
21
25
|
else if (i.glyph)
|
|
22
26
|
item.as = { mark: i.glyph };
|
|
27
|
+
else if (i.slot && cells)
|
|
28
|
+
item.as = { chip: _jsx(OptionStatus, { slot: i.slot, label: i.label, icon: i.icon, place: placeOf(i.value) }) };
|
|
29
|
+
else if (i.color && cells)
|
|
30
|
+
item.as = { chip: _jsx(OptionCategory, { label: i.label, color: i.color, icon: i.icon }) };
|
|
23
31
|
else if (i.slot) {
|
|
24
32
|
const status = statusPlaceOf(i.slot);
|
|
25
33
|
item.as = status !== "between" ? { status } : { status, quarters: onSteps.includes(i) ? quartersOf(onSteps, i) : 2 };
|
|
@@ -65,12 +73,15 @@ export function pickerPropsOf({ items, actions, steps, ...rest }, AppIcon, words
|
|
|
65
73
|
...rest,
|
|
66
74
|
...(words ? { words } : {}),
|
|
67
75
|
...(menuWords ? { menuWords } : {}),
|
|
68
|
-
items: pickerItemsOf(items, { ...(AppIcon ? { AppIcon } : {}), ...(steps ? { steps } : {}) }),
|
|
76
|
+
items: pickerItemsOf(items, { ...(AppIcon ? { AppIcon } : {}), ...(steps ? { steps } : {}), cells: true }),
|
|
69
77
|
...(actions ? { actions: actions.map((a) => ({ id: a.key, label: a.label, icon: a.icon ?? null, onSelect: a.onSelect })) } : {}),
|
|
70
78
|
draft: "shell",
|
|
71
79
|
};
|
|
72
80
|
}
|
|
73
81
|
export function MapPicker(props) {
|
|
82
|
+
return _jsx(PanelControlsFromViews, { children: _jsx(PickerInner, { ...props }) });
|
|
83
|
+
}
|
|
84
|
+
function PickerInner(props) {
|
|
74
85
|
const { components, messages } = useViews();
|
|
75
86
|
return _jsx(Picker, { ...pickerPropsOf(props, components.AppIcon, pickerWordsOf(messages), menuWordsOf(messages)) });
|
|
76
87
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
|
|
4
|
-
import {
|
|
5
|
-
import { Button } from "../button/button.js";
|
|
4
|
+
import { RecordMark } from "../avatar/record-mark.js";
|
|
6
5
|
import { CheckboxMark } from "../checkbox/checkbox.js";
|
|
7
|
-
import { GlassButton } from "../glass-button/glass-button.js";
|
|
8
6
|
import { Input, InputGroup, InputGroupAddon } from "../input/input.js";
|
|
9
7
|
import { Kbd } from "../kbd/kbd.js";
|
|
10
|
-
import {
|
|
8
|
+
import { menuDotsProps } from "../menu/menu.js";
|
|
11
9
|
import { Option } from "../option/option.js";
|
|
12
10
|
import { Spinner } from "../spinner/spinner.js";
|
|
13
11
|
import { StatusGlyph } from "../status/status.js";
|
|
14
12
|
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
15
13
|
import { partAttrs } from "../internal/part-slot.js";
|
|
14
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
16
15
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
17
16
|
import { cx } from "../../internal/cx.js";
|
|
18
17
|
import { Icon } from "../internal/icons.js";
|
|
@@ -66,6 +65,7 @@ export const PICKER_WORDS = {
|
|
|
66
65
|
you: "you",
|
|
67
66
|
};
|
|
68
67
|
function LeadMark({ lead, value }) {
|
|
68
|
+
const { Button } = usePanelControls();
|
|
69
69
|
if (lead.value === value)
|
|
70
70
|
return _jsx("span", { className: "o-picker-lead", "data-slot": "vk-picker-lead", children: lead.label });
|
|
71
71
|
const stop = (e) => e.stopPropagation();
|
|
@@ -92,6 +92,8 @@ function Name({ item, phone }) {
|
|
|
92
92
|
const as = item.as;
|
|
93
93
|
if (as && "option" in as)
|
|
94
94
|
return _jsx(Option, { size: phone ? "lg" : undefined, children: item.label });
|
|
95
|
+
if (as && "chip" in as)
|
|
96
|
+
return _jsx(_Fragment, { children: as.chip });
|
|
95
97
|
if (as && "status" in as)
|
|
96
98
|
return _jsxs(_Fragment, { children: [_jsx("span", { className: "o-picker-mark", children: _jsx(StatusGlyph, { place: as.status, quarters: as.quarters }) }), item.label] });
|
|
97
99
|
if (as && "sign" in as)
|
|
@@ -104,7 +106,7 @@ function Face({ item, phone, size = 20 }) {
|
|
|
104
106
|
const as = item.as;
|
|
105
107
|
if (!as || !("avatar" in as))
|
|
106
108
|
return null;
|
|
107
|
-
return _jsx(
|
|
109
|
+
return _jsx(RecordMark, { label: item.label, shape: as.avatar === "company" ? "thing" : "person", id: as.id, src: as.src, kind: as.kind, size: phone ? 40 : size });
|
|
108
110
|
}
|
|
109
111
|
const After = ({ item }) => (item.after == null ? null : _jsx("span", { className: "o-picker-after", children: item.after }));
|
|
110
112
|
const lineOf = (item, kind) => kind === "line" && item.kind ? (item.line ? `${item.kind} · ${item.line}` : item.kind) : item.line;
|
|
@@ -182,6 +184,7 @@ export function usePicker(props) {
|
|
|
182
184
|
return usePickerAt(props);
|
|
183
185
|
}
|
|
184
186
|
function usePickerAt(props, under) {
|
|
187
|
+
const { Button, Menu, RoundButton } = usePanelControls();
|
|
185
188
|
const { label, items, multiple, value, onDone, empty, search, onSearch, doing, onRetry, onMore, nothingYet, actions = [], readOnly, none: noneWords } = props;
|
|
186
189
|
const w = { ...PICKER_WORDS, ...props.words };
|
|
187
190
|
const menuWords = { ...props.menuWords, ...(props.words ? { picker: props.words } : {}) };
|
|
@@ -623,7 +626,7 @@ function usePickerAt(props, under) {
|
|
|
623
626
|
setRowMenu({ value: item.value, anchor: e.currentTarget });
|
|
624
627
|
};
|
|
625
628
|
return form === "phone"
|
|
626
|
-
? _jsx(
|
|
629
|
+
? _jsx(Button, { ...menuDotsProps(w.rowActions(item.label), "o-picker-row-menu"), "data-slot": "vk-picker-row-more", "data-key": item.value, onClick: open, onKeyDown: stopKeys })
|
|
627
630
|
: _jsx(Button, { kind: "quiet", shape: "icon", size: "20", tabIndex: -1, className: "o-picker-row-menu", "data-slot": "vk-picker-row-more", "data-key": item.value, "data-shown": props.rowMenus ?? "always", "aria-label": w.rowActions(item.label), icon: glyph(DOTS_V), onClick: open, onKeyDown: stopKeys });
|
|
628
631
|
};
|
|
629
632
|
const hasMenu = (item) => !!item.menu?.length;
|
|
@@ -807,10 +810,10 @@ function usePickerAt(props, under) {
|
|
|
807
810
|
const menu = under ? [] : actions.map((a) => ({ icon: a.icon, label: a.label, onSelect: a.onSelect, slot: { slot: "vk-picker-action", key: a.id } }));
|
|
808
811
|
const underActions = under && !typed && actions.length > 0 && (_jsx("div", { className: "o-picker-under", children: actions.map((a) => _jsx(Button, { kind: "outline", size: "44", icon: a.icon, "data-slot": "vk-picker-action", "data-key": a.id, onClick: a.onSelect, children: a.label }, a.id)) }));
|
|
809
812
|
const showBar = !none && (pill || creatable || addable || menu.length > 0 || (!!level && !byHolder));
|
|
810
|
-
const bar = showBar && (_jsxs("div", { className: "o-picker-bar", children: [level && !byHolder && _jsx(
|
|
813
|
+
const bar = showBar && (_jsxs("div", { className: "o-picker-bar", children: [level && !byHolder && _jsx(RoundButton, { "aria-label": w.back(level.label), icon: glyph(BACK), className: "o-picker-round", "data-slot": "vk-picker-back", "data-back": "", onMouseDown: (e) => e.preventDefault(), onClick: () => back() }), pill && (_jsxs(InputGroup, { size: "lg", className: "o-picker-pill", "data-slot": "vk-picker-search", ...pillTap, children: [_jsx(InputGroupAddon, { side: "start", children: glyph(SEARCH) }), _jsx(Input, { combobox: true, autofill: false, ref: pillInput, placeholder: search, "aria-label": search ?? label, onKeyDown: (e) => { if (!backKey(e))
|
|
811
814
|
enter(e); } })] })), addable ? _jsx(Button, { kind: "primary", size: "lg", icon: glyph(PLUS), loading: adding !== undefined, className: "o-picker-create-button", "data-slot": "vk-picker-add", onClick: () => onAdd(typed), children: w.addButton })
|
|
812
815
|
: creatable && !add ? _jsx(Button, { kind: "primary", size: "lg", icon: glyph(PLUS), className: "o-picker-create-button", "data-slot": "vk-picker-create", onClick: createTyped, children: w.createButton })
|
|
813
|
-
: menu.length > 0 && _jsx(Menu, { label: label, entries: menu, words: menuWords, trigger: _jsx(
|
|
816
|
+
: menu.length > 0 && _jsx(Menu, { label: label, entries: menu, words: menuWords, trigger: _jsx(RoundButton, { "aria-label": w.actions, icon: glyph(DOTS), className: "o-picker-round", "data-slot": "vk-picker-more" }) })] }));
|
|
814
817
|
const menuOpen = (item) => (menuOpenFor(item.value) ? { "data-menu-open": "" } : {});
|
|
815
818
|
const heldHere = (v) => inPlace && kept.includes(v);
|
|
816
819
|
const rowValue = (item) => (heldHere(item.value) && !changing ? { key: `unpick:${item.value}`, kind: "unpick", item } : itemEntry(item));
|
|
@@ -2,10 +2,14 @@ import type { PartSlot } from "../internal/part-slot.js";
|
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import type { StatusPlace } from "../status/status.js";
|
|
4
4
|
import type { MenuEntry } from "../menu-list/menu-list.js";
|
|
5
|
-
/** How a row draws its name: an Option chip (a select's value), a step with its Status glyph, an Avatar before it
|
|
6
|
-
*
|
|
5
|
+
/** How a row draws its name: an Option chip (a select's value), a step with its Status glyph, an Avatar before it (its `kind` the
|
|
6
|
+
* record's kind as the app names it, handed to the app's Avatar atom where the provider opts it in, VK-1044), a sign
|
|
7
|
+
* before it (a currency's €), a mark before it (a country's flag), a chip drawn in place of its words (a field's option as its
|
|
8
|
+
* cell draws it, VK-1056), or, left out, plain words. */
|
|
7
9
|
export type PickerAs = {
|
|
8
10
|
option: true;
|
|
11
|
+
} | {
|
|
12
|
+
chip: ReactNode;
|
|
9
13
|
} | {
|
|
10
14
|
status: StatusPlace;
|
|
11
15
|
quarters?: 1 | 2 | 3;
|
|
@@ -13,6 +17,7 @@ export type PickerAs = {
|
|
|
13
17
|
avatar: "person" | "company";
|
|
14
18
|
id?: string;
|
|
15
19
|
src?: string;
|
|
20
|
+
kind?: string;
|
|
16
21
|
} | {
|
|
17
22
|
sign: string;
|
|
18
23
|
} | {
|
|
@@ -30,7 +30,7 @@ function markOf(item) {
|
|
|
30
30
|
return as.quarters ? { status, quarters: as.quarters } : { status };
|
|
31
31
|
}
|
|
32
32
|
if ("avatar" in as)
|
|
33
|
-
return { avatar: as.avatar, ...(as.id ? { id: as.id } : {}) };
|
|
33
|
+
return { avatar: as.avatar, ...(as.id ? { id: as.id } : {}), ...(as.src ? { src: as.src } : {}), ...(as.kind !== undefined ? { kind: as.kind } : {}) };
|
|
34
34
|
return undefined;
|
|
35
35
|
}
|
|
36
36
|
export function quickFiltersFieldsOf(fields) {
|
|
@@ -50,6 +50,7 @@ export const quickFiltersWordsOf = (say) => ({
|
|
|
50
50
|
search: (field) => say({ key: "views.panels.quick-search", values: { field } }),
|
|
51
51
|
clear: say({ key: "views.panels.quick-clear-value" }),
|
|
52
52
|
none: say({ key: "views.panels.quick-none" }),
|
|
53
|
+
nothing: say({ key: "views.panels.filter-no-options" }),
|
|
53
54
|
});
|
|
54
55
|
export function MapQuickFiltersBody(props) {
|
|
55
56
|
return _jsx(PanelControlsFromViews, { children: _jsx(QuickFiltersBodyInner, { ...props }) });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { RecordMark } from "../avatar/record-mark.js";
|
|
6
6
|
import { InputGroup, InputGroupAddon } from "../input/input.js";
|
|
7
7
|
import { usePanelControls } from "../internal/panel-controls.js";
|
|
8
8
|
import { Icon } from "../internal/icons.js";
|
|
@@ -30,7 +30,7 @@ function Mark({ value, phone }) {
|
|
|
30
30
|
return null;
|
|
31
31
|
return _jsx("span", { className: "o-quick-filters-mark", "aria-hidden": "true", children: "status" in m
|
|
32
32
|
? _jsx(StatusGlyph, { place: m.status, quarters: m.quarters })
|
|
33
|
-
: _jsx(
|
|
33
|
+
: _jsx(RecordMark, { label: value.label, shape: m.avatar === "company" ? "thing" : "person", id: m.id, picture: m.src, kind: m.kind, size: phone ? 24 : 20 }) });
|
|
34
34
|
}
|
|
35
35
|
function Values({ field, values, held, several, onPress, search, phone, clear }) {
|
|
36
36
|
const [at, setAt] = React.useState(() => Math.max(0, values.findIndex((v) => held.includes(v.value)))), rows = React.useRef([]);
|
|
@@ -85,7 +85,7 @@ export function QuickFilters({ fields, holds, onHoldsChange, open: openGiven, on
|
|
|
85
85
|
root.current?.querySelector(".o-quick-filters-value")?.focus();
|
|
86
86
|
};
|
|
87
87
|
return (_jsxs("div", { ref: root, className: cx("o-quick-filters", className), "data-slot": "vk-quick", "data-kit": "quick-filters", "data-form": form, children: [_jsxs("div", { className: "o-quick-filters-top", children: [_jsx(ToggleGroup, { "aria-label": w.fields, kind: "pill", size: phone ? "sm" : "xs", spacing: phone ? 2 : 1.5, value: [field.id], onValueChange: (v) => { if (v[0])
|
|
88
|
-
show(v[0]); }, className: "o-quick-filters-strip", "data-slot": "vk-quick-strip", children: fields.map((f) => _jsx(Toggle, { value: f.id, "data-slot": "vk-quick-field", "data-key": f.id, children: f.name }, f.id)) }), searching && (_jsxs(InputGroup, { size: phone ? "lg" : "sm", chrome: "soft", "data-slot": "vk-quick-search", children: [_jsx(InputGroupAddon, { children: _jsx(Icon, { name: "search" }) }), _jsx(Input, { ref: searchBox, value: query, onValueChange: setQuery, placeholder: field.search, "aria-label": field.search ?? w.search(field.name), onKeyDown: toFirst })] }))] }), values.length
|
|
88
|
+
show(v[0]); }, className: "o-quick-filters-strip", "data-slot": "vk-quick-strip", children: fields.map((f) => _jsx(Toggle, { value: f.id, "data-slot": "vk-quick-field", "data-key": f.id, children: f.name }, f.id)) }), searching && (_jsxs(InputGroup, { size: phone ? "lg" : "sm", chrome: "soft", "data-slot": "vk-quick-search", children: [_jsx(InputGroupAddon, { children: _jsx(Icon, { name: "search" }) }), _jsx(Input, { ref: searchBox, value: query, onValueChange: setQuery, placeholder: field.search, "aria-label": field.search ?? w.search(field.name), onKeyDown: toFirst })] }))] }), values.length
|
|
89
89
|
? _jsx(Values, { field: field, values: values, held: heldIn(holds, field.id), several: holding === "several", onPress: press, search: searchBox, phone: phone, clear: w.clear }, `${field.id}:${query}`)
|
|
90
|
-
: _jsx("p", { className: "o-quick-filters-none", "data-slot": "vk-quick-none", role: "status", children: w.none })] }));
|
|
90
|
+
: _jsx("p", { className: "o-quick-filters-none", "data-slot": "vk-quick-none", role: "status", children: query ? w.none : w.nothing })] }));
|
|
91
91
|
}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
5
5
|
import { cx as cn } from "../../internal/cx.js";
|
|
6
|
-
import {
|
|
6
|
+
import { RecordMark } from "../avatar/record-mark.js";
|
|
7
7
|
import { Button } from "../button/button.js";
|
|
8
8
|
import { Icon } from "../internal/icons.js";
|
|
9
9
|
import { StatusGlyph } from "../status/status.js";
|
|
@@ -16,7 +16,7 @@ function Mark({ held }) {
|
|
|
16
16
|
return null;
|
|
17
17
|
return _jsx("span", { className: "o-quick-filters-mark", "aria-hidden": "true", children: "status" in m
|
|
18
18
|
? _jsx(StatusGlyph, { place: m.status, quarters: m.quarters })
|
|
19
|
-
: _jsx(
|
|
19
|
+
: _jsx(RecordMark, { label: held.name, shape: m.avatar === "company" ? "thing" : "person", id: m.id, picture: m.src, kind: m.kind, size: 24 }) });
|
|
20
20
|
}
|
|
21
21
|
export function QuickFiltersReminderControl({ fields, holds, onOpen, onClear, words: given, className }) {
|
|
22
22
|
const spoken = quickFiltersReminderWords(given);
|
|
@@ -18,13 +18,16 @@ export interface QuickValue {
|
|
|
18
18
|
mark?: QuickMark;
|
|
19
19
|
count?: number;
|
|
20
20
|
}
|
|
21
|
-
/** A value's mark: a stage's Status glyph, or a person's or a company's face
|
|
21
|
+
/** A value's mark: a stage's Status glyph, or a person's or a company's face; its `src` and `kind` (the record's kind as the app
|
|
22
|
+
* names it) are handed only to the app's Avatar atom, where the provider's `panelControls` names `Avatar` (VK-1044). */
|
|
22
23
|
export type QuickMark = {
|
|
23
24
|
status: "start" | "between" | "won" | "lost";
|
|
24
25
|
quarters?: 1 | 2 | 3;
|
|
25
26
|
} | {
|
|
26
27
|
avatar: "person" | "company";
|
|
27
28
|
id?: string;
|
|
29
|
+
src?: string;
|
|
30
|
+
kind?: string;
|
|
28
31
|
};
|
|
29
32
|
/** A field's values past this many show a search over them (round 9: "past a handful"; the kit's lists search past 8). */
|
|
30
33
|
export declare const SEARCH_PAST = 8;
|
|
@@ -7,6 +7,8 @@ export interface QuickFiltersWords {
|
|
|
7
7
|
clear: string;
|
|
8
8
|
/** What a search that finds nothing says ("Nothing matches."). */
|
|
9
9
|
none: string;
|
|
10
|
+
/** What a field with no value to pick says, nothing typed ("Nothing to pick."). */
|
|
11
|
+
nothing: string;
|
|
10
12
|
}
|
|
11
13
|
export declare const QUICK_FILTERS_WORDS: QuickFiltersWords;
|
|
12
14
|
/** The words handed, each left out the English. */
|
|
@@ -3,6 +3,7 @@ export const QUICK_FILTERS_WORDS = {
|
|
|
3
3
|
search: (field) => `Search ${field}`,
|
|
4
4
|
clear: "Clear filter",
|
|
5
5
|
none: "Nothing matches.",
|
|
6
|
+
nothing: "Nothing to pick.",
|
|
6
7
|
};
|
|
7
8
|
export const quickFiltersWords = (given) => given ? { ...QUICK_FILTERS_WORDS, ...Object.fromEntries(Object.entries(given).filter(([, w]) => w !== undefined)) } : QUICK_FILTERS_WORDS;
|
|
8
9
|
export const QUICK_FILTERS_REMINDER_WORDS = {
|
|
@@ -10,6 +10,9 @@ export interface SelectItem {
|
|
|
10
10
|
mark?: React.ReactNode;
|
|
11
11
|
you?: boolean;
|
|
12
12
|
group?: string;
|
|
13
|
+
/** Its mark is your own Avatar atom (`ViewsAvatarProps`): a typed field's chip draws it again at `size: "chip"` (VK-1044).
|
|
14
|
+
* ViewKit's own Avatar needs no flag: it is drawn again at 16. */
|
|
15
|
+
avatar?: boolean;
|
|
13
16
|
/** It can't be picked: greyed, passed over by the keys. */
|
|
14
17
|
disabled?: boolean;
|
|
15
18
|
/** A line above it, setting it apart from the rows before. */
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
|
|
5
5
|
import { Field as BaseField } from "@base-ui/react/field";
|
|
6
|
-
import {
|
|
6
|
+
import { isAvatarMark } from "../avatar/avatar-mark.js";
|
|
7
7
|
import { Button, buttonClass } from "../button/button.js";
|
|
8
8
|
import { Field } from "../field/field.js";
|
|
9
9
|
import { Input, InputGroupAddon } from "../input/input.js";
|
|
@@ -42,7 +42,13 @@ export function Select(props) {
|
|
|
42
42
|
return _jsx(SheetSelect, { ...props });
|
|
43
43
|
return _jsx(PickerSelect, { ...props });
|
|
44
44
|
}
|
|
45
|
-
const chipMark = (
|
|
45
|
+
const chipMark = ({ mark, avatar }) => {
|
|
46
|
+
if (!React.isValidElement(mark))
|
|
47
|
+
return mark;
|
|
48
|
+
if (isAvatarMark(mark.type))
|
|
49
|
+
return React.cloneElement(mark, { size: 16 });
|
|
50
|
+
return avatar ? React.cloneElement(mark, { size: "chip" }) : mark;
|
|
51
|
+
};
|
|
46
52
|
export const toPickerItems = (items, chips) => items.map((i) => ({ value: i.value, label: i.label, line: i.line, you: i.you, group: i.group, disabled: i.disabled, divider: i.divider,
|
|
47
53
|
as: chips ? { option: true } : i.mark ? { mark: i.mark } : undefined, ...(i.level ? { level: toPickerItems(i.level, chips) } : {}) }));
|
|
48
54
|
const titleOf = (p) => (typeof p.label === "string" ? p.label : p["aria-label"] ?? p.placeholder ?? "Choose");
|
|
@@ -110,7 +116,7 @@ function TypedBox({ p, f, trigger, field, hint, search }) {
|
|
|
110
116
|
const one = !multiple && f.chosen.length === 1 ? f.chosen[0] : undefined;
|
|
111
117
|
const slot = one?.mark != null && (_jsxs(InputGroupAddon, { side: "start", className: "o-select-mark", "aria-hidden": "true", "data-searching": q !== one.label ? "" : undefined, children: [_jsx("span", { className: "o-select-mark-own", children: one.mark }), glyph(SEARCH, "o-select-mark-search")] }));
|
|
112
118
|
const box = (_jsx(Input, { combobox: true, chrome: "bare", ref: input, className: "o-select-typed-input", placeholder: multiple && f.chosen.length ? undefined : hint, onKeyDown: search.onKeyDown, ...search.attrs, ...(p.label != null ? {} : { "aria-label": p["aria-label"] }) }));
|
|
113
|
-
return (_jsxs(BaseCombobox.InputGroup, { ref: field, className: cx("o-input o-input-group o-select-field o-select-typed o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-slot": p["data-slot"], "data-key": p["data-key"], "data-kit": "select", ...mark, ...busy(p), onMouseDown: keep, children: [slot, multiple ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "o-select-measure", "aria-hidden": "true", inert: true, children: _jsxs("span", { ref: measure, children: [f.chosen.map((i) => _jsx(Option, { icon: chipMark(i
|
|
119
|
+
return (_jsxs(BaseCombobox.InputGroup, { ref: field, className: cx("o-input o-input-group o-select-field o-select-typed o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-slot": p["data-slot"], "data-key": p["data-key"], "data-kit": "select", ...mark, ...busy(p), onMouseDown: keep, children: [slot, multiple ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "o-select-measure", "aria-hidden": "true", inert: true, children: _jsxs("span", { ref: measure, children: [f.chosen.map((i) => _jsx(Option, { icon: chipMark(i), onRemove: () => { }, children: i.label }, i.value)), _jsx(Option, { count: n }), _jsx("span", { className: "o-select-measure-words", children: q })] }) }), _jsxs(BaseCombobox.Chips, { ref: chipsBox, className: "o-select-chips", children: [f.chosen.map((i, at) => _jsx(BaseCombobox.Chip, { "data-over": at >= fit ? "" : undefined, render: _jsx(Option, { icon: chipMark(i), onRemove: () => f.setValue(f.value.filter((v) => v !== i.value)) }), children: i.label }, i.value)), fit < n && _jsx(Option, { count: n - fit }), box] })] })) : box, !small && !disabled && !p.readOnly && f.chosen.length > 0 && (_jsx(BaseCombobox.Clear, { render: (props) => _jsx(Button, { ...props, kind: "quiet", size: "2xs", shape: "icon", className: "o-select-clear", "aria-label": "Clear", icon: glyph(X, ""), children: null }) })), _jsx(SaveMark, { saving: p.saving, saved: p.saved }), _jsx(BaseCombobox.Trigger, { ref: trigger, className: "o-select-chevron o-select-typed-trigger", tabIndex: -1, "aria-label": `Show every ${typeof p.label === "string" ? p.label.toLowerCase() : "choice"}`, children: glyph(CHEVRON, "") })] }));
|
|
114
120
|
}
|
|
115
121
|
const gapOf = (at) => spacingPx(1, at), edgeOf = (at) => spacingPx(1.25, at);
|
|
116
122
|
function listNeed(at, rows, lines) {
|
|
@@ -12,6 +12,8 @@ export type SortEditorOpens = {
|
|
|
12
12
|
export interface SortEditorProps {
|
|
13
13
|
/** What it sorts, as its shell names it ("Sort"): the Sheet's title on a phone, and the rules' name to a screen reader. */
|
|
14
14
|
label: string;
|
|
15
|
+
/** Clear all at its foot; default on. Off inside Customize, where its page's Reset stands in its place (VK-1034). */
|
|
16
|
+
clearAll?: boolean;
|
|
15
17
|
/** The fields a list sorts by, each with its type's mark; one leading one level in (a deal's Company) holds its own. */
|
|
16
18
|
fields: PickerItem[];
|
|
17
19
|
/** The view's rules, the first sorting first. */
|
|
@@ -10,7 +10,6 @@ import { moved, useReorder } from "../internal/reorder.js";
|
|
|
10
10
|
import { useStepReturn } from "../internal/step-return.js";
|
|
11
11
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
12
12
|
import { findItem, itemLabel } from "../picker/rows.js";
|
|
13
|
-
import { Tooltip } from "../tooltip/tooltip.js";
|
|
14
13
|
import { addSort, canAddSort, dropAside, openPlaces, putBack, repoint, SORT_MAX, takenBy } from "./rules.js";
|
|
15
14
|
import { sortWords } from "./words.js";
|
|
16
15
|
const ASCENDING = ["M4 6l7 0", "M4 12l7 0", "M4 18l9 0", "M15 9l3 -3l3 3", "M18 6l0 12"];
|
|
@@ -30,8 +29,8 @@ function fieldsFor(fields, rules, sorted, own, fieldOf) {
|
|
|
30
29
|
}
|
|
31
30
|
export const sortableFields = (fields, rules, fieldOf, sorted = sortWords().sorted) => fieldsFor(fields, rules, sorted, undefined, fieldOf);
|
|
32
31
|
export function useSortEditor(props) {
|
|
33
|
-
const { label, fields, rules, onRulesChange, max = SORT_MAX, onDone, opens, fieldOf, addSort: adds = true } = props;
|
|
34
|
-
const { Button, Select, Menu, Popover } = usePanelControls();
|
|
32
|
+
const { label, fields, rules, onRulesChange, max = SORT_MAX, onDone, opens, fieldOf, addSort: adds = true, clearAll: clears = true } = props;
|
|
33
|
+
const { Button, Select, Menu, Popover, Tooltip } = usePanelControls();
|
|
35
34
|
const aside = React.useMemo(() => props.aside ?? [], [props.aside]);
|
|
36
35
|
const w = sortWords(props.words), search = props.search ?? w.search, DIRECTIONS = directionsOf(w);
|
|
37
36
|
const words = w.picker ? { words: w.picker } : {};
|
|
@@ -157,7 +156,7 @@ export function useSortEditor(props) {
|
|
|
157
156
|
const popAside = pop?.list === "repoint" ? aside.find((a) => a.key === pop.key) : undefined;
|
|
158
157
|
const body = (_jsxs("div", { ref: placeRoot, className: "o-sort-editor", "data-slot": "vk-sort", "data-kit": "sort-editor", "data-sort-form": way, role: narrow ? "group" : undefined, "aria-label": narrow ? label : undefined, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-sort-step": stepTitle !== undefined ? step?.list : undefined, children: [stepTitle !== undefined ? stepList.body : _jsxs(_Fragment, { children: [rules.length || aside.length ? (phone
|
|
159
158
|
? _jsxs(FieldRows, { look: ROWS, className: "o-sort-editor-card", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })
|
|
160
|
-
: _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })) : (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })), _jsxs("div", { className: "o-sort-editor-acts", "data-slot": "vk-sort-foot", children: [addButton(size), rules.length > 0 && _jsx(Button, { kind: "quiet", size: size, className: "o-sort-editor-clear", "data-slot": "vk-sort-clear", onClick: () => change([]), children: w.clearAll })] })] }), narrow && (_jsx(Popover, { open: !!pop && (pop.list === "add" || !!popRule || !!popAside), onOpenChange: (o) => { if (!o)
|
|
159
|
+
: _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })) : (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })), _jsxs("div", { className: "o-sort-editor-acts", "data-slot": "vk-sort-foot", children: [addButton(size), clears && rules.length > 0 && _jsx(Button, { kind: "quiet", size: size, className: "o-sort-editor-clear", "data-slot": "vk-sort-clear", onClick: () => change([]), children: w.clearAll })] })] }), narrow && (_jsx(Popover, { open: !!pop && (pop.list === "add" || !!popRule || !!popAside), onOpenChange: (o) => { if (!o)
|
|
161
160
|
closePop(); }, anchor: pop?.at, className: "o-sort-editor-pop", "aria-label": pop?.list === "add" ? w.add : popAside ? w.fieldNamed(popAside.label) : popRule ? nameOf(popRule.field) : label, children: pop?.list === "add"
|
|
162
161
|
? addPicker
|
|
163
162
|
: popAside ? _jsx(Picker, { label: w.fieldNamed(popAside.label), items: pickable(), value: null, search: search, searchShown: true, form: "computer", defaultLevel: props.level, onDone: closePop, onValueChange: (v) => { pointAt(popAside.key)(v); closePop(); }, ...words })
|
|
@@ -169,7 +168,7 @@ export function useSortEditor(props) {
|
|
|
169
168
|
const items = pickable(r.field);
|
|
170
169
|
return (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: [_jsx(Grip, { label: w.move(name), className: "o-sort-editor-grip", "data-slot": "vk-sort-grip", ...g }), _jsxs("div", { className: "o-sort-editor-field", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.field, "data-slot": "vk-sort-field", items: asSelect(items), value: r.field, search: search, "data-force": open === "field" ? "focus" : undefined, onValueChange: (v) => { if (typeof v === "string" && v !== r.field && !takenBy(now.current, v, r.field, fieldOf))
|
|
171
170
|
change(now.current.map((x, k) => (k === i ? { ...x, field: v } : x))); } }), open === "field" && shownList(items, r.field, w.field, true)] }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: r.direction, "data-force": open === "direction" ? "focus" : undefined, onValueChange: turn(i) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) }), open === "direction" && shownList(DIRECTIONS, r.direction, w.direction, false)] }), _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-remove", "data-slot": "vk-sort-remove", "aria-label": w.remove(name), icon: glyph(X), onClick: () => remove(i) })] }, r.field));
|
|
172
|
-
}), aside.map((a) => (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: [_jsx("span", { className: "o-sort-editor-grip-place", "aria-hidden": "true" }), _jsx("div", { className: "o-sort-editor-field", children: _jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.fieldNamed(a.label), "data-slot": "vk-sort-field", items: asSelect(pickable()), value: null, placeholder: a.label, search: search, onValueChange: pointAt(a.key) }) }) }) }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: a.direction, disabled: true, onValueChange: () => { } }) }) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) })] }), _jsx(Menu, { label: w.sortBy(a.label), align: "end", entries: asideEntries(a), trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(a.label), icon: glyph(DOTS) }) })] }, `aside-${a.key}`)))] }), (adds || rules.length > 0) && _jsxs("div", { className: "o-sort-editor-foot", "data-slot": "vk-sort-foot", children: [adds && addButton("sm"), rules.length > 0 && _jsx(Button, { kind: "quiet", size: "sm", className: "o-sort-editor-clear", "data-slot": "vk-sort-clear", onClick: () => { closePop(); change([]); if (!asideNow.current.length)
|
|
171
|
+
}), aside.map((a) => (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: [_jsx("span", { className: "o-sort-editor-grip-place", "aria-hidden": "true" }), _jsx("div", { className: "o-sort-editor-field", children: _jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.fieldNamed(a.label), "data-slot": "vk-sort-field", items: asSelect(pickable()), value: null, placeholder: a.label, search: search, onValueChange: pointAt(a.key) }) }) }) }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: a.direction, disabled: true, onValueChange: () => { } }) }) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) })] }), _jsx(Menu, { label: w.sortBy(a.label), align: "end", entries: asideEntries(a), trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(a.label), icon: glyph(DOTS) }) })] }, `aside-${a.key}`)))] }), (adds || (clears && rules.length > 0)) && _jsxs("div", { className: "o-sort-editor-foot", "data-slot": "vk-sort-foot", children: [adds && addButton("sm"), clears && rules.length > 0 && _jsx(Button, { kind: "quiet", size: "sm", className: "o-sort-editor-clear", "data-slot": "vk-sort-clear", onClick: () => { closePop(); change([]); if (!asideNow.current.length)
|
|
173
172
|
onDone?.(); }, children: w.clearAllSorts })] }), _jsx(Popover, { open: pop?.list === "add", onOpenChange: (o) => { if (!o)
|
|
174
173
|
closePop(); }, anchor: pop?.at, className: "o-sort-editor-pop", "aria-label": w.add, children: pop?.list === "add" && addPicker })] }) }));
|
|
175
174
|
return { body, head: {} };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
3
3
|
import { type InputProps } from "../input/input.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type ToolbarButtonProps } from "../toolbar-button/toolbar-button.js";
|
|
5
5
|
import { type ToolbarPicks } from "./looks.js";
|
|
6
6
|
import { type ToolbarWords } from "./words.js";
|
|
7
7
|
/** Where a list's part stands: on the row (where it begins), on the row's right, on the filter bar, or on a phone's one line. */
|
|
@@ -57,13 +57,16 @@ export interface ToolbarProps extends Omit<BaseToolbar.Root.Props, "className" |
|
|
|
57
57
|
spacing?: number;
|
|
58
58
|
/** Whether what doesn't fit gives way (words to icons, then into ⋯); otherwise it runs past its end. */
|
|
59
59
|
fold?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* it
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
|
|
60
|
+
/** ⋯ as the app draws it, where what doesn't fit folds (VK-1031): `icon`, its glyph over ViewKit's dots; `className`, put on
|
|
61
|
+
* it; `button`, the app's own button drawn in place of the Toolbar button, handed the very props it would get (`ref`, and what
|
|
62
|
+
* its Menu sets to open from it, included): spread them on your button. Absent, ViewKit's own ⋯. */
|
|
63
|
+
overflow?: ToolbarOverflowControl;
|
|
64
|
+
/** "+N" on the view tabs as the app draws it (VK-1037): `className`, put on it; `button`, the app's own button drawn in place of
|
|
65
|
+
* the Toolbar button, handed the very props it would get (`ref`, its words, and what its Menu, or `onMoreViews`, sets to open
|
|
66
|
+
* from it, included): spread them on your button. Absent, ViewKit's own "+N". */
|
|
67
|
+
moreViews?: ToolbarMoreControl;
|
|
68
|
+
/** "+N filters" as the app draws it, the same way as `moreViews` (VK-1037). Absent, ViewKit's own. */
|
|
69
|
+
moreFilters?: ToolbarMoreControl;
|
|
67
70
|
/** Holds every line as it stands, giving way no further and taking no step back: while what a folded item opened stands open
|
|
68
71
|
* under the button that holds it ("+N filters", ⋯), so that button keeps its place (KIT-624). */
|
|
69
72
|
holds?: boolean;
|
|
@@ -77,6 +80,17 @@ export interface ToolbarProps extends Omit<BaseToolbar.Root.Props, "className" |
|
|
|
77
80
|
className?: string;
|
|
78
81
|
style?: React.CSSProperties;
|
|
79
82
|
}
|
|
83
|
+
/** ⋯ as the app draws it: its glyph, its class, or its whole button, handed a Toolbar button's props. */
|
|
84
|
+
export type ToolbarOverflowControl = {
|
|
85
|
+
icon?: React.ReactNode;
|
|
86
|
+
className?: string;
|
|
87
|
+
button?: React.ComponentType<ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
88
|
+
};
|
|
89
|
+
/** "+N" or "+N filters" as the app draws it: its class, or its whole button, handed a Toolbar button's props (VK-1037). */
|
|
90
|
+
export type ToolbarMoreControl = {
|
|
91
|
+
className?: string;
|
|
92
|
+
button?: React.ComponentType<ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
93
|
+
};
|
|
80
94
|
type Step = {
|
|
81
95
|
i: number;
|
|
82
96
|
to: "icon" | "fold";
|
|
@@ -94,13 +108,12 @@ export interface ToolbarFoldsProps {
|
|
|
94
108
|
export declare function ToolbarFolds({ children }: ToolbarFoldsProps): React.ReactNode;
|
|
95
109
|
/** The steps a line takes as it narrows, in order: words to icons from its end; then the view tabs fold into "+N" from their end,
|
|
96
110
|
* the views giving way before the tools, as the portal's row does; then the filters fold into "+N filters" from their end, only
|
|
97
|
-
* once nothing else gives words up (KIT-624); then the rest folds into ⋯ from its end.
|
|
98
|
-
|
|
99
|
-
declare function stepsOf(items: React.ReactElement[], fill?: boolean): Step[];
|
|
111
|
+
* once nothing else gives words up (KIT-624); then the rest folds into ⋯ from its end. */
|
|
112
|
+
declare function stepsOf(items: React.ReactElement[]): Step[];
|
|
100
113
|
/** The steps a line takes as it narrows, for a test (stepsOf). */
|
|
101
114
|
export declare const toolbarSteps: typeof stepsOf;
|
|
102
115
|
/** The row and, under it, the filter bar: Base UI's toolbar, one Tab stop for the whole of it, the arrows inside. */
|
|
103
|
-
export declare function ToolbarControl({ label, children, bar, barLabel: barNamed, words: given, views, settings, search, add, sort, filter, filters, save, quick, added, picks: said, size, barSize, spacing, fold,
|
|
116
|
+
export declare function ToolbarControl({ label, children, bar, barLabel: barNamed, words: given, views, settings, search, add, sort, filter, filters, save, quick, added, picks: said, size, barSize, spacing, fold, overflow, moreViews: ownViews, moreFilters: ownFilters, holds, form, onMoreViews, moreViewsOpen, className, style, onKeyDown, ...props }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
104
117
|
/** A line between what belongs together and what doesn't, across a line. `data-slot`, its public name where a part names it
|
|
105
118
|
* (VK-1023: the bulk bar's `vk-bulk-separator`). */
|
|
106
119
|
export declare function ToolbarSeparatorControl({ className, "data-slot": slot }: {
|