10 lines
28 KiB
JavaScript
10 lines
28 KiB
JavaScript
"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[319],{56176:(e,t,i)=>{i.r(t),i.d(t,{LineToolTable:()=>Oe});var o=i(50151),s=i(86441),l=i(7029),n=i(42752),r=i(29875),a=i(10568),h=i(49156),c=i(24633),d=i(32679),u=i(11402),p=i(30699),x=i(31229),_=i(38039),g=i(6590),m=i(12988),C=i(73305),f=i(7114),T=i(2844),b=i(68979),w=i(15938);class P{constructor(e){this._textWidthCache=new T.TextWidthCache(1e3),this.setFont(e)}setFont(e){this._fontSize=e,this._font=(0,b.makeFont)(e,w.CHART_FONT_FAMILY)}font(){return this._font}textWidthCache(){return this._textWidthCache}getSymbolWidth(){return(0,f.measureText)("0",this._font,this._textWidthCache).width}getSymbolHeight(){return this._fontSize}}var y=i(17330);function v(e,t){return Math.max(e-16-2,t.getSymbolWidth())}function S(e,t,i){const o=(0,y.wordWrap)(e,i.font(),i.textWidthCache(),!0,t).length,s=i.getSymbolHeight();return o*s+(o-1)*(s*(1.3-1))+16+2}function R(e){return e.getSymbolHeight()+16+1}function I(e){return e.getSymbolWidth()+16+2}function H(e,t,i,o){let s=0;for(let e=0;e<i;e++)s+=t[e];const l=t[i];return[Math.round((e+s)*o),Math.round((e+s+l)*o)]}const{colorWhite:E,colorColdGray200:W,colorColdGray650:A,colorColdGray900:V}=h.colors,M={intervalsVisibilities:{...x.intervalsVisibilitiesDefaults},fontSize:14,horzAlign:p.HorizontalAlign.Left,anchored:!1},z=new Map([[c.StdTheme.Light,{backgroundColor:E,borderColor:W,textColor:V}],[c.StdTheme.Dark,{backgroundColor:V,borderColor:A,textColor:W}]]),D=(0,d.extractThemedColors)((0,o.ensureDefined)(z.get(c.StdTheme.Light)),(0,o.ensureDefined)(z.get(c.StdTheme.Dark))),L=(0,d.extractAllPropertiesKeys)((0,o.ensureDefined)(z.get(c.StdTheme.Light))),B=(0,d.extractAllPropertiesKeys)(M),N=[...new Set([...L,...B,"rowsCount","colsCount","cells.*","columnWidths.*","rowHeights.*"])],k=[...new Set([...N,...g.commonLineToolPropertiesStateKeys])];class F extends _.LineDataSourceProperty{constructor(e){if(super(e),this._tableTextCache=new P(14),!e.state){const e=3,t=3,i=[];for(let o=0;o<e;o++)i.push(new Array(t).fill(""));const o=new Array(t).fill(120),s=new Array(e).fill(0);this.recreateCellsPropsByState({rowsCount:e,colsCount:t,cells:i,columnWidths:o,rowHeights:s})}this.addChild("linesColors",new C.LineToolColorsProperty([(0,o.ensureDefined)(this.child("borderColor"))])),this.addChild("textsColors",new C.LineToolColorsProperty([(0,o.ensureDefined)(this.child("textColor"))])),this.addChild("backgroundsColors",new C.LineToolColorsProperty([(0,o.ensureDefined)(this.child("backgroundColor"))])),this.addChild("editableText",new m.Property(""))}recreateCellsPropsByState(e){const{cells:t,colsCount:i,rowsCount:o,columnWidths:s,rowHeights:l}=e;this.removeProperty("rowsCount"),this.removeProperty("colsCount"),this.removeProperty("cells"),this.removeProperty("columnWidths"),this.removeProperty("rowHeights"),this.addChild("rowsCount",new m.Property(o)),this.addChild("colsCount",new m.Property(i)),this.addChild("cells",new m.Property(t)),this.addChild("columnWidths",new m.Property(s)),
|
|
this.addChild("rowHeights",new m.Property(l)),this.childs().rowsCount.fireChanged(),this.childs().colsCount.fireChanged(),this.childs().cells.fireChanged(),this.childs().columnWidths.fireChanged(),this.childs().rowHeights.fireChanged()}setTableTextCache(e){this._tableTextCache=e}columnWidthValues(){const{colsCount:e,columnWidths:t}=this.childs(),i=t.childs();return Array.from({length:e.value()},((e,t)=>i[t].value()))}rowHeightValues(){const{rowsCount:e,rowHeights:t}=this.childs(),i=t.childs();return Array.from({length:e.value()},((e,t)=>i[t].value()))}setColumnWidthValues(e){const t=this.childs(),i=t.colsCount.value(),o=I(this._tableTextCache);for(let s=0;s<i;s++)t.columnWidths.childs()[s].setValue(Math.max(e[s],o))}setRowHeightValues(e){const t=this.childs(),i=t.rowsCount.value(),o=R(this._tableTextCache);for(let s=0;s<i;s++)t.rowHeights.childs()[s].setValue(Math.max(e[s],o))}cellsValues(){const{rowsCount:e,colsCount:t,cells:i}=this.childs(),o=i.childs();return Array.from({length:e.value()},((e,i)=>Array.from({length:t.value()},((e,t)=>o[i].childs()[t].value()))))}static create(e,t){return new this({defaultName:"linetooltable",factoryDefaultsSupplier:()=>(0,u.factoryDefaultsForCurrentTheme)(M,z),nonThemedDefaultsKeys:B,themedDefaultsKeys:L,allStateKeys:k,themedColors:D,replaceThemedColorsOnThemeChange:!0,state:t,theme:e,templateKeys:N})}}var O,K=i(69186),U=i(56468),G=i(95201),Y=i(32211),$=i(19063),j=i(72791),X=i(32563),q=i(62689);!function(e){e[e.TopLeft=0]="TopLeft",e[e.BottomLeft=1]="BottomLeft",e[e.TopRight=2]="TopRight",e[e.BottomRight=3]="BottomRight",e[e.ResizeVirtualAnchorBase=1024]="ResizeVirtualAnchorBase"}(O||(O={}));var J,Q=i(34026),Z=i(61993),ee=i(30125),te=i(37743),ie=i(97085);function oe(e){if(e<O.ResizeVirtualAnchorBase)return{row:null,column:null};const t=e-O.ResizeVirtualAnchorBase,i=Math.floor(t/O.ResizeVirtualAnchorBase),o=t%O.ResizeVirtualAnchorBase;return{row:0===i?null:i-1,column:0===o?null:o-1}}function se(e){return null===e.row&&null===e.column?null:O.ResizeVirtualAnchorBase+(null===e.row?0:e.row+1)*O.ResizeVirtualAnchorBase+(null===e.column?0:e.column+1)}!function(e){e[e.EdgeHighlightWidth=7]="EdgeHighlightWidth"}(J||(J={}));const le=h.colors.colorTvBlue500Alpha20,ne=h.colors.colorTvBlue500;class re extends ee.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._cellsHitTestData=[]}setData(e){this._data=e}setCellsHitTestData(e){this._cellsHitTestData=e}hitTest(e,t){if(!this._data)return null;const{horizontalPixelRatio:i,verticalPixelRatio:l}=t,{activeEdge:n,changeSize:r,changeOnlyActiveEdge:a,cells:h}=this._data,{x:c,y:d}=h.topLeft,{x:u,y:p}=h.bottomRight,x=d/l,_=c/i,g=p/l,m=u/i;{let t=null,c=null;const d=(0,Z.interactionTolerance)().line;for(const i of h.cells){const{bottom:o,rowIndex:n}=i[0],r=o/l;if(t=(0,Q.pointInBox)(e,(0,s.box)((0,s.point)(_,r-d),(0,s.point)(m,r+d)))?n:null,null!==t)break}for(const t of h.cells[0]){const{right:o,columnIndex:l}=t,n=o/i;if(c=(0,Q.pointInBox)(e,(0,s.box)((0,s.point)(n-d,x),(0,s.point)(n+d,g)))?l:null,null!==c)break}
|
|
if(r&&(null!==c||null!==t)){const e={row:t,column:c},i=null!==c&&null!==t?j.PaneCursorType.Default:null!==c?j.PaneCursorType.HorizontalResize:j.PaneCursorType.VerticalResize;return new U.HitTestResult(a&&c!==n.column&&t!==n.row?U.HitTarget.MovePoint:U.HitTarget.ChangePoint,{cursorType:i,activeItem:e,pointIndex:(0,o.ensureNotNull)(se(e)),nonDiscreteIndex:!0})}}for(const t of h.cells)for(const o of t){const{left:t,right:n,top:r,bottom:a,rowIndex:h,columnIndex:c}=o,d=r/l,u=t/i,p=a/l,x=n/i;if((0,Q.pointInBox)(e,(0,s.box)((0,s.point)(u,d),(0,s.point)(x,p))))return new U.HitTestResult(U.HitTarget.MovePoint,{...this._cellsHitTestData[h]?.[c],activeItem:{rowIndex:h,columnIndex:c}})}return(0,Q.pointInBox)(e,(0,s.box)((0,s.point)(_,x),(0,s.point)(m,g)))?new U.HitTestResult(U.HitTarget.MovePoint):null}_drawImpl(e){if(null===this._data)return;const t=e.context,i=this._data;!function(e,t){e.fillStyle=t.backgroundColor;const{x:i,y:o}=t.cells.topLeft,{x:s,y:l}=t.cells.bottomRight;e.fillRect(i,o,s-i,l-o)}(t,i),function(e,t){const i=(0,Z.roundToMax)(1*e.horizontalPixelRatio),o=(0,Z.roundToMax)(1*e.verticalPixelRatio),s=e.context;s.fillStyle=t.borderColor;const[l,n]=t.editableCell||[-1,-1];let[r,a]=t.selectableCell||[-1,-1];l===r&&n===a&&(r=-1,a=-1);for(const h of t.cells.cells)for(const c of h){const{left:h,right:d,top:u,bottom:p,columnIndex:x,rowIndex:_}=c;if(0===_&&s.fillRect(h,u,d-h,o),0===x&&s.fillRect(h,u,i,p-u),s.fillRect(h,p,d-h,o),s.fillRect(d,u,i,p-u),l===_&&n===x||r===_&&a===x){const l=(0,Z.roundToMax)(2*e.horizontalPixelRatio),n=(0,Z.roundToMax)(2*e.verticalPixelRatio);s.fillStyle=ne,[[h+i,u+o,d-h-i,n],[h+i,p-n,d-h-i,n],[h+i,u+o,l,p-u-o],[d-l,u+o,l,p-u-o]].forEach((([e,t,i,o])=>{s.fillRect(e,t,i,o)})),s.fillStyle=t.borderColor}}}(e,i),function(e,t,i){if(null===t.activeEdge.row&&null===t.activeEdge.column)return;const o=Math.max(1,Math.round(7*i.horizontalPixelRatio));if(e.strokeStyle=le,e.lineWidth=o,null!==t.activeEdge.column){const i=t.cells.cells[0][t.activeEdge.column];(0,te.drawVerticalLine)(e,i.right,t.cells.topLeft.y,t.cells.bottomRight.y)}if(null!==t.activeEdge.row){const i=t.cells.cells[t.activeEdge.row][0];(0,te.drawHorizontalLine)(e,i.bottom,t.cells.topLeft.x,t.cells.bottomRight.x)}}(t,i,e)}}class ae extends Y.InplaceTextLineSourcePaneView{constructor(e,t,i,o,l,n){super(e,t,o,l,n),this._renderer=new G.CompositeRenderer,this._cellsTextRenderers=[],this._lastRenderingInfo=null,this._tryActivateEditMode=(e,t)=>{this.closeTextEditor(),this._source.setInplaceEditableCellIndexes(e),super._tryActivateEditMode(e,t)},this._anchorClickHandler=()=>{this._source.setInplaceEditableCellIndexes([-1,-1])},this._tableTextCache=i,this._anchorPoints=Array.from({length:4},((e,t)=>({point:(0,s.point)(NaN,NaN),pointIndex:t,cursorType:t===O.TopLeft||t===O.BottomRight?j.PaneCursorType.DiagonalNwSeResize:j.PaneCursorType.DiagonalNeSwResize,hitTarget:U.HitTarget.ChangePoint,nonDiscreteIndex:t===O.TopRight||t===O.BottomRight}))),this._tableRenderer=new re,this._source.setAdditionalCursorData((()=>{const e=this._getTextEditableRenderer()
|
|
;return e?{color:this._source.editableTextStyle().cursorColor,...e.getTextInfo()}:{color:this._source.editableTextStyle().cursorColor,lineSpacing:0,lineHeight:0}}),(e=>{const t=this._getTextEditableRenderer();return t?t.positionToCoordinate(e):{x:0,y:0,lineNumber:0}}))}renderer(e){return this._lastRenderingInfo=e,this._invalidated&&this._updateImpl(e),this._renderer}lastRenderingInfo(){return this._lastRenderingInfo}_updateImpl(e){super._updateImpl(e),this._renderer.clear();const t=this._source.priceScale();if(!t||t.isEmpty())return;if(!this._points||this._source.isFixed()&&void 0===this._source.fixedPoint())return;const i=this._source.isFixed()?[(0,o.ensureDefined)(this._source.fixedPoint())]:this._points;if(i.length<1)return;const[l]=i,n=this._source.properties(),r=n.childs(),a=(0,K.lastMouseOrTouchEventInfo)().isTouch;let h={column:null,row:null};if((a?this._source.model().selection().dataSources()[0]:this._source.model().hoveredSource())===this._source){const e=X.mobiletouch?this._source.model().lastSelectedHittestData():this._source.model().lastHittestData(),t=e?.activeItem;(function(e){return(0,ie.isObject)(e)&&"row"in e&&"column"in e})(t)&&(h=t)}const c={columnWidths:this._source.columnWidths(),rowHeights:this._source.rowHeights(),texts:n.cellsValues(),leftTop:l,borderColor:r.borderColor.value(),backgroundColor:r.backgroundColor.value(),textColor:r.textColor.value(),fontSize:r.fontSize.value(),horzAlign:r.horzAlign.value()};this._updateTextRenderers(e,c);const d=this._rawPrecalculatedData(c,e);this._tableRenderer.setData({...c,editableCell:this._getTextEditableCellIndexes(),selectableCell:this._getSelectableCellIndexes(),cells:d,activeEdge:h,changeSize:this._model.selection().isSelected(this._source),changeOnlyActiveEdge:a}),this._setTextRendererPositions(d,e),this._renderer.append(this._tableRenderer),this._cellsTextRenderers.forEach((e=>e.forEach((e=>this._renderer.append(e)))));const{x:u,y:p}=d.topLeft,{x,y:_}=d.bottomRight,{horizontalPixelRatio:g,verticalPixelRatio:m}=e,C=u/g,f=p/m,T=x/g,b=_/m,w=this._source.isFixed();this._anchorPoints[O.TopLeft].point=(0,s.point)(C,f),this._anchorPoints[O.TopLeft].nonDiscreteIndex=w,this._anchorPoints[O.BottomLeft].point=(0,s.point)(C,b),this._anchorPoints[O.BottomLeft].nonDiscreteIndex=w,this._anchorPoints[O.TopRight].point=(0,s.point)(T,f),this._anchorPoints[O.BottomRight].point=(0,s.point)(T,b),this._renderer.append(this.createLineAnchor({points:this._anchorPoints,clickHandler:this._anchorClickHandler},0)),this._model.selection().isSelected(this._source)||(this.closeTextEditor(),this._source.setInplaceEditableCellIndexes([-1,-1]))}_activateEditMode(e){super._activateEditMode(e);const t=this._getTextEditableRenderer();null!==t&&(t.setCursorType(this._textCursorType()),this._updateInplaceText(t.getTextInfo()))}_textColorForCell([e,t]){const i=this._source.properties().childs().textColor.value();let o;return o=this._isEditableCell([e,t])?this._text():this._source.cellText(e,t),o?i:(0,$.generateColor)(i,50,!0)}_isEditableCell([e,t]){
|
|
const i=this._getTextEditableCellIndexes();return i[0]===e&&i[1]===t}_updateTextRenderers(e,t){if(t)if(this._cellsTextRenderers.length!==t.texts.length||this._cellsTextRenderers[0].length!==t.texts[0].length){const e=[],i=[];for(let o=0;o<t.texts.length;o++){const s=t.texts[o],l=[],n=[];for(let e=0;e<s.length;e++){const i=(0,Y.inplaceEditHandlers)(this._tryActivateEditMode.bind(this,[o,e]));n.push(i),l.push(new q.LineToolTextRenderer({text:s[e],font:w.CHART_FONT_FAMILY,fontSize:t.fontSize,lineHeight:1.3,color:this._textColorForCell([o,e]),horzAlign:t.horzAlign,vertAlign:p.VerticalAlign.Top,wordWrapWidth:v(t.columnWidths[e],this._tableTextCache),offsetX:1,offsetY:1,boxPadding:8},new U.HitTestResult(U.HitTarget.MovePoint,i)))}e.push(l),i.push(n)}this._cellsTextRenderers=e,this._tableRenderer.setCellsHitTestData(i)}else{const{height:i,width:s}=e.mediaSize,l=this._getTextEditableRenderer();t.texts.forEach(((e,n)=>{e.forEach(((e,r)=>{const a=this._cellsTextRenderers[n][r];let h={...(0,o.ensureNotNull)(a.data()),text:e,selectionHighlight:void 0,fontSize:t.fontSize,color:this._textColorForCell([n,r]),horzTextAlign:t.horzAlign,horzAlign:t.horzAlign,wordWrapWidth:v(t.columnWidths[r],this._tableTextCache),boxPadding:8};l===a&&(h={...h,...this._inplaceTextHighlight(),text:this._text()},a.isOutOfScreen(s,i)?this.closeTextEditor():this._updateInplaceText(a.getTextInfo())),a.setData(h),a.setCursorType(this._textCursorType())}))}))}}_setTextRendererPositions(e,t){const i=this._source.properties().childs().horzAlign.value(),{horizontalPixelRatio:o,verticalPixelRatio:l}=t;this._cellsTextRenderers.forEach(((t,n)=>{t.forEach(((t,r)=>{const{left:a,right:h,top:c,bottom:d}=e.cells[n][r];t.setPoint((0,s.point)((a+("right"===i?h-a:"center"===i?(h-a)/2:0))/o,c/l));const u=t.data();null!==u&&t.setData({...u,boxWidth:(h-a)/o-1,boxHeight:Math.max((d-c)/l,t.measure().height)})}))}))}_rawPrecalculatedData(e,t){const i=this._cellsTextRenderers.map(((t,i)=>Math.max(...t.map((e=>e.measure().height)),e.rowHeights[i]))),o=e.columnWidths.map(((i,o)=>H(e.leftTop.x,e.columnWidths,o,t.horizontalPixelRatio))),l=i.map(((o,s)=>H(e.leftTop.y,i,s,t.verticalPixelRatio))),n=i.map(((t,i)=>e.columnWidths.map(((t,s)=>{const[n,r]=o[s],[a,h]=l[i];return{left:n,right:r,top:a,bottom:h,columnIndex:s,rowIndex:i,text:e.texts[i][s]}}))));return{topLeft:(0,s.point)(o[0][0],l[0][0]),bottomRight:(0,s.point)(o[o.length-1][1],l[l.length-1][1]),cells:n}}_getTextEditableCellIndexes(){return this._isTextEditMode()?this._getSelectableCellIndexes():[-1,-1]}_getSelectableCellIndexes(){return this._source.inplaceEditableCellIndexes()}_getTextEditableRenderer(){const[e,t]=this._getTextEditableCellIndexes();return-1===e&&-1===t?null:this._cellsTextRenderers[e]?.[t]}}var he=i(11542),ce=i(45126),de=i(91335),ue=i(18009),pe=i(32097),xe=i(91682),_e=i(64147),ge=i(23720)
|
|
;const me=new ce.TranslatedString("change {title} background color",he.t(null,void 0,i(49765))),Ce=new ce.TranslatedString("change {title} border color",he.t(null,void 0,i(69437))),fe=new ce.TranslatedString("change {title} texts alignment",he.t(null,void 0,i(71665))),Te=he.t(null,void 0,i(79468)),be=he.t(null,void 0,i(38408)),we=he.t(null,void 0,i(70320)),Pe=he.t(null,void 0,i(25485));class ye extends ue.LineDataSourceDefinitionsViewModel{_stylePropertyDefinitions(){const e=this._source.properties().childs(),t=this._source.name(),i=(0,xe.removeSpaces)(t),o=new ce.TranslatedString(t,this._source.translatedType());return{definitions:[(0,pe.createColorPropertyDefinition)({color:(0,pe.getColorDefinitionProperty)(this._propertyApplier,e.backgroundColor,null,me.format({title:o}))},{id:`${i}BackgroundColor`,title:Te}),(0,pe.createColorPropertyDefinition)({color:(0,pe.getColorDefinitionProperty)(this._propertyApplier,e.borderColor,null,Ce.format({title:o}))},{id:`${i}BorderColor`,title:be}),(0,de.createTextStyleDefinition)(this._propertyApplier,{textColor:e.textColor,fontSize:e.fontSize},o,{isEditable:!0,isMultiLine:!0,customTitles:{text:we}}),(0,pe.createOptionsPropertyDefinition)({option:(0,pe.convertToDefinitionProperty)(this._propertyApplier,e.horzAlign,fe.format({title:o}))},{id:`${i}TextAlignment`,title:Pe,options:new _e.WatchedValue(ge.availableAlignmentHorizontalItems)})]}}}var ve=i(29981),Se=i(44672),Re=i(64034);class Ie extends a.InplaceTextUndoCommand{constructor(e,t,i,o,s){super(e,t,i,o),this._cellIndexes=[-1,-1],this._cellIndexes=s}_textProperty(e){const[t,i]=this._cellIndexes;return(0,o.assert)(-1!==t,"rowIndex shouldn't be -1"),(0,o.assert)(-1!==i,"columnIndex shouldn't be -1"),e.properties().childs().cells.childs()[t].childs()[i]}}var He=i(60265),Ee=i(85719);const We=new ce.TranslatedString("add column to right",l.t(null,void 0,i(48499))),Ae=new ce.TranslatedString("add row below",l.t(null,void 0,i(48407))),Ve=new ce.TranslatedString("remove column",l.t(null,void 0,i(80240))),Me=new ce.TranslatedString("remove row",l.t(null,void 0,i(4553)));class ze extends He.UndoCommand{constructor(e,t,i,o){super(o,!0,!Ee.lineToolsDoNotAffectChartInvalidation),this._sourceId=t.id(),this._model=e,this._operationType=i;const{rowsCount:s,colsCount:l}=t.properties().state();this._rowsCountPropsState=s,this._colsCountPropsState=l,this._columnWidthsPropsState=t.properties().columnWidthValues(),this._rowHeightsPropsState=t.properties().rowHeightValues(),this._cellsPropsState=t.properties().cellsValues(),this._inplaceEditCellIndexes=t.inplaceEditableCellIndexes()}undo(){const e=this._source();e.properties().recreateCellsPropsByState({cells:this._cellsPropsState,colsCount:this._colsCountPropsState,rowsCount:this._rowsCountPropsState,columnWidths:this._columnWidthsPropsState,rowHeights:this._rowHeightsPropsState}),e.setInplaceEditableCellIndexes(this._inplaceEditCellIndexes,!0)}_source(){return(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceId))}}class De extends ze{constructor(e,t,i){super(e,t,i,1===i?We:Ae)}redo(){
|
|
this._source().insertCells(this._operationType,this._inplaceEditCellIndexes)}}class Le extends ze{constructor(e,t,i){super(e,t,i,1===i?Ve:Me)}redo(){this._source().removeCells(this._operationType,this._inplaceEditCellIndexes)}}function Be(e,t,i){let o=(0,ve.sum)(e);const s=(0,ve.sum)(t);let l=Math.max(i,s);if(o===l)return[...e];if(l<o)for(let i=0;i<e.length;i++)e[i]===t[i]&&(o-=e[i],l-=e[i]);const n=l/o,r=e.map(((e,i)=>Math.max(t[i],e*n)));return(0,ve.sum)(r)>l+.01?Be(r,t,i):r}const Ne=new ce.TranslatedString("change the column width",l.t(null,void 0,i(26391))),ke=new ce.TranslatedString("change the row height",l.t(null,void 0,i(21863))),Fe=new ce.TranslatedString("resize the cell",l.t(null,void 0,i(24849)));class Oe extends a.InplaceTextLineDataSource{constructor(e,t,i,o){const s=t??Oe.createProperties(e.backgroundTheme().spawnOwnership());super(e,s,i,o),this._hasEditableCoordinates=new _e.WatchedValue(!1),this._widthsSnapshot=null,this._inplaceEditCellIndexes=[-1,-1],this._tablePaneView=null,this._contextMenu=null,this._tableTextCache=new P(this._properties.childs().fontSize.value()),this._properties.childs().fontSize.subscribe(this,(e=>{this._tableTextCache.setFont(e.value()),this._properties.setColumnWidthValues(this._properties.columnWidthValues()),this.updateAllViews((0,Se.sourceChangeEvent)(this.id())),this._model.updateSource(this)})),this._properties.setTableTextCache(this._tableTextCache),this._tablePaneView=new ae(this,e,this._tableTextCache,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this)),this._setPaneViews([this._tablePaneView]),this.setInplaceEditableCellIndexes([-1,-1],!0),s.childs().anchored.subscribe(this,this._onAnchoredChange.bind(this))}destroy(){this._properties.childs().fontSize.unsubscribeAll(this),this._contextMenu?.then((e=>e.hide())),super.destroy()}pointsCount(){return 1}name(){return"Table"}isFixed(){return this._properties.childs().anchored.value()}anchorable(){return!0}properties(){return this._properties}template(){return this._properties.template()}snapTo45DegreesAvailable(){return!1}getPoint(e){const t=this._topLeftPoint();if(e===O.TopLeft)return t;const i=this.pointToScreenPoint(t);let o=null;if(i){const e=this.columnWidths(),t=this.rowHeights(),l=i.add((0,s.point)((0,ve.sum)(e),(0,ve.sum)(t)));o=this.screenPointToPoint(l)}if(!o)return null;switch(e){case O.TopRight:return{...t,index:o.index};case O.BottomRight:return{...o};case O.BottomLeft:return{...t,price:o.price}}return null}inplaceEditableCellIndexes(){return this._inplaceEditCellIndexes}setInplaceEditableCellIndexes(e,t=!1){const[i,o]=this._inplaceEditCellIndexes,[s,l]=e;if(!t&&i===s&&o===l)return;this._destroyEditableTextSubscriptions?.();const n=this.properties().childs().editableText,r={};if(-1!==s&&-1!==l){const e=this.properties().childs().cells.childs()[s].childs()[l];n.setValue(e.value()),n.subscribe(r,(()=>e.setValue(n.value()))),e.subscribe(r,(()=>n.setValue(e.value()))),this._destroyEditableTextSubscriptions=()=>{n.unsubscribeAll(r),e.unsubscribeAll(r)}}
|
|
this._inplaceEditCellIndexes=[s,l],this._editableText.setValue(n.value()),this.updateAllViews((0,Se.sourceChangeEvent)(this.id())),this._model.updateSource(this)}switchActiveCell(e=!1){let[t,i]=this._inplaceEditCellIndexes;if(-1===t&&-1===i)return!1;const{colsCount:o,rowsCount:s}=this.properties().state(),l=o*s,n=(t*o+i+(e?l-1:1))%l;return t=Math.floor(n/o)%s,i=n%o,this._saveEditedText(),this.setInplaceEditableCellIndexes([t,i],!0),!0}insertCells(e,t){const i=this.properties().state();let{rowsCount:o,colsCount:s}=i;const l=this.properties().cellsValues(),n=this.properties().columnWidthValues(),r=this.properties().rowHeightValues();let[a,h]=t??this._inplaceEditCellIndexes,c=!1;switch(-1===a&&-1===h&&(c=!0,a=o-1,h=s-1),e){case 0:const e=a+1,t=new Array(s).fill("");e>=o?l.push(t):l.splice(e,0,t),r.splice(e,0,0),o++;break;case 1:const i=h+1;for(const e of l)e.splice(i,0,"");n.splice(i,0,120),s++}this._properties.recreateCellsPropsByState({rowsCount:o,colsCount:s,columnWidths:n,rowHeights:r,cells:l}),this.setInplaceEditableCellIndexes(c?[-1,-1]:[a,h],!0)}isRemoveCellsAvailable(e){const t=this._properties.cellsValues();return(0!==e||1!==t.length)&&(1!==e||1!==t[0].length)}removeCells(e,t){const[i,o]=t??this._inplaceEditCellIndexes;if(-1===i&&-1===o)return;let{rowsCount:s,colsCount:l}=this.properties().state();const n=this.properties().cellsValues(),r=this.properties().columnWidthValues(),a=this.properties().rowHeightValues();switch(e){case 0:n.splice(i,1),a.splice(i,1),s--;break;case 1:for(const e of n)e.splice(o,1);r.splice(o,1),l--}this._properties.recreateCellsPropsByState({rowsCount:s,colsCount:l,columnWidths:r,rowHeights:a,cells:n});const h=Math.min(i,s-1),c=Math.min(o,l-1);this.setInplaceEditableCellIndexes([h,c],!0)}async additionalActions(e,t="Default"){let o=[];return"Default"===t&&(o=(await Promise.all([i.e(1629),i.e(620)]).then(i.bind(i,99758))).tableActions(this,e)),{actions:o,placement:"BeforeAll"}}editableTextProperties(){return{text:this.properties().childs().editableText,textColor:this.properties().childs().textColor}}cellText(e,t){return this.properties().childs().cells.childs()[e].childs()[t].value()}changePointUndoText(e){const{row:t,column:i}=oe(e);return null===t&&null===i?r.changePointUndoText:null===t?Ne:null===i?ke:Fe}startChanging(e,t){this.isFixed()&&this.restoreFixedPoint();const[i,s]=this.columnWidths(!0),[l,n]=this.rowHeights(!0),r=(0,ve.sum)(i),a=(0,ve.sum)(l),h=(0,ve.sum)(n);e??=O.TopLeft;const c=this._topLeftPoint(),d=(0,o.ensureNotNull)(this.priceScale()),u=(0,o.ensure)(this.ownerSource()?.firstValue()),p=d.priceToCoordinate(c.price,u),x=d.coordinateToPrice(p+a,u),_=this._model.timeScale().indexToCoordinate(c.index),g=this._model.timeScale().coordinateToFloatIndex(_+r);switch(e){case O.BottomLeft:t={index:c.index,price:x};break;case O.TopRight:t={index:g,price:c.price};break;case O.BottomRight:t={index:g,price:x};break;default:t={...c}}this._widthsSnapshot={columnWidths:i,columnMinWidths:s,rowHeights:l,rowMinHeights:n,minTotalHeight:h,totalWidth:r,totalHeight:a,startPoint:{...t},
|
|
topLeftPoint:c},super.startChanging(e,t)}setPoint(e,t,i,l){const n=this._model.timeScale(),r=(0,o.ensureNotNull)(this.priceScale()),a=(0,o.ensure)(this.ownerSource()?.firstValue()),h=this._model.mainSeries().interval(),c=(0,o.ensureNotNull)(this._widthsSnapshot),d=(0,o.ensureNotNull)(this.pointToScreenPoint(c.startPoint));let u=(0,o.ensureNotNull)(this.pointToScreenPoint(t));const{totalWidth:p,totalHeight:x,columnWidths:_,columnMinWidths:g,rowHeights:m,rowMinHeights:C}=c,f=this._topLeftPoint(),T=(0,o.ensureNotNull)(this.pointToScreenPoint(f)),b=e===O.TopLeft||e===O.BottomLeft,w=e===O.TopLeft||e===O.TopRight,P=d.add((0,s.point)(b?p:-p,w?x:-x)),y=I(this._tableTextCache);let{x:H,y:E}=u;if(!l){const e=y*c.columnWidths.length,t=c.minTotalHeight;H=b?Math.min(u.x,P.x-e):Math.max(u.x,P.x+e),E=w?Math.min(u.y,P.y-t):Math.max(u.y,P.y+t),u=(0,s.point)(H,E)}const W=this.isFixed(),A=b&&!W?Math.floor(n.coordinateToFloatIndex(H)):n.coordinateToFloatIndex(H);H=n.indexToCoordinate(A);const V=r.coordinateToPrice(E,a),M=d.x-H,z=d.y-E;switch(e){case O.TopLeft:W?this.addFixedPoint(u):this._setPoint(0,{...t,price:V,index:A,interval:h}),l||(this._properties.setColumnWidthValues(this._correctColumnWidths(Be(_,g,p+M),c)),this._properties.setRowHeightValues(Be(m,C,x+z)));break;case O.BottomLeft:W?this.addFixedPoint((0,s.point)(u.x,T.y)):this._setPoint(0,{...t,index:A,price:f.price,interval:h}),l||(this._properties.setColumnWidthValues(this._correctColumnWidths(Be(_,g,p+M),c)),this._properties.setRowHeightValues(Be(m,C,x-z)));break;case O.TopRight:W?this.addFixedPoint((0,s.point)(T.x,u.y)):this._setPoint(0,{...t,price:V,index:f.index,interval:h}),l||(this._properties.setColumnWidthValues(Be(_,g,p-M)),this._properties.setRowHeightValues(Be(m,C,x+z)));break;case O.BottomRight:l||(this._properties.setColumnWidthValues(Be(_,g,p-M)),this._properties.setRowHeightValues(Be(m,C,x-z)))}if(e>=O.ResizeVirtualAnchorBase){const{column:t,row:i}=oe(e);if(null!==t){const e=(0,ve.sum)(_.slice(0,t))+T.x,i=Math.max(y,u.x-e),o=_.map(((e,o)=>o===t?i:e));this._properties.setColumnWidthValues(o)}if(null!==i){const e=(0,ve.sum)(m.slice(0,i))+T.y;let t=R(this._tableTextCache);for(let e=0;e<_.length;e++)t=Math.max(t,S(this.cellText(i,e),v(_[e],this._tableTextCache),this._tableTextCache));const o=Math.max(t,u.y-e),s=m.map(((e,t)=>t===i?o:e));this._properties.setRowHeightValues(s)}}else;}columnWidths(e){const t=this._properties.columnWidthValues();if(!e)return t;const i=I(this._tableTextCache),o=t.map((e=>i));return[t,o]}rowHeights(e){const t=this.properties().rowHeightValues(),i=this.columnWidths(),o=[],s=t.map(((t,s)=>{let l=R(this._tableTextCache),n=Math.max(t,l);for(let e=0;e<this.properties().childs().colsCount.value();e++){const t=S(this.cellText(s,e),v(i[e],this._tableTextCache),this._tableTextCache);n=Math.max(n,t),l=Math.max(l,t)}return e&&o.push(l),n}));return e?[s,o]:s}endChanging(e,t,i){return this._widthsSnapshot=null,super.endChanging(e,t,i)}async onContextMenu(e){
|
|
null===this._contextMenu&&(this._contextMenu=Promise.all([i.e(1629),i.e(620)]).then(i.bind(i,91218)).then((t=>t.showTableContextMenu(this,(()=>{this._contextMenu=null}),e))))}insertCellsUndoCommand(e){return new De(this.model(),this,e)}removeCellsUndoCommand(e){return this.isRemoveCellsAvailable(e)?new Le(this.model(),this,e):null}static createProperties(e,t){const i=F.create(e,t);return this._configureProperties(i),i}_changeEditableTextUndoCommand(e,t){return new Ie(this._model,this,e,t,(0,o.ensureNotNull)(this._inplaceEditCellIndexes))}async _getPropertyDefinitionsViewModelClass(){return ye}_createDataSourceBackgroundColorWV(){return(0,n.convertPropertyToWatchedValue)(this.properties().childs().backgroundColor).ownership()}static _addCollectedProperties(e){}_topLeftPoint(){return this.isFixed()?(0,o.ensureNotNull)(this.screenPointToPoint((0,o.ensureDefined)(this._fixedPoint),!0)):this._points[0]}_correctColumnWidths(e,t){const i=(this._tablePaneView?.lastRenderingInfo()??Re.dpr1PixelRatioInfo).horizontalPixelRatio,s=(0,o.ensureNotNull)(this.pointToScreenPoint(t.topLeftPoint)).x,[,l]=H(s,t.columnWidths,t.columnMinWidths.length-1,i),n=(0,o.ensureNotNull)(this.pointToScreenPoint(this._topLeftPoint())).x,r=(0,ve.sum)(e),a=l/i-n;return e[e.length-1]+=a-r,e}}},62689:(e,t,i)=>{i.d(t,{LineToolTextRenderer:()=>s});var o=i(17330);class s extends o.TextRenderer{getTextInfo(){const e=this._getInternalData(),t=this.fontStyle(),i=this._getFontInfo();return{...e,lineHeight:this.lineHeight(),lineSpacing:this.lineSpacing(),font:t,fontSize:i.fontSize,centerRotation:this.centerTextRotation()??void 0}}setCursorType(e){this._hitTest.data()?.cursorType!==e&&this._hitTest.mergeData({cursorType:e})}}}}]); |