@crediblemark/build 0.24.5 → 0.24.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/ArrayField-2QLVE7PT.mjs +19 -0
- package/dist/{ArrayField-ZD5UTLNU.css → ArrayField-LGEHKPX7.css} +50 -33
- package/dist/{Editor-HOZVZZIZ.mjs → Editor-3EPLDK4J.mjs} +7 -7
- package/dist/{ObjectField-SQKROKJM.css → ObjectField-XRKCCMPB.css} +50 -33
- package/dist/ObjectField-XXOU2VP4.mjs +19 -0
- package/dist/{chunk-VBNE6GK2.mjs → chunk-5JSNFZKX.mjs} +7 -7
- package/dist/{chunk-5VWWS4RS.mjs → chunk-AMHAYK37.mjs} +736 -372
- 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-QBCQ7LDT.mjs} +364 -45
- package/dist/chunk-TE6MUUVZ.mjs +92 -0
- package/dist/{chunk-5OK3IPVN.mjs → chunk-VE6BIQKS.mjs} +1 -1
- package/dist/{chunk-H2LU4EW3.mjs → chunk-WDTSUNWU.mjs} +209 -156
- 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 +50 -33
- package/dist/index.d.mts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +1095 -696
- 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 +50 -33
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +1095 -696
- 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
package/dist/no-external.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ColorPickerField,
|
|
2
3
|
CredBuild,
|
|
3
4
|
Drawer,
|
|
4
5
|
DropZone,
|
|
5
6
|
Render,
|
|
7
|
+
ResponsiveSliderField,
|
|
8
|
+
SliderField,
|
|
6
9
|
blocksPlugin,
|
|
7
10
|
createUseCredBuild,
|
|
8
11
|
fieldsPlugin,
|
|
@@ -12,17 +15,18 @@ import {
|
|
|
12
15
|
registerOverlayPortal,
|
|
13
16
|
useCredBuild,
|
|
14
17
|
useGetCredBuild
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-AMHAYK37.mjs";
|
|
19
|
+
import "./chunk-YE4FXNJW.mjs";
|
|
17
20
|
import {
|
|
18
21
|
setDeep
|
|
19
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QBCQ7LDT.mjs";
|
|
23
|
+
import "./chunk-TE6MUUVZ.mjs";
|
|
20
24
|
import {
|
|
21
25
|
AutoField,
|
|
22
26
|
Button,
|
|
23
27
|
FieldLabel
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-WDTSUNWU.mjs";
|
|
29
|
+
import "./chunk-WH3A7FAR.mjs";
|
|
26
30
|
import {
|
|
27
31
|
migrate,
|
|
28
32
|
resolveAllData,
|
|
@@ -37,11 +41,11 @@ import {
|
|
|
37
41
|
Label,
|
|
38
42
|
RichTextMenu,
|
|
39
43
|
Separator
|
|
40
|
-
} from "./chunk-
|
|
41
|
-
import "./chunk-
|
|
42
|
-
import "./chunk-
|
|
43
|
-
import "./chunk-
|
|
44
|
-
import "./chunk-
|
|
44
|
+
} from "./chunk-5JSNFZKX.mjs";
|
|
45
|
+
import "./chunk-MFTVX2ME.mjs";
|
|
46
|
+
import "./chunk-KUWVOWUV.mjs";
|
|
47
|
+
import "./chunk-VE6BIQKS.mjs";
|
|
48
|
+
import "./chunk-XLNVCM4Q.mjs";
|
|
45
49
|
import "./chunk-64A37UUC.mjs";
|
|
46
50
|
import "./chunk-SMAWAXVX.mjs";
|
|
47
51
|
import "./chunk-BFHV72KK.mjs";
|
|
@@ -54,6 +58,7 @@ export {
|
|
|
54
58
|
ActionBar,
|
|
55
59
|
AutoField,
|
|
56
60
|
Button,
|
|
61
|
+
ColorPickerField,
|
|
57
62
|
CredBuild,
|
|
58
63
|
Drawer,
|
|
59
64
|
DropZone,
|
|
@@ -62,8 +67,10 @@ export {
|
|
|
62
67
|
IconButton,
|
|
63
68
|
Label,
|
|
64
69
|
Render,
|
|
70
|
+
ResponsiveSliderField,
|
|
65
71
|
RichTextMenu,
|
|
66
72
|
Separator,
|
|
73
|
+
SliderField,
|
|
67
74
|
blocksPlugin,
|
|
68
75
|
createUseCredBuild,
|
|
69
76
|
fieldsPlugin,
|
package/package.json
CHANGED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SubField
|
|
3
|
-
} from "./chunk-IRJS3HWQ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getDeep,
|
|
6
|
-
useFieldStoreApi,
|
|
7
|
-
useNestedFieldContext
|
|
8
|
-
} from "./chunk-H2LU4EW3.mjs";
|
|
9
|
-
import "./chunk-2VS2BST6.mjs";
|
|
10
|
-
import "./chunk-AL77I3BV.mjs";
|
|
11
|
-
import "./chunk-VBNE6GK2.mjs";
|
|
12
|
-
import "./chunk-LBMMY5IM.mjs";
|
|
13
|
-
import "./chunk-WKMRHPOM.mjs";
|
|
14
|
-
import "./chunk-5OK3IPVN.mjs";
|
|
15
|
-
import {
|
|
16
|
-
EllipsisVertical,
|
|
17
|
-
useAppStore
|
|
18
|
-
} from "./chunk-GIUKL443.mjs";
|
|
19
|
-
import "./chunk-64A37UUC.mjs";
|
|
20
|
-
import "./chunk-SMAWAXVX.mjs";
|
|
21
|
-
import {
|
|
22
|
-
get_class_name_factory_default
|
|
23
|
-
} from "./chunk-BFHV72KK.mjs";
|
|
24
|
-
import "./chunk-7LXZOPYT.mjs";
|
|
25
|
-
import "./chunk-AFVEAZTD.mjs";
|
|
26
|
-
|
|
27
|
-
// css-module:/home/crediblemark/Project/Credibuild/components/AutoField/fields/ObjectField/styles.module.css#css-module
|
|
28
|
-
var styles_module_default = { "ObjectField": "_ObjectField_b2xjm_5", "ObjectField-fieldset": "_ObjectField-fieldset_b2xjm_13" };
|
|
29
|
-
|
|
30
|
-
// components/AutoField/fields/ObjectField/index.tsx
|
|
31
|
-
import { jsx } from "react/jsx-runtime";
|
|
32
|
-
var getClassName = get_class_name_factory_default("ObjectField", styles_module_default);
|
|
33
|
-
var ObjectField = ({
|
|
34
|
-
field,
|
|
35
|
-
onChange,
|
|
36
|
-
id,
|
|
37
|
-
name = id,
|
|
38
|
-
label,
|
|
39
|
-
labelIcon,
|
|
40
|
-
Label,
|
|
41
|
-
readOnly
|
|
42
|
-
}) => {
|
|
43
|
-
const { localName = name } = useNestedFieldContext();
|
|
44
|
-
const fieldStore = useFieldStoreApi();
|
|
45
|
-
const canEdit = useAppStore(
|
|
46
|
-
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
|
47
|
-
);
|
|
48
|
-
const getValue = () => getDeep(fieldStore.getState(), name) ?? {};
|
|
49
|
-
if (field.type !== "object" || !field.objectFields) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return /* @__PURE__ */ jsx(
|
|
53
|
-
Label,
|
|
54
|
-
{
|
|
55
|
-
label: label || name,
|
|
56
|
-
icon: labelIcon || /* @__PURE__ */ jsx(EllipsisVertical, { size: 16 }),
|
|
57
|
-
el: "div",
|
|
58
|
-
readOnly,
|
|
59
|
-
children: /* @__PURE__ */ jsx("div", { className: getClassName(), children: /* @__PURE__ */ jsx("fieldset", { className: getClassName("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
|
60
|
-
const subField = field.objectFields[subName];
|
|
61
|
-
const subPath = `${localName}.${subName}`;
|
|
62
|
-
return /* @__PURE__ */ jsx(
|
|
63
|
-
SubField,
|
|
64
|
-
{
|
|
65
|
-
id: `${id}_${subName}`,
|
|
66
|
-
name,
|
|
67
|
-
subName,
|
|
68
|
-
localName,
|
|
69
|
-
field: subField,
|
|
70
|
-
forceReadOnly: !canEdit,
|
|
71
|
-
onChange: (subValue, ui, subName2) => {
|
|
72
|
-
const value = getValue();
|
|
73
|
-
if (value[subName2] === subValue) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
onChange({ ...value, [subName2]: subValue }, ui);
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
subPath
|
|
80
|
-
);
|
|
81
|
-
}) }) })
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
export {
|
|
86
|
-
ObjectField
|
|
87
|
-
};
|
package/dist/chunk-BQW2NTNG.mjs
DELETED
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GripVertical
|
|
3
|
-
} from "./chunk-GIUKL443.mjs";
|
|
4
|
-
import {
|
|
5
|
-
get_class_name_factory_default
|
|
6
|
-
} from "./chunk-BFHV72KK.mjs";
|
|
7
|
-
|
|
8
|
-
// css-module:/home/crediblemark/Project/Credibuild/components/DragIcon/styles.module.css#css-module
|
|
9
|
-
var styles_module_default = { "DragIcon": "_DragIcon_ei1r9_1", "DragIcon--disabled": "_DragIcon--disabled_ei1r9_8" };
|
|
10
|
-
|
|
11
|
-
// components/DragIcon/index.tsx
|
|
12
|
-
import { jsx } from "react/jsx-runtime";
|
|
13
|
-
var getClassName = get_class_name_factory_default("DragIcon", styles_module_default);
|
|
14
|
-
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ jsx("div", { className: getClassName({ disabled: isDragDisabled }), children: /* @__PURE__ */ jsx(GripVertical, { size: 12, strokeWidth: 2.5 }) });
|
|
15
|
-
|
|
16
|
-
// lib/data/set-deep.ts
|
|
17
|
-
function setDeep(node, path, newVal) {
|
|
18
|
-
const parts = path.split(".");
|
|
19
|
-
const newNode = { ...node };
|
|
20
|
-
let cur = newNode;
|
|
21
|
-
for (let i = 0; i < parts.length; i++) {
|
|
22
|
-
const [prop, idxStr] = parts[i].replace("]", "").split("[");
|
|
23
|
-
const isLast = i === parts.length - 1;
|
|
24
|
-
if (idxStr !== void 0) {
|
|
25
|
-
if (!Array.isArray(cur[prop])) {
|
|
26
|
-
cur[prop] = [];
|
|
27
|
-
}
|
|
28
|
-
const idx = Number(idxStr);
|
|
29
|
-
if (isLast) {
|
|
30
|
-
cur[prop][idx] = newVal;
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if (cur[prop][idx] === void 0) cur[prop][idx] = {};
|
|
34
|
-
cur = cur[prop][idx];
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (isLast) {
|
|
38
|
-
cur[prop] = newVal;
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (cur[prop] === void 0) {
|
|
42
|
-
cur[prop] = {};
|
|
43
|
-
}
|
|
44
|
-
cur = cur[prop];
|
|
45
|
-
}
|
|
46
|
-
return { ...node, ...newNode };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// lib/dnd/use-sensors.ts
|
|
50
|
-
import { useState } from "react";
|
|
51
|
-
import { PointerSensor } from "@dnd-kit/react";
|
|
52
|
-
import { isElement } from "@dnd-kit/dom/utilities";
|
|
53
|
-
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
54
|
-
var otherDefault = {
|
|
55
|
-
delay: { value: 200, tolerance: 10 },
|
|
56
|
-
distance: { value: 5 }
|
|
57
|
-
};
|
|
58
|
-
var useSensors = ({
|
|
59
|
-
other = otherDefault,
|
|
60
|
-
mouse,
|
|
61
|
-
touch = touchDefault
|
|
62
|
-
} = {
|
|
63
|
-
touch: touchDefault,
|
|
64
|
-
other: otherDefault
|
|
65
|
-
}) => {
|
|
66
|
-
const [sensors] = useState(() => [
|
|
67
|
-
PointerSensor.configure({
|
|
68
|
-
activationConstraints(event, source) {
|
|
69
|
-
const { pointerType, target } = event;
|
|
70
|
-
if (pointerType === "mouse" && isElement(target) && (source.handle === target || source.handle?.contains(target))) {
|
|
71
|
-
return mouse;
|
|
72
|
-
}
|
|
73
|
-
if (pointerType === "touch") {
|
|
74
|
-
return touch;
|
|
75
|
-
}
|
|
76
|
-
return other;
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
]);
|
|
80
|
-
return sensors;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// lib/dnd/collision/dynamic/index.ts
|
|
84
|
-
import {
|
|
85
|
-
CollisionPriority,
|
|
86
|
-
CollisionType as CollisionType2
|
|
87
|
-
} from "@dnd-kit/abstract";
|
|
88
|
-
|
|
89
|
-
// lib/dnd/collision/directional/index.ts
|
|
90
|
-
import { CollisionType } from "@dnd-kit/abstract";
|
|
91
|
-
|
|
92
|
-
// lib/dnd/collision/collision-debug.ts
|
|
93
|
-
var DEBUG = false;
|
|
94
|
-
var debugElements = {};
|
|
95
|
-
var timeout;
|
|
96
|
-
var collisionDebug = (a, b, id, color, label) => {
|
|
97
|
-
if (!DEBUG) return;
|
|
98
|
-
const debugId = `${id}-debug`;
|
|
99
|
-
clearTimeout(timeout);
|
|
100
|
-
timeout = setTimeout(() => {
|
|
101
|
-
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
|
102
|
-
svg.remove();
|
|
103
|
-
delete debugElements[id2];
|
|
104
|
-
});
|
|
105
|
-
}, 1e3);
|
|
106
|
-
requestAnimationFrame(() => {
|
|
107
|
-
const existingEl = debugElements[debugId];
|
|
108
|
-
let line = debugElements[debugId]?.line;
|
|
109
|
-
let text = debugElements[debugId]?.text;
|
|
110
|
-
if (!existingEl) {
|
|
111
|
-
const svgNs = "http://www.w3.org/2000/svg";
|
|
112
|
-
const svg = document.createElementNS(svgNs, "svg");
|
|
113
|
-
line = document.createElementNS(svgNs, "line");
|
|
114
|
-
text = document.createElementNS(svgNs, "text");
|
|
115
|
-
svg.setAttribute("id", debugId);
|
|
116
|
-
svg.setAttribute(
|
|
117
|
-
"style",
|
|
118
|
-
"position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
|
|
119
|
-
);
|
|
120
|
-
svg.appendChild(line);
|
|
121
|
-
svg.appendChild(text);
|
|
122
|
-
text.setAttribute("fill", `black`);
|
|
123
|
-
document.body.appendChild(svg);
|
|
124
|
-
debugElements[debugId] = { svg, line, text };
|
|
125
|
-
}
|
|
126
|
-
line.setAttribute("x1", a.x.toString());
|
|
127
|
-
line.setAttribute("x2", b.x.toString());
|
|
128
|
-
line.setAttribute("y1", a.y.toString());
|
|
129
|
-
line.setAttribute("y2", b.y.toString());
|
|
130
|
-
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
|
131
|
-
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
|
132
|
-
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
|
133
|
-
if (label) {
|
|
134
|
-
text.innerHTML = label;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// lib/dnd/collision/directional/index.ts
|
|
140
|
-
var distanceChange = "increasing";
|
|
141
|
-
var directionalCollision = (input, previous) => {
|
|
142
|
-
const { dragOperation, droppable } = input;
|
|
143
|
-
const { shape: dropShape } = droppable;
|
|
144
|
-
const { position } = dragOperation;
|
|
145
|
-
const dragShape = dragOperation.shape?.current;
|
|
146
|
-
if (!dragShape || !dropShape) return null;
|
|
147
|
-
const dropCenter = dropShape.center;
|
|
148
|
-
const distanceToPrevious = Math.sqrt(
|
|
149
|
-
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
|
150
|
-
);
|
|
151
|
-
const distanceToCurrent = Math.sqrt(
|
|
152
|
-
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
|
153
|
-
);
|
|
154
|
-
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
|
155
|
-
collisionDebug(
|
|
156
|
-
dragShape.center,
|
|
157
|
-
dropCenter,
|
|
158
|
-
droppable.id.toString(),
|
|
159
|
-
"rebeccapurple"
|
|
160
|
-
);
|
|
161
|
-
if (distanceChange === "decreasing") {
|
|
162
|
-
return {
|
|
163
|
-
id: droppable.id,
|
|
164
|
-
value: 1,
|
|
165
|
-
type: CollisionType.Collision
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return null;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// lib/dnd/collision/dynamic/get-direction.ts
|
|
172
|
-
var getDirection = (dragAxis, delta) => {
|
|
173
|
-
if (dragAxis === "dynamic") {
|
|
174
|
-
if (Math.abs(delta.y) > Math.abs(delta.x)) {
|
|
175
|
-
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
|
176
|
-
} else {
|
|
177
|
-
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
|
178
|
-
}
|
|
179
|
-
} else if (dragAxis === "x") {
|
|
180
|
-
return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
|
|
181
|
-
}
|
|
182
|
-
return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// lib/dnd/collision/dynamic/get-midpoint-impact.ts
|
|
186
|
-
var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
|
|
187
|
-
const dragRect = dragShape.boundingRectangle;
|
|
188
|
-
const dropCenter = dropShape.center;
|
|
189
|
-
if (direction === "down") {
|
|
190
|
-
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
|
191
|
-
return dragRect.bottom >= dropCenter.y + offset2;
|
|
192
|
-
} else if (direction === "up") {
|
|
193
|
-
const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
|
|
194
|
-
return dragRect.top < dropCenter.y - offset2;
|
|
195
|
-
} else if (direction === "left") {
|
|
196
|
-
const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
|
|
197
|
-
return dropCenter.x - offset2 >= dragRect.left;
|
|
198
|
-
}
|
|
199
|
-
const offset = offsetMultiplier * dropShape.boundingRectangle.width;
|
|
200
|
-
return dragRect.right - offset >= dropCenter.x;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
|
204
|
-
import { Point } from "@dnd-kit/geometry";
|
|
205
|
-
var INTERVAL_SENSITIVITY = 10;
|
|
206
|
-
var intervalCache = {
|
|
207
|
-
current: { x: 0, y: 0 },
|
|
208
|
-
delta: { x: 0, y: 0 },
|
|
209
|
-
previous: { x: 0, y: 0 },
|
|
210
|
-
direction: null
|
|
211
|
-
};
|
|
212
|
-
var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
|
213
|
-
intervalCache.current = point;
|
|
214
|
-
intervalCache.delta = {
|
|
215
|
-
x: point.x - intervalCache.previous.x,
|
|
216
|
-
y: point.y - intervalCache.previous.y
|
|
217
|
-
};
|
|
218
|
-
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
|
219
|
-
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
|
220
|
-
intervalCache.previous = Point.from(point);
|
|
221
|
-
}
|
|
222
|
-
return intervalCache;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
// lib/dnd/collision/dynamic/index.ts
|
|
226
|
-
import { closestCorners } from "@dnd-kit/collision";
|
|
227
|
-
|
|
228
|
-
// lib/dnd/collision/dynamic/store.ts
|
|
229
|
-
import { createStore } from "zustand/vanilla";
|
|
230
|
-
var collisionStore = createStore(() => ({
|
|
231
|
-
fallbackEnabled: false
|
|
232
|
-
}));
|
|
233
|
-
|
|
234
|
-
// lib/dnd/collision/dynamic/index.ts
|
|
235
|
-
var flushNext = "";
|
|
236
|
-
var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => ((input) => {
|
|
237
|
-
const { dragOperation, droppable } = input;
|
|
238
|
-
const { position } = dragOperation;
|
|
239
|
-
const dragShape = dragOperation.shape?.current;
|
|
240
|
-
const { shape: dropShape } = droppable;
|
|
241
|
-
if (!dragShape || !dropShape) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
const { center: dragCenter } = dragShape;
|
|
245
|
-
const { fallbackEnabled } = collisionStore.getState();
|
|
246
|
-
const interval = trackMovementInterval(position.current, dragAxis);
|
|
247
|
-
const data = {
|
|
248
|
-
direction: interval.direction
|
|
249
|
-
};
|
|
250
|
-
const { center: dropCenter } = dropShape;
|
|
251
|
-
const overMidpoint = getMidpointImpact(
|
|
252
|
-
dragShape,
|
|
253
|
-
dropShape,
|
|
254
|
-
interval.direction,
|
|
255
|
-
midpointOffset
|
|
256
|
-
);
|
|
257
|
-
if (dragOperation.source?.id === droppable.id) {
|
|
258
|
-
const collision = directionalCollision(input, interval.previous);
|
|
259
|
-
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
|
260
|
-
if (collision) {
|
|
261
|
-
return {
|
|
262
|
-
...collision,
|
|
263
|
-
priority: CollisionPriority.Highest,
|
|
264
|
-
data
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
const intersectionArea = dragShape.intersectionArea(dropShape);
|
|
269
|
-
const intersectionRatio = intersectionArea / dropShape.area;
|
|
270
|
-
if (intersectionArea && overMidpoint) {
|
|
271
|
-
collisionDebug(
|
|
272
|
-
dragCenter,
|
|
273
|
-
dropCenter,
|
|
274
|
-
droppable.id.toString(),
|
|
275
|
-
"green",
|
|
276
|
-
interval.direction
|
|
277
|
-
);
|
|
278
|
-
const collision = {
|
|
279
|
-
id: droppable.id,
|
|
280
|
-
value: intersectionRatio,
|
|
281
|
-
priority: CollisionPriority.High,
|
|
282
|
-
type: CollisionType2.Collision
|
|
283
|
-
};
|
|
284
|
-
const shouldFlushId = flushNext === droppable.id;
|
|
285
|
-
flushNext = "";
|
|
286
|
-
return { ...collision, id: shouldFlushId ? "flush" : collision.id, data };
|
|
287
|
-
}
|
|
288
|
-
if (fallbackEnabled && dragOperation.source?.id !== droppable.id) {
|
|
289
|
-
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
|
290
|
-
const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
|
|
291
|
-
if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
|
|
292
|
-
const fallbackCollision = closestCorners(input);
|
|
293
|
-
if (fallbackCollision) {
|
|
294
|
-
const direction = getDirection(dragAxis, {
|
|
295
|
-
x: dragShape.center.x - (droppable.shape?.center.x || 0),
|
|
296
|
-
y: dragShape.center.y - (droppable.shape?.center.y || 0)
|
|
297
|
-
});
|
|
298
|
-
data.direction = direction;
|
|
299
|
-
if (intersectionArea) {
|
|
300
|
-
collisionDebug(
|
|
301
|
-
dragCenter,
|
|
302
|
-
dropCenter,
|
|
303
|
-
droppable.id.toString(),
|
|
304
|
-
"red",
|
|
305
|
-
direction || ""
|
|
306
|
-
);
|
|
307
|
-
flushNext = droppable.id;
|
|
308
|
-
return {
|
|
309
|
-
...fallbackCollision,
|
|
310
|
-
priority: CollisionPriority.Low,
|
|
311
|
-
data
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
collisionDebug(
|
|
315
|
-
dragCenter,
|
|
316
|
-
dropCenter,
|
|
317
|
-
droppable.id.toString(),
|
|
318
|
-
"orange",
|
|
319
|
-
direction || ""
|
|
320
|
-
);
|
|
321
|
-
return {
|
|
322
|
-
...fallbackCollision,
|
|
323
|
-
priority: CollisionPriority.Lowest,
|
|
324
|
-
data
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
|
330
|
-
return null;
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
export {
|
|
334
|
-
DragIcon,
|
|
335
|
-
useSensors,
|
|
336
|
-
collisionStore,
|
|
337
|
-
createDynamicCollisionDetector,
|
|
338
|
-
setDeep
|
|
339
|
-
};
|
package/dist/chunk-IRJS3HWQ.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutoFieldPrivate,
|
|
3
|
-
NestedFieldProvider,
|
|
4
|
-
useNestedFieldContext
|
|
5
|
-
} from "./chunk-H2LU4EW3.mjs";
|
|
6
|
-
|
|
7
|
-
// components/AutoField/subfield.tsx
|
|
8
|
-
import { memo } from "react";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
var SubFieldInternal = ({
|
|
11
|
-
field,
|
|
12
|
-
id,
|
|
13
|
-
index,
|
|
14
|
-
name,
|
|
15
|
-
subName,
|
|
16
|
-
localName,
|
|
17
|
-
onChange,
|
|
18
|
-
forceReadOnly
|
|
19
|
-
}) => {
|
|
20
|
-
const indexName = typeof index !== "undefined" ? `${name}[${index}]` : name;
|
|
21
|
-
const subPath = name ? `${indexName}.${subName}` : subName;
|
|
22
|
-
const localIndexName = typeof index !== "undefined" ? `${localName}[${index}]` : localName ?? subName;
|
|
23
|
-
const localWildcardName = typeof index !== "undefined" ? `${localName}[*]` : localName;
|
|
24
|
-
const localSubPath = `${localIndexName}.${subName}`;
|
|
25
|
-
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
|
26
|
-
const { readOnlyFields } = useNestedFieldContext();
|
|
27
|
-
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
|
28
|
-
const label = field.label || subName;
|
|
29
|
-
return /* @__PURE__ */ jsx(
|
|
30
|
-
NestedFieldProvider,
|
|
31
|
-
{
|
|
32
|
-
name: localIndexName,
|
|
33
|
-
wildcardName: localWildcardName,
|
|
34
|
-
subName,
|
|
35
|
-
readOnlyFields,
|
|
36
|
-
children: /* @__PURE__ */ jsx(
|
|
37
|
-
AutoFieldPrivate,
|
|
38
|
-
{
|
|
39
|
-
name: subPath,
|
|
40
|
-
label,
|
|
41
|
-
id,
|
|
42
|
-
readOnly: subReadOnly,
|
|
43
|
-
field: {
|
|
44
|
-
...field,
|
|
45
|
-
label
|
|
46
|
-
// May be used by custom fields
|
|
47
|
-
},
|
|
48
|
-
onChange: (val, ui) => {
|
|
49
|
-
onChange(val, ui, subName);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
var SubField = memo(SubFieldInternal);
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
SubField
|
|
60
|
-
};
|