@pie-element/element-theme-daisyui 0.1.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/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @pie-element/element-theme-daisyui
2
+
3
+ DaisyUI-focused theme wrapper package for PIE players.
4
+
5
+ ## Custom element
6
+
7
+ - `pie-element-theme-daisyui`
8
+
9
+ ## Usage
10
+
11
+ ```html
12
+ <pie-element-theme-daisyui theme="dark">
13
+ <pie-element-player element-name="hotspot"></pie-element-player>
14
+ </pie-element-theme-daisyui>
15
+ ```
16
+
17
+ This package intentionally ships DaisyUI utilities (`extract`, `convert`, `colors`) and does not include React hooks.
@@ -0,0 +1,156 @@
1
+ import { PieElementThemeElement as e } from "@pie-element/element-theme";
2
+ //#region src/theme-element-daisyui.ts
3
+ var t = class extends e {
4
+ resolveDataTheme(e) {
5
+ return e;
6
+ }
7
+ };
8
+ function n() {
9
+ typeof customElements > "u" || customElements.get("pie-element-theme-daisyui") || customElements.define("pie-element-theme-daisyui", t);
10
+ }
11
+ //#endregion
12
+ //#region src/extract.ts
13
+ function r(e) {
14
+ if (!(typeof document > "u" || typeof window > "u")) try {
15
+ let t = e?.element || document.documentElement, n = getComputedStyle(t), r = n.color, i = n.backgroundColor, a = document.createElement("div");
16
+ a.style.cssText = "position:absolute;visibility:hidden;pointer-events:none", document.body.appendChild(a);
17
+ let o = (e, t = "color") => (a.className = e, getComputedStyle(a)[t]), s = {
18
+ "base-content": r,
19
+ "base-100": i,
20
+ "base-200": o("bg-base-200", "backgroundColor"),
21
+ "base-300": o("bg-base-300", "backgroundColor"),
22
+ primary: o("text-primary"),
23
+ secondary: o("text-secondary"),
24
+ accent: o("text-accent"),
25
+ neutral: o("text-neutral"),
26
+ success: o("text-success"),
27
+ error: o("text-error"),
28
+ warning: o("text-warning"),
29
+ info: o("text-info")
30
+ };
31
+ return document.body.removeChild(a), s;
32
+ } catch {
33
+ return;
34
+ }
35
+ }
36
+ function i(e, t) {
37
+ if (typeof document > "u" || typeof MutationObserver > "u") return () => {};
38
+ let n = t?.element || document.documentElement, i = new MutationObserver((t) => {
39
+ for (let i of t) if (i.type === "attributes" && i.attributeName === "data-theme") {
40
+ e(r({ element: n }));
41
+ break;
42
+ }
43
+ });
44
+ return i.observe(n, {
45
+ attributes: !0,
46
+ attributeFilter: ["data-theme"]
47
+ }), () => i.disconnect();
48
+ }
49
+ function a(e) {
50
+ if (!(typeof document > "u")) return (e || document.documentElement).getAttribute("data-theme") || void 0;
51
+ }
52
+ function o(e, t) {
53
+ typeof document > "u" || (t || document.documentElement).setAttribute("data-theme", e);
54
+ }
55
+ //#endregion
56
+ //#region src/colors.ts
57
+ function s(e) {
58
+ let t = e.replace(/^#/, "");
59
+ return t.length === 3 ? {
60
+ r: parseInt(t[0] + t[0], 16),
61
+ g: parseInt(t[1] + t[1], 16),
62
+ b: parseInt(t[2] + t[2], 16)
63
+ } : t.length === 6 ? {
64
+ r: parseInt(t.substring(0, 2), 16),
65
+ g: parseInt(t.substring(2, 4), 16),
66
+ b: parseInt(t.substring(4, 6), 16)
67
+ } : null;
68
+ }
69
+ function c(e) {
70
+ let t = e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
71
+ return t ? {
72
+ r: parseInt(t[1], 10),
73
+ g: parseInt(t[2], 10),
74
+ b: parseInt(t[3], 10)
75
+ } : null;
76
+ }
77
+ function l(e) {
78
+ let t = e.match(/oklch\(([\d.]+)\s+([\d.]+)\s+([\d.]+)/);
79
+ if (!t) return null;
80
+ let n = Math.max(0, Math.min(1, parseFloat(t[1]))), r = parseFloat(t[2]), i = parseFloat(t[3]) % 360;
81
+ i < 0 && (i += 360);
82
+ let a = i * Math.PI / 180, o = r * Math.cos(a), s = r * Math.sin(a), c = n + .3963377774 * o + .2158037573 * s, l = n - .1055613458 * o - .0638541728 * s, u = n - .0894841775 * o - 1.291485548 * s, d = c * c * c, f = l * l * l, p = u * u * u, m = 4.0767416621 * d - 3.3077115913 * f + .2309699292 * p, h = -1.2684380046 * d + 2.6097574011 * f - .3413193965 * p, g = -.0041960863 * d - .7034186147 * f + 1.707614701 * p, _ = (e) => (e = Math.max(0, Math.min(1, e)), e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055);
83
+ return m = Math.round(_(m) * 255), h = Math.round(_(h) * 255), g = Math.round(_(g) * 255), {
84
+ r: m,
85
+ g: h,
86
+ b: g
87
+ };
88
+ }
89
+ function u(e) {
90
+ return e.startsWith("#") ? s(e) : e.startsWith("rgb") ? c(e) : e.startsWith("oklch") ? l(e) : null;
91
+ }
92
+ function d(e, t, n) {
93
+ let r = (e) => {
94
+ let t = Math.round(Math.max(0, Math.min(255, e))).toString(16);
95
+ return t.length === 1 ? `0${t}` : t;
96
+ };
97
+ return `#${r(e)}${r(t)}${r(n)}`;
98
+ }
99
+ function f(e, t) {
100
+ let n = u(e);
101
+ return n ? d(n.r + (255 - n.r) * t, n.g + (255 - n.g) * t, n.b + (255 - n.b) * t) : e;
102
+ }
103
+ function p(e, t) {
104
+ let n = u(e);
105
+ return n ? d(n.r * (1 - t), n.g * (1 - t), n.b * (1 - t)) : e;
106
+ }
107
+ function m(e, t) {
108
+ let n = u(e);
109
+ return n ? `rgba(${n.r}, ${n.g}, ${n.b}, ${t})` : e;
110
+ }
111
+ function h(e, t) {
112
+ return t > 0 ? f(e, t * .3) : p(e, -t * .3);
113
+ }
114
+ function g(e, t, n = .5) {
115
+ let r = u(e), i = u(t);
116
+ if (!r || !i) return e;
117
+ let a = Math.max(0, Math.min(1, n));
118
+ return d(r.r * a + i.r * (1 - a), r.g * a + i.g * (1 - a), r.b * a + i.b * (1 - a));
119
+ }
120
+ //#endregion
121
+ //#region src/convert.ts
122
+ function _(e) {
123
+ let t = { ...e };
124
+ e.primary && (t["primary-light"] = f(e.primary, .3), t["primary-dark"] = p(e.primary, .3), t["faded-primary"] = m(e.primary, .15)), e.secondary ? (t["secondary-light"] = f(e.secondary, .3), t["secondary-dark"] = p(e.secondary, .3), t.tertiary = p(e.secondary, .1), t["tertiary-light"] = m(e.secondary, .2)) : e.primary && (t.tertiary = p(e.primary, .15), t["tertiary-light"] = m(e.primary, .2)), e.success && (t["correct-secondary"] = m(e.success, .1), t["correct-tertiary"] = p(e.success, .1), t["correct-icon"] = p(e.success, .2), t["feedback-correct-bg"] = m(e.success, .1), t["annotation-pointer-border-color"] = f(e.success, .2)), e.error && (t.incorrect = e.error, t["incorrect-secondary"] = m(e.error, .1), t["incorrect-icon"] = p(e.error, .2), t["feedback-incorrect-bg"] = m(e.error, .1), t["arrow-color"] = e.error), e.warning && (t.missing = e.warning, t["missing-icon"] = p(e.warning, .2)), e.neutral ? (t.disabled = e.neutral, t["disabled-secondary"] = f(e.neutral, .2), t.border = e.neutral, t["border-light"] = f(e.neutral, .3), t["border-dark"] = p(e.neutral, .3), t["border-gray"] = e.neutral) : e["base-300"] && (t.disabled = e["base-300"], t["disabled-secondary"] = f(e["base-300"], .2)), e["base-200"] && (t["background-dark"] = e["base-200"], t["dropdown-background"] = p(e["base-200"], .05), t["secondary-background"] = e["base-200"]), e.primary && (t["focus-checked"] = m(e.primary, .2), t["focus-checked-border"] = p(e.primary, .2)), e.neutral && (t["focus-unchecked"] = m(e.neutral, .2), t["focus-unchecked-border"] = e.neutral);
125
+ let n = e.neutral || e["base-content"] || "#7E8494";
126
+ t["blue-grey-100"] = f(n, .5), t["blue-grey-300"] = f(n, .3), t["blue-grey-600"] = n, t["blue-grey-900"] = p(n, .4), t.black = "#000000", t.white = "#ffffff", e["base-content"] && (t["choice-input-color"] = e["base-content"]), e.primary && (t["choice-input-selected-color"] = e.primary), t.disabled && (t["choice-input-disabled-color"] = t.disabled), e.primary && (t["point-fill"] = e.primary);
127
+ let r = y(e);
128
+ return t["tick-color"] = r ? f(n, .4) : p(n, .4), t["line-stroke"] = r ? f(n, .2) : n, t["point-stroke"] = r ? p(n, .5) : "#ffffff", t["correct-answer-toggle-label-color"] = e["base-content"] || "#000000", e["base-content"] && (t["primary-text"] = e["base-content"]), t["annotation-pointer-right"] = "100%", t["annotation-pointer-top"] = "5px", t["annotation-pointer-border-width"] = "7px", t;
129
+ }
130
+ function v(e) {
131
+ return {
132
+ primary: e.primary,
133
+ secondary: e.secondary,
134
+ accent: e.accent,
135
+ neutral: e.neutral,
136
+ "base-100": e["base-100"],
137
+ "base-200": e["base-200"],
138
+ "base-300": e["base-300"],
139
+ "base-content": e["base-content"],
140
+ info: e.info,
141
+ success: e.success,
142
+ warning: e.warning,
143
+ error: e.error
144
+ };
145
+ }
146
+ function y(e) {
147
+ let t = e["base-content"];
148
+ if (!t) return !1;
149
+ let n = t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
150
+ return n ? (parseInt(n[1], 10) + parseInt(n[2], 10) + parseInt(n[3], 10)) / 3 > 128 : !1;
151
+ }
152
+ //#endregion
153
+ //#region src/index.ts
154
+ n();
155
+ //#endregion
156
+ export { t as PieElementThemeDaisyUiElement, h as adjustSaturation, _ as daisyUiToPieTheme, p as darken, n as definePieElementThemeDaisyUi, r as extractDaisyUiTheme, a as getDaisyUiThemeName, y as isDarkTheme, f as lighten, g as mix, v as pieThemeToDaisyUi, m as rgba, o as setDaisyUiTheme, i as watchDaisyUiTheme };
@@ -0,0 +1,6 @@
1
+ export declare function lighten(color: string, amount: number): string;
2
+ export declare function darken(color: string, amount: number): string;
3
+ export declare function rgba(color: string, alpha: number): string;
4
+ export declare function adjustSaturation(color: string, amount: number): string;
5
+ export declare function mix(color1: string, color2: string, weight?: number): string;
6
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/colors.ts"],"names":[],"mappings":"AAmFA,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ7D;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,MAAM,CAWxE"}
@@ -0,0 +1,6 @@
1
+ import type { PieTheme } from '@pie-element/shared-types';
2
+ import type { PieThemeExtended } from '@pie-element/shared-theming';
3
+ export declare function daisyUiToPieTheme(daisyTheme: PieTheme): PieThemeExtended;
4
+ export declare function pieThemeToDaisyUi(pieTheme: Partial<PieThemeExtended>): PieTheme;
5
+ export declare function isDarkTheme(theme: Partial<PieTheme>): boolean;
6
+ //# sourceMappingURL=convert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/convert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,QAAQ,GAAG,gBAAgB,CAyFxE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,QAAQ,CAe/E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAQ7D"}
@@ -0,0 +1,11 @@
1
+ import type { PieTheme } from '@pie-element/shared-types';
2
+ export interface ExtractDaisyUiThemeOptions {
3
+ element?: HTMLElement;
4
+ }
5
+ export declare function extractDaisyUiTheme(options?: ExtractDaisyUiThemeOptions): PieTheme | undefined;
6
+ export declare function watchDaisyUiTheme(callback: (theme: PieTheme | undefined) => void, options?: {
7
+ element?: HTMLElement;
8
+ }): () => void;
9
+ export declare function getDaisyUiThemeName(element?: HTMLElement): string | undefined;
10
+ export declare function setDaisyUiTheme(themeName: string, element?: HTMLElement): void;
11
+ //# sourceMappingURL=extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,QAAQ,GAAG,SAAS,CAyC9F;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,KAAK,IAAI,EAC/C,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAE,GAClC,MAAM,IAAI,CAiBZ;AAED,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAI7E;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAI9E"}
@@ -0,0 +1,6 @@
1
+ import { definePieElementThemeDaisyUi, PieElementThemeDaisyUiElement } from './theme-element-daisyui.js';
2
+ export { definePieElementThemeDaisyUi, PieElementThemeDaisyUiElement };
3
+ export { extractDaisyUiTheme, watchDaisyUiTheme, getDaisyUiThemeName, setDaisyUiTheme, } from './extract.js';
4
+ export { daisyUiToPieTheme, pieThemeToDaisyUi, isDarkTheme } from './convert.js';
5
+ export { lighten, darken, rgba, adjustSaturation, mix } from './colors.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,CAAC;AACvE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { PieElementThemeElement } from '@pie-element/element-theme';
2
+ export declare class PieElementThemeDaisyUiElement extends PieElementThemeElement {
3
+ protected resolveDataTheme(themeName: 'light' | 'dark'): string;
4
+ }
5
+ export declare function definePieElementThemeDaisyUi(): void;
6
+ //# sourceMappingURL=theme-element-daisyui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-element-daisyui.d.ts","sourceRoot":"","sources":["../../src/theme-element-daisyui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,qBAAa,6BAA8B,SAAQ,sBAAsB;IACvE,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM;CAGhE;AAED,wBAAgB,4BAA4B,SAO3C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=theme-element-daisyui.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-element-daisyui.test.d.ts","sourceRoot":"","sources":["../../test/theme-element-daisyui.test.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@pie-element/element-theme-daisyui",
3
+ "version": "0.1.0",
4
+ "description": "DaisyUI-powered web component theme wrapper for PIE players",
5
+ "type": "module",
6
+ "main": "./dist/pie-element-theme-daisyui.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "development": "./src/index.ts",
12
+ "default": "./dist/pie-element-theme-daisyui.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "vite build && tsc --emitDeclarationOnly",
20
+ "dev": "vite",
21
+ "test": "vitest run"
22
+ },
23
+ "dependencies": {
24
+ "@pie-element/element-theme": "0.1.0",
25
+ "@pie-element/shared-theming": "0.1.0",
26
+ "@pie-element/shared-types": "0.1.0"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.9.3",
30
+ "vite": "^8.0.1",
31
+ "vitest": "^4.1.0"
32
+ },
33
+ "license": "MIT",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/pie-framework/pie-elements-ng.git",
40
+ "directory": "packages/element-theme-daisyui"
41
+ },
42
+ "homepage": "https://github.com/pie-framework/pie-elements-ng#readme",
43
+ "bugs": {
44
+ "url": "https://github.com/pie-framework/pie-elements-ng/issues"
45
+ }
46
+ }