@greypan/web-ui 8.1.0 → 9.1.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 (163) hide show
  1. package/README.CN.md +309 -135
  2. package/README.md +311 -135
  3. package/dist/assets/glass.js +1 -1
  4. package/dist/assets/glass.js.map +1 -1
  5. package/dist/assets/menu-portal.js +1 -1
  6. package/dist/assets/menu-portal.js.map +1 -1
  7. package/dist/assets/modal-surface.js +6 -0
  8. package/dist/assets/modal-surface.js.map +1 -0
  9. package/dist/assets/selection-control.js +1 -1
  10. package/dist/assets/selection-control.js.map +1 -1
  11. package/dist/assets/toast-containers.js +1 -1
  12. package/dist/assets/toast-containers.js.map +1 -1
  13. package/dist/components/autocomplete/index.d.ts +3 -2
  14. package/dist/components/autocomplete/index.js +40 -44
  15. package/dist/components/autocomplete/index.js.map +1 -1
  16. package/dist/components/autocomplete/style.js +1 -1
  17. package/dist/components/autocomplete/style.js.map +1 -1
  18. package/dist/components/avatar/index.js.map +1 -1
  19. package/dist/components/avatar/style.js +1 -1
  20. package/dist/components/avatar/style.js.map +1 -1
  21. package/dist/components/back-top/style.js +1 -1
  22. package/dist/components/back-top/style.js.map +1 -1
  23. package/dist/components/badge/style.js +1 -1
  24. package/dist/components/badge/style.js.map +1 -1
  25. package/dist/components/button/style.js +1 -1
  26. package/dist/components/button/style.js.map +1 -1
  27. package/dist/components/button-group/index.js +0 -1
  28. package/dist/components/button-group/index.js.map +1 -1
  29. package/dist/components/button-group/style.js +1 -1
  30. package/dist/components/button-group/style.js.map +1 -1
  31. package/dist/components/checkbox/index.js +4 -4
  32. package/dist/components/checkbox/index.js.map +1 -1
  33. package/dist/components/checkbox-group/style.js +1 -1
  34. package/dist/components/checkbox-group/style.js.map +1 -1
  35. package/dist/components/context-menu/index.d.ts +182 -3
  36. package/dist/components/context-menu/index.js +166 -91
  37. package/dist/components/context-menu/index.js.map +1 -1
  38. package/dist/components/context-menu/scrim.js +6 -0
  39. package/dist/components/context-menu/scrim.js.map +1 -0
  40. package/dist/components/context-menu/style.js +1 -1
  41. package/dist/components/context-menu/style.js.map +1 -1
  42. package/dist/components/dialog/index.d.ts +9 -0
  43. package/dist/components/dialog/index.js +68 -46
  44. package/dist/components/dialog/index.js.map +1 -1
  45. package/dist/components/dialog/style.js +1 -1
  46. package/dist/components/dialog/style.js.map +1 -1
  47. package/dist/components/drawer/index.d.ts +45 -0
  48. package/dist/components/drawer/index.js +122 -53
  49. package/dist/components/drawer/index.js.map +1 -1
  50. package/dist/components/drawer/style.js +1 -1
  51. package/dist/components/drawer/style.js.map +1 -1
  52. package/dist/components/dropdown/index.d.ts +12 -0
  53. package/dist/components/dropdown/index.js +13 -10
  54. package/dist/components/dropdown/index.js.map +1 -1
  55. package/dist/components/dropdown-divider/style.js +1 -1
  56. package/dist/components/dropdown-divider/style.js.map +1 -1
  57. package/dist/components/dropdown-header/style.js +1 -1
  58. package/dist/components/dropdown-header/style.js.map +1 -1
  59. package/dist/components/dropdown-item/style.js +1 -1
  60. package/dist/components/dropdown-item/style.js.map +1 -1
  61. package/dist/components/editable-text/index.d.ts +39 -0
  62. package/dist/components/editable-text/index.js +6 -2
  63. package/dist/components/editable-text/index.js.map +1 -1
  64. package/dist/components/empty/index.d.ts +21 -4
  65. package/dist/components/empty/index.js +37 -32
  66. package/dist/components/empty/index.js.map +1 -1
  67. package/dist/components/empty/style.js +1 -1
  68. package/dist/components/empty/style.js.map +1 -1
  69. package/dist/components/image-preview/index.js +75 -63
  70. package/dist/components/image-preview/index.js.map +1 -1
  71. package/dist/components/image-preview/style.js +1 -1
  72. package/dist/components/image-preview/style.js.map +1 -1
  73. package/dist/components/index.d.ts +1 -0
  74. package/dist/components/index.js +38 -37
  75. package/dist/components/input/style.js +1 -1
  76. package/dist/components/input/style.js.map +1 -1
  77. package/dist/components/input-number/style.js +1 -1
  78. package/dist/components/input-number/style.js.map +1 -1
  79. package/dist/components/layout/index.d.ts +21 -6
  80. package/dist/components/layout/index.js +47 -27
  81. package/dist/components/layout/index.js.map +1 -1
  82. package/dist/components/layout/style.js +1 -1
  83. package/dist/components/layout/style.js.map +1 -1
  84. package/dist/components/middle-ellipsis/index.d.ts +100 -0
  85. package/dist/components/middle-ellipsis/index.js +112 -0
  86. package/dist/components/middle-ellipsis/index.js.map +1 -0
  87. package/dist/components/middle-ellipsis/style.js +6 -0
  88. package/dist/components/middle-ellipsis/style.js.map +1 -0
  89. package/dist/components/middle-ellipsis/truncate.d.ts +62 -0
  90. package/dist/components/middle-ellipsis/truncate.js +45 -0
  91. package/dist/components/middle-ellipsis/truncate.js.map +1 -0
  92. package/dist/components/option/style.js +1 -1
  93. package/dist/components/option/style.js.map +1 -1
  94. package/dist/components/popover/index.js.map +1 -1
  95. package/dist/components/popover/style.js +1 -1
  96. package/dist/components/popover/style.js.map +1 -1
  97. package/dist/components/radio/style.js +1 -1
  98. package/dist/components/radio/style.js.map +1 -1
  99. package/dist/components/radio-group/style.js +1 -1
  100. package/dist/components/radio-group/style.js.map +1 -1
  101. package/dist/components/segmented/index.d.ts +5 -0
  102. package/dist/components/segmented/index.js +45 -28
  103. package/dist/components/segmented/index.js.map +1 -1
  104. package/dist/components/segmented/style.js +1 -1
  105. package/dist/components/segmented/style.js.map +1 -1
  106. package/dist/components/segmented-trigger/style.js +1 -1
  107. package/dist/components/segmented-trigger/style.js.map +1 -1
  108. package/dist/components/select/index.js +0 -1
  109. package/dist/components/select/index.js.map +1 -1
  110. package/dist/components/select/style.js +1 -1
  111. package/dist/components/select/style.js.map +1 -1
  112. package/dist/components/slider/style.js +1 -1
  113. package/dist/components/slider/style.js.map +1 -1
  114. package/dist/components/spinner/style.js +1 -1
  115. package/dist/components/spinner/style.js.map +1 -1
  116. package/dist/components/svg-draw-lines/index.js.map +1 -1
  117. package/dist/components/switch/style.js +1 -1
  118. package/dist/components/switch/style.js.map +1 -1
  119. package/dist/components/textarea/index.js +2 -2
  120. package/dist/components/textarea/index.js.map +1 -1
  121. package/dist/components/textarea/style.js +1 -1
  122. package/dist/components/textarea/style.js.map +1 -1
  123. package/dist/components/theme/style.js +1 -1
  124. package/dist/components/theme/style.js.map +1 -1
  125. package/dist/components/toast/style.js +1 -1
  126. package/dist/components/toast/style.js.map +1 -1
  127. package/dist/components/tooltip/index.js.map +1 -1
  128. package/dist/components/tooltip/style.js +1 -1
  129. package/dist/components/tooltip/style.js.map +1 -1
  130. package/dist/icons/generated/akar-icons-circle-check.d.ts +6 -0
  131. package/dist/icons/generated/akar-icons-circle-check.js +10 -0
  132. package/dist/icons/generated/akar-icons-circle-check.js.map +1 -0
  133. package/dist/icons/generated/bi-check-lg.d.ts +6 -0
  134. package/dist/icons/generated/bi-check-lg.js +10 -0
  135. package/dist/icons/generated/bi-check-lg.js.map +1 -0
  136. package/dist/icons/generated/fluent-tag-search-24-regular.d.ts +6 -0
  137. package/dist/icons/generated/fluent-tag-search-24-regular.js +10 -0
  138. package/dist/icons/generated/fluent-tag-search-24-regular.js.map +1 -0
  139. package/dist/icons/generated/mdi-tag-search-outline.d.ts +6 -0
  140. package/dist/icons/generated/mdi-tag-search-outline.js +10 -0
  141. package/dist/icons/generated/mdi-tag-search-outline.js.map +1 -0
  142. package/dist/icons/index.d.ts +4 -0
  143. package/dist/icons/index.js +5 -1
  144. package/dist/scrollbars/index.d.ts +33 -0
  145. package/dist/scrollbars/index.js +18 -0
  146. package/dist/scrollbars/index.js.map +1 -0
  147. package/dist/scrollbars/style.css +10 -0
  148. package/dist/shared/element-height/index.js +47 -0
  149. package/dist/shared/element-height/index.js.map +1 -0
  150. package/dist/shared/element-width/index.js +37 -0
  151. package/dist/shared/element-width/index.js.map +1 -0
  152. package/dist/shared/menu-portal/menu-portal.js +11 -11
  153. package/dist/shared/menu-portal/menu-portal.js.map +1 -1
  154. package/dist/shared/menu-portal/menu-tree.js +2 -2
  155. package/dist/shared/menu-portal/menu-tree.js.map +1 -1
  156. package/dist/shared/overlay/anchored-panel.js.map +1 -1
  157. package/dist/shared/overlay/native-dialog-presence.js +23 -11
  158. package/dist/shared/overlay/native-dialog-presence.js.map +1 -1
  159. package/dist/shared/overlay/nested-drawer-layers.js +30 -23
  160. package/dist/shared/overlay/nested-drawer-layers.js.map +1 -1
  161. package/dist/shared/scroll-lock/scroll-lock.js +3 -3
  162. package/dist/shared/scroll-lock/scroll-lock.js.map +1 -1
  163. package/package.json +19 -5
@@ -1,65 +1,70 @@
1
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-inbox.js";
4
- import { normalizeLiteral as n } from "../../shared/normalize/index.js";
5
- import r from "./style.js";
6
- import { LitElement as i, html as a, unsafeCSS as o } from "lit";
7
- import { customElement as s, property as c, state as l } from "lit/decorators.js";
8
- import { classMap as u } from "lit/directives/class-map.js";
4
+ import n from "./style.js";
5
+ import { LitElement as r, html as i, unsafeCSS as a } from "lit";
6
+ import { customElement as o, property as s, state as c } from "lit/decorators.js";
7
+ import { classMap as l } from "lit/directives/class-map.js";
9
8
  //#region src/components/empty/index.ts
10
- var d = [
11
- "small",
12
- "medium",
13
- "large"
14
- ], f = class extends i {
9
+ var u = 56, d = 7, f = 3, p = 30, m = 4, h = 3, g = 56, _ = 14, v = 13, y = 16, b = 14, x = (e) => Number.isFinite(e) && e > 0 ? e : u, S = class extends r {
15
10
  constructor(...e) {
16
- super(...e), this.title = "", this.description = "", this._size = "medium", this._hasTitleSlot = !1, this._hasDescriptionSlot = !1, this._hasActionSlot = !1, this._syncSlotContent = () => {
11
+ super(...e), this.title = "", this.description = "", this._size = u, this._hasTitleSlot = !1, this._hasDescriptionSlot = !1, this._hasActionSlot = !1, this._syncSlotContent = () => {
17
12
  this._hasTitleSlot = this._hasAssignedContent(), this._hasDescriptionSlot = this._hasAssignedContent("description"), this._hasActionSlot = this._hasAssignedContent("action");
18
13
  };
19
14
  }
20
15
  static {
21
- this.styles = [o(r)];
16
+ this.styles = [a(n)];
22
17
  }
23
- get _iconSize() {
24
- return this._size === "small" ? 16 : this._size === "large" ? 32 : 24;
18
+ get size() {
19
+ return this._size;
25
20
  }
26
21
  set size(e) {
27
- let t = n(e, d, "medium");
28
- if (this._size !== t) {
29
- let e = this._size;
30
- this._size = t, this.requestUpdate("size", e);
31
- }
32
- this.getAttribute("size") !== t && this.setAttribute("size", t);
22
+ let t = this._size, n = x(e);
23
+ n !== t && (this._size = n, this.requestUpdate("size", t));
33
24
  }
34
- get size() {
35
- return this._size;
25
+ get _iconSize() {
26
+ return Math.round(this.size * f / d);
27
+ }
28
+ get _sizeStyle() {
29
+ let e = this.size, t = e < g, n = (t) => `${Math.round(e * t / d)}px`;
30
+ return {
31
+ "--wui-internal-empty-size": `${e}px`,
32
+ "--wui-internal-empty-min-height": n(p),
33
+ "--wui-internal-empty-padding-block": n(m),
34
+ "--wui-internal-empty-padding-inline": n(h),
35
+ "--wui-internal-empty-title-font-size": `${t ? _ : y}px`,
36
+ "--wui-internal-empty-description-font-size": `${t ? v : b}px`
37
+ };
36
38
  }
37
39
  connectedCallback() {
38
40
  super.connectedCallback(), this._syncSlotContent();
39
41
  }
42
+ updated() {
43
+ for (let [e, t] of Object.entries(this._sizeStyle)) this.style.setProperty(e, t);
44
+ }
40
45
  _hasAssignedContent(e) {
41
46
  return [...this.childNodes].some((t) => t instanceof HTMLElement && (t.getAttribute("slot") ?? "") === (e ?? "") || !e && t.nodeType === Node.TEXT_NODE && !!t.textContent?.trim());
42
47
  }
43
48
  render() {
44
49
  let e = this._hasTitleSlot || !!this.title, n = this._hasDescriptionSlot || !!this.description;
45
- return a`
50
+ return i`
46
51
  <section class="empty">
47
52
  <div class="empty-icon" aria-hidden="true">
48
53
  <slot name="icon"><web-ui-icon .icon=${t} .size=${this._iconSize}></web-ui-icon></slot>
49
54
  </div>
50
- <div class=${u({
55
+ <div class=${l({
51
56
  "empty-title": !0,
52
57
  "is-hidden": !e
53
58
  })}>
54
59
  <slot @slotchange=${this._syncSlotContent}>${this.title}</slot>
55
60
  </div>
56
- <div class=${u({
61
+ <div class=${l({
57
62
  "empty-description": !0,
58
63
  "is-hidden": !n
59
64
  })}>
60
65
  <slot name="description" @slotchange=${this._syncSlotContent}>${this.description}</slot>
61
66
  </div>
62
- <div class=${u({
67
+ <div class=${l({
63
68
  "empty-action": !0,
64
69
  "is-hidden": !this._hasActionSlot
65
70
  })}>
@@ -69,17 +74,17 @@ var d = [
69
74
  `;
70
75
  }
71
76
  };
72
- e([c({
77
+ e([s({
73
78
  type: String,
74
79
  reflect: !0
75
- })], f.prototype, "title", void 0), e([c({
80
+ })], S.prototype, "title", void 0), e([s({
76
81
  type: String,
77
82
  reflect: !0
78
- })], f.prototype, "description", void 0), e([c({
79
- type: String,
83
+ })], S.prototype, "description", void 0), e([s({
84
+ type: Number,
80
85
  reflect: !0
81
- })], f.prototype, "size", null), e([l()], f.prototype, "_hasTitleSlot", void 0), e([l()], f.prototype, "_hasDescriptionSlot", void 0), e([l()], f.prototype, "_hasActionSlot", void 0), f = e([s("web-ui-empty")], f);
86
+ })], S.prototype, "size", null), e([c()], S.prototype, "_hasTitleSlot", void 0), e([c()], S.prototype, "_hasDescriptionSlot", void 0), e([c()], S.prototype, "_hasActionSlot", void 0), S = e([o("web-ui-empty")], S);
82
87
  //#endregion
83
- export { f as WebUiEmpty };
88
+ export { S as WebUiEmpty };
84
89
 
85
90
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/empty/index.ts"],"sourcesContent":["import { html, LitElement, unsafeCSS } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\n\nimport '@/components/icon'\nimport { lucideInbox } from '@/icons'\nimport { normalizeLiteral } from '@/shared/normalize'\n\nimport style from './style.css?inline'\n\nexport type EmptySize = 'small' | 'medium' | 'large'\n\nconst ALLOWED_SIZES = ['small', 'medium', 'large'] as const\n\n@customElement('web-ui-empty')\nexport class WebUiEmpty extends LitElement {\n static override styles = [unsafeCSS(style)]\n\n @property({ type: String, reflect: true }) override title = ''\n\n @property({ type: String, reflect: true }) description = ''\n\n private get _iconSize(): number {\n return this._size === 'small' ? 16 : this._size === 'large' ? 32 : 24\n }\n\n @property({ type: String, reflect: true })\n set size(value: string) {\n const normalized = normalizeLiteral(value, ALLOWED_SIZES, 'medium')\n if (this._size !== normalized) {\n const old = this._size\n this._size = normalized\n this.requestUpdate('size', old)\n }\n if (this.getAttribute('size') !== normalized) {\n this.setAttribute('size', normalized)\n }\n }\n\n get size(): EmptySize {\n return this._size\n }\n\n private _size: EmptySize = 'medium'\n\n @state() private _hasTitleSlot = false\n @state() private _hasDescriptionSlot = false\n @state() private _hasActionSlot = false\n\n override connectedCallback() {\n super.connectedCallback()\n this._syncSlotContent()\n }\n\n private _syncSlotContent = () => {\n this._hasTitleSlot = this._hasAssignedContent()\n this._hasDescriptionSlot = this._hasAssignedContent('description')\n this._hasActionSlot = this._hasAssignedContent('action')\n }\n\n private _hasAssignedContent(slotName?: string): boolean {\n return [...this.childNodes].some(node => {\n if (node instanceof HTMLElement && (node.getAttribute('slot') ?? '') === (slotName ?? '')) return true\n return !slotName && node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())\n })\n }\n\n override render() {\n const showTitle = this._hasTitleSlot || Boolean(this.title)\n const showDescription = this._hasDescriptionSlot || Boolean(this.description)\n\n return html`\n <section class=\"empty\">\n <div class=\"empty-icon\" aria-hidden=\"true\">\n <slot name=\"icon\"><web-ui-icon .icon=${lucideInbox} .size=${this._iconSize}></web-ui-icon></slot>\n </div>\n <div class=${classMap({ 'empty-title': true, 'is-hidden': !showTitle })}>\n <slot @slotchange=${this._syncSlotContent}>${this.title}</slot>\n </div>\n <div class=${classMap({ 'empty-description': true, 'is-hidden': !showDescription })}>\n <slot name=\"description\" @slotchange=${this._syncSlotContent}>${this.description}</slot>\n </div>\n <div class=${classMap({ 'empty-action': true, 'is-hidden': !this._hasActionSlot })}>\n <slot name=\"action\" @slotchange=${this._syncSlotContent}></slot>\n </div>\n </section>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'web-ui-empty': WebUiEmpty\n }\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,IAAgB;CAAC;CAAS;CAAU;AAAO,GAGpC,IAAN,cAAyB,EAAW;;EAuCR,aApC2B,KAAA,QAAA,IAEH,KAAA,cAAA,IAuB9B,KAAA,QAAA,UAEM,KAAA,gBAAA,IACM,KAAA,sBAAA,IACL,KAAA,iBAAA,IAOD,KAAA,yBAAA;GAG/B,AAFA,KAAK,gBAAgB,KAAK,oBAAoB,GAC9C,KAAK,sBAAsB,KAAK,oBAAoB,aAAa,GACjE,KAAK,iBAAiB,KAAK,oBAAoB,QAAQ;EACzD;;;EA1CyB,KAAA,SAAA,CAAC,EAAU,CAAK,CAAC;;CAM1C,IAAY,YAAoB;EAC9B,OAAO,KAAK,UAAU,UAAU,KAAK,KAAK,UAAU,UAAU,KAAK;CACrE;CAEA,IACI,KAAK,GAAe;EACtB,IAAM,IAAa,EAAiB,GAAO,GAAe,QAAQ;EAClE,IAAI,KAAK,UAAU,GAAY;GAC7B,IAAM,IAAM,KAAK;GAEjB,AADA,KAAK,QAAQ,GACb,KAAK,cAAc,QAAQ,CAAG;EAChC;EACA,AAAI,KAAK,aAAa,MAAM,MAAM,KAChC,KAAK,aAAa,QAAQ,CAAU;CAExC;CAEA,IAAI,OAAkB;EACpB,OAAO,KAAK;CACd;CAQA,oBAA6B;EAE3B,AADA,MAAM,kBAAkB,GACxB,KAAK,iBAAiB;CACxB;CAQA,oBAA4B,GAA4B;EACtD,OAAO,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC,MAAK,MAC3B,aAAgB,gBAAgB,EAAK,aAAa,MAAM,KAAK,SAAS,KAAY,OAC/E,CAAC,KAAY,EAAK,aAAa,KAAK,aAAa,EAAQ,EAAK,aAAa,KAAK,CACxF;CACH;CAEA,SAAkB;EAChB,IAAM,IAAY,KAAK,iBAAiB,EAAQ,KAAK,OAC/C,IAAkB,KAAK,uBAAuB,EAAQ,KAAK;EAEjE,OAAO,CAAI;;;iDAGkC,EAAY,SAAS,KAAK,UAAU;;qBAEhE,EAAS;GAAE,eAAe;GAAM,aAAa,CAAC;EAAU,CAAC,EAAE;8BAClD,KAAK,iBAAiB,GAAG,KAAK,MAAM;;qBAE7C,EAAS;GAAE,qBAAqB;GAAM,aAAa,CAAC;EAAgB,CAAC,EAAE;iDAC3C,KAAK,iBAAiB,GAAG,KAAK,YAAY;;qBAEtE,EAAS;GAAE,gBAAgB;GAAM,aAAa,CAAC,KAAK;EAAe,CAAC,EAAE;4CAC/C,KAAK,iBAAiB;;;;CAIhE;AACF;AAtEG,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,KAAA,CAAA,GAExC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,eAAA,KAAA,CAAA,GAMxC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,IAAA,GAmBxC,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,iBAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,uBAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,kBAAA,KAAA,CAAA,GAjCR,IAAA,EAAA,CAAA,EAAc,cAAc,CAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/empty/index.ts"],"sourcesContent":["import { html, LitElement, unsafeCSS } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\n\nimport '@/components/icon'\nimport { lucideInbox } from '@/icons'\n\nimport style from './style.css?inline'\n\n/**\n * 图标容器边长默认值(px),也是非法输入的回退目标。\n */\nconst DEFAULT_SIZE = 56\n\n/**\n * 派生度量统一除以 7。取 7 是为了让默认档 56 整除出改前 medium 的四个值:字形 3/7 → 24、\n * min-height 30/7 → 240、padding 块 4/7 → 32、padding 行 3/7 → 24。40 与 72 因此落到\n * 171 / 23 / 17 与 309 / 41 / 31,字形 17 与 31。\n */\nconst DERIVED_DENOMINATOR = 7\nconst GLYPH_NUMERATOR = 3\nconst MIN_HEIGHT_NUMERATOR = 30\nconst PADDING_BLOCK_NUMERATOR = 4\nconst PADDING_INLINE_NUMERATOR = 3\n\n/**\n * 字号只有两档,阈值与默认边长同为 56:低于阈值取改前 small 的字号,其余取改前 medium 的\n * 字号。大尺寸靠留白撑开而不是靠字变大,所以 72 与 56 同档。\n */\nconst COMPACT_SIZE_THRESHOLD = 56\nconst COMPACT_TITLE_FONT_SIZE = 14\nconst COMPACT_DESCRIPTION_FONT_SIZE = 13\nconst DEFAULT_TITLE_FONT_SIZE = 16\nconst DEFAULT_DESCRIPTION_FONT_SIZE = 14\n\n/**\n * 只做数值合法性判断,不做枚举映射:有限正数原样采用,其余输入(NaN、±Infinity、0、负数)\n * 回退默认边长。\n *\n * 这一层是必要的:`size` 会同时写进 `--wui-internal-empty-size`,未守卫时\n * `size=\"abc\"` 会产出失效的 `NaNpx`(盒退回 unset 而涨成 300×300),\n * `size=\"\"` 会产出 `0px`(图标不可见)。回退的是边长本身,整套派生度量因此一起回到默认档\n * 56,而不是按 `NaN` 算出垃圾值。\n */\nconst normalizeSize = (value: number): number => (Number.isFinite(value) && value > 0 ? value : DEFAULT_SIZE)\n\n@customElement('web-ui-empty')\nexport class WebUiEmpty extends LitElement {\n static override styles = [unsafeCSS(style)]\n\n @property({ type: String, reflect: true }) override title = ''\n\n @property({ type: String, reflect: true }) description = ''\n\n /**\n * 版面缩放基准,单位 px,默认 56。驱动图标盒、min-height、padding 与标题/描述字号,\n * 使大图标不再配 medium 留白。\n *\n * 派生规则:图标容器边长即 `size`,默认字形边长 `round(size * 3 / 7)`,min-height\n * `round(size * 30 / 7)`,padding 块 `round(size * 4 / 7)`、行 `round(size * 3 / 7)`;\n * 字号在 56 处分两档,低于 56 为 14px / 13px,56 及以上为 16px / 14px。段间距与内容宽度\n * 不随它变化。\n *\n * 派生值全部落在 `--wui-internal-empty-*` 上,`--wui-empty-*` 仍压在其上,所以逐项覆盖\n * 优先于本属性。非法输入(非有限数、0、负数)回退默认边长 56。\n */\n @property({ type: Number, reflect: true })\n get size(): number {\n return this._size\n }\n\n set size(value: number) {\n const old = this._size\n const normalized = normalizeSize(value)\n if (normalized === old) return\n this._size = normalized\n this.requestUpdate('size', old)\n }\n\n private _size = DEFAULT_SIZE\n\n private get _iconSize(): number {\n return Math.round((this.size * GLYPH_NUMERATOR) / DERIVED_DENOMINATOR)\n }\n\n /**\n * `size` 派生的整套度量。CSS 侧按 `var(--wui-empty-*, var(--wui-internal-empty-*, 默认值))`\n * 消费,公开 token 因此始终压在派生值之上。\n */\n private get _sizeStyle(): Record<string, string> {\n const size = this.size\n const compact = size < COMPACT_SIZE_THRESHOLD\n const scaled = (numerator: number) => `${Math.round((size * numerator) / DERIVED_DENOMINATOR)}px`\n return {\n '--wui-internal-empty-size': `${size}px`,\n '--wui-internal-empty-min-height': scaled(MIN_HEIGHT_NUMERATOR),\n '--wui-internal-empty-padding-block': scaled(PADDING_BLOCK_NUMERATOR),\n '--wui-internal-empty-padding-inline': scaled(PADDING_INLINE_NUMERATOR),\n '--wui-internal-empty-title-font-size': `${compact ? COMPACT_TITLE_FONT_SIZE : DEFAULT_TITLE_FONT_SIZE}px`,\n '--wui-internal-empty-description-font-size': `${\n compact ? COMPACT_DESCRIPTION_FONT_SIZE : DEFAULT_DESCRIPTION_FONT_SIZE\n }px`\n }\n }\n\n @state() private _hasTitleSlot = false\n @state() private _hasDescriptionSlot = false\n @state() private _hasActionSlot = false\n\n override connectedCallback() {\n super.connectedCallback()\n this._syncSlotContent()\n }\n\n protected override updated() {\n // 无条件写:条件写同样覆盖得到默认实例(实测首次 changedProperties 里带 size)。\n // 这里换来的不变量是「派生 token 永远与当前 size 一致」——将来新增派生 token 不必\n // 再补一处 changed 判断,而同值 setProperty 不触发样式失效,代价可忽略。\n for (const [token, value] of Object.entries(this._sizeStyle)) {\n this.style.setProperty(token, value)\n }\n }\n\n private _syncSlotContent = () => {\n this._hasTitleSlot = this._hasAssignedContent()\n this._hasDescriptionSlot = this._hasAssignedContent('description')\n this._hasActionSlot = this._hasAssignedContent('action')\n }\n\n private _hasAssignedContent(slotName?: string): boolean {\n return [...this.childNodes].some(node => {\n if (node instanceof HTMLElement && (node.getAttribute('slot') ?? '') === (slotName ?? '')) return true\n return !slotName && node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())\n })\n }\n\n override render() {\n const showTitle = this._hasTitleSlot || Boolean(this.title)\n const showDescription = this._hasDescriptionSlot || Boolean(this.description)\n\n return html`\n <section class=\"empty\">\n <div class=\"empty-icon\" aria-hidden=\"true\">\n <slot name=\"icon\"><web-ui-icon .icon=${lucideInbox} .size=${this._iconSize}></web-ui-icon></slot>\n </div>\n <div class=${classMap({ 'empty-title': true, 'is-hidden': !showTitle })}>\n <slot @slotchange=${this._syncSlotContent}>${this.title}</slot>\n </div>\n <div class=${classMap({ 'empty-description': true, 'is-hidden': !showDescription })}>\n <slot name=\"description\" @slotchange=${this._syncSlotContent}>${this.description}</slot>\n </div>\n <div class=${classMap({ 'empty-action': true, 'is-hidden': !this._hasActionSlot })}>\n <slot name=\"action\" @slotchange=${this._syncSlotContent}></slot>\n </div>\n </section>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'web-ui-empty': WebUiEmpty\n }\n}\n"],"mappings":";;;;;;;;AAYA,IAAM,IAAe,IAOf,IAAsB,GACtB,IAAkB,GAClB,IAAuB,IACvB,IAA0B,GAC1B,IAA2B,GAM3B,IAAyB,IACzB,IAA0B,IAC1B,IAAgC,IAChC,IAA0B,IAC1B,IAAgC,IAWhC,KAAiB,MAA2B,OAAO,SAAS,CAAK,KAAK,IAAQ,IAAI,IAAQ,GAGnF,IAAN,cAAyB,EAAW;;EA4ER,aAzE2B,KAAA,QAAA,IAEH,KAAA,cAAA,IA2BzC,KAAA,QAAA,GA0BiB,KAAA,gBAAA,IACM,KAAA,sBAAA,IACL,KAAA,iBAAA,IAgBD,KAAA,yBAAA;GAG/B,AAFA,KAAK,gBAAgB,KAAK,oBAAoB,GAC9C,KAAK,sBAAsB,KAAK,oBAAoB,aAAa,GACjE,KAAK,iBAAiB,KAAK,oBAAoB,QAAQ;EACzD;;;EA/EyB,KAAA,SAAA,CAAC,EAAU,CAAK,CAAC;;CAkB1C,IACI,OAAe;EACjB,OAAO,KAAK;CACd;CAEA,IAAI,KAAK,GAAe;EACtB,IAAM,IAAM,KAAK,OACX,IAAa,EAAc,CAAK;EAClC,MAAe,MACnB,KAAK,QAAQ,GACb,KAAK,cAAc,QAAQ,CAAG;CAChC;CAIA,IAAY,YAAoB;EAC9B,OAAO,KAAK,MAAO,KAAK,OAAO,IAAmB,CAAmB;CACvE;CAMA,IAAY,aAAqC;EAC/C,IAAM,IAAO,KAAK,MACZ,IAAU,IAAO,GACjB,KAAU,MAAsB,GAAG,KAAK,MAAO,IAAO,IAAa,CAAmB,EAAE;EAC9F,OAAO;GACL,6BAA6B,GAAG,EAAK;GACrC,mCAAmC,EAAO,CAAoB;GAC9D,sCAAsC,EAAO,CAAuB;GACpE,uCAAuC,EAAO,CAAwB;GACtE,wCAAwC,GAAG,IAAU,IAA0B,EAAwB;GACvG,8CAA8C,GAC5C,IAAU,IAAgC,EAC3C;EACH;CACF;CAMA,oBAA6B;EAE3B,AADA,MAAM,kBAAkB,GACxB,KAAK,iBAAiB;CACxB;CAEA,UAA6B;EAI3B,KAAK,IAAM,CAAC,GAAO,MAAU,OAAO,QAAQ,KAAK,UAAU,GACzD,KAAK,MAAM,YAAY,GAAO,CAAK;CAEvC;CAQA,oBAA4B,GAA4B;EACtD,OAAO,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC,MAAK,MAC3B,aAAgB,gBAAgB,EAAK,aAAa,MAAM,KAAK,SAAS,KAAY,OAC/E,CAAC,KAAY,EAAK,aAAa,KAAK,aAAa,EAAQ,EAAK,aAAa,KAAK,CACxF;CACH;CAEA,SAAkB;EAChB,IAAM,IAAY,KAAK,iBAAiB,EAAQ,KAAK,OAC/C,IAAkB,KAAK,uBAAuB,EAAQ,KAAK;EAEjE,OAAO,CAAI;;;iDAGkC,EAAY,SAAS,KAAK,UAAU;;qBAEhE,EAAS;GAAE,eAAe;GAAM,aAAa,CAAC;EAAU,CAAC,EAAE;8BAClD,KAAK,iBAAiB,GAAG,KAAK,MAAM;;qBAE7C,EAAS;GAAE,qBAAqB;GAAM,aAAa,CAAC;EAAgB,CAAC,EAAE;iDAC3C,KAAK,iBAAiB,GAAG,KAAK,YAAY;;qBAEtE,EAAS;GAAE,gBAAgB;GAAM,aAAa,CAAC,KAAK;EAAe,CAAC,EAAE;4CAC/C,KAAK,iBAAiB;;;;CAIhE;AACF;AA3GG,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,SAAA,KAAA,CAAA,GAExC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,eAAA,KAAA,CAAA,GAcxC,EAAA,CAAA,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,IAAA,GAuCxC,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,iBAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,uBAAA,KAAA,CAAA,GACN,EAAA,CAAA,EAAM,CAAA,GAAA,EAAA,WAAA,kBAAA,KAAA,CAAA,GA7DR,IAAA,EAAA,CAAA,EAAc,cAAc,CAAA,GAAA,CAAA"}
@@ -1,5 +1,5 @@
1
1
  //#region src/components/empty/style.css?inline
2
- var e = "*,:before,:after{box-sizing:border-box}:host{display:block}.empty{width:100%;min-block-size:var(--wui-empty-min-height,240px);padding:var(--wui-empty-padding,32px 24px);text-align:center;flex-direction:column;align-items:center;display:flex}.empty-icon{width:var(--wui-empty-icon-size,56px);height:var(--wui-empty-icon-size,56px);border-radius:var(--wui-internal-empty-icon-radius,16px);color:var(--wui-color-text-secondary,#6a6a6a);background-color:var(--wui-color-surface-track,#e5e5ea);box-shadow:none;flex:none;justify-content:center;align-items:center;display:flex}.empty-title,.empty-description,.empty-action{max-inline-size:var(--wui-empty-content-width,480px)}.empty-title{margin-top:var(--wui-empty-title-margin-top,16px);font-size:var(--wui-empty-title-font-size,16px);color:var(--wui-color-text,#1b1b1b);overflow-wrap:anywhere;font-weight:600;line-height:1.5}.empty-description{font-size:var(--wui-empty-description-font-size,14px);color:var(--wui-color-text-secondary,#6a6a6a);overflow-wrap:anywhere;margin-top:6px;line-height:1.6}.empty-action{margin-top:var(--wui-empty-action-margin-top,20px)}.is-hidden{display:none}:host([size=small]){--wui-empty-min-height:160px;--wui-empty-padding:20px 16px;--wui-empty-icon-size:40px;--wui-empty-title-margin-top:12px;--wui-empty-title-font-size:14px;--wui-empty-description-font-size:13px;--wui-empty-action-margin-top:16px}:host([size=large]){--wui-empty-min-height:320px;--wui-empty-padding:48px 32px;--wui-empty-icon-size:72px;--wui-empty-title-margin-top:20px;--wui-empty-title-font-size:18px;--wui-empty-action-margin-top:24px}";
2
+ var e = "*,:before,:after{box-sizing:border-box}:host{display:block}.empty{width:100%;min-block-size:var(--wui-empty-min-height,var(--wui-internal-empty-min-height,240px));padding:var(--wui-empty-padding,var(--wui-internal-empty-padding-block,32px) var(--wui-internal-empty-padding-inline,24px));text-align:center;flex-direction:column;align-items:center;display:flex}.empty-icon{width:var(--wui-empty-icon-size,var(--wui-internal-empty-size,56px));height:var(--wui-empty-icon-size,var(--wui-internal-empty-size,56px));border-radius:var(--wui-internal-empty-icon-radius,18px);color:var(--wui-color-text-secondary,#6a6a6a);background-color:var(--wui-color-surface-track,#e5e5ea);box-shadow:none;flex:none;justify-content:center;align-items:center;display:flex}.empty-title,.empty-description,.empty-action{max-inline-size:var(--wui-empty-content-width,480px)}.empty-title{margin-top:var(--wui-empty-title-margin-top,var(--wui-space-4,16px));font-size:var(--wui-empty-title-font-size,var(--wui-internal-empty-title-font-size,16px));font-weight:var(--wui-font-weight-semibold,600);line-height:var(--wui-line-height-normal,1.5);color:var(--wui-color-text,#1b1b1b);overflow-wrap:anywhere}.empty-description{font-size:var(--wui-empty-description-font-size,var(--wui-internal-empty-description-font-size,14px));line-height:var(--wui-line-height-relaxed,1.6);color:var(--wui-color-text-secondary,#6a6a6a);overflow-wrap:anywhere;margin-top:6px}.empty-action{margin-top:var(--wui-empty-action-margin-top,var(--wui-space-5,20px))}.is-hidden{display:none}";
3
3
  //#endregion
4
4
  export { e as default };
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","names":[],"sources":["../../../src/components/empty/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n}\n\n.empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n\n width: 100%;\n min-block-size: var(--wui-empty-min-height, 240px);\n padding: var(--wui-empty-padding, 32px 24px);\n\n text-align: center;\n}\n\n.empty-icon {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n width: var(--wui-empty-icon-size, 56px);\n height: var(--wui-empty-icon-size, 56px);\n border-radius: var(--wui-internal-empty-icon-radius, 16px);\n\n color: var(--wui-color-text-secondary, #6a6a6a);\n\n background-color: var(--wui-color-surface-track, #e5e5ea);\n box-shadow: none;\n}\n\n.empty-title,\n.empty-description,\n.empty-action {\n max-inline-size: var(--wui-empty-content-width, 480px);\n}\n\n.empty-title {\n margin-top: var(--wui-empty-title-margin-top, 16px);\n\n font-size: var(--wui-empty-title-font-size, 16px);\n font-weight: 600;\n line-height: 1.5;\n color: var(--wui-color-text, #1b1b1b);\n overflow-wrap: anywhere;\n}\n\n.empty-description {\n margin-top: 6px;\n\n font-size: var(--wui-empty-description-font-size, 14px);\n line-height: 1.6;\n color: var(--wui-color-text-secondary, #6a6a6a);\n overflow-wrap: anywhere;\n}\n\n.empty-action {\n margin-top: var(--wui-empty-action-margin-top, 20px);\n}\n\n.is-hidden {\n display: none;\n}\n\n:host([size='small']) {\n --wui-empty-min-height: 160px;\n --wui-empty-padding: 20px 16px;\n --wui-empty-icon-size: 40px;\n --wui-empty-title-margin-top: 12px;\n --wui-empty-title-font-size: 14px;\n --wui-empty-description-font-size: 13px;\n --wui-empty-action-margin-top: 16px;\n}\n\n:host([size='large']) {\n --wui-empty-min-height: 320px;\n --wui-empty-padding: 48px 32px;\n --wui-empty-icon-size: 72px;\n --wui-empty-title-margin-top: 20px;\n --wui-empty-title-font-size: 18px;\n --wui-empty-action-margin-top: 24px;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"style.js","names":[],"sources":["../../../src/components/empty/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n}\n\n.empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n\n width: 100%;\n min-block-size: var(--wui-empty-min-height, var(--wui-internal-empty-min-height, 240px));\n padding: var(\n --wui-empty-padding,\n var(--wui-internal-empty-padding-block, 32px) var(--wui-internal-empty-padding-inline, 24px)\n );\n\n text-align: center;\n}\n\n.empty-icon {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n width: var(--wui-empty-icon-size, var(--wui-internal-empty-size, 56px));\n height: var(--wui-empty-icon-size, var(--wui-internal-empty-size, 56px));\n border-radius: var(--wui-internal-empty-icon-radius, 18px);\n\n color: var(--wui-color-text-secondary, #6a6a6a);\n\n background-color: var(--wui-color-surface-track, #e5e5ea);\n box-shadow: none;\n}\n\n.empty-title,\n.empty-description,\n.empty-action {\n max-inline-size: var(--wui-empty-content-width, 480px);\n}\n\n.empty-title {\n margin-top: var(--wui-empty-title-margin-top, var(--wui-space-4, 16px));\n\n font-size: var(--wui-empty-title-font-size, var(--wui-internal-empty-title-font-size, 16px));\n font-weight: var(--wui-font-weight-semibold, 600);\n line-height: var(--wui-line-height-normal, 1.5);\n color: var(--wui-color-text, #1b1b1b);\n overflow-wrap: anywhere;\n}\n\n.empty-description {\n margin-top: 6px;\n\n font-size: var(--wui-empty-description-font-size, var(--wui-internal-empty-description-font-size, 14px));\n line-height: var(--wui-line-height-relaxed, 1.6);\n color: var(--wui-color-text-secondary, #6a6a6a);\n overflow-wrap: anywhere;\n}\n\n.empty-action {\n margin-top: var(--wui-empty-action-margin-top, var(--wui-space-5, 20px));\n}\n\n.is-hidden {\n display: none;\n}\n"],"mappings":""}
@@ -12,28 +12,29 @@ import { defineOpenOverlay as c } from "../../shared/overlay/open-overlay.js";
12
12
  import { getFallbackOverlayRoot as l } from "../../shared/overlay/overlay-root.js";
13
13
  import { findNearestTheme as u, findRootTheme as d } from "../../shared/overlay/theme-overlay-scope.js";
14
14
  import { defineScrollLockLease as f } from "../../shared/scroll-lock/scroll-lock.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";
15
+ import p from "../../assets/modal-surface.js";
16
+ import { defineNativeDialogPresence as m } from "../../shared/overlay/native-dialog-presence.js";
17
+ import { attachDragGesture as h } from "../../shared/gesture/drag-gesture.js";
18
+ import { clamp as g } from "../../shared/gesture/physics.js";
19
+ import { attachPinchGesture as _ } from "../../shared/gesture/pinch-gesture.js";
20
+ import v from "./style.js";
21
+ import { LitElement as y, html as b, nothing as x, unsafeCSS as S } from "lit";
22
+ import { customElement as C, property as w, state as T } from "lit/decorators.js";
23
+ import { classMap as E } from "lit/directives/class-map.js";
24
+ import { styleMap as D } from "lit/directives/style-map.js";
24
25
  //#region src/components/image-preview/index.ts
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 {
26
+ var O = 1, k = 4, A = .5, j = .002, M = 3, N = .15, P = 320, F = 16, I = 160, L = 320, R = class extends y {
26
27
  constructor(...e) {
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({
28
+ 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 = O, 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({
28
29
  requestClose: () => this.close(),
29
30
  isConnected: () => this.isConnected
30
- }), this._handle = null, this._presence = p().make({
31
+ }), this._handle = null, this._presence = m().make({
31
32
  getDialog: () => this.dialog,
32
33
  isConnected: () => this.isConnected,
33
34
  isOpen: () => this._open
34
- }), 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) => {
35
+ }), this._dismissed = !1, this._swipeGesture = !1, this._panOriginX = 0, this._panOriginY = 0, this._dragged = !1, this._blankPointerDown = !1, this._pinchScale = O, this._pinchLocalX = 0, this._pinchLocalY = 0, this._handleImageSettled = (e) => {
35
36
  let t = e.currentTarget;
36
- t && (this._loadedSources.add(t.src), this.requestUpdate());
37
+ t && (this._markLoaded(t), this.requestUpdate());
37
38
  }, this._handleCancel = (e) => {
38
39
  e.preventDefault(), this.close();
39
40
  }, this._handleNativeClose = () => {
@@ -62,7 +63,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
62
63
  if (!this._open) return;
63
64
  e.preventDefault();
64
65
  let t = e.deltaMode === 1 ? e.deltaY * 16 : e.deltaY, n = this._stageOrigin();
65
- this._zoomAt(this._scale * Math.exp(-t * A), e.clientX - n.x, e.clientY - n.y);
66
+ this._zoomAt(this._scale * Math.exp(-t * j), e.clientX - n.x, e.clientY - n.y);
66
67
  }, this._handleClick = (e) => {
67
68
  if (!this._open) return;
68
69
  let t = this._blankPointerDown;
@@ -74,7 +75,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
74
75
  this.noBackdropClose || this.close();
75
76
  }
76
77
  }, this._handleDoubleClick = (e) => {
77
- this._open && e.target === this._image && (this._scale > D ? this.resetZoom() : this._setScale(O / 2));
78
+ this._open && e.target === this._image && (this._scale > O ? this.resetZoom() : this._setScale(k / 2));
78
79
  }, this._handlePinchStart = (e) => {
79
80
  if (!this._open) return;
80
81
  this._endGesture(), this._dragging = !0, this._dragged = !0;
@@ -82,7 +83,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
82
83
  this._pinchScale = this._scale, this._pinchLocalX = (e.centerX - t.x - this._offsetX) / this._scale, this._pinchLocalY = (e.centerY - t.y - this._offsetY) / this._scale;
83
84
  }, this._handlePinchMove = (e) => {
84
85
  if (!this._open) return;
85
- let t = h(this._pinchScale * e.ratio, D, O), n = this._stageOrigin();
86
+ let t = g(this._pinchScale * e.ratio, O, k), n = this._stageOrigin();
86
87
  this._applyScale(t, e.centerX - n.x - this._pinchLocalX * t, e.centerY - n.y - this._pinchLocalY * t);
87
88
  }, this._handlePinchEnd = () => {
88
89
  this._dragging = !1;
@@ -94,9 +95,9 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
94
95
  if (!this._open || (this._cancelSwipeSettle(), this._swipeDir = 0, this._swipeOffset = 0, e.button !== 0 || e.isPrimary === !1)) return;
95
96
  this._blankPointerDown = this._isBlank(e.target), this._dragged = !1;
96
97
  let t = this._stage;
97
- 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, {
98
+ t && (e.target === t || t.contains(e.target)) && (this._swipeGesture = this._scale === O && this.swipe && this.images.length > 1, this._swipeStartTime = e.timeStamp, this._panOriginX = this._offsetX, this._panOriginY = this._offsetY, this._gesture?.destroy(), this._gesture = h(e, {
98
99
  axis: "both",
99
- threshold: j,
100
+ threshold: M,
100
101
  onMove: (e) => {
101
102
  this._swipeGesture ? (this._swipeOffset = e.deltaX, e.deltaX !== 0 && (this._swipeDir = e.deltaX < 0 ? 1 : -1)) : this._panTo(e.deltaX, e.deltaY);
102
103
  },
@@ -113,7 +114,11 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
113
114
  };
114
115
  }
115
116
  static {
116
- this.styles = [x(t), x(_)];
117
+ this.styles = [
118
+ S(t),
119
+ S(p),
120
+ S(v)
121
+ ];
117
122
  }
118
123
  get dialog() {
119
124
  return this.shadowRoot?.querySelector("dialog") ?? null;
@@ -131,7 +136,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
131
136
  return this._scale;
132
137
  }
133
138
  configure(e) {
134
- 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));
139
+ 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 = g(e.index, 0, Math.max(0, e.images.length - 1));
135
140
  }
136
141
  show() {
137
142
  this._open ||= (this._dismissed = !1, !0);
@@ -142,7 +147,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
142
147
  goTo(e) {
143
148
  let t = this.images.length;
144
149
  if (t === 0) return;
145
- let n = this.loop ? (e % t + t) % t : h(e, 0, t - 1);
150
+ let n = this.loop ? (e % t + t) % t : g(e, 0, t - 1);
146
151
  n !== this._index && (this._index = n, this.resetZoom());
147
152
  }
148
153
  next() {
@@ -152,13 +157,13 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
152
157
  this.goTo(this._index - 1);
153
158
  }
154
159
  zoomIn() {
155
- this._setScale(this._scale + k);
160
+ this._setScale(this._scale + A);
156
161
  }
157
162
  zoomOut() {
158
- this._setScale(this._scale - k);
163
+ this._setScale(this._scale - A);
159
164
  }
160
165
  resetZoom() {
161
- (this._scale !== D || this._offsetX !== 0 || this._offsetY !== 0) && (this._scale = D, this._offsetX = 0, this._offsetY = 0);
166
+ (this._scale !== O || this._offsetX !== 0 || this._offsetY !== 0) && (this._scale = O, this._offsetX = 0, this._offsetY = 0);
162
167
  }
163
168
  connectedCallback() {
164
169
  super.connectedCallback(), this._presence.reconcile(), this._syncScrollLock(), this._attachPinch(), this._reclaimIfOpen();
@@ -174,7 +179,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
174
179
  _attachPinch() {
175
180
  if (this._pinch) return;
176
181
  let e = this._stage;
177
- e && (this._pinch = g(e, {
182
+ e && (this._pinch = _(e, {
178
183
  onStart: this._handlePinchStart,
179
184
  onMove: this._handlePinchMove,
180
185
  onEnd: this._handlePinchEnd,
@@ -184,7 +189,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
184
189
  updated(e) {
185
190
  if (super.updated(e), this.isConnected) {
186
191
  if (e.has("_open")) {
187
- this._presence.sync(this._open);
192
+ this._presence.sync(this._open), this._open && window.getSelection()?.removeAllRanges();
188
193
  let e = this.dialog;
189
194
  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());
190
195
  }
@@ -201,13 +206,13 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
201
206
  this._dismissed || this._open || (this._dismissed = !0, this.dispatchEvent(new CustomEvent("preview-dismissed")));
202
207
  }
203
208
  _zoomAt(e, t, n) {
204
- let r = h(e, D, O);
209
+ let r = g(e, O, k);
205
210
  if (r === this._scale) return;
206
211
  let i = r / this._scale;
207
212
  this._applyScale(r, t - (t - this._offsetX) * i, n - (n - this._offsetY) * i);
208
213
  }
209
214
  _applyScale(e, t, n) {
210
- if (this._scale = e, e === D) {
215
+ if (this._scale = e, e === O) {
211
216
  this._offsetX = 0, this._offsetY = 0;
212
217
  return;
213
218
  }
@@ -248,11 +253,15 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
248
253
  }
249
254
  _clampOffsets() {
250
255
  let e = this._offsetBounds();
251
- this._offsetX = h(this._offsetX, -e.x, e.x), this._offsetY = h(this._offsetY, -e.y, e.y);
256
+ this._offsetX = g(this._offsetX, -e.x, e.x), this._offsetY = g(this._offsetY, -e.y, e.y);
252
257
  }
253
258
  _isBlank(e) {
254
259
  return e === this.dialog || e === this._stage;
255
260
  }
261
+ _markLoaded(e) {
262
+ let t = this.images[Number(e.dataset.index)]?.src;
263
+ t !== void 0 && this._loadedSources.add(t);
264
+ }
256
265
  _endGesture() {
257
266
  this._gesture?.destroy(), this._gesture = void 0, this._dragging = !1, this._cancelSwipeSettle(), this._swipeDir = 0, this._swipeOffset = 0;
258
267
  }
@@ -282,16 +291,16 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
282
291
  this._swipeOffset = 0;
283
292
  return;
284
293
  }
285
- 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;
286
- this._swipeSettling = !0, this._swipeSettleCommit = c, this._swipeSettleDir = r, this._swipeOffset = c ? -r * i : 0, this._swipeSettleTimer = setTimeout(() => this._finishSwipeSettle(), I);
294
+ let a = Math.max(1, Math.round(i * N)), o = n - this._swipeStartTime, s = o >= 2 ? e / o * 1e3 : 0, c = (Math.abs(e) >= a || Math.abs(t) >= P || Math.abs(e) >= F && Math.max(Math.abs(t), Math.abs(s)) >= I) && this._adjacentIndex(r) !== -1;
295
+ this._swipeSettling = !0, this._swipeSettleCommit = c, this._swipeSettleDir = r, this._swipeOffset = c ? -r * i : 0, this._swipeSettleTimer = setTimeout(() => this._finishSwipeSettle(), L);
287
296
  }
288
297
  _panTo(e, t) {
289
298
  let n = this._offsetBounds();
290
- this._offsetX = h(this._panOriginX + e, -n.x, n.x), this._offsetY = h(this._panOriginY + t, -n.y, n.y);
299
+ this._offsetX = g(this._panOriginX + e, -n.x, n.x), this._offsetY = g(this._panOriginY + t, -n.y, n.y);
291
300
  }
292
301
  render() {
293
- let e = this.images.length, t = 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 = t ? "translate3d(0, 0, 0) scale(1)" : `translate3d(0, ${this._offsetY}px, 0) scale(1)`;
294
- return y`
302
+ let e = this.images.length, t = this._scale > O, 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 = t ? "translate3d(0, 0, 0) scale(1)" : `translate3d(0, ${this._offsetY}px, 0) scale(1)`;
303
+ return b`
295
304
  <dialog
296
305
  aria-label="图片预览"
297
306
  @cancel=${this._handleCancel}
@@ -307,7 +316,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
307
316
  <div class="wui-image-preview-content">
308
317
  <div class="wui-image-preview-surface">
309
318
  <div
310
- class=${T({
319
+ class=${E({
311
320
  "wui-image-preview-stage": !0,
312
321
  "is-zoomed": t,
313
322
  "is-dragging": this._dragging,
@@ -316,65 +325,68 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
316
325
  >
317
326
  <div
318
327
  class="wui-image-preview-track"
319
- style=${E({ transform: u })}
328
+ style=${D({ transform: u })}
320
329
  @transitionend=${this._handleSwipeSettleEnd}
321
330
  >
322
- ${c >= 0 ? y`
331
+ ${c >= 0 ? b`
323
332
  <div class="wui-image-preview-slide is-prev" aria-hidden="true">
324
333
  <img
325
- class=${T({
334
+ class=${E({
326
335
  "wui-image-preview-image": !0,
327
336
  "is-loaded": this._loadedSources.has(this.images[c].src)
328
337
  })}
338
+ data-index=${c}
329
339
  src=${this.images[c].src}
330
340
  alt=${this.images[c].alt ?? ""}
331
341
  draggable="false"
332
- style=${E({ transform: f })}
342
+ style=${D({ transform: f })}
333
343
  @load=${this._handleImageSettled}
334
344
  @error=${this._handleImageSettled}
335
345
  />
336
346
  </div>
337
- ` : b}
338
- ${e > 0 ? y`
347
+ ` : x}
348
+ ${e > 0 ? b`
339
349
  <div class="wui-image-preview-slide is-current">
340
350
  <img
341
- class=${T({
351
+ class=${E({
342
352
  "wui-image-preview-image": !0,
343
353
  "is-loaded": this._loadedSources.has(this.images[this._index].src)
344
354
  })}
355
+ data-index=${this._index}
345
356
  src=${this.images[this._index].src}
346
357
  alt=${this.images[this._index].alt ?? ""}
347
358
  draggable="false"
348
- style=${E({ transform: d })}
359
+ style=${D({ transform: d })}
349
360
  @load=${this._handleImageSettled}
350
361
  @error=${this._handleImageSettled}
351
362
  />
352
363
  </div>
353
- ` : b}
354
- ${l >= 0 ? y`
364
+ ` : x}
365
+ ${l >= 0 ? b`
355
366
  <div class="wui-image-preview-slide is-next" aria-hidden="true">
356
367
  <img
357
- class=${T({
368
+ class=${E({
358
369
  "wui-image-preview-image": !0,
359
370
  "is-loaded": this._loadedSources.has(this.images[l].src)
360
371
  })}
372
+ data-index=${l}
361
373
  src=${this.images[l].src}
362
374
  alt=${this.images[l].alt ?? ""}
363
375
  draggable="false"
364
- style=${E({ transform: f })}
376
+ style=${D({ transform: f })}
365
377
  @load=${this._handleImageSettled}
366
378
  @error=${this._handleImageSettled}
367
379
  />
368
380
  </div>
369
- ` : b}
381
+ ` : x}
370
382
  </div>
371
383
  </div>
372
384
  </div>
373
385
  <div class="wui-image-preview-controls">
374
- ${this.indicator ? y`<span class="wui-image-preview-counter wui-glass" aria-live="polite"
386
+ ${this.indicator ? b`<span class="wui-image-preview-counter wui-glass" aria-live="polite"
375
387
  >${this._index + 1} / ${e}</span
376
- >` : b}
377
- ${this.closable ? y`
388
+ >` : x}
389
+ ${this.closable ? b`
378
390
  <web-ui-button
379
391
  class="wui-image-preview-close"
380
392
  variant="glass"
@@ -385,8 +397,8 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
385
397
  >
386
398
  <web-ui-icon size="16" .icon=${o}></web-ui-icon>
387
399
  </web-ui-button>
388
- ` : b}
389
- ${this.nav && e > 1 ? y`
400
+ ` : x}
401
+ ${this.nav && e > 1 ? b`
390
402
  <web-ui-button
391
403
  class="wui-image-preview-nav wui-image-preview-nav-prev"
392
404
  variant="glass"
@@ -409,15 +421,15 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
409
421
  >
410
422
  <web-ui-icon size="20" .icon=${r}></web-ui-icon>
411
423
  </web-ui-button>
412
- ` : b}
413
- ${this.toolbar ? y`
424
+ ` : x}
425
+ ${this.toolbar ? b`
414
426
  <div class="wui-image-preview-toolbar wui-glass">
415
427
  <web-ui-button
416
428
  variant="glass"
417
429
  icon
418
430
  size="30"
419
431
  aria-label="缩小"
420
- ?disabled=${this._scale <= D}
432
+ ?disabled=${this._scale <= O}
421
433
  @click=${this.zoomOut}
422
434
  >
423
435
  <web-ui-icon size="16" .icon=${a}></web-ui-icon>
@@ -428,7 +440,7 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
428
440
  icon
429
441
  size="30"
430
442
  aria-label="放大"
431
- ?disabled=${this._scale >= O}
443
+ ?disabled=${this._scale >= k}
432
444
  @click=${this.zoomIn}
433
445
  >
434
446
  <web-ui-icon size="16" .icon=${i}></web-ui-icon>
@@ -438,21 +450,21 @@ var D = 1, O = 4, k = .5, A = .002, j = 3, M = .15, N = 320, P = 16, F = 160, I
438
450
  icon
439
451
  size="30"
440
452
  aria-label="重置缩放"
441
- ?disabled=${this._scale <= D && !this._isPanned}
453
+ ?disabled=${this._scale <= O && !this._isPanned}
442
454
  @click=${this.resetZoom}
443
455
  >
444
456
  <web-ui-icon size="16" .icon=${s}></web-ui-icon>
445
457
  </web-ui-button>
446
458
  </div>
447
- ` : b}
459
+ ` : x}
448
460
  </div>
449
461
  </div>
450
462
  </dialog>
451
463
  `;
452
464
  }
453
465
  };
454
- 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);
455
- function R(e) {
466
+ e([w({ attribute: !1 })], R.prototype, "images", void 0), e([w({ attribute: !1 })], R.prototype, "loop", void 0), e([w({ attribute: !1 })], R.prototype, "nav", void 0), e([w({ attribute: !1 })], R.prototype, "toolbar", void 0), e([w({ attribute: !1 })], R.prototype, "closable", void 0), e([w({ attribute: !1 })], R.prototype, "indicator", void 0), e([w({ attribute: !1 })], R.prototype, "swipe", void 0), e([w({ attribute: !1 })], R.prototype, "noScrollLock", void 0), e([w({ attribute: !1 })], R.prototype, "noBackdropClose", void 0), e([T()], R.prototype, "_open", void 0), e([T()], R.prototype, "_index", void 0), e([T()], R.prototype, "_scale", void 0), e([T()], R.prototype, "_offsetX", void 0), e([T()], R.prototype, "_offsetY", void 0), e([T()], R.prototype, "_swipeOffset", void 0), e([T()], R.prototype, "_swipeSettling", void 0), e([T()], R.prototype, "_dragging", void 0), R = e([C("web-ui-image-preview")], R);
467
+ function z(e) {
456
468
  let t = (e.images ?? []).map((e) => ({
457
469
  src: e.src,
458
470
  alt: e.alt ?? ""
@@ -499,6 +511,6 @@ function R(e) {
499
511
  };
500
512
  }
501
513
  //#endregion
502
- export { R as imagePreview };
514
+ export { z as imagePreview };
503
515
 
504
516
  //# sourceMappingURL=index.js.map