@aceshooting/lyra-ui 10.0.1 → 11.1.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 +271 -0
- package/custom-elements.json +1 -1
- package/design-tokens.json +13 -0
- package/dist/cli/migrate-wa.mjs +164 -1
- package/dist/cli/migration-contract.json +1 -1
- package/dist/components/charts/chart/box-plot.class.d.ts +27 -0
- package/dist/components/charts/chart/box-plot.class.js +14 -4
- package/dist/components/charts/chart/box-plot.styles.js +28 -0
- package/dist/components/charts/chart/chart.class.d.ts +27 -0
- package/dist/components/charts/chart/chart.class.js +15 -5
- package/dist/components/charts/chart/chart.styles.js +28 -0
- package/dist/components/charts/chart/lite-chart.class.d.ts +32 -0
- package/dist/components/charts/chart/lite-chart.class.js +17 -4
- package/dist/components/charts/chart/lite-chart.styles.js +29 -0
- package/dist/components/data/heatmap/heatmap.class.d.ts +35 -2
- package/dist/components/data/heatmap/heatmap.class.js +2 -2
- package/dist/components/data/table/table.class.d.ts +19 -0
- package/dist/components/data/table/table.class.js +3 -3
- package/dist/components/forms/combobox/combobox.class.d.ts +71 -3
- package/dist/components/forms/combobox/combobox.class.js +4 -2
- package/dist/components/forms/combobox/combobox.styles.js +9 -0
- package/dist/components/forms/date-picker/date-input.class.d.ts +12 -1
- package/dist/components/forms/date-picker/date-input.class.js +4 -2
- package/dist/components/forms/date-picker/date-picker.class.d.ts +72 -0
- package/dist/components/forms/date-picker/date-picker.class.js +15 -3
- package/dist/components/forms/date-picker/date-picker.styles.js +46 -0
- package/dist/components/media/flag/flag.class.d.ts +3 -1
- package/dist/components/media/flag/flag.class.js +1 -1
- package/dist/components/media/map/map.class.d.ts +39 -2
- package/dist/components/media/map/map.class.js +1 -1
- package/dist/components/overlays/dialog/dialog.class.d.ts +20 -0
- package/dist/components/overlays/overlay/popover.class.d.ts +19 -3
- package/dist/components/overlays/overlay/popover.class.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +1 -1
- package/dist/custom-elements-jsx.d.ts +31 -16
- package/dist/internal/canvas.js +1 -1
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/tokens.styles.js +1 -0
- package/dist/lyra.d.ts +1 -1
- package/dist/svelte.d.ts +31 -16
- package/dist/theme.css +32 -0
- package/dist/vue.d.ts +31 -16
- package/llms/components/lr-agent-eval-dashboard.md +1 -1
- package/llms/components/lr-agent-workspace.md +1 -1
- package/llms/components/lr-bar-chart.md +4 -3
- package/llms/components/lr-box-plot.md +15 -4
- package/llms/components/lr-bubble-chart.md +4 -3
- package/llms/components/lr-chart.md +13 -3
- package/llms/components/lr-chunk-inspector.md +1 -1
- package/llms/components/lr-combobox.md +42 -6
- package/llms/components/lr-date-input.md +40 -4
- package/llms/components/lr-date-picker.md +40 -4
- package/llms/components/lr-dialog.md +2 -1
- package/llms/components/lr-doughnut-chart.md +4 -3
- package/llms/components/lr-entity-dossier.md +1 -1
- package/llms/components/lr-eval-run.md +1 -1
- package/llms/components/lr-flag.md +10 -3
- package/llms/components/lr-grounding-summary.md +1 -1
- package/llms/components/lr-heatmap.md +20 -2
- package/llms/components/lr-histogram.md +4 -3
- package/llms/components/lr-line-chart.md +4 -3
- package/llms/components/lr-lite-chart.md +19 -3
- package/llms/components/lr-map.md +21 -4
- package/llms/components/lr-memory-panel.md +1 -1
- package/llms/components/lr-option.md +41 -5
- package/llms/components/lr-pie-chart.md +4 -3
- package/llms/components/lr-polar-area-chart.md +4 -3
- package/llms/components/lr-popover.md +20 -1
- package/llms/components/lr-provenance-panel.md +1 -1
- package/llms/components/lr-radar-chart.md +4 -3
- package/llms/components/lr-rag-answer.md +1 -1
- package/llms/components/lr-rag-eval-dashboard.md +1 -1
- package/llms/components/lr-retrieval-results.md +1 -1
- package/llms/components/lr-retrieval-trace.md +1 -1
- package/llms/components/lr-scatter-chart.md +4 -3
- package/llms/peers.md +8 -8
- package/llms/tokens.md +27 -1
- package/llms-full.txt +231 -28
- package/package.json +1 -1
- package/vscode-css-data.json +70 -0
- package/vscode-html-data.json +131 -20
- package/web-types.json +190 -23
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isRtl}from"../../../internal/rtl.js";import{srOnly,nextId}from"../../../internal/a11y.js";import{finiteCount,finiteInteger,finiteRatio}from"../../../internal/numbers.js";import{resolveCssLength}from"../../../internal/css-length.js";import{getCollator}from"../../../internal/intl-cache.js";import{readPersistedState,writePersistedState}from"../../../internal/persisted-state.js";import{styles}from"./table.styles.js";import{chevronIcon}from"../../../internal/icons.js";import{minMax}from"../heatmap/heatmap-scale.js";import"../../overlays/empty/empty.class.js";import{literalSetConverter,trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_expand,LYRA_DEFAULT_loadMore,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noColumns,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_resizeColumn,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_showAllColumns,LYRA_DEFAULT_showFewerColumns,LYRA_DEFAULT_tableEditCell,LYRA_DEFAULT_tableFilterLabel,LYRA_DEFAULT_tableFilterPlaceholder,LYRA_DEFAULT_tableLoading}from"../../../internal/default-strings.generated.js";const DEFAULT_SKELETON_ROWS=3,MAX_SKELETON_ROWS=20,DEFAULT_PAGE_SIZE=100,MAX_PAGE_SIZE=500,LOW_PRIORITY_MAX_INLINE_SIZE=899.98,MEDIUM_PRIORITY_MAX_INLINE_SIZE=639.98,MAX_TABLE_COLLECTION_ENTRIES=1e4,DEFAULT_RESIZE_MIN_WIDTH_PX=48,UNBOUNDED_RESIZE_ARIA_MAX=Number.MAX_SAFE_INTEGER;function frozenArray(values){const snapshot=[];try{for(const value of values)if(snapshot.push(value),snapshot.length>=MAX_TABLE_COLLECTION_ENTRIES)break}catch{}return Object.freeze(snapshot)}function keySet(values){const snapshot=new Set;try{for(const value of values){if(typeof value=="string"){if(value.trim().length===0)continue}else if(typeof value!="number")continue;if(snapshot.add(value),snapshot.size>=MAX_TABLE_COLLECTION_ENTRIES)break}}catch{}return snapshot}function readonlyKeySet(values){const snapshot=keySet(values);let facade;return facade={get size(){return snapshot.size},has:value=>snapshot.has(value),entries:()=>snapshot.entries(),keys:()=>snapshot.keys(),values:()=>snapshot.values(),[Symbol.iterator]:()=>snapshot[Symbol.iterator](),forEach(callback,thisArg){snapshot.forEach(value=>callback.call(thisArg,value,value,facade))}},Object.freeze(facade)}const UNSAFE_CSS_STRUCTURE=/[;{}]/,URL_FUNCTION=/url\s*\(/i,SAFE_STYLE_PROPERTY=/^-?[_a-zA-Z][\w-]*$|^--[a-zA-Z0-9_-]+$/,optionalBooleanConverter={fromAttribute(value){if(value!==null)return value!=="false"},toAttribute(value){return value===void 0?null:value?"":"false"}};function isDevelopmentRuntime(){const nodeEnv=globalThis.process?.env?.NODE_ENV;if(nodeEnv==="production")return!1;if(nodeEnv==="development")return!0;const viteEnv=import.meta.env;return typeof viteEnv?.DEV=="boolean"?viteEnv.DEV:viteEnv?.MODE==="development"}const TABLE_LAYOUT=literalSetConverter(["auto","fixed"],"auto"),INTERACTIVE_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 stickyDirection(sticky){if(sticky==="start"||sticky==="end")return sticky}function sanitizeCellStyle(cellStyle){if(cellStyle===void 0)return{};const safe={};for(const[rawProperty,rawValue]of Object.entries(cellStyle)){const property2=sanitizeCellStyleProperty(rawProperty),value=sanitizeCellStyleValue(rawValue);if(property2===void 0||value===void 0)continue;const normalizedProperty=normalizeStyleProperty(property2);(normalizedProperty.startsWith("--")||cssSupports(normalizedProperty,value))&&(safe[normalizedProperty]=value)}return safe}function sanitizeCellStyleProperty(property2){const normalized=property2.trim();if(!(!normalized||!SAFE_STYLE_PROPERTY.test(normalized)))return normalized}function normalizeStyleProperty(property2){return property2.startsWith("--")?property2:property2.replace(/[A-Z]/g,"-$&").toLowerCase()}function sanitizeCellStyleValue(value){if(typeof value!="string")return;const normalized=value.trim();if(!(!normalized||UNSAFE_CSS_STRUCTURE.test(normalized)||URL_FUNCTION.test(normalized)))return normalized}function cssSupports(property2,value){return typeof CSS>"u"||typeof CSS.supports!="function"?!0:CSS.supports(property2,value)}function normalizedEditTrigger(editTrigger){if(editTrigger==="always"||editTrigger==="double-click")return editTrigger}function encodeKey(key){return`${typeof key}:${key}`}function safeStringifyForFilter(row){const seen=new WeakSet;try{return JSON.stringify(row,(_key,value)=>{if(typeof value=="bigint")return value.toString();if(typeof value=="object"&&value!==null){if(seen.has(value))return"[Circular]";seen.add(value)}return value})??""}catch{return""}}function asElement(value){return typeof value!="object"||!("nodeType"in value)||value.nodeType!==1||!("matches"in value)?null:value}function eventInteractiveTarget(event,boundary){for(const value of event.composedPath()){if(value===boundary)break;const element=asElement(value);if(element!==null&&(element.matches("[data-table-interactive]")||element.matches(INTERACTIVE_SELECTOR)&&!element.matches("[data-row-key], th[data-col-key]")))return element}return null}class LyraTable extends LyraElement{constructor(){super(...arguments),this._columns=Object.freeze([]),this._rows=Object.freeze([]),this._layout="auto",this.sortKey="",this.sortDir="asc",this.sortMode="client",this.defaultSortDir="asc",this.caption="",this.captionId=nextId("lr-table-caption"),this.selectionMode="none",this.scrollMode="self",this._selectedKeys=new Set,this.filterable=!1,this.filterText="",this.spellcheck=!0,this.autocapitalize="",this.autoCorrect="",this.loading=!1,this.loadingAppearance="spinner",this.skeletonRows=0,this.pageSize=DEFAULT_PAGE_SIZE,this.page=1,this.totalItems=-1,this.paginationMode="client",this._expandedKeys=new Set,this.hasMore=!1,this.emptyDescription="",this.noColumnsDescription="",this.hasHiddenPriorityColumns=!1,this.priorityColumnsToggleAvailable=!1,this.priorityColumnsVisible=!1,this.persistReady=!1,this.loadingAnnouncementsReady=!1,this.activeColKey=null,this.activeRowKey=null,this.editingCell=null,this.focusedEditorCell=null,this.editorHadFocusBeforeUpdate=!1,this.rovingFocusSnapshot=null,this.resizedColumnWidths=new Map,this.rowsByKey=new Map,this.columnsByKey=new Map,this.layoutFrame=null,this.observedHeaders=new Set,this.onResizePointerDown=event=>{const handle=event.currentTarget,key=handle.dataset.colKey,column=key?this.columnsByKey.get(key):void 0,header=handle.closest("th[data-col-key]"),resizeEventWindow=this.ownerDocument.defaultView;if(!key||!column||!header||!resizeEventWindow)return;const replacedStartWidth=this.resizeState?.key===key?this.resizeState.startWidth:void 0;this.cancelResizeGesture();const minWidth=this.minimumResizeWidth(column);this.resizeState={key,pointerId:event.pointerId,startX:event.clientX,startWidth:replacedStartWidth??header.getBoundingClientRect().width,minWidth,maxWidth:this.maximumResizeWidth(column,minWidth),handle,previousWidth:this.resizedColumnWidths.get(key)},handle.toggleAttribute("data-resizing",!0),event.preventDefault(),event.stopPropagation(),handle.setPointerCapture?.(event.pointerId),this.resizeEventWindow=resizeEventWindow,resizeEventWindow.addEventListener("pointermove",this.onResizePointerMove),resizeEventWindow.addEventListener("pointerup",this.onResizePointerEnd),resizeEventWindow.addEventListener("pointercancel",this.onResizePointerEnd),resizeEventWindow.addEventListener("lostpointercapture",this.onResizePointerEnd)},this.onResizePointerMove=event=>{const state2=this.resizeState;if(!state2||event.pointerId!==state2.pointerId)return;const delta=isRtl(this)?state2.startX-event.clientX:event.clientX-state2.startX,width=Math.min(state2.maxWidth,Math.max(state2.minWidth,state2.startWidth+delta));this.resizedColumnWidths.get(state2.key)!==width&&(this.resizedColumnWidths=new Map(this.resizedColumnWidths).set(state2.key,width),this.emit("lr-column-resize",Object.freeze({columnKey:state2.key,width})))},this.onResizeKeyDown=event=>{const handle=event.currentTarget,key=handle.dataset.colKey,column=key?this.columnsByKey.get(key):void 0;if(!column)return;const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),currentWidth=this.currentResizeWidth(column,handle),step=event.shiftKey?50:10;let requestedWidth;event.key==="Home"?requestedWidth=minWidth:event.key==="End"&&Number.isFinite(maxWidth)?requestedWidth=maxWidth:event.key==="ArrowLeft"?requestedWidth=currentWidth+(isRtl(this)?step:-step):event.key==="ArrowRight"&&(requestedWidth=currentWidth+(isRtl(this)?-step:step)),requestedWidth!==void 0&&(event.preventDefault(),event.stopPropagation(),this.resizeColumnTo(column,requestedWidth))},this.onResizePointerEnd=event=>{const state2=this.resizeState;if(!state2||event.pointerId!==state2.pointerId)return;if(state2.handle.removeAttribute("data-resizing"),event.type==="pointerup")try{state2.handle.releasePointerCapture?.(event.pointerId)}catch{}if(this.resizeState=void 0,this.detachResizePointerListeners(),event.type!=="pointerup"){const reverted2=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted2.delete(state2.key):reverted2.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted2;return}const committedWidth=this.resizedColumnWidths.get(state2.key);if(committedWidth===void 0||committedWidth===state2.previousWidth||!this.emit("lr-column-resize",Object.freeze({columnKey:state2.key,width:committedWidth}),{cancelable:!0}).defaultPrevented)return;const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted},this.scheduleLayoutSync=()=>{if(this.layoutFrame)return;const owner=this.ownerDocument.defaultView;if(!owner)return;const frame={owner,handle:0};frame.handle=owner.requestAnimationFrame(()=>{this.layoutFrame===frame&&(this.layoutFrame=null,!(!this.isConnected||this.ownerDocument.defaultView!==owner)&&(this.recomputeHiddenPriorityColumns(),this.applyStickyOffsets(),this.syncResizeHandleValues()))}),this.layoutFrame=frame},this.cachedCanonicalRowEntries=null,this.canonicalRowEntriesInputs=null,this.cachedMatchingEntries=null,this.matchingEntriesInputs=null,this.cachedSortedEntries=null,this.sortedEntriesInputs=null,this.onFilterInput=event=>{event.stopPropagation();const input=event.currentTarget;this.filterText=input.value,this.emit("lr-filter-change",Object.freeze({text:this.filterText}))},this.stopOwnedEvent=event=>{event.stopPropagation()},this.onNativeFocus=event=>{event.stopPropagation(),this.emit("focus")},this.onNativeBlur=event=>{event.stopPropagation(),this.emit("blur")},this.onPaginationChange=event=>{event.stopPropagation();const{page}=event.detail;this.paginationMode==="client"&&(this.page=page),this.emit("lr-page-change",Object.freeze({page}))},this.onTableFocusIn=event=>{const target=event.target,cell=target?.closest?.("td[data-col-key]"),row=target?.closest?.("[data-row-key]"),columnKey=cell?.dataset.colKey,rowKey=row?.dataset.rowKey;this.focusedEditorCell=target?.getAttribute("part")==="cell-editor"&&columnKey!==void 0&&rowKey!==void 0&&normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="always"?{rowKey,columnKey}:null},this.onEditorKeyDown=(event,rowKey,columnKey)=>{event.stopPropagation();const alwaysOn=normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="always";event.key==="Enter"?(event.preventDefault(),this.commitEdit(event,rowKey,columnKey)):event.key==="Escape"&&!alwaysOn&&(event.preventDefault(),this.editingCell=null)},this.onTableDoubleClick=event=>{const target=event.target,table=event.currentTarget;if(eventInteractiveTarget(event,table))return;const cell=target.closest('[part="cell"][data-col-key]'),row=target.closest("[data-row-key]");cell&&row?.dataset.rowKey&&cell.dataset.colKey&&this.startEditing(row.dataset.rowKey,cell.dataset.colKey)},this.toggleColumns=()=>{this.priorityColumnsVisible=!this.priorityColumnsVisible,this.emit("lr-priority-columns-visibility-change",Object.freeze({visible:this.priorityColumnsVisible}))},this.onTableClick=e=>{const target=e.target,table=e.currentTarget;if(eventInteractiveTarget(e,table))return;const th=target.closest("th[data-col-key]");if(th)return this.activateColumn(th.dataset.colKey);const tr=target.closest("[data-row-key]");tr&&this.activateRow(tr.dataset.rowKey)},this.onTableKeyDown=e=>{const target=e.target,table=e.currentTarget;if(eventInteractiveTarget(e,table))return;const th=target.closest("th[data-col-key]");if(th)return this.onHeaderKeyDown(e,th);const tr=target.closest("[data-row-key]");tr&&this.onRowKeyDown(e,tr)}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,expand:LYRA_DEFAULT_expand,loadMore:LYRA_DEFAULT_loadMore,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noColumns:LYRA_DEFAULT_noColumns,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,resizeColumn:LYRA_DEFAULT_resizeColumn,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,showAllColumns:LYRA_DEFAULT_showAllColumns,showFewerColumns:LYRA_DEFAULT_showFewerColumns,tableEditCell:LYRA_DEFAULT_tableEditCell,tableFilterLabel:LYRA_DEFAULT_tableFilterLabel,tableFilterPlaceholder:LYRA_DEFAULT_tableFilterPlaceholder,tableLoading:LYRA_DEFAULT_tableLoading}}static{this.styles=[LyraElement.styles,styles,srOnly]}get columns(){return this._columns}set columns(value){const previous=this._columns,columns=[],seen=new Set;let length=0;try{if(Array.isArray(value)){const descriptor=Object.getOwnPropertyDescriptor(value,"length"),sourceLength=descriptor&&"value"in descriptor?descriptor.value:0;typeof sourceLength=="number"&&Number.isSafeInteger(sourceLength)&&sourceLength>=0&&(length=Math.min(sourceLength,MAX_TABLE_COLLECTION_ENTRIES))}}catch{length=0}for(let index=0;index<length;index+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{continue}if(!descriptor||!("value"in descriptor))continue;const column=descriptor.value;try{const key=column?.key;if(typeof key!="string"||key.trim().length===0||seen.has(key))continue;seen.add(key),columns.push(column)}catch{}}this._columns=frozenArray(columns),this.requestUpdate("columns",previous)}get rows(){return this._rows}set rows(value){const previous=this._rows;this._rows=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("rows",previous)}get layout(){return this._layout}set layout(next){const normalized=TABLE_LAYOUT.normalizeReflected(this,"layout",next),old=this._layout;old!==normalized&&(this._layout=normalized,this.requestUpdate("layout",old))}get selectedRowKeys(){return readonlyKeySet(this._selectedKeys)}set selectedRowKeys(value){const previous=this._selectedKeys;this._selectedKeys=keySet(value??[]),this.requestUpdate("selectedRowKeys",previous)}get expandedRowKeys(){return readonlyKeySet(this._expandedKeys)}set expandedRowKeys(value){const previous=this._expandedKeys;this._expandedKeys=keySet(value??[]),this.requestUpdate("expandedRowKeys",previous)}get storageFullKey(){return this.storageKey?`lr-table:${this.storageKey}`:void 0}parsePixelLength(value){if(!value)return;const trimmed=value.trim();if(!trimmed.endsWith("px"))return;const parsed=Number.parseFloat(trimmed);return Number.isFinite(parsed)?parsed:void 0}minimumResizeWidth(column){const explicit=this.parsePixelLength(column.minWidth);if(explicit!==void 0)return Math.max(0,explicit);const hostStyle=this.ownerDocument.defaultView?.getComputedStyle(this),themed=hostStyle?.getPropertyValue("--lr-table-resize-min-width").trim()||hostStyle?.getPropertyValue("--_lr-table-resize-min-width-default").trim()||"",resolved=resolveCssLength(themed,{host:this});return resolved===void 0?DEFAULT_RESIZE_MIN_WIDTH_PX:Math.max(0,resolved)}maximumResizeWidth(column,minWidth){const explicit=this.parsePixelLength(column.maxWidth);return explicit===void 0?Number.POSITIVE_INFINITY:Math.max(minWidth,explicit)}currentResizeWidth(column,handle){const resized=this.resizedColumnWidths.get(column.key);if(resized!==void 0)return resized;const explicit=this.parsePixelLength(column.width);if(explicit!==void 0)return explicit;const rendered=handle?.closest("th[data-col-key]")?.getBoundingClientRect().width;return rendered&&rendered>0?rendered:this.minimumResizeWidth(column)}resizeColumnTo(column,requestedWidth){const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),width=Math.min(maxWidth,Math.max(minWidth,requestedWidth)),previousWidth=this.resizedColumnWidths.get(column.key);if(previousWidth===width||(this.resizedColumnWidths=new Map(this.resizedColumnWidths).set(column.key,width),!this.emit("lr-column-resize",Object.freeze({columnKey:column.key,width}),{cancelable:!0}).defaultPrevented))return;const reverted=new Map(this.resizedColumnWidths);previousWidth===void 0?reverted.delete(column.key):reverted.set(column.key,previousWidth),this.resizedColumnWidths=reverted}renderedColumnWidth(column){const resized=this.resizedColumnWidths.get(column.key);return resized===void 0?sanitizeCssLength(column.width,"height"):`${resized}px`}renderResizeHandle(column){if(!column.resizable)return nothing;const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth);return html`<span
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isRtl}from"../../../internal/rtl.js";import{srOnly,nextId}from"../../../internal/a11y.js";import{finiteCount,finiteInteger,finiteRatio}from"../../../internal/numbers.js";import{resolveCssLength}from"../../../internal/css-length.js";import{getCollator}from"../../../internal/intl-cache.js";import{readPersistedState,writePersistedState}from"../../../internal/persisted-state.js";import{styles}from"./table.styles.js";import{chevronIcon}from"../../../internal/icons.js";import{minMax}from"../heatmap/heatmap-scale.js";import"../../overlays/empty/empty.class.js";import{literalSetConverter,trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_expand,LYRA_DEFAULT_loadMore,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noColumns,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_resizeColumn,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_showAllColumns,LYRA_DEFAULT_showFewerColumns,LYRA_DEFAULT_tableEditCell,LYRA_DEFAULT_tableFilterLabel,LYRA_DEFAULT_tableFilterPlaceholder,LYRA_DEFAULT_tableLoading}from"../../../internal/default-strings.generated.js";const DEFAULT_SKELETON_ROWS=3,MAX_SKELETON_ROWS=20,DEFAULT_PAGE_SIZE=100,MAX_PAGE_SIZE=500,LOW_PRIORITY_MAX_INLINE_SIZE=899.98,MEDIUM_PRIORITY_MAX_INLINE_SIZE=639.98,MAX_TABLE_COLLECTION_ENTRIES=1e4,DEFAULT_RESIZE_MIN_WIDTH_PX=48,UNBOUNDED_RESIZE_ARIA_MAX=Number.MAX_SAFE_INTEGER;function frozenArray(values){const snapshot=[];try{for(const value of values)if(snapshot.push(value),snapshot.length>=MAX_TABLE_COLLECTION_ENTRIES)break}catch{}return Object.freeze(snapshot)}function keySet(values){const snapshot=new Set;try{for(const value of values){if(typeof value=="string"){if(value.trim().length===0)continue}else if(typeof value!="number")continue;if(snapshot.add(value),snapshot.size>=MAX_TABLE_COLLECTION_ENTRIES)break}}catch{}return snapshot}function readonlyKeySet(values){const snapshot=keySet(values);let facade;return facade={get size(){return snapshot.size},has:value=>snapshot.has(value),entries:()=>snapshot.entries(),keys:()=>snapshot.keys(),values:()=>snapshot.values(),[Symbol.iterator]:()=>snapshot[Symbol.iterator](),forEach(callback,thisArg){snapshot.forEach(value=>callback.call(thisArg,value,value,facade))}},Object.freeze(facade)}const UNSAFE_CSS_STRUCTURE=/[;{}]/,URL_FUNCTION=/url\s*\(/i,SAFE_STYLE_PROPERTY=/^-?[_a-zA-Z][\w-]*$|^--[a-zA-Z0-9_-]+$/,optionalBooleanConverter={fromAttribute(value){if(value!==null)return value!=="false"},toAttribute(value){return value===void 0?null:value?"":"false"}};function isDevelopmentRuntime(){const nodeEnv=globalThis.process?.env?.NODE_ENV;if(nodeEnv==="production")return!1;if(nodeEnv==="development")return!0;const viteEnv=import.meta.env;return typeof viteEnv?.DEV=="boolean"?viteEnv.DEV:viteEnv?.MODE==="development"}const TABLE_LAYOUT=literalSetConverter(["auto","fixed"],"auto"),INTERACTIVE_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 stickyDirection(sticky){if(sticky==="start"||sticky==="end")return sticky}function sanitizeCellStyle(cellStyle){if(cellStyle===void 0)return{};const safe={};for(const[rawProperty,rawValue]of Object.entries(cellStyle)){const property2=sanitizeCellStyleProperty(rawProperty),value=sanitizeCellStyleValue(rawValue);if(property2===void 0||value===void 0)continue;const normalizedProperty=normalizeStyleProperty(property2);(normalizedProperty.startsWith("--")||cssSupports(normalizedProperty,value))&&(safe[normalizedProperty]=value)}return safe}function sanitizeCellStyleProperty(property2){const normalized=property2.trim();if(!(!normalized||!SAFE_STYLE_PROPERTY.test(normalized)))return normalized}function normalizeStyleProperty(property2){return property2.startsWith("--")?property2:property2.replace(/[A-Z]/g,"-$&").toLowerCase()}function sanitizeCellStyleValue(value){if(typeof value!="string")return;const normalized=value.trim();if(!(!normalized||UNSAFE_CSS_STRUCTURE.test(normalized)||URL_FUNCTION.test(normalized)))return normalized}function cssSupports(property2,value){return typeof CSS>"u"||typeof CSS.supports!="function"?!0:CSS.supports(property2,value)}function normalizedEditTrigger(editTrigger){if(editTrigger==="always"||editTrigger==="double-click")return editTrigger}function encodeKey(key){return`${typeof key}:${key}`}function safeStringifyForFilter(row){const seen=new WeakSet;try{return JSON.stringify(row,(_key,value)=>{if(typeof value=="bigint")return value.toString();if(typeof value=="object"&&value!==null){if(seen.has(value))return"[Circular]";seen.add(value)}return value})??""}catch{return""}}function asElement(value){return typeof value!="object"||!("nodeType"in value)||value.nodeType!==1||!("matches"in value)?null:value}function eventInteractiveTarget(event,boundary){for(const value of event.composedPath()){if(value===boundary)break;const element=asElement(value);if(element!==null&&(element.matches("[data-table-interactive]")||element.matches(INTERACTIVE_SELECTOR)&&!element.matches("[data-row-key], th[data-col-key]")))return element}return null}class LyraTable extends LyraElement{constructor(){super(...arguments),this._columns=Object.freeze([]),this._rows=Object.freeze([]),this._layout="auto",this.sortKey="",this.sortDir="asc",this.sortMode="client",this.defaultSortDir="asc",this.caption="",this.captionId=nextId("lr-table-caption"),this.selectionMode="none",this.scrollMode="self",this._selectedKeys=new Set,this.filterable=!1,this.filterText="",this.spellcheck=!0,this.autocapitalize="",this.autoCorrect="",this.loading=!1,this.loadingAppearance="spinner",this.skeletonRows=0,this.pageSize=DEFAULT_PAGE_SIZE,this.page=1,this.totalItems=-1,this.paginationMode="client",this._expandedKeys=new Set,this.hasMore=!1,this.emptyDescription="",this.noColumnsDescription="",this.hasHiddenPriorityColumns=!1,this.priorityColumnsToggleAvailable=!1,this.priorityColumnsVisible=!1,this.persistReady=!1,this.loadingAnnouncementsReady=!1,this.activeColKey=null,this.activeRowKey=null,this.editingCell=null,this.focusedEditorCell=null,this.editorHadFocusBeforeUpdate=!1,this.rovingFocusSnapshot=null,this.resizedColumnWidths=new Map,this.rowsByKey=new Map,this.columnsByKey=new Map,this.layoutFrame=null,this.observedHeaders=new Set,this.onResizePointerDown=event=>{const handle=event.currentTarget,key=handle.dataset.colKey,column=key?this.columnsByKey.get(key):void 0,header=handle.closest("th[data-col-key]"),resizeEventWindow=this.ownerDocument.defaultView;if(!key||!column||!header||!resizeEventWindow)return;const replacedStartWidth=this.resizeState?.key===key?this.resizeState.startWidth:void 0;this.cancelResizeGesture();const minWidth=this.minimumResizeWidth(column);this.resizeState={key,pointerId:event.pointerId,startX:event.clientX,startWidth:replacedStartWidth??header.getBoundingClientRect().width,minWidth,maxWidth:this.maximumResizeWidth(column,minWidth),handle,previousWidth:this.resizedColumnWidths.get(key)},handle.toggleAttribute("data-resizing",!0),event.preventDefault(),event.stopPropagation(),handle.setPointerCapture?.(event.pointerId),this.resizeEventWindow=resizeEventWindow,resizeEventWindow.addEventListener("pointermove",this.onResizePointerMove),resizeEventWindow.addEventListener("pointerup",this.onResizePointerEnd),resizeEventWindow.addEventListener("pointercancel",this.onResizePointerEnd),resizeEventWindow.addEventListener("lostpointercapture",this.onResizePointerEnd)},this.onResizePointerMove=event=>{const state2=this.resizeState;if(!state2||event.pointerId!==state2.pointerId)return;const delta=isRtl(this)?state2.startX-event.clientX:event.clientX-state2.startX,width=Math.min(state2.maxWidth,Math.max(state2.minWidth,state2.startWidth+delta));this.resizedColumnWidths.get(state2.key)!==width&&(this.resizedColumnWidths=new Map(this.resizedColumnWidths).set(state2.key,width),this.emit("lr-column-resize",Object.freeze({columnKey:state2.key,width})))},this.onResizeKeyDown=event=>{const handle=event.currentTarget,key=handle.dataset.colKey,column=key?this.columnsByKey.get(key):void 0;if(!column)return;const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),currentWidth=this.currentResizeWidth(column,handle),step=event.shiftKey?50:10;let requestedWidth;event.key==="Home"?requestedWidth=minWidth:event.key==="End"&&Number.isFinite(maxWidth)?requestedWidth=maxWidth:event.key==="ArrowLeft"?requestedWidth=currentWidth+(isRtl(this)?step:-step):event.key==="ArrowRight"&&(requestedWidth=currentWidth+(isRtl(this)?-step:step)),requestedWidth!==void 0&&(event.preventDefault(),event.stopPropagation(),this.resizeColumnTo(column,requestedWidth))},this.onResizePointerEnd=event=>{const state2=this.resizeState;if(!state2||event.pointerId!==state2.pointerId)return;if(state2.handle.removeAttribute("data-resizing"),event.type==="pointerup")try{state2.handle.releasePointerCapture?.(event.pointerId)}catch{}if(this.resizeState=void 0,this.detachResizePointerListeners(),event.type!=="pointerup"){const reverted2=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted2.delete(state2.key):reverted2.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted2;return}const committedWidth=this.resizedColumnWidths.get(state2.key);if(committedWidth===void 0||committedWidth===state2.previousWidth||!this.emit("lr-column-resize",Object.freeze({columnKey:state2.key,width:committedWidth}),{cancelable:!0}).defaultPrevented)return;const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted},this.scheduleLayoutSync=()=>{if(this.layoutFrame)return;const owner=this.ownerDocument.defaultView;if(!owner)return;const frame={owner,handle:0};frame.handle=owner.requestAnimationFrame(()=>{this.layoutFrame===frame&&(this.layoutFrame=null,!(!this.isConnected||this.ownerDocument.defaultView!==owner)&&(this.recomputeHiddenPriorityColumns(),this.applyStickyOffsets(),this.syncResizeHandleValues()))}),this.layoutFrame=frame},this.cachedCanonicalRowEntries=null,this.canonicalRowEntriesInputs=null,this.cachedMatchingEntries=null,this.matchingEntriesInputs=null,this.cachedSortedEntries=null,this.sortedEntriesInputs=null,this.onFilterInput=event=>{event.stopPropagation();const input=event.currentTarget;this.filterText=input.value,this.emit("lr-filter-change",Object.freeze({text:this.filterText}))},this.stopOwnedEvent=event=>{event.stopPropagation()},this.onNativeFocus=event=>{event.stopPropagation(),this.emit("focus")},this.onNativeBlur=event=>{event.stopPropagation(),this.emit("blur")},this.onPaginationChange=event=>{event.stopPropagation();const{page}=event.detail;this.paginationMode==="client"&&(this.page=page),this.emit("lr-page-change",Object.freeze({page}))},this.onTableFocusIn=event=>{const target=event.target,cell=target?.closest?.("td[data-col-key]"),row=target?.closest?.("[data-row-key]"),columnKey=cell?.dataset.colKey,rowKey=row?.dataset.rowKey;this.focusedEditorCell=target?.getAttribute("part")==="cell-editor"&&columnKey!==void 0&&rowKey!==void 0&&normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="always"?{rowKey,columnKey}:null},this.onEditorKeyDown=(event,rowKey,columnKey)=>{event.stopPropagation();const alwaysOn=normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="always";event.key==="Enter"?(event.preventDefault(),this.commitEdit(event,rowKey,columnKey)):event.key==="Escape"&&!alwaysOn&&(event.preventDefault(),this.editingCell=null)},this.onTableDoubleClick=event=>{const target=event.target,table=event.currentTarget;if(eventInteractiveTarget(event,table))return;const cell=target.closest('[part="cell"][data-col-key]'),row=target.closest("[data-row-key]");cell&&row?.dataset.rowKey&&cell.dataset.colKey&&this.startEditing(row.dataset.rowKey,cell.dataset.colKey)},this.toggleColumns=()=>{this.priorityColumnsVisible=!this.priorityColumnsVisible,this.emit("lr-priority-columns-visibility-change",Object.freeze({visible:this.priorityColumnsVisible}))},this.onTableClick=e=>{const target=e.target,table=e.currentTarget;if(eventInteractiveTarget(e,table))return;const th=target.closest("th[data-col-key]");if(th)return this.activateColumn(th.dataset.colKey);const tr=target.closest("[data-row-key]");tr&&this.activateRow(tr.dataset.rowKey)},this.onTableKeyDown=e=>{const target=e.target,table=e.currentTarget;if(eventInteractiveTarget(e,table))return;const th=target.closest("th[data-col-key]");if(th)return this.onHeaderKeyDown(e,th);const tr=target.closest("[data-row-key]");tr&&this.onRowKeyDown(e,tr)},this.reportedMissingCellColumns=new Set}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,expand:LYRA_DEFAULT_expand,loadMore:LYRA_DEFAULT_loadMore,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noColumns:LYRA_DEFAULT_noColumns,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,resizeColumn:LYRA_DEFAULT_resizeColumn,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,showAllColumns:LYRA_DEFAULT_showAllColumns,showFewerColumns:LYRA_DEFAULT_showFewerColumns,tableEditCell:LYRA_DEFAULT_tableEditCell,tableFilterLabel:LYRA_DEFAULT_tableFilterLabel,tableFilterPlaceholder:LYRA_DEFAULT_tableFilterPlaceholder,tableLoading:LYRA_DEFAULT_tableLoading}}static{this.styles=[LyraElement.styles,styles,srOnly]}get columns(){return this._columns}set columns(value){const previous=this._columns,columns=[],seen=new Set;let length=0;try{if(Array.isArray(value)){const descriptor=Object.getOwnPropertyDescriptor(value,"length"),sourceLength=descriptor&&"value"in descriptor?descriptor.value:0;typeof sourceLength=="number"&&Number.isSafeInteger(sourceLength)&&sourceLength>=0&&(length=Math.min(sourceLength,MAX_TABLE_COLLECTION_ENTRIES))}}catch{length=0}for(let index=0;index<length;index+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{continue}if(!descriptor||!("value"in descriptor))continue;const column=descriptor.value;try{const key=column?.key;if(typeof key!="string"||key.trim().length===0||seen.has(key))continue;seen.add(key),columns.push(column)}catch{}}this._columns=frozenArray(columns),this.requestUpdate("columns",previous)}get rows(){return this._rows}set rows(value){const previous=this._rows;this._rows=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("rows",previous)}get layout(){return this._layout}set layout(next){const normalized=TABLE_LAYOUT.normalizeReflected(this,"layout",next),old=this._layout;old!==normalized&&(this._layout=normalized,this.requestUpdate("layout",old))}get selectedRowKeys(){return readonlyKeySet(this._selectedKeys)}set selectedRowKeys(value){const previous=this._selectedKeys;this._selectedKeys=keySet(value??[]),this.requestUpdate("selectedRowKeys",previous)}get expandedRowKeys(){return readonlyKeySet(this._expandedKeys)}set expandedRowKeys(value){const previous=this._expandedKeys;this._expandedKeys=keySet(value??[]),this.requestUpdate("expandedRowKeys",previous)}get storageFullKey(){return this.storageKey?`lr-table:${this.storageKey}`:void 0}parsePixelLength(value){if(!value)return;const trimmed=value.trim();if(!trimmed.endsWith("px"))return;const parsed=Number.parseFloat(trimmed);return Number.isFinite(parsed)?parsed:void 0}minimumResizeWidth(column){const explicit=this.parsePixelLength(column.minWidth);if(explicit!==void 0)return Math.max(0,explicit);const hostStyle=this.ownerDocument.defaultView?.getComputedStyle(this),themed=hostStyle?.getPropertyValue("--lr-table-resize-min-width").trim()||hostStyle?.getPropertyValue("--_lr-table-resize-min-width-default").trim()||"",resolved=resolveCssLength(themed,{host:this});return resolved===void 0?DEFAULT_RESIZE_MIN_WIDTH_PX:Math.max(0,resolved)}maximumResizeWidth(column,minWidth){const explicit=this.parsePixelLength(column.maxWidth);return explicit===void 0?Number.POSITIVE_INFINITY:Math.max(minWidth,explicit)}currentResizeWidth(column,handle){const resized=this.resizedColumnWidths.get(column.key);if(resized!==void 0)return resized;const explicit=this.parsePixelLength(column.width);if(explicit!==void 0)return explicit;const rendered=handle?.closest("th[data-col-key]")?.getBoundingClientRect().width;return rendered&&rendered>0?rendered:this.minimumResizeWidth(column)}resizeColumnTo(column,requestedWidth){const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),width=Math.min(maxWidth,Math.max(minWidth,requestedWidth)),previousWidth=this.resizedColumnWidths.get(column.key);if(previousWidth===width||(this.resizedColumnWidths=new Map(this.resizedColumnWidths).set(column.key,width),!this.emit("lr-column-resize",Object.freeze({columnKey:column.key,width}),{cancelable:!0}).defaultPrevented))return;const reverted=new Map(this.resizedColumnWidths);previousWidth===void 0?reverted.delete(column.key):reverted.set(column.key,previousWidth),this.resizedColumnWidths=reverted}renderedColumnWidth(column){const resized=this.resizedColumnWidths.get(column.key);return resized===void 0?sanitizeCssLength(column.width,"height"):`${resized}px`}renderResizeHandle(column){if(!column.resizable)return nothing;const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth);return html`<span
|
|
2
2
|
part="resize-handle"
|
|
3
3
|
data-col-key=${column.key}
|
|
4
4
|
role="separator"
|
|
@@ -10,7 +10,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
10
10
|
aria-valuemax=${Number.isFinite(maxWidth)?Math.round(maxWidth):UNBOUNDED_RESIZE_ARIA_MAX}
|
|
11
11
|
@pointerdown=${this.onResizePointerDown}
|
|
12
12
|
@keydown=${this.onResizeKeyDown}
|
|
13
|
-
></span>`}syncResizeHandleValues(){for(const handle of this.renderRoot.querySelectorAll('[part="resize-handle"]')){const key=handle.dataset.colKey;if(!key)continue;const column=this.columnsByKey.get(key);if(!column||this.resizedColumnWidths.has(key)||this.parsePixelLength(column.width)!==void 0)continue;const rendered=handle.closest("th[data-col-key]")?.getBoundingClientRect().width;rendered&&rendered>0&&handle.setAttribute("aria-valuenow",String(Math.round(rendered)))}}detachResizePointerListeners(){const resizeEventWindow=this.resizeEventWindow;resizeEventWindow&&(resizeEventWindow.removeEventListener("pointermove",this.onResizePointerMove),resizeEventWindow.removeEventListener("pointerup",this.onResizePointerEnd),resizeEventWindow.removeEventListener("pointercancel",this.onResizePointerEnd),resizeEventWindow.removeEventListener("lostpointercapture",this.onResizePointerEnd),this.resizeEventWindow=void 0)}rollbackResizePreview(state2){const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted}cancelResizeGesture(){const state2=this.resizeState;if(this.resizeState=void 0,this.detachResizePointerListeners(),!!state2){state2.handle.removeAttribute("data-resizing");try{state2.handle.releasePointerCapture?.(state2.pointerId)}catch{}this.rollbackResizePreview(state2)}}firstUpdated(changed){super.firstUpdated(changed),isDevelopmentRuntime()&&!this.accessibleLabel&&!this.hasAttribute("aria-label")&&!this.caption&&console.warn("<lr-table> has no accessible name: set `accessibleLabel`, a host `aria-label`, or `caption` so assistive technology can identify the grid.")}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink();const owner=this.ownerDocument.defaultView,ResizeObserverCtor=owner?.ResizeObserver;let observer;ResizeObserverCtor&&(observer=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.resizeObserver!==observer||this.scheduleLayoutSync()})),this.resizeObserver=observer;const base=this.renderRoot?.querySelector('[part="base"]');base&&(this.observeBase(base),this.observeHeaders())}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink(),this.cancelResizeGesture(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0;const frame=this.layoutFrame;frame&&frame.owner.cancelAnimationFrame(frame.handle),this.layoutFrame=null,this.observedBase=void 0,this.observedHeaders.clear()}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}localizedOverride(key,override){return override??this.localize(key)}loadingText(){return this.localizedOverride("tableLoading",this.loadingLabel)}observeBase(base){this.observedBase!==base&&(this.observedBase&&this.resizeObserver?.unobserve(this.observedBase),this.resizeObserver?.observe(base),this.observedBase=base)}observeHeaders(){const headers=new Set(this.columns.some(column=>column.sticky||column.resizable)?this.renderRoot.querySelectorAll("th[data-col-key]"):[]);for(const header of this.observedHeaders)headers.has(header)||(this.resizeObserver?.unobserve(header),this.observedHeaders.delete(header));for(const header of headers)this.observedHeaders.has(header)||(this.observedHeaders.add(header),this.resizeObserver?.observe(header))}recomputeHiddenPriorityColumns(){const hasPriorityColumns=this.columns.some(col=>col.priority),anyPriorityHidden=hasPriorityColumns&&[...this.renderRoot.querySelectorAll("th[data-priority]")].some(el=>el.offsetParent===null),inlineSize=this.renderRoot.querySelector('[part="base"]')?.clientWidth??0,wouldHideAtAllocation=hasPriorityColumns&&inlineSize>0&&this.columns.some(column=>column.priority==="low"&&inlineSize<=LOW_PRIORITY_MAX_INLINE_SIZE||column.priority==="medium"&&inlineSize<=MEDIUM_PRIORITY_MAX_INLINE_SIZE),toggleAvailable=anyPriorityHidden||this.priorityColumnsVisible&&wouldHideAtAllocation;this.rehomeFocusedColumn(),this.priorityColumnsToggleAvailable!==toggleAvailable&&(this.priorityColumnsToggleAvailable=toggleAvailable),this.hasHiddenPriorityColumns!==anyPriorityHidden&&(this.hasHiddenPriorityColumns=anyPriorityHidden)}rehomeFocusedColumn(){const visible=this.visibleHeaders();visible.length===0||this.activeColKey===null||visible.some(header=>header.dataset.colKey===this.activeColKey)||(this.activeColKey=visible[0].dataset.colKey??null)}keyOf(row,index){try{const key=this.rowKey?this.rowKey(row):index;return typeof key=="string"?key.trim().length===0?void 0:key:typeof key=="number"?key:void 0}catch{return}}canonicalRowEntries(){const inputs=this.canonicalRowEntriesInputs;if(this.cachedCanonicalRowEntries!==null&&inputs?.rows===this.rows&&inputs.rowKey===this.rowKey)return this.cachedCanonicalRowEntries;const entries=[],seen=new Set;return this.rows.forEach((row,index)=>{const key=this.keyOf(row,index);if(key===void 0)return;const encoded=encodeKey(key);seen.has(encoded)||(seen.add(encoded),entries.push({row,index,key}))}),this.canonicalRowEntriesInputs={rows:this.rows,rowKey:this.rowKey},this.cachedCanonicalRowEntries=entries,entries}matchingEntries(){const text=this.filterText.trim(),locale=text===""?"":this.effectiveLocale,canonicalEntries=this.canonicalRowEntries(),inputs=this.matchingEntriesInputs;if(this.cachedMatchingEntries!==null&&inputs!==null&&inputs.entries===canonicalEntries&&inputs.filter===this.filter&&inputs.text===text&&inputs.locale===locale)return this.cachedMatchingEntries;let entries;if(text==="")entries=canonicalEntries;else{const intlLocale=this.effectiveLocale,normalized=text.toLocaleLowerCase(intlLocale);entries=canonicalEntries.filter(({row})=>this.filter?this.filter(row,text):safeStringifyForFilter(row).toLocaleLowerCase(intlLocale).includes(normalized))}return this.matchingEntriesInputs={entries:canonicalEntries,filter:this.filter,text,locale},this.cachedMatchingEntries=entries,entries}get normalizedPageSize(){return finiteInteger(this.pageSize,DEFAULT_PAGE_SIZE,1,MAX_PAGE_SIZE)}get effectiveSkeletonRows(){const explicit=finiteCount(this.skeletonRows,0,MAX_SKELETON_ROWS);if(explicit>0)return explicit;const pageSize=this.normalizedPageSize;return pageSize===DEFAULT_PAGE_SIZE?DEFAULT_SKELETON_ROWS:Math.min(pageSize,MAX_SKELETON_ROWS)}get matchingTotalItems(){const totalItems=finiteInteger(this.totalItems,-1);return totalItems>=0?totalItems:this.matchingEntries().length}get pageCount(){const pageSize=this.normalizedPageSize;return pageSize>0?Math.ceil(this.matchingTotalItems/pageSize):0}get appliedPage(){return this.pageCount===0?1:finiteInteger(this.page,1,1,this.pageCount)}sortedEntries(){const entries=this.matchingEntries();if(this.sortMode!=="client"||this.sortKey==="")return entries;const col=this.columnsByKey.get(this.sortKey);if(!col?.sortable)return entries;const locale=this.effectiveLocale,inputs=this.sortedEntriesInputs;if(this.cachedSortedEntries!==null&&inputs!==null&&inputs.entries===entries&&inputs.columns===this.columns&&inputs.mode===this.sortMode&&inputs.key===this.sortKey&&inputs.dir===this.sortDir&&inputs.locale===locale&&inputs.groupBy===this.groupBy)return this.cachedSortedEntries;const collator=getCollator(locale,{numeric:!0}),dir=this.sortDir==="desc"?-1:1,decorated=entries.map(entry=>{const raw=col.sortValue?col.sortValue(entry.row):String(col.cell(entry.row)??"");return{entry,value:typeof raw=="number"&&!Number.isFinite(raw)?null:raw}}),compare=(a,b)=>{const av=a.value,bv=b.value;return av==null&&bv==null?0:av==null?1:bv==null?-1:typeof av=="number"&&typeof bv=="number"?(av-bv)*dir:collator.compare(String(av),String(bv))*dir};let sorted;const groupBy=this.groupBy;if(groupBy===void 0)decorated.sort(compare),sorted=decorated.map(decoration=>decoration.entry);else{const buckets=new Map;for(const decoration of decorated){const groupKey=groupBy(decoration.entry.row),bucket=buckets.get(groupKey);bucket===void 0?buckets.set(groupKey,[decoration]):bucket.push(decoration)}const ordered=[...buckets.values()],constantWithinEveryGroup=ordered.every(bucket=>bucket.every(decoration=>compare(decoration,bucket[0])===0));constantWithinEveryGroup&&ordered.sort((a,b)=>compare(a[0],b[0])),sorted=[];for(const bucket of ordered){constantWithinEveryGroup||bucket.sort(compare);for(const decoration of bucket)sorted.push(decoration.entry)}}return this.sortedEntriesInputs={entries,columns:this.columns,mode:this.sortMode,key:this.sortKey,dir:this.sortDir,locale,groupBy},this.cachedSortedEntries=sorted,sorted}renderedEntries(){const entries=this.sortedEntries();if(this.paginationMode==="server")return entries.slice(0,this.normalizedPageSize);const start=(this.appliedPage-1)*this.normalizedPageSize;return entries.slice(start,start+this.normalizedPageSize)}focusedColKey(){const visible=this.visibleHeaders(),visibleKeys=new Set(visible.map(el=>el.dataset.colKey).filter(key=>key!==void 0&&this.columnsByKey.has(key)));return this.activeColKey!==null&&this.columnsByKey.has(this.activeColKey)&&(visibleKeys.size===0||visibleKeys.has(this.activeColKey))?this.activeColKey:visible.find(el=>el.dataset.colKey!==void 0&&this.columnsByKey.has(el.dataset.colKey))?.dataset.colKey??this.columns[0]?.key??null}focusedRowKey(){if(this.activeRowKey!==null&&this.rowsByKey.has(this.activeRowKey))return this.activeRowKey;const selectedKey=this._selectedKeys.values().next().value;if(selectedKey!==void 0){const selected=encodeKey(selectedKey);if(this.rowsByKey.has(selected))return selected}const first=this.renderedEntries()[0];return first?encodeKey(first.key):null}rowsAffectingRovingFocusChanged(changed){return changed.has("rows")||changed.has("rowKey")||changed.has("filterText")||changed.has("filter")||changed.has("page")||changed.has("pageSize")||changed.has("paginationMode")||changed.has("totalItems")||changed.has("columns")||changed.has("sortKey")||changed.has("sortDir")||changed.has("sortMode")||changed.has("groupBy")}captureRovingFocus(changed){this.rovingFocusSnapshot=null;const active=activeElementIn(this.shadowRoot),HTMLElementCtor=this.ownerDocument?.defaultView?.HTMLElement;if(!(!HTMLElementCtor||!(active instanceof HTMLElementCtor))){if(changed.has("columns")&&active.matches("th[data-col-key]")){const headers=this.visibleHeaders(),key=active.dataset.colKey,index=headers.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"header",key,index,targetKey:null,element:active});return}if(this.rowsAffectingRovingFocusChanged(changed)&&active.matches("tr[data-row-key]")){const renderedRows=[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],key=active.dataset.rowKey,index=renderedRows.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"row",key,index,targetKey:null,element:active})}}}resolveRovingFocusTarget(){const snapshot=this.rovingFocusSnapshot;if(snapshot===null)return;const keys=snapshot.kind==="header"?this.columns.map(column=>column.key):[...this.rowsByKey.keys()];snapshot.targetKey=keys.includes(snapshot.key)?snapshot.key:keys[Math.min(snapshot.index,keys.length-1)]??null,snapshot.kind==="header"?this.activeColKey=snapshot.targetKey:this.activeRowKey=snapshot.targetKey}willUpdate(changed){if(super.willUpdate(changed),this.captureRovingFocus(changed),this.selectionMode==="single"&&this._selectedKeys.size>1&&(changed.has("selectionMode")||changed.has("selectedRowKeys"))){const first=this._selectedKeys.values().next().value;if(this.selectedRowKeys=first===void 0?new Set:new Set([first]),this.hasUpdated){const rowKeys=Object.freeze(first===void 0?[]:[first]);this.emit("lr-selection-change",Object.freeze({rowKeys}))}}if(!this.hasUpdated){const parsed=readPersistedState(this.storageFullKey,v=>typeof v=="object"&&v!==null);parsed&&typeof parsed.priorityColumnsVisible=="boolean"&&(this.priorityColumnsVisible=parsed.priorityColumnsVisible)}if(changed.has("columns")&&(this.columnsByKey=new Map(this.columns.map(c=>[c.key,c]))),(changed.has("rows")||changed.has("rowKey")||changed.has("filterText")||changed.has("filter")||changed.has("page")||changed.has("pageSize")||changed.has("paginationMode")||changed.has("totalItems")||changed.has("columns")||changed.has("sortKey")||changed.has("sortDir")||changed.has("sortMode")||changed.has("groupBy"))&&(this.rowsByKey=new Map(this.renderedEntries().map(entry=>[encodeKey(entry.key),entry]))),this.resolveRovingFocusTarget(),this.editingCell!==null){const column=this.columnsByKey.get(this.editingCell.columnKey);(!this.rowsByKey.has(this.editingCell.rowKey)||normalizedEditTrigger(column?.editTrigger)!=="double-click")&&(this.editingCell=null)}this.editorHadFocusBeforeUpdate=this.focusedEditorCell!==null&&activeElementIn(this.shadowRoot)===this.editorElementFor(this.focusedEditorCell.rowKey,this.focusedEditorCell.columnKey)}stickyOffsets(){const offsets=new Map,headerWidths=new Map;for(const el of this.renderRoot.querySelectorAll("th[data-col-key]")){const key=el.dataset.colKey;key!==void 0&&!headerWidths.has(key)&&headerWidths.set(key,el.offsetWidth)}const headerWidth=key=>headerWidths.get(key)??0;let runningStart=0;for(const col of this.columns)stickyDirection(col.sticky)==="start"&&(offsets.set(col.key,runningStart),runningStart+=headerWidth(col.key));let runningEnd=0;for(let i=this.columns.length-1;i>=0;i--){const col=this.columns[i];col&&stickyDirection(col.sticky)==="end"&&(offsets.set(col.key,runningEnd),runningEnd+=headerWidth(col.key))}return offsets}computeHeatDomain(hasHeatTint){if(!hasHeatTint)return null;const values=[];for(const entry of this.matchingEntries())for(const col of this.columns){const v=col.heatValue?.(entry.row);v!=null&&Number.isFinite(v)&&values.push(v)}const auto=minMax(values),lo=this.heatTintScale?.min??auto?.[0],hi=this.heatTintScale?.max??auto?.[1];return lo===void 0||hi===void 0?null:[lo,hi]}heatShare(col,row,domain){if(!col.heatValue||!domain)return null;const v=col.heatValue(row);if(v==null||!Number.isFinite(v))return null;const[lo,hi]=domain;return`${(finiteRatio(v,lo,hi)*100).toFixed(2)}%`}applyStickyOffsets(){if(!this.columns.some(c=>c.sticky))return;const offsets=this.stickyOffsets();this.renderRoot.querySelectorAll("[data-col-key]").forEach(el=>{const key=el.dataset.colKey;key!==void 0&&offsets.has(key)&&el.style.setProperty("--lr-table-sticky-offset",`${offsets.get(key)}px`)})}updated(changed){super.updated(changed),this.loadingAnnouncementsReady&&changed.has("loading")&&this.loading&&this.announcementSink?.announce(this.loadingText()),this.loadingAnnouncementsReady=!0,this.persistReady&&changed.has("priorityColumnsVisible")&&writePersistedState(this.storageFullKey,{priorityColumnsVisible:this.priorityColumnsVisible}),this.persistReady=!0,(changed.has("columns")||changed.has("rows")||changed.has("rowKey"))&&this.applyStickyOffsets(),this.syncResizeHandleValues();const base=this.renderRoot.querySelector('[part="base"]');if(base&&this.observeBase(base),this.observeHeaders(),this.restoreRovingFocus(),this.hasAlwaysOnEditors&&this.restoreAlwaysOnEditorFocus(),changed.has("editingCell")&&this.editingCell){const{rowKey,columnKey}=this.editingCell;queueMicrotask(()=>this.editorElementFor(rowKey,columnKey)?.focus())}queueMicrotask(()=>this.recomputeHiddenPriorityColumns())}restoreRovingFocus(){const snapshot=this.rovingFocusSnapshot;if(this.rovingFocusSnapshot=null,snapshot===null)return;const internalActive=activeElementIn(this.shadowRoot);if(internalActive!==null&&internalActive!==snapshot.element)return;const documentActive=activeElementIn(this.ownerDocument);if(documentActive!==null&&documentActive!==this&&documentActive!==this.ownerDocument.body)return;const candidates=snapshot.kind==="header"?this.visibleHeaders():[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],target=candidates.find(candidate=>snapshot.kind==="header"?candidate.dataset.colKey===snapshot.targetKey:candidate.dataset.rowKey===snapshot.targetKey)??candidates[Math.min(snapshot.index,candidates.length-1)]??null;snapshot.kind==="header"?this.focusHeader(target):this.focusRow(target)}activateColumn(key){this.activeColKey=key;const col=this.columnsByKey.get(key);if(!col?.sortable)return;const sortDir=this.sortKey===key?this.sortDir==="asc"?"desc":"asc":this.defaultSortDir,request=Object.freeze({phase:"request",sortKey:col.key,sortDir});this.emit("lr-sort-request",request,{cancelable:!0}).defaultPrevented||(this.sortMode==="client"&&(this.sortKey=col.key,this.sortDir=sortDir),this.emit("lr-sort",Object.freeze({phase:"commit",sortKey:col.key,sortDir})))}activateRow(key){this.activeRowKey=key;const entry=this.rowsByKey.get(key);if(entry===void 0)return;const{row,key:selectedKey}=entry;if(this.emit("lr-row-click",Object.freeze({row})),this.selectionMode==="single"){this.selectedRowKeys=new Set([selectedKey]);const rowKeys=Object.freeze([selectedKey]);this.emit("lr-selection-change",Object.freeze({rowKeys}))}else if(this.selectionMode==="multiple"){const rawKey=selectedKey,next=new Set(this._selectedKeys);next.has(rawKey)?next.delete(rawKey):next.add(rawKey),this.selectedRowKeys=next;const rowKeys=Object.freeze([...next]);this.emit("lr-selection-change",Object.freeze({rowKeys}))}}get hasAlwaysOnEditors(){return this.columns.some(col=>normalizedEditTrigger(col.editTrigger)==="always")}editorValue(row,column){const value=column.editValue?.(row)??row[column.key]??"";return String(value)}startEditing(rowKey,columnKey){const column=this.columnsByKey.get(columnKey);normalizedEditTrigger(column?.editTrigger)!=="double-click"||!this.rowsByKey.has(rowKey)||(this.editingCell={rowKey,columnKey})}commitEdit(event,rowKey,columnKey){event.stopPropagation();const input=event.currentTarget,entry=this.rowsByKey.get(rowKey),column=this.columnsByKey.get(columnKey),isTransient=this.editingCell?.rowKey===rowKey&&this.editingCell.columnKey===columnKey;if(!entry||!column||normalizedEditTrigger(column.editTrigger)===void 0){isTransient&&(this.editingCell=null);return}const value=column.editType==="number"&&input.value!==""?Number(input.value):input.value;this.emit("lr-cell-edit",Object.freeze({row:entry.row,columnKey,value})),isTransient&&(this.editingCell=null)}editorElementFor(rowKey,columnKey){const row=[...this.renderRoot.querySelectorAll("[data-row-key]")].find(el=>el.dataset.rowKey===rowKey);return(row?[...row.querySelectorAll("td[data-col-key]")].find(el=>el.dataset.colKey===columnKey):void 0)?.querySelector('[part="cell-editor"]')??null}restoreAlwaysOnEditorFocus(){const cell=this.focusedEditorCell;if(cell===null)return;const editor=this.editorElementFor(cell.rowKey,cell.columnKey);editor===null?this.focusedEditorCell=null:this.editorHadFocusBeforeUpdate&&activeElementIn(this.shadowRoot)!==editor&&editor.focus(),this.editorHadFocusBeforeUpdate=!1}activateExpandToggle(key){const entry=this.rowsByKey.get(encodeKey(key));entry!==void 0&&this.emit("lr-row-expand-toggle",Object.freeze({row:entry.row,rowKey:key}))}visibleHeaders(){return[...this.renderRoot?.querySelectorAll("th[data-col-key]")??[]].filter(el=>el.offsetParent!==null)}focusHeader(el){el?.dataset.colKey&&(this.activeColKey=el.dataset.colKey,el.focus())}focusRow(el){el?.dataset.rowKey&&(this.activeRowKey=el.dataset.rowKey,el.focus())}onHeaderKeyDown(e,th){if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateColumn(th.dataset.colKey);return}const headers=this.visibleHeaders(),index=headers.indexOf(th);if(index<0)return;const rtl=isRtl(this);switch(e.key){case"ArrowLeft":e.preventDefault(),this.focusHeader(headers[rtl?Math.min(headers.length-1,index+1):Math.max(0,index-1)]??null);return;case"ArrowRight":e.preventDefault(),this.focusHeader(headers[rtl?Math.max(0,index-1):Math.min(headers.length-1,index+1)]??null);return;case"Home":e.preventDefault(),this.focusHeader(headers[0]??null);return;case"End":e.preventDefault(),this.focusHeader(headers[headers.length-1]??null);return;case"ArrowDown":{e.preventDefault();const rows=[...this.renderRoot.querySelectorAll("[data-row-key]")],key=this.focusedRowKey();this.focusRow(rows.find(r=>r.dataset.rowKey===key)??rows[0]??null);return}default:return}}onRowKeyDown(e,tr){if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateRow(tr.dataset.rowKey);return}const bodyRows=[...this.renderRoot.querySelectorAll("[data-row-key]")],index=bodyRows.indexOf(tr);if(!(index<0))switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(bodyRows[Math.min(bodyRows.length-1,index+1)]??null);return;case"ArrowUp":if(e.preventDefault(),index===0){const headers=this.visibleHeaders(),key=this.focusedColKey();this.focusHeader(headers.find(h=>h.dataset.colKey===key)??headers[0]??null)}else this.focusRow(bodyRows[index-1]??null);return;case"Home":e.preventDefault(),this.focusRow(bodyRows[0]??null);return;case"End":e.preventDefault(),this.focusRow(bodyRows[bodyRows.length-1]??null);return;default:return}}renderCellEditor(row,col,rowKey,alwaysOn){const type=col.editType??"text",isText=type==="text",value=this.editorValue(row,col),label=this.localize("tableEditCell",void 0,{column:col.label}),spellcheck=isText?this.spellcheck:nothing,autocapitalize=isText?this.autocapitalize||nothing:nothing,autocorrect=isText?this.autoCorrect||nothing:nothing,onChange=event=>this.commitEdit(event,rowKey,col.key),onKeyDown=event=>this.onEditorKeyDown(event,rowKey,col.key);return alwaysOn?html`<input
|
|
13
|
+
></span>`}syncResizeHandleValues(){for(const handle of this.renderRoot.querySelectorAll('[part="resize-handle"]')){const key=handle.dataset.colKey;if(!key)continue;const column=this.columnsByKey.get(key);if(!column||this.resizedColumnWidths.has(key)||this.parsePixelLength(column.width)!==void 0)continue;const rendered=handle.closest("th[data-col-key]")?.getBoundingClientRect().width;rendered&&rendered>0&&handle.setAttribute("aria-valuenow",String(Math.round(rendered)))}}detachResizePointerListeners(){const resizeEventWindow=this.resizeEventWindow;resizeEventWindow&&(resizeEventWindow.removeEventListener("pointermove",this.onResizePointerMove),resizeEventWindow.removeEventListener("pointerup",this.onResizePointerEnd),resizeEventWindow.removeEventListener("pointercancel",this.onResizePointerEnd),resizeEventWindow.removeEventListener("lostpointercapture",this.onResizePointerEnd),this.resizeEventWindow=void 0)}rollbackResizePreview(state2){const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted}cancelResizeGesture(){const state2=this.resizeState;if(this.resizeState=void 0,this.detachResizePointerListeners(),!!state2){state2.handle.removeAttribute("data-resizing");try{state2.handle.releasePointerCapture?.(state2.pointerId)}catch{}this.rollbackResizePreview(state2)}}firstUpdated(changed){super.firstUpdated(changed),isDevelopmentRuntime()&&!this.accessibleLabel&&!this.hasAttribute("aria-label")&&!this.caption&&console.warn("<lr-table> has no accessible name: set `accessibleLabel`, a host `aria-label`, or `caption` so assistive technology can identify the grid.")}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink();const owner=this.ownerDocument.defaultView,ResizeObserverCtor=owner?.ResizeObserver;let observer;ResizeObserverCtor&&(observer=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.resizeObserver!==observer||this.scheduleLayoutSync()})),this.resizeObserver=observer;const base=this.renderRoot?.querySelector('[part="base"]');base&&(this.observeBase(base),this.observeHeaders())}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink(),this.cancelResizeGesture(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0;const frame=this.layoutFrame;frame&&frame.owner.cancelAnimationFrame(frame.handle),this.layoutFrame=null,this.observedBase=void 0,this.observedHeaders.clear()}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}localizedOverride(key,override){return override??this.localize(key)}loadingText(){return this.localizedOverride("tableLoading",this.loadingLabel)}observeBase(base){this.observedBase!==base&&(this.observedBase&&this.resizeObserver?.unobserve(this.observedBase),this.resizeObserver?.observe(base),this.observedBase=base)}observeHeaders(){const headers=new Set(this.columns.some(column=>column.sticky||column.resizable)?this.renderRoot.querySelectorAll("th[data-col-key]"):[]);for(const header of this.observedHeaders)headers.has(header)||(this.resizeObserver?.unobserve(header),this.observedHeaders.delete(header));for(const header of headers)this.observedHeaders.has(header)||(this.observedHeaders.add(header),this.resizeObserver?.observe(header))}recomputeHiddenPriorityColumns(){const hasPriorityColumns=this.columns.some(col=>col.priority),anyPriorityHidden=hasPriorityColumns&&[...this.renderRoot.querySelectorAll("th[data-priority]")].some(el=>el.offsetParent===null),inlineSize=this.renderRoot.querySelector('[part="base"]')?.clientWidth??0,wouldHideAtAllocation=hasPriorityColumns&&inlineSize>0&&this.columns.some(column=>column.priority==="low"&&inlineSize<=LOW_PRIORITY_MAX_INLINE_SIZE||column.priority==="medium"&&inlineSize<=MEDIUM_PRIORITY_MAX_INLINE_SIZE),toggleAvailable=anyPriorityHidden||this.priorityColumnsVisible&&wouldHideAtAllocation;this.rehomeFocusedColumn(),this.priorityColumnsToggleAvailable!==toggleAvailable&&(this.priorityColumnsToggleAvailable=toggleAvailable),this.hasHiddenPriorityColumns!==anyPriorityHidden&&(this.hasHiddenPriorityColumns=anyPriorityHidden)}rehomeFocusedColumn(){const visible=this.visibleHeaders();visible.length===0||this.activeColKey===null||visible.some(header=>header.dataset.colKey===this.activeColKey)||(this.activeColKey=visible[0].dataset.colKey??null)}keyOf(row,index){try{const key=this.rowKey?this.rowKey(row):index;return typeof key=="string"?key.trim().length===0?void 0:key:typeof key=="number"?key:void 0}catch{return}}canonicalRowEntries(){const inputs=this.canonicalRowEntriesInputs;if(this.cachedCanonicalRowEntries!==null&&inputs?.rows===this.rows&&inputs.rowKey===this.rowKey)return this.cachedCanonicalRowEntries;const entries=[],seen=new Set;return this.rows.forEach((row,index)=>{const key=this.keyOf(row,index);if(key===void 0)return;const encoded=encodeKey(key);seen.has(encoded)||(seen.add(encoded),entries.push({row,index,key}))}),this.canonicalRowEntriesInputs={rows:this.rows,rowKey:this.rowKey},this.cachedCanonicalRowEntries=entries,entries}matchingEntries(){const text=this.filterText.trim(),locale=text===""?"":this.effectiveLocale,canonicalEntries=this.canonicalRowEntries(),inputs=this.matchingEntriesInputs;if(this.cachedMatchingEntries!==null&&inputs!==null&&inputs.entries===canonicalEntries&&inputs.filter===this.filter&&inputs.text===text&&inputs.locale===locale)return this.cachedMatchingEntries;let entries;if(text==="")entries=canonicalEntries;else{const intlLocale=this.effectiveLocale,normalized=text.toLocaleLowerCase(intlLocale);entries=canonicalEntries.filter(({row})=>this.filter?this.filter(row,text):safeStringifyForFilter(row).toLocaleLowerCase(intlLocale).includes(normalized))}return this.matchingEntriesInputs={entries:canonicalEntries,filter:this.filter,text,locale},this.cachedMatchingEntries=entries,entries}get normalizedPageSize(){return finiteInteger(this.pageSize,DEFAULT_PAGE_SIZE,1,MAX_PAGE_SIZE)}get effectiveSkeletonRows(){const explicit=finiteCount(this.skeletonRows,0,MAX_SKELETON_ROWS);if(explicit>0)return explicit;const pageSize=this.normalizedPageSize;return pageSize===DEFAULT_PAGE_SIZE?DEFAULT_SKELETON_ROWS:Math.min(pageSize,MAX_SKELETON_ROWS)}get matchingTotalItems(){const totalItems=finiteInteger(this.totalItems,-1);return totalItems>=0?totalItems:this.matchingEntries().length}get pageCount(){const pageSize=this.normalizedPageSize;return pageSize>0?Math.ceil(this.matchingTotalItems/pageSize):0}get appliedPage(){return this.pageCount===0?1:finiteInteger(this.page,1,1,this.pageCount)}sortedEntries(){const entries=this.matchingEntries();if(this.sortMode!=="client"||this.sortKey==="")return entries;const col=this.columnsByKey.get(this.sortKey);if(!col?.sortable)return entries;const locale=this.effectiveLocale,inputs=this.sortedEntriesInputs;if(this.cachedSortedEntries!==null&&inputs!==null&&inputs.entries===entries&&inputs.columns===this.columns&&inputs.mode===this.sortMode&&inputs.key===this.sortKey&&inputs.dir===this.sortDir&&inputs.locale===locale&&inputs.groupBy===this.groupBy)return this.cachedSortedEntries;const collator=getCollator(locale,{numeric:!0}),dir=this.sortDir==="desc"?-1:1,decorated=entries.map(entry=>{const raw=col.sortValue?col.sortValue(entry.row):String(col.cell(entry.row)??"");return{entry,value:typeof raw=="number"&&!Number.isFinite(raw)?null:raw}}),compare=(a,b)=>{const av=a.value,bv=b.value;return av==null&&bv==null?0:av==null?1:bv==null?-1:typeof av=="number"&&typeof bv=="number"?(av-bv)*dir:collator.compare(String(av),String(bv))*dir};let sorted;const groupBy=this.groupBy;if(groupBy===void 0)decorated.sort(compare),sorted=decorated.map(decoration=>decoration.entry);else{const buckets=new Map;for(const decoration of decorated){const groupKey=groupBy(decoration.entry.row),bucket=buckets.get(groupKey);bucket===void 0?buckets.set(groupKey,[decoration]):bucket.push(decoration)}const ordered=[...buckets.values()],constantWithinEveryGroup=ordered.every(bucket=>bucket.every(decoration=>compare(decoration,bucket[0])===0));constantWithinEveryGroup&&ordered.sort((a,b)=>compare(a[0],b[0])),sorted=[];for(const bucket of ordered){constantWithinEveryGroup||bucket.sort(compare);for(const decoration of bucket)sorted.push(decoration.entry)}}return this.sortedEntriesInputs={entries,columns:this.columns,mode:this.sortMode,key:this.sortKey,dir:this.sortDir,locale,groupBy},this.cachedSortedEntries=sorted,sorted}renderedEntries(){const entries=this.sortedEntries();if(this.paginationMode==="server")return entries.slice(0,this.normalizedPageSize);const start=(this.appliedPage-1)*this.normalizedPageSize;return entries.slice(start,start+this.normalizedPageSize)}focusedColKey(){const visible=this.visibleHeaders(),visibleKeys=new Set(visible.map(el=>el.dataset.colKey).filter(key=>key!==void 0&&this.columnsByKey.has(key)));return this.activeColKey!==null&&this.columnsByKey.has(this.activeColKey)&&(visibleKeys.size===0||visibleKeys.has(this.activeColKey))?this.activeColKey:visible.find(el=>el.dataset.colKey!==void 0&&this.columnsByKey.has(el.dataset.colKey))?.dataset.colKey??this.columns[0]?.key??null}focusedRowKey(){if(this.activeRowKey!==null&&this.rowsByKey.has(this.activeRowKey))return this.activeRowKey;const selectedKey=this._selectedKeys.values().next().value;if(selectedKey!==void 0){const selected=encodeKey(selectedKey);if(this.rowsByKey.has(selected))return selected}const first=this.renderedEntries()[0];return first?encodeKey(first.key):null}rowsAffectingRovingFocusChanged(changed){return changed.has("rows")||changed.has("rowKey")||changed.has("filterText")||changed.has("filter")||changed.has("page")||changed.has("pageSize")||changed.has("paginationMode")||changed.has("totalItems")||changed.has("columns")||changed.has("sortKey")||changed.has("sortDir")||changed.has("sortMode")||changed.has("groupBy")}captureRovingFocus(changed){this.rovingFocusSnapshot=null;const active=activeElementIn(this.shadowRoot),HTMLElementCtor=this.ownerDocument?.defaultView?.HTMLElement;if(!(!HTMLElementCtor||!(active instanceof HTMLElementCtor))){if(changed.has("columns")&&active.matches("th[data-col-key]")){const headers=this.visibleHeaders(),key=active.dataset.colKey,index=headers.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"header",key,index,targetKey:null,element:active});return}if(this.rowsAffectingRovingFocusChanged(changed)&&active.matches("tr[data-row-key]")){const renderedRows=[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],key=active.dataset.rowKey,index=renderedRows.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"row",key,index,targetKey:null,element:active})}}}resolveRovingFocusTarget(){const snapshot=this.rovingFocusSnapshot;if(snapshot===null)return;const keys=snapshot.kind==="header"?this.columns.map(column=>column.key):[...this.rowsByKey.keys()];snapshot.targetKey=keys.includes(snapshot.key)?snapshot.key:keys[Math.min(snapshot.index,keys.length-1)]??null,snapshot.kind==="header"?this.activeColKey=snapshot.targetKey:this.activeRowKey=snapshot.targetKey}willUpdate(changed){if(super.willUpdate(changed),this.captureRovingFocus(changed),this.selectionMode==="single"&&this._selectedKeys.size>1&&(changed.has("selectionMode")||changed.has("selectedRowKeys"))){const first=this._selectedKeys.values().next().value;if(this.selectedRowKeys=first===void 0?new Set:new Set([first]),this.hasUpdated){const rowKeys=Object.freeze(first===void 0?[]:[first]);this.emit("lr-selection-change",Object.freeze({rowKeys}))}}if(!this.hasUpdated){const parsed=readPersistedState(this.storageFullKey,v=>typeof v=="object"&&v!==null);parsed&&typeof parsed.priorityColumnsVisible=="boolean"&&(this.priorityColumnsVisible=parsed.priorityColumnsVisible)}if(changed.has("columns")&&(this.columnsByKey=new Map(this.columns.map(c=>[c.key,c]))),(changed.has("rows")||changed.has("rowKey")||changed.has("filterText")||changed.has("filter")||changed.has("page")||changed.has("pageSize")||changed.has("paginationMode")||changed.has("totalItems")||changed.has("columns")||changed.has("sortKey")||changed.has("sortDir")||changed.has("sortMode")||changed.has("groupBy"))&&(this.rowsByKey=new Map(this.renderedEntries().map(entry=>[encodeKey(entry.key),entry]))),this.resolveRovingFocusTarget(),this.editingCell!==null){const column=this.columnsByKey.get(this.editingCell.columnKey);(!this.rowsByKey.has(this.editingCell.rowKey)||normalizedEditTrigger(column?.editTrigger)!=="double-click")&&(this.editingCell=null)}this.editorHadFocusBeforeUpdate=this.focusedEditorCell!==null&&activeElementIn(this.shadowRoot)===this.editorElementFor(this.focusedEditorCell.rowKey,this.focusedEditorCell.columnKey)}stickyOffsets(){const offsets=new Map,headerWidths=new Map;for(const el of this.renderRoot.querySelectorAll("th[data-col-key]")){const key=el.dataset.colKey;key!==void 0&&!headerWidths.has(key)&&headerWidths.set(key,el.offsetWidth)}const headerWidth=key=>headerWidths.get(key)??0;let runningStart=0;for(const col of this.columns)stickyDirection(col.sticky)==="start"&&(offsets.set(col.key,runningStart),runningStart+=headerWidth(col.key));let runningEnd=0;for(let i=this.columns.length-1;i>=0;i--){const col=this.columns[i];col&&stickyDirection(col.sticky)==="end"&&(offsets.set(col.key,runningEnd),runningEnd+=headerWidth(col.key))}return offsets}computeHeatDomain(hasHeatTint){if(!hasHeatTint)return null;const values=[];for(const entry of this.matchingEntries())for(const col of this.columns){const v=col.heatValue?.(entry.row);v!=null&&Number.isFinite(v)&&values.push(v)}const auto=minMax(values),lo=this.heatTintScale?.min??auto?.[0],hi=this.heatTintScale?.max??auto?.[1];return lo===void 0||hi===void 0?null:[lo,hi]}heatShare(col,row,domain){if(!col.heatValue||!domain)return null;const v=col.heatValue(row);if(v==null||!Number.isFinite(v))return null;const[lo,hi]=domain;return`${(finiteRatio(v,lo,hi)*100).toFixed(2)}%`}applyStickyOffsets(){if(!this.columns.some(c=>c.sticky))return;const offsets=this.stickyOffsets();this.renderRoot.querySelectorAll("[data-col-key]").forEach(el=>{const key=el.dataset.colKey;key!==void 0&&offsets.has(key)&&el.style.setProperty("--lr-table-sticky-offset",`${offsets.get(key)}px`)})}updated(changed){super.updated(changed),this.loadingAnnouncementsReady&&changed.has("loading")&&this.loading&&this.announcementSink?.announce(this.loadingText()),this.loadingAnnouncementsReady=!0,this.persistReady&&changed.has("priorityColumnsVisible")&&writePersistedState(this.storageFullKey,{priorityColumnsVisible:this.priorityColumnsVisible}),this.persistReady=!0,(changed.has("columns")||changed.has("rows")||changed.has("rowKey"))&&this.applyStickyOffsets(),this.syncResizeHandleValues();const base=this.renderRoot.querySelector('[part="base"]');if(base&&this.observeBase(base),this.observeHeaders(),this.restoreRovingFocus(),this.hasAlwaysOnEditors&&this.restoreAlwaysOnEditorFocus(),changed.has("editingCell")&&this.editingCell){const{rowKey,columnKey}=this.editingCell;queueMicrotask(()=>this.editorElementFor(rowKey,columnKey)?.focus())}queueMicrotask(()=>this.recomputeHiddenPriorityColumns())}restoreRovingFocus(){const snapshot=this.rovingFocusSnapshot;if(this.rovingFocusSnapshot=null,snapshot===null)return;const internalActive=activeElementIn(this.shadowRoot);if(internalActive!==null&&internalActive!==snapshot.element)return;const documentActive=activeElementIn(this.ownerDocument);if(documentActive!==null&&documentActive!==this&&documentActive!==this.ownerDocument.body)return;const candidates=snapshot.kind==="header"?this.visibleHeaders():[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],target=candidates.find(candidate=>snapshot.kind==="header"?candidate.dataset.colKey===snapshot.targetKey:candidate.dataset.rowKey===snapshot.targetKey)??candidates[Math.min(snapshot.index,candidates.length-1)]??null;snapshot.kind==="header"?this.focusHeader(target):this.focusRow(target)}activateColumn(key){this.activeColKey=key;const col=this.columnsByKey.get(key);if(!col?.sortable)return;const sortDir=this.sortKey===key?this.sortDir==="asc"?"desc":"asc":this.defaultSortDir,request=Object.freeze({phase:"request",sortKey:col.key,sortDir});this.emit("lr-sort-request",request,{cancelable:!0}).defaultPrevented||(this.sortMode==="client"&&(this.sortKey=col.key,this.sortDir=sortDir),this.emit("lr-sort",Object.freeze({phase:"commit",sortKey:col.key,sortDir})))}activateRow(key){this.activeRowKey=key;const entry=this.rowsByKey.get(key);if(entry===void 0)return;const{row,key:selectedKey}=entry;if(this.emit("lr-row-click",Object.freeze({row})),this.selectionMode==="single"){this.selectedRowKeys=new Set([selectedKey]);const rowKeys=Object.freeze([selectedKey]);this.emit("lr-selection-change",Object.freeze({rowKeys}))}else if(this.selectionMode==="multiple"){const rawKey=selectedKey,next=new Set(this._selectedKeys);next.has(rawKey)?next.delete(rawKey):next.add(rawKey),this.selectedRowKeys=next;const rowKeys=Object.freeze([...next]);this.emit("lr-selection-change",Object.freeze({rowKeys}))}}get hasAlwaysOnEditors(){return this.columns.some(col=>normalizedEditTrigger(col.editTrigger)==="always")}editorValue(row,column){const value=column.editValue?.(row)??row[column.key]??"";return String(value)}startEditing(rowKey,columnKey){const column=this.columnsByKey.get(columnKey);normalizedEditTrigger(column?.editTrigger)!=="double-click"||!this.rowsByKey.has(rowKey)||(this.editingCell={rowKey,columnKey})}commitEdit(event,rowKey,columnKey){event.stopPropagation();const input=event.currentTarget,entry=this.rowsByKey.get(rowKey),column=this.columnsByKey.get(columnKey),isTransient=this.editingCell?.rowKey===rowKey&&this.editingCell.columnKey===columnKey;if(!entry||!column||normalizedEditTrigger(column.editTrigger)===void 0){isTransient&&(this.editingCell=null);return}const value=column.editType==="number"&&input.value!==""?Number(input.value):input.value;this.emit("lr-cell-edit",Object.freeze({row:entry.row,columnKey,value})),isTransient&&(this.editingCell=null)}editorElementFor(rowKey,columnKey){const row=[...this.renderRoot.querySelectorAll("[data-row-key]")].find(el=>el.dataset.rowKey===rowKey);return(row?[...row.querySelectorAll("td[data-col-key]")].find(el=>el.dataset.colKey===columnKey):void 0)?.querySelector('[part="cell-editor"]')??null}restoreAlwaysOnEditorFocus(){const cell=this.focusedEditorCell;if(cell===null)return;const editor=this.editorElementFor(cell.rowKey,cell.columnKey);editor===null?this.focusedEditorCell=null:this.editorHadFocusBeforeUpdate&&activeElementIn(this.shadowRoot)!==editor&&editor.focus(),this.editorHadFocusBeforeUpdate=!1}activateExpandToggle(key){const entry=this.rowsByKey.get(encodeKey(key));entry!==void 0&&this.emit("lr-row-expand-toggle",Object.freeze({row:entry.row,rowKey:key}))}visibleHeaders(){return[...this.renderRoot?.querySelectorAll("th[data-col-key]")??[]].filter(el=>el.offsetParent!==null)}focusHeader(el){el?.dataset.colKey&&(this.activeColKey=el.dataset.colKey,el.focus())}focusRow(el){el?.dataset.rowKey&&(this.activeRowKey=el.dataset.rowKey,el.focus())}onHeaderKeyDown(e,th){if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateColumn(th.dataset.colKey);return}const headers=this.visibleHeaders(),index=headers.indexOf(th);if(index<0)return;const rtl=isRtl(this);switch(e.key){case"ArrowLeft":e.preventDefault(),this.focusHeader(headers[rtl?Math.min(headers.length-1,index+1):Math.max(0,index-1)]??null);return;case"ArrowRight":e.preventDefault(),this.focusHeader(headers[rtl?Math.max(0,index-1):Math.min(headers.length-1,index+1)]??null);return;case"Home":e.preventDefault(),this.focusHeader(headers[0]??null);return;case"End":e.preventDefault(),this.focusHeader(headers[headers.length-1]??null);return;case"ArrowDown":{e.preventDefault();const rows=[...this.renderRoot.querySelectorAll("[data-row-key]")],key=this.focusedRowKey();this.focusRow(rows.find(r=>r.dataset.rowKey===key)??rows[0]??null);return}default:return}}onRowKeyDown(e,tr){if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateRow(tr.dataset.rowKey);return}const bodyRows=[...this.renderRoot.querySelectorAll("[data-row-key]")],index=bodyRows.indexOf(tr);if(!(index<0))switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(bodyRows[Math.min(bodyRows.length-1,index+1)]??null);return;case"ArrowUp":if(e.preventDefault(),index===0){const headers=this.visibleHeaders(),key=this.focusedColKey();this.focusHeader(headers.find(h=>h.dataset.colKey===key)??headers[0]??null)}else this.focusRow(bodyRows[index-1]??null);return;case"Home":e.preventDefault(),this.focusRow(bodyRows[0]??null);return;case"End":e.preventDefault(),this.focusRow(bodyRows[bodyRows.length-1]??null);return;default:return}}renderCellValue(col,row){if(typeof col.cell=="function")return col.cell(row);const key=String(col.key??"(unkeyed)");return this.reportedMissingCellColumns.has(key)||(this.reportedMissingCellColumns.add(key),console.error(`<lr-table>: column ${JSON.stringify(key)} has no \`cell\` renderer, so its cells render empty. \`cell\` is required, but a lit \`.columns=\${...}\` binding is not type-checked, so this cannot be caught by tsc alone.`)),nothing}renderCellEditor(row,col,rowKey,alwaysOn){const type=col.editType??"text",isText=type==="text",value=this.editorValue(row,col),label=this.localize("tableEditCell",void 0,{column:col.label}),spellcheck=isText?this.spellcheck:nothing,autocapitalize=isText?this.autocapitalize||nothing:nothing,autocorrect=isText?this.autoCorrect||nothing:nothing,onChange=event=>this.commitEdit(event,rowKey,col.key),onKeyDown=event=>this.onEditorKeyDown(event,rowKey,col.key);return alwaysOn?html`<input
|
|
14
14
|
part="cell-editor"
|
|
15
15
|
type=${type}
|
|
16
16
|
value=${value}
|
|
@@ -155,7 +155,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
155
155
|
title=${cellTitle||nothing}
|
|
156
156
|
style=${Object.keys(cellStyle).length?styleMap(cellStyle):nothing}
|
|
157
157
|
>
|
|
158
|
-
${editing?this.renderCellEditor(row,col,encodeKey(key),alwaysOn):
|
|
158
|
+
${editing?this.renderCellEditor(row,col,encodeKey(key),alwaysOn):this.renderCellValue(col,row)}
|
|
159
159
|
</td>`})}
|
|
160
160
|
${hasRowTotal?html`<td part="row-total-cell">${this.rowTotal?.(row)}</td>`:nothing}
|
|
161
161
|
</tr>`,rowExpanded?html`<tr part="expanded-row" role="row">
|
|
@@ -35,6 +35,11 @@ export interface ComboboxSourceRow {
|
|
|
35
35
|
readonly sub?: string;
|
|
36
36
|
/** Optional decorative leading visual. Its rendered subtree is inert and aria-hidden. */
|
|
37
37
|
readonly icon?: unknown;
|
|
38
|
+
/** Leading adornment, mirroring `<lr-option>`'s `start`/`prefix` slots. Inert and aria-hidden,
|
|
39
|
+
* like `icon`, so it never joins the option's accessible name. */
|
|
40
|
+
readonly start?: unknown;
|
|
41
|
+
/** Trailing adornment, mirroring `<lr-option>`'s `end`/`suffix` slots. */
|
|
42
|
+
readonly end?: unknown;
|
|
38
43
|
/** Optional trailing metadata badge. */
|
|
39
44
|
readonly badge?: string | number;
|
|
40
45
|
/** Spoken option label when the visible row needs additional context. */
|
|
@@ -171,6 +176,10 @@ export interface LyraComboboxEventMap {
|
|
|
171
176
|
* `lr-select` and `lr-emoji-picker` so one rule can style every grouped list.
|
|
172
177
|
* @csspart option - An option row.
|
|
173
178
|
* @csspart option-dot - An option row's leading status dot (when `dot-color` is set).
|
|
179
|
+
* @csspart option-start - An option row's leading adornment, cloned from the source
|
|
180
|
+
* `<lr-option>`'s `start`/`prefix` slot (or an async row's `start`). Inert and aria-hidden.
|
|
181
|
+
* @csspart option-end - An option row's trailing adornment, cloned from the source
|
|
182
|
+
* `<lr-option>`'s `end`/`suffix` slot (or an async row's `end`). Inert and aria-hidden.
|
|
174
183
|
* @csspart option-icon - An async option row's optional decorative leading visual. Its rendered
|
|
175
184
|
* subtree remains visible but is inert and hidden from assistive technology.
|
|
176
185
|
* @csspart option-label - An option row's label/sub wrapper.
|
|
@@ -433,6 +442,23 @@ export declare class LyraCombobox extends LyraElement<LyraComboboxEventMap> {
|
|
|
433
442
|
private _restoredStateActive;
|
|
434
443
|
private _name;
|
|
435
444
|
private validationTargetOverride?;
|
|
445
|
+
/**
|
|
446
|
+
* Bounds the popup to roughly this many option rows, leaving the rest reachable by scrolling.
|
|
447
|
+
*
|
|
448
|
+
* This is the third and last of three similarly-named caps, which is exactly the confusion this
|
|
449
|
+
* property exists to end -- each does something different:
|
|
450
|
+
* - `visibleOptions` (this one) caps how many suggestion rows are **visible** at once. Purely
|
|
451
|
+
* presentational: every row is still rendered and still reachable by scrolling.
|
|
452
|
+
* - `maxOptionsVisible` caps how many **selected tags** are shown in multi-select before the
|
|
453
|
+
* "+N" summary. Nothing to do with the suggestion list.
|
|
454
|
+
* - `maxRender` caps how many suggestion rows are **rendered into the DOM at all**, as a
|
|
455
|
+
* performance ceiling; rows past it do not exist and are summarized by `option-overflow`.
|
|
456
|
+
*
|
|
457
|
+
* Unset imposes no bound of its own, leaving the listbox's existing max-height behavior exactly
|
|
458
|
+
* as it was. Zero, negative, and non-finite values normalize to unset rather than collapsing the
|
|
459
|
+
* popup.
|
|
460
|
+
*/
|
|
461
|
+
visibleOptions?: number;
|
|
436
462
|
private _maxOptionsVisible;
|
|
437
463
|
private _maxRender;
|
|
438
464
|
private _sourceDelay;
|
|
@@ -498,13 +524,20 @@ export declare class LyraCombobox extends LyraElement<LyraComboboxEventMap> {
|
|
|
498
524
|
get value(): string | string[];
|
|
499
525
|
set value(next: string | string[]);
|
|
500
526
|
private setValue;
|
|
501
|
-
/** Maximum number of selected-value tags shown before the rest collapse behind a "+N" tag
|
|
527
|
+
/** Maximum number of selected-value **tags** shown before the rest collapse behind a "+N" tag
|
|
502
528
|
* (multi-select only). Sanitized to a finite, non-negative integer.
|
|
529
|
+
*
|
|
530
|
+
* Not to be confused with the two caps on the suggestion list: `visibleOptions` bounds how many
|
|
531
|
+
* suggestion rows are visible at once, and `maxRender` bounds how many are rendered at all.
|
|
532
|
+
* This one only ever concerns the tags for values already chosen.
|
|
503
533
|
* @default 3 */
|
|
504
534
|
get maxOptionsVisible(): number;
|
|
505
535
|
set maxOptionsVisible(next: number);
|
|
506
|
-
/** Maximum number of rows rendered
|
|
507
|
-
* (the current selection is always kept visible regardless).
|
|
536
|
+
/** Maximum number of suggestion rows **rendered into the DOM at all** before the rest collapse
|
|
537
|
+
* behind the overflow indicator (the current selection is always kept visible regardless). This
|
|
538
|
+
* is a performance ceiling, not a visible-height affordance: rows past it do not exist and
|
|
539
|
+
* cannot be scrolled to. Use `visibleOptions` to bound the popup's height while keeping every
|
|
540
|
+
* row reachable, and `maxOptionsVisible` for the selected-tag cap. Sanitized to a finite,
|
|
508
541
|
* non-negative integer capped at 1,000.
|
|
509
542
|
*
|
|
510
543
|
* Rows render in full rather than as a recycled scroll window, because the filter input's
|
|
@@ -587,6 +620,24 @@ export declare class LyraCombobox extends LyraElement<LyraComboboxEventMap> {
|
|
|
587
620
|
private reflectSelected;
|
|
588
621
|
private labelFor;
|
|
589
622
|
/** The current row set in a source-agnostic shape, before capping. */
|
|
623
|
+
/**
|
|
624
|
+
* Cloned adornment nodes, keyed by the option they came from. Cached because `effectiveRows` runs
|
|
625
|
+
* on every render pass: handing Lit a fresh clone each time would rebuild the whole popup's
|
|
626
|
+
* adornment DOM on every keystroke. Dropped wholesale in `collectOptions()`, which is the only
|
|
627
|
+
* place the option set can change.
|
|
628
|
+
*/
|
|
629
|
+
private adornmentClones;
|
|
630
|
+
/**
|
|
631
|
+
* `<lr-option>` documents `start`/`end` (plus the Shoelace `prefix`/`suffix` aliases) adornment
|
|
632
|
+
* slots, but the popup is built from row DATA rather than from the option elements, so slotted
|
|
633
|
+
* nodes have nowhere to land. Clone them into the row instead.
|
|
634
|
+
*
|
|
635
|
+
* `cloneNode(true)`, never `createElementNS`: the latter yields an inert, never-upgrading custom
|
|
636
|
+
* element (AGENTS.md), which would silently break the `<lr-flag>`/avatar case this exists for.
|
|
637
|
+
* Cloning also leaves the author's own subtree exactly where they put it -- moving the live node
|
|
638
|
+
* would empty their markup as a side effect of opening a dropdown.
|
|
639
|
+
*/
|
|
640
|
+
private adornmentsFor;
|
|
590
641
|
private get effectiveRows();
|
|
591
642
|
/** Synthetic action shown only when the current nonempty query has no exact label/value match. */
|
|
592
643
|
private get createRow();
|
|
@@ -620,6 +671,23 @@ export declare class LyraCombobox extends LyraElement<LyraComboboxEventMap> {
|
|
|
620
671
|
private bindDocumentPointer;
|
|
621
672
|
private unbindDocumentPointer;
|
|
622
673
|
private reconnectOpenPopup;
|
|
674
|
+
/**
|
|
675
|
+
* Applies `visibleOptions` as an inline `max-block-size` on the listbox.
|
|
676
|
+
*
|
|
677
|
+
* Measured rather than computed from a token, because a row's height varies with `sub` lines,
|
|
678
|
+
* adornments, and group labels -- an estimate would cut a row in half. Measuring where row N
|
|
679
|
+
* *starts* also naturally accounts for the listbox's own padding.
|
|
680
|
+
*
|
|
681
|
+
* The inline value keeps the positioner clamp inside its own `min()` rather than overriding the
|
|
682
|
+
* stylesheet's: an inline declaration beats the shadow stylesheet outright, so writing a bare
|
|
683
|
+
* pixel length here would let a capped listbox overflow the space the positioner actually has.
|
|
684
|
+
* The property is removed entirely when the cap is unset, normalizes away, or is not exceeded, so
|
|
685
|
+
* the stylesheet's own expression is what applies and behavior is unchanged.
|
|
686
|
+
*
|
|
687
|
+
* Deliberately NOT a custom property: `check-style-policy` forbids component runtime code writing
|
|
688
|
+
* a documented `@cssprop`, and rightly so -- a documented hook is consumer-owned.
|
|
689
|
+
*/
|
|
690
|
+
private syncVisibleOptionsCap;
|
|
623
691
|
protected updated(changed: PropertyValues): void;
|
|
624
692
|
private settleTransition;
|
|
625
693
|
private waitForTransition;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{place}from"../../../internal/positioner.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{chevronIcon,closeIcon}from"../../../internal/icons.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState,syncValidityStates}from"../../../internal/custom-states.js";import{submitOnEnter}from"../../../internal/submit-on-enter.js";import{finiteCount,finiteDuration}from"../../../internal/numbers.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./combobox.styles.js";import"./option.class.js";import{autocorrectConverter,omittedEmptyStringConverter,spellcheckConverter}from"../../../internal/converters.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{attachInternalsSafely,getFormOwner,installCustomErrorProperty,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{tag}from"../../../internal/prefix.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{isOptionSelectedDirty,wasOptionInitiallySelected,RESET_OPTION_SELECTED_FROM_OWNER,SET_OPTION_SELECTED_FROM_OWNER}from"../../../internal/option-selection.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_collapse,LYRA_DEFAULT_comboboxCreate,LYRA_DEFAULT_comboboxLabel,LYRA_DEFAULT_comboboxLoadError,LYRA_DEFAULT_comboboxOverflow,LYRA_DEFAULT_comboboxRequired,LYRA_DEFAULT_comboboxSelectedOverflow,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_removeWithContext,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_valueInvalid}from"../../../internal/default-strings.generated.js";function isLyraOptionElement(value){return isHtmlElement(value)&&value.localName===tag("option")}const VALIDITY_FLAG_KEYS=new Set(["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"]),comboboxSpellcheckConverter={...spellcheckConverter,fromAttribute:(value,type)=>value===null?void 0:spellcheckConverter.fromAttribute?.(value,type)};function isValidityFlagKey(value){return typeof value=="string"&&VALIDITY_FLAG_KEYS.has(value)}const MAX_SOURCE_ROWS=2e3,MAX_SOURCE_TEXT_UNITS=25e4,MAX_SOURCE_FIELD_UNITS=4096,MAX_RENDER_ROWS=1e3;function normalizeSourceResult(input){let candidateRows,candidateTotal;try{Array.isArray(input)?candidateRows=input:typeof input=="object"&&input!==null&&(candidateRows=input.rows,candidateTotal=input.total)}catch{throw new TypeError("Invalid combobox source result")}if(!Array.isArray(candidateRows))throw new TypeError("Invalid combobox source result");const providerTotal=typeof candidateTotal=="number"&&Number.isFinite(candidateTotal)&&candidateTotal>=0?Math.trunc(candidateTotal):candidateRows.length,rows=[];let textUnits=0;const limit=Math.min(candidateRows.length,MAX_SOURCE_ROWS);for(let index=0;index<limit;index++)try{const value=candidateRows[index]?.value,label=candidateRows[index]?.label;if(typeof value!="string"||typeof label!="string"||value.length>MAX_SOURCE_FIELD_UNITS||label.length>MAX_SOURCE_FIELD_UNITS)continue;const source=candidateRows[index],optionalText=key=>{const candidate=source[key];return typeof candidate=="string"&&candidate.length<=MAX_SOURCE_FIELD_UNITS?candidate:void 0},sub=optionalText("sub"),accessibleLabel=optionalText("accessibleLabel"),dotColor=optionalText("dotColor"),group=optionalText("group"),badgeCandidate=source.badge,badge=typeof badgeCandidate=="string"&&badgeCandidate.length<=MAX_SOURCE_FIELD_UNITS||typeof badgeCandidate=="number"&&Number.isFinite(badgeCandidate)?badgeCandidate:void 0,units=value.length+label.length+(sub?.length??0)+(accessibleLabel?.length??0)+(dotColor?.length??0)+(group?.length??0)+(typeof badge=="string"?badge.length:0);if(textUnits+units>MAX_SOURCE_TEXT_UNITS)break;textUnits+=units,rows.push({value,label,...sub===void 0?{}:{sub},...source.icon===void 0?{}:{icon:source.icon},...badge===void 0?{}:{badge},...accessibleLabel===void 0?{}:{accessibleLabel},...source.data===void 0?{}:{data:source.data},...dotColor===void 0?{}:{dotColor},...group===void 0?{}:{group},...typeof source.disabled=="boolean"?{disabled:source.disabled}:{}})}catch{}const total=Math.max(providerTotal,candidateRows.length);return{rows,total,truncated:total>rows.length}}class LyraCombobox extends LyraElement{static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,collapse:LYRA_DEFAULT_collapse,comboboxCreate:LYRA_DEFAULT_comboboxCreate,comboboxLabel:LYRA_DEFAULT_comboboxLabel,comboboxLoadError:LYRA_DEFAULT_comboboxLoadError,comboboxOverflow:LYRA_DEFAULT_comboboxOverflow,comboboxRequired:LYRA_DEFAULT_comboboxRequired,comboboxSelectedOverflow:LYRA_DEFAULT_comboboxSelectedOverflow,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noMatches:LYRA_DEFAULT_noMatches,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,removeWithContext:LYRA_DEFAULT_removeWithContext,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,valueInvalid:LYRA_DEFAULT_valueInvalid}}static{this.immutableEventDetails=Object.freeze(["lr-change","input","change"])}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},multiple:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},value:{noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},maxOptionsVisible:{type:Number,attribute:"max-options-visible",noAccessor:!0},maxRender:{type:Number,attribute:"max-render",noAccessor:!0},sourceDelay:{type:Number,attribute:"source-delay",noAccessor:!0}}}get open(){return this._open}set open(next){const old=this._open,liveDisabled=this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled");if(this._open=!!next&&!liveDisabled,this._open===old){next&&!this._open&&this.hasAttribute("open")&&this.removeAttribute("open");return}this.requestUpdate("open",old)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=!!next,this.requestUpdate()}get inputmode(){return this.inputMode}set inputmode(next){this.inputMode=next??""}get enterkeyhint(){return this.enterKeyHint}set enterkeyhint(next){this.enterKeyHint=next??""}get inputValue(){return this.query}set inputValue(next){this.explicitInputValue=!0,this.query=next??"",this.activeIndex=-1,this.source&&this.runSource(this.query),this.requestUpdate()}constructor(){super(),this.placeholder="",this.label="",this.hint="",this.errorText="",this.allowCreate=!1,this.allowCustomValue=!1,this.appearance="outlined",this.placement="bottom",this.size="m",this.pill=!1,this.clearable=!1,this.withClear=!1,this.withLabel=!1,this.withHint=!1,this.validators=[],this.autocomplete="off",this.inputMode="",this.enterKeyHint="",this.spellcheck=!1,this.autocapitalize="",this.autocorrectValue=!0,this.filter=null,this.source=null,this.query="",this.explicitInputValue=!1,this.activeIndex=-1,this.options=[],this.touched=!1,this.validityRevision=0,this.slotPresence=new SlotPresenceController(this),this.loading=!1,this.sourceFailed=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.sourceToken=0,this._sourceWarmed=!1,this._selectedLabelCache=new Map,this._selectedRowCache=new Map,this._rowsByValue=new Map,this._open=!1,this._fieldsetDisabled=!1,this.listId=nextId("combobox-list"),this.inputId=nextId("combobox-input"),this.restoreFocusOnClose=!0,this.restoringOverlayFocus=!1,this._isFirstUpdate=!0,this.openVetoed=!1,this.closeCleanupPending=!1,this.transitionToken=0,this.transitionWaiters=new Map,this._selected=[],this._valueDirty=!1,this._multiple=!1,this._disabled=!1,this._required=!1,this._defaultSelected=[],this._defaultCaptured=!1,this._restoredStateActive=!1,this._name="",this._maxOptionsVisible=3,this._maxRender=200,this._sourceDelay=200,this.collectOptions=e=>{const slot=e.target,previous=new Set(this.options);if(this.options=slot.assignedElements({flatten:!0}).filter(isLyraOptionElement),this.normalizeActiveIndex(),this._defaultCaptured){const newDefaults=this.options.filter(option=>!previous.has(option)&&option.defaultSelected),newLive=this.options.filter(option=>!previous.has(option)&&option.selected&&!option.defaultSelected);this.refreshOptionDefaults();const eligible=[...!this._restoredStateActive&&!this._valueDirty?newDefaults:[],...this._restoredStateActive?[]:newLive];if(eligible.length){const values=eligible.map(option=>option.value),next=this.multiple?[...new Set([...this._selected,...values])]:values[values.length-1];newLive.length>0?this.value=next:this.setValue(next,!1);return}}else{this._defaultCaptured=!0;const allDefaults=this.options.filter(option=>option.defaultSelected).map(option=>option.value),allLive=this.options.filter(option=>option.selected).map(option=>option.value),defaults=this.multiple?allDefaults:allDefaults.slice(0,1),live=this.multiple?allLive:allLive.slice(0,1),initialLive=this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value),optionDirty=this.options.some(option=>isOptionSelectedDirty(option)),dirtyValues=this.options.filter(option=>isOptionSelectedDirty(option)&&option.selected).map(option=>option.value);this._defaultSelected=[...defaults.length>0?defaults:initialLive.length>0?initialLive:live];const fromDefaults=defaults.length>0,initial=optionDirty?this.multiple?allLive:dirtyValues.slice(-1)[0]?dirtyValues.slice(-1):live:fromDefaults?defaults:live;if(initial.length&&!this._restoredStateActive&&!this._valueDirty){const next=this.multiple?initial:initial[0];fromDefaults&&!optionDirty?this.setValue(next,!1):this.value=next;return}optionDirty&&(this._valueDirty=!0)}this.reflectSelected()},this.onOptionChange=e=>{e.stopPropagation(),queueMicrotask(()=>{this.refreshOptionDefaults(),this.reflectSelected(),this.options=[...this.options],this.normalizeActiveIndex()})},this.onDocPointer=e=>{if(!e.composedPath().includes(this)){if(this.overlayHandle?.isActive()){this.overlayHandle.dismissBackdrop();return}this.restoreFocusOnClose=!1,this.hide()}},this.onInput=e=>{this.liveDisabled||(this.explicitInputValue=!1,this.query=e.target.value,this.activeIndex=-1,this.show(),this.source&&this.runSource(this.query),this.emit("lr-filter",{value:this.query}))},this.onInputBlur=event=>{this.liveDisabled||(this.touched=!0),this.syncCustomStates(),this.restoreFocusOnClose=!1,this.hide(),relayNativeEvent(this,event)},this.onInputFocus=event=>{if(this.liveDisabled){event.stopPropagation();return}this.restoringOverlayFocus||this.show(),relayNativeEvent(this,event)},this.onKeyDown=e=>{if(this.liveDisabled)return;const navigable=this.renderedRows.rows.filter(r=>!r.disabled);switch(e.key){case"ArrowDown":if(e.preventDefault(),!this.open){this.show();return}this.activeIndex=Math.min(navigable.length-1,this.activeIndex+1);break;case"ArrowUp":if(e.preventDefault(),!this.open){this.show();return}this.activeIndex=Math.max(0,this.activeIndex-1);break;case"Enter":{const activeRow=navigable[this.activeIndex];if(this.open&&this.activeIndex>=0&&activeRow){e.preventDefault(),this.pickRow(activeRow);break}const create=this.createRow;if(this.open&&create){e.preventDefault(),this.createOption(create.createInput);break}if(this.open&&this.allowCustomValue&&!this.multiple&&this.query.trim()){e.preventDefault(),this.commitCustomValue(this.query.trim());break}submitOnEnter(this,e);break}case"Escape":this.open&&(!this.overlayHandle?.isActive()||this.overlayHandle.isTopmost())&&(e.preventDefault(),this.hide());break;case"Home":this.open&&(e.preventDefault(),this.activeIndex=0);break;case"End":this.open&&(e.preventDefault(),this.activeIndex=navigable.length-1);break;case"Backspace":this.multiple&&!this.query&&this._selected.length&&this.removeValue(this._selected[this._selected.length-1]);break}},this.onComboMouseDown=e=>{this.liveDisabled||e.composedPath()[0]!==this.inputEl&&(e.target.closest("button")||(e.preventDefault(),this.inputEl?.focus(),this.show()))},this.onListboxMouseDown=e=>{e.preventDefault()},this.onListboxClick=e=>{const value=e.target.closest('[part="option"]')?.dataset.value;if(value===void 0)return;const row=this._rowsByValue.get(value);row&&this.pickRow(row)},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init))}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}get validationTarget(){return this.validationTargetOverride??this.inputEl??void 0}set validationTarget(next){this.validationTargetOverride=next??void 0,this.validityController.refreshAnchor()}resetValidity(){this.validityController.setCustomValidity(""),this.updateValidity()}get input(){return this.inputEl??null}get selectionStart(){return this.inputEl?.selectionStart??null}set selectionStart(value){this.inputEl&&(this.inputEl.selectionStart=value)}get selectionEnd(){return this.inputEl?.selectionEnd??null}set selectionEnd(value){this.inputEl&&(this.inputEl.selectionEnd=value)}get selectionDirection(){return this.inputEl?.selectionDirection}set selectionDirection(value){this.inputEl&&(this.inputEl.selectionDirection=value)}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}focus(options){this.liveDisabled||this.inputEl?.focus(options)}blur(){this.inputEl?.blur()}click(){this.liveDisabled||(this.inputEl?.focus(),this.show())}select(){this.inputEl?.select()}setSelectionRange(start,end,direction){this.inputEl?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const input=this.inputEl;input&&(start===void 0||end===void 0?input.setRangeText(replacement):input.setRangeText(replacement,start,end,selectMode),this.explicitInputValue=!0,this.query=input.value,this.activeIndex=-1,this.source&&this.runSource(this.query))}[VALIDITY_ANCHOR](){return this.validationTarget}connectedCallback(){super.connectedCallback(),this.syncSourceErrorAnnouncementSink(),this.updateValidity(),this.hasUpdated&&this.syncValidatorAttributeObserver(),this.hasUpdated&&queueMicrotask(()=>{this.open?this.reconnectOpenPopup():this.source&&this._selected.length&&this.asyncRows.length===0&&this.runSource("")})}adoptedCallback(){super.adoptedCallback(),this.cleanup?.(),this.cleanup=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.unbindDocumentPointer(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.releaseSourceErrorAnnouncementSink(),this.syncSourceErrorAnnouncementSink()}syncSourceErrorAnnouncementSink(){this.isConnected&&this.sourceErrorAnnouncementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseSourceErrorAnnouncementSink(),this.sourceErrorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}))}releaseSourceErrorAnnouncementSink(){this.sourceErrorAnnouncementSink?.release(),this.sourceErrorAnnouncementSink=void 0}willUpdate(changed){super.willUpdate(changed),this._isFirstUpdate=!this.hasUpdated,this.announceOpenTransition(changed),changed.has("open")&&this.openVetoed?this.closeCleanupPending=!1:changed.has("open")&&!this.open&&this.finalizeCloseState(),changed.has("source")&&(this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceToken++,this.loading=!1,this.sourceFailed=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this._sourceWarmed=!1,this.source&&this.open&&this.runSource(this.query)),!this._sourceWarmed&&this.source&&this._selected.length&&this.asyncRows.length===0&&(this._sourceWarmed=!0,this.runSource(""))}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.syncFormValue(),this.requestUpdate("name",old)}get multiple(){return this._multiple}set multiple(next){const old=this._multiple;this._multiple=!!next,this.toggleAttribute("multiple",this._multiple),this.syncFormValue(),this.requestUpdate("multiple",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._disabled&&this.hide(),this.updateValidity(),this.requestUpdate("disabled",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get value(){return this.multiple?[...this._selected]:this._selected[0]??""}set value(next){this.setValue(next,!0)}setValue(next,dirty){const old=this._selected;dirty&&(this._restoredStateActive=!1,this._valueDirty=!0),this._selected=Array.isArray(next)?[...next]:next?[next]:[];const selected=new Set(this._selected);for(const value of selected){const row=this.effectiveRows.find(candidate=>candidate.value===value)??this.asyncRows.find(candidate=>candidate.value===value);row&&this._selectedRowCache.set(value,row)}for(const value of this._selectedRowCache.keys())selected.has(value)||this._selectedRowCache.delete(value);for(const value of this._selectedLabelCache.keys())selected.has(value)||this._selectedLabelCache.delete(value);this.syncFormValue(),this.reflectSelected(),this.updateValidity(),this.requestUpdate("value",old)}get maxOptionsVisible(){return this._maxOptionsVisible}set maxOptionsVisible(next){const old=this._maxOptionsVisible;this._maxOptionsVisible=finiteCount(next,3),this.requestUpdate("maxOptionsVisible",old)}get maxRender(){return this._maxRender}get sourceDelay(){return this._sourceDelay}set sourceDelay(next){const old=this._sourceDelay;this._sourceDelay=finiteDuration(next,200),this.requestUpdate("sourceDelay",old)}set maxRender(next){const old=this._maxRender;this._maxRender=Math.min(finiteCount(next,200),MAX_RENDER_ROWS),this.requestUpdate("maxRender",old)}get sourceTotal(){return this._sourceTotal}get sourceTruncated(){return this._sourceTruncated}get selectedRows(){return this._selected.map(value=>this._selectedRowCache.get(value)??this.effectiveRows.find(row=>row.value===value)??this.asyncRows.find(row=>row.value===value)).filter(row=>row!=null).map(row=>({...row}))}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}validatorResult(){for(const validator of Array.isArray(this.validators)?this.validators:[]){let result;try{if(typeof validator=="object"&&validator!==null&&"checkValidity"in validator){const checked=validator.checkValidity(this);if(checked?.isValid===!0)continue;const flags={};for(const key of Array.isArray(checked?.invalidKeys)?checked.invalidKeys:[])isValidityFlagKey(key)&&(flags[key]=!0);Object.values(flags).some(Boolean)||(flags.customError=!0);let message=typeof checked?.message=="string"?checked.message:"";return!message&&typeof validator.message=="string"&&(message=validator.message),!message&&typeof validator.message=="function"&&(message=validator.message(this)),{flags,message:message||this.localize("valueInvalid")}}result=typeof validator=="function"?validator(this.value,this):validator?.validate(this.value,this)}catch{return{flags:{customError:!0},message:this.localize("valueInvalid")}}if(!(result===void 0||result===!0)){if(typeof result=="string")return{flags:{customError:!0},message:result};if(result===!1)return{flags:{customError:!0},message:this.localize("valueInvalid")};if(result&&typeof result=="object"&&Object.values(result).some(Boolean))return{flags:result,message:this.localize("valueInvalid")}}}return{}}syncValidatorAttributeObserver(){this.disconnectValidatorAttributeObserver();const owner=this.ownerDocument.defaultView,MutationObserverCtor=owner?.MutationObserver;if(!this.isConnected||!owner||typeof MutationObserverCtor!="function")return;const attributes=new Set;for(const validator of Array.isArray(this.validators)?this.validators:[]){if(typeof validator!="object"||validator===null||!("checkValidity"in validator))continue;let observed;try{observed=validator.observedAttributes}catch{continue}if(Array.isArray(observed))for(const name of observed)typeof name=="string"&&name.length>0&&attributes.add(name)}if(attributes.size===0)return;const binding={},observer=new MutationObserverCtor(()=>{this.validatorAttributeObserver!==binding||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.updateValidity(),this.validityRevision++)});binding.observer=observer,binding.owner=owner;try{observer.observe(this,{attributes:!0,attributeFilter:[...attributes]}),this.validatorAttributeObserver=binding}catch{observer.disconnect()}}disconnectValidatorAttributeObserver(){const binding=this.validatorAttributeObserver;this.validatorAttributeObserver=void 0,binding?.observer.disconnect()}updateValidity(){if(this.barredFromValidation){this.validityController.setValidity({}),this.syncCustomStates();return}const flags={};let message="";this.required&&this._selected.length===0&&(flags.valueMissing=!0,message=this.localize("comboboxRequired"));const configured=this.validatorResult();configured.flags&&Object.assign(flags,configured.flags),configured.message&&(message=configured.message),this.validityController.setValidity(flags,message),this.syncCustomStates()}syncCustomStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this.touched,barred:this.barredFromValidation}),setCustomState(this.internals,"blank",this._selected.length===0),setCustomState(this.internals,"disabled",this.effectiveDisabled)}syncFormValue(){const state2=JSON.stringify(this._selected);if(this.multiple){if(!this.name){this.internals.setFormValue(null,state2);return}const fd=new FormData;for(const v of this._selected)fd.append(this.name,v);this.internals.setFormValue(fd,state2)}else this.internals.setFormValue(this._selected[0]??"",state2)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}formResetCallback(){this.touched=!1,this._restoredStateActive=!1,this._valueDirty=!1;const resetValues=this._defaultSelected.length>0?this._defaultSelected:this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value);this._defaultSelected.length===0&&resetValues.length>0&&(this._defaultSelected=[...resetValues]);const defaults=new Set(resetValues);for(const option of this.options)option[RESET_OPTION_SELECTED_FROM_OWNER](defaults.has(option.value));this.setValue(this.multiple?[...resetValues]:resetValues[0]??"",!1),this.query="",this.explicitInputValue=!1}formStateRestoreCallback(state2,reason){let selected=[];if(typeof state2=="string")try{const parsed=JSON.parse(state2);Array.isArray(parsed)&&parsed.every(value=>typeof value=="string")&&(selected=parsed)}catch{}this.value=this.multiple?selected:selected[0]??"",this._restoredStateActive=!0}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,disabled&&this.hide(),this.updateValidity(),this.requestUpdate()}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return this.touched=!0,this.updateValidity(),this.syncCustomStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncCustomStates()}disconnectedCallback(){this.transitionToken++,this.releaseSourceErrorAnnouncementSink(),this.disconnectValidatorAttributeObserver(),super.disconnectedCallback(),this.cleanup?.(),this.cleanup=void 0,this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.unbindDocumentPointer(),this.resolveTransitionWaiters("lr-after-show"),this.resolveTransitionWaiters("lr-after-hide"),this.open=!1}refreshOptionDefaults(){const declared=this.options.filter(option=>option.defaultSelected).map(option=>option.value);this._defaultSelected=this.multiple?declared:declared.slice(0,1),!this._valueDirty&&!this._restoredStateActive&&this.setValue(this.multiple?[...this._defaultSelected]:this._defaultSelected[0]??"",!1)}reflectSelected(){const sel=new Set(this._selected);for(const option of this.options)option[SET_OPTION_SELECTED_FROM_OWNER](sel.has(option.value))}labelFor(value){return this._selectedLabelCache.get(value)??this.options.find(o=>o.value===value)?.label??this.asyncRows.find(r=>r.value===value)?.label??value}get effectiveRows(){return this.source?this.asyncRows:this.filtered.map(o=>({value:o.value,label:o.label,sub:o.sub||void 0,dotColor:o.dotColor||void 0,group:o.group||void 0,disabled:o.disabled}))}get createRow(){if(!this.allowCreate)return;const inputValue=this.query.trim();if(!inputValue)return;const locale=this.effectiveLocale,folded=inputValue.toLocaleLowerCase(locale);if(!(this.source?this.asyncRows:this.options.map(option=>({value:option.value,label:option.label}))).some(row=>row.value.toLocaleLowerCase(locale)===folded||row.label.toLocaleLowerCase(locale)===folded))return{value:inputValue,label:this.localize("comboboxCreate",void 0,{value:inputValue}),createInput:inputValue}}get renderedRows(){const all=this.effectiveRows,create=this.createRow,sourceOverflow=this.source?Math.max(0,this._sourceTotal-all.length):0;if(all.length<=this.maxRender)return{rows:create?[...all,create]:all,overflow:sourceOverflow};const originalIndex=new Map(all.map((r,i)=>[r,i])),capped=all.slice(0,this.maxRender),cappedValues=new Set(capped.map(r=>r.value));let appendedOutOfCap=!1;for(const v of this._selected)if(!cappedValues.has(v)){const selectedRow=all.find(r=>r.value===v);selectedRow&&(capped.push(selectedRow),appendedOutOfCap=!0)}return appendedOutOfCap&&capped.sort((a,b)=>originalIndex.get(a)-originalIndex.get(b)),create&&capped.push(create),{rows:capped,overflow:all.length-capped.length+(create?1:0)+sourceOverflow}}normalizeActiveIndex(){if(this.activeIndex<0)return;const navigableCount=this.renderedRows.rows.filter(row=>!row.disabled).length,next=navigableCount>0?Math.min(this.activeIndex,navigableCount-1):-1;next!==this.activeIndex&&(this.activeIndex=next)}get filtered(){const locale=this.effectiveLocale,q=this.query.trim().toLocaleLowerCase(locale),selectedLabel=this.multiple?"":this.labelFor(this._selected[0]??"")??"",effective=q&&q===selectedLabel.toLocaleLowerCase(locale)?"":q;if(!effective)return this.options;const fn=this.filter??((o,query2)=>o.label.toLocaleLowerCase(locale).includes(query2)||o.searchText.toLocaleLowerCase(locale).includes(query2));return this.options.filter(o=>fn(o,effective))}get displayValue(){return this.multiple||this.open||this.explicitInputValue?this.query:this._selected[0]?this.labelFor(this._selected[0]):""}announceOpenTransition(changed){if(this.openVetoed=!1,!changed.has("open")||this._isFirstUpdate)return;const name=this.open?"lr-show":"lr-hide";if(!this.isConnected){this.emit("lr-hide");return}this.emit(name,null,{cancelable:!0}).defaultPrevented&&(this.openVetoed=!0,this.open=!this.open,this.resolveTransitionWaiters(this.open?"lr-after-hide":"lr-after-show"))}show(){if(this.open||this.liveDisabled)return Promise.resolve();this.resolveTransitionWaiters("lr-after-hide");const settled=this.waitForTransition("lr-after-show");return this.open=!0,settled}hide(){if(!this.open)return Promise.resolve();this.resolveTransitionWaiters("lr-after-show");const settled=this.waitForTransition("lr-after-hide");return this.closeCleanupPending=!0,this.open=!1,settled}finalizeCloseState(){if(this.closeCleanupPending&&(this.closeCleanupPending=!1,this.activeIndex=-1,!this.multiple)){const queryChanged=this.query!=="";this.query="",this.explicitInputValue=!1,queryChanged&&this.source&&(this.asyncRows=[],this.sourceFailed=!1,this._sourceTotal=0,this._sourceTruncated=!1)}}activateListboxOverlay(){this.cleanup?.(),this.cleanup=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.restoreFocusOnClose=!0,this.overlayHandle=activateOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="listbox"]'),onEscape:()=>{this.hide()},onBackdrop:()=>{this.restoreFocusOnClose=!1,this.hide()},restoreFocusTo:this.inputEl??null,modal:!1,trapFocus:!1}),this.bindDocumentPointer();const anchor=this.renderRoot.querySelector('[part="combobox"]'),listbox=this.renderRoot.querySelector('[part="listbox"]');anchor&&listbox&&(this.cleanup=place(anchor,listbox,{placement:`${this.placement}-start`}))}teardownListboxOverlay(restoreFocus=this.restoreFocusOnClose){this.cleanup?.(),this.cleanup=void 0,this.restoringOverlayFocus=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.restoringOverlayFocus=!1}this.overlayHandle=void 0,this.unbindDocumentPointer(),this.restoreFocusOnClose=!0}bindDocumentPointer(){if(!this.isConnected)return;const ownerDocument=this.ownerDocument;if(this.pointerListenerDocument===ownerDocument&&this.pointerListener)return;this.unbindDocumentPointer();const listener=event=>{this.pointerListener!==listener||this.pointerListenerDocument!==ownerDocument||!this.isConnected||this.ownerDocument!==ownerDocument||this.onDocPointer(event)};this.pointerListenerDocument=ownerDocument,this.pointerListener=listener,ownerDocument.addEventListener("pointerdown",listener,!0)}unbindDocumentPointer(){this.pointerListenerDocument&&this.pointerListener&&this.pointerListenerDocument.removeEventListener("pointerdown",this.pointerListener,!0),this.pointerListenerDocument=void 0,this.pointerListener=void 0}reconnectOpenPopup(){!this.isConnected||!this.open||(this.activateListboxOverlay(),this.source&&this.asyncRows.length===0&&this.runSource(this.query))}updated(changed){super.updated(changed),changed.has("open")&&!this.openVetoed?this.open&&this.isConnected?(this.activateListboxOverlay(),this._isFirstUpdate||this.settleTransition("lr-after-show"),this.source&&this.asyncRows.length===0&&this.runSource(this.query)):this.open?this.teardownListboxOverlay(!1):(this.teardownListboxOverlay(),this._isFirstUpdate||this.settleTransition("lr-after-hide")):changed.has("open")&&this.openVetoed&&(this.restoreFocusOnClose=!0),changed.has("name")&&this.syncFormValue(),changed.has("validators")&&(this.updateValidity(),this.syncValidatorAttributeObserver()),(changed.has("touched")||changed.has("required")||changed.has("value")||changed.has("validators")||changed.has("validityRevision"))&&this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid),changed.has("activeIndex")&&this.renderRoot.querySelector('[part="option"][data-active]')?.scrollIntoView({block:"nearest"})}async settleTransition(event){const token=++this.transitionToken;if(await this.updateComplete,this.transitionToken===token){if(this.isConnected){const view=this.ownerDocument.defaultView;if(view&&await new Promise(resolve=>view.requestAnimationFrame(()=>resolve())),this.transitionToken!==token)return;const animations=this.renderRoot.querySelector('[part="listbox"]')?.getAnimations({subtree:!0})??[];if(await Promise.all(animations.map(animation=>animation.finished.catch(()=>{}))),this.transitionToken!==token)return}this.emit(event),this.resolveTransitionWaiters(event)}}waitForTransition(event){return new Promise(resolve=>{const waiters=this.transitionWaiters.get(event)??new Set;waiters.add(resolve),this.transitionWaiters.set(event,waiters)})}resolveTransitionWaiters(event){const waiters=this.transitionWaiters.get(event);if(waiters){this.transitionWaiters.delete(event);for(const resolve of waiters)resolve()}}emitValueEvents(){this.emit("input",{value:this.value}),this.emit("change",{value:this.value}),this.emit("lr-change",{value:this.value})}createOption(inputValue){if(this.liveDisabled||this.emit("lr-create",{inputValue},{cancelable:!0}).defaultPrevented)return;const option=this.ownerDocument.createElement(tag("option"));option.setAttribute("value",inputValue),option.textContent=inputValue,this.append(option),this.pickRow({value:inputValue,label:inputValue})}commitCustomValue(inputValue){if(this.liveDisabled||this.multiple||!inputValue)return;const selectionChanged=this._selected[0]!==inputValue;this._selectedLabelCache.set(inputValue,inputValue),this.value=inputValue,this.query="",this.explicitInputValue=!1,this.hide(),selectionChanged&&this.emitValueEvents()}pickRow(row){if(this.liveDisabled||row.disabled)return;if(row.createInput!==void 0){this.createOption(row.createInput);return}const selectionChanged=this.multiple||this._selected[0]!==row.value;if(this.multiple){const set=new Set(this._selected);set.has(row.value)?(set.delete(row.value),this._selectedRowCache.delete(row.value)):(set.add(row.value),this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.set(row.value,row)),this.value=[...set],this.query="",this.explicitInputValue=!1}else this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.clear(),this._selectedRowCache.set(row.value,row),this.value=row.value,this.query="",this.explicitInputValue=!1,this.hide();this.source&&this.runSource(this.query),selectionChanged&&this.emitValueEvents()}removeValue(value){if(this.liveDisabled)return;const next=this._selected.filter(v=>v!==value);next.length!==this._selected.length&&(this.value=next,this.emitValueEvents())}clear(){if(this.liveDisabled)return;const hadSelection=this._selected.length>0,queryChanged=this.query!=="";!hadSelection&&!queryChanged||(hadSelection&&(this.value=[]),this.query="",this.explicitInputValue=!1,this.source&&this.runSource(this.query),hadSelection&&(this.emitValueEvents(),this.emit("lr-clear")),queryChanged&&this.emit("lr-filter",{value:this.query}))}runSource(query2){const source=this.source;if(!source)return;this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0;const token=++this.sourceToken,ownerWindow=this.ownerDocument.defaultView;if(!this.isConnected||!ownerWindow)return;const timer={owner:ownerWindow,handle:0,token};timer.handle=ownerWindow.setTimeout(()=>{if(this.sourceTimer!==timer||token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;this.sourceTimer=void 0;const controller=new ownerWindow.AbortController;this.sourceAbort=controller,this.loading=!0,this.sourceFailed=!1,Promise.resolve().then(()=>source(query2,{signal:controller.signal,limit:MAX_SOURCE_ROWS})).then(result=>{if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const normalized=normalizeSourceResult(result);this._sourceTotal=normalized.total,this._sourceTruncated=normalized.truncated,this.asyncRows=normalized.rows,this.sourceFailed=!1,this.normalizeActiveIndex();const selected=new Set(this._selected);for(const row of normalized.rows)selected.has(row.value)&&this._selectedRowCache.set(row.value,row)}).catch(err=>{token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||typeof err=="object"&&err!==null&&"name"in err&&err.name==="AbortError"||(this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this.sourceFailed=!0,this.sourceErrorAnnouncementSink?.announce(this.localize("comboboxLoadError")),console.warn("<lr-combobox> source() rejected:",err))}).finally(()=>{token===this.sourceToken&&(this.loading=!1)})},this._sourceDelay),this.sourceTimer=timer}clearSourceTimer(){const timer=this.sourceTimer;this.sourceTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}renderRows(rows,activeId){const out=[];let currentGroup,currentGroupRows=[],groupIndex=0;const selectedSet=new Set(this._selected),flushGroup=()=>{if(currentGroupRows.length){if(currentGroup){const labelId=`${this.listId}-group-${groupIndex++}`;out.push(html`<div role="group" aria-labelledby=${labelId}>
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{place}from"../../../internal/positioner.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{chevronIcon,closeIcon}from"../../../internal/icons.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState,syncValidityStates}from"../../../internal/custom-states.js";import{submitOnEnter}from"../../../internal/submit-on-enter.js";import{finiteCount,finiteDuration}from"../../../internal/numbers.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./combobox.styles.js";import"./option.class.js";import{autocorrectConverter,omittedEmptyStringConverter,spellcheckConverter}from"../../../internal/converters.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{attachInternalsSafely,getFormOwner,installCustomErrorProperty,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{tag}from"../../../internal/prefix.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{isOptionSelectedDirty,wasOptionInitiallySelected,RESET_OPTION_SELECTED_FROM_OWNER,SET_OPTION_SELECTED_FROM_OWNER}from"../../../internal/option-selection.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_collapse,LYRA_DEFAULT_comboboxCreate,LYRA_DEFAULT_comboboxLabel,LYRA_DEFAULT_comboboxLoadError,LYRA_DEFAULT_comboboxOverflow,LYRA_DEFAULT_comboboxRequired,LYRA_DEFAULT_comboboxSelectedOverflow,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_progress,LYRA_DEFAULT_removeWithContext,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_valueInvalid}from"../../../internal/default-strings.generated.js";function isLyraOptionElement(value){return isHtmlElement(value)&&value.localName===tag("option")}const VALIDITY_FLAG_KEYS=new Set(["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"]),comboboxSpellcheckConverter={...spellcheckConverter,fromAttribute:(value,type)=>value===null?void 0:spellcheckConverter.fromAttribute?.(value,type)};function isValidityFlagKey(value){return typeof value=="string"&&VALIDITY_FLAG_KEYS.has(value)}const MAX_SOURCE_ROWS=2e3,MAX_SOURCE_TEXT_UNITS=25e4,MAX_SOURCE_FIELD_UNITS=4096,MAX_RENDER_ROWS=1e3;function normalizeSourceResult(input){let candidateRows,candidateTotal;try{Array.isArray(input)?candidateRows=input:typeof input=="object"&&input!==null&&(candidateRows=input.rows,candidateTotal=input.total)}catch{throw new TypeError("Invalid combobox source result")}if(!Array.isArray(candidateRows))throw new TypeError("Invalid combobox source result");const providerTotal=typeof candidateTotal=="number"&&Number.isFinite(candidateTotal)&&candidateTotal>=0?Math.trunc(candidateTotal):candidateRows.length,rows=[];let textUnits=0;const limit=Math.min(candidateRows.length,MAX_SOURCE_ROWS);for(let index=0;index<limit;index++)try{const value=candidateRows[index]?.value,label=candidateRows[index]?.label;if(typeof value!="string"||typeof label!="string"||value.length>MAX_SOURCE_FIELD_UNITS||label.length>MAX_SOURCE_FIELD_UNITS)continue;const source=candidateRows[index],optionalText=key=>{const candidate=source[key];return typeof candidate=="string"&&candidate.length<=MAX_SOURCE_FIELD_UNITS?candidate:void 0},sub=optionalText("sub"),accessibleLabel=optionalText("accessibleLabel"),dotColor=optionalText("dotColor"),group=optionalText("group"),badgeCandidate=source.badge,badge=typeof badgeCandidate=="string"&&badgeCandidate.length<=MAX_SOURCE_FIELD_UNITS||typeof badgeCandidate=="number"&&Number.isFinite(badgeCandidate)?badgeCandidate:void 0,units=value.length+label.length+(sub?.length??0)+(accessibleLabel?.length??0)+(dotColor?.length??0)+(group?.length??0)+(typeof badge=="string"?badge.length:0);if(textUnits+units>MAX_SOURCE_TEXT_UNITS)break;textUnits+=units,rows.push({value,label,...sub===void 0?{}:{sub},...source.icon===void 0?{}:{icon:source.icon},...source.start===void 0?{}:{start:source.start},...source.end===void 0?{}:{end:source.end},...badge===void 0?{}:{badge},...accessibleLabel===void 0?{}:{accessibleLabel},...source.data===void 0?{}:{data:source.data},...dotColor===void 0?{}:{dotColor},...group===void 0?{}:{group},...typeof source.disabled=="boolean"?{disabled:source.disabled}:{}})}catch{}const total=Math.max(providerTotal,candidateRows.length);return{rows,total,truncated:total>rows.length}}class LyraCombobox extends LyraElement{static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,collapse:LYRA_DEFAULT_collapse,comboboxCreate:LYRA_DEFAULT_comboboxCreate,comboboxLabel:LYRA_DEFAULT_comboboxLabel,comboboxLoadError:LYRA_DEFAULT_comboboxLoadError,comboboxOverflow:LYRA_DEFAULT_comboboxOverflow,comboboxRequired:LYRA_DEFAULT_comboboxRequired,comboboxSelectedOverflow:LYRA_DEFAULT_comboboxSelectedOverflow,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noMatches:LYRA_DEFAULT_noMatches,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,progress:LYRA_DEFAULT_progress,removeWithContext:LYRA_DEFAULT_removeWithContext,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,valueInvalid:LYRA_DEFAULT_valueInvalid}}static{this.immutableEventDetails=Object.freeze(["lr-change","input","change"])}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},multiple:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},value:{noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},maxOptionsVisible:{type:Number,attribute:"max-options-visible",noAccessor:!0},maxRender:{type:Number,attribute:"max-render",noAccessor:!0},sourceDelay:{type:Number,attribute:"source-delay",noAccessor:!0}}}get open(){return this._open}set open(next){const old=this._open,liveDisabled=this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled");if(this._open=!!next&&!liveDisabled,this._open===old){next&&!this._open&&this.hasAttribute("open")&&this.removeAttribute("open");return}this.requestUpdate("open",old)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=!!next,this.requestUpdate()}get inputmode(){return this.inputMode}set inputmode(next){this.inputMode=next??""}get enterkeyhint(){return this.enterKeyHint}set enterkeyhint(next){this.enterKeyHint=next??""}get inputValue(){return this.query}set inputValue(next){this.explicitInputValue=!0,this.query=next??"",this.activeIndex=-1,this.source&&this.runSource(this.query),this.requestUpdate()}constructor(){super(),this.placeholder="",this.label="",this.hint="",this.errorText="",this.allowCreate=!1,this.allowCustomValue=!1,this.appearance="outlined",this.placement="bottom",this.size="m",this.pill=!1,this.clearable=!1,this.withClear=!1,this.withLabel=!1,this.withHint=!1,this.validators=[],this.autocomplete="off",this.inputMode="",this.enterKeyHint="",this.spellcheck=!1,this.autocapitalize="",this.autocorrectValue=!0,this.filter=null,this.source=null,this.query="",this.explicitInputValue=!1,this.activeIndex=-1,this.options=[],this.touched=!1,this.validityRevision=0,this.slotPresence=new SlotPresenceController(this),this.loading=!1,this.sourceFailed=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.sourceToken=0,this._sourceWarmed=!1,this._selectedLabelCache=new Map,this._selectedRowCache=new Map,this._rowsByValue=new Map,this._open=!1,this._fieldsetDisabled=!1,this.listId=nextId("combobox-list"),this.inputId=nextId("combobox-input"),this.restoreFocusOnClose=!0,this.restoringOverlayFocus=!1,this._isFirstUpdate=!0,this.openVetoed=!1,this.closeCleanupPending=!1,this.transitionToken=0,this.transitionWaiters=new Map,this._selected=[],this._valueDirty=!1,this._multiple=!1,this._disabled=!1,this._required=!1,this._defaultSelected=[],this._defaultCaptured=!1,this._restoredStateActive=!1,this._name="",this._maxOptionsVisible=3,this._maxRender=200,this._sourceDelay=200,this.collectOptions=e=>{const slot=e.target,previous=new Set(this.options);if(this.options=slot.assignedElements({flatten:!0}).filter(isLyraOptionElement),this.adornmentClones=new WeakMap,this.normalizeActiveIndex(),this._defaultCaptured){const newDefaults=this.options.filter(option=>!previous.has(option)&&option.defaultSelected),newLive=this.options.filter(option=>!previous.has(option)&&option.selected&&!option.defaultSelected);this.refreshOptionDefaults();const eligible=[...!this._restoredStateActive&&!this._valueDirty?newDefaults:[],...this._restoredStateActive?[]:newLive];if(eligible.length){const values=eligible.map(option=>option.value),next=this.multiple?[...new Set([...this._selected,...values])]:values[values.length-1];newLive.length>0?this.value=next:this.setValue(next,!1);return}}else{this._defaultCaptured=!0;const allDefaults=this.options.filter(option=>option.defaultSelected).map(option=>option.value),allLive=this.options.filter(option=>option.selected).map(option=>option.value),defaults=this.multiple?allDefaults:allDefaults.slice(0,1),live=this.multiple?allLive:allLive.slice(0,1),initialLive=this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value),optionDirty=this.options.some(option=>isOptionSelectedDirty(option)),dirtyValues=this.options.filter(option=>isOptionSelectedDirty(option)&&option.selected).map(option=>option.value);this._defaultSelected=[...defaults.length>0?defaults:initialLive.length>0?initialLive:live];const fromDefaults=defaults.length>0,initial=optionDirty?this.multiple?allLive:dirtyValues.slice(-1)[0]?dirtyValues.slice(-1):live:fromDefaults?defaults:live;if(initial.length&&!this._restoredStateActive&&!this._valueDirty){const next=this.multiple?initial:initial[0];fromDefaults&&!optionDirty?this.setValue(next,!1):this.value=next;return}optionDirty&&(this._valueDirty=!0)}this.reflectSelected()},this.onOptionChange=e=>{e.stopPropagation(),queueMicrotask(()=>{this.refreshOptionDefaults(),this.reflectSelected(),this.options=[...this.options],this.normalizeActiveIndex()})},this.adornmentClones=new WeakMap,this.onDocPointer=e=>{if(!e.composedPath().includes(this)){if(this.overlayHandle?.isActive()){this.overlayHandle.dismissBackdrop();return}this.restoreFocusOnClose=!1,this.hide()}},this.onInput=e=>{this.liveDisabled||(this.explicitInputValue=!1,this.query=e.target.value,this.activeIndex=-1,this.show(),this.source&&this.runSource(this.query),this.emit("lr-filter",{value:this.query}))},this.onInputBlur=event=>{this.liveDisabled||(this.touched=!0),this.syncCustomStates(),this.restoreFocusOnClose=!1,this.hide(),relayNativeEvent(this,event)},this.onInputFocus=event=>{if(this.liveDisabled){event.stopPropagation();return}this.restoringOverlayFocus||this.show(),relayNativeEvent(this,event)},this.onKeyDown=e=>{if(this.liveDisabled)return;const navigable=this.renderedRows.rows.filter(r=>!r.disabled);switch(e.key){case"ArrowDown":if(e.preventDefault(),!this.open){this.show();return}this.activeIndex=Math.min(navigable.length-1,this.activeIndex+1);break;case"ArrowUp":if(e.preventDefault(),!this.open){this.show();return}this.activeIndex=Math.max(0,this.activeIndex-1);break;case"Enter":{const activeRow=navigable[this.activeIndex];if(this.open&&this.activeIndex>=0&&activeRow){e.preventDefault(),this.pickRow(activeRow);break}const create=this.createRow;if(this.open&&create){e.preventDefault(),this.createOption(create.createInput);break}if(this.open&&this.allowCustomValue&&!this.multiple&&this.query.trim()){e.preventDefault(),this.commitCustomValue(this.query.trim());break}submitOnEnter(this,e);break}case"Escape":this.open&&(!this.overlayHandle?.isActive()||this.overlayHandle.isTopmost())&&(e.preventDefault(),this.hide());break;case"Home":this.open&&(e.preventDefault(),this.activeIndex=0);break;case"End":this.open&&(e.preventDefault(),this.activeIndex=navigable.length-1);break;case"Backspace":this.multiple&&!this.query&&this._selected.length&&this.removeValue(this._selected[this._selected.length-1]);break}},this.onComboMouseDown=e=>{this.liveDisabled||e.composedPath()[0]!==this.inputEl&&(e.target.closest("button")||(e.preventDefault(),this.inputEl?.focus(),this.show()))},this.onListboxMouseDown=e=>{e.preventDefault()},this.onListboxClick=e=>{const value=e.target.closest('[part="option"]')?.dataset.value;if(value===void 0)return;const row=this._rowsByValue.get(value);row&&this.pickRow(row)},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init))}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}get validationTarget(){return this.validationTargetOverride??this.inputEl??void 0}set validationTarget(next){this.validationTargetOverride=next??void 0,this.validityController.refreshAnchor()}resetValidity(){this.validityController.setCustomValidity(""),this.updateValidity()}get input(){return this.inputEl??null}get selectionStart(){return this.inputEl?.selectionStart??null}set selectionStart(value){this.inputEl&&(this.inputEl.selectionStart=value)}get selectionEnd(){return this.inputEl?.selectionEnd??null}set selectionEnd(value){this.inputEl&&(this.inputEl.selectionEnd=value)}get selectionDirection(){return this.inputEl?.selectionDirection}set selectionDirection(value){this.inputEl&&(this.inputEl.selectionDirection=value)}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}focus(options){this.liveDisabled||this.inputEl?.focus(options)}blur(){this.inputEl?.blur()}click(){this.liveDisabled||(this.inputEl?.focus(),this.show())}select(){this.inputEl?.select()}setSelectionRange(start,end,direction){this.inputEl?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const input=this.inputEl;input&&(start===void 0||end===void 0?input.setRangeText(replacement):input.setRangeText(replacement,start,end,selectMode),this.explicitInputValue=!0,this.query=input.value,this.activeIndex=-1,this.source&&this.runSource(this.query))}[VALIDITY_ANCHOR](){return this.validationTarget}connectedCallback(){super.connectedCallback(),this.syncSourceErrorAnnouncementSink(),this.updateValidity(),this.hasUpdated&&this.syncValidatorAttributeObserver(),this.hasUpdated&&queueMicrotask(()=>{this.open?this.reconnectOpenPopup():this.source&&this._selected.length&&this.asyncRows.length===0&&this.runSource("")})}adoptedCallback(){super.adoptedCallback(),this.cleanup?.(),this.cleanup=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.unbindDocumentPointer(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.releaseSourceErrorAnnouncementSink(),this.syncSourceErrorAnnouncementSink()}syncSourceErrorAnnouncementSink(){this.isConnected&&this.sourceErrorAnnouncementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseSourceErrorAnnouncementSink(),this.sourceErrorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}))}releaseSourceErrorAnnouncementSink(){this.sourceErrorAnnouncementSink?.release(),this.sourceErrorAnnouncementSink=void 0}willUpdate(changed){super.willUpdate(changed),this._isFirstUpdate=!this.hasUpdated,this.announceOpenTransition(changed),changed.has("open")&&this.openVetoed?this.closeCleanupPending=!1:changed.has("open")&&!this.open&&this.finalizeCloseState(),changed.has("source")&&(this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceToken++,this.loading=!1,this.sourceFailed=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this._sourceWarmed=!1,this.source&&this.open&&this.runSource(this.query)),!this._sourceWarmed&&this.source&&this._selected.length&&this.asyncRows.length===0&&(this._sourceWarmed=!0,this.runSource(""))}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.syncFormValue(),this.requestUpdate("name",old)}get multiple(){return this._multiple}set multiple(next){const old=this._multiple;this._multiple=!!next,this.toggleAttribute("multiple",this._multiple),this.syncFormValue(),this.requestUpdate("multiple",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._disabled&&this.hide(),this.updateValidity(),this.requestUpdate("disabled",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get value(){return this.multiple?[...this._selected]:this._selected[0]??""}set value(next){this.setValue(next,!0)}setValue(next,dirty){const old=this._selected;dirty&&(this._restoredStateActive=!1,this._valueDirty=!0),this._selected=Array.isArray(next)?[...next]:next?[next]:[];const selected=new Set(this._selected);for(const value of selected){const row=this.effectiveRows.find(candidate=>candidate.value===value)??this.asyncRows.find(candidate=>candidate.value===value);row&&this._selectedRowCache.set(value,row)}for(const value of this._selectedRowCache.keys())selected.has(value)||this._selectedRowCache.delete(value);for(const value of this._selectedLabelCache.keys())selected.has(value)||this._selectedLabelCache.delete(value);this.syncFormValue(),this.reflectSelected(),this.updateValidity(),this.requestUpdate("value",old)}get maxOptionsVisible(){return this._maxOptionsVisible}set maxOptionsVisible(next){const old=this._maxOptionsVisible;this._maxOptionsVisible=finiteCount(next,3),this.requestUpdate("maxOptionsVisible",old)}get maxRender(){return this._maxRender}get sourceDelay(){return this._sourceDelay}set sourceDelay(next){const old=this._sourceDelay;this._sourceDelay=finiteDuration(next,200),this.requestUpdate("sourceDelay",old)}set maxRender(next){const old=this._maxRender;this._maxRender=Math.min(finiteCount(next,200),MAX_RENDER_ROWS),this.requestUpdate("maxRender",old)}get sourceTotal(){return this._sourceTotal}get sourceTruncated(){return this._sourceTruncated}get selectedRows(){return this._selected.map(value=>this._selectedRowCache.get(value)??this.effectiveRows.find(row=>row.value===value)??this.asyncRows.find(row=>row.value===value)).filter(row=>row!=null).map(row=>({...row}))}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}validatorResult(){for(const validator of Array.isArray(this.validators)?this.validators:[]){let result;try{if(typeof validator=="object"&&validator!==null&&"checkValidity"in validator){const checked=validator.checkValidity(this);if(checked?.isValid===!0)continue;const flags={};for(const key of Array.isArray(checked?.invalidKeys)?checked.invalidKeys:[])isValidityFlagKey(key)&&(flags[key]=!0);Object.values(flags).some(Boolean)||(flags.customError=!0);let message=typeof checked?.message=="string"?checked.message:"";return!message&&typeof validator.message=="string"&&(message=validator.message),!message&&typeof validator.message=="function"&&(message=validator.message(this)),{flags,message:message||this.localize("valueInvalid")}}result=typeof validator=="function"?validator(this.value,this):validator?.validate(this.value,this)}catch{return{flags:{customError:!0},message:this.localize("valueInvalid")}}if(!(result===void 0||result===!0)){if(typeof result=="string")return{flags:{customError:!0},message:result};if(result===!1)return{flags:{customError:!0},message:this.localize("valueInvalid")};if(result&&typeof result=="object"&&Object.values(result).some(Boolean))return{flags:result,message:this.localize("valueInvalid")}}}return{}}syncValidatorAttributeObserver(){this.disconnectValidatorAttributeObserver();const owner=this.ownerDocument.defaultView,MutationObserverCtor=owner?.MutationObserver;if(!this.isConnected||!owner||typeof MutationObserverCtor!="function")return;const attributes=new Set;for(const validator of Array.isArray(this.validators)?this.validators:[]){if(typeof validator!="object"||validator===null||!("checkValidity"in validator))continue;let observed;try{observed=validator.observedAttributes}catch{continue}if(Array.isArray(observed))for(const name of observed)typeof name=="string"&&name.length>0&&attributes.add(name)}if(attributes.size===0)return;const binding={},observer=new MutationObserverCtor(()=>{this.validatorAttributeObserver!==binding||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.updateValidity(),this.validityRevision++)});binding.observer=observer,binding.owner=owner;try{observer.observe(this,{attributes:!0,attributeFilter:[...attributes]}),this.validatorAttributeObserver=binding}catch{observer.disconnect()}}disconnectValidatorAttributeObserver(){const binding=this.validatorAttributeObserver;this.validatorAttributeObserver=void 0,binding?.observer.disconnect()}updateValidity(){if(this.barredFromValidation){this.validityController.setValidity({}),this.syncCustomStates();return}const flags={};let message="";this.required&&this._selected.length===0&&(flags.valueMissing=!0,message=this.localize("comboboxRequired"));const configured=this.validatorResult();configured.flags&&Object.assign(flags,configured.flags),configured.message&&(message=configured.message),this.validityController.setValidity(flags,message),this.syncCustomStates()}syncCustomStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this.touched,barred:this.barredFromValidation}),setCustomState(this.internals,"blank",this._selected.length===0),setCustomState(this.internals,"disabled",this.effectiveDisabled)}syncFormValue(){const state2=JSON.stringify(this._selected);if(this.multiple){if(!this.name){this.internals.setFormValue(null,state2);return}const fd=new FormData;for(const v of this._selected)fd.append(this.name,v);this.internals.setFormValue(fd,state2)}else this.internals.setFormValue(this._selected[0]??"",state2)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}formResetCallback(){this.touched=!1,this._restoredStateActive=!1,this._valueDirty=!1;const resetValues=this._defaultSelected.length>0?this._defaultSelected:this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value);this._defaultSelected.length===0&&resetValues.length>0&&(this._defaultSelected=[...resetValues]);const defaults=new Set(resetValues);for(const option of this.options)option[RESET_OPTION_SELECTED_FROM_OWNER](defaults.has(option.value));this.setValue(this.multiple?[...resetValues]:resetValues[0]??"",!1),this.query="",this.explicitInputValue=!1}formStateRestoreCallback(state2,reason){let selected=[];if(typeof state2=="string")try{const parsed=JSON.parse(state2);Array.isArray(parsed)&&parsed.every(value=>typeof value=="string")&&(selected=parsed)}catch{}this.value=this.multiple?selected:selected[0]??"",this._restoredStateActive=!0}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,disabled&&this.hide(),this.updateValidity(),this.requestUpdate()}checkValidity(){return this.updateValidity(),this.internals.checkValidity()}reportValidity(){return this.touched=!0,this.updateValidity(),this.syncCustomStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncCustomStates()}disconnectedCallback(){this.transitionToken++,this.releaseSourceErrorAnnouncementSink(),this.disconnectValidatorAttributeObserver(),super.disconnectedCallback(),this.cleanup?.(),this.cleanup=void 0,this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.unbindDocumentPointer(),this.resolveTransitionWaiters("lr-after-show"),this.resolveTransitionWaiters("lr-after-hide"),this.open=!1}refreshOptionDefaults(){const declared=this.options.filter(option=>option.defaultSelected).map(option=>option.value);this._defaultSelected=this.multiple?declared:declared.slice(0,1),!this._valueDirty&&!this._restoredStateActive&&this.setValue(this.multiple?[...this._defaultSelected]:this._defaultSelected[0]??"",!1)}reflectSelected(){const sel=new Set(this._selected);for(const option of this.options)option[SET_OPTION_SELECTED_FROM_OWNER](sel.has(option.value))}labelFor(value){return this._selectedLabelCache.get(value)??this.options.find(o=>o.value===value)?.label??this.asyncRows.find(r=>r.value===value)?.label??value}adornmentsFor(option){const cached=this.adornmentClones.get(option);if(cached)return cached;const cloneSlot=selector=>{const nodes=Array.from(option.querySelectorAll(selector));if(nodes.length!==0)return nodes.map(node=>node.cloneNode(!0))},resolved={start:cloneSlot(':scope > [slot="start"], :scope > [slot="prefix"]'),end:cloneSlot(':scope > [slot="end"], :scope > [slot="suffix"]')};return this.adornmentClones.set(option,resolved),resolved}get effectiveRows(){return this.source?this.asyncRows:this.filtered.map(o=>{const adornments=this.adornmentsFor(o);return{value:o.value,label:o.label,sub:o.sub||void 0,dotColor:o.dotColor||void 0,group:o.group||void 0,disabled:o.disabled,...adornments.start===void 0?{}:{start:adornments.start},...adornments.end===void 0?{}:{end:adornments.end}}})}get createRow(){if(!this.allowCreate)return;const inputValue=this.query.trim();if(!inputValue)return;const locale=this.effectiveLocale,folded=inputValue.toLocaleLowerCase(locale);if(!(this.source?this.asyncRows:this.options.map(option=>({value:option.value,label:option.label}))).some(row=>row.value.toLocaleLowerCase(locale)===folded||row.label.toLocaleLowerCase(locale)===folded))return{value:inputValue,label:this.localize("comboboxCreate",void 0,{value:inputValue}),createInput:inputValue}}get renderedRows(){const all=this.effectiveRows,create=this.createRow,sourceOverflow=this.source?Math.max(0,this._sourceTotal-all.length):0;if(all.length<=this.maxRender)return{rows:create?[...all,create]:all,overflow:sourceOverflow};const originalIndex=new Map(all.map((r,i)=>[r,i])),capped=all.slice(0,this.maxRender),cappedValues=new Set(capped.map(r=>r.value));let appendedOutOfCap=!1;for(const v of this._selected)if(!cappedValues.has(v)){const selectedRow=all.find(r=>r.value===v);selectedRow&&(capped.push(selectedRow),appendedOutOfCap=!0)}return appendedOutOfCap&&capped.sort((a,b)=>originalIndex.get(a)-originalIndex.get(b)),create&&capped.push(create),{rows:capped,overflow:all.length-capped.length+(create?1:0)+sourceOverflow}}normalizeActiveIndex(){if(this.activeIndex<0)return;const navigableCount=this.renderedRows.rows.filter(row=>!row.disabled).length,next=navigableCount>0?Math.min(this.activeIndex,navigableCount-1):-1;next!==this.activeIndex&&(this.activeIndex=next)}get filtered(){const locale=this.effectiveLocale,q=this.query.trim().toLocaleLowerCase(locale),selectedLabel=this.multiple?"":this.labelFor(this._selected[0]??"")??"",effective=q&&q===selectedLabel.toLocaleLowerCase(locale)?"":q;if(!effective)return this.options;const fn=this.filter??((o,query2)=>o.label.toLocaleLowerCase(locale).includes(query2)||o.searchText.toLocaleLowerCase(locale).includes(query2));return this.options.filter(o=>fn(o,effective))}get displayValue(){return this.multiple||this.open||this.explicitInputValue?this.query:this._selected[0]?this.labelFor(this._selected[0]):""}announceOpenTransition(changed){if(this.openVetoed=!1,!changed.has("open")||this._isFirstUpdate)return;const name=this.open?"lr-show":"lr-hide";if(!this.isConnected){this.emit("lr-hide");return}this.emit(name,null,{cancelable:!0}).defaultPrevented&&(this.openVetoed=!0,this.open=!this.open,this.resolveTransitionWaiters(this.open?"lr-after-hide":"lr-after-show"))}show(){if(this.open||this.liveDisabled)return Promise.resolve();this.resolveTransitionWaiters("lr-after-hide");const settled=this.waitForTransition("lr-after-show");return this.open=!0,settled}hide(){if(!this.open)return Promise.resolve();this.resolveTransitionWaiters("lr-after-show");const settled=this.waitForTransition("lr-after-hide");return this.closeCleanupPending=!0,this.open=!1,settled}finalizeCloseState(){if(this.closeCleanupPending&&(this.closeCleanupPending=!1,this.activeIndex=-1,!this.multiple)){const queryChanged=this.query!=="";this.query="",this.explicitInputValue=!1,queryChanged&&this.source&&(this.asyncRows=[],this.sourceFailed=!1,this._sourceTotal=0,this._sourceTruncated=!1)}}activateListboxOverlay(){this.cleanup?.(),this.cleanup=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.restoreFocusOnClose=!0,this.overlayHandle=activateOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="listbox"]'),onEscape:()=>{this.hide()},onBackdrop:()=>{this.restoreFocusOnClose=!1,this.hide()},restoreFocusTo:this.inputEl??null,modal:!1,trapFocus:!1}),this.bindDocumentPointer();const anchor=this.renderRoot.querySelector('[part="combobox"]'),listbox=this.renderRoot.querySelector('[part="listbox"]');anchor&&listbox&&(this.cleanup=place(anchor,listbox,{placement:`${this.placement}-start`}))}teardownListboxOverlay(restoreFocus=this.restoreFocusOnClose){this.cleanup?.(),this.cleanup=void 0,this.restoringOverlayFocus=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.restoringOverlayFocus=!1}this.overlayHandle=void 0,this.unbindDocumentPointer(),this.restoreFocusOnClose=!0}bindDocumentPointer(){if(!this.isConnected)return;const ownerDocument=this.ownerDocument;if(this.pointerListenerDocument===ownerDocument&&this.pointerListener)return;this.unbindDocumentPointer();const listener=event=>{this.pointerListener!==listener||this.pointerListenerDocument!==ownerDocument||!this.isConnected||this.ownerDocument!==ownerDocument||this.onDocPointer(event)};this.pointerListenerDocument=ownerDocument,this.pointerListener=listener,ownerDocument.addEventListener("pointerdown",listener,!0)}unbindDocumentPointer(){this.pointerListenerDocument&&this.pointerListener&&this.pointerListenerDocument.removeEventListener("pointerdown",this.pointerListener,!0),this.pointerListenerDocument=void 0,this.pointerListener=void 0}reconnectOpenPopup(){!this.isConnected||!this.open||(this.activateListboxOverlay(),this.source&&this.asyncRows.length===0&&this.runSource(this.query))}syncVisibleOptionsCap(){const listbox=this.renderRoot?.querySelector('[part="listbox"]');if(!listbox)return;const clear=()=>{listbox.style.removeProperty("max-block-size")},requested=typeof this.visibleOptions=="number"?finiteCount(this.visibleOptions,0):0;if(requested<=0)return clear();const rows=listbox.querySelectorAll('[part="option"]');if(rows.length<=requested)return clear();const boundary=rows[requested];if(!boundary)return clear();const cap=boundary.getBoundingClientRect().top-listbox.getBoundingClientRect().top;if(!Number.isFinite(cap)||cap<=0)return clear();listbox.style.setProperty("max-block-size",`min(${Math.ceil(cap)}px, var(--lr-positioner-available-block-size, var(--lr-size-18rem)))`)}updated(changed){super.updated(changed),this.syncVisibleOptionsCap(),changed.has("open")&&!this.openVetoed?this.open&&this.isConnected?(this.activateListboxOverlay(),this._isFirstUpdate||this.settleTransition("lr-after-show"),this.source&&this.asyncRows.length===0&&this.runSource(this.query)):this.open?this.teardownListboxOverlay(!1):(this.teardownListboxOverlay(),this._isFirstUpdate||this.settleTransition("lr-after-hide")):changed.has("open")&&this.openVetoed&&(this.restoreFocusOnClose=!0),changed.has("name")&&this.syncFormValue(),changed.has("validators")&&(this.updateValidity(),this.syncValidatorAttributeObserver()),(changed.has("touched")||changed.has("required")||changed.has("value")||changed.has("validators")||changed.has("validityRevision"))&&this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid),changed.has("activeIndex")&&this.renderRoot.querySelector('[part="option"][data-active]')?.scrollIntoView({block:"nearest"})}async settleTransition(event){const token=++this.transitionToken;if(await this.updateComplete,this.transitionToken===token){if(this.isConnected){const view=this.ownerDocument.defaultView;if(view&&await new Promise(resolve=>view.requestAnimationFrame(()=>resolve())),this.transitionToken!==token)return;const animations=this.renderRoot.querySelector('[part="listbox"]')?.getAnimations({subtree:!0})??[];if(await Promise.all(animations.map(animation=>animation.finished.catch(()=>{}))),this.transitionToken!==token)return}this.emit(event),this.resolveTransitionWaiters(event)}}waitForTransition(event){return new Promise(resolve=>{const waiters=this.transitionWaiters.get(event)??new Set;waiters.add(resolve),this.transitionWaiters.set(event,waiters)})}resolveTransitionWaiters(event){const waiters=this.transitionWaiters.get(event);if(waiters){this.transitionWaiters.delete(event);for(const resolve of waiters)resolve()}}emitValueEvents(){this.emit("input",{value:this.value}),this.emit("change",{value:this.value}),this.emit("lr-change",{value:this.value})}createOption(inputValue){if(this.liveDisabled||this.emit("lr-create",{inputValue},{cancelable:!0}).defaultPrevented)return;const option=this.ownerDocument.createElement(tag("option"));option.setAttribute("value",inputValue),option.textContent=inputValue,this.append(option),this.pickRow({value:inputValue,label:inputValue})}commitCustomValue(inputValue){if(this.liveDisabled||this.multiple||!inputValue)return;const selectionChanged=this._selected[0]!==inputValue;this._selectedLabelCache.set(inputValue,inputValue),this.value=inputValue,this.query="",this.explicitInputValue=!1,this.hide(),selectionChanged&&this.emitValueEvents()}pickRow(row){if(this.liveDisabled||row.disabled)return;if(row.createInput!==void 0){this.createOption(row.createInput);return}const selectionChanged=this.multiple||this._selected[0]!==row.value;if(this.multiple){const set=new Set(this._selected);set.has(row.value)?(set.delete(row.value),this._selectedRowCache.delete(row.value)):(set.add(row.value),this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.set(row.value,row)),this.value=[...set],this.query="",this.explicitInputValue=!1}else this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.clear(),this._selectedRowCache.set(row.value,row),this.value=row.value,this.query="",this.explicitInputValue=!1,this.hide();this.source&&this.runSource(this.query),selectionChanged&&this.emitValueEvents()}removeValue(value){if(this.liveDisabled)return;const next=this._selected.filter(v=>v!==value);next.length!==this._selected.length&&(this.value=next,this.emitValueEvents())}clear(){if(this.liveDisabled)return;const hadSelection=this._selected.length>0,queryChanged=this.query!=="";!hadSelection&&!queryChanged||(hadSelection&&(this.value=[]),this.query="",this.explicitInputValue=!1,this.source&&this.runSource(this.query),hadSelection&&(this.emitValueEvents(),this.emit("lr-clear")),queryChanged&&this.emit("lr-filter",{value:this.query}))}runSource(query2){const source=this.source;if(!source)return;this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0;const token=++this.sourceToken,ownerWindow=this.ownerDocument.defaultView;if(!this.isConnected||!ownerWindow)return;const timer={owner:ownerWindow,handle:0,token};timer.handle=ownerWindow.setTimeout(()=>{if(this.sourceTimer!==timer||token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;this.sourceTimer=void 0;const controller=new ownerWindow.AbortController;this.sourceAbort=controller,this.loading=!0,this.sourceFailed=!1,Promise.resolve().then(()=>source(query2,{signal:controller.signal,limit:MAX_SOURCE_ROWS})).then(result=>{if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const normalized=normalizeSourceResult(result);this._sourceTotal=normalized.total,this._sourceTruncated=normalized.truncated,this.asyncRows=normalized.rows,this.sourceFailed=!1,this.normalizeActiveIndex();const selected=new Set(this._selected);for(const row of normalized.rows)selected.has(row.value)&&this._selectedRowCache.set(row.value,row)}).catch(err=>{token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||typeof err=="object"&&err!==null&&"name"in err&&err.name==="AbortError"||(this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this.sourceFailed=!0,this.sourceErrorAnnouncementSink?.announce(this.localize("comboboxLoadError")),console.warn("<lr-combobox> source() rejected:",err))}).finally(()=>{token===this.sourceToken&&(this.loading=!1)})},this._sourceDelay),this.sourceTimer=timer}clearSourceTimer(){const timer=this.sourceTimer;this.sourceTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}renderRows(rows,activeId){const out=[];let currentGroup,currentGroupRows=[],groupIndex=0;const selectedSet=new Set(this._selected),flushGroup=()=>{if(currentGroupRows.length){if(currentGroup){const labelId=`${this.listId}-group-${groupIndex++}`;out.push(html`<div role="group" aria-labelledby=${labelId}>
|
|
2
2
|
<div id=${labelId} part="group-label" class="group-label">${currentGroup}</div>
|
|
3
3
|
${currentGroupRows}
|
|
4
4
|
</div>`)}else out.push(...currentGroupRows);currentGroupRows=[]}};return rows.forEach((o,i)=>{o.group!==currentGroup&&(flushGroup(),currentGroup=o.group);const id=`${this.listId}-opt-${i}`,selected=selectedSet.has(o.value);currentGroupRows.push(html`<div
|
|
@@ -12,6 +12,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
12
12
|
aria-label=${o.accessibleLabel||nothing}
|
|
13
13
|
?data-active=${id===activeId}
|
|
14
14
|
>
|
|
15
|
+
${o.start?renderInertPresentation(o.start,{part:"option-start"}):""}
|
|
15
16
|
${o.icon?renderInertPresentation(o.icon,{part:"option-icon"}):""}
|
|
16
17
|
${o.dotColor?html`<span
|
|
17
18
|
part="option-dot"
|
|
@@ -22,6 +23,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
22
23
|
${o.sub?html`<span part="option-sub">${o.sub}</span>`:""}
|
|
23
24
|
</span>
|
|
24
25
|
${o.badge!=null?html`<span part="option-badge">${o.badge}</span>`:""}
|
|
26
|
+
${o.end?renderInertPresentation(o.end,{part:"option-end"}):""}
|
|
25
27
|
</div>`)}),flushGroup(),out}renderTag(value,index){const option=this.options.find(candidate=>candidate.value===value);if(this.getTag&&option)return this.getTag(option,index);const label=this.labelFor(value);return html`<span part="tag">
|
|
26
28
|
<span part="tag-label"><span part="tag__content">${label}</span></span>
|
|
27
29
|
<button
|
|
@@ -132,4 +134,4 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
132
134
|
@lr-option-change=${this.onOptionChange}
|
|
133
135
|
hidden
|
|
134
136
|
></slot>
|
|
135
|
-
`}}__decorate([property()],LyraCombobox.prototype,"placeholder",void 0),__decorate([property()],LyraCombobox.prototype,"label",void 0),__decorate([property()],LyraCombobox.prototype,"hint",void 0),__decorate([property({attribute:"error-text"})],LyraCombobox.prototype,"errorText",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCombobox.prototype,"open",null),__decorate([property({type:Boolean,attribute:"allow-create"})],LyraCombobox.prototype,"allowCreate",void 0),__decorate([property({type:Boolean,attribute:"allow-custom-value"})],LyraCombobox.prototype,"allowCustomValue",void 0),__decorate([property({reflect:!0})],LyraCombobox.prototype,"appearance",void 0),__decorate([property({reflect:!0})],LyraCombobox.prototype,"placement",void 0),__decorate([property({reflect:!0})],LyraCombobox.prototype,"size",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCombobox.prototype,"pill",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCombobox.prototype,"clearable",void 0),__decorate([property({type:Boolean,attribute:"with-clear"})],LyraCombobox.prototype,"withClear",void 0),__decorate([property({type:Boolean,attribute:"with-label"})],LyraCombobox.prototype,"withLabel",void 0),__decorate([property({type:Boolean,attribute:"with-hint"})],LyraCombobox.prototype,"withHint",void 0),__decorate([property({attribute:!1})],LyraCombobox.prototype,"getTag",void 0),__decorate([property({attribute:!1})],LyraCombobox.prototype,"validators",void 0),__decorate([property()],LyraCombobox.prototype,"autocomplete",void 0),__decorate([property({attribute:"inputmode"})],LyraCombobox.prototype,"inputMode",void 0),__decorate([property({attribute:"enterkeyhint"})],LyraCombobox.prototype,"enterKeyHint",void 0),__decorate([property({converter:comboboxSpellcheckConverter,useDefault:!0})],LyraCombobox.prototype,"spellcheck",void 0),__decorate([property()],LyraCombobox.prototype,"autocapitalize",void 0),__decorate([property({attribute:"empty-text"})],LyraCombobox.prototype,"emptyText",void 0),__decorate([property({attribute:"loading-text"})],LyraCombobox.prototype,"loadingText",void 0),__decorate([property({attribute:"overflow-text"})],LyraCombobox.prototype,"overflowText",void 0),__decorate([property({attribute:!1})],LyraCombobox.prototype,"filter",void 0),__decorate([property({attribute:!1})],LyraCombobox.prototype,"source",void 0),__decorate([property({converter:autocorrectConverter})],LyraCombobox.prototype,"autocorrect",null),__decorate([state()],LyraCombobox.prototype,"query",void 0),__decorate([state()],LyraCombobox.prototype,"activeIndex",void 0),__decorate([state()],LyraCombobox.prototype,"options",void 0),__decorate([state()],LyraCombobox.prototype,"touched",void 0),__decorate([state()],LyraCombobox.prototype,"validityRevision",void 0),__decorate([state()],LyraCombobox.prototype,"loading",void 0),__decorate([state()],LyraCombobox.prototype,"sourceFailed",void 0),__decorate([state()],LyraCombobox.prototype,"asyncRows",void 0),__decorate([query('[part="combobox-input"]')],LyraCombobox.prototype,"inputEl",void 0);export{LyraCombobox};
|
|
137
|
+
`}}__decorate([property()],LyraCombobox.prototype,"placeholder",void 0),__decorate([property()],LyraCombobox.prototype,"label",void 0),__decorate([property()],LyraCombobox.prototype,"hint",void 0),__decorate([property({attribute:"error-text"})],LyraCombobox.prototype,"errorText",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCombobox.prototype,"open",null),__decorate([property({type:Boolean,attribute:"allow-create"})],LyraCombobox.prototype,"allowCreate",void 0),__decorate([property({type:Boolean,attribute:"allow-custom-value"})],LyraCombobox.prototype,"allowCustomValue",void 0),__decorate([property({reflect:!0})],LyraCombobox.prototype,"appearance",void 0),__decorate([property({reflect:!0})],LyraCombobox.prototype,"placement",void 0),__decorate([property({reflect:!0})],LyraCombobox.prototype,"size",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCombobox.prototype,"pill",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCombobox.prototype,"clearable",void 0),__decorate([property({type:Boolean,attribute:"with-clear"})],LyraCombobox.prototype,"withClear",void 0),__decorate([property({type:Boolean,attribute:"with-label"})],LyraCombobox.prototype,"withLabel",void 0),__decorate([property({type:Boolean,attribute:"with-hint"})],LyraCombobox.prototype,"withHint",void 0),__decorate([property({attribute:!1})],LyraCombobox.prototype,"getTag",void 0),__decorate([property({attribute:!1})],LyraCombobox.prototype,"validators",void 0),__decorate([property()],LyraCombobox.prototype,"autocomplete",void 0),__decorate([property({attribute:"inputmode"})],LyraCombobox.prototype,"inputMode",void 0),__decorate([property({attribute:"enterkeyhint"})],LyraCombobox.prototype,"enterKeyHint",void 0),__decorate([property({converter:comboboxSpellcheckConverter,useDefault:!0})],LyraCombobox.prototype,"spellcheck",void 0),__decorate([property()],LyraCombobox.prototype,"autocapitalize",void 0),__decorate([property({attribute:"empty-text"})],LyraCombobox.prototype,"emptyText",void 0),__decorate([property({attribute:"loading-text"})],LyraCombobox.prototype,"loadingText",void 0),__decorate([property({attribute:"overflow-text"})],LyraCombobox.prototype,"overflowText",void 0),__decorate([property({attribute:!1})],LyraCombobox.prototype,"filter",void 0),__decorate([property({attribute:!1})],LyraCombobox.prototype,"source",void 0),__decorate([property({converter:autocorrectConverter})],LyraCombobox.prototype,"autocorrect",null),__decorate([state()],LyraCombobox.prototype,"query",void 0),__decorate([state()],LyraCombobox.prototype,"activeIndex",void 0),__decorate([state()],LyraCombobox.prototype,"options",void 0),__decorate([state()],LyraCombobox.prototype,"touched",void 0),__decorate([state()],LyraCombobox.prototype,"validityRevision",void 0),__decorate([state()],LyraCombobox.prototype,"loading",void 0),__decorate([state()],LyraCombobox.prototype,"sourceFailed",void 0),__decorate([state()],LyraCombobox.prototype,"asyncRows",void 0),__decorate([query('[part="combobox-input"]')],LyraCombobox.prototype,"inputEl",void 0),__decorate([property({type:Number,attribute:"visible-options"})],LyraCombobox.prototype,"visibleOptions",void 0);export{LyraCombobox};
|
|
@@ -342,6 +342,15 @@ import{css}from"lit";import{formControlRequiredMarker}from"../../../internal/for
|
|
|
342
342
|
flex: 0 0 auto;
|
|
343
343
|
color: var(--lr-color-text-quiet);
|
|
344
344
|
}
|
|
345
|
+
[part="option-start"],
|
|
346
|
+
[part="option-end"] {
|
|
347
|
+
display: inline-flex;
|
|
348
|
+
align-items: center;
|
|
349
|
+
justify-content: center;
|
|
350
|
+
flex: 0 0 auto;
|
|
351
|
+
max-inline-size: 40%;
|
|
352
|
+
overflow: hidden;
|
|
353
|
+
}
|
|
345
354
|
[part="option-label"] {
|
|
346
355
|
display: flex;
|
|
347
356
|
flex-direction: column;
|