@editora/ui-sortable 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react.cjs.js +1 -1
- package/dist/react.esm.js +178 -188
- package/package.json +4 -5
package/dist/react.cjs.js
CHANGED
|
@@ -1 +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},
|
|
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},b=gt(bt),C=typeof window<"u"?b.default.useLayoutEffect:b.default.useEffect;function mt(e,s,...i){if(!s||!("className"in s)||!e.includes("-"))return b.default.createElement(e,s,...i);const{className:l,...g}=s,o=[g.class,l].filter(n=>typeof n=="string"&&n!=="").join(" ");return b.default.createElement(e,o?{...g,class:o}:g,...i)}function pt(e){const s=b.default.useRef(null);return b.default.useImperativeHandle(e,()=>s.current),s}function yt(e,s,i){b.default.useEffect(()=>{const l=e.current;if(!l)return;const g=s.filter(o=>typeof o.listener=="function");return g.forEach(({type:o,listener:n})=>{l.addEventListener(o,n)}),()=>{g.forEach(({type:o,listener:n})=>{l.removeEventListener(o,n)})}},[e,...i])}function ht(e,s,i){C(()=>{const l=e.current;l&&s(l)},[e,...i])}function H(e){return e.detail}function y(e,s,i){const l=e.getAttribute(s);if(i==null||i===""){l!=null&&e.removeAttribute(s);return}l!==i&&e.setAttribute(s,i)}function st(e,s,i){if(i){e.hasAttribute(s)||e.setAttribute(s,"");return}e.hasAttribute(s)&&e.removeAttribute(s)}function T(e,s,i){if(i==null){y(e,s,null);return}try{y(e,s,JSON.stringify(i))}catch{y(e,s,null)}}function B(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}function it(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 At(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 vt=[],St=[],F=b.default.forwardRef(function(s,i){const{lists:l,items:g,selection:o,filterQuery:n,sort:m,persistKey:L,allowFilteredDrag:P,allowNesting:D,dropIndicatorVisibility:M,dropzoneStyle:Q,dragPreviewSize:O,dragHandleMode:S,dragHandleSelector:h,itemRadius:k,handleRadius:G,listGap:J,itemSpacing:K,showSelectionBadge:_,disabled:A,renderItem:c,renderListHeader:w,renderEmptyState:R,onChange:j,onItemsChange:N,onSelectionChange:V,onPersistRequest:$,children:ot,...at}=s,f=l??vt,p=g??St,u=pt(i),[x,nt]=b.default.useState(0),U=!!(c||w||R);yt(u,[{type:"change",listener:j||N?(t=>{const r=H(t);r&&(j?.(r),N?.(r.items))}):void 0},{type:"selection-change",listener:V?(t=>{const r=H(t);r&&V(r)}):void 0},{type:"persist-request",listener:$?(t=>{const r=H(t);r&&$(r)}):void 0}],[j,N,V,$]),ht(u,t=>{T(t,"lists",f),T(t,"items",p),T(t,"selection",o??null),y(t,"filter-query",n??null),y(t,"sort",m&&m!=="manual"?m:null),y(t,"persist-key",L??null),st(t,"allow-filtered-drag",P),D===!1?t.setAttribute("allow-nesting","false"):t.removeAttribute("allow-nesting"),M==="always"?t.setAttribute("drop-indicator-visibility","always"):t.removeAttribute("drop-indicator-visibility"),Q==="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=it(k);r?t.style.setProperty("--ui-sortable-item-radius",r):t.style.removeProperty("--ui-sortable-item-radius");const d=it(G);d?t.style.setProperty("--ui-sortable-handle-radius",d):t.style.removeProperty("--ui-sortable-handle-radius");const a=At(J??K);a?t.style.setProperty("--ui-sortable-list-gap",a):t.style.removeProperty("--ui-sortable-list-gap"),c?t.setAttribute("custom-item-rendering","true"):t.removeAttribute("custom-item-rendering"),_===!1?t.setAttribute("show-selection-badge","false"):t.removeAttribute("show-selection-badge"),st(t,"disabled",A)},[f,p,o,n,m,L,P,D,M,Q,O,S,h,k,G,J,K,c,_,A]),C(()=>{if(!U)return;const t=u.current,r=t?.ownerDocument?.defaultView;if(!t||!r)return;let d=!1,a=!1,q=null,I=null;const tt=[c&&p.length>0?".item-custom-content[data-item-content-target]":null,w&&f.length>0?".list-custom-header[data-list-header-target]":null,R&&f.length>0?".list-custom-empty[data-list-empty-target]":null].filter(Boolean).join(", "),et=()=>{d||a||(a=!0,queueMicrotask(()=>{a=!1,!d&&nt(v=>v+1)}))},ct=()=>{const v=u.current?.shadowRoot;return v?(I||(I=new MutationObserver(()=>et()),I.observe(v,{childList:!0,subtree:!0})),!0):!1},rt=()=>{if(d)return;const v=u.current?.shadowRoot,ft=!tt||!!v?.querySelector(tt);if(ct()&&ft){et();return}q=r.requestAnimationFrame(rt)};return rt(),()=>{d=!0,q!==null&&r.cancelAnimationFrame(q),I?.disconnect()}},[u,U,p,f,o,n,m,L,P,D,M,O,S,h,_,A,c,w,R]),C(()=>{const t=u.current,r=t?.shadowRoot;if(!t)return;if(!c||!r){t.removeAttribute("custom-item-rendering-ready"),t.removeAttribute("custom-item-rendering-pending");return}const d=r.querySelectorAll(".item-custom-content[data-item-content-target]"),a=r.querySelectorAll("[data-sortable-custom-item]");d.length>0&&a.length>=d.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"))},[u,c,x,p,o,n,m,A]),C(()=>{const t=u.current?.shadowRoot;t&&(t.querySelectorAll("[data-sortable-custom-handle]").forEach(r=>{r.removeAttribute("data-sortable-custom-handle"),r.removeAttribute("data-drag-trigger"),r.removeAttribute("data-id"),r.removeAttribute("draggable"),r.hasAttribute("data-sortable-handle-tabindex")&&(r.removeAttribute("data-sortable-handle-tabindex"),r.removeAttribute("tabindex"))}),!(!c||!h||S==="item")&&t.querySelectorAll("[data-sortable-custom-item][data-sortable-item-id]").forEach(r=>{const d=r.getAttribute("data-sortable-item-id");d&&r.querySelectorAll(h).forEach(a=>{a.setAttribute("data-sortable-custom-handle",""),a.setAttribute("data-drag-trigger","custom"),a.setAttribute("data-id",d),a.setAttribute("draggable","true"),a.hasAttribute("tabindex")||(a.setAttribute("tabindex","-1"),a.setAttribute("data-sortable-handle-tabindex",""))})}))},[u,c,h,S,x,p,o,n,m,A]);const W=new Map(f.map(t=>[t.id,t])),X=new Map(f.map(t=>[t.id,p.filter(r=>r.listId===t.id).length])),Y=!!A||m==="label"||!!n&&!P,ut=c?p.map(t=>{const r=u.current?.shadowRoot?.querySelector(`.item-custom-content[data-item-content-target="${B(t.id)}"]`);return r?z.createPortal(E.jsx("div",{"data-sortable-custom-item":"","data-sortable-item-id":t.id,"data-selected":o?.includes(t.id)?"true":"false","data-disabled":t.disabled?"true":"false","data-drag-disabled":t.dragDisabled?"true":"false",children:c(t,{selected:o?.includes(t.id)??!1,disabled:!!t.disabled,dragDisabled:!!t.dragDisabled,cloneOnDrag:!!t.cloneOnDrag||!!W.get(t.listId)?.cloneOnDrag,list:W.get(t.listId)})}),r,t.id):null}):null,lt=w?f.map(t=>{const r=u.current?.shadowRoot?.querySelector(`.list-custom-header[data-list-header-target="${B(t.id)}"]`);return r?z.createPortal(E.jsx("div",{"data-sortable-custom-list-header":"","data-sortable-list-id":t.id,children:w(t,{itemCount:X.get(t.id)??0,dragLocked:Y})}),r,`header-${t.id}`):null}):null,dt=R?f.map(t=>{const r=u.current?.shadowRoot?.querySelector(`.list-custom-empty[data-list-empty-target="${B(t.id)}"]`);return r?z.createPortal(E.jsx("div",{"data-sortable-custom-empty":"","data-sortable-list-id":t.id,children:R(t,{itemCount:X.get(t.id)??0,dragLocked:Y,filterQuery:n??""})}),r,`empty-${t.id}`):null}):null,Z={ref:u,...at};return c&&(Z["custom-item-rendering"]=""),E.jsxs(E.Fragment,{children:[mt("ui-sortable",Z,ot),x>=0?ut:null,x>=0?lt:null,x>=0?dt:null]})});F.displayName="Sortable";exports.Sortable=F;exports.default=F;
|
package/dist/react.esm.js
CHANGED
|
@@ -1,72 +1,75 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsx as M, jsxs as ft, Fragment as bt } from "react/jsx-runtime";
|
|
2
|
+
import b from "react";
|
|
3
|
+
import { createPortal as B } from "react-dom";
|
|
4
4
|
import "@editora/ui-core/sortable";
|
|
5
|
-
const
|
|
5
|
+
const q = typeof window < "u" ? b.useLayoutEffect : b.useEffect;
|
|
6
|
+
function mt(e, s, ...i) {
|
|
7
|
+
if (!s || !("className" in s) || !e.includes("-"))
|
|
8
|
+
return b.createElement(e, s, ...i);
|
|
9
|
+
const { className: l, ...m } = s, o = [m.class, l].filter((n) => typeof n == "string" && n !== "").join(" ");
|
|
10
|
+
return b.createElement(e, o ? { ...m, class: o } : m, ...i);
|
|
11
|
+
}
|
|
6
12
|
function gt(e) {
|
|
7
|
-
const s =
|
|
8
|
-
return
|
|
13
|
+
const s = b.useRef(null);
|
|
14
|
+
return b.useImperativeHandle(e, () => s.current), s;
|
|
9
15
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(n) => typeof n.listener == "function"
|
|
16
|
+
function pt(e, s, i) {
|
|
17
|
+
b.useEffect(() => {
|
|
18
|
+
const l = e.current;
|
|
19
|
+
if (!l) return;
|
|
20
|
+
const m = s.filter(
|
|
21
|
+
(o) => typeof o.listener == "function"
|
|
17
22
|
);
|
|
18
|
-
return
|
|
19
|
-
|
|
23
|
+
return m.forEach(({ type: o, listener: n }) => {
|
|
24
|
+
l.addEventListener(o, n);
|
|
20
25
|
}), () => {
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
m.forEach(({ type: o, listener: n }) => {
|
|
27
|
+
l.removeEventListener(o, n);
|
|
23
28
|
});
|
|
24
29
|
};
|
|
25
|
-
}, [e, ...
|
|
30
|
+
}, [e, ...i]);
|
|
26
31
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
}, [e, ...
|
|
32
|
+
function yt(e, s, i) {
|
|
33
|
+
q(() => {
|
|
34
|
+
const l = e.current;
|
|
35
|
+
l && s(l);
|
|
36
|
+
}, [e, ...i]);
|
|
32
37
|
}
|
|
33
|
-
function
|
|
38
|
+
function F(e) {
|
|
34
39
|
return e.detail;
|
|
35
40
|
}
|
|
36
|
-
function y(e, s,
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
41
|
+
function y(e, s, i) {
|
|
42
|
+
const l = e.getAttribute(s);
|
|
43
|
+
if (i == null || i === "") {
|
|
44
|
+
l != null && e.removeAttribute(s);
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
|
-
|
|
47
|
+
l !== i && e.setAttribute(s, i);
|
|
43
48
|
}
|
|
44
|
-
function
|
|
45
|
-
if (
|
|
49
|
+
function rt(e, s, i) {
|
|
50
|
+
if (i) {
|
|
46
51
|
e.hasAttribute(s) || e.setAttribute(s, "");
|
|
47
52
|
return;
|
|
48
53
|
}
|
|
49
54
|
e.hasAttribute(s) && e.removeAttribute(s);
|
|
50
55
|
}
|
|
51
|
-
function
|
|
52
|
-
if (
|
|
56
|
+
function T(e, s, i) {
|
|
57
|
+
if (i == null) {
|
|
53
58
|
y(e, s, null);
|
|
54
59
|
return;
|
|
55
60
|
}
|
|
56
61
|
try {
|
|
57
|
-
y(e, s, JSON.stringify(
|
|
62
|
+
y(e, s, JSON.stringify(i));
|
|
58
63
|
} catch {
|
|
59
64
|
y(e, s, null);
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
|
-
function
|
|
67
|
+
function j(e) {
|
|
63
68
|
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"');
|
|
64
69
|
}
|
|
65
70
|
function st(e) {
|
|
66
|
-
if (e == null || e === "")
|
|
67
|
-
|
|
68
|
-
if (typeof e == "number")
|
|
69
|
-
return `${e}px`;
|
|
71
|
+
if (e == null || e === "") return null;
|
|
72
|
+
if (typeof e == "number") return `${e}px`;
|
|
70
73
|
switch (e) {
|
|
71
74
|
case "none":
|
|
72
75
|
return "0px";
|
|
@@ -84,11 +87,9 @@ function st(e) {
|
|
|
84
87
|
return e;
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
|
-
function
|
|
88
|
-
if (e == null || e === "")
|
|
89
|
-
|
|
90
|
-
if (typeof e == "number")
|
|
91
|
-
return `${e}px`;
|
|
90
|
+
function ht(e) {
|
|
91
|
+
if (e == null || e === "") return null;
|
|
92
|
+
if (typeof e == "number") return `${e}px`;
|
|
92
93
|
switch (e) {
|
|
93
94
|
case "xs":
|
|
94
95
|
return "6px";
|
|
@@ -104,191 +105,182 @@ function yt(e) {
|
|
|
104
105
|
return e;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
const
|
|
108
|
+
const At = [], vt = [], wt = b.forwardRef(function(s, i) {
|
|
108
109
|
const {
|
|
109
|
-
lists:
|
|
110
|
-
items:
|
|
111
|
-
selection:
|
|
112
|
-
filterQuery:
|
|
110
|
+
lists: l,
|
|
111
|
+
items: m,
|
|
112
|
+
selection: o,
|
|
113
|
+
filterQuery: n,
|
|
113
114
|
sort: g,
|
|
114
|
-
persistKey:
|
|
115
|
-
allowFilteredDrag:
|
|
116
|
-
allowNesting:
|
|
117
|
-
dropIndicatorVisibility:
|
|
118
|
-
dropzoneStyle:
|
|
119
|
-
dragPreviewSize:
|
|
115
|
+
persistKey: C,
|
|
116
|
+
allowFilteredDrag: E,
|
|
117
|
+
allowNesting: L,
|
|
118
|
+
dropIndicatorVisibility: D,
|
|
119
|
+
dropzoneStyle: Q,
|
|
120
|
+
dragPreviewSize: O,
|
|
120
121
|
dragHandleMode: w,
|
|
121
122
|
dragHandleSelector: h,
|
|
122
|
-
itemRadius:
|
|
123
|
-
handleRadius:
|
|
124
|
-
listGap:
|
|
125
|
-
itemSpacing:
|
|
126
|
-
showSelectionBadge:
|
|
123
|
+
itemRadius: k,
|
|
124
|
+
handleRadius: G,
|
|
125
|
+
listGap: J,
|
|
126
|
+
itemSpacing: _,
|
|
127
|
+
showSelectionBadge: N,
|
|
127
128
|
disabled: A,
|
|
128
|
-
renderItem:
|
|
129
|
+
renderItem: c,
|
|
129
130
|
renderListHeader: S,
|
|
130
131
|
renderEmptyState: R,
|
|
131
|
-
onChange:
|
|
132
|
-
onItemsChange:
|
|
133
|
-
onSelectionChange:
|
|
134
|
-
onPersistRequest:
|
|
135
|
-
children:
|
|
136
|
-
...
|
|
137
|
-
} = s, l = gt(
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
onChange: V,
|
|
133
|
+
onItemsChange: $,
|
|
134
|
+
onSelectionChange: z,
|
|
135
|
+
onPersistRequest: H,
|
|
136
|
+
children: it,
|
|
137
|
+
...ot
|
|
138
|
+
} = s, f = l ?? At, p = m ?? vt, u = gt(i), [x, at] = b.useState(0), K = !!(c || S || R);
|
|
139
|
+
pt(
|
|
140
|
+
u,
|
|
140
141
|
[
|
|
141
142
|
{
|
|
142
143
|
type: "change",
|
|
143
|
-
listener:
|
|
144
|
-
const r =
|
|
145
|
-
r && (
|
|
146
|
-
} : void 0
|
|
144
|
+
listener: V || $ ? ((t) => {
|
|
145
|
+
const r = F(t);
|
|
146
|
+
r && (V?.(r), $?.(r.items));
|
|
147
|
+
}) : void 0
|
|
147
148
|
},
|
|
148
149
|
{
|
|
149
150
|
type: "selection-change",
|
|
150
|
-
listener:
|
|
151
|
-
const r =
|
|
152
|
-
r &&
|
|
153
|
-
} : void 0
|
|
151
|
+
listener: z ? ((t) => {
|
|
152
|
+
const r = F(t);
|
|
153
|
+
r && z(r);
|
|
154
|
+
}) : void 0
|
|
154
155
|
},
|
|
155
156
|
{
|
|
156
157
|
type: "persist-request",
|
|
157
|
-
listener:
|
|
158
|
-
const r =
|
|
159
|
-
r &&
|
|
160
|
-
} : void 0
|
|
158
|
+
listener: H ? ((t) => {
|
|
159
|
+
const r = F(t);
|
|
160
|
+
r && H(r);
|
|
161
|
+
}) : void 0
|
|
161
162
|
}
|
|
162
163
|
],
|
|
163
|
-
[
|
|
164
|
-
),
|
|
165
|
-
|
|
164
|
+
[V, $, z, H]
|
|
165
|
+
), yt(
|
|
166
|
+
u,
|
|
166
167
|
(t) => {
|
|
167
|
-
|
|
168
|
-
const r = st(
|
|
168
|
+
T(t, "lists", f), T(t, "items", p), T(t, "selection", o ?? null), y(t, "filter-query", n ?? null), y(t, "sort", g && g !== "manual" ? g : null), y(t, "persist-key", C ?? null), rt(t, "allow-filtered-drag", E), L === !1 ? t.setAttribute("allow-nesting", "false") : t.removeAttribute("allow-nesting"), D === "always" ? t.setAttribute("drop-indicator-visibility", "always") : t.removeAttribute("drop-indicator-visibility"), Q === "container" ? t.setAttribute("dropzone-style", "container") : t.removeAttribute("dropzone-style"), O === "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);
|
|
169
|
+
const r = st(k);
|
|
169
170
|
r ? t.style.setProperty("--ui-sortable-item-radius", r) : t.style.removeProperty("--ui-sortable-item-radius");
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
171
|
+
const d = st(G);
|
|
172
|
+
d ? t.style.setProperty("--ui-sortable-handle-radius", d) : t.style.removeProperty("--ui-sortable-handle-radius");
|
|
173
|
+
const a = ht(J ?? _);
|
|
174
|
+
a ? t.style.setProperty("--ui-sortable-list-gap", a) : t.style.removeProperty("--ui-sortable-list-gap"), c ? t.setAttribute("custom-item-rendering", "true") : t.removeAttribute("custom-item-rendering"), N === !1 ? t.setAttribute("show-selection-badge", "false") : t.removeAttribute("show-selection-badge"), rt(t, "disabled", A);
|
|
174
175
|
},
|
|
175
176
|
[
|
|
176
|
-
a,
|
|
177
177
|
f,
|
|
178
|
+
p,
|
|
179
|
+
o,
|
|
178
180
|
n,
|
|
179
|
-
b,
|
|
180
181
|
g,
|
|
181
|
-
D,
|
|
182
|
-
q,
|
|
183
182
|
C,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
E,
|
|
184
|
+
L,
|
|
185
|
+
D,
|
|
186
|
+
Q,
|
|
187
|
+
O,
|
|
187
188
|
w,
|
|
188
189
|
h,
|
|
189
|
-
|
|
190
|
-
T,
|
|
190
|
+
k,
|
|
191
191
|
G,
|
|
192
192
|
J,
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
_,
|
|
194
|
+
c,
|
|
195
|
+
N,
|
|
195
196
|
A
|
|
196
197
|
]
|
|
197
|
-
),
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (!t || !r)
|
|
203
|
-
return;
|
|
204
|
-
let i = !1, o = !1, c = null, v = null;
|
|
198
|
+
), q(() => {
|
|
199
|
+
if (!K) return;
|
|
200
|
+
const t = u.current, r = t?.ownerDocument?.defaultView;
|
|
201
|
+
if (!t || !r) return;
|
|
202
|
+
let d = !1, a = !1, P = null, I = null;
|
|
205
203
|
const Z = [
|
|
206
|
-
|
|
207
|
-
S &&
|
|
208
|
-
R &&
|
|
209
|
-
].filter(Boolean).join(", "),
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
c && p.length > 0 ? ".item-custom-content[data-item-content-target]" : null,
|
|
205
|
+
S && f.length > 0 ? ".list-custom-header[data-list-header-target]" : null,
|
|
206
|
+
R && f.length > 0 ? ".list-custom-empty[data-list-empty-target]" : null
|
|
207
|
+
].filter(Boolean).join(", "), tt = () => {
|
|
208
|
+
d || a || (a = !0, queueMicrotask(() => {
|
|
209
|
+
a = !1, !d && at((v) => v + 1);
|
|
212
210
|
}));
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
const m = (rt = l.current) == null ? void 0 : rt.shadowRoot, I = !Z || !!(m != null && m.querySelector(Z));
|
|
222
|
-
if (ct() && I) {
|
|
223
|
-
_();
|
|
211
|
+
}, dt = () => {
|
|
212
|
+
const v = u.current?.shadowRoot;
|
|
213
|
+
return v ? (I || (I = new MutationObserver(() => tt()), I.observe(v, { childList: !0, subtree: !0 })), !0) : !1;
|
|
214
|
+
}, et = () => {
|
|
215
|
+
if (d) return;
|
|
216
|
+
const v = u.current?.shadowRoot, ct = !Z || !!v?.querySelector(Z);
|
|
217
|
+
if (dt() && ct) {
|
|
218
|
+
tt();
|
|
224
219
|
return;
|
|
225
220
|
}
|
|
226
|
-
|
|
221
|
+
P = r.requestAnimationFrame(et);
|
|
227
222
|
};
|
|
228
|
-
return
|
|
229
|
-
|
|
223
|
+
return et(), () => {
|
|
224
|
+
d = !0, P !== null && r.cancelAnimationFrame(P), I?.disconnect();
|
|
230
225
|
};
|
|
231
226
|
}, [
|
|
232
|
-
|
|
227
|
+
u,
|
|
233
228
|
K,
|
|
229
|
+
p,
|
|
234
230
|
f,
|
|
235
|
-
|
|
231
|
+
o,
|
|
236
232
|
n,
|
|
237
|
-
b,
|
|
238
233
|
g,
|
|
239
|
-
D,
|
|
240
|
-
q,
|
|
241
234
|
C,
|
|
242
|
-
|
|
243
|
-
|
|
235
|
+
E,
|
|
236
|
+
L,
|
|
237
|
+
D,
|
|
238
|
+
O,
|
|
244
239
|
w,
|
|
245
240
|
h,
|
|
246
|
-
|
|
241
|
+
N,
|
|
247
242
|
A,
|
|
248
|
-
|
|
243
|
+
c,
|
|
249
244
|
S,
|
|
250
245
|
R
|
|
251
|
-
]),
|
|
252
|
-
const t =
|
|
253
|
-
if (!t)
|
|
254
|
-
|
|
255
|
-
if (!d || !r) {
|
|
246
|
+
]), q(() => {
|
|
247
|
+
const t = u.current, r = t?.shadowRoot;
|
|
248
|
+
if (!t) return;
|
|
249
|
+
if (!c || !r) {
|
|
256
250
|
t.removeAttribute("custom-item-rendering-ready"), t.removeAttribute("custom-item-rendering-pending");
|
|
257
251
|
return;
|
|
258
252
|
}
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
}, [
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
c.setAttribute("data-sortable-custom-handle", ""), c.setAttribute("data-drag-trigger", "custom"), c.setAttribute("data-id", o), c.setAttribute("draggable", "true");
|
|
253
|
+
const d = r.querySelectorAll(".item-custom-content[data-item-content-target]"), a = r.querySelectorAll("[data-sortable-custom-item]");
|
|
254
|
+
d.length > 0 && a.length >= d.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"));
|
|
255
|
+
}, [u, c, x, p, o, n, g, A]), q(() => {
|
|
256
|
+
const t = u.current?.shadowRoot;
|
|
257
|
+
t && (t.querySelectorAll("[data-sortable-custom-handle]").forEach((r) => {
|
|
258
|
+
r.removeAttribute("data-sortable-custom-handle"), r.removeAttribute("data-drag-trigger"), r.removeAttribute("data-id"), r.removeAttribute("draggable"), r.hasAttribute("data-sortable-handle-tabindex") && (r.removeAttribute("data-sortable-handle-tabindex"), r.removeAttribute("tabindex"));
|
|
259
|
+
}), !(!c || !h || w === "item") && t.querySelectorAll("[data-sortable-custom-item][data-sortable-item-id]").forEach((r) => {
|
|
260
|
+
const d = r.getAttribute("data-sortable-item-id");
|
|
261
|
+
d && r.querySelectorAll(h).forEach((a) => {
|
|
262
|
+
a.setAttribute("data-sortable-custom-handle", ""), a.setAttribute("data-drag-trigger", "custom"), a.setAttribute("data-id", d), a.setAttribute("draggable", "true"), a.hasAttribute("tabindex") || (a.setAttribute("tabindex", "-1"), a.setAttribute("data-sortable-handle-tabindex", ""));
|
|
270
263
|
});
|
|
271
264
|
}));
|
|
272
|
-
}, [
|
|
273
|
-
const U = new Map(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
`.item-custom-content[data-item-content-target="${k(t.id)}"]`
|
|
265
|
+
}, [u, c, h, w, x, p, o, n, g, A]);
|
|
266
|
+
const U = new Map(f.map((t) => [t.id, t])), W = new Map(f.map((t) => [t.id, p.filter((r) => r.listId === t.id).length])), X = !!A || g === "label" || !!n && !E, nt = c ? p.map((t) => {
|
|
267
|
+
const r = u.current?.shadowRoot?.querySelector(
|
|
268
|
+
`.item-custom-content[data-item-content-target="${j(t.id)}"]`
|
|
277
269
|
);
|
|
278
|
-
return r ?
|
|
279
|
-
/* @__PURE__ */
|
|
270
|
+
return r ? B(
|
|
271
|
+
/* @__PURE__ */ M(
|
|
280
272
|
"div",
|
|
281
273
|
{
|
|
282
274
|
"data-sortable-custom-item": "",
|
|
283
275
|
"data-sortable-item-id": t.id,
|
|
284
|
-
"data-selected":
|
|
276
|
+
"data-selected": o?.includes(t.id) ? "true" : "false",
|
|
285
277
|
"data-disabled": t.disabled ? "true" : "false",
|
|
286
278
|
"data-drag-disabled": t.dragDisabled ? "true" : "false",
|
|
287
|
-
children:
|
|
288
|
-
selected:
|
|
279
|
+
children: c(t, {
|
|
280
|
+
selected: o?.includes(t.id) ?? !1,
|
|
289
281
|
disabled: !!t.disabled,
|
|
290
282
|
dragDisabled: !!t.dragDisabled,
|
|
291
|
-
cloneOnDrag: !!t.cloneOnDrag || !!
|
|
283
|
+
cloneOnDrag: !!t.cloneOnDrag || !!U.get(t.listId)?.cloneOnDrag,
|
|
292
284
|
list: U.get(t.listId)
|
|
293
285
|
})
|
|
294
286
|
}
|
|
@@ -296,43 +288,41 @@ const ht = p.forwardRef(function(s, u) {
|
|
|
296
288
|
r,
|
|
297
289
|
t.id
|
|
298
290
|
) : null;
|
|
299
|
-
}) : null,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
`.list-custom-header[data-list-header-target="${k(t.id)}"]`
|
|
291
|
+
}) : null, ut = S ? f.map((t) => {
|
|
292
|
+
const r = u.current?.shadowRoot?.querySelector(
|
|
293
|
+
`.list-custom-header[data-list-header-target="${j(t.id)}"]`
|
|
303
294
|
);
|
|
304
|
-
return r ?
|
|
305
|
-
/* @__PURE__ */
|
|
295
|
+
return r ? B(
|
|
296
|
+
/* @__PURE__ */ M("div", { "data-sortable-custom-list-header": "", "data-sortable-list-id": t.id, children: S(t, {
|
|
306
297
|
itemCount: W.get(t.id) ?? 0,
|
|
307
298
|
dragLocked: X
|
|
308
299
|
}) }),
|
|
309
300
|
r,
|
|
310
301
|
`header-${t.id}`
|
|
311
302
|
) : null;
|
|
312
|
-
}) : null,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
`.list-custom-empty[data-list-empty-target="${k(t.id)}"]`
|
|
303
|
+
}) : null, lt = R ? f.map((t) => {
|
|
304
|
+
const r = u.current?.shadowRoot?.querySelector(
|
|
305
|
+
`.list-custom-empty[data-list-empty-target="${j(t.id)}"]`
|
|
316
306
|
);
|
|
317
|
-
return r ?
|
|
318
|
-
/* @__PURE__ */
|
|
307
|
+
return r ? B(
|
|
308
|
+
/* @__PURE__ */ M("div", { "data-sortable-custom-empty": "", "data-sortable-list-id": t.id, children: R(t, {
|
|
319
309
|
itemCount: W.get(t.id) ?? 0,
|
|
320
310
|
dragLocked: X,
|
|
321
|
-
filterQuery:
|
|
311
|
+
filterQuery: n ?? ""
|
|
322
312
|
}) }),
|
|
323
313
|
r,
|
|
324
314
|
`empty-${t.id}`
|
|
325
315
|
) : null;
|
|
326
|
-
}) : null, Y = { ref:
|
|
327
|
-
return
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
316
|
+
}) : null, Y = { ref: u, ...ot };
|
|
317
|
+
return c && (Y["custom-item-rendering"] = ""), /* @__PURE__ */ ft(bt, { children: [
|
|
318
|
+
mt("ui-sortable", Y, it),
|
|
319
|
+
x >= 0 ? nt : null,
|
|
320
|
+
x >= 0 ? ut : null,
|
|
321
|
+
x >= 0 ? lt : null
|
|
332
322
|
] });
|
|
333
323
|
});
|
|
334
|
-
|
|
324
|
+
wt.displayName = "Sortable";
|
|
335
325
|
export {
|
|
336
|
-
|
|
337
|
-
|
|
326
|
+
wt as Sortable,
|
|
327
|
+
wt as default
|
|
338
328
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/ui-sortable",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"prepare": "npm run build"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@editora/ui-core": "^0.1.
|
|
45
|
+
"@editora/ui-core": "^0.1.22"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=16.8 <21",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"react-dom": "^18.3.1",
|
|
64
64
|
"rimraf": "^5.0.0",
|
|
65
65
|
"typescript": "^5.0.0",
|
|
66
|
-
"vite": "^
|
|
66
|
+
"vite": "^7.3.1",
|
|
67
67
|
"vitest": "^1.6.1"
|
|
68
68
|
},
|
|
69
69
|
"keywords": [
|
|
@@ -80,6 +80,5 @@
|
|
|
80
80
|
"sideEffects": true,
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
|
-
}
|
|
84
|
-
"gitHead": "e19160591d822f5ecf242658d6db63959371838e"
|
|
83
|
+
}
|
|
85
84
|
}
|