@quidgest/ui 0.16.23 → 0.16.25
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/manifest/components.json +1 -0
- package/dist/ui.css +10 -23
- package/dist/ui.esm.js +2444 -2401
- package/dist/ui.js +18 -17
- package/dist/ui.min.css +1 -1
- package/dist/ui.min.js +734 -727
- package/dist/ui.scss +11 -26
- package/esm/components/QAccordion/QAccordionItem.vue.js +3 -3
- package/esm/components/QDefaultsProvider/QDefaultsProvider.d.ts +19 -0
- package/esm/components/QDefaultsProvider/QDefaultsProvider.d.ts.map +1 -0
- package/esm/components/QDefaultsProvider/QDefaultsProvider.vue.js +16 -0
- package/esm/components/QDefaultsProvider/QDefaultsProvider.vue2.js +4 -0
- package/esm/components/QDefaultsProvider/index.d.ts +19 -0
- package/esm/components/QDefaultsProvider/index.d.ts.map +1 -0
- package/esm/components/QDefaultsProvider/index.js +6 -0
- package/esm/components/QDefaultsProvider/types.d.ts +13 -0
- package/esm/components/QDefaultsProvider/types.d.ts.map +1 -0
- package/esm/components/QFileUpload/QFileUpload.vue.js +45 -45
- package/esm/components/QList/QListItem.d.ts.map +1 -1
- package/esm/components/QRadioGroup/QRadioButton.vue.js +12 -12
- package/esm/components/QRadioGroup/QRadioGroup.vue.js +11 -11
- package/esm/components/QTextArea/QTextArea.vue.js +10 -10
- package/esm/components/QTextField/QTextField.d.ts.map +1 -1
- package/esm/components/QTextField/QTextField.vue.js +15 -15
- package/esm/components/QThemeProvider/QThemeProvider.d.ts.map +1 -1
- package/esm/components/QThemeProvider/QThemeProvider.vue.js +29 -11
- package/esm/components/QThemeProvider/types.d.ts +2 -1
- package/esm/components/QThemeProvider/types.d.ts.map +1 -1
- package/esm/components/QToggleGroup/QToggleGroupItem.d.ts.map +1 -1
- package/esm/components/QToggleGroup/QToggleGroupItem.vue.js +10 -10
- package/esm/components/QTooltip/QTooltip.vue.js +23 -23
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.d.ts.map +1 -1
- package/esm/components/index.js +88 -86
- package/esm/composables/defaults.d.ts +2 -2
- package/esm/composables/defaults.d.ts.map +1 -1
- package/esm/composables/defaults.js +12 -12
- package/esm/composables/theme.d.ts +19 -8
- package/esm/composables/theme.d.ts.map +1 -1
- package/esm/composables/theme.js +15 -11
- package/esm/composables/uid.d.ts +2 -2
- package/esm/composables/uid.d.ts.map +1 -1
- package/esm/composables/uid.js +6 -5
- package/esm/composables/useDialog/index.d.ts.map +1 -1
- package/esm/composables/useDialog/index.js +11 -11
- package/esm/composables/useToast/index.js +6 -6
- package/esm/framework.js +45 -36
- package/esm/index.d.ts +1 -0
- package/esm/utils/theme.d.ts +27 -6
- package/esm/utils/theme.d.ts.map +1 -1
- package/esm/utils/theme.js +39 -37
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComputedRef, DeepReadonly, InjectionKey, Ref } from 'vue';
|
|
1
|
+
import { ComputedRef, DeepReadonly, InjectionKey, MaybeRefOrGetter, Ref } from 'vue';
|
|
2
2
|
import { ColorScheme } from '../utils/color';
|
|
3
3
|
export declare const ThemeSymbol: InjectionKey<ThemeInstance>;
|
|
4
4
|
/**
|
|
@@ -44,8 +44,10 @@ export type ThemeInstance = {
|
|
|
44
44
|
readonly current: DeepReadonly<ComputedRef<ThemeDefinition>>;
|
|
45
45
|
/** An array of available theme definitions. */
|
|
46
46
|
readonly themes: DeepReadonly<ThemeDefinition[]>;
|
|
47
|
-
/** The theme class. */
|
|
47
|
+
/** The theme class name. */
|
|
48
48
|
readonly class: ComputedRef<string>;
|
|
49
|
+
/** The theme CSS definition. */
|
|
50
|
+
readonly css: ComputedRef<string | undefined>;
|
|
49
51
|
};
|
|
50
52
|
/**
|
|
51
53
|
* Custom hook for accessing the theme configuration in context.
|
|
@@ -54,14 +56,23 @@ export type ThemeInstance = {
|
|
|
54
56
|
*/
|
|
55
57
|
export declare function useTheme(): ThemeInstance;
|
|
56
58
|
/**
|
|
57
|
-
* Provides and manages a theme instance
|
|
59
|
+
* Provides and manages a reactive theme instance within the Vue dependency injection system.
|
|
58
60
|
*
|
|
59
|
-
* This function retrieves the available themes from the
|
|
60
|
-
*
|
|
61
|
+
* This function retrieves the current list of available themes from the theme context,
|
|
62
|
+
* optionally adds a new `ThemeDefinition`, and creates a reactive theme instance.
|
|
63
|
+
* The new theme instance is then provided using Vue's `provide`, making it accessible
|
|
64
|
+
* to all descendant components via `inject`.
|
|
61
65
|
*
|
|
62
|
-
* @param
|
|
66
|
+
* @param nameOrDef - Either:
|
|
67
|
+
* - A string (or `Ref<string>`/getter) specifying the name of the theme to activate.
|
|
68
|
+
* - A `ThemeDefinition` (or `Ref<ThemeDefinition>`/getter) to register and activate.
|
|
63
69
|
*
|
|
64
|
-
* @returns The newly created and provided `ThemeInstance
|
|
70
|
+
* @returns The newly created and provided `ThemeInstance`, containing:
|
|
71
|
+
* - `name`: reactive theme name (`Ref<string>`),
|
|
72
|
+
* - `current`: computed active theme (`Ref<ThemeDefinition>`),
|
|
73
|
+
* - `themes`: array of all available themes,
|
|
74
|
+
* - `class`: computed CSS class string for the theme,
|
|
75
|
+
* - `css`: computed CSS variables string for the theme.
|
|
65
76
|
*/
|
|
66
|
-
export declare function provideTheme(
|
|
77
|
+
export declare function provideTheme(nameOrDef: MaybeRefOrGetter<string | ThemeDefinition>): ThemeInstance;
|
|
67
78
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/composables/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/composables/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAMjD,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,aAAa,CAAyB,CAAA;AAE7E;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA;AAExC;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAA;IAEpB,mEAAmE;IACnE,MAAM,EAAE,KAAK,CAAC;QACb,6BAA6B;QAC7B,IAAI,EAAE,MAAM,CAAA;QAEZ,mDAAmD;QACnD,IAAI,EAAE,SAAS,CAAA;QAEf,qEAAqE;QACrE,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;KAC7B,CAAC,CAAA;CACF,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAA;IAEZ,mDAAmD;IACnD,IAAI,EAAE,SAAS,CAAA;IAEf,kDAAkD;IAClD,MAAM,EAAE,WAAW,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAE1B,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAA;IAE5D,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,eAAe,EAAE,CAAC,CAAA;IAEhD,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAEnC,gCAAgC;IAChC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAC7C,CAAA;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,aAAa,CAQxC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AAEH,wBAAgB,YAAY,CAAC,SAAS,EAAE,gBAAgB,CAAC,MAAM,GAAG,eAAe,CAAC,GAAG,aAAa,CAsBjG"}
|
package/esm/composables/theme.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { provide as
|
|
2
|
-
import { createThemeInstance as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const e =
|
|
1
|
+
import { toValue as c, provide as i, inject as h } from "vue";
|
|
2
|
+
import { createThemeInstance as u } from "../utils/theme.js";
|
|
3
|
+
const m = Symbol.for("q-theme");
|
|
4
|
+
function f() {
|
|
5
|
+
const e = h(m);
|
|
6
6
|
if (!e)
|
|
7
7
|
throw new Error("[Quidgest UI] Could not find theme instance");
|
|
8
8
|
return e;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
function d(e) {
|
|
11
|
+
const s = f();
|
|
12
|
+
let n, o = structuredClone(s.themes);
|
|
13
|
+
const t = c(e);
|
|
14
|
+
typeof t != "string" ? (o = [...o, t], n = t.name) : n = t;
|
|
15
|
+
const r = u(n, o);
|
|
16
|
+
return i(m, r), r;
|
|
13
17
|
}
|
|
14
18
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
m as ThemeSymbol,
|
|
20
|
+
d as provideTheme,
|
|
21
|
+
f as useTheme
|
|
18
22
|
};
|
package/esm/composables/uid.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
2
|
/**
|
|
3
3
|
* Custom hook to generate unique IDs.
|
|
4
4
|
*
|
|
5
5
|
* @param [componentId] - Optional component-specific ID.
|
|
6
6
|
* @returns A unique ID as a string or a ref containing a string
|
|
7
7
|
*/
|
|
8
|
-
export declare function useId
|
|
8
|
+
export declare function useId(componentId?: MaybeRefOrGetter<string | undefined>): Ref<string>;
|
|
9
9
|
//# sourceMappingURL=uid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uid.d.ts","sourceRoot":"","sources":["../../src/composables/uid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"uid.d.ts","sourceRoot":"","sources":["../../src/composables/uid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAQhD;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAGrF"}
|
package/esm/composables/uid.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
let
|
|
3
|
-
function
|
|
4
|
-
|
|
1
|
+
import { toValue as r, ref as t } from "vue";
|
|
2
|
+
let u = 0;
|
|
3
|
+
function d(e) {
|
|
4
|
+
const o = r(e);
|
|
5
|
+
return t(o || `uid-${++u}`);
|
|
5
6
|
}
|
|
6
7
|
export {
|
|
7
|
-
|
|
8
|
+
d as useId
|
|
8
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/useDialog/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AASrF;;;;GAIG;AACH,wBAAgB,SAAS;uBASE,YAAY,OAAO,MAAM,YAAY,cAAc;uBAgBnD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/useDialog/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AASrF;;;;GAIG;AACH,wBAAgB,SAAS;uBASE,YAAY,OAAO,MAAM,YAAY,cAAc;uBAgBnD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAagC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADjE"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { reactive as
|
|
1
|
+
import { reactive as s } from "vue";
|
|
2
2
|
import { useId as r } from "../uid.js";
|
|
3
|
-
const o =
|
|
4
|
-
function
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
return o.dialogs.push({ id:
|
|
3
|
+
const o = s({ dialogs: [] });
|
|
4
|
+
function c() {
|
|
5
|
+
function t(d, i, e) {
|
|
6
|
+
const n = r(i).value;
|
|
7
|
+
return o.dialogs.push({ id: n, props: d, options: e }), n;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
const i = o.dialogs.findIndex((
|
|
9
|
+
function a(d) {
|
|
10
|
+
const i = o.dialogs.findIndex((e) => e.id === d);
|
|
11
11
|
i !== -1 && o.dialogs.splice(i, 1);
|
|
12
12
|
}
|
|
13
13
|
return {
|
|
14
14
|
...o,
|
|
15
|
-
addDialog:
|
|
16
|
-
removeDialog:
|
|
15
|
+
addDialog: t,
|
|
16
|
+
removeDialog: a
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
c as useDialog
|
|
21
21
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ToastSymbol as a } from "./types.js";
|
|
2
|
-
import { inject as
|
|
2
|
+
import { inject as u, ref as i } from "vue";
|
|
3
3
|
import { useId as c } from "../uid.js";
|
|
4
4
|
function p() {
|
|
5
5
|
const { toasts: t } = f();
|
|
6
6
|
function s(n, o) {
|
|
7
|
-
const e = c(o);
|
|
7
|
+
const e = c(o).value;
|
|
8
8
|
return t.value.push({ id: e, props: n }), e;
|
|
9
9
|
}
|
|
10
10
|
function r(n) {
|
|
@@ -17,19 +17,19 @@ function p() {
|
|
|
17
17
|
removeToast: r
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function l() {
|
|
21
21
|
return {
|
|
22
|
-
toasts:
|
|
22
|
+
toasts: i([])
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function f() {
|
|
26
|
-
const t =
|
|
26
|
+
const t = u(a);
|
|
27
27
|
if (!t)
|
|
28
28
|
throw new Error("useInjectedToast must be used after provideToast");
|
|
29
29
|
return t;
|
|
30
30
|
}
|
|
31
31
|
export {
|
|
32
|
-
|
|
32
|
+
l as createToastInstance,
|
|
33
33
|
f as injectToastInstance,
|
|
34
34
|
p as useToast
|
|
35
35
|
};
|
package/esm/framework.js
CHANGED
|
@@ -1,54 +1,63 @@
|
|
|
1
|
-
import { DEFAULTS_SYMBOL as
|
|
2
|
-
import { ThemeSymbol as
|
|
1
|
+
import { DEFAULTS_SYMBOL as c } from "./composables/defaults.js";
|
|
2
|
+
import { ThemeSymbol as h } from "./composables/theme.js";
|
|
3
3
|
import { DismissibleLayerKey as f } from "./symbols/dismissibleLayer.js";
|
|
4
|
-
import { ToastSymbol as
|
|
5
|
-
import { useDismissibleLayerStack as
|
|
6
|
-
import { createToastInstance as
|
|
7
|
-
import { defaultLightColorScheme as r, defaultDarkColorScheme as
|
|
8
|
-
import { ref as
|
|
9
|
-
import { createThemeInstance as
|
|
10
|
-
function
|
|
4
|
+
import { ToastSymbol as d } from "./composables/useToast/types.js";
|
|
5
|
+
import { useDismissibleLayerStack as u } from "./composables/useDismissibleLayerStack/index.js";
|
|
6
|
+
import { createToastInstance as p } from "./composables/useToast/index.js";
|
|
7
|
+
import { defaultLightColorScheme as r, defaultDarkColorScheme as l } from "./templates/theme.js";
|
|
8
|
+
import { ref as i, watch as S } from "vue";
|
|
9
|
+
import { createThemeInstance as T, generateRootStyle as L } from "./utils/theme.js";
|
|
10
|
+
function F(s = {}) {
|
|
11
11
|
return { install: (t) => {
|
|
12
|
-
const
|
|
13
|
-
for (const a in
|
|
14
|
-
t.component(a,
|
|
15
|
-
const e =
|
|
16
|
-
t.provide(
|
|
17
|
-
const n =
|
|
12
|
+
const m = s.components || {};
|
|
13
|
+
for (const a in m)
|
|
14
|
+
t.component(a, m[a]);
|
|
15
|
+
const e = s.defaults || {};
|
|
16
|
+
t.provide(c, i(e)), y(t, s.themes);
|
|
17
|
+
const n = u();
|
|
18
18
|
t.provide(f, n), b(t);
|
|
19
19
|
} };
|
|
20
20
|
}
|
|
21
|
-
function y(
|
|
21
|
+
function y(s, o) {
|
|
22
22
|
const t = [];
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
25
|
-
s = "default", t.push({
|
|
26
|
-
name: s,
|
|
27
|
-
mode: "light",
|
|
28
|
-
scheme: r
|
|
29
|
-
});
|
|
30
|
-
else
|
|
23
|
+
let m;
|
|
24
|
+
if (o)
|
|
31
25
|
for (const e of o.themes) {
|
|
32
|
-
const a = { ...e.mode === "light" ? r :
|
|
26
|
+
const a = { ...e.mode === "light" ? r : l, ...e.colors };
|
|
33
27
|
t.push({
|
|
34
28
|
name: e.name,
|
|
35
29
|
mode: e.mode,
|
|
36
30
|
scheme: a
|
|
37
|
-
}), e.name === o.defaultTheme && (
|
|
31
|
+
}), e.name === o.defaultTheme && (m = e.name);
|
|
38
32
|
}
|
|
39
|
-
|
|
40
|
-
const e =
|
|
41
|
-
|
|
33
|
+
else {
|
|
34
|
+
const e = [
|
|
35
|
+
{
|
|
36
|
+
name: "light",
|
|
37
|
+
mode: "light",
|
|
38
|
+
scheme: r
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "dark",
|
|
42
|
+
mode: "dark",
|
|
43
|
+
scheme: l
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
t.push(...e), m = "light";
|
|
47
|
+
}
|
|
48
|
+
if (m) {
|
|
49
|
+
const e = i(m), n = T(e, t);
|
|
50
|
+
L(t), S(n.name, k, { immediate: !0 }), s.provide(h, n);
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
|
-
function b(
|
|
45
|
-
const o =
|
|
46
|
-
|
|
53
|
+
function b(s) {
|
|
54
|
+
const o = p();
|
|
55
|
+
s.provide(d, o);
|
|
47
56
|
}
|
|
48
|
-
function
|
|
49
|
-
const o = document.documentElement,
|
|
50
|
-
o.className =
|
|
57
|
+
function k(s) {
|
|
58
|
+
const o = document.documentElement, m = Array.from(o.classList).filter((e) => !e.startsWith("q-theme"));
|
|
59
|
+
o.className = m.join(" "), o.classList.add(`q-theme--${s}`);
|
|
51
60
|
}
|
|
52
61
|
export {
|
|
53
|
-
|
|
62
|
+
F as createFramework
|
|
54
63
|
};
|
package/esm/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ declare module '@vue/runtime-core' {
|
|
|
22
22
|
QColorPicker: typeof import('@quidgest/ui/components')['QColorPicker']
|
|
23
23
|
QCombobox: typeof import('@quidgest/ui/components')['QCombobox']
|
|
24
24
|
QDateTimePicker: typeof import('@quidgest/ui/components')['QDateTimePicker']
|
|
25
|
+
QDefaultsProvider: typeof import('@quidgest/ui/components')['QDefaultsProvider']
|
|
25
26
|
QDialog: typeof import('@quidgest/ui/components')['QDialog']
|
|
26
27
|
QDialogProvider: typeof import('@quidgest/ui/components')['QDialogProvider']
|
|
27
28
|
QDismissibleLayer: typeof import('@quidgest/ui/components')['QDismissibleLayer']
|
package/esm/utils/theme.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeepReadonly,
|
|
1
|
+
import { DeepReadonly, MaybeRefOrGetter } from 'vue';
|
|
2
2
|
import { ThemeDefinition, ThemeInstance } from '../composables/theme';
|
|
3
3
|
export declare const THEME_NODE_ID = "q-theme";
|
|
4
4
|
/**
|
|
@@ -7,6 +7,18 @@ export declare const THEME_NODE_ID = "q-theme";
|
|
|
7
7
|
* @returns The style node used for dynamic themes.
|
|
8
8
|
*/
|
|
9
9
|
export declare function getThemeNode(): HTMLStyleElement;
|
|
10
|
+
/**
|
|
11
|
+
* Generates a CSS class definition for a given theme.
|
|
12
|
+
*
|
|
13
|
+
* This function creates a CSS block scoped to the theme’s class
|
|
14
|
+
* (e.g., `.q-theme--light`), where each color in the theme’s color
|
|
15
|
+
* scheme is exposed as both a HEX and an RGB CSS custom property.
|
|
16
|
+
*
|
|
17
|
+
* @param theme - The `ThemeDefinition` containing the name and color scheme.
|
|
18
|
+
*
|
|
19
|
+
* @returns A string of CSS text defining the theme’s variables.
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateThemeCss(theme: ThemeDefinition): string;
|
|
10
22
|
/**
|
|
11
23
|
* Generates and applies dynamic root-level styles based on the provided themes.
|
|
12
24
|
*
|
|
@@ -21,13 +33,22 @@ export declare function generateRootStyle(themes: ThemeDefinition[]): void;
|
|
|
21
33
|
*/
|
|
22
34
|
export declare function toProperty(color: string): string;
|
|
23
35
|
/**
|
|
24
|
-
* Creates a theme instance
|
|
36
|
+
* Creates a reactive theme instance for a given theme name.
|
|
37
|
+
*
|
|
38
|
+
* This provides reactive access to the currently active theme and
|
|
39
|
+
* computed properties for applying its CSS class and CSS variables.
|
|
25
40
|
*
|
|
26
|
-
* @param name - The name of the theme to
|
|
41
|
+
* @param name - The name of the theme to activate, or a getter/ref returning a string.
|
|
27
42
|
* @param themes - A readonly array of available theme definitions.
|
|
28
|
-
* @returns A ThemeInstance object containing the current theme and metadata.
|
|
29
43
|
*
|
|
30
|
-
* @
|
|
44
|
+
* @returns A `ThemeInstance` object containing:
|
|
45
|
+
* - `name`: a reactive `Ref<string>` of the active theme name.
|
|
46
|
+
* - `current`: a computed `Ref<ThemeDefinition>` of the active theme.
|
|
47
|
+
* - `themes`: the array of all available theme definitions.
|
|
48
|
+
* - `class`: a computed CSS class string for the active theme.
|
|
49
|
+
* - `css`: a computed string of CSS variables for the active theme.
|
|
50
|
+
*
|
|
51
|
+
* @throws Will throw an error if no theme with the specified name exists in `themes`.
|
|
31
52
|
*/
|
|
32
|
-
export declare function createThemeInstance(name:
|
|
53
|
+
export declare function createThemeInstance(name: MaybeRefOrGetter<string>, themes: DeepReadonly<ThemeDefinition[]>): ThemeInstance;
|
|
33
54
|
//# sourceMappingURL=theme.d.ts.map
|
package/esm/utils/theme.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/utils/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/utils/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAQ1E,eAAO,MAAM,aAAa,YAAY,CAAA;AAEtC;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,gBAAgB,CAY/C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,UAoBtD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,QAM1D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,UAOvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC9B,MAAM,EAAE,YAAY,CAAC,eAAe,EAAE,CAAC,GACrC,aAAa,CAqBf"}
|
package/esm/utils/theme.js
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { parseColor as
|
|
3
|
-
import { toKebabCase as
|
|
1
|
+
import { ref as f, toValue as h, computed as c } from "vue";
|
|
2
|
+
import { parseColor as d } from "./color.js";
|
|
3
|
+
import { toKebabCase as p } from "./string.js";
|
|
4
4
|
const a = "q-theme";
|
|
5
|
-
function
|
|
5
|
+
function $() {
|
|
6
6
|
let e = document.getElementById(
|
|
7
7
|
a
|
|
8
8
|
);
|
|
9
9
|
return e || (e = document.createElement("style"), e.id = a, document.head.appendChild(e)), e;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
let t =
|
|
13
|
-
for (const c of e) {
|
|
14
|
-
t += `.q-theme--${c.name} {
|
|
11
|
+
function l(e) {
|
|
12
|
+
let t = `.q-theme--${e.name} {
|
|
15
13
|
`;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const n = e.scheme;
|
|
15
|
+
let o;
|
|
16
|
+
for (o in n) {
|
|
17
|
+
const r = n[o];
|
|
18
|
+
if (r) {
|
|
19
|
+
t += ` ${u(o)}: ${r};
|
|
22
20
|
`;
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const m = d(r);
|
|
22
|
+
t += ` ${u(o)}-rgb: ${m.r} ${m.g} ${m.b};
|
|
25
23
|
`;
|
|
26
|
-
}
|
|
27
24
|
}
|
|
28
|
-
t += `}
|
|
29
|
-
`;
|
|
30
25
|
}
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
return t += `}
|
|
27
|
+
`, t;
|
|
28
|
+
}
|
|
29
|
+
function E(e) {
|
|
30
|
+
const t = e.map(l).join(`
|
|
31
|
+
`), n = $();
|
|
32
|
+
n.textContent = t;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return e ? `--q-theme-${
|
|
34
|
+
function u(e) {
|
|
35
|
+
return e ? `--q-theme-${p(e)}` : "";
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
throw new Error(`Theme "${
|
|
42
|
-
return
|
|
43
|
-
}),
|
|
37
|
+
function b(e, t) {
|
|
38
|
+
const n = f(h(e)), o = c(() => {
|
|
39
|
+
const s = t.find((i) => i.name === n.value);
|
|
40
|
+
if (!s)
|
|
41
|
+
throw new Error(`Theme "${n.value}" not found`);
|
|
42
|
+
return s;
|
|
43
|
+
}), r = c(() => `q-theme--${o.value.name}`), m = c(() => l(o.value));
|
|
44
44
|
return {
|
|
45
|
-
name:
|
|
46
|
-
current:
|
|
45
|
+
name: n,
|
|
46
|
+
current: o,
|
|
47
47
|
themes: t,
|
|
48
|
-
class:
|
|
48
|
+
class: r,
|
|
49
|
+
css: m
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
export {
|
|
52
53
|
a as THEME_NODE_ID,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
l as
|
|
56
|
-
|
|
54
|
+
b as createThemeInstance,
|
|
55
|
+
E as generateRootStyle,
|
|
56
|
+
l as generateThemeCss,
|
|
57
|
+
$ as getThemeNode,
|
|
58
|
+
u as toProperty
|
|
57
59
|
};
|