@wc-kit/core 0.0.0-stage → 0.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/dist/index.cjs.js +4740 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +2047 -0
- package/dist/index.es.js +8066 -0
- package/dist/index.es.js.map +1 -0
- package/package.json +44 -4
- package/src/styles/reset.css +206 -0
- package/src/tokens/tokens.css +209 -0
- package/README.md +0 -3
|
@@ -0,0 +1,4740 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("lit"),s=require("lit/decorators.js"),Vr=require("lit/directives/unsafe-svg.js"),l=i.css`
|
|
2
|
+
*,
|
|
3
|
+
*::before,
|
|
4
|
+
*::after {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
:host {
|
|
9
|
+
display: inline-block;
|
|
10
|
+
font-family: var(--wc-font-family);
|
|
11
|
+
font-size: var(--wc-font-size-medium);
|
|
12
|
+
line-height: var(--wc-line-height-base);
|
|
13
|
+
color: var(--wc-color-text);
|
|
14
|
+
-webkit-tap-highlight-color: transparent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host([hidden]) {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:focus-visible {
|
|
22
|
+
outline: 2px solid var(--wc-color-focus-ring);
|
|
23
|
+
outline-offset: 2px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:focus:not(:focus-visible) {
|
|
27
|
+
outline: none;
|
|
28
|
+
}
|
|
29
|
+
`,Ur=i.css`
|
|
30
|
+
:host {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
/* component 层令牌:引用 semantic 层,允许按实例覆盖 */
|
|
33
|
+
--wc-button-height: 32px;
|
|
34
|
+
--wc-button-padding-x: var(--wc-space-4);
|
|
35
|
+
--wc-button-font-size: var(--wc-font-size-medium);
|
|
36
|
+
--wc-button-radius: var(--wc-radius-medium);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host([size='small']) {
|
|
40
|
+
--wc-button-height: 24px;
|
|
41
|
+
--wc-button-padding-x: var(--wc-space-2);
|
|
42
|
+
--wc-button-font-size: var(--wc-font-size-small);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:host([size='large']) {
|
|
46
|
+
--wc-button-height: 40px;
|
|
47
|
+
--wc-button-padding-x: 20px;
|
|
48
|
+
--wc-button-font-size: var(--wc-font-size-large);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host([block]) {
|
|
52
|
+
display: block;
|
|
53
|
+
width: 100%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.button {
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
gap: var(--wc-space-1);
|
|
61
|
+
width: 100%;
|
|
62
|
+
height: var(--wc-button-height);
|
|
63
|
+
padding: 0 var(--wc-button-padding-x);
|
|
64
|
+
border: 1px solid transparent;
|
|
65
|
+
border-radius: var(--wc-button-radius);
|
|
66
|
+
font-family: inherit;
|
|
67
|
+
font-size: var(--wc-button-font-size);
|
|
68
|
+
line-height: 1;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
user-select: none;
|
|
71
|
+
transition:
|
|
72
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
73
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
74
|
+
color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.button:disabled {
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.icon[hidden] {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* 纯图标按钮:宽度收为与高度相等的正方形 */
|
|
86
|
+
:host(.wc-button--icon-only) .button {
|
|
87
|
+
width: var(--wc-button-height);
|
|
88
|
+
padding: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* ---- theme 语义色变量:base 实色底与 outline/dashed/text/link 前景色统一从这里取 ---- */
|
|
92
|
+
:host {
|
|
93
|
+
--wc-button-theme-color: var(--wc-color-primary);
|
|
94
|
+
--wc-button-theme-hover: var(--wc-color-primary-hover);
|
|
95
|
+
--wc-button-theme-active: var(--wc-color-primary-active);
|
|
96
|
+
}
|
|
97
|
+
:host([theme='success']) {
|
|
98
|
+
--wc-button-theme-color: var(--wc-color-success);
|
|
99
|
+
--wc-button-theme-hover: var(--wc-color-success-dark);
|
|
100
|
+
--wc-button-theme-active: var(--wc-color-success-dark);
|
|
101
|
+
}
|
|
102
|
+
:host([theme='warning']) {
|
|
103
|
+
--wc-button-theme-color: var(--wc-color-warning);
|
|
104
|
+
--wc-button-theme-hover: var(--wc-color-warning-dark);
|
|
105
|
+
--wc-button-theme-active: var(--wc-color-warning-dark);
|
|
106
|
+
}
|
|
107
|
+
:host([theme='danger']) {
|
|
108
|
+
--wc-button-theme-color: var(--wc-color-error);
|
|
109
|
+
--wc-button-theme-hover: var(--wc-color-error-dark);
|
|
110
|
+
--wc-button-theme-active: var(--wc-color-error-dark);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* ---- theme: default ---- */
|
|
114
|
+
:host([variant='base']) .button {
|
|
115
|
+
background-color: var(--wc-color-bg-container);
|
|
116
|
+
border-color: var(--wc-color-border);
|
|
117
|
+
color: var(--wc-color-text);
|
|
118
|
+
}
|
|
119
|
+
:host([theme='default'][variant='base']) .button:hover:not(:disabled) {
|
|
120
|
+
border-color: var(--wc-button-theme-color);
|
|
121
|
+
color: var(--wc-button-theme-color);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ---- theme: primary / success / warning / danger 的 base 变体:实色底 ---- */
|
|
125
|
+
:host([theme='primary'][variant='base']) .button,
|
|
126
|
+
:host([theme='success'][variant='base']) .button,
|
|
127
|
+
:host([theme='warning'][variant='base']) .button,
|
|
128
|
+
:host([theme='danger'][variant='base']) .button {
|
|
129
|
+
background-color: var(--wc-button-theme-color);
|
|
130
|
+
border-color: var(--wc-button-theme-color);
|
|
131
|
+
color: var(--wc-color-text-anti);
|
|
132
|
+
}
|
|
133
|
+
:host([theme='primary'][variant='base']) .button:hover:not(:disabled),
|
|
134
|
+
:host([theme='success'][variant='base']) .button:hover:not(:disabled),
|
|
135
|
+
:host([theme='warning'][variant='base']) .button:hover:not(:disabled),
|
|
136
|
+
:host([theme='danger'][variant='base']) .button:hover:not(:disabled) {
|
|
137
|
+
background-color: var(--wc-button-theme-hover);
|
|
138
|
+
border-color: var(--wc-button-theme-hover);
|
|
139
|
+
color: var(--wc-color-text-anti);
|
|
140
|
+
}
|
|
141
|
+
:host([theme='primary'][variant='base']) .button:active:not(:disabled),
|
|
142
|
+
:host([theme='success'][variant='base']) .button:active:not(:disabled),
|
|
143
|
+
:host([theme='warning'][variant='base']) .button:active:not(:disabled),
|
|
144
|
+
:host([theme='danger'][variant='base']) .button:active:not(:disabled) {
|
|
145
|
+
background-color: var(--wc-button-theme-active);
|
|
146
|
+
border-color: var(--wc-button-theme-active);
|
|
147
|
+
color: var(--wc-color-text-anti);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* ---- variant: outline / dashed(继承 theme 色) ---- */
|
|
151
|
+
:host([variant='outline']) .button,
|
|
152
|
+
:host([variant='dashed']) .button {
|
|
153
|
+
background-color: transparent;
|
|
154
|
+
border-color: var(--wc-button-theme-color);
|
|
155
|
+
color: var(--wc-button-theme-color);
|
|
156
|
+
}
|
|
157
|
+
:host([variant='dashed']) .button {
|
|
158
|
+
border-style: dashed;
|
|
159
|
+
}
|
|
160
|
+
:host([variant='outline']) .button:hover:not(:disabled),
|
|
161
|
+
:host([variant='dashed']) .button:hover:not(:disabled) {
|
|
162
|
+
background-color: var(--wc-button-theme-hover);
|
|
163
|
+
border-color: var(--wc-button-theme-hover);
|
|
164
|
+
color: var(--wc-color-text-anti);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* ---- variant: text ---- */
|
|
168
|
+
:host([variant='text']) .button {
|
|
169
|
+
background-color: transparent;
|
|
170
|
+
border-color: transparent;
|
|
171
|
+
color: var(--wc-button-theme-color);
|
|
172
|
+
}
|
|
173
|
+
:host([variant='text']) .button:hover:not(:disabled) {
|
|
174
|
+
background-color: var(--wc-color-bg);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* ---- variant: link ---- */
|
|
178
|
+
:host([variant='link']) .button {
|
|
179
|
+
background-color: transparent;
|
|
180
|
+
border-color: transparent;
|
|
181
|
+
color: var(--wc-button-theme-color);
|
|
182
|
+
}
|
|
183
|
+
:host([variant='link']) .button:hover:not(:disabled) {
|
|
184
|
+
color: var(--wc-button-theme-hover);
|
|
185
|
+
text-decoration: underline;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* ---- 禁用态 ---- */
|
|
189
|
+
.button:disabled {
|
|
190
|
+
background-color: var(--wc-color-bg-disabled);
|
|
191
|
+
border-color: transparent;
|
|
192
|
+
color: var(--wc-color-text-disabled);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* ---- 加载态 spinner ---- */
|
|
196
|
+
.button[aria-busy='true'] .content {
|
|
197
|
+
opacity: 0.7;
|
|
198
|
+
}
|
|
199
|
+
`;var Yr=Object.defineProperty,oe=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Yr(e,t,r),r};const nt=class nt extends i.LitElement{constructor(){super(...arguments),this.theme="default",this.variant="base",this.size="medium",this.iconPosition="start",this.block=!1,this.disabled=!1,this.loading=!1,this._hasIcon=!1,this._hasText=!1}handleClick(e){this.loading&&(e.preventDefault(),e.stopImmediatePropagation())}render(){const e=i.html`<span class="icon" part="icon" ?hidden=${!this._hasIcon}>
|
|
200
|
+
<slot name="icon" @slotchange=${this._onIconSlotChange}></slot>
|
|
201
|
+
</span>`,t=i.html`<span class="content" part="content"
|
|
202
|
+
><slot @slotchange=${this._onTextSlotChange}></slot
|
|
203
|
+
></span>`;return i.html`
|
|
204
|
+
<button
|
|
205
|
+
part="base"
|
|
206
|
+
class="button"
|
|
207
|
+
?disabled=${this.disabled||this.loading}
|
|
208
|
+
aria-disabled=${this.disabled||this.loading}
|
|
209
|
+
aria-busy=${this.loading}
|
|
210
|
+
@click=${this.handleClick}
|
|
211
|
+
>
|
|
212
|
+
${this.iconPosition==="end"?[t,e]:[e,t]}
|
|
213
|
+
</button>
|
|
214
|
+
`}_onIconSlotChange(e){this._hasIcon=e.target.assignedElements({flatten:!0}).length>0,this._syncIconOnly(),this.requestUpdate()}_onTextSlotChange(e){const t=e.target.assignedNodes({flatten:!0});this._hasText=t.some(n=>(n.textContent??"").trim().length>0),this._syncIconOnly(),this.requestUpdate()}_syncIconOnly(){this.classList.toggle("wc-button--icon-only",this._hasIcon&&!this._hasText)}};nt.styles=[l,Ur];let k=nt;oe([s.property({reflect:!0})],k.prototype,"theme");oe([s.property({reflect:!0})],k.prototype,"variant");oe([s.property({reflect:!0})],k.prototype,"size");oe([s.property({reflect:!0,attribute:"icon-position"})],k.prototype,"iconPosition");oe([s.property({type:Boolean,reflect:!0})],k.prototype,"block");oe([s.property({type:Boolean,reflect:!0})],k.prototype,"disabled");oe([s.property({type:Boolean,reflect:!0})],k.prototype,"loading");customElements.get("wc-button")||customElements.define("wc-button",k);const Hr=i.css`
|
|
215
|
+
:host {
|
|
216
|
+
display: inline-block;
|
|
217
|
+
|
|
218
|
+
/* component 层令牌:首尾按钮保留的圆角 */
|
|
219
|
+
--wc-button-group-radius: var(--wc-radius-medium);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.group {
|
|
223
|
+
display: inline-flex;
|
|
224
|
+
vertical-align: middle;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/*
|
|
228
|
+
* ::slotted 只能作用于子 wc-button 的宿主元素,圆角与边距通过
|
|
229
|
+
* --wc-button-radius 自定义属性穿透进按钮的 Shadow DOM
|
|
230
|
+
*(外层作用域对宿主的声明优先于组件内 :host 声明)。
|
|
231
|
+
* 注意令牌名不能与按钮自身的 --wc-button-radius 同名,否则自引用失效。
|
|
232
|
+
*/
|
|
233
|
+
::slotted(wc-button) {
|
|
234
|
+
--wc-button-radius: 0;
|
|
235
|
+
position: relative;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* 相邻边框合并:后一个左移 1px 压在前一个边框上 */
|
|
239
|
+
::slotted(wc-button:not(:first-child)) {
|
|
240
|
+
margin-left: -1px;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* 悬停/聚焦的上层按钮边框完整可见 */
|
|
244
|
+
::slotted(wc-button:hover),
|
|
245
|
+
::slotted(wc-button:focus-within) {
|
|
246
|
+
z-index: 1;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
::slotted(wc-button:first-child) {
|
|
250
|
+
--wc-button-radius: var(--wc-button-group-radius) 0 0 var(--wc-button-group-radius);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
::slotted(wc-button:last-child) {
|
|
254
|
+
--wc-button-radius: 0 var(--wc-button-group-radius) var(--wc-button-group-radius) 0;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
::slotted(wc-button:only-child) {
|
|
258
|
+
--wc-button-radius: var(--wc-button-group-radius);
|
|
259
|
+
}
|
|
260
|
+
`,ct=class ct extends i.LitElement{render(){return i.html`<div class="group" part="base"><slot></slot></div>`}};ct.styles=[l,Hr];let Oe=ct;customElements.get("wc-button-group")||customElements.define("wc-button-group",Oe);const et=new Map,tt=new Map,Ke=new Map,Ge=new Set;function tr(o){return Ge.add(o),()=>Ge.delete(o)}function rr(){for(const o of[...Ge])o()}function or(o,e){et.set(o,e),rr()}function Kr(o){return et.get(o)}function ar(o,e){tt.set(o,e),rr()}function Wr(o){return tt.get(o)}function d(o,e,t="0 0 24 24"){return{name:o,svg:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${t}" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${e}</svg>`}}ar("default",{resolver:o=>et.get(o)??""});async function sr(o,e){const t=tt.get(o);if(!t)return"";const n=`${o}:${e}`;let r=Ke.get(n);r||(r=Promise.resolve(t.resolver(e)).catch(c=>""),Ke.set(n,r));const a=await r;if(!a)return Ke.delete(n),"";if(t.mutator&&typeof DOMParser<"u"){const u=new DOMParser().parseFromString(a,"text/html").querySelector("svg");if(u)return t.mutator(u),u.outerHTML}return a}const Xr=i.css`
|
|
261
|
+
:host {
|
|
262
|
+
display: inline-flex;
|
|
263
|
+
/* 尺寸默认 1em,跟随 font-size 缩放;颜色继承 currentColor */
|
|
264
|
+
width: 1em;
|
|
265
|
+
height: 1em;
|
|
266
|
+
flex-shrink: 0;
|
|
267
|
+
line-height: 1;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
[part='base'] {
|
|
271
|
+
display: flex;
|
|
272
|
+
width: 100%;
|
|
273
|
+
height: 100%;
|
|
274
|
+
align-items: center;
|
|
275
|
+
justify-content: center;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
svg {
|
|
279
|
+
display: block;
|
|
280
|
+
width: 100%;
|
|
281
|
+
height: 100%;
|
|
282
|
+
/* 不设 fill:描边图标由 SVG 根的 fill="none" 决定(CSS 会覆盖 presentation attribute,
|
|
283
|
+
设 fill: currentColor 会把闭合形状整体填充导致发糊);填充型图标由各自 SVG 声明。
|
|
284
|
+
颜色统一走 color → stroke="currentColor" 继承。 */
|
|
285
|
+
color: currentColor;
|
|
286
|
+
pointer-events: none;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
:host([spin]) svg,
|
|
290
|
+
:host([pulse]) svg {
|
|
291
|
+
transform-origin: center;
|
|
292
|
+
animation: wc-spin var(--wc-duration-slow, 1s) linear infinite;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* pulse:旋转 + 缓动呼吸感,用于加载中区分度更高的场景 */
|
|
296
|
+
:host([pulse]) svg {
|
|
297
|
+
animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@keyframes wc-spin {
|
|
301
|
+
from {
|
|
302
|
+
rotate: 0deg;
|
|
303
|
+
}
|
|
304
|
+
to {
|
|
305
|
+
rotate: 360deg;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@media (prefers-reduced-motion: reduce) {
|
|
310
|
+
:host([spin]) svg,
|
|
311
|
+
:host([pulse]) svg {
|
|
312
|
+
animation: none;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
`;var Gr=Object.defineProperty,ae=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Gr(e,t,r),r};const lt=class lt extends i.LitElement{constructor(){super(...arguments),this.name="",this.src="",this.library="default",this.label="",this.spin=!1,this.pulse=!1,this.svg="",this.requestId=0}willUpdate(e){(e.has("src")||e.has("name")||e.has("library"))&&this.loadIcon()}disconnectedCallback(){this.unwatchRegister?.()}async loadIcon(){this.unwatchRegister?.(),this.unwatchRegister=void 0;const e=++this.requestId,t=this.name&&!this.src?tr(()=>{this.loadIcon()}):null;let n="";if(this.src?n=await this.fetchSrc(this.src):this.name&&(n=await sr(this.library,this.name)),e!==this.requestId){t?.();return}n||!t?t?.():this.unwatchRegister=t,this.svg=n}async fetchSrc(e){if(typeof fetch!="function")return"";try{const t=await fetch(e);return t.ok?await t.text():""}catch{return""}}render(){return i.html`
|
|
316
|
+
<span
|
|
317
|
+
part="base"
|
|
318
|
+
role=${this.label?"img":"presentation"}
|
|
319
|
+
aria-label=${this.label||i.nothing}
|
|
320
|
+
aria-hidden=${this.label?i.nothing:"true"}
|
|
321
|
+
>${this.svg?Vr.unsafeSVG(this.svg):i.nothing}</span
|
|
322
|
+
>
|
|
323
|
+
`}};lt.styles=[l,Xr];let $=lt;ae([s.property()],$.prototype,"name");ae([s.property()],$.prototype,"src");ae([s.property()],$.prototype,"library");ae([s.property()],$.prototype,"label");ae([s.property({type:Boolean,reflect:!0})],$.prototype,"spin");ae([s.property({type:Boolean,reflect:!0})],$.prototype,"pulse");ae([s.state()],$.prototype,"svg");customElements.get("wc-icon")||customElements.define("wc-icon",$);function M(o){const t=class t extends o{constructor(...r){super(...r),this.name="",this.disabled=!1,this.internals=this.attachInternals()}get value(){}set value(r){}formResetCallback(){this.value=this.defaultValue}get defaultValue(){}};t.formAssociated=!0,t.properties={name:{type:String},disabled:{type:Boolean,reflect:!0}};let e=t;return e}const Zr={"select.placeholder":"Select","select.empty":"No data","pagination.total":"{total} items in total","pagination.prev":"Previous page","pagination.next":"Next page","pagination.label":"Pagination","pagination.page":"Page {page}","pagination.jumpTo":"Go to","pagination.pageUnit":"Page","dialog.confirm":"Confirm","dialog.cancel":"Cancel","empty.noData":"No data","table.empty":"No data in table","input.clear":"Clear","inputNumber.increment":"Increment","inputNumber.decrement":"Decrement","datePicker.placeholder":"Select date","datePicker.today":"Today","datePicker.prevYear":"Previous year","datePicker.prevMonth":"Previous month","datePicker.nextMonth":"Next month","datePicker.nextYear":"Next year","form.required":"{name} is required","form.min":"{name} must be no less than {min}","form.max":"{name} must be no greater than {max}","form.minLength":"{name} must be at least {minLength} characters","form.maxLength":"{name} must be at most {maxLength} characters","form.pattern":"{name} format is invalid","form.invalid":"{name} is invalid","tag.close":"Remove","dialog.close":"Close","message.close":"Close","breadcrumb.label":"Breadcrumb","image.loadError":"Failed to load image","image.preview":"Preview","image.zoomIn":"Zoom in","image.zoomOut":"Zoom out","image.rotate":"Rotate","image.reset":"Reset","image.close":"Close","upload.upload":"Upload","upload.clickOrDrag":"Click or drag file here to upload","upload.failed":"Upload failed","upload.retry":"Retry","upload.remove":"Remove","upload.preview":"Preview"},Jr={"select.placeholder":"请选择","select.empty":"暂无数据","pagination.total":"共 {total} 条","pagination.prev":"上一页","pagination.next":"下一页","pagination.label":"分页导航","pagination.page":"第 {page} 页","pagination.jumpTo":"跳至","pagination.pageUnit":"页","dialog.confirm":"确认","dialog.cancel":"取消","empty.noData":"暂无数据","table.empty":"表格暂无数据","input.clear":"清空","inputNumber.increment":"增加","inputNumber.decrement":"减少","datePicker.placeholder":"请选择日期","datePicker.today":"今天","datePicker.prevYear":"上一年","datePicker.prevMonth":"上个月","datePicker.nextMonth":"下个月","datePicker.nextYear":"下一年","form.required":"{name}不能为空","form.min":"{name}不能小于{min}","form.max":"{name}不能大于{max}","form.minLength":"{name}至少{minLength}个字符","form.maxLength":"{name}最多{maxLength}个字符","form.pattern":"{name}格式不正确","form.invalid":"{name}校验不通过","tag.close":"删除","dialog.close":"关闭","message.close":"关闭","breadcrumb.label":"面包屑导航","image.loadError":"图片加载失败","image.preview":"预览","image.zoomIn":"放大","image.zoomOut":"缩小","image.rotate":"旋转","image.reset":"重置","image.close":"关闭","upload.upload":"上传文件","upload.clickOrDrag":"点击或拖拽文件到此处上传","upload.failed":"上传失败","upload.retry":"重新上传","upload.remove":"移除","upload.preview":"预览"},Pe="wc-language-change",ee=new Map([["zh-CN",{...Jr}],["en-US",{...Zr}]]);let xe="zh-CN";function Qr(o,e){const t=ee.get(o);ee.set(o,Object.assign({},t,e)),o===xe&&cr()}function eo(o){if(!/^[a-zA-Z]{2,3}(-[a-zA-Z0-9]+)*$/.test(o))throw new Error(`[wc] 无效的语言标识: "${o}",需符合 BCP 47 格式,如 zh-CN`);o!==xe&&(xe=o,cr())}function ir(){return xe}function rt(o){if(ee.has(o))return o;const e=o.split("-")[0]?.toLowerCase();for(const t of ee.keys())if(t.split("-")[0]?.toLowerCase()===e)return t;return"zh-CN"}function nr(o,e,t){const n=ee.get(rt(o)),r=ee.get("zh-CN");let a=n?.[e]??r?.[e]??e;return t&&(a=a.replace(/\{(\w+)\}/g,(c,u)=>u in t?String(t[u]):c)),a}function to(){return[...ee.keys()]}function cr(){document.dispatchEvent(new CustomEvent(Pe,{detail:{locale:xe},bubbles:!0,composed:!0}))}class v{constructor(e){this.handleLanguageChange=()=>{this.host.requestUpdate()},this.host=e,e.addController(this)}hostConnected(){document.addEventListener(Pe,this.handleLanguageChange)}hostDisconnected(){document.removeEventListener(Pe,this.handleLanguageChange)}term(e,t){return nr(this.resolvedLocale,e,t)}date(e,t){const{locale:n,...r}=t??{};return new Intl.DateTimeFormat(n??this.resolvedLocale,r).format(e)}number(e,t){const{locale:n,...r}=t??{};return new Intl.NumberFormat(n??this.resolvedLocale,r).format(e)}get resolvedLocale(){const e=this.host.getAttribute("lang");return e?rt(e):ir()}}const ro=i.css`
|
|
324
|
+
:host {
|
|
325
|
+
display: inline-block;
|
|
326
|
+
width: 240px;
|
|
327
|
+
|
|
328
|
+
/* component 层令牌 */
|
|
329
|
+
--wc-input-height: 32px;
|
|
330
|
+
--wc-input-padding-x: var(--wc-space-2);
|
|
331
|
+
--wc-input-font-size: var(--wc-font-size-medium);
|
|
332
|
+
--wc-input-radius: var(--wc-radius-medium);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
:host([size='small']) {
|
|
336
|
+
--wc-input-height: 24px;
|
|
337
|
+
--wc-input-padding-x: var(--wc-space-1);
|
|
338
|
+
--wc-input-font-size: var(--wc-font-size-small);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
:host([size='large']) {
|
|
342
|
+
--wc-input-height: 40px;
|
|
343
|
+
--wc-input-padding-x: var(--wc-space-3);
|
|
344
|
+
--wc-input-font-size: var(--wc-font-size-large);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.input {
|
|
348
|
+
display: inline-flex;
|
|
349
|
+
align-items: center;
|
|
350
|
+
gap: var(--wc-space-1);
|
|
351
|
+
width: 100%;
|
|
352
|
+
height: var(--wc-input-height);
|
|
353
|
+
padding: 0 var(--wc-input-padding-x);
|
|
354
|
+
background-color: var(--wc-color-bg-container);
|
|
355
|
+
border: 1px solid var(--wc-color-border);
|
|
356
|
+
border-radius: var(--wc-input-radius);
|
|
357
|
+
transition:
|
|
358
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
359
|
+
box-shadow var(--wc-duration-fast) var(--wc-easing-standard),
|
|
360
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* 焦点态:外层容器统一呈现,内层去掉原生 outline 避免双重 */
|
|
364
|
+
.input:focus-within {
|
|
365
|
+
border-color: var(--wc-color-primary);
|
|
366
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.inner {
|
|
370
|
+
flex: 1;
|
|
371
|
+
min-width: 0;
|
|
372
|
+
height: 100%;
|
|
373
|
+
font-family: inherit;
|
|
374
|
+
font-size: var(--wc-input-font-size);
|
|
375
|
+
color: var(--wc-color-text);
|
|
376
|
+
background: transparent;
|
|
377
|
+
border: none;
|
|
378
|
+
outline: none;
|
|
379
|
+
caret-color: var(--wc-color-primary);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.inner::placeholder {
|
|
383
|
+
color: var(--wc-color-text-placeholder);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.inner:disabled {
|
|
387
|
+
cursor: not-allowed;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.affix {
|
|
391
|
+
display: inline-flex;
|
|
392
|
+
align-items: center;
|
|
393
|
+
color: var(--wc-color-text-placeholder);
|
|
394
|
+
flex-shrink: 0;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.affix[hidden] {
|
|
398
|
+
display: none;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.clear {
|
|
402
|
+
width: 16px;
|
|
403
|
+
height: 16px;
|
|
404
|
+
justify-content: center;
|
|
405
|
+
padding: 0;
|
|
406
|
+
border: none;
|
|
407
|
+
border-radius: var(--wc-radius-circle);
|
|
408
|
+
background: transparent;
|
|
409
|
+
color: var(--wc-color-text-placeholder);
|
|
410
|
+
cursor: pointer;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/* wc-icon 的 :host 自带 text 色,这里让叉号跟随按钮的灰阶 */
|
|
414
|
+
.clear wc-icon {
|
|
415
|
+
color: inherit;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.clear:hover {
|
|
419
|
+
color: var(--wc-color-text-secondary);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/* ---- 校验状态 ---- */
|
|
423
|
+
:host([status='success']) .input {
|
|
424
|
+
border-color: var(--wc-color-success);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
:host([status='warning']) .input {
|
|
428
|
+
border-color: var(--wc-color-warning);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
:host([status='error']) .input {
|
|
432
|
+
border-color: var(--wc-color-error);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
:host([status='error']) .input:focus-within {
|
|
436
|
+
border-color: var(--wc-color-error);
|
|
437
|
+
box-shadow: 0 0 0 2px var(--wc-color-error-light);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/* ---- 禁用 / 只读 ---- */
|
|
441
|
+
:host([disabled]) .input {
|
|
442
|
+
background-color: var(--wc-color-bg-disabled);
|
|
443
|
+
border-color: transparent;
|
|
444
|
+
cursor: not-allowed;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
:host([disabled]) .inner {
|
|
448
|
+
color: var(--wc-color-text-disabled);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
:host([readonly]) .input {
|
|
452
|
+
border-style: dashed;
|
|
453
|
+
}
|
|
454
|
+
`;var oo=Object.defineProperty,ao=Object.getOwnPropertyDescriptor,N=(o,e,t,n)=>{for(var r=n>1?void 0:n?ao(e,t):e,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=(n?c(e,t,r):c(r))||r);return n&&r&&oo(e,t,r),r};const dt=class dt extends M(i.LitElement){constructor(){super(...arguments),this._value="",this.type="text",this.size="medium",this.placeholder="",this.label="",this.readonly=!1,this.clearable=!1,this.status="default",this.localize=new v(this),this._hasPrefix=!1,this._hasSuffix=!1}get value(){return this._value}set value(e){const t=this._value;this._value=e??"",this.requestUpdate("value",t)}get defaultValue(){return this.getAttribute("value")??""}updated(e){super.updated(e),e.has("value")&&this.internals.setFormValue(this.value||null)}formResetCallback(){super.formResetCallback(),this.internals.setFormValue(this.value||null)}handleInput(e){const t=e.target;this.value=t.value,this.dispatchEvent(new CustomEvent("wc-input",{detail:{value:this.value},bubbles:!0,composed:!0}))}handleChange(){this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}handleClear(e){e.preventDefault(),this.value="",this.dispatchEvent(new CustomEvent("wc-clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:""},bubbles:!0,composed:!0})),this.requestUpdate(),this.shadowRoot.querySelector("input")?.focus()}render(){const e=this.clearable&&this.value&&!this.disabled&&!this.readonly;return i.html`
|
|
455
|
+
<div class="input" part="base">
|
|
456
|
+
<span class="affix prefix" part="prefix" ?hidden=${!this._hasPrefix}>
|
|
457
|
+
<slot name="prefix" @slotchange=${this._onPrefixSlotChange}></slot>
|
|
458
|
+
</span>
|
|
459
|
+
<input
|
|
460
|
+
part="input"
|
|
461
|
+
class="inner"
|
|
462
|
+
.value=${this.value}
|
|
463
|
+
type=${this.type}
|
|
464
|
+
?disabled=${this.disabled}
|
|
465
|
+
?readonly=${this.readonly}
|
|
466
|
+
placeholder=${this.placeholder}
|
|
467
|
+
maxlength=${this.maxlength??-1}
|
|
468
|
+
aria-label=${this.label||void 0}
|
|
469
|
+
@input=${this.handleInput}
|
|
470
|
+
@change=${this.handleChange}
|
|
471
|
+
/>
|
|
472
|
+
${e?i.html`
|
|
473
|
+
<button
|
|
474
|
+
type="button"
|
|
475
|
+
class="affix clear"
|
|
476
|
+
part="clear-button"
|
|
477
|
+
tabindex="-1"
|
|
478
|
+
aria-label=${this.localize.term("input.clear")}
|
|
479
|
+
@mousedown=${this.handleClear}
|
|
480
|
+
>
|
|
481
|
+
<wc-icon name="close"></wc-icon>
|
|
482
|
+
</button>
|
|
483
|
+
`:""}
|
|
484
|
+
<span class="affix suffix" part="suffix" ?hidden=${!this._hasSuffix}>
|
|
485
|
+
<slot name="suffix" @slotchange=${this._onSuffixSlotChange}></slot>
|
|
486
|
+
</span>
|
|
487
|
+
</div>
|
|
488
|
+
`}_onPrefixSlotChange(e){this._hasPrefix=e.target.assignedElements({flatten:!0}).length>0,this.requestUpdate()}_onSuffixSlotChange(e){this._hasSuffix=e.target.assignedElements({flatten:!0}).length>0,this.requestUpdate()}};dt.styles=[l,ro];let b=dt;N([s.property()],b.prototype,"value",1);N([s.property()],b.prototype,"type",2);N([s.property({reflect:!0})],b.prototype,"size",2);N([s.property()],b.prototype,"placeholder",2);N([s.property()],b.prototype,"label",2);N([s.property({type:Number})],b.prototype,"maxlength",2);N([s.property({type:Boolean,reflect:!0})],b.prototype,"readonly",2);N([s.property({type:Boolean,reflect:!0})],b.prototype,"clearable",2);N([s.property({reflect:!0})],b.prototype,"status",2);customElements.get("wc-input")||customElements.define("wc-input",b);const so=i.css`
|
|
489
|
+
:host {
|
|
490
|
+
display: inline-block;
|
|
491
|
+
width: 320px;
|
|
492
|
+
|
|
493
|
+
/* component 层令牌 */
|
|
494
|
+
--wc-textarea-min-height: 80px;
|
|
495
|
+
--wc-textarea-padding-y: var(--wc-space-2);
|
|
496
|
+
--wc-textarea-padding-x: var(--wc-space-2);
|
|
497
|
+
--wc-textarea-font-size: var(--wc-font-size-medium);
|
|
498
|
+
--wc-textarea-radius: var(--wc-radius-medium);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.textarea {
|
|
502
|
+
position: relative;
|
|
503
|
+
display: inline-flex;
|
|
504
|
+
width: 100%;
|
|
505
|
+
min-height: var(--wc-textarea-min-height);
|
|
506
|
+
background-color: var(--wc-color-bg-container);
|
|
507
|
+
border: 1px solid var(--wc-color-border);
|
|
508
|
+
border-radius: var(--wc-textarea-radius);
|
|
509
|
+
transition:
|
|
510
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
511
|
+
box-shadow var(--wc-duration-fast) var(--wc-easing-standard),
|
|
512
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.textarea:focus-within {
|
|
516
|
+
border-color: var(--wc-color-primary);
|
|
517
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.inner {
|
|
521
|
+
flex: 1;
|
|
522
|
+
width: 100%;
|
|
523
|
+
padding: var(--wc-textarea-padding-y) var(--wc-textarea-padding-x);
|
|
524
|
+
font-family: inherit;
|
|
525
|
+
font-size: var(--wc-textarea-font-size);
|
|
526
|
+
line-height: var(--wc-line-height-base);
|
|
527
|
+
color: var(--wc-color-text);
|
|
528
|
+
background: transparent;
|
|
529
|
+
border: none;
|
|
530
|
+
outline: none;
|
|
531
|
+
resize: vertical;
|
|
532
|
+
caret-color: var(--wc-color-primary);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/* autosize 时接管高度,禁用手动拉伸 */
|
|
536
|
+
:host([autosize]) .inner {
|
|
537
|
+
resize: none;
|
|
538
|
+
overflow: hidden;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.inner::placeholder {
|
|
542
|
+
color: var(--wc-color-text-placeholder);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.inner:disabled {
|
|
546
|
+
cursor: not-allowed;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.count {
|
|
550
|
+
position: absolute;
|
|
551
|
+
right: var(--wc-textarea-padding-x);
|
|
552
|
+
bottom: var(--wc-textarea-padding-y);
|
|
553
|
+
font-size: var(--wc-font-size-small);
|
|
554
|
+
color: var(--wc-color-text-placeholder);
|
|
555
|
+
background: var(--wc-color-bg-container);
|
|
556
|
+
pointer-events: none;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
:host([status='success']) .textarea {
|
|
560
|
+
border-color: var(--wc-color-success);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
:host([status='warning']) .textarea {
|
|
564
|
+
border-color: var(--wc-color-warning);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
:host([status='error']) .textarea {
|
|
568
|
+
border-color: var(--wc-color-error);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
:host([status='error']) .textarea:focus-within {
|
|
572
|
+
border-color: var(--wc-color-error);
|
|
573
|
+
box-shadow: 0 0 0 2px var(--wc-color-error-light);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
:host([disabled]) .textarea {
|
|
577
|
+
background-color: var(--wc-color-bg-disabled);
|
|
578
|
+
border-color: transparent;
|
|
579
|
+
cursor: not-allowed;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
:host([disabled]) .inner {
|
|
583
|
+
color: var(--wc-color-text-disabled);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
:host([readonly]) .textarea {
|
|
587
|
+
border-style: dashed;
|
|
588
|
+
}
|
|
589
|
+
`;var io=Object.defineProperty,no=Object.getOwnPropertyDescriptor,J=(o,e,t,n)=>{for(var r=n>1?void 0:n?no(e,t):e,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=(n?c(e,t,r):c(r))||r);return n&&r&&io(e,t,r),r};const ht=class ht extends M(i.LitElement){constructor(){super(...arguments),this._value="",this.placeholder="",this.label="",this.rows=3,this.autosize=!1,this.readonly=!1,this.status="default"}get value(){return this._value}set value(e){const t=this._value;this._value=e??"",this.requestUpdate("value",t)}get defaultValue(){return this.getAttribute("value")??""}updated(e){super.updated(e),e.has("value")&&this.internals.setFormValue(this.value||null),e.has("value")&&this.autosize&&this.autoResize()}formResetCallback(){super.formResetCallback(),this.internals.setFormValue(this.value||null)}handleInput(e){const t=e.target;this.value=t.value,this.dispatchEvent(new CustomEvent("wc-input",{detail:{value:this.value},bubbles:!0,composed:!0})),this.autosize&&this.autoResize()}handleChange(){this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}autoResize(){const e=this.shadowRoot.querySelector("textarea");e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)}render(){return i.html`
|
|
590
|
+
<div class="textarea" part="base">
|
|
591
|
+
<textarea
|
|
592
|
+
part="textarea"
|
|
593
|
+
class="inner"
|
|
594
|
+
.value=${this.value}
|
|
595
|
+
rows=${this.rows}
|
|
596
|
+
?disabled=${this.disabled}
|
|
597
|
+
?readonly=${this.readonly}
|
|
598
|
+
placeholder=${this.placeholder}
|
|
599
|
+
maxlength=${this.maxlength??-1}
|
|
600
|
+
aria-label=${this.label||void 0}
|
|
601
|
+
@input=${this.handleInput}
|
|
602
|
+
@change=${this.handleChange}
|
|
603
|
+
></textarea>
|
|
604
|
+
${this.maxlength?i.html`<span class="count" part="count">${this.value.length}/${this.maxlength}</span>`:""}
|
|
605
|
+
</div>
|
|
606
|
+
`}};ht.styles=[l,so];let y=ht;J([s.property()],y.prototype,"value",1);J([s.property()],y.prototype,"placeholder",2);J([s.property()],y.prototype,"label",2);J([s.property({type:Number})],y.prototype,"maxlength",2);J([s.property({type:Number})],y.prototype,"rows",2);J([s.property({type:Boolean,reflect:!0})],y.prototype,"autosize",2);J([s.property({type:Boolean,reflect:!0})],y.prototype,"readonly",2);J([s.property({reflect:!0})],y.prototype,"status",2);customElements.get("wc-textarea")||customElements.define("wc-textarea",y);const co=i.css`
|
|
607
|
+
:host {
|
|
608
|
+
display: inline-block;
|
|
609
|
+
|
|
610
|
+
/* component 层令牌 */
|
|
611
|
+
--wc-checkbox-size: 16px;
|
|
612
|
+
--wc-checkbox-radius: var(--wc-radius-small);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.checkbox {
|
|
616
|
+
display: inline-flex;
|
|
617
|
+
align-items: center;
|
|
618
|
+
gap: var(--wc-space-2);
|
|
619
|
+
font-size: var(--wc-font-size-medium);
|
|
620
|
+
color: var(--wc-color-text);
|
|
621
|
+
cursor: pointer;
|
|
622
|
+
user-select: none;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/* 原生 input 隐藏但保持可聚焦(键盘空格切换) */
|
|
626
|
+
.native {
|
|
627
|
+
position: absolute;
|
|
628
|
+
width: 1px;
|
|
629
|
+
height: 1px;
|
|
630
|
+
margin: 0;
|
|
631
|
+
opacity: 0;
|
|
632
|
+
pointer-events: none;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
.box {
|
|
636
|
+
position: relative;
|
|
637
|
+
display: inline-flex;
|
|
638
|
+
align-items: center;
|
|
639
|
+
justify-content: center;
|
|
640
|
+
width: var(--wc-checkbox-size);
|
|
641
|
+
height: var(--wc-checkbox-size);
|
|
642
|
+
background-color: var(--wc-color-bg-container);
|
|
643
|
+
border: 1px solid var(--wc-color-border-strong);
|
|
644
|
+
border-radius: var(--wc-checkbox-radius);
|
|
645
|
+
color: var(--wc-color-text-anti);
|
|
646
|
+
flex-shrink: 0;
|
|
647
|
+
transition:
|
|
648
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
649
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.check {
|
|
653
|
+
width: 12px;
|
|
654
|
+
height: 12px;
|
|
655
|
+
opacity: 0;
|
|
656
|
+
transform: scale(0.5);
|
|
657
|
+
transition:
|
|
658
|
+
opacity var(--wc-duration-fast) var(--wc-easing-standard),
|
|
659
|
+
transform var(--wc-duration-fast) var(--wc-easing-standard);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
.dash {
|
|
663
|
+
position: absolute;
|
|
664
|
+
width: 8px;
|
|
665
|
+
height: 2px;
|
|
666
|
+
border-radius: 1px;
|
|
667
|
+
background: currentColor;
|
|
668
|
+
opacity: 0;
|
|
669
|
+
transform: scale(0.5);
|
|
670
|
+
transition:
|
|
671
|
+
opacity var(--wc-duration-fast) var(--wc-easing-standard),
|
|
672
|
+
transform var(--wc-duration-fast) var(--wc-easing-standard);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/* 键盘焦点环 */
|
|
676
|
+
.native:focus-visible + .box {
|
|
677
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/* 选中态 */
|
|
681
|
+
:host([checked]) .box {
|
|
682
|
+
background-color: var(--wc-color-primary);
|
|
683
|
+
border-color: var(--wc-color-primary);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
:host([checked]) .check {
|
|
687
|
+
opacity: 1;
|
|
688
|
+
transform: scale(1);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/* 半选态(优先于选中态图标) */
|
|
692
|
+
:host([indeterminate]) .box {
|
|
693
|
+
background-color: var(--wc-color-primary);
|
|
694
|
+
border-color: var(--wc-color-primary);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
:host([indeterminate]) .check {
|
|
698
|
+
opacity: 0;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
:host([indeterminate]) .dash {
|
|
702
|
+
opacity: 1;
|
|
703
|
+
transform: scale(1);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/* 悬停 */
|
|
707
|
+
.checkbox:hover .box:not(.native:disabled + .box) {
|
|
708
|
+
border-color: var(--wc-color-primary);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/* 禁用 */
|
|
712
|
+
:host([disabled]) .checkbox {
|
|
713
|
+
cursor: not-allowed;
|
|
714
|
+
color: var(--wc-color-text-disabled);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
:host([disabled]) .box {
|
|
718
|
+
background-color: var(--wc-color-bg-disabled);
|
|
719
|
+
border-color: var(--wc-color-border);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
:host([disabled][checked]) .box,
|
|
723
|
+
:host([disabled][indeterminate]) .box {
|
|
724
|
+
background-color: var(--wc-color-border);
|
|
725
|
+
border-color: var(--wc-color-border);
|
|
726
|
+
color: var(--wc-color-text-disabled);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.label {
|
|
730
|
+
line-height: var(--wc-line-height-base);
|
|
731
|
+
}
|
|
732
|
+
`;var lo=Object.defineProperty,Te=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&lo(e,t,r),r};const pt=class pt extends M(i.LitElement){constructor(){super(),this.checked=!1,this.indeterminate=!1,this.value="on",this.label="",this.initialChecked=!1,this.initialChecked=this.hasAttribute("checked")}get defaultValue(){return this.initialChecked?this.value:null}updated(e){super.updated(e),(e.has("checked")||e.has("value"))&&this.internals.setFormValue(this.checked?this.value:null)}formResetCallback(){super.formResetCallback(),this.checked=this.initialChecked,this.internals.setFormValue(this.checked?this.value:null)}handleChange(e){const t=e.target;this.indeterminate=!1,this.checked=t.checked,this.dispatchEvent(new CustomEvent("wc-change",{detail:{checked:this.checked,value:this.value},bubbles:!0,composed:!0}))}render(){return i.html`
|
|
733
|
+
<label class="checkbox" part="base">
|
|
734
|
+
<input
|
|
735
|
+
type="checkbox"
|
|
736
|
+
class="native"
|
|
737
|
+
.checked=${this.checked}
|
|
738
|
+
.indeterminate=${this.indeterminate}
|
|
739
|
+
?disabled=${this.disabled}
|
|
740
|
+
aria-label=${this.label||void 0}
|
|
741
|
+
@change=${this.handleChange}
|
|
742
|
+
/>
|
|
743
|
+
<span class="box" part="box" aria-hidden="true">
|
|
744
|
+
<svg class="check" viewBox="0 0 16 16" fill="none">
|
|
745
|
+
<path
|
|
746
|
+
d="M3 8.5L6.5 12L13 4.5"
|
|
747
|
+
stroke="currentColor"
|
|
748
|
+
stroke-width="2"
|
|
749
|
+
stroke-linecap="round"
|
|
750
|
+
stroke-linejoin="round"
|
|
751
|
+
/>
|
|
752
|
+
</svg>
|
|
753
|
+
<span class="dash"></span>
|
|
754
|
+
</span>
|
|
755
|
+
<span class="label" part="label"><slot></slot></span>
|
|
756
|
+
</label>
|
|
757
|
+
`}};pt.styles=[l,co];let R=pt;Te([s.property({type:Boolean,reflect:!0})],R.prototype,"checked");Te([s.property({type:Boolean,reflect:!0})],R.prototype,"indeterminate");Te([s.property()],R.prototype,"value");Te([s.property()],R.prototype,"label");customElements.get("wc-checkbox")||customElements.define("wc-checkbox",R);const ho=i.css`
|
|
758
|
+
:host {
|
|
759
|
+
display: inline-block;
|
|
760
|
+
|
|
761
|
+
/* component 层令牌 */
|
|
762
|
+
--wc-radio-size: 16px;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
.radio {
|
|
766
|
+
display: inline-flex;
|
|
767
|
+
align-items: center;
|
|
768
|
+
gap: var(--wc-space-2);
|
|
769
|
+
font-size: var(--wc-font-size-medium);
|
|
770
|
+
color: var(--wc-color-text);
|
|
771
|
+
cursor: pointer;
|
|
772
|
+
user-select: none;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/* 原生 input 隐藏但保持可聚焦(键盘方向键切换) */
|
|
776
|
+
.native {
|
|
777
|
+
position: absolute;
|
|
778
|
+
width: 1px;
|
|
779
|
+
height: 1px;
|
|
780
|
+
margin: 0;
|
|
781
|
+
opacity: 0;
|
|
782
|
+
pointer-events: none;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.dot {
|
|
786
|
+
position: relative;
|
|
787
|
+
display: inline-flex;
|
|
788
|
+
align-items: center;
|
|
789
|
+
justify-content: center;
|
|
790
|
+
width: var(--wc-radio-size);
|
|
791
|
+
height: var(--wc-radio-size);
|
|
792
|
+
background-color: var(--wc-color-bg-container);
|
|
793
|
+
border: 1px solid var(--wc-color-border-strong);
|
|
794
|
+
border-radius: var(--wc-radius-circle);
|
|
795
|
+
flex-shrink: 0;
|
|
796
|
+
transition: border-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.inner {
|
|
800
|
+
width: calc(var(--wc-radio-size) / 2 - 1px);
|
|
801
|
+
height: calc(var(--wc-radio-size) / 2 - 1px);
|
|
802
|
+
border-radius: var(--wc-radius-circle);
|
|
803
|
+
background-color: var(--wc-color-primary);
|
|
804
|
+
opacity: 0;
|
|
805
|
+
transform: scale(0);
|
|
806
|
+
transition:
|
|
807
|
+
opacity var(--wc-duration-fast) var(--wc-easing-standard),
|
|
808
|
+
transform var(--wc-duration-fast) var(--wc-easing-standard);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
.native:focus-visible + .dot {
|
|
812
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
:host([checked]) .dot {
|
|
816
|
+
border-color: var(--wc-color-primary);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
:host([checked]) .inner {
|
|
820
|
+
opacity: 1;
|
|
821
|
+
transform: scale(1);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
.radio:hover .dot {
|
|
825
|
+
border-color: var(--wc-color-primary);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
:host([disabled]) .radio {
|
|
829
|
+
cursor: not-allowed;
|
|
830
|
+
color: var(--wc-color-text-disabled);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
:host([disabled]) .dot {
|
|
834
|
+
background-color: var(--wc-color-bg-disabled);
|
|
835
|
+
border-color: var(--wc-color-border);
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
:host([disabled][checked]) .dot {
|
|
839
|
+
border-color: var(--wc-color-border);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
:host([disabled][checked]) .inner {
|
|
843
|
+
background-color: var(--wc-color-text-disabled);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
.label {
|
|
847
|
+
line-height: var(--wc-line-height-base);
|
|
848
|
+
}
|
|
849
|
+
`;var po=Object.defineProperty,ot=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&po(e,t,r),r};const ut=class ut extends M(i.LitElement){constructor(){super(),this.checked=!1,this.value="",this.label="",this.initialChecked=!1,this.initialChecked=this.hasAttribute("checked")}get defaultValue(){return this.initialChecked?this.value:null}updated(e){super.updated(e),(e.has("checked")||e.has("value"))&&this.internals.setFormValue(this.checked?this.value:null)}formResetCallback(){super.formResetCallback(),this.checked=this.initialChecked,this.internals.setFormValue(this.checked?this.value:null)}handleChange(e){const t=e.target;this.checked=t.checked,this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}render(){return i.html`
|
|
850
|
+
<label class="radio" part="base">
|
|
851
|
+
<input
|
|
852
|
+
type="radio"
|
|
853
|
+
class="native"
|
|
854
|
+
.checked=${this.checked}
|
|
855
|
+
?disabled=${this.disabled}
|
|
856
|
+
aria-label=${this.label||void 0}
|
|
857
|
+
@change=${this.handleChange}
|
|
858
|
+
/>
|
|
859
|
+
<span class="dot" part="dot" aria-hidden="true"><span class="inner"></span></span>
|
|
860
|
+
<span class="label" part="label"><slot></slot></span>
|
|
861
|
+
</label>
|
|
862
|
+
`}};ut.styles=[l,ho];let te=ut;ot([s.property({type:Boolean,reflect:!0})],te.prototype,"checked");ot([s.property()],te.prototype,"value");ot([s.property()],te.prototype,"label");customElements.get("wc-radio")||customElements.define("wc-radio",te);const uo=i.css`
|
|
863
|
+
:host {
|
|
864
|
+
display: inline-block;
|
|
865
|
+
|
|
866
|
+
/* component 层令牌 */
|
|
867
|
+
--wc-switch-width: 40px;
|
|
868
|
+
--wc-switch-height: 22px;
|
|
869
|
+
--wc-switch-thumb: 18px;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
.switch {
|
|
873
|
+
display: inline-flex;
|
|
874
|
+
align-items: center;
|
|
875
|
+
gap: var(--wc-space-2);
|
|
876
|
+
font-size: var(--wc-font-size-medium);
|
|
877
|
+
color: var(--wc-color-text);
|
|
878
|
+
cursor: pointer;
|
|
879
|
+
user-select: none;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/* 原生 input 隐藏但保持可聚焦(键盘空格切换) */
|
|
883
|
+
.native {
|
|
884
|
+
position: absolute;
|
|
885
|
+
width: 1px;
|
|
886
|
+
height: 1px;
|
|
887
|
+
margin: 0;
|
|
888
|
+
opacity: 0;
|
|
889
|
+
pointer-events: none;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
.track {
|
|
893
|
+
position: relative;
|
|
894
|
+
display: inline-flex;
|
|
895
|
+
align-items: center;
|
|
896
|
+
width: var(--wc-switch-width);
|
|
897
|
+
height: var(--wc-switch-height);
|
|
898
|
+
padding: 2px;
|
|
899
|
+
background-color: var(--wc-color-gray-300);
|
|
900
|
+
border-radius: var(--wc-radius-round);
|
|
901
|
+
flex-shrink: 0;
|
|
902
|
+
transition: background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
.thumb {
|
|
906
|
+
width: var(--wc-switch-thumb);
|
|
907
|
+
height: var(--wc-switch-thumb);
|
|
908
|
+
border-radius: var(--wc-radius-circle);
|
|
909
|
+
background-color: var(--wc-color-text-anti);
|
|
910
|
+
box-shadow: var(--wc-shadow-1);
|
|
911
|
+
transform: translateX(0);
|
|
912
|
+
transition: transform var(--wc-duration-fast) var(--wc-easing-standard);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
.native:focus-visible + .track {
|
|
916
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
:host([checked]) .track {
|
|
920
|
+
background-color: var(--wc-color-primary);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
:host([checked]) .thumb {
|
|
924
|
+
transform: translateX(calc(var(--wc-switch-width) - var(--wc-switch-height)));
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
.switch:hover .track {
|
|
928
|
+
background-color: var(--wc-color-gray-400);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
:host([checked]) .switch:hover .track {
|
|
932
|
+
background-color: var(--wc-color-primary-hover);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
:host([disabled]) .switch {
|
|
936
|
+
cursor: not-allowed;
|
|
937
|
+
color: var(--wc-color-text-disabled);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
:host([disabled]) .track {
|
|
941
|
+
background-color: var(--wc-color-bg-disabled);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
:host([disabled]) .thumb {
|
|
945
|
+
background-color: var(--wc-color-gray-100);
|
|
946
|
+
box-shadow: none;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
.label {
|
|
950
|
+
line-height: var(--wc-line-height-base);
|
|
951
|
+
}
|
|
952
|
+
`;var vo=Object.defineProperty,De=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&vo(e,t,r),r};const vt=class vt extends M(i.LitElement){constructor(){super(),this.checked=!1,this.checkedValue="on",this.uncheckedValue="",this.label="",this.initialChecked=!1,this.initialChecked=this.hasAttribute("checked")}get defaultValue(){return this.initialChecked?this.checkedValue:this.uncheckedValue||null}updated(e){super.updated(e),(e.has("checked")||e.has("checkedValue")||e.has("uncheckedValue"))&&this.internals.setFormValue(this.checked?this.checkedValue:this.uncheckedValue||null)}formResetCallback(){super.formResetCallback(),this.checked=this.initialChecked,this.internals.setFormValue(this.checked?this.checkedValue:this.uncheckedValue||null)}handleChange(e){const t=e.target;this.checked=t.checked,this.dispatchEvent(new CustomEvent("wc-change",{detail:{checked:this.checked},bubbles:!0,composed:!0}))}render(){return i.html`
|
|
953
|
+
<label class="switch" part="base">
|
|
954
|
+
<input
|
|
955
|
+
type="checkbox"
|
|
956
|
+
role="switch"
|
|
957
|
+
class="native"
|
|
958
|
+
.checked=${this.checked}
|
|
959
|
+
?disabled=${this.disabled}
|
|
960
|
+
aria-label=${this.label||void 0}
|
|
961
|
+
@change=${this.handleChange}
|
|
962
|
+
/>
|
|
963
|
+
<span class="track" part="track" aria-hidden="true">
|
|
964
|
+
<span class="thumb" part="thumb"></span>
|
|
965
|
+
</span>
|
|
966
|
+
<span class="label" part="label"><slot></slot></span>
|
|
967
|
+
</label>
|
|
968
|
+
`}};vt.styles=[l,uo];let F=vt;De([s.property({type:Boolean,reflect:!0})],F.prototype,"checked");De([s.property()],F.prototype,"checkedValue");De([s.property()],F.prototype,"uncheckedValue");De([s.property()],F.prototype,"label");customElements.get("wc-switch")||customElements.define("wc-switch",F);const wo=i.css`
|
|
969
|
+
:host {
|
|
970
|
+
display: block;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
.option {
|
|
974
|
+
display: flex;
|
|
975
|
+
align-items: center;
|
|
976
|
+
justify-content: space-between;
|
|
977
|
+
gap: var(--wc-space-2);
|
|
978
|
+
padding: 0 var(--wc-space-3);
|
|
979
|
+
height: 32px;
|
|
980
|
+
font-size: var(--wc-font-size-medium);
|
|
981
|
+
color: var(--wc-color-text);
|
|
982
|
+
cursor: pointer;
|
|
983
|
+
user-select: none;
|
|
984
|
+
transition: background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
.text {
|
|
988
|
+
flex: 1;
|
|
989
|
+
min-width: 0;
|
|
990
|
+
overflow: hidden;
|
|
991
|
+
text-overflow: ellipsis;
|
|
992
|
+
white-space: nowrap;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
.check {
|
|
996
|
+
width: 14px;
|
|
997
|
+
height: 14px;
|
|
998
|
+
color: var(--wc-color-primary);
|
|
999
|
+
flex-shrink: 0;
|
|
1000
|
+
opacity: 0;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
:host([selected]) .check {
|
|
1004
|
+
opacity: 1;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
:host([selected]:not([active])) .text {
|
|
1008
|
+
color: var(--wc-color-primary);
|
|
1009
|
+
font-weight: var(--wc-font-weight-medium);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
:host(:hover:not([disabled])) .option,
|
|
1013
|
+
:host([active]:not([disabled])) .option {
|
|
1014
|
+
background-color: var(--wc-color-bg-hover);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
:host([disabled]) .option {
|
|
1018
|
+
color: var(--wc-color-text-disabled);
|
|
1019
|
+
cursor: not-allowed;
|
|
1020
|
+
}
|
|
1021
|
+
`;var mo=Object.defineProperty,je=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&mo(e,t,r),r};const wt=class wt extends i.LitElement{constructor(){super(...arguments),this.value="",this.disabled=!1,this.selected=!1,this.active=!1}get label(){return(this.textContent??"").trim()}render(){return i.html`
|
|
1022
|
+
<div class="option" part="base" role="option" aria-selected=${this.selected}>
|
|
1023
|
+
<span class="text"><slot></slot></span>
|
|
1024
|
+
<svg class="check" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
1025
|
+
<path
|
|
1026
|
+
d="M3 8.5L6.5 12L13 4.5"
|
|
1027
|
+
stroke="currentColor"
|
|
1028
|
+
stroke-width="2"
|
|
1029
|
+
stroke-linecap="round"
|
|
1030
|
+
stroke-linejoin="round"
|
|
1031
|
+
/>
|
|
1032
|
+
</svg>
|
|
1033
|
+
</div>
|
|
1034
|
+
`}};wt.styles=[wo];let V=wt;je([s.property({reflect:!0})],V.prototype,"value");je([s.property({type:Boolean,reflect:!0})],V.prototype,"disabled");je([s.property({type:Boolean,reflect:!0})],V.prototype,"selected");je([s.property({type:Boolean,reflect:!0})],V.prototype,"active");customElements.get("wc-option")||customElements.define("wc-option",V);const bo=i.css`
|
|
1035
|
+
:host {
|
|
1036
|
+
display: inline-block;
|
|
1037
|
+
width: 240px;
|
|
1038
|
+
|
|
1039
|
+
/* component 层令牌 */
|
|
1040
|
+
--wc-select-height: 32px;
|
|
1041
|
+
--wc-select-padding-x: var(--wc-space-2);
|
|
1042
|
+
--wc-select-font-size: var(--wc-font-size-medium);
|
|
1043
|
+
--wc-select-radius: var(--wc-radius-medium);
|
|
1044
|
+
--wc-select-panel-max-height: 280px;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
:host([size='small']) {
|
|
1048
|
+
--wc-select-height: 24px;
|
|
1049
|
+
--wc-select-padding-x: var(--wc-space-1);
|
|
1050
|
+
--wc-select-font-size: var(--wc-font-size-small);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
:host([size='large']) {
|
|
1054
|
+
--wc-select-height: 40px;
|
|
1055
|
+
--wc-select-padding-x: var(--wc-space-3);
|
|
1056
|
+
--wc-select-font-size: var(--wc-font-size-large);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
.select {
|
|
1060
|
+
position: relative;
|
|
1061
|
+
display: inline-block;
|
|
1062
|
+
width: 100%;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
.trigger {
|
|
1066
|
+
display: inline-flex;
|
|
1067
|
+
align-items: center;
|
|
1068
|
+
gap: var(--wc-space-1);
|
|
1069
|
+
width: 100%;
|
|
1070
|
+
height: var(--wc-select-height);
|
|
1071
|
+
padding: 0 var(--wc-select-padding-x);
|
|
1072
|
+
background-color: var(--wc-color-bg-container);
|
|
1073
|
+
border: 1px solid var(--wc-color-border);
|
|
1074
|
+
border-radius: var(--wc-select-radius);
|
|
1075
|
+
cursor: pointer;
|
|
1076
|
+
user-select: none;
|
|
1077
|
+
transition:
|
|
1078
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
1079
|
+
box-shadow var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/* 与 input 的 focus-within 对齐:键盘聚焦或展开时均呈现焦点视觉 */
|
|
1083
|
+
.trigger:focus-visible,
|
|
1084
|
+
:host([open]) .trigger {
|
|
1085
|
+
outline: none;
|
|
1086
|
+
border-color: var(--wc-color-primary);
|
|
1087
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
.value {
|
|
1091
|
+
flex: 1;
|
|
1092
|
+
min-width: 0;
|
|
1093
|
+
overflow: hidden;
|
|
1094
|
+
text-overflow: ellipsis;
|
|
1095
|
+
white-space: nowrap;
|
|
1096
|
+
font-size: var(--wc-select-font-size);
|
|
1097
|
+
color: var(--wc-color-text);
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
.value.placeholder {
|
|
1101
|
+
color: var(--wc-color-text-placeholder);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
.arrow {
|
|
1105
|
+
font-size: 16px;
|
|
1106
|
+
color: var(--wc-color-text-placeholder);
|
|
1107
|
+
flex-shrink: 0;
|
|
1108
|
+
transition: transform var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
:host([open]) .arrow {
|
|
1112
|
+
transform: rotate(180deg);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
.clear {
|
|
1116
|
+
display: inline-flex;
|
|
1117
|
+
align-items: center;
|
|
1118
|
+
justify-content: center;
|
|
1119
|
+
width: 16px;
|
|
1120
|
+
height: 16px;
|
|
1121
|
+
font-size: 16px;
|
|
1122
|
+
color: var(--wc-color-text-placeholder);
|
|
1123
|
+
border-radius: var(--wc-radius-circle);
|
|
1124
|
+
flex-shrink: 0;
|
|
1125
|
+
opacity: 0;
|
|
1126
|
+
transition: opacity var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
.clear:hover {
|
|
1130
|
+
color: var(--wc-color-text-secondary);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/* 悬停触发器时显示清除按钮 */
|
|
1134
|
+
.trigger:hover .clear,
|
|
1135
|
+
.trigger:focus-visible .clear {
|
|
1136
|
+
opacity: 1;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/* 有清除按钮时悬停隐藏箭头,避免拥挤 */
|
|
1140
|
+
.trigger:hover .clear + .arrow {
|
|
1141
|
+
display: none;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
.panel {
|
|
1145
|
+
position: absolute;
|
|
1146
|
+
top: calc(100% + 4px);
|
|
1147
|
+
left: 0;
|
|
1148
|
+
z-index: var(--wc-z-index-dropdown);
|
|
1149
|
+
width: 100%;
|
|
1150
|
+
max-height: var(--wc-select-panel-max-height);
|
|
1151
|
+
overflow-y: auto;
|
|
1152
|
+
padding: var(--wc-space-1) 0;
|
|
1153
|
+
background-color: var(--wc-color-bg-container);
|
|
1154
|
+
border: 1px solid var(--wc-color-border);
|
|
1155
|
+
border-radius: var(--wc-select-radius);
|
|
1156
|
+
box-shadow: var(--wc-shadow-2);
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
.panel[hidden] {
|
|
1160
|
+
display: none;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
.empty {
|
|
1164
|
+
padding: var(--wc-space-4) var(--wc-space-3);
|
|
1165
|
+
font-size: var(--wc-font-size-medium);
|
|
1166
|
+
color: var(--wc-color-text-placeholder);
|
|
1167
|
+
text-align: center;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/* ---- 校验状态 ---- */
|
|
1171
|
+
:host([status='success']) .trigger {
|
|
1172
|
+
border-color: var(--wc-color-success);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
:host([status='warning']) .trigger {
|
|
1176
|
+
border-color: var(--wc-color-warning);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
:host([status='error']) .trigger {
|
|
1180
|
+
border-color: var(--wc-color-error);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
:host([status='error']) .trigger:focus-visible,
|
|
1184
|
+
:host([status='error'][open]) .trigger {
|
|
1185
|
+
border-color: var(--wc-color-error);
|
|
1186
|
+
box-shadow: 0 0 0 2px var(--wc-color-error-light);
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/* ---- 禁用 ---- */
|
|
1190
|
+
:host([disabled]) .trigger {
|
|
1191
|
+
background-color: var(--wc-color-bg-disabled);
|
|
1192
|
+
border-color: transparent;
|
|
1193
|
+
cursor: not-allowed;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
:host([disabled]) .value {
|
|
1197
|
+
color: var(--wc-color-text-disabled);
|
|
1198
|
+
}
|
|
1199
|
+
`;var go=Object.defineProperty,fo=Object.getOwnPropertyDescriptor,me=(o,e,t,n)=>{for(var r=n>1?void 0:n?fo(e,t):e,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=(n?c(e,t,r):c(r))||r);return n&&r&&go(e,t,r),r};const mt=class mt extends M(i.LitElement){constructor(){super(),this._value="",this.placeholder="",this.size="medium",this.status="default",this.clearable=!1,this.open=!1,this.activeIndex=-1,this.localize=new v(this),this.uid=`wc-select-${Math.random().toString(36).slice(2,8)}`,this.assignedOptions=[],this.onDocumentClick=e=>{e.composedPath().includes(this)||this.hide()},this.handleKeydown=e=>{if(!this.disabled)switch(e.key){case"Enter":case" ":if(e.preventDefault(),this.open&&this.activeIndex>=0){const t=this.enabledOptions[this.activeIndex];t&&this.selectOption(t)}else this.show();break;case"Escape":e.preventDefault(),this.hide();break;case"ArrowDown":e.preventDefault(),this.open?this.enabledOptions.length&&(this.activeIndex=(this.activeIndex+1)%this.enabledOptions.length,this.scrollToActive()):this.show();break;case"ArrowUp":if(e.preventDefault(),!this.open)this.show();else if(this.enabledOptions.length){const t=this.enabledOptions.length;this.activeIndex=(this.activeIndex-1+t)%t,this.scrollToActive()}break;case"Home":this.open&&this.enabledOptions.length&&(e.preventDefault(),this.activeIndex=0,this.scrollToActive());break;case"End":this.open&&this.enabledOptions.length&&(e.preventDefault(),this.activeIndex=this.enabledOptions.length-1,this.scrollToActive());break;case"Tab":this.hide();break}},this.addEventListener("keydown",this.handleKeydown)}get value(){return this._value}set value(e){const t=this._value;this._value=e??"",this.requestUpdate("value",t)}get defaultValue(){return this.getAttribute("value")??""}updated(e){super.updated(e),e.has("value")&&(this.syncOptions(),this.internals.setFormValue(this.value||null))}formResetCallback(){super.formResetCallback(),this.value=String(this.defaultValue??""),this.internals.setFormValue(this.value||null)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}get enabledOptions(){return this.assignedOptions.filter(e=>!e.disabled)}get selectedLabel(){return this.assignedOptions.find(e=>e.value===this.value)?.label??""}get displayText(){return this.value?this.selectedLabel:this.placeholder||this.localize.term("select.placeholder")}onSlotChange(e){this.assignedOptions=e.target.assignedElements().filter(t=>t.tagName==="WC-OPTION"),this.assignedOptions.forEach((t,n)=>t.setAttribute("id",`${this.uid}-opt-${n}`)),this.syncOptions(),this.requestUpdate()}syncOptions(){for(const e of this.assignedOptions)e.selected=!e.disabled&&e.value===this.value}show(){if(this.disabled||this.open)return;this.open=!0;const e=this.enabledOptions.findIndex(t=>t.value===this.value);this.activeIndex=e>=0?e:this.enabledOptions.length?0:-1,this.scrollToActive()}hide(){this.open&&(this.open=!1,this.activeIndex=-1)}toggle(){this.open?this.hide():this.show()}onTriggerClick(){this.toggle()}onPanelClick(e){const t=e.target.closest("wc-option");t&&!t.disabled&&this.selectOption(t)}selectOption(e){this.value=e.value,this.hide(),this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:this.value,label:e.label},bubbles:!0,composed:!0}))}handleClear(e){e.preventDefault(),e.stopPropagation(),this.value="",this.hide(),this.dispatchEvent(new CustomEvent("wc-clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:"",label:""},bubbles:!0,composed:!0}))}scrollToActive(){for(const t of this.assignedOptions)t.active=!1;const e=this.enabledOptions[this.activeIndex];e&&(e.active=!0),this.updateComplete.then(()=>{e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})})}render(){const e=this.activeIndex>=0?this.enabledOptions[this.activeIndex]:void 0,t=e?`${this.uid}-opt-${this.assignedOptions.indexOf(e)}`:"",n=this.clearable&&this.value&&!this.disabled;return i.html`
|
|
1200
|
+
<div class="select" part="base">
|
|
1201
|
+
<div
|
|
1202
|
+
class="trigger"
|
|
1203
|
+
part="trigger"
|
|
1204
|
+
role="combobox"
|
|
1205
|
+
tabindex=${this.disabled?-1:0}
|
|
1206
|
+
aria-haspopup="listbox"
|
|
1207
|
+
aria-expanded=${this.open}
|
|
1208
|
+
aria-disabled=${this.disabled}
|
|
1209
|
+
aria-controls=${this.open?`${this.uid}-panel`:void 0}
|
|
1210
|
+
aria-activedescendant=${this.open&&t?t:void 0}
|
|
1211
|
+
@click=${this.onTriggerClick}
|
|
1212
|
+
>
|
|
1213
|
+
<span class="value ${this.value?"":"placeholder"}" part="value"
|
|
1214
|
+
>${this.displayText}</span
|
|
1215
|
+
>
|
|
1216
|
+
${n?i.html`
|
|
1217
|
+
<span
|
|
1218
|
+
class="clear"
|
|
1219
|
+
part="clear-button"
|
|
1220
|
+
role="button"
|
|
1221
|
+
aria-label=${this.localize.term("input.clear")}
|
|
1222
|
+
@mousedown=${r=>{r.preventDefault(),r.stopPropagation()}}
|
|
1223
|
+
@click=${this.handleClear}
|
|
1224
|
+
>
|
|
1225
|
+
<wc-icon name="close"></wc-icon>
|
|
1226
|
+
</span>
|
|
1227
|
+
`:""}
|
|
1228
|
+
<wc-icon name="chevron-down" class="arrow"></wc-icon>
|
|
1229
|
+
</div>
|
|
1230
|
+
<div
|
|
1231
|
+
class="panel"
|
|
1232
|
+
part="panel"
|
|
1233
|
+
id="${this.uid}-panel"
|
|
1234
|
+
role="listbox"
|
|
1235
|
+
?hidden=${!this.open}
|
|
1236
|
+
@click=${this.onPanelClick}
|
|
1237
|
+
>
|
|
1238
|
+
<slot @slotchange=${this.onSlotChange}></slot>
|
|
1239
|
+
${this.assignedOptions.length===0?i.html`<div class="empty">${this.localize.term("select.empty")}</div>`:""}
|
|
1240
|
+
</div>
|
|
1241
|
+
</div>
|
|
1242
|
+
`}};mt.styles=[l,bo];let O=mt;me([s.property()],O.prototype,"value",1);me([s.property()],O.prototype,"placeholder",2);me([s.property({reflect:!0})],O.prototype,"size",2);me([s.property({reflect:!0})],O.prototype,"status",2);me([s.property({type:Boolean,reflect:!0})],O.prototype,"clearable",2);me([s.property({type:Boolean,reflect:!0})],O.prototype,"open",2);customElements.get("wc-select")||customElements.define("wc-select",O);const yo=i.css`
|
|
1243
|
+
:host {
|
|
1244
|
+
display: inline-block;
|
|
1245
|
+
width: 240px;
|
|
1246
|
+
|
|
1247
|
+
/* component 层令牌 */
|
|
1248
|
+
--wc-slider-height: 20px;
|
|
1249
|
+
--wc-slider-track-height: 4px;
|
|
1250
|
+
--wc-slider-thumb-size: 16px;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
.slider {
|
|
1254
|
+
position: relative;
|
|
1255
|
+
display: inline-flex;
|
|
1256
|
+
align-items: center;
|
|
1257
|
+
width: 100%;
|
|
1258
|
+
height: var(--wc-slider-height);
|
|
1259
|
+
touch-action: none;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
.track {
|
|
1263
|
+
width: 100%;
|
|
1264
|
+
height: var(--wc-slider-track-height);
|
|
1265
|
+
background-color: var(--wc-color-gray-200);
|
|
1266
|
+
border-radius: var(--wc-radius-round);
|
|
1267
|
+
overflow: hidden;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
.fill {
|
|
1271
|
+
height: 100%;
|
|
1272
|
+
background-color: var(--wc-color-primary);
|
|
1273
|
+
transition: width var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
.thumb {
|
|
1277
|
+
position: absolute;
|
|
1278
|
+
top: 50%;
|
|
1279
|
+
width: var(--wc-slider-thumb-size);
|
|
1280
|
+
height: var(--wc-slider-thumb-size);
|
|
1281
|
+
background-color: var(--wc-color-bg-container);
|
|
1282
|
+
border: 2px solid var(--wc-color-primary);
|
|
1283
|
+
border-radius: var(--wc-radius-circle);
|
|
1284
|
+
box-shadow: var(--wc-shadow-1);
|
|
1285
|
+
box-sizing: border-box;
|
|
1286
|
+
pointer-events: none;
|
|
1287
|
+
transform: translate(-50%, -50%);
|
|
1288
|
+
transition: left var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
/* 原生 range 覆盖整个区域接收交互,视觉隐藏 */
|
|
1292
|
+
.native {
|
|
1293
|
+
position: absolute;
|
|
1294
|
+
inset: 0;
|
|
1295
|
+
width: 100%;
|
|
1296
|
+
height: 100%;
|
|
1297
|
+
margin: 0;
|
|
1298
|
+
opacity: 0;
|
|
1299
|
+
cursor: pointer;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
.native:focus-visible ~ .thumb {
|
|
1303
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
.native:disabled {
|
|
1307
|
+
cursor: not-allowed;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
:host([disabled]) .track {
|
|
1311
|
+
background-color: var(--wc-color-bg-disabled);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
:host([disabled]) .fill {
|
|
1315
|
+
background-color: var(--wc-color-border);
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
:host([disabled]) .thumb {
|
|
1319
|
+
border-color: var(--wc-color-border);
|
|
1320
|
+
box-shadow: none;
|
|
1321
|
+
}
|
|
1322
|
+
`;var xo=Object.defineProperty,ko=Object.getOwnPropertyDescriptor,ze=(o,e,t,n)=>{for(var r=n>1?void 0:n?ko(e,t):e,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=(n?c(e,t,r):c(r))||r);return n&&r&&xo(e,t,r),r};const bt=class bt extends M(i.LitElement){constructor(){super(...arguments),this._value=0,this.min=0,this.max=100,this.step=1,this.label=""}get value(){return this._value}set value(e){const t=this._value;this._value=this.clamp(e),this.requestUpdate("value",t)}clamp(e){if(Number.isNaN(e))return this._value;const t=Math.round((e-this.min)/this.step)*this.step+this.min,n=Number(t.toFixed(10));return Math.min(this.max,Math.max(this.min,n))}get percent(){return this.max===this.min?0:(this.value-this.min)/(this.max-this.min)*100}get defaultValue(){const e=this.getAttribute("value");return e?Number(e):0}updated(e){super.updated(e),e.has("value")&&this.internals.setFormValue(String(this.value))}formResetCallback(){super.formResetCallback(),this.value=Number(this.defaultValue??0),this.internals.setFormValue(String(this.value))}handleInput(e){const t=e.target;this.value=Number(t.value),this.dispatchEvent(new CustomEvent("wc-input",{detail:{value:this.value},bubbles:!0,composed:!0}))}handleChange(){this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}render(){return i.html`
|
|
1323
|
+
<div class="slider" part="base">
|
|
1324
|
+
<div class="track" part="track">
|
|
1325
|
+
<div class="fill" part="fill" style="width: ${this.percent}%"></div>
|
|
1326
|
+
</div>
|
|
1327
|
+
<div class="thumb" part="thumb" style="left: ${this.percent}%"></div>
|
|
1328
|
+
<input
|
|
1329
|
+
type="range"
|
|
1330
|
+
class="native"
|
|
1331
|
+
min=${this.min}
|
|
1332
|
+
max=${this.max}
|
|
1333
|
+
step=${this.step}
|
|
1334
|
+
.value=${String(this.value)}
|
|
1335
|
+
?disabled=${this.disabled}
|
|
1336
|
+
aria-label=${this.label||void 0}
|
|
1337
|
+
@input=${this.handleInput}
|
|
1338
|
+
@change=${this.handleChange}
|
|
1339
|
+
/>
|
|
1340
|
+
</div>
|
|
1341
|
+
`}};bt.styles=[l,yo];let D=bt;ze([s.property({type:Number})],D.prototype,"value",1);ze([s.property({type:Number})],D.prototype,"min",2);ze([s.property({type:Number})],D.prototype,"max",2);ze([s.property({type:Number})],D.prototype,"step",2);ze([s.property()],D.prototype,"label",2);customElements.get("wc-slider")||customElements.define("wc-slider",D);const $o=i.css`
|
|
1342
|
+
:host {
|
|
1343
|
+
display: inline-block;
|
|
1344
|
+
width: 144px;
|
|
1345
|
+
|
|
1346
|
+
/* component 层令牌 */
|
|
1347
|
+
--wc-input-number-height: 32px;
|
|
1348
|
+
--wc-input-number-padding-x: var(--wc-space-2);
|
|
1349
|
+
--wc-input-number-font-size: var(--wc-font-size-medium);
|
|
1350
|
+
--wc-input-number-radius: var(--wc-radius-medium);
|
|
1351
|
+
--wc-input-number-step-width: 28px;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
:host([size='small']) {
|
|
1355
|
+
--wc-input-number-height: 24px;
|
|
1356
|
+
--wc-input-number-padding-x: var(--wc-space-1);
|
|
1357
|
+
--wc-input-number-font-size: var(--wc-font-size-small);
|
|
1358
|
+
--wc-input-number-step-width: 24px;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
:host([size='large']) {
|
|
1362
|
+
--wc-input-number-height: 40px;
|
|
1363
|
+
--wc-input-number-padding-x: var(--wc-space-3);
|
|
1364
|
+
--wc-input-number-font-size: var(--wc-font-size-large);
|
|
1365
|
+
--wc-input-number-step-width: 32px;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
.number {
|
|
1369
|
+
display: flex;
|
|
1370
|
+
align-items: stretch;
|
|
1371
|
+
width: 100%;
|
|
1372
|
+
height: var(--wc-input-number-height);
|
|
1373
|
+
background-color: var(--wc-color-bg-container);
|
|
1374
|
+
border: 1px solid var(--wc-color-border);
|
|
1375
|
+
border-radius: var(--wc-input-number-radius);
|
|
1376
|
+
transition:
|
|
1377
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
1378
|
+
box-shadow var(--wc-duration-fast) var(--wc-easing-standard),
|
|
1379
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
.number:focus-within {
|
|
1383
|
+
border-color: var(--wc-color-primary);
|
|
1384
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
.inner {
|
|
1388
|
+
flex: 1;
|
|
1389
|
+
min-width: 0;
|
|
1390
|
+
padding: 0 var(--wc-input-number-padding-x);
|
|
1391
|
+
font-family: inherit;
|
|
1392
|
+
font-size: var(--wc-input-number-font-size);
|
|
1393
|
+
color: var(--wc-color-text);
|
|
1394
|
+
text-align: center;
|
|
1395
|
+
background: transparent;
|
|
1396
|
+
border: none;
|
|
1397
|
+
outline: none;
|
|
1398
|
+
caret-color: var(--wc-color-primary);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
:host([theme='column']) .inner,
|
|
1402
|
+
:host([theme='normal']) .inner {
|
|
1403
|
+
text-align: inherit;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
.inner::placeholder {
|
|
1407
|
+
color: var(--wc-color-text-placeholder);
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
.inner:disabled {
|
|
1411
|
+
cursor: not-allowed;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
.step {
|
|
1415
|
+
display: inline-flex;
|
|
1416
|
+
align-items: center;
|
|
1417
|
+
justify-content: center;
|
|
1418
|
+
flex-shrink: 0;
|
|
1419
|
+
width: var(--wc-input-number-step-width);
|
|
1420
|
+
padding: 0;
|
|
1421
|
+
color: var(--wc-color-text-secondary);
|
|
1422
|
+
cursor: pointer;
|
|
1423
|
+
background: transparent;
|
|
1424
|
+
border: none;
|
|
1425
|
+
border-radius: 0;
|
|
1426
|
+
transition:
|
|
1427
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
1428
|
+
color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
.step:hover:not(:disabled):not(:active) {
|
|
1432
|
+
color: var(--wc-color-primary);
|
|
1433
|
+
background-color: var(--wc-color-bg-hover);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
.step:active:not(:disabled) {
|
|
1437
|
+
color: var(--wc-color-primary-active);
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
.step:disabled {
|
|
1441
|
+
color: var(--wc-color-text-disabled);
|
|
1442
|
+
cursor: not-allowed;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
.step wc-icon {
|
|
1446
|
+
pointer-events: none;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
/* ---- column 主题:步进按钮右侧纵向堆叠 ---- */
|
|
1450
|
+
.stepper {
|
|
1451
|
+
display: flex;
|
|
1452
|
+
flex-direction: column;
|
|
1453
|
+
flex-shrink: 0;
|
|
1454
|
+
width: 22px;
|
|
1455
|
+
border-left: 1px solid var(--wc-color-border);
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
:host([theme='column']) .step {
|
|
1459
|
+
flex: 1;
|
|
1460
|
+
width: 100%;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
:host([theme='column']) .step wc-icon {
|
|
1464
|
+
font-size: 10px;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
.stepper .step + .step {
|
|
1468
|
+
border-top: 1px solid var(--wc-color-border);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/* row 主题:左右两个按钮与边框衔接处不留圆角缝隙 */
|
|
1472
|
+
:host([theme='row']) .number {
|
|
1473
|
+
overflow: hidden;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/* ---- 校验状态 ---- */
|
|
1477
|
+
:host([status='success']) .number {
|
|
1478
|
+
border-color: var(--wc-color-success);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
:host([status='warning']) .number {
|
|
1482
|
+
border-color: var(--wc-color-warning);
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
:host([status='error']) .number {
|
|
1486
|
+
border-color: var(--wc-color-error);
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
:host([status='error']) .number:focus-within {
|
|
1490
|
+
border-color: var(--wc-color-error);
|
|
1491
|
+
box-shadow: 0 0 0 2px var(--wc-color-error-light);
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/* ---- 禁用 / 只读 ---- */
|
|
1495
|
+
:host([disabled]) .number {
|
|
1496
|
+
background-color: var(--wc-color-bg-disabled);
|
|
1497
|
+
border-color: transparent;
|
|
1498
|
+
cursor: not-allowed;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
:host([disabled]) .inner {
|
|
1502
|
+
color: var(--wc-color-text-disabled);
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
:host([readonly]) .number {
|
|
1506
|
+
border-style: dashed;
|
|
1507
|
+
}
|
|
1508
|
+
`;var zo=Object.defineProperty,Co=Object.getOwnPropertyDescriptor,I=(o,e,t,n)=>{for(var r=n>1?void 0:n?Co(e,t):e,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=(n?c(e,t,r):c(r))||r);return n&&r&&zo(e,t,r),r};const gt=class gt extends M(i.LitElement){constructor(){super(...arguments),this._value=0,this.min=-1/0,this.max=1/0,this.step=1,this.theme="row",this.size="medium",this.placeholder="",this.label="",this.readonly=!1,this.status="default",this.localize=new v(this),this._editing=!1,this._text=""}get value(){return this._value}set value(e){const t=this._value;this._value=this.clamp(e),this.requestUpdate("value",t)}clamp(e){if(Number.isNaN(e))return this._value;const t=Number.isFinite(this.min)?Math.round((e-this.min)/this.step)*this.step+this.min:Math.round(e/this.step)*this.step,n=Number(t.toFixed(10));return Math.min(this.max,Math.max(this.min,n))}formatValue(){return String(this._value)}get defaultValue(){const e=this.getAttribute("value");return e?Number(e):0}updated(e){super.updated(e),e.has("value")&&this.internals.setFormValue(String(this.value))}formResetCallback(){super.formResetCallback(),this.value=Number(this.defaultValue??0),this.internals.setFormValue(String(this.value))}stepBy(e){if(this.disabled||this.readonly)return;const t=this.clamp(this.value+e*this.step);t!==this.value&&(this.value=t,this.internals.setFormValue(String(this.value)),this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:this.value},bubbles:!0,composed:!0})))}commit(){if(!this._editing)return;this._editing=!1,this._text="";const e=this.shadowRoot.querySelector(".inner").value.trim(),t=Number(e),n=e===""||Number.isNaN(t)?this._value:this.clamp(t);this.requestUpdate(),n!==this._value&&(this.value=n,this.internals.setFormValue(String(this.value)),this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:this.value},bubbles:!0,composed:!0})))}handleFocus(){this._editing=!0,this._text=this.formatValue(),this.requestUpdate()}handleBlur(){this.commit()}handleInput(e){const t=e.target;this._text=t.value,this.dispatchEvent(new CustomEvent("wc-input",{detail:{value:Number(t.value),text:t.value},bubbles:!0,composed:!0}))}handleKeydown(e){e.key==="ArrowUp"?(e.preventDefault(),this.stepBy(1)):e.key==="ArrowDown"?(e.preventDefault(),this.stepBy(-1)):e.key==="Enter"&&this.commit()}get canDecrement(){return!this.disabled&&!this.readonly&&this.value>this.min}get canIncrement(){return!this.disabled&&!this.readonly&&this.value<this.max}render(){const e=n=>{const r=n===1;return i.html`
|
|
1509
|
+
<button
|
|
1510
|
+
type="button"
|
|
1511
|
+
class="step ${r?"plus":"minus"}"
|
|
1512
|
+
part=${r?"increment-button":"decrement-button"}
|
|
1513
|
+
tabindex="-1"
|
|
1514
|
+
?disabled=${r?!this.canIncrement:!this.canDecrement}
|
|
1515
|
+
aria-label=${this.localize.term(r?"inputNumber.increment":"inputNumber.decrement")}
|
|
1516
|
+
@click=${()=>this.stepBy(n)}
|
|
1517
|
+
>
|
|
1518
|
+
<wc-icon name=${r?"plus":"minus"}></wc-icon>
|
|
1519
|
+
</button>
|
|
1520
|
+
`},t=i.html`
|
|
1521
|
+
<input
|
|
1522
|
+
part="input"
|
|
1523
|
+
class="inner"
|
|
1524
|
+
type="text"
|
|
1525
|
+
inputmode="decimal"
|
|
1526
|
+
.value=${this._editing?this._text:this.formatValue()}
|
|
1527
|
+
?disabled=${this.disabled}
|
|
1528
|
+
?readonly=${this.readonly}
|
|
1529
|
+
placeholder=${this.placeholder}
|
|
1530
|
+
aria-label=${this.label||void 0}
|
|
1531
|
+
@focus=${this.handleFocus}
|
|
1532
|
+
@blur=${this.handleBlur}
|
|
1533
|
+
@input=${this.handleInput}
|
|
1534
|
+
@keydown=${this.handleKeydown}
|
|
1535
|
+
/>
|
|
1536
|
+
`;return this.theme==="normal"?i.html`<div class="number" part="base">${t}</div>`:this.theme==="column"?i.html`
|
|
1537
|
+
<div class="number" part="base">
|
|
1538
|
+
${t}
|
|
1539
|
+
<span class="stepper" part="stepper"> ${e(1)}${e(-1)} </span>
|
|
1540
|
+
</div>
|
|
1541
|
+
`:i.html` <div class="number" part="base">${e(-1)}${t}${e(1)}</div> `}};gt.styles=[l,$o];let m=gt;I([s.property({type:Number})],m.prototype,"value",1);I([s.property({type:Number})],m.prototype,"min",2);I([s.property({type:Number})],m.prototype,"max",2);I([s.property({type:Number})],m.prototype,"step",2);I([s.property({reflect:!0})],m.prototype,"theme",2);I([s.property({reflect:!0})],m.prototype,"size",2);I([s.property()],m.prototype,"placeholder",2);I([s.property()],m.prototype,"label",2);I([s.property({type:Boolean,reflect:!0})],m.prototype,"readonly",2);I([s.property({reflect:!0})],m.prototype,"status",2);customElements.get("wc-input-number")||customElements.define("wc-input-number",m);const Eo=i.css`
|
|
1542
|
+
:host {
|
|
1543
|
+
display: inline-block;
|
|
1544
|
+
width: 240px;
|
|
1545
|
+
|
|
1546
|
+
/* component 层令牌 */
|
|
1547
|
+
--wc-date-picker-height: 32px;
|
|
1548
|
+
--wc-date-picker-padding-x: var(--wc-space-2);
|
|
1549
|
+
--wc-date-picker-font-size: var(--wc-font-size-medium);
|
|
1550
|
+
--wc-date-picker-radius: var(--wc-radius-medium);
|
|
1551
|
+
--wc-date-picker-cell-size: 32px;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
:host([size='small']) {
|
|
1555
|
+
--wc-date-picker-height: 24px;
|
|
1556
|
+
--wc-date-picker-padding-x: var(--wc-space-1);
|
|
1557
|
+
--wc-date-picker-font-size: var(--wc-font-size-small);
|
|
1558
|
+
--wc-date-picker-cell-size: 28px;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
:host([size='large']) {
|
|
1562
|
+
--wc-date-picker-height: 40px;
|
|
1563
|
+
--wc-date-picker-padding-x: var(--wc-space-3);
|
|
1564
|
+
--wc-date-picker-font-size: var(--wc-font-size-large);
|
|
1565
|
+
--wc-date-picker-cell-size: 36px;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
.picker {
|
|
1569
|
+
position: relative;
|
|
1570
|
+
display: inline-block;
|
|
1571
|
+
width: 100%;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
.trigger {
|
|
1575
|
+
display: inline-flex;
|
|
1576
|
+
align-items: center;
|
|
1577
|
+
gap: var(--wc-space-1);
|
|
1578
|
+
width: 100%;
|
|
1579
|
+
height: var(--wc-date-picker-height);
|
|
1580
|
+
padding: 0 var(--wc-date-picker-padding-x);
|
|
1581
|
+
background-color: var(--wc-color-bg-container);
|
|
1582
|
+
border: 1px solid var(--wc-color-border);
|
|
1583
|
+
border-radius: var(--wc-date-picker-radius);
|
|
1584
|
+
cursor: pointer;
|
|
1585
|
+
user-select: none;
|
|
1586
|
+
transition:
|
|
1587
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
1588
|
+
box-shadow var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
.trigger:focus-visible {
|
|
1592
|
+
outline: none;
|
|
1593
|
+
border-color: var(--wc-color-primary);
|
|
1594
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
.value {
|
|
1598
|
+
flex: 1;
|
|
1599
|
+
min-width: 0;
|
|
1600
|
+
overflow: hidden;
|
|
1601
|
+
text-overflow: ellipsis;
|
|
1602
|
+
white-space: nowrap;
|
|
1603
|
+
font-size: var(--wc-date-picker-font-size);
|
|
1604
|
+
color: var(--wc-color-text);
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
.value.placeholder {
|
|
1608
|
+
color: var(--wc-color-text-placeholder);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
.icon {
|
|
1612
|
+
font-size: 16px;
|
|
1613
|
+
color: var(--wc-color-text-placeholder);
|
|
1614
|
+
flex-shrink: 0;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
.clear {
|
|
1618
|
+
display: inline-flex;
|
|
1619
|
+
align-items: center;
|
|
1620
|
+
justify-content: center;
|
|
1621
|
+
width: 16px;
|
|
1622
|
+
height: 16px;
|
|
1623
|
+
font-size: 16px;
|
|
1624
|
+
color: var(--wc-color-text-placeholder);
|
|
1625
|
+
border-radius: var(--wc-radius-circle);
|
|
1626
|
+
flex-shrink: 0;
|
|
1627
|
+
opacity: 0;
|
|
1628
|
+
transition: opacity var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
.clear:hover {
|
|
1632
|
+
color: var(--wc-color-text-secondary);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
.trigger:hover .clear,
|
|
1636
|
+
.trigger:focus-visible .clear {
|
|
1637
|
+
opacity: 1;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
.trigger:hover .clear + .icon {
|
|
1641
|
+
display: none;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
/* ---- 日历面板 ---- */
|
|
1645
|
+
.panel {
|
|
1646
|
+
position: absolute;
|
|
1647
|
+
top: calc(100% + 4px);
|
|
1648
|
+
left: 0;
|
|
1649
|
+
z-index: var(--wc-z-index-dropdown);
|
|
1650
|
+
padding: var(--wc-space-3);
|
|
1651
|
+
background-color: var(--wc-color-bg-container);
|
|
1652
|
+
border: 1px solid var(--wc-color-border);
|
|
1653
|
+
border-radius: var(--wc-date-picker-radius);
|
|
1654
|
+
box-shadow: var(--wc-shadow-2);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
.panel[hidden] {
|
|
1658
|
+
display: none;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
.header {
|
|
1662
|
+
display: flex;
|
|
1663
|
+
align-items: center;
|
|
1664
|
+
gap: var(--wc-space-1);
|
|
1665
|
+
margin-bottom: var(--wc-space-2);
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
.month-label {
|
|
1669
|
+
flex: 1;
|
|
1670
|
+
min-width: 0;
|
|
1671
|
+
font-size: var(--wc-font-size-medium);
|
|
1672
|
+
font-weight: var(--wc-font-weight-medium, 500);
|
|
1673
|
+
color: var(--wc-color-text);
|
|
1674
|
+
text-align: center;
|
|
1675
|
+
white-space: nowrap;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
.nav {
|
|
1679
|
+
display: inline-flex;
|
|
1680
|
+
align-items: center;
|
|
1681
|
+
justify-content: center;
|
|
1682
|
+
width: 22px;
|
|
1683
|
+
height: 22px;
|
|
1684
|
+
padding: 0;
|
|
1685
|
+
font-size: 12px;
|
|
1686
|
+
color: var(--wc-color-text-secondary);
|
|
1687
|
+
cursor: pointer;
|
|
1688
|
+
background: transparent;
|
|
1689
|
+
border: none;
|
|
1690
|
+
border-radius: var(--wc-radius-small);
|
|
1691
|
+
transition:
|
|
1692
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
1693
|
+
color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
.nav wc-icon + wc-icon {
|
|
1697
|
+
margin-left: -10px;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
.nav:hover {
|
|
1701
|
+
color: var(--wc-color-primary);
|
|
1702
|
+
background-color: var(--wc-color-bg-hover);
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
.grid {
|
|
1706
|
+
display: flex;
|
|
1707
|
+
flex-direction: column;
|
|
1708
|
+
gap: 2px;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
.row {
|
|
1712
|
+
display: grid;
|
|
1713
|
+
grid-template-columns: repeat(7, var(--wc-date-picker-cell-size));
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
.cell {
|
|
1717
|
+
display: inline-flex;
|
|
1718
|
+
align-items: center;
|
|
1719
|
+
justify-content: center;
|
|
1720
|
+
width: var(--wc-date-picker-cell-size);
|
|
1721
|
+
height: var(--wc-date-picker-cell-size);
|
|
1722
|
+
box-sizing: border-box;
|
|
1723
|
+
font-size: var(--wc-font-size-small);
|
|
1724
|
+
color: var(--wc-color-text);
|
|
1725
|
+
border: 1px solid transparent;
|
|
1726
|
+
border-radius: var(--wc-radius-circle);
|
|
1727
|
+
user-select: none;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
.cell.weekday {
|
|
1731
|
+
height: auto;
|
|
1732
|
+
color: var(--wc-color-text-placeholder);
|
|
1733
|
+
cursor: default;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
.cell.day {
|
|
1737
|
+
cursor: pointer;
|
|
1738
|
+
transition:
|
|
1739
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
1740
|
+
color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
.cell.day:hover {
|
|
1744
|
+
background-color: var(--wc-color-bg-hover);
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
.cell.day.out {
|
|
1748
|
+
color: var(--wc-color-text-placeholder);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
.cell.day.today {
|
|
1752
|
+
border-color: var(--wc-color-primary);
|
|
1753
|
+
color: var(--wc-color-primary);
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
.cell.day.active {
|
|
1757
|
+
box-shadow: inset 0 0 0 1px var(--wc-color-primary);
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
.cell.day.selected {
|
|
1761
|
+
background-color: var(--wc-color-primary);
|
|
1762
|
+
color: var(--wc-color-text-anti);
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
.cell.day.selected.today {
|
|
1766
|
+
border-color: var(--wc-color-primary);
|
|
1767
|
+
color: var(--wc-color-text-anti);
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
.footer {
|
|
1771
|
+
display: flex;
|
|
1772
|
+
justify-content: flex-end;
|
|
1773
|
+
margin-top: var(--wc-space-2);
|
|
1774
|
+
padding-top: var(--wc-space-2);
|
|
1775
|
+
border-top: 1px solid var(--wc-color-border);
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
.today {
|
|
1779
|
+
padding: 2px var(--wc-space-2);
|
|
1780
|
+
font-size: var(--wc-font-size-small);
|
|
1781
|
+
color: var(--wc-color-primary);
|
|
1782
|
+
cursor: pointer;
|
|
1783
|
+
background: transparent;
|
|
1784
|
+
border: none;
|
|
1785
|
+
border-radius: var(--wc-radius-small);
|
|
1786
|
+
transition: background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
.today:hover {
|
|
1790
|
+
background-color: var(--wc-color-primary-light);
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/* ---- 校验状态 ---- */
|
|
1794
|
+
:host([status='success']) .trigger {
|
|
1795
|
+
border-color: var(--wc-color-success);
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
:host([status='warning']) .trigger {
|
|
1799
|
+
border-color: var(--wc-color-warning);
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
:host([status='error']) .trigger {
|
|
1803
|
+
border-color: var(--wc-color-error);
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
:host([status='error']) .trigger:focus-visible {
|
|
1807
|
+
border-color: var(--wc-color-error);
|
|
1808
|
+
box-shadow: 0 0 0 2px var(--wc-color-error-light);
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
/* ---- 禁用 / 只读 ---- */
|
|
1812
|
+
:host([disabled]) .trigger {
|
|
1813
|
+
background-color: var(--wc-color-bg-disabled);
|
|
1814
|
+
border-color: transparent;
|
|
1815
|
+
cursor: not-allowed;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
:host([disabled]) .value {
|
|
1819
|
+
color: var(--wc-color-text-disabled);
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
:host([readonly]) .trigger {
|
|
1823
|
+
border-style: dashed;
|
|
1824
|
+
}
|
|
1825
|
+
`;var So=Object.defineProperty,_o=Object.getOwnPropertyDescriptor,q=(o,e,t,n)=>{for(var r=n>1?void 0:n?_o(e,t):e,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=(n?c(e,t,r):c(r))||r);return n&&r&&So(e,t,r),r};function Gt(o){return String(o).padStart(2,"0")}function ye(o){return`${o.getFullYear()}-${Gt(o.getMonth()+1)}-${Gt(o.getDate())}`}function We(o){const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(o);if(!e)return null;const t=new Date(Number(e[1]),Number(e[2])-1,Number(e[3]));return Number.isNaN(t.getTime())?null:t}function Zt(o,e){return new Date(o.getFullYear(),o.getMonth(),o.getDate()+e)}const ft=class ft extends M(i.LitElement){constructor(){super(),this._value="",this.placeholder="",this.label="",this.size="medium",this.status="default",this.clearable=!1,this.readonly=!1,this.firstDayOfWeek=0,this.open=!1,this.viewYear=new Date().getFullYear(),this.viewMonth=new Date().getMonth(),this.activeIso="",this.localize=new v(this),this.uid=`wc-date-picker-${Math.random().toString(36).slice(2,8)}`,this.onDocumentClick=e=>{e.composedPath().includes(this)||this.hide()},this.handleKeydown=e=>{if(!(this.disabled||this.readonly))switch(e.key){case"Enter":case" ":e.preventDefault(),this.open&&this.activeIso?this.selectDate(this.activeIso):this.show();break;case"Escape":e.preventDefault(),this.hide();break;case"ArrowLeft":e.preventDefault(),this.open?this.moveActive(-1):this.show();break;case"ArrowRight":e.preventDefault(),this.open?this.moveActive(1):this.show();break;case"ArrowUp":e.preventDefault(),this.open?this.moveActive(-7):this.show();break;case"ArrowDown":e.preventDefault(),this.open?this.moveActive(7):this.show();break;case"Home":this.open&&(e.preventDefault(),this.moveActive(-7));break;case"End":this.open&&(e.preventDefault(),this.moveActive(7));break;case"Tab":this.hide();break}},this.addEventListener("keydown",this.handleKeydown)}get value(){return this._value}set value(e){const t=this._value;this._value=e&&We(e)?e:"",this.requestUpdate("value",t)}get defaultValue(){return this.getAttribute("value")??""}updated(e){super.updated(e),e.has("value")&&this.internals.setFormValue(this.value||null)}formResetCallback(){super.formResetCallback(),this.value=String(this.defaultValue??""),this.internals.setFormValue(this.value||null)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}show(){if(this.disabled||this.readonly||this.open)return;this.open=!0;const e=We(this.value)??new Date;this.viewYear=e.getFullYear(),this.viewMonth=e.getMonth(),this.activeIso=ye(e)}hide(){this.open&&(this.open=!1,this.activeIso="")}toggle(){this.open?this.hide():this.show()}setView(e,t){this.viewYear=e,this.viewMonth=t,this.requestUpdate()}prevMonth(){const e=this.viewMonth===0?11:this.viewMonth-1,t=this.viewMonth===0?this.viewYear-1:this.viewYear;this.setView(t,e)}nextMonth(){const e=this.viewMonth===11?0:this.viewMonth+1,t=this.viewMonth===11?this.viewYear+1:this.viewYear;this.setView(t,e)}prevYear(){this.setView(this.viewYear-1,this.viewMonth)}nextYear(){this.setView(this.viewYear+1,this.viewMonth)}get calendarCells(){const t=(new Date(this.viewYear,this.viewMonth,1).getDay()-this.firstDayOfWeek+7)%7,n=new Date(this.viewYear,this.viewMonth,1-t),r=ye(new Date),a=[];for(let c=0;c<42;c++){const u=Zt(n,c),Ee=ye(u);a.push({iso:Ee,day:u.getDate(),inMonth:u.getMonth()===this.viewMonth,isToday:Ee===r})}return a}get weekdayLabels(){return Array.from({length:7},(e,t)=>this.localize.date(new Date(2023,0,1+(this.firstDayOfWeek+t)%7),{weekday:"narrow"}))}get monthLabel(){return this.localize.date(new Date(this.viewYear,this.viewMonth,1),{year:"numeric",month:"long"})}selectDate(e){this.value=e,this.hide(),this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:e},bubbles:!0,composed:!0}))}handleClear(e){e.preventDefault(),e.stopPropagation(),this.value="",this.hide(),this.dispatchEvent(new CustomEvent("wc-clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:""},bubbles:!0,composed:!0}))}selectToday(){this.selectDate(ye(new Date))}onCellClick(e){const t=e.target.closest("[data-iso]");t?.dataset.iso&&this.selectDate(t.dataset.iso)}moveActive(e){if(!this.open)return;const t=We(this.activeIso)??new Date,n=Zt(t,e),r=ye(n);this.activeIso=r,n.getFullYear()!==this.viewYear||n.getMonth()!==this.viewMonth?this.setView(n.getFullYear(),n.getMonth()):this.requestUpdate()}render(){const e=this.clearable&&this.value&&!this.disabled&&!this.readonly,t=this.open?this.calendarCells:[],n=[];for(let r=0;r<t.length;r+=7)n.push(t.slice(r,r+7));return i.html`
|
|
1826
|
+
<div class="picker" part="base">
|
|
1827
|
+
<div
|
|
1828
|
+
class="trigger"
|
|
1829
|
+
part="trigger"
|
|
1830
|
+
role="combobox"
|
|
1831
|
+
tabindex=${this.disabled?-1:0}
|
|
1832
|
+
aria-haspopup="grid"
|
|
1833
|
+
aria-expanded=${this.open}
|
|
1834
|
+
aria-disabled=${this.disabled}
|
|
1835
|
+
aria-label=${this.label||void 0}
|
|
1836
|
+
aria-controls=${this.open?`${this.uid}-panel`:void 0}
|
|
1837
|
+
aria-activedescendant=${this.open&&this.activeIso?`${this.uid}-cell-${this.activeIso}`:void 0}
|
|
1838
|
+
@click=${this.toggle}
|
|
1839
|
+
>
|
|
1840
|
+
<span class="value ${this.value?"":"placeholder"}" part="value"
|
|
1841
|
+
>${this.value||this.placeholder||this.localize.term("datePicker.placeholder")}</span
|
|
1842
|
+
>
|
|
1843
|
+
${e?i.html`
|
|
1844
|
+
<span
|
|
1845
|
+
class="clear"
|
|
1846
|
+
part="clear-button"
|
|
1847
|
+
role="button"
|
|
1848
|
+
aria-label=${this.localize.term("input.clear")}
|
|
1849
|
+
@mousedown=${r=>{r.preventDefault(),r.stopPropagation()}}
|
|
1850
|
+
@click=${this.handleClear}
|
|
1851
|
+
>
|
|
1852
|
+
<wc-icon name="close"></wc-icon>
|
|
1853
|
+
</span>
|
|
1854
|
+
`:""}
|
|
1855
|
+
<wc-icon name="calendar" class="icon"></wc-icon>
|
|
1856
|
+
</div>
|
|
1857
|
+
<div
|
|
1858
|
+
class="panel"
|
|
1859
|
+
part="panel"
|
|
1860
|
+
id="${this.uid}-panel"
|
|
1861
|
+
role="dialog"
|
|
1862
|
+
aria-label=${this.label||this.localize.term("datePicker.placeholder")}
|
|
1863
|
+
?hidden=${!this.open}
|
|
1864
|
+
>
|
|
1865
|
+
<div class="header" part="header">
|
|
1866
|
+
<button
|
|
1867
|
+
type="button"
|
|
1868
|
+
class="nav"
|
|
1869
|
+
part="prev-year-button"
|
|
1870
|
+
tabindex="-1"
|
|
1871
|
+
aria-label=${this.localize.term("datePicker.prevYear")}
|
|
1872
|
+
@click=${this.prevYear}
|
|
1873
|
+
>
|
|
1874
|
+
<wc-icon name="chevron-left"></wc-icon><wc-icon name="chevron-left"></wc-icon>
|
|
1875
|
+
</button>
|
|
1876
|
+
<button
|
|
1877
|
+
type="button"
|
|
1878
|
+
class="nav"
|
|
1879
|
+
part="prev-month-button"
|
|
1880
|
+
tabindex="-1"
|
|
1881
|
+
aria-label=${this.localize.term("datePicker.prevMonth")}
|
|
1882
|
+
@click=${this.prevMonth}
|
|
1883
|
+
>
|
|
1884
|
+
<wc-icon name="chevron-left"></wc-icon>
|
|
1885
|
+
</button>
|
|
1886
|
+
<span class="month-label" part="month-label">${this.monthLabel}</span>
|
|
1887
|
+
<button
|
|
1888
|
+
type="button"
|
|
1889
|
+
class="nav"
|
|
1890
|
+
part="next-month-button"
|
|
1891
|
+
tabindex="-1"
|
|
1892
|
+
aria-label=${this.localize.term("datePicker.nextMonth")}
|
|
1893
|
+
@click=${this.nextMonth}
|
|
1894
|
+
>
|
|
1895
|
+
<wc-icon name="chevron-right"></wc-icon>
|
|
1896
|
+
</button>
|
|
1897
|
+
<button
|
|
1898
|
+
type="button"
|
|
1899
|
+
class="nav"
|
|
1900
|
+
part="next-year-button"
|
|
1901
|
+
tabindex="-1"
|
|
1902
|
+
aria-label=${this.localize.term("datePicker.nextYear")}
|
|
1903
|
+
@click=${this.nextYear}
|
|
1904
|
+
>
|
|
1905
|
+
<wc-icon name="chevron-right"></wc-icon><wc-icon name="chevron-right"></wc-icon>
|
|
1906
|
+
</button>
|
|
1907
|
+
</div>
|
|
1908
|
+
<div class="grid" part="grid" role="grid">
|
|
1909
|
+
<div class="row weekdays" role="row">
|
|
1910
|
+
${this.weekdayLabels.map(r=>i.html`<span class="cell weekday" role="columnheader">${r}</span>`)}
|
|
1911
|
+
</div>
|
|
1912
|
+
${n.map(r=>i.html`
|
|
1913
|
+
<div class="row" role="row">
|
|
1914
|
+
${r.map(a=>i.html`
|
|
1915
|
+
<span
|
|
1916
|
+
class="cell day ${a.inMonth?"":"out"} ${a.iso===this.value?"selected":""} ${a.iso===this.activeIso?"active":""}"
|
|
1917
|
+
role="gridcell"
|
|
1918
|
+
data-iso=${a.iso}
|
|
1919
|
+
id="${this.uid}-cell-${a.iso}"
|
|
1920
|
+
aria-selected=${a.iso===this.value}
|
|
1921
|
+
@click=${this.onCellClick}
|
|
1922
|
+
>${a.day}</span
|
|
1923
|
+
>
|
|
1924
|
+
`)}
|
|
1925
|
+
</div>
|
|
1926
|
+
`)}
|
|
1927
|
+
</div>
|
|
1928
|
+
<div class="footer" part="footer">
|
|
1929
|
+
<button
|
|
1930
|
+
type="button"
|
|
1931
|
+
class="today"
|
|
1932
|
+
part="today-button"
|
|
1933
|
+
tabindex="-1"
|
|
1934
|
+
@click=${this.selectToday}
|
|
1935
|
+
>
|
|
1936
|
+
${this.localize.term("datePicker.today")}
|
|
1937
|
+
</button>
|
|
1938
|
+
</div>
|
|
1939
|
+
</div>
|
|
1940
|
+
</div>
|
|
1941
|
+
`}};ft.styles=[l,Eo];let g=ft;q([s.property()],g.prototype,"value",1);q([s.property()],g.prototype,"placeholder",2);q([s.property()],g.prototype,"label",2);q([s.property({reflect:!0})],g.prototype,"size",2);q([s.property({reflect:!0})],g.prototype,"status",2);q([s.property({type:Boolean,reflect:!0})],g.prototype,"clearable",2);q([s.property({type:Boolean,reflect:!0})],g.prototype,"readonly",2);q([s.property({type:Number,attribute:"first-day-of-week"})],g.prototype,"firstDayOfWeek",2);q([s.property({type:Boolean,reflect:!0})],g.prototype,"open",2);customElements.get("wc-date-picker")||customElements.define("wc-date-picker",g);const lr=i.css`
|
|
1942
|
+
:host {
|
|
1943
|
+
display: block;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
.form {
|
|
1947
|
+
margin: 0;
|
|
1948
|
+
padding: 0;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
.item {
|
|
1952
|
+
display: grid;
|
|
1953
|
+
grid-template-columns: var(--wc-form-label-width, 80px) 1fr;
|
|
1954
|
+
gap: var(--wc-space-2);
|
|
1955
|
+
align-items: start;
|
|
1956
|
+
margin-bottom: var(--wc-space-4);
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
.label {
|
|
1960
|
+
padding-right: var(--wc-space-2);
|
|
1961
|
+
font-size: var(--wc-font-size-medium);
|
|
1962
|
+
line-height: var(--wc-form-line-height, 32px);
|
|
1963
|
+
color: var(--wc-color-text);
|
|
1964
|
+
text-align: right;
|
|
1965
|
+
overflow-wrap: break-word;
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
.asterisk {
|
|
1969
|
+
margin-right: 2px;
|
|
1970
|
+
color: var(--wc-color-error);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
.asterisk[hidden] {
|
|
1974
|
+
display: none;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
.control {
|
|
1978
|
+
min-width: 0;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
.error {
|
|
1982
|
+
margin-top: var(--wc-space-1);
|
|
1983
|
+
font-size: var(--wc-font-size-small);
|
|
1984
|
+
color: var(--wc-color-error);
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
.error[hidden] {
|
|
1988
|
+
display: none;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
:host([disabled]) .label {
|
|
1992
|
+
color: var(--wc-color-text-disabled);
|
|
1993
|
+
}
|
|
1994
|
+
`,yt=class yt extends i.LitElement{constructor(){super(),this.onSubmit=e=>{e.preventDefault(),this.submit()},this.onHostClick=e=>{const t=e.composedPath().find(r=>r instanceof Element&&r.tagName==="WC-BUTTON");if(!t)return;const n=t.getAttribute("type");n==="submit"?(e.preventDefault(),this.submit()):n==="reset"&&(e.preventDefault(),this.reset())},this.addEventListener("click",this.onHostClick)}connectedCallback(){super.connectedCallback(),this.addEventListener("submit",this.onSubmit)}getItems(){return(this.shadowRoot.querySelector("slot")?.assignedElements()??[]).filter(t=>t.tagName==="WC-FORM-ITEM")}getItem(e){return this.getItems().find(t=>t.name===e)}async validate(){const e={};for(const n of this.getItems()){const r=await n.validate();r&&(e[n.name||`field-${Object.keys(e).length}`]=r)}const t=Object.values(e)[0]??"";return t&&this.focusFirstError(),{valid:Object.keys(e).length===0,errors:e,firstError:t}}reset(){for(const e of this.getItems())e.reset()}async submit(){const e=await this.validate();this.dispatchEvent(new CustomEvent("wc-submit",{detail:e,bubbles:!0,composed:!0}))}focusFirstError(){const e=this.getItems().find(t=>t.error)?.control;!e||typeof e.focus!="function"||(e.focus(),document.activeElement!==e&&e.shadowRoot?.querySelector("input, textarea, button, [tabindex]")?.focus())}render(){return i.html`
|
|
1995
|
+
<form class="form" part="form" novalidate>
|
|
1996
|
+
<slot></slot>
|
|
1997
|
+
</form>
|
|
1998
|
+
`}};yt.styles=[l,lr];let Le=yt;customElements.get("wc-form")||customElements.define("wc-form",Le);var Oo=Object.defineProperty,A=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Oo(e,t,r),r};const xt=class xt extends i.LitElement{constructor(){super(),this.name="",this.label="",this.required=!1,this.pattern="",this.rules=[],this._error="",this.localize=new v(this),this.onControlInteract=()=>{this.validate()},this.addEventListener("wc-change",this.onControlInteract),this.addEventListener("blur",this.onControlInteract,!0)}get error(){return this._error}get control(){return this.shadowRoot.querySelector("slot")?.assignedElements()[0]??null}get controlValue(){return this.control?.value??""}get effectiveRules(){const e=[];return this.required&&e.push({required:!0}),this.min!==void 0&&e.push({min:this.min}),this.max!==void 0&&e.push({max:this.max}),this.minLength!==void 0&&e.push({minLength:this.minLength}),this.maxLength!==void 0&&e.push({maxLength:this.maxLength}),this.pattern&&e.push({pattern:this.pattern}),[...e,...this.rules]}async validate(){const e=this.controlValue;for(const t of this.effectiveRules){const n=await this.checkRule(t,e);if(n)return this.setError(n),n}return this.clearError(),""}async checkRule(e,t){const n=this.label||this.name||"",r=(c,u)=>e.message??this.localize.term(c,{name:n,...u}),a=t===""||t==null||Array.isArray(t)&&t.length===0;if(e.required&&a)return r("form.required");if(a)return"";if(e.min!==void 0&&Number(t)<e.min)return r("form.min",{min:e.min});if(e.max!==void 0&&Number(t)>e.max)return r("form.max",{max:e.max});if(e.minLength!==void 0&&String(t).length<e.minLength)return r("form.minLength",{minLength:e.minLength});if(e.maxLength!==void 0&&String(t).length>e.maxLength)return r("form.maxLength",{maxLength:e.maxLength});if(e.pattern&&!(typeof e.pattern=="string"?new RegExp(e.pattern):e.pattern).test(String(t)))return r("form.pattern");if(e.validator){const c=await e.validator(t);if(c===!1)return r("form.invalid");if(typeof c=="string"&&c)return c}return""}setError(e){this._error=e,this.applyControlStatus(),this.requestUpdate()}clearError(){this._error&&(this._error="",this.applyControlStatus(),this.requestUpdate())}applyControlStatus(){const e=this.control;e&&"status"in e&&(e.status=this._error?"error":"default")}reset(){const e=this.control;e&&(typeof e.formResetCallback=="function"?e.formResetCallback():"value"in e&&(e.value=""),this.clearError())}render(){return i.html`
|
|
1999
|
+
<div class="item" part="base">
|
|
2000
|
+
<label class="label" part="label">
|
|
2001
|
+
<span class="asterisk" ?hidden=${!this.required}>*</span>${this.label}
|
|
2002
|
+
</label>
|
|
2003
|
+
<div class="control" part="control">
|
|
2004
|
+
<slot></slot>
|
|
2005
|
+
<div class="error" part="error" role="alert" ?hidden=${!this._error}>${this._error}</div>
|
|
2006
|
+
</div>
|
|
2007
|
+
</div>
|
|
2008
|
+
`}};xt.styles=[l,lr];let f=xt;A([s.property()],f.prototype,"name");A([s.property()],f.prototype,"label");A([s.property({type:Boolean,reflect:!0})],f.prototype,"required");A([s.property({type:Number})],f.prototype,"min");A([s.property({type:Number})],f.prototype,"max");A([s.property({type:Number,attribute:"min-length"})],f.prototype,"minLength");A([s.property({type:Number,attribute:"max-length"})],f.prototype,"maxLength");A([s.property()],f.prototype,"pattern");A([s.property({attribute:!1})],f.prototype,"rules");customElements.get("wc-form-item")||customElements.define("wc-form-item",f);const Po=i.css`
|
|
2009
|
+
:host {
|
|
2010
|
+
display: block;
|
|
2011
|
+
|
|
2012
|
+
/* component 层令牌 */
|
|
2013
|
+
--wc-divider-color: var(--wc-color-border);
|
|
2014
|
+
--wc-divider-text-gap: var(--wc-space-3);
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
:host([vertical]) {
|
|
2018
|
+
display: inline-block;
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
.divider {
|
|
2022
|
+
display: flex;
|
|
2023
|
+
align-items: center;
|
|
2024
|
+
gap: var(--wc-divider-text-gap);
|
|
2025
|
+
margin: var(--wc-space-4) 0;
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
.content {
|
|
2029
|
+
flex-shrink: 0;
|
|
2030
|
+
font-size: var(--wc-font-size-medium);
|
|
2031
|
+
color: var(--wc-color-text-secondary);
|
|
2032
|
+
white-space: nowrap;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
.content[hidden] {
|
|
2036
|
+
display: none;
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
.line {
|
|
2040
|
+
display: block;
|
|
2041
|
+
flex: 1;
|
|
2042
|
+
/* 不能用 height: 0 + 背景——0 高度画不出背景色,实线会不可见 */
|
|
2043
|
+
height: 1px;
|
|
2044
|
+
background-color: var(--wc-divider-color);
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
:host([dashed]) .line {
|
|
2048
|
+
height: 0;
|
|
2049
|
+
background: none;
|
|
2050
|
+
border-top: 1px dashed var(--wc-divider-color);
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
.line.vertical {
|
|
2054
|
+
display: inline-block;
|
|
2055
|
+
flex: none;
|
|
2056
|
+
width: 1px;
|
|
2057
|
+
height: 1em;
|
|
2058
|
+
margin: 0 var(--wc-space-2);
|
|
2059
|
+
vertical-align: middle;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
:host([dashed]) .line.vertical {
|
|
2063
|
+
width: 0;
|
|
2064
|
+
height: 1em;
|
|
2065
|
+
background: none;
|
|
2066
|
+
border-left: 1px dashed var(--wc-divider-color);
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
/* 文案对齐:一侧线固定短 */
|
|
2070
|
+
.align-left .line.start {
|
|
2071
|
+
flex: 0 0 var(--wc-space-4);
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
.align-right .line.end {
|
|
2075
|
+
flex: 0 0 var(--wc-space-4);
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
.align-left .content {
|
|
2079
|
+
order: -1;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
:host([vertical]) .divider {
|
|
2083
|
+
margin: 0;
|
|
2084
|
+
}
|
|
2085
|
+
`;var Lo=Object.defineProperty,at=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Lo(e,t,r),r};const kt=class kt extends i.LitElement{constructor(){super(...arguments),this.dashed=!1,this.align="center",this.vertical=!1,this._hasContent=!1}onSlotChange(e){this._hasContent=e.target.assignedNodes({flatten:!0}).length>0,this.requestUpdate()}render(){return this.vertical?i.html`<span class="line vertical" part="line"></span>`:i.html`
|
|
2086
|
+
<div class="divider ${`align-${this.align}`}" part="base">
|
|
2087
|
+
<span class="line start" part="line"></span>
|
|
2088
|
+
<span class="content" part="content" ?hidden=${!this._hasContent}>
|
|
2089
|
+
<slot @slotchange=${this.onSlotChange}></slot>
|
|
2090
|
+
</span>
|
|
2091
|
+
<span class="line end" part="line"></span>
|
|
2092
|
+
</div>
|
|
2093
|
+
`}};kt.styles=[l,Po];let re=kt;at([s.property({type:Boolean,reflect:!0})],re.prototype,"dashed");at([s.property({reflect:!0})],re.prototype,"align");at([s.property({type:Boolean,reflect:!0})],re.prototype,"vertical");customElements.get("wc-divider")||customElements.define("wc-divider",re);const Mo=i.css`
|
|
2094
|
+
:host {
|
|
2095
|
+
display: inline-block;
|
|
2096
|
+
|
|
2097
|
+
/* component 层令牌 */
|
|
2098
|
+
--wc-tag-height: 24px;
|
|
2099
|
+
--wc-tag-font-size: var(--wc-font-size-small);
|
|
2100
|
+
--wc-tag-padding-x: var(--wc-space-2);
|
|
2101
|
+
--wc-tag-radius: var(--wc-radius-small);
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
:host([size='small']) {
|
|
2105
|
+
--wc-tag-height: 20px;
|
|
2106
|
+
--wc-tag-font-size: var(--wc-font-size-small);
|
|
2107
|
+
--wc-tag-padding-x: var(--wc-space-1);
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
:host([size='large']) {
|
|
2111
|
+
--wc-tag-height: 28px;
|
|
2112
|
+
--wc-tag-font-size: var(--wc-font-size-medium);
|
|
2113
|
+
--wc-tag-padding-x: var(--wc-space-2);
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
.tag {
|
|
2117
|
+
display: inline-flex;
|
|
2118
|
+
align-items: center;
|
|
2119
|
+
gap: var(--wc-space-1);
|
|
2120
|
+
height: var(--wc-tag-height);
|
|
2121
|
+
padding: 0 var(--wc-tag-padding-x);
|
|
2122
|
+
font-size: var(--wc-tag-font-size);
|
|
2123
|
+
line-height: 1;
|
|
2124
|
+
white-space: nowrap;
|
|
2125
|
+
border: 1px solid transparent;
|
|
2126
|
+
border-radius: var(--wc-tag-radius);
|
|
2127
|
+
box-sizing: border-box;
|
|
2128
|
+
transition: opacity var(--wc-duration-fast) var(--wc-easing-standard);
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
.icon {
|
|
2132
|
+
display: inline-flex;
|
|
2133
|
+
align-items: center;
|
|
2134
|
+
font-size: 1em;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
/* 未分配图标时 slot 渲染占位 fallback,隐藏以消除多余间隙 */
|
|
2138
|
+
.icon:has(.icon-placeholder) {
|
|
2139
|
+
display: none;
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
/* ---- 关闭按钮 ---- */
|
|
2143
|
+
.close {
|
|
2144
|
+
display: inline-flex;
|
|
2145
|
+
align-items: center;
|
|
2146
|
+
justify-content: center;
|
|
2147
|
+
width: 14px;
|
|
2148
|
+
height: 14px;
|
|
2149
|
+
padding: 0;
|
|
2150
|
+
font-size: 10px;
|
|
2151
|
+
color: inherit;
|
|
2152
|
+
cursor: pointer;
|
|
2153
|
+
background: transparent;
|
|
2154
|
+
border: none;
|
|
2155
|
+
border-radius: var(--wc-radius-circle);
|
|
2156
|
+
transition: background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
.close:hover {
|
|
2160
|
+
background-color: var(--wc-color-overlay-hover);
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
.close wc-icon {
|
|
2164
|
+
pointer-events: none;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
/* ---- default 主题 ---- */
|
|
2168
|
+
:host([theme='default']) .tag {
|
|
2169
|
+
color: var(--wc-color-text);
|
|
2170
|
+
background-color: var(--wc-color-bg-container-secondary);
|
|
2171
|
+
border-color: var(--wc-color-border);
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
/* ---- 语义色 × light 浅底(默认 variant) ---- */
|
|
2175
|
+
:host([theme='primary']) .tag {
|
|
2176
|
+
color: var(--wc-color-primary);
|
|
2177
|
+
background-color: var(--wc-color-primary-light);
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
:host([theme='success']) .tag {
|
|
2181
|
+
color: var(--wc-color-success);
|
|
2182
|
+
background-color: var(--wc-color-success-bg);
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
:host([theme='warning']) .tag {
|
|
2186
|
+
color: var(--wc-color-warning);
|
|
2187
|
+
background-color: var(--wc-color-warning-bg);
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
:host([theme='danger']) .tag {
|
|
2191
|
+
color: var(--wc-color-error);
|
|
2192
|
+
background-color: var(--wc-color-error-bg);
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/* ---- dark 实底 ---- */
|
|
2196
|
+
:host([variant='dark'][theme='default']) .tag {
|
|
2197
|
+
color: var(--wc-color-text-anti);
|
|
2198
|
+
background-color: var(--wc-color-text-secondary);
|
|
2199
|
+
border-color: transparent;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
:host([variant='dark'][theme='primary']) .tag {
|
|
2203
|
+
color: var(--wc-color-text-anti);
|
|
2204
|
+
background-color: var(--wc-color-primary);
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
:host([variant='dark'][theme='success']) .tag {
|
|
2208
|
+
color: var(--wc-color-text-anti);
|
|
2209
|
+
background-color: var(--wc-color-success);
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
:host([variant='dark'][theme='warning']) .tag {
|
|
2213
|
+
color: var(--wc-color-text-anti);
|
|
2214
|
+
background-color: var(--wc-color-warning);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
:host([variant='dark'][theme='danger']) .tag {
|
|
2218
|
+
color: var(--wc-color-text-anti);
|
|
2219
|
+
background-color: var(--wc-color-error);
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
/* ---- outline 描边 ---- */
|
|
2223
|
+
:host([variant='outline']) .tag {
|
|
2224
|
+
background-color: transparent;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
:host([variant='outline'][theme='default']) .tag {
|
|
2228
|
+
border-color: var(--wc-color-border);
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
:host([variant='outline'][theme='primary']) .tag {
|
|
2232
|
+
border-color: var(--wc-color-primary);
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
:host([variant='outline'][theme='success']) .tag {
|
|
2236
|
+
border-color: var(--wc-color-success);
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
:host([variant='outline'][theme='warning']) .tag {
|
|
2240
|
+
border-color: var(--wc-color-warning);
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
:host([variant='outline'][theme='danger']) .tag {
|
|
2244
|
+
border-color: var(--wc-color-error);
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
/* ---- 禁用 ---- */
|
|
2248
|
+
:host([disabled]) .tag {
|
|
2249
|
+
cursor: not-allowed;
|
|
2250
|
+
opacity: 0.5;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
:host([disabled]) .close {
|
|
2254
|
+
cursor: not-allowed;
|
|
2255
|
+
}
|
|
2256
|
+
`;var Io=Object.defineProperty,Ce=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Io(e,t,r),r};const $t=class $t extends i.LitElement{constructor(){super(...arguments),this.theme="default",this.size="medium",this.variant="light",this.closable=!1,this.disabled=!1,this.localize=new v(this)}handleClose(e){e.stopPropagation(),!this.disabled&&this.dispatchEvent(new CustomEvent("wc-close",{bubbles:!0,composed:!0}))}render(){return i.html`
|
|
2257
|
+
<span class="tag" part="base">
|
|
2258
|
+
<slot name="icon" class="icon"><span class="icon-placeholder"></span></slot>
|
|
2259
|
+
<slot></slot>
|
|
2260
|
+
${this.closable?i.html`
|
|
2261
|
+
<button
|
|
2262
|
+
type="button"
|
|
2263
|
+
class="close"
|
|
2264
|
+
part="close-button"
|
|
2265
|
+
tabindex="-1"
|
|
2266
|
+
?disabled=${this.disabled}
|
|
2267
|
+
aria-label=${this.localize.term("tag.close")}
|
|
2268
|
+
@click=${this.handleClose}
|
|
2269
|
+
>
|
|
2270
|
+
<wc-icon name="close"></wc-icon>
|
|
2271
|
+
</button>
|
|
2272
|
+
`:""}
|
|
2273
|
+
</span>
|
|
2274
|
+
`}};$t.styles=[l,Mo];let j=$t;Ce([s.property({reflect:!0})],j.prototype,"theme");Ce([s.property({reflect:!0})],j.prototype,"size");Ce([s.property({reflect:!0})],j.prototype,"variant");Ce([s.property({type:Boolean,reflect:!0})],j.prototype,"closable");Ce([s.property({type:Boolean,reflect:!0})],j.prototype,"disabled");customElements.get("wc-tag")||customElements.define("wc-tag",j);const To=i.css`
|
|
2275
|
+
:host {
|
|
2276
|
+
display: inline-block;
|
|
2277
|
+
|
|
2278
|
+
/* component 层令牌(预设档位会覆写) */
|
|
2279
|
+
--wc-avatar-size: 32px;
|
|
2280
|
+
--wc-avatar-font-size: var(--wc-font-size-medium);
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
.avatar {
|
|
2284
|
+
display: inline-flex;
|
|
2285
|
+
align-items: center;
|
|
2286
|
+
justify-content: center;
|
|
2287
|
+
overflow: hidden;
|
|
2288
|
+
width: var(--wc-avatar-size);
|
|
2289
|
+
height: var(--wc-avatar-size);
|
|
2290
|
+
font-size: var(--wc-avatar-font-size);
|
|
2291
|
+
color: var(--wc-color-text);
|
|
2292
|
+
white-space: nowrap;
|
|
2293
|
+
user-select: none;
|
|
2294
|
+
background-color: var(--wc-color-bg-container-secondary);
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
.avatar.small {
|
|
2298
|
+
--wc-avatar-size: 24px;
|
|
2299
|
+
--wc-avatar-font-size: var(--wc-font-size-small);
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
.avatar.large {
|
|
2303
|
+
--wc-avatar-size: 40px;
|
|
2304
|
+
--wc-avatar-font-size: var(--wc-font-size-large);
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
.avatar.shape-circle {
|
|
2308
|
+
border-radius: var(--wc-radius-circle);
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
.avatar.shape-round {
|
|
2312
|
+
border-radius: var(--wc-radius-large);
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
.avatar.shape-square {
|
|
2316
|
+
border-radius: var(--wc-radius-small);
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
.avatar ::slotted(img) {
|
|
2320
|
+
display: block;
|
|
2321
|
+
width: 100%;
|
|
2322
|
+
height: 100%;
|
|
2323
|
+
object-fit: cover;
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
.avatar ::slotted(wc-icon) {
|
|
2327
|
+
color: var(--wc-color-text-placeholder);
|
|
2328
|
+
}
|
|
2329
|
+
`;var Do=Object.defineProperty,dr=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Do(e,t,r),r};const jo=["small","medium","large"],zt=class zt extends i.LitElement{constructor(){super(...arguments),this.size="medium",this.shape="circle"}get isPreset(){return jo.includes(this.size)}get customStyle(){if(this.isPreset)return"";const e=this.size.trim(),t=/^\d+$/.test(e)?`${e}px`:e;return`--wc-avatar-size:${t};--wc-avatar-font-size:${t}`}render(){return i.html`
|
|
2330
|
+
<div
|
|
2331
|
+
class="avatar ${this.isPreset?this.size:"custom"} shape-${this.shape}"
|
|
2332
|
+
part="base"
|
|
2333
|
+
style=${this.customStyle}
|
|
2334
|
+
>
|
|
2335
|
+
<slot></slot>
|
|
2336
|
+
</div>
|
|
2337
|
+
`}};zt.styles=[l,To];let ue=zt;dr([s.property()],ue.prototype,"size");dr([s.property({reflect:!0})],ue.prototype,"shape");customElements.get("wc-avatar")||customElements.define("wc-avatar",ue);const No=i.css`
|
|
2338
|
+
:host {
|
|
2339
|
+
display: inline-block;
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
:host([direction='vertical']) {
|
|
2343
|
+
display: block;
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
.space {
|
|
2347
|
+
display: flex;
|
|
2348
|
+
gap: var(--wc-space-gap, var(--wc-space-4));
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
/* slot 透明化,让 slotted 子元素直接成为 flex item,gap 才能生效 */
|
|
2352
|
+
.space slot {
|
|
2353
|
+
display: contents;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
:host([direction='vertical']) .space {
|
|
2357
|
+
flex-direction: column;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
:host([wrap]) .space {
|
|
2361
|
+
flex-wrap: wrap;
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
.align-start {
|
|
2365
|
+
align-items: flex-start;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
.align-center {
|
|
2369
|
+
align-items: center;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
.align-end {
|
|
2373
|
+
align-items: flex-end;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
.align-baseline {
|
|
2377
|
+
align-items: baseline;
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
.align-stretch {
|
|
2381
|
+
align-items: stretch;
|
|
2382
|
+
}
|
|
2383
|
+
`;var qo=Object.defineProperty,Ne=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&qo(e,t,r),r};const Ao={small:"var(--wc-space-2)",medium:"var(--wc-space-4)",large:"var(--wc-space-6)"},Ct=class Ct extends i.LitElement{constructor(){super(...arguments),this.size="medium",this.direction="horizontal",this.wrap=!1}get gapValue(){const e=Ao[this.size];if(e)return e;const t=this.size.trim();return/^\d+$/.test(t)?`${t}px`:t}render(){return i.html`
|
|
2384
|
+
<div
|
|
2385
|
+
class="space ${`align-${this.align??(this.direction==="vertical"?"stretch":"center")}`}"
|
|
2386
|
+
part="base"
|
|
2387
|
+
style=${`--wc-space-gap:${this.gapValue}`}
|
|
2388
|
+
>
|
|
2389
|
+
<slot></slot>
|
|
2390
|
+
</div>
|
|
2391
|
+
`}};Ct.styles=[l,No];let U=Ct;Ne([s.property()],U.prototype,"size");Ne([s.property({reflect:!0})],U.prototype,"direction");Ne([s.property({reflect:!0})],U.prototype,"align");Ne([s.property({type:Boolean,reflect:!0})],U.prototype,"wrap");customElements.get("wc-space")||customElements.define("wc-space",U);const hr=i.css`
|
|
2392
|
+
:host {
|
|
2393
|
+
display: block;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
wc-row,
|
|
2397
|
+
:host(wc-row) {
|
|
2398
|
+
display: block;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
wc-col,
|
|
2402
|
+
:host(wc-col) {
|
|
2403
|
+
display: contents;
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
.row {
|
|
2407
|
+
display: flex;
|
|
2408
|
+
column-gap: var(--wc-row-gutter, 0);
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
.row slot {
|
|
2412
|
+
display: contents;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
:host([wrap]) .row {
|
|
2416
|
+
flex-wrap: wrap;
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
.justify-start {
|
|
2420
|
+
justify-content: flex-start;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
.justify-center {
|
|
2424
|
+
justify-content: center;
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
.justify-end {
|
|
2428
|
+
justify-content: flex-end;
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
.justify-space-between {
|
|
2432
|
+
justify-content: space-between;
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
.justify-space-around {
|
|
2436
|
+
justify-content: space-around;
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
.justify-space-evenly {
|
|
2440
|
+
justify-content: space-evenly;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
.align-top {
|
|
2444
|
+
align-items: flex-start;
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
.align-middle {
|
|
2448
|
+
align-items: center;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
.align-bottom {
|
|
2452
|
+
align-items: flex-end;
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
.align-stretch {
|
|
2456
|
+
align-items: stretch;
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
.col {
|
|
2460
|
+
box-sizing: border-box;
|
|
2461
|
+
min-width: 0;
|
|
2462
|
+
padding-right: calc(var(--wc-row-gutter, 0) / 2);
|
|
2463
|
+
padding-left: calc(var(--wc-row-gutter, 0) / 2);
|
|
2464
|
+
}
|
|
2465
|
+
`;var Bo=Object.defineProperty,be=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Bo(e,t,r),r};const Et=class Et extends i.LitElement{constructor(){super(...arguments),this.gutter=0,this.justify="start",this.align="top",this.wrap=!1}render(){return i.html`
|
|
2466
|
+
<div
|
|
2467
|
+
class="row ${`justify-${this.justify} align-${this.align}`}"
|
|
2468
|
+
part="base"
|
|
2469
|
+
style=${this.gutter?`--wc-row-gutter:${this.gutter}px`:""}
|
|
2470
|
+
>
|
|
2471
|
+
<slot></slot>
|
|
2472
|
+
</div>
|
|
2473
|
+
`}};Et.styles=[l,hr];let Y=Et;be([s.property({type:Number})],Y.prototype,"gutter");be([s.property({reflect:!0})],Y.prototype,"justify");be([s.property({reflect:!0})],Y.prototype,"align");be([s.property({type:Boolean,reflect:!0})],Y.prototype,"wrap");const St=class St extends i.LitElement{constructor(){super(...arguments),this.span=24,this.offset=0}get widthPercent(){return`${(Math.min(24,Math.max(1,Math.round(this.span)||24))/24*100).toFixed(4)}%`}get offsetPercent(){return`${(Math.min(23,Math.max(0,Math.round(this.offset)||0))/24*100).toFixed(4)}%`}render(){return i.html`
|
|
2474
|
+
<div
|
|
2475
|
+
class="col"
|
|
2476
|
+
part="base"
|
|
2477
|
+
style=${`width:${this.widthPercent};margin-left:${this.offsetPercent}`}
|
|
2478
|
+
>
|
|
2479
|
+
<slot></slot>
|
|
2480
|
+
</div>
|
|
2481
|
+
`}};St.styles=[l,hr];let ve=St;be([s.property({type:Number})],ve.prototype,"span");be([s.property({type:Number})],ve.prototype,"offset");customElements.get("wc-row")||customElements.define("wc-row",Y);customElements.get("wc-col")||customElements.define("wc-col",ve);const Ro=i.css`
|
|
2482
|
+
:host {
|
|
2483
|
+
display: inline;
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
:host([variant='heading']) {
|
|
2487
|
+
display: block;
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
.text {
|
|
2491
|
+
color: var(--wc-color-text);
|
|
2492
|
+
font-size: var(--wc-font-size-medium);
|
|
2493
|
+
line-height: var(--wc-font-line-height, 1.6);
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
.text slot {
|
|
2497
|
+
display: contents;
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
/* ---- 标题级别(h4~h6 无对应全局令牌,组件层补齐) ---- */
|
|
2501
|
+
.heading {
|
|
2502
|
+
font-weight: var(--wc-font-weight-semibold);
|
|
2503
|
+
line-height: 1.4;
|
|
2504
|
+
color: var(--wc-color-text);
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
.level-1 {
|
|
2508
|
+
font-size: var(--wc-font-size-h1);
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
.level-2 {
|
|
2512
|
+
font-size: var(--wc-font-size-h2);
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
.level-3 {
|
|
2516
|
+
font-size: var(--wc-font-size-h3);
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
.level-4 {
|
|
2520
|
+
font-size: var(--wc-font-size-large);
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
.level-5 {
|
|
2524
|
+
font-size: var(--wc-font-size-medium);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
.level-6 {
|
|
2528
|
+
font-size: var(--wc-font-size-medium);
|
|
2529
|
+
font-weight: var(--wc-font-weight-medium);
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
/* ---- 语义色 ---- */
|
|
2533
|
+
:host([type='secondary']) .text {
|
|
2534
|
+
color: var(--wc-color-text-secondary);
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
:host([type='success']) .text {
|
|
2538
|
+
color: var(--wc-color-success);
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
:host([type='warning']) .text {
|
|
2542
|
+
color: var(--wc-color-warning);
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
:host([type='danger']) .text {
|
|
2546
|
+
color: var(--wc-color-error);
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
/* ---- 禁用 ---- */
|
|
2550
|
+
:host([disabled]) .text {
|
|
2551
|
+
color: var(--wc-color-text-disabled);
|
|
2552
|
+
cursor: not-allowed;
|
|
2553
|
+
user-select: none;
|
|
2554
|
+
}
|
|
2555
|
+
`;var Fo=Object.defineProperty,qe=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Fo(e,t,r),r};const _t=class _t extends i.LitElement{constructor(){super(...arguments),this.variant="text",this.level=3,this.type="default",this.disabled=!1}get headingLevel(){const e=Math.round(this.level);return Math.min(6,Math.max(1,Number.isNaN(e)?3:e))}render(){if(this.variant==="heading"){const e=this.headingLevel;return i.html`
|
|
2556
|
+
<div class="text heading level-${e}" part="base" role="heading" aria-level=${e}>
|
|
2557
|
+
<slot></slot>
|
|
2558
|
+
</div>
|
|
2559
|
+
`}return i.html`<span class="text" part="base"><slot></slot></span>`}};_t.styles=[l,Ro];let H=_t;qe([s.property({reflect:!0})],H.prototype,"variant");qe([s.property({type:Number})],H.prototype,"level");qe([s.property({reflect:!0})],H.prototype,"type");qe([s.property({type:Boolean,reflect:!0})],H.prototype,"disabled");customElements.get("wc-text")||customElements.define("wc-text",H);const Vo="wc-dialog, wc-drawer";class st{constructor(e,t){this.host=e,this.hooks=t,this.bound=!1,this.prevFocused=null,this.prevBodyOverflow="",this.onDocumentKeydown=n=>{n.key==="Escape"?(n.stopPropagation(),this.hooks.requestClose("escape")):n.key==="Tab"&&this.trapFocus(n)}}otherOpenOverlays(){let e=0;return document.querySelectorAll(Vo).forEach(t=>{t!==this.host&&t.open&&(e+=1)}),e}trapFocus(e){const t=[...Array.from(this.host.shadowRoot.querySelectorAll('button, [href], [tabindex]:not([tabindex="-1"])')),...Array.from(this.host.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'))].filter(c=>!c.hasAttribute("disabled")&&c.offsetParent!==null);if(t.length===0)return;const n=t[0],r=t[t.length-1],a=this.host.shadowRoot.activeElement??document.activeElement;e.shiftKey&&(a===n||!this.host.contains(a))?(e.preventDefault(),r.focus()):!e.shiftKey&&a===r&&(e.preventDefault(),n.focus())}bind(){this.bound||(this.bound=!0,this.prevFocused=document.activeElement,document.addEventListener("keydown",this.onDocumentKeydown,!0),this.otherOpenOverlays()===0&&(this.prevBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden"),queueMicrotask(()=>{(this.host.shadowRoot?.querySelector('[part="close-button"]')??this.host.shadowRoot?.querySelector('[role="dialog"]'))?.focus()}))}unbind(){this.bound&&(this.bound=!1,document.removeEventListener("keydown",this.onDocumentKeydown,!0),this.otherOpenOverlays()===0&&(document.body.style.overflow=this.prevBodyOverflow),this.prevFocused&&this.prevFocused.focus&&(this.prevFocused.focus(),this.prevFocused=null))}}const Uo=i.css`
|
|
2560
|
+
:host {
|
|
2561
|
+
display: contents;
|
|
2562
|
+
|
|
2563
|
+
/* component 层令牌 */
|
|
2564
|
+
--wc-dialog-width: 520px;
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
.overlay {
|
|
2568
|
+
position: fixed;
|
|
2569
|
+
inset: 0;
|
|
2570
|
+
z-index: var(--wc-z-index-modal);
|
|
2571
|
+
display: flex;
|
|
2572
|
+
align-items: center;
|
|
2573
|
+
justify-content: center;
|
|
2574
|
+
padding: var(--wc-space-4);
|
|
2575
|
+
background: var(--wc-color-mask);
|
|
2576
|
+
animation: wc-dialog-fade var(--wc-duration-fast) var(--wc-easing-standard);
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
.overlay[hidden] {
|
|
2580
|
+
display: none;
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
.dialog {
|
|
2584
|
+
display: flex;
|
|
2585
|
+
flex-direction: column;
|
|
2586
|
+
box-sizing: border-box;
|
|
2587
|
+
width: min(var(--wc-dialog-width), 100%);
|
|
2588
|
+
max-height: calc(100vh - var(--wc-space-8));
|
|
2589
|
+
overflow: hidden;
|
|
2590
|
+
background-color: var(--wc-color-bg-container);
|
|
2591
|
+
border-radius: var(--wc-radius-xlarge);
|
|
2592
|
+
box-shadow: var(--wc-shadow-3);
|
|
2593
|
+
animation: wc-dialog-in var(--wc-duration-medium) var(--wc-easing-standard);
|
|
2594
|
+
outline: none;
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
.header {
|
|
2598
|
+
display: flex;
|
|
2599
|
+
align-items: center;
|
|
2600
|
+
justify-content: space-between;
|
|
2601
|
+
gap: var(--wc-space-2);
|
|
2602
|
+
padding: var(--wc-space-4) var(--wc-space-6) 0;
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
.title {
|
|
2606
|
+
flex: 1;
|
|
2607
|
+
min-width: 0;
|
|
2608
|
+
overflow: hidden;
|
|
2609
|
+
font-size: var(--wc-font-size-large);
|
|
2610
|
+
font-weight: var(--wc-font-weight-semibold);
|
|
2611
|
+
color: var(--wc-color-text);
|
|
2612
|
+
text-overflow: ellipsis;
|
|
2613
|
+
white-space: nowrap;
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
.close {
|
|
2617
|
+
display: inline-flex;
|
|
2618
|
+
flex-shrink: 0;
|
|
2619
|
+
align-items: center;
|
|
2620
|
+
justify-content: center;
|
|
2621
|
+
padding: var(--wc-space-1);
|
|
2622
|
+
font-size: var(--wc-font-size-medium);
|
|
2623
|
+
color: var(--wc-color-text-placeholder);
|
|
2624
|
+
cursor: pointer;
|
|
2625
|
+
background: transparent;
|
|
2626
|
+
border: none;
|
|
2627
|
+
border-radius: var(--wc-radius-small);
|
|
2628
|
+
transition:
|
|
2629
|
+
color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
2630
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
.close:hover {
|
|
2634
|
+
color: var(--wc-color-text);
|
|
2635
|
+
background-color: var(--wc-color-bg-hover);
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
.body {
|
|
2639
|
+
flex: 1;
|
|
2640
|
+
min-height: 0;
|
|
2641
|
+
padding: var(--wc-space-4) var(--wc-space-6);
|
|
2642
|
+
overflow-y: auto;
|
|
2643
|
+
font-size: var(--wc-font-size-medium);
|
|
2644
|
+
color: var(--wc-color-text);
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
.footer {
|
|
2648
|
+
display: flex;
|
|
2649
|
+
gap: var(--wc-space-2);
|
|
2650
|
+
justify-content: flex-end;
|
|
2651
|
+
padding: var(--wc-space-2) var(--wc-space-6) var(--wc-space-4);
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
.footer slot {
|
|
2655
|
+
display: contents;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
@keyframes wc-dialog-fade {
|
|
2659
|
+
from {
|
|
2660
|
+
opacity: 0;
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
to {
|
|
2664
|
+
opacity: 1;
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
@keyframes wc-dialog-in {
|
|
2669
|
+
from {
|
|
2670
|
+
transform: translateY(-8px) scale(0.98);
|
|
2671
|
+
opacity: 0;
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
to {
|
|
2675
|
+
transform: none;
|
|
2676
|
+
opacity: 1;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2681
|
+
.overlay,
|
|
2682
|
+
.dialog {
|
|
2683
|
+
animation: none;
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
`;var Yo=Object.defineProperty,ge=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Yo(e,t,r),r};const Ot=class Ot extends i.LitElement{constructor(){super(...arguments),this.open=!1,this.header="",this.footer=!0,this.closable=!0,this.closeOnOverlayClick=!1,this.width="",this.localize=new v(this),this.overlay=new st(this,{requestClose:e=>this.requestClose(e)})}connectedCallback(){super.connectedCallback(),this.open&&this.overlay.bind()}disconnectedCallback(){super.disconnectedCallback(),this.overlay.unbind()}show(){this.open||(this.open=!0)}requestClose(e="api"){this.dispatchEvent(new CustomEvent("wc-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0}))&&(this.open=!1)}confirm(){this.dispatchEvent(new CustomEvent("wc-confirm",{bubbles:!0,composed:!0})),this.requestClose("confirm")}cancel(){this.dispatchEvent(new CustomEvent("wc-cancel",{bubbles:!0,composed:!0})),this.requestClose("cancel")}updated(e){super.updated(e),e.has("open")&&(this.open?(this.dispatchEvent(new CustomEvent("wc-open",{bubbles:!0,composed:!0})),this.overlay.bind()):this.overlay.unbind())}onOverlayClick(e){e.target===e.currentTarget&&this.closeOnOverlayClick&&this.requestClose("overlay")}widthStyle(){if(!this.width)return"";const e=this.width.trim();return`--wc-dialog-width:${/^\d+$/.test(e)?`${e}px`:e}`}render(){return i.html`
|
|
2687
|
+
<div class="overlay" part="overlay" ?hidden=${!this.open} @click=${this.onOverlayClick}>
|
|
2688
|
+
<div
|
|
2689
|
+
class="dialog"
|
|
2690
|
+
part="base"
|
|
2691
|
+
role="dialog"
|
|
2692
|
+
aria-modal="true"
|
|
2693
|
+
aria-label=${this.header||"dialog"}
|
|
2694
|
+
tabindex="-1"
|
|
2695
|
+
style=${this.widthStyle()}
|
|
2696
|
+
>
|
|
2697
|
+
${this.header||this.closable?i.html`
|
|
2698
|
+
<div class="header" part="header">
|
|
2699
|
+
<div class="title"><slot name="header">${this.header}</slot></div>
|
|
2700
|
+
${this.closable?i.html`
|
|
2701
|
+
<button
|
|
2702
|
+
type="button"
|
|
2703
|
+
class="close"
|
|
2704
|
+
part="close-button"
|
|
2705
|
+
aria-label=${this.localize.term("dialog.close")}
|
|
2706
|
+
@click=${()=>this.requestClose("close-btn")}
|
|
2707
|
+
>
|
|
2708
|
+
<wc-icon name="close"></wc-icon>
|
|
2709
|
+
</button>
|
|
2710
|
+
`:""}
|
|
2711
|
+
</div>
|
|
2712
|
+
`:""}
|
|
2713
|
+
<div class="body" part="body"><slot></slot></div>
|
|
2714
|
+
${this.footer?i.html`
|
|
2715
|
+
<div class="footer" part="footer">
|
|
2716
|
+
<slot name="footer">
|
|
2717
|
+
<wc-button @click=${()=>this.cancel()}>
|
|
2718
|
+
${this.localize.term("dialog.cancel")}
|
|
2719
|
+
</wc-button>
|
|
2720
|
+
<wc-button theme="primary" @click=${()=>this.confirm()}>
|
|
2721
|
+
${this.localize.term("dialog.confirm")}
|
|
2722
|
+
</wc-button>
|
|
2723
|
+
</slot>
|
|
2724
|
+
</div>
|
|
2725
|
+
`:""}
|
|
2726
|
+
</div>
|
|
2727
|
+
</div>
|
|
2728
|
+
`}};Ot.styles=[l,Uo];let P=Ot;ge([s.property({type:Boolean,reflect:!0})],P.prototype,"open");ge([s.property()],P.prototype,"header");ge([s.property({type:Boolean})],P.prototype,"footer");ge([s.property({type:Boolean,reflect:!0})],P.prototype,"closable");ge([s.property({type:Boolean,attribute:"close-on-overlay-click"})],P.prototype,"closeOnOverlayClick");ge([s.property()],P.prototype,"width");customElements.get("wc-dialog")||customElements.define("wc-dialog",P);const Ho=i.css`
|
|
2729
|
+
:host {
|
|
2730
|
+
display: contents;
|
|
2731
|
+
|
|
2732
|
+
/* component 层令牌 */
|
|
2733
|
+
--wc-drawer-size: 500px;
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
.overlay {
|
|
2737
|
+
position: fixed;
|
|
2738
|
+
inset: 0;
|
|
2739
|
+
z-index: var(--wc-z-index-drawer);
|
|
2740
|
+
background: var(--wc-color-mask);
|
|
2741
|
+
animation: wc-drawer-fade var(--wc-duration-fast) var(--wc-easing-standard);
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
.overlay[hidden] {
|
|
2745
|
+
display: none;
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
.drawer {
|
|
2749
|
+
position: absolute;
|
|
2750
|
+
display: flex;
|
|
2751
|
+
flex-direction: column;
|
|
2752
|
+
box-sizing: border-box;
|
|
2753
|
+
overflow: hidden;
|
|
2754
|
+
background-color: var(--wc-color-bg-container);
|
|
2755
|
+
box-shadow: var(--wc-shadow-2);
|
|
2756
|
+
outline: none;
|
|
2757
|
+
animation: wc-drawer-in var(--wc-duration-medium) var(--wc-easing-standard);
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
/* ---- 四个方向 ---- */
|
|
2761
|
+
.placement-right {
|
|
2762
|
+
inset: 0 0 0 auto;
|
|
2763
|
+
width: min(var(--wc-drawer-size), 100%);
|
|
2764
|
+
height: 100%;
|
|
2765
|
+
--wc-drawer-from: translateX(100%);
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
.placement-left {
|
|
2769
|
+
inset: 0 auto 0 0;
|
|
2770
|
+
width: min(var(--wc-drawer-size), 100%);
|
|
2771
|
+
height: 100%;
|
|
2772
|
+
--wc-drawer-from: translateX(-100%);
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
.placement-bottom {
|
|
2776
|
+
inset: auto 0 0 0;
|
|
2777
|
+
width: 100%;
|
|
2778
|
+
height: var(--wc-drawer-size);
|
|
2779
|
+
--wc-drawer-from: translateY(100%);
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
.placement-top {
|
|
2783
|
+
inset: 0 0 auto 0;
|
|
2784
|
+
width: 100%;
|
|
2785
|
+
height: var(--wc-drawer-size);
|
|
2786
|
+
--wc-drawer-from: translateY(-100%);
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
/* ---- 页头 ---- */
|
|
2790
|
+
.header {
|
|
2791
|
+
display: flex;
|
|
2792
|
+
align-items: center;
|
|
2793
|
+
justify-content: space-between;
|
|
2794
|
+
gap: var(--wc-space-2);
|
|
2795
|
+
padding: var(--wc-space-4) var(--wc-space-6) 0;
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
.title {
|
|
2799
|
+
flex: 1;
|
|
2800
|
+
min-width: 0;
|
|
2801
|
+
overflow: hidden;
|
|
2802
|
+
font-size: var(--wc-font-size-large);
|
|
2803
|
+
font-weight: var(--wc-font-weight-semibold);
|
|
2804
|
+
color: var(--wc-color-text);
|
|
2805
|
+
text-overflow: ellipsis;
|
|
2806
|
+
white-space: nowrap;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
.close {
|
|
2810
|
+
display: inline-flex;
|
|
2811
|
+
flex-shrink: 0;
|
|
2812
|
+
align-items: center;
|
|
2813
|
+
justify-content: center;
|
|
2814
|
+
padding: var(--wc-space-1);
|
|
2815
|
+
font-size: var(--wc-font-size-medium);
|
|
2816
|
+
color: var(--wc-color-text-placeholder);
|
|
2817
|
+
cursor: pointer;
|
|
2818
|
+
background: transparent;
|
|
2819
|
+
border: none;
|
|
2820
|
+
border-radius: var(--wc-radius-small);
|
|
2821
|
+
transition:
|
|
2822
|
+
color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
2823
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
.close:hover {
|
|
2827
|
+
color: var(--wc-color-text);
|
|
2828
|
+
background-color: var(--wc-color-bg-hover);
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
/* ---- 内容区 ---- */
|
|
2832
|
+
.body {
|
|
2833
|
+
flex: 1;
|
|
2834
|
+
min-height: 0;
|
|
2835
|
+
padding: var(--wc-space-4) var(--wc-space-6);
|
|
2836
|
+
overflow-y: auto;
|
|
2837
|
+
font-size: var(--wc-font-size-medium);
|
|
2838
|
+
color: var(--wc-color-text);
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
/* ---- 页脚 ---- */
|
|
2842
|
+
.footer {
|
|
2843
|
+
display: flex;
|
|
2844
|
+
gap: var(--wc-space-2);
|
|
2845
|
+
justify-content: flex-end;
|
|
2846
|
+
padding: var(--wc-space-2) var(--wc-space-6) var(--wc-space-4);
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
.footer slot {
|
|
2850
|
+
display: contents;
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
@keyframes wc-drawer-fade {
|
|
2854
|
+
from {
|
|
2855
|
+
opacity: 0;
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
to {
|
|
2859
|
+
opacity: 1;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
@keyframes wc-drawer-in {
|
|
2864
|
+
from {
|
|
2865
|
+
transform: var(--wc-drawer-from, translateX(100%));
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
to {
|
|
2869
|
+
transform: none;
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2874
|
+
.overlay,
|
|
2875
|
+
.drawer {
|
|
2876
|
+
animation: none;
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
`;var Ko=Object.defineProperty,se=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Ko(e,t,r),r};const Wo={small:"300px",medium:"500px",large:"760px"},Pt=class Pt extends i.LitElement{constructor(){super(...arguments),this.open=!1,this.placement="right",this.size="medium",this.header="",this.footer=!0,this.closable=!0,this.closeOnOverlayClick=!0,this.localize=new v(this),this.overlay=new st(this,{requestClose:e=>this.requestClose(e)})}connectedCallback(){super.connectedCallback(),this.open&&this.overlay.bind()}disconnectedCallback(){super.disconnectedCallback(),this.overlay.unbind()}show(){this.open||(this.open=!0)}requestClose(e="api"){this.dispatchEvent(new CustomEvent("wc-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0}))&&(this.open=!1)}confirm(){this.dispatchEvent(new CustomEvent("wc-confirm",{bubbles:!0,composed:!0})),this.requestClose("confirm")}cancel(){this.dispatchEvent(new CustomEvent("wc-cancel",{bubbles:!0,composed:!0})),this.requestClose("cancel")}updated(e){super.updated(e),e.has("open")&&(this.open?(this.dispatchEvent(new CustomEvent("wc-open",{bubbles:!0,composed:!0})),this.overlay.bind()):this.overlay.unbind())}onOverlayClick(e){e.target===e.currentTarget&&this.closeOnOverlayClick&&this.requestClose("overlay")}sizeStyle(){const t=Wo[this.size]??this.size.trim();return`--wc-drawer-size:${/^\d+$/.test(t)?`${t}px`:t}`}render(){return i.html`
|
|
2880
|
+
<div class="overlay" part="overlay" ?hidden=${!this.open} @click=${this.onOverlayClick}>
|
|
2881
|
+
<div
|
|
2882
|
+
class="drawer placement-${this.placement}"
|
|
2883
|
+
part="base"
|
|
2884
|
+
role="dialog"
|
|
2885
|
+
aria-modal="true"
|
|
2886
|
+
aria-label=${this.header||"drawer"}
|
|
2887
|
+
tabindex="-1"
|
|
2888
|
+
style=${this.sizeStyle()}
|
|
2889
|
+
>
|
|
2890
|
+
${this.header||this.closable?i.html`
|
|
2891
|
+
<div class="header" part="header">
|
|
2892
|
+
<div class="title"><slot name="header">${this.header}</slot></div>
|
|
2893
|
+
${this.closable?i.html`
|
|
2894
|
+
<button
|
|
2895
|
+
type="button"
|
|
2896
|
+
class="close"
|
|
2897
|
+
part="close-button"
|
|
2898
|
+
aria-label=${this.localize.term("dialog.close")}
|
|
2899
|
+
@click=${()=>this.requestClose("close-btn")}
|
|
2900
|
+
>
|
|
2901
|
+
<wc-icon name="close"></wc-icon>
|
|
2902
|
+
</button>
|
|
2903
|
+
`:""}
|
|
2904
|
+
</div>
|
|
2905
|
+
`:""}
|
|
2906
|
+
<div class="body" part="body"><slot></slot></div>
|
|
2907
|
+
${this.footer?i.html`
|
|
2908
|
+
<div class="footer" part="footer">
|
|
2909
|
+
<slot name="footer">
|
|
2910
|
+
<wc-button @click=${()=>this.cancel()}>
|
|
2911
|
+
${this.localize.term("dialog.cancel")}
|
|
2912
|
+
</wc-button>
|
|
2913
|
+
<wc-button theme="primary" @click=${()=>this.confirm()}>
|
|
2914
|
+
${this.localize.term("dialog.confirm")}
|
|
2915
|
+
</wc-button>
|
|
2916
|
+
</slot>
|
|
2917
|
+
</div>
|
|
2918
|
+
`:""}
|
|
2919
|
+
</div>
|
|
2920
|
+
</div>
|
|
2921
|
+
`}};Pt.styles=[l,Ho];let z=Pt;se([s.property({type:Boolean,reflect:!0})],z.prototype,"open");se([s.property({reflect:!0})],z.prototype,"placement");se([s.property()],z.prototype,"size");se([s.property()],z.prototype,"header");se([s.property({type:Boolean})],z.prototype,"footer");se([s.property({type:Boolean,reflect:!0})],z.prototype,"closable");se([s.property({type:Boolean,attribute:"close-on-overlay-click"})],z.prototype,"closeOnOverlayClick");customElements.get("wc-drawer")||customElements.define("wc-drawer",z);const Xo=i.css`
|
|
2922
|
+
:host {
|
|
2923
|
+
display: block;
|
|
2924
|
+
pointer-events: auto;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
.message {
|
|
2928
|
+
display: flex;
|
|
2929
|
+
align-items: flex-start;
|
|
2930
|
+
gap: var(--wc-space-2);
|
|
2931
|
+
box-sizing: border-box;
|
|
2932
|
+
min-width: 240px;
|
|
2933
|
+
max-width: 480px;
|
|
2934
|
+
margin: 0 auto var(--wc-space-2);
|
|
2935
|
+
padding: var(--wc-space-2) var(--wc-space-4);
|
|
2936
|
+
font-size: var(--wc-font-size-medium);
|
|
2937
|
+
line-height: var(--wc-font-line-height, 1.6);
|
|
2938
|
+
color: var(--wc-color-text);
|
|
2939
|
+
background-color: var(--wc-color-bg-container);
|
|
2940
|
+
border-radius: var(--wc-radius-medium);
|
|
2941
|
+
box-shadow: var(--wc-shadow-2);
|
|
2942
|
+
animation: wc-message-in var(--wc-duration-medium) var(--wc-easing-standard);
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
.icon {
|
|
2946
|
+
flex-shrink: 0;
|
|
2947
|
+
margin-top: 2px;
|
|
2948
|
+
font-size: var(--wc-font-size-large);
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2951
|
+
.icon.success {
|
|
2952
|
+
color: var(--wc-color-success);
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
.icon.error {
|
|
2956
|
+
color: var(--wc-color-error);
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
.icon.warning {
|
|
2960
|
+
color: var(--wc-color-warning);
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
.icon.info,
|
|
2964
|
+
.icon.loading {
|
|
2965
|
+
color: var(--wc-color-primary);
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
.content {
|
|
2969
|
+
flex: 1;
|
|
2970
|
+
min-width: 0;
|
|
2971
|
+
overflow-wrap: anywhere;
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2974
|
+
.close {
|
|
2975
|
+
display: inline-flex;
|
|
2976
|
+
flex-shrink: 0;
|
|
2977
|
+
align-items: center;
|
|
2978
|
+
justify-content: center;
|
|
2979
|
+
padding: 0;
|
|
2980
|
+
font-size: var(--wc-font-size-medium);
|
|
2981
|
+
color: var(--wc-color-text-placeholder);
|
|
2982
|
+
cursor: pointer;
|
|
2983
|
+
background: transparent;
|
|
2984
|
+
border: none;
|
|
2985
|
+
border-radius: var(--wc-radius-small);
|
|
2986
|
+
transition: color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
.close:hover {
|
|
2990
|
+
color: var(--wc-color-text);
|
|
2991
|
+
}
|
|
2992
|
+
|
|
2993
|
+
@keyframes wc-message-in {
|
|
2994
|
+
from {
|
|
2995
|
+
transform: translateY(-100%);
|
|
2996
|
+
opacity: 0;
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
to {
|
|
3000
|
+
transform: none;
|
|
3001
|
+
opacity: 1;
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3006
|
+
.message {
|
|
3007
|
+
animation: none;
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
`;var Go=Object.defineProperty,Ae=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Go(e,t,r),r};const Zo={info:"info",success:"check",warning:"warning",error:"error",loading:"loader"},Lt=class Lt extends i.LitElement{constructor(){super(...arguments),this.theme="info",this.content="",this.duration=3e3,this.closable=!1,this.localize=new v(this),this.autoCloseTimer=null}connectedCallback(){super.connectedCallback(),this.startAutoClose()}disconnectedCallback(){super.disconnectedCallback(),this.stopAutoClose()}startAutoClose(){this.duration<=0||this.autoCloseTimer!==null||(this.autoCloseTimer=setTimeout(()=>this.close(),this.duration))}stopAutoClose(){this.autoCloseTimer!==null&&(clearTimeout(this.autoCloseTimer),this.autoCloseTimer=null)}close(){this.stopAutoClose(),this.dispatchEvent(new CustomEvent("wc-close",{bubbles:!0,composed:!0})),this.remove()}render(){const e=Zo[this.theme]??"info";return i.html`
|
|
3011
|
+
<div class="message" part="base" role="status" aria-live="polite">
|
|
3012
|
+
<wc-icon
|
|
3013
|
+
class="icon ${this.theme}"
|
|
3014
|
+
part="icon"
|
|
3015
|
+
name=${e}
|
|
3016
|
+
?spin=${this.theme==="loading"}
|
|
3017
|
+
></wc-icon>
|
|
3018
|
+
<div class="content" part="content"><slot>${this.content}</slot></div>
|
|
3019
|
+
${this.closable?i.html`
|
|
3020
|
+
<button
|
|
3021
|
+
type="button"
|
|
3022
|
+
class="close"
|
|
3023
|
+
part="close-button"
|
|
3024
|
+
aria-label=${this.localize.term("message.close")}
|
|
3025
|
+
@click=${()=>this.close()}
|
|
3026
|
+
>
|
|
3027
|
+
<wc-icon name="close"></wc-icon>
|
|
3028
|
+
</button>
|
|
3029
|
+
`:""}
|
|
3030
|
+
</div>
|
|
3031
|
+
`}};Lt.styles=[l,Xo];let K=Lt;Ae([s.property({reflect:!0})],K.prototype,"theme");Ae([s.property()],K.prototype,"content");Ae([s.property({type:Number})],K.prototype,"duration");Ae([s.property({type:Boolean,reflect:!0})],K.prototype,"closable");customElements.get("wc-message")||customElements.define("wc-message",K);let B=null;function Jo(){if(B&&B.isConnected)return B;B=document.createElement("div"),B.className="wc-message-container";const o=parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--wc-z-index-message"));return B.style.cssText=["position:fixed","top:var(--wc-space-4, 16px)","left:0","right:0","display:flex","flex-direction:column","align-items:center","pointer-events:none",`z-index:${Number.isFinite(o)&&o>0?o:1500}`].join(";"),document.body.appendChild(B),B}function he(o,e={}){const t=document.createElement("wc-message");return t.theme=e.theme??"info",t.content=o,e.duration!==void 0&&(t.duration=e.duration),e.closable!==void 0&&(t.closable=e.closable),e.onClose&&t.addEventListener("wc-close",()=>e.onClose()),Jo().appendChild(t),t}const Qo={info:(o,e)=>he(o,{...e,theme:"info"}),success:(o,e)=>he(o,{...e,theme:"success"}),warning:(o,e)=>he(o,{...e,theme:"warning"}),error:(o,e)=>he(o,{...e,theme:"error"}),loading:(o,e)=>he(o,{duration:0,closable:!1,...e,theme:"loading"}),show:he},T=8,_e=12;function Be(o){const e=o.indexOf("-");return e===-1?{base:o}:{base:o.slice(0,e),align:o.slice(e+1)}}function Jt(o){switch(o){case"top":return"bottom";case"bottom":return"top";case"left":return"right";case"right":return"left"}}function Qt(o,e,t,n){switch(o){case"top":return e.y-t.height-T>=n.y;case"bottom":return e.y+e.height+t.height+T<=n.y+n.height;case"left":return e.x-t.width-T>=n.x;case"right":return e.x+e.width+t.width+T<=n.x+n.width}}function Xe(o,e,t){return Math.max(e,Math.min(o,t))}function it(o,e,t,n){const{base:r,align:a}=Be(n);let c=r;!Qt(r,o,e,t)&&Qt(Jt(r),o,e,t)&&(c=Jt(r));const u=a==="start",Ee=a==="end";let le,de;const Kt=(He,Wt,Xt)=>u?He:Ee?He+Wt-Xt:He+Wt/2-Xt/2;c==="top"||c==="bottom"?(le=Kt(o.x,o.width,e.width),de=c==="top"?o.y-e.height-T:o.y+o.height+T):(de=Kt(o.y,o.height,e.height),le=c==="left"?o.x-e.width-T:o.x+o.width+T),le=Xe(le,t.x,t.x+t.width-e.width),de=Xe(de,t.y,t.y+t.height-e.height);const Ar=c==="top"||c==="bottom"?o.x+o.width/2-le:o.y+o.height/2-de,Br=(c==="top"||c==="bottom"?e.width:e.height)-_e,Rr=Xe(Ar,_e,Math.max(_e,Br)),Fr=a?`${c}-${a}`:c;return{x:le,y:de,placement:Fr,arrowOffset:Rr}}const ea=i.css`
|
|
3032
|
+
:host {
|
|
3033
|
+
display: inline-block;
|
|
3034
|
+
|
|
3035
|
+
/* component 层令牌 */
|
|
3036
|
+
--wc-tooltip-max-width: 240px;
|
|
3037
|
+
--wc-tooltip-arrow-offset: 50%;
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
.trigger {
|
|
3041
|
+
display: inline-flex;
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
.panel {
|
|
3045
|
+
position: fixed;
|
|
3046
|
+
z-index: var(--wc-z-index-tooltip);
|
|
3047
|
+
box-sizing: border-box;
|
|
3048
|
+
max-width: var(--wc-tooltip-max-width);
|
|
3049
|
+
padding: var(--wc-space-2) var(--wc-space-3);
|
|
3050
|
+
font-size: var(--wc-font-size-small);
|
|
3051
|
+
line-height: var(--wc-font-line-height, 1.6);
|
|
3052
|
+
color: var(--wc-color-text-anti);
|
|
3053
|
+
background-color: var(--wc-color-gray-900);
|
|
3054
|
+
border-radius: var(--wc-radius-small);
|
|
3055
|
+
box-shadow: var(--wc-shadow-2);
|
|
3056
|
+
opacity: 0;
|
|
3057
|
+
visibility: hidden;
|
|
3058
|
+
transform: scale(0.96);
|
|
3059
|
+
transition:
|
|
3060
|
+
opacity var(--wc-duration-fast) var(--wc-easing-standard),
|
|
3061
|
+
transform var(--wc-duration-fast) var(--wc-easing-standard),
|
|
3062
|
+
visibility var(--wc-duration-fast);
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
.panel[data-open] {
|
|
3066
|
+
opacity: 1;
|
|
3067
|
+
visibility: visible;
|
|
3068
|
+
transform: none;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
.body {
|
|
3072
|
+
overflow-wrap: anywhere;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
/* ---- 箭头:8px 旋转正方形,贴在朝向锚点的一边 ---- */
|
|
3076
|
+
.arrow {
|
|
3077
|
+
position: absolute;
|
|
3078
|
+
width: 8px;
|
|
3079
|
+
height: 8px;
|
|
3080
|
+
background-color: inherit;
|
|
3081
|
+
transform: rotate(45deg);
|
|
3082
|
+
}
|
|
3083
|
+
|
|
3084
|
+
.side-top .arrow {
|
|
3085
|
+
left: var(--wc-tooltip-arrow-offset);
|
|
3086
|
+
bottom: -4px;
|
|
3087
|
+
margin-left: -4px;
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
.side-bottom .arrow {
|
|
3091
|
+
left: var(--wc-tooltip-arrow-offset);
|
|
3092
|
+
top: -4px;
|
|
3093
|
+
margin-left: -4px;
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
.side-left .arrow {
|
|
3097
|
+
top: var(--wc-tooltip-arrow-offset);
|
|
3098
|
+
right: -4px;
|
|
3099
|
+
margin-top: -4px;
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
.side-right .arrow {
|
|
3103
|
+
top: var(--wc-tooltip-arrow-offset);
|
|
3104
|
+
left: -4px;
|
|
3105
|
+
margin-top: -4px;
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3109
|
+
.panel {
|
|
3110
|
+
transition: none;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
`;var ta=Object.defineProperty,Re=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&ta(e,t,r),r};const ra=100,oa=150;let aa=0;const Mt=class Mt extends i.LitElement{constructor(){super(...arguments),this.content="",this.placement="top",this.trigger="hover",this.open=!1,this.panelId=`wc-tooltip-panel-${++aa}`,this.showTimer=null,this.hideTimer=null,this.onDocumentClick=e=>{e.composedPath().includes(this)||this.hide()}}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.clearTimers(),document.removeEventListener("click",this.onDocumentClick,!0)}show(){this.clearTimers(),this.showTimer=setTimeout(()=>{this.open||(this.open=!0,this.dispatchEvent(new CustomEvent("wc-show",{bubbles:!0,composed:!0})))},ra)}hide(){this.clearTimers(),this.hideTimer=setTimeout(()=>{this.open&&(this.open=!1,this.dispatchEvent(new CustomEvent("wc-hide",{bubbles:!0,composed:!0})))},oa)}clearTimers(){this.showTimer!==null&&(clearTimeout(this.showTimer),this.showTimer=null),this.hideTimer!==null&&(clearTimeout(this.hideTimer),this.hideTimer=null)}onTriggerEnter(){this.trigger==="hover"&&this.show()}onTriggerLeave(){this.trigger==="hover"&&this.hide()}onTriggerClick(e){this.trigger==="click"&&(e.stopPropagation(),this.open?this.hide():this.show())}onTriggerKeydown(e){this.trigger==="click"&&e.key==="Escape"&&this.open&&this.hide()}updated(e){super.updated(e),e.has("open")&&(this.open&&this.trigger==="click"?document.addEventListener("click",this.onDocumentClick,!0):this.open||document.removeEventListener("click",this.onDocumentClick,!0),this.open&&this.position())}position(){const e=this.shadowRoot.querySelector(".panel");if(!e)return;const t=this.getBoundingClientRect(),n=e.getBoundingClientRect(),r={x:0,y:0,width:window.innerWidth,height:window.innerHeight},a=it(t,n,r,this.placement);e.style.left=`${a.x}px`,e.style.top=`${a.y}px`,e.dataset.placement=a.placement,e.style.setProperty("--wc-tooltip-arrow-offset",`${a.arrowOffset}px`)}render(){const{base:e}=Be(this.placement);return i.html`
|
|
3114
|
+
<span
|
|
3115
|
+
class="trigger"
|
|
3116
|
+
part="trigger"
|
|
3117
|
+
aria-describedby=${this.panelId}
|
|
3118
|
+
@mouseenter=${this.onTriggerEnter}
|
|
3119
|
+
@mouseleave=${this.onTriggerLeave}
|
|
3120
|
+
@focusin=${this.onTriggerEnter}
|
|
3121
|
+
@focusout=${this.onTriggerLeave}
|
|
3122
|
+
@click=${this.onTriggerClick}
|
|
3123
|
+
@keydown=${this.onTriggerKeydown}
|
|
3124
|
+
>
|
|
3125
|
+
<slot></slot>
|
|
3126
|
+
</span>
|
|
3127
|
+
<div
|
|
3128
|
+
class="panel side-${e}"
|
|
3129
|
+
part="base"
|
|
3130
|
+
id=${this.panelId}
|
|
3131
|
+
role="tooltip"
|
|
3132
|
+
?data-open=${this.open}
|
|
3133
|
+
>
|
|
3134
|
+
<div class="arrow" part="arrow"></div>
|
|
3135
|
+
<div class="body"><slot name="content">${this.content}</slot></div>
|
|
3136
|
+
</div>
|
|
3137
|
+
`}};Mt.styles=[l,ea];let W=Mt;Re([s.property()],W.prototype,"content");Re([s.property()],W.prototype,"placement");Re([s.property({reflect:!0})],W.prototype,"trigger");Re([s.property({type:Boolean,reflect:!0})],W.prototype,"open");customElements.get("wc-tooltip")||customElements.define("wc-tooltip",W);const sa=i.css`
|
|
3138
|
+
:host {
|
|
3139
|
+
display: inline-block;
|
|
3140
|
+
|
|
3141
|
+
/* component 层令牌 */
|
|
3142
|
+
--wc-popconfirm-width: 240px;
|
|
3143
|
+
--wc-popconfirm-arrow-offset: 50%;
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
.trigger {
|
|
3147
|
+
display: inline-flex;
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
.panel {
|
|
3151
|
+
position: fixed;
|
|
3152
|
+
z-index: var(--wc-z-index-tooltip);
|
|
3153
|
+
box-sizing: border-box;
|
|
3154
|
+
width: var(--wc-popconfirm-width);
|
|
3155
|
+
padding: var(--wc-space-4);
|
|
3156
|
+
font-size: var(--wc-font-size-medium);
|
|
3157
|
+
line-height: var(--wc-font-line-height, 1.6);
|
|
3158
|
+
color: var(--wc-color-text);
|
|
3159
|
+
background-color: var(--wc-color-bg-container);
|
|
3160
|
+
border-radius: var(--wc-radius-medium);
|
|
3161
|
+
box-shadow: var(--wc-shadow-2);
|
|
3162
|
+
opacity: 0;
|
|
3163
|
+
visibility: hidden;
|
|
3164
|
+
transform: scale(0.96);
|
|
3165
|
+
transition:
|
|
3166
|
+
opacity var(--wc-duration-fast) var(--wc-easing-standard),
|
|
3167
|
+
transform var(--wc-duration-fast) var(--wc-easing-standard),
|
|
3168
|
+
visibility var(--wc-duration-fast);
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
.panel[data-open] {
|
|
3172
|
+
opacity: 1;
|
|
3173
|
+
visibility: visible;
|
|
3174
|
+
transform: none;
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
.main {
|
|
3178
|
+
display: flex;
|
|
3179
|
+
align-items: flex-start;
|
|
3180
|
+
gap: var(--wc-space-2);
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
.icon {
|
|
3184
|
+
flex-shrink: 0;
|
|
3185
|
+
margin-top: 2px;
|
|
3186
|
+
font-size: var(--wc-font-size-large);
|
|
3187
|
+
color: var(--wc-color-warning);
|
|
3188
|
+
}
|
|
3189
|
+
|
|
3190
|
+
.content {
|
|
3191
|
+
flex: 1;
|
|
3192
|
+
min-width: 0;
|
|
3193
|
+
overflow-wrap: anywhere;
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
.actions {
|
|
3197
|
+
display: flex;
|
|
3198
|
+
gap: var(--wc-space-2);
|
|
3199
|
+
justify-content: flex-end;
|
|
3200
|
+
margin-top: var(--wc-space-3);
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
/* ---- 箭头(同 Tooltip) ---- */
|
|
3204
|
+
.arrow {
|
|
3205
|
+
position: absolute;
|
|
3206
|
+
width: 8px;
|
|
3207
|
+
height: 8px;
|
|
3208
|
+
background-color: inherit;
|
|
3209
|
+
transform: rotate(45deg);
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
.side-top .arrow {
|
|
3213
|
+
left: var(--wc-popconfirm-arrow-offset);
|
|
3214
|
+
bottom: -4px;
|
|
3215
|
+
margin-left: -4px;
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
.side-bottom .arrow {
|
|
3219
|
+
left: var(--wc-popconfirm-arrow-offset);
|
|
3220
|
+
top: -4px;
|
|
3221
|
+
margin-left: -4px;
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
.side-left .arrow {
|
|
3225
|
+
top: var(--wc-popconfirm-arrow-offset);
|
|
3226
|
+
right: -4px;
|
|
3227
|
+
margin-top: -4px;
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
.side-right .arrow {
|
|
3231
|
+
top: var(--wc-popconfirm-arrow-offset);
|
|
3232
|
+
left: -4px;
|
|
3233
|
+
margin-top: -4px;
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3237
|
+
.panel {
|
|
3238
|
+
transition: none;
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
`;var ia=Object.defineProperty,ie=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&ia(e,t,r),r};let na=0;const It=class It extends i.LitElement{constructor(){super(...arguments),this.content="",this.placement="top",this.confirmText="",this.cancelText="",this.theme="primary",this.icon="warning",this.open=!1,this.panelId=`wc-popconfirm-panel-${++na}`,this.localize=new v(this),this.onDocumentClick=e=>{e.composedPath().includes(this)||this.cancel("outside")},this.onDocumentKeydown=e=>{e.key==="Escape"&&(e.stopPropagation(),this.cancel("escape"))}}disconnectedCallback(){super.disconnectedCallback(),this.unbindSideEffects()}connectedCallback(){super.connectedCallback(),this.open&&this.bindSideEffects()}show(){this.open||(this.open=!0,this.bindSideEffects())}hide(){this.open&&(this.open=!1,this.unbindSideEffects())}confirm(){this.dispatchEvent(new CustomEvent("wc-confirm",{bubbles:!0,composed:!0})),this.hide()}cancel(e="button"){this.open&&(this.dispatchEvent(new CustomEvent("wc-cancel",{detail:{reason:e},bubbles:!0,composed:!0})),this.hide())}bindSideEffects(){document.addEventListener("click",this.onDocumentClick,!0),document.addEventListener("keydown",this.onDocumentKeydown,!0),queueMicrotask(()=>{this.shadowRoot.querySelector('[part="confirm-button"]')?.focus()})}unbindSideEffects(){document.removeEventListener("click",this.onDocumentClick,!0),document.removeEventListener("keydown",this.onDocumentKeydown,!0),this.shadowRoot.querySelector(".trigger")?.focus()}updated(e){super.updated(e),e.has("open")&&(this.open?(this.bindSideEffects(),this.position()):this.unbindSideEffects())}position(){const e=this.shadowRoot.querySelector(".panel");if(!e)return;const t=this.getBoundingClientRect(),n=e.getBoundingClientRect(),r={x:0,y:0,width:window.innerWidth,height:window.innerHeight},a=it(t,n,r,this.placement);e.style.left=`${a.x}px`,e.style.top=`${a.y}px`,e.dataset.placement=a.placement,e.style.setProperty("--wc-popconfirm-arrow-offset",`${a.arrowOffset}px`)}onTriggerClick(e){e.stopPropagation(),this.open?this.hide():this.show()}render(){const{base:e}=Be(this.placement);return i.html`
|
|
3242
|
+
<span
|
|
3243
|
+
class="trigger"
|
|
3244
|
+
part="trigger"
|
|
3245
|
+
tabindex="0"
|
|
3246
|
+
role="button"
|
|
3247
|
+
aria-describedby=${this.open?this.panelId:""}
|
|
3248
|
+
@click=${this.onTriggerClick}
|
|
3249
|
+
@keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.onTriggerClick(t))}}
|
|
3250
|
+
>
|
|
3251
|
+
<slot></slot>
|
|
3252
|
+
</span>
|
|
3253
|
+
<div
|
|
3254
|
+
class="panel side-${e}"
|
|
3255
|
+
part="base"
|
|
3256
|
+
id=${this.panelId}
|
|
3257
|
+
role="dialog"
|
|
3258
|
+
aria-label=${this.content||"popconfirm"}
|
|
3259
|
+
?data-open=${this.open}
|
|
3260
|
+
>
|
|
3261
|
+
<div class="arrow" part="arrow"></div>
|
|
3262
|
+
<div class="main">
|
|
3263
|
+
${this.icon?i.html`<wc-icon class="icon" part="icon" name=${this.icon}></wc-icon>`:""}
|
|
3264
|
+
<div class="content"><slot name="content">${this.content}</slot></div>
|
|
3265
|
+
</div>
|
|
3266
|
+
<div class="actions" part="actions">
|
|
3267
|
+
<wc-button size="small" @click=${()=>this.cancel("button")}>
|
|
3268
|
+
${this.cancelText||this.localize.term("dialog.cancel")}
|
|
3269
|
+
</wc-button>
|
|
3270
|
+
<wc-button
|
|
3271
|
+
size="small"
|
|
3272
|
+
theme=${this.theme}
|
|
3273
|
+
part="confirm-button"
|
|
3274
|
+
@click=${()=>this.confirm()}
|
|
3275
|
+
>
|
|
3276
|
+
${this.confirmText||this.localize.term("dialog.confirm")}
|
|
3277
|
+
</wc-button>
|
|
3278
|
+
</div>
|
|
3279
|
+
</div>
|
|
3280
|
+
`}};It.styles=[l,sa];let C=It;ie([s.property()],C.prototype,"content");ie([s.property()],C.prototype,"placement");ie([s.property({attribute:"confirm-text"})],C.prototype,"confirmText");ie([s.property({attribute:"cancel-text"})],C.prototype,"cancelText");ie([s.property()],C.prototype,"theme");ie([s.property()],C.prototype,"icon");ie([s.property({type:Boolean,reflect:!0})],C.prototype,"open");customElements.get("wc-popconfirm")||customElements.define("wc-popconfirm",C);const ca=i.css`
|
|
3281
|
+
:host {
|
|
3282
|
+
display: block;
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
.bar {
|
|
3286
|
+
display: flex;
|
|
3287
|
+
gap: var(--wc-space-2);
|
|
3288
|
+
border-bottom: 1px solid var(--wc-color-border);
|
|
3289
|
+
}
|
|
3290
|
+
|
|
3291
|
+
.tab {
|
|
3292
|
+
position: relative;
|
|
3293
|
+
padding: var(--wc-space-2) var(--wc-space-4);
|
|
3294
|
+
font-size: var(--wc-font-size-medium);
|
|
3295
|
+
line-height: var(--wc-font-line-height, 1.6);
|
|
3296
|
+
color: var(--wc-color-text);
|
|
3297
|
+
cursor: pointer;
|
|
3298
|
+
background: transparent;
|
|
3299
|
+
border: none;
|
|
3300
|
+
outline: none;
|
|
3301
|
+
transition:
|
|
3302
|
+
color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
3303
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
.tab::after {
|
|
3307
|
+
content: '';
|
|
3308
|
+
position: absolute;
|
|
3309
|
+
right: var(--wc-space-3);
|
|
3310
|
+
bottom: -1px;
|
|
3311
|
+
left: var(--wc-space-3);
|
|
3312
|
+
height: 2px;
|
|
3313
|
+
background-color: var(--wc-color-primary);
|
|
3314
|
+
border-radius: var(--wc-radius-small);
|
|
3315
|
+
opacity: 0;
|
|
3316
|
+
transform: scaleX(0.4);
|
|
3317
|
+
transition:
|
|
3318
|
+
opacity var(--wc-duration-fast) var(--wc-easing-standard),
|
|
3319
|
+
transform var(--wc-duration-fast) var(--wc-easing-standard);
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3322
|
+
.tab:hover {
|
|
3323
|
+
color: var(--wc-color-primary);
|
|
3324
|
+
background-color: var(--wc-color-bg-hover);
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
.tab[aria-selected='true'] {
|
|
3328
|
+
color: var(--wc-color-primary);
|
|
3329
|
+
font-weight: var(--wc-font-weight-semibold);
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
.tab[aria-selected='true']::after {
|
|
3333
|
+
opacity: 1;
|
|
3334
|
+
transform: none;
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
.tab:focus-visible {
|
|
3338
|
+
box-shadow: 0 0 0 2px var(--wc-color-focus-ring);
|
|
3339
|
+
}
|
|
3340
|
+
|
|
3341
|
+
.tab[data-disabled] {
|
|
3342
|
+
color: var(--wc-color-text-disabled);
|
|
3343
|
+
cursor: not-allowed;
|
|
3344
|
+
background-color: transparent;
|
|
3345
|
+
}
|
|
3346
|
+
`,la=i.css`
|
|
3347
|
+
:host {
|
|
3348
|
+
display: block;
|
|
3349
|
+
padding-top: var(--wc-space-3);
|
|
3350
|
+
font-size: var(--wc-font-size-medium);
|
|
3351
|
+
line-height: var(--wc-font-line-height, 1.6);
|
|
3352
|
+
color: var(--wc-color-text);
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
:host(:not([active])) {
|
|
3356
|
+
display: none;
|
|
3357
|
+
}
|
|
3358
|
+
`;var da=Object.defineProperty,Fe=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&da(e,t,r),r};const Tt=class Tt extends i.LitElement{constructor(){super(...arguments),this.value="",this.label="",this.disabled=!1,this.active=!1}render(){return i.html`<div class="panel" part="panel" role="tabpanel" aria-label=${this.label}>
|
|
3359
|
+
<slot></slot>
|
|
3360
|
+
</div>`}};Tt.styles=[l,la];let X=Tt;Fe([s.property()],X.prototype,"value");Fe([s.property()],X.prototype,"label");Fe([s.property({type:Boolean,reflect:!0})],X.prototype,"disabled");Fe([s.property({type:Boolean,reflect:!0})],X.prototype,"active");customElements.get("wc-tab")||customElements.define("wc-tab",X);var ha=Object.defineProperty,pa=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&ha(e,t,r),r};const Dt=class Dt extends i.LitElement{constructor(){super(...arguments),this.value="",this.tabs=[],this.uid=`wc-tabs-${Math.random().toString(36).slice(2,8)}`,this.mutationObserver=new MutationObserver(()=>this.collectTabs())}connectedCallback(){super.connectedCallback(),this.mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]})}disconnectedCallback(){super.disconnectedCallback(),this.mutationObserver.disconnect()}collectTabs(){const e=Array.from(this.querySelectorAll("wc-tab"));this.tabs=e.map((t,n)=>({value:t.value||String(n),label:t.label||t.textContent?.trim()||String(n+1),disabled:t.disabled,element:t})),this.requestUpdate(),this.syncActive()}syncActive(){!this.value&&this.tabs.length>0&&!this.tabs.some(e=>e.value===this.value)&&(this.value=this.tabs[0].value);for(const e of this.tabs)e.element.active=e.value===this.value}updated(e){super.updated(e),e.has("value")&&this.syncActive()}select(e){if(e===this.value)return;const t=this.tabs.find(n=>n.value===e);!t||t.disabled||(this.value=e,this.dispatchEvent(new CustomEvent("wc-change",{detail:{value:e},bubbles:!0,composed:!0})))}onTablistKeydown(e){const t=this.tabs.filter(a=>!a.disabled);if(t.length===0)return;const n=Math.max(0,t.findIndex(a=>a.value===this.value));let r;switch(e.key){case"ArrowRight":case"ArrowDown":r=t[(n+1)%t.length];break;case"ArrowLeft":case"ArrowUp":r=t[(n-1+t.length)%t.length];break;case"Home":r=t[0];break;case"End":r=t[t.length-1];break;default:return}e.preventDefault(),r&&(this.select(r.value),this.focusTab(r.value))}focusTab(e){const t=e.replace(/["\\]/g,"\\$&");this.shadowRoot.querySelector(`[data-value="${t}"]`)?.focus()}render(){return i.html`
|
|
3361
|
+
<div class="bar" part="bar" role="tablist" @keydown=${this.onTablistKeydown}>
|
|
3362
|
+
${this.tabs.map(e=>i.html`
|
|
3363
|
+
<button
|
|
3364
|
+
type="button"
|
|
3365
|
+
class="tab"
|
|
3366
|
+
part="tab"
|
|
3367
|
+
role="tab"
|
|
3368
|
+
data-value=${e.value}
|
|
3369
|
+
id=${`${this.uid}-tab-${e.value}`}
|
|
3370
|
+
aria-selected=${e.value===this.value?"true":"false"}
|
|
3371
|
+
aria-disabled=${e.disabled?"true":"false"}
|
|
3372
|
+
tabindex=${e.value===this.value?"0":"-1"}
|
|
3373
|
+
?data-disabled=${e.disabled}
|
|
3374
|
+
@click=${()=>this.select(e.value)}
|
|
3375
|
+
>
|
|
3376
|
+
${e.label}
|
|
3377
|
+
</button>
|
|
3378
|
+
`)}
|
|
3379
|
+
</div>
|
|
3380
|
+
${this.tabs.length>0?i.html`<slot @slotchange=${this.collectTabs}></slot>`:i.nothing}
|
|
3381
|
+
`}};Dt.styles=[l,ca];let ke=Dt;pa([s.property({reflect:!0})],ke.prototype,"value");customElements.get("wc-tabs")||customElements.define("wc-tabs",ke);const ua=i.css`
|
|
3382
|
+
:host {
|
|
3383
|
+
display: block;
|
|
3384
|
+
}
|
|
3385
|
+
|
|
3386
|
+
/* 条目由 shadow 渲染,light-DOM 子元素仅用于收集元数据 */
|
|
3387
|
+
slot {
|
|
3388
|
+
display: none;
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3391
|
+
.list {
|
|
3392
|
+
display: flex;
|
|
3393
|
+
flex-wrap: wrap;
|
|
3394
|
+
align-items: center;
|
|
3395
|
+
gap: var(--wc-space-1);
|
|
3396
|
+
margin: 0;
|
|
3397
|
+
padding: 0;
|
|
3398
|
+
list-style: none;
|
|
3399
|
+
font-size: var(--wc-font-size-medium);
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
.item {
|
|
3403
|
+
display: inline-flex;
|
|
3404
|
+
align-items: center;
|
|
3405
|
+
}
|
|
3406
|
+
|
|
3407
|
+
.separator {
|
|
3408
|
+
display: inline-flex;
|
|
3409
|
+
align-items: center;
|
|
3410
|
+
color: var(--wc-color-text-placeholder);
|
|
3411
|
+
user-select: none;
|
|
3412
|
+
}
|
|
3413
|
+
|
|
3414
|
+
.link {
|
|
3415
|
+
color: var(--wc-color-text-secondary);
|
|
3416
|
+
text-decoration: none;
|
|
3417
|
+
cursor: pointer;
|
|
3418
|
+
transition: color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
.link:hover {
|
|
3422
|
+
color: var(--wc-color-primary);
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
.link[data-disabled] {
|
|
3426
|
+
color: var(--wc-color-text-disabled);
|
|
3427
|
+
cursor: not-allowed;
|
|
3428
|
+
}
|
|
3429
|
+
|
|
3430
|
+
.link[data-disabled]:hover {
|
|
3431
|
+
color: var(--wc-color-text-disabled);
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
.current {
|
|
3435
|
+
color: var(--wc-color-text);
|
|
3436
|
+
font-weight: var(--wc-font-weight-medium);
|
|
3437
|
+
}
|
|
3438
|
+
`;var va=Object.defineProperty,wa=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&va(e,t,r),r};const jt=class jt extends i.LitElement{constructor(){super(...arguments),this.separator="/",this.items=[],this.localize=new v(this),this.mutationObserver=new MutationObserver(()=>this.collectItems())}connectedCallback(){super.connectedCallback(),this.mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["href","disabled"]})}disconnectedCallback(){super.disconnectedCallback(),this.mutationObserver.disconnect()}collectItems(){const e=Array.from(this.querySelectorAll("wc-breadcrumb-item"));this.items=e.map((t,n)=>({label:t.textContent?.trim()||String(n+1),href:t.getAttribute("href")||"",disabled:t.hasAttribute("disabled"),index:n})),this.requestUpdate()}onSelect(e){this.dispatchEvent(new CustomEvent("wc-select",{detail:{index:e.index,label:e.label,href:e.href},bubbles:!0,composed:!0}))}renderItem(e,t){return t?i.html`<span class="current" part="current" aria-current="page">${e.label}</span>`:e.disabled?i.html`<span class="link" data-disabled aria-disabled="true">${e.label}</span>`:e.href?i.html`<a class="link" part="link" href=${e.href} @click=${()=>this.onSelect(e)}
|
|
3439
|
+
>${e.label}</a
|
|
3440
|
+
>`:i.html`<span class="link" part="link" @click=${()=>this.onSelect(e)}
|
|
3441
|
+
>${e.label}</span
|
|
3442
|
+
>`}render(){const e=this.items.length-1;return i.html`
|
|
3443
|
+
<nav class="nav" part="nav" aria-label=${this.localize.term("breadcrumb.label")}>
|
|
3444
|
+
<ol class="list" part="list">
|
|
3445
|
+
${this.items.map((t,n)=>i.html`
|
|
3446
|
+
<li class="item" part="item">${this.renderItem(t,n===e)}</li>
|
|
3447
|
+
${n<e?i.html`<li class="separator" part="separator" aria-hidden="true">
|
|
3448
|
+
${this.separator}
|
|
3449
|
+
</li>`:i.nothing}
|
|
3450
|
+
`)}
|
|
3451
|
+
</ol>
|
|
3452
|
+
<slot @slotchange=${this.collectItems}></slot>
|
|
3453
|
+
</nav>
|
|
3454
|
+
`}};jt.styles=[l,ua];let $e=jt;wa([s.property()],$e.prototype,"separator");customElements.get("wc-breadcrumb")||customElements.define("wc-breadcrumb",$e);var ma=Object.defineProperty,pr=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&ma(e,t,r),r};class Ve extends i.LitElement{constructor(){super(...arguments),this.href="",this.disabled=!1}render(){return i.html``}}pr([s.property()],Ve.prototype,"href");pr([s.property({type:Boolean,reflect:!0})],Ve.prototype,"disabled");customElements.get("wc-breadcrumb-item")||customElements.define("wc-breadcrumb-item",Ve);const ba=i.css`
|
|
3455
|
+
:host {
|
|
3456
|
+
display: block;
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
.pagination {
|
|
3460
|
+
display: flex;
|
|
3461
|
+
flex-wrap: wrap;
|
|
3462
|
+
align-items: center;
|
|
3463
|
+
gap: var(--wc-space-1);
|
|
3464
|
+
font-size: var(--wc-font-size-medium);
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3467
|
+
.total {
|
|
3468
|
+
margin-right: var(--wc-space-2);
|
|
3469
|
+
color: var(--wc-color-text-secondary);
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3472
|
+
.page-button {
|
|
3473
|
+
display: inline-flex;
|
|
3474
|
+
align-items: center;
|
|
3475
|
+
justify-content: center;
|
|
3476
|
+
min-width: 32px;
|
|
3477
|
+
height: 32px;
|
|
3478
|
+
padding: 0 var(--wc-space-2);
|
|
3479
|
+
color: var(--wc-color-text);
|
|
3480
|
+
font: inherit;
|
|
3481
|
+
background: transparent;
|
|
3482
|
+
border: none;
|
|
3483
|
+
border-radius: var(--wc-radius-small);
|
|
3484
|
+
cursor: pointer;
|
|
3485
|
+
transition:
|
|
3486
|
+
color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
3487
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
.page-button:hover:not(:disabled) {
|
|
3491
|
+
color: var(--wc-color-primary);
|
|
3492
|
+
background-color: var(--wc-color-bg-hover);
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
.page-button:disabled {
|
|
3496
|
+
color: var(--wc-color-text-disabled);
|
|
3497
|
+
cursor: not-allowed;
|
|
3498
|
+
background: transparent;
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
.page-button[aria-current='page'] {
|
|
3502
|
+
color: var(--wc-color-primary);
|
|
3503
|
+
font-weight: var(--wc-font-weight-medium);
|
|
3504
|
+
background-color: var(--wc-color-primary-light);
|
|
3505
|
+
}
|
|
3506
|
+
|
|
3507
|
+
.ellipsis {
|
|
3508
|
+
min-width: 32px;
|
|
3509
|
+
color: var(--wc-color-text-placeholder);
|
|
3510
|
+
letter-spacing: 1px;
|
|
3511
|
+
text-align: center;
|
|
3512
|
+
user-select: none;
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
.jumper {
|
|
3516
|
+
display: inline-flex;
|
|
3517
|
+
align-items: center;
|
|
3518
|
+
gap: var(--wc-space-2);
|
|
3519
|
+
margin-left: var(--wc-space-2);
|
|
3520
|
+
color: var(--wc-color-text-secondary);
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
.jumper-input {
|
|
3524
|
+
width: 56px;
|
|
3525
|
+
height: 32px;
|
|
3526
|
+
padding: 0 var(--wc-space-2);
|
|
3527
|
+
font: inherit;
|
|
3528
|
+
color: var(--wc-color-text);
|
|
3529
|
+
text-align: center;
|
|
3530
|
+
background: transparent;
|
|
3531
|
+
border: 1px solid var(--wc-color-border);
|
|
3532
|
+
border-radius: var(--wc-radius-small);
|
|
3533
|
+
}
|
|
3534
|
+
|
|
3535
|
+
.jumper-input:focus {
|
|
3536
|
+
outline: none;
|
|
3537
|
+
border-color: var(--wc-color-primary);
|
|
3538
|
+
}
|
|
3539
|
+
|
|
3540
|
+
.jumper-input:disabled {
|
|
3541
|
+
color: var(--wc-color-text-disabled);
|
|
3542
|
+
background-color: var(--wc-color-bg-disabled, var(--wc-color-bg-hover));
|
|
3543
|
+
cursor: not-allowed;
|
|
3544
|
+
}
|
|
3545
|
+
`;var ga=Object.defineProperty,ne=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&ga(e,t,r),r};const Nt=class Nt extends i.LitElement{constructor(){super(...arguments),this.total=0,this.pageSize=10,this.current=1,this.foldedPageCount=5,this.showTotal=!1,this.showJumper=!1,this.disabled=!1,this.localize=new v(this)}get pageCount(){return Math.max(1,Math.ceil(this.total/Math.max(1,this.pageSize)))}select(e){const t=Math.min(this.pageCount,Math.max(1,Math.floor(e)));if(this.disabled||t===this.current)return;const n=this.current;this.current=t,this.dispatchEvent(new CustomEvent("wc-change",{detail:{current:t,previous:n},bubbles:!0,composed:!0}))}updated(e){super.updated(e),(e.has("total")||e.has("pageSize"))&&this.current>this.pageCount&&(this.current=this.pageCount)}getPageItems(){const e=this.pageCount,t=Math.max(1,this.foldedPageCount);if(e<=t+2)return Array.from({length:e},(c,u)=>u+1);let n=Math.max(2,this.current-Math.floor(t/2));const r=Math.min(e-1,n+t-1);n=Math.max(2,r-t+1);const a=[1];n>2&&a.push("ellipsis-prev");for(let c=n;c<=r;c++)a.push(c);return r<e-1&&a.push("ellipsis-next"),a.push(e),a}onJumperKeydown(e){if(e.key!=="Enter")return;const t=e.target,n=Number.parseInt(t.value,10);Number.isNaN(n)||(this.select(n),t.value=String(this.current))}render(){const e=this.disabled||this.current<=1,t=this.disabled||this.current>=this.pageCount;return i.html`
|
|
3546
|
+
<nav class="pagination" part="nav" aria-label=${this.localize.term("pagination.label")}>
|
|
3547
|
+
${this.showTotal?i.html`<span class="total" part="total">
|
|
3548
|
+
${this.localize.term("pagination.total",{total:this.total})}
|
|
3549
|
+
</span>`:i.nothing}
|
|
3550
|
+
<button
|
|
3551
|
+
type="button"
|
|
3552
|
+
class="page-button"
|
|
3553
|
+
part="prev"
|
|
3554
|
+
?disabled=${e}
|
|
3555
|
+
aria-label=${this.localize.term("pagination.prev")}
|
|
3556
|
+
@click=${()=>this.select(this.current-1)}
|
|
3557
|
+
>
|
|
3558
|
+
<wc-icon name="chevron-left"></wc-icon>
|
|
3559
|
+
</button>
|
|
3560
|
+
${this.getPageItems().map(n=>typeof n!="number"?i.html`<span class="ellipsis" part="ellipsis" aria-hidden="true">•••</span>`:i.html`<button
|
|
3561
|
+
type="button"
|
|
3562
|
+
class="page-button"
|
|
3563
|
+
part="page"
|
|
3564
|
+
?disabled=${this.disabled}
|
|
3565
|
+
aria-label=${this.localize.term("pagination.page",{page:n})}
|
|
3566
|
+
aria-current=${n===this.current?"page":i.nothing}
|
|
3567
|
+
@click=${()=>this.select(n)}
|
|
3568
|
+
>
|
|
3569
|
+
${n}
|
|
3570
|
+
</button>`)}
|
|
3571
|
+
<button
|
|
3572
|
+
type="button"
|
|
3573
|
+
class="page-button"
|
|
3574
|
+
part="next"
|
|
3575
|
+
?disabled=${t}
|
|
3576
|
+
aria-label=${this.localize.term("pagination.next")}
|
|
3577
|
+
@click=${()=>this.select(this.current+1)}
|
|
3578
|
+
>
|
|
3579
|
+
<wc-icon name="chevron-right"></wc-icon>
|
|
3580
|
+
</button>
|
|
3581
|
+
${this.showJumper?i.html`<span class="jumper" part="jumper">
|
|
3582
|
+
${this.localize.term("pagination.jumpTo")}
|
|
3583
|
+
<input
|
|
3584
|
+
type="text"
|
|
3585
|
+
class="jumper-input"
|
|
3586
|
+
part="jumper-input"
|
|
3587
|
+
?disabled=${this.disabled}
|
|
3588
|
+
aria-label=${this.localize.term("pagination.jumpTo")}
|
|
3589
|
+
@keydown=${this.onJumperKeydown}
|
|
3590
|
+
/>
|
|
3591
|
+
${this.localize.term("pagination.pageUnit")}
|
|
3592
|
+
</span>`:i.nothing}
|
|
3593
|
+
</nav>
|
|
3594
|
+
`}};Nt.styles=[l,ba];let E=Nt;ne([s.property({type:Number})],E.prototype,"total");ne([s.property({type:Number,attribute:"page-size"})],E.prototype,"pageSize");ne([s.property({type:Number,reflect:!0})],E.prototype,"current");ne([s.property({type:Number,attribute:"folded-page-count"})],E.prototype,"foldedPageCount");ne([s.property({type:Boolean,attribute:"show-total"})],E.prototype,"showTotal");ne([s.property({type:Boolean,attribute:"show-jumper"})],E.prototype,"showJumper");ne([s.property({type:Boolean,reflect:!0})],E.prototype,"disabled");customElements.get("wc-pagination")||customElements.define("wc-pagination",E);const fa=i.css`
|
|
3595
|
+
:host {
|
|
3596
|
+
position: relative;
|
|
3597
|
+
display: inline-flex;
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
.badge {
|
|
3601
|
+
position: absolute;
|
|
3602
|
+
top: 0;
|
|
3603
|
+
right: 0;
|
|
3604
|
+
z-index: var(--wc-z-index-popover, 1);
|
|
3605
|
+
display: inline-flex;
|
|
3606
|
+
align-items: center;
|
|
3607
|
+
justify-content: center;
|
|
3608
|
+
min-width: 16px;
|
|
3609
|
+
height: 16px;
|
|
3610
|
+
padding: 0 4px;
|
|
3611
|
+
color: var(--wc-color-text-anti);
|
|
3612
|
+
font-size: var(--wc-font-size-xsmall);
|
|
3613
|
+
line-height: 1;
|
|
3614
|
+
white-space: nowrap;
|
|
3615
|
+
background-color: var(--wc-color-error);
|
|
3616
|
+
border-radius: var(--wc-radius-round);
|
|
3617
|
+
transform: translate(50%, -50%);
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
:host([dot]) .badge {
|
|
3621
|
+
min-width: 6px;
|
|
3622
|
+
width: 6px;
|
|
3623
|
+
height: 6px;
|
|
3624
|
+
padding: 0;
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
:host([theme='primary']) .badge {
|
|
3628
|
+
background-color: var(--wc-color-primary);
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
:host([theme='success']) .badge {
|
|
3632
|
+
background-color: var(--wc-color-success);
|
|
3633
|
+
}
|
|
3634
|
+
|
|
3635
|
+
:host([theme='warning']) .badge {
|
|
3636
|
+
background-color: var(--wc-color-warning);
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3639
|
+
:host([theme='danger']) .badge {
|
|
3640
|
+
background-color: var(--wc-color-error);
|
|
3641
|
+
}
|
|
3642
|
+
`;var ya=Object.defineProperty,Ue=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&ya(e,t,r),r};const qt=class qt extends i.LitElement{constructor(){super(...arguments),this.count=0,this.max=99,this.dot=!1,this.theme="danger"}get displayCount(){return this.count>this.max?`${this.max}+`:String(Math.max(0,this.count))}render(){const e=this.dot||this.count>0;return i.html`
|
|
3643
|
+
<slot></slot>
|
|
3644
|
+
${e?i.html`<sup class="badge" part="badge">${this.dot?i.nothing:this.displayCount}</sup>`:i.nothing}
|
|
3645
|
+
`}};qt.styles=[l,fa];let G=qt;Ue([s.property({type:Number})],G.prototype,"count");Ue([s.property({type:Number})],G.prototype,"max");Ue([s.property({type:Boolean,reflect:!0})],G.prototype,"dot");Ue([s.property({reflect:!0})],G.prototype,"theme");customElements.get("wc-badge")||customElements.define("wc-badge",G);const xa=i.css`
|
|
3646
|
+
:host {
|
|
3647
|
+
display: block;
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
.empty {
|
|
3651
|
+
display: flex;
|
|
3652
|
+
flex-direction: column;
|
|
3653
|
+
align-items: center;
|
|
3654
|
+
justify-content: center;
|
|
3655
|
+
padding: var(--wc-space-8) var(--wc-space-4);
|
|
3656
|
+
text-align: center;
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
.icon {
|
|
3660
|
+
display: flex;
|
|
3661
|
+
align-items: center;
|
|
3662
|
+
justify-content: center;
|
|
3663
|
+
color: var(--wc-color-text-placeholder);
|
|
3664
|
+
}
|
|
3665
|
+
|
|
3666
|
+
/* 默认占位图形:圆角方块 + 内嵌虚线圆,柔和示意「空」 */
|
|
3667
|
+
.placeholder {
|
|
3668
|
+
position: relative;
|
|
3669
|
+
display: block;
|
|
3670
|
+
width: 56px;
|
|
3671
|
+
height: 56px;
|
|
3672
|
+
background-color: var(--wc-color-bg-hover);
|
|
3673
|
+
border-radius: var(--wc-radius-xlarge);
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
.placeholder::after {
|
|
3677
|
+
content: '';
|
|
3678
|
+
position: absolute;
|
|
3679
|
+
top: 50%;
|
|
3680
|
+
left: 50%;
|
|
3681
|
+
width: 24px;
|
|
3682
|
+
height: 24px;
|
|
3683
|
+
border: 2px dashed var(--wc-color-text-placeholder);
|
|
3684
|
+
border-radius: var(--wc-radius-circle);
|
|
3685
|
+
transform: translate(-50%, -50%);
|
|
3686
|
+
}
|
|
3687
|
+
|
|
3688
|
+
.description {
|
|
3689
|
+
margin-top: var(--wc-space-3);
|
|
3690
|
+
color: var(--wc-color-text-secondary);
|
|
3691
|
+
font-size: var(--wc-font-size-medium);
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3694
|
+
.action {
|
|
3695
|
+
margin-top: var(--wc-space-4);
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
.action:empty {
|
|
3699
|
+
display: none;
|
|
3700
|
+
}
|
|
3701
|
+
`,At=class At extends i.LitElement{constructor(){super(...arguments),this.localize=new v(this)}render(){return i.html`
|
|
3702
|
+
<div class="empty" part="base">
|
|
3703
|
+
<div class="icon" part="icon">
|
|
3704
|
+
<slot name="icon"><span class="placeholder"></span></slot>
|
|
3705
|
+
</div>
|
|
3706
|
+
<div class="description" part="description">
|
|
3707
|
+
<slot>${this.localize.term("empty.noData")}</slot>
|
|
3708
|
+
</div>
|
|
3709
|
+
<div class="action" part="action">
|
|
3710
|
+
<slot name="action"></slot>
|
|
3711
|
+
</div>
|
|
3712
|
+
</div>
|
|
3713
|
+
`}};At.styles=[l,xa];let Me=At;customElements.get("wc-empty")||customElements.define("wc-empty",Me);const ka=i.css`
|
|
3714
|
+
:host {
|
|
3715
|
+
display: block;
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
/* ---- line ---- */
|
|
3719
|
+
.line {
|
|
3720
|
+
display: flex;
|
|
3721
|
+
align-items: center;
|
|
3722
|
+
gap: var(--wc-space-2);
|
|
3723
|
+
}
|
|
3724
|
+
|
|
3725
|
+
.track {
|
|
3726
|
+
position: relative;
|
|
3727
|
+
flex: 1;
|
|
3728
|
+
overflow: hidden;
|
|
3729
|
+
background-color: var(--wc-color-bg-hover);
|
|
3730
|
+
border-radius: var(--wc-radius-round);
|
|
3731
|
+
}
|
|
3732
|
+
|
|
3733
|
+
.indicator {
|
|
3734
|
+
height: 100%;
|
|
3735
|
+
background-color: var(--wc-color-primary);
|
|
3736
|
+
border-radius: var(--wc-radius-round);
|
|
3737
|
+
transition: width var(--wc-duration-slow, 300ms) var(--wc-easing-standard);
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
:host([status='success']) .indicator {
|
|
3741
|
+
background-color: var(--wc-color-success);
|
|
3742
|
+
}
|
|
3743
|
+
|
|
3744
|
+
:host([status='warning']) .indicator {
|
|
3745
|
+
background-color: var(--wc-color-warning);
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
:host([status='error']) .indicator {
|
|
3749
|
+
background-color: var(--wc-color-error);
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3752
|
+
.label {
|
|
3753
|
+
display: inline-flex;
|
|
3754
|
+
align-items: center;
|
|
3755
|
+
gap: 2px;
|
|
3756
|
+
color: var(--wc-color-text-secondary);
|
|
3757
|
+
font-size: var(--wc-font-size-small);
|
|
3758
|
+
line-height: 1;
|
|
3759
|
+
white-space: nowrap;
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3762
|
+
:host([status='success']) .label {
|
|
3763
|
+
color: var(--wc-color-success);
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
:host([status='error']) .label {
|
|
3767
|
+
color: var(--wc-color-error);
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
.label wc-icon {
|
|
3771
|
+
--icon-size: 1em;
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3774
|
+
/* ---- circle ---- */
|
|
3775
|
+
.circle-wrap {
|
|
3776
|
+
position: relative;
|
|
3777
|
+
display: inline-block;
|
|
3778
|
+
width: 72px;
|
|
3779
|
+
height: 72px;
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3782
|
+
.circle {
|
|
3783
|
+
display: block;
|
|
3784
|
+
width: 100%;
|
|
3785
|
+
height: 100%;
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
.circle .track {
|
|
3789
|
+
fill: none;
|
|
3790
|
+
stroke: var(--wc-color-bg-hover);
|
|
3791
|
+
stroke-width: 6;
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
.circle .indicator {
|
|
3795
|
+
fill: none;
|
|
3796
|
+
stroke: var(--wc-color-primary);
|
|
3797
|
+
stroke-width: 6;
|
|
3798
|
+
stroke-linecap: round;
|
|
3799
|
+
transition: stroke-dashoffset var(--wc-duration-slow, 300ms) var(--wc-easing-standard);
|
|
3800
|
+
}
|
|
3801
|
+
|
|
3802
|
+
:host([status='success']) .circle .indicator {
|
|
3803
|
+
stroke: var(--wc-color-success);
|
|
3804
|
+
}
|
|
3805
|
+
|
|
3806
|
+
:host([status='warning']) .circle .indicator {
|
|
3807
|
+
stroke: var(--wc-color-warning);
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
:host([status='error']) .circle .indicator {
|
|
3811
|
+
stroke: var(--wc-color-error);
|
|
3812
|
+
}
|
|
3813
|
+
|
|
3814
|
+
.circle-label {
|
|
3815
|
+
position: absolute;
|
|
3816
|
+
inset: 0;
|
|
3817
|
+
display: flex;
|
|
3818
|
+
align-items: center;
|
|
3819
|
+
justify-content: center;
|
|
3820
|
+
color: var(--wc-color-text);
|
|
3821
|
+
font-size: var(--wc-font-size-small);
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3824
|
+
.circle-label .label {
|
|
3825
|
+
color: inherit;
|
|
3826
|
+
}
|
|
3827
|
+
`;var $a=Object.defineProperty,fe=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&$a(e,t,r),r};const Ze=32,er=2*Math.PI*Ze,Bt=class Bt extends i.LitElement{constructor(){super(...arguments),this.value=0,this.theme="line",this.status="normal",this.showLabel=!0,this.strokeWidth=6,this.label=""}get percent(){return Math.min(100,Math.max(0,this.value))}get labelText(){return this.label||`${Math.round(this.percent)}%`}renderStatusLabel(){if(!this.showLabel)return i.nothing;const e=this.status==="success"?"check":this.status==="error"?"close":"";return i.html`<span class="label" part="label">
|
|
3828
|
+
${e?i.html`<wc-icon name=${e}></wc-icon>`:i.nothing}${this.labelText}
|
|
3829
|
+
</span>`}renderLine(){return i.html`<div class="line" part="base">
|
|
3830
|
+
<div
|
|
3831
|
+
class="track"
|
|
3832
|
+
part="track"
|
|
3833
|
+
role="progressbar"
|
|
3834
|
+
aria-valuemin="0"
|
|
3835
|
+
aria-valuemax="100"
|
|
3836
|
+
aria-valuenow=${Math.round(this.percent)}
|
|
3837
|
+
aria-label=${this.labelText}
|
|
3838
|
+
style="height: ${this.strokeWidth}px"
|
|
3839
|
+
>
|
|
3840
|
+
<div class="indicator" part="indicator" style="width: ${this.percent}%"></div>
|
|
3841
|
+
</div>
|
|
3842
|
+
${this.renderStatusLabel()}
|
|
3843
|
+
</div>`}renderCircle(){return i.html`<div class="circle-wrap" part="base">
|
|
3844
|
+
<svg
|
|
3845
|
+
class="circle"
|
|
3846
|
+
viewBox="0 0 72 72"
|
|
3847
|
+
role="progressbar"
|
|
3848
|
+
aria-valuemin="0"
|
|
3849
|
+
aria-valuemax="100"
|
|
3850
|
+
aria-valuenow=${Math.round(this.percent)}
|
|
3851
|
+
aria-label=${this.labelText}
|
|
3852
|
+
>
|
|
3853
|
+
<circle class="track" part="track" cx="36" cy="36" r="${Ze}"></circle>
|
|
3854
|
+
<circle
|
|
3855
|
+
class="indicator"
|
|
3856
|
+
part="indicator"
|
|
3857
|
+
cx="36"
|
|
3858
|
+
cy="36"
|
|
3859
|
+
r="${Ze}"
|
|
3860
|
+
stroke-dasharray="${er}"
|
|
3861
|
+
stroke-dashoffset=${er*(1-this.percent/100)}
|
|
3862
|
+
transform="rotate(-90 36 36)"
|
|
3863
|
+
></circle>
|
|
3864
|
+
</svg>
|
|
3865
|
+
<div class="circle-label">${this.renderStatusLabel()}</div>
|
|
3866
|
+
</div>`}render(){return this.theme==="circle"?this.renderCircle():this.renderLine()}};Bt.styles=[l,ka];let L=Bt;fe([s.property({type:Number})],L.prototype,"value");fe([s.property({reflect:!0})],L.prototype,"theme");fe([s.property({reflect:!0})],L.prototype,"status");fe([s.property({type:Boolean,attribute:"show-label"})],L.prototype,"showLabel");fe([s.property({type:Number,attribute:"stroke-width"})],L.prototype,"strokeWidth");fe([s.property()],L.prototype,"label");customElements.get("wc-progress")||customElements.define("wc-progress",L);const za=i.css`
|
|
3867
|
+
:host {
|
|
3868
|
+
display: block;
|
|
3869
|
+
}
|
|
3870
|
+
|
|
3871
|
+
/* display:flex 类会覆盖 [hidden] 的 UA 样式,显式关闭 */
|
|
3872
|
+
[hidden] {
|
|
3873
|
+
display: none !important;
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
.card {
|
|
3877
|
+
background-color: var(--wc-color-bg-container);
|
|
3878
|
+
border-radius: var(--wc-radius-large);
|
|
3879
|
+
transition: box-shadow var(--wc-duration-base, 200ms) var(--wc-easing-standard);
|
|
3880
|
+
}
|
|
3881
|
+
|
|
3882
|
+
:host([bordered]) .card {
|
|
3883
|
+
border: 1px solid var(--wc-color-border);
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3886
|
+
:host([hoverable]) .card:hover {
|
|
3887
|
+
box-shadow: var(--wc-shadow-2);
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
.header {
|
|
3891
|
+
display: flex;
|
|
3892
|
+
align-items: center;
|
|
3893
|
+
justify-content: space-between;
|
|
3894
|
+
gap: var(--wc-space-2);
|
|
3895
|
+
padding: var(--wc-space-4) var(--wc-space-4) 0;
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
.titles {
|
|
3899
|
+
min-width: 0;
|
|
3900
|
+
}
|
|
3901
|
+
|
|
3902
|
+
.title {
|
|
3903
|
+
color: var(--wc-color-text);
|
|
3904
|
+
font-size: var(--wc-font-size-large);
|
|
3905
|
+
font-weight: var(--wc-font-weight-medium);
|
|
3906
|
+
line-height: 1.5;
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
.subtitle {
|
|
3910
|
+
margin-top: 2px;
|
|
3911
|
+
color: var(--wc-color-text-secondary);
|
|
3912
|
+
font-size: var(--wc-font-size-small);
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
.actions {
|
|
3916
|
+
flex-shrink: 0;
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
.body {
|
|
3920
|
+
padding: var(--wc-space-4);
|
|
3921
|
+
color: var(--wc-color-text);
|
|
3922
|
+
font-size: var(--wc-font-size-medium);
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
.footer {
|
|
3926
|
+
padding: var(--wc-space-3) var(--wc-space-4);
|
|
3927
|
+
border-top: 1px solid var(--wc-color-border);
|
|
3928
|
+
}
|
|
3929
|
+
`;var Ca=Object.defineProperty,ce=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Ca(e,t,r),r};const Rt=class Rt extends i.LitElement{constructor(){super(...arguments),this.title="",this.subtitle="",this.bordered=!0,this.hoverable=!1,this.hasHeaderSlot=!1,this.hasActions=!1,this.hasFooter=!1}onSlotChange(e){const t=e.target,n=t.assignedElements().length>0;t.name==="header"?this.hasHeaderSlot=n:t.name==="actions"?this.hasActions=n:t.name==="footer"&&(this.hasFooter=n)}connectedCallback(){super.connectedCallback(),this.hasHeaderSlot=this.querySelector('[slot="header"]')!==null,this.hasActions=this.querySelector('[slot="actions"]')!==null,this.hasFooter=this.querySelector('[slot="footer"]')!==null}renderHeader(){const e=!!(this.title||this.subtitle||this.hasHeaderSlot||this.hasActions);return i.html`<div class="header" part="header" ?hidden=${!e}>
|
|
3930
|
+
<div class="titles" ?hidden=${this.hasHeaderSlot}>
|
|
3931
|
+
${this.title?i.html`<div class="title" part="title">${this.title}</div>`:i.nothing}
|
|
3932
|
+
${this.subtitle?i.html`<div class="subtitle" part="subtitle">${this.subtitle}</div>`:i.nothing}
|
|
3933
|
+
</div>
|
|
3934
|
+
<slot name="header" @slotchange=${this.onSlotChange} ?hidden=${!this.hasHeaderSlot}></slot>
|
|
3935
|
+
<div class="actions" part="actions" ?hidden=${!this.hasActions}>
|
|
3936
|
+
<slot name="actions" @slotchange=${this.onSlotChange}></slot>
|
|
3937
|
+
</div>
|
|
3938
|
+
</div>`}render(){return i.html`<div class="card" part="base">
|
|
3939
|
+
${this.renderHeader()}
|
|
3940
|
+
<div class="body" part="body"><slot></slot></div>
|
|
3941
|
+
<div class="footer" part="footer" ?hidden=${!this.hasFooter}>
|
|
3942
|
+
<slot name="footer" @slotchange=${this.onSlotChange}></slot>
|
|
3943
|
+
</div>
|
|
3944
|
+
</div>`}};Rt.styles=[l,za];let S=Rt;ce([s.property()],S.prototype,"title");ce([s.property()],S.prototype,"subtitle");ce([s.property({type:Boolean,reflect:!0})],S.prototype,"bordered");ce([s.property({type:Boolean,reflect:!0})],S.prototype,"hoverable");ce([s.state()],S.prototype,"hasHeaderSlot");ce([s.state()],S.prototype,"hasActions");ce([s.state()],S.prototype,"hasFooter");customElements.get("wc-card")||customElements.define("wc-card",S);const Ea=i.css`
|
|
3945
|
+
:host {
|
|
3946
|
+
display: block;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
/* display:flex/grid 类会覆盖 [hidden] 的 UA 样式,显式关闭 */
|
|
3950
|
+
[hidden] {
|
|
3951
|
+
display: none !important;
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
.list {
|
|
3955
|
+
margin: 0;
|
|
3956
|
+
padding: 0;
|
|
3957
|
+
list-style: none;
|
|
3958
|
+
color: var(--wc-color-text);
|
|
3959
|
+
font-size: var(--wc-font-size-medium);
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3962
|
+
/* 通过 ::slotted 为 light-DOM 条目提供统一样式 */
|
|
3963
|
+
::slotted(wc-list-item) {
|
|
3964
|
+
display: block;
|
|
3965
|
+
padding: var(--wc-space-3) var(--wc-space-4);
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
::slotted(wc-list-item:not(:last-child)) {
|
|
3969
|
+
border-bottom: 1px solid var(--wc-color-border);
|
|
3970
|
+
}
|
|
3971
|
+
|
|
3972
|
+
:host([striped]) ::slotted(wc-list-item:nth-child(even)) {
|
|
3973
|
+
background-color: var(--wc-color-bg-container-secondary);
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3976
|
+
:host([hoverable]) ::slotted(wc-list-item:hover) {
|
|
3977
|
+
background-color: var(--wc-color-bg-hover);
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
:host([size='small']) ::slotted(wc-list-item) {
|
|
3981
|
+
padding: var(--wc-space-2) var(--wc-space-4);
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3984
|
+
:host([size='large']) ::slotted(wc-list-item) {
|
|
3985
|
+
padding: var(--wc-space-4) var(--wc-space-4);
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
.empty {
|
|
3989
|
+
padding: var(--wc-space-2) 0;
|
|
3990
|
+
}
|
|
3991
|
+
`;var Sa=Object.defineProperty,Ye=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Sa(e,t,r),r};const Ft=class Ft extends i.LitElement{constructor(){super(...arguments),this.size="medium",this.striped=!1,this.hoverable=!1,this.itemCount=0}onSlotChange(e){const t=e.target;t.name===""&&(this.itemCount=t.assignedElements().length)}connectedCallback(){super.connectedCallback(),this.itemCount=this.querySelectorAll("wc-list-item").length}render(){return i.html`
|
|
3992
|
+
<ul class="list" part="base" role="list" ?hidden=${this.itemCount===0}>
|
|
3993
|
+
<slot @slotchange=${this.onSlotChange}></slot>
|
|
3994
|
+
</ul>
|
|
3995
|
+
<div class="empty" part="empty" ?hidden=${this.itemCount>0}>
|
|
3996
|
+
<slot name="empty" @slotchange=${this.onSlotChange}><wc-empty></wc-empty></slot>
|
|
3997
|
+
</div>
|
|
3998
|
+
`}};Ft.styles=[l,Ea];let Z=Ft;Ye([s.property({reflect:!0})],Z.prototype,"size");Ye([s.property({type:Boolean,reflect:!0})],Z.prototype,"striped");Ye([s.property({type:Boolean,reflect:!0})],Z.prototype,"hoverable");Ye([s.state()],Z.prototype,"itemCount");customElements.get("wc-list")||customElements.define("wc-list",Z);const Vt=class Vt extends i.LitElement{render(){return i.html`<slot></slot>`}};Vt.styles=[l];let Ie=Vt;customElements.get("wc-list-item")||customElements.define("wc-list-item",Ie);const _a=i.css`
|
|
3999
|
+
:host {
|
|
4000
|
+
display: block;
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
[hidden] {
|
|
4004
|
+
display: none !important;
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
.wrapper {
|
|
4008
|
+
position: relative;
|
|
4009
|
+
color: var(--wc-color-text);
|
|
4010
|
+
font-size: var(--wc-font-size-medium);
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
table {
|
|
4014
|
+
width: 100%;
|
|
4015
|
+
border-collapse: collapse;
|
|
4016
|
+
text-align: left;
|
|
4017
|
+
}
|
|
4018
|
+
|
|
4019
|
+
th,
|
|
4020
|
+
td {
|
|
4021
|
+
padding: var(--wc-space-3) var(--wc-space-3);
|
|
4022
|
+
border-bottom: 1px solid var(--wc-color-border);
|
|
4023
|
+
font-weight: normal;
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
th {
|
|
4027
|
+
color: var(--wc-color-text-secondary);
|
|
4028
|
+
font-weight: var(--wc-font-weight-medium);
|
|
4029
|
+
background-color: var(--wc-color-bg-container-secondary);
|
|
4030
|
+
white-space: nowrap;
|
|
4031
|
+
user-select: none;
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
:host([bordered]) th,
|
|
4035
|
+
:host([bordered]) td {
|
|
4036
|
+
border: 1px solid var(--wc-color-border);
|
|
4037
|
+
}
|
|
4038
|
+
|
|
4039
|
+
:host([size='small']) th,
|
|
4040
|
+
:host([size='small']) td {
|
|
4041
|
+
padding: var(--wc-space-2) var(--wc-space-2);
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
:host([size='large']) th,
|
|
4045
|
+
:host([size='large']) td {
|
|
4046
|
+
padding: var(--wc-space-4) var(--wc-space-3);
|
|
4047
|
+
}
|
|
4048
|
+
|
|
4049
|
+
:host([striped]) tbody tr:nth-child(even) td {
|
|
4050
|
+
background-color: var(--wc-color-bg-container-secondary);
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
tbody tr {
|
|
4054
|
+
transition: background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
4055
|
+
}
|
|
4056
|
+
|
|
4057
|
+
tbody tr:hover td {
|
|
4058
|
+
background-color: var(--wc-color-bg-hover);
|
|
4059
|
+
}
|
|
4060
|
+
|
|
4061
|
+
:host([striped]) tbody tr:nth-child(even):hover td {
|
|
4062
|
+
background-color: var(--wc-color-bg-hover);
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
th.sortable {
|
|
4066
|
+
cursor: pointer;
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
th.sortable:hover {
|
|
4070
|
+
color: var(--wc-color-primary);
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
th.sorted {
|
|
4074
|
+
color: var(--wc-color-primary);
|
|
4075
|
+
}
|
|
4076
|
+
|
|
4077
|
+
.th-inner {
|
|
4078
|
+
display: inline-flex;
|
|
4079
|
+
align-items: center;
|
|
4080
|
+
gap: var(--wc-space-1);
|
|
4081
|
+
}
|
|
4082
|
+
|
|
4083
|
+
.sort {
|
|
4084
|
+
display: inline-flex;
|
|
4085
|
+
flex-direction: column;
|
|
4086
|
+
gap: 0;
|
|
4087
|
+
color: var(--wc-color-text-placeholder);
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
.sort wc-icon {
|
|
4091
|
+
display: block;
|
|
4092
|
+
height: 0.5em;
|
|
4093
|
+
pointer-events: none;
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
.sort wc-icon.active {
|
|
4097
|
+
color: var(--wc-color-primary);
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
td[ellipsis] {
|
|
4101
|
+
max-width: 0;
|
|
4102
|
+
overflow: hidden;
|
|
4103
|
+
white-space: nowrap;
|
|
4104
|
+
text-overflow: ellipsis;
|
|
4105
|
+
}
|
|
4106
|
+
|
|
4107
|
+
.align-left {
|
|
4108
|
+
text-align: left;
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
.align-right {
|
|
4112
|
+
text-align: right;
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
.align-center {
|
|
4116
|
+
text-align: center;
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
.empty {
|
|
4120
|
+
padding: var(--wc-space-4) 0;
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
.loading {
|
|
4124
|
+
position: absolute;
|
|
4125
|
+
inset: 0;
|
|
4126
|
+
z-index: var(--wc-z-index-popover, 1);
|
|
4127
|
+
display: flex;
|
|
4128
|
+
align-items: center;
|
|
4129
|
+
justify-content: center;
|
|
4130
|
+
color: var(--wc-color-primary);
|
|
4131
|
+
/* 随容器底色自适应明暗主题 */
|
|
4132
|
+
background-color: color-mix(in srgb, var(--wc-color-bg-container) 70%, transparent);
|
|
4133
|
+
}
|
|
4134
|
+
`;var Oa=Object.defineProperty,Q=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Oa(e,t,r),r};const Ut=class Ut extends i.LitElement{constructor(){super(...arguments),this.columns=[],this.data=[],this.striped=!1,this.bordered=!1,this.size="medium",this.loading=!1,this.sortKey="",this.sortOrder=null,this.onSlotChange=()=>this.requestUpdate()}get displayData(){if(!this.sortKey||!this.sortOrder)return this.data;const e=this.sortOrder==="asc"?1:-1;return[...this.data].sort((t,n)=>{const r=t[this.sortKey],a=n[this.sortKey];return r==null?1:a==null?-1:typeof r=="number"&&typeof a=="number"?(r-a)*e:String(r).localeCompare(String(a),"zh-CN")*e})}onHeaderClick(e){if(!e.sortable)return;const t={"":"asc",asc:"desc",desc:null};this.sortOrder=this.sortKey===e.key?t[this.sortOrder??""]??null:"asc",this.sortKey=this.sortOrder===null?"":e.key,this.dispatchEvent(new CustomEvent("wc-sort",{detail:{key:this.sortKey,order:this.sortOrder},bubbles:!0,composed:!0}))}cellContent(e,t,n){const r=e.render?.(t,n);if(r!=null&&r!=="")return typeof r=="object"?r:String(r);const a=t[e.key];return a==null?"":String(a)}renderHead(){return i.html`<thead part="head">
|
|
4135
|
+
<tr>
|
|
4136
|
+
${this.columns.map(e=>{const t=this.sortKey===e.key&&this.sortOrder!==null;return i.html`<th
|
|
4137
|
+
part="th"
|
|
4138
|
+
scope="col"
|
|
4139
|
+
style=${e.width!=null?`width: ${typeof e.width=="number"?`${e.width}px`:e.width}`:i.nothing}
|
|
4140
|
+
class=${[e.align?`align-${e.align}`:"",e.sortable?"sortable":"",t?"sorted":""].join(" ")||i.nothing}
|
|
4141
|
+
aria-sort=${t?this.sortOrder==="asc"?"ascending":"descending":i.nothing}
|
|
4142
|
+
@click=${()=>this.onHeaderClick(e)}
|
|
4143
|
+
>
|
|
4144
|
+
<div class="th-inner">
|
|
4145
|
+
${e.title}
|
|
4146
|
+
${e.sortable?i.html`<span class="sort" part="sort">
|
|
4147
|
+
<wc-icon
|
|
4148
|
+
class=${this.sortKey===e.key&&this.sortOrder==="asc"?"active":""}
|
|
4149
|
+
name="chevron-up"
|
|
4150
|
+
></wc-icon>
|
|
4151
|
+
<wc-icon
|
|
4152
|
+
class=${this.sortKey===e.key&&this.sortOrder==="desc"?"active":""}
|
|
4153
|
+
name="chevron-down"
|
|
4154
|
+
></wc-icon>
|
|
4155
|
+
</span>`:i.nothing}
|
|
4156
|
+
</div>
|
|
4157
|
+
</th>`})}
|
|
4158
|
+
</tr>
|
|
4159
|
+
</thead>`}render(){const e=this.data.length>0;return i.html`<div class="wrapper" part="wrapper">
|
|
4160
|
+
<table part="table">
|
|
4161
|
+
${this.renderHead()}
|
|
4162
|
+
<tbody part="body" ?hidden=${!e}>
|
|
4163
|
+
${this.displayData.map((t,n)=>i.html`<tr
|
|
4164
|
+
part="row"
|
|
4165
|
+
@click=${()=>this.dispatchEvent(new CustomEvent("wc-row-click",{detail:{row:t,index:n},bubbles:!0,composed:!0}))}
|
|
4166
|
+
>
|
|
4167
|
+
${this.columns.map(r=>i.html`<td
|
|
4168
|
+
part="td"
|
|
4169
|
+
class=${r.align?`align-${r.align}`:i.nothing}
|
|
4170
|
+
?ellipsis=${r.ellipsis===!0}
|
|
4171
|
+
title=${r.ellipsis?String(t[r.key]??""):i.nothing}
|
|
4172
|
+
>
|
|
4173
|
+
${this.cellContent(r,t,n)}
|
|
4174
|
+
</td>`)}
|
|
4175
|
+
</tr>`)}
|
|
4176
|
+
</tbody>
|
|
4177
|
+
</table>
|
|
4178
|
+
<div class="empty" part="empty" ?hidden=${e}>
|
|
4179
|
+
<slot name="empty" @slotchange=${this.onSlotChange}><wc-empty></wc-empty></slot>
|
|
4180
|
+
</div>
|
|
4181
|
+
${this.loading?i.html`<div class="loading" part="loading">
|
|
4182
|
+
<wc-icon name="loader" spin label="加载中"></wc-icon>
|
|
4183
|
+
</div>`:i.nothing}
|
|
4184
|
+
</div>`}};Ut.styles=[l,_a];let x=Ut;Q([s.property({type:Array})],x.prototype,"columns");Q([s.property({type:Array})],x.prototype,"data");Q([s.property({type:Boolean,reflect:!0})],x.prototype,"striped");Q([s.property({type:Boolean,reflect:!0})],x.prototype,"bordered");Q([s.property({reflect:!0})],x.prototype,"size");Q([s.property({type:Boolean,reflect:!0})],x.prototype,"loading");Q([s.state()],x.prototype,"sortKey");Q([s.state()],x.prototype,"sortOrder");customElements.get("wc-table")||customElements.define("wc-table",x);const Pa=i.css`
|
|
4185
|
+
:host {
|
|
4186
|
+
--wc-image-bg: var(--wc-color-bg-container-secondary);
|
|
4187
|
+
--wc-image-radius: var(--wc-radius-medium);
|
|
4188
|
+
--wc-image-mask-bg: rgb(0 0 0 / 75%);
|
|
4189
|
+
--wc-image-tool-bg: rgb(255 255 255 / 16%);
|
|
4190
|
+
--wc-image-tool-bg-hover: rgb(255 255 255 / 28%);
|
|
4191
|
+
--wc-image-tool-color: #fff;
|
|
4192
|
+
display: inline-block;
|
|
4193
|
+
vertical-align: middle;
|
|
4194
|
+
}
|
|
4195
|
+
|
|
4196
|
+
.frame {
|
|
4197
|
+
position: relative;
|
|
4198
|
+
width: var(--wc-image-width, 240px);
|
|
4199
|
+
height: var(--wc-image-height, 160px);
|
|
4200
|
+
overflow: hidden;
|
|
4201
|
+
background: var(--wc-image-bg);
|
|
4202
|
+
}
|
|
4203
|
+
|
|
4204
|
+
:host([shape='rounded']) .frame {
|
|
4205
|
+
border-radius: var(--wc-image-radius);
|
|
4206
|
+
}
|
|
4207
|
+
|
|
4208
|
+
:host([shape='circle']) .frame {
|
|
4209
|
+
border-radius: 50%;
|
|
4210
|
+
}
|
|
4211
|
+
|
|
4212
|
+
.frame img {
|
|
4213
|
+
display: block;
|
|
4214
|
+
width: 100%;
|
|
4215
|
+
height: 100%;
|
|
4216
|
+
}
|
|
4217
|
+
|
|
4218
|
+
/* 点击触发层:仅在开启预览且加载成功时出现 */
|
|
4219
|
+
.trigger {
|
|
4220
|
+
position: absolute;
|
|
4221
|
+
inset: 0;
|
|
4222
|
+
z-index: 1;
|
|
4223
|
+
cursor: zoom-in;
|
|
4224
|
+
}
|
|
4225
|
+
|
|
4226
|
+
.trigger:focus-visible {
|
|
4227
|
+
outline: 2px solid var(--wc-color-primary);
|
|
4228
|
+
outline-offset: -2px;
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
/* 加载中 / 失败占位层 */
|
|
4232
|
+
.layer {
|
|
4233
|
+
position: absolute;
|
|
4234
|
+
inset: 0;
|
|
4235
|
+
z-index: 0;
|
|
4236
|
+
display: flex;
|
|
4237
|
+
flex-direction: column;
|
|
4238
|
+
align-items: center;
|
|
4239
|
+
justify-content: center;
|
|
4240
|
+
gap: var(--wc-space-2);
|
|
4241
|
+
color: var(--wc-color-text-placeholder);
|
|
4242
|
+
font-size: var(--wc-font-size-small);
|
|
4243
|
+
}
|
|
4244
|
+
|
|
4245
|
+
/* 大图预览浮层 */
|
|
4246
|
+
.overlay {
|
|
4247
|
+
position: fixed;
|
|
4248
|
+
inset: 0;
|
|
4249
|
+
z-index: var(--wc-z-index-modal);
|
|
4250
|
+
display: flex;
|
|
4251
|
+
align-items: center;
|
|
4252
|
+
justify-content: center;
|
|
4253
|
+
background: var(--wc-image-mask-bg);
|
|
4254
|
+
animation: wc-image-fade var(--wc-duration-fast) var(--wc-easing-standard);
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4257
|
+
.stage {
|
|
4258
|
+
display: flex;
|
|
4259
|
+
align-items: center;
|
|
4260
|
+
justify-content: center;
|
|
4261
|
+
overflow: hidden;
|
|
4262
|
+
cursor: grab;
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4265
|
+
.stage.dragging {
|
|
4266
|
+
cursor: grabbing;
|
|
4267
|
+
}
|
|
4268
|
+
|
|
4269
|
+
.stage img {
|
|
4270
|
+
max-width: 90vw;
|
|
4271
|
+
max-height: 90vh;
|
|
4272
|
+
user-select: none;
|
|
4273
|
+
transition: transform var(--wc-duration-fast) var(--wc-easing-standard);
|
|
4274
|
+
}
|
|
4275
|
+
|
|
4276
|
+
.stage.dragging img {
|
|
4277
|
+
transition: none;
|
|
4278
|
+
}
|
|
4279
|
+
|
|
4280
|
+
.toolbar {
|
|
4281
|
+
position: absolute;
|
|
4282
|
+
left: 50%;
|
|
4283
|
+
bottom: var(--wc-space-6);
|
|
4284
|
+
transform: translateX(-50%);
|
|
4285
|
+
display: flex;
|
|
4286
|
+
align-items: center;
|
|
4287
|
+
gap: var(--wc-space-1);
|
|
4288
|
+
padding: var(--wc-space-2) var(--wc-space-3);
|
|
4289
|
+
background: var(--wc-image-tool-bg);
|
|
4290
|
+
border-radius: var(--wc-radius-circle);
|
|
4291
|
+
backdrop-filter: blur(4px);
|
|
4292
|
+
}
|
|
4293
|
+
|
|
4294
|
+
.toolbar button {
|
|
4295
|
+
display: flex;
|
|
4296
|
+
align-items: center;
|
|
4297
|
+
justify-content: center;
|
|
4298
|
+
width: 40px;
|
|
4299
|
+
height: 40px;
|
|
4300
|
+
border: none;
|
|
4301
|
+
border-radius: 50%;
|
|
4302
|
+
background: transparent;
|
|
4303
|
+
color: var(--wc-image-tool-color);
|
|
4304
|
+
font-size: var(--wc-font-size-small);
|
|
4305
|
+
cursor: pointer;
|
|
4306
|
+
transition: background var(--wc-duration-fast) var(--wc-easing-standard);
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
.toolbar button:hover {
|
|
4310
|
+
background: var(--wc-image-tool-bg-hover);
|
|
4311
|
+
}
|
|
4312
|
+
|
|
4313
|
+
@keyframes wc-image-fade {
|
|
4314
|
+
from {
|
|
4315
|
+
opacity: 0;
|
|
4316
|
+
}
|
|
4317
|
+
to {
|
|
4318
|
+
opacity: 1;
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
`;var La=Object.defineProperty,p=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&La(e,t,r),r};const Ma=.25,Ia=5,Se=.25,Yt=class Yt extends i.LitElement{constructor(){super(...arguments),this.src="",this.alt="",this.fit="fill",this.position="center",this.shape="square",this.lazy=!1,this.preview=!1,this.previewSrc="",this.fallback="",this.status="loading",this.shouldLoad=!1,this.fallbackFailed=!1,this.previewOpen=!1,this.scale=1,this.rotate=0,this.x=0,this.y=0,this.dragging=!1,this.localize=new v(this),this.overlay=new st(this,{requestClose:()=>this.requestClosePreview("escape")}),this.io=null,this.dragStartX=0,this.dragStartY=0}connectedCallback(){super.connectedCallback(),this.lazy&&typeof IntersectionObserver<"u"?(this.io=new IntersectionObserver(e=>{e.some(t=>t.isIntersecting)&&(this.startLoad(),this.io?.disconnect())}),this.io.observe(this)):this.startLoad(),this.previewOpen&&this.overlay.bind()}disconnectedCallback(){super.disconnectedCallback(),this.io?.disconnect(),this.overlay.unbind()}willUpdate(e){super.willUpdate(e),e.has("src")&&(this.status="loading",this.fallbackFailed=!1)}updated(e){super.updated(e),e.has("previewOpen")&&(this.previewOpen?(this.dispatchEvent(new CustomEvent("wc-preview-open",{bubbles:!0,composed:!0})),this.overlay.bind()):this.overlay.unbind())}startLoad(){this.shouldLoad||(this.shouldLoad=!0)}onImgLoad(){this.status="loaded",this.dispatchEvent(new CustomEvent("wc-load",{detail:{src:this.src},bubbles:!0,composed:!0}))}onImgError(){this.status="error",this.dispatchEvent(new CustomEvent("wc-error",{detail:{src:this.src},bubbles:!0,composed:!0}))}openPreview(){!this.preview||this.status!=="loaded"||(this.resetTransform(),this.previewOpen=!0)}requestClosePreview(e="api"){if(!this.previewOpen)return;this.dispatchEvent(new CustomEvent("wc-preview-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0}))&&(this.previewOpen=!1)}zoomBy(e){const t=Math.round((this.scale+e)*100)/100;this.scale=Math.min(Ia,Math.max(Ma,t))}rotateBy(){this.rotate=(this.rotate+90)%360}resetTransform(){this.scale=1,this.rotate=0,this.x=0,this.y=0}onOverlayWheel(e){e.preventDefault(),this.zoomBy(e.deltaY<0?Se:-Se)}onStagePointerDown(e){e.button===0&&(this.dragging=!0,this.dragStartX=e.clientX-this.x,this.dragStartY=e.clientY-this.y,e.currentTarget.setPointerCapture(e.pointerId))}onStagePointerMove(e){this.dragging&&(this.x=e.clientX-this.dragStartX,this.y=e.clientY-this.dragStartY)}onStagePointerUp(){this.dragging=!1}onTriggerKeydown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.openPreview())}imgStyle(){return`object-fit:${this.fit};object-position:${this.position}`}previewStyle(){return`transform:translate(${this.x}px, ${this.y}px) scale(${this.scale}) rotate(${this.rotate}deg)`}render(){const e=this.previewSrc||this.src;return i.html`
|
|
4322
|
+
<div class="frame" part="base">
|
|
4323
|
+
${this.shouldLoad&&this.status!=="error"?i.html`<img
|
|
4324
|
+
part="image"
|
|
4325
|
+
src=${this.src}
|
|
4326
|
+
alt=${this.alt}
|
|
4327
|
+
style=${this.imgStyle()}
|
|
4328
|
+
@load=${this.onImgLoad}
|
|
4329
|
+
@error=${this.onImgError}
|
|
4330
|
+
/>`:""}
|
|
4331
|
+
${this.status==="error"&&this.fallback&&!this.fallbackFailed?i.html`<img
|
|
4332
|
+
part="image"
|
|
4333
|
+
src=${this.fallback}
|
|
4334
|
+
alt=${this.alt}
|
|
4335
|
+
style=${this.imgStyle()}
|
|
4336
|
+
@error=${()=>this.fallbackFailed=!0}
|
|
4337
|
+
/>`:""}
|
|
4338
|
+
${this.status==="loading"?i.html`<div class="layer">
|
|
4339
|
+
<wc-icon name="loader" spin></wc-icon>
|
|
4340
|
+
</div>`:""}
|
|
4341
|
+
${this.status==="error"&&(!this.fallback||this.fallbackFailed)?i.html`<div class="layer">
|
|
4342
|
+
<wc-icon name="image-off"></wc-icon>
|
|
4343
|
+
<span>${this.localize.term("image.loadError")}</span>
|
|
4344
|
+
</div>`:""}
|
|
4345
|
+
${this.preview&&this.status==="loaded"?i.html`<div
|
|
4346
|
+
class="trigger"
|
|
4347
|
+
role="button"
|
|
4348
|
+
tabindex="0"
|
|
4349
|
+
aria-label=${this.localize.term("image.preview")}
|
|
4350
|
+
@click=${()=>this.openPreview()}
|
|
4351
|
+
@keydown=${this.onTriggerKeydown}
|
|
4352
|
+
></div>`:""}
|
|
4353
|
+
</div>
|
|
4354
|
+
${this.previewOpen?i.html`<div
|
|
4355
|
+
class="overlay"
|
|
4356
|
+
part="overlay"
|
|
4357
|
+
role="dialog"
|
|
4358
|
+
aria-modal="true"
|
|
4359
|
+
aria-label=${this.localize.term("image.preview")}
|
|
4360
|
+
tabindex="-1"
|
|
4361
|
+
@wheel=${this.onOverlayWheel}
|
|
4362
|
+
@click=${t=>{t.target===t.currentTarget&&this.requestClosePreview("overlay")}}
|
|
4363
|
+
>
|
|
4364
|
+
<div
|
|
4365
|
+
class="stage ${this.dragging?"dragging":""}"
|
|
4366
|
+
@pointerdown=${this.onStagePointerDown}
|
|
4367
|
+
@pointermove=${this.onStagePointerMove}
|
|
4368
|
+
@pointerup=${this.onStagePointerUp}
|
|
4369
|
+
@pointercancel=${this.onStagePointerUp}
|
|
4370
|
+
>
|
|
4371
|
+
<img
|
|
4372
|
+
part="preview-image"
|
|
4373
|
+
src=${e}
|
|
4374
|
+
alt=${this.alt}
|
|
4375
|
+
draggable="false"
|
|
4376
|
+
style=${this.previewStyle()}
|
|
4377
|
+
/>
|
|
4378
|
+
</div>
|
|
4379
|
+
<div class="toolbar" part="toolbar">
|
|
4380
|
+
<button
|
|
4381
|
+
type="button"
|
|
4382
|
+
aria-label=${this.localize.term("image.zoomIn")}
|
|
4383
|
+
@click=${()=>this.zoomBy(Se)}
|
|
4384
|
+
>
|
|
4385
|
+
<wc-icon name="zoom-in"></wc-icon>
|
|
4386
|
+
</button>
|
|
4387
|
+
<button
|
|
4388
|
+
type="button"
|
|
4389
|
+
aria-label=${this.localize.term("image.zoomOut")}
|
|
4390
|
+
@click=${()=>this.zoomBy(-Se)}
|
|
4391
|
+
>
|
|
4392
|
+
<wc-icon name="zoom-out"></wc-icon>
|
|
4393
|
+
</button>
|
|
4394
|
+
<button
|
|
4395
|
+
type="button"
|
|
4396
|
+
aria-label=${this.localize.term("image.rotate")}
|
|
4397
|
+
@click=${()=>this.rotateBy()}
|
|
4398
|
+
>
|
|
4399
|
+
<wc-icon name="rotate-cw"></wc-icon>
|
|
4400
|
+
</button>
|
|
4401
|
+
<button
|
|
4402
|
+
type="button"
|
|
4403
|
+
aria-label=${this.localize.term("image.reset")}
|
|
4404
|
+
title=${this.localize.term("image.reset")}
|
|
4405
|
+
@click=${()=>this.resetTransform()}
|
|
4406
|
+
>
|
|
4407
|
+
1:1
|
|
4408
|
+
</button>
|
|
4409
|
+
<button
|
|
4410
|
+
type="button"
|
|
4411
|
+
part="close-button"
|
|
4412
|
+
aria-label=${this.localize.term("image.close")}
|
|
4413
|
+
@click=${()=>this.requestClosePreview("close-btn")}
|
|
4414
|
+
>
|
|
4415
|
+
<wc-icon name="close"></wc-icon>
|
|
4416
|
+
</button>
|
|
4417
|
+
</div>
|
|
4418
|
+
</div>`:""}
|
|
4419
|
+
`}};Yt.styles=[l,Pa];let h=Yt;p([s.property()],h.prototype,"src");p([s.property()],h.prototype,"alt");p([s.property()],h.prototype,"fit");p([s.property()],h.prototype,"position");p([s.property({reflect:!0})],h.prototype,"shape");p([s.property({type:Boolean})],h.prototype,"lazy");p([s.property({type:Boolean,reflect:!0})],h.prototype,"preview");p([s.property({attribute:"preview-src"})],h.prototype,"previewSrc");p([s.property()],h.prototype,"fallback");p([s.state()],h.prototype,"status");p([s.state()],h.prototype,"shouldLoad");p([s.state()],h.prototype,"fallbackFailed");p([s.state()],h.prototype,"previewOpen");p([s.state()],h.prototype,"scale");p([s.state()],h.prototype,"rotate");p([s.state()],h.prototype,"x");p([s.state()],h.prototype,"y");p([s.state()],h.prototype,"dragging");customElements.get("wc-image")||customElements.define("wc-image",h);const Ta=i.css`
|
|
4420
|
+
:host {
|
|
4421
|
+
display: block;
|
|
4422
|
+
|
|
4423
|
+
/* component 层令牌 */
|
|
4424
|
+
--wc-upload-font-size: var(--wc-font-size-medium);
|
|
4425
|
+
--wc-upload-radius: var(--wc-radius-medium);
|
|
4426
|
+
--wc-upload-dragger-bg: var(--wc-color-bg-container);
|
|
4427
|
+
}
|
|
4428
|
+
|
|
4429
|
+
.hidden-input {
|
|
4430
|
+
display: none;
|
|
4431
|
+
}
|
|
4432
|
+
|
|
4433
|
+
/* ---- 默认触发按钮 ---- */
|
|
4434
|
+
.trigger-wrap {
|
|
4435
|
+
display: flex;
|
|
4436
|
+
align-items: center;
|
|
4437
|
+
gap: var(--wc-space-2);
|
|
4438
|
+
}
|
|
4439
|
+
|
|
4440
|
+
.trigger {
|
|
4441
|
+
display: inline-flex;
|
|
4442
|
+
align-items: center;
|
|
4443
|
+
gap: var(--wc-space-1);
|
|
4444
|
+
height: 32px;
|
|
4445
|
+
padding: 0 var(--wc-space-3);
|
|
4446
|
+
font-family: inherit;
|
|
4447
|
+
font-size: var(--wc-upload-font-size);
|
|
4448
|
+
color: var(--wc-color-text);
|
|
4449
|
+
background-color: var(--wc-color-bg-container);
|
|
4450
|
+
border: 1px solid var(--wc-color-border);
|
|
4451
|
+
border-radius: var(--wc-upload-radius);
|
|
4452
|
+
cursor: pointer;
|
|
4453
|
+
user-select: none;
|
|
4454
|
+
transition:
|
|
4455
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
4456
|
+
color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
4457
|
+
}
|
|
4458
|
+
|
|
4459
|
+
.trigger:hover:not(:disabled) {
|
|
4460
|
+
border-color: var(--wc-color-primary);
|
|
4461
|
+
color: var(--wc-color-primary);
|
|
4462
|
+
}
|
|
4463
|
+
|
|
4464
|
+
.trigger:disabled {
|
|
4465
|
+
background-color: var(--wc-color-bg-disabled);
|
|
4466
|
+
border-color: transparent;
|
|
4467
|
+
color: var(--wc-color-text-disabled);
|
|
4468
|
+
cursor: not-allowed;
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4471
|
+
/* ---- 拖拽区域 ---- */
|
|
4472
|
+
.dragger {
|
|
4473
|
+
display: flex;
|
|
4474
|
+
flex-direction: column;
|
|
4475
|
+
align-items: center;
|
|
4476
|
+
justify-content: center;
|
|
4477
|
+
padding: var(--wc-space-6) var(--wc-space-4);
|
|
4478
|
+
background-color: var(--wc-upload-dragger-bg);
|
|
4479
|
+
border: 1px dashed var(--wc-color-border);
|
|
4480
|
+
border-radius: var(--wc-upload-radius);
|
|
4481
|
+
cursor: pointer;
|
|
4482
|
+
user-select: none;
|
|
4483
|
+
text-align: center;
|
|
4484
|
+
transition:
|
|
4485
|
+
border-color var(--wc-duration-fast) var(--wc-easing-standard),
|
|
4486
|
+
background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
4487
|
+
}
|
|
4488
|
+
|
|
4489
|
+
.dragger:hover:not([aria-disabled='true']),
|
|
4490
|
+
.dragger.drag-over {
|
|
4491
|
+
border-color: var(--wc-color-primary);
|
|
4492
|
+
background-color: var(--wc-color-bg-hover);
|
|
4493
|
+
}
|
|
4494
|
+
|
|
4495
|
+
.dragger[aria-disabled='true'] {
|
|
4496
|
+
cursor: not-allowed;
|
|
4497
|
+
color: var(--wc-color-text-disabled);
|
|
4498
|
+
}
|
|
4499
|
+
|
|
4500
|
+
.dragger-icon {
|
|
4501
|
+
font-size: 28px;
|
|
4502
|
+
color: var(--wc-color-text-placeholder);
|
|
4503
|
+
}
|
|
4504
|
+
|
|
4505
|
+
.dragger:hover:not([aria-disabled='true']) .dragger-icon,
|
|
4506
|
+
.dragger.drag-over .dragger-icon {
|
|
4507
|
+
color: var(--wc-color-primary);
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4510
|
+
.dragger-text {
|
|
4511
|
+
margin-top: var(--wc-space-2);
|
|
4512
|
+
font-size: var(--wc-upload-font-size);
|
|
4513
|
+
color: var(--wc-color-text);
|
|
4514
|
+
}
|
|
4515
|
+
|
|
4516
|
+
/* ---- 提示文字(tip 插槽) ---- */
|
|
4517
|
+
.tip {
|
|
4518
|
+
display: inline-block;
|
|
4519
|
+
margin-top: var(--wc-space-1);
|
|
4520
|
+
font-size: var(--wc-font-size-small);
|
|
4521
|
+
color: var(--wc-color-text-placeholder);
|
|
4522
|
+
}
|
|
4523
|
+
|
|
4524
|
+
.tip:empty {
|
|
4525
|
+
display: none;
|
|
4526
|
+
}
|
|
4527
|
+
|
|
4528
|
+
/* ---- 文件列表 ---- */
|
|
4529
|
+
.list {
|
|
4530
|
+
margin: var(--wc-space-2) 0 0;
|
|
4531
|
+
padding: 0;
|
|
4532
|
+
list-style: none;
|
|
4533
|
+
}
|
|
4534
|
+
|
|
4535
|
+
.item {
|
|
4536
|
+
padding: var(--wc-space-1) var(--wc-space-2);
|
|
4537
|
+
border-radius: var(--wc-radius-small);
|
|
4538
|
+
transition: background-color var(--wc-duration-fast) var(--wc-easing-standard);
|
|
4539
|
+
}
|
|
4540
|
+
|
|
4541
|
+
.item:hover {
|
|
4542
|
+
background-color: var(--wc-color-bg-hover);
|
|
4543
|
+
}
|
|
4544
|
+
|
|
4545
|
+
.row {
|
|
4546
|
+
display: flex;
|
|
4547
|
+
align-items: center;
|
|
4548
|
+
gap: var(--wc-space-2);
|
|
4549
|
+
min-height: 24px;
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
.type-icon {
|
|
4553
|
+
font-size: 16px;
|
|
4554
|
+
color: var(--wc-color-text-placeholder);
|
|
4555
|
+
flex-shrink: 0;
|
|
4556
|
+
}
|
|
4557
|
+
|
|
4558
|
+
.item.success .type-icon {
|
|
4559
|
+
color: var(--wc-color-success);
|
|
4560
|
+
}
|
|
4561
|
+
|
|
4562
|
+
.item.error .type-icon {
|
|
4563
|
+
color: var(--wc-color-error);
|
|
4564
|
+
}
|
|
4565
|
+
|
|
4566
|
+
.name {
|
|
4567
|
+
flex: 1;
|
|
4568
|
+
min-width: 0;
|
|
4569
|
+
overflow: hidden;
|
|
4570
|
+
text-overflow: ellipsis;
|
|
4571
|
+
white-space: nowrap;
|
|
4572
|
+
font-size: var(--wc-upload-font-size);
|
|
4573
|
+
color: var(--wc-color-text);
|
|
4574
|
+
}
|
|
4575
|
+
|
|
4576
|
+
.name.link {
|
|
4577
|
+
color: var(--wc-color-primary);
|
|
4578
|
+
cursor: pointer;
|
|
4579
|
+
}
|
|
4580
|
+
|
|
4581
|
+
.name.link:hover {
|
|
4582
|
+
text-decoration: underline;
|
|
4583
|
+
}
|
|
4584
|
+
|
|
4585
|
+
.size,
|
|
4586
|
+
.percent,
|
|
4587
|
+
.fail-text {
|
|
4588
|
+
flex-shrink: 0;
|
|
4589
|
+
font-size: var(--wc-font-size-small);
|
|
4590
|
+
color: var(--wc-color-text-placeholder);
|
|
4591
|
+
}
|
|
4592
|
+
|
|
4593
|
+
.fail-text {
|
|
4594
|
+
color: var(--wc-color-error);
|
|
4595
|
+
}
|
|
4596
|
+
|
|
4597
|
+
.status-icon {
|
|
4598
|
+
font-size: 16px;
|
|
4599
|
+
flex-shrink: 0;
|
|
4600
|
+
}
|
|
4601
|
+
|
|
4602
|
+
.status-icon.success {
|
|
4603
|
+
color: var(--wc-color-success);
|
|
4604
|
+
}
|
|
4605
|
+
|
|
4606
|
+
.status-icon.error {
|
|
4607
|
+
color: var(--wc-color-error);
|
|
4608
|
+
}
|
|
4609
|
+
|
|
4610
|
+
.status-icon.waiting {
|
|
4611
|
+
color: var(--wc-color-text-placeholder);
|
|
4612
|
+
}
|
|
4613
|
+
|
|
4614
|
+
.icon-btn {
|
|
4615
|
+
display: inline-flex;
|
|
4616
|
+
align-items: center;
|
|
4617
|
+
justify-content: center;
|
|
4618
|
+
padding: 0;
|
|
4619
|
+
background: transparent;
|
|
4620
|
+
border: none;
|
|
4621
|
+
cursor: pointer;
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4624
|
+
.remove {
|
|
4625
|
+
display: inline-flex;
|
|
4626
|
+
align-items: center;
|
|
4627
|
+
justify-content: center;
|
|
4628
|
+
width: 16px;
|
|
4629
|
+
height: 16px;
|
|
4630
|
+
padding: 0;
|
|
4631
|
+
background: transparent;
|
|
4632
|
+
border: none;
|
|
4633
|
+
border-radius: var(--wc-radius-circle);
|
|
4634
|
+
color: var(--wc-color-text-placeholder);
|
|
4635
|
+
cursor: pointer;
|
|
4636
|
+
flex-shrink: 0;
|
|
4637
|
+
}
|
|
4638
|
+
|
|
4639
|
+
/* wc-icon 的 :host 自带 text 色,这里让叉号跟随按钮的灰阶 */
|
|
4640
|
+
.remove wc-icon {
|
|
4641
|
+
color: inherit;
|
|
4642
|
+
}
|
|
4643
|
+
|
|
4644
|
+
.remove:hover {
|
|
4645
|
+
color: var(--wc-color-text-secondary);
|
|
4646
|
+
}
|
|
4647
|
+
|
|
4648
|
+
.bar {
|
|
4649
|
+
margin: var(--wc-space-1) 0 0 var(--wc-space-6);
|
|
4650
|
+
}
|
|
4651
|
+
`;var Da=Object.defineProperty,_=(o,e,t,n)=>{for(var r=void 0,a=o.length-1,c;a>=0;a--)(c=o[a])&&(r=c(e,t,r)||r);return r&&Da(e,t,r),r};const Ht=class Ht extends i.LitElement{constructor(){super(...arguments),this.action="",this.name="file",this.accept="",this.multiple=!1,this.max=0,this.draggable=!1,this.autoUpload=!0,this.disabled=!1,this.requestMethod=null,this.files=[],this.dragOver=!1,this.localize=new v(this),this.xhrMap=new Map,this.uidCounter=0}disconnectedCallback(){super.disconnectedCallback();for(const e of this.xhrMap.values())e.abort();this.xhrMap.clear()}submit(){for(const e of this.files)e.status==="waiting"&&this.startUpload(e)}clearFiles(){for(const e of this.xhrMap.values())e.abort();this.xhrMap.clear(),this.files.length&&(this.files=[],this.emitChange())}nextUid(){return this.uidCounter+=1,`wc-upload-file-${this.uidCounter}`}pick(){if(this.disabled)return;this.shadowRoot?.querySelector('input[type="file"]')?.click()}onInputChange(e){const t=e.target;t.files?.length&&this.addFiles(t.files),t.value=""}onDragOver(e){e.preventDefault(),this.disabled||(this.dragOver=!0)}onDragLeave(){this.dragOver=!1}onDrop(e){e.preventDefault(),this.dragOver=!1,!this.disabled&&e.dataTransfer?.files?.length&&this.addFiles(e.dataTransfer.files)}onDraggerKeydown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.pick())}addFiles(e){const t=Array.from(e);if(!t.length)return;let n=t;if(this.max>0){const a=this.max-this.files.length;if(a<t.length){const c=t.slice(Math.max(0,a));this.dispatchEvent(new CustomEvent("wc-exceed",{detail:{files:c,max:this.max},bubbles:!0,composed:!0})),n=t.slice(0,Math.max(0,a))}}if(!n.length)return;const r=n.map(a=>({uid:this.nextUid(),raw:a,name:a.name,size:a.size,percent:0,status:"waiting"}));if(this.files=[...this.files,...r],this.dispatchEvent(new CustomEvent("wc-select",{detail:{files:n},bubbles:!0,composed:!0})),this.emitChange(),this.autoUpload)for(const a of r)this.startUpload(a)}startUpload(e){if(!(this.disabled||e.status==="uploading")){if(!this.action&&!this.requestMethod){console.warn("[wc-upload] 未配置 action 或 requestMethod,文件保持待上传状态");return}this.updateFile(e,{status:"uploading",percent:0}),this.requestMethod?this.requestMethod(e,{onProgress:t=>this.handleProgress(e,t),onSuccess:t=>this.handleSuccess(e,t),onError:t=>this.handleError(e,t)}):this.uploadWithXhr(e)}}uploadWithXhr(e){const t=new XMLHttpRequest;this.xhrMap.set(e.uid,t);const n=new FormData;n.append(this.name,e.raw),t.open("POST",this.action),t.upload.onprogress=r=>{r.lengthComputable&&this.handleProgress(e,r.loaded/r.total*100)},t.onload=()=>{if(t.status>=200&&t.status<300){let r=t.responseText;try{r=JSON.parse(t.responseText)}catch{}this.handleSuccess(e,r)}else this.handleError(e,`HTTP ${t.status}`)},t.onerror=()=>this.handleError(e,"network error"),t.send(n)}handleProgress(e,t){const n=Math.min(100,Math.max(0,Math.round(t)));this.updateFile(e,{percent:n}),this.dispatchEvent(new CustomEvent("wc-progress",{detail:{file:this.snapshot(e),percent:n},bubbles:!0,composed:!0}))}handleSuccess(e,t){this.xhrMap.delete(e.uid);const n=typeof t?.url=="string"?t.url:void 0;this.updateFile(e,{status:"success",percent:100,response:t,url:n}),this.dispatchEvent(new CustomEvent("wc-success",{detail:{file:this.snapshot(e),response:t},bubbles:!0,composed:!0})),this.emitChange()}handleError(e,t){this.xhrMap.delete(e.uid),this.updateFile(e,{status:"error"}),this.dispatchEvent(new CustomEvent("wc-error",{detail:{file:this.snapshot(e),message:t},bubbles:!0,composed:!0})),this.emitChange()}removeFile(e){const t=this.files[e];!t||!this.dispatchEvent(new CustomEvent("wc-remove",{detail:{file:t,index:e},bubbles:!0,composed:!0,cancelable:!0}))||(this.xhrMap.get(t.uid)?.abort(),this.xhrMap.delete(t.uid),this.files=this.files.filter((r,a)=>a!==e),this.emitChange())}retry(e){e.status==="error"&&this.startUpload(e)}onNameClick(e){e.url&&this.dispatchEvent(new CustomEvent("wc-preview",{detail:{file:e},bubbles:!0,composed:!0}))}updateFile(e,t){this.files=this.files.map(n=>n.uid===e.uid?{...n,...t}:n)}snapshot(e){return this.files.find(t=>t.uid===e.uid)??e}emitChange(){this.dispatchEvent(new CustomEvent("wc-change",{detail:{files:[...this.files]},bubbles:!0,composed:!0}))}formatSize(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}render(){return i.html`
|
|
4652
|
+
<div class="upload" part="base">
|
|
4653
|
+
<input
|
|
4654
|
+
class="hidden-input"
|
|
4655
|
+
type="file"
|
|
4656
|
+
accept=${this.accept}
|
|
4657
|
+
?multiple=${this.multiple}
|
|
4658
|
+
?disabled=${this.disabled}
|
|
4659
|
+
@change=${this.onInputChange}
|
|
4660
|
+
/>
|
|
4661
|
+
${this.draggable?i.html`<div
|
|
4662
|
+
class="dragger ${this.dragOver?"drag-over":""}"
|
|
4663
|
+
part="dragger"
|
|
4664
|
+
role="button"
|
|
4665
|
+
tabindex=${this.disabled?-1:0}
|
|
4666
|
+
aria-disabled=${this.disabled}
|
|
4667
|
+
@click=${this.pick}
|
|
4668
|
+
@keydown=${this.onDraggerKeydown}
|
|
4669
|
+
@dragover=${this.onDragOver}
|
|
4670
|
+
@dragleave=${this.onDragLeave}
|
|
4671
|
+
@drop=${this.onDrop}
|
|
4672
|
+
>
|
|
4673
|
+
<wc-icon name="upload" class="dragger-icon"></wc-icon>
|
|
4674
|
+
<span class="dragger-text">${this.localize.term("upload.clickOrDrag")}</span>
|
|
4675
|
+
<span class="tip"><slot name="tip"></slot></span>
|
|
4676
|
+
</div>`:i.html`<div class="trigger-wrap">
|
|
4677
|
+
<button
|
|
4678
|
+
type="button"
|
|
4679
|
+
class="trigger"
|
|
4680
|
+
part="trigger"
|
|
4681
|
+
?disabled=${this.disabled}
|
|
4682
|
+
@click=${this.pick}
|
|
4683
|
+
>
|
|
4684
|
+
<wc-icon name="upload"></wc-icon>
|
|
4685
|
+
<span>${this.localize.term("upload.upload")}</span>
|
|
4686
|
+
</button>
|
|
4687
|
+
<span class="tip"><slot name="tip"></slot></span>
|
|
4688
|
+
</div>`}
|
|
4689
|
+
${this.files.length?i.html`<ul class="list" part="list">
|
|
4690
|
+
${this.files.map((e,t)=>i.html`
|
|
4691
|
+
<li class="item ${e.status}" part="item">
|
|
4692
|
+
<div class="row">
|
|
4693
|
+
<wc-icon name="file" class="type-icon"></wc-icon>
|
|
4694
|
+
<span
|
|
4695
|
+
class="name ${e.url?"link":""}"
|
|
4696
|
+
title=${e.name}
|
|
4697
|
+
role=${e.url?"button":void 0}
|
|
4698
|
+
tabindex=${e.url?0:void 0}
|
|
4699
|
+
@click=${()=>this.onNameClick(e)}
|
|
4700
|
+
@keydown=${n=>{e.url&&(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this.onNameClick(e))}}
|
|
4701
|
+
>${e.name}</span
|
|
4702
|
+
>
|
|
4703
|
+
${e.status==="uploading"?i.html`<span class="percent">${Math.round(e.percent??0)}%</span>`:e.status==="error"?i.html`<span class="fail-text"
|
|
4704
|
+
>${this.localize.term("upload.failed")}</span
|
|
4705
|
+
>`:i.html`<span class="size">${this.formatSize(e.size)}</span>`}
|
|
4706
|
+
${e.status==="success"?i.html`<wc-icon name="check" class="status-icon success"></wc-icon>`:e.status==="error"?i.html`<button
|
|
4707
|
+
type="button"
|
|
4708
|
+
class="icon-btn"
|
|
4709
|
+
title=${this.localize.term("upload.retry")}
|
|
4710
|
+
aria-label=${this.localize.term("upload.retry")}
|
|
4711
|
+
@click=${()=>this.retry(e)}
|
|
4712
|
+
>
|
|
4713
|
+
<wc-icon name="error" class="status-icon error"></wc-icon>
|
|
4714
|
+
</button>`:e.status==="waiting"?i.html`<wc-icon
|
|
4715
|
+
name="loader"
|
|
4716
|
+
spin
|
|
4717
|
+
class="status-icon waiting"
|
|
4718
|
+
></wc-icon>`:""}
|
|
4719
|
+
<button
|
|
4720
|
+
type="button"
|
|
4721
|
+
class="remove"
|
|
4722
|
+
part="remove-button"
|
|
4723
|
+
aria-label=${this.localize.term("upload.remove")}
|
|
4724
|
+
@click=${()=>this.removeFile(t)}
|
|
4725
|
+
>
|
|
4726
|
+
<wc-icon name="close"></wc-icon>
|
|
4727
|
+
</button>
|
|
4728
|
+
</div>
|
|
4729
|
+
${e.status==="uploading"?i.html`<wc-progress
|
|
4730
|
+
class="bar"
|
|
4731
|
+
value=${e.percent??0}
|
|
4732
|
+
stroke-width="4"
|
|
4733
|
+
?show-label=${!1}
|
|
4734
|
+
></wc-progress>`:""}
|
|
4735
|
+
</li>
|
|
4736
|
+
`)}
|
|
4737
|
+
</ul>`:""}
|
|
4738
|
+
</div>
|
|
4739
|
+
`}};Ht.styles=[l,Ta];let w=Ht;_([s.property()],w.prototype,"action");_([s.property()],w.prototype,"name");_([s.property()],w.prototype,"accept");_([s.property({type:Boolean})],w.prototype,"multiple");_([s.property({type:Number})],w.prototype,"max");_([s.property({type:Boolean,reflect:!0})],w.prototype,"draggable");_([s.property({type:Boolean,reflect:!0,attribute:"auto-upload",converter:o=>o==null?!0:o!=="false"})],w.prototype,"autoUpload");_([s.property({type:Boolean,reflect:!0})],w.prototype,"disabled");_([s.property({attribute:!1})],w.prototype,"requestMethod");_([s.state()],w.prototype,"files");_([s.state()],w.prototype,"dragOver");customElements.get("wc-upload")||customElements.define("wc-upload",w);const ur=d("arrow-left",'<path d="M19 12H5"/><path d="m12 19-7-7 7-7"/>'),vr=d("arrow-right",'<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>'),wr=d("calendar",'<rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4"/><path d="M8 2v4"/><path d="M3 10h18"/>'),mr=d("check",'<polyline points="20 6 9 17 4 12"/>'),br=d("chevron-down",'<path d="m6 9 6 6 6-6"/>'),gr=d("chevron-left",'<path d="m15 18-6-6 6-6"/>'),fr=d("chevron-right",'<path d="m9 18 6-6-6-6"/>'),yr=d("chevron-up",'<path d="m18 15-6-6-6 6"/>'),xr=d("close",'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'),kr=d("error",'<circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/>'),$r=d("file",'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>'),zr=d("image-off",'<path d="m2 2 20 20"/><path d="M10.41 10.17a2 2 0 0 1-2.24 2.24"/><path d="M21 15V5a2 2 0 0 0-2-2H7"/><path d="M3.59 3.59A2 2 0 0 0 3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.41-.59"/><path d="m21 15-5-5L5 21"/>'),Cr=d("info",'<circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/>'),Er=d("loader",'<path d="M21 12a9 9 0 1 1-6.219-8.56"/>'),Sr=d("minus",'<path d="M5 12h14"/>'),_r=d("plus",'<path d="M5 12h14"/><path d="M12 5v14"/>'),Or=d("rotate-cw",'<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/>'),Pr=d("search",'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>'),Lr=d("upload",'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>'),Mr=d("warning",'<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>'),Ir=d("zoom-in",'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/><path d="M11 8v6"/><path d="M8 11h6"/>'),Tr=d("zoom-out",'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/><path d="M8 11h6"/>'),Dr=[ur,vr,wr,mr,br,gr,fr,yr,xr,kr,$r,zr,Cr,Er,Sr,_r,Or,Pr,Lr,Mr,Ir,Tr];function ja(){for(const o of Dr)or(o.name,o.svg)}const jr="wc-theme-change",Je="wc-theme";let we="light",pe=null;function Na(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Nr(){return we==="auto"?Na():we}function qa(){return we}function qr(o,e){if(o!=="light"&&o!=="dark"&&o!=="auto")throw new Error(`[wc] 无效主题: "${String(o)}",可选 light | dark | auto`);we=o,typeof localStorage<"u"&&(e?.persist?localStorage.setItem(Je,o):localStorage.removeItem(Je)),Ba(),Qe()}function Aa(){let o=null;typeof localStorage<"u"&&(o=localStorage.getItem(Je)),qr(o==="light"||o==="dark"||o==="auto"?o:"auto")}function Ba(){const o=we==="auto"&&typeof window.matchMedia=="function";o&&!pe?(pe=window.matchMedia("(prefers-color-scheme: dark)"),pe.addEventListener("change",Qe)):!o&&pe&&(pe.removeEventListener("change",Qe),pe=null)}function Qe(){const o=Nr();typeof document<"u"&&(document.documentElement.dataset.theme=o),document.dispatchEvent(new CustomEvent(jr,{detail:{theme:we,effective:o},bubbles:!0,composed:!0}))}const Ra=':root{--wc-color-brand-50: #f2f7ff;--wc-color-brand-100: #d9e8ff;--wc-color-brand-200: #b5d0ff;--wc-color-brand-300: #8cb8ff;--wc-color-brand-400: #5f96f7;--wc-color-brand-500: #0052d9;--wc-color-brand-600: #0045c2;--wc-color-brand-700: #00359e;--wc-color-brand-800: #002a7d;--wc-color-success-light: #e3f9e9;--wc-color-success: #2ba471;--wc-color-success-dark: #1f895c;--wc-color-warning-light: #fdf3e6;--wc-color-warning: #e37318;--wc-color-warning-dark: #c25c0a;--wc-color-error-light: #fdecee;--wc-color-error: #d54941;--wc-color-error-dark: #b5362f;--wc-color-info-light: #f2f7ff;--wc-color-info: #0052d9;--wc-color-info-dark: #0045c2;--wc-color-gray-50: #f5f7fa;--wc-color-gray-100: #e7eaee;--wc-color-gray-200: #d5dbe3;--wc-color-gray-300: #c2c9d4;--wc-color-gray-400: #a6b0bf;--wc-color-gray-500: #8a94a6;--wc-color-gray-600: #6b7687;--wc-color-gray-700: #4b5563;--wc-color-gray-800: #2f3540;--wc-color-gray-900: #1b1f27;--wc-font-family: -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue", arial, "PingFang SC", "Microsoft YaHei", sans-serif;--wc-font-family-mono: ui-monospace, sfmono-regular, "SF Mono", menlo, consolas, "Liberation Mono", monospace;--wc-font-size-xsmall: 12px;--wc-font-size-small: 13px;--wc-font-size-medium: 14px;--wc-font-size-large: 16px;--wc-font-size-xlarge: 20px;--wc-font-size-h1: 24px;--wc-font-size-h2: 20px;--wc-font-size-h3: 18px;--wc-font-weight-normal: 400;--wc-font-weight-medium: 500;--wc-font-weight-semibold: 600;--wc-font-weight-bold: 700;--wc-line-height-base: 1.5;--wc-line-height-compact: 1.25;--wc-space-1: 4px;--wc-space-2: 8px;--wc-space-3: 12px;--wc-space-4: 16px;--wc-space-5: 20px;--wc-space-6: 24px;--wc-space-8: 32px;--wc-space-10: 40px;--wc-space-12: 48px;--wc-radius-none: 0;--wc-radius-small: 3px;--wc-radius-medium: 4px;--wc-radius-large: 8px;--wc-radius-xlarge: 10px;--wc-radius-round: 999px;--wc-radius-circle: 50%;--wc-shadow-1: 0 1px 2px rgb(15 23 42 / 6%), 0 1px 3px rgb(15 23 42 / 10%);--wc-shadow-2: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 12px -2px rgb(15 23 42 / 12%);--wc-shadow-3: 0 4px 8px -2px rgb(15 23 42 / 8%), 0 12px 32px -4px rgb(15 23 42 / 18%);--wc-duration-fast: .15s;--wc-duration-medium: .3s;--wc-duration-slow: 1s;--wc-easing-standard: cubic-bezier(.4, 0, .2, 1);--wc-easing-emphasized: cubic-bezier(.2, 0, 0, 1);--wc-z-index-dropdown: 1000;--wc-z-index-sticky: 1100;--wc-z-index-modal: 1200;--wc-z-index-drawer: 1300;--wc-z-index-message: 1500;--wc-z-index-tooltip: 1600;--wc-color-primary: var(--wc-color-brand-500);--wc-color-primary-hover: var(--wc-color-brand-600);--wc-color-primary-active: var(--wc-color-brand-700);--wc-color-primary-light: var(--wc-color-brand-50);--wc-color-text-anti: #ffffff;--wc-color-success-bg: var(--wc-color-success-light);--wc-color-warning-bg: var(--wc-color-warning-light);--wc-color-error-bg: var(--wc-color-error-light);--wc-color-info-bg: var(--wc-color-info-light);--wc-color-text: var(--wc-color-gray-900);--wc-color-text-secondary: var(--wc-color-gray-600);--wc-color-text-placeholder: var(--wc-color-gray-400);--wc-color-text-disabled: var(--wc-color-gray-500);--wc-color-border: var(--wc-color-gray-200);--wc-color-border-strong: var(--wc-color-gray-500);--wc-color-bg: var(--wc-color-gray-50);--wc-color-bg-container: #ffffff;--wc-color-bg-container-secondary: var(--wc-color-gray-50);--wc-color-bg-hover: var(--wc-color-gray-100);--wc-color-bg-disabled: var(--wc-color-gray-100);--wc-color-mask: rgb(0 0 0 / 60%);--wc-color-overlay-hover: rgb(0 0 0 / 8%);--wc-color-focus-ring: var(--wc-color-brand-300)}[data-theme=dark]{color-scheme:dark;--wc-color-primary: var(--wc-color-brand-300);--wc-color-primary-hover: var(--wc-color-brand-200);--wc-color-primary-active: var(--wc-color-brand-100);--wc-color-primary-light: var(--wc-color-brand-800);--wc-color-text-anti: #1b1f27;--wc-color-success: #4fce8e;--wc-color-success-bg: #103524;--wc-color-warning: #f5a962;--wc-color-warning-bg: #3c2a15;--wc-color-error: #e76f68;--wc-color-error-bg: #442423;--wc-color-info: var(--wc-color-brand-300);--wc-color-info-bg: var(--wc-color-brand-800);--wc-color-text: var(--wc-color-gray-50);--wc-color-text-secondary: var(--wc-color-gray-400);--wc-color-text-placeholder: var(--wc-color-gray-600);--wc-color-text-disabled: var(--wc-color-gray-500);--wc-color-border: var(--wc-color-gray-700);--wc-color-border-strong: var(--wc-color-gray-500);--wc-color-bg: var(--wc-color-gray-900);--wc-color-bg-container: #242832;--wc-color-bg-container-secondary: #2f3540;--wc-color-bg-hover: var(--wc-color-gray-800);--wc-color-bg-disabled: var(--wc-color-gray-700);--wc-color-mask: rgb(0 0 0 / 70%);--wc-color-overlay-hover: rgb(255 255 255 / 12%);--wc-color-focus-ring: var(--wc-color-brand-200);--wc-shadow-1: 0 1px 2px rgb(0 0 0 / 40%), 0 1px 3px rgb(0 0 0 / 30%);--wc-shadow-2: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 12px -2px rgb(0 0 0 / 45%);--wc-shadow-3: 0 4px 8px -2px rgb(0 0 0 / 40%), 0 12px 32px -4px rgb(0 0 0 / 50%)}',Fa="*,*:before,*:after{box-sizing:border-box}*{margin:0}html{-webkit-text-size-adjust:100%;text-size-adjust:100%;tab-size:4}body{font-family:var(--wc-font-family);font-size:var(--wc-font-size-medium);line-height:var(--wc-line-height-base);color:var(--wc-color-text);background-color:var(--wc-color-bg-container);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizelegibility}h1,h2,h3,h4,h5,h6{font-weight:var(--wc-font-weight-semibold);line-height:var(--wc-line-height-compact)}h1{font-size:var(--wc-font-size-h1)}h2{font-size:var(--wc-font-size-h2)}h3{font-size:var(--wc-font-size-h3)}h4{font-size:var(--wc-font-size-large)}h5,h6{font-size:var(--wc-font-size-medium)}ul,ol{padding:0;list-style:none}a{color:var(--wc-color-primary);text-decoration:none;transition:color var(--wc-duration-fast) var(--wc-easing-standard)}a:hover{color:var(--wc-color-primary-hover)}a:active{color:var(--wc-color-primary-active)}a[disabled]{color:var(--wc-color-text-disabled);cursor:not-allowed}img,svg,video,canvas,audio,iframe,embed,object{display:block;max-width:100%}img{border-style:none}button,input,select,textarea{font:inherit;color:inherit;letter-spacing:inherit}button{background:none;border:none;padding:0;cursor:pointer}button:disabled{cursor:not-allowed}input,select,textarea{background-color:transparent;border:none}input::placeholder,textarea::placeholder{color:var(--wc-color-text-placeholder)}textarea{resize:vertical}code,kbd,samp,pre{font-family:var(--wc-font-family-mono);font-size:var(--wc-font-size-small)}table{border-collapse:collapse;border-spacing:0}th{font-weight:var(--wc-font-weight-medium);text-align:inherit}fieldset{border:none;padding:0}hr{border:none;border-top:1px solid var(--wc-color-border)}blockquote,figure,dd,dl{margin:0}:focus-visible{outline:2px solid var(--wc-color-focus-ring);outline-offset:2px}:focus:not(:focus-visible){outline:none}::selection{background:var(--wc-color-primary-light);color:var(--wc-color-text)}";exports.ARROW_INSET=_e;exports.FormAssociatedMixin=M;exports.LANGUAGE_CHANGE_EVENT=Pe;exports.LocalizeController=v;exports.POSITION_GAP=T;exports.THEME_CHANGE_EVENT=jr;exports.WcIcon=$;exports.arrowLeft=ur;exports.arrowRight=vr;exports.baseStyles=l;exports.builtinIcons=Dr;exports.calendar=wr;exports.check=mr;exports.chevronDown=br;exports.chevronLeft=gr;exports.chevronRight=fr;exports.chevronUp=yr;exports.close=xr;exports.computePosition=it;exports.createIcon=d;exports.error=kr;exports.file=$r;exports.getEffectiveTheme=Nr;exports.getIcon=Kr;exports.getIconLibrary=Wr;exports.getLocale=ir;exports.getRegisteredLocales=to;exports.getTerm=nr;exports.getTheme=qa;exports.imageOff=zr;exports.info=Cr;exports.initTheme=Aa;exports.loader=Er;exports.message=Qo;exports.minus=Sr;exports.onIconRegister=tr;exports.plus=_r;exports.registerBuiltinIcons=ja;exports.registerIcon=or;exports.registerIconLibrary=ar;exports.registerLocale=Qr;exports.resetCss=Fa;exports.resolveIcon=sr;exports.resolveLocale=rt;exports.rotateCw=Or;exports.search=Pr;exports.setLocale=eo;exports.setTheme=qr;exports.splitPlacement=Be;exports.tokensCss=Ra;exports.upload=Lr;exports.warning=Mr;exports.wcAvatar=ue;exports.wcBadge=G;exports.wcBreadcrumb=$e;exports.wcBreadcrumbItem=Ve;exports.wcButton=k;exports.wcButtonGroup=Oe;exports.wcCard=S;exports.wcCheckbox=R;exports.wcCol=ve;exports.wcDatePicker=g;exports.wcDialog=P;exports.wcDivider=re;exports.wcDrawer=z;exports.wcEmpty=Me;exports.wcForm=Le;exports.wcFormItem=f;exports.wcImage=h;exports.wcInput=b;exports.wcInputNumber=m;exports.wcList=Z;exports.wcListItem=Ie;exports.wcMessage=K;exports.wcOption=V;exports.wcPagination=E;exports.wcPopconfirm=C;exports.wcProgress=L;exports.wcRadio=te;exports.wcRow=Y;exports.wcSelect=O;exports.wcSlider=D;exports.wcSpace=U;exports.wcSwitch=F;exports.wcTab=X;exports.wcTable=x;exports.wcTabs=ke;exports.wcTag=j;exports.wcText=H;exports.wcTextarea=y;exports.wcTooltip=W;exports.wcUpload=w;exports.zoomIn=Ir;exports.zoomOut=Tr;
|
|
4740
|
+
//# sourceMappingURL=index.cjs.js.map
|