@jimka/typescript-ui 0.2.0 → 0.3.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 (167) hide show
  1. package/README.md +4 -0
  2. package/THIRD-PARTY-NOTICES.md +7 -3
  3. package/dist/lib/{AbstractBooleanInput-BGesvIZy.js → AbstractBooleanInput-C3O4kv7_.js} +2 -2
  4. package/dist/lib/{AbstractBooleanInput-BGesvIZy.js.map → AbstractBooleanInput-C3O4kv7_.js.map} +1 -1
  5. package/dist/lib/{AbstractInput-BxOtFrER.js → AbstractInput-DFWniHqq.js} +2 -2
  6. package/dist/lib/{AbstractInput-BxOtFrER.js.map → AbstractInput-DFWniHqq.js.map} +1 -1
  7. package/dist/lib/AnchorConstraints-CSUcj8Wx.js +2 -0
  8. package/dist/lib/AnchorConstraints-CSUcj8Wx.js.map +1 -0
  9. package/dist/lib/{AnimatedDropdown-CZQEqQi-.js → AnimatedDropdown-e9urCXK1.js} +2 -2
  10. package/dist/lib/{AnimatedDropdown-CZQEqQi-.js.map → AnimatedDropdown-e9urCXK1.js.map} +1 -1
  11. package/dist/lib/Border-Dq6dXkmS.js +2 -0
  12. package/dist/lib/{Border-BgaZkc1R.js.map → Border-Dq6dXkmS.js.map} +1 -1
  13. package/dist/lib/{Button-U1rsP4v8.js → Button-B36rBMKC.js} +2 -2
  14. package/dist/lib/{Button-U1rsP4v8.js.map → Button-B36rBMKC.js.map} +1 -1
  15. package/dist/lib/{Card-BVwOS8AG.js → Card-P8iUH2-C.js} +2 -2
  16. package/dist/lib/{Card-BVwOS8AG.js.map → Card-P8iUH2-C.js.map} +1 -1
  17. package/dist/lib/{ComboBox-B9EDPu6T.js → ComboBox-BjAhXXkY.js} +2 -2
  18. package/dist/lib/{ComboBox-B9EDPu6T.js.map → ComboBox-BjAhXXkY.js.map} +1 -1
  19. package/dist/lib/Component-CHTzJxEf.js +2 -0
  20. package/dist/lib/Component-CHTzJxEf.js.map +1 -0
  21. package/dist/lib/Container-xUbHk6l_.js +2 -0
  22. package/dist/lib/{Container-D5H8VxJK.js.map → Container-xUbHk6l_.js.map} +1 -1
  23. package/dist/lib/DOM-BeR95tE8.js +2 -0
  24. package/dist/lib/DOM-BeR95tE8.js.map +1 -0
  25. package/dist/lib/{DragManager-CI4mZQFy.js → DragManager-T5Oljd0F.js} +2 -2
  26. package/dist/lib/{DragManager-CI4mZQFy.js.map → DragManager-T5Oljd0F.js.map} +1 -1
  27. package/dist/lib/{FieldDecorator-CJs9gwqH.js → FieldDecorator-BaTGfKiW.js} +2 -2
  28. package/dist/lib/{FieldDecorator-CJs9gwqH.js.map → FieldDecorator-BaTGfKiW.js.map} +1 -1
  29. package/dist/lib/{Fit-DjRsiwlg.js → Fit-E-EIZv1k.js} +2 -2
  30. package/dist/lib/{Fit-DjRsiwlg.js.map → Fit-E-EIZv1k.js.map} +1 -1
  31. package/dist/lib/{Glyph-KEf4nIv2.js → Glyph-CnNslL95.js} +2 -2
  32. package/dist/lib/{Glyph-KEf4nIv2.js.map → Glyph-CnNslL95.js.map} +1 -1
  33. package/dist/lib/{Grid-DdL9TVeJ.js → Grid-BXS2T8MT.js} +2 -2
  34. package/dist/lib/{Grid-DdL9TVeJ.js.map → Grid-BXS2T8MT.js.map} +1 -1
  35. package/dist/lib/{GridConstraints-DkLueyrf.js → GridConstraints-D_kbd-h2.js} +2 -2
  36. package/dist/lib/{GridConstraints-DkLueyrf.js.map → GridConstraints-D_kbd-h2.js.map} +1 -1
  37. package/dist/lib/HBox-Dm3xgsDE.js +2 -0
  38. package/dist/lib/{HBox-Ce0GTCJP.js.map → HBox-Dm3xgsDE.js.map} +1 -1
  39. package/dist/lib/{Header-BQIVpBte.js → Header-CqFc2OUx.js} +2 -2
  40. package/dist/lib/{Header-BQIVpBte.js.map → Header-CqFc2OUx.js.map} +1 -1
  41. package/dist/lib/{IconText-Bo4Qcnot.js → IconText-CTM2r0Tv.js} +2 -2
  42. package/dist/lib/{IconText-Bo4Qcnot.js.map → IconText-CTM2r0Tv.js.map} +1 -1
  43. package/dist/lib/{LayoutSerialization-BT66TY83.js → LayoutSerialization-D1OHmxSB.js} +2 -2
  44. package/dist/lib/{LayoutSerialization-BT66TY83.js.map → LayoutSerialization-D1OHmxSB.js.map} +1 -1
  45. package/dist/lib/LayoutSizes-CvMmMgHJ.js +2 -0
  46. package/dist/lib/LayoutSizes-CvMmMgHJ.js.map +1 -0
  47. package/dist/lib/List-DHeOPAK2.js +2 -0
  48. package/dist/lib/List-DHeOPAK2.js.map +1 -0
  49. package/dist/lib/MemoryStore-DT6iWWco.js +2 -0
  50. package/dist/lib/MemoryStore-DT6iWWco.js.map +1 -0
  51. package/dist/lib/{Menu-Dz4L7EKJ.js → Menu-B6ippw-p.js} +2 -2
  52. package/dist/lib/{Menu-Dz4L7EKJ.js.map → Menu-B6ippw-p.js.map} +1 -1
  53. package/dist/lib/{MenuButton-VJ5uC3c1.js → MenuButton-Bjm1OyB-.js} +2 -2
  54. package/dist/lib/{MenuButton-VJ5uC3c1.js.map → MenuButton-Bjm1OyB-.js.map} +1 -1
  55. package/dist/lib/{Panel-DzWdYwq1.js → Panel-D9lTLGqP.js} +2 -2
  56. package/dist/lib/{Panel-DzWdYwq1.js.map → Panel-D9lTLGqP.js.map} +1 -1
  57. package/dist/lib/Position-DRSlWn4Z.js +2 -0
  58. package/dist/lib/Position-DRSlWn4Z.js.map +1 -0
  59. package/dist/lib/{ProgressSpinner-zJKtGyNJ.js → ProgressSpinner-glv-29eK.js} +2 -2
  60. package/dist/lib/{ProgressSpinner-zJKtGyNJ.js.map → ProgressSpinner-glv-29eK.js.map} +1 -1
  61. package/dist/lib/{RadioButton-CYSSv4nV.js → RadioButton-R4S3c9WD.js} +2 -2
  62. package/dist/lib/{RadioButton-CYSSv4nV.js.map → RadioButton-R4S3c9WD.js.map} +1 -1
  63. package/dist/lib/{RovingTabIndex-BSZ31Vp5.js → RovingTabIndex-Dgt01LOE.js} +2 -2
  64. package/dist/lib/{RovingTabIndex-BSZ31Vp5.js.map → RovingTabIndex-Dgt01LOE.js.map} +1 -1
  65. package/dist/lib/{Scrollbar-BhtOjqkG.js → Scrollbar-CiVV3axj.js} +2 -2
  66. package/dist/lib/{Scrollbar-BhtOjqkG.js.map → Scrollbar-CiVV3axj.js.map} +1 -1
  67. package/dist/lib/{Slider-CdXm7E64.js → Slider-_JVvuQ8M.js} +2 -2
  68. package/dist/lib/{Slider-CdXm7E64.js.map → Slider-_JVvuQ8M.js.map} +1 -1
  69. package/dist/lib/{Spacer-D9NGW4QG.js → Spacer-B57i2-_G.js} +2 -2
  70. package/dist/lib/{Spacer-D9NGW4QG.js.map → Spacer-B57i2-_G.js.map} +1 -1
  71. package/dist/lib/{TabButton-CThevdY_.js → TabButton-DEypdlZf.js} +2 -2
  72. package/dist/lib/{TabButton-CThevdY_.js.map → TabButton-DEypdlZf.js.map} +1 -1
  73. package/dist/lib/Text-Bni4icFY.js +2 -0
  74. package/dist/lib/Text-Bni4icFY.js.map +1 -0
  75. package/dist/lib/{Tooltip-tkXDk5Bo.js → Tooltip-BUy6uFKN.js} +2 -2
  76. package/dist/lib/{Tooltip-tkXDk5Bo.js.map → Tooltip-BUy6uFKN.js.map} +1 -1
  77. package/dist/lib/VBox-Dr7Ge9M6.js +2 -0
  78. package/dist/lib/VBox-Dr7Ge9M6.js.map +1 -0
  79. package/dist/lib/{VirtualScroller-DwEEJE1_.js → VirtualScroller-BPy6KmSX.js} +2 -2
  80. package/dist/lib/{VirtualScroller-DwEEJE1_.js.map → VirtualScroller-BPy6KmSX.js.map} +1 -1
  81. package/dist/lib/component/button.es.js +1 -1
  82. package/dist/lib/component/chart.es.js +1 -1
  83. package/dist/lib/component/chart.es.js.map +1 -1
  84. package/dist/lib/component/container.es.js +1 -1
  85. package/dist/lib/component/diagram.es.js +1 -1
  86. package/dist/lib/component/diagram.es.js.map +1 -1
  87. package/dist/lib/component/display.es.js +1 -1
  88. package/dist/lib/component/editor.es.js +3 -3
  89. package/dist/lib/component/editor.es.js.map +1 -1
  90. package/dist/lib/component/input.es.js +1 -1
  91. package/dist/lib/component/input.es.js.map +1 -1
  92. package/dist/lib/component/list.es.js +1 -1
  93. package/dist/lib/component/menubar.es.js +1 -1
  94. package/dist/lib/component/table.es.js +2 -2
  95. package/dist/lib/component/table.es.js.map +1 -1
  96. package/dist/lib/component/tree.es.js +1 -1
  97. package/dist/lib/component/tree.es.js.map +1 -1
  98. package/dist/lib/core.es.js +1 -1
  99. package/dist/lib/core.es.js.map +1 -1
  100. package/dist/lib/data.es.js +1 -1
  101. package/dist/lib/data.es.js.map +1 -1
  102. package/dist/lib/glyphs/solid/index.es.js +1 -1
  103. package/dist/lib/layout.es.js +1 -1
  104. package/dist/lib/layout.es.js.map +1 -1
  105. package/dist/lib/overlay.es.js +1 -1
  106. package/dist/lib/overlay.es.js.map +1 -1
  107. package/dist/lib/primitive.es.js +1 -1
  108. package/dist/lib/router.es.js +1 -1
  109. package/dist/lib/router.es.js.map +1 -1
  110. package/dist/lib/{VirtualRowView-BxpHQ_u8.js → selectionsEqual-2PJrcimg.js} +2 -2
  111. package/dist/lib/{VirtualRowView-BxpHQ_u8.js.map → selectionsEqual-2PJrcimg.js.map} +1 -1
  112. package/dist/lib/types/component/diagram/DiagramEdgeLayer.d.ts +14 -1
  113. package/dist/lib/types/component/diagram/DiagramModel.d.ts +1 -0
  114. package/dist/lib/types/component/diagram/DiagramNode.d.ts +4 -0
  115. package/dist/lib/types/component/diagram/DiagramView.d.ts +76 -5
  116. package/dist/lib/types/component/diagram/ElkLayoutEngine.d.ts +14 -1
  117. package/dist/lib/types/component/diagram/index.d.ts +2 -2
  118. package/dist/lib/types/component/editor/CodeEditor.d.ts +3 -2
  119. package/dist/lib/types/component/input/Text.d.ts +3 -1
  120. package/dist/lib/types/component/shared/selectionsEqual.d.ts +1 -0
  121. package/dist/lib/types/component/table/Column.d.ts +2 -0
  122. package/dist/lib/types/component/table/ColumnConfig.d.ts +1 -0
  123. package/dist/lib/types/component/table/Header.d.ts +1 -0
  124. package/dist/lib/types/component/table/Table.d.ts +20 -0
  125. package/dist/lib/types/component/table/cell/Header.d.ts +1 -0
  126. package/dist/lib/types/component/table/index.d.ts +1 -1
  127. package/dist/lib/types/component/tree/Tree.d.ts +1 -0
  128. package/dist/lib/types/core/Aria.d.ts +0 -2
  129. package/dist/lib/types/core/Body.d.ts +1 -0
  130. package/dist/lib/types/core/ClassStyleRules.d.ts +17 -0
  131. package/dist/lib/types/core/Component.d.ts +10 -2
  132. package/dist/lib/types/core/ComponentDefaults.d.ts +1 -0
  133. package/dist/lib/types/core/DOM.d.ts +11 -2
  134. package/dist/lib/types/core/ElementAttributes.d.ts +15 -0
  135. package/dist/lib/types/core/PendingTransitions.d.ts +4 -0
  136. package/dist/lib/types/core/StyleTarget.d.ts +1 -0
  137. package/dist/lib/types/core/Util.d.ts +2 -0
  138. package/dist/lib/types/core/index.d.ts +1 -0
  139. package/dist/lib/types/layout/Border.d.ts +1 -0
  140. package/dist/lib/types/layout/Tab.d.ts +4 -1
  141. package/dist/lib/types/layout/Table.d.ts +1 -0
  142. package/dist/lib/types/overlay/AbstractWindow.d.ts +1 -0
  143. package/dist/lib/types/router/RoutePattern.d.ts +7 -0
  144. package/dist/lib/types/router/Router.d.ts +13 -2
  145. package/dist/lib/types/router/index.d.ts +1 -1
  146. package/dist/lib/validation.es.js +1 -1
  147. package/llms.txt +1 -1
  148. package/package.json +4 -8
  149. package/dist/lib/Border-BgaZkc1R.js +0 -2
  150. package/dist/lib/BoxLayout-DrKGfsup.js +0 -2
  151. package/dist/lib/BoxLayout-DrKGfsup.js.map +0 -1
  152. package/dist/lib/Component-DXf5a3g0.js +0 -2
  153. package/dist/lib/Component-DXf5a3g0.js.map +0 -1
  154. package/dist/lib/Container-D5H8VxJK.js +0 -2
  155. package/dist/lib/DOM-CGn7xyTw.js +0 -2
  156. package/dist/lib/DOM-CGn7xyTw.js.map +0 -1
  157. package/dist/lib/HBox-Ce0GTCJP.js +0 -2
  158. package/dist/lib/LayoutSizes-DU3qSq0w.js +0 -2
  159. package/dist/lib/LayoutSizes-DU3qSq0w.js.map +0 -1
  160. package/dist/lib/List-DtTVTyWW.js +0 -2
  161. package/dist/lib/List-DtTVTyWW.js.map +0 -1
  162. package/dist/lib/Position-A39T7-_1.js +0 -2
  163. package/dist/lib/Position-A39T7-_1.js.map +0 -1
  164. package/dist/lib/Text-gz6qjFfP.js +0 -2
  165. package/dist/lib/Text-gz6qjFfP.js.map +0 -1
  166. package/dist/lib/VBox-EIqw85Rh.js +0 -2
  167. package/dist/lib/VBox-EIqw85Rh.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{i as e,l as t,n}from"./Position-A39T7-_1.js";import{d as r,f as i,t as a,u as o,y as s}from"./Component-DXf5a3g0.js";import{t as c}from"./Glyph-KEf4nIv2.js";import{t as l}from"./Tooltip-tkXDk5Bo.js";import{t as u}from"./Fit-DjRsiwlg.js";import{t as d}from"./Text-gz6qjFfP.js";import{t as f}from"./HBox-Ce0GTCJP.js";import{n as p}from"./VBox-EIqw85Rh.js";var m=new n(5,10,5,10),h=new n(2,6,2,6),g=new n(2,2,2,2),_=new n(4,4,4,4),v=`var(--ts-ui-button-bg, transparent)`,y={tag:`button`,cursor:`pointer`,foregroundColor:`var(--ts-ui-text-color, black)`,border:`2px ridge var(--ts-ui-button-border, rgb(200, 200, 200))`,borderRadius:`var(--ts-ui-border-radius, 4px)`,shadow:`var(--ts-ui-button-shadow, 1px 2px 5px 0 rgba(0, 0, 0, 0.2))`,backgroundImage:`var(--ts-ui-button-bg, linear-gradient(rgb(241, 241, 241), rgb(200, 200, 200)))`,insets:m,anchor:o.CENTER,fill:r.NONE,pressedForegroundColor:`var(--ts-ui-button-pressed-fg, rgb(150, 150, 150))`,pressedBackgroundColor:`var(--ts-ui-button-pressed-bg, rgb(200, 200, 200))`,pressedBackgroundImage:`var(--ts-ui-button-pressed-bg, none)`,pressedShadow:`var(--ts-ui-button-pressed-shadow, 1px 2px 5px 0 rgba(0, 0, 0, 0.2) inset)`,hoverBackgroundColor:`var(--ts-ui-button-hover-bg, rgb(252, 252, 252))`,hoverBackgroundImage:`var(--ts-ui-button-hover-bg, none)`,hoverShadow:`var(--ts-ui-button-hover-shadow, 1px 3px 6px 0 rgba(0, 0, 0, 0.25))`},b=i(class Button extends a{_text;_content;_titleColumn;_description=null;_tooltipSuppressed=!1;_outerColumn=null;_innerRow=null;_glyph=null;_glyphSyncedSize=null;_glyphSizePinned=!1;_onThemeChange=()=>{this._rebuildContentRow(),this.recomputePreferredSize()};get pressedStyleRule(){return this._pressedStyleRule??=this.createStyleRule(`:active`)}_pressedBorder=null;get hoverStyleRule(){return this._hoverStyleRule??=this.createStyleRule(`:hover:not(:active)`)}_hoverBorder=null;_enabledCursor=`pointer`;constructor(e,t,r){let i;typeof e==`string`?i=e:e!==void 0&&(t=e),super(t,{...y,...r??{}}),this.setLayoutManager(new u),this._text=new d,this._titleColumn=new a,this._titleColumn.setLayoutManager(new p({spacing:0})),this._titleColumn.setInsets(new n(0,0,0,0)),this._titleColumn.setPointerEvents(`none`),this._titleColumn.addComponent(this._text),this._content=new a,this._content.setLayoutManager(new f({spacing:2})),this._content.setInsets(new n(0,0,0,0)),this._content.setPointerEvents(`none`),this._content.addComponent(this._titleColumn),this._text.setPointerEvents(`none`),this._text.setTextAlign(`center`),this._text.setFontWeight(`bold`),this._text.setFontSize(`--ts-ui-button-font-size`),this.addComponent(this._content,{fill:this.getFill(),anchor:this.getAnchor()});let o=this._options.text??this._defaultOptions.text??i;o!==void 0&&this.setText(o);let s=this._options.glyph??this._defaultOptions.glyph;s!==void 0&&this.setGlyph(s);let c=this._options.description??this._defaultOptions.description;c!==void 0&&this.setDescription(c),(this._flat||this._compact)&&this._resolveInsets(),this.recomputePreferredSize(),this.subscribeTheme(this._onThemeChange),Object.getPrototypeOf(this)===Button.prototype&&this.applyListeners(t?.listeners)}getAnchor(){return this._options.anchor??this._defaultOptions.anchor}getFill(){return this._options.fill??this._defaultOptions.fill}applyOptions(e){let t=this.getLayoutManager();super.applyOptions(e),e.layoutManager===void 0&&this.getLayoutManager()!==t&&this.setLayoutManager(t),e.descriptionUnderGlyph!==void 0&&(this._options.descriptionUnderGlyph=e.descriptionUnderGlyph),e.showDescription!==void 0&&(this._options.showDescription=e.showDescription),e.showText!==void 0&&(this._options.showText=e.showText);let n=this._text!==void 0;return e.glyphColor!==void 0&&(n?this.setGlyphColor(e.glyphColor):this._options.glyphColor=e.glyphColor),e.descriptionColor!==void 0&&(n?this.setDescriptionColor(e.descriptionColor):this._options.descriptionColor=e.descriptionColor),e.text!==void 0&&(n?this.setText(e.text):this._options.text=e.text),e.description!==void 0&&(n?this.setDescription(e.description):this._options.description=e.description),e.glyph!==void 0&&(n?this.setGlyph(e.glyph):this._options.glyph=e.glyph),e.enabled!==void 0&&this.setEnabled(e.enabled),e.chromeless!==void 0&&(this._options.chromeless=e.chromeless),e.flat!==void 0&&(this._options.flat=e.flat),e.compact!==void 0&&this.setCompact(e.compact),e.anchor!==void 0&&(this._options.anchor=e.anchor),e.fill!==void 0&&(this._options.fill=e.fill),this}applyChromeOptions(e){if((e.chromeless??this.isChromeless())===!0){this.clearBorder(),this._options.borderRadius=void 0,this._options.shadow=void 0,this._options.backgroundImage=void 0,this.getBackgroundColor()===null&&(this._options.backgroundColor=`transparent`);return}super.applyChromeOptions(e),(this._options.flat??e.flat)!==!0&&e.backgroundColor===void 0&&this.setBackgroundColor(v),this.setPressedForegroundColor(e.pressedForegroundColor??this.getPressedForegroundColor()),this.setPressedBackgroundColor(e.pressedBackgroundColor??this.getPressedBackgroundColor()),this.setPressedBackgroundImage(e.pressedBackgroundImage??this.getPressedBackgroundImage()),this.setPressedShadow(e.pressedShadow??this.getPressedShadow()),e.pressedBorder!==void 0&&this.setPressedBorder(e.pressedBorder),e.pressedBorderRadius!==void 0&&this.setPressedBorderRadius(e.pressedBorderRadius),e.hoverForegroundColor!==void 0&&this.setHoverForegroundColor(e.hoverForegroundColor),this.setHoverBackgroundColor(e.hoverBackgroundColor??this.getHoverBackgroundColor()),this.setHoverBackgroundImage(e.hoverBackgroundImage??this.getHoverBackgroundImage()),this.setHoverShadow(e.hoverShadow??this.getHoverShadow()),e.hoverBorder!==void 0&&this.setHoverBorder(e.hoverBorder),e.hoverBorderRadius!==void 0&&this.setHoverBorderRadius(e.hoverBorderRadius),(this._options.flat??e.flat)===!0&&(this._flat=!0,this._applyFlatChrome())}setText(e){return this._options.text=e,this._text.setText(this._isShowText()?e:``),this.recomputePreferredSize(),this._rebuildTooltip(),this._reflectAccessibleName(),this}getText(){return this._options.text??``}setWritingMode(e){let t=this._contentOrientation();return super.setWritingMode(e),this._text&&(this._text.setWritingMode(e),this._description?.setWritingMode(e),this._contentOrientation()!==t&&(this._glyph||this._description)&&this._rebuildContentRow(),this.recomputePreferredSize()),this}setTextAlign(e){if(this._text){this._text.setTextAlign(e);let t=this.getLayoutConstraints(this._content);t&&(t.anchor=this._anchorForTextAlign(e),this.scheduleLayout())}return this}_anchorForTextAlign(e){let t=e===`left`||e===`start`,n=e===`right`||e===`end`,r=this._contentOrientation();return r===`cw`?t?o.NORTH:n?o.SOUTH:o.CENTER:r===`ccw`?t?o.SOUTH:n?o.NORTH:o.CENTER:t?o.WEST:n?o.EAST:o.CENTER}clearWritingMode(){let e=this._contentOrientation();return super.clearWritingMode(),this._text&&(this._text.clearWritingMode(),this._description?.clearWritingMode(),this._contentOrientation()!==e&&(this._glyph||this._description)&&this._rebuildContentRow(),this.recomputePreferredSize()),this}setDescription(e){return this._description||(this._description=new d,this._description.setPointerEvents(`none`),this._description.setTextAlign(`center`),this._description.setFontSize(`--ts-ui-button-description-font-size`),this._description.setFontWeight(`var(--ts-ui-button-description-weight, normal)`),this._description.setForegroundColor(this._options.descriptionColor??`var(--ts-ui-button-description-fg, rgb(110, 110, 110))`)),this._description.setText(e),this._rebuildContentRow(),this._rebuildTooltip(),this.recomputePreferredSize(),this}getDescription(){return this._description}clearDescription(){return this._description=null,this._rebuildContentRow(),this._rebuildTooltip(),this.recomputePreferredSize(),this}_rebuildTooltip(){if(this._tooltipSuppressed){l.detach(this);return}let e=this._options.text??``,t=this._description?.getText().valueOf()??``,n;n=e&&t?`${e}\n\n${t}`:e||t,n?l.attach(this,n):l.detach(this)}setTooltipSuppressed(e){return e===this._tooltipSuppressed?this:(this._tooltipSuppressed=e,this._rebuildTooltip(),this)}_reflectAccessibleName(){let e=this._options.text??``;!this._isShowText()&&e!==``?this.getAria().setLabel(e):this.getAria().clearLabel()}_isDescriptionUnderGlyph(){return this._options.descriptionUnderGlyph??!0}_isShowDescription(){return this._options.showDescription??!0}_isShowText(){return this._options.showText??!0}_contentOrientation(){let e=this.getWritingMode();return e===`sideways-rl`?`cw`:e===`sideways-lr`?`ccw`:`horizontal`}_orientBox(e,t,n){e.setLayoutManager(t===`v`?new p({spacing:n}):new f({spacing:n}))}_addContentChildren(e,t,n){let r=n?[...t].reverse():t;for(let t of r)e.addComponent(t)}_rebuildContentRow(){this._content.removeAllComponents(),this._titleColumn.removeAllComponents(),this._innerRow?.removeAllComponents(),this._outerColumn?.removeAllComponents();let e=this._description!==null&&this._isShowDescription(),r=this._isShowText(),i=this._contentOrientation(),o=i!==`horizontal`,s=o?`v`:`h`,c=o?`h`:`v`,l=i===`ccw`,u=i===`cw`;if(e&&this._glyph&&this._isDescriptionUnderGlyph())this._innerRow||(this._innerRow=new a,this._innerRow.setInsets(new n(0,0,0,0)),this._innerRow.setPointerEvents(`none`)),this._outerColumn||(this._outerColumn=new a,this._outerColumn.setInsets(new n(0,0,0,0)),this._outerColumn.setPointerEvents(`none`)),this._orientBox(this._content,s,2),this._orientBox(this._innerRow,s,2),this._orientBox(this._outerColumn,c,0),this._addContentChildren(this._innerRow,r?[this._glyph,this._text]:[this._glyph],l),this._addContentChildren(this._outerColumn,[this._innerRow,this._description],u),this._content.addComponent(this._outerColumn);else if(e){this._orientBox(this._content,s,2),this._orientBox(this._titleColumn,c,0),this._addContentChildren(this._titleColumn,r?[this._text,this._description]:[this._description],u);let e=this._glyph?[this._glyph,this._titleColumn]:[this._titleColumn];this._addContentChildren(this._content,e,l)}else{let e=this._text.getText().valueOf()!==``;this._orientBox(this._content,s,this._glyph&&!e?0:2);let t=this._glyph?[this._glyph,this._text]:[this._text];this._addContentChildren(this._content,t,l)}let d=!o&&!e&&this._text.getText().valueOf()!==``?t.opticalCenterOffset():0;this._content.setInsets(new n(d,0,0,0)),this._reflectAccessibleName(),this._afterRebuildContentRow()}_afterRebuildContentRow(){}_syncGlyphSize(){let e=this._glyph;if(!e||this._glyphSizePinned)return;let t=this._text.getLineHeight();if(t===null)return;let n=Math.round(t),r=e.getPreferredSize(),i=this._glyphSyncedSize;r&&i!==null&&(r.width!==i||r.height!==i)||(e.setPreferredSize({width:n,height:n}),this._glyphSyncedSize=n)}setGlyph(e){let t=new c(e);return t.setPointerEvents(`none`),this._glyph=t,this._glyphSyncedSize=null,this._options.glyphColor!==void 0&&t.setForegroundColor(this._options.glyphColor),this._rebuildContentRow(),this.recomputePreferredSize(),this}clearGlyph(){return this._glyph=null,this._glyphSyncedSize=null,this._rebuildContentRow(),this.recomputePreferredSize(),this}getGlyph(){return this._glyph}setGlyphColor(e){return this._options.glyphColor=e,this._glyph?.setForegroundColor(e),this}setDescriptionColor(e){return this._options.descriptionColor=e,this._description?.setForegroundColor(e),this}pinGlyphSize(e){return this._glyphSizePinned=!0,this._glyph?.setPreferredSize({width:e,height:e}),this}getBaseline(){return this.wrapInnerBaseline(this._text.getBaseline())}on(e,t){return s.addListener(this,`click`,t),this}off(e,t){return s.removeListener(this,`click`,t),this}click(){return s.fireEvent(this,`click`),this}addPointerDownListener(e){return s.addListener(this,`pointerdown`,e),this}isChromeless(){return this._options.chromeless??this._defaultOptions.chromeless??!1}setChromeless(e){return this.isChromeless()===e||(e?(this._clearChrome(),this._options.chromeless=!0,this._flat=!1,this._options.flat=!1):(this._options.chromeless=!1,this._restoreChrome())),this}_clearChrome(){this.clearBorder(),this.clearBorderRadius(),this.clearShadow(),this.clearBackgroundImage(),this._pressedStyleRule!==void 0&&(this.clearPressedBackgroundColor(),this.clearPressedBackgroundImage(),this.clearPressedForegroundColor(),this.clearPressedShadow(),this.clearPressedBorderRadius(),this.clearPressedBorder()),this._hoverStyleRule!==void 0&&(this.clearHoverBackgroundColor(),this.clearHoverBackgroundImage(),this.clearHoverForegroundColor(),this.clearHoverShadow(),this.clearHoverBorderRadius(),this.clearHoverBorder())}_restoreChrome(){let e=this._defaultOptions;e.backgroundColor===void 0&&this._options.backgroundColor===`transparent`&&this.setBackgroundColor(v),e.border!==void 0&&this.setBorder(e.border),e.borderRadius!==void 0&&this.setBorderRadius(e.borderRadius),e.shadow!==void 0&&this.setShadow(e.shadow),e.backgroundImage!==void 0&&this.setBackgroundImage(e.backgroundImage),e.pressedForegroundColor!==void 0&&this.setPressedForegroundColor(e.pressedForegroundColor),e.pressedBackgroundColor!==void 0&&this.setPressedBackgroundColor(e.pressedBackgroundColor),e.pressedBackgroundImage!==void 0&&this.setPressedBackgroundImage(e.pressedBackgroundImage),e.pressedShadow!==void 0&&this.setPressedShadow(e.pressedShadow),e.pressedBorder===void 0?this.clearPressedBorder():this.setPressedBorder(e.pressedBorder),e.pressedBorderRadius!==void 0&&this.setPressedBorderRadius(e.pressedBorderRadius),e.hoverForegroundColor!==void 0&&this.setHoverForegroundColor(e.hoverForegroundColor),e.hoverBackgroundColor!==void 0&&this.setHoverBackgroundColor(e.hoverBackgroundColor),e.hoverBackgroundImage!==void 0&&this.setHoverBackgroundImage(e.hoverBackgroundImage),e.hoverShadow!==void 0&&this.setHoverShadow(e.hoverShadow),e.hoverBorder===void 0?this.clearHoverBorder():this.setHoverBorder(e.hoverBorder),e.hoverBorderRadius!==void 0&&this.setHoverBorderRadius(e.hoverBorderRadius)}isFlat(){return this._flat??!1}setFlat(e){return e&&this.isChromeless()?(console.warn(`Button #`+this.getId()+`: setFlat(true) ignored — flat and chromeless are mutually exclusive, chromeless wins.`),this):((this._flat??!1)===e||(e?(this._flat=!0,this._options.flat=!0,this._applyFlatChrome()):(this._flat=!1,this._options.flat=!1,this._restoreChrome(),this._resolveInsets())),this)}isCompact(){return this._compact??!1}setCompact(e){return(this._compact??!1)===e?this:(this._compact=e,this._options.compact=e,this._resolveInsets(),this)}_applyFlatChrome(){this.setBorder(`1px solid transparent`),this.clearBorderRadius(),this.clearShadow(),this.clearBackgroundImage();let e=this.getBackgroundColor();(e===void 0||e===v)&&this.setBackgroundColor(`transparent`),this.clearPressedBackgroundImage(),this.clearHoverBackgroundImage(),this.clearHoverShadow(),this.setHoverBackgroundColor(`var(--ts-ui-button-flat-hover-bg, rgba(0, 0, 0, 0.06))`),this.setHoverBorder(`var(--ts-ui-button-flat-hover-border, 1px solid rgb(200, 200, 200))`),this.setPressedBackgroundColor(`var(--ts-ui-button-flat-pressed-bg, rgba(0, 0, 0, 0.10))`),this.setPressedShadow(`var(--ts-ui-button-flat-pressed-shadow, inset 1px 1px 3px rgba(0, 0, 0, 0.25))`),this.setPressedBorder(`var(--ts-ui-button-flat-pressed-border, 1px solid rgb(180, 180, 180))`),this._resolveInsets()}_resolveInsets(){if(this._text===void 0)return;let e=this._glyph!==null&&this._text.getText().valueOf()===``,t;t=this._compact&&e?g:this._compact?h:this._flat&&e?_:m,this.setInsets(t)}setInsets(e){return super.setInsets(e),this.recomputePreferredSize(),this}setPreferredSize(e){return this._consumerSetPreferredSize=!0,super.setPreferredSize(e),this}getPreferredSize(){return this._consumerSetPreferredSize||this._defaultOptions.preferredSize?super.getPreferredSize():this.computePreferredSize()}recomputePreferredSize(){if(this._syncGlyphSize(),this._consumerSetPreferredSize||this._defaultOptions.preferredSize)return;let e=this.computePreferredSize();super.setPreferredSize({width:e.width,height:e.height})}computePreferredSize(){let e=this._content?.getPreferredSize()??{width:0,height:0},t=this.getPerimeterSize();return{width:e.width+t.left+t.right,height:e.height+t.top+t.bottom}}getPressedBackgroundColor(){return this._options.pressedBackgroundColor??this._defaultOptions.pressedBackgroundColor??null}setPressedBackgroundColor(e){return this._options.pressedBackgroundColor=e,this.pressedStyleRule.set(`backgroundColor`,e),this}clearPressedBackgroundColor(){return this._options.pressedBackgroundColor=void 0,this.pressedStyleRule.set(`backgroundColor`,null),this}getPressedBackgroundImage(){return this._options.pressedBackgroundImage??this._defaultOptions.pressedBackgroundImage??null}setPressedBackgroundImage(e){return this._options.pressedBackgroundImage=e,this.pressedStyleRule.set(`backgroundImage`,e),this}clearPressedBackgroundImage(){return this._options.pressedBackgroundImage=void 0,this.pressedStyleRule.set(`backgroundImage`,null),this}getPressedForegroundColor(){return this._options.pressedForegroundColor??this._defaultOptions.pressedForegroundColor??null}setPressedForegroundColor(e){return this._options.pressedForegroundColor=e,this.pressedStyleRule.set(`color`,e),this}clearPressedForegroundColor(){return this._options.pressedForegroundColor=void 0,this.pressedStyleRule.set(`color`,null),this}getPressedBorder(){return this._pressedBorder}setPressedBorder(t){return this._pressedBorder=typeof t==`string`?{border:t}:t??{},this.pressedStyleRule.setMany(e(this._pressedBorder)),this}clearPressedBorder(){return this._pressedBorder=null,this.pressedStyleRule.setMany({borderTop:null,borderRight:null,borderBottom:null,borderLeft:null}),this}getPressedBorderRadius(){return this._options.pressedBorderRadius??null}setPressedBorderRadius(e){return this._options.pressedBorderRadius=e,this.pressedStyleRule.set(`borderRadius`,e),this}clearPressedBorderRadius(){return this._options.pressedBorderRadius=void 0,this.pressedStyleRule.set(`borderRadius`,null),this}getPressedShadow(){return this._options.pressedShadow??this._defaultOptions.pressedShadow??null}setPressedShadow(e){return this._options.pressedShadow=e,this.pressedStyleRule.set(`boxShadow`,e),this}clearPressedShadow(){return this._options.pressedShadow=void 0,this.pressedStyleRule.set(`boxShadow`,null),this}getHoverBackgroundColor(){return this._options.hoverBackgroundColor??this._defaultOptions.hoverBackgroundColor??null}setHoverBackgroundColor(e){return this._options.hoverBackgroundColor=e,this.hoverStyleRule.set(`backgroundColor`,e),this}clearHoverBackgroundColor(){return this._options.hoverBackgroundColor=void 0,this.hoverStyleRule.set(`backgroundColor`,null),this}getHoverBackgroundImage(){return this._options.hoverBackgroundImage??this._defaultOptions.hoverBackgroundImage??null}setHoverBackgroundImage(e){return this._options.hoverBackgroundImage=e,this.hoverStyleRule.set(`backgroundImage`,e),this}clearHoverBackgroundImage(){return this._options.hoverBackgroundImage=void 0,this.hoverStyleRule.set(`backgroundImage`,null),this}getHoverForegroundColor(){return this._options.hoverForegroundColor??null}setHoverForegroundColor(e){return this._options.hoverForegroundColor=e,this.hoverStyleRule.set(`color`,e),this}clearHoverForegroundColor(){return this._options.hoverForegroundColor=void 0,this.hoverStyleRule.set(`color`,null),this}getHoverBorder(){return this._hoverBorder}setHoverBorder(t){return this._hoverBorder=typeof t==`string`?{border:t}:t??{},this.hoverStyleRule.setMany(e(this._hoverBorder)),this}clearHoverBorder(){return this._hoverBorder=null,this.hoverStyleRule.setMany({borderTop:null,borderRight:null,borderBottom:null,borderLeft:null}),this}getHoverBorderRadius(){return this._options.hoverBorderRadius??null}setHoverBorderRadius(e){return this._options.hoverBorderRadius=e,this.hoverStyleRule.set(`borderRadius`,e),this}clearHoverBorderRadius(){return this._options.hoverBorderRadius=void 0,this.hoverStyleRule.set(`borderRadius`,null),this}getHoverShadow(){return this._options.hoverShadow??this._defaultOptions.hoverShadow??null}setHoverShadow(e){return this._options.hoverShadow=e,this.hoverStyleRule.set(`boxShadow`,e),this}clearHoverShadow(){return this._options.hoverShadow=void 0,this.hoverStyleRule.set(`boxShadow`,null),this}setEnabled(e){return(this._options.enabled??!0)===e?this:(this._options.enabled=e,e?(this.setDisabledAttribute(!1),this.clearOpacity(),this.setCursor(this._enabledCursor)):(this._enabledCursor=this.getCursor()??`pointer`,this.setDisabledAttribute(!0),this.setOpacity(.5),this.setCursor(`not-allowed`)),this)}isEnabled(){return this._options.enabled??!0}setDescriptionUnderGlyph(e){return this._options.descriptionUnderGlyph=e,this._rebuildContentRow(),this.recomputePreferredSize(),this}isDescriptionUnderGlyph(){return this._isDescriptionUnderGlyph()}setShowDescription(e){return this._options.showDescription=e,this._rebuildContentRow(),this.recomputePreferredSize(),this}isShowDescription(){return this._isShowDescription()}setShowText(e){return this._options.showText=e,this._text.setText(e?this._options.text??``:``),this._rebuildContentRow(),this._resolveInsets(),this.recomputePreferredSize(),this}isShowText(){return this._isShowText()}});export{b as t};
2
- //# sourceMappingURL=Button-U1rsP4v8.js.map
1
+ import{i as e,l as t,n}from"./Position-DRSlWn4Z.js";import{f as r,m as i,p as a,t as o,x as s}from"./Component-CHTzJxEf.js";import{t as c}from"./Glyph-CnNslL95.js";import{t as l}from"./Tooltip-BUy6uFKN.js";import{t as u}from"./Fit-E-EIZv1k.js";import{t as d}from"./Text-Bni4icFY.js";import{n as f}from"./VBox-Dr7Ge9M6.js";import{t as p}from"./HBox-Dm3xgsDE.js";var m=new n(5,10,5,10),h=new n(2,6,2,6),g=new n(2,2,2,2),_=new n(4,4,4,4),v=`var(--ts-ui-button-bg, transparent)`,y={tag:`button`,cursor:`pointer`,foregroundColor:`var(--ts-ui-text-color, black)`,border:`2px ridge var(--ts-ui-button-border, rgb(200, 200, 200))`,borderRadius:`var(--ts-ui-border-radius, 4px)`,shadow:`var(--ts-ui-button-shadow, 1px 2px 5px 0 rgba(0, 0, 0, 0.2))`,backgroundImage:`var(--ts-ui-button-bg, linear-gradient(rgb(241, 241, 241), rgb(200, 200, 200)))`,insets:m,anchor:r.CENTER,fill:a.NONE,pressedForegroundColor:`var(--ts-ui-button-pressed-fg, rgb(150, 150, 150))`,pressedBackgroundColor:`var(--ts-ui-button-pressed-bg, rgb(200, 200, 200))`,pressedBackgroundImage:`var(--ts-ui-button-pressed-bg, none)`,pressedShadow:`var(--ts-ui-button-pressed-shadow, 1px 2px 5px 0 rgba(0, 0, 0, 0.2) inset)`,hoverBackgroundColor:`var(--ts-ui-button-hover-bg, rgb(252, 252, 252))`,hoverBackgroundImage:`var(--ts-ui-button-hover-bg, none)`,hoverShadow:`var(--ts-ui-button-hover-shadow, 1px 3px 6px 0 rgba(0, 0, 0, 0.25))`},b=i(class Button extends o{_text;_content;_titleColumn;_description=null;_tooltipSuppressed=!1;_outerColumn=null;_innerRow=null;_glyph=null;_glyphSyncedSize=null;_glyphSizePinned=!1;_onThemeChange=()=>{this._rebuildContentRow(),this.recomputePreferredSize()};get pressedStyleRule(){return this._pressedStyleRule??=this.createStyleRule(`:active`)}_pressedBorder=null;get hoverStyleRule(){return this._hoverStyleRule??=this.createStyleRule(`:hover:not(:active)`)}_hoverBorder=null;_enabledCursor=`pointer`;constructor(e,t,r){let i;typeof e==`string`?i=e:e!==void 0&&(t=e),super(t,{...y,...r??{}}),this.setLayoutManager(new u),this._text=new d,this._titleColumn=new o,this._titleColumn.setLayoutManager(new f({spacing:0})),this._titleColumn.setInsets(new n(0,0,0,0)),this._titleColumn.setPointerEvents(`none`),this._titleColumn.addComponent(this._text),this._content=new o,this._content.setLayoutManager(new p({spacing:2})),this._content.setInsets(new n(0,0,0,0)),this._content.setPointerEvents(`none`),this._content.addComponent(this._titleColumn),this._text.setPointerEvents(`none`),this._text.setTextAlign(`center`),this._text.setFontWeight(`bold`),this._text.setFontSize(`--ts-ui-button-font-size`),this.addComponent(this._content,{fill:this.getFill(),anchor:this.getAnchor()});let a=this._options.text??this._defaultOptions.text??i;a!==void 0&&this.setText(a);let s=this._options.glyph??this._defaultOptions.glyph;s!==void 0&&this.setGlyph(s);let c=this._options.description??this._defaultOptions.description;c!==void 0&&this.setDescription(c),(this._flat||this._compact)&&this._resolveInsets(),this.recomputePreferredSize(),this.subscribeTheme(this._onThemeChange),Object.getPrototypeOf(this)===Button.prototype&&this.applyListeners(t?.listeners)}getAnchor(){return this._options.anchor??this._defaultOptions.anchor}getFill(){return this._options.fill??this._defaultOptions.fill}applyOptions(e){let t=this.getLayoutManager();super.applyOptions(e),e.layoutManager===void 0&&this.getLayoutManager()!==t&&this.setLayoutManager(t),e.descriptionUnderGlyph!==void 0&&(this._options.descriptionUnderGlyph=e.descriptionUnderGlyph),e.showDescription!==void 0&&(this._options.showDescription=e.showDescription),e.showText!==void 0&&(this._options.showText=e.showText);let n=this._text!==void 0;return e.glyphColor!==void 0&&(n?this.setGlyphColor(e.glyphColor):this._options.glyphColor=e.glyphColor),e.descriptionColor!==void 0&&(n?this.setDescriptionColor(e.descriptionColor):this._options.descriptionColor=e.descriptionColor),e.text!==void 0&&(n?this.setText(e.text):this._options.text=e.text),e.description!==void 0&&(n?this.setDescription(e.description):this._options.description=e.description),e.glyph!==void 0&&(n?this.setGlyph(e.glyph):this._options.glyph=e.glyph),e.enabled!==void 0&&this.setEnabled(e.enabled),e.chromeless!==void 0&&(this._options.chromeless=e.chromeless),e.flat!==void 0&&(this._options.flat=e.flat),e.compact!==void 0&&this.setCompact(e.compact),e.anchor!==void 0&&(this._options.anchor=e.anchor),e.fill!==void 0&&(this._options.fill=e.fill),this}applyChromeOptions(e){if((e.chromeless??this.isChromeless())===!0){this.clearBorder(),this._options.borderRadius=void 0,this._options.shadow=void 0,this._options.backgroundImage=void 0,this.getBackgroundColor()===null&&(this._options.backgroundColor=`transparent`);return}super.applyChromeOptions(e),(this._options.flat??e.flat)!==!0&&e.backgroundColor===void 0&&this.setBackgroundColor(v),this.setPressedForegroundColor(e.pressedForegroundColor??this.getPressedForegroundColor()),this.setPressedBackgroundColor(e.pressedBackgroundColor??this.getPressedBackgroundColor()),this.setPressedBackgroundImage(e.pressedBackgroundImage??this.getPressedBackgroundImage()),this.setPressedShadow(e.pressedShadow??this.getPressedShadow()),e.pressedBorder!==void 0&&this.setPressedBorder(e.pressedBorder),e.pressedBorderRadius!==void 0&&this.setPressedBorderRadius(e.pressedBorderRadius),e.hoverForegroundColor!==void 0&&this.setHoverForegroundColor(e.hoverForegroundColor),this.setHoverBackgroundColor(e.hoverBackgroundColor??this.getHoverBackgroundColor()),this.setHoverBackgroundImage(e.hoverBackgroundImage??this.getHoverBackgroundImage()),this.setHoverShadow(e.hoverShadow??this.getHoverShadow()),e.hoverBorder!==void 0&&this.setHoverBorder(e.hoverBorder),e.hoverBorderRadius!==void 0&&this.setHoverBorderRadius(e.hoverBorderRadius),(this._options.flat??e.flat)===!0&&(this._flat=!0,this._applyFlatChrome())}setText(e){return this._options.text=e,this._text.setText(this._isShowText()?e:``),this.recomputePreferredSize(),this._rebuildTooltip(),this._reflectAccessibleName(),this}getText(){return this._options.text??``}setWritingMode(e){let t=this._contentOrientation();return super.setWritingMode(e),this._text&&(this._text.setWritingMode(e),this._description?.setWritingMode(e),this._contentOrientation()!==t&&(this._glyph||this._description)&&this._rebuildContentRow(),this.recomputePreferredSize()),this}setTextAlign(e){if(this._text){this._text.setTextAlign(e);let t=this.getLayoutConstraints(this._content);t&&(t.anchor=this._anchorForTextAlign(e),this.scheduleLayout())}return this}_anchorForTextAlign(e){let t=e===`left`||e===`start`,n=e===`right`||e===`end`,i=this._contentOrientation();return i===`cw`?t?r.NORTH:n?r.SOUTH:r.CENTER:i===`ccw`?t?r.SOUTH:n?r.NORTH:r.CENTER:t?r.WEST:n?r.EAST:r.CENTER}clearWritingMode(){let e=this._contentOrientation();return super.clearWritingMode(),this._text&&(this._text.clearWritingMode(),this._description?.clearWritingMode(),this._contentOrientation()!==e&&(this._glyph||this._description)&&this._rebuildContentRow(),this.recomputePreferredSize()),this}setDescription(e){return this._description||(this._description=new d,this._description.setPointerEvents(`none`),this._description.setTextAlign(`center`),this._description.setFontSize(`--ts-ui-button-description-font-size`),this._description.setFontWeight(`var(--ts-ui-button-description-weight, normal)`),this._description.setForegroundColor(this._options.descriptionColor??`var(--ts-ui-button-description-fg, rgb(110, 110, 110))`)),this._description.setText(e),this._rebuildContentRow(),this._rebuildTooltip(),this.recomputePreferredSize(),this}getDescription(){return this._description}clearDescription(){return this._description=null,this._rebuildContentRow(),this._rebuildTooltip(),this.recomputePreferredSize(),this}_rebuildTooltip(){if(this._tooltipSuppressed){l.detach(this);return}let e=this._options.text??``,t=this._description?.getText().valueOf()??``,n;n=e&&t?`${e}\n\n${t}`:e||t,n?l.attach(this,n):l.detach(this)}setTooltipSuppressed(e){return e===this._tooltipSuppressed?this:(this._tooltipSuppressed=e,this._rebuildTooltip(),this)}_reflectAccessibleName(){let e=this._options.text??``;!this._isShowText()&&e!==``?this.getAria().setLabel(e):this.getAria().clearLabel()}_isDescriptionUnderGlyph(){return this._options.descriptionUnderGlyph??!0}_isShowDescription(){return this._options.showDescription??!0}_isShowText(){return this._options.showText??!0}_contentOrientation(){let e=this.getWritingMode();return e===`sideways-rl`?`cw`:e===`sideways-lr`?`ccw`:`horizontal`}_orientBox(e,t,n){e.setLayoutManager(t===`v`?new f({spacing:n}):new p({spacing:n}))}_addContentChildren(e,t,n){let r=n?[...t].reverse():t;for(let t of r)e.addComponent(t)}_rebuildContentRow(){this._content.removeAllComponents(),this._titleColumn.removeAllComponents(),this._innerRow?.removeAllComponents(),this._outerColumn?.removeAllComponents();let e=this._description!==null&&this._isShowDescription(),r=this._isShowText(),i=this._contentOrientation(),a=i!==`horizontal`,s=a?`v`:`h`,c=a?`h`:`v`,l=i===`ccw`,u=i===`cw`;if(e&&this._glyph&&this._isDescriptionUnderGlyph())this._innerRow||(this._innerRow=new o,this._innerRow.setInsets(new n(0,0,0,0)),this._innerRow.setPointerEvents(`none`)),this._outerColumn||(this._outerColumn=new o,this._outerColumn.setInsets(new n(0,0,0,0)),this._outerColumn.setPointerEvents(`none`)),this._orientBox(this._content,s,2),this._orientBox(this._innerRow,s,2),this._orientBox(this._outerColumn,c,0),this._addContentChildren(this._innerRow,r?[this._glyph,this._text]:[this._glyph],l),this._addContentChildren(this._outerColumn,[this._innerRow,this._description],u),this._content.addComponent(this._outerColumn);else if(e){this._orientBox(this._content,s,2),this._orientBox(this._titleColumn,c,0),this._addContentChildren(this._titleColumn,r?[this._text,this._description]:[this._description],u);let e=this._glyph?[this._glyph,this._titleColumn]:[this._titleColumn];this._addContentChildren(this._content,e,l)}else{let e=this._text.getText().valueOf()!==``;this._orientBox(this._content,s,this._glyph&&!e?0:2);let t=this._glyph?[this._glyph,this._text]:[this._text];this._addContentChildren(this._content,t,l)}let d=!a&&!e&&this._text.getText().valueOf()!==``?t.opticalCenterOffset():0;this._content.setInsets(new n(d,0,0,0)),this._reflectAccessibleName(),this._afterRebuildContentRow()}_afterRebuildContentRow(){}_syncGlyphSize(){let e=this._glyph;if(!e||this._glyphSizePinned)return;let t=this._text.getLineHeight();if(t===null)return;let n=Math.round(t),r=e.getPreferredSize(),i=this._glyphSyncedSize;r&&i!==null&&(r.width!==i||r.height!==i)||(e.setPreferredSize({width:n,height:n}),this._glyphSyncedSize=n)}setGlyph(e){let t=new c(e);return t.setPointerEvents(`none`),this._glyph=t,this._glyphSyncedSize=null,this._options.glyphColor!==void 0&&t.setForegroundColor(this._options.glyphColor),this._rebuildContentRow(),this.recomputePreferredSize(),this}clearGlyph(){return this._glyph=null,this._glyphSyncedSize=null,this._rebuildContentRow(),this.recomputePreferredSize(),this}getGlyph(){return this._glyph}setGlyphColor(e){return this._options.glyphColor=e,this._glyph?.setForegroundColor(e),this}setDescriptionColor(e){return this._options.descriptionColor=e,this._description?.setForegroundColor(e),this}pinGlyphSize(e){return this._glyphSizePinned=!0,this._glyph?.setPreferredSize({width:e,height:e}),this}getBaseline(){return this.wrapInnerBaseline(this._text.getBaseline())}on(e,t){return s.addListener(this,`click`,t),this}off(e,t){return s.removeListener(this,`click`,t),this}click(){return s.fireEvent(this,`click`),this}addPointerDownListener(e){return s.addListener(this,`pointerdown`,e),this}isChromeless(){return this._options.chromeless??this._defaultOptions.chromeless??!1}setChromeless(e){return this.isChromeless()===e||(e?(this._clearChrome(),this._options.chromeless=!0,this._flat=!1,this._options.flat=!1):(this._options.chromeless=!1,this._restoreChrome())),this}_clearChrome(){this.clearBorder(),this.clearBorderRadius(),this.clearShadow(),this.clearBackgroundImage(),this._pressedStyleRule!==void 0&&(this.clearPressedBackgroundColor(),this.clearPressedBackgroundImage(),this.clearPressedForegroundColor(),this.clearPressedShadow(),this.clearPressedBorderRadius(),this.clearPressedBorder()),this._hoverStyleRule!==void 0&&(this.clearHoverBackgroundColor(),this.clearHoverBackgroundImage(),this.clearHoverForegroundColor(),this.clearHoverShadow(),this.clearHoverBorderRadius(),this.clearHoverBorder())}_restoreChrome(){let e=this._defaultOptions;e.backgroundColor===void 0&&this._options.backgroundColor===`transparent`&&this.setBackgroundColor(v),e.border!==void 0&&this.setBorder(e.border),e.borderRadius!==void 0&&this.setBorderRadius(e.borderRadius),e.shadow!==void 0&&this.setShadow(e.shadow),e.backgroundImage!==void 0&&this.setBackgroundImage(e.backgroundImage),e.pressedForegroundColor!==void 0&&this.setPressedForegroundColor(e.pressedForegroundColor),e.pressedBackgroundColor!==void 0&&this.setPressedBackgroundColor(e.pressedBackgroundColor),e.pressedBackgroundImage!==void 0&&this.setPressedBackgroundImage(e.pressedBackgroundImage),e.pressedShadow!==void 0&&this.setPressedShadow(e.pressedShadow),e.pressedBorder===void 0?this.clearPressedBorder():this.setPressedBorder(e.pressedBorder),e.pressedBorderRadius!==void 0&&this.setPressedBorderRadius(e.pressedBorderRadius),e.hoverForegroundColor!==void 0&&this.setHoverForegroundColor(e.hoverForegroundColor),e.hoverBackgroundColor!==void 0&&this.setHoverBackgroundColor(e.hoverBackgroundColor),e.hoverBackgroundImage!==void 0&&this.setHoverBackgroundImage(e.hoverBackgroundImage),e.hoverShadow!==void 0&&this.setHoverShadow(e.hoverShadow),e.hoverBorder===void 0?this.clearHoverBorder():this.setHoverBorder(e.hoverBorder),e.hoverBorderRadius!==void 0&&this.setHoverBorderRadius(e.hoverBorderRadius)}isFlat(){return this._flat??!1}setFlat(e){return e&&this.isChromeless()?(console.warn(`Button #`+this.getId()+`: setFlat(true) ignored — flat and chromeless are mutually exclusive, chromeless wins.`),this):((this._flat??!1)===e||(e?(this._flat=!0,this._options.flat=!0,this._applyFlatChrome()):(this._flat=!1,this._options.flat=!1,this._restoreChrome(),this._resolveInsets())),this)}isCompact(){return this._compact??!1}setCompact(e){return(this._compact??!1)===e?this:(this._compact=e,this._options.compact=e,this._resolveInsets(),this)}_applyFlatChrome(){this.setBorder(`1px solid transparent`),this.clearBorderRadius(),this.clearShadow(),this.clearBackgroundImage();let e=this.getBackgroundColor();(e===void 0||e===v)&&this.setBackgroundColor(`transparent`),this.clearPressedBackgroundImage(),this.clearHoverBackgroundImage(),this.clearHoverShadow(),this.setHoverBackgroundColor(`var(--ts-ui-button-flat-hover-bg, rgba(0, 0, 0, 0.06))`),this.setHoverBorder(`var(--ts-ui-button-flat-hover-border, 1px solid rgb(200, 200, 200))`),this.setPressedBackgroundColor(`var(--ts-ui-button-flat-pressed-bg, rgba(0, 0, 0, 0.10))`),this.setPressedShadow(`var(--ts-ui-button-flat-pressed-shadow, inset 1px 1px 3px rgba(0, 0, 0, 0.25))`),this.setPressedBorder(`var(--ts-ui-button-flat-pressed-border, 1px solid rgb(180, 180, 180))`),this._resolveInsets()}_resolveInsets(){if(this._text===void 0)return;let e=this._glyph!==null&&this._text.getText().valueOf()===``,t;t=this._compact&&e?g:this._compact?h:this._flat&&e?_:m,this.setInsets(t)}setInsets(e){return super.setInsets(e),this.recomputePreferredSize(),this}setPreferredSize(e){return this._consumerSetPreferredSize=!0,super.setPreferredSize(e),this}getPreferredSize(){return this._consumerSetPreferredSize||this._defaultOptions.preferredSize?super.getPreferredSize():this.computePreferredSize()}recomputePreferredSize(){if(this._syncGlyphSize(),this._consumerSetPreferredSize||this._defaultOptions.preferredSize)return;let e=this.computePreferredSize();super.setPreferredSize({width:e.width,height:e.height})}computePreferredSize(){let e=this._content?.getPreferredSize()??{width:0,height:0},t=this.getPerimeterSize();return{width:e.width+t.left+t.right,height:e.height+t.top+t.bottom}}getPressedBackgroundColor(){return this._options.pressedBackgroundColor??this._defaultOptions.pressedBackgroundColor??null}setPressedBackgroundColor(e){return this._options.pressedBackgroundColor=e,this.pressedStyleRule.set(`backgroundColor`,e),this}clearPressedBackgroundColor(){return this._options.pressedBackgroundColor=void 0,this.pressedStyleRule.set(`backgroundColor`,null),this}getPressedBackgroundImage(){return this._options.pressedBackgroundImage??this._defaultOptions.pressedBackgroundImage??null}setPressedBackgroundImage(e){return this._options.pressedBackgroundImage=e,this.pressedStyleRule.set(`backgroundImage`,e),this}clearPressedBackgroundImage(){return this._options.pressedBackgroundImage=void 0,this.pressedStyleRule.set(`backgroundImage`,null),this}getPressedForegroundColor(){return this._options.pressedForegroundColor??this._defaultOptions.pressedForegroundColor??null}setPressedForegroundColor(e){return this._options.pressedForegroundColor=e,this.pressedStyleRule.set(`color`,e),this}clearPressedForegroundColor(){return this._options.pressedForegroundColor=void 0,this.pressedStyleRule.set(`color`,null),this}getPressedBorder(){return this._pressedBorder}setPressedBorder(t){return this._pressedBorder=typeof t==`string`?{border:t}:t??{},this.pressedStyleRule.setMany(e(this._pressedBorder)),this}clearPressedBorder(){return this._pressedBorder=null,this.pressedStyleRule.setMany({borderTop:null,borderRight:null,borderBottom:null,borderLeft:null}),this}getPressedBorderRadius(){return this._options.pressedBorderRadius??null}setPressedBorderRadius(e){return this._options.pressedBorderRadius=e,this.pressedStyleRule.set(`borderRadius`,e),this}clearPressedBorderRadius(){return this._options.pressedBorderRadius=void 0,this.pressedStyleRule.set(`borderRadius`,null),this}getPressedShadow(){return this._options.pressedShadow??this._defaultOptions.pressedShadow??null}setPressedShadow(e){return this._options.pressedShadow=e,this.pressedStyleRule.set(`boxShadow`,e),this}clearPressedShadow(){return this._options.pressedShadow=void 0,this.pressedStyleRule.set(`boxShadow`,null),this}getHoverBackgroundColor(){return this._options.hoverBackgroundColor??this._defaultOptions.hoverBackgroundColor??null}setHoverBackgroundColor(e){return this._options.hoverBackgroundColor=e,this.hoverStyleRule.set(`backgroundColor`,e),this}clearHoverBackgroundColor(){return this._options.hoverBackgroundColor=void 0,this.hoverStyleRule.set(`backgroundColor`,null),this}getHoverBackgroundImage(){return this._options.hoverBackgroundImage??this._defaultOptions.hoverBackgroundImage??null}setHoverBackgroundImage(e){return this._options.hoverBackgroundImage=e,this.hoverStyleRule.set(`backgroundImage`,e),this}clearHoverBackgroundImage(){return this._options.hoverBackgroundImage=void 0,this.hoverStyleRule.set(`backgroundImage`,null),this}getHoverForegroundColor(){return this._options.hoverForegroundColor??null}setHoverForegroundColor(e){return this._options.hoverForegroundColor=e,this.hoverStyleRule.set(`color`,e),this}clearHoverForegroundColor(){return this._options.hoverForegroundColor=void 0,this.hoverStyleRule.set(`color`,null),this}getHoverBorder(){return this._hoverBorder}setHoverBorder(t){return this._hoverBorder=typeof t==`string`?{border:t}:t??{},this.hoverStyleRule.setMany(e(this._hoverBorder)),this}clearHoverBorder(){return this._hoverBorder=null,this.hoverStyleRule.setMany({borderTop:null,borderRight:null,borderBottom:null,borderLeft:null}),this}getHoverBorderRadius(){return this._options.hoverBorderRadius??null}setHoverBorderRadius(e){return this._options.hoverBorderRadius=e,this.hoverStyleRule.set(`borderRadius`,e),this}clearHoverBorderRadius(){return this._options.hoverBorderRadius=void 0,this.hoverStyleRule.set(`borderRadius`,null),this}getHoverShadow(){return this._options.hoverShadow??this._defaultOptions.hoverShadow??null}setHoverShadow(e){return this._options.hoverShadow=e,this.hoverStyleRule.set(`boxShadow`,e),this}clearHoverShadow(){return this._options.hoverShadow=void 0,this.hoverStyleRule.set(`boxShadow`,null),this}setEnabled(e){return(this._options.enabled??!0)===e?this:(this._options.enabled=e,e?(this.setDisabledAttribute(!1),this.clearOpacity(),this.setCursor(this._enabledCursor)):(this._enabledCursor=this.getCursor()??`pointer`,this.setDisabledAttribute(!0),this.setOpacity(.5),this.setCursor(`not-allowed`)),this)}isEnabled(){return this._options.enabled??!0}setDescriptionUnderGlyph(e){return this._options.descriptionUnderGlyph=e,this._rebuildContentRow(),this.recomputePreferredSize(),this}isDescriptionUnderGlyph(){return this._isDescriptionUnderGlyph()}setShowDescription(e){return this._options.showDescription=e,this._rebuildContentRow(),this.recomputePreferredSize(),this}isShowDescription(){return this._isShowDescription()}setShowText(e){return this._options.showText=e,this._text.setText(e?this._options.text??``:``),this._rebuildContentRow(),this._resolveInsets(),this.recomputePreferredSize(),this}isShowText(){return this._isShowText()}});export{b as t};
2
+ //# sourceMappingURL=Button-B36rBMKC.js.map