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