@viewkitjs/views 0.3.0 → 0.5.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 +641 -0
- package/README.md +3 -3
- package/dist/atoms/CommandMenu.d.ts +1 -1
- package/dist/atoms/CommandMenu.js +7 -3
- package/dist/atoms/DrillRows.d.ts +3 -0
- package/dist/atoms/DrillRows.js +25 -0
- package/dist/atoms/PanelRows.d.ts +5 -0
- package/dist/atoms/PanelRows.js +40 -0
- package/dist/atoms/PanelSearch.d.ts +2 -0
- package/dist/atoms/PanelSearch.js +21 -0
- package/dist/atoms/RelationRoles.d.ts +2 -0
- package/dist/atoms/RelationRoles.js +6 -0
- package/dist/atoms/Row.js +2 -1
- package/dist/atoms/RowMenu.js +2 -1
- package/dist/atoms/SelectionSheet.d.ts +3 -0
- package/dist/atoms/SelectionSheet.js +30 -0
- package/dist/atoms/StatusMarker.js +3 -1
- package/dist/atoms/Tag.js +2 -1
- package/dist/atoms/defaults.js +14 -0
- package/dist/atoms/types.d.ts +146 -8
- package/dist/cells/cell-values.js +4 -2
- package/dist/cells/relation-wrap.js +3 -1
- package/dist/contract.d.ts +212 -17
- package/dist/contract.js +208 -6
- package/dist/display/boolean.js +3 -1
- package/dist/display/date.d.ts +1 -1
- package/dist/display/date.js +4 -2
- package/dist/display/format.js +20 -4
- package/dist/display/link.js +4 -3
- package/dist/display/multi-value.js +2 -1
- package/dist/display/percent.js +2 -1
- package/dist/display/phone.js +2 -1
- package/dist/display/range.js +3 -13
- package/dist/display/relation.js +23 -8
- package/dist/display/rich-text.js +2 -1
- package/dist/editors/ChipsEditor.d.ts +5 -1
- package/dist/editors/ChipsEditor.js +15 -2
- package/dist/editors/DateEditor.d.ts +2 -0
- package/dist/editors/DateEditor.js +76 -10
- package/dist/editors/EditorPanel.d.ts +14 -4
- package/dist/editors/EditorPanel.js +21 -4
- package/dist/editors/LocationEditor.js +35 -3
- package/dist/editors/NumberEditor.js +3 -2
- package/dist/editors/RangeEditor.d.ts +8 -0
- package/dist/editors/RangeEditor.js +3 -2
- package/dist/editors/RelationEditor.d.ts +2 -0
- package/dist/editors/RelationEditor.js +16 -2
- package/dist/editors/RelationSetEditor.d.ts +4 -2
- package/dist/editors/RelationSetEditor.js +36 -2
- package/dist/editors/SelectEditor.d.ts +5 -2
- package/dist/editors/SelectEditor.js +31 -4
- package/dist/editors/TextEditor.js +3 -1
- package/dist/editors/ValueListEditor.d.ts +3 -0
- package/dist/editors/ValueListEditor.js +10 -4
- package/dist/editors/edit-session.d.ts +14 -2
- package/dist/editors/edit-session.js +13 -5
- package/dist/editors/escape-rule.d.ts +12 -0
- package/dist/editors/escape-rule.js +8 -0
- package/dist/editors/open-value.js +2 -1
- package/dist/editors/picker-slot.d.ts +25 -0
- package/dist/editors/picker-slot.js +37 -0
- package/dist/editors/relation-picker.d.ts +44 -0
- package/dist/editors/relation-picker.js +49 -0
- package/dist/editors/relation-source.d.ts +1 -0
- package/dist/editors/relation-source.js +7 -1
- package/dist/field-row/FieldNoteLine.js +2 -1
- package/dist/field-row/FieldRow.js +41 -6
- package/dist/field-row/FieldRowLane.js +3 -1
- package/dist/field-row/editors/RowChipsEditor.js +1 -1
- package/dist/field-row/editors/RowDateEditor.js +1 -1
- package/dist/field-row/editors/RowEditor.js +2 -1
- package/dist/field-row/editors/RowRangeEditor.js +2 -1
- package/dist/field-row/editors/RowRelationEditor.js +2 -2
- package/dist/field-row/editors/RowSelectEditor.d.ts +1 -1
- package/dist/field-row/editors/RowSelectEditor.js +2 -2
- package/dist/field-row/editors/RowValueListEditor.js +1 -1
- package/dist/field-row/editors/host.d.ts +3 -0
- package/dist/field-row/editors/row-session.js +4 -1
- package/dist/fields/menus.d.ts +2 -0
- package/dist/fields/range-unit.d.ts +7 -0
- package/dist/fields/range-unit.js +13 -0
- package/dist/figures.d.ts +5 -48
- package/dist/figures.js +1 -63
- package/dist/grid/chrome/GridAddColumn.d.ts +8 -0
- package/dist/grid/chrome/GridAddColumn.js +66 -9
- package/dist/grid/chrome/GridAggregateMenu.d.ts +5 -2
- package/dist/grid/chrome/GridAggregateMenu.js +33 -4
- package/dist/grid/chrome/GridCellEditors.d.ts +9 -2
- package/dist/grid/chrome/GridCellEditors.js +24 -5
- package/dist/grid/chrome/GridCellOutline.d.ts +3 -2
- package/dist/grid/chrome/GridCellOutline.js +11 -1
- package/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/dist/grid/chrome/GridColumnColorSection.d.ts +2 -0
- package/dist/grid/chrome/GridColumnColorSection.js +2 -2
- package/dist/grid/chrome/GridColumnDateSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnDateSection.js +2 -2
- package/dist/grid/chrome/GridColumnDurationSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnDurationSection.js +2 -2
- package/dist/grid/chrome/GridColumnMenu.d.ts +10 -6
- package/dist/grid/chrome/GridColumnMenu.js +62 -24
- package/dist/grid/chrome/GridColumnNumberSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnNumberSection.js +2 -2
- package/dist/grid/chrome/GridColumnPercentSection.d.ts +1 -0
- package/dist/grid/chrome/GridColumnPercentSection.js +1 -1
- package/dist/grid/chrome/GridColumnSortSection.d.ts +3 -3
- package/dist/grid/chrome/GridDateEditor.js +1 -1
- package/dist/grid/chrome/GridFooter.js +7 -48
- package/dist/grid/chrome/GridGroupMenu.d.ts +11 -5
- package/dist/grid/chrome/GridGroupMenu.js +28 -13
- package/dist/grid/chrome/GridHeader.d.ts +3 -1
- package/dist/grid/chrome/GridHeader.js +8 -8
- package/dist/grid/chrome/GridNumberEditor.js +3 -24
- package/dist/grid/chrome/GridRangeEditor.js +3 -2
- package/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/dist/grid/chrome/GridRow.d.ts +2 -1
- package/dist/grid/chrome/GridRow.js +13 -37
- package/dist/grid/chrome/GridRowActions.js +2 -1
- package/dist/grid/chrome/GridRowCells.js +9 -4
- package/dist/grid/chrome/GridSelectEditor.js +30 -20
- package/dist/grid/chrome/GridStructure.d.ts +11 -4
- package/dist/grid/chrome/GridStructure.js +19 -7
- package/dist/grid/chrome/GridTable.js +138 -16
- package/dist/grid/chrome/GridTableSurface.d.ts +25 -12
- package/dist/grid/chrome/GridTableSurface.js +13 -6
- package/dist/grid/chrome/GridTextEditor.js +3 -1
- package/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/dist/grid/chrome/cell-clipboard.d.ts +1 -1
- package/dist/grid/chrome/cell-clipboard.js +1 -1
- package/dist/grid/chrome/checks.d.ts +10 -2
- package/dist/grid/chrome/checks.js +17 -11
- package/dist/grid/chrome/column-glyph.d.ts +2 -2
- package/dist/grid/chrome/column-glyph.js +4 -0
- package/dist/grid/chrome/grid-add-column-items.d.ts +13 -0
- package/dist/grid/chrome/grid-add-column-items.js +40 -0
- package/dist/grid/chrome/grid-cell-classes.d.ts +2 -0
- package/dist/grid/chrome/grid-cell-classes.js +10 -4
- package/dist/grid/chrome/grid-column-menu-items.d.ts +75 -0
- package/dist/grid/chrome/grid-column-menu-items.js +263 -0
- package/dist/grid/chrome/grid-edit-escape.d.ts +4 -0
- package/dist/grid/chrome/grid-edit-escape.js +12 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +2 -1
- package/dist/grid/chrome/grid-edit-session.js +14 -1
- package/dist/grid/chrome/grid-figure-value.d.ts +25 -0
- package/dist/grid/chrome/grid-figure-value.js +40 -0
- package/dist/grid/chrome/grid-fitted-box.d.ts +15 -0
- package/dist/grid/chrome/grid-fitted-box.js +26 -0
- package/dist/grid/chrome/grid-group-menu-items.d.ts +31 -0
- package/dist/grid/chrome/grid-group-menu-items.js +75 -0
- package/dist/grid/chrome/grid-group-menu-parts.d.ts +27 -0
- package/dist/grid/chrome/grid-group-menu-parts.js +19 -0
- package/dist/grid/chrome/grid-hover.d.ts +1 -0
- package/dist/grid/chrome/grid-hover.js +13 -1
- package/dist/grid/chrome/grid-lab.d.ts +7 -0
- package/dist/grid/chrome/grid-lab.js +7 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +12 -0
- package/dist/grid/chrome/grid-menu-focus.js +13 -0
- package/dist/grid/chrome/{useGridRowContextMenu.d.ts → grid-row-menu-items.d.ts} +15 -4
- package/dist/grid/chrome/{useGridRowContextMenu.js → grid-row-menu-items.js} +15 -18
- package/dist/grid/chrome/grid-row-props.d.ts +3 -1
- package/dist/grid/chrome/grid-row-window.d.ts +15 -5
- package/dist/grid/chrome/grid-row-window.js +44 -10
- package/dist/grid/chrome/grid-rows-menu.d.ts +38 -0
- package/dist/grid/chrome/grid-rows-menu.js +83 -0
- package/dist/grid/chrome/grid-table-props.d.ts +53 -8
- package/dist/grid/chrome/useGridBandFigures.d.ts +26 -0
- package/dist/grid/chrome/useGridBandFigures.js +50 -0
- package/dist/grid/chrome/useGridBoxes.d.ts +22 -0
- package/dist/grid/chrome/useGridBoxes.js +22 -0
- package/dist/grid/chrome/useGridColumnLayout.js +29 -4
- package/dist/grid/chrome/useGridKeyboard.js +7 -2
- package/dist/grid/chrome/useGridPartColumns.d.ts +5 -0
- package/dist/grid/chrome/useGridPartColumns.js +9 -0
- package/dist/grid/chrome/useGridRangeGestures.js +2 -1
- package/dist/grid/chrome/useGridRecorder.d.ts +16 -0
- package/dist/grid/chrome/useGridRecorder.js +144 -0
- package/dist/grid/chrome/useGridRowOpener.d.ts +41 -0
- package/dist/grid/chrome/useGridRowOpener.js +83 -0
- package/dist/grid/chrome/useGridScrollArea.d.ts +38 -12
- package/dist/grid/chrome/useGridScrollArea.js +70 -17
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +67 -9
- package/dist/grid/core/clipboard-model.d.ts +11 -3
- package/dist/grid/core/clipboard-model.js +9 -4
- package/dist/grid/core/commit-model.d.ts +7 -0
- package/dist/grid/core/editing-controller.d.ts +31 -1
- package/dist/grid/core/editing-controller.js +65 -0
- package/dist/grid/core/grid-recorder.d.ts +111 -0
- package/dist/grid/core/grid-recorder.js +223 -0
- package/dist/grid/core/part-edits.d.ts +18 -0
- package/dist/grid/core/part-edits.js +48 -0
- package/dist/grid/core/pending-reconciliation.js +12 -3
- package/dist/grid/core/refusal-sentence.d.ts +3 -0
- package/dist/grid/core/refusal-sentence.js +15 -0
- package/dist/grid/core/row-opened-from.d.ts +21 -0
- package/dist/grid/core/row-opened-from.js +11 -0
- package/dist/grid/core/useGridEditing.d.ts +16 -2
- package/dist/grid/core/useGridEditing.js +10 -4
- package/dist/grid/core/value-equality.d.ts +19 -1
- package/dist/grid/core/value-equality.js +24 -0
- package/dist/grid/index.d.ts +4 -1
- package/dist/grid/index.js +1 -0
- package/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/dist/grid-lab.d.ts +18 -0
- package/dist/grid-lab.js +16 -0
- package/dist/grouping/sort-groups.d.ts +6 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/reset.d.ts +9 -0
- package/dist/internal/reset.js +1 -0
- package/dist/model/aggregates.d.ts +3 -3
- package/dist/model/aggregates.js +17 -71
- package/dist/model/column-capabilities.d.ts +29 -2
- package/dist/model/column-capabilities.js +27 -3
- package/dist/model/column-filters.js +24 -4
- package/dist/model/column-inspect.d.ts +2 -1
- package/dist/model/column-order.d.ts +2 -2
- package/dist/model/column-schema.d.ts +18 -7
- package/dist/model/column-state.d.ts +9 -20
- package/dist/model/column-state.js +1 -4
- package/dist/model/column-types.d.ts +1 -15
- package/dist/model/column-types.js +1 -1
- package/dist/model/part-columns.d.ts +17 -0
- package/dist/model/part-columns.js +67 -0
- package/dist/model/part-rows.d.ts +3 -10
- package/dist/model/part-rows.js +6 -11
- package/dist/model/part-write.d.ts +11 -0
- package/dist/model/part-write.js +52 -0
- package/dist/model/preferences.d.ts +3 -23
- package/dist/model/preferences.js +1 -17
- package/dist/model/prefs-buckets.d.ts +0 -27
- package/dist/model/prefs-buckets.js +1 -1
- package/dist/model/relation-filters.d.ts +0 -1
- package/dist/model/relation-filters.js +1 -1
- package/dist/model/row-icon.d.ts +5 -9
- package/dist/model/view-rules.d.ts +32 -6
- package/dist/model/view-rules.js +101 -21
- package/dist/provider/ViewsProvider.d.ts +22 -2
- package/dist/provider/ViewsProvider.js +21 -2
- package/dist/provider/components.d.ts +197 -9
- package/dist/provider/context.d.ts +12 -1
- package/dist/provider/desktop.d.ts +3 -0
- package/dist/provider/desktop.js +7 -4
- package/dist/provider/menu-groups.d.ts +3 -2
- package/dist/provider/menu-groups.js +13 -7
- package/dist/provider/missing-slot.d.ts +10 -0
- package/dist/provider/missing-slot.js +15 -0
- package/dist/provider/plain-input.d.ts +3 -2
- package/dist/provider/plain-input.js +3 -1
- package/dist/react.d.ts +3 -2
- package/dist/selection/SelectionBar.d.ts +18 -0
- package/dist/selection/SelectionBar.js +92 -0
- package/dist/selection/SelectionBarPhone.d.ts +3 -0
- package/dist/selection/SelectionBarPhone.js +14 -0
- package/dist/selection/bar-overflow.d.ts +12 -0
- package/dist/selection/bar-overflow.js +42 -0
- package/dist/selection/bar-parts.d.ts +15 -0
- package/dist/selection/bar-parts.js +17 -0
- package/dist/selection/index.d.ts +2 -0
- package/dist/selection/index.js +1 -0
- package/dist/selection/types.d.ts +3 -2
- package/dist/selection/verbs.d.ts +34 -0
- package/dist/selection/verbs.js +1 -0
- package/docs/contract.md +142 -39
- package/docs/getting-started.md +1 -1
- package/docs/guides/atoms.md +32 -4
- package/docs/guides/columns.md +1 -1
- package/docs/guides/display.md +1 -1
- package/docs/guides/editors.md +3 -3
- package/docs/guides/ports.md +1 -1
- package/docs/guides/selection.md +32 -20
- package/docs/guides/the-grid.md +43 -21
- package/docs/guides/the-provider.md +14 -4
- package/docs/index.md +2 -0
- package/docs/install.md +8 -1
- package/docs/reference/editors-date.md +2 -0
- package/docs/reference/editors-panel.md +4 -4
- package/docs/reference/editors-range.md +1 -1
- package/docs/reference/editors-relation.md +3 -3
- package/docs/reference/editors-select.md +1 -1
- package/docs/reference/editors-session.md +3 -2
- package/docs/reference/editors-value-list.md +1 -1
- package/docs/reference/field-row.md +2 -2
- package/docs/reference/grid.md +25 -6
- package/docs/reference/react.md +30 -8
- package/docs/reference/selection.md +10 -2
- package/docs/reference/views.md +42 -36
- package/package.json +22 -3
- package/skills/views/SKILL.md +3 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export const MISSING_COMMAND = "ViewKit drew a list through the components map's `Command`, and the app handed none. Hand `Command`, or hand `Picker` for the editors' lists and set the provider's `menus` to \"menu\" for the grid's menus.";
|
|
3
|
+
export const MISSING_CALENDAR = "ViewKit drew the date editor's month through the components map's `Calendar`, and the app handed none. Hand `Calendar`, or hand `DateBody`, your whole date body, which the date editor then opens instead.";
|
|
4
|
+
const MESSAGES = { Command: MISSING_COMMAND, Calendar: MISSING_CALENDAR };
|
|
5
|
+
export function missingParts(name) {
|
|
6
|
+
const Missing = () => {
|
|
7
|
+
throw new Error(MESSAGES[name]);
|
|
8
|
+
};
|
|
9
|
+
return { Root: Missing, Input: Missing, List: Missing, Empty: Missing, Group: Missing, Item: Missing };
|
|
10
|
+
}
|
|
11
|
+
export function missingComponent(name) {
|
|
12
|
+
return function Missing() {
|
|
13
|
+
throw new Error(MESSAGES[name]);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -2,7 +2,8 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { ViewsInputProps } from "./components.js";
|
|
3
3
|
/**
|
|
4
4
|
* The package's own `Input`, for an app that hands none: a bare `<input>` carrying exactly what the
|
|
5
|
-
* editor hands it, `ref` included, and no look of its own
|
|
6
|
-
* it never reaches
|
|
5
|
+
* editor hands it, `ref` included, and no look of its own beyond the element reset every element the
|
|
6
|
+
* package draws carries (`ELEMENT_RESET`). `chrome` is a hint for an app's frame, so it never reaches
|
|
7
|
+
* the element.
|
|
7
8
|
*/
|
|
8
9
|
export declare function PlainInput({ chrome: _chrome, ...props }: ViewsInputProps): ReactNode;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from "../internal/cx.js";
|
|
4
|
+
import { ELEMENT_RESET } from "../internal/reset.js";
|
|
3
5
|
export function PlainInput({ chrome: _chrome, ...props }) {
|
|
4
|
-
return _jsx("input", { ...props });
|
|
6
|
+
return _jsx("input", { ...props, className: cx(ELEMENT_RESET, props.className) });
|
|
5
7
|
}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { ViewsProvider, useViews } from "./provider/ViewsProvider.js";
|
|
2
2
|
export type { ViewsContextValue, ViewsProviderProps } from "./provider/ViewsProvider.js";
|
|
3
|
+
export type { EditEscape, ViewsEscapeRules } from "./editors/escape-rule.js";
|
|
3
4
|
export { DEFAULT_DESKTOP_QUERY } from "./provider/desktop.js";
|
|
4
|
-
export type { ViewsAlign, ViewsAnchor, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsInputProps, ViewsMenuItem, ViewsMenuProps, ViewsOpenChange, ViewsPopoverProps, ViewsResolvedComponents, ViewsSheetProps, ViewsSide, ViewsTooltipProps, } from "./provider/components.js";
|
|
5
|
+
export type { ViewsAlign, ViewsAnchor, ViewsBarPlacement, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsDateBodyProps, ViewsDatePick, ViewsInputProps, ViewsMenuItem, ViewsMenuProps, ViewsMenuRoute, ViewsOpenChange, ViewsPickerAction, ViewsPickerItem, ViewsPickerProps, ViewsPopoverProps, ViewsResolvedComponents, ViewsSelectionBarSettings, ViewsSheetAction, ViewsSheetActions, ViewsSheetActionsPlace, ViewsSheetProps, ViewsSide, ViewsTooltipProps, } from "./provider/components.js";
|
|
5
6
|
export type { ViewsIconProps, ViewsIcons } from "./provider/icons.js";
|
|
6
7
|
export { NOOP_PORTS } from "./provider/ports.js";
|
|
7
8
|
export type { ViewsClipboardPort, ViewsConfirmPort, ViewsConfirmRequest, ViewsHapticsPort, ViewsPorts, ViewsPrefsPort, ViewsResolvedPorts, ViewsToastPort, } from "./provider/ports.js";
|
|
8
9
|
export { DEFAULT_VIEWS_ATOMS } from "./atoms/defaults.js";
|
|
9
|
-
export type { ViewsAtoms, ViewsCommandMenuProps, ViewsRowMenuItem, ViewsRowMenuProps, ViewsListProps, ViewsRelationLinkProps, ViewsLoadingProps, ViewsLoadMoreProps, ViewsPlatformMarkProps, ViewsRowContentProps, ViewsRowProps, ViewsStatusBadgeProps, ViewsStatusMarkerProps, ViewsTagProps, ViewsTickBoxProps, } from "./atoms/types.js";
|
|
10
|
+
export type { ViewsAtoms, ViewsCommandMenuProps, ViewsRowMenuItem, ViewsRowMenuProps, ViewsListProps, ViewsRelationLinkProps, ViewsRelationRolesProps, ViewsLoadingProps, ViewsLoadMoreProps, ViewsPlatformMarkProps, ViewsRowContentProps, ViewsRowProps, ViewsSelectionSheetProps, ViewsStatusBadgeProps, ViewsStatusMarkerProps, ViewsTagProps, ViewsTickBoxProps, ViewsChoiceRowProps, ViewsCheckRowProps, ViewsRadioRowProps, ViewsDirectionButtonProps, ViewsMenuRowProps, ViewsToggleRowProps, ViewsPanelSearchProps, } from "./atoms/types.js";
|
|
10
11
|
export type { ComponentName, PortName, ViewsIconName, ViewsMessage, ViewsMessageResolver } from "./contract.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { SelectionVerb } from "./verbs.js";
|
|
3
|
+
export type SelectionBarProps = {
|
|
4
|
+
/** How many rows are selected. The bar draws nothing at zero. */
|
|
5
|
+
count: number;
|
|
6
|
+
/** Clears the selection: the count chip, the phone's ✕. */
|
|
7
|
+
onClear: () => void;
|
|
8
|
+
/** What the selection lets a person do, in order: the first four on the bar, the rest in More. */
|
|
9
|
+
verbs: readonly SelectionVerb[];
|
|
10
|
+
/** A batch is running: every control is disabled until it ends. */
|
|
11
|
+
busy?: boolean;
|
|
12
|
+
/** Deletes the selection. The bar's own verb, drawn as the trailing trash in the same place on every list;
|
|
13
|
+
* never a verb in `verbs`. A list with no bulk delete leaves it out. */
|
|
14
|
+
onDelete?: () => void;
|
|
15
|
+
/** The trash's accessible name and tooltip. Default: the `views.selection.delete` message. */
|
|
16
|
+
deleteLabel?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function SelectionBar(props: SelectionBarProps): ReactNode;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { cx } from "../internal/cx.js";
|
|
6
|
+
import { ELEMENT_RESET } from "../internal/reset.js";
|
|
7
|
+
import { useViews } from "../provider/context.js";
|
|
8
|
+
import { useDesktop, useMediaQuery } from "../provider/desktop.js";
|
|
9
|
+
import { overflowItems, splitVerbs } from "./bar-overflow.js";
|
|
10
|
+
import { CountWords, DIVIDER_CLASS, OptionLabel, PILL_CLASS } from "./bar-parts.js";
|
|
11
|
+
import { SelectionBarPhone } from "./SelectionBarPhone.js";
|
|
12
|
+
const DEFAULT_BOTTOM = "calc(1rem + env(safe-area-inset-bottom))";
|
|
13
|
+
const DEFAULT_LAYER = 50;
|
|
14
|
+
export function SelectionBar(props) {
|
|
15
|
+
const { selectionBar } = useViews();
|
|
16
|
+
const desktop = useDesktop();
|
|
17
|
+
const phoneQuery = selectionBar?.phoneQuery;
|
|
18
|
+
const phoneByQuery = useMediaQuery(phoneQuery ?? "not all", false);
|
|
19
|
+
const phone = phoneQuery ? phoneByQuery : !desktop;
|
|
20
|
+
if (props.count === 0 || typeof document === "undefined")
|
|
21
|
+
return null;
|
|
22
|
+
const placement = phone ? selectionBar?.phone : selectionBar?.desktop;
|
|
23
|
+
return createPortal(_jsx("div", { "data-slot": "vk-selection-bar", className: cx("fixed left-1/2 -translate-x-1/2", placement?.className), style: { bottom: placement?.bottom ?? DEFAULT_BOTTOM, zIndex: placement?.zIndex ?? DEFAULT_LAYER }, children: phone ? _jsx(SelectionBarPhone, { ...props }) : _jsx(DesktopBar, { ...props }) }), document.body);
|
|
24
|
+
}
|
|
25
|
+
function DesktopBar({ count, onClear, verbs, busy = false, onDelete, deleteLabel }) {
|
|
26
|
+
const { components, icons, messages } = useViews();
|
|
27
|
+
const { Button, Tooltip } = components;
|
|
28
|
+
const { inline, overflow } = splitVerbs(verbs);
|
|
29
|
+
const Close = icons.close;
|
|
30
|
+
const Trash = icons.delete;
|
|
31
|
+
const trashLabel = deleteLabel ?? messages({ key: "views.selection.delete" });
|
|
32
|
+
const deselect = messages({ key: "views.selection.deselect-all" });
|
|
33
|
+
return (_jsxs("div", { "data-slot": "vk-selection-pill", className: cx(PILL_CLASS, "pl-1.5"), children: [_jsx(Tooltip, { side: "top", delayMs: 300, className: "flex items-center gap-2", content: _jsxs(_Fragment, { children: [deselect, _jsx("span", { className: "rounded-sm border border-solid border-(color:--vk-border) px-1 py-px text-[10px] font-medium text-(color:--vk-fg-subtle)", children: messages({ key: "views.selection.escape" }) })] }), children: _jsxs("button", { type: "button", "data-slot": "vk-selection-chip", onClick: onClear, disabled: busy, "aria-label": deselect, className: cx(ELEMENT_RESET, "group/selchip flex h-8 cursor-pointer items-center gap-1.5 rounded-full bg-(color:--vk-neutral) pl-3 pr-2.5 transition-colors hover:bg-(color:--vk-neutral-hovered) disabled:cursor-default disabled:opacity-50"), children: [_jsx(CountWords, { count: count }), _jsx(Close, { className: "h-3 w-3 text-(color:--vk-fg-subtle) transition-colors group-hover/selchip:text-(color:--vk-fg)" })] }) }), _jsxs("div", { className: "flex items-center gap-1 pl-4", children: [inline.map((verb, index) => (_jsx(InlineVerb, { verb: verb, busy: busy }, index))), onDelete ? (_jsx(Button, { size: "icon", variant: "ghost", className: "h-8 w-8 rounded-full text-(color:--vk-danger) hover:bg-(color:--vk-danger-subtlest) hover:text-(color:--vk-danger)", disabled: busy, onClick: onDelete, "aria-label": trashLabel, title: trashLabel, children: _jsx(Trash, { className: "h-4 w-4" }) })) : null] }), _jsx("span", { className: DIVIDER_CLASS }), _jsx(MoreVerbs, { overflow: overflow, busy: busy })] }));
|
|
34
|
+
}
|
|
35
|
+
function InlineVerb({ verb, busy }) {
|
|
36
|
+
const { Button } = useViews().components;
|
|
37
|
+
if (verb.kind === "options")
|
|
38
|
+
return _jsx(OptionsVerb, { verb: verb, busy: busy });
|
|
39
|
+
if (verb.kind === "group")
|
|
40
|
+
return _jsx(GroupVerb, { verb: verb, busy: busy });
|
|
41
|
+
return (_jsxs(Button, { size: "sm", variant: "ghost", className: cx("rounded-full", verb.destructive && "text-(color:--vk-danger) hover:text-(color:--vk-danger)"), disabled: busy || verb.disabled, onClick: verb.onClick, children: [verb.icon, verb.label] }));
|
|
42
|
+
}
|
|
43
|
+
function useAnchoredOpen(disabled) {
|
|
44
|
+
const [open, setOpen] = useState(false);
|
|
45
|
+
const anchor = useRef(null);
|
|
46
|
+
const openAtPress = useRef(null);
|
|
47
|
+
const trigger = {
|
|
48
|
+
ref: anchor,
|
|
49
|
+
className: "inline-flex",
|
|
50
|
+
onPointerDownCapture: () => {
|
|
51
|
+
openAtPress.current = open;
|
|
52
|
+
},
|
|
53
|
+
onClick: () => {
|
|
54
|
+
const wasOpen = openAtPress.current ?? open;
|
|
55
|
+
openAtPress.current = null;
|
|
56
|
+
if (!disabled)
|
|
57
|
+
setOpen(!wasOpen);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
return { open, setOpen, anchor, trigger };
|
|
61
|
+
}
|
|
62
|
+
function GroupVerb({ verb, busy }) {
|
|
63
|
+
const { Button, Menu } = useViews().components;
|
|
64
|
+
const disabled = Boolean(busy || verb.disabled);
|
|
65
|
+
const { open, setOpen, anchor, trigger } = useAnchoredOpen(disabled);
|
|
66
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ...trigger, children: _jsxs(Button, { size: "sm", variant: "ghost", className: "rounded-full", disabled: disabled, "aria-label": verb.label, children: [verb.icon, verb.label] }) }), _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "top", align: "center", label: verb.label, items: verb.items.map((item, index) => ({
|
|
67
|
+
key: String(index),
|
|
68
|
+
label: item.label,
|
|
69
|
+
icon: item.icon,
|
|
70
|
+
onSelect: item.onClick,
|
|
71
|
+
disabled: item.disabled,
|
|
72
|
+
destructive: item.destructive,
|
|
73
|
+
})) })] }));
|
|
74
|
+
}
|
|
75
|
+
function OptionsVerb({ verb, busy }) {
|
|
76
|
+
const { components, atoms } = useViews();
|
|
77
|
+
const { Button, Popover } = components;
|
|
78
|
+
const { List, Row } = atoms;
|
|
79
|
+
const disabled = Boolean(busy || verb.disabled);
|
|
80
|
+
const { open, setOpen, anchor, trigger } = useAnchoredOpen(disabled);
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ...trigger, children: _jsxs(Button, { size: "sm", variant: "ghost", className: "rounded-full", disabled: disabled, "aria-label": verb.label, children: [verb.icon, verb.label] }) }), _jsx(Popover, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "top", align: "center", sideOffset: 8, onOutsidePress: (event) => (anchor.current?.contains(event.target) ? false : undefined), chrome: "menu", className: "w-48", children: _jsx(List, { className: "max-h-72 overflow-y-auto overscroll-contain scrollbar-overlay", children: verb.options.map((option) => (_jsx(Row, { size: "compact", label: _jsx(OptionLabel, { option: option }), onClick: () => {
|
|
82
|
+
setOpen(false);
|
|
83
|
+
verb.onSelect(option.value);
|
|
84
|
+
} }, option.value))) }) })] }));
|
|
85
|
+
}
|
|
86
|
+
function MoreVerbs({ overflow, busy }) {
|
|
87
|
+
const { components, icons, messages } = useViews();
|
|
88
|
+
const { Button, Menu } = components;
|
|
89
|
+
const { open, setOpen, anchor, trigger } = useAnchoredOpen(busy);
|
|
90
|
+
const More = icons.more;
|
|
91
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ...trigger, children: _jsxs(Button, { size: "sm", variant: "ghost", className: "rounded-full text-(color:--vk-fg-subtle) hover:text-(color:--vk-fg)", disabled: busy, "aria-label": messages({ key: "views.selection.more-label" }), children: [_jsx(More, { className: "h-4 w-4" }), messages({ key: "views.selection.more" })] }) }), _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "top", label: messages({ key: "views.selection.more" }), items: overflowItems(overflow) })] }));
|
|
92
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { cx } from "../internal/cx.js";
|
|
5
|
+
import { useViews } from "../provider/context.js";
|
|
6
|
+
import { CountWords, DIVIDER_CLASS, PILL_CLASS } from "./bar-parts.js";
|
|
7
|
+
export function SelectionBarPhone({ count, onClear, verbs, busy = false, onDelete, deleteLabel }) {
|
|
8
|
+
const { components, atoms, icons, messages } = useViews();
|
|
9
|
+
const { Button } = components;
|
|
10
|
+
const { SelectionSheet } = atoms;
|
|
11
|
+
const [open, setOpen] = useState(false);
|
|
12
|
+
const Close = icons.close;
|
|
13
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { "data-slot": "vk-selection-pill", className: cx(PILL_CLASS, "pl-4"), children: [_jsx(CountWords, { count: count }), _jsx("span", { className: DIVIDER_CLASS }), _jsx(Button, { size: "sm", variant: "ghost", className: "rounded-full", disabled: busy, onClick: () => setOpen(true), children: messages({ key: "views.selection.actions" }) }), _jsx(Button, { size: "icon", variant: "ghost", className: "h-8 w-8 rounded-full text-(color:--vk-fg-subtle) hover:text-(color:--vk-fg)", onClick: onClear, disabled: busy, "aria-label": messages({ key: "views.selection.clear" }), children: _jsx(Close, { className: "h-4 w-4" }) })] }), _jsx(SelectionSheet, { open: open, onOpenChange: (next) => setOpen(next), title: messages({ key: "views.selection.count", values: { count } }), verbs: verbs, onDelete: onDelete, deleteLabel: deleteLabel ?? messages({ key: "views.selection.delete" }), busy: busy })] }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ViewsMenuItem } from "../provider/components.js";
|
|
2
|
+
import type { SelectionVerb } from "./verbs.js";
|
|
3
|
+
/** How many verbs stay on the bar before the rest fold into More. */
|
|
4
|
+
export declare const INLINE_VERBS = 4;
|
|
5
|
+
export declare function splitVerbs(verbs: readonly SelectionVerb[]): {
|
|
6
|
+
inline: SelectionVerb[];
|
|
7
|
+
overflow: SelectionVerb[];
|
|
8
|
+
};
|
|
9
|
+
/** The spilled verbs as More's rows. A group or an options verb keeps its shape, opening its rows beside
|
|
10
|
+
* the menu: its rows only mean something under their own heading ("Set tag → warming / ready"). A menu row
|
|
11
|
+
* is words, so an options verb's values read as their labels here. */
|
|
12
|
+
export declare function overflowItems(overflow: readonly SelectionVerb[]): ViewsMenuItem[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const INLINE_VERBS = 4;
|
|
2
|
+
export function splitVerbs(verbs) {
|
|
3
|
+
return { inline: verbs.slice(0, INLINE_VERBS), overflow: verbs.slice(INLINE_VERBS) };
|
|
4
|
+
}
|
|
5
|
+
export function overflowItems(overflow) {
|
|
6
|
+
return overflow.map((verb, index) => {
|
|
7
|
+
const key = `verb-${index}`;
|
|
8
|
+
if (verb.kind === "action") {
|
|
9
|
+
return { key, label: verb.label, icon: verb.icon, onSelect: verb.onClick, disabled: verb.disabled, destructive: verb.destructive };
|
|
10
|
+
}
|
|
11
|
+
if (verb.kind === "group") {
|
|
12
|
+
return {
|
|
13
|
+
key,
|
|
14
|
+
label: verb.label,
|
|
15
|
+
icon: verb.icon,
|
|
16
|
+
disabled: verb.disabled,
|
|
17
|
+
beside: true,
|
|
18
|
+
children: verb.items.map((item, at) => ({
|
|
19
|
+
key: `${key}-${at}`,
|
|
20
|
+
label: item.label,
|
|
21
|
+
icon: item.icon,
|
|
22
|
+
onSelect: item.onClick,
|
|
23
|
+
disabled: verb.disabled || item.disabled,
|
|
24
|
+
destructive: item.destructive,
|
|
25
|
+
})),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
key,
|
|
30
|
+
label: verb.label,
|
|
31
|
+
icon: verb.icon,
|
|
32
|
+
disabled: verb.disabled,
|
|
33
|
+
beside: true,
|
|
34
|
+
children: verb.options.map((option) => ({
|
|
35
|
+
key: `${key}-${option.value}`,
|
|
36
|
+
label: option.label,
|
|
37
|
+
disabled: verb.disabled,
|
|
38
|
+
onSelect: () => verb.onSelect(option.value),
|
|
39
|
+
})),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { PickerOption } from "../editors/SelectEditor.js";
|
|
3
|
+
/** The pill the bar floats in: the overlay ground, the hairline and the floating drop. */
|
|
4
|
+
export declare const PILL_CLASS = "flex items-center gap-2 rounded-full border border-solid border-(color:--vk-border) bg-(color:--vk-overlay) py-1.5 pr-1.5 text-(color:--vk-fg) shadow-[var(--vk-float-shadow,0_8px_24px_rgb(0_0_0/0.12))]";
|
|
5
|
+
/** The vertical hairline between the bar's regions. */
|
|
6
|
+
export declare const DIVIDER_CLASS = "h-5 w-px bg-(color:--vk-border)";
|
|
7
|
+
/** "3 selected": the number in weight, the word quieter. */
|
|
8
|
+
export declare function CountWords({ count }: {
|
|
9
|
+
count: number;
|
|
10
|
+
}): ReactNode;
|
|
11
|
+
/** A value of an options verb as its badge: a status by its slot, a category by its colour, else its words.
|
|
12
|
+
* The same badges a cell shows, so setting status on the bar reads as setting it in a cell. */
|
|
13
|
+
export declare function OptionLabel({ option }: {
|
|
14
|
+
option: PickerOption;
|
|
15
|
+
}): ReactNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useViews } from "../provider/context.js";
|
|
4
|
+
export const PILL_CLASS = "flex items-center gap-2 rounded-full border border-solid border-(color:--vk-border) bg-(color:--vk-overlay) py-1.5 pr-1.5 text-(color:--vk-fg) shadow-[var(--vk-float-shadow,0_8px_24px_rgb(0_0_0/0.12))]";
|
|
5
|
+
export const DIVIDER_CLASS = "h-5 w-px bg-(color:--vk-border)";
|
|
6
|
+
export function CountWords({ count }) {
|
|
7
|
+
const { messages } = useViews();
|
|
8
|
+
return (_jsxs("span", { className: "text-sm whitespace-nowrap", children: [_jsx("span", { className: "font-semibold tabular-nums", children: count }), _jsxs("span", { className: "text-(color:--vk-fg-subtle)", children: [" ", messages({ key: "views.selection.selected" })] })] }));
|
|
9
|
+
}
|
|
10
|
+
export function OptionLabel({ option }) {
|
|
11
|
+
const { atoms } = useViews();
|
|
12
|
+
if (option.slot)
|
|
13
|
+
return _jsx(atoms.StatusBadge, { slot: option.slot, label: option.label });
|
|
14
|
+
if (option.color)
|
|
15
|
+
return _jsx(atoms.Tag, { label: option.label, color: option.color });
|
|
16
|
+
return option.label;
|
|
17
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { ListBatchApi, ListSelectionConfig } from "./types.js";
|
|
2
|
+
export { SelectionBar, type SelectionBarProps } from "./SelectionBar.js";
|
|
3
|
+
export type { SelectionOptionsVerb, SelectionVerb, SelectionVerbItem } from "./verbs.js";
|
|
2
4
|
export { SelectCheckbox } from "./SelectCheckbox.js";
|
|
3
5
|
export { useCheckDragSelect, ROW_CHECK_ATTR } from "./useCheckDragSelect.js";
|
|
4
6
|
export { preventShiftTextSelect, selectFromClick, ROW_INTERACTIVE_SELECTOR, ROW_NO_TEXT_SELECT, ROW_OPEN_STOP_SELECTOR, } from "./row-click.js";
|
package/dist/selection/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { SelectionBar } from "./SelectionBar.js";
|
|
1
2
|
export { SelectCheckbox } from "./SelectCheckbox.js";
|
|
2
3
|
export { useCheckDragSelect, ROW_CHECK_ATTR } from "./useCheckDragSelect.js";
|
|
3
4
|
export { preventShiftTextSelect, selectFromClick, ROW_INTERACTIVE_SELECTOR, ROW_NO_TEXT_SELECT, ROW_OPEN_STOP_SELECTOR, } from "./row-click.js";
|
|
@@ -12,6 +12,7 @@ export type ListSelectionConfig = {
|
|
|
12
12
|
retention?: SelectionRetention;
|
|
13
13
|
/** Selection clears whenever this view/filter identity changes. */
|
|
14
14
|
resetKey: string;
|
|
15
|
-
/** Render the floating bar, optionally with the active renderer's
|
|
16
|
-
|
|
15
|
+
/** Render the floating bar (`SelectionBar`, with the app's verbs), optionally with the active renderer's
|
|
16
|
+
* batch API. The renderer calls it on every render, empty selection included. Absent: no bar. */
|
|
17
|
+
renderBar?: (sel: UseListSelectionResult, batch?: ListBatchApi) => ReactNode;
|
|
17
18
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { PickerOption } from "../editors/SelectEditor.js";
|
|
3
|
+
/** One verb, or one row of a `group`. */
|
|
4
|
+
export type SelectionVerbItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
/** The app's glyph, drawn before the words. */
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
/** A verb that undoes or removes something (Cancel, Disconnect): drawn in the danger colour. Delete
|
|
10
|
+
* itself is the bar's own `onDelete`, never a verb. */
|
|
11
|
+
destructive?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** "Set this field on every selected row": the field's values as their badges, the same rows a cell's
|
|
15
|
+
* editor picks from. No current value: the rows may already hold several. */
|
|
16
|
+
export type SelectionOptionsVerb = {
|
|
17
|
+
kind: "options";
|
|
18
|
+
label: string;
|
|
19
|
+
icon?: ReactNode;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
options: PickerOption[];
|
|
22
|
+
onSelect: (value: string) => void;
|
|
23
|
+
};
|
|
24
|
+
/** A verb on the bar: a direct `action`, a `group` that opens a small menu of related verbs, or an
|
|
25
|
+
* `options` verb whose values are picked as badges. */
|
|
26
|
+
export type SelectionVerb = ({
|
|
27
|
+
kind: "action";
|
|
28
|
+
} & SelectionVerbItem) | {
|
|
29
|
+
kind: "group";
|
|
30
|
+
label: string;
|
|
31
|
+
icon?: ReactNode;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
items: SelectionVerbItem[];
|
|
34
|
+
} | SelectionOptionsVerb;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|