@esri/solutions-components 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/buffer-tools_6.cjs.entry.js +4 -8
- package/dist/cjs/calcite-combobox_3.cjs.entry.js +61 -61
- package/dist/cjs/calcite-input-message_5.cjs.entry.js +297 -295
- package/dist/cjs/{downloadUtils-415ab342.js → downloadUtils-b85476e8.js} +1093 -1093
- package/dist/cjs/{index.es-98008aa0.js → index.es-3ba50626.js} +10682 -10682
- package/dist/cjs/layer-table.cjs.entry.js +22 -22
- package/dist/cjs/loader.cjs.js +30 -30
- package/dist/cjs/{mapViewUtils-f617ae9a.js → mapViewUtils-df63bfa4.js} +26 -26
- package/dist/cjs/public-notification.cjs.entry.js +109 -4
- package/dist/cjs/solutions-components.cjs.js +31 -31
- package/dist/collection/components/map-draw-tools/map-draw-tools.js +3 -7
- package/dist/collection/components/map-select-tools/map-select-tools.js +74 -14
- package/dist/collection/components/public-notification/public-notification.js +177 -3
- package/dist/collection/utils/queryUtils.js +2 -2
- package/dist/collection/utils/queryUtils.ts +2 -2
- package/dist/components/map-draw-tools2.js +3 -7
- package/dist/components/map-select-tools2.js +55 -50
- package/dist/components/public-notification.js +111 -3
- package/dist/components/queryUtils.js +12 -12
- package/dist/esm/buffer-tools_6.entry.js +4 -8
- package/dist/esm/calcite-combobox_3.entry.js +55 -55
- package/dist/esm/calcite-input-message_5.entry.js +289 -287
- package/dist/esm/{downloadUtils-606b0f0e.js → downloadUtils-f278742f.js} +1089 -1089
- package/dist/esm/{index.es-c736c805.js → index.es-6f3a1143.js} +10596 -10596
- package/dist/esm/layer-table.entry.js +18 -18
- package/dist/esm/loader.js +26 -26
- package/dist/esm/{mapViewUtils-4e945e07.js → mapViewUtils-bd1809f0.js} +14 -14
- package/dist/esm/public-notification.entry.js +109 -4
- package/dist/esm/solutions-components.js +26 -26
- package/dist/solutions-components/{p-72117a18.js → p-03e2c6fd.js} +60 -60
- package/dist/solutions-components/{p-5ee7b022.entry.js → p-045d3988.entry.js} +11 -11
- package/dist/solutions-components/{p-6a657ff6.js → p-40c12650.js} +436 -436
- package/dist/solutions-components/p-70e1d4d8.entry.js +17 -0
- package/dist/solutions-components/p-88e5a76d.js +36 -0
- package/dist/solutions-components/p-bc39f296.entry.js +6 -0
- package/dist/solutions-components/{p-84bbaebf.entry.js → p-c93d8e80.entry.js} +6 -6
- package/dist/solutions-components/{p-4f5641b4.entry.js → p-cbac29fb.entry.js} +2 -2
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/queryUtils.ts +2 -2
- package/dist/types/components/map-select-tools/map-select-tools.d.ts +16 -1
- package/dist/types/components/public-notification/public-notification.d.ts +70 -0
- package/dist/types/components.d.ts +1601 -1553
- package/package.json +1 -1
- package/dist/solutions-components/p-88e28de2.js +0 -36
- package/dist/solutions-components/p-ac76d270.entry.js +0 -17
- package/dist/solutions-components/p-e162304e.entry.js +0 -6
@@ -1,12 +1,12 @@
|
|
1
|
-
/*!
|
2
|
-
* Copyright 2022 Esri
|
3
|
-
* Licensed under the Apache License, Version 2.0
|
4
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
-
*/
|
6
|
-
import{r as i,c as t,h as e,H as s,g as a}from"./p-c2f00d41.js";import{f as n}from"./p-d48a24e6.js";import{d as o,f as c,c as l,u as r,r as h,a as d,F as m}from"./p-a9cefd9c.js";import{g as p}from"./p-a80b3880.js";import{T as u,C as b,b as g,c as f,h as v,d as x,e as y,g as w,a as k}from"./p-a5b1ab03.js";import{c as C,d as z,g as I}from"./p-bd67334c.js";import{s as $,c as H,a as _,d as D,H as j}from"./p-a33d73bb.js";import{c as L}from"./p-9a9955db.js";import{u as A}from"./p-7daea1df.js";import{i as E,t as S,g as P,a as F}from"./p-83166522.js";import{c as T,d as B}from"./p-2e9ed892.js";import{d as M}from"./p-4e32bf8c.js";import{c as O,d as R}from"./p-1c247f54.js";import{i as W,j as U}from"./p-88e28de2.js";import{s as V}from"./p-4557d5a8.js";import"./p-729708a3.js";import"./p-dbc9a5a8.js";import"./p-00444009.js";const X="combobox-item-",Y="combobox-chip-",G="combobox-label-",K="combobox-listbox-",N="combobox-input-",q=class{constructor(e){i(this,e),this.calciteLookupChange=t(this,"calciteLookupChange",6),this.calciteComboboxChange=t(this,"calciteComboboxChange",6),this.calciteComboboxFilterChange=t(this,"calciteComboboxFilterChange",6),this.calciteComboboxChipDismiss=t(this,"calciteComboboxChipDismiss",6),this.calciteComboboxBeforeClose=t(this,"calciteComboboxBeforeClose",6),this.calciteComboboxClose=t(this,"calciteComboboxClose",6),this.calciteComboboxBeforeOpen=t(this,"calciteComboboxBeforeOpen",6),this.calciteComboboxOpen=t(this,"calciteComboboxOpen",6),this.active=!1,this.open=!1,this.disabled=!1,this.maxItems=0,this.overlayPositioning="absolute",this.required=!1,this.selectionMode="multi",this.scale="m",this.value=null,this.intlRemoveTag=u.removeTag,this.placement=o,this.internalValueChangeFlag=!1,this.items=[],this.groupItems=[],this.selectedItems=[],this.visibleItems=[],this.activeItemIndex=-1,this.activeChipIndex=-1,this.activeDescendant="",this.text="",this.textInput=null,this.mutationObserver=L("mutation",(()=>this.updateItems())),this.resizeObserver=L("resize",(()=>this.setMaxScrollerHeight())),this.guid=p(),this.inputHeight=0,this.ignoreSelectedEventsFlag=!1,this.openTransitionProp="opacity",this.setFilteredPlacements=()=>{const{el:i,flipPlacements:t}=this;this.filteredFlipPlacements=t?c(t,i):null},this.getValue=()=>{const i=this.selectedItems.map((i=>{var t;return null===(t=null==i?void 0:i.value)||void 0===t?void 0:t.toString()}));return(null==i?void 0:i.length)?i.length>1?i:i[0]:""},this.onLabelClick=()=>{this.setFocus()},this.keydownHandler=i=>{const{key:t}=i;switch(t){case"Tab":this.activeChipIndex=-1,this.activeItemIndex=-1,this.allowCustomValues&&this.text?(this.addCustomChip(this.text,!0),i.preventDefault()):this.open&&(this.open=!1,i.preventDefault());break;case"ArrowLeft":this.previousChip(),i.preventDefault();break;case"ArrowRight":this.nextChip(),i.preventDefault();break;case"ArrowUp":i.preventDefault(),this.shiftActiveItemIndex(-1),this.comboboxInViewport()||this.el.scrollIntoView();break;case"ArrowDown":i.preventDefault(),this.open||(this.open=!0),this.shiftActiveItemIndex(1),this.comboboxInViewport()||this.el.scrollIntoView();break;case" ":this.textInput.value||(i.preventDefault(),this.open=!0,this.shiftActiveItemIndex(1));break;case"Home":if(!this.open)return;i.preventDefault(),this.updateActiveItemIndex(0),this.scrollToActiveItem(),this.comboboxInViewport()||this.el.scrollIntoView();break;case"End":if(!this.open)return;i.preventDefault(),this.updateActiveItemIndex(this.visibleItems.length-1),this.scrollToActiveItem(),this.comboboxInViewport()||this.el.scrollIntoView();break;case"Escape":this.open=!1,i.preventDefault();break;case"Enter":this.activeItemIndex>-1?(this.toggleSelection(this.visibleItems[this.activeItemIndex]),i.preventDefault()):this.activeChipIndex>-1?(this.removeActiveChip(),i.preventDefault()):this.allowCustomValues&&this.text?(this.addCustomChip(this.text,!0),i.preventDefault()):i.defaultPrevented||$(this)&&i.preventDefault();break;case"Delete":case"Backspace":this.activeChipIndex>-1?(i.preventDefault(),this.removeActiveChip()):!this.text&&this.isMulti()&&(i.preventDefault(),this.removeLastChip())}},this.toggleCloseEnd=()=>{this.open=!1,this.el.removeEventListener("calciteComboboxClose",this.toggleCloseEnd)},this.toggleOpenEnd=()=>{this.open=!1,this.el.removeEventListener("calciteComboboxOpen",this.toggleOpenEnd)},this.setMaxScrollerHeight=async()=>{const{listContainerEl:i,open:t,referenceEl:e}=this;if(!i||!t)return;await this.reposition(!0);const s=this.getMaxScrollerHeight();i.style.maxHeight=s>0?`${s}px`:"",i.style.minWidth=`${e.clientWidth}px`,await this.reposition(!0)},this.calciteChipDismissHandler=(i,t)=>{this.open=!1;const e=this.items.find((i=>i===t));e&&this.toggleSelection(e,!1),this.calciteComboboxChipDismiss.emit(i.detail)},this.clickHandler=i=>{i.composedPath().some((i=>"CALCITE-CHIP"===i.tagName))||(this.open=!this.open,this.updateActiveItemIndex(0),this.setFocus())},this.setInactiveIfNotContained=i=>{const t=i.composedPath();!this.open||t.includes(this.el)||t.includes(this.referenceEl)||(this.allowCustomValues&&this.text.trim().length&&this.addCustomChip(this.text),"single"===this.selectionMode&&(this.textInput&&(this.textInput.value=""),this.text="",this.filterItems(""),this.updateActiveItemIndex(-1)),this.open=!1)},this.setFloatingEl=i=>{this.floatingEl=i,l(this,this.referenceEl,this.floatingEl)},this.setContainerEl=i=>{this.resizeObserver.observe(i),this.listContainerEl=i,this.transitionEl=i,T(this)},this.setReferenceEl=i=>{this.referenceEl=i,l(this,this.referenceEl,this.floatingEl)},this.inputHandler=i=>{const t=i.target.value;this.text=t,this.filterItems(t),t&&(this.activeChipIndex=-1)},this.filterItems=(()=>{const i=(i,t)=>i&&t.some((({label:t,value:e})=>i.tagName===y?e===i.label:e===i.textLabel||e===i.value||t===i.textLabel||t===i.value));return M((t=>{const e=n(this.data,t);this.getCombinedItems().forEach((t=>{const s=!i(t,e);t.hidden=s;const[a,n]=t.ancestors;(i(a,e)||i(n,e))&&(t.hidden=!1),s||t.ancestors.forEach((i=>i.hidden=!1))})),this.visibleItems=this.getVisibleItems(),this.calciteComboboxFilterChange.emit({visibleItems:[...this.visibleItems],text:t})}),100)})(),this.internalCalciteLookupChangeEvent=()=>{this.calciteLookupChange.emit(this.selectedItems)},this.emitCalciteLookupChange=M(this.internalCalciteLookupChangeEvent,0),this.internalComboboxChangeEvent=()=>{const{selectedItems:i}=this;this.calciteComboboxChange.emit({selectedItems:i})},this.emitComboboxChange=M(this.internalComboboxChangeEvent,0),this.updateItems=()=>{this.items=this.getItems(),this.groupItems=this.getGroupItems(),this.data=this.getData(),this.selectedItems=this.getSelectedItems(),this.visibleItems=this.getVisibleItems(),this.needsIcon=this.getNeedsIcon(),this.allowCustomValues||this.setMaxScrollerHeight()},this.scrollToActiveItem=()=>{const i=this.visibleItems[this.activeItemIndex],t=this.calculateSingleItemHeight(i),{offsetHeight:e,scrollTop:s}=this.listContainerEl;e+s<i.offsetTop+t?this.listContainerEl.scrollTop=i.offsetTop-e+t:i.offsetTop<s&&(this.listContainerEl.scrollTop=i.offsetTop)},this.comboboxFocusHandler=()=>{var i;null===(i=this.textInput)||void 0===i||i.focus()},this.comboboxBlurHandler=i=>{this.setInactiveIfNotContained(i)}}activeHandler(i){if(this.disabled)return this.active=!1,void(this.open=!1);this.open=i}openHandler(i){if(i||r(this.floatingEl),this.disabled)return this.active=!1,void(this.open=!1);this.active=i,this.setMaxScrollerHeight()}handleDisabledChange(i){i||(this.active=!1,this.open=!1)}maxItemsHandler(){this.setMaxScrollerHeight()}overlayPositioningHandler(){this.reposition(!0)}valueHandler(i){if(!this.internalValueChangeFlag){const t=this.getItems();Array.isArray(i)?t.forEach((t=>t.selected=i.includes(t.value))):t.forEach(i?t=>t.selected=i===t.value:i=>i.selected=!1),this.updateItems()}}flipPlacementsHandler(){this.setFilteredPlacements(),this.reposition(!0)}documentClickHandler(i){E(i)&&this.setInactiveIfNotContained(i)}calciteComboboxItemChangeHandler(i){if(this.ignoreSelectedEventsFlag)return;const t=i.target,e=this.visibleItems.indexOf(t);this.updateActiveItemIndex(e),this.toggleSelection(t,t.selected)}async reposition(i=!1){const{floatingEl:t,referenceEl:e,placement:s,overlayPositioning:a,filteredFlipPlacements:n}=this;return h(this,{floatingEl:t,referenceEl:e,overlayPositioning:a,placement:s,flipPlacements:n,type:"menu"},i)}async setFocus(){var i;null===(i=this.textInput)||void 0===i||i.focus(),this.activeChipIndex=-1,this.activeItemIndex=-1}connectedCallback(){var i;this.internalValueChangeFlag=!0,this.value=this.getValue(),this.internalValueChangeFlag=!1,null===(i=this.mutationObserver)||void 0===i||i.observe(this.el,{childList:!0,subtree:!0}),C(this),H(this),T(this),this.setFilteredPlacements(),this.reposition(!0),this.active&&this.activeHandler(this.active),this.open&&this.openHandler(this.open)}componentWillLoad(){this.updateItems()}componentDidLoad(){_(this,this.getValue()),this.reposition(!0)}componentDidRender(){this.el.offsetHeight!==this.inputHeight&&(this.reposition(!0),this.inputHeight=this.el.offsetHeight),A(this)}disconnectedCallback(){var i,t;null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),z(this),D(this),d(this,this.referenceEl,this.floatingEl),B(this)}selectedItemsHandler(){this.internalValueChangeFlag=!0,this.value=this.getValue(),this.internalValueChangeFlag=!1}textHandler(){this.updateActiveItemIndex(-1)}comboboxInViewport(){const i=this.el.getBoundingClientRect();return i.top>=0&&i.left>=0&&i.right<=(window.innerWidth||document.documentElement.clientWidth)&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)}onBeforeOpen(){this.calciteComboboxBeforeOpen.emit()}onOpen(){this.calciteComboboxOpen.emit()}onBeforeClose(){this.calciteComboboxBeforeClose.emit()}onClose(){this.calciteComboboxClose.emit()}getMaxScrollerHeight(){const i=this.getCombinedItems().filter((i=>!i.hidden)),{maxItems:t}=this;let e=0,s=0;return i.length>t&&i.forEach((i=>{if(e<t&&t>0){const t=this.calculateSingleItemHeight(i);t>0&&(s+=t,e++)}})),s}calculateSingleItemHeight(i){let t=i.offsetHeight;return Array.from(i.querySelectorAll(b)).map((i=>null==i?void 0:i.offsetHeight)).forEach((i=>{t-=i})),t}getCombinedItems(){return[...this.groupItems,...this.items]}toggleSelection(i,t=!i.selected){i&&(this.isMulti()?(i.selected=t,this.updateAncestors(i),this.selectedItems=this.getSelectedItems(),this.emitCalciteLookupChange(),this.emitComboboxChange(),this.resetText(),this.filterItems("")):(this.ignoreSelectedEventsFlag=!0,this.items.forEach((e=>e.selected=e===i&&t)),this.ignoreSelectedEventsFlag=!1,this.selectedItems=this.getSelectedItems(),this.emitComboboxChange(),this.textInput&&(this.textInput.value=i.textLabel),this.open=!1,this.updateActiveItemIndex(-1),this.resetText(),this.filterItems("")))}updateAncestors(i){if("ancestors"!==this.selectionMode)return;const t=g(i),e=f(i);i.selected?t.forEach((i=>{i.selected=!0})):(e.forEach((i=>i.selected=!1)),[...t].forEach((i=>{v(i)||(i.selected=!1)})))}getVisibleItems(){return this.items.filter((i=>!i.hidden))}getSelectedItems(){if(!this.isMulti()){const i=this.items.find((({selected:i})=>i));return i?[i]:[]}return this.items.filter((i=>i.selected&&("ancestors"!==this.selectionMode||!v(i)))).sort(((i,t)=>{const e=this.selectedItems.indexOf(i),s=this.selectedItems.indexOf(t);return e>-1&&s>-1?e-s:s-e}))}getData(){return this.items.map((i=>({constant:i.constant,filterDisabled:i.filterDisabled,value:i.value,label:i.textLabel})))}getNeedsIcon(){return"single"===this.selectionMode&&this.items.some((i=>i.icon))}resetText(){this.textInput&&(this.textInput.value=""),this.text=""}getItems(){return Array.from(this.el.querySelectorAll(x)).filter((i=>!i.disabled))}getGroupItems(){return Array.from(this.el.querySelectorAll(y))}addCustomChip(i,t){const e=this.items.find((t=>t.textLabel===i));if(e)this.toggleSelection(e,!0);else{this.isMulti()||this.toggleSelection(this.selectedItems[this.selectedItems.length-1],!1);const e=document.createElement(x);e.value=i,e.textLabel=i,e.selected=!0,this.el.appendChild(e),this.resetText(),t&&this.setFocus(),this.updateItems(),this.filterItems(""),this.emitCalciteLookupChange(),this.emitComboboxChange()}}removeActiveChip(){this.toggleSelection(this.selectedItems[this.activeChipIndex],!1),this.setFocus()}removeLastChip(){this.toggleSelection(this.selectedItems[this.selectedItems.length-1],!1),this.setFocus()}previousChip(){if(this.text)return;const i=this.activeChipIndex;this.activeChipIndex=-1===i?this.selectedItems.length-1:Math.max(i-1,0),this.updateActiveItemIndex(-1),this.focusChip()}nextChip(){if(this.text||-1===this.activeChipIndex)return;const i=this.activeChipIndex+1;i>this.selectedItems.length-1?(this.activeChipIndex=-1,this.setFocus()):(this.activeChipIndex=i,this.focusChip()),this.updateActiveItemIndex(-1)}focusChip(){var i;const t=null===(i=this.selectedItems[this.activeChipIndex])||void 0===i?void 0:i.guid,e=t?this.referenceEl.querySelector(`#${Y}${t}`):null;null==e||e.setFocus()}shiftActiveItemIndex(i){const{length:t}=this.visibleItems;this.updateActiveItemIndex((this.activeItemIndex+t+i)%t),this.scrollToActiveItem()}updateActiveItemIndex(i){var t;this.activeItemIndex=i;let e=null;this.visibleItems.forEach(((t,s)=>{s===i?(t.active=!0,e=`${X}${t.guid}`):t.active=!1})),this.activeDescendant=e,this.activeItemIndex>-1&&(this.activeChipIndex=-1,null===(t=this.textInput)||void 0===t||t.focus())}isMulti(){return"single"!==this.selectionMode}renderChips(){const{activeChipIndex:i,scale:t,selectionMode:s,intlRemoveTag:a}=this;return this.selectedItems.map(((n,o)=>{const c={chip:!0,"chip--active":i===o},l=[...[...g(n)].reverse(),n].map((i=>i.textLabel)),r="ancestors"!==s?n.textLabel:l.join(" / ");return e("calcite-chip",{class:c,dismissLabel:a,dismissible:!0,icon:n.icon,id:n.guid?`${Y}${n.guid}`:null,key:n.textLabel,onCalciteChipDismiss:i=>this.calciteChipDismissHandler(i,n),scale:t,title:r,value:n.value},r)}))}renderInput(){const{guid:i,active:t,disabled:s,placeholder:a,selectionMode:n,selectedItems:o,open:c}=this,l="single"===n,r=o[0],h=!(c||t)&&l&&!!r;return e("span",{class:{"input-wrap":!0,"input-wrap--single":l}},h&&e("span",{class:{label:!0,"label--icon":!!(null==r?void 0:r.icon)},key:"label"},r.textLabel),e("input",{"aria-activedescendant":this.activeDescendant,"aria-autocomplete":"list","aria-controls":`${K}${i}`,"aria-label":I(this),class:{input:!0,"input--single":!0,"input--transparent":this.activeChipIndex>-1,"input--hidden":h,"input--icon":!!this.placeholderIcon},disabled:s,id:`${N}${i}`,key:"input",onBlur:this.comboboxBlurHandler,onFocus:this.comboboxFocusHandler,onInput:this.inputHandler,placeholder:a,ref:i=>this.textInput=i,type:"text"}))}renderListBoxOptions(){return this.visibleItems.map((i=>e("li",{"aria-selected":S(i.selected),id:i.guid?`${X}${i.guid}`:null,role:"option",tabindex:"-1"},i.textLabel)))}renderFloatingUIContainer(){const{active:i,setFloatingEl:t,setContainerEl:s,open:a}=this;return e("div",{"aria-hidden":"true",class:{"floating-ui-container":!0,"floating-ui-container--active":a||i},ref:t},e("div",{class:{"list-container":!0,[m.animation]:!0,[m.animationActive]:a||i},ref:s},e("ul",{class:{list:!0,"list--hide":!(a||i)}},e("slot",null))))}renderIconStart(){const{selectedItems:i,placeholderIcon:t,selectionMode:s}=this,a=i[0],n=null==a?void 0:a.icon,o="single"===s;return(!this.open&&a?!!n&&o:!!this.placeholderIcon&&(!a||o))&&e("span",{class:"icon-start"},e("calcite-icon",{class:"selected-icon",icon:!this.open&&a?n:t,scale:"s"}))}renderIconEnd(){const{active:i,open:t}=this;return e("span",{class:"icon-end"},e("calcite-icon",{icon:i||t?"chevron-up":"chevron-down",scale:"s"}))}render(){const{active:i,guid:t,label:a,open:n}=this,o="single"===this.selectionMode;return e(s,null,e("div",{"aria-autocomplete":"list","aria-controls":`${K}${t}`,"aria-expanded":S(n||i),"aria-haspopup":"listbox","aria-labelledby":`${G}${t}`,"aria-live":"polite","aria-owns":`${K}${t}`,class:{wrapper:!0,"wrapper--single":o||!this.selectedItems.length,"wrapper--active":n||i},onClick:this.clickHandler,onKeyDown:this.keydownHandler,ref:this.setReferenceEl,role:"combobox"},e("div",{class:"grid-input"},this.renderIconStart(),!o&&this.renderChips(),e("label",{class:"screen-readers-only",htmlFor:`${N}${t}`,id:`${G}${t}`},a),this.renderInput()),this.renderIconEnd()),e("ul",{"aria-labelledby":`${G}${t}`,"aria-multiselectable":"true",class:"screen-readers-only",id:`${K}${t}`,role:"listbox",tabIndex:-1},this.renderListBoxOptions()),this.renderFloatingUIContainer(),e(j,{component:this}))}get el(){return a(this)}static get watchers(){return{active:["activeHandler"],open:["openHandler"],disabled:["handleDisabledChange"],maxItems:["maxItemsHandler"],overlayPositioning:["overlayPositioningHandler"],value:["valueHandler"],flipPlacements:["flipPlacementsHandler"],selectedItems:["selectedItemsHandler"],text:["textHandler"]}}};q.style="@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{position:relative;display:block}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]){font-size:var(--calcite-font-size--2);--calcite-combobox-item-spacing-unit-l:0.5rem;--calcite-combobox-item-spacing-unit-s:0.25rem;--calcite-combobox-input-height:1.5rem}:host([scale=m]){font-size:var(--calcite-font-size--1);--calcite-combobox-item-spacing-unit-l:0.75rem;--calcite-combobox-item-spacing-unit-s:0.5rem;--calcite-combobox-input-height:2rem}:host([scale=l]){font-size:var(--calcite-font-size-0);--calcite-combobox-item-spacing-unit-l:1rem;--calcite-combobox-item-spacing-unit-s:0.75rem;--calcite-combobox-input-height:2.75rem}.wrapper{display:flex;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-1);outline-color:transparent;padding-block:calc(var(--calcite-combobox-item-spacing-unit-s) / 4);padding-inline:var(--calcite-combobox-item-spacing-unit-l)}:host(:focus-within) .wrapper,.wrapper--active{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.wrapper--single{padding-block:0;padding-inline:var(--calcite-combobox-item-spacing-unit-l);cursor:pointer;flex-wrap:nowrap}.grid-input{display:flex;flex-grow:1;flex-wrap:wrap;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0px}.input{flex-grow:1;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-style:none;background-color:transparent;padding:0px;font-family:inherit;color:var(--calcite-ui-text-1);font-size:inherit;block-size:var(--calcite-combobox-input-height);line-height:var(--calcite-combobox-input-height);min-inline-size:120px;-webkit-margin-after:var(--calcite-combobox-item-spacing-unit-s);margin-block-end:var(--calcite-combobox-item-spacing-unit-s)}.input:focus{outline:2px solid transparent;outline-offset:2px}.input--transparent{opacity:0}.input--single{margin-block:0px;padding:0px}.wrapper--active .input-single{cursor:text}.input--hidden{pointer-events:none;inline-size:0px;min-inline-size:0px;opacity:0}.input--icon{padding-block:0;padding-inline:var(--calcite-combobox-item-spacing-unit-l)}.input-wrap{display:flex;flex-grow:1}.input-wrap--single{flex:1 1 0%;overflow:hidden}.label{pointer-events:none;display:flex;max-inline-size:100%;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0px;font-weight:var(--calcite-font-weight-normal);block-size:var(--calcite-combobox-input-height);line-height:var(--calcite-combobox-input-height)}.label--icon{padding-inline:var(--calcite-combobox-item-spacing-unit-l)}.icon-end,.icon-start{display:flex;inline-size:1rem;cursor:pointer;align-items:center}.icon-end{flex:none}.floating-ui-container{display:block;position:absolute;z-index:900;visibility:hidden;pointer-events:none;inline-size:0;block-size:0;overflow:hidden}.floating-ui-container .calcite-floating-ui-anim{position:relative;transition:var(--calcite-floating-ui-transition);visibility:hidden;transition-property:transform, visibility, opacity;opacity:0;box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);z-index:1;border-radius:0.25rem}.floating-ui-container[data-placement^=bottom] .calcite-floating-ui-anim{transform:translateY(-5px)}.floating-ui-container[data-placement^=top] .calcite-floating-ui-anim{transform:translateY(5px)}.floating-ui-container[data-placement^=left] .calcite-floating-ui-anim{transform:translateX(5px)}.floating-ui-container[data-placement^=right] .calcite-floating-ui-anim{transform:translateX(-5px)}.floating-ui-container[data-placement] .calcite-floating-ui-anim--active{opacity:1;visibility:visible;transform:translate(0)}.floating-ui-container--active{pointer-events:initial;visibility:visible;inline-size:unset;block-size:unset;overflow:unset}@media (forced-colors: active){.wrapper,.floating-ui-container--active{border:1px solid canvasText}}.screen-readers-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.list-container{max-block-size:45vh;overflow-y:auto;background-color:var(--calcite-ui-foreground-1);inline-size:var(--calcite-dropdown-width)}.list{margin:0px;display:block;padding:0px}.list--hide{block-size:0px;overflow:hidden}.chip{margin-block:calc(var(--calcite-combobox-item-spacing-unit-s) / 4);margin-inline:0 var(--calcite-combobox-item-spacing-unit-s);max-inline-size:100%}.chip--active{background-color:var(--calcite-ui-foreground-3)}.item{display:block}::slotted(input[slot=hidden-form-input]){margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;inset:0 !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
|
7
|
-
/*!
|
8
|
-
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
9
|
-
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
10
|
-
* v1.0.0-beta.97
|
11
|
-
*/
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import{r as i,c as t,h as e,H as s,g as a}from"./p-c2f00d41.js";import{f as n}from"./p-d48a24e6.js";import{d as o,f as c,c as l,u as r,r as h,a as d,F as m}from"./p-a9cefd9c.js";import{g as p}from"./p-a80b3880.js";import{T as u,C as b,b as g,c as f,h as v,d as x,e as y,g as w,a as k}from"./p-a5b1ab03.js";import{c as C,d as z,g as I}from"./p-bd67334c.js";import{s as $,c as H,a as _,d as D,H as j}from"./p-a33d73bb.js";import{c as L}from"./p-9a9955db.js";import{u as A}from"./p-7daea1df.js";import{i as E,t as S,g as P,a as F}from"./p-83166522.js";import{c as T,d as B}from"./p-2e9ed892.js";import{d as M}from"./p-4e32bf8c.js";import{c as O,d as R}from"./p-1c247f54.js";import{i as W,j as U}from"./p-88e5a76d.js";import{s as V}from"./p-4557d5a8.js";import"./p-729708a3.js";import"./p-dbc9a5a8.js";import"./p-00444009.js";const X="combobox-item-",Y="combobox-chip-",G="combobox-label-",K="combobox-listbox-",N="combobox-input-",q=class{constructor(e){i(this,e),this.calciteLookupChange=t(this,"calciteLookupChange",6),this.calciteComboboxChange=t(this,"calciteComboboxChange",6),this.calciteComboboxFilterChange=t(this,"calciteComboboxFilterChange",6),this.calciteComboboxChipDismiss=t(this,"calciteComboboxChipDismiss",6),this.calciteComboboxBeforeClose=t(this,"calciteComboboxBeforeClose",6),this.calciteComboboxClose=t(this,"calciteComboboxClose",6),this.calciteComboboxBeforeOpen=t(this,"calciteComboboxBeforeOpen",6),this.calciteComboboxOpen=t(this,"calciteComboboxOpen",6),this.active=!1,this.open=!1,this.disabled=!1,this.maxItems=0,this.overlayPositioning="absolute",this.required=!1,this.selectionMode="multi",this.scale="m",this.value=null,this.intlRemoveTag=u.removeTag,this.placement=o,this.internalValueChangeFlag=!1,this.items=[],this.groupItems=[],this.selectedItems=[],this.visibleItems=[],this.activeItemIndex=-1,this.activeChipIndex=-1,this.activeDescendant="",this.text="",this.textInput=null,this.mutationObserver=L("mutation",(()=>this.updateItems())),this.resizeObserver=L("resize",(()=>this.setMaxScrollerHeight())),this.guid=p(),this.inputHeight=0,this.ignoreSelectedEventsFlag=!1,this.openTransitionProp="opacity",this.setFilteredPlacements=()=>{const{el:i,flipPlacements:t}=this;this.filteredFlipPlacements=t?c(t,i):null},this.getValue=()=>{const i=this.selectedItems.map((i=>{var t;return null===(t=null==i?void 0:i.value)||void 0===t?void 0:t.toString()}));return(null==i?void 0:i.length)?i.length>1?i:i[0]:""},this.onLabelClick=()=>{this.setFocus()},this.keydownHandler=i=>{const{key:t}=i;switch(t){case"Tab":this.activeChipIndex=-1,this.activeItemIndex=-1,this.allowCustomValues&&this.text?(this.addCustomChip(this.text,!0),i.preventDefault()):this.open&&(this.open=!1,i.preventDefault());break;case"ArrowLeft":this.previousChip(),i.preventDefault();break;case"ArrowRight":this.nextChip(),i.preventDefault();break;case"ArrowUp":i.preventDefault(),this.shiftActiveItemIndex(-1),this.comboboxInViewport()||this.el.scrollIntoView();break;case"ArrowDown":i.preventDefault(),this.open||(this.open=!0),this.shiftActiveItemIndex(1),this.comboboxInViewport()||this.el.scrollIntoView();break;case" ":this.textInput.value||(i.preventDefault(),this.open=!0,this.shiftActiveItemIndex(1));break;case"Home":if(!this.open)return;i.preventDefault(),this.updateActiveItemIndex(0),this.scrollToActiveItem(),this.comboboxInViewport()||this.el.scrollIntoView();break;case"End":if(!this.open)return;i.preventDefault(),this.updateActiveItemIndex(this.visibleItems.length-1),this.scrollToActiveItem(),this.comboboxInViewport()||this.el.scrollIntoView();break;case"Escape":this.open=!1,i.preventDefault();break;case"Enter":this.activeItemIndex>-1?(this.toggleSelection(this.visibleItems[this.activeItemIndex]),i.preventDefault()):this.activeChipIndex>-1?(this.removeActiveChip(),i.preventDefault()):this.allowCustomValues&&this.text?(this.addCustomChip(this.text,!0),i.preventDefault()):i.defaultPrevented||$(this)&&i.preventDefault();break;case"Delete":case"Backspace":this.activeChipIndex>-1?(i.preventDefault(),this.removeActiveChip()):!this.text&&this.isMulti()&&(i.preventDefault(),this.removeLastChip())}},this.toggleCloseEnd=()=>{this.open=!1,this.el.removeEventListener("calciteComboboxClose",this.toggleCloseEnd)},this.toggleOpenEnd=()=>{this.open=!1,this.el.removeEventListener("calciteComboboxOpen",this.toggleOpenEnd)},this.setMaxScrollerHeight=async()=>{const{listContainerEl:i,open:t,referenceEl:e}=this;if(!i||!t)return;await this.reposition(!0);const s=this.getMaxScrollerHeight();i.style.maxHeight=s>0?`${s}px`:"",i.style.minWidth=`${e.clientWidth}px`,await this.reposition(!0)},this.calciteChipDismissHandler=(i,t)=>{this.open=!1;const e=this.items.find((i=>i===t));e&&this.toggleSelection(e,!1),this.calciteComboboxChipDismiss.emit(i.detail)},this.clickHandler=i=>{i.composedPath().some((i=>"CALCITE-CHIP"===i.tagName))||(this.open=!this.open,this.updateActiveItemIndex(0),this.setFocus())},this.setInactiveIfNotContained=i=>{const t=i.composedPath();!this.open||t.includes(this.el)||t.includes(this.referenceEl)||(this.allowCustomValues&&this.text.trim().length&&this.addCustomChip(this.text),"single"===this.selectionMode&&(this.textInput&&(this.textInput.value=""),this.text="",this.filterItems(""),this.updateActiveItemIndex(-1)),this.open=!1)},this.setFloatingEl=i=>{this.floatingEl=i,l(this,this.referenceEl,this.floatingEl)},this.setContainerEl=i=>{this.resizeObserver.observe(i),this.listContainerEl=i,this.transitionEl=i,T(this)},this.setReferenceEl=i=>{this.referenceEl=i,l(this,this.referenceEl,this.floatingEl)},this.inputHandler=i=>{const t=i.target.value;this.text=t,this.filterItems(t),t&&(this.activeChipIndex=-1)},this.filterItems=(()=>{const i=(i,t)=>i&&t.some((({label:t,value:e})=>i.tagName===y?e===i.label:e===i.textLabel||e===i.value||t===i.textLabel||t===i.value));return M((t=>{const e=n(this.data,t);this.getCombinedItems().forEach((t=>{const s=!i(t,e);t.hidden=s;const[a,n]=t.ancestors;(i(a,e)||i(n,e))&&(t.hidden=!1),s||t.ancestors.forEach((i=>i.hidden=!1))})),this.visibleItems=this.getVisibleItems(),this.calciteComboboxFilterChange.emit({visibleItems:[...this.visibleItems],text:t})}),100)})(),this.internalCalciteLookupChangeEvent=()=>{this.calciteLookupChange.emit(this.selectedItems)},this.emitCalciteLookupChange=M(this.internalCalciteLookupChangeEvent,0),this.internalComboboxChangeEvent=()=>{const{selectedItems:i}=this;this.calciteComboboxChange.emit({selectedItems:i})},this.emitComboboxChange=M(this.internalComboboxChangeEvent,0),this.updateItems=()=>{this.items=this.getItems(),this.groupItems=this.getGroupItems(),this.data=this.getData(),this.selectedItems=this.getSelectedItems(),this.visibleItems=this.getVisibleItems(),this.needsIcon=this.getNeedsIcon(),this.allowCustomValues||this.setMaxScrollerHeight()},this.scrollToActiveItem=()=>{const i=this.visibleItems[this.activeItemIndex],t=this.calculateSingleItemHeight(i),{offsetHeight:e,scrollTop:s}=this.listContainerEl;e+s<i.offsetTop+t?this.listContainerEl.scrollTop=i.offsetTop-e+t:i.offsetTop<s&&(this.listContainerEl.scrollTop=i.offsetTop)},this.comboboxFocusHandler=()=>{var i;null===(i=this.textInput)||void 0===i||i.focus()},this.comboboxBlurHandler=i=>{this.setInactiveIfNotContained(i)}}activeHandler(i){if(this.disabled)return this.active=!1,void(this.open=!1);this.open=i}openHandler(i){if(i||r(this.floatingEl),this.disabled)return this.active=!1,void(this.open=!1);this.active=i,this.setMaxScrollerHeight()}handleDisabledChange(i){i||(this.active=!1,this.open=!1)}maxItemsHandler(){this.setMaxScrollerHeight()}overlayPositioningHandler(){this.reposition(!0)}valueHandler(i){if(!this.internalValueChangeFlag){const t=this.getItems();Array.isArray(i)?t.forEach((t=>t.selected=i.includes(t.value))):t.forEach(i?t=>t.selected=i===t.value:i=>i.selected=!1),this.updateItems()}}flipPlacementsHandler(){this.setFilteredPlacements(),this.reposition(!0)}documentClickHandler(i){E(i)&&this.setInactiveIfNotContained(i)}calciteComboboxItemChangeHandler(i){if(this.ignoreSelectedEventsFlag)return;const t=i.target,e=this.visibleItems.indexOf(t);this.updateActiveItemIndex(e),this.toggleSelection(t,t.selected)}async reposition(i=!1){const{floatingEl:t,referenceEl:e,placement:s,overlayPositioning:a,filteredFlipPlacements:n}=this;return h(this,{floatingEl:t,referenceEl:e,overlayPositioning:a,placement:s,flipPlacements:n,type:"menu"},i)}async setFocus(){var i;null===(i=this.textInput)||void 0===i||i.focus(),this.activeChipIndex=-1,this.activeItemIndex=-1}connectedCallback(){var i;this.internalValueChangeFlag=!0,this.value=this.getValue(),this.internalValueChangeFlag=!1,null===(i=this.mutationObserver)||void 0===i||i.observe(this.el,{childList:!0,subtree:!0}),C(this),H(this),T(this),this.setFilteredPlacements(),this.reposition(!0),this.active&&this.activeHandler(this.active),this.open&&this.openHandler(this.open)}componentWillLoad(){this.updateItems()}componentDidLoad(){_(this,this.getValue()),this.reposition(!0)}componentDidRender(){this.el.offsetHeight!==this.inputHeight&&(this.reposition(!0),this.inputHeight=this.el.offsetHeight),A(this)}disconnectedCallback(){var i,t;null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),z(this),D(this),d(this,this.referenceEl,this.floatingEl),B(this)}selectedItemsHandler(){this.internalValueChangeFlag=!0,this.value=this.getValue(),this.internalValueChangeFlag=!1}textHandler(){this.updateActiveItemIndex(-1)}comboboxInViewport(){const i=this.el.getBoundingClientRect();return i.top>=0&&i.left>=0&&i.right<=(window.innerWidth||document.documentElement.clientWidth)&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)}onBeforeOpen(){this.calciteComboboxBeforeOpen.emit()}onOpen(){this.calciteComboboxOpen.emit()}onBeforeClose(){this.calciteComboboxBeforeClose.emit()}onClose(){this.calciteComboboxClose.emit()}getMaxScrollerHeight(){const i=this.getCombinedItems().filter((i=>!i.hidden)),{maxItems:t}=this;let e=0,s=0;return i.length>t&&i.forEach((i=>{if(e<t&&t>0){const t=this.calculateSingleItemHeight(i);t>0&&(s+=t,e++)}})),s}calculateSingleItemHeight(i){let t=i.offsetHeight;return Array.from(i.querySelectorAll(b)).map((i=>null==i?void 0:i.offsetHeight)).forEach((i=>{t-=i})),t}getCombinedItems(){return[...this.groupItems,...this.items]}toggleSelection(i,t=!i.selected){i&&(this.isMulti()?(i.selected=t,this.updateAncestors(i),this.selectedItems=this.getSelectedItems(),this.emitCalciteLookupChange(),this.emitComboboxChange(),this.resetText(),this.filterItems("")):(this.ignoreSelectedEventsFlag=!0,this.items.forEach((e=>e.selected=e===i&&t)),this.ignoreSelectedEventsFlag=!1,this.selectedItems=this.getSelectedItems(),this.emitComboboxChange(),this.textInput&&(this.textInput.value=i.textLabel),this.open=!1,this.updateActiveItemIndex(-1),this.resetText(),this.filterItems("")))}updateAncestors(i){if("ancestors"!==this.selectionMode)return;const t=g(i),e=f(i);i.selected?t.forEach((i=>{i.selected=!0})):(e.forEach((i=>i.selected=!1)),[...t].forEach((i=>{v(i)||(i.selected=!1)})))}getVisibleItems(){return this.items.filter((i=>!i.hidden))}getSelectedItems(){if(!this.isMulti()){const i=this.items.find((({selected:i})=>i));return i?[i]:[]}return this.items.filter((i=>i.selected&&("ancestors"!==this.selectionMode||!v(i)))).sort(((i,t)=>{const e=this.selectedItems.indexOf(i),s=this.selectedItems.indexOf(t);return e>-1&&s>-1?e-s:s-e}))}getData(){return this.items.map((i=>({constant:i.constant,filterDisabled:i.filterDisabled,value:i.value,label:i.textLabel})))}getNeedsIcon(){return"single"===this.selectionMode&&this.items.some((i=>i.icon))}resetText(){this.textInput&&(this.textInput.value=""),this.text=""}getItems(){return Array.from(this.el.querySelectorAll(x)).filter((i=>!i.disabled))}getGroupItems(){return Array.from(this.el.querySelectorAll(y))}addCustomChip(i,t){const e=this.items.find((t=>t.textLabel===i));if(e)this.toggleSelection(e,!0);else{this.isMulti()||this.toggleSelection(this.selectedItems[this.selectedItems.length-1],!1);const e=document.createElement(x);e.value=i,e.textLabel=i,e.selected=!0,this.el.appendChild(e),this.resetText(),t&&this.setFocus(),this.updateItems(),this.filterItems(""),this.emitCalciteLookupChange(),this.emitComboboxChange()}}removeActiveChip(){this.toggleSelection(this.selectedItems[this.activeChipIndex],!1),this.setFocus()}removeLastChip(){this.toggleSelection(this.selectedItems[this.selectedItems.length-1],!1),this.setFocus()}previousChip(){if(this.text)return;const i=this.activeChipIndex;this.activeChipIndex=-1===i?this.selectedItems.length-1:Math.max(i-1,0),this.updateActiveItemIndex(-1),this.focusChip()}nextChip(){if(this.text||-1===this.activeChipIndex)return;const i=this.activeChipIndex+1;i>this.selectedItems.length-1?(this.activeChipIndex=-1,this.setFocus()):(this.activeChipIndex=i,this.focusChip()),this.updateActiveItemIndex(-1)}focusChip(){var i;const t=null===(i=this.selectedItems[this.activeChipIndex])||void 0===i?void 0:i.guid,e=t?this.referenceEl.querySelector(`#${Y}${t}`):null;null==e||e.setFocus()}shiftActiveItemIndex(i){const{length:t}=this.visibleItems;this.updateActiveItemIndex((this.activeItemIndex+t+i)%t),this.scrollToActiveItem()}updateActiveItemIndex(i){var t;this.activeItemIndex=i;let e=null;this.visibleItems.forEach(((t,s)=>{s===i?(t.active=!0,e=`${X}${t.guid}`):t.active=!1})),this.activeDescendant=e,this.activeItemIndex>-1&&(this.activeChipIndex=-1,null===(t=this.textInput)||void 0===t||t.focus())}isMulti(){return"single"!==this.selectionMode}renderChips(){const{activeChipIndex:i,scale:t,selectionMode:s,intlRemoveTag:a}=this;return this.selectedItems.map(((n,o)=>{const c={chip:!0,"chip--active":i===o},l=[...[...g(n)].reverse(),n].map((i=>i.textLabel)),r="ancestors"!==s?n.textLabel:l.join(" / ");return e("calcite-chip",{class:c,dismissLabel:a,dismissible:!0,icon:n.icon,id:n.guid?`${Y}${n.guid}`:null,key:n.textLabel,onCalciteChipDismiss:i=>this.calciteChipDismissHandler(i,n),scale:t,title:r,value:n.value},r)}))}renderInput(){const{guid:i,active:t,disabled:s,placeholder:a,selectionMode:n,selectedItems:o,open:c}=this,l="single"===n,r=o[0],h=!(c||t)&&l&&!!r;return e("span",{class:{"input-wrap":!0,"input-wrap--single":l}},h&&e("span",{class:{label:!0,"label--icon":!!(null==r?void 0:r.icon)},key:"label"},r.textLabel),e("input",{"aria-activedescendant":this.activeDescendant,"aria-autocomplete":"list","aria-controls":`${K}${i}`,"aria-label":I(this),class:{input:!0,"input--single":!0,"input--transparent":this.activeChipIndex>-1,"input--hidden":h,"input--icon":!!this.placeholderIcon},disabled:s,id:`${N}${i}`,key:"input",onBlur:this.comboboxBlurHandler,onFocus:this.comboboxFocusHandler,onInput:this.inputHandler,placeholder:a,ref:i=>this.textInput=i,type:"text"}))}renderListBoxOptions(){return this.visibleItems.map((i=>e("li",{"aria-selected":S(i.selected),id:i.guid?`${X}${i.guid}`:null,role:"option",tabindex:"-1"},i.textLabel)))}renderFloatingUIContainer(){const{active:i,setFloatingEl:t,setContainerEl:s,open:a}=this;return e("div",{"aria-hidden":"true",class:{"floating-ui-container":!0,"floating-ui-container--active":a||i},ref:t},e("div",{class:{"list-container":!0,[m.animation]:!0,[m.animationActive]:a||i},ref:s},e("ul",{class:{list:!0,"list--hide":!(a||i)}},e("slot",null))))}renderIconStart(){const{selectedItems:i,placeholderIcon:t,selectionMode:s}=this,a=i[0],n=null==a?void 0:a.icon,o="single"===s;return(!this.open&&a?!!n&&o:!!this.placeholderIcon&&(!a||o))&&e("span",{class:"icon-start"},e("calcite-icon",{class:"selected-icon",icon:!this.open&&a?n:t,scale:"s"}))}renderIconEnd(){const{active:i,open:t}=this;return e("span",{class:"icon-end"},e("calcite-icon",{icon:i||t?"chevron-up":"chevron-down",scale:"s"}))}render(){const{active:i,guid:t,label:a,open:n}=this,o="single"===this.selectionMode;return e(s,null,e("div",{"aria-autocomplete":"list","aria-controls":`${K}${t}`,"aria-expanded":S(n||i),"aria-haspopup":"listbox","aria-labelledby":`${G}${t}`,"aria-live":"polite","aria-owns":`${K}${t}`,class:{wrapper:!0,"wrapper--single":o||!this.selectedItems.length,"wrapper--active":n||i},onClick:this.clickHandler,onKeyDown:this.keydownHandler,ref:this.setReferenceEl,role:"combobox"},e("div",{class:"grid-input"},this.renderIconStart(),!o&&this.renderChips(),e("label",{class:"screen-readers-only",htmlFor:`${N}${t}`,id:`${G}${t}`},a),this.renderInput()),this.renderIconEnd()),e("ul",{"aria-labelledby":`${G}${t}`,"aria-multiselectable":"true",class:"screen-readers-only",id:`${K}${t}`,role:"listbox",tabIndex:-1},this.renderListBoxOptions()),this.renderFloatingUIContainer(),e(j,{component:this}))}get el(){return a(this)}static get watchers(){return{active:["activeHandler"],open:["openHandler"],disabled:["handleDisabledChange"],maxItems:["maxItemsHandler"],overlayPositioning:["overlayPositioningHandler"],value:["valueHandler"],flipPlacements:["flipPlacementsHandler"],selectedItems:["selectedItemsHandler"],text:["textHandler"]}}};q.style="@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{position:relative;display:block}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]){font-size:var(--calcite-font-size--2);--calcite-combobox-item-spacing-unit-l:0.5rem;--calcite-combobox-item-spacing-unit-s:0.25rem;--calcite-combobox-input-height:1.5rem}:host([scale=m]){font-size:var(--calcite-font-size--1);--calcite-combobox-item-spacing-unit-l:0.75rem;--calcite-combobox-item-spacing-unit-s:0.5rem;--calcite-combobox-input-height:2rem}:host([scale=l]){font-size:var(--calcite-font-size-0);--calcite-combobox-item-spacing-unit-l:1rem;--calcite-combobox-item-spacing-unit-s:0.75rem;--calcite-combobox-input-height:2.75rem}.wrapper{display:flex;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-input);background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-1);outline-color:transparent;padding-block:calc(var(--calcite-combobox-item-spacing-unit-s) / 4);padding-inline:var(--calcite-combobox-item-spacing-unit-l)}:host(:focus-within) .wrapper,.wrapper--active{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.wrapper--single{padding-block:0;padding-inline:var(--calcite-combobox-item-spacing-unit-l);cursor:pointer;flex-wrap:nowrap}.grid-input{display:flex;flex-grow:1;flex-wrap:wrap;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0px}.input{flex-grow:1;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-style:none;background-color:transparent;padding:0px;font-family:inherit;color:var(--calcite-ui-text-1);font-size:inherit;block-size:var(--calcite-combobox-input-height);line-height:var(--calcite-combobox-input-height);min-inline-size:120px;-webkit-margin-after:var(--calcite-combobox-item-spacing-unit-s);margin-block-end:var(--calcite-combobox-item-spacing-unit-s)}.input:focus{outline:2px solid transparent;outline-offset:2px}.input--transparent{opacity:0}.input--single{margin-block:0px;padding:0px}.wrapper--active .input-single{cursor:text}.input--hidden{pointer-events:none;inline-size:0px;min-inline-size:0px;opacity:0}.input--icon{padding-block:0;padding-inline:var(--calcite-combobox-item-spacing-unit-l)}.input-wrap{display:flex;flex-grow:1}.input-wrap--single{flex:1 1 0%;overflow:hidden}.label{pointer-events:none;display:flex;max-inline-size:100%;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0px;font-weight:var(--calcite-font-weight-normal);block-size:var(--calcite-combobox-input-height);line-height:var(--calcite-combobox-input-height)}.label--icon{padding-inline:var(--calcite-combobox-item-spacing-unit-l)}.icon-end,.icon-start{display:flex;inline-size:1rem;cursor:pointer;align-items:center}.icon-end{flex:none}.floating-ui-container{display:block;position:absolute;z-index:900;visibility:hidden;pointer-events:none;inline-size:0;block-size:0;overflow:hidden}.floating-ui-container .calcite-floating-ui-anim{position:relative;transition:var(--calcite-floating-ui-transition);visibility:hidden;transition-property:transform, visibility, opacity;opacity:0;box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);z-index:1;border-radius:0.25rem}.floating-ui-container[data-placement^=bottom] .calcite-floating-ui-anim{transform:translateY(-5px)}.floating-ui-container[data-placement^=top] .calcite-floating-ui-anim{transform:translateY(5px)}.floating-ui-container[data-placement^=left] .calcite-floating-ui-anim{transform:translateX(5px)}.floating-ui-container[data-placement^=right] .calcite-floating-ui-anim{transform:translateX(-5px)}.floating-ui-container[data-placement] .calcite-floating-ui-anim--active{opacity:1;visibility:visible;transform:translate(0)}.floating-ui-container--active{pointer-events:initial;visibility:visible;inline-size:unset;block-size:unset;overflow:unset}@media (forced-colors: active){.wrapper,.floating-ui-container--active{border:1px solid canvasText}}.screen-readers-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.list-container{max-block-size:45vh;overflow-y:auto;background-color:var(--calcite-ui-foreground-1);inline-size:var(--calcite-dropdown-width)}.list{margin:0px;display:block;padding:0px}.list--hide{block-size:0px;overflow:hidden}.chip{margin-block:calc(var(--calcite-combobox-item-spacing-unit-s) / 4);margin-inline:0 var(--calcite-combobox-item-spacing-unit-s);max-inline-size:100%}.chip--active{background-color:var(--calcite-ui-foreground-3)}.item{display:block}::slotted(input[slot=hidden-form-input]){margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;inset:0 !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
|
7
|
+
/*!
|
8
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
9
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
10
|
+
* v1.0.0-beta.97
|
11
|
+
*/
|
12
12
|
const J="icon",Q=class{constructor(e){i(this,e),this.calciteComboboxItemChange=t(this,"calciteComboboxItemChange",6),this.disabled=!1,this.selected=!1,this.active=!1,this.guid=p(),this.scale="m",this.itemClickHandler=i=>{i.preventDefault(),this.disabled||(this.selected=!this.selected)}}selectedWatchHandler(){this.calciteComboboxItemChange.emit(this.el)}connectedCallback(){this.ancestors=w(this.el),this.scale=P(this.el,"scale",this.scale),O(this)}disconnectedCallback(){R(this)}componentDidRender(){A(this)}async toggleSelected(i){this.disabled||(this.selected="boolean"==typeof i?i:!this.selected)}renderIcon(i){const{icon:t,disabled:s,selected:a}=this,n=`${J}--indent`;return!i||t||s?e("calcite-icon",{class:{[J]:!t,"icon--custom":!!t,"icon--active":t&&a,[n]:!0},icon:t||(s?"circle-disallowed":i?"dot":"check"),scale:"s"}):e("span",{class:{[J]:!0,"icon--dot":!0,[n]:!0}})}renderChildren(){return F(this.el)?e("ul",{key:"default-slot-container"},e("slot",null)):null}render(){const i="single"===P(this.el,"selection-mode","multi"),t={label:!0,"label--selected":this.selected,"label--active":this.active,"label--single":i},a=k(this.el);return e(s,{"aria-hidden":"true"},e("div",{class:`container scale--${this.scale}`,style:{"--calcite-combobox-item-spacing-indent-multiplier":`${a}`}},e("li",{class:t,id:this.guid,onClick:this.itemClickHandler},this.renderIcon(i),e("span",{class:"title"},this.textLabel)),this.renderChildren()))}get el(){return a(this)}static get watchers(){return{selected:["selectedWatchHandler"]}}};Q.style='@charset "UTF-8";@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}.scale--s{font-size:var(--calcite-font-size--2);line-height:1rem;--calcite-combobox-item-spacing-unit-l:0.5rem;--calcite-combobox-item-spacing-unit-s:0.25rem;--calcite-combobox-item-spacing-indent:0.5rem}.scale--m{font-size:var(--calcite-font-size--1);line-height:1rem;--calcite-combobox-item-spacing-unit-l:0.75rem;--calcite-combobox-item-spacing-unit-s:0.5rem;--calcite-combobox-item-spacing-indent:0.75rem}.scale--l{font-size:var(--calcite-font-size-0);line-height:1.25rem;--calcite-combobox-item-spacing-unit-l:1rem;--calcite-combobox-item-spacing-unit-s:0.75rem;--calcite-combobox-item-spacing-indent:1rem}.container{--calcite-combobox-item-indent-value:calc(\n var(--calcite-combobox-item-spacing-indent) * var(--calcite-combobox-item-spacing-indent-multiplier)\n )}:host(:focus){--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host,ul{margin:0px;display:flex;flex-direction:column;padding:0px}:host(:focus),ul:focus{outline:2px solid transparent;outline-offset:2px}.label{position:relative;box-sizing:border-box;display:flex;inline-size:100%;min-inline-size:100%;cursor:pointer;align-items:center;color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);outline-color:transparent;padding-block:var(--calcite-combobox-item-spacing-unit-s);padding-inline:var(--calcite-combobox-item-spacing-unit-l)}:host([disabled]) .label{cursor:default}.label--selected{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}.label--active{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.label:hover,.label:active{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1);-webkit-text-decoration-line:none;text-decoration-line:none;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.title{padding-block:0;padding-inline:var(--calcite-combobox-item-spacing-unit-l)}.icon{display:inline-flex;opacity:0;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);color:var(--calcite-ui-border-1)}.icon--indent{-webkit-padding-start:var(--calcite-combobox-item-indent-value);padding-inline-start:var(--calcite-combobox-item-indent-value)}.icon--custom{-webkit-margin-before:-1px;margin-block-start:-1px;color:var(--calcite-ui-text-3)}.icon--active{color:var(--calcite-ui-text-1)}.icon--dot{display:flex;justify-content:flex-end;min-inline-size:var(--calcite-combobox-item-spacing-unit-l)}.icon--dot:before{text-align:start;content:"•"}.label--active .icon{opacity:1}.label--selected .icon{opacity:1;color:var(--calcite-ui-brand)}:host(:hover[disabled]) .icon{opacity:1}';const Z=class{constructor(e){i(this,e),this.layerSelectionChange=t(this,"layerSelectionChange",7),this.enabledLayerIds=[],this.mapView=void 0,this.selectedLayerIds=[],this.selectionMode="single",this.layerIds=[]}async watchStateHandler(i,t){i!==t&&(await this._setLayers(),"single"===this.selectionMode&&this.layerSelectionChange.emit([this.layerIds[0]]))}async componentWillLoad(){await this._setLayers(),"single"===this.selectionMode&&(this.layerIds.length>0||1===this.selectedLayerIds.length)&&this.layerSelectionChange.emit(1===this.selectedLayerIds.length?[this.selectedLayerIds[0]]:[this.layerIds[0]])}render(){return e(s,null,e("div",{class:"map-layer-picker-container"},e("div",{class:"map-layer-picker"},"multi"===this.selectionMode?this._getCombobox():this._getSelect())))}_getSelect(){return e("calcite-select",{label:"",onCalciteSelectChange:i=>this._layerSelectionChange(i),ref:i=>{this._layerElement=i}},this._addMapLayersOptions())}_getCombobox(){return e("calcite-combobox",{label:"",onCalciteComboboxChange:i=>this._layerSelectionChange(i),"selection-mode":this.selectionMode},this._addMapLayersOptions())}_addMapLayersOptions(){return this.layerIds.reduce(((i,t)=>(V.managedLayers.indexOf(V.layerNameHash[t])<0&&(!(this.enabledLayerIds.length>0)||this.enabledLayerIds.indexOf(t)>-1)&&i.push("multi"===this.selectionMode&&this.selectedLayerIds.indexOf(t)>-1?e("calcite-combobox-item",{selected:!0,textLabel:V.layerNameHash[t],value:t}):"multi"===this.selectionMode?e("calcite-combobox-item",{textLabel:V.layerNameHash[t],value:t}):this.selectedLayerIds.indexOf(t)>-1?e("calcite-option",{label:V.layerNameHash[t],selected:!0,value:t}):e("calcite-option",{label:V.layerNameHash[t],value:t})),i)),[])}async _setLayers(){if(this.mapView){const i=await W(this.mapView);this.layerIds=i.filter((i=>{var t;return!((null===(t=this.enabledLayerIds)||void 0===t?void 0:t.length)>0)||this.enabledLayerIds.indexOf(i)>-1})),await this._initLayerHashState()}}async _initLayerHashState(){this.mapView&&(V.layerNameHash=await U(this.mapView))}_layerSelectionChange(i){var t;this.selectedLayerIds="single"===this.selectionMode?[this._layerElement.value]:(null===(t=i.detail)||void 0===t?void 0:t.selectedItems.map((i=>i.value)))||[],this.layerSelectionChange.emit(this.selectedLayerIds)}get el(){return a(this)}static get watchers(){return{mapView:["watchStateHandler"]}}};Z.style=":host{display:block}.map-layer-picker-container{width:100%}.map-layer-picker{position:relative;width:100%;display:inline-block}.padding-bottom-1{padding-bottom:1rem}";export{q as calcite_combobox,Q as calcite_combobox_item,Z as map_layer_picker}
|