@zoobzio/nuxt 0.0.0-stage → 0.0.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.
@@ -0,0 +1,12 @@
1
+ import type { ToastVariant } from "@zoobzio/vue/types/components/toast";
2
+
3
+ /**
4
+ * A notification the app shell renders as a toast. `id` is assigned on
5
+ * push, so a consumer never supplies it.
6
+ */
7
+ export interface Notification {
8
+ id: string;
9
+ variant: ToastVariant;
10
+ title: string;
11
+ description?: string;
12
+ }
@@ -0,0 +1,18 @@
1
+ import type { AsyncDataOptions } from "#app";
2
+ import type { ErrorOptions } from "./error";
3
+ import type { HTTPCode } from "ltrl-http";
4
+
5
+ /**
6
+ * What `useRequest` and `useLazyRequest` take: Nuxt's async-data options,
7
+ * less `server` (the wrapper sets it), plus how a failure is reported: the
8
+ * status code and message of the error thrown, and its {@link ErrorOptions}.
9
+ */
10
+ export type RequestOptions<ResT, DataT> = Omit<
11
+ AsyncDataOptions<ResT, DataT>,
12
+ "server"
13
+ > & {
14
+ error?: {
15
+ status?: HTTPCode;
16
+ message?: string;
17
+ } & ErrorOptions;
18
+ };
@@ -0,0 +1,65 @@
1
+ import type { Bound } from "./actions";
2
+ import type { Hooks } from "./hooks";
3
+ import type {
4
+ ActionDescriptor,
5
+ Actions,
6
+ BulkAction,
7
+ Config,
8
+ Events,
9
+ RowAction,
10
+ Service,
11
+ State,
12
+ } from "@zoobzio/table";
13
+
14
+ /**
15
+ * A row action: its descriptor and its handler, under the config key.
16
+ */
17
+ export type TableAction<T> = Bound<ActionDescriptor, RowAction<T>["action"]>;
18
+
19
+ /**
20
+ * A bulk action over the selection: its descriptor and its handler, under
21
+ * the config key.
22
+ */
23
+ export type TableBulkAction = Bound<ActionDescriptor, BulkAction["action"]>;
24
+
25
+ /**
26
+ * The slice of the state container a table may start from: the paging,
27
+ * sort, selection, column order, and committed query the consumer chooses,
28
+ * never what a fetch fills in. It seeds the `useState` record, so it must
29
+ * survive Nuxt's payload (devalue carries the `Set`).
30
+ */
31
+ export type TableInitial<T> = Partial<
32
+ Pick<
33
+ State<T>,
34
+ | "page"
35
+ | "pageSize"
36
+ | "sortField"
37
+ | "sortDirection"
38
+ | "selected"
39
+ | "columnOrder"
40
+ | "entries"
41
+ >
42
+ >;
43
+
44
+ /**
45
+ * What `createTable` takes: the headless config with each action's handler
46
+ * joined to its descriptor, the fetch mechanism, and the initial state.
47
+ */
48
+ export type TableOptions<T> = Omit<Config<T>, "actions" | "bulkActions"> & {
49
+ fetch: Actions<T>["fetch"];
50
+ actions?: Record<string, TableAction<T>>;
51
+ bulkActions?: Record<string, TableBulkAction>;
52
+ initial?: TableInitial<T>;
53
+ };
54
+
55
+ /**
56
+ * The Nuxt hooks a table relays: `table:updated` and `table:filtered`,
57
+ * each carrying the service's payload with its scoping `id`.
58
+ */
59
+ export type TableHooks = Hooks<"table", Events<unknown>>;
60
+
61
+ /**
62
+ * The id-scoped composable `createTable` returns. Call it in setup; every
63
+ * call yields a service over the same shared container.
64
+ */
65
+ export type UseTable<T> = () => Service<T>;
@@ -0,0 +1,21 @@
1
+ import type { Bound } from "../types/actions";
2
+
3
+ import { map, rekey } from "objectively";
4
+
5
+ /**
6
+ * Splits bound actions into the halves the headless services take: the
7
+ * descriptor record for the config and the handler record for the wiring,
8
+ * both under the keys given. No record yields two empty ones.
9
+ */
10
+ export const split = <D extends object, F>(
11
+ bound: Record<string, Bound<D, F>> = {},
12
+ ): { descriptors: Record<string, D>; handlers: Record<string, F> } => ({
13
+ descriptors: rekey<Record<string, Bound<D, F>>, Record<string, D>>(
14
+ bound,
15
+ (key, value) => {
16
+ const { action: _, ...descriptor } = value;
17
+ return [key, descriptor];
18
+ },
19
+ ),
20
+ handlers: map(bound, ({ action }) => action),
21
+ });
@@ -0,0 +1,19 @@
1
+ import { keys } from "objectively";
2
+
3
+ /**
4
+ * Seeds a fresh state container: each defined field of `initial` replaces
5
+ * the container's default in place; an undefined field leaves the default.
6
+ * Returns the container it was given. `S` comes from the container alone,
7
+ * so a partial slice never narrows it.
8
+ */
9
+ export const seed = <S extends object>(
10
+ state: S,
11
+ initial: NoInfer<Partial<S>> = {},
12
+ ): S => {
13
+ for (const key of keys(initial)) {
14
+ const value = initial[key];
15
+ if (value === undefined) continue;
16
+ state[key] = value;
17
+ }
18
+ return state;
19
+ };
@@ -0,0 +1,146 @@
1
+ export const COMPONENTS = [
2
+ "accordion",
3
+ "autocomplete",
4
+ "avatar",
5
+ "breadcrumb",
6
+ "browser",
7
+ "browser-bulk-actions",
8
+ "browser-files",
9
+ "browser-folders",
10
+ "calendar",
11
+ "checkbox",
12
+ "command",
13
+ "date-filters",
14
+ "date-picker",
15
+ "date-range-picker",
16
+ "dialog",
17
+ "directory",
18
+ "fab",
19
+ "facets",
20
+ "form",
21
+ "form-field",
22
+ "hero",
23
+ "keywords",
24
+ "listbox",
25
+ "menu",
26
+ "multi-select",
27
+ "pagination",
28
+ "popover",
29
+ "radio",
30
+ "range-calendar",
31
+ "scroller",
32
+ "segmented-control",
33
+ "select",
34
+ "table",
35
+ "table-body",
36
+ "table-bulk-actions",
37
+ "table-columns",
38
+ "table-head",
39
+ "tabs",
40
+ "tags-input",
41
+ "toast",
42
+ "toaster",
43
+ "tooltip",
44
+ "tree",
45
+ ] as const;
46
+
47
+ export const DEFINITIONS = [
48
+ "accordion",
49
+ "autocomplete",
50
+ "avatar",
51
+ "breadcrumb",
52
+ "browser",
53
+ "calendar",
54
+ "checkbox",
55
+ "command",
56
+ "date-filters",
57
+ "date-picker",
58
+ "date-range-picker",
59
+ "dialog",
60
+ "directory",
61
+ "fab",
62
+ "facets",
63
+ "form",
64
+ "hero",
65
+ "keywords",
66
+ "listbox",
67
+ "menu",
68
+ "multi-select",
69
+ "pagination",
70
+ "popover",
71
+ "radio",
72
+ "range-calendar",
73
+ "scroller",
74
+ "segmented-control",
75
+ "select",
76
+ "table",
77
+ "tabs",
78
+ "tags-input",
79
+ "toast",
80
+ "toaster",
81
+ "tooltip",
82
+ "tree",
83
+ ] as const;
84
+
85
+ // The layer's own consumer surface, keyed by the `app/` subpath that
86
+ // exports it. `imports.scan` is off, so nothing is discovered: each name
87
+ // here is what a consumer may import from `#imports`, and nothing else.
88
+ // `utils/` is plumbing the factories use and is not registered.
89
+ export const LAYER = {
90
+ "composables/error": ["useAppError"],
91
+ "composables/hook": ["useHooks"],
92
+ "composables/log": ["useLogger"],
93
+ "composables/notification": ["useNotifications"],
94
+ "composables/request": ["useRequest", "useLazyRequest"],
95
+ "constants/error": [
96
+ "ERROR_DEFAULT_STATUS_CODE",
97
+ "ERROR_NOT_FOUND_STATUS_CODE",
98
+ ],
99
+ "constants/log": ["LOG_ROOT_NAME", "LOG_LEVELS"],
100
+ "factories/browser": ["createBrowser"],
101
+ "factories/form": ["createForm"],
102
+ "factories/table": ["createTable"],
103
+ "stores/browser": ["accessBrowser"],
104
+ "stores/form": ["accessForm"],
105
+ "stores/log": ["accessLogs"],
106
+ "stores/notification": ["accessNotifications"],
107
+ "stores/table": ["accessTable"],
108
+ } as const satisfies Record<string, readonly string[]>;
109
+
110
+ // Type-only exports, registered the same way so `import type { TableOptions }
111
+ // from "#imports"` resolves. They are re-exported from the virtual module
112
+ // only, never declared global, so the DOM `Notification` and lib
113
+ // `ErrorOptions` are untouched.
114
+ export const LAYER_TYPES = {
115
+ "types/actions": ["Bound"],
116
+ "types/browser": [
117
+ "BrowserAction",
118
+ "BrowserFolderAction",
119
+ "BrowserBulkAction",
120
+ "BrowserInitial",
121
+ "BrowserOptions",
122
+ "BrowserHooks",
123
+ "UseBrowser",
124
+ ],
125
+ "types/error": ["ErrorData", "ErrorOptions", "AppError"],
126
+ "types/form": ["FormInitial", "FormOptions", "FormHooks", "UseForm"],
127
+ "types/hook": [
128
+ "ScopedEvent",
129
+ "ScopedHookKey",
130
+ "HookListener",
131
+ "ErasedHookListener",
132
+ "HookListeners",
133
+ ],
134
+ "types/hooks": ["Hooks"],
135
+ "types/log": ["LogLevel", "LogLine", "LogEmit", "Logger"],
136
+ "types/notification": ["Notification"],
137
+ "types/request": ["RequestOptions"],
138
+ "types/table": [
139
+ "TableAction",
140
+ "TableBulkAction",
141
+ "TableInitial",
142
+ "TableOptions",
143
+ "TableHooks",
144
+ "UseTable",
145
+ ],
146
+ } as const satisfies Record<string, readonly string[]>;
@@ -0,0 +1,52 @@
1
+ import { createRequire } from "node:module";
2
+ import {
3
+ addComponent,
4
+ addImports,
5
+ createResolver,
6
+ defineNuxtModule,
7
+ } from "@nuxt/kit";
8
+
9
+ import { COMPONENTS, DEFINITIONS, LAYER, LAYER_TYPES } from "./constant";
10
+ import { pascal } from "./util";
11
+
12
+ export default defineNuxtModule({
13
+ meta: { name: "@zoobzio/nuxt/imports" },
14
+ setup() {
15
+ // @zoobzio/vue: components into #components, define* into #imports.
16
+ const require = createRequire(import.meta.url);
17
+ const resolve = (subpath: string): string =>
18
+ require.resolve(`@zoobzio/vue/${subpath}`);
19
+
20
+ for (const name of COMPONENTS) {
21
+ addComponent({
22
+ name: pascal(name),
23
+ filePath: resolve(`components/${name}.vue`),
24
+ export: "default",
25
+ });
26
+ }
27
+
28
+ addImports(
29
+ DEFINITIONS.map((name) => ({
30
+ name: `define${pascal(name)}`,
31
+ from: resolve(`definitions/${name}`),
32
+ })),
33
+ );
34
+
35
+ // The layer's own app/ files into #imports, values and types alike.
36
+ const resolver = createResolver(import.meta.url);
37
+ const app = (subpath: string): string =>
38
+ resolver.resolve("../../app", `${subpath}.ts`);
39
+
40
+ addImports(
41
+ Object.entries(LAYER).flatMap(([subpath, names]) =>
42
+ names.map((name) => ({ name, from: app(subpath) })),
43
+ ),
44
+ );
45
+
46
+ addImports(
47
+ Object.entries(LAYER_TYPES).flatMap(([subpath, names]) =>
48
+ names.map((name) => ({ name, from: app(subpath), type: true })),
49
+ ),
50
+ );
51
+ },
52
+ });
@@ -0,0 +1,2 @@
1
+ export const pascal = (kebab: string): string =>
2
+ kebab.replace(/(^|-)([a-z])/g, (_, __, c: string) => c.toUpperCase());
package/nuxt.config.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { defineNuxtConfig } from "nuxt/config";
3
+
4
+ export default defineNuxtConfig({
5
+ compatibilityDate: "2025-11-06",
6
+
7
+ imports: { autoImport: false, scan: false },
8
+
9
+ components: {
10
+ dirs: [],
11
+ transform: { exclude: [/./] },
12
+ },
13
+
14
+ css: [fileURLToPath(new URL("./app/assets/css/reset.css", import.meta.url))],
15
+
16
+ build: {
17
+ transpile: ["@zoobzio/vue"],
18
+ },
19
+
20
+ vite: {
21
+ optimizeDeps: { exclude: ["@zoobzio/nuxt", "@zoobzio/vue"] },
22
+ },
23
+ });
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "@zoobzio/nuxt",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.0",
4
+ "description": "Nuxt layer for the foundation design system: the Nuxt wiring over @zoobzio/vue and the headless services (useState stores, hook-bus factories, app shell).",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Alex Thorwaldson",
8
+ "email": "alex@zoobz.io",
9
+ "url": "https://zoobz.io"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/zoobzio/foundation.git",
14
+ "directory": "integrations/nuxt"
15
+ },
16
+ "files": [
17
+ "app",
18
+ "modules",
19
+ "nuxt.config.ts"
20
+ ],
21
+ "type": "module",
22
+ "main": "./nuxt.config.ts",
23
+ "exports": {
24
+ ".": "./nuxt.config.ts",
25
+ "./components/*": "./app/components/*.vue",
26
+ "./components/*.vue": "./app/components/*.vue",
27
+ "./composables/*": "./app/composables/*.ts",
28
+ "./constants/*": "./app/constants/*.ts",
29
+ "./definitions/*": "./app/definitions/*.ts",
30
+ "./factories/*": "./app/factories/*.ts",
31
+ "./plugins/*": "./app/plugins/*.ts",
32
+ "./services/*": "./app/services/*.ts",
33
+ "./stores/*": "./app/stores/*.ts",
34
+ "./types/*": "./app/types/*.ts",
35
+ "./utils/*": "./app/utils/*.ts",
36
+ "./package.json": "./package.json"
37
+ },
38
+ "dependencies": {
39
+ "@nuxt/kit": "^4.5.0",
40
+ "ltrl-http": "^0.0.20",
41
+ "objectively": "^0.3.0",
42
+ "reka-ui": "^2.6.0",
43
+ "@zoobzio/browser": "0.0.0",
44
+ "@zoobzio/form": "0.0.0",
45
+ "@zoobzio/table": "0.0.0",
46
+ "@zoobzio/vue": "0.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "@vitejs/plugin-vue": "^6.0.6",
50
+ "@vue/test-utils": "^2.4.8",
51
+ "happy-dom": "^20.9.0",
52
+ "nuxt": "^4.5.0",
53
+ "vue": "^3.5.24",
54
+ "vue-tsc": "^2.1.10",
55
+ "zod": "^3.23.0"
56
+ },
57
+ "scripts": {
58
+ "dev": "nuxi dev",
59
+ "build": "nuxi build",
60
+ "lint": "oxlint",
61
+ "typecheck": "nuxi typecheck",
62
+ "test": "vitest run --passWithNoTests"
63
+ }
6
64
  }