viewkitjs 0.21.0 → 0.23.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 +49 -0
- package/MIGRATION.md +1 -1
- package/README.md +1 -1
- package/fields/dist/conventions.d.ts +15 -3
- package/fields/dist/conventions.js +25 -0
- package/fields/dist/design/category-colors.d.ts +12 -5
- package/fields/dist/design/category-colors.js +7 -7
- package/fields/dist/query/buckets.js +42 -35
- package/fields/dist/query/date.js +2 -13
- package/fields/docs/guides/conventions.md +1 -1
- package/fields/docs/guides/options.md +2 -1
- package/fields/docs/reference/design-category-colors.md +2 -2
- package/fields/docs/reference/fields.md +1 -1
- package/package.json +13 -1
- package/views/dist/atoms/tones.js +7 -7
- package/views/dist/contract.d.ts +6 -1
- package/views/dist/contract.js +1 -0
- package/views/dist/controls/atoms.d.ts +8 -0
- package/views/dist/controls/atoms.js +8 -0
- package/views/dist/controls/button/button.d.ts +40 -0
- package/views/dist/controls/button/button.js +40 -0
- package/views/dist/controls/button/looks.d.ts +4 -0
- package/views/dist/controls/button/looks.js +20 -0
- package/views/dist/controls/button/map-button.d.ts +11 -0
- package/views/dist/controls/button/map-button.js +20 -0
- package/views/dist/controls/button/own-look.d.ts +59 -0
- package/views/dist/controls/button/own-look.js +33 -0
- package/views/dist/controls/button/tokens.d.ts +351 -0
- package/views/dist/controls/button/tokens.js +90 -0
- package/views/dist/controls/button.css +530 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +28 -0
- package/views/dist/controls/checkbox/checkbox.js +15 -0
- package/views/dist/controls/checkbox/looks.d.ts +3 -0
- package/views/dist/controls/checkbox/looks.js +8 -0
- package/views/dist/controls/checkbox/map-checkbox.d.ts +2 -0
- package/views/dist/controls/checkbox/map-checkbox.js +5 -0
- package/views/dist/controls/checkbox/tokens.d.ts +131 -0
- package/views/dist/controls/checkbox/tokens.js +35 -0
- package/views/dist/controls/checkbox.css +133 -0
- package/views/dist/controls/controls.d.ts +14 -0
- package/views/dist/controls/controls.js +14 -0
- package/views/dist/controls/field/field.d.ts +94 -0
- package/views/dist/controls/field/field.js +46 -0
- package/views/dist/controls/field/looks.d.ts +13 -0
- package/views/dist/controls/field/looks.js +22 -0
- package/views/dist/controls/field/tokens.d.ts +75 -0
- package/views/dist/controls/field/tokens.js +21 -0
- package/views/dist/controls/field.css +98 -0
- package/views/dist/controls/glass-button/glass-button.d.ts +40 -0
- package/views/dist/controls/glass-button/glass-button.js +16 -0
- package/views/dist/controls/glass-button/looks.d.ts +4 -0
- package/views/dist/controls/glass-button/looks.js +4 -0
- package/views/dist/controls/glass-button/tokens.d.ts +127 -0
- package/views/dist/controls/glass-button/tokens.js +34 -0
- package/views/dist/controls/glass-button.css +111 -0
- package/views/dist/controls/index.d.ts +37 -0
- package/views/dist/controls/index.js +31 -0
- package/views/dist/controls/inline-input/inline-input.d.ts +14 -0
- package/views/dist/controls/inline-input/inline-input.js +10 -0
- package/views/dist/controls/inline-input/looks.d.ts +3 -0
- package/views/dist/controls/inline-input/looks.js +16 -0
- package/views/dist/controls/inline-input/tokens.d.ts +79 -0
- package/views/dist/controls/inline-input/tokens.js +22 -0
- package/views/dist/controls/inline-input.css +78 -0
- package/views/dist/controls/input/autofill.d.ts +25 -0
- package/views/dist/controls/input/autofill.js +17 -0
- package/views/dist/controls/input/input.d.ts +119 -0
- package/views/dist/controls/input/input.js +127 -0
- package/views/dist/controls/input/looks.d.ts +41 -0
- package/views/dist/controls/input/looks.js +48 -0
- package/views/dist/controls/input/map-input.d.ts +2 -0
- package/views/dist/controls/input/map-input.js +5 -0
- package/views/dist/controls/input/tokens.d.ts +171 -0
- package/views/dist/controls/input/tokens.js +45 -0
- package/views/dist/controls/input.css +381 -0
- package/views/dist/controls/internal/anchor.d.ts +16 -0
- package/views/dist/controls/internal/anchor.js +8 -0
- package/views/dist/controls/internal/close-reason.d.ts +5 -0
- package/views/dist/controls/internal/close-reason.js +2 -0
- package/views/dist/controls/internal/popup-host.d.ts +7 -0
- package/views/dist/controls/internal/popup-host.js +10 -0
- package/views/dist/controls/internal/scroll.d.ts +11 -0
- package/views/dist/controls/internal/scroll.js +14 -0
- package/views/dist/controls/kbd/kbd.d.ts +13 -0
- package/views/dist/controls/kbd/kbd.js +10 -0
- package/views/dist/controls/kbd/looks.d.ts +4 -0
- package/views/dist/controls/kbd/looks.js +4 -0
- package/views/dist/controls/kbd/tokens.d.ts +47 -0
- package/views/dist/controls/kbd/tokens.js +14 -0
- package/views/dist/controls/kbd.css +46 -0
- package/views/dist/controls/number-field/number-field.d.ts +48 -0
- package/views/dist/controls/number-field/number-field.js +34 -0
- package/views/dist/controls/number-field/tokens.d.ts +47 -0
- package/views/dist/controls/number-field/tokens.js +14 -0
- package/views/dist/controls/number-field.css +54 -0
- package/views/dist/controls/option/atom-tag.d.ts +6 -0
- package/views/dist/controls/option/atom-tag.js +6 -0
- package/views/dist/controls/option/looks.d.ts +7 -0
- package/views/dist/controls/option/looks.js +21 -0
- package/views/dist/controls/option/option.d.ts +35 -0
- package/views/dist/controls/option/option.js +32 -0
- package/views/dist/controls/option/tokens.d.ts +223 -0
- package/views/dist/controls/option/tokens.js +58 -0
- package/views/dist/controls/option.css +92 -0
- package/views/dist/controls/phone-header/header-bar.d.ts +18 -0
- package/views/dist/controls/phone-header/header-bar.js +9 -0
- package/views/dist/controls/phone-header/looks.d.ts +4 -0
- package/views/dist/controls/phone-header/looks.js +4 -0
- package/views/dist/controls/phone-header/soft-edge.d.ts +5 -0
- package/views/dist/controls/phone-header/soft-edge.js +3 -0
- package/views/dist/controls/phone-header/tokens.d.ts +59 -0
- package/views/dist/controls/phone-header/tokens.js +17 -0
- package/views/dist/controls/phone-header.css +51 -0
- package/views/dist/controls/popover/looks.d.ts +4 -0
- package/views/dist/controls/popover/looks.js +10 -0
- package/views/dist/controls/popover/map-popover.d.ts +3 -0
- package/views/dist/controls/popover/map-popover.js +5 -0
- package/views/dist/controls/popover/popover.d.ts +74 -0
- package/views/dist/controls/popover/popover.js +106 -0
- package/views/dist/controls/popover/tokens.d.ts +83 -0
- package/views/dist/controls/popover/tokens.js +23 -0
- package/views/dist/controls/popover.css +94 -0
- package/views/dist/controls/scrollbar/scrollbar.d.ts +10 -0
- package/views/dist/controls/scrollbar/scrollbar.js +143 -0
- package/views/dist/controls/scrollbar/tokens.d.ts +43 -0
- package/views/dist/controls/scrollbar/tokens.js +13 -0
- package/views/dist/controls/scrollbar.css +47 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +98 -0
- package/views/dist/controls/sheet/bottom-sheet.js +372 -0
- package/views/dist/controls/sheet/forms.d.ts +38 -0
- package/views/dist/controls/sheet/forms.js +26 -0
- package/views/dist/controls/sheet/looks.d.ts +4 -0
- package/views/dist/controls/sheet/looks.js +10 -0
- package/views/dist/controls/sheet/map-sheet.d.ts +3 -0
- package/views/dist/controls/sheet/map-sheet.js +12 -0
- package/views/dist/controls/sheet/spring.d.ts +22 -0
- package/views/dist/controls/sheet/spring.js +48 -0
- package/views/dist/controls/sheet/tokens.d.ts +143 -0
- package/views/dist/controls/sheet/tokens.js +38 -0
- package/views/dist/controls/sheet.css +220 -0
- package/views/dist/controls/smooth.css +101 -0
- package/views/dist/controls/spinner/looks.d.ts +4 -0
- package/views/dist/controls/spinner/looks.js +32 -0
- package/views/dist/controls/spinner/spinner.d.ts +23 -0
- package/views/dist/controls/spinner/spinner.js +16 -0
- package/views/dist/controls/spinner/tokens.d.ts +55 -0
- package/views/dist/controls/spinner/tokens.js +16 -0
- package/views/dist/controls/spinner.css +147 -0
- package/views/dist/controls/status/atom-status-badge.d.ts +10 -0
- package/views/dist/controls/status/atom-status-badge.js +13 -0
- package/views/dist/controls/status/looks.d.ts +4 -0
- package/views/dist/controls/status/looks.js +22 -0
- package/views/dist/controls/status/marks.d.ts +26 -0
- package/views/dist/controls/status/marks.js +73 -0
- package/views/dist/controls/status/status.d.ts +43 -0
- package/views/dist/controls/status/status.js +26 -0
- package/views/dist/controls/status/tokens.d.ts +407 -0
- package/views/dist/controls/status/tokens.js +104 -0
- package/views/dist/controls/status.css +164 -0
- package/views/dist/controls/switch/looks.d.ts +4 -0
- package/views/dist/controls/switch/looks.js +19 -0
- package/views/dist/controls/switch/switch.d.ts +15 -0
- package/views/dist/controls/switch/switch.js +11 -0
- package/views/dist/controls/switch/tokens.d.ts +139 -0
- package/views/dist/controls/switch/tokens.js +37 -0
- package/views/dist/controls/switch.css +169 -0
- package/views/dist/controls/tag/atom-cell-more.d.ts +3 -0
- package/views/dist/controls/tag/atom-cell-more.js +5 -0
- package/views/dist/controls/tag/looks.d.ts +4 -0
- package/views/dist/controls/tag/looks.js +4 -0
- package/views/dist/controls/tag/tag.d.ts +25 -0
- package/views/dist/controls/tag/tag.js +19 -0
- package/views/dist/controls/tag/tokens.d.ts +63 -0
- package/views/dist/controls/tag/tokens.js +18 -0
- package/views/dist/controls/tag.css +81 -0
- package/views/dist/controls/toggle/looks.d.ts +3 -0
- package/views/dist/controls/toggle/looks.js +12 -0
- package/views/dist/controls/toggle/toggle.d.ts +47 -0
- package/views/dist/controls/toggle/toggle.js +23 -0
- package/views/dist/controls/toggle/tokens.d.ts +55 -0
- package/views/dist/controls/toggle/tokens.js +16 -0
- package/views/dist/controls/toggle.css +67 -0
- package/views/dist/controls/tokens.d.ts +16 -0
- package/views/dist/controls/tokens.js +45 -0
- package/views/dist/controls/tooltip/looks.d.ts +4 -0
- package/views/dist/controls/tooltip/looks.js +4 -0
- package/views/dist/controls/tooltip/map-tooltip.d.ts +3 -0
- package/views/dist/controls/tooltip/map-tooltip.js +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +75 -0
- package/views/dist/controls/tooltip/tokens.js +21 -0
- package/views/dist/controls/tooltip/tooltip.d.ts +54 -0
- package/views/dist/controls/tooltip/tooltip.js +78 -0
- package/views/dist/controls/tooltip.css +94 -0
- package/views/dist/display/date.js +15 -2
- package/views/dist/grid/chrome/GridTable.js +21 -19
- package/views/dist/grid/chrome/grid-row-window.js +3 -0
- package/views/dist/grid/chrome/useGridColumnLayout.d.ts +4 -1
- package/views/dist/grid/chrome/useGridColumnLayout.js +17 -2
- package/views/dist/grid/chrome/useGridFittedWidths.d.ts +29 -0
- package/views/dist/grid/chrome/useGridFittedWidths.js +46 -0
- package/views/dist/looks/index.d.ts +17 -0
- package/views/dist/looks/index.js +17 -0
- package/views/dist/looks/looks.d.ts +2 -1
- package/views/dist/looks/pieces.js +37 -1
- package/views/dist/model/column-schema.d.ts +3 -2
- package/views/dist/model/column-state.d.ts +11 -1
- package/views/dist/model/column-state.js +8 -2
- package/views/dist/panels/react/views-row/FoldingViewRow.js +8 -8
- package/views/dist/styles.css +2748 -56
- package/views/dist/styles.unlayered.css +2765 -56
- package/views/docs/contract.md +39 -8
- package/views/docs/controls/button.md +93 -0
- package/views/docs/controls/checkbox.md +38 -0
- package/views/docs/controls/field.md +26 -0
- package/views/docs/controls/glass-button.md +37 -0
- package/views/docs/controls/inline-input.md +27 -0
- package/views/docs/controls/input.md +48 -0
- package/views/docs/controls/kbd.md +17 -0
- package/views/docs/controls/number-field.md +17 -0
- package/views/docs/controls/option.md +61 -0
- package/views/docs/controls/phone-header.md +20 -0
- package/views/docs/controls/popover.md +26 -0
- package/views/docs/controls/scrollbar.md +16 -0
- package/views/docs/controls/sheet.md +41 -0
- package/views/docs/controls/spinner.md +19 -0
- package/views/docs/controls/status.md +107 -0
- package/views/docs/controls/switch.md +40 -0
- package/views/docs/controls/tag.md +21 -0
- package/views/docs/controls/toggle.md +19 -0
- package/views/docs/controls/tooltip.md +24 -0
- package/views/docs/getting-started.md +1 -1
- package/views/docs/guides/the-provider.md +1 -1
- package/views/docs/index.md +1 -0
- package/views/docs/install.md +2 -0
- package/views/docs/reference/controls.md +207 -0
- package/views/docs/reference/looks.md +77 -2
- package/views/docs/reference/views.md +10 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const TOOLTIP_TOKENS = [
|
|
2
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
3
|
+
{ name: "--vk-ground", kind: "colour", outright: "--surface" },
|
|
4
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
5
|
+
{ name: "--vk-corner-smoothing", kind: "size", outright: "--corner-smoothing" },
|
|
6
|
+
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
7
|
+
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
8
|
+
{ name: "--vk-font-size-2xs", kind: "size", outright: "--text-2xs" },
|
|
9
|
+
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
10
|
+
{ name: "--vk-line-height-xs", kind: "size", outright: "--text-xs--line-height" },
|
|
11
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
12
|
+
{ name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
|
|
13
|
+
{ name: "--vk-layer-popup", kind: "size", outright: "--layer-popup" },
|
|
14
|
+
{ name: "--vk-radius-md", kind: "size", outright: "--radius-md" },
|
|
15
|
+
{ name: "--vk-radius-xs", kind: "size", outright: "--radius-xs" },
|
|
16
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
17
|
+
{ name: "--vk-tooltip-delay", kind: "motion", outright: "--tooltip-delay" },
|
|
18
|
+
{ name: "--vk-tooltip-warm", kind: "motion", outright: "--tooltip-warm" },
|
|
19
|
+
{ name: "--vk-toast-duration", kind: "motion", outright: "--toast-duration" },
|
|
20
|
+
];
|
|
21
|
+
export const TOOLTIP_PRIVATE = ["--tooltip-"];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** Its times, in ms, the Outright look's, where nothing declares them: how long the pointer rests before it shows, how long
|
|
3
|
+
* after one has shown in a group the next shows at once, and how long a tapped reason stays. Each is read where it applies,
|
|
4
|
+
* from what it names, as its stylesheet hands it there (--vk-tooltip-delay, --vk-tooltip-warm, --vk-toast-duration), so a
|
|
5
|
+
* look set round a tooltip reaches it. */
|
|
6
|
+
export declare const TOOLTIP_TIMING: {
|
|
7
|
+
readonly delay: 500;
|
|
8
|
+
readonly warm: 300;
|
|
9
|
+
readonly tap: 4000;
|
|
10
|
+
};
|
|
11
|
+
export interface TooltipProps {
|
|
12
|
+
/** The words: an icon button's name, the same as its aria-label; or why something can't be used. */
|
|
13
|
+
label: React.ReactNode;
|
|
14
|
+
/** The keys of its shortcut, after the words, when the action has one. */
|
|
15
|
+
keys?: string[];
|
|
16
|
+
/** A longer reason (why a button is off): it wraps, in the regular weight. */
|
|
17
|
+
reason?: boolean;
|
|
18
|
+
/** Where it sits when there's room: above by default. */
|
|
19
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
20
|
+
/** Where along that side it lines up with what it names: its start, its middle (the default) or its end. */
|
|
21
|
+
align?: "start" | "center" | "end";
|
|
22
|
+
/** How far from what it names it stands, in px: 6 unless said, 10 where the Arrow is worn. */
|
|
23
|
+
sideOffset?: number;
|
|
24
|
+
/** How far along its side it moves from where `align` puts it, in px. */
|
|
25
|
+
alignOffset?: number;
|
|
26
|
+
/** Open, set from outside (a shortcut, a walkthrough), with onOpenChange told every time it opens or closes. */
|
|
27
|
+
open?: boolean;
|
|
28
|
+
/** Open at first. */
|
|
29
|
+
defaultOpen?: boolean;
|
|
30
|
+
/** It opens or closes. */
|
|
31
|
+
onOpenChange?: (open: boolean) => void;
|
|
32
|
+
/** It doesn't show: what it names says it all already (a name that isn't cut). */
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/** How long the pointer rests on what it names before it shows, in ms: read from what it names unless said. */
|
|
35
|
+
delay?: number;
|
|
36
|
+
/** What it names: one element that takes a ref (a Button). A button that is off keeps its focus and
|
|
37
|
+
* pointer for its reason (the Button's focusableWhenDisabled). */
|
|
38
|
+
children: React.ReactElement;
|
|
39
|
+
}
|
|
40
|
+
/** The name of a button that shows only an icon, or why something can't be used: on hover and on keyboard
|
|
41
|
+
* focus, and on a touch screen a reason on a tap on what's off. The button keeps its own aria-label; the tooltip is tied to it with aria-describedby. */
|
|
42
|
+
export declare function Tooltip({ label, keys, reason, side, align, sideOffset, alignOffset, open, defaultOpen, onOpenChange, disabled, delay, children }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export interface TooltipGroupProps {
|
|
44
|
+
/** How long after one has shown the next shows at once, in ms: read off the first of its tooltips unless said. */
|
|
45
|
+
warm?: number;
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
}
|
|
48
|
+
/** Tooltips side by side (a toolbar): once one has shown, the next shows at once for its warm time. */
|
|
49
|
+
export declare function TooltipGroup({ warm, children }: TooltipGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
/** The tooltip standing open beside what it names, for a page that shows how it looks: above, below or
|
|
51
|
+
* beside it, never floating. Without what it names, the tooltip alone in the line. */
|
|
52
|
+
export declare function TooltipShown({ label, keys, reason, side, align, children }: Pick<TooltipProps, "label" | "keys" | "reason" | "side" | "align"> & {
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { usePopupHost } from "../internal/popup-host.js";
|
|
6
|
+
import { Kbd } from "../kbd/kbd.js";
|
|
7
|
+
export const TOOLTIP_TIMING = { delay: 500, warm: 300, tap: 4000 };
|
|
8
|
+
function readMs(el, name, fallback) {
|
|
9
|
+
const v = el ? getComputedStyle(el).getPropertyValue(name).trim() : "", n = parseFloat(v);
|
|
10
|
+
return Number.isNaN(n) ? fallback : /\dms$/.test(v) ? n : /\ds$/.test(v) ? n * 1000 : n;
|
|
11
|
+
}
|
|
12
|
+
const GroupWarm = React.createContext(null);
|
|
13
|
+
const Box = ({ label, keys }) => _jsxs(_Fragment, { children: [label, keys && _jsx(Kbd, { keys: keys })] });
|
|
14
|
+
const gap = (trigger, popup) => (parseFloat(popup ? getComputedStyle(popup).getPropertyValue("--vk-spacing") : "") || 4) * (trigger?.closest('[data-tooltip-arrow="soft"]') ? 2.5 : 1.5);
|
|
15
|
+
export function Tooltip({ label, keys, reason, side = "top", align = "center", sideOffset, alignOffset = 0, open, defaultOpen, onOpenChange, disabled, delay, children }) {
|
|
16
|
+
const ref = React.useRef(null), popup = React.useRef(null), host = usePopupHost(ref), id = React.useId();
|
|
17
|
+
const [wait, setWait] = React.useState(TOOLTIP_TIMING.delay), tellWarm = React.useContext(GroupWarm);
|
|
18
|
+
React.useLayoutEffect(() => {
|
|
19
|
+
setWait(readMs(ref.current, "--tooltip-wait", TOOLTIP_TIMING.delay));
|
|
20
|
+
tellWarm?.(readMs(ref.current, "--tooltip-warm-now", TOOLTIP_TIMING.warm));
|
|
21
|
+
}, [tellWarm]);
|
|
22
|
+
const [own, setOwn] = React.useState(!!defaultOpen), shown = open ?? own, tapped = React.useRef(false);
|
|
23
|
+
const told = React.useRef(onOpenChange);
|
|
24
|
+
const set = React.useCallback((o) => { if (!o)
|
|
25
|
+
tapped.current = false; setOwn(o); told.current?.(o); }, []);
|
|
26
|
+
const off = (el) => el.getAttribute("aria-disabled") === "true" || el.disabled === true || el.hasAttribute("data-disabled");
|
|
27
|
+
const now = React.useRef({ shown, reason, disabled, set });
|
|
28
|
+
React.useLayoutEffect(() => {
|
|
29
|
+
told.current = onOpenChange;
|
|
30
|
+
now.current = { shown, reason, disabled, set };
|
|
31
|
+
if (!shown)
|
|
32
|
+
tapped.current = false;
|
|
33
|
+
});
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
const el = ref.current;
|
|
36
|
+
if (!el)
|
|
37
|
+
return;
|
|
38
|
+
const down = (e) => {
|
|
39
|
+
const { shown, reason, disabled, set } = now.current;
|
|
40
|
+
if (e.pointerType !== "touch" || !reason || disabled || !off(el))
|
|
41
|
+
return;
|
|
42
|
+
if (tapped.current && shown) {
|
|
43
|
+
set(false);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
tapped.current = true;
|
|
47
|
+
set(true);
|
|
48
|
+
};
|
|
49
|
+
el.addEventListener("pointerdown", down);
|
|
50
|
+
return () => el.removeEventListener("pointerdown", down);
|
|
51
|
+
}, []);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (!shown || !tapped.current)
|
|
54
|
+
return;
|
|
55
|
+
const away = (e) => { if (!ref.current?.contains(e.target))
|
|
56
|
+
set(false); };
|
|
57
|
+
const timer = setTimeout(() => set(false), readMs(ref.current, "--tooltip-tap", TOOLTIP_TIMING.tap));
|
|
58
|
+
document.addEventListener("pointerdown", away, true);
|
|
59
|
+
return () => { document.removeEventListener("pointerdown", away, true); clearTimeout(timer); };
|
|
60
|
+
}, [shown, set]);
|
|
61
|
+
return (_jsxs(BaseTooltip.Root, { disabled: disabled, open: shown, onOpenChange: (o, details) => { if (!o && tapped.current && (details?.reason === "trigger-press" || details?.reason === "trigger-hover"))
|
|
62
|
+
return; set(o); }, children: [_jsx(BaseTooltip.Trigger, { ref: ref, render: children, className: "o-tooltip-trigger", delay: delay ?? wait, closeDelay: 0, "aria-describedby": id }), _jsx(BaseTooltip.Portal, { container: host, children: _jsx(BaseTooltip.Positioner, { className: "o-tooltip-positioner", side: side, align: align, alignOffset: alignOffset, sideOffset: () => sideOffset ?? gap(ref.current, popup.current), children: _jsxs(BaseTooltip.Popup, { ref: popup, id: id, className: cx("o-tooltip o-smooth o-smooth-ease", reason && "o-tooltip-reason"), "data-kit": "tooltip", children: [_jsx(Box, { label: label, keys: keys }), _jsx(BaseTooltip.Arrow, { className: "o-tooltip-arrow" })] }) }) })] }));
|
|
63
|
+
}
|
|
64
|
+
export function TooltipGroup({ warm, children }) {
|
|
65
|
+
const [read, setRead] = React.useState(TOOLTIP_TIMING.warm), first = React.useRef(false);
|
|
66
|
+
const tell = React.useCallback((ms) => { if (!first.current) {
|
|
67
|
+
first.current = true;
|
|
68
|
+
setRead(ms);
|
|
69
|
+
} }, []);
|
|
70
|
+
return _jsx(GroupWarm.Provider, { value: tell, children: _jsx(BaseTooltip.Provider, { timeout: warm ?? read, children: children }) });
|
|
71
|
+
}
|
|
72
|
+
export function TooltipShown({ label, keys, reason, side = "top", align = "center", children }) {
|
|
73
|
+
const ref = React.useRef(null);
|
|
74
|
+
React.useLayoutEffect(() => { const a = ref.current, first = a?.firstElementChild; if (a && first && first !== a.lastElementChild)
|
|
75
|
+
a.style.setProperty("--tooltip-anchor-width", `${first.offsetWidth}px`); }, []);
|
|
76
|
+
const box = _jsxs("span", { className: cx("o-tooltip o-smooth o-smooth-ease", reason && "o-tooltip-reason"), role: "tooltip", "data-side": side, "data-align": align, "data-kit": "tooltip", children: [_jsx(Box, { label: label, keys: keys }), _jsx("span", { className: "o-tooltip-arrow", "aria-hidden": "true" })] });
|
|
77
|
+
return children ? _jsxs("span", { ref: ref, className: "o-tooltip-anchor", children: [children, box] }) : box;
|
|
78
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* The Tooltip. Every value it draws with is a public name (controls/tooltip/tokens.ts); this file only says which name each
|
|
2
|
+
part takes. Base UI marks the popup data-starting-style and data-ending-style as it comes and goes, and data-side where it
|
|
3
|
+
sits. What an app sets once is a data attribute on the frame around it (looks.ts):
|
|
4
|
+
|
|
5
|
+
data-tooltip-arrow none · soft no arrow, or a soft point, the tooltip standing 10px off with it and 6px without
|
|
6
|
+
|
|
7
|
+
The rules sit in the components layer, so a utility class on a tooltip still wins. */
|
|
8
|
+
@layer components {
|
|
9
|
+
|
|
10
|
+
/* ── The tooltip: the page's text colour as its ground and the page's ground as its words, so it stands
|
|
11
|
+
out in both themes with no shadow; 6px by 8px, ¾ of the radius, 6px from what it names ──────────── */
|
|
12
|
+
.o-tooltip {
|
|
13
|
+
box-sizing: border-box; display: inline-flex; align-items: center; gap: calc(var(--vk-spacing) * 2);
|
|
14
|
+
width: max-content; max-width: calc(var(--vk-spacing) * 80);
|
|
15
|
+
padding: calc(var(--vk-spacing) * 1.5) calc(var(--vk-spacing) * 2); border-radius: var(--vk-radius-md);
|
|
16
|
+
background-color: var(--vk-fg); color: var(--vk-ground);
|
|
17
|
+
font-size: var(--vk-font-size-xs); line-height: calc(var(--vk-font-size-xs) * var(--vk-line-height-xs)); font-weight: var(--vk-font-weight-medium);
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
transition: opacity var(--vk-duration-fast) var(--vk-ease-out), translate var(--vk-duration-fast) var(--vk-ease-out);
|
|
20
|
+
}
|
|
21
|
+
.o-tooltip-positioner { z-index: var(--vk-layer-popup); }
|
|
22
|
+
/* What it names hands its script its times, read there so a look set round it reaches them: the wait before it shows, how long a
|
|
23
|
+
tapped reason stays, and a group's warm time. */
|
|
24
|
+
.o-tooltip-trigger { --tooltip-wait: var(--vk-tooltip-delay); --tooltip-tap: var(--vk-toast-duration); --tooltip-warm-now: var(--vk-tooltip-warm); }
|
|
25
|
+
/* It fades in and rises 2px. */
|
|
26
|
+
.o-tooltip:is([data-starting-style], [data-ending-style]) { opacity: 0; translate: 0 calc(var(--vk-spacing) * 0.5); }
|
|
27
|
+
|
|
28
|
+
/* ── A longer reason: it wraps, at least 200px wide and at most 320px, in the regular weight ────────── */
|
|
29
|
+
.o-tooltip.o-tooltip-reason { width: auto; min-width: calc(var(--vk-spacing) * 50); font-weight: var(--vk-font-weight-normal); }
|
|
30
|
+
|
|
31
|
+
/* ── Its shortcut: the tooltip's own small key, 16px, outlined in its words' colour (the Kbd inside) ─── */
|
|
32
|
+
.o-tooltip .o-kbd {
|
|
33
|
+
min-width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4); padding: 0 calc(var(--vk-spacing) * 1);
|
|
34
|
+
border: 0; border-radius: var(--vk-radius-xs); box-shadow: inset 0 0 0 var(--vk-border-width) currentColor;
|
|
35
|
+
background-color: transparent; color: inherit; font-size: var(--vk-font-size-2xs); vertical-align: baseline;
|
|
36
|
+
}
|
|
37
|
+
.o-tooltip .o-keys { gap: calc(var(--vk-spacing) * 2); }
|
|
38
|
+
|
|
39
|
+
/* ── Shown standing open on a sheet: above, below or beside what it names ───────────────────────────── */
|
|
40
|
+
.o-tooltip-anchor { position: relative; display: inline-flex; }
|
|
41
|
+
.o-tooltip-anchor > .o-tooltip { position: absolute; z-index: 1; }
|
|
42
|
+
.o-tooltip-anchor > .o-tooltip[data-side="top"] { bottom: calc(100% + var(--vk-spacing) * 1.5); left: 50%; translate: -50% 0; }
|
|
43
|
+
.o-tooltip-anchor > .o-tooltip[data-side="bottom"] { top: calc(100% + var(--vk-spacing) * 1.5); left: 50%; translate: -50% 0; }
|
|
44
|
+
.o-tooltip-anchor > .o-tooltip[data-side="right"] { left: calc(100% + var(--vk-spacing) * 1.5); top: 50%; translate: 0 -50%; }
|
|
45
|
+
.o-tooltip-anchor > .o-tooltip[data-side="left"] { right: calc(100% + var(--vk-spacing) * 1.5); top: 50%; translate: 0 -50%; }
|
|
46
|
+
|
|
47
|
+
/* ── Lined up at its start or its end, shown standing open ────────────────────────────────────────────── */
|
|
48
|
+
.o-tooltip-anchor > .o-tooltip:is([data-side="top"], [data-side="bottom"])[data-align="start"] { left: 0; translate: none; }
|
|
49
|
+
.o-tooltip-anchor > .o-tooltip:is([data-side="top"], [data-side="bottom"])[data-align="end"] { left: auto; right: 0; translate: none; }
|
|
50
|
+
.o-tooltip-anchor > .o-tooltip:is([data-side="left"], [data-side="right"])[data-align="start"] { top: 0; translate: none; }
|
|
51
|
+
.o-tooltip-anchor > .o-tooltip:is([data-side="left"], [data-side="right"])[data-align="end"] { top: auto; bottom: 0; translate: none; }
|
|
52
|
+
|
|
53
|
+
/* ── The Arrow: None, or a soft point, a 10px square turned on its corner, its corners softened, half of it
|
|
54
|
+
showing; with it the tooltip stands 10px off. Base UI places the live one's along its side; the shown one points at the
|
|
55
|
+
middle of what it names. ─────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
56
|
+
.o-tooltip-arrow { display: none; }
|
|
57
|
+
[data-tooltip-arrow="soft"] .o-tooltip-arrow {
|
|
58
|
+
display: block; position: absolute; width: calc(var(--vk-spacing) * 2.5); height: calc(var(--vk-spacing) * 2.5);
|
|
59
|
+
border-radius: calc(var(--vk-radius-xs) * 0.75); background-color: var(--vk-fg); rotate: 45deg; pointer-events: none;
|
|
60
|
+
}
|
|
61
|
+
[data-tooltip-arrow="soft"] .o-tooltip[data-side="top"] > .o-tooltip-arrow { bottom: calc(var(--vk-spacing) * -1); }
|
|
62
|
+
[data-tooltip-arrow="soft"] .o-tooltip[data-side="bottom"] > .o-tooltip-arrow { top: calc(var(--vk-spacing) * -1); }
|
|
63
|
+
[data-tooltip-arrow="soft"] .o-tooltip[data-side="right"] > .o-tooltip-arrow { left: calc(var(--vk-spacing) * -1); }
|
|
64
|
+
[data-tooltip-arrow="soft"] .o-tooltip[data-side="left"] > .o-tooltip-arrow { right: calc(var(--vk-spacing) * -1); }
|
|
65
|
+
/* Shown standing open: 10px off, its point at the middle of what it names. */
|
|
66
|
+
[data-tooltip-arrow="soft"] .o-tooltip-anchor > .o-tooltip[data-side="top"] { bottom: calc(100% + var(--vk-spacing) * 2.5); }
|
|
67
|
+
[data-tooltip-arrow="soft"] .o-tooltip-anchor > .o-tooltip[data-side="bottom"] { top: calc(100% + var(--vk-spacing) * 2.5); }
|
|
68
|
+
[data-tooltip-arrow="soft"] .o-tooltip-anchor > .o-tooltip[data-side="right"] { left: calc(100% + var(--vk-spacing) * 2.5); }
|
|
69
|
+
[data-tooltip-arrow="soft"] .o-tooltip-anchor > .o-tooltip[data-side="left"] { right: calc(100% + var(--vk-spacing) * 2.5); }
|
|
70
|
+
[data-tooltip-arrow="soft"] .o-tooltip-anchor > .o-tooltip:is([data-side="top"], [data-side="bottom"]) > .o-tooltip-arrow { left: calc(50% - var(--vk-spacing) * 1.25); }
|
|
71
|
+
[data-tooltip-arrow="soft"] .o-tooltip-anchor > .o-tooltip:is([data-side="top"], [data-side="bottom"])[data-align="start"] > .o-tooltip-arrow { left: calc(var(--tooltip-anchor-width, 50%) / 2 - var(--vk-spacing) * 1.25); }
|
|
72
|
+
[data-tooltip-arrow="soft"] .o-tooltip-anchor > .o-tooltip:is([data-side="top"], [data-side="bottom"])[data-align="end"] > .o-tooltip-arrow { left: auto; right: calc(var(--tooltip-anchor-width, 50%) / 2 - var(--vk-spacing) * 1.25); }
|
|
73
|
+
[data-tooltip-arrow="soft"] .o-tooltip-anchor > .o-tooltip:is([data-side="left"], [data-side="right"]) > .o-tooltip-arrow { top: calc(50% - var(--vk-spacing) * 1.25); }
|
|
74
|
+
|
|
75
|
+
/* Under reduced motion it just appears. */
|
|
76
|
+
@media (prefers-reduced-motion: reduce) { .o-tooltip { transition: none; } }
|
|
77
|
+
/* ── Its corners smooth: following --vk-corner-smoothing, drawn with the smooth outline
|
|
78
|
+
(smooth.css) in every browser that knows shape(); one that doesn't keeps the corners above. Its round part is fitted to its
|
|
79
|
+
one line, as a control's is. Its arrow stands outside it, so it is never clipped: its ground is a layer inside it (::before),
|
|
80
|
+
clipped, as the Popover's is, over the box its positioner hugs (the tooltip takes no position of its own, so its arrow stands
|
|
81
|
+
where Base UI puts it); the arrow stays as it draws. Its own small key stays as it draws (kbd.css). ── */
|
|
82
|
+
@supports (clip-path: shape(evenodd from 0 0, curve by 1px 1px with 1px 0 / 1px 0, close, move to 0 0, hline to 1px, close)) and (width: calc(tan(atan2(1px, 1px)) * 1px)) {
|
|
83
|
+
.o-tooltip {
|
|
84
|
+
--smooth-amount: var(--vk-corner-smoothing); --tooltip-side: calc(var(--vk-font-size-xs) * var(--vk-line-height-xs) + var(--vk-spacing) * 3);
|
|
85
|
+
--tooltip-fit: min(var(--vk-radius-md), var(--tooltip-side) / (2 + 2 * var(--smooth-amount, 0.7)));
|
|
86
|
+
--smooth-t: var(--tooltip-fit); --smooth-side: var(--tooltip-side);
|
|
87
|
+
isolation: isolate; border-radius: var(--tooltip-fit); background-color: transparent;
|
|
88
|
+
}
|
|
89
|
+
.o-tooltip::before {
|
|
90
|
+
content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
|
|
91
|
+
background-color: var(--vk-fg); clip-path: shape(var(--smooth-outline));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -14,14 +14,27 @@ function DateValue({ field, value, opts: given, }) {
|
|
|
14
14
|
const opts = useDisplayOptions(given);
|
|
15
15
|
const { Tooltip } = useViews().components;
|
|
16
16
|
const [pointed, setPointed] = useState(false);
|
|
17
|
+
const [pressed, setPressed] = useState(false);
|
|
18
|
+
const hold = () => {
|
|
19
|
+
setPressed(true);
|
|
20
|
+
const release = () => {
|
|
21
|
+
window.removeEventListener("pointerup", release, true);
|
|
22
|
+
window.removeEventListener("pointercancel", release, true);
|
|
23
|
+
setTimeout(() => setPressed(false), 0);
|
|
24
|
+
};
|
|
25
|
+
window.addEventListener("pointerup", release, true);
|
|
26
|
+
window.addEventListener("pointercancel", release, true);
|
|
27
|
+
};
|
|
17
28
|
const withTime = opts.withTime ?? (field.type === "datetime" ? field.format?.withTime : false);
|
|
18
|
-
const cell = (_jsx("span", { className: cx(cellTextClass(opts.wrap), "tabular-nums text-(color:--vk-fg)"),
|
|
29
|
+
const cell = (_jsx("span", { className: cx(cellTextClass(opts.wrap), "tabular-nums text-(color:--vk-fg)"), onPointerMove: pointed
|
|
30
|
+
? undefined
|
|
31
|
+
: (event) => event.pointerType !== "touch" && event.buttons === 0 && setPointed(true), onPointerDown: pointed || pressed ? undefined : (event) => event.pointerType !== "touch" && hold(), children: formatDateValue(value, opts.dateStyle ?? field.format?.dateStyle, withTime, field.type, opts) }));
|
|
19
32
|
const d = field.type === "date" && typeof value === "string"
|
|
20
33
|
? fromDayKey(value)
|
|
21
34
|
: value instanceof Date
|
|
22
35
|
? value
|
|
23
36
|
: new Date(String(value));
|
|
24
|
-
if (!pointed || !d || Number.isNaN(d.getTime()))
|
|
37
|
+
if (!pointed || pressed || !d || Number.isNaN(d.getTime()))
|
|
25
38
|
return cell;
|
|
26
39
|
const full = formatDateValue(value, "long", field.type === "datetime", field.type, opts);
|
|
27
40
|
return (_jsx(Tooltip, { content: full, side: "bottom", align: "start", delayMs: 1000, className: "tabular-nums", children: cell }));
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useContext, useDeferredValue, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
4
4
|
import { createGridHoverStore, GridHoverContext, useAnyHover, useGridHeldHover } from "./grid-hover.js";
|
|
5
|
+
import { GridFitContext } from "./useGridFittedWidths.js";
|
|
5
6
|
import { useViews } from "../../provider/context.js";
|
|
6
7
|
import { GridRailProbe, useGridRailReveal } from "./useGridRailReveal.js";
|
|
7
8
|
import { useGridBatchApi } from "./useGridBatchApi.js";
|
|
@@ -104,7 +105,7 @@ function GridTableContent(props) {
|
|
|
104
105
|
const hoverStore = useAnyHover() ? madeHoverStore : null;
|
|
105
106
|
useGridHeldHover(hoverStore, props.hoveredRow, props.onHoveredRowChange);
|
|
106
107
|
const onOpenColumnMenuChange = useGridHeldMenuReport(props.openColumnMenu, props.onOpenColumnMenuChange);
|
|
107
|
-
const { visibleColumns, widthVarsStyle, frozenCount, frozenLeft, columnManager, gridTemplate, minWidth, resizingId, startResize, moveResize, endResize, resetColumnWidth, hideColumn, moveColumn, } = useGridColumnLayout({
|
|
108
|
+
const { visibleColumns, widthVarsStyle, fit, frozenCount, frozenLeft, columnManager, gridTemplate, minWidth, resizingId, startResize, moveResize, endResize, resetColumnWidth, hideColumn, moveColumn, } = useGridColumnLayout({
|
|
108
109
|
rootRef,
|
|
109
110
|
columns: laidOut,
|
|
110
111
|
columnState,
|
|
@@ -113,6 +114,7 @@ function GridTableContent(props) {
|
|
|
113
114
|
freezeIdentity,
|
|
114
115
|
viewBacked: props.viewBacked,
|
|
115
116
|
fillWidth: props.fillWidth,
|
|
117
|
+
phone,
|
|
116
118
|
});
|
|
117
119
|
const showAddColumn = !!columnManager &&
|
|
118
120
|
(!phone || !!props.addColumnOnPhone) &&
|
|
@@ -373,22 +375,22 @@ function GridTableContent(props) {
|
|
|
373
375
|
: undefined;
|
|
374
376
|
const footer = (group) => (_jsx(GridFooter, { group: group, ariaRowIndex: aria.footIndex(grouped ? group.key : (flat.sections[0]?.groupKey ?? group.key)), ariaLevel: grouped ? 2 : undefined, ariaColOffset: ariaColOffset, columns: visibleColumns, selecting: selecting, aggregates: aggregates, numberFormats: numberFormats, renderAggregate: renderAggregate, onAggregateChange: onAggregateChange, viewBacked: props.viewBacked, frozenCount: frozenCount, frozenLeft: frozenLeft, continuation: props.renderGroupFooter?.(group), defaultCurrency: props.defaultCurrency, pageOnly: paged, pin: pinFooter?.pin }));
|
|
375
377
|
const groupCheckbox = (items) => pickOnPhone ? (_jsx(GridHeadCheckBox, { ...groupSelection(items), "aria-label": messages({ key: "views.grid.select-group" }) })) : (_jsx(GridHeadCheck, { selecting: selecting, ...groupSelection(items), "aria-label": messages({ key: "views.grid.select-group" }) }));
|
|
376
|
-
return (_jsx(EditLeaveContext.Provider, { value: leaveScope, children: _jsx(GridHoverContext.Provider, { value: hoverStore, children: _jsx(GridRowWindowContext.Provider, { value: rowWindow.store, children: _jsx(GridTableSurface, { rootRef: rootRef, empty: empty, desktop: !phone, areaRef: areaRef, panRef: panRef, boxes: boxes, minWidth: minWidth, columnsTemplate: gridTemplate, gridAria: empty
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
378
|
+
return (_jsx(EditLeaveContext.Provider, { value: leaveScope, children: _jsx(GridFitContext.Provider, { value: fit, children: _jsx(GridHoverContext.Provider, { value: hoverStore, children: _jsx(GridRowWindowContext.Provider, { value: rowWindow.store, children: _jsx(GridTableSurface, { rootRef: rootRef, empty: empty, desktop: !phone, areaRef: areaRef, panRef: panRef, boxes: boxes, minWidth: minWidth, columnsTemplate: gridTemplate, gridAria: empty
|
|
379
|
+
? { role: "grid", rowCount: 2, colCount: ariaTailIndex }
|
|
380
|
+
: { role: aria.role, rowCount: aria.rowCount, colCount: ariaTailIndex }, style: { ...widthVarsStyle, ...scaleVarsStyle }, selecting: selecting, pinFooter: pinFooter, railRootProps: rail.rootProps, onPointerDown: (event) => {
|
|
381
|
+
longPress.onPointerDown(event);
|
|
382
|
+
if (checkDrag.tryArm(event))
|
|
383
|
+
return;
|
|
384
|
+
handleRootPointerDown(event);
|
|
385
|
+
}, onPointerDownCapture: handleRootPointerDownCapture, onClickCapture: (event) => {
|
|
386
|
+
if (checkDrag.consumeDrag() || longPress.consumeClick()) {
|
|
387
|
+
event.preventDefault();
|
|
388
|
+
event.stopPropagation();
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
handleRootClickCapture(event);
|
|
392
|
+
}, railProbe: _jsx(GridRailProbe, { probeRef: rail.probeRef }), onGuardFocus: (which, from) => {
|
|
393
|
+
if (!settlingFrom())
|
|
394
|
+
enterGrid(which, from);
|
|
395
|
+
}, body: _jsx(GridBody, { empty: empty, emptyState: emptyState, grouped: grouped, oneHead: oneHead, groups: groups, rows: flatRows, selectable: selectable, selecting: selecting, phoneChecks: pickOnPhone, foldOverChecks: foldOverChecks, allSelected: sel.allSelected, someSelected: sel.someSelected, selectAll: sel.selectAll, clearSelection: sel.clear, isCollapsed: isCollapsed, countOf: countOf, sort: sort, sortOptions: sortOptions, groupSummary: groupSummary, onToggleGroup: onToggleGroup, onGroupSummaryChange: onGroupSummaryChange, renderGroupLabel: renderGroupLabel, onHideGroup: onHideGroup, groupMenu: props.groupMenu, figures: bandFigures, countNoun: countNoun, renderHeader: header, renderGroupCheckbox: groupCheckbox, selectGroup: groupSelection, renderRow: renderRow, wrapRows: wrapRows, renderFooter: footer, keptFor: keptFor, barIndexOf: aria.barIndex, ariaColCount: ariaTailIndex }), loadMore: !paged && loadMore?.hasMore ? _jsx(LoadMore, { onReveal: loadMore.onReveal, label: loadMore.label }) : undefined, pager: paged ? _jsx(GridPager, { pages: pages, rowsOnPage: total }) : undefined, selectionBar: selection?.renderBar?.(sel, batchApi) }) }) }) }) }));
|
|
394
396
|
}
|
|
@@ -5,6 +5,7 @@ import { flushSync } from "react-dom";
|
|
|
5
5
|
import { GRID_WINDOW_FALLBACK_ROWS, gridGroupRange, gridRowSegments, } from "../core/row-window.js";
|
|
6
6
|
import { cx } from "../../internal/cx.js";
|
|
7
7
|
import { GridFrozenEdge } from "./checks.js";
|
|
8
|
+
import { GridFitContext } from "./useGridFittedWidths.js";
|
|
8
9
|
import { findGridScrollOwner, gridVisibleBox } from "./grid-scroll-owner.js";
|
|
9
10
|
const sameRange = (a, b) => a === b || (a != null && b != null && a.start === b.start && a.end === b.end);
|
|
10
11
|
export function createGridRowWindowStore() {
|
|
@@ -262,6 +263,8 @@ export const GRID_GAP_LINES = "repeating-linear-gradient(to bottom, transparent
|
|
|
262
263
|
export function GridWindowRows({ groupKey, items, collapsed, kept, renderRow, ...container }) {
|
|
263
264
|
const snapshot = useGridGroupWindow(groupKey);
|
|
264
265
|
const store = useContext(GridRowWindowContext);
|
|
266
|
+
const fit = useContext(GridFitContext);
|
|
267
|
+
useLayoutEffect(() => fit?.());
|
|
265
268
|
const watchGap = useCallback((gap) => (gap && store ? store.watchGap(gap) : undefined), [store]);
|
|
266
269
|
const range = snapshot.range === undefined ? fallbackRange(items.length, collapsed) : snapshot.range;
|
|
267
270
|
const { revealed } = snapshot;
|
|
@@ -2,7 +2,7 @@ import { type PointerEvent as ReactPointerEvent, type RefObject } from "react";
|
|
|
2
2
|
import type { ListColumnsConfig } from "../../model/column-state.js";
|
|
3
3
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
4
4
|
import { type ListColumnState } from "../../model/column-state.js";
|
|
5
|
-
export declare function useGridColumnLayout<Row>({ rootRef, columns, columnState, onColumnStateChange, scale, freezeIdentity, viewBacked, fillWidth, }: {
|
|
5
|
+
export declare function useGridColumnLayout<Row>({ rootRef, columns, columnState, onColumnStateChange, scale, freezeIdentity, viewBacked, fillWidth, phone, }: {
|
|
6
6
|
rootRef: RefObject<HTMLDivElement | null>;
|
|
7
7
|
columns: ListColumn<Row>[];
|
|
8
8
|
columnState?: ListColumnState;
|
|
@@ -14,9 +14,12 @@ export declare function useGridColumnLayout<Row>({ rootRef, columns, columnState
|
|
|
14
14
|
viewBacked?: boolean;
|
|
15
15
|
/** The columns share the grid's width (`GridTableProps.fillWidth`). */
|
|
16
16
|
fillWidth?: boolean;
|
|
17
|
+
/** A phone: its pinned columns with no width of their own stay at the default instead of fitting their values. */
|
|
18
|
+
phone?: boolean;
|
|
17
19
|
}): {
|
|
18
20
|
visibleColumns: ListColumn<Row>[];
|
|
19
21
|
widthVarsStyle: import("react").CSSProperties;
|
|
22
|
+
fit: () => void;
|
|
20
23
|
frozenCount: number;
|
|
21
24
|
frozenLeft: (i: number) => string;
|
|
22
25
|
columnManager: ListColumnsConfig | null;
|
|
@@ -6,12 +6,13 @@ import { clampColumnWidth, columnHideable, isColumnHidden, prettifyOptionValue,
|
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
7
|
import { gridColumnGlyph } from "./column-glyph.js";
|
|
8
8
|
import { gridColumnsTemplate } from "./grid-columns-template.js";
|
|
9
|
+
import { useGridFittedWidths } from "./useGridFittedWidths.js";
|
|
9
10
|
import { partWord } from "../../model/part-rows.js";
|
|
10
11
|
function setBodyResizeState(active) {
|
|
11
12
|
document.body.style.cursor = active ? "col-resize" : "";
|
|
12
13
|
document.body.style.userSelect = active ? "none" : "";
|
|
13
14
|
}
|
|
14
|
-
export function useGridColumnLayout({ rootRef, columns, columnState, onColumnStateChange, scale, freezeIdentity = true, viewBacked = false, fillWidth = false, }) {
|
|
15
|
+
export function useGridColumnLayout({ rootRef, columns, columnState, onColumnStateChange, scale, freezeIdentity = true, viewBacked = false, fillWidth = false, phone = false, }) {
|
|
15
16
|
const { icons, components, messages } = useViews();
|
|
16
17
|
const orderKey = columnState?.order;
|
|
17
18
|
const hiddenKey = columnState?.hidden;
|
|
@@ -31,7 +32,6 @@ export function useGridColumnLayout({ rootRef, columns, columnState, onColumnSta
|
|
|
31
32
|
visible: shownKey?.filter((id) => managedIds.has(id)),
|
|
32
33
|
});
|
|
33
34
|
}, [columns, orderKey, hiddenKey, shownKey, viewBacked]);
|
|
34
|
-
const effectiveWidths = useMemo(() => resolveColumnWidths(visibleColumns, columnState?.widths), [visibleColumns, columnState?.widths]);
|
|
35
35
|
const frozenCount = useMemo(() => {
|
|
36
36
|
if (!freezeIdentity)
|
|
37
37
|
return 0;
|
|
@@ -40,6 +40,20 @@ export function useGridColumnLayout({ rootRef, columns, columnState, onColumnSta
|
|
|
40
40
|
return 0;
|
|
41
41
|
return Math.max(0, Math.min(i + 1, visibleColumns.length - 1));
|
|
42
42
|
}, [freezeIdentity, visibleColumns]);
|
|
43
|
+
const pinnedOnPhone = useMemo(() => (phone ? new Set(visibleColumns.slice(0, frozenCount).map((col) => col.id)) : undefined), [phone, visibleColumns, frozenCount]);
|
|
44
|
+
const { fitted, fit } = useGridFittedWidths({
|
|
45
|
+
rootRef,
|
|
46
|
+
columns: visibleColumns,
|
|
47
|
+
stored: columnState?.widths,
|
|
48
|
+
scale,
|
|
49
|
+
skip: pinnedOnPhone,
|
|
50
|
+
});
|
|
51
|
+
const effectiveWidths = useMemo(() => {
|
|
52
|
+
const kept = pinnedOnPhone
|
|
53
|
+
? Object.fromEntries(Object.entries(fitted).filter(([id]) => !pinnedOnPhone.has(id)))
|
|
54
|
+
: fitted;
|
|
55
|
+
return resolveColumnWidths(visibleColumns, columnState?.widths, kept);
|
|
56
|
+
}, [visibleColumns, columnState?.widths, fitted, pinnedOnPhone]);
|
|
43
57
|
const frozenLeft = useCallback((i) => `calc(var(--vk-rail-w)` +
|
|
44
58
|
visibleColumns
|
|
45
59
|
.slice(0, i)
|
|
@@ -235,6 +249,7 @@ export function useGridColumnLayout({ rootRef, columns, columnState, onColumnSta
|
|
|
235
249
|
return {
|
|
236
250
|
visibleColumns,
|
|
237
251
|
widthVarsStyle,
|
|
252
|
+
fit,
|
|
238
253
|
frozenCount,
|
|
239
254
|
frozenLeft,
|
|
240
255
|
columnManager,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
3
|
+
/** The grid's fit, which a group's rows call after each commit that draws them: rows arriving after the grid's own
|
|
4
|
+
* commit (the row window's ranges re-render only the groups) are read there, still before the paint. */
|
|
5
|
+
export declare const GridFitContext: import("react").Context<(() => void) | null>;
|
|
6
|
+
/**
|
|
7
|
+
* The widths the grid fitted its columns to: a visible column with no width of its own and none stored is read once,
|
|
8
|
+
* in the first commit that draws a cell of it (the rows on screen, plus the window's margin), at its widest drawn
|
|
9
|
+
* value's width and never narrower than its header's (`fittedColumnWidth`). Kept by column id, so a scroll, a page
|
|
10
|
+
* more, a value that grows or a column hidden and shown again never moves it.
|
|
11
|
+
*
|
|
12
|
+
* The read: every drawn cell of the columns still to fit, and their header cells, laid out at their content's own
|
|
13
|
+
* width (inline, put back at once), then each one's layout width, which a transform round the grid doesn't change,
|
|
14
|
+
* over the grid's scale. One layout of the drawn cells, inside a layout effect, so the new widths are drawn before the
|
|
15
|
+
* paint and no width is seen changing; once every visible column is fitted, a commit costs a lookup per column.
|
|
16
|
+
*
|
|
17
|
+
* `skip`: columns left at their default (on a phone, the pinned ones). `fit` runs after the grid's own commits and,
|
|
18
|
+
* through `GridFitContext`, after each group's.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useGridFittedWidths<Row>({ rootRef, columns, stored, scale, skip, }: {
|
|
21
|
+
rootRef: RefObject<HTMLElement | null>;
|
|
22
|
+
columns: readonly ListColumn<Row>[];
|
|
23
|
+
stored?: Record<string, number>;
|
|
24
|
+
scale: number;
|
|
25
|
+
skip?: ReadonlySet<string>;
|
|
26
|
+
}): {
|
|
27
|
+
fitted: Record<string, number>;
|
|
28
|
+
fit: () => void;
|
|
29
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { fittedColumnWidth } from "../../model/column-state.js";
|
|
4
|
+
const NATURAL = { width: "max-content", minWidth: "0", maxWidth: "none", flex: "none" };
|
|
5
|
+
export const GridFitContext = createContext(null);
|
|
6
|
+
export function useGridFittedWidths({ rootRef, columns, stored, scale, skip, }) {
|
|
7
|
+
const [fitted, setFitted] = useState({});
|
|
8
|
+
const latest = useRef({ columns, stored, scale, skip });
|
|
9
|
+
const done = useRef({});
|
|
10
|
+
useLayoutEffect(() => {
|
|
11
|
+
latest.current = { columns, stored, scale, skip };
|
|
12
|
+
});
|
|
13
|
+
const fit = useCallback(() => {
|
|
14
|
+
const root = rootRef.current;
|
|
15
|
+
if (!root)
|
|
16
|
+
return;
|
|
17
|
+
const { columns, stored, scale, skip } = latest.current;
|
|
18
|
+
const reads = [];
|
|
19
|
+
for (const col of columns) {
|
|
20
|
+
if (col.width != null || stored?.[col.id] != null || done.current[col.id] != null || skip?.has(col.id))
|
|
21
|
+
continue;
|
|
22
|
+
const id = CSS.escape(col.id);
|
|
23
|
+
const cells = [...root.querySelectorAll(`[data-col-id="${id}"]`)];
|
|
24
|
+
if (cells.length > 0)
|
|
25
|
+
reads.push({ col, cells, header: root.querySelector(`[data-headcell="${id}"]`) });
|
|
26
|
+
}
|
|
27
|
+
if (reads.length === 0)
|
|
28
|
+
return;
|
|
29
|
+
const boxes = reads.flatMap((read) => (read.header ? [...read.cells, read.header] : read.cells));
|
|
30
|
+
const kept = boxes.map((box) => box.style.cssText);
|
|
31
|
+
for (const box of boxes)
|
|
32
|
+
Object.assign(box.style, NATURAL);
|
|
33
|
+
const read = (box) => (box.offsetWidth + 1) / scale;
|
|
34
|
+
const next = {};
|
|
35
|
+
for (const { col, cells, header } of reads) {
|
|
36
|
+
next[col.id] = fittedColumnWidth(col, Math.max(...cells.map(read)), header ? read(header) : 0);
|
|
37
|
+
}
|
|
38
|
+
boxes.forEach((box, i) => {
|
|
39
|
+
box.style.cssText = kept[i];
|
|
40
|
+
});
|
|
41
|
+
done.current = { ...done.current, ...next };
|
|
42
|
+
setFitted(done.current);
|
|
43
|
+
}, [rootRef]);
|
|
44
|
+
useLayoutEffect(fit);
|
|
45
|
+
return { fitted, fit };
|
|
46
|
+
}
|
|
@@ -5,3 +5,20 @@
|
|
|
5
5
|
export { lookAttrs, lookPicks, lookWorn, lookWornOf, type Look, type LookDevice, type LookOption, type LookPicks, type LookValue, type PieceLooks, } from "./looks.js";
|
|
6
6
|
export { LOOKS } from "./pieces.js";
|
|
7
7
|
export { GRID_LOOKS, GRID_LOOK_READ, gridLookProps, gridLookWorn, gridLookWornOf, type GridLookOptionId, type GridLookProps, type GridLookWorn, } from "../grid/looks.js";
|
|
8
|
+
export { BUTTON_LOOKS, type ButtonLookOptionId } from "../controls/button/looks.js";
|
|
9
|
+
export { SPINNER_LOOKS, type SpinnerLookOptionId } from "../controls/spinner/looks.js";
|
|
10
|
+
export { KBD_LOOKS, type KbdLookOptionId } from "../controls/kbd/looks.js";
|
|
11
|
+
export { TOOLTIP_LOOKS, type TooltipLookOptionId } from "../controls/tooltip/looks.js";
|
|
12
|
+
export { GLASS_BUTTON_LOOKS, type GlassButtonLookOptionId } from "../controls/glass-button/looks.js";
|
|
13
|
+
export { POPOVER_LOOKS, type PopoverLookOptionId } from "../controls/popover/looks.js";
|
|
14
|
+
export { PHONE_HEADER_LOOKS, type PhoneHeaderLookOptionId } from "../controls/phone-header/looks.js";
|
|
15
|
+
export { SHEET_LOOKS, type SheetLookOptionId } from "../controls/sheet/looks.js";
|
|
16
|
+
export { CHECKBOX_LOOKS, type CheckboxLookOptionId } from "../controls/checkbox/looks.js";
|
|
17
|
+
export { FIELD_LOOKS, fieldRowsAttrs, type FieldLookOptionId, type FieldRowsLook } from "../controls/field/looks.js";
|
|
18
|
+
export { INLINE_INPUT_LOOKS, type InlineInputLookOptionId } from "../controls/inline-input/looks.js";
|
|
19
|
+
export { INPUT_LOOKS, attioBox, inputAttrs, inputFrameAttrs, inputOwnAttrs, kindLook, type InputCorner, type InputGround, type InputLookOptionId, type InputOwnLook, type InputPad, type InputPicks, type InputWords, } from "../controls/input/looks.js";
|
|
20
|
+
export { TOGGLE_LOOKS, type ToggleLookOptionId } from "../controls/toggle/looks.js";
|
|
21
|
+
export { OPTION_LOOKS, optionColours, type OptionColour, type OptionLookOptionId } from "../controls/option/looks.js";
|
|
22
|
+
export { STATUS_LOOKS, type StatusLookOptionId } from "../controls/status/looks.js";
|
|
23
|
+
export { SWITCH_LOOKS, type SwitchLookOptionId } from "../controls/switch/looks.js";
|
|
24
|
+
export { TAG_LOOKS, type TagLookOptionId } from "../controls/tag/looks.js";
|
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
export { lookAttrs, lookPicks, lookWorn, lookWornOf, } from "./looks.js";
|
|
2
2
|
export { LOOKS } from "./pieces.js";
|
|
3
3
|
export { GRID_LOOKS, GRID_LOOK_READ, gridLookProps, gridLookWorn, gridLookWornOf, } from "../grid/looks.js";
|
|
4
|
+
export { BUTTON_LOOKS } from "../controls/button/looks.js";
|
|
5
|
+
export { SPINNER_LOOKS } from "../controls/spinner/looks.js";
|
|
6
|
+
export { KBD_LOOKS } from "../controls/kbd/looks.js";
|
|
7
|
+
export { TOOLTIP_LOOKS } from "../controls/tooltip/looks.js";
|
|
8
|
+
export { GLASS_BUTTON_LOOKS } from "../controls/glass-button/looks.js";
|
|
9
|
+
export { POPOVER_LOOKS } from "../controls/popover/looks.js";
|
|
10
|
+
export { PHONE_HEADER_LOOKS } from "../controls/phone-header/looks.js";
|
|
11
|
+
export { SHEET_LOOKS } from "../controls/sheet/looks.js";
|
|
12
|
+
export { CHECKBOX_LOOKS } from "../controls/checkbox/looks.js";
|
|
13
|
+
export { FIELD_LOOKS, fieldRowsAttrs } from "../controls/field/looks.js";
|
|
14
|
+
export { INLINE_INPUT_LOOKS } from "../controls/inline-input/looks.js";
|
|
15
|
+
export { INPUT_LOOKS, attioBox, inputAttrs, inputFrameAttrs, inputOwnAttrs, kindLook, } from "../controls/input/looks.js";
|
|
16
|
+
export { TOGGLE_LOOKS } from "../controls/toggle/looks.js";
|
|
17
|
+
export { OPTION_LOOKS, optionColours } from "../controls/option/looks.js";
|
|
18
|
+
export { STATUS_LOOKS } from "../controls/status/looks.js";
|
|
19
|
+
export { SWITCH_LOOKS } from "../controls/switch/looks.js";
|
|
20
|
+
export { TAG_LOOKS } from "../controls/tag/looks.js";
|
|
@@ -27,7 +27,8 @@ export type Look<Id extends string = string> = {
|
|
|
27
27
|
readonly device?: LookDevice;
|
|
28
28
|
readonly picks: Readonly<Record<Id, string>>;
|
|
29
29
|
};
|
|
30
|
-
/** A piece's options and looks
|
|
30
|
+
/** A piece's options and looks. Nothing picked wears each option's default (`def`), My preset's pick, which no look need
|
|
31
|
+
* match whole. */
|
|
31
32
|
export type PieceLooks<Id extends string = string> = {
|
|
32
33
|
readonly id: string;
|
|
33
34
|
readonly name: string;
|
|
@@ -1,2 +1,38 @@
|
|
|
1
1
|
import { GRID_LOOKS } from "../grid/looks.js";
|
|
2
|
-
|
|
2
|
+
import { BUTTON_LOOKS } from "../controls/button/looks.js";
|
|
3
|
+
import { SPINNER_LOOKS } from "../controls/spinner/looks.js";
|
|
4
|
+
import { KBD_LOOKS } from "../controls/kbd/looks.js";
|
|
5
|
+
import { TOOLTIP_LOOKS } from "../controls/tooltip/looks.js";
|
|
6
|
+
import { GLASS_BUTTON_LOOKS } from "../controls/glass-button/looks.js";
|
|
7
|
+
import { POPOVER_LOOKS } from "../controls/popover/looks.js";
|
|
8
|
+
import { PHONE_HEADER_LOOKS } from "../controls/phone-header/looks.js";
|
|
9
|
+
import { SHEET_LOOKS } from "../controls/sheet/looks.js";
|
|
10
|
+
import { CHECKBOX_LOOKS } from "../controls/checkbox/looks.js";
|
|
11
|
+
import { FIELD_LOOKS } from "../controls/field/looks.js";
|
|
12
|
+
import { INLINE_INPUT_LOOKS } from "../controls/inline-input/looks.js";
|
|
13
|
+
import { INPUT_LOOKS } from "../controls/input/looks.js";
|
|
14
|
+
import { TOGGLE_LOOKS } from "../controls/toggle/looks.js";
|
|
15
|
+
import { OPTION_LOOKS } from "../controls/option/looks.js";
|
|
16
|
+
import { STATUS_LOOKS } from "../controls/status/looks.js";
|
|
17
|
+
import { SWITCH_LOOKS } from "../controls/switch/looks.js";
|
|
18
|
+
import { TAG_LOOKS } from "../controls/tag/looks.js";
|
|
19
|
+
export const LOOKS = [
|
|
20
|
+
GRID_LOOKS,
|
|
21
|
+
BUTTON_LOOKS,
|
|
22
|
+
SPINNER_LOOKS,
|
|
23
|
+
KBD_LOOKS,
|
|
24
|
+
TOOLTIP_LOOKS,
|
|
25
|
+
GLASS_BUTTON_LOOKS,
|
|
26
|
+
POPOVER_LOOKS,
|
|
27
|
+
PHONE_HEADER_LOOKS,
|
|
28
|
+
SHEET_LOOKS,
|
|
29
|
+
INPUT_LOOKS,
|
|
30
|
+
INLINE_INPUT_LOOKS,
|
|
31
|
+
FIELD_LOOKS,
|
|
32
|
+
TOGGLE_LOOKS,
|
|
33
|
+
CHECKBOX_LOOKS,
|
|
34
|
+
OPTION_LOOKS,
|
|
35
|
+
TAG_LOOKS,
|
|
36
|
+
STATUS_LOOKS,
|
|
37
|
+
SWITCH_LOOKS,
|
|
38
|
+
];
|