@greypan/web-ui 6.4.0 → 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.
Files changed (126) hide show
  1. package/README.CN.md +134 -40
  2. package/README.md +145 -51
  3. package/dist/assets/glass.js +1 -1
  4. package/dist/assets/glass.js.map +1 -1
  5. package/dist/assets/selection-control.js +6 -0
  6. package/dist/assets/selection-control.js.map +1 -0
  7. package/dist/assets/toast-containers.js.map +1 -1
  8. package/dist/components/autocomplete/index.d.ts +2 -0
  9. package/dist/components/autocomplete/index.js +19 -20
  10. package/dist/components/autocomplete/index.js.map +1 -1
  11. package/dist/components/autocomplete/style.js.map +1 -1
  12. package/dist/components/badge/style.js.map +1 -1
  13. package/dist/components/button/style.js.map +1 -1
  14. package/dist/components/checkbox/index.d.ts +9 -2
  15. package/dist/components/checkbox/index.js +50 -26
  16. package/dist/components/checkbox/index.js.map +1 -1
  17. package/dist/components/checkbox/style.js +1 -1
  18. package/dist/components/checkbox/style.js.map +1 -1
  19. package/dist/components/checkbox-group/index.d.ts +3 -0
  20. package/dist/components/checkbox-group/index.js +24 -13
  21. package/dist/components/checkbox-group/index.js.map +1 -1
  22. package/dist/components/checkbox-group/style.js +1 -1
  23. package/dist/components/checkbox-group/style.js.map +1 -1
  24. package/dist/components/collapse/index.js.map +1 -1
  25. package/dist/components/context-menu/index.d.ts +10 -0
  26. package/dist/components/context-menu/index.js +48 -34
  27. package/dist/components/context-menu/index.js.map +1 -1
  28. package/dist/components/dialog/index.d.ts +6 -0
  29. package/dist/components/dialog/index.js +45 -20
  30. package/dist/components/dialog/index.js.map +1 -1
  31. package/dist/components/dialog/style.js +1 -1
  32. package/dist/components/dialog/style.js.map +1 -1
  33. package/dist/components/drawer/index.d.ts +22 -4
  34. package/dist/components/drawer/index.js +134 -106
  35. package/dist/components/drawer/index.js.map +1 -1
  36. package/dist/components/drawer/style.js +1 -1
  37. package/dist/components/drawer/style.js.map +1 -1
  38. package/dist/components/dropdown/index.d.ts +21 -1
  39. package/dist/components/dropdown/index.js +74 -51
  40. package/dist/components/dropdown/index.js.map +1 -1
  41. package/dist/components/image-preview/index.js +86 -66
  42. package/dist/components/image-preview/index.js.map +1 -1
  43. package/dist/components/image-preview/style.js +1 -1
  44. package/dist/components/image-preview/style.js.map +1 -1
  45. package/dist/components/index.js +29 -29
  46. package/dist/components/input/index.js +2 -2
  47. package/dist/components/input/index.js.map +1 -1
  48. package/dist/components/input/style.js.map +1 -1
  49. package/dist/components/layout/index.js +2 -2
  50. package/dist/components/layout/index.js.map +1 -1
  51. package/dist/components/layout/style.js +1 -1
  52. package/dist/components/layout/style.js.map +1 -1
  53. package/dist/components/popover/index.d.ts +8 -2
  54. package/dist/components/popover/index.js +47 -52
  55. package/dist/components/popover/index.js.map +1 -1
  56. package/dist/components/radio/index.d.ts +1 -1
  57. package/dist/components/radio/index.js +14 -13
  58. package/dist/components/radio/index.js.map +1 -1
  59. package/dist/components/radio/style.js +1 -1
  60. package/dist/components/radio/style.js.map +1 -1
  61. package/dist/components/radio-group/index.d.ts +3 -0
  62. package/dist/components/radio-group/index.js +24 -13
  63. package/dist/components/radio-group/index.js.map +1 -1
  64. package/dist/components/radio-group/style.js +1 -1
  65. package/dist/components/radio-group/style.js.map +1 -1
  66. package/dist/components/segmented/style.js +1 -1
  67. package/dist/components/segmented/style.js.map +1 -1
  68. package/dist/components/select/index.d.ts +2 -0
  69. package/dist/components/select/index.js +20 -19
  70. package/dist/components/select/index.js.map +1 -1
  71. package/dist/components/slider/index.js.map +1 -1
  72. package/dist/components/slider/style.js +1 -1
  73. package/dist/components/slider/style.js.map +1 -1
  74. package/dist/components/svg-draw-lines/index.d.ts +13 -2
  75. package/dist/components/svg-draw-lines/index.js +44 -31
  76. package/dist/components/svg-draw-lines/index.js.map +1 -1
  77. package/dist/components/switch/index.js.map +1 -1
  78. package/dist/components/switch/style.js.map +1 -1
  79. package/dist/components/textarea/index.js +2 -2
  80. package/dist/components/textarea/index.js.map +1 -1
  81. package/dist/components/textarea/style.js.map +1 -1
  82. package/dist/components/theme/index.d.ts +17 -0
  83. package/dist/components/theme/index.js +180 -20
  84. package/dist/components/theme/index.js.map +1 -1
  85. package/dist/components/theme/style.js +1 -1
  86. package/dist/components/theme/style.js.map +1 -1
  87. package/dist/components/toast/index.d.ts +1 -1
  88. package/dist/components/toast/manager.d.ts +1 -3
  89. package/dist/components/toast/manager.js +92 -49
  90. package/dist/components/toast/manager.js.map +1 -1
  91. package/dist/components/toast/style.js.map +1 -1
  92. package/dist/components/toast/toast.d.ts +37 -0
  93. package/dist/components/toast/toast.js +61 -8
  94. package/dist/components/toast/toast.js.map +1 -1
  95. package/dist/components/toast/types.d.ts +0 -4
  96. package/dist/components/tooltip/index.d.ts +6 -1
  97. package/dist/components/tooltip/index.js +11 -12
  98. package/dist/components/tooltip/index.js.map +1 -1
  99. package/dist/shared/gesture/drag-gesture.js +66 -64
  100. package/dist/shared/gesture/drag-gesture.js.map +1 -1
  101. package/dist/shared/gesture/physics.js +7 -29
  102. package/dist/shared/gesture/physics.js.map +1 -1
  103. package/dist/shared/menu-behavior/index.js +3 -4
  104. package/dist/shared/menu-behavior/index.js.map +1 -1
  105. package/dist/shared/option-portal/combobox-shell.js +7 -8
  106. package/dist/shared/option-portal/combobox-shell.js.map +1 -1
  107. package/dist/shared/overlay/anchored-panel.js +36 -31
  108. package/dist/shared/overlay/anchored-panel.js.map +1 -1
  109. package/dist/shared/overlay/native-dialog-presence.js +16 -0
  110. package/dist/shared/overlay/native-dialog-presence.js.map +1 -1
  111. package/dist/shared/overlay/nested-drawer-layers.js +7 -4
  112. package/dist/shared/overlay/nested-drawer-layers.js.map +1 -1
  113. package/dist/shared/overlay/open-overlay.js +182 -0
  114. package/dist/shared/overlay/open-overlay.js.map +1 -0
  115. package/dist/shared/overlay/presence.js +19 -22
  116. package/dist/shared/overlay/presence.js.map +1 -1
  117. package/dist/shared/theme/duration.js +9 -0
  118. package/dist/shared/theme/duration.js.map +1 -0
  119. package/dist/shared/theme/reduced-motion.js +15 -0
  120. package/dist/shared/theme/reduced-motion.js.map +1 -0
  121. package/package.json +1 -1
  122. package/dist/shared/overlay/composition.js +0 -57
  123. package/dist/shared/overlay/composition.js.map +0 -1
  124. package/dist/shared/overlay/lifecycle.js +0 -41
  125. package/dist/shared/overlay/lifecycle.js.map +0 -1
  126. package/dist/vite.svg +0 -1
@@ -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 { getFallbackOverlayRoot as c } from "../../shared/overlay/overlay-root.js";
11
- import { findNearestTheme as l, findRootTheme as u } from "../../shared/overlay/theme-overlay-scope.js";
12
- import { defineScrollLockLease as d } from "../../shared/scroll-lock/scroll-lock.js";
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 f } from "../../shared/overlay/native-dialog-presence.js";
15
- import { attachDragGesture as p } from "../../shared/gesture/drag-gesture.js";
16
- import { clamp as m } from "../../shared/gesture/physics.js";
17
- import { attachPinchGesture as h } from "../../shared/gesture/pinch-gesture.js";
18
- import g from "./style.js";
19
- import { LitElement as _, html as v, nothing as y, unsafeCSS as b } from "lit";
20
- import { customElement as x, property as S, state as C } from "lit/decorators.js";
21
- import { classMap as w } from "lit/directives/class-map.js";
22
- import { styleMap as T } from "lit/directives/style-map.js";
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 E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F = 320, I = class extends _ {
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 = E, 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 = d().make(), this._presence = f().make({
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 = E, this._pinchLocalX = 0, this._pinchLocalY = 0, this._handleImageSettled = (e) => {
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) => {
@@ -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 * k), e.clientX - n.x, e.clientY - n.y);
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
- this._open && e.target === this._image && (this._scale > E ? this.resetZoom() : this._setScale(D / 2));
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,7 +79,7 @@ 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 = m(this._pinchScale * e.ratio, E, D), n = this._stageOrigin();
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;
@@ -90,9 +91,9 @@ var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F
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
- t && (e.target === t || t.contains(e.target)) && (this._swipeGesture = this._scale === E && this.swipe && this.images.length > 1, this._swipeStartTime = e.timeStamp, this._panOriginX = this._offsetX, this._panOriginY = this._offsetY, this._gesture?.destroy(), this._gesture = p(e, {
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: A,
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 = [b(s), b(g)];
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 = m(e.index, 0, Math.max(0, e.images.length - 1));
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 : m(e, 0, t - 1);
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 + O);
152
+ this._setScale(this._scale + k);
152
153
  }
153
154
  zoomOut() {
154
- this._setScale(this._scale - O);
155
+ this._setScale(this._scale - k);
155
156
  }
156
157
  resetZoom() {
157
- (this._scale !== E || this._offsetX !== 0 || this._offsetY !== 0) && (this._scale = E, this._offsetX = 0, this._offsetY = 0);
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 = h(e, {
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 && (e.has("_open") && (this._presence.sync(this._open), !this._open && !this.dialog?.open && queueMicrotask(() => this._notifyDismissed())), (e.has("_open") || e.has("noScrollLock")) && this._syncScrollLock());
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 = m(e, E, D);
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 === 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 = m(this._offsetX, -e.x, e.x), this._offsetY = m(this._offsetY, -e.y, e.y);
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 * j)), o = n - this._swipeStartTime, s = o >= 2 ? e / o * 1e3 : 0, c = (Math.abs(e) >= a || Math.abs(t) >= M || Math.abs(e) >= N && Math.max(Math.abs(t), Math.abs(s)) >= P) && this._adjacentIndex(r) !== -1;
263
- this._swipeSettling = !0, this._swipeSettleCommit = c, this._swipeSettleDir = r, this._swipeOffset = c ? -r * i : 0, this._swipeSettleTimer = setTimeout(() => this._finishSwipeSettle(), F);
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 = m(this._panOriginX + e, -n.x, n.x), this._offsetY = m(this._panOriginY + t, -n.y, n.y);
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 > E, 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)`;
271
- return v`
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=${w({
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=${T({ transform: u })}
316
+ style=${E({ transform: u })}
297
317
  @transitionend=${this._handleSwipeSettleEnd}
298
318
  >
299
- ${c >= 0 ? v`
319
+ ${c >= 0 ? y`
300
320
  <div class="wui-image-preview-slide is-prev" aria-hidden="true">
301
321
  <img
302
- class=${w({
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=${T({ transform: f })}
329
+ style=${E({ transform: f })}
310
330
  @load=${this._handleImageSettled}
311
331
  @error=${this._handleImageSettled}
312
332
  />
313
333
  </div>
314
- ` : y}
315
- ${e > 0 ? v`
334
+ ` : b}
335
+ ${e > 0 ? y`
316
336
  <div class="wui-image-preview-slide is-current">
317
337
  <img
318
- class=${w({
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=${T({ transform: d })}
345
+ style=${E({ transform: d })}
326
346
  @load=${this._handleImageSettled}
327
347
  @error=${this._handleImageSettled}
328
348
  />
329
349
  </div>
330
- ` : y}
331
- ${l >= 0 ? v`
350
+ ` : b}
351
+ ${l >= 0 ? y`
332
352
  <div class="wui-image-preview-slide is-next" aria-hidden="true">
333
353
  <img
334
- class=${w({
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=${T({ transform: f })}
361
+ style=${E({ transform: f })}
342
362
  @load=${this._handleImageSettled}
343
363
  @error=${this._handleImageSettled}
344
364
  />
345
365
  </div>
346
- ` : y}
366
+ ` : b}
347
367
  </div>
348
368
  </div>
349
369
  </div>
350
370
  <div class="wui-image-preview-controls">
351
- ${this.indicator ? v`<span class="wui-image-preview-counter wui-glass" aria-live="polite"
371
+ ${this.indicator ? y`<span class="wui-image-preview-counter wui-glass" aria-live="polite"
352
372
  >${this._index + 1} / ${e}</span
353
- >` : y}
354
- ${this.closable ? v`
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
- ` : y}
366
- ${this.nav && e > 1 ? v`
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
- ` : y}
390
- ${this.toolbar ? v`
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 <= E}
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 >= D}
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 <= E && !this._isPanned}
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
- ` : y}
444
+ ` : b}
425
445
  </div>
426
446
  </div>
427
447
  </dialog>
428
448
  `;
429
449
  }
430
450
  };
431
- e([S({ attribute: !1 })], I.prototype, "images", void 0), e([S({ attribute: !1 })], I.prototype, "loop", void 0), e([S({ attribute: !1 })], I.prototype, "nav", void 0), e([S({ attribute: !1 })], I.prototype, "toolbar", void 0), e([S({ attribute: !1 })], I.prototype, "closable", void 0), e([S({ attribute: !1 })], I.prototype, "indicator", void 0), e([S({ attribute: !1 })], I.prototype, "swipe", void 0), e([S({ attribute: !1 })], I.prototype, "noScrollLock", void 0), e([S({ attribute: !1 })], I.prototype, "noBackdropClose", void 0), e([C()], I.prototype, "_open", void 0), e([C()], I.prototype, "_index", void 0), e([C()], I.prototype, "_scale", void 0), e([C()], I.prototype, "_offsetX", void 0), e([C()], I.prototype, "_offsetY", void 0), e([C()], I.prototype, "_swipeOffset", void 0), e([C()], I.prototype, "_swipeSettling", void 0), e([C()], I.prototype, "_dragging", void 0), I = e([x("web-ui-image-preview")], I);
432
- function L(e) {
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 ? l(e.target) : u(), r = e.container ?? n?.getOverlayRoot() ?? c(), i = document.createElement("web-ui-image-preview");
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 { L as imagePreview };
499
+ export { R as imagePreview };
480
500
 
481
501
  //# sourceMappingURL=index.js.map