@tatamicks/core 1.0.2 → 1.0.3
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/{PalettePanel-BMZ6dfI3.cjs → PalettePanel-0cFP3tbA.cjs} +2 -2
- package/dist/PalettePanel-0cFP3tbA.cjs.map +1 -0
- package/dist/{PalettePanel-Cigl9i1N.js → PalettePanel-N5Y1TJAk.js} +151 -166
- package/dist/PalettePanel-N5Y1TJAk.js.map +1 -0
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.mjs +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{paperSettingsWidget-7766a5Fe.cjs → paperSettingsWidget-CJ4QFjYK.cjs} +1 -1
- package/dist/{paperSettingsWidget-7766a5Fe.cjs.map → paperSettingsWidget-CJ4QFjYK.cjs.map} +1 -1
- package/dist/{paperSettingsWidget-DvtghSA5.js → paperSettingsWidget-d93s3Gsr.js} +1 -1
- package/dist/{paperSettingsWidget-DvtghSA5.js.map → paperSettingsWidget-d93s3Gsr.js.map} +1 -1
- package/dist/shell.cjs +1 -1
- package/dist/shell.mjs +2 -2
- package/dist/sidebarPortal-B2Mk9Aba.js +875 -0
- package/dist/sidebarPortal-B2Mk9Aba.js.map +1 -0
- package/dist/sidebarPortal-BCIVv4yO.cjs +3 -0
- package/dist/sidebarPortal-BCIVv4yO.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/PalettePanel-BMZ6dfI3.cjs.map +0 -1
- package/dist/PalettePanel-Cigl9i1N.js.map +0 -1
- package/dist/sidebarPortal-BN6FVwaF.js +0 -870
- package/dist/sidebarPortal-BN6FVwaF.js.map +0 -1
- package/dist/sidebarPortal-Cr-dLvA_.cjs +0 -3
- package/dist/sidebarPortal-Cr-dLvA_.cjs.map +0 -1
|
@@ -1,870 +0,0 @@
|
|
|
1
|
-
import { jsxs as q, jsx as S } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as _, useCallback as O } from "react";
|
|
3
|
-
var Z = /* @__PURE__ */ ((t) => (t.left = "left", t.center = "center", t.right = "right", t))(Z || {}), Q = /* @__PURE__ */ ((t) => (t.top = "top", t.center = "center", t.bottom = "bottom", t))(Q || {});
|
|
4
|
-
const $t = {
|
|
5
|
-
kind: "alignment",
|
|
6
|
-
defaultProps: {
|
|
7
|
-
horizontal: "left",
|
|
8
|
-
vertical: "center"
|
|
9
|
-
/* center */
|
|
10
|
-
}
|
|
11
|
-
}, Ut = {
|
|
12
|
-
kind: "checkboxStyle",
|
|
13
|
-
defaultProps: {
|
|
14
|
-
styleConfig: {
|
|
15
|
-
checkboxSize: { value: 16, unit: "px" },
|
|
16
|
-
borderWidth: { value: 1, unit: "px" },
|
|
17
|
-
borderColor: "#000000",
|
|
18
|
-
checkWidth: { value: 3.5, unit: "px" },
|
|
19
|
-
checkColor: "#000000",
|
|
20
|
-
backgroundColor: "#ffffff",
|
|
21
|
-
checkedBackgroundColor: "#ffffff"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}, G = "application/x-tatamicks-block", N = "application/x-tatamicks-block-kind-";
|
|
25
|
-
function Gt(t, r, e) {
|
|
26
|
-
if (!t.dataTransfer) return;
|
|
27
|
-
const n = { kind: r, defaultSize: e };
|
|
28
|
-
t.dataTransfer.setData(G, JSON.stringify(n)), t.dataTransfer.setData(`${N}${r}`, ""), t.dataTransfer.effectAllowed = "copy";
|
|
29
|
-
}
|
|
30
|
-
function Vt(t) {
|
|
31
|
-
if (!t.dataTransfer) return null;
|
|
32
|
-
const r = t.dataTransfer.getData(G);
|
|
33
|
-
if (!r) return null;
|
|
34
|
-
try {
|
|
35
|
-
return JSON.parse(r);
|
|
36
|
-
} catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function Ht(t) {
|
|
41
|
-
if (!t.dataTransfer) return null;
|
|
42
|
-
const r = Array.from(t.dataTransfer.types).find(
|
|
43
|
-
(e) => e.startsWith(N)
|
|
44
|
-
);
|
|
45
|
-
return r ? r.slice(N.length) : null;
|
|
46
|
-
}
|
|
47
|
-
const Wt = {
|
|
48
|
-
colCount: 20,
|
|
49
|
-
rowCount: 28
|
|
50
|
-
};
|
|
51
|
-
var tt = /* @__PURE__ */ ((t) => (t.A4 = "A4", t.B5 = "B5", t.A3 = "A3", t.LETTER = "Letter", t.LEGAL = "Legal", t.CUSTOM = "Custom", t))(tt || {});
|
|
52
|
-
const rt = {
|
|
53
|
-
A4: {
|
|
54
|
-
preset: "A4",
|
|
55
|
-
width: { value: 210, unit: "mm" },
|
|
56
|
-
height: { value: 297, unit: "mm" }
|
|
57
|
-
},
|
|
58
|
-
A3: {
|
|
59
|
-
preset: "A3",
|
|
60
|
-
width: { value: 297, unit: "mm" },
|
|
61
|
-
height: { value: 420, unit: "mm" }
|
|
62
|
-
},
|
|
63
|
-
B5: {
|
|
64
|
-
preset: "B5",
|
|
65
|
-
width: { value: 182, unit: "mm" },
|
|
66
|
-
height: { value: 257, unit: "mm" }
|
|
67
|
-
},
|
|
68
|
-
Letter: {
|
|
69
|
-
preset: "Letter",
|
|
70
|
-
width: { value: 8.5, unit: "inch" },
|
|
71
|
-
height: { value: 11, unit: "inch" }
|
|
72
|
-
},
|
|
73
|
-
Legal: {
|
|
74
|
-
preset: "Legal",
|
|
75
|
-
width: { value: 8.5, unit: "inch" },
|
|
76
|
-
height: { value: 14, unit: "inch" }
|
|
77
|
-
},
|
|
78
|
-
Custom: {
|
|
79
|
-
preset: "Custom",
|
|
80
|
-
width: { value: 210, unit: "mm" },
|
|
81
|
-
height: { value: 297, unit: "mm" }
|
|
82
|
-
}
|
|
83
|
-
}, et = {
|
|
84
|
-
top: { value: 10, unit: "mm" },
|
|
85
|
-
right: { value: 10, unit: "mm" },
|
|
86
|
-
bottom: { value: 10, unit: "mm" },
|
|
87
|
-
left: { value: 10, unit: "mm" }
|
|
88
|
-
}, Ft = {
|
|
89
|
-
size: rt.A4,
|
|
90
|
-
margin: et
|
|
91
|
-
}, Kt = {
|
|
92
|
-
// ==================== GridLayer (10-90) ====================
|
|
93
|
-
GRID_CANVAS: 10,
|
|
94
|
-
MARGIN_OVERLAY: 20,
|
|
95
|
-
GRID_OVERLAY: 30,
|
|
96
|
-
BORDER_OVERLAY: 40,
|
|
97
|
-
// ==================== BlockLayer (100-999,999) ====================
|
|
98
|
-
BLOCK_LAYER_MIN: 100,
|
|
99
|
-
BLOCK_LAYER_MAX: 999999,
|
|
100
|
-
BLOCK_LAYER_STEP: 100,
|
|
101
|
-
// ==================== InteractionLayer (2,000,000+) ====================
|
|
102
|
-
SELECT_BLOCK: 2e6,
|
|
103
|
-
INTERACTION_LAYER_BASE: 21e5,
|
|
104
|
-
BLOCK_GHOST: 22e5,
|
|
105
|
-
HOVER_OUTLINE: 23e5,
|
|
106
|
-
EDIT_BLOCK: 24e5,
|
|
107
|
-
BLOCK_SELECT_BORDER: 25e5,
|
|
108
|
-
BLOCK_HANDLES: 26e5,
|
|
109
|
-
SELECTION_ACTION_BAR: 265e4,
|
|
110
|
-
GRID_GHOST: 27e5,
|
|
111
|
-
DROPDOWN: 34e5
|
|
112
|
-
}, Xt = {
|
|
113
|
-
BG: 10,
|
|
114
|
-
CONTENT: 50,
|
|
115
|
-
GUIDE: 70,
|
|
116
|
-
BORDER: 80,
|
|
117
|
-
VALIDATION: 90
|
|
118
|
-
};
|
|
119
|
-
function zt(t, r) {
|
|
120
|
-
const e = t.match(/^(\d+(?:\.\d+)?)([a-zA-Z%]+)$/);
|
|
121
|
-
if (!e)
|
|
122
|
-
throw new Error(`Invalid dimension string: ${t}`);
|
|
123
|
-
const n = Number(e[1]), o = e[2];
|
|
124
|
-
if (!r.includes(o))
|
|
125
|
-
throw new Error(`Invalid unit: ${o}`);
|
|
126
|
-
return { value: n, unit: o };
|
|
127
|
-
}
|
|
128
|
-
function Jt(t) {
|
|
129
|
-
return `${t.value}${t.unit}`;
|
|
130
|
-
}
|
|
131
|
-
const b = 96, nt = 10, V = 25.4, ot = 0.352778, at = V / b, d = {
|
|
132
|
-
fromCm: (t) => t * nt,
|
|
133
|
-
fromInch: (t) => t * V,
|
|
134
|
-
fromPt: (t) => t * ot,
|
|
135
|
-
fromPx: (t) => t * at,
|
|
136
|
-
fromDim(t) {
|
|
137
|
-
switch (t.unit) {
|
|
138
|
-
case "mm":
|
|
139
|
-
return t.value;
|
|
140
|
-
case "cm":
|
|
141
|
-
return d.fromCm(t.value);
|
|
142
|
-
case "inch":
|
|
143
|
-
return d.fromInch(t.value);
|
|
144
|
-
case "pt":
|
|
145
|
-
return d.fromPt(t.value);
|
|
146
|
-
case "px":
|
|
147
|
-
return d.fromPx(t.value);
|
|
148
|
-
case "fr":
|
|
149
|
-
case "%":
|
|
150
|
-
throw new Error(
|
|
151
|
-
`Cannot convert ${t.unit} to mm. Use physical units only.`
|
|
152
|
-
);
|
|
153
|
-
default: {
|
|
154
|
-
const r = t.unit;
|
|
155
|
-
throw new Error(`Unsupported unit: ${r}`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}, it = 25.4, st = 2.54, ct = 72, f = {
|
|
160
|
-
fromMm: (t, r = b) => t * r / it,
|
|
161
|
-
fromCm: (t, r = b) => t * r / st,
|
|
162
|
-
fromInch: (t, r = b) => t * r,
|
|
163
|
-
fromPt: (t, r = b) => t * r / ct,
|
|
164
|
-
// CSS px(96dpi 基準)を指定 DPI のスクリーン物理 px に変換
|
|
165
|
-
fromPx: (t, r = b) => t * r / b,
|
|
166
|
-
fromDim(t, r = b, e) {
|
|
167
|
-
switch (t.unit) {
|
|
168
|
-
case "mm":
|
|
169
|
-
return f.fromMm(t.value, r);
|
|
170
|
-
case "cm":
|
|
171
|
-
return f.fromCm(t.value, r);
|
|
172
|
-
case "inch":
|
|
173
|
-
return f.fromInch(t.value, r);
|
|
174
|
-
case "pt":
|
|
175
|
-
return f.fromPt(t.value, r);
|
|
176
|
-
case "px":
|
|
177
|
-
return f.fromPx(t.value, r);
|
|
178
|
-
case "%":
|
|
179
|
-
if (e === void 0)
|
|
180
|
-
throw new Error("Base size must be defined for percentage values.");
|
|
181
|
-
return t.value / 100 * e;
|
|
182
|
-
case "fr":
|
|
183
|
-
throw new Error(
|
|
184
|
-
`Cannot convert ${t.unit} to px. Use physical units only.`
|
|
185
|
-
);
|
|
186
|
-
default: {
|
|
187
|
-
const n = t.unit;
|
|
188
|
-
throw new Error(`Unsupported unit: ${n}`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}, ut = {
|
|
193
|
-
"flex-start": "left",
|
|
194
|
-
center: "center",
|
|
195
|
-
"flex-end": "right"
|
|
196
|
-
}, lt = {
|
|
197
|
-
"flex-start": "top",
|
|
198
|
-
center: "center",
|
|
199
|
-
"flex-end": "bottom"
|
|
200
|
-
};
|
|
201
|
-
function ft(t) {
|
|
202
|
-
return typeof t == "object" && t !== null && t.value === 1 && t.unit === "fr";
|
|
203
|
-
}
|
|
204
|
-
function j(t) {
|
|
205
|
-
const r = {};
|
|
206
|
-
for (let e = 0; e < t.length; e++) {
|
|
207
|
-
const n = t[e];
|
|
208
|
-
n !== void 0 && !ft(n) && (r[e] = n);
|
|
209
|
-
}
|
|
210
|
-
return r;
|
|
211
|
-
}
|
|
212
|
-
function H(t) {
|
|
213
|
-
if (typeof t != "object" || t === null)
|
|
214
|
-
throw new Error("grid must be an object");
|
|
215
|
-
const r = t;
|
|
216
|
-
if (Array.isArray(r.cols) && Array.isArray(r.rows)) {
|
|
217
|
-
const e = r.cols, n = r.rows, o = {
|
|
218
|
-
colCount: e.length,
|
|
219
|
-
rowCount: n.length
|
|
220
|
-
}, a = j(e);
|
|
221
|
-
Object.keys(a).length > 0 && (o.cols = a);
|
|
222
|
-
const s = j(n);
|
|
223
|
-
return Object.keys(s).length > 0 && (o.rows = s), o;
|
|
224
|
-
}
|
|
225
|
-
return t;
|
|
226
|
-
}
|
|
227
|
-
function mt(t) {
|
|
228
|
-
if (!("isIndividual" in t))
|
|
229
|
-
return t;
|
|
230
|
-
const r = { ...t }, e = r.isIndividual ?? !0, n = r.all;
|
|
231
|
-
return delete r.isIndividual, delete r.all, !e && n !== void 0 && ("top" in r || (r.top = n), "right" in r || (r.right = n), "bottom" in r || (r.bottom = n), "left" in r || (r.left = n)), r;
|
|
232
|
-
}
|
|
233
|
-
function ht(t) {
|
|
234
|
-
const r = { ...t };
|
|
235
|
-
if ("justifyContent" in r) {
|
|
236
|
-
const e = r.justifyContent;
|
|
237
|
-
r.horizontal = ut[e] ?? e, delete r.justifyContent;
|
|
238
|
-
}
|
|
239
|
-
if ("alignItems" in r) {
|
|
240
|
-
const e = r.alignItems;
|
|
241
|
-
r.vertical = lt[e] ?? e, delete r.alignItems;
|
|
242
|
-
}
|
|
243
|
-
return r;
|
|
244
|
-
}
|
|
245
|
-
function W(t) {
|
|
246
|
-
if (typeof t != "object" || t === null)
|
|
247
|
-
return t;
|
|
248
|
-
let r = { ...t };
|
|
249
|
-
return r = mt(r), r = ht(r), r;
|
|
250
|
-
}
|
|
251
|
-
function dt(t, r) {
|
|
252
|
-
if (typeof t != "object" || t === null)
|
|
253
|
-
throw new Error("page must be an object");
|
|
254
|
-
const e = { ...t };
|
|
255
|
-
return "grid" in e && (e.grid = H(e.grid)), Array.isArray(e.blocks) && (e.blocks = e.blocks.map((n) => {
|
|
256
|
-
if (typeof n == "object" && n !== null) {
|
|
257
|
-
const o = { ...n };
|
|
258
|
-
"props" in o && (o.props = W(o.props));
|
|
259
|
-
const a = typeof o.kind == "string" ? o.kind : void 0;
|
|
260
|
-
if (a && r) {
|
|
261
|
-
const s = r[a];
|
|
262
|
-
s != null && s.migrateProps && (o.props = s.migrateProps(o.props));
|
|
263
|
-
}
|
|
264
|
-
return o;
|
|
265
|
-
}
|
|
266
|
-
return n;
|
|
267
|
-
})), {
|
|
268
|
-
grid: e.grid,
|
|
269
|
-
blocks: e.blocks,
|
|
270
|
-
...e.blockDefaults !== void 0 ? { blockDefaults: e.blockDefaults } : {},
|
|
271
|
-
...e.metaData !== void 0 ? { metaData: e.metaData } : {}
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
function gt(t) {
|
|
275
|
-
return typeof t == "object" && t !== null && !("pages" in t) && "grid" in t && "blocks" in t;
|
|
276
|
-
}
|
|
277
|
-
function pt(t) {
|
|
278
|
-
return typeof t == "object" && t !== null && "pages" in t;
|
|
279
|
-
}
|
|
280
|
-
function bt(t, r) {
|
|
281
|
-
if (typeof t != "object" || t === null)
|
|
282
|
-
throw new Error("Book must be a JSON object");
|
|
283
|
-
const e = { ...t };
|
|
284
|
-
return Array.isArray(e.pages) && (e.pages = e.pages.map((n) => dt(n, r))), {
|
|
285
|
-
paper: e.paper,
|
|
286
|
-
pages: e.pages,
|
|
287
|
-
...e.metaData !== void 0 ? { metaData: e.metaData } : {}
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
function wt(t, r) {
|
|
291
|
-
if (typeof t != "object" || t === null)
|
|
292
|
-
throw new Error("Schema must be a JSON object");
|
|
293
|
-
const e = { ...t }, n = {};
|
|
294
|
-
if ("grid" in e && (n.grid = H(e.grid), delete e.grid), "blocks" in e) {
|
|
295
|
-
const s = e.blocks;
|
|
296
|
-
Array.isArray(s) && (n.blocks = s.map((c) => {
|
|
297
|
-
if (typeof c == "object" && c !== null) {
|
|
298
|
-
const u = { ...c };
|
|
299
|
-
"props" in u && (u.props = W(u.props));
|
|
300
|
-
const p = typeof u.kind == "string" ? u.kind : void 0;
|
|
301
|
-
if (p && r) {
|
|
302
|
-
const w = r[p];
|
|
303
|
-
w != null && w.migrateProps && (u.props = w.migrateProps(u.props));
|
|
304
|
-
}
|
|
305
|
-
return u;
|
|
306
|
-
}
|
|
307
|
-
return c;
|
|
308
|
-
})), delete e.blocks;
|
|
309
|
-
}
|
|
310
|
-
"metaData" in e && (n.metaData = e.metaData, delete e.metaData);
|
|
311
|
-
const o = {};
|
|
312
|
-
"paper" in e && (o.paper = e.paper, delete e.paper);
|
|
313
|
-
const a = {
|
|
314
|
-
grid: n.grid,
|
|
315
|
-
blocks: n.blocks ?? [],
|
|
316
|
-
...n.metaData !== void 0 ? { metaData: n.metaData } : {}
|
|
317
|
-
};
|
|
318
|
-
return {
|
|
319
|
-
paper: o.paper,
|
|
320
|
-
pages: [a]
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
function Mt(t, r) {
|
|
324
|
-
if (gt(t))
|
|
325
|
-
return wt(t, r);
|
|
326
|
-
if (pt(t))
|
|
327
|
-
return bt(t, r);
|
|
328
|
-
throw new Error(
|
|
329
|
-
`入力データの形式を判別できません。
|
|
330
|
-
形式 A(旧 FormSchema): トップレベルに 'grid' と 'blocks' が必要
|
|
331
|
-
形式 B(Book): トップレベルに 'pages' が必要`
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
function I(t) {
|
|
335
|
-
if (t === null) return !0;
|
|
336
|
-
switch (typeof t) {
|
|
337
|
-
case "string":
|
|
338
|
-
case "number":
|
|
339
|
-
case "boolean":
|
|
340
|
-
return !0;
|
|
341
|
-
case "object":
|
|
342
|
-
return Array.isArray(t) ? t.every(I) : Object.getPrototypeOf(t) === Object.prototype ? Object.values(t).every(I) : !1;
|
|
343
|
-
default:
|
|
344
|
-
return !1;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
function T(t) {
|
|
348
|
-
if (t === null || typeof t != "object" || Array.isArray(t) || Object.getPrototypeOf(t) !== Object.prototype)
|
|
349
|
-
throw new Error("values must be a plain object");
|
|
350
|
-
const r = t;
|
|
351
|
-
for (const [e, n] of Object.entries(r))
|
|
352
|
-
if (!I(n))
|
|
353
|
-
throw new Error(`values["${e}"] contains an invalid value`);
|
|
354
|
-
return r;
|
|
355
|
-
}
|
|
356
|
-
function Yt(t) {
|
|
357
|
-
let r;
|
|
358
|
-
try {
|
|
359
|
-
r = JSON.parse(t);
|
|
360
|
-
} catch {
|
|
361
|
-
throw new SyntaxError("invalid JSON for values");
|
|
362
|
-
}
|
|
363
|
-
return T(r);
|
|
364
|
-
}
|
|
365
|
-
function Et(t) {
|
|
366
|
-
if (typeof t != "object" || t === null) return !1;
|
|
367
|
-
const r = t;
|
|
368
|
-
return !(typeof r.colCount != "number" || r.colCount < 1 || typeof r.rowCount != "number" || r.rowCount < 1);
|
|
369
|
-
}
|
|
370
|
-
function vt(t) {
|
|
371
|
-
if (typeof t == "string") return !0;
|
|
372
|
-
if (typeof t != "object" || t === null) return !1;
|
|
373
|
-
const r = t;
|
|
374
|
-
if (typeof r.path != "string") return !1;
|
|
375
|
-
const e = (n) => n === null || typeof n == "string" || typeof n == "number" || typeof n == "boolean";
|
|
376
|
-
return "eq" in r ? e(r.eq) : "neq" in r ? e(r.neq) : !1;
|
|
377
|
-
}
|
|
378
|
-
function kt(t) {
|
|
379
|
-
if (typeof t != "object" || t === null) return !1;
|
|
380
|
-
const r = t;
|
|
381
|
-
if (typeof r.id != "string" || typeof r.kind != "string" || typeof r.layout != "object" || r.layout === null) return !1;
|
|
382
|
-
const e = r.layout;
|
|
383
|
-
if (typeof e.x != "number" || typeof e.y != "number" || typeof e.w != "number" || typeof e.h != "number" || typeof r.props != "object" || r.props === null || Array.isArray(r.props))
|
|
384
|
-
return !1;
|
|
385
|
-
try {
|
|
386
|
-
T(r.props);
|
|
387
|
-
} catch {
|
|
388
|
-
return !1;
|
|
389
|
-
}
|
|
390
|
-
return !("initValue" in r && !I(r.initValue) || "hiddenBinding" in r && !vt(r.hiddenBinding));
|
|
391
|
-
}
|
|
392
|
-
function F(t) {
|
|
393
|
-
if (typeof t != "object" || t === null)
|
|
394
|
-
throw new Error("Page must be an object");
|
|
395
|
-
const r = t;
|
|
396
|
-
if (r.id !== void 0 && typeof r.id != "string")
|
|
397
|
-
throw new Error("Page.id must be a string if provided");
|
|
398
|
-
if (!Et(r.grid))
|
|
399
|
-
throw new Error("Invalid grid definition");
|
|
400
|
-
if (!Array.isArray(r.blocks))
|
|
401
|
-
throw new Error("blocks must be an array");
|
|
402
|
-
if (!r.blocks.every(kt))
|
|
403
|
-
throw new Error("Invalid block definition in blocks array");
|
|
404
|
-
if (r.metaData !== void 0) {
|
|
405
|
-
if (typeof r.metaData != "object" || r.metaData === null)
|
|
406
|
-
throw new Error("metaData must be an object if provided");
|
|
407
|
-
try {
|
|
408
|
-
T(r.metaData);
|
|
409
|
-
} catch (e) {
|
|
410
|
-
throw new Error(
|
|
411
|
-
`Invalid metaData: ${e instanceof Error ? e.message : String(e)}`
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
if (r.blockDefaults !== void 0) {
|
|
416
|
-
if (typeof r.blockDefaults != "object" || r.blockDefaults === null || Array.isArray(r.blockDefaults))
|
|
417
|
-
throw new Error("blockDefaults must be a plain object if provided");
|
|
418
|
-
const e = r.blockDefaults;
|
|
419
|
-
for (const [n, o] of Object.entries(e))
|
|
420
|
-
try {
|
|
421
|
-
T(o);
|
|
422
|
-
} catch (a) {
|
|
423
|
-
throw new Error(
|
|
424
|
-
`Invalid blockDefaults["${n}"]: ${a instanceof Error ? a.message : String(a)}`
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
return t;
|
|
429
|
-
}
|
|
430
|
-
function Pt(t) {
|
|
431
|
-
if (typeof t != "object" || t === null)
|
|
432
|
-
throw new Error("Book must be an object");
|
|
433
|
-
const r = t;
|
|
434
|
-
if (!Array.isArray(r.pages) || r.pages.length === 0)
|
|
435
|
-
throw new Error("Book must have at least one page in pages");
|
|
436
|
-
if (r.pages.forEach((e, n) => {
|
|
437
|
-
try {
|
|
438
|
-
F(e);
|
|
439
|
-
} catch (o) {
|
|
440
|
-
throw new Error(
|
|
441
|
-
`Invalid Page at pages[${n}]: ${o instanceof Error ? o.message : String(o)}`
|
|
442
|
-
);
|
|
443
|
-
}
|
|
444
|
-
}), !r.paper || typeof r.paper != "object")
|
|
445
|
-
throw new Error("Book.paper is required and must be an object");
|
|
446
|
-
return t;
|
|
447
|
-
}
|
|
448
|
-
function qt(t) {
|
|
449
|
-
return JSON.stringify(t);
|
|
450
|
-
}
|
|
451
|
-
function Zt(t) {
|
|
452
|
-
return JSON.stringify(t);
|
|
453
|
-
}
|
|
454
|
-
function Qt(t) {
|
|
455
|
-
let r;
|
|
456
|
-
try {
|
|
457
|
-
r = JSON.parse(t);
|
|
458
|
-
} catch {
|
|
459
|
-
throw new SyntaxError("invalid JSON for Page");
|
|
460
|
-
}
|
|
461
|
-
return F(r);
|
|
462
|
-
}
|
|
463
|
-
function tr(t) {
|
|
464
|
-
let r;
|
|
465
|
-
try {
|
|
466
|
-
r = JSON.parse(t);
|
|
467
|
-
} catch {
|
|
468
|
-
throw new SyntaxError("invalid JSON for Book");
|
|
469
|
-
}
|
|
470
|
-
return Pt(Mt(r));
|
|
471
|
-
}
|
|
472
|
-
function rr({
|
|
473
|
-
checked: t,
|
|
474
|
-
styleConfig: r
|
|
475
|
-
}) {
|
|
476
|
-
const e = (r == null ? void 0 : r.borderColor) ?? "#000000", n = (r == null ? void 0 : r.checkColor) ?? "#000000", o = t ? (r == null ? void 0 : r.checkedBackgroundColor) ?? "#ffffff" : (r == null ? void 0 : r.backgroundColor) ?? "#ffffff", a = r != null && r.borderWidth ? f.fromDim(r.borderWidth) : 1, s = r != null && r.checkWidth ? f.fromDim(r.checkWidth) : 3.5;
|
|
477
|
-
return /* @__PURE__ */ q(
|
|
478
|
-
"svg",
|
|
479
|
-
{
|
|
480
|
-
viewBox: "0 0 20 20",
|
|
481
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
482
|
-
style: { width: "100%", height: "100%", display: "block" },
|
|
483
|
-
"aria-hidden": "true",
|
|
484
|
-
children: [
|
|
485
|
-
/* @__PURE__ */ S(
|
|
486
|
-
"rect",
|
|
487
|
-
{
|
|
488
|
-
x: "2",
|
|
489
|
-
y: "2",
|
|
490
|
-
width: "16",
|
|
491
|
-
height: "16",
|
|
492
|
-
rx: "2",
|
|
493
|
-
ry: "2",
|
|
494
|
-
fill: o,
|
|
495
|
-
stroke: e,
|
|
496
|
-
strokeWidth: a
|
|
497
|
-
}
|
|
498
|
-
),
|
|
499
|
-
t && /* @__PURE__ */ S(
|
|
500
|
-
"path",
|
|
501
|
-
{
|
|
502
|
-
d: "M3 11l4 4L17 4",
|
|
503
|
-
fill: "none",
|
|
504
|
-
stroke: n,
|
|
505
|
-
strokeWidth: s,
|
|
506
|
-
strokeLinecap: "round",
|
|
507
|
-
strokeLinejoin: "round"
|
|
508
|
-
}
|
|
509
|
-
)
|
|
510
|
-
]
|
|
511
|
-
}
|
|
512
|
-
);
|
|
513
|
-
}
|
|
514
|
-
var Dt = /* @__PURE__ */ ((t) => (t.SOLID = "solid", t.DASHED = "dashed", t.DOTTED = "dotted", t))(Dt || {}), yt = /* @__PURE__ */ ((t) => (t.FORM = "Form", t.EDIT = "Edit", t.VIEW = "View", t))(yt || {});
|
|
515
|
-
const i = {
|
|
516
|
-
MM: "mm",
|
|
517
|
-
CM: "cm",
|
|
518
|
-
FR: "fr",
|
|
519
|
-
INCH: "inch",
|
|
520
|
-
PT: "pt",
|
|
521
|
-
PX: "px",
|
|
522
|
-
PERCENT: "%"
|
|
523
|
-
}, er = [
|
|
524
|
-
i.MM,
|
|
525
|
-
i.CM,
|
|
526
|
-
i.FR,
|
|
527
|
-
i.INCH,
|
|
528
|
-
i.PT,
|
|
529
|
-
i.PX,
|
|
530
|
-
i.PERCENT
|
|
531
|
-
], nr = [
|
|
532
|
-
i.MM,
|
|
533
|
-
i.CM,
|
|
534
|
-
i.INCH,
|
|
535
|
-
i.PT,
|
|
536
|
-
i.PX
|
|
537
|
-
], or = [i.MM, i.CM, i.INCH], ar = [
|
|
538
|
-
i.MM,
|
|
539
|
-
i.CM,
|
|
540
|
-
i.FR,
|
|
541
|
-
i.INCH,
|
|
542
|
-
i.PT,
|
|
543
|
-
i.PX
|
|
544
|
-
], ir = [i.PX, i.PT, i.MM], sr = [i.PT, i.PX, i.MM], cr = [
|
|
545
|
-
i.MM,
|
|
546
|
-
i.PT,
|
|
547
|
-
i.PX,
|
|
548
|
-
i.PERCENT
|
|
549
|
-
], ur = [
|
|
550
|
-
i.MM,
|
|
551
|
-
i.CM,
|
|
552
|
-
i.INCH,
|
|
553
|
-
i.PT,
|
|
554
|
-
i.PX,
|
|
555
|
-
i.PERCENT
|
|
556
|
-
];
|
|
557
|
-
var At = /* @__PURE__ */ ((t) => (t.normal = "normal", t.breakWord = "break-word", t.breakAll = "break-all", t))(At || {}), _t = /* @__PURE__ */ ((t) => (t.normal = "normal", t.nowrap = "nowrap", t.pre = "pre", t.preWrap = "pre-wrap", t.preLine = "pre-line", t))(_t || {}), xt = /* @__PURE__ */ ((t) => (t.text = "text", t.number = "number", t.email = "email", t.tel = "tel", t.url = "url", t.date = "date", t.password = "password", t))(xt || {});
|
|
558
|
-
const lr = {
|
|
559
|
-
kind: "textBehavior",
|
|
560
|
-
defaultProps: {
|
|
561
|
-
lineHeight: 1.2,
|
|
562
|
-
multiline: !0,
|
|
563
|
-
wordWrap: "normal",
|
|
564
|
-
whiteSpace: "normal"
|
|
565
|
-
/* normal */
|
|
566
|
-
}
|
|
567
|
-
}, fr = {
|
|
568
|
-
kind: "textValidation",
|
|
569
|
-
defaultProps: {
|
|
570
|
-
inputType: "text"
|
|
571
|
-
/* text */
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
function mr(t) {
|
|
575
|
-
return `move-arrow-session-${t}`;
|
|
576
|
-
}
|
|
577
|
-
function hr(t, r) {
|
|
578
|
-
return `layout-${t}-${[...r].sort().join(",")}`;
|
|
579
|
-
}
|
|
580
|
-
function dr(t) {
|
|
581
|
-
return `binding-${t}`;
|
|
582
|
-
}
|
|
583
|
-
function gr(t) {
|
|
584
|
-
return `initValue-${t}`;
|
|
585
|
-
}
|
|
586
|
-
function pr(t) {
|
|
587
|
-
return `grid-size-${t}`;
|
|
588
|
-
}
|
|
589
|
-
function br(t) {
|
|
590
|
-
return `resize-arrow-session-${t}`;
|
|
591
|
-
}
|
|
592
|
-
const K = { value: 1, unit: "fr" };
|
|
593
|
-
function It(t) {
|
|
594
|
-
return Array.from(
|
|
595
|
-
{ length: t.colCount },
|
|
596
|
-
(r, e) => {
|
|
597
|
-
var n;
|
|
598
|
-
return ((n = t.cols) == null ? void 0 : n[e]) ?? K;
|
|
599
|
-
}
|
|
600
|
-
);
|
|
601
|
-
}
|
|
602
|
-
function Tt(t) {
|
|
603
|
-
return Array.from(
|
|
604
|
-
{ length: t.rowCount },
|
|
605
|
-
(r, e) => {
|
|
606
|
-
var n;
|
|
607
|
-
return ((n = t.rows) == null ? void 0 : n[e]) ?? K;
|
|
608
|
-
}
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
function wr(t) {
|
|
612
|
-
const r = {};
|
|
613
|
-
for (let e = 0; e < t.length; e++) {
|
|
614
|
-
const n = t[e];
|
|
615
|
-
n !== void 0 && !(n.value === 1 && n.unit === "fr") && (r[e] = n);
|
|
616
|
-
}
|
|
617
|
-
return {
|
|
618
|
-
colCount: t.length,
|
|
619
|
-
cols: Object.keys(r).length > 0 ? r : void 0
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
function Mr(t) {
|
|
623
|
-
const r = {};
|
|
624
|
-
for (let e = 0; e < t.length; e++) {
|
|
625
|
-
const n = t[e];
|
|
626
|
-
n !== void 0 && !(n.value === 1 && n.unit === "fr") && (r[e] = n);
|
|
627
|
-
}
|
|
628
|
-
return {
|
|
629
|
-
rowCount: t.length,
|
|
630
|
-
rows: Object.keys(r).length > 0 ? r : void 0
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
function Ot(t) {
|
|
634
|
-
const r = _(() => It(t), [t]), e = _(() => Tt(t), [t]);
|
|
635
|
-
return { expandedCols: r, expandedRows: e };
|
|
636
|
-
}
|
|
637
|
-
function Rt(t) {
|
|
638
|
-
if (t.length === 0) return [];
|
|
639
|
-
const r = [];
|
|
640
|
-
let e = 0;
|
|
641
|
-
for (const n of t) {
|
|
642
|
-
const o = n + e, a = Math.round(o);
|
|
643
|
-
r.push(a), e = o - a;
|
|
644
|
-
}
|
|
645
|
-
return r;
|
|
646
|
-
}
|
|
647
|
-
const Nt = 8, St = 32, jt = 64, Ct = 512, C = (t, r, e) => Math.min(Math.max(t, r), e);
|
|
648
|
-
function B(t) {
|
|
649
|
-
const r = t.length - 1, e = r >= 1 ? t[r] ?? 0 : 0, n = t.length >= 1 ? e / r : 0, o = C(Math.ceil(Math.log2(r + 1)), Nt, St), a = C(n * 2, jt, Ct);
|
|
650
|
-
return { step: o, windowPx: a };
|
|
651
|
-
}
|
|
652
|
-
function R(t, r) {
|
|
653
|
-
const e = r.length - 1;
|
|
654
|
-
if (e <= 0 || r[0] === void 0 || t < r[0] || r[e] === void 0) return -1;
|
|
655
|
-
if (t >= r[e]) return e - 1;
|
|
656
|
-
let n = 1, o = e;
|
|
657
|
-
for (; n <= o; ) {
|
|
658
|
-
const a = n + o >>> 1, s = r[a];
|
|
659
|
-
if (s === void 0) {
|
|
660
|
-
o = a - 1;
|
|
661
|
-
continue;
|
|
662
|
-
}
|
|
663
|
-
s <= t ? n = a + 1 : o = a - 1;
|
|
664
|
-
}
|
|
665
|
-
return n - 1;
|
|
666
|
-
}
|
|
667
|
-
function L(t, r, e) {
|
|
668
|
-
const n = t.length - 1;
|
|
669
|
-
let o = 0;
|
|
670
|
-
return (a) => {
|
|
671
|
-
if (n <= 0 || t[0] === void 0 || a < t[0] || t[n] === void 0) return -1;
|
|
672
|
-
if (a >= t[n]) return n - 1;
|
|
673
|
-
const s = t[o], c = t[o + 1];
|
|
674
|
-
if (s === void 0 || c === void 0) return -1;
|
|
675
|
-
if (s <= a && a < c) return o;
|
|
676
|
-
const u = s - e, p = c + e;
|
|
677
|
-
if (a < u || a >= p)
|
|
678
|
-
return o = R(a, t), o;
|
|
679
|
-
let w = 0;
|
|
680
|
-
const x = t[o + 1];
|
|
681
|
-
if (x !== void 0 && a >= x)
|
|
682
|
-
for (; o + 1 < n; ) {
|
|
683
|
-
const P = t[o + 1];
|
|
684
|
-
if (P === void 0 || a < P) break;
|
|
685
|
-
if (o++, ++w > r)
|
|
686
|
-
return o = R(a, t), o;
|
|
687
|
-
}
|
|
688
|
-
else
|
|
689
|
-
for (; o > 0; ) {
|
|
690
|
-
const P = t[o];
|
|
691
|
-
if (P === void 0 || a >= P) break;
|
|
692
|
-
if (o--, ++w > r)
|
|
693
|
-
return o = R(a, t), o;
|
|
694
|
-
}
|
|
695
|
-
return o;
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
function $(t, r) {
|
|
699
|
-
if (t.length === 0) return [];
|
|
700
|
-
let e = 0, n = 0;
|
|
701
|
-
const o = t.map((c) => {
|
|
702
|
-
if (c.unit === "fr")
|
|
703
|
-
return e += c.value, null;
|
|
704
|
-
const u = d.fromDim(c);
|
|
705
|
-
return n += u, u;
|
|
706
|
-
});
|
|
707
|
-
if (e === 0)
|
|
708
|
-
return o;
|
|
709
|
-
const s = Math.max(0, r - n) / e;
|
|
710
|
-
return o.map((c, u) => {
|
|
711
|
-
if (c != null) return c;
|
|
712
|
-
const p = t[u];
|
|
713
|
-
if (!p) throw new Error(`dims[${u}] is undefined`);
|
|
714
|
-
return p.value * s;
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
function U(t, r = b) {
|
|
718
|
-
const e = t.map((n) => f.fromMm(n, r));
|
|
719
|
-
return Rt(e);
|
|
720
|
-
}
|
|
721
|
-
function Er(t, r, e = b) {
|
|
722
|
-
const { expandedCols: n, expandedRows: o } = Ot(r), a = _(() => {
|
|
723
|
-
var D;
|
|
724
|
-
const g = t.orientation ? t.size.height : t.size.width, v = t.orientation ? t.size.width : t.size.height, M = d.fromDim(g), k = d.fromDim(v), m = t.margin.bulk && ((D = t.margin.all) != null && D.unit) ? d.fromDim(t.margin.all) : void 0, l = m ?? d.fromDim(t.margin.top), h = m ?? d.fromDim(t.margin.bottom), E = m ?? d.fromDim(t.margin.left), y = m ?? d.fromDim(t.margin.right);
|
|
725
|
-
return {
|
|
726
|
-
canvasWidthMm: M,
|
|
727
|
-
canvasHeightMm: k,
|
|
728
|
-
marginTopMm: l,
|
|
729
|
-
marginBottomMm: h,
|
|
730
|
-
marginLeftMm: E,
|
|
731
|
-
marginRightMm: y,
|
|
732
|
-
contentWidthMm: Math.max(0, M - E - y),
|
|
733
|
-
contentHeightMm: Math.max(
|
|
734
|
-
0,
|
|
735
|
-
k - l - h
|
|
736
|
-
)
|
|
737
|
-
};
|
|
738
|
-
}, [t]), s = _(() => {
|
|
739
|
-
const {
|
|
740
|
-
canvasWidthMm: g,
|
|
741
|
-
canvasHeightMm: v,
|
|
742
|
-
marginTopMm: M,
|
|
743
|
-
marginBottomMm: k,
|
|
744
|
-
marginLeftMm: m,
|
|
745
|
-
marginRightMm: l,
|
|
746
|
-
contentWidthMm: h,
|
|
747
|
-
contentHeightMm: E
|
|
748
|
-
} = a;
|
|
749
|
-
return {
|
|
750
|
-
canvas: {
|
|
751
|
-
width: f.fromMm(g, e),
|
|
752
|
-
height: f.fromMm(v, e)
|
|
753
|
-
},
|
|
754
|
-
margin: {
|
|
755
|
-
top: f.fromMm(M, e),
|
|
756
|
-
bottom: f.fromMm(k, e),
|
|
757
|
-
left: f.fromMm(m, e),
|
|
758
|
-
right: f.fromMm(l, e)
|
|
759
|
-
},
|
|
760
|
-
content: {
|
|
761
|
-
width: f.fromMm(h, e),
|
|
762
|
-
height: f.fromMm(E, e)
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
}, [a, e]), { gridPosPx: c, colIndexer: u, rowIndexer: p } = _(() => {
|
|
766
|
-
const { contentWidthMm: g, contentHeightMm: v } = a, M = U($(n, g), e), k = U($(o, v), e), m = [0];
|
|
767
|
-
for (const A of M)
|
|
768
|
-
m.push((m[m.length - 1] ?? 0) + A);
|
|
769
|
-
const l = [0];
|
|
770
|
-
for (const A of k)
|
|
771
|
-
l.push((l[l.length - 1] ?? 0) + A);
|
|
772
|
-
const { step: h, windowPx: E } = B(m), { step: y, windowPx: D } = B(l);
|
|
773
|
-
return {
|
|
774
|
-
gridPosPx: { cols: m, rows: l },
|
|
775
|
-
colIndexer: L(m, h, E),
|
|
776
|
-
rowIndexer: L(l, y, D)
|
|
777
|
-
};
|
|
778
|
-
}, [a, n, o, e]), w = O(
|
|
779
|
-
(g) => u(g - s.margin.left),
|
|
780
|
-
[u, s]
|
|
781
|
-
), x = O(
|
|
782
|
-
(g) => p(g - s.margin.top),
|
|
783
|
-
[p, s]
|
|
784
|
-
), P = O(
|
|
785
|
-
(g) => {
|
|
786
|
-
const { x: v, y: M, w: k, h: m } = g.layout, l = c.cols, h = c.rows;
|
|
787
|
-
if (!l.length || !h.length)
|
|
788
|
-
return { left: 0, top: 0, width: 0, height: 0 };
|
|
789
|
-
const E = Math.min(Math.max(0, v), l.length - 1), y = Math.min(Math.max(0, v + k), l.length - 1), D = Math.min(Math.max(0, M), h.length - 1), A = Math.min(Math.max(0, M + m), h.length - 1), X = (l[E] ?? 0) + s.margin.left, z = (h[D] ?? 0) + s.margin.top, J = (l[y] ?? 0) - (l[E] ?? 0), Y = (h[A] ?? 0) - (h[D] ?? 0);
|
|
790
|
-
return { left: X, top: z, width: J, height: Y };
|
|
791
|
-
},
|
|
792
|
-
[c, s]
|
|
793
|
-
);
|
|
794
|
-
return {
|
|
795
|
-
paperPx: s,
|
|
796
|
-
gridPosPx: c,
|
|
797
|
-
getColIndex: w,
|
|
798
|
-
getRowIndex: x,
|
|
799
|
-
getBlockRectPx: P
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
const vr = '[data-sidebar="true"]', kr = { "data-sidebar": "true" };
|
|
803
|
-
export {
|
|
804
|
-
mr as $,
|
|
805
|
-
nr as A,
|
|
806
|
-
ir as B,
|
|
807
|
-
Gt as C,
|
|
808
|
-
b as D,
|
|
809
|
-
zt as E,
|
|
810
|
-
sr as F,
|
|
811
|
-
ar as G,
|
|
812
|
-
Z as H,
|
|
813
|
-
xt as I,
|
|
814
|
-
lr as J,
|
|
815
|
-
fr as K,
|
|
816
|
-
Dt as L,
|
|
817
|
-
d as M,
|
|
818
|
-
yt as N,
|
|
819
|
-
f as O,
|
|
820
|
-
tt as P,
|
|
821
|
-
F as Q,
|
|
822
|
-
T as R,
|
|
823
|
-
kr as S,
|
|
824
|
-
rr as T,
|
|
825
|
-
i as U,
|
|
826
|
-
Q as V,
|
|
827
|
-
_t as W,
|
|
828
|
-
dr as X,
|
|
829
|
-
Xt as Y,
|
|
830
|
-
Kt as Z,
|
|
831
|
-
br as _,
|
|
832
|
-
Wt as a,
|
|
833
|
-
gr as a0,
|
|
834
|
-
Ot as a1,
|
|
835
|
-
Ht as a2,
|
|
836
|
-
G as a3,
|
|
837
|
-
Vt as a4,
|
|
838
|
-
wr as a5,
|
|
839
|
-
Mr as a6,
|
|
840
|
-
vr as a7,
|
|
841
|
-
It as a8,
|
|
842
|
-
Tt as a9,
|
|
843
|
-
hr as aa,
|
|
844
|
-
pr as ab,
|
|
845
|
-
Ft as b,
|
|
846
|
-
et as c,
|
|
847
|
-
rt as d,
|
|
848
|
-
tr as e,
|
|
849
|
-
Qt as f,
|
|
850
|
-
Yt as g,
|
|
851
|
-
gt as h,
|
|
852
|
-
pt as i,
|
|
853
|
-
bt as j,
|
|
854
|
-
wt as k,
|
|
855
|
-
dt as l,
|
|
856
|
-
Mt as m,
|
|
857
|
-
qt as n,
|
|
858
|
-
er as o,
|
|
859
|
-
Pt as p,
|
|
860
|
-
cr as q,
|
|
861
|
-
or as r,
|
|
862
|
-
Zt as s,
|
|
863
|
-
ur as t,
|
|
864
|
-
Er as u,
|
|
865
|
-
At as v,
|
|
866
|
-
$t as w,
|
|
867
|
-
Ut as x,
|
|
868
|
-
Jt as y,
|
|
869
|
-
I as z
|
|
870
|
-
};
|