@hywax/cms 3.4.3 → 3.5.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/.nuxt/cms/index.ts +1 -0
- package/.nuxt/cms/toc.ts +18 -0
- package/.nuxt/cms.css +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +21 -1
- package/dist/runtime/components/TablePreviewLink.vue +1 -1
- package/dist/runtime/components/Toc.d.vue.ts +23 -0
- package/dist/runtime/components/Toc.vue +65 -0
- package/dist/runtime/components/Toc.vue.d.ts +23 -0
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/package.json +1 -1
package/.nuxt/cms/index.ts
CHANGED
|
@@ -9,5 +9,6 @@ export { default as formUploraImage } from './form-uplora-image'
|
|
|
9
9
|
export { default as modalConfirm } from './modal-confirm'
|
|
10
10
|
export { default as tablePanel } from './table-panel'
|
|
11
11
|
export { default as tableSearchInput } from './table-search-input'
|
|
12
|
+
export { default as toc } from './toc'
|
|
12
13
|
export { default as uploraImage } from './uplora-image'
|
|
13
14
|
export * as prose from './prose'
|
package/.nuxt/cms/toc.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"slots": {
|
|
3
|
+
"root": "",
|
|
4
|
+
"list": "min-w-0",
|
|
5
|
+
"listWithChildren": "ms-3",
|
|
6
|
+
"item": "min-w-0",
|
|
7
|
+
"itemWithChildren": "",
|
|
8
|
+
"link": "group relative text-sm flex items-center focus-visible:outline-primary py-1 text-muted hover:text-default transition-colors",
|
|
9
|
+
"linkText": "truncate"
|
|
10
|
+
},
|
|
11
|
+
"variants": {
|
|
12
|
+
"active": {
|
|
13
|
+
"true": {
|
|
14
|
+
"link": "text-primary"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
package/.nuxt/cms.css
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { pascalCase, kebabCase, camelCase } from 'scule';
|
|
|
7
7
|
import { globSync } from 'tinyglobby';
|
|
8
8
|
|
|
9
9
|
const name = "@hywax/cms";
|
|
10
|
-
const version = "3.
|
|
10
|
+
const version = "3.5.0";
|
|
11
11
|
|
|
12
12
|
function createContext(options, nuxt) {
|
|
13
13
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -536,6 +536,25 @@ const tableSearchInput = {
|
|
|
536
536
|
}
|
|
537
537
|
};
|
|
538
538
|
|
|
539
|
+
const toc = {
|
|
540
|
+
slots: {
|
|
541
|
+
root: "",
|
|
542
|
+
list: "min-w-0",
|
|
543
|
+
listWithChildren: "ms-3",
|
|
544
|
+
item: "min-w-0",
|
|
545
|
+
itemWithChildren: "",
|
|
546
|
+
link: "group relative text-sm flex items-center focus-visible:outline-primary py-1 text-muted hover:text-default transition-colors",
|
|
547
|
+
linkText: "truncate"
|
|
548
|
+
},
|
|
549
|
+
variants: {
|
|
550
|
+
active: {
|
|
551
|
+
true: {
|
|
552
|
+
link: "text-primary"
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
|
|
539
558
|
const uploraImage$1 = {
|
|
540
559
|
slots: {
|
|
541
560
|
root: "relative grid grid-cols-[100%] grid-rows-[100%] overflow-hidden",
|
|
@@ -558,6 +577,7 @@ const theme = {
|
|
|
558
577
|
modalConfirm: modalConfirm,
|
|
559
578
|
tablePanel: tablePanel,
|
|
560
579
|
tableSearchInput: tableSearchInput,
|
|
580
|
+
toc: toc,
|
|
561
581
|
uploraImage: uploraImage$1
|
|
562
582
|
};
|
|
563
583
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="relative flex items-center gap-2">
|
|
3
|
-
<div v-if="image" class="overflow-hidden rounded-lg shrink-0">
|
|
3
|
+
<div v-if="image" class="overflow-hidden rounded-lg shrink-0 size-8">
|
|
4
4
|
<CUploraImage
|
|
5
5
|
v-bind="image"
|
|
6
6
|
:sizes="[{ width: 32, height: 32, descriptor: '1x' }]"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import type { TocLink } from '@nuxtjs/mdc';
|
|
3
|
+
import type { ComponentConfig } from '../types';
|
|
4
|
+
import theme from '#build/cms/toc';
|
|
5
|
+
type Toc = ComponentConfig<typeof theme, AppConfig, 'toc'>;
|
|
6
|
+
export interface TocProps {
|
|
7
|
+
links: TocLink[];
|
|
8
|
+
containerRef?: HTMLElement | null;
|
|
9
|
+
class?: any;
|
|
10
|
+
ui?: Toc['slots'];
|
|
11
|
+
}
|
|
12
|
+
export interface TocEmits {
|
|
13
|
+
move: [string];
|
|
14
|
+
}
|
|
15
|
+
declare const __VLS_export: import("vue").DefineComponent<TocProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
16
|
+
move: (args_0: string) => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<TocProps> & Readonly<{
|
|
18
|
+
onMove?: ((args_0: string) => any) | undefined;
|
|
19
|
+
}>, {
|
|
20
|
+
containerRef: HTMLElement | null;
|
|
21
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- eslint-disable-next-line vue/no-template-shadow -->
|
|
3
|
+
<DefineListTemplate v-slot="{ links, level }">
|
|
4
|
+
<ul :class="level > 0 ? ui.listWithChildren({ class: props.ui?.listWithChildren }) : ui.list({ class: props.ui?.list })">
|
|
5
|
+
<li v-for="(link, index) in links" :key="index" :class="link.children && link.children.length > 0 ? ui.itemWithChildren({ class: props.ui?.itemWithChildren }) : ui.item({ class: props.ui?.item })">
|
|
6
|
+
<a
|
|
7
|
+
:href="`#${link.id}`"
|
|
8
|
+
:class="ui.link({ class: props.ui?.link, active: activeHeadings.includes(link.id) })"
|
|
9
|
+
@click="scrollToHeading(link.id)"
|
|
10
|
+
>
|
|
11
|
+
{{ link.text }}
|
|
12
|
+
</a>
|
|
13
|
+
|
|
14
|
+
<ReuseListTemplate
|
|
15
|
+
v-if="link.children?.length"
|
|
16
|
+
:links="link.children"
|
|
17
|
+
:level="level + 1"
|
|
18
|
+
/>
|
|
19
|
+
</li>
|
|
20
|
+
</ul>
|
|
21
|
+
</DefineListTemplate>
|
|
22
|
+
|
|
23
|
+
<div :class="ui.root({ class: [props.ui?.root, props.class] })">
|
|
24
|
+
<ReuseListTemplate :links="props.links" :level="0" />
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup>
|
|
29
|
+
import theme from "#build/cms/toc";
|
|
30
|
+
import { useAppConfig, useNuxtApp, useRouter, useScrollspy } from "#imports";
|
|
31
|
+
import { createReusableTemplate } from "@vueuse/core";
|
|
32
|
+
import { computed } from "vue";
|
|
33
|
+
import { tv } from "../tv";
|
|
34
|
+
const props = defineProps({
|
|
35
|
+
links: { type: Array, required: true },
|
|
36
|
+
containerRef: { type: null, required: false, default: null },
|
|
37
|
+
class: { type: null, required: false },
|
|
38
|
+
ui: { type: null, required: false }
|
|
39
|
+
});
|
|
40
|
+
const emits = defineEmits(["move"]);
|
|
41
|
+
const router = useRouter();
|
|
42
|
+
const appConfig = useAppConfig();
|
|
43
|
+
const { activeHeadings, updateHeadings } = useScrollspy();
|
|
44
|
+
const [DefineListTemplate, ReuseListTemplate] = createReusableTemplate({
|
|
45
|
+
props: {
|
|
46
|
+
links: Array,
|
|
47
|
+
level: Number
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
function scrollToHeading(id) {
|
|
51
|
+
const encodedId = encodeURIComponent(id);
|
|
52
|
+
router.push(`#${encodedId}`);
|
|
53
|
+
emits("move", id);
|
|
54
|
+
}
|
|
55
|
+
const ui = computed(() => tv({ extend: tv(theme), ...appConfig.cms?.toc || {} })());
|
|
56
|
+
const nuxtApp = useNuxtApp();
|
|
57
|
+
nuxtApp.hooks.hook("page:loading:end", () => {
|
|
58
|
+
const headings = Array.from((props.containerRef || document)?.querySelectorAll("h2, h3") ?? []);
|
|
59
|
+
updateHeadings(headings);
|
|
60
|
+
});
|
|
61
|
+
nuxtApp.hooks.hook("page:transition:finish", () => {
|
|
62
|
+
const headings = Array.from((props.containerRef || document)?.querySelectorAll("h2, h3") ?? []);
|
|
63
|
+
updateHeadings(headings);
|
|
64
|
+
});
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import type { TocLink } from '@nuxtjs/mdc';
|
|
3
|
+
import type { ComponentConfig } from '../types';
|
|
4
|
+
import theme from '#build/cms/toc';
|
|
5
|
+
type Toc = ComponentConfig<typeof theme, AppConfig, 'toc'>;
|
|
6
|
+
export interface TocProps {
|
|
7
|
+
links: TocLink[];
|
|
8
|
+
containerRef?: HTMLElement | null;
|
|
9
|
+
class?: any;
|
|
10
|
+
ui?: Toc['slots'];
|
|
11
|
+
}
|
|
12
|
+
export interface TocEmits {
|
|
13
|
+
move: [string];
|
|
14
|
+
}
|
|
15
|
+
declare const __VLS_export: import("vue").DefineComponent<TocProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
16
|
+
move: (args_0: string) => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<TocProps> & Readonly<{
|
|
18
|
+
onMove?: ((args_0: string) => any) | undefined;
|
|
19
|
+
}>, {
|
|
20
|
+
containerRef: HTMLElement | null;
|
|
21
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
export default _default;
|
|
@@ -18,6 +18,7 @@ export * from '../components/TableFilters.vue';
|
|
|
18
18
|
export * from '../components/TablePanel.vue';
|
|
19
19
|
export * from '../components/TablePreviewSeo.vue';
|
|
20
20
|
export * from '../components/TableSearchInput.vue';
|
|
21
|
+
export * from '../components/Toc.vue';
|
|
21
22
|
export * from '../components/UploraImage.vue';
|
|
22
23
|
export * from '../composables/useAdmin';
|
|
23
24
|
export * from '../composables/useApi';
|
|
@@ -18,6 +18,7 @@ export * from "../components/TableFilters.vue";
|
|
|
18
18
|
export * from "../components/TablePanel.vue";
|
|
19
19
|
export * from "../components/TablePreviewSeo.vue";
|
|
20
20
|
export * from "../components/TableSearchInput.vue";
|
|
21
|
+
export * from "../components/Toc.vue";
|
|
21
22
|
export * from "../components/UploraImage.vue";
|
|
22
23
|
export * from "../composables/useAdmin.js";
|
|
23
24
|
export * from "../composables/useApi.js";
|