p-6a27e2d9.entry.js 19 KB

123456
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.82
  5. */
  6. import{r as t,c as e,h as i,H as a,g as n}from"./p-f74193a3.js";import{f as o,n as r,g as c,a as s,C as l,t as m,k as h}from"./p-f383e414.js";import{c as d,d as f}from"./p-7266932c.js";import"./p-dc14a2a0.js";import"./p-e9e1dee1.js";var p;!function(t){t.Single="single",t.Multi="multi",t.Children="children",t.MultiChildren="multi-children",t.Ancestors="ancestors"}(p||(p={}));const k=class{constructor(i){t(this,i),this.calciteTreeSelect=e(this,"calciteTreeSelect",7),this.lines=!1,this.inputEnabled=!1,this.scale="m",this.selectionMode=p.Single}componentWillRender(){const t=this.el.parentElement.closest("calcite-tree");this.lines=t?t.lines:this.lines,this.scale=t?t.scale:this.scale,this.selectionMode=t?t.selectionMode:this.selectionMode,this.child=!!t}render(){return i(a,{"aria-multiselectable":this.child?void 0:(this.selectionMode===p.Multi||this.selectionMode===p.MultiChildren).toString(),role:this.child?void 0:"tree",tabIndex:this.getRootTabIndex()},i("slot",null))}onFocus(){if(!this.child){const t=this.el.querySelector("calcite-tree-item[selected]")||this.el.querySelector("calcite-tree-item");o(t)}}onFocusIn(t){(t.relatedTarget===this.el||!this.el.contains(t.relatedTarget))&&this.el.removeAttribute("tabindex")}onFocusOut(t){!this.el.contains(t.relatedTarget)&&(this.el.tabIndex=this.getRootTabIndex())}onClick(t){const e=t.target,i=r(e.querySelectorAll("calcite-tree-item"));if(this.child)return;if(this.child||(t.preventDefault(),t.stopPropagation()),this.selectionMode===p.Ancestors&&!this.child)return void this.updateAncestorTree(t);const a=t.detail.modifyCurrentSelection&&(this.selectionMode===p.Multi||this.selectionMode===p.MultiChildren),n=this.selectionMode===p.MultiChildren||this.selectionMode===p.Children,o=!a&&((this.selectionMode===p.Single||this.selectionMode===p.Multi)&&i.length<=0||this.selectionMode===p.Children||this.selectionMode===p.MultiChildren),c=this.selectionMode===p.Children||this.selectionMode===p.MultiChildren;if(!this.child){const s=[];null!==this.selectionMode&&(!e.hasChildren||e.hasChildren&&(this.selectionMode===p.Children||this.selectionMode===p.MultiChildren))&&s.push(e),n&&i.forEach((t=>{s.push(t)})),o&&r(this.el.querySelectorAll("calcite-tree-item[selected]")).forEach((t=>{s.includes(t)||(t.selected=!1)})),c&&!t.detail.forceToggle&&(e.expanded=!0),a&&window.getSelection().removeAllRanges(),s.forEach(a&&e.selected||n&&t.detail.forceToggle?t=>{t.selected=!1}:t=>{t.selected=!0})}this.calciteTreeSelect.emit({selected:r(this.el.querySelectorAll("calcite-tree-item")).filter((t=>t.selected))})}keyDownHandler(t){var e;const i=this.el.closest("calcite-tree:not([child])"),a=t.target;if(i===this.el&&"CALCITE-TREE-ITEM"===a.tagName&&this.el.contains(a))switch(t.key){case"ArrowDown":const i=a.nextElementSibling;i&&i.matches("calcite-tree-item")&&(i.focus(),t.preventDefault());break;case"ArrowLeft":if(a.hasChildren&&a.expanded){a.expanded=!1,t.preventDefault();break}const n=a.parentElement.closest("calcite-tree-item");if(n&&(!a.hasChildren||!1===a.expanded)){n.focus(),t.preventDefault();break}break;case"ArrowRight":if(!a.hasChildren)break;a.expanded&&document.activeElement===a?(null===(e=a.querySelector("calcite-tree-item"))||void 0===e||e.focus(),t.preventDefault()):(a.expanded=!0,t.preventDefault());break;case"ArrowUp":const o=a.previousElementSibling;o&&o.matches("calcite-tree-item")&&(o.focus(),t.preventDefault())}}updateAncestorTree(t){const e=t.target,i=e.querySelectorAll("calcite-tree-item"),a=[];let n=e.parentElement.closest("calcite-tree-item");for(;n;)a.push(n),n=n.parentElement.closest("calcite-tree-item");e.selected=!e.selected,e.indeterminate=!1,(null==i?void 0:i.length)&&i.forEach((t=>{t.selected=e.selected,t.indeterminate=!1})),a&&a.forEach((t=>{const e=r(t.querySelectorAll("calcite-tree-item")),i=e.filter((t=>t.selected));if(0===i.length)return t.selected=!1,void(t.indeterminate=!1);const a=i.length<e.length;t.indeterminate=a,t.selected=!a})),this.calciteTreeSelect.emit({selected:r(this.el.querySelectorAll("calcite-tree-item")).filter((t=>t.selected))})}getRootTabIndex(){return this.child?-1:0}get el(){return n(this)}};k.style="@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 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;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;outline:2px solid transparent;outline-offset:2px}";const b=class{constructor(i){t(this,i),this.calciteTreeItemSelect=e(this,"calciteTreeItemSelect",7),this.selected=!1,this.expanded=!1,this.parentExpanded=!1,this.depth=-1,this.hasChildren=null,this.iconClickHandler=t=>{t.stopPropagation(),this.expanded=!this.expanded},this.childrenClickHandler=t=>t.stopPropagation(),this.updateParentIsExpanded=(t,e)=>{c(t,"children",{all:!0,selector:"calcite-tree-item"}).forEach((t=>t.parentExpanded=e))},this.updateAncestorTree=()=>{if(this.selected&&this.selectionMode===p.Ancestors){const t=[];let e=this.parentTreeItem;for(;e;)t.push(e),e=e.parentElement.closest("calcite-tree-item");t.forEach((t=>t.indeterminate=!0))}}}expandedHandler(t){this.updateParentIsExpanded(this.el,t)}getselectionMode(){this.isSelectionMultiLike=this.selectionMode===p.Multi||this.selectionMode===p.MultiChildren}connectedCallback(){if(this.parentTreeItem=this.el.parentElement.closest("calcite-tree-item"),this.parentTreeItem){const{expanded:t}=this.parentTreeItem;this.updateParentIsExpanded(this.parentTreeItem,t)}d(this)}disconnectedCallback(){f(this)}componentWillRender(){this.hasChildren=!!this.el.querySelector("calcite-tree"),this.depth=0;let t,e=this.el.closest("calcite-tree");if(e)for(this.selectionMode=e.selectionMode,this.scale=e.scale||"m",this.lines=e.lines;e&&(t=e.parentElement.closest("calcite-tree"),t!==e);)e=t,this.depth=this.depth+1}componentDidLoad(){this.updateAncestorTree()}render(){const t="rtl"===s(this.el),e=this.selectionMode===p.Single||this.selectionMode===p.Children,n=this.selectionMode===p.Multi||this.selectionMode===p.MultiChildren,o=this.hasChildren?i("calcite-icon",{class:{chevron:!0,[l.rtl]:t},"data-test-id":"icon",icon:"chevron-right",onClick:this.iconClickHandler,scale:"s"}):null,r=i("slot",{key:"default-slot"}),c=this.selectionMode===p.Ancestors?i("label",{class:"checkbox-label",key:"checkbox-label"},i("calcite-checkbox",{checked:this.selected,class:"checkbox","data-test-id":"checkbox",indeterminate:this.hasChildren&&this.indeterminate,scale:this.scale,tabIndex:-1}),r):null,h=e?"bullet-point":n?"check":null,d=h?i("calcite-icon",{class:{"bullet-point":"bullet-point"===h,checkmark:"check"===h,[l.rtl]:t},icon:h,scale:"s"}):null,f=!(this.parentExpanded||1===this.depth);return i(a,{"aria-expanded":this.hasChildren?m(this.expanded):void 0,"aria-hidden":m(f),"aria-selected":this.selected?"true":n?"false":void 0,"calcite-hydrated-hidden":f,role:"treeitem",tabindex:this.parentExpanded||1===this.depth?"0":"-1"},i("div",{class:{"node-container":!0,[l.rtl]:t},"data-selection-mode":this.selectionMode,ref:t=>this.defaultSlotWrapper=t},o,d,c||r),i("div",{class:{"children-container":!0,[l.rtl]:t},"data-test-id":"calcite-tree-children",onClick:this.childrenClickHandler,ref:t=>this.childrenSlotWrapper=t,role:this.hasChildren?"group":void 0},i("slot",{name:"children"})))}onClick(t){const[e]=h(this.el,"a");e&&"a"!==t.composedPath()[0].tagName.toLowerCase()&&window.open(e.href,""===e.target?"_self":e.target),this.calciteTreeItemSelect.emit({modifyCurrentSelection:this.selectionMode===p.Ancestors||this.isSelectionMultiLike,forceToggle:!1})}keyDownHandler(t){let e;switch(t.key){case" ":this.calciteTreeItemSelect.emit({modifyCurrentSelection:this.isSelectionMultiLike,forceToggle:!1}),t.preventDefault();break;case"Enter":const i=r(this.el.children).find((t=>t.matches("a")));i?(i.click(),this.selected=!0):this.calciteTreeItemSelect.emit({modifyCurrentSelection:this.isSelectionMultiLike,forceToggle:!1}),t.preventDefault();break;case"Home":e=this.el.closest("calcite-tree:not([child])"),e.querySelector("calcite-tree-item").focus();break;case"End":e=this.el.closest("calcite-tree:not([child])");let a=e.children[e.children.length-1],n=r(a.children).find((t=>t.matches("calcite-tree")));for(;n;)a=n.children[e.children.length-1],n=r(a.children).find((t=>t.matches("calcite-tree")));a.focus()}}get el(){return n(this)}static get watchers(){return{expanded:["expandedHandler"],selectionMode:["getselectionMode"]}}};b.style='@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 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;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;max-width:100%;cursor:pointer;color:var(--calcite-ui-text-3);outline:2px solid transparent;outline-offset:2px}:host([scale=s]){font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=s]) .node-container{--calcite-tree-padding-y:0.25rem}:host([scale=s]) .node-container .checkbox,:host([scale=s]) .node-container .chevron,:host([scale=s]) .node-container .checkmark,:host([scale=s]) .node-container .bullet-point{margin-inline:0.25rem}:host([scale=m]){font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=m]) .node-container{--calcite-tree-padding-y:0.5rem}:host([scale=m]) .node-container .checkbox,:host([scale=m]) .node-container .chevron,:host([scale=m]) .node-container .checkmark,:host([scale=m]) .node-container .bullet-point{margin-inline:0.5rem}:host([scale=l]){font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=l]) .node-container{--calcite-tree-padding-y:0.75rem}:host([scale=l]) .node-container .checkbox,:host([scale=l]) .node-container .chevron,:host([scale=l]) .node-container .checkmark,:host([scale=l]) .node-container .bullet-point{margin-inline:0.75rem}:host([lines]) .children-container:after{position:absolute;top:0px;width:1px;transition-property:color, background-color, border-color, fill, stroke, -webkit-text-decoration-color;-webkit-transition-property:color, background-color, border-color, fill, stroke, -webkit-text-decoration-color;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, -webkit-text-decoration-color;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;height:96%;content:"";background-color:var(--calcite-ui-border-2);z-index:-1}:host(:not([lines])) .node-container:after{display:none}::slotted(*){min-width:0px;max-width:100%;overflow-wrap:break-word;color:inherit;text-decoration:none !important}::slotted(*):hover{text-decoration:none !important}::slotted(a){width:100%;-webkit-text-decoration-line:none;text-decoration-line:none}:host{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host(:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.checkbox{outline:2px solid transparent;outline-offset:2px;line-height:0}.checkbox-label{pointer-events:none;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.children-container{position:relative;height:0px;overflow:hidden;-webkit-margin-start:1.25rem;margin-inline-start:1.25rem;-webkit-transform:scaleY(0);transform:scaleY(0);opacity:0;-webkit-transition:var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), opacity var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), all var(--calcite-animation-timing) ease-in-out;transition:var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), opacity var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), all var(--calcite-animation-timing) ease-in-out;-webkit-transform-origin:top;transform-origin:top}:host([expanded])>.children-container{-webkit-transform:scaleY(1);transform:scaleY(1);opacity:1;height:auto}.node-container{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:var(--calcite-tree-padding-y) 0}.node-container .checkmark,.node-container .bullet-point{opacity:0;-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;color:var(--calcite-ui-border-1)}.node-container:hover .checkmark,.node-container:hover .bullet-point,:host([selected]) .node-container:hover .checkmark,:host([selected]) .node-container:hover .bullet-point,:host(:focus) .node-container .checkmark,:host(:focus) .node-container .bullet-point{opacity:1}:host([selected])>.node-container,:host([selected])>.node-container:hover{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([selected])>.node-container .bullet-point,:host([selected])>.node-container .checkmark,:host([selected])>.node-container:hover .bullet-point,:host([selected])>.node-container:hover .checkmark{opacity:1;color:var(--calcite-ui-brand)}:host(:not([has-children])):host([scale=s])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.25rem;padding-inline-start:1.25rem}:host(:not([has-children])):host([scale=m])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.5rem;padding-inline-start:1.5rem}:host(:not([has-children])):host([scale=l])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.75rem;padding-inline-start:1.75rem}:host([has-children])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-margin-start:0;margin-inline-start:0}:host([has-children])>.node-container .bullet-point,:host([has-children])>.node-container .checkmark{display:none}:host([has-children][expanded]:not([selected]))>.node-container ::slotted(*){font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([has-children][selected])>.node-container[data-selection-mode=children],:host([has-children][selected])>.node-container[data-selection-mode=multi-children]{color:var(--calcite-ui-brand)}.chevron{position:relative;-ms-flex-item-align:center;align-self:center;color:var(--calcite-ui-text-3);-webkit-transition-property:all;transition-property:all;-webkit-transition-duration:var(--calcite-animation-timing);transition-duration:var(--calcite-animation-timing);-webkit-transition-timing-function:ease-in-out;transition-timing-function:ease-in-out;-webkit-transition-delay:0s;transition-delay:0s;-ms-flex:0 0 auto;flex:0 0 auto;-webkit-transform:rotate(0deg);transform:rotate(0deg)}.calcite--rtl .chevron{-webkit-transform:rotate(180deg);transform:rotate(180deg)}:host([expanded])>.node-container>.chevron{-webkit-transform:rotate(90deg);transform:rotate(90deg)}:host([selected]) .checkmark,:host([selected]) .bullet-point{color:var(--calcite-ui-brand)}';export{k as calcite_tree,b as calcite_tree_item}