@joewinke/jatui 0.2.11 → 0.2.13
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/actions/attention.js +21 -13
- package/dist/actions/collapse.js +15 -29
- package/dist/actions/floating.js +29 -37
- package/dist/actions/listNav.js +108 -137
- package/dist/actions/railNav.js +72 -89
- package/dist/actions/staggerEntrance.js +19 -23
- package/dist/actions/tooltip.js +63 -51
- package/dist/assets/sounds/error.js +1 -1
- package/dist/assets/sounds/notify.js +1 -1
- package/dist/assets/sounds/pop.js +1 -1
- package/dist/assets/sounds/send.js +1 -1
- package/dist/assets/sounds/success.js +1 -1
- package/dist/assets/sounds/toggle.js +1 -1
- package/dist/components/graph/theme.js +26 -36
- package/dist/components/markup.js +59 -62
- package/dist/components/session-nav/transcriptModel.js +49 -66
- package/dist/components/shell/shell.js +14 -15
- package/dist/components/table/flexRender.js +2 -2
- package/dist/data/emojis.js +4 -4
- package/dist/dnd/autoScroll.js +10 -12
- package/dist/dnd/createDndBoard.js +104 -184
- package/dist/dnd/draggable.js +15 -23
- package/dist/dnd/dropTarget.js +15 -29
- package/dist/dnd/types.d.ts +9 -0
- package/dist/dnd/types.js +2 -14
- package/dist/showcase/generative/intent.js +19 -21
- package/dist/showcase/generative/manifest.js +27 -80
- package/dist/showcase/scroll/scrollProgress.js +20 -22
- package/dist/showcase/scroll/scrollReveal.js +17 -20
- package/dist/stores/commandPalette.js +18 -46
- package/dist/stores/confirmDialog.js +9 -9
- package/dist/stores/inputDialog.js +9 -9
- package/dist/stores/toast.js +10 -33
- package/dist/transitions/glide.js +29 -25
- package/dist/types/booking.js +4 -4
- package/dist/types/comments.js +2 -2
- package/dist/types/messaging.js +3 -3
- package/dist/types/pipeline.js +2 -2
- package/dist/utils/currency.js +2 -4
- package/dist/utils/daisyuiColors.js +25 -27
- package/dist/utils/dateFormatters.js +44 -44
- package/dist/utils/googleMapsLoader.js +46 -100
- package/dist/utils/mentionParser.js +30 -30
- package/dist/utils/phone.js +21 -27
- package/dist/utils/phoneFormat.js +9 -9
- package/dist/utils/sound.js +27 -78
- package/dist/utils/splitText.js +15 -26
- package/dist/utils/taskUtils.js +1 -1
- package/dist/utils/themeWipe.js +27 -72
- package/dist/utils/viewTransition.js +6 -51
- package/package.json +7 -3
- package/dist/dnd/createDndBoard.test.d.ts +0 -1
- package/dist/dnd/createDndBoard.test.js +0 -261
|
@@ -1,48 +1,39 @@
|
|
|
1
1
|
/* createDndBoard.svelte.js generated by Svelte v5.53.11 */
|
|
2
2
|
import * as $ from 'svelte/internal/client';
|
|
3
|
-
|
|
4
|
-
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
5
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
6
|
-
if (ar || !(i in from)) {
|
|
7
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
8
|
-
|
|
9
|
-
ar[i] = from[i];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
3
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
17
4
|
import { extractClosestEdge, attachClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
18
5
|
import { SvelteMap } from 'svelte/reactivity';
|
|
19
6
|
import { announce } from './announce';
|
|
20
7
|
import { makeItemData, isItemData } from './types';
|
|
21
8
|
|
|
22
|
-
|
|
9
|
+
const SHADOW_KEY = '__dnd-shadow__';
|
|
23
10
|
|
|
24
11
|
export function createDndBoard(opts) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var seedQueued = false;
|
|
12
|
+
const edges = opts.edges ?? ['top', 'bottom'];
|
|
13
|
+
const hover = opts.hover ?? 'indicator';
|
|
14
|
+
const mirror = new SvelteMap();
|
|
15
|
+
let dragging = $.state(null);
|
|
16
|
+
let proposal = $.state(null);
|
|
17
|
+
const seq = new Map();
|
|
18
|
+
let inFlight = 0;
|
|
19
|
+
let seedQueued = false;
|
|
34
20
|
|
|
35
21
|
function seed() {
|
|
36
22
|
mirror.clear();
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
var entries = src instanceof Map ? src : new Map(Object.entries(src));
|
|
24
|
+
const src = opts.items();
|
|
40
25
|
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
// Iterate a real ARRAY, never a Map/iterator directly. This module is
|
|
27
|
+
// downlevelled by the package build (svelte-package emits ES5-ish output:
|
|
28
|
+
// `for…of` becomes a `.length`-indexed loop and `[...iterable]` becomes
|
|
29
|
+
// `Array.prototype.slice.call`). Those transforms are correct for arrays
|
|
30
|
+
// but SILENTLY WRONG for Maps/iterators (`Map.length` is undefined → the
|
|
31
|
+
// loop never runs; slice on an iterator returns []). Iterating a Map here
|
|
32
|
+
// left the render mirror permanently empty → every board rendered blank.
|
|
33
|
+
// `Array.from(map)` is a runtime call, so it survives the downlevel intact.
|
|
34
|
+
const entries = src instanceof Map ? Array.from(src) : Object.entries(src);
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
}
|
|
36
|
+
for (const [id, list] of entries) mirror.set(id, [...list]);
|
|
46
37
|
}
|
|
47
38
|
|
|
48
39
|
// Seed synchronously at creation so the render mirror is populated for the very
|
|
@@ -56,10 +47,10 @@ export function createDndBoard(opts) {
|
|
|
56
47
|
// user_effect with no active reaction → effect_orphan (a 500 on any page that
|
|
57
48
|
// server-renders a board). The synchronous seed above covers the SSR render.
|
|
58
49
|
if (typeof window !== 'undefined') {
|
|
59
|
-
$.user_effect(
|
|
50
|
+
$.user_effect(() => {
|
|
60
51
|
opts.items();
|
|
61
52
|
|
|
62
|
-
if ($.
|
|
53
|
+
if ($.get(dragging) || inFlight > 0) {
|
|
63
54
|
seedQueued = true;
|
|
64
55
|
|
|
65
56
|
return;
|
|
@@ -70,61 +61,52 @@ export function createDndBoard(opts) {
|
|
|
70
61
|
}
|
|
71
62
|
|
|
72
63
|
function placementFrom(dropTargets) {
|
|
73
|
-
|
|
74
|
-
var inner = dropTargets[0];
|
|
64
|
+
const inner = dropTargets[0];
|
|
75
65
|
|
|
76
66
|
if (!inner) return null;
|
|
77
67
|
|
|
78
|
-
|
|
68
|
+
const d = inner.data;
|
|
79
69
|
|
|
80
70
|
if (typeof d.container !== 'string') return null;
|
|
81
71
|
|
|
82
|
-
|
|
72
|
+
const list = mirror.get(d.container) ?? [];
|
|
83
73
|
|
|
84
74
|
if (typeof d.index !== 'number') return { container: d.container, index: list.length };
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
const edge = extractClosestEdge(d);
|
|
77
|
+
const after = edge === 'bottom' || edge === 'right';
|
|
88
78
|
|
|
89
79
|
return { container: d.container, index: d.index + (after ? 1 : 0) };
|
|
90
80
|
}
|
|
91
81
|
|
|
92
82
|
function syncShadow(next) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for (var _i = 0, mirror_1 = mirror; _i < mirror_1.length; _i++) {
|
|
97
|
-
var _c = mirror_1[_i], cid = _c[0], list_1 = _c[1];
|
|
98
|
-
|
|
99
|
-
var idx = list_1.findIndex(function (item) {
|
|
100
|
-
return item[SHADOW_KEY];
|
|
101
|
-
});
|
|
83
|
+
// Array.from — never iterate the SvelteMap directly (downlevel breaks it; see seed()).
|
|
84
|
+
for (const [cid, list] of Array.from(mirror)) {
|
|
85
|
+
const idx = list.findIndex((item) => item[SHADOW_KEY]);
|
|
102
86
|
|
|
103
87
|
if (idx !== -1) {
|
|
104
|
-
|
|
105
|
-
mirror.set(cid,
|
|
88
|
+
list.splice(idx, 1);
|
|
89
|
+
mirror.set(cid, list);
|
|
106
90
|
|
|
107
91
|
break;
|
|
108
92
|
}
|
|
109
93
|
}
|
|
110
94
|
|
|
111
|
-
if (!next || !$.
|
|
95
|
+
if (!next || !$.get(dragging)) return;
|
|
112
96
|
|
|
113
|
-
|
|
97
|
+
const list = [...mirror.get(next.container) ?? []];
|
|
114
98
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
_a
|
|
120
|
-
);
|
|
99
|
+
const shadowItem = {
|
|
100
|
+
[SHADOW_KEY]: true,
|
|
101
|
+
key: `${SHADOW_KEY}-${$.get(dragging).key}`
|
|
102
|
+
};
|
|
121
103
|
|
|
122
104
|
list.splice(Math.min(next.index, list.length), 0, shadowItem);
|
|
123
105
|
mirror.set(next.container, list);
|
|
124
106
|
}
|
|
125
107
|
|
|
126
108
|
function consider(next) {
|
|
127
|
-
if (
|
|
109
|
+
if (next?.container === $.get(proposal)?.container && next?.index === $.get(proposal)?.index) return;
|
|
128
110
|
|
|
129
111
|
$.set(proposal, next, true);
|
|
130
112
|
|
|
@@ -132,22 +114,15 @@ export function createDndBoard(opts) {
|
|
|
132
114
|
}
|
|
133
115
|
|
|
134
116
|
function applyToMirror(move) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
var toList = move.from.container === move.to.container
|
|
139
|
-
? fromList
|
|
140
|
-
: __spreadArray([], (_b = mirror.get(move.to.container)) !== null && _b !== void 0 ? _b : [], true);
|
|
141
|
-
|
|
142
|
-
var srcIdx = fromList.findIndex(function (it) {
|
|
143
|
-
return opts.key(it) === opts.key(move.item);
|
|
144
|
-
});
|
|
117
|
+
const fromList = [...mirror.get(move.from.container) ?? []];
|
|
118
|
+
const toList = move.from.container === move.to.container ? fromList : [...mirror.get(move.to.container) ?? []];
|
|
119
|
+
const srcIdx = fromList.findIndex((it) => opts.key(it) === opts.key(move.item));
|
|
145
120
|
|
|
146
121
|
if (srcIdx === -1) return;
|
|
147
122
|
|
|
148
123
|
fromList.splice(srcIdx, 1);
|
|
149
124
|
|
|
150
|
-
|
|
125
|
+
let destIdx = move.to.index;
|
|
151
126
|
|
|
152
127
|
if (move.from.container === move.to.container && move.to.index > move.from.index) {
|
|
153
128
|
destIdx = Math.max(0, destIdx - 1);
|
|
@@ -162,14 +137,9 @@ export function createDndBoard(opts) {
|
|
|
162
137
|
}
|
|
163
138
|
|
|
164
139
|
function rollback(move) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
var _b = mirror_2[_i], cid = _b[0], list = _b[1];
|
|
169
|
-
|
|
170
|
-
var idx = list.findIndex(function (it) {
|
|
171
|
-
return opts.key(it) === opts.key(move.item);
|
|
172
|
-
});
|
|
140
|
+
// Array.from — never iterate the SvelteMap directly (downlevel breaks it; see seed()).
|
|
141
|
+
for (const [cid, list] of Array.from(mirror)) {
|
|
142
|
+
const idx = list.findIndex((it) => opts.key(it) === opts.key(move.item));
|
|
173
143
|
|
|
174
144
|
if (idx !== -1) {
|
|
175
145
|
list.splice(idx, 1);
|
|
@@ -179,16 +149,15 @@ export function createDndBoard(opts) {
|
|
|
179
149
|
}
|
|
180
150
|
}
|
|
181
151
|
|
|
182
|
-
|
|
152
|
+
const fromList = [...mirror.get(move.from.container) ?? []];
|
|
183
153
|
|
|
184
154
|
fromList.splice(Math.min(move.from.index, fromList.length), 0, move.item);
|
|
185
155
|
mirror.set(move.from.container, fromList);
|
|
186
156
|
}
|
|
187
157
|
|
|
188
158
|
function finalize(dropped) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var to = dropped ? $.safe_get(proposal) : null;
|
|
159
|
+
const drag = $.get(dragging);
|
|
160
|
+
const to = dropped ? $.get(proposal) : null;
|
|
192
161
|
|
|
193
162
|
$.set(dragging, null);
|
|
194
163
|
consider(null);
|
|
@@ -204,27 +173,25 @@ export function createDndBoard(opts) {
|
|
|
204
173
|
return;
|
|
205
174
|
}
|
|
206
175
|
|
|
207
|
-
|
|
176
|
+
const move = { item: drag.item, from: drag.from, to };
|
|
208
177
|
|
|
209
178
|
applyToMirror(move);
|
|
210
179
|
|
|
211
180
|
if (opts.announce) announce(opts.announce(move));
|
|
212
181
|
|
|
213
|
-
|
|
182
|
+
const token = (seq.get(drag.key) ?? 0) + 1;
|
|
214
183
|
|
|
215
184
|
seq.set(drag.key, token);
|
|
216
185
|
inFlight++;
|
|
217
186
|
|
|
218
|
-
opts.commit(move).catch(
|
|
219
|
-
var _a;
|
|
220
|
-
|
|
187
|
+
opts.commit(move).catch((error) => {
|
|
221
188
|
if (seq.get(drag.key) === token) rollback(move);
|
|
222
189
|
|
|
223
|
-
|
|
224
|
-
}).finally(
|
|
190
|
+
opts.onError?.(error, move);
|
|
191
|
+
}).finally(() => {
|
|
225
192
|
inFlight--;
|
|
226
193
|
|
|
227
|
-
if (inFlight === 0 && seedQueued && !$.
|
|
194
|
+
if (inFlight === 0 && seedQueued && !$.get(dragging)) {
|
|
228
195
|
seedQueued = false;
|
|
229
196
|
seed();
|
|
230
197
|
}
|
|
@@ -233,111 +200,64 @@ export function createDndBoard(opts) {
|
|
|
233
200
|
|
|
234
201
|
// Drag monitor — CLIENT ONLY (same effect_orphan reason as the seed effect;
|
|
235
202
|
// monitorForElements also needs the DOM, which does not exist during SSR).
|
|
236
|
-
if (typeof window !== 'undefined') $.user_effect(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
{
|
|
251
|
-
key: d.key,
|
|
252
|
-
item: d.item,
|
|
253
|
-
from: { container: d.container, index: d.index }
|
|
254
|
-
},
|
|
255
|
-
true
|
|
256
|
-
);
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
onDropTargetChange(_a) {
|
|
260
|
-
var location = _a.location;
|
|
261
|
-
|
|
262
|
-
consider(placementFrom(location.current.dropTargets));
|
|
263
|
-
},
|
|
264
|
-
|
|
265
|
-
onDrag(_a) {
|
|
266
|
-
var location = _a.location;
|
|
267
|
-
|
|
268
|
-
consider(placementFrom(location.current.dropTargets));
|
|
269
|
-
},
|
|
270
|
-
|
|
271
|
-
onDrop(_a) {
|
|
272
|
-
var location = _a.location;
|
|
273
|
-
|
|
274
|
-
finalize(location.current.dropTargets.length > 0);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
return {
|
|
280
|
-
get(container) {
|
|
281
|
-
var _a;
|
|
282
|
-
|
|
283
|
-
return (_a = mirror.get(container)) !== null && _a !== void 0 ? _a : [];
|
|
284
|
-
},
|
|
285
|
-
|
|
286
|
-
containers() {
|
|
287
|
-
return __spreadArray([], mirror.keys(), true);
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
get dragging() {
|
|
291
|
-
return $.safe_get(dragging);
|
|
203
|
+
if (typeof window !== 'undefined') $.user_effect(() => monitorForElements({
|
|
204
|
+
canMonitor: ({ source }) => isItemData(source.data, opts.type),
|
|
205
|
+
onDragStart({ source }) {
|
|
206
|
+
const d = source.data;
|
|
207
|
+
|
|
208
|
+
$.set(
|
|
209
|
+
dragging,
|
|
210
|
+
{
|
|
211
|
+
key: d.key,
|
|
212
|
+
item: d.item,
|
|
213
|
+
from: { container: d.container, index: d.index }
|
|
214
|
+
},
|
|
215
|
+
true
|
|
216
|
+
);
|
|
292
217
|
},
|
|
293
218
|
|
|
294
|
-
|
|
295
|
-
|
|
219
|
+
onDropTargetChange({ location }) {
|
|
220
|
+
consider(placementFrom(location.current.dropTargets));
|
|
296
221
|
},
|
|
297
222
|
|
|
298
|
-
|
|
299
|
-
|
|
223
|
+
onDrag({ location }) {
|
|
224
|
+
consider(placementFrom(location.current.dropTargets));
|
|
300
225
|
},
|
|
301
226
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
227
|
+
onDrop({ location }) {
|
|
228
|
+
finalize(location.current.dropTargets.length > 0);
|
|
229
|
+
}
|
|
230
|
+
}));
|
|
305
231
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
};
|
|
232
|
+
return {
|
|
233
|
+
get: (container) => mirror.get(container) ?? [],
|
|
234
|
+
containers: () => Array.from(mirror.keys()),
|
|
235
|
+
get dragging() {
|
|
236
|
+
return $.get(dragging);
|
|
312
237
|
},
|
|
313
238
|
|
|
314
|
-
|
|
315
|
-
return
|
|
316
|
-
data(feedback) {
|
|
317
|
-
return attachClosestEdge({ type: ("").concat(opts.type, "-target"), container, index }, {
|
|
318
|
-
input: feedback.input,
|
|
319
|
-
element: feedback.element,
|
|
320
|
-
allowedEdges: edges
|
|
321
|
-
});
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
accepts(d) {
|
|
325
|
-
return isItemData(d, opts.type);
|
|
326
|
-
},
|
|
327
|
-
sticky: true
|
|
328
|
-
};
|
|
239
|
+
get proposal() {
|
|
240
|
+
return $.get(proposal);
|
|
329
241
|
},
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
242
|
+
isSource: (item) => $.get(dragging)?.key === opts.key(item),
|
|
243
|
+
isShadow: (item) => !!item[SHADOW_KEY],
|
|
244
|
+
item: (item, container, index) => ({
|
|
245
|
+
data: () => makeItemData({ type: opts.type, key: opts.key(item), item, container, index })
|
|
246
|
+
}),
|
|
247
|
+
|
|
248
|
+
itemTarget: (container, index) => ({
|
|
249
|
+
data: (feedback) => attachClosestEdge({ type: `${opts.type}-target`, container, index }, {
|
|
250
|
+
input: feedback.input,
|
|
251
|
+
element: feedback.element,
|
|
252
|
+
allowedEdges: edges
|
|
253
|
+
}),
|
|
254
|
+
accepts: (d) => isItemData(d, opts.type),
|
|
255
|
+
sticky: true
|
|
256
|
+
}),
|
|
257
|
+
|
|
258
|
+
containerTarget: (container) => ({
|
|
259
|
+
data: () => ({ type: `${opts.type}-target`, container }),
|
|
260
|
+
accepts: (d) => isItemData(d, opts.type)
|
|
261
|
+
})
|
|
342
262
|
};
|
|
343
263
|
}
|
package/dist/dnd/draggable.js
CHANGED
|
@@ -1,50 +1,42 @@
|
|
|
1
1
|
import { draggable as registerDraggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
2
2
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const draggable = ((node, params) => {
|
|
4
|
+
let current = params;
|
|
5
|
+
let cleanup;
|
|
6
6
|
function register() {
|
|
7
7
|
cleanup = registerDraggable({
|
|
8
8
|
element: node,
|
|
9
9
|
dragHandle: current.dragHandle,
|
|
10
|
-
canDrag:
|
|
11
|
-
getInitialData:
|
|
12
|
-
onGenerateDragPreview
|
|
13
|
-
var source = _a.source, nativeSetDragImage = _a.nativeSetDragImage;
|
|
10
|
+
canDrag: () => !(current.disabled?.() ?? false),
|
|
11
|
+
getInitialData: () => current.data(),
|
|
12
|
+
onGenerateDragPreview({ source, nativeSetDragImage }) {
|
|
14
13
|
if (!current.preview)
|
|
15
14
|
return;
|
|
16
15
|
setCustomNativeDragPreview({
|
|
17
|
-
render:
|
|
18
|
-
|
|
19
|
-
return current.preview(container, source.data);
|
|
20
|
-
},
|
|
21
|
-
nativeSetDragImage: nativeSetDragImage,
|
|
16
|
+
render: ({ container }) => current.preview(container, source.data),
|
|
17
|
+
nativeSetDragImage,
|
|
22
18
|
});
|
|
23
19
|
},
|
|
24
|
-
onDragStart
|
|
25
|
-
var _b;
|
|
26
|
-
var source = _a.source;
|
|
20
|
+
onDragStart({ source }) {
|
|
27
21
|
node.dataset.dragging = 'true';
|
|
28
|
-
|
|
22
|
+
current.onDragStart?.(source.data);
|
|
29
23
|
},
|
|
30
|
-
onDrop
|
|
31
|
-
var _b;
|
|
32
|
-
var source = _a.source;
|
|
24
|
+
onDrop({ source }) {
|
|
33
25
|
delete node.dataset.dragging;
|
|
34
|
-
|
|
26
|
+
current.onDrop?.(source.data);
|
|
35
27
|
},
|
|
36
28
|
});
|
|
37
29
|
}
|
|
38
30
|
register();
|
|
39
31
|
return {
|
|
40
|
-
update
|
|
41
|
-
|
|
32
|
+
update(next) {
|
|
33
|
+
const handleChanged = next.dragHandle !== current.dragHandle;
|
|
42
34
|
current = next;
|
|
43
35
|
if (handleChanged) {
|
|
44
36
|
cleanup();
|
|
45
37
|
register();
|
|
46
38
|
}
|
|
47
39
|
},
|
|
48
|
-
destroy:
|
|
40
|
+
destroy: () => cleanup(),
|
|
49
41
|
};
|
|
50
42
|
});
|
package/dist/dnd/dropTarget.js
CHANGED
|
@@ -1,43 +1,29 @@
|
|
|
1
1
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export const dropTarget = ((node, params) => {
|
|
3
|
+
let current = params;
|
|
4
|
+
const cleanup = dropTargetForElements({
|
|
5
5
|
element: node,
|
|
6
|
-
getData:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
canDrop: function (_a) {
|
|
11
|
-
var _b, _c;
|
|
12
|
-
var source = _a.source;
|
|
13
|
-
return (_c = (_b = current.accepts) === null || _b === void 0 ? void 0 : _b.call(current, source.data)) !== null && _c !== void 0 ? _c : true;
|
|
14
|
-
},
|
|
15
|
-
getIsSticky: function () { var _a; return (_a = current.sticky) !== null && _a !== void 0 ? _a : false; },
|
|
16
|
-
onDragEnter: function (_a) {
|
|
17
|
-
var _b;
|
|
18
|
-
var source = _a.source;
|
|
6
|
+
getData: ({ input, element, source }) => current.data({ input, element, source }),
|
|
7
|
+
canDrop: ({ source }) => current.accepts?.(source.data) ?? true,
|
|
8
|
+
getIsSticky: () => current.sticky ?? false,
|
|
9
|
+
onDragEnter({ source }) {
|
|
19
10
|
node.dataset.dropOver = 'true';
|
|
20
|
-
|
|
11
|
+
current.onEnter?.(source.data);
|
|
21
12
|
},
|
|
22
|
-
onDragLeave
|
|
23
|
-
var _a;
|
|
13
|
+
onDragLeave() {
|
|
24
14
|
delete node.dataset.dropOver;
|
|
25
|
-
|
|
15
|
+
current.onLeave?.();
|
|
26
16
|
},
|
|
27
|
-
onDrag
|
|
28
|
-
|
|
29
|
-
var self = _a.self, source = _a.source;
|
|
30
|
-
(_b = current.onMove) === null || _b === void 0 ? void 0 : _b.call(current, self.data, source.data);
|
|
17
|
+
onDrag({ self, source }) {
|
|
18
|
+
current.onMove?.(self.data, source.data);
|
|
31
19
|
},
|
|
32
|
-
onDrop
|
|
33
|
-
var _b;
|
|
34
|
-
var self = _a.self, source = _a.source;
|
|
20
|
+
onDrop({ self, source }) {
|
|
35
21
|
delete node.dataset.dropOver;
|
|
36
|
-
|
|
22
|
+
current.onDropped?.(self.data, source.data);
|
|
37
23
|
},
|
|
38
24
|
});
|
|
39
25
|
return {
|
|
40
|
-
update
|
|
26
|
+
update(next) {
|
|
41
27
|
current = next;
|
|
42
28
|
},
|
|
43
29
|
destroy: cleanup,
|
package/dist/dnd/types.d.ts
CHANGED
|
@@ -2,7 +2,16 @@ import type { Input } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
|
2
2
|
export interface DragData extends Record<string | symbol, unknown> {
|
|
3
3
|
readonly type: string;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* Module-scoped Symbol brand for board-managed items.
|
|
7
|
+
* ⚠ Symbol identity = module identity. Two copies of this module on one page makes
|
|
8
|
+
* isItemData() return false across the boundary — dnd/ must exist EXACTLY ONCE.
|
|
9
|
+
* Declare all @atlaskit/pragmatic-drag-and-drop* packages as peerDependencies in
|
|
10
|
+
* the host app (host owns the single instance).
|
|
11
|
+
*/
|
|
12
|
+
declare const ITEM: unique symbol;
|
|
5
13
|
export interface ItemDragData<TItem = unknown> extends DragData {
|
|
14
|
+
readonly [ITEM]: true;
|
|
6
15
|
readonly key: string;
|
|
7
16
|
readonly item: TItem;
|
|
8
17
|
readonly container: string;
|
package/dist/dnd/types.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
/**
|
|
13
2
|
* Module-scoped Symbol brand for board-managed items.
|
|
14
3
|
* ⚠ Symbol identity = module identity. Two copies of this module on one page makes
|
|
@@ -16,10 +5,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
16
5
|
* Declare all @atlaskit/pragmatic-drag-and-drop* packages as peerDependencies in
|
|
17
6
|
* the host app (host owns the single instance).
|
|
18
7
|
*/
|
|
19
|
-
|
|
8
|
+
const ITEM = Symbol('jatui-dnd-item');
|
|
20
9
|
export function makeItemData(args) {
|
|
21
|
-
|
|
22
|
-
return __assign(__assign({}, args), (_a = {}, _a[ITEM] = true, _a));
|
|
10
|
+
return { ...args, [ITEM]: true };
|
|
23
11
|
}
|
|
24
12
|
export function isItemData(data, type) {
|
|
25
13
|
return data[ITEM] === true && (type === undefined || data.type === type);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const INTENTS_KEY = 'jatui-gen-intents';
|
|
2
2
|
/**
|
|
3
3
|
* Standard ratio buckets, ordered widest to tallest.
|
|
4
4
|
* quantizeRatio maps a measured w×h to the nearest bucket.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const RATIO_BUCKETS = [
|
|
7
7
|
{ label: '21:9', value: 21 / 9 },
|
|
8
8
|
{ label: '16:9', value: 16 / 9 },
|
|
9
9
|
{ label: '3:2', value: 3 / 2 },
|
|
@@ -15,12 +15,11 @@ var RATIO_BUCKETS = [
|
|
|
15
15
|
export function quantizeRatio(w, h) {
|
|
16
16
|
if (h === 0)
|
|
17
17
|
return '16:9';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
for (
|
|
22
|
-
|
|
23
|
-
var diff = Math.abs(ratio - bucket.value);
|
|
18
|
+
const ratio = w / h;
|
|
19
|
+
let nearest = RATIO_BUCKETS[0];
|
|
20
|
+
let minDiff = Math.abs(ratio - nearest.value);
|
|
21
|
+
for (const bucket of RATIO_BUCKETS) {
|
|
22
|
+
const diff = Math.abs(ratio - bucket.value);
|
|
24
23
|
if (diff < minDiff) {
|
|
25
24
|
minDiff = diff;
|
|
26
25
|
nearest = bucket;
|
|
@@ -34,34 +33,33 @@ export function quantizeRatio(w, h) {
|
|
|
34
33
|
* No-ops in production or when localStorage is unavailable (SSR).
|
|
35
34
|
*/
|
|
36
35
|
export function recordIntent(assetId, el) {
|
|
37
|
-
var _a;
|
|
38
36
|
if (typeof import.meta === 'undefined')
|
|
39
37
|
return;
|
|
40
|
-
if (!
|
|
38
|
+
if (!import.meta.env?.DEV)
|
|
41
39
|
return;
|
|
42
40
|
if (typeof localStorage === 'undefined')
|
|
43
41
|
return;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
existing[assetId] = { assetId
|
|
42
|
+
const rect = el.getBoundingClientRect();
|
|
43
|
+
const w = Math.round(rect.width) || el.offsetWidth;
|
|
44
|
+
const h = Math.round(rect.height) || el.offsetHeight;
|
|
45
|
+
const ratioBucket = quantizeRatio(w, h);
|
|
46
|
+
const intent = new Date().toISOString();
|
|
47
|
+
const existing = readIntents();
|
|
48
|
+
existing[assetId] = { assetId, measuredW: w, measuredH: h, ratioBucket, intent };
|
|
51
49
|
try {
|
|
52
50
|
localStorage.setItem(INTENTS_KEY, JSON.stringify(existing));
|
|
53
51
|
}
|
|
54
|
-
catch
|
|
52
|
+
catch {
|
|
55
53
|
// localStorage full — silently skip
|
|
56
54
|
}
|
|
57
|
-
console.info(
|
|
55
|
+
console.info(`[jatui-gen] no manifest for "${assetId}" — intent recorded (${w}×${h}, ${ratioBucket}). Run: jatui-gen fulfill`);
|
|
58
56
|
}
|
|
59
57
|
function readIntents() {
|
|
60
58
|
try {
|
|
61
|
-
|
|
59
|
+
const raw = localStorage.getItem(INTENTS_KEY);
|
|
62
60
|
return raw ? JSON.parse(raw) : {};
|
|
63
61
|
}
|
|
64
|
-
catch
|
|
62
|
+
catch {
|
|
65
63
|
return {};
|
|
66
64
|
}
|
|
67
65
|
}
|