@aceshooting/lyra-ui 23.0.0 → 24.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -39
- package/README.md +72 -35
- package/custom-elements.json +1 -1
- package/design-tokens.json +1 -1
- package/dist/cli/lyra-rename-ledger.mjs +1 -1
- package/dist/cli/migration-contract.json +1 -1
- package/dist/cli/migration-contract.mjs +1 -1
- package/dist/cli/migration-renames.mjs +2 -2
- package/dist/cli/migration-transforms.mjs +2 -2
- package/dist/components/agent-tools/approval-queue/approval-queue.class.d.ts +1 -4
- package/dist/components/agent-tools/approval-queue/approval-queue.class.js +1 -3
- package/dist/components/agent-tools/compare-panel/compare-panel.class.d.ts +1 -4
- package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.d.ts +1 -7
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
- package/dist/components/agent-tools/context-inspector/context-inspector.class.d.ts +1 -1
- package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +2 -5
- package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -3
- package/dist/components/agent-tools/terminal/terminal.class.d.ts +1 -4
- package/dist/components/agent-tools/terminal/terminal.class.js +2 -2
- package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.d.ts +1 -7
- package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.js +1 -1
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +1 -4
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +1 -3
- package/dist/components/charts/chart/lite-chart-axis-layout.d.ts +13 -0
- package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -0
- package/dist/components/charts/chart/lite-chart.class.d.ts +1 -11
- package/dist/components/charts/chart/lite-chart.class.js +4 -4
- package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +13 -3
- package/dist/components/conversation/agent-workspace/agent-workspace.class.js +1 -2
- package/dist/components/conversation/chat-message/chat-message.class.d.ts +3 -9
- package/dist/components/conversation/chat-message/chat-message.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-core.class.d.ts +6 -8
- package/dist/components/conversation/code-block/code-block-shared.d.ts +1 -4
- package/dist/components/conversation/code-block/code-block.class.d.ts +4 -6
- package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -3
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +1 -4
- package/dist/components/conversation/markdown/markdown.class.d.ts +1 -4
- package/dist/components/conversation/message-actions/message-actions.class.d.ts +1 -4
- package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
- package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +1 -4
- package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
- package/dist/components/conversation/message-parts/message-parts.class.d.ts +2 -5
- package/dist/components/conversation/message-parts/message-parts.class.js +3 -3
- package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +2 -0
- package/dist/components/conversation/streaming-text/streaming-text-core.class.js +0 -1
- package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +2 -0
- package/dist/components/conversation/streaming-text/streaming-text.class.js +0 -1
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +6 -17
- package/dist/components/conversation/thread-list/thread-list.class.js +6 -6
- package/dist/components/data/context-meter/context-meter.class.d.ts +1 -6
- package/dist/components/data/context-meter/context-meter.class.js +1 -1
- package/dist/components/data/data-grid/data-grid.class.d.ts +0 -1
- package/dist/components/data/data-grid/data-grid.class.js +2 -2
- package/dist/components/data/document-library/document-library.class.d.ts +6 -13
- package/dist/components/data/document-library/document-library.class.js +1 -2
- package/dist/components/data/heatmap/heatmap-grid-navigation.d.ts +7 -0
- package/dist/components/data/heatmap/heatmap-grid-navigation.js +1 -0
- package/dist/components/data/heatmap/heatmap.class.d.ts +3 -23
- package/dist/components/data/heatmap/heatmap.class.js +2 -2
- package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +3 -9
- package/dist/components/data/sequence-strip/sequence-strip.class.js +3 -3
- package/dist/components/data/table/table.class.d.ts +5 -14
- package/dist/components/data/table/table.class.js +6 -6
- package/dist/components/forms/button/button.class.d.ts +2 -2
- package/dist/components/forms/button/button.class.js +9 -9
- package/dist/components/forms/combobox/combobox.class.d.ts +1 -4
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/forms/input/time-input.class.d.ts +1 -1
- package/dist/components/forms/input/time-input.class.js +1 -1
- package/dist/components/forms/select/select.class.d.ts +1 -2
- package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +3 -1
- package/dist/components/forms/swatch-picker/swatch-picker.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail-item.class.d.ts +3 -6
- package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.class.d.ts +2 -4
- package/dist/components/layout/app-rail/app-rail.class.js +1 -1
- package/dist/components/layout/app-rail-group/app-rail-group.class.d.ts +2 -6
- package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
- package/dist/components/layout/carousel/carousel.class.d.ts +1 -4
- package/dist/components/layout/carousel/carousel.class.js +2 -2
- package/dist/components/layout/command-palette/command-palette.class.js +1 -1
- package/dist/components/layout/details/details.class.d.ts +2 -4
- package/dist/components/layout/details/details.class.js +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.d.ts +3 -7
- package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/multi-split/multi-split.class.d.ts +2 -4
- package/dist/components/layout/multi-split/multi-split.class.js +1 -1
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +2 -4
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
- package/dist/components/layout/reorder-list/reorder-item.class.d.ts +1 -4
- package/dist/components/layout/reorder-list/reorder-item.class.js +2 -2
- package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +5 -9
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +5 -5
- package/dist/components/media/av-player/av-player.class.js +3 -3
- package/dist/components/media/file-input/file-input.class.d.ts +3 -6
- package/dist/components/media/file-input/file-input.class.js +3 -3
- package/dist/components/media/lightbox/lightbox.class.d.ts +11 -20
- package/dist/components/media/lightbox/lightbox.class.js +1 -1
- package/dist/components/media/map/map-data-layers.d.ts +20 -0
- package/dist/components/media/map/map-data-layers.js +1 -0
- package/dist/components/media/map/map.class.js +3 -3
- package/dist/components/media/media-time.d.ts +2 -0
- package/dist/components/media/media-time.js +1 -0
- package/dist/components/media/video/video.class.js +5 -5
- package/dist/components/media/video-playlist/video-playlist.class.js +2 -2
- package/dist/components/overlays/callout/callout.class.d.ts +2 -5
- package/dist/components/overlays/callout/callout.class.js +2 -2
- package/dist/components/overlays/dialog/dialog.class.d.ts +4 -7
- package/dist/components/overlays/dialog/dialog.class.js +2 -2
- package/dist/components/overlays/overlay/dropdown.class.d.ts +5 -10
- package/dist/components/overlays/overlay/dropdown.class.js +2 -2
- package/dist/components/overlays/overlay/popover.class.d.ts +2 -3
- package/dist/components/overlays/popup/popup.class.js +1 -1
- package/dist/components/overlays/progress/progress-bar.class.d.ts +1 -4
- package/dist/components/overlays/progress/progress-bar.class.js +2 -2
- package/dist/components/overlays/progress/progress-ring.class.d.ts +1 -4
- package/dist/components/overlays/progress/progress-ring.class.js +2 -2
- package/dist/components/overlays/progress/progress-shared.d.ts +3 -3
- package/dist/components/overlays/progress/progress-shared.js +1 -1
- package/dist/components/overlays/toast/toast-item.class.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +5 -10
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +7 -14
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +2 -3
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +2 -8
- package/dist/components/retrieval/memory-panel/memory-panel.class.js +0 -4
- package/dist/components/retrieval/rag-answer/rag-answer.class.js +1 -1
- package/dist/components/utility/export-button/export-button.class.d.ts +6 -10
- package/dist/components/utility/export-button/export-button.class.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
- package/dist/components/viewers/geojson-view/geojson-view.class.d.ts +1 -1
- package/dist/components/viewers/highlight-layer/highlight-layer-timing.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
- package/dist/events.d.ts +17 -78
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/css-motion-time.d.ts +7 -0
- package/dist/internal/css-motion-time.js +1 -0
- package/dist/internal/data-state-renderer.d.ts +1 -3
- package/dist/internal/data-state-renderer.js +1 -1
- package/dist/internal/localization-runtime.d.ts +2 -0
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/lyra-element.js +2 -2
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/looks/data.css +1 -1
- package/dist/looks/terminal.css +1 -1
- package/dist/lyra.d.ts +1 -592
- package/dist/lyra.js +1 -1
- package/dist/testing/event-factory.d.ts +2 -2
- package/dist/testing/interaction-drivers.d.ts +5 -3
- package/dist/testing/lyra-tag-event-map.js +1 -1
- package/dist/theme/looks/data.d.ts +1 -1
- package/dist/theme/looks/data.js +1 -1
- package/dist/theme/looks/terminal.d.ts +1 -1
- package/dist/theme/looks/terminal.js +1 -1
- package/dist/theme/theme.d.ts +2 -80
- package/dist/theme/theme.js +1 -1
- package/llms/components/lr-agent-workspace.md +24 -2
- package/llms/components/lr-alert.md +1 -1
- package/llms/components/lr-animation.md +1 -1
- package/llms/components/lr-app-rail.md +8 -10
- package/llms/components/lr-approval-queue.md +2 -4
- package/llms/components/lr-attachment-trigger.md +3 -4
- package/llms/components/lr-badge.md +2 -2
- package/llms/components/lr-button.md +45 -99
- package/llms/components/lr-callout.md +3 -4
- package/llms/components/lr-carousel.md +3 -5
- package/llms/components/lr-chat-message.md +1 -2
- package/llms/components/lr-claim-evidence.md +1 -1
- package/llms/components/lr-code-block-core.md +2 -2
- package/llms/components/lr-code-block.md +5 -6
- package/llms/components/lr-color-picker.md +1 -1
- package/llms/components/lr-combobox.md +5 -6
- package/llms/components/lr-compare-panel.md +2 -4
- package/llms/components/lr-confirm-bar.md +3 -7
- package/llms/components/lr-context-inspector.md +3 -2
- package/llms/components/lr-context-menu.md +2 -2
- package/llms/components/lr-context-meter.md +2 -4
- package/llms/components/lr-copy-button.md +1 -1
- package/llms/components/lr-data-grid.md +4 -7
- package/llms/components/lr-details.md +3 -3
- package/llms/components/lr-dialog.md +4 -6
- package/llms/components/lr-dock-panel.md +5 -6
- package/llms/components/lr-document-library.md +5 -7
- package/llms/components/lr-drawer.md +3 -3
- package/llms/components/lr-dropdown.md +4 -5
- package/llms/components/lr-eval-run.md +3 -5
- package/llms/components/lr-export-button.md +4 -7
- package/llms/components/lr-file-input.md +0 -5
- package/llms/components/lr-funnel.md +1 -1
- package/llms/components/lr-graph.md +3 -7
- package/llms/components/lr-icon.md +1 -1
- package/llms/components/lr-include.md +1 -1
- package/llms/components/lr-input.md +31 -79
- package/llms/components/lr-json-viewer.md +1 -1
- package/llms/components/lr-knowledge-base.md +4 -6
- package/llms/components/lr-knowledge-graph-explorer.md +2 -5
- package/llms/components/lr-known-date.md +1 -1
- package/llms/components/lr-lightbox.md +9 -7
- package/llms/components/lr-lite-chart.md +1 -5
- package/llms/components/lr-markdown-core.md +3 -4
- package/llms/components/lr-markdown.md +3 -5
- package/llms/components/lr-mcp-app.md +1 -1
- package/llms/components/lr-message-actions.md +2 -3
- package/llms/components/lr-message-feedback.md +1 -3
- package/llms/components/lr-message-parts.md +4 -5
- package/llms/components/lr-multi-split.md +8 -7
- package/llms/components/lr-native-time-input.md +1 -1
- package/llms/components/lr-navigation-menu.md +5 -5
- package/llms/components/lr-number-input.md +3 -1
- package/llms/components/lr-otp-input.md +2 -0
- package/llms/components/lr-page.md +1 -1
- package/llms/components/lr-pan-zoom.md +1 -1
- package/llms/components/lr-phone-input.md +3 -1
- package/llms/components/lr-popover.md +2 -2
- package/llms/components/lr-progress-bar.md +3 -5
- package/llms/components/lr-progress-ring.md +5 -7
- package/llms/components/lr-prompt-input.md +1 -1
- package/llms/components/lr-prompt-queue.md +1 -1
- package/llms/components/lr-prompt-studio.md +1 -1
- package/llms/components/lr-rag-eval-dashboard.md +1 -1
- package/llms/components/lr-rating.md +2 -2
- package/llms/components/lr-realtime-session.md +1 -1
- package/llms/components/lr-reorder-item.md +1 -1
- package/llms/components/lr-reorder-list.md +2 -3
- package/llms/components/lr-retrieval-compare.md +1 -1
- package/llms/components/lr-select.md +3 -1
- package/llms/components/lr-selection-toolbar.md +1 -1
- package/llms/components/lr-sequence-strip.md +3 -8
- package/llms/components/lr-span-waterfall.md +1 -1
- package/llms/components/lr-split-panel.md +1 -1
- package/llms/components/lr-streaming-text-core.md +2 -1
- package/llms/components/lr-streaming-text.md +3 -2
- package/llms/components/lr-subagent-panel.md +1 -1
- package/llms/components/lr-swatch-picker.md +7 -6
- package/llms/components/lr-switch.md +3 -1
- package/llms/components/lr-table.md +33 -85
- package/llms/components/lr-terminal.md +2 -5
- package/llms/components/lr-textarea.md +1 -1
- package/llms/components/lr-thread-list.md +8 -14
- package/llms/components/lr-time-input.md +1 -1
- package/llms/components/lr-toggle-group.md +2 -2
- package/llms/components/lr-toggle.md +1 -1
- package/llms/components/lr-tool-approval-dialog.md +4 -7
- package/llms/components/lr-tool-call-block.md +1 -1
- package/llms/components/lr-tool-timeline.md +2 -5
- package/llms/components/lr-video-playlist.md +1 -1
- package/llms/components/lr-video.md +1 -1
- package/llms/components/lr-widget-renderer.md +7 -6
- package/llms/components/lr-zoomable-frame.md +1 -1
- package/llms/index.md +3 -618
- package/llms/migration.md +614 -614
- package/llms/shared/events-and-types.md +32 -31
- package/llms/shared/frameworks-and-ssr.md +7 -3
- package/llms/shared/imports-and-registration.md +22 -22
- package/llms/shared/localization-and-rtl.md +2 -2
- package/llms/shared/native-styles-and-utilities.md +263 -0
- package/llms/shared/styles-and-tokens.md +85 -676
- package/llms/shared/testing-and-utilities.md +12 -11
- package/llms/shared/v23-to-v24-migration.md +167 -0
- package/llms/shared.md +149 -494
- package/llms/tokens.md +3 -3
- package/llms.txt +9 -4
- package/package.json +7 -311
- package/registrations.json +1 -1
- package/vscode-html-data.json +1 -1
- package/web-types.json +1 -1
- package/dist/ssr-loader.d.ts +0 -2
- package/dist/ssr-loader.js +0 -1
- package/dist/theme/presets/shadcn.d.ts +0 -22
- package/dist/theme/presets/shadcn.js +0 -1
- package/dist/theme/presets.d.ts +0 -49
- package/dist/theme/presets.js +0 -1
- package/dist/themes/shadcn.css +0 -1
|
@@ -197,9 +197,7 @@ cell?:(row:T)=>unknown;});
|
|
|
197
197
|
* `string | number` union an unparameterized table has always carried. */
|
|
198
198
|
export interface LyraTableEventMap<T=unknown,K extends string|number=string|number>{blur:CustomEvent<null>;focus:CustomEvent<null>;'lr-priority-columns-visibility-change':CustomEvent<Readonly<{visible:boolean;}>>;'lr-sort-request':CustomEvent<TableSortRequestDetail>;'lr-sort':CustomEvent<TableSortCommitDetail>;
|
|
199
199
|
/** A row was activated by pointer or Enter/Space. */
|
|
200
|
-
'lr-row-activate':CustomEvent<Readonly<{row:T;}>>;'lr-row-expand-request':CustomEvent<Readonly<{row:T;rowKey:K;expanded:boolean;}>>;'lr-row-expand-toggle':CustomEvent<Readonly<{row:T;rowKey:K;expanded:boolean;}>>;'lr-load-more':CustomEvent<null>;'lr-retry-request':CustomEvent<null>;
|
|
201
|
-
/** @deprecated Use `lr-retry-request`; removal not before 24.0.0. */
|
|
202
|
-
'lr-retry':CustomEvent<null>;'lr-selection-change':CustomEvent<Readonly<{selectedRowKeys:readonly K[];}>>;'lr-filter-change':CustomEvent<Readonly<{filterText:string;}>>;'lr-page-change':CustomEvent<Readonly<{page:number;}>>;'lr-cell-edit':CustomEvent<Readonly<{row:T;columnKey:string;value:string|number;}>>;'lr-column-resize-request':CustomEvent<Readonly<{columnKey:string;width:number;}>>;'lr-column-resize':CustomEvent<Readonly<{columnKey:string;width:number;}>>;}
|
|
200
|
+
'lr-row-activate':CustomEvent<Readonly<{row:T;}>>;'lr-row-expand-request':CustomEvent<Readonly<{row:T;rowKey:K;expanded:boolean;}>>;'lr-row-expand-toggle':CustomEvent<Readonly<{row:T;rowKey:K;expanded:boolean;}>>;'lr-load-more':CustomEvent<null>;'lr-retry-request':CustomEvent<null>;'lr-selection-change':CustomEvent<Readonly<{selectedRowKeys:readonly K[];}>>;'lr-filter-change':CustomEvent<Readonly<{filterText:string;}>>;'lr-page-change':CustomEvent<Readonly<{page:number;}>>;'lr-cell-edit':CustomEvent<Readonly<{row:T;columnKey:string;value:string|number;}>>;'lr-column-resize-request':CustomEvent<Readonly<{columnKey:string;width:number;}>>;'lr-column-resize':CustomEvent<Readonly<{columnKey:string;width:number;}>>;}
|
|
203
201
|
/**
|
|
204
202
|
* `<lr-table>` — a sort/select-aware data table.
|
|
205
203
|
*
|
|
@@ -424,7 +422,7 @@ export interface LyraTableEventMap<T=unknown,K extends string|number=string|numb
|
|
|
424
422
|
* data-empty branch above, which replace them too. Precedence when more than one state could apply
|
|
425
423
|
* at once: `loading` beats `error` beats every empty branch, so a `loading` table never flashes a
|
|
426
424
|
* stale `error`, and an `error` table never falls through to "no rows"/"no columns" copy
|
|
427
|
-
* underneath it. The retry button's `lr-retry` is cancelable: the built-in action clears `error`,
|
|
425
|
+
* underneath it. The retry button's `lr-retry-request` is cancelable: the built-in action clears `error`,
|
|
428
426
|
* and `preventDefault()` leaves it set for a consumer that owns its own retry timing.
|
|
429
427
|
*
|
|
430
428
|
* `layout` sets a floor on the `<table>`'s `table-layout`: `'fixed'` forces it even with no column
|
|
@@ -441,7 +439,6 @@ export interface LyraTableEventMap<T=unknown,K extends string|number=string|numb
|
|
|
441
439
|
* @event lr-row-activate - A row was activated by pointer or Enter/Space. `detail: { row }`.
|
|
442
440
|
* @event lr-load-more - The "load more" control was activated.
|
|
443
441
|
* @event lr-retry-request - Cancelable retry proposal before the default retry action. `detail: null`.
|
|
444
|
-
* @event lr-retry - Deprecated veto alias of `lr-retry-request`; removal not before 24.0.0.
|
|
445
442
|
* The built-in `[part='retry-button']` was activated, only rendered while
|
|
446
443
|
* `error` is set. Cancelable: the default action clears `error`; `preventDefault()` leaves it
|
|
447
444
|
* set instead.
|
|
@@ -680,16 +677,10 @@ sortMode:TableSortMode;
|
|
|
680
677
|
* overrides a direction the user just chose for the column they are still on. Defaults to
|
|
681
678
|
* `'asc'`; set `'desc'` for a most-recent-first or highest-first table. */
|
|
682
679
|
defaultSortDir:TableSortDirection;
|
|
683
|
-
/** Compatibility accessible-name fallback for the grid. Host `aria-label` wins by presence,
|
|
684
|
-
* including the empty string. Without a host name, an explicitly empty compatibility value
|
|
685
|
-
* remains a real override; omitted names let the caption name the grid.
|
|
686
|
-
* @deprecated Use the host `aria-label` or native `ariaLabel` property; removal not before 24.0.0.
|
|
687
|
-
*/
|
|
688
|
-
get accessibleLabel():string|undefined;set accessibleLabel(value:string|undefined);private legacyAccessibleLabel?;
|
|
689
680
|
/** The canonical host accessible name. Presence wins, including an explicitly empty string. */
|
|
690
|
-
private hostAccessibleLabel;
|
|
681
|
+
private hostAccessibleLabel;
|
|
691
682
|
/** Optional visible caption rendered as the table's `<caption>`. Also names the grid (via
|
|
692
|
-
* `aria-labelledby`) when no
|
|
683
|
+
* `aria-labelledby`) when no host `aria-label` is set. Consumer-supplied
|
|
693
684
|
* text, not localized. */
|
|
694
685
|
caption:string;
|
|
695
686
|
/** Stable id for the `<caption>`, so `aria-labelledby` can point at it. */
|
|
@@ -1409,7 +1400,7 @@ private emptyCompactFor;
|
|
|
1409
1400
|
* error branch in `render()` so the two cannot drift in copy, parts, or slot name -- both go
|
|
1410
1401
|
* through the shared {@link renderDataState} ladder renderer (`internal/data-state-renderer.ts`),
|
|
1411
1402
|
* which owns the `error`-prefixed part naming, the `error` slot wrapping, and the cancelable
|
|
1412
|
-
* `lr-retry` request/commit pair. `compactDefault` differs between callers: the row sits inside
|
|
1403
|
+
* `lr-retry-request` request/commit pair. `compactDefault` differs between callers: the row sits inside
|
|
1413
1404
|
* an existing grid and defaults to compact, while the standalone branch owns the whole component
|
|
1414
1405
|
* box and matches the other full-area empty states. */
|
|
1415
1406
|
private renderErrorContent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/dev-mode-attribute-warning.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isRtl}from"../../../internal/rtl.js";import{srOnly,nextId}from"../../../internal/a11y.js";import{finiteCount,finiteInteger,finiteRatio}from"../../../internal/numbers.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import{resolveCssTokenLength}from"../../../internal/css-token-length.js";import{getCollator,getNumberFormat}from"../../../internal/intl-cache.js";import{readPersistedState,writePersistedState}from"../../../internal/persisted-state.js";import{definePersistedProperty,isPersistedPropertyExplicitlySet}from"../../../internal/persisted-restore.js";import{styles}from"./table.styles.js";import{chevronIcon,closeIcon,sortIcon}from"../../../internal/icons.js";import{minMax}from"../heatmap/heatmap-scale.js";import"../../overlays/empty/empty.class.js";import{literalSetConverter,trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{normalizeSize,optionalSizeConverter}from"../../../internal/variants.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{renderDataState}from"../../../internal/data-state-renderer.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_expand,LYRA_DEFAULT_loadMore,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noColumns,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_resizeColumn,LYRA_DEFAULT_resizeValuePixels,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_showAllColumns,LYRA_DEFAULT_showFewerColumns,LYRA_DEFAULT_tableEditCell,LYRA_DEFAULT_tableFilterLabel,LYRA_DEFAULT_tableFilterPlaceholder,LYRA_DEFAULT_tableLoadFailed,LYRA_DEFAULT_tableLoading}from"../../../internal/default-strings.generated.js";const DEFAULT_SKELETON_ROWS=3,MAX_SKELETON_ROWS=20,DEFAULT_PAGE_SIZE=100,MAX_PAGE_SIZE=500,MAX_TABLE_COLLECTION_ENTRIES=1e4,TABLE_SCROLL_OVERFLOW_TOLERANCE_PX=1,DEFAULT_RESIZE_MIN_WIDTH_PX=48,UNBOUNDED_RESIZE_ARIA_MAX=Number.MAX_SAFE_INTEGER,MISSING_CELL_RENDERER_WARNING="lyra-table-missing-cell-renderer",MISSING_ACCESSIBLE_NAME_WARNING="lyra-table-missing-accessible-name",INERT_PRIORITY_COLUMN_CONFIG_WARNING="lyra-table-inert-priority-column-config";function frozenArray(values){const snapshot=[];try{for(const value of values)if(snapshot.push(value),snapshot.length>=MAX_TABLE_COLLECTION_ENTRIES)break}catch{}return Object.freeze(snapshot)}function keySet(values){const snapshot=new Set;try{for(const value of values){if(typeof value=="string"){if(value.trim().length===0)continue}else if(typeof value!="number")continue;if(snapshot.add(value),snapshot.size>=MAX_TABLE_COLLECTION_ENTRIES)break}}catch{}return snapshot}function readonlyKeySet(values){const snapshot=keySet(values);let facade;return facade={get size(){return snapshot.size},has:value=>snapshot.has(value),entries:()=>snapshot.entries(),keys:()=>snapshot.keys(),values:()=>snapshot.values(),[Symbol.iterator]:()=>snapshot[Symbol.iterator](),forEach(callback,thisArg){snapshot.forEach(value=>callback.call(thisArg,value,value,facade))}},Object.freeze(facade)}const UNSAFE_CSS_STRUCTURE=/[;{}]/,URL_FUNCTION=/url\s*\(/i,SAFE_STYLE_PROPERTY=/^-?[_a-zA-Z][\w-]*$|^--[a-zA-Z0-9_-]+$/,COMPACT_EMPTY_SIZES=new Set(["2xs","xs","s"]),isCompactEmptySize=size=>COMPACT_EMPTY_SIZES.has(normalizeSize(size)),TABLE_LAYOUT=literalSetConverter(["auto","fixed"],"auto"),INTERACTIVE_SELECTOR='button, a[href], input, select, textarea, summary, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"]), [role="button"], [role="checkbox"], [role="combobox"], [role="listbox"], [role="menu"], [role="menuitem"], [role="option"], [role="radio"], [role="separator"], [role="slider"], [role="spinbutton"], [role="switch"], [role="tab"], [role="textbox"]';function stickyDirection(sticky){if(sticky==="start"||sticky==="end")return sticky}function sanitizeCellStyle(cellStyle){if(cellStyle===void 0)return{};const safe={};for(const[rawProperty,rawValue]of Object.entries(cellStyle)){const property2=sanitizeCellStyleProperty(rawProperty),value=sanitizeCellStyleValue(rawValue);if(property2===void 0||value===void 0)continue;const normalizedProperty=normalizeStyleProperty(property2);(normalizedProperty.startsWith("--")||cssSupports(normalizedProperty,value))&&(safe[normalizedProperty]=value)}return safe}function sanitizeCellStyleProperty(property2){const normalized=property2.trim();if(!(!normalized||!SAFE_STYLE_PROPERTY.test(normalized)))return normalized}function normalizeStyleProperty(property2){return property2.startsWith("--")?property2:property2.replace(/[A-Z]/g,"-$&").toLowerCase()}function sanitizeCellStyleValue(value){if(typeof value!="string")return;const normalized=value.trim();if(!(!normalized||UNSAFE_CSS_STRUCTURE.test(normalized)||URL_FUNCTION.test(normalized)))return normalized}function cssSupports(property2,value){return typeof CSS>"u"||typeof CSS.supports!="function"?!0:CSS.supports(property2,value)}function normalizedEditTrigger(editTrigger){if(editTrigger==="always"||editTrigger==="double-click")return editTrigger}function encodeKey(key){return`${typeof key}:${key}`}function safeStringifyForFilter(row){const seen=new WeakSet;try{return JSON.stringify(row,(_key,value)=>{if(typeof value=="bigint")return value.toString();if(typeof value=="object"&&value!==null){if(seen.has(value))return"[Circular]";seen.add(value)}return value})??""}catch{return""}}function asElement(value){return typeof value!="object"||!("nodeType"in value)||value.nodeType!==1||!("matches"in value)?null:value}function eventInteractiveTarget(event,boundary){for(const value of event.composedPath()){if(value===boundary)break;const element=asElement(value);if(element!==null&&(element.matches("[data-table-interactive]")||element.matches(INTERACTIVE_SELECTOR)&&!element.matches("[data-row-key], th[data-col-key]")))return element}return null}class LyraTable extends LyraElement{constructor(){super(...arguments),this._columns=Object.freeze([]),this._rows=Object.freeze([]),this._layout="auto",this.sortKey="",this.sortDir="asc",this.sortIndicators="active",this.sortMode="client",this.defaultSortDir="asc",this.hostAccessibleLabel=null,this.caption="",this.captionId=nextId("lr-table-caption"),this.selectionMode="none",this.expansionMode="none",this.scrollMode="self",this._selectedKeys=new Set,this.filterable=!1,this.filterText="",this.spellcheck=!0,this.autocapitalize="",this.autoCorrect="",this.loading=!1,this.loadingAppearance="spinner",this.skeletonRows=0,this.pageSize=DEFAULT_PAGE_SIZE,this.page=1,this.totalItems=-1,this.paginationMode="client",this.unknownTotal=!1,this.hasNext=!0,this._expandedKeys=new Set,this.hasMore=!1,this.error=!1,this.errorDescription="",this.announce=!1,this.emptyDescription="",this.emptyColumnsDescription="",this.hasHiddenPriorityColumns=!1,this.priorityToggleAvailable=!1,this.persistReady=!1,this.firstUpdateAnnouncementsReady=!1,this.activeColKey=null,this.activeRowKey=null,this.editingCell=null,this.focusedEditorCell=null,this.editorHadFocusBeforeUpdate=!1,this.rovingFocusSnapshot=null,this._resizedColumnWidths=new Map,this.resizeWriteGuard=new VetoWriteGuard,this.rowsByKey=new Map,this.columnsByKey=new Map,this.layoutFrame=null,this.observedHeaders=new Set,this.priorityTierNaturalWidth=new Map,this.priorityTierHiddenAllocation=new Map,this.priorityTierRevealAllocation=new Map,this.onResizePointerDown=event=>{const handle=event.currentTarget,key=handle.dataset.colKey,column=key?this.columnsByKey.get(key):void 0,header=handle.closest("th[data-col-key]"),resizeEventWindow=this.ownerDocument.defaultView;if(!key||!column||!header||!resizeEventWindow)return;const replacedStartWidth=this.resizeState?.key===key?this.resizeState.startWidth:void 0;this.cancelResizeGesture();const minWidth=this.minimumResizeWidth(column);this.resizeState={key,pointerId:event.pointerId,startX:event.clientX,startWidth:replacedStartWidth??header.getBoundingClientRect().width,minWidth,maxWidth:this.maximumResizeWidth(column,minWidth),handle,previousWidth:this.resizedColumnWidths.get(key)},handle.toggleAttribute("data-resizing",!0),event.preventDefault(),event.stopPropagation(),handle.setPointerCapture?.(event.pointerId),this.resizeEventWindow=resizeEventWindow,resizeEventWindow.addEventListener("pointermove",this.onResizePointerMove),resizeEventWindow.addEventListener("pointerup",this.onResizePointerEnd),resizeEventWindow.addEventListener("pointercancel",this.onResizePointerEnd),resizeEventWindow.addEventListener("lostpointercapture",this.onResizePointerEnd)},this.onResizePointerMove=event=>{const state2=this.resizeState;if(!state2||event.pointerId!==state2.pointerId)return;const delta=isRtl(this)?state2.startX-event.clientX:event.clientX-state2.startX,width=Math.min(state2.maxWidth,Math.max(state2.minWidth,state2.startWidth+delta));this.resizedColumnWidths.get(state2.key)!==width&&(this.resizedColumnWidths=new Map(this.resizedColumnWidths).set(state2.key,width),this.emit("lr-column-resize",Object.freeze({columnKey:state2.key,width})))},this.onResizeKeyDown=event=>{const handle=event.currentTarget,key=handle.dataset.colKey,column=key?this.columnsByKey.get(key):void 0;if(!column)return;const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),currentWidth=this.currentResizeWidth(column,handle),step=event.shiftKey?50:10;let requestedWidth;event.key==="Home"?requestedWidth=minWidth:event.key==="End"&&Number.isFinite(maxWidth)?requestedWidth=maxWidth:event.key==="ArrowLeft"?requestedWidth=currentWidth+(isRtl(this)?step:-step):event.key==="ArrowRight"&&(requestedWidth=currentWidth+(isRtl(this)?-step:step)),requestedWidth!==void 0&&(event.preventDefault(),event.stopPropagation(),this.resizeColumnTo(column,requestedWidth))},this.onResizePointerEnd=event=>{const state2=this.resizeState;if(!state2||event.pointerId!==state2.pointerId)return;if(state2.handle.removeAttribute("data-resizing"),event.type==="pointerup")try{state2.handle.releasePointerCapture?.(event.pointerId)}catch{}if(this.resizeState=void 0,this.detachResizePointerListeners(),event.type!=="pointerup"){const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted;return}const committedWidth=this.resizedColumnWidths.get(state2.key);if(committedWidth===void 0||committedWidth===state2.previousWidth)return;this.resizeWriteGuard.open();const request=this.emit("lr-column-resize-request",Object.freeze({columnKey:state2.key,width:committedWidth}),{cancelable:!0});if(!this.resizeWriteGuard.touched){if(request.defaultPrevented){this.rollbackResizePreview(state2);return}this.emit("lr-column-resize",Object.freeze({columnKey:state2.key,width:committedWidth}))}},this.scheduleLayoutSync=()=>{if(this.layoutFrame)return;const owner=this.ownerDocument.defaultView;if(!owner)return;const frame={owner,handle:0};frame.handle=owner.requestAnimationFrame(()=>{this.layoutFrame===frame&&(this.layoutFrame=null,!(!this.isConnected||this.ownerDocument.defaultView!==owner)&&(this.syncAutoScrollMode(),this.recomputeHiddenPriorityColumns(),this.applyStickyOffsets(),this.syncResizeHandleValues()))}),this.layoutFrame=frame},this.cachedCanonicalRowEntries=null,this.canonicalRowEntriesInputs=null,this.cachedMatchingEntries=null,this.matchingEntriesInputs=null,this.cachedSortedEntries=null,this.sortedEntriesInputs=null,this.onFilterInput=event=>{event.stopPropagation();const input=event.currentTarget;this.filterText=input.value,this.emit("lr-filter-change",Object.freeze({filterText:this.filterText}))},this.onClearFilter=()=>{this.filterText!==""&&(this.filterText="",this.emit("lr-filter-change",Object.freeze({filterText:""})),this.renderRoot.querySelector('[part="filter"]')?.focus())},this.stopOwnedEvent=event=>{event.stopPropagation()},this.onNativeFocus=event=>{event.stopPropagation(),this.emit("focus")},this.onNativeBlur=event=>{event.stopPropagation(),this.emit("blur")},this.onPaginationChange=event=>{event.stopPropagation();const{page}=event.detail;this.paginationMode==="client"&&(this.page=page),this.emit("lr-page-change",Object.freeze({page}))},this.onTableFocusIn=event=>{const target=event.target,cell=target?.closest?.("td[data-col-key]"),row=target?.closest?.("[data-row-key]"),columnKey=cell?.dataset.colKey,rowKey=row?.dataset.rowKey;this.focusedEditorCell=target?.getAttribute("part")==="cell-editor"&&columnKey!==void 0&&rowKey!==void 0&&normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="always"?{rowKey,columnKey}:null},this.onEditorKeyDown=(event,rowKey,columnKey)=>{event.stopPropagation();const alwaysOn=normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="always";event.key==="Enter"?(event.preventDefault(),this.commitEdit(event,rowKey,columnKey)):event.key==="Escape"&&!alwaysOn&&(event.preventDefault(),this.editingCell=null)},this.onTableDoubleClick=event=>{const target=event.target,table=event.currentTarget;if(eventInteractiveTarget(event,table))return;const cell=target.closest('[part="cell"][data-col-key]'),row=target.closest("[data-row-key]");cell&&row?.dataset.rowKey&&cell.dataset.colKey&&this.startEditing(row.dataset.rowKey,cell.dataset.colKey)},this.toggleColumns=()=>{this.priorityColumnsVisible=!this.priorityColumnsVisible,this.emit("lr-priority-columns-visibility-change",Object.freeze({visible:this.priorityColumnsVisible}))},this.onTableClick=e=>{const target=e.target,table=e.currentTarget;if(eventInteractiveTarget(e,table))return;const th=target.closest("th[data-col-key]");if(th)return this.activateColumn(th.dataset.colKey);const tr=target.closest("[data-row-key]");tr&&this.activateRow(tr.dataset.rowKey)},this.onTableKeyDown=e=>{const target=e.target,table=e.currentTarget;if(eventInteractiveTarget(e,table))return;const th=target.closest("th[data-col-key]");if(th)return this.onHeaderKeyDown(e,th);const tr=target.closest("[data-row-key]");tr&&this.onRowKeyDown(e,tr)}}static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,expand:LYRA_DEFAULT_expand,loadMore:LYRA_DEFAULT_loadMore,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noColumns:LYRA_DEFAULT_noColumns,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,resizeColumn:LYRA_DEFAULT_resizeColumn,resizeValuePixels:LYRA_DEFAULT_resizeValuePixels,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,showAllColumns:LYRA_DEFAULT_showAllColumns,showFewerColumns:LYRA_DEFAULT_showFewerColumns,tableEditCell:LYRA_DEFAULT_tableEditCell,tableFilterLabel:LYRA_DEFAULT_tableFilterLabel,tableFilterPlaceholder:LYRA_DEFAULT_tableFilterPlaceholder,tableLoadFailed:LYRA_DEFAULT_tableLoadFailed,tableLoading:LYRA_DEFAULT_tableLoading}}static{this.styles=[LyraElement.styles,styles,srOnly]}get columns(){return this._columns}set columns(value){const previous=this._columns,columns=[],seen=new Set;let length=0;try{if(Array.isArray(value)){const descriptor=Object.getOwnPropertyDescriptor(value,"length"),sourceLength=descriptor&&"value"in descriptor?descriptor.value:0;typeof sourceLength=="number"&&Number.isSafeInteger(sourceLength)&&sourceLength>=0&&(length=Math.min(sourceLength,MAX_TABLE_COLLECTION_ENTRIES))}}catch{length=0}for(let index=0;index<length;index+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{continue}if(!descriptor||!("value"in descriptor))continue;const column=descriptor.value;try{const key=column?.key;if(typeof key!="string"||key.trim().length===0||seen.has(key))continue;seen.add(key),columns.push(column)}catch{}}this._columns=frozenArray(columns),this.requestUpdate("columns",previous)}get rows(){return this._rows}set rows(value){const previous=this._rows;this._rows=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("rows",previous)}get layout(){return this._layout}set layout(next){const normalized=TABLE_LAYOUT.normalizeReflected(this,"layout",next),old=this._layout;old!==normalized&&(this._layout=normalized,this.requestUpdate("layout",old))}get accessibleLabel(){return this.legacyAccessibleLabel}set accessibleLabel(value){const previous=this.legacyAccessibleLabel;this.legacyAccessibleLabel=value,value!==void 0&&!this.hasAttribute("accessible-label")&&warnDeprecatedUsage(this,"property","accessibleLabel","ariaLabel"),this.requestUpdate("accessibleLabel",previous)}attributeChangedCallback(name,previous,value){super.attributeChangedCallback(name,previous,value),name==="accessible-label"&&value!==null&&warnDeprecatedUsage(this,"attribute",name,"aria-label")}get selectedRowKeys(){return readonlyKeySet(this._selectedKeys)}set selectedRowKeys(value){const previous=this._selectedKeys;this._selectedKeys=keySet(value??[]),this.requestUpdate("selectedRowKeys",previous)}get expandedRowKeys(){return readonlyKeySet(this._expandedKeys)}set expandedRowKeys(value){const previous=this._expandedKeys;this._expandedKeys=keySet(value??[]),this.requestUpdate("expandedRowKeys",previous)}asKeySet(keys){return keys}asKeyList(keys){return keys}get emptySize(){return this._emptySize}set emptySize(value){const previous=this._emptySize,next=optionalSizeConverter.normalize(value);next!==previous&&(this._emptySize=next,this.requestUpdate("emptySize",previous))}get priorityColumnsToggleAvailable(){return this.priorityToggleAvailable}static{definePersistedProperty(this.prototype,"priorityColumnsVisible",{initial:!1,attribute:"priority-columns-visible",type:Boolean,reflect:!0})}get storageFullKey(){return this.storageKey?`lr-table:${this.storageKey}`:void 0}get resizedColumnWidths(){return this._resizedColumnWidths}set resizedColumnWidths(value){const previous=this._resizedColumnWidths;this._resizedColumnWidths=value,markVetoGuardWrite(this.resizeWriteGuard),this.requestUpdate("resizedColumnWidths",previous)}parsePixelLength(value){if(!value)return;const trimmed=value.trim();if(!trimmed.endsWith("px"))return;const parsed=Number.parseFloat(trimmed);return Number.isFinite(parsed)?parsed:void 0}minimumResizeWidth(column){const explicit=this.parsePixelLength(column.minWidth);if(explicit!==void 0)return Math.max(0,explicit);const hostStyle=this.ownerDocument.defaultView?.getComputedStyle(this),themed=hostStyle?.getPropertyValue("--lr-table-resize-min-width").trim()||hostStyle?.getPropertyValue("--_lr-table-resize-min-width-default").trim()||"",resolved=resolveCssTokenLength(themed,{host:this});return resolved===void 0?DEFAULT_RESIZE_MIN_WIDTH_PX:Math.max(0,resolved)}maximumResizeWidth(column,minWidth){const explicit=this.parsePixelLength(column.maxWidth);return explicit===void 0?Number.POSITIVE_INFINITY:Math.max(minWidth,explicit)}currentResizeWidth(column,handle){const resized=this.resizedColumnWidths.get(column.key);if(resized!==void 0)return resized;const explicit=this.parsePixelLength(column.width);if(explicit!==void 0)return explicit;const rendered=handle?.closest("th[data-col-key]")?.getBoundingClientRect().width;return rendered&&rendered>0?rendered:this.minimumResizeWidth(column)}resizeValueText(width){return this.localize("resizeValuePixels",void 0,{value:getNumberFormat(this.effectiveLocale).format(Math.round(width))})}resizeColumnTo(column,requestedWidth){const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),width=Math.min(maxWidth,Math.max(minWidth,requestedWidth));this.resizedColumnWidths.get(column.key)===width||(this.resizeWriteGuard.open(),this.emit("lr-column-resize-request",Object.freeze({columnKey:column.key,width}),{cancelable:!0}).defaultPrevented||this.resizeWriteGuard.touched)||(this.resizedColumnWidths=new Map(this.resizedColumnWidths).set(column.key,width),this.emit("lr-column-resize",Object.freeze({columnKey:column.key,width})),markVetoGuardWrite(this.resizeWriteGuard))}renderedColumnWidth(column){const resized=this.resizedColumnWidths.get(column.key);return resized===void 0?sanitizeCssLength(column.width,"height"):`${resized}px`}renderResizeHandle(column){if(!column.resizable)return nothing;const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),width=this.currentResizeWidth(column);return html`<span
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isRtl}from"../../../internal/rtl.js";import{srOnly,nextId}from"../../../internal/a11y.js";import{finiteCount,finiteInteger,finiteRatio}from"../../../internal/numbers.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import{resolveCssTokenLength}from"../../../internal/css-token-length.js";import{getCollator,getNumberFormat}from"../../../internal/intl-cache.js";import{readPersistedState,writePersistedState}from"../../../internal/persisted-state.js";import{definePersistedProperty,isPersistedPropertyExplicitlySet}from"../../../internal/persisted-restore.js";import{styles}from"./table.styles.js";import{chevronIcon,closeIcon,sortIcon}from"../../../internal/icons.js";import{minMax}from"../heatmap/heatmap-scale.js";import"../../overlays/empty/empty.class.js";import{literalSetConverter,trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{normalizeSize,optionalSizeConverter}from"../../../internal/variants.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{renderDataState}from"../../../internal/data-state-renderer.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_expand,LYRA_DEFAULT_loadMore,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noColumns,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_resizeColumn,LYRA_DEFAULT_resizeValuePixels,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_showAllColumns,LYRA_DEFAULT_showFewerColumns,LYRA_DEFAULT_tableEditCell,LYRA_DEFAULT_tableFilterLabel,LYRA_DEFAULT_tableFilterPlaceholder,LYRA_DEFAULT_tableLoadFailed,LYRA_DEFAULT_tableLoading}from"../../../internal/default-strings.generated.js";const DEFAULT_SKELETON_ROWS=3,MAX_SKELETON_ROWS=20,DEFAULT_PAGE_SIZE=100,MAX_PAGE_SIZE=500,MAX_TABLE_COLLECTION_ENTRIES=1e4,TABLE_SCROLL_OVERFLOW_TOLERANCE_PX=1,DEFAULT_RESIZE_MIN_WIDTH_PX=48,UNBOUNDED_RESIZE_ARIA_MAX=Number.MAX_SAFE_INTEGER,MISSING_CELL_RENDERER_WARNING="lyra-table-missing-cell-renderer",MISSING_ACCESSIBLE_NAME_WARNING="lyra-table-missing-accessible-name",INERT_PRIORITY_COLUMN_CONFIG_WARNING="lyra-table-inert-priority-column-config";function frozenArray(values){const snapshot=[];try{for(const value of values)if(snapshot.push(value),snapshot.length>=MAX_TABLE_COLLECTION_ENTRIES)break}catch{}return Object.freeze(snapshot)}function keySet(values){const snapshot=new Set;try{for(const value of values){if(typeof value=="string"){if(value.trim().length===0)continue}else if(typeof value!="number")continue;if(snapshot.add(value),snapshot.size>=MAX_TABLE_COLLECTION_ENTRIES)break}}catch{}return snapshot}function readonlyKeySet(values){const snapshot=keySet(values);let facade;return facade={get size(){return snapshot.size},has:value=>snapshot.has(value),entries:()=>snapshot.entries(),keys:()=>snapshot.keys(),values:()=>snapshot.values(),[Symbol.iterator]:()=>snapshot[Symbol.iterator](),forEach(callback,thisArg){snapshot.forEach(value=>callback.call(thisArg,value,value,facade))}},Object.freeze(facade)}const UNSAFE_CSS_STRUCTURE=/[;{}]/,URL_FUNCTION=/url\s*\(/i,SAFE_STYLE_PROPERTY=/^-?[_a-zA-Z][\w-]*$|^--[a-zA-Z0-9_-]+$/,COMPACT_EMPTY_SIZES=new Set(["2xs","xs","s"]),isCompactEmptySize=size=>COMPACT_EMPTY_SIZES.has(normalizeSize(size)),TABLE_LAYOUT=literalSetConverter(["auto","fixed"],"auto"),INTERACTIVE_SELECTOR='button, a[href], input, select, textarea, summary, audio[controls], video[controls], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"]), [role="button"], [role="checkbox"], [role="combobox"], [role="listbox"], [role="menu"], [role="menuitem"], [role="option"], [role="radio"], [role="separator"], [role="slider"], [role="spinbutton"], [role="switch"], [role="tab"], [role="textbox"]';function stickyDirection(sticky){if(sticky==="start"||sticky==="end")return sticky}function sanitizeCellStyle(cellStyle){if(cellStyle===void 0)return{};const safe={};for(const[rawProperty,rawValue]of Object.entries(cellStyle)){const property2=sanitizeCellStyleProperty(rawProperty),value=sanitizeCellStyleValue(rawValue);if(property2===void 0||value===void 0)continue;const normalizedProperty=normalizeStyleProperty(property2);(normalizedProperty.startsWith("--")||cssSupports(normalizedProperty,value))&&(safe[normalizedProperty]=value)}return safe}function sanitizeCellStyleProperty(property2){const normalized=property2.trim();if(!(!normalized||!SAFE_STYLE_PROPERTY.test(normalized)))return normalized}function normalizeStyleProperty(property2){return property2.startsWith("--")?property2:property2.replace(/[A-Z]/g,"-$&").toLowerCase()}function sanitizeCellStyleValue(value){if(typeof value!="string")return;const normalized=value.trim();if(!(!normalized||UNSAFE_CSS_STRUCTURE.test(normalized)||URL_FUNCTION.test(normalized)))return normalized}function cssSupports(property2,value){return typeof CSS>"u"||typeof CSS.supports!="function"?!0:CSS.supports(property2,value)}function normalizedEditTrigger(editTrigger){if(editTrigger==="always"||editTrigger==="double-click")return editTrigger}function encodeKey(key){return`${typeof key}:${key}`}function safeStringifyForFilter(row){const seen=new WeakSet;try{return JSON.stringify(row,(_key,value)=>{if(typeof value=="bigint")return value.toString();if(typeof value=="object"&&value!==null){if(seen.has(value))return"[Circular]";seen.add(value)}return value})??""}catch{return""}}function asElement(value){return typeof value!="object"||!("nodeType"in value)||value.nodeType!==1||!("matches"in value)?null:value}function eventInteractiveTarget(event,boundary){for(const value of event.composedPath()){if(value===boundary)break;const element=asElement(value);if(element!==null&&(element.matches("[data-table-interactive]")||element.matches(INTERACTIVE_SELECTOR)&&!element.matches("[data-row-key], th[data-col-key]")))return element}return null}class LyraTable extends LyraElement{constructor(){super(...arguments),this._columns=Object.freeze([]),this._rows=Object.freeze([]),this._layout="auto",this.sortKey="",this.sortDir="asc",this.sortIndicators="active",this.sortMode="client",this.defaultSortDir="asc",this.hostAccessibleLabel=null,this.caption="",this.captionId=nextId("lr-table-caption"),this.selectionMode="none",this.expansionMode="none",this.scrollMode="self",this._selectedKeys=new Set,this.filterable=!1,this.filterText="",this.spellcheck=!0,this.autocapitalize="",this.autoCorrect="",this.loading=!1,this.loadingAppearance="spinner",this.skeletonRows=0,this.pageSize=DEFAULT_PAGE_SIZE,this.page=1,this.totalItems=-1,this.paginationMode="client",this.unknownTotal=!1,this.hasNext=!0,this._expandedKeys=new Set,this.hasMore=!1,this.error=!1,this.errorDescription="",this.announce=!1,this.emptyDescription="",this.emptyColumnsDescription="",this.hasHiddenPriorityColumns=!1,this.priorityToggleAvailable=!1,this.persistReady=!1,this.firstUpdateAnnouncementsReady=!1,this.activeColKey=null,this.activeRowKey=null,this.editingCell=null,this.focusedEditorCell=null,this.editorHadFocusBeforeUpdate=!1,this.rovingFocusSnapshot=null,this._resizedColumnWidths=new Map,this.resizeWriteGuard=new VetoWriteGuard,this.rowsByKey=new Map,this.columnsByKey=new Map,this.layoutFrame=null,this.observedHeaders=new Set,this.priorityTierNaturalWidth=new Map,this.priorityTierHiddenAllocation=new Map,this.priorityTierRevealAllocation=new Map,this.onResizePointerDown=event=>{const handle=event.currentTarget,key=handle.dataset.colKey,column=key?this.columnsByKey.get(key):void 0,header=handle.closest("th[data-col-key]"),resizeEventWindow=this.ownerDocument.defaultView;if(!key||!column||!header||!resizeEventWindow)return;const replacedStartWidth=this.resizeState?.key===key?this.resizeState.startWidth:void 0;this.cancelResizeGesture();const minWidth=this.minimumResizeWidth(column);this.resizeState={key,pointerId:event.pointerId,startX:event.clientX,startWidth:replacedStartWidth??header.getBoundingClientRect().width,minWidth,maxWidth:this.maximumResizeWidth(column,minWidth),handle,previousWidth:this.resizedColumnWidths.get(key)},handle.toggleAttribute("data-resizing",!0),event.preventDefault(),event.stopPropagation(),handle.setPointerCapture?.(event.pointerId),this.resizeEventWindow=resizeEventWindow,resizeEventWindow.addEventListener("pointermove",this.onResizePointerMove),resizeEventWindow.addEventListener("pointerup",this.onResizePointerEnd),resizeEventWindow.addEventListener("pointercancel",this.onResizePointerEnd),resizeEventWindow.addEventListener("lostpointercapture",this.onResizePointerEnd)},this.onResizePointerMove=event=>{const state2=this.resizeState;if(!state2||event.pointerId!==state2.pointerId)return;const delta=isRtl(this)?state2.startX-event.clientX:event.clientX-state2.startX,width=Math.min(state2.maxWidth,Math.max(state2.minWidth,state2.startWidth+delta));this.resizedColumnWidths.get(state2.key)!==width&&(this.resizedColumnWidths=new Map(this.resizedColumnWidths).set(state2.key,width),this.emit("lr-column-resize",Object.freeze({columnKey:state2.key,width})))},this.onResizeKeyDown=event=>{const handle=event.currentTarget,key=handle.dataset.colKey,column=key?this.columnsByKey.get(key):void 0;if(!column)return;const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),currentWidth=this.currentResizeWidth(column,handle),step=event.shiftKey?50:10;let requestedWidth;event.key==="Home"?requestedWidth=minWidth:event.key==="End"&&Number.isFinite(maxWidth)?requestedWidth=maxWidth:event.key==="ArrowLeft"?requestedWidth=currentWidth+(isRtl(this)?step:-step):event.key==="ArrowRight"&&(requestedWidth=currentWidth+(isRtl(this)?-step:step)),requestedWidth!==void 0&&(event.preventDefault(),event.stopPropagation(),this.resizeColumnTo(column,requestedWidth))},this.onResizePointerEnd=event=>{const state2=this.resizeState;if(!state2||event.pointerId!==state2.pointerId)return;if(state2.handle.removeAttribute("data-resizing"),event.type==="pointerup")try{state2.handle.releasePointerCapture?.(event.pointerId)}catch{}if(this.resizeState=void 0,this.detachResizePointerListeners(),event.type!=="pointerup"){const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted;return}const committedWidth=this.resizedColumnWidths.get(state2.key);if(committedWidth===void 0||committedWidth===state2.previousWidth)return;this.resizeWriteGuard.open();const request=this.emit("lr-column-resize-request",Object.freeze({columnKey:state2.key,width:committedWidth}),{cancelable:!0});if(!this.resizeWriteGuard.touched){if(request.defaultPrevented){this.rollbackResizePreview(state2);return}this.emit("lr-column-resize",Object.freeze({columnKey:state2.key,width:committedWidth}))}},this.scheduleLayoutSync=()=>{if(this.layoutFrame)return;const owner=this.ownerDocument.defaultView;if(!owner)return;const frame={owner,handle:0};frame.handle=owner.requestAnimationFrame(()=>{this.layoutFrame===frame&&(this.layoutFrame=null,!(!this.isConnected||this.ownerDocument.defaultView!==owner)&&(this.syncAutoScrollMode(),this.recomputeHiddenPriorityColumns(),this.applyStickyOffsets(),this.syncResizeHandleValues()))}),this.layoutFrame=frame},this.cachedCanonicalRowEntries=null,this.canonicalRowEntriesInputs=null,this.cachedMatchingEntries=null,this.matchingEntriesInputs=null,this.cachedSortedEntries=null,this.sortedEntriesInputs=null,this.onFilterInput=event=>{event.stopPropagation();const input=event.currentTarget;this.filterText=input.value,this.emit("lr-filter-change",Object.freeze({filterText:this.filterText}))},this.onClearFilter=()=>{this.filterText!==""&&(this.filterText="",this.emit("lr-filter-change",Object.freeze({filterText:""})),this.renderRoot.querySelector('[part="filter"]')?.focus())},this.stopOwnedEvent=event=>{event.stopPropagation()},this.onNativeFocus=event=>{event.stopPropagation(),this.emit("focus")},this.onNativeBlur=event=>{event.stopPropagation(),this.emit("blur")},this.onPaginationChange=event=>{event.stopPropagation();const{page}=event.detail;this.paginationMode==="client"&&(this.page=page),this.emit("lr-page-change",Object.freeze({page}))},this.onTableFocusIn=event=>{const target=event.target,cell=target?.closest?.("td[data-col-key]"),row=target?.closest?.("[data-row-key]"),columnKey=cell?.dataset.colKey,rowKey=row?.dataset.rowKey;this.focusedEditorCell=target?.getAttribute("part")==="cell-editor"&&columnKey!==void 0&&rowKey!==void 0&&normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="always"?{rowKey,columnKey}:null},this.onEditorKeyDown=(event,rowKey,columnKey)=>{event.stopPropagation();const alwaysOn=normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="always";event.key==="Enter"?(event.preventDefault(),this.commitEdit(event,rowKey,columnKey)):event.key==="Escape"&&!alwaysOn&&(event.preventDefault(),this.editingCell=null)},this.onTableDoubleClick=event=>{const target=event.target,table=event.currentTarget;if(eventInteractiveTarget(event,table))return;const cell=target.closest('[part="cell"][data-col-key]'),row=target.closest("[data-row-key]");cell&&row?.dataset.rowKey&&cell.dataset.colKey&&this.startEditing(row.dataset.rowKey,cell.dataset.colKey)},this.toggleColumns=()=>{this.priorityColumnsVisible=!this.priorityColumnsVisible,this.emit("lr-priority-columns-visibility-change",Object.freeze({visible:this.priorityColumnsVisible}))},this.onTableClick=e=>{const target=e.target,table=e.currentTarget;if(eventInteractiveTarget(e,table))return;const th=target.closest("th[data-col-key]");if(th)return this.activateColumn(th.dataset.colKey);const tr=target.closest("[data-row-key]");tr&&this.activateRow(tr.dataset.rowKey)},this.onTableKeyDown=e=>{const target=e.target,table=e.currentTarget;if(eventInteractiveTarget(e,table))return;const th=target.closest("th[data-col-key]");if(th)return this.onHeaderKeyDown(e,th);const tr=target.closest("[data-row-key]");tr&&this.onRowKeyDown(e,tr)}}static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,expand:LYRA_DEFAULT_expand,loadMore:LYRA_DEFAULT_loadMore,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noColumns:LYRA_DEFAULT_noColumns,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,resizeColumn:LYRA_DEFAULT_resizeColumn,resizeValuePixels:LYRA_DEFAULT_resizeValuePixels,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,showAllColumns:LYRA_DEFAULT_showAllColumns,showFewerColumns:LYRA_DEFAULT_showFewerColumns,tableEditCell:LYRA_DEFAULT_tableEditCell,tableFilterLabel:LYRA_DEFAULT_tableFilterLabel,tableFilterPlaceholder:LYRA_DEFAULT_tableFilterPlaceholder,tableLoadFailed:LYRA_DEFAULT_tableLoadFailed,tableLoading:LYRA_DEFAULT_tableLoading}}static{this.styles=[LyraElement.styles,styles,srOnly]}get columns(){return this._columns}set columns(value){const previous=this._columns,columns=[],seen=new Set;let length=0;try{if(Array.isArray(value)){const descriptor=Object.getOwnPropertyDescriptor(value,"length"),sourceLength=descriptor&&"value"in descriptor?descriptor.value:0;typeof sourceLength=="number"&&Number.isSafeInteger(sourceLength)&&sourceLength>=0&&(length=Math.min(sourceLength,MAX_TABLE_COLLECTION_ENTRIES))}}catch{length=0}for(let index=0;index<length;index+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(value,String(index))}catch{continue}if(!descriptor||!("value"in descriptor))continue;const column=descriptor.value;try{const key=column?.key;if(typeof key!="string"||key.trim().length===0||seen.has(key))continue;seen.add(key),columns.push(column)}catch{}}this._columns=frozenArray(columns),this.requestUpdate("columns",previous)}get rows(){return this._rows}set rows(value){const previous=this._rows;this._rows=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("rows",previous)}get layout(){return this._layout}set layout(next){const normalized=TABLE_LAYOUT.normalizeReflected(this,"layout",next),old=this._layout;old!==normalized&&(this._layout=normalized,this.requestUpdate("layout",old))}get selectedRowKeys(){return readonlyKeySet(this._selectedKeys)}set selectedRowKeys(value){const previous=this._selectedKeys;this._selectedKeys=keySet(value??[]),this.requestUpdate("selectedRowKeys",previous)}get expandedRowKeys(){return readonlyKeySet(this._expandedKeys)}set expandedRowKeys(value){const previous=this._expandedKeys;this._expandedKeys=keySet(value??[]),this.requestUpdate("expandedRowKeys",previous)}asKeySet(keys){return keys}asKeyList(keys){return keys}get emptySize(){return this._emptySize}set emptySize(value){const previous=this._emptySize,next=optionalSizeConverter.normalize(value);next!==previous&&(this._emptySize=next,this.requestUpdate("emptySize",previous))}get priorityColumnsToggleAvailable(){return this.priorityToggleAvailable}static{definePersistedProperty(this.prototype,"priorityColumnsVisible",{initial:!1,attribute:"priority-columns-visible",type:Boolean,reflect:!0})}get storageFullKey(){return this.storageKey?`lr-table:${this.storageKey}`:void 0}get resizedColumnWidths(){return this._resizedColumnWidths}set resizedColumnWidths(value){const previous=this._resizedColumnWidths;this._resizedColumnWidths=value,markVetoGuardWrite(this.resizeWriteGuard),this.requestUpdate("resizedColumnWidths",previous)}parsePixelLength(value){if(!value)return;const trimmed=value.trim();if(!trimmed.endsWith("px"))return;const parsed=Number.parseFloat(trimmed);return Number.isFinite(parsed)?parsed:void 0}minimumResizeWidth(column){const explicit=this.parsePixelLength(column.minWidth);if(explicit!==void 0)return Math.max(0,explicit);const hostStyle=this.ownerDocument.defaultView?.getComputedStyle(this),themed=hostStyle?.getPropertyValue("--lr-table-resize-min-width").trim()||hostStyle?.getPropertyValue("--_lr-table-resize-min-width-default").trim()||"",resolved=resolveCssTokenLength(themed,{host:this});return resolved===void 0?DEFAULT_RESIZE_MIN_WIDTH_PX:Math.max(0,resolved)}maximumResizeWidth(column,minWidth){const explicit=this.parsePixelLength(column.maxWidth);return explicit===void 0?Number.POSITIVE_INFINITY:Math.max(minWidth,explicit)}currentResizeWidth(column,handle){const resized=this.resizedColumnWidths.get(column.key);if(resized!==void 0)return resized;const explicit=this.parsePixelLength(column.width);if(explicit!==void 0)return explicit;const rendered=handle?.closest("th[data-col-key]")?.getBoundingClientRect().width;return rendered&&rendered>0?rendered:this.minimumResizeWidth(column)}resizeValueText(width){return this.localize("resizeValuePixels",void 0,{value:getNumberFormat(this.effectiveLocale).format(Math.round(width))})}resizeColumnTo(column,requestedWidth){const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),width=Math.min(maxWidth,Math.max(minWidth,requestedWidth));this.resizedColumnWidths.get(column.key)===width||(this.resizeWriteGuard.open(),this.emit("lr-column-resize-request",Object.freeze({columnKey:column.key,width}),{cancelable:!0}).defaultPrevented||this.resizeWriteGuard.touched)||(this.resizedColumnWidths=new Map(this.resizedColumnWidths).set(column.key,width),this.emit("lr-column-resize",Object.freeze({columnKey:column.key,width})),markVetoGuardWrite(this.resizeWriteGuard))}renderedColumnWidth(column){const resized=this.resizedColumnWidths.get(column.key);return resized===void 0?sanitizeCssLength(column.width,"height"):`${resized}px`}renderResizeHandle(column){if(!column.resizable)return nothing;const minWidth=this.minimumResizeWidth(column),maxWidth=this.maximumResizeWidth(column,minWidth),width=this.currentResizeWidth(column);return html`<span
|
|
2
2
|
part="resize-handle"
|
|
3
3
|
data-col-key=${column.key}
|
|
4
4
|
role="separator"
|
|
@@ -11,7 +11,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
11
11
|
aria-valuemax=${Number.isFinite(maxWidth)?Math.round(maxWidth):UNBOUNDED_RESIZE_ARIA_MAX}
|
|
12
12
|
@pointerdown=${this.onResizePointerDown}
|
|
13
13
|
@keydown=${this.onResizeKeyDown}
|
|
14
|
-
></span>`}syncResizeHandleValues(){for(const handle of this.renderRoot.querySelectorAll('[part="resize-handle"]')){const key=handle.dataset.colKey;if(!key)continue;const column=this.columnsByKey.get(key);if(!column||this.resizedColumnWidths.has(key)||this.parsePixelLength(column.width)!==void 0)continue;const rendered=handle.closest("th[data-col-key]")?.getBoundingClientRect().width;if(rendered&&rendered>0){const width=Math.round(rendered);handle.setAttribute("aria-valuenow",String(width)),handle.setAttribute("aria-valuetext",this.resizeValueText(width))}}}detachResizePointerListeners(){const resizeEventWindow=this.resizeEventWindow;resizeEventWindow&&(resizeEventWindow.removeEventListener("pointermove",this.onResizePointerMove),resizeEventWindow.removeEventListener("pointerup",this.onResizePointerEnd),resizeEventWindow.removeEventListener("pointercancel",this.onResizePointerEnd),resizeEventWindow.removeEventListener("lostpointercapture",this.onResizePointerEnd),this.resizeEventWindow=void 0)}rollbackResizePreview(state2){const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted}cancelResizeGesture(){const state2=this.resizeState;if(this.resizeState=void 0,this.detachResizePointerListeners(),!!state2){state2.handle.removeAttribute("data-resizing");try{state2.handle.releasePointerCapture?.(state2.pointerId)}catch{}this.rollbackResizePreview(state2)}}firstUpdated(changed){super.firstUpdated(changed),!this.accessibleLabel&&!this.hasAttribute("aria-label")&&!this.caption&&devWarnOnce(MISSING_ACCESSIBLE_NAME_WARNING,"<lr-table> has no accessible name: set `accessibleLabel`, a host `aria-label`, or `caption` so assistive technology can identify the grid.")}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink();const owner=this.ownerDocument.defaultView,ResizeObserverCtor=owner?.ResizeObserver;let observer;ResizeObserverCtor&&(observer=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.resizeObserver!==observer||this.scheduleLayoutSync()})),this.resizeObserver=observer;const base=this.renderRoot?.querySelector('[part="base"]');base&&(this.observeBase(base),this.observeTable(this.renderRoot.querySelector('[part="table"]')??void 0),this.observeHeaders())}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink(),this.cancelResizeGesture(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0;const frame=this.layoutFrame;frame&&frame.owner.cancelAnimationFrame(frame.handle),this.layoutFrame=null,this.observedBase=void 0,this.observedTable=void 0,this.observedHeaders.clear()}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0,this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}))}localizedOverride(key,override){return override??this.localize(key)}loadingText(){return this.localizedOverride("tableLoading",this.loadingLabel)}observeBase(base){this.observedBase!==base&&(this.observedBase&&this.resizeObserver?.unobserve(this.observedBase),this.resizeObserver?.observe(base),this.observedBase=base)}observeTable(table){this.observedTable!==table&&(this.observedTable&&this.resizeObserver?.unobserve(this.observedTable),table&&this.resizeObserver?.observe(table),this.observedTable=table)}syncAutoScrollMode(){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return;const overflows=this.scrollMode==="auto"&&base.scrollWidth-base.clientWidth>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX;base.toggleAttribute("data-scroll-overflow",overflows)}observeHeaders(){const headers=new Set(this.columns.some(column=>column.sticky||column.resizable)?this.renderRoot.querySelectorAll("th[data-col-key]"):[]);for(const header of this.observedHeaders)headers.has(header)||(this.resizeObserver?.unobserve(header),this.observedHeaders.delete(header));for(const header of headers)this.observedHeaders.has(header)||(this.observedHeaders.add(header),this.resizeObserver?.observe(header))}priorityTierHeaders(tier){return[...this.renderRoot.querySelectorAll(`th[data-priority="${tier}"]`)]}recomputeHiddenPriorityColumns(){const hasLowColumn=this.columns.some(col=>col.priority==="low"),hasMediumColumn=this.columns.some(col=>col.priority==="medium"),base=this.renderRoot.querySelector('[part="base"]');if(!hasLowColumn&&!hasMediumColumn){this.priorityTierNaturalWidth.clear(),this.alwaysVisibleNaturalWidth=void 0,this.priorityTierHiddenAllocation.clear(),this.priorityTierRevealAllocation.clear(),base?.removeAttribute("data-hide-priority-low"),base?.removeAttribute("data-hide-priority-medium"),this.rehomeFocusedColumn(),this.priorityToggleAvailable&&(this.priorityToggleAvailable=!1),this.hasHiddenPriorityColumns&&(this.hasHiddenPriorityColumns=!1);return}if(!base||base.clientWidth<=0){this.rehomeFocusedColumn();return}const genuineOverflow=base.scrollWidth-base.clientWidth>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,lowHeaders=hasLowColumn?this.priorityTierHeaders("low"):[],mediumHeaders=hasMediumColumn?this.priorityTierHeaders("medium"):[],refreshNaturalWidth=(tier,headers)=>{if(headers.length===0)return!1;const currentlyHidden=headers.every(header=>header.offsetParent===null);if(!currentlyHidden&&genuineOverflow){const width=headers.reduce((sum,header)=>sum+header.getBoundingClientRect().width,0);width>0&&this.priorityTierNaturalWidth.set(tier,width)}return currentlyHidden},lowActuallyHidden=refreshNaturalWidth("low",lowHeaders),mediumActuallyHidden=refreshNaturalWidth("medium",mediumHeaders);if(genuineOverflow){const alwaysWidth=[...this.renderRoot.querySelectorAll('[part="head"] > tr > th')].filter(header=>!header.hasAttribute("data-priority")).reduce((sum,header)=>sum+header.getBoundingClientRect().width,0);alwaysWidth>0&&(this.alwaysVisibleNaturalWidth=alwaysWidth)}const lowNaturalWidth=this.priorityTierNaturalWidth.get("low")??0,mediumNaturalWidth=this.priorityTierNaturalWidth.get("medium")??0,overflowAtFull=(lowActuallyHidden||mediumActuallyHidden?(this.alwaysVisibleNaturalWidth??0)+lowNaturalWidth+mediumNaturalWidth:base.scrollWidth)-base.clientWidth,measuredLow=hasLowColumn&&overflowAtFull>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,overflowAfterLow=measuredLow?overflowAtFull-lowNaturalWidth:overflowAtFull,measuredMedium=hasMediumColumn&&overflowAfterLow>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,allocation=base.offsetWidth,needsMedium=this.settlePriorityTier(base,"medium",measuredMedium,mediumActuallyHidden,allocation),needsLow=this.settlePriorityTier(base,"low",hasLowColumn&&(measuredLow||needsMedium),lowActuallyHidden,allocation);this.rehomeFocusedColumn();const toggleAvailable=needsLow||needsMedium,anyPriorityHidden=toggleAvailable&&!this.priorityColumnsVisible;this.priorityToggleAvailable!==toggleAvailable&&(this.priorityToggleAvailable=toggleAvailable),this.hasHiddenPriorityColumns!==anyPriorityHidden&&(this.hasHiddenPriorityColumns=anyPriorityHidden)}settlePriorityTier(base,tier,measured,actuallyHidden,allocation){const attribute=tier==="low"?"data-hide-priority-low":"data-hide-priority-medium",wasMarked=base.hasAttribute(attribute),revealedAt=this.priorityTierRevealAllocation.get(tier);this.priorityTierRevealAllocation.delete(tier);const hiddenAt=this.priorityTierHiddenAllocation.get(tier),held=actuallyHidden&&hiddenAt!==void 0&&allocation<=hiddenAt+TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,hide=measured||held;return hide?(!wasMarked||hiddenAt===void 0)&&this.priorityTierHiddenAllocation.set(tier,Math.max(allocation,revealedAt??allocation)):(this.priorityTierHiddenAllocation.delete(tier),wasMarked&&actuallyHidden&&this.priorityTierRevealAllocation.set(tier,allocation)),base.toggleAttribute(attribute,hide),hide}rehomeFocusedColumn(){const visible=this.visibleHeaders();visible.length===0||this.activeColKey===null||visible.some(header=>header.dataset.colKey===this.activeColKey)||(this.activeColKey=visible[0].dataset.colKey??null)}keyOf(row,index){try{const key=this.rowKey?this.rowKey(row):index;return typeof key=="string"?key.trim().length===0?void 0:key:typeof key=="number"?key:void 0}catch{return}}canonicalRowEntries(){const inputs=this.canonicalRowEntriesInputs;if(this.cachedCanonicalRowEntries!==null&&inputs?.rows===this.rows&&inputs.rowKey===this.rowKey)return this.cachedCanonicalRowEntries;const entries=[],seen=new Set;return this.rows.forEach((row,index)=>{const key=this.keyOf(row,index);if(key===void 0)return;const encoded=encodeKey(key);seen.has(encoded)||(seen.add(encoded),entries.push({row,index,key}))}),this.canonicalRowEntriesInputs={rows:this.rows,rowKey:this.rowKey},this.cachedCanonicalRowEntries=entries,entries}matchingEntries(){const text=(this.filterText??"").trim(),locale=text===""?"":this.effectiveLocale,canonicalEntries=this.canonicalRowEntries(),inputs=this.matchingEntriesInputs;if(this.cachedMatchingEntries!==null&&inputs!==null&&inputs.entries===canonicalEntries&&inputs.filter===this.filter&&inputs.text===text&&inputs.locale===locale)return this.cachedMatchingEntries;let entries;if(text==="")entries=canonicalEntries;else{const intlLocale=this.effectiveLocale,normalized=text.toLocaleLowerCase(intlLocale);entries=canonicalEntries.filter(({row})=>this.filter?this.filter(row,text):safeStringifyForFilter(row).toLocaleLowerCase(intlLocale).includes(normalized))}return this.matchingEntriesInputs={entries:canonicalEntries,filter:this.filter,text,locale},this.cachedMatchingEntries=entries,entries}get normalizedPageSize(){return finiteInteger(this.pageSize,DEFAULT_PAGE_SIZE,1,MAX_PAGE_SIZE)}get effectiveSkeletonRows(){const explicit=finiteCount(this.skeletonRows,0,MAX_SKELETON_ROWS);if(explicit>0)return explicit;const pageSize=this.normalizedPageSize;return pageSize===DEFAULT_PAGE_SIZE?DEFAULT_SKELETON_ROWS:Math.min(pageSize,MAX_SKELETON_ROWS)}get matchingTotalItems(){const totalItems=finiteInteger(this.totalItems,-1);return totalItems>=0?totalItems:this.matchingEntries().length}get serverUnknownTotal(){return this.paginationMode==="server"&&this.unknownTotal}get pageCount(){const pageSize=this.normalizedPageSize;return pageSize>0?Math.ceil(this.matchingTotalItems/pageSize):0}get appliedPage(){return this.pageCount===0?1:finiteInteger(this.page,1,1,this.pageCount)}sortedEntries(){const entries=this.matchingEntries();if(this.sortMode!=="client"||this.sortKey==="")return entries;const col=this.columnsByKey.get(this.sortKey);if(!col?.sortable)return entries;const locale=this.effectiveLocale,inputs=this.sortedEntriesInputs;if(this.cachedSortedEntries!==null&&inputs!==null&&inputs.entries===entries&&inputs.columns===this.columns&&inputs.mode===this.sortMode&&inputs.key===this.sortKey&&inputs.dir===this.sortDir&&inputs.locale===locale&&inputs.groupBy===this.groupBy)return this.cachedSortedEntries;const collator=getCollator(locale,{numeric:!0}),dir=this.sortDir==="desc"?-1:1,decorated=entries.map(entry=>{const raw=typeof col.sortValue=="function"?col.sortValue(entry.row):typeof col.cell=="function"?String(col.cell(entry.row)??""):"";return{entry,value:typeof raw=="number"&&!Number.isFinite(raw)?null:raw}}),compare=(a,b)=>{const av=a.value,bv=b.value;return av==null&&bv==null?0:av==null?1:bv==null?-1:typeof av=="number"&&typeof bv=="number"?(av-bv)*dir:collator.compare(String(av),String(bv))*dir};let sorted;const groupBy=this.groupBy;if(groupBy===void 0)decorated.sort(compare),sorted=decorated.map(decoration=>decoration.entry);else{const buckets=new Map;for(const decoration of decorated){const groupKey=groupBy(decoration.entry.row),bucket=buckets.get(groupKey);bucket===void 0?buckets.set(groupKey,[decoration]):bucket.push(decoration)}const ordered=[...buckets.values()],constantWithinEveryGroup=ordered.every(bucket=>bucket.every(decoration=>compare(decoration,bucket[0])===0));constantWithinEveryGroup&&ordered.sort((a,b)=>compare(a[0],b[0])),sorted=[];for(const bucket of ordered){constantWithinEveryGroup||bucket.sort(compare);for(const decoration of bucket)sorted.push(decoration.entry)}}return this.sortedEntriesInputs={entries,columns:this.columns,mode:this.sortMode,key:this.sortKey,dir:this.sortDir,locale,groupBy},this.cachedSortedEntries=sorted,sorted}renderedEntries(){const entries=this.sortedEntries();if(this.paginationMode==="server")return entries.slice(0,this.normalizedPageSize);const start=(this.appliedPage-1)*this.normalizedPageSize;return entries.slice(start,start+this.normalizedPageSize)}get viewRows(){return Object.freeze(this.sortedEntries().map(entry=>entry.row))}get pageRows(){return Object.freeze(this.renderedEntries().map(entry=>entry.row))}focusedColKey(){const visible=this.visibleHeaders(),visibleKeys=new Set(visible.map(el=>el.dataset.colKey).filter(key=>key!==void 0&&this.columnsByKey.has(key)));return this.activeColKey!==null&&this.columnsByKey.has(this.activeColKey)&&(visibleKeys.size===0||visibleKeys.has(this.activeColKey))?this.activeColKey:visible.find(el=>el.dataset.colKey!==void 0&&this.columnsByKey.has(el.dataset.colKey))?.dataset.colKey??this.columns[0]?.key??null}focusedRowKey(){if(this.activeRowKey!==null&&this.rowsByKey.has(this.activeRowKey))return this.activeRowKey;const selectedKey=this._selectedKeys.values().next().value;if(selectedKey!==void 0){const selected=encodeKey(selectedKey);if(this.rowsByKey.has(selected))return selected}const first=this.renderedEntries()[0];return first?encodeKey(first.key):null}rowsAffectingRovingFocusChanged(changed){return changed.has("rows")||changed.has("rowKey")||changed.has("filterText")||changed.has("filter")||changed.has("page")||changed.has("pageSize")||changed.has("paginationMode")||changed.has("totalItems")||changed.has("columns")||changed.has("sortKey")||changed.has("sortDir")||changed.has("sortMode")||changed.has("groupBy")||this.rowsLocale!==this.effectiveLocale}captureRovingFocus(changed){this.rovingFocusSnapshot=null;const active=activeElementIn(this.shadowRoot),HTMLElementCtor=this.ownerDocument?.defaultView?.HTMLElement;if(!(!HTMLElementCtor||!(active instanceof HTMLElementCtor))){if(changed.has("columns")&&active.matches("th[data-col-key]")){const headers=this.visibleHeaders(),key=active.dataset.colKey,index=headers.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"header",key,index,targetKey:null,element:active});return}if(this.rowsAffectingRovingFocusChanged(changed)&&active.matches("tr[data-row-key]")){const renderedRows=[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],key=active.dataset.rowKey,index=renderedRows.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"row",key,index,targetKey:null,element:active})}}}resolveRovingFocusTarget(){const snapshot=this.rovingFocusSnapshot;if(snapshot===null)return;const keys=snapshot.kind==="header"?this.columns.map(column=>column.key):[...this.rowsByKey.keys()];snapshot.targetKey=keys.includes(snapshot.key)?snapshot.key:keys[Math.min(snapshot.index,keys.length-1)]??null,snapshot.kind==="header"?this.activeColKey=snapshot.targetKey:this.activeRowKey=snapshot.targetKey}willUpdate(changed){if(super.willUpdate(changed),this.captureRovingFocus(changed),this.selectionMode==="single"&&this._selectedKeys.size>1&&(changed.has("selectionMode")||changed.has("selectedRowKeys"))){const first=this._selectedKeys.values().next().value;if(this.selectedRowKeys=this.asKeySet(first===void 0?new Set:new Set([first])),this.hasUpdated){const rowKeys=this.asKeyList(Object.freeze(first===void 0?[]:[first]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}}if(this.expansionMode==="single"&&this._expandedKeys.size>1&&(changed.has("expansionMode")||changed.has("expandedRowKeys"))){const first=this._expandedKeys.values().next().value;this.expandedRowKeys=this.asKeySet(first===void 0?new Set:new Set([first]))}if(!this.hasUpdated){const parsed=readPersistedState(this.storageFullKey,v=>typeof v=="object"&&v!==null);parsed&&typeof parsed.priorityColumnsVisible=="boolean"&&!isPersistedPropertyExplicitlySet(this,"priorityColumnsVisible")&&(this.priorityColumnsVisible=parsed.priorityColumnsVisible)}if(changed.has("columns")&&(this.columnsByKey=new Map(this.columns.map(c=>[c.key,c]))),this.rowsAffectingRovingFocusChanged(changed)&&(this.rowsByKey=new Map(this.renderedEntries().map(entry=>[encodeKey(entry.key),entry])),this.rowsLocale=this.effectiveLocale),this.resolveRovingFocusTarget(),this.editingCell!==null){const column=this.columnsByKey.get(this.editingCell.columnKey);(!this.rowsByKey.has(this.editingCell.rowKey)||normalizedEditTrigger(column?.editTrigger)!=="double-click")&&(this.editingCell=null)}this.editorHadFocusBeforeUpdate=this.focusedEditorCell!==null&&activeElementIn(this.shadowRoot)===this.editorElementFor(this.focusedEditorCell.rowKey,this.focusedEditorCell.columnKey)}stickyOffsets(){const offsets=new Map,headerWidths=new Map;for(const el of this.renderRoot.querySelectorAll("th[data-col-key]")){const key=el.dataset.colKey;key!==void 0&&!headerWidths.has(key)&&headerWidths.set(key,el.offsetWidth)}const headerWidth=key=>headerWidths.get(key)??0;let runningStart=0;for(const col of this.columns)stickyDirection(col.sticky)==="start"&&(offsets.set(col.key,runningStart),runningStart+=headerWidth(col.key));let runningEnd=0;for(let i=this.columns.length-1;i>=0;i--){const col=this.columns[i];col&&stickyDirection(col.sticky)==="end"&&(offsets.set(col.key,runningEnd),runningEnd+=headerWidth(col.key))}return offsets}computeHeatDomain(hasHeatTint){if(!hasHeatTint)return null;const values=[];for(const entry of this.matchingEntries())for(const col of this.columns){const v=col.heatValue?.(entry.row);v!=null&&Number.isFinite(v)&&values.push(v)}const auto=minMax(values),lo=this.heatTintScale?.min??auto?.[0],hi=this.heatTintScale?.max??auto?.[1];return lo===void 0||hi===void 0?null:[lo,hi]}heatShare(col,row,domain){if(!col.heatValue||!domain)return null;const v=col.heatValue(row);if(v==null||!Number.isFinite(v))return null;const[lo,hi]=domain;return`${(finiteRatio(v,lo,hi)*100).toFixed(2)}%`}applyStickyOffsets(){if(!this.columns.some(c=>c.sticky))return;const offsets=this.stickyOffsets();this.renderRoot.querySelectorAll("[data-col-key]").forEach(el=>{const key=el.dataset.colKey;key!==void 0&&offsets.has(key)&&el.style.setProperty("--lr-table-sticky-offset",`${offsets.get(key)}px`)})}updated(changed){super.updated(changed),this.firstUpdateAnnouncementsReady&&changed.has("loading")&&this.loading&&this.announcementSink?.announce(this.loadingText());const announcesErrorTransition=this.firstUpdateAnnouncementsReady&&changed.has("error")&&this.error,announcesMountedError=!this.firstUpdateAnnouncementsReady&&this.announce&&this.error;if((announcesErrorTransition||announcesMountedError)&&this.errorAnnouncementSink?.announce(this.localizedOverride("tableLoadFailed",this.errorHeading)),this.firstUpdateAnnouncementsReady=!0,this.persistReady&&changed.has("priorityColumnsVisible")&&writePersistedState(this.storageFullKey,{priorityColumnsVisible:this.priorityColumnsVisible}),this.persistReady=!0,changed.has("columns")||changed.has("revealColumnsLabel")||changed.has("columnsHideLabel")||changed.has("priorityColumnsVisible")||changed.has("storageKey")){const inertMembers=[],labelsInert=this.revealColumnsLabel!==void 0||this.columnsHideLabel!==void 0;labelsInert&&inertMembers.push("`revealColumnsLabel`/`columnsHideLabel`"),isPersistedPropertyExplicitlySet(this,"priorityColumnsVisible")&&inertMembers.push("`priorityColumnsVisible`"),this.storageKey&&inertMembers.push("`storageKey`"),inertMembers.length>0&&this.columns.length>0&&!this.columns.some(col=>col.priority)&&devWarnOnce(INERT_PRIORITY_COLUMN_CONFIG_WARNING,`<lr-table>: ${inertMembers.join(", ")} `+(inertMembers.length>1||labelsInert?"have":"has")+" no effect unless at least one column declares `priority`.")}(changed.has("columns")||changed.has("rows")||changed.has("rowKey"))&&this.applyStickyOffsets(),this.syncResizeHandleValues();const base=this.renderRoot.querySelector('[part="base"]');if(base&&this.observeBase(base),this.observeTable(this.renderRoot.querySelector('[part="table"]')??void 0),this.syncAutoScrollMode(),this.observeHeaders(),this.restoreRovingFocus(),this.hasAlwaysOnEditors&&this.restoreAlwaysOnEditorFocus(),changed.has("editingCell"))if(this.editingCell){const{rowKey,columnKey}=this.editingCell;queueMicrotask(()=>this.editorElementFor(rowKey,columnKey)?.focus())}else{const previous=changed.get("editingCell");if(previous){const{rowKey,columnKey}=previous;queueMicrotask(()=>this.cellElementForToken(rowKey,columnKey)?.focus())}}queueMicrotask(()=>this.recomputeHiddenPriorityColumns())}restoreRovingFocus(){const snapshot=this.rovingFocusSnapshot;if(this.rovingFocusSnapshot=null,snapshot===null)return;const internalActive=activeElementIn(this.shadowRoot);if(internalActive!==null&&internalActive!==snapshot.element)return;const documentActive=activeElementIn(this.ownerDocument);if(documentActive!==null&&documentActive!==this&&documentActive!==this.ownerDocument.body)return;const candidates=snapshot.kind==="header"?this.visibleHeaders():[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],target=candidates.find(candidate=>snapshot.kind==="header"?candidate.dataset.colKey===snapshot.targetKey:candidate.dataset.rowKey===snapshot.targetKey)??candidates[Math.min(snapshot.index,candidates.length-1)]??null;snapshot.kind==="header"?this.focusHeader(target):this.focusRow(target)}activateColumn(key){this.activeColKey=key;const col=this.columnsByKey.get(key);if(!col?.sortable)return;const sortDir=this.sortKey===key?this.sortDir==="asc"?"desc":"asc":col.defaultSortDir??this.defaultSortDir,request=Object.freeze({phase:"request",sortKey:col.key,sortDir});this.emit("lr-sort-request",request,{cancelable:!0}).defaultPrevented||(this.sortMode==="client"&&(this.sortKey=col.key,this.sortDir=sortDir),this.emit("lr-sort",Object.freeze({phase:"commit",sortKey:col.key,sortDir})))}activateRow(key){this.activeRowKey=key;const entry=this.rowsByKey.get(key);if(entry===void 0)return;const{row,key:selectedKey}=entry;if(this.emit("lr-row-activate",Object.freeze({row})),this.selectionMode==="single"){this.selectedRowKeys=this.asKeySet(new Set([selectedKey]));const rowKeys=this.asKeyList(Object.freeze([selectedKey]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}else if(this.selectionMode==="multiple"){const rawKey=selectedKey,next=new Set(this._selectedKeys);next.has(rawKey)?next.delete(rawKey):next.add(rawKey),this.selectedRowKeys=this.asKeySet(next);const rowKeys=this.asKeyList(Object.freeze([...next]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}}get hasAlwaysOnEditors(){return this.columns.some(col=>normalizedEditTrigger(col.editTrigger)==="always")}editorValue(row,column){const value=column.editValue?.(row)??row[column.key]??"";return String(value)}startEditing(rowKey,columnKey){const column=this.columnsByKey.get(columnKey);normalizedEditTrigger(column?.editTrigger)!=="double-click"||!this.rowsByKey.has(rowKey)||(this.editingCell={rowKey,columnKey})}commitEdit(event,rowKey,columnKey){event.stopPropagation();const field=event.currentTarget,entry=this.rowsByKey.get(rowKey),column=this.columnsByKey.get(columnKey),isTransient=this.editingCell?.rowKey===rowKey&&this.editingCell.columnKey===columnKey;if(!entry||!column||normalizedEditTrigger(column.editTrigger)===void 0){isTransient&&(this.editingCell=null);return}const value=column.editType==="number"&&field.value!==""?Number(field.value):field.value;this.emit("lr-cell-edit",Object.freeze({row:entry.row,columnKey,value})),isTransient&&(this.editingCell=null)}editorElementFor(rowKey,columnKey){return this.cellElementForToken(rowKey,columnKey)?.querySelector('[part="cell-editor"]')??null}restoreAlwaysOnEditorFocus(){const cell=this.focusedEditorCell;if(cell===null)return;const editor=this.editorElementFor(cell.rowKey,cell.columnKey);editor===null?this.focusedEditorCell=null:this.editorHadFocusBeforeUpdate&&activeElementIn(this.shadowRoot)!==editor&&editor.focus(),this.editorHadFocusBeforeUpdate=!1}activateExpandToggle(key){const entry=this.rowsByKey.get(encodeKey(key));if(entry===void 0)return;const expanded=!this._expandedKeys.has(key),detail=Object.freeze({row:entry.row,rowKey:key,expanded});if(this.expansionMode!=="single"&&this.expansionMode!=="multiple"){this.emit("lr-row-expand-toggle",detail);return}requestThenCommit({requestDetail:detail,emitRequest:(requestDetail,init)=>this.emit("lr-row-expand-request",requestDetail,init),commit:()=>{const next=this.expansionMode==="single"?new Set:new Set(this._expandedKeys);expanded?next.add(key):next.delete(key);const displaced=[...this._expandedKeys].filter(other=>other!==key&&!next.has(other));this.expandedRowKeys=this.asKeySet(next);for(const other of displaced){const displacedEntry=this.rowsByKey.get(encodeKey(other));displacedEntry!==void 0&&this.emit("lr-row-expand-toggle",Object.freeze({row:displacedEntry.row,rowKey:other,expanded:!1}))}this.emit("lr-row-expand-toggle",detail)}})}rowElement(rowKey){return this.rowElementForToken(encodeKey(rowKey))}cellElement(rowKey,columnKey){return this.cellElementForToken(encodeKey(rowKey),columnKey)}editCell(rowKey,columnKey){const token=encodeKey(rowKey),trigger=normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger);if(!(trigger===void 0||!this.rowsByKey.has(token))){if(trigger==="always"){this.editorElementFor(token,columnKey)?.focus();return}this.startEditing(token,columnKey)}}expandedContentElement(rowKey){const token=encodeKey(rowKey);return[...this.renderRoot.querySelectorAll("tbody tr[data-expanded-row-key]")].find(el=>el.dataset.expandedRowKey===token)?.querySelector('[part="expanded-cell"]')??null}rowElementForToken(token){return[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")].find(el=>el.dataset.rowKey===token)??null}cellElementForToken(token,columnKey){return[...this.rowElementForToken(token)?.querySelectorAll("td[data-col-key]")??[]].find(el=>el.dataset.colKey===columnKey)??null}visibleHeaders(){return[...this.renderRoot?.querySelectorAll("th[data-col-key]")??[]].filter(el=>el.offsetParent!==null)}focusHeader(el){el?.dataset.colKey&&(this.activeColKey=el.dataset.colKey,el.focus())}focusRow(el){el?.dataset.rowKey&&(this.activeRowKey=el.dataset.rowKey,el.focus())}onHeaderKeyDown(e,th){if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateColumn(th.dataset.colKey);return}const headers=this.visibleHeaders(),index=headers.indexOf(th);if(index<0)return;const rtl=isRtl(this);switch(e.key){case"ArrowLeft":e.preventDefault(),this.focusHeader(headers[rtl?Math.min(headers.length-1,index+1):Math.max(0,index-1)]??null);return;case"ArrowRight":e.preventDefault(),this.focusHeader(headers[rtl?Math.max(0,index-1):Math.min(headers.length-1,index+1)]??null);return;case"Home":e.preventDefault(),this.focusHeader(headers[0]??null);return;case"End":e.preventDefault(),this.focusHeader(headers[headers.length-1]??null);return;case"ArrowDown":{e.preventDefault();const rows=[...this.renderRoot.querySelectorAll("[data-row-key]")],key=this.focusedRowKey();this.focusRow(rows.find(r=>r.dataset.rowKey===key)??rows[0]??null);return}default:return}}editableCellFor(target){const columnKey=target.dataset.colKey;return target.tagName!=="TD"||columnKey===void 0?null:normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="double-click"?{element:target,columnKey}:null}editableCellsInRow(tr){return[...tr.querySelectorAll("td[data-editable]")].filter(td=>td.offsetParent!==null&&!td.inert&&!td.closest("[inert]"))}onRowKeyDown(e,tr){const cell=this.editableCellFor(e.target);if((e.key==="Enter"||e.key==="F2")&&cell){e.preventDefault(),this.startEditing(tr.dataset.rowKey,cell.columnKey);return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateRow(tr.dataset.rowKey);return}if(e.key==="ArrowLeft"||e.key==="ArrowRight"){this.onRowLateralKeyDown(e,tr,cell);return}const bodyRows=[...this.renderRoot.querySelectorAll("[data-row-key]")],index=bodyRows.indexOf(tr);if(!(index<0))switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(bodyRows[Math.min(bodyRows.length-1,index+1)]??null);return;case"ArrowUp":if(e.preventDefault(),index===0){const headers=this.visibleHeaders(),key=this.focusedColKey();this.focusHeader(headers.find(h=>h.dataset.colKey===key)??headers[0]??null)}else this.focusRow(bodyRows[index-1]??null);return;case"Home":e.preventDefault(),this.focusRow(bodyRows[0]??null);return;case"End":e.preventDefault(),this.focusRow(bodyRows[bodyRows.length-1]??null);return;default:return}}onRowLateralKeyDown(e,tr,cell){const cells=this.editableCellsInRow(tr);if(cells.length===0)return;e.preventDefault();const forward=e.key===(isRtl(this)?"ArrowLeft":"ArrowRight");if(cell===null){(forward?cells[0]:cells[cells.length-1])?.focus();return}const index=cells.indexOf(cell.element);forward?cells[index+1]?.focus():index<=0?this.focusRow(tr):cells[index-1]?.focus()}renderCellValue(col,row){return typeof col.cell=="function"?col.cell(row):(devWarnOnce(MISSING_CELL_RENDERER_WARNING,"<lr-table>: a column has no required `cell` renderer, so its cells render empty. Supply a `cell` callback for every column."),nothing)}renderCellEditor(row,col,rowKey,alwaysOn){const type=col.editType??"text",value=this.editorValue(row,col),label=col.editLabel?.(row)??this.localize("tableEditCell",void 0,{column:col.label}),onChange=event=>this.commitEdit(event,rowKey,col.key),onKeyDown=event=>this.onEditorKeyDown(event,rowKey,col.key);if(type==="select"){const options=col.editOptions??[];return html`<select
|
|
14
|
+
></span>`}syncResizeHandleValues(){for(const handle of this.renderRoot.querySelectorAll('[part="resize-handle"]')){const key=handle.dataset.colKey;if(!key)continue;const column=this.columnsByKey.get(key);if(!column||this.resizedColumnWidths.has(key)||this.parsePixelLength(column.width)!==void 0)continue;const rendered=handle.closest("th[data-col-key]")?.getBoundingClientRect().width;if(rendered&&rendered>0){const width=Math.round(rendered);handle.setAttribute("aria-valuenow",String(width)),handle.setAttribute("aria-valuetext",this.resizeValueText(width))}}}detachResizePointerListeners(){const resizeEventWindow=this.resizeEventWindow;resizeEventWindow&&(resizeEventWindow.removeEventListener("pointermove",this.onResizePointerMove),resizeEventWindow.removeEventListener("pointerup",this.onResizePointerEnd),resizeEventWindow.removeEventListener("pointercancel",this.onResizePointerEnd),resizeEventWindow.removeEventListener("lostpointercapture",this.onResizePointerEnd),this.resizeEventWindow=void 0)}rollbackResizePreview(state2){const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted}cancelResizeGesture(){const state2=this.resizeState;if(this.resizeState=void 0,this.detachResizePointerListeners(),!!state2){state2.handle.removeAttribute("data-resizing");try{state2.handle.releasePointerCapture?.(state2.pointerId)}catch{}this.rollbackResizePreview(state2)}}firstUpdated(changed){super.firstUpdated(changed),!this.hasAttribute("aria-label")&&!this.caption&&devWarnOnce(MISSING_ACCESSIBLE_NAME_WARNING,"<lr-table> has no accessible name: set a host `aria-label` or `caption` so assistive technology can identify the grid.")}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink();const owner=this.ownerDocument.defaultView,ResizeObserverCtor=owner?.ResizeObserver;let observer;ResizeObserverCtor&&(observer=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.resizeObserver!==observer||this.scheduleLayoutSync()})),this.resizeObserver=observer;const base=this.renderRoot?.querySelector('[part="base"]');base&&(this.observeBase(base),this.observeTable(this.renderRoot.querySelector('[part="table"]')??void 0),this.observeHeaders())}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink(),this.cancelResizeGesture(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0;const frame=this.layoutFrame;frame&&frame.owner.cancelAnimationFrame(frame.handle),this.layoutFrame=null,this.observedBase=void 0,this.observedTable=void 0,this.observedHeaders.clear()}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0,this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this}))}localizedOverride(key,override){return override??this.localize(key)}loadingText(){return this.localizedOverride("tableLoading",this.loadingLabel)}observeBase(base){this.observedBase!==base&&(this.observedBase&&this.resizeObserver?.unobserve(this.observedBase),this.resizeObserver?.observe(base),this.observedBase=base)}observeTable(table){this.observedTable!==table&&(this.observedTable&&this.resizeObserver?.unobserve(this.observedTable),table&&this.resizeObserver?.observe(table),this.observedTable=table)}syncAutoScrollMode(){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return;const overflows=this.scrollMode==="auto"&&base.scrollWidth-base.clientWidth>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX;base.toggleAttribute("data-scroll-overflow",overflows)}observeHeaders(){const headers=new Set(this.columns.some(column=>column.sticky||column.resizable)?this.renderRoot.querySelectorAll("th[data-col-key]"):[]);for(const header of this.observedHeaders)headers.has(header)||(this.resizeObserver?.unobserve(header),this.observedHeaders.delete(header));for(const header of headers)this.observedHeaders.has(header)||(this.observedHeaders.add(header),this.resizeObserver?.observe(header))}priorityTierHeaders(tier){return[...this.renderRoot.querySelectorAll(`th[data-priority="${tier}"]`)]}recomputeHiddenPriorityColumns(){const hasLowColumn=this.columns.some(col=>col.priority==="low"),hasMediumColumn=this.columns.some(col=>col.priority==="medium"),base=this.renderRoot.querySelector('[part="base"]');if(!hasLowColumn&&!hasMediumColumn){this.priorityTierNaturalWidth.clear(),this.alwaysVisibleNaturalWidth=void 0,this.priorityTierHiddenAllocation.clear(),this.priorityTierRevealAllocation.clear(),base?.removeAttribute("data-hide-priority-low"),base?.removeAttribute("data-hide-priority-medium"),this.rehomeFocusedColumn(),this.priorityToggleAvailable&&(this.priorityToggleAvailable=!1),this.hasHiddenPriorityColumns&&(this.hasHiddenPriorityColumns=!1);return}if(!base||base.clientWidth<=0){this.rehomeFocusedColumn();return}const genuineOverflow=base.scrollWidth-base.clientWidth>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,lowHeaders=hasLowColumn?this.priorityTierHeaders("low"):[],mediumHeaders=hasMediumColumn?this.priorityTierHeaders("medium"):[],refreshNaturalWidth=(tier,headers)=>{if(headers.length===0)return!1;const currentlyHidden=headers.every(header=>header.offsetParent===null);if(!currentlyHidden&&genuineOverflow){const width=headers.reduce((sum,header)=>sum+header.getBoundingClientRect().width,0);width>0&&this.priorityTierNaturalWidth.set(tier,width)}return currentlyHidden},lowActuallyHidden=refreshNaturalWidth("low",lowHeaders),mediumActuallyHidden=refreshNaturalWidth("medium",mediumHeaders);if(genuineOverflow){const alwaysWidth=[...this.renderRoot.querySelectorAll('[part="head"] > tr > th')].filter(header=>!header.hasAttribute("data-priority")).reduce((sum,header)=>sum+header.getBoundingClientRect().width,0);alwaysWidth>0&&(this.alwaysVisibleNaturalWidth=alwaysWidth)}const lowNaturalWidth=this.priorityTierNaturalWidth.get("low")??0,mediumNaturalWidth=this.priorityTierNaturalWidth.get("medium")??0,overflowAtFull=(lowActuallyHidden||mediumActuallyHidden?(this.alwaysVisibleNaturalWidth??0)+lowNaturalWidth+mediumNaturalWidth:base.scrollWidth)-base.clientWidth,measuredLow=hasLowColumn&&overflowAtFull>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,overflowAfterLow=measuredLow?overflowAtFull-lowNaturalWidth:overflowAtFull,measuredMedium=hasMediumColumn&&overflowAfterLow>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,allocation=base.offsetWidth,needsMedium=this.settlePriorityTier(base,"medium",measuredMedium,mediumActuallyHidden,allocation),needsLow=this.settlePriorityTier(base,"low",hasLowColumn&&(measuredLow||needsMedium),lowActuallyHidden,allocation);this.rehomeFocusedColumn();const toggleAvailable=needsLow||needsMedium,anyPriorityHidden=toggleAvailable&&!this.priorityColumnsVisible;this.priorityToggleAvailable!==toggleAvailable&&(this.priorityToggleAvailable=toggleAvailable),this.hasHiddenPriorityColumns!==anyPriorityHidden&&(this.hasHiddenPriorityColumns=anyPriorityHidden)}settlePriorityTier(base,tier,measured,actuallyHidden,allocation){const attribute=tier==="low"?"data-hide-priority-low":"data-hide-priority-medium",wasMarked=base.hasAttribute(attribute),revealedAt=this.priorityTierRevealAllocation.get(tier);this.priorityTierRevealAllocation.delete(tier);const hiddenAt=this.priorityTierHiddenAllocation.get(tier),held=actuallyHidden&&hiddenAt!==void 0&&allocation<=hiddenAt+TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,hide=measured||held;return hide?(!wasMarked||hiddenAt===void 0)&&this.priorityTierHiddenAllocation.set(tier,Math.max(allocation,revealedAt??allocation)):(this.priorityTierHiddenAllocation.delete(tier),wasMarked&&actuallyHidden&&this.priorityTierRevealAllocation.set(tier,allocation)),base.toggleAttribute(attribute,hide),hide}rehomeFocusedColumn(){const visible=this.visibleHeaders();visible.length===0||this.activeColKey===null||visible.some(header=>header.dataset.colKey===this.activeColKey)||(this.activeColKey=visible[0].dataset.colKey??null)}keyOf(row,index){try{const key=this.rowKey?this.rowKey(row):index;return typeof key=="string"?key.trim().length===0?void 0:key:typeof key=="number"?key:void 0}catch{return}}canonicalRowEntries(){const inputs=this.canonicalRowEntriesInputs;if(this.cachedCanonicalRowEntries!==null&&inputs?.rows===this.rows&&inputs.rowKey===this.rowKey)return this.cachedCanonicalRowEntries;const entries=[],seen=new Set;return this.rows.forEach((row,index)=>{const key=this.keyOf(row,index);if(key===void 0)return;const encoded=encodeKey(key);seen.has(encoded)||(seen.add(encoded),entries.push({row,index,key}))}),this.canonicalRowEntriesInputs={rows:this.rows,rowKey:this.rowKey},this.cachedCanonicalRowEntries=entries,entries}matchingEntries(){const text=(this.filterText??"").trim(),locale=text===""?"":this.effectiveLocale,canonicalEntries=this.canonicalRowEntries(),inputs=this.matchingEntriesInputs;if(this.cachedMatchingEntries!==null&&inputs!==null&&inputs.entries===canonicalEntries&&inputs.filter===this.filter&&inputs.text===text&&inputs.locale===locale)return this.cachedMatchingEntries;let entries;if(text==="")entries=canonicalEntries;else{const intlLocale=this.effectiveLocale,normalized=text.toLocaleLowerCase(intlLocale);entries=canonicalEntries.filter(({row})=>this.filter?this.filter(row,text):safeStringifyForFilter(row).toLocaleLowerCase(intlLocale).includes(normalized))}return this.matchingEntriesInputs={entries:canonicalEntries,filter:this.filter,text,locale},this.cachedMatchingEntries=entries,entries}get normalizedPageSize(){return finiteInteger(this.pageSize,DEFAULT_PAGE_SIZE,1,MAX_PAGE_SIZE)}get effectiveSkeletonRows(){const explicit=finiteCount(this.skeletonRows,0,MAX_SKELETON_ROWS);if(explicit>0)return explicit;const pageSize=this.normalizedPageSize;return pageSize===DEFAULT_PAGE_SIZE?DEFAULT_SKELETON_ROWS:Math.min(pageSize,MAX_SKELETON_ROWS)}get matchingTotalItems(){const totalItems=finiteInteger(this.totalItems,-1);return totalItems>=0?totalItems:this.matchingEntries().length}get serverUnknownTotal(){return this.paginationMode==="server"&&this.unknownTotal}get pageCount(){const pageSize=this.normalizedPageSize;return pageSize>0?Math.ceil(this.matchingTotalItems/pageSize):0}get appliedPage(){return this.pageCount===0?1:finiteInteger(this.page,1,1,this.pageCount)}sortedEntries(){const entries=this.matchingEntries();if(this.sortMode!=="client"||this.sortKey==="")return entries;const col=this.columnsByKey.get(this.sortKey);if(!col?.sortable)return entries;const locale=this.effectiveLocale,inputs=this.sortedEntriesInputs;if(this.cachedSortedEntries!==null&&inputs!==null&&inputs.entries===entries&&inputs.columns===this.columns&&inputs.mode===this.sortMode&&inputs.key===this.sortKey&&inputs.dir===this.sortDir&&inputs.locale===locale&&inputs.groupBy===this.groupBy)return this.cachedSortedEntries;const collator=getCollator(locale,{numeric:!0}),dir=this.sortDir==="desc"?-1:1,decorated=entries.map(entry=>{const raw=typeof col.sortValue=="function"?col.sortValue(entry.row):typeof col.cell=="function"?String(col.cell(entry.row)??""):"";return{entry,value:typeof raw=="number"&&!Number.isFinite(raw)?null:raw}}),compare=(a,b)=>{const av=a.value,bv=b.value;return av==null&&bv==null?0:av==null?1:bv==null?-1:typeof av=="number"&&typeof bv=="number"?(av-bv)*dir:collator.compare(String(av),String(bv))*dir};let sorted;const groupBy=this.groupBy;if(groupBy===void 0)decorated.sort(compare),sorted=decorated.map(decoration=>decoration.entry);else{const buckets=new Map;for(const decoration of decorated){const groupKey=groupBy(decoration.entry.row),bucket=buckets.get(groupKey);bucket===void 0?buckets.set(groupKey,[decoration]):bucket.push(decoration)}const ordered=[...buckets.values()],constantWithinEveryGroup=ordered.every(bucket=>bucket.every(decoration=>compare(decoration,bucket[0])===0));constantWithinEveryGroup&&ordered.sort((a,b)=>compare(a[0],b[0])),sorted=[];for(const bucket of ordered){constantWithinEveryGroup||bucket.sort(compare);for(const decoration of bucket)sorted.push(decoration.entry)}}return this.sortedEntriesInputs={entries,columns:this.columns,mode:this.sortMode,key:this.sortKey,dir:this.sortDir,locale,groupBy},this.cachedSortedEntries=sorted,sorted}renderedEntries(){const entries=this.sortedEntries();if(this.paginationMode==="server")return entries.slice(0,this.normalizedPageSize);const start=(this.appliedPage-1)*this.normalizedPageSize;return entries.slice(start,start+this.normalizedPageSize)}get viewRows(){return Object.freeze(this.sortedEntries().map(entry=>entry.row))}get pageRows(){return Object.freeze(this.renderedEntries().map(entry=>entry.row))}focusedColKey(){const visible=this.visibleHeaders(),visibleKeys=new Set(visible.map(el=>el.dataset.colKey).filter(key=>key!==void 0&&this.columnsByKey.has(key)));return this.activeColKey!==null&&this.columnsByKey.has(this.activeColKey)&&(visibleKeys.size===0||visibleKeys.has(this.activeColKey))?this.activeColKey:visible.find(el=>el.dataset.colKey!==void 0&&this.columnsByKey.has(el.dataset.colKey))?.dataset.colKey??this.columns[0]?.key??null}focusedRowKey(){if(this.activeRowKey!==null&&this.rowsByKey.has(this.activeRowKey))return this.activeRowKey;const selectedKey=this._selectedKeys.values().next().value;if(selectedKey!==void 0){const selected=encodeKey(selectedKey);if(this.rowsByKey.has(selected))return selected}const first=this.renderedEntries()[0];return first?encodeKey(first.key):null}rowsAffectingRovingFocusChanged(changed){return changed.has("rows")||changed.has("rowKey")||changed.has("filterText")||changed.has("filter")||changed.has("page")||changed.has("pageSize")||changed.has("paginationMode")||changed.has("totalItems")||changed.has("columns")||changed.has("sortKey")||changed.has("sortDir")||changed.has("sortMode")||changed.has("groupBy")||this.rowsLocale!==this.effectiveLocale}captureRovingFocus(changed){this.rovingFocusSnapshot=null;const active=activeElementIn(this.shadowRoot),HTMLElementCtor=this.ownerDocument?.defaultView?.HTMLElement;if(!(!HTMLElementCtor||!(active instanceof HTMLElementCtor))){if(changed.has("columns")&&active.matches("th[data-col-key]")){const headers=this.visibleHeaders(),key=active.dataset.colKey,index=headers.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"header",key,index,targetKey:null,element:active});return}if(this.rowsAffectingRovingFocusChanged(changed)&&active.matches("tr[data-row-key]")){const renderedRows=[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],key=active.dataset.rowKey,index=renderedRows.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"row",key,index,targetKey:null,element:active})}}}resolveRovingFocusTarget(){const snapshot=this.rovingFocusSnapshot;if(snapshot===null)return;const keys=snapshot.kind==="header"?this.columns.map(column=>column.key):[...this.rowsByKey.keys()];snapshot.targetKey=keys.includes(snapshot.key)?snapshot.key:keys[Math.min(snapshot.index,keys.length-1)]??null,snapshot.kind==="header"?this.activeColKey=snapshot.targetKey:this.activeRowKey=snapshot.targetKey}willUpdate(changed){if(super.willUpdate(changed),this.captureRovingFocus(changed),this.selectionMode==="single"&&this._selectedKeys.size>1&&(changed.has("selectionMode")||changed.has("selectedRowKeys"))){const first=this._selectedKeys.values().next().value;if(this.selectedRowKeys=this.asKeySet(first===void 0?new Set:new Set([first])),this.hasUpdated){const rowKeys=this.asKeyList(Object.freeze(first===void 0?[]:[first]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}}if(this.expansionMode==="single"&&this._expandedKeys.size>1&&(changed.has("expansionMode")||changed.has("expandedRowKeys"))){const first=this._expandedKeys.values().next().value;this.expandedRowKeys=this.asKeySet(first===void 0?new Set:new Set([first]))}if(!this.hasUpdated){const parsed=readPersistedState(this.storageFullKey,v=>typeof v=="object"&&v!==null);parsed&&typeof parsed.priorityColumnsVisible=="boolean"&&!isPersistedPropertyExplicitlySet(this,"priorityColumnsVisible")&&(this.priorityColumnsVisible=parsed.priorityColumnsVisible)}if(changed.has("columns")&&(this.columnsByKey=new Map(this.columns.map(c=>[c.key,c]))),this.rowsAffectingRovingFocusChanged(changed)&&(this.rowsByKey=new Map(this.renderedEntries().map(entry=>[encodeKey(entry.key),entry])),this.rowsLocale=this.effectiveLocale),this.resolveRovingFocusTarget(),this.editingCell!==null){const column=this.columnsByKey.get(this.editingCell.columnKey);(!this.rowsByKey.has(this.editingCell.rowKey)||normalizedEditTrigger(column?.editTrigger)!=="double-click")&&(this.editingCell=null)}this.editorHadFocusBeforeUpdate=this.focusedEditorCell!==null&&activeElementIn(this.shadowRoot)===this.editorElementFor(this.focusedEditorCell.rowKey,this.focusedEditorCell.columnKey)}stickyOffsets(){const offsets=new Map,headerWidths=new Map;for(const el of this.renderRoot.querySelectorAll("th[data-col-key]")){const key=el.dataset.colKey;key!==void 0&&!headerWidths.has(key)&&headerWidths.set(key,el.offsetWidth)}const headerWidth=key=>headerWidths.get(key)??0;let runningStart=0;for(const col of this.columns)stickyDirection(col.sticky)==="start"&&(offsets.set(col.key,runningStart),runningStart+=headerWidth(col.key));let runningEnd=0;for(let i=this.columns.length-1;i>=0;i--){const col=this.columns[i];col&&stickyDirection(col.sticky)==="end"&&(offsets.set(col.key,runningEnd),runningEnd+=headerWidth(col.key))}return offsets}computeHeatDomain(hasHeatTint){if(!hasHeatTint)return null;const values=[];for(const entry of this.matchingEntries())for(const col of this.columns){const v=col.heatValue?.(entry.row);v!=null&&Number.isFinite(v)&&values.push(v)}const auto=minMax(values),lo=this.heatTintScale?.min??auto?.[0],hi=this.heatTintScale?.max??auto?.[1];return lo===void 0||hi===void 0?null:[lo,hi]}heatShare(col,row,domain){if(!col.heatValue||!domain)return null;const v=col.heatValue(row);if(v==null||!Number.isFinite(v))return null;const[lo,hi]=domain;return`${(finiteRatio(v,lo,hi)*100).toFixed(2)}%`}applyStickyOffsets(){if(!this.columns.some(c=>c.sticky))return;const offsets=this.stickyOffsets();this.renderRoot.querySelectorAll("[data-col-key]").forEach(el=>{const key=el.dataset.colKey;key!==void 0&&offsets.has(key)&&el.style.setProperty("--lr-table-sticky-offset",`${offsets.get(key)}px`)})}updated(changed){super.updated(changed),this.firstUpdateAnnouncementsReady&&changed.has("loading")&&this.loading&&this.announcementSink?.announce(this.loadingText());const announcesErrorTransition=this.firstUpdateAnnouncementsReady&&changed.has("error")&&this.error,announcesMountedError=!this.firstUpdateAnnouncementsReady&&this.announce&&this.error;if((announcesErrorTransition||announcesMountedError)&&this.errorAnnouncementSink?.announce(this.localizedOverride("tableLoadFailed",this.errorHeading)),this.firstUpdateAnnouncementsReady=!0,this.persistReady&&changed.has("priorityColumnsVisible")&&writePersistedState(this.storageFullKey,{priorityColumnsVisible:this.priorityColumnsVisible}),this.persistReady=!0,changed.has("columns")||changed.has("revealColumnsLabel")||changed.has("columnsHideLabel")||changed.has("priorityColumnsVisible")||changed.has("storageKey")){const inertMembers=[],labelsInert=this.revealColumnsLabel!==void 0||this.columnsHideLabel!==void 0;labelsInert&&inertMembers.push("`revealColumnsLabel`/`columnsHideLabel`"),isPersistedPropertyExplicitlySet(this,"priorityColumnsVisible")&&inertMembers.push("`priorityColumnsVisible`"),this.storageKey&&inertMembers.push("`storageKey`"),inertMembers.length>0&&this.columns.length>0&&!this.columns.some(col=>col.priority)&&devWarnOnce(INERT_PRIORITY_COLUMN_CONFIG_WARNING,`<lr-table>: ${inertMembers.join(", ")} `+(inertMembers.length>1||labelsInert?"have":"has")+" no effect unless at least one column declares `priority`.")}(changed.has("columns")||changed.has("rows")||changed.has("rowKey"))&&this.applyStickyOffsets(),this.syncResizeHandleValues();const base=this.renderRoot.querySelector('[part="base"]');if(base&&this.observeBase(base),this.observeTable(this.renderRoot.querySelector('[part="table"]')??void 0),this.syncAutoScrollMode(),this.observeHeaders(),this.restoreRovingFocus(),this.hasAlwaysOnEditors&&this.restoreAlwaysOnEditorFocus(),changed.has("editingCell"))if(this.editingCell){const{rowKey,columnKey}=this.editingCell;queueMicrotask(()=>this.editorElementFor(rowKey,columnKey)?.focus())}else{const previous=changed.get("editingCell");if(previous){const{rowKey,columnKey}=previous;queueMicrotask(()=>this.cellElementForToken(rowKey,columnKey)?.focus())}}queueMicrotask(()=>this.recomputeHiddenPriorityColumns())}restoreRovingFocus(){const snapshot=this.rovingFocusSnapshot;if(this.rovingFocusSnapshot=null,snapshot===null)return;const internalActive=activeElementIn(this.shadowRoot);if(internalActive!==null&&internalActive!==snapshot.element)return;const documentActive=activeElementIn(this.ownerDocument);if(documentActive!==null&&documentActive!==this&&documentActive!==this.ownerDocument.body)return;const candidates=snapshot.kind==="header"?this.visibleHeaders():[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],target=candidates.find(candidate=>snapshot.kind==="header"?candidate.dataset.colKey===snapshot.targetKey:candidate.dataset.rowKey===snapshot.targetKey)??candidates[Math.min(snapshot.index,candidates.length-1)]??null;snapshot.kind==="header"?this.focusHeader(target):this.focusRow(target)}activateColumn(key){this.activeColKey=key;const col=this.columnsByKey.get(key);if(!col?.sortable)return;const sortDir=this.sortKey===key?this.sortDir==="asc"?"desc":"asc":col.defaultSortDir??this.defaultSortDir,request=Object.freeze({phase:"request",sortKey:col.key,sortDir});this.emit("lr-sort-request",request,{cancelable:!0}).defaultPrevented||(this.sortMode==="client"&&(this.sortKey=col.key,this.sortDir=sortDir),this.emit("lr-sort",Object.freeze({phase:"commit",sortKey:col.key,sortDir})))}activateRow(key){this.activeRowKey=key;const entry=this.rowsByKey.get(key);if(entry===void 0)return;const{row,key:selectedKey}=entry;if(this.emit("lr-row-activate",Object.freeze({row})),this.selectionMode==="single"){this.selectedRowKeys=this.asKeySet(new Set([selectedKey]));const rowKeys=this.asKeyList(Object.freeze([selectedKey]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}else if(this.selectionMode==="multiple"){const rawKey=selectedKey,next=new Set(this._selectedKeys);next.has(rawKey)?next.delete(rawKey):next.add(rawKey),this.selectedRowKeys=this.asKeySet(next);const rowKeys=this.asKeyList(Object.freeze([...next]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}}get hasAlwaysOnEditors(){return this.columns.some(col=>normalizedEditTrigger(col.editTrigger)==="always")}editorValue(row,column){const value=column.editValue?.(row)??row[column.key]??"";return String(value)}startEditing(rowKey,columnKey){const column=this.columnsByKey.get(columnKey);normalizedEditTrigger(column?.editTrigger)!=="double-click"||!this.rowsByKey.has(rowKey)||(this.editingCell={rowKey,columnKey})}commitEdit(event,rowKey,columnKey){event.stopPropagation();const field=event.currentTarget,entry=this.rowsByKey.get(rowKey),column=this.columnsByKey.get(columnKey),isTransient=this.editingCell?.rowKey===rowKey&&this.editingCell.columnKey===columnKey;if(!entry||!column||normalizedEditTrigger(column.editTrigger)===void 0){isTransient&&(this.editingCell=null);return}const value=column.editType==="number"&&field.value!==""?Number(field.value):field.value;this.emit("lr-cell-edit",Object.freeze({row:entry.row,columnKey,value})),isTransient&&(this.editingCell=null)}editorElementFor(rowKey,columnKey){return this.cellElementForToken(rowKey,columnKey)?.querySelector('[part="cell-editor"]')??null}restoreAlwaysOnEditorFocus(){const cell=this.focusedEditorCell;if(cell===null)return;const editor=this.editorElementFor(cell.rowKey,cell.columnKey);editor===null?this.focusedEditorCell=null:this.editorHadFocusBeforeUpdate&&activeElementIn(this.shadowRoot)!==editor&&editor.focus(),this.editorHadFocusBeforeUpdate=!1}activateExpandToggle(key){const entry=this.rowsByKey.get(encodeKey(key));if(entry===void 0)return;const expanded=!this._expandedKeys.has(key),detail=Object.freeze({row:entry.row,rowKey:key,expanded});if(this.expansionMode!=="single"&&this.expansionMode!=="multiple"){this.emit("lr-row-expand-toggle",detail);return}requestThenCommit({requestDetail:detail,emitRequest:(requestDetail,init)=>this.emit("lr-row-expand-request",requestDetail,init),commit:()=>{const next=this.expansionMode==="single"?new Set:new Set(this._expandedKeys);expanded?next.add(key):next.delete(key);const displaced=[...this._expandedKeys].filter(other=>other!==key&&!next.has(other));this.expandedRowKeys=this.asKeySet(next);for(const other of displaced){const displacedEntry=this.rowsByKey.get(encodeKey(other));displacedEntry!==void 0&&this.emit("lr-row-expand-toggle",Object.freeze({row:displacedEntry.row,rowKey:other,expanded:!1}))}this.emit("lr-row-expand-toggle",detail)}})}rowElement(rowKey){return this.rowElementForToken(encodeKey(rowKey))}cellElement(rowKey,columnKey){return this.cellElementForToken(encodeKey(rowKey),columnKey)}editCell(rowKey,columnKey){const token=encodeKey(rowKey),trigger=normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger);if(!(trigger===void 0||!this.rowsByKey.has(token))){if(trigger==="always"){this.editorElementFor(token,columnKey)?.focus();return}this.startEditing(token,columnKey)}}expandedContentElement(rowKey){const token=encodeKey(rowKey);return[...this.renderRoot.querySelectorAll("tbody tr[data-expanded-row-key]")].find(el=>el.dataset.expandedRowKey===token)?.querySelector('[part="expanded-cell"]')??null}rowElementForToken(token){return[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")].find(el=>el.dataset.rowKey===token)??null}cellElementForToken(token,columnKey){return[...this.rowElementForToken(token)?.querySelectorAll("td[data-col-key]")??[]].find(el=>el.dataset.colKey===columnKey)??null}visibleHeaders(){return[...this.renderRoot?.querySelectorAll("th[data-col-key]")??[]].filter(el=>el.offsetParent!==null)}focusHeader(el){el?.dataset.colKey&&(this.activeColKey=el.dataset.colKey,el.focus())}focusRow(el){el?.dataset.rowKey&&(this.activeRowKey=el.dataset.rowKey,el.focus())}onHeaderKeyDown(e,th){if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateColumn(th.dataset.colKey);return}const headers=this.visibleHeaders(),index=headers.indexOf(th);if(index<0)return;const rtl=isRtl(this);switch(e.key){case"ArrowLeft":e.preventDefault(),this.focusHeader(headers[rtl?Math.min(headers.length-1,index+1):Math.max(0,index-1)]??null);return;case"ArrowRight":e.preventDefault(),this.focusHeader(headers[rtl?Math.max(0,index-1):Math.min(headers.length-1,index+1)]??null);return;case"Home":e.preventDefault(),this.focusHeader(headers[0]??null);return;case"End":e.preventDefault(),this.focusHeader(headers[headers.length-1]??null);return;case"ArrowDown":{e.preventDefault();const rows=[...this.renderRoot.querySelectorAll("[data-row-key]")],key=this.focusedRowKey();this.focusRow(rows.find(r=>r.dataset.rowKey===key)??rows[0]??null);return}default:return}}editableCellFor(target){const columnKey=target.dataset.colKey;return target.tagName!=="TD"||columnKey===void 0?null:normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="double-click"?{element:target,columnKey}:null}editableCellsInRow(tr){return[...tr.querySelectorAll("td[data-editable]")].filter(td=>td.offsetParent!==null&&!td.inert&&!td.closest("[inert]"))}onRowKeyDown(e,tr){const cell=this.editableCellFor(e.target);if((e.key==="Enter"||e.key==="F2")&&cell){e.preventDefault(),this.startEditing(tr.dataset.rowKey,cell.columnKey);return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateRow(tr.dataset.rowKey);return}if(e.key==="ArrowLeft"||e.key==="ArrowRight"){this.onRowLateralKeyDown(e,tr,cell);return}const bodyRows=[...this.renderRoot.querySelectorAll("[data-row-key]")],index=bodyRows.indexOf(tr);if(!(index<0))switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(bodyRows[Math.min(bodyRows.length-1,index+1)]??null);return;case"ArrowUp":if(e.preventDefault(),index===0){const headers=this.visibleHeaders(),key=this.focusedColKey();this.focusHeader(headers.find(h=>h.dataset.colKey===key)??headers[0]??null)}else this.focusRow(bodyRows[index-1]??null);return;case"Home":e.preventDefault(),this.focusRow(bodyRows[0]??null);return;case"End":e.preventDefault(),this.focusRow(bodyRows[bodyRows.length-1]??null);return;default:return}}onRowLateralKeyDown(e,tr,cell){const cells=this.editableCellsInRow(tr);if(cells.length===0)return;e.preventDefault();const forward=e.key===(isRtl(this)?"ArrowLeft":"ArrowRight");if(cell===null){(forward?cells[0]:cells[cells.length-1])?.focus();return}const index=cells.indexOf(cell.element);forward?cells[index+1]?.focus():index<=0?this.focusRow(tr):cells[index-1]?.focus()}renderCellValue(col,row){return typeof col.cell=="function"?col.cell(row):(devWarnOnce(MISSING_CELL_RENDERER_WARNING,"<lr-table>: a column has no required `cell` renderer, so its cells render empty. Supply a `cell` callback for every column."),nothing)}renderCellEditor(row,col,rowKey,alwaysOn){const type=col.editType??"text",value=this.editorValue(row,col),label=col.editLabel?.(row)??this.localize("tableEditCell",void 0,{column:col.label}),onChange=event=>this.commitEdit(event,rowKey,col.key),onKeyDown=event=>this.onEditorKeyDown(event,rowKey,col.key);if(type==="select"){const options=col.editOptions??[];return html`<select
|
|
15
15
|
part="cell-editor"
|
|
16
16
|
aria-label=${label}
|
|
17
17
|
.value=${value}
|
|
@@ -60,7 +60,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
60
60
|
${this.renderSkeletonPlaceholder()}
|
|
61
61
|
</td>`)}
|
|
62
62
|
${hasRowTotal?html`<td part="row-total-cell">${this.renderSkeletonPlaceholder()}</td>`:nothing}
|
|
63
|
-
</tr>`)}emptyCompactFor(branchDefault){const size=this.emptySize;return size===void 0?branchDefault:isCompactEmptySize(size)}renderErrorContent(compactDefault){return renderDataState(this,{loading:!1,error:!0,empty:!1,errorHeading:this.localizedOverride("tableLoadFailed",this.errorHeading),errorDescription:this.errorDescription,compact:this.emptyCompactFor(compactDefault),onRetry:()=>{this.error=!1},emitRetryRequest:(detail,init)=>this.emit("lr-retry-request",detail,init),
|
|
63
|
+
</tr>`)}emptyCompactFor(branchDefault){const size=this.emptySize;return size===void 0?branchDefault:isCompactEmptySize(size)}renderErrorContent(compactDefault){return renderDataState(this,{loading:!1,error:!0,empty:!1,errorHeading:this.localizedOverride("tableLoadFailed",this.errorHeading),errorDescription:this.errorDescription,compact:this.emptyCompactFor(compactDefault),onRetry:()=>{this.error=!1},emitRetryRequest:(detail,init)=>this.emit("lr-retry-request",detail,init)},"error","lr-retry-request")}renderErrorRow(colspan){return html`<tr part="error-row" role="row">
|
|
64
64
|
<td part="error-cell" role="gridcell" colspan=${colspan}>${this.renderErrorContent(!0)}</td>
|
|
65
65
|
</tr>`}render(){const skeletonLoading=this.loading&&this.loadingAppearance==="skeleton"&&this.columns.length>0;if(this.loading&&!skeletonLoading)return html`<div part="base" aria-busy="true">
|
|
66
66
|
<div part="loading" aria-hidden="true">
|
|
@@ -74,7 +74,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
74
74
|
size=${this.emptyCompactFor(!1)?"s":nothing}
|
|
75
75
|
heading=${this.localizedOverride("noColumns",this.emptyColumnsHeading)}
|
|
76
76
|
description=${this.emptyColumnsDescription}
|
|
77
|
-
></lr-empty>`;const hasHostAriaLabel=this.hasAttribute("aria-label"),gridAriaLabel=this.hostAccessibleLabel??
|
|
77
|
+
></lr-empty>`;const hasHostAriaLabel=this.hasAttribute("aria-label"),gridAriaLabel=this.hostAccessibleLabel??nothing,matchingEntries=this.sortedEntries();if(!skeletonLoading&&!this.error&&this.canonicalRowEntries().length===0&&!this.filterable)return html`<slot name="empty"
|
|
78
78
|
><lr-empty
|
|
79
79
|
part="empty"
|
|
80
80
|
exportparts="base:empty-base, icon:empty-icon, heading:empty-heading, description:empty-description, actions:empty-actions"
|
|
@@ -94,7 +94,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
94
94
|
part="table"
|
|
95
95
|
role="grid"
|
|
96
96
|
aria-label=${gridAriaLabel}
|
|
97
|
-
aria-labelledby=${
|
|
97
|
+
aria-labelledby=${!hasHostAriaLabel&&this.caption?this.captionId:nothing}
|
|
98
98
|
aria-multiselectable=${String(this.selectionMode==="multiple")}
|
|
99
99
|
?data-has-column-widths=${hasColumnWidths}
|
|
100
100
|
data-layout=${effectiveLayout}
|
|
@@ -245,4 +245,4 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
245
245
|
@lr-page-change=${this.onPaginationChange}
|
|
246
246
|
></lr-pagination>`:nothing}
|
|
247
247
|
</div>
|
|
248
|
-
`}}__decorate([property({attribute:!1})],LyraTable.prototype,"columns",null),__decorate([property({attribute:!1})],LyraTable.prototype,"rows",null),__decorate([property({reflect:!0,converter:TABLE_LAYOUT})],LyraTable.prototype,"layout",null),__decorate([property({attribute:"sort-key"})],LyraTable.prototype,"sortKey",void 0),__decorate([property({attribute:"sort-dir"})],LyraTable.prototype,"sortDir",void 0),__decorate([property({attribute:"sort-indicators",converter:literalSetConverter(["active","all"],"active")})],LyraTable.prototype,"sortIndicators",void 0),__decorate([property({reflect:!0,attribute:"sort-mode"})],LyraTable.prototype,"sortMode",void 0),__decorate([property({attribute:"default-sort-dir"})],LyraTable.prototype,"defaultSortDir",void 0),__decorate([property({attribute:"
|
|
248
|
+
`}}__decorate([property({attribute:!1})],LyraTable.prototype,"columns",null),__decorate([property({attribute:!1})],LyraTable.prototype,"rows",null),__decorate([property({reflect:!0,converter:TABLE_LAYOUT})],LyraTable.prototype,"layout",null),__decorate([property({attribute:"sort-key"})],LyraTable.prototype,"sortKey",void 0),__decorate([property({attribute:"sort-dir"})],LyraTable.prototype,"sortDir",void 0),__decorate([property({attribute:"sort-indicators",converter:literalSetConverter(["active","all"],"active")})],LyraTable.prototype,"sortIndicators",void 0),__decorate([property({reflect:!0,attribute:"sort-mode"})],LyraTable.prototype,"sortMode",void 0),__decorate([property({attribute:"default-sort-dir"})],LyraTable.prototype,"defaultSortDir",void 0),__decorate([property({attribute:"aria-label"})],LyraTable.prototype,"hostAccessibleLabel",void 0),__decorate([property()],LyraTable.prototype,"caption",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"rowKey",void 0),__decorate([property({reflect:!0,attribute:"selection-mode"})],LyraTable.prototype,"selectionMode",void 0),__decorate([property({reflect:!0,attribute:"expansion-mode"})],LyraTable.prototype,"expansionMode",void 0),__decorate([property({reflect:!0,attribute:"scroll-mode"})],LyraTable.prototype,"scrollMode",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"selectedRowKeys",null),__decorate([property({type:Boolean,reflect:!0})],LyraTable.prototype,"filterable",void 0),__decorate([property({attribute:"filter-text"})],LyraTable.prototype,"filterText",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"filter",void 0),__decorate([property({attribute:"filter-label"})],LyraTable.prototype,"filterLabel",void 0),__decorate([property({attribute:"filter-placeholder"})],LyraTable.prototype,"filterPlaceholder",void 0),__decorate([property({converter:spellcheckConverter})],LyraTable.prototype,"spellcheck",void 0),__decorate([property()],LyraTable.prototype,"autocapitalize",void 0),__decorate([property({attribute:"autocorrect"})],LyraTable.prototype,"autoCorrect",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTable.prototype,"loading",void 0),__decorate([property({attribute:"loading-label"})],LyraTable.prototype,"loadingLabel",void 0),__decorate([property({reflect:!0,attribute:"loading-appearance"})],LyraTable.prototype,"loadingAppearance",void 0),__decorate([property({type:Number,attribute:"skeleton-rows"})],LyraTable.prototype,"skeletonRows",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"groupBy",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"groupLabel",void 0),__decorate([property({type:Number,attribute:"page-size"})],LyraTable.prototype,"pageSize",void 0),__decorate([property({type:Number,reflect:!0})],LyraTable.prototype,"page",void 0),__decorate([property({type:Number,attribute:"total-items"})],LyraTable.prototype,"totalItems",void 0),__decorate([property({reflect:!0,attribute:"pagination-mode"})],LyraTable.prototype,"paginationMode",void 0),__decorate([property({type:Boolean,attribute:"unknown-total",reflect:!0})],LyraTable.prototype,"unknownTotal",void 0),__decorate([property({type:Boolean,attribute:"has-next",reflect:!0,converter:trueDefaultBooleanConverter})],LyraTable.prototype,"hasNext",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"expandedContent",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"canExpand",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"rowExpandLabel",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"expandedRowKeys",null),__decorate([property({attribute:!1})],LyraTable.prototype,"heatTintScale",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"rowTotal",void 0),__decorate([property({attribute:!1})],LyraTable.prototype,"grandTotal",void 0),__decorate([property({type:Boolean,attribute:"has-more",reflect:!0})],LyraTable.prototype,"hasMore",void 0),__decorate([property({attribute:"more-label"})],LyraTable.prototype,"moreLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTable.prototype,"error",void 0),__decorate([property({attribute:"error-heading"})],LyraTable.prototype,"errorHeading",void 0),__decorate([property({attribute:"error-description"})],LyraTable.prototype,"errorDescription",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTable.prototype,"announce",void 0),__decorate([property({attribute:"empty-heading"})],LyraTable.prototype,"emptyHeading",void 0),__decorate([property({attribute:"empty-description"})],LyraTable.prototype,"emptyDescription",void 0),__decorate([property({attribute:"empty-size",converter:optionalSizeConverter})],LyraTable.prototype,"emptySize",null),__decorate([property({attribute:"empty-columns-heading"})],LyraTable.prototype,"emptyColumnsHeading",void 0),__decorate([property({attribute:"empty-columns-description"})],LyraTable.prototype,"emptyColumnsDescription",void 0),__decorate([property({attribute:"reveal-columns-label"})],LyraTable.prototype,"revealColumnsLabel",void 0),__decorate([property({attribute:"columns-hide-label"})],LyraTable.prototype,"columnsHideLabel",void 0),__decorate([property({type:Boolean,attribute:"has-hidden-priority-columns",reflect:!0})],LyraTable.prototype,"hasHiddenPriorityColumns",void 0),__decorate([state()],LyraTable.prototype,"priorityToggleAvailable",void 0),__decorate([property({type:Boolean,attribute:"priority-columns-visible",reflect:!0,noAccessor:!0})],LyraTable.prototype,"priorityColumnsVisible",void 0),__decorate([property({attribute:"storage-key"})],LyraTable.prototype,"storageKey",void 0),__decorate([state()],LyraTable.prototype,"activeColKey",void 0),__decorate([state()],LyraTable.prototype,"activeRowKey",void 0),__decorate([state()],LyraTable.prototype,"editingCell",void 0),__decorate([state()],LyraTable.prototype,"resizedColumnWidths",null);export{LyraTable};
|
|
@@ -402,7 +402,7 @@ resetValidity():void;
|
|
|
402
402
|
* form-data entry; it is still contributed only while this control is the submitter. */
|
|
403
403
|
formStateRestoreCallback(state:string|File|FormData|null,reason:'autocomplete'|'restore'):void;
|
|
404
404
|
/** Runs the form action after every listener on the composed click path had its veto turn. */
|
|
405
|
-
private runClickDefaultAction;private onClick;private
|
|
405
|
+
private runClickDefaultAction;private onClick;private onFocusChange;
|
|
406
406
|
/** Whether anything about this button changes the submission itself, rather than merely
|
|
407
407
|
* triggering it. Only then is the transient native submitter worth creating: with none of these
|
|
408
408
|
* set, a plain `requestSubmit()` keeps `SubmitEvent.submitter` `null` as before. */
|
|
@@ -426,7 +426,7 @@ private submitAsNamedSubmitter;
|
|
|
426
426
|
* `disabled` survives the fieldset re-enabling instead of being permanently overwritten --
|
|
427
427
|
* mirrors `<lr-checkbox>`'s/`<lr-switch>`'s identical `_fieldsetDisabled` pattern.
|
|
428
428
|
*/
|
|
429
|
-
formDisabledCallback(disabled:boolean):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;private syncAdornmentSlots;private
|
|
429
|
+
formDisabledCallback(disabled:boolean):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;private syncAdornmentSlots;private onAdornmentSlotChange;private onDefaultSlotChange;
|
|
430
430
|
/** Whether the label takes the row's slack so a trailing affordance stays pinned to the trailing
|
|
431
431
|
* content edge. Exactly the caret and the `end`/`suffix` adornment qualify: both read as
|
|
432
432
|
* detached glyphs when they float mid-row. A plain button (or one with only a `start`
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var _a;import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{FORM_CONTROL_LABEL_FACTORY,LyraElement}from"../../../internal/lyra-element.js";import{installFormControlInternalsCapture}from"../../../internal/form-control-labels.js";import{chevronIcon,spinnerIcon}from"../../../internal/icons.js";import{hasIconOnlyDefaultContent,IconOnlyLabelObserver}from"../../../internal/icon-only-content.js";import{safeDownloadHref,safeLinkHref}from"../../../internal/safe-url.js";import{syncAriaControlsElements}from"../../../internal/aria-reflection.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{sizes}from"../../../internal/sizes.styles.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./button.styles.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{getFormOwner,installCustomErrorProperty,setFormOwner}from"../../../internal/direct-form-associated.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState}from"../../../internal/custom-states.js";import{omittedEmptyStringConverter}from"../../../internal/converters.js";import{resolveGuardedRel}from"../../../internal/link-rel.js";import{currentValidityValidator}from"../form-validator.js";import{createButtonExternalLabelController}from"./button-external-label.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";installFormControlInternalsCapture();class LyraButton extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","loading","href","value")]}static{this.styles=[LyraElement.styles,sizes,variants,styles]}static{this.formAssociated=!0}static{this[_a]=createButtonExternalLabelController}static{this.properties={disabled:{type:Boolean,reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},customError:{attribute:"custom-error",reflect:!0,noAccessor:!0}}}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old),this.updateValidity()}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 effectiveDisabled(){return this._disabled||this._fieldsetDisabled}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}constructor(){super(),this._fieldsetDisabled=!1,this._disabled=!1,this._name="",this._value="",this._required=!1,this._variant="neutral",this.localDescriptionIds="",this.customValidityMessage="",this.reflectingCustomError=!1,this.accessibleLabel=null,this.triggerHasPopup=null,this.triggerKeyShortcuts=null,this.triggerExpanded=null,this.triggerPressed=null,this.triggerCurrent=null,this.triggerControls=null,this.triggerDescribedBy=null,this.appearance="accent",this.size="m",this.pill=!1,this.circle=!1,this.outline=!1,this.withCaret=!1,this.withStart=!1,this.withEnd=!1,this.wrap=!1,this.type="button",this.formNoValidate=!1,this.loading=!1,this.hasStartSlot=!1,this.hasEndSlot=!1,this.isIconButton=!1,this.iconOnlyObserver=new IconOnlyLabelObserver(this,()=>this.labelEl,()=>this.isIconButton,next=>{this.isIconButton=next,this.syncButtonStates()}),this.onClick=event=>{if(this.type!=="submit"&&this.type!=="reset")return;const ownerWindow=this.ownerDocument.defaultView;let settled=!1;const finish=()=>{settled||(settled=!0,ownerWindow?.removeEventListener("click",finishAtWindow),!(event.defaultPrevented||this.effectiveDisabled||this.loading)&&this.runClickDefaultAction())},finishAtWindow=candidate=>{candidate===event&&finish()};ownerWindow?.addEventListener("click",finishAtWindow),queueMicrotask(finish)},this.onFocus=event=>{relayNativeEvent(this,event)},this.onBlur=event=>{relayNativeEvent(this,event)},this.onStartSlotChange=()=>{this.syncAdornmentSlots()},this.onEndSlotChange=()=>{this.syncAdornmentSlots()},this.onDefaultSlotChange=()=>{this.isIconButton=this.hasIconOnlyDefaultContent(),this.syncButtonStates()},installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.customValidityMessage),this.updateValidity(),this.syncButtonStates()}get variant(){return this._variant}set variant(next){next==="primary"?this._variant="brand":next==="default"||next==="text"?this._variant="neutral":this._variant=next,next==="text"&&(this.appearance="plain")}get caret(){return this.withCaret}set caret(next){this.withCaret=!!next}get value(){return this._value}set value(next){this._value=next??"",this.updateValidity()}get required(){return this._required}set required(next){this._required=!!next,this.updateValidity()}get resolvedRel(){return resolveGuardedRel(this.rel,this.target)}click(){this.effectiveDisabled||this.loading||this.baseEl?.click()}focus(options){!this.effectiveDisabled&&!this.loading&&this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}[(_a=FORM_CONTROL_LABEL_FACTORY,VALIDITY_ANCHOR)](){return this.baseEl??null}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}setCustomValidity(message){const old=this.customValidityMessage||null,next=message??"";if(this.customValidityMessage=next,this.validityController.setCustomValidity(this.isValidationBarred?"":next),!this.reflectingCustomError){this.reflectingCustomError=!0;try{next?this.setAttribute("custom-error",next):this.removeAttribute("custom-error")}finally{this.reflectingCustomError=!1}}this.requestUpdate("customError",old)}resetValidity(){this.customValidityMessage="",this.validityController.setCustomValidity(""),this.updateValidity()}formStateRestoreCallback(state2,reason){this.value=typeof state2=="string"?state2:""}runClickDefaultAction(){if(this.type==="submit"){const form=this.getForm();if(!form)return;this.hasSubmitterOverrides?this.submitAsNamedSubmitter(form):form.requestSubmit()}else this.type==="reset"&&this.getForm()?.reset()}get hasSubmitterOverrides(){return!!(this.name||this.value||this.formNoValidate)||this.formAction!==void 0||this.formEnctype!==void 0||this.formMethod!==void 0||this.formTarget!==void 0}submitAsNamedSubmitter(form){const submitter=this.ownerDocument.createElement("button");submitter.type="submit",submitter.hidden=!0,submitter.tabIndex=-1,this.name&&(submitter.name=this.name,submitter.value=this.value),this.formAction!==void 0&&submitter.setAttribute("formaction",this.formAction),this.formEnctype!==void 0&&submitter.setAttribute("formenctype",this.formEnctype),this.formMethod!==void 0&&submitter.setAttribute("formmethod",this.formMethod),this.formNoValidate&&(submitter.formNoValidate=!0),this.formTarget!==void 0&&submitter.setAttribute("formtarget",this.formTarget),this.parentElement&&this.closest("form")===form?this.insertAdjacentElement("afterend",submitter):form.append(submitter);try{form.requestSubmit(submitter)}finally{submitter.remove()}}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.updateValidity(),this.syncButtonStates(),this.requestUpdate()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncDescribedByElements(),this.updateValidity(),this.syncButtonStates(),this.hasUpdated&&this.iconOnlyObserver.arm()}disconnectedCallback(){this.releaseExternalDescription(),this.iconOnlyObserver.disarm(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncDescribedByElements()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||this.seedFirstRenderState(()=>{this.syncAdornmentSlots(),this.isIconButton=this.hasIconOnlyDefaultContent()})}syncAdornmentSlots(){const collection=this.children,children=collection?Array.from(collection):[];this.hasStartSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="start"||slot==="prefix"}),this.hasEndSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="end"||slot==="suffix"})}hasIconOnlyDefaultContent(){return hasIconOnlyDefaultContent(this)}get labelGrows(){return this.withCaret||this.hasEndSlot||this.withEnd}updated(changed){super.updated(changed),syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements(),this.iconOnlyObserver.arm(),this.updateValidity(),this.syncButtonStates()}updateValidity(){if(this.validityController){if(this.isValidationBarred){this.validityController.setCustomValidity(""),this.validityController.setValidity({});return}this.required&&!this.value?this.validityController.setValidity({valueMissing:!0},this.localize("fieldRequired")):this.validityController.setValidity({}),this.validityController.setCustomValidity(this.customValidityMessage)}}get isValidationBarred(){return this.effectiveDisabled||this.loading||this.baseEl?.localName==="a"}syncButtonStates(){this.internals&&(setCustomState(this.internals,"disabled",this.effectiveDisabled||this.loading),setCustomState(this.internals,"icon-button",this.isIconButton),setCustomState(this.internals,"link",this.baseEl?.localName==="a"),setCustomState(this.internals,"loading",this.loading))}syncDescribedByElements(){const target=this.isConnected?this.baseEl:void 0;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}render(){const pressed=["true","false","mixed"].includes(this.triggerPressed??"")?this.triggerPressed:nothing,current=["page","step","location","date","time","true","false"].includes(this.triggerCurrent??"")?this.triggerCurrent:nothing,content=html`
|
|
1
|
+
var _a;import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{FORM_CONTROL_LABEL_FACTORY,LyraElement}from"../../../internal/lyra-element.js";import{installFormControlInternalsCapture}from"../../../internal/form-control-labels.js";import{chevronIcon,spinnerIcon}from"../../../internal/icons.js";import{hasIconOnlyDefaultContent,IconOnlyLabelObserver}from"../../../internal/icon-only-content.js";import{safeDownloadHref,safeLinkHref}from"../../../internal/safe-url.js";import{syncAriaControlsElements}from"../../../internal/aria-reflection.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{sizes}from"../../../internal/sizes.styles.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./button.styles.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{getFormOwner,installCustomErrorProperty,setFormOwner}from"../../../internal/direct-form-associated.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState}from"../../../internal/custom-states.js";import{omittedEmptyStringConverter}from"../../../internal/converters.js";import{resolveGuardedRel}from"../../../internal/link-rel.js";import{currentValidityValidator}from"../form-validator.js";import{createButtonExternalLabelController}from"./button-external-label.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";installFormControlInternalsCapture();class LyraButton extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","loading","href","value")]}static{this.styles=[LyraElement.styles,sizes,variants,styles]}static{this.formAssociated=!0}static{this[_a]=createButtonExternalLabelController}static{this.properties={disabled:{type:Boolean,reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},customError:{attribute:"custom-error",reflect:!0,noAccessor:!0}}}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old),this.updateValidity()}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 effectiveDisabled(){return this._disabled||this._fieldsetDisabled}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}constructor(){super(),this._fieldsetDisabled=!1,this._disabled=!1,this._name="",this._value="",this._required=!1,this._variant="neutral",this.localDescriptionIds="",this.customValidityMessage="",this.reflectingCustomError=!1,this.accessibleLabel=null,this.triggerHasPopup=null,this.triggerKeyShortcuts=null,this.triggerExpanded=null,this.triggerPressed=null,this.triggerCurrent=null,this.triggerControls=null,this.triggerDescribedBy=null,this.appearance="accent",this.size="m",this.pill=!1,this.circle=!1,this.outline=!1,this.withCaret=!1,this.withStart=!1,this.withEnd=!1,this.wrap=!1,this.type="button",this.formNoValidate=!1,this.loading=!1,this.hasStartSlot=!1,this.hasEndSlot=!1,this.isIconButton=!1,this.iconOnlyObserver=new IconOnlyLabelObserver(this,()=>this.labelEl,()=>this.isIconButton,next=>{this.isIconButton=next,this.syncButtonStates()}),this.onClick=event=>{if(this.type!=="submit"&&this.type!=="reset")return;const ownerWindow=this.ownerDocument.defaultView;let settled=!1;const finish=()=>{settled||(settled=!0,ownerWindow?.removeEventListener("click",finishAtWindow),!(event.defaultPrevented||this.effectiveDisabled||this.loading)&&this.runClickDefaultAction())},finishAtWindow=candidate=>{candidate===event&&finish()};ownerWindow?.addEventListener("click",finishAtWindow),queueMicrotask(finish)},this.onFocusChange=event=>{relayNativeEvent(this,event)},this.onAdornmentSlotChange=()=>{this.syncAdornmentSlots()},this.onDefaultSlotChange=()=>{this.isIconButton=hasIconOnlyDefaultContent(this),this.syncButtonStates()},installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.customValidityMessage),this.updateValidity(),this.syncButtonStates()}get variant(){return this._variant}set variant(next){next==="primary"?this._variant="brand":next==="default"||next==="text"?this._variant="neutral":this._variant=next,next==="text"&&(this.appearance="plain")}get caret(){return this.withCaret}set caret(next){this.withCaret=!!next}get value(){return this._value}set value(next){this._value=next??"",this.updateValidity()}get required(){return this._required}set required(next){this._required=!!next,this.updateValidity()}get resolvedRel(){return resolveGuardedRel(this.rel,this.target)}click(){this.effectiveDisabled||this.loading||this.baseEl?.click()}focus(options){!this.effectiveDisabled&&!this.loading&&this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}[(_a=FORM_CONTROL_LABEL_FACTORY,VALIDITY_ANCHOR)](){return this.baseEl??null}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}setCustomValidity(message){const old=this.customValidityMessage||null,next=message??"";if(this.customValidityMessage=next,this.validityController.setCustomValidity(this.isValidationBarred?"":next),!this.reflectingCustomError){this.reflectingCustomError=!0;try{next?this.setAttribute("custom-error",next):this.removeAttribute("custom-error")}finally{this.reflectingCustomError=!1}}this.requestUpdate("customError",old)}resetValidity(){this.customValidityMessage="",this.validityController.setCustomValidity(""),this.updateValidity()}formStateRestoreCallback(state2,reason){this.value=typeof state2=="string"?state2:""}runClickDefaultAction(){if(this.type==="submit"){const form=this.getForm();if(!form)return;this.hasSubmitterOverrides?this.submitAsNamedSubmitter(form):form.requestSubmit()}else this.type==="reset"&&this.getForm()?.reset()}get hasSubmitterOverrides(){return!!(this.name||this.value||this.formNoValidate)||this.formAction!==void 0||this.formEnctype!==void 0||this.formMethod!==void 0||this.formTarget!==void 0}submitAsNamedSubmitter(form){const submitter=this.ownerDocument.createElement("button");submitter.type="submit",submitter.hidden=!0,submitter.tabIndex=-1,this.name&&(submitter.name=this.name,submitter.value=this.value),this.formAction!==void 0&&submitter.setAttribute("formaction",this.formAction),this.formEnctype!==void 0&&submitter.setAttribute("formenctype",this.formEnctype),this.formMethod!==void 0&&submitter.setAttribute("formmethod",this.formMethod),this.formNoValidate&&(submitter.formNoValidate=!0),this.formTarget!==void 0&&submitter.setAttribute("formtarget",this.formTarget),this.parentElement&&this.closest("form")===form?this.insertAdjacentElement("afterend",submitter):form.append(submitter);try{form.requestSubmit(submitter)}finally{submitter.remove()}}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.updateValidity(),this.syncButtonStates(),this.requestUpdate()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncDescribedByElements(),this.updateValidity(),this.syncButtonStates(),this.hasUpdated&&this.iconOnlyObserver.arm()}disconnectedCallback(){this.releaseExternalDescription(),this.iconOnlyObserver.disarm(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncDescribedByElements()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||this.seedFirstRenderState(()=>{this.syncAdornmentSlots(),this.isIconButton=hasIconOnlyDefaultContent(this)})}syncAdornmentSlots(){const collection=this.children,children=collection?Array.from(collection):[];this.hasStartSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="start"||slot==="prefix"}),this.hasEndSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="end"||slot==="suffix"})}get labelGrows(){return this.withCaret||this.hasEndSlot||this.withEnd}updated(changed){super.updated(changed),syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements(),this.iconOnlyObserver.arm(),this.updateValidity(),this.syncButtonStates()}updateValidity(){if(this.validityController){if(this.isValidationBarred){this.validityController.setCustomValidity(""),this.validityController.setValidity({});return}this.required&&!this.value?this.validityController.setValidity({valueMissing:!0},this.localize("fieldRequired")):this.validityController.setValidity({}),this.validityController.setCustomValidity(this.customValidityMessage)}}get isValidationBarred(){return this.effectiveDisabled||this.loading||this.baseEl?.localName==="a"}syncButtonStates(){this.internals&&(setCustomState(this.internals,"disabled",this.effectiveDisabled||this.loading),setCustomState(this.internals,"icon-button",this.isIconButton),setCustomState(this.internals,"link",this.baseEl?.localName==="a"),setCustomState(this.internals,"loading",this.loading))}syncDescribedByElements(){const target=this.isConnected?this.baseEl:void 0;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}render(){const pressed=["true","false","mixed"].includes(this.triggerPressed??"")?this.triggerPressed:nothing,current=["page","step","location","date","time","true","false"].includes(this.triggerCurrent??"")?this.triggerCurrent:nothing,content=html`
|
|
2
2
|
<span
|
|
3
3
|
part="start prefix"
|
|
4
4
|
?hidden=${!(this.hasStartSlot||this.withStart)}
|
|
5
5
|
>
|
|
6
|
-
<slot name="start" @slotchange=${this.
|
|
7
|
-
<slot name="prefix" @slotchange=${this.
|
|
6
|
+
<slot name="start" @slotchange=${this.onAdornmentSlotChange}></slot>
|
|
7
|
+
<slot name="prefix" @slotchange=${this.onAdornmentSlotChange}></slot>
|
|
8
8
|
</span>
|
|
9
9
|
<span part="label"
|
|
10
10
|
><slot @slotchange=${this.onDefaultSlotChange}></slot
|
|
11
11
|
></span>
|
|
12
12
|
<span part="end suffix" ?hidden=${!(this.hasEndSlot||this.withEnd)}>
|
|
13
|
-
<slot name="end" @slotchange=${this.
|
|
14
|
-
<slot name="suffix" @slotchange=${this.
|
|
13
|
+
<slot name="end" @slotchange=${this.onAdornmentSlotChange}></slot>
|
|
14
|
+
<slot name="suffix" @slotchange=${this.onAdornmentSlotChange}></slot>
|
|
15
15
|
</span>
|
|
16
16
|
${this.withCaret?html`<span part="caret" aria-hidden="true">${chevronIcon()}</span>`:nothing}
|
|
17
17
|
${this.loading?html`<span part="spinner" aria-hidden="true">${spinnerIcon()}</span>`:""}
|
|
@@ -34,8 +34,8 @@ var _a;import{__decorate}from"tslib";import{html,nothing}from"lit";import{proper
|
|
|
34
34
|
aria-disabled=${disabled?"true":"false"}
|
|
35
35
|
aria-busy=${this.loading?"true":"false"}
|
|
36
36
|
tabindex=${disabled?"-1":nothing}
|
|
37
|
-
@focus=${this.
|
|
38
|
-
@blur=${this.
|
|
37
|
+
@focus=${this.onFocusChange}
|
|
38
|
+
@blur=${this.onFocusChange}
|
|
39
39
|
>${content}</a
|
|
40
40
|
>`}return html`
|
|
41
41
|
<button
|
|
@@ -54,8 +54,8 @@ var _a;import{__decorate}from"tslib";import{html,nothing}from"lit";import{proper
|
|
|
54
54
|
aria-busy=${this.loading?"true":"false"}
|
|
55
55
|
?disabled=${this.effectiveDisabled||this.loading}
|
|
56
56
|
@click=${this.onClick}
|
|
57
|
-
@focus=${this.
|
|
58
|
-
@blur=${this.
|
|
57
|
+
@focus=${this.onFocusChange}
|
|
58
|
+
@blur=${this.onFocusChange}
|
|
59
59
|
>
|
|
60
60
|
${content}
|
|
61
61
|
</button>
|
|
@@ -39,9 +39,7 @@ export interface ComboboxFilterDetail{value:string;}export type{LyraPickerDetail
|
|
|
39
39
|
/** `detail.data` is index-aligned with `detail.value`: `data[i]` is the opaque `data` payload
|
|
40
40
|
* behind `value[i]` (light-DOM `<lr-option data>` or an async source row's own `data`), by
|
|
41
41
|
* reference and never deep-cloned, or `undefined` for a value resolving to no live row/option. */
|
|
42
|
-
'lr-change':CustomEvent<LyraEventDetailSnapshot<{readonly value:LyraPickerDetailValue<Multiple>;readonly data:readonly unknown[];}>>;'lr-activate':CustomEvent<{value:string;}>;'lr-source-error':CustomEvent<{error:unknown;query:string;}>;'lr-retry-request':CustomEvent<null>;
|
|
43
|
-
/** @deprecated Use `lr-retry-request`; removal not before 24.0.0. */
|
|
44
|
-
'lr-retry':CustomEvent<null>;input:InputEvent|CustomEvent<LyraEventDetailSnapshot<{readonly value:LyraPickerDetailValue<Multiple>;readonly data:readonly unknown[];}>>;change:CustomEvent<LyraEventDetailSnapshot<{readonly value:LyraPickerDetailValue<Multiple>;readonly data:readonly unknown[];}>>;blur:FocusEvent;focus:FocusEvent;}
|
|
42
|
+
'lr-change':CustomEvent<LyraEventDetailSnapshot<{readonly value:LyraPickerDetailValue<Multiple>;readonly data:readonly unknown[];}>>;'lr-activate':CustomEvent<{value:string;}>;'lr-source-error':CustomEvent<{error:unknown;query:string;}>;'lr-retry-request':CustomEvent<null>;input:InputEvent|CustomEvent<LyraEventDetailSnapshot<{readonly value:LyraPickerDetailValue<Multiple>;readonly data:readonly unknown[];}>>;change:CustomEvent<LyraEventDetailSnapshot<{readonly value:LyraPickerDetailValue<Multiple>;readonly data:readonly unknown[];}>>;blur:FocusEvent;focus:FocusEvent;}
|
|
45
43
|
/**
|
|
46
44
|
* Stable per-event aliases, so a host can name one event's type without restating the detail
|
|
47
45
|
* schema (or re-deriving it from `LyraComboboxEventMap`). Each narrows with the same `Multiple`
|
|
@@ -141,7 +139,6 @@ export type LyraComboboxChangeEvent<Multiple extends boolean=boolean> =LyraCombo
|
|
|
141
139
|
* closing the listbox) by the time the rejection settles. Not cancelable — the failure has
|
|
142
140
|
* already happened and the error row is already what rendered, so there is nothing to veto.
|
|
143
141
|
* @event lr-retry-request - Cancelable retry proposal before the default retry action. `detail: null`.
|
|
144
|
-
* @event lr-retry - Deprecated veto alias of `lr-retry-request`; removal not before 24.0.0.
|
|
145
142
|
* The failed-load state's `[part='retry-button']` was activated. Cancelable —
|
|
146
143
|
* the built-in action calls `refresh()`, and `preventDefault()` leaves the failure on screen for
|
|
147
144
|
* a host that owns its own retry timing.
|