@editora/ui-sortable 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +329 -0
- package/dist/react.cjs.js +1 -0
- package/dist/react.esm.js +338 -0
- package/package.json +29 -3
- package/react.d.ts +96 -0
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# @editora/ui-sortable
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **Broader docs and examples:** https://editora-ecosystem.netlify.app/docs/ui-react/interactive/sortable
|
|
5
|
+
|
|
6
|
+
Standalone package for the Editora sortable web component.
|
|
7
|
+
|
|
8
|
+
`@editora/ui-sortable` is the smallest way to ship `<ui-sortable>` without importing the full `@editora/ui-core` catalog. It supports:
|
|
9
|
+
- single-list reordering
|
|
10
|
+
- multi-list transfer
|
|
11
|
+
- nesting and hierarchy
|
|
12
|
+
- multi-selection
|
|
13
|
+
- keyboard-accessible drag and drop
|
|
14
|
+
- indicator or container-style dropzones
|
|
15
|
+
- an optional React wrapper via `@editora/ui-sortable/react`
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @editora/ui-sortable
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If you want the React wrapper entry, also install React peer dependencies:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install react react-dom
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or install the standalone React-ready setup in one step:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @editora/ui-sortable react react-dom
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
Import the package once to register the custom element:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import '@editora/ui-sortable';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then bind lists and items:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import '@editora/ui-sortable';
|
|
47
|
+
|
|
48
|
+
const sortable = document.querySelector('ui-sortable');
|
|
49
|
+
|
|
50
|
+
sortable.lists = [
|
|
51
|
+
{ id: 'backlog', label: 'Backlog' },
|
|
52
|
+
{ id: 'in-progress', label: 'In Progress' },
|
|
53
|
+
{ id: 'done', label: 'Done' }
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
sortable.items = [
|
|
57
|
+
{ id: 'story-1', label: 'Audit onboarding', listId: 'backlog' },
|
|
58
|
+
{ id: 'story-2', label: 'Ship release notes', listId: 'in-progress' },
|
|
59
|
+
{ id: 'story-3', label: 'Review handoff', listId: 'done' }
|
|
60
|
+
];
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<ui-sortable></ui-sortable>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## React Wrapper
|
|
68
|
+
|
|
69
|
+
The package also exposes a standalone React wrapper:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { Sortable, type SortableItem, type SortableList } from '@editora/ui-sortable/react';
|
|
73
|
+
|
|
74
|
+
const lists: SortableList[] = [
|
|
75
|
+
{ id: 'backlog', label: 'Backlog' },
|
|
76
|
+
{ id: 'done', label: 'Done' }
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
const items: SortableItem[] = [
|
|
80
|
+
{ id: 'story-1', label: 'Audit onboarding', listId: 'backlog' },
|
|
81
|
+
{ id: 'story-2', label: 'Ship release notes', listId: 'done' }
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
export function Example() {
|
|
85
|
+
return (
|
|
86
|
+
<Sortable
|
|
87
|
+
lists={lists}
|
|
88
|
+
items={items}
|
|
89
|
+
dropzoneStyle="container"
|
|
90
|
+
onChange={(detail) => {
|
|
91
|
+
console.log(detail.items);
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Use `@editora/ui-sortable/react` when you want the sortable wrapper only, without taking the rest of `@editora/ui-react`.
|
|
99
|
+
|
|
100
|
+
If you are using Next.js, App Router, or another SSR/RSC framework, import `@editora/ui-sortable/react` from a client component because it registers the custom element in the browser runtime.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
'use client';
|
|
104
|
+
|
|
105
|
+
import { Sortable } from '@editora/ui-sortable/react';
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## React Examples
|
|
109
|
+
|
|
110
|
+
### Controlled Board
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import * as React from 'react';
|
|
114
|
+
import { Sortable, type SortableItem, type SortableList } from '@editora/ui-sortable/react';
|
|
115
|
+
|
|
116
|
+
const lists: SortableList[] = [
|
|
117
|
+
{ id: 'templates', label: 'Templates', cloneOnDrag: true },
|
|
118
|
+
{ id: 'backlog', label: 'Backlog' },
|
|
119
|
+
{ id: 'active', label: 'In Progress' },
|
|
120
|
+
{ id: 'done', label: 'Done', orientation: 'horizontal' }
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
const initialItems: SortableItem[] = [
|
|
124
|
+
{ id: 'template-brief', label: 'Launch brief template', listId: 'templates', cloneOnDrag: true },
|
|
125
|
+
{ id: 'epic', label: 'Release epic', listId: 'backlog' },
|
|
126
|
+
{ id: 'brief', label: 'Draft launch brief', listId: 'backlog', parentId: 'epic' },
|
|
127
|
+
{ id: 'review', label: 'Design review', listId: 'active' }
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
export function ReleaseBoard() {
|
|
131
|
+
const [items, setItems] = React.useState(initialItems);
|
|
132
|
+
const [selection, setSelection] = React.useState<string[]>(['epic']);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<Sortable
|
|
136
|
+
lists={lists}
|
|
137
|
+
items={items}
|
|
138
|
+
selection={selection}
|
|
139
|
+
persistKey="release-board"
|
|
140
|
+
onItemsChange={setItems}
|
|
141
|
+
onSelectionChange={(detail) => setSelection(detail.selection)}
|
|
142
|
+
onPersistRequest={(detail) => {
|
|
143
|
+
console.log(detail.persistence.records);
|
|
144
|
+
}}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Flat List Sorting
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
import * as React from 'react';
|
|
154
|
+
import { Sortable, type SortableItem, type SortableList } from '@editora/ui-sortable/react';
|
|
155
|
+
|
|
156
|
+
const lists: SortableList[] = [
|
|
157
|
+
{ id: 'queue', label: 'Editorial Queue' }
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
const initialItems: SortableItem[] = [
|
|
161
|
+
{ id: 'headline', label: 'Headline polish', listId: 'queue' },
|
|
162
|
+
{ id: 'legal', label: 'Legal review', listId: 'queue' },
|
|
163
|
+
{ id: 'seo', label: 'SEO metadata', listId: 'queue' }
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
export function FlatSortableQueue() {
|
|
167
|
+
const [items, setItems] = React.useState(initialItems);
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<Sortable
|
|
171
|
+
lists={lists}
|
|
172
|
+
items={items}
|
|
173
|
+
allowNesting={false}
|
|
174
|
+
onItemsChange={setItems}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Clone Library
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
import { Sortable, type SortableItem, type SortableList } from '@editora/ui-sortable/react';
|
|
184
|
+
|
|
185
|
+
const lists: SortableList[] = [
|
|
186
|
+
{ id: 'library', label: 'Template Library', cloneOnDrag: true },
|
|
187
|
+
{ id: 'campaign', label: 'Campaign Plan' }
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
const items: SortableItem[] = [
|
|
191
|
+
{ id: 'press-kit', label: 'Press kit template', listId: 'library', cloneOnDrag: true },
|
|
192
|
+
{ id: 'email-series', label: 'Lifecycle email series', listId: 'library', cloneOnDrag: true },
|
|
193
|
+
{ id: 'owner-sync', label: 'Owner sync', listId: 'campaign' }
|
|
194
|
+
];
|
|
195
|
+
|
|
196
|
+
export function CloneLibraryExample() {
|
|
197
|
+
return <Sortable lists={lists} items={items} />;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Container Dropzones
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
<Sortable
|
|
205
|
+
lists={lists}
|
|
206
|
+
items={items}
|
|
207
|
+
dropzoneStyle="container"
|
|
208
|
+
/>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Custom Item Rendering
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
<Sortable
|
|
215
|
+
lists={lists}
|
|
216
|
+
items={items}
|
|
217
|
+
selection={selection}
|
|
218
|
+
onItemsChange={setItems}
|
|
219
|
+
renderItem={(item, context) => (
|
|
220
|
+
<div style={{ display: 'grid', gap: 8 }}>
|
|
221
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', gap: 12 }}>
|
|
222
|
+
<strong>{item.label}</strong>
|
|
223
|
+
<span>{context.selected ? 'Selected' : 'Ready'}</span>
|
|
224
|
+
</div>
|
|
225
|
+
{item.description && <div>{item.description}</div>}
|
|
226
|
+
<small>{context.list?.label}</small>
|
|
227
|
+
</div>
|
|
228
|
+
)}
|
|
229
|
+
/>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Custom List Headers And Empty States
|
|
233
|
+
|
|
234
|
+
```tsx
|
|
235
|
+
<Sortable
|
|
236
|
+
lists={lists}
|
|
237
|
+
items={items}
|
|
238
|
+
renderListHeader={(list, context) => (
|
|
239
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', gap: 12 }}>
|
|
240
|
+
<strong>{list.label}</strong>
|
|
241
|
+
<span>{context.itemCount} items</span>
|
|
242
|
+
</div>
|
|
243
|
+
)}
|
|
244
|
+
renderEmptyState={(list) => (
|
|
245
|
+
<div>
|
|
246
|
+
No items in {list.label} yet. Drag something here to get started.
|
|
247
|
+
</div>
|
|
248
|
+
)}
|
|
249
|
+
/>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Nested Hierarchy
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
import { Sortable, type SortableItem, type SortableList } from '@editora/ui-sortable/react';
|
|
256
|
+
|
|
257
|
+
const lists: SortableList[] = [
|
|
258
|
+
{ id: 'roadmap', label: 'Roadmap' }
|
|
259
|
+
];
|
|
260
|
+
|
|
261
|
+
const items: SortableItem[] = [
|
|
262
|
+
{ id: 'initiative', label: 'Reader retention initiative', listId: 'roadmap' },
|
|
263
|
+
{ id: 'survey', label: 'Audience survey', listId: 'roadmap', parentId: 'initiative' },
|
|
264
|
+
{ id: 'experiment', label: 'Paywall experiment', listId: 'roadmap' }
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
export function NestedHierarchyExample() {
|
|
268
|
+
return <Sortable lists={lists} items={items} />;
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
For broader usage patterns, Storybook-style variations, and the full prop reference, use the Editora docs:
|
|
273
|
+
|
|
274
|
+
- https://editora-ecosystem.netlify.app/docs/ui-react/interactive/sortable
|
|
275
|
+
|
|
276
|
+
## Dropzone Styles
|
|
277
|
+
|
|
278
|
+
Use the default insertion rails:
|
|
279
|
+
|
|
280
|
+
```html
|
|
281
|
+
<ui-sortable></ui-sortable>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Or switch to container-style dropzones:
|
|
285
|
+
|
|
286
|
+
```html
|
|
287
|
+
<ui-sortable dropzone-style="container"></ui-sortable>
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Common Attributes
|
|
291
|
+
|
|
292
|
+
- `dropzone-style="indicator|container"`
|
|
293
|
+
- `drop-indicator-visibility="active|always"`
|
|
294
|
+
- `drag-preview-size="match-item|compact"`
|
|
295
|
+
- `drag-handle-mode="handle|item"`
|
|
296
|
+
- `allow-nesting`
|
|
297
|
+
- `persist-key`
|
|
298
|
+
|
|
299
|
+
## Events
|
|
300
|
+
|
|
301
|
+
The component emits `CustomEvent`s such as:
|
|
302
|
+
- `change`
|
|
303
|
+
- `selection-change`
|
|
304
|
+
|
|
305
|
+
Each event provides structured detail payloads for the latest ordering or selection state.
|
|
306
|
+
|
|
307
|
+
## Type Exports
|
|
308
|
+
|
|
309
|
+
The package also re-exports sortable types from `@editora/ui-core/sortable`, including:
|
|
310
|
+
- `UISortable`
|
|
311
|
+
- `UISortableList`
|
|
312
|
+
- `UISortableItem`
|
|
313
|
+
- `UISortableChangeDetail`
|
|
314
|
+
- `UISortableDropzoneStyle`
|
|
315
|
+
|
|
316
|
+
The React subpath exports:
|
|
317
|
+
- `Sortable`
|
|
318
|
+
- `SortableList`
|
|
319
|
+
- `SortableItem`
|
|
320
|
+
- `SortableChangeDetail`
|
|
321
|
+
- `SortableDropzoneStyle`
|
|
322
|
+
|
|
323
|
+
## Development
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
cd packages/ui-sortable
|
|
327
|
+
npm run build
|
|
328
|
+
npm run test
|
|
329
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=require("react/jsx-runtime"),bt=require("react"),z=require("react-dom");require("@editora/ui-core/sortable");const gt=e=>e&&e.__esModule?e:{default:e},p=gt(bt),L=typeof window<"u"?p.default.useLayoutEffect:p.default.useEffect;function mt(e){const i=p.default.useRef(null);return p.default.useImperativeHandle(e,()=>i.current),i}function pt(e,i,u){p.default.useEffect(()=>{const a=e.current;if(!a)return;const f=i.filter(n=>typeof n.listener=="function");return f.forEach(({type:n,listener:b})=>{a.addEventListener(n,b)}),()=>{f.forEach(({type:n,listener:b})=>{a.removeEventListener(n,b)})}},[e,...u])}function yt(e,i,u){L(()=>{const a=e.current;a&&i(a)},[e,...u])}function H(e){return e.detail}function y(e,i,u){const a=e.getAttribute(i);if(u==null||u===""){a!=null&&e.removeAttribute(i);return}a!==u&&e.setAttribute(i,u)}function it(e,i,u){if(u){e.hasAttribute(i)||e.setAttribute(i,"");return}e.hasAttribute(i)&&e.removeAttribute(i)}function B(e,i,u){if(u==null){y(e,i,null);return}try{y(e,i,JSON.stringify(u))}catch{y(e,i,null)}}function F(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}function ot(e){if(e==null||e==="")return null;if(typeof e=="number")return`${e}px`;switch(e){case"none":return"0px";case"sm":return"10px";case"md":return"16px";case"lg":return"20px";case"xl":return"28px";case"full":return"999px";default:return e}}function ht(e){if(e==null||e==="")return null;if(typeof e=="number")return`${e}px`;switch(e){case"xs":return"6px";case"sm":return"8px";case"md":return"10px";case"lg":return"14px";case"xl":return"18px";default:return e}}const T=p.default.forwardRef(function(i,u){const{lists:a,items:f,selection:n,filterQuery:b,sort:g,persistKey:C,allowFilteredDrag:D,allowNesting:M,dropIndicatorVisibility:j,dropzoneStyle:k,dragPreviewSize:O,dragHandleMode:S,dragHandleSelector:h,itemRadius:N,handleRadius:Q,listGap:G,itemSpacing:J,showSelectionBadge:V,disabled:A,renderItem:d,renderListHeader:w,renderEmptyState:R,onChange:q,onItemsChange:P,onSelectionChange:_,onPersistRequest:$,children:at,...nt}=i,l=mt(u),[x,ut]=p.default.useState(0),K=!!(d||w||R);pt(l,[{type:"change",listener:q||P?t=>{const r=H(t);r&&(q==null||q(r),P==null||P(r.items))}:void 0},{type:"selection-change",listener:_?t=>{const r=H(t);r&&_(r)}:void 0},{type:"persist-request",listener:$?t=>{const r=H(t);r&&$(r)}:void 0}],[q,P,_,$]),yt(l,t=>{B(t,"lists",a),B(t,"items",f),B(t,"selection",n??null),y(t,"filter-query",b??null),y(t,"sort",g&&g!=="manual"?g:null),y(t,"persist-key",C??null),it(t,"allow-filtered-drag",D),M===!1?t.setAttribute("allow-nesting","false"):t.removeAttribute("allow-nesting"),j==="always"?t.setAttribute("drop-indicator-visibility","always"):t.removeAttribute("drop-indicator-visibility"),k==="container"?t.setAttribute("dropzone-style","container"):t.removeAttribute("dropzone-style"),O==="compact"?t.setAttribute("drag-preview-size","compact"):t.removeAttribute("drag-preview-size"),S==="item"?t.setAttribute("drag-handle-mode","item"):t.removeAttribute("drag-handle-mode"),y(t,"drag-handle-selector",h??null);const r=ot(N);r?t.style.setProperty("--ui-sortable-item-radius",r):t.style.removeProperty("--ui-sortable-item-radius");const s=ot(Q);s?t.style.setProperty("--ui-sortable-handle-radius",s):t.style.removeProperty("--ui-sortable-handle-radius");const o=ht(G??J);o?t.style.setProperty("--ui-sortable-list-gap",o):t.style.removeProperty("--ui-sortable-list-gap"),d?t.setAttribute("custom-item-rendering","true"):t.removeAttribute("custom-item-rendering"),V===!1?t.setAttribute("show-selection-badge","false"):t.removeAttribute("show-selection-badge"),it(t,"disabled",A)},[a,f,n,b,g,C,D,M,j,k,O,S,h,N,Q,G,J,d,V,A]),L(()=>{var rt;if(!K)return;const t=l.current,r=(rt=t==null?void 0:t.ownerDocument)==null?void 0:rt.defaultView;if(!t||!r)return;let s=!1,o=!1,c=null,v=null;const Z=[d&&f.length>0?".item-custom-content[data-item-content-target]":null,w&&a.length>0?".list-custom-header[data-list-header-target]":null,R&&a.length>0?".list-custom-empty[data-list-empty-target]":null].filter(Boolean).join(", "),tt=()=>{s||o||(o=!0,queueMicrotask(()=>{o=!1,!s&&ut(m=>m+1)}))},ft=()=>{var I;const m=(I=l.current)==null?void 0:I.shadowRoot;return m?(v||(v=new MutationObserver(()=>tt()),v.observe(m,{childList:!0,subtree:!0})),!0):!1},et=()=>{var st;if(s)return;const m=(st=l.current)==null?void 0:st.shadowRoot,I=!Z||!!(m!=null&&m.querySelector(Z));if(ft()&&I){tt();return}c=r.requestAnimationFrame(et)};return et(),()=>{s=!0,c!==null&&r.cancelAnimationFrame(c),v==null||v.disconnect()}},[l,K,f,a,n,b,g,C,D,M,j,O,S,h,V,A,d,w,R]),L(()=>{const t=l.current,r=t==null?void 0:t.shadowRoot;if(!t)return;if(!d||!r){t.removeAttribute("custom-item-rendering-ready"),t.removeAttribute("custom-item-rendering-pending");return}const s=r.querySelectorAll(".item-custom-content[data-item-content-target]"),o=r.querySelectorAll("[data-sortable-custom-item]");s.length>0&&o.length>=s.length?(t.setAttribute("custom-item-rendering-ready","true"),t.removeAttribute("custom-item-rendering-pending")):(t.removeAttribute("custom-item-rendering-ready"),t.setAttribute("custom-item-rendering-pending","true"))},[l,d,x,f,n,b,g,A]),L(()=>{var r;const t=(r=l.current)==null?void 0:r.shadowRoot;t&&(t.querySelectorAll("[data-sortable-custom-handle]").forEach(s=>{s.removeAttribute("data-sortable-custom-handle"),s.removeAttribute("data-drag-trigger"),s.removeAttribute("data-id"),s.removeAttribute("draggable")}),!(!d||!h||S==="item")&&t.querySelectorAll("[data-sortable-custom-item][data-sortable-item-id]").forEach(s=>{const o=s.getAttribute("data-sortable-item-id");o&&s.querySelectorAll(h).forEach(c=>{c.setAttribute("data-sortable-custom-handle",""),c.setAttribute("data-drag-trigger","custom"),c.setAttribute("data-id",o),c.setAttribute("draggable","true")})}))},[l,d,h,S,x,f,n,b,g,A]);const U=new Map(a.map(t=>[t.id,t])),W=new Map(a.map(t=>[t.id,f.filter(r=>r.listId===t.id).length])),X=!!A||g==="label"||!!b&&!D,lt=d?f.map(t=>{var s,o,c;const r=(o=(s=l.current)==null?void 0:s.shadowRoot)==null?void 0:o.querySelector(`.item-custom-content[data-item-content-target="${F(t.id)}"]`);return r?z.createPortal(E.jsx("div",{"data-sortable-custom-item":"","data-sortable-item-id":t.id,"data-selected":n!=null&&n.includes(t.id)?"true":"false","data-disabled":t.disabled?"true":"false","data-drag-disabled":t.dragDisabled?"true":"false",children:d(t,{selected:(n==null?void 0:n.includes(t.id))??!1,disabled:!!t.disabled,dragDisabled:!!t.dragDisabled,cloneOnDrag:!!t.cloneOnDrag||!!((c=U.get(t.listId))!=null&&c.cloneOnDrag),list:U.get(t.listId)})}),r,t.id):null}):null,dt=w?a.map(t=>{var s,o;const r=(o=(s=l.current)==null?void 0:s.shadowRoot)==null?void 0:o.querySelector(`.list-custom-header[data-list-header-target="${F(t.id)}"]`);return r?z.createPortal(E.jsx("div",{"data-sortable-custom-list-header":"","data-sortable-list-id":t.id,children:w(t,{itemCount:W.get(t.id)??0,dragLocked:X})}),r,`header-${t.id}`):null}):null,ct=R?a.map(t=>{var s,o;const r=(o=(s=l.current)==null?void 0:s.shadowRoot)==null?void 0:o.querySelector(`.list-custom-empty[data-list-empty-target="${F(t.id)}"]`);return r?z.createPortal(E.jsx("div",{"data-sortable-custom-empty":"","data-sortable-list-id":t.id,children:R(t,{itemCount:W.get(t.id)??0,dragLocked:X,filterQuery:b??""})}),r,`empty-${t.id}`):null}):null,Y={ref:l,...nt};return d&&(Y["custom-item-rendering"]=""),E.jsxs(E.Fragment,{children:[p.default.createElement("ui-sortable",Y,at),x>=0?lt:null,x>=0?dt:null,x>=0?ct:null]})});T.displayName="Sortable";exports.Sortable=T;exports.default=T;
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { jsx as B, jsxs as ft, Fragment as bt } from "react/jsx-runtime";
|
|
2
|
+
import p from "react";
|
|
3
|
+
import { createPortal as F } from "react-dom";
|
|
4
|
+
import "@editora/ui-core/sortable";
|
|
5
|
+
const L = typeof window < "u" ? p.useLayoutEffect : p.useEffect;
|
|
6
|
+
function gt(e) {
|
|
7
|
+
const s = p.useRef(null);
|
|
8
|
+
return p.useImperativeHandle(e, () => s.current), s;
|
|
9
|
+
}
|
|
10
|
+
function mt(e, s, u) {
|
|
11
|
+
p.useEffect(() => {
|
|
12
|
+
const a = e.current;
|
|
13
|
+
if (!a)
|
|
14
|
+
return;
|
|
15
|
+
const f = s.filter(
|
|
16
|
+
(n) => typeof n.listener == "function"
|
|
17
|
+
);
|
|
18
|
+
return f.forEach(({ type: n, listener: b }) => {
|
|
19
|
+
a.addEventListener(n, b);
|
|
20
|
+
}), () => {
|
|
21
|
+
f.forEach(({ type: n, listener: b }) => {
|
|
22
|
+
a.removeEventListener(n, b);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}, [e, ...u]);
|
|
26
|
+
}
|
|
27
|
+
function pt(e, s, u) {
|
|
28
|
+
L(() => {
|
|
29
|
+
const a = e.current;
|
|
30
|
+
a && s(a);
|
|
31
|
+
}, [e, ...u]);
|
|
32
|
+
}
|
|
33
|
+
function M(e) {
|
|
34
|
+
return e.detail;
|
|
35
|
+
}
|
|
36
|
+
function y(e, s, u) {
|
|
37
|
+
const a = e.getAttribute(s);
|
|
38
|
+
if (u == null || u === "") {
|
|
39
|
+
a != null && e.removeAttribute(s);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
a !== u && e.setAttribute(s, u);
|
|
43
|
+
}
|
|
44
|
+
function it(e, s, u) {
|
|
45
|
+
if (u) {
|
|
46
|
+
e.hasAttribute(s) || e.setAttribute(s, "");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
e.hasAttribute(s) && e.removeAttribute(s);
|
|
50
|
+
}
|
|
51
|
+
function j(e, s, u) {
|
|
52
|
+
if (u == null) {
|
|
53
|
+
y(e, s, null);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
y(e, s, JSON.stringify(u));
|
|
58
|
+
} catch {
|
|
59
|
+
y(e, s, null);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function k(e) {
|
|
63
|
+
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"');
|
|
64
|
+
}
|
|
65
|
+
function st(e) {
|
|
66
|
+
if (e == null || e === "")
|
|
67
|
+
return null;
|
|
68
|
+
if (typeof e == "number")
|
|
69
|
+
return `${e}px`;
|
|
70
|
+
switch (e) {
|
|
71
|
+
case "none":
|
|
72
|
+
return "0px";
|
|
73
|
+
case "sm":
|
|
74
|
+
return "10px";
|
|
75
|
+
case "md":
|
|
76
|
+
return "16px";
|
|
77
|
+
case "lg":
|
|
78
|
+
return "20px";
|
|
79
|
+
case "xl":
|
|
80
|
+
return "28px";
|
|
81
|
+
case "full":
|
|
82
|
+
return "999px";
|
|
83
|
+
default:
|
|
84
|
+
return e;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function yt(e) {
|
|
88
|
+
if (e == null || e === "")
|
|
89
|
+
return null;
|
|
90
|
+
if (typeof e == "number")
|
|
91
|
+
return `${e}px`;
|
|
92
|
+
switch (e) {
|
|
93
|
+
case "xs":
|
|
94
|
+
return "6px";
|
|
95
|
+
case "sm":
|
|
96
|
+
return "8px";
|
|
97
|
+
case "md":
|
|
98
|
+
return "10px";
|
|
99
|
+
case "lg":
|
|
100
|
+
return "14px";
|
|
101
|
+
case "xl":
|
|
102
|
+
return "18px";
|
|
103
|
+
default:
|
|
104
|
+
return e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const ht = p.forwardRef(function(s, u) {
|
|
108
|
+
const {
|
|
109
|
+
lists: a,
|
|
110
|
+
items: f,
|
|
111
|
+
selection: n,
|
|
112
|
+
filterQuery: b,
|
|
113
|
+
sort: g,
|
|
114
|
+
persistKey: D,
|
|
115
|
+
allowFilteredDrag: q,
|
|
116
|
+
allowNesting: C,
|
|
117
|
+
dropIndicatorVisibility: V,
|
|
118
|
+
dropzoneStyle: N,
|
|
119
|
+
dragPreviewSize: $,
|
|
120
|
+
dragHandleMode: w,
|
|
121
|
+
dragHandleSelector: h,
|
|
122
|
+
itemRadius: Q,
|
|
123
|
+
handleRadius: T,
|
|
124
|
+
listGap: G,
|
|
125
|
+
itemSpacing: J,
|
|
126
|
+
showSelectionBadge: z,
|
|
127
|
+
disabled: A,
|
|
128
|
+
renderItem: d,
|
|
129
|
+
renderListHeader: S,
|
|
130
|
+
renderEmptyState: R,
|
|
131
|
+
onChange: E,
|
|
132
|
+
onItemsChange: x,
|
|
133
|
+
onSelectionChange: H,
|
|
134
|
+
onPersistRequest: O,
|
|
135
|
+
children: ot,
|
|
136
|
+
...at
|
|
137
|
+
} = s, l = gt(u), [P, nt] = p.useState(0), K = !!(d || S || R);
|
|
138
|
+
mt(
|
|
139
|
+
l,
|
|
140
|
+
[
|
|
141
|
+
{
|
|
142
|
+
type: "change",
|
|
143
|
+
listener: E || x ? (t) => {
|
|
144
|
+
const r = M(t);
|
|
145
|
+
r && (E == null || E(r), x == null || x(r.items));
|
|
146
|
+
} : void 0
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: "selection-change",
|
|
150
|
+
listener: H ? (t) => {
|
|
151
|
+
const r = M(t);
|
|
152
|
+
r && H(r);
|
|
153
|
+
} : void 0
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: "persist-request",
|
|
157
|
+
listener: O ? (t) => {
|
|
158
|
+
const r = M(t);
|
|
159
|
+
r && O(r);
|
|
160
|
+
} : void 0
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
[E, x, H, O]
|
|
164
|
+
), pt(
|
|
165
|
+
l,
|
|
166
|
+
(t) => {
|
|
167
|
+
j(t, "lists", a), j(t, "items", f), j(t, "selection", n ?? null), y(t, "filter-query", b ?? null), y(t, "sort", g && g !== "manual" ? g : null), y(t, "persist-key", D ?? null), it(t, "allow-filtered-drag", q), C === !1 ? t.setAttribute("allow-nesting", "false") : t.removeAttribute("allow-nesting"), V === "always" ? t.setAttribute("drop-indicator-visibility", "always") : t.removeAttribute("drop-indicator-visibility"), N === "container" ? t.setAttribute("dropzone-style", "container") : t.removeAttribute("dropzone-style"), $ === "compact" ? t.setAttribute("drag-preview-size", "compact") : t.removeAttribute("drag-preview-size"), w === "item" ? t.setAttribute("drag-handle-mode", "item") : t.removeAttribute("drag-handle-mode"), y(t, "drag-handle-selector", h ?? null);
|
|
168
|
+
const r = st(Q);
|
|
169
|
+
r ? t.style.setProperty("--ui-sortable-item-radius", r) : t.style.removeProperty("--ui-sortable-item-radius");
|
|
170
|
+
const i = st(T);
|
|
171
|
+
i ? t.style.setProperty("--ui-sortable-handle-radius", i) : t.style.removeProperty("--ui-sortable-handle-radius");
|
|
172
|
+
const o = yt(G ?? J);
|
|
173
|
+
o ? t.style.setProperty("--ui-sortable-list-gap", o) : t.style.removeProperty("--ui-sortable-list-gap"), d ? t.setAttribute("custom-item-rendering", "true") : t.removeAttribute("custom-item-rendering"), z === !1 ? t.setAttribute("show-selection-badge", "false") : t.removeAttribute("show-selection-badge"), it(t, "disabled", A);
|
|
174
|
+
},
|
|
175
|
+
[
|
|
176
|
+
a,
|
|
177
|
+
f,
|
|
178
|
+
n,
|
|
179
|
+
b,
|
|
180
|
+
g,
|
|
181
|
+
D,
|
|
182
|
+
q,
|
|
183
|
+
C,
|
|
184
|
+
V,
|
|
185
|
+
N,
|
|
186
|
+
$,
|
|
187
|
+
w,
|
|
188
|
+
h,
|
|
189
|
+
Q,
|
|
190
|
+
T,
|
|
191
|
+
G,
|
|
192
|
+
J,
|
|
193
|
+
d,
|
|
194
|
+
z,
|
|
195
|
+
A
|
|
196
|
+
]
|
|
197
|
+
), L(() => {
|
|
198
|
+
var et;
|
|
199
|
+
if (!K)
|
|
200
|
+
return;
|
|
201
|
+
const t = l.current, r = (et = t == null ? void 0 : t.ownerDocument) == null ? void 0 : et.defaultView;
|
|
202
|
+
if (!t || !r)
|
|
203
|
+
return;
|
|
204
|
+
let i = !1, o = !1, c = null, v = null;
|
|
205
|
+
const Z = [
|
|
206
|
+
d && f.length > 0 ? ".item-custom-content[data-item-content-target]" : null,
|
|
207
|
+
S && a.length > 0 ? ".list-custom-header[data-list-header-target]" : null,
|
|
208
|
+
R && a.length > 0 ? ".list-custom-empty[data-list-empty-target]" : null
|
|
209
|
+
].filter(Boolean).join(", "), _ = () => {
|
|
210
|
+
i || o || (o = !0, queueMicrotask(() => {
|
|
211
|
+
o = !1, !i && nt((m) => m + 1);
|
|
212
|
+
}));
|
|
213
|
+
}, ct = () => {
|
|
214
|
+
var I;
|
|
215
|
+
const m = (I = l.current) == null ? void 0 : I.shadowRoot;
|
|
216
|
+
return m ? (v || (v = new MutationObserver(() => _()), v.observe(m, { childList: !0, subtree: !0 })), !0) : !1;
|
|
217
|
+
}, tt = () => {
|
|
218
|
+
var rt;
|
|
219
|
+
if (i)
|
|
220
|
+
return;
|
|
221
|
+
const m = (rt = l.current) == null ? void 0 : rt.shadowRoot, I = !Z || !!(m != null && m.querySelector(Z));
|
|
222
|
+
if (ct() && I) {
|
|
223
|
+
_();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
c = r.requestAnimationFrame(tt);
|
|
227
|
+
};
|
|
228
|
+
return tt(), () => {
|
|
229
|
+
i = !0, c !== null && r.cancelAnimationFrame(c), v == null || v.disconnect();
|
|
230
|
+
};
|
|
231
|
+
}, [
|
|
232
|
+
l,
|
|
233
|
+
K,
|
|
234
|
+
f,
|
|
235
|
+
a,
|
|
236
|
+
n,
|
|
237
|
+
b,
|
|
238
|
+
g,
|
|
239
|
+
D,
|
|
240
|
+
q,
|
|
241
|
+
C,
|
|
242
|
+
V,
|
|
243
|
+
$,
|
|
244
|
+
w,
|
|
245
|
+
h,
|
|
246
|
+
z,
|
|
247
|
+
A,
|
|
248
|
+
d,
|
|
249
|
+
S,
|
|
250
|
+
R
|
|
251
|
+
]), L(() => {
|
|
252
|
+
const t = l.current, r = t == null ? void 0 : t.shadowRoot;
|
|
253
|
+
if (!t)
|
|
254
|
+
return;
|
|
255
|
+
if (!d || !r) {
|
|
256
|
+
t.removeAttribute("custom-item-rendering-ready"), t.removeAttribute("custom-item-rendering-pending");
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const i = r.querySelectorAll(".item-custom-content[data-item-content-target]"), o = r.querySelectorAll("[data-sortable-custom-item]");
|
|
260
|
+
i.length > 0 && o.length >= i.length ? (t.setAttribute("custom-item-rendering-ready", "true"), t.removeAttribute("custom-item-rendering-pending")) : (t.removeAttribute("custom-item-rendering-ready"), t.setAttribute("custom-item-rendering-pending", "true"));
|
|
261
|
+
}, [l, d, P, f, n, b, g, A]), L(() => {
|
|
262
|
+
var r;
|
|
263
|
+
const t = (r = l.current) == null ? void 0 : r.shadowRoot;
|
|
264
|
+
t && (t.querySelectorAll("[data-sortable-custom-handle]").forEach((i) => {
|
|
265
|
+
i.removeAttribute("data-sortable-custom-handle"), i.removeAttribute("data-drag-trigger"), i.removeAttribute("data-id"), i.removeAttribute("draggable");
|
|
266
|
+
}), !(!d || !h || w === "item") && t.querySelectorAll("[data-sortable-custom-item][data-sortable-item-id]").forEach((i) => {
|
|
267
|
+
const o = i.getAttribute("data-sortable-item-id");
|
|
268
|
+
o && i.querySelectorAll(h).forEach((c) => {
|
|
269
|
+
c.setAttribute("data-sortable-custom-handle", ""), c.setAttribute("data-drag-trigger", "custom"), c.setAttribute("data-id", o), c.setAttribute("draggable", "true");
|
|
270
|
+
});
|
|
271
|
+
}));
|
|
272
|
+
}, [l, d, h, w, P, f, n, b, g, A]);
|
|
273
|
+
const U = new Map(a.map((t) => [t.id, t])), W = new Map(a.map((t) => [t.id, f.filter((r) => r.listId === t.id).length])), X = !!A || g === "label" || !!b && !q, ut = d ? f.map((t) => {
|
|
274
|
+
var i, o, c;
|
|
275
|
+
const r = (o = (i = l.current) == null ? void 0 : i.shadowRoot) == null ? void 0 : o.querySelector(
|
|
276
|
+
`.item-custom-content[data-item-content-target="${k(t.id)}"]`
|
|
277
|
+
);
|
|
278
|
+
return r ? F(
|
|
279
|
+
/* @__PURE__ */ B(
|
|
280
|
+
"div",
|
|
281
|
+
{
|
|
282
|
+
"data-sortable-custom-item": "",
|
|
283
|
+
"data-sortable-item-id": t.id,
|
|
284
|
+
"data-selected": n != null && n.includes(t.id) ? "true" : "false",
|
|
285
|
+
"data-disabled": t.disabled ? "true" : "false",
|
|
286
|
+
"data-drag-disabled": t.dragDisabled ? "true" : "false",
|
|
287
|
+
children: d(t, {
|
|
288
|
+
selected: (n == null ? void 0 : n.includes(t.id)) ?? !1,
|
|
289
|
+
disabled: !!t.disabled,
|
|
290
|
+
dragDisabled: !!t.dragDisabled,
|
|
291
|
+
cloneOnDrag: !!t.cloneOnDrag || !!((c = U.get(t.listId)) != null && c.cloneOnDrag),
|
|
292
|
+
list: U.get(t.listId)
|
|
293
|
+
})
|
|
294
|
+
}
|
|
295
|
+
),
|
|
296
|
+
r,
|
|
297
|
+
t.id
|
|
298
|
+
) : null;
|
|
299
|
+
}) : null, lt = S ? a.map((t) => {
|
|
300
|
+
var i, o;
|
|
301
|
+
const r = (o = (i = l.current) == null ? void 0 : i.shadowRoot) == null ? void 0 : o.querySelector(
|
|
302
|
+
`.list-custom-header[data-list-header-target="${k(t.id)}"]`
|
|
303
|
+
);
|
|
304
|
+
return r ? F(
|
|
305
|
+
/* @__PURE__ */ B("div", { "data-sortable-custom-list-header": "", "data-sortable-list-id": t.id, children: S(t, {
|
|
306
|
+
itemCount: W.get(t.id) ?? 0,
|
|
307
|
+
dragLocked: X
|
|
308
|
+
}) }),
|
|
309
|
+
r,
|
|
310
|
+
`header-${t.id}`
|
|
311
|
+
) : null;
|
|
312
|
+
}) : null, dt = R ? a.map((t) => {
|
|
313
|
+
var i, o;
|
|
314
|
+
const r = (o = (i = l.current) == null ? void 0 : i.shadowRoot) == null ? void 0 : o.querySelector(
|
|
315
|
+
`.list-custom-empty[data-list-empty-target="${k(t.id)}"]`
|
|
316
|
+
);
|
|
317
|
+
return r ? F(
|
|
318
|
+
/* @__PURE__ */ B("div", { "data-sortable-custom-empty": "", "data-sortable-list-id": t.id, children: R(t, {
|
|
319
|
+
itemCount: W.get(t.id) ?? 0,
|
|
320
|
+
dragLocked: X,
|
|
321
|
+
filterQuery: b ?? ""
|
|
322
|
+
}) }),
|
|
323
|
+
r,
|
|
324
|
+
`empty-${t.id}`
|
|
325
|
+
) : null;
|
|
326
|
+
}) : null, Y = { ref: l, ...at };
|
|
327
|
+
return d && (Y["custom-item-rendering"] = ""), /* @__PURE__ */ ft(bt, { children: [
|
|
328
|
+
p.createElement("ui-sortable", Y, ot),
|
|
329
|
+
P >= 0 ? ut : null,
|
|
330
|
+
P >= 0 ? lt : null,
|
|
331
|
+
P >= 0 ? dt : null
|
|
332
|
+
] });
|
|
333
|
+
});
|
|
334
|
+
ht.displayName = "Sortable";
|
|
335
|
+
export {
|
|
336
|
+
ht as Sortable,
|
|
337
|
+
ht as default
|
|
338
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/ui-sortable",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Standalone install for the Editora sortable web component, with reordering, transfer, hierarchy, cloning, and keyboard-accessible drag and drop.",
|
|
5
5
|
"homepage": "https://editora-ecosystem.netlify.app/docs/ui-react/interactive/sortable",
|
|
6
6
|
"bugs": {
|
|
@@ -20,25 +20,51 @@
|
|
|
20
20
|
"import": "./dist/index.esm.js",
|
|
21
21
|
"require": "./dist/index.cjs.js",
|
|
22
22
|
"default": "./dist/index.esm.js"
|
|
23
|
+
},
|
|
24
|
+
"./react": {
|
|
25
|
+
"types": "./react.d.ts",
|
|
26
|
+
"import": "./dist/react.esm.js",
|
|
27
|
+
"require": "./dist/react.cjs.js",
|
|
28
|
+
"default": "./dist/react.esm.js"
|
|
23
29
|
}
|
|
24
30
|
},
|
|
25
31
|
"files": [
|
|
26
32
|
"dist",
|
|
27
|
-
"index.d.ts"
|
|
33
|
+
"index.d.ts",
|
|
34
|
+
"react.d.ts"
|
|
28
35
|
],
|
|
29
36
|
"scripts": {
|
|
30
37
|
"build": "vite build",
|
|
31
38
|
"dev": "vite build --watch",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest",
|
|
32
41
|
"clean": "rimraf dist",
|
|
33
42
|
"prepare": "npm run build"
|
|
34
43
|
},
|
|
35
44
|
"dependencies": {
|
|
36
45
|
"@editora/ui-core": "^0.1.9"
|
|
37
46
|
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": ">=16.8 <21",
|
|
49
|
+
"react-dom": ">=16.8 <21"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"react": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"react-dom": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
38
59
|
"devDependencies": {
|
|
60
|
+
"@testing-library/react": "^16.3.2",
|
|
61
|
+
"jsdom": "^22.1.0",
|
|
62
|
+
"react": "^18.3.1",
|
|
63
|
+
"react-dom": "^18.3.1",
|
|
39
64
|
"rimraf": "^5.0.0",
|
|
40
65
|
"typescript": "^5.0.0",
|
|
41
|
-
"vite": "^4.5.14"
|
|
66
|
+
"vite": "^4.5.14",
|
|
67
|
+
"vitest": "^1.6.1"
|
|
42
68
|
},
|
|
43
69
|
"keywords": [
|
|
44
70
|
"editora",
|
package/react.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
UISortable,
|
|
4
|
+
UISortableList,
|
|
5
|
+
UISortableItem,
|
|
6
|
+
UISortableMoveOptions,
|
|
7
|
+
UISortableDropMode,
|
|
8
|
+
UISortableSortMode,
|
|
9
|
+
UISortableChangeSource,
|
|
10
|
+
UISortableOperation,
|
|
11
|
+
UISortableSelectionChangeDetail,
|
|
12
|
+
UISortablePersistenceRecord,
|
|
13
|
+
UISortablePersistenceSnapshot,
|
|
14
|
+
UISortableChangeDetail,
|
|
15
|
+
UISortableDropIndicatorVisibility,
|
|
16
|
+
UISortableDropzoneStyle,
|
|
17
|
+
UISortableDragHandleMode,
|
|
18
|
+
UISortableListOrientation
|
|
19
|
+
} from '@editora/ui-core/sortable';
|
|
20
|
+
|
|
21
|
+
export type SortableListOrientation = UISortableListOrientation;
|
|
22
|
+
export type SortableSortMode = UISortableSortMode;
|
|
23
|
+
export type SortableDropMode = UISortableDropMode;
|
|
24
|
+
export type SortableChangeSource = UISortableChangeSource;
|
|
25
|
+
export type SortableOperation = UISortableOperation;
|
|
26
|
+
export type SortableDropIndicatorVisibility = UISortableDropIndicatorVisibility;
|
|
27
|
+
export type SortableDropzoneStyle = UISortableDropzoneStyle;
|
|
28
|
+
export type SortableDragPreviewSize = 'match-item' | 'compact';
|
|
29
|
+
export type SortableDragHandleMode = UISortableDragHandleMode;
|
|
30
|
+
export type SortableRadiusPreset = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
31
|
+
export type SortableRadius = SortableRadiusPreset | number | string;
|
|
32
|
+
export type SortableSpacePreset = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
33
|
+
export type SortableSpace = SortableSpacePreset | number | string;
|
|
34
|
+
|
|
35
|
+
export type SortableList = UISortableList;
|
|
36
|
+
export type SortableItem = UISortableItem;
|
|
37
|
+
export type SortableSelectionChangeDetail = UISortableSelectionChangeDetail;
|
|
38
|
+
export type SortablePersistenceRecord = UISortablePersistenceRecord;
|
|
39
|
+
export type SortablePersistenceSnapshot = UISortablePersistenceSnapshot;
|
|
40
|
+
export type SortableChangeDetail = UISortableChangeDetail;
|
|
41
|
+
export type SortableMoveOptions = UISortableMoveOptions;
|
|
42
|
+
export type SortableElement = UISortable;
|
|
43
|
+
|
|
44
|
+
export type SortableRenderItemContext = {
|
|
45
|
+
selected: boolean;
|
|
46
|
+
disabled: boolean;
|
|
47
|
+
dragDisabled: boolean;
|
|
48
|
+
cloneOnDrag: boolean;
|
|
49
|
+
list?: SortableList;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type SortableRenderListHeaderContext = {
|
|
53
|
+
itemCount: number;
|
|
54
|
+
dragLocked: boolean;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type SortableRenderEmptyStateContext = {
|
|
58
|
+
itemCount: number;
|
|
59
|
+
dragLocked: boolean;
|
|
60
|
+
filterQuery: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type SortableProps = Omit<React.HTMLAttributes<SortableElement>, 'onChange'> & {
|
|
64
|
+
lists: SortableList[];
|
|
65
|
+
items: SortableItem[];
|
|
66
|
+
selection?: string[];
|
|
67
|
+
filterQuery?: string;
|
|
68
|
+
sort?: SortableSortMode;
|
|
69
|
+
persistKey?: string;
|
|
70
|
+
allowFilteredDrag?: boolean;
|
|
71
|
+
allowNesting?: boolean;
|
|
72
|
+
dropIndicatorVisibility?: SortableDropIndicatorVisibility;
|
|
73
|
+
dropzoneStyle?: SortableDropzoneStyle;
|
|
74
|
+
dragPreviewSize?: SortableDragPreviewSize;
|
|
75
|
+
dragHandleMode?: SortableDragHandleMode;
|
|
76
|
+
dragHandleSelector?: string;
|
|
77
|
+
itemRadius?: SortableRadius;
|
|
78
|
+
handleRadius?: SortableRadius;
|
|
79
|
+
listGap?: SortableSpace;
|
|
80
|
+
itemSpacing?: SortableSpace;
|
|
81
|
+
showSelectionBadge?: boolean;
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
renderItem?: (item: SortableItem, context: SortableRenderItemContext) => React.ReactNode;
|
|
84
|
+
renderListHeader?: (list: SortableList, context: SortableRenderListHeaderContext) => React.ReactNode;
|
|
85
|
+
renderEmptyState?: (list: SortableList, context: SortableRenderEmptyStateContext) => React.ReactNode;
|
|
86
|
+
onChange?: (detail: SortableChangeDetail) => void;
|
|
87
|
+
onItemsChange?: (items: SortableItem[]) => void;
|
|
88
|
+
onSelectionChange?: (detail: SortableSelectionChangeDetail) => void;
|
|
89
|
+
onPersistRequest?: (detail: SortableChangeDetail) => void;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export declare const Sortable: React.ForwardRefExoticComponent<
|
|
93
|
+
SortableProps & React.RefAttributes<SortableElement>
|
|
94
|
+
>;
|
|
95
|
+
|
|
96
|
+
export default Sortable;
|