xypp-component 0.0.0-stage → 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/README.md CHANGED
@@ -1,3 +1,158 @@
1
- # Temporary Holding Version
1
+ # xypp-component-lib
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 行内业务场景用的 Vue 3 组件库,基于 Vite 构建,ESM 产物,样式与逻辑分离。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm i xypp-component-lib
9
+ ```
10
+
11
+ 需要 Vue 3.5+(peerDependency,不会重复安装)。
12
+
13
+ ## 全量使用
14
+
15
+ ```js
16
+ import { createApp } from 'vue'
17
+ import XUI from 'xypp-component-lib'
18
+ import 'xypp-component-lib/style'
19
+
20
+ createApp(App).use(XUI).mount('#app')
21
+ ```
22
+
23
+ ## 按需使用
24
+
25
+ ```js
26
+ import { XTabs, XTabPane } from 'xypp-component-lib'
27
+ import 'xypp-component-lib/tabs/style'
28
+ ```
29
+
30
+ 也可以只引单个组件入口:
31
+
32
+ ```js
33
+ import XTabs from 'xypp-component-lib/tabs'
34
+ ```
35
+
36
+ > 产物中的 JS 不自动引入 CSS,全局样式或对应组件的样式需要手动 import。
37
+
38
+ ## 组件
39
+
40
+ ### XTabs / XTabPane
41
+
42
+ 标签页,头部指示条带滑动动画。
43
+
44
+ ```vue
45
+ <XTabs v-model="tab" :bar-width="24">
46
+ <XTabPane name="flow" label="交易流水">
47
+ <p>内容</p>
48
+ </XTabPane>
49
+ <XTabPane name="account" label="账户信息">...</XTabPane>
50
+ <XTabPane name="log" label="操作日志" disabled>...</XTabPane>
51
+ </XTabs>
52
+ ```
53
+
54
+ `XTabPane` 必须直接放在 `XTabs` 下(不能多包一层 div),`v-for` 可以。
55
+
56
+ **XTabs**
57
+
58
+ | 属性 | 类型 | 默认值 | 说明 |
59
+ | --- | --- | --- | --- |
60
+ | modelValue | `String \| Number` | — | 当前选中的 tab name,支持 v-model |
61
+ | type | `'line' \| 'card'` | `'line'` | line 为底部指示条,card 为灰底滑块 |
62
+ | animated | `Boolean` | `true` | 是否开启指示条滑动动画 |
63
+ | stretch | `Boolean` | `false` | 各个 tab 是否等分宽度 |
64
+ | barWidth | `Number` | `0` | line 型指示条固定宽度(px),0 表示跟随文字宽度;指定后在单个 tab 内居中 |
65
+
66
+ 事件:`change`(选中变化,参数为 name)、`tab-click`(点击任意 tab)。
67
+
68
+ **XTabPane**
69
+
70
+ | 属性 | 类型 | 默认值 | 说明 |
71
+ | --- | --- | --- | --- |
72
+ | name | `String \| Number` | — | 必填,对应 v-model 的值 |
73
+ | label | `String` | `''` | 头部显示的文字 |
74
+ | disabled | `Boolean` | `false` | 是否禁用 |
75
+ | lazy | `Boolean` | `false` | 懒渲染,首次激活后才挂载 DOM |
76
+
77
+ ### XDropdown / XDropdownItem
78
+
79
+ 下拉菜单,支持 hover / click 触发、方向翻转与边界平移。
80
+
81
+ ```vue
82
+ <XDropdown trigger="click" placement="bottom-start" v-model="value">
83
+ <button>展开</button>
84
+ <template #dropdown>
85
+ <XDropdownItem value="copy">复制</XDropdownItem>
86
+ <XDropdownItem value="paste" disabled>粘贴</XDropdownItem>
87
+ </template>
88
+ </XDropdown>
89
+ ```
90
+
91
+ **XDropdown**:`modelValue`、`visible`(支持 `v-model:visible`)、`trigger`(`hover`/`click`)、`placement`、`disabled`、`offset`、`closeOnClick`、`showTimeout`、`hideTimeout`、`boundaryPadding`、`appendTo`。
92
+ 事件:`select`、`visible-change`。
93
+
94
+ **XDropdownItem**:`value`、`disabled`、`divided`。
95
+
96
+ ### XToast
97
+
98
+ 消息通知,命令式调用,不需要在模板里写标签。首次调用时自动把容器挂载到 body。
99
+
100
+ ```js
101
+ import { XToast } from 'xypp-component-lib'
102
+ import 'xypp-component-lib/toast/style'
103
+
104
+ XToast.success('保存成功')
105
+ XToast.error('网络异常')
106
+ XToast.warning('余额不足')
107
+ XToast.info('已同步到云端')
108
+
109
+ // 完整参数
110
+ XToast.show({
111
+ message: '需要手动关闭的消息',
112
+ type: 'info',
113
+ duration: 0, // 不自动关闭
114
+ closable: true, // 显示关闭按钮
115
+ onClose: () => console.log('closed')
116
+ })
117
+
118
+ // 也支持第二个参数
119
+ XToast.success('已删除', { duration: 2000, onClose: refresh })
120
+
121
+ XToast.clear() // 清空全部
122
+ ```
123
+
124
+ `app.use(XToast)` 之后,模板里可以直接用 `$toast.success('...')`。
125
+
126
+ | 方法 / 选项 | 说明 |
127
+ | --- | --- |
128
+ | `Toast.success / error / warning / info` | 快捷方法,参数为 message 或 `{ message, ...options }` |
129
+ | `Toast.show(message, options)` | 完整调用,返回 toast id |
130
+ | `Toast.clear()` | 关闭全部 |
131
+ | `duration` | 自动关闭毫秒数,默认 3000,传 0 不自动关 |
132
+ | `closable` | 是否显示关闭按钮,默认 false |
133
+ | `onClose` | 关闭后的回调 |
134
+
135
+ ### XAvatar
136
+
137
+ 头像,图片加载失败时回退成名字后两个字。
138
+
139
+ ```vue
140
+ <XAvatar name="张三" src="/avatar.png" size="medium" />
141
+ ```
142
+
143
+ 属性:`name`(必填)、`src`、`size`(`small` / `medium` / `large`)。事件:`click-avatar`。
144
+
145
+ ## 本地开发
146
+
147
+ ```bash
148
+ npm i
149
+ npm run dev # demo 页面,src/App.vue
150
+ npm run build # 产物输出到 dist/
151
+ ```
152
+
153
+ ## 发布
154
+
155
+ ```bash
156
+ npm run build
157
+ npm publish
158
+ ```
@@ -0,0 +1,59 @@
1
+ import { computed as e, createCommentVNode as t, createElementBlock as n, normalizeStyle as r, openBlock as i, ref as a, toDisplayString as o } from "vue";
2
+ //#region packages/ui/Avatar/index.vue
3
+ var s = ["src"], c = {
4
+ __name: "index",
5
+ props: {
6
+ src: String,
7
+ name: {
8
+ type: String,
9
+ required: !0
10
+ },
11
+ size: {
12
+ type: String,
13
+ default: "medium"
14
+ }
15
+ },
16
+ emits: ["click-avatar"],
17
+ setup(c, { emit: l }) {
18
+ let u = l, d = c, f = {
19
+ small: 24,
20
+ medium: 32,
21
+ large: 36
22
+ }, p = e(() => f[d.size || "medium"] || 32), m = {
23
+ small: 10,
24
+ medium: 12,
25
+ large: 16
26
+ }, h = e(() => m[d.size || "medium"] || 14), g = e(() => d.name ? d.name.slice(-2) : ""), _ = a(!!d.src), v = () => {
27
+ _.value = !1;
28
+ }, y = (e) => {
29
+ u("click-avatar", e);
30
+ };
31
+ return (e, a) => g.value ? (i(), n("div", {
32
+ key: 0,
33
+ class: "xypp-avatar",
34
+ style: r({
35
+ width: p.value + "px",
36
+ height: p.value + "px",
37
+ lineHeight: p.value + "px"
38
+ }),
39
+ onClick: y
40
+ }, [_.value ? (i(), n("img", {
41
+ key: 0,
42
+ src: c.src,
43
+ onError: v,
44
+ class: "avatar-img"
45
+ }, null, 40, s)) : (i(), n("span", {
46
+ key: 1,
47
+ class: "avatar-text",
48
+ style: r({ fontSize: h.value + "px" })
49
+ }, o(g.value), 5))], 4)) : t("", !0);
50
+ }
51
+ };
52
+ //#endregion
53
+ //#region packages/ui/Avatar/index.js
54
+ c.install = (e) => {
55
+ e.component("XAvatar", c);
56
+ };
57
+ var l = c;
58
+ //#endregion
59
+ export { l as t };
@@ -0,0 +1 @@
1
+ .xypp-avatar{color:#fff;-webkit-user-select:none;user-select:none;background-color:#3369ff;border-radius:50%;justify-content:center;align-items:center;font-weight:500;display:inline-flex;overflow:hidden}.xypp-avatar .avatar-img{object-fit:cover;width:100%;height:100%}.xypp-avatar .avatar-text{font-size:14px}
@@ -0,0 +1,229 @@
1
+ import { Teleport as e, Transition as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createVNode as s, inject as c, nextTick as l, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, openBlock as p, provide as m, ref as h, renderSlot as g, watch as _, withCtx as v, withModifiers as y } from "vue";
2
+ //#region packages/ui/Dropdown/index.vue
3
+ var b = {
4
+ __name: "index",
5
+ props: {
6
+ modelValue: {
7
+ type: [
8
+ String,
9
+ Number,
10
+ Object
11
+ ],
12
+ default: null
13
+ },
14
+ visible: {
15
+ type: Boolean,
16
+ default: void 0
17
+ },
18
+ trigger: {
19
+ type: String,
20
+ default: "hover"
21
+ },
22
+ placement: {
23
+ type: String,
24
+ default: "bottom"
25
+ },
26
+ disabled: {
27
+ type: Boolean,
28
+ default: !1
29
+ },
30
+ offset: {
31
+ type: Number,
32
+ default: 8
33
+ },
34
+ closeOnClick: {
35
+ type: Boolean,
36
+ default: !0
37
+ },
38
+ showTimeout: {
39
+ type: Number,
40
+ default: 150
41
+ },
42
+ hideTimeout: {
43
+ type: Number,
44
+ default: 150
45
+ },
46
+ boundaryPadding: {
47
+ type: Number,
48
+ default: 8
49
+ },
50
+ appendTo: {
51
+ type: [String, typeof HTMLElement > "u" ? Object : HTMLElement],
52
+ default: "body"
53
+ }
54
+ },
55
+ emits: [
56
+ "visible-change",
57
+ "select",
58
+ "update:modelValue",
59
+ "update:visible"
60
+ ],
61
+ setup(c, { expose: b, emit: x }) {
62
+ let S = x, C = c, w = h(null), T = h(null), E = h(!1), D = n({
63
+ get() {
64
+ return C.visible === void 0 ? E.value : C.visible;
65
+ },
66
+ set(e) {
67
+ E.value = e, S("update:visible", e);
68
+ }
69
+ }), O = h({
70
+ top: 0,
71
+ left: 0
72
+ }), k = h(C.placement), A = null, j = null, M = null, N = n(() => ({
73
+ top: O.value.top + "px",
74
+ left: O.value.left + "px"
75
+ }));
76
+ function P() {
77
+ C.disabled || (clearTimeout(A), clearTimeout(j), C.trigger === "hover" ? j = setTimeout(() => {
78
+ D.value = !0;
79
+ }, C.showTimeout) : D.value = !0);
80
+ }
81
+ function F() {
82
+ clearTimeout(j), clearTimeout(A), C.trigger === "hover" ? A = setTimeout(() => {
83
+ D.value = !1;
84
+ }, C.hideTimeout) : D.value = !1;
85
+ }
86
+ function I() {
87
+ C.disabled || C.trigger === "click" && (D.value ? F() : P());
88
+ }
89
+ function L() {
90
+ C.trigger === "hover" && P();
91
+ }
92
+ function R() {
93
+ C.trigger === "hover" && F();
94
+ }
95
+ function z() {
96
+ let e = w.value, t = T.value;
97
+ if (!e || !t) return;
98
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, o = C.boundaryPadding, s = 0, c = 0, l = C.placement, u = {
99
+ bottom: () => {
100
+ s = n.bottom + C.offset, c = n.left + n.width / 2 - r.width / 2;
101
+ },
102
+ "bottom-start": () => {
103
+ s = n.bottom + C.offset, c = n.left;
104
+ },
105
+ "bottom-end": () => {
106
+ s = n.bottom + C.offset, c = n.right - r.width;
107
+ },
108
+ top: () => {
109
+ s = n.top - r.height - C.offset, c = n.left + n.width / 2 - r.width / 2;
110
+ },
111
+ "top-start": () => {
112
+ s = n.top - r.height - C.offset, c = n.left;
113
+ },
114
+ "top-end": () => {
115
+ s = n.top - r.height - C.offset, c = n.right - r.width;
116
+ }
117
+ };
118
+ (u[C.placement] || u.bottom)();
119
+ let d = a - n.bottom, f = n.top;
120
+ C.placement.startsWith("bottom") && s + r.height > a - o ? f > d && (l = C.placement.replace("bottom", "top"), s = n.top - r.height - C.offset) : C.placement.startsWith("top") && s < o && d > f && (l = C.placement.replace("top", "bottom"), s = n.bottom + C.offset), c < o ? c = o : c + r.width > i - o && (c = i - r.width - o), O.value = {
121
+ top: s,
122
+ left: c
123
+ }, k.value = l;
124
+ }
125
+ function B(e) {
126
+ T.value = e, z();
127
+ }
128
+ function V() {
129
+ O.value = {
130
+ top: 0,
131
+ left: 0
132
+ }, k.value = C.placement, T.value = null;
133
+ }
134
+ function H(e) {
135
+ if (!D.value) return;
136
+ let t = e.composedPath();
137
+ t.includes(w.value) || t.includes(T.value) || F();
138
+ }
139
+ function U(e) {
140
+ e.key === "Escape" && D.value && F();
141
+ }
142
+ function W() {
143
+ D.value && z();
144
+ }
145
+ return _(D, (e) => {
146
+ S("visible-change", e), e ? l(() => {
147
+ document.addEventListener("mousedown", H), document.addEventListener("keydown", U), window.addEventListener("scroll", W, !0), window.addEventListener("resize", W), T.value && typeof ResizeObserver < "u" && (M = new ResizeObserver(() => z()), M.observe(T.value));
148
+ }) : (document.removeEventListener("mousedown", H), document.removeEventListener("keydown", U), window.removeEventListener("scroll", W, !0), window.removeEventListener("resize", W), M &&= (M.disconnect(), null));
149
+ }), m("xypp-dropdown", {
150
+ handleItemClick(e) {
151
+ C.closeOnClick && F(), S("select", e), S("update:modelValue", e);
152
+ },
153
+ activeValue: n(() => C.modelValue)
154
+ }), b({
155
+ show: P,
156
+ hide: F
157
+ }), f(() => {
158
+ clearTimeout(j), clearTimeout(A), document.removeEventListener("mousedown", H), document.removeEventListener("keydown", U), window.removeEventListener("scroll", W, !0), window.removeEventListener("resize", W), M && M.disconnect();
159
+ }), (n, l) => (p(), a("div", {
160
+ class: "xypp-dropdown",
161
+ ref_key: "rootRef",
162
+ ref: w
163
+ }, [o("div", {
164
+ class: "xypp-dropdown__trigger",
165
+ onClick: I,
166
+ onMouseenter: L,
167
+ onMouseleave: R
168
+ }, [g(n.$slots, "default")], 32), (p(), r(e, { to: c.appendTo }, [s(t, {
169
+ name: "xypp-dropdown",
170
+ onBeforeEnter: B,
171
+ onAfterLeave: V
172
+ }, {
173
+ default: v(() => [D.value ? (p(), a("div", {
174
+ key: 0,
175
+ class: u(["xypp-dropdown__menu", [`xypp-dropdown__menu--${k.value}`]]),
176
+ style: d(N.value),
177
+ ref_key: "menuRef",
178
+ ref: T,
179
+ onMouseenter: L,
180
+ onMouseleave: R,
181
+ onClick: l[0] ||= y(() => {}, ["stop"])
182
+ }, [g(n.$slots, "dropdown")], 38)) : i("", !0)]),
183
+ _: 3
184
+ })], 8, ["to"]))], 512));
185
+ }
186
+ }, x = {
187
+ __name: "item",
188
+ props: {
189
+ value: {
190
+ type: [
191
+ String,
192
+ Number,
193
+ Object
194
+ ],
195
+ default: null
196
+ },
197
+ disabled: {
198
+ type: Boolean,
199
+ default: !1
200
+ },
201
+ divided: {
202
+ type: Boolean,
203
+ default: !1
204
+ }
205
+ },
206
+ emits: ["click"],
207
+ setup(e, { emit: t }) {
208
+ let r = e, i = t, o = c("xypp-dropdown", null), s = n(() => !o || r.value === null || r.value === void 0 ? !1 : o.activeValue.value === r.value);
209
+ function l(e) {
210
+ r.disabled || (i("click", e), o && o.handleItemClick(r.value));
211
+ }
212
+ return (t, n) => (p(), a("div", {
213
+ class: u(["xypp-dropdown-item", {
214
+ "xypp-dropdown-item--disabled": e.disabled,
215
+ "xypp-dropdown-item--divided": e.divided,
216
+ "xypp-dropdown-item--active": s.value
217
+ }]),
218
+ onClick: l
219
+ }, [g(t.$slots, "default")], 2));
220
+ }
221
+ };
222
+ //#endregion
223
+ //#region packages/ui/Dropdown/index.js
224
+ b.install = (e) => {
225
+ e.component("XDropdown", b), e.component("XDropdownItem", x);
226
+ };
227
+ var S = b;
228
+ //#endregion
229
+ export { x as n, S as t };
@@ -0,0 +1 @@
1
+ .xypp-dropdown{display:inline-block}.xypp-dropdown__trigger{cursor:pointer;display:inline-block}.xypp-dropdown__menu{z-index:2000;box-sizing:border-box;will-change:opacity, transform;background:#fff;border:1px solid #ebedf0;border-radius:8px;min-width:140px;max-height:320px;padding:6px;position:absolute;overflow-y:auto;box-shadow:0 6px 24px #0000001a}.xypp-dropdown__menu--bottom,.xypp-dropdown__menu--bottom-start,.xypp-dropdown__menu--bottom-end{transform-origin:top}.xypp-dropdown__menu--top,.xypp-dropdown__menu--top-start,.xypp-dropdown__menu--top-end{transform-origin:bottom}.xypp-dropdown-item{color:#333;cursor:pointer;white-space:nowrap;padding:8px;font-size:14px;line-height:1.5;transition:background-color .15s}.xypp-dropdown-item:hover{background-color:#46598c1a;border-radius:4px}.xypp-dropdown-item--disabled{color:#c0c4cc;cursor:not-allowed}.xypp-dropdown-item--disabled:hover{background-color:#0000}.xypp-dropdown-item--active{color:#3369ff;background-color:#3369ff14;border-radius:4px;font-weight:500}.xypp-dropdown-item--divided{border-top:1px solid #ebedf0;margin-top:4px;padding-top:12px}.xypp-dropdown-enter-active,.xypp-dropdown-leave-active{transition:opacity .25s cubic-bezier(.4,0,.2,1),transform .25s cubic-bezier(.4,0,.2,1)}.xypp-dropdown-enter-from,.xypp-dropdown-leave-to{opacity:0;transform:scaleY(.85)}
@@ -0,0 +1,157 @@
1
+ import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, inject as a, nextTick as o, normalizeClass as s, normalizeStyle as c, onBeforeUnmount as l, onMounted as u, openBlock as d, provide as f, reactive as p, ref as m, renderList as h, renderSlot as g, toDisplayString as _, useSlots as v, vShow as y, watch as b, withDirectives as x } from "vue";
2
+ //#region packages/ui/Tabs/pane.vue
3
+ var S = {
4
+ __name: "pane",
5
+ props: {
6
+ name: {
7
+ type: [String, Number],
8
+ required: !0
9
+ },
10
+ label: {
11
+ type: String,
12
+ default: ""
13
+ },
14
+ disabled: {
15
+ type: Boolean,
16
+ default: !1
17
+ },
18
+ lazy: {
19
+ type: Boolean,
20
+ default: !1
21
+ }
22
+ },
23
+ setup(e) {
24
+ let i = e, o = a("xypp-tabs", null), c = t(() => {
25
+ let e = o?.current;
26
+ return !!e && e.value === i.name;
27
+ }), l = m(!1);
28
+ return b(c, (e) => {
29
+ e && (l.value = !0);
30
+ }, { immediate: !0 }), (t, i) => !e.lazy || l.value ? x((d(), r("div", {
31
+ key: 0,
32
+ class: s(["xypp-tab-pane", { "is-active": c.value }]),
33
+ role: "tabpanel"
34
+ }, [g(t.$slots, "default")], 2)), [[y, c.value]]) : n("", !0);
35
+ }
36
+ }, C = ["onClick"], w = { class: "xypp-tabs__content" }, T = {
37
+ __name: "index",
38
+ props: {
39
+ modelValue: {
40
+ type: [String, Number],
41
+ default: void 0
42
+ },
43
+ type: {
44
+ type: String,
45
+ default: "line"
46
+ },
47
+ animated: {
48
+ type: Boolean,
49
+ default: !0
50
+ },
51
+ stretch: {
52
+ type: Boolean,
53
+ default: !1
54
+ },
55
+ barWidth: {
56
+ type: Number,
57
+ default: 0
58
+ }
59
+ },
60
+ emits: [
61
+ "update:modelValue",
62
+ "change",
63
+ "tab-click"
64
+ ],
65
+ setup(n, { emit: a }) {
66
+ let y = n, x = a, T = v(), E = t(() => {
67
+ let t = [], n = (r) => {
68
+ r.forEach((r) => {
69
+ if (r) {
70
+ if (Array.isArray(r)) return n(r);
71
+ if (r.type === e && Array.isArray(r.children)) return n(r.children);
72
+ r.type === S && t.push({
73
+ name: r.props?.name,
74
+ label: r.props?.label ?? "",
75
+ disabled: !!r.props?.disabled
76
+ });
77
+ }
78
+ });
79
+ };
80
+ return T.default && n(T.default()), t;
81
+ }), D = m(void 0), O = t(() => y.modelValue === void 0 ? D.value === void 0 ? E.value[0]?.name : D.value : y.modelValue);
82
+ function k(e) {
83
+ e.disabled || (x("tab-click", e.name), e.name !== O.value && (D.value = e.name, x("update:modelValue", e.name), x("change", e.name)));
84
+ }
85
+ f("xypp-tabs", { current: O });
86
+ let A = m(null), j = [], M = [], N = p({
87
+ x: 0,
88
+ w: 0,
89
+ y: 0,
90
+ h: 0,
91
+ ready: !1,
92
+ visible: !1
93
+ }), P = t(() => ({
94
+ width: N.w + "px",
95
+ opacity: N.visible ? 1 : 0,
96
+ transform: `translate(${N.x}px, ${y.type === "card" ? N.y : 0}px)`,
97
+ ...y.type === "card" ? { height: N.h + "px" } : {}
98
+ }));
99
+ function F() {
100
+ let e = A.value, t = E.value.findIndex((e) => e.name === O.value), n = j[t], r = M[t], i = y.type === "card", a = i ? n : r || n;
101
+ if (!e || !n || !a) {
102
+ N.visible = !1;
103
+ return;
104
+ }
105
+ let o = e.getBoundingClientRect(), s = a.getBoundingClientRect(), c = n.getBoundingClientRect(), l = s.left - o.left - e.clientLeft, u = s.width;
106
+ !i && y.barWidth > 0 && (u = y.barWidth, l = c.left + c.width / 2 - o.left - e.clientLeft - u / 2), N.x = l, N.w = u, N.y = c.top - o.top - e.clientTop, N.h = c.height, N.visible = !0, !N.ready && N.w > 0 && y.animated && requestAnimationFrame(() => {
107
+ N.ready = !0;
108
+ });
109
+ }
110
+ let I = null;
111
+ function L() {
112
+ typeof ResizeObserver > "u" || (I ||= new ResizeObserver(() => F()), I.disconnect(), A.value && I.observe(A.value), j.forEach((e) => e && I.observe(e)));
113
+ }
114
+ return b(O, () => F()), b(() => y.type, () => F()), b(() => y.barWidth, () => F()), b(() => y.animated, () => F()), b(E, async () => {
115
+ await o(), F(), L();
116
+ }), u(async () => {
117
+ await o(), F(), L(), document.fonts?.ready.then(() => F());
118
+ }), l(() => {
119
+ I && I.disconnect();
120
+ }), (t, a) => (d(), r("div", { class: s(["xypp-tabs", [`xypp-tabs--${n.type}`, { "xypp-tabs--stretch": n.stretch }]]) }, [i("div", {
121
+ ref_key: "navRef",
122
+ ref: A,
123
+ class: "xypp-tabs__nav",
124
+ role: "tablist"
125
+ }, [(d(!0), r(e, null, h(E.value, (e, t) => (d(), r("button", {
126
+ key: e.name,
127
+ ref_for: !0,
128
+ ref: (e) => {
129
+ j[t] = e;
130
+ },
131
+ type: "button",
132
+ role: "tab",
133
+ class: s(["xypp-tabs__item", {
134
+ "is-active": e.name === O.value,
135
+ "is-disabled": e.disabled
136
+ }]),
137
+ onClick: (t) => k(e)
138
+ }, [i("span", {
139
+ ref_for: !0,
140
+ ref: (e) => {
141
+ M[t] = e;
142
+ },
143
+ class: "xypp-tabs__label"
144
+ }, _(e.label), 513)], 10, C))), 128)), i("span", {
145
+ class: s(["xypp-tabs__bar", { "is-ready": N.ready }]),
146
+ style: c(P.value)
147
+ }, null, 6)], 512), i("div", w, [g(t.$slots, "default")])], 2));
148
+ }
149
+ };
150
+ //#endregion
151
+ //#region packages/ui/Tabs/index.js
152
+ T.install = (e) => {
153
+ e.component("XTabs", T), e.component("XTabPane", S);
154
+ };
155
+ var E = T;
156
+ //#endregion
157
+ export { S as n, E as t };
package/dist/Tabs.css ADDED
@@ -0,0 +1 @@
1
+ .xypp-tabs{display:block}.xypp-tabs__nav{box-sizing:border-box;border-bottom:1px solid #ebedf0;align-items:center;display:flex;position:relative}.xypp-tabs__item{color:#666;cursor:pointer;white-space:nowrap;background:0 0;border:0;justify-content:center;align-items:center;height:40px;margin:0;padding:0 16px;font-family:inherit;font-size:14px;line-height:1;transition:color .2s;display:inline-flex;position:relative}.xypp-tabs__item:hover{color:#3369ff}.xypp-tabs__item.is-active{color:#3369ff;font-weight:500}.xypp-tabs__item.is-disabled{color:#c0c4cc;cursor:not-allowed}.xypp-tabs__item.is-disabled:hover{color:#c0c4cc}.xypp-tabs__label{pointer-events:none;display:inline-block}.xypp-tabs__bar{opacity:0;pointer-events:none;will-change:transform, width;background-color:#3369ff;border-radius:1px;height:2px;transition:opacity .15s;position:absolute;bottom:0;left:0}.xypp-tabs__bar.is-ready{transition:transform .28s cubic-bezier(.4,0,.2,1),width .28s cubic-bezier(.4,0,.2,1),opacity .15s}.xypp-tabs__content{padding-top:16px}.xypp-tabs--stretch .xypp-tabs__item{flex:1 1 0;padding:0 8px}.xypp-tabs--card .xypp-tabs__nav{background-color:#f2f4f8;border-bottom:0;border-radius:8px;padding:3px}.xypp-tabs--card .xypp-tabs__item{z-index:1;height:34px;padding:0 16px}.xypp-tabs--card .xypp-tabs__bar{background-color:#fff;border-radius:6px;height:0;top:0;bottom:auto;box-shadow:0 1px 2px #0000000f}.xypp-tab-pane.is-active{animation:.2s cubic-bezier(.4,0,.2,1) xypp-tab-pane-in}@keyframes xypp-tab-pane-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}
@@ -0,0 +1,140 @@
1
+ import { Fragment as e, TransitionGroup as t, cloneVNode as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createVNode as s, normalizeClass as c, openBlock as l, render as u, renderList as d, resolveDynamicComponent as f, shallowReactive as p, toDisplayString as m, unref as h, withCtx as g } from "vue";
2
+ //#region packages/ui/Toast/index.vue
3
+ var _ = {
4
+ class: "xypp-toast",
5
+ "aria-live": "polite"
6
+ }, v = {
7
+ viewBox: "0 0 16 16",
8
+ fill: "none"
9
+ }, y = ["d"], b = {
10
+ key: 1,
11
+ class: "xypp-toast__message"
12
+ }, x = ["onClick"], S = {
13
+ __name: "index",
14
+ setup(u, { expose: S }) {
15
+ let C = {
16
+ success: "M3.2 8.6l3 3 6.6-6.6",
17
+ error: "M4.5 4.5l7 7M11.5 4.5l-7 7",
18
+ warning: "M8 3.4v5.4M8 11.8v.1",
19
+ info: "M8 7.2v4.6M8 4.2v.1"
20
+ }, w = [
21
+ "success",
22
+ "error",
23
+ "warning",
24
+ "info"
25
+ ], T = 0, E = p([]), D = /* @__PURE__ */ new Map();
26
+ function O(e) {
27
+ return typeof e == "function" ? {
28
+ text: "",
29
+ render: e
30
+ } : e && typeof e == "object" ? {
31
+ text: "",
32
+ render: () => n(e)
33
+ } : {
34
+ text: e ?? "",
35
+ render: null
36
+ };
37
+ }
38
+ function k(e = {}) {
39
+ let t = ++T, { text: n, render: r } = O(e.message), i = {
40
+ id: t,
41
+ text: n,
42
+ render: r,
43
+ type: w.includes(e.type) ? e.type : "info",
44
+ duration: e.duration ?? 3e3,
45
+ closable: !!e.closable,
46
+ onClose: e.onClose
47
+ };
48
+ return E.push(i), i.duration > 0 && D.set(t, setTimeout(() => A(t), i.duration)), t;
49
+ }
50
+ function A(e) {
51
+ let t = E.findIndex((t) => t.id === e);
52
+ if (t < 0) return;
53
+ let n = E[t];
54
+ clearTimeout(D.get(e)), D.delete(e), E.splice(t, 1), typeof n.onClose == "function" && n.onClose();
55
+ }
56
+ function j() {
57
+ if (!E.length) return;
58
+ let e = E.slice();
59
+ E.splice(0, E.length), e.forEach((e) => {
60
+ clearTimeout(D.get(e.id)), D.delete(e.id), typeof e.onClose == "function" && e.onClose();
61
+ });
62
+ }
63
+ function M(e) {
64
+ let t = e.getBoundingClientRect(), n = e.offsetParent.getBoundingClientRect();
65
+ e.style.top = t.top - n.top + "px", e.style.left = t.left - n.left + "px";
66
+ }
67
+ return S({
68
+ push: k,
69
+ close: A,
70
+ clear: j
71
+ }), (n, u) => (l(), a("div", _, [s(t, {
72
+ name: "xypp-toast",
73
+ onBeforeLeave: M
74
+ }, {
75
+ default: g(() => [(l(!0), a(e, null, d(h(E), (e) => (l(), a("div", {
76
+ key: e.id,
77
+ class: "xypp-toast__item"
78
+ }, [
79
+ o("span", { class: c(["xypp-toast__icon", `xypp-toast__icon--${e.type}`]) }, [(l(), a("svg", v, [o("path", {
80
+ d: C[e.type] || C.info,
81
+ stroke: "currentColor",
82
+ "stroke-width": "1.6",
83
+ "stroke-linecap": "round",
84
+ "stroke-linejoin": "round"
85
+ }, null, 8, y)]))], 2),
86
+ e.render ? (l(), r(f(e.render), {
87
+ key: 0,
88
+ class: "xypp-toast__message"
89
+ })) : (l(), a("span", b, m(e.text), 1)),
90
+ e.closable ? (l(), a("span", {
91
+ key: 2,
92
+ class: "xypp-toast__close",
93
+ onClick: (t) => A(e.id)
94
+ }, "×", 8, x)) : i("", !0)
95
+ ]))), 128))]),
96
+ _: 1
97
+ })]));
98
+ }
99
+ }, C = null;
100
+ function w() {
101
+ if (typeof document > "u") return null;
102
+ if (!C) {
103
+ let e = document.createElement("div");
104
+ e.className = "xypp-toast-root", document.body.appendChild(e);
105
+ let t = s(S);
106
+ u(t, e), C = t.component.exposed;
107
+ }
108
+ return C;
109
+ }
110
+ function T(e, t) {
111
+ return typeof e == "object" && e && !Array.isArray(e) ? e : {
112
+ message: e,
113
+ ...t
114
+ };
115
+ }
116
+ var E = {
117
+ show(e, t) {
118
+ let n = w();
119
+ return n ? n.push(T(e, t)) : void 0;
120
+ },
121
+ clear() {
122
+ let e = w();
123
+ e && e.clear();
124
+ }
125
+ };
126
+ [
127
+ "success",
128
+ "error",
129
+ "warning",
130
+ "info"
131
+ ].forEach((e) => {
132
+ E[e] = (t, n) => E.show(t, {
133
+ ...n,
134
+ type: e
135
+ });
136
+ }), E.install = (e) => {
137
+ e.config.globalProperties.$toast = E;
138
+ };
139
+ //#endregion
140
+ export { E as t };
package/dist/Toast.css ADDED
@@ -0,0 +1 @@
1
+ .xypp-toast{z-index:3000;pointer-events:none;position:fixed;top:24px;left:0;right:0}.xypp-toast__item{box-sizing:border-box;color:#333;pointer-events:auto;background-color:#fff;border:1px solid #ebedf0;border-radius:8px;align-items:center;gap:8px;width:fit-content;max-width:calc(100vw - 32px);margin:10px auto 0;padding:10px 16px;font-size:14px;display:flex;box-shadow:0 4px 16px #00000014}.xypp-toast__item:first-child{margin-top:0}.xypp-toast__icon{color:#fff;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:18px;height:18px;display:inline-flex}.xypp-toast__icon svg{width:12px;height:12px;display:block}.xypp-toast__icon--success{background-color:#52c41a}.xypp-toast__icon--error{background-color:#ff4d4f}.xypp-toast__icon--warning{background-color:#faad14}.xypp-toast__icon--info{background-color:#3369ff}.xypp-toast__message{word-break:break-all;line-height:1.5}.xypp-toast__close{color:#999;cursor:pointer;margin-left:4px;font-size:16px;line-height:1;transition:color .15s}.xypp-toast__close:hover{color:#333}.xypp-toast-enter-active,.xypp-toast-leave-active,.xypp-toast-move{transition:opacity .25s cubic-bezier(.4,0,.2,1),transform .25s cubic-bezier(.4,0,.2,1)}.xypp-toast-enter-from,.xypp-toast-leave-to{opacity:0;transform:translateY(-12px)}.xypp-toast-leave-active{pointer-events:none;margin:0;position:absolute}
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .xypp-avatar{color:#fff;-webkit-user-select:none;user-select:none;background-color:#3369ff;border-radius:50%;justify-content:center;align-items:center;font-weight:500;display:inline-flex;overflow:hidden}.xypp-avatar .avatar-img{object-fit:cover;width:100%;height:100%}.xypp-avatar .avatar-text{font-size:14px}.xypp-dropdown{display:inline-block}.xypp-dropdown__trigger{cursor:pointer;display:inline-block}.xypp-dropdown__menu{z-index:2000;box-sizing:border-box;will-change:opacity, transform;background:#fff;border:1px solid #ebedf0;border-radius:8px;min-width:140px;max-height:320px;padding:6px;position:absolute;overflow-y:auto;box-shadow:0 6px 24px #0000001a}.xypp-dropdown__menu--bottom,.xypp-dropdown__menu--bottom-start,.xypp-dropdown__menu--bottom-end{transform-origin:top}.xypp-dropdown__menu--top,.xypp-dropdown__menu--top-start,.xypp-dropdown__menu--top-end{transform-origin:bottom}.xypp-dropdown-item{color:#333;cursor:pointer;white-space:nowrap;padding:8px;font-size:14px;line-height:1.5;transition:background-color .15s}.xypp-dropdown-item:hover{background-color:#46598c1a;border-radius:4px}.xypp-dropdown-item--disabled{color:#c0c4cc;cursor:not-allowed}.xypp-dropdown-item--disabled:hover{background-color:#0000}.xypp-dropdown-item--active{color:#3369ff;background-color:#3369ff14;border-radius:4px;font-weight:500}.xypp-dropdown-item--divided{border-top:1px solid #ebedf0;margin-top:4px;padding-top:12px}.xypp-dropdown-enter-active,.xypp-dropdown-leave-active{transition:opacity .25s cubic-bezier(.4,0,.2,1),transform .25s cubic-bezier(.4,0,.2,1)}.xypp-dropdown-enter-from,.xypp-dropdown-leave-to{opacity:0;transform:scaleY(.85)}.xypp-tabs{display:block}.xypp-tabs__nav{box-sizing:border-box;border-bottom:1px solid #ebedf0;align-items:center;display:flex;position:relative}.xypp-tabs__item{color:#666;cursor:pointer;white-space:nowrap;background:0 0;border:0;justify-content:center;align-items:center;height:40px;margin:0;padding:0 16px;font-family:inherit;font-size:14px;line-height:1;transition:color .2s;display:inline-flex;position:relative}.xypp-tabs__item:hover{color:#3369ff}.xypp-tabs__item.is-active{color:#3369ff;font-weight:500}.xypp-tabs__item.is-disabled{color:#c0c4cc;cursor:not-allowed}.xypp-tabs__item.is-disabled:hover{color:#c0c4cc}.xypp-tabs__label{pointer-events:none;display:inline-block}.xypp-tabs__bar{opacity:0;pointer-events:none;will-change:transform, width;background-color:#3369ff;border-radius:1px;height:2px;transition:opacity .15s;position:absolute;bottom:0;left:0}.xypp-tabs__bar.is-ready{transition:transform .28s cubic-bezier(.4,0,.2,1),width .28s cubic-bezier(.4,0,.2,1),opacity .15s}.xypp-tabs__content{padding-top:16px}.xypp-tabs--stretch .xypp-tabs__item{flex:1 1 0;padding:0 8px}.xypp-tabs--card .xypp-tabs__nav{background-color:#f2f4f8;border-bottom:0;border-radius:8px;padding:3px}.xypp-tabs--card .xypp-tabs__item{z-index:1;height:34px;padding:0 16px}.xypp-tabs--card .xypp-tabs__bar{background-color:#fff;border-radius:6px;height:0;top:0;bottom:auto;box-shadow:0 1px 2px #0000000f}.xypp-tab-pane.is-active{animation:.2s cubic-bezier(.4,0,.2,1) xypp-tab-pane-in}@keyframes xypp-tab-pane-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.xypp-toast{z-index:3000;pointer-events:none;position:fixed;top:24px;left:0;right:0}.xypp-toast__item{box-sizing:border-box;color:#333;pointer-events:auto;background-color:#fff;border:1px solid #ebedf0;border-radius:8px;align-items:center;gap:8px;width:fit-content;max-width:calc(100vw - 32px);margin:10px auto 0;padding:10px 16px;font-size:14px;display:flex;box-shadow:0 4px 16px #00000014}.xypp-toast__item:first-child{margin-top:0}.xypp-toast__icon{color:#fff;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:18px;height:18px;display:inline-flex}.xypp-toast__icon svg{width:12px;height:12px;display:block}.xypp-toast__icon--success{background-color:#52c41a}.xypp-toast__icon--error{background-color:#ff4d4f}.xypp-toast__icon--warning{background-color:#faad14}.xypp-toast__icon--info{background-color:#3369ff}.xypp-toast__message{word-break:break-all;line-height:1.5}.xypp-toast__close{color:#999;cursor:pointer;margin-left:4px;font-size:16px;line-height:1;transition:color .15s}.xypp-toast__close:hover{color:#333}.xypp-toast-enter-active,.xypp-toast-leave-active,.xypp-toast-move{transition:opacity .25s cubic-bezier(.4,0,.2,1),transform .25s cubic-bezier(.4,0,.2,1)}.xypp-toast-enter-from,.xypp-toast-leave-to{opacity:0;transform:translateY(-12px)}.xypp-toast-leave-active{pointer-events:none;margin:0;position:absolute}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import { t as e } from "./Avatar-D0BZXcC3.js";
2
+ import { n as t, t as n } from "./Dropdown-Ci_m-tLB.js";
3
+ import { n as r, t as i } from "./Tabs-DwkrDtlX.js";
4
+ import { t as a } from "./Toast-5vg695pO.js";
5
+ //#region packages/index.js
6
+ var o = [
7
+ e,
8
+ n,
9
+ i,
10
+ a
11
+ ], s = { install(e) {
12
+ o.forEach((t) => e.use(t));
13
+ } };
14
+ //#endregion
15
+ export { e as XAvatar, n as XDropdown, t as XDropdownItem, r as XTabPane, i as XTabs, a as XToast, s as default };
@@ -0,0 +1,2 @@
1
+ import { t as e } from "../Avatar-D0BZXcC3.js";
2
+ export { e as default };
@@ -0,0 +1,2 @@
1
+ import { n as e, t } from "../Dropdown-Ci_m-tLB.js";
2
+ export { e as DropdownItem, t as default };
@@ -0,0 +1,2 @@
1
+ import { n as e, t } from "../Tabs-DwkrDtlX.js";
2
+ export { e as TabPane, t as default };
@@ -0,0 +1,2 @@
1
+ import { t as e } from "../Toast-5vg695pO.js";
2
+ export { e as default };
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "xypp-component",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "行内业务组件库(Vue 3)",
5
+ "keywords": [
6
+ "vue3",
7
+ "vue",
8
+ "component",
9
+ "component-library",
10
+ "ui"
11
+ ],
12
+ "type": "module",
13
+ "main": "dist/index.js",
14
+ "module": "dist/index.js",
15
+ "style": "dist/index.css",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "exports": {
20
+ ".": "./dist/index.js",
21
+ "./style": "./dist/index.css",
22
+ "./avatar": "./dist/ui/Avatar.js",
23
+ "./avatar/style": "./dist/Avatar.css",
24
+ "./dropdown": "./dist/ui/Dropdown.js",
25
+ "./dropdown/style": "./dist/Dropdown.css",
26
+ "./tabs": "./dist/ui/Tabs.js",
27
+ "./tabs/style": "./dist/Tabs.css",
28
+ "./toast": "./dist/ui/Toast.js",
29
+ "./toast/style": "./dist/Toast.css"
30
+ },
31
+ "scripts": {
32
+ "dev": "vite",
33
+ "build": "vite build",
34
+ "preview": "vite preview",
35
+ "prepublishOnly": "npm run build"
36
+ },
37
+ "peerDependencies": {
38
+ "vue": "^3.5.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^24.12.0",
42
+ "@vitejs/plugin-vue": "^6.0.5",
43
+ "fast-glob": "^3.3.3",
44
+ "sass": "^1.98.0",
45
+ "vite": "^8.0.1",
46
+ "vue": "^3.5.30"
47
+ }
48
+ }