@wallarm-org/design-system 2.3.3 → 2.4.0

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,6 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { c } from "react/compiler-runtime";
2
+ import { c as compiler_runtime_c } from "react/compiler-runtime";
3
3
  import { createContext, useContext, useState } from "react";
4
+ import { createPortal } from "react-dom";
4
5
  import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
5
6
  import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
6
7
  import { useTableContext } from "../TableContext/index.js";
@@ -22,7 +23,7 @@ function resetCursor() {
22
23
  document.head.querySelector(`style[${CURSOR_STYLE_ATTR}]`)?.remove();
23
24
  }
24
25
  const TableBodyRowDndContext = (t0)=>{
25
- const $ = c(3);
26
+ const $ = compiler_runtime_c(3);
26
27
  const { children } = t0;
27
28
  const { rowDndEnabled, onRowReorder } = useTableContext();
28
29
  if (!rowDndEnabled) return children;
@@ -39,7 +40,7 @@ const TableBodyRowDndContext = (t0)=>{
39
40
  return t1;
40
41
  };
41
42
  const TableBodyRowDndContextInner = (t0)=>{
42
- const $ = c(31);
43
+ const $ = compiler_runtime_c(38);
43
44
  const { children, onRowReorder } = t0;
44
45
  const { table } = useTableContext();
45
46
  let t1;
@@ -71,135 +72,169 @@ const TableBodyRowDndContextInner = (t0)=>{
71
72
  } else t3 = $[6];
72
73
  const indicatorState = t3;
73
74
  let t4;
74
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
75
- t4 = {
75
+ if ($[7] !== rows) {
76
+ t4 = new Map(rows.map(_temp2));
77
+ $[7] = rows;
78
+ $[8] = t4;
79
+ } else t4 = $[8];
80
+ const parentOf = t4;
81
+ let t5;
82
+ if ($[9] !== parentOf) {
83
+ t5 = (args)=>closestCenter({
84
+ ...args,
85
+ droppableContainers: args.droppableContainers.filter((c)=>parentOf.get(String(c.id)) === parentOf.get(String(args.active.id)))
86
+ });
87
+ $[9] = parentOf;
88
+ $[10] = t5;
89
+ } else t5 = $[10];
90
+ const collisionDetection = t5;
91
+ let t6;
92
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
93
+ t6 = {
76
94
  activationConstraint: {
77
95
  distance: 5
78
96
  }
79
97
  };
80
- $[7] = t4;
81
- } else t4 = $[7];
82
- const sensors = useSensors(useSensor(PointerSensor, t4), useSensor(KeyboardSensor));
83
- let t5;
84
- if ($[8] !== rows) {
85
- t5 = (event)=>{
98
+ $[11] = t6;
99
+ } else t6 = $[11];
100
+ const sensors = useSensors(useSensor(PointerSensor, t6), useSensor(KeyboardSensor));
101
+ let t7;
102
+ if ($[12] !== rows) {
103
+ t7 = (event)=>{
86
104
  const id = String(event.active.id);
87
- const row = rows.find((r_0)=>r_0.id === id);
105
+ const row = rows.find((r_1)=>r_1.id === id);
88
106
  setActiveRow(row ?? null);
89
107
  setActiveId(id);
90
108
  setCursorGrabbing();
91
109
  };
92
- $[8] = rows;
93
- $[9] = t5;
94
- } else t5 = $[9];
95
- const handleDragStart = t5;
96
- let t6;
97
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
98
- t6 = (event_0)=>{
110
+ $[12] = rows;
111
+ $[13] = t7;
112
+ } else t7 = $[13];
113
+ const handleDragStart = t7;
114
+ let t8;
115
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
116
+ t8 = (event_0)=>{
99
117
  setOverId(event_0.over ? String(event_0.over.id) : null);
100
118
  };
101
- $[10] = t6;
102
- } else t6 = $[10];
103
- const handleDragOver = t6;
104
- let t7;
105
- if ($[11] !== onRowReorder) {
106
- t7 = (event_1)=>{
119
+ $[14] = t8;
120
+ } else t8 = $[14];
121
+ const handleDragOver = t8;
122
+ let t9;
123
+ if ($[15] !== onRowReorder || $[16] !== parentOf) {
124
+ t9 = (event_1)=>{
107
125
  setActiveRow(null);
108
126
  setActiveId(null);
109
127
  setOverId(null);
110
128
  resetCursor();
111
129
  const { active, over } = event_1;
112
130
  if (!over || active.id === over.id) return;
131
+ if (parentOf.get(String(active.id)) !== parentOf.get(String(over.id))) return;
113
132
  onRowReorder?.({
114
133
  activeRowId: String(active.id),
115
134
  overRowId: String(over.id)
116
135
  });
117
136
  };
118
- $[11] = onRowReorder;
119
- $[12] = t7;
120
- } else t7 = $[12];
121
- const handleDragEnd = t7;
122
- let t8;
123
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
124
- t8 = ()=>{
137
+ $[15] = onRowReorder;
138
+ $[16] = parentOf;
139
+ $[17] = t9;
140
+ } else t9 = $[17];
141
+ const handleDragEnd = t9;
142
+ let t10;
143
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
144
+ t10 = ()=>{
125
145
  setActiveRow(null);
126
146
  setActiveId(null);
127
147
  setOverId(null);
128
148
  resetCursor();
129
149
  };
130
- $[13] = t8;
131
- } else t8 = $[13];
132
- const handleDragCancel = t8;
133
- let t9;
134
- if ($[14] !== children || $[15] !== rowIds) {
135
- t9 = /*#__PURE__*/ jsx(SortableContext, {
150
+ $[18] = t10;
151
+ } else t10 = $[18];
152
+ const handleDragCancel = t10;
153
+ let t11;
154
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
155
+ t11 = {
156
+ container: document.body
157
+ };
158
+ $[19] = t11;
159
+ } else t11 = $[19];
160
+ let t12;
161
+ if ($[20] !== children || $[21] !== rowIds) {
162
+ t12 = /*#__PURE__*/ jsx(SortableContext, {
136
163
  items: rowIds,
137
164
  strategy: verticalListSortingStrategy,
138
165
  children: children
139
166
  });
140
- $[14] = children;
141
- $[15] = rowIds;
142
- $[16] = t9;
143
- } else t9 = $[16];
144
- let t10;
145
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
146
- t10 = {
167
+ $[20] = children;
168
+ $[21] = rowIds;
169
+ $[22] = t12;
170
+ } else t12 = $[22];
171
+ let t13;
172
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
173
+ t13 = {
147
174
  cursor: "grabbing"
148
175
  };
149
- $[17] = t10;
150
- } else t10 = $[17];
151
- let t11;
152
- if ($[18] !== activeRow) {
153
- t11 = activeRow ? /*#__PURE__*/ jsx(TableRowOverlay, {
176
+ $[23] = t13;
177
+ } else t13 = $[23];
178
+ let t14;
179
+ if ($[24] !== activeRow) {
180
+ t14 = activeRow ? /*#__PURE__*/ jsx(TableRowOverlay, {
154
181
  row: activeRow
155
182
  }) : null;
156
- $[18] = activeRow;
157
- $[19] = t11;
158
- } else t11 = $[19];
159
- let t12;
160
- if ($[20] !== t11) {
161
- t12 = /*#__PURE__*/ jsx(DragOverlay, {
162
- style: t10,
163
- children: t11
164
- });
165
- $[20] = t11;
166
- $[21] = t12;
167
- } else t12 = $[21];
168
- let t13;
169
- if ($[22] !== handleDragEnd || $[23] !== handleDragStart || $[24] !== sensors || $[25] !== t12 || $[26] !== t9) {
170
- t13 = /*#__PURE__*/ jsxs(DndContext, {
183
+ $[24] = activeRow;
184
+ $[25] = t14;
185
+ } else t14 = $[25];
186
+ let t15;
187
+ if ($[26] !== t14) {
188
+ t15 = /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(DragOverlay, {
189
+ style: t13,
190
+ children: t14
191
+ }), document.body);
192
+ $[26] = t14;
193
+ $[27] = t15;
194
+ } else t15 = $[27];
195
+ let t16;
196
+ if ($[28] !== collisionDetection || $[29] !== handleDragEnd || $[30] !== handleDragStart || $[31] !== sensors || $[32] !== t12 || $[33] !== t15) {
197
+ t16 = /*#__PURE__*/ jsxs(DndContext, {
171
198
  sensors: sensors,
172
- collisionDetection: closestCenter,
199
+ collisionDetection: collisionDetection,
200
+ accessibility: t11,
173
201
  onDragStart: handleDragStart,
174
202
  onDragOver: handleDragOver,
175
203
  onDragEnd: handleDragEnd,
176
204
  onDragCancel: handleDragCancel,
177
205
  children: [
178
- t9,
179
- t12
206
+ t12,
207
+ t15
180
208
  ]
181
209
  });
182
- $[22] = handleDragEnd;
183
- $[23] = handleDragStart;
184
- $[24] = sensors;
185
- $[25] = t12;
186
- $[26] = t9;
187
- $[27] = t13;
188
- } else t13 = $[27];
189
- let t14;
190
- if ($[28] !== indicatorState || $[29] !== t13) {
191
- t14 = /*#__PURE__*/ jsx(RowDndIndicatorContext.Provider, {
210
+ $[28] = collisionDetection;
211
+ $[29] = handleDragEnd;
212
+ $[30] = handleDragStart;
213
+ $[31] = sensors;
214
+ $[32] = t12;
215
+ $[33] = t15;
216
+ $[34] = t16;
217
+ } else t16 = $[34];
218
+ let t17;
219
+ if ($[35] !== indicatorState || $[36] !== t16) {
220
+ t17 = /*#__PURE__*/ jsx(RowDndIndicatorContext.Provider, {
192
221
  value: indicatorState,
193
- children: t13
222
+ children: t16
194
223
  });
195
- $[28] = indicatorState;
196
- $[29] = t13;
197
- $[30] = t14;
198
- } else t14 = $[30];
199
- return t14;
224
+ $[35] = indicatorState;
225
+ $[36] = t16;
226
+ $[37] = t17;
227
+ } else t17 = $[37];
228
+ return t17;
200
229
  };
201
230
  TableBodyRowDndContext.displayName = "TableBodyRowDndContext";
202
231
  function _temp(r) {
203
232
  return r.id;
204
233
  }
234
+ function _temp2(r_0) {
235
+ return [
236
+ r_0.id,
237
+ r_0.parentId
238
+ ];
239
+ }
205
240
  export { TableBodyRowDndContext, useRowDndIndicator };