@directus/themes 1.1.1 → 1.1.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.
@@ -1,5 +1,6 @@
1
1
  import { MaybeRef } from 'vue';
2
2
  import { Theme } from '../schemas/theme.js';
3
- export declare const useFonts: (theme: MaybeRef<Theme>) => {
3
+ import { DeepPartial } from '@directus/types';
4
+ export declare const useFonts: (theme: MaybeRef<Theme | DeepPartial<Theme>>) => {
4
5
  googleFonts: import('vue').ComputedRef<string[]>;
5
6
  };
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
- import { computed as y, unref as f, reactive as B, defineComponent as $, toRefs as D, createBlock as G, openBlock as T, Teleport as _, createTextVNode as L, toDisplayString as M } from "vue";
2
- import { useHead as N } from "@unhead/vue";
1
+ import { computed as y, unref as f, reactive as $, defineComponent as B, toRefs as D, createBlock as G, openBlock as N, Teleport as T, createTextVNode as _, toDisplayString as L } from "vue";
2
+ import { useHead as M } from "@unhead/vue";
3
3
  import { get as W, merge as w, mapKeys as E } from "lodash-es";
4
4
  import { defineStore as U, storeToRefs as I } from "pinia";
5
5
  import P from "decamelize";
6
6
  import { flatten as V } from "flat";
7
7
  import { cssVar as z } from "@directus/utils/browser";
8
8
  import { Type as e } from "@sinclair/typebox";
9
- const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e.String({ $id: "FontWeight" }), h = e.String({ $id: "Length" }), p = e.String({ $id: "Percentage" }), k = e.String({ $id: "BoxShadow" }), j = e.String({ $id: "Number" }), H = e.String({ $id: "Size" }), s = e.Union([e.String(), e.Literal("thin"), e.Literal("medium"), e.Literal("thick")], {
9
+ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), s = e.String({ $id: "FontWeight" }), p = e.String({ $id: "Length" }), v = e.String({ $id: "Percentage" }), k = e.String({ $id: "BoxShadow" }), j = e.String({ $id: "Number" }), H = e.String({ $id: "Size" }), h = e.Union([e.String(), e.Literal("thin"), e.Literal("medium"), e.Literal("thick")], {
10
10
  $id: "LineWidth"
11
11
  }), S = e.Optional(
12
12
  e.Object({
13
- columnGap: e.Optional(e.Union([e.Ref(h), e.Ref(p)])),
14
- rowGap: e.Optional(e.Union([e.Ref(h), e.Ref(p)])),
13
+ columnGap: e.Optional(e.Union([e.Ref(p), e.Ref(v)])),
14
+ rowGap: e.Optional(e.Union([e.Ref(p), e.Ref(v)])),
15
15
  field: e.Optional(
16
16
  e.Object({
17
17
  label: e.Optional(
18
18
  e.Object({
19
19
  foreground: e.Optional(e.Ref(r)),
20
20
  fontFamily: e.Optional(e.Ref(i)),
21
- fontWeight: e.Optional(e.Ref(b))
21
+ fontWeight: e.Optional(e.Ref(s))
22
22
  })
23
23
  ),
24
24
  input: e.Optional(
@@ -34,7 +34,7 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
34
34
  boxShadowHover: e.Optional(e.Ref(k)),
35
35
  boxShadowFocus: e.Optional(e.Ref(k)),
36
36
  height: e.Optional(e.Ref(H)),
37
- padding: e.Optional(e.Union([e.Ref(h), e.Ref(p)]))
37
+ padding: e.Optional(e.Union([e.Ref(p), e.Ref(v)]))
38
38
  })
39
39
  )
40
40
  })
@@ -43,8 +43,8 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
43
43
  ), K = e.Object({
44
44
  //////////////////////////////////////////////////////////////////////////////////////////////////////////
45
45
  // Base border styles
46
- borderRadius: e.Optional(e.Union([e.Ref(h), e.Ref(p)])),
47
- borderWidth: e.Optional(e.Ref(s)),
46
+ borderRadius: e.Optional(e.Union([e.Ref(p), e.Ref(v)])),
47
+ borderWidth: e.Optional(e.Ref(h)),
48
48
  //////////////////////////////////////////////////////////////////////////////////////////////////////////
49
49
  // Base color palette
50
50
  foreground: e.Optional(e.Ref(r)),
@@ -84,25 +84,25 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
84
84
  display: e.Optional(
85
85
  e.Object({
86
86
  fontFamily: e.Optional(e.Ref(i)),
87
- fontWeight: e.Optional(e.Ref(b))
87
+ fontWeight: e.Optional(e.Ref(s))
88
88
  })
89
89
  ),
90
90
  sans: e.Optional(
91
91
  e.Object({
92
92
  fontFamily: e.Optional(e.Ref(i)),
93
- fontWeight: e.Optional(e.Ref(b))
93
+ fontWeight: e.Optional(e.Ref(s))
94
94
  })
95
95
  ),
96
96
  serif: e.Optional(
97
97
  e.Object({
98
98
  fontFamily: e.Optional(e.Ref(i)),
99
- fontWeight: e.Optional(e.Ref(b))
99
+ fontWeight: e.Optional(e.Ref(s))
100
100
  })
101
101
  ),
102
102
  monospace: e.Optional(
103
103
  e.Object({
104
104
  fontFamily: e.Optional(e.Ref(i)),
105
- fontWeight: e.Optional(e.Ref(b))
105
+ fontWeight: e.Optional(e.Ref(s))
106
106
  })
107
107
  )
108
108
  })
@@ -113,21 +113,21 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
113
113
  e.Object({
114
114
  background: e.Optional(e.Ref(r)),
115
115
  backgroundAccent: e.Optional(e.Ref(r)),
116
- borderWidth: e.Optional(e.Ref(s)),
116
+ borderWidth: e.Optional(e.Ref(h)),
117
117
  borderColor: e.Optional(e.Ref(r)),
118
118
  project: e.Optional(
119
119
  e.Object({
120
120
  background: e.Optional(e.Ref(r)),
121
121
  foreground: e.Optional(e.Ref(r)),
122
122
  fontFamily: e.Optional(e.Ref(i)),
123
- borderWidth: e.Optional(e.Ref(s)),
123
+ borderWidth: e.Optional(e.Ref(h)),
124
124
  borderColor: e.Optional(e.Ref(r))
125
125
  })
126
126
  ),
127
127
  modules: e.Optional(
128
128
  e.Object({
129
129
  background: e.Optional(e.Ref(r)),
130
- borderWidth: e.Optional(e.Ref(s)),
130
+ borderWidth: e.Optional(e.Ref(h)),
131
131
  borderColor: e.Optional(e.Ref(r)),
132
132
  button: e.Optional(
133
133
  e.Object({
@@ -159,7 +159,7 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
159
159
  fontFamily: e.Optional(e.Ref(i)),
160
160
  divider: e.Object({
161
161
  borderColor: e.Optional(e.Ref(r)),
162
- borderWidth: e.Optional(e.Ref(s))
162
+ borderWidth: e.Optional(e.Ref(h))
163
163
  })
164
164
  })
165
165
  )
@@ -168,7 +168,7 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
168
168
  header: e.Optional(
169
169
  e.Object({
170
170
  background: e.Optional(e.Ref(r)),
171
- borderWidth: e.Optional(e.Ref(s)),
171
+ borderWidth: e.Optional(e.Ref(h)),
172
172
  borderColor: e.Optional(e.Ref(r)),
173
173
  boxShadow: e.Optional(e.Ref(k)),
174
174
  headline: e.Optional(
@@ -181,7 +181,7 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
181
181
  e.Object({
182
182
  foreground: e.Optional(e.Ref(r)),
183
183
  fontFamily: e.Optional(e.Ref(i)),
184
- fontWeight: e.Optional(e.Ref(b))
184
+ fontWeight: e.Optional(e.Ref(s))
185
185
  })
186
186
  )
187
187
  })
@@ -192,7 +192,7 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
192
192
  background: e.Optional(e.Ref(r)),
193
193
  foreground: e.Optional(e.Ref(r)),
194
194
  fontFamily: e.Optional(e.Ref(i)),
195
- borderWidth: e.Optional(e.Ref(s)),
195
+ borderWidth: e.Optional(e.Ref(h)),
196
196
  borderColor: e.Optional(e.Ref(r)),
197
197
  section: e.Optional(
198
198
  e.Object({
@@ -212,7 +212,7 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
212
212
  backgroundHover: e.Optional(e.Ref(r)),
213
213
  backgroundActive: e.Optional(e.Ref(r)),
214
214
  fontFamily: e.Optional(e.Ref(i)),
215
- borderWidth: e.Optional(e.Ref(s)),
215
+ borderWidth: e.Optional(e.Ref(h)),
216
216
  borderColor: e.Optional(e.Ref(r))
217
217
  })
218
218
  ),
@@ -242,7 +242,7 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
242
242
  menu: e.Optional(
243
243
  e.Object({
244
244
  background: e.Optional(e.Ref(r)),
245
- borderRadius: e.Optional(e.Optional(e.Union([e.Ref(h), e.Ref(p)]))),
245
+ borderRadius: e.Optional(e.Optional(e.Union([e.Ref(p), e.Ref(v)]))),
246
246
  boxShadow: e.Optional(e.Ref(k))
247
247
  })
248
248
  )
@@ -251,34 +251,34 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
251
251
  banner: e.Optional(
252
252
  e.Object({
253
253
  background: e.Optional(e.Ref(r)),
254
- padding: e.Optional(e.Union([e.Ref(h), e.Ref(p)])),
255
- borderRadius: e.Optional(e.Optional(e.Union([e.Ref(h), e.Ref(p)]))),
254
+ padding: e.Optional(e.Union([e.Ref(p), e.Ref(v)])),
255
+ borderRadius: e.Optional(e.Optional(e.Union([e.Ref(p), e.Ref(v)]))),
256
256
  avatar: e.Optional(
257
257
  e.Object({
258
258
  background: e.Optional(e.Ref(r)),
259
259
  foreground: e.Optional(e.Ref(r)),
260
- borderRadius: e.Optional(e.Optional(e.Union([e.Ref(h), e.Ref(p)])))
260
+ borderRadius: e.Optional(e.Optional(e.Union([e.Ref(p), e.Ref(v)])))
261
261
  })
262
262
  ),
263
263
  headline: e.Optional(
264
264
  e.Object({
265
265
  foreground: e.Optional(e.Ref(r)),
266
266
  fontFamily: e.Optional(e.Ref(i)),
267
- fontWeight: e.Optional(e.Ref(b))
267
+ fontWeight: e.Optional(e.Ref(s))
268
268
  })
269
269
  ),
270
270
  title: e.Optional(
271
271
  e.Object({
272
272
  foreground: e.Optional(e.Ref(r)),
273
273
  fontFamily: e.Optional(e.Ref(i)),
274
- fontWeight: e.Optional(e.Ref(b))
274
+ fontWeight: e.Optional(e.Ref(s))
275
275
  })
276
276
  ),
277
277
  subtitle: e.Optional(
278
278
  e.Object({
279
279
  foreground: e.Optional(e.Ref(r)),
280
280
  fontFamily: e.Optional(e.Ref(i)),
281
- fontWeight: e.Optional(e.Ref(b))
281
+ fontWeight: e.Optional(e.Ref(s))
282
282
  })
283
283
  ),
284
284
  art: e.Optional(
@@ -297,49 +297,49 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
297
297
  $defs: {
298
298
  Color: r,
299
299
  FamilyName: i,
300
- Length: h,
301
- Percentage: p,
302
- LineWidth: s,
300
+ Length: p,
301
+ Percentage: v,
302
+ LineWidth: h,
303
303
  BoxShadow: k,
304
304
  Size: H,
305
305
  Number: j
306
306
  }
307
307
  }, q = (d) => {
308
- const v = y(() => {
309
- const o = /* @__PURE__ */ new Map(), c = (m, t = []) => {
310
- for (const [a, n] of Object.entries(m))
311
- typeof n == "object" && n !== null && ("type" in n && n.type === "object" && "properties" in n && c(n.properties, [...t, a]), "$ref" in n && n.$ref === "FamilyName" && (o.has(t) ? o.set(t, { family: a, weight: o.get(t).weight }) : o.set(t, { family: a, weight: null })), "$ref" in n && n.$ref === "FontWeight" && (o.has(t) ? o.set(t, { family: o.get(t).family, weight: a }) : o.set(t, { family: null, weight: a })));
308
+ const F = y(() => {
309
+ const n = /* @__PURE__ */ new Map(), c = (b, t = []) => {
310
+ for (const [a, o] of Object.entries(b))
311
+ typeof o == "object" && o !== null && ("type" in o && o.type === "object" && "properties" in o && c(o.properties, [...t, a]), "$ref" in o && o.$ref === "FamilyName" && (n.has(t) ? n.set(t, { family: a, weight: n.get(t).weight }) : n.set(t, { family: a, weight: null })), "$ref" in o && o.$ref === "FontWeight" && (n.has(t) ? n.set(t, { family: n.get(t).family, weight: a }) : n.set(t, { family: null, weight: a })));
312
312
  };
313
- return c(Q.properties.rules.properties), o;
313
+ return c(Q.properties.rules.properties), n;
314
314
  }), u = y(() => {
315
- const o = /* @__PURE__ */ new Map();
316
- for (const [c, { family: m, weight: t }] of v.value.entries()) {
317
- let a = null, n = null;
318
- if (m && (a = W(f(d).rules, [...c, m])), t && (n = W(f(d).rules, [...c, t])), a) {
319
- const F = a.split(",");
320
- for (const l of F) {
321
- const g = l.trim();
315
+ const n = /* @__PURE__ */ new Map();
316
+ for (const [c, { family: b, weight: t }] of F.value.entries()) {
317
+ let a = null, o = null;
318
+ if (b && (a = W(f(d).rules, [...c, b])), t && (o = W(f(d).rules, [...c, t])), a) {
319
+ const l = a.split(",");
320
+ for (const m of l) {
321
+ const g = m.trim();
322
322
  if (g.startsWith("var(--")) {
323
- F.push(z(g.slice(6, -1)));
323
+ l.push(z(g.slice(6, -1)));
324
324
  continue;
325
325
  }
326
326
  if ((g.startsWith('"') && g.endsWith('"')) === !1)
327
327
  continue;
328
328
  const x = g.slice(1, -1);
329
- o.has(x) ? o.get(x).add(n ?? "400") : o.set(x, /* @__PURE__ */ new Set([n ?? "400"]));
329
+ n.has(x) ? n.get(x).add(o ?? "400") : n.set(x, /* @__PURE__ */ new Set([o ?? "400"]));
330
330
  }
331
331
  }
332
332
  }
333
- return o;
333
+ return n;
334
334
  });
335
335
  return { googleFonts: y(() => {
336
- const o = [];
337
- for (const [c, m] of u.value.entries())
336
+ const n = [];
337
+ for (const [c, b] of u.value.entries())
338
338
  if (["Inter", "Merriweather", "Fira Mono"].includes(c) === !1) {
339
- const a = Array.from(m).join(";");
340
- o.push(`${c.replace(" ", "+")}:wght@${a}`);
339
+ const a = Array.from(b).sort((o, l) => Number(o) - Number(l)).join(";");
340
+ n.push(`${c.replaceAll(" ", "+")}:wght@${a}`);
341
341
  }
342
- return o;
342
+ return n;
343
343
  }) };
344
344
  }, R = (d) => d, A = R({
345
345
  id: "Directus Default",
@@ -1057,20 +1057,20 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
1057
1057
  }
1058
1058
  }
1059
1059
  }), Y = [A], Z = [C, X, J], ee = U("🎨 Themes", () => {
1060
- const d = B({ light: Z, dark: Y });
1060
+ const d = $({ light: Z, dark: Y });
1061
1061
  return { themes: d, registerTheme: (u) => {
1062
1062
  u.appearance === "light" ? d.light.push(u) : d.dark.push(u);
1063
1063
  } };
1064
- }), re = (d, v, u, O, o) => {
1064
+ }), re = (d, F, u, O, n) => {
1065
1065
  const { themes: c } = I(ee());
1066
1066
  return { theme: y(() => {
1067
- const t = f(d) ? f(u) : f(v), a = f(d) ? A : C, n = f(d) ? f(o) : f(O), F = f(c)[f(d) ? "dark" : "light"].find((l) => l.id === t);
1068
- return F ? n ? w({}, a, F, { rules: n }) : w(a, F) : (t && t !== a.id && console.warn(`Theme "${t}" doesn't exist.`), n ? w({}, a, { rules: n }) : a);
1067
+ const t = f(d) ? f(u) : f(F), a = f(d) ? A : C, o = f(d) ? f(n) : f(O), l = f(c)[f(d) ? "dark" : "light"].find((m) => m.id === t);
1068
+ return l ? o ? w({}, a, l, { rules: o }) : w(a, l) : (t && t !== a.id && console.warn(`Theme "${t}" doesn't exist.`), o ? w({}, a, { rules: o }) : a);
1069
1069
  }) };
1070
1070
  }, oe = (d) => {
1071
- const v = V(d, { delimiter: "--" }), u = (O) => `--theme--${P(O, { separator: "-" })}`;
1072
- return E(v, (O, o) => u(o));
1073
- }, ge = /* @__PURE__ */ $({
1071
+ const F = V(d, { delimiter: "--" }), u = (O) => `--theme--${P(O, { separator: "-" })}`;
1072
+ return E(F, (O, n) => u(n));
1073
+ }, me = /* @__PURE__ */ B({
1074
1074
  __name: "theme-provider",
1075
1075
  props: {
1076
1076
  darkMode: { type: Boolean },
@@ -1080,32 +1080,32 @@ const r = e.String({ $id: "Color" }), i = e.String({ $id: "FamilyName" }), b = e
1080
1080
  themeDarkOverrides: { default: () => ({}) }
1081
1081
  },
1082
1082
  setup(d) {
1083
- const v = d, { darkMode: u, themeLight: O, themeDark: o, themeLightOverrides: c, themeDarkOverrides: m } = D(v), { theme: t } = re(u, O, o, c, m), a = y(() => oe(f(t).rules)), { googleFonts: n } = q(t);
1084
- N({
1083
+ const F = d, { darkMode: u, themeLight: O, themeDark: n, themeLightOverrides: c, themeDarkOverrides: b } = D(F), { theme: t } = re(u, O, n, c, b), a = y(() => oe(f(t).rules)), { googleFonts: o } = q(t);
1084
+ M({
1085
1085
  link: y(() => {
1086
- let l = "";
1087
- if (n.value.length > 0) {
1088
- const g = n.value.join("&family=");
1089
- l += `https://fonts.googleapis.com/css2?family=${g}`, l += `
1086
+ let m = "";
1087
+ if (o.value.length > 0) {
1088
+ const g = o.value.join("&family=");
1089
+ m += `https://fonts.googleapis.com/css2?family=${g}`, m += `
1090
1090
  `;
1091
1091
  }
1092
- return l ? [
1092
+ return m ? [
1093
1093
  {
1094
1094
  rel: "stylesheet",
1095
- href: l
1095
+ href: m
1096
1096
  }
1097
1097
  ] : [];
1098
1098
  })
1099
1099
  });
1100
- const F = y(() => `:root {${Object.entries(f(a)).map(([g, x]) => `${g}: ${x};`).join(" ")}}`);
1101
- return (l, g) => (T(), G(_, { to: "#theme" }, [
1102
- L(M(F.value), 1)
1100
+ const l = y(() => `:root {${Object.entries(f(a)).map(([g, x]) => `${g}: ${x};`).join(" ")}}`);
1101
+ return (m, g) => (N(), G(T, { to: "#theme" }, [
1102
+ _(L(l.value), 1)
1103
1103
  ]));
1104
1104
  }
1105
1105
  });
1106
1106
  export {
1107
1107
  le as Definitions,
1108
- ge as ThemeProvider,
1108
+ me as ThemeProvider,
1109
1109
  Q as ThemeSchema,
1110
1110
  R as defineTheme,
1111
1111
  oe as rulesToCssVars,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directus/themes",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Themes for Directus",
5
5
  "homepage": "https://directus.io",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "decamelize": "6.0.0",
27
27
  "flat": "6.0.1",
28
28
  "lodash-es": "4.17.21",
29
- "@directus/utils": "13.0.6"
29
+ "@directus/utils": "13.0.8"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@directus/tsconfig": "3.0.0",
@@ -35,11 +35,12 @@
35
35
  "@vitejs/plugin-vue": "5.2.1",
36
36
  "pinia": "2.3.1",
37
37
  "rollup-plugin-node-externals": "8.0.0",
38
- "typescript": "5.8.2",
39
- "vite": "5.4.14",
38
+ "typescript": "5.8.3",
39
+ "vite": "5.4.19",
40
40
  "vite-plugin-dts": "4.5.1",
41
+ "vitest": "3.2.4",
41
42
  "vue": "3.5.13",
42
- "@directus/types": "13.1.2"
43
+ "@directus/types": "13.2.0"
43
44
  },
44
45
  "peerDependencies": {
45
46
  "@unhead/vue": "1",
@@ -48,6 +49,8 @@
48
49
  },
49
50
  "scripts": {
50
51
  "build": "vite build",
51
- "dev": "vite build --watch"
52
+ "dev": "vite build --watch",
53
+ "test": "vitest run",
54
+ "test:watch": "vitest"
52
55
  }
53
56
  }