easy-component-ui 1.0.3 → 2.0.2
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/.github/workflows/publish.yml +28 -0
- package/components/Base.js +1 -90
- package/components/ea-alert/index.js +1 -298
- package/components/ea-alert/src/style/stylesheet.js +1 -0
- package/components/ea-aside/index.js +1 -0
- package/components/ea-avatar/index.js +1 -277
- package/components/ea-avatar/src/assets/defaultAvatar.js +1 -0
- package/components/ea-avatar/src/assets/errorAvatar.js +1 -0
- package/components/ea-avatar/src/assets/iconAndTextAvatar.js +1 -0
- package/components/ea-avatar/src/style/stylesheet.js +1 -0
- package/components/ea-backtop/index.js +1 -232
- package/components/ea-backtop/src/style/stylesheet.js +1 -0
- package/components/ea-badge/index.js +1 -160
- package/components/ea-badge/src/style/stylesheet.js +1 -0
- package/components/ea-breadcrumb/index.js +1 -0
- package/components/ea-breadcrumb/src/style/stylesheet.js +1 -0
- package/components/ea-breadcrumb-item/index.js +1 -0
- package/components/ea-breadcrumb-item/src/style/style.js +1 -0
- package/components/ea-button/index.js +1 -584
- package/components/ea-button/src/components/ButtonComm.js +1 -0
- package/components/ea-button/src/components/HrefComm.js +1 -0
- package/components/ea-button/src/style/stylesheet.js +1 -0
- package/components/ea-button-group/index.js +1 -459
- package/components/ea-button-group/src/style/stylesheet.js +1 -0
- package/components/ea-calendar/index.js +1 -409
- package/components/ea-calendar/src/style/stylesheet.js +1 -0
- package/components/ea-calendar/src/utils/createChangerElement.js +1 -0
- package/components/ea-calendar/src/utils/createThead.js +1 -0
- package/components/ea-calendar/src/utils/getDate.js +1 -0
- package/components/ea-calendar/src/utils/getUserWeekStart.js +1 -0
- package/components/ea-card/index.js +1 -77
- package/components/ea-card/src/style/stylesheet.js +1 -0
- package/components/ea-carousel/index.js +1 -434
- package/components/ea-carousel/src/style/stylesheet.js +1 -0
- package/components/ea-carousel/src/utils/handleIndexOverflow.js +1 -0
- package/components/ea-carousel-item/index.js +1 -0
- package/components/ea-carousel-item/src/style/stylesheet.js +1 -0
- package/components/ea-checkbox/index.js +1 -314
- package/components/ea-checkbox/src/style/stylesheet.js +1 -0
- package/components/ea-checkbox-group/index.js +1 -107
- package/components/ea-checkbox-group/src/style/stylesheet.js +1 -0
- package/components/ea-collapse/index.js +1 -293
- package/components/ea-collapse-item/index.js +1 -0
- package/components/ea-collapse-item/src/style/stylesheet.js +1 -0
- package/components/ea-container/index.js +1 -0
- package/components/ea-date-picker/index.js +1 -0
- package/components/ea-date-picker/src/style/stylesheet.js +1 -0
- package/components/ea-descriptions/index.js +1 -240
- package/components/ea-descriptions/src/components/contentTemplate.js +1 -0
- package/components/ea-descriptions/src/components/getTdTemplate_border.js +1 -0
- package/components/ea-descriptions/src/components/getTdTemplate_direction.js +1 -0
- package/components/ea-descriptions/src/components/getThTemplate_direction.js +1 -0
- package/components/ea-descriptions/src/components/getThTemplate_normal.js +1 -0
- package/components/ea-descriptions/src/style/stylesheet.js +1 -0
- package/components/ea-descriptions-item/index.js +1 -110
- package/components/ea-descriptions-item/src/stylesheet.js +1 -0
- package/components/ea-drawer/index.js +1 -0
- package/components/ea-drawer/src/style/stylesheet.js +1 -0
- package/components/ea-empty/index.js +1 -141
- package/components/ea-empty/src/assets/emptyStatusSVG.js +1 -0
- package/components/ea-empty/src/style/stylesheet.js +1 -0
- package/components/ea-footer/index.js +1 -0
- package/components/ea-form/index.js +1 -0
- package/components/ea-form-item/index.js +1 -0
- package/components/ea-form-item/src/style/stylesheet.js +1 -0
- package/components/ea-header/index.js +1 -0
- package/components/ea-icon/config.json +1029 -1017
- package/components/ea-icon/css/animation.css +85 -85
- package/components/ea-icon/css/fontello.css +226 -224
- package/components/ea-icon/font/fontello.eot +0 -0
- package/components/ea-icon/font/fontello.svg +350 -683
- package/components/ea-icon/font/fontello.ttf +0 -0
- package/components/ea-icon/font/fontello.woff +0 -0
- package/components/ea-icon/font/fontello.woff2 +0 -0
- package/components/ea-icon/index.js +1 -47
- package/components/ea-image/index.js +1 -412
- package/components/ea-image/src/assets/errorImage.js +1 -0
- package/components/ea-image/src/style/stylesheet.js +1 -0
- package/components/ea-image/src/utils/createPreviewTools.js +1 -0
- package/components/ea-infinite-scroll/index.js +1 -170
- package/components/ea-infinite-scroll-item/index.js +1 -0
- package/components/ea-input/index.js +1 -765
- package/components/ea-input/src/components/createFixIcon.js +1 -0
- package/components/ea-input/src/components/createSuggestionBoard.js +1 -0
- package/components/ea-input/src/components/createWordLimitElement.js +1 -0
- package/components/ea-input/src/style/stylesheet.js +1 -0
- package/components/ea-input/src/utils/dispatchEvent.js +1 -0
- package/components/ea-input/src/utils/handleSearchResult.js +1 -0
- package/components/ea-input/src/utils/handleSuggestionBoardTrigger.js +1 -0
- package/components/ea-input-number/index.js +1 -458
- package/components/ea-input-number/src/style/stylesheet.js +1 -0
- package/components/ea-input-number/src/utils/handleCustomEvent.js +1 -0
- package/components/ea-link/index.js +1 -200
- package/components/ea-link/src/style/stylesheet.js +1 -0
- package/components/ea-loading/index.js +1 -218
- package/components/ea-loading/src/style/stylesheet.js +1 -0
- package/components/ea-main/index.js +1 -0
- package/components/ea-menu/index.js +1 -0
- package/components/ea-menu/src/style/stylesheet.js +1 -0
- package/components/ea-menu/src/utils/handleMenuItemEvent.js +1 -0
- package/components/ea-menu-item/index.js +1 -0
- package/components/ea-menu-item/src/style/stylesheet.js +1 -0
- package/components/ea-menu-item-group/index.js +1 -0
- package/components/ea-menu-item-group/src/style/stylesheet.js +1 -0
- package/components/ea-message/index.js +1 -233
- package/components/ea-message/src/style/stylesheet.js +1 -0
- package/components/ea-message/src/utils/MessageClass.js +1 -0
- package/components/ea-message-box/index.js +1 -202
- package/components/ea-message-box/src/style/stylesheet.js +1 -0
- package/components/ea-message-box/src/utils/EaMessageBoxClass.js +1 -0
- package/components/ea-option/index.js +1 -0
- package/components/ea-option/src/style/stylesheet.js +1 -0
- package/components/ea-option-gropu/index.js +1 -0
- package/components/ea-page-header/index.js +1 -0
- package/components/ea-page-header/src/style/stylesheet.js +1 -0
- package/components/ea-pagination/index.js +1 -444
- package/components/ea-pagination/src/components/getMoreItem.js +1 -0
- package/components/ea-pagination/src/components/getPageItem.js +1 -0
- package/components/ea-pagination/src/components/getShowTotalItem.js +1 -0
- package/components/ea-pagination/src/style/stylesheet.js +1 -0
- package/components/ea-pane/index.js +1 -0
- package/components/ea-pane/src/stylesheet.js +1 -0
- package/components/ea-progress/index.js +1 -333
- package/components/ea-progress/src/components/SVGComm.js +1 -0
- package/components/ea-progress/src/style/stylesheet.js +1 -0
- package/components/ea-radio/index.js +1 -287
- package/components/ea-radio/src/style/stylesheet.js +1 -0
- package/components/ea-radio-group/index.js +1 -59
- package/components/ea-rate/index.js +1 -326
- package/components/ea-rate/src/components/rateComm.js +1 -0
- package/components/ea-rate/src/style/stylesheet.js +1 -0
- package/components/ea-result/index.js +1 -167
- package/components/ea-result/src/style/stylesheet.js +1 -0
- package/components/ea-select/index.js +1 -34
- package/components/ea-select/src/style/stylesheet.js +1 -0
- package/components/ea-skeleton/index.js +1 -341
- package/components/ea-skeleton/src/style/stylesheet.js +1 -0
- package/components/ea-skeleton/src/utils/createSkeletonElement.js +1 -0
- package/components/ea-skeleton-item/index.js +1 -0
- package/components/ea-skeleton-item/src/assets/imageSVG.js +1 -0
- package/components/ea-skeleton-item/src/style/stylesheet.js +1 -0
- package/components/ea-step/index.js +1 -0
- package/components/ea-step/src/style/stylesheet.js +1 -0
- package/components/ea-steps/index.js +1 -0
- package/components/ea-steps/src/style/stylesheet.js +1 -0
- package/components/ea-submenu/index.js +1 -0
- package/components/ea-submenu/src/style/stylesheet.js +1 -0
- package/components/ea-switch/index.js +1 -301
- package/components/ea-switch/src/style/stylesheet.js +1 -0
- package/components/ea-tab/index.js +1 -0
- package/components/ea-tab/src/style/stylesheet.js +1 -0
- package/components/ea-table/index.js +1 -0
- package/components/ea-table/src/style/stylesheet.js +1 -0
- package/components/ea-table-column/index.js +1 -0
- package/components/ea-tabs/index.js +1 -0
- package/components/ea-tabs/src/style/stylesheet.js +1 -0
- package/components/ea-tag/index.js +1 -212
- package/components/ea-tag/src/style/stylesheet.js +1 -0
- package/components/ea-textarea/index.js +1 -333
- package/components/ea-textarea/src/style/stylesheet.js +1 -0
- package/components/ea-time-picker/index.js +1 -0
- package/components/ea-time-picker/src/style/stylesheet.js +1 -0
- package/components/ea-timeline/index.js +1 -334
- package/components/ea-timeline/style/stylesheet.js +1 -0
- package/components/ea-timeline-item/index.js +1 -0
- package/components/ea-timeline-item/src/style/stylesheet.js +1 -0
- package/package.json +11 -11
- package/utils/Validator.js +1 -0
- package/utils/createElement.js +1 -30
- package/utils/handleDefaultAttrIsTrue.js +1 -0
- package/utils/handleTemplate.js +1 -19
- package/utils/setStyle.js +1 -8
- package/utils/timeout.js +1 -0
- package/components/ea-message/MessageClass.js +0 -71
- package/components/ea-message-box/EaMessageBoxClass.js +0 -48
- package/components/ea-ui-base-style.css +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Publish Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- package
|
|
7
|
+
tags:
|
|
8
|
+
- 'v*.*.*'
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout code
|
|
15
|
+
uses: actions/checkout@v3
|
|
16
|
+
|
|
17
|
+
- name: Set up Node.js
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: '14'
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: npm install
|
|
24
|
+
|
|
25
|
+
- name: Publish to npm
|
|
26
|
+
run: npm publish
|
|
27
|
+
env:
|
|
28
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/components/Base.js
CHANGED
|
@@ -1,90 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import setStyle from '../utils/setStyle.js';
|
|
4
|
-
|
|
5
|
-
export default class Base extends HTMLElement {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
|
|
9
|
-
this.isProduction = false;
|
|
10
|
-
this.isProduction = true;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 设置属性值,并切换className
|
|
15
|
-
* @param {string} attr 属性名
|
|
16
|
-
* @param {boolean} flag 属性值
|
|
17
|
-
* @param {string} className class名
|
|
18
|
-
*/
|
|
19
|
-
toggleAttribute(attr, flag, className) {
|
|
20
|
-
if (flag) {
|
|
21
|
-
this.setAttribute(attr, flag);
|
|
22
|
-
|
|
23
|
-
if (className) this.dom.classList.add(className);
|
|
24
|
-
} else {
|
|
25
|
-
|
|
26
|
-
if (this.hasAttribute(attr)) this.removeAttribute(attr);
|
|
27
|
-
if (className) this.dom.classList.remove(className);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 设置属性值
|
|
33
|
-
* @param {string} attr 属性名
|
|
34
|
-
* @param {boolean} flag 属性值
|
|
35
|
-
*/
|
|
36
|
-
toggleAttr(attr, flag) {
|
|
37
|
-
if (flag) {
|
|
38
|
-
this.setAttribute(attr, flag);
|
|
39
|
-
} else {
|
|
40
|
-
this.removeAttribute(attr);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 获取属性值,并转换为布尔值
|
|
46
|
-
* @param {string} attrName 属性名
|
|
47
|
-
* @returns {boolean}
|
|
48
|
-
*/
|
|
49
|
-
getAttrBoolean(attrName) {
|
|
50
|
-
const attr = this.getAttribute(attrName);
|
|
51
|
-
return attr === 'true' || attr === '';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 获取属性值,并转换为数字
|
|
56
|
-
* @param {string} attrName 属性名
|
|
57
|
-
* @returns {number}
|
|
58
|
-
*/
|
|
59
|
-
getAttrNumber(attrName) {
|
|
60
|
-
const attr = this.getAttribute(attrName);
|
|
61
|
-
|
|
62
|
-
return attr ? Number(attr) : 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 样式构建
|
|
66
|
-
build(shadowRoot, stylesheet) {
|
|
67
|
-
if (this.isProduction) {
|
|
68
|
-
const styleNode = document.createElement('style');
|
|
69
|
-
styleNode.innerHTML = stylesheet;
|
|
70
|
-
this.shadowRoot.appendChild(styleNode);
|
|
71
|
-
} else {
|
|
72
|
-
if (this.nodeName.toLowerCase() == 'ea-skeleton-item' && !this.isProduction) setStyle(shadowRoot, new URL("ea-skeleton" + '/index.css', import.meta.url).href);
|
|
73
|
-
else if (this.nodeName.toLowerCase() == 'ea-carousel-item' && !this.isProduction) setStyle(shadowRoot, new URL("ea-carousel" + '/index.css', import.meta.url).href);
|
|
74
|
-
else if (this.nodeName.toLowerCase() == 'ea-timeline-item' && !this.isProduction) setStyle(shadowRoot, new URL("ea-timeline" + '/index.css', import.meta.url).href);
|
|
75
|
-
else if (this.nodeName.toLowerCase() == 'ea-collapse-item' && !this.isProduction) setStyle(shadowRoot, new URL("ea-collapse" + '/index.css', import.meta.url).href);
|
|
76
|
-
else setStyle(shadowRoot, new URL(this.nodeName.toLowerCase() + '/index.css', import.meta.url).href);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* @param {string} url 链接
|
|
83
|
-
*/
|
|
84
|
-
setIconFile(url) {
|
|
85
|
-
const link = document.createElement('link');
|
|
86
|
-
link.rel = 'stylesheet';
|
|
87
|
-
link.href = url;
|
|
88
|
-
this.shadowRoot.appendChild(link);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
import setStyle from"../utils/setStyle.js";export default class Base extends HTMLElement{constructor(){super(),this.isProduction=!1,this.isProduction=!0}toggleAttribute(t,e,s){e?(this.setAttribute(t,e),s&&this.dom.classList.add(s)):(this.hasAttribute(t)&&this.removeAttribute(t),s&&this.dom.classList.remove(s))}toggleAttr(t,e){e?this.setAttribute(t,e):this.removeAttribute(t)}getAttrBoolean(t){const e=this.getAttribute(t);return"true"===e||""===e}getAttrNumber(t){const e=this.getAttribute(t);return e?Number(e):0}build(t,e){if(this.isProduction){const t=document.createElement("style");t.innerHTML=e,this.shadowRoot.appendChild(t)}else setStyle(t,new URL(this.nodeName.toLowerCase()+"/index.css",import.meta.url).href)}}
|
|
@@ -1,298 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js';
|
|
3
|
-
import { createElement } from '../../utils/createElement.js';
|
|
4
|
-
import "../ea-icon/index.js"
|
|
5
|
-
|
|
6
|
-
const stylesheet = `
|
|
7
|
-
.ea-alert_wrap {
|
|
8
|
-
position: relative;
|
|
9
|
-
box-sizing: border-box;
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
border-radius: 4px;
|
|
12
|
-
padding: 8px 16px;
|
|
13
|
-
margin: 20px 0 0;
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
width: 100%;
|
|
17
|
-
opacity: 1;
|
|
18
|
-
transition: opacity 0.2s;
|
|
19
|
-
}
|
|
20
|
-
.ea-alert_wrap .ea-alert_content {
|
|
21
|
-
width: 100%;
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
justify-content: space-between;
|
|
25
|
-
}
|
|
26
|
-
.ea-alert_wrap .ea-alert_content .ea-alert_title {
|
|
27
|
-
display: flex;
|
|
28
|
-
align-items: center;
|
|
29
|
-
}
|
|
30
|
-
.ea-alert_wrap .ea-alert_content .ea-alert_title i {
|
|
31
|
-
margin-right: 0.5rem;
|
|
32
|
-
}
|
|
33
|
-
.ea-alert_wrap .ea-alert_content .ea-alert_close-icon {
|
|
34
|
-
color: #c0c4cc;
|
|
35
|
-
cursor: pointer;
|
|
36
|
-
}
|
|
37
|
-
.ea-alert_wrap .ea-alert_content.ea-alert--center .ea-alert_title,
|
|
38
|
-
.ea-alert_wrap .ea-alert_content.ea-alert--center .ea-alert_close-icon {
|
|
39
|
-
margin-left: auto;
|
|
40
|
-
}
|
|
41
|
-
.ea-alert_wrap .ea-alert_description {
|
|
42
|
-
width: 100%;
|
|
43
|
-
margin: 5px 0 0;
|
|
44
|
-
font-size: 12px;
|
|
45
|
-
}
|
|
46
|
-
.ea-alert_wrap.ea-alert--success {
|
|
47
|
-
background-color: #f0f9eb;
|
|
48
|
-
color: #67c23a;
|
|
49
|
-
}
|
|
50
|
-
.ea-alert_wrap.ea-alert--success.ea-alert--dark {
|
|
51
|
-
color: #fff;
|
|
52
|
-
background-color: #67c23a;
|
|
53
|
-
}
|
|
54
|
-
.ea-alert_wrap.ea-alert--success.ea-alert--dark .ea-alert_close-icon {
|
|
55
|
-
color: #fff;
|
|
56
|
-
}
|
|
57
|
-
.ea-alert_wrap.ea-alert--info {
|
|
58
|
-
background-color: #f4f4f5;
|
|
59
|
-
color: #909399;
|
|
60
|
-
}
|
|
61
|
-
.ea-alert_wrap.ea-alert--info.ea-alert--dark {
|
|
62
|
-
color: #fff;
|
|
63
|
-
background-color: #909399;
|
|
64
|
-
}
|
|
65
|
-
.ea-alert_wrap.ea-alert--info.ea-alert--dark .ea-alert_close-icon {
|
|
66
|
-
color: #fff;
|
|
67
|
-
}
|
|
68
|
-
.ea-alert_wrap.ea-alert--warning {
|
|
69
|
-
background-color: #fdf6ec;
|
|
70
|
-
color: #e6a23c;
|
|
71
|
-
}
|
|
72
|
-
.ea-alert_wrap.ea-alert--warning.ea-alert--dark {
|
|
73
|
-
color: #fff;
|
|
74
|
-
background-color: #e6a23c;
|
|
75
|
-
}
|
|
76
|
-
.ea-alert_wrap.ea-alert--warning.ea-alert--dark .ea-alert_close-icon {
|
|
77
|
-
color: #fff;
|
|
78
|
-
}
|
|
79
|
-
.ea-alert_wrap.ea-alert--error {
|
|
80
|
-
background-color: #fef0f0;
|
|
81
|
-
color: #f56c6c;
|
|
82
|
-
}
|
|
83
|
-
.ea-alert_wrap.ea-alert--error.ea-alert--dark {
|
|
84
|
-
color: #fff;
|
|
85
|
-
background-color: #f56c6c;
|
|
86
|
-
}
|
|
87
|
-
.ea-alert_wrap.ea-alert--error.ea-alert--dark .ea-alert_close-icon {
|
|
88
|
-
color: #fff;
|
|
89
|
-
}
|
|
90
|
-
`;
|
|
91
|
-
|
|
92
|
-
export class EaAlert extends Base {
|
|
93
|
-
#wrap;
|
|
94
|
-
|
|
95
|
-
#alertContent;
|
|
96
|
-
#alertTitle;
|
|
97
|
-
|
|
98
|
-
constructor() {
|
|
99
|
-
super();
|
|
100
|
-
|
|
101
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
102
|
-
const wrap = document.createElement('div');
|
|
103
|
-
wrap.className = 'ea-alert_wrap';
|
|
104
|
-
|
|
105
|
-
const alertTitle = createElement('span', 'ea-alert_title');
|
|
106
|
-
const alertContent = createElement('div', 'ea-alert_content', alertTitle);
|
|
107
|
-
wrap.appendChild(alertContent);
|
|
108
|
-
|
|
109
|
-
this.#wrap = wrap;
|
|
110
|
-
this.#alertContent = alertContent;
|
|
111
|
-
this.#alertTitle = alertTitle;
|
|
112
|
-
|
|
113
|
-
this.setIconFile(new URL('../ea-icon/index.css', import.meta.url).href);
|
|
114
|
-
|
|
115
|
-
this.build(shadowRoot, stylesheet);
|
|
116
|
-
this.shadowRoot.appendChild(wrap);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ------- type 获取提示类型 -------
|
|
120
|
-
// #region
|
|
121
|
-
get type() {
|
|
122
|
-
return this.getAttribute('type') || "info";
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
set type(value) {
|
|
126
|
-
this.setAttribute('type', value);
|
|
127
|
-
|
|
128
|
-
this.#wrap.classList.add(`ea-alert--${value}`);
|
|
129
|
-
}
|
|
130
|
-
// #endregion
|
|
131
|
-
// ------- end -------
|
|
132
|
-
|
|
133
|
-
// ------- title 获取提示标题 -------
|
|
134
|
-
// #region
|
|
135
|
-
get title() {
|
|
136
|
-
return this.getAttribute('title') || "";
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
set title(value) {
|
|
140
|
-
this.setAttribute('title', value);
|
|
141
|
-
|
|
142
|
-
this.#alertTitle.innerText = value;
|
|
143
|
-
}
|
|
144
|
-
// #endregion
|
|
145
|
-
// ------- end -------
|
|
146
|
-
|
|
147
|
-
// ------- closable 是否可关闭 -------
|
|
148
|
-
// #region
|
|
149
|
-
get closable() {
|
|
150
|
-
const flag = this.getAttribute('closable');
|
|
151
|
-
|
|
152
|
-
if (flag === null || flag === "true" || flag === "") return true;
|
|
153
|
-
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
set closable(value) {
|
|
158
|
-
this.setAttribute('closable', value);
|
|
159
|
-
}
|
|
160
|
-
// #endregion
|
|
161
|
-
// ------- end -------
|
|
162
|
-
|
|
163
|
-
// ------- close-text 关闭按钮文字 -------
|
|
164
|
-
// #region
|
|
165
|
-
get closeText() {
|
|
166
|
-
return this.getAttribute('close-text') || "";
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
set closeText(value) {
|
|
170
|
-
this.setAttribute('close-text', value);
|
|
171
|
-
}
|
|
172
|
-
// #endregion
|
|
173
|
-
// ------- end -------
|
|
174
|
-
|
|
175
|
-
// ------- effect 亮色与暗色主题 -------
|
|
176
|
-
// #region
|
|
177
|
-
get effect() {
|
|
178
|
-
return this.getAttribute('effect') || "light";
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
set effect(value) {
|
|
182
|
-
this.setAttribute('effect', value);
|
|
183
|
-
|
|
184
|
-
if (value === "dark") {
|
|
185
|
-
this.#wrap.classList.add('ea-alert--dark');
|
|
186
|
-
} else {
|
|
187
|
-
this.#wrap.classList.remove('ea-alert--dark');
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
// #endregion
|
|
191
|
-
// ------- end -------
|
|
192
|
-
|
|
193
|
-
// ------- show-icon 是否显示图标 -------
|
|
194
|
-
// #region
|
|
195
|
-
get showIcon() {
|
|
196
|
-
return this.getAttrBoolean('show-icon') || false;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
set showIcon(value) {
|
|
200
|
-
this.setAttribute('show-icon', value);
|
|
201
|
-
}
|
|
202
|
-
// #endregion
|
|
203
|
-
// ------- end -------
|
|
204
|
-
|
|
205
|
-
// ------- center 是否居中 -------
|
|
206
|
-
// #region
|
|
207
|
-
get center() {
|
|
208
|
-
return this.getAttrBoolean('center') || false;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
set center(value) {
|
|
212
|
-
this.setAttribute('center', value);
|
|
213
|
-
|
|
214
|
-
this.#alertContent.classList.toggle('ea-alert--center', value);
|
|
215
|
-
}
|
|
216
|
-
// #endregion
|
|
217
|
-
// ------- end -------
|
|
218
|
-
|
|
219
|
-
// ------- description 提示描述 -------
|
|
220
|
-
// #region
|
|
221
|
-
get description() {
|
|
222
|
-
return this.getAttribute('description') || "";
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
set description(value) {
|
|
226
|
-
this.setAttribute('description', value);
|
|
227
|
-
}
|
|
228
|
-
// #endregion
|
|
229
|
-
// ------- end -------
|
|
230
|
-
|
|
231
|
-
initClosableElement(closable, closeText) {
|
|
232
|
-
const that = this;
|
|
233
|
-
|
|
234
|
-
const closeIcon = createElement('i', 'ea-alert_close-icon');
|
|
235
|
-
closable === true && closeText === "" ? closeIcon.classList.add('icon-cancel') : closeIcon.innerText = closeText;
|
|
236
|
-
this.#alertContent.appendChild(closeIcon);
|
|
237
|
-
|
|
238
|
-
closeIcon.addEventListener('click', function () {
|
|
239
|
-
that.#wrap.style.opacity = 0;
|
|
240
|
-
|
|
241
|
-
that.dispatchEvent(new CustomEvent('close', { detail: { target: that } }));
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
this.#wrap.addEventListener('transitionend', function () {
|
|
245
|
-
that.remove();
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
initShowIconElement(type) {
|
|
250
|
-
const iconClass = {
|
|
251
|
-
success: 'ok-circled',
|
|
252
|
-
info: 'info',
|
|
253
|
-
warning: 'attention-alt',
|
|
254
|
-
error: 'cancel-circled'
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const icon = createElement('i', `icon-${iconClass[type]}`);
|
|
258
|
-
icon.classList.add(`ea-alert--${type}`);
|
|
259
|
-
this.#alertTitle.insertBefore(icon, this.#alertTitle.firstChild);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
initDescriptionElement(description) {
|
|
263
|
-
const descriptionElement = createElement('p', 'ea-alert_description');
|
|
264
|
-
this.#wrap.style.flexDirection = 'column';
|
|
265
|
-
|
|
266
|
-
descriptionElement.innerText = description;
|
|
267
|
-
this.#wrap.appendChild(descriptionElement);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
init() {
|
|
271
|
-
|
|
272
|
-
this.type = this.type;
|
|
273
|
-
|
|
274
|
-
this.title = this.title;
|
|
275
|
-
|
|
276
|
-
this.closable = this.closable;
|
|
277
|
-
|
|
278
|
-
this.closeText = this.closeText;
|
|
279
|
-
|
|
280
|
-
this.effect = this.effect;
|
|
281
|
-
|
|
282
|
-
this.center = this.center;
|
|
283
|
-
|
|
284
|
-
if (this.closable) this.initClosableElement(this.closable, this.closeText);
|
|
285
|
-
|
|
286
|
-
if (this.showIcon) this.initShowIconElement(this.type);
|
|
287
|
-
|
|
288
|
-
if (this.description) this.initDescriptionElement(this.description);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
connectedCallback() {
|
|
292
|
-
this.init();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (!customElements.get('ea-alert')) {
|
|
297
|
-
customElements.define('ea-alert', EaAlert);
|
|
298
|
-
}
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import{handleDefaultAttrIsTrue}from"../../utils/handleDefaultAttrIsTrue.js";import{createElement}from"../../utils/createElement.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaAlert extends Base{#t;#e;#s;#i;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML="\n <div class='ea-alert_wrap' part='container'>\n <div class=\"ea-alert_content\" part='content-wrap'>\n <span class=\"ea-alert_title\" part='title'></span>\n <ea-icon class=\"ea-alert_close-icon\" part='icon'></ea-icon>\n </div>\n </div>\n ",this.#t=t.querySelector(".ea-alert_wrap"),this.#e=t.querySelector(".ea-alert_content"),this.#s=t.querySelector(".ea-alert_title"),this.#i=t.querySelector(".ea-alert_close-icon"),this.build(t,stylesheet)}get type(){return this.getAttribute("type")||"info"}set type(t){this.setAttribute("type",t),this.#t.classList.add(`ea-alert--${t}`)}get title(){return this.getAttribute("title")||""}set title(t){this.setAttribute("title",t),this.#s.innerText=t}get closable(){return handleDefaultAttrIsTrue("closable")}set closable(t){this.setAttribute("closable",t),this.#i.style.display=t?"block":"none"}get closeText(){return this.getAttribute("close-text")||""}set closeText(t){this.setAttribute("close-text",t)}get effect(){return this.getAttribute("effect")||"light"}set effect(t){this.setAttribute("effect",t),this.#t.classList.toggle("ea-alert--dark","dark"===t)}get showIcon(){return this.getAttrBoolean("show-icon")||!1}set showIcon(t){this.setAttribute("show-icon",t)}get center(){return this.getAttrBoolean("center")||!1}set center(t){this.setAttribute("center",t),this.#e.classList.toggle("ea-alert--center",t)}get description(){return this.getAttribute("description")||""}set description(t){this.setAttribute("description",t)}#r(){this.closable&&(!0===this.closable&&""===this.closeText?this.#i.icon="icon-cancel":this.#i.innerText=this.closeText,this.#i.addEventListener("click",(()=>{this.#t.style.opacity=0,this.dispatchEvent(new CustomEvent("close",{detail:{target:this.#i}}))})),this.#t.addEventListener("transitionend",(()=>{this.remove()})))}get iconList(){return{success:"ok-circled",info:"info",warning:"attention-alt",error:"cancel-circled"}}#n(){if(!this.showIcon)return;const t=createElement("ea-icon");t.icon=`icon-${this.iconList[this.type]}`,t.classList.add(`ea-alert--${this.type}`),this.#s.insertBefore(t,this.#s.firstChild)}#l(){if(!this.description)return;const t=createElement("p","ea-alert_description");t.part="description",this.#t.style.flexDirection="column",t.innerText=this.description,this.#t.appendChild(t)}connectedCallback(){this.type=this.type,this.title=this.title,this.closable=this.closable,this.closeText=this.closeText,this.effect=this.effect,this.center=this.center,this.#r(),this.#n(),this.#l()}}customElements.get("ea-alert")||customElements.define("ea-alert",EaAlert);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-alert_wrap {\n position: relative;\n box-sizing: border-box;\n overflow: hidden;\n border-radius: 4px;\n padding: 8px 16px;\n margin: 20px 0 0;\n display: flex;\n align-items: center;\n width: 100%;\n opacity: 1;\n transition: opacity 0.2s;\n}\n.ea-alert_wrap .ea-alert_content {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n.ea-alert_wrap .ea-alert_content .ea-alert_title {\n display: flex;\n align-items: center;\n}\n.ea-alert_wrap .ea-alert_content .ea-alert_title i {\n margin-right: 0.5rem;\n}\n.ea-alert_wrap .ea-alert_content .ea-alert_close-icon {\n color: #c0c4cc;\n cursor: pointer;\n}\n.ea-alert_wrap .ea-alert_content.ea-alert--center .ea-alert_title,\n.ea-alert_wrap .ea-alert_content.ea-alert--center .ea-alert_close-icon {\n margin-left: auto;\n}\n.ea-alert_wrap .ea-alert_description {\n width: 100%;\n margin: 5px 0 0;\n font-size: 12px;\n}\n.ea-alert_wrap.ea-alert--success {\n background-color: #f0f9eb;\n color: #67c23a;\n}\n.ea-alert_wrap.ea-alert--success.ea-alert--dark {\n color: #fff;\n background-color: #67c23a;\n}\n.ea-alert_wrap.ea-alert--success.ea-alert--dark .ea-alert_close-icon {\n color: #fff;\n}\n.ea-alert_wrap.ea-alert--info {\n background-color: #f4f4f5;\n color: #909399;\n}\n.ea-alert_wrap.ea-alert--info.ea-alert--dark {\n color: #fff;\n background-color: #909399;\n}\n.ea-alert_wrap.ea-alert--info.ea-alert--dark .ea-alert_close-icon {\n color: #fff;\n}\n.ea-alert_wrap.ea-alert--warning {\n background-color: #fdf6ec;\n color: #e6a23c;\n}\n.ea-alert_wrap.ea-alert--warning.ea-alert--dark {\n color: #fff;\n background-color: #e6a23c;\n}\n.ea-alert_wrap.ea-alert--warning.ea-alert--dark .ea-alert_close-icon {\n color: #fff;\n}\n.ea-alert_wrap.ea-alert--error {\n background-color: #fef0f0;\n color: #f56c6c;\n}\n.ea-alert_wrap.ea-alert--error.ea-alert--dark {\n color: #fff;\n background-color: #f56c6c;\n}\n.ea-alert_wrap.ea-alert--error.ea-alert--dark .ea-alert_close-icon {\n color: #fff;\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";const stylesheet="\n.ea-aside_wrap {\n height: 100%;\n overflow: auto;\n display: flex;\n flex-direction: column;\n}\n.ea-aside_wrap ::slotted(ea-main) {\n overflow: auto;\n}\n";export class EaAside extends Base{#e;constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML='\n <aside class="ea-aside_wrap" part="container">\n <slot></slot>\n </aside>\n ',this.#e=e.querySelector(".ea-aside_wrap"),this.build(e,stylesheet)}get width(){return this.getAttrNumber("width")||200}set width(e){this.setAttribute("width",e),this.#e.style.width=`${e}px`}connectedCallback(){this.width=this.width}}customElements.get("ea-aside")||customElements.define("ea-aside",EaAside);
|