UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 3 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{__decorate as t}from"tslib";import{property as o,subclass as e}from"../../../../core/accessorSupport/decorators.js";import i from"../../../Widget.js";import{WellKnownSizes as n,Icons as r}from"./responsiveToolbarUtils.js";import{ToolbarGroupBase as s}from"./ToolbarGroupBase.js";import{loadCalciteComponents as a}from"../../../support/componentsUtils.js";import{tsx as l,tsxFragment as c,messageBundle as p}from"../../../support/widget.js";const d={splitButtonBase:`${"esri-split-button"}--split-part`};let m=class extends(s(i)){constructor(t){super(t),this.allowCollapse=!0,this.messagesCommon=null}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu")})}static{this.vnodeSelector="calcite-action-group"}get minimumLength(){const t=this.actionChildren;if(!t.length)return 0;const{scale:o}=this;return 1===t.length?n.action[o]+n.groupSeparator+n.groupPadding[o]:this.allowCollapse?n.action[o]+2*n.actionPadding[o]+n.groupPadding[o]+n.splitButtonPart[this.layout][o]+n.groupSeparator:(n.action[o]+n.actionPadding[o])*t.length+n.groupSeparator+n.groupPadding[o]}get lengthOptions(){const{actionChildren:t,minimumLength:o,scale:e,priority:i,allowCollapse:r}=this;if(t.length<2||i<0||!r)return[o];return[o,n.groupSeparator+n.groupPadding[e]+(n.action[e]+n.actionPadding[e])*t.length]}render(){if(!this.actionChildren.length)return l(c,null,void 0);const{actionChildren:t,minimumLength:o,budgetedLength:e,layout:i,slot:n,allowCollapse:r}=this,s=!r||t.length<2||e>o;return l("calcite-action-group",{key:"split-button-group",layout:i,onclick:t=>this._handleClick(t.target),slot:n},s?this._renderUnSplit():this._renderSplit())}_renderSplit(){const{activeChildElement:t,layout:o,actionChildren:e,scale:i,messagesCommon:n}=this,s=t??e.at(0);if(!s)return;const a=e.filter(t=>t!==s);return[this._renderManagedAction(s),l("calcite-action-menu",{key:"split-button-dropdown",label:n.more,overlayPositioning:"fixed",placement:"horizontal"===o?"bottom-end":"right-end"},l("calcite-action",{class:`${d.splitButtonBase}--${o}--${this.scale}`,compact:"horizontal"===o,icon:r.splitButton[o],key:"split-button-dropdown-trigger",scale:i,slot:"trigger",text:n.more}),a?.map(t=>this._renderManagedAction(t)))]}_renderUnSplit(){return this.actionChildren.map(t=>this._renderManagedAction(t))}_renderManagedAction(t){return l("calcite-action",{...t?.properties,"data-action-key":t?.properties?.key,text:t?.properties?.text??""})}};t([o()],m.prototype,"minimumLength",null),t([o()],m.prototype,"allowCollapse",void 0),t([o()],m.prototype,"lengthOptions",null),t([o(),p("esri/t9n/common")],m.prototype,"messagesCommon",void 0),m=t([e("esri.widgets.Sketch.support.ResponsiveToolbar.SplitButton")],m);export{m as SplitButton};