@ni/nimble-components 8.0.0 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1323,19 +1323,11 @@ var ud
1323
1323
  !function(t){t.All="all",t.LeavesOnly="leaves-only",t.None="none"}(ud||(ud={}))
1324
1324
  class pd{constructor(t,e){this.cache=new WeakMap,this.ltr=t,this.rtl=e}bind(t){this.attach(t)}unbind(t){const e=this.cache.get(t)
1325
1325
  e&&Bo.unsubscribe(e)}attach(t){const e=this.cache.get(t)||new vd(this.ltr,this.rtl,t),s=Bo.getValueFor(t)
1326
- Bo.subscribe(e),e.attach(s),this.cache.set(t,e)}}class vd{constructor(t,e,s){this.ltr=t,this.rtl=e,this.source=s,this.attached=null}handleChange({target:t,token:e}){this.attach(e.getValueFor(t))}attach(t){this.attached!==this[t]&&(null!==this.attached&&this.source.$fastController.removeStyles(this.attached),this.attached=this[t],null!==this.attached&&this.source.$fastController.addStyles(this.attached))}}const gd=class extends ki{constructor(){super(),this.treeView=null,this.handleClickOverride=t=>{if(t.composedPath().includes(this.expandCollapseButton))return
1327
- const e=this.getImmediateTreeItem(t.target)
1328
- if(e?.disabled||e!==this)return void t.stopImmediatePropagation()
1329
- const s=this.treeView?.selectionMode===ud.LeavesOnly,i=this.treeView?.selectionMode===ud.All,o=this.hasChildTreeItems()
1330
- if(s&&!o||i){const t=this.getImmediateTreeItem(this.treeView?.currentSelected)
1331
- t&&this!==this.treeView?.currentSelected&&(t.selected=!1),this.selected=!0}else this.expanded=!this.expanded
1332
- t.stopImmediatePropagation()},this.handleSelectedChange=t=>{t.target===this&&this.selected&&this.setGroupSelectionOnRootParentTreeItem(this)},this.addEventListener("click",this.handleClickOverride)}connectedCallback(){super.connectedCallback(),this.addEventListener("selected-change",this.handleSelectedChange),this.treeView=this.getParentTreeView(),this.treeView&&this.selected&&this.setGroupSelectionOnRootParentTreeItem(this)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.handleClickOverride),this.removeEventListener("selected-change",this.handleSelectedChange),this.treeView=null}hasChildTreeItems(){return null!==this.querySelector('[role="treeitem"]')}clearTreeGroupSelection(){const t=this.treeView?.querySelectorAll("[group-selected]")
1326
+ Bo.subscribe(e),e.attach(s),this.cache.set(t,e)}}class vd{constructor(t,e,s){this.ltr=t,this.rtl=e,this.source=s,this.attached=null}handleChange({target:t,token:e}){this.attach(e.getValueFor(t))}attach(t){this.attached!==this[t]&&(null!==this.attached&&this.source.$fastController.removeStyles(this.attached),this.attached=this[t],null!==this.attached&&this.source.$fastController.addStyles(this.attached))}}const gd=class extends ki{constructor(){super(...arguments),this.treeView=null,this.handleSelectedChange=t=>{t.target===this&&this.selected&&this.setGroupSelectionOnRootParentTreeItem(this)}}connectedCallback(){super.connectedCallback(),this.addEventListener("selected-change",this.handleSelectedChange),this.treeView=this.getParentTreeView(),this.treeView&&this.selected&&this.setGroupSelectionOnRootParentTreeItem(this)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("selected-change",this.handleSelectedChange),this.treeView=null}clearTreeGroupSelection(){const t=this.treeView?.querySelectorAll("[group-selected]")
1333
1327
  t?.forEach((t=>t.removeAttribute(dd)))}setGroupSelectionOnRootParentTreeItem(t){this.clearTreeGroupSelection()
1334
1328
  let e=t
1335
1329
  for(;e?.parentElement!==this.treeView;)e=e?.parentElement
1336
- e&&e.setAttribute(dd,"true")}getImmediateTreeItem(t){let e=t
1337
- for(;e&&"treeitem"!==e?.getAttribute("role");)e=e?.parentElement
1338
- return e}getParentTreeView(){return this.parentElement.closest("[role='tree']")}}.compose({baseName:"tree-item",baseClass:ki,template:(t,e)=>{return Y`<template role="treeitem" slot="${t=>t.isNestedItem()?"item":void 0}" tabindex="-1" class="${t=>t.expanded?"expanded":""} ${t=>t.selected?"selected":""} ${t=>t.nested?"nested":""} ${t=>t.disabled?"disabled":""}" aria-expanded="${t=>t.childItems&&t.childItemLength()>0?t.expanded:void 0}" aria-selected="${t=>t.selected}" aria-disabled="${t=>t.disabled}" @focusin="${(t,e)=>t.handleFocus(e.event)}" @focusout="${(t,e)=>t.handleBlur(e.event)}" ${s={property:"childItems",filter:xt()},"string"==typeof s&&(s={property:s}),new k("fast-children",kt,s)}><div class="positioning-region" part="positioning-region"><div class="content-region" part="content-region">${wt((t=>t.childItems&&t.childItemLength()>0),Y`<div aria-hidden="true" class="expand-collapse-button" part="expand-collapse-button" @click="${(t,e)=>t.handleExpandCollapseButtonClick(e.event)}" ${bt("expandCollapseButton")}><slot name="expand-collapse-glyph">${e.expandCollapseGlyph||""}</slot></div>`)} ${It(0,e)}<slot></slot>${zt(0,e)}</div></div>${wt((t=>t.childItems&&t.childItemLength()>0&&(t.expanded||t.renderCollapsedChildren)),Y`<div role="group" class="items" part="items"><slot name="item" ${Ct("items")}></slot></div>`)}</template>`
1330
+ e&&e.setAttribute(dd,"true")}getParentTreeView(){return this.parentElement.closest("[role='tree']")}}.compose({baseName:"tree-item",baseClass:ki,template:(t,e)=>{return Y`<template role="treeitem" slot="${t=>t.isNestedItem()?"item":void 0}" tabindex="-1" class="${t=>t.expanded?"expanded":""} ${t=>t.selected?"selected":""} ${t=>t.nested?"nested":""} ${t=>t.disabled?"disabled":""}" aria-expanded="${t=>t.childItems&&t.childItemLength()>0?t.expanded:void 0}" aria-selected="${t=>t.selected}" aria-disabled="${t=>t.disabled}" @focusin="${(t,e)=>t.handleFocus(e.event)}" @focusout="${(t,e)=>t.handleBlur(e.event)}" ${s={property:"childItems",filter:xt()},"string"==typeof s&&(s={property:s}),new k("fast-children",kt,s)}><div class="positioning-region" part="positioning-region"><div class="content-region" part="content-region">${wt((t=>t.childItems&&t.childItemLength()>0),Y`<div aria-hidden="true" class="expand-collapse-button" part="expand-collapse-button" @click="${(t,e)=>t.handleExpandCollapseButtonClick(e.event)}" ${bt("expandCollapseButton")}><slot name="expand-collapse-glyph">${e.expandCollapseGlyph||""}</slot></div>`)} ${It(0,e)}<slot></slot>${zt(0,e)}</div></div>${wt((t=>t.childItems&&t.childItemLength()>0&&(t.expanded||t.renderCollapsedChildren)),Y`<div role="group" class="items" part="items"><slot name="item" ${Ct("items")}></slot></div>`)}</template>`
1339
1331
  var s},styles:(t,e)=>mt`
1340
1332
  ${ls("block")}
1341
1333
 
@@ -1361,7 +1353,13 @@ const md=mt`
1361
1353
  ${ls("flex")}
1362
1354
 
1363
1355
  :host{flex-direction:column;align-items:stretch;min-width:fit-content;font-size:0}:host(${xc}){outline:none}`
1364
- class fd extends _i{constructor(){super(...arguments),this.selectionMode=ud.All}}Ro([ot({attribute:"selection-mode"})],fd.prototype,"selectionMode",void 0)
1356
+ class fd extends _i{constructor(){super(...arguments),this.selectionMode=ud.All}handleClick(t){if(t.defaultPrevented)return!1
1357
+ if(!(t.target instanceof Element&&Ci(t.target)))return!0
1358
+ const e=t.target
1359
+ return!e.disabled&&(this.canSelect(e)?e.selected=!0:this.itemHasChildren(e)&&(e.expanded=!e.expanded),!0)}canSelect(t){switch(this.selectionMode){case ud.All:return!0
1360
+ case ud.None:return!1
1361
+ case ud.LeavesOnly:return!this.itemHasChildren(t)
1362
+ default:return!0}}itemHasChildren(t){return null!==t.querySelector('[role="treeitem"]')}}Ro([ot({attribute:"selection-mode"})],fd.prototype,"selectionMode",void 0)
1365
1363
  const bd=fd.compose({baseName:"tree-view",baseClass:_i,template:(t,e)=>Y`<template role="tree" ${bt("treeView")} @keydown="${(t,e)=>t.handleKeyDown(e.event)}" @focusin="${(t,e)=>t.handleFocus(e.event)}" @focusout="${(t,e)=>t.handleBlur(e.event)}" @click="${(t,e)=>t.handleClick(e.event)}" @selected-change="${(t,e)=>t.handleSelectedChange(e.event)}"><slot ${Ct("slottedTreeItems")}></slot></template>`,styles:md})
1366
1364
  Es.getOrCreate().withPrefix("nimble").register(bd())}()
1367
1365
  //# sourceMappingURL=all-components-bundle.min.js.map