@gx-design-vue/context 0.0.5-alpha.2 → 0.0.5-alpha.4
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/context/ContextProvider.d.ts +4 -4
- package/dist/context/ContextProvider.js +3 -5
- package/dist/context/index.js +1 -3
- package/dist/context.esm.js +202 -204
- package/dist/context.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -3
- package/dist/theme-context/ThemeContext.d.ts +4 -4
- package/dist/theme-context/ThemeContext.js +1 -4
- package/dist/theme-context/context.js +1 -3
- package/dist/theme-context/dark.d.ts +2 -2
- package/dist/theme-context/dark.js +1 -3
- package/dist/theme-context/index.js +2 -3
- package/dist/theme-context/types.js +1 -1
- package/dist/theme-context/utils.js +1 -3
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
2
|
import { PropType, SlotsType } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/context/ContextProvider.d.ts
|
|
@@ -19,7 +19,7 @@ declare const contextProps: {
|
|
|
19
19
|
required: boolean;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
declare const ContextProvider:
|
|
22
|
+
declare const ContextProvider: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
23
23
|
contextKey: {
|
|
24
24
|
type: PropType<ContextProviderProps["contextKey"]>;
|
|
25
25
|
required: boolean;
|
|
@@ -28,7 +28,7 @@ declare const ContextProvider: vue0.DefineComponent<vue0.ExtractPropTypes<{
|
|
|
28
28
|
type: PropType<ContextProviderProps["value"]>;
|
|
29
29
|
required: boolean;
|
|
30
30
|
};
|
|
31
|
-
}>, () => any, {}, {}, {},
|
|
31
|
+
}>, () => any, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
|
32
32
|
contextKey: {
|
|
33
33
|
type: PropType<ContextProviderProps["contextKey"]>;
|
|
34
34
|
required: boolean;
|
|
@@ -37,7 +37,7 @@ declare const ContextProvider: vue0.DefineComponent<vue0.ExtractPropTypes<{
|
|
|
37
37
|
type: PropType<ContextProviderProps["value"]>;
|
|
38
38
|
required: boolean;
|
|
39
39
|
};
|
|
40
|
-
}>> & Readonly<{}>, {}, SlotsType<ContextProviderSlots>, {}, {}, string,
|
|
40
|
+
}>> & Readonly<{}>, {}, SlotsType<ContextProviderSlots>, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
|
41
41
|
declare function useContextProvider<T = any>(contextInjectKey: string, defaultValue?: T): T & {
|
|
42
42
|
contextId: string;
|
|
43
43
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { defineComponent, inject, provide, toRefs } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { createUUIDFactory, isObject } from "@gx-design-vue/pro-utils";
|
|
4
3
|
//#region src/context/ContextProvider.tsx
|
|
5
4
|
let contextId = null;
|
|
6
5
|
function updateContextKey(key) {
|
|
@@ -25,7 +24,7 @@ const ContextProvider = /* @__PURE__ */ defineComponent({
|
|
|
25
24
|
setup: (props, { slots }) => {
|
|
26
25
|
if (props.contextKey && props.value && isObject(props.value)) provide(updateContextKey(props.contextKey), {
|
|
27
26
|
...toRefs(props.value),
|
|
28
|
-
contextId: `${props.contextKey}-${
|
|
27
|
+
contextId: `${props.contextKey}-${createUUIDFactory().uuid(10)}`
|
|
29
28
|
});
|
|
30
29
|
else console.warn("[ContextProvider]: contextKey is required");
|
|
31
30
|
return () => slots.default?.();
|
|
@@ -34,6 +33,5 @@ const ContextProvider = /* @__PURE__ */ defineComponent({
|
|
|
34
33
|
function useContextProvider(contextInjectKey, defaultValue) {
|
|
35
34
|
if (typeof contextId === "symbol") return inject(updateContextKey(contextInjectKey), defaultValue || {});
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
|
-
export { ContextProvider, contextProps, useContextProvider };
|
|
37
|
+
export { ContextProvider, contextProps, useContextProvider };
|
package/dist/context/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { inject, provide } from "vue";
|
|
2
|
-
|
|
3
2
|
//#region src/context/index.ts
|
|
4
3
|
function useContext(key, defaultValue) {
|
|
5
4
|
const contextInjectKey = Symbol(key);
|
|
@@ -15,6 +14,5 @@ function useContext(key, defaultValue) {
|
|
|
15
14
|
contextInjectKey
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
//#endregion
|
|
20
|
-
export { useContext };
|
|
18
|
+
export { useContext };
|
package/dist/context.esm.js
CHANGED
|
@@ -1,75 +1,68 @@
|
|
|
1
|
-
import { computed, customRef, defineComponent, getCurrentInstance, getCurrentScope, hasInjectionContext, inject, isRef, nextTick, onMounted, provide, readonly, ref, shallowRef, toRef, toRefs, toValue, unref, watch, watchEffect } from "vue";
|
|
2
|
-
|
|
1
|
+
import { computed as e, customRef as t, defineComponent as n, getCurrentInstance as r, getCurrentScope as i, hasInjectionContext as a, inject as o, isRef as s, nextTick as c, onMounted as l, provide as u, readonly as d, ref as f, shallowReadonly as p, shallowRef as m, toRef as h, toRefs as g, toValue as _, unref as v, watch as y, watchEffect as b } from "vue";
|
|
2
|
+
//#region src/context/index.ts
|
|
3
|
+
function x(e, t) {
|
|
3
4
|
let n = Symbol(e);
|
|
4
5
|
return {
|
|
5
6
|
provideContext: (e) => {
|
|
6
|
-
|
|
7
|
+
u(n, e);
|
|
7
8
|
},
|
|
8
|
-
useInjectContext: (e) =>
|
|
9
|
+
useInjectContext: (e) => o(n, e || t || {}),
|
|
9
10
|
contextInjectKey: n
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ../pro-utils/dist/is/type.js
|
|
15
|
+
function S(e, t) {
|
|
14
16
|
return Object.prototype.toString.call(e) === `[object ${t}]`;
|
|
15
17
|
}
|
|
16
|
-
function
|
|
17
|
-
return e !== null &&
|
|
18
|
+
function C(e) {
|
|
19
|
+
return e !== null && S(e, "Object");
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
function
|
|
23
|
-
rafIds.delete(e);
|
|
24
|
-
}
|
|
25
|
-
function wrapperRaf(e, t = 1) {
|
|
26
|
-
rafUUID += 1;
|
|
27
|
-
let n = rafUUID;
|
|
28
|
-
function r(t) {
|
|
29
|
-
if (t === 0) cleanup(n), e();
|
|
30
|
-
else {
|
|
31
|
-
let e = raf(() => {
|
|
32
|
-
r(t - 1);
|
|
33
|
-
});
|
|
34
|
-
rafIds.set(n, e);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return r(t), n;
|
|
38
|
-
}
|
|
39
|
-
wrapperRaf.cancel = (e) => {
|
|
40
|
-
let t = rafIds.get(e);
|
|
41
|
-
return cleanup(t), caf(t);
|
|
42
|
-
};
|
|
43
|
-
function getRandomNumber() {
|
|
44
|
-
let e = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region ../pro-utils/dist/string/uuid.js
|
|
23
|
+
var w = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
|
|
24
|
+
function T() {
|
|
45
25
|
return {
|
|
46
|
-
uuid(
|
|
47
|
-
let
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
uuid(e, t) {
|
|
27
|
+
let n = w, r = t || n.length;
|
|
28
|
+
if (e) {
|
|
29
|
+
let t = "";
|
|
30
|
+
for (let i = 0; i < e; i += 1) t += n[Math.floor(Math.random() * r)];
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
34
|
+
let t = Math.floor(Math.random() * 16);
|
|
35
|
+
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
36
|
+
});
|
|
51
37
|
},
|
|
52
38
|
uuidFast() {
|
|
53
|
-
let
|
|
54
|
-
for (
|
|
55
|
-
|
|
39
|
+
let e = w, t = Array.from({ length: 36 });
|
|
40
|
+
for (let n = 0; n < 36; n += 1) if (n === 8 || n === 13 || n === 18 || n === 23) t[n] = "-";
|
|
41
|
+
else if (n === 14) t[n] = "4";
|
|
42
|
+
else {
|
|
43
|
+
let r = Math.floor(Math.random() * 16);
|
|
44
|
+
t[n] = e[n === 19 ? r & 3 | 8 : r];
|
|
45
|
+
}
|
|
46
|
+
return t.join("");
|
|
56
47
|
},
|
|
57
48
|
uuidString() {
|
|
58
49
|
return this.uuidFast().replace(/-/g, "");
|
|
59
50
|
},
|
|
60
51
|
uuidCompact() {
|
|
61
52
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
62
|
-
let t = Math.random() * 16
|
|
63
|
-
return (e === "x" ? t : t
|
|
53
|
+
let t = Math.floor(Math.random() * 16);
|
|
54
|
+
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
64
55
|
});
|
|
65
56
|
}
|
|
66
57
|
};
|
|
67
58
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/context/ContextProvider.tsx
|
|
61
|
+
var E = null;
|
|
62
|
+
function D(e) {
|
|
63
|
+
return E || (E = Symbol(e), E);
|
|
71
64
|
}
|
|
72
|
-
var
|
|
65
|
+
var O = /* @__PURE__ */ n({
|
|
73
66
|
name: "ContextProvider",
|
|
74
67
|
props: {
|
|
75
68
|
contextKey: {
|
|
@@ -82,31 +75,32 @@ var ContextProvider = /* @__PURE__ */ defineComponent({
|
|
|
82
75
|
}
|
|
83
76
|
},
|
|
84
77
|
slots: Object,
|
|
85
|
-
setup: (e, { slots: t }) => (e.contextKey && e.value &&
|
|
86
|
-
...
|
|
87
|
-
contextId: `${e.contextKey}-${
|
|
78
|
+
setup: (e, { slots: t }) => (e.contextKey && e.value && C(e.value) ? u(D(e.contextKey), {
|
|
79
|
+
...g(e.value),
|
|
80
|
+
contextId: `${e.contextKey}-${T().uuid(10)}`
|
|
88
81
|
}) : console.warn("[ContextProvider]: contextKey is required"), () => t.default?.())
|
|
89
82
|
});
|
|
90
|
-
function
|
|
91
|
-
if (typeof
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
function k(e, t) {
|
|
84
|
+
if (typeof E == "symbol") return o(D(e), t || {});
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/theme-context/context.ts
|
|
88
|
+
var { provideContext: A, useInjectContext: j } = x("theme-provider"), M = /* @__PURE__ */ new WeakMap(), N = (...e) => {
|
|
89
|
+
let t = e[0], n = r()?.proxy ?? i();
|
|
90
|
+
if (n == null && !a()) throw Error("injectLocal must be called in setup");
|
|
91
|
+
return n && M.has(n) && t in M.get(n) ? M.get(n)[t] : o(...e);
|
|
92
|
+
}, P = typeof window < "u" && typeof document < "u";
|
|
99
93
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
100
|
-
var
|
|
101
|
-
function
|
|
102
|
-
if (e.length !== 1) return
|
|
94
|
+
var ee = Object.prototype.toString, te = (e) => ee.call(e) === "[object Object]", F = () => {};
|
|
95
|
+
function I(...e) {
|
|
96
|
+
if (e.length !== 1) return h(...e);
|
|
103
97
|
let n = e[0];
|
|
104
|
-
return typeof n == "function" ?
|
|
98
|
+
return typeof n == "function" ? d(t(() => ({
|
|
105
99
|
get: n,
|
|
106
|
-
set:
|
|
107
|
-
}))) :
|
|
100
|
+
set: F
|
|
101
|
+
}))) : f(n);
|
|
108
102
|
}
|
|
109
|
-
function
|
|
103
|
+
function ne(e, t) {
|
|
110
104
|
function n(...n) {
|
|
111
105
|
return new Promise((r, i) => {
|
|
112
106
|
Promise.resolve(e(() => t.apply(this, n), {
|
|
@@ -118,9 +112,9 @@ function createFilterWrapper(e, t) {
|
|
|
118
112
|
}
|
|
119
113
|
return n;
|
|
120
114
|
}
|
|
121
|
-
var
|
|
122
|
-
function
|
|
123
|
-
let { initialState: n = "active" } = t, r =
|
|
115
|
+
var L = (e) => e();
|
|
116
|
+
function R(e = L, t = {}) {
|
|
117
|
+
let { initialState: n = "active" } = t, r = I(n === "active");
|
|
124
118
|
function i() {
|
|
125
119
|
r.value = !1;
|
|
126
120
|
}
|
|
@@ -128,7 +122,7 @@ function pausableFilter(e = bypassFilter, t = {}) {
|
|
|
128
122
|
r.value = !0;
|
|
129
123
|
}
|
|
130
124
|
return {
|
|
131
|
-
isActive:
|
|
125
|
+
isActive: p(r),
|
|
132
126
|
pause: i,
|
|
133
127
|
resume: a,
|
|
134
128
|
eventFilter: (...t) => {
|
|
@@ -136,23 +130,23 @@ function pausableFilter(e = bypassFilter, t = {}) {
|
|
|
136
130
|
}
|
|
137
131
|
};
|
|
138
132
|
}
|
|
139
|
-
function
|
|
133
|
+
function z(e) {
|
|
140
134
|
return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
|
|
141
135
|
}
|
|
142
|
-
function
|
|
136
|
+
function B(e) {
|
|
143
137
|
return Array.isArray(e) ? e : [e];
|
|
144
138
|
}
|
|
145
|
-
function
|
|
146
|
-
return e ||
|
|
139
|
+
function V(e) {
|
|
140
|
+
return e || r();
|
|
147
141
|
}
|
|
148
|
-
function
|
|
149
|
-
let { eventFilter: r =
|
|
150
|
-
return
|
|
142
|
+
function re(e, t, n = {}) {
|
|
143
|
+
let { eventFilter: r = L, ...i } = n;
|
|
144
|
+
return y(e, ne(r, t), i);
|
|
151
145
|
}
|
|
152
|
-
function
|
|
153
|
-
let { eventFilter: r, initialState: i = "active", ...a } = n, { eventFilter: o, pause: s, resume: c, isActive: l } =
|
|
146
|
+
function ie(e, t, n = {}) {
|
|
147
|
+
let { eventFilter: r, initialState: i = "active", ...a } = n, { eventFilter: o, pause: s, resume: c, isActive: l } = R(r, { initialState: i });
|
|
154
148
|
return {
|
|
155
|
-
stop:
|
|
149
|
+
stop: re(e, t, {
|
|
156
150
|
...a,
|
|
157
151
|
eventFilter: o
|
|
158
152
|
}),
|
|
@@ -161,96 +155,98 @@ function watchPausable(e, t, n = {}) {
|
|
|
161
155
|
isActive: l
|
|
162
156
|
};
|
|
163
157
|
}
|
|
164
|
-
function
|
|
165
|
-
|
|
158
|
+
function H(e, t = !0, n) {
|
|
159
|
+
V(n) ? l(e, n) : t ? e() : c(e);
|
|
166
160
|
}
|
|
167
|
-
function
|
|
168
|
-
let { truthyValue: n = !0, falsyValue: r = !1 } = t, i =
|
|
161
|
+
function ae(e = !1, t = {}) {
|
|
162
|
+
let { truthyValue: n = !0, falsyValue: r = !1 } = t, i = s(e), a = m(e);
|
|
169
163
|
function o(e) {
|
|
170
164
|
if (arguments.length) return a.value = e, a.value;
|
|
171
165
|
{
|
|
172
|
-
let e =
|
|
173
|
-
return a.value = a.value === e ?
|
|
166
|
+
let e = _(n);
|
|
167
|
+
return a.value = a.value === e ? _(r) : e, a.value;
|
|
174
168
|
}
|
|
175
169
|
}
|
|
176
170
|
return i ? o : [a, o];
|
|
177
171
|
}
|
|
178
|
-
function
|
|
179
|
-
return
|
|
172
|
+
function U(e, t, n) {
|
|
173
|
+
return y(e, t, {
|
|
180
174
|
...n,
|
|
181
175
|
immediate: !0
|
|
182
176
|
});
|
|
183
177
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region ../../node_modules/.pnpm/@vueuse+core@14.3.0_vue@3.5.27_typescript@6.0.3_/node_modules/@vueuse/core/dist/index.js
|
|
180
|
+
var W = P ? window : void 0;
|
|
181
|
+
P && window.document, P && window.navigator, P && window.location;
|
|
182
|
+
function G(e) {
|
|
183
|
+
let t = _(e);
|
|
188
184
|
return t?.$el ?? t;
|
|
189
185
|
}
|
|
190
|
-
function
|
|
191
|
-
let n = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), r =
|
|
192
|
-
let e =
|
|
186
|
+
function K(...t) {
|
|
187
|
+
let n = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), r = e(() => {
|
|
188
|
+
let e = B(_(t[0])).filter((e) => e != null);
|
|
193
189
|
return e.every((e) => typeof e != "string") ? e : void 0;
|
|
194
190
|
});
|
|
195
|
-
return
|
|
196
|
-
r.value?.map((e) =>
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
return U(() => [
|
|
192
|
+
r.value?.map((e) => G(e)) ?? [W].filter((e) => e != null),
|
|
193
|
+
B(_(r.value ? t[1] : t[0])),
|
|
194
|
+
B(v(r.value ? t[2] : t[1])),
|
|
195
|
+
_(r.value ? t[3] : t[2])
|
|
200
196
|
], ([e, t, r, i], a, o) => {
|
|
201
197
|
if (!e?.length || !t?.length || !r?.length) return;
|
|
202
|
-
let s =
|
|
198
|
+
let s = te(i) ? { ...i } : i, c = e.flatMap((e) => t.flatMap((t) => r.map((r) => n(e, t, r, s))));
|
|
203
199
|
o(() => {
|
|
204
200
|
c.forEach((e) => e());
|
|
205
201
|
});
|
|
206
202
|
}, { flush: "post" });
|
|
207
203
|
}
|
|
208
|
-
function
|
|
209
|
-
let e =
|
|
210
|
-
return t &&
|
|
204
|
+
function q() {
|
|
205
|
+
let e = m(!1), t = r();
|
|
206
|
+
return t && l(() => {
|
|
211
207
|
e.value = !0;
|
|
212
208
|
}, t), e;
|
|
213
209
|
}
|
|
214
210
|
/* @__NO_SIDE_EFFECTS__ */
|
|
215
|
-
function
|
|
216
|
-
let n =
|
|
217
|
-
return
|
|
211
|
+
function oe(t) {
|
|
212
|
+
let n = q();
|
|
213
|
+
return e(() => (n.value, !!t()));
|
|
218
214
|
}
|
|
219
|
-
var
|
|
215
|
+
var se = Symbol("vueuse-ssr-width");
|
|
220
216
|
/* @__NO_SIDE_EFFECTS__ */
|
|
221
|
-
function
|
|
222
|
-
let e =
|
|
217
|
+
function ce() {
|
|
218
|
+
let e = a() ? N(se, null) : null;
|
|
223
219
|
return typeof e == "number" ? e : void 0;
|
|
224
220
|
}
|
|
225
|
-
function
|
|
226
|
-
let { window: r =
|
|
227
|
-
return
|
|
221
|
+
function le(t, n = {}) {
|
|
222
|
+
let { window: r = W, ssrWidth: i = /* @__PURE__ */ ce() } = n, a = /* @__PURE__ */ oe(() => r && "matchMedia" in r && typeof r.matchMedia == "function"), o = m(typeof i == "number"), s = m(), c = m(!1);
|
|
223
|
+
return b(() => {
|
|
228
224
|
if (o.value) {
|
|
229
|
-
o.value = !a.value, c.value =
|
|
225
|
+
o.value = !a.value, c.value = _(t).split(",").some((e) => {
|
|
230
226
|
let t = e.includes("not all"), n = e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), r = e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), a = !!(n || r);
|
|
231
|
-
return n && a && (a = i >=
|
|
227
|
+
return n && a && (a = i >= z(n[1])), r && a && (a = i <= z(r[1])), t ? !a : a;
|
|
232
228
|
});
|
|
233
229
|
return;
|
|
234
230
|
}
|
|
235
|
-
a.value && (s.value = r.matchMedia(
|
|
236
|
-
}),
|
|
231
|
+
a.value && (s.value = r.matchMedia(_(t)), c.value = s.value.matches);
|
|
232
|
+
}), K(s, "change", (e) => {
|
|
237
233
|
c.value = e.matches;
|
|
238
|
-
}, { passive: !0 }),
|
|
234
|
+
}, { passive: !0 }), e(() => c.value);
|
|
239
235
|
}
|
|
240
|
-
var
|
|
241
|
-
function
|
|
242
|
-
return
|
|
236
|
+
var J = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Y = "__vueuse_ssr_handlers__", ue = /* @__PURE__ */ de();
|
|
237
|
+
function de() {
|
|
238
|
+
return Y in J || (J[Y] = J[Y] || {}), J[Y];
|
|
243
239
|
}
|
|
244
|
-
function
|
|
245
|
-
return
|
|
240
|
+
function X(e, t) {
|
|
241
|
+
return ue[e] || t;
|
|
246
242
|
}
|
|
247
|
-
function
|
|
248
|
-
return
|
|
243
|
+
function fe(e) {
|
|
244
|
+
return le("(prefers-color-scheme: dark)", e);
|
|
249
245
|
}
|
|
250
|
-
function
|
|
246
|
+
function pe(e) {
|
|
251
247
|
return e == null ? "any" : e instanceof Set ? "set" : e instanceof Map ? "map" : e instanceof Date ? "date" : typeof e == "boolean" ? "boolean" : typeof e == "string" ? "string" : typeof e == "object" ? "object" : Number.isNaN(e) ? "any" : "number";
|
|
252
248
|
}
|
|
253
|
-
var
|
|
249
|
+
var me = {
|
|
254
250
|
boolean: {
|
|
255
251
|
read: (e) => e === "true",
|
|
256
252
|
write: (e) => String(e)
|
|
@@ -283,102 +279,102 @@ var StorageSerializers = {
|
|
|
283
279
|
read: (e) => new Date(e),
|
|
284
280
|
write: (e) => e.toISOString()
|
|
285
281
|
}
|
|
286
|
-
},
|
|
287
|
-
function
|
|
288
|
-
let { flush: a = "pre", deep: o = !0, listenToStorageChanges: s = !0, writeDefaults: l = !0, mergeDefaults: u = !1, shallow: d, window:
|
|
282
|
+
}, Z = "vueuse-storage";
|
|
283
|
+
function he(t, n, r, i = {}) {
|
|
284
|
+
let { flush: a = "pre", deep: o = !0, listenToStorageChanges: s = !0, writeDefaults: l = !0, mergeDefaults: u = !1, shallow: d, window: p = W, eventFilter: h, onError: g = (e) => {
|
|
289
285
|
console.error(e);
|
|
290
|
-
}, initOnMounted: v } = i,
|
|
286
|
+
}, initOnMounted: v } = i, b = (d ? m : f)(typeof n == "function" ? n() : n), x = e(() => _(t));
|
|
291
287
|
if (!r) try {
|
|
292
|
-
r =
|
|
288
|
+
r = X("getDefaultStorage", () => W?.localStorage)();
|
|
293
289
|
} catch (e) {
|
|
294
|
-
|
|
290
|
+
g(e);
|
|
295
291
|
}
|
|
296
|
-
if (!r) return
|
|
297
|
-
let
|
|
292
|
+
if (!r) return b;
|
|
293
|
+
let S = _(n), C = pe(S), w = i.serializer ?? me[C], { pause: T, resume: E } = ie(b, (e) => k(e), {
|
|
298
294
|
flush: a,
|
|
299
295
|
deep: o,
|
|
300
296
|
eventFilter: h
|
|
301
297
|
});
|
|
302
|
-
|
|
303
|
-
let
|
|
304
|
-
|
|
305
|
-
v && !
|
|
306
|
-
}, { passive: !0 }) :
|
|
307
|
-
v && !
|
|
308
|
-
})), v ?
|
|
309
|
-
|
|
310
|
-
}) :
|
|
311
|
-
function
|
|
312
|
-
if (
|
|
298
|
+
y(x, () => j(), { flush: a });
|
|
299
|
+
let D = !1;
|
|
300
|
+
p && s && (r instanceof Storage ? K(p, "storage", (e) => {
|
|
301
|
+
v && !D || j(e);
|
|
302
|
+
}, { passive: !0 }) : K(p, Z, (e) => {
|
|
303
|
+
v && !D || M(e);
|
|
304
|
+
})), v ? H(() => {
|
|
305
|
+
D = !0, j();
|
|
306
|
+
}) : j();
|
|
307
|
+
function O(e, t) {
|
|
308
|
+
if (p) {
|
|
313
309
|
let n = {
|
|
314
|
-
key:
|
|
310
|
+
key: x.value,
|
|
315
311
|
oldValue: e,
|
|
316
312
|
newValue: t,
|
|
317
313
|
storageArea: r
|
|
318
314
|
};
|
|
319
|
-
|
|
315
|
+
p.dispatchEvent(r instanceof Storage ? new StorageEvent("storage", n) : new CustomEvent(Z, { detail: n }));
|
|
320
316
|
}
|
|
321
317
|
}
|
|
322
|
-
function
|
|
318
|
+
function k(e) {
|
|
323
319
|
try {
|
|
324
|
-
let t = r.getItem(
|
|
325
|
-
if (e == null)
|
|
320
|
+
let t = r.getItem(x.value);
|
|
321
|
+
if (e == null) O(t, null), r.removeItem(x.value);
|
|
326
322
|
else {
|
|
327
|
-
let n =
|
|
328
|
-
t !== n && (r.setItem(
|
|
323
|
+
let n = w.write(e);
|
|
324
|
+
t !== n && (r.setItem(x.value, n), O(t, n));
|
|
329
325
|
}
|
|
330
326
|
} catch (e) {
|
|
331
|
-
|
|
327
|
+
g(e);
|
|
332
328
|
}
|
|
333
329
|
}
|
|
334
|
-
function
|
|
335
|
-
let t = e ? e.newValue : r.getItem(
|
|
336
|
-
if (t == null) return l &&
|
|
330
|
+
function A(e) {
|
|
331
|
+
let t = e ? e.newValue : r.getItem(x.value);
|
|
332
|
+
if (t == null) return l && S != null && r.setItem(x.value, w.write(S)), S;
|
|
337
333
|
if (!e && u) {
|
|
338
|
-
let e =
|
|
339
|
-
return typeof u == "function" ? u(e,
|
|
340
|
-
...
|
|
334
|
+
let e = w.read(t);
|
|
335
|
+
return typeof u == "function" ? u(e, S) : C === "object" && !Array.isArray(e) ? {
|
|
336
|
+
...S,
|
|
341
337
|
...e
|
|
342
338
|
} : e;
|
|
343
339
|
} else if (typeof t != "string") return t;
|
|
344
|
-
else return
|
|
340
|
+
else return w.read(t);
|
|
345
341
|
}
|
|
346
|
-
function
|
|
342
|
+
function j(e) {
|
|
347
343
|
if (!(e && e.storageArea !== r)) {
|
|
348
344
|
if (e && e.key == null) {
|
|
349
|
-
|
|
345
|
+
b.value = S;
|
|
350
346
|
return;
|
|
351
347
|
}
|
|
352
|
-
if (!(e && e.key !==
|
|
353
|
-
|
|
348
|
+
if (!(e && e.key !== x.value)) {
|
|
349
|
+
T();
|
|
354
350
|
try {
|
|
355
|
-
let t =
|
|
356
|
-
(e === void 0 || e?.newValue !== t) && (
|
|
351
|
+
let t = w.write(b.value);
|
|
352
|
+
(e === void 0 || e?.newValue !== t) && (b.value = A(e));
|
|
357
353
|
} catch (e) {
|
|
358
|
-
|
|
354
|
+
g(e);
|
|
359
355
|
} finally {
|
|
360
|
-
e ?
|
|
356
|
+
e ? c(E) : E();
|
|
361
357
|
}
|
|
362
358
|
}
|
|
363
359
|
}
|
|
364
360
|
}
|
|
365
|
-
function
|
|
366
|
-
|
|
361
|
+
function M(e) {
|
|
362
|
+
j(e.detail);
|
|
367
363
|
}
|
|
368
|
-
return
|
|
364
|
+
return b;
|
|
369
365
|
}
|
|
370
|
-
var
|
|
371
|
-
function
|
|
372
|
-
let { selector: n = "html", attribute: r = "class", initialValue: i = "auto", window: a =
|
|
366
|
+
var ge = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";
|
|
367
|
+
function Q(t = {}) {
|
|
368
|
+
let { selector: n = "html", attribute: r = "class", initialValue: i = "auto", window: a = W, storage: o, storageKey: s = "vueuse-color-scheme", listenToStorageChanges: c = !0, storageRef: l, emitAuto: u, disableTransition: d = !0 } = t, f = {
|
|
373
369
|
auto: "",
|
|
374
370
|
light: "light",
|
|
375
371
|
dark: "dark",
|
|
376
372
|
...t.modes || {}
|
|
377
|
-
}, p =
|
|
373
|
+
}, p = fe({ window: a }), m = e(() => p.value ? "dark" : "light"), h = l || (s == null ? I(i) : he(s, i, o, {
|
|
378
374
|
window: a,
|
|
379
375
|
listenToStorageChanges: c
|
|
380
|
-
})), g =
|
|
381
|
-
let r = typeof e == "string" ? a?.document.querySelector(e) :
|
|
376
|
+
})), g = e(() => h.value === "auto" ? m.value : h.value), _ = X("updateHTMLAttrs", (e, t, n) => {
|
|
377
|
+
let r = typeof e == "string" ? a?.document.querySelector(e) : G(e);
|
|
382
378
|
if (!r) return;
|
|
383
379
|
let i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = null;
|
|
384
380
|
if (t === "class") {
|
|
@@ -392,7 +388,7 @@ function useColorMode(t = {}) {
|
|
|
392
388
|
};
|
|
393
389
|
if (i.size === 0 && o.size === 0 && s === null) return;
|
|
394
390
|
let c;
|
|
395
|
-
d && (c = a.document.createElement("style"), c.appendChild(document.createTextNode(
|
|
391
|
+
d && (c = a.document.createElement("style"), c.appendChild(document.createTextNode(ge)), a.document.head.appendChild(c));
|
|
396
392
|
for (let e of i) r.classList.add(e);
|
|
397
393
|
for (let e of o) r.classList.remove(e);
|
|
398
394
|
s && r.setAttribute(s.key, s.value), d && (a.getComputedStyle(c).opacity, document.head.removeChild(c));
|
|
@@ -400,14 +396,14 @@ function useColorMode(t = {}) {
|
|
|
400
396
|
function v(e) {
|
|
401
397
|
_(n, r, f[e] ?? e);
|
|
402
398
|
}
|
|
403
|
-
function
|
|
399
|
+
function b(e) {
|
|
404
400
|
t.onChanged ? t.onChanged(e, v) : v(e);
|
|
405
401
|
}
|
|
406
|
-
|
|
402
|
+
y(g, b, {
|
|
407
403
|
flush: "post",
|
|
408
404
|
immediate: !0
|
|
409
|
-
}),
|
|
410
|
-
let
|
|
405
|
+
}), H(() => b(g.value));
|
|
406
|
+
let x = e({
|
|
411
407
|
get() {
|
|
412
408
|
return u ? h.value : g.value;
|
|
413
409
|
},
|
|
@@ -415,14 +411,14 @@ function useColorMode(t = {}) {
|
|
|
415
411
|
h.value = e;
|
|
416
412
|
}
|
|
417
413
|
});
|
|
418
|
-
return Object.assign(
|
|
414
|
+
return Object.assign(x, {
|
|
419
415
|
store: h,
|
|
420
416
|
system: m,
|
|
421
417
|
state: g
|
|
422
418
|
});
|
|
423
419
|
}
|
|
424
|
-
function
|
|
425
|
-
let { valueDark: n = "dark", valueLight: r = "" } = t, i =
|
|
420
|
+
function _e(t = {}) {
|
|
421
|
+
let { valueDark: n = "dark", valueLight: r = "" } = t, i = Q({
|
|
426
422
|
...t,
|
|
427
423
|
onChanged: (e, n) => {
|
|
428
424
|
var r;
|
|
@@ -432,8 +428,8 @@ function useDark(t = {}) {
|
|
|
432
428
|
dark: n,
|
|
433
429
|
light: r
|
|
434
430
|
}
|
|
435
|
-
}), a =
|
|
436
|
-
return
|
|
431
|
+
}), a = e(() => i.system.value);
|
|
432
|
+
return e({
|
|
437
433
|
get() {
|
|
438
434
|
return i.value === "dark";
|
|
439
435
|
},
|
|
@@ -443,7 +439,7 @@ function useDark(t = {}) {
|
|
|
443
439
|
}
|
|
444
440
|
});
|
|
445
441
|
}
|
|
446
|
-
|
|
442
|
+
var ve = ae(_e({ storageKey: "gx-theme-appearance" })), $ = {
|
|
447
443
|
theme: { type: String },
|
|
448
444
|
defaultTheme: {
|
|
449
445
|
type: String,
|
|
@@ -452,23 +448,22 @@ const toggleDark = useToggle(useDark({ storageKey: "gx-theme-appearance" })), th
|
|
|
452
448
|
onChange: { type: Function },
|
|
453
449
|
onChangeBase: { type: Function },
|
|
454
450
|
onUpdateTheme: { type: Function }
|
|
455
|
-
}
|
|
456
|
-
var ThemeContext = /* @__PURE__ */ defineComponent({
|
|
451
|
+
}, ye = /* @__PURE__ */ n({
|
|
457
452
|
name: "ThemeContext",
|
|
458
453
|
inheritAttrs: !1,
|
|
459
|
-
props:
|
|
454
|
+
props: $,
|
|
460
455
|
slots: Object,
|
|
461
456
|
setup: (t, { slots: n, emit: r }) => {
|
|
462
|
-
let i = document.querySelector("html"), a =
|
|
463
|
-
|
|
457
|
+
let i = document.querySelector("html"), a = f(), o = f(t.theme || t.defaultTheme || "system");
|
|
458
|
+
y(() => t.theme, (e) => {
|
|
464
459
|
e && (o.value = e);
|
|
465
460
|
});
|
|
466
|
-
let { system: s, store: c } =
|
|
467
|
-
|
|
461
|
+
let { system: s, store: c } = Q();
|
|
462
|
+
y(() => s.value, () => {
|
|
468
463
|
l();
|
|
469
|
-
}, { immediate: !0 }),
|
|
464
|
+
}, { immediate: !0 }), y(() => a.value, (e) => {
|
|
470
465
|
e && t.onChangeBase?.(e);
|
|
471
|
-
}, { immediate: !0 }),
|
|
466
|
+
}, { immediate: !0 }), y(o, (e) => {
|
|
472
467
|
t.onChange?.(e), r("update:theme", e), l();
|
|
473
468
|
});
|
|
474
469
|
function l() {
|
|
@@ -477,22 +472,24 @@ var ThemeContext = /* @__PURE__ */ defineComponent({
|
|
|
477
472
|
function u(e) {
|
|
478
473
|
o.value = e, l();
|
|
479
474
|
}
|
|
480
|
-
return
|
|
475
|
+
return A({
|
|
481
476
|
theme: o,
|
|
482
477
|
resolvedTheme: a,
|
|
483
|
-
isDark:
|
|
478
|
+
isDark: e(() => a.value === "dark"),
|
|
484
479
|
setTheme: u
|
|
485
480
|
}), () => n.default?.();
|
|
486
481
|
}
|
|
487
482
|
});
|
|
488
|
-
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/theme-context/utils.ts
|
|
485
|
+
function be(e, t) {
|
|
489
486
|
if (!(document.startViewTransition && !window.matchMedia("(prefers-reduced-motion: reduce)").matches)) {
|
|
490
487
|
t.setTheme?.(t.isDark ? "dark" : "light");
|
|
491
488
|
return;
|
|
492
489
|
}
|
|
493
490
|
let n = e.getBoundingClientRect(), r = n.left + n.width / 2, i = n.top + n.height / 2, a = Math.hypot(Math.max(r, innerWidth - r), Math.max(i, innerHeight - i)), o = 100 * r / innerWidth, s = 100 * i / innerHeight, l = Math.hypot(innerWidth, innerHeight) / Math.SQRT2, u = 100 * a / l;
|
|
494
491
|
document.startViewTransition(async () => {
|
|
495
|
-
t.setTheme?.(t.isDark ? "dark" : "light"), await
|
|
492
|
+
t.setTheme?.(t.isDark ? "dark" : "light"), await c();
|
|
496
493
|
}).ready.then(() => {
|
|
497
494
|
let e = [`circle(0% at ${o}% ${s}%)`, `circle(${u}% at ${o}% ${s}%)`];
|
|
498
495
|
document.documentElement.animate({ clipPath: t.isDark ? [...e].reverse() : e }, {
|
|
@@ -503,4 +500,5 @@ function toggleAnimateTheme(e, t) {
|
|
|
503
500
|
});
|
|
504
501
|
});
|
|
505
502
|
}
|
|
506
|
-
|
|
503
|
+
//#endregion
|
|
504
|
+
export { O as ContextProvider, ye as ThemeContext, $ as themeContextProps, be as toggleAnimateTheme, ve as toggleDark, x as useContext, k as useContextProvider, j as useThemeContext };
|
package/dist/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Context={},e.Vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e,n){let r=Symbol(e);return{provideContext:e=>{(0,t.provide)(r,e)},useInjectContext:e=>(0,t.inject)(r,e||n||{}),contextInjectKey:r}}typeof process<`u`&&process.versions!=null&&process.versions.node;function r(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function i(e){return e!==null&&r(e,`Object`)}var a=e=>setTimeout(e,16),o=e=>clearTimeout(e);typeof window<`u`&&`requestAnimationFrame`in window&&(a=e=>window.requestAnimationFrame(e),o=e=>window.cancelAnimationFrame(e));var s=0,c=new Map;function l(e){c.delete(e)}function u(e,t=1){s+=1;let n=s;function r(t){if(t===0)l(n),e();else{let e=a(()=>{r(t-1)});c.set(n,e)}}return r(t),n}u.cancel=e=>{let t=c.get(e);return l(t),o(t)};function d(){let e=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``);return{uuid(t,n){let r=e,i=[],a=n||r.length,o,s;if(t)for(o=0;o<t;o+=1)i[o]=r[Number.parseInt(String(Math.random()*a))];else for(i[8]=`-`,i[13]=`-`,i[18]=`-`,i[23]=`-`,i[14]=`4`,o=0;o<36;o+=1)i[o]||(s=Math.random()*16,i[o]=r[o===19?s&&3||8:s]);return i.join(``)},uuidFast(){let t=e,n=Array.from({length:36}),r=0,i,a;for(a=0;a<36;a+=1)a===8||a===13||a===18||a===23?n[a]=`-`:a===14?n[a]=`4`:(r<=2&&(r=33554432+Math.random()*16777216||0),i=r&&15,r=r>4,n[a]=t[a===19?i&&3||8:i]);return n.join(``)},uuidString(){return this.uuidFast().replace(/-/g,``)},uuidCompact(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16||0;return(e===`x`?t:t&&3||8).toString(16)})}}}var f=null;function p(e){return f||(f=Symbol(e),f)}let m={contextKey:{type:String,required:!0},value:{type:Object,required:!0}};var h=(0,t.defineComponent)({name:`ContextProvider`,props:m,slots:Object,setup:(e,{slots:n})=>(e.contextKey&&e.value&&i(e.value)?(0,t.provide)(p(e.contextKey),{...(0,t.toRefs)(e.value),contextId:`${e.contextKey}-${d().uuid(10)}`}):console.warn(`[ContextProvider]: contextKey is required`),()=>n.default?.())});function g(e,n){if(typeof f==`symbol`)return(0,t.inject)(p(e),n||{})}let{provideContext:_,useInjectContext:v}=n(`theme-provider`);var y=new WeakMap,b=(...e)=>{let n=e[0],r=(0,t.getCurrentInstance)()?.proxy??(0,t.getCurrentScope)();if(r==null&&!(0,t.hasInjectionContext)())throw Error(`injectLocal must be called in setup`);return r&&y.has(r)&&n in y.get(r)?y.get(r)[n]:(0,t.inject)(...e)},x=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var S=Object.prototype.toString,C=e=>S.call(e)===`[object Object]`,w=()=>{};function T(...e){if(e.length!==1)return(0,t.toRef)(...e);let n=e[0];return typeof n==`function`?(0,t.readonly)((0,t.customRef)(()=>({get:n,set:w}))):(0,t.ref)(n)}function E(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}var D=e=>e();function O(e=D,n={}){let{initialState:r=`active`}=n,i=T(r===`active`);function a(){i.value=!1}function o(){i.value=!0}return{isActive:(0,t.readonly)(i),pause:a,resume:o,eventFilter:(...t)=>{i.value&&e(...t)}}}function k(e){return e.endsWith(`rem`)?Number.parseFloat(e)*16:Number.parseFloat(e)}function A(e){return Array.isArray(e)?e:[e]}function j(e){return e||(0,t.getCurrentInstance)()}function M(e,n,r={}){let{eventFilter:i=D,...a}=r;return(0,t.watch)(e,E(i,n),a)}function N(e,t,n={}){let{eventFilter:r,initialState:i=`active`,...a}=n,{eventFilter:o,pause:s,resume:c,isActive:l}=O(r,{initialState:i});return{stop:M(e,t,{...a,eventFilter:o}),pause:s,resume:c,isActive:l}}function P(e,n=!0,r){j(r)?(0,t.onMounted)(e,r):n?e():(0,t.nextTick)(e)}function F(e=!1,n={}){let{truthyValue:r=!0,falsyValue:i=!1}=n,a=(0,t.isRef)(e),o=(0,t.shallowRef)(e);function s(e){if(arguments.length)return o.value=e,o.value;{let e=(0,t.toValue)(r);return o.value=o.value===e?(0,t.toValue)(i):e,o.value}}return a?s:[o,s]}function I(e,n,r){return(0,t.watch)(e,n,{...r,immediate:!0})}var L=x?window:void 0;x&&window.document,x&&window.navigator,x&&window.location;function R(e){let n=(0,t.toValue)(e);return n?.$el??n}function z(...e){let n=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),r=(0,t.computed)(()=>{let n=A((0,t.toValue)(e[0])).filter(e=>e!=null);return n.every(e=>typeof e!=`string`)?n:void 0});return I(()=>[r.value?.map(e=>R(e))??[L].filter(e=>e!=null),A((0,t.toValue)(r.value?e[1]:e[0])),A((0,t.unref)(r.value?e[2]:e[1])),(0,t.toValue)(r.value?e[3]:e[2])],([e,t,r,i],a,o)=>{if(!e?.length||!t?.length||!r?.length)return;let s=C(i)?{...i}:i,c=e.flatMap(e=>t.flatMap(t=>r.map(r=>n(e,t,r,s))));o(()=>{c.forEach(e=>e())})},{flush:`post`})}function B(){let e=(0,t.shallowRef)(!1),n=(0,t.getCurrentInstance)();return n&&(0,t.onMounted)(()=>{e.value=!0},n),e}function V(e){let n=B();return(0,t.computed)(()=>(n.value,!!e()))}var H=Symbol(`vueuse-ssr-width`);function U(){let e=(0,t.hasInjectionContext)()?b(H,null):null;return typeof e==`number`?e:void 0}function W(e,n={}){let{window:r=L,ssrWidth:i=U()}=n,a=V(()=>r&&`matchMedia`in r&&typeof r.matchMedia==`function`),o=(0,t.shallowRef)(typeof i==`number`),s=(0,t.shallowRef)(),c=(0,t.shallowRef)(!1);return(0,t.watchEffect)(()=>{if(o.value){o.value=!a.value,c.value=(0,t.toValue)(e).split(`,`).some(e=>{let t=e.includes(`not all`),n=e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),r=e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),a=!!(n||r);return n&&a&&(a=i>=k(n[1])),r&&a&&(a=i<=k(r[1])),t?!a:a});return}a.value&&(s.value=r.matchMedia((0,t.toValue)(e)),c.value=s.value.matches)}),z(s,`change`,e=>{c.value=e.matches},{passive:!0}),(0,t.computed)(()=>c.value)}var G=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},K=`__vueuse_ssr_handlers__`,q=J();function J(){return K in G||(G[K]=G[K]||{}),G[K]}function Y(e,t){return q[e]||t}function X(e){return W(`(prefers-color-scheme: dark)`,e)}function ee(e){return e==null?`any`:e instanceof Set?`set`:e instanceof Map?`map`:e instanceof Date?`date`:typeof e==`boolean`?`boolean`:typeof e==`string`?`string`:typeof e==`object`?`object`:Number.isNaN(e)?`any`:`number`}var te={boolean:{read:e=>e===`true`,write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},Z=`vueuse-storage`;function ne(e,n,r,i={}){let{flush:a=`pre`,deep:o=!0,listenToStorageChanges:s=!0,writeDefaults:c=!0,mergeDefaults:l=!1,shallow:u,window:d=L,eventFilter:f,onError:p=e=>{console.error(e)},initOnMounted:m}=i,h=(u?t.shallowRef:t.ref)(typeof n==`function`?n():n),g=(0,t.computed)(()=>(0,t.toValue)(e));if(!r)try{r=Y(`getDefaultStorage`,()=>L?.localStorage)()}catch(e){p(e)}if(!r)return h;let _=(0,t.toValue)(n),v=ee(_),y=i.serializer??te[v],{pause:b,resume:x}=N(h,e=>w(e),{flush:a,deep:o,eventFilter:f});(0,t.watch)(g,()=>E(),{flush:a});let S=!1;d&&s&&(r instanceof Storage?z(d,`storage`,e=>{m&&!S||E(e)},{passive:!0}):z(d,Z,e=>{m&&!S||D(e)})),m?P(()=>{S=!0,E()}):E();function C(e,t){if(d){let n={key:g.value,oldValue:e,newValue:t,storageArea:r};d.dispatchEvent(r instanceof Storage?new StorageEvent(`storage`,n):new CustomEvent(Z,{detail:n}))}}function w(e){try{let t=r.getItem(g.value);if(e==null)C(t,null),r.removeItem(g.value);else{let n=y.write(e);t!==n&&(r.setItem(g.value,n),C(t,n))}}catch(e){p(e)}}function T(e){let t=e?e.newValue:r.getItem(g.value);if(t==null)return c&&_!=null&&r.setItem(g.value,y.write(_)),_;if(!e&&l){let e=y.read(t);return typeof l==`function`?l(e,_):v===`object`&&!Array.isArray(e)?{..._,...e}:e}else if(typeof t!=`string`)return t;else return y.read(t)}function E(e){if(!(e&&e.storageArea!==r)){if(e&&e.key==null){h.value=_;return}if(!(e&&e.key!==g.value)){b();try{let t=y.write(h.value);(e===void 0||e?.newValue!==t)&&(h.value=T(e))}catch(e){p(e)}finally{e?(0,t.nextTick)(x):x()}}}}function D(e){E(e.detail)}return h}var re=`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function Q(e={}){let{selector:n=`html`,attribute:r=`class`,initialValue:i=`auto`,window:a=L,storage:o,storageKey:s=`vueuse-color-scheme`,listenToStorageChanges:c=!0,storageRef:l,emitAuto:u,disableTransition:d=!0}=e,f={auto:``,light:`light`,dark:`dark`,...e.modes||{}},p=X({window:a}),m=(0,t.computed)(()=>p.value?`dark`:`light`),h=l||(s==null?T(i):ne(s,i,o,{window:a,listenToStorageChanges:c})),g=(0,t.computed)(()=>h.value===`auto`?m.value:h.value),_=Y(`updateHTMLAttrs`,(e,t,n)=>{let r=typeof e==`string`?a?.document.querySelector(e):R(e);if(!r)return;let i=new Set,o=new Set,s=null;if(t===`class`){let e=n.split(/\s/g);Object.values(f).flatMap(e=>(e||``).split(/\s/g)).filter(Boolean).forEach(t=>{e.includes(t)?i.add(t):o.add(t)})}else s={key:t,value:n};if(i.size===0&&o.size===0&&s===null)return;let c;d&&(c=a.document.createElement(`style`),c.appendChild(document.createTextNode(re)),a.document.head.appendChild(c));for(let e of i)r.classList.add(e);for(let e of o)r.classList.remove(e);s&&r.setAttribute(s.key,s.value),d&&(a.getComputedStyle(c).opacity,document.head.removeChild(c))});function v(e){_(n,r,f[e]??e)}function y(t){e.onChanged?e.onChanged(t,v):v(t)}(0,t.watch)(g,y,{flush:`post`,immediate:!0}),P(()=>y(g.value));let b=(0,t.computed)({get(){return u?h.value:g.value},set(e){h.value=e}});return Object.assign(b,{store:h,system:m,state:g})}function ie(e={}){let{valueDark:n=`dark`,valueLight:r=``}=e,i=Q({...e,onChanged:(t,n)=>{var r;e.onChanged?(r=e.onChanged)==null||r.call(e,t===`dark`,n,t):n(t)},modes:{dark:n,light:r}}),a=(0,t.computed)(()=>i.system.value);return(0,t.computed)({get(){return i.value===`dark`},set(e){let t=e?`dark`:`light`;a.value===t?i.value=`auto`:i.value=t}})}let ae=F(ie({storageKey:`gx-theme-appearance`})),$={theme:{type:String},defaultTheme:{type:String,default:`system`},onChange:{type:Function},onChangeBase:{type:Function},onUpdateTheme:{type:Function}};var oe=(0,t.defineComponent)({name:`ThemeContext`,inheritAttrs:!1,props:$,slots:Object,setup:(e,{slots:n,emit:r})=>{let i=document.querySelector(`html`),a=(0,t.ref)(),o=(0,t.ref)(e.theme||e.defaultTheme||`system`);(0,t.watch)(()=>e.theme,e=>{e&&(o.value=e)});let{system:s,store:c}=Q();(0,t.watch)(()=>s.value,()=>{l()},{immediate:!0}),(0,t.watch)(()=>a.value,t=>{t&&e.onChangeBase?.(t)},{immediate:!0}),(0,t.watch)(o,t=>{e.onChange?.(t),r(`update:theme`,t),l()});function l(){i&&(o.value===`system`?(a.value=s.value,i.setAttribute(`data-theme`,a.value)):(a.value=o.value,i.setAttribute(`data-theme`,o.value)),c.value=a.value)}function u(e){o.value=e,l()}return _({theme:o,resolvedTheme:a,isDark:(0,t.computed)(()=>a.value===`dark`),setTheme:u}),()=>n.default?.()}});function se(e,n){if(!(document.startViewTransition&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)){n.setTheme?.(n.isDark?`dark`:`light`);return}let r=e.getBoundingClientRect(),i=r.left+r.width/2,a=r.top+r.height/2,o=Math.hypot(Math.max(i,innerWidth-i),Math.max(a,innerHeight-a)),s=100*i/innerWidth,c=100*a/innerHeight,l=Math.hypot(innerWidth,innerHeight)/Math.SQRT2,u=100*o/l;document.startViewTransition(async()=>{n.setTheme?.(n.isDark?`dark`:`light`),await(0,t.nextTick)()}).ready.then(()=>{let e=[`circle(0% at ${s}% ${c}%)`,`circle(${u}% at ${s}% ${c}%)`];document.documentElement.animate({clipPath:n.isDark?[...e].reverse():e},{duration:400,fill:`forwards`,easing:`ease-in`,pseudoElement:n.isDark?`::view-transition-old(root)`:`::view-transition-new(root)`})})}e.ContextProvider=h,e.ThemeContext=oe,e.themeContextProps=$,e.toggleAnimateTheme=se,e.toggleDark=ae,e.useContext=n,e.useContextProvider=g,e.useThemeContext=v});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Context={},e.Vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e,n){let r=Symbol(e);return{provideContext:e=>{(0,t.provide)(r,e)},useInjectContext:e=>(0,t.inject)(r,e||n||{}),contextInjectKey:r}}function r(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function i(e){return e!==null&&r(e,`Object`)}var a=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`.split(``);function o(){return{uuid(e,t){let n=a,r=t||n.length;if(e){let t=``;for(let i=0;i<e;i+=1)t+=n[Math.floor(Math.random()*r)];return t}return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.floor(Math.random()*16);return(e===`x`?t:t&3|8).toString(16)})},uuidFast(){let e=a,t=Array.from({length:36});for(let n=0;n<36;n+=1)if(n===8||n===13||n===18||n===23)t[n]=`-`;else if(n===14)t[n]=`4`;else{let r=Math.floor(Math.random()*16);t[n]=e[n===19?r&3|8:r]}return t.join(``)},uuidString(){return this.uuidFast().replace(/-/g,``)},uuidCompact(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.floor(Math.random()*16);return(e===`x`?t:t&3|8).toString(16)})}}}var s=null;function c(e){return s||(s=Symbol(e),s)}var l={contextKey:{type:String,required:!0},value:{type:Object,required:!0}},u=(0,t.defineComponent)({name:`ContextProvider`,props:l,slots:Object,setup:(e,{slots:n})=>(e.contextKey&&e.value&&i(e.value)?(0,t.provide)(c(e.contextKey),{...(0,t.toRefs)(e.value),contextId:`${e.contextKey}-${o().uuid(10)}`}):console.warn(`[ContextProvider]: contextKey is required`),()=>n.default?.())});function d(e,n){if(typeof s==`symbol`)return(0,t.inject)(c(e),n||{})}var{provideContext:f,useInjectContext:p}=n(`theme-provider`),m=new WeakMap,h=(...e)=>{let n=e[0],r=(0,t.getCurrentInstance)()?.proxy??(0,t.getCurrentScope)();if(r==null&&!(0,t.hasInjectionContext)())throw Error(`injectLocal must be called in setup`);return r&&m.has(r)&&n in m.get(r)?m.get(r)[n]:(0,t.inject)(...e)},g=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var _=Object.prototype.toString,v=e=>_.call(e)===`[object Object]`,y=()=>{};function b(...e){if(e.length!==1)return(0,t.toRef)(...e);let n=e[0];return typeof n==`function`?(0,t.readonly)((0,t.customRef)(()=>({get:n,set:y}))):(0,t.ref)(n)}function x(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}var S=e=>e();function C(e=S,n={}){let{initialState:r=`active`}=n,i=b(r===`active`);function a(){i.value=!1}function o(){i.value=!0}return{isActive:(0,t.shallowReadonly)(i),pause:a,resume:o,eventFilter:(...t)=>{i.value&&e(...t)}}}function w(e){return e.endsWith(`rem`)?Number.parseFloat(e)*16:Number.parseFloat(e)}function T(e){return Array.isArray(e)?e:[e]}function E(e){return e||(0,t.getCurrentInstance)()}function D(e,n,r={}){let{eventFilter:i=S,...a}=r;return(0,t.watch)(e,x(i,n),a)}function O(e,t,n={}){let{eventFilter:r,initialState:i=`active`,...a}=n,{eventFilter:o,pause:s,resume:c,isActive:l}=C(r,{initialState:i});return{stop:D(e,t,{...a,eventFilter:o}),pause:s,resume:c,isActive:l}}function k(e,n=!0,r){E(r)?(0,t.onMounted)(e,r):n?e():(0,t.nextTick)(e)}function A(e=!1,n={}){let{truthyValue:r=!0,falsyValue:i=!1}=n,a=(0,t.isRef)(e),o=(0,t.shallowRef)(e);function s(e){if(arguments.length)return o.value=e,o.value;{let e=(0,t.toValue)(r);return o.value=o.value===e?(0,t.toValue)(i):e,o.value}}return a?s:[o,s]}function j(e,n,r){return(0,t.watch)(e,n,{...r,immediate:!0})}var M=g?window:void 0;g&&window.document,g&&window.navigator,g&&window.location;function N(e){let n=(0,t.toValue)(e);return n?.$el??n}function P(...e){let n=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),r=(0,t.computed)(()=>{let n=T((0,t.toValue)(e[0])).filter(e=>e!=null);return n.every(e=>typeof e!=`string`)?n:void 0});return j(()=>[r.value?.map(e=>N(e))??[M].filter(e=>e!=null),T((0,t.toValue)(r.value?e[1]:e[0])),T((0,t.unref)(r.value?e[2]:e[1])),(0,t.toValue)(r.value?e[3]:e[2])],([e,t,r,i],a,o)=>{if(!e?.length||!t?.length||!r?.length)return;let s=v(i)?{...i}:i,c=e.flatMap(e=>t.flatMap(t=>r.map(r=>n(e,t,r,s))));o(()=>{c.forEach(e=>e())})},{flush:`post`})}function F(){let e=(0,t.shallowRef)(!1),n=(0,t.getCurrentInstance)();return n&&(0,t.onMounted)(()=>{e.value=!0},n),e}function I(e){let n=F();return(0,t.computed)(()=>(n.value,!!e()))}var L=Symbol(`vueuse-ssr-width`);function ee(){let e=(0,t.hasInjectionContext)()?h(L,null):null;return typeof e==`number`?e:void 0}function R(e,n={}){let{window:r=M,ssrWidth:i=ee()}=n,a=I(()=>r&&`matchMedia`in r&&typeof r.matchMedia==`function`),o=(0,t.shallowRef)(typeof i==`number`),s=(0,t.shallowRef)(),c=(0,t.shallowRef)(!1);return(0,t.watchEffect)(()=>{if(o.value){o.value=!a.value,c.value=(0,t.toValue)(e).split(`,`).some(e=>{let t=e.includes(`not all`),n=e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),r=e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),a=!!(n||r);return n&&a&&(a=i>=w(n[1])),r&&a&&(a=i<=w(r[1])),t?!a:a});return}a.value&&(s.value=r.matchMedia((0,t.toValue)(e)),c.value=s.value.matches)}),P(s,`change`,e=>{c.value=e.matches},{passive:!0}),(0,t.computed)(()=>c.value)}var z=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},B=`__vueuse_ssr_handlers__`,V=H();function H(){return B in z||(z[B]=z[B]||{}),z[B]}function U(e,t){return V[e]||t}function W(e){return R(`(prefers-color-scheme: dark)`,e)}function G(e){return e==null?`any`:e instanceof Set?`set`:e instanceof Map?`map`:e instanceof Date?`date`:typeof e==`boolean`?`boolean`:typeof e==`string`?`string`:typeof e==`object`?`object`:Number.isNaN(e)?`any`:`number`}var K={boolean:{read:e=>e===`true`,write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},q=`vueuse-storage`;function J(e,n,r,i={}){let{flush:a=`pre`,deep:o=!0,listenToStorageChanges:s=!0,writeDefaults:c=!0,mergeDefaults:l=!1,shallow:u,window:d=M,eventFilter:f,onError:p=e=>{console.error(e)},initOnMounted:m}=i,h=(u?t.shallowRef:t.ref)(typeof n==`function`?n():n),g=(0,t.computed)(()=>(0,t.toValue)(e));if(!r)try{r=U(`getDefaultStorage`,()=>M?.localStorage)()}catch(e){p(e)}if(!r)return h;let _=(0,t.toValue)(n),v=G(_),y=i.serializer??K[v],{pause:b,resume:x}=O(h,e=>w(e),{flush:a,deep:o,eventFilter:f});(0,t.watch)(g,()=>E(),{flush:a});let S=!1;d&&s&&(r instanceof Storage?P(d,`storage`,e=>{m&&!S||E(e)},{passive:!0}):P(d,q,e=>{m&&!S||D(e)})),m?k(()=>{S=!0,E()}):E();function C(e,t){if(d){let n={key:g.value,oldValue:e,newValue:t,storageArea:r};d.dispatchEvent(r instanceof Storage?new StorageEvent(`storage`,n):new CustomEvent(q,{detail:n}))}}function w(e){try{let t=r.getItem(g.value);if(e==null)C(t,null),r.removeItem(g.value);else{let n=y.write(e);t!==n&&(r.setItem(g.value,n),C(t,n))}}catch(e){p(e)}}function T(e){let t=e?e.newValue:r.getItem(g.value);if(t==null)return c&&_!=null&&r.setItem(g.value,y.write(_)),_;if(!e&&l){let e=y.read(t);return typeof l==`function`?l(e,_):v===`object`&&!Array.isArray(e)?{..._,...e}:e}else if(typeof t!=`string`)return t;else return y.read(t)}function E(e){if(!(e&&e.storageArea!==r)){if(e&&e.key==null){h.value=_;return}if(!(e&&e.key!==g.value)){b();try{let t=y.write(h.value);(e===void 0||e?.newValue!==t)&&(h.value=T(e))}catch(e){p(e)}finally{e?(0,t.nextTick)(x):x()}}}}function D(e){E(e.detail)}return h}var Y=`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function X(e={}){let{selector:n=`html`,attribute:r=`class`,initialValue:i=`auto`,window:a=M,storage:o,storageKey:s=`vueuse-color-scheme`,listenToStorageChanges:c=!0,storageRef:l,emitAuto:u,disableTransition:d=!0}=e,f={auto:``,light:`light`,dark:`dark`,...e.modes||{}},p=W({window:a}),m=(0,t.computed)(()=>p.value?`dark`:`light`),h=l||(s==null?b(i):J(s,i,o,{window:a,listenToStorageChanges:c})),g=(0,t.computed)(()=>h.value===`auto`?m.value:h.value),_=U(`updateHTMLAttrs`,(e,t,n)=>{let r=typeof e==`string`?a?.document.querySelector(e):N(e);if(!r)return;let i=new Set,o=new Set,s=null;if(t===`class`){let e=n.split(/\s/g);Object.values(f).flatMap(e=>(e||``).split(/\s/g)).filter(Boolean).forEach(t=>{e.includes(t)?i.add(t):o.add(t)})}else s={key:t,value:n};if(i.size===0&&o.size===0&&s===null)return;let c;d&&(c=a.document.createElement(`style`),c.appendChild(document.createTextNode(Y)),a.document.head.appendChild(c));for(let e of i)r.classList.add(e);for(let e of o)r.classList.remove(e);s&&r.setAttribute(s.key,s.value),d&&(a.getComputedStyle(c).opacity,document.head.removeChild(c))});function v(e){_(n,r,f[e]??e)}function y(t){e.onChanged?e.onChanged(t,v):v(t)}(0,t.watch)(g,y,{flush:`post`,immediate:!0}),k(()=>y(g.value));let x=(0,t.computed)({get(){return u?h.value:g.value},set(e){h.value=e}});return Object.assign(x,{store:h,system:m,state:g})}function Z(e={}){let{valueDark:n=`dark`,valueLight:r=``}=e,i=X({...e,onChanged:(t,n)=>{var r;e.onChanged?(r=e.onChanged)==null||r.call(e,t===`dark`,n,t):n(t)},modes:{dark:n,light:r}}),a=(0,t.computed)(()=>i.system.value);return(0,t.computed)({get(){return i.value===`dark`},set(e){let t=e?`dark`:`light`;a.value===t?i.value=`auto`:i.value=t}})}var Q=A(Z({storageKey:`gx-theme-appearance`})),$={theme:{type:String},defaultTheme:{type:String,default:`system`},onChange:{type:Function},onChangeBase:{type:Function},onUpdateTheme:{type:Function}},te=(0,t.defineComponent)({name:`ThemeContext`,inheritAttrs:!1,props:$,slots:Object,setup:(e,{slots:n,emit:r})=>{let i=document.querySelector(`html`),a=(0,t.ref)(),o=(0,t.ref)(e.theme||e.defaultTheme||`system`);(0,t.watch)(()=>e.theme,e=>{e&&(o.value=e)});let{system:s,store:c}=X();(0,t.watch)(()=>s.value,()=>{l()},{immediate:!0}),(0,t.watch)(()=>a.value,t=>{t&&e.onChangeBase?.(t)},{immediate:!0}),(0,t.watch)(o,t=>{e.onChange?.(t),r(`update:theme`,t),l()});function l(){i&&(o.value===`system`?(a.value=s.value,i.setAttribute(`data-theme`,a.value)):(a.value=o.value,i.setAttribute(`data-theme`,o.value)),c.value=a.value)}function u(e){o.value=e,l()}return f({theme:o,resolvedTheme:a,isDark:(0,t.computed)(()=>a.value===`dark`),setTheme:u}),()=>n.default?.()}});function ne(e,n){if(!(document.startViewTransition&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)){n.setTheme?.(n.isDark?`dark`:`light`);return}let r=e.getBoundingClientRect(),i=r.left+r.width/2,a=r.top+r.height/2,o=Math.hypot(Math.max(i,innerWidth-i),Math.max(a,innerHeight-a)),s=100*i/innerWidth,c=100*a/innerHeight,l=Math.hypot(innerWidth,innerHeight)/Math.SQRT2,u=100*o/l;document.startViewTransition(async()=>{n.setTheme?.(n.isDark?`dark`:`light`),await(0,t.nextTick)()}).ready.then(()=>{let e=[`circle(0% at ${s}% ${c}%)`,`circle(${u}% at ${s}% ${c}%)`];document.documentElement.animate({clipPath:n.isDark?[...e].reverse():e},{duration:400,fill:`forwards`,easing:`ease-in`,pseudoElement:n.isDark?`::view-transition-old(root)`:`::view-transition-new(root)`})})}e.ContextProvider=u,e.ThemeContext=te,e.themeContextProps=$,e.toggleAnimateTheme=ne,e.toggleDark=Q,e.useContext=n,e.useContextProvider=d,e.useThemeContext=p});
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,4 @@ import { useThemeContext } from "./theme-context/context.js";
|
|
|
5
5
|
import { toggleDark } from "./theme-context/dark.js";
|
|
6
6
|
import ThemeContext, { ThemeContextEmits, ThemeContextProps, ThemeContextSlots, themeContextProps } from "./theme-context/ThemeContext.js";
|
|
7
7
|
import { toggleAnimateTheme } from "./theme-context/utils.js";
|
|
8
|
-
import "./theme-context/index.js";
|
|
9
8
|
export { BaseTheme, ContextProvider, ThemeContext, ThemeContextEmits, ThemeContextProps, ThemeContextSlots, ThemeProviderContext, ThemeValue, themeContextProps, toggleAnimateTheme, toggleDark, useContext, useContextProvider, useThemeContext };
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,7 @@ import { useContext } from "./context/index.js";
|
|
|
2
2
|
import { ContextProvider, useContextProvider } from "./context/ContextProvider.js";
|
|
3
3
|
import { useThemeContext } from "./theme-context/context.js";
|
|
4
4
|
import { toggleDark } from "./theme-context/dark.js";
|
|
5
|
-
import
|
|
5
|
+
import ThemeContext, { themeContextProps } from "./theme-context/ThemeContext.js";
|
|
6
6
|
import { toggleAnimateTheme } from "./theme-context/utils.js";
|
|
7
7
|
import "./theme-context/index.js";
|
|
8
|
-
|
|
9
|
-
export { ContextProvider, ThemeContext_default as ThemeContext, themeContextProps, toggleAnimateTheme, toggleDark, useContext, useContextProvider, useThemeContext };
|
|
8
|
+
export { ContextProvider, ThemeContext, themeContextProps, toggleAnimateTheme, toggleDark, useContext, useContextProvider, useThemeContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseTheme, ThemeValue } from "./types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _$vue from "vue";
|
|
3
3
|
import { PropType, SlotsType } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/theme-context/ThemeContext.d.ts
|
|
@@ -36,7 +36,7 @@ declare const themeContextProps: {
|
|
|
36
36
|
type: PropType<(theme: ThemeValue) => void>;
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
|
-
declare const ThemeContext:
|
|
39
|
+
declare const ThemeContext: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
40
40
|
theme: {
|
|
41
41
|
type: PropType<ThemeValue>;
|
|
42
42
|
};
|
|
@@ -53,7 +53,7 @@ declare const ThemeContext: vue6.DefineComponent<vue6.ExtractPropTypes<{
|
|
|
53
53
|
onUpdateTheme: {
|
|
54
54
|
type: PropType<(theme: ThemeValue) => void>;
|
|
55
55
|
};
|
|
56
|
-
}>, () => any, {}, {}, {},
|
|
56
|
+
}>, () => any, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
|
57
57
|
theme: {
|
|
58
58
|
type: PropType<ThemeValue>;
|
|
59
59
|
};
|
|
@@ -72,6 +72,6 @@ declare const ThemeContext: vue6.DefineComponent<vue6.ExtractPropTypes<{
|
|
|
72
72
|
};
|
|
73
73
|
}>> & Readonly<{}>, {
|
|
74
74
|
defaultTheme: ThemeValue;
|
|
75
|
-
}, SlotsType<ThemeContextSlots>, {}, {}, string,
|
|
75
|
+
}, SlotsType<ThemeContextSlots>, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
|
76
76
|
//#endregion
|
|
77
77
|
export { ThemeContextEmits, ThemeContextProps, ThemeContextSlots, ThemeContext as default, themeContextProps };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createThemeContext } from "./context.js";
|
|
2
2
|
import { computed, defineComponent, ref, watch } from "vue";
|
|
3
3
|
import { useColorMode } from "@vueuse/core";
|
|
4
|
-
|
|
5
4
|
//#region src/theme-context/ThemeContext.tsx
|
|
6
5
|
const themeContextProps = {
|
|
7
6
|
theme: { type: String },
|
|
@@ -62,7 +61,5 @@ const ThemeContext = /* @__PURE__ */ defineComponent({
|
|
|
62
61
|
return () => slots.default?.();
|
|
63
62
|
}
|
|
64
63
|
});
|
|
65
|
-
var ThemeContext_default = ThemeContext;
|
|
66
|
-
|
|
67
64
|
//#endregion
|
|
68
|
-
export {
|
|
65
|
+
export { ThemeContext as default, themeContextProps };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useContext } from "../context/index.js";
|
|
2
|
-
|
|
3
2
|
//#region src/theme-context/context.ts
|
|
4
3
|
const { provideContext: createThemeContext, useInjectContext: useThemeContext } = useContext("theme-provider");
|
|
5
|
-
|
|
6
4
|
//#endregion
|
|
7
|
-
export { createThemeContext, useThemeContext };
|
|
5
|
+
export { createThemeContext, useThemeContext };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as _vueuse_core0 from "@vueuse/core";
|
|
1
|
+
import * as _$_vueuse_core0 from "@vueuse/core";
|
|
2
2
|
|
|
3
3
|
//#region src/theme-context/dark.d.ts
|
|
4
|
-
declare const isDark: _vueuse_core0.UseDarkReturn;
|
|
4
|
+
declare const isDark: _$_vueuse_core0.UseDarkReturn;
|
|
5
5
|
declare const toggleDark: (value?: boolean) => boolean;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { isDark, toggleDark };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useDark, useToggle } from "@vueuse/core";
|
|
2
|
-
|
|
3
2
|
//#region src/theme-context/dark.ts
|
|
4
3
|
const isDark = useDark({ storageKey: "gx-theme-appearance" });
|
|
5
4
|
const toggleDark = useToggle(isDark);
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
|
-
export { isDark, toggleDark };
|
|
6
|
+
export { isDark, toggleDark };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useThemeContext } from "./context.js";
|
|
2
2
|
import { toggleDark } from "./dark.js";
|
|
3
|
-
import
|
|
3
|
+
import ThemeContext, { themeContextProps } from "./ThemeContext.js";
|
|
4
4
|
import { toggleAnimateTheme } from "./utils.js";
|
|
5
|
-
|
|
6
|
-
export { ThemeContext_default as ThemeContext, themeContextProps, toggleAnimateTheme, toggleDark, useThemeContext };
|
|
5
|
+
export { ThemeContext, themeContextProps, toggleAnimateTheme, toggleDark, useThemeContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { nextTick } from "vue";
|
|
2
|
-
|
|
3
2
|
//#region src/theme-context/utils.ts
|
|
4
3
|
function toggleAnimateTheme(el, props) {
|
|
5
4
|
if (!(document.startViewTransition && !window.matchMedia("(prefers-reduced-motion: reduce)").matches)) {
|
|
@@ -27,6 +26,5 @@ function toggleAnimateTheme(el, props) {
|
|
|
27
26
|
});
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
//#endregion
|
|
32
|
-
export { toggleAnimateTheme };
|
|
30
|
+
export { toggleAnimateTheme };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gx-design-vue/context",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.5-alpha.
|
|
4
|
+
"version": "0.0.5-alpha.4",
|
|
5
5
|
"description": "Gx Design Context",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "gx12358",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"vue": ">=3.2.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@vueuse/core": "^14.
|
|
44
|
-
"@gx-design-vue/pro-utils": "^0.2.0-alpha.
|
|
43
|
+
"@vueuse/core": "^14.3.0",
|
|
44
|
+
"@gx-design-vue/pro-utils": "^0.2.0-alpha.4"
|
|
45
45
|
},
|
|
46
46
|
"browserslist": [
|
|
47
47
|
"> 1%",
|