@editora/ui-sortable 0.1.5 → 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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=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:u,...g}=s,o=[g.class,u].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 u=e.current;if(!u)return;const g=s.filter(o=>typeof o.listener=="function");return g.forEach(({type:o,listener:n})=>{u.addEventListener(o,n)}),()=>{g.forEach(({type:o,listener:n})=>{u.removeEventListener(o,n)})}},[e,...i])}function ht(e,s,i){C(()=>{const u=e.current;u&&s(u)},[e,...i])}function H(e){return e.detail}function y(e,s,i){const u=e.getAttribute(s);if(i==null||i===""){u!=null&&e.removeAttribute(s);return}u!==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:u,items:g,selection:o,filterQuery:n,sort:m,persistKey:L,allowFilteredDrag:q,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,...nt}=s,f=u??vt,p=g??St,a=pt(i),[E,at]=b.default.useState(0),U=!!(c||w||R);yt(a,[{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(a,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",q),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 l=it(G);l?t.style.setProperty("--ui-sortable-handle-radius",l):t.style.removeProperty("--ui-sortable-handle-radius");const d=At(J??K);d?t.style.setProperty("--ui-sortable-list-gap",d):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,q,D,M,Q,O,S,h,k,G,J,K,c,_,A]),C(()=>{if(!U)return;const t=a.current,r=t?.ownerDocument?.defaultView;if(!t||!r)return;let l=!1,d=!1,x=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=()=>{l||d||(d=!0,queueMicrotask(()=>{d=!1,!l&&at(v=>v+1)}))},ct=()=>{const v=a.current?.shadowRoot;return v?(I||(I=new MutationObserver(()=>et()),I.observe(v,{childList:!0,subtree:!0})),!0):!1},rt=()=>{if(l)return;const v=a.current?.shadowRoot,ft=!tt||!!v?.querySelector(tt);if(ct()&&ft){et();return}x=r.requestAnimationFrame(rt)};return rt(),()=>{l=!0,x!==null&&r.cancelAnimationFrame(x),I?.disconnect()}},[a,U,p,f,o,n,m,L,q,D,M,O,S,h,_,A,c,w,R]),C(()=>{const t=a.current,r=t?.shadowRoot;if(!t)return;if(!c||!r){t.removeAttribute("custom-item-rendering-ready"),t.removeAttribute("custom-item-rendering-pending");return}const l=r.querySelectorAll(".item-custom-content[data-item-content-target]"),d=r.querySelectorAll("[data-sortable-custom-item]");l.length>0&&d.length>=l.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"))},[a,c,E,p,o,n,m,A]),C(()=>{const t=a.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")}),!(!c||!h||S==="item")&&t.querySelectorAll("[data-sortable-custom-item][data-sortable-item-id]").forEach(r=>{const l=r.getAttribute("data-sortable-item-id");l&&r.querySelectorAll(h).forEach(d=>{d.setAttribute("data-sortable-custom-handle",""),d.setAttribute("data-drag-trigger","custom"),d.setAttribute("data-id",l),d.setAttribute("draggable","true")})}))},[a,c,h,S,E,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&&!q,ut=c?p.map(t=>{const r=a.current?.shadowRoot?.querySelector(`.item-custom-content[data-item-content-target="${B(t.id)}"]`);return r?z.createPortal(P.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=a.current?.shadowRoot?.querySelector(`.list-custom-header[data-list-header-target="${B(t.id)}"]`);return r?z.createPortal(P.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=a.current?.shadowRoot?.querySelector(`.list-custom-empty[data-list-empty-target="${B(t.id)}"]`);return r?z.createPortal(P.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:a,...nt};return c&&(Z["custom-item-rendering"]=""),P.jsxs(P.Fragment,{children:[mt("ui-sortable",Z,ot),E>=0?ut:null,E>=0?lt:null,E>=0?dt:null]})});F.displayName="Sortable";exports.Sortable=F;exports.default=F;
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,50 +1,50 @@
1
- import { jsx as M, jsxs as ft, Fragment as mt } from "react/jsx-runtime";
2
- import m from "react";
1
+ import { jsx as M, jsxs as ft, Fragment as bt } from "react/jsx-runtime";
2
+ import b from "react";
3
3
  import { createPortal as B } from "react-dom";
4
4
  import "@editora/ui-core/sortable";
5
- const q = typeof window < "u" ? m.useLayoutEffect : m.useEffect;
6
- function gt(e, s, ...i) {
5
+ const q = typeof window < "u" ? b.useLayoutEffect : b.useEffect;
6
+ function mt(e, s, ...i) {
7
7
  if (!s || !("className" in s) || !e.includes("-"))
8
- return m.createElement(e, s, ...i);
9
- const { className: u, ...g } = s, o = [g.class, u].filter((n) => typeof n == "string" && n !== "").join(" ");
10
- return m.createElement(e, o ? { ...g, class: o } : g, ...i);
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
11
  }
12
- function bt(e) {
13
- const s = m.useRef(null);
14
- return m.useImperativeHandle(e, () => s.current), s;
12
+ function gt(e) {
13
+ const s = b.useRef(null);
14
+ return b.useImperativeHandle(e, () => s.current), s;
15
15
  }
16
16
  function pt(e, s, i) {
17
- m.useEffect(() => {
18
- const u = e.current;
19
- if (!u) return;
20
- const g = s.filter(
17
+ b.useEffect(() => {
18
+ const l = e.current;
19
+ if (!l) return;
20
+ const m = s.filter(
21
21
  (o) => typeof o.listener == "function"
22
22
  );
23
- return g.forEach(({ type: o, listener: n }) => {
24
- u.addEventListener(o, n);
23
+ return m.forEach(({ type: o, listener: n }) => {
24
+ l.addEventListener(o, n);
25
25
  }), () => {
26
- g.forEach(({ type: o, listener: n }) => {
27
- u.removeEventListener(o, n);
26
+ m.forEach(({ type: o, listener: n }) => {
27
+ l.removeEventListener(o, n);
28
28
  });
29
29
  };
30
30
  }, [e, ...i]);
31
31
  }
32
32
  function yt(e, s, i) {
33
33
  q(() => {
34
- const u = e.current;
35
- u && s(u);
34
+ const l = e.current;
35
+ l && s(l);
36
36
  }, [e, ...i]);
37
37
  }
38
38
  function F(e) {
39
39
  return e.detail;
40
40
  }
41
41
  function y(e, s, i) {
42
- const u = e.getAttribute(s);
42
+ const l = e.getAttribute(s);
43
43
  if (i == null || i === "") {
44
- u != null && e.removeAttribute(s);
44
+ l != null && e.removeAttribute(s);
45
45
  return;
46
46
  }
47
- u !== i && e.setAttribute(s, i);
47
+ l !== i && e.setAttribute(s, i);
48
48
  }
49
49
  function rt(e, s, i) {
50
50
  if (i) {
@@ -105,15 +105,15 @@ function ht(e) {
105
105
  return e;
106
106
  }
107
107
  }
108
- const At = [], vt = [], wt = m.forwardRef(function(s, i) {
108
+ const At = [], vt = [], wt = b.forwardRef(function(s, i) {
109
109
  const {
110
- lists: u,
111
- items: g,
110
+ lists: l,
111
+ items: m,
112
112
  selection: o,
113
113
  filterQuery: n,
114
- sort: b,
114
+ sort: g,
115
115
  persistKey: C,
116
- allowFilteredDrag: P,
116
+ allowFilteredDrag: E,
117
117
  allowNesting: L,
118
118
  dropIndicatorVisibility: D,
119
119
  dropzoneStyle: Q,
@@ -135,9 +135,9 @@ const At = [], vt = [], wt = m.forwardRef(function(s, i) {
135
135
  onPersistRequest: H,
136
136
  children: it,
137
137
  ...ot
138
- } = s, f = u ?? At, p = g ?? vt, a = bt(i), [E, nt] = m.useState(0), K = !!(c || S || R);
138
+ } = s, f = l ?? At, p = m ?? vt, u = gt(i), [x, at] = b.useState(0), K = !!(c || S || R);
139
139
  pt(
140
- a,
140
+ u,
141
141
  [
142
142
  {
143
143
  type: "change",
@@ -163,24 +163,24 @@ const At = [], vt = [], wt = m.forwardRef(function(s, i) {
163
163
  ],
164
164
  [V, $, z, H]
165
165
  ), yt(
166
- a,
166
+ u,
167
167
  (t) => {
168
- T(t, "lists", f), T(t, "items", p), T(t, "selection", o ?? null), y(t, "filter-query", n ?? null), y(t, "sort", b && b !== "manual" ? b : null), y(t, "persist-key", C ?? null), rt(t, "allow-filtered-drag", P), 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);
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
169
  const r = st(k);
170
170
  r ? t.style.setProperty("--ui-sortable-item-radius", r) : t.style.removeProperty("--ui-sortable-item-radius");
171
- const l = st(G);
172
- l ? t.style.setProperty("--ui-sortable-handle-radius", l) : t.style.removeProperty("--ui-sortable-handle-radius");
173
- const d = ht(J ?? _);
174
- d ? t.style.setProperty("--ui-sortable-list-gap", d) : 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);
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);
175
175
  },
176
176
  [
177
177
  f,
178
178
  p,
179
179
  o,
180
180
  n,
181
- b,
181
+ g,
182
182
  C,
183
- P,
183
+ E,
184
184
  L,
185
185
  D,
186
186
  Q,
@@ -197,42 +197,42 @@ const At = [], vt = [], wt = m.forwardRef(function(s, i) {
197
197
  ]
198
198
  ), q(() => {
199
199
  if (!K) return;
200
- const t = a.current, r = t?.ownerDocument?.defaultView;
200
+ const t = u.current, r = t?.ownerDocument?.defaultView;
201
201
  if (!t || !r) return;
202
- let l = !1, d = !1, I = null, x = null;
202
+ let d = !1, a = !1, P = null, I = null;
203
203
  const Z = [
204
204
  c && p.length > 0 ? ".item-custom-content[data-item-content-target]" : null,
205
205
  S && f.length > 0 ? ".list-custom-header[data-list-header-target]" : null,
206
206
  R && f.length > 0 ? ".list-custom-empty[data-list-empty-target]" : null
207
207
  ].filter(Boolean).join(", "), tt = () => {
208
- l || d || (d = !0, queueMicrotask(() => {
209
- d = !1, !l && nt((v) => v + 1);
208
+ d || a || (a = !0, queueMicrotask(() => {
209
+ a = !1, !d && at((v) => v + 1);
210
210
  }));
211
211
  }, dt = () => {
212
- const v = a.current?.shadowRoot;
213
- return v ? (x || (x = new MutationObserver(() => tt()), x.observe(v, { childList: !0, subtree: !0 })), !0) : !1;
212
+ const v = u.current?.shadowRoot;
213
+ return v ? (I || (I = new MutationObserver(() => tt()), I.observe(v, { childList: !0, subtree: !0 })), !0) : !1;
214
214
  }, et = () => {
215
- if (l) return;
216
- const v = a.current?.shadowRoot, ct = !Z || !!v?.querySelector(Z);
215
+ if (d) return;
216
+ const v = u.current?.shadowRoot, ct = !Z || !!v?.querySelector(Z);
217
217
  if (dt() && ct) {
218
218
  tt();
219
219
  return;
220
220
  }
221
- I = r.requestAnimationFrame(et);
221
+ P = r.requestAnimationFrame(et);
222
222
  };
223
223
  return et(), () => {
224
- l = !0, I !== null && r.cancelAnimationFrame(I), x?.disconnect();
224
+ d = !0, P !== null && r.cancelAnimationFrame(P), I?.disconnect();
225
225
  };
226
226
  }, [
227
- a,
227
+ u,
228
228
  K,
229
229
  p,
230
230
  f,
231
231
  o,
232
232
  n,
233
- b,
233
+ g,
234
234
  C,
235
- P,
235
+ E,
236
236
  L,
237
237
  D,
238
238
  O,
@@ -244,27 +244,27 @@ const At = [], vt = [], wt = m.forwardRef(function(s, i) {
244
244
  S,
245
245
  R
246
246
  ]), q(() => {
247
- const t = a.current, r = t?.shadowRoot;
247
+ const t = u.current, r = t?.shadowRoot;
248
248
  if (!t) return;
249
249
  if (!c || !r) {
250
250
  t.removeAttribute("custom-item-rendering-ready"), t.removeAttribute("custom-item-rendering-pending");
251
251
  return;
252
252
  }
253
- const l = r.querySelectorAll(".item-custom-content[data-item-content-target]"), d = r.querySelectorAll("[data-sortable-custom-item]");
254
- l.length > 0 && d.length >= l.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
- }, [a, c, E, p, o, n, b, A]), q(() => {
256
- const t = a.current?.shadowRoot;
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
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");
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
259
  }), !(!c || !h || w === "item") && t.querySelectorAll("[data-sortable-custom-item][data-sortable-item-id]").forEach((r) => {
260
- const l = r.getAttribute("data-sortable-item-id");
261
- l && r.querySelectorAll(h).forEach((d) => {
262
- d.setAttribute("data-sortable-custom-handle", ""), d.setAttribute("data-drag-trigger", "custom"), d.setAttribute("data-id", l), d.setAttribute("draggable", "true");
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", ""));
263
263
  });
264
264
  }));
265
- }, [a, c, h, w, E, p, o, n, b, 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 || b === "label" || !!n && !P, at = c ? p.map((t) => {
267
- const r = a.current?.shadowRoot?.querySelector(
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
268
  `.item-custom-content[data-item-content-target="${j(t.id)}"]`
269
269
  );
270
270
  return r ? B(
@@ -289,7 +289,7 @@ const At = [], vt = [], wt = m.forwardRef(function(s, i) {
289
289
  t.id
290
290
  ) : null;
291
291
  }) : null, ut = S ? f.map((t) => {
292
- const r = a.current?.shadowRoot?.querySelector(
292
+ const r = u.current?.shadowRoot?.querySelector(
293
293
  `.list-custom-header[data-list-header-target="${j(t.id)}"]`
294
294
  );
295
295
  return r ? B(
@@ -301,7 +301,7 @@ const At = [], vt = [], wt = m.forwardRef(function(s, i) {
301
301
  `header-${t.id}`
302
302
  ) : null;
303
303
  }) : null, lt = R ? f.map((t) => {
304
- const r = a.current?.shadowRoot?.querySelector(
304
+ const r = u.current?.shadowRoot?.querySelector(
305
305
  `.list-custom-empty[data-list-empty-target="${j(t.id)}"]`
306
306
  );
307
307
  return r ? B(
@@ -313,12 +313,12 @@ const At = [], vt = [], wt = m.forwardRef(function(s, i) {
313
313
  r,
314
314
  `empty-${t.id}`
315
315
  ) : null;
316
- }) : null, Y = { ref: a, ...ot };
317
- return c && (Y["custom-item-rendering"] = ""), /* @__PURE__ */ ft(mt, { children: [
318
- gt("ui-sortable", Y, it),
319
- E >= 0 ? at : null,
320
- E >= 0 ? ut : null,
321
- E >= 0 ? lt : null
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
322
322
  ] });
323
323
  });
324
324
  wt.displayName = "Sortable";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editora/ui-sortable",
3
- "version": "0.1.5",
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.21"
45
+ "@editora/ui-core": "^0.1.22"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "react": ">=16.8 <21",