mx-ui-template 0.1.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.
package/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # lsy_ui_template
2
+
3
+ 基于 Naive UI 二次封装的 Vue 3 UI 组件库模板,可以发布到 npm 使用。
4
+
5
+ ## 特性
6
+
7
+ - 📦 开箱即用的 Vue 3 组件
8
+ - 🎨 基于 Naive UI 的样式系统
9
+ - 🚀 完整的 TypeScript 类型支持
10
+ - 🔧 简单易用的 API 设计
11
+ - 📱 响应式设计
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ npm install mx-ui-template naive-ui@^2.43.0 @vicons/material@^0.13.0 vue@^3.0.0
17
+ # 或
18
+ pnpm add mx-ui-template naive-ui@^2.43.0 @vicons/material@^0.13.0 vue@^3.0.0
19
+ # 或
20
+ yarn add mx-ui-template naive-ui@^2.43.0 @vicons/material@^0.13.0 vue@^3.0.0
21
+ ```
22
+
23
+ ## 使用
24
+
25
+ ### 全局引入
26
+
27
+ ```ts
28
+ // main.ts
29
+ import { createApp } from 'vue'
30
+ import App from './App.vue'
31
+ import MxUI from 'mx-ui-template'
32
+ import 'mx-ui-template/style.css' // 这会自动映射到 dist/mx-ui-template.css
33
+
34
+ const app = createApp(App)
35
+ app.use(MxUI)
36
+ app.mount('#app')
37
+ ```
38
+
39
+ ### 按需引入
40
+
41
+ ```ts
42
+ // 导入组件
43
+ import { Button, Input, Card } from 'mx-ui-template'
44
+ // 导入样式
45
+ import 'mx-ui-template/style.css' // 这会自动映射到 dist/mx-ui-template.css
46
+
47
+ // 在组件中使用
48
+ components: {
49
+ Button,
50
+ Input,
51
+ Card
52
+ }
53
+ ```
54
+
55
+ ## 组件列表
56
+
57
+ ## 工具函数
58
+
59
+ 组件库的工具函数已单独打包为 `mx-ui-template_utils`,可以通过以下方式导入使用:
60
+
61
+ ```ts
62
+ // 方式1:单独导入utils包
63
+ import * as utils from 'mx-ui-template_utils'
64
+ // 或者
65
+ import utils from 'mx-ui-template_utils'
66
+
67
+ // 格式化日期
68
+ handleDate() {
69
+ const now = new Date()
70
+ const formattedDate = utils.formatDate(now, {
71
+ options: { year: 'numeric', month: 'long', day: 'numeric' }
72
+ })
73
+ console.log(formattedDate) // 输出类似:2024年7月25日
74
+ }
75
+
76
+ // 检查值是否为空
77
+ checkEmpty() {
78
+ console.log(utils.isEmpty('')) // true
79
+ console.log(utils.isEmpty({})) // true
80
+ console.log(utils.isEmpty('hello')) // false
81
+ }```
82
+
83
+ ### Button 按钮
84
+
85
+ ```vue
86
+ <Button>默认按钮</Button>
87
+ <Button type="primary">主要按钮</Button>
88
+ <Button type="success">成功按钮</Button>
89
+ <Button type="warning">警告按钮</Button>
90
+ <Button type="error">错误按钮</Button>
91
+ <Button type="info">信息按钮</Button>
92
+ <Button size="small">小按钮</Button>
93
+ <Button size="large">大按钮</Button>
94
+ <Button disabled>禁用按钮</Button>
95
+ <Button :loading="true">加载按钮</Button>
96
+ <Button circle>O</Button>
97
+ <Button ghost>幽灵按钮</Button>
98
+ <Button dashed>虚线按钮</Button>
99
+ ```
100
+
101
+ ### Input 输入框
102
+
103
+ ```vue
104
+ <Input placeholder="请输入内容" />
105
+ <Input type="password" placeholder="请输入密码" />
106
+ <Input v-model="value" placeholder="双向绑定" />
107
+ <Input size="small" placeholder="小尺寸" />
108
+ <Input size="large" placeholder="大尺寸" />
109
+ <Input readonly placeholder="只读" />
110
+ <Input disabled placeholder="禁用" />
111
+ <Input maxlength="10" showWordLimit placeholder="带字数限制" />
112
+ ```
113
+
114
+ ### Card 卡片
115
+
116
+ ```vue
117
+ <Card title="卡片标题">
118
+ 卡片内容
119
+ </Card>
120
+ <Card title="可关闭卡片" closable @close="handleClose">
121
+ 点击右上角关闭按钮可以关闭卡片
122
+ </Card>
123
+ <Card title="无边框卡片" :bordered="false">
124
+ 无边框样式的卡片
125
+ </Card>
126
+ <Card title="带额外内容的卡片">
127
+ <template #header-extra>
128
+ <Button size="small">操作</Button>
129
+ </template>
130
+ 带额外内容的卡片
131
+ </Card>
132
+ ```
133
+
134
+ ## 开发
135
+
136
+ ```bash
137
+ # 安装依赖
138
+ npm install
139
+
140
+ # 启动开发服务器
141
+ npm run dev
142
+
143
+ # 构建组件库
144
+ npm run build:lib
145
+
146
+ # 预览构建结果
147
+ npm run preview
148
+
149
+ # 发布到 npm
150
+ npm run pub
151
+ ```
152
+
153
+ ## 开发说明
154
+
155
+ - 组件源码位于 `src/components/` 目录下
156
+ - 组件类型定义位于 `src/types/` 目录下
157
+ - 组件样式位于 `src/styles/` 目录下
158
+ - 演示页面位于 `src/App.vue`
159
+
160
+ ## License
161
+
162
+ MIT
@@ -0,0 +1 @@
1
+ [data-v-fdf1cb77] .n-button{transition:all .3s ease}[data-v-fdf1cb77] .n-button:hover:not(:disabled){transform:translateY(-1px)}[data-v-fdf1cb77] .n-button:active:not(:disabled){transform:translateY(0)}[data-v-be9f5c5c] .n-input-wrapper{transition:all .3s ease}[data-v-be9f5c5c] .n-input-wrapper:focus-within{box-shadow:0 0 0 2px #1890ff33}[data-v-fdc12dd9] .n-card{transition:all .3s ease;border-radius:var(--border-radius)}[data-v-fdc12dd9] .n-card:hover{box-shadow:0 4px 16px #0000001a}*{box-sizing:border-box}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:root{--primary-color: #1890ff;--success-color: #52c41a;--warning-color: #faad14;--error-color: #f5222d;--info-color: #1890ff;--text-primary: #262626;--text-secondary: #8c8c8c;--text-disabled: #bfbfbf;--border-color: #d9d9d9;--border-radius: 6px;--box-shadow: 0 2px 8px rgba(0, 0, 0, .15)}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb{background:#888;border-radius:4px}::-webkit-scrollbar-thumb:hover{background:#555}
@@ -0,0 +1,167 @@
1
+ import { defineComponent as u, createBlock as r, openBlock as y, unref as m, normalizeStyle as f, normalizeClass as h, withCtx as i, renderSlot as c, computed as C, createSlots as p } from "vue";
2
+ import { NButton as z, NInput as v, NCard as k } from "naive-ui";
3
+ const I = /* @__PURE__ */ u({
4
+ __name: "Button",
5
+ props: {
6
+ type: {},
7
+ size: {},
8
+ circle: { type: Boolean },
9
+ ghost: { type: Boolean },
10
+ dashed: { type: Boolean },
11
+ loading: { type: Boolean },
12
+ onClick: { type: Function },
13
+ id: {},
14
+ class: {},
15
+ style: {},
16
+ disabled: { type: Boolean }
17
+ },
18
+ emits: ["click"],
19
+ setup(e, { emit: l }) {
20
+ const t = e, o = l, s = (n) => {
21
+ !t.disabled && t.onClick && t.onClick(n), o("click", n);
22
+ };
23
+ return (n, d) => (y(), r(m(z), {
24
+ id: e.id,
25
+ class: h(e.class),
26
+ style: f(e.style),
27
+ type: e.type,
28
+ size: e.size,
29
+ circle: e.circle,
30
+ ghost: e.ghost,
31
+ dashed: e.dashed,
32
+ loading: e.loading,
33
+ disabled: e.disabled,
34
+ onClick: s
35
+ }, {
36
+ default: i(() => [
37
+ c(n.$slots, "default", {}, void 0, !0)
38
+ ]),
39
+ _: 3
40
+ }, 8, ["id", "class", "style", "type", "size", "circle", "ghost", "dashed", "loading", "disabled"]));
41
+ }
42
+ }), b = (e, l) => {
43
+ const t = e.__vccOpts || e;
44
+ for (const [o, s] of l)
45
+ t[o] = s;
46
+ return t;
47
+ }, V = /* @__PURE__ */ b(I, [["__scopeId", "data-v-fdf1cb77"]]), F = /* @__PURE__ */ u({
48
+ __name: "Input",
49
+ props: {
50
+ modelValue: {},
51
+ type: {},
52
+ size: {},
53
+ placeholder: {},
54
+ readonly: { type: Boolean },
55
+ maxlength: {},
56
+ showWordLimit: { type: Boolean },
57
+ prefixIcon: {},
58
+ suffixIcon: {},
59
+ "onUpdate:modelValue": { type: Function },
60
+ onBlur: { type: Function },
61
+ onFocus: { type: Function },
62
+ id: {},
63
+ class: {},
64
+ style: {},
65
+ disabled: { type: Boolean }
66
+ },
67
+ emits: ["update:modelValue", "input", "blur", "focus"],
68
+ setup(e, { emit: l }) {
69
+ const t = e, o = l, s = C({
70
+ get() {
71
+ return t.modelValue?.toString() || "";
72
+ },
73
+ set(a) {
74
+ o("update:modelValue", typeof t.modelValue == "number" && a !== "" ? Number(a) : a);
75
+ }
76
+ }), n = (a) => {
77
+ o("update:modelValue", a);
78
+ }, d = (a) => {
79
+ o("blur", a);
80
+ }, B = (a) => {
81
+ o("focus", a);
82
+ };
83
+ return (a, x) => (y(), r(m(v), {
84
+ id: e.id,
85
+ class: h(e.class),
86
+ style: f(e.style),
87
+ value: s.value,
88
+ "onUpdate:value": [
89
+ x[0] || (x[0] = (g) => s.value = g),
90
+ n
91
+ ],
92
+ type: e.type,
93
+ size: e.size,
94
+ placeholder: e.placeholder,
95
+ readonly: e.readonly,
96
+ maxlength: e.maxlength,
97
+ "show-word-limit": e.showWordLimit,
98
+ "prefix-icon": e.prefixIcon,
99
+ "suffix-icon": e.suffixIcon,
100
+ disabled: e.disabled,
101
+ onBlur: d,
102
+ onFocus: B
103
+ }, null, 8, ["id", "class", "style", "value", "type", "size", "placeholder", "readonly", "maxlength", "show-word-limit", "prefix-icon", "suffix-icon", "disabled"]));
104
+ }
105
+ }), w = /* @__PURE__ */ b(F, [["__scopeId", "data-v-be9f5c5c"]]), $ = /* @__PURE__ */ u({
106
+ __name: "Card",
107
+ props: {
108
+ title: {},
109
+ bordered: { type: Boolean },
110
+ size: {},
111
+ closable: { type: Boolean },
112
+ onClose: { type: Function },
113
+ id: {},
114
+ class: {},
115
+ style: {},
116
+ disabled: { type: Boolean }
117
+ },
118
+ emits: ["close"],
119
+ setup(e, { emit: l }) {
120
+ const t = e, o = l, s = () => {
121
+ t.onClose && t.onClose(), o("close");
122
+ };
123
+ return (n, d) => (y(), r(m(k), {
124
+ id: e.id,
125
+ class: h(e.class),
126
+ style: f(e.style),
127
+ title: e.title,
128
+ bordered: e.bordered,
129
+ size: e.size,
130
+ closable: e.closable,
131
+ onClose: s
132
+ }, p({
133
+ default: i(() => [
134
+ c(n.$slots, "default", {}, void 0, !0)
135
+ ]),
136
+ _: 2
137
+ }, [
138
+ n.$slots["header-extra"] ? {
139
+ name: "header-extra",
140
+ fn: i(() => [
141
+ c(n.$slots, "header-extra", {}, void 0, !0)
142
+ ]),
143
+ key: "0"
144
+ } : void 0
145
+ ]), 1032, ["id", "class", "style", "title", "bordered", "size", "closable"]));
146
+ }
147
+ }), S = /* @__PURE__ */ b($, [["__scopeId", "data-v-fdc12dd9"]]), U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
148
+ __proto__: null
149
+ }, Symbol.toStringTag, { value: "Module" })), N = {
150
+ Button: V,
151
+ Input: w,
152
+ Card: S
153
+ }, L = {
154
+ install: (e) => {
155
+ Object.values(N).forEach((l) => {
156
+ e.component(l.name, l);
157
+ });
158
+ }
159
+ };
160
+ export {
161
+ V as Button,
162
+ S as Card,
163
+ w as Input,
164
+ N as components,
165
+ L as default,
166
+ U as types
167
+ };
@@ -0,0 +1 @@
1
+ (function(l,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("naive-ui")):typeof define=="function"&&define.amd?define(["exports","vue","naive-ui"],t):(l=typeof globalThis<"u"?globalThis:l||self,t(l.MxUI={},l.Vue,l.NaiveUI))})(this,(function(l,t,c){"use strict";const B=t.defineComponent({__name:"Button",props:{type:{},size:{},circle:{type:Boolean},ghost:{type:Boolean},dashed:{type:Boolean},loading:{type:Boolean},onClick:{type:Function},id:{},class:{},style:{},disabled:{type:Boolean}},emits:["click"],setup(e,{emit:o}){const n=e,i=o,d=a=>{!n.disabled&&n.onClick&&n.onClick(a),i("click",a)};return(a,u)=>(t.openBlock(),t.createBlock(t.unref(c.NButton),{id:e.id,class:t.normalizeClass(e.class),style:t.normalizeStyle(e.style),type:e.type,size:e.size,circle:e.circle,ghost:e.ghost,dashed:e.dashed,loading:e.loading,disabled:e.disabled,onClick:d},{default:t.withCtx(()=>[t.renderSlot(a.$slots,"default",{},void 0,!0)]),_:3},8,["id","class","style","type","size","circle","ghost","dashed","loading","disabled"]))}}),r=(e,o)=>{const n=e.__vccOpts||e;for(const[i,d]of o)n[i]=d;return n},f=r(B,[["__scopeId","data-v-fdf1cb77"]]),m=r(t.defineComponent({__name:"Input",props:{modelValue:{},type:{},size:{},placeholder:{},readonly:{type:Boolean},maxlength:{},showWordLimit:{type:Boolean},prefixIcon:{},suffixIcon:{},"onUpdate:modelValue":{type:Function},onBlur:{type:Function},onFocus:{type:Function},id:{},class:{},style:{},disabled:{type:Boolean}},emits:["update:modelValue","input","blur","focus"],setup(e,{emit:o}){const n=e,i=o,d=t.computed({get(){return n.modelValue?.toString()||""},set(s){i("update:modelValue",typeof n.modelValue=="number"&&s!==""?Number(s):s)}}),a=s=>{i("update:modelValue",s)},u=s=>{i("blur",s)},z=s=>{i("focus",s)};return(s,b)=>(t.openBlock(),t.createBlock(t.unref(c.NInput),{id:e.id,class:t.normalizeClass(e.class),style:t.normalizeStyle(e.style),value:d.value,"onUpdate:value":[b[0]||(b[0]=g=>d.value=g),a],type:e.type,size:e.size,placeholder:e.placeholder,readonly:e.readonly,maxlength:e.maxlength,"show-word-limit":e.showWordLimit,"prefix-icon":e.prefixIcon,"suffix-icon":e.suffixIcon,disabled:e.disabled,onBlur:u,onFocus:z},null,8,["id","class","style","value","type","size","placeholder","readonly","maxlength","show-word-limit","prefix-icon","suffix-icon","disabled"]))}}),[["__scopeId","data-v-be9f5c5c"]]),y=r(t.defineComponent({__name:"Card",props:{title:{},bordered:{type:Boolean},size:{},closable:{type:Boolean},onClose:{type:Function},id:{},class:{},style:{},disabled:{type:Boolean}},emits:["close"],setup(e,{emit:o}){const n=e,i=o,d=()=>{n.onClose&&n.onClose(),i("close")};return(a,u)=>(t.openBlock(),t.createBlock(t.unref(c.NCard),{id:e.id,class:t.normalizeClass(e.class),style:t.normalizeStyle(e.style),title:e.title,bordered:e.bordered,size:e.size,closable:e.closable,onClose:d},t.createSlots({default:t.withCtx(()=>[t.renderSlot(a.$slots,"default",{},void 0,!0)]),_:2},[a.$slots["header-extra"]?{name:"header-extra",fn:t.withCtx(()=>[t.renderSlot(a.$slots,"header-extra",{},void 0,!0)]),key:"0"}:void 0]),1032,["id","class","style","title","bordered","size","closable"]))}}),[["__scopeId","data-v-fdc12dd9"]]),C=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),h={Button:f,Input:m,Card:y},p={install:e=>{Object.values(h).forEach(o=>{e.component(o.name,o)})}};l.Button=f,l.Card=y,l.Input=m,l.components=h,l.default=p,l.types=C,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -0,0 +1,20 @@
1
+ function o(t, r) {
2
+ if (!t) return "";
3
+ const e = t instanceof Date ? t : new Date(t);
4
+ if (Number.isNaN(e.getTime())) return "";
5
+ const n = r?.locale ?? void 0, i = r?.options ?? { year: "numeric", month: "2-digit", day: "2-digit" };
6
+ return new Intl.DateTimeFormat(n, i).format(e);
7
+ }
8
+ function f(t) {
9
+ return t == null ? !0 : typeof t == "string" ? t.trim() === "" : Array.isArray(t) ? t.length === 0 : typeof t == "object" ? Object.keys(t).length === 0 : !1;
10
+ }
11
+ const s = {
12
+ formatDate: o,
13
+ isEmpty: f
14
+ };
15
+ export {
16
+ s as default,
17
+ o as formatDate,
18
+ f as isEmpty,
19
+ s as utils
20
+ };
@@ -0,0 +1 @@
1
+ (function(t,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(t=typeof globalThis<"u"?globalThis:t||self,n(t.MxUIUtils={}))})(this,(function(t){"use strict";function n(e,r){if(!e)return"";const f=e instanceof Date?e:new Date(e);if(Number.isNaN(f.getTime()))return"";const s=r?.locale??void 0,u=r?.options??{year:"numeric",month:"2-digit",day:"2-digit"};return new Intl.DateTimeFormat(s,u).format(f)}function i(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}const o={formatDate:n,isEmpty:i};t.default=o,t.formatDate=n,t.isEmpty=i,t.utils=o,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "mx-ui-template",
3
+ "private": false,
4
+ "version": "0.1.4",
5
+ "type": "module",
6
+ "main": "./dist/mx-ui-template.umd.cjs",
7
+ "module": "./dist/mx-ui-template.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/mx-ui-template.js",
12
+ "require": "./dist/mx-ui-template.umd.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./style.css": "./dist/mx-ui-template.css"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "dev": "vite",
22
+ "build": "vue-tsc -b && vite build",
23
+ "build:lib": "vue-tsc -b && vite build -c vite.config.lib.ts",
24
+ "build:utils": "vue-tsc -b && vite build -c vite.config.utils.ts",
25
+ "build:all": "npm run build:lib && npm run build:utils",
26
+ "preview": "vite preview",
27
+ "prepare": "npm run build:all",
28
+ "pub": "npm publish --access public"
29
+ },
30
+ "peerDependencies": {
31
+ "@vicons/material": "^0.13.0",
32
+ "naive-ui": "^2.43.0",
33
+ "vue": "^3.0.0"
34
+ },
35
+ "dependencies": {
36
+ "@vicons/material": "^0.13.0",
37
+ "naive-ui": "^2.43.0",
38
+ "vue": "^3.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^24.7.2",
42
+ "@vitejs/plugin-vue": "^6.0.1",
43
+ "@vue/tsconfig": "^0.8.1",
44
+ "sass": "^1.93.2",
45
+ "typescript": "~5.9.3",
46
+ "vite": "^7.1.7",
47
+ "vue-tsc": "^3.1.0"
48
+ }
49
+ }