@floegence/floe-webapp-core 0.36.9 → 0.36.10
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/components/deck/DeckCell.d.ts +3 -1
- package/dist/components/deck/DeckCell.js +28 -26
- package/dist/components/deck/DeckGrid.js +126 -104
- package/dist/components/deck/DropZonePreview.js +15 -15
- package/dist/components/deck/deckGridMetrics.d.ts +15 -0
- package/dist/components/deck/deckGridMetrics.js +35 -15
- package/dist/context/DeckContext.d.ts +14 -1
- package/dist/context/DeckContext.js +187 -174
- package/dist/floe.css +2 -0
- package/dist/hooks/useDeckDrag.js +25 -22
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createSignal as
|
|
2
|
-
import { createStore as
|
|
3
|
-
import { createSimpleContext as
|
|
4
|
-
import { useResolvedFloeConfig as
|
|
5
|
-
import { useWidgetRegistry as
|
|
6
|
-
import { hasCollision as
|
|
7
|
-
function
|
|
1
|
+
import { createSignal as h, createEffect as J, batch as W } from "solid-js";
|
|
2
|
+
import { createStore as N, produce as f, unwrap as Q } from "solid-js/store";
|
|
3
|
+
import { createSimpleContext as U } from "./createSimpleContext.js";
|
|
4
|
+
import { useResolvedFloeConfig as V } from "./FloeConfigContext.js";
|
|
5
|
+
import { useWidgetRegistry as Z } from "./WidgetRegistry.js";
|
|
6
|
+
import { hasCollision as k, sameGridPosition as B, constrainPosition as _, findFreePosition as tt } from "../utils/gridCollision.js";
|
|
7
|
+
function et() {
|
|
8
8
|
const d = Date.now();
|
|
9
9
|
return [{
|
|
10
10
|
id: "preset-default",
|
|
@@ -135,8 +135,8 @@ function Z() {
|
|
|
135
135
|
updatedAt: d
|
|
136
136
|
}];
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
if (!d || d.length === 0) return
|
|
138
|
+
function it(d) {
|
|
139
|
+
if (!d || d.length === 0) return et();
|
|
140
140
|
const m = Date.now();
|
|
141
141
|
return d.map((y) => ({
|
|
142
142
|
id: y.id,
|
|
@@ -154,64 +154,64 @@ function _(d) {
|
|
|
154
154
|
}));
|
|
155
155
|
}
|
|
156
156
|
const {
|
|
157
|
-
Provider:
|
|
158
|
-
use:
|
|
159
|
-
} =
|
|
157
|
+
Provider: ut,
|
|
158
|
+
use: lt
|
|
159
|
+
} = U({
|
|
160
160
|
name: "Deck",
|
|
161
|
-
init:
|
|
161
|
+
init: ot
|
|
162
162
|
});
|
|
163
|
-
function
|
|
164
|
-
const d =
|
|
163
|
+
function ot() {
|
|
164
|
+
const d = V(), m = Z(), y = () => d.config.deck.storageKey, u = (d.config.deck.presetsMode ?? "mutable") === "immutable", L = (t) => {
|
|
165
165
|
try {
|
|
166
166
|
if (t === null || typeof t != "object") return t;
|
|
167
167
|
if (t instanceof Date) return new Date(t.getTime());
|
|
168
|
-
const i =
|
|
168
|
+
const i = Q(t);
|
|
169
169
|
if (typeof structuredClone == "function")
|
|
170
170
|
try {
|
|
171
171
|
return structuredClone(i);
|
|
172
172
|
} catch {
|
|
173
173
|
}
|
|
174
|
-
const
|
|
174
|
+
const o = /* @__PURE__ */ new WeakMap(), a = (e) => {
|
|
175
175
|
if (e === null || typeof e != "object") return e;
|
|
176
176
|
if (e instanceof Date) return new Date(e.getTime());
|
|
177
177
|
if (Array.isArray(e)) {
|
|
178
|
-
const
|
|
178
|
+
const s = new Array(e.length);
|
|
179
179
|
for (let p = 0; p < e.length; p += 1)
|
|
180
|
-
|
|
181
|
-
return
|
|
180
|
+
s[p] = a(e[p]);
|
|
181
|
+
return s;
|
|
182
182
|
}
|
|
183
183
|
if (e instanceof Map) {
|
|
184
|
-
const
|
|
184
|
+
const s = /* @__PURE__ */ new Map();
|
|
185
185
|
for (const [p, P] of e.entries())
|
|
186
|
-
|
|
187
|
-
return
|
|
186
|
+
s.set(a(p), a(P));
|
|
187
|
+
return s;
|
|
188
188
|
}
|
|
189
189
|
if (e instanceof Set) {
|
|
190
|
-
const
|
|
190
|
+
const s = /* @__PURE__ */ new Set();
|
|
191
191
|
for (const p of e.values())
|
|
192
|
-
|
|
193
|
-
return
|
|
192
|
+
s.add(a(p));
|
|
193
|
+
return s;
|
|
194
194
|
}
|
|
195
|
-
if (
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
for (const
|
|
195
|
+
if (o.has(e)) return o.get(e);
|
|
196
|
+
const n = {};
|
|
197
|
+
o.set(e, n);
|
|
198
|
+
for (const s of Object.keys(e))
|
|
199
199
|
try {
|
|
200
|
-
|
|
200
|
+
n[s] = a(e[s]);
|
|
201
201
|
} catch {
|
|
202
202
|
}
|
|
203
|
-
return
|
|
203
|
+
return n;
|
|
204
204
|
};
|
|
205
|
-
return
|
|
205
|
+
return a(i);
|
|
206
206
|
} catch {
|
|
207
207
|
return t;
|
|
208
208
|
}
|
|
209
209
|
}, F = (t) => {
|
|
210
210
|
const i = {};
|
|
211
|
-
for (const
|
|
212
|
-
!
|
|
211
|
+
for (const o of t.widgets ?? [])
|
|
212
|
+
!o?.id || !o.state || (i[o.id] = o.state);
|
|
213
213
|
return i;
|
|
214
|
-
},
|
|
214
|
+
}, C = it(d.config.deck.presets), T = new Set(C.map((t) => t.id)), g = d.persist.load(y(), {}), R = Array.isArray(g.layouts) ? g.layouts : [], j = new Map(R.map((t) => [t.id, t])), E = C.map((t) => {
|
|
215
215
|
const i = j.get(t.id);
|
|
216
216
|
if (!u)
|
|
217
217
|
return i ? {
|
|
@@ -223,79 +223,79 @@ function tt() {
|
|
|
223
223
|
...i,
|
|
224
224
|
isPreset: !1
|
|
225
225
|
} : t;
|
|
226
|
-
const
|
|
226
|
+
const o = (g.presetWidgetStateByLayoutId ?? {})[t.id] ?? {}, e = {
|
|
227
227
|
...i ? F(i) : {},
|
|
228
|
-
...
|
|
228
|
+
...o
|
|
229
229
|
};
|
|
230
230
|
return {
|
|
231
231
|
...t,
|
|
232
|
-
widgets: t.widgets.map((
|
|
233
|
-
...
|
|
234
|
-
state: e[
|
|
232
|
+
widgets: t.widgets.map((n) => ({
|
|
233
|
+
...n,
|
|
234
|
+
state: e[n.id] ? L(e[n.id]) : void 0
|
|
235
235
|
}))
|
|
236
236
|
};
|
|
237
|
-
}), K =
|
|
237
|
+
}), K = R.filter((t) => !t.isPreset && !T.has(t.id)), I = [...E, ...K], x = new Set(I.map((t) => t.id)), $ = g.activeLayoutId && x.has(g.activeLayoutId) ? g.activeLayoutId : d.config.deck.defaultActiveLayoutId && x.has(d.config.deck.defaultActiveLayoutId) ? d.config.deck.defaultActiveLayoutId : I[0]?.id ?? "", G = {
|
|
238
238
|
layouts: I,
|
|
239
239
|
activeLayoutId: $,
|
|
240
240
|
editMode: !1
|
|
241
|
-
}, [r, c] =
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
for (const
|
|
241
|
+
}, [r, c] = N(G), [b, A] = h(null), [O, D] = h(null), [z, M] = h(null), X = (t) => t;
|
|
242
|
+
J(() => {
|
|
243
|
+
X(r.layouts.length);
|
|
244
|
+
for (const a of r.layouts) X(a.updatedAt);
|
|
245
245
|
if (!u) {
|
|
246
|
-
const
|
|
246
|
+
const a = {
|
|
247
247
|
layouts: r.layouts,
|
|
248
248
|
activeLayoutId: r.activeLayoutId
|
|
249
249
|
};
|
|
250
|
-
d.persist.debouncedSave(y(),
|
|
250
|
+
d.persist.debouncedSave(y(), a);
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
253
253
|
const t = {}, i = [];
|
|
254
|
-
for (const
|
|
255
|
-
if (
|
|
254
|
+
for (const a of r.layouts) {
|
|
255
|
+
if (a.isPreset) {
|
|
256
256
|
const e = {};
|
|
257
|
-
for (const
|
|
258
|
-
!
|
|
259
|
-
t[
|
|
257
|
+
for (const n of a.widgets ?? [])
|
|
258
|
+
!n?.id || !n.state || (e[n.id] = n.state);
|
|
259
|
+
t[a.id] = e;
|
|
260
260
|
continue;
|
|
261
261
|
}
|
|
262
|
-
i.push(
|
|
262
|
+
i.push(a);
|
|
263
263
|
}
|
|
264
|
-
const
|
|
264
|
+
const o = {
|
|
265
265
|
layouts: i,
|
|
266
266
|
activeLayoutId: r.activeLayoutId,
|
|
267
267
|
presetWidgetStateByLayoutId: t
|
|
268
268
|
};
|
|
269
|
-
d.persist.debouncedSave(y(),
|
|
269
|
+
d.persist.debouncedSave(y(), o);
|
|
270
270
|
});
|
|
271
|
-
const
|
|
271
|
+
const l = () => r.layouts.find((t) => t.id === r.activeLayoutId), S = () => `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
272
272
|
return {
|
|
273
273
|
// Layout management
|
|
274
274
|
layouts: () => r.layouts,
|
|
275
275
|
activeLayoutId: () => r.activeLayoutId,
|
|
276
|
-
activeLayout:
|
|
276
|
+
activeLayout: l,
|
|
277
277
|
setActiveLayout: (t) => {
|
|
278
|
-
r.layouts.some((i) => i.id === t) && (c("activeLayoutId", t), u && r.layouts.find((
|
|
278
|
+
r.layouts.some((i) => i.id === t) && (c("activeLayoutId", t), u && r.layouts.find((o) => o.id === t)?.isPreset && c("editMode", !1));
|
|
279
279
|
},
|
|
280
280
|
createLayout: (t, i) => {
|
|
281
|
-
const
|
|
281
|
+
const o = {
|
|
282
282
|
id: S(),
|
|
283
283
|
name: t,
|
|
284
284
|
widgets: i ?? [],
|
|
285
285
|
createdAt: Date.now(),
|
|
286
286
|
updatedAt: Date.now()
|
|
287
287
|
};
|
|
288
|
-
return c(
|
|
289
|
-
|
|
290
|
-
})),
|
|
288
|
+
return c(f((a) => {
|
|
289
|
+
a.layouts.push(o), a.activeLayoutId = o.id;
|
|
290
|
+
})), o;
|
|
291
291
|
},
|
|
292
292
|
duplicateLayout: (t, i) => {
|
|
293
|
-
const
|
|
294
|
-
if (!
|
|
295
|
-
const
|
|
293
|
+
const o = r.layouts.find((e) => e.id === t);
|
|
294
|
+
if (!o) return;
|
|
295
|
+
const a = {
|
|
296
296
|
id: S(),
|
|
297
297
|
name: i,
|
|
298
|
-
widgets:
|
|
298
|
+
widgets: o.widgets.map((e) => ({
|
|
299
299
|
...e,
|
|
300
300
|
id: S(),
|
|
301
301
|
position: {
|
|
@@ -307,199 +307,212 @@ function tt() {
|
|
|
307
307
|
createdAt: Date.now(),
|
|
308
308
|
updatedAt: Date.now()
|
|
309
309
|
};
|
|
310
|
-
return c(
|
|
311
|
-
e.layouts.push(
|
|
312
|
-
})),
|
|
310
|
+
return c(f((e) => {
|
|
311
|
+
e.layouts.push(a), e.activeLayoutId = a.id;
|
|
312
|
+
})), a;
|
|
313
313
|
},
|
|
314
314
|
deleteLayout: (t) => {
|
|
315
|
-
const i = r.layouts.find((
|
|
316
|
-
!i || i.isPreset || c(
|
|
317
|
-
const
|
|
318
|
-
|
|
315
|
+
const i = r.layouts.find((o) => o.id === t);
|
|
316
|
+
!i || i.isPreset || c(f((o) => {
|
|
317
|
+
const a = o.layouts.findIndex((e) => e.id === t);
|
|
318
|
+
a !== -1 && (o.layouts.splice(a, 1), o.activeLayoutId === t && (o.activeLayoutId = o.layouts[0]?.id ?? ""));
|
|
319
319
|
}));
|
|
320
320
|
},
|
|
321
321
|
renameLayout: (t, i) => {
|
|
322
|
-
const
|
|
323
|
-
!
|
|
324
|
-
const e =
|
|
322
|
+
const o = r.layouts.find((a) => a.id === t);
|
|
323
|
+
!o || o.isPreset || c(f((a) => {
|
|
324
|
+
const e = a.layouts.find((n) => n.id === t);
|
|
325
325
|
e && (e.name = i, e.updatedAt = Date.now());
|
|
326
326
|
}));
|
|
327
327
|
},
|
|
328
328
|
// Edit mode
|
|
329
329
|
editMode: () => r.editMode,
|
|
330
330
|
setEditMode: (t) => {
|
|
331
|
-
t && u &&
|
|
331
|
+
t && u && l()?.isPreset || c("editMode", t);
|
|
332
332
|
},
|
|
333
333
|
toggleEditMode: () => {
|
|
334
|
-
!r.editMode && u &&
|
|
334
|
+
!r.editMode && u && l()?.isPreset || c("editMode", !r.editMode);
|
|
335
335
|
},
|
|
336
336
|
// Widget management
|
|
337
|
-
addWidget: (t, i,
|
|
338
|
-
const
|
|
339
|
-
if (!
|
|
340
|
-
const e = m.getWidget(t),
|
|
337
|
+
addWidget: (t, i, o) => {
|
|
338
|
+
const a = l();
|
|
339
|
+
if (!a || u && a.isPreset) return;
|
|
340
|
+
const e = m.getWidget(t), n = {
|
|
341
341
|
minColSpan: e?.minColSpan ?? 2,
|
|
342
342
|
minRowSpan: e?.minRowSpan ?? 2
|
|
343
|
-
},
|
|
344
|
-
colSpan: i?.colSpan ?? e?.defaultColSpan ?? Math.max(
|
|
345
|
-
rowSpan: i?.rowSpan ?? e?.defaultRowSpan ?? Math.max(
|
|
346
|
-
}, p = i?.col !== void 0 && i?.row !== void 0 ?
|
|
347
|
-
...
|
|
343
|
+
}, s = {
|
|
344
|
+
colSpan: i?.colSpan ?? e?.defaultColSpan ?? Math.max(n.minColSpan, 4),
|
|
345
|
+
rowSpan: i?.rowSpan ?? e?.defaultRowSpan ?? Math.max(n.minRowSpan, 3)
|
|
346
|
+
}, p = i?.col !== void 0 && i?.row !== void 0 ? _({
|
|
347
|
+
...s,
|
|
348
348
|
col: i.col,
|
|
349
349
|
row: i.row
|
|
350
|
-
},
|
|
350
|
+
}, n.minColSpan, n.minRowSpan) : tt(a.widgets, s.colSpan, s.rowSpan), P = S(), q = {
|
|
351
351
|
id: P,
|
|
352
352
|
type: t,
|
|
353
353
|
position: p,
|
|
354
|
-
config:
|
|
354
|
+
config: o
|
|
355
355
|
};
|
|
356
|
-
return c(
|
|
357
|
-
const v =
|
|
358
|
-
v && (v.widgets.push(
|
|
356
|
+
return c(f((Y) => {
|
|
357
|
+
const v = Y.layouts.find((H) => H.id === Y.activeLayoutId);
|
|
358
|
+
v && (v.widgets.push(q), v.updatedAt = Date.now());
|
|
359
359
|
})), P;
|
|
360
360
|
},
|
|
361
361
|
removeWidget: (t) => {
|
|
362
|
-
const i =
|
|
363
|
-
u && i?.isPreset || c(
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
366
|
-
const e =
|
|
367
|
-
e !== -1 && (
|
|
362
|
+
const i = l();
|
|
363
|
+
u && i?.isPreset || c(f((o) => {
|
|
364
|
+
const a = o.layouts.find((e) => e.id === o.activeLayoutId);
|
|
365
|
+
if (a) {
|
|
366
|
+
const e = a.widgets.findIndex((n) => n.id === t);
|
|
367
|
+
e !== -1 && (a.widgets.splice(e, 1), a.updatedAt = Date.now());
|
|
368
368
|
}
|
|
369
369
|
}));
|
|
370
370
|
},
|
|
371
371
|
updateWidgetPosition: (t, i) => {
|
|
372
|
-
const
|
|
373
|
-
u &&
|
|
374
|
-
const e =
|
|
372
|
+
const o = l();
|
|
373
|
+
u && o?.isPreset || c(f((a) => {
|
|
374
|
+
const e = a.layouts.find((n) => n.id === a.activeLayoutId);
|
|
375
375
|
if (e) {
|
|
376
|
-
const
|
|
377
|
-
|
|
376
|
+
const n = e.widgets.find((s) => s.id === t);
|
|
377
|
+
n && (k(i, e.widgets, t) || (n.position = i, e.updatedAt = Date.now()));
|
|
378
378
|
}
|
|
379
379
|
}));
|
|
380
380
|
},
|
|
381
381
|
updateWidgetConfig: (t, i) => {
|
|
382
|
-
const
|
|
383
|
-
u &&
|
|
384
|
-
const e =
|
|
382
|
+
const o = l();
|
|
383
|
+
u && o?.isPreset || c(f((a) => {
|
|
384
|
+
const e = a.layouts.find((n) => n.id === a.activeLayoutId);
|
|
385
385
|
if (e) {
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
...
|
|
386
|
+
const n = e.widgets.find((s) => s.id === t);
|
|
387
|
+
n && (n.config = {
|
|
388
|
+
...n.config,
|
|
389
389
|
...i
|
|
390
390
|
}, e.updatedAt = Date.now());
|
|
391
391
|
}
|
|
392
392
|
}));
|
|
393
393
|
},
|
|
394
394
|
updateWidgetTitle: (t, i) => {
|
|
395
|
-
const
|
|
396
|
-
u &&
|
|
397
|
-
const e =
|
|
395
|
+
const o = l();
|
|
396
|
+
u && o?.isPreset || c(f((a) => {
|
|
397
|
+
const e = a.layouts.find((n) => n.id === a.activeLayoutId);
|
|
398
398
|
if (e) {
|
|
399
|
-
const
|
|
400
|
-
|
|
399
|
+
const n = e.widgets.find((s) => s.id === t);
|
|
400
|
+
n && (n.title = i, e.updatedAt = Date.now());
|
|
401
401
|
}
|
|
402
402
|
}));
|
|
403
403
|
},
|
|
404
404
|
changeWidgetType: (t, i) => {
|
|
405
|
-
const
|
|
406
|
-
u &&
|
|
407
|
-
const e =
|
|
405
|
+
const o = l();
|
|
406
|
+
u && o?.isPreset || c(f((a) => {
|
|
407
|
+
const e = a.layouts.find((n) => n.id === a.activeLayoutId);
|
|
408
408
|
if (e) {
|
|
409
|
-
const
|
|
410
|
-
|
|
409
|
+
const n = e.widgets.find((s) => s.id === t);
|
|
410
|
+
n && (n.type = i, n.config = void 0, n.title = void 0, n.state = void 0, e.updatedAt = Date.now());
|
|
411
411
|
}
|
|
412
412
|
}));
|
|
413
413
|
},
|
|
414
|
-
updateWidgetState: (t, i,
|
|
415
|
-
c(
|
|
416
|
-
const e =
|
|
414
|
+
updateWidgetState: (t, i, o) => {
|
|
415
|
+
c(f((a) => {
|
|
416
|
+
const e = a.layouts.find((n) => n.id === a.activeLayoutId);
|
|
417
417
|
if (e) {
|
|
418
|
-
const
|
|
419
|
-
|
|
418
|
+
const n = e.widgets.find((s) => s.id === t);
|
|
419
|
+
n && (n.state || (n.state = {}), n.state[i] = o, e.updatedAt = Date.now());
|
|
420
420
|
}
|
|
421
421
|
}));
|
|
422
422
|
},
|
|
423
|
-
getWidgetState: (t) =>
|
|
423
|
+
getWidgetState: (t) => l()?.widgets.find((a) => a.id === t)?.state ?? {},
|
|
424
424
|
// Drag state
|
|
425
|
-
dragState:
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
e
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
425
|
+
dragState: b,
|
|
426
|
+
dragMotion: O,
|
|
427
|
+
startDrag: (t, i, o) => {
|
|
428
|
+
const a = l();
|
|
429
|
+
if (u && a?.isPreset) return;
|
|
430
|
+
const e = a?.widgets.find((n) => n.id === t);
|
|
431
|
+
e && W(() => {
|
|
432
|
+
A({
|
|
433
|
+
widgetId: t,
|
|
434
|
+
originalPosition: {
|
|
435
|
+
...e.position
|
|
436
|
+
},
|
|
437
|
+
currentPosition: {
|
|
438
|
+
...e.position
|
|
439
|
+
},
|
|
440
|
+
startX: i,
|
|
441
|
+
startY: o
|
|
442
|
+
}), D({
|
|
443
|
+
widgetId: t,
|
|
444
|
+
deltaX: 0,
|
|
445
|
+
deltaY: 0
|
|
446
|
+
});
|
|
440
447
|
});
|
|
441
448
|
},
|
|
442
|
-
updateDrag: (t) => {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
449
|
+
updateDrag: (t, i) => {
|
|
450
|
+
W(() => {
|
|
451
|
+
D((o) => !o || o.deltaX === i.deltaX && o.deltaY === i.deltaY ? o : {
|
|
452
|
+
...o,
|
|
453
|
+
deltaX: i.deltaX,
|
|
454
|
+
deltaY: i.deltaY
|
|
455
|
+
}), A((o) => !o || B(o.currentPosition, t) ? o : {
|
|
456
|
+
...o,
|
|
457
|
+
currentPosition: t
|
|
458
|
+
});
|
|
446
459
|
});
|
|
447
460
|
},
|
|
448
461
|
endDrag: (t) => {
|
|
449
|
-
const i =
|
|
450
|
-
|
|
462
|
+
const i = b();
|
|
463
|
+
i && W(() => {
|
|
451
464
|
if (t) {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
const e =
|
|
465
|
+
const o = l();
|
|
466
|
+
o && !(u && o.isPreset) && !k(i.currentPosition, o.widgets, i.widgetId) && c(f((a) => {
|
|
467
|
+
const e = a.layouts.find((n) => n.id === a.activeLayoutId);
|
|
455
468
|
if (e) {
|
|
456
|
-
const
|
|
457
|
-
|
|
469
|
+
const n = e.widgets.find((s) => s.id === i.widgetId);
|
|
470
|
+
n && (n.position = i.currentPosition, e.updatedAt = Date.now());
|
|
458
471
|
}
|
|
459
472
|
}));
|
|
460
473
|
}
|
|
461
|
-
A(null);
|
|
462
|
-
}
|
|
474
|
+
A(null), D(null);
|
|
475
|
+
});
|
|
463
476
|
},
|
|
464
477
|
// Resize state
|
|
465
|
-
resizeState:
|
|
466
|
-
startResize: (t, i,
|
|
467
|
-
const e =
|
|
478
|
+
resizeState: z,
|
|
479
|
+
startResize: (t, i, o, a) => {
|
|
480
|
+
const e = l();
|
|
468
481
|
if (u && e?.isPreset) return;
|
|
469
|
-
const
|
|
470
|
-
|
|
482
|
+
const n = e?.widgets.find((s) => s.id === t);
|
|
483
|
+
n && M({
|
|
471
484
|
widgetId: t,
|
|
472
485
|
edge: i,
|
|
473
486
|
originalPosition: {
|
|
474
|
-
...
|
|
487
|
+
...n.position
|
|
475
488
|
},
|
|
476
489
|
currentPosition: {
|
|
477
|
-
...
|
|
490
|
+
...n.position
|
|
478
491
|
},
|
|
479
|
-
startX:
|
|
480
|
-
startY:
|
|
492
|
+
startX: o,
|
|
493
|
+
startY: a
|
|
481
494
|
});
|
|
482
495
|
},
|
|
483
496
|
updateResize: (t) => {
|
|
484
|
-
|
|
497
|
+
M((i) => !i || B(i.currentPosition, t) ? i : {
|
|
485
498
|
...i,
|
|
486
499
|
currentPosition: t
|
|
487
500
|
});
|
|
488
501
|
},
|
|
489
502
|
endResize: (t) => {
|
|
490
|
-
const i =
|
|
503
|
+
const i = z();
|
|
491
504
|
if (i) {
|
|
492
505
|
if (t) {
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
const e =
|
|
506
|
+
const o = l();
|
|
507
|
+
o && !(u && o.isPreset) && !k(i.currentPosition, o.widgets, i.widgetId) && c(f((a) => {
|
|
508
|
+
const e = a.layouts.find((n) => n.id === a.activeLayoutId);
|
|
496
509
|
if (e) {
|
|
497
|
-
const
|
|
498
|
-
|
|
510
|
+
const n = e.widgets.find((s) => s.id === i.widgetId);
|
|
511
|
+
n && (n.position = i.currentPosition, e.updatedAt = Date.now());
|
|
499
512
|
}
|
|
500
513
|
}));
|
|
501
514
|
}
|
|
502
|
-
|
|
515
|
+
M(null);
|
|
503
516
|
}
|
|
504
517
|
},
|
|
505
518
|
// Utilities
|
|
@@ -513,7 +526,7 @@ function tt() {
|
|
|
513
526
|
};
|
|
514
527
|
}
|
|
515
528
|
export {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
529
|
+
ut as DeckProvider,
|
|
530
|
+
ot as createDeckService,
|
|
531
|
+
lt as useDeck
|
|
519
532
|
};
|
package/dist/floe.css
CHANGED
|
@@ -414,7 +414,9 @@
|
|
|
414
414
|
[data-floe-hot-interaction~='resize'] [data-floe-geometry-surface='shell-sidebar'],
|
|
415
415
|
[data-floe-hot-interaction~='resize'] [data-floe-geometry-surface='sidebar-pane'],
|
|
416
416
|
[data-floe-hot-interaction~='resize'] [data-floe-geometry-surface='floating-window'],
|
|
417
|
+
[data-floe-hot-interaction~='resize'] [data-floe-geometry-surface='deck-widget'],
|
|
417
418
|
[data-floe-hot-interaction~='drag'] [data-floe-geometry-surface='floating-window'],
|
|
419
|
+
[data-floe-hot-interaction~='drag'] [data-floe-geometry-surface='deck-widget'],
|
|
418
420
|
[data-floe-hot-interaction~='drag'] [data-floe-geometry-surface='notes-note'],
|
|
419
421
|
[data-floe-hot-interaction~='drag'] [data-floe-geometry-surface='notes-note'] .notes-note__surface {
|
|
420
422
|
animation: none !important;
|
|
@@ -1,48 +1,51 @@
|
|
|
1
|
-
import { createEffect as
|
|
1
|
+
import { createEffect as m, onCleanup as E } from "solid-js";
|
|
2
2
|
import { useDeck as h } from "../context/DeckContext.js";
|
|
3
3
|
import { applyDragDelta as k } from "../utils/gridLayout.js";
|
|
4
4
|
import { startDeckPointerSession as y } from "../components/deck/deckPointerSession.js";
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
let i = null, l = null,
|
|
8
|
-
const s = (
|
|
9
|
-
i?.stop({ commit:
|
|
10
|
-
}, u = (
|
|
11
|
-
const a =
|
|
12
|
-
if (!a || a.closest('button, input, select, textarea, [role="button"], a') || a.closest("[data-widget-resize-handle]") ||
|
|
5
|
+
function L() {
|
|
6
|
+
const o = h();
|
|
7
|
+
let i = null, l = null, r = null;
|
|
8
|
+
const s = (e) => {
|
|
9
|
+
i?.stop({ commit: e }), i = null, l = null, r = null;
|
|
10
|
+
}, u = (e) => {
|
|
11
|
+
const a = e.target;
|
|
12
|
+
if (!a || a.closest('button, input, select, textarea, [role="button"], a') || a.closest("[data-widget-resize-handle]") || e.pointerType === "mouse" && e.button !== 0) return;
|
|
13
13
|
const d = a.closest("[data-widget-drag-handle]");
|
|
14
14
|
if (!d) return;
|
|
15
15
|
const n = d.dataset.widgetDragHandle;
|
|
16
16
|
if (!n) return;
|
|
17
17
|
const c = d.closest(".deck-grid");
|
|
18
18
|
if (!c) return;
|
|
19
|
-
const g =
|
|
19
|
+
const g = o.activeLayout()?.widgets.find((t) => t.id === n);
|
|
20
20
|
if (!g) return;
|
|
21
|
-
|
|
22
|
-
const p =
|
|
23
|
-
!p || p.widgetId !== n || (l = n,
|
|
21
|
+
e.preventDefault(), e.stopPropagation(), s(!1), o.startDrag(n, e.clientX, e.clientY);
|
|
22
|
+
const p = o.dragState();
|
|
23
|
+
!p || p.widgetId !== n || (l = n, r = { ...g.position }, i = y({
|
|
24
24
|
kind: "drag",
|
|
25
25
|
widgetId: n,
|
|
26
26
|
gridEl: c,
|
|
27
27
|
captureEl: d,
|
|
28
|
-
pointerEvent:
|
|
28
|
+
pointerEvent: e,
|
|
29
29
|
cursor: "grabbing",
|
|
30
|
-
onMove: (
|
|
31
|
-
if (!l || !
|
|
32
|
-
const f = Math.round(
|
|
33
|
-
|
|
30
|
+
onMove: (t) => {
|
|
31
|
+
if (!l || !r) return;
|
|
32
|
+
const f = Math.round(t.deltaX / t.cellWidth), D = Math.round(t.deltaY / t.cellHeight), w = k(r, f, D, t.cols);
|
|
33
|
+
o.updateDrag(w, {
|
|
34
|
+
deltaX: t.deltaX,
|
|
35
|
+
deltaY: t.deltaY
|
|
36
|
+
});
|
|
34
37
|
},
|
|
35
|
-
onEnd: ({ commit:
|
|
36
|
-
i = null, l = null,
|
|
38
|
+
onEnd: ({ commit: t }) => {
|
|
39
|
+
i = null, l = null, r = null, o.endDrag(t);
|
|
37
40
|
}
|
|
38
41
|
}));
|
|
39
42
|
};
|
|
40
|
-
|
|
43
|
+
m(() => {
|
|
41
44
|
typeof document > "u" || (document.addEventListener("pointerdown", u, !0), E(() => {
|
|
42
45
|
s(!1), document.removeEventListener("pointerdown", u, !0);
|
|
43
46
|
}));
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
export {
|
|
47
|
-
|
|
50
|
+
L as useDeckDrag
|
|
48
51
|
};
|