@nice2dev/ui 1.3.18 → 1.4.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.
- package/CHANGELOG.md +75 -0
- package/README.md +27 -0
- package/dist/{NiceDataGrid-CFibAGHt.cjs → NiceDataGrid-BT6iCUgP.cjs} +1 -1
- package/dist/{NiceForm-ChRj4r3f.cjs → NiceForm-Bysp66Ef.cjs} +1 -1
- package/dist/{NiceMention-DNx3d9L7.cjs → NiceMention-sc8W-DwH.cjs} +1 -1
- package/dist/NiceModuleLifecyclePanel-DBQPCa_V.cjs +1 -0
- package/dist/{NiceSavedQueryPanel-BuRAgrBk.cjs → NiceSavedQueryPanel-BbznsXFd.cjs} +1 -1
- package/dist/{NiceScheduler-DAoo1eyo.cjs → NiceScheduler-3Ez0zSQJ.cjs} +1 -1
- package/dist/{core-lazy-DohJQ33c.cjs → core-lazy-CL4ZIxF-.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/editors/pickers/pickerCommons.mjs +284 -87
- package/dist/editors/pickers/themePickerHelpers.mjs +10 -8
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +166 -166
- package/dist/index.d.ts +142 -10
- package/dist/index.mjs +1517 -1488
- package/dist/navigation/sidebarColors.mjs +61 -50
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +7 -0
- package/dist/pickerCommons-CwcCc8Qi.cjs +1 -0
- package/dist/planning/NiceResourceAllocation.mjs +31 -31
- package/dist/style.css +4 -4
- package/dist/tools/NiceThemeDesigner.mjs +781 -708
- package/dist/tools/NiceThemePreview.mjs +344 -282
- package/dist/tools/themeCatalog.mjs +28 -44
- package/dist/tools/themeCatalogArchive.mjs +38 -0
- package/dist/tools/themeDesigner/ThemeSetEditors.mjs +400 -0
- package/dist/tools/themeDesigner/ThemeValueField.mjs +146 -0
- package/dist/tools/themeDesigner/themeDesignerPaths.mjs +105 -0
- package/package.json +4 -4
- package/dist/NiceModuleLifecyclePanel-D8Q081R6.cjs +0 -1
- package/dist/pickerCommons-BWglYl6J.cjs +0 -1
|
@@ -1,50 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
1
|
+
import { NICE_THEME_CURATED_PACKS as o } from "@nice2dev/ui-core";
|
|
2
|
+
const s = (t, r, m, e) => ({
|
|
3
3
|
id: t,
|
|
4
|
-
label:
|
|
5
|
-
entries:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
name: r.theme.name,
|
|
11
|
-
theme: r.theme,
|
|
12
|
-
pack: r,
|
|
13
|
-
packList: n,
|
|
4
|
+
label: r,
|
|
5
|
+
entries: m.map((n) => ({
|
|
6
|
+
name: n.theme.name,
|
|
7
|
+
theme: n.theme,
|
|
8
|
+
pack: n,
|
|
9
|
+
packList: e,
|
|
14
10
|
category: t
|
|
15
11
|
}))
|
|
16
|
-
}),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
e("design-system", "Design System", s.slice(58, 64)),
|
|
35
|
-
e("retro", "Retro", s.slice(64, 72)),
|
|
36
|
-
e("seasonal", "Seasonal", s.slice(72, 80)),
|
|
37
|
-
e("cultural", "Cultural", s.slice(80, 88)),
|
|
38
|
-
e("accessibility", "Accessibility", s.slice(88, 92)),
|
|
39
|
-
e("modern-ui", "Modern UI", s.slice(92))
|
|
40
|
-
], N = /* @__PURE__ */ (() => {
|
|
41
|
-
const t = /* @__PURE__ */ new Set(), a = [];
|
|
42
|
-
for (const c of y)
|
|
43
|
-
for (const n of c.entries)
|
|
44
|
-
t.has(n.name) || (t.add(n.name), a.push(n));
|
|
45
|
-
return a;
|
|
12
|
+
}), a = /* @__PURE__ */ (() => {
|
|
13
|
+
const t = (e) => e.theme.darkMode === "dark", r = o.filter((e) => e.meta.tags.includes("premium")), m = o.filter((e) => !e.meta.tags.includes("premium"));
|
|
14
|
+
return [
|
|
15
|
+
s("premium", "Premium", r, "curated"),
|
|
16
|
+
s(
|
|
17
|
+
"light",
|
|
18
|
+
"Light",
|
|
19
|
+
m.filter((e) => !t(e)),
|
|
20
|
+
"curated"
|
|
21
|
+
),
|
|
22
|
+
s("dark", "Dark", m.filter(t), "curated")
|
|
23
|
+
];
|
|
24
|
+
})(), c = /* @__PURE__ */ (() => {
|
|
25
|
+
const t = /* @__PURE__ */ new Set(), r = [];
|
|
26
|
+
for (const m of a)
|
|
27
|
+
for (const e of m.entries)
|
|
28
|
+
t.has(e.name) || (t.add(e.name), r.push(e));
|
|
29
|
+
return r;
|
|
46
30
|
})();
|
|
47
31
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
a as NICE_THEME_CATALOG,
|
|
33
|
+
c as NICE_THEME_CATALOG_ENTRIES
|
|
50
34
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { NICE_THEME_ARCHIVE as c } from "@nice2dev/ui-core";
|
|
2
|
+
const s = (e, t, a) => ({
|
|
3
|
+
id: e,
|
|
4
|
+
label: t,
|
|
5
|
+
entries: a.map((r) => ({ name: r.name, theme: r, category: e }))
|
|
6
|
+
}), m = /* @__PURE__ */ (() => {
|
|
7
|
+
const e = c.gallery, t = (a, r, i, n) => ({
|
|
8
|
+
id: a,
|
|
9
|
+
label: r,
|
|
10
|
+
entries: i.map((l) => ({
|
|
11
|
+
name: l.theme.name,
|
|
12
|
+
theme: l.theme,
|
|
13
|
+
pack: l,
|
|
14
|
+
packList: n,
|
|
15
|
+
category: a
|
|
16
|
+
}))
|
|
17
|
+
});
|
|
18
|
+
return [
|
|
19
|
+
t("packs", "Theme Packs", c.packs, "base"),
|
|
20
|
+
t("packs-2", "Theme Packs Vol. 2", c.packsExtended, "extended"),
|
|
21
|
+
s("core", "Core", c.core),
|
|
22
|
+
s("neutral", "Neutral", e.slice(0, 8)),
|
|
23
|
+
s("vibrant", "Vibrant", e.slice(8, 22)),
|
|
24
|
+
s("dark", "Dark", e.slice(22, 32)),
|
|
25
|
+
s("nature", "Nature", e.slice(32, 42)),
|
|
26
|
+
s("pastel", "Pastel", e.slice(42, 50)),
|
|
27
|
+
s("industry", "Industry", e.slice(50, 58)),
|
|
28
|
+
s("design-system", "Design System", e.slice(58, 64)),
|
|
29
|
+
s("retro", "Retro", e.slice(64, 72)),
|
|
30
|
+
s("seasonal", "Seasonal", e.slice(72, 80)),
|
|
31
|
+
s("cultural", "Cultural", e.slice(80, 88)),
|
|
32
|
+
s("accessibility", "Accessibility", e.slice(88, 92)),
|
|
33
|
+
s("modern-ui", "Modern UI", e.slice(92))
|
|
34
|
+
];
|
|
35
|
+
})();
|
|
36
|
+
export {
|
|
37
|
+
m as NICE_THEME_ARCHIVE_CATALOG
|
|
38
|
+
};
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { jsxs as p, jsx as a, Fragment as V } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as w, resolveTheme as E, getThemeValue as k, colorSetSnapshot as C, NiceIcon as N, THEME_HIGHLIGHT_CURVE as L, themeRefsOf as O, resolveThemeValue as _, renameThemeRef as W } from "@nice2dev/ui-core";
|
|
3
|
+
import { useMemo as B, useState as F } from "react";
|
|
4
|
+
import { NiceButton as y } from "../../buttons/NiceButton.mjs";
|
|
5
|
+
import { NiceCheckbox as M } from "../../editors/inputs/NiceCheckbox.mjs";
|
|
6
|
+
import { NiceNumberInput as z } from "../../editors/inputs/NiceNumberInput.mjs";
|
|
7
|
+
import { NiceSelect as P } from "../../editors/inputs/NiceSelect.mjs";
|
|
8
|
+
import { NiceTextInput as T } from "../../editors/inputs/NiceTextInput.mjs";
|
|
9
|
+
import { NiceColorPicker as S } from "../../editors/pickers/NiceColorPicker.mjs";
|
|
10
|
+
import { setThemePath as x } from "./themeDesignerPaths.mjs";
|
|
11
|
+
import { ThemeValueField as R } from "./ThemeValueField.mjs";
|
|
12
|
+
function te({
|
|
13
|
+
id: o,
|
|
14
|
+
label: c,
|
|
15
|
+
which: i,
|
|
16
|
+
theme: s,
|
|
17
|
+
edit: n,
|
|
18
|
+
onGoTo: v
|
|
19
|
+
}) {
|
|
20
|
+
const { t: m } = w(), u = `layout.sideNav.${i}`, b = k(s, u) ?? {}, h = b.mode ?? "shade", $ = h !== "list" && b.sync !== !1, e = B(
|
|
21
|
+
() => i === "headers" ? E(s).headerLevels?.map((t) => ({ background: t.bg, text: t.text })) ?? C(s, "headers") : C(s, "highlight"),
|
|
22
|
+
[s, i]
|
|
23
|
+
), r = () => n.replace(
|
|
24
|
+
x(s, u, { ...b, sync: !1, levels: C(s, i) }),
|
|
25
|
+
m("theme.syncOnce", "Sync once")
|
|
26
|
+
);
|
|
27
|
+
return /* @__PURE__ */ p("div", { className: "nice-theme-set", "data-token": u, children: [
|
|
28
|
+
/* @__PURE__ */ p("div", { className: "nice-theme-set__head", children: [
|
|
29
|
+
/* @__PURE__ */ a("span", { className: "nice-theme-set__title", children: c }),
|
|
30
|
+
/* @__PURE__ */ a(
|
|
31
|
+
P,
|
|
32
|
+
{
|
|
33
|
+
id: `${o}-mode`,
|
|
34
|
+
"aria-label": m("theme.setMode", "How the levels are made"),
|
|
35
|
+
size: "sm",
|
|
36
|
+
value: h,
|
|
37
|
+
options: [
|
|
38
|
+
{ value: "shade", label: m("theme.setShade", "Shaded from one colour") },
|
|
39
|
+
{ value: "palette", label: m("theme.setPalette", "From the palette") },
|
|
40
|
+
{ value: "list", label: m("theme.setList", "A list") }
|
|
41
|
+
],
|
|
42
|
+
onChange: (t) => n.set(`${u}.mode`, t)
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
] }),
|
|
46
|
+
/* @__PURE__ */ a(
|
|
47
|
+
R,
|
|
48
|
+
{
|
|
49
|
+
id: `${o}-base`,
|
|
50
|
+
label: i === "headers" ? m("theme.headerBase", "Header colour") : m("theme.highlight", "Highlight"),
|
|
51
|
+
path: `${u}.base`,
|
|
52
|
+
theme: s,
|
|
53
|
+
onChange: (t, l) => n.set(t, l),
|
|
54
|
+
onGoTo: v
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
i === "highlight" && /* @__PURE__ */ a(
|
|
58
|
+
R,
|
|
59
|
+
{
|
|
60
|
+
id: `${o}-text`,
|
|
61
|
+
label: m("theme.highlightText", "Highlight text"),
|
|
62
|
+
path: `${u}.text`,
|
|
63
|
+
theme: s,
|
|
64
|
+
onChange: (t, l) => n.set(t, l),
|
|
65
|
+
onGoTo: v
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ p("div", { className: "nice-theme-set__row", children: [
|
|
69
|
+
i === "headers" && /* @__PURE__ */ a(
|
|
70
|
+
z,
|
|
71
|
+
{
|
|
72
|
+
id: `${o}-count`,
|
|
73
|
+
label: m("theme.levels", "Levels"),
|
|
74
|
+
labelPlacement: "left",
|
|
75
|
+
size: "sm",
|
|
76
|
+
min: 1,
|
|
77
|
+
max: 10,
|
|
78
|
+
value: b.count ?? 6,
|
|
79
|
+
onChange: (t) => n.set(`${u}.count`, typeof t == "number" ? t : void 0)
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ a(
|
|
83
|
+
M,
|
|
84
|
+
{
|
|
85
|
+
label: m("theme.sync", "Sync"),
|
|
86
|
+
checked: $,
|
|
87
|
+
disabled: h === "list",
|
|
88
|
+
onChange: (t) => n.set(`${u}.sync`, t ? void 0 : !1)
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ a(y, { size: "sm", variant: "secondary", onClick: r, children: m("theme.syncOnce", "Sync once") })
|
|
92
|
+
] }),
|
|
93
|
+
$ && /* @__PURE__ */ a("p", { className: "nice-theme-set__hint", children: m(
|
|
94
|
+
"theme.syncHint",
|
|
95
|
+
"Derived from the colour above. Turn Sync off — or use Sync once — to fix single levels."
|
|
96
|
+
) }),
|
|
97
|
+
/* @__PURE__ */ a("ol", { className: "nice-theme-set__levels", children: e.map((t, l) => {
|
|
98
|
+
const d = `${u}.levels.${l}`, f = !$ && k(s, d) !== void 0;
|
|
99
|
+
return /* @__PURE__ */ p("li", { className: "nice-theme-set__level", children: [
|
|
100
|
+
/* @__PURE__ */ a(
|
|
101
|
+
"span",
|
|
102
|
+
{
|
|
103
|
+
className: "nice-theme-set__sample",
|
|
104
|
+
style: { background: t.background, color: t.text },
|
|
105
|
+
"aria-hidden": "true",
|
|
106
|
+
children: l + 1
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
$ ? /* @__PURE__ */ a("code", { className: "nice-theme-set__value", children: t.background }) : /* @__PURE__ */ p(V, { children: [
|
|
110
|
+
/* @__PURE__ */ a(
|
|
111
|
+
S,
|
|
112
|
+
{
|
|
113
|
+
id: `${o}-l${l}-bg`,
|
|
114
|
+
"aria-label": `${c} ${l + 1}`,
|
|
115
|
+
size: "sm",
|
|
116
|
+
compact: !0,
|
|
117
|
+
value: t.background ?? "",
|
|
118
|
+
onChange: (g) => n.set(`${d}.background`, g)
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
/* @__PURE__ */ a(
|
|
122
|
+
S,
|
|
123
|
+
{
|
|
124
|
+
id: `${o}-l${l}-text`,
|
|
125
|
+
"aria-label": `${c} ${l + 1} — ${m("theme.text", "Text")}`,
|
|
126
|
+
size: "sm",
|
|
127
|
+
compact: !0,
|
|
128
|
+
value: t.text ?? "",
|
|
129
|
+
onChange: (g) => n.set(`${d}.text`, g)
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
f && /* @__PURE__ */ a(
|
|
133
|
+
"button",
|
|
134
|
+
{
|
|
135
|
+
type: "button",
|
|
136
|
+
className: "nice-theme-set__reset",
|
|
137
|
+
title: m("theme.resetDerived", "Reset to derived"),
|
|
138
|
+
"aria-label": m("theme.resetDerived", "Reset to derived"),
|
|
139
|
+
onClick: () => n.set(d, void 0),
|
|
140
|
+
children: /* @__PURE__ */ a(N, { name: "undo", size: 12 })
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] })
|
|
144
|
+
] }, l);
|
|
145
|
+
}) }),
|
|
146
|
+
i === "highlight" && /* @__PURE__ */ a("p", { className: "nice-theme-set__hint", children: m(
|
|
147
|
+
"theme.pathHint",
|
|
148
|
+
"Each level above the active item takes the highlight over its own colour — {steps} — the active row the highlight itself."
|
|
149
|
+
).replace(
|
|
150
|
+
"{steps}",
|
|
151
|
+
(b.curve ?? L).map((t) => `${Math.round(t * 100)}%`).join(" · ")
|
|
152
|
+
) })
|
|
153
|
+
] });
|
|
154
|
+
}
|
|
155
|
+
const A = (o) => o.trim().replace(/[^\w-]+/g, "");
|
|
156
|
+
function ae({
|
|
157
|
+
id: o,
|
|
158
|
+
theme: c,
|
|
159
|
+
edit: i
|
|
160
|
+
}) {
|
|
161
|
+
const { t: s } = w(), n = c.palette ?? {}, v = c.gradients ?? {}, [m, u] = F(null), b = (e, r, t) => {
|
|
162
|
+
const l = A(t), d = e === "palette" ? n : v;
|
|
163
|
+
if (!l || l === r || l in d)
|
|
164
|
+
return;
|
|
165
|
+
const f = Object.entries(d).map(([H, I]) => [H === r ? l : H, I]);
|
|
166
|
+
let g = x(c, e, Object.fromEntries(f));
|
|
167
|
+
g = W(g, `${e}.${r}`, `${e}.${l}`), i.replace(g, s("theme.renameSwatch", "Rename"));
|
|
168
|
+
}, h = (e, r) => {
|
|
169
|
+
const t = `${e}.${r}`;
|
|
170
|
+
let l = c;
|
|
171
|
+
for (const f of O(c, t)) {
|
|
172
|
+
const g = k(c, f);
|
|
173
|
+
typeof g == "string" && g.trim() === `{${t}}` && (l = x(l, f, _(c, t)?.css ?? ""));
|
|
174
|
+
}
|
|
175
|
+
const d = { ...e === "palette" ? n : v };
|
|
176
|
+
delete d[r], i.replace(x(l, e, d), s("theme.removeSwatch", "Remove")), u(null);
|
|
177
|
+
}, $ = (e, r) => {
|
|
178
|
+
let t = Object.keys(e).length + 1;
|
|
179
|
+
for (; `${r}${t}` in e; )
|
|
180
|
+
t++;
|
|
181
|
+
return `${r}${t}`;
|
|
182
|
+
};
|
|
183
|
+
return /* @__PURE__ */ p("div", { className: "nice-theme-palette", children: [
|
|
184
|
+
/* @__PURE__ */ a("h4", { className: "nice-theme-palette__title", children: s("theme.palette", "Palette") }),
|
|
185
|
+
/* @__PURE__ */ a("p", { className: "nice-theme-set__hint", children: s(
|
|
186
|
+
"theme.paletteHint",
|
|
187
|
+
"Named colours any field can link to — change one here and every linked field follows."
|
|
188
|
+
) }),
|
|
189
|
+
/* @__PURE__ */ a("ul", { className: "nice-theme-palette__list", children: Object.entries(n).map(([e, r]) => {
|
|
190
|
+
const t = O(c, `palette.${e}`).length;
|
|
191
|
+
return /* @__PURE__ */ p("li", { className: "nice-theme-palette__item", "data-token": `palette.${e}`, children: [
|
|
192
|
+
/* @__PURE__ */ a(
|
|
193
|
+
T,
|
|
194
|
+
{
|
|
195
|
+
id: `${o}-p-${e}`,
|
|
196
|
+
"aria-label": s("theme.swatchName", "Name"),
|
|
197
|
+
size: "sm",
|
|
198
|
+
defaultValue: e,
|
|
199
|
+
onBlur: (l) => b("palette", e, l.target.value)
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
/* @__PURE__ */ a(
|
|
203
|
+
S,
|
|
204
|
+
{
|
|
205
|
+
id: `${o}-pc-${e}`,
|
|
206
|
+
"aria-label": e,
|
|
207
|
+
size: "sm",
|
|
208
|
+
compact: !0,
|
|
209
|
+
value: r,
|
|
210
|
+
onChange: (l) => i.set(`palette.${e}`, l)
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
t > 0 && /* @__PURE__ */ a("span", { className: "nice-theme-value__used", children: t }),
|
|
214
|
+
m === `palette.${e}` ? /* @__PURE__ */ p("span", { className: "nice-theme-palette__confirm", children: [
|
|
215
|
+
s("theme.removeUsed", "Linked fields keep their colour."),
|
|
216
|
+
/* @__PURE__ */ a(y, { size: "sm", variant: "danger", onClick: () => h("palette", e), children: s("theme.remove", "Remove") })
|
|
217
|
+
] }) : /* @__PURE__ */ a(
|
|
218
|
+
"button",
|
|
219
|
+
{
|
|
220
|
+
type: "button",
|
|
221
|
+
className: "nice-theme-set__reset",
|
|
222
|
+
"aria-label": s("theme.remove", "Remove"),
|
|
223
|
+
title: s("theme.remove", "Remove"),
|
|
224
|
+
onClick: () => t > 0 ? u(`palette.${e}`) : h("palette", e),
|
|
225
|
+
children: /* @__PURE__ */ a(N, { name: "trash", size: 12 })
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
] }, e);
|
|
229
|
+
}) }),
|
|
230
|
+
/* @__PURE__ */ p(
|
|
231
|
+
y,
|
|
232
|
+
{
|
|
233
|
+
size: "sm",
|
|
234
|
+
variant: "secondary",
|
|
235
|
+
onClick: () => i.set(
|
|
236
|
+
`palette.${$(n, "color")}`,
|
|
237
|
+
_(c, "colors.primary")?.color ?? ""
|
|
238
|
+
),
|
|
239
|
+
children: [
|
|
240
|
+
/* @__PURE__ */ a(N, { name: "plus", size: 12 }),
|
|
241
|
+
" ",
|
|
242
|
+
s("theme.addSwatch", "Add a colour")
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
),
|
|
246
|
+
/* @__PURE__ */ a("h4", { className: "nice-theme-palette__title", children: s("theme.gradients", "Gradients") }),
|
|
247
|
+
/* @__PURE__ */ a("ul", { className: "nice-theme-palette__list", children: Object.entries(v).map(([e, r]) => {
|
|
248
|
+
const t = typeof r == "string" ? r : r.css, l = _(c, `gradients.${e}`)?.css ?? t;
|
|
249
|
+
return /* @__PURE__ */ p("li", { className: "nice-theme-palette__item", "data-token": `gradients.${e}`, children: [
|
|
250
|
+
/* @__PURE__ */ a(
|
|
251
|
+
T,
|
|
252
|
+
{
|
|
253
|
+
id: `${o}-g-${e}`,
|
|
254
|
+
"aria-label": s("theme.swatchName", "Name"),
|
|
255
|
+
size: "sm",
|
|
256
|
+
defaultValue: e,
|
|
257
|
+
onBlur: (d) => b("gradients", e, d.target.value)
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ a(
|
|
261
|
+
"span",
|
|
262
|
+
{
|
|
263
|
+
className: "nice-theme-value__swatch nice-theme-palette__gradient",
|
|
264
|
+
style: { backgroundImage: l },
|
|
265
|
+
"aria-hidden": "true"
|
|
266
|
+
}
|
|
267
|
+
),
|
|
268
|
+
/* @__PURE__ */ a(
|
|
269
|
+
T,
|
|
270
|
+
{
|
|
271
|
+
id: `${o}-gc-${e}`,
|
|
272
|
+
"aria-label": e,
|
|
273
|
+
size: "sm",
|
|
274
|
+
value: t,
|
|
275
|
+
onChange: (d) => i.set(
|
|
276
|
+
`gradients.${e}`,
|
|
277
|
+
typeof r == "string" ? d : { ...r, css: d }
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
),
|
|
281
|
+
/* @__PURE__ */ a(
|
|
282
|
+
"button",
|
|
283
|
+
{
|
|
284
|
+
type: "button",
|
|
285
|
+
className: "nice-theme-set__reset",
|
|
286
|
+
"aria-label": s("theme.remove", "Remove"),
|
|
287
|
+
title: s("theme.remove", "Remove"),
|
|
288
|
+
onClick: () => h("gradients", e),
|
|
289
|
+
children: /* @__PURE__ */ a(N, { name: "trash", size: 12 })
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
] }, e);
|
|
293
|
+
}) }),
|
|
294
|
+
/* @__PURE__ */ p(
|
|
295
|
+
y,
|
|
296
|
+
{
|
|
297
|
+
size: "sm",
|
|
298
|
+
variant: "secondary",
|
|
299
|
+
onClick: () => {
|
|
300
|
+
const e = Object.keys(n)[0], r = e ? `{palette.${e}}` : _(c, "colors.primary")?.color ?? "", t = _(c, "colors.accent")?.color ?? r;
|
|
301
|
+
i.set(
|
|
302
|
+
`gradients.${$(v, "gradient")}`,
|
|
303
|
+
`linear-gradient(135deg, ${r} 0%, ${t} 100%)`
|
|
304
|
+
);
|
|
305
|
+
},
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ a(N, { name: "plus", size: 12 }),
|
|
308
|
+
" ",
|
|
309
|
+
s("theme.addGradient", "Add a gradient")
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
] });
|
|
314
|
+
}
|
|
315
|
+
const j = (o, c) => o && parseFloat(o) || c;
|
|
316
|
+
function se({
|
|
317
|
+
id: o,
|
|
318
|
+
theme: c,
|
|
319
|
+
edit: i,
|
|
320
|
+
onGoTo: s
|
|
321
|
+
}) {
|
|
322
|
+
const { t: n } = w(), v = c.scrollbar ?? {}, m = E(c).vars, u = Object.fromEntries(
|
|
323
|
+
Object.entries(m).filter(([h]) => h.startsWith("--nice-scrollbar-"))
|
|
324
|
+
), b = (h, $, e = "color") => /* @__PURE__ */ a(
|
|
325
|
+
R,
|
|
326
|
+
{
|
|
327
|
+
id: `${o}-${h}`,
|
|
328
|
+
label: $,
|
|
329
|
+
path: `scrollbar.${h}`,
|
|
330
|
+
theme: c,
|
|
331
|
+
kind: e,
|
|
332
|
+
onChange: (r, t) => i.set(r, t),
|
|
333
|
+
onGoTo: s
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
return /* @__PURE__ */ p("div", { className: "nice-theme-scrollbar", children: [
|
|
337
|
+
/* @__PURE__ */ p("div", { className: "nice-theme-builder__grid", children: [
|
|
338
|
+
b("track", n("theme.sbTrack", "Track")),
|
|
339
|
+
b("thumb", n("theme.sbThumb", "Thumb"), "surface"),
|
|
340
|
+
b("thumbHover", n("theme.sbThumbHover", "Thumb on hover")),
|
|
341
|
+
/* @__PURE__ */ a(
|
|
342
|
+
z,
|
|
343
|
+
{
|
|
344
|
+
id: `${o}-width`,
|
|
345
|
+
label: n("theme.sbWidth", "Track width (px)"),
|
|
346
|
+
labelPlacement: "left",
|
|
347
|
+
size: "sm",
|
|
348
|
+
min: 2,
|
|
349
|
+
max: 24,
|
|
350
|
+
value: j(v.width, 10),
|
|
351
|
+
onChange: (h) => i.set("scrollbar.width", typeof h == "number" ? `${h}px` : void 0)
|
|
352
|
+
}
|
|
353
|
+
),
|
|
354
|
+
/* @__PURE__ */ a(
|
|
355
|
+
z,
|
|
356
|
+
{
|
|
357
|
+
id: `${o}-thumb-width`,
|
|
358
|
+
label: n("theme.sbThumbWidth", "Thumb width (px)"),
|
|
359
|
+
labelPlacement: "left",
|
|
360
|
+
size: "sm",
|
|
361
|
+
min: 1,
|
|
362
|
+
max: 24,
|
|
363
|
+
value: j(v.thumbWidth, 6),
|
|
364
|
+
onChange: (h) => i.set("scrollbar.thumbWidth", typeof h == "number" ? `${h}px` : void 0)
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ a(
|
|
368
|
+
P,
|
|
369
|
+
{
|
|
370
|
+
id: `${o}-radius`,
|
|
371
|
+
label: n("theme.sbRadius", "Rounding"),
|
|
372
|
+
labelPlacement: "left",
|
|
373
|
+
size: "sm",
|
|
374
|
+
value: v.radius ?? "full",
|
|
375
|
+
options: [
|
|
376
|
+
{ value: "0px", label: n("theme.sbSquare", "Square") },
|
|
377
|
+
{ value: "2px", label: "2px" },
|
|
378
|
+
{ value: "4px", label: "4px" },
|
|
379
|
+
{ value: "full", label: n("theme.sbRound", "Round") }
|
|
380
|
+
],
|
|
381
|
+
onChange: (h) => i.set("scrollbar.radius", h)
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
] }),
|
|
385
|
+
/* @__PURE__ */ a(
|
|
386
|
+
"div",
|
|
387
|
+
{
|
|
388
|
+
className: "nice-theme-scrollbar__sample",
|
|
389
|
+
style: u,
|
|
390
|
+
"data-testid": "theme-scrollbar-sample",
|
|
391
|
+
children: /* @__PURE__ */ a("div", { className: "nice-theme-scrollbar__content", children: n("theme.sbSample", "Scroll me") })
|
|
392
|
+
}
|
|
393
|
+
)
|
|
394
|
+
] });
|
|
395
|
+
}
|
|
396
|
+
export {
|
|
397
|
+
te as ThemeColorSetEditor,
|
|
398
|
+
ae as ThemePaletteEditor,
|
|
399
|
+
se as ThemeScrollbarEditor
|
|
400
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { jsxs as u, jsx as l, Fragment as I } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as x, getThemeValue as E, parseThemeRef as F, isThemeGradient as N, resolveThemeValue as O, themeRefsOf as W, NiceIcon as k, wouldCreateCycle as B } from "@nice2dev/ui-core";
|
|
3
|
+
import { useState as M, useMemo as $ } from "react";
|
|
4
|
+
import { NiceSelect as P } from "../../editors/inputs/NiceSelect.mjs";
|
|
5
|
+
import { NiceTextInput as V } from "../../editors/inputs/NiceTextInput.mjs";
|
|
6
|
+
import { NiceColorPicker as R } from "../../editors/pickers/NiceColorPicker.mjs";
|
|
7
|
+
import { THEME_LINKABLE_FIELDS as U, themeGroupLabel as A, themeFieldLabel as z } from "./themeDesignerPaths.mjs";
|
|
8
|
+
function Y({
|
|
9
|
+
id: b,
|
|
10
|
+
label: g,
|
|
11
|
+
path: i,
|
|
12
|
+
theme: s,
|
|
13
|
+
kind: h = "color",
|
|
14
|
+
onChange: f,
|
|
15
|
+
onGoTo: y
|
|
16
|
+
}) {
|
|
17
|
+
const { t } = x(), r = E(s, i), _ = typeof r == "string" ? r : "", o = F(r), T = o ? "link" : N(_) ? "gradient" : "color", [L, p] = M(null), c = L ?? T, a = $(() => O(s, i), [s, i]), v = $(() => W(s, i), [s, i]), C = $(() => {
|
|
18
|
+
const e = [], m = (n, d) => {
|
|
19
|
+
n !== i && !B(s, i, n) && e.push({ value: n, label: d });
|
|
20
|
+
};
|
|
21
|
+
for (const n of Object.keys(s.palette ?? {}))
|
|
22
|
+
m(`palette.${n}`, `${t("theme.palette", "Palette")} · ${n}`);
|
|
23
|
+
if (h === "surface")
|
|
24
|
+
for (const n of Object.keys(s.gradients ?? {}))
|
|
25
|
+
m(`gradients.${n}`, `${t("theme.gradients", "Gradients")} · ${n}`);
|
|
26
|
+
for (const n of U)
|
|
27
|
+
for (const d of n.fields)
|
|
28
|
+
(h === "surface" || !d.surface) && m(d.path, `${A(n, t)} · ${t(d.key, d.label)}`);
|
|
29
|
+
return e;
|
|
30
|
+
}, [s, i, h, t]), j = (e) => {
|
|
31
|
+
if (e === T) {
|
|
32
|
+
p(null);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (e === "color")
|
|
36
|
+
p(null), f(i, a?.color ?? "");
|
|
37
|
+
else if (e === "gradient") {
|
|
38
|
+
p(null);
|
|
39
|
+
const m = a?.color ?? "transparent";
|
|
40
|
+
f(i, `linear-gradient(135deg, ${m} 0%, ${m} 100%)`);
|
|
41
|
+
} else
|
|
42
|
+
p("link");
|
|
43
|
+
}, w = c === "gradient" ? _ || (r && typeof r == "object" && "css" in r ? r.css : "") : "", S = a ? N(a.css) ? { backgroundImage: a.css } : { background: a.color } : void 0, G = [
|
|
44
|
+
{ id: "color", label: t("theme.mode.color", "Colour") },
|
|
45
|
+
...h === "surface" ? [{ id: "gradient", label: t("theme.mode.gradient", "Gradient") }] : [],
|
|
46
|
+
{ id: "link", label: t("theme.mode.link", "Link") }
|
|
47
|
+
];
|
|
48
|
+
return /* @__PURE__ */ u("div", { className: "nice-theme-value", "data-mode": c, children: [
|
|
49
|
+
/* @__PURE__ */ u("div", { className: "nice-theme-value__head", children: [
|
|
50
|
+
/* @__PURE__ */ l("span", { className: "nice-theme-value__label", children: g }),
|
|
51
|
+
v.length > 0 && /* @__PURE__ */ u(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
className: "nice-theme-value__used",
|
|
55
|
+
title: `${t("theme.usedBy", "Linked from")}: ${v.map((e) => z(e, t)).join(", ")}`,
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ l(k, { name: "link", size: 11 }),
|
|
58
|
+
v.length
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ l("span", { className: "nice-theme-value__modes", role: "group", "aria-label": g, children: G.map((e) => /* @__PURE__ */ l(
|
|
63
|
+
"button",
|
|
64
|
+
{
|
|
65
|
+
type: "button",
|
|
66
|
+
className: `nice-theme-value__mode${c === e.id ? " nice-theme-value__mode--on" : ""}`,
|
|
67
|
+
"aria-pressed": c === e.id,
|
|
68
|
+
onClick: () => j(e.id),
|
|
69
|
+
children: e.label
|
|
70
|
+
},
|
|
71
|
+
e.id
|
|
72
|
+
)) })
|
|
73
|
+
] }),
|
|
74
|
+
/* @__PURE__ */ u("div", { className: "nice-theme-value__body", children: [
|
|
75
|
+
/* @__PURE__ */ l("span", { className: "nice-theme-value__swatch", style: S, "aria-hidden": "true" }),
|
|
76
|
+
c === "color" && /* @__PURE__ */ l(
|
|
77
|
+
R,
|
|
78
|
+
{
|
|
79
|
+
id: b,
|
|
80
|
+
"aria-label": g,
|
|
81
|
+
size: "sm",
|
|
82
|
+
compact: !0,
|
|
83
|
+
value: _ || a?.color || "",
|
|
84
|
+
onChange: (e) => f(i, e)
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
c === "gradient" && /* @__PURE__ */ l(
|
|
88
|
+
V,
|
|
89
|
+
{
|
|
90
|
+
id: b,
|
|
91
|
+
"aria-label": g,
|
|
92
|
+
size: "sm",
|
|
93
|
+
value: w,
|
|
94
|
+
onChange: (e) => f(i, e)
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
c === "link" && /* @__PURE__ */ u(I, { children: [
|
|
98
|
+
o && !L ? /* @__PURE__ */ u("span", { className: "nice-theme-value__chip", "data-testid": "theme-link-chip", children: [
|
|
99
|
+
/* @__PURE__ */ l(k, { name: "link", size: 12 }),
|
|
100
|
+
/* @__PURE__ */ l("span", { className: "nice-theme-value__chip-text", children: o.startsWith("palette.") || o.startsWith("gradients.") ? o.split(".").slice(1).join(".") : z(o, t) }),
|
|
101
|
+
!o.startsWith("palette.") && !o.startsWith("gradients.") && y && /* @__PURE__ */ l(
|
|
102
|
+
"button",
|
|
103
|
+
{
|
|
104
|
+
type: "button",
|
|
105
|
+
className: "nice-theme-value__chip-btn",
|
|
106
|
+
title: t("theme.goToSource", "Go to the source"),
|
|
107
|
+
"aria-label": t("theme.goToSource", "Go to the source"),
|
|
108
|
+
onClick: () => y(o),
|
|
109
|
+
children: /* @__PURE__ */ l(k, { name: "arrow-right", size: 12 })
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ l(
|
|
113
|
+
"button",
|
|
114
|
+
{
|
|
115
|
+
type: "button",
|
|
116
|
+
className: "nice-theme-value__chip-btn",
|
|
117
|
+
title: t("theme.unlink", "Unlink — keep the colour"),
|
|
118
|
+
"aria-label": t("theme.unlink", "Unlink — keep the colour"),
|
|
119
|
+
onClick: () => j(
|
|
120
|
+
h === "surface" && a && N(a.css) ? "gradient" : "color"
|
|
121
|
+
),
|
|
122
|
+
children: /* @__PURE__ */ l(k, { name: "unlink", size: 12 })
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
] }) : null,
|
|
126
|
+
/* @__PURE__ */ l(
|
|
127
|
+
P,
|
|
128
|
+
{
|
|
129
|
+
id: `${b}-link`,
|
|
130
|
+
"aria-label": t("theme.linkTo", "Link to"),
|
|
131
|
+
size: "sm",
|
|
132
|
+
placeholder: t("theme.linkTo", "Link to…"),
|
|
133
|
+
value: o ?? "",
|
|
134
|
+
options: C,
|
|
135
|
+
onChange: (e) => {
|
|
136
|
+
p(null), e && f(i, `{${String(e)}}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
] })
|
|
141
|
+
] })
|
|
142
|
+
] });
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
Y as ThemeValueField
|
|
146
|
+
};
|