@aceshooting/lyra-ui 14.3.1 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +127 -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/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/tab-group/tab-group.class.js +1 -1
- 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/badge/tag.class.js +1 -1
- package/dist/components/overlays/chip/chip.class.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/accessibility-visibility.d.ts +13 -2
- package/dist/internal/accessibility-visibility.js +1 -1
- 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 +31 -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 +31 -0
- package/llms/components/lr-menu.md +31 -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-full.txt +212 -59
- package/package.json +3 -3
- package/vscode-css-data.json +1 -1
- package/vscode-html-data.json +1 -1
- package/web-types.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";const styles=css`:host{display:block}[part=base]{border:var(--lr-
|
|
1
|
+
import{css}from"lit";const styles=css`:host{display:block}[part=base]{border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);background:var(--lr-terminal-surface-color,var(--lr-color-surface-raised));flex-direction:column;display:flex;overflow:hidden}:host([frame=plain]) [part=base]{background:0 0;border:0;border-radius:0}[part=toolbar]{justify-content:flex-end;gap:var(--lr-space-xs);padding:var(--lr-space-xs) var(--lr-space-s);border-block-end:var(--lr-border-width-thin) solid var(--lr-color-border);display:flex}:host([compact]) [part=toolbar]{gap:var(--lr-terminal-compact-toolbar-gap,var(--lr-space-2xs));padding:var(--lr-terminal-compact-toolbar-padding,var(--lr-space-2xs) var(--lr-space-xs))}[part=copy-button],[part=download-button]{font:inherit;font-size:var(--lr-font-size-xs);color:var(--lr-color-text-quiet);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius-xs);padding:var(--lr-space-2xs) var(--lr-space-xs);cursor:pointer;background:0 0}[part=copy-button]:hover,[part=download-button]:hover{background:var(--lr-terminal-toolbar-button-hover-bg,var(--lr-color-brand-quiet))}[part=copy-button]:active,[part=download-button]:active{background:var(--lr-terminal-toolbar-button-active-bg,color-mix(in oklab, var(--lr-terminal-toolbar-button-hover-bg,var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active)))}[part=copy-button]:focus-visible,[part=download-button]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}[part=viewport]{block-size:var(--lr-terminal-height,var(--lr-size-20rem));position:relative}lr-virtual-list{block-size:100%;font-family:var(--lr-font-mono);font-size:var(--lr-font-size-sm);color:var(--lr-color-text);display:block}lr-virtual-list::part(line){white-space:pre-wrap;overflow-wrap:anywhere;padding-inline:var(--lr-space-s);line-height:var(--lr-line-height-normal)}lr-virtual-list::part(line):hover{background:var(--lr-terminal-line-hover-bg,var(--lr-color-brand-quiet))}lr-virtual-list::part(line):active{background:var(--lr-terminal-line-active-bg,color-mix(in oklab, var(--lr-terminal-line-hover-bg,var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active)))}lr-virtual-list::part(line-highlight-accent):hover,lr-virtual-list::part(line-highlight-accent):active{background:var(--lr-terminal-highlight-accent-bg,var(--lr-color-brand-quiet))}lr-virtual-list::part(line-highlight-success):hover,lr-virtual-list::part(line-highlight-success):active{background:var(--lr-terminal-highlight-success-bg,var(--lr-color-success-quiet))}lr-virtual-list::part(line-highlight-warning):hover,lr-virtual-list::part(line-highlight-warning):active{background:var(--lr-terminal-highlight-warning-bg,var(--lr-color-warning-quiet))}lr-virtual-list::part(line-highlight-danger):hover,lr-virtual-list::part(line-highlight-danger):active{background:var(--lr-terminal-highlight-danger-bg,var(--lr-color-danger-quiet))}lr-virtual-list::part(line-highlight-neutral):hover,lr-virtual-list::part(line-highlight-neutral):active{background:var(--lr-terminal-highlight-neutral-bg,var(--lr-color-surface))}lr-virtual-list::part(line):focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}:host([compact]) lr-virtual-list::part(line){padding-inline:var(--lr-terminal-compact-line-padding-inline,var(--lr-space-xs))}:host(:not([wrap])) lr-virtual-list::part(line){white-space:pre;overflow-wrap:normal;box-sizing:border-box;inline-size:max-content;min-inline-size:100%}:host(:not([wrap])) lr-virtual-list::part(base){overflow-x:auto}[part=jump-to-latest]{font:inherit;font-size:var(--lr-font-size-xs);color:var(--lr-color-surface);background:var(--lr-color-brand);border-radius:var(--lr-radius-pill);padding:var(--lr-space-2xs) var(--lr-space-s);box-shadow:var(--lr-shadow-m);cursor:pointer;z-index:var(--lr-layer-content);transition:opacity var(--lr-transition-fast);border:none;position:absolute;inset-block-end:var(--lr-space-s);inset-inline-end:var(--lr-space-s)}[part=jump-to-latest]:hover{background:color-mix(in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-hover))}[part=jump-to-latest]:active{background:color-mix(in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active))}[part=jump-to-latest]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}@media (prefers-reduced-motion:reduce){[part=jump-to-latest]{transition:none!important}}`;export{styles};
|
|
@@ -52,7 +52,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
52
52
|
`}renderSuite(suite,suiteIndex){const visibleTests=suite.tests.map((test,testIndex)=>({test,testIndex})).filter(({test})=>this.statusFilter.length===0||this.statusFilter.includes(test.status));return visibleTests.length===0?nothing:html`
|
|
53
53
|
<div part="suite">
|
|
54
54
|
<div part="suite-header">${suite.name}</div>
|
|
55
|
-
<div role="list" aria-label=${suite.name}
|
|
55
|
+
<div role="list" aria-label=${suite.name||nothing}
|
|
56
56
|
>${visibleTests.map(({test,testIndex})=>this.renderTest(suite.id,suite.name,test,suiteIndex,testIndex))}</div
|
|
57
57
|
>
|
|
58
58
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement,type LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import'../../forms/select/select.class.js';import'../../forms/combobox/option.class.js';import{type FormOwnerValue}from'../../../internal/form-associated.js';
|
|
1
|
+
import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement,type LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import'../../forms/select/select.class.js';import'../../forms/combobox/option.class.js';import'../../forms/input/number-input.class.js';import{type FormOwnerValue}from'../../../internal/form-associated.js';
|
|
2
2
|
/** The four leaf property types this flat-schema renderer understands. */
|
|
3
3
|
export type ToolParamFormPropertyType='string'|'number'|'integer'|'boolean';export type ToolParamFormPrimitive=string|number|boolean;
|
|
4
4
|
/**
|
|
@@ -103,17 +103,20 @@ export interface FlatToolParamSchema{readonly type:'object';readonly properties:
|
|
|
103
103
|
* the field that changed.
|
|
104
104
|
* @event lr-validity-change - Effective native validity or errors changed. The frozen
|
|
105
105
|
* `detail: { valid, errors }` includes custom errors and own/fieldset validation barring.
|
|
106
|
-
* @event focus - Re-dispatched when a generated native text
|
|
107
|
-
* controls (`<lr-select>`) already expose their own bubbling,
|
|
108
|
-
*
|
|
106
|
+
* @event focus - Re-dispatched when a generated native `'string'` text input receives focus.
|
|
107
|
+
* Composed controls (`<lr-select>`, `<lr-number-input>`) already expose their own bubbling,
|
|
108
|
+
* composed bridge.
|
|
109
|
+
* @event blur - Re-dispatched when a generated native `'string'` text input loses focus.
|
|
109
110
|
* @event lr-invalid - The complete parameter form failed a validity check. Cancelable;
|
|
110
111
|
* preventing it also prevents the native `invalid` event's default validation UI.
|
|
111
112
|
* @csspart base - The outer wrapper around all fields.
|
|
112
113
|
* @csspart field - One property's wrapper (label + control + description + error).
|
|
113
114
|
* @csspart label - A field's label.
|
|
114
|
-
* @csspart control - The native `<input>` for a `'string'` (non-enum) or
|
|
115
|
-
*
|
|
116
|
-
*
|
|
115
|
+
* @csspart control - The native `<input>` for a `'string'` (non-enum) field, or the composed
|
|
116
|
+
* `<lr-number-input>` for a `'number'`/`'integer'` field (its own increment/decrement steppers
|
|
117
|
+
* replace the field type's native spin buttons — see `<lr-number-input>`'s own docs for its
|
|
118
|
+
* further-forwarded parts). Not present on the `'boolean'`/enum (`<lr-select>`) or
|
|
119
|
+
* unsupported-type fallback branches.
|
|
117
120
|
* @csspart description - A field's helper text, from `schema.description`.
|
|
118
121
|
* @csspart error - A field-level or form-level validation message.
|
|
119
122
|
* @csspart unsupported - The fallback note rendered in place of a control for
|
|
@@ -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{state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";installFormControlLabelSupport();import{nextId}from"../../../internal/a11y.js";import{AnchoredValidityController,resolveValidityAnchor,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{styles}from"./tool-param-form.styles.js";import"../../forms/select/select.class.js";import"../../forms/combobox/option.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{attachInternalsSafely,getFormOwner,installCustomErrorProperty,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_fieldMustBeBoolean,LYRA_DEFAULT_fieldMustBeInteger,LYRA_DEFAULT_fieldMustBeNumber,LYRA_DEFAULT_fieldMustBeOneOf,LYRA_DEFAULT_fieldMustBeString,LYRA_DEFAULT_fieldMustEqual,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_noData,LYRA_DEFAULT_schemaMustBeObject,LYRA_DEFAULT_schemaPropertiesMustBeFlat,LYRA_DEFAULT_toolParamBooleanFalse,LYRA_DEFAULT_toolParamBooleanTrue,LYRA_DEFAULT_toolParamBooleanUnset,LYRA_DEFAULT_toolParamMissingProperty,LYRA_DEFAULT_toolParamSchemaLimit,LYRA_DEFAULT_unsupportedFieldType,LYRA_DEFAULT_valueMustBeSerializable}from"../../../internal/default-strings.generated.js";const MAX_SCHEMA_FIELDS=100,MAX_ENUM_OPTIONS=500,MAX_VALUE_ENTRIES=1e4,MAX_VALUE_NODES=5e4,MAX_VALUE_INSPECTIONS=MAX_VALUE_NODES*2,MAX_VALUE_DEPTH=16,OMIT_VALUE=Symbol("omit-tool-param-value"),LIMIT_VALUE=Symbol("limit-tool-param-value"),FUNCTION_TO_STRING=Function.prototype.toString,OBJECT_CONSTRUCTOR_SOURCE=FUNCTION_TO_STRING.call(Object);function isPlainRecord(value){try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructorDescriptor=Object.getOwnPropertyDescriptor(prototype,"constructor");if(!constructorDescriptor||!("value"in constructorDescriptor)||typeof constructorDescriptor.value!="function")return!1;const constructor=constructorDescriptor.value,constructorPrototype=Object.getOwnPropertyDescriptor(constructor,"prototype");return!!(constructorPrototype&&"value"in constructorPrototype&&constructorPrototype.value===prototype&&FUNCTION_TO_STRING.call(constructor)===OBJECT_CONSTRUCTOR_SOURCE)}catch{return!1}}function checkpointSnapshot(budget){return{remaining:budget.remaining,seenEntries:budget.seenEntries.length,truncated:budget.truncated}}function restoreSnapshotCheckpoint(budget,checkpoint){for(budget.remaining=checkpoint.remaining,budget.truncated=checkpoint.truncated;budget.seenEntries.length>checkpoint.seenEntries;){const source=budget.seenEntries.pop();source&&budget.seen.delete(source)}}function rememberSnapshot(budget,source,output){budget.seen.set(source,output),budget.seenEntries.push(source)}function omitInvalidValue(budget,checkpoint){return restoreSnapshotCheckpoint(budget,checkpoint),budget.invalid=!0,OMIT_VALUE}function snapshotValueEntry(value,budget,depth){if(value===null||typeof value!="object"&&typeof value!="function")return value;const checkpoint=checkpointSnapshot(budget);if(typeof value=="function")return omitInvalidValue(budget,checkpoint);if(depth>MAX_VALUE_DEPTH||budget.remaining<=0)return budget.truncated=!0,LIMIT_VALUE;const existing=budget.seen.get(value);if(existing!==void 0)return existing;let isArray=!1;try{isArray=Array.isArray(value)}catch{return omitInvalidValue(budget,checkpoint)}if(isArray){if(budget.remainingInspections<=0)return budget.truncated=!0,LIMIT_VALUE;budget.remainingInspections-=1;const output2=[];rememberSnapshot(budget,value,output2);let sourceLength=0;try{const descriptor=Object.getOwnPropertyDescriptor(value,"length");if(descriptor&&"value"in descriptor&&typeof descriptor.value=="number"&&Number.isSafeInteger(descriptor.value)&&descriptor.value>=0)sourceLength=descriptor.value;else return omitInvalidValue(budget,checkpoint)}catch{return omitInvalidValue(budget,checkpoint)}sourceLength>MAX_VALUE_ENTRIES&&(budget.truncated=!0);const length=Math.min(sourceLength,MAX_VALUE_ENTRIES);let outputLength=length;for(let index=0;index<length;index+=1){if(budget.remaining<=0||budget.remainingInspections<=0){budget.truncated=!0,outputLength=index;break}budget.remainingInspections-=1;let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{budget.invalid=!0;continue}if(!descriptor)continue;if(!("value"in descriptor)){budget.invalid=!0;continue}const entryCheckpoint=checkpointSnapshot(budget);budget.remaining-=1;const entry=snapshotValueEntry(descriptor.value,budget,depth+1);if(entry===OMIT_VALUE){restoreSnapshotCheckpoint(budget,entryCheckpoint);continue}if(entry===LIMIT_VALUE){outputLength=index;break}Object.defineProperty(output2,String(index),{value:entry,enumerable:!0,configurable:!1,writable:!1})}return output2.length=outputLength,Object.freeze(output2)}if(!isPlainRecord(value))return omitInvalidValue(budget,checkpoint);const output={};rememberSnapshot(budget,value,output);let retained=0;try{for(const key in value){if(retained>=MAX_VALUE_ENTRIES||budget.remaining<=0||budget.remainingInspections<=0){budget.truncated=!0;break}budget.remainingInspections-=1;const descriptor=Object.getOwnPropertyDescriptor(value,key);if(!descriptor||!descriptor.enumerable)continue;if(!("value"in descriptor)){budget.invalid=!0;continue}const entryCheckpoint=checkpointSnapshot(budget);budget.remaining-=1;const entry=snapshotValueEntry(descriptor.value,budget,depth+1);if(entry===OMIT_VALUE){restoreSnapshotCheckpoint(budget,entryCheckpoint);continue}if(entry===LIMIT_VALUE)break;retained+=1,Object.defineProperty(output,key,{value:entry,enumerable:!0,configurable:!1,writable:!1})}}catch{return omitInvalidValue(budget,checkpoint)}return Object.freeze(output)}function snapshotFormValue(value){if(value==null)return{value:Object.freeze({}),invalid:!1,truncated:!1};let isArray=!1;try{isArray=Array.isArray(value)}catch{return{value:Object.freeze({}),invalid:!0,truncated:!1}}if(typeof value!="object"||isArray||!isPlainRecord(value))return{value:Object.freeze({}),invalid:!0,truncated:!1};const budget={remaining:MAX_VALUE_NODES,remainingInspections:MAX_VALUE_INSPECTIONS,seen:new WeakMap,seenEntries:[],invalid:!1,truncated:!1},snapshot=snapshotValueEntry(value,budget,0);return{value:snapshot===OMIT_VALUE||snapshot===LIMIT_VALUE?Object.freeze({}):snapshot,invalid:budget.invalid||snapshot===OMIT_VALUE,truncated:budget.truncated||snapshot===LIMIT_VALUE}}const EMPTY_SCHEMA=Object.freeze({type:"object",properties:Object.freeze({})});function snapshotSchemaStringArray(value){let isArray=!1;try{isArray=Array.isArray(value)}catch{return{isArray:!1,exceededLimit:!1}}if(!isArray)return{isArray:!1,exceededLimit:!1};let sourceLength=0;try{const descriptor=Object.getOwnPropertyDescriptor(value,"length");descriptor&&"value"in descriptor&&typeof descriptor.value=="number"&&Number.isSafeInteger(descriptor.value)&&descriptor.value>=0&&(sourceLength=descriptor.value)}catch{return{isArray:!0,value:Object.freeze([]),exceededLimit:!1}}const output=[];for(let index=0;index<Math.min(sourceLength,MAX_SCHEMA_FIELDS);index+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{continue}descriptor&&"value"in descriptor&&typeof descriptor.value=="string"&&output.push(descriptor.value)}return{isArray:!0,value:Object.freeze(output),exceededLimit:sourceLength>MAX_SCHEMA_FIELDS}}function snapshotSchemaEnum(value){let isArray=!1;try{isArray=Array.isArray(value)}catch{return{malformed:!0,exceededLimit:!1}}if(!isArray)return{malformed:!0,exceededLimit:!1};let sourceLength=0;try{const descriptor=Object.getOwnPropertyDescriptor(value,"length");if(!descriptor||!("value"in descriptor)||typeof descriptor.value!="number"||!Number.isSafeInteger(descriptor.value)||descriptor.value<0)return{malformed:!0,exceededLimit:!1};sourceLength=descriptor.value}catch{return{malformed:!0,exceededLimit:!1}}const output=[];for(let index=0;index<Math.min(sourceLength,MAX_ENUM_OPTIONS);index+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{return{malformed:!0,exceededLimit:sourceLength>MAX_ENUM_OPTIONS}}if(descriptor){if(!("value"in descriptor)||typeof descriptor.value!="string")return{malformed:!0,exceededLimit:sourceLength>MAX_ENUM_OPTIONS};output.push(descriptor.value)}}return{value:Object.freeze(output),malformed:!1,exceededLimit:sourceLength>MAX_ENUM_OPTIONS}}function snapshotSchemaProperty(value){let descriptors;try{descriptors=Object.getOwnPropertyDescriptors(value)}catch{return{malformed:!0,exceededLimit:!1}}const withoutEnum={};let enumDescriptor;for(const key of Reflect.ownKeys(descriptors)){const descriptor=descriptors[key];if(descriptor?.enumerable){if(key==="enum"){enumDescriptor=descriptor;continue}if(!("value"in descriptor))return{malformed:!0,exceededLimit:!1};Object.defineProperty(withoutEnum,key,{value:descriptor.value,enumerable:!0,configurable:!1,writable:!1})}}const propertySnapshot=snapshotFormValue(withoutEnum);if(propertySnapshot.invalid||propertySnapshot.truncated)return{malformed:!0,exceededLimit:!1};let choices,exceededLimit=!1,hasEnum=!1;if(enumDescriptor){if(!("value"in enumDescriptor))return{malformed:!0,exceededLimit:!1};if(hasEnum=!0,enumDescriptor.value!==void 0){const enumSnapshot=snapshotSchemaEnum(enumDescriptor.value);if(enumSnapshot.malformed)return{malformed:!0,exceededLimit:enumSnapshot.exceededLimit};choices=enumSnapshot.value,exceededLimit=enumSnapshot.exceededLimit}}const output={};for(const key of Reflect.ownKeys(propertySnapshot.value)){const descriptor=Object.getOwnPropertyDescriptor(propertySnapshot.value,key);!descriptor?.enumerable||!("value"in descriptor)||Object.defineProperty(output,key,{value:descriptor.value,enumerable:!0,configurable:!1,writable:!1})}return hasEnum&&Object.defineProperty(output,"enum",{value:choices,enumerable:!0,configurable:!1,writable:!1}),{value:Object.freeze(output),malformed:!1,exceededLimit}}function snapshotSchema(value){if(value==null)return{schema:EMPTY_SCHEMA,shapeError:"",exceededLimits:!1};let isArray=!1;try{isArray=Array.isArray(value)}catch{return{schema:EMPTY_SCHEMA,shapeError:"object",exceededLimits:!1}}if(typeof value!="object"||isArray)return{schema:EMPTY_SCHEMA,shapeError:"object",exceededLimits:!1};let rootDescriptors;try{rootDescriptors=Object.getOwnPropertyDescriptors(value)}catch{return{schema:EMPTY_SCHEMA,shapeError:"object",exceededLimits:!1}}const typeDescriptor=rootDescriptors.type;if(!typeDescriptor||!("value"in typeDescriptor)||typeDescriptor.value!=="object")return{schema:EMPTY_SCHEMA,shapeError:"object",exceededLimits:!1};const propertiesDescriptor=rootDescriptors.properties,propertiesValue=propertiesDescriptor&&"value"in propertiesDescriptor?propertiesDescriptor.value:void 0;if(propertiesValue===null||typeof propertiesValue!="object"||!isPlainRecord(propertiesValue))return{schema:EMPTY_SCHEMA,shapeError:"properties",exceededLimits:!1};const properties=Object.create(null);let shapeError="",exceededLimits=!1,seenFields=0,propertyDescriptors;try{propertyDescriptors=Object.getOwnPropertyDescriptors(propertiesValue)}catch{return{schema:EMPTY_SCHEMA,shapeError:"properties",exceededLimits:!1}}for(const key of Reflect.ownKeys(propertyDescriptors)){const descriptor=propertyDescriptors[key];if(typeof key!="string"||!descriptor?.enumerable)continue;if(seenFields+=1,seenFields>MAX_SCHEMA_FIELDS){exceededLimits=!0;break}if(!("value"in descriptor)||descriptor.value===null||typeof descriptor.value!="object"||!isPlainRecord(descriptor.value)){shapeError="properties";continue}const propertySnapshot=snapshotSchemaProperty(descriptor.value);if(propertySnapshot.malformed||!propertySnapshot.value){shapeError="properties",propertySnapshot.exceededLimit&&(exceededLimits=!0);continue}propertySnapshot.exceededLimit&&(exceededLimits=!0),properties[key]=propertySnapshot.value}const requiredDescriptor=rootDescriptors.required;let required;if(requiredDescriptor&&"value"in requiredDescriptor){const requiredSnapshot=snapshotSchemaStringArray(requiredDescriptor.value);requiredSnapshot.isArray?(required=requiredSnapshot.value,requiredSnapshot.exceededLimit&&(exceededLimits=!0)):requiredDescriptor.enumerable&&(shapeError="properties")}else requiredDescriptor?.enumerable&&(shapeError="properties");return{schema:Object.freeze({type:"object",properties:Object.freeze(properties),...required===void 0?{}:{required}}),shapeError,exceededLimits}}function cloneFormValue(value,_ownerWindow){return snapshotFormValue(value).value}class LyraToolParamForm extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldMustBeBoolean:LYRA_DEFAULT_fieldMustBeBoolean,fieldMustBeInteger:LYRA_DEFAULT_fieldMustBeInteger,fieldMustBeNumber:LYRA_DEFAULT_fieldMustBeNumber,fieldMustBeOneOf:LYRA_DEFAULT_fieldMustBeOneOf,fieldMustBeString:LYRA_DEFAULT_fieldMustBeString,fieldMustEqual:LYRA_DEFAULT_fieldMustEqual,fieldRequired:LYRA_DEFAULT_fieldRequired,noData:LYRA_DEFAULT_noData,schemaMustBeObject:LYRA_DEFAULT_schemaMustBeObject,schemaPropertiesMustBeFlat:LYRA_DEFAULT_schemaPropertiesMustBeFlat,toolParamBooleanFalse:LYRA_DEFAULT_toolParamBooleanFalse,toolParamBooleanTrue:LYRA_DEFAULT_toolParamBooleanTrue,toolParamBooleanUnset:LYRA_DEFAULT_toolParamBooleanUnset,toolParamMissingProperty:LYRA_DEFAULT_toolParamMissingProperty,toolParamSchemaLimit:LYRA_DEFAULT_toolParamSchemaLimit,unsupportedFieldType:LYRA_DEFAULT_unsupportedFieldType,valueMustBeSerializable:LYRA_DEFAULT_valueMustBeSerializable}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-validity-change","lr-input"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},schema:{attribute:!1,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}constructor(){super(),this._errors={},this._formError="",this.showFormError=!1,this.touchedFields=new Set,this.baseId=nextId("tool-param-form"),this._fieldsetDisabled=!1,this._name="",this._schema=EMPTY_SCHEMA,this.schemaInputShapeError="",this.schemaInputExceededLimits=!1,this._value=Object.freeze({}),this.valueInputInvalid=!1,this.valueInputTruncated=!1,this.defaultValueSnapshot=Object.freeze({}),this.defaultValueCaptured=!1,this._effectiveValue=Object.freeze({}),this._validityFlags={},this._disabled=!1,this.hasInteracted=!1,this.visibleErrorSnapshot=new Map,this.suppressNextErrorAnnouncement=!0,this.stopNestedControlEvent=e=>{e.stopPropagation()},this.onFieldFocus=()=>{this.emit("focus")},this.onFieldBlur=()=>{this.emit("blur")},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.syncFormState()}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}[VALIDITY_ANCHOR](){const field=this.firstInvalidField();if(field){const input=field.querySelector("input.control");if(input)return input;for(const child of field.children){const anchor=resolveValidityAnchor(child);if(anchor)return anchor}}return this.firstMissingPropertyError()}firstInvalidField(){if(!this.renderRoot)return;const fields=Array.from(this.renderRoot.querySelectorAll('[part="field"]'));for(const key of Object.keys(this._errors)){const field=fields.find(candidate=>candidate.dataset.key===key);if(field)return field}}get missingRequiredKeys(){const properties=this.schemaProperties;return this.requiredKeys.filter(key=>!Object.prototype.hasOwnProperty.call(properties,key)&&!!this._errors[key])}firstMissingPropertyError(){if(!this.renderRoot)return;const errors=Array.from(this.renderRoot.querySelectorAll('[part="error"][data-missing-property]'));for(const key of Object.keys(this._errors)){const error=errors.find(candidate=>candidate.dataset.key===key);if(error)return error}}focusFirstControl(){if(!this.renderRoot)return;const controls=this.renderRoot.querySelectorAll("input.control, lr-select");for(const control of controls)if(!(control.disabled||control.getAttribute("aria-disabled")==="true")){control.focus();return}}click(){this.effectiveDisabled||this.focusFirstControl()}connectedCallback(){this.defaultValueCaptured||(this.defaultValueSnapshot=cloneFormValue(this._value,this.ownerDocument.defaultView),this.defaultValueCaptured=!0),super.connectedCallback(),this.errorAnnouncementSink?.element.ownerDocument!==this.ownerDocument&&(this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this})),this.hasUpdated&&(this.suppressNextErrorAnnouncement=!0,this.requestUpdate()),this.syncFormState()}disconnectedCallback(){super.disconnectedCallback(),this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.suppressNextErrorAnnouncement=!0}get effectiveValue(){return snapshotFormValue(this._effectiveValue).value}get schemaProperties(){return this._schema.properties}get requiredKeys(){return this._schema.required??Object.freeze([])}resolveEffectiveValue(){const props=this.schemaProperties,out={...this.value};for(const[key,prop]of Object.entries(props))!Object.prototype.hasOwnProperty.call(this.value,key)&&prop.default!==void 0&&Object.defineProperty(out,key,{configurable:!0,enumerable:!0,writable:!0,value:prop.default});return snapshotFormValue(out).value}get schema(){return this._schema}set schema(next){const old=this._schema,snapshot=snapshotSchema(next);this._schema=snapshot.schema,this.schemaInputShapeError=snapshot.shapeError,this.schemaInputExceededLimits=snapshot.exceededLimits,this.syncFormState(),this.requestUpdate("schema",old)}get value(){return this._value}set value(next){const old=this._value,snapshot=snapshotFormValue(next);this._value=snapshot.value,this.valueInputInvalid=snapshot.invalid,this.valueInputTruncated=snapshot.truncated,this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.applyValidity(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&(this.validityController.customValidityMessage||this._formError)&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}get formError(){return this._formError}computeValidation(effective){const props=this.schemaProperties,required=new Set(this.requiredKeys),out={},flags={},addError=(key,message)=>{Object.defineProperty(out,key,{configurable:!0,enumerable:!0,writable:!0,value:message})};for(const[key,prop]of Object.entries(props)){const type=prop?.type;if(type!=="string"&&type!=="number"&&type!=="integer"&&type!=="boolean"){addError(key,this.localize("unsupportedFieldType",void 0,{type:String(type)})),flags.customError=!0;continue}if(!(Object.prototype.hasOwnProperty.call(effective,key)&&effective[key]!==void 0)){required.has(key)&&(addError(key,this.localize("fieldRequired")),flags.valueMissing=!0);continue}const v=effective[key];if(type==="string"&&typeof v!="string"){addError(key,this.localize("fieldMustBeString")),flags.typeMismatch=!0;continue}if(type==="number"&&(typeof v!="number"||!Number.isFinite(v))){addError(key,this.localize("fieldMustBeNumber")),flags.typeMismatch=!0;continue}if(type==="integer"&&(typeof v!="number"||!Number.isFinite(v))){addError(key,this.localize("fieldMustBeInteger")),flags.typeMismatch=!0;continue}if(type==="integer"&&!Number.isInteger(v)){addError(key,this.localize("fieldMustBeInteger")),flags.stepMismatch=!0;continue}if(type==="boolean"&&typeof v!="boolean"){addError(key,this.localize("fieldMustBeBoolean")),flags.typeMismatch=!0;continue}if(type==="string"&&Array.isArray(prop.enum)&&!prop.enum.includes(v)){addError(key,this.localize("fieldMustBeOneOf",void 0,{values:getListFormat(this.effectiveLocale,{style:"long",type:"disjunction"}).format(prop.enum)})),flags.customError=!0;continue}prop.const!==void 0&&v!==prop.const&&(addError(key,this.localize("fieldMustEqual",void 0,{value:JSON.stringify(prop.const)})),flags.customError=!0)}for(const key of required)Object.prototype.hasOwnProperty.call(props,key)||(!Object.prototype.hasOwnProperty.call(effective,key)||effective[key]===void 0)&&(addError(key,this.localize("fieldRequired")),flags.valueMissing=!0);return{errors:out,flags}}checkValidity(){return this.syncFormState(),this.internals.checkValidity()}reportValidity(){this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this._formError&&(this.showFormError=!0),this.requestUpdate();const valid=this.internals.reportValidity();return!valid&&!this.firstInvalidField()&&this.missingRequiredKeys.length>0&&this.updateComplete.then(()=>{const error=this.firstMissingPropertyError();this.validityController.refreshAnchor(),error?.focus()}),valid}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot(),this.requestUpdate()}formResetCallback(){this.hasInteracted=!1,this.value=cloneFormValue(this.defaultValueSnapshot,this.ownerDocument.defaultView),this.touchedFields=new Set,this.showFormError=!1}formStateRestoreCallback(state2,_mode){let restored={};if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=parsed)}catch{}this.value=restored}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.applyValidity(),this.requestUpdate()}schemaShapeError(){return this.schemaInputShapeError==="object"?this.localize("schemaMustBeObject"):this.schemaInputShapeError==="properties"?this.localize("schemaPropertiesMustBeFlat"):this.schemaInputExceededLimits?this.localize("toolParamSchemaLimit",void 0,{fields:getNumberFormat(this.effectiveLocale).format(MAX_SCHEMA_FIELDS),options:getNumberFormat(this.effectiveLocale).format(MAX_ENUM_OPTIONS)}):""}serializeEffectiveValue(effective){const serialized=JSON.stringify(effective,(_key,value)=>{if(typeof value=="number"&&!Number.isFinite(value))throw new TypeError("Non-finite numbers are not JSON values.");return value});if(typeof serialized!="string")throw new TypeError("Value did not serialize to JSON.");return serialized}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncInternals(formValue){this.internals.setFormValue(formValue,formValue),this.applyValidity()}applyValidity(){if(this.validityController){if(this.barredFromValidation||Object.keys(this._validityFlags).length===0)this.validityController.setValidity({});else{const firstMessage=Object.values(this._errors)[0]??this._formError;this.validityController.setValidity(this._validityFlags,firstMessage)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}}syncValidityCustomStates(){syncValidityStates(this.internals,{required:this.requiredKeys.length>0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}syncFormState(){let effective=Object.freeze({}),errors={},flags={},formError="",formValue=null;try{if(formError=this.schemaShapeError(),this.valueInputInvalid||this.valueInputTruncated)throw new TypeError("The value could not be retained within the public snapshot boundary.");effective=this.resolveEffectiveValue();const validation=this.computeValidation(effective);errors=validation.errors,flags=validation.flags,formValue=this.serializeEffectiveValue(effective)}catch{formError=this.localize("valueMustBeSerializable"),formValue=null}formError&&(flags.customError=!0,formValue=null),this._effectiveValue=effective,JSON.stringify(this._errors)!==JSON.stringify(errors)&&(this._errors=errors),this._formError=formError,this._validityFlags=flags,this.syncInternals(formValue)}updated(changed){if(super.updated(changed),this.publishValiditySnapshot(),changed.has("value")||changed.has("schema")||changed.has("_errors")||changed.has("_formError")){const nestedUpdates=Array.from(this.firstInvalidField()?.children??[]).filter(element=>typeof element[VALIDITY_ANCHOR]=="function").map(element=>element.updateComplete).filter(update=>update!==void 0);nestedUpdates.length>0&&Promise.all(nestedUpdates).then(()=>this.validityController.refreshAnchor())}const currentErrors=new Map;for(const node of this.renderRoot.querySelectorAll('[part="error"]')){const fieldKey=node.closest('[part~="field"]')?.dataset.key,key=node.dataset.key??fieldKey??"form",text=node.textContent?.trim()??"";text&¤tErrors.set(key,text)}if(!this.suppressNextErrorAnnouncement){const freshMessages=[];for(const[key,text]of currentErrors)this.visibleErrorSnapshot.get(key)!==text&&!freshMessages.includes(text)&&freshMessages.push(text);freshMessages.length>0&&this.errorAnnouncementSink?.announce(freshMessages.join(" "))}this.visibleErrorSnapshot=currentErrors,this.suppressNextErrorAnnouncement=!1}setFieldValue(key,val){this.effectiveDisabled||(this.hasInteracted=!0,this.value={...this.value,[key]:val},this.emit("lr-input",{value:this.effectiveValue}))}markTouched(key){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(key)&&(this.touchedFields=new Set(this.touchedFields).add(key))}onTextInput(key,e){this.setFieldValue(key,e.target.value)}onNumberInput(key,e){const n=e.target.valueAsNumber;this.setFieldValue(key,Number.isNaN(n)?void 0:n)}onSelectChange(key,e){e.stopPropagation(),this.setFieldValue(key,e.target.value)}onBooleanSelectChange(key,e){e.stopPropagation();const value=e.target.value;if(value===""){if(this.effectiveDisabled)return;if(this.hasInteracted=!0,this.schemaProperties[key]?.default!==void 0)this.value={...this.value,[key]:void 0};else{const next={...this.value};Reflect.deleteProperty(next,key),this.value=next}this.emit("lr-input",{value:this.effectiveValue});return}this.setFieldValue(key,value==="true")}renderControl(key,prop,fieldId,label,required,describedBy,errorMessage,effective){if(prop.type==="string"&&prop.enum&&prop.enum.length>0)return html`<lr-select
|
|
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{state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";installFormControlLabelSupport();import{nextId}from"../../../internal/a11y.js";import{AnchoredValidityController,resolveValidityAnchor,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{styles}from"./tool-param-form.styles.js";import"../../forms/select/select.class.js";import"../../forms/combobox/option.class.js";import"../../forms/input/number-input.class.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{attachInternalsSafely,getFormOwner,installCustomErrorProperty,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_fieldMustBeBoolean,LYRA_DEFAULT_fieldMustBeInteger,LYRA_DEFAULT_fieldMustBeNumber,LYRA_DEFAULT_fieldMustBeOneOf,LYRA_DEFAULT_fieldMustBeString,LYRA_DEFAULT_fieldMustEqual,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_noData,LYRA_DEFAULT_schemaMustBeObject,LYRA_DEFAULT_schemaPropertiesMustBeFlat,LYRA_DEFAULT_toolParamBooleanFalse,LYRA_DEFAULT_toolParamBooleanTrue,LYRA_DEFAULT_toolParamBooleanUnset,LYRA_DEFAULT_toolParamMissingProperty,LYRA_DEFAULT_toolParamSchemaLimit,LYRA_DEFAULT_unsupportedFieldType,LYRA_DEFAULT_valueMustBeSerializable}from"../../../internal/default-strings.generated.js";const MAX_SCHEMA_FIELDS=100,MAX_ENUM_OPTIONS=500,MAX_VALUE_ENTRIES=1e4,MAX_VALUE_NODES=5e4,MAX_VALUE_INSPECTIONS=MAX_VALUE_NODES*2,MAX_VALUE_DEPTH=16,OMIT_VALUE=Symbol("omit-tool-param-value"),LIMIT_VALUE=Symbol("limit-tool-param-value"),FUNCTION_TO_STRING=Function.prototype.toString,OBJECT_CONSTRUCTOR_SOURCE=FUNCTION_TO_STRING.call(Object);function isPlainRecord(value){try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructorDescriptor=Object.getOwnPropertyDescriptor(prototype,"constructor");if(!constructorDescriptor||!("value"in constructorDescriptor)||typeof constructorDescriptor.value!="function")return!1;const constructor=constructorDescriptor.value,constructorPrototype=Object.getOwnPropertyDescriptor(constructor,"prototype");return!!(constructorPrototype&&"value"in constructorPrototype&&constructorPrototype.value===prototype&&FUNCTION_TO_STRING.call(constructor)===OBJECT_CONSTRUCTOR_SOURCE)}catch{return!1}}function checkpointSnapshot(budget){return{remaining:budget.remaining,seenEntries:budget.seenEntries.length,truncated:budget.truncated}}function restoreSnapshotCheckpoint(budget,checkpoint){for(budget.remaining=checkpoint.remaining,budget.truncated=checkpoint.truncated;budget.seenEntries.length>checkpoint.seenEntries;){const source=budget.seenEntries.pop();source&&budget.seen.delete(source)}}function rememberSnapshot(budget,source,output){budget.seen.set(source,output),budget.seenEntries.push(source)}function omitInvalidValue(budget,checkpoint){return restoreSnapshotCheckpoint(budget,checkpoint),budget.invalid=!0,OMIT_VALUE}function snapshotValueEntry(value,budget,depth){if(value===null||typeof value!="object"&&typeof value!="function")return value;const checkpoint=checkpointSnapshot(budget);if(typeof value=="function")return omitInvalidValue(budget,checkpoint);if(depth>MAX_VALUE_DEPTH||budget.remaining<=0)return budget.truncated=!0,LIMIT_VALUE;const existing=budget.seen.get(value);if(existing!==void 0)return existing;let isArray=!1;try{isArray=Array.isArray(value)}catch{return omitInvalidValue(budget,checkpoint)}if(isArray){if(budget.remainingInspections<=0)return budget.truncated=!0,LIMIT_VALUE;budget.remainingInspections-=1;const output2=[];rememberSnapshot(budget,value,output2);let sourceLength=0;try{const descriptor=Object.getOwnPropertyDescriptor(value,"length");if(descriptor&&"value"in descriptor&&typeof descriptor.value=="number"&&Number.isSafeInteger(descriptor.value)&&descriptor.value>=0)sourceLength=descriptor.value;else return omitInvalidValue(budget,checkpoint)}catch{return omitInvalidValue(budget,checkpoint)}sourceLength>MAX_VALUE_ENTRIES&&(budget.truncated=!0);const length=Math.min(sourceLength,MAX_VALUE_ENTRIES);let outputLength=length;for(let index=0;index<length;index+=1){if(budget.remaining<=0||budget.remainingInspections<=0){budget.truncated=!0,outputLength=index;break}budget.remainingInspections-=1;let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{budget.invalid=!0;continue}if(!descriptor)continue;if(!("value"in descriptor)){budget.invalid=!0;continue}const entryCheckpoint=checkpointSnapshot(budget);budget.remaining-=1;const entry=snapshotValueEntry(descriptor.value,budget,depth+1);if(entry===OMIT_VALUE){restoreSnapshotCheckpoint(budget,entryCheckpoint);continue}if(entry===LIMIT_VALUE){outputLength=index;break}Object.defineProperty(output2,String(index),{value:entry,enumerable:!0,configurable:!1,writable:!1})}return output2.length=outputLength,Object.freeze(output2)}if(!isPlainRecord(value))return omitInvalidValue(budget,checkpoint);const output={};rememberSnapshot(budget,value,output);let retained=0;try{for(const key in value){if(retained>=MAX_VALUE_ENTRIES||budget.remaining<=0||budget.remainingInspections<=0){budget.truncated=!0;break}budget.remainingInspections-=1;const descriptor=Object.getOwnPropertyDescriptor(value,key);if(!descriptor||!descriptor.enumerable)continue;if(!("value"in descriptor)){budget.invalid=!0;continue}const entryCheckpoint=checkpointSnapshot(budget);budget.remaining-=1;const entry=snapshotValueEntry(descriptor.value,budget,depth+1);if(entry===OMIT_VALUE){restoreSnapshotCheckpoint(budget,entryCheckpoint);continue}if(entry===LIMIT_VALUE)break;retained+=1,Object.defineProperty(output,key,{value:entry,enumerable:!0,configurable:!1,writable:!1})}}catch{return omitInvalidValue(budget,checkpoint)}return Object.freeze(output)}function snapshotFormValue(value){if(value==null)return{value:Object.freeze({}),invalid:!1,truncated:!1};let isArray=!1;try{isArray=Array.isArray(value)}catch{return{value:Object.freeze({}),invalid:!0,truncated:!1}}if(typeof value!="object"||isArray||!isPlainRecord(value))return{value:Object.freeze({}),invalid:!0,truncated:!1};const budget={remaining:MAX_VALUE_NODES,remainingInspections:MAX_VALUE_INSPECTIONS,seen:new WeakMap,seenEntries:[],invalid:!1,truncated:!1},snapshot=snapshotValueEntry(value,budget,0);return{value:snapshot===OMIT_VALUE||snapshot===LIMIT_VALUE?Object.freeze({}):snapshot,invalid:budget.invalid||snapshot===OMIT_VALUE,truncated:budget.truncated||snapshot===LIMIT_VALUE}}const EMPTY_SCHEMA=Object.freeze({type:"object",properties:Object.freeze({})});function snapshotSchemaStringArray(value){let isArray=!1;try{isArray=Array.isArray(value)}catch{return{isArray:!1,exceededLimit:!1}}if(!isArray)return{isArray:!1,exceededLimit:!1};let sourceLength=0;try{const descriptor=Object.getOwnPropertyDescriptor(value,"length");descriptor&&"value"in descriptor&&typeof descriptor.value=="number"&&Number.isSafeInteger(descriptor.value)&&descriptor.value>=0&&(sourceLength=descriptor.value)}catch{return{isArray:!0,value:Object.freeze([]),exceededLimit:!1}}const output=[];for(let index=0;index<Math.min(sourceLength,MAX_SCHEMA_FIELDS);index+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{continue}descriptor&&"value"in descriptor&&typeof descriptor.value=="string"&&output.push(descriptor.value)}return{isArray:!0,value:Object.freeze(output),exceededLimit:sourceLength>MAX_SCHEMA_FIELDS}}function snapshotSchemaEnum(value){let isArray=!1;try{isArray=Array.isArray(value)}catch{return{malformed:!0,exceededLimit:!1}}if(!isArray)return{malformed:!0,exceededLimit:!1};let sourceLength=0;try{const descriptor=Object.getOwnPropertyDescriptor(value,"length");if(!descriptor||!("value"in descriptor)||typeof descriptor.value!="number"||!Number.isSafeInteger(descriptor.value)||descriptor.value<0)return{malformed:!0,exceededLimit:!1};sourceLength=descriptor.value}catch{return{malformed:!0,exceededLimit:!1}}const output=[];for(let index=0;index<Math.min(sourceLength,MAX_ENUM_OPTIONS);index+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{return{malformed:!0,exceededLimit:sourceLength>MAX_ENUM_OPTIONS}}if(descriptor){if(!("value"in descriptor)||typeof descriptor.value!="string")return{malformed:!0,exceededLimit:sourceLength>MAX_ENUM_OPTIONS};output.push(descriptor.value)}}return{value:Object.freeze(output),malformed:!1,exceededLimit:sourceLength>MAX_ENUM_OPTIONS}}function snapshotSchemaProperty(value){let descriptors;try{descriptors=Object.getOwnPropertyDescriptors(value)}catch{return{malformed:!0,exceededLimit:!1}}const withoutEnum={};let enumDescriptor;for(const key of Reflect.ownKeys(descriptors)){const descriptor=descriptors[key];if(descriptor?.enumerable){if(key==="enum"){enumDescriptor=descriptor;continue}if(!("value"in descriptor))return{malformed:!0,exceededLimit:!1};Object.defineProperty(withoutEnum,key,{value:descriptor.value,enumerable:!0,configurable:!1,writable:!1})}}const propertySnapshot=snapshotFormValue(withoutEnum);if(propertySnapshot.invalid||propertySnapshot.truncated)return{malformed:!0,exceededLimit:!1};let choices,exceededLimit=!1,hasEnum=!1;if(enumDescriptor){if(!("value"in enumDescriptor))return{malformed:!0,exceededLimit:!1};if(hasEnum=!0,enumDescriptor.value!==void 0){const enumSnapshot=snapshotSchemaEnum(enumDescriptor.value);if(enumSnapshot.malformed)return{malformed:!0,exceededLimit:enumSnapshot.exceededLimit};choices=enumSnapshot.value,exceededLimit=enumSnapshot.exceededLimit}}const output={};for(const key of Reflect.ownKeys(propertySnapshot.value)){const descriptor=Object.getOwnPropertyDescriptor(propertySnapshot.value,key);!descriptor?.enumerable||!("value"in descriptor)||Object.defineProperty(output,key,{value:descriptor.value,enumerable:!0,configurable:!1,writable:!1})}return hasEnum&&Object.defineProperty(output,"enum",{value:choices,enumerable:!0,configurable:!1,writable:!1}),{value:Object.freeze(output),malformed:!1,exceededLimit}}function snapshotSchema(value){if(value==null)return{schema:EMPTY_SCHEMA,shapeError:"",exceededLimits:!1};let isArray=!1;try{isArray=Array.isArray(value)}catch{return{schema:EMPTY_SCHEMA,shapeError:"object",exceededLimits:!1}}if(typeof value!="object"||isArray)return{schema:EMPTY_SCHEMA,shapeError:"object",exceededLimits:!1};let rootDescriptors;try{rootDescriptors=Object.getOwnPropertyDescriptors(value)}catch{return{schema:EMPTY_SCHEMA,shapeError:"object",exceededLimits:!1}}const typeDescriptor=rootDescriptors.type;if(!typeDescriptor||!("value"in typeDescriptor)||typeDescriptor.value!=="object")return{schema:EMPTY_SCHEMA,shapeError:"object",exceededLimits:!1};const propertiesDescriptor=rootDescriptors.properties,propertiesValue=propertiesDescriptor&&"value"in propertiesDescriptor?propertiesDescriptor.value:void 0;if(propertiesValue===null||typeof propertiesValue!="object"||!isPlainRecord(propertiesValue))return{schema:EMPTY_SCHEMA,shapeError:"properties",exceededLimits:!1};const properties=Object.create(null);let shapeError="",exceededLimits=!1,seenFields=0,propertyDescriptors;try{propertyDescriptors=Object.getOwnPropertyDescriptors(propertiesValue)}catch{return{schema:EMPTY_SCHEMA,shapeError:"properties",exceededLimits:!1}}for(const key of Reflect.ownKeys(propertyDescriptors)){const descriptor=propertyDescriptors[key];if(typeof key!="string"||!descriptor?.enumerable)continue;if(seenFields+=1,seenFields>MAX_SCHEMA_FIELDS){exceededLimits=!0;break}if(!("value"in descriptor)||descriptor.value===null||typeof descriptor.value!="object"||!isPlainRecord(descriptor.value)){shapeError="properties";continue}const propertySnapshot=snapshotSchemaProperty(descriptor.value);if(propertySnapshot.malformed||!propertySnapshot.value){shapeError="properties",propertySnapshot.exceededLimit&&(exceededLimits=!0);continue}propertySnapshot.exceededLimit&&(exceededLimits=!0),properties[key]=propertySnapshot.value}const requiredDescriptor=rootDescriptors.required;let required;if(requiredDescriptor&&"value"in requiredDescriptor){const requiredSnapshot=snapshotSchemaStringArray(requiredDescriptor.value);requiredSnapshot.isArray?(required=requiredSnapshot.value,requiredSnapshot.exceededLimit&&(exceededLimits=!0)):requiredDescriptor.enumerable&&(shapeError="properties")}else requiredDescriptor?.enumerable&&(shapeError="properties");return{schema:Object.freeze({type:"object",properties:Object.freeze(properties),...required===void 0?{}:{required}}),shapeError,exceededLimits}}function cloneFormValue(value,_ownerWindow){return snapshotFormValue(value).value}class LyraToolParamForm extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldMustBeBoolean:LYRA_DEFAULT_fieldMustBeBoolean,fieldMustBeInteger:LYRA_DEFAULT_fieldMustBeInteger,fieldMustBeNumber:LYRA_DEFAULT_fieldMustBeNumber,fieldMustBeOneOf:LYRA_DEFAULT_fieldMustBeOneOf,fieldMustBeString:LYRA_DEFAULT_fieldMustBeString,fieldMustEqual:LYRA_DEFAULT_fieldMustEqual,fieldRequired:LYRA_DEFAULT_fieldRequired,noData:LYRA_DEFAULT_noData,schemaMustBeObject:LYRA_DEFAULT_schemaMustBeObject,schemaPropertiesMustBeFlat:LYRA_DEFAULT_schemaPropertiesMustBeFlat,toolParamBooleanFalse:LYRA_DEFAULT_toolParamBooleanFalse,toolParamBooleanTrue:LYRA_DEFAULT_toolParamBooleanTrue,toolParamBooleanUnset:LYRA_DEFAULT_toolParamBooleanUnset,toolParamMissingProperty:LYRA_DEFAULT_toolParamMissingProperty,toolParamSchemaLimit:LYRA_DEFAULT_toolParamSchemaLimit,unsupportedFieldType:LYRA_DEFAULT_unsupportedFieldType,valueMustBeSerializable:LYRA_DEFAULT_valueMustBeSerializable}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-validity-change","lr-input"])}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},schema:{attribute:!1,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}constructor(){super(),this._errors={},this._formError="",this.showFormError=!1,this.touchedFields=new Set,this.baseId=nextId("tool-param-form"),this._fieldsetDisabled=!1,this._name="",this._schema=EMPTY_SCHEMA,this.schemaInputShapeError="",this.schemaInputExceededLimits=!1,this._value=Object.freeze({}),this.valueInputInvalid=!1,this.valueInputTruncated=!1,this.defaultValueSnapshot=Object.freeze({}),this.defaultValueCaptured=!1,this._effectiveValue=Object.freeze({}),this._validityFlags={},this._disabled=!1,this.hasInteracted=!1,this.visibleErrorSnapshot=new Map,this.suppressNextErrorAnnouncement=!0,this.stopNestedControlEvent=e=>{e.stopPropagation()},this.onFieldFocus=()=>{this.emit("focus")},this.onFieldBlur=()=>{this.emit("blur")},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.syncFormState()}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}[VALIDITY_ANCHOR](){const field=this.firstInvalidField();if(field){const input=field.querySelector("input.control");if(input)return input;for(const child of field.children){const anchor=resolveValidityAnchor(child);if(anchor)return anchor}}return this.firstMissingPropertyError()}firstInvalidField(){if(!this.renderRoot)return;const fields=Array.from(this.renderRoot.querySelectorAll('[part="field"]'));for(const key of Object.keys(this._errors)){const field=fields.find(candidate=>candidate.dataset.key===key);if(field)return field}}get missingRequiredKeys(){const properties=this.schemaProperties;return this.requiredKeys.filter(key=>!Object.prototype.hasOwnProperty.call(properties,key)&&!!this._errors[key])}firstMissingPropertyError(){if(!this.renderRoot)return;const errors=Array.from(this.renderRoot.querySelectorAll('[part="error"][data-missing-property]'));for(const key of Object.keys(this._errors)){const error=errors.find(candidate=>candidate.dataset.key===key);if(error)return error}}focusFirstControl(){if(!this.renderRoot)return;const controls=this.renderRoot.querySelectorAll("input.control, lr-select");for(const control of controls)if(!(control.disabled||control.getAttribute("aria-disabled")==="true")){control.focus();return}}click(){this.effectiveDisabled||this.focusFirstControl()}connectedCallback(){this.defaultValueCaptured||(this.defaultValueSnapshot=cloneFormValue(this._value,this.ownerDocument.defaultView),this.defaultValueCaptured=!0),super.connectedCallback(),this.errorAnnouncementSink?.element.ownerDocument!==this.ownerDocument&&(this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this})),this.hasUpdated&&(this.suppressNextErrorAnnouncement=!0,this.requestUpdate()),this.syncFormState()}disconnectedCallback(){super.disconnectedCallback(),this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.suppressNextErrorAnnouncement=!0}get effectiveValue(){return snapshotFormValue(this._effectiveValue).value}get schemaProperties(){return this._schema.properties}get requiredKeys(){return this._schema.required??Object.freeze([])}resolveEffectiveValue(){const props=this.schemaProperties,out={...this.value};for(const[key,prop]of Object.entries(props))!Object.prototype.hasOwnProperty.call(this.value,key)&&prop.default!==void 0&&Object.defineProperty(out,key,{configurable:!0,enumerable:!0,writable:!0,value:prop.default});return snapshotFormValue(out).value}get schema(){return this._schema}set schema(next){const old=this._schema,snapshot=snapshotSchema(next);this._schema=snapshot.schema,this.schemaInputShapeError=snapshot.shapeError,this.schemaInputExceededLimits=snapshot.exceededLimits,this.syncFormState(),this.requestUpdate("schema",old)}get value(){return this._value}set value(next){const old=this._value,snapshot=snapshotFormValue(next);this._value=snapshot.value,this.valueInputInvalid=snapshot.invalid,this.valueInputTruncated=snapshot.truncated,this.syncFormState(),this.requestUpdate("value",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.applyValidity(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get errors(){return this.publicValidityErrors()}publicValidityErrors(){const errors={...this._errors};return this.willValidate&&(this.validityController.customValidityMessage||this._formError)&&(errors.base=this.validationMessage),Object.freeze(errors)}publishValiditySnapshot(){if(!this.isConnected)return;const valid=!this.willValidate||this.validity.valid,errors=valid?Object.freeze({}):this.publicValidityErrors(),key=JSON.stringify({valid,errors});key!==this.lastValidityKey&&(this.lastValidityKey=key,this.emit("lr-validity-change",Object.freeze({valid,errors})))}get formError(){return this._formError}computeValidation(effective){const props=this.schemaProperties,required=new Set(this.requiredKeys),out={},flags={},addError=(key,message)=>{Object.defineProperty(out,key,{configurable:!0,enumerable:!0,writable:!0,value:message})};for(const[key,prop]of Object.entries(props)){const type=prop?.type;if(type!=="string"&&type!=="number"&&type!=="integer"&&type!=="boolean"){addError(key,this.localize("unsupportedFieldType",void 0,{type:String(type)})),flags.customError=!0;continue}if(!(Object.prototype.hasOwnProperty.call(effective,key)&&effective[key]!==void 0)){required.has(key)&&(addError(key,this.localize("fieldRequired")),flags.valueMissing=!0);continue}const v=effective[key];if(type==="string"&&typeof v!="string"){addError(key,this.localize("fieldMustBeString")),flags.typeMismatch=!0;continue}if(type==="number"&&(typeof v!="number"||!Number.isFinite(v))){addError(key,this.localize("fieldMustBeNumber")),flags.typeMismatch=!0;continue}if(type==="integer"&&(typeof v!="number"||!Number.isFinite(v))){addError(key,this.localize("fieldMustBeInteger")),flags.typeMismatch=!0;continue}if(type==="integer"&&!Number.isInteger(v)){addError(key,this.localize("fieldMustBeInteger")),flags.stepMismatch=!0;continue}if(type==="boolean"&&typeof v!="boolean"){addError(key,this.localize("fieldMustBeBoolean")),flags.typeMismatch=!0;continue}if(type==="string"&&Array.isArray(prop.enum)&&!prop.enum.includes(v)){addError(key,this.localize("fieldMustBeOneOf",void 0,{values:getListFormat(this.effectiveLocale,{style:"long",type:"disjunction"}).format(prop.enum)})),flags.customError=!0;continue}prop.const!==void 0&&v!==prop.const&&(addError(key,this.localize("fieldMustEqual",void 0,{value:JSON.stringify(prop.const)})),flags.customError=!0)}for(const key of required)Object.prototype.hasOwnProperty.call(props,key)||(!Object.prototype.hasOwnProperty.call(effective,key)||effective[key]===void 0)&&(addError(key,this.localize("fieldRequired")),flags.valueMissing=!0);return{errors:out,flags}}checkValidity(){return this.syncFormState(),this.internals.checkValidity()}reportValidity(){this.hasInteracted=!0,this.syncFormState(),Object.keys(this._errors).length>0&&(this.touchedFields=new Set([...this.touchedFields,...Object.keys(this._errors)])),this._formError&&(this.showFormError=!0),this.requestUpdate();const valid=this.internals.reportValidity();return!valid&&!this.firstInvalidField()&&this.missingRequiredKeys.length>0&&this.updateComplete.then(()=>{const error=this.firstMissingPropertyError();this.validityController.refreshAnchor(),error?.focus()}),valid}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityCustomStates(),this.publishValiditySnapshot(),this.requestUpdate()}formResetCallback(){this.hasInteracted=!1,this.value=cloneFormValue(this.defaultValueSnapshot,this.ownerDocument.defaultView),this.touchedFields=new Set,this.showFormError=!1}formStateRestoreCallback(state2,_mode){let restored={};if(typeof state2=="string")try{const parsed=JSON.parse(state2);parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)&&(restored=parsed)}catch{}this.value=restored}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.applyValidity(),this.requestUpdate()}schemaShapeError(){return this.schemaInputShapeError==="object"?this.localize("schemaMustBeObject"):this.schemaInputShapeError==="properties"?this.localize("schemaPropertiesMustBeFlat"):this.schemaInputExceededLimits?this.localize("toolParamSchemaLimit",void 0,{fields:getNumberFormat(this.effectiveLocale).format(MAX_SCHEMA_FIELDS),options:getNumberFormat(this.effectiveLocale).format(MAX_ENUM_OPTIONS)}):""}serializeEffectiveValue(effective){const serialized=JSON.stringify(effective,(_key,value)=>{if(typeof value=="number"&&!Number.isFinite(value))throw new TypeError("Non-finite numbers are not JSON values.");return value});if(typeof serialized!="string")throw new TypeError("Value did not serialize to JSON.");return serialized}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}syncInternals(formValue){this.internals.setFormValue(formValue,formValue),this.applyValidity()}applyValidity(){if(this.validityController){if(this.barredFromValidation||Object.keys(this._validityFlags).length===0)this.validityController.setValidity({});else{const firstMessage=Object.values(this._errors)[0]??this._formError;this.validityController.setValidity(this._validityFlags,firstMessage)}this.syncValidityCustomStates(),this.publishValiditySnapshot()}}syncValidityCustomStates(){syncValidityStates(this.internals,{required:this.requiredKeys.length>0,hasInteracted:this.hasInteracted,barred:this.barredFromValidation})}syncFormState(){let effective=Object.freeze({}),errors={},flags={},formError="",formValue=null;try{if(formError=this.schemaShapeError(),this.valueInputInvalid||this.valueInputTruncated)throw new TypeError("The value could not be retained within the public snapshot boundary.");effective=this.resolveEffectiveValue();const validation=this.computeValidation(effective);errors=validation.errors,flags=validation.flags,formValue=this.serializeEffectiveValue(effective)}catch{formError=this.localize("valueMustBeSerializable"),formValue=null}formError&&(flags.customError=!0,formValue=null),this._effectiveValue=effective,JSON.stringify(this._errors)!==JSON.stringify(errors)&&(this._errors=errors),this._formError=formError,this._validityFlags=flags,this.syncInternals(formValue)}updated(changed){if(super.updated(changed),this.publishValiditySnapshot(),changed.has("value")||changed.has("schema")||changed.has("_errors")||changed.has("_formError")){const nestedUpdates=Array.from(this.firstInvalidField()?.children??[]).filter(element=>typeof element[VALIDITY_ANCHOR]=="function").map(element=>element.updateComplete).filter(update=>update!==void 0);nestedUpdates.length>0&&Promise.all(nestedUpdates).then(()=>this.validityController.refreshAnchor())}const currentErrors=new Map;for(const node of this.renderRoot.querySelectorAll('[part="error"]')){const fieldKey=node.closest('[part~="field"]')?.dataset.key,key=node.dataset.key??fieldKey??"form",text=node.textContent?.trim()??"";text&¤tErrors.set(key,text)}if(!this.suppressNextErrorAnnouncement){const freshMessages=[];for(const[key,text]of currentErrors)this.visibleErrorSnapshot.get(key)!==text&&!freshMessages.includes(text)&&freshMessages.push(text);freshMessages.length>0&&this.errorAnnouncementSink?.announce(freshMessages.join(" "))}this.visibleErrorSnapshot=currentErrors,this.suppressNextErrorAnnouncement=!1}setFieldValue(key,val){this.effectiveDisabled||(this.hasInteracted=!0,this.value={...this.value,[key]:val},this.emit("lr-input",{value:this.effectiveValue}))}markTouched(key){this.hasInteracted=!0,this.syncValidityCustomStates(),!this.touchedFields.has(key)&&(this.touchedFields=new Set(this.touchedFields).add(key))}onTextInput(key,e){this.setFieldValue(key,e.target.value)}onNumberInput(key,e){e.stopPropagation();const n=e.target.valueAsNumber;this.setFieldValue(key,Number.isNaN(n)?void 0:n)}onSelectChange(key,e){e.stopPropagation(),this.setFieldValue(key,e.target.value)}onBooleanSelectChange(key,e){e.stopPropagation();const value=e.target.value;if(value===""){if(this.effectiveDisabled)return;if(this.hasInteracted=!0,this.schemaProperties[key]?.default!==void 0)this.value={...this.value,[key]:void 0};else{const next={...this.value};Reflect.deleteProperty(next,key),this.value=next}this.emit("lr-input",{value:this.effectiveValue});return}this.setFieldValue(key,value==="true")}renderControl(key,prop,fieldId,label,required,describedBy,errorMessage,effective){if(prop.type==="string"&&prop.enum&&prop.enum.length>0)return html`<lr-select
|
|
2
2
|
id=${fieldId}
|
|
3
3
|
.label=${label}
|
|
4
4
|
.hint=${prop.description??""}
|
|
@@ -35,21 +35,22 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
35
35
|
@input=${e=>this.onTextInput(key,e)}
|
|
36
36
|
@focus=${this.onFieldFocus}
|
|
37
37
|
@blur=${this.onFieldBlur}
|
|
38
|
-
/>`;if(prop.type==="number"||prop.type==="integer"){const numValue=typeof effective=="number"&&!Number.isNaN(effective)?String(effective):"";return html`<input
|
|
39
|
-
class="control"
|
|
38
|
+
/>`;if(prop.type==="number"||prop.type==="integer"){const numValue=typeof effective=="number"&&!Number.isNaN(effective)?String(effective):"";return html`<lr-number-input
|
|
40
39
|
part="control"
|
|
41
|
-
type="number"
|
|
42
40
|
id=${fieldId}
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
.label=${label}
|
|
42
|
+
.hint=${prop.description??""}
|
|
43
|
+
.errorText=${errorMessage}
|
|
44
|
+
.required=${!1}
|
|
45
45
|
aria-required=${required?"true":"false"}
|
|
46
|
-
|
|
46
|
+
.step=${prop.type==="integer"?1:"any"}
|
|
47
47
|
.value=${numValue}
|
|
48
48
|
?disabled=${this.effectiveDisabled}
|
|
49
49
|
@input=${e=>this.onNumberInput(key,e)}
|
|
50
|
-
@
|
|
51
|
-
@
|
|
52
|
-
|
|
50
|
+
@lr-input=${this.stopNestedControlEvent}
|
|
51
|
+
@change=${this.stopNestedControlEvent}
|
|
52
|
+
@lr-change=${this.stopNestedControlEvent}
|
|
53
|
+
></lr-number-input>`}if(prop.type==="boolean"){const selected=effective===!0?"true":effective===!1?"false":"";return html`<lr-select
|
|
53
54
|
id=${fieldId}
|
|
54
55
|
.label=${label}
|
|
55
56
|
.hint=${prop.description??""}
|
|
@@ -69,14 +70,14 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
69
70
|
<lr-option value="">${this.localize("toolParamBooleanUnset")}</lr-option>
|
|
70
71
|
<lr-option value="true">${this.localize("toolParamBooleanTrue")}</lr-option>
|
|
71
72
|
<lr-option value="false">${this.localize("toolParamBooleanFalse")}</lr-option>
|
|
72
|
-
</lr-select>`}return html`<p part="unsupported" class="unsupported" id=${fieldId}>${this.localize("unsupportedFieldType",void 0,{type:String(prop.type)})}</p>`}renderField(key,prop,index){const required=this.requiredKeys.includes(key),label=prop.title??key,fieldId=`${this.baseId}-f${index}`,descId=prop.description?`${fieldId}-desc`:"",errId=this._errors[key]?`${fieldId}-err`:"",describedBy=[descId,this.touchedFields.has(key)?errId:""].filter(Boolean).join(" "),hasError=this.touchedFields.has(key)&&!!this._errors[key],errorMessage=hasError?this._errors[key]??"":"",effective=this._effectiveValue[key],isBoolean=prop.type==="boolean",isComposedSelect=prop.type==="string"&&!!prop.enum?.length;return html`
|
|
73
|
+
</lr-select>`}return html`<p part="unsupported" class="unsupported" id=${fieldId}>${this.localize("unsupportedFieldType",void 0,{type:String(prop.type)})}</p>`}renderField(key,prop,index){const required=this.requiredKeys.includes(key),label=prop.title??key,fieldId=`${this.baseId}-f${index}`,descId=prop.description?`${fieldId}-desc`:"",errId=this._errors[key]?`${fieldId}-err`:"",describedBy=[descId,this.touchedFields.has(key)?errId:""].filter(Boolean).join(" "),hasError=this.touchedFields.has(key)&&!!this._errors[key],errorMessage=hasError?this._errors[key]??"":"",effective=this._effectiveValue[key],isBoolean=prop.type==="boolean",isComposedSelect=prop.type==="string"&&!!prop.enum?.length,isComposedNumber=prop.type==="number"||prop.type==="integer";return html`
|
|
73
74
|
<div part="field" class="field" data-key=${key} data-type=${prop.type} ?data-required=${required}
|
|
74
75
|
@focusout=${()=>this.markTouched(key)}
|
|
75
76
|
>
|
|
76
|
-
${isBoolean||isComposedSelect?nothing:html`<label part="label" for=${fieldId}>${label}</label>`}
|
|
77
|
+
${isBoolean||isComposedSelect||isComposedNumber?nothing:html`<label part="label" for=${fieldId}>${label}</label>`}
|
|
77
78
|
${this.renderControl(key,prop,fieldId,label,required,describedBy,errorMessage,effective)}
|
|
78
|
-
${prop.description&&!isComposedSelect?html`<p part="description" id=${descId}>${prop.description}</p>`:nothing}
|
|
79
|
-
${hasError&&!isComposedSelect?html`<p part="error" id=${errId}>${this._errors[key]}</p>`:nothing}
|
|
79
|
+
${prop.description&&!isComposedSelect&&!isComposedNumber?html`<p part="description" id=${descId}>${prop.description}</p>`:nothing}
|
|
80
|
+
${hasError&&!isComposedSelect&&!isComposedNumber?html`<p part="error" id=${errId}>${this._errors[key]}</p>`:nothing}
|
|
80
81
|
</div>
|
|
81
82
|
`}render(){const props=this.schemaProperties,entries=Object.entries(props),missingRequiredKeys=this.missingRequiredKeys.filter(key=>this.touchedFields.has(key)),hostLabel=this.getAttribute("aria-label"),groupInvalid=this.hasInteracted&&!this.barredFromValidation&&!this.internals.validity.valid;return html`<div
|
|
82
83
|
part="base"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from'./tool-param-form.class.js';import'../../forms/select/select.js';
|
|
1
|
+
export*from'./tool-param-form.class.js';import'../../forms/select/select.js';import'../../forms/input/number-input.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./tool-param-form.class.js";import{LyraToolParamForm}from"./tool-param-form.class.js";import{defineElement}from"../../../internal/prefix.js";import"../../forms/select/select.js";defineElement("tool-param-form",LyraToolParamForm);
|
|
1
|
+
export*from"./tool-param-form.class.js";import{LyraToolParamForm}from"./tool-param-form.class.js";import{defineElement}from"../../../internal/prefix.js";import"../../forms/select/select.js";import"../../forms/input/number-input.js";defineElement("tool-param-form",LyraToolParamForm);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";import{formControlRequiredMarker}from"../../../internal/form-control.styles.js";const styles=css` :host { display: block; min-inline-size: 0; max-inline-size: 100%; } :host(:disabled) [part='base'] { color: var(--lr-color-text-quiet); } :host(:disabled) [part='field'] { cursor: not-allowed; } [part='base'] { display: flex; flex-direction: column; gap: var(--lr-space-l); min-inline-size: 0; max-inline-size: 100%; } [part='field'] { display: flex; flex-direction: column; align-items: flex-start; gap: var(--lr-space-xs); min-inline-size: 0; max-inline-size: 100%; } [part='label'] { display: block; font-size: var(--lr-font-size-md-sm); font-weight: var(--lr-font-weight-semibold); } ${formControlRequiredMarker} [part='field'] > lr-select, [part='field'] > input.control { inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; } input.control { box-sizing: border-box; min-block-size: var(--lr-size-2-5rem); 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: inherit; font: inherit; font-size: var(--lr-font-size-m); } input.control
|
|
1
|
+
import{css}from"lit";import{formControlRequiredMarker}from"../../../internal/form-control.styles.js";const styles=css` :host { display: block; min-inline-size: 0; max-inline-size: 100%; } :host(:disabled) [part='base'] { color: var(--lr-color-text-quiet); } :host(:disabled) [part='field'] { cursor: not-allowed; } [part='base'] { display: flex; flex-direction: column; gap: var(--lr-space-l); min-inline-size: 0; max-inline-size: 100%; } [part='field'] { display: flex; flex-direction: column; align-items: flex-start; gap: var(--lr-space-xs); min-inline-size: 0; max-inline-size: 100%; } [part='label'] { display: block; font-size: var(--lr-font-size-md-sm); font-weight: var(--lr-font-weight-semibold); } ${formControlRequiredMarker} [part='field'] > lr-select, [part='field'] > lr-number-input, [part='field'] > input.control { inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; } input.control { box-sizing: border-box; min-block-size: var(--lr-size-2-5rem); 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: inherit; font: inherit; font-size: var(--lr-font-size-m); } input.control:focus-visible { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } input.control:where(:hover):where(:not(:disabled)) { border-color: var(--lr-color-brand); } input.control[aria-invalid='true'] { border-color: var(--lr-tool-param-form-invalid-border-color, var(--lr-color-danger)); } input.control:disabled { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part='description'] { margin: 0; font-size: var(--lr-font-size-sm); color: var(--lr-color-text-quiet); } [part='label'], [part='description'], [part='error'], [part='unsupported'], [part='empty'] { min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; } [part='error'] { margin: 0; font-size: var(--lr-font-size-sm); color: var(--lr-color-danger); } .unsupported { margin: 0; font-size: var(--lr-font-size-sm); font-style: italic; color: var(--lr-color-text-quiet); } [part='empty'] { margin: 0; font-size: var(--lr-font-size-md-sm); color: var(--lr-color-text-quiet); } `;export{styles};
|
|
@@ -47,8 +47,11 @@ export type ToolResultDialogCloseReason='escape'|'backdrop'|'close-button'|'api'
|
|
|
47
47
|
* @event lr-close - `detail: ToolResultDialogCloseReason`. Fired
|
|
48
48
|
* exactly once per dismissal, via Escape, an opted-in backdrop click, the built-in
|
|
49
49
|
* close button, or a `close()` call.
|
|
50
|
-
* @event lr-maximize-change - `detail: { maximized: boolean }` (the new
|
|
51
|
-
* state), fired when the header's maximize/restore toggle is clicked
|
|
50
|
+
* @event lr-maximize-change - Cancelable. `detail: { maximized: boolean }` (the would-be new
|
|
51
|
+
* `maximized` state), fired when the header's maximize/restore toggle is clicked, *before*
|
|
52
|
+
* `maximized` itself changes. Calling `preventDefault()` vetoes the toggle and leaves `maximized`
|
|
53
|
+
* unchanged -- e.g. a host persisting a per-user "prefers maximized" layout preference can hold the
|
|
54
|
+
* transition until a save round-trip completes.
|
|
52
55
|
* @csspart backdrop - The full-viewport scrim behind the panel.
|
|
53
56
|
* @csspart panel - The dialog panel itself (`role="dialog"` while open).
|
|
54
57
|
* @csspart header - The row containing the tool name, status, duration, and toggle/close buttons.
|
|
@@ -20,7 +20,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
20
20
|
<circle cx="12" cy="12" r="9"></circle>
|
|
21
21
|
<line x1="9" y1="9" x2="15" y2="15"></line>
|
|
22
22
|
<line x1="15" y1="9" x2="9" y2="15"></line>
|
|
23
|
-
`)}function deniedIcon(){return icon(svg`<circle cx="12" cy="12" r="9"></circle><line x1="6" y1="18" x2="18" y2="6"></line>`)}const STATUS_ICON={pending:pendingIcon,running:runningIcon,success:successIcon,error:errorIcon,denied:deniedIcon},STATUS_LABEL={pending:"Pending",running:"Running",success:"Success",error:"Error",denied:"Denied"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied"},STATUS_VALUES=new Set(Object.keys(STATUS_LABEL)),statusConverter={fromAttribute(value){return value!==null&&STATUS_VALUES.has(value)?value:"pending"},toAttribute(value){return value}};class LyraToolResultDialog extends LyraElement{constructor(){super(...arguments),this.open=!1,this.lightDismiss=!1,this.accessibleLabel=null,this.toolName="",this.status="pending",this.maximized=!1,this.hasFooterSlot=!1,this.titleId=nextId("tool-result-dialog-title"),this.onFooterSlotChange=e=>{this.hasFooterSlot=e.target.assignedElements({flatten:!0}).length>0},this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{this.close("close-button")},this.toggleMaximized=()=>{
|
|
23
|
+
`)}function deniedIcon(){return icon(svg`<circle cx="12" cy="12" r="9"></circle><line x1="6" y1="18" x2="18" y2="6"></line>`)}const STATUS_ICON={pending:pendingIcon,running:runningIcon,success:successIcon,error:errorIcon,denied:deniedIcon},STATUS_LABEL={pending:"Pending",running:"Running",success:"Success",error:"Error",denied:"Denied"},STATUS_LABEL_KEY={pending:"statusPending",running:"statusRunning",success:"statusSuccess",error:"statusError",denied:"statusDenied"},STATUS_VALUES=new Set(Object.keys(STATUS_LABEL)),statusConverter={fromAttribute(value){return value!==null&&STATUS_VALUES.has(value)?value:"pending"},toAttribute(value){return value}};class LyraToolResultDialog extends LyraElement{constructor(){super(...arguments),this.open=!1,this.lightDismiss=!1,this.accessibleLabel=null,this.toolName="",this.status="pending",this.maximized=!1,this.hasFooterSlot=!1,this.titleId=nextId("tool-result-dialog-title"),this.onFooterSlotChange=e=>{this.hasFooterSlot=e.target.assignedElements({flatten:!0}).length>0},this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{this.close("close-button")},this.toggleMaximized=()=>{const next=!this.maximized;this.emit("lr-maximize-change",Object.freeze({maximized:next}),{cancelable:!0}).defaultPrevented||(this.maximized=next)}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,durationMilliseconds:LYRA_DEFAULT_durationMilliseconds,durationSeconds:LYRA_DEFAULT_durationSeconds,map:LYRA_DEFAULT_map,maximize:LYRA_DEFAULT_maximize,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,popover:LYRA_DEFAULT_popover,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusDenied:LYRA_DEFAULT_statusDenied,statusError:LYRA_DEFAULT_statusError,statusPending:LYRA_DEFAULT_statusPending,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess,toolCall:LYRA_DEFAULT_toolCall}}static{this.styles=[LyraElement.styles,styles]}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")),changed.has("open")&&(this.open?this.activateOverlay():this.deactivateOverlay())}updated(changed){super.updated(changed),changed.has("open")&&this.open&&this.overlay?.focusInitial()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.open&&(this.overlay?.isActive()?this.overlay.resume():this.activateOverlay(),queueMicrotask(()=>this.overlay?.focusInitial()))}disconnectedCallback(){super.disconnectedCallback(),this.overlay?.suspend()}close(reason="api"){this.open&&(this.open=!1,this.emit("lr-close",reason))}show(){this.open||(this.open=!0)}hide(reason="api"){this.close(reason)}activateOverlay(){this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>{this.lightDismiss&&this.close("backdrop")},lockScroll:!0,suspendWhenUnrendered:!0}))}deactivateOverlay(){this.overlay?.deactivate(),this.overlay=void 0}localizedDuration(ms){const duration=durationMessageValue(ms);return this.localize(duration.key,void 0,{value:getNumberFormat(this.effectiveLocale,{maximumFractionDigits:duration.key==="durationSeconds"?1:0}).format(duration.value)})}get safeDurationMs(){return this.durationMs!=null&&Number.isFinite(this.durationMs)?finiteRange(this.durationMs,0,0):null}render(){const durationMs=this.safeDurationMs,panelLabel=!this.hasAttribute("aria-label")&&this.accessibleLabel?this.accessibleLabel:null;return html`
|
|
24
24
|
<div part="backdrop" @click=${this.onBackdropClick}></div>
|
|
25
25
|
<div
|
|
26
26
|
part="panel"
|
|
@@ -107,6 +107,8 @@ export type ToolSelectDialogCloseReason='escape'|'backdrop'|'api'|(string&Record
|
|
|
107
107
|
* @csspart tool-disabled-reason - A disabled row's `disabledReason` text, slotted inside
|
|
108
108
|
* `tool-checkbox` (alongside `tool-name`/`tool-description`) so it contributes to the
|
|
109
109
|
* checkbox's accessible name/description instead of going unannounced.
|
|
110
|
+
* @csspart search-clear - The clear-search button, replacing the native search-cancel glyph the
|
|
111
|
+
* component resets. Only rendered while the field has text.
|
|
110
112
|
* @csspart footer - The wrapper around the `footer` slot.
|
|
111
113
|
* @cssprop [--lr-tool-select-dialog-overlay-color=var(--lr-color-overlay)] - Backdrop scrim color.
|
|
112
114
|
* @status stable
|
|
@@ -155,7 +157,7 @@ close(reason?:ToolSelectDialogCloseReason):void;
|
|
|
155
157
|
/** Opens the dialog. No-op when already open. */
|
|
156
158
|
show():void;
|
|
157
159
|
/** Closes the dialog through the same reasoned lifecycle as `close()`. */
|
|
158
|
-
hide(reason?:ToolSelectDialogCloseReason):void;private onBackdropClick;private emitChange;private restoreChildChecked;private onSearchInput;private onSearchFocus;private onSearchBlur;private stopNestedControlEvent;private onDefaultsToggle;private onToolToggle;private categoryId;private get canonicalTools();private get canonicalSelectedToolIds();
|
|
160
|
+
hide(reason?:ToolSelectDialogCloseReason):void;private onBackdropClick;private emitChange;private restoreChildChecked;private onSearchInput;private onSearchFocus;private onSearchBlur;private onClearSearch;private stopNestedControlEvent;private onDefaultsToggle;private onToolToggle;private categoryId;private get canonicalTools();private get canonicalSelectedToolIds();
|
|
159
161
|
/** Tools grouped by `category` (first-seen order), with an uncategorized
|
|
160
162
|
* bucket always last, then filtered by the active search query -- a
|
|
161
163
|
* category left with zero matches is dropped entirely rather than
|
|
@@ -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{live}from"lit/directives/live.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR,getOwnDataDescriptor}from"../../../internal/data-descriptors.js";import{styles}from"./tool-select-dialog.styles.js";import"../../forms/checkbox/checkbox.class.js";import"../../forms/switch/switch.class.js";import{trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{getNumberFormat,resolveIntlLocale}from"../../../internal/intl-cache.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loadMore,LYRA_DEFAULT_noMatchesQuery,LYRA_DEFAULT_otherCategory,LYRA_DEFAULT_searchToolsPlaceholder,LYRA_DEFAULT_selectTools,LYRA_DEFAULT_toolCount,LYRA_DEFAULT_toolSelectCustomizeHint,LYRA_DEFAULT_toolSelectLimit,LYRA_DEFAULT_toolSelectNoneAvailable,LYRA_DEFAULT_toolSelectSummary,LYRA_DEFAULT_useDefaultTools}from"../../../internal/default-strings.generated.js";const UNCATEGORIZED=null,MAX_RENDERED_TOOLS=200,MAX_NORMALIZED_TOOL_ENTRIES=1e4,FUNCTION_TO_STRING=Function.prototype.toString,OBJECT_CONSTRUCTOR_SOURCE=FUNCTION_TO_STRING.call(Object);function isRuntimeArray(value){try{return Array.isArray(value)}catch{return!1}}function ownDataArrayValues(value,limit){if(!isRuntimeArray(value))return[];const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return[];const values=[];for(let index=0;index<Math.min(length.value,limit);index+=1){const entry=getOwnDataDescriptor(value,String(index));entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR||values.push(entry.value)}return values}function isPlainToolRecord(value){if(value===null||typeof value!="object")return!1;try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructor=getOwnDataDescriptor(prototype,"constructor");if(constructor===MISSING_OWN_DATA_DESCRIPTOR||constructor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof constructor.value!="function")return!1;const name=getOwnDataDescriptor(constructor.value,"name"),constructorPrototype=getOwnDataDescriptor(constructor.value,"prototype");return name!==MISSING_OWN_DATA_DESCRIPTOR&&name!==UNSAFE_OWN_DATA_DESCRIPTOR&&name.value==="Object"&&constructorPrototype!==MISSING_OWN_DATA_DESCRIPTOR&&constructorPrototype!==UNSAFE_OWN_DATA_DESCRIPTOR&&constructorPrototype.value===prototype&&FUNCTION_TO_STRING.call(constructor.value)===OBJECT_CONSTRUCTOR_SOURCE}catch{return!1}}function requiredToolString(record,key){const value=getOwnDataDescriptor(record,key);if(!(value===MISSING_OWN_DATA_DESCRIPTOR||value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="string"||value.value.trim().length===0))return value.value}function optionalToolString(record,key){const value=getOwnDataDescriptor(record,key);if(value!==MISSING_OWN_DATA_DESCRIPTOR)return value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="string"?null:value.value}function optionalToolBoolean(record,key){const value=getOwnDataDescriptor(record,key);if(value!==MISSING_OWN_DATA_DESCRIPTOR)return value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="boolean"?null:value.value}function canonicalTool(value){if(!isPlainToolRecord(value))return;const id=requiredToolString(value,"id"),name=requiredToolString(value,"name"),description=optionalToolString(value,"description"),category=optionalToolString(value,"category"),icon=optionalToolString(value,"icon"),disabled=optionalToolBoolean(value,"disabled"),disabledReason=optionalToolString(value,"disabledReason");if(!(id===void 0||name===void 0||description===null||category===null||icon===null||disabled===null||disabledReason===null))return Object.freeze({id,name,...description===void 0?{}:{description},...category===void 0?{}:{category},...icon===void 0?{}:{icon},...disabled===void 0?{}:{disabled},...disabledReason===void 0?{}:{disabledReason}})}function projectCanonicalTools(input){const tools=[],seen=new Set;for(const entry of ownDataArrayValues(input,MAX_NORMALIZED_TOOL_ENTRIES)){const tool=canonicalTool(entry);!tool||seen.has(tool.id)||(seen.add(tool.id),tools.push(tool))}return Object.freeze(tools)}function projectCanonicalSelectedToolIds(input){const ids=[],seen=new Set;for(const entry of ownDataArrayValues(input,MAX_NORMALIZED_TOOL_ENTRIES))typeof entry!="string"||entry.trim().length===0||seen.has(entry)||(seen.add(entry),ids.push(entry));return Object.freeze(ids)}function defaultFilter(tool,query,locale){const intlLocale=resolveIntlLocale(locale);return tool.name.toLocaleLowerCase(intlLocale).includes(query)||(tool.description??"").toLocaleLowerCase(intlLocale).includes(query)}class LyraToolSelectDialog extends LyraElement{constructor(){super(...arguments),this.open=!1,this.lightDismiss=!1,this.tools=[],this.selectedToolIds=[],this.useDefaults=!1,this.accessibleLabel=null,this.autocomplete="",this.spellcheck=!0,this.autocapitalize="",this.autoCorrect="",this.inputMode="",this.enterKeyHint="",this.filter=null,this.query="",this.hasFooterSlot=!1,this.renderedToolLimit=MAX_RENDERED_TOOLS,this.titleId=nextId("tool-select-dialog-title"),this.categoryIds=new Map,this.onFooterSlotChange=e=>{this.hasFooterSlot=e.target.assignedElements({flatten:!0}).length>0},this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.onSearchInput=e=>{this.query=e.target.value,this.renderedToolLimit=MAX_RENDERED_TOOLS,e.stopPropagation()},this.onSearchFocus=()=>{this.emit("focus")},this.onSearchBlur=()=>{this.emit("blur")},this.stopNestedControlEvent=event=>{event.stopPropagation()},this.onDefaultsToggle=e=>{e.stopPropagation();const next={selectedToolIds:this.canonicalSelectedToolIds,useDefaults:e.detail.checked};if(this.emitChange(next)){this.useDefaults=next.useDefaults;return}this.restoreChildChecked(e,this.useDefaults)},this.onLoadMore=()=>{this.renderedToolLimit+=MAX_RENDERED_TOOLS,this.updateComplete.then(()=>{if(!this.isConnected||!this.open)return;(this.shadowRoot?.querySelector('[part="load-more"]')??this.shadowRoot?.querySelector('[part="body"]'))?.focus()})}}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,loadMore:LYRA_DEFAULT_loadMore,noMatchesQuery:LYRA_DEFAULT_noMatchesQuery,otherCategory:LYRA_DEFAULT_otherCategory,searchToolsPlaceholder:LYRA_DEFAULT_searchToolsPlaceholder,selectTools:LYRA_DEFAULT_selectTools,toolCount:LYRA_DEFAULT_toolCount,toolSelectCustomizeHint:LYRA_DEFAULT_toolSelectCustomizeHint,toolSelectLimit:LYRA_DEFAULT_toolSelectLimit,toolSelectNoneAvailable:LYRA_DEFAULT_toolSelectNoneAvailable,toolSelectSummary:LYRA_DEFAULT_toolSelectSummary,useDefaultTools:LYRA_DEFAULT_useDefaultTools}}static{this.ownedCollectionProperties=Object.freeze(["tools","selectedToolIds"])}static{this.styles=[LyraElement.styles,styles,srOnly]}static{this.immutableEventDetails=Object.freeze(["lr-change"])}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")),changed.has("tools")&&(this.canonicalToolsCache=void 0,this.renderedToolLimit=MAX_RENDERED_TOOLS),changed.has("selectedToolIds")&&(this.canonicalSelectedToolIdsCache=void 0,this.canonicalSelectedToolIdsSource=void 0),changed.has("filter")&&(this.renderedToolLimit=MAX_RENDERED_TOOLS),changed.has("open")&&(this.open?this.activateOverlay():(this.overlay?.deactivate(),this.overlay=void 0,this.query="",this.renderedToolLimit=MAX_RENDERED_TOOLS))}updated(changed){super.updated(changed),changed.has("open")&&this.open&&this.overlay?.focusInitial()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.open&&(this.activateOverlay(),queueMicrotask(()=>this.overlay?.focusInitial()))}disconnectedCallback(){super.disconnectedCallback(),this.overlay?.suspend()}activateOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>{this.lightDismiss&&this.close("backdrop")},lockScroll:!0,suspendWhenUnrendered:!0})}close(reason="api"){this.open&&(this.open=!1,this.emit("lr-close",reason))}show(){this.open||(this.open=!0)}hide(reason="api"){this.close(reason)}emitChange(next){return!this.emit("lr-change",{selectedToolIds:[...next.selectedToolIds],useDefaults:next.useDefaults},{cancelable:!0}).defaultPrevented}restoreChildChecked(event,checked){const control=event.currentTarget;control&&(control.checked=checked)}onToolToggle(tool,e){if(e.stopPropagation(),tool.disabled||this.useDefaults)return;const selected=this.canonicalSelectedToolIds,index=selected.indexOf(tool.id),next={selectedToolIds:e.detail.checked?index>=0?selected:[...selected.slice(0,MAX_NORMALIZED_TOOL_ENTRIES-1),tool.id]:index<0?selected:[...selected.slice(0,index),...selected.slice(index+1)],useDefaults:this.useDefaults};if(this.emitChange(next)){this.selectedToolIds=next.selectedToolIds,this.canonicalSelectedToolIdsCache=next.selectedToolIds,this.canonicalSelectedToolIdsSource=this.selectedToolIds;return}this.restoreChildChecked(e,this.canonicalSelectedToolIds.includes(tool.id))}categoryId(category){let id=this.categoryIds.get(category);return id||(id=nextId("tool-select-dialog-category"),this.categoryIds.set(category,id)),id}get canonicalTools(){return this.canonicalToolsCache||(this.canonicalToolsCache=projectCanonicalTools(this.tools)),this.canonicalToolsCache}get canonicalSelectedToolIds(){const source=this.selectedToolIds;return(this.canonicalSelectedToolIdsCache===void 0||this.canonicalSelectedToolIdsSource!==source)&&(this.canonicalSelectedToolIdsCache=projectCanonicalSelectedToolIds(source),this.canonicalSelectedToolIdsSource=source),this.canonicalSelectedToolIdsCache}get projection(){const order=[],byCategory=new Map;for(const tool of this.canonicalTools){const category=tool.category?.trim()||UNCATEGORIZED;let bucket=byCategory.get(category);bucket||(bucket=[],byCategory.set(category,bucket),category!==UNCATEGORIZED&&order.push(category)),bucket.push(tool)}byCategory.has(UNCATEGORIZED)&&order.push(UNCATEGORIZED);const q=this.query.trim().toLocaleLowerCase(this.effectiveLocale),filter=typeof this.filter=="function"?this.filter:null,matches=q?tool=>{if(!filter)return defaultFilter(tool,q,this.effectiveLocale);try{return!!filter(tool,q)}catch{return!1}}:()=>!0,matchingGroups=order.map(category=>({category,tools:byCategory.get(category).filter(matches)})).filter(group=>group.tools.length>0),totalMatches=matchingGroups.reduce((total,group)=>total+group.tools.length,0),selectedIds=new Set(this.canonicalSelectedToolIds),chosenIds=new Set;for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;selectedIds.has(tool.id)&&chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}const groups=matchingGroups.map(group=>({category:group.category,tools:group.tools.filter(tool=>chosenIds.has(tool.id))})).filter(group=>group.tools.length>0),renderedCount=chosenIds.size;return{groups,renderedCount,totalMatches,truncated:renderedCount<totalMatches}}renderTool(tool,selectedIds){const rowDisabled=!!tool.disabled||this.useDefaults;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{live}from"lit/directives/live.js";import{LyraElement}from"../../../internal/lyra-element.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{nextId,srOnly}from"../../../internal/a11y.js";import{MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR,getOwnDataDescriptor}from"../../../internal/data-descriptors.js";import{styles}from"./tool-select-dialog.styles.js";import"../../forms/checkbox/checkbox.class.js";import"../../forms/switch/switch.class.js";import{trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{getNumberFormat,resolveIntlLocale}from"../../../internal/intl-cache.js";import{closeIcon}from"../../../internal/icons.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loadMore,LYRA_DEFAULT_noMatchesQuery,LYRA_DEFAULT_otherCategory,LYRA_DEFAULT_searchToolsPlaceholder,LYRA_DEFAULT_selectTools,LYRA_DEFAULT_toolCount,LYRA_DEFAULT_toolSelectCustomizeHint,LYRA_DEFAULT_toolSelectLimit,LYRA_DEFAULT_toolSelectNoneAvailable,LYRA_DEFAULT_toolSelectSummary,LYRA_DEFAULT_useDefaultTools}from"../../../internal/default-strings.generated.js";const UNCATEGORIZED=null,MAX_RENDERED_TOOLS=200,MAX_NORMALIZED_TOOL_ENTRIES=1e4,FUNCTION_TO_STRING=Function.prototype.toString,OBJECT_CONSTRUCTOR_SOURCE=FUNCTION_TO_STRING.call(Object);function isRuntimeArray(value){try{return Array.isArray(value)}catch{return!1}}function ownDataArrayValues(value,limit){if(!isRuntimeArray(value))return[];const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return[];const values=[];for(let index=0;index<Math.min(length.value,limit);index+=1){const entry=getOwnDataDescriptor(value,String(index));entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR||values.push(entry.value)}return values}function isPlainToolRecord(value){if(value===null||typeof value!="object")return!1;try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructor=getOwnDataDescriptor(prototype,"constructor");if(constructor===MISSING_OWN_DATA_DESCRIPTOR||constructor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof constructor.value!="function")return!1;const name=getOwnDataDescriptor(constructor.value,"name"),constructorPrototype=getOwnDataDescriptor(constructor.value,"prototype");return name!==MISSING_OWN_DATA_DESCRIPTOR&&name!==UNSAFE_OWN_DATA_DESCRIPTOR&&name.value==="Object"&&constructorPrototype!==MISSING_OWN_DATA_DESCRIPTOR&&constructorPrototype!==UNSAFE_OWN_DATA_DESCRIPTOR&&constructorPrototype.value===prototype&&FUNCTION_TO_STRING.call(constructor.value)===OBJECT_CONSTRUCTOR_SOURCE}catch{return!1}}function requiredToolString(record,key){const value=getOwnDataDescriptor(record,key);if(!(value===MISSING_OWN_DATA_DESCRIPTOR||value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="string"||value.value.trim().length===0))return value.value}function optionalToolString(record,key){const value=getOwnDataDescriptor(record,key);if(value!==MISSING_OWN_DATA_DESCRIPTOR)return value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="string"?null:value.value}function optionalToolBoolean(record,key){const value=getOwnDataDescriptor(record,key);if(value!==MISSING_OWN_DATA_DESCRIPTOR)return value===UNSAFE_OWN_DATA_DESCRIPTOR||typeof value.value!="boolean"?null:value.value}function canonicalTool(value){if(!isPlainToolRecord(value))return;const id=requiredToolString(value,"id"),name=requiredToolString(value,"name"),description=optionalToolString(value,"description"),category=optionalToolString(value,"category"),icon=optionalToolString(value,"icon"),disabled=optionalToolBoolean(value,"disabled"),disabledReason=optionalToolString(value,"disabledReason");if(!(id===void 0||name===void 0||description===null||category===null||icon===null||disabled===null||disabledReason===null))return Object.freeze({id,name,...description===void 0?{}:{description},...category===void 0?{}:{category},...icon===void 0?{}:{icon},...disabled===void 0?{}:{disabled},...disabledReason===void 0?{}:{disabledReason}})}function projectCanonicalTools(input){const tools=[],seen=new Set;for(const entry of ownDataArrayValues(input,MAX_NORMALIZED_TOOL_ENTRIES)){const tool=canonicalTool(entry);!tool||seen.has(tool.id)||(seen.add(tool.id),tools.push(tool))}return Object.freeze(tools)}function projectCanonicalSelectedToolIds(input){const ids=[],seen=new Set;for(const entry of ownDataArrayValues(input,MAX_NORMALIZED_TOOL_ENTRIES))typeof entry!="string"||entry.trim().length===0||seen.has(entry)||(seen.add(entry),ids.push(entry));return Object.freeze(ids)}function defaultFilter(tool,query,locale){const intlLocale=resolveIntlLocale(locale);return tool.name.toLocaleLowerCase(intlLocale).includes(query)||(tool.description??"").toLocaleLowerCase(intlLocale).includes(query)}class LyraToolSelectDialog extends LyraElement{constructor(){super(...arguments),this.open=!1,this.lightDismiss=!1,this.tools=[],this.selectedToolIds=[],this.useDefaults=!1,this.accessibleLabel=null,this.autocomplete="",this.spellcheck=!0,this.autocapitalize="",this.autoCorrect="",this.inputMode="",this.enterKeyHint="",this.filter=null,this.query="",this.hasFooterSlot=!1,this.renderedToolLimit=MAX_RENDERED_TOOLS,this.titleId=nextId("tool-select-dialog-title"),this.categoryIds=new Map,this.onFooterSlotChange=e=>{this.hasFooterSlot=e.target.assignedElements({flatten:!0}).length>0},this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.onSearchInput=e=>{this.query=e.target.value,this.renderedToolLimit=MAX_RENDERED_TOOLS,e.stopPropagation()},this.onSearchFocus=()=>{this.emit("focus")},this.onSearchBlur=()=>{this.emit("blur")},this.onClearSearch=()=>{this.query="",this.renderedToolLimit=MAX_RENDERED_TOOLS,this.renderRoot.querySelector('[part="search-input"]')?.focus()},this.stopNestedControlEvent=event=>{event.stopPropagation()},this.onDefaultsToggle=e=>{e.stopPropagation();const next={selectedToolIds:this.canonicalSelectedToolIds,useDefaults:e.detail.checked};if(this.emitChange(next)){this.useDefaults=next.useDefaults;return}this.restoreChildChecked(e,this.useDefaults)},this.onLoadMore=()=>{this.renderedToolLimit+=MAX_RENDERED_TOOLS,this.updateComplete.then(()=>{if(!this.isConnected||!this.open)return;(this.shadowRoot?.querySelector('[part="load-more"]')??this.shadowRoot?.querySelector('[part="body"]'))?.focus()})}}static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,fieldRequired:LYRA_DEFAULT_fieldRequired,loadMore:LYRA_DEFAULT_loadMore,noMatchesQuery:LYRA_DEFAULT_noMatchesQuery,otherCategory:LYRA_DEFAULT_otherCategory,searchToolsPlaceholder:LYRA_DEFAULT_searchToolsPlaceholder,selectTools:LYRA_DEFAULT_selectTools,toolCount:LYRA_DEFAULT_toolCount,toolSelectCustomizeHint:LYRA_DEFAULT_toolSelectCustomizeHint,toolSelectLimit:LYRA_DEFAULT_toolSelectLimit,toolSelectNoneAvailable:LYRA_DEFAULT_toolSelectNoneAvailable,toolSelectSummary:LYRA_DEFAULT_toolSelectSummary,useDefaultTools:LYRA_DEFAULT_useDefaultTools}}static{this.ownedCollectionProperties=Object.freeze(["tools","selectedToolIds"])}static{this.styles=[LyraElement.styles,styles,srOnly]}static{this.immutableEventDetails=Object.freeze(["lr-change"])}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")),changed.has("tools")&&(this.canonicalToolsCache=void 0,this.renderedToolLimit=MAX_RENDERED_TOOLS),changed.has("selectedToolIds")&&(this.canonicalSelectedToolIdsCache=void 0,this.canonicalSelectedToolIdsSource=void 0),changed.has("filter")&&(this.renderedToolLimit=MAX_RENDERED_TOOLS),changed.has("open")&&(this.open?this.activateOverlay():(this.overlay?.deactivate(),this.overlay=void 0,this.query="",this.renderedToolLimit=MAX_RENDERED_TOOLS))}updated(changed){super.updated(changed),changed.has("open")&&this.open&&this.overlay?.focusInitial()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.open&&(this.activateOverlay(),queueMicrotask(()=>this.overlay?.focusInitial()))}disconnectedCallback(){super.disconnectedCallback(),this.overlay?.suspend()}activateOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>this.close("escape"),onBackdrop:()=>{this.lightDismiss&&this.close("backdrop")},lockScroll:!0,suspendWhenUnrendered:!0})}close(reason="api"){this.open&&(this.open=!1,this.emit("lr-close",reason))}show(){this.open||(this.open=!0)}hide(reason="api"){this.close(reason)}emitChange(next){return!this.emit("lr-change",{selectedToolIds:[...next.selectedToolIds],useDefaults:next.useDefaults},{cancelable:!0}).defaultPrevented}restoreChildChecked(event,checked){const control=event.currentTarget;control&&(control.checked=checked)}onToolToggle(tool,e){if(e.stopPropagation(),tool.disabled||this.useDefaults)return;const selected=this.canonicalSelectedToolIds,index=selected.indexOf(tool.id),next={selectedToolIds:e.detail.checked?index>=0?selected:[...selected.slice(0,MAX_NORMALIZED_TOOL_ENTRIES-1),tool.id]:index<0?selected:[...selected.slice(0,index),...selected.slice(index+1)],useDefaults:this.useDefaults};if(this.emitChange(next)){this.selectedToolIds=next.selectedToolIds,this.canonicalSelectedToolIdsCache=next.selectedToolIds,this.canonicalSelectedToolIdsSource=this.selectedToolIds;return}this.restoreChildChecked(e,this.canonicalSelectedToolIds.includes(tool.id))}categoryId(category){let id=this.categoryIds.get(category);return id||(id=nextId("tool-select-dialog-category"),this.categoryIds.set(category,id)),id}get canonicalTools(){return this.canonicalToolsCache||(this.canonicalToolsCache=projectCanonicalTools(this.tools)),this.canonicalToolsCache}get canonicalSelectedToolIds(){const source=this.selectedToolIds;return(this.canonicalSelectedToolIdsCache===void 0||this.canonicalSelectedToolIdsSource!==source)&&(this.canonicalSelectedToolIdsCache=projectCanonicalSelectedToolIds(source),this.canonicalSelectedToolIdsSource=source),this.canonicalSelectedToolIdsCache}get projection(){const order=[],byCategory=new Map;for(const tool of this.canonicalTools){const category=tool.category?.trim()||UNCATEGORIZED;let bucket=byCategory.get(category);bucket||(bucket=[],byCategory.set(category,bucket),category!==UNCATEGORIZED&&order.push(category)),bucket.push(tool)}byCategory.has(UNCATEGORIZED)&&order.push(UNCATEGORIZED);const q=this.query.trim().toLocaleLowerCase(this.effectiveLocale),filter=typeof this.filter=="function"?this.filter:null,matches=q?tool=>{if(!filter)return defaultFilter(tool,q,this.effectiveLocale);try{return!!filter(tool,q)}catch{return!1}}:()=>!0,matchingGroups=order.map(category=>({category,tools:byCategory.get(category).filter(matches)})).filter(group=>group.tools.length>0),totalMatches=matchingGroups.reduce((total,group)=>total+group.tools.length,0),selectedIds=new Set(this.canonicalSelectedToolIds),chosenIds=new Set;for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;selectedIds.has(tool.id)&&chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}for(const group of matchingGroups){for(const tool of group.tools){if(chosenIds.size>=this.renderedToolLimit)break;chosenIds.add(tool.id)}if(chosenIds.size>=this.renderedToolLimit)break}const groups=matchingGroups.map(group=>({category:group.category,tools:group.tools.filter(tool=>chosenIds.has(tool.id))})).filter(group=>group.tools.length>0),renderedCount=chosenIds.size;return{groups,renderedCount,totalMatches,truncated:renderedCount<totalMatches}}renderTool(tool,selectedIds){const rowDisabled=!!tool.disabled||this.useDefaults;return html`
|
|
2
2
|
<li part="tool-row" ?data-disabled=${rowDisabled}>
|
|
3
3
|
<lr-checkbox
|
|
4
4
|
part="tool-checkbox"
|
|
@@ -67,6 +67,14 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
67
67
|
@focus=${this.onSearchFocus}
|
|
68
68
|
@blur=${this.onSearchBlur}
|
|
69
69
|
/>
|
|
70
|
+
${this.query?html`<button
|
|
71
|
+
part="search-clear"
|
|
72
|
+
type="button"
|
|
73
|
+
aria-label=${this.localize("clear")}
|
|
74
|
+
@click=${this.onClearSearch}
|
|
75
|
+
>
|
|
76
|
+
<span aria-hidden="true" inert>${closeIcon()}</span>
|
|
77
|
+
</button>`:nothing}
|
|
70
78
|
</div>
|
|
71
79
|
<div part="defaults-row">
|
|
72
80
|
<lr-switch
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";const styles=css`:host{--_lr-tool-select-dialog-overlay-color:var(--lr-color-overlay);z-index:var(--lr-overlay-stack-index,var(--lr-layer-modal));justify-content:center;align-items:center;padding-block-start:max(var(--lr-space-l), var(--lr-safe-area-top));padding-block-end:max(var(--lr-space-l), var(--lr-safe-area-bottom));padding-inline-start:max(var(--lr-space-l), var(--lr-safe-area-inline-start));padding-inline-end:max(var(--lr-space-l), var(--lr-safe-area-inline-end));display:none;position:fixed;inset:0}:host([open]){display:flex}[part=backdrop]{background:var(--lr-tool-select-dialog-overlay-color,var(--_lr-tool-select-dialog-overlay-color));position:absolute;inset:0}[part=panel]{inline-size:min(var(--lr-size-30rem), 100%);min-inline-size:0;max-inline-size:100%;block-size:min(var(--lr-size-38rem), 100%);background:var(--lr-color-surface-overlay);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);box-shadow:var(--lr-shadow-xl);flex-direction:column;display:flex;position:relative;overflow:hidden}[part=header]{min-inline-size:0;max-inline-size:100%;padding:var(--lr-space-l) var(--lr-space-l) 0}[part=title]{overflow-wrap:anywhere;min-inline-size:0;max-inline-size:100%;font-size:var(--lr-font-size-m);font-weight:var(--lr-font-weight-semibold);margin:0}[part=subtitle]{margin:var(--lr-space-xs) 0 0;font-size:var(--lr-font-size-sm);color:var(--lr-color-text-quiet)}[part=subtitle][hidden]{display:none}[part=search-row]{padding:var(--lr-space-m) var(--lr-space-l) 0}[part=search-input]{appearance:textfield;box-sizing:border-box;inline-size:100%;padding:var(--lr-space-s)
|
|
1
|
+
import{css}from"lit";const styles=css`:host{--_lr-tool-select-dialog-overlay-color:var(--lr-color-overlay);z-index:var(--lr-overlay-stack-index,var(--lr-layer-modal));justify-content:center;align-items:center;padding-block-start:max(var(--lr-space-l), var(--lr-safe-area-top));padding-block-end:max(var(--lr-space-l), var(--lr-safe-area-bottom));padding-inline-start:max(var(--lr-space-l), var(--lr-safe-area-inline-start));padding-inline-end:max(var(--lr-space-l), var(--lr-safe-area-inline-end));display:none;position:fixed;inset:0}:host([open]){display:flex}[part=backdrop]{background:var(--lr-tool-select-dialog-overlay-color,var(--_lr-tool-select-dialog-overlay-color));position:absolute;inset:0}[part=panel]{inline-size:min(var(--lr-size-30rem), 100%);min-inline-size:0;max-inline-size:100%;block-size:min(var(--lr-size-38rem), 100%);background:var(--lr-color-surface-overlay);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-radius);box-shadow:var(--lr-shadow-xl);flex-direction:column;display:flex;position:relative;overflow:hidden}[part=header]{min-inline-size:0;max-inline-size:100%;padding:var(--lr-space-l) var(--lr-space-l) 0}[part=title]{overflow-wrap:anywhere;min-inline-size:0;max-inline-size:100%;font-size:var(--lr-font-size-m);font-weight:var(--lr-font-weight-semibold);margin:0}[part=subtitle]{margin:var(--lr-space-xs) 0 0;font-size:var(--lr-font-size-sm);color:var(--lr-color-text-quiet)}[part=subtitle][hidden]{display:none}[part=search-row]{padding:var(--lr-space-m) var(--lr-space-l) 0;position:relative}[part=search-input]{appearance:textfield;box-sizing:border-box;inline-size:100%;padding-block: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:inherit;font:inherit;padding-inline-start:var(--lr-space-m);padding-inline-end:var(--lr-icon-button-size)}[part=search-clear]{inset-block:var(--lr-space-m) 0;min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);cursor:pointer;color:var(--lr-color-text-quiet);padding:var(--lr-space-xs);background:0 0;border:none;justify-content:center;align-items:center;display:inline-flex;position:absolute;inset-inline-end:var(--lr-space-l)}[part=search-clear]:hover{color:var(--lr-color-text)}[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:calc(-1 * var(--lr-focus-ring-width))}[part=search-input]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}:where([part=search-input]):hover{border-color:var(--lr-color-brand)}[part=search-input]::placeholder{color:var(--lr-color-text-quiet);opacity:1}[part=search-input]::-webkit-search-cancel-button,[part=search-input]::-webkit-search-decoration{appearance:none}[part=defaults-row]{gap:var(--lr-space-xs);padding:var(--lr-space-m) var(--lr-space-l);border-block-end:var(--lr-border-width-thin) solid var(--lr-color-border);flex-direction:column;display:flex}[part=defaults-hint]{font-size:var(--lr-font-size-xs);color:var(--lr-color-text-quiet);margin:0;padding-inline-start:calc(var(--lr-size-2-25rem) + var(--lr-space-s))}[part=body]{min-block-size:0;min-inline-size:0;max-inline-size:100%;padding:var(--lr-space-m) var(--lr-space-l) var(--lr-space-l);flex:auto;overflow:auto}[part=body]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:calc(-1 * var(--lr-focus-ring-width))}:where([part=body]):hover{outline:var(--lr-border-width-thin) solid var(--lr-color-border);outline-offset:calc(-1 * var(--lr-border-width-thin))}[part=empty]{padding:var(--lr-space-l) 0;color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-md-sm);text-align:center;margin:0}[part=limit]{justify-content:space-between;align-items:center;gap:var(--lr-space-s);min-inline-size:0;max-inline-size:100%;border-block-start:var(--lr-border-width-thin) solid var(--lr-color-border);color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-sm);overflow-wrap:anywhere;flex-wrap:wrap;margin-block-start:var(--lr-space-l);padding-block-start:var(--lr-space-m);display:flex}[part=load-more]{min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);max-inline-size:100%;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;overflow-wrap:anywhere;cursor:pointer}[part=load-more]:hover{border-color:var(--lr-color-brand);background:var(--lr-color-brand-quiet)}[part=load-more]:active{background:color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active))}[part=load-more]:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}[part=category]{min-inline-size:0;max-inline-size:100%;margin-block-end:var(--lr-space-l)}[part=category]:last-child{margin-block-end:0}[part=category-heading]{align-items:baseline;gap:var(--lr-space-xs);min-inline-size:0;max-inline-size:100%;margin:0 0 var(--lr-space-s);font-size:var(--lr-font-size-xs);font-weight:var(--lr-font-weight-bold);text-transform:uppercase;letter-spacing:var(--lr-size-0-04em);color:var(--lr-color-text-quiet);overflow-wrap:anywhere;flex-wrap:wrap;display:flex}[part=category-count]{font-weight:var(--lr-font-weight-normal);text-transform:none;letter-spacing:normal}[part=category-list]{gap:var(--lr-space-s);flex-direction:column;min-inline-size:0;max-inline-size:100%;margin:0;padding:0;list-style:none;display:flex}[part=tool-row]{gap:var(--lr-space-xs);flex-direction:column;min-inline-size:0;max-inline-size:100%;display:flex}[part=tool-checkbox]{inline-size:100%;min-inline-size:0;max-inline-size:100%;display:block}[part=tool-checkbox]::part(base){box-sizing:border-box;align-items:flex-start;inline-size:100%;min-inline-size:0;max-inline-size:100%}[part=tool-checkbox]::part(label),[part=tool-checkbox]::part(hint){gap:var(--lr-size-0-125rem);flex-direction:column;display:flex}[part=tool-name]{align-items:center;gap:var(--lr-space-xs);font-size:var(--lr-font-size-md-sm);font-weight:var(--lr-font-weight-semibold);color:var(--lr-color-text);overflow-wrap:anywhere;min-inline-size:0;max-inline-size:100%;display:inline-flex}[part=tool-icon]{line-height:var(--lr-line-height-none)}[part=tool-description]{overflow-wrap:anywhere;min-inline-size:0;max-inline-size:100%;font-size:var(--lr-font-size-sm);color:var(--lr-color-text-quiet);display:block}[part=tool-disabled-reason]{min-inline-size:0;max-inline-size:100%;font-size:var(--lr-font-size-xs);color:var(--lr-color-warning);overflow-wrap:anywhere;display:block}[part=footer]{justify-content:flex-end;align-items:center;gap:var(--lr-space-s);box-sizing:border-box;min-inline-size:0;max-inline-size:100%;padding:var(--lr-space-m) var(--lr-space-l);border-block-start:var(--lr-border-width-thin) solid var(--lr-color-border);overflow-wrap:anywhere;flex-wrap:wrap;display:flex}[part=footer] ::slotted(*){white-space:normal;overflow-wrap:anywhere;flex:0 auto;min-inline-size:0;max-inline-size:100%}[part=footer][hidden]{display:none}`;export{styles};
|
|
@@ -28,6 +28,34 @@ export interface LyraBoxPlotPointDetail{datasetIndex:number;index:number;label:s
|
|
|
28
28
|
* @cssprop --lr-box-plot-data-table-toggle-active-bg - Pressed background of the `dataTableToggle`
|
|
29
29
|
* disclosure button; defaults to a mix of the hover background with the shared active mix
|
|
30
30
|
* partner.
|
|
31
|
+
* @cssprop [--lr-box-plot-border-width=var(--lr-border-width-thin)] - Canvas box-outline stroke
|
|
32
|
+
* width, in pixels. Same override mechanism as `<lr-chart>`'s `--border-width`.
|
|
33
|
+
* @cssprop [--lr-box-plot-item-radius=0] - Radius, in pixels, of the individual raw-sample dots
|
|
34
|
+
* drawn alongside each box; `0` (the default) disables them.
|
|
35
|
+
* @cssprop [--lr-box-plot-border-color-1=var(--lr-color-chart-1)] - First series box-outline color.
|
|
36
|
+
* @cssprop [--lr-box-plot-border-color-2=var(--lr-color-chart-2)] - Second series box-outline color.
|
|
37
|
+
* @cssprop [--lr-box-plot-border-color-3=var(--lr-color-chart-3)] - Third series box-outline color.
|
|
38
|
+
* @cssprop [--lr-box-plot-border-color-4=var(--lr-color-chart-4)] - Fourth series box-outline color.
|
|
39
|
+
* @cssprop [--lr-box-plot-border-color-5=var(--lr-color-chart-5)] - Fifth series box-outline color.
|
|
40
|
+
* @cssprop [--lr-box-plot-border-color-6=var(--lr-color-chart-6)] - Sixth series box-outline color.
|
|
41
|
+
* @cssprop [--lr-box-plot-border-color-7=var(--lr-color-chart-7)] - Seventh series box-outline color.
|
|
42
|
+
* @cssprop [--lr-box-plot-border-color-8=var(--lr-color-chart-8)] - Eighth series box-outline color.
|
|
43
|
+
* @cssprop [--lr-box-plot-fill-color-1=var(--lr-color-chart-1)] - First series box-fill and
|
|
44
|
+
* legend-swatch color.
|
|
45
|
+
* @cssprop [--lr-box-plot-fill-color-2=var(--lr-color-chart-2)] - Second series box-fill and
|
|
46
|
+
* legend-swatch color.
|
|
47
|
+
* @cssprop [--lr-box-plot-fill-color-3=var(--lr-color-chart-3)] - Third series box-fill and
|
|
48
|
+
* legend-swatch color.
|
|
49
|
+
* @cssprop [--lr-box-plot-fill-color-4=var(--lr-color-chart-4)] - Fourth series box-fill and
|
|
50
|
+
* legend-swatch color.
|
|
51
|
+
* @cssprop [--lr-box-plot-fill-color-5=var(--lr-color-chart-5)] - Fifth series box-fill and
|
|
52
|
+
* legend-swatch color.
|
|
53
|
+
* @cssprop [--lr-box-plot-fill-color-6=var(--lr-color-chart-6)] - Sixth series box-fill and
|
|
54
|
+
* legend-swatch color.
|
|
55
|
+
* @cssprop [--lr-box-plot-fill-color-7=var(--lr-color-chart-7)] - Seventh series box-fill and
|
|
56
|
+
* legend-swatch color.
|
|
57
|
+
* @cssprop [--lr-box-plot-fill-color-8=var(--lr-color-chart-8)] - Eighth series box-fill and
|
|
58
|
+
* legend-swatch color.
|
|
31
59
|
* @csspart error - Static visible error shown instead of the canvas when the optional box-plot
|
|
32
60
|
* peer fails to load; its transition is announced through a shared light-DOM alert.
|
|
33
61
|
* @csspart data-truncation - Explanation shown when the generated accessible alternative samples
|
|
@@ -67,8 +95,17 @@ export declare class LyraBoxPlot extends LyraElement<LyraBoxPlotEventMap>{protec
|
|
|
67
95
|
/** Series with an array `data` payload. Malformed entries are dropped without hiding siblings. */
|
|
68
96
|
get datasets():readonly LyraBoxPlotSeries[];set datasets(value:readonly LyraBoxPlotSeries[]);
|
|
69
97
|
/** Complete controlled legend visibility state. `undefined` keeps the default all-visible state. */
|
|
70
|
-
hiddenDatasets?:readonly number[];
|
|
71
|
-
/**
|
|
98
|
+
hiddenDatasets?:readonly number[];
|
|
99
|
+
/**
|
|
100
|
+
* Deliberately opt-in (default `false`), unlike `lr-chart`'s negative-polarity
|
|
101
|
+
* `withoutLegend` (legend shown by default): a box plot's single/few-series comparison usage is
|
|
102
|
+
* more often legend-redundant (category labels already identify each box) than `lr-chart`'s
|
|
103
|
+
* typical multi-dataset case.
|
|
104
|
+
*/
|
|
105
|
+
legend:boolean;
|
|
106
|
+
/** Logical placement for the optional DOM legend. Deliberately `'bottom'`, unlike `lr-chart`'s
|
|
107
|
+
* `'top'` default -- shared with `lr-lite-chart` via `chart-chrome.ts`'s
|
|
108
|
+
* `normalizeChartChromeLegendPosition()` default. */
|
|
72
109
|
legendPosition:LyraChartChromeLegendPosition;height:string;yLabel:string;beginAtZero:boolean;
|
|
73
110
|
/** Accessible chart name. A host `aria-label` wins. */
|
|
74
111
|
label:string|null;
|
|
@@ -125,6 +162,17 @@ private themeColors;
|
|
|
125
162
|
/** The series color for a box index, honoring an explicit per-series `color` override. */
|
|
126
163
|
private seriesColor;
|
|
127
164
|
/**
|
|
165
|
+
* `seriesColor()`, then layered with a `--lr-box-plot-border-color-N` CSS override (`N` 1-8,
|
|
166
|
+
* wrapping like the underlying `--lr-color-chart-N` ramp) — mirrors `<lr-chart>`'s
|
|
167
|
+
* `--border-color-N`/`--fill-color-N` palette-override mechanism for the canvas box outline.
|
|
168
|
+
*/
|
|
169
|
+
private seriesBorderColor;
|
|
170
|
+
/**
|
|
171
|
+
* `seriesColor()`, then layered with a `--lr-box-plot-fill-color-N` CSS override for the canvas
|
|
172
|
+
* box fill and the matching legend swatch.
|
|
173
|
+
*/
|
|
174
|
+
private seriesFillColor;
|
|
175
|
+
/**
|
|
128
176
|
* The forced-colors texture painted over a box's fill, or `undefined` while the user is on a
|
|
129
177
|
* normal palette. Mirrors `<lr-chart>`'s accommodation for its proportional types: forced-colors
|
|
130
178
|
* mode collapses the eight-color `--lr-color-chart-*` ramp onto a repeating three-value system
|
|
@@ -133,7 +181,15 @@ private seriesColor;
|
|
|
133
181
|
* the channel available here — the peer's element has no border-dash or point-style option to
|
|
134
182
|
* cycle the way a Chart.js line dataset does.
|
|
135
183
|
*/
|
|
136
|
-
private forcedColorFill;private styleColor;
|
|
184
|
+
private forcedColorFill;private styleColor;
|
|
185
|
+
/**
|
|
186
|
+
* Resolves a themeable numeric geometry token the same way `themeColors()`/`styleColor()`
|
|
187
|
+
* resolve color tokens — via `getComputedStyle` on every draw, since the peer renders to canvas
|
|
188
|
+
* and can't consume a CSS `var()` directly. `fallbackToken`, when given, is tried before the
|
|
189
|
+
* hard-coded `fallback` so the token can itself default to a `--lr-*` design token (mirrors
|
|
190
|
+
* `LyraChart.styleNumber()`).
|
|
191
|
+
*/
|
|
192
|
+
private styleNumber;private buildConfig;private draw;private drawIfVisible;
|
|
137
193
|
/**
|
|
138
194
|
* A sibling `<lr-chart>` registering `chartjs-plugin-annotation` globally leaves this instance
|
|
139
195
|
* without the plugin's per-chart state (created only in `beforeInit`), so the plugin would throw
|
|
@@ -141,7 +197,11 @@ private forcedColorFill;private styleColor;private buildConfig;private draw;priv
|
|
|
141
197
|
*/
|
|
142
198
|
private rebuildAfterAnnotationRegistration;
|
|
143
199
|
/** Re-reads canvas theme custom properties after an out-of-band ancestor theme change. */
|
|
144
|
-
refreshTheme():void;
|
|
200
|
+
refreshTheme():void;
|
|
201
|
+
/** A blank/missing `series.label` must never reach an accessible name (legend toggle) or a
|
|
202
|
+
* rendered cell as empty text -- mirrors `LyraChart.datasetLabel()`'s fallback shape, reusing
|
|
203
|
+
* this file's own existing `chartSeriesLabel` fallback (see `markAnnouncement()`). */
|
|
204
|
+
private seriesDisplayLabel;private formatValue;
|
|
145
205
|
/** Returns a spreadsheet-safe CSV snapshot or the current canvas PNG data URL. */
|
|
146
206
|
exportData(format:'csv'|'png'):string;private boxPlotDescription;
|
|
147
207
|
/**
|