@brickflow/ui 0.0.26 → 0.0.28
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/module.d.mts +4 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +409 -11
- package/dist/runtime/components/Button/icons.demo.d.vue.ts +8 -0
- package/dist/runtime/components/Button/icons.demo.vue +25 -0
- package/dist/runtime/components/Button/icons.demo.vue.d.ts +8 -0
- package/dist/runtime/components/Button/index.d.vue.ts +45 -0
- package/dist/runtime/components/Button/index.vue +162 -0
- package/dist/runtime/components/Button/index.vue.d.ts +45 -0
- package/dist/runtime/components/Button/size.demo.d.vue.ts +7 -0
- package/dist/runtime/components/Button/size.demo.vue +78 -0
- package/dist/runtime/components/Button/size.demo.vue.d.ts +7 -0
- package/dist/runtime/components/Button/slots.demo.d.vue.ts +7 -0
- package/dist/runtime/components/Button/slots.demo.vue +23 -0
- package/dist/runtime/components/Button/slots.demo.vue.d.ts +7 -0
- package/dist/runtime/components/Button/state.demo.d.vue.ts +7 -0
- package/dist/runtime/components/Button/state.demo.vue +18 -0
- package/dist/runtime/components/Button/state.demo.vue.d.ts +7 -0
- package/dist/runtime/components/Button/variants.demo.d.vue.ts +7 -0
- package/dist/runtime/components/Button/variants.demo.vue +207 -0
- package/dist/runtime/components/Button/variants.demo.vue.d.ts +7 -0
- package/dist/runtime/components/Icon/basic.demo.d.vue.ts +8 -0
- package/dist/runtime/components/Icon/basic.demo.vue +44 -0
- package/dist/runtime/components/Icon/basic.demo.vue.d.ts +8 -0
- package/dist/runtime/components/Icon/index.d.vue.ts +7 -0
- package/dist/runtime/components/Icon/index.vue +18 -0
- package/dist/runtime/components/Icon/index.vue.d.ts +7 -0
- package/dist/runtime/components/Link/basic.demo.d.vue.ts +8 -0
- package/dist/runtime/components/Link/basic.demo.vue +27 -0
- package/dist/runtime/components/Link/basic.demo.vue.d.ts +8 -0
- package/dist/runtime/components/Link/index.d.vue.ts +51 -0
- package/dist/runtime/components/Link/index.vue +62 -0
- package/dist/runtime/components/Link/index.vue.d.ts +51 -0
- package/dist/runtime/composables/useScreen.d.ts +18 -0
- package/dist/runtime/composables/useScreen.js +68 -0
- package/dist/runtime/composables/useTheme.d.ts +17 -0
- package/dist/runtime/composables/useTheme.js +77 -0
- package/dist/runtime/composables/useTranslate.d.ts +20 -0
- package/dist/runtime/composables/useTranslate.js +17 -0
- package/dist/runtime/icon-font.d.ts +4 -0
- package/dist/runtime/pages/ui.d.vue.ts +4 -0
- package/dist/runtime/pages/ui.vue +717 -0
- package/dist/runtime/pages/ui.vue.d.ts +4 -0
- package/dist/runtime/tailwind.d.ts +4 -1
- package/dist/runtime/tailwind.js +2 -1
- package/dist/runtime/ui-catalog.d.ts +39 -0
- package/dist/runtime/ui-options.d.ts +3 -0
- package/dist/types.d.mts +2 -0
- package/package.json +10 -10
- package/dist/runtime/components/Button.d.vue.ts +0 -23
- package/dist/runtime/components/Button.vue +0 -29
- package/dist/runtime/components/Button.vue.d.ts +0 -23
- package/dist/runtime/composables/useBrickme.d.ts +0 -9
- package/dist/runtime/composables/useBrickme.js +0 -14
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
defineOptions({
|
|
4
|
+
inheritAttrs: false
|
|
5
|
+
});
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
name: { type: String, required: true }
|
|
8
|
+
});
|
|
9
|
+
const classes = computed(() => `icon-${props.name}`);
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<i
|
|
14
|
+
v-bind="$attrs"
|
|
15
|
+
:class="[classes, 'aspect-square']"
|
|
16
|
+
role="img"
|
|
17
|
+
/>
|
|
18
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
name: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=index.vue.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const uiDemo: {
|
|
2
|
+
description: string;
|
|
3
|
+
title: string;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
//# sourceMappingURL=basic.demo.vue.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export const uiDemo = {
|
|
3
|
+
description: "Internal navigation keeps the current locale.",
|
|
4
|
+
title: "Basic usage"
|
|
5
|
+
};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
import Link from "./index.vue";
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div class="flex flex-wrap items-center gap-4">
|
|
14
|
+
<Link
|
|
15
|
+
to="/"
|
|
16
|
+
class="text-main-300 hover:text-main-200"
|
|
17
|
+
>
|
|
18
|
+
Go to Home
|
|
19
|
+
</Link>
|
|
20
|
+
<Link
|
|
21
|
+
to="/ui?component=button"
|
|
22
|
+
class="text-main-300 hover:text-main-200"
|
|
23
|
+
>
|
|
24
|
+
Open Button
|
|
25
|
+
</Link>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const uiDemo: {
|
|
2
|
+
description: string;
|
|
3
|
+
title: string;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
//# sourceMappingURL=basic.demo.vue.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ComponentPublicInstance } from 'vue';
|
|
2
|
+
import { type RouteLocationRaw } from 'vue-router';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
activeClass?: string;
|
|
5
|
+
class?: (false | string)[] | string;
|
|
6
|
+
custom?: boolean;
|
|
7
|
+
exactActiveClass?: string;
|
|
8
|
+
external?: boolean;
|
|
9
|
+
faster?: boolean;
|
|
10
|
+
href?: RouteLocationRaw;
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
onPointerdown?: () => void;
|
|
13
|
+
prefetch?: boolean;
|
|
14
|
+
rel?: null | string;
|
|
15
|
+
replace?: boolean;
|
|
16
|
+
style?: Record<string, string>;
|
|
17
|
+
target?: '_blank' | '_parent' | '_self' | '_top' | null | (Record<string, never> & string);
|
|
18
|
+
to?: RouteLocationRaw;
|
|
19
|
+
};
|
|
20
|
+
declare var __VLS_9: {};
|
|
21
|
+
type __VLS_Slots = {} & {
|
|
22
|
+
default?: (props: typeof __VLS_9) => any;
|
|
23
|
+
};
|
|
24
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
25
|
+
linkRef: import("vue").Ref<ComponentPublicInstance | undefined, ComponentPublicInstance | undefined>;
|
|
26
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
27
|
+
style: Record<string, string>;
|
|
28
|
+
onClick: () => void;
|
|
29
|
+
onPointerdown: () => void;
|
|
30
|
+
class: (false | string)[] | string;
|
|
31
|
+
replace: boolean;
|
|
32
|
+
activeClass: string;
|
|
33
|
+
custom: boolean;
|
|
34
|
+
exactActiveClass: string;
|
|
35
|
+
external: boolean;
|
|
36
|
+
faster: boolean;
|
|
37
|
+
href: RouteLocationRaw;
|
|
38
|
+
prefetch: boolean;
|
|
39
|
+
rel: null | string;
|
|
40
|
+
target: "_blank" | "_parent" | "_self" | "_top" | null | (Record<string, never> & string);
|
|
41
|
+
to: RouteLocationRaw;
|
|
42
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
43
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
44
|
+
declare const _default: typeof __VLS_export;
|
|
45
|
+
export default _default;
|
|
46
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
47
|
+
new (): {
|
|
48
|
+
$slots: S;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=index.vue.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NuxtLink
|
|
3
|
+
ref="linkRef"
|
|
4
|
+
data-allow-mismatch
|
|
5
|
+
v-bind="prepareProps"
|
|
6
|
+
>
|
|
7
|
+
<slot />
|
|
8
|
+
</NuxtLink>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup>
|
|
12
|
+
import { computed, ref } from "vue";
|
|
13
|
+
import { useRouter } from "vue-router";
|
|
14
|
+
import { useTranslate } from "../../composables/useTranslate";
|
|
15
|
+
defineOptions({ inheritAttrs: false });
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
activeClass: { type: String, required: false, default: void 0 },
|
|
18
|
+
class: { type: [Array, String], required: false, default: void 0 },
|
|
19
|
+
custom: { type: Boolean, required: false, default: false },
|
|
20
|
+
exactActiveClass: { type: String, required: false, default: void 0 },
|
|
21
|
+
external: { type: Boolean, required: false, default: false },
|
|
22
|
+
faster: { type: Boolean, required: false, default: false },
|
|
23
|
+
href: { type: null, required: false, default: void 0 },
|
|
24
|
+
onClick: { type: Function, required: false, default: void 0 },
|
|
25
|
+
onPointerdown: { type: Function, required: false, default: void 0 },
|
|
26
|
+
prefetch: { type: Boolean, required: false, default: false },
|
|
27
|
+
rel: { type: [null, String], required: false, default: void 0 },
|
|
28
|
+
replace: { type: Boolean, required: false, default: false },
|
|
29
|
+
style: { type: Object, required: false, default: void 0 },
|
|
30
|
+
target: { type: [String, null, Object], required: false, default: void 0 },
|
|
31
|
+
to: { type: null, required: false, default: void 0 }
|
|
32
|
+
});
|
|
33
|
+
const { localePath } = useTranslate();
|
|
34
|
+
const prepareProps = computed(() => {
|
|
35
|
+
const { faster: _faster, onPointerdown: _onPointerdown, ...linkProps } = props;
|
|
36
|
+
const refineDrops = { ...linkProps, onPointerdown: props.faster ? handlePointerDown : void 0 };
|
|
37
|
+
if (typeof props.to === "string") {
|
|
38
|
+
return { ...refineDrops, to: localePath(props.to) };
|
|
39
|
+
} else if (props.to?.path) {
|
|
40
|
+
return { ...refineDrops, to: { ...props.to, path: localePath(props.to.path) } };
|
|
41
|
+
}
|
|
42
|
+
return refineDrops;
|
|
43
|
+
});
|
|
44
|
+
const linkRef = ref();
|
|
45
|
+
function handlePointerDown(e) {
|
|
46
|
+
const router = useRouter();
|
|
47
|
+
props.onPointerdown?.();
|
|
48
|
+
if (e.button !== 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
const to = prepareProps.value.to;
|
|
56
|
+
if (!to) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
props.replace ? router.replace(to) : router.push(to);
|
|
60
|
+
}
|
|
61
|
+
defineExpose({ linkRef });
|
|
62
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ComponentPublicInstance } from 'vue';
|
|
2
|
+
import { type RouteLocationRaw } from 'vue-router';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
activeClass?: string;
|
|
5
|
+
class?: (false | string)[] | string;
|
|
6
|
+
custom?: boolean;
|
|
7
|
+
exactActiveClass?: string;
|
|
8
|
+
external?: boolean;
|
|
9
|
+
faster?: boolean;
|
|
10
|
+
href?: RouteLocationRaw;
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
onPointerdown?: () => void;
|
|
13
|
+
prefetch?: boolean;
|
|
14
|
+
rel?: null | string;
|
|
15
|
+
replace?: boolean;
|
|
16
|
+
style?: Record<string, string>;
|
|
17
|
+
target?: '_blank' | '_parent' | '_self' | '_top' | null | (Record<string, never> & string);
|
|
18
|
+
to?: RouteLocationRaw;
|
|
19
|
+
};
|
|
20
|
+
declare var __VLS_9: {};
|
|
21
|
+
type __VLS_Slots = {} & {
|
|
22
|
+
default?: (props: typeof __VLS_9) => any;
|
|
23
|
+
};
|
|
24
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
25
|
+
linkRef: import("vue").Ref<ComponentPublicInstance | undefined, ComponentPublicInstance | undefined>;
|
|
26
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
27
|
+
style: Record<string, string>;
|
|
28
|
+
onClick: () => void;
|
|
29
|
+
onPointerdown: () => void;
|
|
30
|
+
class: (false | string)[] | string;
|
|
31
|
+
replace: boolean;
|
|
32
|
+
activeClass: string;
|
|
33
|
+
custom: boolean;
|
|
34
|
+
exactActiveClass: string;
|
|
35
|
+
external: boolean;
|
|
36
|
+
faster: boolean;
|
|
37
|
+
href: RouteLocationRaw;
|
|
38
|
+
prefetch: boolean;
|
|
39
|
+
rel: null | string;
|
|
40
|
+
target: "_blank" | "_parent" | "_self" | "_top" | null | (Record<string, never> & string);
|
|
41
|
+
to: RouteLocationRaw;
|
|
42
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
43
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
44
|
+
declare const _default: typeof __VLS_export;
|
|
45
|
+
export default _default;
|
|
46
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
47
|
+
new (): {
|
|
48
|
+
$slots: S;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=index.vue.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare const screen: {
|
|
2
|
+
readonly base: boolean;
|
|
3
|
+
readonly baseClass: "sm:hidden";
|
|
4
|
+
readonly lg: boolean;
|
|
5
|
+
readonly lgClass: "max-lg:hidden xl:hidden";
|
|
6
|
+
readonly md: boolean;
|
|
7
|
+
readonly mdClass: "max-md:hidden lg:hidden";
|
|
8
|
+
readonly ready: Promise<void>;
|
|
9
|
+
readonly sm: boolean;
|
|
10
|
+
readonly smClass: "max-sm:hidden md:hidden";
|
|
11
|
+
readonly xl: boolean;
|
|
12
|
+
readonly xlClass: "max-xl:hidden 2xl:hidden";
|
|
13
|
+
readonly xxl: boolean;
|
|
14
|
+
readonly xxlClass: "max-2xl:hidden";
|
|
15
|
+
};
|
|
16
|
+
export declare function useScreen(): typeof screen;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=useScreen.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { onMounted, reactive } from "vue";
|
|
2
|
+
const state = reactive({
|
|
3
|
+
base: true,
|
|
4
|
+
lg: true,
|
|
5
|
+
md: true,
|
|
6
|
+
sm: true,
|
|
7
|
+
xl: true,
|
|
8
|
+
xxl: true
|
|
9
|
+
});
|
|
10
|
+
const queries = {
|
|
11
|
+
base: "(width < 40rem)",
|
|
12
|
+
lg: "(64rem <= width < 80rem)",
|
|
13
|
+
md: "(48rem <= width < 64rem)",
|
|
14
|
+
sm: "(40rem <= width < 48rem)",
|
|
15
|
+
xl: "(80rem <= width < 96rem)",
|
|
16
|
+
xxl: "(width >= 96rem)"
|
|
17
|
+
};
|
|
18
|
+
let initialized = false;
|
|
19
|
+
let resolveReady = () => void 0;
|
|
20
|
+
const ready = import.meta.client ? new Promise((resolve) => {
|
|
21
|
+
resolveReady = resolve;
|
|
22
|
+
}) : Promise.resolve();
|
|
23
|
+
function initialize() {
|
|
24
|
+
if (initialized) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
initialized = true;
|
|
28
|
+
for (const [key, query] of Object.entries(queries)) {
|
|
29
|
+
const mediaQuery = window.matchMedia(query);
|
|
30
|
+
const update = (event) => {
|
|
31
|
+
state[key] = event.matches;
|
|
32
|
+
};
|
|
33
|
+
update(mediaQuery);
|
|
34
|
+
mediaQuery.addEventListener("change", update);
|
|
35
|
+
}
|
|
36
|
+
resolveReady();
|
|
37
|
+
}
|
|
38
|
+
const screen = {
|
|
39
|
+
get base() {
|
|
40
|
+
return state.base;
|
|
41
|
+
},
|
|
42
|
+
baseClass: "sm:hidden",
|
|
43
|
+
get lg() {
|
|
44
|
+
return state.lg;
|
|
45
|
+
},
|
|
46
|
+
lgClass: "max-lg:hidden xl:hidden",
|
|
47
|
+
get md() {
|
|
48
|
+
return state.md;
|
|
49
|
+
},
|
|
50
|
+
mdClass: "max-md:hidden lg:hidden",
|
|
51
|
+
ready,
|
|
52
|
+
get sm() {
|
|
53
|
+
return state.sm;
|
|
54
|
+
},
|
|
55
|
+
smClass: "max-sm:hidden md:hidden",
|
|
56
|
+
get xl() {
|
|
57
|
+
return state.xl;
|
|
58
|
+
},
|
|
59
|
+
xlClass: "max-xl:hidden 2xl:hidden",
|
|
60
|
+
get xxl() {
|
|
61
|
+
return state.xxl;
|
|
62
|
+
},
|
|
63
|
+
xxlClass: "max-2xl:hidden"
|
|
64
|
+
};
|
|
65
|
+
export function useScreen() {
|
|
66
|
+
onMounted(initialize);
|
|
67
|
+
return screen;
|
|
68
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
2
|
+
export type Theme = 'dark' | 'light';
|
|
3
|
+
export interface ThemeController {
|
|
4
|
+
isDark: ComputedRef<boolean>;
|
|
5
|
+
isLight: ComputedRef<boolean>;
|
|
6
|
+
setTheme: (value: Theme) => void;
|
|
7
|
+
theme: Ref<Theme>;
|
|
8
|
+
toggleTheme: () => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Controls the colour theme used by the UI catalogue.
|
|
12
|
+
*
|
|
13
|
+
* The selected theme is stored in localStorage. A bootstrap script applies it
|
|
14
|
+
* before Nuxt mounts the application.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useTheme(): ThemeController;
|
|
17
|
+
//# sourceMappingURL=useTheme.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useState } from "nuxt/app";
|
|
2
|
+
import { computed, onMounted, onUnmounted, watch } from "vue";
|
|
3
|
+
const THEME_STORAGE_KEY = "ui-theme";
|
|
4
|
+
const THEME_STATE = "ui-theme";
|
|
5
|
+
const normalizeTheme = (value) => value === "light" ? "light" : "dark";
|
|
6
|
+
const getSystemTheme = () => window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
7
|
+
const getInitialTheme = () => {
|
|
8
|
+
if (!import.meta.client) {
|
|
9
|
+
return "dark";
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const storedTheme = localStorage.getItem(THEME_STORAGE_KEY);
|
|
13
|
+
if (storedTheme === "dark" || storedTheme === "light") {
|
|
14
|
+
return storedTheme;
|
|
15
|
+
}
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
return getSystemTheme();
|
|
19
|
+
};
|
|
20
|
+
const applyTheme = (theme) => {
|
|
21
|
+
if (!import.meta.client) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const root = document.documentElement;
|
|
25
|
+
root.dataset.uiTheme = theme;
|
|
26
|
+
root.style.colorScheme = theme;
|
|
27
|
+
};
|
|
28
|
+
export function useTheme() {
|
|
29
|
+
const theme = useState(THEME_STATE, getInitialTheme);
|
|
30
|
+
const synchronizeTheme = () => {
|
|
31
|
+
const nextTheme = getInitialTheme();
|
|
32
|
+
theme.value = nextTheme;
|
|
33
|
+
applyTheme(nextTheme);
|
|
34
|
+
};
|
|
35
|
+
if (import.meta.client) {
|
|
36
|
+
synchronizeTheme();
|
|
37
|
+
}
|
|
38
|
+
onMounted(() => {
|
|
39
|
+
window.addEventListener("pageshow", synchronizeTheme);
|
|
40
|
+
});
|
|
41
|
+
onUnmounted(() => {
|
|
42
|
+
window.removeEventListener("pageshow", synchronizeTheme);
|
|
43
|
+
});
|
|
44
|
+
watch(
|
|
45
|
+
theme,
|
|
46
|
+
(value) => {
|
|
47
|
+
const nextTheme = normalizeTheme(value);
|
|
48
|
+
if (nextTheme !== value) {
|
|
49
|
+
theme.value = nextTheme;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (import.meta.client) {
|
|
53
|
+
applyTheme(nextTheme);
|
|
54
|
+
try {
|
|
55
|
+
localStorage.setItem(THEME_STORAGE_KEY, nextTheme);
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{ flush: "sync" }
|
|
61
|
+
);
|
|
62
|
+
const isDark = computed(() => theme.value === "dark");
|
|
63
|
+
const isLight = computed(() => theme.value === "light");
|
|
64
|
+
const setTheme = (value) => {
|
|
65
|
+
theme.value = value;
|
|
66
|
+
};
|
|
67
|
+
const toggleTheme = () => {
|
|
68
|
+
theme.value = isDark.value ? "light" : "dark";
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
isDark,
|
|
72
|
+
isLight,
|
|
73
|
+
setTheme,
|
|
74
|
+
theme,
|
|
75
|
+
toggleTheme
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RouteRecordNameGeneric } from 'vue-router';
|
|
2
|
+
import { type App, type Ref } from 'vue';
|
|
3
|
+
export interface BrickflowConfig {
|
|
4
|
+
i18n?: BrickflowI18n;
|
|
5
|
+
}
|
|
6
|
+
export interface BrickflowI18n {
|
|
7
|
+
getRealName: (route: {
|
|
8
|
+
name: RouteRecordNameGeneric;
|
|
9
|
+
}) => string;
|
|
10
|
+
getRealPath: (route: BrickflowRouteLocationParam | string) => string;
|
|
11
|
+
locale: Ref<string>;
|
|
12
|
+
localePath: (route: BrickflowRouteLocationParam | string) => string;
|
|
13
|
+
}
|
|
14
|
+
export interface BrickflowRouteLocationParam {
|
|
15
|
+
path: string;
|
|
16
|
+
query: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export declare function provideBrickflowConfig<T extends BrickflowConfig>(app: App, config: T): void;
|
|
19
|
+
export declare function useTranslate(): BrickflowI18n;
|
|
20
|
+
//# sourceMappingURL=useTranslate.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { inject, ref } from "vue";
|
|
2
|
+
const brickflowConfigKey = Symbol("brickflow-config");
|
|
3
|
+
const useTranslateFallback = () => {
|
|
4
|
+
const getRealPath = (route) => typeof route === "string" ? route : route.path;
|
|
5
|
+
return {
|
|
6
|
+
getRealName: (route) => String(route.name),
|
|
7
|
+
getRealPath,
|
|
8
|
+
locale: ref("en"),
|
|
9
|
+
localePath: getRealPath
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export function provideBrickflowConfig(app, config) {
|
|
13
|
+
app.provide(brickflowConfigKey, config);
|
|
14
|
+
}
|
|
15
|
+
export function useTranslate() {
|
|
16
|
+
return inject(brickflowConfigKey)?.i18n ?? useTranslateFallback();
|
|
17
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=ui.vue.d.ts.map
|