@jimka/typescript-ui 0.4.0 → 0.4.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.
- package/dist/lib/{AbstractBooleanInput-DSwKBAic.js → AbstractBooleanInput-DE5NNJT0.js} +2 -2
- package/dist/lib/{AbstractBooleanInput-DSwKBAic.js.map → AbstractBooleanInput-DE5NNJT0.js.map} +1 -1
- package/dist/lib/{AbstractInput-BmWGJTs1.js → AbstractInput-BxfrmD2W.js} +2 -2
- package/dist/lib/{AbstractInput-BmWGJTs1.js.map → AbstractInput-BxfrmD2W.js.map} +1 -1
- package/dist/lib/{AnchorConstraints-CVrMP9rz.js → AnchorConstraints-DdDYSDkf.js} +2 -2
- package/dist/lib/{AnchorConstraints-CVrMP9rz.js.map → AnchorConstraints-DdDYSDkf.js.map} +1 -1
- package/dist/lib/{AnimatedDropdown-DKas40B-.js → AnimatedDropdown-QLNasu_Y.js} +2 -2
- package/dist/lib/{AnimatedDropdown-DKas40B-.js.map → AnimatedDropdown-QLNasu_Y.js.map} +1 -1
- package/dist/lib/Border-CKKUk5G9.js +2 -0
- package/dist/lib/Border-CKKUk5G9.js.map +1 -0
- package/dist/lib/{Button-bjpWruNc.js → Button-MZDYJOMC.js} +2 -2
- package/dist/lib/{Button-bjpWruNc.js.map → Button-MZDYJOMC.js.map} +1 -1
- package/dist/lib/{Card-BdfbvOD_.js → Card-a4dzYrbX.js} +2 -2
- package/dist/lib/{Card-BdfbvOD_.js.map → Card-a4dzYrbX.js.map} +1 -1
- package/dist/lib/ComboBox-C04SfXAR.js +2 -0
- package/dist/lib/ComboBox-C04SfXAR.js.map +1 -0
- package/dist/lib/Component-fRQvgaEY.js +2 -0
- package/dist/lib/Component-fRQvgaEY.js.map +1 -0
- package/dist/lib/Container-0bsG2Q8Z.js +2 -0
- package/dist/lib/{Container-CAQpj4yb.js.map → Container-0bsG2Q8Z.js.map} +1 -1
- package/dist/lib/{DragManager-CHWCe3-8.js → DragManager-DRor_-1x.js} +2 -2
- package/dist/lib/{DragManager-CHWCe3-8.js.map → DragManager-DRor_-1x.js.map} +1 -1
- package/dist/lib/{FieldDecorator-CgAGcqCk.js → FieldDecorator-Bpx8J8n9.js} +2 -2
- package/dist/lib/{FieldDecorator-CgAGcqCk.js.map → FieldDecorator-Bpx8J8n9.js.map} +1 -1
- package/dist/lib/{Fit-DIYt2aQB.js → Fit-CL1m1nIZ.js} +2 -2
- package/dist/lib/{Fit-DIYt2aQB.js.map → Fit-CL1m1nIZ.js.map} +1 -1
- package/dist/lib/{Glyph-CeAIWyPB.js → Glyph-wN7bk7mg.js} +2 -2
- package/dist/lib/{Glyph-CeAIWyPB.js.map → Glyph-wN7bk7mg.js.map} +1 -1
- package/dist/lib/{Grid-ViA0joow.js → Grid-DHHmaB-Y.js} +2 -2
- package/dist/lib/{Grid-ViA0joow.js.map → Grid-DHHmaB-Y.js.map} +1 -1
- package/dist/lib/{GridConstraints-B1rxCw9B.js → GridConstraints-DVc1BmlP.js} +2 -2
- package/dist/lib/{GridConstraints-B1rxCw9B.js.map → GridConstraints-DVc1BmlP.js.map} +1 -1
- package/dist/lib/{Header-mKaqgfat.js → Header-2hKwQo_u.js} +2 -2
- package/dist/lib/{Header-mKaqgfat.js.map → Header-2hKwQo_u.js.map} +1 -1
- package/dist/lib/{IconText-BqwXA82-.js → IconText-DC7Xe34b.js} +2 -2
- package/dist/lib/{IconText-BqwXA82-.js.map → IconText-DC7Xe34b.js.map} +1 -1
- package/dist/lib/LayoutConstraints-LIHYYd2F.js +2 -0
- package/dist/lib/LayoutConstraints-LIHYYd2F.js.map +1 -0
- package/dist/lib/{LayoutSerialization-D82UtnDD.js → LayoutSerialization-D5bBas4W.js} +2 -2
- package/dist/lib/{LayoutSerialization-D82UtnDD.js.map → LayoutSerialization-D5bBas4W.js.map} +1 -1
- package/dist/lib/{LayoutSizes-DG9aW9k6.js → LayoutSizes-qNaURyiw.js} +2 -2
- package/dist/lib/LayoutSizes-qNaURyiw.js.map +1 -0
- package/dist/lib/{List-CUntS8ux.js → List-CG4NvwuV.js} +2 -2
- package/dist/lib/{List-CUntS8ux.js.map → List-CG4NvwuV.js.map} +1 -1
- package/dist/lib/Menu-CrZy2u0g.js +2 -0
- package/dist/lib/Menu-CrZy2u0g.js.map +1 -0
- package/dist/lib/MenuButton-wy_0RskC.js +2 -0
- package/dist/lib/MenuButton-wy_0RskC.js.map +1 -0
- package/dist/lib/{Panel-D2X33qR6.js → Panel-Rd9zkNXx.js} +2 -2
- package/dist/lib/{Panel-D2X33qR6.js.map → Panel-Rd9zkNXx.js.map} +1 -1
- package/dist/lib/{ProgressSpinner-DCyq02pd.js → ProgressSpinner-yt-VXyCb.js} +2 -2
- package/dist/lib/{ProgressSpinner-DCyq02pd.js.map → ProgressSpinner-yt-VXyCb.js.map} +1 -1
- package/dist/lib/{RadioButton-BJIAQkII.js → RadioButton-D23rId-V.js} +2 -2
- package/dist/lib/{RadioButton-BJIAQkII.js.map → RadioButton-D23rId-V.js.map} +1 -1
- package/dist/lib/{Scrollbar-CSFK-Y57.js → Scrollbar-SOj9psiP.js} +2 -2
- package/dist/lib/{Scrollbar-CSFK-Y57.js.map → Scrollbar-SOj9psiP.js.map} +1 -1
- package/dist/lib/{Slider-C-kQQYCj.js → Slider-DBnAZ-F7.js} +2 -2
- package/dist/lib/{Slider-C-kQQYCj.js.map → Slider-DBnAZ-F7.js.map} +1 -1
- package/dist/lib/{Spacer-D159iJy9.js → Spacer-qalSEJ5i.js} +2 -2
- package/dist/lib/{Spacer-D159iJy9.js.map → Spacer-qalSEJ5i.js.map} +1 -1
- package/dist/lib/{TabButton-CHkXBgCj.js → TabButton-DKECTTk1.js} +2 -2
- package/dist/lib/{TabButton-CHkXBgCj.js.map → TabButton-DKECTTk1.js.map} +1 -1
- package/dist/lib/{Text-D5pg7taZ.js → Text-KB5LksJl.js} +2 -2
- package/dist/lib/{Text-D5pg7taZ.js.map → Text-KB5LksJl.js.map} +1 -1
- package/dist/lib/{Tooltip-DzK6LxUt.js → Tooltip-Dro4DOZs.js} +2 -2
- package/dist/lib/{Tooltip-DzK6LxUt.js.map → Tooltip-Dro4DOZs.js.map} +1 -1
- package/dist/lib/{VBox-BNegDPs_.js → VBox-P3WFGkPc.js} +2 -2
- package/dist/lib/{VBox-BNegDPs_.js.map → VBox-P3WFGkPc.js.map} +1 -1
- package/dist/lib/{VirtualScroller-zQr-vKrO.js → VirtualScroller-Bv4KXGKW.js} +2 -2
- package/dist/lib/{VirtualScroller-zQr-vKrO.js.map → VirtualScroller-Bv4KXGKW.js.map} +1 -1
- package/dist/lib/component/button.es.js +1 -1
- package/dist/lib/component/button.es.js.map +1 -1
- package/dist/lib/component/chart.es.js +1 -1
- package/dist/lib/component/chart.es.js.map +1 -1
- package/dist/lib/component/container.es.js +1 -1
- package/dist/lib/component/container.es.js.map +1 -1
- package/dist/lib/component/diagram.es.js +1 -1
- package/dist/lib/component/display.es.js +1 -1
- package/dist/lib/component/editor.es.js +1 -1
- package/dist/lib/component/input.es.js +1 -1
- package/dist/lib/component/list.es.js +1 -1
- package/dist/lib/component/menubar.es.js +1 -1
- package/dist/lib/component/menubar.es.js.map +1 -1
- package/dist/lib/component/table.es.js +2 -2
- package/dist/lib/component/table.es.js.map +1 -1
- package/dist/lib/component/tree.es.js +1 -1
- package/dist/lib/core.es.js +1 -1
- package/dist/lib/layout.es.js +1 -1
- package/dist/lib/overlay.es.js +1 -1
- package/dist/lib/overlay.es.js.map +1 -1
- package/dist/lib/{selectionsEqual-4r5R7pTK.js → selectionsEqual-Ci3_uflt.js} +2 -2
- package/dist/lib/{selectionsEqual-4r5R7pTK.js.map → selectionsEqual-Ci3_uflt.js.map} +1 -1
- package/dist/lib/types/component/button/MenuButton.d.ts +1 -0
- package/dist/lib/types/component/button/SplitButton.d.ts +1 -0
- package/dist/lib/types/component/button/TabButton.d.ts +1 -0
- package/dist/lib/types/component/chart/ChartLegend.d.ts +0 -1
- package/dist/lib/types/component/container/CollapseButton.d.ts +0 -1
- package/dist/lib/types/component/container/TabPanel.d.ts +3 -0
- package/dist/lib/types/component/input/Link.d.ts +0 -1
- package/dist/lib/types/component/menubar/MenuBar.d.ts +1 -0
- package/dist/lib/types/component/menubar/MenuBarButton.d.ts +0 -1
- package/dist/lib/types/component/menubar/ToolBar.d.ts +1 -0
- package/dist/lib/types/component/table/Table.d.ts +1 -0
- package/dist/lib/types/core/BorderWidths.d.ts +12 -0
- package/dist/lib/types/core/Component.d.ts +1 -0
- package/dist/lib/types/core/Event.d.ts +2 -0
- package/dist/lib/types/layout/LayoutConstraints.d.ts +1 -0
- package/dist/lib/types/layout/LayoutSerialization.d.ts +3 -0
- package/dist/lib/types/overlay/Dock.d.ts +1 -0
- package/dist/lib/validation.es.js +1 -1
- package/package.json +1 -1
- package/dist/lib/Border-Bz29z-_7.js +0 -2
- package/dist/lib/Border-Bz29z-_7.js.map +0 -1
- package/dist/lib/ComboBox-CBw2VLLN.js +0 -2
- package/dist/lib/ComboBox-CBw2VLLN.js.map +0 -1
- package/dist/lib/Component-DHqrPwAw.js +0 -2
- package/dist/lib/Component-DHqrPwAw.js.map +0 -1
- package/dist/lib/Container-CAQpj4yb.js +0 -2
- package/dist/lib/LayoutConstraints-DkctJZXB.js +0 -2
- package/dist/lib/LayoutConstraints-DkctJZXB.js.map +0 -1
- package/dist/lib/LayoutSizes-DG9aW9k6.js.map +0 -1
- package/dist/lib/Menu-B_-SQj72.js +0 -2
- package/dist/lib/Menu-B_-SQj72.js.map +0 -1
- package/dist/lib/MenuButton-C79l8Ysf.js +0 -2
- package/dist/lib/MenuButton-C79l8Ysf.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"../DOM-67StIm5G.js";import{l as t,n}from"../Position-Ck_KD4cR.js";import{S as r,b as i,h as a,r as o,t as s}from"../Component-DHqrPwAw.js";import{t as c}from"../ListenerBag-WPdKuuds.js";import{t as l}from"../Glyph-CeAIWyPB.js";import{t as u}from"../Text-D5pg7taZ.js";import{r as d}from"../VBox-BNegDPs_.js";import{t as f}from"../Border-Bz29z-_7.js";import{t as ee}from"../ProgressSpinner-DCyq02pd.js";import{t as p}from"../Placement-7kqdaK4Z.js";import{t as te}from"../Header-mKaqgfat.js";import{t as m}from"../Button-bjpWruNc.js";import{angle_left as h}from"../glyphs/solid/angle_left.es.js";import{angle_right as g}from"../glyphs/solid/angle_right.es.js";import{n as _,t as v}from"../Slider-C-kQQYCj.js";import{t as y}from"../IconText-BqwXA82-.js";import{angles_left as b}from"../glyphs/solid/angles_left.es.js";import{angles_right as x}from"../glyphs/solid/angles_right.es.js";import{play as S}from"../glyphs/solid/play.es.js";import{pause as C}from"../glyphs/solid/pause.es.js";import{volume_high as w}from"../glyphs/solid/volume_high.es.js";import{volume_mute as T}from"../glyphs/solid/volume_mute.es.js";import{expand as E}from"../glyphs/solid/expand.es.js";import{compress as D}from"../glyphs/solid/compress.es.js";import{lexer as O}from"marked";var k={tag:`canvas`,maxFps:30},A=-1,Canvas=class extends s{_ctx=null;_rafId=null;_animationStartMs=null;_lastDrawMs=null;_elapsedMs=0;_animationRequested=!1;_syncedWidth=A;_syncedHeight=A;_syncedDpr=A;_dprToken=0;constructor(e,t){super(e,{...k,...t??{}}),this.clearInsets()}applyOptions(e){return super.applyOptions(e),e.onDraw!==void 0&&this.setOnDraw(e.onDraw),e.animateWhenHidden!==void 0&&this.setAnimateWhenHidden(e.animateWhenHidden),e.maxFps!==void 0&&this.setMaxFps(e.maxFps),this}getContext(){if(this._ctx)return this._ctx;let t=this.getElement();return t?(this._ctx=e.sink.getContext(t,`2d`),this._ctx):null}setOnDraw(e){return this._options.onDraw=e??void 0,this.redraw(),this}getOnDraw(){return this._options.onDraw??this._defaultOptions.onDraw??null}redraw(){let e=this.getContext();if(!e)return this;let t=this.getWidth(),n=this.getHeight();return e.clearRect(0,0,t,n),this.getOnDraw()?.(e,t,n,this._elapsedMs),this}startAnimation(){return this._animationRequested=!0,this._animationStartMs=null,this._lastDrawMs=null,this._elapsedMs=0,this.reconcileAnimation(),this}stopAnimation(){return this._animationRequested=!1,this.reconcileAnimation(),this}isAnimating(){return this._rafId!==null}setAnimateWhenHidden(e){return this._options.animateWhenHidden=e,this.reconcileAnimation(),this}setMaxFps(e){return this._options.maxFps=Math.max(0,e),this}getMaxFps(){return this._options.maxFps??this._defaultOptions.maxFps??0}getAnimateWhenHidden(){return this._options.animateWhenHidden??this._defaultOptions.animateWhenHidden??!1}syncBackingStore(){let t=this.getContext();if(!t)return;let n=this.getWidth(),r=this.getHeight(),i=e.source.getDevicePixelRatio();if(n===this._syncedWidth&&r===this._syncedHeight&&i===this._syncedDpr)return;let a=this.getElement();e.sink.apply(a,{setAttr:{width:String(Math.round(n*i)),height:String(Math.round(r*i))}}),t.setTransform(i,0,0,i,0,0),this._syncedWidth=n,this._syncedHeight=r,this._syncedDpr=i,this.redraw()}doLayout(){return super.doLayout(),this.syncBackingStore(),this}render(){let e=super.render();return this.watchDevicePixelRatio(),e}destructor(){this.stopAnimation(),super.destructor()}shouldAnimate(){return this._animationRequested&&(this.getAnimateWhenHidden()||this.isEffectivelyVisible())}reconcileAnimation(){this.shouldAnimate()?this._rafId===null&&(this._rafId=e.sink.requestAnimationFrame(this.animationStep)):this._rafId!=null&&(e.sink.cancelAnimationFrame(this._rafId),this._rafId=null)}animationStep=t=>{if(!this._animationRequested){this._rafId=null;return}this._animationStartMs===null&&(this._animationStartMs=t);let n=this.getMaxFps(),r=n>0?1e3/n:0;(this._lastDrawMs===null||t-this._lastDrawMs>=r)&&(this._lastDrawMs=t,this._elapsedMs=t-this._animationStartMs,this.redraw()),this._rafId=e.sink.requestAnimationFrame(this.animationStep)};onEffectiveVisibilityChange(e){super.onEffectiveVisibilityChange(e),this.reconcileAnimation()}watchDevicePixelRatio(){let t=++this._dprToken,n=e.source.getDevicePixelRatio();e.source.matchMedia(`(resolution: ${n}dppx)`).addChangeListener(()=>this.onDevicePixelRatioChange(t))}onDevicePixelRatioChange(e){e===this._dprToken&&this.getElement()&&(this.syncBackingStore(),this.watchDevicePixelRatio())}},ne=a(Canvas),re={tag:`canvas`,maxFps:30},j=-1,WebGLCanvas=class extends s{_gl=null;_rafId=null;_animationStartMs=null;_lastDrawMs=null;_elapsedMs=0;_animationRequested=!1;_contextLost=!1;_syncedWidth=j;_syncedHeight=j;_syncedDpr=j;_dprToken=0;constructor(e,t){super(e,{...re,...t??{}}),this._contextInitialised=!1,this.clearInsets()}applyOptions(e){return super.applyOptions(e),e.onContextInit!==void 0&&this.setOnContextInit(e.onContextInit),e.onFrame!==void 0&&this.setOnFrame(e.onFrame),e.animateWhenHidden!==void 0&&this.setAnimateWhenHidden(e.animateWhenHidden),e.maxFps!==void 0&&this.setMaxFps(e.maxFps),this}getContext(){if(this._gl)return this._gl;let t=this.getElement();return t?(this._gl=e.sink.getContext(t,`webgl2`),this._gl):null}setOnContextInit(e){return this._options.onContextInit=e??void 0,this._contextInitialised=!1,this}getOnContextInit(){return this._options.onContextInit??this._defaultOptions.onContextInit??null}setOnFrame(e){return this._options.onFrame=e??void 0,this}getOnFrame(){return this._options.onFrame??this._defaultOptions.onFrame??null}startAnimation(){return this._animationRequested=!0,this._animationStartMs=null,this._lastDrawMs=null,this._elapsedMs=0,this.reconcileAnimation(),this}stopAnimation(){return this._animationRequested=!1,this.reconcileAnimation(),this}isAnimating(){return this._rafId!==null}setAnimateWhenHidden(e){return this._options.animateWhenHidden=e,this.reconcileAnimation(),this}getAnimateWhenHidden(){return this._options.animateWhenHidden??this._defaultOptions.animateWhenHidden??!1}setMaxFps(e){return this._options.maxFps=Math.max(0,e),this}getMaxFps(){return this._options.maxFps??this._defaultOptions.maxFps??0}syncBackingStore(){let t=this.getContext();if(!t)return;let n=this.getWidth(),r=this.getHeight(),i=e.source.getDevicePixelRatio();if(n===this._syncedWidth&&r===this._syncedHeight&&i===this._syncedDpr)return;let a=Math.round(n*i),o=Math.round(r*i);e.sink.apply(this.getElement(),{setAttr:{width:String(a),height:String(o)}}),t.viewport(0,0,a,o),this._syncedWidth=n,this._syncedHeight=r,this._syncedDpr=i,this.renderFrame()}doLayout(){return super.doLayout(),this.syncBackingStore(),this}render(){let e=super.render();return r.addListener(this,`webglcontextlost`,e=>{e.preventDefault(),this._contextLost=!0}),r.addListener(this,`webglcontextrestored`,()=>{this._contextLost=!1,this._contextInitialised=!1,this.syncBackingStore()}),this.watchDevicePixelRatio(),this.onFirstLayout(()=>this.startAnimation()),e}destructor(){this.stopAnimation(),super.destructor()}shouldAnimate(){return this._animationRequested&&(this.getAnimateWhenHidden()||this.isEffectivelyVisible())}reconcileAnimation(){this.shouldAnimate()?this._rafId===null&&(this._rafId=e.sink.requestAnimationFrame(this.animationStep)):this._rafId!=null&&(e.sink.cancelAnimationFrame(this._rafId),this._rafId=null)}animationStep=t=>{if(!this._animationRequested){this._rafId=null;return}this._animationStartMs===null&&(this._animationStartMs=t);let n=this.getMaxFps(),r=n>0?1e3/n:0;(this._lastDrawMs===null||t-this._lastDrawMs>=r)&&(this._lastDrawMs=t,this._elapsedMs=t-this._animationStartMs,this.renderFrame()),this._rafId=e.sink.requestAnimationFrame(this.animationStep)};onEffectiveVisibilityChange(e){super.onEffectiveVisibilityChange(e),this.reconcileAnimation()}renderFrame(){let e=this.getContext();!e||this._contextLost||(this._contextInitialised||=(this.getOnContextInit()?.(e),!0),this.getOnFrame()?.(e,this.getWidth(),this.getHeight(),this._elapsedMs))}watchDevicePixelRatio(){let t=++this._dprToken,n=e.source.getDevicePixelRatio();e.source.matchMedia(`(resolution: ${n}dppx)`).addChangeListener(()=>this.onDevicePixelRatioChange(t))}onDevicePixelRatioChange(e){e===this._dprToken&&this.getElement()&&(this.syncBackingStore(),this.watchDevicePixelRatio())}},ie=a(WebGLCanvas),M=100,N={tag:`img`},Image=class extends s{_src;constructor(e,t,n){super(t,{...N,...n??{}}),this._src=e,this.clearInsets()}getElement(e=!1){return super.getElement(e)}getPreferredSize(){let t=this.getElement(),n=e.source.getNaturalSize(t);return{width:n.width,height:n.height}}getMinSize(){let t=super.getMinSize();if(this._options.minSize)return t;let n=this.getElement();if(!n||!e.source.getNaturalSize(n).width)return{width:20,height:20};let r=e.source.getNaturalSize(n);return{width:Math.min(r.width,M),height:Math.min(r.height,M)}}render(){let t=super.render();return e.sink.apply(t,{setAttr:{src:this._src.valueOf()}}),t}},P=a(Image),F=`ts-ui-md-code`,I=`ts-ui-md-pre`,L=`ts-ui-md-quote`,R=`ts-ui-md-list`,z=`ts-ui-md-link`,B=`ts-ui-md-heading`,V=`ts-ui-md-table-wrap`,H=`ts-ui-md-table`,U=`ts-ui-md-th`,W=`ts-ui-md-td`,G=`ts-ui-md-align-left`,K=`ts-ui-md-align-center`,q=`ts-ui-md-align-right`,ae=1,J=6,Y=!1;function ensureMarkdownClassRules(){Y||(Y=!0,new i({scope:`class`,name:F,styles:{fontFamily:`var(--ts-ui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,background:`rgba(127, 127, 127, 0.16)`,borderRadius:`var(--ts-ui-border-radius, 3px)`,padding:`0.1em 0.3em`}}),new i({scope:`class`,name:I,styles:{fontFamily:`var(--ts-ui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,background:`rgba(127, 127, 127, 0.16)`,borderRadius:`var(--ts-ui-border-radius, 3px)`,padding:`0.6em 0.8em`,whiteSpace:`pre`,overflow:`auto`}}),new i({scope:`class`,name:L,styles:{borderLeft:`3px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,paddingLeft:`1em`,marginLeft:`0`}}),new i({scope:`class`,name:R,styles:{paddingLeft:`1.5em`}}),new i({scope:`class`,name:z,styles:{color:`var(--ts-ui-indicator-focus, #2563eb)`}}),new i({scope:`class`,name:B,styles:{fontWeight:`600`}}),new i({scope:`class`,name:V,styles:{maxWidth:`100%`,overflowX:`auto`}}),new i({scope:`class`,name:H,styles:{borderCollapse:`collapse`}}),new i({scope:`class`,name:U,styles:{border:`1px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,padding:`0.3em 0.6em`,fontWeight:`600`,textAlign:`left`}}),new i({scope:`class`,name:W,styles:{border:`1px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,padding:`0.3em 0.6em`}}),new i({scope:`class`,name:G,styles:{textAlign:`left`}}),new i({scope:`class`,name:K,styles:{textAlign:`center`}}),new i({scope:`class`,name:q,styles:{textAlign:`right`}}))}function alignmentClass(e){switch(e){case`left`:return G;case`center`:return K;case`right`:return q;default:return null}}function slugify(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function defaultLinkResolver(e){return{href:e,external:!0}}var Markdown=class extends s{_contentHandles=[];_measuredHeight=null;_unsubscribeTheme;constructor(e,t){super(t),e!==void 0&&this._options.markdown===void 0&&(this._options.markdown=e),this.setWhiteSpace(`normal`),this.setElementCSSRule(`overflowWrap`,`break-word`),this._unsubscribeTheme=o.onThemeChange(()=>this.measureContentHeight()),this.onFirstLayout(()=>this.measureContentHeight())}applyOptions(e){return super.applyOptions(e),e.markdown!==void 0&&(this._options.markdown=e.markdown),e.linkResolver!==void 0&&(this._options.linkResolver=e.linkResolver),this}getMarkdown(){return this._options.markdown??``}setLinkResolver(e){return this._options.linkResolver=e,this}getLinkResolver(){return this._options.linkResolver??defaultLinkResolver}setMarkdown(e){this._options.markdown=e;let t=this.getElement();return t?(this.clearContent(),ensureMarkdownClassRules(),this.appendBlockTokens(t,O(e),new Map),this.measureContentHeight(),this):this}getMinSize(){let e=super.getMinSize();return this._measuredHeight===null?e:e?{width:e.width,height:Math.max(e.height,this._measuredHeight)}:{width:0,height:this._measuredHeight}}getPreferredSize(){let e=super.getPreferredSize();return this._measuredHeight===null||this.getPreferredSizeConstraint()!==null?e:e?{width:e.width,height:this._measuredHeight}:{width:0,height:this._measuredHeight}}setWidth(e){let t=e!==this.getWidth();return super.setWidth(e),t&&this.measureContentHeight(),this}destructor(){this._unsubscribeTheme(),super.destructor()}measureContentHeight(){let t=this.getElement();if(!t)return;let n=this.getHeight();this.setElementStyle(`height`,`auto`),this.commitElementStyle();let r=this.getBorderSize(),i=e.source.getScrollMetrics(t).scrollHeight+r.top+r.bottom;this.setElementStyle(`height`,n+`px`),this.commitElementStyle(),i!==this._measuredHeight&&(this._measuredHeight=i,(this.getParentComponent()??this).scheduleLayout())}render(){let e=super.render();return ensureMarkdownClassRules(),this.appendBlockTokens(e,O(this.getMarkdown()),new Map),e}create(t){let n=e.sink.createElement(t);return this.trackHandle(n),this._contentHandles.push(n),n}clearContent(){for(let t of this._contentHandles)e.sink.removeElement(t),this.untrackHandle(t),e.sink.release(t);this._contentHandles.length=0}appendBlockTokens(e,t,n){for(let r of t)this.appendBlockToken(e,r,n)}appendBlockToken(e,t,n){switch(t.type){case`heading`:this.appendHeading(e,t,n);break;case`paragraph`:this.appendParagraph(e,t);break;case`list`:this.appendList(e,t,n);break;case`blockquote`:this.appendBlockquote(e,t,n);break;case`code`:this.appendCode(e,t);break;case`table`:this.appendTable(e,t);break;case`space`:break;default:this.appendTextNode(e,t.raw??``);break}}appendHeading(t,n,r){let i=Math.min(Math.max(n.depth,ae),J),a=this.create(`h`+i),o=slugify(n.text),s=r.get(o)??0;r.set(o,s+1);let c=s===0?o:`${o}-${s}`;e.sink.apply(a,{addClass:[B],setAttr:{id:c}}),this.appendInlineTokens(a,n.tokens),e.sink.appendChild(t,a)}appendParagraph(t,n){let r=this.create(`p`);this.appendInlineTokens(r,n.tokens),e.sink.appendChild(t,r)}appendList(t,n,r){let i=this.create(n.ordered?`ol`:`ul`);e.sink.apply(i,{addClass:[R]});for(let e of n.items)this.appendListItem(i,e,r);e.sink.appendChild(t,i)}appendListItem(t,n,r){let i=this.create(`li`);for(let e of n.tokens)if(e.type===`text`){let t=e;t.tokens&&t.tokens.length>0?this.appendInlineTokens(i,t.tokens):this.appendInlineToken(i,t,n.tokens.length===1)}else this.appendBlockToken(i,e,r);e.sink.appendChild(t,i)}appendTable(t,n){let r=this.create(`div`);e.sink.apply(r,{addClass:[V]});let i=this.create(`table`);e.sink.apply(i,{addClass:[H]});let a=this.create(`thead`);this.appendTableRow(a,n.header,!0),e.sink.appendChild(i,a);let o=this.create(`tbody`);for(let e of n.rows)this.appendTableRow(o,e,!1);e.sink.appendChild(i,o),e.sink.appendChild(r,i),e.sink.appendChild(t,r)}appendTableRow(t,n,r){let i=this.create(`tr`);for(let t of n){let n=this.create(r?`th`:`td`),a=[r?U:W],o=alignmentClass(t.align);o&&a.push(o),e.sink.apply(n,{addClass:a}),this.appendInlineTokens(n,t.tokens),e.sink.appendChild(i,n)}e.sink.appendChild(t,i)}appendBlockquote(t,n,r){let i=this.create(`blockquote`);e.sink.apply(i,{addClass:[L]}),this.appendBlockTokens(i,n.tokens,r),e.sink.appendChild(t,i)}appendCode(t,n){let r=this.create(`pre`);e.sink.apply(r,{addClass:[I]});let i=this.create(`code`);e.sink.apply(i,{text:n.text}),e.sink.appendChild(r,i),e.sink.appendChild(t,r)}appendInlineTokens(e,t){let n=t.length===1;for(let r of t)this.appendInlineToken(e,r,n)}appendInlineToken(t,n,r){switch(n.type){case`text`:{let i=n;i.tokens&&i.tokens.length>0?this.appendInlineTokens(t,i.tokens):r?e.sink.apply(t,{text:i.text}):this.appendTextNode(t,i.text);break}case`strong`:this.appendInlineWrapper(t,`strong`,n.tokens);break;case`em`:this.appendInlineWrapper(t,`em`,n.tokens);break;case`codespan`:{let r=this.create(`code`);e.sink.apply(r,{addClass:[F],text:n.text}),e.sink.appendChild(t,r);break}case`link`:this.appendLink(t,n);break;default:this.appendTextNode(t,n.text??n.raw??``);break}}appendInlineWrapper(t,n,r){let i=this.create(n);this.appendInlineTokens(i,r),e.sink.appendChild(t,i)}appendLink(t,n){let r=this.create(`a`),i=this.getLinkResolver()(n.href),a={href:i.href};i.external&&(a.target=`_blank`,a.rel=`noopener noreferrer`),e.sink.apply(r,{addClass:[z],setAttr:a}),this.appendInlineTokens(r,n.tokens),e.sink.appendChild(t,r)}appendTextNode(t,n){let r=this.create(`span`);e.sink.apply(r,{text:n}),e.sink.appendChild(t,r)}},oe=a(Markdown),se={gap:2,insets:new n(0,0,0,0)},IconLabel=class extends s{_glyph;_label;constructor(e,t,n,r,i){super(r,{...se,...i??{}}),this.setLayoutManager(new d({spacing:this.getGap()}));let a=this._options.glyph??e,o=this._options.text??t,s=this._options.forId??n;this._glyph=new l(a),this._label=new _(o,s),this.addComponent(this._glyph),this.addComponent(this._label),this._options.gap!==void 0&&this.getLayoutManager().setComponentSpacing(this._options.gap)}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),e.forId!==void 0&&(this._options.forId=e.forId),this}setGlyph(e){return this.removeComponent(this._glyph),this._glyph=new l(e),this.insertComponent(this._glyph,0),this}setText(e){return this._label.setText(e),this}setForId(e){return this._label.setForId(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}getLabelComponent(){return this._label}},ce=a(IconLabel);i.ensureKeyframes(`ts-ui-progress-indeterminate`,`0% { transform: translateX(-100%); } 100% { transform: translateX(400%); }`);var ProgressBar=class extends s{_track;_fill;_value;_indeterminate;constructor(e=0,n=!1,r){super(),this._value=t.clamp(e,0,100),this._indeterminate=n,this.setBackgroundColor(`var(--ts-ui-progress-track-bg, rgb(220, 220, 220))`),this.setBorderRadius(`var(--ts-ui-progress-track-radius, 4px)`),this._track=new s,this._track.setOverflow(`hidden`),this._track.setBorderRadius(`var(--ts-ui-progress-track-radius, 4px)`),this._fill=new s,this._fill.setBackgroundColor(`var(--ts-ui-progress-fill-bg, rgb(30, 100, 200))`),this._track.addComponent(this._fill),super.addComponent(this._track),this.getAria().setRole(`progressbar`),this.getAria().setValueMin(0),this.getAria().setValueMax(100),this.getAria().setValueNow(this._value),this._indeterminate&&this.applyIndeterminate(!0),r&&this.applyOptions(r)}applyOptions(e){return super.applyOptions(e),e.indeterminate!==void 0&&this.setIndeterminate(e.indeterminate),e.value!==void 0&&this.setValue(e.value),this}getBaseline(){let e=this.getPreferredSize();return e?e.height-2:null}getValue(){return this._indeterminate?0:this._value}setValue(e){let n=t.clamp(e,0,100);return n===this._value?this:(this._value=n,this.getAria().setValueNow(n),this._indeterminate||this.scheduleLayout(),this)}isIndeterminate(){return this._indeterminate}setIndeterminate(e){return this._indeterminate===e?this:(this._indeterminate=e,this.applyIndeterminate(e),this.flushLayout(),this)}doLayout(){let e=this.getContentBounds();if(!e)return super.doLayout(),this;if(this._track.setX(e.x),this._track.setY(e.y),this._track.setSize({width:e.width,height:e.height}),this._indeterminate){let t=Math.max(20,Math.round(e.width*.25));this._fill.setX(0),this._fill.setY(0),this._fill.setSize({width:t,height:e.height})}else{let t=Math.round(e.width*this._value/100);this._fill.setX(0),this._fill.setY(0),this._fill.setSize({width:t,height:e.height})}return super.doLayout(),this}applyIndeterminate(e){e?(this._fill.setBackgroundColor(`var(--ts-ui-progress-indeterminate-bg, rgb(30, 100, 200))`),this._fill.setAnimation(`ts-ui-progress-indeterminate 1.4s ease-in-out infinite`)):(this._fill.setBackgroundColor(`var(--ts-ui-progress-fill-bg, rgb(30, 100, 200))`),this._fill.clearAnimation())}},le=a(ProgressBar);l.register(b,h,g,x);var PaginationBar=class extends s{_store;_firstBtn;_prevBtn;_nextBtn;_lastBtn;_pageText;_onStoreUpdate=()=>this.refresh();constructor(e,t){super(),this._store=e;let n=new d;n.setComponentSpacing(4),this.setLayoutManager(n),this._firstBtn=new m({glyph:`angles-left`}),this._prevBtn=new m({glyph:`angle-left`}),this._pageText=new u(`Page x of y`),this._nextBtn=new m({glyph:`angle-right`}),this._lastBtn=new m({glyph:`angles-right`}),this._firstBtn.setPreferredSize({width:28,height:28}),this._prevBtn.setPreferredSize({width:28,height:28}),this._nextBtn.setPreferredSize({width:28,height:28}),this._lastBtn.setPreferredSize({width:28,height:28}),this._pageText.centerInHeight(28),this._firstBtn.on(`action`,()=>{this._store.goToPage(1)}),this._prevBtn.on(`action`,()=>this._store.prevPage()),this._nextBtn.on(`action`,()=>this._store.nextPage()),this._lastBtn.on(`action`,()=>{let e=this._store.getTotalPages();this._store.goToPage(e??this._store.getPage())}),this.addComponent(this._firstBtn),this.addComponent(this._prevBtn),this.addComponent(this._pageText),this.addComponent(this._nextBtn),this.addComponent(this._lastBtn),this._store.on(`pagechange`,this._onStoreUpdate),this._store.on(`load`,this._onStoreUpdate),this._store.on(`datachange`,this._onStoreUpdate),this._store.on(`add`,this._onStoreUpdate),this._store.on(`remove`,this._onStoreUpdate),this._store.on(`sync`,this._onStoreUpdate),this.refresh(),t&&this.applyOptions(t)}applyOptions(e){return super.applyOptions(e),e.pageSize!==void 0&&this._store.setPageSize(e.pageSize),e.pageIndex!==void 0&&this._store.goToPage(e.pageIndex),this}destructor(){this._store.off(`pagechange`,this._onStoreUpdate),this._store.off(`load`,this._onStoreUpdate),this._store.off(`datachange`,this._onStoreUpdate),this._store.off(`add`,this._onStoreUpdate),this._store.off(`remove`,this._onStoreUpdate),this._store.off(`sync`,this._onStoreUpdate),super.destructor()}refresh(){let e=this._store.getPage(),t=this._store.getTotalPages(),n=this._store.hasPendingChanges(),r=t==null?`Page ${e}`:`Page ${e} of ${t}`;this._pageText.setText(r),this._firstBtn.setEnabled(!n&&e>1),this._prevBtn.setEnabled(!n&&e>1),this._nextBtn.setEnabled(!n&&(t==null||e<t)),this._lastBtn.setEnabled(!n&&t!=null&&e<t)}},ue=a(PaginationBar),de=[`timeupdate`,`play`,`pause`,`ended`,`loadedmetadata`,`durationchange`,`volumechange`,`ratechange`],fe=1,pe=1,X={tag:`video`},Video=class extends s{_listeners=new c;_mediaHandlers=new Map;constructor(e,t){super(e,{...X,...t??{}}),this.clearInsets(),this.getAria().setLabel(`Video`),this.buildMediaHandlers(),this.applyListeners(e?.listeners)}applyOptions(e){return super.applyOptions(e),e.src!==void 0&&this.setSrc(e.src),e.poster!==void 0&&this.setPoster(e.poster),e.autoplay!==void 0&&this.setAutoplay(e.autoplay),e.loop!==void 0&&this.setLoop(e.loop),e.preload!==void 0&&this.setPreload(e.preload),e.muted!==void 0&&this.setMuted(e.muted),e.volume!==void 0&&this.setVolume(e.volume),e.playbackRate!==void 0&&this.setPlaybackRate(e.playbackRate),this}getSrc(){return this._options.src??null}setSrc(e){return this._options.src=e,this.setElementAttribute(`src`,e),this}getPoster(){return this._options.poster??null}setPoster(e){return this._options.poster=e,this.setElementAttribute(`poster`,e),this}isAutoplay(){return this._options.autoplay??!1}setAutoplay(e){return this._options.autoplay=e,this.setElementAttribute(`autoplay`,e?``:null),this}isLoop(){return this._options.loop??!1}setLoop(e){return this._options.loop=e,this.setElementAttribute(`loop`,e?``:null),this}isMuted(){return this._options.muted??!1}setMuted(t){this._options.muted=t,this.setElementAttribute(`muted`,t?``:null);let n=this.getElement();return n&&e.sink.setMuted(n,t),this}getPreload(){return this._options.preload??null}setPreload(e){return this._options.preload=e,this.setElementAttribute(`preload`,e),this}getVolume(){return this._options.volume??fe}setVolume(t){let n=Math.max(0,Math.min(1,t));this._options.volume=n;let r=this.getElement();return r&&e.sink.setVolume(r,n),this}getPlaybackRate(){return this._options.playbackRate??pe}setPlaybackRate(t){this._options.playbackRate=t;let n=this.getElement();return n&&e.sink.setPlaybackRate(n,t),this}setCurrentTime(t){let n=this.getElement();return n&&e.sink.setCurrentTime(n,t),this}play(){let t=this.getElement();return t&&e.sink.mediaPlay(t),this}pause(){let t=this.getElement();return t&&e.sink.mediaPause(t),this}getMediaState(){let t=this.getElement();return t?e.source.getMediaState(t):{currentTime:0,duration:0,paused:!0,ended:!1,volume:this.getVolume(),muted:this.isMuted(),playbackRate:this.getPlaybackRate()}}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e){this._listeners.fire(e)}init(e){super.init(e);let t=e??this.getElement();return t?(this.replayMediaOptions(t),this.attachMediaListeners(t),this):this}destructor(){let t=this.getElement();if(t)for(let[n,r]of this._mediaHandlers)e.sink.removeListener(t,n,r);super.destructor()}buildMediaHandlers(){for(let e of de)this._mediaHandlers.set(e,()=>this.emit(e))}replayMediaOptions(t){let n=this._options,r={};n.src!==void 0&&(r.src=n.src),n.poster!==void 0&&(r.poster=n.poster),n.preload!==void 0&&(r.preload=n.preload),n.autoplay&&(r.autoplay=``),n.loop&&(r.loop=``),n.muted&&(r.muted=``),Object.keys(r).length>0&&e.sink.apply(t,{setAttr:r}),n.muted!==void 0&&e.sink.setMuted(t,n.muted),n.volume!==void 0&&e.sink.setVolume(t,n.volume),n.playbackRate!==void 0&&e.sink.setPlaybackRate(t,n.playbackRate)}attachMediaListeners(t){for(let[n,r]of this._mediaHandlers)e.sink.addListener(t,n,r)}},Z=a(Video),ProgressiveEngine=class{load(e,t){e.setSrc(t)}destroy(){}};l.register(S,C,w,T,E,D);var Q=28,$=80,me=28,he=.05,ge=6;function formatMediaTime(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e),n=t%60,r=Math.floor(t/60)%60,i=Math.floor(t/3600),a=String(n).padStart(2,`0`);return i>=1?`${i}:${String(r).padStart(2,`0`)}:${a}`:`${r}:${a}`}var VideoPlayer=class extends s{_video;_controls;_playBtn;_scrubber;_timeText;_muteBtn;_volume;_fullscreenBtn;_engine=new ProgressiveEngine;_playing=!1;_fullscreen=!1;_scrubbing=!1;_syncing=!1;_listeners=new c;_onPlayButton=()=>this.togglePlay();_onMuteButton=()=>this.setMuted(!this.isMuted());_onFullscreenButton=()=>this.toggleFullscreen();_onScrub=()=>this.beginScrub();_onVolumeChange=e=>this.onVolumeSlider(e);_onVideoPlay=()=>this.onVideoPlay();_onVideoPause=()=>this.onVideoPause();_onVideoEnded=()=>this.onVideoEnded();_onVideoTimeUpdate=()=>this.onVideoTimeUpdate();_onVideoSync=()=>this.syncFromVideo();_onFullscreenChange=()=>this.syncFullscreen();constructor(e){super(),this.setLayoutManager(new f),this.getAria().setRole(`region`),this.getAria().setLabel(`Video player`),this._video=new Z,this.buildControlBar(),this.wireControlListeners(),this.wireVideoListeners(),this.addComponent(this._video,{placement:p.CENTER}),this.addComponent(this._controls,{placement:p.SOUTH}),this.syncFromState(this._video.getMediaState()),e&&this.applyOptions(e),this.applyListeners(e?.listeners)}applyOptions(e){return super.applyOptions(e),e.engine!==void 0&&(this._engine=e.engine),e.src!==void 0&&this.setSrc(e.src),e.poster!==void 0&&this._video.setPoster(e.poster),e.autoplay!==void 0&&this._video.setAutoplay(e.autoplay),e.loop!==void 0&&this._video.setLoop(e.loop),e.muted!==void 0&&this._video.setMuted(e.muted),e.volume!==void 0&&this._video.setVolume(e.volume),e.playbackRate!==void 0&&this._video.setPlaybackRate(e.playbackRate),e.controls!==void 0&&this.setControlsVisible(e.controls),this}getSrc(){return this._video.getSrc()}setSrc(e){return this._engine.destroy(),this._engine.load(this._video,e),this}getVolume(){return this._video.getVolume()}setVolume(e){return this._video.setVolume(e),this.syncFromVideo(),this}isMuted(){return this._video.isMuted()}setMuted(e){return this._video.setMuted(e),this.syncFromVideo(),this}getPlaybackRate(){return this._video.getPlaybackRate()}setPlaybackRate(e){return this._video.setPlaybackRate(e),this}setCurrentTime(e){return this._video.setCurrentTime(e),this}getCurrentTime(){return this._video.getMediaState().currentTime}getDuration(){return this._video.getMediaState().duration}isPlaying(){return this._playing}play(){return this._video.play(),this}pause(){return this._video.pause(),this}togglePlay(){return this._playing?this.pause():this.play()}isControlsVisible(){return this._options.controls??!0}setControlsVisible(e){return this._options.controls=e,this._controls.setVisible(e),this}isFullscreen(){return this._fullscreen}enterFullscreen(){let t=this.getElement();return t&&e.sink.requestFullscreen(t),this}exitFullscreen(){return e.sink.exitFullscreen(),this}toggleFullscreen(){return this._fullscreen?this.exitFullscreen():this.enterFullscreen()}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e){this._listeners.fire(e)}init(t){super.init(t);let n=t??this.getElement();return n?(e.sink.addListener(n,`fullscreenchange`,this._onFullscreenChange),this.syncFromVideo(),this):this}destructor(){let t=this.getElement();t&&e.sink.removeListener(t,`fullscreenchange`,this._onFullscreenChange),super.destructor()}syncFromState(e){this._syncing=!0;try{this._scrubbing||(this._scrubber.setMax(e.duration||0),this._scrubber.setValue(e.currentTime)),this._timeText.setText(`${formatMediaTime(e.currentTime)} / ${formatMediaTime(e.duration)}`),this._playBtn.setGlyph(e.paused?`play`:`pause`),this._muteBtn.setGlyph(e.muted||e.volume===0?`volume-mute`:`volume-high`),this._volume.setValue(e.muted?0:e.volume)}finally{this._syncing=!1}}syncFromVideo(){this.syncFromState(this._video.getMediaState())}buildControlBar(){this._playBtn=this.makeControlButton(`play`,`Play`),this._muteBtn=this.makeControlButton(`volume-high`,`Mute`),this._fullscreenBtn=this.makeControlButton(`expand`,`Fullscreen`),this._scrubber=new v({min:0,max:0,value:0}),this._scrubber.getAria().setLabel(`Seek`),this._volume=new v({min:0,max:1,step:he,value:1}),this._volume.getAria().setLabel(`Volume`),this._volume.setPreferredSize({width:$,height:this._volume.getPreferredSize().height}),this._volume.setMaxSize({width:$,height:this._volume.getPreferredSize().height}),this._timeText=new u(`0:00 / 0:00`),this._timeText.centerInHeight(me);let e=new d;e.setComponentSpacing(ge),this._controls=new s,this._controls.setLayoutManager(e),this._controls.setBackgroundColor(`var(--ts-ui-body-bg, rgb(255, 255, 255))`),this._controls.addComponent(this._playBtn),this._controls.addComponent(this._scrubber,{weight:1}),this._controls.addComponent(this._timeText),this._controls.addComponent(this._muteBtn),this._controls.addComponent(this._volume),this._controls.addComponent(this._fullscreenBtn)}makeControlButton(e,t){let n=new m({glyph:e,text:t,showText:!1});return n.setPreferredSize({width:Q,height:Q}),n}wireControlListeners(){this._playBtn.on(`action`,this._onPlayButton),this._muteBtn.on(`action`,this._onMuteButton),this._fullscreenBtn.on(`action`,this._onFullscreenButton),this._scrubber.on(`action`,this._onScrub),this._volume.on(`change`,this._onVolumeChange)}wireVideoListeners(){this._video.on(`play`,this._onVideoPlay),this._video.on(`pause`,this._onVideoPause),this._video.on(`ended`,this._onVideoEnded),this._video.on(`timeupdate`,this._onVideoTimeUpdate),this._video.on(`durationchange`,this._onVideoSync),this._video.on(`loadedmetadata`,this._onVideoSync),this._video.on(`volumechange`,this._onVideoSync),this._video.on(`ratechange`,this._onVideoSync)}beginScrub(){this._syncing||(this._scrubbing=!0,this._video.setCurrentTime(this._scrubber.getValue()))}onVolumeSlider(e){this._syncing||(this._video.setVolume(e),this.syncFromVideo())}onVideoPlay(){this._playing=!0,this.syncFromVideo(),this.emit(`play`)}onVideoPause(){this._playing=!1,this.syncFromVideo(),this.emit(`pause`)}onVideoEnded(){this._playing=!1,this.syncFromVideo(),this.emit(`ended`)}onVideoTimeUpdate(){this.syncFromVideo(),this._scrubbing=!1}syncFullscreen(){let t=e.source.getFullscreenElement(),n=this.getElement();this._fullscreen=n!=null&&t===n,this._fullscreenBtn.setGlyph(this._fullscreen?`compress`:`expand`),this.doLayout()}getInnerSize(){if(this._fullscreen&&this.getElement()){let t=e.source.getViewportSize(),n=this.getPerimeterSize();return{width:t.width-n.left-n.right,height:t.height-n.top-n.bottom}}return super.getInnerSize()}},_e=a(VideoPlayer);export{ne as Canvas,l as Glyph,te as Header,ce as IconLabel,y as IconText,P as Image,oe as Markdown,ue as PaginationBar,le as ProgressBar,ee as ProgressSpinner,ProgressiveEngine,Z as Video,_e as VideoPlayer,ie as WebGLCanvas};
|
|
1
|
+
import{t as e}from"../DOM-67StIm5G.js";import{l as t,n}from"../Position-Ck_KD4cR.js";import{S as r,b as i,h as a,r as o,t as s}from"../Component-fRQvgaEY.js";import{t as c}from"../ListenerBag-WPdKuuds.js";import{t as l}from"../Glyph-wN7bk7mg.js";import{t as u}from"../Text-KB5LksJl.js";import{r as d}from"../VBox-P3WFGkPc.js";import{t as f}from"../Border-CKKUk5G9.js";import{t as ee}from"../ProgressSpinner-yt-VXyCb.js";import{t as p}from"../Placement-7kqdaK4Z.js";import{t as te}from"../Header-2hKwQo_u.js";import{t as m}from"../Button-MZDYJOMC.js";import{angle_left as h}from"../glyphs/solid/angle_left.es.js";import{angle_right as g}from"../glyphs/solid/angle_right.es.js";import{n as _,t as v}from"../Slider-DBnAZ-F7.js";import{t as y}from"../IconText-DC7Xe34b.js";import{angles_left as b}from"../glyphs/solid/angles_left.es.js";import{angles_right as x}from"../glyphs/solid/angles_right.es.js";import{play as S}from"../glyphs/solid/play.es.js";import{pause as C}from"../glyphs/solid/pause.es.js";import{volume_high as w}from"../glyphs/solid/volume_high.es.js";import{volume_mute as T}from"../glyphs/solid/volume_mute.es.js";import{expand as E}from"../glyphs/solid/expand.es.js";import{compress as D}from"../glyphs/solid/compress.es.js";import{lexer as O}from"marked";var k={tag:`canvas`,maxFps:30},A=-1,Canvas=class extends s{_ctx=null;_rafId=null;_animationStartMs=null;_lastDrawMs=null;_elapsedMs=0;_animationRequested=!1;_syncedWidth=A;_syncedHeight=A;_syncedDpr=A;_dprToken=0;constructor(e,t){super(e,{...k,...t??{}}),this.clearInsets()}applyOptions(e){return super.applyOptions(e),e.onDraw!==void 0&&this.setOnDraw(e.onDraw),e.animateWhenHidden!==void 0&&this.setAnimateWhenHidden(e.animateWhenHidden),e.maxFps!==void 0&&this.setMaxFps(e.maxFps),this}getContext(){if(this._ctx)return this._ctx;let t=this.getElement();return t?(this._ctx=e.sink.getContext(t,`2d`),this._ctx):null}setOnDraw(e){return this._options.onDraw=e??void 0,this.redraw(),this}getOnDraw(){return this._options.onDraw??this._defaultOptions.onDraw??null}redraw(){let e=this.getContext();if(!e)return this;let t=this.getWidth(),n=this.getHeight();return e.clearRect(0,0,t,n),this.getOnDraw()?.(e,t,n,this._elapsedMs),this}startAnimation(){return this._animationRequested=!0,this._animationStartMs=null,this._lastDrawMs=null,this._elapsedMs=0,this.reconcileAnimation(),this}stopAnimation(){return this._animationRequested=!1,this.reconcileAnimation(),this}isAnimating(){return this._rafId!==null}setAnimateWhenHidden(e){return this._options.animateWhenHidden=e,this.reconcileAnimation(),this}setMaxFps(e){return this._options.maxFps=Math.max(0,e),this}getMaxFps(){return this._options.maxFps??this._defaultOptions.maxFps??0}getAnimateWhenHidden(){return this._options.animateWhenHidden??this._defaultOptions.animateWhenHidden??!1}syncBackingStore(){let t=this.getContext();if(!t)return;let n=this.getWidth(),r=this.getHeight(),i=e.source.getDevicePixelRatio();if(n===this._syncedWidth&&r===this._syncedHeight&&i===this._syncedDpr)return;let a=this.getElement();e.sink.apply(a,{setAttr:{width:String(Math.round(n*i)),height:String(Math.round(r*i))}}),t.setTransform(i,0,0,i,0,0),this._syncedWidth=n,this._syncedHeight=r,this._syncedDpr=i,this.redraw()}doLayout(){return super.doLayout(),this.syncBackingStore(),this}render(){let e=super.render();return this.watchDevicePixelRatio(),e}destructor(){this.stopAnimation(),super.destructor()}shouldAnimate(){return this._animationRequested&&(this.getAnimateWhenHidden()||this.isEffectivelyVisible())}reconcileAnimation(){this.shouldAnimate()?this._rafId===null&&(this._rafId=e.sink.requestAnimationFrame(this.animationStep)):this._rafId!=null&&(e.sink.cancelAnimationFrame(this._rafId),this._rafId=null)}animationStep=t=>{if(!this._animationRequested){this._rafId=null;return}this._animationStartMs===null&&(this._animationStartMs=t);let n=this.getMaxFps(),r=n>0?1e3/n:0;(this._lastDrawMs===null||t-this._lastDrawMs>=r)&&(this._lastDrawMs=t,this._elapsedMs=t-this._animationStartMs,this.redraw()),this._rafId=e.sink.requestAnimationFrame(this.animationStep)};onEffectiveVisibilityChange(e){super.onEffectiveVisibilityChange(e),this.reconcileAnimation()}watchDevicePixelRatio(){let t=++this._dprToken,n=e.source.getDevicePixelRatio();e.source.matchMedia(`(resolution: ${n}dppx)`).addChangeListener(()=>this.onDevicePixelRatioChange(t))}onDevicePixelRatioChange(e){e===this._dprToken&&this.getElement()&&(this.syncBackingStore(),this.watchDevicePixelRatio())}},ne=a(Canvas),re={tag:`canvas`,maxFps:30},j=-1,WebGLCanvas=class extends s{_gl=null;_rafId=null;_animationStartMs=null;_lastDrawMs=null;_elapsedMs=0;_animationRequested=!1;_contextLost=!1;_syncedWidth=j;_syncedHeight=j;_syncedDpr=j;_dprToken=0;constructor(e,t){super(e,{...re,...t??{}}),this._contextInitialised=!1,this.clearInsets()}applyOptions(e){return super.applyOptions(e),e.onContextInit!==void 0&&this.setOnContextInit(e.onContextInit),e.onFrame!==void 0&&this.setOnFrame(e.onFrame),e.animateWhenHidden!==void 0&&this.setAnimateWhenHidden(e.animateWhenHidden),e.maxFps!==void 0&&this.setMaxFps(e.maxFps),this}getContext(){if(this._gl)return this._gl;let t=this.getElement();return t?(this._gl=e.sink.getContext(t,`webgl2`),this._gl):null}setOnContextInit(e){return this._options.onContextInit=e??void 0,this._contextInitialised=!1,this}getOnContextInit(){return this._options.onContextInit??this._defaultOptions.onContextInit??null}setOnFrame(e){return this._options.onFrame=e??void 0,this}getOnFrame(){return this._options.onFrame??this._defaultOptions.onFrame??null}startAnimation(){return this._animationRequested=!0,this._animationStartMs=null,this._lastDrawMs=null,this._elapsedMs=0,this.reconcileAnimation(),this}stopAnimation(){return this._animationRequested=!1,this.reconcileAnimation(),this}isAnimating(){return this._rafId!==null}setAnimateWhenHidden(e){return this._options.animateWhenHidden=e,this.reconcileAnimation(),this}getAnimateWhenHidden(){return this._options.animateWhenHidden??this._defaultOptions.animateWhenHidden??!1}setMaxFps(e){return this._options.maxFps=Math.max(0,e),this}getMaxFps(){return this._options.maxFps??this._defaultOptions.maxFps??0}syncBackingStore(){let t=this.getContext();if(!t)return;let n=this.getWidth(),r=this.getHeight(),i=e.source.getDevicePixelRatio();if(n===this._syncedWidth&&r===this._syncedHeight&&i===this._syncedDpr)return;let a=Math.round(n*i),o=Math.round(r*i);e.sink.apply(this.getElement(),{setAttr:{width:String(a),height:String(o)}}),t.viewport(0,0,a,o),this._syncedWidth=n,this._syncedHeight=r,this._syncedDpr=i,this.renderFrame()}doLayout(){return super.doLayout(),this.syncBackingStore(),this}render(){let e=super.render();return r.addListener(this,`webglcontextlost`,e=>{e.preventDefault(),this._contextLost=!0}),r.addListener(this,`webglcontextrestored`,()=>{this._contextLost=!1,this._contextInitialised=!1,this.syncBackingStore()}),this.watchDevicePixelRatio(),this.onFirstLayout(()=>this.startAnimation()),e}destructor(){this.stopAnimation(),super.destructor()}shouldAnimate(){return this._animationRequested&&(this.getAnimateWhenHidden()||this.isEffectivelyVisible())}reconcileAnimation(){this.shouldAnimate()?this._rafId===null&&(this._rafId=e.sink.requestAnimationFrame(this.animationStep)):this._rafId!=null&&(e.sink.cancelAnimationFrame(this._rafId),this._rafId=null)}animationStep=t=>{if(!this._animationRequested){this._rafId=null;return}this._animationStartMs===null&&(this._animationStartMs=t);let n=this.getMaxFps(),r=n>0?1e3/n:0;(this._lastDrawMs===null||t-this._lastDrawMs>=r)&&(this._lastDrawMs=t,this._elapsedMs=t-this._animationStartMs,this.renderFrame()),this._rafId=e.sink.requestAnimationFrame(this.animationStep)};onEffectiveVisibilityChange(e){super.onEffectiveVisibilityChange(e),this.reconcileAnimation()}renderFrame(){let e=this.getContext();!e||this._contextLost||(this._contextInitialised||=(this.getOnContextInit()?.(e),!0),this.getOnFrame()?.(e,this.getWidth(),this.getHeight(),this._elapsedMs))}watchDevicePixelRatio(){let t=++this._dprToken,n=e.source.getDevicePixelRatio();e.source.matchMedia(`(resolution: ${n}dppx)`).addChangeListener(()=>this.onDevicePixelRatioChange(t))}onDevicePixelRatioChange(e){e===this._dprToken&&this.getElement()&&(this.syncBackingStore(),this.watchDevicePixelRatio())}},ie=a(WebGLCanvas),M=100,N={tag:`img`},Image=class extends s{_src;constructor(e,t,n){super(t,{...N,...n??{}}),this._src=e,this.clearInsets()}getElement(e=!1){return super.getElement(e)}getPreferredSize(){let t=this.getElement(),n=e.source.getNaturalSize(t);return{width:n.width,height:n.height}}getMinSize(){let t=super.getMinSize();if(this._options.minSize)return t;let n=this.getElement();if(!n||!e.source.getNaturalSize(n).width)return{width:20,height:20};let r=e.source.getNaturalSize(n);return{width:Math.min(r.width,M),height:Math.min(r.height,M)}}render(){let t=super.render();return e.sink.apply(t,{setAttr:{src:this._src.valueOf()}}),t}},P=a(Image),F=`ts-ui-md-code`,I=`ts-ui-md-pre`,L=`ts-ui-md-quote`,R=`ts-ui-md-list`,z=`ts-ui-md-link`,B=`ts-ui-md-heading`,V=`ts-ui-md-table-wrap`,H=`ts-ui-md-table`,U=`ts-ui-md-th`,W=`ts-ui-md-td`,G=`ts-ui-md-align-left`,K=`ts-ui-md-align-center`,q=`ts-ui-md-align-right`,ae=1,J=6,Y=!1;function ensureMarkdownClassRules(){Y||(Y=!0,new i({scope:`class`,name:F,styles:{fontFamily:`var(--ts-ui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,background:`rgba(127, 127, 127, 0.16)`,borderRadius:`var(--ts-ui-border-radius, 3px)`,padding:`0.1em 0.3em`}}),new i({scope:`class`,name:I,styles:{fontFamily:`var(--ts-ui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,background:`rgba(127, 127, 127, 0.16)`,borderRadius:`var(--ts-ui-border-radius, 3px)`,padding:`0.6em 0.8em`,whiteSpace:`pre`,overflow:`auto`}}),new i({scope:`class`,name:L,styles:{borderLeft:`3px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,paddingLeft:`1em`,marginLeft:`0`}}),new i({scope:`class`,name:R,styles:{paddingLeft:`1.5em`}}),new i({scope:`class`,name:z,styles:{color:`var(--ts-ui-indicator-focus, #2563eb)`}}),new i({scope:`class`,name:B,styles:{fontWeight:`600`}}),new i({scope:`class`,name:V,styles:{maxWidth:`100%`,overflowX:`auto`}}),new i({scope:`class`,name:H,styles:{borderCollapse:`collapse`}}),new i({scope:`class`,name:U,styles:{border:`1px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,padding:`0.3em 0.6em`,fontWeight:`600`,textAlign:`left`}}),new i({scope:`class`,name:W,styles:{border:`1px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,padding:`0.3em 0.6em`}}),new i({scope:`class`,name:G,styles:{textAlign:`left`}}),new i({scope:`class`,name:K,styles:{textAlign:`center`}}),new i({scope:`class`,name:q,styles:{textAlign:`right`}}))}function alignmentClass(e){switch(e){case`left`:return G;case`center`:return K;case`right`:return q;default:return null}}function slugify(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function defaultLinkResolver(e){return{href:e,external:!0}}var Markdown=class extends s{_contentHandles=[];_measuredHeight=null;_unsubscribeTheme;constructor(e,t){super(t),e!==void 0&&this._options.markdown===void 0&&(this._options.markdown=e),this.setWhiteSpace(`normal`),this.setElementCSSRule(`overflowWrap`,`break-word`),this._unsubscribeTheme=o.onThemeChange(()=>this.measureContentHeight()),this.onFirstLayout(()=>this.measureContentHeight())}applyOptions(e){return super.applyOptions(e),e.markdown!==void 0&&(this._options.markdown=e.markdown),e.linkResolver!==void 0&&(this._options.linkResolver=e.linkResolver),this}getMarkdown(){return this._options.markdown??``}setLinkResolver(e){return this._options.linkResolver=e,this}getLinkResolver(){return this._options.linkResolver??defaultLinkResolver}setMarkdown(e){this._options.markdown=e;let t=this.getElement();return t?(this.clearContent(),ensureMarkdownClassRules(),this.appendBlockTokens(t,O(e),new Map),this.measureContentHeight(),this):this}getMinSize(){let e=super.getMinSize();return this._measuredHeight===null?e:e?{width:e.width,height:Math.max(e.height,this._measuredHeight)}:{width:0,height:this._measuredHeight}}getPreferredSize(){let e=super.getPreferredSize();return this._measuredHeight===null||this.getPreferredSizeConstraint()!==null?e:e?{width:e.width,height:this._measuredHeight}:{width:0,height:this._measuredHeight}}setWidth(e){let t=e!==this.getWidth();return super.setWidth(e),t&&this.measureContentHeight(),this}destructor(){this._unsubscribeTheme(),super.destructor()}measureContentHeight(){let t=this.getElement();if(!t)return;let n=this.getHeight();this.setElementStyle(`height`,`auto`),this.commitElementStyle();let r=this.getBorderSize(),i=e.source.getScrollMetrics(t).scrollHeight+r.top+r.bottom;this.setElementStyle(`height`,n+`px`),this.commitElementStyle(),i!==this._measuredHeight&&(this._measuredHeight=i,(this.getParentComponent()??this).scheduleLayout())}render(){let e=super.render();return ensureMarkdownClassRules(),this.appendBlockTokens(e,O(this.getMarkdown()),new Map),e}create(t){let n=e.sink.createElement(t);return this.trackHandle(n),this._contentHandles.push(n),n}clearContent(){for(let t of this._contentHandles)e.sink.removeElement(t),this.untrackHandle(t),e.sink.release(t);this._contentHandles.length=0}appendBlockTokens(e,t,n){for(let r of t)this.appendBlockToken(e,r,n)}appendBlockToken(e,t,n){switch(t.type){case`heading`:this.appendHeading(e,t,n);break;case`paragraph`:this.appendParagraph(e,t);break;case`list`:this.appendList(e,t,n);break;case`blockquote`:this.appendBlockquote(e,t,n);break;case`code`:this.appendCode(e,t);break;case`table`:this.appendTable(e,t);break;case`space`:break;default:this.appendTextNode(e,t.raw??``);break}}appendHeading(t,n,r){let i=Math.min(Math.max(n.depth,ae),J),a=this.create(`h`+i),o=slugify(n.text),s=r.get(o)??0;r.set(o,s+1);let c=s===0?o:`${o}-${s}`;e.sink.apply(a,{addClass:[B],setAttr:{id:c}}),this.appendInlineTokens(a,n.tokens),e.sink.appendChild(t,a)}appendParagraph(t,n){let r=this.create(`p`);this.appendInlineTokens(r,n.tokens),e.sink.appendChild(t,r)}appendList(t,n,r){let i=this.create(n.ordered?`ol`:`ul`);e.sink.apply(i,{addClass:[R]});for(let e of n.items)this.appendListItem(i,e,r);e.sink.appendChild(t,i)}appendListItem(t,n,r){let i=this.create(`li`);for(let e of n.tokens)if(e.type===`text`){let t=e;t.tokens&&t.tokens.length>0?this.appendInlineTokens(i,t.tokens):this.appendInlineToken(i,t,n.tokens.length===1)}else this.appendBlockToken(i,e,r);e.sink.appendChild(t,i)}appendTable(t,n){let r=this.create(`div`);e.sink.apply(r,{addClass:[V]});let i=this.create(`table`);e.sink.apply(i,{addClass:[H]});let a=this.create(`thead`);this.appendTableRow(a,n.header,!0),e.sink.appendChild(i,a);let o=this.create(`tbody`);for(let e of n.rows)this.appendTableRow(o,e,!1);e.sink.appendChild(i,o),e.sink.appendChild(r,i),e.sink.appendChild(t,r)}appendTableRow(t,n,r){let i=this.create(`tr`);for(let t of n){let n=this.create(r?`th`:`td`),a=[r?U:W],o=alignmentClass(t.align);o&&a.push(o),e.sink.apply(n,{addClass:a}),this.appendInlineTokens(n,t.tokens),e.sink.appendChild(i,n)}e.sink.appendChild(t,i)}appendBlockquote(t,n,r){let i=this.create(`blockquote`);e.sink.apply(i,{addClass:[L]}),this.appendBlockTokens(i,n.tokens,r),e.sink.appendChild(t,i)}appendCode(t,n){let r=this.create(`pre`);e.sink.apply(r,{addClass:[I]});let i=this.create(`code`);e.sink.apply(i,{text:n.text}),e.sink.appendChild(r,i),e.sink.appendChild(t,r)}appendInlineTokens(e,t){let n=t.length===1;for(let r of t)this.appendInlineToken(e,r,n)}appendInlineToken(t,n,r){switch(n.type){case`text`:{let i=n;i.tokens&&i.tokens.length>0?this.appendInlineTokens(t,i.tokens):r?e.sink.apply(t,{text:i.text}):this.appendTextNode(t,i.text);break}case`strong`:this.appendInlineWrapper(t,`strong`,n.tokens);break;case`em`:this.appendInlineWrapper(t,`em`,n.tokens);break;case`codespan`:{let r=this.create(`code`);e.sink.apply(r,{addClass:[F],text:n.text}),e.sink.appendChild(t,r);break}case`link`:this.appendLink(t,n);break;default:this.appendTextNode(t,n.text??n.raw??``);break}}appendInlineWrapper(t,n,r){let i=this.create(n);this.appendInlineTokens(i,r),e.sink.appendChild(t,i)}appendLink(t,n){let r=this.create(`a`),i=this.getLinkResolver()(n.href),a={href:i.href};i.external&&(a.target=`_blank`,a.rel=`noopener noreferrer`),e.sink.apply(r,{addClass:[z],setAttr:a}),this.appendInlineTokens(r,n.tokens),e.sink.appendChild(t,r)}appendTextNode(t,n){let r=this.create(`span`);e.sink.apply(r,{text:n}),e.sink.appendChild(t,r)}},oe=a(Markdown),se={gap:2,insets:new n(0,0,0,0)},IconLabel=class extends s{_glyph;_label;constructor(e,t,n,r,i){super(r,{...se,...i??{}}),this.setLayoutManager(new d({spacing:this.getGap()}));let a=this._options.glyph??e,o=this._options.text??t,s=this._options.forId??n;this._glyph=new l(a),this._label=new _(o,s),this.addComponent(this._glyph),this.addComponent(this._label),this._options.gap!==void 0&&this.getLayoutManager().setComponentSpacing(this._options.gap)}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),e.forId!==void 0&&(this._options.forId=e.forId),this}setGlyph(e){return this.removeComponent(this._glyph),this._glyph=new l(e),this.insertComponent(this._glyph,0),this}setText(e){return this._label.setText(e),this}setForId(e){return this._label.setForId(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}getLabelComponent(){return this._label}},ce=a(IconLabel);i.ensureKeyframes(`ts-ui-progress-indeterminate`,`0% { transform: translateX(-100%); } 100% { transform: translateX(400%); }`);var ProgressBar=class extends s{_track;_fill;_value;_indeterminate;constructor(e=0,n=!1,r){super(),this._value=t.clamp(e,0,100),this._indeterminate=n,this.setBackgroundColor(`var(--ts-ui-progress-track-bg, rgb(220, 220, 220))`),this.setBorderRadius(`var(--ts-ui-progress-track-radius, 4px)`),this._track=new s,this._track.setOverflow(`hidden`),this._track.setBorderRadius(`var(--ts-ui-progress-track-radius, 4px)`),this._fill=new s,this._fill.setBackgroundColor(`var(--ts-ui-progress-fill-bg, rgb(30, 100, 200))`),this._track.addComponent(this._fill),super.addComponent(this._track),this.getAria().setRole(`progressbar`),this.getAria().setValueMin(0),this.getAria().setValueMax(100),this.getAria().setValueNow(this._value),this._indeterminate&&this.applyIndeterminate(!0),r&&this.applyOptions(r)}applyOptions(e){return super.applyOptions(e),e.indeterminate!==void 0&&this.setIndeterminate(e.indeterminate),e.value!==void 0&&this.setValue(e.value),this}getBaseline(){let e=this.getPreferredSize();return e?e.height-2:null}getValue(){return this._indeterminate?0:this._value}setValue(e){let n=t.clamp(e,0,100);return n===this._value?this:(this._value=n,this.getAria().setValueNow(n),this._indeterminate||this.scheduleLayout(),this)}isIndeterminate(){return this._indeterminate}setIndeterminate(e){return this._indeterminate===e?this:(this._indeterminate=e,this.applyIndeterminate(e),this.flushLayout(),this)}doLayout(){let e=this.getContentBounds();if(!e)return super.doLayout(),this;if(this._track.setX(e.x),this._track.setY(e.y),this._track.setSize({width:e.width,height:e.height}),this._indeterminate){let t=Math.max(20,Math.round(e.width*.25));this._fill.setX(0),this._fill.setY(0),this._fill.setSize({width:t,height:e.height})}else{let t=Math.round(e.width*this._value/100);this._fill.setX(0),this._fill.setY(0),this._fill.setSize({width:t,height:e.height})}return super.doLayout(),this}applyIndeterminate(e){e?(this._fill.setBackgroundColor(`var(--ts-ui-progress-indeterminate-bg, rgb(30, 100, 200))`),this._fill.setAnimation(`ts-ui-progress-indeterminate 1.4s ease-in-out infinite`)):(this._fill.setBackgroundColor(`var(--ts-ui-progress-fill-bg, rgb(30, 100, 200))`),this._fill.clearAnimation())}},le=a(ProgressBar);l.register(b,h,g,x);var PaginationBar=class extends s{_store;_firstBtn;_prevBtn;_nextBtn;_lastBtn;_pageText;_onStoreUpdate=()=>this.refresh();constructor(e,t){super(),this._store=e;let n=new d;n.setComponentSpacing(4),this.setLayoutManager(n),this._firstBtn=new m({glyph:`angles-left`}),this._prevBtn=new m({glyph:`angle-left`}),this._pageText=new u(`Page x of y`),this._nextBtn=new m({glyph:`angle-right`}),this._lastBtn=new m({glyph:`angles-right`}),this._firstBtn.setPreferredSize({width:28,height:28}),this._prevBtn.setPreferredSize({width:28,height:28}),this._nextBtn.setPreferredSize({width:28,height:28}),this._lastBtn.setPreferredSize({width:28,height:28}),this._pageText.centerInHeight(28),this._firstBtn.on(`action`,()=>{this._store.goToPage(1)}),this._prevBtn.on(`action`,()=>this._store.prevPage()),this._nextBtn.on(`action`,()=>this._store.nextPage()),this._lastBtn.on(`action`,()=>{let e=this._store.getTotalPages();this._store.goToPage(e??this._store.getPage())}),this.addComponent(this._firstBtn),this.addComponent(this._prevBtn),this.addComponent(this._pageText),this.addComponent(this._nextBtn),this.addComponent(this._lastBtn),this._store.on(`pagechange`,this._onStoreUpdate),this._store.on(`load`,this._onStoreUpdate),this._store.on(`datachange`,this._onStoreUpdate),this._store.on(`add`,this._onStoreUpdate),this._store.on(`remove`,this._onStoreUpdate),this._store.on(`sync`,this._onStoreUpdate),this.refresh(),t&&this.applyOptions(t)}applyOptions(e){return super.applyOptions(e),e.pageSize!==void 0&&this._store.setPageSize(e.pageSize),e.pageIndex!==void 0&&this._store.goToPage(e.pageIndex),this}destructor(){this._store.off(`pagechange`,this._onStoreUpdate),this._store.off(`load`,this._onStoreUpdate),this._store.off(`datachange`,this._onStoreUpdate),this._store.off(`add`,this._onStoreUpdate),this._store.off(`remove`,this._onStoreUpdate),this._store.off(`sync`,this._onStoreUpdate),super.destructor()}refresh(){let e=this._store.getPage(),t=this._store.getTotalPages(),n=this._store.hasPendingChanges(),r=t==null?`Page ${e}`:`Page ${e} of ${t}`;this._pageText.setText(r),this._firstBtn.setEnabled(!n&&e>1),this._prevBtn.setEnabled(!n&&e>1),this._nextBtn.setEnabled(!n&&(t==null||e<t)),this._lastBtn.setEnabled(!n&&t!=null&&e<t)}},ue=a(PaginationBar),de=[`timeupdate`,`play`,`pause`,`ended`,`loadedmetadata`,`durationchange`,`volumechange`,`ratechange`],fe=1,pe=1,X={tag:`video`},Video=class extends s{_listeners=new c;_mediaHandlers=new Map;constructor(e,t){super(e,{...X,...t??{}}),this.clearInsets(),this.getAria().setLabel(`Video`),this.buildMediaHandlers(),this.applyListeners(e?.listeners)}applyOptions(e){return super.applyOptions(e),e.src!==void 0&&this.setSrc(e.src),e.poster!==void 0&&this.setPoster(e.poster),e.autoplay!==void 0&&this.setAutoplay(e.autoplay),e.loop!==void 0&&this.setLoop(e.loop),e.preload!==void 0&&this.setPreload(e.preload),e.muted!==void 0&&this.setMuted(e.muted),e.volume!==void 0&&this.setVolume(e.volume),e.playbackRate!==void 0&&this.setPlaybackRate(e.playbackRate),this}getSrc(){return this._options.src??null}setSrc(e){return this._options.src=e,this.setElementAttribute(`src`,e),this}getPoster(){return this._options.poster??null}setPoster(e){return this._options.poster=e,this.setElementAttribute(`poster`,e),this}isAutoplay(){return this._options.autoplay??!1}setAutoplay(e){return this._options.autoplay=e,this.setElementAttribute(`autoplay`,e?``:null),this}isLoop(){return this._options.loop??!1}setLoop(e){return this._options.loop=e,this.setElementAttribute(`loop`,e?``:null),this}isMuted(){return this._options.muted??!1}setMuted(t){this._options.muted=t,this.setElementAttribute(`muted`,t?``:null);let n=this.getElement();return n&&e.sink.setMuted(n,t),this}getPreload(){return this._options.preload??null}setPreload(e){return this._options.preload=e,this.setElementAttribute(`preload`,e),this}getVolume(){return this._options.volume??fe}setVolume(t){let n=Math.max(0,Math.min(1,t));this._options.volume=n;let r=this.getElement();return r&&e.sink.setVolume(r,n),this}getPlaybackRate(){return this._options.playbackRate??pe}setPlaybackRate(t){this._options.playbackRate=t;let n=this.getElement();return n&&e.sink.setPlaybackRate(n,t),this}setCurrentTime(t){let n=this.getElement();return n&&e.sink.setCurrentTime(n,t),this}play(){let t=this.getElement();return t&&e.sink.mediaPlay(t),this}pause(){let t=this.getElement();return t&&e.sink.mediaPause(t),this}getMediaState(){let t=this.getElement();return t?e.source.getMediaState(t):{currentTime:0,duration:0,paused:!0,ended:!1,volume:this.getVolume(),muted:this.isMuted(),playbackRate:this.getPlaybackRate()}}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e){this._listeners.fire(e)}init(e){super.init(e);let t=e??this.getElement();return t?(this.replayMediaOptions(t),this.attachMediaListeners(t),this):this}destructor(){let t=this.getElement();if(t)for(let[n,r]of this._mediaHandlers)e.sink.removeListener(t,n,r);super.destructor()}buildMediaHandlers(){for(let e of de)this._mediaHandlers.set(e,()=>this.emit(e))}replayMediaOptions(t){let n=this._options,r={};n.src!==void 0&&(r.src=n.src),n.poster!==void 0&&(r.poster=n.poster),n.preload!==void 0&&(r.preload=n.preload),n.autoplay&&(r.autoplay=``),n.loop&&(r.loop=``),n.muted&&(r.muted=``),Object.keys(r).length>0&&e.sink.apply(t,{setAttr:r}),n.muted!==void 0&&e.sink.setMuted(t,n.muted),n.volume!==void 0&&e.sink.setVolume(t,n.volume),n.playbackRate!==void 0&&e.sink.setPlaybackRate(t,n.playbackRate)}attachMediaListeners(t){for(let[n,r]of this._mediaHandlers)e.sink.addListener(t,n,r)}},Z=a(Video),ProgressiveEngine=class{load(e,t){e.setSrc(t)}destroy(){}};l.register(S,C,w,T,E,D);var Q=28,$=80,me=28,he=.05,ge=6;function formatMediaTime(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e),n=t%60,r=Math.floor(t/60)%60,i=Math.floor(t/3600),a=String(n).padStart(2,`0`);return i>=1?`${i}:${String(r).padStart(2,`0`)}:${a}`:`${r}:${a}`}var VideoPlayer=class extends s{_video;_controls;_playBtn;_scrubber;_timeText;_muteBtn;_volume;_fullscreenBtn;_engine=new ProgressiveEngine;_playing=!1;_fullscreen=!1;_scrubbing=!1;_syncing=!1;_listeners=new c;_onPlayButton=()=>this.togglePlay();_onMuteButton=()=>this.setMuted(!this.isMuted());_onFullscreenButton=()=>this.toggleFullscreen();_onScrub=()=>this.beginScrub();_onVolumeChange=e=>this.onVolumeSlider(e);_onVideoPlay=()=>this.onVideoPlay();_onVideoPause=()=>this.onVideoPause();_onVideoEnded=()=>this.onVideoEnded();_onVideoTimeUpdate=()=>this.onVideoTimeUpdate();_onVideoSync=()=>this.syncFromVideo();_onFullscreenChange=()=>this.syncFullscreen();constructor(e){super(),this.setLayoutManager(new f),this.getAria().setRole(`region`),this.getAria().setLabel(`Video player`),this._video=new Z,this.buildControlBar(),this.wireControlListeners(),this.wireVideoListeners(),this.addComponent(this._video,{placement:p.CENTER}),this.addComponent(this._controls,{placement:p.SOUTH}),this.syncFromState(this._video.getMediaState()),e&&this.applyOptions(e),this.applyListeners(e?.listeners)}applyOptions(e){return super.applyOptions(e),e.engine!==void 0&&(this._engine=e.engine),e.src!==void 0&&this.setSrc(e.src),e.poster!==void 0&&this._video.setPoster(e.poster),e.autoplay!==void 0&&this._video.setAutoplay(e.autoplay),e.loop!==void 0&&this._video.setLoop(e.loop),e.muted!==void 0&&this._video.setMuted(e.muted),e.volume!==void 0&&this._video.setVolume(e.volume),e.playbackRate!==void 0&&this._video.setPlaybackRate(e.playbackRate),e.controls!==void 0&&this.setControlsVisible(e.controls),this}getSrc(){return this._video.getSrc()}setSrc(e){return this._engine.destroy(),this._engine.load(this._video,e),this}getVolume(){return this._video.getVolume()}setVolume(e){return this._video.setVolume(e),this.syncFromVideo(),this}isMuted(){return this._video.isMuted()}setMuted(e){return this._video.setMuted(e),this.syncFromVideo(),this}getPlaybackRate(){return this._video.getPlaybackRate()}setPlaybackRate(e){return this._video.setPlaybackRate(e),this}setCurrentTime(e){return this._video.setCurrentTime(e),this}getCurrentTime(){return this._video.getMediaState().currentTime}getDuration(){return this._video.getMediaState().duration}isPlaying(){return this._playing}play(){return this._video.play(),this}pause(){return this._video.pause(),this}togglePlay(){return this._playing?this.pause():this.play()}isControlsVisible(){return this._options.controls??!0}setControlsVisible(e){return this._options.controls=e,this._controls.setVisible(e),this}isFullscreen(){return this._fullscreen}enterFullscreen(){let t=this.getElement();return t&&e.sink.requestFullscreen(t),this}exitFullscreen(){return e.sink.exitFullscreen(),this}toggleFullscreen(){return this._fullscreen?this.exitFullscreen():this.enterFullscreen()}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e){this._listeners.fire(e)}init(t){super.init(t);let n=t??this.getElement();return n?(e.sink.addListener(n,`fullscreenchange`,this._onFullscreenChange),this.syncFromVideo(),this):this}destructor(){let t=this.getElement();t&&e.sink.removeListener(t,`fullscreenchange`,this._onFullscreenChange),super.destructor()}syncFromState(e){this._syncing=!0;try{this._scrubbing||(this._scrubber.setMax(e.duration||0),this._scrubber.setValue(e.currentTime)),this._timeText.setText(`${formatMediaTime(e.currentTime)} / ${formatMediaTime(e.duration)}`),this._playBtn.setGlyph(e.paused?`play`:`pause`),this._muteBtn.setGlyph(e.muted||e.volume===0?`volume-mute`:`volume-high`),this._volume.setValue(e.muted?0:e.volume)}finally{this._syncing=!1}}syncFromVideo(){this.syncFromState(this._video.getMediaState())}buildControlBar(){this._playBtn=this.makeControlButton(`play`,`Play`),this._muteBtn=this.makeControlButton(`volume-high`,`Mute`),this._fullscreenBtn=this.makeControlButton(`expand`,`Fullscreen`),this._scrubber=new v({min:0,max:0,value:0}),this._scrubber.getAria().setLabel(`Seek`),this._volume=new v({min:0,max:1,step:he,value:1}),this._volume.getAria().setLabel(`Volume`),this._volume.setPreferredSize({width:$,height:this._volume.getPreferredSize().height}),this._volume.setMaxSize({width:$,height:this._volume.getPreferredSize().height}),this._timeText=new u(`0:00 / 0:00`),this._timeText.centerInHeight(me);let e=new d;e.setComponentSpacing(ge),this._controls=new s,this._controls.setLayoutManager(e),this._controls.setBackgroundColor(`var(--ts-ui-body-bg, rgb(255, 255, 255))`),this._controls.addComponent(this._playBtn),this._controls.addComponent(this._scrubber,{weight:1}),this._controls.addComponent(this._timeText),this._controls.addComponent(this._muteBtn),this._controls.addComponent(this._volume),this._controls.addComponent(this._fullscreenBtn)}makeControlButton(e,t){let n=new m({glyph:e,text:t,showText:!1});return n.setPreferredSize({width:Q,height:Q}),n}wireControlListeners(){this._playBtn.on(`action`,this._onPlayButton),this._muteBtn.on(`action`,this._onMuteButton),this._fullscreenBtn.on(`action`,this._onFullscreenButton),this._scrubber.on(`action`,this._onScrub),this._volume.on(`change`,this._onVolumeChange)}wireVideoListeners(){this._video.on(`play`,this._onVideoPlay),this._video.on(`pause`,this._onVideoPause),this._video.on(`ended`,this._onVideoEnded),this._video.on(`timeupdate`,this._onVideoTimeUpdate),this._video.on(`durationchange`,this._onVideoSync),this._video.on(`loadedmetadata`,this._onVideoSync),this._video.on(`volumechange`,this._onVideoSync),this._video.on(`ratechange`,this._onVideoSync)}beginScrub(){this._syncing||(this._scrubbing=!0,this._video.setCurrentTime(this._scrubber.getValue()))}onVolumeSlider(e){this._syncing||(this._video.setVolume(e),this.syncFromVideo())}onVideoPlay(){this._playing=!0,this.syncFromVideo(),this.emit(`play`)}onVideoPause(){this._playing=!1,this.syncFromVideo(),this.emit(`pause`)}onVideoEnded(){this._playing=!1,this.syncFromVideo(),this.emit(`ended`)}onVideoTimeUpdate(){this.syncFromVideo(),this._scrubbing=!1}syncFullscreen(){let t=e.source.getFullscreenElement(),n=this.getElement();this._fullscreen=n!=null&&t===n,this._fullscreenBtn.setGlyph(this._fullscreen?`compress`:`expand`),this.doLayout()}getInnerSize(){if(this._fullscreen&&this.getElement()){let t=e.source.getViewportSize(),n=this.getPerimeterSize();return{width:t.width-n.left-n.right,height:t.height-n.top-n.bottom}}return super.getInnerSize()}},_e=a(VideoPlayer);export{ne as Canvas,l as Glyph,te as Header,ce as IconLabel,y as IconText,P as Image,oe as Markdown,ue as PaginationBar,le as ProgressBar,ee as ProgressSpinner,ProgressiveEngine,Z as Video,_e as VideoPlayer,ie as WebGLCanvas};
|
|
2
2
|
//# sourceMappingURL=display.es.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"../DOM-67StIm5G.js";import{n as t}from"../Position-Ck_KD4cR.js";import{b as n,h as r,r as i,t as a,v as o}from"../Component-DHqrPwAw.js";import{t as s}from"../ListenerBag-WPdKuuds.js";import{t as c}from"../Card-BdfbvOD_.js";import{EditorView as l,drawSelection as u,highlightActiveLine as ee,highlightActiveLineGutter as te,keymap as ne,lineNumbers as re}from"@codemirror/view";import{Compartment as d,EditorState as f}from"@codemirror/state";import{defaultKeymap as ie,history as p,historyKeymap as ae,indentWithTab as oe}from"@codemirror/commands";import{HighlightStyle as se,bracketMatching as ce,indentOnInput as le,indentRange as ue,syntaxHighlighting as de}from"@codemirror/language";import{tags as m}from"@lezer/highlight";import{$createParagraphNode as fe,$getRoot as pe,$getSelection as h,$isRangeSelection as g,FORMAT_TEXT_COMMAND as _,createEditor as me}from"lexical";import{$convertFromMarkdownString as v,$convertToMarkdownString as y,BOLD_STAR as he,CODE as ge,HEADING as _e,INLINE_CODE as ve,ITALIC_STAR as ye,LINK as be,ORDERED_LIST as xe,QUOTE as Se,UNORDERED_LIST as Ce,registerMarkdownShortcuts as we}from"@lexical/markdown";import{$createHeadingNode as b,$createQuoteNode as x,HeadingNode as S,QuoteNode as C,registerRichText as w}from"@lexical/rich-text";import{INSERT_ORDERED_LIST_COMMAND as T,INSERT_UNORDERED_LIST_COMMAND as E,ListItemNode as D,ListNode as O,registerList as k}from"@lexical/list";import{$toggleLink as Te,LinkNode as Ee}from"@lexical/link";import{$createCodeNode as De,CodeHighlightNode as Oe,CodeNode as ke}from"@lexical/code";import{createEmptyHistoryState as Ae,registerHistory as je}from"@lexical/history";import{$createTableCellNode as Me,$createTableNode as Ne,$createTableRowNode as Pe,$deleteTableColumnAtSelection as Fe,$deleteTableRowAtSelection as Ie,$getTableCellNodeFromLexicalNode as Le,$insertTableColumnAtSelection as Re,$insertTableRowAtSelection as ze,$isTableCellNode as A,$isTableNode as Be,$isTableRowNode as Ve,INSERT_TABLE_COMMAND as He,TableCellHeaderStates as j,TableCellNode as M,TableNode as N,TableRowNode as P,registerTableCellUnmergeTransform as Ue,registerTablePlugin as We,registerTableSelectionObserver as Ge}from"@lexical/table";import{mergeRegister as Ke}from"@lexical/utils";import{$setBlocksType as qe}from"@lexical/selection";var F=new Map;function registerLanguage(e){F.set(e.id,e)}function getLanguage(e){return F.get(e)}function listLanguages(){return Array.from(F.values())}function formatWithPrettier(e,t){return async(n,r)=>{let[{formatWithCursor:i},a]=await Promise.all([import(`prettier/standalone`),t()]);return i(n,{parser:e,plugins:a,cursorOffset:r})}}var formatWithSql=async(e,t)=>{let{format:n}=await import(`sql-formatter`),r=n(e);return{formatted:r,cursorOffset:Math.min(t,r.length)}};async function loadBabelPlugins(){let[e,t]=await Promise.all([import(`prettier/plugins/babel`),import(`prettier/plugins/estree`)]);return[e,t]}registerLanguage({id:`javascript`,label:`JavaScript / TypeScript`,loadExtension:async()=>{let{javascript:e}=await import(`@codemirror/lang-javascript`);return e({typescript:!0})},loadFormatter:async()=>formatWithPrettier(`babel-ts`,loadBabelPlugins)}),registerLanguage({id:`json`,label:`JSON`,loadExtension:async()=>{let{json:e}=await import(`@codemirror/lang-json`);return e()},loadFormatter:async()=>formatWithPrettier(`json`,loadBabelPlugins)}),registerLanguage({id:`html`,label:`HTML`,loadExtension:async()=>{let{html:e}=await import(`@codemirror/lang-html`);return e()},loadFormatter:async()=>formatWithPrettier(`html`,async()=>[await import(`prettier/plugins/html`)])}),registerLanguage({id:`sql`,label:`SQL`,loadExtension:async()=>{let{sql:e}=await import(`@codemirror/lang-sql`);return e()},loadFormatter:async()=>formatWithSql}),registerLanguage({id:`markdown`,label:`Markdown`,loadExtension:async()=>{let{markdown:e}=await import(`@codemirror/lang-markdown`);return e()},loadFormatter:async()=>formatWithPrettier(`markdown`,async()=>[await import(`prettier/plugins/markdown`)])});var I=`#2563eb`,L=`#16a34a`,R=`#6b7280`,Je=`#d97706`,Ye=`#7c3aed`,Xe=`#0891b2`,Ze=`#be185d`;function codeEditorTheme(e){return[l.theme({"&":{height:`100%`,color:`var(--ts-ui-text-color, #1a1a1a)`,backgroundColor:`var(--ts-ui-input-bg, #ffffff)`},".cm-content":{fontFamily:`var(--ts-ui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,caretColor:`var(--ts-ui-indicator-focus, #2563eb)`,cursor:`text`},".cm-gutters":{color:`var(--ts-ui-text-color, #1a1a1a)`,backgroundColor:`var(--ts-ui-input-bg, #ffffff)`,borderRight:`1px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`},"&.cm-focused .cm-cursor":{borderLeftColor:`var(--ts-ui-indicator-focus, #2563eb)`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:`var(--ts-ui-indicator-selection, rgba(37, 99, 235, 0.25))`},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:`rgba(127, 127, 127, 0.08)`}},{dark:e}),de(se.define([{tag:m.keyword,color:I},{tag:[m.string,m.special(m.string)],color:L},{tag:m.comment,color:R,fontStyle:`italic`},{tag:[m.number,m.bool,m.null],color:Je},{tag:[m.definition(m.variableName),m.function(m.variableName)],color:Ye},{tag:m.typeName,color:Xe},{tag:[m.propertyName,m.attributeName],color:Ze},{tag:m.tagName,color:I},{tag:[m.heading,m.heading1,m.heading2,m.heading3,m.heading4,m.heading5,m.heading6],color:I,fontWeight:`bold`},{tag:m.strong,fontWeight:`bold`},{tag:m.emphasis,fontStyle:`italic`},{tag:m.monospace,color:L},{tag:[m.link,m.url],color:I,textDecoration:`underline`},{tag:[m.quote,m.contentSeparator],color:R},{tag:m.processingInstruction,color:R}]))]}var Qe={overflow:`auto`},$e=`.cm-scroller`,et=300,tt=.16,nt=`var(--ts-ui-validation-error-border, #dc2626)`;function buildReadOnlyExtension(e){return f.readOnly.of(e)}var CodeEditor=class extends a{_view=null;_flashOverlay=null;_flashAnimation=null;_langCompartment=new d;_readOnlyCompartment=new d;_themeCompartment=new d;_listeners=new s;_unsubscribeTheme;_scrollElement=null;constructor(e,t,n){super(t,{...Qe,...n??{}}),e!==void 0&&this._options.value===void 0&&(this._options.value=e),this._unsubscribeTheme=i.onThemeChange(()=>this.onThemeChange()),this.applyListeners(t?.listeners),this.onFirstLayout(()=>this.mount())}applyOptions(e){return super.applyOptions(e),e.value!==void 0&&(this._options.value=e.value),e.language!==void 0&&(this._options.language=e.language),e.readOnly!==void 0&&(this._options.readOnly=e.readOnly),this}getValue(){return this._view?this._view.state.doc.toString():this._options.value??``}setValue(e){return this._options.value=e,this._view&&this._view.dispatch({changes:{from:0,to:this._view.state.doc.length,insert:e}}),this}getLanguage(){return this._options.language??null}setLanguage(e){if(this._options.language=e??void 0,!this._view)return this;if(!e)return this._view.dispatch({effects:this._langCompartment.reconfigure([])}),this;let t=getLanguage(e);return t&&t.loadExtension().then(t=>{this._view&&this.getLanguage()===e&&this._view.dispatch({effects:this._langCompartment.reconfigure(t)})}),this}getReadOnly(){return this._options.readOnly??!1}setReadOnly(e){return this._options.readOnly=e,this._view&&this._view.dispatch({effects:this._readOnlyCompartment.reconfigure(buildReadOnlyExtension(e))}),this}focus(e=!1){return this._view?(this._view.focus(),this):super.focus(e)}moveCursorToEnd(){if(this._view){let e=this._view.state.doc.length;this._view.dispatch({selection:{anchor:e},scrollIntoView:!0})}return this}async format(){let e=this.getLanguage(),t=e?getLanguage(e):void 0;if(!t?.loadFormatter){this.reindentFallback();return}let n=await(await t.loadFormatter())(this.getValue(),this._view?this._view.state.selection.main.head:0);this._options.value=n.formatted,this._view&&this._view.dispatch({changes:{from:0,to:this._view.state.doc.length,insert:n.formatted},selection:{anchor:Math.min(n.cursorOffset,n.formatted.length)}})}reindentFallback(){this._view&&this._view.dispatch({changes:ue(this._view.state,0,this._view.state.doc.length)})}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?[t]:[])}destructor(){this._flashAnimation?.cancel(),this._flashAnimation=null,this._unsubscribeTheme(),this._scrollElement=null,this._view?.destroy(),this._view=null,super.destructor()}getScrollElement(){return this._scrollElement??super.getScrollElement()}mount(){if(this._view)return;let t=this.getElement();if(!t)return;let n=i.getTheme().colorScheme===`dark`,r=[p(),ne.of([...ie,...ae,oe]),u(),re(),ee(),te(),le(),ce(),this._readOnlyCompartment.of(buildReadOnlyExtension(this.getReadOnly())),this._themeCompartment.of(codeEditorTheme(n)),this._langCompartment.of([]),l.updateListener.of(e=>{e.docChanged&&(this._options.value=e.state.doc.toString(),this.emit(`change`,{value:this._options.value}))}),l.domEventHandlers({beforeinput:()=>this.onEditIntent(),paste:()=>this.onEditIntent(),drop:()=>this.onEditIntent()})],a=f.create({doc:this._options.value??``,extensions:r});this._view=e.sink.mountView(t,e=>new l({parent:e,state:a})),this._view&&(this.mountFlashOverlay(t),this._scrollElement=e.source.querySelector(t,$e));let o=this.getLanguage();o&&this.setLanguage(o)}mountFlashOverlay(t){let n=this.trackHandle(e.sink.createElement(`div`));e.sink.apply(n,{style:{position:`absolute`,inset:`0`,pointerEvents:`none`,zIndex:`300`,backgroundColor:nt,opacity:`0`}}),e.sink.appendChild(t,n),this._flashOverlay=n}onThemeChange(){if(!this._view)return;let e=i.getTheme().colorScheme===`dark`;this._view.dispatch({effects:this._themeCompartment.reconfigure(codeEditorTheme(e))})}onEditIntent(){return this.getReadOnly()&&this.signalReadOnlyEdit(),!1}signalReadOnlyEdit(){this.emit(`readonlyedit`),this.flashReadOnly()}flashReadOnly(){this._flashOverlay&&(this._flashAnimation?.cancel(),this._flashAnimation=o.play(this._flashOverlay,{from:{opacity:String(tt)},to:{opacity:`0`},durationMs:et,properties:[`opacity`]}))}},z=r(CodeEditor),rt=/\|/;function splitTableRow(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;e<t.length;e+=1){let i=t[e];i===`\\`&&t[e+1]===`|`?(r+=`|`,e+=1):i===`|`?(n.push(r.trim()),r=``):r+=i}return n.push(r.trim()),n}function parseDelimiterRow(e){let t=splitTableRow(e),n=[];for(let e of t){if(!/^:?-+:?$/.test(e))return null;let t=e.startsWith(`:`),r=e.endsWith(`:`);t&&r?n.push(`center`):t?n.push(`left`):r?n.push(`right`):n.push(``)}return n}function formatDelimiterRow(e){return`| `+e.map(e=>{switch(e){case`left`:return`:---`;case`center`:return`:---:`;case`right`:return`---:`;default:return`---`}}).join(` | `)+` |`}function escapeCellText(e){return e.trim().replace(/\|/g,`\\|`).replace(/\n/g,`\\n`)}function createTableTransformer(e){return{dependencies:[N,P,M],regExpStart:rt,type:`multiline-element`,handleImportAfterStartMatch:({lines:t,rootNode:n,startLineIndex:r})=>{let i=t[r+1];if(i===void 0)return null;let a=parseDelimiterRow(i);if(a===null)return null;let o=splitTableRow(t[r]),s=o.length;if(a.length!==s)return null;let c=[o],l=r+1;for(let e=r+2;e<t.length;e+=1){let n=t[e];if(n.trim()===``)break;c.push(splitTableRow(n)),l=e}let u=Ne();return c.forEach((t,n)=>{let r=Pe();for(let i=0;i<s;i+=1){let o=Me(n===0?j.ROW:j.NO_STATUS);v((t[i]??``).replace(/\\n/g,`
|
|
1
|
+
import{t as e}from"../DOM-67StIm5G.js";import{n as t}from"../Position-Ck_KD4cR.js";import{b as n,h as r,r as i,t as a,v as o}from"../Component-fRQvgaEY.js";import{t as s}from"../ListenerBag-WPdKuuds.js";import{t as c}from"../Card-a4dzYrbX.js";import{EditorView as l,drawSelection as u,highlightActiveLine as ee,highlightActiveLineGutter as te,keymap as ne,lineNumbers as re}from"@codemirror/view";import{Compartment as d,EditorState as f}from"@codemirror/state";import{defaultKeymap as ie,history as p,historyKeymap as ae,indentWithTab as oe}from"@codemirror/commands";import{HighlightStyle as se,bracketMatching as ce,indentOnInput as le,indentRange as ue,syntaxHighlighting as de}from"@codemirror/language";import{tags as m}from"@lezer/highlight";import{$createParagraphNode as fe,$getRoot as pe,$getSelection as h,$isRangeSelection as g,FORMAT_TEXT_COMMAND as _,createEditor as me}from"lexical";import{$convertFromMarkdownString as v,$convertToMarkdownString as y,BOLD_STAR as he,CODE as ge,HEADING as _e,INLINE_CODE as ve,ITALIC_STAR as ye,LINK as be,ORDERED_LIST as xe,QUOTE as Se,UNORDERED_LIST as Ce,registerMarkdownShortcuts as we}from"@lexical/markdown";import{$createHeadingNode as b,$createQuoteNode as x,HeadingNode as S,QuoteNode as C,registerRichText as w}from"@lexical/rich-text";import{INSERT_ORDERED_LIST_COMMAND as T,INSERT_UNORDERED_LIST_COMMAND as E,ListItemNode as D,ListNode as O,registerList as k}from"@lexical/list";import{$toggleLink as Te,LinkNode as Ee}from"@lexical/link";import{$createCodeNode as De,CodeHighlightNode as Oe,CodeNode as ke}from"@lexical/code";import{createEmptyHistoryState as Ae,registerHistory as je}from"@lexical/history";import{$createTableCellNode as Me,$createTableNode as Ne,$createTableRowNode as Pe,$deleteTableColumnAtSelection as Fe,$deleteTableRowAtSelection as Ie,$getTableCellNodeFromLexicalNode as Le,$insertTableColumnAtSelection as Re,$insertTableRowAtSelection as ze,$isTableCellNode as A,$isTableNode as Be,$isTableRowNode as Ve,INSERT_TABLE_COMMAND as He,TableCellHeaderStates as j,TableCellNode as M,TableNode as N,TableRowNode as P,registerTableCellUnmergeTransform as Ue,registerTablePlugin as We,registerTableSelectionObserver as Ge}from"@lexical/table";import{mergeRegister as Ke}from"@lexical/utils";import{$setBlocksType as qe}from"@lexical/selection";var F=new Map;function registerLanguage(e){F.set(e.id,e)}function getLanguage(e){return F.get(e)}function listLanguages(){return Array.from(F.values())}function formatWithPrettier(e,t){return async(n,r)=>{let[{formatWithCursor:i},a]=await Promise.all([import(`prettier/standalone`),t()]);return i(n,{parser:e,plugins:a,cursorOffset:r})}}var formatWithSql=async(e,t)=>{let{format:n}=await import(`sql-formatter`),r=n(e);return{formatted:r,cursorOffset:Math.min(t,r.length)}};async function loadBabelPlugins(){let[e,t]=await Promise.all([import(`prettier/plugins/babel`),import(`prettier/plugins/estree`)]);return[e,t]}registerLanguage({id:`javascript`,label:`JavaScript / TypeScript`,loadExtension:async()=>{let{javascript:e}=await import(`@codemirror/lang-javascript`);return e({typescript:!0})},loadFormatter:async()=>formatWithPrettier(`babel-ts`,loadBabelPlugins)}),registerLanguage({id:`json`,label:`JSON`,loadExtension:async()=>{let{json:e}=await import(`@codemirror/lang-json`);return e()},loadFormatter:async()=>formatWithPrettier(`json`,loadBabelPlugins)}),registerLanguage({id:`html`,label:`HTML`,loadExtension:async()=>{let{html:e}=await import(`@codemirror/lang-html`);return e()},loadFormatter:async()=>formatWithPrettier(`html`,async()=>[await import(`prettier/plugins/html`)])}),registerLanguage({id:`sql`,label:`SQL`,loadExtension:async()=>{let{sql:e}=await import(`@codemirror/lang-sql`);return e()},loadFormatter:async()=>formatWithSql}),registerLanguage({id:`markdown`,label:`Markdown`,loadExtension:async()=>{let{markdown:e}=await import(`@codemirror/lang-markdown`);return e()},loadFormatter:async()=>formatWithPrettier(`markdown`,async()=>[await import(`prettier/plugins/markdown`)])});var I=`#2563eb`,L=`#16a34a`,R=`#6b7280`,Je=`#d97706`,Ye=`#7c3aed`,Xe=`#0891b2`,Ze=`#be185d`;function codeEditorTheme(e){return[l.theme({"&":{height:`100%`,color:`var(--ts-ui-text-color, #1a1a1a)`,backgroundColor:`var(--ts-ui-input-bg, #ffffff)`},".cm-content":{fontFamily:`var(--ts-ui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,caretColor:`var(--ts-ui-indicator-focus, #2563eb)`,cursor:`text`},".cm-gutters":{color:`var(--ts-ui-text-color, #1a1a1a)`,backgroundColor:`var(--ts-ui-input-bg, #ffffff)`,borderRight:`1px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`},"&.cm-focused .cm-cursor":{borderLeftColor:`var(--ts-ui-indicator-focus, #2563eb)`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:`var(--ts-ui-indicator-selection, rgba(37, 99, 235, 0.25))`},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:`rgba(127, 127, 127, 0.08)`}},{dark:e}),de(se.define([{tag:m.keyword,color:I},{tag:[m.string,m.special(m.string)],color:L},{tag:m.comment,color:R,fontStyle:`italic`},{tag:[m.number,m.bool,m.null],color:Je},{tag:[m.definition(m.variableName),m.function(m.variableName)],color:Ye},{tag:m.typeName,color:Xe},{tag:[m.propertyName,m.attributeName],color:Ze},{tag:m.tagName,color:I},{tag:[m.heading,m.heading1,m.heading2,m.heading3,m.heading4,m.heading5,m.heading6],color:I,fontWeight:`bold`},{tag:m.strong,fontWeight:`bold`},{tag:m.emphasis,fontStyle:`italic`},{tag:m.monospace,color:L},{tag:[m.link,m.url],color:I,textDecoration:`underline`},{tag:[m.quote,m.contentSeparator],color:R},{tag:m.processingInstruction,color:R}]))]}var Qe={overflow:`auto`},$e=`.cm-scroller`,et=300,tt=.16,nt=`var(--ts-ui-validation-error-border, #dc2626)`;function buildReadOnlyExtension(e){return f.readOnly.of(e)}var CodeEditor=class extends a{_view=null;_flashOverlay=null;_flashAnimation=null;_langCompartment=new d;_readOnlyCompartment=new d;_themeCompartment=new d;_listeners=new s;_unsubscribeTheme;_scrollElement=null;constructor(e,t,n){super(t,{...Qe,...n??{}}),e!==void 0&&this._options.value===void 0&&(this._options.value=e),this._unsubscribeTheme=i.onThemeChange(()=>this.onThemeChange()),this.applyListeners(t?.listeners),this.onFirstLayout(()=>this.mount())}applyOptions(e){return super.applyOptions(e),e.value!==void 0&&(this._options.value=e.value),e.language!==void 0&&(this._options.language=e.language),e.readOnly!==void 0&&(this._options.readOnly=e.readOnly),this}getValue(){return this._view?this._view.state.doc.toString():this._options.value??``}setValue(e){return this._options.value=e,this._view&&this._view.dispatch({changes:{from:0,to:this._view.state.doc.length,insert:e}}),this}getLanguage(){return this._options.language??null}setLanguage(e){if(this._options.language=e??void 0,!this._view)return this;if(!e)return this._view.dispatch({effects:this._langCompartment.reconfigure([])}),this;let t=getLanguage(e);return t&&t.loadExtension().then(t=>{this._view&&this.getLanguage()===e&&this._view.dispatch({effects:this._langCompartment.reconfigure(t)})}),this}getReadOnly(){return this._options.readOnly??!1}setReadOnly(e){return this._options.readOnly=e,this._view&&this._view.dispatch({effects:this._readOnlyCompartment.reconfigure(buildReadOnlyExtension(e))}),this}focus(e=!1){return this._view?(this._view.focus(),this):super.focus(e)}moveCursorToEnd(){if(this._view){let e=this._view.state.doc.length;this._view.dispatch({selection:{anchor:e},scrollIntoView:!0})}return this}async format(){let e=this.getLanguage(),t=e?getLanguage(e):void 0;if(!t?.loadFormatter){this.reindentFallback();return}let n=await(await t.loadFormatter())(this.getValue(),this._view?this._view.state.selection.main.head:0);this._options.value=n.formatted,this._view&&this._view.dispatch({changes:{from:0,to:this._view.state.doc.length,insert:n.formatted},selection:{anchor:Math.min(n.cursorOffset,n.formatted.length)}})}reindentFallback(){this._view&&this._view.dispatch({changes:ue(this._view.state,0,this._view.state.doc.length)})}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?[t]:[])}destructor(){this._flashAnimation?.cancel(),this._flashAnimation=null,this._unsubscribeTheme(),this._scrollElement=null,this._view?.destroy(),this._view=null,super.destructor()}getScrollElement(){return this._scrollElement??super.getScrollElement()}mount(){if(this._view)return;let t=this.getElement();if(!t)return;let n=i.getTheme().colorScheme===`dark`,r=[p(),ne.of([...ie,...ae,oe]),u(),re(),ee(),te(),le(),ce(),this._readOnlyCompartment.of(buildReadOnlyExtension(this.getReadOnly())),this._themeCompartment.of(codeEditorTheme(n)),this._langCompartment.of([]),l.updateListener.of(e=>{e.docChanged&&(this._options.value=e.state.doc.toString(),this.emit(`change`,{value:this._options.value}))}),l.domEventHandlers({beforeinput:()=>this.onEditIntent(),paste:()=>this.onEditIntent(),drop:()=>this.onEditIntent()})],a=f.create({doc:this._options.value??``,extensions:r});this._view=e.sink.mountView(t,e=>new l({parent:e,state:a})),this._view&&(this.mountFlashOverlay(t),this._scrollElement=e.source.querySelector(t,$e));let o=this.getLanguage();o&&this.setLanguage(o)}mountFlashOverlay(t){let n=this.trackHandle(e.sink.createElement(`div`));e.sink.apply(n,{style:{position:`absolute`,inset:`0`,pointerEvents:`none`,zIndex:`300`,backgroundColor:nt,opacity:`0`}}),e.sink.appendChild(t,n),this._flashOverlay=n}onThemeChange(){if(!this._view)return;let e=i.getTheme().colorScheme===`dark`;this._view.dispatch({effects:this._themeCompartment.reconfigure(codeEditorTheme(e))})}onEditIntent(){return this.getReadOnly()&&this.signalReadOnlyEdit(),!1}signalReadOnlyEdit(){this.emit(`readonlyedit`),this.flashReadOnly()}flashReadOnly(){this._flashOverlay&&(this._flashAnimation?.cancel(),this._flashAnimation=o.play(this._flashOverlay,{from:{opacity:String(tt)},to:{opacity:`0`},durationMs:et,properties:[`opacity`]}))}},z=r(CodeEditor),rt=/\|/;function splitTableRow(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;e<t.length;e+=1){let i=t[e];i===`\\`&&t[e+1]===`|`?(r+=`|`,e+=1):i===`|`?(n.push(r.trim()),r=``):r+=i}return n.push(r.trim()),n}function parseDelimiterRow(e){let t=splitTableRow(e),n=[];for(let e of t){if(!/^:?-+:?$/.test(e))return null;let t=e.startsWith(`:`),r=e.endsWith(`:`);t&&r?n.push(`center`):t?n.push(`left`):r?n.push(`right`):n.push(``)}return n}function formatDelimiterRow(e){return`| `+e.map(e=>{switch(e){case`left`:return`:---`;case`center`:return`:---:`;case`right`:return`---:`;default:return`---`}}).join(` | `)+` |`}function escapeCellText(e){return e.trim().replace(/\|/g,`\\|`).replace(/\n/g,`\\n`)}function createTableTransformer(e){return{dependencies:[N,P,M],regExpStart:rt,type:`multiline-element`,handleImportAfterStartMatch:({lines:t,rootNode:n,startLineIndex:r})=>{let i=t[r+1];if(i===void 0)return null;let a=parseDelimiterRow(i);if(a===null)return null;let o=splitTableRow(t[r]),s=o.length;if(a.length!==s)return null;let c=[o],l=r+1;for(let e=r+2;e<t.length;e+=1){let n=t[e];if(n.trim()===``)break;c.push(splitTableRow(n)),l=e}let u=Ne();return c.forEach((t,n)=>{let r=Pe();for(let i=0;i<s;i+=1){let o=Me(n===0?j.ROW:j.NO_STATUS);v((t[i]??``).replace(/\\n/g,`
|
|
2
2
|
`),e(),o),o.setFormat(a[i]??``),r.append(o)}u.append(r)}),n.append(u),[!0,l]},replace:()=>!1,export:t=>{if(!Be(t))return null;let n=t.getChildren().filter(Ve);if(n.length===0)return null;let renderRow=t=>`| `+t.getChildren().filter(A).map(t=>escapeCellText(y(e(),t))).join(` | `)+` |`,r=n[0],i=r.getChildren().filter(A).map(e=>e.getFormatType()),a=[renderRow(r),formatDelimiterRow(i)];for(let e=1;e<n.length;e+=1)a.push(renderRow(n[e]));return a.join(`
|
|
3
3
|
`)}}}var B=[createTableTransformer(()=>B),_e,Se,ge,Ce,xe,he,ye,ve,be],it=[S,C,O,D,Ee,ke,Oe,N,P,M],V=`ts-ui-mde-heading`,H=`ts-ui-mde-quote`,U=`ts-ui-mde-code`,W=`ts-ui-mde-inline-code`,G=`ts-ui-mde-list`,K=`ts-ui-mde-link`,q=`ts-ui-mde-bold`,J=`ts-ui-mde-italic`,Y=`ts-ui-mde-table`,at=`ts-ui-mde-table-row`,X=`ts-ui-mde-table-cell`,Z=`ts-ui-mde-table-cell-header`,Q=`ts-ui-mde-table-cell-selected`,$=!1;function ensureMarkdownEditorClassRules(){$||($=!0,new n({scope:`class`,name:V,styles:{fontWeight:`600`}}),new n({scope:`class`,name:H,styles:{borderLeft:`3px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,paddingLeft:`1em`,marginLeft:`0`}}),new n({scope:`class`,name:U,styles:{fontFamily:`var(--ts-ui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,background:`rgba(127, 127, 127, 0.16)`,borderRadius:`var(--ts-ui-border-radius, 3px)`,padding:`0.6em 0.8em`,whiteSpace:`pre-wrap`,display:`block`,margin:`1em 0`}}),new n({scope:`class`,name:W,styles:{fontFamily:`var(--ts-ui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,background:`rgba(127, 127, 127, 0.16)`,borderRadius:`var(--ts-ui-border-radius, 3px)`,padding:`0.1em 0.3em`}}),new n({scope:`class`,name:G,styles:{paddingLeft:`1.5em`}}),new n({scope:`class`,name:K,styles:{color:`var(--ts-ui-indicator-focus, #2563eb)`}}),new n({scope:`class`,name:q,styles:{fontWeight:`700`}}),new n({scope:`class`,name:J,styles:{fontStyle:`italic`}}),new n({scope:`class`,name:Y,styles:{borderCollapse:`collapse`}}),new n({scope:`class`,name:X,styles:{border:`1px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,padding:`0.3em 0.6em`}}),new n({scope:`class`,name:Z,styles:{border:`1px solid var(--ts-ui-border-color, rgba(127, 127, 127, 0.4))`,padding:`0.3em 0.6em`,fontWeight:`600`}}),new n({scope:`selector`,name:`.${X} > p`,styles:{margin:`0`}}),new n({scope:`class`,name:Q,styles:{backgroundColor:`var(--ts-ui-table-row-selected, rgba(30, 100, 200, 0.15))`}}))}var ot={heading:{h1:V,h2:V,h3:V,h4:V,h5:V,h6:V},quote:H,code:U,list:{ul:G,ol:G},text:{bold:q,italic:J,code:W},link:K,table:Y,tableRow:at,tableCell:X,tableCellHeader:Z,tableCellSelected:Q},st=300;function reportEditorError(e){throw e}function createBlockNode(e){switch(e){case`quote`:return x();case`code`:return De();case`paragraph`:return fe();default:return b(e)}}function $selectionIsInTableCell(){let e=h();return g(e)?Le(e.anchor.getNode())!==null:!1}var WysiwygSurface=class extends a{_contentEditable=!1;_onReady;constructor(e){super(),this._onReady=e,this.setContentEditable(!0),this.setOverflow(`auto`),this.setPadding(new t(4,6,4,6)),this.setCursor(`text`),this.onFirstLayout(()=>this._onReady())}init(t){super.init(t);let n=t??this.getElement();return n&&e.sink.apply(n,{setAttr:{contenteditable:this._contentEditable?`true`:`false`}}),this}setContentEditable(e){return this._contentEditable=e,this.setElementAttribute(`contenteditable`,e?`true`:`false`),this}getContentEditable(){return this._contentEditable}mount(t){if(t.getRootElement())return;let n=this.getElement();n&&(ensureMarkdownEditorClassRules(),e.sink.mountView(n,e=>(t.setRootElement(e),e)))}},MarkdownEditor=class extends a{_editor=null;_unregister=null;_unregisterTableView=null;_listeners=new s;_card;_wysiwyg;_codeEditor;constructor(e,t){super(t),e!==void 0&&this._options.value===void 0&&(this._options.value=e),this._card=new c,this.setLayoutManager(this._card),this._wysiwyg=new WysiwygSurface(()=>this.mountWysiwyg()),this._codeEditor=new z(this._options.value??``,{language:`markdown`,readOnly:this._options.readOnly??!1,listeners:{change:e=>this.handleCodeChange(e)}}),this.addComponent(this._wysiwyg),this.addComponent(this._codeEditor),this._card.setVisibleComponentId(this.getMode()===`source`?this._codeEditor.getId():this._wysiwyg.getId()),this.applyListeners(t?.listeners)}applyOptions(e){return super.applyOptions(e),e.value!==void 0&&(this._options.value=e.value),e.readOnly!==void 0&&(this._options.readOnly=e.readOnly),e.mode!==void 0&&(this._options.mode=e.mode),this}getMode(){return this._options.mode??`wysiwyg`}setMode(e){if(this.getMode()===e)return this;let t=this.getValue();return this._options.mode=e,e===`source`?(this._codeEditor.setValue(t),this._card.setVisibleComponentId(this._codeEditor.getId())):(this.ensureEditor().update(()=>v(t,B),{discrete:!0}),this._card.setVisibleComponentId(this._wysiwyg.getId())),this}getValue(){if(this.getMode()===`source`)return this._codeEditor.getValue();let e=this._editor;return e?e.read(()=>y(B)):this._options.value??``}setValue(e){return this.getMode()===`source`?(this._codeEditor.setValue(e),this):(this.ensureEditor().update(()=>v(e,B),{discrete:!0}),this)}getReadOnly(){return this._options.readOnly??!1}setReadOnly(e){return this._options.readOnly=e,this._editor?.setEditable(!e),this._codeEditor.setReadOnly(e),this}focus(e=!1){return this.getMode()===`source`?this._codeEditor.focus(e):this.ensureEditor().focus(),this}toggleBold(){return this.ensureEditor().dispatchCommand(_,`bold`),this}toggleItalic(){return this.ensureEditor().dispatchCommand(_,`italic`),this}toggleInlineCode(){return this.ensureEditor().dispatchCommand(_,`code`),this}toggleUnorderedList(){return this.ensureEditor().dispatchCommand(E,void 0),this}toggleOrderedList(){return this.ensureEditor().dispatchCommand(T,void 0),this}toggleLink(e){return this.ensureEditor().update(()=>{g(h())&&Te(e)},{discrete:!0}),this}setBlockType(e){return this.ensureEditor().update(()=>{let t=h();g(t)&&qe(t,()=>createBlockNode(e))},{discrete:!0}),this}insertTable(e,t){let n=this.ensureEditor();return n.update(()=>{g(h())||pe().selectEnd()},{discrete:!0}),n.dispatchCommand(He,{columns:String(t),rows:String(e),includeHeaders:{rows:!0,columns:!1}}),this}insertTableRow(e=!0){return this.ensureEditor().update(()=>{$selectionIsInTableCell()&&ze(e)},{discrete:!0}),this}deleteTableRow(){return this.ensureEditor().update(()=>{$selectionIsInTableCell()&&Ie()},{discrete:!0}),this}insertTableColumn(e=!0){return this.ensureEditor().update(()=>{$selectionIsInTableCell()&&Re(e)},{discrete:!0}),this}deleteTableColumn(){return this.ensureEditor().update(()=>{$selectionIsInTableCell()&&Fe()},{discrete:!0}),this}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)}setContentEditable(e){return this._wysiwyg.setContentEditable(e),this}getContentEditable(){return this._wysiwyg.getContentEditable()}destructor(){this._unregisterTableView?.(),this._unregister?.(),this._editor?.setRootElement(null),super.destructor()}ensureEditor(){if(!this._editor){let e=me({nodes:it,theme:ot,onError:reportEditorError});e.update(()=>v(this._options.value??``,B),{discrete:!0}),e.setEditable(!(this._options.readOnly??!1)),this._unregister=Ke(w(e),k(e),We(e),Ue(e),je(e,Ae(),st),we(e,B),e.registerUpdateListener(()=>this.handleChange())),this._editor=e}return this._editor}mountWysiwyg(){let e=this.ensureEditor();this._wysiwyg.mount(e),e.getRootElement()&&!this._unregisterTableView&&(this._unregisterTableView=Ge(e,!0))}handleChange(){let e=this._editor;if(!e)return;let t=e.read(()=>y(B));t!==this._options.value&&(this._options.value=t,this.emit(`change`,{value:t}))}handleCodeChange(e){e.value!==this._options.value&&(this._options.value=e.value,this.emit(`change`,{value:e.value}))}},ct=r(MarkdownEditor);export{z as CodeEditor,ct as MarkdownEditor,getLanguage,listLanguages,registerLanguage};
|
|
4
4
|
//# sourceMappingURL=editor.es.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"../DOM-67StIm5G.js";import{a as t,l as n,n as r,s as i}from"../Position-Ck_KD4cR.js";import{S as a,b as o,h as s,t as c,v as l}from"../Component-DHqrPwAw.js";import{t as u}from"../ListenerBag-WPdKuuds.js";import{a as d}from"../Scrollbar-CSFK-Y57.js";import{t as f}from"../Glyph-CeAIWyPB.js";import{t as ee}from"../AnimatedDropdown-DKas40B-.js";import{t as p}from"../Fit-DIYt2aQB.js";import{t as m}from"../Text-D5pg7taZ.js";import{t as h}from"../AbstractInput-BmWGJTs1.js";import{t as g}from"../AbstractBooleanInput-DSwKBAic.js";import{n as _,r as v}from"../VBox-BNegDPs_.js";import{t as te}from"../RadioButton-BJIAQkII.js";import{t as y}from"../Button-bjpWruNc.js";import{n as b,t as x}from"../Slider-C-kQQYCj.js";import{a as S,c as ne,d as C,f as w,g as T,h as E,i as D,l as O,m as k,n as A,o as j,p as M,r as N,s as P,t as F,u as I}from"../ComboBox-CBw2VLLN.js";import{calendar as L}from"../glyphs/solid/calendar.es.js";import{t as R}from"../List-CUntS8ux.js";import{chevron_down as z}from"../glyphs/solid/chevron_down.es.js";import{chevron_up as B}from"../glyphs/solid/chevron_up.es.js";f.register(L);var DateField=class extends C{constructor(e){super(e),this._button.setGlyph(`calendar`),this._options.value!==void 0&&this.setValue(this._options.value)}applyOptions(e){return super.applyOptions(e),e.value!==void 0&&(this._options.value=e.value),e.minDate!==void 0&&(this._options.minDate=e.minDate),e.maxDate!==void 0&&(this._options.maxDate=e.maxDate),this}formatValue(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}parseRaw(e){let t=new Date(e+`T00:00:00`);return isNaN(t.getTime())?null:t}createDropdown(){return new j(e=>this.onDropdownSelected(e),{minDate:this._options.minDate??null,maxDate:this._options.maxDate??null})}onDropdownSelected(e){this.setValue(e),this.closeDropdown(),this._input.focus(),a.fireEvent(this._input,`input`)}getPreferredWidth(){return 160}},V=s(DateField);f.register(L);var DateTimeField=class extends C{constructor(e){super(e),this._button.setGlyph(`calendar`),this._options.showSeconds!==void 0&&(this._showSeconds=this._options.showSeconds),this._options.value!==void 0&&this.setValue(this._options.value)}applyOptions(e){return super.applyOptions(e),e.showSeconds!==void 0&&(this._options.showSeconds=e.showSeconds),e.value!==void 0&&(this._options.value=e.value),e.minDate!==void 0&&(this._options.minDate=e.minDate),e.maxDate!==void 0&&(this._options.maxDate=e.maxDate),this}formatValue(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getDate()).padStart(2,`0`),i=String(e.getHours()).padStart(2,`0`),a=String(e.getMinutes()).padStart(2,`0`);return this._showSeconds?`${t}-${n}-${r} ${i}:${a}:${String(e.getSeconds()).padStart(2,`0`)}`:`${t}-${n}-${r} ${i}:${a}`}parseRaw(e){let[t,n]=e.trim().split(/\s+/);if(!t||!n)return null;let r=new Date(`${t}T${n}`);return isNaN(r.getTime())?null:r}createDropdown(){return new N(e=>this.onDropdownSelected(e),{showSeconds:this._showSeconds,minDate:this._options.minDate??null,maxDate:this._options.maxDate??null})}onDropdownSelected(e){this.setValue(e),a.fireEvent(this._input,`input`)}getPreferredWidth(){return 200}},H=s(DateTimeField),U={padding:new r(3,3,3,3),cursor:`text`,backgroundColor:`var(--ts-ui-input-bg, rgb(255, 255, 255))`,foregroundColor:`var(--ts-ui-text-color, black)`},PasswordField=class extends E{constructor(e,t){super(e,{...U,...t??{}}),this.updateHeight(),this.subscribeTheme(()=>this.updateHeight()),this.setType(`password`),this._options.name===void 0&&this.setName(`password`),this._options.autoComplete===void 0&&this.setAutoComplete(e?.newPassword?`new-password`:`current-password`)}updateHeight(){let e=n.singleLineBoxHeight(this.getInsets(),this.getPadding(),this.getBorderSize());this.setPreferredSize({width:200,height:e}),this.setMaxSize({width:2**53-1,height:e}),this.setMinSize({width:0,height:e})}},re=s(PasswordField),W={cursor:`text`,padding:new r(3,3,3,3),backgroundColor:`var(--ts-ui-input-bg, rgb(255, 255, 255))`,foregroundColor:`var(--ts-ui-text-color, black)`},UsernameField=class extends E{constructor(e,t){super(e,{...W,...t??{}}),this.updateHeight(),this.subscribeTheme(()=>this.updateHeight()),this.setType(`text`),this._options.name===void 0&&this.setName(`username`),this._options.autoComplete===void 0&&this.setAutoComplete(e?.email?`email`:`username`)}updateHeight(){let e=n.singleLineBoxHeight(this.getInsets(),this.getPadding(),this.getBorderSize());this.setPreferredSize({width:200,height:e}),this.setMaxSize({width:2**53-1,height:e}),this.setMinSize({width:0,height:e})}},G=s(UsernameField),K={tag:`textarea`,cursor:`text`,overflow:`auto`,padding:new r(3,3,3,3),preferredSize:{width:200,height:200},minSize:{width:100,height:100},backgroundColor:`var(--ts-ui-input-bg, rgb(255, 255, 255))`,foregroundColor:`var(--ts-ui-text-color, black)`},TextArea=class extends E{constructor(e=``,t,n){super(e?{text:e,...t}:t,{...K,...n??{}}),this.setElementCSSRules({resize:`none`})}applyOptions(e){return super.applyOptions(e),e.rows!==void 0&&this.setRows(e.rows),e.cols!==void 0&&this.setCols(e.cols),e.wrap!==void 0&&this.setWrap(e.wrap),this}getRows(){return this._options.rows??null}setRows(e){return this._options.rows=e,this.setElementAttribute(`rows`,String(e)),this}clearRows(){return this._options.rows===void 0?this:(this._options.rows=void 0,this.removeElementAttribute(`rows`),this)}getCols(){return this._options.cols??null}setCols(e){return this._options.cols=e,this.setElementAttribute(`cols`,String(e)),this}clearCols(){return this._options.cols===void 0?this:(this._options.cols=void 0,this.removeElementAttribute(`cols`),this)}getWrap(){return this._options.wrap??null}setWrap(e){return this._options.wrap=e,this.setElementAttribute(`wrap`,e),this}clearWrap(){return this._options.wrap===void 0?this:(this._options.wrap=void 0,this.removeElementAttribute(`wrap`),this)}getBaseline(){return this.wrapInnerBaseline(n.measureTextBaseline())}init(t){super.init(t);let n=t||this.getElement();return this._options.rows!==void 0&&e.sink.apply(n,{setAttr:{rows:String(this._options.rows)}}),this._options.cols!==void 0&&e.sink.apply(n,{setAttr:{cols:String(this._options.cols)}}),this._options.wrap!==void 0&&e.sink.apply(n,{setAttr:{wrap:this._options.wrap}}),this}},q=s(TextArea),Toggle=class extends g{_track;_thumb;constructor(e){super({...e??{}}),this.setLayoutManager(new v),this._track=new c,this._track.setBackgroundColor(`var(--ts-ui-toggle-track-bg-off, rgb(200, 200, 200))`),this._track.setBorderRadius(`999px`),this._track.setPreferredSize({width:36,height:20}),this._track.setMinSize({width:36,height:20}),this._track.setMaxSize({width:36,height:20}),this._track.setCursor(`pointer`),this._thumb=new c,this._thumb.setBackgroundColor(`var(--ts-ui-toggle-thumb-bg, rgb(255, 255, 255))`),this._thumb.setBorderRadius(`999px`),this._thumb.setPreferredSize({width:16,height:16}),this._thumb.setMaxSize({width:16,height:16}),this._thumb.setSize({width:16,height:16}),this._thumb.setShadow(`0 1px 2px rgba(0, 0, 0, 0.25)`),this._thumb.setX(2),this._thumb.setY(2),this._thumb.setPointerEvents(`none`),l.isReducedMotion()||(this._thumb.setTransition(`transform 120ms ease-out`),this._track.setTransition(`background-color 120ms ease-out`)),this._track.addComponent(this._thumb),super.addComponent(this._track),this.getAria().setRole(`switch`),this.getAria().setTabIndex(0),this.getAria().setChecked(!1),this.setOutline(`none`),a.addListener(this._track,`click`,()=>this.activateFromPointer()),this.installKeyboard(),this._options.value!==void 0&&this.applyValue(this._options.value),this._options.label!==void 0&&this.applyLabel(this._options.label),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.value!==void 0&&(this._options.value=e.value),e.label!==void 0&&(this._options.label=e.label),e.enabled!==void 0&&(this._options.enabled=e.enabled),e.readOnly!==void 0&&(this._options.readOnly=e.readOnly),this}activate(){this.setValue(!this.getValue())}getInteractiveSurface(){return this._track}activationKeys(){return[` `,`Enter`]}getValue(){return this._options.value??!1}setValue(e){let t=!!e;return t===this.getValue()?this:(this._options.value=t,this.applyValue(t),this.notifyChange(t),this)}clearValue(){return this.setValue(!1)}getBaseline(){let e=this._label;if(e===null)return null;let t=e.getBaseline();return t===null?null:this.wrapInnerBaseline(t+this.labelCenterOffset())}labelCenterOffset(){if(this._label===null)return 0;let e=this._track.getPreferredSize()?.height??0,t=this._label.getPreferredSize()?.height??e;return Math.max(0,Math.round((e-t)/2))}doLayout(){super.doLayout();let e=this._label,t=this.labelCenterOffset();return e!==null&&t>0&&e.setY(e.getY()+t),this}applyValue(e){this.getAria().setChecked(e),this._thumb.setTransform(e?`translateX(16px)`:`translateX(0px)`),this._track.setBackgroundColor(e?`var(--ts-ui-toggle-track-bg-on, rgb(30, 100, 200))`:`var(--ts-ui-toggle-track-bg-off, rgb(200, 200, 200))`)}},J=s(Toggle),Y=22,X={durationMs:100,backgroundColor:`var(--ts-ui-autocomplete-bg, rgb(255, 255, 255))`,border:`var(--ts-ui-input-border)`,borderRadius:`var(--ts-ui-border-radius, 4px)`,shadow:`var(--ts-ui-autocomplete-shadow, 2px 4px 8px rgba(0,0,0,0.15))`};new o({scope:`selector`,name:`.AutoCompleteDropdown .List:focus::after`,styles:{content:`none`}});var AutoCompleteDropdown=class extends ee{_list;_onSelect;_onHide;constructor(e,t,n,r){super(n,{...X,...r??{}}),this._onSelect=e,this._onHide=t,this.setContain(`layout`),this.setLayoutManager(new p),this._list=new R,this._list.setBorder(`none`),this._list.setBorderRadius(`0`),this._list.setFocusOnRowClick(!1),this._list.setSelectFollowsFocus(!1),this.addComponent(this._list),this._list.on(`action`,()=>{let e=this._list.getValue();e&&this._onSelect(e)})}show(t,n){this.getElement(!0),this.pauseLayout(),this._list.setItemsArray(n.map(e=>({key:e,label:e}))),this.resumeLayout();let r=this.getPerimeterSize(),i=r.top+r.bottom,a=e.source.getElementRect(t);return this.setWidth(a.width),this.setHeight(n.length*Y+i),this.placeAnchored(a),this.setAnchorElement(t),this.showAnimated(),this.doLayout(),this}hide(){return this.hideAnimated(),this}handleKey(e){return this._list.handleKey(e)}getFocusedRowId(){return this._list.getFocusedRowId()}getList(){return this._list}onHideComplete(){this._onHide()}},ie=s(AutoCompleteDropdown);w(`.AutoCompleteField`);var AutoCompleteField=class extends h{_textField;_dropdown;_debounceTimer=null;_selectBag=new u;constructor(e){super(),this.setBorder(`var(--ts-ui-input-border)`),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),this._textField=new I,this._textField.setBorder(`none`),this._textField.setBorderRadius(`0`),this._textField.setOutline(`none`),this.addComponent(this._textField),this.syncSizeFromTextField(),this.subscribeTheme(()=>this.syncSizeFromTextField()),this._dropdown=new ie(e=>this.onSuggestionSelected(e),()=>this.onDropdownHidden()),this._textField.getAria().setRole(`combobox`),this._textField.getAria().setAutoComplete(`list`),this._textField.getAria().setExpanded(!1),this._textField.getAria().setControls(this._dropdown.getId()),this._textField.getAria().setActiveDescendant(``),a.addListener(this._textField,`input`,()=>this.onInput()),a.addListener(this._textField,`keydown`,e=>this.onKeyDown(e)),a.addListener(this._textField,`blur`,()=>this.onBlur()),this._textField.on(`change`,e=>this.notifyChange(e)),e&&this.applyOptions(e),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.suggestions!==void 0&&this.setSuggestions(e.suggestions),e.minChars!==void 0&&this.setMinChars(e.minChars),e.debounceMs!==void 0&&this.setDebounceMs(e.debounceMs),e.maxSuggestions!==void 0&&this.setMaxSuggestions(e.maxSuggestions),e.matchMode!==void 0&&this.setMatchMode(e.matchMode),e.placeholder!==void 0&&this.setPlaceholder(e.placeholder),e.store!==void 0&&e.displayField!==void 0?this.setStore(e.store,e.displayField):(e.store!==void 0&&(this._options.store=e.store),e.displayField!==void 0&&(this._options.displayField=e.displayField)),this}syncSizeFromTextField(){let e=this.getPerimeterSize(),t=e.left+e.right,n=e.top+e.bottom,r=this._textField.getPreferredSize(),a=this._textField.getMaxSize(),o=this._textField.getMinSize();r&&this.setPreferredSize({width:r.width,height:r.height+n}),a&&this.setMaxSize({width:i(a.width+t),height:i(a.height+n)}),o&&this.setMinSize({width:o.width,height:o.height+n})}getBaseline(){return this.wrapInnerBaseline(this._textField.getBaseline())}doLayout(){super.doLayout();let e=this.getContentBounds();return e?(this._textField.setX(e.x),this._textField.setY(e.y),this._textField.setWidth(e.width),this._textField.setHeight(e.height),this):this}setValue(e){return this._textField.setValue(e),this}getValue(){return this._textField.getValue()}applyEnabled(e){this._textField.setEnabled(e)}applyReadOnly(e){this._textField.setReadOnly(e)}setSuggestions(e){return this._options.suggestions=e,this}setStore(e,t){return this._options.store=e,this._options.displayField=t,this}setMinChars(e){return this._options.minChars=e,this}setDebounceMs(e){return this._options.debounceMs=e,this}setMaxSuggestions(e){return this._options.maxSuggestions=e,this}setMatchMode(e){return this._options.matchMode=e,this}setPlaceholder(e){return this._options.placeholder=e,this._textField.setPlaceholder(e),this}on(e,t){return e===`select`?(this._selectBag.add(`select`,t),this):super.on(e,t)}off(e,t){return e===`select`?(this._selectBag.remove(`select`,t),this):super.off(e,t)}addSelectListener(e){this.on(`select`,e)}onInput(){this._debounceTimer!==null&&clearTimeout(this._debounceTimer);let e=this._options.minChars??1,t=this.getValue();if(t.length<e){this._dropdown.hide();return}this._debounceTimer=setTimeout(()=>this.querySuggestions(t),this._options.debounceMs??200)}onKeyDown(e){if(this._dropdown.isOpen()&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`)&&this._dropdown.handleKey(e)){e.preventDefault(),this.updateActiveDescendant();return}switch(e.key){case`ArrowDown`:e.preventDefault(),this.querySuggestions(this.getValue());break;case`Escape`:this._dropdown.hide(),this._textField.focus();break;case`Tab`:this._dropdown.hide();break;default:break}}onBlur(){setTimeout(()=>{let t=e.source.getActiveElement(),n=this._dropdown.getElement();n&&e.source.contains(n,t)||this._dropdown.hide()},150)}matches(e,t){let n=this._options.matchMode??`contains`,r=n===`containsCaseSensitive`||n===`startsWithCaseSensitive`,i=n===`startsWith`||n===`startsWithCaseSensitive`,a=r?e:e.toLowerCase(),o=r?t:t.toLowerCase();return i?a.startsWith(o):a.includes(o)}querySuggestions(e){let t=this._options.maxSuggestions??10,n=this._options.matchMode??`contains`,r=this._options.suggestions,i=this._options.store,a=this._options.displayField;if(r!==void 0){let n=r.filter(t=>this.matches(t,e)).slice(0,t);e===this.getValue()&&this.showSuggestions(n);return}if(i!==void 0&&a!==void 0){let r=n===`containsCaseSensitive`||n===`startsWithCaseSensitive`,o=n===`startsWith`||n===`startsWithCaseSensitive`?`startsWith`:`contains`;i.clearFilter(),i.filterBy({type:o,field:a,value:e,caseSensitive:r});let s=i.getRecords().map(e=>String(e.get(a))).slice(0,t);e===this.getValue()&&this.showSuggestions(s)}}showSuggestions(e){if(e.length===0){this._dropdown.hide();return}this._dropdown.show(this._textField.getElement(!0),e),this._textField.getAria().setExpanded(!0)}onDropdownHidden(){this._textField.getAria().setExpanded(!1),this._textField.getAria().setActiveDescendant(``)}updateActiveDescendant(){this._textField.getAria().setActiveDescendant(this._dropdown.getFocusedRowId()??``)}onSuggestionSelected(e){this.setValue(e),this._selectBag.fire(`select`,e),this._dropdown.hide(),this._textField.focus()}},ae=s(AutoCompleteField);f.register(B,z);var oe={border:`none`,borderRadius:`0`,insets:new r(0,0,0,0)},SpinButton=class extends y{_listeners=new u;_repeat;constructor(e,t,n){super(void 0,t,{...oe,glyph:e===`▲`?`chevron-up`:`chevron-down`,...n??{}}),this.updateSize(),this.subscribeTheme(()=>this.updateSize()),t?.shadow===void 0&&this.clearShadow(),t?.pressedShadow===void 0&&this.clearPressedShadow(),this.pinGlyphSize(8),this.getGlyph()?.setTranslate(0,-1),this._repeat=new d({initialDelay:400,decay:.75,floor:40,onTick:()=>this.emit(`tick`)}),a.addListener(this,`mousedown`,()=>this.onMouseDown()),a.addViewportListener(this,`mouseup`,()=>this.onMouseUp()),a.addViewportListener(this,`mouseleave`,()=>this.onMouseUp()),this.applyListeners(t?.listeners)}updateSize(){let e=n.lineHeightPx()+6+2,t=Math.floor((e-2)/2);this.setPreferredSize({width:18,height:t}),this.setMinSize({width:18,height:t}),this.setMaxSize({width:18,height:t})}on(e,t){return e===`action`?a.addListener(this,`click`,t):this._listeners.add(e,t),this}off(e,t){return e===`action`?a.removeListener(this,`click`,t):this._listeners.remove(e,t),this}emit(e,...t){this._listeners.fire(e,...t)}onMouseDown(){this._repeat.start()}onMouseUp(){this._repeat.isRunning()&&this._repeat.stop()}},Z=s(SpinButton);w(`.NumberSpinner`),new o({scope:`selector`,name:`.NumberSpinner .TextField:focus`,styles:{boxShadow:`none`}});var se={insets:new r(0,0,0,0),border:`1px solid var(--ts-ui-button-border, rgb(200, 200, 200))`,borderRadius:`var(--ts-ui-border-radius, 4px)`,backgroundColor:`var(--ts-ui-input-bg, rgb(255, 255, 255))`},NumberSpinner=class extends h{_input;_upBtn;_downBtn;_btnBox;constructor(e,t){super(e,{...se,...t??{}}),this._input=new I,this._input.setTextAlign(`right`),this._input.setBorder(`none`),this._input.setBorderRadius(`0`),this._input.setOutline(`none`),this._input.setText(this.formatValue(0)),this._upBtn=new Z(`▲`),this._downBtn=new Z(`▼`),this._upBtn.setBorder({borderTop:`1px solid transparent`}),this._upBtn.setBorderRadius(`0`),this._downBtn.setBorder({borderTop:`1px solid var(--ts-ui-spinner-divider, rgb(180, 180, 180))`}),this._downBtn.setBorderRadius(`0`),this._btnBox=new c;let n=new _;n.setComponentSpacing(0),this._btnBox.setLayoutManager(n),this._btnBox.setInsets(new r(0,0,0,0)),this._btnBox.addComponent(this._upBtn),this._btnBox.addComponent(this._downBtn);let i=new v;i.setComponentSpacing(0),i.setStretching(!0),this.setLayoutManager(i),this.addComponent(this._input,{weight:1}),this.addComponent(this._btnBox),this._upBtn.on(`tick`,()=>this.applyValue(this.getValue()+this.getStep())),this._downBtn.on(`tick`,()=>this.applyValue(this.getValue()-this.getStep())),a.addListener(this._input,`blur`,()=>this.onBlur()),a.addListener(this._input,`keydown`,e=>this.onKeyDown(e)),this.updateHeight(),this.subscribeTheme(()=>this.updateHeight()),this.getAria().setRole(`spinbutton`),this.getAria().setValueNow(0),this._options.min!==void 0&&this.setMin(this._options.min),this._options.max!==void 0&&this.setMax(this._options.max),this._options.step!==void 0&&this.setStep(this._options.step),this._options.precision!==void 0&&this.setPrecision(this._options.precision),this._options.value!==void 0&&this.setValue(this._options.value),this._options.enabled!==void 0&&this.setEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.setReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.min!==void 0&&(this._options.min=e.min),e.max!==void 0&&(this._options.max=e.max),e.step!==void 0&&(this._options.step=e.step),e.precision!==void 0&&(this._options.precision=e.precision),e.value!==void 0&&(this._options.value=e.value),e.enabled!==void 0&&(this._options.enabled=e.enabled),this}getBaseline(){return this.wrapInnerBaseline(this._input.getBaseline())}updateHeight(){let e=n.singleLineBoxHeight(this.getInsets(),this._input.getPadding(),this.getBorderSize());this.setPreferredSize({width:120,height:e}),this.setMaxSize({width:t,height:e}),this.setMinSize({width:0,height:e})}getValue(){return this._options.value??0}setValue(e){return this._setValueSilent(e),this}getMin(){return this._options.min??-1/0}setMin(e){return this._options.min=e,this.getAria().setValueMin(isFinite(e)?e:null),this}getMax(){return this._options.max??1/0}setMax(e){return this._options.max=e,this.getAria().setValueMax(isFinite(e)?e:null),this}getStep(){return this._options.step??1}setStep(e){return this._options.step=e,this}getPrecision(){return this._options.precision??null}setPrecision(e){return this._options.precision=e,this._input.setText(this.formatValue(this.getValue())),this}applyEnabled(e){e?(this._input.setDisabledAttribute(!1),this._upBtn.setPointerEvents(`auto`),this._downBtn.setPointerEvents(`auto`),this.clearOpacity()):(this._input.setDisabledAttribute(!0),this._upBtn.setPointerEvents(`none`),this._downBtn.setPointerEvents(`none`),this.setOpacity(.5))}applyReadOnly(e){this._input.setReadOnly(e)}applyValue(e){if(!this.isEnabled())return;let t=this.normalize(e);if(t===this.getValue()){this._input.setText(this.formatValue(t));return}this._options.value=t,this._input.setText(this.formatValue(t)),this.getAria().setValueNow(t),this.notifyChange(t)}_setValueSilent(e){let t=this.normalize(e);this._options.value=t,this._input.setText(this.formatValue(t)),this.getAria().setValueNow(t)}normalize(e){let t=Math.min(this.getMax(),Math.max(this.getMin(),e));return t=Math.round(t/this.getStep())*this.getStep(),t=parseFloat(t.toFixed(this.derivePrecision())),t}onBlur(){let e=parseFloat(this._input.getText().valueOf());if(isNaN(e)){this._input.setText(this.formatValue(this.getValue()));return}this.applyValue(e)}onKeyDown(e){if(e.key===`ArrowUp`){e.preventDefault(),this.applyValue(this.getValue()+this.getStep());return}if(e.key===`ArrowDown`){e.preventDefault(),this.applyValue(this.getValue()-this.getStep());return}e.key===`Enter`&&this.onBlur()}formatValue(e){return e.toFixed(this.derivePrecision())}derivePrecision(){let e=this._options.precision??null;if(e!==null)return e;let t=String(this.getStep()),n=t.indexOf(`.`);return n>=0?t.length-n-1:0}},Q=s(NumberSpinner),ce=3,$=`no file selected`,HiddenFileInput=class extends c{_type=null;_multiple=!1;_accept=null;constructor(){super({tag:`input`}),this.setDisplayed(!1),this.setType(`file`)}getType(){return this._type}setType(e){this._type=e,this.setElementAttribute(`type`,e)}setMultipleAttribute(e){this._multiple=e,e?this.setElementAttribute(`multiple`,``):this.removeElementAttribute(`multiple`)}setAcceptAttribute(e){this._accept=e,this.setElementAttribute(`accept`,e)}setDisabled(e){this.setDisabledAttribute(e)}openPicker(){let t=this.getElement();t&&e.sink.click(t)}getFiles(){let t=this.getElement();return t?e.source.getFiles(t):null}clearFiles(){let t=this.getElement();t&&e.sink.setValue(t,``)}init(t){super.init(t);let n=t??this.getElement();return n?(this._type!==null&&e.sink.apply(n,{setAttr:{type:this._type}}),this._multiple&&e.sink.apply(n,{setAttr:{multiple:``}}),this._accept!==null&&e.sink.apply(n,{setAttr:{accept:this._accept}}),this):this}},FileField=class extends h{_button;_label;_input;_droppedFiles=[];constructor(e){super({...e??{}}),this.setLayoutManager(new v),this._button=new y(this.defaultButtonText()),this._button.on(`action`,()=>this.openPicker()),this._label=new m($,{truncate:!0}),this._label.setForegroundColor(`var(--ts-ui-form-text, inherit)`),this._input=new HiddenFileInput,a.addListener(this._input,`change`,()=>this.onNativeChange()),super.addComponent(this._button),super.addComponent(this._label,{weight:1}),super.addComponent(this._input),this._options.multiple!==void 0&&this.setMultiple(this._options.multiple),this._options.accept!==void 0&&this.setAccept(this._options.accept),this._options.buttonText!==void 0&&this._button.setText(this._options.buttonText),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.multiple!==void 0&&(this._options.multiple=e.multiple),e.accept!==void 0&&(this._options.accept=e.accept),e.buttonText!==void 0&&(this._options.buttonText=e.buttonText),this}defaultButtonText(){return this.isMultiple()?`Choose files…`:`Choose file…`}openPicker(){!this.isEnabled()||this.isReadOnly()||this._input.openPicker()}onNativeChange(){this._droppedFiles=[];let e=this.getValue();this.updateLabel(e),this.notifyChange(e)}acceptDroppedFiles(e){this._droppedFiles=Array.from(e);let t=this.getValue();this.updateLabel(t),this.notifyChange(t)}getValue(){if(this._droppedFiles.length>0)return this._droppedFiles;let e=this._input.getFiles();return e?Array.from(e):[]}setValue(e){return e&&e.length>0?(console.warn(`FileField '`+this.getId()+`' setValue ignored a non-empty File[]: the browser security model forbids programmatically populating a file input. Only setValue([]) (clearing) is supported.`),this):this.clearValue()}clearValue(){this._droppedFiles=[],this._input.clearFiles();let e=this.getValue();return this.updateLabel(e),this.notifyChange(e),this}isMultiple(){return this._options.multiple??!1}setMultiple(e){return this._options.multiple=!!e,this._input.setMultipleAttribute(this._options.multiple),this._options.buttonText===void 0&&this._button.setText(this.defaultButtonText()),this}getAccept(){return this._options.accept??null}setAccept(e){return this._options.accept=e,this._input.setAcceptAttribute(e),this}updateLabel(e){e.length===0?this._label.setText($):e.length===1?this._label.setText(e[0].name):e.length>ce?this._label.setText(e.length+` files`):this._label.setText(e.map(e=>e.name).join(`, `))}applyEnabled(e){this._button.setEnabled(e),this._input.setDisabled(!e)}applyReadOnly(e){this._button.setEnabled(!e&&this.isEnabled()),this.getAria().setReadOnly(e)}},le=s(FileField),ue=`var(--ts-ui-filedropzone-border, 2px dashed rgba(80, 140, 240, 0.40))`,de=`var(--ts-ui-filedropzone-bg, rgba(80, 140, 240, 0.06))`,fe=`var(--ts-ui-filedropzone-active-border, 2px dashed rgba(80, 140, 240, 0.80))`,pe=`var(--ts-ui-filedropzone-active-bg, rgba(80, 140, 240, 0.18))`,me=`Drop files here or click to browse`,FileDropZone=class extends h{_prompt;_field;_dragDepth=0;constructor(e){super({...e??{}}),this.setLayoutManager(new _),this._prompt=new m(this._options.promptText??me),this._prompt.setForegroundColor(`var(--ts-ui-form-text, inherit)`),this._field=new FileField(this.fieldOptions()),this._field.on(`change`,e=>this.notifyChange(e)),super.addComponent(this._prompt),super.addComponent(this._field),this.setActive(!1),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),a.addSubtreeListener(this,`dragenter`,e=>this.onDragEnter(e)),a.addSubtreeListener(this,`dragover`,e=>this.onDragOver(e)),a.addSubtreeListener(this,`dragleave`,e=>this.onDragLeave(e)),a.addSubtreeListener(this,`drop`,e=>this.onDrop(e)),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.promptText!==void 0&&(this._options.promptText=e.promptText),this}fieldOptions(){return{multiple:this._options.multiple,accept:this._options.accept,buttonText:this._options.buttonText}}setActive(e){this.setBorder(e?fe:ue),this.setBackgroundColor(e?pe:de)}onDragEnter(e){e.preventDefault(),this._dragDepth++,this._dragDepth===1&&this.setActive(!0)}onDragOver(e){e.preventDefault()}onDragLeave(e){e.preventDefault(),this._dragDepth=Math.max(0,this._dragDepth-1),this._dragDepth===0&&this.setActive(!1)}onDrop(e){if(e.preventDefault(),this._dragDepth=0,this.setActive(!1),!this.isEnabled()||this.isReadOnly())return;let t=e.dataTransfer?.files;!t||t.length===0||this._field.acceptDroppedFiles(t)}getValue(){return this._field.getValue()}setValue(e){return this._field.setValue(e),this}clearValue(){return this._field.clearValue(),this}applyEnabled(e){this._field.setEnabled(e)}applyReadOnly(e){this._field.setReadOnly(e)}},he=s(FileDropZone);export{g as AbstractBooleanInput,h as AbstractInput,C as AbstractPickerField,ae as AutoCompleteField,A as Checkbox,F as ComboBox,V as DateField,j as DatePickerDropdown,H as DateTimeField,N as DateTimePickerDropdown,he as FileDropZone,le as FileField,b as Label,T as Link,Q as NumberSpinner,re as PasswordField,M as PickerButton,P as PickerCell,ne as PickerCellList,O as PickerColumn,k as PickerInput,te as RadioButton,x as Slider,Z as SpinButton,m as Text,q as TextArea,I as TextField,E as TextInput,D as TimeField,S as TimePickerDropdown,J as Toggle,G as UsernameField};
|
|
1
|
+
import{t as e}from"../DOM-67StIm5G.js";import{a as t,l as n,n as r,s as i}from"../Position-Ck_KD4cR.js";import{S as a,b as o,h as s,t as c,v as l}from"../Component-fRQvgaEY.js";import{t as u}from"../ListenerBag-WPdKuuds.js";import{a as d}from"../Scrollbar-SOj9psiP.js";import{t as f}from"../Glyph-wN7bk7mg.js";import{t as ee}from"../AnimatedDropdown-QLNasu_Y.js";import{t as p}from"../Fit-CL1m1nIZ.js";import{t as m}from"../Text-KB5LksJl.js";import{t as h}from"../AbstractInput-BxfrmD2W.js";import{t as g}from"../AbstractBooleanInput-DE5NNJT0.js";import{n as _,r as v}from"../VBox-P3WFGkPc.js";import{t as te}from"../RadioButton-D23rId-V.js";import{t as y}from"../Button-MZDYJOMC.js";import{n as b,t as x}from"../Slider-DBnAZ-F7.js";import{a as S,c as ne,d as C,f as w,g as T,h as E,i as D,l as O,m as k,n as A,o as j,p as M,r as N,s as P,t as F,u as I}from"../ComboBox-C04SfXAR.js";import{calendar as L}from"../glyphs/solid/calendar.es.js";import{t as R}from"../List-CG4NvwuV.js";import{chevron_down as z}from"../glyphs/solid/chevron_down.es.js";import{chevron_up as B}from"../glyphs/solid/chevron_up.es.js";f.register(L);var DateField=class extends C{constructor(e){super(e),this._button.setGlyph(`calendar`),this._options.value!==void 0&&this.setValue(this._options.value)}applyOptions(e){return super.applyOptions(e),e.value!==void 0&&(this._options.value=e.value),e.minDate!==void 0&&(this._options.minDate=e.minDate),e.maxDate!==void 0&&(this._options.maxDate=e.maxDate),this}formatValue(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}parseRaw(e){let t=new Date(e+`T00:00:00`);return isNaN(t.getTime())?null:t}createDropdown(){return new j(e=>this.onDropdownSelected(e),{minDate:this._options.minDate??null,maxDate:this._options.maxDate??null})}onDropdownSelected(e){this.setValue(e),this.closeDropdown(),this._input.focus(),a.fireEvent(this._input,`input`)}getPreferredWidth(){return 160}},V=s(DateField);f.register(L);var DateTimeField=class extends C{constructor(e){super(e),this._button.setGlyph(`calendar`),this._options.showSeconds!==void 0&&(this._showSeconds=this._options.showSeconds),this._options.value!==void 0&&this.setValue(this._options.value)}applyOptions(e){return super.applyOptions(e),e.showSeconds!==void 0&&(this._options.showSeconds=e.showSeconds),e.value!==void 0&&(this._options.value=e.value),e.minDate!==void 0&&(this._options.minDate=e.minDate),e.maxDate!==void 0&&(this._options.maxDate=e.maxDate),this}formatValue(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getDate()).padStart(2,`0`),i=String(e.getHours()).padStart(2,`0`),a=String(e.getMinutes()).padStart(2,`0`);return this._showSeconds?`${t}-${n}-${r} ${i}:${a}:${String(e.getSeconds()).padStart(2,`0`)}`:`${t}-${n}-${r} ${i}:${a}`}parseRaw(e){let[t,n]=e.trim().split(/\s+/);if(!t||!n)return null;let r=new Date(`${t}T${n}`);return isNaN(r.getTime())?null:r}createDropdown(){return new N(e=>this.onDropdownSelected(e),{showSeconds:this._showSeconds,minDate:this._options.minDate??null,maxDate:this._options.maxDate??null})}onDropdownSelected(e){this.setValue(e),a.fireEvent(this._input,`input`)}getPreferredWidth(){return 200}},H=s(DateTimeField),U={padding:new r(3,3,3,3),cursor:`text`,backgroundColor:`var(--ts-ui-input-bg, rgb(255, 255, 255))`,foregroundColor:`var(--ts-ui-text-color, black)`},PasswordField=class extends E{constructor(e,t){super(e,{...U,...t??{}}),this.updateHeight(),this.subscribeTheme(()=>this.updateHeight()),this.setType(`password`),this._options.name===void 0&&this.setName(`password`),this._options.autoComplete===void 0&&this.setAutoComplete(e?.newPassword?`new-password`:`current-password`)}updateHeight(){let e=n.singleLineBoxHeight(this.getInsets(),this.getPadding(),this.getBorderSize());this.setPreferredSize({width:200,height:e}),this.setMaxSize({width:2**53-1,height:e}),this.setMinSize({width:0,height:e})}},re=s(PasswordField),W={cursor:`text`,padding:new r(3,3,3,3),backgroundColor:`var(--ts-ui-input-bg, rgb(255, 255, 255))`,foregroundColor:`var(--ts-ui-text-color, black)`},UsernameField=class extends E{constructor(e,t){super(e,{...W,...t??{}}),this.updateHeight(),this.subscribeTheme(()=>this.updateHeight()),this.setType(`text`),this._options.name===void 0&&this.setName(`username`),this._options.autoComplete===void 0&&this.setAutoComplete(e?.email?`email`:`username`)}updateHeight(){let e=n.singleLineBoxHeight(this.getInsets(),this.getPadding(),this.getBorderSize());this.setPreferredSize({width:200,height:e}),this.setMaxSize({width:2**53-1,height:e}),this.setMinSize({width:0,height:e})}},G=s(UsernameField),K={tag:`textarea`,cursor:`text`,overflow:`auto`,padding:new r(3,3,3,3),preferredSize:{width:200,height:200},minSize:{width:100,height:100},backgroundColor:`var(--ts-ui-input-bg, rgb(255, 255, 255))`,foregroundColor:`var(--ts-ui-text-color, black)`},TextArea=class extends E{constructor(e=``,t,n){super(e?{text:e,...t}:t,{...K,...n??{}}),this.setElementCSSRules({resize:`none`})}applyOptions(e){return super.applyOptions(e),e.rows!==void 0&&this.setRows(e.rows),e.cols!==void 0&&this.setCols(e.cols),e.wrap!==void 0&&this.setWrap(e.wrap),this}getRows(){return this._options.rows??null}setRows(e){return this._options.rows=e,this.setElementAttribute(`rows`,String(e)),this}clearRows(){return this._options.rows===void 0?this:(this._options.rows=void 0,this.removeElementAttribute(`rows`),this)}getCols(){return this._options.cols??null}setCols(e){return this._options.cols=e,this.setElementAttribute(`cols`,String(e)),this}clearCols(){return this._options.cols===void 0?this:(this._options.cols=void 0,this.removeElementAttribute(`cols`),this)}getWrap(){return this._options.wrap??null}setWrap(e){return this._options.wrap=e,this.setElementAttribute(`wrap`,e),this}clearWrap(){return this._options.wrap===void 0?this:(this._options.wrap=void 0,this.removeElementAttribute(`wrap`),this)}getBaseline(){return this.wrapInnerBaseline(n.measureTextBaseline())}init(t){super.init(t);let n=t||this.getElement();return this._options.rows!==void 0&&e.sink.apply(n,{setAttr:{rows:String(this._options.rows)}}),this._options.cols!==void 0&&e.sink.apply(n,{setAttr:{cols:String(this._options.cols)}}),this._options.wrap!==void 0&&e.sink.apply(n,{setAttr:{wrap:this._options.wrap}}),this}},q=s(TextArea),Toggle=class extends g{_track;_thumb;constructor(e){super({...e??{}}),this.setLayoutManager(new v),this._track=new c,this._track.setBackgroundColor(`var(--ts-ui-toggle-track-bg-off, rgb(200, 200, 200))`),this._track.setBorderRadius(`999px`),this._track.setPreferredSize({width:36,height:20}),this._track.setMinSize({width:36,height:20}),this._track.setMaxSize({width:36,height:20}),this._track.setCursor(`pointer`),this._thumb=new c,this._thumb.setBackgroundColor(`var(--ts-ui-toggle-thumb-bg, rgb(255, 255, 255))`),this._thumb.setBorderRadius(`999px`),this._thumb.setPreferredSize({width:16,height:16}),this._thumb.setMaxSize({width:16,height:16}),this._thumb.setSize({width:16,height:16}),this._thumb.setShadow(`0 1px 2px rgba(0, 0, 0, 0.25)`),this._thumb.setX(2),this._thumb.setY(2),this._thumb.setPointerEvents(`none`),l.isReducedMotion()||(this._thumb.setTransition(`transform 120ms ease-out`),this._track.setTransition(`background-color 120ms ease-out`)),this._track.addComponent(this._thumb),super.addComponent(this._track),this.getAria().setRole(`switch`),this.getAria().setTabIndex(0),this.getAria().setChecked(!1),this.setOutline(`none`),a.addListener(this._track,`click`,()=>this.activateFromPointer()),this.installKeyboard(),this._options.value!==void 0&&this.applyValue(this._options.value),this._options.label!==void 0&&this.applyLabel(this._options.label),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.value!==void 0&&(this._options.value=e.value),e.label!==void 0&&(this._options.label=e.label),e.enabled!==void 0&&(this._options.enabled=e.enabled),e.readOnly!==void 0&&(this._options.readOnly=e.readOnly),this}activate(){this.setValue(!this.getValue())}getInteractiveSurface(){return this._track}activationKeys(){return[` `,`Enter`]}getValue(){return this._options.value??!1}setValue(e){let t=!!e;return t===this.getValue()?this:(this._options.value=t,this.applyValue(t),this.notifyChange(t),this)}clearValue(){return this.setValue(!1)}getBaseline(){let e=this._label;if(e===null)return null;let t=e.getBaseline();return t===null?null:this.wrapInnerBaseline(t+this.labelCenterOffset())}labelCenterOffset(){if(this._label===null)return 0;let e=this._track.getPreferredSize()?.height??0,t=this._label.getPreferredSize()?.height??e;return Math.max(0,Math.round((e-t)/2))}doLayout(){super.doLayout();let e=this._label,t=this.labelCenterOffset();return e!==null&&t>0&&e.setY(e.getY()+t),this}applyValue(e){this.getAria().setChecked(e),this._thumb.setTransform(e?`translateX(16px)`:`translateX(0px)`),this._track.setBackgroundColor(e?`var(--ts-ui-toggle-track-bg-on, rgb(30, 100, 200))`:`var(--ts-ui-toggle-track-bg-off, rgb(200, 200, 200))`)}},J=s(Toggle),Y=22,X={durationMs:100,backgroundColor:`var(--ts-ui-autocomplete-bg, rgb(255, 255, 255))`,border:`var(--ts-ui-input-border)`,borderRadius:`var(--ts-ui-border-radius, 4px)`,shadow:`var(--ts-ui-autocomplete-shadow, 2px 4px 8px rgba(0,0,0,0.15))`};new o({scope:`selector`,name:`.AutoCompleteDropdown .List:focus::after`,styles:{content:`none`}});var AutoCompleteDropdown=class extends ee{_list;_onSelect;_onHide;constructor(e,t,n,r){super(n,{...X,...r??{}}),this._onSelect=e,this._onHide=t,this.setContain(`layout`),this.setLayoutManager(new p),this._list=new R,this._list.setBorder(`none`),this._list.setBorderRadius(`0`),this._list.setFocusOnRowClick(!1),this._list.setSelectFollowsFocus(!1),this.addComponent(this._list),this._list.on(`action`,()=>{let e=this._list.getValue();e&&this._onSelect(e)})}show(t,n){this.getElement(!0),this.pauseLayout(),this._list.setItemsArray(n.map(e=>({key:e,label:e}))),this.resumeLayout();let r=this.getPerimeterSize(),i=r.top+r.bottom,a=e.source.getElementRect(t);return this.setWidth(a.width),this.setHeight(n.length*Y+i),this.placeAnchored(a),this.setAnchorElement(t),this.showAnimated(),this.doLayout(),this}hide(){return this.hideAnimated(),this}handleKey(e){return this._list.handleKey(e)}getFocusedRowId(){return this._list.getFocusedRowId()}getList(){return this._list}onHideComplete(){this._onHide()}},ie=s(AutoCompleteDropdown);w(`.AutoCompleteField`);var AutoCompleteField=class extends h{_textField;_dropdown;_debounceTimer=null;_selectBag=new u;constructor(e){super(),this.setBorder(`var(--ts-ui-input-border)`),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),this._textField=new I,this._textField.setBorder(`none`),this._textField.setBorderRadius(`0`),this._textField.setOutline(`none`),this.addComponent(this._textField),this.syncSizeFromTextField(),this.subscribeTheme(()=>this.syncSizeFromTextField()),this._dropdown=new ie(e=>this.onSuggestionSelected(e),()=>this.onDropdownHidden()),this._textField.getAria().setRole(`combobox`),this._textField.getAria().setAutoComplete(`list`),this._textField.getAria().setExpanded(!1),this._textField.getAria().setControls(this._dropdown.getId()),this._textField.getAria().setActiveDescendant(``),a.addListener(this._textField,`input`,()=>this.onInput()),a.addListener(this._textField,`keydown`,e=>this.onKeyDown(e)),a.addListener(this._textField,`blur`,()=>this.onBlur()),this._textField.on(`change`,e=>this.notifyChange(e)),e&&this.applyOptions(e),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.suggestions!==void 0&&this.setSuggestions(e.suggestions),e.minChars!==void 0&&this.setMinChars(e.minChars),e.debounceMs!==void 0&&this.setDebounceMs(e.debounceMs),e.maxSuggestions!==void 0&&this.setMaxSuggestions(e.maxSuggestions),e.matchMode!==void 0&&this.setMatchMode(e.matchMode),e.placeholder!==void 0&&this.setPlaceholder(e.placeholder),e.store!==void 0&&e.displayField!==void 0?this.setStore(e.store,e.displayField):(e.store!==void 0&&(this._options.store=e.store),e.displayField!==void 0&&(this._options.displayField=e.displayField)),this}syncSizeFromTextField(){let e=this.getPerimeterSize(),t=e.left+e.right,n=e.top+e.bottom,r=this._textField.getPreferredSize(),a=this._textField.getMaxSize(),o=this._textField.getMinSize();r&&this.setPreferredSize({width:r.width,height:r.height+n}),a&&this.setMaxSize({width:i(a.width+t),height:i(a.height+n)}),o&&this.setMinSize({width:o.width,height:o.height+n})}getBaseline(){return this.wrapInnerBaseline(this._textField.getBaseline())}doLayout(){super.doLayout();let e=this.getContentBounds();return e?(this._textField.setX(e.x),this._textField.setY(e.y),this._textField.setWidth(e.width),this._textField.setHeight(e.height),this):this}setValue(e){return this._textField.setValue(e),this}getValue(){return this._textField.getValue()}applyEnabled(e){this._textField.setEnabled(e)}applyReadOnly(e){this._textField.setReadOnly(e)}setSuggestions(e){return this._options.suggestions=e,this}setStore(e,t){return this._options.store=e,this._options.displayField=t,this}setMinChars(e){return this._options.minChars=e,this}setDebounceMs(e){return this._options.debounceMs=e,this}setMaxSuggestions(e){return this._options.maxSuggestions=e,this}setMatchMode(e){return this._options.matchMode=e,this}setPlaceholder(e){return this._options.placeholder=e,this._textField.setPlaceholder(e),this}on(e,t){return e===`select`?(this._selectBag.add(`select`,t),this):super.on(e,t)}off(e,t){return e===`select`?(this._selectBag.remove(`select`,t),this):super.off(e,t)}addSelectListener(e){this.on(`select`,e)}onInput(){this._debounceTimer!==null&&clearTimeout(this._debounceTimer);let e=this._options.minChars??1,t=this.getValue();if(t.length<e){this._dropdown.hide();return}this._debounceTimer=setTimeout(()=>this.querySuggestions(t),this._options.debounceMs??200)}onKeyDown(e){if(this._dropdown.isOpen()&&(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`)&&this._dropdown.handleKey(e)){e.preventDefault(),this.updateActiveDescendant();return}switch(e.key){case`ArrowDown`:e.preventDefault(),this.querySuggestions(this.getValue());break;case`Escape`:this._dropdown.hide(),this._textField.focus();break;case`Tab`:this._dropdown.hide();break;default:break}}onBlur(){setTimeout(()=>{let t=e.source.getActiveElement(),n=this._dropdown.getElement();n&&e.source.contains(n,t)||this._dropdown.hide()},150)}matches(e,t){let n=this._options.matchMode??`contains`,r=n===`containsCaseSensitive`||n===`startsWithCaseSensitive`,i=n===`startsWith`||n===`startsWithCaseSensitive`,a=r?e:e.toLowerCase(),o=r?t:t.toLowerCase();return i?a.startsWith(o):a.includes(o)}querySuggestions(e){let t=this._options.maxSuggestions??10,n=this._options.matchMode??`contains`,r=this._options.suggestions,i=this._options.store,a=this._options.displayField;if(r!==void 0){let n=r.filter(t=>this.matches(t,e)).slice(0,t);e===this.getValue()&&this.showSuggestions(n);return}if(i!==void 0&&a!==void 0){let r=n===`containsCaseSensitive`||n===`startsWithCaseSensitive`,o=n===`startsWith`||n===`startsWithCaseSensitive`?`startsWith`:`contains`;i.clearFilter(),i.filterBy({type:o,field:a,value:e,caseSensitive:r});let s=i.getRecords().map(e=>String(e.get(a))).slice(0,t);e===this.getValue()&&this.showSuggestions(s)}}showSuggestions(e){if(e.length===0){this._dropdown.hide();return}this._dropdown.show(this._textField.getElement(!0),e),this._textField.getAria().setExpanded(!0)}onDropdownHidden(){this._textField.getAria().setExpanded(!1),this._textField.getAria().setActiveDescendant(``)}updateActiveDescendant(){this._textField.getAria().setActiveDescendant(this._dropdown.getFocusedRowId()??``)}onSuggestionSelected(e){this.setValue(e),this._selectBag.fire(`select`,e),this._dropdown.hide(),this._textField.focus()}},ae=s(AutoCompleteField);f.register(B,z);var oe={border:`none`,borderRadius:`0`,insets:new r(0,0,0,0)},SpinButton=class extends y{_listeners=new u;_repeat;constructor(e,t,n){super(void 0,t,{...oe,glyph:e===`▲`?`chevron-up`:`chevron-down`,...n??{}}),this.updateSize(),this.subscribeTheme(()=>this.updateSize()),t?.shadow===void 0&&this.clearShadow(),t?.pressedShadow===void 0&&this.clearPressedShadow(),this.pinGlyphSize(8),this.getGlyph()?.setTranslate(0,-1),this._repeat=new d({initialDelay:400,decay:.75,floor:40,onTick:()=>this.emit(`tick`)}),a.addListener(this,`mousedown`,()=>this.onMouseDown()),a.addViewportListener(this,`mouseup`,()=>this.onMouseUp()),a.addViewportListener(this,`mouseleave`,()=>this.onMouseUp()),this.applyListeners(t?.listeners)}updateSize(){let e=n.lineHeightPx()+6+2,t=Math.floor((e-2)/2);this.setPreferredSize({width:18,height:t}),this.setMinSize({width:18,height:t}),this.setMaxSize({width:18,height:t})}on(e,t){return e===`action`?a.addListener(this,`click`,t):this._listeners.add(e,t),this}off(e,t){return e===`action`?a.removeListener(this,`click`,t):this._listeners.remove(e,t),this}emit(e,...t){this._listeners.fire(e,...t)}onMouseDown(){this._repeat.start()}onMouseUp(){this._repeat.isRunning()&&this._repeat.stop()}},Z=s(SpinButton);w(`.NumberSpinner`),new o({scope:`selector`,name:`.NumberSpinner .TextField:focus`,styles:{boxShadow:`none`}});var se={insets:new r(0,0,0,0),border:`1px solid var(--ts-ui-button-border, rgb(200, 200, 200))`,borderRadius:`var(--ts-ui-border-radius, 4px)`,backgroundColor:`var(--ts-ui-input-bg, rgb(255, 255, 255))`},NumberSpinner=class extends h{_input;_upBtn;_downBtn;_btnBox;constructor(e,t){super(e,{...se,...t??{}}),this._input=new I,this._input.setTextAlign(`right`),this._input.setBorder(`none`),this._input.setBorderRadius(`0`),this._input.setOutline(`none`),this._input.setText(this.formatValue(0)),this._upBtn=new Z(`▲`),this._downBtn=new Z(`▼`),this._upBtn.setBorder({borderTop:`1px solid transparent`}),this._upBtn.setBorderRadius(`0`),this._downBtn.setBorder({borderTop:`1px solid var(--ts-ui-spinner-divider, rgb(180, 180, 180))`}),this._downBtn.setBorderRadius(`0`),this._btnBox=new c;let n=new _;n.setComponentSpacing(0),this._btnBox.setLayoutManager(n),this._btnBox.setInsets(new r(0,0,0,0)),this._btnBox.addComponent(this._upBtn),this._btnBox.addComponent(this._downBtn);let i=new v;i.setComponentSpacing(0),i.setStretching(!0),this.setLayoutManager(i),this.addComponent(this._input,{weight:1}),this.addComponent(this._btnBox),this._upBtn.on(`tick`,()=>this.applyValue(this.getValue()+this.getStep())),this._downBtn.on(`tick`,()=>this.applyValue(this.getValue()-this.getStep())),a.addListener(this._input,`blur`,()=>this.onBlur()),a.addListener(this._input,`keydown`,e=>this.onKeyDown(e)),this.updateHeight(),this.subscribeTheme(()=>this.updateHeight()),this.getAria().setRole(`spinbutton`),this.getAria().setValueNow(0),this._options.min!==void 0&&this.setMin(this._options.min),this._options.max!==void 0&&this.setMax(this._options.max),this._options.step!==void 0&&this.setStep(this._options.step),this._options.precision!==void 0&&this.setPrecision(this._options.precision),this._options.value!==void 0&&this.setValue(this._options.value),this._options.enabled!==void 0&&this.setEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.setReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.min!==void 0&&(this._options.min=e.min),e.max!==void 0&&(this._options.max=e.max),e.step!==void 0&&(this._options.step=e.step),e.precision!==void 0&&(this._options.precision=e.precision),e.value!==void 0&&(this._options.value=e.value),e.enabled!==void 0&&(this._options.enabled=e.enabled),this}getBaseline(){return this.wrapInnerBaseline(this._input.getBaseline())}updateHeight(){let e=n.singleLineBoxHeight(this.getInsets(),this._input.getPadding(),this.getBorderSize());this.setPreferredSize({width:120,height:e}),this.setMaxSize({width:t,height:e}),this.setMinSize({width:0,height:e})}getValue(){return this._options.value??0}setValue(e){return this._setValueSilent(e),this}getMin(){return this._options.min??-1/0}setMin(e){return this._options.min=e,this.getAria().setValueMin(isFinite(e)?e:null),this}getMax(){return this._options.max??1/0}setMax(e){return this._options.max=e,this.getAria().setValueMax(isFinite(e)?e:null),this}getStep(){return this._options.step??1}setStep(e){return this._options.step=e,this}getPrecision(){return this._options.precision??null}setPrecision(e){return this._options.precision=e,this._input.setText(this.formatValue(this.getValue())),this}applyEnabled(e){e?(this._input.setDisabledAttribute(!1),this._upBtn.setPointerEvents(`auto`),this._downBtn.setPointerEvents(`auto`),this.clearOpacity()):(this._input.setDisabledAttribute(!0),this._upBtn.setPointerEvents(`none`),this._downBtn.setPointerEvents(`none`),this.setOpacity(.5))}applyReadOnly(e){this._input.setReadOnly(e)}applyValue(e){if(!this.isEnabled())return;let t=this.normalize(e);if(t===this.getValue()){this._input.setText(this.formatValue(t));return}this._options.value=t,this._input.setText(this.formatValue(t)),this.getAria().setValueNow(t),this.notifyChange(t)}_setValueSilent(e){let t=this.normalize(e);this._options.value=t,this._input.setText(this.formatValue(t)),this.getAria().setValueNow(t)}normalize(e){let t=Math.min(this.getMax(),Math.max(this.getMin(),e));return t=Math.round(t/this.getStep())*this.getStep(),t=parseFloat(t.toFixed(this.derivePrecision())),t}onBlur(){let e=parseFloat(this._input.getText().valueOf());if(isNaN(e)){this._input.setText(this.formatValue(this.getValue()));return}this.applyValue(e)}onKeyDown(e){if(e.key===`ArrowUp`){e.preventDefault(),this.applyValue(this.getValue()+this.getStep());return}if(e.key===`ArrowDown`){e.preventDefault(),this.applyValue(this.getValue()-this.getStep());return}e.key===`Enter`&&this.onBlur()}formatValue(e){return e.toFixed(this.derivePrecision())}derivePrecision(){let e=this._options.precision??null;if(e!==null)return e;let t=String(this.getStep()),n=t.indexOf(`.`);return n>=0?t.length-n-1:0}},Q=s(NumberSpinner),ce=3,$=`no file selected`,HiddenFileInput=class extends c{_type=null;_multiple=!1;_accept=null;constructor(){super({tag:`input`}),this.setDisplayed(!1),this.setType(`file`)}getType(){return this._type}setType(e){this._type=e,this.setElementAttribute(`type`,e)}setMultipleAttribute(e){this._multiple=e,e?this.setElementAttribute(`multiple`,``):this.removeElementAttribute(`multiple`)}setAcceptAttribute(e){this._accept=e,this.setElementAttribute(`accept`,e)}setDisabled(e){this.setDisabledAttribute(e)}openPicker(){let t=this.getElement();t&&e.sink.click(t)}getFiles(){let t=this.getElement();return t?e.source.getFiles(t):null}clearFiles(){let t=this.getElement();t&&e.sink.setValue(t,``)}init(t){super.init(t);let n=t??this.getElement();return n?(this._type!==null&&e.sink.apply(n,{setAttr:{type:this._type}}),this._multiple&&e.sink.apply(n,{setAttr:{multiple:``}}),this._accept!==null&&e.sink.apply(n,{setAttr:{accept:this._accept}}),this):this}},FileField=class extends h{_button;_label;_input;_droppedFiles=[];constructor(e){super({...e??{}}),this.setLayoutManager(new v),this._button=new y(this.defaultButtonText()),this._button.on(`action`,()=>this.openPicker()),this._label=new m($,{truncate:!0}),this._label.setForegroundColor(`var(--ts-ui-form-text, inherit)`),this._input=new HiddenFileInput,a.addListener(this._input,`change`,()=>this.onNativeChange()),super.addComponent(this._button),super.addComponent(this._label,{weight:1}),super.addComponent(this._input),this._options.multiple!==void 0&&this.setMultiple(this._options.multiple),this._options.accept!==void 0&&this.setAccept(this._options.accept),this._options.buttonText!==void 0&&this._button.setText(this._options.buttonText),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.multiple!==void 0&&(this._options.multiple=e.multiple),e.accept!==void 0&&(this._options.accept=e.accept),e.buttonText!==void 0&&(this._options.buttonText=e.buttonText),this}defaultButtonText(){return this.isMultiple()?`Choose files…`:`Choose file…`}openPicker(){!this.isEnabled()||this.isReadOnly()||this._input.openPicker()}onNativeChange(){this._droppedFiles=[];let e=this.getValue();this.updateLabel(e),this.notifyChange(e)}acceptDroppedFiles(e){this._droppedFiles=Array.from(e);let t=this.getValue();this.updateLabel(t),this.notifyChange(t)}getValue(){if(this._droppedFiles.length>0)return this._droppedFiles;let e=this._input.getFiles();return e?Array.from(e):[]}setValue(e){return e&&e.length>0?(console.warn(`FileField '`+this.getId()+`' setValue ignored a non-empty File[]: the browser security model forbids programmatically populating a file input. Only setValue([]) (clearing) is supported.`),this):this.clearValue()}clearValue(){this._droppedFiles=[],this._input.clearFiles();let e=this.getValue();return this.updateLabel(e),this.notifyChange(e),this}isMultiple(){return this._options.multiple??!1}setMultiple(e){return this._options.multiple=!!e,this._input.setMultipleAttribute(this._options.multiple),this._options.buttonText===void 0&&this._button.setText(this.defaultButtonText()),this}getAccept(){return this._options.accept??null}setAccept(e){return this._options.accept=e,this._input.setAcceptAttribute(e),this}updateLabel(e){e.length===0?this._label.setText($):e.length===1?this._label.setText(e[0].name):e.length>ce?this._label.setText(e.length+` files`):this._label.setText(e.map(e=>e.name).join(`, `))}applyEnabled(e){this._button.setEnabled(e),this._input.setDisabled(!e)}applyReadOnly(e){this._button.setEnabled(!e&&this.isEnabled()),this.getAria().setReadOnly(e)}},le=s(FileField),ue=`var(--ts-ui-filedropzone-border, 2px dashed rgba(80, 140, 240, 0.40))`,de=`var(--ts-ui-filedropzone-bg, rgba(80, 140, 240, 0.06))`,fe=`var(--ts-ui-filedropzone-active-border, 2px dashed rgba(80, 140, 240, 0.80))`,pe=`var(--ts-ui-filedropzone-active-bg, rgba(80, 140, 240, 0.18))`,me=`Drop files here or click to browse`,FileDropZone=class extends h{_prompt;_field;_dragDepth=0;constructor(e){super({...e??{}}),this.setLayoutManager(new _),this._prompt=new m(this._options.promptText??me),this._prompt.setForegroundColor(`var(--ts-ui-form-text, inherit)`),this._field=new FileField(this.fieldOptions()),this._field.on(`change`,e=>this.notifyChange(e)),super.addComponent(this._prompt),super.addComponent(this._field),this.setActive(!1),this.setBorderRadius(`var(--ts-ui-border-radius, 4px)`),a.addSubtreeListener(this,`dragenter`,e=>this.onDragEnter(e)),a.addSubtreeListener(this,`dragover`,e=>this.onDragOver(e)),a.addSubtreeListener(this,`dragleave`,e=>this.onDragLeave(e)),a.addSubtreeListener(this,`drop`,e=>this.onDrop(e)),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.promptText!==void 0&&(this._options.promptText=e.promptText),this}fieldOptions(){return{multiple:this._options.multiple,accept:this._options.accept,buttonText:this._options.buttonText}}setActive(e){this.setBorder(e?fe:ue),this.setBackgroundColor(e?pe:de)}onDragEnter(e){e.preventDefault(),this._dragDepth++,this._dragDepth===1&&this.setActive(!0)}onDragOver(e){e.preventDefault()}onDragLeave(e){e.preventDefault(),this._dragDepth=Math.max(0,this._dragDepth-1),this._dragDepth===0&&this.setActive(!1)}onDrop(e){if(e.preventDefault(),this._dragDepth=0,this.setActive(!1),!this.isEnabled()||this.isReadOnly())return;let t=e.dataTransfer?.files;!t||t.length===0||this._field.acceptDroppedFiles(t)}getValue(){return this._field.getValue()}setValue(e){return this._field.setValue(e),this}clearValue(){return this._field.clearValue(),this}applyEnabled(e){this._field.setEnabled(e)}applyReadOnly(e){this._field.setReadOnly(e)}},he=s(FileDropZone);export{g as AbstractBooleanInput,h as AbstractInput,C as AbstractPickerField,ae as AutoCompleteField,A as Checkbox,F as ComboBox,V as DateField,j as DatePickerDropdown,H as DateTimeField,N as DateTimePickerDropdown,he as FileDropZone,le as FileField,b as Label,T as Link,Q as NumberSpinner,re as PasswordField,M as PickerButton,P as PickerCell,ne as PickerCellList,O as PickerColumn,k as PickerInput,te as RadioButton,x as Slider,Z as SpinButton,m as Text,q as TextArea,I as TextField,E as TextInput,D as TimeField,S as TimePickerDropdown,J as Toggle,G as UsernameField};
|
|
2
2
|
//# sourceMappingURL=input.es.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"../DOM-67StIm5G.js";import{n as t}from"../Position-Ck_KD4cR.js";import{h as n,t as r}from"../Component-
|
|
1
|
+
import{t as e}from"../DOM-67StIm5G.js";import{n as t}from"../Position-Ck_KD4cR.js";import{h as n,t as r}from"../Component-fRQvgaEY.js";import{t as i}from"../Glyph-wN7bk7mg.js";import{t as a}from"../Text-KB5LksJl.js";import{n as o,r as s}from"../VBox-P3WFGkPc.js";import{i as c,n as l,r as u,t as d}from"../List-CG4NvwuV.js";import{t as f}from"../reduceModifierSelection-DTo8HyFl.js";var MultiSelectList=class extends l{constructor(e){super(e),this.getAria().setMultiselectable(!0),this._options.selectedIndices!==void 0&&this.applyInitialSelection(this._options.selectedIndices)}applyOptions(e){return super.applyOptions(e),e.selectedIndices!==void 0&&(this._options.selectedIndices=e.selectedIndices),this}setValues(e){let t=new Set(e);this._selectedSet.clear();for(let e=0;e<this._items.length;e++)t.has(this._items[e].key)&&this._selectedSet.add(e);return this._selectedSet.size>0?this._anchorIndex=Math.max(...this._selectedSet):this._anchorIndex=null,this.refreshRowVisualState(),this.updateActiveDescendant(),this}setValue(e){return this.setValues(e)}getValue(){return[...this._selectedSet].sort((e,t)=>e-t).map(e=>this._items[e].key)}getSelectedRecords(){let e=this.getStore();if(!e)return[];let t=e.getRecords(),n=[...this._selectedSet].sort((e,t)=>e-t),r=[];for(let e of n)e<t.length&&r.push(t[e]);return r}setSelectedRecords(e){let t=this.getStore();if(!t)return this;let n=new Set(e),r=t.getRecords(),i=[];for(let e=0;e<this._items.length&&e<r.length;e++)n.has(r[e])&&i.push(this._items[e].key);return this.setValues(i)}reduceSelection(e,t){this._anchorIndex=f(this._selectedSet,this._anchorIndex,e,e=>e,e=>e,t),this._focusedIndex=e}notifyUserChange(){this.fireChange()}handleKeyDown(e){if(!(!this.isEnabled()||this.isReadOnly())){if((e.ctrlKey||e.metaKey)&&(e.key===`a`||e.key===`A`)){e.preventDefault(),this.selectAll();return}super.handleKeyDown(e)}}selectAll(){if(this._items.length!==0){this._selectedSet.clear();for(let e=0;e<this._items.length;e++)this._selectedSet.add(e);this._anchorIndex=0,this._focusedIndex=this._items.length-1,this.refreshRowVisualState(),this.updateActiveDescendant(),this.notifyUserChange()}}applyInitialSelection(e){this._selectedSet.clear();for(let t of e)t>=0&&t<this._items.length&&this._selectedSet.add(t);this._selectedSet.size>0&&(this._anchorIndex=Math.max(...this._selectedSet)),this.refreshRowVisualState(),this.updateActiveDescendant()}},p=n(MultiSelectList),AbstractMarkerList=class extends r{_markerColumnWidth=0;constructor(e,n,r,i){super(r,{tag:e,padding:new t(0,0,0,25),layoutManager:new o({spacing:0,stretching:!0}),itemStyle:n,...i??{}}),this.setElementCSSRule(`listStyleType`,`none`),this.getAria().setRole(`list`)}applyOptions(e){return super.applyOptions(e),this.setStyle(e.itemStyle??this.getStyle()),this}getStyle(){return this._style??this._defaultOptions.itemStyle}setStyle(e){return this._style=e,this.renumber(),this}getMarkerColumnWidth(){return this._markerColumnWidth}doLayout(){return this.isLayoutPaused()?this:(this.syncMarkerColumn(),super.doLayout())}syncMarkerColumn(){let e=this.getComponents(),t=0;for(let n of e)t=Math.max(t,n.getMarkerWidth());this._markerColumnWidth=t;for(let n of e)n.setMarkerColumnWidth(t)}renumber(){let e=this.getComponents();for(let t=0;t<e.length;t++)e[t].setMarker(this.markerText(t))}addComponent(e,t){return super.addComponent(e,t),this}insertComponent(e,t,n){return super.insertComponent(e,t,n),this.renumber(),this}removeComponent(e){let t=super.removeComponent(e);return this.renumber(),t}sortComponents(e){return super.sortComponents(e),this.renumber(),this}},m=function(e){return e.NONE=`none`,e.DISC=`disc`,e.CIRCLE=`circle`,e.SQUARE=`square`,e}({}),h={[m.NONE]:``,[m.DISC]:`•`,[m.CIRCLE]:`◦`,[m.SQUARE]:`▪`},BulletedList=class extends AbstractMarkerList{constructor(e){super(`ul`,m.DISC,e)}markerText(e){return h[this.getStyle()]}},g=n(BulletedList),_=function(e){return e.NONE=`none`,e.DECIMAL=`decimal`,e.DECIMAL_LEADING_ZERO=`decimal-leading-zero`,e.LOWER_ALPHA=`lower-alpha`,e.LOWER_GREEK=`lower-greek`,e.LOWER_LATIN=`lower-latin`,e.LOWER_ROMAN=`lower-roman`,e.UPPER_ALPHA=`upper-alpha`,e.UPPER_GREEK=`upper-greek`,e.UPPER_LATIN=`upper-latin`,e.UPPER_ROMAN=`upper-roman`,e}({}),v=2,y=3999,b=`abcdefghijklmnopqrstuvwxyz`,x=`αβγδεζηθικλμνξοπρστυφχψω`,S=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]];function alphabetic(e,t){let n=t.length,r=``,i=e;for(;i>0;)--i,r=t[i%n]+r,i=Math.floor(i/n);return r}function roman(e){if(e>y)return String(e);let t=``,n=e;for(let[e,r]of S)for(;n>=e;)t+=r,n-=e;return t}var C={[_.DECIMAL]:e=>String(e),[_.DECIMAL_LEADING_ZERO]:e=>String(e).padStart(v,`0`),[_.LOWER_ALPHA]:e=>alphabetic(e,b),[_.LOWER_LATIN]:e=>alphabetic(e,b),[_.UPPER_ALPHA]:e=>alphabetic(e,b).toUpperCase(),[_.UPPER_LATIN]:e=>alphabetic(e,b).toUpperCase(),[_.LOWER_GREEK]:e=>alphabetic(e,x),[_.UPPER_GREEK]:e=>alphabetic(e,x).toUpperCase(),[_.LOWER_ROMAN]:e=>roman(e),[_.UPPER_ROMAN]:e=>roman(e).toUpperCase()},NumberedList=class extends AbstractMarkerList{constructor(e){super(`ol`,_.DECIMAL,e)}markerText(e){let t=this.getStyle();return t===_.NONE?``:C[t](e+1)+`.`}},w=n(NumberedList),T=4,E={tag:`li`},ListItem=class extends r{_key;_marker;_text;constructor(e,t,n,r){super(n,{...E,layoutManager:new s({spacing:T}),...r??{}}),this._key=e,this._marker=new a(void 0,{textAlign:`right`}),this._text=new a,this.addComponent(this._marker),this.addComponent(this._text,{weight:1}),this._marker.getAria().setHidden(!0),this.getAria().setRole(`listitem`),this.setText(this._options.text??t),this.setMarker(``)}applyOptions(e){return super.applyOptions(e),e.text!==void 0&&(this._options.text=e.text),this}getKey(){return this._key}getText(){return this._text.getText().valueOf()}setText(e){return this._text.setText(e),this}getMarker(){return this._marker.getText().valueOf()}setMarker(e){return this._marker.setText(e),this._marker.setDisplayed(e.length>0),this}getMarkerWidth(){return this._marker.getPreferredSize(),this._marker.getPreferredSizeConstraint()?.width??0}setMarkerColumnWidth(e){return this._marker.setMinSize({width:e,height:0}),this}render(){let t=super.render();return e.sink.apply(t,{dataset:{key:this._key}}),t}},D=n(ListItem),O=20,k=16,GlyphListItemRenderer=class extends c{_icon=null;_label;_currentGlyph=null;_measured=!1;constructor(){super(),this.clearInsets(),this._label=new a,this._label.clearInsets(),this._label.setAutoMeasure(!1)}update(t){let n=t.item.glyph?t.item.glyph:null;if(n!==this._currentGlyph){let t=this.getElement();if(t&&this._icon){let n=this._icon.getElement();n&&e.source.getParentNode(n)===t&&e.sink.removeChild(t,n)}this._icon=null,this._currentGlyph=n,n!==null&&(this._icon=new i(n),this._icon.clearInsets(),this._icon.setPointerEvents(`none`),t&&e.sink.insertBefore(t,this._icon.getElement(!0),this._label.getElement()??null))}this._label.setText(t.item.label),this._measured=!1}getContentWidth(){this._measured||=(this._label.measure(),!0);let e=this._label.getPreferredSize()?.width??0;return(this._icon?O:0)+e}layoutChildren(e,t){let n=this.getContentBounds()??{x:0,y:0,width:e,height:t};this._icon&&(this._icon.setAutoCommitStyle(!1),this._icon.setX(n.x),this._icon.setY(n.y+Math.max(0,(n.height-k)/2)),this._icon.setWidth(k),this._icon.setHeight(k),this._icon.setAutoCommitStyle(!0));let r=n.x+(this._icon?O:0),i=Math.max(0,n.x+n.width-r);this._label.setAutoCommitStyle(!1),this._label.setX(r),this._label.setY(n.y),this._label.setWidth(i),this._label.setHeight(n.height),this._label.setLineHeight(n.height),this._label.setAutoCommitStyle(!0)}init(t){super.init(t);let n=t||this.getElement();return n?(this._icon&&e.sink.appendChild(n,this._icon.getElement(!0)),e.sink.appendChild(n,this._label.getElement(!0)),this):this}},A=n(GlyphListItemRenderer);export{AbstractMarkerList,g as BulletedList,m as BulletedListItemStyle,A as GlyphListItemRenderer,u as LabelListItemRenderer,d as List,D as ListItem,c as ListItemRenderer,p as MultiSelectList,w as NumberedList,_ as NumberedListItemStyle};
|
|
2
2
|
//# sourceMappingURL=list.es.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"../DOM-67StIm5G.js";import{n as t}from"../Position-Ck_KD4cR.js";import{S as n,h as r,t as i}from"../Component-
|
|
1
|
+
import{t as e}from"../DOM-67StIm5G.js";import{n as t}from"../Position-Ck_KD4cR.js";import{S as n,h as r,t as i}from"../Component-fRQvgaEY.js";import{t as a}from"../Container-0bsG2Q8Z.js";import{t as o}from"../Glyph-wN7bk7mg.js";import{t as s}from"../RovingTabIndex-DFJyoveq.js";import{n as c,r as l}from"../VBox-P3WFGkPc.js";import{t as u}from"../Button-MZDYJOMC.js";import{t as d}from"../Menu-CrZy2u0g.js";import{t as f}from"../Spacer-qalSEJ5i.js";import{ellipsis_v as p}from"../glyphs/solid/ellipsis_v.es.js";var m={backgroundColor:`var(--ts-ui-menu-bar-btn-bg, transparent)`,foregroundColor:`var(--ts-ui-menu-bar-btn-fg, inherit)`,cursor:`pointer`},h=4,g=10,MenuBarButton=class extends u{_onClickHandler;_onMouseOverHandler;constructor(e,r,i,a,o){super(e,{...a,chromeless:!0,styleRules:[...a?.styleRules??[],{suffix:`:hover`,styles:{backgroundColor:`var(--ts-ui-menu-bar-btn-hover-bg, rgba(30, 100, 200, 0.10))`}}]},{...m,...o??{}}),this._content.getLayoutManager().setComponentSpacing(h),this.setInsets(new t(0,g,0,g)),this.getAria().setRole(`menuitem`),this.getAria().setHasPopup(`menu`),this.getAria().setExpanded(!1),this._onClickHandler=()=>{r()},this._onMouseOverHandler=()=>{i()},n.addListener(this,`click`,this._onClickHandler),n.addListener(this,`mouseover`,this._onMouseOverHandler)}computePreferredSize(){let{width:e}=super.computePreferredSize();return{width:e,height:28}}setActive(e){return this.setBackgroundColor(e?`var(--ts-ui-menu-bar-btn-hover-bg, rgba(30, 100, 200, 0.10))`:`var(--ts-ui-menu-bar-btn-bg, transparent)`),this.getAria().setExpanded(e),this.setTooltipSuppressed(e),this}},_=r(MenuBarButton),MenuBar=class extends i{_buttons=[];_panels=[];_openIndex=-1;_quickSwitchActive=!1;_keydownListening=!1;_onKeyDown;constructor(e){super(e);let t=new l;t.setComponentSpacing(0),t.setStretching(!0),this.setLayoutManager(t),this.setBackgroundColor(`var(--ts-ui-menu-bar-bg, rgb(245, 245, 245))`),this.setElementCSSRule(`borderBottom`,`1px solid var(--ts-ui-menu-bar-border, rgb(220, 220, 220))`),this.setMinSize({width:0,height:28}),this.getAria().setRole(`menubar`),this.getAria().setLabel(`Main menu`),this.getAria().setTabIndex(0),this._onKeyDown=e=>{if(this._openIndex<0)return;let t=this._panels[this._openIndex];switch(e.key){case`Escape`:return this.closeMenu(),{stop:!0,prevent:!0};case`ArrowLeft`:return this.openMenu((this._openIndex-1+this._panels.length)%this._panels.length),{stop:!0,prevent:!0};case`ArrowRight`:return this.openMenu((this._openIndex+1)%this._panels.length),{stop:!0,prevent:!0};case`ArrowDown`:return t.getFocusedIndex()<0?t.focusItem(0):t.focusNext(),{stop:!0,prevent:!0};case`ArrowUp`:return t.focusPrev(),{stop:!0,prevent:!0};case`Enter`:return t.activateFocused(),{stop:!0,prevent:!0}}},e?.menus&&this.setMenus(e.menus)}setMenus(e){this._openIndex>=0&&this.closeMenu();for(let e of this._panels)e.dispose();this._buttons.length=0,this._panels.length=0,this.disposeAllComponents();for(let t=0;t<e.length;t++){let n=e[t],r=t,i=new _(n.label,()=>{this._openIndex===r?this.closeMenu():this.openMenu(r)},()=>{this._quickSwitchActive&&this._openIndex!==r&&this.openMenu(r)},n.glyph===void 0?void 0:{glyph:n.glyph}),a=new d(n.items,()=>{this.closeMenu()});this._buttons.push(i),this._panels.push(a),this.addComponent(i)}return this}destructor(){for(let e of this._panels)e.dispose();super.destructor()}openMenu(e){return e<0||e>=this._panels.length||e===this._openIndex?this:(this._openIndex>=0&&(this._panels[this._openIndex].close(),this._buttons[this._openIndex].setActive(!1)),this._openIndex=e,this._quickSwitchActive=!0,this._buttons[e].setActive(!0),this._panels[e].setExcludedElement(this._buttons[e].getElement(!0)),this._panels[e].open(this._buttons[e].getElement(!0)),this._keydownListening||(this._keydownListening=!0,n.addViewportListener(this,`keydown`,this._onKeyDown)),this)}closeMenu(){return this._openIndex<0?this:(this._panels[this._openIndex].close(),this._buttons[this._openIndex].setActive(!1),this._openIndex=-1,this._quickSwitchActive=!1,this._keydownListening&&(this._keydownListening=!1,n.removeViewportListener(this,`keydown`,this._onKeyDown)),this)}getOpenIndex(){return this._openIndex}},v=r(MenuBar);o.register(p);var y=4,b=`ellipsis-v`,x={orientation:`horizontal`,compact:!0,overflow:`clip`,overflowSide:`end`,flat:!0,backgroundColor:`var(--ts-ui-toolbar-bg, rgb(245, 245, 245))`},ToolBar=class extends a{constructor(e,t){super(e,{...x,...t??{}}),this.getAria().setRole(`toolbar`),this.getAria().setTabIndex(0),this._onKeyDown=e=>{let t=this._orientation===`horizontal`,n=t?`ArrowRight`:`ArrowDown`,r=t?`ArrowLeft`:`ArrowUp`;e.key===n?(e.preventDefault(),this._rovingTabIndex.moveNext()):e.key===r&&(e.preventDefault(),this._rovingTabIndex.movePrev())},n.addSubtreeListener(this,`keydown`,this._onKeyDown)}applyOptions(e){return super.applyOptions(e),this.setOrientation(e.orientation??this.getOrientation()),this.setCompact(e.compact??this.isCompact()),this.setOverflowSide(e.overflowSide??this.getOverflowSide()),this.setOverflow(e.overflow??this.getOverflow()),this.setFlat(e.flat??this.isFlat()),this}setOrientation(e){if(e===this._orientation)return this;let t=this.getLayoutManager(),n=t instanceof l||t instanceof c?t.getComponentSpacing():0,r=e===`horizontal`?new l:new c;r.setComponentSpacing(n),r.setStretching(!0),this.setLayoutManager(r),this._orientation=e,this.getAria().setOrientation(e);let i=`var(--ts-ui-toolbar-border, rgb(220, 220, 220))`;return e===`horizontal`?this.setBorder({borderBottom:`1px solid ${i}`}):this.setBorder({borderRight:`1px solid ${i}`}),this}getOrientation(){return this._orientation??this._defaultOptions.orientation}setCompact(e){if(e===this._compact)return this;this._compact=e;let n=e?0:4;this.setInsets(new t(n,n,n,n));for(let t of this.getComponents())t instanceof u&&t.setCompact(e);return this.doLayout(),this}isCompact(){return this._compact??this._defaultOptions.compact}setOverflow(e){return this._overflowMode=e,e===`menu`&&this._overflowButton===void 0&&this._createOverflowAffordance(),this.doLayout(),this}_createOverflowAffordance(){let e=new u({flat:!0,glyph:b});e.setDisplayed(!1),e.getAria().setLabel(`More`),e.getAria().setHasPopup(`menu`),e.on(`action`,()=>{this._toggleOverflowMenu()}),this._overflowButton=e,this._overflowMenu=new d,this._overflowSpacer=f.flex(),super.addComponent(e),this._positionOverflowTrigger()}_positionOverflowTrigger(){let e=this._overflowButton,t=this._overflowSpacer;e==null||t==null||(this._overflowSide===`end`?(t.getParentComponent()!==this&&super.addComponent(t),this.moveComponent(e,this.getComponents().length-1),this.moveComponent(t,this.getComponents().length-2)):(t.getParentComponent()===this&&this.removeComponent(t),this.moveComponent(e,0)))}getOverflow(){return this._overflowMode??this._defaultOptions.overflow}setOverflowSide(e){return e===this._overflowSide?this:(this._overflowSide=e,this._positionOverflowTrigger(),this.doLayout(),this)}getOverflowSide(){return this._overflowSide??this._defaultOptions.overflowSide}setFlat(e){if(e===this._flat)return this;this._flat=e;for(let t of this.getComponents())t instanceof u&&t.setFlat(e);return this}isFlat(){return this._flat??this._defaultOptions.flat}addComponent(e,t){return super.addComponent(e,t),this._rovingTabIndex===void 0&&(this._rovingTabIndex=new s),e.getAria().getTabIndex()!==-1&&this._rovingTabIndex.add(e),this._flat&&e instanceof u&&e.setFlat(!0),this._compact&&e instanceof u&&e.setCompact(!0),this._positionOverflowTrigger(),this}doLayout(){return super.doLayout(),this._overflowMode!==`menu`||this._orientation!==`horizontal`||this._overflowButton===void 0||this._overflowButton===null||this._reflowOverflow(this._overflowButton),this}_reflowOverflow(e){let t=this.getInsets(),n=this.getWidth()-t.getLeft()-t.getRight(),r=this.getLayoutManager(),i=r instanceof l?r.getComponentSpacing():y,a=this.getComponents().filter(t=>t!==e&&t!==this._overflowSpacer),o=this._computeOverflowed(a,e,n,i),s=!1;for(let e of a){let t=o.includes(e);e.isDisplayed()===t&&(e.setDisplayed(!t),s=!0)}let c=o.length>0;e.isDisplayed()!==c&&(e.setDisplayed(c),s=!0),s&&super.doLayout()}_computeOverflowed(e,t,n,r){let widthOf=e=>e.getPreferredSize()?.width??0,i=0;for(let t=0;t<e.length;t++)i+=widthOf(e[t]),t>0&&(i+=r);if(i<=n)return[];let a=n-(widthOf(t)+r),o=[],s=0,c=!1;for(let t=0;t<e.length;t++){let n=e[t],i=s+widthOf(n)+(t>0?r:0);i>a&&(c=!0),c&&n instanceof u?o.push(n):s=i}return o}destructor(){this._overflowMenu?.dispose(),super.destructor()}_toggleOverflowMenu(){let t=this._overflowButton,n=this._overflowMenu;if(t==null||n==null)return;let r=[];for(let e of this.getComponents()){if(e===t||e.isDisplayed()||!(e instanceof u))continue;let n=e.getGlyph()?.getGlyphName();r.push({text:e.getText(),glyph:n,action:()=>{e.click()}})}let i=t.getElement();if(!i)return;let a=e.source.getViewportRect(t);n.toggleFor(i,a,r)}},S=r(ToolBar),C={},w=r(class ToolBarSeparator extends i{static THICKNESS=1;_orientation;constructor(e,t){super(e,{...C,...t??{}}),this._orientation=e?.orientation??`vertical`,this._orientation===`vertical`?(this.setPreferredSize({width:ToolBarSeparator.THICKNESS,height:0}),this.setMaxSize({width:ToolBarSeparator.THICKNESS,height:Number.MAX_VALUE})):(this.setPreferredSize({width:0,height:ToolBarSeparator.THICKNESS}),this.setMaxSize({width:Number.MAX_VALUE,height:ToolBarSeparator.THICKNESS})),this.setBackgroundColor(`var(--ts-ui-toolbar-separator-color, rgb(220, 220, 220))`),this.getAria().setRole(`separator`),this.getAria().setOrientation(this._orientation),this.getAria().setTabIndex(-1)}getOrientation(){return this._orientation}});export{v as MenuBar,_ as MenuBarButton,S as ToolBar,w as ToolBarSeparator};
|
|
2
2
|
//# sourceMappingURL=menubar.es.js.map
|