@jimka/typescript-ui 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +5 -18
  2. package/dist/lib/AbstractBooleanInput-C6CidMMX.js +2 -0
  3. package/dist/lib/AbstractBooleanInput-C6CidMMX.js.map +1 -0
  4. package/dist/lib/AbstractInput-CfjW_HM2.js +2 -0
  5. package/dist/lib/AbstractInput-CfjW_HM2.js.map +1 -0
  6. package/dist/lib/AnimatedDropdown-BFz-DO7R.js +2 -0
  7. package/dist/lib/AnimatedDropdown-BFz-DO7R.js.map +1 -0
  8. package/dist/lib/Border-5Ki2DCWz.js +2 -0
  9. package/dist/lib/Border-5Ki2DCWz.js.map +1 -0
  10. package/dist/lib/BoxLayout-8ryMD4j5.js +2 -0
  11. package/dist/lib/BoxLayout-8ryMD4j5.js.map +1 -0
  12. package/dist/lib/Button-Cdq2ySPL.js +2 -0
  13. package/dist/lib/Button-Cdq2ySPL.js.map +1 -0
  14. package/dist/lib/Card-AKIUAWYS.js +2 -0
  15. package/dist/lib/Card-AKIUAWYS.js.map +1 -0
  16. package/dist/lib/ComboBox-e_YVsWBr.js +2 -0
  17. package/dist/lib/ComboBox-e_YVsWBr.js.map +1 -0
  18. package/dist/lib/Component-Bs6TvaGZ.js +2 -0
  19. package/dist/lib/Component-Bs6TvaGZ.js.map +1 -0
  20. package/dist/lib/Container-CzyZeMyZ.js +2 -0
  21. package/dist/lib/Container-CzyZeMyZ.js.map +1 -0
  22. package/dist/lib/DOM-DeF_dWe2.js +2 -0
  23. package/dist/lib/DOM-DeF_dWe2.js.map +1 -0
  24. package/dist/lib/DragManager-c6M_mE3e.js +2 -0
  25. package/dist/lib/DragManager-c6M_mE3e.js.map +1 -0
  26. package/dist/lib/FieldDecorator-Bl0h9UEF.js +2 -0
  27. package/dist/lib/FieldDecorator-Bl0h9UEF.js.map +1 -0
  28. package/dist/lib/Fit-CUS1JXy3.js +2 -0
  29. package/dist/lib/Fit-CUS1JXy3.js.map +1 -0
  30. package/dist/lib/Glyph-6Ki3A1_a.js +2 -0
  31. package/dist/lib/Glyph-6Ki3A1_a.js.map +1 -0
  32. package/dist/lib/Grid-D8luwRPI.js +2 -0
  33. package/dist/lib/Grid-D8luwRPI.js.map +1 -0
  34. package/dist/lib/GridConstraints-CzC0w4i-.js +2 -0
  35. package/dist/lib/GridConstraints-CzC0w4i-.js.map +1 -0
  36. package/dist/lib/HBox-BWMf9h6r.js +2 -0
  37. package/dist/lib/HBox-BWMf9h6r.js.map +1 -0
  38. package/dist/lib/Header-CQjomjo0.js +2 -0
  39. package/dist/lib/Header-CQjomjo0.js.map +1 -0
  40. package/dist/lib/IconText-BXJK0MOq.js +2 -0
  41. package/dist/lib/IconText-BXJK0MOq.js.map +1 -0
  42. package/dist/lib/LayoutSerialization-C_zcwaN3.js +2 -0
  43. package/dist/lib/LayoutSerialization-C_zcwaN3.js.map +1 -0
  44. package/dist/lib/LayoutSizes-XdhpAOmc.js +2 -0
  45. package/dist/lib/LayoutSizes-XdhpAOmc.js.map +1 -0
  46. package/dist/lib/List-BgxnLWnl.js +2 -0
  47. package/dist/lib/List-BgxnLWnl.js.map +1 -0
  48. package/dist/lib/Menu-BdnwRY0M.js +2 -0
  49. package/dist/lib/Menu-BdnwRY0M.js.map +1 -0
  50. package/dist/lib/MenuButton-D15cSbMf.js +2 -0
  51. package/dist/lib/MenuButton-D15cSbMf.js.map +1 -0
  52. package/dist/lib/Panel-DApa7vA6.js +2 -0
  53. package/dist/lib/Panel-DApa7vA6.js.map +1 -0
  54. package/dist/lib/Position-DJKB0N3l.js +2 -0
  55. package/dist/lib/Position-DJKB0N3l.js.map +1 -0
  56. package/dist/lib/ProgressSpinner-CNYcsBhw.js +2 -0
  57. package/dist/lib/ProgressSpinner-CNYcsBhw.js.map +1 -0
  58. package/dist/lib/RadioButton-CepkneSA.js +2 -0
  59. package/dist/lib/RadioButton-CepkneSA.js.map +1 -0
  60. package/dist/lib/RovingTabIndex-D-zOuptw.js +2 -0
  61. package/dist/lib/RovingTabIndex-D-zOuptw.js.map +1 -0
  62. package/dist/lib/Scrollbar-DQdCdj94.js +2 -0
  63. package/dist/lib/Scrollbar-DQdCdj94.js.map +1 -0
  64. package/dist/lib/Slider-DvDdVvRm.js +2 -0
  65. package/dist/lib/Slider-DvDdVvRm.js.map +1 -0
  66. package/dist/lib/Spacer-BqiPiCqz.js +2 -0
  67. package/dist/lib/Spacer-BqiPiCqz.js.map +1 -0
  68. package/dist/lib/TabButton-DqYDfN7P.js +2 -0
  69. package/dist/lib/TabButton-DqYDfN7P.js.map +1 -0
  70. package/dist/lib/Text-DJoUHukb.js +2 -0
  71. package/dist/lib/Text-DJoUHukb.js.map +1 -0
  72. package/dist/lib/Tooltip-5BR7yYEX.js +3 -0
  73. package/dist/lib/Tooltip-5BR7yYEX.js.map +1 -0
  74. package/dist/lib/VBox-CdV9VGxR.js +2 -0
  75. package/dist/lib/VBox-CdV9VGxR.js.map +1 -0
  76. package/dist/lib/VirtualRowView-C18j90n5.js +2 -0
  77. package/dist/lib/VirtualRowView-C18j90n5.js.map +1 -0
  78. package/dist/lib/VirtualScroller-BKMvTisA.js +2 -0
  79. package/dist/lib/VirtualScroller-BKMvTisA.js.map +1 -0
  80. package/dist/lib/component/button.es.js +1 -1
  81. package/dist/lib/component/button.es.js.map +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/container.es.js.map +1 -1
  86. package/dist/lib/component/diagram.es.js +1 -1
  87. package/dist/lib/component/diagram.es.js.map +1 -1
  88. package/dist/lib/component/display.es.js +1 -1
  89. package/dist/lib/component/display.es.js.map +1 -1
  90. package/dist/lib/component/editor.es.js +3 -1
  91. package/dist/lib/component/editor.es.js.map +1 -1
  92. package/dist/lib/component/input.es.js +1 -1
  93. package/dist/lib/component/input.es.js.map +1 -1
  94. package/dist/lib/component/list.es.js +1 -1
  95. package/dist/lib/component/list.es.js.map +1 -1
  96. package/dist/lib/component/menubar.es.js +1 -1
  97. package/dist/lib/component/menubar.es.js.map +1 -1
  98. package/dist/lib/component/table.es.js +2 -2
  99. package/dist/lib/component/table.es.js.map +1 -1
  100. package/dist/lib/component/tree.es.js +1 -1
  101. package/dist/lib/component/tree.es.js.map +1 -1
  102. package/dist/lib/core.es.js +1 -1
  103. package/dist/lib/core.es.js.map +1 -1
  104. package/dist/lib/layout.es.js +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 +2 -0
  109. package/dist/lib/router.es.js.map +1 -0
  110. package/dist/lib/types/component/container/SplitGutter.d.ts +1 -1
  111. package/dist/lib/types/component/container/WindowBorder.d.ts +1 -1
  112. package/dist/lib/types/component/display/Markdown.d.ts +10 -0
  113. package/dist/lib/types/component/display/index.d.ts +1 -1
  114. package/dist/lib/types/component/editor/MarkdownEditor.d.ts +6 -0
  115. package/dist/lib/types/component/editor/markdownTableTransformer.d.ts +2 -0
  116. package/dist/lib/types/core/DOM.d.ts +6 -0
  117. package/dist/lib/types/overlay/AbstractWindow.d.ts +1 -1
  118. package/dist/lib/types/router/RoutePattern.d.ts +18 -0
  119. package/dist/lib/types/router/Router.d.ts +36 -0
  120. package/dist/lib/types/router/index.d.ts +2 -0
  121. package/dist/lib/validation.es.js +1 -1
  122. package/llms.txt +8 -4
  123. package/package.json +6 -1
@@ -0,0 +1,2 @@
1
+ import{d as e,f as t}from"./Component-Bs6TvaGZ.js";import{t as n}from"./BoxLayout-8ryMD4j5.js";var HBox=class extends n{_defaultComponentWidth=100;getContentBaseline(){if(this.isStretching())return null;let e=this.getContainer();if(!e)return null;let t=[],n=[];for(let r of e.getLaidOutComponents()){let e=r.getPreferredSize();t.push(e?e.height:0),n.push(r.getBaseline())}return this.computeRowMetrics(t,n).rowAscent}getPreferredSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=e.getLaidOutComponents(),r=t.left+t.right,i=[],a=[];if(this._mode===`equal`){let e=0;for(let t in n){let r=n[t],o=r.getPreferredSize();o&&(e=Math.max(e,o.width),i.push(o.height),a.push(r.getBaseline()))}r+=n.length*(e+this._spacing)-this._spacing}else{for(let e in n){let t=n[e],o=t.getPreferredSize();o&&(r+=o.width,i.push(o.height),a.push(t.getBaseline()))}r+=this._spacing*(n.length-1)}let o=this.computeRowHeight(i,a);return o+=t.top+t.bottom,{width:r,height:o}}getMinSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=e.getLaidOutComponents(),r=t.left+t.right,i=[],a=[];if(this._mode===`equal`){let e=0;for(let t in n){let r=n[t],o=r.getMinSize();o&&(e=Math.max(e,o.width),i.push(o.height),a.push(r.getBaseline()))}r+=n.length*(e+this._spacing)-this._spacing}else{for(let e in n){let t=n[e],o=t.getMinSize();o&&(r+=o.width,i.push(o.height),a.push(t.getBaseline()))}r+=this._spacing*(n.length-1)}let o=this.computeRowHeight(i,a);return o+=t.top+t.bottom,{width:r,height:o}}getMaxSize(){return this.aggregateMaxSize(!0)}computeTotalMinSize(){let e=this.getContainer();if(!e)return{width:0,height:0};let t=e.getLaidOutComponents();if(t.length===0)return{width:0,height:0};let n=0;if(this._mode===`equal`){let e=0;for(let r of t){let t=r.getMinSize();t&&(e=Math.max(e,t.width),n=Math.max(n,t.height))}return{width:t.length*(e+this._spacing)-this._spacing,height:n}}let r=this._spacing*(t.length-1);for(let e of t){let t=e.getMinSize();t&&(r+=t.width,n=Math.max(n,t.height))}return{width:r,height:n}}doLayout(){let e=this.getContainer();if(!e)return;let t=e.getInnerSize();if(!t)return;let n=e.getLaidOutComponents(),r=e.getContentInsets(),i=this.getComponentSpacing(),a=this.inflateForOverflow(t);this._mode===`equal`?this.layoutEqualMode(n,t,a,r,i):this.layoutPreferredMode(n,a,r,i),this.reserveContentFrame()}layoutEqualMode(t,n,r,i,a){let o=this.computeEqualCellWidth(t,n.width,a);if(this.isStretching()){let n=i.getTop(),s=i.getLeft();for(let i of t)this.placeComponent(i,s,n,o,r.height,e.BOTH),s+=o+a;return}let s=[],c=[];for(let e of t){let t=e.getPreferredSize();s.push(t?t.height:0),c.push(e.getBaseline())}let{rowAscent:l,rowDescent:u}=this.computeRowMetrics(s,c),d=i.getTop(),f=r.height,p=i.getLeft();for(let n=0;n<t.length;n+=1){let r=t[n],m=this.crossPlacement(r,d,f,s[n],!0);if(m)this.placeComponent(r,p,m.offset,o,m.extent,e.BOTH);else{let t=this.rowChildY(i.getTop(),s[n],c[n],l,u);this.placeComponent(r,p,t,o,s[n],e.BOTH)}p+=o+a}}computeEqualCellWidth(e,t,n){let r=0,i=0;for(let t of e){let e=t.getMinSize();e&&(r=Math.max(r,e.width));let n=t.getPreferredSize();n&&(i=Math.max(i,n.width))}let a=(t-n*(e.length-1))/e.length;return a>=r?a:this.isOverflowingX()&&this._overflowSizing===`preferred`?Math.max(r,i):r}layoutPreferredMode(t,n,r,i){let{totalWeight:a,fixedPreferred:o,fixedMin:s}=this.measureFixedWidths(t,i),{remaining:c,shrinkRatio:l}=this.computeShrink(o,s,n.width,this.isOverflowingX()),u=[],d=[],f=[];for(let e of t){let t=this.getLayoutConstraints(e)?.weight??0,r=e.getPreferredSize(),i=e.getMinSize(),o=e.getMaxSize();u.push(this.resolveChildWidth(r,i,o,t,a,c,l));let s;s=!r||this.isStretching()?n.height:Math.min(r.height,n.height),o&&(s=Math.min(s,o.height)),d.push(s),f.push(e.getBaseline())}let{rowAscent:p,rowDescent:m}=this.isStretching()?{rowAscent:null,rowDescent:0}:this.computeRowMetrics(d,f),h=0,g=0;if(a===0){let e=i*(t.length-1);for(let t of u)e+=t;let a=n.width-(r.getLeft()+r.getRight());({lead:h,gap:g}=this.justifyOffsets(e,a,t.length))}let _=r.getTop(),v=n.height-(r.getTop()+r.getBottom()),y=r.getLeft()+h;for(let n=0;n<t.length;n+=1){let a=t[n],o=a.getPreferredSize(),s=a.getMaxSize(),c=o?Math.min(o.height,v):v;s&&(c=Math.min(c,s.height));let l=this.crossPlacement(a,_,v,c,!0);if(l)this.placeComponent(a,y,l.offset,u[n],l.extent,e.BOTH);else{let t=this.rowChildY(r.getTop(),d[n],f[n],p,m);this.placeComponent(a,y,t,u[n],d[n],e.BOTH)}y+=u[n],y+=i+g}}measureFixedWidths(e,t){let n=0,r=t*(e.length-1),i=t*(e.length-1);for(let t of e){let e=this.getLayoutConstraints(t)?.weight??0;if(e>0)n+=e;else{let e=t.getPreferredSize(),n=t.getMinSize();r+=this.preferredChildWidth(e,n),i+=n?n.width:0}}return{totalWeight:n,fixedPreferred:r,fixedMin:i}}preferredChildWidth(e,t){let n=(e?e.width:void 0)??(t&&t.width>0?t.width:void 0)??this._defaultComponentWidth;return t?Math.max(n,t.width):n}resolveChildWidth(e,t,n,r,i,a,o){let s;if(r>0&&i>0)s=r/i*a;else{let n=this.preferredChildWidth(e,t);s=n-o*(n-(t?t.width:0))}return t&&(s=Math.max(s,t.width)),n&&(s=Math.min(s,n.width)),s}rowChildY(e,t,n,r,i){return r===null?e:n===null?e+this.nullChildY(t,r,i):e+(r-n)}},r=t(HBox);export{r as t};
2
+ //# sourceMappingURL=HBox-BWMf9h6r.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HBox-BWMf9h6r.js","names":[],"sources":["../../src/typescript/lib/layout/HBox.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { BoxLayout, BoxLayoutOptions } from \"~/layout/BoxLayout.js\";\nimport { FillType } from \"~/layout/FillType.js\";\nimport { Size } from \"~/primitive/Size.js\";\nimport { Insets } from \"~/primitive/Insets.js\";\nimport { Component } from \"~/core/Component.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link HBox}.\n *\n * @remarks `mode` selects the sizing strategy along the horizontal axis.\n * `\"preferred\"` (the default) honours each child's preferred width and\n * supports `weight` cells. `\"equal\"` divides the container width equally\n * and ignores `weight`. `mode` is independent of `stretching` (the cross-axis\n * fill): `stretching` defaults to `false` in both modes, so `\"equal\"` divides\n * the width but leaves children at their preferred height unless\n * `stretching: true` is passed.\n *\n * @category Layouts\n */\nexport interface HBoxOptions extends BoxLayoutOptions {}\n\n/**\n * A layout manager that places children in a single horizontal row. The\n * `mode` option selects between preferred-width sequencing (with weight-cell\n * support) and equal-width division of the container.\n *\n * @category Layouts\n */\nclass HBox extends BoxLayout {\n\n private _defaultComponentWidth: number = 100;\n\n /**\n * Returns the row's baseline (the maximum child text baseline) measured from\n * the container's content-top, so a baseline-aware parent aligns this HBox\n * container by the same baseline its own children align to — rather than\n * auto-centring the whole container.\n *\n * @returns The inner baseline offset in pixels, or `null` while stretching\n * (baseline alignment is disabled) or when no child reports a baseline.\n */\n getContentBaseline(): number | null {\n if (this.isStretching()) {\n return null;\n }\n\n const container = this.getContainer();\n if (!container) {\n return null;\n }\n\n const heights: number[] = [];\n const baselines: Array<number | null> = [];\n\n for (const component of container.getLaidOutComponents()) {\n const size = component.getPreferredSize();\n heights.push(size ? size.height : 0);\n baselines.push(component.getBaseline());\n }\n\n return this.computeRowMetrics(heights, baselines).rowAscent;\n }\n\n /**\n * Returns the preferred size. In `\"preferred\"` mode this is the sum\n * of child widths plus spacing. In `\"equal\"` mode it is\n * `count * (maxChildWidth + spacing) - spacing`. Row height in both\n * modes is the baseline-aware row height of the children.\n *\n * @returns The preferred `{width, height}`, or `null` if no container is attached.\n */\n getPreferredSize(): Size | null {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let perimeterSize = container.getPerimeterSize();\n let components = container.getLaidOutComponents();\n let width = perimeterSize.left + perimeterSize.right;\n\n const heights: number[] = [];\n const baselines: Array<number | null> = [];\n\n if (this._mode === \"equal\") {\n let maxChildWidth = 0;\n\n for (let idx in components) {\n let component = components[idx];\n let size = component.getPreferredSize();\n\n if (size) {\n maxChildWidth = Math.max(maxChildWidth, size.width);\n heights.push(size.height);\n baselines.push(component.getBaseline());\n }\n }\n\n width += components.length * (maxChildWidth + this._spacing) - this._spacing;\n } else {\n for (let idx in components) {\n let component = components[idx];\n let size = component.getPreferredSize();\n\n if (size) {\n width += size.width;\n heights.push(size.height);\n baselines.push(component.getBaseline());\n }\n }\n\n width += this._spacing * (components.length - 1);\n }\n\n let height = this.computeRowHeight(heights, baselines);\n\n height += perimeterSize.top + perimeterSize.bottom;\n\n return {\n width: width,\n height: height\n };\n }\n\n /**\n * Returns the minimum size. In `\"preferred\"` mode this is the sum of\n * child min widths plus spacing. In `\"equal\"` mode it is\n * `count * (maxChildMinWidth + spacing) - spacing`. Row height in\n * both modes is the baseline-aware row height of the children's\n * minimums.\n *\n * @returns The minimum `{width, height}`, or `null` if no container is attached.\n */\n getMinSize(): Size | null {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let perimeterSize = container.getPerimeterSize();\n let components = container.getLaidOutComponents();\n let width = perimeterSize.left + perimeterSize.right;\n\n const heights: number[] = [];\n const baselines: Array<number | null> = [];\n\n if (this._mode === \"equal\") {\n let maxChildMinWidth = 0;\n\n for (let idx in components) {\n let component = components[idx];\n let size = component.getMinSize();\n\n if (size) {\n maxChildMinWidth = Math.max(maxChildMinWidth, size.width);\n heights.push(size.height);\n baselines.push(component.getBaseline());\n }\n }\n\n width += components.length * (maxChildMinWidth + this._spacing) - this._spacing;\n } else {\n for (let idx in components) {\n let component = components[idx];\n let size = component.getMinSize();\n\n if (size) {\n width += size.width;\n heights.push(size.height);\n baselines.push(component.getBaseline());\n }\n }\n\n width += this._spacing * (components.length - 1);\n }\n\n let height = this.computeRowHeight(heights, baselines);\n\n height += perimeterSize.top + perimeterSize.bottom;\n\n return {\n width: width,\n height: height\n };\n }\n\n /**\n * Returns the maximum size the row can usefully occupy. Along the main axis\n * (width) it sums the children's *maximum* widths plus spacing; in `\"equal\"`\n * mode it is `count * maxChildMaxWidth` plus spacing, since every cell shares\n * the widest child's allowance. The cross axis (height) takes the *largest*\n * child maximum — the tallest a child permits the row to grow to. A child\n * whose maximum is `null` or at the unbounded sentinel makes that axis\n * unbounded.\n *\n * @returns The maximum `{width, height}`, or `null` if no container is attached.\n */\n getMaxSize(): Size | null {\n return this.aggregateMaxSize(true);\n }\n\n /**\n * Computes the children's combined minSize along this manager's geometry.\n * In `\"preferred\"` mode width is the sum of per-child `minSize.width`\n * plus spacing. In `\"equal\"` mode width is\n * `count * maxChildMinWidth + spacing*(n-1)` (HBox distributes width\n * equally so the per-cell floor is the max of every child's min width).\n * Height in both modes is the max per-child `minSize.height`. Used by\n * `doLayout` to inflate the working size when the host has opted into\n * `setOverflowing` on the corresponding axis.\n *\n * @returns The total min-size; `{ width: 0, height: 0 }` when the\n * container is absent or has no children.\n */\n protected computeTotalMinSize(): Size {\n const container = this.getContainer();\n if (!container) {\n return { width: 0, height: 0 };\n }\n\n const components = container.getLaidOutComponents();\n if (components.length === 0) {\n return { width: 0, height: 0 };\n }\n\n let height = 0;\n\n if (this._mode === \"equal\") {\n let maxWidth = 0;\n\n for (const component of components) {\n const min = component.getMinSize();\n if (min) {\n maxWidth = Math.max(maxWidth, min.width);\n height = Math.max(height, min.height);\n }\n }\n\n return {\n width: components.length * (maxWidth + this._spacing) - this._spacing,\n height,\n };\n }\n\n let width = this._spacing * (components.length - 1);\n\n for (const component of components) {\n const min = component.getMinSize();\n if (min) {\n width += min.width;\n height = Math.max(height, min.height);\n }\n }\n\n return { width, height };\n }\n\n /**\n * Lays out the children left-to-right, dispatching to `layoutEqualMode` or\n * `layoutPreferredMode` per the sizing mode after inflating the working\n * size for any scroll-enabled axis.\n */\n doLayout(): void {\n const container = this.getContainer();\n if (!container) {\n return;\n }\n\n const innerSize = container.getInnerSize();\n if (!innerSize) {\n return;\n }\n\n const components = container.getLaidOutComponents();\n const containerInsets = container.getContentInsets();\n const spacing = this.getComponentSpacing();\n\n // Universal scroll: when the host has opted into per-axis overflow, lay\n // out against the children's combined minSize so trailing children land\n // past the viewport and the host's CSS `overflow: auto` scrolls.\n // `innerSize` stays the real viewport for equal mode's overflow test.\n const containerSize = this.inflateForOverflow(innerSize);\n\n if (this._mode === \"equal\") {\n this.layoutEqualMode(components, innerSize, containerSize, containerInsets, spacing);\n } else {\n this.layoutPreferredMode(components, containerSize, containerInsets, spacing);\n }\n\n this.reserveContentFrame();\n }\n\n /**\n * Places children in equal-width cells. Every cell takes the same width\n * (see {@link HBox.computeEqualCellWidth}); when stretching, cells fill the\n * container height, otherwise children keep their preferred height and are\n * baseline-aligned within the row.\n *\n * @param components - The children to place, in order.\n * @param innerSize - The host's real inner size (pre-inflation), used to\n * measure the equal share against the true viewport.\n * @param containerSize - The working size, possibly inflated for overflow.\n * @param insets - The container's content insets.\n * @param spacing - Inter-child spacing in pixels.\n */\n private layoutEqualMode(components: Component[], innerSize: Size, containerSize: Size, insets: Insets, spacing: number): void {\n const cellWidth = this.computeEqualCellWidth(components, innerSize.width, spacing);\n\n if (this.isStretching()) {\n const y = insets.getTop();\n let x = insets.getLeft();\n\n for (const component of components) {\n this.placeComponent(component, x, y, cellWidth, containerSize.height, FillType.BOTH);\n\n x += cellWidth + spacing;\n }\n\n return;\n }\n\n const heights: number[] = [];\n const baselines: Array<number | null> = [];\n\n for (const component of components) {\n const size = component.getPreferredSize();\n\n heights.push(size ? size.height : 0);\n baselines.push(component.getBaseline());\n }\n\n const { rowAscent, rowDescent } = this.computeRowMetrics(heights, baselines);\n\n // Match the equal-stretch band exactly: the stretch branch fills\n // containerSize.height from insets.top with no bottom-inset subtraction,\n // so an EAST/fill align-self child reaches the same trailing edge.\n const crossLead = insets.getTop();\n const crossExtent = containerSize.height;\n\n let x = insets.getLeft();\n\n for (let idx = 0; idx < components.length; idx += 1) {\n const component = components[idx];\n\n const cross = this.crossPlacement(component, crossLead, crossExtent, heights[idx], true);\n\n if (cross) {\n this.placeComponent(component, x, cross.offset, cellWidth, cross.extent, FillType.BOTH);\n } else {\n const y = this.rowChildY(insets.getTop(), heights[idx], baselines[idx], rowAscent, rowDescent);\n\n this.placeComponent(component, x, y, cellWidth, heights[idx], FillType.BOTH);\n }\n\n x += cellWidth + spacing;\n }\n }\n\n /**\n * Computes the shared cell width for equal mode: the equal share of the\n * inner width, floored at the widest child's min width.\n *\n * @param components - The children sharing the row.\n * @param innerWidth - The host's real inner width (pre-inflation).\n * @param spacing - Inter-child spacing in pixels.\n * @returns The width every equal-mode cell receives.\n *\n * @remarks Three cases drive the floor: (1) the share clears the widest\n * child's min width → the row fits, divide equally; (2) the share is below\n * the min floor, the host scrolls on this axis, and `overflowSizing` is\n * `\"preferred\"` → every cell takes the widest child's preferred width so\n * cells regain preferred size instead of sticking at min while scrolling;\n * (3) otherwise → clamp to the min floor (a non-scrolling host's\n * `overflow: hidden` clips the surplus).\n */\n private computeEqualCellWidth(components: Component[], innerWidth: number, spacing: number): number {\n let maxChildMinWidth = 0;\n let maxChildPreferredWidth = 0;\n\n for (const component of components) {\n const min = component.getMinSize();\n if (min) {\n maxChildMinWidth = Math.max(maxChildMinWidth, min.width);\n }\n\n const pref = component.getPreferredSize();\n if (pref) {\n maxChildPreferredWidth = Math.max(maxChildPreferredWidth, pref.width);\n }\n }\n\n const equalShare = (innerWidth - spacing * (components.length - 1)) / components.length;\n\n if (equalShare >= maxChildMinWidth) {\n return equalShare;\n }\n\n if (this.isOverflowingX() && this._overflowSizing === \"preferred\") {\n return Math.max(maxChildMinWidth, maxChildPreferredWidth);\n }\n\n return maxChildMinWidth;\n }\n\n /**\n * Places children at their preferred widths. Weight cells split the space\n * left after the non-weighted children; when the row overflows, the\n * non-weighted children shrink proportionally toward their min widths.\n * Children keep their preferred height (or fill the row height when\n * stretching) and are baseline-aligned unless stretching.\n *\n * @param components - The children to place, in order.\n * @param containerSize - The working size, possibly inflated for overflow.\n * @param insets - The container's content insets.\n * @param spacing - Inter-child spacing in pixels.\n */\n private layoutPreferredMode(components: Component[], containerSize: Size, insets: Insets, spacing: number): void {\n const { totalWeight, fixedPreferred, fixedMin } = this.measureFixedWidths(components, spacing);\n\n const { remaining: remainingWidth, shrinkRatio } = this.computeShrink(\n fixedPreferred,\n fixedMin,\n containerSize.width,\n this.isOverflowingX()\n );\n\n const widths: number[] = [];\n const heights: number[] = [];\n const baselines: Array<number | null> = [];\n\n for (const component of components) {\n const weight = this.getLayoutConstraints(component)?.weight ?? 0;\n const size = component.getPreferredSize();\n const minSize = component.getMinSize();\n const maxSize = component.getMaxSize();\n\n widths.push(this.resolveChildWidth(size, minSize, maxSize, weight, totalWeight, remainingWidth, shrinkRatio));\n\n // Cross-axis (height): give the child the row's available height —\n // the full inner height when stretching or sizeless, otherwise its\n // preferred height capped to the row. Cap to the child's maximum, but\n // do NOT floor to its minimum: enforcing the minimum here would\n // dogmatically inflate a child back up to its content size even when\n // the row is shorter, defeating a scrolling/clipping child. The\n // child's own setHeight → clampHeight applies its minimum (its\n // content minimum for a general component, or nothing for a Panel,\n // which fits its allocation and scrolls). When the host opts into\n // vertical scroll, `containerSize` is already inflated to the content\n // extent upstream, so `min(pref, containerSize)` still yields the full\n // height without a floor here.\n let height: number;\n\n if (!size || this.isStretching()) {\n height = containerSize.height;\n } else {\n height = Math.min(size.height, containerSize.height);\n }\n\n if (maxSize) {\n height = Math.min(height, maxSize.height);\n }\n\n heights.push(height);\n\n baselines.push(component.getBaseline());\n }\n\n // Stretching forces every child to fill the row vertically, which makes\n // baseline alignment meaningless — fall back to top-alignment. rowAscent\n // is driven only by text-bearing children; tall null-baseline children\n // (a List, TextArea, etc.) must NOT drag the baseline down or every text\n // label in the row would be pushed off the top.\n const { rowAscent, rowDescent } = this.isStretching()\n ? { rowAscent: null, rowDescent: 0 }\n : this.computeRowMetrics(heights, baselines);\n\n // Sum the placed main extents to find the trailing slack, then ask the\n // shared helper how to distribute it. Weight cells already consume all\n // slack, so justify is a no-op when any are present.\n let lead = 0;\n let gap = 0;\n\n if (totalWeight === 0) {\n let contentWidth = spacing * (components.length - 1);\n\n for (const w of widths) {\n contentWidth += w;\n }\n\n const innerWidth = containerSize.width - (insets.getLeft() + insets.getRight());\n\n ({ lead, gap } = this.justifyOffsets(contentWidth, innerWidth, components.length));\n }\n\n // Cross band for per-child align-self: the same vertical band the\n // stretch path fills, trimmed by both insets.\n const crossLead = insets.getTop();\n const crossExtent = containerSize.height - (insets.getTop() + insets.getBottom());\n\n let x = insets.getLeft() + lead;\n\n for (let idx = 0; idx < components.length; idx += 1) {\n const component = components[idx];\n\n // Align-self sizes from the child's *preferred* height (capped to the\n // band + max), independent of the stretch-inflated heights[idx], so an\n // anchored child shrinks-and-anchors even under global stretching.\n const pref = component.getPreferredSize();\n const maxSize = component.getMaxSize();\n let naturalCross = pref ? Math.min(pref.height, crossExtent) : crossExtent;\n\n if (maxSize) {\n naturalCross = Math.min(naturalCross, maxSize.height);\n }\n\n const cross = this.crossPlacement(component, crossLead, crossExtent, naturalCross, true);\n\n if (cross) {\n this.placeComponent(component, x, cross.offset, widths[idx], cross.extent, FillType.BOTH);\n } else {\n const y = this.rowChildY(insets.getTop(), heights[idx], baselines[idx], rowAscent, rowDescent);\n\n this.placeComponent(component, x, y, widths[idx], heights[idx], FillType.BOTH);\n }\n\n // Advance by the resolved width, not getWidth(): the gap is measured\n // against the same extent contentWidth summed, so a placeComponent\n // clamp must not skew the trailing edge.\n x += widths[idx];\n x += spacing + gap;\n }\n }\n\n /**\n * Sums the non-weighted children's preferred and minimum widths (each\n * including inter-child spacing) and the total weight of the weight cells.\n *\n * @param components - The children sharing the row.\n * @param spacing - Inter-child spacing in pixels.\n * @returns `totalWeight` of the weight cells, plus the `fixedPreferred` and\n * `fixedMin` width totals of the non-weighted children.\n */\n private measureFixedWidths(components: Component[], spacing: number): { totalWeight: number; fixedPreferred: number; fixedMin: number } {\n let totalWeight = 0;\n let fixedPreferred = spacing * (components.length - 1);\n let fixedMin = spacing * (components.length - 1);\n\n for (const component of components) {\n const weight = this.getLayoutConstraints(component)?.weight ?? 0;\n\n if (weight > 0) {\n totalWeight += weight;\n } else {\n const size = component.getPreferredSize();\n const minSize = component.getMinSize();\n\n fixedPreferred += this.preferredChildWidth(size, minSize);\n fixedMin += minSize ? minSize.width : 0;\n }\n }\n\n return { totalWeight, fixedPreferred, fixedMin };\n }\n\n /**\n * Resolves a non-weighted child's preferred width, falling back through min\n * width to `_defaultComponentWidth`.\n *\n * @param size - The child's preferred size, or `null`.\n * @param minSize - The child's minimum size, or `null`.\n * @returns The width the child contributes before shrinking.\n *\n * @remarks Nullish-coalesce, not `||`: a component with an explicit\n * preferred width of 0 (e.g. an empty `Text` label) must contribute 0, not\n * fall through to `_defaultComponentWidth` and inflate the row's fixed total\n * past the container, which would force the shrink path to squeeze every\n * non-weighted child (including glyphs) toward its min size. The\n * `minSize.width > 0` guard prevents `LayoutManager._defaultMinSize =\n * {0,0}` from short-circuiting the chain into a 0 width (which would land a\n * layout-managed Table on width 0 even though no preferred size was set).\n *\n * The result is floored at the child's own min width: a child placed at\n * `max(preferred, min)` (see {@link HBox.resolveChildWidth}) must reserve\n * that same width in the fixed total, or a child reporting `preferred < min`\n * (a `min ≤ preferred` invariant violation) would be under-reserved and push\n * the weighted cells out, overflowing the row.\n */\n private preferredChildWidth(size: Size | null, minSize: Size | null): number {\n const preferred = (size ? size.width : undefined)\n ?? (minSize && minSize.width > 0 ? minSize.width : undefined)\n ?? this._defaultComponentWidth;\n\n return minSize ? Math.max(preferred, minSize.width) : preferred;\n }\n\n /**\n * Resolves a child's final width within the row, clamped to its min/max.\n * Weight cells take a share of `remainingWidth`; non-weighted children take\n * their preferred width reduced by the shrink ratio toward their min width.\n *\n * @param size - The child's preferred size, or `null`.\n * @param minSize - The child's minimum size, or `null`.\n * @param maxSize - The child's maximum size, or `null`.\n * @param weight - The child's weight constraint (0 when non-weighted).\n * @param totalWeight - The summed weight of all weight cells.\n * @param remainingWidth - The space available to weight cells.\n * @param shrinkRatio - How far (0–1) non-weighted children shrink to min.\n * @returns The child's width.\n */\n private resolveChildWidth(size: Size | null, minSize: Size | null, maxSize: Size | null, weight: number, totalWeight: number, remainingWidth: number, shrinkRatio: number): number {\n let width: number;\n\n if (weight > 0 && totalWeight > 0) {\n width = (weight / totalWeight) * remainingWidth;\n } else {\n const pref = this.preferredChildWidth(size, minSize);\n const min = minSize ? minSize.width : 0;\n\n width = pref - shrinkRatio * (pref - min);\n }\n\n if (minSize) {\n width = Math.max(width, minSize.width);\n }\n\n if (maxSize) {\n width = Math.min(width, maxSize.width);\n }\n\n return width;\n }\n\n /**\n * Computes a child's y within the row, aligning text-bearing children on the\n * shared baseline and centring null-baseline children in the text line.\n *\n * @param top - The row's content-top (inside the insets).\n * @param height - The child's height.\n * @param baseline - The child's baseline, or `null` for graphical/replaced children.\n * @param rowAscent - The row's text baseline, or `null` when no child reports one.\n * @param rowDescent - The row's text descent.\n * @returns The child's y position.\n */\n private rowChildY(top: number, height: number, baseline: number | null, rowAscent: number | null, rowDescent: number): number {\n if (rowAscent === null) {\n return top;\n }\n\n if (baseline !== null) {\n return top + (rowAscent - baseline);\n }\n\n return top + this.nullChildY(height, rowAscent, rowDescent);\n }\n}\n\nconst HBoxCallable = callable(HBox);\ntype HBoxCallable = HBox;\nexport {\n HBox as _HBox,\n HBoxCallable as HBox\n};\n"],"mappings":"+FA+BA,IAAM,KAAN,cAAmB,CAAU,CAEzB,uBAAyC,IAWzC,oBAAoC,CAChC,GAAI,KAAK,aAAa,EAClB,OAAO,KAGX,IAAM,EAAY,KAAK,aAAa,EACpC,GAAI,CAAC,EACD,OAAO,KAGX,IAAM,EAAoB,CAAC,EACrB,EAAkC,CAAC,EAEzC,IAAK,IAAM,KAAa,EAAU,qBAAqB,EAAG,CACtD,IAAM,EAAO,EAAU,iBAAiB,EACxC,EAAQ,KAAK,EAAO,EAAK,OAAS,CAAC,EACnC,EAAU,KAAK,EAAU,YAAY,CAAC,CAC1C,CAEA,OAAO,KAAK,kBAAkB,EAAS,CAAS,CAAC,CAAC,SACtD,CAUA,kBAAgC,CAC5B,IAAI,EAAY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import{d as t,f as n,u as r}from"./Component-Bs6TvaGZ.js";import{t as i}from"./Container-CzyZeMyZ.js";import{t as a}from"./Text-DJoUHukb.js";import{t as o}from"./Border-5Ki2DCWz.js";import{t as s}from"./Placement-7kqdaK4Z.js";var c={insets:new e(4,4,4,4)},Header=class extends i{_text;constructor(e,n){super(n,{...c,tag:`header`}),this.setLayoutManager(new o),this._text=new a(e),this._options.fontWeight===void 0&&this._text.setFontWeight(`bold`),this._options.fontSize===void 0&&this._text.setFontSize(`--ts-ui-header-font-size`),this._text.setPointerEvents(`none`),this.addComponent(this._text,{placement:s.WEST,anchor:r.WEST,fill:t.HORIZONTAL}),this.subscribeTheme(()=>{this.updatePreferredSize()}),this._options.preferredSize===void 0&&this.updatePreferredSize(),this._options.text!==void 0&&this._text.setText(this._options.text),this._options.textAlign!==void 0&&this._text.setTextAlign(this._options.textAlign),this._options.textShadow!==void 0&&this._text.setTextShadow(this._options.textShadow),this._options.fontFamily!==void 0&&this._text.setFontFamily(this._options.fontFamily),this._options.fontSize!==void 0&&this._text.setFontSize(this._options.fontSize),this._options.fontWeight!==void 0&&this._text.setFontWeight(this._options.fontWeight),this._options.fontStyle!==void 0&&this._text.setFontStyle(this._options.fontStyle),this._options.fontVariant!==void 0&&this._text.setFontVariant(this._options.fontVariant),this._options.fontStretch!==void 0&&this._text.setFontStretch(this._options.fontStretch),this._options.fontKerning!==void 0&&this._text.setFontKerning(this._options.fontKerning),this._options.fontSizeAdjust!==void 0&&this._text.setFontSizeAdjust(this._options.fontSizeAdjust),this._options.lineHeight!==void 0&&this._text.setLineHeight(this._options.lineHeight),this._options.textOverflow!==void 0&&this._text.setTextOverflow(this._options.textOverflow)}applyOptions(e){return super.applyOptions(e),e.text!==void 0&&(this._options.text=e.text),e.textAlign!==void 0&&(this._options.textAlign=e.textAlign),e.textShadow!==void 0&&(this._options.textShadow=e.textShadow),e.fontFamily!==void 0&&(this._options.fontFamily=e.fontFamily),e.fontSize!==void 0&&(this._options.fontSize=e.fontSize),e.fontWeight!==void 0&&(this._options.fontWeight=e.fontWeight),e.fontStyle!==void 0&&(this._options.fontStyle=e.fontStyle),e.fontVariant!==void 0&&(this._options.fontVariant=e.fontVariant),e.fontStretch!==void 0&&(this._options.fontStretch=e.fontStretch),e.fontKerning!==void 0&&(this._options.fontKerning=e.fontKerning),e.fontSizeAdjust!==void 0&&(this._options.fontSizeAdjust=e.fontSizeAdjust),e.lineHeight!==void 0&&(this._options.lineHeight=e.lineHeight),e.textOverflow!==void 0&&(this._options.textOverflow=e.textOverflow),this}updatePreferredSize(){let e=this._text.getPreferredSize(),t=this.getInsets(),n=(e?e.height:20)+t.getTop()+t.getBottom();this.setPreferredSize(100,n)}getText(){return this._text}getBaseline(){return this.wrapInnerBaseline(this._text.getBaseline())}},l=n(Header);export{l as t};
2
+ //# sourceMappingURL=Header-CQjomjo0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Header-CQjomjo0.js","names":[],"sources":["../../src/typescript/lib/component/display/Header.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Border as BorderLayout } from \"~/layout/Border.js\";\nimport { Text, TextOptions } from \"~/component/input/Text.js\";\nimport { Insets } from \"~/primitive/Insets.js\";\nimport { AnchorType } from \"~/layout/AnchorType.js\";\nimport { FillType } from \"~/layout/FillType.js\";\nimport { Placement } from \"~/primitive/Placement.js\";\nimport { Container } from \"~/core/Container.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link Header}. Text and font fields target\n * the inner header label, not the header bar itself.\n *\n * @category Components\n */\nexport interface HeaderOptions extends TextOptions {\n}\n\n/**\n * User-overridable defaults forwarded to `super` via the options bag. The\n * cascade in `Container`/`Component` dispatches each present setter once with the\n * final value. Font fields are handled in the constructor body once the inner\n * `text` child exists — they're written into `_options` by `applyOptions` and\n * dispatched from there.\n */\nconst _defaultHeaderOptions: Partial<HeaderOptions> = {\n // Static content padding around the header label — the single source of the\n // bar's padding (WindowHeader subclasses Header without passing its own\n // insets). 4px matches the spacing headers carried implicitly from Panel\n // before the Container reparent; it is not theme-derived, so headers do not\n // reflow their padding on a theme change.\n insets: new Insets(4, 4, 4, 4),\n};\n\n/**\n * A header bar component containing a left-aligned text label.\n *\n * Renders a `<header>` element with a Border layout manager and a bold label\n * anchored to the west side.\n *\n * @category Components\n */\nclass Header<TOptions extends HeaderOptions = HeaderOptions> extends Container<TOptions> {\n\n private _text!: Text;\n\n constructor(text: string, options?: TOptions) {\n super(\n options,\n { ..._defaultHeaderOptions, tag: \"header\" } as Partial<TOptions>,\n );\n\n this.setLayoutManager(new BorderLayout());\n\n // Build the inner text label. Font defaults are applied here when the\n // caller didn't supply an override — the cascade can't reach `this.text`\n // because it doesn't exist yet during `super`.\n this._text = new Text(text);\n if (this._options.fontWeight === undefined) {\n this._text.setFontWeight(\"bold\");\n }\n if (this._options.fontSize === undefined) {\n this._text.setFontSize(\"--ts-ui-header-font-size\");\n }\n this._text.setPointerEvents(\"none\");\n\n this.addComponent(this._text, {\n placement: Placement.WEST,\n anchor: AnchorType.WEST,\n fill: FillType.HORIZONTAL\n });\n\n // Recompute the preferred height on theme change: the header font size\n // is theme-bound, so a theme swap can change the label's measured height.\n // The insets are static (see `_defaultHeaderOptions`), so padding is not\n // re-derived here.\n this.subscribeTheme(() => {\n this.updatePreferredSize();\n });\n\n if (this._options.preferredSize === undefined) {\n this.updatePreferredSize();\n }\n\n // Late-built state: font/text fields written pure into `_options` by\n // the super-time cascade. Dispatch them now that `this.text` exists.\n if (this._options.text !== undefined) {\n this._text.setText(this._options.text);\n }\n if (this._options.textAlign !== undefined) {\n this._text.setTextAlign(this._options.textAlign);\n }\n if (this._options.textShadow !== undefined) {\n this._text.setTextShadow(this._options.textShadow);\n }\n if (this._options.fontFamily !== undefined) {\n this._text.setFontFamily(this._options.fontFamily);\n }\n if (this._options.fontSize !== undefined) {\n this._text.setFontSize(this._options.fontSize);\n }\n if (this._options.fontWeight !== undefined) {\n this._text.setFontWeight(this._options.fontWeight);\n }\n if (this._options.fontStyle !== undefined) {\n this._text.setFontStyle(this._options.fontStyle);\n }\n if (this._options.fontVariant !== undefined) {\n this._text.setFontVariant(this._options.fontVariant);\n }\n if (this._options.fontStretch !== undefined) {\n this._text.setFontStretch(this._options.fontStretch);\n }\n if (this._options.fontKerning !== undefined) {\n this._text.setFontKerning(this._options.fontKerning);\n }\n if (this._options.fontSizeAdjust !== undefined) {\n this._text.setFontSizeAdjust(this._options.fontSizeAdjust);\n }\n if (this._options.lineHeight !== undefined) {\n this._text.setLineHeight(this._options.lineHeight);\n }\n if (this._options.textOverflow !== undefined) {\n this._text.setTextOverflow(this._options.textOverflow);\n }\n }\n\n /**\n * Applies a {@link HeaderOptions} bag. Inherited Container/Component fields\n * cascade through `super.applyOptions`; text-targeting fields are written\n * pure into `_options` here and dispatched from the constructor body once\n * `this.text` exists.\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 if (options.text !== undefined) this._options.text = options.text;\n if (options.textAlign !== undefined) this._options.textAlign = options.textAlign;\n if (options.textShadow !== undefined) this._options.textShadow = options.textShadow;\n if (options.fontFamily !== undefined) this._options.fontFamily = options.fontFamily;\n if (options.fontSize !== undefined) this._options.fontSize = options.fontSize;\n if (options.fontWeight !== undefined) this._options.fontWeight = options.fontWeight;\n if (options.fontStyle !== undefined) this._options.fontStyle = options.fontStyle;\n if (options.fontVariant !== undefined) this._options.fontVariant = options.fontVariant;\n if (options.fontStretch !== undefined) this._options.fontStretch = options.fontStretch;\n if (options.fontKerning !== undefined) this._options.fontKerning = options.fontKerning;\n if (options.fontSizeAdjust !== undefined) this._options.fontSizeAdjust = options.fontSizeAdjust;\n if (options.lineHeight !== undefined) this._options.lineHeight = options.lineHeight;\n if (options.textOverflow !== undefined) this._options.textOverflow = options.textOverflow;\n\n return this;\n }\n\n /**\n * Recalculates the preferred height from the text component's measured preferred size.\n *\n * Called at construction time and after each theme change so that font-size\n * adjustments propagate to the header's layout hint automatically. `protected`\n * so a subclass can override the derivation — `WindowHeader` substitutes a\n * chrome-band thickness so its stretched controls fill the bar.\n */\n protected updatePreferredSize(): void {\n const textSize = this._text.getPreferredSize();\n const insets = this.getInsets();\n const textHeight = textSize ? textSize.height : 20;\n const preferredHeight = textHeight\n + insets.getTop()\n + insets.getBottom();\n\n this.setPreferredSize(100, preferredHeight);\n }\n\n /**\n * Returns the Text child used to display the header text.\n *\n * @returns The internal Text instance.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the offset from the top of the header to the label's text baseline.\n *\n * @returns The baseline offset in pixels, or `null` when the label has no baseline.\n */\n getBaseline(): number | null {\n return this.wrapInnerBaseline(this._text.getBaseline());\n }\n}\n\nconst HeaderCallable = callable(Header);\ntype HeaderCallable<TOptions extends HeaderOptions = HeaderOptions> = Header<TOptions>;\nexport {\n Header as _Header,\n HeaderCallable as Header\n};\n"],"mappings":"6QA2BA,IAAM,EAAgD,CAMlD,OAAQ,IAAI,EAAO,EAAG,EAAG,EAAG,CAAC,CACjC,EAUM,OAAN,cAAqE,CAAoB,CAErF,MAEA,YAAY,EAAc,EAAoB,CAC1C,MACI,EACA,CAAE,GAAG,EAAuB,IAAK,QAAS,CAC9C,EAEA,KAAK,iBAAiB,IAAI,CAAc,EAKxC,KAAK,MAAQ,IAAI,EAAK,CAAI,EACtB,KAAK,SAAS,aAAe,IAAA,IAC7B,KAAK,MAAM,cAAc,MAAM,EAE/B,KAAK,SAAS,WAAa,IAAA,IAC3B,KAAK,MAAM,YAAY,0BAA0B,EAErD,KAAK,MAAM,iBAAiB,MAAM,EAElC,KAAK,aAAa,KAAK,MAAO,CAC1B,UAAW,EAAU,KACrB,OAAQ,EAAW,KACnB,KAAM,EAAS,UACnB,CAAC,EAMD,KAAK,mBAAqB,CACtB,KAAK,oBAAoB,CAC7B,CAAC,EAEG,KAAK,SAAS,gBAAkB,IAAA,IAChC,KAAK,oBAAoB,EAKzB,KAAK,SAA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,KAAW,KAAK,SAAS,WAAiB,EAAQ,YAC7E,EAAQ,WAAmB,IAAA,KAAW,KAAK,SAAS,SAAiB,EAAQ,UAC7E,EAAQ,aAAmB,IAAA,KAAW,KAAK,SAAS,WAAiB,EAAQ,YAC7E,EAAQ,YAAmB,IAAA,KAAW,KAAK,SAAS,UAAiB,EAAQ,WAC7E,EAAQ,cAAmB,IAAA,KAAW,KAAK,SAAS,YAAiB,EAAQ,aAC7E,EAAQ,cAAmB,IAAA,KAAW,KAAK,SAAS,YAAiB,EAAQ,aAC7E,EAAQ,cAAmB,IAAA,KAAW,KAAK,SAAS,YAAiB,EAAQ,aAC7E,EAAQ,iBAAmB,IAAA,KAAW,KAAK,SAAS,eAAiB,EAAQ,gBAC7E,EAAQ,aAAmB,IAAA,KAAW,KAAK,SAAS,WAAiB,EAAQ,YAC7E,EAAQ,eAAmB,IAAA,KAAW,KAAK,SAAS,aAAiB,EAAQ,cAE1E,IACX,CAUA,qBAAsC,CAClC,IAAM,EAAW,KAAK,MAAM,iBAAiB,EACvC,EAAS,KAAK,UAAU,EAExB,GADa,EAAW,EAAS,OAAS,IAElB,EAAO,OAAO,EACd,EAAO,UAAU,EAE/C,KAAK,iBAAiB,IAAK,CAAe,CAC9C,CAOA,SAAU,CACN,OAAO,KAAK,KAChB,CAOA,aAA6B,CACzB,OAAO,KAAK,kBAAkB,KAAK,MAAM,YAAY,CAAC,CAC1D,CACJ,EAEM,EAAiB,EAAS,MAAM"}
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./Position-DJKB0N3l.js";import{f as t,t as n}from"./Component-Bs6TvaGZ.js";import{t as r}from"./Glyph-6Ki3A1_a.js";import{t as i}from"./Text-DJoUHukb.js";import{t as a}from"./HBox-BWMf9h6r.js";var o={gap:2,insets:new e(0,0,0,0)},IconText=class extends n{_glyph;_text;constructor(e,t,n){super(n,{...o,layoutManager:new a}),this._glyph=new r(e),this._text=new i(t),this.addComponent(this._glyph),this.addComponent(this._text),this.getLayoutManager().setComponentSpacing(this.getGap()),this._options.glyph!==void 0&&this.setGlyph(this._options.glyph),this._options.text!==void 0&&this.setText(this._options.text)}applyOptions(e){return super.applyOptions(e),e.gap!==void 0&&(this._options.gap=e.gap),e.glyph!==void 0&&(this._options.glyph=e.glyph),e.text!==void 0&&(this._options.text=e.text),this}setGlyph(e){return this.removeComponent(this._glyph),this._glyph=new r(e),this.insertComponent(this._glyph,0),this}setText(e){return this._text.setText(e),this}setGap(e){return this._options.gap=e,this.getLayoutManager().setComponentSpacing(e),this}getGap(){return this._options.gap??this._defaultOptions.gap}getGlyphComponent(){return this._glyph}getTextComponent(){return this._text}},s=t(IconText);export{s as t};
2
+ //# sourceMappingURL=IconText-BXJK0MOq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconText-BXJK0MOq.js","names":[],"sources":["../../src/typescript/lib/component/display/IconText.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { HBox } from \"~/layout/HBox.js\";\nimport { Insets } from \"~/primitive/Insets.js\";\nimport { Text } from \"~/component/input/Text.js\";\nimport { Glyph } from \"~/component/display/Glyph.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link IconText}.\n *\n * @category Components\n */\nexport interface IconTextOptions extends ComponentOptions {\n glyph?: string;\n text?: string;\n gap?: number;\n}\n\n/**\n * User-overridable defaults forwarded to `super` via the options bag. The\n * cascade dispatches each present setter once with the final value. `gap`\n * is included even though its setter touches `getLayoutManager()`: it is\n * pure-bag-written by `applyOptions` and dispatched after the HBox is built.\n * `layoutManager` is *not* listed because each instance needs its own fresh\n * HBox — sharing one instance across components would corrupt layout state.\n */\nconst _defaultIconTextOptions: Partial<IconTextOptions> = {\n gap: 2,\n insets: new Insets(0, 0, 0, 0),\n};\n\n/**\n * A small composite pairing a leading [`Glyph`](/api/component/display/classes/Glyph)\n * with a trailing standalone [`Text`](/api/component/input/classes/Text), laid out\n * horizontally with a configurable gap (default 2).\n *\n * For form-control labels that need to be associated with an input element, use\n * [`IconLabel`](/api/component/display/classes/IconLabel) instead — its trailing\n * text is a real `<label for=\"…\">`.\n *\n * @example\n * ```typescript\n * import { IconText } from '@jimka/typescript-ui/component/display';\n *\n * panel.addComponent(new IconText('times', 'Close'));\n * ```\n *\n * @category Components\n */\nclass IconText extends Component<IconTextOptions> {\n\n private _glyph!: Glyph;\n private _text!: Text;\n\n /**\n * Constructs an `IconText` pairing the named glyph with the given label text.\n *\n * @param glyph - Registry glyph name. Must be present in the internal `Glyphs` registry.\n * @param text - Label text shown to the right of the glyph.\n * @param options - Optional configuration bag (gap override, common Component fields).\n */\n constructor(glyph: string, text: string, options?: IconTextOptions) {\n // The HBox sits in the defaults bag (under user options) so a caller\n // that wants a different layoutManager can still override it.\n super(options, {\n ..._defaultIconTextOptions,\n layoutManager: new HBox(),\n });\n\n this._glyph = new Glyph(glyph);\n this._text = new Text(text);\n\n this.addComponent(this._glyph);\n this.addComponent(this._text);\n\n // Late-built state: `gap` and `glyph`/`text` setters reach into\n // children that didn't exist during `super`'s cascade. Dispatch from\n // `_options` now that the row is built. `gap` always applies its\n // effective value (caller override, else the class default) since the\n // HBox is seeded without spacing.\n (this.getLayoutManager() as HBox).setComponentSpacing(this.getGap());\n if (this._options.glyph !== undefined) {\n this.setGlyph(this._options.glyph);\n }\n if (this._options.text !== undefined) {\n this.setText(this._options.text);\n }\n }\n\n /**\n * Applies an {@link IconTextOptions} bag. Inherited Component fields cascade\n * through `super.applyOptions`; the gap/glyph/text fields are written pure\n * to `_options` here and dispatched from the constructor body once children\n * exist.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: IconTextOptions): this {\n super.applyOptions(options);\n\n if (options.gap !== undefined) this._options.gap = options.gap;\n if (options.glyph !== undefined) this._options.glyph = options.glyph;\n if (options.text !== undefined) this._options.text = options.text;\n\n return this;\n }\n\n /**\n * Replaces the leading glyph with a fresh instance for the given registry name.\n *\n * @param name - Registry glyph name. Must be present in the internal registry.\n *\n * @returns This component, for method chaining.\n */\n setGlyph(name: string): this {\n this.removeComponent(this._glyph);\n\n this._glyph = new Glyph(name);\n this.insertComponent(this._glyph, 0);\n\n return this;\n }\n\n /**\n * Updates the trailing label text.\n *\n * @param text - The new label string.\n *\n * @returns This component, for method chaining.\n */\n setText(text: string): this {\n this._text.setText(text);\n\n return this;\n }\n\n /**\n * Sets the pixel gap between the glyph and the text.\n *\n * @param px - Gap in pixels.\n *\n * @returns This component, for method chaining.\n */\n setGap(px: number): this {\n this._options.gap = px;\n (this.getLayoutManager() as HBox).setComponentSpacing(px);\n\n return this;\n }\n\n /**\n * Returns the effective gap between the glyph and the text — the\n * caller/setter value, else the class default (2).\n *\n * @returns The gap in pixels.\n */\n getGap(): number {\n return (this._options.gap ?? this._defaultOptions.gap)!;\n }\n\n /**\n * Returns the leading glyph component.\n *\n * @returns The [`Glyph`](/api/component/display/classes/Glyph) instance.\n */\n getGlyphComponent(): Glyph {\n return this._glyph;\n }\n\n /**\n * Returns the trailing text component.\n *\n * @returns The [`Text`](/api/component/input/classes/Text) instance.\n */\n getTextComponent(): Text {\n return this._text;\n }\n}\n\nconst IconTextCallable = callable(IconText);\ntype IconTextCallable = IconText;\nexport {\n IconText as _IconText,\n IconTextCallable as IconText\n};\n"],"mappings":"oNA4BA,IAAM,EAAoD,CACtD,IAAQ,EACR,OAAQ,IAAI,EAAO,EAAG,EAAG,EAAG,CAAC,CACjC,EAoBM,SAAN,cAAuB,CAA2B,CAE9C,OACA,MASA,YAAY,EAAe,EAAc,EAA2B,CAGhE,MAAM,EAAS,CACX,GAAG,EACH,cAAe,IAAI,CACvB,CAAC,EAED,KAAK,OAAS,IAAI,EAAM,CAAK,EAC7B,KAAK,MAAS,IAAI,EAAK,CAAI,EAE3B,KAAK,aAAa,KAAK,MAAM,EAC7B,KAAK,aAAa,KAAK,KAAK,EAO5B,KAAM,iBAAiB,CAAC,CAAU,oBAAoB,KAAK,OAAO,CAAC,EAC/D,KAAK,SAAS,QAAU,IAAA,IACxB,KAAK,SAAS,KAAK,SAAS,KAAK,EAEjC,KAAK,SAAS,OAAS,IAAA,IACvB,KAAK,QAAQ,KAAK,SAAS,IAAI,CAEvC,CAUA,aAAuB,EAAgC,CAOnD,OANA,MAAM,aAAa,CAAO,EAEtB,EAAQ,MAAU,IAAA,KAAW,KAAK,SAAS,IAAQ,EAAQ,KAC3D,EAAQ,QAAU,IAAA,KAAW,KAAK,SAAS,MAAQ,EAAQ,OAC3D,EAAQ,OAAU,IAAA,KAAW,KAAK,SAAS,KAAQ,EAAQ,MAExD,IACX,CASA,SAAS,EAAoB,CAMzB,OALA,KAAK,gBAAgB,KAAK,MAAM,EAEhC,KAAK,OAAS,IAAI,EAAM,CAAI,EAC5B,KAAK,gBAAgB,KAAK,OAAQ,CAAC,EAE5B,IACX,CASA,QAAQ,EAAoB,CAGxB,OAFA,KAAK,MAAM,QAAQ,CAAI,EAEhB,IACX,CASA,OAAO,EAAkB,CAIrB,MAHA,MAAK,SAAS,IAAM,EACpB,KAAM,iBAAiB,CAAC,CAAU,oBAAoB,CAAE,EAEjD,IACX,CAQA,QAAiB,CACb,OAAQ,KAAK,SAAS,KAAO,KAAK,gBAAgB,GACtD,CAOA,mBAA2B,CACvB,OAAO,KAAK,MAChB,CAOA,kBAAyB,CACrB,OAAO,KAAK,KAChB,CACJ,EAEM,EAAmB,EAAS,QAAQ"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./DOM-DeF_dWe2.js";import{a as t,l as n,t as r}from"./Position-DJKB0N3l.js";import{d as i,f as a,l as o,t as s}from"./Component-Bs6TvaGZ.js";import{t as c}from"./ListenerBag-WPdKuuds.js";import{t as l}from"./Container-CzyZeMyZ.js";import{a as u}from"./Tooltip-5BR7yYEX.js";import{d,i as f,l as p,n as m,o as h,r as g,t as _}from"./LayoutSizes-XdhpAOmc.js";import{i as v,n as y}from"./Border-5Ki2DCWz.js";import{t as b}from"./LayoutConstraints-CHI2lhPd.js";import{n as x,r as S,t as C}from"./DragManager-c6M_mE3e.js";var w=4,T=1,Split=class extends o{_orientation=`horizontal`;_sizes=new Map;_gutters=[];_collapsed=new Map;_weights=new Map;_pendingCollapsed=[];_listeners=new c;_pendingSizes=null;_dragOriginPointer=0;_dragOriginLhsSize=0;_dragOriginRhsSize=0;_lastAvailableMain=0;_collapseAnimation=null;constructor(e){super(),e&&this.applyOptions(e)}applyOptions(e){if(super.applyOptions(e),e.orientation!==void 0&&this.setOrientation(e.orientation),e.collapsedPanes!==void 0&&(this._pendingCollapsed=[...e.collapsedPanes]),e.paneSizes!==void 0&&(this._pendingSizes=e.paneSizes.map(e=>({...e}))),e.listeners!==void 0){let t=e.listeners;for(let e of Object.keys(t)){let n=t[e];n!==void 0&&this.on(e,n)}}}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,...t){this._listeners.fire(e,...t)}isPaneCollapsed(e){let t=this.getContainer();if(!t)return!1;let n=t.getLaidOutComponents()[e];return n?this._collapsed.get(n)??!1:!1}collapsesTowardStart(e){return e===`west`||e===`north`}paneDirection(e){return this.getLayoutConstraints(e)?.collapseDirection??(this._orientation===`horizontal`?`west`:`north`)}paneCollapsible(e){return this.getLayoutConstraints(e)?.collapsible!==!1}gutterTargetPane(e,t){let n=t[e+1];if(n&&this.paneCollapsible(n)&&!this.collapsesTowardStart(this.paneDirection(n)))return e+1;let r=t[e];return r&&this.paneCollapsible(r)&&this.collapsesTowardStart(this.paneDirection(r))?e:-1}paneServingGutter(e,t){let n=this.paneDirection(t[e]);return this.collapsesTowardStart(n)?e<t.length-1&&this.gutterTargetPane(e,t)===e?e:-1:e>0&&this.gutterTargetPane(e-1,t)===e?e-1:-1}setPaneCollapsed(e,t){let n=this.getContainer();if(!n)return this;let r=n.getLaidOutComponents(),i=r[e];if(!i||this.paneServingGutter(e,r)<0||(this._collapsed.get(i)??!1)===t)return this;this._collapsed.set(i,t),this.emit(`panecollapse`,e,t);let a=[...r.map(e=>({component:e,relayout:!0})),...this._gutters.map(e=>({component:e,relayout:!1}))];return this._collapseAnimation=v(n,i,a,this._collapseAnimation,()=>{this._collapseAnimation=null}),this}getOrientation(){return this._orientation}setOrientation(e){return this._orientation=e,this}setPaneSize(e,t){return this._sizes.set(e,t),this}getPaneSize(e){return this._sizes.get(e)}setPaneResizeWeight(e,t){return this._weights.set(e,t),this}getPaneResizeWeight(e){return this._weights.get(e)}effectiveResizeWeight(e,t){return this._weights.get(e)??this.getLayoutConstraints(e)?.weight??t}clampMain(e,t,r){let i=e.getMinSize(),a=e.getMaxSize(),o=i?r?i.width:i.height:0,s=a?r?a.width:a.height:1/0;return n.clamp(t,o,s)}isPinnedMain(e,t){let n=e.getMinSize(),r=e.getMaxSize();return(n?t?n.width:n.height:0)===(r?t?r.width:r.height:1/0)}isResizePinnedMain(e){return this.effectiveResizeWeight(e,T)===0}seedFromPreferred(e,t){for(let n of e){if(this._sizes.has(n))continue;let e=n.getPreferredSizeConstraint();if(!e)continue;let r=t?e.width:e.height;this._sizes.set(n,this.clampMain(n,r,t))}}transferPaneSize(e,t){let n=this._sizes.get(e);if(n===void 0)return this;this._sizes.set(t,n),this._sizes.delete(e);let r=this._collapsed.get(e);r!==void 0&&(this._collapsed.set(t,r),this._collapsed.delete(e));let i=this._weights.get(e);return i!==void 0&&(this._weights.set(t,i),this._weights.delete(e)),this}getPaneRatios(){let e=this.getContainer();if(!e)return[];let t=e.getComponents();return t.length===0?[]:g(t.map(e=>this._sizes.get(e)??0),t.length)}getPreferredSize(){return this.computeContentSize(e=>e.getPreferredSize())}getMinSize(){return this.computeContentSize(e=>e.getMinSize())}getMaxSize(){return{width:t,height:t}}computeContentSize(e){let t=this.getContainer();if(!t)return null;let n=t.getLaidOutComponents(),r=t.getPerimeterSize(),i=this._orientation===`horizontal`,a=0,o=0;for(let t=0;t<n.length;t+=1){let r=e(n[t]);r&&(a+=i?r.width:r.height,o=Math.max(o,i?r.height:r.width))}return a+=this.gutterTotal(n.length),i?{width:a+r.left+r.right,height:o+r.top+r.bottom}:{width:o+r.left+r.right,height:a+r.top+r.bottom}}applyPaneRatios(e){let t=this.getContainer();if(!t)return this;let n=t.getComponents(),r=n.length;if(r===0)return this;let i=g(e,r),a=t.getInnerSize(),o=a?this._orientation===`horizontal`?a.width:a.height:0,s=Math.max(0,o-this.gutterTotal(r)),c=s>0?s:1;return n.forEach((e,t)=>{this._sizes.set(e,i[t]*c)}),this._lastAvailableMain=c,t.scheduleLayout(),this}paneSizeUnits(e){return e.map(e=>this.isResizePinnedMain(e)?`px`:`ratio`)}getPaneSizes(){let e=this.getContainer();if(!e)return[];let t=e.getComponents();if(t.length===0)return[];let n=this.paneSizeUnits(t);return this._pendingSizes!==null&&m(this._pendingSizes,n)?this._pendingSizes.map(e=>({...e})):f(n,t.map(e=>this._sizes.get(e)??0))}applyPaneSizes(e){let t=this.getContainer();if(!t)return this;let n=t.getComponents();if(!m(e,this.paneSizeUnits(n)))return this;let r=t.getInnerSize(),i=r?this._orientation===`horizontal`?r.width:r.height:0,a=Math.max(0,i-this.gutterTotal(n.length)),o=_(e,a);return n.forEach((e,t)=>this.setPaneSize(e,o[t])),this._lastAvailableMain=a>0?a:1,t.scheduleLayout(),this}setPaneCollapsedImmediate(e,t){let n=this.getContainer();if(!n)return this;let r=n.getLaidOutComponents(),i=r[e];return!i||t&&this.paneServingGutter(e,r)<0?this:(this._collapsed.set(i,t),this.emit(`panecollapse`,e,t),n.scheduleLayout(),this)}onDragStart(e,t,n){let r=this._gutters.indexOf(t),i=e.getLaidOutComponents()[r],a=e.getLaidOutComponents()[r+1];this._dragOriginPointer=n,this._orientation===`horizontal`?(this._dragOriginLhsSize=i.getWidth(),this._dragOriginRhsSize=a.getWidth()):(this._dragOriginLhsSize=i.getHeight(),this._dragOriginRhsSize=a.getHeight())}onDrag(e,t,n){let r=this._gutters.indexOf(t),i=e.getLaidOutComponents()[r],a=e.getLaidOutComponents()[r+1],o=this._orientation===`horizontal`,s=this._dragOriginLhsSize+this._dragOriginRhsSize,c=i.getMinSize(),l=a.getMinSize(),u=i.getMaxSize(),d=a.getMaxSize(),f=c?o?c.width:c.height:0,p=l?o?l.width:l.height:0,m=u?o?u.width:u.height:1/0,h=d?o?d.width:d.height:1/0,g=n-this._dragOriginPointer,_=Math.max(f,s-h),v=Math.min(m,s-p),y=this._dragOriginLhsSize+g;y=Math.max(_,Math.min(v,y));let b=s-y,x=y-(o?i.getWidth():i.getHeight());o?(i.setWidth(y),t.setX(t.getX()+x),a.setX(a.getX()+x),a.setWidth(b)):(i.setHeight(y),t.setY(t.getY()+x),a.setY(a.getY()+x),a.setHeight(b)),this._sizes.set(i,y),this._sizes.set(a,b),i.doLayout(),a.doLayout()}onDragEnd(){this.emit(`paneresize`,this.getPaneSizes())}detach(){super.detach();for(let t of this._gutters){let n=t.getElement();e.sink.removeChild(e.source.getParentNode(n),n),t.destroy()}return this._gutters=[],this}gutterTotal(e){return Math.max(0,e-1)*w}computeTotalMinSize(){let e=this.getContainer();if(!e)return{width:0,height:0};let t=e.getLaidOutComponents();if(t.length===0)return{width:0,height:0};let n=t.length-1,r=0,i=0;for(let e=0;e<t.length;e+=1){let a=t[e],o=this._sizes.get(a),s=this._collapsed.get(a)??!1,c=e<n;if(s&&c)r+=18;else{if(!s)if(o!=null)r+=o;else{let e=a.getMinSize();e&&(r+=this._orientation===`horizontal`?e.width:e.height)}c&&(r+=w)}let l=a.getMinSize();l&&(i=Math.max(i,this._orientation===`horizontal`?l.height:l.width))}return this._orientation===`horizontal`?{width:r,height:i}:{width:i,height:r}}doLayout(){let t=this,n=this.getContainer();if(!n)return;let r=n.getInnerSize();if(!r)return;let a=this._orientation===`horizontal`?r.width:r.height;r=this.inflateForOverflow(r);let o=n.getElement(),s=n.getLaidOutComponents(),c=n.getContentInsets(),l=s.length-1;for(let r=this._gutters.length;r<l;r+=1){let i=new y(this._orientation,{expandedBackground:`transparent`}),a=r;i.on(`dragstart`,function(e){t.onDragStart(n,i,e)}),i.on(`drag`,function(e){t.onDrag(n,i,e)}),i.on(`dragend`,()=>this.onDragEnd()),i.on(`collapse`,function(){let e=t.gutterTargetPane(a,n.getLaidOutComponents());e>=0&&t.setPaneCollapsed(e,!t.isPaneCollapsed(e))}),this._gutters.push(i),e.sink.appendChild(o,i.getElement(!0))}let u=c.getLeft(),d=c.getTop();this.recalculateSizes(),this.applyPendingSizes(),this.applyPendingCollapsed(s);let f=this._orientation===`horizontal`,p=f?r.height:r.width,m=this.computeMainAxisSizes(s,a),h=new Set;for(let e=0;e<s.length;e+=1){let t=s[e],n=this.paneServingGutter(e,s);if((this._collapsed.get(t)??!1)&&n>=0){let e=this._gutters[n];e.setCollapseDirection(this.paneDirection(t)),e.setCollapsible(!0),this.placeGutterAsStrip(e,t,u,d,p,f,this.paneDirection(t)),h.add(n),f?u+=18:d+=18;continue}let r=m.get(t);if(t.setVisible(!0),this.placeComponent(t,u,d,f?r:p,f?p:r,i.BOTH),t.setClipPath(n>=0?`inset(0 0 0 0)`:null),f?u+=r:d+=r,e<l){let t=this._gutters[e],n=this.gutterTargetPane(e,s);!(n>=0&&(this._collapsed.get(s[n])??!1)&&this.paneServingGutter(n,s)===e)&&!h.has(e)&&(t.setOpaque(!1),t.setVisible(!0),t.setCollapsible(n>=0),n>=0&&t.setCollapseDirection(this.paneDirection(s[n])),t.setX(u),t.setY(d),f?(t.setWidth(w),t.setHeight(p),u+=w):(t.setWidth(p),t.setHeight(w),d+=w),h.add(e))}}for(let e=0;e<this._gutters.length;e+=1)h.has(e)||this._gutters[e].setVisible(!1)}placeGutterAsStrip(e,t,n,r,a,o,s){e.setOpaque(!0),e.setVisible(!0),e.setX(n),e.setY(r),o?(e.setWidth(18),e.setHeight(a)):(e.setWidth(a),e.setHeight(18));let c=this._sizes.get(t)??18,l=this.collapsesTowardStart(s);if(t.setVisible(!0),o){let e=l?n:n+18-c;this.placeComponent(t,e,r,c,a,i.BOTH)}else{let e=l?r:r+18-c;this.placeComponent(t,n,e,a,c,i.BOTH)}t.setClipPath(this.paneClipInset(s))}paneClipInset(e){switch(e){case`east`:return`inset(0 0 0 100%)`;case`north`:return`inset(0 0 100% 0)`;case`south`:return`inset(100% 0 0 0)`;default:return`inset(0 100% 0 0)`}}applyPendingSizes(){let e=this._pendingSizes;e!==null&&(this._pendingSizes=null,this.applyPaneSizes(e))}applyPendingCollapsed(e){if(this._pendingCollapsed.length!==0){for(let t of this._pendingCollapsed){let n=e[t];n&&this.paneServingGutter(t,e)>=0&&this._collapsed.set(n,!0)}this._pendingCollapsed=[]}}computeMainAxisSizes(e,t){let n=e.length-1,r=0,i=0,a=0;for(let t=0;t<e.length;t+=1){let o=e[t];(this._collapsed.get(o)??!1)&&this.paneServingGutter(t,e)>=0?(i+=1,!this.collapsesTowardStart(this.paneDirection(o))&&t<n&&(a+=1)):r+=this._sizes.get(o)??0}let o=Math.max(0,t-this.gutterTotal(e.length)),s=Math.max(0,o-i*(18-w)+a*w),c=r>0?s/r:0,l=new Map;for(let t=0;t<e.length;t+=1){let n=e[t],r=(this._collapsed.get(n)??!1)&&this.paneServingGutter(t,e)>=0;l.set(n,r?0:(this._sizes.get(n)??0)*c)}return l}recalculateSizes(){let e=this.getContainer();if(!e)return;let t=e.getInnerSize();if(!t)return;let n=e.getComponents();for(let e of[...this._sizes.keys()])n.indexOf(e)<0&&(this._sizes.delete(e),this._collapsed.delete(e));for(let e of[...this._weights.keys()])n.indexOf(e)<0&&this._weights.delete(e);let r=this._orientation===`horizontal`?t.width:t.height,i=Math.max(0,r-this.gutterTotal(n.length)),a=this._orientation===`horizontal`;this.seedFromPreferred(n,a);for(let e of n){let t=this._sizes.get(e);t!==void 0&&this._sizes.set(e,this.clampMain(e,t,a))}if(this._lastAvailableMain>0&&i>0&&i!==this._lastAvailableMain&&this._sizes.size>0){let e=i-this._lastAvailableMain,t=0;for(let e=0;e<n.length;e+=1){let r=n[e];t+=this.effectiveResizeWeight(r,this._sizes.get(r)??0)}if(t>0)for(let r=0;r<n.length;r+=1){let i=n[r],a=this._sizes.get(i);if(a!=null){let n=this.effectiveResizeWeight(i,a);this._sizes.set(i,Math.max(0,a+n/t*e))}}}if(this._lastAvailableMain===0&&i>0&&this._sizes.size>0){let e=0;for(let t=0;t<n.length;t+=1){let r=this.effectiveResizeWeight(n[t],0);r>0&&(e+=r)}if(e>0){let t=0;for(let e=0;e<n.length;e+=1)t+=this._sizes.get(n[e])??0;let r=i-t;for(let t=0;t<n.length;t+=1){let i=n[t],o=this.effectiveResizeWeight(i,0);if(o>0){let t=this._sizes.get(i)??0;this._sizes.set(i,this.clampMain(i,t+o/e*r,a))}}}}let o=0;for(let e=0;e<n.length;e+=1){let t=n[e];this._sizes.has(t)&&(o+=1)}for(let e=0;e<n.length;e+=1){let t=n[e],r=this._sizes.get(t);if(r==null){if(this._sizes.size!=0){r=0;for(let e=0;e<n.length;e+=1){let t=n[e],i=this._sizes.get(t);if(i==null)continue;let a=i*(1/(o+1));r+=a,i-=a,this._sizes.set(t,i)}}else r=i;this._sizes.set(t,r),o+=1}}let s=0,c=0,l=0;for(let e=0;e<n.length;e+=1){let t=n[e],r=this._sizes.get(t)??0;this.isPinnedMain(t,a)?s+=r:this.isResizePinnedMain(t)?c+=r:l+=r}if(i>0){let e=Math.max(0,i-s),t=1,r=1,o=1;l>0&&e>=c?o=(e-c)/l:c>0?(o=0,r=e/c):s>0&&(t=i/s);for(let e=0;e<n.length;e+=1){let i=n[e],s=this._sizes.get(i);if(s==null)continue;let c=this.isPinnedMain(i,a)?t:this.isResizePinnedMain(i)?r:o;c!==1&&this._sizes.set(i,s*c)}}i>0&&(this._lastAvailableMain=i)}},E=a(Split),D=.25,DropZoneHighlight=class extends s{_valid=!0;constructor(){super(),this.setPosition(r.ABSOLUTE),this.setPointerEvents(`none`),this.setBackgroundColor(`var(--ts-ui-drag-dropzone-active-bg)`),this.setVisible(!1)}placeBand(e,t,n,r){this.setX(e),this.setY(t),this.setWidth(n),this.setHeight(r),this.setVisible(!0)}setValid(e){this._valid!==e&&(this._valid=e,this.setBackgroundColor(e?`var(--ts-ui-drag-dropzone-active-bg)`:`var(--ts-ui-drag-dropzone-invalid-bg)`))}hide(){this.setVisible(!1)}},O=u.Band.Window-1,DropZoneOverlay=class extends s{_highlight=new DropZoneHighlight;_zone=null;_valid=!0;constructor(){super(),this.setPosition(r.ABSOLUTE),this.setZIndex(O),this.setPointerEvents(`none`),this.setBackgroundColor(`var(--ts-ui-drag-dropzone-bg)`),this.setBorder({border:`1px solid var(--ts-ui-drag-dropzone-border)`})}attachTo(t){let n=this.getElement(!0);this.setX(0),this.setY(0),this.setWidth(t.getWidth()),this.setHeight(t.getHeight());let r=t.getElement(!0);e.source.getParentElement(n)!==r&&e.sink.appendChild(r,n);let i=this._highlight.getElement(!0);e.source.getParentElement(i)!==n&&e.sink.appendChild(n,i)}setHighlight(e,t=!0){if(e===this._zone&&t===this._valid)return;if(this._zone=e,this._valid=t,e===null){this._highlight.hide();return}this._highlight.setValid(t);let n=this.getWidth(),r=this.getHeight(),i=D,a=0,o=0,s=n,c=r;switch(e){case`top`:a=0,o=0,s=n,c=r*i;break;case`bottom`:a=0,o=r*(1-i),s=n,c=r*i;break;case`left`:a=0,o=0,s=n*i,c=r;break;case`right`:a=n*(1-i),o=0,s=n*i,c=r;break;case`center`:a=n*i,o=r*i,s=n*(1-2*i),c=r*(1-2*i);break}this._highlight.placeBand(a,o,s,c)}highlightFull(){this._zone=null,this._valid=!0,this._highlight.setValid(!0),this._highlight.placeBand(0,0,this.getWidth(),this.getHeight())}detach(){this._zone=null,this._valid=!0,this.removeElement()}},k=a(DropZoneOverlay),DockRegion=class{_region;_overlay=new k;_teardown;_onStructureChanged;_raiseTimer=null;constructor(e,t){this._region=e,this._onStructureChanged=t??null,this._teardown=C.makeDropTarget(e,{accepts:e=>e.dragData.tabDrag===!0,suppressValidityTint:!0,onDragOver:e=>{let t=e.dragData.componentId,n=this.dropZone(e.clientX,e.clientY);return this._overlay.attachTo(this._region),this._overlay.setHighlight(n,this.isLegalDrop(t,n)),this.scheduleSpringRaise(),null},onDragLeave:()=>{this._overlay.detach(),this.clearSpringRaise()},onDrop:e=>{let t=e.dragData.componentId,n=this.dropZone(e.clientX,e.clientY);if(this._overlay.detach(),this.clearSpringRaise(),!this.isLegalDrop(t,n))return!1;let r=S.get(t);if(!r)return!1;n===`center`?this.dockAsTab(r):this.splitOnEdge(r,n),this.raiseHostWindow(),this._onStructureChanged?.()}})}destroy(){this._teardown(),this._overlay.detach(),this.clearSpringRaise()}hostWindow(){for(let e=this._region;e;e=e.getParentComponent())if(e instanceof d)return e;return null}raiseHostWindow(){this.hostWindow()?.bringToFront()}scheduleSpringRaise(){this._raiseTimer===null&&(this._raiseTimer=setTimeout(()=>{this._raiseTimer=null,C.isDragging()&&this.raiseHostWindow()},x))}clearSpringRaise(){this._raiseTimer!==null&&(clearTimeout(this._raiseTimer),this._raiseTimer=null)}dropZone(e,t){return this.isSeedRegion()?`center`:this.computeZone(e,t)}isSeedRegion(){return this._region.getComponents().every(e=>this._region.getLayoutConstraints(e)?.transient===!0)}computeZone(t,n){let r=e.source.getViewportRect(this._region),i=(t-r.left)/r.width,a=(n-r.top)/r.height,o=D,s=i,c=1-i,l=a,u=1-a,d=Math.min(s,c,l,u);return d>=o?`center`:d===s?`left`:d===c?`right`:d===l?`top`:`bottom`}isLegalDrop(e,t){for(let t=this._region;t;t=t.getParentComponent())if(t.getId()===e)return!1;let n=this._region.getComponents();return n.length===1&&n[0].getId()===e?!1:t===`center`?!this.isRedundantCenterDrop(e):!this.isRedundantEdgeDrop(e,t)}isRedundantCenterDrop(e){let t=S.get(e);if(!t)return!1;let n=t.getParentComponent();if(this._region.getLayoutManager()instanceof h)return n===this._region;let r=this._region.getParentComponent();return r?.getLayoutManager()instanceof h&&n===r}isRedundantEdgeDrop(e,t){let n=S.get(e);if(!n)return!1;let r=n.getParentComponent();if(!r||r.getComponents().length!==1)return!1;let i=t===`left`||t===`right`?`horizontal`:`vertical`,a=t===`top`||t===`left`,o=this._region.getLayoutManager();if(o instanceof E&&String(o.getOrientation())===i){if(r.getParentComponent()!==this._region)return!1;let e=this._region.getComponents();return a?e[0]===r:e[e.length-1]===r}let s=this._region.getParentComponent(),c=s?.getLayoutManager()instanceof h?s:this._region,l=c?.getParentComponent();if(!l)return!1;let u=l.getLayoutManager();if(!(u instanceof E&&String(u.getOrientation())===i)||r.getParentComponent()!==l)return!1;let d=l.getComponents(),f=d.indexOf(c),p=d.indexOf(r);return a?p===f-1:p===f+1}splitOnEdge(e,t){let n=t===`left`||t===`right`?`horizontal`:`vertical`,r=t===`top`||t===`left`,i=this.newStack();i.moveComponent(e);let a=this._region.getLayoutManager();if(a instanceof E&&String(a.getOrientation())===n){this._region.moveComponent(i,r?0:this._region.getComponents().length);return}let o=this._region.getParentComponent(),s=o?.getLayoutManager()instanceof h?o:this._region,c=s.getParentComponent();if(!c)return;let u=c.getLayoutManager(),d=c.getComponents().indexOf(s);if(u instanceof E&&String(u.getOrientation())===n){c.moveComponent(i,r?d:d+1);return}let f=new l({layoutManager:new E({orientation:n})});c.moveComponent(f,d);let p=this.ensureStacked(s);f.moveComponent(i,+!r),f.moveComponent(p,+!!r),u instanceof E&&u.transferPaneSize(s,f)}ensureStacked(e){let t=e.getLayoutManager();if(t instanceof h||t instanceof E)return e;let n=this.newStack();return n.moveComponent(e),n}newStack(){let e=new l({layoutManager:new h({reorderable:!0,compact:!0})});return e.getLayoutManager().on(`empty`,()=>this.pruneEmptyStack(e)),e}pruneEmptyStack(e){let t=e.getParentComponent();t&&t.getLayoutManager()instanceof E&&(t.removeComponent(e),this.collapseIfSinglePaneSplit(t))}collapseIfSinglePaneSplit(e){if(!(e.getLayoutManager()instanceof E))return;let t=e.getComponents();if(t.length!==1)return;let n=e.getParentComponent();if(!n)return;let r=n.getComponents().indexOf(e),i=n.getLayoutManager();i instanceof E&&i.transferPaneSize(e,t[0]),n.moveComponent(t[0],r),n.removeComponent(e)}dockAsTab(e){if(this._region.getLayoutManager()instanceof h){this._region.moveComponent(e),this._region.scheduleLayout();return}let t=this._region.getParentComponent();if(!t)return;if(t.getLayoutManager()instanceof h){t.moveComponent(e),t.scheduleLayout();return}let n=t.getComponents().indexOf(this._region),r=this.newStack();t.moveComponent(r,n),r.moveComponent(this._region),r.moveComponent(e),r.scheduleLayout()}};function managerKind(e){let t=e.getLayoutManager();return t?t.getClassName().replace(/^_/,``):``}function panelIdOf(e){return e.getId()}function serializableChildren(e){return e.getComponents().filter(t=>e.getLayoutConstraints(t)?.transient!==!0)}function nodeFor(e){let t=managerKind(e);if(t===`Split`){let t=e.getLayoutManager(),n=e.getComponents().map(nodeFor);return{kind:`split`,orientation:t.getOrientation()===`vertical`?`vertical`:`horizontal`,children:n,ratios:t.getPaneRatios(),collapsed:n.map((e,n)=>t.isPaneCollapsed(n))}}if(t===`Tab`){let t=e.getLayoutManager();return{kind:`tab`,children:serializableChildren(e).map(nodeFor),activeIndex:t.getActiveTabIndex()}}let n=e.getParentComponent()?.getLayoutConstraints(e)?.glyph??null;return{kind:`panel`,panelId:panelIdOf(e),glyph:n}}function windowContentOf(e){return e.getComponents().find(t=>!e.isChromeComponent(t))??null}function windowNodeFor(e){let t=windowContentOf(e);return t?{kind:`window`,content:nodeFor(t),header:e.getTitle(),rect:e.getRect(),state:e.getWindowState(),restoreRect:e.getRestoreRect()}:null}function serializeLayout(e){let t=p.getOpenWindows().map(windowNodeFor).filter(e=>e!==null);return{version:1,root:nodeFor(e),windows:t}}function collectLeaves(e,t){serializableChildren(e).forEach(e=>{let n=managerKind(e);n===`Split`||n===`Tab`?collectLeaves(e,t):t.push(e)})}function parkLeaves(e,t,n){let r=[];collectLeaves(e,r),t.forEach(e=>{let t=windowContentOf(e);if(!t)return;let n=managerKind(t);n===`Split`||n===`Tab`?collectLeaves(t,r):r.push(t)});let i=new Map;return r.forEach(e=>{let t=panelIdOf(e);n(t)===e&&(i.set(t,e),e.getParentComponent()?.removeComponent(e))}),i}function hostsComponent(e,t){for(let n=t;n;n=n.getParentComponent())if(n===e)return!0;return!1}function constraintsFor(e){if(e.kind!==`panel`||!e.glyph)return;let t=new b;return t.glyph=e.glyph,t}function materializeNode(e,t,n){if(e.kind===`panel`){let r=t.get(e.panelId)??n(e.panelId);return r||console.warn(`restoreLayout: no component for panelId "${e.panelId}"; skipping.`),r}let r=new s;return populateContainer(r,e,t,n),r}function populateContainer(e,t,n,r){if(t.kind===`split`){let i=new E({orientation:t.orientation});e.setLayoutManager(i);let a=[];t.children.forEach((i,o)=>{let s=materializeNode(i,n,r);s&&(e.moveComponent(s,void 0,constraintsFor(i)),a.push({ratio:t.ratios[o]??0,collapsed:t.collapsed[o]??!1}))}),i.applyPaneRatios(a.map(e=>e.ratio)),a.forEach((e,t)=>{e.collapsed&&i.setPaneCollapsedImmediate(t,!0)})}else{let i=new h({reorderable:!0,compact:!0});e.setLayoutManager(i),t.children.forEach(t=>{let a=materializeNode(t,n,r);a&&(e.moveComponent(a,void 0,constraintsFor(t)),i.createTab(a))}),i.setActiveTabIndex(t.activeIndex)}}function applyWindow(e,t,n){let r=e.content??(e.panelId?{kind:`panel`,panelId:e.panelId,glyph:null}:null);if(!r){console.warn(`restoreLayout: window node has neither content nor panelId; skipping.`);return}let i=materializeNode(r,t,n);if(!i)return;let a=new p(e.header);a.moveComponent(i,void 0,constraintsFor(r));let o=e.state===`normal`?e.rect:e.restoreRect??e.rect;a.applyRect(o),a.show(),e.state!==`normal`&&a.setWindowState(e.state)}function restoreLayout(e,t,n){let r=p.getOpenWindows().filter(t=>!hostsComponent(t,e)),i=parkLeaves(e,r,n);if(r.forEach(e=>e.onExitAction()),e.removeAllComponents(),t.root.kind===`panel`){let r=materializeNode(t.root,i,n);r&&e.moveComponent(r,void 0,constraintsFor(t.root))}else populateContainer(e,t.root,i,n);t.windows.forEach(e=>applyWindow(e,i,n))}export{E as a,k as i,serializeLayout as n,DockRegion as r,restoreLayout as t};
2
+ //# sourceMappingURL=LayoutSerialization-C_zcwaN3.js.map