@weasel-js/labkit 1.3.0-pre.0 → 1.4.0-pre.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/_dts/CanvasStackContext-DtAn_3O-.d.ts +42 -0
- package/dist/_dts/DrawCommand-B3bskUsC.d.ts +564 -0
- package/dist/_dts/{PrefsForm-BYa6cWnO.d.ts → PrefsForm-BkUJZx0A.d.ts} +4 -1
- package/dist/_dts/fitViewToBounds-dZ2UDB6e.d.ts +21 -0
- package/dist/_dts/frac-Cp3NivlC.d.ts +728 -0
- package/dist/_dts/index-BDVzvRzQ.d.ts +236 -0
- package/dist/_dts/shapeKinds-Cx_rxwsa.d.ts +87 -0
- package/dist/_dts/{DrawCommand-DBB45NfN.d.ts → types-C-gh9Ap-.d.ts} +1 -582
- package/dist/_dts/{types-AHlQxBNN.d.ts → types-D6s4b7if.d.ts} +2 -2
- package/dist/_dts/{types-1Sdxy_Pv.d.ts → types-DYMaEvM5.d.ts} +26 -1
- package/dist/_dts/{useTrialState-CsGMjhu9.d.ts → useTrialState-gmMvZqPc.d.ts} +7 -2
- package/dist/canvas/index.d.ts +43 -25
- package/dist/canvas/index.js +5 -3
- package/dist/chrome/index.d.ts +9 -6
- package/dist/chrome/index.js +7 -6
- package/dist/chunk-2AYGEN57.js +32 -0
- package/dist/chunk-2AYGEN57.js.map +1 -0
- package/dist/{chunk-RVNN4CHQ.js → chunk-3P5TTTA7.js} +16 -8
- package/dist/chunk-3P5TTTA7.js.map +1 -0
- package/dist/{chunk-NS54R52R.js → chunk-3ZELRRBV.js} +45 -40
- package/dist/chunk-3ZELRRBV.js.map +1 -0
- package/dist/{chunk-HFDVGF4X.js → chunk-4EY67BKJ.js} +32 -7
- package/dist/chunk-4EY67BKJ.js.map +1 -0
- package/dist/chunk-5TCEVMPI.js +140 -0
- package/dist/chunk-5TCEVMPI.js.map +1 -0
- package/dist/{chunk-O7NVSCLN.js → chunk-6JMU56CU.js} +133 -134
- package/dist/chunk-6JMU56CU.js.map +1 -0
- package/dist/{chunk-CPUJ3QXL.js → chunk-CQLQPQ4P.js} +2 -2
- package/dist/chunk-CQLQPQ4P.js.map +1 -0
- package/dist/chunk-CTRKTLYZ.js +33 -0
- package/dist/chunk-CTRKTLYZ.js.map +1 -0
- package/dist/chunk-EQIB2PGC.js +458 -0
- package/dist/chunk-EQIB2PGC.js.map +1 -0
- package/dist/chunk-HEORBLVT.js +7128 -0
- package/dist/chunk-HEORBLVT.js.map +1 -0
- package/dist/{chunk-V7PRSIRQ.js → chunk-JDDIZSLL.js} +4 -4
- package/dist/chunk-JDDIZSLL.js.map +1 -0
- package/dist/chunk-LITE5YFB.js +669 -0
- package/dist/chunk-LITE5YFB.js.map +1 -0
- package/dist/{chunk-Z6HJ5FEM.js → chunk-ROQDRXKW.js} +732 -315
- package/dist/chunk-ROQDRXKW.js.map +1 -0
- package/dist/chunk-SBXNQW4G.js +3 -0
- package/dist/chunk-SBXNQW4G.js.map +1 -0
- package/dist/{chunk-4TMMVIDM.js → chunk-XJ6N32QP.js} +50 -6
- package/dist/chunk-XJ6N32QP.js.map +1 -0
- package/dist/chunk-YQJNT4XQ.js +293 -0
- package/dist/chunk-YQJNT4XQ.js.map +1 -0
- package/dist/controls/index.d.ts +4 -28
- package/dist/controls/index.js +3 -3
- package/dist/dragdrop/index.d.ts +50 -5
- package/dist/dragdrop/index.js +3 -1
- package/dist/index.d.ts +660 -302
- package/dist/index.js +1793 -587
- package/dist/index.js.map +1 -1
- package/dist/layers/index.d.ts +6 -5
- package/dist/layers/index.js +4 -2
- package/dist/loupe/index.d.ts +187 -0
- package/dist/loupe/index.js +7 -0
- package/dist/loupe/index.js.map +1 -0
- package/dist/passthrough/weasel-canvas.d.ts +3 -1
- package/dist/passthrough/weasel-canvas.js +1 -1
- package/dist/passthrough/weasel-ui.d.ts +151 -91
- package/dist/passthrough/weasel-ui.js +3 -2
- package/dist/primitives/index.d.ts +3 -1
- package/dist/primitives/index.js +6 -5
- package/dist/state/index.d.ts +3 -3
- package/dist/state/index.js +2 -2
- package/dist/styles.css +229 -703
- package/dist/surface/index.d.ts +18 -2
- package/dist/surface/index.js +2 -2
- package/dist/ui/layers/index.d.ts +8 -2
- package/dist/ui/layers/index.js +2 -4
- package/dist/undo/index.d.ts +5 -4
- package/package.json +14 -7
- package/src/annotations/AnnotationOverlay.tsx +205 -0
- package/src/annotations/AnnotationTargets.tsx +37 -0
- package/src/annotations/Annotations.less +129 -0
- package/src/annotations/Annotations.meaning.test.tsx +111 -0
- package/src/annotations/Annotations.overlay.test.tsx +142 -0
- package/src/annotations/AnnotationsContext.ts +49 -0
- package/src/annotations/ExportMenu.test.tsx +86 -0
- package/src/annotations/ExportMenu.tsx +182 -0
- package/src/annotations/MarkList.tsx +75 -0
- package/src/annotations/capture.test.ts +140 -0
- package/src/annotations/capture.ts +237 -0
- package/src/annotations/drawOne.test.ts +56 -0
- package/src/annotations/drawOne.ts +47 -0
- package/src/annotations/frac.test.ts +59 -0
- package/src/annotations/frac.ts +66 -0
- package/src/annotations/history.test.ts +82 -0
- package/src/annotations/history.ts +118 -0
- package/src/annotations/index.ts +37 -0
- package/src/annotations/paint.test.ts +125 -0
- package/src/annotations/paint.ts +130 -0
- package/src/annotations/staleness.test.ts +56 -0
- package/src/annotations/staleness.ts +41 -0
- package/src/annotations/store.test.ts +175 -0
- package/src/annotations/store.ts +317 -0
- package/src/annotations/svgNodes.test.ts +77 -0
- package/src/annotations/svgNodes.ts +74 -0
- package/src/annotations/toolMap.test.ts +36 -0
- package/src/annotations/toolMap.ts +54 -0
- package/src/annotations/types.ts +222 -0
- package/src/annotations/view.test.ts +37 -0
- package/src/annotations/view.ts +40 -0
- package/src/canvas/AGENTS.md +55 -5
- package/src/canvas/CanvasStack.test.tsx +27 -1
- package/src/canvas/CanvasStack.tsx +29 -4
- package/src/canvas/CanvasStackContext.ts +23 -4
- package/src/canvas/camera.test.ts +78 -0
- package/src/canvas/camera.ts +62 -0
- package/src/canvas/canvasCoords.test.ts +26 -0
- package/src/canvas/canvasCoords.ts +20 -7
- package/src/canvas/index.ts +5 -1
- package/src/canvas/useLayerScheduler.ts +7 -3
- package/src/canvas/usePanZoom.test.ts +36 -5
- package/src/canvas/usePanZoom.ts +20 -15
- package/src/canvas/worldSpec.test.ts +63 -0
- package/src/canvas/worldSpec.ts +48 -0
- package/src/chrome/builtins.test.ts +31 -1
- package/src/chrome/builtins.tsx +63 -19
- package/src/chrome/regions/PaletteRegion.test.tsx +22 -1
- package/src/chrome/regions/PaletteRegion.tsx +4 -0
- package/src/chrome/regions/SidebarRegion.tsx +37 -13
- package/src/chrome/regions/ToolbarRegion.tsx +2 -1
- package/src/chrome/regions/ViewportRegion.tsx +9 -1
- package/src/chrome/regions/regions.test.tsx +6 -1
- package/src/chrome/types.ts +20 -0
- package/src/config/builder.test.ts +7 -1
- package/src/config/builder.ts +1 -5
- package/src/config/resolve.test.ts +1 -2
- package/src/controls/ControlPanel.stories.tsx +41 -2
- package/src/controls/ControlPanel.test.tsx +69 -9
- package/src/controls/ControlPanel.tsx +106 -25
- package/src/dragdrop/DragDropRuntime.tsx +8 -2
- package/src/dragdrop/dragDrop.test.tsx +29 -2
- package/src/dragdrop/index.ts +11 -0
- package/src/index.test.ts +22 -0
- package/src/index.ts +136 -4
- package/src/instrument/SineWave.smoke.test.tsx +1 -0
- package/src/instrument/types.ts +24 -1
- package/src/lab/Lab.surface.test.tsx +162 -0
- package/src/lab/Lab.tsx +102 -17
- package/src/lab/Lab.undock.test.tsx +85 -0
- package/src/lab/LabFullChrome.stories.tsx +20 -0
- package/src/lab/LabShell.less +11 -0
- package/src/lab/Workspace.less +73 -0
- package/src/lab/Workspace.surface.test.tsx +2 -0
- package/src/lab/Workspace.tsx +97 -8
- package/src/lab/index.ts +1 -1
- package/src/lab/panelHost.ts +37 -0
- package/src/layers/AGENTS.md +1 -1
- package/src/layers/LayerList.tsx +1 -1
- package/src/loupe/AGENTS.md +49 -0
- package/src/loupe/CanvasLoupe.tsx +83 -0
- package/src/loupe/DomLoupe.tsx +62 -0
- package/src/loupe/Loupe.less +38 -0
- package/src/loupe/LoupeBubble.tsx +32 -0
- package/src/loupe/TrialLoupe.tsx +93 -0
- package/src/loupe/canvasLens.test.ts +205 -0
- package/src/loupe/canvasLens.ts +141 -0
- package/src/loupe/index.ts +19 -0
- package/src/loupe/types.test.ts +29 -0
- package/src/loupe/types.ts +90 -0
- package/src/loupe/useHostSize.ts +30 -0
- package/src/loupe/useLoupe.test.tsx +197 -0
- package/src/loupe/useLoupe.ts +189 -0
- package/src/passthrough/weasel-ui.ts +25 -17
- package/src/primitives/FloatingPanel.test.tsx +76 -1
- package/src/primitives/FloatingPanel.tsx +19 -3
- package/src/primitives/ScaleIndicator.test.tsx +7 -2
- package/src/primitives/Sidebar.less +18 -0
- package/src/primitives/Toolbar.less +8 -0
- package/src/primitives/Toolbar.tsx +5 -0
- package/src/primitives/useRovingTabIndex.test.ts +21 -0
- package/src/primitives/useRovingTabIndex.ts +26 -17
- package/src/state/document.test.ts +23 -0
- package/src/state/document.ts +14 -2
- package/src/state/index.ts +2 -0
- package/src/state/store.test.ts +24 -0
- package/src/state/store.ts +35 -1
- package/src/state/types.ts +11 -0
- package/src/state/undock.test.ts +40 -0
- package/src/state/undock.ts +39 -0
- package/src/styles.less +2 -4
- package/src/surface/SurfaceContext.ts +4 -0
- package/src/surface/index.ts +8 -3
- package/src/surface/useSurfaceTile.test.tsx +2 -0
- package/src/surface/useSurfaceTile.ts +7 -1
- package/src/surface/useTiledSurface.test.tsx +58 -0
- package/src/surface/useTiledSurface.ts +38 -3
- package/src/theme/Interstellar.stories.tsx +1 -1
- package/src/trial/Trial.annotations.persist.test.tsx +166 -0
- package/src/trial/Trial.annotations.test.tsx +121 -0
- package/src/trial/Trial.canvas.test.tsx +76 -1
- package/src/trial/Trial.config.test.tsx +3 -8
- package/src/trial/Trial.less +19 -0
- package/src/trial/Trial.loupe.test.tsx +128 -0
- package/src/trial/Trial.stories.tsx +1 -0
- package/src/trial/Trial.test.tsx +12 -0
- package/src/trial/Trial.trialId.test.tsx +36 -0
- package/src/trial/Trial.tsx +215 -40
- package/src/trial/TrialChrome.tsx +35 -0
- package/src/trial/UndockedSections.tsx +65 -0
- package/src/trial/trialOps.test.ts +21 -0
- package/src/trial/trialOps.ts +5 -3
- package/src/ui/layers/index.ts +5 -1
- package/dist/_dts/index-DgcNdEdh.d.ts +0 -314
- package/dist/chunk-4TMMVIDM.js.map +0 -1
- package/dist/chunk-CPUJ3QXL.js.map +0 -1
- package/dist/chunk-HFDVGF4X.js.map +0 -1
- package/dist/chunk-NS54R52R.js.map +0 -1
- package/dist/chunk-O2BULFHX.js +0 -152
- package/dist/chunk-O2BULFHX.js.map +0 -1
- package/dist/chunk-O7NVSCLN.js.map +0 -1
- package/dist/chunk-PO6L3NSH.js +0 -366
- package/dist/chunk-PO6L3NSH.js.map +0 -1
- package/dist/chunk-PQJ5B2U2.js +0 -27
- package/dist/chunk-PQJ5B2U2.js.map +0 -1
- package/dist/chunk-RVNN4CHQ.js.map +0 -1
- package/dist/chunk-TLGRYALP.js +0 -6151
- package/dist/chunk-TLGRYALP.js.map +0 -1
- package/dist/chunk-V7PRSIRQ.js.map +0 -1
- package/dist/chunk-Z6HJ5FEM.js.map +0 -1
- package/dist/chunk-ZZAYVX4X.js +0 -505
- package/dist/chunk-ZZAYVX4X.js.map +0 -1
- package/src/primitives/DragHandleGlyph.tsx +0 -29
- package/src/ui/format.test.ts +0 -33
- package/src/ui/format.ts +0 -30
- package/src/ui/layers/LayerStack.less +0 -143
- package/src/ui/layers/LayerStack.stories.tsx +0 -45
- package/src/ui/layers/LayerStack.test.tsx +0 -170
- package/src/ui/layers/LayerStack.tsx +0 -208
- package/src/ui/properties/CheckboxRow.stories.tsx +0 -27
- package/src/ui/properties/ColorRow.stories.tsx +0 -106
- package/src/ui/properties/CurveField.less +0 -48
- package/src/ui/properties/CurveField.stories.tsx +0 -20
- package/src/ui/properties/CurveField.test.tsx +0 -127
- package/src/ui/properties/CurveField.tsx +0 -184
- package/src/ui/properties/EffectCard.tsx +0 -324
- package/src/ui/properties/Gallery.stories.tsx +0 -178
- package/src/ui/properties/NumberRow.stories.tsx +0 -65
- package/src/ui/properties/PropertyGroup.less +0 -50
- package/src/ui/properties/PropertyGroup.stories.tsx +0 -34
- package/src/ui/properties/PropertyGroup.test.tsx +0 -33
- package/src/ui/properties/PropertyGroup.tsx +0 -45
- package/src/ui/properties/PropertyList.stories.tsx +0 -83
- package/src/ui/properties/PropertyPanel.less +0 -606
- package/src/ui/properties/PropertyPanel.stories.tsx +0 -190
- package/src/ui/properties/PropertyPanel.test.tsx +0 -193
- package/src/ui/properties/PropertyPanel.tsx +0 -469
- package/src/ui/properties/PropertyRow.stories.tsx +0 -53
- package/src/ui/properties/SelectRow.stories.tsx +0 -58
- package/src/ui/properties/SliderRow.stories.tsx +0 -74
- package/src/ui/properties/SpeechBalloonPanels.stories.tsx +0 -398
- package/src/ui/properties/TextRow.stories.tsx +0 -62
- package/src/ui/properties/ToggleRow.stories.tsx +0 -57
- package/src/ui/properties/index.ts +0 -39
- package/src/ui/properties/storyLayouts.tsx +0 -36
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
CheckboxRow,
|
|
5
|
-
ColorRow,
|
|
6
|
-
NumberRow,
|
|
7
|
-
PropertyList,
|
|
8
|
-
type PropertyListPack,
|
|
9
|
-
PropertyPanel,
|
|
10
|
-
PropertyRow,
|
|
11
|
-
SelectRow,
|
|
12
|
-
SliderRow,
|
|
13
|
-
TextRow,
|
|
14
|
-
ToggleRow,
|
|
15
|
-
} from './PropertyPanel';
|
|
16
|
-
|
|
17
|
-
// Args common to most stories — exposed as Storybook controls so the
|
|
18
|
-
// title, pack mode, and container width can be tweaked live.
|
|
19
|
-
interface DemoArgs {
|
|
20
|
-
title: string;
|
|
21
|
-
pack: PropertyListPack;
|
|
22
|
-
width: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const meta: Meta<DemoArgs> = {
|
|
26
|
-
title: 'labkit/UI/Properties/PropertyPanel',
|
|
27
|
-
argTypes: {
|
|
28
|
-
title: { control: 'text' },
|
|
29
|
-
pack: {
|
|
30
|
-
control: 'inline-radio',
|
|
31
|
-
options: ['auto-color', 'pairs'] satisfies PropertyListPack[],
|
|
32
|
-
description:
|
|
33
|
-
"PropertyList packing. 'auto-color' (default) spans non-color rows full-width; 'pairs' packs every row two-per-row.",
|
|
34
|
-
},
|
|
35
|
-
width: { control: { type: 'number', min: 200, max: 600, step: 10 } },
|
|
36
|
-
},
|
|
37
|
-
args: {
|
|
38
|
-
title: 'Shape',
|
|
39
|
-
pack: 'auto-color',
|
|
40
|
-
width: 320,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
export default meta;
|
|
44
|
-
|
|
45
|
-
type Story = StoryObj<DemoArgs>;
|
|
46
|
-
|
|
47
|
-
function Demo({ title, pack, width }: DemoArgs) {
|
|
48
|
-
const [opacity, setOpacity] = useState(0.65);
|
|
49
|
-
const [radius, setRadius] = useState(12);
|
|
50
|
-
const [fill, setFill] = useState('#b08adb');
|
|
51
|
-
const [stroke, setStroke] = useState('#1a1428');
|
|
52
|
-
const [label, setLabel] = useState('Untitled');
|
|
53
|
-
const [visible, setVisible] = useState(true);
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<div style={{ width }}>
|
|
57
|
-
<PropertyPanel title={title}>
|
|
58
|
-
<PropertyList pack={pack}>
|
|
59
|
-
<SliderRow
|
|
60
|
-
label="Opacity"
|
|
61
|
-
value={opacity}
|
|
62
|
-
min={0}
|
|
63
|
-
max={1}
|
|
64
|
-
step={0.01}
|
|
65
|
-
onChange={setOpacity}
|
|
66
|
-
format={(v) => v.toFixed(2)}
|
|
67
|
-
/>
|
|
68
|
-
<SliderRow
|
|
69
|
-
label="Radius"
|
|
70
|
-
value={radius}
|
|
71
|
-
min={0}
|
|
72
|
-
max={64}
|
|
73
|
-
step={1}
|
|
74
|
-
onChange={setRadius}
|
|
75
|
-
unit="px"
|
|
76
|
-
/>
|
|
77
|
-
<ColorRow label="Fill" value={fill} onChange={setFill} />
|
|
78
|
-
<ColorRow label="Stroke" value={stroke} onChange={setStroke} />
|
|
79
|
-
<TextRow label="Label" value={label} onChange={setLabel} />
|
|
80
|
-
<CheckboxRow label="Visible" value={visible} onChange={setVisible} />
|
|
81
|
-
</PropertyList>
|
|
82
|
-
</PropertyPanel>
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export const Default: Story = {
|
|
88
|
-
render: (args) => <Demo {...args} />,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const NoTitle: Story = {
|
|
92
|
-
args: { title: '' },
|
|
93
|
-
render: ({ title, width }) => (
|
|
94
|
-
<div style={{ width }}>
|
|
95
|
-
<PropertyPanel title={title || undefined}>
|
|
96
|
-
<PropertyList>
|
|
97
|
-
<SliderRow label="Just a slider" value={50} min={0} max={100} onChange={() => {}} />
|
|
98
|
-
</PropertyList>
|
|
99
|
-
</PropertyPanel>
|
|
100
|
-
</div>
|
|
101
|
-
),
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
function AllRowsDemo({ title, pack, width }: DemoArgs) {
|
|
105
|
-
const [opacity, setOpacity] = useState(0.65);
|
|
106
|
-
const [count, setCount] = useState(8);
|
|
107
|
-
const [fill, setFill] = useState('#b08adb');
|
|
108
|
-
const [stroke, setStroke] = useState('#1a1428');
|
|
109
|
-
const [name, setName] = useState('Untitled');
|
|
110
|
-
const [visible, setVisible] = useState(true);
|
|
111
|
-
const [mode, setMode] = useState<'fill' | 'stroke' | 'both'>('both');
|
|
112
|
-
const [align, setAlign] = useState<'left' | 'center' | 'right'>('center');
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<div style={{ width }}>
|
|
116
|
-
<PropertyPanel title={title}>
|
|
117
|
-
<PropertyList pack={pack}>
|
|
118
|
-
<SliderRow
|
|
119
|
-
label="Opacity"
|
|
120
|
-
value={opacity}
|
|
121
|
-
min={0}
|
|
122
|
-
max={1}
|
|
123
|
-
step={0.01}
|
|
124
|
-
onChange={setOpacity}
|
|
125
|
-
format={(v) => v.toFixed(2)}
|
|
126
|
-
/>
|
|
127
|
-
<NumberRow label="Count" value={count} onChange={setCount} min={0} max={100} step={1} />
|
|
128
|
-
<ColorRow label="Fill" value={fill} onChange={setFill} />
|
|
129
|
-
<ColorRow label="Stroke" value={stroke} onChange={setStroke} />
|
|
130
|
-
<TextRow label="Name" value={name} onChange={setName} />
|
|
131
|
-
<SelectRow
|
|
132
|
-
label="Mode"
|
|
133
|
-
value={mode}
|
|
134
|
-
onChange={setMode}
|
|
135
|
-
options={[
|
|
136
|
-
{ value: 'fill', label: 'Fill only' },
|
|
137
|
-
{ value: 'stroke', label: 'Stroke only' },
|
|
138
|
-
{ value: 'both', label: 'Fill + stroke' },
|
|
139
|
-
]}
|
|
140
|
-
/>
|
|
141
|
-
<ToggleRow
|
|
142
|
-
label="Align"
|
|
143
|
-
value={align}
|
|
144
|
-
onChange={setAlign}
|
|
145
|
-
options={[
|
|
146
|
-
{ value: 'left', label: 'L' },
|
|
147
|
-
{ value: 'center', label: 'C' },
|
|
148
|
-
{ value: 'right', label: 'R' },
|
|
149
|
-
]}
|
|
150
|
-
/>
|
|
151
|
-
<CheckboxRow label="Visible" value={visible} onChange={setVisible} />
|
|
152
|
-
</PropertyList>
|
|
153
|
-
</PropertyPanel>
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export const AllRows: Story = {
|
|
159
|
-
args: { title: 'Everything' },
|
|
160
|
-
render: (args) => <AllRowsDemo {...args} />,
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export const CustomPropertyRow: Story = {
|
|
164
|
-
args: { title: 'Custom row' },
|
|
165
|
-
render: ({ title, pack, width }) => (
|
|
166
|
-
<div style={{ width }}>
|
|
167
|
-
<PropertyPanel title={title}>
|
|
168
|
-
<PropertyList pack={pack}>
|
|
169
|
-
<PropertyRow label="Anything" readout="custom">
|
|
170
|
-
<button type="button">click me</button>
|
|
171
|
-
</PropertyRow>
|
|
172
|
-
</PropertyList>
|
|
173
|
-
</PropertyPanel>
|
|
174
|
-
</div>
|
|
175
|
-
),
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export const ListWithoutChrome: Story = {
|
|
179
|
-
// No title — this story explicitly demonstrates rendering without the panel chrome.
|
|
180
|
-
argTypes: { title: { table: { disable: true } } },
|
|
181
|
-
render: ({ pack, width }) => (
|
|
182
|
-
<div style={{ width }}>
|
|
183
|
-
<PropertyList pack={pack}>
|
|
184
|
-
<SliderRow label="Bare" value={50} min={0} max={100} onChange={() => {}} />
|
|
185
|
-
<ColorRow label="Color A" value="#b08adb" onChange={() => {}} />
|
|
186
|
-
<ColorRow label="Color B" value="#1a1428" onChange={() => {}} />
|
|
187
|
-
</PropertyList>
|
|
188
|
-
</div>
|
|
189
|
-
),
|
|
190
|
-
};
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
-
import {
|
|
4
|
-
CheckboxRow,
|
|
5
|
-
ColorRow,
|
|
6
|
-
NumberRow,
|
|
7
|
-
PropertyList,
|
|
8
|
-
PropertyPanel,
|
|
9
|
-
PropertyRow,
|
|
10
|
-
SelectRow,
|
|
11
|
-
SliderRow,
|
|
12
|
-
TextRow,
|
|
13
|
-
ToggleRow,
|
|
14
|
-
} from './PropertyPanel';
|
|
15
|
-
|
|
16
|
-
describe('PropertyPanel', () => {
|
|
17
|
-
it('renders title and children', () => {
|
|
18
|
-
render(
|
|
19
|
-
<PropertyPanel title="Shape">
|
|
20
|
-
<PropertyRow label="A">
|
|
21
|
-
<input type="text" defaultValue="x" />
|
|
22
|
-
</PropertyRow>
|
|
23
|
-
</PropertyPanel>,
|
|
24
|
-
);
|
|
25
|
-
expect(screen.getByRole('heading', { name: 'Shape' })).toBeInTheDocument();
|
|
26
|
-
expect(screen.getByText('A')).toBeInTheDocument();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('omits the heading when no title is given', () => {
|
|
30
|
-
const { container } = render(
|
|
31
|
-
<PropertyPanel>
|
|
32
|
-
<PropertyRow label="A">
|
|
33
|
-
<input type="text" defaultValue="x" />
|
|
34
|
-
</PropertyRow>
|
|
35
|
-
</PropertyPanel>,
|
|
36
|
-
);
|
|
37
|
-
expect(container.querySelector('.lk-property-panel__title')).toBeNull();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('renders children directly (no implicit grid)', () => {
|
|
41
|
-
const { container } = render(
|
|
42
|
-
<PropertyPanel>
|
|
43
|
-
<span>raw child</span>
|
|
44
|
-
</PropertyPanel>,
|
|
45
|
-
);
|
|
46
|
-
expect(container.querySelector('.lk-property-list')).toBeNull();
|
|
47
|
-
expect(screen.getByText('raw child')).toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('PropertyList', () => {
|
|
52
|
-
it('renders a grid container', () => {
|
|
53
|
-
const { container } = render(
|
|
54
|
-
<PropertyList>
|
|
55
|
-
<PropertyRow label="A">
|
|
56
|
-
<input type="text" defaultValue="x" />
|
|
57
|
-
</PropertyRow>
|
|
58
|
-
</PropertyList>,
|
|
59
|
-
);
|
|
60
|
-
expect(container.querySelector('.lk-property-list')).not.toBeNull();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('PropertyRow', () => {
|
|
65
|
-
it('renders label and optional readout', () => {
|
|
66
|
-
render(
|
|
67
|
-
<PropertyRow label="Opacity" readout="0.65">
|
|
68
|
-
<input type="range" defaultValue={50} />
|
|
69
|
-
</PropertyRow>,
|
|
70
|
-
);
|
|
71
|
-
expect(screen.getByText('Opacity')).toBeInTheDocument();
|
|
72
|
-
expect(screen.getByText('0.65')).toBeInTheDocument();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('applies variant class', () => {
|
|
76
|
-
const { container } = render(
|
|
77
|
-
<PropertyRow label="L" variant="color">
|
|
78
|
-
<input type="color" defaultValue="#fff" />
|
|
79
|
-
</PropertyRow>,
|
|
80
|
-
);
|
|
81
|
-
expect(container.querySelector('.lk-property-row--color')).not.toBeNull();
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe('SliderRow', () => {
|
|
86
|
-
it('emits numeric value on change', () => {
|
|
87
|
-
const onChange = vi.fn();
|
|
88
|
-
render(<SliderRow label="Op" value={10} min={0} max={100} onChange={onChange} />);
|
|
89
|
-
fireEvent.change(screen.getByRole('slider'), { target: { value: '42' } });
|
|
90
|
-
expect(onChange).toHaveBeenCalledWith(42);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('formats the readout when format is supplied', () => {
|
|
94
|
-
render(
|
|
95
|
-
<SliderRow
|
|
96
|
-
label="Op"
|
|
97
|
-
value={0.5}
|
|
98
|
-
min={0}
|
|
99
|
-
max={1}
|
|
100
|
-
step={0.01}
|
|
101
|
-
onChange={() => {}}
|
|
102
|
-
format={(v) => v.toFixed(2)}
|
|
103
|
-
/>,
|
|
104
|
-
);
|
|
105
|
-
expect(screen.getByDisplayValue('0.50')).toBeInTheDocument();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('ColorRow', () => {
|
|
110
|
-
it('emits the new hex on change', () => {
|
|
111
|
-
const onChange = vi.fn();
|
|
112
|
-
const { container } = render(<ColorRow label="Fill" value="#ffffff" onChange={onChange} />);
|
|
113
|
-
const input = container.querySelector('input[type="color"]') as HTMLInputElement;
|
|
114
|
-
fireEvent.change(input, { target: { value: '#aa3300' } });
|
|
115
|
-
expect(onChange).toHaveBeenCalledWith('#aa3300');
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe('CheckboxRow', () => {
|
|
120
|
-
it('toggles the boolean', () => {
|
|
121
|
-
const onChange = vi.fn();
|
|
122
|
-
render(<CheckboxRow label="Visible" value={false} onChange={onChange} />);
|
|
123
|
-
fireEvent.click(screen.getByRole('checkbox'));
|
|
124
|
-
expect(onChange).toHaveBeenCalledWith(true);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe('TextRow', () => {
|
|
129
|
-
it('emits the new text on change', () => {
|
|
130
|
-
const onChange = vi.fn();
|
|
131
|
-
render(<TextRow label="Name" value="foo" onChange={onChange} />);
|
|
132
|
-
fireEvent.change(screen.getByDisplayValue('foo'), { target: { value: 'bar' } });
|
|
133
|
-
expect(onChange).toHaveBeenCalledWith('bar');
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
describe('NumberRow', () => {
|
|
138
|
-
it('emits a number on change', () => {
|
|
139
|
-
const onChange = vi.fn();
|
|
140
|
-
render(<NumberRow label="N" value={1} onChange={onChange} />);
|
|
141
|
-
fireEvent.change(screen.getByRole('spinbutton'), { target: { value: '42' } });
|
|
142
|
-
expect(onChange).toHaveBeenCalledWith(42);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('ignores non-finite values', () => {
|
|
146
|
-
const onChange = vi.fn();
|
|
147
|
-
render(<NumberRow label="N" value={1} onChange={onChange} />);
|
|
148
|
-
fireEvent.change(screen.getByRole('spinbutton'), { target: { value: 'abc' } });
|
|
149
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
describe('SelectRow', () => {
|
|
154
|
-
it('emits the selected option', () => {
|
|
155
|
-
const onChange = vi.fn();
|
|
156
|
-
render(
|
|
157
|
-
<SelectRow
|
|
158
|
-
label="Mode"
|
|
159
|
-
value="a"
|
|
160
|
-
options={[
|
|
161
|
-
{ value: 'a', label: 'A' },
|
|
162
|
-
{ value: 'b', label: 'B' },
|
|
163
|
-
]}
|
|
164
|
-
onChange={onChange}
|
|
165
|
-
/>,
|
|
166
|
-
);
|
|
167
|
-
fireEvent.change(screen.getByRole('combobox'), { target: { value: 'b' } });
|
|
168
|
-
expect(onChange).toHaveBeenCalledWith('b');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('ToggleRow', () => {
|
|
173
|
-
it('marks the active option aria-pressed and emits on click', () => {
|
|
174
|
-
const onChange = vi.fn();
|
|
175
|
-
render(
|
|
176
|
-
<ToggleRow
|
|
177
|
-
label="Align"
|
|
178
|
-
value="left"
|
|
179
|
-
options={[
|
|
180
|
-
{ value: 'left', label: 'L' },
|
|
181
|
-
{ value: 'right', label: 'R' },
|
|
182
|
-
]}
|
|
183
|
-
onChange={onChange}
|
|
184
|
-
/>,
|
|
185
|
-
);
|
|
186
|
-
const left = screen.getByText('L');
|
|
187
|
-
const right = screen.getByText('R');
|
|
188
|
-
expect(left).toHaveAttribute('aria-pressed', 'true');
|
|
189
|
-
expect(right).toHaveAttribute('aria-pressed', 'false');
|
|
190
|
-
fireEvent.click(right);
|
|
191
|
-
expect(onChange).toHaveBeenCalledWith('right');
|
|
192
|
-
});
|
|
193
|
-
});
|