cursedbelt 6.14.0 → 6.15.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/dist/react/components/ControlPanel.d.ts +2 -1
- package/dist/react/components/ControlPanel.d.ts.map +1 -1
- package/dist/react/components/ControlPanel.js +4 -3
- package/dist/react/components/ControlPanel.js.map +1 -1
- package/dist/react/components/FieldGrid.d.ts +23 -1
- package/dist/react/components/FieldGrid.d.ts.map +1 -1
- package/dist/react/components/FieldGrid.js +26 -4
- package/dist/react/components/FieldGrid.js.map +1 -1
- package/dist/react/components/SliderField.d.ts.map +1 -1
- package/dist/react/components/SliderField.js +8 -2
- package/dist/react/components/SliderField.js.map +1 -1
- package/package.json +2 -2
- package/src/react/components/ControlPanel.tsx +5 -4
- package/src/react/components/FieldGrid.tsx +41 -3
- package/src/react/components/SliderField.tsx +8 -2
- package/src/react/components/SliderField.valueColumn.spec.tsx +73 -0
|
@@ -35,7 +35,8 @@ export interface ControlPanelProps {
|
|
|
35
35
|
* boxes — whitespace and a 1px vertical rule between columns. Columns wrap whole, every column in
|
|
36
36
|
* a row is the same height and padding, and each group's fields share one label column. On a
|
|
37
37
|
* phone the groups become stacked accordions (the first open), so the canvas above stays in view
|
|
38
|
-
* and no column is squeezed past use.
|
|
38
|
+
* and no column is squeezed past use. Every slider in the panel shares one value column
|
|
39
|
+
* ({@link SliderValueColumnScope}), across its groups.
|
|
39
40
|
*/
|
|
40
41
|
export declare function ControlPanel({ title, actions, children, columnMin, className, ...rest }: ControlPanelProps): import("react").JSX.Element;
|
|
41
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlPanel.d.ts","sourceRoot":"","sources":["../../../src/react/components/ControlPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAItD,OAAO,EAAa,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"ControlPanel.d.ts","sourceRoot":"","sources":["../../../src/react/components/ControlPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAItD,OAAO,EAAa,KAAK,cAAc,EAA0B,MAAM,gBAAgB,CAAC;AAKxF,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,QAAQ,EAAE,SAAS,CAAC;IACpB,6FAA6F;IAC7F,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yEAAyE;IACzE,UAAU,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAgB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,+BAiCjH;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAiB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,+BAsBtH"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMediaQuery } from '../hooks/useMediaQuery.js';
|
|
3
3
|
import { cn } from '../lib/cn.js';
|
|
4
4
|
import { Collapsible } from './Collapsible.js';
|
|
5
|
-
import { FieldGrid } from './FieldGrid.js';
|
|
5
|
+
import { FieldGrid, SliderValueColumnScope } from './FieldGrid.js';
|
|
6
6
|
/** Below this a panel's columns would be squeezed past use, so they stack as accordions (FRM-17). */
|
|
7
7
|
const PHONE_QUERY = '(max-width: 639px)';
|
|
8
8
|
const COLUMN_MIN = {
|
|
@@ -16,12 +16,13 @@ const COLUMN_MIN = {
|
|
|
16
16
|
* boxes — whitespace and a 1px vertical rule between columns. Columns wrap whole, every column in
|
|
17
17
|
* a row is the same height and padding, and each group's fields share one label column. On a
|
|
18
18
|
* phone the groups become stacked accordions (the first open), so the canvas above stays in view
|
|
19
|
-
* and no column is squeezed past use.
|
|
19
|
+
* and no column is squeezed past use. Every slider in the panel shares one value column
|
|
20
|
+
* ({@link SliderValueColumnScope}), across its groups.
|
|
20
21
|
*/
|
|
21
22
|
export function ControlPanel({ title, actions, children, columnMin = 'md', className, ...rest }) {
|
|
22
23
|
const phone = useMediaQuery(PHONE_QUERY);
|
|
23
24
|
const name = typeof title === 'string' ? title : undefined;
|
|
24
|
-
return (_jsxs("section", { ...rest, className: cn('flex min-w-0 flex-col gap-4', className), "data-cb-control-panel": phone ? 'stacked' : 'columns', "aria-label": name, children: [title != null || actions != null ? (_jsxs("div", { className: 'flex min-w-0 items-center justify-between gap-3', "data-cb-control-panel-header": '', children: [title != null ? _jsx("h2", { className: 'm-0 min-w-0 truncate text-sm font-semibold text-foreground', children: title }) : _jsx("span", {}), actions != null ? _jsx("div", { className: 'flex shrink-0 items-center gap-2', children: actions }) : null] })) : null, phone ? (_jsx("div", { className: 'flex flex-col divide-y divide-border', "data-cb-control-panel-groups": '', "data-phone": '', children: children })) : (_jsx("div", { className: 'cb-control-panel-frame', children: _jsx("div", { className: 'cb-control-panel-groups', "data-cb-control-panel-groups": '', style: { '--cb-panel-col-min': COLUMN_MIN[columnMin] }, children: children }) }))] }));
|
|
25
|
+
return (_jsxs("section", { ...rest, className: cn('flex min-w-0 flex-col gap-4', className), "data-cb-control-panel": phone ? 'stacked' : 'columns', "aria-label": name, children: [title != null || actions != null ? (_jsxs("div", { className: 'flex min-w-0 items-center justify-between gap-3', "data-cb-control-panel-header": '', children: [title != null ? _jsx("h2", { className: 'm-0 min-w-0 truncate text-sm font-semibold text-foreground', children: title }) : _jsx("span", {}), actions != null ? _jsx("div", { className: 'flex shrink-0 items-center gap-2', children: actions }) : null] })) : null, phone ? (_jsx("div", { className: 'flex flex-col divide-y divide-border', "data-cb-control-panel-groups": '', "data-phone": '', children: _jsx(SliderValueColumnScope, { children: children }) })) : (_jsx("div", { className: 'cb-control-panel-frame', children: _jsx("div", { className: 'cb-control-panel-groups', "data-cb-control-panel-groups": '', style: { '--cb-panel-col-min': COLUMN_MIN[columnMin] }, children: _jsx(SliderValueColumnScope, { children: children }) }) }))] }));
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* One topic column of a {@link ControlPanel}: a `.cb-meta-label` eyebrow over a {@link FieldGrid},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlPanel.js","sourceRoot":"","sources":["../../../src/react/components/ControlPanel.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ControlPanel.js","sourceRoot":"","sources":["../../../src/react/components/ControlPanel.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAuB,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExF,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/B,KAAK,EAAE,EAAE,oBAAoB,EAAE,UAAU,CAAC,SAAS,CAAC,EAAmB,YAEvE,KAAC,sBAAsB,cAAE,QAAQ,GAA0B,GACvD,GACF,CACP,IACO,CACX,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,EAAqB;IACrH,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,KAAC,SAAS,IAAC,UAAU,EAAE,UAAU,YAAG,QAAQ,GAAa,CAAC;IACvE,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CACL,iBAAS,IAAI,EAAE,SAAS,EAAE,SAAS,2BAAwB,EAAE,YAC3D,KAAC,WAAW,IACV,OAAO,EAAE,eAAM,SAAS,EAAC,eAAe,YAAE,KAAK,GAAQ,EACvD,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAC,WAAW,YAE3B,IAAI,GACO,GACV,CACP,CAAC;IACJ,CAAC;IACD,OAAO,CACL,uBAAc,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,0BAA0B,EAAE,SAAS,CAAC,2BAAwB,EAAE,aAChG,iBAAQ,SAAS,EAAC,wBAAwB,YAAE,KAAK,GAAU,EAC1D,IAAI,IACI,CACZ,CAAC;AACJ,CAAC"}
|
|
@@ -13,13 +13,35 @@ export interface FieldGridProps {
|
|
|
13
13
|
}
|
|
14
14
|
/** The enclosing FieldGrid's label width, or `null` outside one — SliderField sizes its narrow-grid threshold from it (forge task 2667). */
|
|
15
15
|
export declare const useFieldGridLabelWidth: () => NonNullable<"sm" | "md" | "lg" | undefined> | null;
|
|
16
|
+
/**
|
|
17
|
+
* The value column a panel's `SliderField`s share (forge task 5550). Each slider measures its own
|
|
18
|
+
* longest readout; one that needs the wide box registers here, and while any does, every slider in
|
|
19
|
+
* the scope draws the wide box — so a `1.00×` row and an `Auto 2×` row end their tracks on one edge.
|
|
20
|
+
*/
|
|
21
|
+
export interface SliderValueColumn {
|
|
22
|
+
/** Some slider in the scope needs the wide value box. */
|
|
23
|
+
wide: boolean;
|
|
24
|
+
/** A slider that needs the wide box calls this; the returned function takes it back. */
|
|
25
|
+
claimWide: () => () => void;
|
|
26
|
+
}
|
|
27
|
+
/** The enclosing scope's shared value column, or `null` outside one — then a slider sizes its box alone. */
|
|
28
|
+
export declare const useSliderValueColumn: () => SliderValueColumn | null;
|
|
29
|
+
/**
|
|
30
|
+
* Opens a shared value column for the `SliderField`s inside it. `ControlPanel` opens one for the
|
|
31
|
+
* whole panel and `FieldGrid` for itself; an inner scope defers to the outer, so every group of
|
|
32
|
+
* one panel shares ONE column, not one per group.
|
|
33
|
+
*/
|
|
34
|
+
export declare function SliderValueColumnScope({ children }: {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}): import("react").JSX.Element;
|
|
16
37
|
/**
|
|
17
38
|
* A column of fields whose labels share ONE label column (FRM-1, FRM-2): every label shares a
|
|
18
39
|
* left edge, and every control shares its left edge, so a dense settings list or a control
|
|
19
40
|
* panel reads as one straight-edged table instead of a zig-zag. Put `Field layout="inline"`
|
|
20
41
|
* and `SliderField` inside it. Stacked labels (a plain `Stack` of `Field`s) stay the default
|
|
21
42
|
* for an ordinary form; reach for this only for a dense panel or a settings list. On a phone
|
|
22
|
-
* each row stacks its label over its control.
|
|
43
|
+
* each row stacks its label over its control. Its sliders share one value column too
|
|
44
|
+
* ({@link SliderValueColumnScope}), so their tracks end on one right edge.
|
|
23
45
|
*/
|
|
24
46
|
export declare function FieldGrid({ children, labelWidth, density, className, ...rest }: FieldGridProps): import("react").JSX.Element;
|
|
25
47
|
//# sourceMappingURL=FieldGrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGrid.d.ts","sourceRoot":"","sources":["../../../src/react/components/FieldGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"FieldGrid.d.ts","sourceRoot":"","sources":["../../../src/react/components/FieldGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,SAAS,EAA8C,MAAM,OAAO,CAAC;AAGtH,MAAM,WAAW,cAAc;IAC7B,yGAAyG;IACzG,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAChC,0GAA0G;IAC1G,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD,4IAA4I;AAC5I,eAAO,MAAM,sBAAsB,0DAAsC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,IAAI,EAAE,OAAO,CAAC;IACd,wFAAwF;IACxF,SAAS,EAAE,MAAM,MAAM,IAAI,CAAC;CAC7B;AAID,4GAA4G;AAC5G,eAAO,MAAM,oBAAoB,gCAAuC,CAAC;AAEzE;;;;GAIG;AAEH,wBAAgB,sBAAsB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAU3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,UAAiB,EAAE,OAAiB,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,+BAe/G"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from 'react';
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
3
3
|
import { cn } from '../lib/cn.js';
|
|
4
4
|
const LABEL_COL = {
|
|
5
5
|
sm: '7rem',
|
|
@@ -9,17 +9,39 @@ const LABEL_COL = {
|
|
|
9
9
|
const LabelWidthContext = createContext(null);
|
|
10
10
|
/** The enclosing FieldGrid's label width, or `null` outside one — SliderField sizes its narrow-grid threshold from it (forge task 2667). */
|
|
11
11
|
export const useFieldGridLabelWidth = () => useContext(LabelWidthContext);
|
|
12
|
+
const ValueColumnContext = createContext(null);
|
|
13
|
+
/** The enclosing scope's shared value column, or `null` outside one — then a slider sizes its box alone. */
|
|
14
|
+
export const useSliderValueColumn = () => useContext(ValueColumnContext);
|
|
15
|
+
/**
|
|
16
|
+
* Opens a shared value column for the `SliderField`s inside it. `ControlPanel` opens one for the
|
|
17
|
+
* whole panel and `FieldGrid` for itself; an inner scope defers to the outer, so every group of
|
|
18
|
+
* one panel shares ONE column, not one per group.
|
|
19
|
+
*/
|
|
20
|
+
// no-attribute-forward: a context provider around its children, with no element of its own.
|
|
21
|
+
export function SliderValueColumnScope({ children }) {
|
|
22
|
+
const outer = useContext(ValueColumnContext);
|
|
23
|
+
const [claims, setClaims] = useState(0);
|
|
24
|
+
const claimWide = useCallback(() => {
|
|
25
|
+
setClaims((n) => n + 1);
|
|
26
|
+
return () => setClaims((n) => n - 1);
|
|
27
|
+
}, []);
|
|
28
|
+
const own = useMemo(() => ({ wide: claims > 0, claimWide }), [claims, claimWide]);
|
|
29
|
+
if (outer)
|
|
30
|
+
return _jsx(_Fragment, { children: children });
|
|
31
|
+
return _jsx(ValueColumnContext.Provider, { value: own, children: children });
|
|
32
|
+
}
|
|
12
33
|
/**
|
|
13
34
|
* A column of fields whose labels share ONE label column (FRM-1, FRM-2): every label shares a
|
|
14
35
|
* left edge, and every control shares its left edge, so a dense settings list or a control
|
|
15
36
|
* panel reads as one straight-edged table instead of a zig-zag. Put `Field layout="inline"`
|
|
16
37
|
* and `SliderField` inside it. Stacked labels (a plain `Stack` of `Field`s) stay the default
|
|
17
38
|
* for an ordinary form; reach for this only for a dense panel or a settings list. On a phone
|
|
18
|
-
* each row stacks its label over its control.
|
|
39
|
+
* each row stacks its label over its control. Its sliders share one value column too
|
|
40
|
+
* ({@link SliderValueColumnScope}), so their tracks end on one right edge.
|
|
19
41
|
*/
|
|
20
42
|
export function FieldGrid({ children, labelWidth = 'md', density = 'dense', className, ...rest }) {
|
|
21
43
|
return (_jsx("div", { ...rest, className: cn('cb-field-grid', className), "data-cb-field-grid": '', "data-density": density,
|
|
22
44
|
// A live custom property — the one track every row's label column reads.
|
|
23
|
-
style: { '--cb-label-col': LABEL_COL[labelWidth] }, children: _jsx(LabelWidthContext.Provider, { value: labelWidth, children: children }) }));
|
|
45
|
+
style: { '--cb-label-col': LABEL_COL[labelWidth] }, children: _jsx(LabelWidthContext.Provider, { value: labelWidth, children: _jsx(SliderValueColumnScope, { children: children }) }) }));
|
|
24
46
|
}
|
|
25
47
|
//# sourceMappingURL=FieldGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldGrid.js","sourceRoot":"","sources":["../../../src/react/components/FieldGrid.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsB,aAAa,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FieldGrid.js","sourceRoot":"","sources":["../../../src/react/components/FieldGrid.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsB,aAAa,EAAkB,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtH,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAelC,MAAM,SAAS,GAA8D;IAC3E,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,OAAO;CACZ,CAAC;AAEF,MAAM,iBAAiB,GAAG,aAAa,CAAmD,IAAI,CAAC,CAAC;AAEhG,4IAA4I;AAC5I,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;AAc1E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+5,7 @@ import { useDebouncedCallback } from '../hooks/useDebouncedCallback.js';
|
|
|
5
5
|
import { cn } from '../lib/cn.js';
|
|
6
6
|
import { HELP_FOLD_CHARS } from '../lib/field.js';
|
|
7
7
|
import { Button } from './Button.js';
|
|
8
|
-
import { useFieldGridLabelWidth } from './FieldGrid.js';
|
|
8
|
+
import { useFieldGridLabelWidth, useSliderValueColumn } from './FieldGrid.js';
|
|
9
9
|
import { InfoHint } from './InfoHint.js';
|
|
10
10
|
import { Input } from './Input.js';
|
|
11
11
|
import { Slider } from './Slider.js';
|
|
@@ -162,7 +162,13 @@ export function SliderField({ label, value, min, max, step = 1, disabled, onChan
|
|
|
162
162
|
const r = formatValue ? formatValue(v) : formatSliderValue(v, step);
|
|
163
163
|
return typeof r === 'string' || typeof r === 'number' ? String(r).length : 0;
|
|
164
164
|
}));
|
|
165
|
-
const
|
|
165
|
+
const ownWide = widest > WIDE_READOUT_CHARS;
|
|
166
|
+
// Inside a FieldGrid or ControlPanel the box is the scope's: any slider that needs the wide box
|
|
167
|
+
// widens every one, so the panel's tracks end on one edge (forge task 5550). Alone, its own.
|
|
168
|
+
const column = useSliderValueColumn();
|
|
169
|
+
const claimWide = column?.claimWide;
|
|
170
|
+
useLayoutEffect(() => (ownWide && claimWide ? claimWide() : undefined), [ownWide, claimWide]);
|
|
171
|
+
const wide = ownWide || (column?.wide ?? false);
|
|
166
172
|
const gridLabel = useFieldGridLabelWidth();
|
|
167
173
|
const folds = typeof hint === 'string' && hint.length > HELP_FOLD_CHARS;
|
|
168
174
|
const resetNow = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderField.js","sourceRoot":"","sources":["../../../src/react/components/SliderField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAO,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,E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AQ,EACtB,eAAM,SAAS,EAAC,YAAY,YAAE,IAAI,CAAC,CAAC,CAAC,GAAQ,IACzC,CACP,CAAC,CAAC,CAAC,IAAI,EACP,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CACxB,YAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAC,6DAA6D,wBAAoB,EAAE,YACzG,IAAI,GACH,CACL,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursedbelt",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.15.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The React design system of the cursedbelt split — components, styles, theme. cursedbelt-core below it; server tier in cursedbelt-server.",
|
|
@@ -984,7 +984,7 @@
|
|
|
984
984
|
"@vidstack/react": "1.15.6",
|
|
985
985
|
"@vitejs/plugin-react": "^5.2.0",
|
|
986
986
|
"cursedbelt-server": "^4.76.0",
|
|
987
|
-
"cursedops": "^0.
|
|
987
|
+
"cursedops": "^0.35.0",
|
|
988
988
|
"diff": "^9.0.0",
|
|
989
989
|
"emoji-mart": "^5.6.0",
|
|
990
990
|
"hls.js": "^1.5.0",
|
|
@@ -2,7 +2,7 @@ import type { CSSProperties, ReactNode } from 'react';
|
|
|
2
2
|
import { useMediaQuery } from '../hooks/useMediaQuery.js';
|
|
3
3
|
import { cn } from '../lib/cn.js';
|
|
4
4
|
import { Collapsible } from './Collapsible.js';
|
|
5
|
-
import { FieldGrid, type FieldGridProps } from './FieldGrid.js';
|
|
5
|
+
import { FieldGrid, type FieldGridProps, SliderValueColumnScope } from './FieldGrid.js';
|
|
6
6
|
|
|
7
7
|
/** Below this a panel's columns would be squeezed past use, so they stack as accordions (FRM-17). */
|
|
8
8
|
const PHONE_QUERY = '(max-width: 639px)';
|
|
@@ -50,7 +50,8 @@ const COLUMN_MIN: Record<NonNullable<ControlPanelProps['columnMin']>, string> =
|
|
|
50
50
|
* boxes — whitespace and a 1px vertical rule between columns. Columns wrap whole, every column in
|
|
51
51
|
* a row is the same height and padding, and each group's fields share one label column. On a
|
|
52
52
|
* phone the groups become stacked accordions (the first open), so the canvas above stays in view
|
|
53
|
-
* and no column is squeezed past use.
|
|
53
|
+
* and no column is squeezed past use. Every slider in the panel shares one value column
|
|
54
|
+
* ({@link SliderValueColumnScope}), across its groups.
|
|
54
55
|
*/
|
|
55
56
|
export function ControlPanel({ title, actions, children, columnMin = 'md', className, ...rest }: ControlPanelProps) {
|
|
56
57
|
const phone = useMediaQuery(PHONE_QUERY);
|
|
@@ -70,7 +71,7 @@ export function ControlPanel({ title, actions, children, columnMin = 'md', class
|
|
|
70
71
|
) : null}
|
|
71
72
|
{phone ? (
|
|
72
73
|
<div className='flex flex-col divide-y divide-border' data-cb-control-panel-groups='' data-phone=''>
|
|
73
|
-
{children}
|
|
74
|
+
<SliderValueColumnScope>{children}</SliderValueColumnScope>
|
|
74
75
|
</div>
|
|
75
76
|
) : (
|
|
76
77
|
<div className='cb-control-panel-frame'>
|
|
@@ -79,7 +80,7 @@ export function ControlPanel({ title, actions, children, columnMin = 'md', class
|
|
|
79
80
|
data-cb-control-panel-groups=''
|
|
80
81
|
style={{ '--cb-panel-col-min': COLUMN_MIN[columnMin] } as CSSProperties}
|
|
81
82
|
>
|
|
82
|
-
{children}
|
|
83
|
+
<SliderValueColumnScope>{children}</SliderValueColumnScope>
|
|
83
84
|
</div>
|
|
84
85
|
</div>
|
|
85
86
|
)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CSSProperties, createContext, type ReactNode, useContext } from 'react';
|
|
1
|
+
import { type CSSProperties, createContext, type ReactNode, useCallback, useContext, useMemo, useState } from 'react';
|
|
2
2
|
import { cn } from '../lib/cn.js';
|
|
3
3
|
|
|
4
4
|
export interface FieldGridProps {
|
|
@@ -25,13 +25,49 @@ const LabelWidthContext = createContext<NonNullable<FieldGridProps['labelWidth']
|
|
|
25
25
|
/** The enclosing FieldGrid's label width, or `null` outside one — SliderField sizes its narrow-grid threshold from it (forge task 2667). */
|
|
26
26
|
export const useFieldGridLabelWidth = () => useContext(LabelWidthContext);
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The value column a panel's `SliderField`s share (forge task 5550). Each slider measures its own
|
|
30
|
+
* longest readout; one that needs the wide box registers here, and while any does, every slider in
|
|
31
|
+
* the scope draws the wide box — so a `1.00×` row and an `Auto 2×` row end their tracks on one edge.
|
|
32
|
+
*/
|
|
33
|
+
export interface SliderValueColumn {
|
|
34
|
+
/** Some slider in the scope needs the wide value box. */
|
|
35
|
+
wide: boolean;
|
|
36
|
+
/** A slider that needs the wide box calls this; the returned function takes it back. */
|
|
37
|
+
claimWide: () => () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const ValueColumnContext = createContext<SliderValueColumn | null>(null);
|
|
41
|
+
|
|
42
|
+
/** The enclosing scope's shared value column, or `null` outside one — then a slider sizes its box alone. */
|
|
43
|
+
export const useSliderValueColumn = () => useContext(ValueColumnContext);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Opens a shared value column for the `SliderField`s inside it. `ControlPanel` opens one for the
|
|
47
|
+
* whole panel and `FieldGrid` for itself; an inner scope defers to the outer, so every group of
|
|
48
|
+
* one panel shares ONE column, not one per group.
|
|
49
|
+
*/
|
|
50
|
+
// no-attribute-forward: a context provider around its children, with no element of its own.
|
|
51
|
+
export function SliderValueColumnScope({ children }: { children: ReactNode }) {
|
|
52
|
+
const outer = useContext(ValueColumnContext);
|
|
53
|
+
const [claims, setClaims] = useState(0);
|
|
54
|
+
const claimWide = useCallback(() => {
|
|
55
|
+
setClaims((n) => n + 1);
|
|
56
|
+
return () => setClaims((n) => n - 1);
|
|
57
|
+
}, []);
|
|
58
|
+
const own = useMemo(() => ({ wide: claims > 0, claimWide }), [claims, claimWide]);
|
|
59
|
+
if (outer) return <>{children}</>;
|
|
60
|
+
return <ValueColumnContext.Provider value={own}>{children}</ValueColumnContext.Provider>;
|
|
61
|
+
}
|
|
62
|
+
|
|
28
63
|
/**
|
|
29
64
|
* A column of fields whose labels share ONE label column (FRM-1, FRM-2): every label shares a
|
|
30
65
|
* left edge, and every control shares its left edge, so a dense settings list or a control
|
|
31
66
|
* panel reads as one straight-edged table instead of a zig-zag. Put `Field layout="inline"`
|
|
32
67
|
* and `SliderField` inside it. Stacked labels (a plain `Stack` of `Field`s) stay the default
|
|
33
68
|
* for an ordinary form; reach for this only for a dense panel or a settings list. On a phone
|
|
34
|
-
* each row stacks its label over its control.
|
|
69
|
+
* each row stacks its label over its control. Its sliders share one value column too
|
|
70
|
+
* ({@link SliderValueColumnScope}), so their tracks end on one right edge.
|
|
35
71
|
*/
|
|
36
72
|
export function FieldGrid({ children, labelWidth = 'md', density = 'dense', className, ...rest }: FieldGridProps) {
|
|
37
73
|
return (
|
|
@@ -43,7 +79,9 @@ export function FieldGrid({ children, labelWidth = 'md', density = 'dense', clas
|
|
|
43
79
|
// A live custom property — the one track every row's label column reads.
|
|
44
80
|
style={{ '--cb-label-col': LABEL_COL[labelWidth] } as CSSProperties}
|
|
45
81
|
>
|
|
46
|
-
<LabelWidthContext.Provider value={labelWidth}>
|
|
82
|
+
<LabelWidthContext.Provider value={labelWidth}>
|
|
83
|
+
<SliderValueColumnScope>{children}</SliderValueColumnScope>
|
|
84
|
+
</LabelWidthContext.Provider>
|
|
47
85
|
</div>
|
|
48
86
|
);
|
|
49
87
|
}
|
|
@@ -4,7 +4,7 @@ import { useDebouncedCallback } from '../hooks/useDebouncedCallback.js';
|
|
|
4
4
|
import { cn } from '../lib/cn.js';
|
|
5
5
|
import { HELP_FOLD_CHARS } from '../lib/field.js';
|
|
6
6
|
import { Button } from './Button.js';
|
|
7
|
-
import { useFieldGridLabelWidth } from './FieldGrid.js';
|
|
7
|
+
import { useFieldGridLabelWidth, useSliderValueColumn } from './FieldGrid.js';
|
|
8
8
|
import { InfoHint } from './InfoHint.js';
|
|
9
9
|
import { Input } from './Input.js';
|
|
10
10
|
import { Slider } from './Slider.js';
|
|
@@ -260,7 +260,13 @@ export function SliderField({
|
|
|
260
260
|
return typeof r === 'string' || typeof r === 'number' ? String(r).length : 0;
|
|
261
261
|
}),
|
|
262
262
|
);
|
|
263
|
-
const
|
|
263
|
+
const ownWide = widest > WIDE_READOUT_CHARS;
|
|
264
|
+
// Inside a FieldGrid or ControlPanel the box is the scope's: any slider that needs the wide box
|
|
265
|
+
// widens every one, so the panel's tracks end on one edge (forge task 5550). Alone, its own.
|
|
266
|
+
const column = useSliderValueColumn();
|
|
267
|
+
const claimWide = column?.claimWide;
|
|
268
|
+
useLayoutEffect(() => (ownWide && claimWide ? claimWide() : undefined), [ownWide, claimWide]);
|
|
269
|
+
const wide = ownWide || (column?.wide ?? false);
|
|
264
270
|
const gridLabel = useFieldGridLabelWidth();
|
|
265
271
|
const folds = typeof hint === 'string' && hint.length > HELP_FOLD_CHARS;
|
|
266
272
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { cleanup, render } from '@testing-library/react';
|
|
3
|
+
import { ControlGroup, ControlPanel } from './ControlPanel.js';
|
|
4
|
+
import { FieldGrid } from './FieldGrid.js';
|
|
5
|
+
import { SliderField } from './SliderField.js';
|
|
6
|
+
|
|
7
|
+
afterEach(cleanup);
|
|
8
|
+
|
|
9
|
+
// Forge task 5550: patterns' Controls inspector drew "Auto 2×" and "133 iter" in an 8rem box and
|
|
10
|
+
// "1.00×" in a 5rem one, so the Shape group's tracks stopped 3rem short of View's and Motion's. A
|
|
11
|
+
// panel's sliders share ONE value column: any slider whose readout needs the wide box widens all.
|
|
12
|
+
const times = (v: number) => `${v.toFixed(2)}×`;
|
|
13
|
+
const iter = (v: number) => `${v} iter`;
|
|
14
|
+
const Warp = () => <SliderField label='Text warp' value={1} min={0} max={4} step={0.01} formatValue={times} />;
|
|
15
|
+
const Detail = () => <SliderField label='Detail' value={133} min={10} max={500} step={1} formatValue={iter} />;
|
|
16
|
+
|
|
17
|
+
const boxes = (root: HTMLElement) => [...root.querySelectorAll<HTMLInputElement>('[data-cb-slider-value]')];
|
|
18
|
+
const widths = (root: HTMLElement) => boxes(root).map((b) => (b.className.includes('w-32') ? 'wide' : 'narrow'));
|
|
19
|
+
const fits = (root: HTMLElement) => [...root.querySelectorAll('.cb-slider-row')].map((r) => r.getAttribute('data-cb-slider-fit'));
|
|
20
|
+
|
|
21
|
+
describe('SliderField value column', () => {
|
|
22
|
+
test('one group: a 1.00× slider takes the wide box a 133 iter slider needs, and the wide stack threshold', () => {
|
|
23
|
+
const { container } = render(
|
|
24
|
+
<ControlGroup title='Shape' labelWidth='sm'>
|
|
25
|
+
<Warp />
|
|
26
|
+
<Detail />
|
|
27
|
+
</ControlGroup>,
|
|
28
|
+
);
|
|
29
|
+
expect(widths(container)).toEqual(['wide', 'wide']);
|
|
30
|
+
expect(fits(container)).toEqual(['22.5', '22.5']);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('one panel: every group shares the column, not one column per group', () => {
|
|
34
|
+
const { container } = render(
|
|
35
|
+
<ControlPanel title='Pattern'>
|
|
36
|
+
<ControlGroup title='Shape' labelWidth='sm'>
|
|
37
|
+
<Detail />
|
|
38
|
+
</ControlGroup>
|
|
39
|
+
<ControlGroup title='View' labelWidth='sm'>
|
|
40
|
+
<Warp />
|
|
41
|
+
</ControlGroup>
|
|
42
|
+
</ControlPanel>,
|
|
43
|
+
);
|
|
44
|
+
expect(widths(container)).toEqual(['wide', 'wide']);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('a grid of short readouts keeps the narrow box, and loses the wide one when its wide slider goes', () => {
|
|
48
|
+
const { container, rerender } = render(
|
|
49
|
+
<FieldGrid>
|
|
50
|
+
<Warp />
|
|
51
|
+
<Detail />
|
|
52
|
+
</FieldGrid>,
|
|
53
|
+
);
|
|
54
|
+
expect(widths(container)).toEqual(['wide', 'wide']);
|
|
55
|
+
rerender(
|
|
56
|
+
<FieldGrid>
|
|
57
|
+
<Warp />
|
|
58
|
+
</FieldGrid>,
|
|
59
|
+
);
|
|
60
|
+
expect(widths(container)).toEqual(['narrow']);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('outside a grid each slider sizes its own box', () => {
|
|
64
|
+
const { container } = render(
|
|
65
|
+
<div>
|
|
66
|
+
<Warp />
|
|
67
|
+
<Detail />
|
|
68
|
+
</div>,
|
|
69
|
+
);
|
|
70
|
+
expect(widths(container)).toEqual(['narrow', 'wide']);
|
|
71
|
+
expect(fits(container)).toEqual([null, null]);
|
|
72
|
+
});
|
|
73
|
+
});
|