@contember/react-repeater-dnd-kit 2.0.0-alpha.4 → 2.0.0-alpha.40
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/api-extractor.json +3 -0
- package/dist/development/index.cjs +11 -12
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +7 -7
- package/dist/development/{components → src/components}/RepeaterSortable.cjs +21 -16
- package/dist/development/src/components/RepeaterSortable.cjs.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortable.js +18 -13
- package/dist/development/src/components/RepeaterSortable.js.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableDragOverlay.cjs +10 -10
- package/dist/development/src/components/RepeaterSortableDragOverlay.cjs.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableDragOverlay.js +10 -10
- package/dist/development/src/components/RepeaterSortableDragOverlay.js.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableDropIndicator.cjs +2 -2
- package/dist/development/src/components/RepeaterSortableDropIndicator.cjs.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableDropIndicator.js +2 -2
- package/dist/development/src/components/RepeaterSortableDropIndicator.js.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableEachItem.cjs +8 -8
- package/dist/development/src/components/RepeaterSortableEachItem.cjs.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableEachItem.js +8 -8
- package/dist/development/src/components/RepeaterSortableEachItem.js.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableItemActivator.cjs +4 -4
- package/dist/development/src/components/RepeaterSortableItemActivator.cjs.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableItemActivator.js +2 -2
- package/dist/development/src/components/RepeaterSortableItemActivator.js.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableItemNode.cjs +2 -2
- package/dist/development/src/components/RepeaterSortableItemNode.cjs.map +1 -0
- package/dist/development/{components → src/components}/RepeaterSortableItemNode.js +2 -2
- package/dist/development/src/components/RepeaterSortableItemNode.js.map +1 -0
- package/dist/development/src/contexts.cjs.map +1 -0
- package/dist/development/src/contexts.js.map +1 -0
- package/dist/production/index.cjs +11 -12
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +7 -7
- package/dist/production/{components → src/components}/RepeaterSortable.cjs +15 -10
- package/dist/production/src/components/RepeaterSortable.cjs.map +1 -0
- package/dist/production/{components → src/components}/RepeaterSortable.js +12 -7
- package/dist/production/src/components/RepeaterSortable.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableDragOverlay.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableDragOverlay.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableDropIndicator.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableDropIndicator.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableEachItem.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableEachItem.js.map +1 -0
- package/dist/production/{components → src/components}/RepeaterSortableItemActivator.cjs +2 -2
- package/dist/production/src/components/RepeaterSortableItemActivator.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableItemActivator.js.map +1 -0
- package/dist/production/src/components/RepeaterSortableItemNode.cjs.map +1 -0
- package/dist/production/src/components/RepeaterSortableItemNode.js.map +1 -0
- package/dist/production/src/contexts.cjs.map +1 -0
- package/dist/production/src/contexts.js.map +1 -0
- package/dist/types/components/RepeaterSortable.d.ts +34 -2
- package/dist/types/components/RepeaterSortable.d.ts.map +1 -1
- package/dist/types/components/RepeaterSortableDragOverlay.d.ts +3 -0
- package/dist/types/components/RepeaterSortableDragOverlay.d.ts.map +1 -1
- package/dist/types/components/RepeaterSortableDropIndicator.d.ts +4 -1
- package/dist/types/components/RepeaterSortableDropIndicator.d.ts.map +1 -1
- package/dist/types/components/RepeaterSortableEachItem.d.ts +4 -0
- package/dist/types/components/RepeaterSortableEachItem.d.ts.map +1 -1
- package/dist/types/components/RepeaterSortableItemActivator.d.ts +5 -2
- package/dist/types/components/RepeaterSortableItemActivator.d.ts.map +1 -1
- package/dist/types/components/RepeaterSortableItemNode.d.ts +5 -2
- package/dist/types/components/RepeaterSortableItemNode.d.ts.map +1 -1
- package/dist/types/contexts.d.ts +6 -1
- package/dist/types/contexts.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -18
- package/src/components/RepeaterSortable.tsx +47 -22
- package/src/components/RepeaterSortableDragOverlay.tsx +3 -0
- package/src/components/RepeaterSortableDropIndicator.tsx +3 -0
- package/src/components/RepeaterSortableEachItem.tsx +4 -0
- package/src/components/RepeaterSortableItemActivator.tsx +5 -2
- package/src/components/RepeaterSortableItemNode.tsx +5 -2
- package/src/contexts.ts +6 -0
- package/tsconfig.json +7 -0
- package/tsdoc.json +6 -0
- package/dist/development/components/RepeaterSortable.cjs.map +0 -1
- package/dist/development/components/RepeaterSortable.js.map +0 -1
- package/dist/development/components/RepeaterSortableDragOverlay.cjs.map +0 -1
- package/dist/development/components/RepeaterSortableDragOverlay.js.map +0 -1
- package/dist/development/components/RepeaterSortableDropIndicator.cjs.map +0 -1
- package/dist/development/components/RepeaterSortableDropIndicator.js.map +0 -1
- package/dist/development/components/RepeaterSortableEachItem.cjs.map +0 -1
- package/dist/development/components/RepeaterSortableEachItem.js.map +0 -1
- package/dist/development/components/RepeaterSortableItemActivator.cjs.map +0 -1
- package/dist/development/components/RepeaterSortableItemActivator.js.map +0 -1
- package/dist/development/components/RepeaterSortableItemNode.cjs.map +0 -1
- package/dist/development/components/RepeaterSortableItemNode.js.map +0 -1
- package/dist/development/contexts.cjs.map +0 -1
- package/dist/development/contexts.js.map +0 -1
- package/dist/production/components/RepeaterSortable.cjs.map +0 -1
- package/dist/production/components/RepeaterSortable.js.map +0 -1
- package/dist/production/components/RepeaterSortableDragOverlay.cjs.map +0 -1
- package/dist/production/components/RepeaterSortableDragOverlay.js.map +0 -1
- package/dist/production/components/RepeaterSortableDropIndicator.cjs.map +0 -1
- package/dist/production/components/RepeaterSortableDropIndicator.js.map +0 -1
- package/dist/production/components/RepeaterSortableEachItem.cjs.map +0 -1
- package/dist/production/components/RepeaterSortableEachItem.js.map +0 -1
- package/dist/production/components/RepeaterSortableItemActivator.cjs.map +0 -1
- package/dist/production/components/RepeaterSortableItemActivator.js.map +0 -1
- package/dist/production/components/RepeaterSortableItemNode.cjs.map +0 -1
- package/dist/production/components/RepeaterSortableItemNode.js.map +0 -1
- package/dist/production/contexts.cjs.map +0 -1
- package/dist/production/contexts.js.map +0 -1
- /package/dist/development/{contexts.cjs → src/contexts.cjs} +0 -0
- /package/dist/development/{contexts.js → src/contexts.js} +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableDragOverlay.cjs +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableDragOverlay.js +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableDropIndicator.cjs +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableDropIndicator.js +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableEachItem.cjs +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableEachItem.js +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableItemActivator.js +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableItemNode.cjs +0 -0
- /package/dist/production/{components → src/components}/RepeaterSortableItemNode.js +0 -0
- /package/dist/production/{contexts.cjs → src/contexts.cjs} +0 -0
- /package/dist/production/{contexts.js → src/contexts.js} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/react-repeater-dnd-kit",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.40",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -11,37 +11,31 @@
|
|
|
11
11
|
"types": "./dist/types/index.d.ts",
|
|
12
12
|
"development": "./dist/development/index.js",
|
|
13
13
|
"production": "./dist/production/index.js",
|
|
14
|
+
"typescript": "./src/index.ts",
|
|
14
15
|
"default": "./dist/production/index.js"
|
|
15
16
|
},
|
|
16
17
|
"require": {
|
|
17
18
|
"types": "./dist/types/index.d.ts",
|
|
18
19
|
"development": "./dist/development/index.cjs",
|
|
19
20
|
"production": "./dist/production/index.cjs",
|
|
21
|
+
"typescript": "./src/index.ts",
|
|
20
22
|
"default": "./dist/production/index.cjs"
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
|
-
"files": [
|
|
25
|
-
"dist/",
|
|
26
|
-
"src/"
|
|
27
|
-
],
|
|
28
26
|
"typings": "./dist/types/index.d.ts",
|
|
29
27
|
"scripts": {
|
|
30
|
-
"build": "yarn build:js:dev && yarn build:js:prod",
|
|
31
|
-
"build:js:dev": "NODE_ENV=development vite build --mode development",
|
|
32
|
-
"build:js:prod": "vite build --mode production",
|
|
33
28
|
"ae:build": "api-extractor run --local",
|
|
34
|
-
"ae:test": "api-extractor run"
|
|
35
|
-
"test": "vitest"
|
|
29
|
+
"ae:test": "api-extractor run"
|
|
36
30
|
},
|
|
37
31
|
"dependencies": {
|
|
38
|
-
"@contember/react-binding": "2.0.0-alpha.
|
|
39
|
-
"@contember/react-repeater": "2.0.0-alpha.
|
|
40
|
-
"@contember/react-utils": "2.0.0-alpha.
|
|
32
|
+
"@contember/react-binding": "2.0.0-alpha.40",
|
|
33
|
+
"@contember/react-repeater": "2.0.0-alpha.40",
|
|
34
|
+
"@contember/react-utils": "2.0.0-alpha.40",
|
|
41
35
|
"@dnd-kit/core": "^6.1.0",
|
|
42
36
|
"@dnd-kit/sortable": "^8.0.0",
|
|
43
|
-
"@radix-ui/react-portal": "^1.
|
|
44
|
-
"@radix-ui/react-slot": "^1.0
|
|
37
|
+
"@radix-ui/react-portal": "^1.1.2",
|
|
38
|
+
"@radix-ui/react-slot": "^1.1.0"
|
|
45
39
|
},
|
|
46
40
|
"peerDependencies": {
|
|
47
41
|
"react": "^18 || ^19",
|
|
@@ -55,6 +49,5 @@
|
|
|
55
49
|
"type": "git",
|
|
56
50
|
"url": "https://github.com/contember/interface.git",
|
|
57
51
|
"directory": "packages/react-repeater-dnd-kit"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,24 +1,44 @@
|
|
|
1
1
|
import React, { ReactNode, useCallback, useMemo, useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
DndContext,
|
|
5
|
-
DragEndEvent,
|
|
6
|
-
KeyboardSensor,
|
|
7
|
-
MeasuringStrategy,
|
|
8
|
-
MouseSensor,
|
|
9
|
-
TouchSensor,
|
|
10
|
-
UniqueIdentifier,
|
|
11
|
-
useSensor,
|
|
12
|
-
useSensors,
|
|
13
|
-
} from '@dnd-kit/core'
|
|
2
|
+
import type { DragStartEvent } from '@dnd-kit/core'
|
|
3
|
+
import { closestCenter, DndContext, DndContextProps, DragCancelEvent, DragEndEvent, KeyboardSensor, MeasuringStrategy, MouseSensor, TouchSensor, UniqueIdentifier, useSensor, useSensors } from '@dnd-kit/core'
|
|
14
4
|
import { RepeaterActiveEntityContext } from '../contexts'
|
|
15
5
|
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'
|
|
16
|
-
import { useRepeaterSortedEntities } from '@contember/react-repeater'
|
|
17
|
-
import { useRepeaterMethods } from '@contember/react-repeater'
|
|
6
|
+
import { useRepeaterMethods, useRepeaterSortedEntities } from '@contember/react-repeater'
|
|
18
7
|
|
|
19
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Initializes dnd-kit based sorting for the repeater.
|
|
10
|
+
* Using the props, you can customize the behavior of the sorting and hook into the drag events.
|
|
11
|
+
*
|
|
12
|
+
* ## Example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Repeater {...}>
|
|
15
|
+
* <RepeaterSortable>
|
|
16
|
+
* <RepeaterSortableEachItem>
|
|
17
|
+
* <div>
|
|
18
|
+
* <RepeaterSortableDropIndicator position={'before'}><div>Drop here</div></RepeaterSortableDropIndicator>
|
|
19
|
+
* <RepeaterSortableItemNode>
|
|
20
|
+
* <div>
|
|
21
|
+
* <RepeaterSortableItemActivator>
|
|
22
|
+
* <span/>
|
|
23
|
+
* </RepeaterSortableItemActivator>
|
|
24
|
+
* {children}
|
|
25
|
+
* </div>
|
|
26
|
+
* </RepeaterSortableItemNode>
|
|
27
|
+
* <RepeaterSortableDropIndicator position={'afer'}><div>Drop here</div></RepeaterSortableDropIndicator>
|
|
28
|
+
* </div>
|
|
29
|
+
* </RepeaterSortableEachItem>
|
|
30
|
+
* <RepeaterSortableDragOverlay>
|
|
31
|
+
* <div>
|
|
32
|
+
* {children}
|
|
33
|
+
* </div>
|
|
34
|
+
* </RepeaterSortableDragOverlay>
|
|
35
|
+
* </RepeaterSortable>
|
|
36
|
+
* </Repeater>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const RepeaterSortable = ({ children, onDragStart, onDragEnd: onDragEndIn, onDragCancel: onDragCancelIn, ...props }: {
|
|
20
40
|
children: ReactNode
|
|
21
|
-
}) => {
|
|
41
|
+
} & DndContextProps) => {
|
|
22
42
|
const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null)
|
|
23
43
|
const { moveItem } = useRepeaterMethods()
|
|
24
44
|
const entities = useRepeaterSortedEntities()
|
|
@@ -37,19 +57,22 @@ export const RepeaterSortable = ({ children }: {
|
|
|
37
57
|
useSensor(KeyboardSensor),
|
|
38
58
|
)
|
|
39
59
|
|
|
40
|
-
const onDragCancel = () => {
|
|
60
|
+
const onDragCancel = (event: DragCancelEvent) => {
|
|
61
|
+
onDragCancelIn?.(event)
|
|
41
62
|
setActiveId(null)
|
|
42
63
|
}
|
|
43
64
|
|
|
44
|
-
const onDragEnd = useCallback((
|
|
65
|
+
const onDragEnd = useCallback((event: DragEndEvent) => {
|
|
66
|
+
onDragEndIn?.(event)
|
|
45
67
|
setActiveId(null)
|
|
68
|
+
const { active, over } = event
|
|
46
69
|
const activeEntity = entities.find(it => it.id === active.id)
|
|
47
70
|
const overIndex = over ? entities.findIndex(it => it.id === over.id) : undefined
|
|
48
71
|
if (!activeEntity || overIndex === undefined) {
|
|
49
72
|
return
|
|
50
73
|
}
|
|
51
74
|
moveItem?.(activeEntity, overIndex)
|
|
52
|
-
}, [entities, moveItem])
|
|
75
|
+
}, [entities, moveItem, onDragEndIn])
|
|
53
76
|
|
|
54
77
|
return (
|
|
55
78
|
<DndContext
|
|
@@ -59,12 +82,14 @@ export const RepeaterSortable = ({ children }: {
|
|
|
59
82
|
strategy: MeasuringStrategy.Always,
|
|
60
83
|
},
|
|
61
84
|
}}
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
collisionDetection={closestCenter}
|
|
86
|
+
{...props}
|
|
87
|
+
onDragStart={(event: DragStartEvent) => {
|
|
88
|
+
onDragStart?.(event)
|
|
89
|
+
setActiveId(event.active.id)
|
|
64
90
|
}}
|
|
65
91
|
onDragEnd={onDragEnd}
|
|
66
92
|
onDragCancel={onDragCancel}
|
|
67
|
-
collisionDetection={closestCenter}
|
|
68
93
|
>
|
|
69
94
|
<RepeaterActiveEntityContext.Provider value={activeItem}>
|
|
70
95
|
<SortableContext items={entities} strategy={verticalListSortingStrategy}>
|
|
@@ -5,6 +5,9 @@ import { DragOverlay } from '@dnd-kit/core'
|
|
|
5
5
|
import { AccessorTree, Entity, useAccessorTreeState } from '@contember/react-binding'
|
|
6
6
|
import { RepeaterCurrentEntityContext } from '@contember/react-repeater'
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Component for rendering the repeater item being dragged.
|
|
10
|
+
*/
|
|
8
11
|
export const RepeaterSortableDragOverlay = ({ children }: {
|
|
9
12
|
children: ReactNode
|
|
10
13
|
}) => {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react'
|
|
2
2
|
import { useRepeaterSortableItem } from '../contexts'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Renders a child element when the repeater item is being dragged over the drop indicator.
|
|
6
|
+
*/
|
|
4
7
|
export const RepeaterSortableDropIndicator = ({ children, position }: {
|
|
5
8
|
children: ReactNode
|
|
6
9
|
position: 'before' | 'after'
|
|
@@ -4,6 +4,10 @@ import { RepeaterEachItem, useRepeaterSortedEntities } from '@contember/react-re
|
|
|
4
4
|
import { RepeaterSortableItemContext } from '../contexts'
|
|
5
5
|
import { useEntity } from '@contember/react-binding'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Iterates over all entities in the repeater and renders the children for each entity.
|
|
9
|
+
* Also sets up the dnd-kit sortable context for the repeater items.
|
|
10
|
+
*/
|
|
7
11
|
export const RepeaterSortableEachItem = ({ children }: {
|
|
8
12
|
children: ReactNode
|
|
9
13
|
}) => {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import React, { forwardRef, ReactNode } from 'react'
|
|
1
|
+
import React, { forwardRef, ReactElement, ReactNode } from 'react'
|
|
2
2
|
import { useRepeaterSortableItem } from '../contexts'
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot'
|
|
4
4
|
import { useComposeRef } from '@contember/react-utils'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Slot for the repeater item activator, which is the element that triggers the drag and drop interaction (e.g. a handle).
|
|
8
|
+
*/
|
|
6
9
|
export const RepeaterSortableItemActivator = forwardRef<HTMLElement, {
|
|
7
|
-
children:
|
|
10
|
+
children: ReactElement
|
|
8
11
|
}>((props, ref) => {
|
|
9
12
|
const { setActivatorNodeRef, listeners } = useRepeaterSortableItem()
|
|
10
13
|
return <Slot ref={useComposeRef(ref, setActivatorNodeRef)} {...listeners} {...props} />
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactElement } from 'react'
|
|
2
2
|
import { useRepeaterSortableItem } from '../contexts'
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Slot for the repeater item node, which is the element that is being dragged.
|
|
7
|
+
*/
|
|
5
8
|
export const RepeaterSortableItemNode = ({ children }: {
|
|
6
|
-
children:
|
|
9
|
+
children: ReactElement
|
|
7
10
|
}) => {
|
|
8
11
|
const { setNodeRef } = useRepeaterSortableItem()
|
|
9
12
|
return <Slot ref={setNodeRef}>{children}</Slot>
|
package/src/contexts.ts
CHANGED
|
@@ -5,9 +5,15 @@ import { useSortable } from '@dnd-kit/sortable'
|
|
|
5
5
|
const RepeaterSortableItemContext_ = createRequiredContext<ReturnType<typeof useSortable>>('RepeaterSortableItemContext')
|
|
6
6
|
/** @internal */
|
|
7
7
|
export const RepeaterSortableItemContext = RepeaterSortableItemContext_[0]
|
|
8
|
+
/**
|
|
9
|
+
* Returns the sortable context from dnd-kit (e.g. isDragging, isOver, setNodeRef) for the repeater item.
|
|
10
|
+
*/
|
|
8
11
|
export const useRepeaterSortableItem = RepeaterSortableItemContext_[1]
|
|
9
12
|
|
|
10
13
|
const RepeaterActiveEntityContext_ = createContext<EntityAccessor | undefined>('RepeaterActiveEntityContext', undefined)
|
|
11
14
|
/** @internal */
|
|
12
15
|
export const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0]
|
|
16
|
+
/**
|
|
17
|
+
* Returns the entity that is currently being dragged in the repeater.
|
|
18
|
+
*/
|
|
13
19
|
export const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1]
|
package/tsconfig.json
ADDED
package/tsdoc.json
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortable.cjs","sources":["../../../src/components/RepeaterSortable.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo, useState } from 'react'\nimport {\n\tclosestCenter,\n\tDndContext,\n\tDragEndEvent,\n\tKeyboardSensor,\n\tMeasuringStrategy,\n\tMouseSensor,\n\tTouchSensor,\n\tUniqueIdentifier,\n\tuseSensor,\n\tuseSensors,\n} from '@dnd-kit/core'\nimport { RepeaterActiveEntityContext } from '../contexts'\nimport { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { useRepeaterMethods } from '@contember/react-repeater'\n\nexport const RepeaterSortable = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst [activeId, setActiveId] = useState<UniqueIdentifier | null>(null)\n\tconst { moveItem } = useRepeaterMethods()\n\tconst entities = useRepeaterSortedEntities()\n\n\n\tconst activeItem = useMemo(() => {\n\t\tif (!activeId) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn entities.find(it => it.id === activeId)\n\t}, [activeId, entities])\n\n\tconst sensors = useSensors(\n\t\tuseSensor(MouseSensor),\n\t\tuseSensor(TouchSensor),\n\t\tuseSensor(KeyboardSensor),\n\t)\n\n\tconst onDragCancel = () => {\n\t\tsetActiveId(null)\n\t}\n\n\tconst onDragEnd = useCallback(({ active, over }: DragEndEvent) => {\n\t\tsetActiveId(null)\n\t\tconst activeEntity = entities.find(it => it.id === active.id)\n\t\tconst overIndex = over ? entities.findIndex(it => it.id === over.id) : undefined\n\t\tif (!activeEntity || overIndex === undefined) {\n\t\t\treturn\n\t\t}\n\t\tmoveItem?.(activeEntity, overIndex)\n\t}, [entities, moveItem])\n\n\treturn (\n\t\t<DndContext\n\t\t\tsensors={sensors}\n\t\t\tmeasuring={{\n\t\t\t\tdroppable: {\n\t\t\t\t\tstrategy: MeasuringStrategy.Always,\n\t\t\t\t},\n\t\t\t}}\n\t\t\tonDragStart={({ active }) => {\n\t\t\t\tsetActiveId(active.id)\n\t\t\t}}\n\t\t\tonDragEnd={onDragEnd}\n\t\t\tonDragCancel={onDragCancel}\n\t\t\tcollisionDetection={closestCenter}\n\t\t>\n\t\t\t<RepeaterActiveEntityContext.Provider value={activeItem}>\n\t\t\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t\t\t{children}\n\t\t\t\t</SortableContext>\n\t\t\t</RepeaterActiveEntityContext.Provider>\n\t\t</DndContext>\n\t)\n}\n"],"names":["useState","useRepeaterMethods","useRepeaterSortedEntities","useMemo","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","useCallback","jsxDEV","DndContext","MeasuringStrategy","closestCenter","RepeaterActiveEntityContext","SortableContext","verticalListSortingStrategy","this"],"mappings":";;;;;;;;AAkBO,MAAM,mBAAmB,CAAC,EAAE,eAE7B;AACL,QAAM,CAAC,UAAU,WAAW,IAAIA,eAAkC,IAAI;AAChE,QAAA,EAAE,aAAaC,cAAAA;AACrB,QAAM,WAAWC,cAAAA;AAGX,QAAA,aAAaC,MAAAA,QAAQ,MAAM;AAChC,QAAI,CAAC,UAAU;AACP,aAAA;AAAA,IACR;AACA,WAAO,SAAS,KAAK,CAAM,OAAA,GAAG,OAAO,QAAQ;AAAA,EAAA,GAC3C,CAAC,UAAU,QAAQ,CAAC;AAEvB,QAAM,UAAUC,KAAA;AAAA,IACfC,KAAAA,UAAUC,KAAAA,WAAW;AAAA,IACrBD,KAAAA,UAAUE,KAAAA,WAAW;AAAA,IACrBF,KAAAA,UAAUG,KAAAA,cAAc;AAAA,EAAA;AAGzB,QAAM,eAAe,MAAM;AAC1B,gBAAY,IAAI;AAAA,EAAA;AAGjB,QAAM,YAAYC,MAAY,YAAA,CAAC,EAAE,QAAQ,WAAyB;AACjE,gBAAY,IAAI;AAChB,UAAM,eAAe,SAAS,KAAK,QAAM,GAAG,OAAO,OAAO,EAAE;AACtD,UAAA,YAAY,OAAO,SAAS,UAAU,QAAM,GAAG,OAAO,KAAK,EAAE,IAAI;AACnE,QAAA,CAAC,gBAAgB,cAAc,QAAW;AAC7C;AAAA,IACD;AACA,eAAW,cAAc,SAAS;AAAA,EAAA,GAChC,CAAC,UAAU,QAAQ,CAAC;AAGtB,SAAAC,8BAAA;AAAA,IAACC,KAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACV,WAAW;AAAA,UACV,UAAUC,KAAkB,kBAAA;AAAA,QAC7B;AAAA,MACD;AAAA,MACA,aAAa,CAAC,EAAE,aAAa;AAC5B,oBAAY,OAAO,EAAE;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA,oBAAoBC,KAAA;AAAA,MAEpB,UAACH,8BAAA,OAAAI,qCAA4B,UAA5B,EAAqC,OAAO,YAC5C,UAACJ,8BAAA,OAAAK,SAAA,iBAAA,EAAgB,OAAO,UAAU,UAAUC,SAAAA,6BAC1C,YADF,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAC,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAIA,GAAAA,MAAA;AAAA,IAAA;AAAA,IAlBD;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAqBF;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortable.js","sources":["../../../src/components/RepeaterSortable.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo, useState } from 'react'\nimport {\n\tclosestCenter,\n\tDndContext,\n\tDragEndEvent,\n\tKeyboardSensor,\n\tMeasuringStrategy,\n\tMouseSensor,\n\tTouchSensor,\n\tUniqueIdentifier,\n\tuseSensor,\n\tuseSensors,\n} from '@dnd-kit/core'\nimport { RepeaterActiveEntityContext } from '../contexts'\nimport { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { useRepeaterMethods } from '@contember/react-repeater'\n\nexport const RepeaterSortable = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst [activeId, setActiveId] = useState<UniqueIdentifier | null>(null)\n\tconst { moveItem } = useRepeaterMethods()\n\tconst entities = useRepeaterSortedEntities()\n\n\n\tconst activeItem = useMemo(() => {\n\t\tif (!activeId) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn entities.find(it => it.id === activeId)\n\t}, [activeId, entities])\n\n\tconst sensors = useSensors(\n\t\tuseSensor(MouseSensor),\n\t\tuseSensor(TouchSensor),\n\t\tuseSensor(KeyboardSensor),\n\t)\n\n\tconst onDragCancel = () => {\n\t\tsetActiveId(null)\n\t}\n\n\tconst onDragEnd = useCallback(({ active, over }: DragEndEvent) => {\n\t\tsetActiveId(null)\n\t\tconst activeEntity = entities.find(it => it.id === active.id)\n\t\tconst overIndex = over ? entities.findIndex(it => it.id === over.id) : undefined\n\t\tif (!activeEntity || overIndex === undefined) {\n\t\t\treturn\n\t\t}\n\t\tmoveItem?.(activeEntity, overIndex)\n\t}, [entities, moveItem])\n\n\treturn (\n\t\t<DndContext\n\t\t\tsensors={sensors}\n\t\t\tmeasuring={{\n\t\t\t\tdroppable: {\n\t\t\t\t\tstrategy: MeasuringStrategy.Always,\n\t\t\t\t},\n\t\t\t}}\n\t\t\tonDragStart={({ active }) => {\n\t\t\t\tsetActiveId(active.id)\n\t\t\t}}\n\t\t\tonDragEnd={onDragEnd}\n\t\t\tonDragCancel={onDragCancel}\n\t\t\tcollisionDetection={closestCenter}\n\t\t>\n\t\t\t<RepeaterActiveEntityContext.Provider value={activeItem}>\n\t\t\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t\t\t{children}\n\t\t\t\t</SortableContext>\n\t\t\t</RepeaterActiveEntityContext.Provider>\n\t\t</DndContext>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;;AAkBO,MAAM,mBAAmB,CAAC,EAAE,eAE7B;AACL,QAAM,CAAC,UAAU,WAAW,IAAI,SAAkC,IAAI;AAChE,QAAA,EAAE,aAAa;AACrB,QAAM,WAAW;AAGX,QAAA,aAAa,QAAQ,MAAM;AAChC,QAAI,CAAC,UAAU;AACP,aAAA;AAAA,IACR;AACA,WAAO,SAAS,KAAK,CAAM,OAAA,GAAG,OAAO,QAAQ;AAAA,EAAA,GAC3C,CAAC,UAAU,QAAQ,CAAC;AAEvB,QAAM,UAAU;AAAA,IACf,UAAU,WAAW;AAAA,IACrB,UAAU,WAAW;AAAA,IACrB,UAAU,cAAc;AAAA,EAAA;AAGzB,QAAM,eAAe,MAAM;AAC1B,gBAAY,IAAI;AAAA,EAAA;AAGjB,QAAM,YAAY,YAAY,CAAC,EAAE,QAAQ,WAAyB;AACjE,gBAAY,IAAI;AAChB,UAAM,eAAe,SAAS,KAAK,QAAM,GAAG,OAAO,OAAO,EAAE;AACtD,UAAA,YAAY,OAAO,SAAS,UAAU,QAAM,GAAG,OAAO,KAAK,EAAE,IAAI;AACnE,QAAA,CAAC,gBAAgB,cAAc,QAAW;AAC7C;AAAA,IACD;AACA,eAAW,cAAc,SAAS;AAAA,EAAA,GAChC,CAAC,UAAU,QAAQ,CAAC;AAGtB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACV,WAAW;AAAA,UACV,UAAU,kBAAkB;AAAA,QAC7B;AAAA,MACD;AAAA,MACA,aAAa,CAAC,EAAE,aAAa;AAC5B,oBAAY,OAAO,EAAE;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA,oBAAoB;AAAA,MAEpB,UAAC,uBAAA,4BAA4B,UAA5B,EAAqC,OAAO,YAC5C,UAAC,uBAAA,iBAAA,EAAgB,OAAO,UAAU,UAAU,6BAC1C,YADF,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAIA,GAAAA,MAAA;AAAA,IAAA;AAAA,IAlBD;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAqBF;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableDragOverlay.cjs","sources":["../../../src/components/RepeaterSortableDragOverlay.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterActiveEntity } from '../contexts'\nimport { Portal } from '@radix-ui/react-portal'\nimport { DragOverlay } from '@dnd-kit/core'\nimport { AccessorTree, Entity, useAccessorTreeState } from '@contember/react-binding'\nimport { RepeaterCurrentEntityContext } from '@contember/react-repeater'\n\nexport const RepeaterSortableDragOverlay = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst activeItem = useRepeaterActiveEntity()\n\tconst accessorTreeState = useAccessorTreeState()\n\tif (!activeItem) {\n\t\treturn null\n\t}\n\treturn (\n\t\t<Portal>\n\t\t\t<DragOverlay>\n\t\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t\t<Entity accessor={activeItem}>\n\t\t\t\t\t\t<RepeaterCurrentEntityContext.Provider value={activeItem}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</RepeaterCurrentEntityContext.Provider>\n\t\t\t\t\t</Entity>\n\t\t\t\t</AccessorTree>\n\t\t\t</DragOverlay>\n\t\t</Portal>\n\t)\n}\n"],"names":["useRepeaterActiveEntity","useAccessorTreeState","Portal","jsxDEV","DragOverlay","AccessorTree","Entity","RepeaterCurrentEntityContext","this"],"mappings":";;;;;;;;AAOO,MAAM,8BAA8B,CAAC,EAAE,eAExC;AACL,QAAM,aAAaA,SAAAA;AACnB,QAAM,oBAAoBC,aAAAA;AAC1B,MAAI,CAAC,YAAY;AACT,WAAA;AAAA,EACR;AACA,8CACEC,YACA,QAAA,EAAA,UAAAC,8BAAA,OAACC,oBACA,UAACD,8BAAA,OAAAE,aAAA,cAAA,EAAa,OAAO,mBACpB,UAAAF,8BAAAA,OAACG,aAAO,QAAA,EAAA,UAAU,YACjB,UAACH,8BAAAA,OAAAI,cAAAA,6BAA6B,UAA7B,EAAsC,OAAO,YAC5C,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAIA,EALD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA,EAPD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAQA,EATD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAUA,GAAAA,MAAA;AAEF;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableDragOverlay.js","sources":["../../../src/components/RepeaterSortableDragOverlay.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterActiveEntity } from '../contexts'\nimport { Portal } from '@radix-ui/react-portal'\nimport { DragOverlay } from '@dnd-kit/core'\nimport { AccessorTree, Entity, useAccessorTreeState } from '@contember/react-binding'\nimport { RepeaterCurrentEntityContext } from '@contember/react-repeater'\n\nexport const RepeaterSortableDragOverlay = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst activeItem = useRepeaterActiveEntity()\n\tconst accessorTreeState = useAccessorTreeState()\n\tif (!activeItem) {\n\t\treturn null\n\t}\n\treturn (\n\t\t<Portal>\n\t\t\t<DragOverlay>\n\t\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t\t<Entity accessor={activeItem}>\n\t\t\t\t\t\t<RepeaterCurrentEntityContext.Provider value={activeItem}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</RepeaterCurrentEntityContext.Provider>\n\t\t\t\t\t</Entity>\n\t\t\t\t</AccessorTree>\n\t\t\t</DragOverlay>\n\t\t</Portal>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;;AAOO,MAAM,8BAA8B,CAAC,EAAE,eAExC;AACL,QAAM,aAAa;AACnB,QAAM,oBAAoB;AAC1B,MAAI,CAAC,YAAY;AACT,WAAA;AAAA,EACR;AACA,gCACE,QACA,EAAA,UAAA,uBAAC,eACA,UAAC,uBAAA,cAAA,EAAa,OAAO,mBACpB,UAAA,uBAAC,QAAO,EAAA,UAAU,YACjB,UAAC,uBAAA,6BAA6B,UAA7B,EAAsC,OAAO,YAC5C,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAIA,EALD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAMA,EAPD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAQA,EATD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAUA,GAAAA,MAAA;AAEF;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableDropIndicator.cjs","sources":["../../../src/components/RepeaterSortableDropIndicator.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\n\nexport const RepeaterSortableDropIndicator = ({ children, position }: {\n\tchildren: ReactNode\n\tposition: 'before' | 'after'\n}) => {\n\tconst sortable = useRepeaterSortableItem()\n\tconst isOver = sortable.isOver\n\tconst activeSortable = sortable.active?.data.current?.sortable\n\tconst isAfter = (sortable.data?.sortable.index ?? 0) > activeSortable?.index\n\tconst renderedPosition = isAfter ? 'after' : 'before'\n\n\treturn renderedPosition === position && isOver ? <>{children}</> : null\n}\n"],"names":["useRepeaterSortableItem","jsxDEV","Fragment","this"],"mappings":";;;;AAGO,MAAM,gCAAgC,CAAC,EAAE,UAAU,eAGpD;AACL,QAAM,WAAWA,SAAAA;AACjB,QAAM,SAAS,SAAS;AACxB,QAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS;AACtD,QAAM,WAAW,SAAS,MAAM,SAAS,SAAS,KAAK,gBAAgB;AACjE,QAAA,mBAAmB,UAAU,UAAU;AAE7C,SAAO,qBAAqB,YAAY,SAASC,8BAAA,OAAAC,wBAAA,EAAG,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAAY,IAAM;AACpE;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableDropIndicator.js","sources":["../../../src/components/RepeaterSortableDropIndicator.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\n\nexport const RepeaterSortableDropIndicator = ({ children, position }: {\n\tchildren: ReactNode\n\tposition: 'before' | 'after'\n}) => {\n\tconst sortable = useRepeaterSortableItem()\n\tconst isOver = sortable.isOver\n\tconst activeSortable = sortable.active?.data.current?.sortable\n\tconst isAfter = (sortable.data?.sortable.index ?? 0) > activeSortable?.index\n\tconst renderedPosition = isAfter ? 'after' : 'before'\n\n\treturn renderedPosition === position && isOver ? <>{children}</> : null\n}\n"],"names":["this"],"mappings":";;AAGO,MAAM,gCAAgC,CAAC,EAAE,UAAU,eAGpD;AACL,QAAM,WAAW;AACjB,QAAM,SAAS,SAAS;AACxB,QAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS;AACtD,QAAM,WAAW,SAAS,MAAM,SAAS,SAAS,KAAK,gBAAgB;AACjE,QAAA,mBAAmB,UAAU,UAAU;AAE7C,SAAO,qBAAqB,YAAY,SAAS,uBAAA,UAAA,EAAG,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAY,IAAM;AACpE;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableEachItem.cjs","sources":["../../../src/components/RepeaterSortableEachItem.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { RepeaterEachItem, useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { RepeaterSortableItemContext } from '../contexts'\nimport { useEntity } from '@contember/react-binding'\n\nexport const RepeaterSortableEachItem = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entities = useRepeaterSortedEntities()\n\n\treturn (\n\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t<RepeaterEachItem>\n\t\t\t\t<RepeaterSortableEachItemInner>\n\t\t\t\t\t{children}\n\t\t\t\t</RepeaterSortableEachItemInner>\n\n\t\t\t</RepeaterEachItem>\n\t\t</SortableContext>\n\t)\n}\nconst RepeaterSortableEachItemInner = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entity = useEntity()\n\tconst sortable = useSortable({\n\t\tid: entity.id,\n\t})\n\treturn (\n\t\t<RepeaterSortableItemContext.Provider value={sortable}>\n\t\t\t{children}\n\t\t</RepeaterSortableItemContext.Provider>\n\t)\n}\n"],"names":["useRepeaterSortedEntities","jsxDEV","SortableContext","verticalListSortingStrategy","RepeaterEachItem","this","useEntity","sortable","useSortable","RepeaterSortableItemContext"],"mappings":";;;;;;;AAMO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACL,QAAM,WAAWA,cAAAA;AAGhB,SAAAC,8BAAAA,OAACC,SAAAA,iBAAgB,EAAA,OAAO,UAAU,UAAUC,sCAC3C,UAACF,8BAAAA,OAAAG,cAAAA,kBAAA,EACA,UAACH,8BAAAA,OAAA,+BAAA,EACC,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAI,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAKA,EAND,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAOA,GAAAA,MAAA;AAEF;AACA,MAAM,gCAAgC,CAAC,EAAE,eAEnC;AACL,QAAM,SAASC,aAAAA;AACf,QAAMC,aAAWC,SAAAA,YAAY;AAAA,IAC5B,IAAI,OAAO;AAAA,EAAA,CACX;AACD,8CACEC,qCAA4B,UAA5B,EAAqC,OAAOF,YAC3C,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAEA,GAAAF,MAAA;AAEF;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableEachItem.js","sources":["../../../src/components/RepeaterSortableEachItem.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { RepeaterEachItem, useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { RepeaterSortableItemContext } from '../contexts'\nimport { useEntity } from '@contember/react-binding'\n\nexport const RepeaterSortableEachItem = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entities = useRepeaterSortedEntities()\n\n\treturn (\n\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t<RepeaterEachItem>\n\t\t\t\t<RepeaterSortableEachItemInner>\n\t\t\t\t\t{children}\n\t\t\t\t</RepeaterSortableEachItemInner>\n\n\t\t\t</RepeaterEachItem>\n\t\t</SortableContext>\n\t)\n}\nconst RepeaterSortableEachItemInner = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entity = useEntity()\n\tconst sortable = useSortable({\n\t\tid: entity.id,\n\t})\n\treturn (\n\t\t<RepeaterSortableItemContext.Provider value={sortable}>\n\t\t\t{children}\n\t\t</RepeaterSortableItemContext.Provider>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;AAMO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACL,QAAM,WAAW;AAGhB,SAAA,uBAAC,iBAAgB,EAAA,OAAO,UAAU,UAAU,6BAC3C,UAAC,uBAAA,kBAAA,EACA,UAAC,uBAAA,+BAAA,EACC,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAKA,EAND,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAOA,GAAAA,MAAA;AAEF;AACA,MAAM,gCAAgC,CAAC,EAAE,eAEnC;AACL,QAAM,SAAS;AACf,QAAM,WAAW,YAAY;AAAA,IAC5B,IAAI,OAAO;AAAA,EAAA,CACX;AACD,gCACE,4BAA4B,UAA5B,EAAqC,OAAO,UAC3C,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAEA,GAAAA,MAAA;AAEF;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableItemActivator.cjs","sources":["../../../src/components/RepeaterSortableItemActivator.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useComposeRef } from '@contember/react-utils'\n\nexport const RepeaterSortableItemActivator = forwardRef<HTMLElement, {\n\tchildren: ReactNode\n}>((props, ref) => {\n\tconst { setActivatorNodeRef, listeners } = useRepeaterSortableItem()\n\treturn <Slot ref={useComposeRef(ref, setActivatorNodeRef)} {...listeners} {...props} />\n})\n"],"names":["forwardRef","useRepeaterSortableItem","jsxDEV","Slot","useComposeRef","this"],"mappings":";;;;;;;AAKO,MAAM,gCAAgCA,MAAA,WAE1C,CAAC,OAAO,QAAQ;AAClB,QAAM,EAAE,qBAAqB,UAAU,IAAIC,SAAwB,wBAAA;AAC5D,SAAAC,8BAAA,OAACC,UAAK,MAAA,EAAA,KAAKC,WAAAA,cAAc,KAAK,mBAAmB,GAAI,GAAG,WAAY,GAAG,MAAvE,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA8E,GAAAC,MAAA;AACtF,CAAC;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableItemActivator.js","sources":["../../../src/components/RepeaterSortableItemActivator.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useComposeRef } from '@contember/react-utils'\n\nexport const RepeaterSortableItemActivator = forwardRef<HTMLElement, {\n\tchildren: ReactNode\n}>((props, ref) => {\n\tconst { setActivatorNodeRef, listeners } = useRepeaterSortableItem()\n\treturn <Slot ref={useComposeRef(ref, setActivatorNodeRef)} {...listeners} {...props} />\n})\n"],"names":["this"],"mappings":";;;;;AAKO,MAAM,gCAAgC,WAE1C,CAAC,OAAO,QAAQ;AAClB,QAAM,EAAE,qBAAqB,UAAU,IAAI,wBAAwB;AAC5D,SAAA,uBAAC,MAAK,EAAA,KAAK,cAAc,KAAK,mBAAmB,GAAI,GAAG,WAAY,GAAG,MAAvE,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA8E,GAAAA,MAAA;AACtF,CAAC;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableItemNode.cjs","sources":["../../../src/components/RepeaterSortableItemNode.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\n\nexport const RepeaterSortableItemNode = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst { setNodeRef } = useRepeaterSortableItem()\n\treturn <Slot ref={setNodeRef}>{children}</Slot>\n}\n"],"names":["useRepeaterSortableItem","jsxDEV","Slot","this"],"mappings":";;;;;AAIO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACC,QAAA,EAAE,eAAeA,SAAAA;AACvB,SAAQC,8BAAA,OAAAC,UAAA,MAAA,EAAK,KAAK,YAAa,SAAxB,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAiC,GAAAC,MAAA;AACzC;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableItemNode.js","sources":["../../../src/components/RepeaterSortableItemNode.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\n\nexport const RepeaterSortableItemNode = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst { setNodeRef } = useRepeaterSortableItem()\n\treturn <Slot ref={setNodeRef}>{children}</Slot>\n}\n"],"names":["this"],"mappings":";;;AAIO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACC,QAAA,EAAE,eAAe;AACvB,SAAQ,uBAAA,MAAA,EAAK,KAAK,YAAa,SAAxB,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAiC,GAAAA,MAAA;AACzC;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.cjs","sources":["../../src/contexts.ts"],"sourcesContent":["import { createRequiredContext, createContext } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/react-binding'\nimport { useSortable } from '@dnd-kit/sortable'\n\nconst RepeaterSortableItemContext_ = createRequiredContext<ReturnType<typeof useSortable>>('RepeaterSortableItemContext')\n/** @internal */\nexport const RepeaterSortableItemContext = RepeaterSortableItemContext_[0]\nexport const useRepeaterSortableItem = RepeaterSortableItemContext_[1]\n\nconst RepeaterActiveEntityContext_ = createContext<EntityAccessor | undefined>('RepeaterActiveEntityContext', undefined)\n/** @internal */\nexport const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0]\nexport const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1]\n"],"names":["createRequiredContext","createContext"],"mappings":";;;AAIA,MAAM,+BAA+BA,WAAAA,sBAAsD,6BAA6B;AAE3G,MAAA,8BAA8B,6BAA6B,CAAC;AAC5D,MAAA,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,+BAA+BC,WAA0C,cAAA,+BAA+B,MAAS;AAE1G,MAAA,8BAA8B,6BAA6B,CAAC;AAC5D,MAAA,0BAA0B,6BAA6B,CAAC;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.js","sources":["../../src/contexts.ts"],"sourcesContent":["import { createRequiredContext, createContext } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/react-binding'\nimport { useSortable } from '@dnd-kit/sortable'\n\nconst RepeaterSortableItemContext_ = createRequiredContext<ReturnType<typeof useSortable>>('RepeaterSortableItemContext')\n/** @internal */\nexport const RepeaterSortableItemContext = RepeaterSortableItemContext_[0]\nexport const useRepeaterSortableItem = RepeaterSortableItemContext_[1]\n\nconst RepeaterActiveEntityContext_ = createContext<EntityAccessor | undefined>('RepeaterActiveEntityContext', undefined)\n/** @internal */\nexport const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0]\nexport const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1]\n"],"names":[],"mappings":";AAIA,MAAM,+BAA+B,sBAAsD,6BAA6B;AAE3G,MAAA,8BAA8B,6BAA6B,CAAC;AAC5D,MAAA,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,+BAA+B,cAA0C,+BAA+B,MAAS;AAE1G,MAAA,8BAA8B,6BAA6B,CAAC;AAC5D,MAAA,0BAA0B,6BAA6B,CAAC;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortable.cjs","sources":["../../../src/components/RepeaterSortable.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo, useState } from 'react'\nimport {\n\tclosestCenter,\n\tDndContext,\n\tDragEndEvent,\n\tKeyboardSensor,\n\tMeasuringStrategy,\n\tMouseSensor,\n\tTouchSensor,\n\tUniqueIdentifier,\n\tuseSensor,\n\tuseSensors,\n} from '@dnd-kit/core'\nimport { RepeaterActiveEntityContext } from '../contexts'\nimport { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { useRepeaterMethods } from '@contember/react-repeater'\n\nexport const RepeaterSortable = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst [activeId, setActiveId] = useState<UniqueIdentifier | null>(null)\n\tconst { moveItem } = useRepeaterMethods()\n\tconst entities = useRepeaterSortedEntities()\n\n\n\tconst activeItem = useMemo(() => {\n\t\tif (!activeId) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn entities.find(it => it.id === activeId)\n\t}, [activeId, entities])\n\n\tconst sensors = useSensors(\n\t\tuseSensor(MouseSensor),\n\t\tuseSensor(TouchSensor),\n\t\tuseSensor(KeyboardSensor),\n\t)\n\n\tconst onDragCancel = () => {\n\t\tsetActiveId(null)\n\t}\n\n\tconst onDragEnd = useCallback(({ active, over }: DragEndEvent) => {\n\t\tsetActiveId(null)\n\t\tconst activeEntity = entities.find(it => it.id === active.id)\n\t\tconst overIndex = over ? entities.findIndex(it => it.id === over.id) : undefined\n\t\tif (!activeEntity || overIndex === undefined) {\n\t\t\treturn\n\t\t}\n\t\tmoveItem?.(activeEntity, overIndex)\n\t}, [entities, moveItem])\n\n\treturn (\n\t\t<DndContext\n\t\t\tsensors={sensors}\n\t\t\tmeasuring={{\n\t\t\t\tdroppable: {\n\t\t\t\t\tstrategy: MeasuringStrategy.Always,\n\t\t\t\t},\n\t\t\t}}\n\t\t\tonDragStart={({ active }) => {\n\t\t\t\tsetActiveId(active.id)\n\t\t\t}}\n\t\t\tonDragEnd={onDragEnd}\n\t\t\tonDragCancel={onDragCancel}\n\t\t\tcollisionDetection={closestCenter}\n\t\t>\n\t\t\t<RepeaterActiveEntityContext.Provider value={activeItem}>\n\t\t\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t\t\t{children}\n\t\t\t\t</SortableContext>\n\t\t\t</RepeaterActiveEntityContext.Provider>\n\t\t</DndContext>\n\t)\n}\n"],"names":["useState","useRepeaterMethods","useRepeaterSortedEntities","useMemo","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","useCallback","jsx","DndContext","MeasuringStrategy","closestCenter","RepeaterActiveEntityContext","SortableContext","verticalListSortingStrategy"],"mappings":";;;;;;;;AAkBO,MAAM,mBAAmB,CAAC,EAAE,eAE7B;AACL,QAAM,CAAC,UAAU,WAAW,IAAIA,eAAkC,IAAI;AAChE,QAAA,EAAE,aAAaC,cAAAA;AACrB,QAAM,WAAWC,cAAAA;AAGX,QAAA,aAAaC,MAAAA,QAAQ,MAAM;AAChC,QAAI,CAAC,UAAU;AACP,aAAA;AAAA,IACR;AACA,WAAO,SAAS,KAAK,CAAM,OAAA,GAAG,OAAO,QAAQ;AAAA,EAAA,GAC3C,CAAC,UAAU,QAAQ,CAAC;AAEvB,QAAM,UAAUC,KAAA;AAAA,IACfC,KAAAA,UAAUC,KAAAA,WAAW;AAAA,IACrBD,KAAAA,UAAUE,KAAAA,WAAW;AAAA,IACrBF,KAAAA,UAAUG,KAAAA,cAAc;AAAA,EAAA;AAGzB,QAAM,eAAe,MAAM;AAC1B,gBAAY,IAAI;AAAA,EAAA;AAGjB,QAAM,YAAYC,MAAY,YAAA,CAAC,EAAE,QAAQ,WAAyB;AACjE,gBAAY,IAAI;AAChB,UAAM,eAAe,SAAS,KAAK,QAAM,GAAG,OAAO,OAAO,EAAE;AACtD,UAAA,YAAY,OAAO,SAAS,UAAU,QAAM,GAAG,OAAO,KAAK,EAAE,IAAI;AACnE,QAAA,CAAC,gBAAgB,cAAc,QAAW;AAC7C;AAAA,IACD;AACA,eAAW,cAAc,SAAS;AAAA,EAAA,GAChC,CAAC,UAAU,QAAQ,CAAC;AAGtB,SAAAC,2BAAA;AAAA,IAACC,KAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACV,WAAW;AAAA,UACV,UAAUC,KAAkB,kBAAA;AAAA,QAC7B;AAAA,MACD;AAAA,MACA,aAAa,CAAC,EAAE,aAAa;AAC5B,oBAAY,OAAO,EAAE;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA,oBAAoBC,KAAA;AAAA,MAEpB,UAACH,2BAAA,IAAAI,qCAA4B,UAA5B,EAAqC,OAAO,YAC5C,UAACJ,2BAAAA,IAAAK,SAAAA,iBAAA,EAAgB,OAAO,UAAU,UAAUC,SAAAA,6BAC1C,SACF,CAAA,GACD;AAAA,IAAA;AAAA,EAAA;AAGH;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortable.js","sources":["../../../src/components/RepeaterSortable.tsx"],"sourcesContent":["import React, { ReactNode, useCallback, useMemo, useState } from 'react'\nimport {\n\tclosestCenter,\n\tDndContext,\n\tDragEndEvent,\n\tKeyboardSensor,\n\tMeasuringStrategy,\n\tMouseSensor,\n\tTouchSensor,\n\tUniqueIdentifier,\n\tuseSensor,\n\tuseSensors,\n} from '@dnd-kit/core'\nimport { RepeaterActiveEntityContext } from '../contexts'\nimport { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { useRepeaterMethods } from '@contember/react-repeater'\n\nexport const RepeaterSortable = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst [activeId, setActiveId] = useState<UniqueIdentifier | null>(null)\n\tconst { moveItem } = useRepeaterMethods()\n\tconst entities = useRepeaterSortedEntities()\n\n\n\tconst activeItem = useMemo(() => {\n\t\tif (!activeId) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn entities.find(it => it.id === activeId)\n\t}, [activeId, entities])\n\n\tconst sensors = useSensors(\n\t\tuseSensor(MouseSensor),\n\t\tuseSensor(TouchSensor),\n\t\tuseSensor(KeyboardSensor),\n\t)\n\n\tconst onDragCancel = () => {\n\t\tsetActiveId(null)\n\t}\n\n\tconst onDragEnd = useCallback(({ active, over }: DragEndEvent) => {\n\t\tsetActiveId(null)\n\t\tconst activeEntity = entities.find(it => it.id === active.id)\n\t\tconst overIndex = over ? entities.findIndex(it => it.id === over.id) : undefined\n\t\tif (!activeEntity || overIndex === undefined) {\n\t\t\treturn\n\t\t}\n\t\tmoveItem?.(activeEntity, overIndex)\n\t}, [entities, moveItem])\n\n\treturn (\n\t\t<DndContext\n\t\t\tsensors={sensors}\n\t\t\tmeasuring={{\n\t\t\t\tdroppable: {\n\t\t\t\t\tstrategy: MeasuringStrategy.Always,\n\t\t\t\t},\n\t\t\t}}\n\t\t\tonDragStart={({ active }) => {\n\t\t\t\tsetActiveId(active.id)\n\t\t\t}}\n\t\t\tonDragEnd={onDragEnd}\n\t\t\tonDragCancel={onDragCancel}\n\t\t\tcollisionDetection={closestCenter}\n\t\t>\n\t\t\t<RepeaterActiveEntityContext.Provider value={activeItem}>\n\t\t\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t\t\t{children}\n\t\t\t\t</SortableContext>\n\t\t\t</RepeaterActiveEntityContext.Provider>\n\t\t</DndContext>\n\t)\n}\n"],"names":[],"mappings":";;;;;;AAkBO,MAAM,mBAAmB,CAAC,EAAE,eAE7B;AACL,QAAM,CAAC,UAAU,WAAW,IAAI,SAAkC,IAAI;AAChE,QAAA,EAAE,aAAa;AACrB,QAAM,WAAW;AAGX,QAAA,aAAa,QAAQ,MAAM;AAChC,QAAI,CAAC,UAAU;AACP,aAAA;AAAA,IACR;AACA,WAAO,SAAS,KAAK,CAAM,OAAA,GAAG,OAAO,QAAQ;AAAA,EAAA,GAC3C,CAAC,UAAU,QAAQ,CAAC;AAEvB,QAAM,UAAU;AAAA,IACf,UAAU,WAAW;AAAA,IACrB,UAAU,WAAW;AAAA,IACrB,UAAU,cAAc;AAAA,EAAA;AAGzB,QAAM,eAAe,MAAM;AAC1B,gBAAY,IAAI;AAAA,EAAA;AAGjB,QAAM,YAAY,YAAY,CAAC,EAAE,QAAQ,WAAyB;AACjE,gBAAY,IAAI;AAChB,UAAM,eAAe,SAAS,KAAK,QAAM,GAAG,OAAO,OAAO,EAAE;AACtD,UAAA,YAAY,OAAO,SAAS,UAAU,QAAM,GAAG,OAAO,KAAK,EAAE,IAAI;AACnE,QAAA,CAAC,gBAAgB,cAAc,QAAW;AAC7C;AAAA,IACD;AACA,eAAW,cAAc,SAAS;AAAA,EAAA,GAChC,CAAC,UAAU,QAAQ,CAAC;AAGtB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACV,WAAW;AAAA,UACV,UAAU,kBAAkB;AAAA,QAC7B;AAAA,MACD;AAAA,MACA,aAAa,CAAC,EAAE,aAAa;AAC5B,oBAAY,OAAO,EAAE;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA,oBAAoB;AAAA,MAEpB,UAAC,oBAAA,4BAA4B,UAA5B,EAAqC,OAAO,YAC5C,UAAC,oBAAA,iBAAA,EAAgB,OAAO,UAAU,UAAU,6BAC1C,SACF,CAAA,GACD;AAAA,IAAA;AAAA,EAAA;AAGH;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableDragOverlay.cjs","sources":["../../../src/components/RepeaterSortableDragOverlay.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterActiveEntity } from '../contexts'\nimport { Portal } from '@radix-ui/react-portal'\nimport { DragOverlay } from '@dnd-kit/core'\nimport { AccessorTree, Entity, useAccessorTreeState } from '@contember/react-binding'\nimport { RepeaterCurrentEntityContext } from '@contember/react-repeater'\n\nexport const RepeaterSortableDragOverlay = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst activeItem = useRepeaterActiveEntity()\n\tconst accessorTreeState = useAccessorTreeState()\n\tif (!activeItem) {\n\t\treturn null\n\t}\n\treturn (\n\t\t<Portal>\n\t\t\t<DragOverlay>\n\t\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t\t<Entity accessor={activeItem}>\n\t\t\t\t\t\t<RepeaterCurrentEntityContext.Provider value={activeItem}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</RepeaterCurrentEntityContext.Provider>\n\t\t\t\t\t</Entity>\n\t\t\t\t</AccessorTree>\n\t\t\t</DragOverlay>\n\t\t</Portal>\n\t)\n}\n"],"names":["useRepeaterActiveEntity","useAccessorTreeState","jsx","Portal","DragOverlay","AccessorTree","Entity","RepeaterCurrentEntityContext"],"mappings":";;;;;;;;AAOO,MAAM,8BAA8B,CAAC,EAAE,eAExC;AACL,QAAM,aAAaA,SAAAA;AACnB,QAAM,oBAAoBC,aAAAA;AAC1B,MAAI,CAAC,YAAY;AACT,WAAA;AAAA,EACR;AAEC,SAAAC,2BAAA,IAACC,sBACA,UAACD,2BAAAA,IAAAE,KAAAA,aAAA,EACA,yCAACC,aAAa,cAAA,EAAA,OAAO,mBACpB,UAAAH,2BAAAA,IAACI,aAAAA,QAAO,EAAA,UAAU,YACjB,UAACJ,2BAAA,IAAAK,cAAA,6BAA6B,UAA7B,EAAsC,OAAO,YAC5C,SACF,CAAA,EACD,CAAA,EACD,CAAA,EACD,CAAA,EACD,CAAA;AAEF;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableDragOverlay.js","sources":["../../../src/components/RepeaterSortableDragOverlay.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterActiveEntity } from '../contexts'\nimport { Portal } from '@radix-ui/react-portal'\nimport { DragOverlay } from '@dnd-kit/core'\nimport { AccessorTree, Entity, useAccessorTreeState } from '@contember/react-binding'\nimport { RepeaterCurrentEntityContext } from '@contember/react-repeater'\n\nexport const RepeaterSortableDragOverlay = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst activeItem = useRepeaterActiveEntity()\n\tconst accessorTreeState = useAccessorTreeState()\n\tif (!activeItem) {\n\t\treturn null\n\t}\n\treturn (\n\t\t<Portal>\n\t\t\t<DragOverlay>\n\t\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t\t<Entity accessor={activeItem}>\n\t\t\t\t\t\t<RepeaterCurrentEntityContext.Provider value={activeItem}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</RepeaterCurrentEntityContext.Provider>\n\t\t\t\t\t</Entity>\n\t\t\t\t</AccessorTree>\n\t\t\t</DragOverlay>\n\t\t</Portal>\n\t)\n}\n"],"names":[],"mappings":";;;;;;AAOO,MAAM,8BAA8B,CAAC,EAAE,eAExC;AACL,QAAM,aAAa;AACnB,QAAM,oBAAoB;AAC1B,MAAI,CAAC,YAAY;AACT,WAAA;AAAA,EACR;AAEC,SAAA,oBAAC,UACA,UAAC,oBAAA,aAAA,EACA,8BAAC,cAAa,EAAA,OAAO,mBACpB,UAAA,oBAAC,QAAO,EAAA,UAAU,YACjB,UAAC,oBAAA,6BAA6B,UAA7B,EAAsC,OAAO,YAC5C,SACF,CAAA,EACD,CAAA,EACD,CAAA,EACD,CAAA,EACD,CAAA;AAEF;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableDropIndicator.cjs","sources":["../../../src/components/RepeaterSortableDropIndicator.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\n\nexport const RepeaterSortableDropIndicator = ({ children, position }: {\n\tchildren: ReactNode\n\tposition: 'before' | 'after'\n}) => {\n\tconst sortable = useRepeaterSortableItem()\n\tconst isOver = sortable.isOver\n\tconst activeSortable = sortable.active?.data.current?.sortable\n\tconst isAfter = (sortable.data?.sortable.index ?? 0) > activeSortable?.index\n\tconst renderedPosition = isAfter ? 'after' : 'before'\n\n\treturn renderedPosition === position && isOver ? <>{children}</> : null\n}\n"],"names":["useRepeaterSortableItem","jsx","Fragment"],"mappings":";;;;AAGO,MAAM,gCAAgC,CAAC,EAAE,UAAU,eAGpD;AACL,QAAM,WAAWA,SAAAA;AACjB,QAAM,SAAS,SAAS;AACxB,QAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS;AACtD,QAAM,WAAW,SAAS,MAAM,SAAS,SAAS,KAAK,gBAAgB;AACjE,QAAA,mBAAmB,UAAU,UAAU;AAE7C,SAAO,qBAAqB,YAAY,SAASC,2BAAAA,IAAAC,WAAAA,UAAA,EAAG,UAAS,IAAM;AACpE;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableDropIndicator.js","sources":["../../../src/components/RepeaterSortableDropIndicator.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\n\nexport const RepeaterSortableDropIndicator = ({ children, position }: {\n\tchildren: ReactNode\n\tposition: 'before' | 'after'\n}) => {\n\tconst sortable = useRepeaterSortableItem()\n\tconst isOver = sortable.isOver\n\tconst activeSortable = sortable.active?.data.current?.sortable\n\tconst isAfter = (sortable.data?.sortable.index ?? 0) > activeSortable?.index\n\tconst renderedPosition = isAfter ? 'after' : 'before'\n\n\treturn renderedPosition === position && isOver ? <>{children}</> : null\n}\n"],"names":[],"mappings":";;AAGO,MAAM,gCAAgC,CAAC,EAAE,UAAU,eAGpD;AACL,QAAM,WAAW;AACjB,QAAM,SAAS,SAAS;AACxB,QAAM,iBAAiB,SAAS,QAAQ,KAAK,SAAS;AACtD,QAAM,WAAW,SAAS,MAAM,SAAS,SAAS,KAAK,gBAAgB;AACjE,QAAA,mBAAmB,UAAU,UAAU;AAE7C,SAAO,qBAAqB,YAAY,SAAS,oBAAA,UAAA,EAAG,UAAS,IAAM;AACpE;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableEachItem.cjs","sources":["../../../src/components/RepeaterSortableEachItem.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { RepeaterEachItem, useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { RepeaterSortableItemContext } from '../contexts'\nimport { useEntity } from '@contember/react-binding'\n\nexport const RepeaterSortableEachItem = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entities = useRepeaterSortedEntities()\n\n\treturn (\n\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t<RepeaterEachItem>\n\t\t\t\t<RepeaterSortableEachItemInner>\n\t\t\t\t\t{children}\n\t\t\t\t</RepeaterSortableEachItemInner>\n\n\t\t\t</RepeaterEachItem>\n\t\t</SortableContext>\n\t)\n}\nconst RepeaterSortableEachItemInner = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entity = useEntity()\n\tconst sortable = useSortable({\n\t\tid: entity.id,\n\t})\n\treturn (\n\t\t<RepeaterSortableItemContext.Provider value={sortable}>\n\t\t\t{children}\n\t\t</RepeaterSortableItemContext.Provider>\n\t)\n}\n"],"names":["useRepeaterSortedEntities","jsx","SortableContext","verticalListSortingStrategy","RepeaterEachItem","useEntity","sortable","useSortable","RepeaterSortableItemContext"],"mappings":";;;;;;;AAMO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACL,QAAM,WAAWA,cAAAA;AAEjB,SACEC,2BAAAA,IAAAC,SAAAA,iBAAA,EAAgB,OAAO,UAAU,UAAUC,SAAA,6BAC3C,UAACF,2BAAAA,IAAAG,cAAAA,kBAAA,EACA,UAACH,2BAAAA,IAAA,+BAAA,EACC,UACF,EAAA,CAED,EACD,CAAA;AAEF;AACA,MAAM,gCAAgC,CAAC,EAAE,eAEnC;AACL,QAAM,SAASI,aAAAA;AACf,QAAMC,aAAWC,SAAAA,YAAY;AAAA,IAC5B,IAAI,OAAO;AAAA,EAAA,CACX;AACD,wCACEC,SAAAA,4BAA4B,UAA5B,EAAqC,OAAOF,YAC3C,SACF,CAAA;AAEF;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableEachItem.js","sources":["../../../src/components/RepeaterSortableEachItem.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'\nimport { RepeaterEachItem, useRepeaterSortedEntities } from '@contember/react-repeater'\nimport { RepeaterSortableItemContext } from '../contexts'\nimport { useEntity } from '@contember/react-binding'\n\nexport const RepeaterSortableEachItem = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entities = useRepeaterSortedEntities()\n\n\treturn (\n\t\t<SortableContext items={entities} strategy={verticalListSortingStrategy}>\n\t\t\t<RepeaterEachItem>\n\t\t\t\t<RepeaterSortableEachItemInner>\n\t\t\t\t\t{children}\n\t\t\t\t</RepeaterSortableEachItemInner>\n\n\t\t\t</RepeaterEachItem>\n\t\t</SortableContext>\n\t)\n}\nconst RepeaterSortableEachItemInner = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst entity = useEntity()\n\tconst sortable = useSortable({\n\t\tid: entity.id,\n\t})\n\treturn (\n\t\t<RepeaterSortableItemContext.Provider value={sortable}>\n\t\t\t{children}\n\t\t</RepeaterSortableItemContext.Provider>\n\t)\n}\n"],"names":[],"mappings":";;;;;AAMO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACL,QAAM,WAAW;AAEjB,SACE,oBAAA,iBAAA,EAAgB,OAAO,UAAU,UAAU,6BAC3C,UAAC,oBAAA,kBAAA,EACA,UAAC,oBAAA,+BAAA,EACC,UACF,EAAA,CAED,EACD,CAAA;AAEF;AACA,MAAM,gCAAgC,CAAC,EAAE,eAEnC;AACL,QAAM,SAAS;AACf,QAAM,WAAW,YAAY;AAAA,IAC5B,IAAI,OAAO;AAAA,EAAA,CACX;AACD,6BACE,4BAA4B,UAA5B,EAAqC,OAAO,UAC3C,SACF,CAAA;AAEF;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableItemActivator.cjs","sources":["../../../src/components/RepeaterSortableItemActivator.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useComposeRef } from '@contember/react-utils'\n\nexport const RepeaterSortableItemActivator = forwardRef<HTMLElement, {\n\tchildren: ReactNode\n}>((props, ref) => {\n\tconst { setActivatorNodeRef, listeners } = useRepeaterSortableItem()\n\treturn <Slot ref={useComposeRef(ref, setActivatorNodeRef)} {...listeners} {...props} />\n})\n"],"names":["forwardRef","useRepeaterSortableItem","jsx","Slot","useComposeRef"],"mappings":";;;;;;;AAKO,MAAM,gCAAgCA,MAAA,WAE1C,CAAC,OAAO,QAAQ;AAClB,QAAM,EAAE,qBAAqB,UAAU,IAAIC,SAAwB,wBAAA;AAC5D,SAAAC,+BAACC,UAAAA,MAAK,EAAA,KAAKC,WAAAA,cAAc,KAAK,mBAAmB,GAAI,GAAG,WAAY,GAAG,MAAO,CAAA;AACtF,CAAC;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableItemActivator.js","sources":["../../../src/components/RepeaterSortableItemActivator.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\nimport { useComposeRef } from '@contember/react-utils'\n\nexport const RepeaterSortableItemActivator = forwardRef<HTMLElement, {\n\tchildren: ReactNode\n}>((props, ref) => {\n\tconst { setActivatorNodeRef, listeners } = useRepeaterSortableItem()\n\treturn <Slot ref={useComposeRef(ref, setActivatorNodeRef)} {...listeners} {...props} />\n})\n"],"names":[],"mappings":";;;;;AAKO,MAAM,gCAAgC,WAE1C,CAAC,OAAO,QAAQ;AAClB,QAAM,EAAE,qBAAqB,UAAU,IAAI,wBAAwB;AAC5D,SAAA,oBAAC,MAAK,EAAA,KAAK,cAAc,KAAK,mBAAmB,GAAI,GAAG,WAAY,GAAG,MAAO,CAAA;AACtF,CAAC;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableItemNode.cjs","sources":["../../../src/components/RepeaterSortableItemNode.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\n\nexport const RepeaterSortableItemNode = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst { setNodeRef } = useRepeaterSortableItem()\n\treturn <Slot ref={setNodeRef}>{children}</Slot>\n}\n"],"names":["useRepeaterSortableItem","jsx","Slot"],"mappings":";;;;;AAIO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACC,QAAA,EAAE,eAAeA,SAAAA;AACvB,SAAQC,2BAAAA,IAAAC,UAAAA,MAAA,EAAK,KAAK,YAAa,SAAS,CAAA;AACzC;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterSortableItemNode.js","sources":["../../../src/components/RepeaterSortableItemNode.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useRepeaterSortableItem } from '../contexts'\nimport { Slot } from '@radix-ui/react-slot'\n\nexport const RepeaterSortableItemNode = ({ children }: {\n\tchildren: ReactNode\n}) => {\n\tconst { setNodeRef } = useRepeaterSortableItem()\n\treturn <Slot ref={setNodeRef}>{children}</Slot>\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,2BAA2B,CAAC,EAAE,eAErC;AACC,QAAA,EAAE,eAAe;AACvB,SAAQ,oBAAA,MAAA,EAAK,KAAK,YAAa,SAAS,CAAA;AACzC;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.cjs","sources":["../../src/contexts.ts"],"sourcesContent":["import { createRequiredContext, createContext } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/react-binding'\nimport { useSortable } from '@dnd-kit/sortable'\n\nconst RepeaterSortableItemContext_ = createRequiredContext<ReturnType<typeof useSortable>>('RepeaterSortableItemContext')\n/** @internal */\nexport const RepeaterSortableItemContext = RepeaterSortableItemContext_[0]\nexport const useRepeaterSortableItem = RepeaterSortableItemContext_[1]\n\nconst RepeaterActiveEntityContext_ = createContext<EntityAccessor | undefined>('RepeaterActiveEntityContext', undefined)\n/** @internal */\nexport const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0]\nexport const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1]\n"],"names":["createRequiredContext","createContext"],"mappings":";;;AAIA,MAAM,+BAA+BA,WAAAA,sBAAsD,6BAA6B;AAE3G,MAAA,8BAA8B,6BAA6B,CAAC;AAC5D,MAAA,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,+BAA+BC,WAA0C,cAAA,+BAA+B,MAAS;AAE1G,MAAA,8BAA8B,6BAA6B,CAAC;AAC5D,MAAA,0BAA0B,6BAA6B,CAAC;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.js","sources":["../../src/contexts.ts"],"sourcesContent":["import { createRequiredContext, createContext } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/react-binding'\nimport { useSortable } from '@dnd-kit/sortable'\n\nconst RepeaterSortableItemContext_ = createRequiredContext<ReturnType<typeof useSortable>>('RepeaterSortableItemContext')\n/** @internal */\nexport const RepeaterSortableItemContext = RepeaterSortableItemContext_[0]\nexport const useRepeaterSortableItem = RepeaterSortableItemContext_[1]\n\nconst RepeaterActiveEntityContext_ = createContext<EntityAccessor | undefined>('RepeaterActiveEntityContext', undefined)\n/** @internal */\nexport const RepeaterActiveEntityContext = RepeaterActiveEntityContext_[0]\nexport const useRepeaterActiveEntity = RepeaterActiveEntityContext_[1]\n"],"names":[],"mappings":";AAIA,MAAM,+BAA+B,sBAAsD,6BAA6B;AAE3G,MAAA,8BAA8B,6BAA6B,CAAC;AAC5D,MAAA,0BAA0B,6BAA6B,CAAC;AAErE,MAAM,+BAA+B,cAA0C,+BAA+B,MAAS;AAE1G,MAAA,8BAA8B,6BAA6B,CAAC;AAC5D,MAAA,0BAA0B,6BAA6B,CAAC;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|