@jimka/typescript-ui 0.3.0 → 0.4.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 (221) hide show
  1. package/dist/lib/{AbstractBooleanInput-C3O4kv7_.js → AbstractBooleanInput-DSwKBAic.js} +2 -2
  2. package/dist/lib/{AbstractBooleanInput-C3O4kv7_.js.map → AbstractBooleanInput-DSwKBAic.js.map} +1 -1
  3. package/dist/lib/{AbstractInput-DFWniHqq.js → AbstractInput-BmWGJTs1.js} +2 -2
  4. package/dist/lib/{AbstractInput-DFWniHqq.js.map → AbstractInput-BmWGJTs1.js.map} +1 -1
  5. package/dist/lib/{AnchorConstraints-CSUcj8Wx.js → AnchorConstraints-CVrMP9rz.js} +2 -2
  6. package/dist/lib/{AnchorConstraints-CSUcj8Wx.js.map → AnchorConstraints-CVrMP9rz.js.map} +1 -1
  7. package/dist/lib/{AnimatedDropdown-e9urCXK1.js → AnimatedDropdown-DKas40B-.js} +2 -2
  8. package/dist/lib/{AnimatedDropdown-e9urCXK1.js.map → AnimatedDropdown-DKas40B-.js.map} +1 -1
  9. package/dist/lib/Border-Bz29z-_7.js +2 -0
  10. package/dist/lib/Border-Bz29z-_7.js.map +1 -0
  11. package/dist/lib/Button-bjpWruNc.js +2 -0
  12. package/dist/lib/{Button-B36rBMKC.js.map → Button-bjpWruNc.js.map} +1 -1
  13. package/dist/lib/{Card-P8iUH2-C.js → Card-BdfbvOD_.js} +2 -2
  14. package/dist/lib/{Card-P8iUH2-C.js.map → Card-BdfbvOD_.js.map} +1 -1
  15. package/dist/lib/ComboBox-CBw2VLLN.js +2 -0
  16. package/dist/lib/ComboBox-CBw2VLLN.js.map +1 -0
  17. package/dist/lib/Component-DHqrPwAw.js +2 -0
  18. package/dist/lib/Component-DHqrPwAw.js.map +1 -0
  19. package/dist/lib/Container-CAQpj4yb.js +2 -0
  20. package/dist/lib/{Container-xUbHk6l_.js.map → Container-CAQpj4yb.js.map} +1 -1
  21. package/dist/lib/{DOM-BeR95tE8.js → DOM-67StIm5G.js} +2 -2
  22. package/dist/lib/DOM-67StIm5G.js.map +1 -0
  23. package/dist/lib/DragChain-CYGuT7OA.js +2 -0
  24. package/dist/lib/DragChain-CYGuT7OA.js.map +1 -0
  25. package/dist/lib/DragManager-CHWCe3-8.js +2 -0
  26. package/dist/lib/DragManager-CHWCe3-8.js.map +1 -0
  27. package/dist/lib/{FieldDecorator-BaTGfKiW.js → FieldDecorator-CgAGcqCk.js} +2 -2
  28. package/dist/lib/{FieldDecorator-BaTGfKiW.js.map → FieldDecorator-CgAGcqCk.js.map} +1 -1
  29. package/dist/lib/{Fit-E-EIZv1k.js → Fit-DIYt2aQB.js} +2 -2
  30. package/dist/lib/{Fit-E-EIZv1k.js.map → Fit-DIYt2aQB.js.map} +1 -1
  31. package/dist/lib/Glyph-CeAIWyPB.js +2 -0
  32. package/dist/lib/Glyph-CeAIWyPB.js.map +1 -0
  33. package/dist/lib/{Grid-BXS2T8MT.js → Grid-ViA0joow.js} +2 -2
  34. package/dist/lib/{Grid-BXS2T8MT.js.map → Grid-ViA0joow.js.map} +1 -1
  35. package/dist/lib/GridConstraints-B1rxCw9B.js +2 -0
  36. package/dist/lib/GridConstraints-B1rxCw9B.js.map +1 -0
  37. package/dist/lib/Header-mKaqgfat.js +2 -0
  38. package/dist/lib/Header-mKaqgfat.js.map +1 -0
  39. package/dist/lib/IconText-BqwXA82-.js +2 -0
  40. package/dist/lib/IconText-BqwXA82-.js.map +1 -0
  41. package/dist/lib/{LayoutSerialization-D1OHmxSB.js → LayoutSerialization-D82UtnDD.js} +2 -2
  42. package/dist/lib/{LayoutSerialization-D1OHmxSB.js.map → LayoutSerialization-D82UtnDD.js.map} +1 -1
  43. package/dist/lib/LayoutSizes-DG9aW9k6.js +2 -0
  44. package/dist/lib/LayoutSizes-DG9aW9k6.js.map +1 -0
  45. package/dist/lib/List-CUntS8ux.js +2 -0
  46. package/dist/lib/List-CUntS8ux.js.map +1 -0
  47. package/dist/lib/MemoryStore-DT6iWWco.js.map +1 -1
  48. package/dist/lib/Menu-B_-SQj72.js +2 -0
  49. package/dist/lib/Menu-B_-SQj72.js.map +1 -0
  50. package/dist/lib/{MenuButton-Bjm1OyB-.js → MenuButton-C79l8Ysf.js} +2 -2
  51. package/dist/lib/{MenuButton-Bjm1OyB-.js.map → MenuButton-C79l8Ysf.js.map} +1 -1
  52. package/dist/lib/{Panel-D9lTLGqP.js → Panel-D2X33qR6.js} +2 -2
  53. package/dist/lib/{Panel-D9lTLGqP.js.map → Panel-D2X33qR6.js.map} +1 -1
  54. package/dist/lib/Position-Ck_KD4cR.js +2 -0
  55. package/dist/lib/Position-Ck_KD4cR.js.map +1 -0
  56. package/dist/lib/{ProgressSpinner-glv-29eK.js → ProgressSpinner-DCyq02pd.js} +2 -2
  57. package/dist/lib/{ProgressSpinner-glv-29eK.js.map → ProgressSpinner-DCyq02pd.js.map} +1 -1
  58. package/dist/lib/{RadioButton-R4S3c9WD.js → RadioButton-BJIAQkII.js} +2 -2
  59. package/dist/lib/{RadioButton-R4S3c9WD.js.map → RadioButton-BJIAQkII.js.map} +1 -1
  60. package/dist/lib/{RovingTabIndex-Dgt01LOE.js → RovingTabIndex-DFJyoveq.js} +2 -2
  61. package/dist/lib/{RovingTabIndex-Dgt01LOE.js.map → RovingTabIndex-DFJyoveq.js.map} +1 -1
  62. package/dist/lib/Scrollbar-CSFK-Y57.js +2 -0
  63. package/dist/lib/Scrollbar-CSFK-Y57.js.map +1 -0
  64. package/dist/lib/Slider-C-kQQYCj.js +2 -0
  65. package/dist/lib/Slider-C-kQQYCj.js.map +1 -0
  66. package/dist/lib/{Spacer-B57i2-_G.js → Spacer-D159iJy9.js} +2 -2
  67. package/dist/lib/{Spacer-B57i2-_G.js.map → Spacer-D159iJy9.js.map} +1 -1
  68. package/dist/lib/TabButton-CHkXBgCj.js +2 -0
  69. package/dist/lib/TabButton-CHkXBgCj.js.map +1 -0
  70. package/dist/lib/{Text-Bni4icFY.js → Text-D5pg7taZ.js} +2 -2
  71. package/dist/lib/{Text-Bni4icFY.js.map → Text-D5pg7taZ.js.map} +1 -1
  72. package/dist/lib/Tooltip-DzK6LxUt.js +3 -0
  73. package/dist/lib/{Tooltip-BUy6uFKN.js.map → Tooltip-DzK6LxUt.js.map} +1 -1
  74. package/dist/lib/VBox-BNegDPs_.js +2 -0
  75. package/dist/lib/VBox-BNegDPs_.js.map +1 -0
  76. package/dist/lib/VirtualScroller-zQr-vKrO.js +2 -0
  77. package/dist/lib/VirtualScroller-zQr-vKrO.js.map +1 -0
  78. package/dist/lib/component/button.es.js +1 -1
  79. package/dist/lib/component/chart.es.js +1 -1
  80. package/dist/lib/component/chart.es.js.map +1 -1
  81. package/dist/lib/component/container.es.js +1 -1
  82. package/dist/lib/component/container.es.js.map +1 -1
  83. package/dist/lib/component/diagram.es.js +1 -1
  84. package/dist/lib/component/diagram.es.js.map +1 -1
  85. package/dist/lib/component/display.es.js +1 -1
  86. package/dist/lib/component/display.es.js.map +1 -1
  87. package/dist/lib/component/editor.es.js +2 -2
  88. package/dist/lib/component/editor.es.js.map +1 -1
  89. package/dist/lib/component/input.es.js +1 -1
  90. package/dist/lib/component/input.es.js.map +1 -1
  91. package/dist/lib/component/list.es.js +1 -1
  92. package/dist/lib/component/list.es.js.map +1 -1
  93. package/dist/lib/component/menubar.es.js +1 -1
  94. package/dist/lib/component/menubar.es.js.map +1 -1
  95. package/dist/lib/component/table.es.js +2 -2
  96. package/dist/lib/component/table.es.js.map +1 -1
  97. package/dist/lib/component/tree.es.js +1 -1
  98. package/dist/lib/component/tree.es.js.map +1 -1
  99. package/dist/lib/core.es.js +1 -1
  100. package/dist/lib/core.es.js.map +1 -1
  101. package/dist/lib/layout.es.js +1 -1
  102. package/dist/lib/layout.es.js.map +1 -1
  103. package/dist/lib/overlay.es.js +1 -1
  104. package/dist/lib/overlay.es.js.map +1 -1
  105. package/dist/lib/primitive.es.js +1 -1
  106. package/dist/lib/router.es.js +1 -1
  107. package/dist/lib/selectionsEqual-4r5R7pTK.js +2 -0
  108. package/dist/lib/selectionsEqual-4r5R7pTK.js.map +1 -0
  109. package/dist/lib/types/component/button/TabCloseButton.d.ts +1 -1
  110. package/dist/lib/types/component/container/CollapseButton.d.ts +1 -1
  111. package/dist/lib/types/component/container/DialogBackdrop.d.ts +1 -1
  112. package/dist/lib/types/component/container/MenuItem.d.ts +4 -0
  113. package/dist/lib/types/component/container/MenuSeparator.d.ts +1 -1
  114. package/dist/lib/types/component/container/Scrollbar.d.ts +1 -0
  115. package/dist/lib/types/component/container/SplitGutter.d.ts +2 -2
  116. package/dist/lib/types/component/container/StatusBar.d.ts +1 -1
  117. package/dist/lib/types/component/container/VirtualScroller.d.ts +1 -0
  118. package/dist/lib/types/component/container/WindowBorder.d.ts +1 -1
  119. package/dist/lib/types/component/diagram/DiagramNode.d.ts +1 -1
  120. package/dist/lib/types/component/display/Canvas.d.ts +8 -2
  121. package/dist/lib/types/component/display/Glyph.d.ts +2 -1
  122. package/dist/lib/types/component/display/Header.d.ts +1 -1
  123. package/dist/lib/types/component/display/IconLabel.d.ts +1 -1
  124. package/dist/lib/types/component/display/IconText.d.ts +1 -1
  125. package/dist/lib/types/component/display/Image.d.ts +1 -1
  126. package/dist/lib/types/component/display/Video.d.ts +1 -1
  127. package/dist/lib/types/component/display/WebGLCanvas.d.ts +8 -2
  128. package/dist/lib/types/component/editor/CodeEditor.d.ts +1 -1
  129. package/dist/lib/types/component/input/AbstractPickerField.d.ts +1 -1
  130. package/dist/lib/types/component/input/AutoCompleteDropdown.d.ts +1 -1
  131. package/dist/lib/types/component/input/Link.d.ts +1 -1
  132. package/dist/lib/types/component/input/NumberSpinner.d.ts +1 -1
  133. package/dist/lib/types/component/input/PasswordField.d.ts +1 -1
  134. package/dist/lib/types/component/input/SpinButton.d.ts +1 -1
  135. package/dist/lib/types/component/input/TextArea.d.ts +1 -1
  136. package/dist/lib/types/component/input/TextField.d.ts +3 -1
  137. package/dist/lib/types/component/input/UsernameField.d.ts +1 -1
  138. package/dist/lib/types/component/list/AbstractMarkerList.d.ts +9 -1
  139. package/dist/lib/types/component/list/BulletedList.d.ts +1 -0
  140. package/dist/lib/types/component/list/ListItem.d.ts +10 -4
  141. package/dist/lib/types/component/list/NumberedList.d.ts +1 -0
  142. package/dist/lib/types/component/menubar/MenuBarButton.d.ts +1 -1
  143. package/dist/lib/types/component/menubar/ToolBar.d.ts +1 -1
  144. package/dist/lib/types/component/menubar/ToolBarSeparator.d.ts +1 -1
  145. package/dist/lib/types/component/shared/VirtualRowView.d.ts +13 -1
  146. package/dist/lib/types/component/table/Body.d.ts +15 -2
  147. package/dist/lib/types/component/table/CellGeometry.d.ts +6 -0
  148. package/dist/lib/types/component/table/Column.d.ts +4 -0
  149. package/dist/lib/types/component/table/ColumnConfig.d.ts +3 -0
  150. package/dist/lib/types/component/table/Header.d.ts +24 -2
  151. package/dist/lib/types/component/table/Row.d.ts +13 -2
  152. package/dist/lib/types/component/table/Table.d.ts +25 -4
  153. package/dist/lib/types/component/table/TableExporter.d.ts +1 -1
  154. package/dist/lib/types/component/table/TablePanel.d.ts +2 -1
  155. package/dist/lib/types/component/table/cell/Cell.d.ts +1 -1
  156. package/dist/lib/types/component/table/cell/Header.d.ts +3 -0
  157. package/dist/lib/types/component/table/index.d.ts +1 -1
  158. package/dist/lib/types/component/tree/Tree.d.ts +1 -0
  159. package/dist/lib/types/core/Aria.d.ts +1 -1
  160. package/dist/lib/types/core/Body.d.ts +8 -2
  161. package/dist/lib/types/core/Component.d.ts +6 -0
  162. package/dist/lib/types/core/DOM.d.ts +4 -0
  163. package/dist/lib/types/core/DragChain.d.ts +3 -0
  164. package/dist/lib/types/core/Favicon.d.ts +7 -0
  165. package/dist/lib/types/core/FirstLayoutGate.d.ts +5 -0
  166. package/dist/lib/types/core/Theme.d.ts +1 -0
  167. package/dist/lib/types/core/Util.d.ts +1 -0
  168. package/dist/lib/types/core/index.d.ts +2 -0
  169. package/dist/lib/types/layout/Accordion.d.ts +0 -1
  170. package/dist/lib/types/layout/FlowLayout.d.ts +4 -0
  171. package/dist/lib/types/layout/HFlow.d.ts +3 -0
  172. package/dist/lib/types/layout/VFlow.d.ts +1 -0
  173. package/dist/lib/types/overlay/AbstractWindow.d.ts +1 -1
  174. package/dist/lib/types/overlay/Dock.d.ts +1 -0
  175. package/dist/lib/types/overlay/DropZoneOverlay.d.ts +1 -0
  176. package/dist/lib/types/overlay/Popover.d.ts +1 -1
  177. package/dist/lib/validation.es.js +1 -1
  178. package/llms.txt +1 -0
  179. package/package.json +2 -2
  180. package/dist/lib/Border-Dq6dXkmS.js +0 -2
  181. package/dist/lib/Border-Dq6dXkmS.js.map +0 -1
  182. package/dist/lib/Button-B36rBMKC.js +0 -2
  183. package/dist/lib/ComboBox-BjAhXXkY.js +0 -2
  184. package/dist/lib/ComboBox-BjAhXXkY.js.map +0 -1
  185. package/dist/lib/Component-CHTzJxEf.js +0 -2
  186. package/dist/lib/Component-CHTzJxEf.js.map +0 -1
  187. package/dist/lib/Container-xUbHk6l_.js +0 -2
  188. package/dist/lib/DOM-BeR95tE8.js.map +0 -1
  189. package/dist/lib/DragManager-T5Oljd0F.js +0 -2
  190. package/dist/lib/DragManager-T5Oljd0F.js.map +0 -1
  191. package/dist/lib/Glyph-CnNslL95.js +0 -2
  192. package/dist/lib/Glyph-CnNslL95.js.map +0 -1
  193. package/dist/lib/GridConstraints-D_kbd-h2.js +0 -2
  194. package/dist/lib/GridConstraints-D_kbd-h2.js.map +0 -1
  195. package/dist/lib/HBox-Dm3xgsDE.js +0 -2
  196. package/dist/lib/HBox-Dm3xgsDE.js.map +0 -1
  197. package/dist/lib/Header-CqFc2OUx.js +0 -2
  198. package/dist/lib/Header-CqFc2OUx.js.map +0 -1
  199. package/dist/lib/IconText-CTM2r0Tv.js +0 -2
  200. package/dist/lib/IconText-CTM2r0Tv.js.map +0 -1
  201. package/dist/lib/LayoutSizes-CvMmMgHJ.js +0 -2
  202. package/dist/lib/LayoutSizes-CvMmMgHJ.js.map +0 -1
  203. package/dist/lib/List-DHeOPAK2.js +0 -2
  204. package/dist/lib/List-DHeOPAK2.js.map +0 -1
  205. package/dist/lib/Menu-B6ippw-p.js +0 -2
  206. package/dist/lib/Menu-B6ippw-p.js.map +0 -1
  207. package/dist/lib/Position-DRSlWn4Z.js +0 -2
  208. package/dist/lib/Position-DRSlWn4Z.js.map +0 -1
  209. package/dist/lib/Scrollbar-CiVV3axj.js +0 -2
  210. package/dist/lib/Scrollbar-CiVV3axj.js.map +0 -1
  211. package/dist/lib/Slider-_JVvuQ8M.js +0 -2
  212. package/dist/lib/Slider-_JVvuQ8M.js.map +0 -1
  213. package/dist/lib/TabButton-DEypdlZf.js +0 -2
  214. package/dist/lib/TabButton-DEypdlZf.js.map +0 -1
  215. package/dist/lib/Tooltip-BUy6uFKN.js +0 -3
  216. package/dist/lib/VBox-Dr7Ge9M6.js +0 -2
  217. package/dist/lib/VBox-Dr7Ge9M6.js.map +0 -1
  218. package/dist/lib/VirtualScroller-BPy6KmSX.js +0 -2
  219. package/dist/lib/VirtualScroller-BPy6KmSX.js.map +0 -1
  220. package/dist/lib/selectionsEqual-2PJrcimg.js +0 -2
  221. package/dist/lib/selectionsEqual-2PJrcimg.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{t as e}from"./DOM-BeR95tE8.js";import{l as t}from"./Position-DRSlWn4Z.js";import{m as n,t as r}from"./Component-CHTzJxEf.js";var i={tag:`span`,textAlign:`left`,fontFamily:`var(--ts-ui-font-family, system-ui, sans-serif)`,fontKerning:`auto`,fontSize:14,fontSizeAdjust:`none`,fontStretch:`normal`,fontStyle:`normal`,fontVariant:`normal`,fontWeight:`normal`,truncate:!0},a=100,o=`calc(1em + var(--ts-ui-line-padding, 2px))`,Text=class extends r{_hasExplicitPreferredSize=!1;_fontSizeCSSVar=`--ts-ui-font-size`;_fontSizeCSSRule=`var(--ts-ui-font-size, 14px)`;_lineHeightCSSVar=null;_lineHeightCSSRule=o;_measuredBaseline=null;_measuredMinSize=null;_autoMeasure=!0;_measurementDirty=!0;_measuredGeneration=-1;_wordBreak=null;_lineClamp=null;_textOverflow=null;_truncate=!0;constructor(e,t,n){super(t,{...i,...n??{}}),this.clearInsets(),this.setElementCSSRule(`lineHeight`,this._lineHeightCSSRule),e!==void 0&&this._options.text===void 0&&this.setText(e),this._measurementDirty=!0}applyOptions(e){return super.applyOptions(e),e.text!==void 0&&this.setText(e.text),e.textAlign!==void 0&&this.setTextAlign(e.textAlign),e.textShadow!==void 0&&this.setTextShadow(e.textShadow),e.fontFamily!==void 0&&this.setFontFamily(e.fontFamily),e.fontSize!==void 0&&this.setFontSize(e.fontSize),e.fontWeight!==void 0&&this.setFontWeight(e.fontWeight),e.fontStyle!==void 0&&this.setFontStyle(e.fontStyle),e.fontVariant!==void 0&&this.setFontVariant(e.fontVariant),e.fontStretch!==void 0&&this.setFontStretch(e.fontStretch),e.fontKerning!==void 0&&this.setFontKerning(e.fontKerning),e.fontSizeAdjust!==void 0&&this.setFontSizeAdjust(e.fontSizeAdjust),e.lineHeight!==void 0&&this.setLineHeight(e.lineHeight),e.textOverflow!==void 0&&this.setTextOverflow(e.textOverflow),e.whiteSpace!==void 0&&this.setWhiteSpace(e.whiteSpace),this.setTruncate(e.truncate??this._defaultOptions.truncate),this}readThemeLineHeightPx(){let n=this._options.fontSize??this._defaultOptions.fontSize??14;if(this._lineHeightCSSVar){let t=e.source.getThemeVar(this._lineHeightCSSVar),n=parseFloat(t);if(!isNaN(n))return n}return t.lineHeightPx({fontSizePx:n})}getElement(e=!1){return super.getElement(e)}resolveBoundFontSizePx(){return this._fontSizeCSSVar?t.boundFontSizePx(this._fontSizeCSSVar,this._fontSizeCSSRule):null}setPreferredSize(e){return this._hasExplicitPreferredSize=!0,super.setPreferredSize(e),this}setCalculatedSize(e,t){this._hasExplicitPreferredSize||super.setPreferredSize({width:e,height:t})}calculateSize(){if(this._measurementDirty=!1,this._measuredGeneration=t.textMetricsGeneration(),!this._autoMeasure)return;let n=this.getLineHeight()??this.readThemeLineHeightPx(),r=Math.ceil(n),i=this._options.text;if(i){let t=e.source.measureText(i.toString(),this.measureOptions()),n=this.measuredHeight(i.toString(),t.width,t.height);this._measuredBaseline=t.baseline,this.setCalculatedSize(t.width,n);let o=this._truncate?Math.min(t.width,a):t.width;this._measuredMinSize={width:o,height:Math.max(n,r)}}else this._measuredBaseline=null,this.setCalculatedSize(0,0),this._measuredMinSize={width:0,height:0}}needsMeasure(){return this._measurementDirty||this._measuredGeneration!==t.textMetricsGeneration()}measure(){let e=this._autoMeasure;this._autoMeasure=!0,this.calculateSize(),this._autoMeasure=e}getBaseline(){return this.needsMeasure()&&this.calculateSize(),this.wrapInnerBaseline(this._measuredBaseline)}measureOptions(){let e=this.getFontSize(),t=this.getLineHeight();return{fontFamily:this.getFontFamily()??void 0,fontSize:this._fontSizeCSSRule??(e===null?void 0:`${e}px`),fontWeight:this.getFontWeight()??void 0,fontStyle:this.getFontStyle()??void 0,fontVariant:this.getFontVariant()??void 0,fontStretch:this.getFontStretch()??void 0,lineHeight:this._lineHeightCSSRule??(t===null?void 0:`${t}px`)}}isWrapping(){let e=this.getWhiteSpace();return e===`normal`||e===`pre-wrap`||e===`pre-line`||e===`break-spaces`}measuredHeight(t,n,r){if(!this.isWrapping()||this.isVerticalWritingMode())return r;let i=this.getWidth();if(Number.isNaN(i))return r;let a=this.getPerimeterSize(),o=i-a.left-a.right;if(o>=n)return r;let s=e.source.measureText(t,{...this.measureOptions(),maxWidth:o}),c=Math.ceil(this.getLineHeight()??this.readThemeLineHeightPx());return Math.max(s.height,c)}setWidth(e){let t=this.getWidth();return super.setWidth(e),this.isWrapping()&&this.getWidth()!==t&&(this._measurementDirty=!0,this.calculateSize()),this}getPreferredSize(){this.needsMeasure()&&this.calculateSize();let e=super.getPreferredSize();return e&&this.isVerticalWritingMode()?{width:e.height,height:e.width}:e}isVerticalWritingMode(){let e=this.getWritingMode();return e!==null&&(e.startsWith(`vertical`)||e.startsWith(`sideways`))}getMinSize(){this.needsMeasure()&&this.calculateSize();let e=this._measuredMinSize,t=super.getMinSize();return e?this.isVerticalWritingMode()?t?{width:Math.max(t.width,e.height),height:t.height}:{width:e.height,height:0}:t?{width:t.width,height:Math.max(t.height,e.height)}:{width:0,height:e.height}:t}getText(){return this._options.text||``}setText(t){this._options.text=t||``,this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout();let n=this.getElement();return n&&e.sink.apply(n,{text:t.valueOf()}),this}setAutoMeasure(e){return this._autoMeasure=e,this}getTextAlign(){return this._options.textAlign??this._defaultOptions.textAlign??null}setTextAlign(e){return this._options.textAlign=e,this.setElementCSSRule(`textAlign`,e),this}getTextShadow(){return this._options.textShadow??null}setTextShadow(e){return this._options.textShadow=e,this.setElementCSSRule(`textShadow`,e),this}clearTextShadow(){return this._options.textShadow===void 0?this:(this._options.textShadow=void 0,this.setElementCSSRule(`textShadow`,null),this)}getFontFamily(){return this._options.fontFamily??this._defaultOptions.fontFamily??null}setFontFamily(e){return this._options.fontFamily=e,this.setElementCSSRule(`fontFamily`,e),this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}getFontKerning(){return this._options.fontKerning??this._defaultOptions.fontKerning??null}setFontKerning(e){return this._options.fontKerning=e,this.setElementCSSRule(`fontKerning`,e),this}getFontSize(){if(this._fontSizeCSSVar){let e=this.resolveBoundFontSizePx();if(e!==null)return e}return this._options.fontSize??this._defaultOptions.fontSize??null}setFontSize(e){if(typeof e==`number`)this._options.fontSize=e,this._fontSizeCSSVar=null,this._fontSizeCSSRule=null,this.setElementCSSRule(`fontSize`,e+`px`);else{let t=this.getFontSize()??14;this._fontSizeCSSVar=e,this._fontSizeCSSRule=`var(${e}, ${t}px)`,this.setElementCSSRule(`fontSize`,this._fontSizeCSSRule);let n=this.resolveBoundFontSizePx();n!==null&&(this._options.fontSize=n)}return this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}getFontSizeAdjust(){return this._options.fontSizeAdjust??this._defaultOptions.fontSizeAdjust??null}setFontSizeAdjust(e){return this._options.fontSizeAdjust=e,this.setElementCSSRule(`fontSizeAdjust`,e),this}getFontStretch(){return this._options.fontStretch??this._defaultOptions.fontStretch??null}setFontStretch(e){return this._options.fontStretch=e,this.setElementCSSRule(`fontStretch`,e),this}getFontStyle(){return this._options.fontStyle??this._defaultOptions.fontStyle??null}setFontStyle(e){return this._options.fontStyle=e,this.setElementCSSRule(`fontStyle`,e),this}getFontVariant(){return this._options.fontVariant??this._defaultOptions.fontVariant??null}setFontVariant(e){return this._options.fontVariant=e,this.setElementCSSRule(`fontVariant`,e),this}getFontWeight(){return this._options.fontWeight??this._defaultOptions.fontWeight??null}setFontWeight(e){return this._options.fontWeight=e,this.setElementCSSRule(`fontWeight`,e),this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}getLineHeight(){return this._options.lineHeight??this._defaultOptions.lineHeight??this.readThemeLineHeightPx()}setLineHeight(e){if(typeof e==`number`){if(this._options.lineHeight===e&&this._lineHeightCSSVar===null&&this._lineHeightCSSRule===null)return this;this._options.lineHeight=e,this._lineHeightCSSVar=null,this._lineHeightCSSRule=null,this.setElementCSSRule(`lineHeight`,e+`px`)}else this._lineHeightCSSVar=e,this._lineHeightCSSRule=`var(${e}, ${o})`,this._options.lineHeight=this.readThemeLineHeightPx(),this.setElementCSSRule(`lineHeight`,this._lineHeightCSSRule);return this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}centerInHeight(e){return e===null?(this._lineHeightCSSVar=null,this._lineHeightCSSRule=o,this._options.lineHeight=this.readThemeLineHeightPx(),this.setElementCSSRule(`lineHeight`,this._lineHeightCSSRule),this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this):this.setLineHeight(e)}getTextOverflow(){return this._textOverflow}setTextOverflow(e){return this._textOverflow=e,this.setElementCSSRule(`textOverflow`,e),this}clearTextOverflow(){return this._textOverflow===null?this:(this._textOverflow=null,this.setElementCSSRule(`textOverflow`,null),this)}isTruncate(){return this._truncate}setTruncate(e){return this._truncate=e,e?(this.setWhiteSpace(`nowrap`),this.setOverflow(`hidden`),this.setTextOverflow(`ellipsis`)):(this.setElementCSSRule(`whiteSpace`,null),this.setOverflow(`visible`),this.setElementCSSRule(`textOverflow`,null),this._textOverflow=null),this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}getWordBreak(){return this._wordBreak}setWordBreak(e){return this._wordBreak===e?this:(this._wordBreak=e,this.setElementCSSRule(`wordBreak`,e),this)}getLineClamp(){return this._lineClamp}setLineClamp(e){return this._lineClamp===e?this:(this._lineClamp=e,this.setElementCSSRules({display:`-webkit-box`,webkitBoxOrient:`vertical`,webkitLineClamp:String(e),overflow:`hidden`,textOverflow:`ellipsis`}),this)}clearLineClamp(){return this._lineClamp===null?this:(this._lineClamp=null,this.setElementCSSRules({display:null,webkitBoxOrient:null,webkitLineClamp:null,overflow:null,textOverflow:null}),this)}applyStyle(e){super.applyStyle(e);let t=this.getFontSize(),n=this.getLineHeight();return this.setElementCSSRules({fontFamily:this.getFontFamily()??``,textAlign:this.getTextAlign()??``,textShadow:this.getTextShadow()??``,fontKerning:this.getFontKerning()??``,fontSize:this._fontSizeCSSRule??(t===null?``:`${t}px`),fontSizeAdjust:this.getFontSizeAdjust()??``,fontStretch:this.getFontStretch()??``,fontStyle:this.getFontStyle()??``,fontVariant:this.getFontVariant()??``,fontWeight:this.getFontWeight()??``,lineHeight:this._lineHeightCSSRule??(n===null?``:`${n}px`)}),this}render(){let t=super.render();return e.sink.apply(t,{text:this.getText().valueOf()}),t}},s=n(Text);export{s as t};
2
- //# sourceMappingURL=Text-Bni4icFY.js.map
1
+ import{t as e}from"./DOM-67StIm5G.js";import{l as t}from"./Position-Ck_KD4cR.js";import{h as n,t as r}from"./Component-DHqrPwAw.js";var i={tag:`span`,textAlign:`left`,fontFamily:`var(--ts-ui-font-family, system-ui, sans-serif)`,fontKerning:`auto`,fontSize:14,fontSizeAdjust:`none`,fontStretch:`normal`,fontStyle:`normal`,fontVariant:`normal`,fontWeight:`normal`,truncate:!0},a=100,o=`calc(1em + var(--ts-ui-line-padding, 2px))`,Text=class extends r{_hasExplicitPreferredSize=!1;_fontSizeCSSVar=`--ts-ui-font-size`;_fontSizeCSSRule=`var(--ts-ui-font-size, 14px)`;_lineHeightCSSVar=null;_lineHeightCSSRule=o;_measuredBaseline=null;_measuredMinSize=null;_autoMeasure=!0;_measurementDirty=!0;_measuredGeneration=-1;_wordBreak=null;_lineClamp=null;_textOverflow=null;_truncate=!0;constructor(e,t,n){super(t,{...i,...n??{}}),this.clearInsets(),this.setElementCSSRule(`lineHeight`,this._lineHeightCSSRule),e!==void 0&&this._options.text===void 0&&this.setText(e),this._measurementDirty=!0}applyOptions(e){return super.applyOptions(e),e.text!==void 0&&this.setText(e.text),e.textAlign!==void 0&&this.setTextAlign(e.textAlign),e.textShadow!==void 0&&this.setTextShadow(e.textShadow),e.fontFamily!==void 0&&this.setFontFamily(e.fontFamily),e.fontSize!==void 0&&this.setFontSize(e.fontSize),e.fontWeight!==void 0&&this.setFontWeight(e.fontWeight),e.fontStyle!==void 0&&this.setFontStyle(e.fontStyle),e.fontVariant!==void 0&&this.setFontVariant(e.fontVariant),e.fontStretch!==void 0&&this.setFontStretch(e.fontStretch),e.fontKerning!==void 0&&this.setFontKerning(e.fontKerning),e.fontSizeAdjust!==void 0&&this.setFontSizeAdjust(e.fontSizeAdjust),e.lineHeight!==void 0&&this.setLineHeight(e.lineHeight),e.textOverflow!==void 0&&this.setTextOverflow(e.textOverflow),e.whiteSpace!==void 0&&this.setWhiteSpace(e.whiteSpace),this.setTruncate(e.truncate??this._defaultOptions.truncate),this}readThemeLineHeightPx(){let n=this._options.fontSize??this._defaultOptions.fontSize??14;if(this._lineHeightCSSVar){let t=e.source.getThemeVar(this._lineHeightCSSVar),n=parseFloat(t);if(!isNaN(n))return n}return t.lineHeightPx({fontSizePx:n})}getElement(e=!1){return super.getElement(e)}resolveBoundFontSizePx(){return this._fontSizeCSSVar?t.boundFontSizePx(this._fontSizeCSSVar,this._fontSizeCSSRule):null}setPreferredSize(e){return this._hasExplicitPreferredSize=!0,super.setPreferredSize(e),this}setCalculatedSize(e,t){this._hasExplicitPreferredSize||super.setPreferredSize({width:e,height:t})}calculateSize(){if(this._measurementDirty=!1,this._measuredGeneration=t.textMetricsGeneration(),!this._autoMeasure)return;let n=this.getLineHeight()??this.readThemeLineHeightPx(),r=Math.ceil(n),i=this._options.text;if(i){let t=e.source.measureText(i.toString(),this.measureOptions()),n=this.measuredHeight(i.toString(),t.width,t.height);this._measuredBaseline=t.baseline,this.setCalculatedSize(t.width,n);let o=this._truncate?Math.min(t.width,a):t.width;this._measuredMinSize={width:o,height:Math.max(n,r)}}else this._measuredBaseline=null,this.setCalculatedSize(0,0),this._measuredMinSize={width:0,height:0}}needsMeasure(){return this._measurementDirty||this._measuredGeneration!==t.textMetricsGeneration()}measure(){let e=this._autoMeasure;this._autoMeasure=!0,this.calculateSize(),this._autoMeasure=e}getBaseline(){return this.needsMeasure()&&this.calculateSize(),this.wrapInnerBaseline(this._measuredBaseline)}measureOptions(){let e=this.getFontSize(),t=this.getLineHeight();return{fontFamily:this.getFontFamily()??void 0,fontSize:this._fontSizeCSSRule??(e===null?void 0:`${e}px`),fontWeight:this.getFontWeight()??void 0,fontStyle:this.getFontStyle()??void 0,fontVariant:this.getFontVariant()??void 0,fontStretch:this.getFontStretch()??void 0,lineHeight:this._lineHeightCSSRule??(t===null?void 0:`${t}px`)}}isWrapping(){let e=this.getWhiteSpace();return e===`normal`||e===`pre-wrap`||e===`pre-line`||e===`break-spaces`}measuredHeight(t,n,r){if(!this.isWrapping()||this.isVerticalWritingMode())return r;let i=this.getWidth();if(Number.isNaN(i))return r;let a=this.getPerimeterSize(),o=i-a.left-a.right;if(o>=n)return r;let s=e.source.measureText(t,{...this.measureOptions(),maxWidth:o}),c=Math.ceil(this.getLineHeight()??this.readThemeLineHeightPx());return Math.max(s.height,c)}setWidth(e){let t=this.getWidth();return super.setWidth(e),this.isWrapping()&&this.getWidth()!==t&&(this._measurementDirty=!0,this.calculateSize()),this}getPreferredSize(){this.needsMeasure()&&this.calculateSize();let e=super.getPreferredSize();return e&&this.isVerticalWritingMode()?{width:e.height,height:e.width}:e}isVerticalWritingMode(){let e=this.getWritingMode();return e!==null&&(e.startsWith(`vertical`)||e.startsWith(`sideways`))}getMinSize(){this.needsMeasure()&&this.calculateSize();let e=this._measuredMinSize,t=super.getMinSize();return e?this.isVerticalWritingMode()?t?{width:Math.max(t.width,e.height),height:t.height}:{width:e.height,height:0}:t?{width:t.width,height:Math.max(t.height,e.height)}:{width:0,height:e.height}:t}getText(){return this._options.text||``}setText(t){this._options.text=t||``,this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout();let n=this.getElement();return n&&e.sink.apply(n,{text:t.valueOf()}),this}setAutoMeasure(e){return this._autoMeasure=e,this}getTextAlign(){return this._options.textAlign??this._defaultOptions.textAlign??null}setTextAlign(e){return this._options.textAlign=e,this.setElementCSSRule(`textAlign`,e),this}getTextShadow(){return this._options.textShadow??null}setTextShadow(e){return this._options.textShadow=e,this.setElementCSSRule(`textShadow`,e),this}clearTextShadow(){return this._options.textShadow===void 0?this:(this._options.textShadow=void 0,this.setElementCSSRule(`textShadow`,null),this)}getFontFamily(){return this._options.fontFamily??this._defaultOptions.fontFamily??null}setFontFamily(e){return this._options.fontFamily=e,this.setElementCSSRule(`fontFamily`,e),this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}getFontKerning(){return this._options.fontKerning??this._defaultOptions.fontKerning??null}setFontKerning(e){return this._options.fontKerning=e,this.setElementCSSRule(`fontKerning`,e),this}getFontSize(){if(this._fontSizeCSSVar){let e=this.resolveBoundFontSizePx();if(e!==null)return e}return this._options.fontSize??this._defaultOptions.fontSize??null}setFontSize(e){if(typeof e==`number`)this._options.fontSize=e,this._fontSizeCSSVar=null,this._fontSizeCSSRule=null,this.setElementCSSRule(`fontSize`,e+`px`);else{let t=this.getFontSize()??14;this._fontSizeCSSVar=e,this._fontSizeCSSRule=`var(${e}, ${t}px)`,this.setElementCSSRule(`fontSize`,this._fontSizeCSSRule);let n=this.resolveBoundFontSizePx();n!==null&&(this._options.fontSize=n)}return this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}getFontSizeAdjust(){return this._options.fontSizeAdjust??this._defaultOptions.fontSizeAdjust??null}setFontSizeAdjust(e){return this._options.fontSizeAdjust=e,this.setElementCSSRule(`fontSizeAdjust`,e),this}getFontStretch(){return this._options.fontStretch??this._defaultOptions.fontStretch??null}setFontStretch(e){return this._options.fontStretch=e,this.setElementCSSRule(`fontStretch`,e),this}getFontStyle(){return this._options.fontStyle??this._defaultOptions.fontStyle??null}setFontStyle(e){return this._options.fontStyle=e,this.setElementCSSRule(`fontStyle`,e),this}getFontVariant(){return this._options.fontVariant??this._defaultOptions.fontVariant??null}setFontVariant(e){return this._options.fontVariant=e,this.setElementCSSRule(`fontVariant`,e),this}getFontWeight(){return this._options.fontWeight??this._defaultOptions.fontWeight??null}setFontWeight(e){return this._options.fontWeight=e,this.setElementCSSRule(`fontWeight`,e),this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}getLineHeight(){return this._options.lineHeight??this._defaultOptions.lineHeight??this.readThemeLineHeightPx()}setLineHeight(e){if(typeof e==`number`){if(this._options.lineHeight===e&&this._lineHeightCSSVar===null&&this._lineHeightCSSRule===null)return this;this._options.lineHeight=e,this._lineHeightCSSVar=null,this._lineHeightCSSRule=null,this.setElementCSSRule(`lineHeight`,e+`px`)}else this._lineHeightCSSVar=e,this._lineHeightCSSRule=`var(${e}, ${o})`,this._options.lineHeight=this.readThemeLineHeightPx(),this.setElementCSSRule(`lineHeight`,this._lineHeightCSSRule);return this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}centerInHeight(e){return e===null?(this._lineHeightCSSVar=null,this._lineHeightCSSRule=o,this._options.lineHeight=this.readThemeLineHeightPx(),this.setElementCSSRule(`lineHeight`,this._lineHeightCSSRule),this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this):this.setLineHeight(e)}getTextOverflow(){return this._textOverflow}setTextOverflow(e){return this._textOverflow=e,this.setElementCSSRule(`textOverflow`,e),this}clearTextOverflow(){return this._textOverflow===null?this:(this._textOverflow=null,this.setElementCSSRule(`textOverflow`,null),this)}isTruncate(){return this._truncate}setTruncate(e){return this._truncate=e,e?(this.setWhiteSpace(`nowrap`),this.setOverflow(`hidden`),this.setTextOverflow(`ellipsis`)):(this.setElementCSSRule(`whiteSpace`,null),this.setOverflow(`visible`),this.setElementCSSRule(`textOverflow`,null),this._textOverflow=null),this._measurementDirty=!0,(this.getParentComponent()??this).scheduleLayout(),this}getWordBreak(){return this._wordBreak}setWordBreak(e){return this._wordBreak===e?this:(this._wordBreak=e,this.setElementCSSRule(`wordBreak`,e),this)}getLineClamp(){return this._lineClamp}setLineClamp(e){return this._lineClamp===e?this:(this._lineClamp=e,this.setElementCSSRules({display:`-webkit-box`,webkitBoxOrient:`vertical`,webkitLineClamp:String(e),overflow:`hidden`,textOverflow:`ellipsis`}),this)}clearLineClamp(){return this._lineClamp===null?this:(this._lineClamp=null,this.setElementCSSRules({display:null,webkitBoxOrient:null,webkitLineClamp:null,overflow:null,textOverflow:null}),this)}applyStyle(e){super.applyStyle(e);let t=this.getFontSize(),n=this.getLineHeight();return this.setElementCSSRules({fontFamily:this.getFontFamily()??``,textAlign:this.getTextAlign()??``,textShadow:this.getTextShadow()??``,fontKerning:this.getFontKerning()??``,fontSize:this._fontSizeCSSRule??(t===null?``:`${t}px`),fontSizeAdjust:this.getFontSizeAdjust()??``,fontStretch:this.getFontStretch()??``,fontStyle:this.getFontStyle()??``,fontVariant:this.getFontVariant()??``,fontWeight:this.getFontWeight()??``,lineHeight:this._lineHeightCSSRule??(n===null?``:`${n}px`)}),this}render(){let t=super.render();return e.sink.apply(t,{text:this.getText().valueOf()}),t}},s=n(Text);export{s as t};
2
+ //# sourceMappingURL=Text-D5pg7taZ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text-Bni4icFY.js","names":[],"sources":["../../src/typescript/lib/component/input/Text.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { DOM } from \"~/core/DOM.js\";\nimport type { Handle } from \"~/core/DOM.js\";\nimport { Util } from \"~/core/Util.js\";\nimport { Size } from \"~/primitive/Size.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link Text}.\n *\n * @category Components\n */\nexport interface TextOptions extends ComponentOptions {\n tag?: string;\n text?: string;\n textAlign?: string;\n textShadow?: string;\n fontFamily?: string;\n fontSize?: number | string;\n fontWeight?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontStretch?: string;\n fontKerning?: string;\n fontSizeAdjust?: string;\n lineHeight?: number | string;\n textOverflow?: string;\n whiteSpace?: string;\n /**\n * When `true` (default), the text is single-line + clipped + ellipsised\n * when its rendered width is below its natural width, and `minSize.width`\n * is capped at `100` so parent layouts can shrink the text past its\n * natural width.\n *\n * When `false`, no ellipsis is applied and `minSize.width` reports the\n * full natural width — the text refuses to be squeezed, forcing the\n * parent to widen (used by [`Button`](/api/component/button/classes/Button)\n * for the label so the button grows to fit its text instead of clipping).\n */\n truncate?: boolean;\n}\n\n/**\n * Module-level class defaults forwarded to `super` via the options bag so the\n * `applyOptions` cascade dispatches each setter once with the final value.\n *\n * `lineHeight` is intentionally **omitted**: it is theme-derived\n * (`readThemeLineHeightPx()`), so its getter falls back to that resolver\n * directly rather than a value seeded here.\n *\n * `fontFamily` is a pure getter-fallback despite living in this bag:\n * `_defaultOptions.fontFamily` is consulted by `getFontFamily()`, but is\n * never dispatched through `setFontFamily(...)` — doing so would write the\n * literal `var(--ts-ui-font-family, …)` onto every Text's CSS rule, blocking\n * a parent's `font-family` override from cascading through.\n */\nconst _defaultTextOptions: Partial<TextOptions> = {\n tag: \"span\",\n textAlign: \"left\",\n fontFamily: \"var(--ts-ui-font-family, system-ui, sans-serif)\",\n fontKerning: \"auto\",\n fontSize: 14,\n fontSizeAdjust: \"none\",\n fontStretch: \"normal\",\n fontStyle: \"normal\",\n fontVariant: \"normal\",\n fontWeight: \"normal\",\n truncate: true,\n};\n\n// Upper bound for the auto-derived `minSize.width` from text measurement —\n// short labels report their full measured width (so they're never truncated\n// when the container has room), longer text caps here so the parent layout\n// always has room to shrink the Text below its natural width.\nconst TEXT_AUTO_MIN_WIDTH_CAP_PX = 100;\n\n// Default theme-tracking line-height rule: the control's own font size plus the\n// `--ts-ui-line-padding` leading, so the line box scales per font size. `1em`\n// resolves against the element's own font-size at both render and measure time.\n// `2px` is the shipped `--ts-ui-line-padding` default, used only if the var is\n// absent. A control overrides this with an explicit px via `setLineHeight`.\nconst ADDITIVE_LINE_HEIGHT_RULE = \"calc(1em + var(--ts-ui-line-padding, 2px))\";\n\n/**\n * A text-displaying component with comprehensive font and layout controls.\n *\n * Uses an off-screen probe element to measure text dimensions and automatically\n * updates the preferred size whenever the text or a font property changes.\n *\n * @category Components\n */\nclass Text<TOptions extends TextOptions = TextOptions> extends Component<TOptions> {\n\n private _hasExplicitPreferredSize: boolean = false;\n private _fontSizeCSSVar : string | null = \"--ts-ui-font-size\";\n private _fontSizeCSSRule: string | null = \"var(--ts-ui-font-size, 14px)\";\n private _lineHeightCSSVar : string | null = null;\n private _lineHeightCSSRule: string | null = ADDITIVE_LINE_HEIGHT_RULE;\n private _measuredBaseline: number | null = null;\n private _measuredMinSize: Size | null = null;\n private _autoMeasure: boolean = true;\n private _measurementDirty: boolean = true;\n // The `Util.textMetricsGeneration()` value as of the last `calculateSize`,\n // so a theme change (which bumps the generation) is noticed lazily by\n // `needsMeasure()` without Text holding its own theme subscription. `-1`\n // never matches a real generation, so an unmeasured Text is always due.\n private _measuredGeneration: number = -1;\n private _wordBreak: string | null = null;\n private _lineClamp: number | null = null;\n private _textOverflow: string | null = null;\n private _truncate: boolean = true;\n\n // `NoInfer` on `options` keeps a partial options literal from narrowing\n // TOptions to just the keys it carries: `new Text(\"x\", { fontWeight: \"600\" })`\n // must stay a `Text<TextOptions>` (assignable to Component), not a\n // `Text<{ fontWeight: string }>` (whose narrowed option type is not). Subclasses\n // still fix TOptions through `extends Text<MyOptions>`, not argument inference.\n constructor(text?: String, options?: NoInfer<TOptions>, subclassDefaults?: Partial<TOptions>) {\n super(\n options,\n { ..._defaultTextOptions, ...(subclassDefaults ?? {}) } as Partial<TOptions>,\n );\n\n // The cascade-driven `setFontSize(14)` clobbers `fontSizeCSSVar` and\n // `fontSizeCSSRule` to null, but Text's field initializers (which run\n // after super returns, i.e. right above this line) restore both to\n // their var-binding values — so theme reactivity is preserved by the\n // DOM `var(...)` binding even though the cascade temporarily writes a\n // literal. `getFontSize()` / `getLineHeight()` re-resolve those bound\n // vars live (through `Util`'s theme-invalidated metrics cache) rather\n // than caching a value that would go stale on a theme change.\n this.clearInsets();\n this.setElementCSSRule(\"lineHeight\", this._lineHeightCSSRule);\n\n // Positional `text` constructor argument: write to the bag only when\n // the caller didn't also pass `options.text` (which would have been\n // dispatched via super's applyOptions cascade and should win).\n if (text !== undefined && this._options.text === undefined) {\n this.setText(text);\n }\n\n // Off-screen text measurement is deferred until the first\n // getPreferredSize / getBaseline call so construction stays JS-only\n // (no forced layout from `DOM.source.measureText`).\n this._measurementDirty = true;\n }\n\n /**\n * Applies a {@link TextOptions} bag to this component, dispatching font and\n * text properties to their corresponding setters after the inherited\n * Component fields have been applied.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: TOptions): this {\n super.applyOptions(options);\n\n // Dispatch only caller-supplied values. Class-level font defaults (e.g.\n // the 14px size, a subclass's bold weight) are resolved lazily by the\n // font getters' `_defaultOptions` fallback, which `applyStyle` re-reads\n // at render — so they never enter `_options`.\n if (options.text !== undefined) {\n this.setText(options.text);\n }\n\n if (options.textAlign !== undefined) {\n this.setTextAlign(options.textAlign);\n }\n\n if (options.textShadow !== undefined) {\n this.setTextShadow(options.textShadow);\n }\n\n if (options.fontFamily !== undefined) {\n this.setFontFamily(options.fontFamily);\n }\n\n if (options.fontSize !== undefined) {\n this.setFontSize(options.fontSize);\n }\n\n if (options.fontWeight !== undefined) {\n this.setFontWeight(options.fontWeight);\n }\n\n if (options.fontStyle !== undefined) {\n this.setFontStyle(options.fontStyle);\n }\n\n if (options.fontVariant !== undefined) {\n this.setFontVariant(options.fontVariant);\n }\n\n if (options.fontStretch !== undefined) {\n this.setFontStretch(options.fontStretch);\n }\n\n if (options.fontKerning !== undefined) {\n this.setFontKerning(options.fontKerning);\n }\n\n if (options.fontSizeAdjust !== undefined) {\n this.setFontSizeAdjust(options.fontSizeAdjust);\n }\n\n if (options.lineHeight !== undefined) {\n this.setLineHeight(options.lineHeight);\n }\n\n if (options.textOverflow !== undefined) {\n this.setTextOverflow(options.textOverflow);\n }\n\n if (options.whiteSpace !== undefined) {\n this.setWhiteSpace(options.whiteSpace);\n }\n\n // `truncate` carries a class default (true) and applies its CSS\n // (white-space / overflow / text-overflow) imperatively via the setter\n // with no render re-read, so always dispatch the caller value or the\n // default — otherwise a default-truncating Text never gets the CSS.\n this.setTruncate(options.truncate ?? this._defaultOptions.truncate!);\n\n return this;\n }\n\n /**\n * Resolves this `Text`'s line box height in pixels under the additive\n * leading model.\n *\n * @returns `Util.lineHeightPx(fontSize)` — the control's own font size plus\n * the `--ts-ui-line-padding` leading — for the default theme-tracking case.\n * A legacy custom line-height var binding resolves that var as a fixed line\n * box instead, falling back to the additive value when it is unparseable.\n *\n * @remarks `_options.fontSize` is always a resolved px number here (a CSS\n * var passed to `setFontSize` is resolved and stored as a number), so the\n * leading scales with the control's actual font size — a 12px button title\n * and a 14px label get proportionate line boxes from the one token. This is\n * the same arithmetic `Util.lineHeightPx` applies for input box heights, so\n * a `Text` measures and renders at the line height a sibling input expects.\n */\n private readThemeLineHeightPx(): number {\n // `_options.fontSize` is the resolved px the bound var evaluates to —\n // `setFontSize`/`onThemeChange` populate it through the probe-backed\n // `resolveBoundFontSizePx`, so it is correct even pre-attach (a calc()\n // token included). No element read here: a parent reads this at\n // construction, before this Text's own element is styled.\n const fs = (this._options.fontSize as number | undefined) ?? (this._defaultOptions.fontSize as number | undefined) ?? 14;\n\n if (this._lineHeightCSSVar) {\n const raw = DOM.source.getThemeVar(this._lineHeightCSSVar);\n const parsed = parseFloat(raw);\n\n if (!isNaN(parsed)) {\n return parsed;\n }\n }\n\n return Util.lineHeightPx({ fontSizePx: fs });\n }\n\n /**\n * Returns the DOM element handle.\n *\n * @param createIfMissing - Optional. When true, renders the element if it does not yet exist.\n *\n * @returns The component's element handle.\n */\n getElement(createIfMissing: boolean = false): Handle | undefined {\n return super.getElement(createIfMissing);\n }\n\n /**\n * Resolves the bound font-size var to a px number. A simple var (e.g. the\n * `--ts-ui-font-size` base) parses straight off the document root; a relative\n * font token's var holds a `calc(...)` that `getPropertyValue` returns\n * unevaluated (so `parseFloat` reads `NaN`), so it falls back to a\n * cascade-evaluating probe via `DOM.source.resolveFontSizePx`. The probe path\n * works **pre-attach** — before this component's own element is styled —\n * which is when a parent (e.g. a `Header`) first reads the line-box size.\n *\n * @returns The resolved font size in px, or `null` when no var is bound (an\n * explicit numeric size was set instead) — callers keep the cached number.\n */\n private resolveBoundFontSizePx(): number | null {\n if (!this._fontSizeCSSVar) return null; // explicit px size — no var bound\n\n return Util.boundFontSizePx(this._fontSizeCSSVar, this._fontSizeCSSRule);\n }\n\n /**\n * Sets the preferred size from an explicit caller, locking it against automatic recalculation.\n *\n * @param size - The preferred size in pixels.\n *\n * @returns This component, for method chaining.\n */\n setPreferredSize(size: Size): this {\n this._hasExplicitPreferredSize = true;\n super.setPreferredSize(size);\n\n return this;\n }\n\n /**\n * Updates the preferred size from a measurement only when no explicit size has been set.\n */\n private setCalculatedSize(width: number, height: number): void {\n if (!this._hasExplicitPreferredSize) {\n super.setPreferredSize({ width: width, height: height });\n }\n }\n\n /**\n * Measures the text using an off-screen probe element and sets the preferred size.\n *\n * @remarks Creates a temporary fixed-positioned invisible `<span>`, appends it to the body\n * to obtain its bounding rect, then removes it. Sets preferred size to (0, 0) when no text is set.\n * No-op when {@link setAutoMeasure} is `false` — the parent layout is expected to size this Text.\n */\n private calculateSize(): void {\n this._measurementDirty = false;\n this._measuredGeneration = Util.textMetricsGeneration();\n\n if (!this._autoMeasure) {\n return;\n }\n\n // Floor the reported minimum height to one line so a single-line label\n // is never squeezed below its line box (the measured height is 0 for\n // empty text and unset before the first probe).\n const lineHeightPx = this.getLineHeight() ?? this.readThemeLineHeightPx();\n const minLineHeight = Math.ceil(lineHeightPx);\n\n const text = this._options.text;\n if (text) {\n // Natural (single-line) measurement establishes the preferred WIDTH\n // and the baseline; the height then follows the box's current width,\n // growing when a wrapping run has been laid out narrower than natural.\n const natural = DOM.source.measureText(text.toString(), this.measureOptions());\n const height = this.measuredHeight(text.toString(), natural.width, natural.height);\n\n this._measuredBaseline = natural.baseline;\n this.setCalculatedSize(natural.width, height);\n // Store the measured floor as per-instance derived state (like\n // `_measuredBaseline`), kept out of `_defaultOptions`, which holds\n // the class-level Text defaults rather than per-instance\n // measurements. `getMinSize` folds this into the inherited min.\n // When truncation is disabled, report the full natural width so the\n // parent layout widens to fit instead of squeezing the text;\n // otherwise cap it so the parent can shrink the text past its\n // natural width.\n const autoMinWidth = this._truncate\n ? Math.min(natural.width, TEXT_AUTO_MIN_WIDTH_CAP_PX)\n : natural.width;\n this._measuredMinSize = {\n width: autoMinWidth,\n height: Math.max(height, minLineHeight),\n };\n } else {\n // No glyphs means no baseline — report null so HBox doesn't try\n // to baseline-align surrounding components against an empty box.\n // Reserve no line height either: an empty Text (e.g. the label slot\n // of an icon-only button) must collapse so it doesn't inflate the\n // container and knock the icon off-centre. The one-line floor only\n // applies once there is text to keep on its line.\n this._measuredBaseline = null;\n this.setCalculatedSize(0, 0);\n this._measuredMinSize = { width: 0, height: 0 };\n }\n }\n\n /**\n * Whether the cached measurement is stale — either because something\n * marked it dirty (a text/font change) or because the active theme's\n * text metrics have moved on since the last measurement.\n *\n * @returns `true` when the next size/baseline read should re-measure.\n *\n * @remarks Replaces a per-instance `ThemeManager` subscription: instead of\n * every `Text` re-measuring eagerly on each theme change, it compares its\n * own `_measuredGeneration` against `Util.textMetricsGeneration()` lazily,\n * the next time a caller actually asks for a size.\n */\n private needsMeasure(): boolean {\n return this._measurementDirty || this._measuredGeneration !== Util.textMetricsGeneration();\n }\n\n /**\n * Forces a one-off text measurement that ignores {@link setAutoMeasure}.\n * Use when the caller has opted out of auto-measure but needs an up-to-date\n * preferred size after a programmatic text change.\n */\n measure(): void {\n const wasAuto = this._autoMeasure;\n this._autoMeasure = true;\n this.calculateSize();\n this._autoMeasure = wasAuto;\n }\n\n /**\n * Returns the visual baseline of the rendered text, accounting for any\n * border, padding, or framework insets on this component.\n *\n * @returns The baseline offset from the component's outer top, in pixels,\n * or `null` when no text has been measured yet.\n *\n * @remarks Forces a measurement when the cached value is stale — the\n * off-screen probe is deferred from construction so first-call timing\n * shifts to whoever asks for a size first (usually `doLayout`).\n */\n getBaseline(): number | null {\n if (this.needsMeasure()) {\n this.calculateSize();\n }\n\n return this.wrapInnerBaseline(this._measuredBaseline);\n }\n\n /**\n * Builds the font/line-height option bag for a {@link DOM.measureText} probe\n * from this Text's resolved styling. Shared by the natural (single-line)\n * measurement and the wrap-aware height re-measurement in\n * {@link measuredHeight}, which adds a `maxWidth`.\n *\n * @returns The measure options (font family/size/weight/style/variant/stretch\n * and line height), each `undefined` when unset so the probe's own default\n * applies.\n */\n private measureOptions() {\n const fontSize = this.getFontSize();\n const lineHeight = this.getLineHeight();\n\n return {\n fontFamily : this.getFontFamily() ?? undefined,\n fontSize : this._fontSizeCSSRule ?? (fontSize !== null ? `${fontSize}px` : undefined),\n fontWeight : this.getFontWeight() ?? undefined,\n fontStyle : this.getFontStyle() ?? undefined,\n fontVariant: this.getFontVariant() ?? undefined,\n fontStretch: this.getFontStretch() ?? undefined,\n lineHeight : this._lineHeightCSSRule ?? (lineHeight !== null ? `${lineHeight}px` : undefined),\n };\n }\n\n /**\n * Whether this Text wraps onto multiple lines — i.e. its `white-space` is a\n * wrapping value rather than `nowrap`/`pre`. Only a wrapping Text's height\n * depends on the width it is given.\n *\n * @returns `true` when the text soft-wraps at its box width.\n */\n private isWrapping(): boolean {\n const ws = this.getWhiteSpace();\n\n return ws === \"normal\" || ws === \"pre-wrap\" || ws === \"pre-line\" || ws === \"break-spaces\";\n }\n\n /**\n * The height the text needs given its current laid-out width.\n *\n * A `nowrap` label — or one not yet given a width, or in a vertical writing\n * mode — is width-independent, so its natural single-line height stands. A\n * wrapping label whose box is narrower than its natural run re-measures at\n * the current inner width (its own border/insets removed): the extra lines\n * make it taller. The re-measure uses the same line-height as the render, so\n * the reported height matches what is drawn — line-height is the per-line\n * unit the whole calculation stacks.\n *\n * @param text - The text run being measured.\n * @param naturalWidth - The natural single-line width (nowrap), the wrap threshold.\n * @param naturalHeight - The natural single-line height, used when it does not wrap.\n * @returns The height (px) at the current width; floored at one line.\n */\n private measuredHeight(text: string, naturalWidth: number, naturalHeight: number): number {\n if (!this.isWrapping() || this.isVerticalWritingMode()) {\n return naturalHeight;\n }\n\n const width = this.getWidth();\n\n if (Number.isNaN(width)) {\n return naturalHeight;\n }\n\n const perimeter = this.getPerimeterSize();\n const innerWidth = width - perimeter.left - perimeter.right;\n\n // Wide enough for the whole run on one line → no wrapping; keep the exact\n // single-line height and skip a redundant probe.\n if (innerWidth >= naturalWidth) {\n return naturalHeight;\n }\n\n const wrapped = DOM.source.measureText(text, { ...this.measureOptions(), maxWidth: innerWidth });\n const minLineHeight = Math.ceil(this.getLineHeight() ?? this.readThemeLineHeightPx());\n\n return Math.max(wrapped.height, minLineHeight);\n }\n\n /**\n * Sets the laid-out width and, for a wrapping Text, re-measures at the new\n * width so its preferred height tracks the number of wrapped lines.\n *\n * A wrapping run's height depends on the width it is given, but the\n * preferred-size protocol resolves heights bottom-up before widths are\n * assigned top-down — so the height is only knowable once the box has a\n * width. Re-measuring here updates the preferred height, and\n * `Component.setPreferredSize` fires the ancestor notify, so the parent\n * re-lays-out one pass later at the taller height (the box's own min height\n * also rises, so the current pass already reserves the room rather than\n * clipping). A `nowrap` label's height is width-independent, so its width\n * changes need no re-measure. Idempotent once the width settles: an\n * unchanged width re-measures to the same height and the notify is suppressed.\n *\n * @param width - The new outer width in pixels.\n * @returns This component, for chaining.\n */\n override setWidth(width: number): this {\n const previous = this.getWidth();\n\n super.setWidth(width);\n\n if (this.isWrapping() && this.getWidth() !== previous) {\n this._measurementDirty = true;\n // Re-measure now (at the new width) so the updated preferred height\n // propagates before the next layout pass reads it.\n this.calculateSize();\n }\n\n return this;\n }\n\n /**\n * Returns the preferred size, lazily measuring the text on the first call.\n *\n * @returns The preferred Size, or `null` per the inherited contract.\n *\n * @remarks Construction no longer eagerly probes `document.body` for text\n * dimensions; the first reader of the preferred size pays the measurement\n * cost. After attach this is `doLayout`, so the probe happens at layout\n * time rather than construction time.\n */\n getPreferredSize() {\n if (this.needsMeasure()) {\n this.calculateSize();\n }\n\n const size = super.getPreferredSize();\n\n // `measureTextMetrics` always measures the run horizontally. A vertical\n // writing mode rotates it onto the block axis, so the natural text length\n // becomes the height and the line box becomes the width — swap to report\n // the on-screen extents.\n if (size && this.isVerticalWritingMode()) {\n return { width: size.height, height: size.width };\n }\n\n return size;\n }\n\n /**\n * Whether the active {@link Component.setWritingMode | writing mode} rotates\n * the text run onto the block (vertical) axis, so the measured horizontal\n * extents must be swapped to describe the on-screen size.\n *\n * @returns `true` for a `vertical-*` or `sideways-*` writing mode.\n */\n private isVerticalWritingMode(): boolean {\n const mode = this.getWritingMode();\n\n return mode !== null && (mode.startsWith(\"vertical\") || mode.startsWith(\"sideways\"));\n }\n\n /**\n * Returns the effective minimum size, folding the measured one-line height\n * floor (from `calculateSize`) into the inherited component/layout minimum.\n *\n * @returns The minimum `{width, height}`, never shorter than one line of\n * text, or `null` only when neither a measurement nor an inherited minimum\n * exists.\n *\n * @remarks Only the **height** floor participates in the hard minimum —\n * text cannot render below its line box without clipping. The measured\n * width is deliberately *not* folded in: surfacing each label's natural\n * width as a hard minimum would stop parent layouts (e.g. an equal-mode tab\n * bar) from compressing short labels to fit, which is why `Text.minSize`\n * has historically reported a zero width. The floor is per-instance derived\n * state held in `_measuredMinSize`, not a class default, so it lives outside\n * `_defaultOptions`. An explicit caller `setMinSize` taller than the floor\n * still wins via `Math.max`; a value shorter than one line is lifted to it.\n */\n getMinSize(): Size | null {\n if (this.needsMeasure()) {\n this.calculateSize();\n }\n\n const measured = this._measuredMinSize;\n const base = super.getMinSize();\n\n if (!measured) {\n return base;\n }\n\n // Vertical writing mode: the one-line floor guards the line *thickness*,\n // which is now the width rather than the height (the length runs down the\n // block axis and stays freely compressible).\n if (this.isVerticalWritingMode()) {\n if (!base) {\n return { width: measured.height, height: 0 };\n }\n\n return {\n width: Math.max(base.width, measured.height),\n height: base.height,\n };\n }\n\n if (!base) {\n return { width: 0, height: measured.height };\n }\n\n return {\n width: base.width,\n height: Math.max(base.height, measured.height),\n };\n }\n\n /**\n * Returns the current text content, or an empty string if none is set.\n *\n * @returns The current text string, or \"\" if no text is set.\n */\n getText() {\n return this._options.text || \"\";\n }\n\n /**\n * Sets the text content, recalculates the preferred size, and updates the DOM element.\n *\n * @param text - The new text to display.\n *\n * @returns This component, for method chaining.\n */\n setText(text: String): this {\n this._options.text = (text || \"\") as TOptions[\"text\"];\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n let element = this.getElement();\n if (!element) {\n return this;\n }\n\n DOM.sink.apply(element, { text: text.valueOf() });\n\n return this;\n }\n\n /**\n * Enables or disables automatic text measurement on `setText`.\n *\n * @param enabled - When `false`, `setText` skips the off-screen probe and\n * leaves preferred size and baseline unchanged. Use only when\n * the parent layout (e.g. [`Fit`](/api/layout/classes/Fit)) sizes this Text from\n * the container, so the measured preferred size is unused.\n *\n * @returns This component, for method chaining.\n */\n setAutoMeasure(enabled: boolean): this {\n this._autoMeasure = enabled;\n\n return this;\n }\n\n /**\n * Returns the current CSS text-align value.\n *\n * @returns The CSS text-align string, or null if not set.\n */\n getTextAlign() {\n return this._options.textAlign ?? this._defaultOptions.textAlign ?? null;\n }\n\n /**\n * Sets the CSS text-align and updates the component's CSS rule.\n *\n * @param align - A CSS text-align value (e.g. \"left\", \"center\", \"right\").\n *\n * @returns This component, for method chaining.\n */\n setTextAlign(align: string): this {\n this._options.textAlign = align;\n\n this.setElementCSSRule(\"textAlign\", align);\n\n return this;\n }\n\n /**\n * Returns the CSS text-shadow value.\n *\n * @returns The CSS text-shadow string, or null if not set.\n */\n getTextShadow() {\n return this._options.textShadow ?? null;\n }\n\n /**\n * Sets the CSS text-shadow and updates the component's CSS rule.\n *\n * @param shadow - A CSS text-shadow value.\n *\n * @returns This component, for method chaining.\n */\n setTextShadow(shadow: string): this {\n this._options.textShadow = shadow;\n\n this.setElementCSSRule(\"textShadow\", shadow);\n\n return this;\n }\n\n /**\n * Removes the text-shadow CSS property from the component's CSS rule.\n *\n * @returns This component, for method chaining.\n */\n clearTextShadow(): this {\n if (this._options.textShadow === undefined) {\n return this;\n }\n\n this._options.textShadow = undefined;\n this.setElementCSSRule(\"textShadow\", null);\n\n return this;\n }\n\n /**\n * Returns the CSS font-family value.\n *\n * @returns The CSS font-family string, or null if not set.\n */\n getFontFamily() {\n return this._options.fontFamily ?? this._defaultOptions.fontFamily ?? null;\n }\n\n /**\n * Sets the CSS font-family, updates the rule, and recalculates preferred size.\n *\n * @param value - The CSS font-family string (e.g. \"sans-serif\", \"'Arial', sans-serif\").\n *\n * @returns This component, for method chaining.\n */\n setFontFamily(value: string): this {\n this._options.fontFamily = value;\n\n this.setElementCSSRule(\"fontFamily\", value);\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns the CSS font-kerning value.\n *\n * @returns The CSS font-kerning string, or null if not set.\n */\n getFontKerning() {\n return this._options.fontKerning ?? this._defaultOptions.fontKerning ?? null;\n }\n\n /**\n * Sets the CSS font-kerning and updates the component's CSS rule.\n *\n * @param value - A CSS font-kerning value (e.g. \"auto\", \"normal\", \"none\").\n *\n * @returns This component, for method chaining.\n */\n setFontKerning(value: string): this {\n this._options.fontKerning = value;\n\n this.setElementCSSRule(\"fontKerning\", value);\n\n return this;\n }\n\n /**\n * Returns the font size in pixels.\n *\n * @returns The font size as a number, or null if not set.\n *\n * @remarks When a CSS var is bound (the default), this re-resolves it\n * through `Util`'s theme-invalidated cache — so it tracks a theme change\n * live — rather than the caller/class fallback, which is a stale snapshot\n * of the last-resolved value.\n */\n getFontSize() {\n if (this._fontSizeCSSVar) {\n const resolved = this.resolveBoundFontSizePx();\n\n if (resolved !== null) {\n return resolved;\n }\n }\n\n return (this._options.fontSize as number | undefined) ?? (this._defaultOptions.fontSize as number | undefined) ?? null;\n }\n\n /**\n * Sets the font size. Pass a number for an explicit pixel value, or a CSS variable name\n * (e.g. `\"--ts-ui-header-font-size\"`) to bind to a theme token.\n *\n * @param value - Pixel size as a number, or a CSS custom property name as a string.\n *\n * @returns This component, for method chaining.\n */\n setFontSize(value: number | string): this {\n if (typeof value === 'number') {\n this._options.fontSize = value as TOptions[\"fontSize\"];\n this._fontSizeCSSVar = null;\n this._fontSizeCSSRule = null;\n this.setElementCSSRule(\"fontSize\", value + \"px\");\n } else {\n const fallbackPx = (this.getFontSize() as number | undefined) ?? 14;\n this._fontSizeCSSVar = value;\n this._fontSizeCSSRule = `var(${value}, ${fallbackPx}px)`;\n this.setElementCSSRule(\"fontSize\", this._fontSizeCSSRule);\n\n // Cache the resolved px so line-box/baseline math has the real size\n // even pre-attach — resolveBoundFontSizePx probes the cascade for a\n // calc()-valued token rather than parseFloat-ing its raw var string.\n const resolved = this.resolveBoundFontSizePx();\n if (resolved !== null) {\n this._options.fontSize = resolved as TOptions[\"fontSize\"];\n }\n }\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns the CSS font-size-adjust value.\n *\n * @returns The CSS font-size-adjust string, or null if not set.\n */\n getFontSizeAdjust() {\n return this._options.fontSizeAdjust ?? this._defaultOptions.fontSizeAdjust ?? null;\n }\n\n /**\n * Sets the CSS font-size-adjust and updates the component's CSS rule.\n *\n * @param value - A CSS font-size-adjust value.\n *\n * @returns This component, for method chaining.\n */\n setFontSizeAdjust(value: string): this {\n this._options.fontSizeAdjust = value;\n\n this.setElementCSSRule(\"fontSizeAdjust\", value);\n\n return this;\n }\n\n /**\n * Returns the CSS font-stretch value.\n *\n * @returns The CSS font-stretch string, or null if not set.\n */\n getFontStretch() {\n return this._options.fontStretch ?? this._defaultOptions.fontStretch ?? null;\n }\n\n /**\n * Sets the CSS font-stretch and updates the component's CSS rule.\n *\n * @param value - A CSS font-stretch value (e.g. \"normal\", \"condensed\", \"expanded\").\n *\n * @returns This component, for method chaining.\n */\n setFontStretch(value: string): this {\n this._options.fontStretch = value;\n\n this.setElementCSSRule(\"fontStretch\", value);\n\n return this;\n }\n\n /**\n * Returns the CSS font-style value (e.g. \"normal\", \"italic\").\n *\n * @returns The CSS font-style string, or null if not set.\n */\n getFontStyle() {\n return this._options.fontStyle ?? this._defaultOptions.fontStyle ?? null;\n }\n\n /**\n * Sets the CSS font-style and updates the component's CSS rule.\n *\n * @param value - A CSS font-style value (e.g. \"normal\", \"italic\", \"oblique\").\n *\n * @returns This component, for method chaining.\n */\n setFontStyle(value: string): this {\n this._options.fontStyle = value;\n\n this.setElementCSSRule(\"fontStyle\", value);\n\n return this;\n }\n\n /**\n * Returns the CSS font-variant value.\n *\n * @returns The CSS font-variant string, or null if not set.\n */\n getFontVariant() {\n return this._options.fontVariant ?? this._defaultOptions.fontVariant ?? null;\n }\n\n /**\n * Sets the CSS font-variant and updates the component's CSS rule.\n *\n * @param value - A CSS font-variant value (e.g. \"normal\", \"small-caps\").\n *\n * @returns This component, for method chaining.\n */\n setFontVariant(value: string): this {\n this._options.fontVariant = value;\n\n this.setElementCSSRule(\"fontVariant\", value);\n\n return this;\n }\n\n /**\n * Returns the CSS font-weight value.\n *\n * @returns The CSS font-weight string, or null if not set.\n */\n getFontWeight() {\n return this._options.fontWeight ?? this._defaultOptions.fontWeight ?? null;\n }\n\n /**\n * Sets the CSS font-weight, updates the rule, and recalculates preferred size.\n *\n * @param value - A CSS font-weight value (e.g. \"normal\", \"bold\", \"700\").\n *\n * @returns This component, for method chaining.\n */\n setFontWeight(value: string): this {\n this._options.fontWeight = value;\n\n this.setElementCSSRule(\"fontWeight\", value);\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns the line height in pixels.\n *\n * @returns The caller/setter value when one was set; otherwise the\n * resolved additive line box (font size plus the theme's line padding).\n */\n getLineHeight() {\n return (this._options.lineHeight as number | undefined) ?? (this._defaultOptions.lineHeight as number | undefined) ?? this.readThemeLineHeightPx();\n }\n\n /**\n * Sets the line height. Pass a number for an explicit fixed pixel value\n * (which stops tracking the theme — this is the per-control override of the\n * additive default), or a CSS variable name to bind the line box to a\n * custom token, resolved as a fixed line box for measurement.\n *\n * @param value - Pixel value as a number, or a CSS custom property name as a string.\n *\n * @returns This component, for method chaining.\n */\n setLineHeight(value: number | string): this {\n if (typeof value === 'number') {\n // Idempotent re-apply: a no-op numeric line-height must not re-arm\n // the layout flush. CellRenderer.doLayout syncs the Text child's\n // line-height to the cell height on every pass; without this guard\n // that unconditional scheduleLayout below re-dirtied the renderer\n // each frame, spinning a silent CPU-pinning relayout loop. Only skip\n // when already in pure-numeric mode with the same value (the initial\n // additive-rule state has a non-null _lineHeightCSSRule, so the first\n // apply still runs). Mirrors the framework's \"unchanged value → early\n // return before scheduleLayout\" idiom (Card.setVisibleComponentId).\n if (this._options.lineHeight === value && this._lineHeightCSSVar === null && this._lineHeightCSSRule === null) {\n return this;\n }\n\n this._options.lineHeight = value as TOptions[\"lineHeight\"];\n this._lineHeightCSSVar = null;\n this._lineHeightCSSRule = null;\n this.setElementCSSRule(\"lineHeight\", value + \"px\");\n } else {\n this._lineHeightCSSVar = value;\n this._lineHeightCSSRule = `var(${value}, ${ADDITIVE_LINE_HEIGHT_RULE})`;\n this._options.lineHeight = this.readThemeLineHeightPx() as TOptions[\"lineHeight\"];\n this.setElementCSSRule(\"lineHeight\", this._lineHeightCSSRule);\n }\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Sets the line-height equal to the given pixel height so a single-line\n * text sits vertically centred in a fixed-height inline box.\n *\n * @param px - Pixel value matching the container's height, or `null` to\n * revert to the theme's additive line box (font size +\n * `--ts-ui-line-padding`).\n *\n * @returns This component, for method chaining.\n *\n * @example\n * ```typescript\n * const label = new Text(\"File\");\n * label.centerInHeight(28);\n * ```\n */\n centerInHeight(px: number | null): this {\n if (px === null) {\n this._lineHeightCSSVar = null;\n this._lineHeightCSSRule = ADDITIVE_LINE_HEIGHT_RULE;\n this._options.lineHeight = this.readThemeLineHeightPx() as TOptions[\"lineHeight\"];\n this.setElementCSSRule(\"lineHeight\", this._lineHeightCSSRule);\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n return this.setLineHeight(px);\n }\n\n /**\n * Returns the CSS text-overflow value last passed to {@link setTextOverflow},\n * or `null` if not set.\n *\n * @returns The text-overflow string, or null.\n */\n getTextOverflow(): string | null {\n return this._textOverflow;\n }\n\n /**\n * Sets the CSS text-overflow property and updates the component's CSS rule.\n *\n * @param value - A CSS text-overflow value (e.g. \"clip\", \"ellipsis\").\n *\n * @returns This component, for method chaining.\n */\n setTextOverflow(value: string): this {\n this._textOverflow = value;\n\n this.setElementCSSRule(\"textOverflow\", value);\n\n return this;\n }\n\n /**\n * Removes the text-overflow CSS property from the component's CSS rule.\n *\n * @returns This component, for method chaining.\n */\n clearTextOverflow(): this {\n if (this._textOverflow === null) {\n return this;\n }\n\n this._textOverflow = null;\n this.setElementCSSRule(\"textOverflow\", null);\n\n return this;\n }\n\n /**\n * Returns whether single-line truncation + ellipsis is enabled (default `true`).\n *\n * @returns `true` when the text clips with \"…\" once narrower than its\n * natural width; `false` when the text refuses to shrink past its\n * natural width.\n */\n isTruncate(): boolean {\n return this._truncate;\n }\n\n /**\n * Toggles single-line truncation mode. When `true`, the text renders as\n * single-line + `overflow: hidden` + `text-overflow: ellipsis` and reports\n * `minSize.width = Math.min(natural, 100)`. When `false`, those CSS\n * properties are cleared and the text reports its full natural width as\n * `minSize.width` so parent layouts widen to fit instead of clipping.\n *\n * @param value - `true` to enable ellipsised truncation, `false` to\n * disable (the text expands to its natural width).\n *\n * @returns This component, for method chaining.\n */\n setTruncate(value: boolean): this {\n this._truncate = value;\n\n if (value) {\n this.setWhiteSpace(\"nowrap\");\n this.setOverflow(\"hidden\");\n this.setTextOverflow(\"ellipsis\");\n } else {\n this.setElementCSSRule(\"whiteSpace\", null);\n this.setOverflow(\"visible\");\n this.setElementCSSRule(\"textOverflow\", null);\n this._textOverflow = null;\n }\n\n // The auto-min cap depends on `_truncate`; re-measure so the parent\n // layout sees the new floor on the next layout pass.\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns the current CSS `word-break` value, or null if not set.\n *\n * @returns The word-break string, or null.\n */\n getWordBreak(): string | null {\n return this._wordBreak;\n }\n\n /**\n * Sets the CSS `word-break` property on the component's CSS rule.\n *\n * @param value - A CSS word-break value (e.g. \"break-word\", \"normal\", \"keep-all\").\n *\n * @returns This component, for method chaining.\n */\n setWordBreak(value: string): this {\n if (this._wordBreak === value) {\n return this;\n }\n\n this._wordBreak = value;\n this.setElementCSSRule(\"wordBreak\", value);\n\n return this;\n }\n\n /**\n * Returns the current line-clamp line count, or null if no clamp is applied.\n *\n * @returns The maximum line count, or null.\n */\n getLineClamp(): number | null {\n return this._lineClamp;\n }\n\n /**\n * Clamps the rendered text to a maximum line count via CSS line-clamp.\n *\n * Writes `display: -webkit-box`, `-webkit-box-orient: vertical`,\n * `-webkit-line-clamp`, `overflow: hidden`, and `text-overflow: ellipsis`\n * in a single call. Use {@link clearLineClamp} to remove the clamp.\n *\n * @param lines - The maximum number of lines to display before the ellipsis.\n *\n * @returns This component, for method chaining.\n */\n setLineClamp(lines: number): this {\n if (this._lineClamp === lines) {\n return this;\n }\n\n this._lineClamp = lines;\n this.setElementCSSRules({\n display: \"-webkit-box\",\n webkitBoxOrient: \"vertical\",\n webkitLineClamp: String(lines),\n overflow: \"hidden\",\n textOverflow: \"ellipsis\"\n });\n\n return this;\n }\n\n /**\n * Removes the line-clamp styling previously applied by {@link setLineClamp}.\n *\n * @returns This component, for method chaining.\n */\n clearLineClamp(): this {\n if (this._lineClamp === null) {\n return this;\n }\n\n this._lineClamp = null;\n this.setElementCSSRules({\n display: null,\n webkitBoxOrient: null,\n webkitLineClamp: null,\n overflow: null,\n textOverflow: null\n });\n\n return this;\n }\n\n /**\n * Applies all text-specific style properties to the element's CSS rule in addition to base styles.\n *\n * @param element - The element handle to apply styles to.\n */\n applyStyle(element: Handle): this {\n super.applyStyle(element);\n\n const fontSize = this.getFontSize();\n const lineHeight = this.getLineHeight();\n\n this.setElementCSSRules({\n fontFamily: this.getFontFamily() ?? '',\n textAlign: this.getTextAlign() ?? '',\n textShadow: this.getTextShadow() ?? '',\n fontKerning: this.getFontKerning() ?? '',\n fontSize: this._fontSizeCSSRule ?? (fontSize !== null ? `${fontSize}px` : ''),\n fontSizeAdjust: this.getFontSizeAdjust() ?? '',\n fontStretch: this.getFontStretch() ?? '',\n fontStyle: this.getFontStyle() ?? '',\n fontVariant: this.getFontVariant() ?? '',\n fontWeight: this.getFontWeight() ?? '',\n lineHeight: this._lineHeightCSSRule ?? (lineHeight !== null ? `${lineHeight}px` : '')\n });\n\n return this;\n }\n\n /**\n * Renders the element and sets its text content.\n *\n * @returns The created element with textContent initialised.\n */\n protected render() {\n let element = super.render();\n\n DOM.sink.apply(element, { text: this.getText().valueOf() });\n\n return element;\n }\n}\n\nconst TextCallable = callable(Text);\ntype TextCallable<TOptions extends TextOptions = TextOptions> = Text<TOptions>;\nexport {\n Text as _Text,\n TextCallable as Text\n};\n"],"mappings":"oIA0DA,IAAM,EAA4C,CAC9C,IAAgB,OAChB,UAAgB,OAChB,WAAgB,kDAChB,YAAgB,OAChB,SAAgB,GAChB,eAAgB,OAChB,YAAgB,SAChB,UAAgB,SAChB,YAAgB,SAChB,WAAgB,SAChB,SAAgB,EACpB,EAMM,EAA6B,IAO7B,EAA4B,6CAU5B,KAAN,cAA+D,CAAoB,CAE/E,0BAA6C,GAC7C,gBAA0C,oBAC1C,iBAA0C,+BAC1C,kBAA4C,KAC5C,mBAA4C,EAC5C,kBAA2C,KAC3C,iBAAwC,KACxC,aAAgC,GAChC,kBAAqC,GAKrC,oBAAsC,GACtC,WAAoC,KACpC,WAAoC,KACpC,cAAuC,KACvC,UAA6B,GAO7B,YAAY,EAAe,EAA6B,EAAsC,CAC1F,MACI,EACA,CAAE,GAAG,EAAqB,GAAI,GAAoB,CAAC,CAAG,CAC1D,EAUA,KAAK,YAAY,EACjB,KAAK,kBAAkB,aAAc,KAAK,kBAAkB,EAKxD,IAAS,IAAA,IAAa,KAAK,SAAS,OAAS,IAAA,IAC7C,KAAK,QAAQ,CAAI,EAMrB,KAAK,kBAAoB,EAC7B,CASA,aAAuB,EAAyB,CAqE5C,OApEA,MAAM,aAAa,CAAO,EAMtB,EAAQ,OAAS,IAAA,IACjB,KAAK,QAAQ,EAAQ,IAAI,EAGzB,EAAQ,YAAc,IAAA,IACtB,KAAK,aAAa,EAAQ,SAAS,EAGnC,EAAQ,aAAe,IAAA,IACvB,KAAK,cAAc,EAAQ,UAAU,EAGrC,EAAQ,aAAe,IAAA,IACvB,KAAK,cAAc,EAAQ,UAAU,EAGrC,EAAQ,WAAa,IAAA,IACrB,KAAK,YAAY,EAAQ,QAAQ,EAGjC,EAAQ,aAAe,IAAA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,KAAK,WAAa,KAClB,KAAK,mBAAmB,CACpB,QAAS,KACT,gBAAiB,KACjB,gBAAiB,KACjB,SAAU,KACV,aAAc,IAClB,CAAC,EAEM,KACX,CAOA,WAAW,EAAuB,CAC9B,MAAM,WAAW,CAAO,EAExB,IAAM,EAAa,KAAK,YAAY,EAC9B,EAAa,KAAK,cAAc,EAgBtC,OAdA,KAAK,mBAAmB,CACpB,WAAgB,KAAK,cAAc,GAAQ,GAC3C,UAAgB,KAAK,aAAa,GAAS,GAC3C,WAAgB,KAAK,cAAc,GAAQ,GAC3C,YAAgB,KAAK,eAAe,GAAO,GAC3C,SAAgB,KAAK,mBAAwB,IAAa,KAAyB,GAAlB,GAAG,EAAS,KAC7E,eAAgB,KAAK,kBAAkB,GAAK,GAC5C,YAAgB,KAAK,eAAe,GAAO,GAC3C,UAAgB,KAAK,aAAa,GAAS,GAC3C,YAAgB,KAAK,eAAe,GAAO,GAC3C,WAAgB,KAAK,cAAc,GAAQ,GAC3C,WAAgB,KAAK,qBAAwB,IAAe,KAA2B,GAApB,GAAG,EAAW,IACrF,CAAC,EAEM,IACX,CAOA,QAAmB,CACf,IAAI,EAAU,MAAM,OAAO,EAI3B,OAFA,EAAI,KAAK,MAAM,EAAS,CAAE,KAAM,KAAK,QAAQ,CAAC,CAAC,QAAQ,CAAE,CAAC,EAEnD,CACX,CACJ,EAEM,EAAe,EAAS,IAAI"}
1
+ {"version":3,"file":"Text-D5pg7taZ.js","names":[],"sources":["../../src/typescript/lib/component/input/Text.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { DOM } from \"~/core/DOM.js\";\nimport type { Handle } from \"~/core/DOM.js\";\nimport { Util } from \"~/core/Util.js\";\nimport { Size } from \"~/primitive/Size.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link Text}.\n *\n * @category Components\n */\nexport interface TextOptions extends ComponentOptions {\n tag?: string;\n text?: string;\n textAlign?: string;\n textShadow?: string;\n fontFamily?: string;\n fontSize?: number | string;\n fontWeight?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontStretch?: string;\n fontKerning?: string;\n fontSizeAdjust?: string;\n lineHeight?: number | string;\n textOverflow?: string;\n whiteSpace?: string;\n /**\n * When `true` (default), the text is single-line + clipped + ellipsised\n * when its rendered width is below its natural width, and `minSize.width`\n * is capped at `100` so parent layouts can shrink the text past its\n * natural width.\n *\n * When `false`, no ellipsis is applied and `minSize.width` reports the\n * full natural width — the text refuses to be squeezed, forcing the\n * parent to widen (used by [`Button`](/api/component/button/classes/Button)\n * for the label so the button grows to fit its text instead of clipping).\n */\n truncate?: boolean;\n}\n\n/**\n * Module-level class defaults forwarded to `super` via the options bag so the\n * `applyOptions` cascade dispatches each setter once with the final value.\n *\n * `lineHeight` is intentionally **omitted**: it is theme-derived\n * (`readThemeLineHeightPx()`), so its getter falls back to that resolver\n * directly rather than a value seeded here.\n *\n * `fontFamily` is a pure getter-fallback despite living in this bag:\n * `_defaultOptions.fontFamily` is consulted by `getFontFamily()`, but is\n * never dispatched through `setFontFamily(...)` — doing so would write the\n * literal `var(--ts-ui-font-family, …)` onto every Text's CSS rule, blocking\n * a parent's `font-family` override from cascading through.\n */\nconst _defaultTextOptions: Partial<TextOptions> = {\n tag: \"span\",\n textAlign: \"left\",\n fontFamily: \"var(--ts-ui-font-family, system-ui, sans-serif)\",\n fontKerning: \"auto\",\n fontSize: 14,\n fontSizeAdjust: \"none\",\n fontStretch: \"normal\",\n fontStyle: \"normal\",\n fontVariant: \"normal\",\n fontWeight: \"normal\",\n truncate: true,\n};\n\n// Upper bound for the auto-derived `minSize.width` from text measurement —\n// short labels report their full measured width (so they're never truncated\n// when the container has room), longer text caps here so the parent layout\n// always has room to shrink the Text below its natural width.\nconst TEXT_AUTO_MIN_WIDTH_CAP_PX = 100;\n\n// Default theme-tracking line-height rule: the control's own font size plus the\n// `--ts-ui-line-padding` leading, so the line box scales per font size. `1em`\n// resolves against the element's own font-size at both render and measure time.\n// `2px` is the shipped `--ts-ui-line-padding` default, used only if the var is\n// absent. A control overrides this with an explicit px via `setLineHeight`.\nconst ADDITIVE_LINE_HEIGHT_RULE = \"calc(1em + var(--ts-ui-line-padding, 2px))\";\n\n/**\n * A text-displaying component with comprehensive font and layout controls.\n *\n * Uses an off-screen probe element to measure text dimensions and automatically\n * updates the preferred size whenever the text or a font property changes.\n *\n * @category Components\n */\nclass Text<TOptions extends TextOptions = TextOptions> extends Component<TOptions> {\n\n private _hasExplicitPreferredSize: boolean = false;\n private _fontSizeCSSVar : string | null = \"--ts-ui-font-size\";\n private _fontSizeCSSRule: string | null = \"var(--ts-ui-font-size, 14px)\";\n private _lineHeightCSSVar : string | null = null;\n private _lineHeightCSSRule: string | null = ADDITIVE_LINE_HEIGHT_RULE;\n private _measuredBaseline: number | null = null;\n private _measuredMinSize: Size | null = null;\n private _autoMeasure: boolean = true;\n private _measurementDirty: boolean = true;\n // The `Util.textMetricsGeneration()` value as of the last `calculateSize`,\n // so a theme change (which bumps the generation) is noticed lazily by\n // `needsMeasure()` without Text holding its own theme subscription. `-1`\n // never matches a real generation, so an unmeasured Text is always due.\n private _measuredGeneration: number = -1;\n private _wordBreak: string | null = null;\n private _lineClamp: number | null = null;\n private _textOverflow: string | null = null;\n private _truncate: boolean = true;\n\n // `NoInfer` on `options` keeps a partial options literal from narrowing\n // TOptions to just the keys it carries: `new Text(\"x\", { fontWeight: \"600\" })`\n // must stay a `Text<TextOptions>` (assignable to Component), not a\n // `Text<{ fontWeight: string }>` (whose narrowed option type is not). Subclasses\n // still fix TOptions through `extends Text<MyOptions>`, not argument inference.\n constructor(text?: String, options?: NoInfer<TOptions>, subclassDefaults?: Partial<TOptions>) {\n super(\n options,\n { ..._defaultTextOptions, ...(subclassDefaults ?? {}) } as Partial<TOptions>,\n );\n\n // The cascade-driven `setFontSize(14)` clobbers `fontSizeCSSVar` and\n // `fontSizeCSSRule` to null, but Text's field initializers (which run\n // after super returns, i.e. right above this line) restore both to\n // their var-binding values — so theme reactivity is preserved by the\n // DOM `var(...)` binding even though the cascade temporarily writes a\n // literal. `getFontSize()` / `getLineHeight()` re-resolve those bound\n // vars live (through `Util`'s theme-invalidated metrics cache) rather\n // than caching a value that would go stale on a theme change.\n this.clearInsets();\n this.setElementCSSRule(\"lineHeight\", this._lineHeightCSSRule);\n\n // Positional `text` constructor argument: write to the bag only when\n // the caller didn't also pass `options.text` (which would have been\n // dispatched via super's applyOptions cascade and should win).\n if (text !== undefined && this._options.text === undefined) {\n this.setText(text);\n }\n\n // Off-screen text measurement is deferred until the first\n // getPreferredSize / getBaseline call so construction stays JS-only\n // (no forced layout from `DOM.source.measureText`).\n this._measurementDirty = true;\n }\n\n /**\n * Applies a {@link TextOptions} bag to this component, dispatching font and\n * text properties to their corresponding setters after the inherited\n * Component fields have been applied.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: TOptions): this {\n super.applyOptions(options);\n\n // Dispatch only caller-supplied values. Class-level font defaults (e.g.\n // the 14px size, a subclass's bold weight) are resolved lazily by the\n // font getters' `_defaultOptions` fallback, which `applyStyle` re-reads\n // at render — so they never enter `_options`.\n if (options.text !== undefined) {\n this.setText(options.text);\n }\n\n if (options.textAlign !== undefined) {\n this.setTextAlign(options.textAlign);\n }\n\n if (options.textShadow !== undefined) {\n this.setTextShadow(options.textShadow);\n }\n\n if (options.fontFamily !== undefined) {\n this.setFontFamily(options.fontFamily);\n }\n\n if (options.fontSize !== undefined) {\n this.setFontSize(options.fontSize);\n }\n\n if (options.fontWeight !== undefined) {\n this.setFontWeight(options.fontWeight);\n }\n\n if (options.fontStyle !== undefined) {\n this.setFontStyle(options.fontStyle);\n }\n\n if (options.fontVariant !== undefined) {\n this.setFontVariant(options.fontVariant);\n }\n\n if (options.fontStretch !== undefined) {\n this.setFontStretch(options.fontStretch);\n }\n\n if (options.fontKerning !== undefined) {\n this.setFontKerning(options.fontKerning);\n }\n\n if (options.fontSizeAdjust !== undefined) {\n this.setFontSizeAdjust(options.fontSizeAdjust);\n }\n\n if (options.lineHeight !== undefined) {\n this.setLineHeight(options.lineHeight);\n }\n\n if (options.textOverflow !== undefined) {\n this.setTextOverflow(options.textOverflow);\n }\n\n if (options.whiteSpace !== undefined) {\n this.setWhiteSpace(options.whiteSpace);\n }\n\n // `truncate` carries a class default (true) and applies its CSS\n // (white-space / overflow / text-overflow) imperatively via the setter\n // with no render re-read, so always dispatch the caller value or the\n // default — otherwise a default-truncating Text never gets the CSS.\n this.setTruncate(options.truncate ?? this._defaultOptions.truncate!);\n\n return this;\n }\n\n /**\n * Resolves this `Text`'s line box height in pixels under the additive\n * leading model.\n *\n * @returns `Util.lineHeightPx(fontSize)` — the control's own font size plus\n * the `--ts-ui-line-padding` leading — for the default theme-tracking case.\n * A legacy custom line-height var binding resolves that var as a fixed line\n * box instead, falling back to the additive value when it is unparseable.\n *\n * @remarks `_options.fontSize` is always a resolved px number here (a CSS\n * var passed to `setFontSize` is resolved and stored as a number), so the\n * leading scales with the control's actual font size — a 12px button title\n * and a 14px label get proportionate line boxes from the one token. This is\n * the same arithmetic `Util.lineHeightPx` applies for input box heights, so\n * a `Text` measures and renders at the line height a sibling input expects.\n */\n private readThemeLineHeightPx(): number {\n // `_options.fontSize` is the resolved px the bound var evaluates to —\n // `setFontSize`/`onThemeChange` populate it through the probe-backed\n // `resolveBoundFontSizePx`, so it is correct even pre-attach (a calc()\n // token included). No element read here: a parent reads this at\n // construction, before this Text's own element is styled.\n const fs = (this._options.fontSize as number | undefined) ?? (this._defaultOptions.fontSize as number | undefined) ?? 14;\n\n if (this._lineHeightCSSVar) {\n const raw = DOM.source.getThemeVar(this._lineHeightCSSVar);\n const parsed = parseFloat(raw);\n\n if (!isNaN(parsed)) {\n return parsed;\n }\n }\n\n return Util.lineHeightPx({ fontSizePx: fs });\n }\n\n /**\n * Returns the DOM element handle.\n *\n * @param createIfMissing - Optional. When true, renders the element if it does not yet exist.\n *\n * @returns The component's element handle.\n */\n getElement(createIfMissing: boolean = false): Handle | undefined {\n return super.getElement(createIfMissing);\n }\n\n /**\n * Resolves the bound font-size var to a px number. A simple var (e.g. the\n * `--ts-ui-font-size` base) parses straight off the document root; a relative\n * font token's var holds a `calc(...)` that `getPropertyValue` returns\n * unevaluated (so `parseFloat` reads `NaN`), so it falls back to a\n * cascade-evaluating probe via `DOM.source.resolveFontSizePx`. The probe path\n * works **pre-attach** — before this component's own element is styled —\n * which is when a parent (e.g. a `Header`) first reads the line-box size.\n *\n * @returns The resolved font size in px, or `null` when no var is bound (an\n * explicit numeric size was set instead) — callers keep the cached number.\n */\n private resolveBoundFontSizePx(): number | null {\n if (!this._fontSizeCSSVar) return null; // explicit px size — no var bound\n\n return Util.boundFontSizePx(this._fontSizeCSSVar, this._fontSizeCSSRule);\n }\n\n /**\n * Sets the preferred size from an explicit caller, locking it against automatic recalculation.\n *\n * @param size - The preferred size in pixels.\n *\n * @returns This component, for method chaining.\n */\n setPreferredSize(size: Size): this {\n this._hasExplicitPreferredSize = true;\n super.setPreferredSize(size);\n\n return this;\n }\n\n /**\n * Updates the preferred size from a measurement only when no explicit size has been set.\n */\n private setCalculatedSize(width: number, height: number): void {\n if (!this._hasExplicitPreferredSize) {\n super.setPreferredSize({ width: width, height: height });\n }\n }\n\n /**\n * Measures the text using an off-screen probe element and sets the preferred size.\n *\n * @remarks Creates a temporary fixed-positioned invisible `<span>`, appends it to the body\n * to obtain its bounding rect, then removes it. Sets preferred size to (0, 0) when no text is set.\n * No-op when {@link setAutoMeasure} is `false` — the parent layout is expected to size this Text.\n */\n private calculateSize(): void {\n this._measurementDirty = false;\n this._measuredGeneration = Util.textMetricsGeneration();\n\n if (!this._autoMeasure) {\n return;\n }\n\n // Floor the reported minimum height to one line so a single-line label\n // is never squeezed below its line box (the measured height is 0 for\n // empty text and unset before the first probe).\n const lineHeightPx = this.getLineHeight() ?? this.readThemeLineHeightPx();\n const minLineHeight = Math.ceil(lineHeightPx);\n\n const text = this._options.text;\n if (text) {\n // Natural (single-line) measurement establishes the preferred WIDTH\n // and the baseline; the height then follows the box's current width,\n // growing when a wrapping run has been laid out narrower than natural.\n const natural = DOM.source.measureText(text.toString(), this.measureOptions());\n const height = this.measuredHeight(text.toString(), natural.width, natural.height);\n\n this._measuredBaseline = natural.baseline;\n this.setCalculatedSize(natural.width, height);\n // Store the measured floor as per-instance derived state (like\n // `_measuredBaseline`), kept out of `_defaultOptions`, which holds\n // the class-level Text defaults rather than per-instance\n // measurements. `getMinSize` folds this into the inherited min.\n // When truncation is disabled, report the full natural width so the\n // parent layout widens to fit instead of squeezing the text;\n // otherwise cap it so the parent can shrink the text past its\n // natural width.\n const autoMinWidth = this._truncate\n ? Math.min(natural.width, TEXT_AUTO_MIN_WIDTH_CAP_PX)\n : natural.width;\n this._measuredMinSize = {\n width: autoMinWidth,\n height: Math.max(height, minLineHeight),\n };\n } else {\n // No glyphs means no baseline — report null so HBox doesn't try\n // to baseline-align surrounding components against an empty box.\n // Reserve no line height either: an empty Text (e.g. the label slot\n // of an icon-only button) must collapse so it doesn't inflate the\n // container and knock the icon off-centre. The one-line floor only\n // applies once there is text to keep on its line.\n this._measuredBaseline = null;\n this.setCalculatedSize(0, 0);\n this._measuredMinSize = { width: 0, height: 0 };\n }\n }\n\n /**\n * Whether the cached measurement is stale — either because something\n * marked it dirty (a text/font change) or because the active theme's\n * text metrics have moved on since the last measurement.\n *\n * @returns `true` when the next size/baseline read should re-measure.\n *\n * @remarks Replaces a per-instance `ThemeManager` subscription: instead of\n * every `Text` re-measuring eagerly on each theme change, it compares its\n * own `_measuredGeneration` against `Util.textMetricsGeneration()` lazily,\n * the next time a caller actually asks for a size.\n */\n private needsMeasure(): boolean {\n return this._measurementDirty || this._measuredGeneration !== Util.textMetricsGeneration();\n }\n\n /**\n * Forces a one-off text measurement that ignores {@link setAutoMeasure}.\n * Use when the caller has opted out of auto-measure but needs an up-to-date\n * preferred size after a programmatic text change.\n */\n measure(): void {\n const wasAuto = this._autoMeasure;\n this._autoMeasure = true;\n this.calculateSize();\n this._autoMeasure = wasAuto;\n }\n\n /**\n * Returns the visual baseline of the rendered text, accounting for any\n * border, padding, or framework insets on this component.\n *\n * @returns The baseline offset from the component's outer top, in pixels,\n * or `null` when no text has been measured yet.\n *\n * @remarks Forces a measurement when the cached value is stale — the\n * off-screen probe is deferred from construction so first-call timing\n * shifts to whoever asks for a size first (usually `doLayout`).\n */\n getBaseline(): number | null {\n if (this.needsMeasure()) {\n this.calculateSize();\n }\n\n return this.wrapInnerBaseline(this._measuredBaseline);\n }\n\n /**\n * Builds the font/line-height option bag for a {@link DOM.measureText} probe\n * from this Text's resolved styling. Shared by the natural (single-line)\n * measurement and the wrap-aware height re-measurement in\n * {@link measuredHeight}, which adds a `maxWidth`.\n *\n * @returns The measure options (font family/size/weight/style/variant/stretch\n * and line height), each `undefined` when unset so the probe's own default\n * applies.\n */\n private measureOptions() {\n const fontSize = this.getFontSize();\n const lineHeight = this.getLineHeight();\n\n return {\n fontFamily : this.getFontFamily() ?? undefined,\n fontSize : this._fontSizeCSSRule ?? (fontSize !== null ? `${fontSize}px` : undefined),\n fontWeight : this.getFontWeight() ?? undefined,\n fontStyle : this.getFontStyle() ?? undefined,\n fontVariant: this.getFontVariant() ?? undefined,\n fontStretch: this.getFontStretch() ?? undefined,\n lineHeight : this._lineHeightCSSRule ?? (lineHeight !== null ? `${lineHeight}px` : undefined),\n };\n }\n\n /**\n * Whether this Text wraps onto multiple lines — i.e. its `white-space` is a\n * wrapping value rather than `nowrap`/`pre`. Only a wrapping Text's height\n * depends on the width it is given.\n *\n * @returns `true` when the text soft-wraps at its box width.\n */\n private isWrapping(): boolean {\n const ws = this.getWhiteSpace();\n\n return ws === \"normal\" || ws === \"pre-wrap\" || ws === \"pre-line\" || ws === \"break-spaces\";\n }\n\n /**\n * The height the text needs given its current laid-out width.\n *\n * A `nowrap` label — or one not yet given a width, or in a vertical writing\n * mode — is width-independent, so its natural single-line height stands. A\n * wrapping label whose box is narrower than its natural run re-measures at\n * the current inner width (its own border/insets removed): the extra lines\n * make it taller. The re-measure uses the same line-height as the render, so\n * the reported height matches what is drawn — line-height is the per-line\n * unit the whole calculation stacks.\n *\n * @param text - The text run being measured.\n * @param naturalWidth - The natural single-line width (nowrap), the wrap threshold.\n * @param naturalHeight - The natural single-line height, used when it does not wrap.\n * @returns The height (px) at the current width; floored at one line.\n */\n private measuredHeight(text: string, naturalWidth: number, naturalHeight: number): number {\n if (!this.isWrapping() || this.isVerticalWritingMode()) {\n return naturalHeight;\n }\n\n const width = this.getWidth();\n\n if (Number.isNaN(width)) {\n return naturalHeight;\n }\n\n const perimeter = this.getPerimeterSize();\n const innerWidth = width - perimeter.left - perimeter.right;\n\n // Wide enough for the whole run on one line → no wrapping; keep the exact\n // single-line height and skip a redundant probe.\n if (innerWidth >= naturalWidth) {\n return naturalHeight;\n }\n\n const wrapped = DOM.source.measureText(text, { ...this.measureOptions(), maxWidth: innerWidth });\n const minLineHeight = Math.ceil(this.getLineHeight() ?? this.readThemeLineHeightPx());\n\n return Math.max(wrapped.height, minLineHeight);\n }\n\n /**\n * Sets the laid-out width and, for a wrapping Text, re-measures at the new\n * width so its preferred height tracks the number of wrapped lines.\n *\n * A wrapping run's height depends on the width it is given, but the\n * preferred-size protocol resolves heights bottom-up before widths are\n * assigned top-down — so the height is only knowable once the box has a\n * width. Re-measuring here updates the preferred height, and\n * `Component.setPreferredSize` fires the ancestor notify, so the parent\n * re-lays-out one pass later at the taller height (the box's own min height\n * also rises, so the current pass already reserves the room rather than\n * clipping). A `nowrap` label's height is width-independent, so its width\n * changes need no re-measure. Idempotent once the width settles: an\n * unchanged width re-measures to the same height and the notify is suppressed.\n *\n * @param width - The new outer width in pixels.\n * @returns This component, for chaining.\n */\n override setWidth(width: number): this {\n const previous = this.getWidth();\n\n super.setWidth(width);\n\n if (this.isWrapping() && this.getWidth() !== previous) {\n this._measurementDirty = true;\n // Re-measure now (at the new width) so the updated preferred height\n // propagates before the next layout pass reads it.\n this.calculateSize();\n }\n\n return this;\n }\n\n /**\n * Returns the preferred size, lazily measuring the text on the first call.\n *\n * @returns The preferred Size, or `null` per the inherited contract.\n *\n * @remarks Construction no longer eagerly probes `document.body` for text\n * dimensions; the first reader of the preferred size pays the measurement\n * cost. After attach this is `doLayout`, so the probe happens at layout\n * time rather than construction time.\n */\n getPreferredSize() {\n if (this.needsMeasure()) {\n this.calculateSize();\n }\n\n const size = super.getPreferredSize();\n\n // `measureTextMetrics` always measures the run horizontally. A vertical\n // writing mode rotates it onto the block axis, so the natural text length\n // becomes the height and the line box becomes the width — swap to report\n // the on-screen extents.\n if (size && this.isVerticalWritingMode()) {\n return { width: size.height, height: size.width };\n }\n\n return size;\n }\n\n /**\n * Whether the active {@link Component.setWritingMode | writing mode} rotates\n * the text run onto the block (vertical) axis, so the measured horizontal\n * extents must be swapped to describe the on-screen size.\n *\n * @returns `true` for a `vertical-*` or `sideways-*` writing mode.\n */\n private isVerticalWritingMode(): boolean {\n const mode = this.getWritingMode();\n\n return mode !== null && (mode.startsWith(\"vertical\") || mode.startsWith(\"sideways\"));\n }\n\n /**\n * Returns the effective minimum size, folding the measured one-line height\n * floor (from `calculateSize`) into the inherited component/layout minimum.\n *\n * @returns The minimum `{width, height}`, never shorter than one line of\n * text, or `null` only when neither a measurement nor an inherited minimum\n * exists.\n *\n * @remarks Only the **height** floor participates in the hard minimum —\n * text cannot render below its line box without clipping. The measured\n * width is deliberately *not* folded in: surfacing each label's natural\n * width as a hard minimum would stop parent layouts (e.g. an equal-mode tab\n * bar) from compressing short labels to fit, which is why `Text.minSize`\n * has historically reported a zero width. The floor is per-instance derived\n * state held in `_measuredMinSize`, not a class default, so it lives outside\n * `_defaultOptions`. An explicit caller `setMinSize` taller than the floor\n * still wins via `Math.max`; a value shorter than one line is lifted to it.\n */\n getMinSize(): Size | null {\n if (this.needsMeasure()) {\n this.calculateSize();\n }\n\n const measured = this._measuredMinSize;\n const base = super.getMinSize();\n\n if (!measured) {\n return base;\n }\n\n // Vertical writing mode: the one-line floor guards the line *thickness*,\n // which is now the width rather than the height (the length runs down the\n // block axis and stays freely compressible).\n if (this.isVerticalWritingMode()) {\n if (!base) {\n return { width: measured.height, height: 0 };\n }\n\n return {\n width: Math.max(base.width, measured.height),\n height: base.height,\n };\n }\n\n if (!base) {\n return { width: 0, height: measured.height };\n }\n\n return {\n width: base.width,\n height: Math.max(base.height, measured.height),\n };\n }\n\n /**\n * Returns the current text content, or an empty string if none is set.\n *\n * @returns The current text string, or \"\" if no text is set.\n */\n getText() {\n return this._options.text || \"\";\n }\n\n /**\n * Sets the text content, recalculates the preferred size, and updates the DOM element.\n *\n * @param text - The new text to display.\n *\n * @returns This component, for method chaining.\n */\n setText(text: String): this {\n this._options.text = (text || \"\") as TOptions[\"text\"];\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n let element = this.getElement();\n if (!element) {\n return this;\n }\n\n DOM.sink.apply(element, { text: text.valueOf() });\n\n return this;\n }\n\n /**\n * Enables or disables automatic text measurement on `setText`.\n *\n * @param enabled - When `false`, `setText` skips the off-screen probe and\n * leaves preferred size and baseline unchanged. Use only when\n * the parent layout (e.g. [`Fit`](/api/layout/classes/Fit)) sizes this Text from\n * the container, so the measured preferred size is unused.\n *\n * @returns This component, for method chaining.\n */\n setAutoMeasure(enabled: boolean): this {\n this._autoMeasure = enabled;\n\n return this;\n }\n\n /**\n * Returns the current CSS text-align value.\n *\n * @returns The CSS text-align string, or null if not set.\n */\n getTextAlign() {\n return this._options.textAlign ?? this._defaultOptions.textAlign ?? null;\n }\n\n /**\n * Sets the CSS text-align and updates the component's CSS rule.\n *\n * @param align - A CSS text-align value (e.g. \"left\", \"center\", \"right\").\n *\n * @returns This component, for method chaining.\n */\n setTextAlign(align: string): this {\n this._options.textAlign = align;\n\n this.setElementCSSRule(\"textAlign\", align);\n\n return this;\n }\n\n /**\n * Returns the CSS text-shadow value.\n *\n * @returns The CSS text-shadow string, or null if not set.\n */\n getTextShadow() {\n return this._options.textShadow ?? null;\n }\n\n /**\n * Sets the CSS text-shadow and updates the component's CSS rule.\n *\n * @param shadow - A CSS text-shadow value.\n *\n * @returns This component, for method chaining.\n */\n setTextShadow(shadow: string): this {\n this._options.textShadow = shadow;\n\n this.setElementCSSRule(\"textShadow\", shadow);\n\n return this;\n }\n\n /**\n * Removes the text-shadow CSS property from the component's CSS rule.\n *\n * @returns This component, for method chaining.\n */\n clearTextShadow(): this {\n if (this._options.textShadow === undefined) {\n return this;\n }\n\n this._options.textShadow = undefined;\n this.setElementCSSRule(\"textShadow\", null);\n\n return this;\n }\n\n /**\n * Returns the CSS font-family value.\n *\n * @returns The CSS font-family string, or null if not set.\n */\n getFontFamily() {\n return this._options.fontFamily ?? this._defaultOptions.fontFamily ?? null;\n }\n\n /**\n * Sets the CSS font-family, updates the rule, and recalculates preferred size.\n *\n * @param value - The CSS font-family string (e.g. \"sans-serif\", \"'Arial', sans-serif\").\n *\n * @returns This component, for method chaining.\n */\n setFontFamily(value: string): this {\n this._options.fontFamily = value;\n\n this.setElementCSSRule(\"fontFamily\", value);\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns the CSS font-kerning value.\n *\n * @returns The CSS font-kerning string, or null if not set.\n */\n getFontKerning() {\n return this._options.fontKerning ?? this._defaultOptions.fontKerning ?? null;\n }\n\n /**\n * Sets the CSS font-kerning and updates the component's CSS rule.\n *\n * @param value - A CSS font-kerning value (e.g. \"auto\", \"normal\", \"none\").\n *\n * @returns This component, for method chaining.\n */\n setFontKerning(value: string): this {\n this._options.fontKerning = value;\n\n this.setElementCSSRule(\"fontKerning\", value);\n\n return this;\n }\n\n /**\n * Returns the font size in pixels.\n *\n * @returns The font size as a number, or null if not set.\n *\n * @remarks When a CSS var is bound (the default), this re-resolves it\n * through `Util`'s theme-invalidated cache — so it tracks a theme change\n * live — rather than the caller/class fallback, which is a stale snapshot\n * of the last-resolved value.\n */\n getFontSize() {\n if (this._fontSizeCSSVar) {\n const resolved = this.resolveBoundFontSizePx();\n\n if (resolved !== null) {\n return resolved;\n }\n }\n\n return (this._options.fontSize as number | undefined) ?? (this._defaultOptions.fontSize as number | undefined) ?? null;\n }\n\n /**\n * Sets the font size. Pass a number for an explicit pixel value, or a CSS variable name\n * (e.g. `\"--ts-ui-header-font-size\"`) to bind to a theme token.\n *\n * @param value - Pixel size as a number, or a CSS custom property name as a string.\n *\n * @returns This component, for method chaining.\n */\n setFontSize(value: number | string): this {\n if (typeof value === 'number') {\n this._options.fontSize = value as TOptions[\"fontSize\"];\n this._fontSizeCSSVar = null;\n this._fontSizeCSSRule = null;\n this.setElementCSSRule(\"fontSize\", value + \"px\");\n } else {\n const fallbackPx = (this.getFontSize() as number | undefined) ?? 14;\n this._fontSizeCSSVar = value;\n this._fontSizeCSSRule = `var(${value}, ${fallbackPx}px)`;\n this.setElementCSSRule(\"fontSize\", this._fontSizeCSSRule);\n\n // Cache the resolved px so line-box/baseline math has the real size\n // even pre-attach — resolveBoundFontSizePx probes the cascade for a\n // calc()-valued token rather than parseFloat-ing its raw var string.\n const resolved = this.resolveBoundFontSizePx();\n if (resolved !== null) {\n this._options.fontSize = resolved as TOptions[\"fontSize\"];\n }\n }\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns the CSS font-size-adjust value.\n *\n * @returns The CSS font-size-adjust string, or null if not set.\n */\n getFontSizeAdjust() {\n return this._options.fontSizeAdjust ?? this._defaultOptions.fontSizeAdjust ?? null;\n }\n\n /**\n * Sets the CSS font-size-adjust and updates the component's CSS rule.\n *\n * @param value - A CSS font-size-adjust value.\n *\n * @returns This component, for method chaining.\n */\n setFontSizeAdjust(value: string): this {\n this._options.fontSizeAdjust = value;\n\n this.setElementCSSRule(\"fontSizeAdjust\", value);\n\n return this;\n }\n\n /**\n * Returns the CSS font-stretch value.\n *\n * @returns The CSS font-stretch string, or null if not set.\n */\n getFontStretch() {\n return this._options.fontStretch ?? this._defaultOptions.fontStretch ?? null;\n }\n\n /**\n * Sets the CSS font-stretch and updates the component's CSS rule.\n *\n * @param value - A CSS font-stretch value (e.g. \"normal\", \"condensed\", \"expanded\").\n *\n * @returns This component, for method chaining.\n */\n setFontStretch(value: string): this {\n this._options.fontStretch = value;\n\n this.setElementCSSRule(\"fontStretch\", value);\n\n return this;\n }\n\n /**\n * Returns the CSS font-style value (e.g. \"normal\", \"italic\").\n *\n * @returns The CSS font-style string, or null if not set.\n */\n getFontStyle() {\n return this._options.fontStyle ?? this._defaultOptions.fontStyle ?? null;\n }\n\n /**\n * Sets the CSS font-style and updates the component's CSS rule.\n *\n * @param value - A CSS font-style value (e.g. \"normal\", \"italic\", \"oblique\").\n *\n * @returns This component, for method chaining.\n */\n setFontStyle(value: string): this {\n this._options.fontStyle = value;\n\n this.setElementCSSRule(\"fontStyle\", value);\n\n return this;\n }\n\n /**\n * Returns the CSS font-variant value.\n *\n * @returns The CSS font-variant string, or null if not set.\n */\n getFontVariant() {\n return this._options.fontVariant ?? this._defaultOptions.fontVariant ?? null;\n }\n\n /**\n * Sets the CSS font-variant and updates the component's CSS rule.\n *\n * @param value - A CSS font-variant value (e.g. \"normal\", \"small-caps\").\n *\n * @returns This component, for method chaining.\n */\n setFontVariant(value: string): this {\n this._options.fontVariant = value;\n\n this.setElementCSSRule(\"fontVariant\", value);\n\n return this;\n }\n\n /**\n * Returns the CSS font-weight value.\n *\n * @returns The CSS font-weight string, or null if not set.\n */\n getFontWeight() {\n return this._options.fontWeight ?? this._defaultOptions.fontWeight ?? null;\n }\n\n /**\n * Sets the CSS font-weight, updates the rule, and recalculates preferred size.\n *\n * @param value - A CSS font-weight value (e.g. \"normal\", \"bold\", \"700\").\n *\n * @returns This component, for method chaining.\n */\n setFontWeight(value: string): this {\n this._options.fontWeight = value;\n\n this.setElementCSSRule(\"fontWeight\", value);\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns the line height in pixels.\n *\n * @returns The caller/setter value when one was set; otherwise the\n * resolved additive line box (font size plus the theme's line padding).\n */\n getLineHeight() {\n return (this._options.lineHeight as number | undefined) ?? (this._defaultOptions.lineHeight as number | undefined) ?? this.readThemeLineHeightPx();\n }\n\n /**\n * Sets the line height. Pass a number for an explicit fixed pixel value\n * (which stops tracking the theme — this is the per-control override of the\n * additive default), or a CSS variable name to bind the line box to a\n * custom token, resolved as a fixed line box for measurement.\n *\n * @param value - Pixel value as a number, or a CSS custom property name as a string.\n *\n * @returns This component, for method chaining.\n */\n setLineHeight(value: number | string): this {\n if (typeof value === 'number') {\n // Idempotent re-apply: a no-op numeric line-height must not re-arm\n // the layout flush. CellRenderer.doLayout syncs the Text child's\n // line-height to the cell height on every pass; without this guard\n // that unconditional scheduleLayout below re-dirtied the renderer\n // each frame, spinning a silent CPU-pinning relayout loop. Only skip\n // when already in pure-numeric mode with the same value (the initial\n // additive-rule state has a non-null _lineHeightCSSRule, so the first\n // apply still runs). Mirrors the framework's \"unchanged value → early\n // return before scheduleLayout\" idiom (Card.setVisibleComponentId).\n if (this._options.lineHeight === value && this._lineHeightCSSVar === null && this._lineHeightCSSRule === null) {\n return this;\n }\n\n this._options.lineHeight = value as TOptions[\"lineHeight\"];\n this._lineHeightCSSVar = null;\n this._lineHeightCSSRule = null;\n this.setElementCSSRule(\"lineHeight\", value + \"px\");\n } else {\n this._lineHeightCSSVar = value;\n this._lineHeightCSSRule = `var(${value}, ${ADDITIVE_LINE_HEIGHT_RULE})`;\n this._options.lineHeight = this.readThemeLineHeightPx() as TOptions[\"lineHeight\"];\n this.setElementCSSRule(\"lineHeight\", this._lineHeightCSSRule);\n }\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Sets the line-height equal to the given pixel height so a single-line\n * text sits vertically centred in a fixed-height inline box.\n *\n * @param px - Pixel value matching the container's height, or `null` to\n * revert to the theme's additive line box (font size +\n * `--ts-ui-line-padding`).\n *\n * @returns This component, for method chaining.\n *\n * @example\n * ```typescript\n * const label = new Text(\"File\");\n * label.centerInHeight(28);\n * ```\n */\n centerInHeight(px: number | null): this {\n if (px === null) {\n this._lineHeightCSSVar = null;\n this._lineHeightCSSRule = ADDITIVE_LINE_HEIGHT_RULE;\n this._options.lineHeight = this.readThemeLineHeightPx() as TOptions[\"lineHeight\"];\n this.setElementCSSRule(\"lineHeight\", this._lineHeightCSSRule);\n\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n return this.setLineHeight(px);\n }\n\n /**\n * Returns the CSS text-overflow value last passed to {@link setTextOverflow},\n * or `null` if not set.\n *\n * @returns The text-overflow string, or null.\n */\n getTextOverflow(): string | null {\n return this._textOverflow;\n }\n\n /**\n * Sets the CSS text-overflow property and updates the component's CSS rule.\n *\n * @param value - A CSS text-overflow value (e.g. \"clip\", \"ellipsis\").\n *\n * @returns This component, for method chaining.\n */\n setTextOverflow(value: string): this {\n this._textOverflow = value;\n\n this.setElementCSSRule(\"textOverflow\", value);\n\n return this;\n }\n\n /**\n * Removes the text-overflow CSS property from the component's CSS rule.\n *\n * @returns This component, for method chaining.\n */\n clearTextOverflow(): this {\n if (this._textOverflow === null) {\n return this;\n }\n\n this._textOverflow = null;\n this.setElementCSSRule(\"textOverflow\", null);\n\n return this;\n }\n\n /**\n * Returns whether single-line truncation + ellipsis is enabled (default `true`).\n *\n * @returns `true` when the text clips with \"…\" once narrower than its\n * natural width; `false` when the text refuses to shrink past its\n * natural width.\n */\n isTruncate(): boolean {\n return this._truncate;\n }\n\n /**\n * Toggles single-line truncation mode. When `true`, the text renders as\n * single-line + `overflow: hidden` + `text-overflow: ellipsis` and reports\n * `minSize.width = Math.min(natural, 100)`. When `false`, those CSS\n * properties are cleared and the text reports its full natural width as\n * `minSize.width` so parent layouts widen to fit instead of clipping.\n *\n * @param value - `true` to enable ellipsised truncation, `false` to\n * disable (the text expands to its natural width).\n *\n * @returns This component, for method chaining.\n */\n setTruncate(value: boolean): this {\n this._truncate = value;\n\n if (value) {\n this.setWhiteSpace(\"nowrap\");\n this.setOverflow(\"hidden\");\n this.setTextOverflow(\"ellipsis\");\n } else {\n this.setElementCSSRule(\"whiteSpace\", null);\n this.setOverflow(\"visible\");\n this.setElementCSSRule(\"textOverflow\", null);\n this._textOverflow = null;\n }\n\n // The auto-min cap depends on `_truncate`; re-measure so the parent\n // layout sees the new floor on the next layout pass.\n this._measurementDirty = true;\n (this.getParentComponent() ?? this).scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns the current CSS `word-break` value, or null if not set.\n *\n * @returns The word-break string, or null.\n */\n getWordBreak(): string | null {\n return this._wordBreak;\n }\n\n /**\n * Sets the CSS `word-break` property on the component's CSS rule.\n *\n * @param value - A CSS word-break value (e.g. \"break-word\", \"normal\", \"keep-all\").\n *\n * @returns This component, for method chaining.\n */\n setWordBreak(value: string): this {\n if (this._wordBreak === value) {\n return this;\n }\n\n this._wordBreak = value;\n this.setElementCSSRule(\"wordBreak\", value);\n\n return this;\n }\n\n /**\n * Returns the current line-clamp line count, or null if no clamp is applied.\n *\n * @returns The maximum line count, or null.\n */\n getLineClamp(): number | null {\n return this._lineClamp;\n }\n\n /**\n * Clamps the rendered text to a maximum line count via CSS line-clamp.\n *\n * Writes `display: -webkit-box`, `-webkit-box-orient: vertical`,\n * `-webkit-line-clamp`, `overflow: hidden`, and `text-overflow: ellipsis`\n * in a single call. Use {@link clearLineClamp} to remove the clamp.\n *\n * @param lines - The maximum number of lines to display before the ellipsis.\n *\n * @returns This component, for method chaining.\n */\n setLineClamp(lines: number): this {\n if (this._lineClamp === lines) {\n return this;\n }\n\n this._lineClamp = lines;\n this.setElementCSSRules({\n display: \"-webkit-box\",\n webkitBoxOrient: \"vertical\",\n webkitLineClamp: String(lines),\n overflow: \"hidden\",\n textOverflow: \"ellipsis\"\n });\n\n return this;\n }\n\n /**\n * Removes the line-clamp styling previously applied by {@link setLineClamp}.\n *\n * @returns This component, for method chaining.\n */\n clearLineClamp(): this {\n if (this._lineClamp === null) {\n return this;\n }\n\n this._lineClamp = null;\n this.setElementCSSRules({\n display: null,\n webkitBoxOrient: null,\n webkitLineClamp: null,\n overflow: null,\n textOverflow: null\n });\n\n return this;\n }\n\n /**\n * Applies all text-specific style properties to the element's CSS rule in addition to base styles.\n *\n * @param element - The element handle to apply styles to.\n */\n applyStyle(element: Handle): this {\n super.applyStyle(element);\n\n const fontSize = this.getFontSize();\n const lineHeight = this.getLineHeight();\n\n this.setElementCSSRules({\n fontFamily: this.getFontFamily() ?? '',\n textAlign: this.getTextAlign() ?? '',\n textShadow: this.getTextShadow() ?? '',\n fontKerning: this.getFontKerning() ?? '',\n fontSize: this._fontSizeCSSRule ?? (fontSize !== null ? `${fontSize}px` : ''),\n fontSizeAdjust: this.getFontSizeAdjust() ?? '',\n fontStretch: this.getFontStretch() ?? '',\n fontStyle: this.getFontStyle() ?? '',\n fontVariant: this.getFontVariant() ?? '',\n fontWeight: this.getFontWeight() ?? '',\n lineHeight: this._lineHeightCSSRule ?? (lineHeight !== null ? `${lineHeight}px` : '')\n });\n\n return this;\n }\n\n /**\n * Renders the element and sets its text content.\n *\n * @returns The created element with textContent initialised.\n */\n protected render() {\n let element = super.render();\n\n DOM.sink.apply(element, { text: this.getText().valueOf() });\n\n return element;\n }\n}\n\nconst TextCallable = callable(Text);\ntype TextCallable<TOptions extends TextOptions = TextOptions> = Text<TOptions>;\nexport {\n Text as _Text,\n TextCallable as Text\n};\n"],"mappings":"oIA0DA,IAAM,EAA4C,CAC9C,IAAgB,OAChB,UAAgB,OAChB,WAAgB,kDAChB,YAAgB,OAChB,SAAgB,GAChB,eAAgB,OAChB,YAAgB,SAChB,UAAgB,SAChB,YAAgB,SAChB,WAAgB,SAChB,SAAgB,EACpB,EAMM,EAA6B,IAO7B,EAA4B,6CAU5B,KAAN,cAA+D,CAAoB,CAE/E,0BAA6C,GAC7C,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,KAAyB,GAAlB,GAAG,EAAS,KAC7E,eAAgB,KAAK,kBAAkB,GAAK,GAC5C,YAAgB,KAAK,eAAe,GAAO,GAC3C,UAAgB,KAAK,aAAa,GAAS,GAC3C,YAAgB,KAAK,eAAe,GAAO,GAC3C,WAAgB,KAAK,cAAc,GAAQ,GAC3C,WAAgB,KAAK,qBAAwB,IAAe,KAA2B,GAApB,GAAG,EAAW,IACrF,CAAC,EAEM,IACX,CAOA,QAAmB,CACf,IAAI,EAAU,MAAM,OAAO,EAI3B,OAFA,EAAI,KAAK,MAAM,EAAS,CAAE,KAAM,KAAK,QAAQ,CAAC,CAAC,QAAQ,CAAE,CAAC,EAEnD,CACX,CACJ,EAEM,EAAe,EAAS,IAAI"}
@@ -0,0 +1,3 @@
1
+ import{t as e}from"./DOM-67StIm5G.js";import{l as t}from"./Position-Ck_KD4cR.js";import{S as n,t as r,v as i}from"./Component-DHqrPwAw.js";import{t as a}from"./Text-D5pg7taZ.js";var o=9e3,s=9800,c=1e4,l=11e3,u=12e3,d=new r,f;(function(t){let r=[],i=new WeakMap,a=0,f=null,p=!1;t.Band={Window:o,Popover:s,Dropdown:c,Dialog:l,Tooltip:u};function bandFor(e,t){return e?e.band:t}function register(e){if(i.has(e))return;let t=r.length>0?r[r.length-1]:null,n=e.isLayerRoot?.()?null:t,o=bandFor(n,e.getBand?.()??c),s={layer:e,parent:n,children:[],band:o,zIndex:o+ ++a};i.set(e,s),r.push(s),n&&n.children.push(s),p||installListeners()}t.register=register;function mount(t){e.source.contains(e.source.getDocumentElement(),t)||e.sink.appendChild(e.source.getDocumentElement(),t)}t.mount=mount;function unregister(e){let t=i.get(e);if(!t)return;i.delete(e);let n=r.indexOf(t);if(n>=0&&r.splice(n,1),t.parent){let e=t.parent.children.indexOf(t);e>=0&&t.parent.children.splice(e,1)}f===e&&(f=null),r.length===0&&p&&uninstallListeners()}t.unregister=unregister;function containsAcrossLayers(t,n){if(!n)return!1;let r=i.get(t);if(!r){let r=t.getLayerElement();return r?e.source.contains(r,n):!1}return nodeContains(r,n)}t.containsAcrossLayers=containsAcrossLayers;function getTopLayer(){return r.length>0?r[r.length-1].layer:null}t.getTopLayer=getTopLayer;function bringToFront(e){let t=i.get(e);t&&(restampSubtree(t),markActive(e))}t.bringToFront=bringToFront;function getZIndex(e){let t=i.get(e);return t?t.zIndex:c}t.getZIndex=getZIndex;function restampSubtree(e){let walk=e=>{e.zIndex=e.band+ ++a,e.layer.onZIndexChanged?.(e.zIndex);for(let t of e.children)walk(t)};walk(e)}function nodeContains(t,n){let r=t.layer.getLayerElement();if(r&&e.source.contains(r,n))return!0;for(let e of t.children)if(nodeContains(e,n))return!0;return!1}function markActive(e){f!==e&&(deactivateActive(),f=e,e.onActivate&&e.onActivate(!0))}function deactivateActive(){f&&f.onActivate&&f.onActivate(!1),f=null}function activatableAncestor(e){let t=e;for(;t;){if(t.layer.onActivate)return t.layer;t=t.parent}return null}function handleOutside(t,n){let i=r.slice().reverse(),a=!1,o=!1;for(let r of i){let i=r.layer.getDismissMode();if(containsAcrossLayers(r.layer,t)){markActive(activatableAncestor(r)??r.layer),a=!0,o=!0;break}let s=r.layer.getAnchorElement?.();if(s&&t&&e.source.contains(s,t)){o=!0;break}if(i===`manual`||i===`modal`||!(n?i===`blur`:i===`click-outside`||i===`blur`)){if(i===`modal`){o=!0;break}continue}r.layer.requestClose()}!a&&!o&&!n&&deactivateActive()}function onPointerDown(t){handleOutside(t.target===null?null:e.source.intern(t.target),!1)}function onWindowBlur(t){e.source.isWindow(t.target===null?null:e.source.intern(t.target))&&handleOutside(null,!1)}function onFocusIn(t){handleOutside(t.target===null?null:e.source.intern(t.target),!0)}function onKeyDown(e){if(e.key===`Escape`){for(let e=r.length-1;e>=0;e--)if(r[e].layer.getDismissMode()!==`manual`)return r[e].layer.requestClose(),!0}}function installListeners(){n.addViewportListener(d,`pointerdown`,onPointerDown),n.addViewportListener(d,`focusin`,onFocusIn),n.addViewportListener(d,`keydown`,onKeyDown),n.addViewportListener(d,`blur`,onWindowBlur),p=!0}function uninstallListeners(){n.removeViewportListener(d,`pointerdown`,onPointerDown),n.removeViewportListener(d,`focusin`,onFocusIn),n.removeViewportListener(d,`keydown`,onKeyDown),n.removeViewportListener(d,`blur`,onWindowBlur),p=!1}})(f||={});function positionAdjacent(e,t,n,r,i){let a=t+i,o=r-a,s=e-i;return n<=o?a:n<=s?e-n-i:o>=s?Math.max(0,r-n):0}function positionAligned(e,t,n,r,i){if(e>=i&&e+n<=r-i)return e;let a=t-n;return a>=i&&a+n<=r-i?a:clampAxis(e,n,r,i)}function clampAxis(e,n,r,i){return t.clamp(e,i,Math.max(i,r-n-i))}function positionFlexibleAnchored(e,t,n,r,i){let a=r-t-i,o=e-i;return n<=a||a>=o?{start:t,available:a}:{start:e-Math.min(n,o),available:o}}function positionAnchored(e,t,n,r){let i=r.gap??0,a=r.margin??0;if(r.axis===`vertical`){let r=positionAdjacent(e.top,e.bottom,t.height,n.height,i);return{x:positionAligned(e.left,e.right,t.width,n.width,a),y:r}}return{x:positionAdjacent(e.left,e.right,t.width,n.width,i),y:positionAligned(e.top,e.bottom,t.height,n.height,a)}}var p=100,m=class Tooltip extends r{_showAnimation=null;_hideAnimation=null;static instance=null;static showTimer=null;static attachments=new Map;static elementAttachments=new Map;static activeElement=null;static watching=!1;static _onAnchorWatch=()=>{Tooltip.activeElement!==null&&!e.source.isConnected(Tooltip.activeElement)&&Tooltip.hide()};static dismissing=!1;static H_PADDING=16;static V_PADDING=8;static MAX_WIDTH=300;static ITEM_HEIGHT=20;static CURSOR_LEFT=4;static CURSOR_RIGHT=12;static CURSOR_UP=0;static CURSOR_DOWN=12;static CURSOR_GAP=2;_text;_lineCount=1;_perLine=Tooltip.ITEM_HEIGHT;constructor(){super(),this.setVisible(!1),this.setZIndex(f.Band.Tooltip),this.setBackgroundColor(`var(--ts-ui-tooltip-bg, rgb(255, 255, 240))`),this.setForegroundColor(`var(--ts-ui-tooltip-color, rgb(0, 0, 0))`),this.setBorder({border:`1px solid var(--ts-ui-tooltip-border, rgb(180, 180, 100))`}),this.setShadow(`var(--ts-ui-tooltip-shadow, 1px 2px 4px rgba(0, 0, 0, 0.2))`),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),this.setPointerEvents(`none`),this.setContain(`layout paint`),this._text=new a,this._text.setPointerEvents(`none`),this._text.setWhiteSpace(`pre-wrap`),this.addComponent(this._text)}static getInstance(){return Tooltip.instance||=new Tooltip,Tooltip.instance}static show(r,a,o){Tooltip.showTimer!==null&&(clearTimeout(Tooltip.showTimer),Tooltip.showTimer=null);let s=Tooltip.getInstance(),c=s.isVisible()&&!Tooltip.dismissing;s._text.setText(r);let l=r.split(`
2
+ `),u=l.reduce((e,n)=>Math.max(e,t.measureTextWidth(n)),0);s._perLine=s._perLineHeight();let d=s.getPerimeterSize(),m=d.left+d.right,h=d.top+d.bottom,g=Math.min(Tooltip.MAX_WIDTH,u+Tooltip.H_PADDING+m);if(u+Tooltip.H_PADDING+m>Tooltip.MAX_WIDTH){let t=g-Tooltip.H_PADDING-m,n=e.source.measureText(r,{maxWidth:t}).height;s._lineCount=Math.max(l.length,Math.round(n/s._perLine))}else s._lineCount=l.length;let _=s._lineCount*s._perLine+Tooltip.V_PADDING;s._lineCount===1&&(_=Math.max(_,Tooltip.ITEM_HEIGHT+Tooltip.V_PADDING)),_+=h,s.setWidth(g),s.setHeight(_);let v=e.source.getViewportSize(),y=t.clamp(a,0,v.width),b=t.clamp(o,0,v.height);s.setX(positionAdjacent(y-Tooltip.CURSOR_LEFT,y+Tooltip.CURSOR_RIGHT,g,v.width,Tooltip.CURSOR_GAP)),s.setY(positionAdjacent(b-Tooltip.CURSOR_UP,b+Tooltip.CURSOR_DOWN,_,v.height,Tooltip.CURSOR_GAP));let x=s.getElement(!0);if(s.scheduleLayout(),f.mount(x),s.setVisible(!0),Tooltip.watching||=(n.addViewportListener(s,`mousemove`,Tooltip._onAnchorWatch),!0),Tooltip.dismissing=!1,c){e.sink.apply(x,{style:{opacity:`1`}});return}s._showAnimation?.cancel(),s._showAnimation=i.play(x,{from:{opacity:`0`},to:{opacity:`1`},durationMs:p,properties:[`opacity`]})}static hide(){Tooltip.showTimer!==null&&(clearTimeout(Tooltip.showTimer),Tooltip.showTimer=null);let e=Tooltip.getInstance(),t=e.getElement();Tooltip.watching&&=(n.removeViewportListener(e,`mousemove`,Tooltip._onAnchorWatch),!1),Tooltip.activeElement=null,t&&(Tooltip.dismissing=!0,e._hideAnimation?.cancel(),e._hideAnimation=i.play(t,{to:{opacity:`0`},durationMs:p,properties:[`opacity`],onComplete:()=>{Tooltip.dismissing&&(Tooltip.dismissing=!1,e.setVisible(!1),e.removeElement())}}))}static attach(e,t,r){Tooltip.detach(e);let i=0,a=0,mouseoverFn=n=>{Tooltip.showTimer===null&&(i=n.clientX,a=n.clientY,Tooltip.showTimer=setTimeout(()=>{Tooltip._applyColors(r),Tooltip.activeElement=e.getElement()??null,Tooltip.show(t,i,a),Tooltip.showTimer=null},500))},mousemoveFn=e=>{i=e.clientX,a=e.clientY},mouseoutFn=()=>{Tooltip.hide()},mousedownFn=()=>{Tooltip.hide()};n.addListener(e,`mouseover`,mouseoverFn),n.addListener(e,`mousemove`,mousemoveFn),n.addListener(e,`mouseout`,mouseoutFn),n.addListener(e,`mousedown`,mousedownFn),Tooltip.attachments.set(e.getId(),{text:t,colors:r,mouseoverFn,mousemoveFn,mouseoutFn,mousedownFn})}static detach(e){let t=e.getId(),r=Tooltip.attachments.get(t);r&&(n.removeListener(e,`mouseover`,r.mouseoverFn),n.removeListener(e,`mousemove`,r.mousemoveFn),n.removeListener(e,`mouseout`,r.mouseoutFn),n.removeListener(e,`mousedown`,r.mousedownFn),Tooltip.attachments.delete(t),Tooltip.hide())}static _applyColors(e){let t=Tooltip.getInstance();t.setBackgroundColor(e?.background??`var(--ts-ui-tooltip-bg, rgb(255, 255, 240))`),t.setForegroundColor(e?.color??`var(--ts-ui-tooltip-color, rgb(0, 0, 0))`),t.setBorder({border:`1px solid ${e?.border??`var(--ts-ui-tooltip-border, rgb(180, 180, 100))`}`})}static attachToElement(t,n){let r=Tooltip.elementAttachments.get(t),i=Tooltip.activeElement===t,a=r?r.lastX:0,o=r?r.lastY:0;Tooltip.detachElement(t);let s={text:n,showTimer:null,lastX:a,lastY:o,mouseoverFn:function onTooltipMouseOver(e){s.showTimer===null&&(s.lastX=e.clientX,s.lastY=e.clientY,s.showTimer=setTimeout(function onTooltipShowTimer(){Tooltip.activeElement=t,Tooltip.show(s.text,s.lastX,s.lastY),s.showTimer=null},500))},mousemoveFn:function onTooltipMouseMove(e){s.lastX=e.clientX,s.lastY=e.clientY},mouseoutFn:function onTooltipMouseOut(){s.showTimer!==null&&(clearTimeout(s.showTimer),s.showTimer=null),Tooltip.activeElement===t&&(Tooltip.activeElement=null),Tooltip.hide()},mousedownFn:function onTooltipMouseDown(){s.showTimer!==null&&(clearTimeout(s.showTimer),s.showTimer=null),Tooltip.hide()}};e.sink.addListener(t,`mouseover`,s.mouseoverFn),e.sink.addListener(t,`mousemove`,s.mousemoveFn),e.sink.addListener(t,`mouseout`,s.mouseoutFn),e.sink.addListener(t,`mousedown`,s.mousedownFn),Tooltip.elementAttachments.set(t,s),i&&(Tooltip.activeElement=t,Tooltip.show(n,s.lastX,s.lastY))}static detachElement(t){let n=Tooltip.elementAttachments.get(t);n&&(e.sink.removeListener(t,`mouseover`,n.mouseoverFn),e.sink.removeListener(t,`mousemove`,n.mousemoveFn),e.sink.removeListener(t,`mouseout`,n.mouseoutFn),e.sink.removeListener(t,`mousedown`,n.mousedownFn),n.showTimer!==null&&(clearTimeout(n.showTimer),n.showTimer=null),Tooltip.elementAttachments.delete(t),Tooltip.activeElement===t&&(Tooltip.activeElement=null))}_perLineHeight(){let{height:t}=e.source.measureText(`X`);return Math.ceil(t)}doLayout(){super.doLayout();let e=this.getContentBounds();return e?(this._text.setX(e.x+Tooltip.H_PADDING/2),this._text.setY(e.y+Tooltip.V_PADDING/2),this._text.setWidth(Math.max(0,e.width-Tooltip.H_PADDING)),this._text.setHeight(this._lineCount*this._perLine),this):this}destructor(){this._showAnimation?.cancel(),this._showAnimation=null,this._hideAnimation?.cancel(),this._hideAnimation=null,super.destructor()}};export{f as a,positionFlexibleAnchored as i,positionAligned as n,positionAnchored as r,m as t};
3
+ //# sourceMappingURL=Tooltip-DzK6LxUt.js.map