@greypan/web-ui 10.1.0 → 10.1.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/README.CN.md +10 -1
- package/README.md +12 -1
- package/dist/components/autocomplete/index.js +62 -60
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/collapse/index.js +1 -1
- package/dist/components/collapse/index.js.map +1 -1
- package/dist/components/collapse/style.js +1 -1
- package/dist/components/collapse/style.js.map +1 -1
- package/dist/components/context-menu/index.d.ts +16 -0
- package/dist/components/context-menu/index.js +9 -4
- package/dist/components/context-menu/index.js.map +1 -1
- package/dist/components/dialog/index.js +39 -37
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/drawer/index.js +64 -62
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/empty/style.js +1 -1
- package/dist/components/empty/style.js.map +1 -1
- package/dist/components/segmented/index.js +17 -7
- package/dist/components/segmented/index.js.map +1 -1
- package/dist/components/select/index.js +45 -43
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/toast/manager.js +1 -1
- package/dist/components/toast/manager.js.map +1 -1
- package/dist/scrollbars/internal.js +6 -0
- package/dist/scrollbars/internal.js.map +1 -0
- package/dist/scrollbars/style.css +1 -1
- package/dist/shared/menu-portal/menu-portal.js +16 -14
- package/dist/shared/menu-portal/menu-portal.js.map +1 -1
- package/dist/shared/overlay/overlay-root.js +13 -12
- package/dist/shared/overlay/overlay-root.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,27 +4,28 @@ import t from "../../assets/glass.js";
|
|
|
4
4
|
import n from "../../icons/generated/ooui-close.js";
|
|
5
5
|
import { normalizeLiteral as r } from "../../shared/normalize/index.js";
|
|
6
6
|
import "../button/index.js";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import l from "../../
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import h from "
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
7
|
+
import i from "../../scrollbars/internal.js";
|
|
8
|
+
import { dispatchOpenChangeEvent as a } from "../../shared/open-state/index.js";
|
|
9
|
+
import { defineOpenOverlay as o } from "../../shared/overlay/open-overlay.js";
|
|
10
|
+
import { defineScrollLockLease as s } from "../../shared/scroll-lock/scroll-lock.js";
|
|
11
|
+
import { prefersReducedMotion as c } from "../../shared/theme/reduced-motion.js";
|
|
12
|
+
import { UserChangeController as l } from "../../shared/events/user-change.js";
|
|
13
|
+
import u from "../../assets/modal-surface.js";
|
|
14
|
+
import { defineNativeDialogPresence as d } from "../../shared/overlay/native-dialog-presence.js";
|
|
15
|
+
import { ElementHeightController as f } from "../../shared/element-height/index.js";
|
|
16
|
+
import { attachDragGesture as p } from "../../shared/gesture/drag-gesture.js";
|
|
17
|
+
import { dampOverscroll as m } from "../../shared/gesture/physics.js";
|
|
18
|
+
import { defineNestedDrawerLayers as h } from "../../shared/overlay/nested-drawer-layers.js";
|
|
19
|
+
import g from "./style.js";
|
|
20
|
+
import { LitElement as _, html as v, nothing as y, unsafeCSS as b } from "lit";
|
|
21
|
+
import { customElement as x, property as S } from "lit/decorators.js";
|
|
21
22
|
//#region src/components/drawer/index.ts
|
|
22
|
-
var
|
|
23
|
+
var C = [
|
|
23
24
|
"right",
|
|
24
25
|
"left",
|
|
25
26
|
"top",
|
|
26
27
|
"bottom"
|
|
27
|
-
],
|
|
28
|
+
], w = .5, T = 10, E = 500, D = 50, O = 10, k = 120, A = 10, j = [
|
|
28
29
|
"button",
|
|
29
30
|
"input",
|
|
30
31
|
"select",
|
|
@@ -50,7 +51,7 @@ var S = [
|
|
|
50
51
|
"[role=\"combobox\"]",
|
|
51
52
|
"[role=\"slider\"]",
|
|
52
53
|
"[role=\"spinbutton\"]"
|
|
53
|
-
].join(","),
|
|
54
|
+
].join(","), M = 180, N = 420, P = "cubic-bezier(0.32, 0.72, 0, 1)", F = "cubic-bezier(0.22, 1.3, 0.36, 1)", I = 1, L = 80;
|
|
54
55
|
if (typeof CSS < "u" && "registerProperty" in CSS) {
|
|
55
56
|
try {
|
|
56
57
|
CSS.registerProperty({
|
|
@@ -85,16 +86,16 @@ if (typeof CSS < "u" && "registerProperty" in CSS) {
|
|
|
85
86
|
});
|
|
86
87
|
} catch {}
|
|
87
88
|
}
|
|
88
|
-
var
|
|
89
|
+
var R = class extends _ {
|
|
89
90
|
constructor(...e) {
|
|
90
|
-
super(...e), this.open = !1, this.noScrollLock = !1, this.noBackdropClose = !1, this.controlled = !1, this._placement = "right", this.heading = "", this.closable = !1, this.headless = !1, this.dialogLabel = "", this.draggable = !1, this._hasHeaderSlot = !1, this._hasFooterSlot = !1, this._userOpenChange = new
|
|
91
|
+
super(...e), this.open = !1, this.noScrollLock = !1, this.noBackdropClose = !1, this.controlled = !1, this._placement = "right", this.heading = "", this.closable = !1, this.headless = !1, this.dialogLabel = "", this.draggable = !1, this._hasHeaderSlot = !1, this._hasFooterSlot = !1, this._userOpenChange = new l(), this._headerHeight = new f(this, ".wui-drawer-header", (e) => this._setAvoidance("--wui-internal-drawer-header-inset", e)), this._footerHeight = new f(this, ".wui-drawer-footer", (e) => this._setAvoidance("--wui-internal-drawer-footer-inset", e)), this._scrollLock = s().make(), this._presence = d().make({
|
|
91
92
|
getDialog: () => this.dialog,
|
|
92
93
|
isConnected: () => this.isConnected,
|
|
93
94
|
isOpen: () => this.open
|
|
94
|
-
}), this._nestedLayers =
|
|
95
|
+
}), this._nestedLayers = h().make({
|
|
95
96
|
getDialog: () => this.dialog,
|
|
96
97
|
getPlacement: () => this._placement
|
|
97
|
-
}), this._overlay =
|
|
98
|
+
}), this._overlay = o().make({
|
|
98
99
|
requestClose: () => this._closeFromUser(),
|
|
99
100
|
isConnected: () => this.isConnected
|
|
100
101
|
}), this._handle = null, this._dragGesture = null, this._dragInitialOffset = 0, this._dragOffset = 0, this._cancelBaseline = 0, this._lastAxisPos = 0, this._swipeIntentDisp = -1, this._swipeCancelled = !1, this._settleFinish = null, this._dragAwaitWriteback = !1, this._handleDragWritebackTimeout = () => {
|
|
@@ -117,9 +118,10 @@ var L = class extends g {
|
|
|
117
118
|
}
|
|
118
119
|
static {
|
|
119
120
|
this.styles = [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
b(t),
|
|
122
|
+
b(u),
|
|
123
|
+
b(i),
|
|
124
|
+
b(g)
|
|
123
125
|
];
|
|
124
126
|
}
|
|
125
127
|
get placement() {
|
|
@@ -127,7 +129,7 @@ var L = class extends g {
|
|
|
127
129
|
}
|
|
128
130
|
set placement(e) {
|
|
129
131
|
let t = this._placement;
|
|
130
|
-
this._placement = r(e,
|
|
132
|
+
this._placement = r(e, C, "right"), this.requestUpdate("placement", t);
|
|
131
133
|
}
|
|
132
134
|
get dialog() {
|
|
133
135
|
return this.shadowRoot?.querySelector("dialog") ?? null;
|
|
@@ -151,7 +153,7 @@ var L = class extends g {
|
|
|
151
153
|
return e ? this._dragAxis === "x" ? e.offsetWidth : e.offsetHeight : 0;
|
|
152
154
|
}
|
|
153
155
|
_dragCloseThreshold(e) {
|
|
154
|
-
return Math.max(e *
|
|
156
|
+
return Math.max(e * w, T);
|
|
155
157
|
}
|
|
156
158
|
_readDrawerInset(e) {
|
|
157
159
|
let t = getComputedStyle(e).getPropertyValue("--wui-internal-drawer-inset"), n = Number.parseFloat(t);
|
|
@@ -176,7 +178,7 @@ var L = class extends g {
|
|
|
176
178
|
}
|
|
177
179
|
_isInteractivePath(e) {
|
|
178
180
|
let t = typeof e.composedPath == "function" ? e.composedPath() : [e.target];
|
|
179
|
-
for (let e of t) if (e instanceof Element && e.matches(
|
|
181
|
+
for (let e of t) if (e instanceof Element && e.matches(j)) return !0;
|
|
180
182
|
return !1;
|
|
181
183
|
}
|
|
182
184
|
_handleDragPointerDown(e) {
|
|
@@ -186,18 +188,18 @@ var L = class extends g {
|
|
|
186
188
|
let n = getComputedStyle(t).transform, r = n && n !== "none" && typeof DOMMatrixReadOnly == "function" ? new DOMMatrixReadOnly(n)[this._dragAxis === "x" ? "m41" : "m42"] : 0;
|
|
187
189
|
this._abortSettle(), this._cancelDragAwait(), this._dragInitialOffset = r * this._dragCloseSign, this._dragOffset = this._dragInitialOffset;
|
|
188
190
|
let i = this._dragAxis === "x" ? e.clientX : e.clientY;
|
|
189
|
-
this._cancelBaseline = i, this._lastAxisPos = i, this._swipeIntentDisp = -1, this._swipeCancelled = !1, t.classList.add("is-dragging"), this._applyDragOffset(t, this._dragOffset), this._dragGesture =
|
|
191
|
+
this._cancelBaseline = i, this._lastAxisPos = i, this._swipeIntentDisp = -1, this._swipeCancelled = !1, t.classList.add("is-dragging"), this._applyDragOffset(t, this._dragOffset), this._dragGesture = p(e, {
|
|
190
192
|
axis: this._dragAxis,
|
|
191
193
|
calibrateOnFirstMove: !0,
|
|
192
194
|
onMove: (e) => {
|
|
193
195
|
let n = (this._dragAxis === "x" ? e.deltaX : e.deltaY) * this._dragCloseSign;
|
|
194
|
-
this._dragOffset = this._dragInitialOffset +
|
|
196
|
+
this._dragOffset = this._dragInitialOffset + m(n), this._trackSwipeCancel(this._dragAxis === "x" ? e.clientX : e.clientY, n);
|
|
195
197
|
let r = this._measureDragSize(), i = this._dragOffset - this._dragInitialOffset;
|
|
196
198
|
t.classList.toggle("is-drag-close", i > this._dragCloseThreshold(r)), this._applyDragOffset(t, this._dragOffset);
|
|
197
199
|
},
|
|
198
200
|
onEnd: (e) => {
|
|
199
201
|
this._dragGesture = null, this._syncDragInert(), t.classList.remove("is-dragging", "is-drag-close");
|
|
200
|
-
let n = this._measureDragSize(), r = (this._dragAxis === "x" ? e.velocityX : e.velocityY) * this._dragCloseSign, i = this._dragOffset - this._dragInitialOffset, a = e.duration > 0 ? i / Math.max(e.duration,
|
|
202
|
+
let n = this._measureDragSize(), r = (this._dragAxis === "x" ? e.velocityX : e.velocityY) * this._dragCloseSign, i = this._dragOffset - this._dragInitialOffset, a = e.duration > 0 ? i / Math.max(e.duration, D) * 1e3 : 0, o = i > 0 && a >= E && !this._swipeCancelled;
|
|
201
203
|
i > this._dragCloseThreshold(n) || o ? this._settleToClose(t, r) : this._settleRebound(t, r, this._dragOffset);
|
|
202
204
|
},
|
|
203
205
|
onCancel: () => {
|
|
@@ -212,7 +214,7 @@ var L = class extends g {
|
|
|
212
214
|
return;
|
|
213
215
|
}
|
|
214
216
|
let r = (e - this._cancelBaseline) * this._dragCloseSign;
|
|
215
|
-
r > this._dragCloseThreshold(this._measureDragSize()) ? this._swipeCancelled = !1 : this._swipeIntentDisp - r >=
|
|
217
|
+
r > this._dragCloseThreshold(this._measureDragSize()) ? this._swipeCancelled = !1 : this._swipeIntentDisp - r >= O && (this._swipeCancelled = !0);
|
|
216
218
|
}
|
|
217
219
|
_cancelActiveDrag() {
|
|
218
220
|
if (!this._isDragging()) return;
|
|
@@ -235,31 +237,31 @@ var L = class extends g {
|
|
|
235
237
|
let r = this._dragCloseDistance(e), i = () => {
|
|
236
238
|
this.controlled ? this._applyDragOffset(e, r) : (e.classList.remove("is-visible"), this._clearDragStyles(e)), this._closeFromDrag();
|
|
237
239
|
};
|
|
238
|
-
if (
|
|
240
|
+
if (c(this) || Math.abs(r - n) < 1) {
|
|
239
241
|
e.classList.remove("is-dragging"), i();
|
|
240
242
|
return;
|
|
241
243
|
}
|
|
242
|
-
this._startSettle(e, r, 0, this._settleDuration(Math.abs(r - n), t),
|
|
244
|
+
this._startSettle(e, r, 0, this._settleDuration(Math.abs(r - n), t), P, i);
|
|
243
245
|
}
|
|
244
246
|
_settleRebound(e, t, n) {
|
|
245
247
|
this._dragOffset = 0;
|
|
246
248
|
let r = () => {
|
|
247
249
|
this._clearDragStyles(e);
|
|
248
250
|
};
|
|
249
|
-
if (
|
|
251
|
+
if (c(this) || Math.abs(n) < 1) {
|
|
250
252
|
e.classList.remove("is-dragging"), r();
|
|
251
253
|
return;
|
|
252
254
|
}
|
|
253
|
-
this._startSettle(e, 0, 1, this._settleDuration(Math.abs(n), t),
|
|
255
|
+
this._startSettle(e, 0, 1, this._settleDuration(Math.abs(n), t), F, r);
|
|
254
256
|
}
|
|
255
257
|
_settleDuration(e, t) {
|
|
256
|
-
let n = e / Math.max(Math.abs(t),
|
|
257
|
-
return Math.min(
|
|
258
|
+
let n = e / Math.max(Math.abs(t), I) * 1e3;
|
|
259
|
+
return Math.min(N, Math.max(M, n));
|
|
258
260
|
}
|
|
259
261
|
_startSettle(e, t, n, r, i, a) {
|
|
260
262
|
this._abortSettle();
|
|
261
263
|
let o = this._dragCloseSign;
|
|
262
|
-
e.style.setProperty("--wui-internal-settle-duration", `${r}ms`), e.style.setProperty("--wui-internal-settle-easing", i), e.style.transform = this._dragAxis === "x" ? `translateX(${t * o}px)` : `translateY(${t * o}px)`, e.style.setProperty("--wui-internal-drag-backdrop-opacity", String(n)), e.classList.add("is-settling"), e.classList.remove("is-dragging"), this._settleFinish = a, this._settleTimer = setTimeout(() => this._finishSettle(), r +
|
|
264
|
+
e.style.setProperty("--wui-internal-settle-duration", `${r}ms`), e.style.setProperty("--wui-internal-settle-easing", i), e.style.transform = this._dragAxis === "x" ? `translateX(${t * o}px)` : `translateY(${t * o}px)`, e.style.setProperty("--wui-internal-drag-backdrop-opacity", String(n)), e.classList.add("is-settling"), e.classList.remove("is-dragging"), this._settleFinish = a, this._settleTimer = setTimeout(() => this._finishSettle(), r + L);
|
|
263
265
|
}
|
|
264
266
|
_finishSettle() {
|
|
265
267
|
let e = this._settleFinish;
|
|
@@ -271,7 +273,7 @@ var L = class extends g {
|
|
|
271
273
|
e && (e.classList.remove("is-settling"), e.style.removeProperty("--wui-internal-settle-duration"), e.style.removeProperty("--wui-internal-settle-easing"));
|
|
272
274
|
}
|
|
273
275
|
_closeFromDrag() {
|
|
274
|
-
this._closeFromUser(), this.controlled && (this._dragAwaitWriteback = !0, this._dragRequestTimer = setTimeout(this._handleDragWritebackTimeout,
|
|
276
|
+
this._closeFromUser(), this.controlled && (this._dragAwaitWriteback = !0, this._dragRequestTimer = setTimeout(this._handleDragWritebackTimeout, k));
|
|
275
277
|
}
|
|
276
278
|
connectedCallback() {
|
|
277
279
|
super.connectedCallback(), this._resyncSlotPresence(), this._presence.reconcile(), this.open && this._nestedLayers.register(), this._syncScrollLock(), this._reclaimIfOpen();
|
|
@@ -380,23 +382,23 @@ var L = class extends g {
|
|
|
380
382
|
handleBackdropClick(e) {
|
|
381
383
|
if (e.target !== e.currentTarget || this.noBackdropClose || this._isDragging() || e.detail === 0) return;
|
|
382
384
|
let t = this._backdropPress;
|
|
383
|
-
this._backdropPress = null, t && t.onMask && (Math.hypot(e.clientX - t.x, e.clientY - t.y) >
|
|
385
|
+
this._backdropPress = null, t && t.onMask && (Math.hypot(e.clientX - t.x, e.clientY - t.y) > A || this._closeFromUser());
|
|
384
386
|
}
|
|
385
387
|
emitOpenChange(e = this.open) {
|
|
386
|
-
|
|
388
|
+
a(this, e);
|
|
387
389
|
}
|
|
388
390
|
_syncScrollLock(e = this.open) {
|
|
389
391
|
this._scrollLock.sync(e && !this.noScrollLock);
|
|
390
392
|
}
|
|
391
393
|
render() {
|
|
392
|
-
let e = this._hasHeaderSlot || !!this.heading, t = this.dialogLabel.trim(), r = !t && !this.headless && e ? "wui-drawer-heading" :
|
|
393
|
-
${i ?
|
|
394
|
+
let e = this._hasHeaderSlot || !!this.heading, t = this.dialogLabel.trim(), r = !t && !this.headless && e ? "wui-drawer-heading" : y, i = this.placement === "top" || this.placement === "bottom", a = this.draggable ? v`
|
|
395
|
+
${i ? v`<div class="wui-drawer-drag-edge" @pointerdown=${this._handleDragPointerDown}></div>` : y}
|
|
394
396
|
<div class="wui-drawer-drag-zone" @pointerdown=${this._handleDragPointerDown}></div>
|
|
395
397
|
<div class="wui-drawer-drag-bar"></div>
|
|
396
|
-
` :
|
|
397
|
-
return
|
|
398
|
+
` : y;
|
|
399
|
+
return v`
|
|
398
400
|
<dialog
|
|
399
|
-
aria-label=${t ||
|
|
401
|
+
aria-label=${t || y}
|
|
400
402
|
aria-labelledby=${r}
|
|
401
403
|
@cancel=${this.handleCancel}
|
|
402
404
|
@close=${this.handleNativeClose}
|
|
@@ -405,7 +407,7 @@ var L = class extends g {
|
|
|
405
407
|
@keydown=${this.handleKeydown}
|
|
406
408
|
@transitionend=${this.handleTransitionEnd}
|
|
407
409
|
>
|
|
408
|
-
${this.headless ?
|
|
410
|
+
${this.headless ? v`<slot></slot>${a}` : v`
|
|
409
411
|
<div class="wui-drawer-body wui-glass">
|
|
410
412
|
<div
|
|
411
413
|
class="wui-drawer-header"
|
|
@@ -414,10 +416,10 @@ var L = class extends g {
|
|
|
414
416
|
@pointerdown=${this._handleSectionDragPointerDown}
|
|
415
417
|
>
|
|
416
418
|
<slot name="header" @slotchange=${this.handleHeaderSlotChange}>
|
|
417
|
-
${this.heading ?
|
|
419
|
+
${this.heading ? v`<span class="wui-drawer-heading">${this.heading}</span>` : y}
|
|
418
420
|
</slot>
|
|
419
421
|
</div>
|
|
420
|
-
<div class="wui-drawer-content">
|
|
422
|
+
<div class="wui-drawer-content wui-scroll">
|
|
421
423
|
<slot></slot>
|
|
422
424
|
</div>
|
|
423
425
|
<div
|
|
@@ -428,7 +430,7 @@ var L = class extends g {
|
|
|
428
430
|
<slot name="footer" @slotchange=${this.handleFooterSlotChange}></slot>
|
|
429
431
|
</div>
|
|
430
432
|
</div>
|
|
431
|
-
${this.closable ?
|
|
433
|
+
${this.closable ? v`
|
|
432
434
|
<web-ui-button
|
|
433
435
|
class="wui-drawer-close"
|
|
434
436
|
@click=${this._closeFromUser}
|
|
@@ -439,44 +441,44 @@ var L = class extends g {
|
|
|
439
441
|
>
|
|
440
442
|
<web-ui-icon size="14" .icon=${n}></web-ui-icon>
|
|
441
443
|
</web-ui-button>
|
|
442
|
-
` :
|
|
444
|
+
` : y}
|
|
443
445
|
${a}
|
|
444
446
|
`}
|
|
445
447
|
</dialog>
|
|
446
448
|
`;
|
|
447
449
|
}
|
|
448
450
|
};
|
|
449
|
-
e([
|
|
451
|
+
e([S({
|
|
450
452
|
type: Boolean,
|
|
451
453
|
reflect: !0
|
|
452
|
-
})],
|
|
454
|
+
})], R.prototype, "open", void 0), e([S({
|
|
453
455
|
type: Boolean,
|
|
454
456
|
reflect: !0,
|
|
455
457
|
attribute: "no-scroll-lock"
|
|
456
|
-
})],
|
|
458
|
+
})], R.prototype, "noScrollLock", void 0), e([S({
|
|
457
459
|
type: Boolean,
|
|
458
460
|
reflect: !0,
|
|
459
461
|
attribute: "no-backdrop-close"
|
|
460
|
-
})],
|
|
462
|
+
})], R.prototype, "noBackdropClose", void 0), e([S({
|
|
461
463
|
type: Boolean,
|
|
462
464
|
reflect: !0
|
|
463
|
-
})],
|
|
465
|
+
})], R.prototype, "controlled", void 0), e([S({
|
|
464
466
|
type: String,
|
|
465
467
|
reflect: !0
|
|
466
|
-
})],
|
|
468
|
+
})], R.prototype, "placement", null), e([S({ type: String })], R.prototype, "heading", void 0), e([S({
|
|
467
469
|
type: Boolean,
|
|
468
470
|
reflect: !0
|
|
469
|
-
})],
|
|
471
|
+
})], R.prototype, "closable", void 0), e([S({
|
|
470
472
|
type: Boolean,
|
|
471
473
|
reflect: !0
|
|
472
|
-
})],
|
|
474
|
+
})], R.prototype, "headless", void 0), e([S({
|
|
473
475
|
type: String,
|
|
474
476
|
attribute: "dialog-label"
|
|
475
|
-
})],
|
|
477
|
+
})], R.prototype, "dialogLabel", void 0), e([S({
|
|
476
478
|
type: Boolean,
|
|
477
479
|
reflect: !0
|
|
478
|
-
})],
|
|
480
|
+
})], R.prototype, "draggable", void 0), R = e([x("web-ui-drawer")], R);
|
|
479
481
|
//#endregion
|
|
480
|
-
export {
|
|
482
|
+
export { R as WebUiDrawer };
|
|
481
483
|
|
|
482
484
|
//# sourceMappingURL=index.js.map
|