@hywax/cms 0.0.4 → 0.0.5

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.
Files changed (70) hide show
  1. package/.nuxt/cms/autocomplete-select.ts +5 -0
  2. package/.nuxt/cms/button-copy.ts +5 -0
  3. package/.nuxt/cms/button-delete.ts +5 -0
  4. package/.nuxt/cms/form-panel-aside-section.ts +9 -0
  5. package/.nuxt/cms/form-panel-section.ts +8 -0
  6. package/.nuxt/cms/form-panel.ts +15 -0
  7. package/.nuxt/cms/index.ts +16 -0
  8. package/.nuxt/cms/input-seo.ts +5 -0
  9. package/.nuxt/cms/input-slug.ts +5 -0
  10. package/.nuxt/cms/modal-confirm.ts +5 -0
  11. package/.nuxt/cms/table-cell-preview.ts +9 -0
  12. package/.nuxt/cms/table-cell-seo.ts +5 -0
  13. package/.nuxt/cms/table-cell-user.ts +5 -0
  14. package/.nuxt/cms/table-panel-column-sorting.ts +5 -0
  15. package/.nuxt/cms/table-panel-column-visibility.ts +5 -0
  16. package/.nuxt/cms/table-panel-filters.ts +5 -0
  17. package/.nuxt/cms/table-panel.ts +8 -0
  18. package/cli/templates.mjs +3 -2
  19. package/dist/module.json +1 -1
  20. package/dist/module.mjs +154 -4
  21. package/dist/runtime/components/AutocompleteSelect.vue +170 -0
  22. package/dist/runtime/components/AutocompleteSelect.vue.d.ts +42 -0
  23. package/dist/runtime/components/ButtonCopy.vue +40 -0
  24. package/dist/runtime/components/ButtonCopy.vue.d.ts +23 -0
  25. package/dist/runtime/components/ButtonDelete.vue +52 -0
  26. package/dist/runtime/components/ButtonDelete.vue.d.ts +28 -0
  27. package/dist/runtime/components/FormPanel.vue +70 -0
  28. package/dist/runtime/components/FormPanel.vue.d.ts +41 -0
  29. package/dist/runtime/components/FormPanelAsideSection.vue +41 -0
  30. package/dist/runtime/components/FormPanelAsideSection.vue.d.ts +23 -0
  31. package/dist/runtime/components/FormPanelSection.vue +31 -0
  32. package/dist/runtime/components/FormPanelSection.vue.d.ts +20 -0
  33. package/dist/runtime/components/InputSeo.vue +73 -0
  34. package/dist/runtime/components/InputSeo.vue.d.ts +19 -0
  35. package/dist/runtime/components/InputSlug.vue +70 -0
  36. package/dist/runtime/components/InputSlug.vue.d.ts +29 -0
  37. package/dist/runtime/components/ModalConfirm.vue +91 -0
  38. package/dist/runtime/components/ModalConfirm.vue.d.ts +26 -0
  39. package/dist/runtime/components/TableCellPreview.vue +40 -0
  40. package/dist/runtime/components/TableCellPreview.vue.d.ts +18 -0
  41. package/dist/runtime/components/TableCellSeo.vue +34 -0
  42. package/dist/runtime/components/TableCellSeo.vue.d.ts +13 -0
  43. package/dist/runtime/components/TableCellUser.vue +33 -0
  44. package/dist/runtime/components/TableCellUser.vue.d.ts +15 -0
  45. package/dist/runtime/components/TablePanel.vue +153 -0
  46. package/dist/runtime/components/TablePanel.vue.d.ts +50 -0
  47. package/dist/runtime/components/TablePanelColumnSorting.vue +72 -0
  48. package/dist/runtime/components/TablePanelColumnSorting.vue.d.ts +20 -0
  49. package/dist/runtime/components/TablePanelColumnVisibility.vue +49 -0
  50. package/dist/runtime/components/TablePanelColumnVisibility.vue.d.ts +20 -0
  51. package/dist/runtime/components/TablePanelFilters.vue +79 -0
  52. package/dist/runtime/components/TablePanelFilters.vue.d.ts +34 -0
  53. package/dist/runtime/components/prose/UploraImage.vue +8 -3
  54. package/dist/runtime/composables/useDeleteConfirm.d.ts +15 -0
  55. package/dist/runtime/composables/useDeleteConfirm.js +29 -0
  56. package/dist/runtime/composables/useSeoStats.d.ts +2 -2
  57. package/dist/runtime/composables/useSeoStats.js +1 -1
  58. package/dist/runtime/composables/useTable.d.ts +19 -0
  59. package/dist/runtime/composables/useTable.js +90 -0
  60. package/dist/runtime/editor/markdown/index.d.ts +3 -0
  61. package/dist/runtime/editor/markdown/index.js +47 -0
  62. package/dist/runtime/editor/markdown/nodes/callout.d.ts +2 -0
  63. package/dist/runtime/editor/markdown/nodes/callout.js +21 -0
  64. package/dist/runtime/editor/markdown/nodes/uploraImage.d.ts +2 -0
  65. package/dist/runtime/editor/markdown/nodes/uploraImage.js +31 -0
  66. package/dist/runtime/server/utils/validation.d.ts +2 -2
  67. package/dist/runtime/types/index.d.ts +16 -0
  68. package/dist/runtime/types/index.js +16 -0
  69. package/dist/runtime/types/query.d.ts +3 -1
  70. package/package.json +5 -5
@@ -4,9 +4,9 @@ interface SEOStats {
4
4
  progress: number;
5
5
  color: 'error' | 'warning' | 'success';
6
6
  }
7
- interface UseSEOStatsReturn {
7
+ interface UseSeoStatsReturn {
8
8
  title: ComputedRef<SEOStats>;
9
9
  description: ComputedRef<SEOStats>;
10
10
  }
11
- export declare function useSEOStats(options: MaybeRefOrGetter<SEO>): UseSEOStatsReturn;
11
+ export declare function useSeoStats(options: MaybeRefOrGetter<SEO>): UseSeoStatsReturn;
12
12
  export {};
@@ -20,7 +20,7 @@ function computeColor(score) {
20
20
  }
21
21
  return "success";
22
22
  }
23
- export function useSEOStats(options) {
23
+ export function useSeoStats(options) {
24
24
  const title = computed(() => {
25
25
  const value = toValue(options);
26
26
  const score = computeScore(value.title.length, 45, 60);
@@ -0,0 +1,19 @@
1
+ import type { SortingState } from '@tanstack/vue-table';
2
+ import type { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
3
+ import type { PaginationQuery, SortQuery } from '../types';
4
+ interface UseTableReturn<T> {
5
+ models: Ref<T>;
6
+ appliedCount: ComputedRef<number>;
7
+ applyFilters: () => void;
8
+ resetFilters: () => void;
9
+ sorting: Ref<SortingState>;
10
+ pagination: Ref<PaginationQuery>;
11
+ filters: Ref<T>;
12
+ query: ComputedRef<T & PaginationQuery & SortQuery | object>;
13
+ }
14
+ interface UseTableOptions<T> {
15
+ defaultSort?: SortQuery;
16
+ countFiltersExcept?: Array<keyof T>;
17
+ }
18
+ export default function useTable<T extends object>(initialFilters: MaybeRefOrGetter<T>, options?: UseTableOptions<T>): UseTableReturn<T>;
19
+ export {};
@@ -0,0 +1,90 @@
1
+ import { computed, reactive, ref, toRaw, toValue, watch } from "#imports";
2
+ import isEqual from "fast-deep-equal";
3
+ function useTableFilters(initialFilters, options) {
4
+ const initial = computed(() => toValue(initialFilters));
5
+ const filters = ref(structuredClone(initial.value));
6
+ const models = ref(structuredClone(initial.value));
7
+ const applyFilters = () => {
8
+ filters.value = structuredClone(toRaw(models.value));
9
+ };
10
+ const resetFilters = () => {
11
+ models.value = structuredClone(initial.value);
12
+ applyFilters();
13
+ };
14
+ const appliedCountFields = computed(() => {
15
+ const fields = Object.keys(initial.value);
16
+ if (!options?.countFiltersExcept) {
17
+ return fields;
18
+ }
19
+ return fields.filter((key) => {
20
+ return !options.countFiltersExcept.includes(key);
21
+ });
22
+ });
23
+ const appliedCount = computed(() => {
24
+ return appliedCountFields.value.reduce((sum, key) => {
25
+ return isEqual(filters.value[key], initial.value[key]) ? sum : sum + 1;
26
+ }, 0);
27
+ });
28
+ watch(initial, (initial2) => {
29
+ filters.value = structuredClone(initial2);
30
+ models.value = structuredClone(initial2);
31
+ });
32
+ return {
33
+ filters,
34
+ models,
35
+ appliedCount,
36
+ applyFilters,
37
+ resetFilters
38
+ };
39
+ }
40
+ function useTableSort(defaultSort) {
41
+ const state = reactive({ "sort.column": defaultSort?.sortColumn ?? null, "sort.type": defaultSort?.sortType ?? "desc" });
42
+ const sort = computed(() => {
43
+ if (!state["sort.column"]) {
44
+ return null;
45
+ }
46
+ return { sortColumn: state["sort.column"], sortType: state["sort.type"] };
47
+ });
48
+ const sorting = computed({
49
+ get: () => state["sort.column"] ? [{ id: state["sort.column"], desc: state["sort.type"] === "desc" }] : [],
50
+ set: (value) => {
51
+ if (value.length === 0) {
52
+ state["sort.column"] = null;
53
+ state["sort.type"] = "asc";
54
+ return;
55
+ }
56
+ const { id, desc } = value[0];
57
+ state["sort.column"] = id;
58
+ state["sort.type"] = desc ? "desc" : "asc";
59
+ }
60
+ });
61
+ return { sort, sorting };
62
+ }
63
+ export default function useTable(initialFilters, options) {
64
+ const { filters, models, appliedCount, applyFilters, resetFilters } = useTableFilters(initialFilters, options);
65
+ const { sort, sorting } = useTableSort(options?.defaultSort);
66
+ const pagination = ref({ page: 1, perPage: 20 });
67
+ const query = computed(() => {
68
+ return {
69
+ ...filters.value,
70
+ ...sort.value,
71
+ ...pagination.value
72
+ };
73
+ });
74
+ watch([filters, sort, () => pagination.value.perPage], () => {
75
+ if (pagination.value.page === 1) {
76
+ return;
77
+ }
78
+ pagination.value.page = 1;
79
+ }, { deep: true });
80
+ return {
81
+ models,
82
+ appliedCount,
83
+ applyFilters,
84
+ resetFilters,
85
+ filters,
86
+ sorting,
87
+ pagination,
88
+ query
89
+ };
90
+ }
@@ -0,0 +1,3 @@
1
+ import type { MDCProsemirrorOptions } from '@unpress/mdc-prosemirror';
2
+ export declare function docToMarkdown(doc: any, config?: MDCProsemirrorOptions): Promise<string>;
3
+ export declare function markdownToDoc(markdown: string, config?: MDCProsemirrorOptions): Promise<import("@unpress/mdc-prosemirror").NodeJSON>;
@@ -0,0 +1,47 @@
1
+ import { docToMarkdown as docToMarkdownProsemirror, markdownToDoc as markdownToDocProsemirror } from "@unpress/mdc-prosemirror";
2
+ import { defu } from "defu";
3
+ import { calloutNode } from "./nodes/callout.js";
4
+ import { uploraImageNode } from "./nodes/uploraImage.js";
5
+ function genericComponentNode(type) {
6
+ const componentMap = {
7
+ "callout": "callout",
8
+ "caution": "callout",
9
+ "note": "callout",
10
+ "warning": "callout",
11
+ "tip": "callout",
12
+ "uplora-image": "uploraImage"
13
+ };
14
+ return {
15
+ type,
16
+ parse: () => {
17
+ },
18
+ compile: (node) => {
19
+ if (!node || !node.attrs?.componentName) {
20
+ return;
21
+ }
22
+ for (const [markdown, prosemirror] of Object.entries(componentMap)) {
23
+ if (markdown === node.attrs.componentName) {
24
+ node.type = prosemirror;
25
+ return;
26
+ }
27
+ }
28
+ }
29
+ };
30
+ }
31
+ const extraNodes = [
32
+ genericComponentNode("containerComponent"),
33
+ genericComponentNode("textComponent"),
34
+ genericComponentNode("leafComponent"),
35
+ uploraImageNode,
36
+ calloutNode
37
+ ];
38
+ export function docToMarkdown(doc, config) {
39
+ return docToMarkdownProsemirror(doc, defu(config || {}, {
40
+ extraNodes
41
+ }));
42
+ }
43
+ export function markdownToDoc(markdown, config) {
44
+ return markdownToDocProsemirror(markdown, defu(config || {}, {
45
+ extraNodes
46
+ }));
47
+ }
@@ -0,0 +1,2 @@
1
+ import type { ExtraNode } from '@unpress/mdc-prosemirror';
2
+ export declare const calloutNode: ExtraNode;
@@ -0,0 +1,21 @@
1
+ export const calloutNode = {
2
+ type: "callout",
3
+ parse: (node) => {
4
+ if (!node) {
5
+ return;
6
+ }
7
+ Object.assign(node, {
8
+ type: "containerComponent",
9
+ name: node.attrs?.type || "note"
10
+ });
11
+ },
12
+ compile: (node) => {
13
+ if (!node) {
14
+ return;
15
+ }
16
+ node.type = "callout";
17
+ node.attrs = {
18
+ type: node.attrs?.componentName
19
+ };
20
+ }
21
+ };
@@ -0,0 +1,2 @@
1
+ import type { ExtraNode } from '@unpress/mdc-prosemirror';
2
+ export declare const uploraImageNode: ExtraNode;
@@ -0,0 +1,31 @@
1
+ export const uploraImageNode = {
2
+ type: "uploraImage",
3
+ parse: (node) => {
4
+ if (!node) {
5
+ return;
6
+ }
7
+ Object.assign(node, {
8
+ type: "containerComponent",
9
+ name: "uplora-image",
10
+ attributes: {
11
+ image: node.attrs?.image || "",
12
+ alt: node.attrs?.alt || "",
13
+ lqip: node.attrs?.lqip || ""
14
+ },
15
+ children: []
16
+ });
17
+ },
18
+ compile: (node) => {
19
+ if (!node) {
20
+ return;
21
+ }
22
+ node.type = "uploraImage";
23
+ node.attrs = {
24
+ image: node.attrs?.attributes?.image || node.attrs?.fmAttributes?.image || "",
25
+ alt: node.attrs?.attributes?.alt || node.attrs?.fmAttributes?.alt || "",
26
+ color: node.attrs?.attributes?.color || node.attrs?.fmAttributes?.color || "",
27
+ lqip: node.attrs?.attributes?.lqip || node.attrs?.fmAttributes?.lqip || ""
28
+ };
29
+ delete node.children;
30
+ }
31
+ };
@@ -1,3 +1,3 @@
1
- import type { PaginationQuery, PaginationQueryRaw, SortQuery, SortQueryRaw } from '../../types';
1
+ import type { PaginationQueryRaw, PaginationQueryValidated, SortQuery, SortQueryRaw } from '../../types';
2
2
  export declare function getValidatedSort<T extends string[]>(query: SortQueryRaw, availableColumns: readonly [...T]): SortQuery<T[number]>;
3
- export declare function getValidatedPagination(query: PaginationQueryRaw): PaginationQuery;
3
+ export declare function getValidatedPagination(query: PaginationQueryRaw): PaginationQueryValidated;
@@ -1,4 +1,20 @@
1
+ export * from '../components/AutocompleteSelect.vue';
1
2
  export * from '../components/ButtonClear.vue';
3
+ export * from '../components/ButtonCopy.vue';
4
+ export * from '../components/ButtonDelete.vue';
5
+ export * from '../components/FormPanel.vue';
6
+ export * from '../components/FormPanelAsideSection.vue';
7
+ export * from '../components/FormPanelSection.vue';
8
+ export * from '../components/InputSeo.vue';
9
+ export * from '../components/InputSlug.vue';
10
+ export * from '../components/ModalConfirm.vue';
11
+ export * from '../components/TableCellPreview.vue';
12
+ export * from '../components/TableCellSeo.vue';
13
+ export * from '../components/TableCellUser.vue';
14
+ export * from '../components/TablePanel.vue';
15
+ export * from '../components/TablePanelColumnSorting.vue';
16
+ export * from '../components/TablePanelColumnVisibility.vue';
17
+ export * from '../components/TablePanelFilters.vue';
2
18
  export * from '../components/UploraImage.vue';
3
19
  export * from './image';
4
20
  export * from './query';
@@ -1,4 +1,20 @@
1
+ export * from "../components/AutocompleteSelect.vue";
1
2
  export * from "../components/ButtonClear.vue";
3
+ export * from "../components/ButtonCopy.vue";
4
+ export * from "../components/ButtonDelete.vue";
5
+ export * from "../components/FormPanel.vue";
6
+ export * from "../components/FormPanelAsideSection.vue";
7
+ export * from "../components/FormPanelSection.vue";
8
+ export * from "../components/InputSeo.vue";
9
+ export * from "../components/InputSlug.vue";
10
+ export * from "../components/ModalConfirm.vue";
11
+ export * from "../components/TableCellPreview.vue";
12
+ export * from "../components/TableCellSeo.vue";
13
+ export * from "../components/TableCellUser.vue";
14
+ export * from "../components/TablePanel.vue";
15
+ export * from "../components/TablePanelColumnSorting.vue";
16
+ export * from "../components/TablePanelColumnVisibility.vue";
17
+ export * from "../components/TablePanelFilters.vue";
2
18
  export * from "../components/UploraImage.vue";
3
19
  export * from "./image.js";
4
20
  export * from "./query.js";
@@ -16,5 +16,7 @@ export interface PaginationQueryRaw {
16
16
  export interface PaginationQuery {
17
17
  page: number;
18
18
  perPage: number;
19
- pageOffset: number;
20
19
  }
20
+ export type PaginationQueryValidated = PaginationQuery & {
21
+ pageOffset: number;
22
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "description": "Hywax CMS. ⚠️ This package is intended for internal use only.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "@dicebear/collection": "^9.2.2",
59
59
  "@dicebear/core": "^9.2.2",
60
- "@iconify-json/lucide": "1.2.50",
60
+ "@iconify-json/lucide": "1.2.51",
61
61
  "@nuxt/kit": "^3.17.5",
62
62
  "@nuxt/ui-pro": "^3.1.3",
63
63
  "@nuxtjs/mdc": "^0.17.0",
@@ -74,14 +74,14 @@
74
74
  "zod": "^3.25.67"
75
75
  },
76
76
  "devDependencies": {
77
- "@antfu/eslint-config": "^4.14.1",
77
+ "@antfu/eslint-config": "^4.15.0",
78
78
  "@commitlint/cli": "^19.8.1",
79
79
  "@commitlint/config-conventional": "^19.8.1",
80
80
  "@nuxt/devtools": "^2.5.0",
81
81
  "@nuxt/module-builder": "^1.0.1",
82
82
  "@nuxt/schema": "^3.17.5",
83
83
  "@nuxt/test-utils": "^3.19.1",
84
- "@types/node": "^22.14.0",
84
+ "@types/node": "^22.15.32",
85
85
  "@vue/test-utils": "^2.4.6",
86
86
  "changelogen": "^0.6.1",
87
87
  "eslint": "^9.29.0",
@@ -90,7 +90,7 @@
90
90
  "lint-staged": "^16.1.2",
91
91
  "nuxt": "^3.17.5",
92
92
  "typescript": "^5.8.3",
93
- "vitest": "^3.2.3",
93
+ "vitest": "^3.2.4",
94
94
  "vue-tsc": "^2.2.10"
95
95
  },
96
96
  "resolutions": {