@hywax/cms 2.0.1 → 2.1.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.
@@ -1,8 +1,8 @@
1
1
  export default {
2
2
  "slots": {
3
3
  "root": "",
4
- "title": "text-base text-pretty font-semibold text-highlighted mb-2",
5
- "description": "text-[15px] text-pretty text-muted mt-1",
4
+ "title": "text-base text-pretty font-semibold text-highlighted",
5
+ "description": "text-[15px] text-pretty text-muted mb-2",
6
6
  "body": "relative rounded-lg bg-elevated/50 ring ring-default grid gap-x-8 gap-y-4 p-4 sm:p-6"
7
7
  }
8
8
  }
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
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 { defu } from 'defu';
7
7
  import { globSync } from 'tinyglobby';
8
8
 
9
9
  const name = "@hywax/cms";
10
- const version = "2.0.1";
10
+ const version = "2.1.0";
11
11
 
12
12
  function createContext(options, nuxt) {
13
13
  const { resolve } = createResolver(import.meta.url);
@@ -149,7 +149,86 @@ const icons = {
149
149
  editLine: "i-lucide-pen-line"
150
150
  };
151
151
 
152
- function prepareMergeConfigs({ nuxt, options }) {
152
+ async function buildComponentDependencyGraph(componentDir, componentPattern) {
153
+ const dependencyGraph = /* @__PURE__ */ new Map();
154
+ const componentFiles = globSync(["**/*.vue"], {
155
+ cwd: componentDir,
156
+ absolute: true
157
+ });
158
+ for (const componentFile of componentFiles) {
159
+ try {
160
+ const content = await readFile(componentFile, "utf-8");
161
+ const componentName = pascalCase(componentFile.split("/").pop().replace(".vue", ""));
162
+ const dependencies = /* @__PURE__ */ new Set();
163
+ const matches = content.matchAll(componentPattern);
164
+ for (const match of matches) {
165
+ const depName = match[1] || match[2];
166
+ if (depName && depName !== componentName) {
167
+ dependencies.add(depName);
168
+ }
169
+ }
170
+ dependencyGraph.set(componentName, dependencies);
171
+ } catch {
172
+ }
173
+ }
174
+ return dependencyGraph;
175
+ }
176
+ function resolveComponentDependencies(component, dependencyGraph, resolved = /* @__PURE__ */ new Set()) {
177
+ if (resolved.has(component)) {
178
+ return resolved;
179
+ }
180
+ resolved.add(component);
181
+ const dependencies = dependencyGraph.get(component);
182
+ if (dependencies) {
183
+ for (const dep of dependencies) {
184
+ resolveComponentDependencies(dep, dependencyGraph, resolved);
185
+ }
186
+ }
187
+ return resolved;
188
+ }
189
+ async function detectUsedComponents(dirs, prefix, componentDir, includeComponents) {
190
+ const detectedComponents = /* @__PURE__ */ new Set();
191
+ if (includeComponents && includeComponents.length > 0) {
192
+ for (const component of includeComponents) {
193
+ detectedComponents.add(component);
194
+ }
195
+ }
196
+ const componentPattern = new RegExp(`<(?:Lazy)?${prefix}([A-Z][a-zA-Z]+)|\\b(?:Lazy)?${prefix}([A-Z][a-zA-Z]+)\\b`, "g");
197
+ for (const dir of dirs) {
198
+ const appFiles = globSync(["**/*.{vue,ts,js,tsx,jsx}"], {
199
+ cwd: dir,
200
+ ignore: ["node_modules/**", ".nuxt/**", "dist/**"]
201
+ });
202
+ for (const file of appFiles) {
203
+ try {
204
+ const filePath = join(dir, file);
205
+ const content = await readFile(filePath, "utf-8");
206
+ const matches = content.matchAll(componentPattern);
207
+ for (const match of matches) {
208
+ const componentName = match[1] || match[2];
209
+ if (componentName) {
210
+ detectedComponents.add(componentName);
211
+ }
212
+ }
213
+ } catch {
214
+ }
215
+ }
216
+ }
217
+ if (detectedComponents.size === 0) {
218
+ return void 0;
219
+ }
220
+ const dependencyGraph = await buildComponentDependencyGraph(componentDir, componentPattern);
221
+ const allComponents = /* @__PURE__ */ new Set();
222
+ for (const component of detectedComponents) {
223
+ const resolved = resolveComponentDependencies(component, dependencyGraph);
224
+ for (const resolvedComponent of resolved) {
225
+ allComponents.add(resolvedComponent);
226
+ }
227
+ }
228
+ return allComponents;
229
+ }
230
+
231
+ async function prepareMergeConfigs({ nuxt, options, resolve }) {
153
232
  nuxt.options.experimental = defu(nuxt.options.experimental || {}, {
154
233
  typedPages: true
155
234
  });
@@ -219,12 +298,17 @@ function prepareMergeConfigs({ nuxt, options }) {
219
298
  }
220
299
  }
221
300
  });
301
+ const detectedComponents = await detectUsedComponents(
302
+ [resolve("./runtime/components"), resolve("./runtime/composables")],
303
+ "U",
304
+ resolve("./runtime/components")
305
+ );
222
306
  nuxt.options.ui = defu(nuxt.options.ui || {}, {
223
307
  colorMode: true,
224
308
  fonts: true,
225
309
  mdc: true,
226
310
  experimental: {
227
- componentDetection: true
311
+ componentDetection: [...detectedComponents || []]
228
312
  }
229
313
  });
230
314
  nuxt.options.colorMode = defu(nuxt.options.colorMode || {}, {
@@ -347,8 +431,8 @@ const formPanelAsideSection = {
347
431
  const formPanelSection = {
348
432
  slots: {
349
433
  root: "",
350
- title: "text-base text-pretty font-semibold text-highlighted mb-2",
351
- description: "text-[15px] text-pretty text-muted mt-1",
434
+ title: "text-base text-pretty font-semibold text-highlighted",
435
+ description: "text-[15px] text-pretty text-muted mb-2",
352
436
  body: "relative rounded-lg bg-elevated/50 ring ring-default grid gap-x-8 gap-y-4 p-4 sm:p-6"
353
437
  }
354
438
  };
@@ -455,85 +539,6 @@ const themeProse = {
455
539
  uploraImage: uploraImage
456
540
  };
457
541
 
458
- async function buildComponentDependencyGraph(componentDir, componentPattern) {
459
- const dependencyGraph = /* @__PURE__ */ new Map();
460
- const componentFiles = globSync(["**/*.vue"], {
461
- cwd: componentDir,
462
- absolute: true
463
- });
464
- for (const componentFile of componentFiles) {
465
- try {
466
- const content = await readFile(componentFile, "utf-8");
467
- const componentName = pascalCase(componentFile.split("/").pop().replace(".vue", ""));
468
- const dependencies = /* @__PURE__ */ new Set();
469
- const matches = content.matchAll(componentPattern);
470
- for (const match of matches) {
471
- const depName = match[1] || match[2];
472
- if (depName && depName !== componentName) {
473
- dependencies.add(depName);
474
- }
475
- }
476
- dependencyGraph.set(componentName, dependencies);
477
- } catch {
478
- }
479
- }
480
- return dependencyGraph;
481
- }
482
- function resolveComponentDependencies(component, dependencyGraph, resolved = /* @__PURE__ */ new Set()) {
483
- if (resolved.has(component)) {
484
- return resolved;
485
- }
486
- resolved.add(component);
487
- const dependencies = dependencyGraph.get(component);
488
- if (dependencies) {
489
- for (const dep of dependencies) {
490
- resolveComponentDependencies(dep, dependencyGraph, resolved);
491
- }
492
- }
493
- return resolved;
494
- }
495
- async function detectUsedComponents(dirs, prefix, componentDir, includeComponents) {
496
- const detectedComponents = /* @__PURE__ */ new Set();
497
- if (includeComponents && includeComponents.length > 0) {
498
- for (const component of includeComponents) {
499
- detectedComponents.add(component);
500
- }
501
- }
502
- const componentPattern = new RegExp(`<(?:Lazy)?${prefix}([A-Z][a-zA-Z]+)|\\b(?:Lazy)?${prefix}([A-Z][a-zA-Z]+)\\b`, "g");
503
- for (const dir of dirs) {
504
- const appFiles = globSync(["**/*.{vue,ts,js,tsx,jsx}"], {
505
- cwd: dir,
506
- ignore: ["node_modules/**", ".nuxt/**", "dist/**"]
507
- });
508
- for (const file of appFiles) {
509
- try {
510
- const filePath = join(dir, file);
511
- const content = await readFile(filePath, "utf-8");
512
- const matches = content.matchAll(componentPattern);
513
- for (const match of matches) {
514
- const componentName = match[1] || match[2];
515
- if (componentName) {
516
- detectedComponents.add(componentName);
517
- }
518
- }
519
- } catch {
520
- }
521
- }
522
- }
523
- if (detectedComponents.size === 0) {
524
- return void 0;
525
- }
526
- const dependencyGraph = await buildComponentDependencyGraph(componentDir, componentPattern);
527
- const allComponents = /* @__PURE__ */ new Set();
528
- for (const component of detectedComponents) {
529
- const resolved = resolveComponentDependencies(component, dependencyGraph);
530
- for (const resolvedComponent of resolved) {
531
- allComponents.add(resolvedComponent);
532
- }
533
- }
534
- return allComponents;
535
- }
536
-
537
542
  function getAppTemplates({ options, resolve, nuxt }) {
538
543
  const templates = [];
539
544
  let previousDetectedComponents;
@@ -759,7 +764,7 @@ const module$1 = defineNuxtModule({
759
764
  defaults: defaultModuleOptions,
760
765
  async setup(options, nuxt) {
761
766
  const context = createContext(options, nuxt);
762
- prepareMergeConfigs(context);
767
+ await prepareMergeConfigs(context);
763
768
  prepareTemplates(context);
764
769
  prepareAutoImports(context);
765
770
  prepareServerRoutes(context);
@@ -27,4 +27,7 @@ declare const __VLS_export: import("vue").DefineComponent<InputSlugProps & {
27
27
  }> & Readonly<{
28
28
  "onUpdate:title"?: ((value: string | undefined) => any) | undefined;
29
29
  "onUpdate:slug"?: ((value: string | undefined) => any) | undefined;
30
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
+ }>, {
31
+ titleKey: string;
32
+ slugKey: string;
33
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -50,8 +50,8 @@ import { slugify } from "../utils/slugify";
50
50
  const props = defineProps({
51
51
  regenerate: { type: Boolean, required: false },
52
52
  label: { type: String, required: false },
53
- titleKey: { type: String, required: false },
54
- slugKey: { type: String, required: false },
53
+ titleKey: { type: String, required: false, default: "title" },
54
+ slugKey: { type: String, required: false, default: "slug" },
55
55
  inputProps: { type: Object, required: false },
56
56
  as: { type: null, required: false },
57
57
  class: { type: null, required: false },
@@ -27,4 +27,7 @@ declare const __VLS_export: import("vue").DefineComponent<InputSlugProps & {
27
27
  }> & Readonly<{
28
28
  "onUpdate:title"?: ((value: string | undefined) => any) | undefined;
29
29
  "onUpdate:slug"?: ((value: string | undefined) => any) | undefined;
30
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
+ }>, {
31
+ titleKey: string;
32
+ slugKey: string;
33
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -0,0 +1,13 @@
1
+ import type { ButtonProps } from '@nuxt/ui';
2
+ import type { RouteLocationRaw } from 'vue-router';
3
+ import type { UploraImageProps } from './UploraImage.vue';
4
+ export interface TablePreviewLinkProps {
5
+ to?: RouteLocationRaw;
6
+ target?: ButtonProps['target'];
7
+ label: string;
8
+ description?: string;
9
+ image?: Pick<UploraImageProps, 'image' | 'alt' | 'color' | 'lqip'>;
10
+ }
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
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div class="relative flex items-center gap-2">
3
+ <div class="overflow-hidden rounded-lg">
4
+ <UploraImage
5
+ v-if="image"
6
+ v-bind="image"
7
+ :sizes="[{ width: 32, height: 32, descriptor: '1x' }]"
8
+ :ui="{ picture: 'aspect-square' }"
9
+ />
10
+ </div>
11
+ <div>
12
+ <ULink
13
+ v-if="to"
14
+ :to="to"
15
+ :target="target"
16
+ class="text-primary font-medium"
17
+ >
18
+ {{ label }}
19
+ </ULink>
20
+ <p v-else class="font-medium text-highlighted text-sm">
21
+ {{ label }}
22
+ </p>
23
+ <p v-if="description" class="text-muted text-xs">
24
+ {{ description }}
25
+ </p>
26
+ </div>
27
+ </div>
28
+ </template>
29
+
30
+ <script setup>
31
+ import UploraImage from "./UploraImage.vue";
32
+ defineProps({
33
+ to: { type: null, required: false },
34
+ target: { type: [String, Object, null], required: false },
35
+ label: { type: String, required: true },
36
+ description: { type: String, required: false },
37
+ image: { type: Object, required: false }
38
+ });
39
+ </script>
@@ -0,0 +1,13 @@
1
+ import type { ButtonProps } from '@nuxt/ui';
2
+ import type { RouteLocationRaw } from 'vue-router';
3
+ import type { UploraImageProps } from './UploraImage.vue';
4
+ export interface TablePreviewLinkProps {
5
+ to?: RouteLocationRaw;
6
+ target?: ButtonProps['target'];
7
+ label: string;
8
+ description?: string;
9
+ image?: Pick<UploraImageProps, 'image' | 'alt' | 'color' | 'lqip'>;
10
+ }
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
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
@@ -1,6 +1,7 @@
1
1
  import type { ButtonProps, FormSchema, TableColumn, TableData, TableRow } from '@nuxt/ui';
2
2
  import type { RowData } from '@tanstack/table-core';
3
3
  import type { RouteLocationRaw } from 'vue-router';
4
+ import type { TablePreviewLinkProps } from '../components/TablePreviewLink.vue';
4
5
  import type { FiltersField } from '../types';
5
6
  declare module '@tanstack/table-core' {
6
7
  interface ColumnMeta<TData extends RowData, TValue> {
@@ -18,8 +19,8 @@ export type TableColumnCustom<T extends TableData, D = unknown> = TableColumn<T,
18
19
  to?: ((row: TableRow<T>) => RouteLocationRaw | string | undefined) | RouteLocationRaw | string | undefined;
19
20
  target?: ButtonProps['target'];
20
21
  emptyValue?: string;
21
- image?: string;
22
- description?: string;
22
+ image?: ((row: TableRow<T>) => TablePreviewLinkProps['image'] | undefined) | TablePreviewLinkProps['image'] | undefined;
23
+ description?: ((row: TableRow<T>) => string | undefined) | string | undefined;
23
24
  };
24
25
  export declare function useTableColumns<I extends Record<string, any>, T extends readonly TableColumnCustom<I>[] = readonly TableColumnCustom<I>[]>(columns: T): {
25
26
  columns: {
@@ -1,5 +1,5 @@
1
- import { UUser } from "#components";
2
1
  import { h } from "vue";
2
+ import TablePreviewLink from "../components/TablePreviewLink.vue";
3
3
  import { formatDate, formatDateTime, formatNumber } from "../utils/index.js";
4
4
  export function useTableFiltersFields(_schema, fields) {
5
5
  return { filtersFields: fields };
@@ -28,17 +28,16 @@ function transformColumn(column) {
28
28
  return void 0;
29
29
  }
30
30
  if (column.to) {
31
- return h(UUser, {
32
- to: typeof column.to === "function" ? column.to(row) : column.to,
33
- target: column.target,
34
- name: value.toString(),
35
- class: "inline-flex",
36
- ui: {
37
- name: "text-primary",
38
- avatar: "group-hover/user:scale-100"
39
- },
40
- avatar: column.image ? { src: column.image, size: "sm", alt: value.toString() } : void 0,
41
- description: column.description
31
+ const to = typeof column.to === "function" ? column.to(row) : column.to;
32
+ const target = column.target;
33
+ const description = typeof column.description === "function" ? column.description(row) : column.description;
34
+ const image = typeof column.image === "function" ? column.image(row) : column.image;
35
+ return h(TablePreviewLink, {
36
+ to,
37
+ target,
38
+ description,
39
+ label: value.toString(),
40
+ image
42
41
  });
43
42
  }
44
43
  return value;
@@ -0,0 +1,4 @@
1
+ export declare function createEnumItems<T extends Record<any, string>>(labels: T): Array<{
2
+ value: keyof T;
3
+ label: string;
4
+ }>;
@@ -0,0 +1,6 @@
1
+ export function createEnumItems(labels) {
2
+ return Object.entries(labels).map(([value, label]) => ({
3
+ value,
4
+ label
5
+ }));
6
+ }
@@ -1,6 +1,7 @@
1
1
  export * from './auth';
2
2
  export * from './avatar';
3
3
  export * from './date';
4
+ export * from './enums';
4
5
  export * from './formatters';
5
6
  export * from './logger';
6
7
  export * from './slugify';
@@ -1,6 +1,7 @@
1
1
  export * from "./auth.js";
2
2
  export * from "./avatar.js";
3
3
  export * from "./date.js";
4
+ export * from "./enums.js";
4
5
  export * from "./formatters.js";
5
6
  export * from "./logger.js";
6
7
  export * from "./slugify.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "2.1.0",
5
5
  "description": "Hywax CMS. ⚠️ This package is intended for internal use only.",
6
6
  "imports": {
7
7
  "#build/cms/*": "./.nuxt/cms/*.ts",
@@ -79,16 +79,16 @@
79
79
  "scule": "^1.3.0",
80
80
  "sortablejs": "^1.15.6",
81
81
  "tinyglobby": "^0.2.15",
82
- "zod": "^4.3.4"
82
+ "zod": "^4.3.5"
83
83
  },
84
84
  "devDependencies": {
85
- "@antfu/eslint-config": "^5.4.1",
85
+ "@antfu/eslint-config": "^6.7.3",
86
86
  "@commitlint/cli": "^20.3.0",
87
87
  "@commitlint/config-conventional": "^20.3.0",
88
88
  "@nuxt/devtools": "^3.1.1",
89
89
  "@nuxt/module-builder": "^1.0.2",
90
90
  "@nuxt/schema": "^4.2.2",
91
- "@nuxt/test-utils": "^3.21.0",
91
+ "@nuxt/test-utils": "^3.22.0",
92
92
  "@types/sortablejs": "^1.15.9",
93
93
  "@vue/test-utils": "^2.4.6",
94
94
  "changelogen-monorepo": "^0.5.0",