@ciwergrp/nuxid 1.6.2 → 1.6.4

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 (32) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/route/route-query.d.ts +2 -1
  3. package/dist/runtime/route/route-query.js +11 -7
  4. package/docs/.docs/built-in-modules/element-plus.md +28 -0
  5. package/docs/.docs/built-in-modules/index.md +15 -0
  6. package/docs/.docs/built-in-modules/lodash.md +14 -0
  7. package/docs/.docs/built-in-modules/nuxt-icon.md +31 -0
  8. package/docs/.docs/built-in-modules/sentry.md +13 -0
  9. package/docs/.docs/built-in-modules/vueuse.md +28 -0
  10. package/docs/.docs/composables/use-breadcrumbs.md +53 -0
  11. package/docs/.docs/composables/use-cursor-http.md +56 -0
  12. package/docs/.docs/composables/use-http.md +57 -0
  13. package/docs/.docs/composables/use-pinia.md +65 -0
  14. package/docs/.docs/composables/use-query-filters.md +88 -0
  15. package/docs/.docs/composables/use-route-query.md +39 -0
  16. package/docs/.docs/composables/use-title.md +48 -0
  17. package/docs/.docs/composables/use-version-updater.md +38 -0
  18. package/docs/.docs/configuration.md +164 -0
  19. package/docs/.docs/form-validation/create-validation-rules.md +130 -0
  20. package/docs/.docs/form-validation/quick-start.md +67 -0
  21. package/docs/.docs/form-validation/request-generator.md +38 -0
  22. package/docs/.docs/form-validation/rules.md +418 -0
  23. package/docs/.docs/forms/use-form.md +58 -0
  24. package/docs/.docs/helpers/array.md +169 -0
  25. package/docs/.docs/helpers/date.md +702 -0
  26. package/docs/.docs/helpers/index.md +34 -0
  27. package/docs/.docs/helpers/number.md +169 -0
  28. package/docs/.docs/helpers/object.md +85 -0
  29. package/docs/.docs/helpers/string.md +316 -0
  30. package/docs/.docs/index.md +17 -0
  31. package/docs/.docs/structure-directory.md +28 -0
  32. package/package.json +3 -1
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
3
  "configKey": "nuxid",
4
- "version": "1.6.2",
4
+ "version": "1.6.4",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,3 +1,4 @@
1
+ import type { LocationQueryRaw } from 'vue-router';
1
2
  export declare function useRouteQuery(): {
2
- URLRouteQuery: (query: any, route?: string) => Promise<void | import("vue-router").NavigationFailure | undefined>;
3
+ URLRouteQuery: (query: LocationQueryRaw, route?: string) => Promise<void | import("vue-router").NavigationFailure | undefined>;
3
4
  };
@@ -1,14 +1,18 @@
1
1
  import { useRoute, useRouter } from "vue-router";
2
2
  export function useRouteQuery() {
3
+ const currentRoute = useRoute();
4
+ const router = useRouter();
3
5
  const URLRouteQuery = (query, route) => {
4
- const $route = useRoute();
5
- const router = useRouter();
6
+ const mergedQuery = {
7
+ ...currentRoute.query,
8
+ ...query
9
+ };
10
+ const nextQuery = Object.fromEntries(
11
+ Object.entries(mergedQuery).filter(([, value]) => value !== void 0)
12
+ );
6
13
  return router.push({
7
- path: route,
8
- query: {
9
- ...$route.query,
10
- ...query
11
- }
14
+ path: route ?? currentRoute.path,
15
+ query: nextQuery
12
16
  });
13
17
  };
14
18
  return {
@@ -0,0 +1,28 @@
1
+ # @element-plus/nuxt
2
+
3
+ Nuxus can install and configure Element Plus via `elementPlus` options.
4
+
5
+ ## Enable
6
+
7
+ ```ts
8
+ export default defineNuxtConfig({
9
+ nuxid: {
10
+ elementPlus: true,
11
+ },
12
+ })
13
+ ```
14
+
15
+ ## Configure
16
+
17
+ ```ts
18
+ export default defineNuxtConfig({
19
+ nuxid: {
20
+ elementPlus: {
21
+ enabled: true,
22
+ config: {
23
+ // @element-plus/nuxt options
24
+ },
25
+ },
26
+ },
27
+ })
28
+ ```
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: Built-In Modules
3
+ ---
4
+
5
+ # Built-In Modules
6
+
7
+ These are Nuxt-only modules that Nuxus can configure or integrate with.
8
+
9
+ ## Modules
10
+
11
+ - [lodash](/built-in-modules/lodash)
12
+ - [@element-plus/nuxt](/built-in-modules/element-plus)
13
+ - [@nuxt/icon](/built-in-modules/nuxt-icon)
14
+ - [@vueuse/nuxt](/built-in-modules/vueuse)
15
+ - [@sentry/nuxt](/built-in-modules/sentry)
@@ -0,0 +1,14 @@
1
+ # lodash
2
+
3
+ Nuxus can auto-import lodash helpers when `lodash` is enabled.
4
+
5
+ ## Enable
6
+
7
+ ```ts
8
+ export default defineNuxtConfig({
9
+ nuxid: {
10
+ lodash: true,
11
+ },
12
+ })
13
+ ```
14
+
@@ -0,0 +1,31 @@
1
+ # @nuxt/icon
2
+
3
+ Nuxus can install and configure @nuxt/icon via the `icon` options.
4
+
5
+ ## Enable
6
+
7
+ ```ts
8
+ export default defineNuxtConfig({
9
+ nuxid: {
10
+ icon: true,
11
+ },
12
+ })
13
+ ```
14
+
15
+ ## Configure
16
+
17
+ ```ts
18
+ export default defineNuxtConfig({
19
+ nuxid: {
20
+ icon: {
21
+ enabled: true,
22
+ config: {
23
+ componentName: 'KIcon',
24
+ size: '1.25em',
25
+ class: 'align-middle inline-block text-current',
26
+ mode: 'svg',
27
+ },
28
+ },
29
+ },
30
+ })
31
+ ```
@@ -0,0 +1,13 @@
1
+ # @sentry/nuxt
2
+
3
+ Nuxus declares @sentry/nuxt as a module dependency. Configure it in your Nuxt config as needed.
4
+
5
+ ## Configure
6
+
7
+ ```ts
8
+ export default defineNuxtConfig({
9
+ sentry: {
10
+ // @sentry/nuxt options
11
+ },
12
+ })
13
+ ```
@@ -0,0 +1,28 @@
1
+ # @vueuse/nuxt
2
+
3
+ Nuxus integrates with VueUse and can manage auto-import exclusions.
4
+
5
+ ## Enable
6
+
7
+ ```ts
8
+ export default defineNuxtConfig({
9
+ nuxid: {
10
+ vueuse: true,
11
+ },
12
+ })
13
+ ```
14
+
15
+ ## Configure
16
+
17
+ ```ts
18
+ export default defineNuxtConfig({
19
+ nuxid: {
20
+ vueuse: {
21
+ enabled: true,
22
+ autoImports: true,
23
+ ssrHandlers: false,
24
+ exclude: [],
25
+ },
26
+ },
27
+ })
28
+ ```
@@ -0,0 +1,53 @@
1
+ # useBreadcrumbs
2
+
3
+ `useBreadcrumbs` stores and exposes breadcrumb state in Nuxt app state.
4
+
5
+ ## Signature
6
+
7
+ ```ts
8
+ const {
9
+ breadcrumbs,
10
+ activeBreadcrumb,
11
+ setBreadcrumbs,
12
+ } = useBreadcrumbs()
13
+ ```
14
+
15
+ ## Params
16
+
17
+ - None.
18
+
19
+ ## Types
20
+
21
+ ```ts
22
+ type BreadcrumbItem = {
23
+ name: string
24
+ path: string
25
+ }
26
+
27
+ type UseBreadcrumbsReturn = {
28
+ breadcrumbs: Readonly<Ref<BreadcrumbItem[]>>
29
+ activeBreadcrumb: ComputedRef<BreadcrumbItem | null>
30
+ setBreadcrumbs: (value: BreadcrumbItem[]) => void
31
+ }
32
+ ```
33
+
34
+ ## Returns
35
+
36
+ - `breadcrumbs`: readonly breadcrumb list.
37
+ - `activeBreadcrumb`: computed last breadcrumb item or `null`.
38
+ - `setBreadcrumbs(value)`: replaces breadcrumb list.
39
+
40
+ ## Example
41
+
42
+ ```ts
43
+ const { breadcrumbs, activeBreadcrumb, setBreadcrumbs } = useBreadcrumbs()
44
+
45
+ setBreadcrumbs([
46
+ { name: 'Home', path: '/' },
47
+ { name: 'Products', path: '/products' },
48
+ ])
49
+
50
+ console.log(breadcrumbs.value.length) // 2
51
+ console.log(activeBreadcrumb.value?.name) // Products
52
+ ```
53
+
@@ -0,0 +1,56 @@
1
+ # useCursorHttp
2
+
3
+ `useCursorHttp` wraps cursor-based APIs for infinite lists. It merges new pages, exposes `loadMore` and `refresh`, and can poll for new items.
4
+
5
+ ## Signature
6
+
7
+ ```ts
8
+ const result = await useCursorHttp(url, options?)
9
+ ```
10
+
11
+ ## Options
12
+
13
+ - `lazy` (boolean): skip the first fetch until `init()` is called.
14
+ - `immediate` (boolean): run the first fetch on creation. Default: `true`.
15
+ - `pollInterval` (number): poll interval in ms for new items.
16
+ - `fetcher` (function): custom fetcher. Defaults to Nuxt `$fetch`.
17
+ - `fetchOptions` (object): passed to `$fetch`, supports refs for reactive params.
18
+ - `meta` (object): response meta keys.
19
+ - `meta.cursorKey` (string): key for the next cursor. Default: `afterCursor`.
20
+ - `meta.hasMoreKey` (string): key for more data. Default: `hasMore`.
21
+ - `itemKey` (string): unique item id to dedupe polls. Default: `id`.
22
+ - `cursorParam` (string): query param for cursor. Default: `cursor`.
23
+
24
+ ## Returns
25
+
26
+ - `data` (ref): response data with merged pages.
27
+ - `loading` (readonly ref)
28
+ - `error` (readonly ref)
29
+ - `hasNextPage` (readonly ref)
30
+ - `isLoadMoreTriggered` (readonly ref)
31
+ - `loadMore()` (function)
32
+ - `refresh()` (function)
33
+ - `init()` (function)
34
+
35
+ ## Examples
36
+
37
+ Basic usage:
38
+
39
+ ```ts
40
+ const {
41
+ data,
42
+ loading,
43
+ hasNextPage,
44
+ loadMore,
45
+ } = await useCursorHttp('/api/articles')
46
+ ```
47
+
48
+ Custom cursor keys and polling:
49
+
50
+ ```ts
51
+ const result = await useCursorHttp('/api/articles', {
52
+ meta: { cursorKey: 'nextCursor', hasMoreKey: 'hasMore' },
53
+ cursorParam: 'after',
54
+ pollInterval: 10000,
55
+ })
56
+ ```
@@ -0,0 +1,57 @@
1
+ # useHttp
2
+
3
+ `useHttp` builds a reactive form object with submit helpers that use Nuxt `$fetch`. It normalizes strings and nested values, supports `FormData` when files are present, and tracks `processing`, `errors`, and `response`.
4
+
5
+ ## Signature
6
+
7
+ ```ts
8
+ const form = useHttp(initialData, formOptions)
9
+ ```
10
+
11
+ ## Options
12
+
13
+ - `alwaysFormData` (boolean): force `FormData` even when there are no files.
14
+ - `fetcher` (function): custom fetcher. Defaults to Nuxt `$fetch`.
15
+ - `fetchOptions` (object): shared options passed to `$fetch` (headers, onResponse, etc).
16
+
17
+ ## Returns
18
+
19
+ The returned object includes your initial fields plus:
20
+
21
+ - `submit(method, url, options?)`
22
+ - `post(url, options?)`
23
+ - `patch(url, options?)`
24
+ - `put(url, options?)`
25
+ - `delete(url, options?)`
26
+ - `processing` (boolean)
27
+ - `errors` (any)
28
+ - `response` (object | null)
29
+
30
+ ## Examples
31
+
32
+ Basic submit:
33
+
34
+ ```ts
35
+ const form = useHttp({ name: '', avatar: null })
36
+
37
+ await form.post('/api/users')
38
+ ```
39
+
40
+ Send multipart data and attach hooks:
41
+
42
+ ```ts
43
+ const form = useHttp(
44
+ { name: '', avatar: null, tags: [] },
45
+ {
46
+ alwaysFormData: true,
47
+ fetchOptions: {
48
+ onResponse({ response }) {
49
+ console.log('ok', response.ok)
50
+ },
51
+ },
52
+ },
53
+ )
54
+
55
+ await form.post('/api/users')
56
+ ```
57
+
@@ -0,0 +1,65 @@
1
+ # usePinia
2
+
3
+ `usePinia` returns the active Pinia instance from Nuxt. Use it when you need to pass the instance explicitly to a store or to work outside the standard auto-import context.
4
+
5
+ This composable is available when the `pinia` feature is enabled in `nuxid`.
6
+
7
+ ## Enable
8
+
9
+ ```ts
10
+ export default defineNuxtConfig({
11
+ nuxid: {
12
+ pinia: true,
13
+ },
14
+ })
15
+ ```
16
+
17
+ ## Configure
18
+
19
+ ```ts
20
+ export default defineNuxtConfig({
21
+ nuxid: {
22
+ pinia: {
23
+ enabled: true,
24
+ storesDirs: ['stores'],
25
+ },
26
+ },
27
+ })
28
+ ```
29
+
30
+ ## Signature
31
+
32
+ ```ts
33
+ const pinia = usePinia()
34
+ ```
35
+
36
+ ## Returns
37
+
38
+ - The Pinia instance injected by Nuxt.
39
+
40
+ ## Auto-imports
41
+
42
+ When enabled, Nuxus auto-imports common Pinia helpers:
43
+
44
+ - `defineStore`
45
+ - `definePiniaStore` (alias of `defineStore`)
46
+ - `acceptHMRUpdate`
47
+ - `storeToRefs`
48
+ - `usePinia`
49
+
50
+ ## Examples
51
+
52
+ Use with a store:
53
+
54
+ ```ts
55
+ const pinia = usePinia()
56
+ const userStore = useUserStore(pinia)
57
+ ```
58
+
59
+ Create a store with auto-imported helpers:
60
+
61
+ ```ts
62
+ const useUserStore = defineStore('user', {
63
+ state: () => ({ name: '' }),
64
+ })
65
+ ```
@@ -0,0 +1,88 @@
1
+ # useQueryFilters
2
+
3
+ `useQueryFilters` builds active filter chips from route query and provides helpers to apply, reset, and remove filters.
4
+
5
+ ## Signature
6
+
7
+ ```ts
8
+ const {
9
+ activeFilters,
10
+ applyFilters,
11
+ resetFilters,
12
+ handleFilterChange,
13
+ normalizeQueryValue,
14
+ } = useQueryFilters(definitions)
15
+ ```
16
+
17
+ ## Params
18
+
19
+ - `definitions: QueryFilterDefinition[]`
20
+
21
+ ## Types
22
+
23
+ ```ts
24
+ import type { LocationQuery, LocationQueryValue } from 'vue-router'
25
+
26
+ type ActiveQueryFilter = {
27
+ key: string
28
+ label: string
29
+ value: string
30
+ displayValue: string
31
+ }
32
+
33
+ type QueryFilterDefinition = {
34
+ key: string
35
+ label: string
36
+ clearQueryKeys: string[]
37
+ resolve: (query: LocationQuery) => { value: string; displayValue: string } | null
38
+ }
39
+ ```
40
+
41
+ ```ts
42
+ type FilterChangePayload = {
43
+ key: string
44
+ active: boolean
45
+ }
46
+
47
+ type UseQueryFiltersReturn = {
48
+ activeFilters: ComputedRef<ActiveQueryFilter[]>
49
+ applyFilters: (query: Record<string, any>, callback?: () => void | Promise<void>) => Promise<void>
50
+ resetFilters: (queryKeys: string[], callback?: () => void | Promise<void>) => Promise<void>
51
+ handleFilterChange: (payload: FilterChangePayload, callback?: () => void | Promise<void>) => Promise<void>
52
+ normalizeQueryValue: (value: LocationQueryValue | LocationQueryValue[] | undefined) => LocationQueryValue | undefined
53
+ }
54
+ ```
55
+
56
+ ## API
57
+
58
+ - `activeFilters`: computed active filters resolved from route query.
59
+ - `applyFilters(query, callback?)`: merges query and pushes route.
60
+ - `resetFilters(queryKeys, callback?)`: removes specified query keys.
61
+ - `handleFilterChange(payload, callback?)`: removes query keys defined in matching filter when `payload.active` is `false`.
62
+ - `normalizeQueryValue(value)`: returns first value for array query params.
63
+
64
+ ## Example
65
+
66
+ ```ts
67
+ const definitions = [
68
+ {
69
+ key: 'status',
70
+ label: 'Status',
71
+ clearQueryKeys: ['status'],
72
+ resolve: (query) => {
73
+ const value = query.status
74
+ if (!value || Array.isArray(value)) {
75
+ return null
76
+ }
77
+
78
+ return { value, displayValue: value }
79
+ },
80
+ },
81
+ ]
82
+
83
+ const { activeFilters, applyFilters, resetFilters } = useQueryFilters(definitions)
84
+
85
+ await applyFilters({ status: 'active' })
86
+ await resetFilters(['status'])
87
+ ```
88
+
@@ -0,0 +1,39 @@
1
+ # useRouteQuery
2
+
3
+ `useRouteQuery` is a small helper to push merged query params to the router.
4
+
5
+ ## Signature
6
+
7
+ ```ts
8
+ const { URLRouteQuery } = useRouteQuery()
9
+ ```
10
+
11
+ ## Params
12
+
13
+ - None.
14
+
15
+ ## Types
16
+
17
+ ```ts
18
+ type URLRouteQuery = (query: any, route?: string) => Promise<void>
19
+
20
+ type UseRouteQueryReturn = {
21
+ URLRouteQuery: URLRouteQuery
22
+ }
23
+ ```
24
+
25
+ ## API
26
+
27
+ - `URLRouteQuery(query, route?)`
28
+ - `query`: query values to merge with current route query.
29
+ - `route` (optional): target path. If omitted, current path is used.
30
+
31
+ ## Example
32
+
33
+ ```ts
34
+ const { URLRouteQuery } = useRouteQuery()
35
+
36
+ await URLRouteQuery({ page: 2, sort: 'desc' })
37
+ await URLRouteQuery({ category: 'books' }, '/products')
38
+ ```
39
+
@@ -0,0 +1,48 @@
1
+ # useTitle
2
+
3
+ `useTitle` manages the current document title and provides helpers to read, set, and reset it using `runtimeConfig.public.appTitle`.
4
+
5
+ ## Signature
6
+
7
+ ```ts
8
+ const {
9
+ title,
10
+ getTitle,
11
+ setTitle,
12
+ resetTitle,
13
+ } = useTitle()
14
+ ```
15
+
16
+ ## Params
17
+
18
+ - None.
19
+
20
+ ## Types
21
+
22
+ ```ts
23
+ type UseTitleReturn = {
24
+ title: Readonly<Ref<string>>
25
+ getTitle: () => string
26
+ setTitle: (value: string) => void
27
+ resetTitle: () => void
28
+ }
29
+ ```
30
+
31
+ ## Returns
32
+
33
+ - `title`: readonly reactive title value.
34
+ - `getTitle()`: returns the current title string.
35
+ - `setTitle(value)`: sets the title and updates `<head><title>`.
36
+ - `resetTitle()`: resets title to `runtimeConfig.public.appTitle` and updates `<head><title>`.
37
+
38
+ ## Example
39
+
40
+ ```ts
41
+ const { title, setTitle, resetTitle } = useTitle()
42
+
43
+ setTitle('Dashboard')
44
+ console.log(title.value) // Dashboard
45
+
46
+ resetTitle()
47
+ ```
48
+
@@ -0,0 +1,38 @@
1
+ # useVersionUpdater
2
+
3
+ `useVersionUpdater` exposes a reactive flag that turns `true` after Nuxt emits `app:manifest:update`.
4
+
5
+ ## Signature
6
+
7
+ ```ts
8
+ const { isNewVersionAvailable } = useVersionUpdater()
9
+ ```
10
+
11
+ ## Params
12
+
13
+ - None.
14
+
15
+ ## Types
16
+
17
+ ```ts
18
+ type UseVersionUpdaterReturn = {
19
+ isNewVersionAvailable: Readonly<Ref<boolean>>
20
+ }
21
+ ```
22
+
23
+ ## Returns
24
+
25
+ - `isNewVersionAvailable`: readonly ref, default `false`, becomes `true` once a new app manifest version is detected.
26
+
27
+ ## Example
28
+
29
+ ```ts
30
+ const { isNewVersionAvailable } = useVersionUpdater()
31
+
32
+ watch(isNewVersionAvailable, (available) => {
33
+ if (available) {
34
+ console.log('A new version is available')
35
+ }
36
+ })
37
+ ```
38
+