web-kxjl-components 1.0.1 → 1.0.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 CHANGED
@@ -10,18 +10,18 @@ npm install web-kxjl-components
10
10
 
11
11
  宿主项目需自带 `vue`、`element-plus`(peerDependencies),组件库不会重复打包这两个依赖。
12
12
 
13
+ 样式已内联进 JS,导入组件时自动注入,无需再引入 css 文件。
14
+
13
15
  按需引入(推荐):
14
16
 
15
17
  ```ts
16
18
  import { KxEmpty } from "web-kxjl-components";
17
- import "web-kxjl-components/style.css";
18
19
  ```
19
20
 
20
21
  全量注册:
21
22
 
22
23
  ```ts
23
24
  import KxComponents from "web-kxjl-components";
24
- import "web-kxjl-components/style.css";
25
25
 
26
26
  app.use(KxComponents);
27
27
  ```
package/dist/index.js CHANGED
@@ -1,62 +1,45 @@
1
+ (function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`.kx-empty[data-v-392d5d37]{justify-content:center;align-items:center;width:100%;height:100%;display:flex}.kx-app-switcher__trigger[data-v-af73d3b0]{cursor:pointer;display:inline-flex}.kx-app-switcher__panel[data-v-af73d3b0]{--kx-text-primary:var(--kx-switcher-text-primary,#303133);--kx-text-regular:var(--kx-switcher-text-regular,#606266);--kx-text-disabled:var(--kx-switcher-text-disabled,#a8abb2);--kx-bg-overlay:var(--kx-switcher-bg-overlay,#fff);--kx-border-light:var(--kx-switcher-border-light,#e4e7ed);--kx-box-shadow-light:var(--kx-switcher-box-shadow-light,0 0 12px #0000001f);--kx-fill-light:var(--kx-switcher-fill-light,#f5f7fa);justify-content:flex-end;align-items:flex-start;gap:8px;min-height:80px;display:flex}.kx-app-switcher__card[data-v-af73d3b0]{background:var(--kx-bg-overlay);border:1px solid var(--kx-border-light);box-shadow:var(--kx-box-shadow-light);border-radius:8px;padding:12px}.kx-app-switcher__systems[data-v-af73d3b0]{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.kx-app-switcher__system[data-v-af73d3b0]{color:var(--kx-text-primary);text-align:left;cursor:pointer;background:0 0;border:none;border-radius:6px;align-items:center;gap:10px;padding:8px;font-size:14px;font-weight:400;display:flex}.kx-app-switcher__system[data-v-af73d3b0]:hover{background:var(--kx-fill-light)}.kx-app-switcher__system.is-disabled[data-v-af73d3b0]{color:var(--kx-text-disabled);cursor:not-allowed}.kx-app-switcher__system.is-disabled[data-v-af73d3b0]:hover{background:0 0}.kx-app-switcher__system.is-disabled .kx-app-switcher__system-icon[data-v-af73d3b0]{opacity:.4;filter:grayscale()}.kx-app-switcher__system-icon[data-v-af73d3b0]{background:var(--kx-system-icon-bg);box-sizing:border-box;border-radius:6px;flex:none;width:24px;height:24px;padding:5px;overflow:hidden}.kx-app-switcher__system[data-v-af73d3b0]:nth-child(6n+1){--kx-system-icon-bg:#4b3fe9}.kx-app-switcher__system[data-v-af73d3b0]:nth-child(6n+2){--kx-system-icon-bg:#ef883a}.kx-app-switcher__system[data-v-af73d3b0]:nth-child(6n+3){--kx-system-icon-bg:#3fade9}.kx-app-switcher__system[data-v-af73d3b0]:nth-child(6n+4){--kx-system-icon-bg:#3686ff}.kx-app-switcher__system[data-v-af73d3b0]:nth-child(6n+5){--kx-system-icon-bg:#61bb5a}.kx-app-switcher__system[data-v-af73d3b0]:nth-child(6n){--kx-system-icon-bg:#ec6589}.kx-app-switcher__icon[data-v-af73d3b0]{object-fit:contain;width:100%;height:100%;display:block}.kx-app-switcher__system-name[data-v-af73d3b0]{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kx-app-switcher__products[data-v-af73d3b0]{flex-direction:column;flex:none;gap:8px;width:190px;display:flex}.kx-app-switcher__title[data-v-af73d3b0]{color:var(--kx-text-regular);font-size:14px}.kx-app-switcher__product[data-v-af73d3b0]{height:52px;color:var(--kx-text-primary);cursor:pointer;background:linear-gradient(90deg, #fff, var(--kx-product-bg-end));border:1px solid #e2e8f0;border-radius:4px;justify-content:space-between;align-items:center;padding:0 0 0 16px;font-size:16px;font-weight:600;display:flex}.kx-app-switcher__product.is-active[data-v-af73d3b0]{border-color:var(--kx-product-border)}.kx-app-switcher__product[data-v-af73d3b0]:nth-of-type(5n+1){--kx-product-bg-end:#dde9ff;--kx-product-border:#3b6df0}.kx-app-switcher__product[data-v-af73d3b0]:nth-of-type(5n+2){--kx-product-bg-end:#f4ecff;--kx-product-border:#883eff}.kx-app-switcher__product[data-v-af73d3b0]:nth-of-type(5n+3){--kx-product-bg-end:#e2f8e8;--kx-product-border:#61bb5a}.kx-app-switcher__product[data-v-af73d3b0]:nth-of-type(5n+4){--kx-product-bg-end:#d9f2ff;--kx-product-border:#3fade9}.kx-app-switcher__product[data-v-af73d3b0]:nth-of-type(5n){--kx-product-bg-end:#ffebdd;--kx-product-border:#ef883a}.kx-app-switcher__product-icon[data-v-af73d3b0]{flex:none;width:104px;height:47px}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
1
2
  import { ElEmpty as e, ElLoadingDirective as t, ElPopover as n, ElTooltip as r } from "element-plus/es";
2
3
  import "element-plus/es/components/base/style/css";
3
4
  import "element-plus/es/components/empty/style/css";
4
- import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createStaticVNode as u, createVNode as d, defineComponent as f, normalizeClass as p, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, watch as y, withCtx as b, withDirectives as x } from "vue";
5
+ import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, normalizeClass as f, openBlock as p, ref as m, renderList as h, renderSlot as g, toDisplayString as _, watch as v, withCtx as y, withDirectives as b } from "vue";
5
6
  import "element-plus/es/components/loading/style/css";
6
7
  import "element-plus/es/components/popover/style/css";
7
8
  import "element-plus/es/components/tooltip/style/css";
8
9
  // src/components/kx-empty/index.vue?vue&type=script&setup=true&lang.ts
9
- var S = { class: "kx-empty" }, C = /*@__PURE__*/ f({
10
+ var x = { class: "kx-empty" }, S = /*@__PURE__*/ d({
10
11
  name: "KxEmpty",
11
12
  __name: "index",
12
13
  props: { description: { default: "暂无数据" } },
13
14
  setup(t) {
14
15
  return (n, r) => {
15
16
  let i = e;
16
- return m(), c("div", S, [d(i, { description: t.description }, {
17
- default: b(() => [_(n.$slots, "default", {}, void 0, !0)]),
17
+ return p(), c("div", x, [u(i, { description: t.description }, {
18
+ default: y(() => [g(n.$slots, "default", {}, void 0, !0)]),
18
19
  _: 3
19
20
  }, 8, ["description"])]);
20
21
  };
21
22
  }
22
- }), w = (e, t) => {
23
+ }), C = (e, t) => {
23
24
  let n = e.__vccOpts || e;
24
25
  for (let [e, r] of t) n[e] = r;
25
26
  return n;
26
- }, T = /*#__PURE__*/ w(C, [["__scopeId", "data-v-392d5d37"]]), E = ["src"], D = {
27
- key: 1,
28
- class: "kx-app-icon",
29
- viewBox: "0 0 24 24",
30
- "aria-hidden": "true"
31
- }, O = /*#__PURE__*/ w(/* @__PURE__ */ f({
32
- name: "KxAppIcon",
33
- __name: "app-icon",
34
- props: { src: {} },
35
- setup(e) {
36
- let t = e, n = h(!1);
37
- return y(() => t.src, () => {
38
- n.value = !1;
39
- }), (t, r) => e.src && !n.value ? (m(), c("img", {
40
- key: 0,
41
- class: "kx-app-icon",
42
- src: e.src,
43
- alt: "",
44
- onError: r[0] ||= (e) => n.value = !0
45
- }, null, 40, E)) : (m(), c("svg", D, [...r[1] ||= [u("<rect width=\"24\" height=\"24\" rx=\"6\" fill=\"var(--el-color-primary)\" data-v-352f5b8f></rect><rect x=\"5\" y=\"5\" width=\"6\" height=\"6\" rx=\"1.5\" fill=\"#fff\" data-v-352f5b8f></rect><rect x=\"13\" y=\"5\" width=\"6\" height=\"6\" rx=\"1.5\" fill=\"#fff\" data-v-352f5b8f></rect><rect x=\"5\" y=\"13\" width=\"6\" height=\"6\" rx=\"1.5\" fill=\"#fff\" data-v-352f5b8f></rect><rect x=\"13\" y=\"13\" width=\"6\" height=\"6\" rx=\"1.5\" fill=\"#fff\" data-v-352f5b8f></rect>", 5)]]));
46
- }
47
- }), [["__scopeId", "data-v-352f5b8f"]]), k = { class: "kx-app-switcher__trigger" }, A = { class: "kx-app-switcher__panel" }, j = {
27
+ }, w = /*#__PURE__*/ C(S, [["__scopeId", "data-v-392d5d37"]]), T = { class: "kx-app-switcher__trigger" }, E = { class: "kx-app-switcher__panel" }, D = {
48
28
  key: 0,
49
29
  class: "kx-app-switcher__card kx-app-switcher__systems"
50
- }, M = [
30
+ }, O = [
51
31
  "aria-disabled",
52
32
  "title",
53
33
  "onClick"
54
- ], N = { class: "kx-app-switcher__system-icon" }, P = { class: "kx-app-switcher__system-name" }, F = { class: "kx-app-switcher__card kx-app-switcher__products" }, I = [
34
+ ], k = { class: "kx-app-switcher__system-icon" }, A = ["src"], j = { class: "kx-app-switcher__system-name" }, M = { class: "kx-app-switcher__card kx-app-switcher__products" }, N = [
55
35
  "title",
56
36
  "onMouseenter",
57
37
  "onFocus",
58
38
  "onClick"
59
- ], L = { class: "kx-app-switcher__product-name" }, R = { class: "kx-app-switcher__product-icon" }, z = /*#__PURE__*/ w(/* @__PURE__ */ f({
39
+ ], P = { class: "kx-app-switcher__product-name" }, F = {
40
+ key: 0,
41
+ class: "kx-app-switcher__product-icon"
42
+ }, I = ["src"], L = /*#__PURE__*/ C(/* @__PURE__ */ d({
60
43
  name: "KxAppSwitcher",
61
44
  __name: "index",
62
45
  props: {
@@ -65,30 +48,30 @@ var S = { class: "kx-empty" }, C = /*@__PURE__*/ f({
65
48
  disabledTip: { default: "暂未开通" }
66
49
  },
67
50
  setup(u) {
68
- let f = u, S = h(!1), C = h(!1), w = h(!1), T = h([]), E = h(null), D = /^(https?:|data:|blob:|\/\/)/i;
51
+ let d = u, x = m(!1), S = m(!1), C = m(!1), w = m([]), L = m(null), R = /^(https?:|data:|blob:|\/\/)/i;
69
52
  function z(e) {
70
53
  return [...e].sort((e, t) => (e.sortNum ?? 0) - (t.sortNum ?? 0));
71
54
  }
72
- let B = a(() => T.value.find((e) => e.id === E.value)?.systems ?? []);
55
+ let B = a(() => w.value.find((e) => e.id === L.value)?.systems ?? []);
73
56
  async function V() {
74
- if (!(C.value || w.value)) {
75
- C.value = !0;
57
+ if (!(S.value || C.value)) {
58
+ S.value = !0;
76
59
  try {
77
- let e = await f.fetcher();
78
- e.code === 0 && Array.isArray(e.data) && (T.value = z(e.data).map((e) => ({
60
+ let e = await d.fetcher();
61
+ e.code === 0 && Array.isArray(e.data) && (w.value = z(e.data).map((e) => ({
79
62
  ...e,
80
63
  systems: z(e.systems ?? [])
81
- })), E.value = T.value[0]?.id ?? null, w.value = !0);
64
+ })), L.value = w.value[0]?.id ?? null, C.value = !0);
82
65
  } catch {} finally {
83
- C.value = !1;
66
+ S.value = !1;
84
67
  }
85
68
  }
86
69
  }
87
- y(S, (e) => {
70
+ v(x, (e) => {
88
71
  e && V();
89
72
  });
90
73
  function H(e) {
91
- return e ? D.test(e) ? e : f.staticFileFormat ? f.staticFileFormat(e) : e : "";
74
+ return e ? R.test(e) ? e : d.staticFileFormat ? d.staticFileFormat(e) : e : "";
92
75
  }
93
76
  function U(e) {
94
77
  if (!e.sysUrl) return;
@@ -98,16 +81,16 @@ var S = { class: "kx-empty" }, C = /*@__PURE__*/ f({
98
81
  } catch {
99
82
  return;
100
83
  }
101
- (t.protocol === "http:" || t.protocol === "https:") && (window.open(t.href, "_blank", "noopener,noreferrer"), S.value = !1);
84
+ (t.protocol === "http:" || t.protocol === "https:") && (window.open(t.href, "_blank", "noopener,noreferrer"), x.value = !1);
102
85
  }
103
- return (a, f) => {
104
- let h = r, y = e, w = n, D = t;
105
- return m(), o(w, {
106
- visible: S.value,
107
- "onUpdate:visible": f[0] ||= (e) => S.value = e,
86
+ return (a, d) => {
87
+ let m = r, v = e, C = n, R = t;
88
+ return p(), o(C, {
89
+ visible: x.value,
90
+ "onUpdate:visible": d[0] ||= (e) => x.value = e,
108
91
  trigger: "click",
109
92
  placement: "bottom-end",
110
- width: 430,
93
+ width: 480,
111
94
  "show-arrow": !1,
112
95
  "popper-style": {
113
96
  padding: 0,
@@ -116,48 +99,57 @@ var S = { class: "kx-empty" }, C = /*@__PURE__*/ f({
116
99
  boxShadow: "none"
117
100
  }
118
101
  }, {
119
- reference: b(() => [l("span", k, [_(a.$slots, "default", { visible: S.value }, void 0, !0)])]),
120
- default: b(() => [x((m(), c("div", A, [B.value.length ? (m(), c("div", j, [(m(!0), c(i, null, g(B.value, (e) => (m(), o(h, {
102
+ reference: y(() => [l("span", T, [g(a.$slots, "default", { visible: x.value }, void 0, !0)])]),
103
+ default: y(() => [b((p(), c("div", E, [B.value.length ? (p(), c("div", D, [(p(!0), c(i, null, h(B.value, (e) => (p(), o(m, {
121
104
  key: e.id,
122
105
  content: u.disabledTip,
123
106
  disabled: !!e.sysUrl,
124
107
  placement: "left"
125
108
  }, {
126
- default: b(() => [l("button", {
109
+ default: y(() => [l("button", {
127
110
  type: "button",
128
- class: p(["kx-app-switcher__system", { "is-disabled": !e.sysUrl }]),
111
+ class: f(["kx-app-switcher__system", { "is-disabled": !e.sysUrl }]),
129
112
  "aria-disabled": !e.sysUrl,
130
113
  title: e.description,
131
114
  onClick: (t) => U(e)
132
- }, [l("span", N, [d(O, { src: H(e.icon) }, null, 8, ["src"])]), l("span", P, v(e.sysName), 1)], 10, M)]),
115
+ }, [l("span", k, [e.icon ? (p(), c("img", {
116
+ key: 0,
117
+ class: "kx-app-switcher__icon",
118
+ src: H(e.icon),
119
+ alt: ""
120
+ }, null, 8, A)) : s("", !0)]), l("span", j, _(e.sysName), 1)], 10, O)]),
133
121
  _: 2
134
- }, 1032, ["content", "disabled"]))), 128))])) : s("", !0), l("div", F, [
135
- f[1] ||= l("div", { class: "kx-app-switcher__title" }, "应用切换", -1),
136
- !C.value && !T.value.length ? (m(), o(y, {
122
+ }, 1032, ["content", "disabled"]))), 128))])) : s("", !0), l("div", M, [
123
+ d[1] ||= l("div", { class: "kx-app-switcher__title" }, "应用切换", -1),
124
+ !S.value && !w.value.length ? (p(), o(v, {
137
125
  key: 0,
138
126
  "image-size": 60,
139
127
  description: "暂无应用"
140
128
  })) : s("", !0),
141
- (m(!0), c(i, null, g(T.value, (e) => (m(), c("button", {
129
+ (p(!0), c(i, null, h(w.value, (e) => (p(), c("button", {
142
130
  key: e.id,
143
131
  type: "button",
144
- class: p(["kx-app-switcher__product", { "is-active": e.id === E.value }]),
132
+ class: f(["kx-app-switcher__product", { "is-active": e.id === L.value }]),
145
133
  title: e.description,
146
- onMouseenter: (t) => E.value = e.id,
147
- onFocus: (t) => E.value = e.id,
148
- onClick: (t) => E.value = e.id
149
- }, [l("span", L, v(e.productName), 1), l("span", R, [d(O, { src: H(e.icon) }, null, 8, ["src"])])], 42, I))), 128))
150
- ])])), [[D, C.value]])]),
134
+ onMouseenter: (t) => L.value = e.id,
135
+ onFocus: (t) => L.value = e.id,
136
+ onClick: (t) => L.value = e.id
137
+ }, [l("span", P, _(e.productName), 1), e.icon ? (p(), c("span", F, [l("img", {
138
+ class: "kx-app-switcher__icon",
139
+ src: H(e.icon),
140
+ alt: ""
141
+ }, null, 8, I)])) : s("", !0)], 42, N))), 128))
142
+ ])])), [[R, S.value]])]),
151
143
  _: 3
152
144
  }, 8, ["visible"]);
153
145
  };
154
146
  }
155
- }), [["__scopeId", "data-v-5a0f26bb"]]), B = {
156
- KxEmpty: T,
157
- KxAppSwitcher: z
158
- }, V = { install(e) {
159
- Object.entries(B).forEach(([t, n]) => {
147
+ }), [["__scopeId", "data-v-af73d3b0"]]), R = {
148
+ KxEmpty: w,
149
+ KxAppSwitcher: L
150
+ }, z = { install(e) {
151
+ Object.entries(R).forEach(([t, n]) => {
160
152
  e.component(t, n);
161
153
  });
162
154
  } };
163
- export { z as KxAppSwitcher, T as KxEmpty, V as default };
155
+ export { L as KxAppSwitcher, w as KxEmpty, z as default };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "web-kxjl-components",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "公司公共组件库(Vue 3 + Element Plus)",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
7
7
  "sideEffects": [
8
- "**/*.css"
8
+ "./dist/index.js"
9
9
  ],
10
10
  "files": [
11
11
  "dist"
@@ -17,8 +17,7 @@
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
19
19
  "import": "./dist/index.js"
20
- },
21
- "./style.css": "./dist/web-kxjl-components.css"
20
+ }
22
21
  },
23
22
  "publishConfig": {
24
23
  "registry": "https://registry.npmjs.org/",
@@ -43,6 +42,7 @@
43
42
  "typescript": "~6.0.2",
44
43
  "unplugin-vue-components": "^32.1.0",
45
44
  "vite": "^8.0.12",
45
+ "vite-plugin-css-injected-by-js": "5.0.3",
46
46
  "vue": "^3.5.34",
47
47
  "vue-tsc": "^3.2.8"
48
48
  }
@@ -1,7 +0,0 @@
1
- type __VLS_Props = {
2
- /** 图标地址,为空或加载失败时显示默认图标 */
3
- src?: string;
4
- };
5
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
- declare const _default: typeof __VLS_export;
7
- export default _default;
@@ -1,2 +0,0 @@
1
- .kx-empty[data-v-392d5d37]{justify-content:center;align-items:center;width:100%;height:100%;display:flex}.kx-app-icon[data-v-352f5b8f]{object-fit:contain;width:100%;height:100%;display:block}.kx-app-switcher__trigger[data-v-5a0f26bb]{cursor:pointer;display:inline-flex}.kx-app-switcher__panel[data-v-5a0f26bb]{justify-content:flex-end;align-items:flex-start;gap:8px;min-height:80px;display:flex}.kx-app-switcher__card[data-v-5a0f26bb]{background:var(--el-bg-color-overlay);border:1px solid var(--el-border-color-light);box-shadow:var(--el-box-shadow-light);border-radius:8px;padding:12px}.kx-app-switcher__systems[data-v-5a0f26bb]{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.kx-app-switcher__system[data-v-5a0f26bb]{color:var(--el-text-color-primary);text-align:left;cursor:pointer;background:0 0;border:none;border-radius:6px;align-items:center;gap:10px;padding:8px;font-size:14px;display:flex}.kx-app-switcher__system[data-v-5a0f26bb]:hover{background:var(--el-fill-color-light)}.kx-app-switcher__system.is-disabled[data-v-5a0f26bb]{color:var(--el-text-color-disabled);cursor:not-allowed}.kx-app-switcher__system.is-disabled[data-v-5a0f26bb]:hover{background:0 0}.kx-app-switcher__system.is-disabled .kx-app-switcher__system-icon[data-v-5a0f26bb]{opacity:.4;filter:grayscale()}.kx-app-switcher__system-icon[data-v-5a0f26bb]{flex:none;width:24px;height:24px}.kx-app-switcher__system-name[data-v-5a0f26bb]{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kx-app-switcher__products[data-v-5a0f26bb]{flex-direction:column;flex:none;gap:8px;width:200px;display:flex}.kx-app-switcher__title[data-v-5a0f26bb]{color:var(--el-text-color-regular);font-size:14px}.kx-app-switcher__product[data-v-5a0f26bb]{height:56px;color:var(--el-text-color-primary);cursor:pointer;background:var(--el-fill-color-lighter);border:1px solid #0000;border-radius:8px;justify-content:space-between;align-items:center;padding:0 12px;font-size:15px;font-weight:600;display:flex}.kx-app-switcher__product.is-active[data-v-5a0f26bb]{background:var(--el-color-primary-light-9);border-color:var(--el-color-primary-light-5)}.kx-app-switcher__product-icon[data-v-5a0f26bb]{flex:none;width:36px;height:36px}
2
- /*$vite$:1*/