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
|
@@ -98,14 +98,12 @@ export function customizeWriteOf(p, own, now, next) {
|
|
|
98
98
|
return null;
|
|
99
99
|
return () => viewKit.onColumnsChange(next.columns.map((c) => ({ id: c.id, hidden: !c.shown })));
|
|
100
100
|
}
|
|
101
|
-
const toggleOf = (t) => ({ key: t.key, label: t.label, value: t.value, onChange: t.onChange, ...(t.icon != null && { icon: t.icon }), ...(t.
|
|
101
|
+
const toggleOf = (t) => ({ key: t.key, label: t.label, value: t.value, onChange: t.onChange, ...(t.icon != null && { icon: t.icon }), ...(t.section && { section: t.section }) });
|
|
102
102
|
const choiceOf = (c) => ({ key: c.key, label: c.label, value: c.value, options: [...c.options], onChange: c.onChange });
|
|
103
103
|
function layoutSettingsOf(layout) {
|
|
104
104
|
return {
|
|
105
105
|
choices: [...(layout.density ? [choiceOf(layout.density)] : []), ...layout.choices.map(choiceOf)],
|
|
106
106
|
toggles: layout.toggles.map(toggleOf),
|
|
107
|
-
...(layout.personal && { personal: { label: layout.personal.label, toggles: layout.personal.toggles.map(toggleOf), choices: layout.personal.choices.map(choiceOf),
|
|
108
|
-
...(layout.personal.onReset && { onReset: layout.personal.onReset }) } }),
|
|
109
107
|
};
|
|
110
108
|
}
|
|
111
109
|
const NO_SORT = { label: "", options: [], rules: [], setAside: [], max: 1, addSort: true, onRulesChange() { } };
|
|
@@ -127,25 +125,27 @@ function CustomizeBodyInner(props) {
|
|
|
127
125
|
const groupWords = React.useMemo(() => groupEditorWordsOf(say), [say]);
|
|
128
126
|
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
129
127
|
const editorForm = phone ? "phone" : "narrow";
|
|
128
|
+
const marked = (page) => (p.resets ? !!p.resets[page] : undefined);
|
|
130
129
|
const sortProps = sortEditorPropsOf({ ...(p.sort ?? NO_SORT), form: p.form, onDone: stay }, sortWords, say);
|
|
131
|
-
const
|
|
130
|
+
const clearAll = !p.resets;
|
|
131
|
+
const sorting = useSortEditor({ ...sortProps, form: editorForm, onDone: undefined, clearAll });
|
|
132
132
|
const sortSaid = sortLabel(sortProps.rules, sortProps.fields);
|
|
133
|
-
const sort = p.sort && { says: sortSaid ? `${sortSaid.first}${sortSaid.more ? ` +${sortSaid.more}` : ""}` : w.none, inForce: !!sortSaid,
|
|
133
|
+
const sort = p.sort && { says: sortSaid ? `${sortSaid.first}${sortSaid.more ? ` +${sortSaid.more}` : ""}` : w.none, inForce: marked("sort") ?? !!sortSaid,
|
|
134
134
|
opens: sorting.body, level: levelOf(sorting) };
|
|
135
135
|
const filterHanded = { ...(p.filter ?? NO_FILTER), form: p.form, onDone: stay };
|
|
136
136
|
const map = useMapFilterBody(filterHanded, filterWords, say, views?.components.AppIcon, wayWord);
|
|
137
137
|
const filtering = useFilterEditor({ label: filterHanded.label, fields: map.kit.fields, filter: map.filter, levels: filterHanded.levels, form: editorForm, onFilterChange: map.change,
|
|
138
|
-
own: map.own, words: filterWords });
|
|
138
|
+
own: map.own, words: filterWords, clearAll });
|
|
139
139
|
const ruleCount = rulesOf(map.filter).length;
|
|
140
|
-
const filter = p.filter && { says: ruleCount > 0 ? String(ruleCount) : w.none, inForce: ruleCount > 0, opens: filtering.body, level: levelOf(filtering) };
|
|
140
|
+
const filter = p.filter && { says: ruleCount > 0 ? String(ruleCount) : w.none, inForce: marked("filter") ?? ruleCount > 0, opens: filtering.body, level: levelOf(filtering) };
|
|
141
141
|
const groupProps = groupEditorPropsOf({ ...(p.group ?? NO_GROUP), form: p.form, onDone: stay }, groupWords);
|
|
142
142
|
const grouping = useGroupEditor(groupProps);
|
|
143
|
-
const group = p.group && { says: groupLabel(groupProps.group, groupProps.fields, w.none), inForce: p.group.group.value !== "none",
|
|
143
|
+
const group = p.group && { says: groupLabel(groupProps.group, groupProps.fields, w.none), inForce: marked("group") ?? p.group.group.value !== "none",
|
|
144
144
|
opens: grouping.body, level: grouping.level };
|
|
145
145
|
const view = { name: onRename ? name ?? "" : "", layout: p.layout?.value ?? "", columns: columnsOf(p, say), counts: false, freeze: false, wrap: false };
|
|
146
146
|
const shared = p.view, kit = p.foot === "kit";
|
|
147
|
-
const foot = shared ? (shared.changes > 0 && p.foot !== "none" ? {
|
|
148
|
-
changed: true, onReset: shared.onReset, ...(shared.canPublish && { onSave: shared.onPublish }), pending: shared.pending, stale: shared.stale,
|
|
147
|
+
const foot = shared ? ((shared.changes > 0 || shared.layered) && p.foot !== "none" ? {
|
|
148
|
+
changed: true, onReset: shared.onReset, ...(shared.canPublish && shared.changes > 0 && { onSave: shared.onPublish }), pending: shared.pending, stale: shared.stale,
|
|
149
149
|
words: { reset: say({ key: kit ? "views.panels.view-clear" : "views.panels.view-reset" }), save: say({ key: kit ? "views.panels.view-save" : shared.own ? "views.panels.view-save-own" : "views.panels.view-publish" }) },
|
|
150
150
|
} : {}) : p.onClear && p.foot !== "none" ? { changed: true, onReset: p.onClear, words: { reset: say({ key: "views.panels.view-clear" }) } } : {};
|
|
151
151
|
const { words: footWords, ...footProps } = foot;
|
|
@@ -177,13 +177,14 @@ function CustomizeBodyInner(props) {
|
|
|
177
177
|
toggles: p.toggles.map(toggleOf),
|
|
178
178
|
...(p.layout && { layoutSettings: layoutSettingsOf(p.layout) }),
|
|
179
179
|
...(p.columns?.reset && { columnsReset: p.columns.reset }),
|
|
180
|
+
...(p.resets && { resets: p.resets, differs: { layout: !!p.resets.layout, columns: !!p.resets.columns } }),
|
|
180
181
|
...(p.columns?.onStartsLineChange && { onLineChange: p.columns.onStartsLineChange }),
|
|
181
182
|
...(p.columns?.footer != null && { columnsFoot: p.columns.footer }),
|
|
182
183
|
...(fields.length > 0 && { fields, foldFields: p.fields.folded }),
|
|
183
184
|
...footProps,
|
|
184
185
|
...(exportCount !== undefined && { exportCount }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }),
|
|
185
186
|
onClose: p.onDone, onScreenChange: p.onPageChange, screen: p.page, form: p.form,
|
|
186
|
-
words: { ...w, ...(p.layout && { layout: p.layout.label }), ...(p.columns && { columns: p.columns.label }),
|
|
187
|
+
words: { ...w, reset: say({ key: shared && !kit ? "views.panels.view-reset" : "views.panels.view-clear" }), ...(p.layout && { layout: p.layout.label }), ...(p.columns && { columns: p.columns.label }),
|
|
187
188
|
...(p.layout && p.layout.value !== "table" && { shownHeading: say({ key: "views.panels.customize-shown-fields" }) }), ...footWords },
|
|
188
189
|
});
|
|
189
190
|
const told = parts.level;
|
|
@@ -42,11 +42,11 @@ export interface CustomizeWords {
|
|
|
42
42
|
/** A table's two settings, as its own page draws them (the view's `freeze` and `wrap`). */
|
|
43
43
|
freeze: string;
|
|
44
44
|
wrap: string;
|
|
45
|
-
/**
|
|
45
|
+
/** @deprecated Drawn nowhere since the Layout page ends at its toggles (VK-1033). To be removed in a later release. */
|
|
46
46
|
personalReset: string;
|
|
47
|
-
/** Columns
|
|
47
|
+
/** @deprecated Drawn nowhere since Columns resets through its page's Reset (VK-1034). To be removed in a later release. */
|
|
48
48
|
columnsReset: string;
|
|
49
|
-
/**
|
|
49
|
+
/** @deprecated Drawn nowhere since a toggle carries no way back of its own (VK-1033). To be removed in a later release. */
|
|
50
50
|
toggleReset: (label: string) => string;
|
|
51
51
|
/** The shared view moved after the reader's changes began. */
|
|
52
52
|
stale: string;
|
|
@@ -16,6 +16,8 @@ export interface FilterOwn {
|
|
|
16
16
|
export interface FilterEditorProps {
|
|
17
17
|
/** What it filters, as its shell names it ("Filter"): the Sheet's title on a phone, and the rules' name to a screen reader. */
|
|
18
18
|
label: string;
|
|
19
|
+
/** Clear all at its foot; default on. Off inside Customize, where its page's Reset stands in its place (VK-1034). */
|
|
20
|
+
clearAll?: boolean;
|
|
19
21
|
/** The fields a list filters by, each typed, a choice's values with it; one leading one level in (a deal's Company) holds its own. */
|
|
20
22
|
fields: FilterField[];
|
|
21
23
|
/** The view's filter: its rules, joined by its join, groups in it. */
|
|
@@ -7,10 +7,8 @@ import { asSelect, DOTS, DOTS_LOOK, DOTS_UP, glyph, MORE_LOOK, PLUS, TRASH, useD
|
|
|
7
7
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
8
8
|
import { usePanelControls } from "../internal/panel-controls.js";
|
|
9
9
|
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
10
|
-
import { NumberField } from "../number-field/number-field.js";
|
|
11
10
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
12
11
|
import { itemLabel } from "../picker/rows.js";
|
|
13
|
-
import { Tooltip } from "../tooltip/tooltip.js";
|
|
14
12
|
import { HOW, wayOf } from "./how.js";
|
|
15
13
|
import { PairValue } from "./parts.js";
|
|
16
14
|
import { BlockHead, GroupMenu, MenuStep } from "./block.js";
|
|
@@ -39,7 +37,7 @@ function OwnValue({ name, own, open, onOpenChange, phone, size, placeholder }) {
|
|
|
39
37
|
export function useFilterEditor(props) {
|
|
40
38
|
const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels } = props;
|
|
41
39
|
const w = filterWords(props.words), words = w.picker ? { words: w.picker } : {};
|
|
42
|
-
const { Button, Select, Menu, Popover, Input } = usePanelControls();
|
|
40
|
+
const { Button, Select, Menu, Popover, Input, Tooltip, NumberBox } = usePanelControls();
|
|
43
41
|
const screen = React.useContext(PhoneHost), small = usePhone(), way = props.form ?? (screen || small ? "phone" : "computer");
|
|
44
42
|
const phone = way === "phone", stacked = phone || way === "narrow";
|
|
45
43
|
const now = React.useRef(filter);
|
|
@@ -191,7 +189,7 @@ export function useFilterEditor(props) {
|
|
|
191
189
|
return _jsx(DateValue, { name: name, value: typeof r.value === "string" ? r.value : null, onValue: set(r.id), open: !standing && isOpen, onOpenChange: phone ? (o) => { if (o)
|
|
192
190
|
setStep({ list: "value", rule: r.id }); } : onOpenChange, phone: phone, size: size, placeholder: w.chooseDate });
|
|
193
191
|
if (field.type === "number" || field.type === "range")
|
|
194
|
-
return _jsx(
|
|
192
|
+
return _jsx(NumberBox, { size: size, steppers: false, "aria-label": name, placeholder: w.typeNumber, value: typeof r.value === "number" ? r.value : null, onValueChange: (v) => set(r.id)(v ?? null) });
|
|
195
193
|
return _jsx(Input, { size: size, "aria-label": name, placeholder: w.typeValue, value: typeof r.value === "string" ? r.value : "", onChange: (e) => set(r.id)(e.target.value) });
|
|
196
194
|
};
|
|
197
195
|
function groupEntries(g) {
|
|
@@ -236,11 +234,11 @@ export function useFilterEditor(props) {
|
|
|
236
234
|
setAdding(null); }, anchor: adding?.at, className: "w-fit min-w-[calc(var(--vk-spacing,var(--spacing))*48)]", "aria-label": w.add, children: adding && _jsx(Picker, { label: w.add, items: fieldsIn(filter, adding.group, fields), value: null, onValueChange: (v) => add(adding.group, v), onDone: () => setAdding(null), search: w.search, searchShown: true, form: "computer", ...words }) }));
|
|
237
235
|
if (stacked) {
|
|
238
236
|
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "data-kit": "filter-editor", "data-filter-form": way, role: phone ? undefined : "group", "aria-label": phone ? undefined : label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-filter-step": stepTitle !== undefined ? step?.list : undefined, children: stepTitle !== undefined ? stepBody : _jsxs(_Fragment, { children: [top, filter.rules.length ? level(filter, 0)
|
|
239
|
-
: _jsxs("div", { className: "o-filter-editor-none", "data-slot": "vk-filter-none", children: [_jsx("p", { className: "o-filter-editor-none-head", children: w.none }), _jsx("p", { className: "o-filter-editor-none-line", children: w.noneLine })] }), _jsxs("div", { className: "o-filter-editor-acts", "data-slot": "vk-filter-foot", children: [addButton(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"), filter.rules.length > 0 && _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAll }), props.excludable && groupMore(filter)] }), !phone && addingPopover] }) }));
|
|
237
|
+
: _jsxs("div", { className: "o-filter-editor-none", "data-slot": "vk-filter-none", children: [_jsx("p", { className: "o-filter-editor-none-head", children: w.none }), _jsx("p", { className: "o-filter-editor-none-line", children: w.noneLine })] }), _jsxs("div", { className: "o-filter-editor-acts", "data-slot": "vk-filter-foot", children: [addButton(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"), props.clearAll !== false && filter.rules.length > 0 && _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAll }), props.excludable && groupMore(filter)] }), !phone && addingPopover] }) }));
|
|
240
238
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
241
239
|
}
|
|
242
240
|
const fieldsAlone = !filter.rules.length && !filter.relation;
|
|
243
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "data-kit": "filter-editor", "data-filter-form": "computer", role: "group", "aria-label": label, tabIndex: -1, "data-filter-fields": fieldsAlone ? "" : undefined, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: !fieldsAlone ? _jsxs(_Fragment, { children: [top, level(filter, 0), _jsxs("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: [addButton(filter.id, "outline", "sm"), _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAllFilters }), props.excludable && groupMore(filter)] }), addingPopover] }) : (_jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words })) }));
|
|
241
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "data-kit": "filter-editor", "data-filter-form": "computer", role: "group", "aria-label": label, tabIndex: -1, "data-filter-fields": fieldsAlone ? "" : undefined, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: !fieldsAlone ? _jsxs(_Fragment, { children: [top, level(filter, 0), _jsxs("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: [addButton(filter.id, "outline", "sm"), props.clearAll !== false && _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAllFilters }), props.excludable && groupMore(filter)] }), addingPopover] }) : (_jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words })) }));
|
|
244
242
|
return { body, head: {} };
|
|
245
243
|
}
|
|
246
244
|
export const useFilterEditorParts = useFilterEditor;
|
|
@@ -35,7 +35,7 @@ export declare const FILTER_SEARCH: string;
|
|
|
35
35
|
export declare function valuePlaceholder(field: FilterField, w?: FilterEditorWords): string;
|
|
36
36
|
/** The body a Popover holds under the part of a filter pressed: the fields, its type's ways, or its value in its type's own. */
|
|
37
37
|
export declare function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFilterChange, onDone, own, form, words: given }: FilterPartProps): import("react/jsx-runtime").JSX.Element | null;
|
|
38
|
-
/** A range's From and To: two
|
|
38
|
+
/** A range's From and To: two number boxes, an en dash between, each named by its end; either may be left empty. */
|
|
39
39
|
export declare function PairValue({ name, value, onValue, size, onKeyDown, words: given, slot }: {
|
|
40
40
|
name: string;
|
|
41
41
|
value: [number | null, number | null];
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { DateEditor } from "../date-editor/date-editor.js";
|
|
4
4
|
import { usePanelControls } from "../internal/panel-controls.js";
|
|
5
|
-
import { NumberField } from "../number-field/number-field.js";
|
|
6
5
|
import { Picker } from "../picker/picker.js";
|
|
7
6
|
import { itemLabel } from "../picker/rows.js";
|
|
8
7
|
import { HOW, wayOf } from "./how.js";
|
|
@@ -62,7 +61,8 @@ export function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFi
|
|
|
62
61
|
}
|
|
63
62
|
export function PairValue({ name, value, onValue, size, onKeyDown, words: given, slot }) {
|
|
64
63
|
const w = filterWords(given), [from, to] = value;
|
|
65
|
-
|
|
64
|
+
const { NumberBox } = usePanelControls();
|
|
65
|
+
return (_jsxs("div", { className: "o-filter-editor-pair", ...(slot ? { "data-slot": slot } : {}), children: [_jsx(NumberBox, { size: size, steppers: false, "aria-label": w.fromOf(name), placeholder: w.from, value: from, onValueChange: (v) => onValue([v ?? null, to]), onKeyDown: onKeyDown }), _jsx("span", { className: "o-filter-editor-dash", "aria-hidden": "true", children: "\u2013" }), _jsx(NumberBox, { size: size, steppers: false, "aria-label": w.toOf(name), placeholder: w.to, value: to, onValueChange: (v) => onValue([from, v ?? null]), onKeyDown: onKeyDown })] }));
|
|
66
66
|
}
|
|
67
67
|
const WHOLE = { maximumFractionDigits: 0 };
|
|
68
68
|
function TypedValue({ rule: r, field, name, set, onDone, w }) {
|
|
@@ -70,8 +70,8 @@ function TypedValue({ rule: r, field, name, set, onDone, w }) {
|
|
|
70
70
|
e.preventDefault();
|
|
71
71
|
onDone();
|
|
72
72
|
} };
|
|
73
|
-
const { Input } = usePanelControls();
|
|
73
|
+
const { Input, NumberBox } = usePanelControls();
|
|
74
74
|
return field.type === "number" || field.type === "range"
|
|
75
|
-
? _jsx(
|
|
75
|
+
? _jsx(NumberBox, { "data-slot": "vk-filter-part-value", "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "number" ? r.value : null, format: field.integer ? WHOLE : undefined, onValueChange: (v) => set({ value: v ?? null }), onKeyDown: enter })
|
|
76
76
|
: _jsx(Input, { "data-slot": "vk-filter-part-value", "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "string" ? r.value : "", onChange: (e) => set({ value: e.target.value }), onKeyDown: enter });
|
|
77
77
|
}
|
|
@@ -92,7 +92,7 @@ export { QUICK_FILTERS_RULES } from "./quick-filters/rules.js";
|
|
|
92
92
|
export { QUICK_FILTERS_ATTRS, quickFiltersWornOf } from "./quick-filters/looks.js";
|
|
93
93
|
export { QUICK_FILTERS_WORDS, quickFiltersWords, type QuickFiltersWords } from "./quick-filters/words.js";
|
|
94
94
|
export { quickFiltersFieldsOf, quickHoldsOf, quickListHoldOf, type QuickFiltersFieldIn } from "./quick-filters/map-quick-filters-body.js";
|
|
95
|
-
export { ToolbarControl, ToolbarFolds, ToolbarInput, ToolbarSeparatorControl, ToolbarSpacer, toolbarSteps, useToolbarWorn, type ToolbarAt, type ToolbarFoldsProps, type ToolbarInputProps, type ToolbarPlace, type ToolbarProps, } from "./toolbar/toolbar.js";
|
|
95
|
+
export { ToolbarControl, ToolbarFolds, ToolbarInput, ToolbarSeparatorControl, ToolbarSpacer, toolbarSteps, useToolbarWorn, type ToolbarAt, type ToolbarFoldsProps, type ToolbarInputProps, type ToolbarMoreControl, type ToolbarOverflowControl, type ToolbarPlace, type ToolbarProps, } from "./toolbar/toolbar.js";
|
|
96
96
|
export { TOOLBAR_ATTRS, toolbarWornOf } from "./toolbar/looks.js";
|
|
97
97
|
export { TOOLBAR_WORDS, toolbarWords, type ToolbarWords } from "./toolbar/words.js";
|
|
98
98
|
export { QuickFiltersReminderControl, type QuickFiltersReminderProps } from "./quick-filters/reminder.js";
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { parseNumber } from "viewkitjs/fields";
|
|
4
5
|
import { ViewsContext } from "../../provider/context.js";
|
|
5
6
|
import { NO_APP_CONTROLS, PanelControlsContext } from "./panel-controls.js";
|
|
6
7
|
export function useAppPanelControls() {
|
|
7
8
|
const views = React.useContext(ViewsContext);
|
|
8
|
-
const components = views?.components, names = views?.panelControls;
|
|
9
|
+
const components = views?.components, atoms = views?.atoms, names = views?.panelControls, conventions = views?.conventions;
|
|
9
10
|
return React.useMemo(() => {
|
|
10
|
-
if (!components || !names?.size)
|
|
11
|
+
if (!components || !atoms || !names?.size)
|
|
11
12
|
return NO_APP_CONTROLS;
|
|
12
13
|
const out = {};
|
|
13
14
|
for (const name of names)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if (name !== "RelationChip")
|
|
16
|
+
out[name] = name === "Avatar" ? atoms.Avatar : components[name];
|
|
17
|
+
if (out.Input)
|
|
18
|
+
out.parseNumber = (typed) => parseNumber(typed, conventions);
|
|
19
|
+
return Object.keys(out).length ? out : NO_APP_CONTROLS;
|
|
20
|
+
}, [components, atoms, names, conventions]);
|
|
17
21
|
}
|
|
18
22
|
export function PanelControlsFromViews({ children }) {
|
|
19
23
|
return _jsx(PanelControlsContext.Provider, { value: useAppPanelControls(), children: children });
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ViewsAvatarProps } from "../../atoms/types.js";
|
|
3
|
+
import type { ViewsButtonProps, ViewsCalendarProps, ViewsInputProps, ViewsMenuItem, ViewsMenuProps, ViewsPopoverProps, ViewsSelectProps, ViewsTooltipProps } from "../../provider/components.js";
|
|
3
4
|
import { type ButtonProps } from "../button/button.js";
|
|
5
|
+
import { type GlassButtonProps } from "../glass-button/glass-button.js";
|
|
4
6
|
import { type InputProps } from "../input/input.js";
|
|
5
7
|
import { type MenuProps } from "../menu/menu.js";
|
|
8
|
+
import { type NumberFieldProps } from "../number-field/number-field.js";
|
|
6
9
|
import type { MenuEntry } from "../menu-list/menu-list.js";
|
|
7
10
|
import { type PopoverProps } from "../popover/popover.js";
|
|
8
11
|
import { type SelectListProps, type SelectProps } from "../select/select.js";
|
|
12
|
+
import { type TooltipProps } from "../tooltip/tooltip.js";
|
|
9
13
|
/** The app's own controls the panels draw, by name; a name left out is ViewKit's own. */
|
|
10
14
|
export type AppPanelControls = {
|
|
11
15
|
Button?: React.ComponentType<ViewsButtonProps>;
|
|
@@ -15,6 +19,13 @@ export type AppPanelControls = {
|
|
|
15
19
|
Input?: React.ComponentType<ViewsInputProps>;
|
|
16
20
|
/** The date editor's month (VK-1021). */
|
|
17
21
|
Calendar?: React.ComponentType<ViewsCalendarProps>;
|
|
22
|
+
/** The panels' tooltips (VK-1015). */
|
|
23
|
+
Tooltip?: React.ComponentType<ViewsTooltipProps>;
|
|
24
|
+
/** The app's Avatar atom: every record's mark a panel draws (VK-1044, controls/avatar/record-mark.tsx). */
|
|
25
|
+
Avatar?: React.ComponentType<ViewsAvatarProps>;
|
|
26
|
+
/** How a number box drawn by the app's Input reads what is typed (VK-1018): the provider's conventions, handed by the map body
|
|
27
|
+
* with the Input; a plain reading of the digits where none is. */
|
|
28
|
+
parseNumber?: (typed: string) => number | null;
|
|
18
29
|
};
|
|
19
30
|
/** No app control: what a panel drawn alone reads. */
|
|
20
31
|
export declare const NO_APP_CONTROLS: AppPanelControls;
|
|
@@ -37,20 +48,33 @@ export type PanelControls = {
|
|
|
37
48
|
GroupButton: React.ComponentType<ButtonLike>;
|
|
38
49
|
/** The app's Calendar, or null: the date editor then draws its own month (VK-1021). */
|
|
39
50
|
Calendar: React.ComponentType<ViewsCalendarProps> | null;
|
|
51
|
+
/** The phone's round glass button (the Picker's Back and ⋯): ViewKit's GlassButton, or the app's Button as a quiet one (VK-1022). */
|
|
52
|
+
RoundButton: React.ComponentType<RoundLike>;
|
|
53
|
+
/** A tooltip in a panel: ViewKit's Tooltip, or the app's handed its words, side and whether they are a reason (VK-1015). */
|
|
54
|
+
Tooltip: React.ComponentType<TooltipProps>;
|
|
55
|
+
/** A number's box in a panel (the filter's value, a range's From and To): ViewKit's Number field, or the app's Input with
|
|
56
|
+
* ViewKit reading what is typed (VK-1018). */
|
|
57
|
+
NumberBox: React.ComponentType<NumberFieldProps>;
|
|
58
|
+
};
|
|
59
|
+
type RoundLike = GlassButtonProps & {
|
|
60
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
40
61
|
};
|
|
41
62
|
/** The controls a panel draws: the app's where the context holds them, else ViewKit's own, the same components. */
|
|
42
63
|
export declare function usePanelControls(): PanelControls;
|
|
43
64
|
/** ViewKit's Button props as the map's: its kind a variant, its size and form one of the map's three sizes, its icons in its
|
|
44
65
|
* children; one that can't be used but keeps its focus says so and takes no press. ViewKit's own look is never handed. */
|
|
45
66
|
export declare function buttonPropsOf(p: ButtonLike): ViewsButtonProps;
|
|
67
|
+
/** Whether a component is the hook's app Button: it takes ViewKit's Button props, so the Toolbar holds it as it holds ViewKit's
|
|
68
|
+
* Button, one of its stops (the bulk bar, VK-1023). */
|
|
69
|
+
export declare const isAppButton: (type: unknown) => boolean;
|
|
46
70
|
/** ViewKit's Select props as the map's: its rows, value, pick, name and size, and anything else a ViewKit part hands it (an
|
|
47
71
|
* `aria-describedby`, a handler) on the rest; never its list's width or its own look. */
|
|
48
72
|
export declare function selectPropsOf(p: SelectListProps): ViewsSelectProps;
|
|
49
73
|
/** A menu's rows as the map's: an action, a tick, a pick's choices (under its heading when it has one), a line before the next row.
|
|
50
74
|
* Each row keeps its public name and which one it is. A kind the map has no word for is left out, with a warning. */
|
|
51
|
-
export declare function menuItemsOf(entries: MenuEntry[], label: string): ViewsMenuItem[];
|
|
75
|
+
export declare function menuItemsOf(entries: MenuEntry[], label: string, within?: string): ViewsMenuItem[];
|
|
52
76
|
/** ViewKit's Popover props as the map's: open, where, what closes it, its name, its popup's marks and click (an editor's inner
|
|
53
|
-
* Escape rides those marks, VK-1021); a trigger of its own
|
|
77
|
+
* Escape rides those marks, VK-1021); a trigger of its own is opened by TriggeredPopover (VK-1022). A `finalFocus` ref is honoured by AppPopover itself. */
|
|
54
78
|
export declare function popoverPropsOf(p: PopoverProps): ViewsPopoverProps;
|
|
55
79
|
/** ViewKit's Input props as the map's: a value typed handed as its change, in the app's field frame, or bare where a ViewKit box
|
|
56
80
|
* frames it (a box group) or the part says so (VK-1021); never ViewKit's own look. */
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { useLabelableContext, useLabelableId } from "@base-ui/react/internals/labelable-provider";
|
|
5
|
+
import { NOOP } from "@base-ui/react/internals/noop";
|
|
4
6
|
import { Button } from "../button/button.js";
|
|
7
|
+
import { GlassButton } from "../glass-button/glass-button.js";
|
|
5
8
|
import { useAutofill } from "../input/autofill.js";
|
|
6
9
|
import { Input, InputGroupButton, InputGroupContext } from "../input/input.js";
|
|
7
10
|
import { Menu } from "../menu/menu.js";
|
|
11
|
+
import { NumberField } from "../number-field/number-field.js";
|
|
8
12
|
import { Popover } from "../popover/popover.js";
|
|
9
13
|
import { Select } from "../select/select.js";
|
|
14
|
+
import { Tooltip } from "../tooltip/tooltip.js";
|
|
10
15
|
export const NO_APP_CONTROLS = Object.freeze({});
|
|
11
16
|
export const PanelControlsContext = React.createContext(NO_APP_CONTROLS);
|
|
12
17
|
const OWN = {
|
|
13
18
|
Button: Button, Select, Menu, Popover, Input: Input,
|
|
14
|
-
GroupButton: InputGroupButton, Calendar: null,
|
|
19
|
+
GroupButton: InputGroupButton, Calendar: null, RoundButton: GlassButton,
|
|
20
|
+
Tooltip, NumberBox: NumberField,
|
|
15
21
|
};
|
|
16
22
|
export function usePanelControls() {
|
|
17
23
|
const app = React.useContext(PanelControlsContext);
|
|
@@ -19,10 +25,13 @@ export function usePanelControls() {
|
|
|
19
25
|
Button: app.Button ? AppButton : OWN.Button,
|
|
20
26
|
Select: app.Select ? AppSelect : Select,
|
|
21
27
|
Menu: app.Menu || app.Button ? OpenedMenu : Menu,
|
|
22
|
-
Popover: app.Popover ?
|
|
28
|
+
Popover: app.Popover || app.Button ? OpenedPopover : Popover,
|
|
23
29
|
Input: app.Input ? AppInput : OWN.Input,
|
|
24
30
|
GroupButton: app.Button ? AppGroupButton : OWN.GroupButton,
|
|
25
31
|
Calendar: app.Calendar ?? null,
|
|
32
|
+
RoundButton: app.Button ? AppRoundButton : OWN.RoundButton,
|
|
33
|
+
Tooltip: app.Tooltip ? AppTooltip : Tooltip,
|
|
34
|
+
NumberBox: app.Input ? AppNumberBox : NumberField,
|
|
26
35
|
}), [app]);
|
|
27
36
|
}
|
|
28
37
|
const VARIANT = {
|
|
@@ -31,12 +40,13 @@ const VARIANT = {
|
|
|
31
40
|
};
|
|
32
41
|
const SMALL = new Set(["2xs", "xs", "sm", "20", "22", "26", "20x24", "line"]);
|
|
33
42
|
export function buttonPropsOf(p) {
|
|
34
|
-
const { kind, size, shape, look: _look, loading
|
|
43
|
+
const { kind, size, shape, look: _look, loading, render: _render, nativeButton: _native, icon, iconEnd, children, focusableWhenDisabled, disabled, onClick, ...rest } = p;
|
|
35
44
|
const words = children != null && children !== false;
|
|
36
45
|
const inside = icon != null && !words && iconEnd == null ? icon : _jsxs(_Fragment, { children: [icon, children, iconEnd] });
|
|
37
|
-
const held = !!disabled && !!focusableWhenDisabled;
|
|
46
|
+
const held = (!!disabled && !!focusableWhenDisabled) || (!!loading && !disabled);
|
|
38
47
|
return {
|
|
39
48
|
...rest,
|
|
49
|
+
...(loading ? { "aria-busy": true } : {}),
|
|
40
50
|
type: rest.type ?? "button",
|
|
41
51
|
variant: VARIANT[kind ?? "outline"],
|
|
42
52
|
size: shape === "icon" || shape === "round" ? "icon" : SMALL.has(size ?? "md") ? "sm" : "default",
|
|
@@ -46,13 +56,71 @@ export function buttonPropsOf(p) {
|
|
|
46
56
|
}
|
|
47
57
|
function AppButton(p) {
|
|
48
58
|
const Own = React.useContext(PanelControlsContext).Button;
|
|
49
|
-
if (!Own)
|
|
59
|
+
if (!Own || p.render)
|
|
50
60
|
return _jsx(Button, { ...p });
|
|
51
61
|
return _jsx(Own, { ...buttonPropsOf(p) });
|
|
52
62
|
}
|
|
63
|
+
export const isAppButton = (type) => type === AppButton;
|
|
53
64
|
function AppGroupButton(p) {
|
|
54
65
|
return _jsx(AppButton, { kind: "quiet", size: "sm", ...p });
|
|
55
66
|
}
|
|
67
|
+
function AppRoundButton({ icon, children, kind, pressed, count, dot, size, render, ...p }) {
|
|
68
|
+
if (render)
|
|
69
|
+
return _jsx(GlassButton, { icon, children, kind, pressed, count, dot, size, render, ...p });
|
|
70
|
+
if (count != null || dot)
|
|
71
|
+
warnUnsaid("Button", [...(count != null ? ["count"] : []), ...(dot ? ["dot"] : [])], named(p) ?? "");
|
|
72
|
+
return _jsx(AppButton, { kind: kind === "primary" ? "primary" : kind === "danger" ? "danger" : "quiet", ...(children == null ? { shape: "icon" } : {}), icon: icon, ...(pressed !== undefined ? { "aria-pressed": pressed } : {}), ...p, children: children });
|
|
73
|
+
}
|
|
74
|
+
function useFieldControlId(id) {
|
|
75
|
+
const inField = useLabelableContext().registerControlId !== NOOP;
|
|
76
|
+
const named = useLabelableId({ id });
|
|
77
|
+
return inField && named ? { id: named } : {};
|
|
78
|
+
}
|
|
79
|
+
function AppTooltip({ label, keys, reason, side, align, disabled, delay, children }) {
|
|
80
|
+
const Own = React.useContext(PanelControlsContext).Tooltip;
|
|
81
|
+
if (!Own)
|
|
82
|
+
return _jsx(Tooltip, { label, keys, reason, side, align, disabled, delay, children: children });
|
|
83
|
+
if (disabled)
|
|
84
|
+
return children;
|
|
85
|
+
if (keys?.length)
|
|
86
|
+
warnUnsaid("Tooltip", ["keys"], typeof label === "string" ? label : "");
|
|
87
|
+
return _jsx(Own, { content: label, ...(reason ? { reason } : {}), ...(side ? { side } : {}), ...(align ? { align } : {}), ...(delay != null ? { delayMs: delay } : {}), children: children });
|
|
88
|
+
}
|
|
89
|
+
const plainNumber = (typed) => {
|
|
90
|
+
const t = typed.trim();
|
|
91
|
+
if (!t)
|
|
92
|
+
return null;
|
|
93
|
+
const n = Number(t.replace(",", "."));
|
|
94
|
+
return Number.isFinite(n) ? n : null;
|
|
95
|
+
};
|
|
96
|
+
function AppNumberBox(p) {
|
|
97
|
+
const read = React.useContext(PanelControlsContext).parseNumber ?? plainNumber;
|
|
98
|
+
const { value, onValueChange, format, onKeyDown, onBlur, onFocus, placeholder, size, disabled, readOnly, autoFocus, id, name } = p;
|
|
99
|
+
const whole = format?.maximumFractionDigits === 0;
|
|
100
|
+
const numberOf = (typed) => { const n = read(typed); return n == null ? null : whole ? Math.round(n) : n; };
|
|
101
|
+
const textOf = (n) => (n == null ? "" : String(n));
|
|
102
|
+
const [typed, setTyped] = React.useState(() => textOf(value));
|
|
103
|
+
const [held, setHeld] = React.useState(value ?? null);
|
|
104
|
+
if ((value ?? null) !== held) {
|
|
105
|
+
setHeld(value ?? null);
|
|
106
|
+
if (numberOf(typed) !== (value ?? null))
|
|
107
|
+
setTyped(textOf(value));
|
|
108
|
+
}
|
|
109
|
+
const hand = (n) => {
|
|
110
|
+
setHeld(n);
|
|
111
|
+
onValueChange?.(n);
|
|
112
|
+
};
|
|
113
|
+
const named = Object.fromEntries(Object.entries(p).filter(([k]) => k.startsWith("aria-") || k.startsWith("data-")));
|
|
114
|
+
return (_jsx(AppInput, { ...named, id, name, placeholder, disabled, readOnly, autoFocus, onFocus, size: size, type: "text", inputMode: "decimal", value: typed, onChange: (e) => { setTyped(e.target.value); hand(numberOf(e.target.value)); }, onKeyDown: (e) => {
|
|
115
|
+
onKeyDown?.(e);
|
|
116
|
+
if (e.defaultPrevented || (e.key !== "ArrowUp" && e.key !== "ArrowDown") || disabled || readOnly)
|
|
117
|
+
return;
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
const n = (numberOf(typed) ?? 0) + (e.key === "ArrowUp" ? 1 : -1) * (e.shiftKey ? 10 : 1);
|
|
120
|
+
setTyped(textOf(n));
|
|
121
|
+
hand(n);
|
|
122
|
+
}, onBlur: (e) => { onBlur?.(e); setTyped(textOf(numberOf(typed))); } }));
|
|
123
|
+
}
|
|
56
124
|
const selectItemsOf = (items) => items.map(({ value, label, line, group, disabled, mark, level }) => ({
|
|
57
125
|
value, label, ...(mark != null ? { icon: mark } : {}), ...(line != null ? { line } : {}), ...(group != null ? { group } : {}),
|
|
58
126
|
...(disabled ? { disabled } : {}), ...(level ? { level: selectItemsOf(level) } : {}),
|
|
@@ -60,23 +128,27 @@ const selectItemsOf = (items) => items.map(({ value, label, line, group, disable
|
|
|
60
128
|
export function selectPropsOf(p) {
|
|
61
129
|
const { items, value, onValueChange, multiple, placeholder, disabled, open, onOpenChange, search, size, className, opens: _opens, defaultValue: _defaultValue, label: _label, labelAt: _labelAt, note: _note, error: _error, name: _name, required: _required, readOnly: _readOnly, autoComplete: _autoComplete, side: _side, align: _align, listWidth: _listWidth, chips: _chips, clear: _clear, pickerWords: _pickerWords, searchIn: _searchIn, onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, ...rest } = p;
|
|
62
130
|
const { "data-force": _force, saving: _saving, ...passed } = rest;
|
|
63
|
-
const unsaid = Object.entries({ onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, clear: _clear })
|
|
131
|
+
const unsaid = Object.entries({ onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, ...(multiple ? { clear: _clear } : {}) })
|
|
64
132
|
.filter(([, v]) => v != null && v !== false).map(([k]) => k);
|
|
65
133
|
if (unsaid.length)
|
|
66
134
|
warnUnsaid("Select", unsaid, named(p) ?? "");
|
|
135
|
+
const clears = !multiple && typeof _clear === "string" && _clear !== "";
|
|
67
136
|
return {
|
|
68
137
|
...passed,
|
|
69
|
-
items:
|
|
138
|
+
items: clears ? [{ value: NO_VALUE, label: _clear }, ...selectItemsOf(items)] : selectItemsOf(items), value: value ?? null,
|
|
139
|
+
onValueChange: (v) => onValueChange?.(clears && v === NO_VALUE ? null : v), size: size === "md" || size === "lg" ? "default" : "sm",
|
|
70
140
|
...(multiple ? { multiple } : {}), ...(placeholder != null ? { placeholder } : {}), ...(disabled ? { disabled } : {}),
|
|
71
141
|
...(open !== undefined ? { open } : {}), ...(onOpenChange ? { onOpenChange } : {}), ...(search != null ? { search } : {}),
|
|
72
142
|
...(className ? { className } : {}),
|
|
73
143
|
};
|
|
74
144
|
}
|
|
145
|
+
const NO_VALUE = "\u0000vk-none";
|
|
75
146
|
function AppSelect(p) {
|
|
76
147
|
const Own = React.useContext(PanelControlsContext).Select;
|
|
148
|
+
const field = useFieldControlId(p.id);
|
|
77
149
|
if (!Own || p.opens)
|
|
78
150
|
return _jsx(Select, { ...p });
|
|
79
|
-
return _jsx(Own, { ...selectPropsOf(p) });
|
|
151
|
+
return _jsx(Own, { ...selectPropsOf(p), ...field });
|
|
80
152
|
}
|
|
81
153
|
const named = (p) => p["aria-label"] ?? p["data-slot"];
|
|
82
154
|
const warned = new Set();
|
|
@@ -93,7 +165,7 @@ function warnLeftOut(kind, label) {
|
|
|
93
165
|
warned.add(`${kind}:${label}`);
|
|
94
166
|
console.warn(`ViewKit: the menu "${label}" holds a "${kind}" row the components map's Menu can't be handed, so your Menu doesn't draw it.`);
|
|
95
167
|
}
|
|
96
|
-
export function menuItemsOf(entries, label) {
|
|
168
|
+
export function menuItemsOf(entries, label, within = "") {
|
|
97
169
|
const out = [];
|
|
98
170
|
let line = false;
|
|
99
171
|
const push = (item) => { out.push(line ? { ...item, separatorBefore: true } : item); line = false; };
|
|
@@ -102,7 +174,7 @@ export function menuItemsOf(entries, label) {
|
|
|
102
174
|
line = out.length > 0;
|
|
103
175
|
return;
|
|
104
176
|
}
|
|
105
|
-
const slot = e.slot?.slot, key = e.slot?.key ??
|
|
177
|
+
const slot = e.slot?.slot, key = e.slot?.key ?? `${within}${at}`;
|
|
106
178
|
if (e.kind === undefined || e.kind === "action") {
|
|
107
179
|
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), ...(e.onSelect ? { onSelect: e.onSelect } : {}), ...(e.danger ? { destructive: true } : {}),
|
|
108
180
|
...(e.disabled ? { disabled: true, disabledReason: e.disabled } : {}), ...(slot ? { slot } : {}) });
|
|
@@ -123,6 +195,30 @@ export function menuItemsOf(entries, label) {
|
|
|
123
195
|
else
|
|
124
196
|
rows.forEach(push);
|
|
125
197
|
}
|
|
198
|
+
else if (e.kind === "group") {
|
|
199
|
+
push({ key, label: e.heading, children: menuItemsOf(e.entries, label, `${key}.`), ...(slot ? { slot } : {}) });
|
|
200
|
+
}
|
|
201
|
+
else if (e.kind === "actions") {
|
|
202
|
+
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), children: menuItemsOf(e.entries, label, `${key}.`), beside: true,
|
|
203
|
+
...(e.detail ? { detail: e.detail } : {}), ...(slot ? { slot } : {}) });
|
|
204
|
+
}
|
|
205
|
+
else if (e.kind === "choices") {
|
|
206
|
+
const rows = e.choices.map((c) => {
|
|
207
|
+
const named = c.slot?.slot ?? slot;
|
|
208
|
+
return { key: c.slot?.key ?? c.value, label: c.label, ...(c.mark != null ? { icon: c.mark } : {}), checked: c.value === e.value,
|
|
209
|
+
onSelect: () => e.onChoose?.(c.value), ...(named ? { slot: named } : {}) };
|
|
210
|
+
});
|
|
211
|
+
const said = e.detail ?? e.choices.find((c) => c.value === e.value)?.label;
|
|
212
|
+
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), beside: true, children: rows, ...(said ? { detail: said } : {}), ...(slot ? { slot } : {}) });
|
|
213
|
+
}
|
|
214
|
+
else if (e.kind === "link") {
|
|
215
|
+
const unsaid = [...(e.render ? ["render"] : []), ...(e.external ? ["external"] : [])];
|
|
216
|
+
if (unsaid.length)
|
|
217
|
+
warnUnsaid("Menu", unsaid, label);
|
|
218
|
+
const go = e.onSelect;
|
|
219
|
+
push({ key, label: e.label, ...(e.icon != null ? { icon: e.icon } : {}), ...(e.href ? { href: e.href } : {}),
|
|
220
|
+
...(go ? { onSelect: () => go(undefined) } : {}), ...(slot ? { slot } : {}) });
|
|
221
|
+
}
|
|
126
222
|
else
|
|
127
223
|
warnLeftOut(e.kind, label);
|
|
128
224
|
});
|
|
@@ -220,6 +316,39 @@ function AppPopover(p) {
|
|
|
220
316
|
why.current = "outside-press"; return kept; };
|
|
221
317
|
return _jsx(Own, { ...handed, onOutsidePress: onOutsidePress, onOpenChange: (o, d) => { why.current = o ? null : d?.reason ?? why.current; handed.onOpenChange(o, d); } });
|
|
222
318
|
}
|
|
319
|
+
function OpenedPopover(p) {
|
|
320
|
+
return p.trigger ? _jsx(TriggeredPopover, { ...p }) : _jsx(AppPopover, { ...p });
|
|
321
|
+
}
|
|
322
|
+
function TriggeredPopover(p) {
|
|
323
|
+
const [ownOpen, setOwnOpen] = React.useState(!!p.defaultOpen), open = p.open ?? ownOpen;
|
|
324
|
+
const [at, setAt] = React.useState(null);
|
|
325
|
+
const back = React.useRef(null);
|
|
326
|
+
const openNow = React.useRef(open), pressedOpen = React.useRef(null);
|
|
327
|
+
React.useLayoutEffect(() => { openNow.current = open; });
|
|
328
|
+
const set = (next, reason = "trigger-press") => {
|
|
329
|
+
openNow.current = next;
|
|
330
|
+
setOwnOpen(next);
|
|
331
|
+
p.onOpenChange?.(next, { reason });
|
|
332
|
+
};
|
|
333
|
+
const trigger = p.trigger;
|
|
334
|
+
const own = trigger.props.ref;
|
|
335
|
+
const placed = (el) => { if (el) {
|
|
336
|
+
back.current = el;
|
|
337
|
+
setAt(el);
|
|
338
|
+
} fillRef(own, el); };
|
|
339
|
+
function onPointerDown(e) { pressedOpen.current = openNow.current; trigger.props.onPointerDown?.(e); }
|
|
340
|
+
function onClick(e) {
|
|
341
|
+
trigger.props.onClick?.(e);
|
|
342
|
+
back.current = e.currentTarget;
|
|
343
|
+
setAt(e.currentTarget);
|
|
344
|
+
const was = pressedOpen.current ?? openNow.current;
|
|
345
|
+
pressedOpen.current = null;
|
|
346
|
+
set(!was);
|
|
347
|
+
}
|
|
348
|
+
const opener = React.cloneElement(trigger, { ref: placed, "aria-haspopup": "dialog", "aria-expanded": open, "data-state": open ? "open" : "closed", onPointerDown, onClick });
|
|
349
|
+
const finalFocus = p.finalFocus === false ? false : p.finalFocus && typeof p.finalFocus !== "boolean" ? p.finalFocus : back;
|
|
350
|
+
return (_jsxs(_Fragment, { children: [opener, _jsx(AppPopover, { ...p, trigger: undefined, defaultOpen: undefined, anchor: p.anchor ?? at, open: open, finalFocus: finalFocus, onOpenChange: (o, d) => set(o, d.reason) })] }));
|
|
351
|
+
}
|
|
223
352
|
export function inputPropsOf(p, bare = false) {
|
|
224
353
|
const { size: _size, chrome: _chrome, look: _look, numeric: _numeric, multiline: _multiline, grow: _grow, maxLines: _maxLines, minLines: _minLines, lines: _lines, autofill: _autofill, fills: _fills, saving: _saving, saved: _saved, combobox: _combobox, onValueChange, onChange, ...rest } = p;
|
|
225
354
|
return {
|
|
@@ -233,8 +362,8 @@ export function inputPropsOf(p, bare = false) {
|
|
|
233
362
|
}
|
|
234
363
|
function AppInput(p) {
|
|
235
364
|
const Own = React.useContext(PanelControlsContext).Input;
|
|
236
|
-
const grouped = React.useContext(InputGroupContext) != null, fill = useAutofill();
|
|
365
|
+
const grouped = React.useContext(InputGroupContext) != null, fill = useAutofill(), field = useFieldControlId(p.id);
|
|
237
366
|
if (!Own || p.multiline || p.combobox)
|
|
238
367
|
return _jsx(Input, { ...p });
|
|
239
|
-
return _jsx(Own, { ...fill(p.autofill !== false), ...inputPropsOf(p, p.chrome === "bare" || grouped) });
|
|
368
|
+
return _jsx(Own, { ...fill(p.autofill !== false), ...inputPropsOf(p, p.chrome === "bare" || grouped), ...field });
|
|
240
369
|
}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { Button } from "../button/button.js";
|
|
4
|
+
import { RecordMark } from "../avatar/record-mark.js";
|
|
6
5
|
import { FieldRows, FieldRowsRow as FieldRow } from "../field/field.js";
|
|
7
|
-
import {
|
|
6
|
+
import { InputGroup, InputGroupAddon } from "../input/input.js";
|
|
7
|
+
import { usePanelControls } from "../internal/panel-controls.js";
|
|
8
8
|
import { DOTS, DOTS_LOOK, glyph, PLUS, useDecide, useStandingRoom, X } from "../internal/editor-parts.js";
|
|
9
9
|
import { Icon } from "../internal/icons.js";
|
|
10
10
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
11
11
|
import { spacingPx } from "../internal/read-token.js";
|
|
12
12
|
import { drawnAt, scrollInList } from "../internal/scroll.js";
|
|
13
13
|
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
14
|
-
import { Menu } from "../menu/menu.js";
|
|
15
14
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
16
|
-
import { Popover } from "../popover/popover.js";
|
|
17
15
|
import { Radio, RadioGroup } from "../radio/radio.js";
|
|
18
|
-
import { Select } from "../select/select.js";
|
|
19
16
|
import { Spinner } from "../spinner/spinner.js";
|
|
20
17
|
import { Switch } from "../switch/switch.js";
|
|
21
18
|
import { midWord } from "../text-editor/check.js";
|
|
@@ -34,9 +31,10 @@ const FIELDS = { cards: "one", edge: "on", height: "52", label: "104", lines: "w
|
|
|
34
31
|
function Face({ record, size }) {
|
|
35
32
|
const as = record.as;
|
|
36
33
|
const avatar = as && "avatar" in as ? as : null;
|
|
37
|
-
return _jsx(
|
|
34
|
+
return _jsx(RecordMark, { label: record.label, shape: avatar?.avatar === "person" ? "person" : "thing", id: avatar?.id, src: avatar?.src, kind: avatar?.kind, size: size });
|
|
38
35
|
}
|
|
39
36
|
export function useLinksEditor(props) {
|
|
37
|
+
const { Button, Input, Menu, Popover, Select } = usePanelControls();
|
|
40
38
|
const { label, kind, records, fields, links, onLinksChange, lead, autoFocus = true, opens, onSearch, doing, onRetry, onMore, actions = [] } = props;
|
|
41
39
|
const w = linksWords(props.words), search = props.search ?? w.search;
|
|
42
40
|
const screen = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (screen || small ? "phone" : "computer")) === "phone";
|
|
@@ -6,5 +6,5 @@ import type { LinksEditorWords } from "./words.js";
|
|
|
6
6
|
export declare function linksEditorWordsOf(say: ViewsMessageResolver, makeLead?: string): LinksEditorWords;
|
|
7
7
|
/** ViewKit's links body's props as the Links editor's, its roles' column named `rolesWord`. */
|
|
8
8
|
export declare function linksEditorPropsOf(p: ViewsLinksBodyProps, words: LinksEditorWords, rolesWord: string, AppIcon?: ViewsResolvedComponents["AppIcon"]): LinksEditorProps;
|
|
9
|
-
/** ViewKit's links body,
|
|
9
|
+
/** ViewKit's links body, its controls the app's where the provider's `panelControls` names them (VK-1022). */
|
|
10
10
|
export declare function MapLinksBody(props: ViewsLinksBodyProps): import("react/jsx-runtime").JSX.Element;
|