ep-craft 0.1.3 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ep-craft",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "A Vue 3 component library based on element-plus with ep- prefix",
5
5
  "type": "module",
6
6
  "main": "./dist/ep-craft.js",
@@ -1,4 +1,5 @@
1
1
  @use 'sass:map';
2
+ @use 'sass:list';
2
3
 
3
4
  @use 'common/var' as *;
4
5
  @use 'mixins/button' as *;
@@ -16,8 +17,84 @@ $button-icon-span-gap: map.merge(
16
17
  $button-icon-span-gap
17
18
  );
18
19
 
20
+ @mixin button-reverse-variant(
21
+ $text-color,
22
+ $border-color,
23
+ $hover-bg-color,
24
+ $active-bg-color,
25
+ $disabled-bg-color: getCssVar('color-white')
26
+ ) {
27
+ @include set-css-var-value(('button', 'text-color'), $text-color);
28
+ @include set-css-var-value(('button', 'bg-color'), getCssVar('color-white'));
29
+ @include set-css-var-value(('button', 'border-color'), $border-color);
30
+ @include set-css-var-value(('button', 'hover', 'text-color'), $text-color);
31
+ @include set-css-var-value(('button', 'hover', 'bg-color'), $hover-bg-color);
32
+ @include set-css-var-value(('button', 'hover', 'border-color'), $border-color);
33
+ @include set-css-var-value(('button', 'active', 'text-color'), $text-color);
34
+ @include set-css-var-value(('button', 'active', 'bg-color'), $active-bg-color);
35
+ @include set-css-var-value(('button', 'active', 'border-color'), $border-color);
36
+ @include set-css-var-value(('button', 'disabled', 'text-color'), $text-color);
37
+ @include set-css-var-value(('button', 'disabled', 'bg-color'), $disabled-bg-color);
38
+ @include set-css-var-value(('button', 'disabled', 'border-color'), $border-color);
39
+
40
+ // 禁用态整体 40% 透明(保持实色,符合 Figma 设计)
41
+ @include when(disabled) {
42
+ opacity: 0.4;
43
+ }
44
+ }
45
+
46
+ // Button 专用浅色(hover/active 背景),公共色板未覆盖,集中在此管理
47
+ $button-plain-hover-bg: (
48
+ primary: #f5f8ff,
49
+ success: #f3fbf9,
50
+ warning: #fff6eb,
51
+ danger: #fff5f5,
52
+ );
53
+ $button-plain-active-bg: (
54
+ primary: #e5edff,
55
+ success: #e7f8f3,
56
+ warning: #ffe8cc,
57
+ danger: #ffc9c9,
58
+ );
59
+ // info plain 的 hover 浅背景,公共色板未覆盖
60
+ $button-info-plain-hover-bg: #f7f8fa;
61
+
62
+ // 各类型 plain 样式配置:text/border 色、hover 背景、active 背景、禁用背景
63
+ $button-plain-config: (
64
+ primary: (
65
+ $color-primary,
66
+ $color-primary,
67
+ map.get($button-plain-hover-bg, primary),
68
+ map.get($button-plain-active-bg, primary),
69
+ transparent,
70
+ ),
71
+ success: (
72
+ $color-success,
73
+ $color-success,
74
+ map.get($button-plain-hover-bg, success),
75
+ map.get($button-plain-active-bg, success),
76
+ transparent,
77
+ ),
78
+ warning: (
79
+ $color-warning,
80
+ $color-warning,
81
+ map.get($button-plain-hover-bg, warning),
82
+ map.get($button-plain-active-bg, warning),
83
+ transparent,
84
+ ),
85
+ danger: (
86
+ $color-danger,
87
+ $color-danger,
88
+ map.get($button-plain-hover-bg, danger),
89
+ map.get($button-plain-active-bg, danger),
90
+ transparent,
91
+ ),
92
+ );
93
+
19
94
  @include b(button) {
20
95
  @include set-component-css-var('button', $button);
96
+ // 默认按钮(未指定 type)样式与 primary 保持一致
97
+ @include button-variant(primary);
21
98
  }
22
99
 
23
100
  @include b(button) {
@@ -97,17 +174,14 @@ $button-icon-span-gap: map.merge(
97
174
  }
98
175
 
99
176
  @include when(plain) {
100
- @include css-var-from-global(
101
- ('button', 'hover', 'text-color'),
102
- ('color', 'primary')
103
- );
104
- @include css-var-from-global(
105
- ('button', 'hover', 'bg-color'),
106
- ('fill-color', 'blank')
107
- );
108
- @include css-var-from-global(
109
- ('button', 'hover', 'border-color'),
110
- ('color', 'primary')
177
+ // 默认朴素按钮样式与 primary + plain 保持一致
178
+ $cfg: map.get($button-plain-config, primary);
179
+ @include button-reverse-variant(
180
+ $color-primary,
181
+ list.nth($cfg, 2),
182
+ list.nth($cfg, 3),
183
+ list.nth($cfg, 4),
184
+ list.nth($cfg, 5)
111
185
  );
112
186
  }
113
187
 
@@ -127,6 +201,14 @@ $button-icon-span-gap: map.merge(
127
201
  background-color: getCssVar('button', 'disabled', 'bg-color');
128
202
  border-color: getCssVar('button', 'disabled', 'border-color');
129
203
  }
204
+
205
+ // 非 plain 按钮禁用时删除边框
206
+ &:not(.is-plain) {
207
+ &,
208
+ &:hover {
209
+ border-color: transparent;
210
+ }
211
+ }
130
212
  }
131
213
 
132
214
  @include when(loading) {
@@ -286,9 +368,104 @@ $button-icon-span-gap: map.merge(
286
368
  }
287
369
  }
288
370
 
289
- @each $type in (primary, success, warning, danger, info) {
371
+ // default 类型样式与 primary 保持一致
372
+ @include m(default) {
373
+ @include button-variant(primary);
374
+
375
+ &.is-plain {
376
+ $cfg: map.get($button-plain-config, primary);
377
+ @include button-reverse-variant(
378
+ getCssVar('color-primary'),
379
+ list.nth($cfg, 2),
380
+ list.nth($cfg, 3),
381
+ list.nth($cfg, 4),
382
+ list.nth($cfg, 5)
383
+ );
384
+
385
+ // plain 禁用态按 Figma 设计:透明背景 + 主题色 + 整体 40% 透明
386
+ &.is-disabled {
387
+ &,
388
+ &:hover,
389
+ &:focus,
390
+ &:active {
391
+ color: getCssVar('color-primary');
392
+ background-color: transparent;
393
+ border-color: list.nth($cfg, 2);
394
+ opacity: 0.4;
395
+ }
396
+ }
397
+ }
398
+ }
399
+
400
+ @each $type in (primary, success, warning, danger) {
290
401
  @include m($type) {
291
402
  @include button-variant($type);
403
+
404
+ &.is-plain {
405
+ $cfg: map.get($button-plain-config, $type);
406
+ // primary 文字色沿用全局 CSS 变量,其余用配置色值
407
+ $text: list.nth($cfg, 1);
408
+ @if $type == primary {
409
+ $text: getCssVar('color-primary');
410
+ }
411
+
412
+ @include button-reverse-variant(
413
+ $text,
414
+ list.nth($cfg, 2),
415
+ list.nth($cfg, 3),
416
+ list.nth($cfg, 4),
417
+ list.nth($cfg, 5)
418
+ );
419
+
420
+ // plain 禁用态按 Figma 设计:透明背景 + 主题色 + 整体 40% 透明
421
+ // 覆盖 button-plain mixin 内置的浅色禁用样式
422
+ &.is-disabled {
423
+ &,
424
+ &:hover,
425
+ &:focus,
426
+ &:active {
427
+ color: $text;
428
+ background-color: transparent;
429
+ border-color: list.nth($cfg, 2);
430
+ opacity: 0.4;
431
+ }
432
+ }
433
+ }
434
+ }
435
+ }
436
+
437
+ @include m(info) {
438
+ $info-text: map.get($text-color, 'primary');
439
+ $info-border: map.get($colors, 'info', 'light-3');
440
+
441
+ @include button-variant(info);
442
+ @include set-css-var-value(('button', 'text-color'), $info-text);
443
+ @include set-css-var-value(('button', 'hover', 'text-color'), $info-text);
444
+ @include set-css-var-value(('button', 'active', 'text-color'), $info-text);
445
+ @include set-css-var-value(('button', 'disabled', 'text-color'), rgba($info-text, 0.4));
446
+
447
+ &.is-plain {
448
+ // 禁用背景保持白色,其余同 button-reverse-variant 默认(含整体 40% 透明)
449
+ @include button-reverse-variant(
450
+ $info-text,
451
+ $info-border,
452
+ $button-info-plain-hover-bg,
453
+ $color-info
454
+ );
455
+
456
+ // plain + info 禁用态按 Figma 设计:白底 + 实色 + 整体 40% 透明
457
+ // 覆盖 button-plain mixin 内置的浅色禁用样式
458
+ &.is-disabled {
459
+ &,
460
+ &:hover,
461
+ &:focus,
462
+ &:active {
463
+ color: $info-text;
464
+ background-color: getCssVar('color-white');
465
+ border-color: $info-border;
466
+ opacity: 0.4;
467
+ }
468
+ }
292
469
  }
293
470
  }
294
471
 
@@ -307,6 +484,7 @@ $button-icon-span-gap: map.merge(
307
484
  }
308
485
  }
309
486
 
487
+
310
488
  & {
311
489
  @include button-size(
312
490
  map.get($button-padding-vertical, $size) - $button-border-width,
@@ -19,22 +19,40 @@ $colors: map.deep-merge(
19
19
  'white': #ffffff,
20
20
  'black': #000000,
21
21
  'primary': (
22
- 'base': #409eff,
22
+ 'base': #1c64fd,
23
+ 'light-3': #4480ff,
24
+ 'light-5': rgba(28, 100, 253, 0.4),
25
+ 'dark-2': #164ed1,
23
26
  ),
24
27
  'success': (
25
- 'base': #67c23a,
28
+ 'base': #12b886,
29
+ 'light-3': #59cdaa,
30
+ 'light-5': rgba(18, 184, 134, 0.4),
31
+ 'dark-2': #0f956c,
26
32
  ),
27
33
  'warning': (
28
- 'base': #e6a23c,
34
+ 'base': #f57f00,
35
+ 'light-3': #ffa94d,
36
+ 'light-5': rgba(245, 127, 0, 0.4),
37
+ 'dark-2': #d05706,
29
38
  ),
30
39
  'danger': (
31
- 'base': #f56c6c,
40
+ 'base': #f14646,
41
+ 'light-3': #fb7c7c,
42
+ 'light-5': rgba(241, 70, 70, 0.4),
43
+ 'dark-2': #dc2c2c,
32
44
  ),
33
45
  'error': (
34
- 'base': #f56c6c,
46
+ 'base': #f14646,
47
+ 'light-3': #fb7c7c,
48
+ 'light-5': rgba(241, 70, 70, 0.4),
49
+ 'dark-2': #dc2c2c,
35
50
  ),
36
51
  'info': (
37
- 'base': #909399,
52
+ 'base': #f2f3f5,
53
+ 'light-3': #e5e6eb,
54
+ 'light-5': rgba(242, 243, 245, 0.4),
55
+ 'dark-2': #c9cbd4,
38
56
  ),
39
57
  ),
40
58
  $colors
@@ -98,8 +116,8 @@ $color-info: map.get($colors, 'info', 'base') !default;
98
116
  $text-color: () !default;
99
117
  $text-color: map.merge(
100
118
  (
101
- 'primary': #303133,
102
- 'regular': #606266,
119
+ 'primary': #1d1f29,
120
+ 'regular': #1d1f29,
103
121
  'secondary': #909399,
104
122
  'placeholder': #a8abb2,
105
123
  'disabled': #c0c4cc,
@@ -815,8 +833,8 @@ $button-font-size: map.merge(
815
833
  (
816
834
  'large': getCssVar('font-size', 'base'),
817
835
  'default': getCssVar('font-size', 'base'),
818
- 'small': 12px,
819
- 'mini': 12px,
836
+ 'small': getCssVar('font-size', 'base'),
837
+ 'mini': getCssVar('font-size', 'extra-small'),
820
838
  ),
821
839
  $button-font-size
822
840
  );
@@ -1,171 +0,0 @@
1
- import { defineComponent as Z, useSlots as j, inject as G, computed as a, ref as oo, Text as eo, openBlock as d, createBlock as m, resolveDynamicComponent as C, mergeProps as to, withCtx as x, createElementBlock as T, Fragment as ro, renderSlot as _, unref as N, normalizeClass as K, createCommentVNode as A } from "vue";
2
- import { ElIcon as lo } from "element-plus/es/components/icon/index.mjs";
3
- import { useFormSize as no, useFormDisabled as ao } from "element-plus/es/components/form/src/hooks/use-form-common-props.mjs";
4
- import { useFormItem as so } from "element-plus/es/components/form/src/hooks/use-form-item.mjs";
5
- import { useGlobalConfig as io } from "element-plus/es/components/config-provider/src/hooks/use-global-config.mjs";
6
- import { buttonGroupContextKey as co } from "element-plus/es/components/button/src/constants.mjs";
7
- import { buttonEmits as uo, buttonProps as vo } from "./button.js";
8
- import { TinyColor as po } from "../../node_modules/@ctrl/tinycolor/dist/module/index.js";
9
- const b = "el", k = "button", So = /* @__PURE__ */ Z({
10
- name: "EpButton",
11
- __name: "EpButton",
12
- props: vo,
13
- emits: uo,
14
- setup(U, { expose: q, emit: H }) {
15
- const w = lo, e = U, J = H, h = j(), L = (o = "") => o ? `${b}-${k}-${o}` : `${b}-${k}`, B = (o) => o ? `${b}-${k}--${o}` : "", i = (o, r = !0) => o && r ? `is-${o}` : "", l = (o) => `--${b}-${k}-${o}`, g = (o) => `--${b}-${o}`, y = (o) => {
16
- const r = {};
17
- for (const n in o) o[n] && (r[`--${b}-${k}-${n}`] = o[n]);
18
- return r;
19
- }, u = G(co, void 0), v = io("button"), { form: S } = so(), I = no(a(() => u == null ? void 0 : u.size)), c = ao(), E = oo(), z = a(
20
- () => {
21
- var o;
22
- return e.type || (u == null ? void 0 : u.type) || ((o = v.value) == null ? void 0 : o.type) || "";
23
- }
24
- ), M = a(
25
- () => {
26
- var o;
27
- return e.autoInsertSpace ?? ((o = v.value) == null ? void 0 : o.autoInsertSpace) ?? !1;
28
- }
29
- ), F = a(() => {
30
- var o;
31
- return e.plain ?? ((o = v.value) == null ? void 0 : o.plain) ?? !1;
32
- }), O = a(() => {
33
- var o;
34
- return e.round ?? ((o = v.value) == null ? void 0 : o.round) ?? !1;
35
- }), V = a(() => {
36
- var o;
37
- return e.text ?? ((o = v.value) == null ? void 0 : o.text) ?? !1;
38
- }), Q = a(() => {
39
- var o;
40
- return e.dashed ?? ((o = v.value) == null ? void 0 : o.dashed) ?? !1;
41
- }), R = a(() => e.tag === "button" ? {
42
- ariaDisabled: c.value || e.loading,
43
- disabled: c.value || e.loading,
44
- autofocus: e.autofocus,
45
- type: e.nativeType
46
- } : {}), D = a(() => {
47
- var r;
48
- const o = (r = h.default) == null ? void 0 : r.call(h);
49
- if (M.value && (o == null ? void 0 : o.length) === 1) {
50
- const n = o[0];
51
- if ((n == null ? void 0 : n.type) === eo) {
52
- const t = n.children;
53
- return new RegExp("^\\p{Unified_Ideograph}{2}$", "u").test(t.trim());
54
- }
55
- }
56
- return !1;
57
- }), W = (o) => {
58
- if (c.value || e.loading) {
59
- o.stopPropagation();
60
- return;
61
- }
62
- e.nativeType === "reset" && (S == null || S.resetFields()), J("click", o);
63
- };
64
- function s(o, r = 20) {
65
- return o.mix("#141414", r).toString();
66
- }
67
- const X = a(() => {
68
- let o = {}, r = e.color;
69
- if (r) {
70
- const n = r.match(/var\((.*?)\)/);
71
- n && (r = window.getComputedStyle(window.document.documentElement).getPropertyValue(n[1]));
72
- const t = new po(r), p = e.dark ? t.tint(20).toString() : s(t, 20);
73
- if (F.value)
74
- o = y({
75
- "bg-color": e.dark ? s(t, 90) : t.tint(90).toString(),
76
- "text-color": r,
77
- "border-color": e.dark ? s(t, 50) : t.tint(50).toString(),
78
- "hover-text-color": `var(${g("color-white")})`,
79
- "hover-bg-color": r,
80
- "hover-border-color": r,
81
- "active-bg-color": p,
82
- "active-text-color": `var(${g("color-white")})`,
83
- "active-border-color": p
84
- }), c.value && (o[l("disabled-bg-color")] = e.dark ? s(t, 90) : t.tint(90).toString(), o[l("disabled-text-color")] = e.dark ? s(t, 50) : t.tint(50).toString(), o[l("disabled-border-color")] = e.dark ? s(t, 80) : t.tint(80).toString());
85
- else if (e.link || V.value) {
86
- const f = e.dark ? s(t, 30) : t.tint(30).toString();
87
- if (o = y({
88
- "text-color": r,
89
- "hover-text-color": f,
90
- "active-text-color": p
91
- }), e.link && (o[l("hover-link-text-color")] = f, o[l("active-color")] = p), c.value) {
92
- const $ = e.dark ? s(t, 50) : t.tint(50).toString();
93
- o[l("disabled-bg-color")] = "transparent", o[l("disabled-text-color")] = $, o[l("disabled-border-color")] = "transparent";
94
- }
95
- } else {
96
- const f = e.dark ? s(t, 30) : t.tint(30).toString(), $ = t.isDark() ? `var(${g("color-white")})` : `var(${g("color-black")})`;
97
- if (o = y({
98
- "bg-color": r,
99
- "text-color": $,
100
- "border-color": r,
101
- "hover-bg-color": f,
102
- "hover-text-color": $,
103
- "hover-border-color": f,
104
- "active-bg-color": p,
105
- "active-border-color": p
106
- }), c.value) {
107
- const P = e.dark ? s(t, 50) : t.tint(50).toString();
108
- o[l("disabled-bg-color")] = P, o[l("disabled-text-color")] = e.dark ? "rgba(255, 255, 255, 0.5)" : `var(${g("color-white")})`, o[l("disabled-border-color")] = P;
109
- }
110
- }
111
- }
112
- return o;
113
- }), Y = a(() => [
114
- L(),
115
- B(z.value),
116
- B(I.value),
117
- i("disabled", c.value),
118
- i("loading", e.loading),
119
- i("plain", F.value),
120
- i("round", O.value),
121
- i("circle", e.circle),
122
- i("text", V.value),
123
- i("dashed", Q.value),
124
- i("link", e.link),
125
- i("has-bg", e.bg)
126
- ]);
127
- return q({
128
- ref: E,
129
- size: I,
130
- type: z,
131
- disabled: c,
132
- shouldAddSpace: D
133
- }), (o, r) => (d(), m(C(o.tag), to({
134
- ref_key: "_ref",
135
- ref: E
136
- }, R.value, {
137
- class: Y.value,
138
- style: X.value,
139
- onClick: W
140
- }), {
141
- default: x(() => [
142
- o.loading ? (d(), T(ro, { key: 0 }, [
143
- o.$slots.loading ? _(o.$slots, "loading", { key: 0 }) : (d(), m(N(w), {
144
- key: 1,
145
- class: K("is-loading")
146
- }, {
147
- default: x(() => [
148
- (d(), m(C(o.loadingIcon)))
149
- ]),
150
- _: 1
151
- }))
152
- ], 64)) : o.icon || o.$slots.icon ? (d(), m(N(w), { key: 1 }, {
153
- default: x(() => [
154
- o.icon ? (d(), m(C(o.icon), { key: 0 })) : _(o.$slots, "icon", { key: 1 })
155
- ]),
156
- _: 3
157
- })) : A("", !0),
158
- o.$slots.default ? (d(), T("span", {
159
- key: 2,
160
- class: K({ "el-button__text--expand": D.value })
161
- }, [
162
- _(o.$slots, "default")
163
- ], 2)) : A("", !0)
164
- ]),
165
- _: 3
166
- }, 16, ["class", "style"]));
167
- }
168
- });
169
- export {
170
- So as default
171
- };
@@ -1,4 +0,0 @@
1
- import f from "./EpButton.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,95 +0,0 @@
1
- import { Loading as e } from "@element-plus/icons-vue";
2
- const o = [
3
- "default",
4
- "primary",
5
- "success",
6
- "warning",
7
- "info",
8
- "danger",
9
- "text",
10
- ""
11
- ], n = ["button", "submit", "reset"], l = {
12
- /** 按钮尺寸 */
13
- size: {
14
- type: String,
15
- values: ["", "large", "default", "small", "mini"]
16
- },
17
- /** 是否禁用 */
18
- disabled: {
19
- type: Boolean,
20
- default: void 0
21
- },
22
- /** 按钮类型 */
23
- type: {
24
- type: String,
25
- values: o,
26
- default: ""
27
- },
28
- /** 图标组件 */
29
- icon: {
30
- type: [String, Object, Function]
31
- },
32
- /** 原生 button 类型 */
33
- nativeType: {
34
- type: String,
35
- values: n,
36
- default: "button"
37
- },
38
- /** 是否为加载中状态 */
39
- loading: Boolean,
40
- /** 自定义加载中图标组件 */
41
- loadingIcon: {
42
- type: [String, Object, Function],
43
- default: () => e
44
- },
45
- /** 是否为朴素按钮 */
46
- plain: {
47
- type: Boolean,
48
- default: void 0
49
- },
50
- /** 是否为文字按钮 */
51
- text: {
52
- type: Boolean,
53
- default: void 0
54
- },
55
- /** 是否为链接按钮 */
56
- link: Boolean,
57
- /** 文字按钮背景色是否常亮 */
58
- bg: Boolean,
59
- /** 原生 autofocus */
60
- autofocus: Boolean,
61
- /** 是否为圆角按钮 */
62
- round: {
63
- type: Boolean,
64
- default: void 0
65
- },
66
- /** 是否为圆形按钮 */
67
- circle: Boolean,
68
- /** 是否为虚线按钮 */
69
- dashed: {
70
- type: Boolean,
71
- default: void 0
72
- },
73
- /** 自定义按钮颜色,自动计算 hover 和 active 颜色 */
74
- color: String,
75
- /** 暗黑模式,将 color 自动转换为暗黑模式颜色 */
76
- dark: Boolean,
77
- /** 是否在两个中文字符之间自动插入空格 */
78
- autoInsertSpace: {
79
- type: Boolean,
80
- default: void 0
81
- },
82
- /** 自定义元素标签 */
83
- tag: {
84
- type: [String, Object],
85
- default: "button"
86
- }
87
- }, i = {
88
- click: (t) => t instanceof MouseEvent
89
- };
90
- export {
91
- i as buttonEmits,
92
- n as buttonNativeTypes,
93
- l as buttonProps,
94
- o as buttonTypes
95
- };