@greypan/web-ui 6.3.1 → 7.0.0
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 +145 -42
- package/README.md +156 -53
- package/dist/_virtual/{_@oxc-project_runtime@0.146.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/decorate.js +1 -1
- package/dist/assets/glass.js +1 -1
- package/dist/assets/glass.js.map +1 -1
- package/dist/assets/menu-portal.js +1 -1
- package/dist/assets/menu-portal.js.map +1 -1
- package/dist/assets/overlay-motion.js +1 -1
- package/dist/assets/overlay-motion.js.map +1 -1
- package/dist/assets/selection-control.js +6 -0
- package/dist/assets/selection-control.js.map +1 -0
- package/dist/assets/toast-containers.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +2 -0
- package/dist/components/autocomplete/index.js +22 -23
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/autocomplete/style.js +1 -1
- package/dist/components/autocomplete/style.js.map +1 -1
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/back-top/index.js +1 -1
- package/dist/components/badge/index.js +1 -1
- package/dist/components/badge/style.js.map +1 -1
- package/dist/components/button/index.js +1 -1
- package/dist/components/button/style.js.map +1 -1
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/checkbox/index.d.ts +9 -2
- package/dist/components/checkbox/index.js +52 -28
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox/style.js +1 -1
- package/dist/components/checkbox/style.js.map +1 -1
- package/dist/components/checkbox-group/index.d.ts +3 -0
- package/dist/components/checkbox-group/index.js +26 -15
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/checkbox-group/style.js +1 -1
- package/dist/components/checkbox-group/style.js.map +1 -1
- package/dist/components/collapse/index.js +3 -3
- package/dist/components/collapse/index.js.map +1 -1
- package/dist/components/context-menu/index.d.ts +10 -0
- package/dist/components/context-menu/index.js +53 -39
- package/dist/components/context-menu/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +6 -0
- package/dist/components/dialog/index.js +46 -21
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/dialog/style.js +1 -1
- package/dist/components/dialog/style.js.map +1 -1
- package/dist/components/drawer/index.d.ts +22 -4
- package/dist/components/drawer/index.js +135 -107
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/drawer/style.js +1 -1
- package/dist/components/drawer/style.js.map +1 -1
- package/dist/components/dropdown/index.d.ts +21 -1
- package/dist/components/dropdown/index.js +78 -55
- package/dist/components/dropdown/index.js.map +1 -1
- package/dist/components/dropdown-divider/index.js +1 -1
- package/dist/components/dropdown-header/index.js +1 -1
- package/dist/components/dropdown-item/index.js +1 -1
- package/dist/components/empty/index.js +1 -1
- package/dist/components/icon/index.js +1 -1
- package/dist/components/icon/style.js +1 -1
- package/dist/components/icon/style.js.map +1 -1
- package/dist/components/image-preview/index.js +89 -69
- package/dist/components/image-preview/index.js.map +1 -1
- package/dist/components/image-preview/style.js +1 -1
- package/dist/components/image-preview/style.js.map +1 -1
- package/dist/components/index.js +29 -29
- package/dist/components/input/index.js +4 -4
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/style.js.map +1 -1
- package/dist/components/input-number/index.js +2 -2
- package/dist/components/input-number/index.js.map +1 -1
- package/dist/components/layout/index.js +3 -3
- package/dist/components/layout/index.js.map +1 -1
- package/dist/components/layout/style.js +1 -1
- package/dist/components/layout/style.js.map +1 -1
- package/dist/components/option/index.js +1 -1
- package/dist/components/popover/index.d.ts +8 -2
- package/dist/components/popover/index.js +48 -53
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/radio/index.d.ts +1 -1
- package/dist/components/radio/index.js +16 -15
- package/dist/components/radio/index.js.map +1 -1
- package/dist/components/radio/style.js +1 -1
- package/dist/components/radio/style.js.map +1 -1
- package/dist/components/radio-group/index.d.ts +3 -0
- package/dist/components/radio-group/index.js +26 -15
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/radio-group/style.js +1 -1
- package/dist/components/radio-group/style.js.map +1 -1
- package/dist/components/segmented/index.js +1 -1
- package/dist/components/segmented/style.js +1 -1
- package/dist/components/segmented/style.js.map +1 -1
- package/dist/components/segmented-trigger/index.js +1 -1
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +23 -22
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/select/style.js +1 -1
- package/dist/components/select/style.js.map +1 -1
- package/dist/components/slider/index.js +1 -1
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/style.js +1 -1
- package/dist/components/slider/style.js.map +1 -1
- package/dist/components/spinner/index.js +2 -2
- package/dist/components/spinner/index.js.map +1 -1
- package/dist/components/spinner/style.js +1 -1
- package/dist/components/spinner/style.js.map +1 -1
- package/dist/components/svg-draw-lines/index.d.ts +13 -2
- package/dist/components/svg-draw-lines/index.js +45 -32
- package/dist/components/svg-draw-lines/index.js.map +1 -1
- package/dist/components/switch/index.js +2 -2
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/style.js +1 -1
- package/dist/components/switch/style.js.map +1 -1
- package/dist/components/textarea/index.js +5 -5
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/textarea/style.js.map +1 -1
- package/dist/components/theme/index.d.ts +17 -0
- package/dist/components/theme/index.js +181 -21
- package/dist/components/theme/index.js.map +1 -1
- package/dist/components/theme/style.js +1 -1
- package/dist/components/theme/style.js.map +1 -1
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/manager.d.ts +1 -3
- package/dist/components/toast/manager.js +92 -49
- package/dist/components/toast/manager.js.map +1 -1
- package/dist/components/toast/style.js +1 -1
- package/dist/components/toast/style.js.map +1 -1
- package/dist/components/toast/toast.d.ts +37 -0
- package/dist/components/toast/toast.js +62 -9
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toast/types.d.ts +0 -4
- package/dist/components/tooltip/index.d.ts +6 -1
- package/dist/components/tooltip/index.js +17 -15
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/shared/form-association/index.js +1 -1
- package/dist/shared/form-association/index.js.map +1 -1
- package/dist/shared/gesture/drag-gesture.js +66 -64
- package/dist/shared/gesture/drag-gesture.js.map +1 -1
- package/dist/shared/gesture/physics.js +7 -29
- package/dist/shared/gesture/physics.js.map +1 -1
- package/dist/shared/menu-behavior/index.js +3 -4
- package/dist/shared/menu-behavior/index.js.map +1 -1
- package/dist/shared/menu-portal/menu-tree.js +1 -1
- package/dist/shared/menu-portal/menu-tree.js.map +1 -1
- package/dist/shared/option-portal/combobox-shell.js +7 -8
- package/dist/shared/option-portal/combobox-shell.js.map +1 -1
- package/dist/shared/overlay/anchored-panel.js +36 -31
- package/dist/shared/overlay/anchored-panel.js.map +1 -1
- package/dist/shared/overlay/native-dialog-presence.js +18 -2
- package/dist/shared/overlay/native-dialog-presence.js.map +1 -1
- package/dist/shared/overlay/nested-drawer-layers.js +7 -4
- package/dist/shared/overlay/nested-drawer-layers.js.map +1 -1
- package/dist/shared/overlay/open-overlay.js +182 -0
- package/dist/shared/overlay/open-overlay.js.map +1 -0
- package/dist/shared/overlay/overlay.js +1 -1
- package/dist/shared/overlay/overlay.js.map +1 -1
- package/dist/shared/overlay/portal.js +1 -1
- package/dist/shared/overlay/portal.js.map +1 -1
- package/dist/shared/overlay/presence.js +19 -22
- package/dist/shared/overlay/presence.js.map +1 -1
- package/dist/shared/theme/duration.js +9 -0
- package/dist/shared/theme/duration.js.map +1 -0
- package/dist/shared/theme/reduced-motion.js +15 -0
- package/dist/shared/theme/reduced-motion.js.map +1 -0
- package/dist/shared/visible-area/index.js +1 -1
- package/dist/shared/visible-area/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/shared/overlay/composition.js +0 -57
- package/dist/shared/overlay/composition.js.map +0 -1
- package/dist/shared/overlay/lifecycle.js +0 -41
- package/dist/shared/overlay/lifecycle.js.map +0 -1
- package/dist/vite.svg +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import e from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/decorate.js";
|
|
2
2
|
import "../icon/index.js";
|
|
3
3
|
import t from "../../icons/generated/lucide-chevron-left.js";
|
|
4
4
|
import n from "../../icons/generated/lucide-chevron-right.js";
|
|
@@ -7,27 +7,28 @@ import i from "../../icons/generated/lucide-minus.js";
|
|
|
7
7
|
import a from "../../icons/generated/ooui-close.js";
|
|
8
8
|
import o from "../../icons/generated/radix-icons-reset.js";
|
|
9
9
|
import s from "../../assets/glass.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { defineOpenOverlay as c } from "../../shared/overlay/open-overlay.js";
|
|
11
|
+
import { getFallbackOverlayRoot as l } from "../../shared/overlay/overlay-root.js";
|
|
12
|
+
import { findNearestTheme as u, findRootTheme as d } from "../../shared/overlay/theme-overlay-scope.js";
|
|
13
|
+
import { defineScrollLockLease as f } from "../../shared/scroll-lock/scroll-lock.js";
|
|
13
14
|
import "../button/index.js";
|
|
14
|
-
import { defineNativeDialogPresence as
|
|
15
|
-
import { attachDragGesture as
|
|
16
|
-
import { clamp as
|
|
17
|
-
import { attachPinchGesture as
|
|
18
|
-
import
|
|
19
|
-
import { LitElement as
|
|
20
|
-
import { customElement as
|
|
21
|
-
import { classMap as
|
|
22
|
-
import { styleMap as
|
|
15
|
+
import { defineNativeDialogPresence as p } from "../../shared/overlay/native-dialog-presence.js";
|
|
16
|
+
import { attachDragGesture as m } from "../../shared/gesture/drag-gesture.js";
|
|
17
|
+
import { clamp as h } from "../../shared/gesture/physics.js";
|
|
18
|
+
import { attachPinchGesture as g } from "../../shared/gesture/pinch-gesture.js";
|
|
19
|
+
import _ from "./style.js";
|
|
20
|
+
import { LitElement as v, html as y, nothing as b, unsafeCSS as x } from "lit";
|
|
21
|
+
import { customElement as S, property as C, state as w } from "lit/decorators.js";
|
|
22
|
+
import { classMap as T } from "lit/directives/class-map.js";
|
|
23
|
+
import { styleMap as E } from "lit/directives/style-map.js";
|
|
23
24
|
//#region src/components/image-preview/index.ts
|
|
24
|
-
var
|
|
25
|
+
var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I = 320, L = class extends v {
|
|
25
26
|
constructor(...e) {
|
|
26
|
-
super(...e), this.images = [], this.loop = !0, this.nav = !1, this.toolbar = !1, this.closable = !1, this.indicator = !1, this.swipe = !1, this.noScrollLock = !1, this.noBackdropClose = !1, this._open = !1, this._index = 0, this._scale =
|
|
27
|
+
super(...e), this.images = [], this.loop = !0, this.nav = !1, this.toolbar = !1, this.closable = !1, this.indicator = !1, this.swipe = !1, this.noScrollLock = !1, this.noBackdropClose = !1, this._open = !1, this._index = 0, this._scale = D, this._offsetX = 0, this._offsetY = 0, this._swipeOffset = 0, this._swipeSettling = !1, this._dragging = !1, this._loadedSources = /* @__PURE__ */ new Set(), this._swipeDir = 0, this._swipeStartTime = 0, this._swipeSettleCommit = !1, this._swipeSettleDir = 1, this._scrollLock = f().make(), this._overlay = c().make({ requestClose: () => this.close() }), this._handle = null, this._presence = p().make({
|
|
27
28
|
getDialog: () => this.dialog,
|
|
28
29
|
isConnected: () => this.isConnected,
|
|
29
30
|
isOpen: () => this._open
|
|
30
|
-
}), this._dismissed = !1, this._swipeGesture = !1, this._panOriginX = 0, this._panOriginY = 0, this._dragged = !1, this._blankPointerDown = !1, this._pinchScale =
|
|
31
|
+
}), this._dismissed = !1, this._swipeGesture = !1, this._panOriginX = 0, this._panOriginY = 0, this._dragged = !1, this._blankPointerDown = !1, this._pinchScale = D, this._pinchLocalX = 0, this._pinchLocalY = 0, this._handleImageSettled = (e) => {
|
|
31
32
|
let t = e.currentTarget;
|
|
32
33
|
t && (this._loadedSources.add(t.src), this.requestUpdate());
|
|
33
34
|
}, this._handleCancel = (e) => {
|
|
@@ -37,7 +38,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
37
38
|
}, this._handleTransitionEnd = (e) => {
|
|
38
39
|
this._presence.handleTransitionEnd(e);
|
|
39
40
|
}, this._handleKeydown = (e) => {
|
|
40
|
-
if (
|
|
41
|
+
if (this._open && !e.defaultPrevented && !(e.altKey || e.ctrlKey || e.metaKey)) switch (e.key) {
|
|
41
42
|
case "ArrowLeft":
|
|
42
43
|
e.preventDefault(), this.prev();
|
|
43
44
|
break;
|
|
@@ -58,7 +59,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
58
59
|
if (!this._open) return;
|
|
59
60
|
e.preventDefault();
|
|
60
61
|
let t = e.deltaMode === 1 ? e.deltaY * 16 : e.deltaY, n = this._stageOrigin();
|
|
61
|
-
this._zoomAt(this._scale * Math.exp(-t *
|
|
62
|
+
this._zoomAt(this._scale * Math.exp(-t * A), e.clientX - n.x, e.clientY - n.y);
|
|
62
63
|
}, this._handleClick = (e) => {
|
|
63
64
|
if (!this._open) return;
|
|
64
65
|
let t = this._blankPointerDown;
|
|
@@ -70,7 +71,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
70
71
|
this.noBackdropClose || this.close();
|
|
71
72
|
}
|
|
72
73
|
}, this._handleDoubleClick = (e) => {
|
|
73
|
-
|
|
74
|
+
this._open && e.target === this._image && (this._scale > D ? this.resetZoom() : this._setScale(O / 2));
|
|
74
75
|
}, this._handlePinchStart = (e) => {
|
|
75
76
|
if (!this._open) return;
|
|
76
77
|
this._endGesture(), this._dragging = !0, this._dragged = !0;
|
|
@@ -78,21 +79,21 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
78
79
|
this._pinchScale = this._scale, this._pinchLocalX = (e.centerX - t.x - this._offsetX) / this._scale, this._pinchLocalY = (e.centerY - t.y - this._offsetY) / this._scale;
|
|
79
80
|
}, this._handlePinchMove = (e) => {
|
|
80
81
|
if (!this._open) return;
|
|
81
|
-
let t =
|
|
82
|
+
let t = h(this._pinchScale * e.ratio, D, O), n = this._stageOrigin();
|
|
82
83
|
this._applyScale(t, e.centerX - n.x - this._pinchLocalX * t, e.centerY - n.y - this._pinchLocalY * t);
|
|
83
84
|
}, this._handlePinchEnd = () => {
|
|
84
85
|
this._dragging = !1;
|
|
85
86
|
}, this._handlePinchCancel = () => {
|
|
86
87
|
this._dragging = !1;
|
|
87
88
|
}, this._handleSwipeSettleEnd = (e) => {
|
|
88
|
-
|
|
89
|
+
this._swipeSettling && e.propertyName === "transform" && this._finishSwipeSettle();
|
|
89
90
|
}, this._handlePointerDown = (e) => {
|
|
90
91
|
if (!this._open || (this._cancelSwipeSettle(), this._swipeDir = 0, this._swipeOffset = 0, e.button !== 0 || e.isPrimary === !1)) return;
|
|
91
92
|
this._blankPointerDown = this._isBlank(e.target), this._dragged = !1;
|
|
92
93
|
let t = this._stage;
|
|
93
|
-
|
|
94
|
+
t && (e.target === t || t.contains(e.target)) && (this._swipeGesture = this._scale === D && this.swipe && this.images.length > 1, this._swipeStartTime = e.timeStamp, this._panOriginX = this._offsetX, this._panOriginY = this._offsetY, this._gesture?.destroy(), this._gesture = m(e, {
|
|
94
95
|
axis: "both",
|
|
95
|
-
threshold:
|
|
96
|
+
threshold: j,
|
|
96
97
|
onMove: (e) => {
|
|
97
98
|
this._swipeGesture ? (this._swipeOffset = e.deltaX, e.deltaX !== 0 && (this._swipeDir = e.deltaX < 0 ? 1 : -1)) : this._panTo(e.deltaX, e.deltaY);
|
|
98
99
|
},
|
|
@@ -109,7 +110,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
static {
|
|
112
|
-
this.styles = [
|
|
113
|
+
this.styles = [x(s), x(_)];
|
|
113
114
|
}
|
|
114
115
|
get dialog() {
|
|
115
116
|
return this.shadowRoot?.querySelector("dialog") ?? null;
|
|
@@ -127,7 +128,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
127
128
|
return this._scale;
|
|
128
129
|
}
|
|
129
130
|
configure(e) {
|
|
130
|
-
this.images = e.images, this.loop = e.loop, this.nav = e.nav, this.toolbar = e.toolbar, this.closable = e.closable, this.indicator = e.indicator, this.swipe = e.swipe, this.noScrollLock = e.noScrollLock, this.noBackdropClose = e.noBackdropClose, this._index =
|
|
131
|
+
this.images = e.images, this.loop = e.loop, this.nav = e.nav, this.toolbar = e.toolbar, this.closable = e.closable, this.indicator = e.indicator, this.swipe = e.swipe, this.noScrollLock = e.noScrollLock, this.noBackdropClose = e.noBackdropClose, this._index = h(e.index, 0, Math.max(0, e.images.length - 1));
|
|
131
132
|
}
|
|
132
133
|
show() {
|
|
133
134
|
this._open ||= (this._dismissed = !1, !0);
|
|
@@ -138,7 +139,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
138
139
|
goTo(e) {
|
|
139
140
|
let t = this.images.length;
|
|
140
141
|
if (t === 0) return;
|
|
141
|
-
let n = this.loop ? (e % t + t) % t :
|
|
142
|
+
let n = this.loop ? (e % t + t) % t : h(e, 0, t - 1);
|
|
142
143
|
n !== this._index && (this._index = n, this.resetZoom());
|
|
143
144
|
}
|
|
144
145
|
next() {
|
|
@@ -148,17 +149,29 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
148
149
|
this.goTo(this._index - 1);
|
|
149
150
|
}
|
|
150
151
|
zoomIn() {
|
|
151
|
-
this._setScale(this._scale +
|
|
152
|
+
this._setScale(this._scale + k);
|
|
152
153
|
}
|
|
153
154
|
zoomOut() {
|
|
154
|
-
this._setScale(this._scale -
|
|
155
|
+
this._setScale(this._scale - k);
|
|
155
156
|
}
|
|
156
157
|
resetZoom() {
|
|
157
|
-
(this._scale !==
|
|
158
|
+
(this._scale !== D || this._offsetX !== 0 || this._offsetY !== 0) && (this._scale = D, this._offsetX = 0, this._offsetY = 0);
|
|
159
|
+
}
|
|
160
|
+
connectedCallback() {
|
|
161
|
+
super.connectedCallback(), this._presence.reconcile(), this._syncScrollLock(), this._attachPinch(), this._reclaimIfOpen();
|
|
162
|
+
}
|
|
163
|
+
_reclaimIfOpen() {
|
|
164
|
+
if (!this._open || this._handle) return;
|
|
165
|
+
let e = this.dialog;
|
|
166
|
+
e && (this._handle = this._overlay.claim(e, { ancestryFrom: this }));
|
|
158
167
|
}
|
|
159
168
|
firstUpdated() {
|
|
169
|
+
this._attachPinch();
|
|
170
|
+
}
|
|
171
|
+
_attachPinch() {
|
|
172
|
+
if (this._pinch) return;
|
|
160
173
|
let e = this._stage;
|
|
161
|
-
e && (this._pinch =
|
|
174
|
+
e && (this._pinch = g(e, {
|
|
162
175
|
onStart: this._handlePinchStart,
|
|
163
176
|
onMove: this._handlePinchMove,
|
|
164
177
|
onEnd: this._handlePinchEnd,
|
|
@@ -166,10 +179,17 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
166
179
|
}));
|
|
167
180
|
}
|
|
168
181
|
updated(e) {
|
|
169
|
-
super.updated(e), this.isConnected
|
|
182
|
+
if (super.updated(e), this.isConnected) {
|
|
183
|
+
if (e.has("_open")) {
|
|
184
|
+
this._presence.sync(this._open);
|
|
185
|
+
let e = this.dialog;
|
|
186
|
+
e && (this._open ? (this._handle?.release(), this._handle = this._overlay.claim(e, { ancestryFrom: this })) : (this._handle?.release(), this._handle = null)), !this._open && !this.dialog?.open && queueMicrotask(() => this._notifyDismissed());
|
|
187
|
+
}
|
|
188
|
+
(e.has("_open") || e.has("noScrollLock")) && this._syncScrollLock();
|
|
189
|
+
}
|
|
170
190
|
}
|
|
171
191
|
disconnectedCallback() {
|
|
172
|
-
super.disconnectedCallback(), this._endGesture(), this._pinch?.destroy(), this._pinch = void 0, this._presence.dispose(), this._scrollLock.release();
|
|
192
|
+
super.disconnectedCallback(), this._endGesture(), this._pinch?.destroy(), this._pinch = void 0, this._presence.dispose(), this._scrollLock.release(), this._handle?.release(), this._handle = null;
|
|
173
193
|
}
|
|
174
194
|
_syncScrollLock() {
|
|
175
195
|
this._scrollLock.sync(this._open && !this.noScrollLock);
|
|
@@ -178,13 +198,13 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
178
198
|
this._dismissed || this._open || (this._dismissed = !0, this.dispatchEvent(new CustomEvent("preview-dismissed")));
|
|
179
199
|
}
|
|
180
200
|
_zoomAt(e, t, n) {
|
|
181
|
-
let r =
|
|
201
|
+
let r = h(e, D, O);
|
|
182
202
|
if (r === this._scale) return;
|
|
183
203
|
let i = r / this._scale;
|
|
184
204
|
this._applyScale(r, t - (t - this._offsetX) * i, n - (n - this._offsetY) * i);
|
|
185
205
|
}
|
|
186
206
|
_applyScale(e, t, n) {
|
|
187
|
-
if (this._scale = e, e ===
|
|
207
|
+
if (this._scale = e, e === D) {
|
|
188
208
|
this._offsetX = 0, this._offsetY = 0;
|
|
189
209
|
return;
|
|
190
210
|
}
|
|
@@ -225,7 +245,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
225
245
|
}
|
|
226
246
|
_clampOffsets() {
|
|
227
247
|
let e = this._offsetBounds();
|
|
228
|
-
this._offsetX =
|
|
248
|
+
this._offsetX = h(this._offsetX, -e.x, e.x), this._offsetY = h(this._offsetY, -e.y, e.y);
|
|
229
249
|
}
|
|
230
250
|
_isBlank(e) {
|
|
231
251
|
return e === this.dialog || e === this._stage;
|
|
@@ -259,16 +279,16 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
259
279
|
this._swipeOffset = 0;
|
|
260
280
|
return;
|
|
261
281
|
}
|
|
262
|
-
let a = Math.max(1, Math.round(i *
|
|
263
|
-
this._swipeSettling = !0, this._swipeSettleCommit = c, this._swipeSettleDir = r, this._swipeOffset = c ? -r * i : 0, this._swipeSettleTimer = setTimeout(() => this._finishSwipeSettle(),
|
|
282
|
+
let a = Math.max(1, Math.round(i * M)), o = n - this._swipeStartTime, s = o >= 2 ? e / o * 1e3 : 0, c = (Math.abs(e) >= a || Math.abs(t) >= N || Math.abs(e) >= P && Math.max(Math.abs(t), Math.abs(s)) >= F) && this._adjacentIndex(r) !== -1;
|
|
283
|
+
this._swipeSettling = !0, this._swipeSettleCommit = c, this._swipeSettleDir = r, this._swipeOffset = c ? -r * i : 0, this._swipeSettleTimer = setTimeout(() => this._finishSwipeSettle(), I);
|
|
264
284
|
}
|
|
265
285
|
_panTo(e, t) {
|
|
266
286
|
let n = this._offsetBounds();
|
|
267
|
-
this._offsetX =
|
|
287
|
+
this._offsetX = h(this._panOriginX + e, -n.x, n.x), this._offsetY = h(this._panOriginY + t, -n.y, n.y);
|
|
268
288
|
}
|
|
269
289
|
render() {
|
|
270
|
-
let e = this.images.length, s = this._scale >
|
|
271
|
-
return
|
|
290
|
+
let e = this.images.length, s = this._scale > D, c = e > 0 ? this._adjacentIndex(-1) : -1, l = e > 0 ? this._adjacentIndex(1) : -1, u = `translate3d(${this._swipeOffset}px, 0, 0)`, d = `translate3d(${this._offsetX}px, ${this._offsetY}px, 0) scale(${this._scale})`, f = s ? "translate3d(0, 0, 0) scale(1)" : `translate3d(0, ${this._offsetY}px, 0) scale(1)`;
|
|
291
|
+
return y`
|
|
272
292
|
<dialog
|
|
273
293
|
aria-label="图片预览"
|
|
274
294
|
@cancel=${this._handleCancel}
|
|
@@ -284,7 +304,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
284
304
|
<div class="wui-image-preview-content">
|
|
285
305
|
<div class="wui-image-preview-surface">
|
|
286
306
|
<div
|
|
287
|
-
class=${
|
|
307
|
+
class=${T({
|
|
288
308
|
"wui-image-preview-stage": !0,
|
|
289
309
|
"is-zoomed": s,
|
|
290
310
|
"is-dragging": this._dragging,
|
|
@@ -293,65 +313,65 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
293
313
|
>
|
|
294
314
|
<div
|
|
295
315
|
class="wui-image-preview-track"
|
|
296
|
-
style=${
|
|
316
|
+
style=${E({ transform: u })}
|
|
297
317
|
@transitionend=${this._handleSwipeSettleEnd}
|
|
298
318
|
>
|
|
299
|
-
${c >= 0 ?
|
|
319
|
+
${c >= 0 ? y`
|
|
300
320
|
<div class="wui-image-preview-slide is-prev" aria-hidden="true">
|
|
301
321
|
<img
|
|
302
|
-
class=${
|
|
322
|
+
class=${T({
|
|
303
323
|
"wui-image-preview-image": !0,
|
|
304
324
|
"is-loaded": this._loadedSources.has(this.images[c].src)
|
|
305
325
|
})}
|
|
306
326
|
src=${this.images[c].src}
|
|
307
327
|
alt=${this.images[c].alt ?? ""}
|
|
308
328
|
draggable="false"
|
|
309
|
-
style=${
|
|
329
|
+
style=${E({ transform: f })}
|
|
310
330
|
@load=${this._handleImageSettled}
|
|
311
331
|
@error=${this._handleImageSettled}
|
|
312
332
|
/>
|
|
313
333
|
</div>
|
|
314
|
-
` :
|
|
315
|
-
${e > 0 ?
|
|
334
|
+
` : b}
|
|
335
|
+
${e > 0 ? y`
|
|
316
336
|
<div class="wui-image-preview-slide is-current">
|
|
317
337
|
<img
|
|
318
|
-
class=${
|
|
338
|
+
class=${T({
|
|
319
339
|
"wui-image-preview-image": !0,
|
|
320
340
|
"is-loaded": this._loadedSources.has(this.images[this._index].src)
|
|
321
341
|
})}
|
|
322
342
|
src=${this.images[this._index].src}
|
|
323
343
|
alt=${this.images[this._index].alt ?? ""}
|
|
324
344
|
draggable="false"
|
|
325
|
-
style=${
|
|
345
|
+
style=${E({ transform: d })}
|
|
326
346
|
@load=${this._handleImageSettled}
|
|
327
347
|
@error=${this._handleImageSettled}
|
|
328
348
|
/>
|
|
329
349
|
</div>
|
|
330
|
-
` :
|
|
331
|
-
${l >= 0 ?
|
|
350
|
+
` : b}
|
|
351
|
+
${l >= 0 ? y`
|
|
332
352
|
<div class="wui-image-preview-slide is-next" aria-hidden="true">
|
|
333
353
|
<img
|
|
334
|
-
class=${
|
|
354
|
+
class=${T({
|
|
335
355
|
"wui-image-preview-image": !0,
|
|
336
356
|
"is-loaded": this._loadedSources.has(this.images[l].src)
|
|
337
357
|
})}
|
|
338
358
|
src=${this.images[l].src}
|
|
339
359
|
alt=${this.images[l].alt ?? ""}
|
|
340
360
|
draggable="false"
|
|
341
|
-
style=${
|
|
361
|
+
style=${E({ transform: f })}
|
|
342
362
|
@load=${this._handleImageSettled}
|
|
343
363
|
@error=${this._handleImageSettled}
|
|
344
364
|
/>
|
|
345
365
|
</div>
|
|
346
|
-
` :
|
|
366
|
+
` : b}
|
|
347
367
|
</div>
|
|
348
368
|
</div>
|
|
349
369
|
</div>
|
|
350
370
|
<div class="wui-image-preview-controls">
|
|
351
|
-
${this.indicator ?
|
|
371
|
+
${this.indicator ? y`<span class="wui-image-preview-counter wui-glass" aria-live="polite"
|
|
352
372
|
>${this._index + 1} / ${e}</span
|
|
353
|
-
>` :
|
|
354
|
-
${this.closable ?
|
|
373
|
+
>` : b}
|
|
374
|
+
${this.closable ? y`
|
|
355
375
|
<web-ui-button
|
|
356
376
|
class="wui-image-preview-close"
|
|
357
377
|
variant="glass"
|
|
@@ -362,8 +382,8 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
362
382
|
>
|
|
363
383
|
<web-ui-icon size="16" .icon=${a}></web-ui-icon>
|
|
364
384
|
</web-ui-button>
|
|
365
|
-
` :
|
|
366
|
-
${this.nav && e > 1 ?
|
|
385
|
+
` : b}
|
|
386
|
+
${this.nav && e > 1 ? y`
|
|
367
387
|
<web-ui-button
|
|
368
388
|
class="wui-image-preview-nav wui-image-preview-nav-prev"
|
|
369
389
|
variant="glass"
|
|
@@ -386,15 +406,15 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
386
406
|
>
|
|
387
407
|
<web-ui-icon size="20" .icon=${n}></web-ui-icon>
|
|
388
408
|
</web-ui-button>
|
|
389
|
-
` :
|
|
390
|
-
${this.toolbar ?
|
|
409
|
+
` : b}
|
|
410
|
+
${this.toolbar ? y`
|
|
391
411
|
<div class="wui-image-preview-toolbar wui-glass">
|
|
392
412
|
<web-ui-button
|
|
393
413
|
variant="glass"
|
|
394
414
|
icon
|
|
395
415
|
size="30"
|
|
396
416
|
aria-label="缩小"
|
|
397
|
-
?disabled=${this._scale <=
|
|
417
|
+
?disabled=${this._scale <= D}
|
|
398
418
|
@click=${this.zoomOut}
|
|
399
419
|
>
|
|
400
420
|
<web-ui-icon size="16" .icon=${i}></web-ui-icon>
|
|
@@ -405,7 +425,7 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
405
425
|
icon
|
|
406
426
|
size="30"
|
|
407
427
|
aria-label="放大"
|
|
408
|
-
?disabled=${this._scale >=
|
|
428
|
+
?disabled=${this._scale >= O}
|
|
409
429
|
@click=${this.zoomIn}
|
|
410
430
|
>
|
|
411
431
|
<web-ui-icon size="16" .icon=${r}></web-ui-icon>
|
|
@@ -415,27 +435,27 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
|
|
|
415
435
|
icon
|
|
416
436
|
size="30"
|
|
417
437
|
aria-label="重置缩放"
|
|
418
|
-
?disabled=${this._scale <=
|
|
438
|
+
?disabled=${this._scale <= D && !this._isPanned}
|
|
419
439
|
@click=${this.resetZoom}
|
|
420
440
|
>
|
|
421
441
|
<web-ui-icon size="16" .icon=${o}></web-ui-icon>
|
|
422
442
|
</web-ui-button>
|
|
423
443
|
</div>
|
|
424
|
-
` :
|
|
444
|
+
` : b}
|
|
425
445
|
</div>
|
|
426
446
|
</div>
|
|
427
447
|
</dialog>
|
|
428
448
|
`;
|
|
429
449
|
}
|
|
430
450
|
};
|
|
431
|
-
e([
|
|
432
|
-
function
|
|
451
|
+
e([C({ attribute: !1 })], L.prototype, "images", void 0), e([C({ attribute: !1 })], L.prototype, "loop", void 0), e([C({ attribute: !1 })], L.prototype, "nav", void 0), e([C({ attribute: !1 })], L.prototype, "toolbar", void 0), e([C({ attribute: !1 })], L.prototype, "closable", void 0), e([C({ attribute: !1 })], L.prototype, "indicator", void 0), e([C({ attribute: !1 })], L.prototype, "swipe", void 0), e([C({ attribute: !1 })], L.prototype, "noScrollLock", void 0), e([C({ attribute: !1 })], L.prototype, "noBackdropClose", void 0), e([w()], L.prototype, "_open", void 0), e([w()], L.prototype, "_index", void 0), e([w()], L.prototype, "_scale", void 0), e([w()], L.prototype, "_offsetX", void 0), e([w()], L.prototype, "_offsetY", void 0), e([w()], L.prototype, "_swipeOffset", void 0), e([w()], L.prototype, "_swipeSettling", void 0), e([w()], L.prototype, "_dragging", void 0), L = e([S("web-ui-image-preview")], L);
|
|
452
|
+
function R(e) {
|
|
433
453
|
let t = (e.images ?? []).map((e) => ({
|
|
434
454
|
src: e.src,
|
|
435
455
|
alt: e.alt ?? ""
|
|
436
456
|
}));
|
|
437
457
|
if (t.length === 0) throw Error("[web-ui-image-preview] imagePreview requires at least one image");
|
|
438
|
-
let n = e.target ?
|
|
458
|
+
let n = e.target ? u(e.target) : d(), r = e.container ?? n?.getOverlayRoot() ?? l(), i = document.createElement("web-ui-image-preview");
|
|
439
459
|
i.configure({
|
|
440
460
|
images: t,
|
|
441
461
|
index: e.index ?? 0,
|
|
@@ -476,6 +496,6 @@ function L(e) {
|
|
|
476
496
|
};
|
|
477
497
|
}
|
|
478
498
|
//#endregion
|
|
479
|
-
export {
|
|
499
|
+
export { R as imagePreview };
|
|
480
500
|
|
|
481
501
|
//# sourceMappingURL=index.js.map
|