@iris-ui-kit/vue 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/LICENSE +21 -0
- package/dist/admin.cjs +1869 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.d.cts +376 -0
- package/dist/admin.d.ts +376 -0
- package/dist/admin.js +10 -0
- package/dist/admin.js.map +1 -0
- package/dist/async.cjs +76 -0
- package/dist/async.cjs.map +1 -0
- package/dist/async.d.cts +59 -0
- package/dist/async.d.ts +59 -0
- package/dist/async.js +3 -0
- package/dist/async.js.map +1 -0
- package/dist/behaviors.cjs +659 -0
- package/dist/behaviors.cjs.map +1 -0
- package/dist/behaviors.d.cts +441 -0
- package/dist/behaviors.d.ts +441 -0
- package/dist/behaviors.js +3 -0
- package/dist/behaviors.js.map +1 -0
- package/dist/chunk-3FJUCHCC.js +146 -0
- package/dist/chunk-3FJUCHCC.js.map +1 -0
- package/dist/chunk-3R3QDLJC.js +172 -0
- package/dist/chunk-3R3QDLJC.js.map +1 -0
- package/dist/chunk-4FLIW67H.js +137 -0
- package/dist/chunk-4FLIW67H.js.map +1 -0
- package/dist/chunk-4FQ7XF52.js +3 -0
- package/dist/chunk-4FQ7XF52.js.map +1 -0
- package/dist/chunk-72PZMU6R.js +99 -0
- package/dist/chunk-72PZMU6R.js.map +1 -0
- package/dist/chunk-75GSYEJS.js +17 -0
- package/dist/chunk-75GSYEJS.js.map +1 -0
- package/dist/chunk-7IOJADZC.js +38 -0
- package/dist/chunk-7IOJADZC.js.map +1 -0
- package/dist/chunk-CIZGSGXN.js +651 -0
- package/dist/chunk-CIZGSGXN.js.map +1 -0
- package/dist/chunk-F77KIPOH.js +103 -0
- package/dist/chunk-F77KIPOH.js.map +1 -0
- package/dist/chunk-FJBYAIL4.js +1318 -0
- package/dist/chunk-FJBYAIL4.js.map +1 -0
- package/dist/chunk-H7HVVPYR.js +66 -0
- package/dist/chunk-H7HVVPYR.js.map +1 -0
- package/dist/chunk-I6D5VXQK.js +167 -0
- package/dist/chunk-I6D5VXQK.js.map +1 -0
- package/dist/chunk-PPYNXNGZ.js +73 -0
- package/dist/chunk-PPYNXNGZ.js.map +1 -0
- package/dist/chunk-QLUIKEMJ.js +1197 -0
- package/dist/chunk-QLUIKEMJ.js.map +1 -0
- package/dist/chunk-ROJV6RON.js +3 -0
- package/dist/chunk-ROJV6RON.js.map +1 -0
- package/dist/chunk-S43IHHBU.js +82 -0
- package/dist/chunk-S43IHHBU.js.map +1 -0
- package/dist/chunk-TCAXRWT6.js +108 -0
- package/dist/chunk-TCAXRWT6.js.map +1 -0
- package/dist/chunk-TQB5LVOH.js +17 -0
- package/dist/chunk-TQB5LVOH.js.map +1 -0
- package/dist/chunk-VM2CXEUA.js +46 -0
- package/dist/chunk-VM2CXEUA.js.map +1 -0
- package/dist/chunk-W2JVHGFR.js +103 -0
- package/dist/chunk-W2JVHGFR.js.map +1 -0
- package/dist/chunk-WL67XCH5.js +59 -0
- package/dist/chunk-WL67XCH5.js.map +1 -0
- package/dist/chunk-XCNCIG2I.js +165 -0
- package/dist/chunk-XCNCIG2I.js.map +1 -0
- package/dist/chunk-XSLBANUV.js +16 -0
- package/dist/chunk-XSLBANUV.js.map +1 -0
- package/dist/chunk-ZY4NLITM.js +73 -0
- package/dist/chunk-ZY4NLITM.js.map +1 -0
- package/dist/data.cjs +59 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +46 -0
- package/dist/data.d.ts +46 -0
- package/dist/data.js +4 -0
- package/dist/data.js.map +1 -0
- package/dist/error-boundary.cjs +115 -0
- package/dist/error-boundary.cjs.map +1 -0
- package/dist/error-boundary.d.cts +60 -0
- package/dist/error-boundary.d.ts +60 -0
- package/dist/error-boundary.js +4 -0
- package/dist/error-boundary.js.map +1 -0
- package/dist/floating.cjs +149 -0
- package/dist/floating.cjs.map +1 -0
- package/dist/floating.d.cts +106 -0
- package/dist/floating.d.ts +106 -0
- package/dist/floating.js +4 -0
- package/dist/floating.js.map +1 -0
- package/dist/form.cjs +144 -0
- package/dist/form.cjs.map +1 -0
- package/dist/form.d.cts +128 -0
- package/dist/form.d.ts +128 -0
- package/dist/form.js +3 -0
- package/dist/form.js.map +1 -0
- package/dist/i18n.cjs +112 -0
- package/dist/i18n.cjs.map +1 -0
- package/dist/i18n.d.cts +99 -0
- package/dist/i18n.d.ts +99 -0
- package/dist/i18n.js +3 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.cjs +18673 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8087 -0
- package/dist/index.d.ts +8087 -0
- package/dist/index.js +13525 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts.cjs +392 -0
- package/dist/layouts.cjs.map +1 -0
- package/dist/layouts.d.cts +406 -0
- package/dist/layouts.d.ts +406 -0
- package/dist/layouts.js +5 -0
- package/dist/layouts.js.map +1 -0
- package/dist/machine.cjs +19 -0
- package/dist/machine.cjs.map +1 -0
- package/dist/machine.d.cts +18 -0
- package/dist/machine.d.ts +18 -0
- package/dist/machine.js +4 -0
- package/dist/machine.js.map +1 -0
- package/dist/modal-utils.cjs +170 -0
- package/dist/modal-utils.cjs.map +1 -0
- package/dist/modal-utils.d.cts +43 -0
- package/dist/modal-utils.d.ts +43 -0
- package/dist/modal-utils.js +3 -0
- package/dist/modal-utils.js.map +1 -0
- package/dist/motion.cjs +88 -0
- package/dist/motion.cjs.map +1 -0
- package/dist/motion.d.cts +43 -0
- package/dist/motion.d.ts +43 -0
- package/dist/motion.js +3 -0
- package/dist/motion.js.map +1 -0
- package/dist/provider.cjs +272 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +130 -0
- package/dist/provider.d.ts +130 -0
- package/dist/provider.js +6 -0
- package/dist/provider.js.map +1 -0
- package/dist/resource.cjs +25 -0
- package/dist/resource.cjs.map +1 -0
- package/dist/resource.d.cts +17 -0
- package/dist/resource.d.ts +17 -0
- package/dist/resource.js +3 -0
- package/dist/resource.js.map +1 -0
- package/dist/skeletons.cjs +1659 -0
- package/dist/skeletons.cjs.map +1 -0
- package/dist/skeletons.d.cts +179 -0
- package/dist/skeletons.d.ts +179 -0
- package/dist/skeletons.js +7 -0
- package/dist/skeletons.js.map +1 -0
- package/dist/skins.cjs +138 -0
- package/dist/skins.cjs.map +1 -0
- package/dist/skins.d.cts +67 -0
- package/dist/skins.d.ts +67 -0
- package/dist/skins.js +3 -0
- package/dist/skins.js.map +1 -0
- package/dist/theme.cjs +106 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.cts +103 -0
- package/dist/theme.d.ts +103 -0
- package/dist/theme.js +3 -0
- package/dist/theme.js.map +1 -0
- package/dist/undo.cjs +51 -0
- package/dist/undo.cjs.map +1 -0
- package/dist/undo.d.cts +48 -0
- package/dist/undo.d.ts +48 -0
- package/dist/undo.js +3 -0
- package/dist/undo.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType } from 'vue';
|
|
3
|
+
|
|
4
|
+
interface IrisLoginSubmitPayload {
|
|
5
|
+
email: string;
|
|
6
|
+
password: string;
|
|
7
|
+
remember: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Layer 4 system skeleton: a centered login page using only Iris primitives.
|
|
11
|
+
* Demonstrates the recommended composition pattern (Container + Stack +
|
|
12
|
+
* FormField wrappers) for forms.
|
|
13
|
+
*
|
|
14
|
+
* The template is opinionated about layout and a11y; data binding is left to
|
|
15
|
+
* the consumer via the `submit` event + slot props.
|
|
16
|
+
*/
|
|
17
|
+
declare const IrisLoginTemplate: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
18
|
+
title: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
description: {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
/** Show "Remember me" checkbox. */
|
|
27
|
+
showRemember: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: boolean;
|
|
30
|
+
};
|
|
31
|
+
/** Error message shown above the form. */
|
|
32
|
+
error: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
default: string;
|
|
35
|
+
};
|
|
36
|
+
submitLabel: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: string;
|
|
39
|
+
};
|
|
40
|
+
/** Disable the entire form (e.g. while a request is pending). */
|
|
41
|
+
loading: {
|
|
42
|
+
type: BooleanConstructor;
|
|
43
|
+
default: boolean;
|
|
44
|
+
};
|
|
45
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
48
|
+
submit: (_payload: IrisLoginSubmitPayload) => true;
|
|
49
|
+
}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
50
|
+
title: {
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
default: string;
|
|
53
|
+
};
|
|
54
|
+
description: {
|
|
55
|
+
type: StringConstructor;
|
|
56
|
+
default: string;
|
|
57
|
+
};
|
|
58
|
+
/** Show "Remember me" checkbox. */
|
|
59
|
+
showRemember: {
|
|
60
|
+
type: BooleanConstructor;
|
|
61
|
+
default: boolean;
|
|
62
|
+
};
|
|
63
|
+
/** Error message shown above the form. */
|
|
64
|
+
error: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
default: string;
|
|
67
|
+
};
|
|
68
|
+
submitLabel: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
/** Disable the entire form (e.g. while a request is pending). */
|
|
73
|
+
loading: {
|
|
74
|
+
type: BooleanConstructor;
|
|
75
|
+
default: boolean;
|
|
76
|
+
};
|
|
77
|
+
}>> & Readonly<{
|
|
78
|
+
onSubmit?: ((_payload: IrisLoginSubmitPayload) => any) | undefined;
|
|
79
|
+
}>, {
|
|
80
|
+
title: string;
|
|
81
|
+
error: string;
|
|
82
|
+
description: string;
|
|
83
|
+
loading: boolean;
|
|
84
|
+
showRemember: boolean;
|
|
85
|
+
submitLabel: string;
|
|
86
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
87
|
+
|
|
88
|
+
interface IrisDashboardNavItem {
|
|
89
|
+
id: string;
|
|
90
|
+
label: string;
|
|
91
|
+
/** Optional icon (any ReactNode-like; ignored if `slots.icon` is used). */
|
|
92
|
+
icon?: string;
|
|
93
|
+
}
|
|
94
|
+
interface IrisDashboardCardSpec {
|
|
95
|
+
id: string;
|
|
96
|
+
title: string;
|
|
97
|
+
colSpan?: number | 'full';
|
|
98
|
+
rowSpan?: number;
|
|
99
|
+
/** Plain text or HTML — replace via `#card.<id>` slot for full control. */
|
|
100
|
+
body?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Layer 4 system skeleton: a 3-region dashboard shell — sidebar + header +
|
|
104
|
+
* main grid. Built from `IrisSidebarLayout` + `IrisHeaderLayout` +
|
|
105
|
+
* `IrisDashboardGrid` so it inherits collapsing, sticky header, and responsive
|
|
106
|
+
* column layout out of the box.
|
|
107
|
+
*/
|
|
108
|
+
declare const IrisDashboardTemplate: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
109
|
+
title: {
|
|
110
|
+
type: StringConstructor;
|
|
111
|
+
default: string;
|
|
112
|
+
};
|
|
113
|
+
sidebarTitle: {
|
|
114
|
+
type: StringConstructor;
|
|
115
|
+
default: string;
|
|
116
|
+
};
|
|
117
|
+
nav: {
|
|
118
|
+
type: PropType<IrisDashboardNavItem[]>;
|
|
119
|
+
default: () => never[];
|
|
120
|
+
};
|
|
121
|
+
/** Currently active nav item id. */
|
|
122
|
+
activeId: {
|
|
123
|
+
type: StringConstructor;
|
|
124
|
+
default: string;
|
|
125
|
+
};
|
|
126
|
+
/** Cards to render in the main grid. Skip to use the `default` slot only. */
|
|
127
|
+
cards: {
|
|
128
|
+
type: PropType<IrisDashboardCardSpec[]>;
|
|
129
|
+
default: () => never[];
|
|
130
|
+
};
|
|
131
|
+
defaultCollapsed: {
|
|
132
|
+
type: BooleanConstructor;
|
|
133
|
+
default: boolean;
|
|
134
|
+
};
|
|
135
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
136
|
+
[key: string]: any;
|
|
137
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
138
|
+
'update:activeId': (_id: string) => true;
|
|
139
|
+
'update:collapsed': (_value: boolean) => true;
|
|
140
|
+
}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
141
|
+
title: {
|
|
142
|
+
type: StringConstructor;
|
|
143
|
+
default: string;
|
|
144
|
+
};
|
|
145
|
+
sidebarTitle: {
|
|
146
|
+
type: StringConstructor;
|
|
147
|
+
default: string;
|
|
148
|
+
};
|
|
149
|
+
nav: {
|
|
150
|
+
type: PropType<IrisDashboardNavItem[]>;
|
|
151
|
+
default: () => never[];
|
|
152
|
+
};
|
|
153
|
+
/** Currently active nav item id. */
|
|
154
|
+
activeId: {
|
|
155
|
+
type: StringConstructor;
|
|
156
|
+
default: string;
|
|
157
|
+
};
|
|
158
|
+
/** Cards to render in the main grid. Skip to use the `default` slot only. */
|
|
159
|
+
cards: {
|
|
160
|
+
type: PropType<IrisDashboardCardSpec[]>;
|
|
161
|
+
default: () => never[];
|
|
162
|
+
};
|
|
163
|
+
defaultCollapsed: {
|
|
164
|
+
type: BooleanConstructor;
|
|
165
|
+
default: boolean;
|
|
166
|
+
};
|
|
167
|
+
}>> & Readonly<{
|
|
168
|
+
"onUpdate:collapsed"?: ((_value: boolean) => any) | undefined;
|
|
169
|
+
"onUpdate:activeId"?: ((_id: string) => any) | undefined;
|
|
170
|
+
}>, {
|
|
171
|
+
nav: IrisDashboardNavItem[];
|
|
172
|
+
title: string;
|
|
173
|
+
defaultCollapsed: boolean;
|
|
174
|
+
sidebarTitle: string;
|
|
175
|
+
activeId: string;
|
|
176
|
+
cards: IrisDashboardCardSpec[];
|
|
177
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
178
|
+
|
|
179
|
+
export { type IrisDashboardCardSpec, type IrisDashboardNavItem, IrisDashboardTemplate, type IrisLoginSubmitPayload, IrisLoginTemplate };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { IrisDashboardTemplate, IrisLoginTemplate } from './chunk-QLUIKEMJ.js';
|
|
2
|
+
import './chunk-3R3QDLJC.js';
|
|
3
|
+
import './chunk-F77KIPOH.js';
|
|
4
|
+
import './chunk-I6D5VXQK.js';
|
|
5
|
+
import './chunk-TCAXRWT6.js';
|
|
6
|
+
//# sourceMappingURL=skeletons.js.map
|
|
7
|
+
//# sourceMappingURL=skeletons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"skeletons.js"}
|
package/dist/skins.cjs
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var skins = require('@iris-ui-kit/skins');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var theme = require('@iris-ui-kit/theme');
|
|
6
|
+
|
|
7
|
+
// src/skins/index.ts
|
|
8
|
+
var IrisSkinKey = /* @__PURE__ */ Symbol("IrisSkin");
|
|
9
|
+
var SkinProvider = vue.defineComponent({
|
|
10
|
+
name: "IrisSkinProvider",
|
|
11
|
+
props: {
|
|
12
|
+
engine: { type: Object, required: true },
|
|
13
|
+
target: { type: Object, default: null },
|
|
14
|
+
cspNonce: { type: String, default: void 0 }
|
|
15
|
+
},
|
|
16
|
+
setup(props, { slots }) {
|
|
17
|
+
const current = vue.ref(props.engine.current());
|
|
18
|
+
const unsubscribe = props.engine.subscribe((next) => {
|
|
19
|
+
current.value = next;
|
|
20
|
+
});
|
|
21
|
+
let applied = null;
|
|
22
|
+
const targetEl = () => props.target ?? document.documentElement;
|
|
23
|
+
const apply = () => {
|
|
24
|
+
applied?.revert();
|
|
25
|
+
applied = skins.applySkin(current.value, targetEl());
|
|
26
|
+
};
|
|
27
|
+
vue.onMounted(() => {
|
|
28
|
+
theme.injectGlobalStyles(props.cspNonce);
|
|
29
|
+
apply();
|
|
30
|
+
});
|
|
31
|
+
vue.watch(current, () => {
|
|
32
|
+
if (applied) apply();
|
|
33
|
+
});
|
|
34
|
+
vue.onBeforeUnmount(() => {
|
|
35
|
+
unsubscribe();
|
|
36
|
+
applied?.revert();
|
|
37
|
+
applied = null;
|
|
38
|
+
});
|
|
39
|
+
vue.provide(IrisSkinKey, { engine: props.engine, current });
|
|
40
|
+
return () => slots.default?.();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
function useSkinContext() {
|
|
44
|
+
const ctx = vue.inject(IrisSkinKey);
|
|
45
|
+
if (!ctx) throw new Error("[iris-ui] useSkin(): no <SkinProvider> ancestor found");
|
|
46
|
+
return ctx;
|
|
47
|
+
}
|
|
48
|
+
function useSkin() {
|
|
49
|
+
const { engine, current } = useSkinContext();
|
|
50
|
+
return {
|
|
51
|
+
skin: vue.computed(() => current.value),
|
|
52
|
+
setSkin: engine.setSkin,
|
|
53
|
+
loadSkin: engine.loadSkin,
|
|
54
|
+
useFromCatalog: engine.useFromCatalog,
|
|
55
|
+
patch: engine.patch,
|
|
56
|
+
resetPatch: engine.resetPatch,
|
|
57
|
+
setMode: engine.setMode,
|
|
58
|
+
getMode: engine.getMode,
|
|
59
|
+
getActiveId: engine.getActiveId,
|
|
60
|
+
availableSkins: engine.availableSkins,
|
|
61
|
+
errors: engine.errors
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Object.defineProperty(exports, "SkinResolutionError", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () { return skins.SkinResolutionError; }
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "applySkin", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () { return skins.applySkin; }
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "builtinSkins", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () { return skins.builtinSkins; }
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "createSkinCatalog", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () { return skins.createSkinCatalog; }
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "createSkinEngine", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return skins.createSkinEngine; }
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, "createSkinRegistry", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () { return skins.createSkinRegistry; }
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "darkSkin", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () { return skins.darkSkin; }
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "lightSkin", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () { return skins.lightSkin; }
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "loadSkin", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () { return skins.loadSkin; }
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "localStorageSkinStorage", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () { return skins.localStorageSkinStorage; }
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "memorySkinStorage", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () { return skins.memorySkinStorage; }
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, "renderSkinStyle", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () { return skins.renderSkinStyle; }
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "resolveSkin", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () { return skins.resolveSkin; }
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(exports, "skinBootScript", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function () { return skins.skinBootScript; }
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, "skinError", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function () { return skins.skinError; }
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, "skinToCssEntries", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () { return skins.skinToCssEntries; }
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(exports, "validateSkin", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () { return skins.validateSkin; }
|
|
132
|
+
});
|
|
133
|
+
exports.IrisSkinKey = IrisSkinKey;
|
|
134
|
+
exports.SkinProvider = SkinProvider;
|
|
135
|
+
exports.useSkin = useSkin;
|
|
136
|
+
exports.useSkinContext = useSkinContext;
|
|
137
|
+
//# sourceMappingURL=skins.cjs.map
|
|
138
|
+
//# sourceMappingURL=skins.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/skins/SkinProvider.ts","../src/skins/useSkin.ts"],"names":["defineComponent","ref","applySkin","onMounted","injectGlobalStyles","watch","onBeforeUnmount","provide","inject","computed"],"mappings":";;;;;;;AAyBO,IAAM,WAAA,0BAAoD,UAAU;AAOpE,IAAM,eAAeA,mBAAA,CAAgB;AAAA,EAC1C,IAAA,EAAM,kBAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAgC,UAAU,IAAA,EAAK;AAAA,IAC/D,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAwC,SAAS,IAAA,EAAK;AAAA,IACtE,QAAA,EAAU,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,MAAA;AAAU,GAC/C;A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CAAA;AACjF,EAAA,OAAO,GAAA;AACT;ACrDO,SAAS,OAAA,GAAyB;AACvC,EAAA,MAAM,EAAE,MAAA,EAAQ,OAAA,EAAQ,GAAI,cAAA,EAAe;AAC3C,EAAA,OAAO;AAAA,IACL,IAAA,EAAMC,YAAA,CAAS,MAAM,OAAA,CAAQ,KAAK,CAAA;AAAA,IAClC,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,UAAU,MAAA,CAAO,QAAA;AAAA,IACjB,gBAAgB,MAAA,CAAO,cAAA;AAAA,IACvB,OAAO,MAAA,CAAO,KAAA;AAAA,IACd,YAAY,MAAA,CAAO,UAAA;AAAA,IACnB,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,aAAa,MAAA,CAAO,WAAA;AAAA,IACpB,gBAAgB,MAAA,CAAO,cAAA;AAAA,IACvB,QAAQ,MAAA,CAAO;AAAA,GACjB;AACF","file":"skins.cjs","sourcesContent":["import {\n defineComponent,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n watch,\n type InjectionKey,\n type PropType,\n type Ref,\n} from 'vue'\nimport { injectGlobalStyles } from '@iris-ui-kit/theme'\nimport {\n applySkin,\n type ApplySkinResult,\n type ResolvedSkin,\n type SkinEngine,\n} from '@iris-ui-kit/skins'\n\nexport interface IrisSkinContext {\n engine: SkinEngine\n current: Ref<ResolvedSkin>\n}\n\nexport const IrisSkinKey: InjectionKey<IrisSkinContext> = Symbol('IrisSkin')\n\n/**\n * Renderless provider mirroring `<IrisThemeProvider>` for skins: subscribes to\n * the engine store, applies/reverts the resolved skin on the target element,\n * and provides the engine + current skin to descendants. Zero skin logic.\n */\nexport const SkinProvider = defineComponent({\n name: 'IrisSkinProvider',\n props: {\n engine: { type: Object as PropType<SkinEngine>, required: true },\n target: { type: Object as PropType<HTMLElement | null>, default: null },\n cspNonce: { type: String, default: undefined },\n },\n setup(props, { slots }) {\n const current = ref(props.engine.current()) as Ref<ResolvedSkin>\n const unsubscribe = props.engine.subscribe((next) => {\n current.value = next\n })\n\n let applied: ApplySkinResult | null = null\n const targetEl = () => props.target ?? document.documentElement\n const apply = () => {\n applied?.revert()\n applied = applySkin(current.value, targetEl())\n }\n\n onMounted(() => {\n injectGlobalStyles(props.cspNonce)\n apply()\n })\n watch(current, () => {\n if (applied) apply()\n })\n onBeforeUnmount(() => {\n unsubscribe()\n applied?.revert()\n applied = null\n })\n\n provide(IrisSkinKey, { engine: props.engine, current })\n return () => slots.default?.()\n },\n})\n\nexport function useSkinContext(): IrisSkinContext {\n const ctx = inject(IrisSkinKey)\n if (!ctx) throw new Error('[iris-ui] useSkin(): no <SkinProvider> ancestor found')\n return ctx\n}\n","import type { ComputedRef } from 'vue'\nimport { computed } from 'vue'\nimport type { ResolvedSkin, Skin, SkinMode, SkinPatch, SkinError } from '@iris-ui-kit/skins'\nimport { useSkinContext } from './SkinProvider'\n\nexport interface UseSkinReturn {\n skin: ComputedRef<ResolvedSkin>\n setSkin: (id: string) => void\n loadSkin: (source: string | Skin) => Promise<ResolvedSkin>\n useFromCatalog: (id: string) => Promise<ResolvedSkin>\n patch: (overrides: SkinPatch) => void\n resetPatch: () => void\n setMode: (mode: SkinMode) => void\n getMode: () => SkinMode\n /** Logical selected id (pre system-variant remap) — e.g. 'auto' while following the system. */\n getActiveId: () => string\n availableSkins: () => Skin[]\n errors: () => SkinError[]\n}\n\n/** Read + control the active skin from anywhere inside a `<SkinProvider>`. */\nexport function useSkin(): UseSkinReturn {\n const { engine, current } = useSkinContext()\n return {\n skin: computed(() => current.value),\n setSkin: engine.setSkin,\n loadSkin: engine.loadSkin,\n useFromCatalog: engine.useFromCatalog,\n patch: engine.patch,\n resetPatch: engine.resetPatch,\n setMode: engine.setMode,\n getMode: engine.getMode,\n getActiveId: engine.getActiveId,\n availableSkins: engine.availableSkins,\n errors: engine.errors,\n }\n}\n"]}
|
package/dist/skins.d.cts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SkinEngine, ResolvedSkin, Skin, SkinPatch, SkinMode, SkinError } from '@iris-ui-kit/skins';
|
|
2
|
+
export { ApplySkinResult, LoadSkinOptions, ResolvedSkin, Skin, SkinBootScriptConfig, SkinCatalog, SkinCatalogConfig, SkinEngine, SkinEngineConfig, SkinError, SkinErrorCode, SkinLookup, SkinManifest, SkinManifestEntry, SkinMode, SkinPatch, SkinRegistry, SkinResolutionError, SkinStorage, SkinTokenOverrides, applySkin, builtinSkins, createSkinCatalog, createSkinEngine, createSkinRegistry, darkSkin, lightSkin, loadSkin, localStorageSkinStorage, memorySkinStorage, renderSkinStyle, resolveSkin, skinBootScript, skinError, skinToCssEntries, validateSkin } from '@iris-ui-kit/skins';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import { Ref, InjectionKey, PropType, ComputedRef } from 'vue';
|
|
5
|
+
|
|
6
|
+
interface IrisSkinContext {
|
|
7
|
+
engine: SkinEngine;
|
|
8
|
+
current: Ref<ResolvedSkin>;
|
|
9
|
+
}
|
|
10
|
+
declare const IrisSkinKey: InjectionKey<IrisSkinContext>;
|
|
11
|
+
/**
|
|
12
|
+
* Renderless provider mirroring `<IrisThemeProvider>` for skins: subscribes to
|
|
13
|
+
* the engine store, applies/reverts the resolved skin on the target element,
|
|
14
|
+
* and provides the engine + current skin to descendants. Zero skin logic.
|
|
15
|
+
*/
|
|
16
|
+
declare const SkinProvider: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
17
|
+
engine: {
|
|
18
|
+
type: PropType<SkinEngine>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
target: {
|
|
22
|
+
type: PropType<HTMLElement | null>;
|
|
23
|
+
default: null;
|
|
24
|
+
};
|
|
25
|
+
cspNonce: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
32
|
+
engine: {
|
|
33
|
+
type: PropType<SkinEngine>;
|
|
34
|
+
required: true;
|
|
35
|
+
};
|
|
36
|
+
target: {
|
|
37
|
+
type: PropType<HTMLElement | null>;
|
|
38
|
+
default: null;
|
|
39
|
+
};
|
|
40
|
+
cspNonce: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
default: undefined;
|
|
43
|
+
};
|
|
44
|
+
}>> & Readonly<{}>, {
|
|
45
|
+
target: HTMLElement | null;
|
|
46
|
+
cspNonce: string;
|
|
47
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
48
|
+
declare function useSkinContext(): IrisSkinContext;
|
|
49
|
+
|
|
50
|
+
interface UseSkinReturn {
|
|
51
|
+
skin: ComputedRef<ResolvedSkin>;
|
|
52
|
+
setSkin: (id: string) => void;
|
|
53
|
+
loadSkin: (source: string | Skin) => Promise<ResolvedSkin>;
|
|
54
|
+
useFromCatalog: (id: string) => Promise<ResolvedSkin>;
|
|
55
|
+
patch: (overrides: SkinPatch) => void;
|
|
56
|
+
resetPatch: () => void;
|
|
57
|
+
setMode: (mode: SkinMode) => void;
|
|
58
|
+
getMode: () => SkinMode;
|
|
59
|
+
/** Logical selected id (pre system-variant remap) — e.g. 'auto' while following the system. */
|
|
60
|
+
getActiveId: () => string;
|
|
61
|
+
availableSkins: () => Skin[];
|
|
62
|
+
errors: () => SkinError[];
|
|
63
|
+
}
|
|
64
|
+
/** Read + control the active skin from anywhere inside a `<SkinProvider>`. */
|
|
65
|
+
declare function useSkin(): UseSkinReturn;
|
|
66
|
+
|
|
67
|
+
export { type IrisSkinContext, IrisSkinKey, SkinProvider, type UseSkinReturn, useSkin, useSkinContext };
|
package/dist/skins.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SkinEngine, ResolvedSkin, Skin, SkinPatch, SkinMode, SkinError } from '@iris-ui-kit/skins';
|
|
2
|
+
export { ApplySkinResult, LoadSkinOptions, ResolvedSkin, Skin, SkinBootScriptConfig, SkinCatalog, SkinCatalogConfig, SkinEngine, SkinEngineConfig, SkinError, SkinErrorCode, SkinLookup, SkinManifest, SkinManifestEntry, SkinMode, SkinPatch, SkinRegistry, SkinResolutionError, SkinStorage, SkinTokenOverrides, applySkin, builtinSkins, createSkinCatalog, createSkinEngine, createSkinRegistry, darkSkin, lightSkin, loadSkin, localStorageSkinStorage, memorySkinStorage, renderSkinStyle, resolveSkin, skinBootScript, skinError, skinToCssEntries, validateSkin } from '@iris-ui-kit/skins';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import { Ref, InjectionKey, PropType, ComputedRef } from 'vue';
|
|
5
|
+
|
|
6
|
+
interface IrisSkinContext {
|
|
7
|
+
engine: SkinEngine;
|
|
8
|
+
current: Ref<ResolvedSkin>;
|
|
9
|
+
}
|
|
10
|
+
declare const IrisSkinKey: InjectionKey<IrisSkinContext>;
|
|
11
|
+
/**
|
|
12
|
+
* Renderless provider mirroring `<IrisThemeProvider>` for skins: subscribes to
|
|
13
|
+
* the engine store, applies/reverts the resolved skin on the target element,
|
|
14
|
+
* and provides the engine + current skin to descendants. Zero skin logic.
|
|
15
|
+
*/
|
|
16
|
+
declare const SkinProvider: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
17
|
+
engine: {
|
|
18
|
+
type: PropType<SkinEngine>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
target: {
|
|
22
|
+
type: PropType<HTMLElement | null>;
|
|
23
|
+
default: null;
|
|
24
|
+
};
|
|
25
|
+
cspNonce: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
32
|
+
engine: {
|
|
33
|
+
type: PropType<SkinEngine>;
|
|
34
|
+
required: true;
|
|
35
|
+
};
|
|
36
|
+
target: {
|
|
37
|
+
type: PropType<HTMLElement | null>;
|
|
38
|
+
default: null;
|
|
39
|
+
};
|
|
40
|
+
cspNonce: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
default: undefined;
|
|
43
|
+
};
|
|
44
|
+
}>> & Readonly<{}>, {
|
|
45
|
+
target: HTMLElement | null;
|
|
46
|
+
cspNonce: string;
|
|
47
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
48
|
+
declare function useSkinContext(): IrisSkinContext;
|
|
49
|
+
|
|
50
|
+
interface UseSkinReturn {
|
|
51
|
+
skin: ComputedRef<ResolvedSkin>;
|
|
52
|
+
setSkin: (id: string) => void;
|
|
53
|
+
loadSkin: (source: string | Skin) => Promise<ResolvedSkin>;
|
|
54
|
+
useFromCatalog: (id: string) => Promise<ResolvedSkin>;
|
|
55
|
+
patch: (overrides: SkinPatch) => void;
|
|
56
|
+
resetPatch: () => void;
|
|
57
|
+
setMode: (mode: SkinMode) => void;
|
|
58
|
+
getMode: () => SkinMode;
|
|
59
|
+
/** Logical selected id (pre system-variant remap) — e.g. 'auto' while following the system. */
|
|
60
|
+
getActiveId: () => string;
|
|
61
|
+
availableSkins: () => Skin[];
|
|
62
|
+
errors: () => SkinError[];
|
|
63
|
+
}
|
|
64
|
+
/** Read + control the active skin from anywhere inside a `<SkinProvider>`. */
|
|
65
|
+
declare function useSkin(): UseSkinReturn;
|
|
66
|
+
|
|
67
|
+
export { type IrisSkinContext, IrisSkinKey, SkinProvider, type UseSkinReturn, useSkin, useSkinContext };
|
package/dist/skins.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { IrisSkinKey, SkinProvider, SkinResolutionError, applySkin, builtinSkins, createSkinCatalog, createSkinEngine, createSkinRegistry, darkSkin, lightSkin, loadSkin, localStorageSkinStorage, memorySkinStorage, renderSkinStyle, resolveSkin, skinBootScript, skinError, skinToCssEntries, useSkin, useSkinContext, validateSkin } from './chunk-H7HVVPYR.js';
|
|
2
|
+
//# sourceMappingURL=skins.js.map
|
|
3
|
+
//# sourceMappingURL=skins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"skins.js"}
|
package/dist/theme.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
var theme = require('@iris-ui-kit/theme');
|
|
5
|
+
|
|
6
|
+
// src/theme/ThemeProvider.ts
|
|
7
|
+
var IrisThemeKey = /* @__PURE__ */ Symbol("IrisTheme");
|
|
8
|
+
var ThemeProvider = vue.defineComponent({
|
|
9
|
+
name: "IrisThemeProvider",
|
|
10
|
+
props: {
|
|
11
|
+
store: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
target: {
|
|
16
|
+
type: Object,
|
|
17
|
+
default: null
|
|
18
|
+
},
|
|
19
|
+
/** Writing direction; sets `dir` on the target for RTL. Default `'ltr'`. */
|
|
20
|
+
dir: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: "ltr"
|
|
23
|
+
},
|
|
24
|
+
/** CSP nonce for injected inline stylesheets. */
|
|
25
|
+
cspNonce: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: void 0
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
setup(props, { slots }) {
|
|
31
|
+
const current = vue.ref(props.store.store.getState());
|
|
32
|
+
const unsubscribe = props.store.store.subscribe((next) => {
|
|
33
|
+
current.value = next;
|
|
34
|
+
});
|
|
35
|
+
let applied = null;
|
|
36
|
+
let dirApplied = null;
|
|
37
|
+
const targetEl = () => props.target ?? document.documentElement;
|
|
38
|
+
const applyCurrent = () => {
|
|
39
|
+
applied?.revert();
|
|
40
|
+
applied = theme.applyTheme(current.value, targetEl());
|
|
41
|
+
};
|
|
42
|
+
const applyDir = () => {
|
|
43
|
+
dirApplied?.revert();
|
|
44
|
+
dirApplied = theme.applyDirection(props.dir, targetEl());
|
|
45
|
+
};
|
|
46
|
+
vue.onMounted(() => {
|
|
47
|
+
theme.injectGlobalStyles(props.cspNonce);
|
|
48
|
+
applyCurrent();
|
|
49
|
+
applyDir();
|
|
50
|
+
});
|
|
51
|
+
vue.watch(current, () => {
|
|
52
|
+
if (applied) applyCurrent();
|
|
53
|
+
});
|
|
54
|
+
vue.watch(
|
|
55
|
+
() => props.dir,
|
|
56
|
+
() => {
|
|
57
|
+
if (dirApplied) applyDir();
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
vue.onBeforeUnmount(() => {
|
|
61
|
+
unsubscribe();
|
|
62
|
+
applied?.revert();
|
|
63
|
+
applied = null;
|
|
64
|
+
dirApplied?.revert();
|
|
65
|
+
dirApplied = null;
|
|
66
|
+
});
|
|
67
|
+
vue.provide(IrisThemeKey, { store: props.store, current, dir: vue.computed(() => props.dir) });
|
|
68
|
+
return () => slots.default?.();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
function useThemeContext() {
|
|
72
|
+
const ctx = vue.inject(IrisThemeKey);
|
|
73
|
+
if (!ctx) {
|
|
74
|
+
throw new Error("[iris-ui] useTheme(): no <ThemeProvider> ancestor found");
|
|
75
|
+
}
|
|
76
|
+
return ctx;
|
|
77
|
+
}
|
|
78
|
+
function useDirection() {
|
|
79
|
+
const ctx = vue.inject(IrisThemeKey, null);
|
|
80
|
+
return ctx ? ctx.dir : vue.computed(() => "ltr");
|
|
81
|
+
}
|
|
82
|
+
function useTheme() {
|
|
83
|
+
const ctx = useThemeContext();
|
|
84
|
+
return {
|
|
85
|
+
theme: vue.computed(() => ctx.current.value),
|
|
86
|
+
setTheme: ctx.store.setTheme,
|
|
87
|
+
availableThemes: ctx.store.availableThemes
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function useColorScheme() {
|
|
91
|
+
const scheme = vue.ref(theme.getColorScheme());
|
|
92
|
+
const stop = theme.watchColorScheme((s) => {
|
|
93
|
+
scheme.value = s;
|
|
94
|
+
});
|
|
95
|
+
vue.onBeforeUnmount(stop);
|
|
96
|
+
return scheme;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
exports.IrisThemeKey = IrisThemeKey;
|
|
100
|
+
exports.ThemeProvider = ThemeProvider;
|
|
101
|
+
exports.useColorScheme = useColorScheme;
|
|
102
|
+
exports.useDirection = useDirection;
|
|
103
|
+
exports.useTheme = useTheme;
|
|
104
|
+
exports.useThemeContext = useThemeContext;
|
|
105
|
+
//# sourceMappingURL=theme.cjs.map
|
|
106
|
+
//# sourceMappingURL=theme.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/ThemeProvider.ts","../src/theme/useTheme.ts","../src/theme/useColorScheme.ts"],"names":["defineComponent","ref","applyTheme","applyDirection","onMounted","injectGlobalStyles","watch","onBeforeUnmount","provide","computed","inject","getColorScheme","watchColorScheme"],"mappings":";;;;;;AA+BO,IAAM,YAAA,0BAAsD,WAAW;AAWvE,IAAM,gBAAgBA,mBAAA,CAAgB;AAAA,EAC3C,IAAA,EAAM,mBAAA;AAAA,EACN,KAAA,EAAO;AAAA,IACL,KAAA,EAAO;AAAA,MACL,IAAA,EAAM,MAAA;AAAA,MACN,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA;AAAA,IAEA,GAAA,EAAK;AAAA,MACH,IAAA,EAAM,MAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA;AAAA,IAEA,QAAA,EAAU;AAAA,MACR,IAAA,EAAM,MAAA;AAAA,MACN,OAA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,CAAA;AAAA,EACjB,CAAC,CAAA;AACD,EAAAL,oBAAgB,IAAI,CAAA;AACpB,EAAA,OAAO,MAAA;AACT","file":"theme.cjs","sourcesContent":["import {\n computed,\n defineComponent,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n ref,\n watch,\n type ComputedRef,\n type InjectionKey,\n type PropType,\n type Ref,\n} from 'vue'\nimport {\n applyDirection,\n applyTheme,\n injectGlobalStyles,\n type ApplyDirectionResult,\n type ApplyThemeResult,\n type Direction,\n type ThemeStore,\n} from '@iris-ui-kit/theme'\nimport type { IrisTheme } from '@iris-ui-kit/tokens'\n\nexport interface IrisThemeContext {\n store: ThemeStore\n current: Ref<IrisTheme>\n dir: ComputedRef<Direction>\n}\n\nexport const IrisThemeKey: InjectionKey<IrisThemeContext> = Symbol('IrisTheme')\n\n/**\n * Renderless provider that:\n * 1. exposes the theme store to descendants via `provide`,\n * 2. applies the current theme to a target element on mount and on change,\n * 3. reverts the inline custom properties on unmount.\n *\n * `target` defaults to `document.documentElement`. Pass an element ref to\n * scope a theme to a subtree.\n */\nexport const ThemeProvider = defineComponent({\n name: 'IrisThemeProvider',\n props: {\n store: {\n type: Object as PropType<ThemeStore>,\n required: true,\n },\n target: {\n type: Object as PropType<HTMLElement | null>,\n default: null,\n },\n /** Writing direction; sets `dir` on the target for RTL. Default `'ltr'`. */\n dir: {\n type: String as PropType<Direction>,\n default: 'ltr',\n },\n /** CSP nonce for injected inline stylesheets. */\n cspNonce: {\n type: String,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n const current = ref(props.store.store.getState()) as Ref<IrisTheme>\n const unsubscribe = props.store.store.subscribe((next) => {\n current.value = next\n })\n\n let applied: ApplyThemeResult | null = null\n let dirApplied: ApplyDirectionResult | null = null\n\n const targetEl = () => props.target ?? document.documentElement\n\n const applyCurrent = () => {\n applied?.revert()\n applied = applyTheme(current.value, targetEl())\n }\n\n const applyDir = () => {\n dirApplied?.revert()\n dirApplied = applyDirection(props.dir, targetEl())\n }\n\n onMounted(() => {\n injectGlobalStyles(props.cspNonce)\n applyCurrent()\n applyDir()\n })\n\n watch(current, () => {\n if (applied) applyCurrent()\n })\n\n watch(\n () => props.dir,\n () => {\n if (dirApplied) applyDir()\n },\n )\n\n onBeforeUnmount(() => {\n unsubscribe()\n applied?.revert()\n applied = null\n dirApplied?.revert()\n dirApplied = null\n })\n\n provide(IrisThemeKey, { store: props.store, current, dir: computed(() => props.dir) })\n\n return () => slots.default?.()\n },\n})\n\nexport function useThemeContext(): IrisThemeContext {\n const ctx = inject(IrisThemeKey)\n if (!ctx) {\n throw new Error('[iris-ui] useTheme(): no <ThemeProvider> ancestor found')\n }\n return ctx\n}\n\n/**\n * Current writing direction (`'ltr'` / `'rtl'`) from the nearest\n * `<ThemeProvider>`, or a static `'ltr'` ref when there is none.\n */\nexport function useDirection(): ComputedRef<Direction> {\n const ctx = inject(IrisThemeKey, null)\n return ctx ? ctx.dir : computed(() => 'ltr' as Direction)\n}\n","import { computed, type ComputedRef } from 'vue'\nimport type { IrisTheme } from '@iris-ui-kit/tokens'\nimport { useThemeContext } from './ThemeProvider'\n\nexport interface UseThemeReturn {\n /** Reactive ref to the active theme. */\n theme: ComputedRef<IrisTheme>\n /** Switch by name or by passing a theme directly. */\n setTheme: (target: string | IrisTheme) => void\n /** Map of all themes registered with the store. */\n availableThemes: Record<string, IrisTheme>\n}\n\n/**\n * Read and write the current theme from anywhere inside a <ThemeProvider>.\n *\n * @example\n * const { theme, setTheme } = useTheme()\n * theme.value.colors['iris.primary']\n * setTheme('dark')\n */\nexport function useTheme(): UseThemeReturn {\n const ctx = useThemeContext()\n return {\n theme: computed(() => ctx.current.value),\n setTheme: ctx.store.setTheme,\n availableThemes: ctx.store.availableThemes,\n }\n}\n","import { onBeforeUnmount, ref, type Ref } from 'vue'\nimport { getColorScheme, watchColorScheme, type ColorScheme } from '@iris-ui-kit/theme'\n\n/**\n * Reactive system color scheme (`'light'` / `'dark'`) from\n * `prefers-color-scheme`. SSR-safe (reports `'light'` until matchMedia is\n * available). Wire it to a theme store to auto-follow the system:\n *\n * ```ts\n * const scheme = useColorScheme()\n * watch(scheme, (s) => store.setTheme(s === 'dark' ? 'dark' : 'light'), { immediate: true })\n * ```\n */\nexport function useColorScheme(): Ref<ColorScheme> {\n const scheme = ref<ColorScheme>(getColorScheme())\n const stop = watchColorScheme((s) => {\n scheme.value = s\n })\n onBeforeUnmount(stop)\n return scheme\n}\n"]}
|