@plasmicpkgs/dnd-kit 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Latipov Abdukhamid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ Plasmic components and registration calls for dnd-kit
@@ -0,0 +1,419 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var React = require('react');
8
+ var React__default = _interopDefault(React);
9
+ var reactDom = require('react-dom');
10
+ var testUtils = require('react-dom/test-utils');
11
+ var core = require('@dnd-kit/core');
12
+ var sortable = require('@dnd-kit/sortable');
13
+ var host = require('@plasmicapp/host');
14
+ var modifiers = require('@dnd-kit/modifiers');
15
+ var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
16
+
17
+ function _extends() {
18
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
19
+ for (var e = 1; e < arguments.length; e++) {
20
+ var t = arguments[e];
21
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
22
+ }
23
+ return n;
24
+ }, _extends.apply(null, arguments);
25
+ }
26
+ function _objectWithoutPropertiesLoose(r, e) {
27
+ if (null == r) return {};
28
+ var t = {};
29
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
30
+ if (-1 !== e.indexOf(n)) continue;
31
+ t[n] = r[n];
32
+ }
33
+ return t;
34
+ }
35
+
36
+ function registerComponentHelper(loader, component, meta) {
37
+ if (loader) {
38
+ loader.registerComponent(component, meta);
39
+ } else {
40
+ registerComponent(component, meta);
41
+ }
42
+ }
43
+
44
+ var _excluded = ["color", "dragOverlay", "dragging", "disabled", "fadeIn", "height", "index", "listeners", "renderItem", "sorting", "style", "transition", "transform", "value", "wrapperStyle"];
45
+ var Item = /*#__PURE__*/React__default.memo(/*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
46
+ var _transform$x, _transform$y, _transform$scaleX, _transform$scaleY;
47
+ var dragOverlay = _ref.dragOverlay,
48
+ dragging = _ref.dragging,
49
+ fadeIn = _ref.fadeIn,
50
+ index = _ref.index,
51
+ listeners = _ref.listeners,
52
+ _ref$renderItem = _ref.renderItem,
53
+ renderItem = _ref$renderItem === void 0 ? function () {
54
+ return React__default.createElement("div", null);
55
+ } : _ref$renderItem,
56
+ sorting = _ref.sorting,
57
+ style = _ref.style,
58
+ transition = _ref.transition,
59
+ transform = _ref.transform,
60
+ value = _ref.value,
61
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
62
+ React.useEffect(function () {
63
+ if (!dragOverlay) {
64
+ return;
65
+ }
66
+ document.body.style.cursor = "grabbing";
67
+ return function () {
68
+ document.body.style.cursor = "";
69
+ };
70
+ }, [dragOverlay]);
71
+ var child = renderItem({
72
+ dragOverlay: Boolean(dragOverlay),
73
+ dragging: Boolean(dragging),
74
+ sorting: Boolean(sorting),
75
+ index: index,
76
+ fadeIn: Boolean(fadeIn),
77
+ listeners: listeners,
78
+ ref: ref,
79
+ style: style,
80
+ transform: transform,
81
+ transition: transition,
82
+ value: value
83
+ }, value);
84
+ return testUtils.isElement(child) ? React.cloneElement(child, {
85
+ ref: ref,
86
+ style: {
87
+ transition: [transition].filter(Boolean).join(", "),
88
+ transform: "translate3d(" + ((_transform$x = transform == null ? void 0 : transform.x) != null ? _transform$x : 0) + "px, " + ((_transform$y = transform == null ? void 0 : transform.y) != null ? _transform$y : 0) + "px, 0) scaleX(" + ((_transform$scaleX = transform == null ? void 0 : transform.scaleX) != null ? _transform$scaleX : 1) + ") scaleY(" + ((_transform$scaleY = transform == null ? void 0 : transform.scaleY) != null ? _transform$scaleY : 1)
89
+ }
90
+ }) : child;
91
+ }));
92
+ var dropAnimationConfig = {
93
+ sideEffects: /*#__PURE__*/core.defaultDropAnimationSideEffects({
94
+ styles: {
95
+ active: {
96
+ opacity: "0.5"
97
+ }
98
+ }
99
+ })
100
+ };
101
+ var screenReaderInstructions = {
102
+ draggable: "\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "
103
+ };
104
+ var modifierByName = {
105
+ restrictToVerticalAxis: modifiers.restrictToVerticalAxis,
106
+ restrictToWindowEdges: modifiers.restrictToWindowEdges,
107
+ restrictToHorizontalAxis: modifiers.restrictToHorizontalAxis,
108
+ restrictToParentElement: modifiers.restrictToParentElement,
109
+ restrictToFirstScrollableAncestor: modifiers.restrictToFirstScrollableAncestor
110
+ };
111
+ function Sortable(_ref2) {
112
+ var _modifiers;
113
+ var className = _ref2.className,
114
+ style = _ref2.style,
115
+ activationConstraint = _ref2.activationConstraint,
116
+ animateLayoutChanges = _ref2.animateLayoutChanges,
117
+ _ref2$adjustScale = _ref2.adjustScale,
118
+ adjustScale = _ref2$adjustScale === void 0 ? false : _ref2$adjustScale,
119
+ _ref2$collisionDetect = _ref2.collisionDetection,
120
+ collisionDetection = _ref2$collisionDetect === void 0 ? core.closestCenter : _ref2$collisionDetect,
121
+ _ref2$coordinateGette = _ref2.coordinateGetter,
122
+ coordinateGetter = _ref2$coordinateGette === void 0 ? sortable.sortableKeyboardCoordinates : _ref2$coordinateGette,
123
+ _ref2$dropAnimation = _ref2.dropAnimation,
124
+ dropAnimation = _ref2$dropAnimation === void 0 ? dropAnimationConfig : _ref2$dropAnimation,
125
+ getNewIndex = _ref2.getNewIndex,
126
+ _ref2$rowKey = _ref2.rowKey,
127
+ rowKey = _ref2$rowKey === void 0 ? function (item) {
128
+ return item.id;
129
+ } : _ref2$rowKey,
130
+ _ref2$items = _ref2.items,
131
+ initialItems = _ref2$items === void 0 ? [] : _ref2$items,
132
+ measuring = _ref2.measuring,
133
+ modifiers = _ref2.modifiers,
134
+ _renderItem = _ref2.renderItem,
135
+ _ref2$reorderItems = _ref2.reorderItems,
136
+ reorderItems = _ref2$reorderItems === void 0 ? sortable.arrayMove : _ref2$reorderItems,
137
+ _ref2$strategy = _ref2.strategy,
138
+ strategy = _ref2$strategy === void 0 ? sortable.rectSortingStrategy : _ref2$strategy,
139
+ _ref2$useDragOverlay = _ref2.useDragOverlay,
140
+ useDragOverlay = _ref2$useDragOverlay === void 0 ? true : _ref2$useDragOverlay,
141
+ modifierNames = _ref2.modifierNames,
142
+ themeResetClass = _ref2.themeResetClass,
143
+ onReorder = _ref2.onReorder;
144
+ modifiers = (_modifiers = modifiers) != null ? _modifiers : (modifierNames != null ? modifierNames : []).map(function (name) {
145
+ return modifierByName[name];
146
+ });
147
+ // This is the optimistic version.
148
+ var _useState = React.useState(function () {
149
+ return initialItems;
150
+ }),
151
+ items = _useState[0],
152
+ setItems = _useState[1];
153
+ React.useEffect(function () {
154
+ setItems(initialItems);
155
+ }, [initialItems]);
156
+ var _useState2 = React.useState(null),
157
+ activeId = _useState2[0],
158
+ setActiveId = _useState2[1];
159
+ var sensors = core.useSensors(core.useSensor(core.MouseSensor, {
160
+ activationConstraint: activationConstraint
161
+ }), core.useSensor(core.TouchSensor, {
162
+ activationConstraint: activationConstraint
163
+ }), core.useSensor(core.KeyboardSensor, {
164
+ // Disable smooth scrolling in Cypress automated tests
165
+ scrollBehavior: "Cypress" in globalThis ? "auto" : undefined,
166
+ coordinateGetter: coordinateGetter
167
+ }));
168
+ var isFirstAnnouncement = React.useRef(true);
169
+ var getIndex = function getIndex(id) {
170
+ return items.findIndex(function (item) {
171
+ return rowKey(item) === id;
172
+ });
173
+ };
174
+ var getPosition = function getPosition(id) {
175
+ return getIndex(id) + 1;
176
+ };
177
+ var activeIndex = activeId ? getIndex(activeId) : -1;
178
+ var announcements = {
179
+ onDragStart: function onDragStart(_ref3) {
180
+ var id = _ref3.active.id;
181
+ return "Picked up sortable item " + String(id) + ". Sortable item " + id + " is in position " + getPosition(id) + " of " + items.length;
182
+ },
183
+ onDragOver: function onDragOver(_ref4) {
184
+ var active = _ref4.active,
185
+ over = _ref4.over;
186
+ // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.
187
+ // The first `onDragOver` event therefore doesn't need to be announced, because it is called
188
+ // immediately after the `onDragStart` announcement and is redundant.
189
+ if (isFirstAnnouncement.current === true) {
190
+ isFirstAnnouncement.current = false;
191
+ return;
192
+ }
193
+ if (over) {
194
+ return "Sortable item " + active.id + " was moved into position " + getPosition(over.id) + " of " + items.length;
195
+ }
196
+ return;
197
+ },
198
+ onDragEnd: function onDragEnd(_ref5) {
199
+ var active = _ref5.active,
200
+ over = _ref5.over;
201
+ if (over) {
202
+ return "Sortable item " + active.id + " was dropped at position " + getPosition(over.id) + " of " + items.length;
203
+ }
204
+ return;
205
+ },
206
+ onDragCancel: function onDragCancel(_ref6) {
207
+ var id = _ref6.active.id;
208
+ return "Sorting was cancelled. Sortable item " + id + " was dropped and returned to position " + getPosition(id) + " of " + items.length + ".";
209
+ }
210
+ };
211
+ React.useEffect(function () {
212
+ if (!activeId) {
213
+ isFirstAnnouncement.current = true;
214
+ }
215
+ }, [activeId]);
216
+ return React__default.createElement("div", {
217
+ className: className,
218
+ style: style
219
+ }, React__default.createElement(core.DndContext, {
220
+ accessibility: {
221
+ announcements: announcements,
222
+ screenReaderInstructions: screenReaderInstructions
223
+ },
224
+ sensors: sensors,
225
+ collisionDetection: collisionDetection,
226
+ onDragStart: function onDragStart(_ref7) {
227
+ var active = _ref7.active;
228
+ if (!active) {
229
+ return;
230
+ }
231
+ setActiveId(active.id);
232
+ },
233
+ onDragEnd: function onDragEnd(_ref8) {
234
+ var over = _ref8.over;
235
+ setActiveId(null);
236
+ if (over) {
237
+ var overIndex = getIndex(over.id);
238
+ var reordered = reorderItems(items, activeIndex, overIndex);
239
+ onReorder == null || onReorder(activeIndex, overIndex, reordered, items);
240
+ if (activeIndex !== overIndex) {
241
+ setItems(function (items) {
242
+ return reordered;
243
+ });
244
+ }
245
+ }
246
+ },
247
+ onDragCancel: function onDragCancel() {
248
+ return setActiveId(null);
249
+ },
250
+ measuring: measuring,
251
+ modifiers: modifiers
252
+ }, React__default.createElement(sortable.SortableContext, {
253
+ items: items.map(rowKey),
254
+ strategy: strategy
255
+ }, items.map(function (value, index) {
256
+ return React__default.createElement(SortableItem, {
257
+ key: rowKey(value),
258
+ id: rowKey(value),
259
+ value: value,
260
+ index: index,
261
+ renderItem: _renderItem,
262
+ animateLayoutChanges: animateLayoutChanges,
263
+ useDragOverlay: useDragOverlay,
264
+ getNewIndex: getNewIndex
265
+ });
266
+ })), useDragOverlay && typeof document !== "undefined" ? reactDom.createPortal(React__default.createElement(core.DragOverlay, {
267
+ adjustScale: adjustScale,
268
+ dropAnimation: dropAnimation
269
+ }, activeId ? React__default.createElement(Item, {
270
+ index: activeIndex,
271
+ value: items[activeIndex],
272
+ renderItem: function renderItem() {
273
+ return React__default.createElement("div", {
274
+ className: themeResetClass
275
+ }, _renderItem.apply(void 0, arguments));
276
+ },
277
+ dragOverlay: true
278
+ }) : null), document.body) : null));
279
+ }
280
+ function SortableItem(_ref9) {
281
+ var animateLayoutChanges = _ref9.animateLayoutChanges,
282
+ getNewIndex = _ref9.getNewIndex,
283
+ id = _ref9.id,
284
+ value = _ref9.value,
285
+ index = _ref9.index,
286
+ renderItem = _ref9.renderItem,
287
+ useDragOverlay = _ref9.useDragOverlay;
288
+ var sortableData = sortable.useSortable({
289
+ id: id,
290
+ animateLayoutChanges: animateLayoutChanges,
291
+ getNewIndex: getNewIndex
292
+ });
293
+ var attributes = sortableData.attributes,
294
+ isDragging = sortableData.isDragging,
295
+ isSorting = sortableData.isSorting,
296
+ listeners = sortableData.listeners,
297
+ setNodeRef = sortableData.setNodeRef,
298
+ transform = sortableData.transform,
299
+ transition = sortableData.transition;
300
+ return React__default.createElement(host.DataProvider, {
301
+ hidden: true,
302
+ name: "sortableItem",
303
+ data: sortableData
304
+ }, React__default.createElement(Item, Object.assign({
305
+ ref: setNodeRef,
306
+ value: value,
307
+ dragging: isDragging,
308
+ sorting: isSorting,
309
+ renderItem: renderItem,
310
+ index: index,
311
+ transform: transform,
312
+ transition: transition,
313
+ listeners: listeners,
314
+ "data-index": index,
315
+ "data-id": id,
316
+ dragOverlay: !useDragOverlay && isDragging
317
+ }, attributes)));
318
+ }
319
+ function SortableHandle(_ref10) {
320
+ var children = _ref10.children;
321
+ var data = host.useSelector("sortableItem");
322
+ var child = React__default.Children.toArray(children)[0];
323
+ return testUtils.isElement(child) ? React.cloneElement(child, _extends({}, data == null ? void 0 : data.listeners, {
324
+ ref: data == null ? void 0 : data.setActivatorNodeRef,
325
+ tabIndex: 0
326
+ })) : null;
327
+ }
328
+ function registerSortable(loader) {
329
+ registerComponentHelper(loader, SortableHandle, {
330
+ name: "SortableHandle",
331
+ props: {
332
+ children: {
333
+ type: "slot",
334
+ defaultValue: {
335
+ type: "text",
336
+ value: "Handle"
337
+ },
338
+ mergeWithParent: true
339
+ }
340
+ },
341
+ importPath: "@plasmicpkgs/dnd-kit",
342
+ importName: "SortableHandle"
343
+ });
344
+ registerComponentHelper(loader, Sortable, {
345
+ name: "Sortable",
346
+ props: {
347
+ items: {
348
+ type: "array",
349
+ defaultValue: [{
350
+ id: 1,
351
+ name: "hello"
352
+ }, {
353
+ id: 2,
354
+ name: "world"
355
+ }]
356
+ },
357
+ modifierNames: {
358
+ displayName: "Options",
359
+ type: "choice",
360
+ multiSelect: true,
361
+ options: Object.keys(modifierByName).map(function (v) {
362
+ return {
363
+ value: v,
364
+ label: v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, "$1 $2")
365
+ };
366
+ })
367
+ },
368
+ onReorder: {
369
+ type: "eventHandler",
370
+ argTypes: [{
371
+ name: "fromIndex",
372
+ type: "number"
373
+ }, {
374
+ name: "toIndex",
375
+ type: "number"
376
+ }, {
377
+ name: "newItems",
378
+ type: "object"
379
+ }, {
380
+ name: "oldItems",
381
+ type: "object"
382
+ }]
383
+ },
384
+ themeResetClass: {
385
+ type: "themeResetClass"
386
+ },
387
+ renderItem: {
388
+ type: "slot",
389
+ renderPropParams: ["sortableData", "currentItem"],
390
+ mergeWithParent: true,
391
+ defaultValue: {
392
+ type: "hbox",
393
+ children: [{
394
+ type: "text",
395
+ value: "Item"
396
+ }, {
397
+ type: "component",
398
+ name: "SortableHandle"
399
+ }]
400
+ }
401
+ }
402
+ },
403
+ importPath: "@plasmicpkgs/dnd-kit",
404
+ importName: "Sortable"
405
+ });
406
+ }
407
+
408
+ function registerAll(loader) {
409
+ registerSortable(loader);
410
+ }
411
+
412
+ exports.Item = Item;
413
+ exports.Sortable = Sortable;
414
+ exports.SortableHandle = SortableHandle;
415
+ exports.SortableItem = SortableItem;
416
+ exports.modifierByName = modifierByName;
417
+ exports.registerAll = registerAll;
418
+ exports.registerSortable = registerSortable;
419
+ //# sourceMappingURL=dnd-kit.cjs.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dnd-kit.cjs.development.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","wrapperStyle","props","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","attributes","isDragging","isSorting","setNodeRef","DataProvider","hidden","data","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toUpperCase","slice","replace","argTypes","renderPropParams","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAcgBA,uBAAuBA,CACrCC,MAAgC,EAChCC,SAAY,EACZC,IAA4C;EAE5C,IAAIF,MAAM,EAAE;IACVA,MAAM,CAACG,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;GAC1C,MAAM;IACLC,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;;AAEtC;;;ACxBA,IAsFaE,IAAI,gBAAGC,cAAK,CAACC,IAAI,cAC5BD,cAAK,CAACE,UAAU,CACd,UAAAC,IAAA,EAmBEC,GAAG;;MAhBDC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,AACAC,MAAM,GAAAL,IAAA,CAANK,MAAM;IACNC,AACAC,KAAK,GAAAP,IAAA,CAALO,KAAK;IACLC,SAAS,GAAAR,IAAA,CAATQ,SAAS;IAAAC,eAAA,GAAAT,IAAA,CACTU,UAAU;IAAVA,UAAU,GAAAD,eAAA,cAAG;MAAA,OAAMZ,yCAAO;QAAAY,eAAA;IAC1BE,OAAO,GAAAX,IAAA,CAAPW,OAAO;IACPC,KAAK,GAAAZ,IAAA,CAALY,KAAK;IACLC,UAAU,GAAAb,IAAA,CAAVa,UAAU;IACVC,SAAS,GAAAd,IAAA,CAATc,SAAS;IACTC,KAAK,GAAAf,IAAA,CAALe,KAAK;IACLC,AACGC,KAAK,GAAAC,6BAAA,CAAAlB,IAAA,EAAAmB,SAAA;EAIVC,eAAS,CAAC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C1J,KAAK,EAAE0J,CAAC;YACRC,KAAK,EACHD,CAAC,CAAC,CAAC,CAAC,CAACE,WAAW,EAAE,GAAGF,CAAC,CAACG,KAAK,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,iBAAiB,EAAE,OAAO;WACrE;SAAC;OACH;MACDrF,SAAS,EAAE;QACTuE,IAAI,EAAE,cAAc;QACpBe,QAAQ,EAAE,CACR;UACEnF,IAAI,EAAE,WAAW;UACjBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,SAAS;UACfoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP,EACD;UACEpE,IAAI,EAAE,UAAU;UAChBoE,IAAI,EAAE;SACP;OAEJ;MACDxE,eAAe,EAAE;QACfwE,IAAI,EAAE;OACP;MACDrJ,UAAU,EAAE;QACVqJ,IAAI,EAAE,MAAM;QACZgB,gBAAgB,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;QACjDd,eAAe,EAAE,IAAI;QACrBD,YAAY,EAAE;UACZD,IAAI,EAAE,MAAM;UACZR,QAAQ,EAAE,CACR;YACEQ,IAAI,EAAE,MAAM;YACZhJ,KAAK,EAAE;WACR,EACD;YACEgJ,IAAI,EAAE,WAAW;YACjBpE,IAAI,EAAE;WACP;;;KAIR;IACDuE,UAAU,EAAE,sBAAsB;IAClCC,UAAU,EAAE;GACb,CAAC;AACJ;;SCriBgBa,WAAWA,CAACxL,MAAqB;EAC/CsK,gBAAgB,CAACtK,MAAM,CAAC;AAC1B;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),n=require("react-dom"),a=require("react-dom/test-utils"),o=require("@dnd-kit/core"),i=require("@dnd-kit/sortable"),s=require("@plasmicapp/host"),l=require("@dnd-kit/modifiers"),d=e(require("@plasmicapp/host/registerComponent"));function u(){return(u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(null,arguments)}function c(e,t,r){e?e.registerComponent(t,r):d(t,r)}var m=["color","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","renderItem","sorting","style","transition","transform","value","wrapperStyle"],f=r.memo(r.forwardRef((function(e,n){var o,i,s,l,d=e.dragOverlay,u=e.dragging,c=e.fadeIn,f=e.index,p=e.listeners,v=e.renderItem,g=void 0===v?function(){return r.createElement("div",null)}:v,y=e.sorting,b=e.style,S=e.transition,h=e.transform,x=e.value;!function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}}(e,m),t.useEffect((function(){if(d)return document.body.style.cursor="grabbing",function(){document.body.style.cursor=""}}),[d]);var I=g({dragOverlay:Boolean(d),dragging:Boolean(u),sorting:Boolean(y),index:f,fadeIn:Boolean(c),listeners:p,ref:n,style:b,transform:h,transition:S,value:x},x);return a.isElement(I)?t.cloneElement(I,{ref:n,style:{transition:[S].filter(Boolean).join(", "),transform:"translate3d("+(null!=(o=null==h?void 0:h.x)?o:0)+"px, "+(null!=(i=null==h?void 0:h.y)?i:0)+"px, 0) scaleX("+(null!=(s=null==h?void 0:h.scaleX)?s:1)+") scaleY("+(null!=(l=null==h?void 0:h.scaleY)?l:1)}}):I}))),p={sideEffects:o.defaultDropAnimationSideEffects({styles:{active:{opacity:"0.5"}}})},v={draggable:"\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},g={restrictToVerticalAxis:l.restrictToVerticalAxis,restrictToWindowEdges:l.restrictToWindowEdges,restrictToHorizontalAxis:l.restrictToHorizontalAxis,restrictToParentElement:l.restrictToParentElement,restrictToFirstScrollableAncestor:l.restrictToFirstScrollableAncestor};function y(e){var a,s=e.className,l=e.style,d=e.activationConstraint,u=e.animateLayoutChanges,c=e.adjustScale,m=void 0!==c&&c,y=e.collisionDetection,S=void 0===y?o.closestCenter:y,h=e.coordinateGetter,x=void 0===h?i.sortableKeyboardCoordinates:h,I=e.dropAnimation,E=void 0===I?p:I,C=e.getNewIndex,w=e.rowKey,O=void 0===w?function(e){return e.id}:w,D=e.items,N=void 0===D?[]:D,P=e.measuring,T=e.modifiers,A=e.renderItem,k=e.reorderItems,j=void 0===k?i.arrayMove:k,R=e.strategy,q=void 0===R?i.rectSortingStrategy:R,H=e.useDragOverlay,B=void 0===H||H,V=e.modifierNames,W=e.themeResetClass,L=e.onReorder;T=null!=(a=T)?a:(null!=V?V:[]).map((function(e){return g[e]}));var z=t.useState((function(){return N})),K=z[0],M=z[1];t.useEffect((function(){M(N)}),[N]);var F=t.useState(null),G=F[0],X=F[1],Y=o.useSensors(o.useSensor(o.MouseSensor,{activationConstraint:d}),o.useSensor(o.TouchSensor,{activationConstraint:d}),o.useSensor(o.KeyboardSensor,{scrollBehavior:"Cypress"in globalThis?"auto":void 0,coordinateGetter:x})),$=t.useRef(!0),_=function(e){return K.findIndex((function(t){return O(t)===e}))},U=function(e){return _(e)+1},Z=G?_(G):-1,J={onDragStart:function(e){var t=e.active.id;return"Picked up sortable item "+String(t)+". Sortable item "+t+" is in position "+U(t)+" of "+K.length},onDragOver:function(e){var t=e.over;if(!0!==$.current)return t?"Sortable item "+e.active.id+" was moved into position "+U(t.id)+" of "+K.length:void 0;$.current=!1},onDragEnd:function(e){var t=e.over;if(t)return"Sortable item "+e.active.id+" was dropped at position "+U(t.id)+" of "+K.length},onDragCancel:function(e){var t=e.active.id;return"Sorting was cancelled. Sortable item "+t+" was dropped and returned to position "+U(t)+" of "+K.length+"."}};return t.useEffect((function(){G||($.current=!0)}),[G]),r.createElement("div",{className:s,style:l},r.createElement(o.DndContext,{accessibility:{announcements:J,screenReaderInstructions:v},sensors:Y,collisionDetection:S,onDragStart:function(e){var t=e.active;t&&X(t.id)},onDragEnd:function(e){var t=e.over;if(X(null),t){var r=_(t.id),n=j(K,Z,r);null==L||L(Z,r,n,K),Z!==r&&M((function(e){return n}))}},onDragCancel:function(){return X(null)},measuring:P,modifiers:T},r.createElement(i.SortableContext,{items:K.map(O),strategy:q},K.map((function(e,t){return r.createElement(b,{key:O(e),id:O(e),value:e,index:t,renderItem:A,animateLayoutChanges:u,useDragOverlay:B,getNewIndex:C})}))),B&&"undefined"!=typeof document?n.createPortal(r.createElement(o.DragOverlay,{adjustScale:m,dropAnimation:E},G?r.createElement(f,{index:Z,value:K[Z],renderItem:function(){return r.createElement("div",{className:W},A.apply(void 0,arguments))},dragOverlay:!0}):null),document.body):null))}function b(e){var t=e.id,n=e.value,a=e.index,o=e.renderItem,l=e.useDragOverlay,d=i.useSortable({id:t,animateLayoutChanges:e.animateLayoutChanges,getNewIndex:e.getNewIndex}),u=d.isDragging;return r.createElement(s.DataProvider,{hidden:!0,name:"sortableItem",data:d},r.createElement(f,Object.assign({ref:d.setNodeRef,value:n,dragging:u,sorting:d.isSorting,renderItem:o,index:a,transform:d.transform,transition:d.transition,listeners:d.listeners,"data-index":a,"data-id":t,dragOverlay:!l&&u},d.attributes)))}function S(e){var n=e.children,o=s.useSelector("sortableItem"),i=r.Children.toArray(n)[0];return a.isElement(i)?t.cloneElement(i,u({},null==o?void 0:o.listeners,{ref:null==o?void 0:o.setActivatorNodeRef,tabIndex:0})):null}function h(e){c(e,S,{name:"SortableHandle",props:{children:{type:"slot",defaultValue:{type:"text",value:"Handle"},mergeWithParent:!0}},importPath:"@plasmicpkgs/dnd-kit",importName:"SortableHandle"}),c(e,y,{name:"Sortable",props:{items:{type:"array",defaultValue:[{id:1,name:"hello"},{id:2,name:"world"}]},modifierNames:{displayName:"Options",type:"choice",multiSelect:!0,options:Object.keys(g).map((function(e){return{value:e,label:e[0].toUpperCase()+e.slice(1).replace(/([a-z])([A-Z])/g,"$1 $2")}}))},onReorder:{type:"eventHandler",argTypes:[{name:"fromIndex",type:"number"},{name:"toIndex",type:"number"},{name:"newItems",type:"object"},{name:"oldItems",type:"object"}]},themeResetClass:{type:"themeResetClass"},renderItem:{type:"slot",renderPropParams:["sortableData","currentItem"],mergeWithParent:!0,defaultValue:{type:"hbox",children:[{type:"text",value:"Item"},{type:"component",name:"SortableHandle"}]}}},importPath:"@plasmicpkgs/dnd-kit",importName:"Sortable"})}exports.Item=f,exports.Sortable=y,exports.SortableHandle=S,exports.SortableItem=b,exports.modifierByName=g,exports.registerAll=function(e){h(e)},exports.registerSortable=h;
2
+ //# sourceMappingURL=dnd-kit.cjs.production.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dnd-kit.cjs.production.min.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","isDragging","DataProvider","hidden","data","setNodeRef","isSorting","attributes","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","props","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toUpperCase","slice","replace","argTypes","renderPropParams"],"mappings":"4mBAcgBA,EACdC,EACAC,EACAC,GAEIF,EACFA,EAAOG,kBAAkBF,EAAWC,GAEpCC,EAAkBF,EAAWC,4KCgEpBE,EAAOC,EAAMC,KACxBD,EAAME,YACJ,SAAAC,EAmBEC,eAhBEC,EAAWF,EAAXE,YACAC,EAAQH,EAARG,SACAC,EACMJ,EAANK,OACAC,EACKN,EAALO,MACAC,EAASR,EAATQ,UAASC,EAAAT,EACTU,WAAAA,WAAUD,EAAG,WAAA,OAAMZ,6BAAOY,EAC1BE,EAAOX,EAAPW,QACAC,EAAKZ,EAALY,MACAC,EAAUb,EAAVa,WACAC,EAASd,EAATc,UACAC,EAAKf,EAALe,0IAEQC,CAAAhB,EAAAiB,GAIVC,aAAU,WACR,GAAKhB,EAML,OAFAiB,SAASC,KAAKR,MAAMS,OAAS,WAEtB,WACLF,SAASC,KAAKR,MAAMS,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QAASC,OAAOC,KAAK3H,GAAgB4C,KAAI,SAACgF,GAAC,MAAM,CAC/CzJ,MAAOyJ,EACPC,MACED,EAAE,GAAGE,cAAgBF,EAAEG,MAAM,GAAGC,QAAQ,kBAAmB,cAGjEtF,UAAW,CACTwE,KAAM,eACNe,SAAU,CACR,CACEpF,KAAM,YACNqE,KAAM,UAER,CACErE,KAAM,UACNqE,KAAM,UAER,CACErE,KAAM,WACNqE,KAAM,UAER,CACErE,KAAM,WACNqE,KAAM,YAIZzE,gBAAiB,CACfyE,KAAM,mBAERpJ,WAAY,CACVoJ,KAAM,OACNgB,iBAAkB,CAAC,eAAgB,eACnCd,iBAAiB,EACjBD,aAAc,CACZD,KAAM,OACNT,SAAU,CACR,CACES,KAAM,OACN/I,MAAO,QAET,CACE+I,KAAM,YACNrE,KAAM,sBAMhBwE,WAAY,uBACZC,WAAY,qJCniBY1K,GAC1BoK,EAAiBpK"}
@@ -0,0 +1,406 @@
1
+ import React, { useEffect, cloneElement, useState, useRef } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { isElement } from 'react-dom/test-utils';
4
+ import { useSensors, useSensor, MouseSensor, TouchSensor, KeyboardSensor, DndContext, DragOverlay, closestCenter, defaultDropAnimationSideEffects } from '@dnd-kit/core';
5
+ import { SortableContext, useSortable, sortableKeyboardCoordinates, arrayMove, rectSortingStrategy } from '@dnd-kit/sortable';
6
+ import { DataProvider, useSelector } from '@plasmicapp/host';
7
+ import { restrictToVerticalAxis, restrictToWindowEdges, restrictToHorizontalAxis, restrictToParentElement, restrictToFirstScrollableAncestor } from '@dnd-kit/modifiers';
8
+ import registerComponent from '@plasmicapp/host/registerComponent';
9
+
10
+ function _extends() {
11
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
12
+ for (var e = 1; e < arguments.length; e++) {
13
+ var t = arguments[e];
14
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
15
+ }
16
+ return n;
17
+ }, _extends.apply(null, arguments);
18
+ }
19
+ function _objectWithoutPropertiesLoose(r, e) {
20
+ if (null == r) return {};
21
+ var t = {};
22
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
23
+ if (-1 !== e.indexOf(n)) continue;
24
+ t[n] = r[n];
25
+ }
26
+ return t;
27
+ }
28
+
29
+ function registerComponentHelper(loader, component, meta) {
30
+ if (loader) {
31
+ loader.registerComponent(component, meta);
32
+ } else {
33
+ registerComponent(component, meta);
34
+ }
35
+ }
36
+
37
+ var _excluded = ["color", "dragOverlay", "dragging", "disabled", "fadeIn", "height", "index", "listeners", "renderItem", "sorting", "style", "transition", "transform", "value", "wrapperStyle"];
38
+ var Item = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (_ref, ref) {
39
+ var _transform$x, _transform$y, _transform$scaleX, _transform$scaleY;
40
+ var dragOverlay = _ref.dragOverlay,
41
+ dragging = _ref.dragging,
42
+ fadeIn = _ref.fadeIn,
43
+ index = _ref.index,
44
+ listeners = _ref.listeners,
45
+ _ref$renderItem = _ref.renderItem,
46
+ renderItem = _ref$renderItem === void 0 ? function () {
47
+ return React.createElement("div", null);
48
+ } : _ref$renderItem,
49
+ sorting = _ref.sorting,
50
+ style = _ref.style,
51
+ transition = _ref.transition,
52
+ transform = _ref.transform,
53
+ value = _ref.value,
54
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
55
+ useEffect(function () {
56
+ if (!dragOverlay) {
57
+ return;
58
+ }
59
+ document.body.style.cursor = "grabbing";
60
+ return function () {
61
+ document.body.style.cursor = "";
62
+ };
63
+ }, [dragOverlay]);
64
+ var child = renderItem({
65
+ dragOverlay: Boolean(dragOverlay),
66
+ dragging: Boolean(dragging),
67
+ sorting: Boolean(sorting),
68
+ index: index,
69
+ fadeIn: Boolean(fadeIn),
70
+ listeners: listeners,
71
+ ref: ref,
72
+ style: style,
73
+ transform: transform,
74
+ transition: transition,
75
+ value: value
76
+ }, value);
77
+ return isElement(child) ? cloneElement(child, {
78
+ ref: ref,
79
+ style: {
80
+ transition: [transition].filter(Boolean).join(", "),
81
+ transform: "translate3d(" + ((_transform$x = transform == null ? void 0 : transform.x) != null ? _transform$x : 0) + "px, " + ((_transform$y = transform == null ? void 0 : transform.y) != null ? _transform$y : 0) + "px, 0) scaleX(" + ((_transform$scaleX = transform == null ? void 0 : transform.scaleX) != null ? _transform$scaleX : 1) + ") scaleY(" + ((_transform$scaleY = transform == null ? void 0 : transform.scaleY) != null ? _transform$scaleY : 1)
82
+ }
83
+ }) : child;
84
+ }));
85
+ var dropAnimationConfig = {
86
+ sideEffects: /*#__PURE__*/defaultDropAnimationSideEffects({
87
+ styles: {
88
+ active: {
89
+ opacity: "0.5"
90
+ }
91
+ }
92
+ })
93
+ };
94
+ var screenReaderInstructions = {
95
+ draggable: "\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "
96
+ };
97
+ var modifierByName = {
98
+ restrictToVerticalAxis: restrictToVerticalAxis,
99
+ restrictToWindowEdges: restrictToWindowEdges,
100
+ restrictToHorizontalAxis: restrictToHorizontalAxis,
101
+ restrictToParentElement: restrictToParentElement,
102
+ restrictToFirstScrollableAncestor: restrictToFirstScrollableAncestor
103
+ };
104
+ function Sortable(_ref2) {
105
+ var _modifiers;
106
+ var className = _ref2.className,
107
+ style = _ref2.style,
108
+ activationConstraint = _ref2.activationConstraint,
109
+ animateLayoutChanges = _ref2.animateLayoutChanges,
110
+ _ref2$adjustScale = _ref2.adjustScale,
111
+ adjustScale = _ref2$adjustScale === void 0 ? false : _ref2$adjustScale,
112
+ _ref2$collisionDetect = _ref2.collisionDetection,
113
+ collisionDetection = _ref2$collisionDetect === void 0 ? closestCenter : _ref2$collisionDetect,
114
+ _ref2$coordinateGette = _ref2.coordinateGetter,
115
+ coordinateGetter = _ref2$coordinateGette === void 0 ? sortableKeyboardCoordinates : _ref2$coordinateGette,
116
+ _ref2$dropAnimation = _ref2.dropAnimation,
117
+ dropAnimation = _ref2$dropAnimation === void 0 ? dropAnimationConfig : _ref2$dropAnimation,
118
+ getNewIndex = _ref2.getNewIndex,
119
+ _ref2$rowKey = _ref2.rowKey,
120
+ rowKey = _ref2$rowKey === void 0 ? function (item) {
121
+ return item.id;
122
+ } : _ref2$rowKey,
123
+ _ref2$items = _ref2.items,
124
+ initialItems = _ref2$items === void 0 ? [] : _ref2$items,
125
+ measuring = _ref2.measuring,
126
+ modifiers = _ref2.modifiers,
127
+ _renderItem = _ref2.renderItem,
128
+ _ref2$reorderItems = _ref2.reorderItems,
129
+ reorderItems = _ref2$reorderItems === void 0 ? arrayMove : _ref2$reorderItems,
130
+ _ref2$strategy = _ref2.strategy,
131
+ strategy = _ref2$strategy === void 0 ? rectSortingStrategy : _ref2$strategy,
132
+ _ref2$useDragOverlay = _ref2.useDragOverlay,
133
+ useDragOverlay = _ref2$useDragOverlay === void 0 ? true : _ref2$useDragOverlay,
134
+ modifierNames = _ref2.modifierNames,
135
+ themeResetClass = _ref2.themeResetClass,
136
+ onReorder = _ref2.onReorder;
137
+ modifiers = (_modifiers = modifiers) != null ? _modifiers : (modifierNames != null ? modifierNames : []).map(function (name) {
138
+ return modifierByName[name];
139
+ });
140
+ // This is the optimistic version.
141
+ var _useState = useState(function () {
142
+ return initialItems;
143
+ }),
144
+ items = _useState[0],
145
+ setItems = _useState[1];
146
+ useEffect(function () {
147
+ setItems(initialItems);
148
+ }, [initialItems]);
149
+ var _useState2 = useState(null),
150
+ activeId = _useState2[0],
151
+ setActiveId = _useState2[1];
152
+ var sensors = useSensors(useSensor(MouseSensor, {
153
+ activationConstraint: activationConstraint
154
+ }), useSensor(TouchSensor, {
155
+ activationConstraint: activationConstraint
156
+ }), useSensor(KeyboardSensor, {
157
+ // Disable smooth scrolling in Cypress automated tests
158
+ scrollBehavior: "Cypress" in globalThis ? "auto" : undefined,
159
+ coordinateGetter: coordinateGetter
160
+ }));
161
+ var isFirstAnnouncement = useRef(true);
162
+ var getIndex = function getIndex(id) {
163
+ return items.findIndex(function (item) {
164
+ return rowKey(item) === id;
165
+ });
166
+ };
167
+ var getPosition = function getPosition(id) {
168
+ return getIndex(id) + 1;
169
+ };
170
+ var activeIndex = activeId ? getIndex(activeId) : -1;
171
+ var announcements = {
172
+ onDragStart: function onDragStart(_ref3) {
173
+ var id = _ref3.active.id;
174
+ return "Picked up sortable item " + String(id) + ". Sortable item " + id + " is in position " + getPosition(id) + " of " + items.length;
175
+ },
176
+ onDragOver: function onDragOver(_ref4) {
177
+ var active = _ref4.active,
178
+ over = _ref4.over;
179
+ // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.
180
+ // The first `onDragOver` event therefore doesn't need to be announced, because it is called
181
+ // immediately after the `onDragStart` announcement and is redundant.
182
+ if (isFirstAnnouncement.current === true) {
183
+ isFirstAnnouncement.current = false;
184
+ return;
185
+ }
186
+ if (over) {
187
+ return "Sortable item " + active.id + " was moved into position " + getPosition(over.id) + " of " + items.length;
188
+ }
189
+ return;
190
+ },
191
+ onDragEnd: function onDragEnd(_ref5) {
192
+ var active = _ref5.active,
193
+ over = _ref5.over;
194
+ if (over) {
195
+ return "Sortable item " + active.id + " was dropped at position " + getPosition(over.id) + " of " + items.length;
196
+ }
197
+ return;
198
+ },
199
+ onDragCancel: function onDragCancel(_ref6) {
200
+ var id = _ref6.active.id;
201
+ return "Sorting was cancelled. Sortable item " + id + " was dropped and returned to position " + getPosition(id) + " of " + items.length + ".";
202
+ }
203
+ };
204
+ useEffect(function () {
205
+ if (!activeId) {
206
+ isFirstAnnouncement.current = true;
207
+ }
208
+ }, [activeId]);
209
+ return React.createElement("div", {
210
+ className: className,
211
+ style: style
212
+ }, React.createElement(DndContext, {
213
+ accessibility: {
214
+ announcements: announcements,
215
+ screenReaderInstructions: screenReaderInstructions
216
+ },
217
+ sensors: sensors,
218
+ collisionDetection: collisionDetection,
219
+ onDragStart: function onDragStart(_ref7) {
220
+ var active = _ref7.active;
221
+ if (!active) {
222
+ return;
223
+ }
224
+ setActiveId(active.id);
225
+ },
226
+ onDragEnd: function onDragEnd(_ref8) {
227
+ var over = _ref8.over;
228
+ setActiveId(null);
229
+ if (over) {
230
+ var overIndex = getIndex(over.id);
231
+ var reordered = reorderItems(items, activeIndex, overIndex);
232
+ onReorder == null || onReorder(activeIndex, overIndex, reordered, items);
233
+ if (activeIndex !== overIndex) {
234
+ setItems(function (items) {
235
+ return reordered;
236
+ });
237
+ }
238
+ }
239
+ },
240
+ onDragCancel: function onDragCancel() {
241
+ return setActiveId(null);
242
+ },
243
+ measuring: measuring,
244
+ modifiers: modifiers
245
+ }, React.createElement(SortableContext, {
246
+ items: items.map(rowKey),
247
+ strategy: strategy
248
+ }, items.map(function (value, index) {
249
+ return React.createElement(SortableItem, {
250
+ key: rowKey(value),
251
+ id: rowKey(value),
252
+ value: value,
253
+ index: index,
254
+ renderItem: _renderItem,
255
+ animateLayoutChanges: animateLayoutChanges,
256
+ useDragOverlay: useDragOverlay,
257
+ getNewIndex: getNewIndex
258
+ });
259
+ })), useDragOverlay && typeof document !== "undefined" ? createPortal(React.createElement(DragOverlay, {
260
+ adjustScale: adjustScale,
261
+ dropAnimation: dropAnimation
262
+ }, activeId ? React.createElement(Item, {
263
+ index: activeIndex,
264
+ value: items[activeIndex],
265
+ renderItem: function renderItem() {
266
+ return React.createElement("div", {
267
+ className: themeResetClass
268
+ }, _renderItem.apply(void 0, arguments));
269
+ },
270
+ dragOverlay: true
271
+ }) : null), document.body) : null));
272
+ }
273
+ function SortableItem(_ref9) {
274
+ var animateLayoutChanges = _ref9.animateLayoutChanges,
275
+ getNewIndex = _ref9.getNewIndex,
276
+ id = _ref9.id,
277
+ value = _ref9.value,
278
+ index = _ref9.index,
279
+ renderItem = _ref9.renderItem,
280
+ useDragOverlay = _ref9.useDragOverlay;
281
+ var sortableData = useSortable({
282
+ id: id,
283
+ animateLayoutChanges: animateLayoutChanges,
284
+ getNewIndex: getNewIndex
285
+ });
286
+ var attributes = sortableData.attributes,
287
+ isDragging = sortableData.isDragging,
288
+ isSorting = sortableData.isSorting,
289
+ listeners = sortableData.listeners,
290
+ setNodeRef = sortableData.setNodeRef,
291
+ transform = sortableData.transform,
292
+ transition = sortableData.transition;
293
+ return React.createElement(DataProvider, {
294
+ hidden: true,
295
+ name: "sortableItem",
296
+ data: sortableData
297
+ }, React.createElement(Item, Object.assign({
298
+ ref: setNodeRef,
299
+ value: value,
300
+ dragging: isDragging,
301
+ sorting: isSorting,
302
+ renderItem: renderItem,
303
+ index: index,
304
+ transform: transform,
305
+ transition: transition,
306
+ listeners: listeners,
307
+ "data-index": index,
308
+ "data-id": id,
309
+ dragOverlay: !useDragOverlay && isDragging
310
+ }, attributes)));
311
+ }
312
+ function SortableHandle(_ref10) {
313
+ var children = _ref10.children;
314
+ var data = useSelector("sortableItem");
315
+ var child = React.Children.toArray(children)[0];
316
+ return isElement(child) ? cloneElement(child, _extends({}, data == null ? void 0 : data.listeners, {
317
+ ref: data == null ? void 0 : data.setActivatorNodeRef,
318
+ tabIndex: 0
319
+ })) : null;
320
+ }
321
+ function registerSortable(loader) {
322
+ registerComponentHelper(loader, SortableHandle, {
323
+ name: "SortableHandle",
324
+ props: {
325
+ children: {
326
+ type: "slot",
327
+ defaultValue: {
328
+ type: "text",
329
+ value: "Handle"
330
+ },
331
+ mergeWithParent: true
332
+ }
333
+ },
334
+ importPath: "@plasmicpkgs/dnd-kit",
335
+ importName: "SortableHandle"
336
+ });
337
+ registerComponentHelper(loader, Sortable, {
338
+ name: "Sortable",
339
+ props: {
340
+ items: {
341
+ type: "array",
342
+ defaultValue: [{
343
+ id: 1,
344
+ name: "hello"
345
+ }, {
346
+ id: 2,
347
+ name: "world"
348
+ }]
349
+ },
350
+ modifierNames: {
351
+ displayName: "Options",
352
+ type: "choice",
353
+ multiSelect: true,
354
+ options: Object.keys(modifierByName).map(function (v) {
355
+ return {
356
+ value: v,
357
+ label: v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, "$1 $2")
358
+ };
359
+ })
360
+ },
361
+ onReorder: {
362
+ type: "eventHandler",
363
+ argTypes: [{
364
+ name: "fromIndex",
365
+ type: "number"
366
+ }, {
367
+ name: "toIndex",
368
+ type: "number"
369
+ }, {
370
+ name: "newItems",
371
+ type: "object"
372
+ }, {
373
+ name: "oldItems",
374
+ type: "object"
375
+ }]
376
+ },
377
+ themeResetClass: {
378
+ type: "themeResetClass"
379
+ },
380
+ renderItem: {
381
+ type: "slot",
382
+ renderPropParams: ["sortableData", "currentItem"],
383
+ mergeWithParent: true,
384
+ defaultValue: {
385
+ type: "hbox",
386
+ children: [{
387
+ type: "text",
388
+ value: "Item"
389
+ }, {
390
+ type: "component",
391
+ name: "SortableHandle"
392
+ }]
393
+ }
394
+ }
395
+ },
396
+ importPath: "@plasmicpkgs/dnd-kit",
397
+ importName: "Sortable"
398
+ });
399
+ }
400
+
401
+ function registerAll(loader) {
402
+ registerSortable(loader);
403
+ }
404
+
405
+ export { Item, Sortable, SortableHandle, SortableItem, modifierByName, registerAll, registerSortable };
406
+ //# sourceMappingURL=dnd-kit.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dnd-kit.esm.js","sources":["../src/util.ts","../src/sortable.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n default as registerComponent,\n} from \"@plasmicapp/host/registerComponent\";\nimport { default as registerGlobalContext } from \"@plasmicapp/host/registerGlobalContext\";\nimport { default as registerToken } from \"@plasmicapp/host/registerToken\";\nimport React from \"react\";\n\nexport type Registerable = {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n registerToken: typeof registerToken;\n};\n\nexport function registerComponentHelper<T extends React.ComponentType<any>>(\n loader: Registerable | undefined,\n component: T,\n meta: ComponentMeta<React.ComponentProps<T>>\n) {\n if (loader) {\n loader.registerComponent(component, meta);\n } else {\n registerComponent(component, meta);\n }\n}\n","import React, { cloneElement, useEffect, useRef, useState } from \"react\";\nimport type { Key, ReactElement, ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isElement } from \"react-dom/test-utils\";\nimport {\n closestCenter,\n DragOverlay,\n DndContext,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n defaultDropAnimationSideEffects,\n} from \"@dnd-kit/core\";\nimport type {\n SortingStrategy,\n AnimateLayoutChanges,\n NewIndexGetter,\n} from \"@dnd-kit/sortable\";\nimport {\n arrayMove,\n useSortable,\n SortableContext,\n sortableKeyboardCoordinates,\n rectSortingStrategy,\n} from \"@dnd-kit/sortable\";\n\nimport { DataProvider, useSelector } from \"@plasmicapp/host\";\n\nimport type {\n DraggableSyntheticListeners,\n Active,\n Announcements,\n CollisionDetection,\n DropAnimation,\n KeyboardCoordinateGetter,\n Modifiers,\n MeasuringConfiguration,\n PointerActivationConstraint,\n ScreenReaderInstructions,\n UniqueIdentifier,\n} from \"@dnd-kit/core\";\nimport type { Transform } from \"@dnd-kit/utilities\";\nimport {\n restrictToFirstScrollableAncestor,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from \"@dnd-kit/modifiers\";\nimport { Registerable, registerComponentHelper } from \"./util\";\n\nexport interface ItemProps {\n dragOverlay?: boolean;\n color?: string;\n disabled?: boolean;\n dragging?: boolean;\n height?: number;\n index?: number;\n fadeIn?: boolean;\n transform?: Transform | null;\n listeners?: DraggableSyntheticListeners;\n sorting?: boolean;\n style?: React.CSSProperties;\n transition?: string | null;\n wrapperStyle?: React.CSSProperties;\n value: React.ReactNode;\n renderItem?(\n args: {\n dragOverlay: boolean;\n dragging: boolean;\n sorting: boolean;\n index: number | undefined;\n fadeIn: boolean;\n listeners: DraggableSyntheticListeners;\n ref: React.Ref<HTMLElement>;\n style: React.CSSProperties | undefined;\n transform: ItemProps[\"transform\"];\n transition: ItemProps[\"transition\"];\n value: ItemProps[\"value\"];\n },\n currentItem: ItemProps[\"value\"]\n ): React.ReactElement;\n}\n\nexport const Item = React.memo(\n React.forwardRef<HTMLLIElement, ItemProps>(\n (\n {\n color,\n dragOverlay,\n dragging,\n disabled,\n fadeIn,\n height,\n index,\n listeners,\n renderItem = () => <div />,\n sorting,\n style,\n transition,\n transform,\n value,\n wrapperStyle,\n ...props\n },\n ref\n ) => {\n useEffect(() => {\n if (!dragOverlay) {\n return;\n }\n\n document.body.style.cursor = \"grabbing\";\n\n return () => {\n document.body.style.cursor = \"\";\n };\n }, [dragOverlay]);\n\n const child = renderItem(\n {\n dragOverlay: Boolean(dragOverlay),\n dragging: Boolean(dragging),\n sorting: Boolean(sorting),\n index,\n fadeIn: Boolean(fadeIn),\n listeners,\n ref,\n style,\n transform,\n transition,\n value,\n },\n value\n );\n\n return isElement(child)\n ? cloneElement(child, {\n ref,\n style: {\n transition: [transition].filter(Boolean).join(\", \"),\n transform: `translate3d(${transform?.x ?? 0}px, ${\n transform?.y ?? 0\n }px, 0) scaleX(${transform?.scaleX ?? 1}) scaleY(${\n transform?.scaleY ?? 1\n }`,\n },\n })\n : child;\n }\n )\n);\n\nexport interface SortableProps {\n onReorder?: (\n fromIndex: number,\n toIndex: number,\n newItems: any[],\n oldItems: any[]\n ) => void;\n themeResetClass?: string;\n activationConstraint?: PointerActivationConstraint;\n animateLayoutChanges?: AnimateLayoutChanges;\n adjustScale?: boolean;\n collisionDetection?: CollisionDetection;\n coordinateGetter?: KeyboardCoordinateGetter;\n Container?: any; // To-do: Fix me\n dropAnimation?: DropAnimation | null;\n getNewIndex?: NewIndexGetter;\n rowKey?: (item: any) => Key;\n itemCount?: number;\n items?: any[];\n measuring?: MeasuringConfiguration;\n modifiers?: Modifiers;\n renderItem?: any;\n removable?: boolean;\n reorderItems?: typeof arrayMove;\n strategy?: SortingStrategy;\n style?: React.CSSProperties;\n useDragOverlay?: boolean;\n modifierNames?: (\n | \"restrictToHorizontalAxis\"\n | \"restrictToVerticalAxis\"\n | \"restrictToWindowEdges\"\n | \"restrictToParentElement\"\n | \"restrictToFirstScrollableAncestor\"\n )[];\n getItemStyles?(args: {\n id: UniqueIdentifier;\n index: number;\n isSorting: boolean;\n isDragOverlay: boolean;\n overIndex: number;\n isDragging: boolean;\n }): React.CSSProperties;\n wrapperStyle?(args: {\n active: Pick<Active, \"id\"> | null;\n index: number;\n isDragging: boolean;\n id: UniqueIdentifier;\n }): React.CSSProperties;\n isDisabled?(id: UniqueIdentifier): boolean;\n className?: string;\n}\n\nconst dropAnimationConfig: DropAnimation = {\n sideEffects: defaultDropAnimationSideEffects({\n styles: {\n active: {\n opacity: \"0.5\",\n },\n },\n }),\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable: `\n To pick up a sortable item, press the space bar.\n While sorting, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n `,\n};\n\nexport const modifierByName = {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n restrictToHorizontalAxis,\n restrictToParentElement,\n restrictToFirstScrollableAncestor,\n};\n\nexport function Sortable({\n className,\n style,\n activationConstraint,\n animateLayoutChanges,\n adjustScale = false,\n collisionDetection = closestCenter,\n coordinateGetter = sortableKeyboardCoordinates,\n dropAnimation = dropAnimationConfig,\n getNewIndex,\n rowKey = (item) => item.id,\n items: initialItems = [],\n measuring,\n modifiers,\n removable,\n renderItem,\n reorderItems = arrayMove,\n strategy = rectSortingStrategy,\n useDragOverlay = true,\n modifierNames,\n themeResetClass,\n onReorder,\n}: SortableProps) {\n modifiers =\n modifiers ?? (modifierNames ?? []).map((name) => modifierByName[name]);\n\n // This is the optimistic version.\n const [items, setItems] = useState<UniqueIdentifier[]>(() => initialItems);\n useEffect(() => {\n setItems(initialItems);\n }, [initialItems]);\n const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n const sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint,\n }),\n useSensor(TouchSensor, {\n activationConstraint,\n }),\n useSensor(KeyboardSensor, {\n // Disable smooth scrolling in Cypress automated tests\n scrollBehavior: \"Cypress\" in globalThis ? \"auto\" : undefined,\n coordinateGetter,\n })\n );\n const isFirstAnnouncement = useRef(true);\n const getIndex = (id: UniqueIdentifier) =>\n items.findIndex((item) => rowKey(item) === id);\n const getPosition = (id: UniqueIdentifier) => getIndex(id) + 1;\n const activeIndex = activeId ? getIndex(activeId) : -1;\n const announcements: Announcements = {\n onDragStart({ active: { id } }) {\n return `Picked up sortable item ${String(\n id\n )}. Sortable item ${id} is in position ${getPosition(id)} of ${\n items.length\n }`;\n },\n onDragOver({ active, over }) {\n // In this specific use-case, the picked up item's `id` is always the same as the first `over` id.\n // The first `onDragOver` event therefore doesn't need to be announced, because it is called\n // immediately after the `onDragStart` announcement and is redundant.\n if (isFirstAnnouncement.current === true) {\n isFirstAnnouncement.current = false;\n return;\n }\n\n if (over) {\n return `Sortable item ${\n active.id\n } was moved into position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragEnd({ active, over }) {\n if (over) {\n return `Sortable item ${\n active.id\n } was dropped at position ${getPosition(over.id)} of ${items.length}`;\n }\n\n return;\n },\n onDragCancel({ active: { id } }) {\n return `Sorting was cancelled. Sortable item ${id} was dropped and returned to position ${getPosition(\n id\n )} of ${items.length}.`;\n },\n };\n useEffect(() => {\n if (!activeId) {\n isFirstAnnouncement.current = true;\n }\n }, [activeId]);\n\n return (\n <div className={className} style={style}>\n <DndContext\n accessibility={{\n announcements,\n screenReaderInstructions,\n }}\n sensors={sensors}\n collisionDetection={collisionDetection}\n onDragStart={({ active }) => {\n if (!active) {\n return;\n }\n\n setActiveId(active.id);\n }}\n onDragEnd={({ over }) => {\n setActiveId(null);\n\n if (over) {\n const overIndex = getIndex(over.id);\n const reordered = reorderItems(items, activeIndex, overIndex);\n onReorder?.(activeIndex, overIndex, reordered, items);\n if (activeIndex !== overIndex) {\n setItems((items) => reordered);\n }\n }\n }}\n onDragCancel={() => setActiveId(null)}\n measuring={measuring}\n modifiers={modifiers}\n >\n <SortableContext items={items.map(rowKey)} strategy={strategy}>\n {items.map((value, index) => (\n <SortableItem\n key={rowKey(value)}\n id={rowKey(value)}\n value={value}\n index={index}\n renderItem={renderItem}\n animateLayoutChanges={animateLayoutChanges}\n useDragOverlay={useDragOverlay}\n getNewIndex={getNewIndex}\n />\n ))}\n </SortableContext>\n {useDragOverlay && typeof document !== \"undefined\"\n ? createPortal(\n <DragOverlay\n adjustScale={adjustScale}\n dropAnimation={dropAnimation}\n >\n {activeId ? (\n <Item\n index={activeIndex}\n value={items[activeIndex]}\n renderItem={(...args) => (\n <div className={themeResetClass}>\n {renderItem(...args)}\n </div>\n )}\n dragOverlay\n />\n ) : null}\n </DragOverlay>,\n document.body\n )\n : null}\n </DndContext>\n </div>\n );\n}\n\ninterface SortableItemProps {\n animateLayoutChanges?: AnimateLayoutChanges;\n getNewIndex?: NewIndexGetter;\n id: UniqueIdentifier;\n index: number;\n useDragOverlay?: boolean;\n renderItem?(args: any): React.ReactElement;\n value?: any;\n}\n\nexport function SortableItem({\n animateLayoutChanges,\n getNewIndex,\n id,\n value,\n index,\n renderItem,\n useDragOverlay,\n}: SortableItemProps) {\n const sortableData = useSortable({\n id,\n animateLayoutChanges,\n getNewIndex,\n });\n const {\n attributes,\n isDragging,\n isSorting,\n listeners,\n setNodeRef,\n transform,\n transition,\n } = sortableData;\n\n return (\n <DataProvider hidden={true} name={\"sortableItem\"} data={sortableData}>\n <Item\n ref={setNodeRef}\n value={value}\n dragging={isDragging}\n sorting={isSorting}\n renderItem={renderItem}\n index={index}\n transform={transform}\n transition={transition}\n listeners={listeners}\n data-index={index}\n data-id={id}\n dragOverlay={!useDragOverlay && isDragging}\n {...attributes}\n />\n </DataProvider>\n );\n}\n\nexport function SortableHandle({ children }: { children?: ReactNode }) {\n const data = useSelector(\"sortableItem\");\n const child = React.Children.toArray(children)[0];\n return isElement(child)\n ? cloneElement(child as ReactElement, {\n ...data?.listeners,\n ref: data?.setActivatorNodeRef,\n tabIndex: 0,\n })\n : null;\n}\n\nexport function registerSortable(loader?: Registerable) {\n registerComponentHelper(loader, SortableHandle, {\n name: \"SortableHandle\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"text\",\n value: \"Handle\",\n },\n mergeWithParent: true,\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"SortableHandle\",\n });\n\n registerComponentHelper(loader, Sortable, {\n name: \"Sortable\",\n props: {\n items: {\n type: \"array\",\n defaultValue: [\n { id: 1, name: \"hello\" },\n { id: 2, name: \"world\" },\n ],\n },\n modifierNames: {\n displayName: \"Options\",\n type: \"choice\",\n multiSelect: true,\n options: Object.keys(modifierByName).map((v) => ({\n value: v,\n label:\n v[0].toUpperCase() + v.slice(1).replace(/([a-z])([A-Z])/g, \"$1 $2\"),\n })),\n },\n onReorder: {\n type: \"eventHandler\",\n argTypes: [\n {\n name: \"fromIndex\",\n type: \"number\",\n },\n {\n name: \"toIndex\",\n type: \"number\",\n },\n {\n name: \"newItems\",\n type: \"object\",\n },\n {\n name: \"oldItems\",\n type: \"object\",\n },\n ],\n },\n themeResetClass: {\n type: \"themeResetClass\",\n },\n renderItem: {\n type: \"slot\",\n renderPropParams: [\"sortableData\", \"currentItem\"],\n mergeWithParent: true,\n defaultValue: {\n type: \"hbox\",\n children: [\n {\n type: \"text\",\n value: \"Item\",\n },\n {\n type: \"component\",\n name: \"SortableHandle\",\n },\n ],\n },\n } as any,\n },\n importPath: \"@plasmicpkgs/dnd-kit\",\n importName: \"Sortable\",\n });\n}\n","import { registerSortable } from \"./sortable\";\nimport { Registerable } from \"./util\";\n\nexport function registerAll(loader?: Registerable) {\n registerSortable(loader);\n}\n\nexport * from \"./sortable\";\n"],"names":["registerComponentHelper","loader","component","meta","registerComponent","Item","React","memo","forwardRef","_ref","ref","dragOverlay","dragging","disabled","fadeIn","height","index","listeners","_ref$renderItem","renderItem","sorting","style","transition","transform","value","wrapperStyle","props","_objectWithoutPropertiesLoose","_excluded","useEffect","document","body","cursor","child","Boolean","isElement","cloneElement","filter","join","_transform$x","x","_transform$y","y","_transform$scaleX","scaleX","_transform$scaleY","scaleY","dropAnimationConfig","sideEffects","defaultDropAnimationSideEffects","styles","active","opacity","screenReaderInstructions","draggable","modifierByName","restrictToVerticalAxis","restrictToWindowEdges","restrictToHorizontalAxis","restrictToParentElement","restrictToFirstScrollableAncestor","Sortable","_ref2","className","activationConstraint","animateLayoutChanges","_ref2$adjustScale","adjustScale","_ref2$collisionDetect","collisionDetection","closestCenter","_ref2$coordinateGette","coordinateGetter","sortableKeyboardCoordinates","_ref2$dropAnimation","dropAnimation","getNewIndex","_ref2$rowKey","rowKey","item","id","_ref2$items","items","initialItems","measuring","modifiers","removable","_ref2$reorderItems","reorderItems","arrayMove","_ref2$strategy","strategy","rectSortingStrategy","_ref2$useDragOverlay","useDragOverlay","modifierNames","themeResetClass","onReorder","_modifiers","map","name","_useState","useState","setItems","_useState2","activeId","setActiveId","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","scrollBehavior","globalThis","undefined","isFirstAnnouncement","useRef","getIndex","findIndex","getPosition","activeIndex","announcements","onDragStart","_ref3","String","length","onDragOver","_ref4","over","current","onDragEnd","_ref5","onDragCancel","_ref6","DndContext","accessibility","_ref7","_ref8","overIndex","reordered","SortableContext","SortableItem","key","createPortal","DragOverlay","apply","arguments","_ref9","sortableData","useSortable","attributes","isDragging","isSorting","setNodeRef","DataProvider","hidden","data","SortableHandle","_ref10","children","useSelector","Children","toArray","_extends","setActivatorNodeRef","tabIndex","registerSortable","type","defaultValue","mergeWithParent","importPath","importName","displayName","multiSelect","options","Object","keys","v","label","toUpperCase","slice","replace","argTypes","renderPropParams","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;SAcgBA,uBAAuBA,CACrCC,MAAgC,EAChCC,SAAY,EACZC,IAA4C;EAE5C,IAAIF,MAAM,EAAE;IACVA,MAAM,CAACG,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;GAC1C,MAAM;IACLC,iBAAiB,CAACF,SAAS,EAAEC,IAAI,CAAC;;AAEtC;;;ACxBA,I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QACZgB,gBAAgB,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;QACjDd,eAAe,EAAE,IAAI;QACrBD,YAAY,EAAE;UACZD,IAAI,EAAE,MAAM;UACZR,QAAQ,EAAE,CACR;YACEQ,IAAI,EAAE,MAAM;YACZhJ,KAAK,EAAE;WACR,EACD;YACEgJ,IAAI,EAAE,WAAW;YACjBpE,IAAI,EAAE;WACP;;;KAIR;IACDuE,UAAU,EAAE,sBAAsB;IAClCC,UAAU,EAAE;GACb,CAAC;AACJ;;SCriBgBa,WAAWA,CAACxL,MAAqB;EAC/CsK,gBAAgB,CAACtK,MAAM,CAAC;AAC1B;;;;"}
@@ -0,0 +1,3 @@
1
+ import { Registerable } from "./util";
2
+ export declare function registerAll(loader?: Registerable): void;
3
+ export * from "./sortable";
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./dnd-kit.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./dnd-kit.cjs.development.js')
8
+ }
@@ -0,0 +1,100 @@
1
+ import React from "react";
2
+ import type { Key, ReactNode } from "react";
3
+ import type { SortingStrategy, AnimateLayoutChanges, NewIndexGetter } from "@dnd-kit/sortable";
4
+ import { arrayMove } from "@dnd-kit/sortable";
5
+ import type { DraggableSyntheticListeners, Active, CollisionDetection, DropAnimation, KeyboardCoordinateGetter, Modifiers, MeasuringConfiguration, PointerActivationConstraint, UniqueIdentifier } from "@dnd-kit/core";
6
+ import type { Transform } from "@dnd-kit/utilities";
7
+ import { Registerable } from "./util";
8
+ export interface ItemProps {
9
+ dragOverlay?: boolean;
10
+ color?: string;
11
+ disabled?: boolean;
12
+ dragging?: boolean;
13
+ height?: number;
14
+ index?: number;
15
+ fadeIn?: boolean;
16
+ transform?: Transform | null;
17
+ listeners?: DraggableSyntheticListeners;
18
+ sorting?: boolean;
19
+ style?: React.CSSProperties;
20
+ transition?: string | null;
21
+ wrapperStyle?: React.CSSProperties;
22
+ value: React.ReactNode;
23
+ renderItem?(args: {
24
+ dragOverlay: boolean;
25
+ dragging: boolean;
26
+ sorting: boolean;
27
+ index: number | undefined;
28
+ fadeIn: boolean;
29
+ listeners: DraggableSyntheticListeners;
30
+ ref: React.Ref<HTMLElement>;
31
+ style: React.CSSProperties | undefined;
32
+ transform: ItemProps["transform"];
33
+ transition: ItemProps["transition"];
34
+ value: ItemProps["value"];
35
+ }, currentItem: ItemProps["value"]): React.ReactElement;
36
+ }
37
+ export declare const Item: React.MemoExoticComponent<React.ForwardRefExoticComponent<ItemProps & React.RefAttributes<HTMLLIElement>>>;
38
+ export interface SortableProps {
39
+ onReorder?: (fromIndex: number, toIndex: number, newItems: any[], oldItems: any[]) => void;
40
+ themeResetClass?: string;
41
+ activationConstraint?: PointerActivationConstraint;
42
+ animateLayoutChanges?: AnimateLayoutChanges;
43
+ adjustScale?: boolean;
44
+ collisionDetection?: CollisionDetection;
45
+ coordinateGetter?: KeyboardCoordinateGetter;
46
+ Container?: any;
47
+ dropAnimation?: DropAnimation | null;
48
+ getNewIndex?: NewIndexGetter;
49
+ rowKey?: (item: any) => Key;
50
+ itemCount?: number;
51
+ items?: any[];
52
+ measuring?: MeasuringConfiguration;
53
+ modifiers?: Modifiers;
54
+ renderItem?: any;
55
+ removable?: boolean;
56
+ reorderItems?: typeof arrayMove;
57
+ strategy?: SortingStrategy;
58
+ style?: React.CSSProperties;
59
+ useDragOverlay?: boolean;
60
+ modifierNames?: ("restrictToHorizontalAxis" | "restrictToVerticalAxis" | "restrictToWindowEdges" | "restrictToParentElement" | "restrictToFirstScrollableAncestor")[];
61
+ getItemStyles?(args: {
62
+ id: UniqueIdentifier;
63
+ index: number;
64
+ isSorting: boolean;
65
+ isDragOverlay: boolean;
66
+ overIndex: number;
67
+ isDragging: boolean;
68
+ }): React.CSSProperties;
69
+ wrapperStyle?(args: {
70
+ active: Pick<Active, "id"> | null;
71
+ index: number;
72
+ isDragging: boolean;
73
+ id: UniqueIdentifier;
74
+ }): React.CSSProperties;
75
+ isDisabled?(id: UniqueIdentifier): boolean;
76
+ className?: string;
77
+ }
78
+ export declare const modifierByName: {
79
+ restrictToVerticalAxis: import("@dnd-kit/core").Modifier;
80
+ restrictToWindowEdges: import("@dnd-kit/core").Modifier;
81
+ restrictToHorizontalAxis: import("@dnd-kit/core").Modifier;
82
+ restrictToParentElement: import("@dnd-kit/core").Modifier;
83
+ restrictToFirstScrollableAncestor: import("@dnd-kit/core").Modifier;
84
+ };
85
+ export declare function Sortable({ className, style, activationConstraint, animateLayoutChanges, adjustScale, collisionDetection, coordinateGetter, dropAnimation, getNewIndex, rowKey, items: initialItems, measuring, modifiers, removable, renderItem, reorderItems, strategy, useDragOverlay, modifierNames, themeResetClass, onReorder, }: SortableProps): React.JSX.Element;
86
+ interface SortableItemProps {
87
+ animateLayoutChanges?: AnimateLayoutChanges;
88
+ getNewIndex?: NewIndexGetter;
89
+ id: UniqueIdentifier;
90
+ index: number;
91
+ useDragOverlay?: boolean;
92
+ renderItem?(args: any): React.ReactElement;
93
+ value?: any;
94
+ }
95
+ export declare function SortableItem({ animateLayoutChanges, getNewIndex, id, value, index, renderItem, useDragOverlay, }: SortableItemProps): React.JSX.Element;
96
+ export declare function SortableHandle({ children }: {
97
+ children?: ReactNode;
98
+ }): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | null;
99
+ export declare function registerSortable(loader?: Registerable): void;
100
+ export {};
package/dist/util.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { ComponentMeta, default as registerComponent } from "@plasmicapp/host/registerComponent";
2
+ import { default as registerGlobalContext } from "@plasmicapp/host/registerGlobalContext";
3
+ import { default as registerToken } from "@plasmicapp/host/registerToken";
4
+ import React from "react";
5
+ export declare type Registerable = {
6
+ registerComponent: typeof registerComponent;
7
+ registerGlobalContext: typeof registerGlobalContext;
8
+ registerToken: typeof registerToken;
9
+ };
10
+ export declare function registerComponentHelper<T extends React.ComponentType<any>>(loader: Registerable | undefined, component: T, meta: ComponentMeta<React.ComponentProps<T>>): void;
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@plasmicpkgs/dnd-kit",
3
+ "version": "0.0.3",
4
+ "description": "Plasmic Spotify components.",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "module": "dist/dnd-kit.esm.js",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "start": "tsdx watch",
16
+ "build": "tsdx build",
17
+ "test": "TEST_CWD=`pwd` yarn --cwd=../.. test --passWithNoTests",
18
+ "lint": "tsdx lint",
19
+ "prepublishOnly": "npm run build",
20
+ "size": "size-limit",
21
+ "analyze": "size-limit --why"
22
+ },
23
+ "peerDependencies": {
24
+ "react": ">=16"
25
+ },
26
+ "size-limit": [
27
+ {
28
+ "path": "dist/dnd-kit.cjs.production.min.js",
29
+ "limit": "10 KB"
30
+ },
31
+ {
32
+ "path": "dist/dnd-kit.esm.js",
33
+ "limit": "10 KB"
34
+ }
35
+ ],
36
+ "devDependencies": {
37
+ "@plasmicapp/host": "1.0.225",
38
+ "@types/react": "^17.0.43",
39
+ "@types/react-dom": "^17.0.14",
40
+ "husky": "^7.0.4",
41
+ "react": "^18.0.0",
42
+ "react-dom": "^18.0.0",
43
+ "tsdx": "^0.14.1",
44
+ "tslib": "^2.3.1"
45
+ },
46
+ "dependencies": {
47
+ "@dnd-kit/core": "^6.0.8",
48
+ "@dnd-kit/modifiers": "^6.0.1",
49
+ "@dnd-kit/sortable": "^7.0.2",
50
+ "@dnd-kit/utilities": "^3.2.1"
51
+ },
52
+ "gitHead": "400da4e813c2876ed9d2ada28ef265afd30c69d5"
53
+ }