@aceshooting/lyra-ui 31.1.1 → 31.2.0
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.
- package/CHANGELOG.md +20 -0
- package/dist/components/data/tree/tree-data-expansion.js +1 -0
- package/dist/components/data/tree/tree-item.class.d.ts +10 -4
- package/dist/components/data/tree/tree-item.class.js +5 -2
- package/dist/components/data/tree/tree-item.styles.js +1 -1
- package/dist/components/data/tree/tree-owner-controller.js +1 -1
- package/dist/components/data/tree/tree-pointer-reorder.js +1 -0
- package/dist/components/data/tree/tree-types.d.ts +5 -1
- package/dist/components/data/tree/tree.class.d.ts +27 -9
- package/dist/components/data/tree/tree.class.js +5 -3
- package/dist/components/data/tree/tree.styles.js +1 -1
- package/dist/components/forms/select/select.class.js +1 -1
- package/dist/events.d.ts +10 -1
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/sizes.styles.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/llms/components/lr-tree-item.md +1 -1
- package/llms/components/lr-tree.md +59 -7
- package/llms/peers.md +1 -1
- package/llms/shared/ai-and-peers.md +10 -1
- package/llms/shared.md +10 -1
- package/locales.json +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 31.2.0
|
|
4
|
+
|
|
5
|
+
The quick Chromium comparison of the feature candidate with 31.1.1 flagged five of 150 timing metrics as slower. For 1,000 chart points, total p95 rose from 93.7 to 114.8 ms; for 5,000 ingestion items, paint median rose from 23.2 to 27.9 ms; for sorting 10,000 table rows, settle p95 rose from 8.0 to 9.3 ms. A fixed A-B-B-A follow-up used 15 samples per workload per run. No metric was flagged in both candidate-versus-baseline pairs, and repeated runs of the same version also produced flags. The affected component implementations and dependencies were unchanged; their shared code differed only in package metadata and an unused size constant. Together, these observations point to timing variation without demonstrating a sustained slowdown.
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- fe6ba7d: Set initial branch expansion with `LyraTreeNodeData.expanded`. The tree remembers expansion by stable ID across data updates and collapsed ancestor remounts. Use `lr-bulk-toggle` to read which branches changed, including branches currently out of view.
|
|
10
|
+
- fe6ba7d: Enable `pointer-reorderable` to request a move before or after a visible tree row. Listen for `lr-pointer-reorder` to apply the move. Use `allow-cross-parent-reorder` to permit cross-parent moves and `canDrop` to validate drop candidates.
|
|
11
|
+
|
|
12
|
+
The tree additions and shared size/keyboard fixes increase the measured full registration bundle to 1,506,118 gzip bytes and the data bundle to 445,961 bytes. Only the ten exceeded entry limits advance to their next 64-byte boundary. Passing limits, initial-route budgets, optional-peer exclusions and the existing headroom policy remain unchanged.
|
|
13
|
+
- fe6ba7d: Set `size` on data and declarative trees to choose a row density. Use `--lr-tree-row-height` and `--lr-tree-toggle-size` to size rows and controls independently while preserving minimum pointer targets.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Keep lazy tree loading and its accessible busy state in one render, including after reconnect.
|
|
18
|
+
- fe6ba7d: Include document editor translations in full locale imports and expose a `docx-editor` family for applications that load editor messages separately.
|
|
19
|
+
- fe6ba7d: Consume printable select typeahead keys so choosing an option in WebKit cannot also replace a retained text selection in an editor.
|
|
20
|
+
- Updated dependencies [fe6ba7d]
|
|
21
|
+
- @aceshooting/lyra-translations@31.2.0
|
|
22
|
+
|
|
3
23
|
## 31.1.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TREE_MAX_RENDER_DEPTH}from"./tree-types.js";class TreeDataExpansion{constructor(isActive){this.isActive=isActive,this.entries=new Map}replace(roots){const next=new Map,stack=roots.map(item=>({item,depth:0})).reverse();for(;stack.length>0;){const{item,depth}=stack.pop(),previous=this.entries.get(item.id),children=item.children??[],loaded=children.length>0,branch=!item.disabled&&depth<TREE_MAX_RENDER_DEPTH&&(item.lazy===!0||loaded);let state="closed";branch&&(!previous||item.expanded!==void 0&&item.expanded!==previous.item.expanded?item.expanded&&(state=loaded?"open":"awaiting-children"):previous.state==="awaiting-children"?state=loaded?"open":"awaiting-children":loaded&&(state=previous.state)),next.set(item.id,{item,branch,state});for(let index=children.length-1;index>=0;index--)stack.push({item:children[index],depth:depth+1})}this.entries=next}entry(item){if(!this.isActive())return;const entry=this.entries.get(item.id);return entry?.item===item?entry:void 0}read(item){return this.entry(item)?.state}write(item,expanded){const entry=this.entry(item);entry?.branch&&(expanded?item.children?.length&&(entry.state="open"):entry.state="closed")}closeAll(changed,mounted){for(const[id,entry]of this.entries)entry.state==="open"&&!mounted.has(entry.item)&&changed.add(id),entry.state="closed"}}export{TreeDataExpansion};
|
|
@@ -58,6 +58,7 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement,type
|
|
|
58
58
|
* @csspart tree-item - The outer wrapper around the row and child group. It is the same node as
|
|
59
59
|
* `base`.
|
|
60
60
|
* @csspart row - The tree row.
|
|
61
|
+
* @csspart reorder-handle - Touch drag grip for pointer-reorderable trees.
|
|
61
62
|
* @csspart toggle - The expand/collapse button, with pointer hover/pressed feedback while enabled.
|
|
62
63
|
* @csspart icon - The optional decorative leading icon.
|
|
63
64
|
* @csspart content - The primary and secondary text wrapper.
|
|
@@ -100,6 +101,8 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement,type
|
|
|
100
101
|
* `--indent-size` (capped at `--lr-size-8rem`) to produce the row's `padding-inline-start`.
|
|
101
102
|
* @cssprop [--lr-tree-selected-bg=var(--lr-color-brand-quiet)] - Background of the selected row,
|
|
102
103
|
* and the base its hover/press mixes from.
|
|
104
|
+
* @cssprop --lr-tree-row-height - Minimum block size of the row. Taller content can grow the row.
|
|
105
|
+
* @cssprop --lr-tree-toggle-size - Size of the disclosure button, leaf placeholder and selection checkbox, subject to pointer hit-area minimums.
|
|
103
106
|
* @cssprop [--lr-tree-selected-color=var(--lr-color-brand)] - Text color of the selected row in every state; unset pointer states use on-quiet text.
|
|
104
107
|
* @cssprop [--lr-tree-checkbox-checked-border-color=var(--lr-color-brand)] - Checked control border, and
|
|
105
108
|
* the border under the pointer.
|
|
@@ -148,13 +151,16 @@ disabled:boolean;
|
|
|
148
151
|
* Whether this item is the current selection. Declarative markup can seed it with the reflected
|
|
149
152
|
* attribute; data objects seed it on assignment; an owning tree then maintains it directly.
|
|
150
153
|
*/
|
|
151
|
-
selected:boolean;
|
|
154
|
+
selected:boolean;private _expanded;
|
|
155
|
+
/** Whether this branch is open. A data tree remembers direct writes to its branch rows by id.
|
|
156
|
+
* @default false */
|
|
157
|
+
get expanded():boolean;set expanded(value:boolean);private setExpanded;
|
|
152
158
|
/** Enables asynchronous child loading. Expanding emits `lr-lazy-load` and waits for children.*/
|
|
153
159
|
lazy:boolean;private _loading;
|
|
154
160
|
/** Whether a lazy expansion is waiting for children.*/
|
|
155
161
|
get loading():boolean;
|
|
156
162
|
/** Whether only part of this branch is selected. Managed by the owning tree.*/
|
|
157
|
-
get indeterminate():boolean;private get ownerContext();private lifecycleGeneration;private lazyGeneration;private lifecycleTimer?;private lifecycleAnimation?;private _collapsing;private generatedId?;
|
|
163
|
+
get indeterminate():boolean;private get ownerContext();private lifecycleGeneration;private lazyGeneration;private expansionOwner?;private lifecycleTimer?;private lifecycleAnimation?;private _collapsing;private generatedId?;
|
|
158
164
|
/**
|
|
159
165
|
* This item's identity, in whichever child model is in use: `item.id` in the data model, or a
|
|
160
166
|
* generated, per-element id in the declarative one (where the markup carries no id of its own).
|
|
@@ -179,10 +185,10 @@ get nodeLabel():string;private syncItemAriaLabel;
|
|
|
179
185
|
*/
|
|
180
186
|
childItems():LyraTreeItem[];
|
|
181
187
|
/** Gets this node's direct child items, optionally excluding disabled children.*/
|
|
182
|
-
getChildrenItems({includeDisabled}?:{includeDisabled?:boolean;}):LyraTreeItem[];private isChildItem;private isDeclarativeLabelNode;private labelForwardingSlots;private get slottedLabelText();private declarativeLabelRoots;private declarativeLabelNodes;private get hasSlottedLabel();private assignChildSlots;private readonly labelTextObserver;private handleLabelSlotChange;private slottedLabel;private slottedChildren;private sampleLightDomState;connectedCallback():void;disconnectedCallback():void;private onOwnedFocus;adoptedCallback():void;private actualChildItems;get hasChildren():boolean;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;
|
|
188
|
+
getChildrenItems({includeDisabled}?:{includeDisabled?:boolean;}):LyraTreeItem[];private isChildItem;private isDeclarativeLabelNode;private labelForwardingSlots;private get slottedLabelText();private declarativeLabelRoots;private declarativeLabelNodes;private get hasSlottedLabel();private assignChildSlots;private readonly labelTextObserver;private handleLabelSlotChange;private slottedLabel;private slottedChildren;private sampleLightDomState;connectedCallback():void;disconnectedCallback():void;private onOwnedFocus;adoptedCallback():void;private actualChildItems;get hasChildren():boolean;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private syncDataExpansion;
|
|
183
189
|
/** Expand this node (no-op if already expanded, disabled, loading, or a leaf).*/
|
|
184
190
|
expand():void;private commitExpanded;private beginLazyLoad;private finishLazyLoad;private cancelLazyLoad;private scheduleAfterEvent;private cancelLifecycleTimer;private motionDuration;
|
|
185
|
-
/** Collapse this
|
|
191
|
+
/** Collapse this branch or cancel its pending lazy expansion.*/
|
|
186
192
|
collapse():void;
|
|
187
193
|
/**
|
|
188
194
|
* Fire this item's primary "select" action (Enter/Space, or clicking
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{deepActiveElementIn}from"../../../internal/active-element.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{tag}from"../../../internal/prefix.js";import{hasRealContent,isAccessibilityVisible,nextId}from"../../../internal/a11y.js";import{composedAccessibilityText}from"../../../internal/accessibility-visibility.js";import{chevronIcon}from"../../../internal/icons.js";import{parseCssTimeToken}from"../../../internal/css-motion-time.js";import{finiteDuration}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{cascadeUpdateComplete}from"./update-cascade.js";import{styles}from"./tree-item.styles.js";import{fromInteractiveDescendant,treeItemMotionPreference,treeItemOwnerContext}from"./tree-owner-controller.js";import{TREE_MAX_RENDER_DEPTH}from"./tree-types.js";const CHILDREN_SLOT="children",TREE_ITEM_EXPORT_PARTS=["base","tree-item","row","toggle","icon","content","label","description","badge","group","item","item--disabled","item--expanded","item--indeterminate","item--selected","indentation","expand-button","spinner","spinner__base","children","checkbox","checkbox__base","checkbox__control","checkbox__control--checked","checkbox__control--indeterminate","checkbox__checked-icon","checkbox__indeterminate-icon","checkbox__label"].join(", ");class LyraTreeItem extends LyraElement{constructor(){super(...arguments),this.itemInternals=attachInternalsSafely(this),this.managedItemAriaLabel=null,this.writingItemAriaLabel=!1,this.label="",this.disabled=!1,this.selected=!1,this.expanded=!1,this.lazy=!1,this._loading=!1,this.lifecycleGeneration=0,this.lazyGeneration=0,this._collapsing=!1,this.labelTextObserver=new AccessibleTextController(this,[],()=>{this.assignChildSlots(),this.requestUpdate(),this._loading&&this.actualChildItems().length>0&&this.finishLazyLoad(this.lazyGeneration)},["slot"]),this.handleLabelSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||target.getRootNode()!==this.renderRoot&&!this.labelForwardingSlots().includes(target)||(this.labelTextObserver.bind(),this.requestUpdate())},this.slottedLabel=!1,this.slottedChildren=!1,this.onOwnedFocus=event=>{event.composedPath()[0]===this&&deepActiveElementIn(this.ownerDocument)===this&&this.ownerContext.focusOwner?.(this)},this.onToggleMouseDown=e=>{e.preventDefault(),!this.isDisabled&&this.focus()},this.onTogglePointerDown=event=>{const toggle=event.currentTarget;toggle?.nodeType===1&&(toggle.setAttribute("data-pressed",""),toggle.setPointerCapture(event.pointerId))},this.onTogglePointerEnd=event=>{const toggle=event.currentTarget;toggle?.nodeType===1&&(toggle.removeAttribute("data-pressed"),toggle.hasPointerCapture(event.pointerId)&&toggle.releasePointerCapture(event.pointerId))},this.onRowClick=event=>{const row=event.currentTarget;fromInteractiveDescendant(event,target=>target===row)||this.select()}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-expand","lr-after-expand","lr-collapse","lr-after-collapse","lr-lazy-change","lr-lazy-load"])}static{this.identityEventDetailProperties=Object.freeze({"lr-expand":Object.freeze(["item"]),"lr-after-expand":Object.freeze(["item"]),"lr-collapse":Object.freeze(["item"]),"lr-after-collapse":Object.freeze(["item"]),"lr-lazy-change":Object.freeze(["item"]),"lr-lazy-load":Object.freeze(["item"])})}static{this.styles=[LyraElement.styles,styles]}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="aria-label"&&!this.writingItemAriaLabel&&(this.managedItemAriaLabel=null)}get item(){return this._item}set item(value){const old=this._item;if(old===value)return;this._item=value,this.labelTextObserver.setEnabled(!value),(value?.selected!==void 0||old?.id!==value?.id)&&(this.selected=!!value?.selected),this.lazy=!!value?.lazy;const hasResolvedChildren=!!value?.children?.length;this._loading&&(hasResolvedChildren||!this.lazy)&&this.finishLazyLoad(this.lazyGeneration,hasResolvedChildren),this.requestUpdate("item",old)}get loading(){return this._loading}get indeterminate(){return this.ownerContext.indeterminate}get ownerContext(){return treeItemOwnerContext(this)}get nodeId(){return this.item?this.item.id:this.generatedId??=nextId("tree-item")}get isDisabled(){return this.item?!!(this.item.disabled||this.hasDuplicateDataId):this.disabled}get hasDuplicateDataId(){const context=this.ownerContext.identity,item=this.item;return!!(context&&item&&context.collisionIds.has(item.id)&&context.ownerPaths.get(item.id)!==context.path)}get nodeLabel(){const ariaLabel=this.getAttribute("aria-label");return ariaLabel!==null?ariaLabel:this.item?this.item.accessibleLabel||this.item.label:this.slottedLabelText||this.label}syncItemAriaLabel(){const current=this.getAttribute("aria-label");if(this.managedItemAriaLabel===null&¤t!==null)return;const item=this.item;let next=item?.accessibleLabel||null;if(item&&!this.hasAttribute("aria-labelledby")&&!next?.trim()&&!item.label.trim()&&!item.description?.trim()&&!item.badges?.some(badge=>badge.label?.trim()||badge.text.trim())&&(next=item.id),next===null){if(this.managedItemAriaLabel!==null&¤t===this.managedItemAriaLabel){this.writingItemAriaLabel=!0;try{this.removeAttribute("aria-label")}finally{this.writingItemAriaLabel=!1}}this.managedItemAriaLabel=null;return}if(current!==next){this.writingItemAriaLabel=!0;try{this.setAttribute("aria-label",next)}finally{this.writingItemAriaLabel=!1}}this.managedItemAriaLabel=next}childItems(){return this.item?[...this.shadowRoot?.querySelectorAll(tag("tree-item"))??[]]:[...this.children].filter(child=>this.isChildItem(child))}getChildrenItems({includeDisabled=!0}={}){const children=this.childItems();return includeDisabled?children:children.filter(child=>!child.isDisabled)}isChildItem(node){return node.nodeType===1&&node.localName===tag("tree-item")}isDeclarativeLabelNode(node){if(this.isChildItem(node))return!1;if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName===null||slotName===""}labelForwardingSlots(){return Array.from(this.querySelectorAll("slot")).filter(slot=>{let top=slot;for(;top.parentNode&&top.parentNode!==this;)top=top.parentNode;return top.parentNode===this&&this.isDeclarativeLabelNode(top)})}get slottedLabelText(){return composedAccessibilityText(this.declarativeLabelRoots(),{requireRendered:!1,shouldPruneNode:node=>{if(this.contains(node))return!1;const target=node.nodeType===1?node:node.parentElement;return target===null||!isAccessibilityVisible(target)},skipRootAncestorValidation:!0}).replace(/\s+/g," ").trim()}declarativeLabelRoots(){const childNodes=this.childNodes;return childNodes?Array.from(childNodes).filter(node=>this.isDeclarativeLabelNode(node)):[]}declarativeLabelNodes(){const renderRoot=this.renderRoot;if(!renderRoot)return[];const slot=renderRoot.querySelector("slot:not([name])");return slot?slot.assignedNodes({flatten:!0}):this.declarativeLabelRoots().flatMap(node=>{if(node.nodeType!==1||node.localName!=="slot")return[node];const forwardingSlot=node;return forwardingSlot.assignedNodes().length>0?forwardingSlot.assignedNodes({flatten:!0}):Array.from(forwardingSlot.childNodes)})}get hasSlottedLabel(){return hasRealContent(this.declarativeLabelNodes())}assignChildSlots(){for(const child of this.children)this.isChildItem(child)&&child.getAttribute("slot")!==CHILDREN_SLOT&&child.setAttribute("slot",CHILDREN_SLOT)}sampleLightDomState(){this.slottedLabel=this.hasSlottedLabel,this.slottedChildren=!this.item&&this.hasChildren}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.sampleLightDomState(),this.addEventListener("slotchange",this.handleLabelSlotChange),this.addEventListener("focusin",this.onOwnedFocus)}disconnectedCallback(){this.removeEventListener("slotchange",this.handleLabelSlotChange),this.removeEventListener("focusin",this.onOwnedFocus),this.lifecycleGeneration++,this.lazyGeneration++,this.cancelLifecycleTimer(),this._loading=!1,this.lazy&&(this.expanded=!1),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}actualChildItems(){return this.childItems()}get hasChildren(){const context=this.ownerContext;return context.depth>=TREE_MAX_RENDER_DEPTH?!1:this.item?!!(this.lazy||this.item.children?.length&&!context.ancestry.includes(this.item)):this.lazy||this.childItems().length>0}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&changed.size>0&&[...changed.keys()].every(key=>key==="selected"||key==="expanded"||key==="disabled"||key==="_loading"||key==="_collapsing")&&this.labelTextObserver.preserveBindingForNextUpdate(),this.assignChildSlots(),this.hasUpdated?this.sampleLightDomState():this.seedFirstRenderState(()=>this.sampleLightDomState()),(changed.has("item")||changed.has("disabled"))&&this.isDisabled&&this.expanded&&(this.expanded=!1),(changed.has("item")||changed.has("disabled"))&&this.isDisabled&&this._loading&&this.cancelLazyLoad(!0),changed.has("lazy")&&this._loading&&!this.lazy&&this.finishLazyLoad(this.lazyGeneration,this.actualChildItems().length>0),this.setAttribute("role","treeitem");const context=this.ownerContext;this.setAttribute("aria-level",String(context.depth+1)),this.setAttribute("aria-setsize",String(context.setSize)),this.setAttribute("aria-posinset",String(context.posInSet)),this.hasChildren?this.setAttribute("aria-expanded",String(this.expanded)):this.removeAttribute("aria-expanded"),this.syncItemAriaLabel(),this.multipleSelection?(this.setAttribute("aria-checked",context.indeterminate?"mixed":String(this.selected)),this.removeAttribute("aria-selected")):(this.removeAttribute("aria-checked"),context.ownsSelection||!this.item||this.item.selected!==void 0?this.setAttribute("aria-selected",String(this.selected)):this.removeAttribute("aria-selected")),this.setAttribute("aria-disabled",String(this.isDisabled)),this._loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.tabIndex=!this.isDisabled&&this.nodeId===(context.activeNodeId?context.activeNodeId():context.activeId)?0:-1,setCustomState(this.itemInternals,"disabled",this.isDisabled),setCustomState(this.itemInternals,"expanded",this.expanded),setCustomState(this.itemInternals,"indeterminate",context.indeterminate),setCustomState(this.itemInternals,"selected",this.selected)}updated(changed){super.updated(changed),(changed.has("expanded")||changed.has("item"))&&this.ownerContext.syncOwner?.()}expand(){if(!(this.isDisabled||this._loading||this.expanded)){if(this.lazy){this.beginLazyLoad();return}this.hasChildren&&this.commitExpanded(!0)}}commitExpanded(expanded){this.expanded!==expanded&&(this.lifecycleGeneration++,this.cancelLifecycleTimer(),this._collapsing=!expanded,this.expanded=expanded,this.emit(expanded?"lr-expand":"lr-collapse",{item:this}),this.emit("lr-node-toggle",{nodeId:this.nodeId,expanded}),this.scheduleAfterEvent(expanded,this.lifecycleGeneration))}beginLazyLoad(){if(this._loading||this.isDisabled)return;this._loading=!0;const generation=++this.lazyGeneration;this.emit("lr-lazy-change",{item:this,loading:!0}),this.emit("lr-lazy-load",{item:this,generation})}finishLazyLoad(generation,hasResolvedChildren=this.actualChildItems().length>0){!this._loading||generation!==this.lazyGeneration||(this._loading=!1,this.emit("lr-lazy-change",{item:this,loading:!1}),!(!this.isConnected||this.isDisabled||!hasResolvedChildren)&&this.commitExpanded(!0))}cancelLazyLoad(emitChange){this._loading&&(this.lazyGeneration++,this._loading=!1,emitChange&&this.emit("lr-lazy-change",{item:this,loading:!1}))}scheduleAfterEvent(expanded,generation){const owner=this.ownerDocument.defaultView;if(!owner)return;const reducedMotion=treeItemMotionPreference(this);this.updateComplete.then(()=>{if(generation!==this.lifecycleGeneration||!this.isConnected||this.expanded!==expanded||this.ownerDocument.defaultView!==owner)return;const animationNode=this.renderRoot.querySelector('[part="children"]'),duration=this.motionDuration(expanded,owner,reducedMotion),finish=()=>{if(this.cancelLifecycleTimer(),!(generation!==this.lifecycleGeneration||!this.isConnected||this.expanded!==expanded||this.ownerDocument.defaultView!==owner)){if(!expanded&&this._collapsing){this._collapsing=!1,this.updateComplete.then(()=>{generation===this.lifecycleGeneration&&this.isConnected&&!this.expanded&&!this._collapsing&&this.ownerDocument.defaultView===owner&&this.emit("lr-after-collapse",{item:this})});return}this.emit("lr-after-expand",{item:this})}},computedAnimation=animationNode&&duration>0?owner.getComputedStyle(animationNode).animationName:"none";if(!animationNode||duration===0||computedAnimation==="none"){finish();return}const listener=event=>{event.target===animationNode&&finish()};animationNode.addEventListener("animationend",listener),this.lifecycleAnimation={node:animationNode,listener};const timer={owner,handle:0};timer.handle=owner.setTimeout(finish,duration),this.lifecycleTimer=timer})}cancelLifecycleTimer(){const animation=this.lifecycleAnimation;animation&&(this.lifecycleAnimation=void 0,animation.node.removeEventListener("animationend",animation.listener));const timer=this.lifecycleTimer;timer&&(this.lifecycleTimer=void 0,timer.owner.clearTimeout(timer.handle))}motionDuration(expanded,owner,reduced=prefersReducedMotion(this)){if(reduced)return 0;const property2=expanded?"--show-duration":"--hide-duration",ownStyle=owner.getComputedStyle(this),raw=ownStyle.getPropertyValue(property2).trim()||ownStyle.getPropertyValue("--lr-duration-base").trim();return finiteDuration(parseCssTimeToken(raw)?.ms??0,0)}collapse(){this.isDisabled||!this.hasChildren||!this.expanded||this.commitExpanded(!1)}select(){this.isDisabled||(this.emit("lr-node-select",{nodeId:this.nodeId}),this.focus())}click(){if(this.isDisabled)return;const row=this.renderRoot.querySelector('[part="row"]');row?row.click():this.select()}async getUpdateComplete(){const result=await super.getUpdateComplete(),context=this.ownerContext;return context.ownsSelection&&context.depth<TREE_MAX_RENDER_DEPTH&&await cascadeUpdateComplete(this.childItems()),result}get multipleSelection(){const selection=this.ownerContext.selection;return selection==="multiple"||selection==="leaf-multiple"}itemPartNames(){return["item",this.isDisabled?"item--disabled":"",this.expanded?"item--expanded":"",this.indeterminate?"item--indeterminate":"",this.selected?"item--selected":""].filter(Boolean).join(" ")}inheritedIcon(source){if(!source)return nothing;const clone=source.cloneNode(!0);return clone.removeAttribute("slot"),clone.removeAttribute("id"),clone.setAttribute("aria-hidden","true"),clone}renderDisclosureIcon(){const slotName=this.expanded?"expand-icon":"collapse-icon",context=this.ownerContext,inherited=this.inheritedIcon(this.expanded?context.expandIcon:context.collapseIcon);return html`<slot name=${slotName}>${inherited===nothing?chevronIcon():inherited}</slot>`}renderSpinner(){return html`<span part="spinner" aria-hidden="true"><span part="spinner__base"></span></span>`}renderCheckbox(){if(!this.multipleSelection)return nothing;const controlParts=["checkbox__control",this.selected?"checkbox__control--checked":"",this.indeterminate?"checkbox__control--indeterminate":""].filter(Boolean).join(" ");return html`
|
|
1
|
+
import{__decorate}from"tslib";import{deepActiveElementIn}from"../../../internal/active-element.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{tag}from"../../../internal/prefix.js";import{hasRealContent,isAccessibilityVisible,nextId}from"../../../internal/a11y.js";import{composedAccessibilityText}from"../../../internal/accessibility-visibility.js";import{chevronIcon}from"../../../internal/icons.js";import{parseCssTimeToken}from"../../../internal/css-motion-time.js";import{finiteDuration}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{cascadeUpdateComplete}from"./update-cascade.js";import{styles}from"./tree-item.styles.js";import{fromInteractiveDescendant,treeItemDataExpansion,treeItemMotionPreference,treeItemOwnerContext}from"./tree-owner-controller.js";import{TREE_MAX_RENDER_DEPTH}from"./tree-types.js";const CHILDREN_SLOT="children",TREE_ITEM_EXPORT_PARTS=["base","tree-item","row","toggle","icon","content","label","description","badge","group","item","item--disabled","item--expanded","item--indeterminate","item--selected","reorder-handle","indentation","expand-button","spinner","spinner__base","children","checkbox","checkbox__base","checkbox__control","checkbox__control--checked","checkbox__control--indeterminate","checkbox__checked-icon","checkbox__indeterminate-icon","checkbox__label"].join(", ");class LyraTreeItem extends LyraElement{constructor(){super(...arguments),this.itemInternals=attachInternalsSafely(this),this.managedItemAriaLabel=null,this.writingItemAriaLabel=!1,this.label="",this.disabled=!1,this.selected=!1,this._expanded=!1,this.lazy=!1,this._loading=!1,this.lifecycleGeneration=0,this.lazyGeneration=0,this._collapsing=!1,this.labelTextObserver=new AccessibleTextController(this,[],()=>{this.assignChildSlots(),this.requestUpdate(),this._loading&&this.actualChildItems().length>0&&this.finishLazyLoad(this.lazyGeneration)},["slot"]),this.handleLabelSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||target.getRootNode()!==this.renderRoot&&!this.labelForwardingSlots().includes(target)||(this.labelTextObserver.bind(),this.requestUpdate())},this.slottedLabel=!1,this.slottedChildren=!1,this.onOwnedFocus=event=>{event.composedPath()[0]===this&&deepActiveElementIn(this.ownerDocument)===this&&this.ownerContext.focusOwner?.(this)},this.onToggleMouseDown=e=>{e.preventDefault(),!this.isDisabled&&this.focus()},this.onTogglePointerDown=event=>{const toggle=event.currentTarget;toggle?.nodeType===1&&(toggle.setAttribute("data-pressed",""),toggle.setPointerCapture(event.pointerId))},this.onTogglePointerEnd=event=>{const toggle=event.currentTarget;toggle?.nodeType===1&&(toggle.removeAttribute("data-pressed"),toggle.hasPointerCapture(event.pointerId)&&toggle.releasePointerCapture(event.pointerId))},this.onRowClick=event=>{const row=event.currentTarget;fromInteractiveDescendant(event,target=>target===row)||this.select()}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-expand","lr-after-expand","lr-collapse","lr-after-collapse","lr-lazy-change","lr-lazy-load"])}static{this.identityEventDetailProperties=Object.freeze({"lr-expand":Object.freeze(["item"]),"lr-after-expand":Object.freeze(["item"]),"lr-collapse":Object.freeze(["item"]),"lr-after-collapse":Object.freeze(["item"]),"lr-lazy-change":Object.freeze(["item"]),"lr-lazy-load":Object.freeze(["item"])})}static{this.styles=[LyraElement.styles,styles]}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="aria-label"&&!this.writingItemAriaLabel&&(this.managedItemAriaLabel=null)}get item(){return this._item}set item(value){const old=this._item;if(old===value)return;this._item=value,this.labelTextObserver.setEnabled(!value),(value?.selected!==void 0||old?.id!==value?.id)&&(this.selected=!!value?.selected),this.lazy=!!value?.lazy;const hasResolvedChildren=!!value?.children?.length;this._loading&&(old?.id!==value?.id||this.isDisabled||value?.expanded===!1&&old?.expanded!==!1)&&this.cancelLazyLoad(!0),this._loading&&(hasResolvedChildren||!this.lazy)&&this.finishLazyLoad(this.lazyGeneration,hasResolvedChildren),this.requestUpdate("item",old)}get expanded(){return this._expanded}set expanded(value){this.setExpanded(value)&&this.isConnected&&this.item&&treeItemDataExpansion(this)?.write(this.item,value)}setExpanded(value){const previous=this._expanded;return previous===value?!1:(this._expanded=value,this.requestUpdate("expanded",previous),!0)}get loading(){return this._loading}get indeterminate(){return this.ownerContext.indeterminate}get ownerContext(){return treeItemOwnerContext(this)}get nodeId(){return this.item?this.item.id:this.generatedId??=nextId("tree-item")}get isDisabled(){return this.item?!!(this.item.disabled||this.hasDuplicateDataId):this.disabled}get hasDuplicateDataId(){const context=this.ownerContext.identity,item=this.item;return!!(context&&item&&context.collisionIds.has(item.id)&&context.ownerPaths.get(item.id)!==context.path)}get nodeLabel(){const ariaLabel=this.getAttribute("aria-label");return ariaLabel!==null?ariaLabel:this.item?this.item.accessibleLabel||this.item.label:this.slottedLabelText||this.label}syncItemAriaLabel(){const current=this.getAttribute("aria-label");if(this.managedItemAriaLabel===null&¤t!==null)return;const item=this.item;let next=item?.accessibleLabel||null;if(item&&!this.hasAttribute("aria-labelledby")&&!next?.trim()&&!item.label.trim()&&!item.description?.trim()&&!item.badges?.some(badge=>badge.label?.trim()||badge.text.trim())&&(next=item.id),next===null){if(this.managedItemAriaLabel!==null&¤t===this.managedItemAriaLabel){this.writingItemAriaLabel=!0;try{this.removeAttribute("aria-label")}finally{this.writingItemAriaLabel=!1}}this.managedItemAriaLabel=null;return}if(current!==next){this.writingItemAriaLabel=!0;try{this.setAttribute("aria-label",next)}finally{this.writingItemAriaLabel=!1}}this.managedItemAriaLabel=next}childItems(){return this.item?[...this.shadowRoot?.querySelectorAll(tag("tree-item"))??[]]:[...this.children].filter(child=>this.isChildItem(child))}getChildrenItems({includeDisabled=!0}={}){const children=this.childItems();return includeDisabled?children:children.filter(child=>!child.isDisabled)}isChildItem(node){return node.nodeType===1&&node.localName===tag("tree-item")}isDeclarativeLabelNode(node){if(this.isChildItem(node))return!1;if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName===null||slotName===""}labelForwardingSlots(){return Array.from(this.querySelectorAll("slot")).filter(slot=>{let top=slot;for(;top.parentNode&&top.parentNode!==this;)top=top.parentNode;return top.parentNode===this&&this.isDeclarativeLabelNode(top)})}get slottedLabelText(){return composedAccessibilityText(this.declarativeLabelRoots(),{requireRendered:!1,shouldPruneNode:node=>{if(this.contains(node))return!1;const target=node.nodeType===1?node:node.parentElement;return target===null||!isAccessibilityVisible(target)},skipRootAncestorValidation:!0}).replace(/\s+/g," ").trim()}declarativeLabelRoots(){const childNodes=this.childNodes;return childNodes?Array.from(childNodes).filter(node=>this.isDeclarativeLabelNode(node)):[]}declarativeLabelNodes(){const renderRoot=this.renderRoot;if(!renderRoot)return[];const slot=renderRoot.querySelector("slot:not([name])");return slot?slot.assignedNodes({flatten:!0}):this.declarativeLabelRoots().flatMap(node=>{if(node.nodeType!==1||node.localName!=="slot")return[node];const forwardingSlot=node;return forwardingSlot.assignedNodes().length>0?forwardingSlot.assignedNodes({flatten:!0}):Array.from(forwardingSlot.childNodes)})}get hasSlottedLabel(){return hasRealContent(this.declarativeLabelNodes())}assignChildSlots(){for(const child of this.children)this.isChildItem(child)&&child.getAttribute("slot")!==CHILDREN_SLOT&&child.setAttribute("slot",CHILDREN_SLOT)}sampleLightDomState(){this.slottedLabel=this.hasSlottedLabel,this.slottedChildren=!this.item&&this.hasChildren}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.sampleLightDomState(),this.item&&this.lazy&&this.requestUpdate(),this.addEventListener("slotchange",this.handleLabelSlotChange),this.addEventListener("focusin",this.onOwnedFocus)}disconnectedCallback(){this.removeEventListener("slotchange",this.handleLabelSlotChange),this.removeEventListener("focusin",this.onOwnedFocus),this.lifecycleGeneration++,this.lazyGeneration++,this.cancelLifecycleTimer(),this._loading=!1,this.lazy&&!this.expansionOwner&&this.setExpanded(!1),this._collapsing=!1,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}actualChildItems(){return this.childItems()}get hasChildren(){const context=this.ownerContext;return context.depth>=TREE_MAX_RENDER_DEPTH?!1:this.item?!!(this.lazy||this.item.children?.length&&!context.ancestry.includes(this.item)):this.lazy||this.childItems().length>0}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&changed.size>0&&[...changed.keys()].every(key=>key==="selected"||key==="expanded"||key==="disabled"||key==="_loading"||key==="_collapsing")&&this.labelTextObserver.preserveBindingForNextUpdate(),this.assignChildSlots(),this.hasUpdated?this.sampleLightDomState():this.seedFirstRenderState(()=>this.sampleLightDomState()),this.syncDataExpansion(changed),(changed.has("item")||changed.has("disabled"))&&this.isDisabled&&this.expanded&&(this.expanded=!1),(changed.has("item")||changed.has("disabled"))&&this.isDisabled&&this._loading&&this.cancelLazyLoad(!0),changed.has("lazy")&&this._loading&&!this.lazy&&this.finishLazyLoad(this.lazyGeneration,this.actualChildItems().length>0),this.isConnected&&this.item&&this.ownerContext.expansionVisible&&this.expansionOwner?.read(this.item)==="awaiting-children"&&this.expand(),this.setAttribute("role","treeitem");const context=this.ownerContext;this.setAttribute("aria-level",String(context.depth+1)),this.setAttribute("aria-setsize",String(context.setSize)),this.setAttribute("aria-posinset",String(context.posInSet)),this.hasChildren?this.setAttribute("aria-expanded",String(this.expanded)):this.removeAttribute("aria-expanded"),this.syncItemAriaLabel(),this.multipleSelection?(this.setAttribute("aria-checked",context.indeterminate?"mixed":String(this.selected)),this.removeAttribute("aria-selected")):(this.removeAttribute("aria-checked"),context.ownsSelection||!this.item||this.item.selected!==void 0?this.setAttribute("aria-selected",String(this.selected)):this.removeAttribute("aria-selected")),this.setAttribute("aria-disabled",String(this.isDisabled)),this._loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.tabIndex=!this.isDisabled&&this.nodeId===(context.activeNodeId?context.activeNodeId():context.activeId)?0:-1,setCustomState(this.itemInternals,"disabled",this.isDisabled),setCustomState(this.itemInternals,"expanded",this.expanded),setCustomState(this.itemInternals,"indeterminate",context.indeterminate),setCustomState(this.itemInternals,"selected",this.selected)}updated(changed){super.updated(changed),this.isConnected&&(changed.has("expanded")||changed.has("item"))&&this.ownerContext.syncOwner?.()}syncDataExpansion(changed){const item=this.item,owner=item?treeItemDataExpansion(this):void 0,ownerChanged=owner!==this.expansionOwner;if(this.expansionOwner=owner,!item||!owner||!changed.has("item")&&!ownerChanged)return;const state2=owner.read(item);state2!==void 0&&this.setExpanded(state2==="open")&&(this.lifecycleGeneration++,this.cancelLifecycleTimer(),this._collapsing=!1,this.expanded||this.ownerContext.syncOwner?.(this))}expand(){if(!(this.isDisabled||this._loading||this.expanded||!this.hasChildren)){if(this.lazy&&!this.item?.children?.length){this.beginLazyLoad();return}this.commitExpanded(!0)}}commitExpanded(expanded){this.expanded!==expanded&&(this.lifecycleGeneration++,this.cancelLifecycleTimer(),this._collapsing=!expanded,this.expanded=expanded,this.emit(expanded?"lr-expand":"lr-collapse",{item:this}),this.emit("lr-node-toggle",{nodeId:this.nodeId,expanded}),this.scheduleAfterEvent(expanded,this.lifecycleGeneration))}beginLazyLoad(){if(this._loading||this.isDisabled)return;this._loading=!0;const generation=++this.lazyGeneration;this.emit("lr-lazy-change",{item:this,loading:!0}),this._loading&&generation===this.lazyGeneration&&this.emit("lr-lazy-load",{item:this,generation})}finishLazyLoad(generation,hasResolvedChildren=this.actualChildItems().length>0){!this._loading||generation!==this.lazyGeneration||(this._loading=!1,this.emit("lr-lazy-change",{item:this,loading:!1}),!(!this.isConnected||this.isDisabled||generation!==this.lazyGeneration||!hasResolvedChildren)&&this.commitExpanded(!0))}cancelLazyLoad(emitChange){this.lazyGeneration++,this._loading&&(this._loading=!1,emitChange&&this.emit("lr-lazy-change",{item:this,loading:!1}))}scheduleAfterEvent(expanded,generation){const owner=this.ownerDocument.defaultView;if(!owner)return;const reducedMotion=treeItemMotionPreference(this);this.updateComplete.then(()=>{if(generation!==this.lifecycleGeneration||!this.isConnected||this.expanded!==expanded||this.ownerDocument.defaultView!==owner)return;const animationNode=this.renderRoot.querySelector('[part="children"]'),duration=this.motionDuration(expanded,owner,reducedMotion),finish=()=>{if(this.cancelLifecycleTimer(),!(generation!==this.lifecycleGeneration||!this.isConnected||this.expanded!==expanded||this.ownerDocument.defaultView!==owner)){if(!expanded&&this._collapsing){this._collapsing=!1,this.updateComplete.then(()=>{generation===this.lifecycleGeneration&&this.isConnected&&!this.expanded&&!this._collapsing&&this.ownerDocument.defaultView===owner&&this.emit("lr-after-collapse",{item:this})});return}this.emit("lr-after-expand",{item:this})}},computedAnimation=animationNode&&duration>0?owner.getComputedStyle(animationNode).animationName:"none";if(!animationNode||duration===0||computedAnimation==="none"){finish();return}const listener=event=>{event.target===animationNode&&finish()};animationNode.addEventListener("animationend",listener),this.lifecycleAnimation={node:animationNode,listener};const timer={owner,handle:0};timer.handle=owner.setTimeout(finish,duration),this.lifecycleTimer=timer})}cancelLifecycleTimer(){const animation=this.lifecycleAnimation;animation&&(this.lifecycleAnimation=void 0,animation.node.removeEventListener("animationend",animation.listener));const timer=this.lifecycleTimer;timer&&(this.lifecycleTimer=void 0,timer.owner.clearTimeout(timer.handle))}motionDuration(expanded,owner,reduced=prefersReducedMotion(this)){if(reduced)return 0;const property2=expanded?"--show-duration":"--hide-duration",ownStyle=owner.getComputedStyle(this),raw=ownStyle.getPropertyValue(property2).trim()||ownStyle.getPropertyValue("--lr-duration-base").trim();return finiteDuration(parseCssTimeToken(raw)?.ms??0,0)}collapse(){this.cancelLazyLoad(!0),this.item&&treeItemDataExpansion(this)?.write(this.item,!1),!(this.isDisabled||!this.hasChildren||!this.expanded)&&this.commitExpanded(!1)}select(){this.isDisabled||(this.emit("lr-node-select",{nodeId:this.nodeId}),this.focus())}click(){if(this.isDisabled)return;const row=this.renderRoot.querySelector('[part="row"]');row?row.click():this.select()}async getUpdateComplete(){const result=await super.getUpdateComplete(),context=this.ownerContext;return context.ownsSelection&&context.depth<TREE_MAX_RENDER_DEPTH&&await cascadeUpdateComplete(this.childItems()),result}get multipleSelection(){const selection=this.ownerContext.selection;return selection==="multiple"||selection==="leaf-multiple"}itemPartNames(){return["item",this.isDisabled?"item--disabled":"",this.expanded?"item--expanded":"",this.indeterminate?"item--indeterminate":"",this.selected?"item--selected":""].filter(Boolean).join(" ")}inheritedIcon(source){if(!source)return nothing;const clone=source.cloneNode(!0);return clone.removeAttribute("slot"),clone.removeAttribute("id"),clone.setAttribute("aria-hidden","true"),clone}renderDisclosureIcon(){const slotName=this.expanded?"expand-icon":"collapse-icon",context=this.ownerContext,inherited=this.inheritedIcon(this.expanded?context.expandIcon:context.collapseIcon);return html`<slot name=${slotName}>${inherited===nothing?chevronIcon():inherited}</slot>`}renderSpinner(){return html`<span part="spinner" aria-hidden="true"><span part="spinner__base"></span></span>`}renderCheckbox(){if(!this.multipleSelection)return nothing;const controlParts=["checkbox__control",this.selected?"checkbox__control--checked":"",this.indeterminate?"checkbox__control--indeterminate":""].filter(Boolean).join(" ");return html`
|
|
2
2
|
<span
|
|
3
3
|
part="checkbox"
|
|
4
4
|
aria-hidden="true"
|
|
@@ -14,7 +14,10 @@ import{__decorate}from"tslib";import{deepActiveElementIn}from"../../../internal/
|
|
|
14
14
|
`}renderRow(content){return html`
|
|
15
15
|
<div part="row" style=${`--lr-tree-depth:${this.ownerContext.depth}`} @click=${this.onRowClick}>
|
|
16
16
|
<span part="indentation" aria-hidden="true"></span>
|
|
17
|
+
${this.ownerContext.pointerReorderable&&!this.isDisabled?html`<span part="reorder-handle" aria-hidden="true">⠿</span>`:nothing}
|
|
17
18
|
<span part="expand-button">
|
|
19
|
+
<!-- hit-area-exempt: compact rows allow a 24px disclosure target and retain the
|
|
20
|
+
shared icon-button minimum when hover is unavailable or the pointer is coarse. -->
|
|
18
21
|
<button
|
|
19
22
|
part="toggle"
|
|
20
23
|
type="button"
|
|
@@ -66,4 +69,4 @@ import{__decorate}from"tslib";import{deepActiveElementIn}from"../../../internal/
|
|
|
66
69
|
${(this.expanded||this._collapsing)&&this.slottedChildren?html`<div part="group" role="group">
|
|
67
70
|
<div part="children" ?data-collapsing=${this._collapsing}><slot name=${CHILDREN_SLOT}></slot></div>
|
|
68
71
|
</div>`:nothing}
|
|
69
|
-
</div>`}keyedChildren(children){const occurrences=new Map;return children.map(child=>{const occurrence=occurrences.get(child.id)??0;return occurrences.set(child.id,occurrence+1),{child,key:`${child.id}\0${occurrence}`}})}}__decorate([property({attribute:!1})],LyraTreeItem.prototype,"item",null),__decorate([property()],LyraTreeItem.prototype,"label",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTreeItem.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTreeItem.prototype,"selected",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTreeItem.prototype,"expanded",
|
|
72
|
+
</div>`}keyedChildren(children){const occurrences=new Map;return children.map(child=>{const occurrence=occurrences.get(child.id)??0;return occurrences.set(child.id,occurrence+1),{child,key:`${child.id}\0${occurrence}`}})}}__decorate([property({attribute:!1})],LyraTreeItem.prototype,"item",null),__decorate([property()],LyraTreeItem.prototype,"label",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTreeItem.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTreeItem.prototype,"selected",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTreeItem.prototype,"expanded",null),__decorate([property({type:Boolean,reflect:!0})],LyraTreeItem.prototype,"lazy",void 0),__decorate([state()],LyraTreeItem.prototype,"_loading",void 0),__decorate([state()],LyraTreeItem.prototype,"_collapsing",void 0),__decorate([state()],LyraTreeItem.prototype,"slottedLabel",void 0),__decorate([state()],LyraTreeItem.prototype,"slottedChildren",void 0);export{LyraTreeItem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{iconHitTarget,focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: block; outline: none; } [part~='item'] { border-radius: var(--lr-radius); transition: background-color var(--lr-transition-fast); } :host(:focus-visible) [part='row'] { ${focusRing} } [part='row'] { position: relative; display: flex; align-items: center; gap: var(--lr-space-xs); padding: var(--lr-space-xs) var(--lr-space-s); padding-inline-start: calc( var(--lr-space-s) + min(var(--lr-tree-depth, 0) * var(--indent-size, var(--lr-space-l)), var(--lr-size-8rem)) ); cursor: pointer; border-radius: inherit; background: inherit; } :host([aria-selected='true']) [part~='item'] { color: var(--lr-tree-selected-color, var(--lr-color-brand)); background: var(--lr-tree-selected-bg, var(--lr-color-brand-quiet)); } [part~='item']:hover, :host(:where([aria-selected='true'])) [part~='item']:hover { background: color-mix(in oklab, var(--lr-tree-selected-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-hover)); } [part~='item']:active, :host(:where([aria-selected='true'])) [part~='item']:active { background: color-mix( in oklab, var(--lr-tree-selected-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } :host(:where([aria-selected='true'])) [part~='item']:is(:hover, :active) { color: var(--lr-tree-selected-color, var(--lr-color-brand-on-quiet)); } :host([aria-disabled='true']) [part~='item'] { opacity: var(--lr-opacity-disabled); } :host([aria-disabled='true']) [part='row'] { cursor: default; } :host([aria-disabled='true']) [part~='item']:hover { background: transparent; } :host([aria-disabled='true']) [part~='item']:active { background: transparent; } [part='toggle'] { font: inherit; inline-size: var(--lr-size-1-75rem); block-size: var(--lr-size-1-75rem); ${iconHitTarget} padding: var(--lr-space-xs); display: inline-flex; align-items: center; justify-content: center; border: none; background: none; color: var(--lr-color-text-quiet); cursor: pointer; flex: 0 0 auto; transition: background-color var(--lr-transition-fast); } :where([part='toggle']):hover:where(:not(:disabled)) { background: var(--lr-color-surface-hover, var(--lr-color-neutral-fill-quiet)); border-radius: var(--lr-radius); } :where([part='toggle']):active:where(:not(:disabled)) { background: color-mix( in oklab, var(--lr-color-surface-hover, var(--lr-color-neutral-fill-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } :where([part='toggle'])[data-pressed]:where(:not(:disabled)) { background: color-mix( in oklab, var(--lr-color-surface-hover, var(--lr-color-neutral-fill-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part='expand-button'] { display: inline-flex; flex: 0 0 auto; } [part='indentation'] { position: absolute; inset-block: var(--indent-guide-offset, 0); inset-inline-start: 0; box-sizing: border-box; inline-size: min(calc(var(--lr-tree-depth, 0) * var(--indent-size, var(--lr-space-l))), var(--lr-size-8rem)); border-inline-end-width: var(--indent-guide-width, 0); border-inline-end-style: var(--indent-guide-style, solid); border-inline-end-color: var(--indent-guide-color, var(--lr-color-border-subtle)); } [part='toggle']:disabled { cursor: default; } [part='toggle'][hidden] { visibility: hidden; } [part='spinner'] { display: inline-flex; align-items: center; justify-content: center; } [part='spinner__base'] { box-sizing: border-box; inline-size: var(--lr-size-1rem); block-size: var(--lr-size-1rem); border: var(--lr-border-width-medium) solid var(--lr-color-border); border-block-start-color: var(--lr-color-brand); border-radius: 50%; animation: var(--_lr-motion-animation, lr-tree-spin var(--lr-duration-ambient) linear infinite); } [part='checkbox'] { display: inline-flex; align-items: center; justify-content: center; ${iconHitTarget} cursor: pointer; flex: 0 0 auto; } [part='checkbox']:hover [part~='checkbox__control'] { border-color: var(--lr-color-brand); } [part='checkbox']:active [part~='checkbox__control'] { border-color: color-mix(in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active)); } [part='checkbox']:hover [part~='checkbox__control--checked'] { border-color: var(--lr-tree-checkbox-checked-border-color, var(--lr-color-brand)); } [part='checkbox']:hover [part~='checkbox__control--indeterminate'] { border-color: var(--lr-tree-checkbox-indeterminate-border-color, var(--lr-color-brand)); } [part='checkbox']:active [part~='checkbox__control--checked'] { border-color: color-mix(in oklab, var(--lr-tree-checkbox-checked-border-color, var(--lr-color-brand)), var(--lr-color-mix-partner) var(--lr-color-mix-active)); } [part='checkbox']:active [part~='checkbox__control--indeterminate'] { border-color: color-mix(in oklab, var(--lr-tree-checkbox-indeterminate-border-color, var(--lr-color-brand)), var(--lr-color-mix-partner) var(--lr-color-mix-active)); } :host([aria-disabled='true']) [part='checkbox'] { cursor: default; } :host([aria-disabled='true']) [part='checkbox']:hover [part~='checkbox__control'] { border-color: var(--lr-color-border); } :host([aria-disabled='true']) [part='checkbox']:active [part~='checkbox__control'] { border-color: var(--lr-color-border); } [part='checkbox__base'] { display: inline-flex; } [part~='checkbox__control'] { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; inline-size: var(--lr-size-1rem); block-size: var(--lr-size-1rem); border: var(--lr-border-width-thin) solid var(--lr-color-border); border-radius: var(--lr-radius-xs); color: var(--lr-color-on-brand); background: var(--lr-color-surface); } [part~='checkbox__control--checked'] { border-color: var(--lr-tree-checkbox-checked-border-color, var(--lr-color-brand)); background: var(--lr-tree-checkbox-checked-bg, var(--lr-color-brand)); color: var(--lr-tree-checkbox-checked-color, var(--lr-color-on-brand)); } [part~='checkbox__control--indeterminate'] { border-color: var(--lr-tree-checkbox-indeterminate-border-color, var(--lr-color-brand)); background: var(--lr-tree-checkbox-indeterminate-bg, var(--lr-color-brand)); color: var(--lr-tree-checkbox-indeterminate-color, var(--lr-color-on-brand)); } [part='checkbox__checked-icon'], [part='checkbox__indeterminate-icon'] { display: none; line-height: var(--lr-line-height-compact); } [part~='checkbox__control--checked'] [part='checkbox__checked-icon'] { display: inline; } [part~='checkbox__control--indeterminate'] [part='checkbox__checked-icon'] { display: none; } [part~='checkbox__control--indeterminate'] [part='checkbox__indeterminate-icon'] { display: inline; } [part='checkbox__label'] { display: contents; } :host([expanded]) [part='toggle'] { transform: rotate(90deg); } :host(:dir(rtl)) [part='toggle'] { transform: rotate(180deg); } :host([expanded]:dir(rtl)) [part='toggle'] { transform: rotate(90deg); } [part='label'] { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } [part='icon'] { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; color: var(--lr-color-text-quiet); } [part='content'] { display: flex; flex: 1 1 auto; flex-direction: column; min-inline-size: 0; } [part='description'] { min-inline-size: 0; color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-xs); line-height: var(--lr-line-height-compact); overflow-wrap: anywhere; } [part='badge'] { flex: 0 0 auto; font-size: var(--lr-font-size-xs); color: var(--lr-color-text); background: var(--lr-color-border); border-radius: var(--lr-radius); padding: 0 var(--lr-space-xs); } [part='badge'] + [part='badge'] { margin-inline-start: var(--lr-space-xs); } [part='badge'][data-tone='neutral'] { color: var(--lr-tree-badge-neutral-color, var(--lr-color-text-quiet)); background: var(--lr-tree-badge-neutral-bg, var(--lr-color-surface)); } [part='badge'][data-tone='brand'] { color: var(--lr-tree-badge-brand-color, var(--lr-color-brand)); background: var(--lr-tree-badge-brand-bg, var(--lr-color-brand-quiet)); } [part='badge'][data-tone='success'] { color: var(--lr-tree-badge-success-color, var(--lr-color-success)); background: var(--lr-tree-badge-success-bg, var(--lr-color-success-quiet)); } [part='badge'][data-tone='warning'] { color: var(--lr-tree-badge-warning-color, var(--lr-color-warning)); background: var(--lr-tree-badge-warning-bg, var(--lr-color-warning-quiet)); } [part='badge'][data-tone='danger'] { color: var(--lr-tree-badge-danger-color, var(--lr-color-danger)); background: var(--lr-tree-badge-danger-bg, var(--lr-color-danger-quiet)); } [part='children'] { animation-duration: var(--_lr-motion-duration, var(--show-duration, var(--lr-duration-base))); animation-timing-function: var(--lr-easing-standard); } :host([expanded]) [part='children'] { animation-name: var(--_lr-motion-animation, lr-tree-show); } [part='children'][data-collapsing] { animation-name: var(--_lr-motion-animation, lr-tree-hide); animation-duration: var(--_lr-motion-duration, var(--hide-duration, var(--lr-duration-base))); } @keyframes lr-tree-show { from { opacity: 0; } to { opacity: 1; } } @keyframes lr-tree-hide { from { opacity: 1; } to { opacity: 0; } } @keyframes lr-tree-spin { to { transform: rotate(1turn); } } @media (prefers-reduced-motion: reduce) { [part='children'], [part='spinner__base'] { animation: none; } } `;export{styles};
|
|
1
|
+
import{minimumPointerTarget}from"../../../internal/sizes.styles.js";import{focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: block; outline: none; --_lr-tree-toggle-min: ${minimumPointerTarget}; --_lr-tree-requested-toggle-size: var(--lr-tree-toggle-size, var(--_lr-tree-tier-toggle-size)); } @media (hover: none), (pointer: coarse) { :host { --_lr-tree-toggle-min: max(${minimumPointerTarget}, var(--lr-icon-button-size)); } } [part~='item'] { border-radius: var(--lr-radius); transition: background-color var(--lr-transition-fast); } :host(:focus-visible) [part='row'] { ${focusRing} } [part='row'] { position: relative; display: flex; align-items: center; gap: var(--lr-space-xs); min-block-size: max(${minimumPointerTarget}, var(--lr-tree-row-height, var(--_lr-tree-tier-row-height, ${minimumPointerTarget}))); padding-block: var(--_lr-tree-tier-row-padding, var(--lr-space-xs)); padding-inline: var(--lr-space-s); padding-inline-start: calc( var(--lr-space-s) + min(var(--lr-tree-depth, 0) * var(--indent-size, var(--lr-space-l)), var(--lr-size-8rem)) ); cursor: pointer; border-radius: inherit; background: inherit; } :host([aria-selected='true']) [part~='item'] { color: var(--lr-tree-selected-color, var(--lr-color-brand)); background: var(--lr-tree-selected-bg, var(--lr-color-brand-quiet)); } [part~='item']:hover, :host(:where([aria-selected='true'])) [part~='item']:hover { background: color-mix(in oklab, var(--lr-tree-selected-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-hover)); } [part~='item']:active, :host(:where([aria-selected='true'])) [part~='item']:active { background: color-mix( in oklab, var(--lr-tree-selected-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } :host(:where([aria-selected='true'])) [part~='item']:is(:hover, :active) { color: var(--lr-tree-selected-color, var(--lr-color-brand-on-quiet)); } :host([aria-disabled='true']) [part~='item'] { opacity: var(--lr-opacity-disabled); } :host([aria-disabled='true']) [part='row'] { cursor: default; } :host([aria-disabled='true']) [part~='item']:hover { background: transparent; } :host([aria-disabled='true']) [part~='item']:active { background: transparent; } [part='toggle'], [part='checkbox'] { inline-size: var(--_lr-tree-toggle-min); block-size: var(--_lr-tree-toggle-min); } [part='toggle'] { font: inherit; min-inline-size: var(--_lr-tree-requested-toggle-size, max(var(--lr-size-1-75rem), var(--lr-icon-button-size))); min-block-size: var(--_lr-tree-requested-toggle-size, max(var(--lr-size-1-75rem), var(--lr-icon-button-size))); padding: var(--lr-space-xs); display: inline-flex; align-items: center; justify-content: center; border: none; background: none; color: var(--lr-color-text-quiet); cursor: pointer; flex: 0 0 auto; transition: background-color var(--lr-transition-fast); } :where([part='toggle']):hover:where(:not(:disabled)) { background: var(--lr-color-surface-hover, var(--lr-color-neutral-fill-quiet)); border-radius: var(--lr-radius); } :where([part='toggle']):active:where(:not(:disabled)) { background: color-mix( in oklab, var(--lr-color-surface-hover, var(--lr-color-neutral-fill-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } :where([part='toggle'])[data-pressed]:where(:not(:disabled)) { background: color-mix( in oklab, var(--lr-color-surface-hover, var(--lr-color-neutral-fill-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part='reorder-handle'] { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-inline-size: var(--_lr-tree-toggle-min); min-block-size: var(--_lr-tree-toggle-min); align-self: stretch; cursor: grab; touch-action: none; user-select: none; color: var(--lr-color-text-quiet); } [part='reorder-handle']:where(:hover, :active) { color: var(--lr-color-text); } [part='reorder-handle']:where(:active) { cursor: grabbing; } [part='expand-button'] { display: inline-flex; flex: 0 0 auto; } [part='indentation'] { position: absolute; inset-block: var(--indent-guide-offset, 0); inset-inline-start: 0; box-sizing: border-box; inline-size: min(calc(var(--lr-tree-depth, 0) * var(--indent-size, var(--lr-space-l))), var(--lr-size-8rem)); border-inline-end-width: var(--indent-guide-width, 0); border-inline-end-style: var(--indent-guide-style, solid); border-inline-end-color: var(--indent-guide-color, var(--lr-color-border-subtle)); } [part='toggle']:disabled { cursor: default; } [part='toggle'][hidden] { visibility: hidden; } [part='spinner'] { display: inline-flex; align-items: center; justify-content: center; } [part='spinner__base'] { box-sizing: border-box; inline-size: var(--lr-size-1rem); block-size: var(--lr-size-1rem); border: var(--lr-border-width-medium) solid var(--lr-color-border); border-block-start-color: var(--lr-color-brand); border-radius: 50%; animation: var(--_lr-motion-animation, lr-tree-spin var(--lr-duration-ambient) linear infinite); } [part='checkbox'] { min-inline-size: var(--_lr-tree-requested-toggle-size, var(--lr-icon-button-size)); min-block-size: var(--_lr-tree-requested-toggle-size, var(--lr-icon-button-size)); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; } [part='checkbox']:hover [part~='checkbox__control'] { border-color: var(--lr-color-brand); } [part='checkbox']:active [part~='checkbox__control'] { border-color: color-mix(in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active)); } [part='checkbox']:hover [part~='checkbox__control--checked'] { border-color: var(--lr-tree-checkbox-checked-border-color, var(--lr-color-brand)); } [part='checkbox']:hover [part~='checkbox__control--indeterminate'] { border-color: var(--lr-tree-checkbox-indeterminate-border-color, var(--lr-color-brand)); } [part='checkbox']:active [part~='checkbox__control--checked'] { border-color: color-mix(in oklab, var(--lr-tree-checkbox-checked-border-color, var(--lr-color-brand)), var(--lr-color-mix-partner) var(--lr-color-mix-active)); } [part='checkbox']:active [part~='checkbox__control--indeterminate'] { border-color: color-mix(in oklab, var(--lr-tree-checkbox-indeterminate-border-color, var(--lr-color-brand)), var(--lr-color-mix-partner) var(--lr-color-mix-active)); } :host([aria-disabled='true']) [part='checkbox'] { cursor: default; } :host([aria-disabled='true']) [part='checkbox']:hover [part~='checkbox__control'] { border-color: var(--lr-color-border); } :host([aria-disabled='true']) [part='checkbox']:active [part~='checkbox__control'] { border-color: var(--lr-color-border); } [part='checkbox__base'] { display: inline-flex; } [part~='checkbox__control'] { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; inline-size: var(--lr-size-1rem); block-size: var(--lr-size-1rem); border: var(--lr-border-width-thin) solid var(--lr-color-border); border-radius: var(--lr-radius-xs); color: var(--lr-color-on-brand); background: var(--lr-color-surface); } [part~='checkbox__control--checked'] { border-color: var(--lr-tree-checkbox-checked-border-color, var(--lr-color-brand)); background: var(--lr-tree-checkbox-checked-bg, var(--lr-color-brand)); color: var(--lr-tree-checkbox-checked-color, var(--lr-color-on-brand)); } [part~='checkbox__control--indeterminate'] { border-color: var(--lr-tree-checkbox-indeterminate-border-color, var(--lr-color-brand)); background: var(--lr-tree-checkbox-indeterminate-bg, var(--lr-color-brand)); color: var(--lr-tree-checkbox-indeterminate-color, var(--lr-color-on-brand)); } [part='checkbox__checked-icon'], [part='checkbox__indeterminate-icon'] { display: none; line-height: var(--lr-line-height-compact); } [part~='checkbox__control--checked'] [part='checkbox__checked-icon'] { display: inline; } [part~='checkbox__control--indeterminate'] [part='checkbox__checked-icon'] { display: none; } [part~='checkbox__control--indeterminate'] [part='checkbox__indeterminate-icon'] { display: inline; } [part='checkbox__label'] { display: contents; } :host([expanded]) [part='toggle'] { transform: rotate(90deg); } :host(:dir(rtl)) [part='toggle'] { transform: rotate(180deg); } :host([expanded]:dir(rtl)) [part='toggle'] { transform: rotate(90deg); } [part='label'] { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } [part='icon'] { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; color: var(--lr-color-text-quiet); } [part='content'] { display: flex; flex: 1 1 auto; flex-direction: column; min-inline-size: 0; } [part='description'] { min-inline-size: 0; color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-xs); line-height: var(--lr-line-height-compact); overflow-wrap: anywhere; } [part='badge'] { flex: 0 0 auto; font-size: var(--lr-font-size-xs); color: var(--lr-color-text); background: var(--lr-color-border); border-radius: var(--lr-radius); padding: 0 var(--lr-space-xs); } [part='badge'] + [part='badge'] { margin-inline-start: var(--lr-space-xs); } [part='badge'][data-tone='neutral'] { color: var(--lr-tree-badge-neutral-color, var(--lr-color-text-quiet)); background: var(--lr-tree-badge-neutral-bg, var(--lr-color-surface)); } [part='badge'][data-tone='brand'] { color: var(--lr-tree-badge-brand-color, var(--lr-color-brand)); background: var(--lr-tree-badge-brand-bg, var(--lr-color-brand-quiet)); } [part='badge'][data-tone='success'] { color: var(--lr-tree-badge-success-color, var(--lr-color-success)); background: var(--lr-tree-badge-success-bg, var(--lr-color-success-quiet)); } [part='badge'][data-tone='warning'] { color: var(--lr-tree-badge-warning-color, var(--lr-color-warning)); background: var(--lr-tree-badge-warning-bg, var(--lr-color-warning-quiet)); } [part='badge'][data-tone='danger'] { color: var(--lr-tree-badge-danger-color, var(--lr-color-danger)); background: var(--lr-tree-badge-danger-bg, var(--lr-color-danger-quiet)); } [part='children'] { animation-duration: var(--_lr-motion-duration, var(--show-duration, var(--lr-duration-base))); animation-timing-function: var(--lr-easing-standard); } :host([expanded]) [part='children'] { animation-name: var(--_lr-motion-animation, lr-tree-show); } [part='children'][data-collapsing] { animation-name: var(--_lr-motion-animation, lr-tree-hide); animation-duration: var(--_lr-motion-duration, var(--hide-duration, var(--lr-duration-base))); } @keyframes lr-tree-show { from { opacity: 0; } to { opacity: 1; } } @keyframes lr-tree-hide { from { opacity: 1; } to { opacity: 0; } } @keyframes lr-tree-spin { to { transform: rotate(1turn); } } @media (prefers-reduced-motion: reduce) { [part='children'], [part='spinner__base'] { animation: none; } } `;export{styles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{finiteInteger}from"../../../internal/numbers.js";const DEFAULT_CONTEXT=Object.freeze({activeId:null,ancestry:Object.freeze([]),depth:0,setSize:1,posInSet:1,selection:"single",ownsSelection:!1,expandIcon:null,collapseIcon:null,indeterminate:!1}),contexts=new WeakMap;function treeItemOwnerContext(owner){return contexts.get(owner)??DEFAULT_CONTEXT}function sameAncestry(left,right){return left.length===right.length&&left.every((item,index)=>item===right[index])}function sameIdentity(left,right){return left?.path===right?.path&&left?.ownerPaths===right?.ownerPaths&&left?.collisionIds===right?.collisionIds&&left?.declaredChildrenAtPath===right?.declaredChildrenAtPath}function configureTreeItemOwner(owner,next){const previous=treeItemOwnerContext(owner),normalized=Object.freeze({...next,ancestry:Object.freeze([...next.ancestry]),depth:finiteInteger(next.depth,0,0),setSize:next.setSize===-1?-1:finiteInteger(next.setSize,1,1),posInSet:finiteInteger(next.posInSet,1,1),indeterminate:next.indeterminate??previous.indeterminate});previous.activeId===normalized.activeId&&previous.activeNodeId===normalized.activeNodeId&&sameAncestry(previous.ancestry,normalized.ancestry)&&previous.depth===normalized.depth&&previous.setSize===normalized.setSize&&previous.posInSet===normalized.posInSet&&previous.selection===normalized.selection&&previous.ownsSelection===normalized.ownsSelection&&sameIdentity(previous.identity,normalized.identity)&&previous.expandIcon===normalized.expandIcon&&previous.collapseIcon===normalized.collapseIcon&&previous.indeterminate===normalized.indeterminate&&previous.syncOwner===normalized.syncOwner&&previous.focusOwner===normalized.focusOwner||(contexts.set(owner,normalized),owner.requestUpdate())}function setTreeItemSelection(owner,selected,indeterminate){const previous=treeItemOwnerContext(owner),nextIndeterminate=!!indeterminate,contextChanged=!previous.ownsSelection||previous.indeterminate!==nextIndeterminate;contextChanged&&contexts.set(owner,Object.freeze({...previous,ownsSelection:!0,indeterminate:nextIndeterminate})),owner.selected!==!!selected?owner.selected=!!selected:contextChanged&&owner.requestUpdate()}const INTERACTIVE_DESCENDANT_SELECTOR='button, a[href], input, select, textarea, summary, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"]), [role="button"], [role="checkbox"], [role="combobox"], [role="listbox"], [role="menu"], [role="menuitem"], [role="option"], [role="radio"], [role="separator"], [role="slider"], [role="spinbutton"], [role="switch"], [role="tab"], [role="textbox"]';function fromInteractiveDescendant(event,isBoundary){for(const target of event.composedPath()){if(isBoundary(target))return!1;const element=target;if(element.nodeType===1&&typeof element.matches=="function"&&element.matches(INTERACTIVE_DESCENDANT_SELECTOR))return!0}return!1}const bulkMotionPreferences=new WeakMap;function withTreeItemMotionPreference(owner,reduced,expand){bulkMotionPreferences.set(owner,reduced);try{expand()}finally{bulkMotionPreferences.delete(owner)}}function treeItemMotionPreference(owner){return bulkMotionPreferences.get(owner)}export{configureTreeItemOwner,fromInteractiveDescendant,setTreeItemSelection,treeItemMotionPreference,treeItemOwnerContext,withTreeItemMotionPreference};
|
|
1
|
+
import{tag}from"../../../internal/prefix.js";import{finiteInteger}from"../../../internal/numbers.js";const DEFAULT_CONTEXT=Object.freeze({activeId:null,ancestry:Object.freeze([]),depth:0,setSize:1,posInSet:1,selection:"single",ownsSelection:!1,expandIcon:null,collapseIcon:null,indeterminate:!1}),contexts=new WeakMap;function treeItemOwnerContext(owner){return contexts.get(owner)??DEFAULT_CONTEXT}function treeItemDataExpansion(owner){let item=owner;for(;;){const context=contexts.get(item);if(context)return context.dataExpansion;const root=item.getRootNode?.();if(root?.host?.localName!==tag("tree-item"))return;item=root.host}}function sameAncestry(left,right){return left.length===right.length&&left.every((item,index)=>item===right[index])}function sameIdentity(left,right){return left?.path===right?.path&&left?.ownerPaths===right?.ownerPaths&&left?.collisionIds===right?.collisionIds&&left?.declaredChildrenAtPath===right?.declaredChildrenAtPath}function configureTreeItemOwner(owner,next){const previous=treeItemOwnerContext(owner),normalized=Object.freeze({...next,ancestry:Object.freeze([...next.ancestry]),depth:finiteInteger(next.depth,0,0),setSize:next.setSize===-1?-1:finiteInteger(next.setSize,1,1),posInSet:finiteInteger(next.posInSet,1,1),indeterminate:next.indeterminate??previous.indeterminate});previous.pointerReorderable===normalized.pointerReorderable&&previous.activeId===normalized.activeId&&previous.activeNodeId===normalized.activeNodeId&&sameAncestry(previous.ancestry,normalized.ancestry)&&previous.depth===normalized.depth&&previous.setSize===normalized.setSize&&previous.posInSet===normalized.posInSet&&previous.selection===normalized.selection&&previous.ownsSelection===normalized.ownsSelection&&previous.dataExpansion===normalized.dataExpansion&&previous.expansionVisible===normalized.expansionVisible&&sameIdentity(previous.identity,normalized.identity)&&previous.expandIcon===normalized.expandIcon&&previous.collapseIcon===normalized.collapseIcon&&previous.indeterminate===normalized.indeterminate&&previous.syncOwner===normalized.syncOwner&&previous.focusOwner===normalized.focusOwner||(contexts.set(owner,normalized),owner.requestUpdate())}function setTreeItemSelection(owner,selected,indeterminate){const previous=treeItemOwnerContext(owner),nextIndeterminate=!!indeterminate,contextChanged=!previous.ownsSelection||previous.indeterminate!==nextIndeterminate;contextChanged&&contexts.set(owner,Object.freeze({...previous,ownsSelection:!0,indeterminate:nextIndeterminate})),owner.selected!==!!selected?owner.selected=!!selected:contextChanged&&owner.requestUpdate()}const INTERACTIVE_DESCENDANT_SELECTOR='button, a[href], input, select, textarea, summary, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"]), [role="button"], [role="checkbox"], [role="combobox"], [role="listbox"], [role="menu"], [role="menuitem"], [role="option"], [role="radio"], [role="separator"], [role="slider"], [role="spinbutton"], [role="switch"], [role="tab"], [role="textbox"]';function fromInteractiveDescendant(event,isBoundary){for(const target of event.composedPath()){if(isBoundary(target))return!1;const element=target;if(element.nodeType===1&&typeof element.matches=="function"&&element.matches(INTERACTIVE_DESCENDANT_SELECTOR))return!0}return!1}const bulkMotionPreferences=new WeakMap;function withTreeItemMotionPreference(owner,reduced,expand){bulkMotionPreferences.set(owner,reduced);try{expand()}finally{bulkMotionPreferences.delete(owner)}}function treeItemMotionPreference(owner){return bulkMotionPreferences.get(owner)}export{configureTreeItemOwner,fromInteractiveDescendant,setTreeItemSelection,treeItemDataExpansion,treeItemMotionPreference,treeItemOwnerContext,withTreeItemMotionPreference};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{composedContains,flattenedParentElement}from"../../../internal/composed-tree.js";import{tag}from"../../../internal/prefix.js";import{fromInteractiveDescendant}from"./tree-owner-controller.js";function sameCandidate(previous,next){if(!previous||!next||previous.row!==next.row||previous.parent!==next.parent||previous.item!==next.item||previous.parentItem!==next.parentItem)return!1;const a=previous.detail,b=next.detail;return a.nodeId===b.nodeId&&a.fromParentNodeId===b.fromParentNodeId&&a.fromIndex===b.fromIndex&&a.toParentNodeId===b.toParentNodeId&&a.toIndex===b.toIndex&&a.targetNodeId===b.targetNodeId&&a.position===b.position}function hitRow(tree,x,y){let hit=tree.getRootNode().elementFromPoint?.(x,y)??null;for(;hit?.shadowRoot;){const inside=hit.shadowRoot.elementFromPoint?.(x,y);if(!inside||inside===hit||!composedContains(hit,inside))break;hit=inside}for(let element=hit;element&&element!==tree;element=flattenedParentElement(element)){if(element.localName===tag("tree"))return;if(element.part?.contains("row")&&element.getRootNode().host?.localName===tag("tree-item"))return element}}function eligible(tree,node){const row=node.shadowRoot?.querySelector('[part="row"]'),view=tree.ownerDocument.defaultView;if(!row||!view||!row.getClientRects().length||view.getComputedStyle(row).visibility!=="visible")return!1;for(let current=node;current;current=flattenedParentElement(current)){if(current.hasAttribute("inert")||current.hasAttribute("hidden"))return!1;if(current.localName===tag("tree"))return current===tree;if(current.localName===tag("tree-item")){const ancestor=current;if(ancestor.isDisabled||ancestor!==node&&!ancestor.expanded)return!1}}return!1}function scrollContainer(tree,source){const view=tree.ownerDocument.defaultView;if(!view)return null;for(let element=source;element;element=flattenedParentElement(element))if(element.scrollHeight>element.clientHeight&&/^(auto|scroll|overlay)$/.test(view.getComputedStyle(element).overflowY))return element;return tree.ownerDocument.scrollingElement}class TreePointerReorder{constructor(tree,locate,uniqueIds,request){this.tree=tree,this.locate=locate,this.uniqueIds=uniqueIds,this.request=request,this.start=event=>{if(this.gesture||!this.tree.pointerReorderable||this.tree.treeSource!==void 0||!event.isPrimary||event.button!==0)return;const path=event.composedPath(),treeTag=tag("tree"),itemTag=tag("tree-item");if(path.find(target=>target.localName===treeTag)!==this.tree||fromInteractiveDescendant(event,target=>target.localName===itemTag))return;const node=path.find(target=>target.localName===itemTag),rowRoot=node?.shadowRoot,row=rowRoot?.querySelector('[part="row"]');if(!node||!rowRoot||!row||!path.includes(row)||!eligible(this.tree,node))return;const checkbox=rowRoot.querySelector('[part="checkbox"]');if(checkbox&&path.includes(checkbox)||event.pointerType==="touch"&&!path.some(target=>target.part?.contains("reorder-handle")))return;const location=this.locate(node),view=this.tree.ownerDocument.defaultView;!location||!view||(this.clearClick(),this.gesture={node,row,rowRoot,parent:location.parent,index:location.index,data:this.tree.data,sourceItem:node.item,sourceParentItem:location.parent?.item,nodeId:node.nodeId,parentId:location.parent?.nodeId??null,pointerId:event.pointerId,startX:event.clientX,startY:event.clientY,x:event.clientX,y:event.clientY,dragging:!1,view},rowRoot.addEventListener("selectstart",this.preventNativeDrag,!0),rowRoot.addEventListener("dragstart",this.preventNativeDrag,!0),node.addEventListener("selectstart",this.preventNativeDrag,!0),node.addEventListener("dragstart",this.preventNativeDrag,!0),view.addEventListener("pointermove",this.move,!0),view.addEventListener("pointerup",this.up,!0),view.addEventListener("pointercancel",this.interrupt,!0),this.tree.addEventListener("lostpointercapture",this.interrupt),view.addEventListener("keydown",this.keyDown,!0),view.addEventListener("blur",this.cancel))},this.preventNativeDrag=event=>{const gesture=this.gesture;!gesture||!this.tree.pointerReorderable||this.tree.treeSource!==void 0||!eligible(this.tree,gesture.node)||!event.composedPath().includes(gesture.row)||fromInteractiveDescendant(event,target=>target===gesture.row)||event.preventDefault()},this.move=event=>{const gesture=this.gesture;if(!(!gesture||event.pointerId!==gesture.pointerId)){if(gesture.x=event.clientX,gesture.y=event.clientY,!gesture.dragging){if(Math.hypot(gesture.x-gesture.startX,gesture.y-gesture.startY)<5)return;gesture.dragging=!0;try{this.tree.setPointerCapture(gesture.pointerId)}catch{}}event.cancelable&&event.preventDefault(),this.updateTarget()}},this.up=event=>{const gesture=this.gesture;if(!gesture||gesture.pointerId!==event.pointerId)return;gesture.x=event.clientX,gesture.y=event.clientY;const candidate=gesture.dragging?this.allowed(gesture):void 0;this.cancel(),candidate&&sameCandidate(gesture.painted,candidate)&&this.request(candidate.detail)},this.interrupt=event=>{event.pointerId===this.gesture?.pointerId&&(event.type!=="lostpointercapture"||event.composedPath()[0]===this.tree)&&this.cancel()},this.keyDown=event=>{event.key==="Escape"&&(event.preventDefault(),event.stopPropagation(),this.cancel())},this.cancel=()=>{const gesture=this.gesture;if(!gesture)return;this.gesture=void 0;const{view,pointerId}=gesture;this.animation!==void 0&&view.cancelAnimationFrame(this.animation),this.animation=void 0,gesture.rowRoot.removeEventListener("selectstart",this.preventNativeDrag,!0),gesture.rowRoot.removeEventListener("dragstart",this.preventNativeDrag,!0),gesture.node.removeEventListener("selectstart",this.preventNativeDrag,!0),gesture.node.removeEventListener("dragstart",this.preventNativeDrag,!0),view.removeEventListener("pointermove",this.move,!0),view.removeEventListener("pointerup",this.up,!0),view.removeEventListener("pointercancel",this.interrupt,!0),this.tree.removeEventListener("lostpointercapture",this.interrupt),view.removeEventListener("keydown",this.keyDown,!0),view.removeEventListener("blur",this.cancel),this.tree.hasPointerCapture?.(pointerId)&&this.tree.releasePointerCapture(pointerId);const line=this.indicator;line&&(line.hidden=!0),gesture.dragging&&this.tree.isConnected&&(this.tree.addEventListener("click",this.onClick,!0),this.tree.addEventListener("pointerdown",this.clearClick,!0))},this.onClick=event=>{event.detail>0&&(event.preventDefault(),event.stopImmediatePropagation(),this.clearClick())},this.clearClick=()=>{this.tree.removeEventListener("click",this.onClick,!0),this.tree.removeEventListener("pointerdown",this.clearClick,!0)}}candidate(gesture){const tree=this.tree;if(!tree.pointerReorderable||tree.treeSource!==void 0||tree.data!==gesture.data||gesture.node.item!==gesture.sourceItem||gesture.node.nodeId!==gesture.nodeId||!eligible(tree,gesture.node))return;const row=hitRow(tree,gesture.x,gesture.y);if(!row)return;const target=row.getRootNode().host;if(!eligible(tree,target)||composedContains(gesture.node,target))return;const source=this.locate(gesture.node),dest=this.locate(target);if(!source||source.parent!==gesture.parent||source.index!==gesture.index||!dest||source.parent?.item!==gesture.sourceParentItem||(source.parent?.nodeId??null)!==gesture.parentId||dest.parent!==source.parent&&!tree.allowCrossParentReorder)return;const ids=new Set([gesture.node.nodeId,target.nodeId]);if(source.parent&&ids.add(source.parent.nodeId),dest.parent&&ids.add(dest.parent.nodeId),!this.uniqueIds(ids))return;const box=row.getBoundingClientRect();if(gesture.x<box.left||gesture.x>=box.right||gesture.y<box.top||gesture.y>=box.bottom)return;const position=gesture.y<box.top+box.height/2?"before":"after",insertion=dest.index+(position==="after"?1:0),toIndex=insertion-(dest.parent===source.parent&&source.index<insertion?1:0);if(!(dest.parent===source.parent&&toIndex===source.index))return{row,parent:dest.parent,parentItem:dest.parent?.item,item:target.item,detail:Object.freeze({nodeId:gesture.node.nodeId,fromParentNodeId:source.parent?.nodeId??null,fromIndex:source.index,toParentNodeId:dest.parent?.nodeId??null,toIndex,targetNodeId:target.nodeId,position})}}allowed(gesture){const candidate=this.candidate(gesture);if(!candidate)return;const canDrop=this.tree.canDrop;if(canDrop===void 0)return candidate;try{if(typeof canDrop!="function")return;const answer=canDrop(candidate.detail);if(answer!==!0){answer&&typeof answer.then=="function"&&Promise.resolve(answer).catch(()=>{});return}}catch{return}if(this.gesture!==gesture||this.tree.canDrop!==canDrop)return;const current=this.candidate(gesture);return sameCandidate(candidate,current)?current:void 0}get indicator(){return this.tree.shadowRoot?.querySelector('[part="drop-indicator"]')??null}updateTarget(){const gesture=this.gesture;if(!gesture?.dragging)return;const candidate=this.allowed(gesture);gesture.painted=candidate;const line=this.indicator,base=line?.parentElement;if(line&&base&&(line.hidden=!candidate,candidate)){const row=candidate.row.getBoundingClientRect(),origin=base.getBoundingClientRect(),style=gesture.view.getComputedStyle(candidate.row),indent=Number.parseFloat(style.paddingInlineStart)||0,y=candidate.detail.position==="before"?row.top:row.bottom;line.style.left=`${row.left-origin.left+base.scrollLeft+(style.direction==="rtl"?0:indent)}px`,line.style.top=`${y-origin.top+base.scrollTop}px`,line.style.width=`${Math.max(0,row.width-indent)}px`}this.gesture===gesture&&this.animation===void 0&&this.autoScroll(gesture)}autoScroll(gesture){const scroller=scrollContainer(this.tree,gesture.node);if(!scroller)return;const doc=this.tree.ownerDocument,treeBounds=this.tree.getBoundingClientRect();if(gesture.x<treeBounds.left||gesture.x>=treeBounds.right)return;const bounds=scroller===doc.scrollingElement?{top:0,bottom:gesture.view.innerHeight,left:0,right:gesture.view.innerWidth}:scroller.getBoundingClientRect();if(gesture.x<bounds.left||gesture.x>=bounds.right||gesture.y<bounds.top||gesture.y>=bounds.bottom)return;const edge=Math.min(36,(bounds.bottom-bounds.top)/4),distance=gesture.y<bounds.top+edge?gesture.y-bounds.top-edge:gesture.y>bounds.bottom-edge?gesture.y-bounds.bottom+edge:0;if(!distance)return;const delta=Math.sign(distance)*Math.ceil(Math.abs(distance)/2);(delta<0?scroller.scrollTop<=0:scroller.scrollTop+scroller.clientHeight>=scroller.scrollHeight-1)||(this.animation=gesture.view.requestAnimationFrame(()=>{this.animation=void 0,gesture===this.gesture&&(scroller.scrollTop+=delta,this.updateTarget())}))}}export{TreePointerReorder};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type{LyraVariant}from'../../../internal/variants.js';
|
|
2
2
|
/** Selection behavior shared by the declarative and data-driven tree models.*/
|
|
3
|
-
export type TreeSelection='single'|'multiple'|'leaf'|'leaf-multiple';
|
|
3
|
+
export type TreeSelection='single'|'multiple'|'leaf'|'leaf-multiple';
|
|
4
|
+
/** Controlled pointer insertion. Indices are sibling-scoped; toIndex is measured after removing the source.*/
|
|
5
|
+
export interface LyraTreePointerReorderDetail{readonly nodeId:string;readonly fromParentNodeId:string|null;readonly fromIndex:number;readonly toParentNodeId:string|null;readonly toIndex:number;readonly targetNodeId:string;readonly position:'before'|'after';}export interface TreeBadge{readonly text:string;readonly tone?:LyraVariant;
|
|
4
6
|
/** Accessible name override. When omitted or empty, the visible `text` names the chip naturally.*/
|
|
5
7
|
readonly label?:string;}export interface LyraTreeNodeData{
|
|
6
8
|
/** Stable public identity, unique across every reachable item in one data tree. If invalid input
|
|
@@ -10,6 +12,8 @@ readonly id:string;readonly label:string;
|
|
|
10
12
|
/** Whether this item is the current selection. When set, the treeitem exposes
|
|
11
13
|
* `aria-selected` and renders the matching selected state. */
|
|
12
14
|
readonly selected?:boolean;
|
|
15
|
+
/** Seeds a data branch on first assignment or when an explicitly supplied value changes.*/
|
|
16
|
+
readonly expanded?:boolean;
|
|
13
17
|
/** Removes this item from roving focus and prevents select/toggle activation.*/
|
|
14
18
|
readonly disabled?:boolean;
|
|
15
19
|
/** Marks children as asynchronously loadable. Assign a refreshed item with children (or
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type{LyraHierarchySource,LyraHierarchyQuery}from'../../../data-sources.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement,type LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import'./tree-item.class.js';import type{LyraTreeItem}from'./tree-item.class.js';import type{TreeBadge,LyraTreeNodeData,TreeSelection}from'./tree-types.js';export type{TreeBadge,LyraTreeNodeData,TreeSelection};
|
|
1
|
+
import type{LyraHierarchySource,LyraHierarchyQuery}from'../../../data-sources.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement,type LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type LyraSize}from'../../../internal/variants.js';import'./tree-item.class.js';import type{LyraTreeItem}from'./tree-item.class.js';import type{TreeBadge,LyraTreeNodeData,LyraTreePointerReorderDetail,TreeSelection}from'./tree-types.js';export type{TreeBadge,LyraTreeNodeData,LyraTreePointerReorderDetail,TreeSelection};
|
|
2
2
|
/** Provider-owned immutable preorder used when treeSource is defined.*/
|
|
3
|
-
export type TreeSource=LyraHierarchySource<LyraTreeNodeData,LyraHierarchyQuery>;export interface LyraTreeEventMap{'lr-source-selection-change':CustomEvent<Readonly<{key:string;selected:boolean;scope:'item'|'subtree';state:string;}>>;'lr-node-toggle':CustomEvent<{nodeId:string;expanded:boolean;}>;'lr-node-select':CustomEvent<{nodeId:string;}>;'lr-reorder':CustomEvent<{nodeId:string;parentNodeId:string|null;fromIndex:number;toIndex:number;}>;'lr-selection-change':CustomEvent<LyraEventDetailSnapshot<{readonly selection:readonly LyraTreeItem[];}>>;'lr-expand':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;}>>;'lr-after-expand':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;}>>;'lr-collapse':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;}>>;'lr-after-collapse':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;}>>;'lr-lazy-change':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;readonly loading:boolean;}>>;'lr-lazy-load':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;readonly generation:number;}>>;}
|
|
3
|
+
export type TreeSource=LyraHierarchySource<LyraTreeNodeData,LyraHierarchyQuery>;export interface LyraTreeEventMap{'lr-pointer-reorder':CustomEvent<LyraTreePointerReorderDetail>;'lr-source-selection-change':CustomEvent<Readonly<{key:string;selected:boolean;scope:'item'|'subtree';state:string;}>>;'lr-node-toggle':CustomEvent<{nodeId:string;expanded:boolean;}>;'lr-bulk-toggle':CustomEvent<Readonly<{expanded:boolean;nodeIds:readonly string[];}>>;'lr-node-select':CustomEvent<{nodeId:string;}>;'lr-reorder':CustomEvent<{nodeId:string;parentNodeId:string|null;fromIndex:number;toIndex:number;}>;'lr-selection-change':CustomEvent<LyraEventDetailSnapshot<{readonly selection:readonly LyraTreeItem[];}>>;'lr-expand':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;}>>;'lr-after-expand':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;}>>;'lr-collapse':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;}>>;'lr-after-collapse':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;}>>;'lr-lazy-change':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;readonly loading:boolean;}>>;'lr-lazy-load':CustomEvent<LyraEventDetailSnapshot<{readonly item:LyraTreeItem;readonly generation:number;}>>;}
|
|
4
4
|
/**
|
|
5
5
|
* `<lr-tree>` — an expand/collapse hierarchy for graph/document navigation.
|
|
6
6
|
*
|
|
@@ -44,6 +44,9 @@ export type TreeSource=LyraHierarchySource<LyraTreeNodeData,LyraHierarchyQuery>;
|
|
|
44
44
|
*
|
|
45
45
|
* Provider mode uses treeSource's immutable preorder and ignores nested value.children.
|
|
46
46
|
* Legacy DOM selection/lazy events and bulk expand/collapse remain legacy-only; source reordering is unavailable.
|
|
47
|
+
* @event lr-pointer-reorder - A controlled pointer move request. Detail carries nodeId, fromParentNodeId, fromIndex, toParentNodeId, toIndex, targetNodeId and position (before or after). Root parent IDs are null and toIndex is the sibling index after removal.
|
|
48
|
+
* @csspart drop-indicator - The insertion line at the permitted pointer target.
|
|
49
|
+
* @cssprop [--lr-tree-drop-indicator-color=var(--lr-color-brand)] - Color of the insertion line.
|
|
47
50
|
* @csspart source-list - The bounded source viewport.
|
|
48
51
|
* @csspart source-row - A mounted semantic tree row.
|
|
49
52
|
* @csspart source-toggle - A source branch or retry button.
|
|
@@ -52,6 +55,7 @@ export type TreeSource=LyraHierarchySource<LyraTreeNodeData,LyraHierarchyQuery>;
|
|
|
52
55
|
* @csspart source-error - Localized provider or row failure.
|
|
53
56
|
* @event lr-source-selection-change - Accepted provider selection intent: readonly { key, selected, scope, state } without DOM item enumeration.
|
|
54
57
|
* @customElement lr-tree
|
|
58
|
+
* @event lr-bulk-toggle - Emitted after a bulk operation changes branch expansion. Immutable `detail: { expanded, nodeIds }` includes changes to unmounted data branches.
|
|
55
59
|
* @event lr-node-toggle - `detail: { nodeId, expanded }`, dispatched by a descendant `<lr-tree-item>` and observed here (bubbling, composed) to keep the roving-tabindex `activeId` in sync.
|
|
56
60
|
* @event lr-node-select - `detail: { nodeId }`, dispatched by a descendant `<lr-tree-item>` and observed here (bubbling, composed) to keep the roving-tabindex `activeId` in sync.
|
|
57
61
|
* @event lr-reorder - `detail: { nodeId, parentNodeId, fromIndex, toIndex }` — Ctrl/Cmd+ArrowUp/ArrowDown requests moving the focused node within its **own parent's** child list (`parentNodeId` is `null` for a top-level item; the indices are sibling-scoped, not flattened-visible-list positions). Only fired while `reorderable`. Never fires at a subtree boundary, so a reorder can never become a reparent. Success is announced only after the rendered sibling order confirms the request.
|
|
@@ -69,6 +73,8 @@ export type TreeSource=LyraHierarchySource<LyraTreeNodeData,LyraHierarchyQuery>;
|
|
|
69
73
|
* @slot - Top-level `<lr-tree-item>` elements, each nesting its own children — the declarative child model. Leave it empty and assign `data` instead for the object model.
|
|
70
74
|
* @slot expand-icon - Default icon shown by expanded items; an item-level slot takes precedence.
|
|
71
75
|
* @slot collapse-icon - Default icon shown by collapsed items; an item-level slot takes precedence.
|
|
76
|
+
* @cssprop --lr-tree-row-height - Minimum block size of data and declarative rows. Inherits through nested items.
|
|
77
|
+
* @cssprop --lr-tree-toggle-size - Size of data and declarative disclosure buttons, leaf placeholders and selection checkboxes. Inherits through nested items.
|
|
72
78
|
* @cssprop [--indent-size=var(--lr-space-l)] - Indentation step for nested items.
|
|
73
79
|
* @cssprop [--indent-guide-color=var(--lr-color-border-subtle)] - Indentation guide color.
|
|
74
80
|
* @cssprop [--indent-guide-offset=0] - Block-axis inset for indentation guides.
|
|
@@ -77,7 +83,11 @@ export type TreeSource=LyraHierarchySource<LyraTreeNodeData,LyraHierarchyQuery>;
|
|
|
77
83
|
* @status stable
|
|
78
84
|
* @since 4.0.0
|
|
79
85
|
*/
|
|
80
|
-
export declare class LyraTree extends LyraElement<LyraTreeEventMap>{protected static collectionSupport:import("../../../internal/lyra-element.js").LyraCollectionSupport;protected static readonly immutableEventDetails:readonly string[];protected static readonly identityEventDetailProperties:Readonly<{'lr-selection-change':readonly string[];}>;static styles:import("lit").CSSResultGroup[];private
|
|
86
|
+
export declare class LyraTree extends LyraElement<LyraTreeEventMap>{protected static collectionSupport:import("../../../internal/lyra-element.js").LyraCollectionSupport;protected static readonly immutableEventDetails:readonly string[];protected static readonly identityEventDetailProperties:Readonly<{'lr-selection-change':readonly string[];}>;static styles:import("lit").CSSResultGroup[];private _size?;
|
|
87
|
+
/** Optional row density for data and declarative trees. Accepts `2xs`, `xs`, `s`, `m`, `l`,
|
|
88
|
+
* `xl` and the `small`, `medium`, `large` aliases. Omitting size keeps the original row
|
|
89
|
+
* geometry. Provider rows use their own measured layout. */
|
|
90
|
+
get size():LyraSize|undefined;set size(next:LyraSize|undefined);private _treeSource;private sourceMode;private sourcePaintVersion;private sourceAnnouncement?;private readonly sourceAnnouncer;private readonly hierarchy;
|
|
81
91
|
/** Immutable provider preorder. Wins over legacy inputs while defined; unset restores them.
|
|
82
92
|
* At most 301 rows mount, with four 100-row pages and one focused row retained.
|
|
83
93
|
* Row names include label, description and badge text unless accessibleLabel overrides them;
|
|
@@ -86,11 +96,13 @@ export declare class LyraTree extends LyraElement<LyraTreeEventMap>{protected st
|
|
|
86
96
|
* @default undefined */
|
|
87
97
|
get treeSource():TreeSource|undefined;set treeSource(value:TreeSource|undefined);
|
|
88
98
|
/** Reveals a provider key and focuses its current visible row; false when absent or obsolete.*/
|
|
89
|
-
revealSourceKey(key:string):Promise<boolean>;private normalizeSourceValue;private announceSource;private sourceSummary;private _data;private lastDataInput;private lastDataLimit;private selectionBeforeRefresh?;private declaredChildrenAtPath;private declaredRootCount;private _dataTruncated;private _limitReached;
|
|
99
|
+
revealSourceKey(key:string):Promise<boolean>;private normalizeSourceValue;private announceSource;private sourceSummary;private _data;private readonly dataExpansion;private lastDataInput;private lastDataLimit;private selectionBeforeRefresh?;private declaredChildrenAtPath;private declaredRootCount;private _dataTruncated;private _limitReached;
|
|
90
100
|
/** Clone-owned/frozen object child model. Normalization retains at most maxNodes nodes (default 1000) over 64
|
|
91
101
|
* descendant levels and inspects at most 10,000 root/child array positions in depth-first order.
|
|
92
102
|
* A reassignment is diffed by id: a node whose fields and children are unchanged keeps its
|
|
93
103
|
* previous object, so its row neither re-renders nor re-seeds element state.
|
|
104
|
+
* Branch disclosure follows the id across moves and unmounts. A changed explicit `expanded`
|
|
105
|
+
* boolean replaces the current value. Removing the field preserves it. Removed ids are forgotten.
|
|
94
106
|
* An otherwise unnamed projected row uses its stable data ID as its semantic name, without
|
|
95
107
|
* changing its visible label or the installed data.
|
|
96
108
|
* @default [] */
|
|
@@ -112,18 +124,24 @@ maxNodes:number;private get effectiveMaxNodes();
|
|
|
112
124
|
* `false`: unset, no `lr-reorder` is ever emitted, Ctrl/Cmd+Arrow keeps behaving exactly like
|
|
113
125
|
* a plain Arrow press, and the internal live region is not rendered at all.
|
|
114
126
|
*/
|
|
115
|
-
reorderable:boolean;
|
|
127
|
+
reorderable:boolean;
|
|
128
|
+
/** Enables pointer reorder requests on object and declarative rows. Touch drags begin on the grip.*/
|
|
129
|
+
pointerReorderable:boolean;
|
|
130
|
+
/** Allows pointer moves before or after rows belonging to another parent.*/
|
|
131
|
+
allowCrossParentReorder:boolean;
|
|
132
|
+
/** Optional synchronous policy for pointer reordering. Only true accepts a candidate.*/
|
|
133
|
+
canDrop?:(request:LyraTreePointerReorderDetail)=>boolean;private _selection;
|
|
116
134
|
/** Selection behavior. Multiple modes cascade through enabled descendants and expose checkboxes.
|
|
117
135
|
* @default 'single' */
|
|
118
|
-
get selection():TreeSelection;set selection(value:TreeSelection);private _activeId;private activeNode?;private readonly readActiveId;private get activeId();private set activeId(value);private setActiveNode;private get nodeWalkLimit();private hasAuthoredItems;private pendingFocusId;private readonly generatedNodes;private dataIdOwnerPaths;private dataIdCollisions;private selectionSyncPending;private dataSyncPending;private inertMutationPending;private dirtyConfigureRoots;private lastFocusedNodeId;private liveRegion?;private pendingReorder?;private get nodeElements();private childrenOf;private isNavigable;private allNodeElements;
|
|
136
|
+
get selection():TreeSelection;set selection(value:TreeSelection);private _activeId;private activeNode?;private readonly readActiveId;private get activeId();private set activeId(value);private setActiveNode;private get nodeWalkLimit();private hasAuthoredItems;private pendingFocusId;private readonly generatedNodes;private dataIdOwnerPaths;private dataIdCollisions;private selectionSyncPending;private dataSyncPending;private inertMutationPending;private dirtyConfigureRoots;private lastFocusedNodeId;private liveRegion?;private pendingReorder?;private pendingPointerReorder?;private readonly pointerOrder;private get nodeElements();private childrenOf;private isNavigable;private allNodeElements;
|
|
119
137
|
/** The current selected item elements in document order.*/
|
|
120
|
-
get selectedItems():readonly LyraTreeItem[];private iconSource;private applyTreeContext;private selectableInSingleMode;private normalizeSingleSelection;private setBranchSelection;private deriveMultipleSelection;private normalizeMultipleSelection;private normalizeSelection;private selectionBefore?;private setSelection;private updateSelectionFrom;private refreshAuthoredItems;private visibleNodeElements;private findItem;private isDuplicateDataPath;private rebuildDataIdentity;private treeIdentityAt;private firstEnabledId;private isEnabledReachableId;private findRenderedSiblings;private deepFocusedNode;private resolveActiveFromDom;private onTreeFocusIn;private onItemFocus;requestUpdate(name?:PropertyKey,oldValue?:unknown):void;protected willUpdate(changed:PropertyValues):void;protected firstUpdated(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private contextSyncPending;private bulkExpansions;private syncGeneration;private syncRequested;private syncRunning;private syncTask?;private requestContextSync;private scheduleTreeSync;private runTreeSync;private onChildrenChanged;private childObserver?;private childObserverDocument?;private childObserverGeneration;private rootTreeItemAncestor;private onChildMutations;connectedCallback():void;private armChildObserver;disconnectedCallback():void;adoptedCallback():void;private resetChildObserver;private syncNodes;private focusNode;private onNodeActivate;private subtreeHasId;private focusIsWithin;private eventNode;private onNodeSelect;
|
|
138
|
+
get selectedItems():readonly LyraTreeItem[];private iconSource;private applyTreeContext;private selectableInSingleMode;private normalizeSingleSelection;private setBranchSelection;private deriveMultipleSelection;private normalizeMultipleSelection;private normalizeSelection;private selectionBefore?;private setSelection;private updateSelectionFrom;private refreshAuthoredItems;private visibleNodeElements;private findItem;private isDuplicateDataPath;private rebuildDataIdentity;private treeIdentityAt;private firstEnabledId;private isEnabledReachableId;private findRenderedSiblings;private deepFocusedNode;private resolveActiveFromDom;private onTreeFocusIn;private onItemFocus;requestUpdate(name?:PropertyKey,oldValue?:unknown):void;protected willUpdate(changed:PropertyValues):void;protected firstUpdated(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private contextSyncPending;private bulkExpansions;private bulkExpansionGeneration;private syncGeneration;private syncRequested;private syncRunning;private syncTask?;private requestContextSync;private scheduleTreeSync;private runTreeSync;private onChildrenChanged;private childObserver?;private childObserverDocument?;private childObserverGeneration;private rootTreeItemAncestor;private onChildMutations;connectedCallback():void;private armChildObserver;disconnectedCallback():void;adoptedCallback():void;private resetChildObserver;private syncNodes;private focusNode;private onNodeActivate;private subtreeHasId;private focusIsWithin;private eventNode;private onNodeSelect;
|
|
121
139
|
/**
|
|
122
140
|
* Waits for this tree's own update, any hierarchy sync it scheduled (see `runTreeSync()`), and
|
|
123
141
|
* the item cascade, so `await tree.updateComplete` still means every reachable item has its
|
|
124
142
|
* context, selection state, and restored focus. It performs no work itself.
|
|
125
143
|
*/
|
|
126
|
-
protected getUpdateComplete():Promise<boolean>;private reportRefreshSelectionChange;private restorePendingFocus;private requestReorder;private confirmPendingReorder;private onTreeKeyDown;
|
|
144
|
+
protected getUpdateComplete():Promise<boolean>;private reportRefreshSelectionChange;private restorePendingFocus;private requestReorder;private confirmPendingReorder;private pointerSiblingIds;private confirmPointerReorder;private onTreeKeyDown;
|
|
127
145
|
/**
|
|
128
146
|
* Expand every node in the tree, recursively. Resolves once every
|
|
129
147
|
* descendant has actually finished expanding (not just had `expanded` set)
|
|
@@ -157,4 +175,4 @@ expandAll():Promise<void>;
|
|
|
157
175
|
* roving-tabindex target was a nested descendant whose ancestor's
|
|
158
176
|
* `role="group"` is about to disappear.
|
|
159
177
|
*/
|
|
160
|
-
collapseAll():Promise<void>;render():TemplateResult;private formatCount;}declare global{interface HTMLElementTagNameMap{'lr-tree':LyraTree;}}
|
|
178
|
+
collapseAll():Promise<void>;private emitBulkToggle;render():TemplateResult;private formatCount;}declare global{interface HTMLElementTagNameMap{'lr-tree':LyraTree;}}
|