@adea-ai/ui 0.160.1 → 0.160.2
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/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts.map +1 -1
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js +10 -4
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -1
- package/dist/r/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +17 -4
- package/package.json +1 -1
- package/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +17 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixel-resize-handle.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx"],"names":[],"mappings":"AASA,MAAM,MAAM,sBAAsB,GAAG;IACnC,6EAA6E;IAC7E,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"pixel-resize-handle.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx"],"names":[],"mappings":"AASA,MAAM,MAAM,sBAAsB,GAAG;IACnC,6EAA6E;IAC7E,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,sCAwK9D"}
|
|
@@ -29,29 +29,34 @@ function PixelResizeHandle(props) {
|
|
|
29
29
|
const value = () => Math.min(maximum(), Math.max(minimum(), Math.round(props.value)));
|
|
30
30
|
const isRight = () => props.side === "right";
|
|
31
31
|
const bounded = (next) => Math.min(maximum(), Math.max(minimum(), Math.round(next)));
|
|
32
|
-
const commit = () => props.onCommit?.(
|
|
32
|
+
const commit = (next = value()) => props.onCommit?.(next);
|
|
33
33
|
let interacting = false;
|
|
34
34
|
const [drag, setDrag] = createSignal();
|
|
35
35
|
let pendingMove;
|
|
36
36
|
let moveFrame;
|
|
37
|
+
let pointerValue;
|
|
37
38
|
const flushMove = () => {
|
|
38
39
|
if (moveFrame !== void 0) cancelAnimationFrame(moveFrame);
|
|
39
40
|
moveFrame = void 0;
|
|
40
41
|
const next = pendingMove;
|
|
41
42
|
pendingMove = void 0;
|
|
42
|
-
if (next
|
|
43
|
+
if (next === void 0) return;
|
|
44
|
+
move(next);
|
|
45
|
+
return next;
|
|
43
46
|
};
|
|
44
47
|
const scheduleMove = (next) => {
|
|
45
48
|
pendingMove = next;
|
|
49
|
+
pointerValue = next;
|
|
46
50
|
if (moveFrame === void 0) moveFrame = requestAnimationFrame(flushMove);
|
|
47
51
|
};
|
|
48
52
|
const endPointer = (shouldCommit) => {
|
|
49
53
|
const current = drag();
|
|
50
54
|
if (!current) return;
|
|
51
|
-
flushMove();
|
|
55
|
+
const committed = flushMove() ?? pointerValue ?? value();
|
|
56
|
+
pointerValue = void 0;
|
|
52
57
|
setDrag(void 0);
|
|
53
58
|
if (current.handle.hasPointerCapture(current.pointerId)) current.handle.releasePointerCapture(current.pointerId);
|
|
54
|
-
if (shouldCommit) commit();
|
|
59
|
+
if (shouldCommit) commit(committed);
|
|
55
60
|
};
|
|
56
61
|
const endKeyboard = () => {
|
|
57
62
|
const wasInteracting = interacting;
|
|
@@ -128,6 +133,7 @@ function PixelResizeHandle(props) {
|
|
|
128
133
|
interacting = false;
|
|
129
134
|
handle.focus();
|
|
130
135
|
handle.setPointerCapture(event.pointerId);
|
|
136
|
+
pointerValue = void 0;
|
|
131
137
|
setDrag({
|
|
132
138
|
pointerId: event.pointerId,
|
|
133
139
|
startX: event.clientX,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixel-resize-handle.js","names":["<GripVertical class={resizeGripIconClass} />","class={resizeGripIconClass}","width: `${maximum()}px`","aria-label={props.label ?? `Resize ${props.side} pane`}","aria-controls={props.controls}","aria-valuemin={minimum()}","aria-valuemax={maximum()}","aria-valuenow={value()}","aria-valuetext={`${value()} pixels`}","data-dragging={drag() ? '' : undefined}","left: `${isRight() ? maximum() - value() : value()}px`","class={cn(\n resizeSeparatorClass(props.grip ?? 'rung'),\n 'pointer-events-auto absolute inset-y-0 w-px cursor-pointer'\n )}","<div\n class={cn(\n 'pointer-events-none absolute inset-y-0',\n {\n 'left-0': props.side === 'left',\n 'right-0': props.side === 'right',\n },\n props.class\n )}\n style={{ width: `${maximum()}px` }}\n >\n <div\n role=\"separator\"\n tabindex={0}\n aria-orientation=\"vertical\"\n aria-label={props.label ?? `Resize ${props.side} pane`}\n aria-controls={props.controls}\n aria-valuemin={minimum()}\n aria-valuemax={maximum()}\n aria-valuenow={value()}\n aria-valuetext={`${value()} pixels`}\n data-dragging={drag() ? '' : undefined}\n style={{ left: `${isRight() ? maximum() - value() : value()}px` }}\n class={cn(\n resizeSeparatorClass(props.grip ?? 'rung'),\n 'pointer-events-auto absolute inset-y-0 w-px cursor-pointer'\n )}\n onPointerDown={(event) => {\n if (event.button !== 0 || !event.isPrimary) return\n const handle = event.currentTarget\n endPointer(false)\n interacting = false\n handle.focus()\n handle.setPointerCapture(event.pointerId)\n setDrag({\n pointerId: event.pointerId,\n startX: event.clientX,\n startValue: value(),\n handle,\n })\n }}\n onPointerMove={(event) => {\n const current = drag()\n if (!current || event.pointerId !== current.pointerId) return\n if (!current.handle.hasPointerCapture(current.pointerId)) {\n endPointer(false)\n return\n }\n const delta = (event.clientX - current.startX) * (isRight() ? -1 : 1)\n scheduleMove(bounded(current.startValue + delta))\n }}\n // A press that lands in a text selection would start a native drag of it,\n // and the browser cancels the pointer gesture for that drag.\n onDragStart={(event) => event.preventDefault()}\n onPointerUp={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(true)\n }}\n onPointerCancel={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onLostPointerCapture={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onBlur={() => {\n endKeyboard()\n endPointer(false)\n }}\n onKeyDown={(event) => {\n const current = drag()\n if (current && !current.handle.hasPointerCapture(current.pointerId)) endPointer(false)\n if (drag()) {\n event.preventDefault()\n return\n }\n const direction = KEY_DIRECTION[event.key]\n if (direction !== undefined) {\n event.preventDefault()\n interacting = true\n move(bounded(value() + direction * (isRight() ? -1 : 1) * (props.step ?? 16)))\n } else if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault()\n interacting = true\n move(event.key === 'Home' ? minimum() : maximum())\n }\n }}\n onKeyUp={(event) => {\n if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) endKeyboard()\n }}\n >\n {props.grip === 'chip' ? (\n <div class={resizeGripClass.chip}>\n <GripVertical class={resizeGripIconClass} />\n </div>\n ) : (\n <div data-slot=\"resizable-grip\" class={resizeGripClass.rung} />\n )}\n </div>\n </div>","GripVertical","LucideGripVertical","_$readShallow","_$setStyleProperty","_$setAttribute"],"sources":["../../../../src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx"],"sourcesContent":["import { GripVertical as LucideGripVertical } from '@lucide/solid'\nimport { createSignal, onCleanup } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { resizeGripClass, resizeGripIconClass, resizeSeparatorClass } from '#lib/resize-separator'\nimport { fastIcon } from '#lib/fast-icon'\n\n// lucide icons drawn from a cloned template (see fastIcon).\nconst GripVertical = fastIcon(LucideGripVertical)\n\nexport type PixelResizeHandleProps = {\n /** Which physical edge of the ruler the resizable surface is attached to. */\n side: 'left' | 'right'\n /** Current width in CSS pixels. */\n value: number\n minimum: number\n maximum: number\n step?: number\n label?: string\n controls?: string\n class?: string\n /**\n * The grip drawn on the edge: the quieter rung by default, or the bordered\n * chip for hosts that want the heavier affordance.\n */\n grip?: 'chip' | 'rung'\n onChange(value: number): void\n onCommit?(value: number): void\n}\n\n/**\n * PixelResizeHandle.\n *\n * A keyboard- and pointer-operable edge ruler for a host-owned pane. Keep the\n * pane's actual width and any persistence in its layout owner; this component\n * reports a bounded pixel value and draws the grip at the matching left or\n * right edge.\n *\n * The ruler is a single separator positioned inside a box as wide as the\n * maximum, so it needs no panel-group geometry (and none of the split-layout\n * code that comes with one): arrow keys move it by `step` along its visual\n * edge, Home and End jump to the bounds, and a pointer drag is captured on the\n * handle so cancellation and lost capture end the gesture.\n */\nexport function PixelResizeHandle(props: PixelResizeHandleProps) {\n const maximum = () => Math.max(1, props.maximum)\n const minimum = () => Math.min(maximum(), Math.max(0, props.minimum))\n const value = () => Math.min(maximum(), Math.max(minimum(), Math.round(props.value)))\n const isRight = () => props.side === 'right'\n const bounded = (next: number) => Math.min(maximum(), Math.max(minimum(), Math.round(next)))\n const commit = () => props.onCommit?.(value())\n let interacting = false\n const [drag, setDrag] = createSignal<{\n pointerId: number\n startX: number\n startValue: number\n handle: HTMLElement\n }>()\n // Pointer moves are applied once per frame: each `onChange` relays out the\n // shell, and pointer events can arrive faster than frames (WebKit does not align\n // them). Ending the gesture applies the last pending value first.\n let pendingMove: number | undefined\n let moveFrame: number | undefined\n const flushMove = () => {\n if (moveFrame !== undefined) cancelAnimationFrame(moveFrame)\n moveFrame = undefined\n const next = pendingMove\n pendingMove = undefined\n if (next !== undefined) move(next)\n }\n const scheduleMove = (next: number) => {\n pendingMove = next\n if (moveFrame === undefined) moveFrame = requestAnimationFrame(flushMove)\n }\n const endPointer = (shouldCommit: boolean) => {\n const current = drag()\n if (!current) return\n flushMove()\n setDrag(undefined)\n if (current.handle.hasPointerCapture(current.pointerId))\n current.handle.releasePointerCapture(current.pointerId)\n if (shouldCommit) commit()\n }\n const endKeyboard = () => {\n const wasInteracting = interacting\n interacting = false\n if (wasInteracting) commit()\n }\n onCleanup(() => {\n endKeyboard()\n endPointer(false)\n })\n const move = (next: number) => {\n if (next !== value()) props.onChange(next)\n }\n // Arrow keys describe physical movement of the handle: on a right-edge pane\n // moving the handle left widens the pane.\n const KEY_DIRECTION: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1 }\n\n return (\n <div\n class={cn(\n 'pointer-events-none absolute inset-y-0',\n {\n 'left-0': props.side === 'left',\n 'right-0': props.side === 'right',\n },\n props.class\n )}\n style={{ width: `${maximum()}px` }}\n >\n <div\n role=\"separator\"\n tabindex={0}\n aria-orientation=\"vertical\"\n aria-label={props.label ?? `Resize ${props.side} pane`}\n aria-controls={props.controls}\n aria-valuemin={minimum()}\n aria-valuemax={maximum()}\n aria-valuenow={value()}\n aria-valuetext={`${value()} pixels`}\n data-dragging={drag() ? '' : undefined}\n style={{ left: `${isRight() ? maximum() - value() : value()}px` }}\n class={cn(\n resizeSeparatorClass(props.grip ?? 'rung'),\n 'pointer-events-auto absolute inset-y-0 w-px cursor-pointer'\n )}\n onPointerDown={(event) => {\n if (event.button !== 0 || !event.isPrimary) return\n const handle = event.currentTarget\n endPointer(false)\n interacting = false\n handle.focus()\n handle.setPointerCapture(event.pointerId)\n setDrag({\n pointerId: event.pointerId,\n startX: event.clientX,\n startValue: value(),\n handle,\n })\n }}\n onPointerMove={(event) => {\n const current = drag()\n if (!current || event.pointerId !== current.pointerId) return\n if (!current.handle.hasPointerCapture(current.pointerId)) {\n endPointer(false)\n return\n }\n const delta = (event.clientX - current.startX) * (isRight() ? -1 : 1)\n scheduleMove(bounded(current.startValue + delta))\n }}\n // A press that lands in a text selection would start a native drag of it,\n // and the browser cancels the pointer gesture for that drag.\n onDragStart={(event) => event.preventDefault()}\n onPointerUp={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(true)\n }}\n onPointerCancel={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onLostPointerCapture={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onBlur={() => {\n endKeyboard()\n endPointer(false)\n }}\n onKeyDown={(event) => {\n const current = drag()\n if (current && !current.handle.hasPointerCapture(current.pointerId)) endPointer(false)\n if (drag()) {\n event.preventDefault()\n return\n }\n const direction = KEY_DIRECTION[event.key]\n if (direction !== undefined) {\n event.preventDefault()\n interacting = true\n move(bounded(value() + direction * (isRight() ? -1 : 1) * (props.step ?? 16)))\n } else if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault()\n interacting = true\n move(event.key === 'Home' ? minimum() : maximum())\n }\n }}\n onKeyUp={(event) => {\n if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) endKeyboard()\n }}\n >\n {props.grip === 'chip' ? (\n <div class={resizeGripClass.chip}>\n <GripVertical class={resizeGripIconClass} />\n </div>\n ) : (\n <div data-slot=\"resizable-grip\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QAAQ,EAAE;GAM3BC,GAAY,MAAM,SAAS,UAAU,MAAM,KAAK;GAChDC,GAAe,MAAM;GACrBC,GAAe,QAAQ;GACvBC,GAAe,QAAQ;GACvBC,GAAe,MAAM;GACrBC,GAAgB,GAAG,MAAM,EAAE;GAC3BC,GAAe,KAAK,IAAI,KAAK,KAAA;GACpBC,GAAM,GAAG,QAAQ,IAAI,QAAQ,IAAI,MAAM,IAAI,MAAM,EAAE;GAC5DC,GAAAA,YAAO,GACL,qBAAqB,MAAM,QAAQ,MAAM,GACzC,4DACF,CAAC;EAlBF;CAPD,IAAA,EAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,KAAA,QAAA;EAOC,UAAA,MAAA,GAAA,KAAA,CAAA;EACQ,MAAA,KAAA,KAAAK,iBAAA,MAAA,SAAA,CAAsB;EAM7B,MAAA,KAAA,KAAAC,aAAA,OAAA,cAAA,CAAsD;EACtD,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAA6B;EAC7B,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAAwB;EACxB,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAAwB;EACxB,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAAsB;EACtB,MAAA,KAAA,KAAAA,aAAA,OAAA,kBAAA,CAAmC;EACnC,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAAsC;EAC7B,MAAA,KAAA,KAAAD,iBAAA,OAAA,QAAA,CAAqD;EAC9D,UAAA,OAAA,GAAA,KAAA,CAGC;CAlBF,CAAA;CATL,OACEJ;AAmGJ"}
|
|
1
|
+
{"version":3,"file":"pixel-resize-handle.js","names":["<GripVertical class={resizeGripIconClass} />","class={resizeGripIconClass}","width: `${maximum()}px`","aria-label={props.label ?? `Resize ${props.side} pane`}","aria-controls={props.controls}","aria-valuemin={minimum()}","aria-valuemax={maximum()}","aria-valuenow={value()}","aria-valuetext={`${value()} pixels`}","data-dragging={drag() ? '' : undefined}","left: `${isRight() ? maximum() - value() : value()}px`","class={cn(\n resizeSeparatorClass(props.grip ?? 'rung'),\n 'pointer-events-auto absolute inset-y-0 w-px cursor-pointer'\n )}","<div\n class={cn(\n 'pointer-events-none absolute inset-y-0',\n {\n 'left-0': props.side === 'left',\n 'right-0': props.side === 'right',\n },\n props.class\n )}\n style={{ width: `${maximum()}px` }}\n >\n <div\n role=\"separator\"\n tabindex={0}\n aria-orientation=\"vertical\"\n aria-label={props.label ?? `Resize ${props.side} pane`}\n aria-controls={props.controls}\n aria-valuemin={minimum()}\n aria-valuemax={maximum()}\n aria-valuenow={value()}\n aria-valuetext={`${value()} pixels`}\n data-dragging={drag() ? '' : undefined}\n style={{ left: `${isRight() ? maximum() - value() : value()}px` }}\n class={cn(\n resizeSeparatorClass(props.grip ?? 'rung'),\n 'pointer-events-auto absolute inset-y-0 w-px cursor-pointer'\n )}\n onPointerDown={(event) => {\n if (event.button !== 0 || !event.isPrimary) return\n const handle = event.currentTarget\n endPointer(false)\n interacting = false\n handle.focus()\n handle.setPointerCapture(event.pointerId)\n pointerValue = undefined\n setDrag({\n pointerId: event.pointerId,\n startX: event.clientX,\n startValue: value(),\n handle,\n })\n }}\n onPointerMove={(event) => {\n const current = drag()\n if (!current || event.pointerId !== current.pointerId) return\n if (!current.handle.hasPointerCapture(current.pointerId)) {\n endPointer(false)\n return\n }\n const delta = (event.clientX - current.startX) * (isRight() ? -1 : 1)\n scheduleMove(bounded(current.startValue + delta))\n }}\n // A press that lands in a text selection would start a native drag of it,\n // and the browser cancels the pointer gesture for that drag.\n onDragStart={(event) => event.preventDefault()}\n onPointerUp={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(true)\n }}\n onPointerCancel={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onLostPointerCapture={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onBlur={() => {\n endKeyboard()\n endPointer(false)\n }}\n onKeyDown={(event) => {\n const current = drag()\n if (current && !current.handle.hasPointerCapture(current.pointerId)) endPointer(false)\n if (drag()) {\n event.preventDefault()\n return\n }\n const direction = KEY_DIRECTION[event.key]\n if (direction !== undefined) {\n event.preventDefault()\n interacting = true\n move(bounded(value() + direction * (isRight() ? -1 : 1) * (props.step ?? 16)))\n } else if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault()\n interacting = true\n move(event.key === 'Home' ? minimum() : maximum())\n }\n }}\n onKeyUp={(event) => {\n if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) endKeyboard()\n }}\n >\n {props.grip === 'chip' ? (\n <div class={resizeGripClass.chip}>\n <GripVertical class={resizeGripIconClass} />\n </div>\n ) : (\n <div data-slot=\"resizable-grip\" class={resizeGripClass.rung} />\n )}\n </div>\n </div>","GripVertical","LucideGripVertical","_$readShallow","_$setStyleProperty","_$setAttribute"],"sources":["../../../../src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx"],"sourcesContent":["import { GripVertical as LucideGripVertical } from '@lucide/solid'\nimport { createSignal, onCleanup } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { resizeGripClass, resizeGripIconClass, resizeSeparatorClass } from '#lib/resize-separator'\nimport { fastIcon } from '#lib/fast-icon'\n\n// lucide icons drawn from a cloned template (see fastIcon).\nconst GripVertical = fastIcon(LucideGripVertical)\n\nexport type PixelResizeHandleProps = {\n /** Which physical edge of the ruler the resizable surface is attached to. */\n side: 'left' | 'right'\n /** Current width in CSS pixels. */\n value: number\n minimum: number\n maximum: number\n step?: number\n label?: string\n controls?: string\n class?: string\n /**\n * The grip drawn on the edge: the quieter rung by default, or the bordered\n * chip for hosts that want the heavier affordance.\n */\n grip?: 'chip' | 'rung'\n onChange(value: number): void\n onCommit?(value: number): void\n}\n\n/**\n * PixelResizeHandle.\n *\n * A keyboard- and pointer-operable edge ruler for a host-owned pane. Keep the\n * pane's actual width and any persistence in its layout owner; this component\n * reports a bounded pixel value and draws the grip at the matching left or\n * right edge.\n *\n * The ruler is a single separator positioned inside a box as wide as the\n * maximum, so it needs no panel-group geometry (and none of the split-layout\n * code that comes with one): arrow keys move it by `step` along its visual\n * edge, Home and End jump to the bounds, and a pointer drag is captured on the\n * handle so cancellation and lost capture end the gesture.\n */\nexport function PixelResizeHandle(props: PixelResizeHandleProps) {\n const maximum = () => Math.max(1, props.maximum)\n const minimum = () => Math.min(maximum(), Math.max(0, props.minimum))\n const value = () => Math.min(maximum(), Math.max(minimum(), Math.round(props.value)))\n const isRight = () => props.side === 'right'\n const bounded = (next: number) => Math.min(maximum(), Math.max(minimum(), Math.round(next)))\n const commit = (next = value()) => props.onCommit?.(next)\n let interacting = false\n const [drag, setDrag] = createSignal<{\n pointerId: number\n startX: number\n startValue: number\n handle: HTMLElement\n }>()\n // Pointer moves are applied once per frame: each `onChange` relays out the\n // shell, and pointer events can arrive faster than frames (WebKit does not align\n // them). Ending the gesture applies the last pending value first.\n let pendingMove: number | undefined\n let moveFrame: number | undefined\n // The last value the pointer asked for, whether or not its frame has run. A\n // release reads this rather than the prop, which reports the host's previous\n // width until the update renders.\n let pointerValue: number | undefined\n const flushMove = () => {\n if (moveFrame !== undefined) cancelAnimationFrame(moveFrame)\n moveFrame = undefined\n const next = pendingMove\n pendingMove = undefined\n if (next === undefined) return\n move(next)\n return next\n }\n const scheduleMove = (next: number) => {\n pendingMove = next\n pointerValue = next\n if (moveFrame === undefined) moveFrame = requestAnimationFrame(flushMove)\n }\n const endPointer = (shouldCommit: boolean) => {\n const current = drag()\n if (!current) return\n const applied = flushMove()\n // The pending move is applied to the host first, but the prop it reports\n // through is read on the next render. Commit the value just applied, not\n // the stale prop, or a fast release reports the previous width.\n const committed = applied ?? pointerValue ?? value()\n pointerValue = undefined\n setDrag(undefined)\n if (current.handle.hasPointerCapture(current.pointerId))\n current.handle.releasePointerCapture(current.pointerId)\n if (shouldCommit) commit(committed)\n }\n const endKeyboard = () => {\n const wasInteracting = interacting\n interacting = false\n if (wasInteracting) commit()\n }\n onCleanup(() => {\n endKeyboard()\n endPointer(false)\n })\n const move = (next: number) => {\n if (next !== value()) props.onChange(next)\n }\n // Arrow keys describe physical movement of the handle: on a right-edge pane\n // moving the handle left widens the pane.\n const KEY_DIRECTION: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1 }\n\n return (\n <div\n class={cn(\n 'pointer-events-none absolute inset-y-0',\n {\n 'left-0': props.side === 'left',\n 'right-0': props.side === 'right',\n },\n props.class\n )}\n style={{ width: `${maximum()}px` }}\n >\n <div\n role=\"separator\"\n tabindex={0}\n aria-orientation=\"vertical\"\n aria-label={props.label ?? `Resize ${props.side} pane`}\n aria-controls={props.controls}\n aria-valuemin={minimum()}\n aria-valuemax={maximum()}\n aria-valuenow={value()}\n aria-valuetext={`${value()} pixels`}\n data-dragging={drag() ? '' : undefined}\n style={{ left: `${isRight() ? maximum() - value() : value()}px` }}\n class={cn(\n resizeSeparatorClass(props.grip ?? 'rung'),\n 'pointer-events-auto absolute inset-y-0 w-px cursor-pointer'\n )}\n onPointerDown={(event) => {\n if (event.button !== 0 || !event.isPrimary) return\n const handle = event.currentTarget\n endPointer(false)\n interacting = false\n handle.focus()\n handle.setPointerCapture(event.pointerId)\n pointerValue = undefined\n setDrag({\n pointerId: event.pointerId,\n startX: event.clientX,\n startValue: value(),\n handle,\n })\n }}\n onPointerMove={(event) => {\n const current = drag()\n if (!current || event.pointerId !== current.pointerId) return\n if (!current.handle.hasPointerCapture(current.pointerId)) {\n endPointer(false)\n return\n }\n const delta = (event.clientX - current.startX) * (isRight() ? -1 : 1)\n scheduleMove(bounded(current.startValue + delta))\n }}\n // A press that lands in a text selection would start a native drag of it,\n // and the browser cancels the pointer gesture for that drag.\n onDragStart={(event) => event.preventDefault()}\n onPointerUp={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(true)\n }}\n onPointerCancel={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onLostPointerCapture={(event) => {\n if (event.pointerId === drag()?.pointerId) endPointer(false)\n }}\n onBlur={() => {\n endKeyboard()\n endPointer(false)\n }}\n onKeyDown={(event) => {\n const current = drag()\n if (current && !current.handle.hasPointerCapture(current.pointerId)) endPointer(false)\n if (drag()) {\n event.preventDefault()\n return\n }\n const direction = KEY_DIRECTION[event.key]\n if (direction !== undefined) {\n event.preventDefault()\n interacting = true\n move(bounded(value() + direction * (isRight() ? -1 : 1) * (props.step ?? 16)))\n } else if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault()\n interacting = true\n move(event.key === 'Home' ? minimum() : maximum())\n }\n }}\n onKeyUp={(event) => {\n if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) endKeyboard()\n }}\n >\n {props.grip === 'chip' ? (\n <div class={resizeGripClass.chip}>\n <GripVertical class={resizeGripIconClass} />\n </div>\n ) : (\n <div data-slot=\"resizable-grip\" class={resizeGripClass.rung} />\n )}\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;AAOA,IAAMa,iBAAe,SAASC,YAAkB;;;;;;;;;;;;;;;AAoChD,SAAgB,kBAAkB,OAA+B;CAC/D,MAAM,gBAAgB,KAAK,IAAI,GAAG,MAAM,OAAO;CAC/C,MAAM,gBAAgB,KAAK,IAAI,QAAQ,GAAG,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC;CACpE,MAAM,cAAc,KAAK,IAAI,QAAQ,GAAG,KAAK,IAAI,QAAQ,GAAG,KAAK,MAAM,MAAM,KAAK,CAAC,CAAC;CACpF,MAAM,gBAAgB,MAAM,SAAS;CACrC,MAAM,WAAW,SAAiB,KAAK,IAAI,QAAQ,GAAG,KAAK,IAAI,QAAQ,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC;CAC3F,MAAM,UAAU,OAAO,MAAM,MAAM,MAAM,WAAW,IAAI;CACxD,IAAI,cAAc;CAClB,MAAM,CAAC,MAAM,WAAW,aAKrB;CAIH,IAAI;CACJ,IAAI;CAIJ,IAAI;CACJ,MAAM,kBA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AAA,OAAA,cAAA,CAAsD;EACtD,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAA6B;EAC7B,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAAwB;EACxB,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAAwB;EACxB,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAAsB;EACtB,MAAA,KAAA,KAAAA,aAAA,OAAA,kBAAA,CAAmC;EACnC,MAAA,KAAA,KAAAA,aAAA,OAAA,iBAAA,CAAsC;EAC7B,MAAA,KAAA,KAAAD,iBAAA,OAAA,QAAA,CAAqD;EAC9D,UAAA,OAAA,GAAA,KAAA,CAGC;CAlBF,CAAA;CATL,OACEJ;AAoGJ"}
|
|
@@ -47,7 +47,7 @@ export function PixelResizeHandle(props: PixelResizeHandleProps) {
|
|
|
47
47
|
const value = () => Math.min(maximum(), Math.max(minimum(), Math.round(props.value)))
|
|
48
48
|
const isRight = () => props.side === 'right'
|
|
49
49
|
const bounded = (next: number) => Math.min(maximum(), Math.max(minimum(), Math.round(next)))
|
|
50
|
-
const commit = () => props.onCommit?.(
|
|
50
|
+
const commit = (next = value()) => props.onCommit?.(next)
|
|
51
51
|
let interacting = false
|
|
52
52
|
const [drag, setDrag] = createSignal<{
|
|
53
53
|
pointerId: number
|
|
@@ -60,25 +60,37 @@ export function PixelResizeHandle(props: PixelResizeHandleProps) {
|
|
|
60
60
|
// them). Ending the gesture applies the last pending value first.
|
|
61
61
|
let pendingMove: number | undefined
|
|
62
62
|
let moveFrame: number | undefined
|
|
63
|
+
// The last value the pointer asked for, whether or not its frame has run. A
|
|
64
|
+
// release reads this rather than the prop, which reports the host's previous
|
|
65
|
+
// width until the update renders.
|
|
66
|
+
let pointerValue: number | undefined
|
|
63
67
|
const flushMove = () => {
|
|
64
68
|
if (moveFrame !== undefined) cancelAnimationFrame(moveFrame)
|
|
65
69
|
moveFrame = undefined
|
|
66
70
|
const next = pendingMove
|
|
67
71
|
pendingMove = undefined
|
|
68
|
-
if (next
|
|
72
|
+
if (next === undefined) return
|
|
73
|
+
move(next)
|
|
74
|
+
return next
|
|
69
75
|
}
|
|
70
76
|
const scheduleMove = (next: number) => {
|
|
71
77
|
pendingMove = next
|
|
78
|
+
pointerValue = next
|
|
72
79
|
if (moveFrame === undefined) moveFrame = requestAnimationFrame(flushMove)
|
|
73
80
|
}
|
|
74
81
|
const endPointer = (shouldCommit: boolean) => {
|
|
75
82
|
const current = drag()
|
|
76
83
|
if (!current) return
|
|
77
|
-
flushMove()
|
|
84
|
+
const applied = flushMove()
|
|
85
|
+
// The pending move is applied to the host first, but the prop it reports
|
|
86
|
+
// through is read on the next render. Commit the value just applied, not
|
|
87
|
+
// the stale prop, or a fast release reports the previous width.
|
|
88
|
+
const committed = applied ?? pointerValue ?? value()
|
|
89
|
+
pointerValue = undefined
|
|
78
90
|
setDrag(undefined)
|
|
79
91
|
if (current.handle.hasPointerCapture(current.pointerId))
|
|
80
92
|
current.handle.releasePointerCapture(current.pointerId)
|
|
81
|
-
if (shouldCommit) commit()
|
|
93
|
+
if (shouldCommit) commit(committed)
|
|
82
94
|
}
|
|
83
95
|
const endKeyboard = () => {
|
|
84
96
|
const wasInteracting = interacting
|
|
@@ -131,6 +143,7 @@ export function PixelResizeHandle(props: PixelResizeHandleProps) {
|
|
|
131
143
|
interacting = false
|
|
132
144
|
handle.focus()
|
|
133
145
|
handle.setPointerCapture(event.pointerId)
|
|
146
|
+
pointerValue = undefined
|
|
134
147
|
setDrag({
|
|
135
148
|
pointerId: event.pointerId,
|
|
136
149
|
startX: event.clientX,
|
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ export function PixelResizeHandle(props: PixelResizeHandleProps) {
|
|
|
47
47
|
const value = () => Math.min(maximum(), Math.max(minimum(), Math.round(props.value)))
|
|
48
48
|
const isRight = () => props.side === 'right'
|
|
49
49
|
const bounded = (next: number) => Math.min(maximum(), Math.max(minimum(), Math.round(next)))
|
|
50
|
-
const commit = () => props.onCommit?.(
|
|
50
|
+
const commit = (next = value()) => props.onCommit?.(next)
|
|
51
51
|
let interacting = false
|
|
52
52
|
const [drag, setDrag] = createSignal<{
|
|
53
53
|
pointerId: number
|
|
@@ -60,25 +60,37 @@ export function PixelResizeHandle(props: PixelResizeHandleProps) {
|
|
|
60
60
|
// them). Ending the gesture applies the last pending value first.
|
|
61
61
|
let pendingMove: number | undefined
|
|
62
62
|
let moveFrame: number | undefined
|
|
63
|
+
// The last value the pointer asked for, whether or not its frame has run. A
|
|
64
|
+
// release reads this rather than the prop, which reports the host's previous
|
|
65
|
+
// width until the update renders.
|
|
66
|
+
let pointerValue: number | undefined
|
|
63
67
|
const flushMove = () => {
|
|
64
68
|
if (moveFrame !== undefined) cancelAnimationFrame(moveFrame)
|
|
65
69
|
moveFrame = undefined
|
|
66
70
|
const next = pendingMove
|
|
67
71
|
pendingMove = undefined
|
|
68
|
-
if (next
|
|
72
|
+
if (next === undefined) return
|
|
73
|
+
move(next)
|
|
74
|
+
return next
|
|
69
75
|
}
|
|
70
76
|
const scheduleMove = (next: number) => {
|
|
71
77
|
pendingMove = next
|
|
78
|
+
pointerValue = next
|
|
72
79
|
if (moveFrame === undefined) moveFrame = requestAnimationFrame(flushMove)
|
|
73
80
|
}
|
|
74
81
|
const endPointer = (shouldCommit: boolean) => {
|
|
75
82
|
const current = drag()
|
|
76
83
|
if (!current) return
|
|
77
|
-
flushMove()
|
|
84
|
+
const applied = flushMove()
|
|
85
|
+
// The pending move is applied to the host first, but the prop it reports
|
|
86
|
+
// through is read on the next render. Commit the value just applied, not
|
|
87
|
+
// the stale prop, or a fast release reports the previous width.
|
|
88
|
+
const committed = applied ?? pointerValue ?? value()
|
|
89
|
+
pointerValue = undefined
|
|
78
90
|
setDrag(undefined)
|
|
79
91
|
if (current.handle.hasPointerCapture(current.pointerId))
|
|
80
92
|
current.handle.releasePointerCapture(current.pointerId)
|
|
81
|
-
if (shouldCommit) commit()
|
|
93
|
+
if (shouldCommit) commit(committed)
|
|
82
94
|
}
|
|
83
95
|
const endKeyboard = () => {
|
|
84
96
|
const wasInteracting = interacting
|
|
@@ -131,6 +143,7 @@ export function PixelResizeHandle(props: PixelResizeHandleProps) {
|
|
|
131
143
|
interacting = false
|
|
132
144
|
handle.focus()
|
|
133
145
|
handle.setPointerCapture(event.pointerId)
|
|
146
|
+
pointerValue = undefined
|
|
134
147
|
setDrag({
|
|
135
148
|
pointerId: event.pointerId,
|
|
136
149
|
startX: event.clientX,
|