@floegence/floe-webapp-core 0.2.1 → 0.2.2
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/index58.js +57 -55
- package/package.json +1 -1
package/dist/index58.js
CHANGED
|
@@ -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 A, constrainPosition as
|
|
7
|
-
function
|
|
1
|
+
import { createSignal as x, createEffect as B } from "solid-js";
|
|
2
|
+
import { createStore as q, produce as c } from "solid-js/store";
|
|
3
|
+
import { createSimpleContext as G } from "./index50.js";
|
|
4
|
+
import { useResolvedFloeConfig as H } from "./index51.js";
|
|
5
|
+
import { useWidgetRegistry as J } from "./index57.js";
|
|
6
|
+
import { hasCollision as A, constrainPosition as N, findFreePosition as Q } from "./index72.js";
|
|
7
|
+
function U() {
|
|
8
8
|
const d = Date.now();
|
|
9
9
|
return [{
|
|
10
10
|
id: "preset-default",
|
|
@@ -135,8 +135,8 @@ function Q() {
|
|
|
135
135
|
updatedAt: d
|
|
136
136
|
}];
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
if (!d || d.length === 0) return
|
|
138
|
+
function V(d) {
|
|
139
|
+
if (!d || d.length === 0) return U();
|
|
140
140
|
const w = Date.now();
|
|
141
141
|
return d.map((p) => ({
|
|
142
142
|
id: p.id,
|
|
@@ -154,33 +154,35 @@ function U(d) {
|
|
|
154
154
|
}));
|
|
155
155
|
}
|
|
156
156
|
const {
|
|
157
|
-
Provider:
|
|
158
|
-
use:
|
|
159
|
-
} =
|
|
157
|
+
Provider: ot,
|
|
158
|
+
use: nt
|
|
159
|
+
} = G({
|
|
160
160
|
name: "Deck",
|
|
161
|
-
init:
|
|
161
|
+
init: X
|
|
162
162
|
});
|
|
163
|
-
function
|
|
164
|
-
var
|
|
165
|
-
const d =
|
|
166
|
-
const e =
|
|
163
|
+
function X() {
|
|
164
|
+
var h;
|
|
165
|
+
const d = H(), w = J(), p = () => d.config.deck.storageKey, l = V(d.config.deck.presets), z = new Set(l.map((t) => t.id)), y = d.persist.load(p(), {}), D = y.layouts ?? [], b = new Map(D.map((t) => [t.id, t])), E = l.map((t) => {
|
|
166
|
+
const e = b.get(t.id);
|
|
167
167
|
return e ? {
|
|
168
168
|
...e,
|
|
169
169
|
isPreset: t.isPreset
|
|
170
170
|
} : t;
|
|
171
|
-
}),
|
|
171
|
+
}), F = D.filter((t) => !t.isPreset && !z.has(t.id)), S = [...E, ...F], P = new Set(S.map((t) => t.id)), T = y.activeLayoutId && P.has(y.activeLayoutId) ? y.activeLayoutId : d.config.deck.defaultActiveLayoutId && P.has(d.config.deck.defaultActiveLayoutId) ? d.config.deck.defaultActiveLayoutId : ((h = S[0]) == null ? void 0 : h.id) ?? "", j = {
|
|
172
172
|
layouts: S,
|
|
173
|
-
activeLayoutId:
|
|
173
|
+
activeLayoutId: T,
|
|
174
174
|
editMode: !1
|
|
175
|
-
}, [
|
|
176
|
-
|
|
175
|
+
}, [r, s] = q(j), [C, v] = x(null), [M, L] = x(null), R = (t) => t;
|
|
176
|
+
B(() => {
|
|
177
|
+
R(r.layouts.length);
|
|
178
|
+
for (const e of r.layouts) R(e.updatedAt);
|
|
177
179
|
const t = {
|
|
178
|
-
layouts:
|
|
179
|
-
activeLayoutId:
|
|
180
|
+
layouts: r.layouts,
|
|
181
|
+
activeLayoutId: r.activeLayoutId
|
|
180
182
|
};
|
|
181
183
|
d.persist.debouncedSave(p(), t);
|
|
182
184
|
});
|
|
183
|
-
const f = () =>
|
|
185
|
+
const f = () => r.layouts.find((t) => t.id === r.activeLayoutId), g = () => `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, m = (t) => {
|
|
184
186
|
if (typeof structuredClone == "function") return structuredClone(t);
|
|
185
187
|
if (t === null || typeof t != "object") return t;
|
|
186
188
|
if (t instanceof Date) return new Date(t.getTime());
|
|
@@ -192,11 +194,11 @@ function V() {
|
|
|
192
194
|
};
|
|
193
195
|
return {
|
|
194
196
|
// Layout management
|
|
195
|
-
layouts: () =>
|
|
196
|
-
activeLayoutId: () =>
|
|
197
|
+
layouts: () => r.layouts,
|
|
198
|
+
activeLayoutId: () => r.activeLayoutId,
|
|
197
199
|
activeLayout: f,
|
|
198
200
|
setActiveLayout: (t) => {
|
|
199
|
-
|
|
201
|
+
r.layouts.some((e) => e.id === t) && s("activeLayoutId", t);
|
|
200
202
|
},
|
|
201
203
|
createLayout: (t, e) => {
|
|
202
204
|
const o = {
|
|
@@ -206,12 +208,12 @@ function V() {
|
|
|
206
208
|
createdAt: Date.now(),
|
|
207
209
|
updatedAt: Date.now()
|
|
208
210
|
};
|
|
209
|
-
return s(
|
|
211
|
+
return s(c((n) => {
|
|
210
212
|
n.layouts.push(o), n.activeLayoutId = o.id;
|
|
211
213
|
})), o;
|
|
212
214
|
},
|
|
213
215
|
duplicateLayout: (t, e) => {
|
|
214
|
-
const o =
|
|
216
|
+
const o = r.layouts.find((i) => i.id === t);
|
|
215
217
|
if (!o) return;
|
|
216
218
|
const n = {
|
|
217
219
|
id: g(),
|
|
@@ -228,29 +230,29 @@ function V() {
|
|
|
228
230
|
createdAt: Date.now(),
|
|
229
231
|
updatedAt: Date.now()
|
|
230
232
|
};
|
|
231
|
-
return s(
|
|
233
|
+
return s(c((i) => {
|
|
232
234
|
i.layouts.push(n), i.activeLayoutId = n.id;
|
|
233
235
|
})), n;
|
|
234
236
|
},
|
|
235
237
|
deleteLayout: (t) => {
|
|
236
|
-
const e =
|
|
237
|
-
!e || e.isPreset || s(
|
|
238
|
+
const e = r.layouts.find((o) => o.id === t);
|
|
239
|
+
!e || e.isPreset || s(c((o) => {
|
|
238
240
|
var i;
|
|
239
241
|
const n = o.layouts.findIndex((a) => a.id === t);
|
|
240
242
|
n !== -1 && (o.layouts.splice(n, 1), o.activeLayoutId === t && (o.activeLayoutId = ((i = o.layouts[0]) == null ? void 0 : i.id) ?? ""));
|
|
241
243
|
}));
|
|
242
244
|
},
|
|
243
245
|
renameLayout: (t, e) => {
|
|
244
|
-
const o =
|
|
245
|
-
!o || o.isPreset || s(
|
|
246
|
+
const o = r.layouts.find((n) => n.id === t);
|
|
247
|
+
!o || o.isPreset || s(c((n) => {
|
|
246
248
|
const i = n.layouts.find((a) => a.id === t);
|
|
247
249
|
i && (i.name = e, i.updatedAt = Date.now());
|
|
248
250
|
}));
|
|
249
251
|
},
|
|
250
252
|
// Edit mode
|
|
251
|
-
editMode: () =>
|
|
253
|
+
editMode: () => r.editMode,
|
|
252
254
|
setEditMode: (t) => s("editMode", t),
|
|
253
|
-
toggleEditMode: () => s("editMode", !
|
|
255
|
+
toggleEditMode: () => s("editMode", !r.editMode),
|
|
254
256
|
// Widget management
|
|
255
257
|
addWidget: (t, e, o) => {
|
|
256
258
|
const n = f();
|
|
@@ -261,23 +263,23 @@ function V() {
|
|
|
261
263
|
}, u = {
|
|
262
264
|
colSpan: (e == null ? void 0 : e.colSpan) ?? (i == null ? void 0 : i.defaultColSpan) ?? Math.max(a.minColSpan, 4),
|
|
263
265
|
rowSpan: (e == null ? void 0 : e.rowSpan) ?? (i == null ? void 0 : i.defaultRowSpan) ?? Math.max(a.minRowSpan, 3)
|
|
264
|
-
},
|
|
266
|
+
}, K = (e == null ? void 0 : e.col) !== void 0 && (e == null ? void 0 : e.row) !== void 0 ? N({
|
|
265
267
|
...u,
|
|
266
268
|
col: e.col,
|
|
267
269
|
row: e.row
|
|
268
|
-
}, a.minColSpan, a.minRowSpan) :
|
|
269
|
-
id:
|
|
270
|
+
}, a.minColSpan, a.minRowSpan) : Q(n.widgets, u.colSpan, u.rowSpan), W = g(), O = {
|
|
271
|
+
id: W,
|
|
270
272
|
type: t,
|
|
271
|
-
position:
|
|
273
|
+
position: K,
|
|
272
274
|
config: o
|
|
273
275
|
};
|
|
274
|
-
return s(
|
|
275
|
-
const I =
|
|
276
|
-
I && (I.widgets.push(
|
|
277
|
-
})),
|
|
276
|
+
return s(c((k) => {
|
|
277
|
+
const I = k.layouts.find(($) => $.id === k.activeLayoutId);
|
|
278
|
+
I && (I.widgets.push(O), I.updatedAt = Date.now());
|
|
279
|
+
})), W;
|
|
278
280
|
},
|
|
279
281
|
removeWidget: (t) => {
|
|
280
|
-
s(
|
|
282
|
+
s(c((e) => {
|
|
281
283
|
const o = e.layouts.find((n) => n.id === e.activeLayoutId);
|
|
282
284
|
if (o) {
|
|
283
285
|
const n = o.widgets.findIndex((i) => i.id === t);
|
|
@@ -286,7 +288,7 @@ function V() {
|
|
|
286
288
|
}));
|
|
287
289
|
},
|
|
288
290
|
updateWidgetPosition: (t, e) => {
|
|
289
|
-
s(
|
|
291
|
+
s(c((o) => {
|
|
290
292
|
const n = o.layouts.find((i) => i.id === o.activeLayoutId);
|
|
291
293
|
if (n) {
|
|
292
294
|
const i = n.widgets.find((a) => a.id === t);
|
|
@@ -295,7 +297,7 @@ function V() {
|
|
|
295
297
|
}));
|
|
296
298
|
},
|
|
297
299
|
updateWidgetConfig: (t, e) => {
|
|
298
|
-
s(
|
|
300
|
+
s(c((o) => {
|
|
299
301
|
const n = o.layouts.find((i) => i.id === o.activeLayoutId);
|
|
300
302
|
if (n) {
|
|
301
303
|
const i = n.widgets.find((a) => a.id === t);
|
|
@@ -307,7 +309,7 @@ function V() {
|
|
|
307
309
|
}));
|
|
308
310
|
},
|
|
309
311
|
updateWidgetTitle: (t, e) => {
|
|
310
|
-
s(
|
|
312
|
+
s(c((o) => {
|
|
311
313
|
const n = o.layouts.find((i) => i.id === o.activeLayoutId);
|
|
312
314
|
if (n) {
|
|
313
315
|
const i = n.widgets.find((a) => a.id === t);
|
|
@@ -316,7 +318,7 @@ function V() {
|
|
|
316
318
|
}));
|
|
317
319
|
},
|
|
318
320
|
changeWidgetType: (t, e) => {
|
|
319
|
-
s(
|
|
321
|
+
s(c((o) => {
|
|
320
322
|
const n = o.layouts.find((i) => i.id === o.activeLayoutId);
|
|
321
323
|
if (n) {
|
|
322
324
|
const i = n.widgets.find((a) => a.id === t);
|
|
@@ -325,7 +327,7 @@ function V() {
|
|
|
325
327
|
}));
|
|
326
328
|
},
|
|
327
329
|
updateWidgetState: (t, e, o) => {
|
|
328
|
-
s(
|
|
330
|
+
s(c((n) => {
|
|
329
331
|
const i = n.layouts.find((a) => a.id === n.activeLayoutId);
|
|
330
332
|
if (i) {
|
|
331
333
|
const a = i.widgets.find((u) => u.id === t);
|
|
@@ -369,7 +371,7 @@ function V() {
|
|
|
369
371
|
if (e) {
|
|
370
372
|
if (t) {
|
|
371
373
|
const o = f();
|
|
372
|
-
o && !A(e.currentPosition, o.widgets, e.widgetId) && s(
|
|
374
|
+
o && !A(e.currentPosition, o.widgets, e.widgetId) && s(c((n) => {
|
|
373
375
|
const i = n.layouts.find((a) => a.id === n.activeLayoutId);
|
|
374
376
|
if (i) {
|
|
375
377
|
const a = i.widgets.find((u) => u.id === e.widgetId);
|
|
@@ -408,7 +410,7 @@ function V() {
|
|
|
408
410
|
if (e) {
|
|
409
411
|
if (t) {
|
|
410
412
|
const o = f();
|
|
411
|
-
o && !A(e.currentPosition, o.widgets, e.widgetId) && s(
|
|
413
|
+
o && !A(e.currentPosition, o.widgets, e.widgetId) && s(c((n) => {
|
|
412
414
|
const i = n.layouts.find((a) => a.id === n.activeLayoutId);
|
|
413
415
|
if (i) {
|
|
414
416
|
const a = i.widgets.find((u) => u.id === e.widgetId);
|
|
@@ -430,7 +432,7 @@ function V() {
|
|
|
430
432
|
};
|
|
431
433
|
}
|
|
432
434
|
export {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
435
|
+
ot as DeckProvider,
|
|
436
|
+
X as createDeckService,
|
|
437
|
+
nt as useDeck
|
|
436
438
|
};
|