UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.99 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as o}from"../../../../chunks/tslib.es6.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";import r from"../../../Widget.js";import{WellKnownSizes as s,Icons as i}from"./responsiveToolbarUtils.js";import{ToolbarGroupBase as n}from"./ToolbarGroupBase.js";import{loadCalciteComponents as c}from"../../../support/componentsUtils.js";import"../../../support/widgetUtils.js";import{messageBundle as l}from"../../../support/decorators/messageBundle.js";import{tsx as a,tsxFragment as p}from"../../../support/jsxFactory.js";let m=class extends(n(r)){constructor(o){super(o),this.allowCollapse=!0,this.messagesCommon=null}loadDependencies(){return c({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{actionChildren:o,scale:t}=this;return o.length?this.allowCollapse?s.groupSeparator+s.action[t]*Math.min(o.length,2):s.groupSeparator+s.action[t]*o.length:0}get lengthOptions(){const{actionChildren:o,scale:t,minimumLength:e,allowCollapse:r,priority:i}=this,n=[e];if(o.length<=2||!r||i<1)return n;for(let c=1;c<o.length-1;c++)n.push(e+s.action[t]*c);return n}render(){if(!this.actionChildren.length)return a(p,null,void 0);const{budgetedLength:o,actionChildren:t,activeChildElement:e,layout:r,slot:n,scale:c}=this,l=Math.floor(o/s.action[c]),m=[],u=[];if(l>=t.length)m.push(...t);else{const o=e??m.at(0);if(m.push(...t.slice(0,l-1)),u.push(...t.slice(l-1)),o&&u.includes(o)){const[t]=u.splice(u.indexOf(o),1),e=m.pop();m.push(t),e&&u.unshift(e)}}return a("calcite-action-group",{key:"overflow-button-group",layout:r,onclick:o=>this._handleClick(o.target),slot:n},m.map((o=>this._renderManagedAction(o))),u.length>0?a("calcite-action-menu",{key:"split-button-dropdown",label:this.messagesCommon.more,overlayPositioning:"fixed"},a("calcite-action",{icon:i.overflow,key:"split-button-dropdown-trigger",scale:c,slot:"trigger",text:this.messagesCommon.more}),u.map((o=>this._renderManagedAction(o)))):void 0)}_renderManagedAction(o){return a("calcite-action",{...o?.properties,"data-action-key":o?.properties?.key,text:o?.properties?.text??""})}};o([t()],m.prototype,"allowCollapse",void 0),o([t()],m.prototype,"minimumLength",null),o([t(),l("esri/t9n/common")],m.prototype,"messagesCommon",void 0),o([t()],m.prototype,"lengthOptions",null),m=o([e("esri.widgets.Sketch.support.ResponsiveToolbar.OverflowGroup")],m);export{m as default};