easy-component-ui 1.0.3 → 2.0.1
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
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from "../Base.js";
|
|
3
|
-
|
|
4
|
-
const stylesheet = `
|
|
5
|
-
.ea-radio-group {
|
|
6
|
-
display: flex;
|
|
7
|
-
}
|
|
8
|
-
.ea-radio-group ea-radio {
|
|
9
|
-
margin-right: 2rem;
|
|
10
|
-
}`;
|
|
11
|
-
|
|
12
|
-
export class EaRadioGroup extends Base {
|
|
13
|
-
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
|
|
17
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
18
|
-
|
|
19
|
-
const dom = document.createElement('div');
|
|
20
|
-
shadowRoot.appendChild(dom);
|
|
21
|
-
const slot = document.createElement('slot');
|
|
22
|
-
dom.className = "ea-radio-group";
|
|
23
|
-
dom.appendChild(slot);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.dom = dom;
|
|
27
|
-
|
|
28
|
-
this.build(shadowRoot, stylesheet);
|
|
29
|
-
|
|
30
|
-
shadowRoot.appendChild(dom);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// ------- name 唯一键值 -------
|
|
34
|
-
// #region
|
|
35
|
-
get name() {
|
|
36
|
-
return this.getAttribute('name');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
set name(val) {
|
|
40
|
-
this.querySelectorAll('ea-radio').forEach(radio => {
|
|
41
|
-
radio.setAttribute('name', val);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
// #endregion
|
|
45
|
-
// ------- end -------
|
|
46
|
-
|
|
47
|
-
init() {
|
|
48
|
-
// name 唯一键值
|
|
49
|
-
this.name = this.name;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
connectedCallback() {
|
|
53
|
-
this.init();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!window.customElements.get("ea-radio-group")) {
|
|
58
|
-
window.customElements.define("ea-radio-group", EaRadioGroup);
|
|
59
|
-
}
|
|
1
|
+
import Base from"../Base.js";const stylesheet="\n.ea-radio-group_wrap {\n display: flex;\n}\n";export class EaRadioGroup extends Base{constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML='\n <div class="ea-radio-group_wrap" part="container">\n <slot></slot>\n </div>\n ',this.build(e,stylesheet)}get name(){return this.getAttribute("name")}set name(e){this.querySelectorAll("ea-radio").forEach((t=>{t.setAttribute("name",e)}))}get value(){return this.getAttribute("value")||""}set value(e){e&&this.setAttribute("value",e)}#e(e){e.forEach((e=>{e.checked&&(this.value=e.value),e.addEventListener("change",(t=>{this.value=e.value,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{target:e,value:this.value}}))}))}))}#t(e){const t=Array.from(e).find((e=>e.value===this.value));t&&(t.checked=!0)}connectedCallback(){this.setAttribute("data-ea-component",!0),this.name=this.name;const e=this.querySelectorAll("ea-radio");this.#e(e),this.#t(e)}}window.customElements.get("ea-radio-group")||window.customElements.define("ea-radio-group",EaRadioGroup);
|
|
@@ -1,326 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import Base from '../Base.js';
|
|
3
|
-
import "../ea-icon/index.js"
|
|
4
|
-
|
|
5
|
-
const stylesheet = `
|
|
6
|
-
:host {
|
|
7
|
-
--i-color: rgb(247, 186, 42);
|
|
8
|
-
}
|
|
9
|
-
.ea-rate_wrap {
|
|
10
|
-
--i-color: rgb(247, 186, 42);
|
|
11
|
-
position: relative;
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
}
|
|
15
|
-
.ea-rate_wrap .ea-rate_item {
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
width: 24px;
|
|
18
|
-
height: 24px;
|
|
19
|
-
}
|
|
20
|
-
.ea-rate_wrap .ea-rate_item > i {
|
|
21
|
-
color: #c0c4cc;
|
|
22
|
-
font-size: 1rem;
|
|
23
|
-
line-height: 1;
|
|
24
|
-
transition: color 0.3s, font-size 0.1s;
|
|
25
|
-
}
|
|
26
|
-
.ea-rate_wrap .ea-rate_item.ea-rate_item--active > i {
|
|
27
|
-
color: var(--i-color);
|
|
28
|
-
font-size: 1.1rem;
|
|
29
|
-
}
|
|
30
|
-
.ea-rate_wrap .ea-rate_item.ea-rate_item--disabled {
|
|
31
|
-
pointer-events: none;
|
|
32
|
-
cursor: default;
|
|
33
|
-
}
|
|
34
|
-
.ea-rate_wrap .ea-rate_text {
|
|
35
|
-
margin-left: 0.25rem;
|
|
36
|
-
min-width: 2rem;
|
|
37
|
-
font-size: 0.8rem;
|
|
38
|
-
line-height: 0.8;
|
|
39
|
-
vertical-align: middle;
|
|
40
|
-
}
|
|
41
|
-
.ea-rate_wrap .ea-rate_score {
|
|
42
|
-
position: absolute;
|
|
43
|
-
left: 0;
|
|
44
|
-
top: 0;
|
|
45
|
-
}
|
|
46
|
-
.ea-rate_wrap .ea-rate_score .ea-rate_score_item {
|
|
47
|
-
width: 24px;
|
|
48
|
-
height: 24px;
|
|
49
|
-
}
|
|
50
|
-
.ea-rate_wrap .ea-rate_score .ea-rate_score_item > i {
|
|
51
|
-
color: #c0c4cc;
|
|
52
|
-
font-size: 1rem;
|
|
53
|
-
line-height: 1;
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
const rateDom = (index) => {
|
|
58
|
-
const dom = document.createElement('span');
|
|
59
|
-
dom.className = 'ea-rate_item';
|
|
60
|
-
dom.setAttribute('data-index', index);
|
|
61
|
-
|
|
62
|
-
const icon = document.createElement('i');
|
|
63
|
-
icon.className = 'icon-star-empty';
|
|
64
|
-
|
|
65
|
-
dom.appendChild(icon);
|
|
66
|
-
|
|
67
|
-
return dom;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export class EaRate extends Base {
|
|
72
|
-
#mounted = false;
|
|
73
|
-
#wrap;
|
|
74
|
-
#appendSlot;
|
|
75
|
-
#textList = ["极差", "失望", "一般", "满意", "惊喜"];
|
|
76
|
-
|
|
77
|
-
static get observedAttributes() {
|
|
78
|
-
return ['value'];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
constructor() {
|
|
82
|
-
super();
|
|
83
|
-
|
|
84
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
85
|
-
const wrap = document.createElement('div');
|
|
86
|
-
wrap.className = 'ea-rate_wrap';
|
|
87
|
-
|
|
88
|
-
for (let i = 0; i < 5; i++) {
|
|
89
|
-
const dom = rateDom(i);
|
|
90
|
-
|
|
91
|
-
wrap.appendChild(dom);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const text = document.createElement('span');
|
|
95
|
-
text.className = 'ea-rate_text';
|
|
96
|
-
wrap.appendChild(text);
|
|
97
|
-
|
|
98
|
-
this.#wrap = wrap;
|
|
99
|
-
this.#appendSlot = text;
|
|
100
|
-
|
|
101
|
-
this.setIconFile(new URL('../ea-icon/index.css', import.meta.url).href);
|
|
102
|
-
|
|
103
|
-
this.build(shadowRoot, stylesheet);
|
|
104
|
-
this.shadowRoot.appendChild(wrap);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 设置/显示选中状态
|
|
108
|
-
setCheckedStatus(index) {
|
|
109
|
-
const item = this.#wrap.querySelectorAll('.ea-rate_item');
|
|
110
|
-
|
|
111
|
-
for (let i = 0; i < index; i++) {
|
|
112
|
-
item[i].classList.add('ea-rate_item--active');
|
|
113
|
-
item[i].querySelector('i').className = this.activeIconClass;
|
|
114
|
-
|
|
115
|
-
if (this.showText) {
|
|
116
|
-
this.#appendSlot.innerText = this.showTextList[index - 1];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 当未选中时, 清除选中状态
|
|
122
|
-
clearCheckedStatus() {
|
|
123
|
-
this.#wrap.querySelectorAll('.ea-rate_item').forEach(item => {
|
|
124
|
-
item.classList.remove('ea-rate_item--active');
|
|
125
|
-
item.querySelector('i').className = this.voidIconClass;
|
|
126
|
-
|
|
127
|
-
if (this.showText) {
|
|
128
|
-
const text = this.#wrap.querySelector('.ea-rate_text');
|
|
129
|
-
text.innerText = "";
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ------- value 当前选中值 -------
|
|
135
|
-
// #region
|
|
136
|
-
get value() {
|
|
137
|
-
const value = this.getAttrNumber('value') || 0;
|
|
138
|
-
|
|
139
|
-
if (value < 1 || value > 5 || !value) return 0;
|
|
140
|
-
else return Number(value);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
set value(val) {
|
|
144
|
-
val = Number(val);
|
|
145
|
-
|
|
146
|
-
this.setAttribute('value', val);
|
|
147
|
-
|
|
148
|
-
this.clearCheckedStatus();
|
|
149
|
-
|
|
150
|
-
this.setCheckedStatus(val);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// #endregion
|
|
154
|
-
// ------- end -------
|
|
155
|
-
|
|
156
|
-
// ------- color 颜色 -------
|
|
157
|
-
// #region
|
|
158
|
-
get color() {
|
|
159
|
-
return this.getAttribute('color') || 'rgb(247, 186, 42)';
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
set color(val) {
|
|
163
|
-
this.setAttribute('color', val);
|
|
164
|
-
this.#wrap.querySelectorAll('.ea-rate_item').forEach(item => {
|
|
165
|
-
item.querySelector('i').style.setProperty('--i-color', val);
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
// #endregion
|
|
169
|
-
// ------- end -------
|
|
170
|
-
|
|
171
|
-
// ------- show-text 显示文本 -------
|
|
172
|
-
// #region
|
|
173
|
-
|
|
174
|
-
get showText() {
|
|
175
|
-
return this.getAttrBoolean('show-text');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
set showText(val) {
|
|
179
|
-
this.toggleAttr('show-text', val);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
get showTextList() {
|
|
183
|
-
return this.#textList;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
set showTextList(val) {
|
|
187
|
-
if (typeof val === "object" && val.length === 5) this.#textList = val;
|
|
188
|
-
}
|
|
189
|
-
// #endregion
|
|
190
|
-
// ------- end -------
|
|
191
|
-
|
|
192
|
-
// ------- void-icon-class 自定空图标样式类 -------
|
|
193
|
-
// #region
|
|
194
|
-
get voidIconClass() {
|
|
195
|
-
return this.getAttribute('void-icon-class') || 'icon-star-empty';
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
set voidIconClass(val) {
|
|
199
|
-
this.setAttribute('void-icon-class', val);
|
|
200
|
-
this.#wrap.querySelectorAll('.ea-rate_item').forEach(item => {
|
|
201
|
-
item.querySelector('i').className = val;
|
|
202
|
-
})
|
|
203
|
-
}
|
|
204
|
-
// #endregion
|
|
205
|
-
// ------- end -------
|
|
206
|
-
|
|
207
|
-
// ------- active-icon-class 自定图标样式类 -------
|
|
208
|
-
// #region
|
|
209
|
-
get activeIconClass() {
|
|
210
|
-
return this.getAttribute('active-icon-class') || 'icon-star';
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
set activeIconClass(val) {
|
|
214
|
-
this.setAttribute('active-icon-class', val);
|
|
215
|
-
this.#wrap.querySelectorAll('.ea-rate_item').forEach(item => {
|
|
216
|
-
item.querySelector('i').className = val;
|
|
217
|
-
})
|
|
218
|
-
}
|
|
219
|
-
// #endregion
|
|
220
|
-
// ------- end -------
|
|
221
|
-
|
|
222
|
-
// ------- disabled 禁用 -------
|
|
223
|
-
// #region
|
|
224
|
-
get disabled() {
|
|
225
|
-
return this.getAttrBoolean('disabled');
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
set disabled(val) {
|
|
229
|
-
this.toggleAttr('disabled', val);
|
|
230
|
-
|
|
231
|
-
this.#wrap.querySelectorAll('.ea-rate_item').forEach(item => {
|
|
232
|
-
item.classList.toggle('ea-rate_item--disabled', val);
|
|
233
|
-
})
|
|
234
|
-
}
|
|
235
|
-
// #endregion
|
|
236
|
-
// ------- end -------
|
|
237
|
-
|
|
238
|
-
// 初始化鼠标事件
|
|
239
|
-
initRateEvent() {
|
|
240
|
-
const that = this;
|
|
241
|
-
|
|
242
|
-
this.#wrap.querySelectorAll('.ea-rate_item').forEach(dom => {
|
|
243
|
-
|
|
244
|
-
// 鼠标移入: 显示选中状态
|
|
245
|
-
dom.addEventListener('mouseenter', function (e) {
|
|
246
|
-
const index = Number(this.getAttribute('data-index'));
|
|
247
|
-
|
|
248
|
-
that.clearCheckedStatus();
|
|
249
|
-
that.setCheckedStatus(index + 1);
|
|
250
|
-
|
|
251
|
-
that.dispatchEvent(new CustomEvent("hover", {
|
|
252
|
-
detail: {
|
|
253
|
-
value: index + 1,
|
|
254
|
-
rateText: that.#textList[index]
|
|
255
|
-
}
|
|
256
|
-
}));
|
|
257
|
-
})
|
|
258
|
-
|
|
259
|
-
// 鼠标移出: 清除选中状态
|
|
260
|
-
dom.addEventListener('mouseleave', function (e) {
|
|
261
|
-
that.clearCheckedStatus();
|
|
262
|
-
|
|
263
|
-
that.setCheckedStatus(that.value);
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
// 点击: 设置选中状态
|
|
267
|
-
dom.addEventListener('click', function (e) {
|
|
268
|
-
const index = Number(this.getAttribute('data-index'));
|
|
269
|
-
|
|
270
|
-
that.value = index + 1;
|
|
271
|
-
that.dispatchEvent(new CustomEvent("change", {
|
|
272
|
-
detail: {
|
|
273
|
-
value: index + 1,
|
|
274
|
-
rateText: that.#textList[index]
|
|
275
|
-
}
|
|
276
|
-
}))
|
|
277
|
-
})
|
|
278
|
-
})
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
init() {
|
|
282
|
-
const that = this;
|
|
283
|
-
|
|
284
|
-
// icon-class 自定图标样式类初始化
|
|
285
|
-
this.activeIconClass = this.activeIconClass;
|
|
286
|
-
|
|
287
|
-
// void-icon-class 自定空图标样式类初始化
|
|
288
|
-
this.voidIconClass = this.voidIconClass;
|
|
289
|
-
|
|
290
|
-
// show-text 显示文本初始化
|
|
291
|
-
this.showText = this.showText;
|
|
292
|
-
|
|
293
|
-
// color 颜色初始化
|
|
294
|
-
this.color = this.color;
|
|
295
|
-
|
|
296
|
-
// value 星级初始化
|
|
297
|
-
this.value = this.value;
|
|
298
|
-
|
|
299
|
-
// disabled 禁用初始化
|
|
300
|
-
this.disabled = this.disabled;
|
|
301
|
-
|
|
302
|
-
// 初始化鼠标事件
|
|
303
|
-
if (!this.disabled) this.initRateEvent();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
connectedCallback() {
|
|
307
|
-
this.init();
|
|
308
|
-
|
|
309
|
-
this.#mounted = true;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
313
|
-
if (!this.#mounted) return;
|
|
314
|
-
|
|
315
|
-
if (name == "value") {
|
|
316
|
-
|
|
317
|
-
this.clearCheckedStatus();
|
|
318
|
-
|
|
319
|
-
this.setCheckedStatus(newVal);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (!customElements.get('ea-rate')) {
|
|
325
|
-
customElements.define('ea-rate', EaRate);
|
|
326
|
-
}
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import{initRateTempalte}from"./src/components/rateComm.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaRate extends Base{#t;#e;#s;#i;#a;#o=["极差","失望","一般","满意","惊喜"];constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <div class="ea-rate_wrap" part="container">\n <section class="ea-rate_item-wrap" part="item-wrap">\n </section>\n <span class="ea-rate_text" part="text-wrap"></span>\n </div>\n ',this.#t=t.querySelector(".ea-rate_wrap"),this.#e=t.querySelector(".ea-rate_item-wrap"),this.#s=t.querySelector(".ea-rate_text"),initRateTempalte(this.#e),this.#i=t.querySelectorAll(".ea-rate_item"),this.#a=t.querySelectorAll("ea-icon"),this.build(t,stylesheet)}get value(){const t=this.getAttrNumber("value")||0;return t<1||t>5||!t?0:t}set value(t){t&&!isNaN(Number(t))&&(this.setAttribute("value",t),this.#r(),this.#n(t))}get color(){return this.getAttribute("color")}set color(t){t&&(this.setAttribute("color",t),this.#e.style.setProperty("--i-color",t))}get disabled(){return this.getAttrBoolean("disabled")}set disabled(t){this.toggleAttr("disabled",t),this.#i.forEach((e=>{e.classList.toggle("disabled",t)})),this.#t.style.cursor=t?"not-allowed":"pointer"}get showText(){return this.getAttrBoolean("show-text")}set showText(t){this.toggleAttr("show-text",t)}get showTextList(){return this.#o}set showTextList(t){"object"==typeof t&&5===t.length&&(this.#o=t)}get voidIcon(){return this.getAttribute("void-icon")||"icon-star-empty"}set voidIcon(t){this.setAttribute("void-icon",t),this.#c(t)}get activeIcon(){return this.getAttribute("active-icon")||"icon-star"}set activeIcon(t){this.setAttribute("active-icon",t),this.#c(t)}#c(t){this.#a.forEach((e=>{e.icon=t}))}#n(t){for(let e=0;e<t;e++)this.#i[e].classList.add("active"),this.#a[e].icon=this.activeIcon,this.showText&&(this.#s.innerText=this.showTextList[t-1])}#r(){this.#i.forEach(((t,e)=>{t.classList.remove("active"),this.#a[e].icon=this.voidIcon,this.showText&&(this.#s.innerText="")}))}#h(){this.#i.forEach((t=>{const{index:e}=t;t.addEventListener("mouseenter",(()=>{this.#r(),this.#n(e+1),this.dispatchEvent(new CustomEvent("hover",{detail:{value:e+1,rateText:this.#o[e]}}))})),t.addEventListener("mouseleave",(()=>{this.#r(),this.#n(this.value)})),t.addEventListener("click",(()=>{this.value=e+1,this.dispatchEvent(new CustomEvent("change",{detail:{value:e+1,rateText:this.#o[e]}}))}))}))}connectedCallback(){this.activeIconClass=this.activeIconClass,this.voidIconClass=this.voidIconClass,this.showText=this.showText,this.color=this.color,this.value=this.value,this.disabled=this.disabled,this.disabled||this.#h()}}customElements.get("ea-rate")||customElements.define("ea-rate",EaRate);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createElement}from"../../../../utils/createElement.js";const rateComm=e=>{const t=createElement("span","ea-rate_item");t.index=e,t.part="rate-item";const a=createElement("ea-icon");return a.icon="icon-star-empty",t.appendChild(a),t};export const initRateTempalte=e=>{for(let t=0;t<5;t++)e.appendChild(rateComm(t))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n:host {\n --i-color: rgb(247, 186, 42);\n}\n.ea-rate_wrap {\n position: relative;\n display: flex;\n align-items: center;\n}\n.ea-rate_wrap .ea-rate_item {\n cursor: pointer;\n}\n.ea-rate_wrap .ea-rate_item ea-icon::part(container) {\n color: var(--i-color);\n transition: color 0.3s, font-size 0.1s;\n}\n.ea-rate_wrap .ea-rate_item.active ea-icon::part(container) {\n font-size: 1.1rem;\n}\n.ea-rate_wrap .ea-rate_item.disabled {\n pointer-events: none;\n cursor: not-allowed;\n}\n.ea-rate_wrap .ea-rate_text {\n margin-left: 0.25rem;\n min-width: 2rem;\n font-size: 0.8rem;\n line-height: 0.8;\n vertical-align: middle;\n}\n.ea-rate_wrap .ea-rate_score {\n position: absolute;\n left: 0;\n top: 0;\n}\n.ea-rate_wrap .ea-rate_score .ea-rate_score_item {\n width: 24px;\n height: 24px;\n}\n.ea-rate_wrap .ea-rate_score .ea-rate_score_item > i {\n color: #c0c4cc;\n font-size: 1rem;\n line-height: 1;\n}\n";
|
|
@@ -1,167 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { createElement, createSlotElement } from '../../utils/createElement.js';
|
|
3
|
-
import { handleTemplate } from '../../utils/handleTemplate.js';
|
|
4
|
-
import Base from '../Base.js';
|
|
5
|
-
import "../ea-icon/index.js"
|
|
6
|
-
|
|
7
|
-
const stylesheet = `
|
|
8
|
-
.ea-result_wrap {
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
align-items: center;
|
|
13
|
-
box-sizing: border-box;
|
|
14
|
-
padding: 40px 30px;
|
|
15
|
-
}
|
|
16
|
-
.ea-result_wrap .ea-result_icon {
|
|
17
|
-
font-size: 3rem;
|
|
18
|
-
}
|
|
19
|
-
.ea-result_wrap .ea-result_icon i[class=icon-ok-circled] {
|
|
20
|
-
color: #67c23a;
|
|
21
|
-
}
|
|
22
|
-
.ea-result_wrap .ea-result_icon i[class=icon-cancel-circled] {
|
|
23
|
-
color: #f56c6c;
|
|
24
|
-
}
|
|
25
|
-
.ea-result_wrap .ea-result_icon i[class=icon-attention-alt] {
|
|
26
|
-
color: #e6a23c;
|
|
27
|
-
}
|
|
28
|
-
.ea-result_wrap .ea-result_icon i[class=icon-info] {
|
|
29
|
-
color: #909399;
|
|
30
|
-
}
|
|
31
|
-
.ea-result_wrap .ea-result_title,
|
|
32
|
-
.ea-result_wrap .ea-result_subtitle {
|
|
33
|
-
color: #5e6d82;
|
|
34
|
-
font-size: 14px;
|
|
35
|
-
}
|
|
36
|
-
.ea-result_wrap .ea-result_title {
|
|
37
|
-
margin-top: 20px;
|
|
38
|
-
}
|
|
39
|
-
.ea-result_wrap .ea-result_subtitle {
|
|
40
|
-
margin-top: 10px;
|
|
41
|
-
}
|
|
42
|
-
.ea-result_wrap .ea-result_extra {
|
|
43
|
-
margin-top: 30px;
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
export class EaResult extends Base {
|
|
48
|
-
#wrap;
|
|
49
|
-
|
|
50
|
-
#resultIcon;
|
|
51
|
-
#resultTitle;
|
|
52
|
-
#resultSubtitle;
|
|
53
|
-
#resultExtraWrap;
|
|
54
|
-
|
|
55
|
-
#resultIconSlot;
|
|
56
|
-
#resultTitleSlot;
|
|
57
|
-
#resultSubtitleSlot;
|
|
58
|
-
#resultExtraSlot;
|
|
59
|
-
|
|
60
|
-
constructor() {
|
|
61
|
-
super();
|
|
62
|
-
|
|
63
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
64
|
-
const wrap = document.createElement('div');
|
|
65
|
-
wrap.className = 'ea-result_wrap';
|
|
66
|
-
|
|
67
|
-
const iconWrap = createElement('div', 'ea-result_icon');
|
|
68
|
-
wrap.appendChild(iconWrap);
|
|
69
|
-
|
|
70
|
-
const resultTitle = createElement('div', 'ea-result_title');
|
|
71
|
-
wrap.appendChild(resultTitle);
|
|
72
|
-
|
|
73
|
-
const resultSubtitle = createElement('div', 'ea-result_subtitle');
|
|
74
|
-
wrap.appendChild(resultSubtitle);
|
|
75
|
-
|
|
76
|
-
const resultExtraWrap = createElement('div', 'ea-result_extra');
|
|
77
|
-
wrap.appendChild(resultExtraWrap);
|
|
78
|
-
|
|
79
|
-
const resultIconSlot = createSlotElement('icon');
|
|
80
|
-
const resultTitleSlot = createSlotElement('title');
|
|
81
|
-
const resultSubtitleSlot = createSlotElement('subTitle');
|
|
82
|
-
const resultExtraSlot = createSlotElement('extra');
|
|
83
|
-
|
|
84
|
-
this.#wrap = wrap;
|
|
85
|
-
this.#resultIcon = iconWrap;
|
|
86
|
-
this.#resultTitle = resultTitle;
|
|
87
|
-
this.#resultSubtitle = resultSubtitle;
|
|
88
|
-
this.#resultExtraWrap = resultExtraWrap;
|
|
89
|
-
|
|
90
|
-
this.#resultIconSlot = resultIconSlot;
|
|
91
|
-
this.#resultTitleSlot = resultTitleSlot;
|
|
92
|
-
this.#resultSubtitleSlot = resultSubtitleSlot;
|
|
93
|
-
this.#resultExtraSlot = resultExtraSlot;
|
|
94
|
-
|
|
95
|
-
this.build(shadowRoot, stylesheet);
|
|
96
|
-
this.setIconFile(new URL('../ea-icon/index.css', import.meta.url).href);
|
|
97
|
-
this.shadowRoot.appendChild(wrap);
|
|
98
|
-
|
|
99
|
-
shadowRoot.appendChild(resultIconSlot);
|
|
100
|
-
shadowRoot.appendChild(resultTitleSlot);
|
|
101
|
-
shadowRoot.appendChild(resultSubtitleSlot);
|
|
102
|
-
shadowRoot.appendChild(resultExtraSlot);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ------- icon 设置自定义icon -------
|
|
106
|
-
// #region
|
|
107
|
-
get icon() {
|
|
108
|
-
return this.getAttribute('icon') || '';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
set icon(value) {
|
|
112
|
-
this.setAttribute('icon', value);
|
|
113
|
-
|
|
114
|
-
this.#resultIcon.innerHTML = `<i class="${value}"></i>`;
|
|
115
|
-
}
|
|
116
|
-
// #endregion
|
|
117
|
-
// ------- end -------
|
|
118
|
-
|
|
119
|
-
// ------- title 设置标题 -------
|
|
120
|
-
// #region
|
|
121
|
-
get title() {
|
|
122
|
-
return this.getAttribute('title') || '';
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
set title(value) {
|
|
126
|
-
this.setAttribute('title', value);
|
|
127
|
-
|
|
128
|
-
this.#resultTitle.innerText = value;
|
|
129
|
-
}
|
|
130
|
-
// #endregion
|
|
131
|
-
// ------- end -------
|
|
132
|
-
|
|
133
|
-
// ------- sub-title 设置副标题 -------
|
|
134
|
-
// #region
|
|
135
|
-
get subtitle() {
|
|
136
|
-
return this.getAttribute('sub-title') || '';
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
set subtitle(value) {
|
|
140
|
-
this.setAttribute('sub-title', value);
|
|
141
|
-
|
|
142
|
-
this.#resultSubtitle.innerText = value;
|
|
143
|
-
}
|
|
144
|
-
// #endregion
|
|
145
|
-
// ------- end -------
|
|
146
|
-
|
|
147
|
-
init() {
|
|
148
|
-
const that = this;
|
|
149
|
-
|
|
150
|
-
this.icon = this.icon;
|
|
151
|
-
this.title = this.title;
|
|
152
|
-
this.subtitle = this.subtitle;
|
|
153
|
-
|
|
154
|
-
handleTemplate(this, "icon", this.#resultIcon, this.#resultIconSlot);
|
|
155
|
-
handleTemplate(this, "title", this.#resultTitle, this.#resultTitleSlot);
|
|
156
|
-
handleTemplate(this, "subTitle", this.#resultSubtitle, this.#resultSubtitleSlot);
|
|
157
|
-
handleTemplate(this, "extra", this.#resultExtraWrap, this.#resultExtraSlot);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
connectedCallback() {
|
|
161
|
-
this.init();
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (!customElements.get('ea-result')) {
|
|
166
|
-
customElements.define('ea-result', EaResult);
|
|
167
|
-
}
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import{stylesheet}from"./src/style/stylesheet.js";export class EaResult extends Base{#t;#e;#s;#l;#i;#r;#u;#n;#o;constructor(){super();const t=this.attachShadow({mode:"open"});t.innerHTML='\n <div class="ea-result_wrap" part="container">\n <div class="ea-result_icon" part="icon-wrap">\n <slot name="icon"></slot>\n </div>\n <div class="ea-result_title" part="title-wrap">\n <slot name="title"></slot>\n </div>\n <div class="ea-result_subtitle" part="subTitle-wrap">\n <slot name="subTitle"></slot>\n </div>\n <div class="ea-result_extra" part="extra-wrap">\n <slot name="extra"></slot>\n </div>\n </div>\n ',this.#t=t.querySelector(".ea-result_wrap"),this.#e=t.querySelector(".ea-result_icon"),this.#s=t.querySelector(".ea-result_title"),this.#l=t.querySelector(".ea-result_subtitle"),this.#i=t.querySelector(".ea-result_extra"),this.#r=t.querySelector('slot[name="icon"]'),this.#u=t.querySelector('slot[name="title"]'),this.#n=t.querySelector('slot[name="subTitle"]'),this.#o=t.querySelector('slot[name="extra"]'),this.build(t,stylesheet)}get icon(){return this.getAttribute("icon")||""}set icon(t){t&&(this.setAttribute("icon",t),this.#e.innerHTML=`<ea-icon icon="${t}"></ea-icon>`)}get title(){return this.getAttribute("title")||""}set title(t){t&&(this.setAttribute("title",t),this.#s.innerText=t)}get subtitle(){return this.getAttribute("sub-title")||""}set subtitle(t){t&&(this.setAttribute("sub-title",t),this.#l.innerText=t)}connectedCallback(){this.icon=this.icon,this.title=this.title,this.subtitle=this.subtitle}}customElements.get("ea-result")||customElements.define("ea-result",EaResult);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-result_wrap {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n padding: 40px 30px;\n}\n.ea-result_wrap .ea-result_icon {\n font-size: 3rem;\n}\n.ea-result_wrap .ea-result_icon ea-icon[icon=icon-ok-circled] {\n color: #67c23a;\n}\n.ea-result_wrap .ea-result_icon ea-icon[icon=icon-cancel-circled] {\n color: #f56c6c;\n}\n.ea-result_wrap .ea-result_icon ea-icon[icon=icon-attention-alt] {\n color: #e6a23c;\n}\n.ea-result_wrap .ea-result_icon ea-icon[icon=icon-info] {\n color: #909399;\n}\n.ea-result_wrap .ea-result_title,\n.ea-result_wrap .ea-result_subtitle {\n color: #5e6d82;\n font-size: 14px;\n}\n.ea-result_wrap .ea-result_title {\n margin-top: 20px;\n}\n.ea-result_wrap .ea-result_subtitle {\n margin-top: 10px;\n}\n.ea-result_wrap .ea-result_extra {\n margin-top: 30px;\n}\n";
|
|
@@ -1,34 +1 @@
|
|
|
1
|
-
import Base from
|
|
2
|
-
|
|
3
|
-
const stylesheet = `
|
|
4
|
-
@import url('/ea_ui_component/icon/index.css');
|
|
5
|
-
`;
|
|
6
|
-
|
|
7
|
-
export class EaSelect extends Base {
|
|
8
|
-
#wrap;
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
|
|
12
|
-
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
13
|
-
this.shadowRoot = shadowRoot;
|
|
14
|
-
const wrap = document.createElement('div');
|
|
15
|
-
wrap.className = 'ea-select_wrap';
|
|
16
|
-
|
|
17
|
-
this.#wrap = wrap;
|
|
18
|
-
|
|
19
|
-
this.build(shadowRoot, stylesheet);
|
|
20
|
-
this.shadowRoot.appendChild(wrap);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
init() {
|
|
24
|
-
const that = this;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
connectedCallback() {
|
|
28
|
-
this.init();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!window.customElements.get("ea-select")) {
|
|
33
|
-
window.customElements.define("ea-select", EaSelect);
|
|
34
|
-
}
|
|
1
|
+
import Base from"../Base.js";import"../ea-icon/index.js";import"../ea-option/index.js";import"../ea-option-gropu/index.js";import"../ea-input/index.js";import{stylesheet}from"./src/style/stylesheet.js";import{timeout,withTransitionTimeOut}from"../../utils/timeout.js";export class EaSelect extends Base{#e;#t;#i;#s;#n;constructor(){super();const e=this.attachShadow({mode:"open"});e.innerHTML='\n <div class="ea-select_wrap" part="container">\n <div class="ea-select_input-wrap" part="input-wrap">\n <ea-input type="text" part="input" readonly autocomplete="off"></ea-input>\n <span class="ea-select_dropdown-icon" part="dropdown-icon-wrap">\n <ea-icon part="icon" icon="icon-angle-down" color="#c0c4cc"></ea-icon>\n </span>\n </div>\n <div class="ea-select_dropdown-wrap" part="dropdown-wrap">\n <slot></slot>\n <slot name="empty" class="ea-select_dropdown-empty" style="display: none;">\n <p>暂无数据</p>\n </slot>\n </div>\n </div>\n ',this.#e=this.shadowRoot.querySelector(".ea-select_wrap"),this.#t=this.shadowRoot.querySelector("ea-input"),this.#i=this.shadowRoot.querySelector(".ea-select_dropdown-icon"),this.#s=this.shadowRoot.querySelector(".ea-select_dropdown-wrap"),this.#n=this.shadowRoot.querySelector(".ea-select_dropdown-empty"),this.build(e,stylesheet)}get name(){return this.getAttribute("name")||"select"}set name(e){this.setAttribute("name",e)}get width(){return this.getAttribute("width")||"200px"}set width(e){this.setAttribute("width",e),this.#e.style.width=e}get value(){const e=this.selection;return this.multiple?e.split(",")||[]:this.selection}set value(e){this.setAttribute("value",e),this.multiple?this.selection=e.join(","):this.selection=e}get selection(){return this.getAttribute("selection")||""}set selection(e){this.setAttribute("selection",e),this.#t.value=e}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(e){this.setAttribute("placeholder",e),this.#t.placeholder=e}get disabled(){return this.getAttrBoolean("disabled")||!1}set disabled(e){this.toggleAttr("disabled",e),this.#t.disabled=e}get clearable(){return this.getAttrBoolean("clearable")||!1}set clearable(e){if(this.setAttribute("clearable",e),e){const e=this.#i.querySelector("ea-icon");this.#i.addEventListener("mouseenter",(t=>{e.icon="icon-cancel-circled2"})),this.#i.addEventListener("mouseleave",(t=>{e.icon="icon-angle-down"})),this.#i.addEventListener("click",(e=>{this.dispatchEvent(new CustomEvent("clear",{detail:{originValue:this.selection}})),this.querySelectorAll("ea-option").forEach((e=>{e.checked=!1})),this.selection=""}))}}get filterable(){return this.getAttrBoolean("filterable")||!1}set filterable(e){this.setAttribute("filterable",e),this.#t.readonly=!1===e,e&&this.#t.addEventListener("change",(e=>{const t=this.querySelectorAll("ea-option"),{value:i}=e.detail;t.forEach((e=>{e.style.display=e.value.includes(i)?"block":"none"}));let s=Array.from(t).every((e=>"block"!==e.style.display));this.#n.style.display=s?"block":"none"}))}get multiple(){return this.getAttrBoolean("multiple")||!1}set multiple(e){this.setAttribute("multiple",e)}get isInvalid(){return this.getAttrBoolean("is-invalid")||!1}set isInvalid(e){this.setAttribute("is-invalid",e),this.#t.isInvalid=e}#l(){const e=this.querySelectorAll("ea-option");e.forEach((t=>{t.disabled||t.addEventListener("click",(i=>{if(this.multiple)if(t.checked=!t.checked,t.checked)this.selection=this.selection?this.selection+","+t.value:t.value;else{const e=this.selection.split(",");e.splice(e.indexOf(t.value),1),this.selection=e.join(",")}else this.#t.value=t.value,this.selection=t.value,e.forEach((e=>{e.checked=!1})),t.checked=!0;this.dispatchEvent(new CustomEvent("change",{detail:{value:this.selection}}))}))}))}connectedCallback(){this.setAttribute("data-ea-component",!0),this.#s.style.width=this.width,this.name=this.name,this.width=this.width,this.selection=this.selection,this.placeholder=this.placeholder,this.disabled=this.disabled,this.clearable=this.clearable,this.filterable=this.filterable,this.multiple=this.multiple,this.#l(),this.#t.addEventListener("focus",(e=>{this.#e.classList.add("is-open"),this.dispatchEvent(new CustomEvent("visible-change",{detail:{visible:!0}}))})),this.#t.addEventListener("blur",(e=>{timeout((()=>{this.#e.classList.remove("is-open")}),100),this.dispatchEvent(new CustomEvent("visible-change",{detail:{visible:!1}}))})),withTransitionTimeOut(this.#e)}}customElements.get("ea-select")||customElements.define("ea-select",EaSelect);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stylesheet="\n.ea-select_wrap {\n position: relative;\n}\n.ea-select_wrap .ea-select_input-wrap .ea-select_dropdown-icon {\n position: absolute;\n left: calc(100% - 24px);\n top: 50%;\n transform-origin: center;\n transform: translateY(-50%);\n}\n.ea-select_wrap .ea-select_input-wrap .ea-select_dropdown-icon.is-open {\n transform: translateY(-50%) rotate(180deg);\n}\n.ea-select_wrap .ea-select_dropdown-wrap {\n position: absolute;\n left: 0;\n bottom: -12px;\n transform: translateY(100%) scaleY(0);\n transform-origin: center top;\n box-sizing: border-box;\n background-color: #fff;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n z-index: 2035;\n}\n.ea-select_wrap .ea-select_dropdown-wrap .ea-select_dropdown-empty {\n padding: 10px 0;\n margin: 0;\n text-align: center;\n color: #999;\n font-size: 14px;\n}\n.ea-select_wrap.is-open .ea-select_input-wrap .ea-select_dropdown-icon {\n transform: translateY(-50%) rotate(180deg);\n}\n.ea-select_wrap.is-open .ea-select_dropdown-wrap {\n transform: translateY(100%) scaleY(1);\n}\n.ea-select_wrap.is-disabled {\n pointer-events: none;\n cursor: not-allowed;\n}\n.ea-select_wrap.with-transition .ea-select_input-wrap .ea-select_dropdown-icon {\n transition: transform 0.3s;\n}\n.ea-select_wrap.with-transition .ea-select_dropdown-wrap {\n transition: transform 0.3s;\n}\n";
|