@crediblemark/build 0.24.5 → 0.24.7
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/ArrayField-2HGRARI2.mjs +19 -0
- package/dist/{ArrayField-ZD5UTLNU.css → ArrayField-SEWJV5GB.css} +53 -36
- package/dist/{Editor-HOZVZZIZ.mjs → Editor-3EPLDK4J.mjs} +7 -7
- package/dist/ObjectField-2JSLQM7O.mjs +19 -0
- package/dist/{ObjectField-SQKROKJM.css → ObjectField-KBWPA5AV.css} +53 -36
- package/dist/{chunk-VBNE6GK2.mjs → chunk-5JSNFZKX.mjs} +7 -7
- package/dist/chunk-7EY2S46B.mjs +92 -0
- package/dist/{chunk-WKMRHPOM.mjs → chunk-KUWVOWUV.mjs} +1 -1
- package/dist/{chunk-LBMMY5IM.mjs → chunk-MFTVX2ME.mjs} +1 -1
- package/dist/{ArrayField-F7OLZF6U.mjs → chunk-N2NNRJDJ.mjs} +364 -45
- package/dist/{chunk-H2LU4EW3.mjs → chunk-QV6ANL5D.mjs} +209 -156
- package/dist/{chunk-5VWWS4RS.mjs → chunk-TROD5OXC.mjs} +737 -373
- package/dist/{chunk-5OK3IPVN.mjs → chunk-VE6BIQKS.mjs} +1 -1
- package/dist/{chunk-2VS2BST6.mjs → chunk-WH3A7FAR.mjs} +1 -1
- package/dist/{chunk-GIUKL443.mjs → chunk-XLNVCM4Q.mjs} +30 -30
- package/dist/{chunk-6RPYD5IO.mjs → chunk-YE4FXNJW.mjs} +2 -2
- package/dist/{full-65U7W6EN.mjs → full-SYDEKGLJ.mjs} +5 -5
- package/dist/index.css +71 -54
- package/dist/index.d.mts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +1096 -697
- package/dist/index.mjs +17 -10
- package/dist/{loaded-3NNC6Q35.mjs → loaded-5JH76RZT.mjs} +2 -2
- package/dist/{loaded-2CPFB62H.mjs → loaded-NHGZU7V3.mjs} +2 -2
- package/dist/{loaded-GYA4OMNE.mjs → loaded-ON5OAY2P.mjs} +2 -2
- package/dist/no-external.css +71 -54
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +1096 -697
- package/dist/no-external.mjs +17 -10
- package/package.json +1 -1
- package/dist/ObjectField-4SN4ZYFF.mjs +0 -87
- package/dist/chunk-BQW2NTNG.mjs +0 -339
- package/dist/chunk-IRJS3HWQ.mjs +0 -60
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
SubField
|
|
3
|
-
} from "./chunk-IRJS3HWQ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
DragIcon,
|
|
6
|
-
createDynamicCollisionDetector,
|
|
7
|
-
setDeep,
|
|
8
|
-
useSensors
|
|
9
|
-
} from "./chunk-BQW2NTNG.mjs";
|
|
10
|
-
import {
|
|
2
|
+
SubField,
|
|
11
3
|
getDeep,
|
|
12
4
|
useFieldStore,
|
|
13
5
|
useFieldStoreApi,
|
|
14
6
|
useNestedFieldContext
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-2VS2BST6.mjs";
|
|
17
|
-
import "./chunk-AL77I3BV.mjs";
|
|
7
|
+
} from "./chunk-QV6ANL5D.mjs";
|
|
18
8
|
import {
|
|
19
9
|
IconButton
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-LBMMY5IM.mjs";
|
|
22
|
-
import "./chunk-WKMRHPOM.mjs";
|
|
23
|
-
import "./chunk-5OK3IPVN.mjs";
|
|
10
|
+
} from "./chunk-5JSNFZKX.mjs";
|
|
24
11
|
import {
|
|
25
12
|
Copy,
|
|
13
|
+
GripVertical,
|
|
26
14
|
List,
|
|
27
15
|
Plus,
|
|
28
16
|
Trash,
|
|
@@ -30,11 +18,10 @@ import {
|
|
|
30
18
|
replace,
|
|
31
19
|
useAppStore,
|
|
32
20
|
useAppStoreApi
|
|
33
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XLNVCM4Q.mjs";
|
|
34
22
|
import {
|
|
35
23
|
populateIds
|
|
36
24
|
} from "./chunk-64A37UUC.mjs";
|
|
37
|
-
import "./chunk-SMAWAXVX.mjs";
|
|
38
25
|
import {
|
|
39
26
|
get_class_name_factory_default
|
|
40
27
|
} from "./chunk-BFHV72KK.mjs";
|
|
@@ -42,7 +29,6 @@ import {
|
|
|
42
29
|
defaultSlots,
|
|
43
30
|
walkField
|
|
44
31
|
} from "./chunk-7LXZOPYT.mjs";
|
|
45
|
-
import "./chunk-AFVEAZTD.mjs";
|
|
46
32
|
|
|
47
33
|
// css-module:/home/crediblemark/Project/Credibuild/components/AutoField/fields/ArrayField/styles.module.css#css-module
|
|
48
34
|
var styles_module_default = { "ArrayField": "_ArrayField_1q029_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_1q029_13", "ArrayField-addButton": "_ArrayField-addButton_1q029_18", "ArrayField--hasItems": "_ArrayField--hasItems_1q029_33", "ArrayField-inner": "_ArrayField-inner_1q029_59", "ArrayFieldItem": "_ArrayFieldItem_1q029_67", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_1q029_78", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_1q029_82", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_1q029_97", "ArrayFieldItem--noFields": "_ArrayFieldItem--noFields_1q029_122", "ArrayField--addDisabled": "_ArrayField--addDisabled_1q029_131", "ArrayFieldItem-body": "_ArrayFieldItem-body_1q029_170", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_1q029_179", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_1q029_187", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_1q029_193" };
|
|
@@ -54,13 +40,307 @@ import {
|
|
|
54
40
|
useEffect,
|
|
55
41
|
useMemo,
|
|
56
42
|
useRef,
|
|
57
|
-
useState
|
|
43
|
+
useState as useState2
|
|
58
44
|
} from "react";
|
|
59
45
|
|
|
46
|
+
// css-module:/home/crediblemark/Project/Credibuild/components/DragIcon/styles.module.css#css-module
|
|
47
|
+
var styles_module_default2 = { "DragIcon": "_DragIcon_ei1r9_1", "DragIcon--disabled": "_DragIcon--disabled_ei1r9_8" };
|
|
48
|
+
|
|
49
|
+
// components/DragIcon/index.tsx
|
|
50
|
+
import { jsx } from "react/jsx-runtime";
|
|
51
|
+
var getClassName = get_class_name_factory_default("DragIcon", styles_module_default2);
|
|
52
|
+
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ jsx("div", { className: getClassName({ disabled: isDragDisabled }), children: /* @__PURE__ */ jsx(GripVertical, { size: 12, strokeWidth: 2.5 }) });
|
|
53
|
+
|
|
60
54
|
// components/Sortable/index.tsx
|
|
61
55
|
import { DragDropProvider } from "@dnd-kit/react";
|
|
56
|
+
|
|
57
|
+
// lib/dnd/use-sensors.ts
|
|
58
|
+
import { useState } from "react";
|
|
59
|
+
import { PointerSensor } from "@dnd-kit/react";
|
|
60
|
+
import { isElement } from "@dnd-kit/dom/utilities";
|
|
61
|
+
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
62
|
+
var otherDefault = {
|
|
63
|
+
delay: { value: 200, tolerance: 10 },
|
|
64
|
+
distance: { value: 5 }
|
|
65
|
+
};
|
|
66
|
+
var useSensors = ({
|
|
67
|
+
other = otherDefault,
|
|
68
|
+
mouse,
|
|
69
|
+
touch = touchDefault
|
|
70
|
+
} = {
|
|
71
|
+
touch: touchDefault,
|
|
72
|
+
other: otherDefault
|
|
73
|
+
}) => {
|
|
74
|
+
const [sensors] = useState(() => [
|
|
75
|
+
PointerSensor.configure({
|
|
76
|
+
activationConstraints(event, source) {
|
|
77
|
+
const { pointerType, target } = event;
|
|
78
|
+
if (pointerType === "mouse" && isElement(target) && (source.handle === target || source.handle?.contains(target))) {
|
|
79
|
+
return mouse;
|
|
80
|
+
}
|
|
81
|
+
if (pointerType === "touch") {
|
|
82
|
+
return touch;
|
|
83
|
+
}
|
|
84
|
+
return other;
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
]);
|
|
88
|
+
return sensors;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// lib/dnd/collision/dynamic/index.ts
|
|
92
|
+
import {
|
|
93
|
+
CollisionPriority,
|
|
94
|
+
CollisionType as CollisionType2
|
|
95
|
+
} from "@dnd-kit/abstract";
|
|
96
|
+
|
|
97
|
+
// lib/dnd/collision/directional/index.ts
|
|
98
|
+
import { CollisionType } from "@dnd-kit/abstract";
|
|
99
|
+
|
|
100
|
+
// lib/dnd/collision/collision-debug.ts
|
|
101
|
+
var DEBUG = false;
|
|
102
|
+
var debugElements = {};
|
|
103
|
+
var timeout;
|
|
104
|
+
var collisionDebug = (a, b, id, color, label) => {
|
|
105
|
+
if (!DEBUG) return;
|
|
106
|
+
const debugId = `${id}-debug`;
|
|
107
|
+
clearTimeout(timeout);
|
|
108
|
+
timeout = setTimeout(() => {
|
|
109
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
|
110
|
+
svg.remove();
|
|
111
|
+
delete debugElements[id2];
|
|
112
|
+
});
|
|
113
|
+
}, 1e3);
|
|
114
|
+
requestAnimationFrame(() => {
|
|
115
|
+
const existingEl = debugElements[debugId];
|
|
116
|
+
let line = debugElements[debugId]?.line;
|
|
117
|
+
let text = debugElements[debugId]?.text;
|
|
118
|
+
if (!existingEl) {
|
|
119
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
|
120
|
+
const svg = document.createElementNS(svgNs, "svg");
|
|
121
|
+
line = document.createElementNS(svgNs, "line");
|
|
122
|
+
text = document.createElementNS(svgNs, "text");
|
|
123
|
+
svg.setAttribute("id", debugId);
|
|
124
|
+
svg.setAttribute(
|
|
125
|
+
"style",
|
|
126
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
|
|
127
|
+
);
|
|
128
|
+
svg.appendChild(line);
|
|
129
|
+
svg.appendChild(text);
|
|
130
|
+
text.setAttribute("fill", `black`);
|
|
131
|
+
document.body.appendChild(svg);
|
|
132
|
+
debugElements[debugId] = { svg, line, text };
|
|
133
|
+
}
|
|
134
|
+
line.setAttribute("x1", a.x.toString());
|
|
135
|
+
line.setAttribute("x2", b.x.toString());
|
|
136
|
+
line.setAttribute("y1", a.y.toString());
|
|
137
|
+
line.setAttribute("y2", b.y.toString());
|
|
138
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
|
139
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
|
140
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
|
141
|
+
if (label) {
|
|
142
|
+
text.innerHTML = label;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// lib/dnd/collision/directional/index.ts
|
|
148
|
+
var distanceChange = "increasing";
|
|
149
|
+
var directionalCollision = (input, previous) => {
|
|
150
|
+
const { dragOperation, droppable } = input;
|
|
151
|
+
const { shape: dropShape } = droppable;
|
|
152
|
+
const { position } = dragOperation;
|
|
153
|
+
const dragShape = dragOperation.shape?.current;
|
|
154
|
+
if (!dragShape || !dropShape) return null;
|
|
155
|
+
const dropCenter = dropShape.center;
|
|
156
|
+
const distanceToPrevious = Math.sqrt(
|
|
157
|
+
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
|
158
|
+
);
|
|
159
|
+
const distanceToCurrent = Math.sqrt(
|
|
160
|
+
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
|
161
|
+
);
|
|
162
|
+
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
|
163
|
+
collisionDebug(
|
|
164
|
+
dragShape.center,
|
|
165
|
+
dropCenter,
|
|
166
|
+
droppable.id.toString(),
|
|
167
|
+
"rebeccapurple"
|
|
168
|
+
);
|
|
169
|
+
if (distanceChange === "decreasing") {
|
|
170
|
+
return {
|
|
171
|
+
id: droppable.id,
|
|
172
|
+
value: 1,
|
|
173
|
+
type: CollisionType.Collision
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// lib/dnd/collision/dynamic/get-direction.ts
|
|
180
|
+
var getDirection = (dragAxis, delta) => {
|
|
181
|
+
if (dragAxis === "dynamic") {
|
|
182
|
+
if (Math.abs(delta.y) > Math.abs(delta.x)) {
|
|
183
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
|
184
|
+
} else {
|
|
185
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
|
186
|
+
}
|
|
187
|
+
} else if (dragAxis === "x") {
|
|
188
|
+
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
|
189
|
+
}
|
|
190
|
+
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
|
194
|
+
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
|
195
|
+
const dragRect = dragShape.boundingRectangle;
|
|
196
|
+
const dropCenter = dropShape.center;
|
|
197
|
+
if (direction === "down") {
|
|
198
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
|
199
|
+
return dragRect.bottom >= dropCenter.y + offset2;
|
|
200
|
+
} else if (direction === "up") {
|
|
201
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
|
202
|
+
return dragRect.top < dropCenter.y - offset2;
|
|
203
|
+
} else if (direction === "left") {
|
|
204
|
+
const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
|
|
205
|
+
return dropCenter.x - offset2 >= dragRect.left;
|
|
206
|
+
}
|
|
207
|
+
const offset = offsetMultiplier * dropShape.boundingRectangle.width;
|
|
208
|
+
return dragRect.right - offset >= dropCenter.x;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
|
212
|
+
import { Point } from "@dnd-kit/geometry";
|
|
213
|
+
var INTERVAL_SENSITIVITY = 10;
|
|
214
|
+
var intervalCache = {
|
|
215
|
+
current: { x: 0, y: 0 },
|
|
216
|
+
delta: { x: 0, y: 0 },
|
|
217
|
+
previous: { x: 0, y: 0 },
|
|
218
|
+
direction: null
|
|
219
|
+
};
|
|
220
|
+
var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
|
221
|
+
intervalCache.current = point;
|
|
222
|
+
intervalCache.delta = {
|
|
223
|
+
x: point.x - intervalCache.previous.x,
|
|
224
|
+
y: point.y - intervalCache.previous.y
|
|
225
|
+
};
|
|
226
|
+
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
|
227
|
+
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
|
228
|
+
intervalCache.previous = Point.from(point);
|
|
229
|
+
}
|
|
230
|
+
return intervalCache;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// lib/dnd/collision/dynamic/index.ts
|
|
234
|
+
import { closestCorners } from "@dnd-kit/collision";
|
|
235
|
+
|
|
236
|
+
// lib/dnd/collision/dynamic/store.ts
|
|
237
|
+
import { createStore } from "zustand/vanilla";
|
|
238
|
+
var collisionStore = createStore(() => ({
|
|
239
|
+
fallbackEnabled: false
|
|
240
|
+
}));
|
|
241
|
+
|
|
242
|
+
// lib/dnd/collision/dynamic/index.ts
|
|
243
|
+
var flushNext = "";
|
|
244
|
+
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => ((input) => {
|
|
245
|
+
const { dragOperation, droppable } = input;
|
|
246
|
+
const { position } = dragOperation;
|
|
247
|
+
const dragShape = dragOperation.shape?.current;
|
|
248
|
+
const { shape: dropShape } = droppable;
|
|
249
|
+
if (!dragShape || !dropShape) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
const { center: dragCenter } = dragShape;
|
|
253
|
+
const { fallbackEnabled } = collisionStore.getState();
|
|
254
|
+
const interval = trackMovementInterval(position.current, dragAxis);
|
|
255
|
+
const data = {
|
|
256
|
+
direction: interval.direction
|
|
257
|
+
};
|
|
258
|
+
const { center: dropCenter } = dropShape;
|
|
259
|
+
const overMidpoint = getMidpointImpact(
|
|
260
|
+
dragShape,
|
|
261
|
+
dropShape,
|
|
262
|
+
interval.direction,
|
|
263
|
+
midpointOffset
|
|
264
|
+
);
|
|
265
|
+
if (dragOperation.source?.id === droppable.id) {
|
|
266
|
+
const collision = directionalCollision(input, interval.previous);
|
|
267
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
|
268
|
+
if (collision) {
|
|
269
|
+
return {
|
|
270
|
+
...collision,
|
|
271
|
+
priority: CollisionPriority.Highest,
|
|
272
|
+
data
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const intersectionArea = dragShape.intersectionArea(dropShape);
|
|
277
|
+
const intersectionRatio = intersectionArea / dropShape.area;
|
|
278
|
+
if (intersectionArea && overMidpoint) {
|
|
279
|
+
collisionDebug(
|
|
280
|
+
dragCenter,
|
|
281
|
+
dropCenter,
|
|
282
|
+
droppable.id.toString(),
|
|
283
|
+
"green",
|
|
284
|
+
interval.direction
|
|
285
|
+
);
|
|
286
|
+
const collision = {
|
|
287
|
+
id: droppable.id,
|
|
288
|
+
value: intersectionRatio,
|
|
289
|
+
priority: CollisionPriority.High,
|
|
290
|
+
type: CollisionType2.Collision
|
|
291
|
+
};
|
|
292
|
+
const shouldFlushId = flushNext === droppable.id;
|
|
293
|
+
flushNext = "";
|
|
294
|
+
return { ...collision, id: shouldFlushId ? "flush" : collision.id, data };
|
|
295
|
+
}
|
|
296
|
+
if (fallbackEnabled && dragOperation.source?.id !== droppable.id) {
|
|
297
|
+
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
|
298
|
+
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
|
299
|
+
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
|
300
|
+
const fallbackCollision = closestCorners(input);
|
|
301
|
+
if (fallbackCollision) {
|
|
302
|
+
const direction = getDirection(dragAxis, {
|
|
303
|
+
x: dragShape.center.x - (droppable.shape?.center.x || 0),
|
|
304
|
+
y: dragShape.center.y - (droppable.shape?.center.y || 0)
|
|
305
|
+
});
|
|
306
|
+
data.direction = direction;
|
|
307
|
+
if (intersectionArea) {
|
|
308
|
+
collisionDebug(
|
|
309
|
+
dragCenter,
|
|
310
|
+
dropCenter,
|
|
311
|
+
droppable.id.toString(),
|
|
312
|
+
"red",
|
|
313
|
+
direction || ""
|
|
314
|
+
);
|
|
315
|
+
flushNext = droppable.id;
|
|
316
|
+
return {
|
|
317
|
+
...fallbackCollision,
|
|
318
|
+
priority: CollisionPriority.Low,
|
|
319
|
+
data
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
collisionDebug(
|
|
323
|
+
dragCenter,
|
|
324
|
+
dropCenter,
|
|
325
|
+
droppable.id.toString(),
|
|
326
|
+
"orange",
|
|
327
|
+
direction || ""
|
|
328
|
+
);
|
|
329
|
+
return {
|
|
330
|
+
...fallbackCollision,
|
|
331
|
+
priority: CollisionPriority.Lowest,
|
|
332
|
+
data
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
|
338
|
+
return null;
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// components/Sortable/index.tsx
|
|
62
342
|
import { useSortable } from "@dnd-kit/react/sortable";
|
|
63
|
-
import { jsx } from "react/jsx-runtime";
|
|
343
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
64
344
|
var SortableProvider = ({
|
|
65
345
|
children,
|
|
66
346
|
onDragStart,
|
|
@@ -70,7 +350,7 @@ var SortableProvider = ({
|
|
|
70
350
|
const sensors = useSensors({
|
|
71
351
|
mouse: { distance: { value: 5 } }
|
|
72
352
|
});
|
|
73
|
-
return /* @__PURE__ */
|
|
353
|
+
return /* @__PURE__ */ jsx2(
|
|
74
354
|
DragDropProvider,
|
|
75
355
|
{
|
|
76
356
|
sensors,
|
|
@@ -129,9 +409,42 @@ var Sortable = ({
|
|
|
129
409
|
return children({ isDragging, isDropping, ref: sortableRef, handleRef });
|
|
130
410
|
};
|
|
131
411
|
|
|
412
|
+
// lib/data/set-deep.ts
|
|
413
|
+
function setDeep(node, path, newVal) {
|
|
414
|
+
const parts = path.split(".");
|
|
415
|
+
const newNode = { ...node };
|
|
416
|
+
let cur = newNode;
|
|
417
|
+
for (let i = 0; i < parts.length; i++) {
|
|
418
|
+
const [prop, idxStr] = parts[i].replace("]", "").split("[");
|
|
419
|
+
const isLast = i === parts.length - 1;
|
|
420
|
+
if (idxStr !== void 0) {
|
|
421
|
+
if (!Array.isArray(cur[prop])) {
|
|
422
|
+
cur[prop] = [];
|
|
423
|
+
}
|
|
424
|
+
const idx = Number(idxStr);
|
|
425
|
+
if (isLast) {
|
|
426
|
+
cur[prop][idx] = newVal;
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
if (cur[prop][idx] === void 0) cur[prop][idx] = {};
|
|
430
|
+
cur = cur[prop][idx];
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
if (isLast) {
|
|
434
|
+
cur[prop] = newVal;
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
if (cur[prop] === void 0) {
|
|
438
|
+
cur[prop] = {};
|
|
439
|
+
}
|
|
440
|
+
cur = cur[prop];
|
|
441
|
+
}
|
|
442
|
+
return { ...node, ...newNode };
|
|
443
|
+
}
|
|
444
|
+
|
|
132
445
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
133
|
-
import { Fragment, jsx as
|
|
134
|
-
var
|
|
446
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
447
|
+
var getClassName2 = get_class_name_factory_default("ArrayField", styles_module_default);
|
|
135
448
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default);
|
|
136
449
|
var ItemSummaryInner = ({
|
|
137
450
|
index,
|
|
@@ -180,7 +493,7 @@ var ArrayFieldItemInternal = ({
|
|
|
180
493
|
(subField) => subField.type !== "slot" && subField.visible !== false
|
|
181
494
|
);
|
|
182
495
|
}, [field.arrayFields]);
|
|
183
|
-
return /* @__PURE__ */
|
|
496
|
+
return /* @__PURE__ */ jsx3(Sortable, { id, index: dragIndex, disabled: readOnly, children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ jsxs(
|
|
184
497
|
"div",
|
|
185
498
|
{
|
|
186
499
|
ref,
|
|
@@ -203,7 +516,7 @@ var ArrayFieldItemInternal = ({
|
|
|
203
516
|
},
|
|
204
517
|
className: getClassNameItem("summary"),
|
|
205
518
|
children: [
|
|
206
|
-
/* @__PURE__ */
|
|
519
|
+
/* @__PURE__ */ jsx3(
|
|
207
520
|
ItemSummary,
|
|
208
521
|
{
|
|
209
522
|
index,
|
|
@@ -213,15 +526,15 @@ var ArrayFieldItemInternal = ({
|
|
|
213
526
|
}
|
|
214
527
|
),
|
|
215
528
|
/* @__PURE__ */ jsxs("div", { className: getClassNameItem("rhs"), children: [
|
|
216
|
-
!readOnly && /* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */
|
|
529
|
+
!readOnly && /* @__PURE__ */ jsx3("div", { className: getClassNameItem("actions"), children: actions }),
|
|
530
|
+
/* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3(DragIcon, {}) })
|
|
218
531
|
] })
|
|
219
532
|
]
|
|
220
533
|
}
|
|
221
534
|
),
|
|
222
|
-
/* @__PURE__ */
|
|
535
|
+
/* @__PURE__ */ jsx3("div", { className: getClassNameItem("body"), children: isExpanded && hasVisibleFields && /* @__PURE__ */ jsx3("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
|
223
536
|
const subField = field.arrayFields[subName];
|
|
224
|
-
return /* @__PURE__ */
|
|
537
|
+
return /* @__PURE__ */ jsx3(
|
|
225
538
|
SubField,
|
|
226
539
|
{
|
|
227
540
|
id: `${id}_${subName}`,
|
|
@@ -249,7 +562,7 @@ var ArrayField = ({
|
|
|
249
562
|
label,
|
|
250
563
|
labelIcon,
|
|
251
564
|
readOnly,
|
|
252
|
-
Label = (props) => /* @__PURE__ */
|
|
565
|
+
Label = (props) => /* @__PURE__ */ jsx3("div", { ...props })
|
|
253
566
|
}) => {
|
|
254
567
|
const setUi = useAppStore((s) => s.setUi);
|
|
255
568
|
const appStoreApi = useAppStoreApi();
|
|
@@ -316,7 +629,7 @@ var ArrayField = ({
|
|
|
316
629
|
});
|
|
317
630
|
return { ...arrayState, items: newItems };
|
|
318
631
|
}, [getArrayState, getHighestIndex, id]);
|
|
319
|
-
const [draggedItem, setDraggedItem] =
|
|
632
|
+
const [draggedItem, setDraggedItem] = useState2("");
|
|
320
633
|
const isDraggingAny = !!draggedItem;
|
|
321
634
|
const valueRef = useRef([]);
|
|
322
635
|
useEffect(() => {
|
|
@@ -371,14 +684,14 @@ var ArrayField = ({
|
|
|
371
684
|
return null;
|
|
372
685
|
}
|
|
373
686
|
const addDisabled = field.max !== void 0 && mirror?.items.length >= field.max || readOnly;
|
|
374
|
-
return /* @__PURE__ */
|
|
687
|
+
return /* @__PURE__ */ jsx3(
|
|
375
688
|
Label,
|
|
376
689
|
{
|
|
377
690
|
label: label || name,
|
|
378
|
-
icon: labelIcon || /* @__PURE__ */
|
|
691
|
+
icon: labelIcon || /* @__PURE__ */ jsx3(List, { size: 16 }),
|
|
379
692
|
el: "div",
|
|
380
693
|
readOnly,
|
|
381
|
-
children: /* @__PURE__ */
|
|
694
|
+
children: /* @__PURE__ */ jsx3(
|
|
382
695
|
SortableProvider,
|
|
383
696
|
{
|
|
384
697
|
onDragStart: (id2) => {
|
|
@@ -417,18 +730,18 @@ var ArrayField = ({
|
|
|
417
730
|
children: /* @__PURE__ */ jsxs(
|
|
418
731
|
"div",
|
|
419
732
|
{
|
|
420
|
-
className:
|
|
733
|
+
className: getClassName2({
|
|
421
734
|
hasItems: numItems > 0,
|
|
422
735
|
addDisabled
|
|
423
736
|
}),
|
|
424
737
|
children: [
|
|
425
|
-
mirror.items.length > 0 && /* @__PURE__ */
|
|
738
|
+
mirror.items.length > 0 && /* @__PURE__ */ jsx3("div", { className: getClassName2("inner"), "data-dnd-container": true, children: mirror.items.map((item, index) => {
|
|
426
739
|
const {
|
|
427
740
|
_arrayId = `${id}-${index}`,
|
|
428
741
|
_originalIndex = index,
|
|
429
742
|
_currentIndex = index
|
|
430
743
|
} = item;
|
|
431
|
-
return /* @__PURE__ */
|
|
744
|
+
return /* @__PURE__ */ jsx3(
|
|
432
745
|
ArrayFieldItem,
|
|
433
746
|
{
|
|
434
747
|
index: _currentIndex,
|
|
@@ -467,7 +780,7 @@ var ArrayField = ({
|
|
|
467
780
|
}
|
|
468
781
|
},
|
|
469
782
|
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
470
|
-
/* @__PURE__ */
|
|
783
|
+
/* @__PURE__ */ jsx3("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx3(
|
|
471
784
|
IconButton,
|
|
472
785
|
{
|
|
473
786
|
type: "button",
|
|
@@ -481,10 +794,10 @@ var ArrayField = ({
|
|
|
481
794
|
updateValue(existingValue);
|
|
482
795
|
},
|
|
483
796
|
title: "Duplicate",
|
|
484
|
-
children: /* @__PURE__ */
|
|
797
|
+
children: /* @__PURE__ */ jsx3(Copy, { size: 16 })
|
|
485
798
|
}
|
|
486
799
|
) }),
|
|
487
|
-
/* @__PURE__ */
|
|
800
|
+
/* @__PURE__ */ jsx3("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx3(
|
|
488
801
|
IconButton,
|
|
489
802
|
{
|
|
490
803
|
type: "button",
|
|
@@ -497,7 +810,7 @@ var ArrayField = ({
|
|
|
497
810
|
updateValue(existingValue);
|
|
498
811
|
},
|
|
499
812
|
title: "Delete",
|
|
500
|
-
children: /* @__PURE__ */
|
|
813
|
+
children: /* @__PURE__ */ jsx3(Trash, { size: 16 })
|
|
501
814
|
}
|
|
502
815
|
) })
|
|
503
816
|
] })
|
|
@@ -505,11 +818,11 @@ var ArrayField = ({
|
|
|
505
818
|
_arrayId
|
|
506
819
|
);
|
|
507
820
|
}) }),
|
|
508
|
-
!addDisabled && /* @__PURE__ */
|
|
821
|
+
!addDisabled && /* @__PURE__ */ jsx3(
|
|
509
822
|
"button",
|
|
510
823
|
{
|
|
511
824
|
type: "button",
|
|
512
|
-
className:
|
|
825
|
+
className: getClassName2("addButton"),
|
|
513
826
|
onClick: () => {
|
|
514
827
|
if (isDraggingAny) return;
|
|
515
828
|
const value = getValue();
|
|
@@ -522,7 +835,7 @@ var ArrayField = ({
|
|
|
522
835
|
const newValue = [...existingValue, newItem];
|
|
523
836
|
updateValue(newValue);
|
|
524
837
|
},
|
|
525
|
-
children: /* @__PURE__ */
|
|
838
|
+
children: /* @__PURE__ */ jsx3(Plus, { size: 21 })
|
|
526
839
|
}
|
|
527
840
|
)
|
|
528
841
|
]
|
|
@@ -533,6 +846,12 @@ var ArrayField = ({
|
|
|
533
846
|
}
|
|
534
847
|
);
|
|
535
848
|
};
|
|
849
|
+
|
|
536
850
|
export {
|
|
851
|
+
DragIcon,
|
|
852
|
+
useSensors,
|
|
853
|
+
collisionStore,
|
|
854
|
+
createDynamicCollisionDetector,
|
|
855
|
+
setDeep,
|
|
537
856
|
ArrayField
|
|
538
857
|
};
|