@epilot/zenith-react 0.2.0 → 0.2.2

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.
@@ -1,95 +1,109 @@
1
- import { jsx as s, jsxs as N } from "react/jsx-runtime";
2
- import * as o from "react";
3
- import { useSensors as A, useSensor as D, DndContext as R, closestCenter as j, DragOverlay as G, KeyboardSensor as K, PointerSensor as P } from "../../vendor/.bun/@dnd-kit_core@6.3.1_6f4b9a1cfb20c0ae/vendor/@dnd-kit/core/dist/core.esm.js";
4
- import { SortableContext as V, verticalListSortingStrategy as k, useSortable as q, arrayMove as B, sortableKeyboardCoordinates as M } from "../../vendor/.bun/@dnd-kit_sortable@10.0.0_1d291640e1250bbe/vendor/@dnd-kit/sortable/dist/sortable.esm.js";
5
- import { useListStyles as _, ListItem as z, listContext as F, ListRoot as H, ListItemBody as L, canonicalDomDensity as J } from "./list.js";
6
- const Q = o.forwardRef(
7
- function(n, f) {
8
- const i = o.useId();
9
- process.env.NODE_ENV !== "production" && n.value === void 0 && console.warn(
1
+ import { jsx as r, jsxs as B } from "react/jsx-runtime";
2
+ import * as i from "react";
3
+ import { useSensors as F, useSensor as O, DndContext as P, closestCenter as j, DragOverlay as G, KeyboardSensor as K, PointerSensor as T } from "../../vendor/.bun/@dnd-kit_core@6.3.1_6f4b9a1cfb20c0ae/vendor/@dnd-kit/core/dist/core.esm.js";
4
+ import { SortableContext as _, verticalListSortingStrategy as k, useSortable as q, arrayMove as H, sortableKeyboardCoordinates as M } from "../../vendor/.bun/@dnd-kit_sortable@10.0.0_1d291640e1250bbe/vendor/@dnd-kit/sortable/dist/sortable.esm.js";
5
+ import { useListStyles as z, ListItem as J, listContext as Q, ListRoot as U, ListItemBody as C, canonicalDomDensity as W } from "./list.js";
6
+ const X = i.forwardRef(
7
+ function(e, a) {
8
+ const s = i.useId();
9
+ process.env.NODE_ENV !== "production" && e.value === void 0 && console.warn(
10
10
  "SortableList: a `ListItem` is missing a `value`. Give each item a unique `value` so it can be reordered — items without one are excluded from `onReorder`."
11
11
  );
12
12
  const {
13
- attributes: r,
14
- listeners: a,
15
- setNodeRef: I,
16
- setActivatorNodeRef: p,
17
- isDragging: l,
18
- isOver: d,
19
- activeIndex: c,
20
- overIndex: u
13
+ attributes: d,
14
+ listeners: u,
15
+ setNodeRef: y,
16
+ setActivatorNodeRef: g,
17
+ isDragging: v,
18
+ isOver: f,
19
+ activeIndex: m,
20
+ overIndex: n
21
21
  } = q({
22
- id: n.value ?? i,
22
+ id: e.value ?? s,
23
23
  animateLayoutChanges: () => !1
24
- }), e = d && !l && c !== -1 ? c < u ? "bottom" : "top" : null;
25
- return /* @__PURE__ */ s(
26
- L,
24
+ }), p = f && !v && m !== -1 ? m < n ? "bottom" : "top" : null;
25
+ return /* @__PURE__ */ r(
26
+ C,
27
27
  {
28
- ref: f,
29
- ...n,
30
- setNodeRef: I,
31
- setActivatorNodeRef: p,
32
- isDragging: l,
33
- dropEdge: e,
34
- listeners: a,
35
- attributes: r
28
+ ref: a,
29
+ ...e,
30
+ setNodeRef: y,
31
+ setActivatorNodeRef: g,
32
+ isDragging: v,
33
+ dropEdge: p,
34
+ listeners: u,
35
+ attributes: d
36
36
  }
37
37
  );
38
38
  }
39
- ), Y = o.forwardRef(function({
40
- striped: n = !1,
41
- showIndex: f = !1,
42
- onReorder: i,
43
- density: r,
44
- children: a,
45
- ...I
46
- }, p) {
47
- const l = _(), d = J(r), c = o.useId(), u = o.Children.toArray(a).filter(
48
- o.isValidElement
49
- ).filter((t) => t.type === z), e = u.map((t) => t.props.value).filter((t) => typeof t == "string"), [v, S] = o.useState(null), C = v ? e.indexOf(v) : -1, m = v != null ? u.find((t) => t.props.value === v) : void 0, O = A(
50
- D(P, { activationConstraint: { distance: 3 } }),
39
+ ), L = { x: 0, y: 0 }, Y = (o) => {
40
+ const e = o.ownerDocument.createElement("div");
41
+ e.style.cssText = "position:fixed;top:0;left:0;width:0;height:0;visibility:hidden", o.after(e);
42
+ const { left: a, top: s } = e.getBoundingClientRect();
43
+ return e.remove(), { x: a, y: s };
44
+ }, Z = (o) => ({ transform: e }) => ({
45
+ ...e,
46
+ x: e.x - o.x,
47
+ y: e.y - o.y
48
+ }), oe = i.forwardRef(function({
49
+ striped: e = !1,
50
+ showIndex: a = !1,
51
+ onReorder: s,
52
+ density: d,
53
+ children: u,
54
+ ...y
55
+ }, g) {
56
+ const v = z(), f = W(d), m = i.useId(), n = i.useRef(null);
57
+ i.useImperativeHandle(g, () => n.current, []);
58
+ const p = i.Children.toArray(u).filter(
59
+ i.isValidElement
60
+ ).filter((t) => t.type === J), l = p.map((t) => t.props.value).filter((t) => typeof t == "string"), [x, I] = i.useState(null), [E, w] = i.useState(L), N = x ? l.indexOf(x) : -1, c = x != null ? p.find((t) => t.props.value === x) : void 0, R = F(
61
+ O(T, { activationConstraint: { distance: 3 } }),
51
62
  // Without the sortable coordinate getter each arrow press moves a fixed 25px, not one row.
52
- D(K, {
63
+ O(K, {
53
64
  coordinateGetter: M
54
65
  })
55
- ), E = (t) => {
56
- S(t.active.id);
57
- }, w = (t) => {
58
- S(null);
59
- const { active: b, over: g } = t;
60
- if (!g || b.id === g.id) return;
61
- const x = e.indexOf(b.id), y = e.indexOf(g.id);
62
- x === -1 || y === -1 || i == null || i(B(e, x, y));
66
+ ), V = (t) => {
67
+ I(t.active.id), w(
68
+ n.current ? Y(n.current) : L
69
+ );
70
+ }, A = (t) => {
71
+ I(null);
72
+ const { active: b, over: S } = t;
73
+ if (!S || b.id === S.id) return;
74
+ const h = l.indexOf(b.id), D = l.indexOf(S.id);
75
+ h === -1 || D === -1 || s == null || s(H(l, h, D));
63
76
  };
64
- return /* @__PURE__ */ s(
65
- F.Provider,
77
+ return /* @__PURE__ */ r(
78
+ Q.Provider,
66
79
  {
67
80
  value: {
68
- striped: n,
69
- showIndex: f,
81
+ striped: e,
82
+ showIndex: a,
70
83
  sortable: !0,
71
- SortableItem: Q
84
+ SortableItem: X
72
85
  },
73
- children: /* @__PURE__ */ N(
74
- R,
86
+ children: /* @__PURE__ */ B(
87
+ P,
75
88
  {
76
- id: c,
77
- sensors: O,
89
+ id: m,
90
+ sensors: R,
78
91
  collisionDetection: j,
79
- onDragStart: E,
80
- onDragEnd: w,
81
- onDragCancel: () => S(null),
92
+ onDragStart: V,
93
+ onDragEnd: A,
94
+ onDragCancel: () => I(null),
82
95
  children: [
83
- /* @__PURE__ */ s(V, { items: e, strategy: k, children: /* @__PURE__ */ s(H, { ref: p, density: r, ...I, children: a }) }),
84
- /* @__PURE__ */ s(G, { children: m ? /* @__PURE__ */ s(
85
- L,
96
+ /* @__PURE__ */ r(_, { items: l, strategy: k, children: /* @__PURE__ */ r(U, { ref: n, density: d, ...y, children: u }) }),
97
+ /* @__PURE__ */ r(G, { modifiers: [Z(E)], children: c ? /* @__PURE__ */ r(
98
+ C,
86
99
  {
87
- value: m.props.value,
88
- status: m.props.status,
89
- index: C,
90
- className: l.dragOverlayItem,
91
- ...d !== void 0 ? { "data-density": d } : {},
92
- children: m.props.children
100
+ value: c.props.value,
101
+ textValue: c.props.textValue,
102
+ status: c.props.status,
103
+ index: N,
104
+ className: v.dragOverlayItem,
105
+ ...f !== void 0 ? { "data-density": f } : {},
106
+ children: c.props.children
93
107
  }
94
108
  ) : null })
95
109
  ]
@@ -99,6 +113,6 @@ const Q = o.forwardRef(
99
113
  );
100
114
  });
101
115
  export {
102
- Y as SortableList
116
+ oe as SortableList
103
117
  };
104
118
  //# sourceMappingURL=list-sortable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"list-sortable.js","sources":["../../../src/components/list/list-sortable.tsx"],"sourcesContent":["import * as React from \"react\"\nimport {\n DndContext,\n DragOverlay,\n closestCenter,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n type DragEndEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\"\nimport {\n SortableContext,\n verticalListSortingStrategy,\n arrayMove,\n sortableKeyboardCoordinates,\n useSortable,\n} from \"@dnd-kit/sortable\"\n\nimport {\n listContext,\n ListItem,\n ListItemBody,\n ListRoot,\n canonicalDomDensity,\n useListStyles,\n type ListItemDragListeners,\n type ListItemProps,\n type ListProps,\n} from \"./list\"\n\n// ── SortableListItem ───────────────────────────────────────────────────────\n\nconst SortableListItem = React.forwardRef<HTMLLIElement, ListItemProps>(\n function SortableListItem(props, ref) {\n const fallbackId = React.useId()\n\n if (process.env.NODE_ENV !== \"production\" && props.value === undefined) {\n console.warn(\n \"SortableList: a `ListItem` is missing a `value`. \" +\n \"Give each item a unique `value` so it can be reordered — \" +\n \"items without one are excluded from `onReorder`.\"\n )\n }\n\n const {\n attributes,\n listeners,\n setNodeRef,\n setActivatorNodeRef,\n isDragging,\n isOver,\n activeIndex,\n overIndex,\n } = useSortable({\n id: props.value ?? fallbackId,\n animateLayoutChanges: () => false,\n })\n\n const dropEdge: \"top\" | \"bottom\" | null =\n isOver && !isDragging && activeIndex !== -1\n ? activeIndex < overIndex\n ? \"bottom\"\n : \"top\"\n : null\n\n return (\n <ListItemBody\n ref={ref}\n {...props}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n isDragging={isDragging}\n dropEdge={dropEdge}\n listeners={listeners as ListItemDragListeners | undefined}\n attributes={attributes}\n />\n )\n }\n)\n\n// ── SortableList ───────────────────────────────────────────────────────────\n\nexport type SortableListProps = ListProps & {\n /** Called with the new order of `ListItem` values after a drag. */\n onReorder?: (values: string[]) => void\n}\n\nexport const SortableList = React.forwardRef<\n HTMLOListElement,\n SortableListProps\n>(function SortableList(\n {\n striped = false,\n showIndex = false,\n onReorder,\n density,\n children,\n ...props\n },\n ref\n) {\n const styles = useListStyles()\n const domDensity = canonicalDomDensity(density)\n // dnd-kit otherwise numbers its describedby/live-region ids from a module counter, which the\n // server and the client advance separately, so the handles' aria-describedby failed hydration.\n const dndId = React.useId()\n\n const listItems = (\n React.Children.toArray(children).filter(\n React.isValidElement\n ) as React.ReactElement<ListItemProps>[]\n ).filter((child) => child.type === ListItem)\n const values = listItems\n .map((child) => child.props.value)\n .filter((v): v is string => typeof v === \"string\")\n\n const [activeId, setActiveId] = React.useState<string | null>(null)\n const activeIndex = activeId ? values.indexOf(activeId) : -1\n const activeItem =\n activeId != null\n ? listItems.find((child) => child.props.value === activeId)\n : undefined\n\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 3 } }),\n // Without the sortable coordinate getter each arrow press moves a fixed 25px, not one row.\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n })\n )\n\n const handleDragStart = (event: DragStartEvent) => {\n setActiveId(event.active.id as string)\n }\n\n const handleDragEnd = (event: DragEndEvent) => {\n setActiveId(null)\n const { active, over } = event\n if (!over || active.id === over.id) return\n\n const oldIndex = values.indexOf(active.id as string)\n const newIndex = values.indexOf(over.id as string)\n if (oldIndex === -1 || newIndex === -1) return\n\n onReorder?.(arrayMove(values, oldIndex, newIndex))\n }\n\n return (\n <listContext.Provider\n value={{\n striped,\n showIndex,\n sortable: true,\n SortableItem: SortableListItem,\n }}\n >\n <DndContext\n id={dndId}\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n onDragCancel={() => setActiveId(null)}\n >\n <SortableContext items={values} strategy={verticalListSortingStrategy}>\n <ListRoot ref={ref} density={density} {...props}>\n {children}\n </ListRoot>\n </SortableContext>\n <DragOverlay>\n {activeItem ? (\n <ListItemBody\n value={activeItem.props.value}\n status={activeItem.props.status}\n index={activeIndex}\n className={styles.dragOverlayItem}\n // Reasserted only for an EXPLICIT density: DragOverlay is an ordinary DOM sibling\n // of the `<ol>`, not a portal (dnd-kit's `PositionedOverlay` renders in place —\n // confirmed from the installed source), so an omitted/ambient density already\n // reaches it correctly through the real DOM tree with no stamp at all.\n {...(domDensity !== undefined\n ? { \"data-density\": domDensity }\n : {})}\n >\n {activeItem.props.children}\n </ListItemBody>\n ) : null}\n </DragOverlay>\n </DndContext>\n </listContext.Provider>\n )\n})\n"],"names":["SortableListItem","React","props","ref","fallbackId","attributes","listeners","setNodeRef","setActivatorNodeRef","isDragging","isOver","activeIndex","overIndex","useSortable","dropEdge","jsx","ListItemBody","SortableList","striped","showIndex","onReorder","density","children","styles","useListStyles","domDensity","canonicalDomDensity","dndId","listItems","child","ListItem","values","v","activeId","setActiveId","activeItem","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","sortableKeyboardCoordinates","handleDragStart","event","handleDragEnd","active","over","oldIndex","newIndex","arrayMove","listContext","jsxs","DndContext","closestCenter","SortableContext","verticalListSortingStrategy","ListRoot","DragOverlay"],"mappings":";;;;;AAkCA,MAAMA,IAAmBC,EAAM;AAAA,EAC7B,SAA0BC,GAAOC,GAAK;AACpC,UAAMC,IAAaH,EAAM,MAAA;AAEzB,IAAI,QAAQ,IAAI,aAAa,gBAAgBC,EAAM,UAAU,UAC3D,QAAQ;AAAA,MACN;AAAA,IAAA;AAMJ,UAAM;AAAA,MACJ,YAAAG;AAAA,MACA,WAAAC;AAAA,MACA,YAAAC;AAAA,MACA,qBAAAC;AAAA,MACA,YAAAC;AAAA,MACA,QAAAC;AAAA,MACA,aAAAC;AAAA,MACA,WAAAC;AAAA,IAAA,IACEC,EAAY;AAAA,MACd,IAAIX,EAAM,SAASE;AAAA,MACnB,sBAAsB,MAAM;AAAA,IAAA,CAC7B,GAEKU,IACJJ,KAAU,CAACD,KAAcE,MAAgB,KACrCA,IAAcC,IACZ,WACA,QACF;AAEN,WACE,gBAAAG;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAAb;AAAA,QACC,GAAGD;AAAA,QACJ,YAAAK;AAAA,QACA,qBAAAC;AAAA,QACA,YAAAC;AAAA,QACA,UAAAK;AAAA,QACA,WAAAR;AAAA,QACA,YAAAD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF,GASaY,IAAehB,EAAM,WAGhC,SACA;AAAA,EACE,SAAAiB,IAAU;AAAA,EACV,WAAAC,IAAY;AAA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AZ;AAAA,MACC,OAAO;AAAA,QACL,SAAAhC;AAAA,QACA,WAAAC;AAAA,QACA,UAAU;AAAA,QACV,cAAcnB;AAAA,MAAA;AAAA,MAGhB,UAAA,gBAAAmD;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,IAAIzB;AAAA,UACJ,SAAAS;AAAA,UACA,oBAAoBiB;AAAA,UACpB,aAAaX;AAAA,UACb,WAAWE;AAAA,UACX,cAAc,MAAMV,EAAY,IAAI;AAAA,UAEpC,UAAA;AAAA,YAAA,gBAAAnB,EAACuC,GAAA,EAAgB,OAAOvB,GAAQ,UAAUwB,GACxC,UAAA,gBAAAxC,EAACyC,GAAA,EAAS,KAAArD,GAAU,SAAAkB,GAAmB,GAAGnB,GACvC,UAAAoB,EAAA,CACH,GACF;AAAA,YACA,gBAAAP,EAAC0C,KACE,UAAAtB,IACC,gBAAApB;AAAA,cAACC;AAAA,cAAA;AAAA,gBACC,OAAOmB,EAAW,MAAM;AAAA,gBACxB,QAAQA,EAAW,MAAM;AAAA,gBACzB,OAAOxB;AAAA,gBACP,WAAWY,EAAO;AAAA,gBAKjB,GAAIE,MAAe,SAChB,EAAE,gBAAgBA,EAAA,IAClB,CAAA;AAAA,gBAEH,YAAW,MAAM;AAAA,cAAA;AAAA,YAAA,IAElB,KAAA,CACN;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN,CAAC;"}
1
+ {"version":3,"file":"list-sortable.js","sources":["../../../src/components/list/list-sortable.tsx"],"sourcesContent":["import * as React from \"react\"\nimport {\n DndContext,\n DragOverlay,\n closestCenter,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n type DragEndEvent,\n type DragStartEvent,\n type Modifier,\n} from \"@dnd-kit/core\"\nimport {\n SortableContext,\n verticalListSortingStrategy,\n arrayMove,\n sortableKeyboardCoordinates,\n useSortable,\n} from \"@dnd-kit/sortable\"\n\nimport {\n listContext,\n ListItem,\n ListItemBody,\n ListRoot,\n canonicalDomDensity,\n useListStyles,\n type ListItemDragListeners,\n type ListItemProps,\n type ListProps,\n} from \"./list\"\n\n// ── SortableListItem ───────────────────────────────────────────────────────\n\nconst SortableListItem = React.forwardRef<HTMLLIElement, ListItemProps>(\n function SortableListItem(props, ref) {\n const fallbackId = React.useId()\n\n if (process.env.NODE_ENV !== \"production\" && props.value === undefined) {\n console.warn(\n \"SortableList: a `ListItem` is missing a `value`. \" +\n \"Give each item a unique `value` so it can be reordered — \" +\n \"items without one are excluded from `onReorder`.\"\n )\n }\n\n const {\n attributes,\n listeners,\n setNodeRef,\n setActivatorNodeRef,\n isDragging,\n isOver,\n activeIndex,\n overIndex,\n } = useSortable({\n id: props.value ?? fallbackId,\n animateLayoutChanges: () => false,\n })\n\n const dropEdge: \"top\" | \"bottom\" | null =\n isOver && !isDragging && activeIndex !== -1\n ? activeIndex < overIndex\n ? \"bottom\"\n : \"top\"\n : null\n\n return (\n <ListItemBody\n ref={ref}\n {...props}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n isDragging={isDragging}\n dropEdge={dropEdge}\n listeners={listeners as ListItemDragListeners | undefined}\n attributes={attributes}\n />\n )\n }\n)\n\n// ── SortableList ───────────────────────────────────────────────────────────\n\ntype Offset = { x: number; y: number }\n\nconst NO_OFFSET: Offset = { x: 0, y: 0 }\n\n/**\n * Where a fixed-position box placed beside `node` lands, which a transformed ancestor such as a Popover moves off the viewport's origin.\n */\nconst getFixedPositionOrigin = (node: Element): Offset => {\n const probe = node.ownerDocument.createElement(\"div\")\n probe.style.cssText =\n \"position:fixed;top:0;left:0;width:0;height:0;visibility:hidden\"\n node.after(probe)\n const { left, top } = probe.getBoundingClientRect()\n probe.remove()\n return { x: left, y: top }\n}\n\n/**\n * Moves the drag overlay back by `offset`.\n */\nconst shiftBy =\n (offset: Offset): Modifier =>\n ({ transform }) => ({\n ...transform,\n x: transform.x - offset.x,\n y: transform.y - offset.y,\n })\n\nexport type SortableListProps = ListProps & {\n /** Called with the new order of `ListItem` values after a drag. */\n onReorder?: (values: string[]) => void\n}\n\nexport const SortableList = React.forwardRef<\n HTMLOListElement,\n SortableListProps\n>(function SortableList(\n {\n striped = false,\n showIndex = false,\n onReorder,\n density,\n children,\n ...props\n },\n ref\n) {\n const styles = useListStyles()\n const domDensity = canonicalDomDensity(density)\n // dnd-kit otherwise numbers its describedby/live-region ids from a module counter, which the\n // server and the client advance separately, so the handles' aria-describedby failed hydration.\n const dndId = React.useId()\n const listRef = React.useRef<HTMLOListElement>(null)\n React.useImperativeHandle(ref, () => listRef.current as HTMLOListElement, [])\n\n const listItems = (\n React.Children.toArray(children).filter(\n React.isValidElement\n ) as React.ReactElement<ListItemProps>[]\n ).filter((child) => child.type === ListItem)\n const values = listItems\n .map((child) => child.props.value)\n .filter((v): v is string => typeof v === \"string\")\n\n const [activeId, setActiveId] = React.useState<string | null>(null)\n const [overlayOrigin, setOverlayOrigin] = React.useState(NO_OFFSET)\n const activeIndex = activeId ? values.indexOf(activeId) : -1\n const activeItem =\n activeId != null\n ? listItems.find((child) => child.props.value === activeId)\n : undefined\n\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 3 } }),\n // Without the sortable coordinate getter each arrow press moves a fixed 25px, not one row.\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n })\n )\n\n const handleDragStart = (event: DragStartEvent) => {\n setActiveId(event.active.id as string)\n setOverlayOrigin(\n listRef.current ? getFixedPositionOrigin(listRef.current) : NO_OFFSET\n )\n }\n\n const handleDragEnd = (event: DragEndEvent) => {\n setActiveId(null)\n const { active, over } = event\n if (!over || active.id === over.id) return\n\n const oldIndex = values.indexOf(active.id as string)\n const newIndex = values.indexOf(over.id as string)\n if (oldIndex === -1 || newIndex === -1) return\n\n onReorder?.(arrayMove(values, oldIndex, newIndex))\n }\n\n return (\n <listContext.Provider\n value={{\n striped,\n showIndex,\n sortable: true,\n SortableItem: SortableListItem,\n }}\n >\n <DndContext\n id={dndId}\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n onDragCancel={() => setActiveId(null)}\n >\n <SortableContext items={values} strategy={verticalListSortingStrategy}>\n <ListRoot ref={listRef} density={density} {...props}>\n {children}\n </ListRoot>\n </SortableContext>\n {/* The overlay stays beside the list so density and appearance reach it through the DOM;\n under a transformed ancestor its fixed position starts from that ancestor, not the\n viewport, so it is shifted back to stay under the pointer. */}\n <DragOverlay modifiers={[shiftBy(overlayOrigin)]}>\n {activeItem ? (\n <ListItemBody\n value={activeItem.props.value}\n textValue={activeItem.props.textValue}\n status={activeItem.props.status}\n index={activeIndex}\n className={styles.dragOverlayItem}\n // Reasserted only for an EXPLICIT density: DragOverlay is an ordinary DOM sibling\n // of the `<ol>`, not a portal (dnd-kit's `PositionedOverlay` renders in place —\n // confirmed from the installed source), so an omitted/ambient density already\n // reaches it correctly through the real DOM tree with no stamp at all.\n {...(domDensity !== undefined\n ? { \"data-density\": domDensity }\n : {})}\n >\n {activeItem.props.children}\n </ListItemBody>\n ) : null}\n </DragOverlay>\n </DndContext>\n </listContext.Provider>\n )\n})\n"],"names":["SortableListItem","React","props","ref","fallbackId","attributes","listeners","setNodeRef","setActivatorNodeRef","isDragging","isOver","activeIndex","overIndex","useSortable","dropEdge","jsx","ListItemBody","NO_OFFSET","getFixedPositionOrigin","node","probe","left","top","shiftBy","offset","transform","SortableList","striped","showIndex","onReorder","density","children","styles","useListStyles","domDensity","canonicalDomDensity","dndId","listRef","listItems","child","ListItem","values","v","activeId","setActiveId","overlayOrigin","setOverlayOrigin","activeItem","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","sortableKeyboardCoordinates","handleDragStart","event","handleDragEnd","active","over","oldIndex","newIndex","arrayMove","listContext","jsxs","DndContext","closestCenter","SortableContext","verticalListSortingStrategy","ListRoot","DragOverlay"],"mappings":";;;;;AAmCA,MAAMA,IAAmBC,EAAM;AAAA,EAC7B,SAA0BC,GA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