easy-component-ui 0.0.2 → 1.0.3
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/components/Base.js +90 -0
- package/components/ea-alert/index.js +298 -0
- package/components/ea-avatar/index.js +277 -0
- package/components/ea-backtop/index.js +232 -0
- package/components/ea-badge/index.js +160 -0
- package/components/ea-button/index.js +584 -0
- package/components/ea-button-group/index.js +459 -0
- package/components/ea-calendar/index.js +409 -0
- package/components/ea-card/index.js +77 -0
- package/components/ea-carousel/index.js +434 -0
- package/components/ea-checkbox/index.js +314 -0
- package/components/ea-checkbox-group/index.js +107 -0
- package/components/ea-collapse/index.js +293 -0
- package/components/ea-descriptions/index.js +240 -0
- package/components/ea-descriptions-item/index.js +110 -0
- package/components/ea-empty/index.js +141 -0
- package/{icon → components/ea-icon}/config.json +1017 -1017
- package/{icon → components/ea-icon}/css/animation.css +85 -85
- package/{icon → components/ea-icon}/css/fontello.css +224 -224
- package/components/ea-icon/font/fontello.svg +683 -0
- package/components/ea-icon/index.css +2 -0
- package/components/ea-icon/index.js +47 -0
- package/components/ea-image/index.js +412 -0
- package/components/ea-infinite-scroll/index.js +170 -0
- package/components/ea-input/index.js +765 -0
- package/components/ea-input-number/index.js +458 -0
- package/components/ea-link/index.js +200 -0
- package/components/ea-loading/index.js +218 -0
- package/components/ea-message/MessageClass.js +71 -0
- package/components/ea-message/index.js +233 -0
- package/components/ea-message-box/EaMessageBoxClass.js +48 -0
- package/components/ea-message-box/index.js +202 -0
- package/components/ea-pagination/index.js +444 -0
- package/components/ea-progress/index.js +333 -0
- package/components/ea-radio/index.js +287 -0
- package/components/ea-radio-group/index.js +59 -0
- package/components/ea-rate/index.js +326 -0
- package/components/ea-result/index.js +167 -0
- package/components/ea-select/index.js +34 -0
- package/components/ea-skeleton/index.js +341 -0
- package/components/ea-switch/index.js +301 -0
- package/components/ea-tag/index.js +212 -0
- package/components/ea-textarea/index.js +333 -0
- package/components/ea-timeline/index.js +334 -0
- package/components/ea-ui-base-style.css +0 -0
- package/package.json +1 -1
- package/utils/createElement.js +30 -0
- package/utils/handleTemplate.js +19 -0
- package/utils/setStyle.js +8 -0
- package/icon/font/fontello.svg +0 -346
- package/icon/index.css +0 -2
- package/index.js +0 -1693
- /package/{icon → components/ea-icon}/css/fontello-codes.css +0 -0
- /package/{icon → components/ea-icon}/css/fontello-embedded.css +0 -0
- /package/{icon → components/ea-icon}/css/fontello-ie7-codes.css +0 -0
- /package/{icon → components/ea-icon}/css/fontello-ie7.css +0 -0
- /package/{icon → components/ea-icon}/font/fontello.eot +0 -0
- /package/{icon → components/ea-icon}/font/fontello.ttf +0 -0
- /package/{icon → components/ea-icon}/font/fontello.woff +0 -0
- /package/{icon → components/ea-icon}/font/fontello.woff2 +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import Base from '../Base.js';
|
|
3
|
+
import { createElement, createSlotElement } from '../../utils/createElement.js';
|
|
4
|
+
import "../ea-icon/index.js"
|
|
5
|
+
|
|
6
|
+
const stylesheet = `
|
|
7
|
+
.ea-backtop_wrap {
|
|
8
|
+
position: fixed;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
width: 40px;
|
|
13
|
+
height: 40px;
|
|
14
|
+
right: 40px;
|
|
15
|
+
bottom: 40px;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
background-color: #fff;
|
|
18
|
+
border-radius: 50%;
|
|
19
|
+
color: #409eff;
|
|
20
|
+
font-size: 14px;
|
|
21
|
+
box-shadow: 0 0 6px rgba(0, 0, 0, 0.12);
|
|
22
|
+
opacity: 1;
|
|
23
|
+
z-index: 5;
|
|
24
|
+
transition: opacity 0.3s ease-in-out;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
export class EaBacktop extends Base {
|
|
29
|
+
#wrap;
|
|
30
|
+
|
|
31
|
+
#iconSlot;
|
|
32
|
+
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
|
|
36
|
+
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
37
|
+
const wrap = document.createElement('div');
|
|
38
|
+
wrap.className = 'ea-backtop_wrap';
|
|
39
|
+
wrap.style.display = 'none';
|
|
40
|
+
|
|
41
|
+
const slot = createSlotElement('');
|
|
42
|
+
wrap.appendChild(slot);
|
|
43
|
+
this.#iconSlot = slot;
|
|
44
|
+
|
|
45
|
+
this.#wrap = wrap;
|
|
46
|
+
this.setIconFile(new URL('../ea-icon/index.css', import.meta.url).href);
|
|
47
|
+
|
|
48
|
+
this.build(shadowRoot, stylesheet);
|
|
49
|
+
this.shadowRoot.appendChild(wrap);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ------- target 触发滚动的对象 -------
|
|
53
|
+
// #region
|
|
54
|
+
get target() {
|
|
55
|
+
return this.getAttribute('target');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
set target(value) {
|
|
59
|
+
this.setAttribute('target', value);
|
|
60
|
+
}
|
|
61
|
+
// #endregion
|
|
62
|
+
// ------- end -------
|
|
63
|
+
|
|
64
|
+
// ------- right 滚动按钮距离右边的距离 -------
|
|
65
|
+
// #region
|
|
66
|
+
get right() {
|
|
67
|
+
return this.getAttribute('right') || 40;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
set right(value) {
|
|
71
|
+
this.setAttribute('right', value);
|
|
72
|
+
|
|
73
|
+
this.#wrap.style.right = value + 'px';
|
|
74
|
+
}
|
|
75
|
+
// #endregion
|
|
76
|
+
// ------- end -------
|
|
77
|
+
|
|
78
|
+
// ------- bottom 滚动按钮距离下边的距离 -------
|
|
79
|
+
// #region
|
|
80
|
+
get bottom() {
|
|
81
|
+
return this.getAttribute('bottom') || 40;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
set bottom(value) {
|
|
85
|
+
this.setAttribute('bottom', value);
|
|
86
|
+
|
|
87
|
+
this.#wrap.style.bottom = value + 'px';
|
|
88
|
+
}
|
|
89
|
+
// #endregion
|
|
90
|
+
// ------- end -------
|
|
91
|
+
|
|
92
|
+
// ------- icon 图标类名 -------
|
|
93
|
+
// #region
|
|
94
|
+
get icon() {
|
|
95
|
+
return this.getAttribute('icon') || "icon-angle-up";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
set icon(value) {
|
|
99
|
+
this.setAttribute('icon', value);
|
|
100
|
+
|
|
101
|
+
const icon = createElement('ea-icon');
|
|
102
|
+
icon.icon = value;
|
|
103
|
+
this.#iconSlot.innerHTML = "";
|
|
104
|
+
this.#iconSlot.appendChild(icon);
|
|
105
|
+
}
|
|
106
|
+
// #endregion
|
|
107
|
+
// ------- end -------
|
|
108
|
+
|
|
109
|
+
// ------- visibility-height 滚动按钮显示和隐藏的触发条件 -------
|
|
110
|
+
// #region
|
|
111
|
+
get visibilityHeight() {
|
|
112
|
+
return this.getAttribute('visibility-height') || 200;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
set visibilityHeight(value) {
|
|
116
|
+
this.setAttribute('visibility-height', value);
|
|
117
|
+
}
|
|
118
|
+
// #endregion
|
|
119
|
+
// ------- end -------
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 根据滚动位置控制返回顶部按钮的显示和隐藏。
|
|
123
|
+
*
|
|
124
|
+
* 当页面滚动超过200像素时,显示返回顶部按钮,并在过渡结束后设置按钮为完全可见。
|
|
125
|
+
* 当页面滚动不超过200像素时,隐藏返回顶部按钮,并在过渡结束后将按钮的显示属性设置为none。
|
|
126
|
+
*
|
|
127
|
+
* @param {*} scrollDom - 用于检测滚动位置的DOM元素。
|
|
128
|
+
* @param {number} scrollFlag - 页面滚动到指定距离时触发。
|
|
129
|
+
*/
|
|
130
|
+
#handleBackTopBtnShow(scrollDom, scrollFlag) {
|
|
131
|
+
const that = this;
|
|
132
|
+
|
|
133
|
+
// 当滚动距离超过200像素时,显示返回顶部按钮
|
|
134
|
+
if (scrollDom.scrollTop > scrollFlag) {
|
|
135
|
+
this.#wrap.style.display = 'flex';
|
|
136
|
+
this.#wrap.ontransitionend = null;
|
|
137
|
+
|
|
138
|
+
// 延迟10毫秒后设置按钮的透明度为1,使其完全可见
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
this.#wrap.style.opacity = 1;
|
|
141
|
+
}, 10);
|
|
142
|
+
} else {
|
|
143
|
+
// 当滚动距离不超过200像素时,隐藏返回顶部按钮
|
|
144
|
+
this.#wrap.style.opacity = 0;
|
|
145
|
+
|
|
146
|
+
// 在过渡结束时,将按钮的显示属性设置为none
|
|
147
|
+
this.#wrap.ontransitionend = function () {
|
|
148
|
+
that.#wrap.style.display = 'none';
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 根据目标名称获取滚动事件相关DOM元素。
|
|
155
|
+
*
|
|
156
|
+
* 此函数用于确定应该监听哪个DOM元素的滚动事件。它可以是特定的DOM元素,或者是整个文档。
|
|
157
|
+
* 通过判断目标名称是否为空或未定义,来决定是获取整个文档还是指定的DOM元素。
|
|
158
|
+
*
|
|
159
|
+
* @param {string} targetName - 目标元素的选择器字符串。如果为空或未定义,则监听整个文档。
|
|
160
|
+
* @returns {Object} 返回一个对象,包含两个属性:dom和scrollDom,它们都指向同一个被选中的DOM元素,或者如果未指定目标名称,则指向document对象。
|
|
161
|
+
*/
|
|
162
|
+
#handleScrollEvent(targetName) {
|
|
163
|
+
// 保存当前上下文的引用
|
|
164
|
+
const that = this;
|
|
165
|
+
|
|
166
|
+
// 初始化dom和scrollDom变量为null
|
|
167
|
+
let dom = null;
|
|
168
|
+
let scrollDom = null;
|
|
169
|
+
|
|
170
|
+
// 判断目标名称是否为空或未定义
|
|
171
|
+
if (targetName === "null" || targetName === '' || targetName === null || targetName === undefined || targetName === 'undefined') {
|
|
172
|
+
// 如果是,设置dom和scrollDom为document对象
|
|
173
|
+
dom = document;
|
|
174
|
+
scrollDom = document.documentElement;
|
|
175
|
+
} else {
|
|
176
|
+
// 如果不是,通过目标名称查询DOM元素,并设置dom和scrollDom
|
|
177
|
+
dom = document.querySelector(targetName);
|
|
178
|
+
scrollDom = document.querySelector(targetName);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// 返回包含dom和scrollDom的对象
|
|
182
|
+
return { dom, scrollDom };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#initScrollBtn() {
|
|
186
|
+
const that = this;
|
|
187
|
+
const { dom, scrollDom } = this.#handleScrollEvent(this.target);
|
|
188
|
+
|
|
189
|
+
this.#handleBackTopBtnShow(scrollDom, this.visibilityHeight);
|
|
190
|
+
|
|
191
|
+
dom.addEventListener('scroll', function () {
|
|
192
|
+
that.#handleBackTopBtnShow(scrollDom, that.visibilityHeight);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
this.#wrap.addEventListener('click', function () {
|
|
196
|
+
let step = 10;
|
|
197
|
+
|
|
198
|
+
let timer = setInterval(() => {
|
|
199
|
+
step += 5;
|
|
200
|
+
scrollDom.scrollTop -= step;
|
|
201
|
+
|
|
202
|
+
if (scrollDom.scrollTop <= 0) {
|
|
203
|
+
scrollDom.scrollTop = 0;
|
|
204
|
+
clearInterval(timer);
|
|
205
|
+
timer = null;
|
|
206
|
+
}
|
|
207
|
+
}, 12);
|
|
208
|
+
|
|
209
|
+
this.dispatchEvent(new CustomEvent('backtop', {}));
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
init() {
|
|
214
|
+
const that = this;
|
|
215
|
+
|
|
216
|
+
this.target = this.target;
|
|
217
|
+
this.right = this.right;
|
|
218
|
+
this.bottom = this.bottom;
|
|
219
|
+
this.visibilityHeight = this.visibilityHeight;
|
|
220
|
+
this.icon = this.icon;
|
|
221
|
+
|
|
222
|
+
this.#initScrollBtn();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
connectedCallback() {
|
|
226
|
+
this.init();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (!customElements.get('ea-backtop')) {
|
|
231
|
+
customElements.define('ea-backtop', EaBacktop);
|
|
232
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import Base from '../Base.js';
|
|
3
|
+
|
|
4
|
+
const stylesheet = `
|
|
5
|
+
.ea-badge_wrap {
|
|
6
|
+
position: relative;
|
|
7
|
+
vertical-align: middle;
|
|
8
|
+
display: inline-block;
|
|
9
|
+
}
|
|
10
|
+
.ea-badge_wrap .ea-badge_content {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
padding: 0 0.375rem;
|
|
13
|
+
border-radius: 0.625rem;
|
|
14
|
+
border: 1px solid #fff;
|
|
15
|
+
height: 1.125rem;
|
|
16
|
+
line-height: 1.125rem;
|
|
17
|
+
position: absolute;
|
|
18
|
+
right: 0.625rem;
|
|
19
|
+
top: 0;
|
|
20
|
+
transform: translate(100%, -50%);
|
|
21
|
+
color: #fff;
|
|
22
|
+
font-size: 0.75rem;
|
|
23
|
+
text-align: center;
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
background-color: #f56c6c;
|
|
26
|
+
}
|
|
27
|
+
.ea-badge_wrap .ea-badge_content.primary {
|
|
28
|
+
background-color: #409eff;
|
|
29
|
+
}
|
|
30
|
+
.ea-badge_wrap .ea-badge_content.success {
|
|
31
|
+
background-color: #67c23a;
|
|
32
|
+
}
|
|
33
|
+
.ea-badge_wrap .ea-badge_content.warning {
|
|
34
|
+
background-color: #e6a23c;
|
|
35
|
+
}
|
|
36
|
+
.ea-badge_wrap .ea-badge_content.info {
|
|
37
|
+
background-color: #909399;
|
|
38
|
+
}
|
|
39
|
+
.ea-badge_wrap .ea-badge_content.dot {
|
|
40
|
+
right: 0.3125rem;
|
|
41
|
+
padding: 0;
|
|
42
|
+
border-radius: 50%;
|
|
43
|
+
width: 0.5rem;
|
|
44
|
+
height: 0.5rem;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
export class EaBadge extends Base {
|
|
49
|
+
#wrap;
|
|
50
|
+
#badgeWrap;
|
|
51
|
+
|
|
52
|
+
constructor() {
|
|
53
|
+
super();
|
|
54
|
+
|
|
55
|
+
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
56
|
+
const wrap = document.createElement('div');
|
|
57
|
+
wrap.className = 'ea-badge_wrap';
|
|
58
|
+
|
|
59
|
+
const slot = document.createElement('slot');
|
|
60
|
+
wrap.appendChild(slot);
|
|
61
|
+
|
|
62
|
+
const badgeWrap = document.createElement('sup');
|
|
63
|
+
badgeWrap.className = 'ea-badge_content';
|
|
64
|
+
wrap.appendChild(badgeWrap);
|
|
65
|
+
|
|
66
|
+
this.#wrap = wrap;
|
|
67
|
+
this.#badgeWrap = badgeWrap;
|
|
68
|
+
|
|
69
|
+
this.build(shadowRoot, stylesheet);
|
|
70
|
+
this.shadowRoot.appendChild(wrap);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ------- value 徽章内的值 -------
|
|
74
|
+
// #region
|
|
75
|
+
get value() {
|
|
76
|
+
return this.getAttribute('value') || '';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
set value(value) {
|
|
80
|
+
this.setAttribute('value', value);
|
|
81
|
+
|
|
82
|
+
this.#badgeWrap.innerHTML = value;
|
|
83
|
+
}
|
|
84
|
+
// #endregion
|
|
85
|
+
// ------- end -------
|
|
86
|
+
|
|
87
|
+
// ------- type 样式类型 -------
|
|
88
|
+
// #region
|
|
89
|
+
get type() {
|
|
90
|
+
return this.getAttribute('type') || 'normal';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
set type(value) {
|
|
94
|
+
this.setAttribute('type', value);
|
|
95
|
+
|
|
96
|
+
this.#badgeWrap.classList.add(value);
|
|
97
|
+
}
|
|
98
|
+
// #endregion
|
|
99
|
+
// ------- end -------
|
|
100
|
+
|
|
101
|
+
// ------- max 最大值 -------
|
|
102
|
+
// #region
|
|
103
|
+
get max() {
|
|
104
|
+
return this.getAttrNumber('max') || Infinity;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
set max(value) {
|
|
108
|
+
if (value === Infinity) return;
|
|
109
|
+
|
|
110
|
+
value = parseInt(value);
|
|
111
|
+
|
|
112
|
+
this.setAttribute('max', value);
|
|
113
|
+
|
|
114
|
+
if (this.value > value) {
|
|
115
|
+
this.value = value + '+';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// #endregion
|
|
119
|
+
// ------- end -------
|
|
120
|
+
|
|
121
|
+
// ------- is-dot 是否为点状徽章 -------
|
|
122
|
+
// #region
|
|
123
|
+
get isDot() {
|
|
124
|
+
return this.getAttrBoolean('is-dot') || false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
set isDot(value) {
|
|
128
|
+
this.toggleAttr('is-dot', value);
|
|
129
|
+
|
|
130
|
+
this.#badgeWrap.innerText = value ? '' : this.value;
|
|
131
|
+
this.#badgeWrap.classList.toggle('dot', value);
|
|
132
|
+
}
|
|
133
|
+
// #endregion
|
|
134
|
+
// ------- end -------
|
|
135
|
+
|
|
136
|
+
init() {
|
|
137
|
+
const that = this;
|
|
138
|
+
|
|
139
|
+
this.value = this.value;
|
|
140
|
+
|
|
141
|
+
this.type = this.type;
|
|
142
|
+
|
|
143
|
+
this.max = this.max;
|
|
144
|
+
|
|
145
|
+
this.isDot = this.isDot;
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
const button = this.querySelector('ea-button');
|
|
149
|
+
if (button) button.style.setProperty('--margin-right', '0');
|
|
150
|
+
} catch (error) { }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
connectedCallback() {
|
|
154
|
+
this.init();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!customElements.get('ea-badge')) {
|
|
159
|
+
customElements.define('ea-badge', EaBadge);
|
|
160
|
+
}
|