@zc-ui/nuxt 1.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.
- package/LICENSE +21 -0
- package/dist/module.cjs +121 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.mjs +98 -0
- package/dist/module.mjs.map +1 -0
- package/package.json +59 -0
- package/src/runtime/plugin.ts +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ZC UI Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory(require("@nuxt/kit"), require("@zc-ui/components")) : typeof define === "function" && define.amd ? define(["@nuxt/kit", "@zc-ui/components"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.ZcUINuxtModule = factory(global._nuxt_kit, global._zc_ui_components));
|
|
3
|
+
})(this, function(_nuxt_kit, _zc_ui_components) {
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var __create = Object.create;
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
+
key = keys[i];
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
+
value: mod,
|
|
23
|
+
enumerable: true
|
|
24
|
+
}) : target, mod));
|
|
25
|
+
//#endregion
|
|
26
|
+
_zc_ui_components = __toESM(_zc_ui_components, 1);
|
|
27
|
+
//#endregion
|
|
28
|
+
return (0, _nuxt_kit.defineNuxtModule)({
|
|
29
|
+
meta: {
|
|
30
|
+
name: "@zc-ui/nuxt",
|
|
31
|
+
configKey: "zcUi",
|
|
32
|
+
compatibility: { nuxt: "^3.0.0" }
|
|
33
|
+
},
|
|
34
|
+
defaults: {
|
|
35
|
+
components: true,
|
|
36
|
+
composables: true,
|
|
37
|
+
styles: true,
|
|
38
|
+
prefix: "Zc"
|
|
39
|
+
},
|
|
40
|
+
setup(options, nuxt) {
|
|
41
|
+
const { resolve } = (0, _nuxt_kit.createResolver)({}.url);
|
|
42
|
+
nuxt.options.build.transpile.push("@zc-ui/components");
|
|
43
|
+
nuxt.options.build.transpile.push("@zc-ui/utils");
|
|
44
|
+
nuxt.options.build.transpile.push("@zc-ui/hooks");
|
|
45
|
+
nuxt.options.build.transpile.push("@zc-ui/locale");
|
|
46
|
+
if (options.styles) nuxt.options.css.push("@zc-ui/theme/dist/index.css");
|
|
47
|
+
(0, _nuxt_kit.addPlugin)({
|
|
48
|
+
src: resolve("./runtime/plugin"),
|
|
49
|
+
mode: "client"
|
|
50
|
+
});
|
|
51
|
+
if (options.components) {
|
|
52
|
+
options.prefix;
|
|
53
|
+
for (const [exportName, component] of Object.entries(_zc_ui_components)) if (exportName.startsWith("Zc") && typeof component === "object" && component !== null && "install" in component) (0, _nuxt_kit.addComponent)({
|
|
54
|
+
name: exportName,
|
|
55
|
+
filePath: "@zc-ui/components",
|
|
56
|
+
export: exportName,
|
|
57
|
+
mode: "all"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (options.composables) {
|
|
61
|
+
for (const name of [
|
|
62
|
+
"useNamespace",
|
|
63
|
+
"useEventListener",
|
|
64
|
+
"useClickOutside",
|
|
65
|
+
"useSize",
|
|
66
|
+
"useZIndex",
|
|
67
|
+
"useId",
|
|
68
|
+
"useFocusTrap",
|
|
69
|
+
"useTimeoutFn",
|
|
70
|
+
"useIntervalFn",
|
|
71
|
+
"useDebounce",
|
|
72
|
+
"useDebounceFn",
|
|
73
|
+
"useThrottle",
|
|
74
|
+
"useThrottleFn",
|
|
75
|
+
"useScroll",
|
|
76
|
+
"useStorage",
|
|
77
|
+
"useLocalStorage",
|
|
78
|
+
"useSessionStorage",
|
|
79
|
+
"useMediaQuery",
|
|
80
|
+
"useBreakpoints",
|
|
81
|
+
"useClipboard",
|
|
82
|
+
"useResizeObserver",
|
|
83
|
+
"useIntersectionObserver",
|
|
84
|
+
"useDark",
|
|
85
|
+
"useColorMode",
|
|
86
|
+
"useToggle"
|
|
87
|
+
]) (0, _nuxt_kit.addImports)({
|
|
88
|
+
name,
|
|
89
|
+
from: "@zc-ui/hooks"
|
|
90
|
+
});
|
|
91
|
+
for (const name of [
|
|
92
|
+
"ZcMessage",
|
|
93
|
+
"ZcMessageCloseAll",
|
|
94
|
+
"ZcNotification",
|
|
95
|
+
"ZcNotificationCloseAll",
|
|
96
|
+
"ZcLoadingDirective",
|
|
97
|
+
"ZcLoadingService"
|
|
98
|
+
]) (0, _nuxt_kit.addImports)({
|
|
99
|
+
name,
|
|
100
|
+
from: "@zc-ui/components"
|
|
101
|
+
});
|
|
102
|
+
(0, _nuxt_kit.addImports)({
|
|
103
|
+
name: "isClient",
|
|
104
|
+
from: "@zc-ui/utils"
|
|
105
|
+
});
|
|
106
|
+
(0, _nuxt_kit.addImports)({
|
|
107
|
+
name: "isServer",
|
|
108
|
+
from: "@zc-ui/utils"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
nuxt.options.runtimeConfig.public.zcUi = {
|
|
112
|
+
components: options.components,
|
|
113
|
+
composables: options.composables,
|
|
114
|
+
styles: options.styles,
|
|
115
|
+
prefix: options.prefix
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=module.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\r\n defineNuxtModule,\r\n addPlugin,\r\n createResolver,\r\n addImports,\r\n addComponent,\r\n} from '@nuxt/kit'\r\nimport type { Component } from '@zc-ui/components'\r\nimport * as ZcComponents from '@zc-ui/components'\r\n\r\n/**\r\n * Module options for `@zc-ui/nuxt`.\r\n */\r\nexport interface ModuleOptions {\r\n /**\r\n * Whether to globally register all ZC UI components.\r\n * When `true` (default), all components are auto-imported.\r\n * Set to `false` to manually import only what you need.\r\n *\r\n * @default true\r\n */\r\n components?: boolean\r\n\r\n /**\r\n * Whether to auto-import composables (useMessage, useNotification, useLoading, etc.)\r\n *\r\n * @default true\r\n */\r\n composables?: boolean\r\n\r\n /**\r\n * Whether to inject the default CSS theme.\r\n *\r\n * @default true\r\n */\r\n styles?: boolean\r\n\r\n /**\r\n * Component name prefix.\r\n *\r\n * @default 'Zc'\r\n */\r\n prefix?: string\r\n}\r\n\r\nexport default defineNuxtModule<ModuleOptions>({\r\n meta: {\r\n name: '@zc-ui/nuxt',\r\n configKey: 'zcUi',\r\n compatibility: {\r\n nuxt: '^3.0.0',\r\n },\r\n },\r\n defaults: {\r\n components: true,\r\n composables: true,\r\n styles: true,\r\n prefix: 'Zc',\r\n },\r\n setup(options, nuxt) {\r\n const { resolve } = createResolver(import.meta.url)\r\n\r\n // ---- 1. Transpile @zc-ui packages for SSR ----\r\n nuxt.options.build.transpile.push('@zc-ui/components')\r\n nuxt.options.build.transpile.push('@zc-ui/utils')\r\n nuxt.options.build.transpile.push('@zc-ui/hooks')\r\n nuxt.options.build.transpile.push('@zc-ui/locale')\r\n\r\n // ---- 2. Inject CSS theme ----\r\n if (options.styles) {\r\n nuxt.options.css.push('@zc-ui/theme/dist/index.css')\r\n }\r\n\r\n // ---- 3. Register a plugin for imperative APIs (message, notification, loading) ----\r\n // The plugin runs on client-side and provides app-level context.\r\n addPlugin({\r\n src: resolve('./runtime/plugin'),\r\n mode: 'client',\r\n })\r\n\r\n // ---- 4. Auto-register components ----\r\n if (options.components) {\r\n const prefix = options.prefix ?? 'Zc'\r\n for (const [exportName, component] of Object.entries(ZcComponents)) {\r\n // Skip non-component exports (types, functions, etc.)\r\n if (exportName.startsWith('Zc') && typeof component === 'object' && component !== null && 'install' in component) {\r\n addComponent({\r\n name: exportName,\r\n filePath: '@zc-ui/components',\r\n export: exportName,\r\n // Ensure SSR-friendly: components resolve their own environment\r\n mode: 'all',\r\n })\r\n }\r\n }\r\n\r\n // Also register the imperative API components\r\n void prefix\r\n }\r\n\r\n // ---- 5. Auto-import composables ----\r\n if (options.composables) {\r\n // Hooks from @zc-ui/hooks\r\n const hookComposables = [\r\n 'useNamespace',\r\n 'useEventListener',\r\n 'useClickOutside',\r\n 'useSize',\r\n 'useZIndex',\r\n 'useId',\r\n 'useFocusTrap',\r\n 'useTimeoutFn',\r\n 'useIntervalFn',\r\n 'useDebounce',\r\n 'useDebounceFn',\r\n 'useThrottle',\r\n 'useThrottleFn',\r\n 'useScroll',\r\n 'useStorage',\r\n 'useLocalStorage',\r\n 'useSessionStorage',\r\n 'useMediaQuery',\r\n 'useBreakpoints',\r\n 'useClipboard',\r\n 'useResizeObserver',\r\n 'useIntersectionObserver',\r\n 'useDark',\r\n 'useColorMode',\r\n 'useToggle',\r\n ]\r\n\r\n for (const name of hookComposables) {\r\n addImports({\r\n name,\r\n from: '@zc-ui/hooks',\r\n })\r\n }\r\n\r\n // Imperative APIs from @zc-ui/components\r\n const apiComposables = [\r\n 'ZcMessage',\r\n 'ZcMessageCloseAll',\r\n 'ZcNotification',\r\n 'ZcNotificationCloseAll',\r\n 'ZcLoadingDirective',\r\n 'ZcLoadingService',\r\n ]\r\n\r\n for (const name of apiComposables) {\r\n addImports({\r\n name,\r\n from: '@zc-ui/components',\r\n })\r\n }\r\n\r\n // SSR utilities from @zc-ui/utils\r\n addImports({\r\n name: 'isClient',\r\n from: '@zc-ui/utils',\r\n })\r\n addImports({\r\n name: 'isServer',\r\n from: '@zc-ui/utils',\r\n })\r\n }\r\n\r\n // Provide runtime config\r\n nuxt.options.runtimeConfig.public.zcUi = {\r\n components: options.components,\r\n composables: options.composables,\r\n styles: options.styles,\r\n prefix: options.prefix,\r\n }\r\n },\r\n})\r\n\r\nexport type { ModuleOptions }\r\n// Re-export types for consumers\r\nexport type { Component }\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;SA6CA,GAAA,UAAA,kBAA+C;EAC7C,MAAM;GACJ,MAAM;GACN,WAAW;GACX,eAAe,EACb,MAAM,SACR;EACF;EACA,UAAU;GACR,YAAY;GACZ,aAAa;GACb,QAAQ;GACR,QAAQ;EACV;EACA,MAAM,SAAS,MAAM;GACnB,MAAM,EAAE,aAAA,GAAA,UAAA,gBAAA,CAAA,EAAuC,GAAG;GAGlD,KAAK,QAAQ,MAAM,UAAU,KAAK,mBAAmB;GACrD,KAAK,QAAQ,MAAM,UAAU,KAAK,cAAc;GAChD,KAAK,QAAQ,MAAM,UAAU,KAAK,cAAc;GAChD,KAAK,QAAQ,MAAM,UAAU,KAAK,eAAe;GAGjD,IAAI,QAAQ,QACV,KAAK,QAAQ,IAAI,KAAK,6BAA6B;GAKrD,CAAA,GAAA,UAAA,WAAU;IACR,KAAK,QAAQ,kBAAkB;IAC/B,MAAM;GACR,CAAC;GAGD,IAAI,QAAQ,YAAY;IACP,QAAQ;IACvB,KAAK,MAAM,CAAC,YAAY,cAAc,OAAO,QAAQ,iBAAY,GAE/D,IAAI,WAAW,WAAW,IAAI,KAAK,OAAO,cAAc,YAAY,cAAc,QAAQ,aAAa,WACrG,CAAA,GAAA,UAAA,cAAa;KACX,MAAM;KACN,UAAU;KACV,QAAQ;KAER,MAAM;IACR,CAAC;GAMP;GAGA,IAAI,QAAQ,aAAa;IA8BvB,KAAK,MAAM,QAAQ;KA3BjB;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;IAGiB,GACjB,CAAA,GAAA,UAAA,YAAW;KACT;KACA,MAAM;IACR,CAAC;IAaH,KAAK,MAAM,QAAQ;KARjB;KACA;KACA;KACA;KACA;KACA;IAGiB,GACjB,CAAA,GAAA,UAAA,YAAW;KACT;KACA,MAAM;IACR,CAAC;IAIH,CAAA,GAAA,UAAA,YAAW;KACT,MAAM;KACN,MAAM;IACR,CAAC;IACD,CAAA,GAAA,UAAA,YAAW;KACT,MAAM;KACN,MAAM;IACR,CAAC;GACH;GAGA,KAAK,QAAQ,cAAc,OAAO,OAAO;IACvC,YAAY,QAAQ;IACpB,aAAa,QAAQ;IACrB,QAAQ,QAAQ;IAChB,QAAQ,QAAQ;GAClB;EACF;CACF"}
|
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { addComponent, addImports, addPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
|
|
2
|
+
import * as ZcComponents from "@zc-ui/components";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
var src_default = defineNuxtModule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "@zc-ui/nuxt",
|
|
7
|
+
configKey: "zcUi",
|
|
8
|
+
compatibility: { nuxt: "^3.0.0" }
|
|
9
|
+
},
|
|
10
|
+
defaults: {
|
|
11
|
+
components: true,
|
|
12
|
+
composables: true,
|
|
13
|
+
styles: true,
|
|
14
|
+
prefix: "Zc"
|
|
15
|
+
},
|
|
16
|
+
setup(options, nuxt) {
|
|
17
|
+
const { resolve } = createResolver(import.meta.url);
|
|
18
|
+
nuxt.options.build.transpile.push("@zc-ui/components");
|
|
19
|
+
nuxt.options.build.transpile.push("@zc-ui/utils");
|
|
20
|
+
nuxt.options.build.transpile.push("@zc-ui/hooks");
|
|
21
|
+
nuxt.options.build.transpile.push("@zc-ui/locale");
|
|
22
|
+
if (options.styles) nuxt.options.css.push("@zc-ui/theme/dist/index.css");
|
|
23
|
+
addPlugin({
|
|
24
|
+
src: resolve("./runtime/plugin"),
|
|
25
|
+
mode: "client"
|
|
26
|
+
});
|
|
27
|
+
if (options.components) {
|
|
28
|
+
options.prefix;
|
|
29
|
+
for (const [exportName, component] of Object.entries(ZcComponents)) if (exportName.startsWith("Zc") && typeof component === "object" && component !== null && "install" in component) addComponent({
|
|
30
|
+
name: exportName,
|
|
31
|
+
filePath: "@zc-ui/components",
|
|
32
|
+
export: exportName,
|
|
33
|
+
mode: "all"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (options.composables) {
|
|
37
|
+
for (const name of [
|
|
38
|
+
"useNamespace",
|
|
39
|
+
"useEventListener",
|
|
40
|
+
"useClickOutside",
|
|
41
|
+
"useSize",
|
|
42
|
+
"useZIndex",
|
|
43
|
+
"useId",
|
|
44
|
+
"useFocusTrap",
|
|
45
|
+
"useTimeoutFn",
|
|
46
|
+
"useIntervalFn",
|
|
47
|
+
"useDebounce",
|
|
48
|
+
"useDebounceFn",
|
|
49
|
+
"useThrottle",
|
|
50
|
+
"useThrottleFn",
|
|
51
|
+
"useScroll",
|
|
52
|
+
"useStorage",
|
|
53
|
+
"useLocalStorage",
|
|
54
|
+
"useSessionStorage",
|
|
55
|
+
"useMediaQuery",
|
|
56
|
+
"useBreakpoints",
|
|
57
|
+
"useClipboard",
|
|
58
|
+
"useResizeObserver",
|
|
59
|
+
"useIntersectionObserver",
|
|
60
|
+
"useDark",
|
|
61
|
+
"useColorMode",
|
|
62
|
+
"useToggle"
|
|
63
|
+
]) addImports({
|
|
64
|
+
name,
|
|
65
|
+
from: "@zc-ui/hooks"
|
|
66
|
+
});
|
|
67
|
+
for (const name of [
|
|
68
|
+
"ZcMessage",
|
|
69
|
+
"ZcMessageCloseAll",
|
|
70
|
+
"ZcNotification",
|
|
71
|
+
"ZcNotificationCloseAll",
|
|
72
|
+
"ZcLoadingDirective",
|
|
73
|
+
"ZcLoadingService"
|
|
74
|
+
]) addImports({
|
|
75
|
+
name,
|
|
76
|
+
from: "@zc-ui/components"
|
|
77
|
+
});
|
|
78
|
+
addImports({
|
|
79
|
+
name: "isClient",
|
|
80
|
+
from: "@zc-ui/utils"
|
|
81
|
+
});
|
|
82
|
+
addImports({
|
|
83
|
+
name: "isServer",
|
|
84
|
+
from: "@zc-ui/utils"
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
nuxt.options.runtimeConfig.public.zcUi = {
|
|
88
|
+
components: options.components,
|
|
89
|
+
composables: options.composables,
|
|
90
|
+
styles: options.styles,
|
|
91
|
+
prefix: options.prefix
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
//#endregion
|
|
96
|
+
export { src_default as default };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=module.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\r\n defineNuxtModule,\r\n addPlugin,\r\n createResolver,\r\n addImports,\r\n addComponent,\r\n} from '@nuxt/kit'\r\nimport type { Component } from '@zc-ui/components'\r\nimport * as ZcComponents from '@zc-ui/components'\r\n\r\n/**\r\n * Module options for `@zc-ui/nuxt`.\r\n */\r\nexport interface ModuleOptions {\r\n /**\r\n * Whether to globally register all ZC UI components.\r\n * When `true` (default), all components are auto-imported.\r\n * Set to `false` to manually import only what you need.\r\n *\r\n * @default true\r\n */\r\n components?: boolean\r\n\r\n /**\r\n * Whether to auto-import composables (useMessage, useNotification, useLoading, etc.)\r\n *\r\n * @default true\r\n */\r\n composables?: boolean\r\n\r\n /**\r\n * Whether to inject the default CSS theme.\r\n *\r\n * @default true\r\n */\r\n styles?: boolean\r\n\r\n /**\r\n * Component name prefix.\r\n *\r\n * @default 'Zc'\r\n */\r\n prefix?: string\r\n}\r\n\r\nexport default defineNuxtModule<ModuleOptions>({\r\n meta: {\r\n name: '@zc-ui/nuxt',\r\n configKey: 'zcUi',\r\n compatibility: {\r\n nuxt: '^3.0.0',\r\n },\r\n },\r\n defaults: {\r\n components: true,\r\n composables: true,\r\n styles: true,\r\n prefix: 'Zc',\r\n },\r\n setup(options, nuxt) {\r\n const { resolve } = createResolver(import.meta.url)\r\n\r\n // ---- 1. Transpile @zc-ui packages for SSR ----\r\n nuxt.options.build.transpile.push('@zc-ui/components')\r\n nuxt.options.build.transpile.push('@zc-ui/utils')\r\n nuxt.options.build.transpile.push('@zc-ui/hooks')\r\n nuxt.options.build.transpile.push('@zc-ui/locale')\r\n\r\n // ---- 2. Inject CSS theme ----\r\n if (options.styles) {\r\n nuxt.options.css.push('@zc-ui/theme/dist/index.css')\r\n }\r\n\r\n // ---- 3. Register a plugin for imperative APIs (message, notification, loading) ----\r\n // The plugin runs on client-side and provides app-level context.\r\n addPlugin({\r\n src: resolve('./runtime/plugin'),\r\n mode: 'client',\r\n })\r\n\r\n // ---- 4. Auto-register components ----\r\n if (options.components) {\r\n const prefix = options.prefix ?? 'Zc'\r\n for (const [exportName, component] of Object.entries(ZcComponents)) {\r\n // Skip non-component exports (types, functions, etc.)\r\n if (exportName.startsWith('Zc') && typeof component === 'object' && component !== null && 'install' in component) {\r\n addComponent({\r\n name: exportName,\r\n filePath: '@zc-ui/components',\r\n export: exportName,\r\n // Ensure SSR-friendly: components resolve their own environment\r\n mode: 'all',\r\n })\r\n }\r\n }\r\n\r\n // Also register the imperative API components\r\n void prefix\r\n }\r\n\r\n // ---- 5. Auto-import composables ----\r\n if (options.composables) {\r\n // Hooks from @zc-ui/hooks\r\n const hookComposables = [\r\n 'useNamespace',\r\n 'useEventListener',\r\n 'useClickOutside',\r\n 'useSize',\r\n 'useZIndex',\r\n 'useId',\r\n 'useFocusTrap',\r\n 'useTimeoutFn',\r\n 'useIntervalFn',\r\n 'useDebounce',\r\n 'useDebounceFn',\r\n 'useThrottle',\r\n 'useThrottleFn',\r\n 'useScroll',\r\n 'useStorage',\r\n 'useLocalStorage',\r\n 'useSessionStorage',\r\n 'useMediaQuery',\r\n 'useBreakpoints',\r\n 'useClipboard',\r\n 'useResizeObserver',\r\n 'useIntersectionObserver',\r\n 'useDark',\r\n 'useColorMode',\r\n 'useToggle',\r\n ]\r\n\r\n for (const name of hookComposables) {\r\n addImports({\r\n name,\r\n from: '@zc-ui/hooks',\r\n })\r\n }\r\n\r\n // Imperative APIs from @zc-ui/components\r\n const apiComposables = [\r\n 'ZcMessage',\r\n 'ZcMessageCloseAll',\r\n 'ZcNotification',\r\n 'ZcNotificationCloseAll',\r\n 'ZcLoadingDirective',\r\n 'ZcLoadingService',\r\n ]\r\n\r\n for (const name of apiComposables) {\r\n addImports({\r\n name,\r\n from: '@zc-ui/components',\r\n })\r\n }\r\n\r\n // SSR utilities from @zc-ui/utils\r\n addImports({\r\n name: 'isClient',\r\n from: '@zc-ui/utils',\r\n })\r\n addImports({\r\n name: 'isServer',\r\n from: '@zc-ui/utils',\r\n })\r\n }\r\n\r\n // Provide runtime config\r\n nuxt.options.runtimeConfig.public.zcUi = {\r\n components: options.components,\r\n composables: options.composables,\r\n styles: options.styles,\r\n prefix: options.prefix,\r\n }\r\n },\r\n})\r\n\r\nexport type { ModuleOptions }\r\n// Re-export types for consumers\r\nexport type { Component }\r\n"],"mappings":";;;AA6CA,IAAA,cAAe,iBAAgC;CAC7C,MAAM;EACJ,MAAM;EACN,WAAW;EACX,eAAe,EACb,MAAM,SACR;CACF;CACA,UAAU;EACR,YAAY;EACZ,aAAa;EACb,QAAQ;EACR,QAAQ;CACV;CACA,MAAM,SAAS,MAAM;EACnB,MAAM,EAAE,YAAY,eAAe,OAAO,KAAK,GAAG;EAGlD,KAAK,QAAQ,MAAM,UAAU,KAAK,mBAAmB;EACrD,KAAK,QAAQ,MAAM,UAAU,KAAK,cAAc;EAChD,KAAK,QAAQ,MAAM,UAAU,KAAK,cAAc;EAChD,KAAK,QAAQ,MAAM,UAAU,KAAK,eAAe;EAGjD,IAAI,QAAQ,QACV,KAAK,QAAQ,IAAI,KAAK,6BAA6B;EAKrD,UAAU;GACR,KAAK,QAAQ,kBAAkB;GAC/B,MAAM;EACR,CAAC;EAGD,IAAI,QAAQ,YAAY;GACP,QAAQ;GACvB,KAAK,MAAM,CAAC,YAAY,cAAc,OAAO,QAAQ,YAAY,GAE/D,IAAI,WAAW,WAAW,IAAI,KAAK,OAAO,cAAc,YAAY,cAAc,QAAQ,aAAa,WACrG,aAAa;IACX,MAAM;IACN,UAAU;IACV,QAAQ;IAER,MAAM;GACR,CAAC;EAMP;EAGA,IAAI,QAAQ,aAAa;GA8BvB,KAAK,MAAM,QAAQ;IA3BjB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GAGiB,GACjB,WAAW;IACT;IACA,MAAM;GACR,CAAC;GAaH,KAAK,MAAM,QAAQ;IARjB;IACA;IACA;IACA;IACA;IACA;GAGiB,GACjB,WAAW;IACT;IACA,MAAM;GACR,CAAC;GAIH,WAAW;IACT,MAAM;IACN,MAAM;GACR,CAAC;GACD,WAAW;IACT,MAAM;IACN,MAAM;GACR,CAAC;EACH;EAGA,KAAK,QAAQ,cAAc,OAAO,OAAO;GACvC,YAAY,QAAQ;GACpB,aAAa,QAAQ;GACrB,QAAQ,QAAQ;GAChB,QAAQ,QAAQ;EAClB;CACF;AACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zc-ui/nuxt",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Nuxt 3 module for ZC UI — auto-imports components, composables, and the default theme.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "ZC UI Team",
|
|
7
|
+
"homepage": "https://zc-ui.github.io/zc-ui",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/zc-ui/zc-ui.git",
|
|
11
|
+
"directory": "packages/nuxt-module"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/zc-ui/zc-ui/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"nuxt",
|
|
18
|
+
"nuxt3",
|
|
19
|
+
"nuxt-module",
|
|
20
|
+
"vue",
|
|
21
|
+
"vue3",
|
|
22
|
+
"ui",
|
|
23
|
+
"zc-ui"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/module.cjs",
|
|
27
|
+
"module": "./dist/module.mjs",
|
|
28
|
+
"types": "./dist/types/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/types/index.d.ts",
|
|
32
|
+
"import": "./dist/module.mjs",
|
|
33
|
+
"require": "./dist/module.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./runtime/*": "./src/runtime/*"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"src/runtime"
|
|
40
|
+
],
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"registry": "https://registry.npmjs.org"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@nuxt/kit": "^3.10.0",
|
|
48
|
+
"@zc-ui/components": "1.0.0",
|
|
49
|
+
"@zc-ui/utils": "1.0.0",
|
|
50
|
+
"@zc-ui/theme": "1.0.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"nuxt": "^3.0.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "vite build",
|
|
57
|
+
"typecheck": "vue-tsc --noEmit -p tsconfig.json"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from '#app'
|
|
2
|
+
import {
|
|
3
|
+
ZcMessage,
|
|
4
|
+
ZcMessageCloseAll,
|
|
5
|
+
ZcNotification,
|
|
6
|
+
ZcNotificationCloseAll,
|
|
7
|
+
ZcLoadingService,
|
|
8
|
+
ZcLoadingDirective,
|
|
9
|
+
} from '@zc-ui/components'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Client-side Nuxt plugin that registers ZC UI's imperative APIs as
|
|
13
|
+
* app-level provides. This ensures message/notification/loading are
|
|
14
|
+
* available in any component via `useNuxtApp()`.
|
|
15
|
+
*
|
|
16
|
+
* This plugin only runs on the client (`mode: 'client'`) to avoid
|
|
17
|
+
* SSR-side DOM access.
|
|
18
|
+
*/
|
|
19
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
20
|
+
// Provide imperative APIs
|
|
21
|
+
nuxtApp.provide('zcMessage', ZcMessage)
|
|
22
|
+
nuxtApp.provide('zcMessageCloseAll', ZcMessageCloseAll)
|
|
23
|
+
nuxtApp.provide('zcNotification', ZcNotification)
|
|
24
|
+
nuxtApp.provide('zcNotificationCloseAll', ZcNotificationCloseAll)
|
|
25
|
+
nuxtApp.provide('zcLoading', ZcLoadingService)
|
|
26
|
+
|
|
27
|
+
// Register v-loading directive globally
|
|
28
|
+
nuxtApp.vueApp.directive('loading', ZcLoadingDirective)
|
|
29
|
+
})
|