@filipgutica/ui 0.2.2 → 1.0.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/dist/theme.js CHANGED
@@ -1,375 +1,2 @@
1
- import { parse as e, printParseErrorCode as t } from "jsonc-parser";
2
- //#region src/theme/index.ts
3
- var n = class extends Error {
4
- code;
5
- constructor(e, t) {
6
- super(t), this.name = "ThemeValidationError", this.code = e;
7
- }
8
- }, r = /* @__PURE__ */ "pageBackground.surface.surfaceRaised.surfaceMuted.textPrimary.textMuted.border.borderSubtle.link.accent.focus.buttonBackground.buttonForeground.buttonHoverBackground.inputBackground.inputForeground.inputBorder.inputPlaceholder.rowHoverBackground.rowSelectedBackground.rowSelectedForeground.codeBackground.codeForeground.error.warning.success.info.progress".split("."), i = /* @__PURE__ */ new Set(/* @__PURE__ */ "editor.background,editor.foreground,foreground,sideBar.background,panel.background,editorWidget.background,descriptionForeground,disabledForeground,panel.border,sideBar.border,contrastBorder,contrastActiveBorder,focusBorder,textLink.foreground,textLink.activeForeground,button.background,button.foreground,button.hoverBackground,input.background,input.foreground,input.border,input.placeholderForeground,list.hoverBackground,list.activeSelectionBackground,list.activeSelectionForeground,list.inactiveSelectionBackground,list.inactiveSelectionForeground,errorForeground,editorError.foreground,notificationsErrorIcon.foreground,notificationsWarningIcon.foreground,editorWarning.foreground,notificationsInfoIcon.foreground,editorInfo.foreground,testing.iconPassed,terminal.ansiGreen,progressBar.background".split(",")), a = {
9
- pageBackground: "#EFF1F5",
10
- surface: "#E6E9EF",
11
- surfaceRaised: "#FFFFFF",
12
- surfaceMuted: "#DCE0E8",
13
- textPrimary: "#4C4F69",
14
- textMuted: "#6C6F85",
15
- border: "#ACB0BE",
16
- borderSubtle: "#CCD0DA",
17
- link: "#1E66F5",
18
- accent: "#8839EF",
19
- focus: "#1E66F5",
20
- buttonBackground: "#1E66F5",
21
- buttonForeground: "#FFFFFF",
22
- buttonHoverBackground: "#1A5AD7",
23
- inputBackground: "#FFFFFF",
24
- inputForeground: "#4C4F69",
25
- inputBorder: "#9CA0B0",
26
- inputPlaceholder: "#7C7F93",
27
- rowHoverBackground: "#DCE0E8",
28
- rowSelectedBackground: "#D9E2FA",
29
- rowSelectedForeground: "#4C4F69",
30
- codeBackground: "#E6E9EF",
31
- codeForeground: "#4C4F69",
32
- error: "#D20F39",
33
- warning: "#8A5600",
34
- success: "#287D3C",
35
- info: "#176B87",
36
- progress: "#8839EF"
37
- }, o = {
38
- pageBackground: "#1E1E2E",
39
- surface: "#181825",
40
- surfaceRaised: "#242435",
41
- surfaceMuted: "#313244",
42
- textPrimary: "#CDD6F4",
43
- textMuted: "#A6ADC8",
44
- border: "#585B70",
45
- borderSubtle: "#45475A",
46
- link: "#89B4FA",
47
- accent: "#CBA6F7",
48
- focus: "#89B4FA",
49
- buttonBackground: "#89B4FA",
50
- buttonForeground: "#11111B",
51
- buttonHoverBackground: "#B4BEFE",
52
- inputBackground: "#11111B",
53
- inputForeground: "#CDD6F4",
54
- inputBorder: "#6C7086",
55
- inputPlaceholder: "#9399B2",
56
- rowHoverBackground: "#313244",
57
- rowSelectedBackground: "#45475A",
58
- rowSelectedForeground: "#CDD6F4",
59
- codeBackground: "#11111B",
60
- codeForeground: "#CDD6F4",
61
- error: "#F38BA8",
62
- warning: "#F9E2AF",
63
- success: "#A6E3A1",
64
- info: "#89DCEB",
65
- progress: "#CBA6F7"
66
- }, s = (e) => typeof e == "object" && !!e && !Array.isArray(e), c = (e) => typeof e == "string" && /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e), l = (e) => typeof e == "string" && /^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/i.test(e), u = (e) => e.length === 4 || e.length === 5 ? `#${[...e.slice(1)].map((e) => e.repeat(2)).join("")}` : e, d = (e) => {
67
- let t = e.length === 4 || e.length === 5 ? [...e.slice(1)].map((e) => e.repeat(2)).join("") : e.slice(1);
68
- return [
69
- Number.parseInt(t.slice(0, 2), 16),
70
- Number.parseInt(t.slice(2, 4), 16),
71
- Number.parseInt(t.slice(4, 6), 16),
72
- t.length === 8 ? Number.parseInt(t.slice(6, 8), 16) / 255 : 1
73
- ];
74
- }, f = (e, t, n) => {
75
- let [r, i, a] = d(n), o = (e) => {
76
- let [t, n, o, s] = d(e);
77
- return [
78
- t * s + r * (1 - s),
79
- n * s + i * (1 - s),
80
- o * s + a * (1 - s)
81
- ];
82
- }, s = ([e, t, n]) => {
83
- let r = [
84
- e,
85
- t,
86
- n
87
- ].map((e) => {
88
- let t = e / 255;
89
- return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
90
- });
91
- return .2126 * r[0] + .7152 * r[1] + .0722 * r[2];
92
- }, c = s(o(e)), l = s(o(t));
93
- return (Math.max(c, l) + .05) / (Math.min(c, l) + .05);
94
- }, p = ({ background: e, preferred: t, underlay: n }) => f(t, e, n) >= 4.5 ? t : [
95
- t,
96
- "#000000",
97
- "#FFFFFF"
98
- ].reduce((t, r) => f(r, e, n) > f(t, e, n) ? r : t), m = ({ color: e, against: t, fallback: n }) => f(e, t, t) >= 3 ? e : f(n, t, t) >= 3 ? n : p({
99
- background: t,
100
- preferred: n,
101
- underlay: t
102
- }), h = ({ color: e, background: t, underlay: n, fallback: r }) => f(e, t, n) >= 4.5 ? e : p({
103
- background: t,
104
- preferred: r,
105
- underlay: n
106
- }), g = ({ color: e, backgrounds: t, underlay: n, fallbacks: r }) => {
107
- let i = [e, ...r];
108
- return i.find((e) => t.every((t) => f(e, t, n) >= 4.5)) || i.reduce((e, r) => Math.min(...t.map((e) => f(r, e, n))) > Math.min(...t.map((t) => f(e, t, n))) ? r : e);
109
- }, _ = (e, t) => d(e)[3] === 1 ? e : t, v = (e) => {
110
- let [t, n, r] = d(e);
111
- return (.2126 * t + .7152 * n + .0722 * r) / 255 < .5 ? "dark" : "light";
112
- }, y = (e, t) => {
113
- if (e === void 0) return v(t);
114
- if (e === "light") return "light";
115
- if (e === "dark") return "dark";
116
- if (e === "hc") return "high-contrast-dark";
117
- if (e === "hcLight") return "high-contrast-light";
118
- throw new n("unsupported-type", "The theme type must be \"light\", \"dark\", \"hc\", or \"hcLight\".");
119
- }, b = (e, t, n) => {
120
- for (let n of t) {
121
- let t = e[n];
122
- if (c(t)) return u(t);
123
- }
124
- return n;
125
- }, x = (e, t) => {
126
- let n = e.slice(0, t).split("\n");
127
- return {
128
- line: n.length,
129
- column: (n.at(-1)?.length ?? 0) + 1
130
- };
131
- }, S = (e) => ((e.split(/[\\/]/).at(-1) ?? "Imported theme").replace(/\.jsonc?$/i, "") || "Imported theme").slice(0, 80), C = ({ colors: e, appearance: t, background: n, foreground: r }) => {
132
- let i = t === "dark" || t === "high-contrast-dark" ? o : a, s = b(e, t.startsWith("high-contrast") ? [
133
- "contrastBorder",
134
- "contrastActiveBorder",
135
- "panel.border",
136
- "sideBar.border",
137
- "focusBorder"
138
- ] : [
139
- "panel.border",
140
- "sideBar.border",
141
- "contrastBorder",
142
- "input.border",
143
- "focusBorder"
144
- ], i.border), c = t.startsWith("high-contrast") ? m({
145
- color: s,
146
- against: n,
147
- fallback: i.border
148
- }) : s, l = b(e, [
149
- "textLink.foreground",
150
- "focusBorder",
151
- "progressBar.background",
152
- "button.background"
153
- ], i.link), u = b(e, [
154
- "focusBorder",
155
- "progressBar.background",
156
- "textLink.foreground",
157
- "button.background"
158
- ], l), d = p({
159
- background: n,
160
- preferred: r,
161
- underlay: n
162
- }), _ = b(e, [
163
- "sideBar.background",
164
- "panel.background",
165
- "editor.background"
166
- ], i.surface), v = f(d, _, n) >= 4.5 ? _ : n, y = b(e, [
167
- "panel.background",
168
- "sideBar.background",
169
- "editorWidget.background",
170
- "editor.background"
171
- ], v), x = f(d, y, n) >= 4.5 ? y : v, S = g({
172
- color: l,
173
- backgrounds: [n, v],
174
- underlay: n,
175
- fallbacks: [i.link, d]
176
- }), C = m({
177
- color: u,
178
- against: v,
179
- fallback: i.accent
180
- }), w = g({
181
- color: b(e, [
182
- "descriptionForeground",
183
- "disabledForeground",
184
- "foreground",
185
- "editor.foreground"
186
- ], i.textMuted),
187
- backgrounds: [n, v],
188
- underlay: n,
189
- fallbacks: [i.textMuted, d]
190
- }), T = b(e, [
191
- "editorWidget.background",
192
- "list.hoverBackground",
193
- "sideBar.background",
194
- "panel.background"
195
- ], i.surfaceMuted), E = f(d, T, v) >= 4.5 && f(w, T, v) >= 4.5 ? T : v, D = b(e, ["button.background"], i.buttonBackground), O = p({
196
- background: D,
197
- preferred: b(e, ["button.foreground"], i.buttonForeground),
198
- underlay: v
199
- }), k = b(e, ["button.hoverBackground", "button.background"], i.buttonHoverBackground), A = f(O, k, v) >= 4.5 ? k : D, j = b(e, [
200
- "focusBorder",
201
- "contrastActiveBorder",
202
- "textLink.activeForeground"
203
- ], i.focus), M = b(e, [
204
- "panel.border",
205
- "sideBar.border",
206
- "contrastBorder"
207
- ], c), N = t.startsWith("high-contrast") ? m({
208
- color: M,
209
- against: v,
210
- fallback: c
211
- }) : M, P = b(e, ["input.background"], v), F = b(e, t.startsWith("high-contrast") ? [
212
- "contrastBorder",
213
- "input.border",
214
- "focusBorder"
215
- ] : [
216
- "input.border",
217
- "contrastBorder",
218
- "focusBorder"
219
- ], c), I = (t, r) => h({
220
- color: b(e, t, r),
221
- background: v,
222
- underlay: n,
223
- fallback: r
224
- }), L = b(e, ["list.hoverBackground"], i.rowHoverBackground), R = f(d, L, v) >= 4.5 ? L : v;
225
- return {
226
- pageBackground: n,
227
- surface: v,
228
- surfaceRaised: x,
229
- surfaceMuted: E,
230
- textPrimary: d,
231
- textMuted: w,
232
- border: c,
233
- borderSubtle: N,
234
- link: S,
235
- accent: C,
236
- focus: m({
237
- color: j,
238
- against: n,
239
- fallback: i.focus
240
- }),
241
- buttonBackground: D,
242
- buttonForeground: O,
243
- buttonHoverBackground: A,
244
- inputBackground: P,
245
- inputForeground: p({
246
- background: P,
247
- preferred: b(e, [
248
- "input.foreground",
249
- "editor.foreground",
250
- "foreground"
251
- ], d),
252
- underlay: v
253
- }),
254
- inputBorder: t.startsWith("high-contrast") ? m({
255
- color: F,
256
- against: P,
257
- fallback: c
258
- }) : F,
259
- inputPlaceholder: h({
260
- color: b(e, ["input.placeholderForeground", "descriptionForeground"], w),
261
- background: P,
262
- underlay: v,
263
- fallback: i.textMuted
264
- }),
265
- rowHoverBackground: R,
266
- rowSelectedBackground: b(e, ["list.activeSelectionBackground", "list.inactiveSelectionBackground"], i.rowSelectedBackground),
267
- rowSelectedForeground: p({
268
- background: b(e, ["list.activeSelectionBackground", "list.inactiveSelectionBackground"], i.rowSelectedBackground),
269
- preferred: b(e, ["list.activeSelectionForeground", "list.inactiveSelectionForeground"], i.rowSelectedForeground),
270
- underlay: v
271
- }),
272
- codeBackground: b(e, ["editor.background"], i.codeBackground),
273
- codeForeground: p({
274
- background: b(e, ["editor.background"], i.codeBackground),
275
- preferred: b(e, ["editor.foreground", "foreground"], i.codeForeground),
276
- underlay: n
277
- }),
278
- error: I([
279
- "errorForeground",
280
- "notificationsErrorIcon.foreground",
281
- "editorError.foreground"
282
- ], i.error),
283
- warning: I(["notificationsWarningIcon.foreground", "editorWarning.foreground"], i.warning),
284
- success: I(["testing.iconPassed", "terminal.ansiGreen"], i.success),
285
- info: I([
286
- "notificationsInfoIcon.foreground",
287
- "editorInfo.foreground",
288
- "textLink.foreground"
289
- ], i.info),
290
- progress: m({
291
- color: b(e, [
292
- "progressBar.background",
293
- "focusBorder",
294
- "textLink.foreground"
295
- ], C),
296
- against: E,
297
- fallback: i.progress
298
- })
299
- };
300
- }, w = ({ source: r, fileName: l }) => {
301
- let u = [], d = e(r, u, { allowTrailingComma: !0 }), f = u[0];
302
- if (f) {
303
- let { line: e, column: i } = x(r, f.offset);
304
- throw new n("malformed-json", `The theme could not be parsed (${t(f.error)} at line ${e}, column ${i}).`);
305
- }
306
- if (!s(d)) throw new n("invalid-shape", "The theme file must contain a JSON object.");
307
- if (d.name !== void 0 && typeof d.name != "string") throw new n("invalid-shape", "The theme name must be a string when provided.");
308
- if (!s(d.colors)) throw new n("invalid-shape", "The theme must contain a \"colors\" object.");
309
- let p = d.colors;
310
- for (let e of i) {
311
- let t = p[e];
312
- if (t !== void 0 && !c(t)) throw new n("invalid-color", `The color for "${e}" must be a 3-, 4-, 6-, or 8-digit hexadecimal value.`);
313
- }
314
- let m = b(p, [
315
- "editor.background",
316
- "sideBar.background",
317
- "panel.background"
318
- ], ""), h = b(p, ["editor.foreground", "foreground"], "");
319
- if (!m || !h) throw new n("missing-colors", "The theme must define a supported background color and foreground color.");
320
- let g = y(d.type, m), v = _(m, (g === "dark" || g === "high-contrast-dark" ? o : a).pageBackground);
321
- return {
322
- name: d.name?.trim().replace(/\s+/g, " ").slice(0, 80) || S(l),
323
- appearance: g,
324
- tokens: C({
325
- colors: p,
326
- appearance: g,
327
- background: v,
328
- foreground: h
329
- })
330
- };
331
- }, T = (e) => {
332
- if (!s(e) || typeof e.name != "string" || e.name.trim().length === 0 || e.name.length > 80) return !1;
333
- let t = e.appearance;
334
- if (t !== "light" && t !== "dark" && t !== "high-contrast-light" && t !== "high-contrast-dark") return !1;
335
- let n = e.tokens;
336
- return !s(n) || Object.keys(n).length !== r.length ? !1 : r.every((e) => l(n[e]));
337
- }, E = {
338
- pageBackground: "--color-bg",
339
- surface: "--color-surface",
340
- surfaceRaised: "--color-surface-raised",
341
- surfaceMuted: "--color-surface-muted",
342
- textPrimary: "--color-text",
343
- textMuted: "--color-muted",
344
- border: "--color-border",
345
- borderSubtle: "--color-border-subtle",
346
- link: "--color-link",
347
- accent: "--color-accent",
348
- focus: "--color-focus",
349
- buttonBackground: "--color-button-bg",
350
- buttonForeground: "--color-button-text",
351
- buttonHoverBackground: "--color-button-hover",
352
- inputBackground: "--color-input-bg",
353
- inputForeground: "--color-input-text",
354
- inputBorder: "--color-input-border",
355
- inputPlaceholder: "--color-input-placeholder",
356
- rowHoverBackground: "--color-row-hover",
357
- rowSelectedBackground: "--color-row-selected",
358
- rowSelectedForeground: "--color-row-selected-text",
359
- codeBackground: "--color-code",
360
- codeForeground: "--color-code-text",
361
- error: "--color-error",
362
- warning: "--color-warning",
363
- success: "--color-success",
364
- info: "--color-info",
365
- progress: "--color-progress"
366
- }, D = ({ root: e, theme: t }) => {
367
- for (let n of r) {
368
- let r = E[n];
369
- t ? e.style.setProperty(r, t.tokens[n]) : e.style.removeProperty(r);
370
- }
371
- let n = t?.appearance;
372
- e.classList.toggle("dark", n === "dark" || n === "high-contrast-dark"), e.classList.toggle("high-contrast", n === "high-contrast-light" || n === "high-contrast-dark");
373
- };
374
- //#endregion
375
- export { n as ThemeValidationError, D as applySemanticTheme, T as isNormalizedTheme, w as parseVsCodeTheme, E as semanticCssVariables, r as semanticTokenKeys };
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./theme-CIwueiir.js";
2
+ export { a as ThemeValidationError, n as applySemanticTheme, i as isNormalizedTheme, t as parseVsCodeTheme, e as semanticCssVariables, r as semanticTokenKeys };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@filipgutica/ui",
3
- "version": "0.2.2",
3
+ "version": "1.0.0",
4
4
  "description": "A compact Vue design system with Tailwind CSS and VS Code theme support",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -31,12 +31,20 @@
31
31
  },
32
32
  "scripts": {
33
33
  "build": "vite build && vue-tsc -p tsconfig.build.json --emitDeclarationOnly",
34
+ "docs:build": "vite build --config docs/vite.config.ts",
35
+ "docs:dev": "vite --config docs/vite.config.ts",
36
+ "docs:preview": "vite preview --config docs/vite.config.ts",
37
+ "docs:smoke": "node scripts/docs-smoke.mjs",
38
+ "docs:typecheck": "vue-tsc -p docs/tsconfig.json --noEmit",
39
+ "lint": "eslint . --max-warnings=0",
40
+ "lint:fix": "eslint . --fix --max-warnings=0",
34
41
  "prepublishOnly": "pnpm verify",
35
42
  "release": "semantic-release",
36
43
  "release:dry-run": "semantic-release --dry-run --no-ci",
37
44
  "test": "vitest run",
45
+ "test:e2e": "playwright test",
38
46
  "typecheck": "vue-tsc -p tsconfig.json --noEmit",
39
- "verify": "pnpm typecheck && pnpm test && pnpm build && pnpm pack --dry-run && publint"
47
+ "verify": "pnpm lint && pnpm typecheck && pnpm docs:typecheck && pnpm test && pnpm test:e2e && pnpm build && pnpm docs:build && pnpm pack --dry-run && publint"
40
48
  },
41
49
  "engines": {
42
50
  "node": ">=22.12"
@@ -56,26 +64,36 @@
56
64
  },
57
65
  "homepage": "https://github.com/filipgutica/ui#readme",
58
66
  "dependencies": {
67
+ "@vueuse/core": "^14.4.0",
59
68
  "jsonc-parser": "^3.3.1",
60
69
  "jszip": "^3.10.1",
61
- "reka-ui": "^2.10.4"
70
+ "reka-ui": "^2.10.4",
71
+ "shiki": "^3.23.0"
62
72
  },
63
73
  "peerDependencies": {
64
- "vue": ">=3.4.0"
74
+ "vue": "^3.5.0"
65
75
  },
66
76
  "devDependencies": {
67
77
  "@commitlint/cli": "^21.2.2",
68
78
  "@commitlint/config-conventional": "^21.2.2",
79
+ "@eslint/js": "^10.0.1",
80
+ "@playwright/test": "^1.62.1",
69
81
  "@semantic-release/commit-analyzer": "13.0.1",
82
+ "@tailwindcss/vite": "^4.3.3",
70
83
  "@types/node": "^26.0.0",
71
84
  "@vitejs/plugin-vue": "^6.0.0",
72
85
  "@vue/test-utils": "^2.4.6",
73
86
  "conventional-changelog-conventionalcommits": "^9.3.1",
87
+ "eslint": "^10.9.1",
88
+ "eslint-plugin-vue": "^10.10.0",
89
+ "globals": "^17.12.0",
74
90
  "happy-dom": "^20.12.2",
75
91
  "publint": "^0.3.24",
76
92
  "semantic-release": "^25.0.9",
93
+ "swrv": "^1.2.0",
77
94
  "tailwindcss": "^4.3.3",
78
95
  "typescript": "^5.9.3",
96
+ "typescript-eslint": "^8.69.0",
79
97
  "vite": "^8.2.2",
80
98
  "vitest": "^4.1.11",
81
99
  "vue": "^3.5.42",