@gridui/resizable 1.0.1 → 1.0.3
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/README.md +2 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +2 -2
- package/dist/styles.css +1 -1
- package/docs/catalog.json +6 -2
- package/docs/reference/README.md +4 -0
- package/docs/reference/resizable.md +107 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -27,3 +27,5 @@ Use `size`/`onSizeChange` for controlled state, or `defaultSize` for local state
|
|
|
27
27
|
The separator has a required `label`, a range, and relationships to both regions. Use the orientation's arrow keys to resize, Shift+Arrow for ten steps, or Home/End for the bounds. Horizontal arrows and drag movement respect inherited RTL; vertical movement does not reverse. Pointer capture continues the drag outside the handle. Escape, pointer cancellation, window blur, or an orientation change requests restoration of the pre-drag size. During a drag, Escape is consumed before an enclosing dialog can dismiss; the next Escape retains the dialog's normal behavior. Touch handles use a larger target. The separator does not submit or reset form state.
|
|
28
28
|
|
|
29
29
|
See [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-layout/resizable/.changeset/history).
|
|
30
|
+
|
|
31
|
+
[Component reference](docs/reference/README.md) contains focused API pages for each public component.
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var keyboardSize = (key, size, step, horizontal, reverse, min, max) => {
|
|
|
25
25
|
|
|
26
26
|
// src/resizable/resizable.tsx
|
|
27
27
|
import { isComposingKeyEvent, listenForDragCancellation } from "@gridui/interaction";
|
|
28
|
+
import { useInteractionOutline } from "@gridui/overlay";
|
|
28
29
|
import { cn } from "@gridui/style-utils";
|
|
29
30
|
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
30
31
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -51,6 +52,8 @@ var Resizable = (props) => {
|
|
|
51
52
|
] = useState(defaultSize);
|
|
52
53
|
const drag = useRef(null);
|
|
53
54
|
const separator = useRef(null);
|
|
55
|
+
const firstRef = useInteractionOutline({});
|
|
56
|
+
const secondRef = useInteractionOutline({});
|
|
54
57
|
const firstId = useId();
|
|
55
58
|
const secondId = useId();
|
|
56
59
|
const current = constrainSize(size ?? local, minSize, maxSize);
|
|
@@ -115,6 +118,7 @@ var Resizable = (props) => {
|
|
|
115
118
|
"div",
|
|
116
119
|
{
|
|
117
120
|
id: firstId,
|
|
121
|
+
ref: firstRef,
|
|
118
122
|
className: "gridui-resizable-panel",
|
|
119
123
|
children: first
|
|
120
124
|
}
|
|
@@ -201,6 +205,7 @@ var Resizable = (props) => {
|
|
|
201
205
|
"div",
|
|
202
206
|
{
|
|
203
207
|
id: secondId,
|
|
208
|
+
ref: secondRef,
|
|
204
209
|
className: "gridui-resizable-panel",
|
|
205
210
|
children: second
|
|
206
211
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/resizable/size.ts", "../src/resizable/resizable.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Resizable\n * @namespace Resizable\n * @description Size\n */\n\nexport const constrainSize = (size: number, min: number, max: number): number => {\n if (!Number.isFinite(size) || !Number.isFinite(min) || !Number.isFinite(max) || min < 0 || max > 100 || min > max) {\n throw new RangeError(\"Resizable requires finite percentages and 0 <= minSize <= maxSize <= 100.\");\n }\n return Math.min(max, Math.max(min, size));\n};\n\nexport const pointerSize = (size: number, delta: number, extent: number, reverse: boolean, min: number, max: number): number => {\n return constrainSize(extent > 0 ? size + delta / extent * 100 * (reverse ? -1 : 1) : size, min, max);\n};\n\nexport const keyboardSize = (key: string, size: number, step: number, horizontal: boolean, reverse: boolean, min: number, max: number): number | null => {\n if (key === \"Home\") {\n return min;\n }\n if (key === \"End\") {\n return max;\n }\n const positive = horizontal ? \"ArrowRight\" : \"ArrowDown\";\n const negative = horizontal ? \"ArrowLeft\" : \"ArrowUp\";\n if (key !== positive && key !== negative) {\n return null;\n }\n return constrainSize(size + (key === positive ? 1 : -1) * (horizontal && reverse ? -1 : 1) * step, min, max);\n};\n", "/**\n * @author WMXPY\n * @package Resizable\n * @namespace Resizable\n * @description Resizable\n */\n\nimport { constrainSize, keyboardSize, pointerSize } from \"./size\";\nimport { isComposingKeyEvent, listenForDragCancellation } from \"@gridui/interaction\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type ComponentPropsWithRef, type FC, type ReactNode, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\n\nexport type ResizableProps = Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onChange\"> & {\n readonly first: ReactNode;\n readonly second: ReactNode;\n readonly label: string;\n readonly orientation?: \"horizontal\" | \"vertical\";\n readonly size?: number;\n readonly defaultSize?: number;\n readonly minSize?: number;\n readonly maxSize?: number;\n readonly step?: number;\n readonly disabled?: boolean;\n readonly onSizeChange?: (size: number) => void;\n};\n\ntype Drag = {\n readonly pointerId: number;\n readonly start: number;\n readonly size: number;\n readonly extent: number;\n readonly reverse: boolean;\n readonly horizontal: boolean;\n readonly element: HTMLDivElement;\n readonly cleanup: () => void;\n};\n\nexport const Resizable: FC<ResizableProps> = (props: ResizableProps) => {\n const { first, second, label, orientation = \"horizontal\", size, defaultSize = 50, minSize = 10, maxSize = 90,\n step = 1, disabled = false, onSizeChange, className, style, ...restProps } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultSize);\n const drag = useRef<Drag | null>(null);\n const separator = useRef<HTMLDivElement>(null);\n const firstId = useId();\n const secondId = useId();\n const current = constrainSize(size ?? local, minSize, maxSize);\n if (!Number.isFinite(step) || step <= 0) {\n throw new RangeError(\"Resizable step must be a positive finite percentage.\");\n }\n const horizontal = orientation === \"horizontal\";\n const update = (next: number) => {\n if (disabled) {\n return;\n }\n if (size === undefined) {\n setLocal(next);\n }\n if (next !== current) {\n onSizeChange?.(next);\n }\n };\n const cancel = () => {\n const active = drag.current;\n if (!active) {\n return;\n }\n drag.current = null;\n active.cleanup();\n const next = constrainSize(active.size, minSize, maxSize);\n if (size === undefined) {\n setLocal(next);\n }\n if (next !== current) {\n onSizeChange?.(next);\n }\n if (active.element.hasPointerCapture(active.pointerId)) {\n active.element.releasePointerCapture(active.pointerId);\n }\n };\n const cancelRef = useRef(cancel);\n cancelRef.current = cancel;\n useEffect(() => {\n return () => {\n cancelRef.current();\n };\n }, []);\n useLayoutEffect(() => {\n if (disabled || (drag.current && drag.current.horizontal !== horizontal)) {\n cancel();\n }\n });\n const tracks = `minmax(0, ${current}fr) var(--gridui-resizable-handle-size, 12px) minmax(0, ${100 - current}fr)`;\n return (<div\n {...restProps}\n className={cn(\"gridui-resizable\", className)}\n data-orientation={orientation}\n style={{\n ...style,\n ...(horizontal ? { gridTemplateColumns: tracks } : { gridTemplateRows: tracks }),\n }}\n >\n <div\n id={firstId}\n className=\"gridui-resizable-panel\"\n >\n {first}\n </div>\n <div\n ref={separator}\n role=\"separator\"\n aria-label={label}\n aria-controls={`${firstId} ${secondId}`}\n aria-orientation={horizontal ? \"vertical\" : \"horizontal\"}\n aria-valuemin={minSize}\n aria-valuemax={maxSize}\n aria-valuenow={Math.round(current * 100) / 100}\n aria-valuetext={`${Math.round(current)}%`}\n aria-disabled={disabled || undefined}\n tabIndex={disabled ? -1 : 0}\n className=\"gridui-resizable-handle\"\n onKeyDown={(event) => {\n if (disabled || event.defaultPrevented || isComposingKeyEvent(event.nativeEvent)) {\n return;\n }\n const reverse = getComputedStyle(event.currentTarget).direction === \"rtl\";\n const next = keyboardSize(event.key, current, step * (event.shiftKey ? 10 : 1), horizontal, reverse, minSize, maxSize);\n if (next !== null) {\n event.preventDefault();\n update(next);\n }\n }}\n onPointerDown={(event) => {\n if (disabled || event.button !== 0 || !event.isPrimary || drag.current) {\n return;\n }\n const handle = event.currentTarget;\n const bounds = handle.parentElement?.getBoundingClientRect();\n if (!bounds) {\n return;\n }\n const handleBounds = handle.getBoundingClientRect();\n drag.current = {\n pointerId: event.pointerId,\n start: horizontal ? event.clientX : event.clientY,\n size: current,\n extent: horizontal ? bounds.width - handleBounds.width : bounds.height - handleBounds.height,\n reverse: horizontal && getComputedStyle(handle).direction === \"rtl\",\n horizontal,\n element: handle,\n cleanup: listenForDragCancellation(handle, () => {\n cancelRef.current();\n }),\n };\n handle.focus();\n handle.setPointerCapture(event.pointerId);\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n const active = drag.current;\n if (!active || active.pointerId !== event.pointerId) {\n return;\n }\n const coordinate = horizontal ? event.clientX : event.clientY;\n update(pointerSize(active.size, coordinate - active.start, active.extent, active.reverse, minSize, maxSize));\n }}\n onPointerUp={(event) => {\n if (drag.current?.pointerId === event.pointerId) {\n const active = drag.current;\n drag.current = null;\n active.cleanup();\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n }\n }}\n onPointerCancel={(event) => {\n if (drag.current?.pointerId === event.pointerId) {\n cancel();\n }\n }}\n onLostPointerCapture={cancel}\n />\n <div\n id={secondId}\n className=\"gridui-resizable-panel\"\n >\n {second}\n </div>\n </div>);\n};\n"],
|
|
5
|
-
"mappings": ";AAOO,IAAM,gBAAgB,CAAC,MAAc,KAAa,QAAwB;AAC7E,MAAI,CAAC,OAAO,SAAS,IAAI,KAAK,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,GAAG,KAAK,MAAM,KAAK,MAAM,OAAO,MAAM,KAAK;AAC/G,UAAM,IAAI,WAAW,2EAA2E;AAAA,EACpG;AACA,SAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;AAC5C;AAEO,IAAM,cAAc,CAAC,MAAc,OAAe,QAAgB,SAAkB,KAAa,QAAwB;AAC5H,SAAO,cAAc,SAAS,IAAI,OAAO,QAAQ,SAAS,OAAO,UAAU,KAAK,KAAK,MAAM,KAAK,GAAG;AACvG;AAEO,IAAM,eAAe,CAAC,KAAa,MAAc,MAAc,YAAqB,SAAkB,KAAa,QAA+B;AACrJ,MAAI,QAAQ,QAAQ;AAChB,WAAO;AAAA,EACX;AACA,MAAI,QAAQ,OAAO;AACf,WAAO;AAAA,EACX;AACA,QAAM,WAAW,aAAa,eAAe;AAC7C,QAAM,WAAW,aAAa,cAAc;AAC5C,MAAI,QAAQ,YAAY,QAAQ,UAAU;AACtC,WAAO;AAAA,EACX;AACA,SAAO,cAAc,QAAQ,QAAQ,WAAW,IAAI,OAAO,cAAc,UAAU,KAAK,KAAK,MAAM,KAAK,GAAG;AAC/G;;;ACvBA,SAAS,qBAAqB,iCAAiC;AAC/D,SAAS,UAAU;AACnB,SAA8D,WAAW,OAAO,iBAAiB,QAAQ,gBAAgB;
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Resizable\n * @namespace Resizable\n * @description Size\n */\n\nexport const constrainSize = (size: number, min: number, max: number): number => {\n if (!Number.isFinite(size) || !Number.isFinite(min) || !Number.isFinite(max) || min < 0 || max > 100 || min > max) {\n throw new RangeError(\"Resizable requires finite percentages and 0 <= minSize <= maxSize <= 100.\");\n }\n return Math.min(max, Math.max(min, size));\n};\n\nexport const pointerSize = (size: number, delta: number, extent: number, reverse: boolean, min: number, max: number): number => {\n return constrainSize(extent > 0 ? size + delta / extent * 100 * (reverse ? -1 : 1) : size, min, max);\n};\n\nexport const keyboardSize = (key: string, size: number, step: number, horizontal: boolean, reverse: boolean, min: number, max: number): number | null => {\n if (key === \"Home\") {\n return min;\n }\n if (key === \"End\") {\n return max;\n }\n const positive = horizontal ? \"ArrowRight\" : \"ArrowDown\";\n const negative = horizontal ? \"ArrowLeft\" : \"ArrowUp\";\n if (key !== positive && key !== negative) {\n return null;\n }\n return constrainSize(size + (key === positive ? 1 : -1) * (horizontal && reverse ? -1 : 1) * step, min, max);\n};\n", "/**\n * @author WMXPY\n * @package Resizable\n * @namespace Resizable\n * @description Resizable\n */\n\nimport { constrainSize, keyboardSize, pointerSize } from \"./size\";\nimport { isComposingKeyEvent, listenForDragCancellation } from \"@gridui/interaction\";\nimport { useInteractionOutline } from \"@gridui/overlay\";\nimport { cn } from \"@gridui/style-utils\";\nimport { type ComponentPropsWithRef, type FC, type ReactNode, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\n\nexport type ResizableProps = Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onChange\"> & {\n readonly first: ReactNode;\n readonly second: ReactNode;\n readonly label: string;\n readonly orientation?: \"horizontal\" | \"vertical\";\n readonly size?: number;\n readonly defaultSize?: number;\n readonly minSize?: number;\n readonly maxSize?: number;\n readonly step?: number;\n readonly disabled?: boolean;\n readonly onSizeChange?: (size: number) => void;\n};\n\ntype Drag = {\n readonly pointerId: number;\n readonly start: number;\n readonly size: number;\n readonly extent: number;\n readonly reverse: boolean;\n readonly horizontal: boolean;\n readonly element: HTMLDivElement;\n readonly cleanup: () => void;\n};\n\nexport const Resizable: FC<ResizableProps> = (props: ResizableProps) => {\n const { first, second, label, orientation = \"horizontal\", size, defaultSize = 50, minSize = 10, maxSize = 90,\n step = 1, disabled = false, onSizeChange, className, style, ...restProps } = props;\n const [\n local,\n setLocal,\n ] = useState(defaultSize);\n const drag = useRef<Drag | null>(null);\n const separator = useRef<HTMLDivElement>(null);\n const firstRef = useInteractionOutline<HTMLDivElement>({});\n const secondRef = useInteractionOutline<HTMLDivElement>({});\n const firstId = useId();\n const secondId = useId();\n const current = constrainSize(size ?? local, minSize, maxSize);\n if (!Number.isFinite(step) || step <= 0) {\n throw new RangeError(\"Resizable step must be a positive finite percentage.\");\n }\n const horizontal = orientation === \"horizontal\";\n const update = (next: number) => {\n if (disabled) {\n return;\n }\n if (size === undefined) {\n setLocal(next);\n }\n if (next !== current) {\n onSizeChange?.(next);\n }\n };\n const cancel = () => {\n const active = drag.current;\n if (!active) {\n return;\n }\n drag.current = null;\n active.cleanup();\n const next = constrainSize(active.size, minSize, maxSize);\n if (size === undefined) {\n setLocal(next);\n }\n if (next !== current) {\n onSizeChange?.(next);\n }\n if (active.element.hasPointerCapture(active.pointerId)) {\n active.element.releasePointerCapture(active.pointerId);\n }\n };\n const cancelRef = useRef(cancel);\n cancelRef.current = cancel;\n useEffect(() => {\n return () => {\n cancelRef.current();\n };\n }, []);\n useLayoutEffect(() => {\n if (disabled || (drag.current && drag.current.horizontal !== horizontal)) {\n cancel();\n }\n });\n const tracks = `minmax(0, ${current}fr) var(--gridui-resizable-handle-size, 12px) minmax(0, ${100 - current}fr)`;\n return (<div\n {...restProps}\n className={cn(\"gridui-resizable\", className)}\n data-orientation={orientation}\n style={{\n ...style,\n ...(horizontal ? { gridTemplateColumns: tracks } : { gridTemplateRows: tracks }),\n }}\n >\n <div\n id={firstId}\n ref={firstRef}\n className=\"gridui-resizable-panel\"\n >\n {first}\n </div>\n <div\n ref={separator}\n role=\"separator\"\n aria-label={label}\n aria-controls={`${firstId} ${secondId}`}\n aria-orientation={horizontal ? \"vertical\" : \"horizontal\"}\n aria-valuemin={minSize}\n aria-valuemax={maxSize}\n aria-valuenow={Math.round(current * 100) / 100}\n aria-valuetext={`${Math.round(current)}%`}\n aria-disabled={disabled || undefined}\n tabIndex={disabled ? -1 : 0}\n className=\"gridui-resizable-handle\"\n onKeyDown={(event) => {\n if (disabled || event.defaultPrevented || isComposingKeyEvent(event.nativeEvent)) {\n return;\n }\n const reverse = getComputedStyle(event.currentTarget).direction === \"rtl\";\n const next = keyboardSize(event.key, current, step * (event.shiftKey ? 10 : 1), horizontal, reverse, minSize, maxSize);\n if (next !== null) {\n event.preventDefault();\n update(next);\n }\n }}\n onPointerDown={(event) => {\n if (disabled || event.button !== 0 || !event.isPrimary || drag.current) {\n return;\n }\n const handle = event.currentTarget;\n const bounds = handle.parentElement?.getBoundingClientRect();\n if (!bounds) {\n return;\n }\n const handleBounds = handle.getBoundingClientRect();\n drag.current = {\n pointerId: event.pointerId,\n start: horizontal ? event.clientX : event.clientY,\n size: current,\n extent: horizontal ? bounds.width - handleBounds.width : bounds.height - handleBounds.height,\n reverse: horizontal && getComputedStyle(handle).direction === \"rtl\",\n horizontal,\n element: handle,\n cleanup: listenForDragCancellation(handle, () => {\n cancelRef.current();\n }),\n };\n handle.focus();\n handle.setPointerCapture(event.pointerId);\n event.preventDefault();\n }}\n onPointerMove={(event) => {\n const active = drag.current;\n if (!active || active.pointerId !== event.pointerId) {\n return;\n }\n const coordinate = horizontal ? event.clientX : event.clientY;\n update(pointerSize(active.size, coordinate - active.start, active.extent, active.reverse, minSize, maxSize));\n }}\n onPointerUp={(event) => {\n if (drag.current?.pointerId === event.pointerId) {\n const active = drag.current;\n drag.current = null;\n active.cleanup();\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n }\n }}\n onPointerCancel={(event) => {\n if (drag.current?.pointerId === event.pointerId) {\n cancel();\n }\n }}\n onLostPointerCapture={cancel}\n />\n <div\n id={secondId}\n ref={secondRef}\n className=\"gridui-resizable-panel\"\n >\n {second}\n </div>\n </div>);\n};\n"],
|
|
5
|
+
"mappings": ";AAOO,IAAM,gBAAgB,CAAC,MAAc,KAAa,QAAwB;AAC7E,MAAI,CAAC,OAAO,SAAS,IAAI,KAAK,CAAC,OAAO,SAAS,GAAG,KAAK,CAAC,OAAO,SAAS,GAAG,KAAK,MAAM,KAAK,MAAM,OAAO,MAAM,KAAK;AAC/G,UAAM,IAAI,WAAW,2EAA2E;AAAA,EACpG;AACA,SAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;AAC5C;AAEO,IAAM,cAAc,CAAC,MAAc,OAAe,QAAgB,SAAkB,KAAa,QAAwB;AAC5H,SAAO,cAAc,SAAS,IAAI,OAAO,QAAQ,SAAS,OAAO,UAAU,KAAK,KAAK,MAAM,KAAK,GAAG;AACvG;AAEO,IAAM,eAAe,CAAC,KAAa,MAAc,MAAc,YAAqB,SAAkB,KAAa,QAA+B;AACrJ,MAAI,QAAQ,QAAQ;AAChB,WAAO;AAAA,EACX;AACA,MAAI,QAAQ,OAAO;AACf,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oBAAM,eAAe;AAAA,YACzB;AAAA,YACA,eAAe,CAAC,UAAU;AACtB,oBAAM,SAAS,KAAK;AACpB,kBAAI,CAAC,UAAU,OAAO,cAAc,MAAM,WAAW;AACjD;AAAA,cACJ;AACA,oBAAM,aAAa,aAAa,MAAM,UAAU,MAAM;AACtD,qBAAO,YAAY,OAAO,MAAM,aAAa,OAAO,OAAO,OAAO,QAAQ,OAAO,SAAS,SAAS,OAAO,CAAC;AAAA,YAC/G;AAAA,YACA,aAAa,CAAC,UAAU;AACpB,kBAAI,KAAK,SAAS,cAAc,MAAM,WAAW;AAC7C,sBAAM,SAAS,KAAK;AACpB,qBAAK,UAAU;AACf,uBAAO,QAAQ;AACf,oBAAI,MAAM,cAAc,kBAAkB,MAAM,SAAS,GAAG;AACxD,wBAAM,cAAc,sBAAsB,MAAM,SAAS;AAAA,gBAC7D;AAAA,cACJ;AAAA,YACJ;AAAA,YACA,iBAAiB,CAAC,UAAU;AACxB,kBAAI,KAAK,SAAS,cAAc,MAAM,WAAW;AAC7C,uBAAO;AAAA,cACX;AAAA,YACJ;AAAA,YACA,sBAAsB;AAAA;AAAA,QAC1B;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACG,IAAI;AAAA,YACJ,KAAK;AAAA,YACL,WAAU;AAAA,YAET;AAAA;AAAA,QACL;AAAA;AAAA;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/styles.css
CHANGED
package/docs/catalog.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/resizable",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"category": "layout",
|
|
6
6
|
"description": "GridUI React resizable",
|
|
7
7
|
"usage": "Two independently scrolling regions separated by a keyboard and pointer resizer. Resizable owns its separator; surrounding Grid regions continue to own outer seams.",
|
|
8
8
|
"documentation": [
|
|
9
|
-
"README.md"
|
|
9
|
+
"README.md",
|
|
10
|
+
"docs/reference/README.md",
|
|
11
|
+
"docs/reference/resizable.md"
|
|
10
12
|
],
|
|
11
13
|
"exports": [
|
|
12
14
|
{
|
|
@@ -22,9 +24,11 @@
|
|
|
22
24
|
],
|
|
23
25
|
"styles": [
|
|
24
26
|
"@gridui/theme/styles.css",
|
|
27
|
+
"@gridui/overlay/styles.css",
|
|
25
28
|
"@gridui/resizable/styles.css"
|
|
26
29
|
],
|
|
27
30
|
"examples": [
|
|
31
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-layout/resizable/stories/regions.mdx",
|
|
28
32
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-layout/resizable/stories/resizable.stories.tsx"
|
|
29
33
|
]
|
|
30
34
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# Resizable
|
|
3
|
+
|
|
4
|
+
Divides content into two panels with a movable separator. Use it when users need to adjust how much space each panel receives.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/resizable`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { Resizable } from "@gridui/resizable";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/resizable/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-layout/resizable/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-layout/resizable/stories/resizable.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### onFocus
|
|
23
|
+
|
|
24
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
25
|
+
|
|
26
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
27
|
+
|
|
28
|
+
### onBlur
|
|
29
|
+
|
|
30
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
31
|
+
|
|
32
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
33
|
+
|
|
34
|
+
### onSubmit
|
|
35
|
+
|
|
36
|
+
``(event: SubmitEvent<HTMLDivElement>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onClick
|
|
41
|
+
|
|
42
|
+
``(event: MouseEvent<HTMLDivElement, MouseEvent>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### first
|
|
47
|
+
|
|
48
|
+
``ReactNode`` · Required
|
|
49
|
+
|
|
50
|
+
### second
|
|
51
|
+
|
|
52
|
+
``ReactNode`` · Required
|
|
53
|
+
|
|
54
|
+
### label
|
|
55
|
+
|
|
56
|
+
``string`` · Required
|
|
57
|
+
|
|
58
|
+
### orientation
|
|
59
|
+
|
|
60
|
+
``"vertical" | "horizontal" | undefined`` · Optional
|
|
61
|
+
|
|
62
|
+
Default: ``"horizontal"``
|
|
63
|
+
|
|
64
|
+
### size
|
|
65
|
+
|
|
66
|
+
``number | undefined`` · Optional
|
|
67
|
+
|
|
68
|
+
Component size preset.
|
|
69
|
+
|
|
70
|
+
### defaultSize
|
|
71
|
+
|
|
72
|
+
``number | undefined`` · Optional
|
|
73
|
+
|
|
74
|
+
Default: ``50``
|
|
75
|
+
|
|
76
|
+
### minSize
|
|
77
|
+
|
|
78
|
+
``number | undefined`` · Optional
|
|
79
|
+
|
|
80
|
+
Default: ``10``
|
|
81
|
+
|
|
82
|
+
### maxSize
|
|
83
|
+
|
|
84
|
+
``number | undefined`` · Optional
|
|
85
|
+
|
|
86
|
+
Default: ``90``
|
|
87
|
+
|
|
88
|
+
### step
|
|
89
|
+
|
|
90
|
+
``number | undefined`` · Optional
|
|
91
|
+
|
|
92
|
+
Default: ``1``
|
|
93
|
+
|
|
94
|
+
### disabled
|
|
95
|
+
|
|
96
|
+
``boolean | undefined`` · Optional
|
|
97
|
+
|
|
98
|
+
Default: ``false``
|
|
99
|
+
|
|
100
|
+
Prevents interaction when enabled.
|
|
101
|
+
|
|
102
|
+
### onSizeChange
|
|
103
|
+
|
|
104
|
+
``(size: number): void`` · Optional
|
|
105
|
+
|
|
106
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
107
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/resizable",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "GridUI React resizable",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@gridui/interaction": "^1.2.1",
|
|
31
|
-
"@gridui/
|
|
31
|
+
"@gridui/overlay": "^2.0.0",
|
|
32
|
+
"@gridui/style-utils": "^4.0.0",
|
|
32
33
|
"@gridui/theme": "^2.5.3"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|