@zc-ui/resolver 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/index.cjs +1 -0
- package/dist/index.mjs +199 -0
- package/dist/types/component-map.d.ts +24 -0
- package/dist/types/component-map.d.ts.map +1 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/resolver.d.ts +69 -0
- package/dist/types/resolver.d.ts.map +1 -0
- package/dist/types/types.d.ts +89 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +48 -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/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={ZcButton:`button`,ZcIcon:`icon`,ZcRow:`row`,ZcCol:`col`,ZcContainer:`container`,ZcHeader:`container`,ZcAside:`container`,ZcMain:`container`,ZcFooter:`container`,ZcSpace:`space`,ZcGrid:`grid`,ZcGridItem:`grid`,ZcInput:`input`,ZcSwitch:`switch`,ZcCheckbox:`checkbox`,ZcCheckboxGroup:`checkbox`,ZcRadio:`radio`,ZcRadioGroup:`radio`,ZcSelect:`select`,ZcForm:`form`,ZcFormItem:`form`,ZcDatePicker:`date-picker`,ZcTag:`tag`,ZcBadge:`badge`,ZcAvatar:`avatar`,ZcEmpty:`empty`,ZcSkeleton:`skeleton`,ZcSkeletonItem:`skeleton`,ZcTable:`table`,ZcImage:`image`,ZcTree:`tree`,ZcTreeNode:`tree`,ZcDescriptions:`descriptions`,ZcDescriptionsItem:`descriptions`,ZcStatistic:`statistic`,ZcTimeline:`timeline`,ZcTimelineItem:`timeline`,ZcList:`list`,ZcListItem:`list`,ZcCarousel:`carousel`,ZcCarouselItem:`carousel`,ZcTooltip:`tooltip`,ZcDialog:`dialog`,ZcPagination:`pagination`,ZcMessage:`message`,ZcNotification:`notification`,ZcLoading:`loading`,ZcMenu:`menu`,ZcMenuItem:`menu`,ZcSubmenu:`menu`,ZcTabs:`tabs`,ZcTabPane:`tabs`,ZcBreadcrumb:`breadcrumb`,ZcBreadcrumbItem:`breadcrumb`,ZcDropdown:`dropdown`,ZcDropdownMenu:`dropdown`,ZcDropdownItem:`dropdown`,ZcAnchor:`anchor`,ZcAnchorLink:`anchor`,ZcBacktop:`backtop`,ZcAffix:`affix`,ZcCard:`card`,ZcDivider:`divider`,ZcCollapse:`collapse`,ZcCollapseItem:`collapse`,ZcScrollbar:`scrollbar`,ZcAlert:`alert`,ZcDrawer:`drawer`,ZcProgress:`progress`,ZcSteps:`steps`,ZcStep:`steps`,ZcPopconfirm:`popconfirm`,ZcResult:`result`,ZcWatermark:`watermark`,ZcAutoComplete:`auto-complete`,ZcInputNumber:`input-number`,ZcColorPicker:`color-picker`,ZcRate:`rate`,ZcSlider:`slider`,ZcTimePicker:`time-picker`,ZcUpload:`upload`,ZcCascader:`cascader`,ZcTransfer:`transfer`,ZcMention:`mention`,ZcTreeSelect:`tree-select`,ZcSegmented:`segmented`,ZcTour:`tour`,ZcPopover:`popover`,ZcCountdown:`countdown`,ZcQrCode:`qr-code`},t={Container:[`Header`,`Aside`,`Main`,`Footer`],Form:[`FormItem`],Checkbox:[`CheckboxGroup`],Radio:[`RadioGroup`],Grid:[`GridItem`],Skeleton:[`SkeletonItem`],Tree:[`TreeNode`],Descriptions:[`DescriptionsItem`],Timeline:[`TimelineItem`],List:[`ListItem`],Carousel:[`CarouselItem`],Menu:[`MenuItem`,`Submenu`],Tabs:[`TabPane`],Breadcrumb:[`BreadcrumbItem`],Dropdown:[`DropdownMenu`,`DropdownItem`],Anchor:[`AnchorLink`],Collapse:[`CollapseItem`],Steps:[`Step`]},n={ZcMessage:{from:`@zc-ui/components`,sideEffects:[`@zc-ui/components/styles`]},ZcMessageCloseAll:{from:`@zc-ui/components`,sideEffects:[`@zc-ui/components/styles`]},ZcNotification:{from:`@zc-ui/components`,sideEffects:[`@zc-ui/components/styles`]},ZcNotificationCloseAll:{from:`@zc-ui/components`,sideEffects:[`@zc-ui/components/styles`]},ZcLoadingDirective:{from:`@zc-ui/components`,sideEffects:[`@zc-ui/components/styles`]},ZcLoadingService:{from:`@zc-ui/components`,sideEffects:[`@zc-ui/components/styles`]}};function r(e={}){return{importStyle:`full`,ssr:!1,packageName:`@zc-ui/components`,stylePath:`@zc-ui/components/styles`,exclude:[],prefix:`Zc`,...e}}function i(e,t){if(t.importStyle!==!1)return t.importStyle===`full`?[t.stylePath]:[`${t.stylePath}/${e}.css`]}function a(t){var n;return(n=e[t])==null?null:n}function o(e={}){let t=r(e);return{type:`component`,resolve:e=>{if(!e.startsWith(t.prefix)||t.exclude.includes(e)||t.include&&!t.include.includes(e))return null;let r=t.prefix===`Zc`?e:`Zc`+e.slice(t.prefix.length);if(n[r]){let e=n[r];return{name:r,from:e.from,sideEffects:t.importStyle===!1?void 0:e.sideEffects}}let o=a(r);if(o===null)return null;let s=i(o,t);return{name:r,from:t.packageName,sideEffects:s}}}}function s(e,t={}){return o(t).resolve(e)}function c(e={}){return o({...e,ssr:!0})}exports.ZcUiResolver=o,exports.ZcUiResolverSSR=c,exports.componentMap=e,exports.functionMap=n,exports.parentChildMap=t,exports.resolveZcComponent=s;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
//#region src/component-map.ts
|
|
2
|
+
var e = {
|
|
3
|
+
ZcButton: "button",
|
|
4
|
+
ZcIcon: "icon",
|
|
5
|
+
ZcRow: "row",
|
|
6
|
+
ZcCol: "col",
|
|
7
|
+
ZcContainer: "container",
|
|
8
|
+
ZcHeader: "container",
|
|
9
|
+
ZcAside: "container",
|
|
10
|
+
ZcMain: "container",
|
|
11
|
+
ZcFooter: "container",
|
|
12
|
+
ZcSpace: "space",
|
|
13
|
+
ZcGrid: "grid",
|
|
14
|
+
ZcGridItem: "grid",
|
|
15
|
+
ZcInput: "input",
|
|
16
|
+
ZcSwitch: "switch",
|
|
17
|
+
ZcCheckbox: "checkbox",
|
|
18
|
+
ZcCheckboxGroup: "checkbox",
|
|
19
|
+
ZcRadio: "radio",
|
|
20
|
+
ZcRadioGroup: "radio",
|
|
21
|
+
ZcSelect: "select",
|
|
22
|
+
ZcForm: "form",
|
|
23
|
+
ZcFormItem: "form",
|
|
24
|
+
ZcDatePicker: "date-picker",
|
|
25
|
+
ZcTag: "tag",
|
|
26
|
+
ZcBadge: "badge",
|
|
27
|
+
ZcAvatar: "avatar",
|
|
28
|
+
ZcEmpty: "empty",
|
|
29
|
+
ZcSkeleton: "skeleton",
|
|
30
|
+
ZcSkeletonItem: "skeleton",
|
|
31
|
+
ZcTable: "table",
|
|
32
|
+
ZcImage: "image",
|
|
33
|
+
ZcTree: "tree",
|
|
34
|
+
ZcTreeNode: "tree",
|
|
35
|
+
ZcDescriptions: "descriptions",
|
|
36
|
+
ZcDescriptionsItem: "descriptions",
|
|
37
|
+
ZcStatistic: "statistic",
|
|
38
|
+
ZcTimeline: "timeline",
|
|
39
|
+
ZcTimelineItem: "timeline",
|
|
40
|
+
ZcList: "list",
|
|
41
|
+
ZcListItem: "list",
|
|
42
|
+
ZcCarousel: "carousel",
|
|
43
|
+
ZcCarouselItem: "carousel",
|
|
44
|
+
ZcTooltip: "tooltip",
|
|
45
|
+
ZcDialog: "dialog",
|
|
46
|
+
ZcPagination: "pagination",
|
|
47
|
+
ZcMessage: "message",
|
|
48
|
+
ZcNotification: "notification",
|
|
49
|
+
ZcLoading: "loading",
|
|
50
|
+
ZcMenu: "menu",
|
|
51
|
+
ZcMenuItem: "menu",
|
|
52
|
+
ZcSubmenu: "menu",
|
|
53
|
+
ZcTabs: "tabs",
|
|
54
|
+
ZcTabPane: "tabs",
|
|
55
|
+
ZcBreadcrumb: "breadcrumb",
|
|
56
|
+
ZcBreadcrumbItem: "breadcrumb",
|
|
57
|
+
ZcDropdown: "dropdown",
|
|
58
|
+
ZcDropdownMenu: "dropdown",
|
|
59
|
+
ZcDropdownItem: "dropdown",
|
|
60
|
+
ZcAnchor: "anchor",
|
|
61
|
+
ZcAnchorLink: "anchor",
|
|
62
|
+
ZcBacktop: "backtop",
|
|
63
|
+
ZcAffix: "affix",
|
|
64
|
+
ZcCard: "card",
|
|
65
|
+
ZcDivider: "divider",
|
|
66
|
+
ZcCollapse: "collapse",
|
|
67
|
+
ZcCollapseItem: "collapse",
|
|
68
|
+
ZcScrollbar: "scrollbar",
|
|
69
|
+
ZcAlert: "alert",
|
|
70
|
+
ZcDrawer: "drawer",
|
|
71
|
+
ZcProgress: "progress",
|
|
72
|
+
ZcSteps: "steps",
|
|
73
|
+
ZcStep: "steps",
|
|
74
|
+
ZcPopconfirm: "popconfirm",
|
|
75
|
+
ZcResult: "result",
|
|
76
|
+
ZcWatermark: "watermark",
|
|
77
|
+
ZcAutoComplete: "auto-complete",
|
|
78
|
+
ZcInputNumber: "input-number",
|
|
79
|
+
ZcColorPicker: "color-picker",
|
|
80
|
+
ZcRate: "rate",
|
|
81
|
+
ZcSlider: "slider",
|
|
82
|
+
ZcTimePicker: "time-picker",
|
|
83
|
+
ZcUpload: "upload",
|
|
84
|
+
ZcCascader: "cascader",
|
|
85
|
+
ZcTransfer: "transfer",
|
|
86
|
+
ZcMention: "mention",
|
|
87
|
+
ZcTreeSelect: "tree-select",
|
|
88
|
+
ZcSegmented: "segmented",
|
|
89
|
+
ZcTour: "tour",
|
|
90
|
+
ZcPopover: "popover",
|
|
91
|
+
ZcCountdown: "countdown",
|
|
92
|
+
ZcQrCode: "qr-code"
|
|
93
|
+
}, t = {
|
|
94
|
+
Container: [
|
|
95
|
+
"Header",
|
|
96
|
+
"Aside",
|
|
97
|
+
"Main",
|
|
98
|
+
"Footer"
|
|
99
|
+
],
|
|
100
|
+
Form: ["FormItem"],
|
|
101
|
+
Checkbox: ["CheckboxGroup"],
|
|
102
|
+
Radio: ["RadioGroup"],
|
|
103
|
+
Grid: ["GridItem"],
|
|
104
|
+
Skeleton: ["SkeletonItem"],
|
|
105
|
+
Tree: ["TreeNode"],
|
|
106
|
+
Descriptions: ["DescriptionsItem"],
|
|
107
|
+
Timeline: ["TimelineItem"],
|
|
108
|
+
List: ["ListItem"],
|
|
109
|
+
Carousel: ["CarouselItem"],
|
|
110
|
+
Menu: ["MenuItem", "Submenu"],
|
|
111
|
+
Tabs: ["TabPane"],
|
|
112
|
+
Breadcrumb: ["BreadcrumbItem"],
|
|
113
|
+
Dropdown: ["DropdownMenu", "DropdownItem"],
|
|
114
|
+
Anchor: ["AnchorLink"],
|
|
115
|
+
Collapse: ["CollapseItem"],
|
|
116
|
+
Steps: ["Step"]
|
|
117
|
+
}, n = {
|
|
118
|
+
ZcMessage: {
|
|
119
|
+
from: "@zc-ui/components",
|
|
120
|
+
sideEffects: ["@zc-ui/components/styles"]
|
|
121
|
+
},
|
|
122
|
+
ZcMessageCloseAll: {
|
|
123
|
+
from: "@zc-ui/components",
|
|
124
|
+
sideEffects: ["@zc-ui/components/styles"]
|
|
125
|
+
},
|
|
126
|
+
ZcNotification: {
|
|
127
|
+
from: "@zc-ui/components",
|
|
128
|
+
sideEffects: ["@zc-ui/components/styles"]
|
|
129
|
+
},
|
|
130
|
+
ZcNotificationCloseAll: {
|
|
131
|
+
from: "@zc-ui/components",
|
|
132
|
+
sideEffects: ["@zc-ui/components/styles"]
|
|
133
|
+
},
|
|
134
|
+
ZcLoadingDirective: {
|
|
135
|
+
from: "@zc-ui/components",
|
|
136
|
+
sideEffects: ["@zc-ui/components/styles"]
|
|
137
|
+
},
|
|
138
|
+
ZcLoadingService: {
|
|
139
|
+
from: "@zc-ui/components",
|
|
140
|
+
sideEffects: ["@zc-ui/components/styles"]
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/resolver.ts
|
|
145
|
+
function r(e = {}) {
|
|
146
|
+
return {
|
|
147
|
+
importStyle: "full",
|
|
148
|
+
ssr: !1,
|
|
149
|
+
packageName: "@zc-ui/components",
|
|
150
|
+
stylePath: "@zc-ui/components/styles",
|
|
151
|
+
exclude: [],
|
|
152
|
+
prefix: "Zc",
|
|
153
|
+
...e
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function i(e, t) {
|
|
157
|
+
if (t.importStyle !== !1) return t.importStyle === "full" ? [t.stylePath] : [`${t.stylePath}/${e}.css`];
|
|
158
|
+
}
|
|
159
|
+
function a(t) {
|
|
160
|
+
var n;
|
|
161
|
+
return (n = e[t]) == null ? null : n;
|
|
162
|
+
}
|
|
163
|
+
function o(e = {}) {
|
|
164
|
+
let t = r(e);
|
|
165
|
+
return {
|
|
166
|
+
type: "component",
|
|
167
|
+
resolve: (e) => {
|
|
168
|
+
if (!e.startsWith(t.prefix) || t.exclude.includes(e) || t.include && !t.include.includes(e)) return null;
|
|
169
|
+
let r = t.prefix === "Zc" ? e : "Zc" + e.slice(t.prefix.length);
|
|
170
|
+
if (n[r]) {
|
|
171
|
+
let e = n[r];
|
|
172
|
+
return {
|
|
173
|
+
name: r,
|
|
174
|
+
from: e.from,
|
|
175
|
+
sideEffects: t.importStyle === !1 ? void 0 : e.sideEffects
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
let o = a(r);
|
|
179
|
+
if (o === null) return null;
|
|
180
|
+
let s = i(o, t);
|
|
181
|
+
return {
|
|
182
|
+
name: r,
|
|
183
|
+
from: t.packageName,
|
|
184
|
+
sideEffects: s
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function s(e, t = {}) {
|
|
190
|
+
return o(t).resolve(e);
|
|
191
|
+
}
|
|
192
|
+
function c(e = {}) {
|
|
193
|
+
return o({
|
|
194
|
+
...e,
|
|
195
|
+
ssr: !0
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { o as ZcUiResolver, c as ZcUiResolverSSR, e as componentMap, n as functionMap, t as parentChildMap, s as resolveZcComponent };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component name to directory mapping.
|
|
3
|
+
*
|
|
4
|
+
* Keys are PascalCase export names (e.g. `ZcButton`).
|
|
5
|
+
* Values are the kebab-case directory names used in the package source.
|
|
6
|
+
*
|
|
7
|
+
* This is auto-generated from `packages/components/src/index.ts`.
|
|
8
|
+
* When a new component is added, add its mapping here.
|
|
9
|
+
*/
|
|
10
|
+
export declare const componentMap: Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Components that share a directory with a parent component.
|
|
13
|
+
* These use the same CSS and source directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare const parentChildMap: Record<string, string[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Functional API exports (not components, but useful with unplugin-auto-import).
|
|
18
|
+
* These are imported from sub-paths within the components package.
|
|
19
|
+
*/
|
|
20
|
+
export declare const functionMap: Record<string, {
|
|
21
|
+
from: string;
|
|
22
|
+
sideEffects?: string[];
|
|
23
|
+
}>;
|
|
24
|
+
//# sourceMappingURL=component-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-map.d.ts","sourceRoot":"","sources":["../../src/component-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA0H/C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAmBnD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAC9B,MAAM,EACN;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CA0BzC,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zc-ui/resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolver for `unplugin-vue-components` and `unplugin-auto-import`.
|
|
5
|
+
*
|
|
6
|
+
* Enables automatic on-demand importing of ZC UI components.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // vite.config.ts
|
|
11
|
+
* import { defineConfig } from 'vite'
|
|
12
|
+
* import Components from 'unplugin-vue-components/vite'
|
|
13
|
+
* import { ZcUiResolver } from '@zc-ui/resolver'
|
|
14
|
+
*
|
|
15
|
+
* export default defineConfig({
|
|
16
|
+
* plugins: [
|
|
17
|
+
* Components({
|
|
18
|
+
* resolvers: [ZcUiResolver()],
|
|
19
|
+
* }),
|
|
20
|
+
* ],
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @packageDocumentation
|
|
25
|
+
*/
|
|
26
|
+
export { ZcUiResolver, ZcUiResolverSSR, resolveZcComponent } from './resolver';
|
|
27
|
+
export { componentMap, functionMap, parentChildMap } from './component-map';
|
|
28
|
+
export type { ZcUiResolverOptions, ComponentResolver, ComponentResolverResult, ResolvedComponent, } from './types';
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC3E,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ZcUiResolverOptions, ResolvedComponent, ComponentResolver } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* ZC UI Resolver for `unplugin-vue-components`.
|
|
4
|
+
*
|
|
5
|
+
* Automatically resolves `ZcXxx` components used in `<template>` to
|
|
6
|
+
* on-demand imports from `@zc-ui/components`, including optional CSS.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // vite.config.ts
|
|
11
|
+
* import Components from 'unplugin-vue-components/vite'
|
|
12
|
+
* import { ZcUiResolver } from '@zc-ui/resolver'
|
|
13
|
+
*
|
|
14
|
+
* export default {
|
|
15
|
+
* plugins: [
|
|
16
|
+
* Components({
|
|
17
|
+
* resolvers: [ZcUiResolver()],
|
|
18
|
+
* }),
|
|
19
|
+
* ],
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example SSR mode
|
|
24
|
+
* ```ts
|
|
25
|
+
* Components({
|
|
26
|
+
* resolvers: [ZcUiResolver({ ssr: true })],
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Per-component CSS
|
|
31
|
+
* ```ts
|
|
32
|
+
* Components({
|
|
33
|
+
* resolvers: [ZcUiResolver({ importStyle: 'component' })],
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function ZcUiResolver(options?: ZcUiResolverOptions): ComponentResolver;
|
|
38
|
+
/**
|
|
39
|
+
* Standalone resolve function for manual use or testing.
|
|
40
|
+
*
|
|
41
|
+
* Returns the resolved component info without wrapping in a
|
|
42
|
+
* `ComponentResolver` object.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { resolveZcComponent } from '@zc-ui/resolver'
|
|
47
|
+
*
|
|
48
|
+
* const result = resolveZcComponent('ZcButton')
|
|
49
|
+
* // { name: 'ZcButton', from: '@zc-ui/components', sideEffects: ['@zc-ui/components/styles'] }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveZcComponent(name: string, options?: ZcUiResolverOptions): ResolvedComponent | null | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* SSR-compatible resolver.
|
|
55
|
+
*
|
|
56
|
+
* Shortcut for `ZcUiResolver({ ssr: true })`.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import Components from 'unplugin-vue-components/vite'
|
|
61
|
+
* import { ZcUiResolverSSR } from '@zc-ui/resolver'
|
|
62
|
+
*
|
|
63
|
+
* Components({
|
|
64
|
+
* resolvers: [ZcUiResolverSSR()],
|
|
65
|
+
* })
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function ZcUiResolverSSR(options?: Omit<ZcUiResolverOptions, 'ssr'>): ComponentResolver;
|
|
69
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAkDhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,YAAY,CAC1B,OAAO,GAAE,mBAAwB,GAChC,iBAAiB,CAsDnB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,mBAAwB,GAChC,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAGtC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,OAAO,GAAE,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAM,GAC7C,iBAAiB,CAEnB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the ZC UI resolver.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Options for the ZC UI component resolver.
|
|
6
|
+
*/
|
|
7
|
+
export interface ZcUiResolverOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Whether to import CSS styles automatically.
|
|
10
|
+
*
|
|
11
|
+
* - `'full'` — Import the entire stylesheet (recommended for most projects).
|
|
12
|
+
* - `'component'` — Import per-component CSS (requires per-component CSS build).
|
|
13
|
+
* - `false` — Don't import any CSS.
|
|
14
|
+
*
|
|
15
|
+
* @default 'full'
|
|
16
|
+
*/
|
|
17
|
+
importStyle?: 'full' | 'component' | false;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the project uses SSR (Server-Side Rendering).
|
|
20
|
+
*
|
|
21
|
+
* When enabled, the resolver uses CJS-compatible import paths.
|
|
22
|
+
*
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
ssr?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Custom package name for ZC UI components.
|
|
28
|
+
*
|
|
29
|
+
* Useful if the package is published under a different name or
|
|
30
|
+
* you're using a fork.
|
|
31
|
+
*
|
|
32
|
+
* @default '@zc-ui/components'
|
|
33
|
+
*/
|
|
34
|
+
packageName?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Custom CSS import path prefix.
|
|
37
|
+
*
|
|
38
|
+
* When `importStyle` is `'full'`, CSS is imported from
|
|
39
|
+
* `${stylePath}`. When `importStyle` is `'component'`, CSS is imported from
|
|
40
|
+
* `${stylePath}/${componentDir}.css`.
|
|
41
|
+
*
|
|
42
|
+
* @default '@zc-ui/components/styles'
|
|
43
|
+
*/
|
|
44
|
+
stylePath?: string;
|
|
45
|
+
/**
|
|
46
|
+
* List of component names to exclude from auto-import.
|
|
47
|
+
*
|
|
48
|
+
* Example: `['ZcMessage', 'ZcNotification']`
|
|
49
|
+
*
|
|
50
|
+
* @default []
|
|
51
|
+
*/
|
|
52
|
+
exclude?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Only resolve these component names.
|
|
55
|
+
* If set, only listed components will be auto-imported.
|
|
56
|
+
*
|
|
57
|
+
* @default undefined (resolve all)
|
|
58
|
+
*/
|
|
59
|
+
include?: string[];
|
|
60
|
+
/**
|
|
61
|
+
* Prefix for component names.
|
|
62
|
+
* Components in templates must start with this prefix to be resolved.
|
|
63
|
+
*
|
|
64
|
+
* @default 'Zc'
|
|
65
|
+
*/
|
|
66
|
+
prefix?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Return type of the resolver function.
|
|
70
|
+
* Compatible with `unplugin-vue-components` ComponentResolver interface.
|
|
71
|
+
*/
|
|
72
|
+
export interface ComponentResolverResult {
|
|
73
|
+
type: 'component';
|
|
74
|
+
resolve: (name: string) => ResolvedComponent | null | undefined;
|
|
75
|
+
}
|
|
76
|
+
export interface ResolvedComponent {
|
|
77
|
+
/** The export name to import */
|
|
78
|
+
name: string;
|
|
79
|
+
/** The module path to import from */
|
|
80
|
+
from: string;
|
|
81
|
+
/** CSS side effects to import */
|
|
82
|
+
sideEffects?: string[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A component resolver compatible with `unplugin-vue-components`.
|
|
86
|
+
* Returns `{ type, resolve }` object.
|
|
87
|
+
*/
|
|
88
|
+
export type ComponentResolver = ComponentResolverResult;
|
|
89
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,KAAK,CAAA;IAE1C;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IAEb;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAElB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAElB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,WAAW,CAAA;IACjB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAA;CAChE;AAED,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zc-ui/resolver",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ZC UI resolver for unplugin-vue-components and unplugin-auto-import",
|
|
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/resolver"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/zc-ui/zc-ui/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vue",
|
|
18
|
+
"vue3",
|
|
19
|
+
"ui",
|
|
20
|
+
"resolver",
|
|
21
|
+
"unplugin",
|
|
22
|
+
"auto-import",
|
|
23
|
+
"zc-ui"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"module": "./dist/index.mjs",
|
|
28
|
+
"types": "./dist/types/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/types/index.d.ts",
|
|
32
|
+
"import": "./dist/index.mjs",
|
|
33
|
+
"require": "./dist/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"sideEffects": false,
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"registry": "https://registry.npmjs.org"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "vite build",
|
|
46
|
+
"typecheck": "vue-tsc --noEmit -p tsconfig.json"
|
|
47
|
+
}
|
|
48
|
+
}
|