@dxos/react-ui-dnd 0.7.5-labs.c0e040f

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/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ MIT License
2
+ Copyright (c) 2025 DXOS
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @dxos/react-ui-dnd
2
+
3
+ Drag and drop components.
@@ -0,0 +1,124 @@
1
+ // packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx
2
+ import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
3
+ import { disableNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview";
4
+ import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
5
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
6
+ import React, { useLayoutEffect, useRef } from "react";
7
+ import { mx } from "@dxos/react-ui-theme";
8
+
9
+ // packages/ui/react-ui-dnd/src/util/sizeStyle.ts
10
+ var sizeStyle = (size, sideOrOrientation) => {
11
+ switch (sideOrOrientation) {
12
+ case "horizontal":
13
+ case "inline-start":
14
+ case "inline-end":
15
+ return {
16
+ inlineSize: size === "min-content" ? size : `${size}rem`
17
+ };
18
+ case "vertical":
19
+ case "block-start":
20
+ case "block-end":
21
+ return {
22
+ blockSize: size === "min-content" ? size : `${size}rem`
23
+ };
24
+ }
25
+ };
26
+
27
+ // packages/ui/react-ui-dnd/src/util/rem.ts
28
+ var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
29
+
30
+ // packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx
31
+ var measureSubject = (element, fallbackSize) => {
32
+ const stackItemElement = element.closest("[data-dx-resize-subject]");
33
+ return stackItemElement?.getBoundingClientRect() ?? {
34
+ width: fallbackSize,
35
+ height: fallbackSize
36
+ };
37
+ };
38
+ var getNextSize = (startSize, location, client, side, minSize, maxSize) => {
39
+ return Math.min(maxSize ?? Infinity, Math.max(minSize, startSize + (location.current.input[client] - location.initial.input[client]) / REM * (side.endsWith("end") ? 1 : -1)));
40
+ };
41
+ var resizeAttributes = {
42
+ "data-dx-resize-subject": true
43
+ };
44
+ var ResizeHandle = ({ classNames, side, iconPosition = "start", defaultSize, fallbackSize, size: propsSize, minSize, maxSize, onSizeChange }) => {
45
+ const buttonRef = useRef(null);
46
+ const [size = "min-content", setSize] = useControllableState({
47
+ prop: propsSize,
48
+ defaultProp: defaultSize,
49
+ onChange: onSizeChange
50
+ });
51
+ const dragStartSize = useRef(size);
52
+ const orientation = side.startsWith("inline") ? "horizontal" : "vertical";
53
+ const client = orientation === "horizontal" ? "clientX" : "clientY";
54
+ useLayoutEffect(() => {
55
+ if (!buttonRef.current) {
56
+ return;
57
+ }
58
+ return draggable({
59
+ element: buttonRef.current,
60
+ onGenerateDragPreview: ({ nativeSetDragImage }) => {
61
+ disableNativeDragPreview({
62
+ nativeSetDragImage
63
+ });
64
+ preventUnhandled.start();
65
+ },
66
+ onDragStart: () => {
67
+ dragStartSize.current = dragStartSize.current === "min-content" ? measureSubject(buttonRef.current, fallbackSize)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
68
+ },
69
+ onDrag: ({ location }) => {
70
+ if (typeof dragStartSize.current !== "number") {
71
+ return;
72
+ }
73
+ setSize(getNextSize(dragStartSize.current, location, client, side, minSize, maxSize));
74
+ },
75
+ onDrop: ({ location }) => {
76
+ if (typeof dragStartSize.current !== "number") {
77
+ return;
78
+ }
79
+ const nextSize = getNextSize(dragStartSize.current, location, client, side, minSize, maxSize);
80
+ setSize(nextSize);
81
+ onSizeChange?.(nextSize, true);
82
+ dragStartSize.current = nextSize;
83
+ }
84
+ });
85
+ }, [
86
+ // Note that `size` should not be a dependency here since dragging this adjusts the size.
87
+ minSize,
88
+ maxSize
89
+ ]);
90
+ return /* @__PURE__ */ React.createElement("button", {
91
+ ref: buttonRef,
92
+ "data-side": side,
93
+ className: mx("group absolute flex focus-visible:outline-none", orientation === "horizontal" ? 'cursor-col-resize is-4 inset-block-0 data-[side="inline-end"]:inline-end-0 data-[side="inline-end"]:before:inline-end-0 data-[side="inline-start"]:inline-start-0 data-[side="inline-start"]:before:inline-start-0 !border-lb-0 before:inset-block-0 before:is-1' : 'cursor-row-resize bs-4 inset-inline-0 data-[side="block-end"]:block-end-0 data-[side="block-end"]:before:block-end-0 data-[side="block-start"]:block-start-0 data-[side="block-start"]:before:block-start-0 !border-li-0 before:inset-inline-0 before:bs-1', orientation === "horizontal" ? iconPosition === "end" ? "align-end" : iconPosition === "center" ? "align-center" : "align-start" : iconPosition === "end" ? "justify-end" : iconPosition === "center" ? "justify-center" : "justify-start", "before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100", "before:absolute before:block before:bg-accentFocusIndicator", classNames)
94
+ }, /* @__PURE__ */ React.createElement("div", {
95
+ role: "none",
96
+ "data-side": side,
97
+ className: mx("grid place-items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0", orientation === "horizontal" ? "bs-[--rail-size] is-4" : "is-[--rail-size] bs-4")
98
+ }, /* @__PURE__ */ React.createElement(DragHandleSignifier, {
99
+ side
100
+ })));
101
+ };
102
+ var DragHandleSignifier = ({ side }) => {
103
+ return /* @__PURE__ */ React.createElement("svg", {
104
+ xmlns: "http://www.w3.org/2000/svg",
105
+ viewBox: "0 0 256 256",
106
+ fill: "currentColor",
107
+ className: mx("shrink-0 bs-4 is-4 text-unAccent", side === "block-end" ? "rotate-90" : side === "block-start" ? "-rotate-90" : side === "inline-start" && "rotate-180")
108
+ }, /* @__PURE__ */ React.createElement("path", {
109
+ d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
110
+ }), /* @__PURE__ */ React.createElement("path", {
111
+ d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
112
+ }), /* @__PURE__ */ React.createElement("path", {
113
+ d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
114
+ }), /* @__PURE__ */ React.createElement("path", {
115
+ d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
116
+ }));
117
+ };
118
+ export {
119
+ REM,
120
+ ResizeHandle,
121
+ resizeAttributes,
122
+ sizeStyle
123
+ };
124
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ResizeHandle.tsx", "../../../src/util/sizeStyle.ts", "../../../src/util/rem.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';\nimport { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';\nimport { type DragLocationHistory } from '@atlaskit/pragmatic-drag-and-drop/types';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { useLayoutEffect, useRef } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type Size, type Side } from '../types';\nimport { REM } from '../util';\n\nconst measureSubject = (element: HTMLButtonElement, fallbackSize: number): { width: number; height: number } => {\n const stackItemElement = element.closest('[data-dx-resize-subject]');\n return stackItemElement?.getBoundingClientRect() ?? { width: fallbackSize, height: fallbackSize };\n};\n\nconst getNextSize = (\n startSize: number,\n location: DragLocationHistory,\n client: 'clientX' | 'clientY',\n side: Side,\n minSize: number,\n maxSize: number | undefined,\n) => {\n return Math.min(\n maxSize ?? Infinity,\n Math.max(\n minSize,\n startSize +\n ((location.current.input[client] - location.initial.input[client]) / REM) * (side.endsWith('end') ? 1 : -1),\n ),\n );\n};\n\nexport const resizeAttributes = {\n 'data-dx-resize-subject': true,\n};\n\nexport type ResizeHandleProps = ThemedClassName<{\n side: Side;\n defaultSize?: Size;\n fallbackSize: number;\n size?: Size;\n minSize: number;\n maxSize?: number;\n unit?: 'rem';\n iconPosition?: 'start' | 'center' | 'end';\n onSizeChange?: (nextSize: Size, commit?: boolean) => void;\n}>;\n\nexport const ResizeHandle = ({\n classNames,\n side,\n iconPosition = 'start',\n defaultSize,\n fallbackSize,\n size: propsSize,\n minSize,\n maxSize,\n onSizeChange,\n}: ResizeHandleProps) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [size = 'min-content', setSize] = useControllableState({\n prop: propsSize,\n defaultProp: defaultSize,\n onChange: onSizeChange,\n });\n const dragStartSize = useRef<Size>(size);\n\n const orientation = side.startsWith('inline') ? 'horizontal' : 'vertical';\n const client = orientation === 'horizontal' ? 'clientX' : 'clientY';\n\n useLayoutEffect(() => {\n if (!buttonRef.current) {\n return;\n }\n\n // TODO(thure): This should handle StackItem state vs local state better.\n return draggable({\n element: buttonRef.current,\n onGenerateDragPreview: ({ nativeSetDragImage }) => {\n // We will be moving the line to indicate a drag; we can disable the native drag preview.\n disableNativeDragPreview({ nativeSetDragImage });\n // We don't want any native drop animation for when the user does not drop on a drop target.\n // We want the drag to finish immediately.\n preventUnhandled.start();\n },\n onDragStart: () => {\n dragStartSize.current =\n dragStartSize.current === 'min-content'\n ? measureSubject(buttonRef.current!, fallbackSize)[orientation === 'horizontal' ? 'width' : 'height'] / REM\n : dragStartSize.current;\n },\n onDrag: ({ location }) => {\n if (typeof dragStartSize.current !== 'number') {\n return;\n }\n setSize(getNextSize(dragStartSize.current, location, client, side, minSize, maxSize));\n },\n onDrop: ({ location }) => {\n if (typeof dragStartSize.current !== 'number') {\n return;\n }\n const nextSize = getNextSize(dragStartSize.current, location, client, side, minSize, maxSize);\n setSize(nextSize);\n onSizeChange?.(nextSize, true);\n dragStartSize.current = nextSize;\n },\n });\n }, [\n // Note that `size` should not be a dependency here since dragging this adjusts the size.\n minSize,\n maxSize,\n ]);\n\n return (\n <button\n ref={buttonRef}\n data-side={side}\n className={mx(\n 'group absolute flex focus-visible:outline-none',\n orientation === 'horizontal'\n ? 'cursor-col-resize is-4 inset-block-0 data-[side=\"inline-end\"]:inline-end-0 data-[side=\"inline-end\"]:before:inline-end-0 data-[side=\"inline-start\"]:inline-start-0 data-[side=\"inline-start\"]:before:inline-start-0 !border-lb-0 before:inset-block-0 before:is-1'\n : 'cursor-row-resize bs-4 inset-inline-0 data-[side=\"block-end\"]:block-end-0 data-[side=\"block-end\"]:before:block-end-0 data-[side=\"block-start\"]:block-start-0 data-[side=\"block-start\"]:before:block-start-0 !border-li-0 before:inset-inline-0 before:bs-1',\n orientation === 'horizontal'\n ? iconPosition === 'end'\n ? 'align-end'\n : iconPosition === 'center'\n ? 'align-center'\n : 'align-start'\n : iconPosition === 'end'\n ? 'justify-end'\n : iconPosition === 'center'\n ? 'justify-center'\n : 'justify-start',\n 'before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100',\n 'before:absolute before:block before:bg-accentFocusIndicator',\n classNames,\n )}\n >\n <div\n role='none'\n data-side={side}\n className={mx(\n 'grid place-items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0',\n orientation === 'horizontal' ? 'bs-[--rail-size] is-4' : 'is-[--rail-size] bs-4',\n )}\n >\n <DragHandleSignifier side={side} />\n </div>\n </button>\n );\n};\n\nconst DragHandleSignifier = ({ side }: Pick<ResizeHandleProps, 'side'>) => {\n return (\n <svg\n xmlns='http://www.w3.org/2000/svg'\n viewBox='0 0 256 256'\n fill='currentColor'\n className={mx(\n 'shrink-0 bs-4 is-4 text-unAccent',\n side === 'block-end'\n ? 'rotate-90'\n : side === 'block-start'\n ? '-rotate-90'\n : side === 'inline-start' && 'rotate-180',\n )}\n >\n {/* two pips: <path d='M256,120c-8.8,0-16-7.2-16-16v-56c0-8.8,7.2-16,16-16v88Z' />\n <path d='M256,232c-8.8,0-16-7.2-16-16v-56c0-8.8,7.2-16,16-16v88Z' /> */}\n <path d='M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n </svg>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ResizeHandleProps } from '../components';\nimport { type Size } from '../types';\n\nexport const sizeStyle = (size: Size, sideOrOrientation: ResizeHandleProps['side'] | 'horizontal' | 'vertical') => {\n switch (sideOrOrientation) {\n case 'horizontal':\n case 'inline-start':\n case 'inline-end':\n return { inlineSize: size === 'min-content' ? size : `${size}rem` };\n case 'vertical':\n case 'block-start':\n case 'block-end':\n return { blockSize: size === 'min-content' ? size : `${size}rem` };\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport const REM = parseFloat(getComputedStyle(document.documentElement).fontSize);\n"],
5
+ "mappings": ";AAIA,SAASA,iBAAiB;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IACCC,MAAK;IACLJ,aAAW3C;IACX4C,WAAWC,GACT,sGACAjB,gBAAgB,eAAe,0BAA0B,uBAAA;KAG3D,sBAAA,cAACoB,qBAAAA;IAAoBhD;;AAI7B;AAEA,IAAMgD,sBAAsB,CAAC,EAAEhD,KAAI,MAAmC;AACpE,SACE,sBAAA,cAACiD,OAAAA;IACCC,OAAM;IACNC,SAAQ;IACRC,MAAK;IACLR,WAAWC,GACT,oCACA7C,SAAS,cACL,cACAA,SAAS,gBACP,eACAA,SAAS,kBAAkB,YAAA;KAKnC,sBAAA,cAACqD,QAAAA;IAAKC,GAAE;MACR,sBAAA,cAACD,QAAAA;IAAKC,GAAE;MACR,sBAAA,cAACD,QAAAA;IAAKC,GAAE;MACR,sBAAA,cAACD,QAAAA;IAAKC,GAAE;;AAGd;",
6
+ "names": ["draggable", "disableNativeDragPreview", "preventUnhandled", "useControllableState", "React", "useLayoutEffect", "useRef", "mx", "sizeStyle", "size", "sideOrOrientation", "inlineSize", "blockSize", "REM", "parseFloat", "getComputedStyle", "document", "documentElement", "fontSize", "measureSubject", "element", "fallbackSize", "stackItemElement", "closest", "getBoundingClientRect", "width", "height", "getNextSize", "startSize", "location", "client", "side", "minSize", "maxSize", "Math", "min", "Infinity", "max", "current", "input", "initial", "REM", "endsWith", "resizeAttributes", "ResizeHandle", "classNames", "iconPosition", "defaultSize", "size", "propsSize", "onSizeChange", "buttonRef", "useRef", "setSize", "useControllableState", "prop", "defaultProp", "onChange", "dragStartSize", "orientation", "startsWith", "useLayoutEffect", "draggable", "onGenerateDragPreview", "nativeSetDragImage", "disableNativeDragPreview", "preventUnhandled", "start", "onDragStart", "onDrag", "onDrop", "nextSize", "button", "ref", "data-side", "className", "mx", "div", "role", "DragHandleSignifier", "svg", "xmlns", "viewBox", "fill", "path", "d"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"packages/ui/react-ui-dnd/src/util/sizeStyle.ts":{"bytes":2090,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/util/rem.ts":{"bytes":795,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/util/index.ts":{"bytes":581,"imports":[{"path":"packages/ui/react-ui-dnd/src/util/sizeStyle.ts","kind":"import-statement","original":"./sizeStyle"},{"path":"packages/ui/react-ui-dnd/src/util/rem.ts","kind":"import-statement","original":"./rem"}],"format":"esm"},"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx":{"bytes":19857,"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/prevent-unhandled","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-dnd/src/util/index.ts","kind":"import-statement","original":"../util"}],"format":"esm"},"packages/ui/react-ui-dnd/src/components/index.ts":{"bytes":519,"imports":[{"path":"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx","kind":"import-statement","original":"./ResizeHandle"}],"format":"esm"},"packages/ui/react-ui-dnd/src/types.ts":{"bytes":604,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/index.ts":{"bytes":663,"imports":[{"path":"packages/ui/react-ui-dnd/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/ui/react-ui-dnd/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/ui/react-ui-dnd/src/util/index.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-dnd/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":11473},"packages/ui/react-ui-dnd/dist/lib/browser/index.mjs":{"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/prevent-unhandled","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"exports":["REM","ResizeHandle","resizeAttributes","sizeStyle"],"entryPoint":"packages/ui/react-ui-dnd/src/index.ts","inputs":{"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx":{"bytesInOutput":5153},"packages/ui/react-ui-dnd/src/util/sizeStyle.ts":{"bytesInOutput":400},"packages/ui/react-ui-dnd/src/util/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-dnd/src/util/rem.ts":{"bytesInOutput":75},"packages/ui/react-ui-dnd/src/components/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-dnd/src/index.ts":{"bytesInOutput":0}},"bytes":5947}}}
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var node_exports = {};
30
+ __export(node_exports, {
31
+ REM: () => REM,
32
+ ResizeHandle: () => ResizeHandle,
33
+ resizeAttributes: () => resizeAttributes,
34
+ sizeStyle: () => sizeStyle
35
+ });
36
+ module.exports = __toCommonJS(node_exports);
37
+ var import_adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
38
+ var import_disable_native_drag_preview = require("@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview");
39
+ var import_prevent_unhandled = require("@atlaskit/pragmatic-drag-and-drop/prevent-unhandled");
40
+ var import_react_use_controllable_state = require("@radix-ui/react-use-controllable-state");
41
+ var import_react = __toESM(require("react"));
42
+ var import_react_ui_theme = require("@dxos/react-ui-theme");
43
+ var sizeStyle = (size, sideOrOrientation) => {
44
+ switch (sideOrOrientation) {
45
+ case "horizontal":
46
+ case "inline-start":
47
+ case "inline-end":
48
+ return {
49
+ inlineSize: size === "min-content" ? size : `${size}rem`
50
+ };
51
+ case "vertical":
52
+ case "block-start":
53
+ case "block-end":
54
+ return {
55
+ blockSize: size === "min-content" ? size : `${size}rem`
56
+ };
57
+ }
58
+ };
59
+ var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
60
+ var measureSubject = (element, fallbackSize) => {
61
+ const stackItemElement = element.closest("[data-dx-resize-subject]");
62
+ return stackItemElement?.getBoundingClientRect() ?? {
63
+ width: fallbackSize,
64
+ height: fallbackSize
65
+ };
66
+ };
67
+ var getNextSize = (startSize, location, client, side, minSize, maxSize) => {
68
+ return Math.min(maxSize ?? Infinity, Math.max(minSize, startSize + (location.current.input[client] - location.initial.input[client]) / REM * (side.endsWith("end") ? 1 : -1)));
69
+ };
70
+ var resizeAttributes = {
71
+ "data-dx-resize-subject": true
72
+ };
73
+ var ResizeHandle = ({ classNames, side, iconPosition = "start", defaultSize, fallbackSize, size: propsSize, minSize, maxSize, onSizeChange }) => {
74
+ const buttonRef = (0, import_react.useRef)(null);
75
+ const [size = "min-content", setSize] = (0, import_react_use_controllable_state.useControllableState)({
76
+ prop: propsSize,
77
+ defaultProp: defaultSize,
78
+ onChange: onSizeChange
79
+ });
80
+ const dragStartSize = (0, import_react.useRef)(size);
81
+ const orientation = side.startsWith("inline") ? "horizontal" : "vertical";
82
+ const client = orientation === "horizontal" ? "clientX" : "clientY";
83
+ (0, import_react.useLayoutEffect)(() => {
84
+ if (!buttonRef.current) {
85
+ return;
86
+ }
87
+ return (0, import_adapter.draggable)({
88
+ element: buttonRef.current,
89
+ onGenerateDragPreview: ({ nativeSetDragImage }) => {
90
+ (0, import_disable_native_drag_preview.disableNativeDragPreview)({
91
+ nativeSetDragImage
92
+ });
93
+ import_prevent_unhandled.preventUnhandled.start();
94
+ },
95
+ onDragStart: () => {
96
+ dragStartSize.current = dragStartSize.current === "min-content" ? measureSubject(buttonRef.current, fallbackSize)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
97
+ },
98
+ onDrag: ({ location }) => {
99
+ if (typeof dragStartSize.current !== "number") {
100
+ return;
101
+ }
102
+ setSize(getNextSize(dragStartSize.current, location, client, side, minSize, maxSize));
103
+ },
104
+ onDrop: ({ location }) => {
105
+ if (typeof dragStartSize.current !== "number") {
106
+ return;
107
+ }
108
+ const nextSize = getNextSize(dragStartSize.current, location, client, side, minSize, maxSize);
109
+ setSize(nextSize);
110
+ onSizeChange?.(nextSize, true);
111
+ dragStartSize.current = nextSize;
112
+ }
113
+ });
114
+ }, [
115
+ // Note that `size` should not be a dependency here since dragging this adjusts the size.
116
+ minSize,
117
+ maxSize
118
+ ]);
119
+ return /* @__PURE__ */ import_react.default.createElement("button", {
120
+ ref: buttonRef,
121
+ "data-side": side,
122
+ className: (0, import_react_ui_theme.mx)("group absolute flex focus-visible:outline-none", orientation === "horizontal" ? 'cursor-col-resize is-4 inset-block-0 data-[side="inline-end"]:inline-end-0 data-[side="inline-end"]:before:inline-end-0 data-[side="inline-start"]:inline-start-0 data-[side="inline-start"]:before:inline-start-0 !border-lb-0 before:inset-block-0 before:is-1' : 'cursor-row-resize bs-4 inset-inline-0 data-[side="block-end"]:block-end-0 data-[side="block-end"]:before:block-end-0 data-[side="block-start"]:block-start-0 data-[side="block-start"]:before:block-start-0 !border-li-0 before:inset-inline-0 before:bs-1', orientation === "horizontal" ? iconPosition === "end" ? "align-end" : iconPosition === "center" ? "align-center" : "align-start" : iconPosition === "end" ? "justify-end" : iconPosition === "center" ? "justify-center" : "justify-start", "before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100", "before:absolute before:block before:bg-accentFocusIndicator", classNames)
123
+ }, /* @__PURE__ */ import_react.default.createElement("div", {
124
+ role: "none",
125
+ "data-side": side,
126
+ className: (0, import_react_ui_theme.mx)("grid place-items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0", orientation === "horizontal" ? "bs-[--rail-size] is-4" : "is-[--rail-size] bs-4")
127
+ }, /* @__PURE__ */ import_react.default.createElement(DragHandleSignifier, {
128
+ side
129
+ })));
130
+ };
131
+ var DragHandleSignifier = ({ side }) => {
132
+ return /* @__PURE__ */ import_react.default.createElement("svg", {
133
+ xmlns: "http://www.w3.org/2000/svg",
134
+ viewBox: "0 0 256 256",
135
+ fill: "currentColor",
136
+ className: (0, import_react_ui_theme.mx)("shrink-0 bs-4 is-4 text-unAccent", side === "block-end" ? "rotate-90" : side === "block-start" ? "-rotate-90" : side === "inline-start" && "rotate-180")
137
+ }, /* @__PURE__ */ import_react.default.createElement("path", {
138
+ d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
139
+ }), /* @__PURE__ */ import_react.default.createElement("path", {
140
+ d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
141
+ }), /* @__PURE__ */ import_react.default.createElement("path", {
142
+ d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
143
+ }), /* @__PURE__ */ import_react.default.createElement("path", {
144
+ d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
145
+ }));
146
+ };
147
+ // Annotate the CommonJS export names for ESM import in node:
148
+ 0 && (module.exports = {
149
+ REM,
150
+ ResizeHandle,
151
+ resizeAttributes,
152
+ sizeStyle
153
+ });
154
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ResizeHandle.tsx", "../../../src/util/sizeStyle.ts", "../../../src/util/rem.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';\nimport { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';\nimport { type DragLocationHistory } from '@atlaskit/pragmatic-drag-and-drop/types';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { useLayoutEffect, useRef } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type Size, type Side } from '../types';\nimport { REM } from '../util';\n\nconst measureSubject = (element: HTMLButtonElement, fallbackSize: number): { width: number; height: number } => {\n const stackItemElement = element.closest('[data-dx-resize-subject]');\n return stackItemElement?.getBoundingClientRect() ?? { width: fallbackSize, height: fallbackSize };\n};\n\nconst getNextSize = (\n startSize: number,\n location: DragLocationHistory,\n client: 'clientX' | 'clientY',\n side: Side,\n minSize: number,\n maxSize: number | undefined,\n) => {\n return Math.min(\n maxSize ?? Infinity,\n Math.max(\n minSize,\n startSize +\n ((location.current.input[client] - location.initial.input[client]) / REM) * (side.endsWith('end') ? 1 : -1),\n ),\n );\n};\n\nexport const resizeAttributes = {\n 'data-dx-resize-subject': true,\n};\n\nexport type ResizeHandleProps = ThemedClassName<{\n side: Side;\n defaultSize?: Size;\n fallbackSize: number;\n size?: Size;\n minSize: number;\n maxSize?: number;\n unit?: 'rem';\n iconPosition?: 'start' | 'center' | 'end';\n onSizeChange?: (nextSize: Size, commit?: boolean) => void;\n}>;\n\nexport const ResizeHandle = ({\n classNames,\n side,\n iconPosition = 'start',\n defaultSize,\n fallbackSize,\n size: propsSize,\n minSize,\n maxSize,\n onSizeChange,\n}: ResizeHandleProps) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [size = 'min-content', setSize] = useControllableState({\n prop: propsSize,\n defaultProp: defaultSize,\n onChange: onSizeChange,\n });\n const dragStartSize = useRef<Size>(size);\n\n const orientation = side.startsWith('inline') ? 'horizontal' : 'vertical';\n const client = orientation === 'horizontal' ? 'clientX' : 'clientY';\n\n useLayoutEffect(() => {\n if (!buttonRef.current) {\n return;\n }\n\n // TODO(thure): This should handle StackItem state vs local state better.\n return draggable({\n element: buttonRef.current,\n onGenerateDragPreview: ({ nativeSetDragImage }) => {\n // We will be moving the line to indicate a drag; we can disable the native drag preview.\n disableNativeDragPreview({ nativeSetDragImage });\n // We don't want any native drop animation for when the user does not drop on a drop target.\n // We want the drag to finish immediately.\n preventUnhandled.start();\n },\n onDragStart: () => {\n dragStartSize.current =\n dragStartSize.current === 'min-content'\n ? measureSubject(buttonRef.current!, fallbackSize)[orientation === 'horizontal' ? 'width' : 'height'] / REM\n : dragStartSize.current;\n },\n onDrag: ({ location }) => {\n if (typeof dragStartSize.current !== 'number') {\n return;\n }\n setSize(getNextSize(dragStartSize.current, location, client, side, minSize, maxSize));\n },\n onDrop: ({ location }) => {\n if (typeof dragStartSize.current !== 'number') {\n return;\n }\n const nextSize = getNextSize(dragStartSize.current, location, client, side, minSize, maxSize);\n setSize(nextSize);\n onSizeChange?.(nextSize, true);\n dragStartSize.current = nextSize;\n },\n });\n }, [\n // Note that `size` should not be a dependency here since dragging this adjusts the size.\n minSize,\n maxSize,\n ]);\n\n return (\n <button\n ref={buttonRef}\n data-side={side}\n className={mx(\n 'group absolute flex focus-visible:outline-none',\n orientation === 'horizontal'\n ? 'cursor-col-resize is-4 inset-block-0 data-[side=\"inline-end\"]:inline-end-0 data-[side=\"inline-end\"]:before:inline-end-0 data-[side=\"inline-start\"]:inline-start-0 data-[side=\"inline-start\"]:before:inline-start-0 !border-lb-0 before:inset-block-0 before:is-1'\n : 'cursor-row-resize bs-4 inset-inline-0 data-[side=\"block-end\"]:block-end-0 data-[side=\"block-end\"]:before:block-end-0 data-[side=\"block-start\"]:block-start-0 data-[side=\"block-start\"]:before:block-start-0 !border-li-0 before:inset-inline-0 before:bs-1',\n orientation === 'horizontal'\n ? iconPosition === 'end'\n ? 'align-end'\n : iconPosition === 'center'\n ? 'align-center'\n : 'align-start'\n : iconPosition === 'end'\n ? 'justify-end'\n : iconPosition === 'center'\n ? 'justify-center'\n : 'justify-start',\n 'before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100',\n 'before:absolute before:block before:bg-accentFocusIndicator',\n classNames,\n )}\n >\n <div\n role='none'\n data-side={side}\n className={mx(\n 'grid place-items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0',\n orientation === 'horizontal' ? 'bs-[--rail-size] is-4' : 'is-[--rail-size] bs-4',\n )}\n >\n <DragHandleSignifier side={side} />\n </div>\n </button>\n );\n};\n\nconst DragHandleSignifier = ({ side }: Pick<ResizeHandleProps, 'side'>) => {\n return (\n <svg\n xmlns='http://www.w3.org/2000/svg'\n viewBox='0 0 256 256'\n fill='currentColor'\n className={mx(\n 'shrink-0 bs-4 is-4 text-unAccent',\n side === 'block-end'\n ? 'rotate-90'\n : side === 'block-start'\n ? '-rotate-90'\n : side === 'inline-start' && 'rotate-180',\n )}\n >\n {/* two pips: <path d='M256,120c-8.8,0-16-7.2-16-16v-56c0-8.8,7.2-16,16-16v88Z' />\n <path d='M256,232c-8.8,0-16-7.2-16-16v-56c0-8.8,7.2-16,16-16v88Z' /> */}\n <path d='M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n </svg>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ResizeHandleProps } from '../components';\nimport { type Size } from '../types';\n\nexport const sizeStyle = (size: Size, sideOrOrientation: ResizeHandleProps['side'] | 'horizontal' | 'vertical') => {\n switch (sideOrOrientation) {\n case 'horizontal':\n case 'inline-start':\n case 'inline-end':\n return { inlineSize: size === 'min-content' ? size : `${size}rem` };\n case 'vertical':\n case 'block-start':\n case 'block-end':\n return { blockSize: size === 'min-content' ? size : `${size}rem` };\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport const REM = parseFloat(getComputedStyle(document.documentElement).fontSize);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,qBAA0B;AAC1B,yCAAyC;AACzC,+BAAiC;AAEjC,0CAAqC;AACrC,mBAA+C;AAG/C,4BAAmB;ACLZ,IAAMA,YAAY,CAACC,MAAYC,sBAAAA;AACpC,UAAQA,mBAAAA;IACN,KAAK;IACL,KAAK;IACL,KAAK;AACH,aAAO;QAAEC,YAAYF,SAAS,gBAAgBA,OAAO,GAAGA,IAAAA;MAAU;IACpE,KAAK;IACL,KAAK;IACL,KAAK;AACH,aAAO;QAAEG,WAAWH,SAAS,gBAAgBA,OAAO,GAAGA,IAAAA;MAAU;EACrE;AACF;ACdO,IAAMI,MAAMC,WAAWC,iBAAiBC,SAASC,eAAe,EAAEC,QAAQ;AFajF,IAAMC,iBAAiB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AACa,QAAAA;IAAKC,GAAE;MACR,6BAAAd,QAAA,cAACa,QAAAA;IAAKC,GAAE;;AAGd;",
6
+ "names": ["sizeStyle", "size", "sideOrOrientation", "inlineSize", "blockSize", "REM", "parseFloat", "getComputedStyle", "document", "documentElement", "fontSize", "measureSubject", "element", "fallbackSize", "stackItemElement", "closest", "getBoundingClientRect", "width", "height", "getNextSize", "startSize", "location", "client", "side", "minSize", "maxSize", "Math", "min", "Infinity", "max", "current", "input", "initial", "endsWith", "resizeAttributes", "ResizeHandle", "classNames", "iconPosition", "defaultSize", "propsSize", "onSizeChange", "buttonRef", "useRef", "setSize", "useControllableState", "prop", "defaultProp", "onChange", "dragStartSize", "orientation", "startsWith", "useLayoutEffect", "draggable", "onGenerateDragPreview", "nativeSetDragImage", "disableNativeDragPreview", "preventUnhandled", "start", "onDragStart", "onDrag", "onDrop", "nextSize", "React", "button", "ref", "data-side", "className", "mx", "div", "role", "DragHandleSignifier", "svg", "xmlns", "viewBox", "fill", "path", "d"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"packages/ui/react-ui-dnd/src/util/sizeStyle.ts":{"bytes":2090,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/util/rem.ts":{"bytes":795,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/util/index.ts":{"bytes":581,"imports":[{"path":"packages/ui/react-ui-dnd/src/util/sizeStyle.ts","kind":"import-statement","original":"./sizeStyle"},{"path":"packages/ui/react-ui-dnd/src/util/rem.ts","kind":"import-statement","original":"./rem"}],"format":"esm"},"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx":{"bytes":19857,"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/prevent-unhandled","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-dnd/src/util/index.ts","kind":"import-statement","original":"../util"}],"format":"esm"},"packages/ui/react-ui-dnd/src/components/index.ts":{"bytes":519,"imports":[{"path":"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx","kind":"import-statement","original":"./ResizeHandle"}],"format":"esm"},"packages/ui/react-ui-dnd/src/types.ts":{"bytes":604,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/index.ts":{"bytes":663,"imports":[{"path":"packages/ui/react-ui-dnd/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/ui/react-ui-dnd/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/ui/react-ui-dnd/src/util/index.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-dnd/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":11473},"packages/ui/react-ui-dnd/dist/lib/node/index.cjs":{"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/prevent-unhandled","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"exports":["REM","ResizeHandle","resizeAttributes","sizeStyle"],"entryPoint":"packages/ui/react-ui-dnd/src/index.ts","inputs":{"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx":{"bytesInOutput":5153},"packages/ui/react-ui-dnd/src/util/sizeStyle.ts":{"bytesInOutput":400},"packages/ui/react-ui-dnd/src/util/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-dnd/src/util/rem.ts":{"bytesInOutput":75},"packages/ui/react-ui-dnd/src/components/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-dnd/src/index.ts":{"bytesInOutput":0}},"bytes":5947}}}
@@ -0,0 +1,126 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx
4
+ import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
5
+ import { disableNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview";
6
+ import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
7
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
8
+ import React, { useLayoutEffect, useRef } from "react";
9
+ import { mx } from "@dxos/react-ui-theme";
10
+
11
+ // packages/ui/react-ui-dnd/src/util/sizeStyle.ts
12
+ var sizeStyle = (size, sideOrOrientation) => {
13
+ switch (sideOrOrientation) {
14
+ case "horizontal":
15
+ case "inline-start":
16
+ case "inline-end":
17
+ return {
18
+ inlineSize: size === "min-content" ? size : `${size}rem`
19
+ };
20
+ case "vertical":
21
+ case "block-start":
22
+ case "block-end":
23
+ return {
24
+ blockSize: size === "min-content" ? size : `${size}rem`
25
+ };
26
+ }
27
+ };
28
+
29
+ // packages/ui/react-ui-dnd/src/util/rem.ts
30
+ var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
31
+
32
+ // packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx
33
+ var measureSubject = (element, fallbackSize) => {
34
+ const stackItemElement = element.closest("[data-dx-resize-subject]");
35
+ return stackItemElement?.getBoundingClientRect() ?? {
36
+ width: fallbackSize,
37
+ height: fallbackSize
38
+ };
39
+ };
40
+ var getNextSize = (startSize, location, client, side, minSize, maxSize) => {
41
+ return Math.min(maxSize ?? Infinity, Math.max(minSize, startSize + (location.current.input[client] - location.initial.input[client]) / REM * (side.endsWith("end") ? 1 : -1)));
42
+ };
43
+ var resizeAttributes = {
44
+ "data-dx-resize-subject": true
45
+ };
46
+ var ResizeHandle = ({ classNames, side, iconPosition = "start", defaultSize, fallbackSize, size: propsSize, minSize, maxSize, onSizeChange }) => {
47
+ const buttonRef = useRef(null);
48
+ const [size = "min-content", setSize] = useControllableState({
49
+ prop: propsSize,
50
+ defaultProp: defaultSize,
51
+ onChange: onSizeChange
52
+ });
53
+ const dragStartSize = useRef(size);
54
+ const orientation = side.startsWith("inline") ? "horizontal" : "vertical";
55
+ const client = orientation === "horizontal" ? "clientX" : "clientY";
56
+ useLayoutEffect(() => {
57
+ if (!buttonRef.current) {
58
+ return;
59
+ }
60
+ return draggable({
61
+ element: buttonRef.current,
62
+ onGenerateDragPreview: ({ nativeSetDragImage }) => {
63
+ disableNativeDragPreview({
64
+ nativeSetDragImage
65
+ });
66
+ preventUnhandled.start();
67
+ },
68
+ onDragStart: () => {
69
+ dragStartSize.current = dragStartSize.current === "min-content" ? measureSubject(buttonRef.current, fallbackSize)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
70
+ },
71
+ onDrag: ({ location }) => {
72
+ if (typeof dragStartSize.current !== "number") {
73
+ return;
74
+ }
75
+ setSize(getNextSize(dragStartSize.current, location, client, side, minSize, maxSize));
76
+ },
77
+ onDrop: ({ location }) => {
78
+ if (typeof dragStartSize.current !== "number") {
79
+ return;
80
+ }
81
+ const nextSize = getNextSize(dragStartSize.current, location, client, side, minSize, maxSize);
82
+ setSize(nextSize);
83
+ onSizeChange?.(nextSize, true);
84
+ dragStartSize.current = nextSize;
85
+ }
86
+ });
87
+ }, [
88
+ // Note that `size` should not be a dependency here since dragging this adjusts the size.
89
+ minSize,
90
+ maxSize
91
+ ]);
92
+ return /* @__PURE__ */ React.createElement("button", {
93
+ ref: buttonRef,
94
+ "data-side": side,
95
+ className: mx("group absolute flex focus-visible:outline-none", orientation === "horizontal" ? 'cursor-col-resize is-4 inset-block-0 data-[side="inline-end"]:inline-end-0 data-[side="inline-end"]:before:inline-end-0 data-[side="inline-start"]:inline-start-0 data-[side="inline-start"]:before:inline-start-0 !border-lb-0 before:inset-block-0 before:is-1' : 'cursor-row-resize bs-4 inset-inline-0 data-[side="block-end"]:block-end-0 data-[side="block-end"]:before:block-end-0 data-[side="block-start"]:block-start-0 data-[side="block-start"]:before:block-start-0 !border-li-0 before:inset-inline-0 before:bs-1', orientation === "horizontal" ? iconPosition === "end" ? "align-end" : iconPosition === "center" ? "align-center" : "align-start" : iconPosition === "end" ? "justify-end" : iconPosition === "center" ? "justify-center" : "justify-start", "before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100", "before:absolute before:block before:bg-accentFocusIndicator", classNames)
96
+ }, /* @__PURE__ */ React.createElement("div", {
97
+ role: "none",
98
+ "data-side": side,
99
+ className: mx("grid place-items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0", orientation === "horizontal" ? "bs-[--rail-size] is-4" : "is-[--rail-size] bs-4")
100
+ }, /* @__PURE__ */ React.createElement(DragHandleSignifier, {
101
+ side
102
+ })));
103
+ };
104
+ var DragHandleSignifier = ({ side }) => {
105
+ return /* @__PURE__ */ React.createElement("svg", {
106
+ xmlns: "http://www.w3.org/2000/svg",
107
+ viewBox: "0 0 256 256",
108
+ fill: "currentColor",
109
+ className: mx("shrink-0 bs-4 is-4 text-unAccent", side === "block-end" ? "rotate-90" : side === "block-start" ? "-rotate-90" : side === "inline-start" && "rotate-180")
110
+ }, /* @__PURE__ */ React.createElement("path", {
111
+ d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
112
+ }), /* @__PURE__ */ React.createElement("path", {
113
+ d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
114
+ }), /* @__PURE__ */ React.createElement("path", {
115
+ d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
116
+ }), /* @__PURE__ */ React.createElement("path", {
117
+ d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
118
+ }));
119
+ };
120
+ export {
121
+ REM,
122
+ ResizeHandle,
123
+ resizeAttributes,
124
+ sizeStyle
125
+ };
126
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ResizeHandle.tsx", "../../../src/util/sizeStyle.ts", "../../../src/util/rem.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';\nimport { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';\nimport { type DragLocationHistory } from '@atlaskit/pragmatic-drag-and-drop/types';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { useLayoutEffect, useRef } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type Size, type Side } from '../types';\nimport { REM } from '../util';\n\nconst measureSubject = (element: HTMLButtonElement, fallbackSize: number): { width: number; height: number } => {\n const stackItemElement = element.closest('[data-dx-resize-subject]');\n return stackItemElement?.getBoundingClientRect() ?? { width: fallbackSize, height: fallbackSize };\n};\n\nconst getNextSize = (\n startSize: number,\n location: DragLocationHistory,\n client: 'clientX' | 'clientY',\n side: Side,\n minSize: number,\n maxSize: number | undefined,\n) => {\n return Math.min(\n maxSize ?? Infinity,\n Math.max(\n minSize,\n startSize +\n ((location.current.input[client] - location.initial.input[client]) / REM) * (side.endsWith('end') ? 1 : -1),\n ),\n );\n};\n\nexport const resizeAttributes = {\n 'data-dx-resize-subject': true,\n};\n\nexport type ResizeHandleProps = ThemedClassName<{\n side: Side;\n defaultSize?: Size;\n fallbackSize: number;\n size?: Size;\n minSize: number;\n maxSize?: number;\n unit?: 'rem';\n iconPosition?: 'start' | 'center' | 'end';\n onSizeChange?: (nextSize: Size, commit?: boolean) => void;\n}>;\n\nexport const ResizeHandle = ({\n classNames,\n side,\n iconPosition = 'start',\n defaultSize,\n fallbackSize,\n size: propsSize,\n minSize,\n maxSize,\n onSizeChange,\n}: ResizeHandleProps) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [size = 'min-content', setSize] = useControllableState({\n prop: propsSize,\n defaultProp: defaultSize,\n onChange: onSizeChange,\n });\n const dragStartSize = useRef<Size>(size);\n\n const orientation = side.startsWith('inline') ? 'horizontal' : 'vertical';\n const client = orientation === 'horizontal' ? 'clientX' : 'clientY';\n\n useLayoutEffect(() => {\n if (!buttonRef.current) {\n return;\n }\n\n // TODO(thure): This should handle StackItem state vs local state better.\n return draggable({\n element: buttonRef.current,\n onGenerateDragPreview: ({ nativeSetDragImage }) => {\n // We will be moving the line to indicate a drag; we can disable the native drag preview.\n disableNativeDragPreview({ nativeSetDragImage });\n // We don't want any native drop animation for when the user does not drop on a drop target.\n // We want the drag to finish immediately.\n preventUnhandled.start();\n },\n onDragStart: () => {\n dragStartSize.current =\n dragStartSize.current === 'min-content'\n ? measureSubject(buttonRef.current!, fallbackSize)[orientation === 'horizontal' ? 'width' : 'height'] / REM\n : dragStartSize.current;\n },\n onDrag: ({ location }) => {\n if (typeof dragStartSize.current !== 'number') {\n return;\n }\n setSize(getNextSize(dragStartSize.current, location, client, side, minSize, maxSize));\n },\n onDrop: ({ location }) => {\n if (typeof dragStartSize.current !== 'number') {\n return;\n }\n const nextSize = getNextSize(dragStartSize.current, location, client, side, minSize, maxSize);\n setSize(nextSize);\n onSizeChange?.(nextSize, true);\n dragStartSize.current = nextSize;\n },\n });\n }, [\n // Note that `size` should not be a dependency here since dragging this adjusts the size.\n minSize,\n maxSize,\n ]);\n\n return (\n <button\n ref={buttonRef}\n data-side={side}\n className={mx(\n 'group absolute flex focus-visible:outline-none',\n orientation === 'horizontal'\n ? 'cursor-col-resize is-4 inset-block-0 data-[side=\"inline-end\"]:inline-end-0 data-[side=\"inline-end\"]:before:inline-end-0 data-[side=\"inline-start\"]:inline-start-0 data-[side=\"inline-start\"]:before:inline-start-0 !border-lb-0 before:inset-block-0 before:is-1'\n : 'cursor-row-resize bs-4 inset-inline-0 data-[side=\"block-end\"]:block-end-0 data-[side=\"block-end\"]:before:block-end-0 data-[side=\"block-start\"]:block-start-0 data-[side=\"block-start\"]:before:block-start-0 !border-li-0 before:inset-inline-0 before:bs-1',\n orientation === 'horizontal'\n ? iconPosition === 'end'\n ? 'align-end'\n : iconPosition === 'center'\n ? 'align-center'\n : 'align-start'\n : iconPosition === 'end'\n ? 'justify-end'\n : iconPosition === 'center'\n ? 'justify-center'\n : 'justify-start',\n 'before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100',\n 'before:absolute before:block before:bg-accentFocusIndicator',\n classNames,\n )}\n >\n <div\n role='none'\n data-side={side}\n className={mx(\n 'grid place-items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0',\n orientation === 'horizontal' ? 'bs-[--rail-size] is-4' : 'is-[--rail-size] bs-4',\n )}\n >\n <DragHandleSignifier side={side} />\n </div>\n </button>\n );\n};\n\nconst DragHandleSignifier = ({ side }: Pick<ResizeHandleProps, 'side'>) => {\n return (\n <svg\n xmlns='http://www.w3.org/2000/svg'\n viewBox='0 0 256 256'\n fill='currentColor'\n className={mx(\n 'shrink-0 bs-4 is-4 text-unAccent',\n side === 'block-end'\n ? 'rotate-90'\n : side === 'block-start'\n ? '-rotate-90'\n : side === 'inline-start' && 'rotate-180',\n )}\n >\n {/* two pips: <path d='M256,120c-8.8,0-16-7.2-16-16v-56c0-8.8,7.2-16,16-16v88Z' />\n <path d='M256,232c-8.8,0-16-7.2-16-16v-56c0-8.8,7.2-16,16-16v88Z' /> */}\n <path d='M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n <path d='M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />\n </svg>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ResizeHandleProps } from '../components';\nimport { type Size } from '../types';\n\nexport const sizeStyle = (size: Size, sideOrOrientation: ResizeHandleProps['side'] | 'horizontal' | 'vertical') => {\n switch (sideOrOrientation) {\n case 'horizontal':\n case 'inline-start':\n case 'inline-end':\n return { inlineSize: size === 'min-content' ? size : `${size}rem` };\n case 'vertical':\n case 'block-start':\n case 'block-end':\n return { blockSize: size === 'min-content' ? size : `${size}rem` };\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport const REM = parseFloat(getComputedStyle(document.documentElement).fontSize);\n"],
5
+ "mappings": ";;;AAIA,SAASA,iBAAiB;AAC1B,SAASC,gCAAgC;AACzC,SAASC,wBAAwB;AAEjC,SAASC,4BAA4B;AACrC,OAAOC,SAASC,iBAAiBC,cAAc;AAG/C,SAASC,UAAU;;;ACLZ,IAAMC,YAAY,CAACC,MAAYC,sBAAAA;AACpC,UAAQA,mBAAAA;IACN,KAAK;IACL,KAAK;IACL,KAAK;AACH,aAAO;QAAEC,YAAYF,SAAS,gBAAgBA,OAAO,GAAGA,IAAAA;MAAU;IACpE,KAAK;IACL,KAAK;IACL,KAAK;AACH,aAAO;QAAEG,WAAWH,SAAS,gBAAgBA,OAAO,GAAGA,IAAAA;MAAU;EACrE;AACF;;;ACdO,IAAMI,MAAMC,WAAWC,iBAAiBC,SAASC,eAAe,EAAEC,QAAQ;;;AFajF,IAAMC,iBAAiB,CAACC,SAA4BC,iBAAAA;AAClD,QAAMC,mBAAmBF,QAAQG,QAAQ,0BAAA;AACzC,SAAOD,kBAAkBE,sBAAAA,KAA2B;IAAEC,OAAOJ;IAAcK,QAAQL;EAAa;AAClG;AAEA,IAAMM,cAAc,CAClBC,WACAC,UACAC,QACAC,MACAC,SACAC,YAAAA;AAEA,SAAOC,KAAKC,IACVF,WAAWG,UACXF,K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U;AAC7C;QACF;AACA,cAAMiC,WAAW5C,YAAY+B,cAAcpB,SAAST,UAAUC,QAAQC,MAAMC,SAASC,OAAAA;AACrFoB,gBAAQkB,QAAAA;AACRrB,uBAAeqB,UAAU,IAAA;AACzBb,sBAAcpB,UAAUiC;MAC1B;IACF,CAAA;EACF,GAAG;;IAEDvC;IACAC;GACD;AAED,SACE,sBAAA,cAACuC,UAAAA;IACCC,KAAKtB;IACLuB,aAAW3C;IACX4C,WAAWC,GACT,kDACAjB,gBAAgB,eACZ,qQACA,8PACJA,gBAAgB,eACZb,iBAAiB,QACf,cACAA,iBAAiB,WACf,iBACA,gBACJA,iBAAiB,QACf,gBACAA,iBAAiB,WACf,mBACA,iBACR,yKACA,+DACAD,UAAAA;KAGF,sBAAA,cAACgC,OAAAA;IACCC,MAAK;IACLJ,aAAW3C;IACX4C,WAAWC,GACT,sGACAjB,gBAAgB,eAAe,0BAA0B,uBAAA;KAG3D,sBAAA,cAACoB,qBAAAA;IAAoBhD;;AAI7B;AAEA,IAAMgD,sBAAsB,CAAC,EAAEhD,KAAI,MAAmC;AACpE,SACE,sBAAA,cAACiD,OAAAA;IACCC,OAAM;IACNC,SAAQ;IACRC,MAAK;IACLR,WAAWC,GACT,oCACA7C,SAAS,cACL,cACAA,SAAS,gBACP,eACAA,SAAS,kBAAkB,YAAA;KAKnC,sBAAA,cAACqD,QAAAA;IAAKC,GAAE;MACR,sBAAA,cAACD,QAAAA;IAAKC,GAAE;MACR,sBAAA,cAACD,QAAAA;IAAKC,GAAE;MACR,sBAAA,cAACD,QAAAA;IAAKC,GAAE;;AAGd;",
6
+ "names": ["draggable", "disableNativeDragPreview", "preventUnhandled", "useControllableState", "React", "useLayoutEffect", "useRef", "mx", "sizeStyle", "size", "sideOrOrientation", "inlineSize", "blockSize", "REM", "parseFloat", "getComputedStyle", "document", "documentElement", "fontSize", "measureSubject", "element", "fallbackSize", "stackItemElement", "closest", "getBoundingClientRect", "width", "height", "getNextSize", "startSize", "location", "client", "side", "minSize", "maxSize", "Math", "min", "Infinity", "max", "current", "input", "initial", "REM", "endsWith", "resizeAttributes", "ResizeHandle", "classNames", "iconPosition", "defaultSize", "size", "propsSize", "onSizeChange", "buttonRef", "useRef", "setSize", "useControllableState", "prop", "defaultProp", "onChange", "dragStartSize", "orientation", "startsWith", "useLayoutEffect", "draggable", "onGenerateDragPreview", "nativeSetDragImage", "disableNativeDragPreview", "preventUnhandled", "start", "onDragStart", "onDrag", "onDrop", "nextSize", "button", "ref", "data-side", "className", "mx", "div", "role", "DragHandleSignifier", "svg", "xmlns", "viewBox", "fill", "path", "d"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"packages/ui/react-ui-dnd/src/util/sizeStyle.ts":{"bytes":2090,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/util/rem.ts":{"bytes":795,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/util/index.ts":{"bytes":581,"imports":[{"path":"packages/ui/react-ui-dnd/src/util/sizeStyle.ts","kind":"import-statement","original":"./sizeStyle"},{"path":"packages/ui/react-ui-dnd/src/util/rem.ts","kind":"import-statement","original":"./rem"}],"format":"esm"},"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx":{"bytes":19857,"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/prevent-unhandled","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-dnd/src/util/index.ts","kind":"import-statement","original":"../util"}],"format":"esm"},"packages/ui/react-ui-dnd/src/components/index.ts":{"bytes":519,"imports":[{"path":"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx","kind":"import-statement","original":"./ResizeHandle"}],"format":"esm"},"packages/ui/react-ui-dnd/src/types.ts":{"bytes":604,"imports":[],"format":"esm"},"packages/ui/react-ui-dnd/src/index.ts":{"bytes":663,"imports":[{"path":"packages/ui/react-ui-dnd/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/ui/react-ui-dnd/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/ui/react-ui-dnd/src/util/index.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-dnd/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":11475},"packages/ui/react-ui-dnd/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/prevent-unhandled","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"exports":["REM","ResizeHandle","resizeAttributes","sizeStyle"],"entryPoint":"packages/ui/react-ui-dnd/src/index.ts","inputs":{"packages/ui/react-ui-dnd/src/components/ResizeHandle.tsx":{"bytesInOutput":5153},"packages/ui/react-ui-dnd/src/util/sizeStyle.ts":{"bytesInOutput":400},"packages/ui/react-ui-dnd/src/util/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-dnd/src/util/rem.ts":{"bytesInOutput":75},"packages/ui/react-ui-dnd/src/components/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-dnd/src/index.ts":{"bytesInOutput":0}},"bytes":6040}}}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { type ThemedClassName } from '@dxos/react-ui';
3
+ import { type Size, type Side } from '../types';
4
+ export declare const resizeAttributes: {
5
+ 'data-dx-resize-subject': boolean;
6
+ };
7
+ export type ResizeHandleProps = ThemedClassName<{
8
+ side: Side;
9
+ defaultSize?: Size;
10
+ fallbackSize: number;
11
+ size?: Size;
12
+ minSize: number;
13
+ maxSize?: number;
14
+ unit?: 'rem';
15
+ iconPosition?: 'start' | 'center' | 'end';
16
+ onSizeChange?: (nextSize: Size, commit?: boolean) => void;
17
+ }>;
18
+ export declare const ResizeHandle: ({ classNames, side, iconPosition, defaultSize, fallbackSize, size: propsSize, minSize, maxSize, onSizeChange, }: ResizeHandleProps) => React.JSX.Element;
19
+ //# sourceMappingURL=ResizeHandle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResizeHandle.d.ts","sourceRoot":"","sources":["../../../../src/components/ResizeHandle.tsx"],"names":[],"mappings":"AASA,OAAO,KAAkC,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,UAAU,CAAC;AA0BhD,eAAO,MAAM,gBAAgB;;CAE5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;IAC9C,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,YAAY,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC1C,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC3D,CAAC,CAAC;AAEH,eAAO,MAAM,YAAY,oHAUtB,iBAAiB,sBA4FnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './ResizeHandle';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './components';
2
+ export * from './types';
3
+ export * from './util';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type Size = number | 'min-content';
2
+ export type Side = 'inline-start' | 'inline-end' | 'block-start' | 'block-end';
3
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,aAAa,CAAC;AAC1C,MAAM,MAAM,IAAI,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,GAAG,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './sizeStyle';
2
+ export * from './rem';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/util/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const REM: number;
2
+ //# sourceMappingURL=rem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rem.d.ts","sourceRoot":"","sources":["../../../../src/util/rem.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,GAAG,QAAkE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type ResizeHandleProps } from '../components';
2
+ import { type Size } from '../types';
3
+ export declare const sizeStyle: (size: Size, sideOrOrientation: ResizeHandleProps["side"] | "horizontal" | "vertical") => {
4
+ inlineSize: string;
5
+ blockSize?: undefined;
6
+ } | {
7
+ blockSize: string;
8
+ inlineSize?: undefined;
9
+ };
10
+ //# sourceMappingURL=sizeStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sizeStyle.d.ts","sourceRoot":"","sources":["../../../../src/util/sizeStyle.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,eAAO,MAAM,SAAS,SAAU,IAAI,qBAAqB,iBAAiB,CAAC,MAAM,CAAC,GAAG,YAAY,GAAG,UAAU;;;;;;CAW7G,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":"5.7.3"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@dxos/react-ui-dnd",
3
+ "version": "0.7.5-labs.c0e040f",
4
+ "description": "Drag and drop components.",
5
+ "homepage": "https://dxos.org",
6
+ "bugs": "https://github.com/dxos/dxos/issues",
7
+ "license": "MIT",
8
+ "author": "DXOS.org",
9
+ "sideEffects": true,
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/types/src/index.d.ts",
13
+ "browser": "./dist/lib/browser/index.mjs",
14
+ "node": "./dist/lib/node-esm/index.mjs"
15
+ }
16
+ },
17
+ "types": "dist/types/src/index.d.ts",
18
+ "typesVersions": {
19
+ "*": {
20
+ "testing": [
21
+ "dist/types/src/testing/index.d.ts"
22
+ ]
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "src"
28
+ ],
29
+ "dependencies": {
30
+ "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
31
+ "@radix-ui/react-use-controllable-state": "1.1.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/react": "~18.2.0",
35
+ "@types/react-dom": "~18.2.0",
36
+ "react": "~18.2.0",
37
+ "react-dom": "~18.2.0",
38
+ "vite": "5.4.7",
39
+ "@dxos/react-ui": "0.7.5-labs.c0e040f",
40
+ "@dxos/react-ui-theme": "0.7.5-labs.c0e040f"
41
+ },
42
+ "peerDependencies": {
43
+ "react": "~18.2.0",
44
+ "react-dom": "~18.2.0",
45
+ "@dxos/react-ui": "0.7.5-labs.c0e040f",
46
+ "@dxos/react-ui-theme": "0.7.5-labs.c0e040f"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ }
51
+ }
@@ -0,0 +1,184 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
6
+ import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview';
7
+ import { preventUnhandled } from '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled';
8
+ import { type DragLocationHistory } from '@atlaskit/pragmatic-drag-and-drop/types';
9
+ import { useControllableState } from '@radix-ui/react-use-controllable-state';
10
+ import React, { useLayoutEffect, useRef } from 'react';
11
+
12
+ import { type ThemedClassName } from '@dxos/react-ui';
13
+ import { mx } from '@dxos/react-ui-theme';
14
+
15
+ import { type Size, type Side } from '../types';
16
+ import { REM } from '../util';
17
+
18
+ const measureSubject = (element: HTMLButtonElement, fallbackSize: number): { width: number; height: number } => {
19
+ const stackItemElement = element.closest('[data-dx-resize-subject]');
20
+ return stackItemElement?.getBoundingClientRect() ?? { width: fallbackSize, height: fallbackSize };
21
+ };
22
+
23
+ const getNextSize = (
24
+ startSize: number,
25
+ location: DragLocationHistory,
26
+ client: 'clientX' | 'clientY',
27
+ side: Side,
28
+ minSize: number,
29
+ maxSize: number | undefined,
30
+ ) => {
31
+ return Math.min(
32
+ maxSize ?? Infinity,
33
+ Math.max(
34
+ minSize,
35
+ startSize +
36
+ ((location.current.input[client] - location.initial.input[client]) / REM) * (side.endsWith('end') ? 1 : -1),
37
+ ),
38
+ );
39
+ };
40
+
41
+ export const resizeAttributes = {
42
+ 'data-dx-resize-subject': true,
43
+ };
44
+
45
+ export type ResizeHandleProps = ThemedClassName<{
46
+ side: Side;
47
+ defaultSize?: Size;
48
+ fallbackSize: number;
49
+ size?: Size;
50
+ minSize: number;
51
+ maxSize?: number;
52
+ unit?: 'rem';
53
+ iconPosition?: 'start' | 'center' | 'end';
54
+ onSizeChange?: (nextSize: Size, commit?: boolean) => void;
55
+ }>;
56
+
57
+ export const ResizeHandle = ({
58
+ classNames,
59
+ side,
60
+ iconPosition = 'start',
61
+ defaultSize,
62
+ fallbackSize,
63
+ size: propsSize,
64
+ minSize,
65
+ maxSize,
66
+ onSizeChange,
67
+ }: ResizeHandleProps) => {
68
+ const buttonRef = useRef<HTMLButtonElement>(null);
69
+ const [size = 'min-content', setSize] = useControllableState({
70
+ prop: propsSize,
71
+ defaultProp: defaultSize,
72
+ onChange: onSizeChange,
73
+ });
74
+ const dragStartSize = useRef<Size>(size);
75
+
76
+ const orientation = side.startsWith('inline') ? 'horizontal' : 'vertical';
77
+ const client = orientation === 'horizontal' ? 'clientX' : 'clientY';
78
+
79
+ useLayoutEffect(() => {
80
+ if (!buttonRef.current) {
81
+ return;
82
+ }
83
+
84
+ // TODO(thure): This should handle StackItem state vs local state better.
85
+ return draggable({
86
+ element: buttonRef.current,
87
+ onGenerateDragPreview: ({ nativeSetDragImage }) => {
88
+ // We will be moving the line to indicate a drag; we can disable the native drag preview.
89
+ disableNativeDragPreview({ nativeSetDragImage });
90
+ // We don't want any native drop animation for when the user does not drop on a drop target.
91
+ // We want the drag to finish immediately.
92
+ preventUnhandled.start();
93
+ },
94
+ onDragStart: () => {
95
+ dragStartSize.current =
96
+ dragStartSize.current === 'min-content'
97
+ ? measureSubject(buttonRef.current!, fallbackSize)[orientation === 'horizontal' ? 'width' : 'height'] / REM
98
+ : dragStartSize.current;
99
+ },
100
+ onDrag: ({ location }) => {
101
+ if (typeof dragStartSize.current !== 'number') {
102
+ return;
103
+ }
104
+ setSize(getNextSize(dragStartSize.current, location, client, side, minSize, maxSize));
105
+ },
106
+ onDrop: ({ location }) => {
107
+ if (typeof dragStartSize.current !== 'number') {
108
+ return;
109
+ }
110
+ const nextSize = getNextSize(dragStartSize.current, location, client, side, minSize, maxSize);
111
+ setSize(nextSize);
112
+ onSizeChange?.(nextSize, true);
113
+ dragStartSize.current = nextSize;
114
+ },
115
+ });
116
+ }, [
117
+ // Note that `size` should not be a dependency here since dragging this adjusts the size.
118
+ minSize,
119
+ maxSize,
120
+ ]);
121
+
122
+ return (
123
+ <button
124
+ ref={buttonRef}
125
+ data-side={side}
126
+ className={mx(
127
+ 'group absolute flex focus-visible:outline-none',
128
+ orientation === 'horizontal'
129
+ ? 'cursor-col-resize is-4 inset-block-0 data-[side="inline-end"]:inline-end-0 data-[side="inline-end"]:before:inline-end-0 data-[side="inline-start"]:inline-start-0 data-[side="inline-start"]:before:inline-start-0 !border-lb-0 before:inset-block-0 before:is-1'
130
+ : 'cursor-row-resize bs-4 inset-inline-0 data-[side="block-end"]:block-end-0 data-[side="block-end"]:before:block-end-0 data-[side="block-start"]:block-start-0 data-[side="block-start"]:before:block-start-0 !border-li-0 before:inset-inline-0 before:bs-1',
131
+ orientation === 'horizontal'
132
+ ? iconPosition === 'end'
133
+ ? 'align-end'
134
+ : iconPosition === 'center'
135
+ ? 'align-center'
136
+ : 'align-start'
137
+ : iconPosition === 'end'
138
+ ? 'justify-end'
139
+ : iconPosition === 'center'
140
+ ? 'justify-center'
141
+ : 'justify-start',
142
+ 'before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100',
143
+ 'before:absolute before:block before:bg-accentFocusIndicator',
144
+ classNames,
145
+ )}
146
+ >
147
+ <div
148
+ role='none'
149
+ data-side={side}
150
+ className={mx(
151
+ 'grid place-items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0',
152
+ orientation === 'horizontal' ? 'bs-[--rail-size] is-4' : 'is-[--rail-size] bs-4',
153
+ )}
154
+ >
155
+ <DragHandleSignifier side={side} />
156
+ </div>
157
+ </button>
158
+ );
159
+ };
160
+
161
+ const DragHandleSignifier = ({ side }: Pick<ResizeHandleProps, 'side'>) => {
162
+ return (
163
+ <svg
164
+ xmlns='http://www.w3.org/2000/svg'
165
+ viewBox='0 0 256 256'
166
+ fill='currentColor'
167
+ className={mx(
168
+ 'shrink-0 bs-4 is-4 text-unAccent',
169
+ side === 'block-end'
170
+ ? 'rotate-90'
171
+ : side === 'block-start'
172
+ ? '-rotate-90'
173
+ : side === 'inline-start' && 'rotate-180',
174
+ )}
175
+ >
176
+ {/* two pips: <path d='M256,120c-8.8,0-16-7.2-16-16v-56c0-8.8,7.2-16,16-16v88Z' />
177
+ <path d='M256,232c-8.8,0-16-7.2-16-16v-56c0-8.8,7.2-16,16-16v88Z' /> */}
178
+ <path d='M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />
179
+ <path d='M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />
180
+ <path d='M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />
181
+ <path d='M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z' />
182
+ </svg>
183
+ );
184
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './ResizeHandle';
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './components';
6
+ export * from './types';
7
+ export * from './util';
package/src/types.ts ADDED
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export type Size = number | 'min-content';
6
+ export type Side = 'inline-start' | 'inline-end' | 'block-start' | 'block-end';
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './sizeStyle';
6
+ export * from './rem';
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export const REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type ResizeHandleProps } from '../components';
6
+ import { type Size } from '../types';
7
+
8
+ export const sizeStyle = (size: Size, sideOrOrientation: ResizeHandleProps['side'] | 'horizontal' | 'vertical') => {
9
+ switch (sideOrOrientation) {
10
+ case 'horizontal':
11
+ case 'inline-start':
12
+ case 'inline-end':
13
+ return { inlineSize: size === 'min-content' ? size : `${size}rem` };
14
+ case 'vertical':
15
+ case 'block-start':
16
+ case 'block-end':
17
+ return { blockSize: size === 'min-content' ? size : `${size}rem` };
18
+ }
19
+ };