@nvidia-elements/core 2.20.3 → 2.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/accordion/accordion2.js +4 -4
  3. package/dist/alert/alert-group2.js +1 -1
  4. package/dist/alert/alert2.js +1 -1
  5. package/dist/avatar/avatar-group2.js +1 -1
  6. package/dist/avatar/avatar2.js +1 -1
  7. package/dist/badge/badge2.js +1 -1
  8. package/dist/breadcrumb/breadcrumb2.js +1 -1
  9. package/dist/bundles/index.d.ts +2 -2
  10. package/dist/bundles/index.js +11 -11
  11. package/dist/button/button2.js +1 -1
  12. package/dist/button-group/button-group2.js +1 -1
  13. package/dist/card/card2.js +4 -4
  14. package/dist/chat-message/chat-message2.js +1 -1
  15. package/dist/checkbox/checkbox-group2.js +1 -1
  16. package/dist/checkbox/checkbox2.js +1 -1
  17. package/dist/color/color2.js +1 -1
  18. package/dist/combobox/combobox.d.ts +1 -0
  19. package/dist/combobox/combobox2.js +80 -70
  20. package/dist/combobox/combobox2.js.map +1 -1
  21. package/dist/copy-button/copy-button2.js +1 -1
  22. package/dist/custom-elements-jsx.d.ts +1 -1
  23. package/dist/custom-elements-vue.d.ts +1 -1
  24. package/dist/custom-elements.json +3 -3
  25. package/dist/data.html.json +1 -1
  26. package/dist/date/date2.js +1 -1
  27. package/dist/datetime/datetime2.js +1 -1
  28. package/dist/dialog/dialog-footer2.js +1 -1
  29. package/dist/dialog/dialog-header2.js +1 -1
  30. package/dist/dialog/dialog2.js +1 -1
  31. package/dist/divider/divider2.js +1 -1
  32. package/dist/dot/dot2.js +1 -1
  33. package/dist/drag-handle/drag-handle2.js +1 -1
  34. package/dist/drawer/drawer-content2.js +1 -1
  35. package/dist/drawer/drawer-footer2.js +1 -1
  36. package/dist/drawer/drawer-header2.js +1 -1
  37. package/dist/drawer/drawer2.js +1 -1
  38. package/dist/dropdown/dropdown-footer2.js +1 -1
  39. package/dist/dropdown/dropdown-header2.js +1 -1
  40. package/dist/dropdown/dropdown.js +1 -1
  41. package/dist/dropdown/dropdown.js.map +1 -1
  42. package/dist/dropdown/dropdown2.js +2 -2
  43. package/dist/dropdown/dropdown2.js.map +1 -1
  44. package/dist/dropdown-group/dropdown-group.d.ts +1 -1
  45. package/dist/dropdown-group/dropdown-group.examples.js.map +1 -1
  46. package/dist/dropdown-group/dropdown-group.examples.json +11 -0
  47. package/dist/dropdown-group/dropdown-group.js +55 -25
  48. package/dist/dropdown-group/dropdown-group.js.map +1 -1
  49. package/dist/dropzone/dropzone2.js +1 -1
  50. package/dist/file/file2.js +1 -1
  51. package/dist/format-bytes/format-bytes2.js +1 -1
  52. package/dist/format-datetime/format-datetime2.js +1 -1
  53. package/dist/format-number/format-number2.js +1 -1
  54. package/dist/format-relative-time/format-relative-time2.js +1 -1
  55. package/dist/format-truncate/format-truncate2.js +35 -34
  56. package/dist/format-truncate/format-truncate2.js.map +1 -1
  57. package/dist/forms/control/control2.js +1 -1
  58. package/dist/forms/control-group/control-group2.js +1 -1
  59. package/dist/forms/control-message/control-message2.js +1 -1
  60. package/dist/gauge/gauge2.js +1 -1
  61. package/dist/grid/cell/cell2.js +1 -1
  62. package/dist/grid/column/column2.js +1 -1
  63. package/dist/grid/footer/footer2.js +1 -1
  64. package/dist/grid/grid2.js +1 -1
  65. package/dist/grid/header/header2.js +1 -1
  66. package/dist/grid/placeholder/placeholder2.js +1 -1
  67. package/dist/grid/row/row2.js +1 -1
  68. package/dist/icon/icon2.js +2 -2
  69. package/dist/icon-button/icon-button2.js +1 -1
  70. package/dist/iframe/iframe2.js +1 -1
  71. package/dist/index.js +1 -1
  72. package/dist/input/input-group2.js +1 -1
  73. package/dist/input/input2.js +1 -1
  74. package/dist/internal/controllers/type-native-popover.controller.d.ts +0 -1
  75. package/dist/internal/controllers/type-native-popover.controller.js.map +1 -1
  76. package/dist/internal/controllers/type-native-popover.utils.d.ts +0 -1
  77. package/dist/internal/controllers/type-native-popover.utils.js +1 -1
  78. package/dist/internal/controllers/type-native-popover.utils.js.map +1 -1
  79. package/dist/internal/index.js +23 -23
  80. package/dist/internal/styles/popover.js +1 -1
  81. package/dist/internal/styles/popover.js.map +1 -1
  82. package/dist/internal/styles/popover2.js +3 -10
  83. package/dist/internal/styles/popover2.js.map +1 -1
  84. package/dist/internal/utils/dom.js.map +1 -1
  85. package/dist/joystick/joystick2.js +1 -1
  86. package/dist/logo/logo2.js +1 -1
  87. package/dist/menu/menu-group2.js +1 -1
  88. package/dist/menu/menu-item2.js +1 -1
  89. package/dist/menu/menu2.js +1 -1
  90. package/dist/month/month2.js +1 -1
  91. package/dist/notification/notification-group2.js +1 -1
  92. package/dist/notification/notification2.js +1 -1
  93. package/dist/page/page-panel/page-panel-content2.js +1 -1
  94. package/dist/page/page-panel/page-panel-footer2.js +1 -1
  95. package/dist/page/page-panel/page-panel-header2.js +1 -1
  96. package/dist/page/page-panel/page-panel2.js +1 -1
  97. package/dist/page/page2.js +1 -1
  98. package/dist/page-header/page-header2.js +1 -1
  99. package/dist/page-loader/page-loader2.js +1 -1
  100. package/dist/pagination/pagination2.js +1 -1
  101. package/dist/panel/panel2.js +4 -4
  102. package/dist/password/password2.js +1 -1
  103. package/dist/preferences-input/preferences-input2.js +1 -1
  104. package/dist/progress-bar/progress-bar2.js +1 -1
  105. package/dist/progress-dot/progress-dot2.js +1 -1
  106. package/dist/progress-ring/progress-ring2.js +1 -1
  107. package/dist/progressive-filter-chip/progressive-filter-chip2.js +1 -1
  108. package/dist/pulse/pulse2.js +1 -1
  109. package/dist/radio/radio-group2.js +1 -1
  110. package/dist/radio/radio2.js +1 -1
  111. package/dist/range/range2.js +1 -1
  112. package/dist/resize-handle/resize-handle2.js +1 -1
  113. package/dist/search/search2.js +1 -1
  114. package/dist/select/select2.js +45 -32
  115. package/dist/select/select2.js.map +1 -1
  116. package/dist/skeleton/skeleton2.js +1 -1
  117. package/dist/sort-button/sort-button2.js +1 -1
  118. package/dist/sparkline/sparkline2.js +1 -1
  119. package/dist/star-rating/star-rating2.js +1 -1
  120. package/dist/steps/steps2.js +2 -2
  121. package/dist/switch/switch-group2.js +1 -1
  122. package/dist/switch/switch2.js +1 -1
  123. package/dist/tabs/tabs-group2.js +1 -1
  124. package/dist/tabs/tabs-item-group2.js +1 -1
  125. package/dist/tabs/tabs2.js +2 -2
  126. package/dist/tag/tag2.js +1 -1
  127. package/dist/textarea/textarea2.js +1 -1
  128. package/dist/time/time2.js +1 -1
  129. package/dist/toast/toast2.js +1 -1
  130. package/dist/toggletip/toggletip-footer2.js +1 -1
  131. package/dist/toggletip/toggletip-header2.js +1 -1
  132. package/dist/toggletip/toggletip.js +1 -1
  133. package/dist/toggletip/toggletip.js.map +1 -1
  134. package/dist/toggletip/toggletip2.js +1 -1
  135. package/dist/toolbar/toolbar2.js +1 -1
  136. package/dist/tooltip/tooltip2.js +1 -1
  137. package/dist/tree/tree-node2.js +1 -1
  138. package/dist/tree/tree2.js +1 -1
  139. package/dist/week/week2.js +1 -1
  140. package/package.json +44 -9
@@ -9,7 +9,7 @@ import { property as u } from "lit/decorators/property.js";
9
9
  // src/format-truncate/format-truncate.ts
10
10
  var d = class extends c {
11
11
  constructor(...e) {
12
- super(...e), this.position = "start", this.strategy = "character", this.bias = "end", this.preserve = 6, this.#l = () => {
12
+ super(...e), this.position = "start", this.strategy = "character", this.bias = "end", this.preserve = 6, this.#r = Infinity, this.#u = () => {
13
13
  this.requestUpdate();
14
14
  };
15
15
  }
@@ -19,71 +19,76 @@ var d = class extends c {
19
19
  static {
20
20
  this.metadata = {
21
21
  tag: "nve-format-truncate",
22
- version: "2.20.3"
22
+ version: "2.21.1"
23
23
  };
24
24
  }
25
25
  #e;
26
26
  #t;
27
+ #n;
28
+ #r;
27
29
  connectedCallback() {
28
- super.connectedCallback(), e(this), this.#c(), this.requestUpdate();
30
+ super.connectedCallback(), e(this), this.#r = Infinity, this.#l(), this.requestUpdate();
29
31
  }
30
32
  disconnectedCallback() {
31
- super.disconnectedCallback(), this.#t?.disconnect();
33
+ super.disconnectedCallback(), this.#t?.disconnect(), this.#n !== void 0 && this.ownerDocument.defaultView?.cancelAnimationFrame(this.#n), this.#n = void 0;
32
34
  }
33
35
  connectedMoveCallback() {
34
- this.#c(), this.requestUpdate();
36
+ this.#r = Infinity, this.#l(), this.requestUpdate();
35
37
  }
36
38
  render() {
37
- let e = this.#n, t = this.#r(e);
38
- return t === e ? this.removeAttribute("title") : this.title = e, l`<span internal-host aria-hidden="true">${t}</span><span sizing-host aria-hidden="true">${e}</span><slot @slotchange="${this.#l}"></slot>`;
39
+ let e = this.#i, t = this.#a(e);
40
+ return t === e ? this.removeAttribute("title") : this.title !== e && (this.title = e), l`<span internal-host aria-hidden="true">${t}</span><span sizing-host aria-hidden="true">${e}</span><slot @slotchange="${this.#u}"></slot>`;
39
41
  }
40
- get #n() {
42
+ get #i() {
41
43
  let e = this.shadowRoot?.querySelector("slot:not([name])");
42
44
  if (e) return a(e.assignedNodes({ flatten: !0 }));
43
- let t = Array.from(this.childNodes ?? []).filter(m);
45
+ let t = Array.from(this.childNodes ?? []).filter(p);
44
46
  return t.length ? a(t) : i(this.textContent ?? "");
45
47
  }
46
- #r(e) {
47
- let t = this.#a();
48
+ #a(e) {
49
+ let t = this.#o();
48
50
  return o(e, {
49
51
  position: this.position,
50
52
  strategy: this.strategy,
51
53
  bias: this.bias,
52
54
  preserve: this.preserve,
53
- availableWidth: this.#i,
55
+ availableWidth: this.#r,
54
56
  measureText: t
55
57
  });
56
58
  }
57
- get #i() {
58
- let e = this.ownerDocument?.defaultView;
59
- return !e || !this.shadowRoot?.querySelector("[internal-host]") ? Infinity : f(this, e);
60
- }
61
- #a() {
62
- let e = this.ownerDocument?.defaultView, t = this.#s;
59
+ #o() {
60
+ let e = this.ownerDocument?.defaultView, t = this.#c;
63
61
  if (!e || !t) return () => 0;
64
62
  let n = e.getComputedStyle(this);
65
63
  t.font = n.font;
66
- let r = p(n.letterSpacing), i = p(n.wordSpacing), a = new Intl.Segmenter(void 0, { granularity: "grapheme" });
67
- return (e) => this.#o(e, {
64
+ let r = f(n.letterSpacing), i = f(n.wordSpacing), a = new Intl.Segmenter(void 0, { granularity: "grapheme" });
65
+ return (e) => this.#s(e, {
68
66
  context: t,
69
67
  letterSpacing: r,
70
68
  wordSpacing: i,
71
69
  graphemeSegmenter: a
72
70
  });
73
71
  }
74
- #o(e, { context: t, letterSpacing: n, wordSpacing: r, graphemeSegmenter: i }) {
72
+ #s(e, { context: t, letterSpacing: n, wordSpacing: r, graphemeSegmenter: i }) {
75
73
  let a = i.segment(e), o = Array.from(e.matchAll(/\s/gu)).length;
76
74
  return t.measureText(e).width + Math.max(0, Array.from(a).length - 1) * n + o * r;
77
75
  }
78
- get #s() {
76
+ get #c() {
79
77
  return this.#e === void 0 && (this.#e = this.ownerDocument?.createElement("canvas").getContext("2d") ?? null), this.#e;
80
78
  }
81
- #c() {
82
- typeof ResizeObserver < "u" && (this.#t ??= new ResizeObserver(() => {
83
- this.isConnected && this.requestUpdate();
79
+ #l() {
80
+ typeof ResizeObserver < "u" && (this.#t ??= new ResizeObserver((e) => {
81
+ let t = e[0];
82
+ if (this.isConnected && t) {
83
+ this.#r = t.contentRect.width;
84
+ let e = this.ownerDocument.defaultView;
85
+ e && this.#n === void 0 && (this.#n = e.requestAnimationFrame(() => {
86
+ this.#n = void 0, this.isConnected && this.requestUpdate();
87
+ }));
88
+ }
84
89
  }), this.#t.disconnect(), this.#t.observe(this));
85
90
  }
86
- #l;
91
+ #u;
87
92
  };
88
93
  r([u({
89
94
  type: String,
@@ -98,18 +103,14 @@ r([u({
98
103
  type: Number,
99
104
  reflect: !0
100
105
  })], d.prototype, "preserve", void 0), d = r([t()], d);
101
- function f(e, t) {
102
- let n = t.getComputedStyle(e);
103
- return Math.max(0, e.getBoundingClientRect().width - p(n.borderInlineStartWidth) - p(n.borderInlineEndWidth) - p(n.paddingInlineStart) - p(n.paddingInlineEnd));
104
- }
105
- function p(e) {
106
+ function f(e) {
106
107
  let t = Number.parseFloat(e);
107
108
  return Number.isFinite(t) ? t : 0;
108
109
  }
109
- function m(e) {
110
- return !h(e) || !e.getAttribute("slot");
110
+ function p(e) {
111
+ return !m(e) || !e.getAttribute("slot");
111
112
  }
112
- function h(e) {
113
+ function m(e) {
113
114
  return e.nodeType === 1;
114
115
  }
115
116
  export { d as FormatTruncate };
@@ -1 +1 @@
1
- {"version":3,"file":"format-truncate2.js","names":["styles","_decorate","__decorate","format_truncate_default","FormatTruncate","LitElement","_args","#onSlotChange","useStyles","attachInternals","#observeAvailableWidth","#resizeObserver","text","#slottedText","truncatedText","#renderText","slot","normalizeTruncateText","nodes","isDefaultSlotNode","normalizeTruncateString","measureText","#createTextMeasurer","truncateText","#availableWidth","view","getContentWidth","context","#textMeasurementContext","computedStyles","letterSpacing","cssPixelValue","wordSpacing","graphemeSegmenter","#measureText","graphemeSegments","whitespaceCount","#measurementContext","property","typeSSR","element","parsed","value","isElementNode","node"],"sources":["../../src/format-truncate/format-truncate.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TemplateResult } from 'lit';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { attachInternals, useStyles, typeSSR } from '@nvidia-elements/core/internal';\nimport { normalizeTruncateString, normalizeTruncateText, truncateText } from './utils.js';\nimport styles from './format-truncate.css?inline';\n\n/**\n * @element nve-format-truncate\n * @description Truncates text at its start, center, or end while preserving the full text for assistive technology.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-truncate/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-truncate\n * @slot - Text to truncate. The component flattens, trims, and normalizes mixed text and element nodes.\n * @beta\n */\n@typeSSR()\nexport class FormatTruncate extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-truncate',\n version: '0.0.0'\n };\n\n /**\n * Location of the ellipsis. Use start or end to preserve one edge, or center to preserve both edges.\n */\n @property({ type: String, reflect: true }) position: 'start' | 'center' | 'end' = 'start';\n\n /**\n * Text unit used for center truncation. Character preserves graphemes, word preserves words, and path preserves path segments.\n */\n @property({ type: String, reflect: true }) strategy: 'character' | 'word' | 'path' = 'character';\n\n /**\n * Edge favored by center truncation. The favored edge keeps at least the configured number of units.\n */\n @property({ type: String, reflect: true }) bias: 'start' | 'end' = 'end';\n\n /**\n * Number of strategy units retained at the biased edge during center truncation.\n */\n @property({ type: Number, reflect: true }) preserve = 6;\n\n /** @private */\n declare _internals: ElementInternals;\n\n #measurementContext?: CanvasRenderingContext2D | null;\n #resizeObserver?: ResizeObserver;\n\n override connectedCallback(): void {\n super.connectedCallback();\n attachInternals(this);\n this.#observeAvailableWidth();\n this.requestUpdate();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#resizeObserver?.disconnect();\n }\n\n connectedMoveCallback(): void {\n this.#observeAvailableWidth();\n this.requestUpdate();\n }\n\n override render(): TemplateResult {\n const text = this.#slottedText;\n const truncatedText = this.#renderText(text);\n\n if (truncatedText !== text) this.title = text;\n else this.removeAttribute('title');\n\n return html`<span internal-host aria-hidden=\"true\">${truncatedText}</span><span sizing-host aria-hidden=\"true\">${text}</span><slot @slotchange=${this.#onSlotChange}></slot>`;\n }\n\n get #slottedText(): string {\n const slot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])');\n if (slot) return normalizeTruncateText(slot.assignedNodes({ flatten: true }));\n\n const nodes = Array.from(this.childNodes ?? []).filter(isDefaultSlotNode);\n return nodes.length ? normalizeTruncateText(nodes) : normalizeTruncateString(this.textContent ?? '');\n }\n\n #renderText(text: string): string {\n const measureText = this.#createTextMeasurer();\n\n return truncateText(text, {\n position: this.position,\n strategy: this.strategy,\n bias: this.bias,\n preserve: this.preserve,\n availableWidth: this.#availableWidth,\n measureText\n });\n }\n\n get #availableWidth(): number {\n const view = this.ownerDocument?.defaultView;\n if (!view || !this.shadowRoot?.querySelector('[internal-host]')) return Number.POSITIVE_INFINITY;\n\n return getContentWidth(this, view);\n }\n\n #createTextMeasurer(): (text: string) => number {\n const view = this.ownerDocument?.defaultView;\n const context = this.#textMeasurementContext;\n if (!view || !context) return () => 0;\n\n const computedStyles = view.getComputedStyle(this);\n context.font = computedStyles.font;\n\n const letterSpacing = cssPixelValue(computedStyles.letterSpacing);\n const wordSpacing = cssPixelValue(computedStyles.wordSpacing);\n const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n\n return text => this.#measureText(text, { context, letterSpacing, wordSpacing, graphemeSegmenter });\n }\n\n #measureText(\n text: string,\n {\n context,\n letterSpacing,\n wordSpacing,\n graphemeSegmenter\n }: {\n context: CanvasRenderingContext2D;\n letterSpacing: number;\n wordSpacing: number;\n graphemeSegmenter: Intl.Segmenter;\n }\n ): number {\n const graphemeSegments = graphemeSegmenter.segment(text);\n const whitespaceCount = Array.from(text.matchAll(/\\s/gu)).length;\n\n return (\n context.measureText(text).width +\n Math.max(0, Array.from(graphemeSegments).length - 1) * letterSpacing +\n whitespaceCount * wordSpacing\n );\n }\n\n get #textMeasurementContext(): CanvasRenderingContext2D | null {\n if (this.#measurementContext === undefined) {\n this.#measurementContext = this.ownerDocument?.createElement('canvas').getContext('2d') ?? null;\n }\n\n return this.#measurementContext;\n }\n\n #observeAvailableWidth(): void {\n if (typeof ResizeObserver === 'undefined') return;\n\n this.#resizeObserver ??= new ResizeObserver(() => {\n if (this.isConnected) this.requestUpdate();\n });\n this.#resizeObserver.disconnect();\n this.#resizeObserver.observe(this);\n }\n\n #onSlotChange = (): void => {\n this.requestUpdate();\n };\n}\n\nfunction getContentWidth(element: HTMLElement, view: Window): number {\n const computedStyles = view.getComputedStyle(element);\n return Math.max(\n 0,\n element.getBoundingClientRect().width -\n cssPixelValue(computedStyles.borderInlineStartWidth) -\n cssPixelValue(computedStyles.borderInlineEndWidth) -\n cssPixelValue(computedStyles.paddingInlineStart) -\n cssPixelValue(computedStyles.paddingInlineEnd)\n );\n}\n\nfunction cssPixelValue(value: string): number {\n const parsed = Number.parseFloat(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nfunction isDefaultSlotNode(node: Node): boolean {\n return !isElementNode(node) || !node.getAttribute('slot');\n}\n\nfunction isElementNode(node: Node): node is Element {\n return node.nodeType === 1;\n}\n"],"mappings":";;;;;;;;;AAoBO,IAAMI,IAAN,cAA6BC,EAAW;;EAkJjB,A,aAvIsD,KAAA,WAAA,SAKG,KAAA,WAAA,aAKlB,KAAA,OAAA,OAKb,KAAA,WAAA,GAwH1B,KAAAE,WAAA;GAC1B,KAAK,cAAc;EACrB;;;EAnJgB,KAAA,SAAAC,EAAU,CAACR,CAAM,CAAC;;;EAEP,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;CAyBA;CACA;CAEA,oBAAmC;EAIjC,AAHA,MAAM,kBAAkB,GACxBS,EAAgB,IAAI,GACpB,KAAKC,GAAuB,GAC5B,KAAK,cAAc;CACrB;CAEA,uBAAsC;EAEpC,AADA,MAAM,qBAAqB,GAC3B,KAAKC,IAAiB,WAAW;CACnC;CAEA,wBAA8B;EAE5B,AADA,KAAKD,GAAuB,GAC5B,KAAK,cAAc;CACrB;CAEA,SAAkC;EAChC,IAAME,IAAO,KAAKC,IACZC,IAAgB,KAAKC,GAAYH,CAAI;EAK3C,OAHIE,MAAkBF,IACjB,KAAK,gBAAgB,OAAO,IADL,KAAK,QAAQA,GAGlC,CAAI,0CAA0CE,EAAc,8CAA8CF,EAAK,4BAA2B,KAAKL,GAAc;CACtK;CAEA,IAAIM,KAAuB;EACzB,IAAMG,IAAO,KAAK,YAAY,cAA+B,kBAAkB;EAC/E,IAAIA,GAAM,OAAOC,EAAsBD,EAAK,cAAc,EAAE,SAAS,GAAK,CAAC,CAAC;EAE5E,IAAME,IAAQ,MAAM,KAAK,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC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AK,aAAa,MAAM;AAC1D;AAEA,SAASD,EAAc,GAA6B;CAClD,OAAOC,EAAK,aAAa;AAC3B"}
1
+ {"version":3,"file":"format-truncate2.js","names":["styles","_decorate","__decorate","format_truncate_default","FormatTruncate","LitElement","_args","#availableWidth","#onSlotChange","useStyles","attachInternals","#observeAvailableWidth","#resizeObserver","#resizeFrame","text","#slottedText","truncatedText","#renderText","slot","normalizeTruncateText","nodes","isDefaultSlotNode","normalizeTruncateString","measureText","#createTextMeasurer","truncateText","view","context","#textMeasurementContext","computedStyles","letterSpacing","cssPixelValue","wordSpacing","graphemeSegmenter","#measureText","graphemeSegments","whitespaceCount","#measurementContext","entry","entries","property","typeSSR","parsed","value","isElementNode","node"],"sources":["../../src/format-truncate/format-truncate.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TemplateResult } from 'lit';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { attachInternals, useStyles, typeSSR } from '@nvidia-elements/core/internal';\nimport { normalizeTruncateString, normalizeTruncateText, truncateText } from './utils.js';\nimport styles from './format-truncate.css?inline';\n\n/**\n * @element nve-format-truncate\n * @description Truncates text at its start, center, or end while preserving the full text for assistive technology.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-truncate/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-truncate\n * @slot - Text to truncate. The component flattens, trims, and normalizes mixed text and element nodes.\n * @beta\n */\n@typeSSR()\nexport class FormatTruncate extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-truncate',\n version: '0.0.0'\n };\n\n /**\n * Location of the ellipsis. Use start or end to preserve one edge, or center to preserve both edges.\n */\n @property({ type: String, reflect: true }) position: 'start' | 'center' | 'end' = 'start';\n\n /**\n * Text unit used for center truncation. Character preserves graphemes, word preserves words, and path preserves path segments.\n */\n @property({ type: String, reflect: true }) strategy: 'character' | 'word' | 'path' = 'character';\n\n /**\n * Edge favored by center truncation. The favored edge keeps at least the configured number of units.\n */\n @property({ type: String, reflect: true }) bias: 'start' | 'end' = 'end';\n\n /**\n * Number of strategy units retained at the biased edge during center truncation.\n */\n @property({ type: Number, reflect: true }) preserve = 6;\n\n /** @private */\n declare _internals: ElementInternals;\n\n #measurementContext?: CanvasRenderingContext2D | null;\n #resizeObserver?: ResizeObserver;\n #resizeFrame?: number;\n #availableWidth = Number.POSITIVE_INFINITY;\n\n override connectedCallback(): void {\n super.connectedCallback();\n attachInternals(this);\n this.#availableWidth = Number.POSITIVE_INFINITY;\n this.#observeAvailableWidth();\n this.requestUpdate();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#resizeObserver?.disconnect();\n if (this.#resizeFrame !== undefined) this.ownerDocument.defaultView?.cancelAnimationFrame(this.#resizeFrame);\n this.#resizeFrame = undefined;\n }\n\n connectedMoveCallback(): void {\n this.#availableWidth = Number.POSITIVE_INFINITY;\n this.#observeAvailableWidth();\n this.requestUpdate();\n }\n\n override render(): TemplateResult {\n const text = this.#slottedText;\n const truncatedText = this.#renderText(text);\n\n if (truncatedText !== text) {\n if (this.title !== text) this.title = text;\n } else this.removeAttribute('title');\n\n return html`<span internal-host aria-hidden=\"true\">${truncatedText}</span><span sizing-host aria-hidden=\"true\">${text}</span><slot @slotchange=${this.#onSlotChange}></slot>`;\n }\n\n get #slottedText(): string {\n const slot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])');\n if (slot) return normalizeTruncateText(slot.assignedNodes({ flatten: true }));\n\n const nodes = Array.from(this.childNodes ?? []).filter(isDefaultSlotNode);\n return nodes.length ? normalizeTruncateText(nodes) : normalizeTruncateString(this.textContent ?? '');\n }\n\n #renderText(text: string): string {\n const measureText = this.#createTextMeasurer();\n\n return truncateText(text, {\n position: this.position,\n strategy: this.strategy,\n bias: this.bias,\n preserve: this.preserve,\n availableWidth: this.#availableWidth,\n measureText\n });\n }\n\n #createTextMeasurer(): (text: string) => number {\n const view = this.ownerDocument?.defaultView;\n const context = this.#textMeasurementContext;\n if (!view || !context) return () => 0;\n\n const computedStyles = view.getComputedStyle(this);\n context.font = computedStyles.font;\n\n const letterSpacing = cssPixelValue(computedStyles.letterSpacing);\n const wordSpacing = cssPixelValue(computedStyles.wordSpacing);\n const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n\n return text => this.#measureText(text, { context, letterSpacing, wordSpacing, graphemeSegmenter });\n }\n\n #measureText(\n text: string,\n {\n context,\n letterSpacing,\n wordSpacing,\n graphemeSegmenter\n }: {\n context: CanvasRenderingContext2D;\n letterSpacing: number;\n wordSpacing: number;\n graphemeSegmenter: Intl.Segmenter;\n }\n ): number {\n const graphemeSegments = graphemeSegmenter.segment(text);\n const whitespaceCount = Array.from(text.matchAll(/\\s/gu)).length;\n\n return (\n context.measureText(text).width +\n Math.max(0, Array.from(graphemeSegments).length - 1) * letterSpacing +\n whitespaceCount * wordSpacing\n );\n }\n\n get #textMeasurementContext(): CanvasRenderingContext2D | null {\n if (this.#measurementContext === undefined) {\n this.#measurementContext = this.ownerDocument?.createElement('canvas').getContext('2d') ?? null;\n }\n\n return this.#measurementContext;\n }\n\n #observeAvailableWidth(): void {\n if (typeof ResizeObserver === 'undefined') return;\n\n this.#resizeObserver ??= new ResizeObserver(entries => {\n const entry = entries[0];\n if (this.isConnected && entry) {\n // Content-box measurements avoid synchronous geometry reads between sibling Lit updates.\n this.#availableWidth = entry.contentRect.width;\n const view = this.ownerDocument.defaultView;\n if (view && this.#resizeFrame === undefined) {\n this.#resizeFrame = view.requestAnimationFrame(() => {\n this.#resizeFrame = undefined;\n if (this.isConnected) this.requestUpdate();\n });\n }\n }\n });\n this.#resizeObserver.disconnect();\n this.#resizeObserver.observe(this);\n }\n\n #onSlotChange = (): void => {\n this.requestUpdate();\n };\n}\n\nfunction cssPixelValue(value: string): number {\n const parsed = Number.parseFloat(value);\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nfunction isDefaultSlotNode(node: Node): boolean {\n return !isElementNode(node) || !node.getAttribute('slot');\n}\n\nfunction isElementNode(node: Node): node is Element {\n return node.nodeType === 1;\n}\n"],"mappings":";;;;;;;;;AAoBO,IAAMI,IAAN,cAA6BC,EAAW;;EA6JjB,A,aAlJsD,KAAA,WAAA,SAKG,KAAA,WAAA,aAKlB,KAAA,OAAA,OAKb,KAAA,WAAA,GAQpC,KAAAE,KAAA,UA2HU,KAAAC,WAAA;GAC1B,KAAK,cAAc;EACrB;;;EA9JgB,KAAA,SAAAC,EAAU,CAACT,CAAM,CAAC;;;EAEP,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;CAyBA;CACA;CACA;CACA;CAEA,oBAAmC;EAKjC,AAJA,MAAM,kBAAkB,GACxBU,EAAgB,IAAI,GACpB,KAAKH,KAAkB,UACvB,KAAKI,GAAuB,GAC5B,KAAK,cAAc;CACrB;CAEA,uBAAsC;EAIpC,AAHA,MAAM,qBAAqB,GAC3B,KAAKC,IAAiB,WAAW,GAC7B,KAAKC,OAAiB,KAAA,KAAW,KAAK,cAAc,aAAa,qBAAqB,KAAKA,EAAY,GAC3G,KAAKA,KAAe,KAAA;CACtB;CAEA,wBAA8B;EAG5B,AAFA,KAAKN,KAAkB,UACvB,KAAKI,GAAuB,GAC5B,KAAK,cAAc;CACrB;CAEA,SAAkC;EAChC,IAAMG,IAAO,KAAKC,IACZC,IAAgB,KAAKC,GAAYH,CAAI;EAM3C,OAJIE,MAAkBF,IAEf,KAAK,gBAAgB,OAAO,IAD7B,KAAK,UAAUA,MAAM,KAAK,QAAQA,IAGjC,CAAI,0CAA0CE,EAAc,8CAA8CF,EAAK,4BAA2B,KAAKN,GAAc;CACtK;CAEA,IAAIO,KAAuB;EACzB,IAAMG,IAAO,KAAK,YAAY,cAA+B,kBAAkB;EAC/E,IAAIA,GAAM,OAAOC,EAAsBD,EAAK,cAAc,EAAE,SAAS,GAA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,7 +51,7 @@ var C = class extends _ {
51
51
  static {
52
52
  this.metadata = {
53
53
  tag: "nve-control",
54
- version: "2.20.3"
54
+ version: "2.21.1"
55
55
  };
56
56
  }
57
57
  render() {
@@ -24,7 +24,7 @@ var m = class extends d {
24
24
  static {
25
25
  this.metadata = {
26
26
  tag: "nve-control-group",
27
- version: "2.20.3"
27
+ version: "2.21.1"
28
28
  };
29
29
  }
30
30
  render() {
@@ -23,7 +23,7 @@ var l = {
23
23
  static {
24
24
  this.metadata = {
25
25
  tag: "nve-control-message",
26
- version: "2.20.3"
26
+ version: "2.21.1"
27
27
  };
28
28
  }
29
29
  static {
@@ -45,7 +45,7 @@ var l = {
45
45
  static {
46
46
  this.metadata = {
47
47
  tag: "nve-gauge",
48
- version: "2.20.3"
48
+ version: "2.21.1"
49
49
  };
50
50
  }
51
51
  #e;
@@ -10,7 +10,7 @@ var a = class extends r {
10
10
  static {
11
11
  this.metadata = {
12
12
  tag: "nve-grid-cell",
13
- version: "2.20.3"
13
+ version: "2.21.1"
14
14
  };
15
15
  }
16
16
  render() {
@@ -13,7 +13,7 @@ var c = class r extends a {
13
13
  static {
14
14
  this.metadata = {
15
15
  tag: "nve-grid-column",
16
- version: "2.20.3"
16
+ version: "2.21.1"
17
17
  };
18
18
  }
19
19
  get #e() {
@@ -15,7 +15,7 @@ var s = class extends a {
15
15
  static {
16
16
  this.metadata = {
17
17
  tag: "nve-grid-footer",
18
- version: "2.20.3"
18
+ version: "2.21.1"
19
19
  };
20
20
  }
21
21
  static {
@@ -23,7 +23,7 @@ var y = class extends g {
23
23
  static {
24
24
  this.metadata = {
25
25
  tag: "nve-grid",
26
- version: "2.20.3",
26
+ version: "2.21.1",
27
27
  children: [
28
28
  d.metadata.tag,
29
29
  f.metadata.tag,
@@ -19,7 +19,7 @@ var m = class extends d {
19
19
  static {
20
20
  this.metadata = {
21
21
  tag: "nve-grid-header",
22
- version: "2.20.3",
22
+ version: "2.21.1",
23
23
  children: [s.metadata.tag]
24
24
  };
25
25
  }
@@ -10,7 +10,7 @@ var a = class extends r {
10
10
  static {
11
11
  this.metadata = {
12
12
  tag: "nve-grid-placeholder",
13
- version: "2.20.3"
13
+ version: "2.21.1"
14
14
  };
15
15
  }
16
16
  render() {
@@ -15,7 +15,7 @@ var u = class extends s {
15
15
  static {
16
16
  this.metadata = {
17
17
  tag: "nve-grid-row",
18
- version: "2.20.3",
18
+ version: "2.21.1",
19
19
  children: [a.metadata.tag]
20
20
  };
21
21
  }
@@ -16,7 +16,7 @@ var f = class n extends o {
16
16
  static {
17
17
  this.metadata = {
18
18
  tag: "nve-icon",
19
- version: "2.20.3"
19
+ version: "2.21.1"
20
20
  };
21
21
  }
22
22
  static {
@@ -103,7 +103,7 @@ a([l({
103
103
  })], f.prototype, "name", void 0), a([d()], f.prototype, "svg", void 0);
104
104
  function p(e) {
105
105
  if (typeof globalThis.customElements?.get == "function") {
106
- let t = n(e.metadata.version), i = n("2.20.3");
106
+ let t = n(e.metadata.version), i = n("2.21.1");
107
107
  t.minor <= i.minor && t.major <= i.major && (e._icons = {
108
108
  ...e._icons,
109
109
  ...r
@@ -15,7 +15,7 @@ var l = class extends a {
15
15
  static {
16
16
  this.metadata = {
17
17
  tag: "nve-icon-button",
18
- version: "2.20.3"
18
+ version: "2.21.1"
19
19
  };
20
20
  }
21
21
  static {
@@ -47,7 +47,7 @@ var a = "\n window.addEventListener('message', event => {\n if (event.so
47
47
  static {
48
48
  this.metadata = {
49
49
  tag: "nve-iframe",
50
- version: "2.20.3"
50
+ version: "2.21.1"
51
51
  };
52
52
  }
53
53
  static get observedAttributes() {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { getThemeTokens as e } from "./internal/utils/dom.js";
2
2
  import { statusIcons as t } from "./internal/types/index.js";
3
3
  import { internal_exports as n } from "./internal/index.js";
4
4
  // src/index.ts
5
- var r = "2.20.3", i = "@nvidia-elements", a = n.I18nService;
5
+ var r = "2.21.1", i = "@nvidia-elements", a = n.I18nService;
6
6
  export { a as I18nService, i as SCOPE, r as VERSION, e as getThemeTokens, t as statusIcons };
7
7
 
8
8
  //# sourceMappingURL=index.js.map
@@ -11,7 +11,7 @@ var a = class extends n {
11
11
  static {
12
12
  this.metadata = {
13
13
  tag: "nve-input-group",
14
- version: "2.20.3"
14
+ version: "2.21.1"
15
15
  };
16
16
  }
17
17
  async connectedCallback() {
@@ -14,7 +14,7 @@ var a = r, o = class extends n {
14
14
  static {
15
15
  this.metadata = {
16
16
  tag: "nve-input",
17
- version: "2.20.3"
17
+ version: "2.21.1"
18
18
  };
19
19
  }
20
20
  };
@@ -6,7 +6,6 @@ export interface NativePopover extends ReactiveElement {
6
6
  popoverType?: PopoverType;
7
7
  modal?: boolean;
8
8
  popoverDismissible?: boolean;
9
- _activeTrigger?: HTMLElement;
10
9
  _internals?: ElementInternals;
11
10
  /** @deprecated */
12
11
  trigger?: HTMLElement | string;
@@ -1 +1 @@
1
- {"version":3,"file":"type-native-popover.controller.js","names":["TypeNativePopoverController","#nativeTriggers","root","popoverTargetTriggers","commandForTriggers","interestForTriggers","host","showPopover","source","options","getHostAnchor","getHostTrigger","attachInternals","#updateLegacyTriggers","#setupLegacyTriggers","#setupModalLightDismiss","#onBeforeToggle","#onToggle","#onCommand","#onInterest","#onLoseInterest","#observers","observer","#onPointerDown","#onPointerUp","#removeHintTrigger","#clearInterestTimeout","#clearCloseTimeout","#closeTimeout","#interestTimeout","raw","value","#legacyHostTrigger","r","trigger","#previousLegacyTrigger","#clearLegacyTrigger","#hintTrigger","#setupHintTrigger","#setupPopoverTargetTrigger","#onHintMouseEnter","#onHintMouseLeave","generateId","open","focusElement","target","#setCloseTimeout","#toggleFocus","interestDelayStart","#parseInterestDelay","#pointerdownWithinModal","clickOutsideElementBounds","hasOpenPopover"],"sources":["../../../src/internal/controllers/type-native-popover.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport { clickOutsideElementBounds, generateId } from '../utils/dom.js';\nimport { attachInternals } from '../utils/a11y.js';\nimport { focusElement } from '../utils/focus.js';\nimport { getHostAnchor, getHostTrigger, hasOpenPopover } from './type-native-popover.utils.js';\nimport type { InterestEvent, PopoverType } from '../types/index.js';\n\nexport interface NativePopover extends ReactiveElement {\n anchor?: HTMLElement | string;\n closeTimeout?: number;\n popoverType?: PopoverType;\n modal?: boolean;\n popoverDismissible?: boolean;\n _activeTrigger?: HTMLElement;\n _internals?: ElementInternals;\n\n /** @deprecated */\n trigger?: HTMLElement | string;\n /** @deprecated */\n openDelay?: number;\n /** @deprecated */\n behaviorTrigger?: boolean;\n}\n\n/**\n * https://open-ui.org/components/popup.research.explainer\n */\nexport class TypeNativePopoverController<T extends NativePopover> implements ReactiveController {\n get #nativeTriggers(): HTMLElement[] {\n const root = this.host.getRootNode() as HTMLElement;\n const popoverTargetTriggers = Array.from(\n root.querySelectorAll(`[popovertarget=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n const commandForTriggers = Array.from(\n root.querySelectorAll(`[commandfor=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n const interestForTriggers = Array.from(\n root.querySelectorAll(`[interestfor=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n return [...popoverTargetTriggers, ...commandForTriggers, ...interestForTriggers];\n }\n\n constructor(private host: T) {\n this.host.addController(this);\n\n const showPopover = this.host.showPopover;\n this.host.showPopover = (options?: ShowPopoverOptions) => {\n if (this.host.isConnected) {\n // provide legacy fallback for source anchor or trigger if not provided, this can happen if the popover is dynamically created in the DOM without the use of the standard popover api or legacy trigger based api\n let source: HTMLElement | Element | null = options?.source ?? null;\n if (!source) {\n if (this.host.anchor) {\n source = getHostAnchor(this.host);\n } else if (this.host.trigger) {\n source = getHostTrigger(this.host, this.host.trigger);\n } else {\n source = globalThis.document.activeElement;\n }\n }\n\n showPopover.call(this.host, { source: source as HTMLElement });\n }\n };\n }\n\n async hostConnected() {\n attachInternals(this.host);\n this.host.popover = this.host.popoverType ?? null;\n await this.host.updateComplete;\n if (!this.host.isConnected) return;\n\n this.host.setAttribute('nve-popover', '');\n this.#updateLegacyTriggers();\n this.#setupLegacyTriggers(); // eslint-disable-line @typescript-eslint/no-floating-promises\n this.#setupModalLightDismiss();\n this.host.inert = this.host.matches(':not(:popover-open)') && !!this.#nativeTriggers.length;\n\n this.host.addEventListener('beforetoggle', this.#onBeforeToggle);\n this.host.addEventListener('toggle', this.#onToggle as EventListener);\n this.host.addEventListener('command', this.#onCommand as EventListener);\n this.host.addEventListener('interest', this.#onInterest as EventListener);\n this.host.addEventListener('loseinterest', this.#onLoseInterest as EventListener);\n }\n\n #interestTimeout: ReturnType<typeof setTimeout> | null = null;\n #closeTimeout: ReturnType<typeof setTimeout> | null = null;\n #observers: MutationObserver[] = [];\n #previousLegacyTrigger: HTMLButtonElement | null = null;\n #hintTrigger: HTMLButtonElement | null = null;\n\n async hostUpdated() {\n this.host.popover = this.host.popoverType ?? null;\n this.#updateLegacyTriggers();\n }\n\n hostDisconnected() {\n this.#observers.forEach(observer => observer.disconnect());\n this.#observers.length = 0;\n this.host.removeEventListener('beforetoggle', this.#onBeforeToggle);\n this.host.removeEventListener('toggle', this.#onToggle as EventListener);\n this.host.removeEventListener('command', this.#onCommand as EventListener);\n this.host.removeEventListener('interest', this.#onInterest as EventListener);\n this.host.removeEventListener('loseinterest', this.#onLoseInterest as EventListener);\n this.host.removeEventListener('pointerdown', this.#onPointerDown);\n this.host.removeEventListener('pointerup', this.#onPointerUp);\n this.#removeHintTrigger();\n this.#clearInterestTimeout();\n this.#clearCloseTimeout();\n }\n\n #setCloseTimeout() {\n this.#clearCloseTimeout();\n if (this.host.closeTimeout) {\n this.#closeTimeout = setTimeout(() => this.host.hidePopover(), this.host.closeTimeout);\n }\n }\n\n #clearCloseTimeout() {\n if (this.#closeTimeout) {\n clearTimeout(this.#closeTimeout);\n this.#closeTimeout = null;\n }\n }\n\n #clearInterestTimeout() {\n if (this.#interestTimeout) {\n clearTimeout(this.#interestTimeout);\n this.#interestTimeout = null;\n }\n }\n\n #parseInterestDelay(): number {\n const style = getComputedStyle(this.host);\n const raw = (style as unknown as { interestDelayStart: string }).interestDelayStart;\n if (!raw) {\n return 0;\n }\n const value = parseFloat(raw);\n return raw.endsWith('ms') ? value : value * 1000;\n }\n\n #pointerdownWithinModal = false;\n\n #setupModalLightDismiss() {\n this.host.removeEventListener('pointerdown', this.#onPointerDown);\n this.host.removeEventListener('pointerup', this.#onPointerUp);\n this.host.addEventListener('pointerdown', this.#onPointerDown);\n this.host.addEventListener('pointerup', this.#onPointerUp);\n }\n\n get #legacyHostTrigger(): HTMLElement | null {\n return this.host.trigger ? (getHostTrigger(this.host, this.host.trigger) as HTMLButtonElement) : null;\n }\n\n /**\n * @deprecated Legacy behavior that allows popovers to show as open by default when using the legacy trigger based api\n */\n async #setupLegacyTriggers() {\n await new Promise(r => requestAnimationFrame(r));\n\n // setup host hidden updates for legacy triggers\n const observer = new MutationObserver(() => {\n if (this.host.isConnected && !this.host.hidden && !this.host.matches(':popover-open')) {\n this.host.showPopover();\n }\n\n if (this.host.isConnected && this.host.hidden && this.host.matches(':popover-open')) {\n this.host.hidePopover();\n }\n });\n observer.observe(this.host, { attributes: true, attributeFilter: ['hidden'] });\n this.#observers.push(observer);\n\n // determine if popover is open by default\n if (\n this.host.isConnected &&\n !this.#nativeTriggers.length &&\n !this.host.hidden &&\n !this.host.matches(':popover-open')\n ) {\n this.host.popover = 'manual';\n this.host.showPopover();\n }\n }\n\n /**\n * @deprecated Legacy behavior that allows popovers to show as open by default when using the legacy trigger based api\n */\n #updateLegacyTriggers() {\n const trigger = this.#legacyHostTrigger as HTMLButtonElement;\n\n if (this.#previousLegacyTrigger && this.#previousLegacyTrigger !== trigger) {\n this.#clearLegacyTrigger(this.#previousLegacyTrigger);\n }\n\n if (this.#hintTrigger && this.#hintTrigger !== trigger) {\n this.#removeHintTrigger();\n }\n\n if (!trigger) {\n this.#previousLegacyTrigger = null;\n return;\n }\n\n if (this.host.popoverType === 'hint') {\n this.#setupHintTrigger(trigger);\n } else {\n this.#setupPopoverTargetTrigger(trigger);\n }\n this.#previousLegacyTrigger = trigger;\n }\n\n #setupHintTrigger(trigger: HTMLButtonElement) {\n if (this.#hintTrigger === trigger) return;\n\n trigger.addEventListener('mouseenter', this.#onHintMouseEnter);\n trigger.addEventListener('mouseleave', this.#onHintMouseLeave);\n trigger.addEventListener('focusout', this.#onHintMouseLeave);\n this.#hintTrigger = trigger;\n }\n\n #setupPopoverTargetTrigger(trigger: HTMLButtonElement) {\n this.#removeHintTrigger();\n this.host.id = this.host.id ? this.host.id : generateId();\n trigger.popoverTargetElement = this.host;\n trigger.setAttribute('popovertarget', this.host.id);\n }\n\n #toggleFocus(open: boolean, target: HTMLElement) {\n if (open) {\n // only focus popover if not the active element and not containing the active element already\n if ((this.host.getRootNode() as Document).activeElement !== this.host && !this.host.shadowRoot!.activeElement) {\n focusElement(this.host);\n }\n } else {\n focusElement(target);\n }\n }\n\n #clearLegacyTrigger(trigger: HTMLButtonElement) {\n trigger.popoverTargetElement = null;\n trigger.removeAttribute('popovertarget');\n if (this.#hintTrigger === trigger) {\n this.#removeHintTrigger();\n }\n }\n\n #removeHintTrigger() {\n this.#hintTrigger?.removeEventListener('mouseenter', this.#onHintMouseEnter);\n this.#hintTrigger?.removeEventListener('mouseleave', this.#onHintMouseLeave);\n this.#hintTrigger?.removeEventListener('focusout', this.#onHintMouseLeave);\n this.#hintTrigger = null;\n }\n\n #onBeforeToggle = (e: ToggleEvent) => {\n if (e.newState === 'open') {\n this.host._internals!.states.add('transition-start');\n }\n };\n\n #onToggle = (e: ToggleEvent) => {\n if (this.host.behaviorTrigger) {\n this.host.hidden = e.newState === 'closed';\n }\n\n if (e.newState === 'open' && this.host.closeTimeout) {\n this.#setCloseTimeout();\n }\n\n if (e.newState === 'closed') {\n this.#clearInterestTimeout();\n this.#clearCloseTimeout();\n }\n\n this.host.inert = this.host.matches(':not(:popover-open)');\n\n if (this.host.modal) {\n this.#toggleFocus(e.newState === 'open', e.target as HTMLElement);\n }\n\n this.host.dispatchEvent(\n new CustomEvent(e.newState === 'open' && e.oldState !== 'open' ? 'open' : 'close', {\n bubbles: true,\n composed: true,\n detail: { trigger: e.source }\n })\n );\n };\n\n #onCommand = (e: CommandEvent) => {\n if (e.command === 'toggle-popover') {\n this.host.togglePopover({ source: e.source as HTMLElement });\n }\n\n if (e.command === 'hide-popover') {\n this.host.hidePopover();\n this.#clearInterestTimeout();\n }\n\n if (e.command === 'show-popover') {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n };\n\n #onInterest = (e: InterestEvent) => {\n const isCustomElement = e.source?.localName.includes('-');\n if (isCustomElement) {\n const interestDelayStart = this.host.openDelay ?? this.#parseInterestDelay();\n if (interestDelayStart) {\n this.#interestTimeout = setTimeout(() => {\n if (this.host.isConnected) {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }, interestDelayStart);\n } else {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }\n };\n\n #onLoseInterest = (e: InterestEvent) => {\n const isCustomElement = e.source?.localName.includes('-');\n if (isCustomElement) {\n this.host.hidePopover();\n }\n\n this.#clearInterestTimeout();\n };\n\n #onPointerDown = (e: PointerEvent) => {\n if (this.host.modal && this.host.matches(':popover-open')) {\n this.#pointerdownWithinModal = clickOutsideElementBounds(e, this.host);\n }\n };\n\n #onPointerUp = (e: PointerEvent) => {\n if (\n this.#pointerdownWithinModal &&\n this.host.popoverDismissible &&\n this.host.modal &&\n this.host.matches(':popover-open') &&\n !hasOpenPopover(this.host) &&\n clickOutsideElementBounds(e, this.host)\n ) {\n this.host.hidePopover();\n }\n };\n\n #onHintMouseEnter = (e: MouseEvent) => {\n this.host.showPopover({ source: e.currentTarget as HT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EtD,KAAK,KAAK,YAAY,GAGxB,KAAKtB,GAAsB;CAC7B;CAEA,MAAkB,MAAoB;EACpC,AAAI,KAAK,KAAK,SAAS,KAAK,KAAK,QAAQ,eAAe,MACtD,KAAKwB,KAA0BC,EAA0B,GAAG,KAAK,IAAI;CAEzE;CAEA,MAAgB,MAAoB;EAClC,AACE,KAAKD,MACL,KAAK,KAAK,sBACV,KAAK,KAAK,SACV,KAAK,KAAK,QAAQ,eAAe,KACjC,CAACE,EAAe,KAAK,IAAI,KACzBD,EAA0B,GAAG,KAAK,IAAI,KAEtC,KAAK,KAAK,YAAY;CAE1B;CAEA,MAAqB,MAAkB;EACrC,KAAK,KAAK,YAAY,EAAE,QAAQ,EAAE,cAA6B,CAAC;CAClE;CAEA,WAA0B;EACxB,KAAK,KAAK,YAAY;CACxB;AACF"}
1
+ {"version":3,"file":"type-native-popover.controller.js","names":["TypeNativePopoverController","#nativeTriggers","root","popoverTargetTriggers","commandForTriggers","interestForTriggers","host","showPopover","source","options","getHostAnchor","getHostTrigger","attachInternals","#updateLegacyTriggers","#setupLegacyTriggers","#setupModalLightDismiss","#onBeforeToggle","#onToggle","#onCommand","#onInterest","#onLoseInterest","#observers","observer","#onPointerDown","#onPointerUp","#removeHintTrigger","#clearInterestTimeout","#clearCloseTimeout","#closeTimeout","#interestTimeout","raw","value","#legacyHostTrigger","r","trigger","#previousLegacyTrigger","#clearLegacyTrigger","#hintTrigger","#setupHintTrigger","#setupPopoverTargetTrigger","#onHintMouseEnter","#onHintMouseLeave","generateId","open","focusElement","target","#setCloseTimeout","#toggleFocus","interestDelayStart","#parseInterestDelay","#pointerdownWithinModal","clickOutsideElementBounds","hasOpenPopover"],"sources":["../../../src/internal/controllers/type-native-popover.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport { clickOutsideElementBounds, generateId } from '../utils/dom.js';\nimport { attachInternals } from '../utils/a11y.js';\nimport { focusElement } from '../utils/focus.js';\nimport { getHostAnchor, getHostTrigger, hasOpenPopover } from './type-native-popover.utils.js';\nimport type { InterestEvent, PopoverType } from '../types/index.js';\n\nexport interface NativePopover extends ReactiveElement {\n anchor?: HTMLElement | string;\n closeTimeout?: number;\n popoverType?: PopoverType;\n modal?: boolean;\n popoverDismissible?: boolean;\n _internals?: ElementInternals;\n\n /** @deprecated */\n trigger?: HTMLElement | string;\n /** @deprecated */\n openDelay?: number;\n /** @deprecated */\n behaviorTrigger?: boolean;\n}\n\n/**\n * https://open-ui.org/components/popup.research.explainer\n */\nexport class TypeNativePopoverController<T extends NativePopover> implements ReactiveController {\n get #nativeTriggers(): HTMLElement[] {\n const root = this.host.getRootNode() as HTMLElement;\n const popoverTargetTriggers = Array.from(\n root.querySelectorAll(`[popovertarget=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n const commandForTriggers = Array.from(\n root.querySelectorAll(`[commandfor=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n const interestForTriggers = Array.from(\n root.querySelectorAll(`[interestfor=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n return [...popoverTargetTriggers, ...commandForTriggers, ...interestForTriggers];\n }\n\n constructor(private host: T) {\n this.host.addController(this);\n\n const showPopover = this.host.showPopover;\n this.host.showPopover = (options?: ShowPopoverOptions) => {\n if (this.host.isConnected) {\n // provide legacy fallback for source anchor or trigger if not provided, this can happen if the popover is dynamically created in the DOM without the use of the standard popover api or legacy trigger based api\n let source: HTMLElement | Element | null = options?.source ?? null;\n if (!source) {\n if (this.host.anchor) {\n source = getHostAnchor(this.host);\n } else if (this.host.trigger) {\n source = getHostTrigger(this.host, this.host.trigger);\n } else {\n source = globalThis.document.activeElement;\n }\n }\n\n showPopover.call(this.host, { source: source as HTMLElement });\n }\n };\n }\n\n async hostConnected() {\n attachInternals(this.host);\n this.host.popover = this.host.popoverType ?? null;\n await this.host.updateComplete;\n if (!this.host.isConnected) return;\n\n this.host.setAttribute('nve-popover', '');\n this.#updateLegacyTriggers();\n this.#setupLegacyTriggers(); // eslint-disable-line @typescript-eslint/no-floating-promises\n this.#setupModalLightDismiss();\n this.host.inert = this.host.matches(':not(:popover-open)') && !!this.#nativeTriggers.length;\n\n this.host.addEventListener('beforetoggle', this.#onBeforeToggle);\n this.host.addEventListener('toggle', this.#onToggle as EventListener);\n this.host.addEventListener('command', this.#onCommand as EventListener);\n this.host.addEventListener('interest', this.#onInterest as EventListener);\n this.host.addEventListener('loseinterest', this.#onLoseInterest as EventListener);\n }\n\n #interestTimeout: ReturnType<typeof setTimeout> | null = null;\n #closeTimeout: ReturnType<typeof setTimeout> | null = null;\n #observers: MutationObserver[] = [];\n #previousLegacyTrigger: HTMLButtonElement | null = null;\n #hintTrigger: HTMLButtonElement | null = null;\n\n async hostUpdated() {\n this.host.popover = this.host.popoverType ?? null;\n this.#updateLegacyTriggers();\n }\n\n hostDisconnected() {\n this.#observers.forEach(observer => observer.disconnect());\n this.#observers.length = 0;\n this.host.removeEventListener('beforetoggle', this.#onBeforeToggle);\n this.host.removeEventListener('toggle', this.#onToggle as EventListener);\n this.host.removeEventListener('command', this.#onCommand as EventListener);\n this.host.removeEventListener('interest', this.#onInterest as EventListener);\n this.host.removeEventListener('loseinterest', this.#onLoseInterest as EventListener);\n this.host.removeEventListener('pointerdown', this.#onPointerDown);\n this.host.removeEventListener('pointerup', this.#onPointerUp);\n this.#removeHintTrigger();\n this.#clearInterestTimeout();\n this.#clearCloseTimeout();\n }\n\n #setCloseTimeout() {\n this.#clearCloseTimeout();\n if (this.host.closeTimeout) {\n this.#closeTimeout = setTimeout(() => this.host.hidePopover(), this.host.closeTimeout);\n }\n }\n\n #clearCloseTimeout() {\n if (this.#closeTimeout) {\n clearTimeout(this.#closeTimeout);\n this.#closeTimeout = null;\n }\n }\n\n #clearInterestTimeout() {\n if (this.#interestTimeout) {\n clearTimeout(this.#interestTimeout);\n this.#interestTimeout = null;\n }\n }\n\n #parseInterestDelay(): number {\n const style = getComputedStyle(this.host);\n const raw = (style as unknown as { interestDelayStart: string }).interestDelayStart;\n if (!raw) {\n return 0;\n }\n const value = parseFloat(raw);\n return raw.endsWith('ms') ? value : value * 1000;\n }\n\n #pointerdownWithinModal = false;\n\n #setupModalLightDismiss() {\n this.host.removeEventListener('pointerdown', this.#onPointerDown);\n this.host.removeEventListener('pointerup', this.#onPointerUp);\n this.host.addEventListener('pointerdown', this.#onPointerDown);\n this.host.addEventListener('pointerup', this.#onPointerUp);\n }\n\n get #legacyHostTrigger(): HTMLElement | null {\n return this.host.trigger ? (getHostTrigger(this.host, this.host.trigger) as HTMLButtonElement) : null;\n }\n\n /**\n * @deprecated Legacy behavior that allows popovers to show as open by default when using the legacy trigger based api\n */\n async #setupLegacyTriggers() {\n await new Promise(r => requestAnimationFrame(r));\n\n // setup host hidden updates for legacy triggers\n const observer = new MutationObserver(() => {\n if (this.host.isConnected && !this.host.hidden && !this.host.matches(':popover-open')) {\n this.host.showPopover();\n }\n\n if (this.host.isConnected && this.host.hidden && this.host.matches(':popover-open')) {\n this.host.hidePopover();\n }\n });\n observer.observe(this.host, { attributes: true, attributeFilter: ['hidden'] });\n this.#observers.push(observer);\n\n // determine if popover is open by default\n if (\n this.host.isConnected &&\n !this.#nativeTriggers.length &&\n !this.host.hidden &&\n !this.host.matches(':popover-open')\n ) {\n this.host.popover = 'manual';\n this.host.showPopover();\n }\n }\n\n /**\n * @deprecated Legacy behavior that allows popovers to show as open by default when using the legacy trigger based api\n */\n #updateLegacyTriggers() {\n const trigger = this.#legacyHostTrigger as HTMLButtonElement;\n\n if (this.#previousLegacyTrigger && this.#previousLegacyTrigger !== trigger) {\n this.#clearLegacyTrigger(this.#previousLegacyTrigger);\n }\n\n if (this.#hintTrigger && this.#hintTrigger !== trigger) {\n this.#removeHintTrigger();\n }\n\n if (!trigger) {\n this.#previousLegacyTrigger = null;\n return;\n }\n\n if (this.host.popoverType === 'hint') {\n this.#setupHintTrigger(trigger);\n } else {\n this.#setupPopoverTargetTrigger(trigger);\n }\n this.#previousLegacyTrigger = trigger;\n }\n\n #setupHintTrigger(trigger: HTMLButtonElement) {\n if (this.#hintTrigger === trigger) return;\n\n trigger.addEventListener('mouseenter', this.#onHintMouseEnter);\n trigger.addEventListener('mouseleave', this.#onHintMouseLeave);\n trigger.addEventListener('focusout', this.#onHintMouseLeave);\n this.#hintTrigger = trigger;\n }\n\n #setupPopoverTargetTrigger(trigger: HTMLButtonElement) {\n this.#removeHintTrigger();\n this.host.id = this.host.id ? this.host.id : generateId();\n trigger.popoverTargetElement = this.host;\n trigger.setAttribute('popovertarget', this.host.id);\n }\n\n #toggleFocus(open: boolean, target: HTMLElement) {\n if (open) {\n // only focus popover if not the active element and not containing the active element already\n if ((this.host.getRootNode() as Document).activeElement !== this.host && !this.host.shadowRoot!.activeElement) {\n focusElement(this.host);\n }\n } else {\n focusElement(target);\n }\n }\n\n #clearLegacyTrigger(trigger: HTMLButtonElement) {\n trigger.popoverTargetElement = null;\n trigger.removeAttribute('popovertarget');\n if (this.#hintTrigger === trigger) {\n this.#removeHintTrigger();\n }\n }\n\n #removeHintTrigger() {\n this.#hintTrigger?.removeEventListener('mouseenter', this.#onHintMouseEnter);\n this.#hintTrigger?.removeEventListener('mouseleave', this.#onHintMouseLeave);\n this.#hintTrigger?.removeEventListener('focusout', this.#onHintMouseLeave);\n this.#hintTrigger = null;\n }\n\n #onBeforeToggle = (e: ToggleEvent) => {\n if (e.newState === 'open') {\n this.host._internals!.states.add('transition-start');\n }\n };\n\n #onToggle = (e: ToggleEvent) => {\n if (this.host.behaviorTrigger) {\n this.host.hidden = e.newState === 'closed';\n }\n\n if (e.newState === 'open' && this.host.closeTimeout) {\n this.#setCloseTimeout();\n }\n\n if (e.newState === 'closed') {\n this.#clearInterestTimeout();\n this.#clearCloseTimeout();\n }\n\n this.host.inert = this.host.matches(':not(:popover-open)');\n\n if (this.host.modal) {\n this.#toggleFocus(e.newState === 'open', e.target as HTMLElement);\n }\n\n this.host.dispatchEvent(\n new CustomEvent(e.newState === 'open' && e.oldState !== 'open' ? 'open' : 'close', {\n bubbles: true,\n composed: true,\n detail: { trigger: e.source }\n })\n );\n };\n\n #onCommand = (e: CommandEvent) => {\n if (e.command === 'toggle-popover') {\n this.host.togglePopover({ source: e.source as HTMLElement });\n }\n\n if (e.command === 'hide-popover') {\n this.host.hidePopover();\n this.#clearInterestTimeout();\n }\n\n if (e.command === 'show-popover') {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n };\n\n #onInterest = (e: InterestEvent) => {\n const isCustomElement = e.source?.localName.includes('-');\n if (isCustomElement) {\n const interestDelayStart = this.host.openDelay ?? this.#parseInterestDelay();\n if (interestDelayStart) {\n this.#interestTimeout = setTimeout(() => {\n if (this.host.isConnected) {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }, interestDelayStart);\n } else {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }\n };\n\n #onLoseInterest = (e: InterestEvent) => {\n const isCustomElement = e.source?.localName.includes('-');\n if (isCustomElement) {\n this.host.hidePopover();\n }\n\n this.#clearInterestTimeout();\n };\n\n #onPointerDown = (e: PointerEvent) => {\n if (this.host.modal && this.host.matches(':popover-open')) {\n this.#pointerdownWithinModal = clickOutsideElementBounds(e, this.host);\n }\n };\n\n #onPointerUp = (e: PointerEvent) => {\n if (\n this.#pointerdownWithinModal &&\n this.host.popoverDismissible &&\n this.host.modal &&\n this.host.matches(':popover-open') &&\n !hasOpenPopover(this.host) &&\n clickOutsideElementBounds(e, this.host)\n ) {\n this.host.hidePopover();\n }\n };\n\n #onHintMouseEnter = (e: MouseEvent) => {\n this.host.showPopover({ source: e.currentTarget as HTMLElement });\n };\n\n #onHintMouseLeave = () => {\n this.host.hidePopover();\n };\n}\n"],"mappings":";;;;;AA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;EACpC,AAAI,KAAK,KAAK,SAAS,KAAK,KAAK,QAAQ,eAAe,MACtD,KAAKwB,KAA0BC,EAA0B,GAAG,KAAK,IAAI;CAEzE;CAEA,MAAgB,MAAoB;EAClC,AACE,KAAKD,MACL,KAAK,KAAK,sBACV,KAAK,KAAK,SACV,KAAK,KAAK,QAAQ,eAAe,KACjC,CAACE,EAAe,KAAK,IAAI,KACzBD,EAA0B,GAAG,KAAK,IAAI,KAEtC,KAAK,KAAK,YAAY;CAE1B;CAEA,MAAqB,MAAkB;EACrC,KAAK,KAAK,YAAY,EAAE,QAAQ,EAAE,cAA6B,CAAC;CAClE;CAEA,WAA0B;EACxB,KAAK,KAAK,YAAY;CACxB;AACF"}
@@ -2,6 +2,5 @@ export declare function associateAnchor(host: HTMLElement, anchor: HTMLElement):
2
2
  export declare function getHostTrigger(element: HTMLElement, trigger: HTMLElement | string): HTMLButtonElement;
3
3
  export declare function getHostAnchor(host: HTMLElement & {
4
4
  anchor?: HTMLElement | string;
5
- _activeTrigger?: HTMLElement;
6
5
  }): HTMLElement;
7
6
  export declare function hasOpenPopover(host: HTMLElement): boolean;
@@ -6,7 +6,7 @@ function r(e, t) {
6
6
  return typeof t == "string" ? n(e.parentNode).filter((e) => e?.id !== "").find((e) => e.id === t) ?? globalThis.document.body : t;
7
7
  }
8
8
  function i(r) {
9
- let i = r.anchor ?? r._activeTrigger;
9
+ let i = r.anchor;
10
10
  if (typeof i == "string" && i?.length) {
11
11
  let a = n(r.parentNode).find((e) => e.id === i);
12
12
  return a || e.warn(t(i)), a ?? globalThis.document.body;
@@ -1 +1 @@
1
- {"version":3,"file":"type-native-popover.utils.js","names":["getHostTrigger","trigger","getFlattenedDOMTree","element","el","getHostAnchor","anchor","host","match","LogService","getIdMatchNotFoundWarning","hasOpenPopover"],"sources":["../../../src/internal/controllers/type-native-popover.utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { LogService } from '../services/log.service.js';\nimport { getIdMatchNotFoundWarning } from '../utils/audit-logs.js';\nimport { generateId, getFlattenedDOMTree, getAnchorNames, appendAnchorName } from '../utils/dom.js';\n\nexport function associateAnchor(host: HTMLElement, anchor: HTMLElement) {\n const anchorNames = getAnchorNames(anchor);\n let anchorId = anchorNames.find(name => name.startsWith('--_'));\n if (!anchorId) {\n anchorId = `--${anchor.id && !anchor.id.includes(':') ? `_${anchor.id}` : generateId()}`;\n appendAnchorName(anchor, anchorId);\n }\n host.style.positionAnchor = anchorId;\n}\n\nexport function getHostTrigger(element: HTMLElement, trigger: HTMLElement | string) {\n if (typeof trigger === 'string') {\n return (\n (getFlattenedDOMTree(element.parentNode as HTMLElement)\n .filter(el => el?.id !== '')\n .find(el => el.id === trigger) as HTMLButtonElement) ?? globalThis.document.body\n );\n } else {\n return trigger as HTMLButtonElement;\n }\n}\n\nexport function getHostAnchor(host: HTMLElement & { anchor?: HTMLElement | string; _activeTrigger?: HTMLElement }) {\n const anchor = host.anchor ?? host._activeTrigger;\n\n if (typeof anchor === 'string' && anchor?.length) {\n const match = getFlattenedDOMTree(host.parentNode as HTMLElement).find(el => el.id === anchor);\n\n if (!match) {\n LogService.warn(getIdMatchNotFoundWarning(anchor));\n }\n\n return match ?? globalThis.document.body;\n } else if (anchor && anchor !== globalThis.document.body) {\n return anchor as HTMLElement;\n } else {\n return globalThis.document.body;\n }\n}\n\nexport function hasOpenPopover(host: HTMLElement) {\n return !!getFlattenedDOMTree(host).filter(e => e.popover && e.matches(':popover-open')).length;\n}\n"],"mappings":";;;;AAiBA,SAAgBA,EAAe,GAAsB,GAA+B;CAQhF,OAPE,OAAOC,KAAY,WAElBC,EAAoBC,EAAQ,UAAyB,CAAC,CACpD,QAAO,MAAMC,GAAI,OAAO,EAAE,CAAC,CAC3B,MAAK,MAAMA,EAAG,OAAOH,CAAO,KAA2B,WAAW,SAAS,OAGzEA;AAEX;AAEA,SAAgBI,EAAc,GAAqF;CACjH,IAAMC,IAASC,EAAK,UAAUA,EAAK;CAEnC,IAAI,OAAOD,KAAW,YAAYA,GAAQ,QAAQ;EAChD,IAAME,IAAQN,EAAoBK,EAAK,UAAyB,CAAC,CAAC,MAAK,MAAMH,EAAG,OAAOE,CAAM;EAM7F,OAJKE,KACHC,EAAW,KAAKC,EAA0BJ,CAAM,CAAC,GAG5CE,KAAS,WAAW,SAAS;CACtC;CAGE,OAHSF,KAAUA,MAAW,WAAW,SAAS,OAC3CA,IAEA,WAAW,SAAS;AAE/B;AAEA,SAAgBK,EAAe,GAAmB;CAChD,OAAO,CAAC,CAACT,EAAoBK,CAAI,CAAC,CAAC,QAAO,MAAK,EAAE,WAAW,EAAE,QAAQ,eAAe,CAAC,CAAC,CAAC;AAC1F"}
1
+ {"version":3,"file":"type-native-popover.utils.js","names":["getHostTrigger","trigger","getFlattenedDOMTree","element","el","getHostAnchor","anchor","host","match","LogService","getIdMatchNotFoundWarning","hasOpenPopover"],"sources":["../../../src/internal/controllers/type-native-popover.utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { LogService } from '../services/log.service.js';\nimport { getIdMatchNotFoundWarning } from '../utils/audit-logs.js';\nimport { generateId, getFlattenedDOMTree, getAnchorNames, appendAnchorName } from '../utils/dom.js';\n\nexport function associateAnchor(host: HTMLElement, anchor: HTMLElement) {\n const anchorNames = getAnchorNames(anchor);\n let anchorId = anchorNames.find(name => name.startsWith('--_'));\n if (!anchorId) {\n anchorId = `--${anchor.id && !anchor.id.includes(':') ? `_${anchor.id}` : generateId()}`;\n appendAnchorName(anchor, anchorId);\n }\n host.style.positionAnchor = anchorId;\n}\n\nexport function getHostTrigger(element: HTMLElement, trigger: HTMLElement | string) {\n if (typeof trigger === 'string') {\n return (\n (getFlattenedDOMTree(element.parentNode as HTMLElement)\n .filter(el => el?.id !== '')\n .find(el => el.id === trigger) as HTMLButtonElement) ?? globalThis.document.body\n );\n } else {\n return trigger as HTMLButtonElement;\n }\n}\n\nexport function getHostAnchor(host: HTMLElement & { anchor?: HTMLElement | string }) {\n const anchor = host.anchor;\n\n if (typeof anchor === 'string' && anchor?.length) {\n const match = getFlattenedDOMTree(host.parentNode as HTMLElement).find(el => el.id === anchor);\n\n if (!match) {\n LogService.warn(getIdMatchNotFoundWarning(anchor));\n }\n\n return match ?? globalThis.document.body;\n } else if (anchor && anchor !== globalThis.document.body) {\n return anchor as HTMLElement;\n } else {\n return globalThis.document.body;\n }\n}\n\nexport function hasOpenPopover(host: HTMLElement) {\n return !!getFlattenedDOMTree(host).filter(e => e.popover && e.matches(':popover-open')).length;\n}\n"],"mappings":";;;;AAiBA,SAAgBA,EAAe,GAAsB,GAA+B;CAQhF,OAPE,OAAOC,KAAY,WAElBC,EAAoBC,EAAQ,UAAyB,CAAC,CACpD,QAAO,MAAMC,GAAI,OAAO,EAAE,CAAC,CAC3B,MAAK,MAAMA,EAAG,OAAOH,CAAO,KAA2B,WAAW,SAAS,OAGzEA;AAEX;AAEA,SAAgBI,EAAc,GAAuD;CACnF,IAAMC,IAASC,EAAK;CAEpB,IAAI,OAAOD,KAAW,YAAYA,GAAQ,QAAQ;EAChD,IAAME,IAAQN,EAAoBK,EAAK,UAAyB,CAAC,CAAC,MAAK,MAAMH,EAAG,OAAOE,CAAM;EAM7F,OAJKE,KACHC,EAAW,KAAKC,EAA0BJ,CAAM,CAAC,GAG5CE,KAAS,WAAW,SAAS;CACtC;CAGE,OAHSF,KAAUA,MAAW,WAAW,SAAS,OAC3CA,IAEA,WAAW,SAAS;AAE/B;AAEA,SAAgBK,EAAe,GAAmB;CAChD,OAAO,CAAC,CAACT,EAAoBK,CAAI,CAAC,CAAC,QAAO,MAAK,EAAE,WAAW,EAAE,QAAQ,eAAe,CAAC,CAAC,CAAC;AAC1F"}