@kolkrabbi/design-editor 0.27.0 → 0.28.0

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.
@@ -0,0 +1,166 @@
1
+ import { F as e, L as t } from "./rolls-CGma4Bua.js";
2
+ import { Dropdown as n, LabeledControl as r, SettingsRow as i, embedFontFace as a } from "@kolkrabbi/kol-component";
3
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
4
+ //#region src/kinetic/fonts.js
5
+ var l = [
6
+ {
7
+ key: "rot",
8
+ label: "Rot",
9
+ family: "TG Rot",
10
+ url: "/fonts/tg/TGRotVF.ttf",
11
+ axes: [{
12
+ tag: "wdth",
13
+ min: 64,
14
+ max: 172,
15
+ def: 100
16
+ }, {
17
+ tag: "wght",
18
+ min: 100,
19
+ max: 900,
20
+ def: 400
21
+ }]
22
+ },
23
+ {
24
+ key: "malromur",
25
+ label: "Malromur",
26
+ family: "TG Malromur",
27
+ url: "/fonts/tg/TGMalromurRomanVF.ttf",
28
+ axes: [{
29
+ tag: "wght",
30
+ min: 300,
31
+ max: 900,
32
+ def: 300
33
+ }]
34
+ },
35
+ {
36
+ key: "gullhamrar",
37
+ label: "Gullhamrar",
38
+ family: "TG Gullhamrar",
39
+ url: "/fonts/tg/TGGullhamrarVF.ttf",
40
+ axes: [{
41
+ tag: "wght",
42
+ min: 300,
43
+ max: 900,
44
+ def: 300
45
+ }]
46
+ }
47
+ ], u = l.map((e) => ({
48
+ value: e.key,
49
+ label: e.label
50
+ })), d = {
51
+ wght: "Weight",
52
+ wdth: "Width",
53
+ ital: "Italic",
54
+ slnt: "Slant",
55
+ opsz: "Optical size"
56
+ }, f = (e) => l.find((t) => t.key === e) || l[0];
57
+ function p(e) {
58
+ let t = {};
59
+ for (let n of e.axes) t[n.tag] = n.def;
60
+ return t;
61
+ }
62
+ function m(e) {
63
+ let t = Object.entries(e || {}).map(([e, t]) => `'${e}' ${Math.round(t * 100) / 100}`);
64
+ return t.length ? t.join(", ") : "normal";
65
+ }
66
+ var h = !1;
67
+ async function g() {
68
+ if (!(h || typeof FontFace > "u")) {
69
+ h = !0;
70
+ for (let e of l) {
71
+ let t = {}, n = e.axes.find((e) => e.tag === "wght"), r = e.axes.find((e) => e.tag === "wdth");
72
+ n && (t.weight = `${n.min} ${n.max}`), r && (t.stretch = `${r.min}% ${r.max}%`);
73
+ try {
74
+ let n = new FontFace(e.family, `url(${e.url})`, t);
75
+ document.fonts.add(n), n.load().catch(() => {});
76
+ } catch {}
77
+ }
78
+ try {
79
+ await document.fonts.ready;
80
+ } catch {}
81
+ }
82
+ }
83
+ var _ = /* @__PURE__ */ new Map(), v = null;
84
+ function y() {
85
+ return v || (v = Promise.all(l.map(async (e) => {
86
+ if (!_.has(e.url)) try {
87
+ _.set(e.url, await a({
88
+ family: e.family,
89
+ url: e.url
90
+ }));
91
+ } catch (t) {
92
+ console.warn(`[design-editor] font not embedded, export will fall back for ${e.family}:`, t);
93
+ }
94
+ })), v);
95
+ }
96
+ function b(e) {
97
+ let t = /* @__PURE__ */ new Set();
98
+ for (let n of e?.instances ?? []) t.add(f(n.font).url);
99
+ return [...t].map((e) => _.get(e)).filter(Boolean).join("\n");
100
+ }
101
+ //#endregion
102
+ //#region src/editor/compose/inspectors/TreePicker.jsx
103
+ function x(e) {
104
+ return /* @__PURE__ */ s(n, {
105
+ variant: "subtle",
106
+ size: t(),
107
+ className: "w-full",
108
+ ...e
109
+ });
110
+ }
111
+ function S({ label: t, options: n, value: a, onChange: o, children: c, inline: l = !0 }) {
112
+ let u = c ?? /* @__PURE__ */ s(x, {
113
+ options: n,
114
+ value: a,
115
+ onChange: o
116
+ });
117
+ return l ? /* @__PURE__ */ s(i, {
118
+ label: t,
119
+ align: "fill",
120
+ labelWidth: e,
121
+ children: u
122
+ }) : /* @__PURE__ */ s(r, {
123
+ label: t,
124
+ children: u
125
+ });
126
+ }
127
+ function C({ tree: e, presets: t, current: n, onPick: r, inline: i = !0, subLabel: a = (e) => e }) {
128
+ let l = e.find((e) => e.label === n.typeLabel) ?? e.find((e) => e.subs.includes(n.sub)) ?? e[0], u = t.filter((e) => e.sub === n.sub), d = (e) => t.find((t) => t.sub === e);
129
+ return /* @__PURE__ */ c(o, { children: [
130
+ /* @__PURE__ */ s(S, {
131
+ inline: i,
132
+ label: "Type",
133
+ options: e.map((e) => ({
134
+ value: e.label,
135
+ label: e.label
136
+ })),
137
+ value: l.label,
138
+ onChange: (t) => {
139
+ let n = e.find((e) => e.label === t);
140
+ n && r(d(n.subs[0]));
141
+ }
142
+ }),
143
+ /* @__PURE__ */ s(S, {
144
+ inline: i,
145
+ label: "Category",
146
+ options: l.subs.map((e) => ({
147
+ value: e,
148
+ label: a(e)
149
+ })),
150
+ value: n.sub,
151
+ onChange: (e) => r(d(e))
152
+ }),
153
+ /* @__PURE__ */ s(S, {
154
+ inline: i,
155
+ label: "Preset",
156
+ options: u.map((e) => ({
157
+ value: e.id,
158
+ label: e.label
159
+ })),
160
+ value: n.id,
161
+ onChange: (e) => r(t.find((t) => t.id === e))
162
+ })
163
+ ] });
164
+ }
165
+ //#endregion
166
+ export { l as a, f as c, m as d, y as f, d as i, b as l, S as n, u as o, C as r, p as s, x as t, g as u };