@aceshooting/lyra-ui 14.3.2 → 15.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +116 -0
- package/custom-elements.json +1 -1
- package/design-tokens.json +1 -1
- package/dist/cli/migration-contract.json +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.d.ts +4 -0
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +3 -3
- package/dist/components/agent-tools/approval-queue/approval-queue.class.js +3 -2
- package/dist/components/agent-tools/artifact-panel/artifact-panel.styles.js +1 -1
- package/dist/components/agent-tools/commit-card/commit-card.styles.js +1 -1
- package/dist/components/agent-tools/compare-panel/compare-panel.styles.js +1 -1
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +8 -3
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.d.ts +3 -1
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +10 -1
- package/dist/components/agent-tools/eval-dataset/eval-dataset.styles.js +1 -1
- package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +1 -1
- package/dist/components/agent-tools/subagent-panel/subagent-panel.class.d.ts +19 -1
- package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +4 -4
- package/dist/components/agent-tools/subagent-panel/subagent-panel.styles.js +1 -1
- package/dist/components/agent-tools/task-list/task-list.class.d.ts +5 -0
- package/dist/components/agent-tools/task-list/task-list.class.js +3 -3
- package/dist/components/agent-tools/terminal/terminal.class.d.ts +1 -1
- package/dist/components/agent-tools/terminal/terminal.styles.js +1 -1
- package/dist/components/agent-tools/test-results/test-results.class.js +1 -1
- package/dist/components/agent-tools/tool-param-form/tool-param-form.class.d.ts +10 -7
- package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +15 -14
- package/dist/components/agent-tools/tool-param-form/tool-param-form.d.ts +1 -1
- package/dist/components/agent-tools/tool-param-form/tool-param-form.js +1 -1
- package/dist/components/agent-tools/tool-param-form/tool-param-form.styles.js +1 -1
- package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.d.ts +5 -2
- package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.js +1 -1
- package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.d.ts +3 -1
- package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +9 -1
- package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.styles.js +1 -1
- package/dist/components/charts/chart/box-plot.class.d.ts +64 -4
- package/dist/components/charts/chart/box-plot.class.js +5 -5
- package/dist/components/charts/chart/chart-colors.d.ts +10 -0
- package/dist/components/charts/chart/chart-colors.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +35 -10
- package/dist/components/charts/chart/chart.class.js +4 -4
- package/dist/components/charts/chart/lite-chart.class.d.ts +10 -2
- package/dist/components/charts/chart/lite-chart.styles.js +1 -1
- package/dist/components/conversation/markdown/markdown.class.d.ts +9 -1
- package/dist/components/conversation/markdown/markdown.class.js +1 -1
- package/dist/components/conversation/message-parts/message-parts.class.d.ts +18 -1
- package/dist/components/conversation/message-parts/message-parts.class.js +4 -4
- package/dist/components/conversation/model-select/model-select.class.d.ts +6 -2
- package/dist/components/conversation/model-select/model-select.class.js +3 -3
- package/dist/components/conversation/prompt-input/prompt-input.styles.js +1 -1
- package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +5 -1
- package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
- package/dist/components/data/calendar/calendar.class.js +2 -2
- package/dist/components/data/context-meter/context-meter.styles.js +1 -1
- package/dist/components/data/data-grid/data-grid-types.d.ts +8 -2
- package/dist/components/data/data-grid/data-grid.class.d.ts +16 -3
- package/dist/components/data/data-grid/data-grid.class.js +3 -2
- package/dist/components/data/env-list/env-list.styles.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +22 -2
- package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
- package/dist/components/data/flow-minimap/flow-minimap.class.d.ts +12 -4
- package/dist/components/data/flow-minimap/flow-minimap.class.js +2 -2
- package/dist/components/data/flow-minimap/flow-minimap.styles.js +1 -1
- package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +5 -1
- package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
- package/dist/components/data/heatmap/heatmap.class.d.ts +12 -1
- package/dist/components/data/heatmap/heatmap.class.js +3 -3
- package/dist/components/data/heatmap/heatmap.styles.js +1 -1
- package/dist/components/forms/button/button.styles.js +1 -1
- package/dist/components/forms/code-editor/code-editor.class.js +1 -1
- package/dist/components/forms/combobox/combobox.class.js +1 -1
- package/dist/components/forms/combobox/combobox.styles.js +1 -1
- package/dist/components/forms/date-picker/date-input.class.js +1 -1
- package/dist/components/forms/date-picker/date-picker.class.d.ts +12 -1
- package/dist/components/forms/date-picker/date-picker.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.class.d.ts +27 -5
- package/dist/components/forms/icon-button/icon-button.class.js +7 -3
- package/dist/components/forms/input/input.styles.js +1 -1
- package/dist/components/forms/input/time-input.class.d.ts +13 -2
- package/dist/components/forms/input/time-input.class.js +1 -1
- package/dist/components/forms/otp-input/otp-input.class.d.ts +8 -1
- package/dist/components/forms/otp-input/otp-input.class.js +1 -1
- package/dist/components/forms/rubric-form/rubric-form.class.d.ts +1 -1
- package/dist/components/forms/rubric-form/rubric-form.class.js +1 -1
- package/dist/components/forms/select/select.class.d.ts +1 -1
- package/dist/components/forms/select/select.class.js +1 -1
- package/dist/components/forms/slider/slider.class.d.ts +4 -1
- package/dist/components/forms/slider/slider.class.js +1 -1
- package/dist/components/forms/textarea/textarea.class.d.ts +9 -4
- package/dist/components/forms/textarea/textarea.class.js +1 -1
- package/dist/components/forms/time-range/time-range.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.class.d.ts +7 -2
- package/dist/components/layout/app-rail/app-rail.class.js +1 -1
- package/dist/components/layout/card/card.class.js +2 -2
- package/dist/components/layout/card/card.styles.js +1 -1
- package/dist/components/layout/control-group/control-group.class.js +1 -1
- package/dist/components/layout/dashboard-grid/dashboard-grid.styles.js +1 -1
- package/dist/components/layout/details/details.styles.js +1 -1
- package/dist/components/layout/filter-bar/filter-bar.class.d.ts +13 -3
- package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
- package/dist/components/layout/menu/dropdown-item.class.d.ts +2 -0
- package/dist/components/layout/menu/menu-item.class.d.ts +28 -1
- package/dist/components/layout/menu/menu-item.class.js +45 -35
- package/dist/components/layout/menu/menu-item.styles.js +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/multi-split/multi-split.class.d.ts +12 -2
- package/dist/components/layout/multi-split/multi-split.class.js +1 -1
- package/dist/components/layout/page/page.class.js +2 -1
- package/dist/components/layout/page/page.styles.js +1 -1
- package/dist/components/layout/responsive-panel/responsive-panel.class.d.ts +6 -4
- package/dist/components/layout/responsive-panel/responsive-panel.class.js +2 -2
- package/dist/components/layout/responsive-panel/responsive-panel.styles.js +1 -1
- package/dist/components/layout/stepper/stepper.class.js +2 -2
- package/dist/components/layout/virtual-list/virtual-list.class.js +2 -2
- package/dist/components/layout/widget/widget.class.d.ts +12 -2
- package/dist/components/layout/widget/widget.class.js +2 -2
- package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +1 -1
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
- package/dist/components/media/file-icon/file-icon.class.d.ts +3 -1
- package/dist/components/media/file-icon/file-icon.class.js +1 -1
- package/dist/components/media/file-input/file-input.class.d.ts +1 -1
- package/dist/components/media/file-input/file-input.class.js +1 -1
- package/dist/components/media/flag/flag.styles.js +1 -1
- package/dist/components/media/image-comparer/image-comparer.class.d.ts +5 -5
- package/dist/components/media/image-comparer/image-comparer.class.js +1 -1
- package/dist/components/media/image-comparer/image-comparer.styles.js +1 -1
- package/dist/components/media/lightbox/lightbox.styles.js +1 -1
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/sequence-playback/sequence-playback.class.js +1 -1
- package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
- package/dist/components/media/video-playlist/video-playlist.styles.js +1 -1
- package/dist/components/overlays/alert/alert.class.d.ts +6 -0
- package/dist/components/overlays/alert/alert.styles.js +1 -1
- package/dist/components/overlays/empty/empty.class.js +2 -2
- package/dist/components/overlays/kbd/kbd.styles.js +1 -1
- package/dist/components/overlays/progress/progress-ring.class.d.ts +4 -1
- package/dist/components/overlays/progress/progress.styles.js +1 -1
- package/dist/components/overlays/toast/toast.styles.js +1 -1
- package/dist/components/retrieval/graph/graph-canvas.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +10 -3
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/graph/graph.styles.js +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +6 -6
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.js +2 -2
- package/dist/components/retrieval/mind-map/mind-map.styles.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +3 -3
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +3 -3
- package/dist/components/retrieval/node-palette/node-palette.class.d.ts +7 -1
- package/dist/components/retrieval/node-palette/node-palette.class.js +23 -13
- package/dist/components/retrieval/node-palette/node-palette.styles.js +1 -1
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +4 -1
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +1 -1
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
- package/dist/components/retrieval/retrieval-search/retrieval-search.class.js +4 -3
- package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +1 -1
- package/dist/components/retrieval/source-list/source-list.class.d.ts +7 -1
- package/dist/components/retrieval/source-list/source-list.class.js +1 -1
- package/dist/components/utility/export-button/export-button.class.d.ts +14 -2
- package/dist/components/utility/export-button/export-button.class.js +3 -3
- package/dist/components/utility/export-button/export-button.styles.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
- package/dist/components/utility/known-date/known-date.class.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.d.ts +4 -2
- package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
- package/dist/components/viewers/csv-viewer/csv-viewer.class.d.ts +9 -1
- package/dist/components/viewers/csv-viewer/csv-viewer.class.js +4 -4
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.d.ts +1 -1
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +4 -4
- package/dist/components/viewers/document-compare/document-compare.class.d.ts +5 -0
- package/dist/components/viewers/document-compare/document-compare.class.js +9 -4
- package/dist/components/viewers/document-compare/document-compare.styles.js +1 -1
- package/dist/components/viewers/document-preview/document-preview.class.d.ts +9 -1
- package/dist/components/viewers/document-preview/document-preview.class.js +2 -1
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.d.ts +5 -0
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +5 -0
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.d.ts +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +3 -3
- package/dist/components/viewers/xml-viewer/xml-viewer.styles.js +1 -1
- package/dist/custom-elements-jsx.d.ts +1 -1
- package/dist/events.d.ts +5 -4
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/vue.d.ts +1 -1
- package/llms/components/lr-alert.md +11 -3
- package/llms/components/lr-box-plot.md +21 -4
- package/llms/components/lr-chart.md +13 -4
- package/llms/components/lr-code-block.md +5 -4
- package/llms/components/lr-data-grid.md +24 -10
- package/llms/components/lr-document-compare.md +5 -0
- package/llms/components/lr-dropdown-item.md +24 -0
- package/llms/components/lr-eval-dataset.md +5 -4
- package/llms/components/lr-export-button.md +10 -5
- package/llms/components/lr-filter-bar.md +4 -1
- package/llms/components/lr-flow-minimap.md +7 -1
- package/llms/components/lr-icon-button.md +6 -1
- package/llms/components/lr-lite-chart.md +2 -1
- package/llms/components/lr-markdown.md +2 -2
- package/llms/components/lr-menu-item.md +24 -0
- package/llms/components/lr-menu.md +24 -0
- package/llms/components/lr-message-parts.md +7 -0
- package/llms/components/lr-model-settings-panel.md +4 -1
- package/llms/components/lr-node-palette.md +5 -4
- package/llms/components/lr-pdf-viewer.md +7 -0
- package/llms/components/lr-responsive-panel.md +2 -2
- package/llms/components/lr-subagent-panel.md +17 -2
- package/llms/components/lr-thinking-panel.md +4 -0
- package/llms/components/lr-timeline-item.md +1 -1
- package/llms/components/lr-timeline.md +1 -1
- package/llms/components/lr-tool-select-dialog.md +4 -3
- package/llms/components/lr-virtual-list.md +11 -11
- package/llms/peers.md +1 -1
- package/llms-full.txt +205 -59
- package/package.json +7 -7
- package/vscode-css-data.json +1 -1
- package/vscode-html-data.json +1 -1
- package/web-types.json +1 -1
|
@@ -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{LyraElement}from"../../../internal/lyra-element.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{Announcer,acquireAnnouncementSink}from"../../../internal/announcer.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{FLOW_PALETTE_MIME_TYPE}from"../../data/flow-canvas/flow-canvas.class.js";import{styles}from"./node-palette.styles.js";import{activeElementIn}from"../../../internal/active-element.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_nodePaletteDragHint,LYRA_DEFAULT_nodePaletteEmpty,LYRA_DEFAULT_nodePaletteLabel,LYRA_DEFAULT_nodePalettePlaceholder,LYRA_DEFAULT_nodePaletteResultCount,LYRA_DEFAULT_reorderItemMoved,LYRA_DEFAULT_search}from"../../../internal/default-strings.generated.js";const MAX_PALETTE_KEYWORDS=1e4,MAX_PALETTE_ITEMS=1e4,EMPTY_CANONICAL_PALETTE_ITEMS=Object.freeze([]);function descriptorValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectKeywords(value){try{if(!Array.isArray(value))return;const lengthDescriptor=descriptorValue(value,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0||lengthDescriptor.value>MAX_PALETTE_KEYWORDS)return;const keywords=[],length=Math.min(lengthDescriptor.value,MAX_PALETTE_KEYWORDS);for(let index=0;index<length;index+=1){const descriptor=descriptorValue(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof descriptor.value!="string")return;keywords.push(descriptor.value)}return Object.freeze(keywords)}catch{return}}function projectPaletteItem(candidate,sourceIndex){try{if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))return;const typeDescriptor=descriptorValue(candidate,"type"),labelDescriptor=descriptorValue(candidate,"label"),descriptionDescriptor=descriptorValue(candidate,"description"),categoryDescriptor=descriptorValue(candidate,"category"),keywordsDescriptor=descriptorValue(candidate,"keywords"),iconDescriptor=descriptorValue(candidate,"icon"),disabledDescriptor=descriptorValue(candidate,"disabled");if(typeDescriptor===MISSING_OWN_DATA_DESCRIPTOR||typeDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||labelDescriptor===MISSING_OWN_DATA_DESCRIPTOR||labelDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||descriptionDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||categoryDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||keywordsDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||iconDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||disabledDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof typeDescriptor.value!="string"||typeDescriptor.value.trim()===""||typeof labelDescriptor.value!="string"||labelDescriptor.value.trim()==="")return;const description=descriptionDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:descriptionDescriptor.value,category=categoryDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:categoryDescriptor.value,keywordsValue=keywordsDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:keywordsDescriptor.value,icon=iconDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:iconDescriptor.value,disabled=disabledDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:disabledDescriptor.value;if(description!==void 0&&typeof description!="string"||category!==void 0&&typeof category!="string"||disabled!==void 0&&typeof disabled!="boolean")return;const keywords=keywordsValue===void 0?Object.freeze([]):projectKeywords(keywordsValue);return keywords?Object.freeze({source:candidate,sourceIndex,type:typeDescriptor.value,label:labelDescriptor.value,description,category,keywords,icon,disabled:disabled??!1}):void 0}catch{return}}function projectPaletteItems(value){try{if(!Array.isArray(value))return EMPTY_CANONICAL_PALETTE_ITEMS;const lengthDescriptor=descriptorValue(value,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0)return EMPTY_CANONICAL_PALETTE_ITEMS;const items=[],length=Math.min(lengthDescriptor.value,MAX_PALETTE_ITEMS);for(let index=0;index<length;index+=1){const descriptor=descriptorValue(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const item=projectPaletteItem(descriptor.value,index);item&&items.push(item)}return Object.freeze(items)}catch{return EMPTY_CANONICAL_PALETTE_ITEMS}}class LyraNodePalette extends LyraElement{constructor(){super(...arguments),this.items=[],this.reorderable=!1,this.accessibleLabel=null,this.queryText="",this.activeIndex=0,this.liveText="",this.listId=nextId("node-palette-list"),this.hintId=nextId("node-palette-hint"),this.announcer=new Announcer({onFlush:text=>{this.liveText=text,this.announcementSink?.announce(text)}}),this.isMounting=!0,this.canonicalItemsCache=null,this.filteredCache=null,this.categorizedCache=null,this.rovingListCache=null,this.lastRenderedRovingList=[],this.pendingFocusIndex=null,this.onSearchInput=e=>{this.queryText=e.target.value,this.activeIndex=0},this.onSearchFocus=event=>{relayNativeEvent(this,event)},this.onSearchBlur=event=>{relayNativeEvent(this,event)},this.onFieldKeyDown=e=>{if(e.key==="ArrowDown"){if(e.preventDefault(),this.lastRenderedRovingList.length===0)return;this.activeIndex=0,this.focusItem(0)}}}static{this.defaultStrings={...super.defaultStrings,nodePaletteDragHint:LYRA_DEFAULT_nodePaletteDragHint,nodePaletteEmpty:LYRA_DEFAULT_nodePaletteEmpty,nodePaletteLabel:LYRA_DEFAULT_nodePaletteLabel,nodePalettePlaceholder:LYRA_DEFAULT_nodePalettePlaceholder,nodePaletteResultCount:LYRA_DEFAULT_nodePaletteResultCount,reorderItemMoved:LYRA_DEFAULT_reorderItemMoved,search:LYRA_DEFAULT_search}}static{this.ownedCollectionProperties=Object.freeze(["items"])}static{this.identityCollectionProperties=Object.freeze(["items"])}static{this.identityEventDetailProperties=Object.freeze({"lr-select":Object.freeze(["item"])})}static{this.styles=[LyraElement.styles,styles,srOnly]}static{this.immutableEventDetails=Object.freeze(["lr-select"])}get canonicalItems(){const items=this.items,cache=this.canonicalItemsCache;if(cache&&cache.items===items)return cache.result;const result=projectPaletteItems(items);return this.canonicalItemsCache={items,result},result}get filtered(){const locale=this.effectiveLocale,q=this.queryText.trim().toLocaleLowerCase(locale),items=this.canonicalItems,cache=this.filteredCache;if(cache&&cache.items===items&&cache.query===q&&cache.locale===locale)return cache.result;const result=[];for(const item of items)q&&![item.label,item.category??"",...item.keywords].join(" ").toLocaleLowerCase(locale).includes(q)||result.push(item);return this.filteredCache={items,query:q,locale,result},result}categorized(filtered){const cache=this.categorizedCache;if(cache&&cache.filtered===filtered)return cache.result;const groups=new Map;for(const item of filtered){const key=item.category??null;groups.has(key)||groups.set(key,[]),groups.get(key).push(item)}const result=Array.from(groups,([category,groupItems])=>({category,items:groupItems}));return this.categorizedCache={filtered,result},result}rovingList(filtered=this.filtered){const cache=this.rovingListCache;if(cache&&cache.filtered===filtered)return cache.result;const result=this.categorized(filtered).flatMap(group=>group.items).filter(item=>!item.disabled);return this.rovingListCache={filtered,result},result}itemElements(){return Array.from(this.renderRoot.querySelectorAll('[part="item"]:not([aria-disabled="true"])'))}occurrenceAt(items,index){const item=items[index]?.source;let occurrence=0;for(let i=0;i<index;i++)items[i]?.source===item&&occurrence++;return occurrence}indexOfOccurrence(items,item,occurrence){let seen=0;for(let index=0;index<items.length;index++)if(items[index]?.source===item){if(seen===occurrence)return index;seen++}return-1}connectedCallback(){super.connectedCallback();const ownerWindow=this.ownerDocument.defaultView;ownerWindow&&this.announcer.setTimerHost(ownerWindow),this.announcementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}disconnectedCallback(){this.announcer.cancel(),this.liveText="",this.isMounting=!0,this.announcementSink?.release(),this.announcementSink=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback();const ownerWindow=this.ownerDocument.defaultView;ownerWindow&&this.announcer.setTimerHost(ownerWindow)}willUpdate(changed){super.willUpdate(changed);const previous=this.lastRenderedRovingList,next=this.rovingList(),structureChanged=previous.length!==next.length||previous.some((item,index)=>item!==next[index]);if(!this.hasUpdated||!structureChanged)return;const oldElements=this.itemElements(),focusedIndex=oldElements.indexOf(activeElementIn(this.shadowRoot)),referenceIndex=focusedIndex>=0?focusedIndex:Math.min(Math.max(0,this.activeIndex),Math.max(0,previous.length-1));let nextIndex=0;const previousItem=previous[referenceIndex];if(!changed.has("queryText")&&previousItem){const occurrence=this.occurrenceAt(previous,referenceIndex),preservedIndex=this.indexOfOccurrence(next,previousItem.source,occurrence);nextIndex=preservedIndex>=0?preservedIndex:Math.min(referenceIndex,Math.max(0,next.length-1))}if(focusedIndex>=0)if(next.length===0)this.renderRoot.querySelector("input")?.focus();else{const nextItem=next[nextIndex],nextOccurrence=this.occurrenceAt(next,nextIndex),survivingOldIndex=this.indexOfOccurrence(previous,nextItem.source,nextOccurrence),survivingOldElement=oldElements[survivingOldIndex];survivingOldElement?survivingOldElement.focus():this.renderRoot.querySelector("input")?.focus(),this.pendingFocusIndex=nextIndex}this.activeIndex=next.length===0?0:nextIndex}updated(changed){super.updated(changed),this.lastRenderedRovingList=this.rovingList();const pendingFocusIndex=this.pendingFocusIndex;pendingFocusIndex!==null&&(this.pendingFocusIndex=null,this.itemElements()[Math.min(pendingFocusIndex,this.lastRenderedRovingList.length-1)]?.focus()),changed.has("items")&&this.confirmPendingReorder();const wasMounting=this.isMounting;if(this.isMounting=!1,!wasMounting&&(changed.has("queryText")||changed.has("items"))){const count=this.filtered.length,countText=getNumberFormat(this.effectiveLocale).format(count);this.announcer.announce(this.localize("nodePaletteResultCount",void 0,{count:countText,pluralCount:count}))}}focusItem(index){this.updateComplete.then(()=>{this.itemElements()[index]?.focus()})}onItemKeyDown(e,rovingIndex,item){const list=this.lastRenderedRovingList;if(this.reorderable&&(e.ctrlKey||e.metaKey)&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this.requestReorder(item,e.key==="ArrowDown"?1:-1);return}if(e.key==="ArrowDown")e.preventDefault(),this.activeIndex=Math.min(list.length-1,rovingIndex+1),this.focusItem(this.activeIndex);else if(e.key==="ArrowUp"){if(e.preventDefault(),rovingIndex===0){this.renderRoot.querySelector("input")?.focus();return}this.activeIndex=Math.max(0,rovingIndex-1),this.focusItem(this.activeIndex)}else e.key==="Home"?(e.preventDefault(),this.activeIndex=0,this.focusItem(0)):e.key==="End"?(e.preventDefault(),this.activeIndex=list.length-1,this.focusItem(this.activeIndex)):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.place(item))}groupItemsFor(category){return this.categorized(this.filtered).find(group=>group.category===category)?.items??[]}requestReorder(item,delta){const category=item.category??null,group=this.groupItemsFor(category),position=group.indexOf(item),neighbor=position<0?void 0:group[position+delta];if(!neighbor)return;const fromIndex=item.sourceIndex,toIndex=neighbor.sourceIndex;this.pendingReorder={item:item.source,itemOccurrence:this.occurrenceAt(group,position),category,neighbor:neighbor.source,neighborOccurrence:this.occurrenceAt(group,position+delta),wasBefore:delta===1},this.emit("lr-reorder",{type:item.type,category,fromIndex,toIndex})}confirmPendingReorder(){const pending=this.pendingReorder;if(!pending)return;const group=this.groupItemsFor(pending.category),position=this.indexOfOccurrence(group,pending.item,pending.itemOccurrence),neighborPosition=this.indexOfOccurrence(group,pending.neighbor,pending.neighborOccurrence);if(position<0||neighborPosition<0){this.pendingReorder=void 0;return}if(position<neighborPosition===pending.wasBefore)return;this.pendingReorder=void 0;const numberFormat=getNumberFormat(this.effectiveLocale),text=this.localize("reorderItemMoved",void 0,{index:numberFormat.format(position+1),total:numberFormat.format(group.length)});this.updateComplete.then(()=>this.announcer.announce(text,{force:!0}))}place(item){item.disabled||(this.emit("lr-palette-place",{type:item.type}),this.emit("lr-select",{item:item.source}))}onItemDragStart(e,item){item.disabled||!e.dataTransfer||(e.dataTransfer.setData(FLOW_PALETTE_MIME_TYPE,JSON.stringify({type:item.type})),e.dataTransfer.setData("text/plain",item.label),e.dataTransfer.effectAllowed="copy")}itemTemplate(item,rovingIndex){return html`<div
|
|
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{LyraElement}from"../../../internal/lyra-element.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{Announcer,acquireAnnouncementSink}from"../../../internal/announcer.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{FLOW_PALETTE_MIME_TYPE}from"../../data/flow-canvas/flow-canvas.class.js";import{styles}from"./node-palette.styles.js";import{activeElementIn}from"../../../internal/active-element.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{closeIcon}from"../../../internal/icons.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_nodePaletteDragHint,LYRA_DEFAULT_nodePaletteEmpty,LYRA_DEFAULT_nodePaletteLabel,LYRA_DEFAULT_nodePalettePlaceholder,LYRA_DEFAULT_nodePaletteResultCount,LYRA_DEFAULT_reorderItemMoved,LYRA_DEFAULT_search}from"../../../internal/default-strings.generated.js";const MAX_PALETTE_KEYWORDS=1e4,MAX_PALETTE_ITEMS=1e4,EMPTY_CANONICAL_PALETTE_ITEMS=Object.freeze([]);function descriptorValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectKeywords(value){try{if(!Array.isArray(value))return;const lengthDescriptor=descriptorValue(value,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0||lengthDescriptor.value>MAX_PALETTE_KEYWORDS)return;const keywords=[],length=Math.min(lengthDescriptor.value,MAX_PALETTE_KEYWORDS);for(let index=0;index<length;index+=1){const descriptor=descriptorValue(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof descriptor.value!="string")return;keywords.push(descriptor.value)}return Object.freeze(keywords)}catch{return}}function projectPaletteItem(candidate,sourceIndex){try{if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))return;const typeDescriptor=descriptorValue(candidate,"type"),labelDescriptor=descriptorValue(candidate,"label"),descriptionDescriptor=descriptorValue(candidate,"description"),categoryDescriptor=descriptorValue(candidate,"category"),keywordsDescriptor=descriptorValue(candidate,"keywords"),iconDescriptor=descriptorValue(candidate,"icon"),disabledDescriptor=descriptorValue(candidate,"disabled");if(typeDescriptor===MISSING_OWN_DATA_DESCRIPTOR||typeDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||labelDescriptor===MISSING_OWN_DATA_DESCRIPTOR||labelDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||descriptionDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||categoryDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||keywordsDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||iconDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||disabledDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof typeDescriptor.value!="string"||typeDescriptor.value.trim()===""||typeof labelDescriptor.value!="string"||labelDescriptor.value.trim()==="")return;const description=descriptionDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:descriptionDescriptor.value,category=categoryDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:categoryDescriptor.value,keywordsValue=keywordsDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:keywordsDescriptor.value,icon=iconDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:iconDescriptor.value,disabled=disabledDescriptor===MISSING_OWN_DATA_DESCRIPTOR?void 0:disabledDescriptor.value;if(description!==void 0&&typeof description!="string"||category!==void 0&&typeof category!="string"||disabled!==void 0&&typeof disabled!="boolean")return;const keywords=keywordsValue===void 0?Object.freeze([]):projectKeywords(keywordsValue);return keywords?Object.freeze({source:candidate,sourceIndex,type:typeDescriptor.value,label:labelDescriptor.value,description,category,keywords,icon,disabled:disabled??!1}):void 0}catch{return}}function projectPaletteItems(value){try{if(!Array.isArray(value))return EMPTY_CANONICAL_PALETTE_ITEMS;const lengthDescriptor=descriptorValue(value,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0)return EMPTY_CANONICAL_PALETTE_ITEMS;const items=[],length=Math.min(lengthDescriptor.value,MAX_PALETTE_ITEMS);for(let index=0;index<length;index+=1){const descriptor=descriptorValue(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const item=projectPaletteItem(descriptor.value,index);item&&items.push(item)}return Object.freeze(items)}catch{return EMPTY_CANONICAL_PALETTE_ITEMS}}class LyraNodePalette extends LyraElement{constructor(){super(...arguments),this.items=[],this.reorderable=!1,this.accessibleLabel=null,this.queryText="",this.activeIndex=0,this.liveText="",this.listId=nextId("node-palette-list"),this.hintId=nextId("node-palette-hint"),this.announcer=new Announcer({onFlush:text=>{this.liveText=text,this.announcementSink?.announce(text)}}),this.isMounting=!0,this.canonicalItemsCache=null,this.filteredCache=null,this.categorizedCache=null,this.rovingListCache=null,this.lastRenderedRovingList=[],this.pendingFocusIndex=null,this.onSearchInput=e=>{this.queryText=e.target.value,this.activeIndex=0},this.onSearchClear=()=>{this.queryText!==""&&(this.queryText="",this.activeIndex=0,this.renderRoot.querySelector('[part="search"]')?.focus())},this.onSearchFocus=event=>{relayNativeEvent(this,event)},this.onSearchBlur=event=>{relayNativeEvent(this,event)},this.onFieldKeyDown=e=>{if(e.key==="ArrowDown"){if(e.preventDefault(),this.lastRenderedRovingList.length===0)return;this.activeIndex=0,this.focusItem(0)}}}static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,nodePaletteDragHint:LYRA_DEFAULT_nodePaletteDragHint,nodePaletteEmpty:LYRA_DEFAULT_nodePaletteEmpty,nodePaletteLabel:LYRA_DEFAULT_nodePaletteLabel,nodePalettePlaceholder:LYRA_DEFAULT_nodePalettePlaceholder,nodePaletteResultCount:LYRA_DEFAULT_nodePaletteResultCount,reorderItemMoved:LYRA_DEFAULT_reorderItemMoved,search:LYRA_DEFAULT_search}}static{this.ownedCollectionProperties=Object.freeze(["items"])}static{this.identityCollectionProperties=Object.freeze(["items"])}static{this.identityEventDetailProperties=Object.freeze({"lr-select":Object.freeze(["item"])})}static{this.styles=[LyraElement.styles,styles,srOnly]}static{this.immutableEventDetails=Object.freeze(["lr-select"])}get canonicalItems(){const items=this.items,cache=this.canonicalItemsCache;if(cache&&cache.items===items)return cache.result;const result=projectPaletteItems(items);return this.canonicalItemsCache={items,result},result}get filtered(){const locale=this.effectiveLocale,q=this.queryText.trim().toLocaleLowerCase(locale),items=this.canonicalItems,cache=this.filteredCache;if(cache&&cache.items===items&&cache.query===q&&cache.locale===locale)return cache.result;const result=[];for(const item of items)q&&![item.label,item.category??"",...item.keywords].join(" ").toLocaleLowerCase(locale).includes(q)||result.push(item);return this.filteredCache={items,query:q,locale,result},result}categorized(filtered){const cache=this.categorizedCache;if(cache&&cache.filtered===filtered)return cache.result;const groups=new Map;for(const item of filtered){const key=item.category??null;groups.has(key)||groups.set(key,[]),groups.get(key).push(item)}const result=Array.from(groups,([category,groupItems])=>({category,items:groupItems}));return this.categorizedCache={filtered,result},result}rovingList(filtered=this.filtered){const cache=this.rovingListCache;if(cache&&cache.filtered===filtered)return cache.result;const result=this.categorized(filtered).flatMap(group=>group.items).filter(item=>!item.disabled);return this.rovingListCache={filtered,result},result}itemElements(){return Array.from(this.renderRoot.querySelectorAll('[part="item"]:not([aria-disabled="true"])'))}occurrenceAt(items,index){const item=items[index]?.source;let occurrence=0;for(let i=0;i<index;i++)items[i]?.source===item&&occurrence++;return occurrence}indexOfOccurrence(items,item,occurrence){let seen=0;for(let index=0;index<items.length;index++)if(items[index]?.source===item){if(seen===occurrence)return index;seen++}return-1}connectedCallback(){super.connectedCallback();const ownerWindow=this.ownerDocument.defaultView;ownerWindow&&this.announcer.setTimerHost(ownerWindow),this.announcementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}disconnectedCallback(){this.announcer.cancel(),this.liveText="",this.isMounting=!0,this.announcementSink?.release(),this.announcementSink=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback();const ownerWindow=this.ownerDocument.defaultView;ownerWindow&&this.announcer.setTimerHost(ownerWindow)}willUpdate(changed){super.willUpdate(changed);const previous=this.lastRenderedRovingList,next=this.rovingList(),structureChanged=previous.length!==next.length||previous.some((item,index)=>item!==next[index]);if(!this.hasUpdated||!structureChanged)return;const oldElements=this.itemElements(),focusedIndex=oldElements.indexOf(activeElementIn(this.shadowRoot)),referenceIndex=focusedIndex>=0?focusedIndex:Math.min(Math.max(0,this.activeIndex),Math.max(0,previous.length-1));let nextIndex=0;const previousItem=previous[referenceIndex];if(!changed.has("queryText")&&previousItem){const occurrence=this.occurrenceAt(previous,referenceIndex),preservedIndex=this.indexOfOccurrence(next,previousItem.source,occurrence);nextIndex=preservedIndex>=0?preservedIndex:Math.min(referenceIndex,Math.max(0,next.length-1))}if(focusedIndex>=0)if(next.length===0)this.renderRoot.querySelector("input")?.focus();else{const nextItem=next[nextIndex],nextOccurrence=this.occurrenceAt(next,nextIndex),survivingOldIndex=this.indexOfOccurrence(previous,nextItem.source,nextOccurrence),survivingOldElement=oldElements[survivingOldIndex];survivingOldElement?survivingOldElement.focus():this.renderRoot.querySelector("input")?.focus(),this.pendingFocusIndex=nextIndex}this.activeIndex=next.length===0?0:nextIndex}updated(changed){super.updated(changed),this.lastRenderedRovingList=this.rovingList();const pendingFocusIndex=this.pendingFocusIndex;pendingFocusIndex!==null&&(this.pendingFocusIndex=null,this.itemElements()[Math.min(pendingFocusIndex,this.lastRenderedRovingList.length-1)]?.focus()),changed.has("items")&&this.confirmPendingReorder();const wasMounting=this.isMounting;if(this.isMounting=!1,!wasMounting&&(changed.has("queryText")||changed.has("items"))){const count=this.filtered.length,countText=getNumberFormat(this.effectiveLocale).format(count);this.announcer.announce(this.localize("nodePaletteResultCount",void 0,{count:countText,pluralCount:count}))}}focusItem(index){this.updateComplete.then(()=>{this.itemElements()[index]?.focus()})}onItemKeyDown(e,rovingIndex,item){const list=this.lastRenderedRovingList;if(this.reorderable&&(e.ctrlKey||e.metaKey)&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this.requestReorder(item,e.key==="ArrowDown"?1:-1);return}if(e.key==="ArrowDown")e.preventDefault(),this.activeIndex=Math.min(list.length-1,rovingIndex+1),this.focusItem(this.activeIndex);else if(e.key==="ArrowUp"){if(e.preventDefault(),rovingIndex===0){this.renderRoot.querySelector("input")?.focus();return}this.activeIndex=Math.max(0,rovingIndex-1),this.focusItem(this.activeIndex)}else e.key==="Home"?(e.preventDefault(),this.activeIndex=0,this.focusItem(0)):e.key==="End"?(e.preventDefault(),this.activeIndex=list.length-1,this.focusItem(this.activeIndex)):(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.place(item))}groupItemsFor(category){return this.categorized(this.filtered).find(group=>group.category===category)?.items??[]}requestReorder(item,delta){const category=item.category??null,group=this.groupItemsFor(category),position=group.indexOf(item),neighbor=position<0?void 0:group[position+delta];if(!neighbor)return;const fromIndex=item.sourceIndex,toIndex=neighbor.sourceIndex;this.pendingReorder={item:item.source,itemOccurrence:this.occurrenceAt(group,position),category,neighbor:neighbor.source,neighborOccurrence:this.occurrenceAt(group,position+delta),wasBefore:delta===1},this.emit("lr-reorder",{type:item.type,category,fromIndex,toIndex})}confirmPendingReorder(){const pending=this.pendingReorder;if(!pending)return;const group=this.groupItemsFor(pending.category),position=this.indexOfOccurrence(group,pending.item,pending.itemOccurrence),neighborPosition=this.indexOfOccurrence(group,pending.neighbor,pending.neighborOccurrence);if(position<0||neighborPosition<0){this.pendingReorder=void 0;return}if(position<neighborPosition===pending.wasBefore)return;this.pendingReorder=void 0;const numberFormat=getNumberFormat(this.effectiveLocale),text=this.localize("reorderItemMoved",void 0,{index:numberFormat.format(position+1),total:numberFormat.format(group.length)});this.updateComplete.then(()=>this.announcer.announce(text,{force:!0}))}place(item){item.disabled||(this.emit("lr-palette-place",{type:item.type}),this.emit("lr-select",{item:item.source}))}onItemDragStart(e,item){item.disabled||!e.dataTransfer||(e.dataTransfer.setData(FLOW_PALETTE_MIME_TYPE,JSON.stringify({type:item.type})),e.dataTransfer.setData("text/plain",item.label),e.dataTransfer.effectAllowed="copy")}itemTemplate(item,rovingIndex){return html`<div
|
|
2
2
|
part="item"
|
|
3
3
|
role="option"
|
|
4
4
|
aria-selected="false"
|
|
@@ -18,18 +18,28 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
18
18
|
${item.description?html`<span part="item-description">${item.description}</span>`:nothing}
|
|
19
19
|
</div>`}render(){const filtered=this.filtered,groups=this.categorized(filtered);let nextRovingIndex=0;const componentLabel=typeof this.label=="string"&&this.label.trim()!==""?this.label:this.localize("nodePaletteLabel"),listLabel=!this.hasAttribute("aria-label")&&typeof this.accessibleLabel=="string"&&this.accessibleLabel.trim()!==""?this.accessibleLabel:componentLabel;return html`<div part="base">
|
|
20
20
|
<slot name="header"></slot>
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
<div part="search-field">
|
|
22
|
+
<input
|
|
23
|
+
part="search"
|
|
24
|
+
type="search"
|
|
25
|
+
aria-label=${this.localize("search")}
|
|
26
|
+
aria-controls=${this.listId}
|
|
27
|
+
placeholder=${this.localize("nodePalettePlaceholder")}
|
|
28
|
+
.value=${this.queryText}
|
|
29
|
+
@input=${this.onSearchInput}
|
|
30
|
+
@keydown=${this.onFieldKeyDown}
|
|
31
|
+
@focus=${this.onSearchFocus}
|
|
32
|
+
@blur=${this.onSearchBlur}
|
|
33
|
+
/>
|
|
34
|
+
${this.queryText===""?nothing:html`<button
|
|
35
|
+
part="search-clear"
|
|
36
|
+
type="button"
|
|
37
|
+
aria-label=${this.localize("clear")}
|
|
38
|
+
@click=${this.onSearchClear}
|
|
39
|
+
>
|
|
40
|
+
<span aria-hidden="true" inert>${closeIcon()}</span>
|
|
41
|
+
</button>`}
|
|
42
|
+
</div>
|
|
33
43
|
<div part="list" id=${this.listId} role="listbox" aria-label=${listLabel}>
|
|
34
44
|
${groups.length===0?html`<div
|
|
35
45
|
part="empty"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";const styles=css`:host{min-inline-size:0;display:block}[part=base]{gap:var(--lr-space-xs);flex-direction:column;min-inline-size:0;display:flex}[part=search]{box-sizing:border-box;inline-size:100%;min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);padding:var(--lr-space-xs) var(--lr-space-s);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);background:var(--lr-color-surface);color:var(--lr-color-text);font:inherit}[part=search]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}[part=search]:hover{border-color:var(--lr-color-border-strong)}[part=search]::-webkit-search-cancel-button,[part=search]::-webkit-search-decoration{-webkit-appearance:none;appearance:none;display:none}[part=search]::placeholder{color:var(--lr-color-text-quiet)}[part=list]{gap:var(--lr-size-2px);flex-direction:column;min-inline-size:0;display:flex;overflow:clip auto}[part=group-header]{padding:var(--lr-space-2xs) var(--lr-space-s);font-size:var(--lr-font-size-xs);font-weight:var(--lr-font-weight-medium);color:var(--lr-color-text-quiet);text-transform:uppercase}[part=item]{gap:var(--lr-size-2px);box-sizing:border-box;min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);padding:var(--lr-space-xs) var(--lr-space-s);border-radius:var(--lr-radius);cursor:grab;flex-direction:column;display:flex}[part=item][aria-disabled=true]{cursor:not-allowed;opacity:var(--lr-opacity-disabled)}:where([part=item]):hover:where(:not([aria-disabled=true])),:where([part=item]):focus-visible:where(:not([aria-disabled=true])){background:var(--lr-color-surface-hover,var(--lr-color-border))}:where([part=item]):active:where(:not([aria-disabled=true])){background:color-mix(in oklab, var(--lr-color-surface-hover,var(--lr-color-border)), var(--lr-color-mix-partner) var(--lr-color-mix-active));cursor:grabbing}[part=item]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:calc(-1 * var(--lr-focus-ring-width))}[part=item-label]{font-weight:var(--lr-font-weight-medium)}[part=item-description]{font-size:var(--lr-font-size-xs);color:var(--lr-color-text-quiet);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}[part=empty]{padding:var(--lr-space-m);color:var(--lr-color-text-quiet);text-align:center}`;export{styles};
|
|
1
|
+
import{css}from"lit";const styles=css`:host{min-inline-size:0;display:block}[part=base]{gap:var(--lr-space-xs);flex-direction:column;min-inline-size:0;display:flex}[part=search-field]{min-inline-size:0;display:flex;position:relative}[part=search]{box-sizing:border-box;inline-size:100%;min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);padding:var(--lr-space-xs) var(--lr-space-s);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);background:var(--lr-color-surface);color:var(--lr-color-text);font:inherit;padding-inline-end:calc(var(--lr-icon-button-size) + var(--lr-space-2xs))}[part=search]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}[part=search]:hover{border-color:var(--lr-color-border-strong)}[part=search]::-webkit-search-cancel-button,[part=search]::-webkit-search-decoration{-webkit-appearance:none;appearance:none;display:none}[part=search]::placeholder{color:var(--lr-color-text-quiet)}[part=search-clear]{min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);border-radius:var(--lr-radius);color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-m);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:absolute;inset-block-start:50%;inset-inline-end:var(--lr-space-2xs);translate:0 -50%}[part=search-clear]:hover{color:var(--lr-color-text);background:color-mix(in oklab, var(--lr-color-surface), var(--lr-color-mix-partner) var(--lr-color-mix-hover))}[part=search-clear]:active{color:var(--lr-color-text);background:color-mix(in oklab, var(--lr-color-surface), var(--lr-color-mix-partner) var(--lr-color-mix-active))}[part=search-clear]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}[part=list]{gap:var(--lr-size-2px);flex-direction:column;min-inline-size:0;display:flex;overflow:clip auto}[part=group-header]{padding:var(--lr-space-2xs) var(--lr-space-s);font-size:var(--lr-font-size-xs);font-weight:var(--lr-font-weight-medium);color:var(--lr-color-text-quiet);text-transform:uppercase}[part=item]{gap:var(--lr-size-2px);box-sizing:border-box;min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);padding:var(--lr-space-xs) var(--lr-space-s);border-radius:var(--lr-radius);cursor:grab;flex-direction:column;display:flex}[part=item][aria-disabled=true]{cursor:not-allowed;opacity:var(--lr-opacity-disabled)}:where([part=item]):hover:where(:not([aria-disabled=true])),:where([part=item]):focus-visible:where(:not([aria-disabled=true])){background:var(--lr-color-surface-hover,var(--lr-color-border))}:where([part=item]):active:where(:not([aria-disabled=true])){background:color-mix(in oklab, var(--lr-color-surface-hover,var(--lr-color-border)), var(--lr-color-mix-partner) var(--lr-color-mix-active));cursor:grabbing}[part=item]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:calc(-1 * var(--lr-focus-ring-width))}[part=item-label]{font-weight:var(--lr-font-weight-medium)}[part=item-description]{font-size:var(--lr-font-size-xs);color:var(--lr-color-text-quiet);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}[part=empty]{padding:var(--lr-space-m);color:var(--lr-color-text-quiet);text-align:center}`;export{styles};
|
|
@@ -39,7 +39,10 @@ export declare class LyraRagEvalDashboard extends LyraElement<LyraRagEvalDashboa
|
|
|
39
39
|
metrics:readonly LyraRagEvaluationMetric[];
|
|
40
40
|
/** Evaluation runs displayed in the trend chart and run history. */
|
|
41
41
|
runs:readonly LyraRagEvaluationRun[];
|
|
42
|
-
/** Controlled id of the active metric; empty selects the first available metric.
|
|
42
|
+
/** Controlled id of the active metric; empty selects the first available metric. A non-empty
|
|
43
|
+
* value that matches no declared `metrics` entry selects no metric at all (no button renders
|
|
44
|
+
* `aria-pressed="true"`, and no chart renders) rather than silently substituting the first
|
|
45
|
+
* metric -- the host's own readback always agrees with what is rendered. */
|
|
43
46
|
metricId:string;
|
|
44
47
|
/** Controlled evaluation slice. An unavailable value is preserved and renders an explicit
|
|
45
48
|
* localized state until the host changes it or supplies a matching run. */
|
|
@@ -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}from"lit/decorators.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{firstByRetrievalIdentity,isNonBlankIdentity}from"../retrieval-identity.js";import{finiteRange}from"../../../internal/numbers.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import"../../charts/chart/lite-chart.class.js";import"../../data/stat/stat.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./rag-eval-dashboard.styles.js";import{retrievalSemanticLabel,retrievalSemanticRole}from"../retrieval-semantic-owner.js";import{LYRA_DEFAULT_ragEvalDashboardAllSlices,LYRA_DEFAULT_ragEvalDashboardEmpty,LYRA_DEFAULT_ragEvalDashboardLabel,LYRA_DEFAULT_ragEvalDashboardRuns,LYRA_DEFAULT_ragEvalDashboardSliceUnavailable,LYRA_DEFAULT_ragEvalDashboardSlices}from"../../../internal/default-strings.generated.js";function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}class LyraRagEvalDashboard extends LyraElement{constructor(){super(...arguments),this.metrics=[],this.runs=[],this.metricId="",this.slice="",this.showChart=!0,this.chartHeight="220px"}static{this.defaultStrings={...super.defaultStrings,ragEvalDashboardAllSlices:LYRA_DEFAULT_ragEvalDashboardAllSlices,ragEvalDashboardEmpty:LYRA_DEFAULT_ragEvalDashboardEmpty,ragEvalDashboardLabel:LYRA_DEFAULT_ragEvalDashboardLabel,ragEvalDashboardRuns:LYRA_DEFAULT_ragEvalDashboardRuns,ragEvalDashboardSliceUnavailable:LYRA_DEFAULT_ragEvalDashboardSliceUnavailable,ragEvalDashboardSlices:LYRA_DEFAULT_ragEvalDashboardSlices}}static{this.ownedCollectionProperties=Object.freeze(["metrics","runs"])}static{this.styles=[LyraElement.styles,styles]}get normalizedMetrics(){return firstByRetrievalIdentity(Array.isArray(this.metrics)?this.metrics:[],metric=>metric.id)}get normalizedRuns(){return firstByRetrievalIdentity(Array.isArray(this.runs)?this.runs.filter(run=>isRecord(run)&&isNonBlankIdentity(run.id)&&typeof run.label=="string"&&isRecord(run.metrics)):[],run=>run.id)}activeMetric(metrics){return metrics.find(metric=>metric.id===this.metricId)
|
|
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}from"lit/decorators.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{firstByRetrievalIdentity,isNonBlankIdentity}from"../retrieval-identity.js";import{finiteRange}from"../../../internal/numbers.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import"../../charts/chart/lite-chart.class.js";import"../../data/stat/stat.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./rag-eval-dashboard.styles.js";import{retrievalSemanticLabel,retrievalSemanticRole}from"../retrieval-semantic-owner.js";import{LYRA_DEFAULT_ragEvalDashboardAllSlices,LYRA_DEFAULT_ragEvalDashboardEmpty,LYRA_DEFAULT_ragEvalDashboardLabel,LYRA_DEFAULT_ragEvalDashboardRuns,LYRA_DEFAULT_ragEvalDashboardSliceUnavailable,LYRA_DEFAULT_ragEvalDashboardSlices}from"../../../internal/default-strings.generated.js";function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}class LyraRagEvalDashboard extends LyraElement{constructor(){super(...arguments),this.metrics=[],this.runs=[],this.metricId="",this.slice="",this.showChart=!0,this.chartHeight="220px"}static{this.defaultStrings={...super.defaultStrings,ragEvalDashboardAllSlices:LYRA_DEFAULT_ragEvalDashboardAllSlices,ragEvalDashboardEmpty:LYRA_DEFAULT_ragEvalDashboardEmpty,ragEvalDashboardLabel:LYRA_DEFAULT_ragEvalDashboardLabel,ragEvalDashboardRuns:LYRA_DEFAULT_ragEvalDashboardRuns,ragEvalDashboardSliceUnavailable:LYRA_DEFAULT_ragEvalDashboardSliceUnavailable,ragEvalDashboardSlices:LYRA_DEFAULT_ragEvalDashboardSlices}}static{this.ownedCollectionProperties=Object.freeze(["metrics","runs"])}static{this.styles=[LyraElement.styles,styles]}get normalizedMetrics(){return firstByRetrievalIdentity(Array.isArray(this.metrics)?this.metrics:[],metric=>metric.id)}get normalizedRuns(){return firstByRetrievalIdentity(Array.isArray(this.runs)?this.runs.filter(run=>isRecord(run)&&isNonBlankIdentity(run.id)&&typeof run.label=="string"&&isRecord(run.metrics)):[],run=>run.id)}activeMetric(metrics){return this.metricId?metrics.find(metric=>metric.id===this.metricId):metrics[0]}slices(runs){return[...new Set(runs.map(run=>run.slice).filter(slice=>!!slice))]}filteredRuns(runs){return this.slice?runs.filter(run=>run.slice===this.slice):runs}formatMetric(metric,raw){const value=Number.isFinite(raw)?raw:0;return metric.format==="percent"?getNumberFormat(this.effectiveLocale,{style:"percent",maximumFractionDigits:1}).format(finiteRange(value,0,0,1)):getNumberFormat(this.effectiveLocale,{maximumFractionDigits:3}).format(value)}latestValue(metric,runs){return[...runs].reverse().find(run=>Number.isFinite(run.metrics[metric.id]))?.metrics[metric.id]}emitRunChange(run){this.emit("lr-run-change",{run})}renderSlices(slices){if(!slices.length)return nothing;const allSlicesPart=this.slice?"slice":"slice slice-selected";return html`
|
|
2
2
|
<nav part="slices" aria-label=${this.localize("ragEvalDashboardSlices")}>
|
|
3
3
|
<button
|
|
4
4
|
part=${allSlicesPart}
|
|
@@ -22,7 +22,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
22
22
|
></lr-chunk-inspector>
|
|
23
23
|
${this.presentation==="expanded"?this.renderMetadata(chunk.metadata):nothing}
|
|
24
24
|
</div>
|
|
25
|
-
`}}static{this.defaultStrings={...super.defaultStrings,chunkInspectorEmpty:LYRA_DEFAULT_chunkInspectorEmpty,chunkInspectorLabel:LYRA_DEFAULT_chunkInspectorLabel,loadMore:LYRA_DEFAULT_loadMore,retrievalResultsSelectRow:LYRA_DEFAULT_retrievalResultsSelectRow,untitledSource:LYRA_DEFAULT_untitledSource}}static{this.ownedCollectionProperties=Object.freeze(["chunks","selectedChunkIds","groupOrder"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-select","lr-chunk-open"])}connectedCallback(){super.connectedCallback(),this.errorAnnouncementSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}),this.emptyAnnouncementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}disconnectedCallback(){this.isMounting=!0,this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.emptyAnnouncementSink?.release(),this.emptyAnnouncementSink=void 0,this.wasEmptyPresented=!1,super.disconnectedCallback()}deepActiveElement(){return deepActiveElementIn(this.shadowRoot)}chunkAnchor(start){let current=start;for(;current&¤t!==this;){if(current.hasAttribute("data-chunk-id"))return current;if(current.parentElement){current=current.parentElement;continue}const root=current.getRootNode();current=root.nodeType===11&&"host"in root?root.host:null}return null}renderedChunkIds(){const roots=[this.renderRoot],virtualList=this.renderRoot.querySelector("lr-virtual-list");return virtualList?.shadowRoot&&roots.push(virtualList.shadowRoot),roots.flatMap(root=>[...root.querySelectorAll("lr-chunk-inspector[data-chunk-id]")].map(element=>element.getAttribute("data-chunk-id")).filter(id=>id!==null))}willUpdate(changed){super.willUpdate(changed);const groupingLocaleSignature=this.grouping==="source"?`${this.effectiveLocale}\0${this.localize("untitledSource")}`:"";if((this.processedChunksCache===void 0||changed.has("chunks")||changed.has("dedupe")||changed.has("sort")||changed.has("grouping")||changed.has("groupBy")||changed.has("groupLabel")||changed.has("groupOrder")||groupingLocaleSignature!==this.processedGroupingLocaleSignature)&&(this.processedGroupingLocaleSignature=groupingLocaleSignature,this.processedChunksCache=this.computeProcessedChunks()),changed.has("chunks")||changed.has("selectedChunkIds")){const normalized=this.normalizedSelectedChunkIds();(normalized.length!==this.selectedChunkIds.length||normalized.some((id,index)=>id!==this.selectedChunkIds[index]))&&(this.selectedChunkIds=normalized)}if(!changed.has("chunks")&&!changed.has("dedupe")&&!changed.has("sort")&&!changed.has("grouping")&&!changed.has("groupBy")&&!changed.has("groupLabel")&&!changed.has("groupOrder")&&!changed.has("presentation")&&!changed.has("selectable")&&!changed.has("virtualizeAt")&&!changed.has("loading")&&!changed.has("errorText"))return;const focusedId=this.chunkAnchor(this.deepActiveElement())?.getAttribute("data-chunk-id");if(!focusedId)return;const previousIds=this.previousProcessedChunkIds.length?this.previousProcessedChunkIds:this.renderedChunkIds(),focusedIndex=Math.max(0,previousIds.indexOf(focusedId)),nextChunks=this.errorText?[]:this.processedChunks.chunks;if(nextChunks.length===0){this.pendingFocusTarget="base";return}const survivingIndex=nextChunks.findIndex(chunk=>chunk.id===focusedId),nextIndex=survivingIndex>=0?survivingIndex:Math.min(focusedIndex,nextChunks.length-1);this.pendingFocusTarget=nextChunks[nextIndex].id}updated(changed){super.updated(changed);const wasMounting=this.isMounting;this.isMounting=!1,!wasMounting&&changed.has("errorText")&&this.errorText!==""&&this.isConnected&&this.errorAnnouncementSink?.announce(this.errorText);const emptyPresented=!this.loading&&this.errorText===""&&this.processedChunks.chunks.length===0;!wasMounting&&!this.wasEmptyPresented&&emptyPresented&&this.isConnected&&this.emptyAnnouncementSink?.announce(this.localize("chunkInspectorEmpty")),this.wasEmptyPresented=emptyPresented,this.previousProcessedChunkIds=this.errorText?[]:this.processedChunks.chunks.map(chunk=>chunk.id);const generation=++this.focusRestoreGeneration,target=this.pendingFocusTarget;target!==void 0&&(this.pendingFocusTarget=void 0,this.restoreControlledFocus(target,generation))}async restoreControlledFocus(target,generation){if(await this.updateComplete,generation!==this.focusRestoreGeneration||!this.isConnected)return;if(target==="base"){this.renderRoot.querySelector('[part="base"]')?.focus();return}const virtualList=this.renderRoot.querySelector("lr-virtual-list");if(await virtualList?.updateComplete,generation!==this.focusRestoreGeneration||!this.isConnected)return;const roots=[this.renderRoot];virtualList?.shadowRoot&&roots.push(virtualList.shadowRoot);const candidates=roots.flatMap(root=>[...root.querySelectorAll("[data-chunk-id]")]),checkbox=candidates.find(element=>element.localName==="lr-checkbox"&&element.getAttribute("data-chunk-id")===target);if(checkbox){checkbox.focus();return}const inspector=candidates.find(element=>element.localName==="lr-chunk-inspector"&&element.getAttribute("data-chunk-id")===target);await inspector?.updateComplete,!(generation!==this.focusRestoreGeneration||!this.isConnected)&&inspector?.shadowRoot?.querySelector('[part="open-button"]')?.focus()}get effectiveVirtualizeAt(){return finiteCount(this.virtualizeAt,50)}canonicalChunks(){return firstByRetrievalIdentity(Array.isArray(this.chunks)?this.chunks.filter(isValidRetrievalChunk):[],chunk=>chunk.id)}normalizedSelectedChunkIds(){const validIds=new Set(this.canonicalChunks().map(chunk=>chunk.id));return canonicalIdentityList(this.selectedChunkIds).filter(id=>validIds.has(id))}get processedChunks(){return this.processedChunksCache??=this.computeProcessedChunks()}computeProcessedChunks(){const canonical=this.canonicalChunks(),sorted=this.sort==="score"?canonical.sort((a,b)=>safeScore(b.score)-safeScore(a.score)):canonical;if(this.grouping==="source")return this.bucketed(sorted,chunk=>chunk.source.id,(_id,groupChunks)=>groupChunks[0].source.name||this.localize("untitledSource"));if(this.grouping==="custom"&&this.groupBy){const groupBy=this.groupBy;return this.bucketed(sorted,groupBy,(id,groupChunks)=>this.groupLabel?.(id,groupChunks)??id)}return{chunks:sorted,groups:[]}}orderedGroupKeys(grouped){const firstSeen=[...grouped.keys()];if(this.grouping!=="custom"||!this.groupOrder)return firstSeen;if(typeof this.groupOrder=="function")return firstSeen.sort(this.groupOrder);const ordered=[...new Set(this.groupOrder)].filter(id=>grouped.has(id)),listed=new Set(ordered);return[...ordered,...firstSeen.filter(id=>!listed.has(id))]}bucketed(sorted,keyOf,labelOf){const grouped=new Map;for(const chunk of sorted){const key=keyOf(chunk),existing=grouped.get(key);existing?existing.push(chunk):grouped.set(key,[chunk])}const rows=[],groups=[];for(const key of this.orderedGroupKeys(grouped)){const groupChunks=grouped.get(key);!groupChunks||groupChunks.length===0||(groups.push({key,label:labelOf(key,groupChunks),startIndex:rows.length}),rows.push(...groupChunks))}return{chunks:rows,groups}}toggleSelect(chunk){const next=new Set(this.normalizedSelectedChunkIds());next.has(chunk.id)?next.delete(chunk.id):next.add(chunk.id);const chunkIds=[...next];this.selectedChunkIds=chunkIds;const selectedChunks=this.canonicalChunks().filter(c=>next.has(c.id));this.emit("lr-select",{chunkIds,chunks:selectedChunks})}formatMetadataValue(value){if(value==null)return"";if(typeof value=="string"||typeof value=="boolean")return String(value);if(typeof value=="number")return getNumberFormat(this.effectiveLocale).format(finiteNumber(value,0));try{return JSON.stringify(value)}catch{return String(value)}}renderMetadata(metadata){const entries=metadata?Object.entries(metadata):[];return entries.length===0?nothing:html`
|
|
25
|
+
`}}static{this.defaultStrings={...super.defaultStrings,chunkInspectorEmpty:LYRA_DEFAULT_chunkInspectorEmpty,chunkInspectorLabel:LYRA_DEFAULT_chunkInspectorLabel,loadMore:LYRA_DEFAULT_loadMore,retrievalResultsSelectRow:LYRA_DEFAULT_retrievalResultsSelectRow,untitledSource:LYRA_DEFAULT_untitledSource}}static{this.ownedCollectionProperties=Object.freeze(["chunks","selectedChunkIds","groupOrder"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-select","lr-chunk-open"])}connectedCallback(){super.connectedCallback(),this.errorAnnouncementSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}),this.emptyAnnouncementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}disconnectedCallback(){this.isMounting=!0,this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.emptyAnnouncementSink?.release(),this.emptyAnnouncementSink=void 0,this.wasEmptyPresented=!1,super.disconnectedCallback()}deepActiveElement(){return deepActiveElementIn(this.shadowRoot)}chunkAnchor(start){let current=start;for(;current&¤t!==this;){if(current.hasAttribute("data-chunk-id"))return current;if(current.parentElement){current=current.parentElement;continue}const root=current.getRootNode();current=root.nodeType===11&&"host"in root?root.host:null}return null}renderedChunkIds(){const roots=[this.renderRoot],virtualList=this.renderRoot.querySelector("lr-virtual-list");return virtualList?.shadowRoot&&roots.push(virtualList.shadowRoot),roots.flatMap(root=>[...root.querySelectorAll("lr-chunk-inspector[data-chunk-id]")].map(element=>element.getAttribute("data-chunk-id")).filter(id=>id!==null))}willUpdate(changed){super.willUpdate(changed);const groupingLocaleSignature=this.grouping==="source"?`${this.effectiveLocale}\0${this.localize("untitledSource")}`:"";if((this.processedChunksCache===void 0||changed.has("chunks")||changed.has("dedupe")||changed.has("sort")||changed.has("grouping")||changed.has("groupBy")||changed.has("groupLabel")||changed.has("groupOrder")||groupingLocaleSignature!==this.processedGroupingLocaleSignature)&&(this.processedGroupingLocaleSignature=groupingLocaleSignature,this.processedChunksCache=this.computeProcessedChunks()),changed.has("chunks")||changed.has("selectedChunkIds")){const normalized=this.normalizedSelectedChunkIds();if(normalized.length!==this.selectedChunkIds.length||normalized.some((id,index)=>id!==this.selectedChunkIds[index])){const shouldAnnounce=this.hasUpdated&&changed.has("chunks");if(this.selectedChunkIds=normalized,shouldAnnounce){const selected=new Set(normalized);this.emit("lr-select",{chunkIds:normalized,chunks:this.canonicalChunks().filter(chunk=>selected.has(chunk.id))})}}}if(!changed.has("chunks")&&!changed.has("dedupe")&&!changed.has("sort")&&!changed.has("grouping")&&!changed.has("groupBy")&&!changed.has("groupLabel")&&!changed.has("groupOrder")&&!changed.has("presentation")&&!changed.has("selectable")&&!changed.has("virtualizeAt")&&!changed.has("loading")&&!changed.has("errorText"))return;const focusedId=this.chunkAnchor(this.deepActiveElement())?.getAttribute("data-chunk-id");if(!focusedId)return;const previousIds=this.previousProcessedChunkIds.length?this.previousProcessedChunkIds:this.renderedChunkIds(),focusedIndex=Math.max(0,previousIds.indexOf(focusedId)),nextChunks=this.errorText?[]:this.processedChunks.chunks;if(nextChunks.length===0){this.pendingFocusTarget="base";return}const survivingIndex=nextChunks.findIndex(chunk=>chunk.id===focusedId),nextIndex=survivingIndex>=0?survivingIndex:Math.min(focusedIndex,nextChunks.length-1);this.pendingFocusTarget=nextChunks[nextIndex].id}updated(changed){super.updated(changed);const wasMounting=this.isMounting;this.isMounting=!1,!wasMounting&&changed.has("errorText")&&this.errorText!==""&&this.isConnected&&this.errorAnnouncementSink?.announce(this.errorText);const emptyPresented=!this.loading&&this.errorText===""&&this.processedChunks.chunks.length===0;!wasMounting&&!this.wasEmptyPresented&&emptyPresented&&this.isConnected&&this.emptyAnnouncementSink?.announce(this.localize("chunkInspectorEmpty")),this.wasEmptyPresented=emptyPresented,this.previousProcessedChunkIds=this.errorText?[]:this.processedChunks.chunks.map(chunk=>chunk.id);const generation=++this.focusRestoreGeneration,target=this.pendingFocusTarget;target!==void 0&&(this.pendingFocusTarget=void 0,this.restoreControlledFocus(target,generation))}async restoreControlledFocus(target,generation){if(await this.updateComplete,generation!==this.focusRestoreGeneration||!this.isConnected)return;if(target==="base"){this.renderRoot.querySelector('[part="base"]')?.focus();return}const virtualList=this.renderRoot.querySelector("lr-virtual-list");if(await virtualList?.updateComplete,generation!==this.focusRestoreGeneration||!this.isConnected)return;const roots=[this.renderRoot];virtualList?.shadowRoot&&roots.push(virtualList.shadowRoot);const candidates=roots.flatMap(root=>[...root.querySelectorAll("[data-chunk-id]")]),checkbox=candidates.find(element=>element.localName==="lr-checkbox"&&element.getAttribute("data-chunk-id")===target);if(checkbox){checkbox.focus();return}const inspector=candidates.find(element=>element.localName==="lr-chunk-inspector"&&element.getAttribute("data-chunk-id")===target);await inspector?.updateComplete,!(generation!==this.focusRestoreGeneration||!this.isConnected)&&inspector?.shadowRoot?.querySelector('[part="open-button"]')?.focus()}get effectiveVirtualizeAt(){return finiteCount(this.virtualizeAt,50)}canonicalChunks(){return firstByRetrievalIdentity(Array.isArray(this.chunks)?this.chunks.filter(isValidRetrievalChunk):[],chunk=>chunk.id)}normalizedSelectedChunkIds(){const validIds=new Set(this.canonicalChunks().map(chunk=>chunk.id));return canonicalIdentityList(this.selectedChunkIds).filter(id=>validIds.has(id))}get processedChunks(){return this.processedChunksCache??=this.computeProcessedChunks()}computeProcessedChunks(){const canonical=this.canonicalChunks(),sorted=this.sort==="score"?canonical.sort((a,b)=>safeScore(b.score)-safeScore(a.score)):canonical;if(this.grouping==="source")return this.bucketed(sorted,chunk=>chunk.source.id,(_id,groupChunks)=>groupChunks[0].source.name||this.localize("untitledSource"));if(this.grouping==="custom"&&this.groupBy){const groupBy=this.groupBy;return this.bucketed(sorted,groupBy,(id,groupChunks)=>this.groupLabel?.(id,groupChunks)??id)}return{chunks:sorted,groups:[]}}orderedGroupKeys(grouped){const firstSeen=[...grouped.keys()];if(this.grouping!=="custom"||!this.groupOrder)return firstSeen;if(typeof this.groupOrder=="function")return firstSeen.sort(this.groupOrder);const ordered=[...new Set(this.groupOrder)].filter(id=>grouped.has(id)),listed=new Set(ordered);return[...ordered,...firstSeen.filter(id=>!listed.has(id))]}bucketed(sorted,keyOf,labelOf){const grouped=new Map;for(const chunk of sorted){const key=keyOf(chunk),existing=grouped.get(key);existing?existing.push(chunk):grouped.set(key,[chunk])}const rows=[],groups=[];for(const key of this.orderedGroupKeys(grouped)){const groupChunks=grouped.get(key);!groupChunks||groupChunks.length===0||(groups.push({key,label:labelOf(key,groupChunks),startIndex:rows.length}),rows.push(...groupChunks))}return{chunks:rows,groups}}toggleSelect(chunk){const next=new Set(this.normalizedSelectedChunkIds());next.has(chunk.id)?next.delete(chunk.id):next.add(chunk.id);const chunkIds=[...next];this.selectedChunkIds=chunkIds;const selectedChunks=this.canonicalChunks().filter(c=>next.has(c.id));this.emit("lr-select",{chunkIds,chunks:selectedChunks})}formatMetadataValue(value){if(value==null)return"";if(typeof value=="string"||typeof value=="boolean")return String(value);if(typeof value=="number")return getNumberFormat(this.effectiveLocale).format(finiteNumber(value,0));try{return JSON.stringify(value)}catch{return String(value)}}renderMetadata(metadata){const entries=metadata?Object.entries(metadata):[];return entries.length===0?nothing:html`
|
|
26
26
|
<dl part="metadata">
|
|
27
27
|
${entries.map(([key,value])=>html`<div part="metadata-entry">
|
|
28
28
|
<dt part="metadata-term">${key}</dt>
|
|
@@ -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}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import"../../forms/input/input.class.js";import"../../layout/segmented/segmented.class.js";import"../../overlays/chip/chip.class.js";import"../../overlays/chip/chip-group.class.js";import"../../overlays/spinner/spinner.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./retrieval-search.styles.js";import{retrievalSemanticLabel,retrievalSemanticRole}from"../retrieval-semantic-owner.js";import{formatBoundedRetrievalValue}from"../retrieval-value-format.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{literalSetConverter}from"../../../internal/converters.js";import{canonicalIdentityList,isRecord}from"../retrieval-identity.js";import{LYRA_DEFAULT_cancel,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_retrievalFilterChipLabel,LYRA_DEFAULT_retrievalFiltersLabel,LYRA_DEFAULT_retrievalModeHybrid,LYRA_DEFAULT_retrievalModeKeyword,LYRA_DEFAULT_retrievalModeLabel,LYRA_DEFAULT_retrievalModeVector,LYRA_DEFAULT_retrievalSearchEmptyDescription,LYRA_DEFAULT_retrievalSearchLabel,LYRA_DEFAULT_search,LYRA_DEFAULT_valueInvalid}from"../../../internal/default-strings.generated.js";const RETRIEVAL_MODE=literalSetConverter(["vector","keyword","hybrid"],"hybrid");class LyraRetrievalSearch extends LyraElement{constructor(){super(...arguments),this.query="",this._mode="hybrid",this.filters={},this.scope=[],this.loading=!1,this.errorText="",this.empty=!1,this.placeholder="",this.accessibleLabel=null,this.isMounting=!0,this.wasEmptyPresented=!1,this.chipFocusGeneration=0,this.onQueryInput=e=>{e.stopPropagation(),this.query=e.detail.value},this.onQueryKeyDown=e=>{e.key==="Enter"&&(e.isComposing||e.keyCode===229||(e.preventDefault(),this.submit()))},this.onModeChange=e=>{e.stopPropagation(),this.mode=e.detail.value},this.onSubmitClick=()=>{if(this.loading){this.cancel();return}this.submit()}}static{this.defaultStrings={...super.defaultStrings,cancel:LYRA_DEFAULT_cancel,fieldRequired:LYRA_DEFAULT_fieldRequired,noMatches:LYRA_DEFAULT_noMatches,retrievalFilterChipLabel:LYRA_DEFAULT_retrievalFilterChipLabel,retrievalFiltersLabel:LYRA_DEFAULT_retrievalFiltersLabel,retrievalModeHybrid:LYRA_DEFAULT_retrievalModeHybrid,retrievalModeKeyword:LYRA_DEFAULT_retrievalModeKeyword,retrievalModeLabel:LYRA_DEFAULT_retrievalModeLabel,retrievalModeVector:LYRA_DEFAULT_retrievalModeVector,retrievalSearchEmptyDescription:LYRA_DEFAULT_retrievalSearchEmptyDescription,retrievalSearchLabel:LYRA_DEFAULT_retrievalSearchLabel,search:LYRA_DEFAULT_search,valueInvalid:LYRA_DEFAULT_valueInvalid}}static{this.ownedCollectionProperties=Object.freeze(["filters","scope"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-search","lr-filters-change"])}get mode(){return this._mode}set mode(next){const normalized=RETRIEVAL_MODE.normalize(next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}connectedCallback(){super.connectedCallback(),this.errorAnnouncementSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}),this.emptyAnnouncementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}disconnectedCallback(){this.isMounting=!0,this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.emptyAnnouncementSink?.release(),this.emptyAnnouncementSink=void 0,this.wasEmptyPresented=!1,super.disconnectedCallback()}updated(changed){super.updated(changed);const wasMounting=this.isMounting;this.isMounting=!1,!wasMounting&&changed.has("errorText")&&this.errorText!==""&&this.isConnected&&this.errorAnnouncementSink?.announce(this.errorText);const emptyPresented=this.empty&&!this.loading&&this.errorText==="";!wasMounting&&!this.wasEmptyPresented&&emptyPresented&&this.isConnected&&this.emptyAnnouncementSink?.announce(this.localize("noMatches")),this.wasEmptyPresented=emptyPresented}modeItems(){return[{value:"vector",label:this.localize("retrievalModeVector")},{value:"keyword",label:this.localize("retrievalModeKeyword")},{value:"hybrid",label:this.localize("retrievalModeHybrid")}]}formatFilterValue(value){const sentinel=this.localize("valueInvalid");return formatBoundedRetrievalValue(value,{locale:this.effectiveLocale,invalid:sentinel,truncated:sentinel})}get normalizedFilters(){return isRecord(this.filters)?this.filters:{}}get normalizedScope(){return canonicalIdentityList(this.scope)}buildQuery(){return{text:this.query,mode:this.mode,filters:{...this.normalizedFilters},scope:[...this.normalizedScope]}}submit(){this.loading&&this.emit("lr-cancel",{reason:"superseded"}),this.emit("lr-search",this.buildQuery())}cancel(){this.emit("lr-cancel",{})}emitFiltersChange(){this.emit("lr-filters-change",{filters:{...this.normalizedFilters},scope:[...this.normalizedScope]})}repairFocusAfterChipRemoval(index,shouldRepair){const generation=++this.chipFocusGeneration;shouldRepair&&this.updateComplete.then(()=>{if(!this.isConnected||generation!==this.chipFocusGeneration)return;const chips=this.renderRoot.querySelectorAll('[part="filters"] lr-chip'),target=chips[Math.min(index,chips.length-1)];if(target){target.focus();return}this.renderRoot.querySelector('[part="query"]')?.focus()})}removeScope(value,shouldRepairFocus=!1){const scope=this.normalizedScope,index=scope.indexOf(value);this.scope=scope.filter(s=>s!==value),this.emitFiltersChange(),this.repairFocusAfterChipRemoval(Math.max(0,index),shouldRepairFocus)}removeFilter(key,shouldRepairFocus=!1){const filters=this.normalizedFilters,index=this.normalizedScope.length+Object.keys(filters).indexOf(key),next={...filters};delete next[key],this.filters=next,this.emitFiltersChange(),this.repairFocusAfterChipRemoval(Math.max(0,index),shouldRepairFocus)}render(){const label=retrievalSemanticLabel(this,this.accessibleLabel??(this.label==null?this.localize("retrievalSearchLabel"):this.label)),searchRole=retrievalSemanticRole(this,"search"),filters=this.normalizedFilters,scope=this.normalizedScope,hasFilters=Object.keys(filters).length>0||scope.length>0;return html`
|
|
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}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import"../../forms/input/input.class.js";import"../../layout/segmented/segmented.class.js";import"../../overlays/chip/chip.class.js";import"../../overlays/chip/chip-group.class.js";import"../../overlays/spinner/spinner.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./retrieval-search.styles.js";import{retrievalSemanticLabel,retrievalSemanticRole}from"../retrieval-semantic-owner.js";import{formatBoundedRetrievalValue}from"../retrieval-value-format.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{literalSetConverter}from"../../../internal/converters.js";import{activeElementIn}from"../../../internal/active-element.js";import{canonicalIdentityList,isRecord}from"../retrieval-identity.js";import{LYRA_DEFAULT_cancel,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_retrievalFilterChipLabel,LYRA_DEFAULT_retrievalFiltersLabel,LYRA_DEFAULT_retrievalModeHybrid,LYRA_DEFAULT_retrievalModeKeyword,LYRA_DEFAULT_retrievalModeLabel,LYRA_DEFAULT_retrievalModeVector,LYRA_DEFAULT_retrievalSearchEmptyDescription,LYRA_DEFAULT_retrievalSearchLabel,LYRA_DEFAULT_search,LYRA_DEFAULT_valueInvalid}from"../../../internal/default-strings.generated.js";const RETRIEVAL_MODE=literalSetConverter(["vector","keyword","hybrid"],"hybrid");class LyraRetrievalSearch extends LyraElement{constructor(){super(...arguments),this.query="",this._mode="hybrid",this.filters={},this.scope=[],this.loading=!1,this.errorText="",this.empty=!1,this.placeholder="",this.accessibleLabel=null,this.isMounting=!0,this.wasEmptyPresented=!1,this.chipFocusGeneration=0,this.onQueryInput=e=>{e.stopPropagation(),this.query=e.detail.value},this.onQueryKeyDown=e=>{e.key==="Enter"&&(e.isComposing||e.keyCode===229||(e.preventDefault(),this.submit()))},this.onModeChange=e=>{e.stopPropagation(),this.mode=e.detail.value},this.onSubmitClick=()=>{if(this.loading){this.cancel();return}this.submit()}}static{this.defaultStrings={...super.defaultStrings,cancel:LYRA_DEFAULT_cancel,fieldRequired:LYRA_DEFAULT_fieldRequired,noMatches:LYRA_DEFAULT_noMatches,retrievalFilterChipLabel:LYRA_DEFAULT_retrievalFilterChipLabel,retrievalFiltersLabel:LYRA_DEFAULT_retrievalFiltersLabel,retrievalModeHybrid:LYRA_DEFAULT_retrievalModeHybrid,retrievalModeKeyword:LYRA_DEFAULT_retrievalModeKeyword,retrievalModeLabel:LYRA_DEFAULT_retrievalModeLabel,retrievalModeVector:LYRA_DEFAULT_retrievalModeVector,retrievalSearchEmptyDescription:LYRA_DEFAULT_retrievalSearchEmptyDescription,retrievalSearchLabel:LYRA_DEFAULT_retrievalSearchLabel,search:LYRA_DEFAULT_search,valueInvalid:LYRA_DEFAULT_valueInvalid}}static{this.ownedCollectionProperties=Object.freeze(["filters","scope"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-search","lr-filters-change"])}get mode(){return this._mode}set mode(next){const normalized=RETRIEVAL_MODE.normalize(next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}connectedCallback(){super.connectedCallback(),this.errorAnnouncementSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}),this.emptyAnnouncementSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}disconnectedCallback(){this.isMounting=!0,this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.emptyAnnouncementSink?.release(),this.emptyAnnouncementSink=void 0,this.wasEmptyPresented=!1,super.disconnectedCallback()}updated(changed){super.updated(changed);const wasMounting=this.isMounting;this.isMounting=!1,!wasMounting&&changed.has("errorText")&&this.errorText!==""&&this.isConnected&&this.errorAnnouncementSink?.announce(this.errorText);const emptyPresented=this.empty&&!this.loading&&this.errorText==="";!wasMounting&&!this.wasEmptyPresented&&emptyPresented&&this.isConnected&&this.emptyAnnouncementSink?.announce(this.localize("noMatches")),this.wasEmptyPresented=emptyPresented}modeItems(){return[{value:"vector",label:this.localize("retrievalModeVector")},{value:"keyword",label:this.localize("retrievalModeKeyword")},{value:"hybrid",label:this.localize("retrievalModeHybrid")}]}formatFilterValue(value){const sentinel=this.localize("valueInvalid");return formatBoundedRetrievalValue(value,{locale:this.effectiveLocale,invalid:sentinel,truncated:sentinel})}get normalizedFilters(){return isRecord(this.filters)?this.filters:{}}get normalizedScope(){return canonicalIdentityList(this.scope)}buildQuery(){return{text:this.query,mode:this.mode,filters:{...this.normalizedFilters},scope:[...this.normalizedScope]}}submit(){this.loading&&this.emit("lr-cancel",{reason:"superseded"}),this.emit("lr-search",this.buildQuery())}cancel(){this.emit("lr-cancel",{})}emitFiltersChange(){this.emit("lr-filters-change",{filters:{...this.normalizedFilters},scope:[...this.normalizedScope]})}repairFocusAfterChipRemoval(index,shouldRepair){const generation=++this.chipFocusGeneration;shouldRepair&&this.updateComplete.then(()=>{if(!this.isConnected||generation!==this.chipFocusGeneration)return;const chips=this.renderRoot.querySelectorAll('[part="filters"] lr-chip'),target=chips[Math.min(index,chips.length-1)];if(target){target.focus();return}this.renderRoot.querySelector('[part="query"]')?.focus()})}removeScope(value,shouldRepairFocus=!1){const scope=this.normalizedScope,index=scope.indexOf(value);this.scope=scope.filter(s=>s!==value),this.emitFiltersChange(),this.repairFocusAfterChipRemoval(Math.max(0,index),shouldRepairFocus)}removeFilter(key,shouldRepairFocus=!1){const filters=this.normalizedFilters,index=this.normalizedScope.length+Object.keys(filters).indexOf(key),next={...filters};delete next[key],this.filters=next,this.emitFiltersChange(),this.repairFocusAfterChipRemoval(Math.max(0,index),shouldRepairFocus)}render(){const label=retrievalSemanticLabel(this,this.accessibleLabel??(this.label==null?this.localize("retrievalSearchLabel"):this.label)),searchRole=retrievalSemanticRole(this,"search"),filters=this.normalizedFilters,scope=this.normalizedScope,hasFilters=Object.keys(filters).length>0||scope.length>0;return html`
|
|
2
2
|
<div
|
|
3
3
|
part="base"
|
|
4
4
|
role=${searchRole??nothing}
|
|
@@ -8,6 +8,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
8
8
|
<lr-input
|
|
9
9
|
part="query"
|
|
10
10
|
type="search"
|
|
11
|
+
clearable
|
|
11
12
|
placeholder=${this.placeholder||this.localize("search")}
|
|
12
13
|
.value=${this.query}
|
|
13
14
|
@lr-input=${this.onQueryInput}
|
|
@@ -36,13 +37,13 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
36
37
|
variant="brand"
|
|
37
38
|
removable
|
|
38
39
|
value=${s}
|
|
39
|
-
@lr-remove=${event=>{event.stopPropagation();const chip=event.currentTarget;this.removeScope(s,chip.shadowRoot
|
|
40
|
+
@lr-remove=${event=>{event.stopPropagation();const chip=event.currentTarget;this.removeScope(s,activeElementIn(chip.shadowRoot)!==null)}}
|
|
40
41
|
>${s}</lr-chip
|
|
41
42
|
>`)}
|
|
42
43
|
${Object.entries(filters).map(([k,v])=>html`<lr-chip
|
|
43
44
|
removable
|
|
44
45
|
value=${k}
|
|
45
|
-
@lr-remove=${event=>{event.stopPropagation();const chip=event.currentTarget;this.removeFilter(k,chip.shadowRoot
|
|
46
|
+
@lr-remove=${event=>{event.stopPropagation();const chip=event.currentTarget;this.removeFilter(k,activeElementIn(chip.shadowRoot)!==null)}}
|
|
46
47
|
>${this.localize("retrievalFilterChipLabel",void 0,{key:k,value:this.formatFilterValue(v)})}</lr-chip
|
|
47
48
|
>`)}
|
|
48
49
|
</lr-chip-group>`:nothing}
|
|
@@ -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{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{finiteNumber}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{chevronIcon}from"../../../internal/icons.js";import"../../agent-tools/span-waterfall/span-waterfall.class.js";import"../chunk-inspector/chunk-inspector.class.js";import{firstByRetrievalIdentity,isValidRetrievalChunk}from"../retrieval-identity.js";import{styles}from"./retrieval-trace.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_expand,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_retrievalStageEmbed,LYRA_DEFAULT_retrievalStageFilter,LYRA_DEFAULT_retrievalStageQueryRewrite,LYRA_DEFAULT_retrievalStageRerank,LYRA_DEFAULT_retrievalStageRetrieve,LYRA_DEFAULT_retrievalTraceEvidenceToggle,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_tokensIn,LYRA_DEFAULT_tokensOut}from"../../../internal/default-strings.generated.js";const STAGE_SPAN_KIND={"query-rewrite":"llm",embed:"embedding",retrieve:"retriever",rerank:"tool",filter:"tool"},STAGE_LABEL={"query-rewrite":{key:"retrievalStageQueryRewrite"},embed:{key:"retrievalStageEmbed"},retrieve:{key:"retrievalStageRetrieve"},rerank:{key:"retrievalStageRerank"},filter:{key:"retrievalStageFilter"}};function validChunks(evidence){return Array.isArray(evidence?.chunks)?evidence.chunks.filter(isValidRetrievalChunk):[]}function hasEvidence(evidence){return evidence?!!evidence.text||validChunks(evidence).length>0||!!(evidence.metadata&&Object.keys(evidence.metadata).length>0):!1}function toLyraChunk(chunk){return{id:chunk.id,text:chunk.text,score:chunk.score,sourceId:chunk.source.id,title:chunk.source.name,...chunk.locator?{anchor:chunk.locator}:{},...chunk.locator?.kind==="page"?{page:chunk.locator.page}:{}}}class LyraRetrievalTrace extends LyraElement{constructor(){super(...arguments),this.stages=[],this.activeStageId=null,this.label="",this.expandedStageIds=new Set,this.evidenceDomIdPrefix=nextId("retrieval-trace-evidence"),this.onStageSelect=e=>{e.stopPropagation();const{spanId:stageId}=e.detail;this.emit("lr-stage-select",{stageId});const stage=this.normalizedStages.find(s=>s.id===stageId);if(stage&&hasEvidence(stage.evidence)&&!this.expandedStageIds.has(stageId)){const next=new Set(this.expandedStageIds);next.add(stageId),this.expandedStageIds=next,this.emit("lr-stage-toggle",{stageId,expanded:!0})}}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,expand:LYRA_DEFAULT_expand,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,retrievalStageEmbed:LYRA_DEFAULT_retrievalStageEmbed,retrievalStageFilter:LYRA_DEFAULT_retrievalStageFilter,retrievalStageQueryRewrite:LYRA_DEFAULT_retrievalStageQueryRewrite,retrievalStageRerank:LYRA_DEFAULT_retrievalStageRerank,retrievalStageRetrieve:LYRA_DEFAULT_retrievalStageRetrieve,retrievalTraceEvidenceToggle:LYRA_DEFAULT_retrievalTraceEvidenceToggle,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,tokensIn:LYRA_DEFAULT_tokensIn,tokensOut:LYRA_DEFAULT_tokensOut}}static{this.ownedCollectionProperties=Object.freeze(["stages"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-stage-chunk-action"])}get normalizedStages(){return firstByRetrievalIdentity(Array.isArray(this.stages)?this.stages:[],stage=>stage.id)}stageLabel(stage){if(typeof stage.label=="string"&&stage.label)return stage.label;const entry=STAGE_LABEL[stage.kind];return entry?this.localize(entry.key):String(stage.kind)}toSpans(){return this.normalizedStages.map(stage=>({id:stage.id,name:this.stageLabel(stage),kind:STAGE_SPAN_KIND[stage.kind]??"tool",startMs:stage.startMs,endMs:stage.endMs,status:stage.status,detail:stage.detail}))}toggleEvidence(stageId){const expanded=!this.expandedStageIds.has(stageId),next=new Set(this.expandedStageIds);expanded?next.add(stageId):next.delete(stageId),this.expandedStageIds=next,this.emit("lr-stage-toggle",{stageId,expanded})}willUpdate(changed){if(super.willUpdate(changed),changed.has("stages")){const ids=new Set(this.normalizedStages.map(s=>s.id));let pruned=null;for(const id of this.expandedStageIds)ids.has(id)||(pruned??=new Set(this.expandedStageIds),pruned.delete(id));pruned&&(this.expandedStageIds=pruned)}}renderEvidenceBody(stage){const evidence=stage.evidence,chunks=validChunks(evidence).map(toLyraChunk),metaEntries=evidence.metadata?Object.entries(evidence.metadata):[];return html`
|
|
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{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{finiteNumber}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{chevronIcon}from"../../../internal/icons.js";import"../../agent-tools/span-waterfall/span-waterfall.class.js";import"../chunk-inspector/chunk-inspector.class.js";import{firstByRetrievalIdentity,isValidRetrievalChunk}from"../retrieval-identity.js";import{styles}from"./retrieval-trace.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_durationMilliseconds,LYRA_DEFAULT_durationSeconds,LYRA_DEFAULT_expand,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_popover,LYRA_DEFAULT_retrievalStageEmbed,LYRA_DEFAULT_retrievalStageFilter,LYRA_DEFAULT_retrievalStageQueryRewrite,LYRA_DEFAULT_retrievalStageRerank,LYRA_DEFAULT_retrievalStageRetrieve,LYRA_DEFAULT_retrievalTraceEvidenceToggle,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_tokensIn,LYRA_DEFAULT_tokensOut}from"../../../internal/default-strings.generated.js";const STAGE_SPAN_KIND={"query-rewrite":"llm",embed:"embedding",retrieve:"retriever",rerank:"tool",filter:"tool"},STAGE_LABEL={"query-rewrite":{key:"retrievalStageQueryRewrite"},embed:{key:"retrievalStageEmbed"},retrieve:{key:"retrievalStageRetrieve"},rerank:{key:"retrievalStageRerank"},filter:{key:"retrievalStageFilter"}};function validChunks(evidence){return Array.isArray(evidence?.chunks)?evidence.chunks.filter(isValidRetrievalChunk):[]}function hasEvidence(evidence){return evidence?!!evidence.text||validChunks(evidence).length>0||!!(evidence.metadata&&Object.keys(evidence.metadata).length>0):!1}function toLyraChunk(chunk){return{id:chunk.id,text:chunk.text,score:chunk.score,sourceId:chunk.source.id,title:chunk.source.name,...chunk.locator?{anchor:chunk.locator}:{},...chunk.locator?.kind==="page"?{page:chunk.locator.page}:{}}}class LyraRetrievalTrace extends LyraElement{constructor(){super(...arguments),this.stages=[],this.activeStageId=null,this.label="",this.expandedStageIds=new Set,this.evidenceDomIdPrefix=nextId("retrieval-trace-evidence"),this.onStageSelect=e=>{e.stopPropagation();const{spanId:stageId}=e.detail;this.emit("lr-stage-select",{stageId});const stage=this.normalizedStages.find(s=>s.id===stageId);if(stage&&hasEvidence(stage.evidence)&&!this.expandedStageIds.has(stageId)){const next=new Set(this.expandedStageIds);next.add(stageId),this.expandedStageIds=next,this.emit("lr-stage-toggle",{stageId,expanded:!0})}}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,expand:LYRA_DEFAULT_expand,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,retrievalStageEmbed:LYRA_DEFAULT_retrievalStageEmbed,retrievalStageFilter:LYRA_DEFAULT_retrievalStageFilter,retrievalStageQueryRewrite:LYRA_DEFAULT_retrievalStageQueryRewrite,retrievalStageRerank:LYRA_DEFAULT_retrievalStageRerank,retrievalStageRetrieve:LYRA_DEFAULT_retrievalStageRetrieve,retrievalTraceEvidenceToggle:LYRA_DEFAULT_retrievalTraceEvidenceToggle,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,tokensIn:LYRA_DEFAULT_tokensIn,tokensOut:LYRA_DEFAULT_tokensOut}}static{this.ownedCollectionProperties=Object.freeze(["stages"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-stage-chunk-action"])}get normalizedStages(){return firstByRetrievalIdentity(Array.isArray(this.stages)?this.stages:[],stage=>stage.id)}stageLabel(stage){if(typeof stage.label=="string"&&stage.label)return stage.label;const entry=STAGE_LABEL[stage.kind];return entry?this.localize(entry.key):String(stage.kind)}toSpans(){return this.normalizedStages.map(stage=>({id:stage.id,name:this.stageLabel(stage),kind:STAGE_SPAN_KIND[stage.kind]??"tool",startMs:stage.startMs,endMs:stage.endMs,status:stage.status,detail:stage.detail}))}toggleEvidence(stageId){const expanded=!this.expandedStageIds.has(stageId),next=new Set(this.expandedStageIds);expanded?next.add(stageId):next.delete(stageId),this.expandedStageIds=next,this.emit("lr-stage-toggle",{stageId,expanded})}willUpdate(changed){if(super.willUpdate(changed),changed.has("stages")){const ids=new Set(this.normalizedStages.map(s=>s.id));let pruned=null;for(const id of this.expandedStageIds)ids.has(id)||(pruned??=new Set(this.expandedStageIds),pruned.delete(id));pruned&&(this.expandedStageIds=pruned)}}renderEvidenceBody(stage){const evidence=stage.evidence,chunks=validChunks(evidence).map(toLyraChunk),metaEntries=evidence.metadata?Object.entries(evidence.metadata):[];return html`
|
|
2
2
|
${evidence.text?html`<p part="evidence-text">${evidence.text}</p>`:nothing}
|
|
3
3
|
${chunks.length>0?html`<lr-chunk-inspector
|
|
4
4
|
part="chunk-inspector"
|
|
@@ -53,4 +53,10 @@ labelPlural:string;private slottedCount;private readonly listId;private readonly
|
|
|
53
53
|
* handy for building a `label-plural` string that stays in sync with
|
|
54
54
|
* what's actually slotted without hand-counting DOM children, e.g.
|
|
55
55
|
* `list.labelPlural = \`${list.sourceCount} sources\`;`. */
|
|
56
|
-
get sourceCount():number;
|
|
56
|
+
get sourceCount():number;
|
|
57
|
+
/** Intentionally inert -- `sourceCount` is always derived live from the actual slotted
|
|
58
|
+
* children. A getter with no setter throws (in strict-mode module code, which every consumer
|
|
59
|
+
* runs) the moment anything assigns to it, including a stray `.sourceCount=${x}` template
|
|
60
|
+
* binding; this no-op keeps that assignment harmless instead of throwing from inside
|
|
61
|
+
* framework internals. */
|
|
62
|
+
set sourceCount(_value:number);private onSlotChange;private toggle;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-source-list':LyraSourceList;}}
|
|
@@ -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}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./source-list.styles.js";import{LYRA_DEFAULT_sourceListDefaultLabel}from"../../../internal/default-strings.generated.js";class LyraSourceList extends LyraElement{constructor(){super(...arguments),this.expanded=!1,this.labelPlural="",this.slottedCount=0,this.listId=nextId("source-list-region"),this.previousRoles=new Map,this.roleObserverGeneration=0,this.onSlotChange=e=>{const elements=e.target.assignedElements({flatten:!0});this.slottedCount=elements.length,this.syncItemRoles(elements)},this.toggle=()=>{this.expanded=!this.expanded,this.emit("lr-toggle",{expanded:this.expanded})}}static{this.defaultStrings={...super.defaultStrings,sourceListDefaultLabel:LYRA_DEFAULT_sourceListDefaultLabel}}static{this.styles=[LyraElement.styles,styles]}isCompatibleListItem(element){const existingRole=element.getAttribute("role")?.trim(),role=existingRole==="listitem"&&this.previousRoles.has(element)&&this.previousRoles.get(element)!=="listitem"?void 0:existingRole;if(role==="listitem")return!0;if(role||element.hasAttribute("tabindex")||element.isContentEditable)return!1;const localName=element.localName;return localName===tag("source-card")||localName==="div"||localName==="span"}onRoleMutations(records){for(const record of records){const element=record.target;if(!(element.parentElement!==this||element.getAttribute("slot"))){record.attributeName==="role"&&this.previousRoles.has(element)&&this.previousRoles.set(element,element.getAttribute("role")),this.reconcileAssignedItems();return}}}observeRoleChanges(){if(!this.isConnected)return;const ownerDocument=this.ownerDocument;if(!this.roleObserver||this.roleObserverDocument!==ownerDocument){this.resetRoleObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.roleObserverGeneration,observer=new MutationObserverCtor(records=>{this.roleObserver!==observer||this.roleObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onRoleMutations(records)});this.roleObserver=observer,this.roleObserverDocument=ownerDocument}this.roleObserver.observe(this,{attributes:!0,attributeFilter:["role","tabindex","contenteditable"],subtree:!0})}syncItemRoles(elements){this.roleObserver?.disconnect();const assigned=new Set(elements),hasListSemantics=elements.every(element=>this.isCompatibleListItem(element)),list=this.shadowRoot?.querySelector('[part="list"]');this.isConnected&&hasListSemantics?list?.setAttribute("role","list"):list?.removeAttribute("role");for(const[element,role]of this.previousRoles)hasListSemantics&&assigned.has(element)&&element.getAttribute("role")==="listitem"&&role!=="listitem"||(role===null?element.removeAttribute("role"):element.setAttribute("role",role),this.previousRoles.delete(element));if(hasListSemantics)for(const element of elements)element.getAttribute("role")?.trim()||(this.previousRoles.has(element)||this.previousRoles.set(element,element.getAttribute("role")),element.setAttribute("role","listitem"));this.observeRoleChanges()}reconcileAssignedItems(){const slot=this.shadowRoot?.querySelector("slot");if(!slot)return;const elements=slot.assignedElements({flatten:!0});this.slottedCount=elements.length,this.syncItemRoles(elements)}connectedCallback(){if(super.connectedCallback(),this.observeRoleChanges(),this.hasUpdated){const ownerDocument=this.ownerDocument,generation=this.roleObserverGeneration;this.updateComplete.then(()=>{!this.isConnected||this.ownerDocument!==ownerDocument||this.roleObserverGeneration!==generation||this.reconcileAssignedItems()})}}disconnectedCallback(){this.roleObserver?.disconnect(),this.syncItemRoles([]),this.resetRoleObserver(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetRoleObserver()}resetRoleObserver(){this.roleObserverGeneration+=1,this.roleObserver?.disconnect(),this.roleObserver=void 0,this.roleObserverDocument=void 0}willUpdate(changed){if(super.willUpdate(changed),!this.hasUpdated){const elements=Array.from(this.children).filter(el=>!el.getAttribute("slot"));this.slottedCount=elements.length}}firstUpdated(changed){super.firstUpdated(changed),this.reconcileAssignedItems()}get sourceCount(){return this.slottedCount}render(){const requestedHeaderText=this.labelPlural||(this.label==null?this.localize("sourceListDefaultLabel"):this.label),headerText=requestedHeaderText.trim()===""?this.localize("sourceListDefaultLabel"):requestedHeaderText;return html`
|
|
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}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{chevronIcon}from"../../../internal/icons.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./source-list.styles.js";import{LYRA_DEFAULT_sourceListDefaultLabel}from"../../../internal/default-strings.generated.js";class LyraSourceList extends LyraElement{constructor(){super(...arguments),this.expanded=!1,this.labelPlural="",this.slottedCount=0,this.listId=nextId("source-list-region"),this.previousRoles=new Map,this.roleObserverGeneration=0,this.onSlotChange=e=>{const elements=e.target.assignedElements({flatten:!0});this.slottedCount=elements.length,this.syncItemRoles(elements)},this.toggle=()=>{this.expanded=!this.expanded,this.emit("lr-toggle",{expanded:this.expanded})}}static{this.defaultStrings={...super.defaultStrings,sourceListDefaultLabel:LYRA_DEFAULT_sourceListDefaultLabel}}static{this.styles=[LyraElement.styles,styles]}isCompatibleListItem(element){const existingRole=element.getAttribute("role")?.trim(),role=existingRole==="listitem"&&this.previousRoles.has(element)&&this.previousRoles.get(element)!=="listitem"?void 0:existingRole;if(role==="listitem")return!0;if(role||element.hasAttribute("tabindex")||element.isContentEditable)return!1;const localName=element.localName;return localName===tag("source-card")||localName==="div"||localName==="span"}onRoleMutations(records){for(const record of records){const element=record.target;if(!(element.parentElement!==this||element.getAttribute("slot"))){record.attributeName==="role"&&this.previousRoles.has(element)&&this.previousRoles.set(element,element.getAttribute("role")),this.reconcileAssignedItems();return}}}observeRoleChanges(){if(!this.isConnected)return;const ownerDocument=this.ownerDocument;if(!this.roleObserver||this.roleObserverDocument!==ownerDocument){this.resetRoleObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.roleObserverGeneration,observer=new MutationObserverCtor(records=>{this.roleObserver!==observer||this.roleObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onRoleMutations(records)});this.roleObserver=observer,this.roleObserverDocument=ownerDocument}this.roleObserver.observe(this,{attributes:!0,attributeFilter:["role","tabindex","contenteditable"],subtree:!0})}syncItemRoles(elements){this.roleObserver?.disconnect();const assigned=new Set(elements),hasListSemantics=elements.every(element=>this.isCompatibleListItem(element)),list=this.shadowRoot?.querySelector('[part="list"]');this.isConnected&&hasListSemantics?list?.setAttribute("role","list"):list?.removeAttribute("role");for(const[element,role]of this.previousRoles)hasListSemantics&&assigned.has(element)&&element.getAttribute("role")==="listitem"&&role!=="listitem"||(role===null?element.removeAttribute("role"):element.setAttribute("role",role),this.previousRoles.delete(element));if(hasListSemantics)for(const element of elements)element.getAttribute("role")?.trim()||(this.previousRoles.has(element)||this.previousRoles.set(element,element.getAttribute("role")),element.setAttribute("role","listitem"));this.observeRoleChanges()}reconcileAssignedItems(){const slot=this.shadowRoot?.querySelector("slot");if(!slot)return;const elements=slot.assignedElements({flatten:!0});this.slottedCount=elements.length,this.syncItemRoles(elements)}connectedCallback(){if(super.connectedCallback(),this.observeRoleChanges(),this.hasUpdated){const ownerDocument=this.ownerDocument,generation=this.roleObserverGeneration;this.updateComplete.then(()=>{!this.isConnected||this.ownerDocument!==ownerDocument||this.roleObserverGeneration!==generation||this.reconcileAssignedItems()})}}disconnectedCallback(){this.roleObserver?.disconnect(),this.syncItemRoles([]),this.resetRoleObserver(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetRoleObserver()}resetRoleObserver(){this.roleObserverGeneration+=1,this.roleObserver?.disconnect(),this.roleObserver=void 0,this.roleObserverDocument=void 0}willUpdate(changed){if(super.willUpdate(changed),!this.hasUpdated){const elements=Array.from(this.children).filter(el=>!el.getAttribute("slot"));this.slottedCount=elements.length}}firstUpdated(changed){super.firstUpdated(changed),this.reconcileAssignedItems()}get sourceCount(){return this.slottedCount}set sourceCount(_value){}render(){const requestedHeaderText=this.labelPlural||(this.label==null?this.localize("sourceListDefaultLabel"):this.label),headerText=requestedHeaderText.trim()===""?this.localize("sourceListDefaultLabel"):requestedHeaderText;return html`
|
|
2
2
|
<div part="base">
|
|
3
3
|
<button
|
|
4
4
|
part="header"
|
|
@@ -19,13 +19,18 @@ readonly extension?:string;}export type LyraExportFormatOption=LyraExportFormat|
|
|
|
19
19
|
* to substitute the built-in client-side download with a server-generated one.
|
|
20
20
|
* @event lr-export-complete - Fired after a non-cancelled download completes.
|
|
21
21
|
* @event lr-export-error - Fired when a built-in CSV/JSON export cannot be serialized or
|
|
22
|
-
* downloaded. `detail: { format, error }`.
|
|
22
|
+
* downloaded. `detail: { format, error }`. The same failure is also announced through the
|
|
23
|
+
* shared light-DOM live region and marks the trigger with the `trigger-error` part token, so a
|
|
24
|
+
* screen-reader user and a sighted user both learn the export failed without needing to listen
|
|
25
|
+
* for this event.
|
|
23
26
|
* @event lr-show - The format menu is about to open, however `open` became true. Cancelable —
|
|
24
27
|
* `preventDefault()` leaves it closed. Not fired for markup that renders open from the start.
|
|
25
28
|
* @event lr-hide - The format menu is about to close. Cancelable on the same terms as `lr-show`.
|
|
26
29
|
* A close this component imposes on itself (disablement, `loading`, or a format list collapsing
|
|
27
30
|
* to one entry) emits no lifecycle event and therefore offers no veto point.
|
|
28
31
|
* @csspart trigger - The button that triggers the export (or opens the format menu).
|
|
32
|
+
* @csspart trigger-error - Present alongside `trigger` after a built-in CSV/JSON export fails,
|
|
33
|
+
* until the next export attempt. Style with `::part(trigger-error)`.
|
|
29
34
|
* @csspart menu - The format-choice menu, shown when more than one format is configured.
|
|
30
35
|
* @csspart menu-item - A single format option inside the menu.
|
|
31
36
|
* @csspart format-label - A format option's primary label.
|
|
@@ -54,7 +59,14 @@ label?:string;
|
|
|
54
59
|
/** Accessible name forwarded from the host to the native trigger button.
|
|
55
60
|
* When unset, a nonempty visible `label` provides the name; an empty visible label uses the
|
|
56
61
|
* localized default. An explicit empty `aria-label` remains authoritative by presence. */
|
|
57
|
-
accessibleLabel:string|null;open:boolean;private triggerEl?;private menuEl?;
|
|
62
|
+
accessibleLabel:string|null;open:boolean;private triggerEl?;private menuEl?;
|
|
63
|
+
/** True from a failed built-in CSV/JSON export until the next export attempt starts; drives
|
|
64
|
+
* the visible `trigger-error` part token. */
|
|
65
|
+
private exportFailed;
|
|
66
|
+
/** Handle on the shared light-DOM live region export outcomes announce through -- a region
|
|
67
|
+
* rendered inside this shadow root is not reliably announced. Acquired on connect, not on the
|
|
68
|
+
* first failure, so assistive tech is already observing before any text arrives. */
|
|
69
|
+
private sink?;private readonly menuId;private cleanup?;private overlay?;private menuPositioned;private pointerDocument?;private connectionGeneration;private connectedDocument?;private pendingDisconnectDocument?;private _isFirstUpdate;private openVetoed;
|
|
58
70
|
/** Which menu item to focus the next time `open` flips true; reset after use. */
|
|
59
71
|
private pendingMenuFocusIndex;private formatsFocusSnapshot?;private forcedMenuClose?;
|
|
60
72
|
/** Tracks only the temporary focus-rescue tabindex this component added itself. */
|
|
@@ -1,6 +1,6 @@
|
|
|
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}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{deferredPlaceReady as place}from"../../../internal/anchored-overlay-runtime.js";import{nextId}from"../../../internal/a11y.js";import{buildCsv,downloadBlob}from"./csv.js";import{styles}from"./export-button.styles.js";import{activeElementIn}from"../../../internal/active-element.js";import{activateNonmodalOverlay}from"../../../internal/nonmodal-overlay-manager.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{LYRA_DEFAULT_exportButtonLabel,LYRA_DEFAULT_exportFormatMenuLabel}from"../../../internal/default-strings.generated.js";const MAX_EXPORT_FORMATS=1e4;function queueDocumentMicrotask(ownerDocument,callback){const ownerWindow=ownerDocument.defaultView;if(ownerWindow){ownerWindow.queueMicrotask(callback);return}Promise.resolve().then(callback)}function formatArrayLength(value){try{if(!Array.isArray(value))return;const length=getOwnDataDescriptor(value,"length");return length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0?void 0:{source:value,length:Math.min(length.value,MAX_EXPORT_FORMATS)}}catch{return}}function projectExportFormat(value){if(value==="csv"||value==="json")return value;if(value===null||typeof value!="object")return;const formatId=getOwnDataDescriptor(value,"formatId"),label=getOwnDataDescriptor(value,"label");if(formatId===MISSING_OWN_DATA_DESCRIPTOR||formatId===UNSAFE_OWN_DATA_DESCRIPTOR||label===MISSING_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR||typeof formatId.value!="string"||formatId.value.trim().length===0||typeof label.value!="string"||label.value.trim().length===0)return;const description=getOwnDataDescriptor(value,"description"),extension=getOwnDataDescriptor(value,"extension");return Object.freeze({formatId:formatId.value,label:label.value,...description!==MISSING_OWN_DATA_DESCRIPTOR&&description!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof description.value=="string"?{description:description.value}:{},...extension!==MISSING_OWN_DATA_DESCRIPTOR&&extension!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof extension.value=="string"?{extension:extension.value}:{}})}class LyraExportButton extends LyraElement{constructor(){super(...arguments),this._rows=Object.freeze([]),this._columns=Object.freeze([]),this.filename="export",this._formats=Object.freeze(["csv"]),this.disabled=!1,this.loading=!1,this.accessibleLabel=null,this.open=!1,this.menuId=nextId("export-menu"),this.menuPositioned=!1,this.connectionGeneration=0,this._isFirstUpdate=!0,this.openVetoed=!1,this.pendingMenuFocusIndex=0,this.injectedHostTabIndex=!1,this.restoreFocusOnMenuClose=!1,this.onDocPointer=e=>{e.composedPath().includes(this)||(this.overlay?.isActive()?this.overlay.dismissBackdrop():this.closeMenu())},this.syncMenuOverlay=()=>{if(this.cleanup?.(),this.cleanup=void 0,this.menuPositioned=!1,this.unbindDocumentPointer(),!this.open||!this.isConnected){const restoreFocus=this.restoreFocusOnMenuClose;this.restoreFocusOnMenuClose=!1,this.deactivateMenuOverlay(restoreFocus);return}this.activateMenuOverlay(),this.bindDocumentPointer();const anchor=this.triggerEl,menu=this.menuEl,ownerDocument=this.ownerDocument;if(!anchor||!menu)return;const placement=place(anchor,menu);this.cleanup=placement,placement.ready.then(positioned=>{if(!(this.cleanup!==placement||!this.open||!this.isConnected||this.ownerDocument!==ownerDocument)){if(!positioned){this.forcedMenuClose="state",this.open=!1;return}this.menuPositioned=!0,this.focusMenuItem(this.pendingMenuFocusIndex),this.pendingMenuFocusIndex=0}})},this.onKeyDown=e=>{if(this.formats.length<=1||this.disabled||this.loading)return;const items=this.menuItemEls(),currentIndex=items.indexOf(e.target);switch(e.key){case"ArrowDown":e.preventDefault(),this.focusMenuItemOnOpen(currentIndex===-1?0:currentIndex+1);break;case"ArrowUp":e.preventDefault(),this.focusMenuItemOnOpen(currentIndex===-1?items.length-1:currentIndex-1);break;case"Home":this.open&&(e.preventDefault(),this.focusMenuItem(0));break;case"End":this.open&&(e.preventDefault(),this.focusMenuItem(items.length-1));break}}}static{this.defaultStrings={...super.defaultStrings,exportButtonLabel:LYRA_DEFAULT_exportButtonLabel,exportFormatMenuLabel:LYRA_DEFAULT_exportFormatMenuLabel}}static{this.styles=[LyraElement.styles,styles]}static{this.properties={rows:{attribute:!1,noAccessor:!0},columns:{attribute:!1,noAccessor:!0},formats:{attribute:!1,noAccessor:!0}}}get rows(){return this._rows}set rows(next){const previous=this._rows,source=Array.isArray(next)?next:[];this._rows=Object.freeze(source.map(row=>Object.freeze({...row}))),this.requestUpdate("rows",previous)}get columns(){return this._columns}set columns(next){const previous=this._columns,source=Array.isArray(next)?next:[];this._columns=Object.freeze(source.map(column=>Object.freeze({...column}))),this.requestUpdate("columns",previous)}get formats(){return this._formats}set formats(next){const previous=this._formats,source=formatArrayLength(next),seen=new Set,formats=[];for(let index=0;source&&index<source.length;index+=1){const descriptor=getOwnDataDescriptor(source.source,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const snapshot=projectExportFormat(descriptor.value);if(!snapshot)continue;const id=typeof snapshot=="string"?snapshot:snapshot.formatId;typeof id!="string"||id.trim()===""||seen.has(id)||(seen.add(id),formats.push(snapshot))}this._formats=Object.freeze(formats),this.requestUpdate("formats",previous)}connectedCallback(){const pendingDisconnectDocument=this.pendingDisconnectDocument;if(this.pendingDisconnectDocument=void 0,this.connectionGeneration+=1,this.connectedDocument=this.ownerDocument,super.connectedCallback(),pendingDisconnectDocument){if(pendingDisconnectDocument===this.ownerDocument){this.deactivateMenuOverlay(!1),this.restoreFocusOnMenuClose=!1,this.open=!1;return}this.hasUpdated&&this.open&&this.scheduleAfterUpdate(this.syncMenuOverlay,"export-button-menu-overlay");return}this.hasUpdated&&this.open&&this.scheduleAfterUpdate(this.syncMenuOverlay,"export-button-menu-overlay")}disconnectedCallback(){const generation=++this.connectionGeneration,disconnectDocument=this.connectedDocument??this.ownerDocument;this.pendingDisconnectDocument=disconnectDocument,super.disconnectedCallback(),this.cleanup?.(),this.cleanup=void 0,this.menuPositioned=!1,this.unbindDocumentPointer(),this.overlay?.suspend(),this.restoreFocusOnMenuClose=!1,queueDocumentMicrotask(disconnectDocument,()=>{this.connectionGeneration!==generation||this.isConnected||this.pendingDisconnectDocument!==disconnectDocument||(this.pendingDisconnectDocument=void 0,this.deactivateMenuOverlay(!1),this.restoreFocusOnMenuClose=!1,this.open=!1)})}adoptedCallback(){super.adoptedCallback(),this.cleanup?.(),this.cleanup=void 0,this.unbindDocumentPointer(),this.overlay?.suspend()}bindDocumentPointer(){if(!this.isConnected)return;const owner=this.ownerDocument;this.pointerDocument!==owner&&(this.unbindDocumentPointer(),owner.addEventListener("pointerdown",this.onDocPointer),this.pointerDocument=owner)}unbindDocumentPointer(){this.pointerDocument?.removeEventListener("pointerdown",this.onDocPointer),this.pointerDocument=void 0}openMenu(){this.open||(this.open=!0)}closeMenu(restoreFocus=!1){this.open&&(this.restoreFocusOnMenuClose||=restoreFocus,this.open=!1)}activateMenuOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateNonmodalOverlay({host:this,panel:()=>this.menuEl??null,onEscape:()=>this.closeMenu(!0),onBackdrop:()=>this.closeMenu(),onTab:()=>this.closeMenu(),restoreFocusTo:()=>this.triggerEl??null})}deactivateMenuOverlay(restoreFocus){const overlay=this.overlay;this.overlay=void 0,overlay?.deactivate({restoreFocus}),this.unbindDocumentPointer()}menuItemEls(){return Array.from(this.renderRoot.querySelectorAll('[part="menu-item"]'))}focusMenuItem(index){const items=this.menuItemEls();items.length!==0&&items[Math.max(0,Math.min(items.length-1,index))]?.focus()}focusMenuItemOnOpen(index){this.open&&this.menuPositioned?this.focusMenuItem(index):(this.pendingMenuFocusIndex=index,this.open||this.openMenu())}firstUpdated(changed){super.firstUpdated(changed),this.renderRoot.addEventListener("keydown",this.onKeyDown)}willUpdate(changed){if(super.willUpdate(changed),this._isFirstUpdate=!this.hasUpdated,this.setAttribute("aria-busy",String(this.loading)),(changed.has("disabled")||changed.has("loading"))&&!this.disabled&&!this.loading&&this.injectedHostTabIndex&&(this.getAttribute("tabindex")==="-1"&&this.removeAttribute("tabindex"),this.injectedHostTabIndex=!1),(changed.has("disabled")||changed.has("loading"))&&(this.disabled||this.loading)){const active=activeElementIn(this.shadowRoot);if(active===this.triggerEl||active?.getAttribute("part")==="menu-item"){this.hasAttribute("tabindex")||(this.tabIndex=-1,this.injectedHostTabIndex=!0);const ownerHTMLElement=this.ownerDocument.defaultView?.HTMLElement,nativeFocus=ownerHTMLElement?Reflect.get(ownerHTMLElement.prototype,"focus",this):void 0;typeof nativeFocus=="function"&&nativeFocus.call(this,{preventScroll:!0})}this.open&&(this.open=!1,this.forcedMenuClose="state")}if(changed.has("formats")){const active=activeElementIn(this.shadowRoot),index=this.menuItemEls().indexOf(active),previous=changed.get("formats")?.[index];this.formatsFocusSnapshot=index>=0&&previous?{index,id:this.formatId(previous)}:void 0}if(this.open&&this.formats.length<=1){const previousOpen=changed.get("open");this.forcedMenuClose=changed.has("formats")&&changed.get("formats")?.length?"formats":previousOpen===!1||previousOpen===void 0?"invalid-open":"state",this.open=!1}this.announceMenuTransition(changed)}announceMenuTransition(changed){if(this.openVetoed=!1,!changed.has("open")||this._isFirstUpdate||this.forcedMenuClose)return;const name=this.open?"lr-show":"lr-hide";this.emit(name,null,{cancelable:!0}).defaultPrevented&&(this.openVetoed=!0,this.open=!this.open)}updated(changed){super.updated(changed);const forcedMenuClose=this.forcedMenuClose;if(this.forcedMenuClose=void 0,(changed.has("open")||forcedMenuClose==="formats"||forcedMenuClose==="state")&&!this.openVetoed?this.syncMenuOverlay():this.openVetoed&&(this.restoreFocusOnMenuClose=!1),changed.has("formats")&&this.formatsFocusSnapshot){const{index,id}=this.formatsFocusSnapshot;this.formatsFocusSnapshot=void 0,this.scheduleAfterUpdate(()=>{if(this.formats.length<=1)this.closeMenu(),this.triggerEl?.focus();else if(this.open){const nextIndex=this.formats.findIndex(format=>this.formatId(format)===id);this.focusMenuItemOnOpen(nextIndex>=0?nextIndex:index)}})}}effectiveColumns(){if(this.columns.length>0)return this.columns;const keys=new Set;for(const row of this.rows)for(const key of Object.keys(row))keys.add(key);return Array.from(keys,key=>({key,label:key}))}rowsForExport(){const keys=this.effectiveColumns().map(c=>c.key);return this.rows.map(row=>{const picked=Object.create(null);for(const key of keys)picked[key]=row[key];return picked})}formatId(format){return typeof format=="string"?format:format.formatId}formatLabel(format){return typeof format=="string"?format.toUpperCase():format.label}doExport(formatOption){if(this.disabled||this.loading)return;this.closeMenu(),this.triggerEl?.focus();const format=this.formatId(formatOption);if(!this.emit("lr-export",Object.freeze({format}),{cancelable:!0}).defaultPrevented&&!(format!=="csv"&&format!=="json"))try{format==="csv"?downloadBlob(buildCsv(this.rows,this.effectiveColumns()),`${this.filename}.csv`,"text/csv;charset=utf-8;",this.ownerDocument):downloadBlob(JSON.stringify(this.rowsForExport(),null,2),`${this.filename}.json`,"application/json",this.ownerDocument),this.emit("lr-export-complete",Object.freeze({format}))}catch(error){this.emit("lr-export-error",Object.freeze({format,error}))}}onTriggerClick(){this.disabled||this.loading||this.formats.length!==0&&(this.formats.length===1?this.doExport(this.formats[0]):this.open?this.closeMenu():this.openMenu())}focus(options){this.triggerEl?.focus(options)}blur(){this.triggerEl?.blur()}click(){this.triggerEl?.click()}get effectiveLabel(){return this.label==null?this.localize("exportButtonLabel"):this.label}render(){const label=this.effectiveLabel,labelNamesTrigger=label.trim().length>0,accessibleLabel=this.accessibleLabel??(labelNamesTrigger?label:this.localize("exportButtonLabel")),triggerAriaLabel=this.accessibleLabel!==null||!labelNamesTrigger?accessibleLabel:nothing;return html`
|
|
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{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{deferredPlaceReady as place}from"../../../internal/anchored-overlay-runtime.js";import{nextId}from"../../../internal/a11y.js";import{buildCsv,downloadBlob}from"./csv.js";import{styles}from"./export-button.styles.js";import{activeElementIn}from"../../../internal/active-element.js";import{activateNonmodalOverlay}from"../../../internal/nonmodal-overlay-manager.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_exportButtonLabel,LYRA_DEFAULT_exportFormatMenuLabel,LYRA_DEFAULT_statusError}from"../../../internal/default-strings.generated.js";const MAX_EXPORT_FORMATS=1e4;function queueDocumentMicrotask(ownerDocument,callback){const ownerWindow=ownerDocument.defaultView;if(ownerWindow){ownerWindow.queueMicrotask(callback);return}Promise.resolve().then(callback)}function formatArrayLength(value){try{if(!Array.isArray(value))return;const length=getOwnDataDescriptor(value,"length");return length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0?void 0:{source:value,length:Math.min(length.value,MAX_EXPORT_FORMATS)}}catch{return}}function projectExportFormat(value){if(value==="csv"||value==="json")return value;if(value===null||typeof value!="object")return;const formatId=getOwnDataDescriptor(value,"formatId"),label=getOwnDataDescriptor(value,"label");if(formatId===MISSING_OWN_DATA_DESCRIPTOR||formatId===UNSAFE_OWN_DATA_DESCRIPTOR||label===MISSING_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR||typeof formatId.value!="string"||formatId.value.trim().length===0||typeof label.value!="string"||label.value.trim().length===0)return;const description=getOwnDataDescriptor(value,"description"),extension=getOwnDataDescriptor(value,"extension");return Object.freeze({formatId:formatId.value,label:label.value,...description!==MISSING_OWN_DATA_DESCRIPTOR&&description!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof description.value=="string"?{description:description.value}:{},...extension!==MISSING_OWN_DATA_DESCRIPTOR&&extension!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof extension.value=="string"?{extension:extension.value}:{}})}class LyraExportButton extends LyraElement{constructor(){super(...arguments),this._rows=Object.freeze([]),this._columns=Object.freeze([]),this.filename="export",this._formats=Object.freeze(["csv"]),this.disabled=!1,this.loading=!1,this.accessibleLabel=null,this.open=!1,this.exportFailed=!1,this.menuId=nextId("export-menu"),this.menuPositioned=!1,this.connectionGeneration=0,this._isFirstUpdate=!0,this.openVetoed=!1,this.pendingMenuFocusIndex=0,this.injectedHostTabIndex=!1,this.restoreFocusOnMenuClose=!1,this.onDocPointer=e=>{e.composedPath().includes(this)||(this.overlay?.isActive()?this.overlay.dismissBackdrop():this.closeMenu())},this.syncMenuOverlay=()=>{if(this.cleanup?.(),this.cleanup=void 0,this.menuPositioned=!1,this.unbindDocumentPointer(),!this.open||!this.isConnected){const restoreFocus=this.restoreFocusOnMenuClose;this.restoreFocusOnMenuClose=!1,this.deactivateMenuOverlay(restoreFocus);return}this.activateMenuOverlay(),this.bindDocumentPointer();const anchor=this.triggerEl,menu=this.menuEl,ownerDocument=this.ownerDocument;if(!anchor||!menu)return;const placement=place(anchor,menu);this.cleanup=placement,placement.ready.then(positioned=>{if(!(this.cleanup!==placement||!this.open||!this.isConnected||this.ownerDocument!==ownerDocument)){if(!positioned){this.forcedMenuClose="state",this.open=!1;return}this.menuPositioned=!0,this.focusMenuItem(this.pendingMenuFocusIndex),this.pendingMenuFocusIndex=0}})},this.onKeyDown=e=>{if(this.formats.length<=1||this.disabled||this.loading)return;const items=this.menuItemEls(),currentIndex=items.indexOf(e.target);switch(e.key){case"ArrowDown":e.preventDefault(),this.focusMenuItemOnOpen(currentIndex===-1?0:currentIndex+1);break;case"ArrowUp":e.preventDefault(),this.focusMenuItemOnOpen(currentIndex===-1?items.length-1:currentIndex-1);break;case"Home":this.open&&(e.preventDefault(),this.focusMenuItem(0));break;case"End":this.open&&(e.preventDefault(),this.focusMenuItem(items.length-1));break}}}static{this.defaultStrings={...super.defaultStrings,exportButtonLabel:LYRA_DEFAULT_exportButtonLabel,exportFormatMenuLabel:LYRA_DEFAULT_exportFormatMenuLabel,statusError:LYRA_DEFAULT_statusError}}static{this.styles=[LyraElement.styles,styles]}static{this.properties={rows:{attribute:!1,noAccessor:!0},columns:{attribute:!1,noAccessor:!0},formats:{attribute:!1,noAccessor:!0}}}get rows(){return this._rows}set rows(next){const previous=this._rows,source=Array.isArray(next)?next:[];this._rows=Object.freeze(source.map(row=>Object.freeze({...row}))),this.requestUpdate("rows",previous)}get columns(){return this._columns}set columns(next){const previous=this._columns,source=Array.isArray(next)?next:[];this._columns=Object.freeze(source.map(column=>Object.freeze({...column}))),this.requestUpdate("columns",previous)}get formats(){return this._formats}set formats(next){const previous=this._formats,source=formatArrayLength(next),seen=new Set,formats=[];for(let index=0;source&&index<source.length;index+=1){const descriptor=getOwnDataDescriptor(source.source,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const snapshot=projectExportFormat(descriptor.value);if(!snapshot)continue;const id=typeof snapshot=="string"?snapshot:snapshot.formatId;typeof id!="string"||id.trim()===""||seen.has(id)||(seen.add(id),formats.push(snapshot))}this._formats=Object.freeze(formats),this.requestUpdate("formats",previous)}connectedCallback(){const pendingDisconnectDocument=this.pendingDisconnectDocument;if(this.pendingDisconnectDocument=void 0,this.connectionGeneration+=1,this.connectedDocument=this.ownerDocument,super.connectedCallback(),this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),pendingDisconnectDocument){if(pendingDisconnectDocument===this.ownerDocument){this.deactivateMenuOverlay(!1),this.restoreFocusOnMenuClose=!1,this.open=!1;return}this.hasUpdated&&this.open&&this.scheduleAfterUpdate(this.syncMenuOverlay,"export-button-menu-overlay");return}this.hasUpdated&&this.open&&this.scheduleAfterUpdate(this.syncMenuOverlay,"export-button-menu-overlay")}disconnectedCallback(){const generation=++this.connectionGeneration,disconnectDocument=this.connectedDocument??this.ownerDocument;this.pendingDisconnectDocument=disconnectDocument,super.disconnectedCallback(),this.cleanup?.(),this.cleanup=void 0,this.menuPositioned=!1,this.unbindDocumentPointer(),this.overlay?.suspend(),this.restoreFocusOnMenuClose=!1,this.sink?.release(),this.sink=void 0,queueDocumentMicrotask(disconnectDocument,()=>{this.connectionGeneration!==generation||this.isConnected||this.pendingDisconnectDocument!==disconnectDocument||(this.pendingDisconnectDocument=void 0,this.deactivateMenuOverlay(!1),this.restoreFocusOnMenuClose=!1,this.open=!1)})}adoptedCallback(){super.adoptedCallback(),this.cleanup?.(),this.cleanup=void 0,this.unbindDocumentPointer(),this.overlay?.suspend(),this.sink?.release(),this.sink=void 0}bindDocumentPointer(){if(!this.isConnected)return;const owner=this.ownerDocument;this.pointerDocument!==owner&&(this.unbindDocumentPointer(),owner.addEventListener("pointerdown",this.onDocPointer),this.pointerDocument=owner)}unbindDocumentPointer(){this.pointerDocument?.removeEventListener("pointerdown",this.onDocPointer),this.pointerDocument=void 0}openMenu(){this.open||(this.open=!0)}closeMenu(restoreFocus=!1){this.open&&(this.restoreFocusOnMenuClose||=restoreFocus,this.open=!1)}activateMenuOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateNonmodalOverlay({host:this,panel:()=>this.menuEl??null,onEscape:()=>this.closeMenu(!0),onBackdrop:()=>this.closeMenu(),onTab:()=>this.closeMenu(),restoreFocusTo:()=>this.triggerEl??null})}deactivateMenuOverlay(restoreFocus){const overlay=this.overlay;this.overlay=void 0,overlay?.deactivate({restoreFocus}),this.unbindDocumentPointer()}menuItemEls(){return Array.from(this.renderRoot.querySelectorAll('[part="menu-item"]'))}focusMenuItem(index){const items=this.menuItemEls();items.length!==0&&items[Math.max(0,Math.min(items.length-1,index))]?.focus()}focusMenuItemOnOpen(index){this.open&&this.menuPositioned?this.focusMenuItem(index):(this.pendingMenuFocusIndex=index,this.open||this.openMenu())}firstUpdated(changed){super.firstUpdated(changed),this.renderRoot.addEventListener("keydown",this.onKeyDown)}willUpdate(changed){if(super.willUpdate(changed),this._isFirstUpdate=!this.hasUpdated,this.setAttribute("aria-busy",String(this.loading)),(changed.has("disabled")||changed.has("loading"))&&!this.disabled&&!this.loading&&this.injectedHostTabIndex&&(this.getAttribute("tabindex")==="-1"&&this.removeAttribute("tabindex"),this.injectedHostTabIndex=!1),(changed.has("disabled")||changed.has("loading"))&&(this.disabled||this.loading)){const active=activeElementIn(this.shadowRoot);if(active===this.triggerEl||active?.getAttribute("part")==="menu-item"){this.hasAttribute("tabindex")||(this.tabIndex=-1,this.injectedHostTabIndex=!0);const ownerHTMLElement=this.ownerDocument.defaultView?.HTMLElement,nativeFocus=ownerHTMLElement?Reflect.get(ownerHTMLElement.prototype,"focus",this):void 0;typeof nativeFocus=="function"&&nativeFocus.call(this,{preventScroll:!0})}this.open&&(this.open=!1,this.forcedMenuClose="state")}if(changed.has("formats")){const active=activeElementIn(this.shadowRoot),index=this.menuItemEls().indexOf(active),previous=changed.get("formats")?.[index];this.formatsFocusSnapshot=index>=0&&previous?{index,id:this.formatId(previous)}:void 0}if(this.open&&this.formats.length<=1){const previousOpen=changed.get("open");this.forcedMenuClose=changed.has("formats")&&changed.get("formats")?.length?"formats":previousOpen===!1||previousOpen===void 0?"invalid-open":"state",this.open=!1}this.announceMenuTransition(changed)}announceMenuTransition(changed){if(this.openVetoed=!1,!changed.has("open")||this._isFirstUpdate||this.forcedMenuClose)return;const name=this.open?"lr-show":"lr-hide";this.emit(name,null,{cancelable:!0}).defaultPrevented&&(this.openVetoed=!0,this.open=!this.open)}updated(changed){super.updated(changed);const forcedMenuClose=this.forcedMenuClose;if(this.forcedMenuClose=void 0,(changed.has("open")||forcedMenuClose==="formats"||forcedMenuClose==="state")&&!this.openVetoed?this.syncMenuOverlay():this.openVetoed&&(this.restoreFocusOnMenuClose=!1),changed.has("formats")&&this.formatsFocusSnapshot){const{index,id}=this.formatsFocusSnapshot;this.formatsFocusSnapshot=void 0,this.scheduleAfterUpdate(()=>{if(this.formats.length<=1)this.closeMenu(),this.triggerEl?.focus();else if(this.open){const nextIndex=this.formats.findIndex(format=>this.formatId(format)===id);this.focusMenuItemOnOpen(nextIndex>=0?nextIndex:index)}})}}effectiveColumns(){if(this.columns.length>0)return this.columns;const keys=new Set;for(const row of this.rows)for(const key of Object.keys(row))keys.add(key);return Array.from(keys,key=>({key,label:key}))}rowsForExport(){const keys=this.effectiveColumns().map(c=>c.key);return this.rows.map(row=>{const picked=Object.create(null);for(const key of keys)picked[key]=row[key];return picked})}formatId(format){return typeof format=="string"?format:format.formatId}formatLabel(format){return typeof format=="string"?format.toUpperCase():format.label}doExport(formatOption){if(this.disabled||this.loading)return;this.closeMenu(),this.triggerEl?.focus(),this.exportFailed=!1;const format=this.formatId(formatOption);if(!this.emit("lr-export",Object.freeze({format}),{cancelable:!0}).defaultPrevented&&!(format!=="csv"&&format!=="json"))try{format==="csv"?downloadBlob(buildCsv(this.rows,this.effectiveColumns()),`${this.filename}.csv`,"text/csv;charset=utf-8;",this.ownerDocument):downloadBlob(JSON.stringify(this.rowsForExport(),null,2),`${this.filename}.json`,"application/json",this.ownerDocument),this.emit("lr-export-complete",Object.freeze({format}))}catch(error){this.exportFailed=!0,this.sink?.announce(this.localize("statusError")),this.emit("lr-export-error",Object.freeze({format,error}))}}onTriggerClick(){this.disabled||this.loading||this.formats.length!==0&&(this.formats.length===1?this.doExport(this.formats[0]):this.open?this.closeMenu():this.openMenu())}focus(options){this.triggerEl?.focus(options)}blur(){this.triggerEl?.blur()}click(){this.triggerEl?.click()}get effectiveLabel(){return this.label==null?this.localize("exportButtonLabel"):this.label}render(){const label=this.effectiveLabel,labelNamesTrigger=label.trim().length>0,accessibleLabel=this.accessibleLabel??(labelNamesTrigger?label:this.localize("exportButtonLabel")),triggerAriaLabel=this.accessibleLabel!==null||!labelNamesTrigger?accessibleLabel:nothing;return html`
|
|
2
2
|
<button
|
|
3
|
-
part
|
|
3
|
+
part=${this.exportFailed?"trigger trigger-error":"trigger"}
|
|
4
4
|
type="button"
|
|
5
5
|
?disabled=${this.disabled||this.loading||this.formats.length===0}
|
|
6
6
|
aria-label=${triggerAriaLabel}
|
|
@@ -29,4 +29,4 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
29
29
|
${typeof f!="string"&&f.description?html`<span part="format-description">${f.description}</span>`:nothing}
|
|
30
30
|
</button>`)}
|
|
31
31
|
</div>`:nothing}
|
|
32
|
-
`}}__decorate([property()],LyraExportButton.prototype,"filename",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraExportButton.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraExportButton.prototype,"loading",void 0),__decorate([property()],LyraExportButton.prototype,"label",void 0),__decorate([property({attribute:"aria-label"})],LyraExportButton.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraExportButton.prototype,"open",void 0),__decorate([query('[part
|
|
32
|
+
`}}__decorate([property()],LyraExportButton.prototype,"filename",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraExportButton.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraExportButton.prototype,"loading",void 0),__decorate([property()],LyraExportButton.prototype,"label",void 0),__decorate([property({attribute:"aria-label"})],LyraExportButton.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraExportButton.prototype,"open",void 0),__decorate([query('[part~="trigger"]')],LyraExportButton.prototype,"triggerEl",void 0),__decorate([query('[part="menu"]')],LyraExportButton.prototype,"menuEl",void 0),__decorate([state()],LyraExportButton.prototype,"exportFailed",void 0);export{LyraExportButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";const styles=css`:host{display:inline-block;position:relative}[part
|
|
1
|
+
import{css}from"lit";const styles=css`:host{display:inline-block;position:relative}[part~=trigger]{justify-content:center;align-items:center;gap:var(--lr-space-xs);padding:var(--lr-space-xs) var(--lr-space-m);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);background:var(--lr-color-surface);color:var(--lr-color-text);font:inherit;min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);cursor:pointer;display:inline-flex}:where([part~=trigger]):hover:where(:not(:disabled)){border-color:var(--lr-color-brand)}:where([part~=trigger]):active:where(:not(:disabled)){border-color:var(--lr-color-brand);background:color-mix(in oklab, var(--lr-color-surface), var(--lr-color-mix-partner) var(--lr-color-mix-active))}[part~=trigger]:disabled{opacity:var(--lr-opacity-disabled);cursor:not-allowed}[part~=trigger]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}[part~=trigger-error]{border-color:var(--lr-color-danger);color:var(--lr-color-danger)}[part=menu]{visibility:hidden;z-index:var(--lr-layer-dropdown);box-sizing:border-box;inline-size:max-content;min-inline-size:min(var(--lr-popover-viewport-clamp), var(--lr-size-8rem), var(--lr-positioner-available-inline-size,100vw));max-inline-size:min(var(--lr-popover-viewport-clamp), var(--lr-size-20rem), var(--lr-positioner-available-inline-size,100vw));max-block-size:var(--lr-positioner-available-block-size,100vh);padding:var(--lr-space-xs);background:var(--lr-color-surface);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);box-shadow:var(--lr-shadow-m);opacity:0;transform:translateY(var(--lr-size-neg-4px));transition:opacity var(--lr-transition-fast), transform var(--lr-transition-fast);position:fixed;overflow:auto}:host([open]) [part=menu]{visibility:visible;opacity:1;transform:none}@media (prefers-reduced-motion:reduce){[part=menu]{transition:none}}[part=menu-item]{justify-content:center;align-items:center;gap:var(--lr-size-1px);box-sizing:border-box;inline-size:100%;min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);text-align:center;padding:var(--lr-space-xs) var(--lr-space-s);color:inherit;font:inherit;cursor:pointer;border-radius:var(--lr-radius);background:0 0;border:none;flex-direction:column;display:flex}:where([part=menu-item]):hover:where(:not(:disabled)){background:var(--lr-color-brand-quiet)}:where([part=menu-item]):active:where(:not(:disabled)){background:color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active))}[part=menu-item]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}[part=menu-item]:disabled{opacity:var(--lr-opacity-disabled);cursor:not-allowed}[part=format-description]{color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-sm)}[part=format-label],[part=format-description]{overflow-wrap:anywhere;max-inline-size:100%}`;export{styles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";const styles=css`:host{--_lr-json-viewer-max-height:none;--_lr-json-viewer-font:var(--lr-font-mono);--_lr-json-viewer-active-outline:var(--lr-focus-ring-color);--_lr-json-viewer-string-color:var(--lr-color-success);--_lr-json-viewer-number-color:var(--lr-color-brand);--_lr-json-viewer-boolean-color:var(--lr-color-warning);--_lr-json-viewer-null-color:var(--lr-color-text-quiet);font-family:var(--lr-json-viewer-font,var(--_lr-json-viewer-font));font-size:var(--lr-font-size-sm);line-height:var(--lr-line-height-loose);display:block}[part=base]{max-block-size:var(--lr-json-viewer-max-height,var(--_lr-json-viewer-max-height));border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);background:var(--lr-color-surface);display:block;overflow:auto}[part=toolbar]{z-index:var(--lr-layer-content);padding:var(--lr-space-xs) var(--lr-space-s);border-block-end:var(--lr-border-width-thin) solid var(--lr-color-border);background:var(--lr-color-surface);justify-content:flex-end;display:flex;position:sticky;inset-block-start:0}[part=tree]{padding:var(--lr-space-s);direction:ltr}.row{align-items:flex-start;gap:var(--lr-space-xs);border-radius:var(--lr-radius);min-inline-size:0;display:flex}.row:hover{background:var(--lr-json-viewer-row-hover-bg,var(--lr-color-brand-quiet))}.row:hover [part=copy-button],.row:focus-within [part=copy-button]{opacity:1}[part=toggle]{inline-size:var(--lr-size-1-25rem);block-size:var(--lr-size-1-25rem);min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);color:var(--lr-color-text-quiet);border-radius:var(--lr-radius);cursor:pointer;background:0 0;border:none;flex:none;justify-content:center;align-items:center;margin-block-start:var(--lr-size-0-1875rem);padding:0;display:inline-flex}[part=toggle][hidden]{visibility:hidden}[part=toggle] .chevron{transition:transform var(--lr-transition-fast);display:inline-flex;transform:rotate(0)}[part=toggle][aria-expanded=true] .chevron{transform:rotate(90deg)}:where([part=toggle]):hover:where(:not([hidden])){background:var(--lr-color-brand-quiet);color:var(--lr-color-brand)}:where([part=toggle]):active:where(:not([hidden])){background:color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active));color:var(--lr-color-brand)}[part=toggle]:focus-visible,[part=copy-button]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}.toggle-space{inline-size:var(--lr-icon-button-size);flex:none}[part=key]{overflow-wrap:anywhere;min-inline-size:0;font-weight:var(--lr-font-weight-semibold);color:var(--lr-color-text);flex:0 auto}.colon{color:var(--lr-color-text-quiet);flex:none;margin-inline-end:var(--lr-space-xs)}[part=bracket]{color:var(--lr-color-text-quiet);flex:none}[part=key][data-match],[part=value][data-match]{background:var(--lr-json-viewer-match-bg,var(--lr-color-warning-quiet));border-radius:var(--lr-size-0-1875rem);box-shadow:0 0 0 var(--lr-size-0-125rem) var(--lr-json-viewer-match-bg,var(--lr-color-warning-quiet))}[part=value]{overflow-wrap:anywhere;word-break:break-word;white-space:pre-wrap;min-inline-size:0}[part=value][data-type=string]{color:var(--lr-json-viewer-string-color,var(--_lr-json-viewer-string-color))}[part=value][data-type=number]{color:var(--lr-json-viewer-number-color,var(--_lr-json-viewer-number-color))}[part=value][data-type=boolean]{color:var(--lr-json-viewer-boolean-color,var(--_lr-json-viewer-boolean-color))}[part=value][data-type=null],[part=value][data-type=undefined],[part=value][data-type=circular]{color:var(--lr-json-viewer-null-color,var(--_lr-json-viewer-null-color));font-style:italic}[part=key][data-active],[part=value][data-active]{outline:var(--lr-focus-ring-width) solid var(--lr-json-viewer-active-outline,var(--_lr-json-viewer-active-outline));outline-offset:var(--lr-focus-ring-offset)}.preview{color:var(--lr-color-text-quiet);margin-inline:var(--lr-space-xs);flex:none;font-style:italic}[part=copy-button]{color:var(--lr-color-text-quiet);font:inherit;font-size:var(--lr-font-size-xs);line-height:var(--lr-line-height-none);min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);padding:var(--lr-size-0-125rem) var(--lr-space-xs);border-radius:var(--lr-radius);cursor:pointer;background:0 0;border:none;flex:none;margin-inline-start:auto}[part=copy-button]:hover{background:var(--lr-color-brand-quiet);color:var(--lr-color-brand)}[part=copy-button]:active{background:color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active));color:var(--lr-color-brand)}.row [part=copy-button]{opacity:0}.row [part=copy-button]:focus-visible{opacity:1}@media (hover:none),(pointer:coarse){.row [part=copy-button]{opacity:1}}@media (prefers-reduced-motion:reduce){[part=toggle] .chevron{transition:none!important}}`;export{styles};
|
|
1
|
+
import{css}from"lit";const styles=css`:host{--_lr-json-viewer-max-height:none;--_lr-json-viewer-font:var(--lr-font-mono);--_lr-json-viewer-active-outline:var(--lr-focus-ring-color);--_lr-json-viewer-string-color:var(--lr-color-success);--_lr-json-viewer-number-color:var(--lr-color-brand);--_lr-json-viewer-boolean-color:var(--lr-color-warning);--_lr-json-viewer-null-color:var(--lr-color-text-quiet);font-family:var(--lr-json-viewer-font,var(--_lr-json-viewer-font));font-size:var(--lr-font-size-sm);line-height:var(--lr-line-height-loose);display:block}[part=base]{max-block-size:var(--lr-json-viewer-max-height,var(--_lr-json-viewer-max-height));border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);background:var(--lr-color-surface);display:block;overflow:auto}[part=toolbar]{z-index:var(--lr-layer-content);padding:var(--lr-space-xs) var(--lr-space-s);border-block-end:var(--lr-border-width-thin) solid var(--lr-color-border);background:var(--lr-color-surface);justify-content:flex-end;display:flex;position:sticky;inset-block-start:0}[part=tree]{padding:var(--lr-space-s);direction:ltr}.row{align-items:flex-start;gap:var(--lr-space-xs);border-radius:var(--lr-radius);min-inline-size:0;display:flex}.row:hover{background:var(--lr-json-viewer-row-hover-bg,var(--lr-color-brand-quiet))}.row:hover [part=copy-button],.row:focus-within [part=copy-button]{opacity:1}[part=toggle]{inline-size:var(--lr-size-1-25rem);block-size:var(--lr-size-1-25rem);min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);color:var(--lr-color-text-quiet);border-radius:var(--lr-radius);cursor:pointer;font:inherit;background:0 0;border:none;flex:none;justify-content:center;align-items:center;margin-block-start:var(--lr-size-0-1875rem);padding:0;display:inline-flex}[part=toggle][hidden]{visibility:hidden}[part=toggle] .chevron{transition:transform var(--lr-transition-fast);display:inline-flex;transform:rotate(0)}[part=toggle][aria-expanded=true] .chevron{transform:rotate(90deg)}:where([part=toggle]):hover:where(:not([hidden])){background:var(--lr-color-brand-quiet);color:var(--lr-color-brand)}:where([part=toggle]):active:where(:not([hidden])){background:color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active));color:var(--lr-color-brand)}[part=toggle]:focus-visible,[part=copy-button]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}.toggle-space{inline-size:var(--lr-icon-button-size);flex:none}[part=key]{overflow-wrap:anywhere;min-inline-size:0;font-weight:var(--lr-font-weight-semibold);color:var(--lr-color-text);flex:0 auto}.colon{color:var(--lr-color-text-quiet);flex:none;margin-inline-end:var(--lr-space-xs)}[part=bracket]{color:var(--lr-color-text-quiet);flex:none}[part=key][data-match],[part=value][data-match]{background:var(--lr-json-viewer-match-bg,var(--lr-color-warning-quiet));border-radius:var(--lr-size-0-1875rem);box-shadow:0 0 0 var(--lr-size-0-125rem) var(--lr-json-viewer-match-bg,var(--lr-color-warning-quiet))}[part=value]{overflow-wrap:anywhere;word-break:break-word;white-space:pre-wrap;min-inline-size:0}[part=value][data-type=string]{color:var(--lr-json-viewer-string-color,var(--_lr-json-viewer-string-color))}[part=value][data-type=number]{color:var(--lr-json-viewer-number-color,var(--_lr-json-viewer-number-color))}[part=value][data-type=boolean]{color:var(--lr-json-viewer-boolean-color,var(--_lr-json-viewer-boolean-color))}[part=value][data-type=null],[part=value][data-type=undefined],[part=value][data-type=circular]{color:var(--lr-json-viewer-null-color,var(--_lr-json-viewer-null-color));font-style:italic}[part=key][data-active],[part=value][data-active]{outline:var(--lr-focus-ring-width) solid var(--lr-json-viewer-active-outline,var(--_lr-json-viewer-active-outline));outline-offset:var(--lr-focus-ring-offset)}.preview{color:var(--lr-color-text-quiet);margin-inline:var(--lr-space-xs);flex:none;font-style:italic}[part=copy-button]{color:var(--lr-color-text-quiet);font:inherit;font-size:var(--lr-font-size-xs);line-height:var(--lr-line-height-none);min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);padding:var(--lr-size-0-125rem) var(--lr-space-xs);border-radius:var(--lr-radius);cursor:pointer;background:0 0;border:none;flex:none;margin-inline-start:auto}[part=copy-button]:hover{background:var(--lr-color-brand-quiet);color:var(--lr-color-brand)}[part=copy-button]:active{background:color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active));color:var(--lr-color-brand)}.row [part=copy-button]{opacity:0}.row [part=copy-button]:focus-visible{opacity:1}@media (hover:none),(pointer:coarse){.row [part=copy-button]{opacity:1}}@media (prefers-reduced-motion:reduce){[part=toggle] .chevron{transition:none!important}}`;export{styles};
|