@mtn-ui/components 0.0.2 → 0.0.3
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/dist/index/index.js +900 -929
- package/dist/index/index.js.map +1 -1
- package/dist/resolver/index.js +35 -0
- package/dist/resolver/index.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function o(t) {
|
|
2
|
+
return t.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
|
3
|
+
}
|
|
4
|
+
function s() {
|
|
5
|
+
return {
|
|
6
|
+
type: "component",
|
|
7
|
+
resolve: (t) => {
|
|
8
|
+
if (t.startsWith("Mtn")) {
|
|
9
|
+
const e = t.slice(3), r = o(e);
|
|
10
|
+
return {
|
|
11
|
+
name: e,
|
|
12
|
+
// 导出名称(如 Button, ConfirmButton)
|
|
13
|
+
from: `@mtn-ui/components/${r}`
|
|
14
|
+
// 路径(如 button, confirm-button)
|
|
15
|
+
// 自动引入样式的逻辑(如果需要,可以取消注释)
|
|
16
|
+
// sideEffects: `@mtn-ui/components/${path}/style`,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const n = o(t);
|
|
20
|
+
return {
|
|
21
|
+
name: t,
|
|
22
|
+
// 导出名称(如 Button)
|
|
23
|
+
from: `@mtn-ui/components/${n}`
|
|
24
|
+
// 路径(如 button)
|
|
25
|
+
// sideEffects: `@mtn-ui/components/${path}/style`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const c = s();
|
|
31
|
+
export {
|
|
32
|
+
s as MtnUIResolver,
|
|
33
|
+
c as default
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/resolver.ts"],"sourcesContent":["import type { ComponentResolver } from 'unplugin-vue-components/types'\n\n/**\n * MTN UI Components Resolver\n * \n * 用于 unplugin-vue-components 的组件解析器\n * 当在模板中使用 <MtnButton /> 时,自动解析组件和样式路径\n * \n * @example\n * ```ts\n * // vite.config.ts\n * import Components from 'unplugin-vue-components/vite'\n * import { MtnUIResolver } from '@mtn-ui/components/resolver'\n * \n * export default defineConfig({\n * plugins: [\n * Components({\n * resolvers: [MtnUIResolver()]\n * })\n * ]\n * })\n * ```\n */\n/**\n * 将 PascalCase 转换为 kebab-case\n * @example\n * PascalCaseToKebabCase('ConfirmButton') => 'confirm-button'\n * PascalCaseToKebabCase('Button') => 'button'\n */\nfunction pascalCaseToKebabCase(str: string): string {\n return str\n .replace(/([A-Z])/g, '-$1') // 在大写字母前添加连字符\n .toLowerCase() // 转为小写\n .replace(/^-/, '') // 移除开头的连字符\n}\n\nexport function MtnUIResolver(): ComponentResolver {\n return {\n type: 'component',\n resolve: (name: string) => {\n // 支持的组件名格式:\n // - Button (PascalCase,直接使用)\n // - MtnButton (PascalCase,移除 Mtn 前缀)\n // - mtn-button (kebab-case,会被 unplugin-vue-components 转换为 MtnButton)\n \n // 如果组件名以 Mtn 开头,移除前缀\n if (name.startsWith('Mtn')) {\n const componentName = name.slice(3) // 移除 'Mtn' 前缀 (MtnButton -> Button)\n const path = pascalCaseToKebabCase(componentName) // 转为 kebab-case (ConfirmButton -> confirm-button)\n \n return {\n name: componentName, // 导出名称(如 Button, ConfirmButton)\n from: `@mtn-ui/components/${path}`, // 路径(如 button, confirm-button)\n // 自动引入样式的逻辑(如果需要,可以取消注释)\n // sideEffects: `@mtn-ui/components/${path}/style`,\n }\n }\n\n // 如果组件名直接是组件名(如 Button),转换为 kebab-case\n const path = pascalCaseToKebabCase(name)\n return {\n name: name, // 导出名称(如 Button)\n from: `@mtn-ui/components/${path}`, // 路径(如 button)\n // sideEffects: `@mtn-ui/components/${path}/style`,\n }\n },\n }\n}\n\n/**\n * 默认导出的 Resolver\n */\nexport default MtnUIResolver()\n"],"names":["pascalCaseToKebabCase","str","MtnUIResolver","name","componentName","path","resolver"],"mappings":"AA6BA,SAASA,EAAsBC,GAAqB;AAClD,SAAOA,EACJ,QAAQ,YAAY,KAAK,EACzB,cACA,QAAQ,MAAM,EAAE;AACrB;AAEO,SAASC,IAAmC;AACjD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,CAACC,MAAiB;AAOzB,UAAIA,EAAK,WAAW,KAAK,GAAG;AAC1B,cAAMC,IAAgBD,EAAK,MAAM,CAAC,GAC5BE,IAAOL,EAAsBI,CAAa;AAEhD,eAAO;AAAA,UACL,MAAMA;AAAA;AAAA,UACN,MAAM,sBAAsBC,CAAI;AAAA;AAAA;AAAA;AAAA,QAAA;AAAA,MAIpC;AAGA,YAAMA,IAAOL,EAAsBG,CAAI;AACvC,aAAO;AAAA,QACL,MAAAA;AAAA;AAAA,QACA,MAAM,sBAAsBE,CAAI;AAAA;AAAA;AAAA,MAAA;AAAA,IAGpC;AAAA,EAAA;AAEJ;AAKA,MAAAC,IAAeJ,EAAA;"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtn-ui/components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "MTN UI Components",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.js",
|
|
6
|
+
"main": "./dist/index/index.js",
|
|
7
|
+
"module": "./dist/index/index.js",
|
|
8
8
|
"types": "./dist/types/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"sideEffects": [
|
|
13
13
|
"**/*.css",
|
|
14
14
|
"**/*.scss",
|
|
15
|
-
"./dist/index.css",
|
|
15
|
+
"./dist/index/style.css",
|
|
16
16
|
"./dist/**/*.css"
|
|
17
17
|
],
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
|
-
"import": "./dist/index.js",
|
|
22
|
-
"default": "./dist/index.js"
|
|
21
|
+
"import": "./dist/index/index.js",
|
|
22
|
+
"default": "./dist/index/index.js"
|
|
23
23
|
},
|
|
24
24
|
"./style": {
|
|
25
|
-
"import": "./dist/index.css",
|
|
26
|
-
"default": "./dist/index.css"
|
|
25
|
+
"import": "./dist/index/style.css",
|
|
26
|
+
"default": "./dist/index/style.css"
|
|
27
27
|
},
|
|
28
28
|
"./button": {
|
|
29
29
|
"types": "./dist/types/button/index.d.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"./resolver": {
|
|
34
34
|
"types": "./dist/types/resolver.d.ts",
|
|
35
|
-
"import": "./dist/resolver.js",
|
|
36
|
-
"default": "./dist/resolver.js"
|
|
35
|
+
"import": "./dist/resolver/index.js",
|
|
36
|
+
"default": "./dist/resolver/index.js"
|
|
37
37
|
},
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"vue-tsc": "^2.0.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@mtn-ui/utils": "0.0.
|
|
80
|
+
"@mtn-ui/utils": "0.0.3"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "vite build",
|