@viewkitjs/views 0.0.0-stage → 0.1.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 +420 -0
- package/LICENSE.md +7 -0
- package/README.md +50 -2
- package/dist/atoms/CommandMenu.d.ts +2 -0
- package/dist/atoms/CommandMenu.js +20 -0
- package/dist/atoms/List.d.ts +2 -0
- package/dist/atoms/List.js +6 -0
- package/dist/atoms/LoadMore.d.ts +2 -0
- package/dist/atoms/LoadMore.js +25 -0
- package/dist/atoms/Loading.d.ts +2 -0
- package/dist/atoms/Loading.js +7 -0
- package/dist/atoms/PlatformMark.d.ts +2 -0
- package/dist/atoms/PlatformMark.js +4 -0
- package/dist/atoms/RelationLink.d.ts +2 -0
- package/dist/atoms/RelationLink.js +6 -0
- package/dist/atoms/Row.d.ts +3 -0
- package/dist/atoms/Row.js +30 -0
- package/dist/atoms/RowMenu.d.ts +2 -0
- package/dist/atoms/RowMenu.js +101 -0
- package/dist/atoms/StatusBadge.d.ts +2 -0
- package/dist/atoms/StatusBadge.js +7 -0
- package/dist/atoms/StatusMarker.d.ts +2 -0
- package/dist/atoms/StatusMarker.js +19 -0
- package/dist/atoms/Tag.d.ts +2 -0
- package/dist/atoms/Tag.js +13 -0
- package/dist/atoms/TickBox.d.ts +2 -0
- package/dist/atoms/TickBox.js +8 -0
- package/dist/atoms/defaults.d.ts +2 -0
- package/dist/atoms/defaults.js +27 -0
- package/dist/atoms/tones.d.ts +5 -0
- package/dist/atoms/tones.js +28 -0
- package/dist/atoms/types.d.ts +178 -0
- package/dist/atoms/types.js +3 -0
- package/dist/cells/cell-format.d.ts +138 -0
- package/dist/cells/cell-format.js +16 -0
- package/dist/cells/cell-title.d.ts +17 -0
- package/dist/cells/cell-title.js +8 -0
- package/dist/cells/cell-values.d.ts +28 -0
- package/dist/cells/cell-values.js +87 -0
- package/dist/cells/index.d.ts +4 -0
- package/dist/cells/index.js +4 -0
- package/dist/cells/legacy-field.d.ts +52 -0
- package/dist/cells/legacy-field.js +164 -0
- package/dist/cells/relation-wrap.d.ts +3 -0
- package/dist/cells/relation-wrap.js +24 -0
- package/dist/cells/use-cell-format.d.ts +5 -0
- package/dist/cells/use-cell-format.js +10 -0
- package/dist/contract.d.ts +431 -0
- package/dist/contract.js +663 -0
- package/dist/display/actor.d.ts +4 -0
- package/dist/display/actor.js +26 -0
- package/dist/display/boolean.d.ts +18 -0
- package/dist/display/boolean.js +43 -0
- package/dist/display/breakdown.d.ts +15 -0
- package/dist/display/breakdown.js +32 -0
- package/dist/display/currency.d.ts +9 -0
- package/dist/display/currency.js +29 -0
- package/dist/display/date.d.ts +12 -0
- package/dist/display/date.js +26 -0
- package/dist/display/display-cores.d.ts +31 -0
- package/dist/display/display-cores.js +57 -0
- package/dist/display/entity-chip.d.ts +26 -0
- package/dist/display/entity-chip.js +9 -0
- package/dist/display/format.d.ts +51 -0
- package/dist/display/format.js +181 -0
- package/dist/display/index.d.ts +8 -0
- package/dist/display/index.js +7 -0
- package/dist/display/link.d.ts +29 -0
- package/dist/display/link.js +48 -0
- package/dist/display/location.d.ts +7 -0
- package/dist/display/location.js +15 -0
- package/dist/display/multi-value.d.ts +18 -0
- package/dist/display/multi-value.js +28 -0
- package/dist/display/name.d.ts +6 -0
- package/dist/display/name.js +14 -0
- package/dist/display/number.d.ts +11 -0
- package/dist/display/number.js +27 -0
- package/dist/display/options.d.ts +153 -0
- package/dist/display/options.js +1 -0
- package/dist/display/percent.d.ts +4 -0
- package/dist/display/percent.js +33 -0
- package/dist/display/phone.d.ts +10 -0
- package/dist/display/phone.js +38 -0
- package/dist/display/range.d.ts +6 -0
- package/dist/display/range.js +29 -0
- package/dist/display/relation.d.ts +4 -0
- package/dist/display/relation.js +29 -0
- package/dist/display/rich-text.d.ts +10 -0
- package/dist/display/rich-text.js +34 -0
- package/dist/display/select.d.ts +6 -0
- package/dist/display/select.js +38 -0
- package/dist/display/text-class.d.ts +23 -0
- package/dist/display/text-class.js +5 -0
- package/dist/display/text.d.ts +19 -0
- package/dist/display/text.js +8 -0
- package/dist/display/use-display-options.d.ts +2 -0
- package/dist/display/use-display-options.js +14 -0
- package/dist/display/user.d.ts +11 -0
- package/dist/display/user.js +10 -0
- package/dist/display/value-list.d.ts +10 -0
- package/dist/display/value-list.js +12 -0
- package/dist/display/viewer.d.ts +4 -0
- package/dist/display/viewer.js +11 -0
- package/dist/display/web-href.d.ts +8 -0
- package/dist/display/web-href.js +12 -0
- package/dist/editors/ChipsEditor.d.ts +59 -0
- package/dist/editors/ChipsEditor.js +73 -0
- package/dist/editors/DateEditor.d.ts +25 -0
- package/dist/editors/DateEditor.js +122 -0
- package/dist/editors/LocationEditor.d.ts +22 -0
- package/dist/editors/LocationEditor.js +229 -0
- package/dist/editors/NameEditor.d.ts +22 -0
- package/dist/editors/NameEditor.js +91 -0
- package/dist/editors/NumberEditor.d.ts +67 -0
- package/dist/editors/NumberEditor.js +86 -0
- package/dist/editors/RangeEditor.d.ts +22 -0
- package/dist/editors/RangeEditor.js +70 -0
- package/dist/editors/RelationEditor.d.ts +65 -0
- package/dist/editors/RelationEditor.js +64 -0
- package/dist/editors/SelectEditor.d.ts +72 -0
- package/dist/editors/SelectEditor.js +59 -0
- package/dist/editors/ValueListEditor.d.ts +38 -0
- package/dist/editors/ValueListEditor.js +217 -0
- package/dist/editors/edit-cores.d.ts +83 -0
- package/dist/editors/edit-cores.js +38 -0
- package/dist/editors/edit-session.d.ts +74 -0
- package/dist/editors/edit-session.js +35 -0
- package/dist/editors/open-values.d.ts +28 -0
- package/dist/editors/open-values.js +26 -0
- package/dist/editors/relation-source.d.ts +66 -0
- package/dist/editors/relation-source.js +102 -0
- package/dist/fields/binding.d.ts +87 -0
- package/dist/fields/binding.js +117 -0
- package/dist/fields/currency.d.ts +92 -0
- package/dist/fields/currency.js +55 -0
- package/dist/fields/denomination.d.ts +42 -0
- package/dist/fields/denomination.js +11 -0
- package/dist/fields/edit-core-types.d.ts +40 -0
- package/dist/fields/edit-core-types.js +29 -0
- package/dist/fields/format-knobs.d.ts +34 -0
- package/dist/fields/format-knobs.js +36 -0
- package/dist/fields/menus.d.ts +28 -0
- package/dist/fields/menus.js +1 -0
- package/dist/fields/money.d.ts +59 -0
- package/dist/fields/money.js +77 -0
- package/dist/fields/number-edit.d.ts +11 -0
- package/dist/fields/number-edit.js +17 -0
- package/dist/fields/prepare-write.d.ts +55 -0
- package/dist/fields/prepare-write.js +67 -0
- package/dist/fields/relation-source-types.d.ts +54 -0
- package/dist/fields/relation-source-types.js +1 -0
- package/dist/figures.d.ts +52 -0
- package/dist/figures.js +63 -0
- package/dist/filters/date-filter.d.ts +2 -0
- package/dist/filters/date-filter.js +1 -0
- package/dist/filters/filter-model.d.ts +177 -0
- package/dist/filters/filter-model.js +41 -0
- package/dist/filters/number-filter.d.ts +2 -0
- package/dist/filters/number-filter.js +1 -0
- package/dist/filters/range-filter.d.ts +2 -0
- package/dist/filters/range-filter.js +1 -0
- package/dist/filters/registry.d.ts +136 -0
- package/dist/filters/registry.js +46 -0
- package/dist/filters/relation-filter.d.ts +16 -0
- package/dist/filters/relation-filter.js +53 -0
- package/dist/filters/text-filter.d.ts +2 -0
- package/dist/filters/text-filter.js +1 -0
- package/dist/filters/types.d.ts +27 -0
- package/dist/filters/types.js +1 -0
- package/dist/grouping/sort-groups.d.ts +18 -0
- package/dist/grouping/sort-groups.js +33 -0
- package/dist/grouping/types.d.ts +10 -0
- package/dist/grouping/types.js +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +29 -0
- package/dist/internal/chip.d.ts +4 -0
- package/dist/internal/chip.js +3 -0
- package/dist/internal/cx.d.ts +3 -0
- package/dist/internal/cx.js +3 -0
- package/dist/model/aggregates.d.ts +59 -0
- package/dist/model/aggregates.js +186 -0
- package/dist/model/card-density.d.ts +8 -0
- package/dist/model/card-density.js +10 -0
- package/dist/model/card-layout.d.ts +85 -0
- package/dist/model/card-layout.js +90 -0
- package/dist/model/column-capabilities.d.ts +162 -0
- package/dist/model/column-capabilities.js +233 -0
- package/dist/model/column-filters.d.ts +106 -0
- package/dist/model/column-filters.js +321 -0
- package/dist/model/column-format.d.ts +103 -0
- package/dist/model/column-format.js +1 -0
- package/dist/model/column-from.d.ts +28 -0
- package/dist/model/column-from.js +160 -0
- package/dist/model/column-inspect.d.ts +18 -0
- package/dist/model/column-inspect.js +6 -0
- package/dist/model/column-knobs.d.ts +20 -0
- package/dist/model/column-knobs.js +16 -0
- package/dist/model/column-money.d.ts +13 -0
- package/dist/model/column-money.js +27 -0
- package/dist/model/column-order.d.ts +36 -0
- package/dist/model/column-order.js +68 -0
- package/dist/model/column-schema.d.ts +335 -0
- package/dist/model/column-schema.js +1 -0
- package/dist/model/column-sort.d.ts +17 -0
- package/dist/model/column-sort.js +11 -0
- package/dist/model/column-state.d.ts +77 -0
- package/dist/model/column-state.js +95 -0
- package/dist/model/column-types.d.ts +109 -0
- package/dist/model/column-types.js +50 -0
- package/dist/model/column-warnings.d.ts +44 -0
- package/dist/model/column-warnings.js +24 -0
- package/dist/model/density.d.ts +3 -0
- package/dist/model/density.js +13 -0
- package/dist/model/field-type-of.d.ts +21 -0
- package/dist/model/field-type-of.js +11 -0
- package/dist/model/filter-capabilities.d.ts +1 -0
- package/dist/model/filter-capabilities.js +1 -0
- package/dist/model/filter-pushdown.d.ts +106 -0
- package/dist/model/filter-pushdown.js +147 -0
- package/dist/model/index.d.ts +40 -0
- package/dist/model/index.js +21 -0
- package/dist/model/part-rows.d.ts +28 -0
- package/dist/model/part-rows.js +40 -0
- package/dist/model/preferences.d.ts +151 -0
- package/dist/model/preferences.js +84 -0
- package/dist/model/prefs-buckets.d.ts +173 -0
- package/dist/model/prefs-buckets.js +71 -0
- package/dist/model/relation-filters.d.ts +45 -0
- package/dist/model/relation-filters.js +78 -0
- package/dist/model/render-count.d.ts +2 -0
- package/dist/model/render-count.js +24 -0
- package/dist/model/row-icon.d.ts +23 -0
- package/dist/model/row-icon.js +5 -0
- package/dist/model/view-rules.d.ts +73 -0
- package/dist/model/view-rules.js +216 -0
- package/dist/provider/ViewsProvider.d.ts +26 -0
- package/dist/provider/ViewsProvider.js +12 -0
- package/dist/provider/components.d.ts +222 -0
- package/dist/provider/components.js +3 -0
- package/dist/provider/context.d.ts +19 -0
- package/dist/provider/context.js +10 -0
- package/dist/provider/icons.d.ts +6 -0
- package/dist/provider/icons.js +1 -0
- package/dist/provider/ports.d.ts +35 -0
- package/dist/provider/ports.js +8 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.js +4 -0
- package/dist/selection/SelectCheckbox.d.ts +17 -0
- package/dist/selection/SelectCheckbox.js +11 -0
- package/dist/selection/index.d.ts +7 -0
- package/dist/selection/index.js +6 -0
- package/dist/selection/model.d.ts +55 -0
- package/dist/selection/model.js +86 -0
- package/dist/selection/row-click.d.ts +35 -0
- package/dist/selection/row-click.js +20 -0
- package/dist/selection/types.d.ts +17 -0
- package/dist/selection/types.js +1 -0
- package/dist/selection/useCheckDragSelect.d.ts +61 -0
- package/dist/selection/useCheckDragSelect.js +165 -0
- package/dist/selection/useListSelection.d.ts +39 -0
- package/dist/selection/useListSelection.js +48 -0
- package/dist/selection/useListSelectionShortcuts.d.ts +6 -0
- package/dist/selection/useListSelectionShortcuts.js +14 -0
- package/dist/selection/useRestIntent.d.ts +18 -0
- package/dist/selection/useRestIntent.js +35 -0
- package/docs/contract.md +453 -0
- package/docs/install.md +105 -0
- package/docs/reshaping.md +19 -0
- package/package.json +114 -3
- package/skills/views/SKILL.md +87 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from "../internal/cx.js";
|
|
4
|
+
import { useViews } from "../provider/context.js";
|
|
5
|
+
const LABEL_SIZE = { compact: "text-[13px]", regular: "text-sm" };
|
|
6
|
+
function labelClass(label, wrap, size) {
|
|
7
|
+
const layout = wrap
|
|
8
|
+
? "block min-w-0 break-all"
|
|
9
|
+
: typeof label === "string" || typeof label === "number"
|
|
10
|
+
? "block truncate"
|
|
11
|
+
: "flex min-w-0 items-center";
|
|
12
|
+
return cx(layout, LABEL_SIZE[size]);
|
|
13
|
+
}
|
|
14
|
+
export function DefaultRowContent({ label, description, leading, leadingLane, trailing, detail, chosen, chosenTint = true, tone = "default", size = "regular", wrap, className, }) {
|
|
15
|
+
const Check = useViews().icons.check;
|
|
16
|
+
const tinted = Boolean(chosen && chosenTint);
|
|
17
|
+
return (_jsxs("span", { "data-slot": "vk-row-content", "data-chosen": chosen || undefined, "data-muted": (tone === "muted" && !tinted) || undefined, className: cx("flex min-w-0 flex-1 items-center gap-2.5", tinted
|
|
18
|
+
? "font-medium text-(color:--vk-fg-selected)"
|
|
19
|
+
: tone === "muted"
|
|
20
|
+
? "text-(color:--vk-fg-subtle) group-hover/row:text-(color:--vk-fg)"
|
|
21
|
+
: null, className), children: [leading || leadingLane ? (_jsx("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: leading })) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: labelClass(label, wrap, size), children: label }), description ? (_jsx("span", { className: "block truncate text-xs text-(color:--vk-fg-subtle)", children: description })) : null] }), detail != null ? (_jsx("span", { className: cx("ml-3.5 shrink-0 truncate text-xs font-normal", chosen ? "text-(color:--vk-fg-brand)" : "text-(color:--vk-fg-subtle)"), children: detail })) : null, trailing, chosen && detail == null ? (_jsx("span", { className: "ml-auto flex size-4 shrink-0 items-center justify-center text-(color:--vk-fg-selected)", children: _jsx(Check, { className: "size-3.5" }) })) : null] }));
|
|
22
|
+
}
|
|
23
|
+
export function DefaultRow({ onClick, onMouseDown, disabled, interactive = true, opens, open, title, role, "aria-selected": ariaSelected, className, ...content }) {
|
|
24
|
+
const frame = "flex w-full items-center rounded-md px-2 py-1.5 text-left";
|
|
25
|
+
const body = _jsx(DefaultRowContent, { ...content });
|
|
26
|
+
if (!interactive) {
|
|
27
|
+
return (_jsx("div", { "data-slot": "vk-row", title: title, className: cx(frame, className), children: body }));
|
|
28
|
+
}
|
|
29
|
+
return (_jsx("button", { type: "button", "data-slot": "vk-row", "data-disabled": disabled || undefined, "data-open": open || undefined, "aria-haspopup": opens ? "menu" : undefined, "aria-expanded": opens ? Boolean(open) : undefined, disabled: disabled, onClick: onClick, onMouseDown: onMouseDown, title: title, role: role, "aria-selected": role ? ariaSelected : undefined, className: cx(frame, "group/row transition-colors hover:bg-(color:--vk-hovered) data-open:bg-(color:--vk-pressed) disabled:pointer-events-none disabled:opacity-50", className), children: body }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { useViews } from "../provider/context.js";
|
|
5
|
+
const OPEN_GRACE_MS = 300;
|
|
6
|
+
function inGraceSince(openedAt) {
|
|
7
|
+
return performance.now() - openedAt < OPEN_GRACE_MS;
|
|
8
|
+
}
|
|
9
|
+
function toMenuItems(entries) {
|
|
10
|
+
const out = [];
|
|
11
|
+
let ruled = false;
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
if (entry.separator) {
|
|
14
|
+
ruled = out.length > 0;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
out.push({ ...entry.item, key: entry.key, separatorBefore: ruled || undefined });
|
|
18
|
+
ruled = false;
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
function hostEntry(item, index) {
|
|
23
|
+
if (item.separator)
|
|
24
|
+
return { separator: true };
|
|
25
|
+
return {
|
|
26
|
+
key: `item-${index}`,
|
|
27
|
+
item: {
|
|
28
|
+
label: item.label,
|
|
29
|
+
icon: item.icon,
|
|
30
|
+
onSelect: item.onClick,
|
|
31
|
+
disabled: item.disabled,
|
|
32
|
+
destructive: item.destructive,
|
|
33
|
+
shortcut: item.shortcut,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function DefaultRowMenu({ children, rowId, items, openHref, onDelete }) {
|
|
38
|
+
const { components, icons, messages } = useViews();
|
|
39
|
+
const { Menu } = components;
|
|
40
|
+
const [point, setPoint] = useState(null);
|
|
41
|
+
const openedAt = useRef(0);
|
|
42
|
+
const lastPress = useRef(undefined);
|
|
43
|
+
const wrapper = useRef(null);
|
|
44
|
+
const inGrace = () => inGraceSince(openedAt.current);
|
|
45
|
+
const guarded = (run) => () => {
|
|
46
|
+
if (!inGrace())
|
|
47
|
+
run();
|
|
48
|
+
};
|
|
49
|
+
const Open = icons.open;
|
|
50
|
+
const Delete = icons.delete;
|
|
51
|
+
const entries = [];
|
|
52
|
+
if (openHref) {
|
|
53
|
+
entries.push({
|
|
54
|
+
key: "open",
|
|
55
|
+
item: {
|
|
56
|
+
label: messages({ key: "views.menus.row-open" }),
|
|
57
|
+
icon: _jsx(Open, { className: "h-4 w-4" }),
|
|
58
|
+
onSelect: () => window.open(openHref, "_blank", "noopener,noreferrer"),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
entries.push({ separator: true }, ...items.map(hostEntry), { separator: true });
|
|
63
|
+
if (onDelete) {
|
|
64
|
+
entries.push({
|
|
65
|
+
key: "delete",
|
|
66
|
+
item: {
|
|
67
|
+
label: messages({ key: "views.menus.row-delete" }),
|
|
68
|
+
icon: _jsx(Delete, { className: "h-4 w-4" }),
|
|
69
|
+
destructive: true,
|
|
70
|
+
onSelect: () => {
|
|
71
|
+
if (window.confirm(messages({ key: "views.menus.row-delete-confirm" })))
|
|
72
|
+
void onDelete(rowId);
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const rows = toMenuItems(entries).map((row) => (row.onSelect ? { ...row, onSelect: guarded(row.onSelect) } : row));
|
|
78
|
+
if (point && rows.length === 0)
|
|
79
|
+
setPoint(null);
|
|
80
|
+
return (_jsxs("div", { ref: wrapper, "data-slot": "vk-row-menu", onPointerDownCapture: (event) => {
|
|
81
|
+
lastPress.current = event.pointerType;
|
|
82
|
+
}, onContextMenu: (event) => {
|
|
83
|
+
const fromMore = event.target.closest?.('[data-slot="vk-grid-row-more"]');
|
|
84
|
+
const touched = lastPress.current === "touch";
|
|
85
|
+
lastPress.current = undefined;
|
|
86
|
+
if (touched && !fromMore)
|
|
87
|
+
return;
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
openedAt.current = performance.now();
|
|
90
|
+
setPoint({ x: event.clientX, y: event.clientY });
|
|
91
|
+
}, onPointerUpCapture: (event) => {
|
|
92
|
+
if (!point || !inGrace())
|
|
93
|
+
return;
|
|
94
|
+
if (wrapper.current?.contains(event.target))
|
|
95
|
+
return;
|
|
96
|
+
event.stopPropagation();
|
|
97
|
+
}, children: [children, _jsx(Menu, { open: point !== null && rows.length > 0, onOpenChange: (open) => {
|
|
98
|
+
if (!open)
|
|
99
|
+
setPoint(null);
|
|
100
|
+
}, anchor: point, items: rows })] }));
|
|
101
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from "../internal/cx.js";
|
|
4
|
+
import { STATUS_DOT, STATUS_TEXT } from "./tones.js";
|
|
5
|
+
export function DefaultStatusBadge({ slot, label, leading, title, size = "compact", className }) {
|
|
6
|
+
return (_jsxs("span", { "data-slot": "vk-status", "data-status": slot, title: title, className: cx("inline-flex min-w-0 items-center gap-1.5 font-medium", size === "compact" ? "text-[11px]" : "text-xs", STATUS_TEXT[slot], className), children: [leading ?? _jsx("span", { "aria-hidden": "true", className: cx("size-1.5 shrink-0 rounded-full", STATUS_DOT[slot]) }), _jsx("span", { className: "truncate", children: label })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { useViews } from "../provider/context.js";
|
|
5
|
+
export function DefaultStatusMarker({ slot = "warning", label, title, reason, emptyReason, onResolve, resolveLabel, }) {
|
|
6
|
+
const { atoms, components, icons, messages } = useViews();
|
|
7
|
+
const [open, setOpen] = useState(false);
|
|
8
|
+
const anchor = useRef(null);
|
|
9
|
+
const { Popover, Button } = components;
|
|
10
|
+
const Badge = atoms.StatusBadge;
|
|
11
|
+
const Warning = icons.warning;
|
|
12
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { ref: anchor, type: "button", tabIndex: -1, "aria-label": title, "data-slot": "vk-marker", className: "inline-flex max-w-full", onClick: (event) => {
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
setOpen((current) => !current);
|
|
15
|
+
}, children: _jsx(Badge, { slot: slot, label: label, leading: _jsx(Warning, { className: "size-3" }) }) }), _jsx(Popover, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "bottom", align: "start", className: "w-64", onPanelClick: (event) => event.stopPropagation(), onOutsidePress: (event) => anchor.current?.contains(event.target) ? false : undefined, children: _jsxs("div", { className: "flex flex-col gap-2 text-sm", children: [_jsx("span", { className: "text-xs font-medium text-(color:--vk-fg-subtle)", children: title }), _jsx("span", { children: reason || emptyReason || messages({ key: "views.editors.marker-no-reason" }) }), onResolve ? (_jsx(Button, { size: "sm", variant: "outline", onClick: () => {
|
|
16
|
+
onResolve();
|
|
17
|
+
setOpen(false);
|
|
18
|
+
}, children: resolveLabel ?? messages({ key: "views.editors.marker-resolve" }) })) : null] }) })] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from "../internal/cx.js";
|
|
4
|
+
import { useViews } from "../provider/context.js";
|
|
5
|
+
import { TAG_TONE } from "./tones.js";
|
|
6
|
+
export function DefaultTag({ label, color, leading, onRemove, removeLabel, className }) {
|
|
7
|
+
const { icons, messages } = useViews();
|
|
8
|
+
const Close = icons.close;
|
|
9
|
+
return (_jsxs("span", { "data-slot": "vk-tag", className: cx("inline-flex h-5 max-w-full items-center gap-1 rounded-md px-2 text-xs font-medium", onRemove ? "pr-1" : null, TAG_TONE[color], className), children: [leading ? _jsx("span", { "aria-hidden": "true", className: "flex shrink-0 items-center", children: leading }) : null, _jsx("span", { className: "truncate", children: label }), onRemove ? (_jsx("button", { type: "button", "aria-label": removeLabel ?? messages({ key: "views.editors.tag-remove", values: { label } }), className: "grid size-3.5 shrink-0 place-content-center rounded-full hover:bg-(color:--vk-hovered)", onClick: (event) => {
|
|
10
|
+
event.stopPropagation();
|
|
11
|
+
onRemove();
|
|
12
|
+
}, children: _jsx(Close, { className: "size-2.5" }) })) : null] }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from "../internal/cx.js";
|
|
4
|
+
import { useViews } from "../provider/context.js";
|
|
5
|
+
export function DefaultTickBox({ checked, className }) {
|
|
6
|
+
const Check = useViews().icons.check;
|
|
7
|
+
return (_jsx("span", { "aria-hidden": "true", "data-slot": "vk-tick", "data-checked": checked || undefined, className: cx("grid size-4 shrink-0 place-content-center rounded-sm border transition-colors", checked ? "border-(color:--vk-brand) bg-(color:--vk-brand) text-(color:--vk-fg-on-brand)" : "border-(color:--vk-border)", className), children: checked ? _jsx(Check, { className: "size-3" }) : null }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DefaultCommandMenu } from "./CommandMenu.js";
|
|
2
|
+
import { DefaultList } from "./List.js";
|
|
3
|
+
import { DefaultLoading } from "./Loading.js";
|
|
4
|
+
import { DefaultLoadMore } from "./LoadMore.js";
|
|
5
|
+
import { DefaultPlatformMark } from "./PlatformMark.js";
|
|
6
|
+
import { DefaultRelationLink } from "./RelationLink.js";
|
|
7
|
+
import { DefaultRow, DefaultRowContent } from "./Row.js";
|
|
8
|
+
import { DefaultRowMenu } from "./RowMenu.js";
|
|
9
|
+
import { DefaultStatusBadge } from "./StatusBadge.js";
|
|
10
|
+
import { DefaultStatusMarker } from "./StatusMarker.js";
|
|
11
|
+
import { DefaultTag } from "./Tag.js";
|
|
12
|
+
import { DefaultTickBox } from "./TickBox.js";
|
|
13
|
+
export const DEFAULT_VIEWS_ATOMS = {
|
|
14
|
+
List: DefaultList,
|
|
15
|
+
Row: DefaultRow,
|
|
16
|
+
RowContent: DefaultRowContent,
|
|
17
|
+
TickBox: DefaultTickBox,
|
|
18
|
+
StatusBadge: DefaultStatusBadge,
|
|
19
|
+
StatusMarker: DefaultStatusMarker,
|
|
20
|
+
Tag: DefaultTag,
|
|
21
|
+
CommandMenu: DefaultCommandMenu,
|
|
22
|
+
RelationLink: DefaultRelationLink,
|
|
23
|
+
Loading: DefaultLoading,
|
|
24
|
+
LoadMore: DefaultLoadMore,
|
|
25
|
+
PlatformMark: DefaultPlatformMark,
|
|
26
|
+
RowMenu: DefaultRowMenu,
|
|
27
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
2
|
+
import type { StatusSlot } from "@viewkitjs/fields/design/status-slots";
|
|
3
|
+
export declare const STATUS_TEXT: Record<StatusSlot, string>;
|
|
4
|
+
export declare const STATUS_DOT: Record<StatusSlot, string>;
|
|
5
|
+
export declare const TAG_TONE: Record<CategoryColor, string>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const STATUS_TEXT = {
|
|
2
|
+
success: "text-[var(--vk-success,hsl(160_84%_39%))]",
|
|
3
|
+
error: "text-(color:--vk-danger)",
|
|
4
|
+
warning: "text-[var(--vk-warning,hsl(38_92%_50%))]",
|
|
5
|
+
running: "text-[var(--vk-info,hsl(199_89%_48%))]",
|
|
6
|
+
pending: "text-(color:--vk-fg-subtle)",
|
|
7
|
+
primary: "text-(color:--vk-fg-brand)",
|
|
8
|
+
muted: "text-(color:--vk-fg-subtle)",
|
|
9
|
+
};
|
|
10
|
+
export const STATUS_DOT = {
|
|
11
|
+
success: "bg-[var(--vk-success,hsl(160_84%_39%))]",
|
|
12
|
+
error: "bg-(color:--vk-danger)",
|
|
13
|
+
warning: "bg-[var(--vk-warning,hsl(38_92%_50%))]",
|
|
14
|
+
running: "bg-[var(--vk-info,hsl(199_89%_48%))]",
|
|
15
|
+
pending: "bg-(color:--vk-fg-subtle)",
|
|
16
|
+
primary: "bg-(color:--vk-brand)",
|
|
17
|
+
muted: "bg-(color:--vk-fg-subtle)",
|
|
18
|
+
};
|
|
19
|
+
export const TAG_TONE = {
|
|
20
|
+
gray: "bg-(color:--vk-neutral) text-(color:--vk-fg-subtle)",
|
|
21
|
+
blue: "bg-[color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_12%,var(--vk-ground))] text-[var(--vk-label-blue,hsl(199_89%_48%))]",
|
|
22
|
+
green: "bg-[color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_12%,var(--vk-ground))] text-[var(--vk-label-green,hsl(160_84%_39%))]",
|
|
23
|
+
amber: "bg-[color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_12%,var(--vk-ground))] text-[var(--vk-label-amber,hsl(38_92%_50%))]",
|
|
24
|
+
red: "bg-[color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_12%,var(--vk-ground))] text-[var(--vk-label-red,hsl(0_84%_60%))]",
|
|
25
|
+
purple: "bg-[color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_12%,var(--vk-ground))] text-[var(--vk-label-purple,hsl(258_90%_66%))]",
|
|
26
|
+
pink: "bg-[color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_12%,var(--vk-ground))] text-[var(--vk-label-pink,hsl(330_81%_60%))]",
|
|
27
|
+
teal: "bg-[color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_12%,var(--vk-ground))] text-[var(--vk-label-teal,hsl(173_80%_40%))]",
|
|
28
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { ComponentType, MouseEventHandler, ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { LinkPlatform, RelationValue } from "@viewkitjs/fields";
|
|
3
|
+
import type { CategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
4
|
+
import type { StatusSlot } from "@viewkitjs/fields/design/status-slots";
|
|
5
|
+
import type { FieldRowMenuItem } from "../fields/menus.js";
|
|
6
|
+
/** A row's inside. Inside a command list's item it is all the row is: the item owns
|
|
7
|
+
* the element, the highlight and the keyboard. */
|
|
8
|
+
export type ViewsRowContentProps = {
|
|
9
|
+
/** Text truncates to one line; any other node (a badge, a link) is laid out in a row so it centres. */
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
/** A second line under the label. */
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
/** A glyph before the label. */
|
|
14
|
+
leading?: ReactNode;
|
|
15
|
+
/** Keep the leading lane's width with no glyph in it, so rows with and without one align. */
|
|
16
|
+
leadingLane?: boolean;
|
|
17
|
+
/** After the label, before the chosen check. */
|
|
18
|
+
trailing?: ReactNode;
|
|
19
|
+
/** What the row says at its right edge, in the subtle colour: a setting's current choice, or a live sample. A chosen
|
|
20
|
+
* row draws it in the brand colour and no check, so a column of samples stays in line. */
|
|
21
|
+
detail?: ReactNode;
|
|
22
|
+
/** The value this row stands for is the current one: a trailing check. */
|
|
23
|
+
chosen?: boolean;
|
|
24
|
+
/** A chosen row also takes the chosen colour. Default true; a row whose label is a badge keeps its own. */
|
|
25
|
+
chosenTint?: boolean;
|
|
26
|
+
/** `muted` for a row that offers rather than lists (none, create, add). */
|
|
27
|
+
tone?: "default" | "muted";
|
|
28
|
+
/** `compact` draws the label at 13px — a command list's row, a list of values; `regular`
|
|
29
|
+
* (default) at the app's menu size. */
|
|
30
|
+
size?: "compact" | "regular";
|
|
31
|
+
/** Break a long label instead of truncating it — a list that exists to make values readable. */
|
|
32
|
+
wrap?: boolean;
|
|
33
|
+
className?: string;
|
|
34
|
+
};
|
|
35
|
+
/** A whole row: a button, or with `interactive={false}` a static line. */
|
|
36
|
+
export type ViewsRowProps = ViewsRowContentProps & {
|
|
37
|
+
onClick?: () => void;
|
|
38
|
+
/** For a row inside an editor that must keep its input focused. */
|
|
39
|
+
onMouseDown?: MouseEventHandler<HTMLButtonElement>;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/** Default true. False draws a line that is read, not pressed. */
|
|
42
|
+
interactive?: boolean;
|
|
43
|
+
/** The row opens a flyout beside its menu: `aria-haspopup="menu"`, and `aria-expanded` from `open`. */
|
|
44
|
+
opens?: boolean;
|
|
45
|
+
/** The flyout this row opens is up now: `aria-expanded`, `data-open` and the pressed ground. */
|
|
46
|
+
open?: boolean;
|
|
47
|
+
title?: string;
|
|
48
|
+
/** A role for a row that is not a plain button (an option, a tab); `aria-selected` rides only with one. */
|
|
49
|
+
role?: string;
|
|
50
|
+
"aria-selected"?: boolean;
|
|
51
|
+
};
|
|
52
|
+
/** A paint-only tick box: the control around it is the caller's. */
|
|
53
|
+
export type ViewsTickBoxProps = {
|
|
54
|
+
checked: boolean;
|
|
55
|
+
className?: string;
|
|
56
|
+
};
|
|
57
|
+
/** The rows' container: the inset a run of rows sits in, inside a panel or a command group. */
|
|
58
|
+
export type ViewsListProps = {
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
className?: string;
|
|
61
|
+
};
|
|
62
|
+
export type ViewsStatusBadgeProps = {
|
|
63
|
+
slot: StatusSlot;
|
|
64
|
+
label: ReactNode;
|
|
65
|
+
/** Replaces the slot's own mark. */
|
|
66
|
+
leading?: ReactNode;
|
|
67
|
+
title?: string;
|
|
68
|
+
/** Default `compact` (11px), the size a status value is drawn at in a cell. */
|
|
69
|
+
size?: "compact" | "regular";
|
|
70
|
+
className?: string;
|
|
71
|
+
};
|
|
72
|
+
export type ViewsStatusMarkerProps = {
|
|
73
|
+
/** Default `warning`: a marker is attention. */
|
|
74
|
+
slot?: StatusSlot;
|
|
75
|
+
label: string;
|
|
76
|
+
/** The panel's heading and the marker's accessible name. */
|
|
77
|
+
title: string;
|
|
78
|
+
reason?: string | null;
|
|
79
|
+
/** Shown when there is no reason; defaults to the package's wording. */
|
|
80
|
+
emptyReason?: string;
|
|
81
|
+
/** Absent: a read-only marker. */
|
|
82
|
+
onResolve?: () => void;
|
|
83
|
+
resolveLabel?: string;
|
|
84
|
+
};
|
|
85
|
+
export type ViewsTagProps = {
|
|
86
|
+
label: string;
|
|
87
|
+
color: CategoryColor;
|
|
88
|
+
/** A glyph before the label — an option's icon, drawn by the app's AppIcon. */
|
|
89
|
+
leading?: ReactNode;
|
|
90
|
+
/** Draws a remove control inside the tag. */
|
|
91
|
+
onRemove?: () => void;
|
|
92
|
+
/** The remove control's accessible name; defaults to the package's wording. */
|
|
93
|
+
removeLabel?: string;
|
|
94
|
+
className?: string;
|
|
95
|
+
};
|
|
96
|
+
/** A `command` cell's verb menu: the host's verbs, opened from the trigger the cell drew. The
|
|
97
|
+
* default is the app's menu primitive (the components map's `Menu`); an app swaps in its own
|
|
98
|
+
* action menu. */
|
|
99
|
+
export type ViewsCommandMenuProps = {
|
|
100
|
+
/** What opens the menu — the cell draws it, a button. */
|
|
101
|
+
trigger: ReactElement;
|
|
102
|
+
items: readonly FieldRowMenuItem[];
|
|
103
|
+
align?: "start" | "center" | "end";
|
|
104
|
+
};
|
|
105
|
+
/** Where a relation chip goes: the app's own link around the chip the display drew. The default
|
|
106
|
+
* goes nowhere — a relation is a fact as often as a destination. */
|
|
107
|
+
export type ViewsRelationLinkProps = {
|
|
108
|
+
relation: RelationValue;
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
};
|
|
111
|
+
/** A wait: the whole list reloading (`body`), or more rows arriving (`footer`). The default is a
|
|
112
|
+
* plain ring; an app swaps in its own loader. */
|
|
113
|
+
export type ViewsLoadingProps = {
|
|
114
|
+
placement: "body" | "footer";
|
|
115
|
+
label: string;
|
|
116
|
+
};
|
|
117
|
+
/** How a list asks for its next page once its end comes near. The default watches a sentinel past
|
|
118
|
+
* the last row and draws `Loading` (or the host's words) while it waits; an app swaps in its own —
|
|
119
|
+
* a button, a different distance. */
|
|
120
|
+
export type ViewsLoadMoreProps = {
|
|
121
|
+
onReveal: () => void;
|
|
122
|
+
label?: string;
|
|
123
|
+
};
|
|
124
|
+
/** A link's platform, drawn before the link (`linkPlatform`): its key says which, its name what to call it.
|
|
125
|
+
* The default draws nothing, so a link looks plain; an app swaps in its own marks. */
|
|
126
|
+
export type ViewsPlatformMarkProps = {
|
|
127
|
+
platform: LinkPlatform;
|
|
128
|
+
className?: string;
|
|
129
|
+
};
|
|
130
|
+
/** One row of the row's menu: a rule, or a labelled row with its click. The shape a host's own row-menu
|
|
131
|
+
* items already have, so a host hands its list through unchanged. */
|
|
132
|
+
export type ViewsRowMenuItem = {
|
|
133
|
+
separator: true;
|
|
134
|
+
} | {
|
|
135
|
+
separator?: false;
|
|
136
|
+
label: string;
|
|
137
|
+
icon?: ReactNode;
|
|
138
|
+
onClick: () => void;
|
|
139
|
+
destructive?: boolean;
|
|
140
|
+
disabled?: boolean;
|
|
141
|
+
/** A keyboard hint drawn at the row's end, never bound by the menu. */
|
|
142
|
+
shortcut?: string;
|
|
143
|
+
};
|
|
144
|
+
/** The row's right-click menu, around the row it opens on. The rendering builds `items` (the cell's
|
|
145
|
+
* clipboard rows, Select, the host's verbs); the menu adds the page link before them and Delete after.
|
|
146
|
+
* The default is the components map's `Menu` at the pointer; an app swaps in its own (a dialog before
|
|
147
|
+
* a delete, a long-press). */
|
|
148
|
+
export type ViewsRowMenuProps = {
|
|
149
|
+
/** The row: right-click on it, or the row's ⋯, opens the menu. */
|
|
150
|
+
children: ReactNode;
|
|
151
|
+
/** The row's data id: what `onDelete` is called with. */
|
|
152
|
+
rowId: string;
|
|
153
|
+
items: readonly ViewsRowMenuItem[];
|
|
154
|
+
/** The row's own page, opened in a new tab. Absent: no Open page row. */
|
|
155
|
+
openHref?: string;
|
|
156
|
+
/** Absent: no Delete row. */
|
|
157
|
+
onDelete?: (rowId: string) => Promise<void>;
|
|
158
|
+
/** What Delete removes, for an app's own confirmation; the default's confirm doesn't use it. */
|
|
159
|
+
deleteLabel?: string;
|
|
160
|
+
/** Flips the row's selection, for an app whose long-press selects. Absent when the list can't select.
|
|
161
|
+
* The default doesn't use it: on a phone the ⋯ is the way in. */
|
|
162
|
+
onToggleSelect?: () => void;
|
|
163
|
+
};
|
|
164
|
+
export type ViewsAtoms = {
|
|
165
|
+
List: ComponentType<ViewsListProps>;
|
|
166
|
+
Row: ComponentType<ViewsRowProps>;
|
|
167
|
+
RowContent: ComponentType<ViewsRowContentProps>;
|
|
168
|
+
TickBox: ComponentType<ViewsTickBoxProps>;
|
|
169
|
+
StatusBadge: ComponentType<ViewsStatusBadgeProps>;
|
|
170
|
+
StatusMarker: ComponentType<ViewsStatusMarkerProps>;
|
|
171
|
+
Tag: ComponentType<ViewsTagProps>;
|
|
172
|
+
CommandMenu: ComponentType<ViewsCommandMenuProps>;
|
|
173
|
+
RelationLink: ComponentType<ViewsRelationLinkProps>;
|
|
174
|
+
Loading: ComponentType<ViewsLoadingProps>;
|
|
175
|
+
LoadMore: ComponentType<ViewsLoadMoreProps>;
|
|
176
|
+
PlatformMark: ComponentType<ViewsPlatformMarkProps>;
|
|
177
|
+
RowMenu: ComponentType<ViewsRowMenuProps>;
|
|
178
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { PercentDisplay } from "@viewkitjs/fields";
|
|
3
|
+
import type { FieldPresentation, FieldViewerContext } from "../display/options.js";
|
|
4
|
+
import type { FieldRowMenuItem } from "../fields/menus.js";
|
|
5
|
+
import type { ListColumn, ListRelationValue, ListSelectColor } from "../model/column-schema.js";
|
|
6
|
+
import type { ListDateStyle, ListDurationStyle } from "../model/column-format.js";
|
|
7
|
+
/**
|
|
8
|
+
* COLUMN-SHAPED FORMATTING — the two string formatters that still take a column,
|
|
9
|
+
* and the per-row currency only this layer can resolve.
|
|
10
|
+
*
|
|
11
|
+
* The formatting itself is the display's (`../display/format.ts`), which turns a VALUE
|
|
12
|
+
* plus a field's `format` block into a string. These two stay because three
|
|
13
|
+
* consumers hold a column rather than a field — the footer aggregates
|
|
14
|
+
* (`GridFooter`) and the column menu's two live format previews
|
|
15
|
+
* (`GridColumnDateSection`, `GridColumnDurationSection`) — and asking each of
|
|
16
|
+
* them to synthesize a def would put the same translation in three places.
|
|
17
|
+
*
|
|
18
|
+
* The viewer is the caller's: these never read the runtime's locale or zone, nor any
|
|
19
|
+
* app's state. The grid's callers hand the provider's through `useCellFormat()`.
|
|
20
|
+
*/
|
|
21
|
+
/** Per-column render context threaded from GridTable (user overrides). */
|
|
22
|
+
export type GridCellOptions = {
|
|
23
|
+
presentation?: FieldPresentation;
|
|
24
|
+
viewer?: FieldViewerContext;
|
|
25
|
+
optionColors?: Record<string, ListSelectColor>;
|
|
26
|
+
dateStyle?: ListDateStyle;
|
|
27
|
+
durationStyle?: ListDurationStyle;
|
|
28
|
+
/** Number columns: the workspace's decimals override (header menu) — wins
|
|
29
|
+
* over the column's declared `format`. */
|
|
30
|
+
decimals?: number;
|
|
31
|
+
/** The code a value is drawn in when the CALLER knows it and the column's
|
|
32
|
+
* format does not — a per-row column's row code (`resolveRowCurrency`), a
|
|
33
|
+
* total's currency. Never a reader override: a reading lives on the column. */
|
|
34
|
+
currency?: string;
|
|
35
|
+
/** Date columns: per-user show-time override — wins over `format.withTime`. */
|
|
36
|
+
withTime?: boolean;
|
|
37
|
+
/** Percent columns: the workspace's display — wins over `format.percentDisplay`. */
|
|
38
|
+
percentDisplay?: PercentDisplay;
|
|
39
|
+
/** Per-user "Wrap columns" toggle: text-bearing cells wrap instead of
|
|
40
|
+
* truncating. See `cellTextClass` in the display. */
|
|
41
|
+
wrap?: boolean;
|
|
42
|
+
/** Optimistic pending value (Tier 3) — wins over `accessor(row)` when defined.
|
|
43
|
+
* Only typed cells honor it; custom `render` columns show confirmed data. */
|
|
44
|
+
valueOverride?: unknown;
|
|
45
|
+
/** `marker` booleans: the row's reason sentence (from `col.marker.reason`). */
|
|
46
|
+
markerReason?: string | null;
|
|
47
|
+
/**
|
|
48
|
+
* `marker` booleans: clear the exception. The only BEHAVIORAL entry in an
|
|
49
|
+
* otherwise display-only bag — deliberate. The alternative (rendering the
|
|
50
|
+
* marker from GridRow, the way editors are mounted) would split one type's
|
|
51
|
+
* rendering across two files to keep this one field out.
|
|
52
|
+
*/
|
|
53
|
+
onResolve?: () => void;
|
|
54
|
+
/**
|
|
55
|
+
* Two-way (`checkbox` / `icon`) booleans: flip the value. The twin of
|
|
56
|
+
* `onResolve` — that one is hardcoded `true → false`, this one carries the
|
|
57
|
+
* value, which is what a two-way column needs. Its PRESENCE is also what
|
|
58
|
+
* makes the cell interactive: without it the boolean renders as a plain,
|
|
59
|
+
* unclickable glyph, so a read-only or settings-locked column can't be toggled.
|
|
60
|
+
*/
|
|
61
|
+
onToggle?: (next: boolean) => void;
|
|
62
|
+
/**
|
|
63
|
+
* `command` columns: the verbs this row offers INSTEAD of an editor, already
|
|
64
|
+
* resolved for the row (`FieldMenus<Row>[key](row)`). Behavioral, like the two
|
|
65
|
+
* above, and for the same reason it sits here rather than in the row chrome:
|
|
66
|
+
* the cell IS the trigger, so the menu is part of how the value is drawn. Its
|
|
67
|
+
* PRESENCE is the affordance — a command column whose host wired no verbs is
|
|
68
|
+
* a read-only badge, never an empty dropdown.
|
|
69
|
+
*/
|
|
70
|
+
commandItems?: readonly FieldRowMenuItem[];
|
|
71
|
+
/**
|
|
72
|
+
* `relation` cells: open the entity this row POINTS AT — which is a different
|
|
73
|
+
* entity from the one `onOpenRow` opens, and the reason this can't reuse the
|
|
74
|
+
* row's own handler.
|
|
75
|
+
*
|
|
76
|
+
* Takes the CLICKED value rather than nothing, because a one-to-many cell has
|
|
77
|
+
* several and the caller can't re-derive which one you pressed: reading the
|
|
78
|
+
* accessor again would only ever hand back the first.
|
|
79
|
+
*
|
|
80
|
+
* An OVERRIDE, not the affordance. A relation is clickable by default — the
|
|
81
|
+
* chip resolves its own destination from the entity kind (drawer if that kind
|
|
82
|
+
* has one, else its page, else inert). Pass this only for a list whose
|
|
83
|
+
* relations go somewhere the app-wide answer cannot know: an execution's
|
|
84
|
+
* `thread` lands in the inbox, and its pre-collapse `prospect` goes nowhere.
|
|
85
|
+
*
|
|
86
|
+
* It used to be the affordance, and that is the bug it caused: every renderer
|
|
87
|
+
* builds this bag by hand, so whether a relation was clickable depended on
|
|
88
|
+
* which VIEW you were looking at — grid chips worked, board cards were dead.
|
|
89
|
+
*/
|
|
90
|
+
onOpenRelation?: (value: ListRelationValue) => void;
|
|
91
|
+
/**
|
|
92
|
+
* `relation` cells: this app's glyph for an entity KIND.
|
|
93
|
+
*
|
|
94
|
+
* The portable chip has no entity registry of its own; Portal's list binding
|
|
95
|
+
* supplies this resolver by default, and another host can supply its own.
|
|
96
|
+
*/
|
|
97
|
+
entityIcon?: (kind: string | undefined) => ReactNode;
|
|
98
|
+
/**
|
|
99
|
+
* A host whose own slot already owns the click and the drag — a calendar
|
|
100
|
+
* event card, whose outer element (not any cell inside it) is the button.
|
|
101
|
+
* Every typed cell draws its bare content only: a relation is its icon and
|
|
102
|
+
* label with no anchor or button wrapper, an overflow count is plain text
|
|
103
|
+
* with no popover trigger, a two-way boolean shows its glyph with no toggle.
|
|
104
|
+
* Set once by the host, never per column — a card that nested one of these
|
|
105
|
+
* controls inside the slot's own button would be invalid markup.
|
|
106
|
+
*/
|
|
107
|
+
slotOwnsClick?: boolean;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Fold the code a money cell is drawn in into the render options, so the
|
|
111
|
+
* formatter keeps its plain string contract and only the RESOLUTION moves up
|
|
112
|
+
* here — this is the only layer that has the row.
|
|
113
|
+
*
|
|
114
|
+
* There is no reader override here any more. A reader's choice is a READING on
|
|
115
|
+
* the column (`readMoneyColumn`): a converted column arrives with its
|
|
116
|
+
* `format.currency` already set and no `currencyAccessor`, a column read in
|
|
117
|
+
* Original with the row's code and no `format.currency`. Both are stamped: the
|
|
118
|
+
* row's own code onto a row's own figure, the reading's code onto a figure the
|
|
119
|
+
* reading converted — never a code onto a number it does not describe.
|
|
120
|
+
*
|
|
121
|
+
* The reading's code has to travel this way because a registry field with a
|
|
122
|
+
* per-row code (`code: { field }`, Deals' Value) has no fixed code for the core
|
|
123
|
+
* to fall back on: only a field-less column's def is synthesized from
|
|
124
|
+
* `format.currency`. Left out, the formatter draws EUR over a RON figure
|
|
125
|
+
* (POR-602). `shownCodeOf` is the same answer a custom `render` cell is handed.
|
|
126
|
+
*/
|
|
127
|
+
export declare function resolveRowCurrency<Row>(col: ListColumn<Row>, row: Row, opts?: GridCellOptions): GridCellOptions | undefined;
|
|
128
|
+
/** A date column's value as text — the column's `dateStyle`/`withTime` with the
|
|
129
|
+
* user's overrides on top, handed to the one date formatter, in the caller's viewer. */
|
|
130
|
+
export declare function formatDate(value: unknown, col: ListColumn<never>, override: ListDateStyle | undefined, withTimeOverride: boolean | undefined, viewer: FieldViewerContext): string;
|
|
131
|
+
/** Exported for the footer aggregates — sum/avg/min/max print with the same
|
|
132
|
+
* format (currency, decimals, display-currency override) as the cells. The
|
|
133
|
+
* column's format is read in the display layer's wider vocabulary, so a legacy
|
|
134
|
+
* percent or currency column's total prints as its cells do. The viewer and the
|
|
135
|
+
* presentation are the caller's (`useCellFormat`). */
|
|
136
|
+
export declare function formatNumber(value: number, col: ListColumn<never>, opts: GridCellOptions & {
|
|
137
|
+
viewer: FieldViewerContext;
|
|
138
|
+
}): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { formatDateValue, formatNumberValue } from "../display/format.js";
|
|
2
|
+
import { shownCodeOf } from "../fields/money.js";
|
|
3
|
+
import { temporalKindOf } from "../model/field-type-of.js";
|
|
4
|
+
import { legacyNumberLikeFormat } from "./legacy-field.js";
|
|
5
|
+
export function resolveRowCurrency(col, row, opts) {
|
|
6
|
+
if (col.currencyAccessor)
|
|
7
|
+
return { ...opts, currency: col.currencyAccessor(row) };
|
|
8
|
+
const code = shownCodeOf(col, row);
|
|
9
|
+
return code ? { ...opts, currency: code } : opts;
|
|
10
|
+
}
|
|
11
|
+
export function formatDate(value, col, override, withTimeOverride, viewer) {
|
|
12
|
+
return formatDateValue(value, override ?? col.format?.dateStyle, withTimeOverride ?? col.format?.withTime, temporalKindOf(col), { viewer });
|
|
13
|
+
}
|
|
14
|
+
export function formatNumber(value, col, opts) {
|
|
15
|
+
return formatNumberValue(value, legacyNumberLikeFormat(col), opts);
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { GridCellOptions } from "./cell-format.js";
|
|
3
|
+
import type { ListColumn } from "../model/column-schema.js";
|
|
4
|
+
/**
|
|
5
|
+
* THE TITLE CELL — the one typed cell the list owns, not a field.
|
|
6
|
+
*
|
|
7
|
+
* `title` is a column ROLE, not a storage type: the value it draws is text (or
|
|
8
|
+
* a number, or a date), and what makes the cell a title is that clicking it
|
|
9
|
+
* OPENS THE ROW. That is a fact about the list, not about the value, so this
|
|
10
|
+
* arm stays here; its content arrives drawn — text as itself, a figure or a
|
|
11
|
+
* moment through its field's core (`cell-values.tsx`).
|
|
12
|
+
*
|
|
13
|
+
* It also places its own `indicator`, which is why `renderTypedCell` skips its
|
|
14
|
+
* generic indicator lane for this type: the adornment has to sit inside the
|
|
15
|
+
* cell's own layout rules about where the click target ends.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderTitleCell<Row>(col: ListColumn<Row>, row: Row, content: ReactNode, opts?: GridCellOptions): ReactNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cellTextClass } from "../display/text-class.js";
|
|
4
|
+
import { cx } from "../internal/cx.js";
|
|
5
|
+
export function renderTitleCell(col, row, content, opts) {
|
|
6
|
+
const indicator = col.indicator?.(row);
|
|
7
|
+
return (_jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { "data-cell-open": true, className: cx("min-w-0 cursor-pointer font-medium text-(color:--vk-fg)", cellTextClass(opts?.wrap)), children: content }), indicator] }));
|
|
8
|
+
}
|