@contember/react-repeater-dnd-kit 2.1.0-alpha.36 → 2.1.0-alpha.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/index.cjs +27 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +21 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/src/components/RepeaterSortable.cjs +77 -0
- package/dist/development/src/components/RepeaterSortable.cjs.map +1 -0
- package/dist/development/src/components/RepeaterSortable.js +77 -0
- package/dist/development/src/components/RepeaterSortable.js.map +1 -0
- package/dist/development/src/components/RepeaterSortableDragOverlay.cjs +38 -0
- package/dist/development/src/components/RepeaterSortableDragOverlay.cjs.map +1 -0
- package/dist/development/src/components/RepeaterSortableDragOverlay.js +38 -0
- package/dist/development/src/components/RepeaterSortableDragOverlay.js.map +1 -0
- package/dist/development/src/components/RepeaterSortableDropIndicator.cjs +18 -0
- package/dist/development/src/components/RepeaterSortableDropIndicator.cjs.map +1 -0
- package/dist/development/src/components/RepeaterSortableDropIndicator.js +18 -0
- package/dist/development/src/components/RepeaterSortableDropIndicator.js.map +1 -0
- package/dist/development/src/components/RepeaterSortableEachItem.cjs +36 -0
- package/dist/development/src/components/RepeaterSortableEachItem.cjs.map +1 -0
- package/dist/development/src/components/RepeaterSortableEachItem.js +36 -0
- package/dist/development/src/components/RepeaterSortableEachItem.js.map +1 -0
- package/dist/development/src/components/RepeaterSortableItemActivator.cjs +17 -0
- package/dist/development/src/components/RepeaterSortableItemActivator.cjs.map +1 -0
- package/dist/development/src/components/RepeaterSortableItemActivator.js +17 -0
- package/dist/development/src/components/RepeaterSortableItemActivator.js.map +1 -0
- package/dist/development/src/components/RepeaterSortableItemNode.cjs +15 -0
- package/dist/development/src/components/RepeaterSortableItemNode.cjs.map +1 -0
- package/dist/development/src/components/RepeaterSortableItemNode.js +15 -0
- package/dist/development/src/components/RepeaterSortableItemNode.js.map +1 -0
- package/dist/development/src/contexts.cjs +14 -0
- package/dist/development/src/contexts.cjs.map +1 -0
- package/dist/development/src/contexts.js +14 -0
- package/dist/development/src/contexts.js.map +1 -0
- package/dist/production/index.cjs +27 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +21 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/src/components/RepeaterSortable.cjs +61 -0
- package/dist/production/src/components/RepeaterSortable.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortable.js +61 -0
- package/dist/production/src/components/RepeaterSortable.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableDragOverlay.cjs +18 -0
- package/dist/production/src/components/RepeaterSortableDragOverlay.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableDragOverlay.js +18 -0
- package/dist/production/src/components/RepeaterSortableDragOverlay.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableDropIndicator.cjs +14 -0
- package/dist/production/src/components/RepeaterSortableDropIndicator.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableDropIndicator.js +14 -0
- package/dist/production/src/components/RepeaterSortableDropIndicator.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableEachItem.cjs +20 -0
- package/dist/production/src/components/RepeaterSortableEachItem.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableEachItem.js +20 -0
- package/dist/production/src/components/RepeaterSortableEachItem.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableItemActivator.cjs +13 -0
- package/dist/production/src/components/RepeaterSortableItemActivator.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableItemActivator.js +13 -0
- package/dist/production/src/components/RepeaterSortableItemActivator.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableItemNode.cjs +11 -0
- package/dist/production/src/components/RepeaterSortableItemNode.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableItemNode.js +11 -0
- package/dist/production/src/components/RepeaterSortableItemNode.js.map +1 -0
- package/dist/production/src/contexts.cjs +14 -0
- package/dist/production/src/contexts.cjs.map +1 -0
- package/dist/production/src/contexts.js +14 -0
- package/dist/production/src/contexts.js.map +1 -0
- package/dist/types/components/RepeaterSortable.d.ts +37 -0
- package/dist/types/components/RepeaterSortable.d.ts.map +1 -0
- package/dist/types/components/RepeaterSortableDragOverlay.d.ts +8 -0
- package/dist/types/components/RepeaterSortableDragOverlay.d.ts.map +1 -0
- package/dist/types/components/RepeaterSortableDropIndicator.d.ts +9 -0
- package/dist/types/components/RepeaterSortableDropIndicator.d.ts.map +1 -0
- package/dist/types/components/RepeaterSortableEachItem.d.ts +9 -0
- package/dist/types/components/RepeaterSortableEachItem.d.ts.map +1 -0
- package/dist/types/components/RepeaterSortableItemActivator.d.ts +8 -0
- package/dist/types/components/RepeaterSortableItemActivator.d.ts.map +1 -0
- package/dist/types/components/RepeaterSortableItemNode.d.ts +8 -0
- package/dist/types/components/RepeaterSortableItemNode.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +7 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/contexts.d.ts +62 -0
- package/dist/types/contexts.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +12 -12
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const contexts = require("./src/contexts.cjs");
|
|
4
|
+
const reactRepeater = require("@contember/react-repeater");
|
|
5
|
+
const RepeaterSortable = require("./src/components/RepeaterSortable.cjs");
|
|
6
|
+
const RepeaterSortableDragOverlay = require("./src/components/RepeaterSortableDragOverlay.cjs");
|
|
7
|
+
const RepeaterSortableDropIndicator = require("./src/components/RepeaterSortableDropIndicator.cjs");
|
|
8
|
+
const RepeaterSortableEachItem = require("./src/components/RepeaterSortableEachItem.cjs");
|
|
9
|
+
const RepeaterSortableItemActivator = require("./src/components/RepeaterSortableItemActivator.cjs");
|
|
10
|
+
const RepeaterSortableItemNode = require("./src/components/RepeaterSortableItemNode.cjs");
|
|
11
|
+
exports.RepeaterActiveEntityContext = contexts.RepeaterActiveEntityContext;
|
|
12
|
+
exports.RepeaterSortableItemContext = contexts.RepeaterSortableItemContext;
|
|
13
|
+
exports.useRepeaterActiveEntity = contexts.useRepeaterActiveEntity;
|
|
14
|
+
exports.useRepeaterSortableItem = contexts.useRepeaterSortableItem;
|
|
15
|
+
exports.RepeaterSortable = RepeaterSortable.RepeaterSortable;
|
|
16
|
+
exports.RepeaterSortableDragOverlay = RepeaterSortableDragOverlay.RepeaterSortableDragOverlay;
|
|
17
|
+
exports.RepeaterSortableDropIndicator = RepeaterSortableDropIndicator.RepeaterSortableDropIndicator;
|
|
18
|
+
exports.RepeaterSortableEachItem = RepeaterSortableEachItem.RepeaterSortableEachItem;
|
|
19
|
+
exports.RepeaterSortableItemActivator = RepeaterSortableItemActivator.RepeaterSortableItemActivator;
|
|
20
|
+
exports.RepeaterSortableItemNode = RepeaterSortableItemNode.RepeaterSortableItemNode;
|
|
21
|
+
Object.keys(reactRepeater).forEach((k) => {
|
|
22
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: () => reactRepeater[k]
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RepeaterActiveEntityContext, RepeaterSortableItemContext, useRepeaterActiveEntity, useRepeaterSortableItem } from "./src/contexts.js";
|
|
2
|
+
export * from "@contember/react-repeater";
|
|
3
|
+
import { RepeaterSortable } from "./src/components/RepeaterSortable.js";
|
|
4
|
+
import { RepeaterSortableDragOverlay } from "./src/components/RepeaterSortableDragOverlay.js";
|
|
5
|
+
import { RepeaterSortableDropIndicator } from "./src/components/RepeaterSortableDropIndicator.js";
|
|
6
|
+
import { RepeaterSortableEachItem } from "./src/components/RepeaterSortableEachItem.js";
|
|
7
|
+
import { RepeaterSortableItemActivator } from "./src/components/RepeaterSortableItemActivator.js";
|
|
8
|
+
import { RepeaterSortableItemNode } from "./src/components/RepeaterSortableItemNode.js";
|
|
9
|
+
export {
|
|
10
|
+
RepeaterActiveEntityContext,
|
|
11
|
+
RepeaterSortable,
|
|
12
|
+
RepeaterSortableDragOverlay,
|
|
13
|
+
RepeaterSortableDropIndicator,
|
|
14
|
+
RepeaterSortableEachItem,
|
|
15
|
+
RepeaterSortableItemActivator,
|
|
16
|
+
RepeaterSortableItemContext,
|
|
17
|
+
RepeaterSortableItemNode,
|
|
18
|
+
useRepeaterActiveEntity,
|
|
19
|
+
useRepeaterSortableItem
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const core = require("@dnd-kit/core");
|
|
6
|
+
const contexts = require("../contexts.cjs");
|
|
7
|
+
const sortable = require("@dnd-kit/sortable");
|
|
8
|
+
const reactRepeater = require("@contember/react-repeater");
|
|
9
|
+
const RepeaterSortable = ({ children, onDragStart, onDragEnd: onDragEndIn, onDragCancel: onDragCancelIn, ...props }) => {
|
|
10
|
+
const [activeId, setActiveId] = React.useState(null);
|
|
11
|
+
const { moveItem } = reactRepeater.useRepeaterMethods();
|
|
12
|
+
const entities = reactRepeater.useRepeaterSortedEntities();
|
|
13
|
+
const activeItem = React.useMemo(() => {
|
|
14
|
+
if (!activeId) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
return entities.find((it) => it.id === activeId);
|
|
18
|
+
}, [activeId, entities]);
|
|
19
|
+
const sensors = core.useSensors(
|
|
20
|
+
core.useSensor(core.MouseSensor),
|
|
21
|
+
core.useSensor(core.TouchSensor),
|
|
22
|
+
core.useSensor(core.KeyboardSensor)
|
|
23
|
+
);
|
|
24
|
+
const onDragCancel = (event) => {
|
|
25
|
+
onDragCancelIn?.(event);
|
|
26
|
+
setActiveId(null);
|
|
27
|
+
};
|
|
28
|
+
const onDragEnd = React.useCallback((event) => {
|
|
29
|
+
onDragEndIn?.(event);
|
|
30
|
+
setActiveId(null);
|
|
31
|
+
const { active, over } = event;
|
|
32
|
+
const activeEntity = entities.find((it) => it.id === active.id);
|
|
33
|
+
const overIndex = over ? entities.findIndex((it) => it.id === over.id) : void 0;
|
|
34
|
+
if (!activeEntity || overIndex === void 0) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
moveItem?.(activeEntity, overIndex);
|
|
38
|
+
}, [entities, moveItem, onDragEndIn]);
|
|
39
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
40
|
+
core.DndContext,
|
|
41
|
+
{
|
|
42
|
+
sensors,
|
|
43
|
+
measuring: {
|
|
44
|
+
droppable: {
|
|
45
|
+
strategy: core.MeasuringStrategy.Always
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
collisionDetection: core.closestCenter,
|
|
49
|
+
...props,
|
|
50
|
+
onDragStart: (event) => {
|
|
51
|
+
onDragStart?.(event);
|
|
52
|
+
setActiveId(event.active.id);
|
|
53
|
+
},
|
|
54
|
+
onDragEnd,
|
|
55
|
+
onDragCancel,
|
|
56
|
+
children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.RepeaterActiveEntityContext.Provider, { value: activeItem, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(sortable.SortableContext, { items: entities, strategy: sortable.verticalListSortingStrategy, children }, void 0, false, {
|
|
57
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortable.tsx",
|
|
58
|
+
lineNumber: 107,
|
|
59
|
+
columnNumber: 5
|
|
60
|
+
}, void 0) }, void 0, false, {
|
|
61
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortable.tsx",
|
|
62
|
+
lineNumber: 106,
|
|
63
|
+
columnNumber: 4
|
|
64
|
+
}, void 0)
|
|
65
|
+
},
|
|
66
|
+
void 0,
|
|
67
|
+
false,
|
|
68
|
+
{
|
|
69
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortable.tsx",
|
|
70
|
+
lineNumber: 90,
|
|
71
|
+
columnNumber: 3
|
|
72
|
+
},
|
|
73
|
+
void 0
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
exports.RepeaterSortable = RepeaterSortable;
|
|
77
|
+
//# sourceMappingURL=RepeaterSortable.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortable.cjs","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortable.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo, useState } from 'react'\nimport type { DragStartEvent } from '@dnd-kit/core'\nimport {\n\tclosestCenter,\n\tDndContext,\n\tDndContextProps,\n\tDragCancelEvent,\n\tDragEndEvent,\n\tKeyboardSensor,\n\tMeasuringStrategy,\n\tMouseSensor,\n\tTouchSensor,\n\tUniqueIdentifier,\n\tuseSensor,\n\tuseSensors,\n} from '@dnd-kit/core'\nimport { RepeaterActiveEntityContext } from '../contexts'\nimport { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { useRepeaterMethods, useRepeaterSortedEntities } from '@contember/react-repeater'\n\n/**\n * Initializes dnd-kit based sorting for the repeater.\n * Using the props, you can customize the behavior of the sorting and hook into the drag events.\n *\n * ## Example\n * ```tsx\n * <Repeater {...}>\n * <RepeaterSortable>\n * <RepeaterSortableEachItem>\n * <div>\n * <RepeaterSortableDropIndicator position={'before'}><div>Drop here</div></RepeaterSortableDropIndicator>\n * <RepeaterSortableItemNode>\n * <div>\n * <RepeaterSortableItemActivator>\n * <span/>\n * </RepeaterSortableItemActivator>\n * {children}\n * </div>\n * </RepeaterSortableItemNode>\n * <RepeaterSortableDropIndicator position={'afer'}><div>Drop here</div></RepeaterSortableDropIndicator>\n * </div>\n * </RepeaterSortableEachItem>\n * <RepeaterSortableDragOverlay>\n * <div>\n * {children}\n * </div>\n * </RepeaterSortableDragOverlay>\n * </RepeaterSortable>\n * </Repeater>\n * ```\n */\nexport const RepeaterSortable = ({ children, onDragStart, onDragEnd: onDragEndIn, onDragCancel: onDragCancelIn, ...props }: {\n\tchildren: ReactNode\n} & DndContextProps) => {\n\tconst [activeId, setActiveId] = useState<UniqueIdentifier | null>(null)\n\tconst { moveItem } = useRepeaterMethods()\n\tconst entities = useRepeaterSortedEntities()\n\n\tconst activeItem = useMemo(() => {\n\t\tif (!activeId) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn entities.find(it => it.id === activeId)\n\t}, [activeId, entities])\n\n\tconst sensors = useSensors(\n\t\tuseSensor(MouseSensor),\n\t\tuseSensor(TouchSensor),\n\t\tuseSensor(KeyboardSensor),\n\t)\n\n\tconst onDragCancel = (event: DragCancelEvent) => {\n\t\tonDragCancelIn?.(event)\n\t\tsetActiveId(null)\n\t}\n\n\tconst onDragEnd = useCallback((event: DragEndEvent) => {\n\t\tonDragEndIn?.(event)\n\t\tsetActiveId(null)\n\t\tconst { active, over } = event\n\t\tconst activeEntity = entities.find(it => it.id === active.id)\n\t\tconst overIndex = over ? entities.findIndex(it => it.id === over.id) : undefined\n\t\tif (!activeEntity || overIndex === undefined) {\n\t\t\treturn\n\t\t}\n\t\tmoveItem?.(activeEntity, overIndex)\n\t}, [entities, moveItem, onDragEndIn])\n\n\treturn (\n\t\t<DndContext\n\t\t\tsensors={sensors}\n\t\t\tmeasuring={{\n\t\t\t\tdroppable: {\n\t\t\t\t\tstrategy: MeasuringStrategy.Always,\n\t\t\t\t},\n\t\t\t}}\n\t\t\tcollisionDetection={closestCenter}\n\t\t\t{...props}\n\t\t\tonDragStart={(event: DragStartEvent) => {\n\t\t\t\tonDragStart?.(event)\n\t\t\t\tsetActiveId(event.active.id)\n\t\t\t}}\n\t\t\tonDragEnd={onDragEnd}\n\t\t\tonDragCancel={onDragCancel}\n\t\t>\n\t\t\t<RepeaterActiveEntityContext.Provider value={activeItem}>\n\t\t\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t\t\t{children}\n\t\t\t\t</SortableContext>\n\t\t\t</RepeaterActiveEntityContext.Provider>\n\t\t</DndContext>\n\t)\n}\n"],"names":["useState","useRepeaterMethods","useRepeaterSortedEntities","useMemo","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","useCallback","jsxDEV","DndContext","MeasuringStrategy","closestCenter","RepeaterActiveEntityContext","SortableContext","verticalListSortingStrategy","this"],"mappings":";;;;;;;;AAmDO,MAAM,mBAAmB,CAAC,EAAE,UAAU,aAAa,WAAW,aAAa,cAAc,gBAAgB,GAAG,YAE3F;AACvB,QAAM,CAAC,UAAU,WAAW,IAAIA,MAAAA,SAAkC,IAAI;AACtE,QAAM,EAAE,SAAA,IAAaC,iCAAA;AACrB,QAAM,WAAWC,cAAAA,0BAAA;AAEjB,QAAM,aAAaC,MAAAA,QAAQ,MAAM;AAChC,QAAI,CAAC,UAAU;AACd,aAAO;AAAA,IACR;AACA,WAAO,SAAS,KAAK,CAAA,OAAM,GAAG,OAAO,QAAQ;AAAA,EAC9C,GAAG,CAAC,UAAU,QAAQ,CAAC;AAEvB,QAAM,UAAUC,KAAAA;AAAAA,IACfC,KAAAA,UAAUC,KAAAA,WAAW;AAAA,IACrBD,KAAAA,UAAUE,KAAAA,WAAW;AAAA,IACrBF,KAAAA,UAAUG,KAAAA,cAAc;AAAA,EAAA;AAGzB,QAAM,eAAe,CAAC,UAA2B;AAChD,qBAAiB,KAAK;AACtB,gBAAY,IAAI;AAAA,EACjB;AAEA,QAAM,YAAYC,kBAAY,CAAC,UAAwB;AACtD,kBAAc,KAAK;AACnB,gBAAY,IAAI;AAChB,UAAM,EAAE,QAAQ,KAAA,IAAS;AACzB,UAAM,eAAe,SAAS,KAAK,QAAM,GAAG,OAAO,OAAO,EAAE;AAC5D,UAAM,YAAY,OAAO,SAAS,UAAU,QAAM,GAAG,OAAO,KAAK,EAAE,IAAI;AACvE,QAAI,CAAC,gBAAgB,cAAc,QAAW;AAC7C;AAAA,IACD;AACA,eAAW,cAAc,SAAS;AAAA,EACnC,GAAG,CAAC,UAAU,UAAU,WAAW,CAAC;AAEpC,SACCC,8BAAAA;AAAAA,IAACC,KAAAA;AAAAA,IAAA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACV,WAAW;AAAA,UACV,UAAUC,KAAAA,kBAAkB;AAAA,QAAA;AAAA,MAC7B;AAAA,MAED,oBAAoBC,KAAAA;AAAAA,MACnB,GAAG;AAAA,MACJ,aAAa,CAAC,UAA0B;AACvC,sBAAc,KAAK;AACnB,oBAAY,MAAM,OAAO,EAAE;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,MAEA,UAAAH,8BAAAA,OAACI,qCAA4B,UAA5B,EAAqC,OAAO,YAC5C,UAAAJ,8BAAAA,OAACK,SAAAA,iBAAA,EAAgB,OAAO,UAAU,UAAUC,SAAAA,6BAC1C,SAAA,GADF,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAC,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAIA;AAAA,IAAA;AAAA,IApBD;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAuBF;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useState, useMemo, useCallback } from "react";
|
|
3
|
+
import { useSensors, useSensor, MouseSensor, TouchSensor, KeyboardSensor, DndContext, closestCenter, MeasuringStrategy } from "@dnd-kit/core";
|
|
4
|
+
import { RepeaterActiveEntityContext } from "../contexts.js";
|
|
5
|
+
import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
6
|
+
import { useRepeaterMethods, useRepeaterSortedEntities } from "@contember/react-repeater";
|
|
7
|
+
const RepeaterSortable = ({ children, onDragStart, onDragEnd: onDragEndIn, onDragCancel: onDragCancelIn, ...props }) => {
|
|
8
|
+
const [activeId, setActiveId] = useState(null);
|
|
9
|
+
const { moveItem } = useRepeaterMethods();
|
|
10
|
+
const entities = useRepeaterSortedEntities();
|
|
11
|
+
const activeItem = useMemo(() => {
|
|
12
|
+
if (!activeId) {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
return entities.find((it) => it.id === activeId);
|
|
16
|
+
}, [activeId, entities]);
|
|
17
|
+
const sensors = useSensors(
|
|
18
|
+
useSensor(MouseSensor),
|
|
19
|
+
useSensor(TouchSensor),
|
|
20
|
+
useSensor(KeyboardSensor)
|
|
21
|
+
);
|
|
22
|
+
const onDragCancel = (event) => {
|
|
23
|
+
onDragCancelIn?.(event);
|
|
24
|
+
setActiveId(null);
|
|
25
|
+
};
|
|
26
|
+
const onDragEnd = useCallback((event) => {
|
|
27
|
+
onDragEndIn?.(event);
|
|
28
|
+
setActiveId(null);
|
|
29
|
+
const { active, over } = event;
|
|
30
|
+
const activeEntity = entities.find((it) => it.id === active.id);
|
|
31
|
+
const overIndex = over ? entities.findIndex((it) => it.id === over.id) : void 0;
|
|
32
|
+
if (!activeEntity || overIndex === void 0) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
moveItem?.(activeEntity, overIndex);
|
|
36
|
+
}, [entities, moveItem, onDragEndIn]);
|
|
37
|
+
return /* @__PURE__ */ jsxDEV(
|
|
38
|
+
DndContext,
|
|
39
|
+
{
|
|
40
|
+
sensors,
|
|
41
|
+
measuring: {
|
|
42
|
+
droppable: {
|
|
43
|
+
strategy: MeasuringStrategy.Always
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
collisionDetection: closestCenter,
|
|
47
|
+
...props,
|
|
48
|
+
onDragStart: (event) => {
|
|
49
|
+
onDragStart?.(event);
|
|
50
|
+
setActiveId(event.active.id);
|
|
51
|
+
},
|
|
52
|
+
onDragEnd,
|
|
53
|
+
onDragCancel,
|
|
54
|
+
children: /* @__PURE__ */ jsxDEV(RepeaterActiveEntityContext.Provider, { value: activeItem, children: /* @__PURE__ */ jsxDEV(SortableContext, { items: entities, strategy: verticalListSortingStrategy, children }, void 0, false, {
|
|
55
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortable.tsx",
|
|
56
|
+
lineNumber: 107,
|
|
57
|
+
columnNumber: 5
|
|
58
|
+
}, void 0) }, void 0, false, {
|
|
59
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortable.tsx",
|
|
60
|
+
lineNumber: 106,
|
|
61
|
+
columnNumber: 4
|
|
62
|
+
}, void 0)
|
|
63
|
+
},
|
|
64
|
+
void 0,
|
|
65
|
+
false,
|
|
66
|
+
{
|
|
67
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortable.tsx",
|
|
68
|
+
lineNumber: 90,
|
|
69
|
+
columnNumber: 3
|
|
70
|
+
},
|
|
71
|
+
void 0
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
RepeaterSortable
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=RepeaterSortable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortable.js","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortable.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo, useState } from 'react'\nimport type { DragStartEvent } from '@dnd-kit/core'\nimport {\n\tclosestCenter,\n\tDndContext,\n\tDndContextProps,\n\tDragCancelEvent,\n\tDragEndEvent,\n\tKeyboardSensor,\n\tMeasuringStrategy,\n\tMouseSensor,\n\tTouchSensor,\n\tUniqueIdentifier,\n\tuseSensor,\n\tuseSensors,\n} from '@dnd-kit/core'\nimport { RepeaterActiveEntityContext } from '../contexts'\nimport { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { useRepeaterMethods, useRepeaterSortedEntities } from '@contember/react-repeater'\n\n/**\n * Initializes dnd-kit based sorting for the repeater.\n * Using the props, you can customize the behavior of the sorting and hook into the drag events.\n *\n * ## Example\n * ```tsx\n * <Repeater {...}>\n * <RepeaterSortable>\n * <RepeaterSortableEachItem>\n * <div>\n * <RepeaterSortableDropIndicator position={'before'}><div>Drop here</div></RepeaterSortableDropIndicator>\n * <RepeaterSortableItemNode>\n * <div>\n * <RepeaterSortableItemActivator>\n * <span/>\n * </RepeaterSortableItemActivator>\n * {children}\n * </div>\n * </RepeaterSortableItemNode>\n * <RepeaterSortableDropIndicator position={'afer'}><div>Drop here</div></RepeaterSortableDropIndicator>\n * </div>\n * </RepeaterSortableEachItem>\n * <RepeaterSortableDragOverlay>\n * <div>\n * {children}\n * </div>\n * </RepeaterSortableDragOverlay>\n * </RepeaterSortable>\n * </Repeater>\n * ```\n */\nexport const RepeaterSortable = ({ children, onDragStart, onDragEnd: onDragEndIn, onDragCancel: onDragCancelIn, ...props }: {\n\tchildren: ReactNode\n} & DndContextProps) => {\n\tconst [activeId, setActiveId] = useState<UniqueIdentifier | null>(null)\n\tconst { moveItem } = useRepeaterMethods()\n\tconst entities = useRepeaterSortedEntities()\n\n\tconst activeItem = useMemo(() => {\n\t\tif (!activeId) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn entities.find(it => it.id === activeId)\n\t}, [activeId, entities])\n\n\tconst sensors = useSensors(\n\t\tuseSensor(MouseSensor),\n\t\tuseSensor(TouchSensor),\n\t\tuseSensor(KeyboardSensor),\n\t)\n\n\tconst onDragCancel = (event: DragCancelEvent) => {\n\t\tonDragCancelIn?.(event)\n\t\tsetActiveId(null)\n\t}\n\n\tconst onDragEnd = useCallback((event: DragEndEvent) => {\n\t\tonDragEndIn?.(event)\n\t\tsetActiveId(null)\n\t\tconst { active, over } = event\n\t\tconst activeEntity = entities.find(it => it.id === active.id)\n\t\tconst overIndex = over ? entities.findIndex(it => it.id === over.id) : undefined\n\t\tif (!activeEntity || overIndex === undefined) {\n\t\t\treturn\n\t\t}\n\t\tmoveItem?.(activeEntity, overIndex)\n\t}, [entities, moveItem, onDragEndIn])\n\n\treturn (\n\t\t<DndContext\n\t\t\tsensors={sensors}\n\t\t\tmeasuring={{\n\t\t\t\tdroppable: {\n\t\t\t\t\tstrategy: MeasuringStrategy.Always,\n\t\t\t\t},\n\t\t\t}}\n\t\t\tcollisionDetection={closestCenter}\n\t\t\t{...props}\n\t\t\tonDragStart={(event: DragStartEvent) => {\n\t\t\t\tonDragStart?.(event)\n\t\t\t\tsetActiveId(event.active.id)\n\t\t\t}}\n\t\t\tonDragEnd={onDragEnd}\n\t\t\tonDragCancel={onDragCancel}\n\t\t>\n\t\t\t<RepeaterActiveEntityContext.Provider value={activeItem}>\n\t\t\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t\t\t{children}\n\t\t\t\t</SortableContext>\n\t\t\t</RepeaterActiveEntityContext.Provider>\n\t\t</DndContext>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;;AAmDO,MAAM,mBAAmB,CAAC,EAAE,UAAU,aAAa,WAAW,aAAa,cAAc,gBAAgB,GAAG,YAE3F;AACvB,QAAM,CAAC,UAAU,WAAW,IAAI,SAAkC,IAAI;AACtE,QAAM,EAAE,SAAA,IAAa,mBAAA;AACrB,QAAM,WAAW,0BAAA;AAEjB,QAAM,aAAa,QAAQ,MAAM;AAChC,QAAI,CAAC,UAAU;AACd,aAAO;AAAA,IACR;AACA,WAAO,SAAS,KAAK,CAAA,OAAM,GAAG,OAAO,QAAQ;AAAA,EAC9C,GAAG,CAAC,UAAU,QAAQ,CAAC;AAEvB,QAAM,UAAU;AAAA,IACf,UAAU,WAAW;AAAA,IACrB,UAAU,WAAW;AAAA,IACrB,UAAU,cAAc;AAAA,EAAA;AAGzB,QAAM,eAAe,CAAC,UAA2B;AAChD,qBAAiB,KAAK;AACtB,gBAAY,IAAI;AAAA,EACjB;AAEA,QAAM,YAAY,YAAY,CAAC,UAAwB;AACtD,kBAAc,KAAK;AACnB,gBAAY,IAAI;AAChB,UAAM,EAAE,QAAQ,KAAA,IAAS;AACzB,UAAM,eAAe,SAAS,KAAK,QAAM,GAAG,OAAO,OAAO,EAAE;AAC5D,UAAM,YAAY,OAAO,SAAS,UAAU,QAAM,GAAG,OAAO,KAAK,EAAE,IAAI;AACvE,QAAI,CAAC,gBAAgB,cAAc,QAAW;AAC7C;AAAA,IACD;AACA,eAAW,cAAc,SAAS;AAAA,EACnC,GAAG,CAAC,UAAU,UAAU,WAAW,CAAC;AAEpC,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACV,WAAW;AAAA,UACV,UAAU,kBAAkB;AAAA,QAAA;AAAA,MAC7B;AAAA,MAED,oBAAoB;AAAA,MACnB,GAAG;AAAA,MACJ,aAAa,CAAC,UAA0B;AACvC,sBAAc,KAAK;AACnB,oBAAY,MAAM,OAAO,EAAE;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,MAEA,UAAA,uBAAC,4BAA4B,UAA5B,EAAqC,OAAO,YAC5C,UAAA,uBAAC,iBAAA,EAAgB,OAAO,UAAU,UAAU,6BAC1C,SAAA,GADF,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAIA;AAAA,IAAA;AAAA,IApBD;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAuBF;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const contexts = require("../contexts.cjs");
|
|
5
|
+
const reactPortal = require("@radix-ui/react-portal");
|
|
6
|
+
const core = require("@dnd-kit/core");
|
|
7
|
+
const reactBinding = require("@contember/react-binding");
|
|
8
|
+
const reactRepeater = require("@contember/react-repeater");
|
|
9
|
+
const RepeaterSortableDragOverlay = ({ children }) => {
|
|
10
|
+
const activeItem = contexts.useRepeaterActiveEntity();
|
|
11
|
+
const accessorTreeState = reactBinding.useAccessorTreeState();
|
|
12
|
+
if (!activeItem) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactPortal.Portal, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(core.DragOverlay, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.AccessorTree, { state: accessorTreeState, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Entity, { accessor: activeItem, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactRepeater.RepeaterCurrentEntityContext.Provider, { value: activeItem, children }, void 0, false, {
|
|
16
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
17
|
+
lineNumber: 24,
|
|
18
|
+
columnNumber: 7
|
|
19
|
+
}, void 0) }, void 0, false, {
|
|
20
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
21
|
+
lineNumber: 23,
|
|
22
|
+
columnNumber: 6
|
|
23
|
+
}, void 0) }, void 0, false, {
|
|
24
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
25
|
+
lineNumber: 22,
|
|
26
|
+
columnNumber: 5
|
|
27
|
+
}, void 0) }, void 0, false, {
|
|
28
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
29
|
+
lineNumber: 21,
|
|
30
|
+
columnNumber: 4
|
|
31
|
+
}, void 0) }, void 0, false, {
|
|
32
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
33
|
+
lineNumber: 20,
|
|
34
|
+
columnNumber: 3
|
|
35
|
+
}, void 0);
|
|
36
|
+
};
|
|
37
|
+
exports.RepeaterSortableDragOverlay = RepeaterSortableDragOverlay;
|
|
38
|
+
//# sourceMappingURL=RepeaterSortableDragOverlay.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableDragOverlay.cjs","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterActiveEntity } from '../contexts'\nimport { Portal } from '@radix-ui/react-portal'\nimport { DragOverlay } from '@dnd-kit/core'\nimport { AccessorTree, Entity, useAccessorTreeState } from '@contember/react-binding'\nimport { RepeaterCurrentEntityContext } from '@contember/react-repeater'\n\n/**\n * Component for rendering the repeater item being dragged.\n */\nexport const RepeaterSortableDragOverlay = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst activeItem = useRepeaterActiveEntity()\n\tconst accessorTreeState = useAccessorTreeState()\n\tif (!activeItem) {\n\t\treturn null\n\t}\n\treturn (\n\t\t<Portal>\n\t\t\t<DragOverlay>\n\t\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t\t<Entity accessor={activeItem}>\n\t\t\t\t\t\t<RepeaterCurrentEntityContext.Provider value={activeItem}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</RepeaterCurrentEntityContext.Provider>\n\t\t\t\t\t</Entity>\n\t\t\t\t</AccessorTree>\n\t\t\t</DragOverlay>\n\t\t</Portal>\n\t)\n}\n"],"names":["useRepeaterActiveEntity","useAccessorTreeState","Portal","jsxDEV","DragOverlay","AccessorTree","Entity","RepeaterCurrentEntityContext","this"],"mappings":";;;;;;;;AAUO,MAAM,8BAA8B,CAAC,EAAE,eAExC;AACL,QAAM,aAAaA,SAAAA,wBAAA;AACnB,QAAM,oBAAoBC,aAAAA,qBAAA;AAC1B,MAAI,CAAC,YAAY;AAChB,WAAO;AAAA,EACR;AACA,8CACEC,YAAAA,QAAA,EACA,UAAAC,8BAAAA,OAACC,KAAAA,eACA,UAAAD,8BAAAA,OAACE,aAAAA,cAAA,EAAa,OAAO,mBACpB,UAAAF,8BAAAA,OAACG,aAAAA,QAAA,EAAO,UAAU,YACjB,UAAAH,8BAAAA,OAACI,cAAAA,6BAA6B,UAA7B,EAAsC,OAAO,YAC5C,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAIA,EAAA,GALD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA,EAAA,GAPD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAQA,EAAA,GATD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAUA;AAEF;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useRepeaterActiveEntity } from "../contexts.js";
|
|
3
|
+
import { Portal } from "@radix-ui/react-portal";
|
|
4
|
+
import { DragOverlay } from "@dnd-kit/core";
|
|
5
|
+
import { useAccessorTreeState, AccessorTree, Entity } from "@contember/react-binding";
|
|
6
|
+
import { RepeaterCurrentEntityContext } from "@contember/react-repeater";
|
|
7
|
+
const RepeaterSortableDragOverlay = ({ children }) => {
|
|
8
|
+
const activeItem = useRepeaterActiveEntity();
|
|
9
|
+
const accessorTreeState = useAccessorTreeState();
|
|
10
|
+
if (!activeItem) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ jsxDEV(Portal, { children: /* @__PURE__ */ jsxDEV(DragOverlay, { children: /* @__PURE__ */ jsxDEV(AccessorTree, { state: accessorTreeState, children: /* @__PURE__ */ jsxDEV(Entity, { accessor: activeItem, children: /* @__PURE__ */ jsxDEV(RepeaterCurrentEntityContext.Provider, { value: activeItem, children }, void 0, false, {
|
|
14
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
15
|
+
lineNumber: 24,
|
|
16
|
+
columnNumber: 7
|
|
17
|
+
}, void 0) }, void 0, false, {
|
|
18
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
19
|
+
lineNumber: 23,
|
|
20
|
+
columnNumber: 6
|
|
21
|
+
}, void 0) }, void 0, false, {
|
|
22
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
23
|
+
lineNumber: 22,
|
|
24
|
+
columnNumber: 5
|
|
25
|
+
}, void 0) }, void 0, false, {
|
|
26
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
27
|
+
lineNumber: 21,
|
|
28
|
+
columnNumber: 4
|
|
29
|
+
}, void 0) }, void 0, false, {
|
|
30
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx",
|
|
31
|
+
lineNumber: 20,
|
|
32
|
+
columnNumber: 3
|
|
33
|
+
}, void 0);
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
RepeaterSortableDragOverlay
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=RepeaterSortableDragOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableDragOverlay.js","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableDragOverlay.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterActiveEntity } from '../contexts'\nimport { Portal } from '@radix-ui/react-portal'\nimport { DragOverlay } from '@dnd-kit/core'\nimport { AccessorTree, Entity, useAccessorTreeState } from '@contember/react-binding'\nimport { RepeaterCurrentEntityContext } from '@contember/react-repeater'\n\n/**\n * Component for rendering the repeater item being dragged.\n */\nexport const RepeaterSortableDragOverlay = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst activeItem = useRepeaterActiveEntity()\n\tconst accessorTreeState = useAccessorTreeState()\n\tif (!activeItem) {\n\t\treturn null\n\t}\n\treturn (\n\t\t<Portal>\n\t\t\t<DragOverlay>\n\t\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t\t<Entity accessor={activeItem}>\n\t\t\t\t\t\t<RepeaterCurrentEntityContext.Provider value={activeItem}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</RepeaterCurrentEntityContext.Provider>\n\t\t\t\t\t</Entity>\n\t\t\t\t</AccessorTree>\n\t\t\t</DragOverlay>\n\t\t</Portal>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;;AAUO,MAAM,8BAA8B,CAAC,EAAE,eAExC;AACL,QAAM,aAAa,wBAAA;AACnB,QAAM,oBAAoB,qBAAA;AAC1B,MAAI,CAAC,YAAY;AAChB,WAAO;AAAA,EACR;AACA,gCACE,QAAA,EACA,UAAA,uBAAC,eACA,UAAA,uBAAC,cAAA,EAAa,OAAO,mBACpB,UAAA,uBAAC,QAAA,EAAO,UAAU,YACjB,UAAA,uBAAC,6BAA6B,UAA7B,EAAsC,OAAO,YAC5C,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAIA,EAAA,GALD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA,EAAA,GAPD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAQA,EAAA,GATD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAUA;AAEF;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const contexts = require("../contexts.cjs");
|
|
5
|
+
const RepeaterSortableDropIndicator = ({ children, position }) => {
|
|
6
|
+
const sortable = contexts.useRepeaterSortableItem();
|
|
7
|
+
const isOver = sortable.isOver;
|
|
8
|
+
const activeSortable = sortable.active?.data.current?.sortable;
|
|
9
|
+
const isAfter = (sortable.data?.sortable.index ?? 0) > activeSortable?.index;
|
|
10
|
+
const renderedPosition = isAfter ? "after" : "before";
|
|
11
|
+
return renderedPosition === position && isOver ? /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
|
|
12
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDropIndicator.tsx",
|
|
13
|
+
lineNumber: 17,
|
|
14
|
+
columnNumber: 51
|
|
15
|
+
}, void 0) : null;
|
|
16
|
+
};
|
|
17
|
+
exports.RepeaterSortableDropIndicator = RepeaterSortableDropIndicator;
|
|
18
|
+
//# sourceMappingURL=RepeaterSortableDropIndicator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableDropIndicator.cjs","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableDropIndicator.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\n\n/**\n * Renders a child element when the repeater item is being dragged over the drop indicator.\n */\nexport const RepeaterSortableDropIndicator = ({ children, position }: {\n\tchildren: ReactNode\n\tposition: 'before' | 'after'\n}) => {\n\tconst sortable = useRepeaterSortableItem()\n\tconst isOver = sortable.isOver\n\tconst activeSortable = sortable.active?.data.current?.sortable\n\tconst isAfter = (sortable.data?.sortable.index ?? 0) > activeSortable?.index\n\tconst renderedPosition = isAfter ? 'after' : 'before'\n\n\treturn renderedPosition === position && isOver ? <>{children}</> : null\n}\n"],"names":["useRepeaterSortableItem","jsxDEV","Fragment","this"],"mappings":";;;;AAMO,MAAM,gCAAgC,CAAC,EAAE,UAAU,eAGpD;AACL,QAAM,WAAWA,SAAAA,wBAAA;AACjB,QAAM,SAAS,SAAS;AACxB,QAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS;AACtD,QAAM,WAAW,SAAS,MAAM,SAAS,SAAS,KAAK,gBAAgB;AACvE,QAAM,mBAAmB,UAAU,UAAU;AAE7C,SAAO,qBAAqB,YAAY,SAASC,8BAAAA,OAAAC,cAAAA,UAAA,EAAG,SAAA,GAAH,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAAY,IAAM;AACpE;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useRepeaterSortableItem } from "../contexts.js";
|
|
3
|
+
const RepeaterSortableDropIndicator = ({ children, position }) => {
|
|
4
|
+
const sortable = useRepeaterSortableItem();
|
|
5
|
+
const isOver = sortable.isOver;
|
|
6
|
+
const activeSortable = sortable.active?.data.current?.sortable;
|
|
7
|
+
const isAfter = (sortable.data?.sortable.index ?? 0) > activeSortable?.index;
|
|
8
|
+
const renderedPosition = isAfter ? "after" : "before";
|
|
9
|
+
return renderedPosition === position && isOver ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
10
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableDropIndicator.tsx",
|
|
11
|
+
lineNumber: 17,
|
|
12
|
+
columnNumber: 51
|
|
13
|
+
}, void 0) : null;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
RepeaterSortableDropIndicator
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=RepeaterSortableDropIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableDropIndicator.js","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableDropIndicator.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\n\n/**\n * Renders a child element when the repeater item is being dragged over the drop indicator.\n */\nexport const RepeaterSortableDropIndicator = ({ children, position }: {\n\tchildren: ReactNode\n\tposition: 'before' | 'after'\n}) => {\n\tconst sortable = useRepeaterSortableItem()\n\tconst isOver = sortable.isOver\n\tconst activeSortable = sortable.active?.data.current?.sortable\n\tconst isAfter = (sortable.data?.sortable.index ?? 0) > activeSortable?.index\n\tconst renderedPosition = isAfter ? 'after' : 'before'\n\n\treturn renderedPosition === position && isOver ? <>{children}</> : null\n}\n"],"names":["this"],"mappings":";;AAMO,MAAM,gCAAgC,CAAC,EAAE,UAAU,eAGpD;AACL,QAAM,WAAW,wBAAA;AACjB,QAAM,SAAS,SAAS;AACxB,QAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS;AACtD,QAAM,WAAW,SAAS,MAAM,SAAS,SAAS,KAAK,gBAAgB;AACvE,QAAM,mBAAmB,UAAU,UAAU;AAE7C,SAAO,qBAAqB,YAAY,SAAS,uBAAA,UAAA,EAAG,SAAA,GAAH,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAY,IAAM;AACpE;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const sortable = require("@dnd-kit/sortable");
|
|
5
|
+
const reactRepeater = require("@contember/react-repeater");
|
|
6
|
+
const contexts = require("../contexts.cjs");
|
|
7
|
+
const reactBinding = require("@contember/react-binding");
|
|
8
|
+
const RepeaterSortableEachItem = ({ children }) => {
|
|
9
|
+
const entities = reactRepeater.useRepeaterSortedEntities();
|
|
10
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(sortable.SortableContext, { items: entities, strategy: sortable.verticalListSortingStrategy, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactRepeater.RepeaterEachItem, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(RepeaterSortableEachItemInner, { children }, void 0, false, {
|
|
11
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx",
|
|
12
|
+
lineNumber: 19,
|
|
13
|
+
columnNumber: 5
|
|
14
|
+
}, void 0) }, void 0, false, {
|
|
15
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx",
|
|
16
|
+
lineNumber: 18,
|
|
17
|
+
columnNumber: 4
|
|
18
|
+
}, void 0) }, void 0, false, {
|
|
19
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx",
|
|
20
|
+
lineNumber: 17,
|
|
21
|
+
columnNumber: 3
|
|
22
|
+
}, void 0);
|
|
23
|
+
};
|
|
24
|
+
const RepeaterSortableEachItemInner = ({ children }) => {
|
|
25
|
+
const entity = reactBinding.useEntity();
|
|
26
|
+
const sortable$1 = sortable.useSortable({
|
|
27
|
+
id: entity.id
|
|
28
|
+
});
|
|
29
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.RepeaterSortableItemContext.Provider, { value: sortable$1, children }, void 0, false, {
|
|
30
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx",
|
|
31
|
+
lineNumber: 34,
|
|
32
|
+
columnNumber: 3
|
|
33
|
+
}, void 0);
|
|
34
|
+
};
|
|
35
|
+
exports.RepeaterSortableEachItem = RepeaterSortableEachItem;
|
|
36
|
+
//# sourceMappingURL=RepeaterSortableEachItem.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableEachItem.cjs","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { RepeaterEachItem, useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { RepeaterSortableItemContext } from '../contexts'\nimport { useEntity } from '@contember/react-binding'\n\n/**\n * Iterates over all entities in the repeater and renders the children for each entity.\n * Also sets up the dnd-kit sortable context for the repeater items.\n */\nexport const RepeaterSortableEachItem = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entities = useRepeaterSortedEntities()\n\n\treturn (\n\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t<RepeaterEachItem>\n\t\t\t\t<RepeaterSortableEachItemInner>\n\t\t\t\t\t{children}\n\t\t\t\t</RepeaterSortableEachItemInner>\n\t\t\t</RepeaterEachItem>\n\t\t</SortableContext>\n\t)\n}\nconst RepeaterSortableEachItemInner = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entity = useEntity()\n\tconst sortable = useSortable({\n\t\tid: entity.id,\n\t})\n\treturn (\n\t\t<RepeaterSortableItemContext.Provider value={sortable}>\n\t\t\t{children}\n\t\t</RepeaterSortableItemContext.Provider>\n\t)\n}\n"],"names":["useRepeaterSortedEntities","jsxDEV","SortableContext","verticalListSortingStrategy","RepeaterEachItem","this","useEntity","sortable","useSortable","RepeaterSortableItemContext"],"mappings":";;;;;;;AAUO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACL,QAAM,WAAWA,cAAAA,0BAAA;AAEjB,SACCC,8BAAAA,OAACC,SAAAA,iBAAA,EAAgB,OAAO,UAAU,UAAUC,SAAAA,6BAC3C,UAAAF,8BAAAA,OAACG,cAAAA,kBAAA,EACA,UAAAH,qCAAC,+BAAA,EACC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAI,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAIA,EAAA,GALD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA;AAEF;AACA,MAAM,gCAAgC,CAAC,EAAE,eAEnC;AACL,QAAM,SAASC,aAAAA,UAAA;AACf,QAAMC,aAAWC,SAAAA,YAAY;AAAA,IAC5B,IAAI,OAAO;AAAA,EAAA,CACX;AACD,8CACEC,qCAA4B,UAA5B,EAAqC,OAAOF,YAC3C,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAF,MAEA;AAEF;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { SortableContext, verticalListSortingStrategy, useSortable } from "@dnd-kit/sortable";
|
|
3
|
+
import { useRepeaterSortedEntities, RepeaterEachItem } from "@contember/react-repeater";
|
|
4
|
+
import { RepeaterSortableItemContext } from "../contexts.js";
|
|
5
|
+
import { useEntity } from "@contember/react-binding";
|
|
6
|
+
const RepeaterSortableEachItem = ({ children }) => {
|
|
7
|
+
const entities = useRepeaterSortedEntities();
|
|
8
|
+
return /* @__PURE__ */ jsxDEV(SortableContext, { items: entities, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsxDEV(RepeaterEachItem, { children: /* @__PURE__ */ jsxDEV(RepeaterSortableEachItemInner, { children }, void 0, false, {
|
|
9
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx",
|
|
10
|
+
lineNumber: 19,
|
|
11
|
+
columnNumber: 5
|
|
12
|
+
}, void 0) }, void 0, false, {
|
|
13
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx",
|
|
14
|
+
lineNumber: 18,
|
|
15
|
+
columnNumber: 4
|
|
16
|
+
}, void 0) }, void 0, false, {
|
|
17
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx",
|
|
18
|
+
lineNumber: 17,
|
|
19
|
+
columnNumber: 3
|
|
20
|
+
}, void 0);
|
|
21
|
+
};
|
|
22
|
+
const RepeaterSortableEachItemInner = ({ children }) => {
|
|
23
|
+
const entity = useEntity();
|
|
24
|
+
const sortable = useSortable({
|
|
25
|
+
id: entity.id
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsxDEV(RepeaterSortableItemContext.Provider, { value: sortable, children }, void 0, false, {
|
|
28
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx",
|
|
29
|
+
lineNumber: 34,
|
|
30
|
+
columnNumber: 3
|
|
31
|
+
}, void 0);
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
RepeaterSortableEachItem
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=RepeaterSortableEachItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableEachItem.js","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableEachItem.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { RepeaterEachItem, useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { RepeaterSortableItemContext } from '../contexts'\nimport { useEntity } from '@contember/react-binding'\n\n/**\n * Iterates over all entities in the repeater and renders the children for each entity.\n * Also sets up the dnd-kit sortable context for the repeater items.\n */\nexport const RepeaterSortableEachItem = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entities = useRepeaterSortedEntities()\n\n\treturn (\n\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t<RepeaterEachItem>\n\t\t\t\t<RepeaterSortableEachItemInner>\n\t\t\t\t\t{children}\n\t\t\t\t</RepeaterSortableEachItemInner>\n\t\t\t</RepeaterEachItem>\n\t\t</SortableContext>\n\t)\n}\nconst RepeaterSortableEachItemInner = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entity = useEntity()\n\tconst sortable = useSortable({\n\t\tid: entity.id,\n\t})\n\treturn (\n\t\t<RepeaterSortableItemContext.Provider value={sortable}>\n\t\t\t{children}\n\t\t</RepeaterSortableItemContext.Provider>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;AAUO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACL,QAAM,WAAW,0BAAA;AAEjB,SACC,uBAAC,iBAAA,EAAgB,OAAO,UAAU,UAAU,6BAC3C,UAAA,uBAAC,kBAAA,EACA,UAAA,uBAAC,+BAAA,EACC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAIA,EAAA,GALD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA;AAEF;AACA,MAAM,gCAAgC,CAAC,EAAE,eAEnC;AACL,QAAM,SAAS,UAAA;AACf,QAAM,WAAW,YAAY;AAAA,IAC5B,IAAI,OAAO;AAAA,EAAA,CACX;AACD,gCACE,4BAA4B,UAA5B,EAAqC,OAAO,UAC3C,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA;AAEF;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const contexts = require("../contexts.cjs");
|
|
6
|
+
const reactSlot = require("@radix-ui/react-slot");
|
|
7
|
+
const reactUtils = require("@contember/react-utils");
|
|
8
|
+
const RepeaterSortableItemActivator = React.forwardRef((props, ref) => {
|
|
9
|
+
const { setActivatorNodeRef, listeners } = contexts.useRepeaterSortableItem();
|
|
10
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactSlot.Slot, { ref: reactUtils.useComposeRef(ref, setActivatorNodeRef), ...listeners, ...props }, void 0, false, {
|
|
11
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableItemActivator.tsx",
|
|
12
|
+
lineNumber: 13,
|
|
13
|
+
columnNumber: 9
|
|
14
|
+
}, void 0);
|
|
15
|
+
});
|
|
16
|
+
exports.RepeaterSortableItemActivator = RepeaterSortableItemActivator;
|
|
17
|
+
//# sourceMappingURL=RepeaterSortableItemActivator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableItemActivator.cjs","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableItemActivator.tsx"],"sourcesContent":["import React, { forwardRef, ReactElement, ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useComposeRef } from '@contember/react-utils'\n\n/**\n * Slot for the repeater item activator, which is the element that triggers the drag and drop interaction (e.g. a handle).\n */\nexport const RepeaterSortableItemActivator = forwardRef<HTMLElement, {\n\tchildren: ReactElement\n}>((props, ref) => {\n\tconst { setActivatorNodeRef, listeners } = useRepeaterSortableItem()\n\treturn <Slot ref={useComposeRef(ref, setActivatorNodeRef)} {...listeners} {...props} />\n})\n"],"names":["forwardRef","useRepeaterSortableItem","jsxDEV","Slot","useComposeRef","this"],"mappings":";;;;;;;AAQO,MAAM,gCAAgCA,MAAAA,WAE1C,CAAC,OAAO,QAAQ;AAClB,QAAM,EAAE,qBAAqB,UAAA,IAAcC,iCAAA;AAC3C,SAAOC,8BAAAA,OAACC,UAAAA,MAAA,EAAK,KAAKC,WAAAA,cAAc,KAAK,mBAAmB,GAAI,GAAG,WAAY,GAAG,MAAA,GAAvE,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAA8E;AACtF,CAAC;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useRepeaterSortableItem } from "../contexts.js";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { useComposeRef } from "@contember/react-utils";
|
|
6
|
+
const RepeaterSortableItemActivator = forwardRef((props, ref) => {
|
|
7
|
+
const { setActivatorNodeRef, listeners } = useRepeaterSortableItem();
|
|
8
|
+
return /* @__PURE__ */ jsxDEV(Slot, { ref: useComposeRef(ref, setActivatorNodeRef), ...listeners, ...props }, void 0, false, {
|
|
9
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableItemActivator.tsx",
|
|
10
|
+
lineNumber: 13,
|
|
11
|
+
columnNumber: 9
|
|
12
|
+
}, void 0);
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
RepeaterSortableItemActivator
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=RepeaterSortableItemActivator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableItemActivator.js","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableItemActivator.tsx"],"sourcesContent":["import React, { forwardRef, ReactElement, ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useComposeRef } from '@contember/react-utils'\n\n/**\n * Slot for the repeater item activator, which is the element that triggers the drag and drop interaction (e.g. a handle).\n */\nexport const RepeaterSortableItemActivator = forwardRef<HTMLElement, {\n\tchildren: ReactElement\n}>((props, ref) => {\n\tconst { setActivatorNodeRef, listeners } = useRepeaterSortableItem()\n\treturn <Slot ref={useComposeRef(ref, setActivatorNodeRef)} {...listeners} {...props} />\n})\n"],"names":["this"],"mappings":";;;;;AAQO,MAAM,gCAAgC,WAE1C,CAAC,OAAO,QAAQ;AAClB,QAAM,EAAE,qBAAqB,UAAA,IAAc,wBAAA;AAC3C,SAAO,uBAAC,MAAA,EAAK,KAAK,cAAc,KAAK,mBAAmB,GAAI,GAAG,WAAY,GAAG,MAAA,GAAvE,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAA8E;AACtF,CAAC;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const contexts = require("../contexts.cjs");
|
|
5
|
+
const reactSlot = require("@radix-ui/react-slot");
|
|
6
|
+
const RepeaterSortableItemNode = ({ children }) => {
|
|
7
|
+
const { setNodeRef } = contexts.useRepeaterSortableItem();
|
|
8
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactSlot.Slot, { ref: setNodeRef, children }, void 0, false, {
|
|
9
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableItemNode.tsx",
|
|
10
|
+
lineNumber: 12,
|
|
11
|
+
columnNumber: 9
|
|
12
|
+
}, void 0);
|
|
13
|
+
};
|
|
14
|
+
exports.RepeaterSortableItemNode = RepeaterSortableItemNode;
|
|
15
|
+
//# sourceMappingURL=RepeaterSortableItemNode.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableItemNode.cjs","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableItemNode.tsx"],"sourcesContent":["import React, { ReactElement } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\n\n/**\n * Slot for the repeater item node, which is the element that is being dragged.\n */\nexport const RepeaterSortableItemNode = ({ children }: {\n\tchildren: ReactElement\n}) => {\n\tconst { setNodeRef } = useRepeaterSortableItem()\n\treturn <Slot ref={setNodeRef}>{children}</Slot>\n}\n"],"names":["useRepeaterSortableItem","jsxDEV","Slot","this"],"mappings":";;;;;AAOO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACL,QAAM,EAAE,WAAA,IAAeA,iCAAA;AACvB,SAAOC,8BAAAA,OAACC,UAAAA,MAAA,EAAK,KAAK,YAAa,SAAA,GAAxB,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAAiC;AACzC;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useRepeaterSortableItem } from "../contexts.js";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
const RepeaterSortableItemNode = ({ children }) => {
|
|
5
|
+
const { setNodeRef } = useRepeaterSortableItem();
|
|
6
|
+
return /* @__PURE__ */ jsxDEV(Slot, { ref: setNodeRef, children }, void 0, false, {
|
|
7
|
+
fileName: "/home/runner/work/contember/contember/packages/react-repeater-dnd-kit/src/components/RepeaterSortableItemNode.tsx",
|
|
8
|
+
lineNumber: 12,
|
|
9
|
+
columnNumber: 9
|
|
10
|
+
}, void 0);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
RepeaterSortableItemNode
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=RepeaterSortableItemNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RepeaterSortableItemNode.js","sources":["../../../../../packages/react-repeater-dnd-kit/src/components/RepeaterSortableItemNode.tsx"],"sourcesContent":["import React, { ReactElement } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\n\n/**\n * Slot for the repeater item node, which is the element that is being dragged.\n */\nexport const RepeaterSortableItemNode = ({ children }: {\n\tchildren: ReactElement\n}) => {\n\tconst { setNodeRef } = useRepeaterSortableItem()\n\treturn <Slot ref={setNodeRef}>{children}</Slot>\n}\n"],"names":["this"],"mappings":";;;AAOO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACL,QAAM,EAAE,WAAA,IAAe,wBAAA;AACvB,SAAO,uBAAC,MAAA,EAAK,KAAK,YAAa,SAAA,GAAxB,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAiC;AACzC;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactUtils = require("@contember/react-utils");
|
|
4
|
+
const RepeaterSortableItemContext_ = reactUtils.createRequiredContext("RepeaterSortableItemContext");
|
|
5
|
+
const RepeaterSortableItemContext = RepeaterSortableItemContext_[0];
|
|
6
|
+
const useRepeaterSortableItem = RepeaterSortableItemContext_[1];
|
|
7
|
+
const RepeaterActiveEntityContext_ = reactUtils.createContext("RepeaterActiveEntityContext", void 0);
|
|
8
|
+
const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0];
|
|
9
|
+
const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1];
|
|
10
|
+
exports.RepeaterActiveEntityContext = RepeaterActiveEntityContext;
|
|
11
|
+
exports.RepeaterSortableItemContext = RepeaterSortableItemContext;
|
|
12
|
+
exports.useRepeaterActiveEntity = useRepeaterActiveEntity;
|
|
13
|
+
exports.useRepeaterSortableItem = useRepeaterSortableItem;
|
|
14
|
+
//# sourceMappingURL=contexts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.cjs","sources":["../../../../packages/react-repeater-dnd-kit/src/contexts.ts"],"sourcesContent":["import { createContext, createRequiredContext } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/react-binding'\nimport { useSortable } from '@dnd-kit/sortable'\n\nconst RepeaterSortableItemContext_ = createRequiredContext<ReturnType<typeof useSortable>>('RepeaterSortableItemContext')\n/** @internal */\nexport const RepeaterSortableItemContext = RepeaterSortableItemContext_[0]\n/**\n * Returns the sortable context from dnd-kit (e.g. isDragging, isOver, setNodeRef) for the repeater item.\n */\nexport const useRepeaterSortableItem = RepeaterSortableItemContext_[1]\n\nconst RepeaterActiveEntityContext_ = createContext<EntityAccessor | undefined>('RepeaterActiveEntityContext', undefined)\n/** @internal */\nexport const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0]\n/**\n * Returns the entity that is currently being dragged in the repeater.\n */\nexport const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1]\n"],"names":["createRequiredContext","createContext"],"mappings":";;;AAIA,MAAM,+BAA+BA,WAAAA,sBAAsD,6BAA6B;AAEjH,MAAM,8BAA8B,6BAA6B,CAAC;AAIlE,MAAM,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,+BAA+BC,WAAAA,cAA0C,+BAA+B,MAAS;AAEhH,MAAM,8BAA8B,6BAA6B,CAAC;AAIlE,MAAM,0BAA0B,6BAA6B,CAAC;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, createRequiredContext } from "@contember/react-utils";
|
|
2
|
+
const RepeaterSortableItemContext_ = createRequiredContext("RepeaterSortableItemContext");
|
|
3
|
+
const RepeaterSortableItemContext = RepeaterSortableItemContext_[0];
|
|
4
|
+
const useRepeaterSortableItem = RepeaterSortableItemContext_[1];
|
|
5
|
+
const RepeaterActiveEntityContext_ = createContext("RepeaterActiveEntityContext", void 0);
|
|
6
|
+
const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0];
|
|
7
|
+
const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1];
|
|
8
|
+
export {
|
|
9
|
+
RepeaterActiveEntityContext,
|
|
10
|
+
RepeaterSortableItemContext,
|
|
11
|
+
useRepeaterActiveEntity,
|
|
12
|
+
useRepeaterSortableItem
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=contexts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.js","sources":["../../../../packages/react-repeater-dnd-kit/src/contexts.ts"],"sourcesContent":["import { createContext, createRequiredContext } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/react-binding'\nimport { useSortable } from '@dnd-kit/sortable'\n\nconst RepeaterSortableItemContext_ = createRequiredContext<ReturnType<typeof useSortable>>('RepeaterSortableItemContext')\n/** @internal */\nexport const RepeaterSortableItemContext = RepeaterSortableItemContext_[0]\n/**\n * Returns the sortable context from dnd-kit (e.g. isDragging, isOver, setNodeRef) for the repeater item.\n */\nexport const useRepeaterSortableItem = RepeaterSortableItemContext_[1]\n\nconst RepeaterActiveEntityContext_ = createContext<EntityAccessor | undefined>('RepeaterActiveEntityContext', undefined)\n/** @internal */\nexport const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0]\n/**\n * Returns the entity that is currently being dragged in the repeater.\n */\nexport const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1]\n"],"names":[],"mappings":";AAIA,MAAM,+BAA+B,sBAAsD,6BAA6B;AAEjH,MAAM,8BAA8B,6BAA6B,CAAC;AAIlE,MAAM,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,+BAA+B,cAA0C,+BAA+B,MAAS;AAEhH,MAAM,8BAA8B,6BAA6B,CAAC;AAIlE,MAAM,0BAA0B,6BAA6B,CAAC;"}
|