@hywax/cms 3.7.0 → 3.8.1

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.
@@ -3,7 +3,7 @@ export default {
3
3
  "base": "grid gap-4"
4
4
  },
5
5
  "variants": {
6
- "columns": {
6
+ "layout": {
7
7
  "two-columns": {
8
8
  "base": "grid-cols-2"
9
9
  },
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
- "version": "3.7.0",
3
+ "version": "3.8.1",
4
4
  "configKey": "cms",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
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.7.0";
10
+ const version = "3.8.1";
11
11
 
12
12
  function createContext(options, nuxt) {
13
13
  const { resolve } = createResolver(import.meta.url);
@@ -619,7 +619,7 @@ const uploraImageGallery = {
619
619
  base: "grid gap-4"
620
620
  },
621
621
  variants: {
622
- columns: {
622
+ layout: {
623
623
  "two-columns": {
624
624
  base: "grid-cols-2"
625
625
  },
@@ -29,7 +29,7 @@
29
29
  :state="state"
30
30
  :schema="schema"
31
31
  :class="ui.form({ class: props.ui?.form })"
32
- :validate-on="['change']"
32
+ :validate-on="['input']"
33
33
  @submit="submitHandler"
34
34
  >
35
35
  <div :class="ui.body({ class: props.ui?.body })">
@@ -3,7 +3,7 @@
3
3
  :name="name"
4
4
  :schema="schema"
5
5
  :class="ui.root({ class: [props.ui?.root, props.class] })"
6
- :validate-on="['change']"
6
+ :validate-on="['input']"
7
7
  nested
8
8
  >
9
9
  <UFormField
@@ -83,14 +83,15 @@ const state = computed({
83
83
  };
84
84
  },
85
85
  set: (value) => {
86
- model.value = value;
86
+ const isEmpty = Object.values(value).every((value2) => !value2);
87
+ model.value = isEmpty ? null : value;
87
88
  }
88
89
  });
89
90
  const appConfig = useAppConfig();
90
91
  const schema = z.object({
91
92
  title: z.string(),
92
93
  description: z.string()
93
- });
94
+ }).nullable();
94
95
  const { title, description } = useSeoStats(() => state.value);
95
96
  const ui = computed(() => tv({ extend: tv(theme), ...appConfig.cms?.formSeo || {} })());
96
97
  </script>
@@ -1,8 +1,9 @@
1
1
  <template>
2
2
  <UForm
3
+ ref="formRef"
3
4
  :schema="schema"
4
5
  :class="ui.root({ class: [props.ui?.root, props.class] })"
5
- :validate-on="['change']"
6
+ :validate-on="['input']"
6
7
  nested
7
8
  >
8
9
  <UFormField
@@ -45,7 +46,7 @@
45
46
  <script>
46
47
  import theme from "#build/cms/form-slug";
47
48
  import { useAppConfig } from "#imports";
48
- import { computed, ref, watch } from "vue";
49
+ import { computed, ref, useTemplateRef, watch } from "vue";
49
50
  import { z } from "zod";
50
51
  import { tv } from "../tv";
51
52
  import { slugify } from "../utils/slugify";
@@ -69,6 +70,7 @@ const schema = z.object({
69
70
  title: z.string().min(1),
70
71
  slug: z.string().min(1)
71
72
  });
73
+ const formRef = useTemplateRef("formRef");
72
74
  const isRegenerate = ref(props.regenerate);
73
75
  watch(title, () => {
74
76
  if (!isRegenerate.value) {
@@ -76,5 +78,10 @@ watch(title, () => {
76
78
  }
77
79
  slug.value = slugify(title.value);
78
80
  });
81
+ watch(slug, () => {
82
+ if (formRef.value?.getErrors("slug")) {
83
+ formRef.value?.clear("slug");
84
+ }
85
+ });
79
86
  const ui = computed(() => tv({ extend: tv(theme), ...appConfig.cms?.formSlug || {} })());
80
87
  </script>
@@ -3,7 +3,7 @@
3
3
  :name="name"
4
4
  :schema="schema"
5
5
  :class="ui.root({ class: [props.ui?.root, props.class] })"
6
- :validate-on="['change']"
6
+ :validate-on="['input']"
7
7
  :nested="nested"
8
8
  >
9
9
  <UFormField name="image" :label="label">
@@ -148,7 +148,8 @@ const state = computed({
148
148
  };
149
149
  },
150
150
  set: (value) => {
151
- model.value = value;
151
+ const isEmpty = Object.values(value).every((value2) => !value2);
152
+ model.value = isEmpty ? null : value;
152
153
  }
153
154
  });
154
155
  const appConfig = useAppConfig();
@@ -160,7 +161,7 @@ const schema = z.object({
160
161
  lqip: z.string().min(1).optional(),
161
162
  color: z.string().min(1).optional(),
162
163
  aspect: z.union([z.literal("horizontal"), z.literal("vertical"), z.literal("dynamic")]).optional()
163
- });
164
+ }).nullable();
164
165
  const extensions = computed(() => imagesExtensions.filter((extension) => extension !== "jpeg").join(", "));
165
166
  const aspectItems = [
166
167
  { value: "horizontal", label: "\u0413\u043E\u0440\u0438\u0437\u043E\u043D\u0442\u0430\u043B\u044C\u043D\u044B\u0439" },
@@ -5,8 +5,8 @@ export interface TablePreviewLinkProps {
5
5
  to?: RouteLocationRaw;
6
6
  target?: ButtonProps['target'];
7
7
  label: string;
8
- description?: string;
9
- image?: Pick<UploraImageProps, 'image' | 'alt' | 'color' | 'lqip'>;
8
+ description?: string | null;
9
+ image?: Pick<UploraImageProps, 'image' | 'alt' | 'color' | 'lqip'> | null;
10
10
  }
11
11
  declare const __VLS_export: import("vue").DefineComponent<TablePreviewLinkProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<TablePreviewLinkProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
12
  declare const _default: typeof __VLS_export;
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <div class="relative flex items-center gap-2">
3
+ <!-- TODO: добавить <CUploraPlaceholder /> -->
3
4
  <div v-if="image" class="overflow-hidden rounded-lg shrink-0 size-8">
4
5
  <CUploraImage
5
6
  v-bind="image"
@@ -32,7 +33,7 @@ defineProps({
32
33
  to: { type: null, required: false },
33
34
  target: { type: [String, Object, null], required: false },
34
35
  label: { type: String, required: true },
35
- description: { type: String, required: false },
36
- image: { type: Object, required: false }
36
+ description: { type: [String, null], required: false },
37
+ image: { type: [Object, null], required: false }
37
38
  });
38
39
  </script>
@@ -5,8 +5,8 @@ export interface TablePreviewLinkProps {
5
5
  to?: RouteLocationRaw;
6
6
  target?: ButtonProps['target'];
7
7
  label: string;
8
- description?: string;
9
- image?: Pick<UploraImageProps, 'image' | 'alt' | 'color' | 'lqip'>;
8
+ description?: string | null;
9
+ image?: Pick<UploraImageProps, 'image' | 'alt' | 'color' | 'lqip'> | null;
10
10
  }
11
11
  declare const __VLS_export: import("vue").DefineComponent<TablePreviewLinkProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<TablePreviewLinkProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
12
  declare const _default: typeof __VLS_export;
@@ -1,6 +1,6 @@
1
1
  import type { SEO } from '../types/seo';
2
2
  export interface TableCellSeoProps {
3
- seo: SEO;
3
+ seo: SEO | null;
4
4
  as?: any;
5
5
  }
6
6
  declare const _default: typeof __VLS_export;
@@ -13,10 +13,11 @@ import { useSeoStats } from "../composables/useSeoStats";
13
13
 
14
14
  <script setup>
15
15
  const props = defineProps({
16
- seo: { type: Object, required: true },
16
+ seo: { type: [Object, null], required: true },
17
17
  as: { type: null, required: false }
18
18
  });
19
- const { title, description, computeColor } = useSeoStats(props.seo);
19
+ const seo = computed(() => props.seo ?? { title: "", description: "" });
20
+ const { title, description, computeColor } = useSeoStats(seo);
20
21
  const rating = computed(() => {
21
22
  return Math.round((title.value.progress + description.value.progress) / 2);
22
23
  });
@@ -1,6 +1,6 @@
1
1
  import type { SEO } from '../types/seo';
2
2
  export interface TableCellSeoProps {
3
- seo: SEO;
3
+ seo: SEO | null;
4
4
  as?: any;
5
5
  }
6
6
  declare const _default: typeof __VLS_export;
@@ -3,7 +3,7 @@ import type { ComponentConfig } from '../../types';
3
3
  import theme from '#build/cms/prose/uplora-image-gallery';
4
4
  export type ProseUploraImageGallery = ComponentConfig<typeof theme, AppConfig, 'uploraImageGallery', 'cms.prose'>;
5
5
  export interface ProseUploraImageGalleryProps {
6
- columns: 'two-columns' | 'three-columns';
6
+ layout: 'two-columns' | 'three-columns';
7
7
  class?: any;
8
8
  ui?: ProseUploraImageGallery['slots'];
9
9
  }
@@ -13,12 +13,12 @@ import { tv } from "../../tv";
13
13
 
14
14
  <script setup>
15
15
  const props = defineProps({
16
- columns: { type: String, required: true },
16
+ layout: { type: String, required: true },
17
17
  class: { type: null, required: false },
18
18
  ui: { type: null, required: false }
19
19
  });
20
20
  const appConfig = useAppConfig();
21
21
  const ui = computed(() => tv({ extend: tv(theme), ...appConfig.cms?.prose?.uploraImageGallery || {} })({
22
- columns: props.columns
22
+ layout: props.layout
23
23
  }));
24
24
  </script>
@@ -3,7 +3,7 @@ import type { ComponentConfig } from '../../types';
3
3
  import theme from '#build/cms/prose/uplora-image-gallery';
4
4
  export type ProseUploraImageGallery = ComponentConfig<typeof theme, AppConfig, 'uploraImageGallery', 'cms.prose'>;
5
5
  export interface ProseUploraImageGalleryProps {
6
- columns: 'two-columns' | 'three-columns';
6
+ layout: 'two-columns' | 'three-columns';
7
7
  class?: any;
8
8
  ui?: ProseUploraImageGallery['slots'];
9
9
  }
@@ -19,8 +19,8 @@ export type TableColumnCustom<T extends TableData, D = unknown> = TableColumn<T,
19
19
  to?: ((row: TableRow<T>) => RouteLocationRaw | string | undefined) | RouteLocationRaw | string | undefined;
20
20
  target?: ButtonProps['target'];
21
21
  emptyValue?: string;
22
- image?: ((row: TableRow<T>) => TablePreviewLinkProps['image'] | undefined) | TablePreviewLinkProps['image'] | undefined;
23
- description?: ((row: TableRow<T>) => string | undefined) | string | undefined;
22
+ image?: ((row: TableRow<T>) => TablePreviewLinkProps['image'] | undefined | null) | TablePreviewLinkProps['image'] | undefined | null;
23
+ description?: ((row: TableRow<T>) => string | undefined | null) | string | undefined | null;
24
24
  };
25
25
  export declare function useTableColumns<I extends Record<string, any>, T extends readonly TableColumnCustom<I>[] = readonly TableColumnCustom<I>[]>(columns: T): {
26
26
  columns: {
@@ -20,7 +20,7 @@ export const UploraImageGallery = Node.create({
20
20
  content: "block*",
21
21
  addAttributes() {
22
22
  return {
23
- columns: { default: "two-columns" }
23
+ layout: { default: "two-columns" }
24
24
  };
25
25
  },
26
26
  ...createBlockMarkdownSpec({ name: "uplora-image-gallery", content: "block" }),
@@ -14,9 +14,9 @@
14
14
  variant="ghost"
15
15
  color="neutral"
16
16
  size="sm"
17
- :items="columnsItems"
18
- :model-value="attrs.columns"
19
- @update:model-value="updateAttributes({ ...attrs, columns: $event })"
17
+ :items="layoutItems"
18
+ :model-value="attrs.layout"
19
+ @update:model-value="updateAttributes({ ...attrs, layout: $event })"
20
20
  />
21
21
  <UButton
22
22
  color="neutral"
@@ -63,7 +63,7 @@ const theme = {
63
63
  actions: "flex items-center gap-0.5"
64
64
  },
65
65
  variants: {
66
- columns: {
66
+ layout: {
67
67
  "two-columns": {
68
68
  content: "grid-cols-2"
69
69
  },
@@ -73,7 +73,7 @@ const theme = {
73
73
  }
74
74
  }
75
75
  };
76
- const columnsItems = [
76
+ const layoutItems = [
77
77
  { value: "two-columns", label: "2 \u043A\u043E\u043B\u043E\u043D\u043A\u0438" },
78
78
  { value: "three-columns", label: "3 \u043A\u043E\u043B\u043E\u043D\u043A\u0438" }
79
79
  ];
@@ -88,6 +88,6 @@ function handleInsertImage() {
88
88
  });
89
89
  }
90
90
  const ui = computed(() => tv({ extend: tv(theme) })({
91
- columns: attrs.value.columns
91
+ layout: attrs.value.layout
92
92
  }));
93
93
  </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
3
  "type": "module",
4
- "version": "3.7.0",
4
+ "version": "3.8.1",
5
5
  "description": "Hywax CMS. ⚠️ This package is intended for internal use only.",
6
6
  "imports": {
7
7
  "#build/cms/*": "./.nuxt/cms/*.ts",