@aceshooting/lyra-ui 9.1.1 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +597 -0
- package/custom-elements.json +1 -1
- package/dist/cli/migrate-wa.mjs +52 -0
- package/dist/cli/migration-contract.json +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +0 -16
- package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.js +1 -1
- package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.styles.js +7 -5
- package/dist/components/agent-tools/agent-run/agent-run.class.js +2 -2
- package/dist/components/agent-tools/agent-run/agent-run.styles.js +0 -13
- package/dist/components/agent-tools/agent-trace/agent-trace.styles.js +7 -4
- package/dist/components/agent-tools/approval-queue/approval-queue.styles.js +7 -5
- package/dist/components/agent-tools/artifact-panel/artifact-panel.styles.js +0 -3
- package/dist/components/agent-tools/browser-frame/browser-frame.styles.js +3 -5
- package/dist/components/agent-tools/commit-card/commit-card.styles.js +0 -10
- package/dist/components/agent-tools/compare-panel/compare-panel.styles.js +11 -6
- package/dist/components/agent-tools/confirm-bar/confirm-bar.styles.js +0 -46
- package/dist/components/agent-tools/eval-dataset/eval-dataset.styles.js +0 -7
- package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +2 -2
- package/dist/components/agent-tools/prompt-studio/prompt-studio.styles.js +0 -15
- package/dist/components/agent-tools/result-card/result-card.styles.js +0 -7
- package/dist/components/agent-tools/result-card/result-field.styles.js +0 -5
- package/dist/components/agent-tools/schema-viewer/schema-viewer.styles.js +0 -3
- package/dist/components/agent-tools/span-waterfall/span-waterfall.styles.js +0 -15
- package/dist/components/agent-tools/stack-trace/stack-trace.styles.js +0 -20
- package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +2 -2
- package/dist/components/agent-tools/subagent-panel/subagent-panel.styles.js +0 -3
- package/dist/components/agent-tools/task-list/task-list.styles.js +0 -15
- package/dist/components/agent-tools/terminal/terminal.class.d.ts +11 -6
- package/dist/components/agent-tools/terminal/terminal.class.js +4 -4
- package/dist/components/agent-tools/terminal/terminal.styles.js +0 -46
- package/dist/components/agent-tools/test-results/test-results.class.js +2 -2
- package/dist/components/agent-tools/test-results/test-results.styles.js +0 -5
- package/dist/components/agent-tools/thinking-panel/thinking-panel.styles.js +0 -41
- package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.styles.js +0 -41
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.styles.js +0 -30
- package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +6 -6
- package/dist/components/agent-tools/tool-param-form/tool-param-form.styles.js +0 -5
- package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.styles.js +0 -20
- package/dist/components/agent-tools/tool-result-view/tool-result-view.styles.js +0 -4
- package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.styles.js +0 -21
- package/dist/components/agent-tools/trace-tree/trace-tree.styles.js +7 -31
- package/dist/components/charts/chart/box-plot.styles.js +0 -20
- package/dist/components/charts/chart/chart-colors.d.ts +1 -1
- package/dist/components/charts/chart/chart-colors.js +1 -1
- package/dist/components/charts/chart/chart-core-loader.d.ts +1 -0
- package/dist/components/charts/chart/chart-core-loader.js +1 -1
- package/dist/components/charts/chart/chart-feature-loader.d.ts +35 -0
- package/dist/components/charts/chart/chart-feature-loader.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +93 -0
- package/dist/components/charts/chart/chart.class.js +3 -3
- package/dist/components/charts/chart/chart.styles.js +0 -27
- package/dist/components/charts/chart/lite-chart.class.d.ts +20 -1
- package/dist/components/charts/chart/lite-chart.class.js +4 -4
- package/dist/components/charts/chart/lite-chart.styles.js +0 -27
- package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +20 -0
- package/dist/components/conversation/agent-workspace/agent-workspace.class.js +3 -1
- package/dist/components/conversation/agent-workspace/agent-workspace.styles.js +3 -0
- package/dist/components/conversation/audio-visualizer/audio-visualizer.styles.js +0 -7
- package/dist/components/conversation/branch-picker/branch-picker.styles.js +0 -3
- package/dist/components/conversation/chat-composer/chat-composer.styles.js +0 -51
- package/dist/components/conversation/chat-message/chat-message.styles.js +7 -35
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
- package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +0 -33
- package/dist/components/conversation/checkpoint/checkpoint.class.js +1 -1
- package/dist/components/conversation/checkpoint/checkpoint.styles.js +0 -3
- package/dist/components/conversation/code-block/code-block-shared.d.ts +5 -2
- package/dist/components/conversation/code-block/code-block.class.js +1 -1
- package/dist/components/conversation/code-block/code-block.styles.js +4 -95
- package/dist/components/conversation/code-block/code-loader.d.ts +11 -0
- package/dist/components/conversation/code-block/code-loader.js +1 -1
- package/dist/components/conversation/code-block/shiki-types.d.ts +12 -0
- package/dist/components/conversation/code-block/shiki-types.js +1 -1
- package/dist/components/conversation/conversation-item/conversation-item.styles.js +8 -54
- package/dist/components/conversation/generation-metrics/generation-metrics.class.js +2 -2
- package/dist/components/conversation/generation-metrics/generation-metrics.styles.js +0 -17
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown.styles.js +0 -41
- package/dist/components/conversation/message-actions/message-actions.styles.js +0 -3
- package/dist/components/conversation/message-feedback/message-feedback.styles.js +0 -35
- package/dist/components/conversation/message-parts/message-parts.class.d.ts +1 -1
- package/dist/components/conversation/message-parts/message-parts.styles.js +0 -5
- package/dist/components/conversation/model-select/model-select.class.js +3 -3
- package/dist/components/conversation/model-select/model-select.styles.js +12 -47
- package/dist/components/conversation/model-settings-panel/model-settings-panel.styles.js +0 -6
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +3 -0
- package/dist/components/conversation/prompt-input/prompt-input.styles.js +0 -10
- package/dist/components/conversation/push-to-talk/push-to-talk.styles.js +0 -8
- package/dist/components/conversation/selection-toolbar/selection-toolbar.styles.js +1 -11
- package/dist/components/conversation/stream-status/stream-status.styles.js +0 -16
- package/dist/components/conversation/streaming-text/streaming-text.styles.js +0 -15
- package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +0 -5
- package/dist/components/conversation/thread-list/thread-list.styles.js +0 -23
- package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +16 -4
- package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
- package/dist/components/conversation/transcript-feed/transcript-feed.styles.js +0 -1
- package/dist/components/conversation/typing-indicator/typing-indicator.styles.js +0 -23
- package/dist/components/conversation/usage-badge/usage-badge.styles.js +0 -3
- package/dist/components/conversation/voice-picker/voice-picker.class.js +3 -3
- package/dist/components/conversation/voice-picker/voice-picker.styles.js +9 -29
- package/dist/components/conversation/widget-renderer/resolve.d.ts +2 -0
- package/dist/components/conversation/widget-renderer/resolve.js +1 -1
- package/dist/components/data/calendar/calendar.class.d.ts +15 -2
- package/dist/components/data/calendar/calendar.class.js +2 -2
- package/dist/components/data/calendar/calendar.styles.js +2 -28
- package/dist/components/data/condition-builder/condition-builder.class.d.ts +10 -6
- package/dist/components/data/condition-builder/condition-builder.class.js +2 -2
- package/dist/components/data/condition-builder/condition-builder.styles.js +0 -6
- package/dist/components/data/context-meter/context-meter.styles.js +0 -24
- package/dist/components/data/data-grid/data-grid.class.js +3 -3
- package/dist/components/data/data-grid/data-grid.styles.js +0 -22
- package/dist/components/data/document-library/document-library.class.js +2 -2
- package/dist/components/data/document-library/document-library.styles.js +0 -4
- package/dist/components/data/env-list/env-list.class.js +1 -1
- package/dist/components/data/env-list/env-list.styles.js +7 -4
- package/dist/components/data/file-tree/file-tree.class.d.ts +12 -0
- package/dist/components/data/flow-canvas/flow-canvas.styles.js +12 -19
- package/dist/components/data/flow-controls/flow-controls.class.js +2 -2
- package/dist/components/data/flow-controls/flow-controls.styles.js +3 -36
- package/dist/components/data/flow-minimap/flow-minimap.class.js +1 -1
- package/dist/components/data/flow-minimap/flow-minimap.styles.js +0 -9
- package/dist/components/data/flow-node/flow-node.styles.js +0 -23
- package/dist/components/data/flow-run-status/flow-run-status.class.js +1 -1
- package/dist/components/data/flow-run-status/flow-run-status.styles.js +0 -7
- package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +0 -7
- package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
- package/dist/components/data/graph-query-builder/graph-query-builder.styles.js +0 -10
- package/dist/components/data/heatmap/heatmap-scale.d.ts +20 -0
- package/dist/components/data/heatmap/heatmap-scale.js +1 -1
- package/dist/components/data/heatmap/heatmap.class.d.ts +84 -1
- package/dist/components/data/heatmap/heatmap.class.js +2 -2
- package/dist/components/data/heatmap/heatmap.styles.js +0 -54
- package/dist/components/data/pagination/pagination.styles.js +23 -46
- package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +34 -1
- package/dist/components/data/sequence-strip/sequence-strip.class.js +5 -2
- package/dist/components/data/sequence-strip/sequence-strip.styles.js +14 -20
- package/dist/components/data/sparkline/sparkline.class.js +1 -1
- package/dist/components/data/stat/stat.styles.js +0 -67
- package/dist/components/data/table/table.class.d.ts +42 -3
- package/dist/components/data/table/table.class.js +4 -4
- package/dist/components/data/table/table.styles.js +20 -91
- package/dist/components/data/timeline/timeline-item.styles.js +0 -30
- package/dist/components/data/timeline/timeline.class.d.ts +89 -1
- package/dist/components/data/timeline/timeline.class.js +2 -2
- package/dist/components/data/timeline/timeline.styles.js +111 -31
- package/dist/components/data/tree/tree-item.styles.js +1 -28
- package/dist/components/data/tree/tree.class.js +2 -2
- package/dist/components/data/tree/tree.styles.js +0 -6
- package/dist/components/data/word-cloud/word-cloud.styles.js +0 -5
- package/dist/components/forms/button/button.class.js +1 -1
- package/dist/components/forms/button/button.styles.js +0 -105
- package/dist/components/forms/checkbox/checkbox.class.d.ts +3 -0
- package/dist/components/forms/checkbox/checkbox.class.js +1 -1
- package/dist/components/forms/checkbox/checkbox.styles.js +0 -39
- package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +21 -2
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
- package/dist/components/forms/checkbox-group/checkbox-group.styles.js +0 -18
- package/dist/components/forms/code-editor/code-editor.styles.js +0 -30
- package/dist/components/forms/color-picker/color-picker.class.js +2 -2
- package/dist/components/forms/color-picker/color-picker.styles.js +0 -69
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/forms/combobox/combobox.styles.js +22 -111
- package/dist/components/forms/combobox/option.styles.js +7 -1
- package/dist/components/forms/date-picker/date-input.class.js +1 -1
- package/dist/components/forms/date-picker/date-input.styles.js +12 -67
- package/dist/components/forms/date-picker/date-picker.class.d.ts +1 -0
- package/dist/components/forms/date-picker/date-picker.class.js +22 -20
- package/dist/components/forms/date-picker/date-picker.styles.js +36 -29
- package/dist/components/forms/emoji-picker/emoji-data-loader.d.ts +6 -3
- package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +8 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.styles.js +3 -41
- package/dist/components/forms/icon-button/icon-button.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.styles.js +0 -16
- package/dist/components/forms/input/input.styles.js +0 -54
- package/dist/components/forms/input/number-input.styles.d.ts +4 -5
- package/dist/components/forms/input/number-input.styles.js +0 -11
- package/dist/components/forms/input/time-input-shared.d.ts +11 -0
- package/dist/components/forms/input/time-input-shared.js +1 -1
- package/dist/components/forms/input/time-input.class.d.ts +11 -2
- package/dist/components/forms/input/time-input.class.js +1 -1
- package/dist/components/forms/input/time-input.styles.js +0 -6
- package/dist/components/forms/locale-picker/locale-picker.class.js +2 -2
- package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -26
- package/dist/components/forms/otp-input/otp-input.class.js +3 -3
- package/dist/components/forms/otp-input/otp-input.styles.js +0 -16
- package/dist/components/forms/phone-input/phone-input.class.d.ts +9 -1
- package/dist/components/forms/phone-input/phone-input.class.js +2 -2
- package/dist/components/forms/phone-input/phone-input.styles.js +0 -37
- package/dist/components/forms/radio/radio-button.styles.js +1 -30
- package/dist/components/forms/radio/radio-group.styles.js +0 -4
- package/dist/components/forms/radio/radio.styles.js +0 -44
- package/dist/components/forms/rubric-form/rubric-form.styles.js +0 -5
- package/dist/components/forms/select/select.class.js +1 -1
- package/dist/components/forms/select/select.styles.js +14 -114
- package/dist/components/forms/slider/slider.styles.js +0 -55
- package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +0 -11
- package/dist/components/forms/swatch-picker/swatch-picker.class.js +2 -2
- package/dist/components/forms/swatch-picker/swatch-picker.styles.js +0 -77
- package/dist/components/forms/switch/switch.class.d.ts +3 -0
- package/dist/components/forms/switch/switch.class.js +1 -1
- package/dist/components/forms/switch/switch.styles.js +0 -37
- package/dist/components/forms/textarea/textarea.styles.js +0 -28
- package/dist/components/forms/time-range/time-range.styles.js +12 -84
- package/dist/components/forms/token-input/token-input.class.d.ts +23 -9
- package/dist/components/forms/token-input/token-input.class.js +1 -1
- package/dist/components/forms/token-input/token-input.styles.js +1 -54
- package/dist/components/layout/app-rail/app-rail-item.class.js +2 -2
- package/dist/components/layout/app-rail/app-rail-item.styles.js +0 -13
- package/dist/components/layout/app-rail/app-rail.class.d.ts +5 -0
- package/dist/components/layout/app-rail/app-rail.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.styles.js +0 -46
- package/dist/components/layout/button-group/button-group.styles.js +0 -6
- package/dist/components/layout/card/card.class.d.ts +12 -0
- package/dist/components/layout/card/card.styles.js +3 -11
- package/dist/components/layout/carousel/carousel.styles.js +0 -1
- package/dist/components/layout/command-palette/command-palette.class.d.ts +8 -0
- package/dist/components/layout/command-palette/command-palette.class.js +3 -1
- package/dist/components/layout/command-palette/command-palette.styles.js +1 -13
- package/dist/components/layout/control-group/control-group.styles.js +0 -7
- package/dist/components/layout/dashboard-grid/dashboard-grid.styles.js +6 -25
- package/dist/components/layout/details/accordion.class.d.ts +13 -0
- package/dist/components/layout/details/accordion.class.js +1 -1
- package/dist/components/layout/details/details.class.js +1 -1
- package/dist/components/layout/details/details.styles.js +0 -12
- package/dist/components/layout/dock-panel/dock-panel.styles.js +0 -45
- package/dist/components/layout/drilldown-panel/drilldown-panel.class.d.ts +2 -0
- package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +2 -2
- package/dist/components/layout/drilldown-panel/drilldown-panel.styles.js +0 -4
- package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
- package/dist/components/layout/filter-bar/filter-bar.styles.js +0 -9
- package/dist/components/layout/menu/menu-item.class.d.ts +5 -0
- package/dist/components/layout/menu/menu-item.class.js +1 -1
- package/dist/components/layout/menu/menu-item.styles.js +0 -49
- package/dist/components/layout/menu/menu-label.styles.js +0 -2
- package/dist/components/layout/menu/menu.styles.js +0 -18
- package/dist/components/layout/multi-split/multi-split.styles.js +0 -63
- package/dist/components/layout/page/page.class.d.ts +4 -0
- package/dist/components/layout/page/page.class.js +1 -1
- package/dist/components/layout/reorder-list/reorder-item.styles.js +0 -4
- package/dist/components/layout/responsive-panel/responsive-panel.styles.js +0 -27
- package/dist/components/layout/scroller/scroller.styles.js +0 -20
- package/dist/components/layout/segmented/segmented.class.d.ts +7 -1
- package/dist/components/layout/segmented/segmented.class.js +1 -1
- package/dist/components/layout/segmented/segmented.styles.js +69 -37
- package/dist/components/layout/split-panel/split-panel.styles.js +1 -7
- package/dist/components/layout/stepper/stepper.class.d.ts +8 -1
- package/dist/components/layout/stepper/stepper.class.js +1 -1
- package/dist/components/layout/stepper/stepper.styles.js +140 -41
- package/dist/components/layout/tab-group/tab-group.class.d.ts +4 -1
- package/dist/components/layout/tab-group/tab-group.styles.js +9 -75
- package/dist/components/layout/tab-group/tab.styles.js +0 -2
- package/dist/components/layout/virtual-list/virtual-list.class.d.ts +4 -4
- package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.styles.js +0 -68
- package/dist/components/layout/widget/widget.class.d.ts +5 -1
- package/dist/components/layout/widget/widget.class.js +1 -1
- package/dist/components/layout/widget/widget.styles.js +97 -40
- package/dist/components/media/animated-image/animated-image.class.d.ts +3 -0
- package/dist/components/media/animated-image/animated-image.class.js +1 -1
- package/dist/components/media/animated-image/animated-image.styles.js +0 -28
- package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +1 -1
- package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
- package/dist/components/media/attachment-chip/attachment-chip.styles.js +0 -31
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
- package/dist/components/media/attachment-trigger/attachment-trigger.styles.js +0 -40
- package/dist/components/media/av-player/av-player.class.d.ts +5 -6
- package/dist/components/media/av-player/av-player.class.js +1 -1
- package/dist/components/media/av-player/av-player.styles.js +0 -45
- package/dist/components/media/avatar/avatar.styles.js +3 -16
- package/dist/components/media/file-icon/file-icon.class.d.ts +1 -2
- package/dist/components/media/file-icon/file-icon.class.js +1 -1
- package/dist/components/media/file-input/file-input.class.d.ts +12 -0
- package/dist/components/media/file-input/file-input.styles.js +3 -24
- package/dist/components/media/flag/flag.class.d.ts +20 -0
- package/dist/components/media/flag/flag.class.js +4 -2
- package/dist/components/media/flag/flag.styles.js +7 -1
- package/dist/components/media/flag/language-map.d.ts +10 -0
- package/dist/components/media/flag/language-map.js +1 -1
- package/dist/components/media/image-comparer/image-comparer.styles.js +4 -33
- package/dist/components/media/image-viewer/image-viewer.class.js +0 -2
- package/dist/components/media/image-viewer/image-viewer.styles.js +7 -27
- package/dist/components/media/lightbox/lightbox.class.js +0 -2
- package/dist/components/media/lightbox/lightbox.styles.js +0 -21
- package/dist/components/media/map/map-loader.d.ts +19 -1
- package/dist/components/media/map/map-loader.js +1 -1
- package/dist/components/media/map/map.class.d.ts +141 -1
- package/dist/components/media/map/map.class.js +15 -3
- package/dist/components/media/map/map.styles.js +20 -17
- package/dist/components/media/media-card/media-card.class.d.ts +14 -3
- package/dist/components/media/media-card/media-card.class.js +1 -1
- package/dist/components/media/media-card/media-card.styles.js +2 -28
- package/dist/components/media/pan-zoom/pan-zoom.styles.js +0 -3
- package/dist/components/media/qr-code/qr-code.class.d.ts +3 -2
- package/dist/components/media/qr-code/qr-code.class.js +2 -2
- package/dist/components/media/qr-code/qr-code.styles.js +0 -3
- package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +2 -0
- package/dist/components/media/sequence-playback/sequence-playback.class.js +2 -1
- package/dist/components/media/sequence-playback/sequence-playback.styles.js +0 -19
- package/dist/components/media/video/video.class.d.ts +23 -2
- package/dist/components/media/video/video.class.js +3 -3
- package/dist/components/media/video/video.styles.js +4 -2
- package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +3 -2
- package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
- package/dist/components/media/zoomable-frame/zoomable-frame.styles.js +0 -5
- package/dist/components/overlays/alert/alert.styles.js +4 -2
- package/dist/components/overlays/badge/badge.styles.js +4 -48
- package/dist/components/overlays/badge/tag.styles.js +0 -14
- package/dist/components/overlays/callout/callout.styles.js +0 -11
- package/dist/components/overlays/chip/chip-group.styles.js +0 -18
- package/dist/components/overlays/chip/chip.styles.js +6 -69
- package/dist/components/overlays/dialog/confirm.d.ts +1 -4
- package/dist/components/overlays/dialog/confirm.js +1 -1
- package/dist/components/overlays/dialog/dialog.class.d.ts +12 -9
- package/dist/components/overlays/dialog/dialog.class.js +1 -1
- package/dist/components/overlays/dialog/dialog.styles.js +0 -43
- package/dist/components/overlays/drawer/drawer.class.d.ts +2 -2
- package/dist/components/overlays/drawer/drawer.styles.js +0 -9
- package/dist/components/overlays/empty/empty.styles.js +0 -12
- package/dist/components/overlays/kbd/kbd.styles.js +0 -8
- package/dist/components/overlays/overlay/dropdown.class.d.ts +1 -6
- package/dist/components/overlays/overlay/dropdown.class.js +2 -2
- package/dist/components/overlays/overlay/overlay.styles.js +0 -28
- package/dist/components/overlays/overlay/popover.class.d.ts +9 -1
- package/dist/components/overlays/overlay/popover.class.js +2 -2
- package/dist/components/overlays/overlay/tooltip.class.d.ts +10 -0
- package/dist/components/overlays/overlay/tooltip.class.js +1 -1
- package/dist/components/overlays/popup/popup.class.d.ts +1 -0
- package/dist/components/overlays/popup/popup.class.js +1 -1
- package/dist/components/overlays/popup/popup.styles.js +0 -15
- package/dist/components/overlays/progress/progress-ring.class.d.ts +9 -1
- package/dist/components/overlays/progress/progress-ring.class.js +3 -3
- package/dist/components/overlays/progress/progress.styles.js +0 -21
- package/dist/components/overlays/rating/rating.styles.js +0 -25
- package/dist/components/overlays/skeleton/skeleton.styles.js +0 -4
- package/dist/components/overlays/spinner/spinner.styles.js +0 -3
- package/dist/components/overlays/toast/toast-item.styles.js +3 -45
- package/dist/components/retrieval/chunk-inspector/chunk-inspector.styles.js +0 -35
- package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +2 -2
- package/dist/components/retrieval/citation-badge/citation-badge.class.js +3 -3
- package/dist/components/retrieval/citation-badge/citation-badge.styles.js +0 -20
- package/dist/components/retrieval/claim-evidence/claim-evidence.styles.js +0 -8
- package/dist/components/retrieval/community-card/community-card.class.d.ts +1 -0
- package/dist/components/retrieval/community-card/community-card.styles.js +0 -6
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +8 -12
- package/dist/components/retrieval/entity-card/entity-card.class.d.ts +4 -3
- package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
- package/dist/components/retrieval/entity-card/entity-card.styles.js +0 -12
- package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +10 -4
- package/dist/components/retrieval/entity-chip/entity-chip.class.js +3 -3
- package/dist/components/retrieval/entity-chip/entity-chip.styles.js +6 -9
- package/dist/components/retrieval/entity-dossier/entity-dossier.class.d.ts +19 -5
- package/dist/components/retrieval/graph/graph.class.d.ts +5 -0
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/graph/graph.styles.js +0 -30
- package/dist/components/retrieval/graph-legend/graph-legend.styles.js +0 -3
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +0 -25
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.d.ts +2 -0
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.styles.js +0 -7
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +20 -6
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +2 -2
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +0 -16
- package/dist/components/retrieval/mind-map/mind-map.class.d.ts +5 -3
- package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map.styles.js +0 -2
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +3 -2
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.styles.js +0 -30
- package/dist/components/retrieval/node-palette/node-palette.styles.js +0 -11
- package/dist/components/retrieval/path-strip/path-strip.styles.js +0 -10
- package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +12 -3
- package/dist/components/retrieval/provenance-panel/provenance-panel.styles.js +0 -2
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +3 -2
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +2 -2
- package/dist/components/retrieval/retrieval-results/retrieval-results.styles.js +0 -28
- package/dist/components/retrieval/retrieval-search/retrieval-search.styles.js +0 -4
- package/dist/components/retrieval/retrieval-trace/retrieval-trace.styles.js +0 -2
- package/dist/components/retrieval/source-card/source-card.styles.js +0 -13
- package/dist/components/retrieval/source-list/source-list.styles.js +0 -7
- package/dist/components/retrieval/source-picker/source-picker.styles.js +0 -7
- package/dist/components/utility/copy-button/copy-button.styles.js +0 -10
- package/dist/components/utility/diff-view/diff-view.styles.js +0 -14
- package/dist/components/utility/export-button/export-button.styles.js +0 -22
- package/dist/components/utility/icon/icon.styles.js +0 -6
- package/dist/components/utility/json-viewer/json-viewer.styles.js +2 -48
- package/dist/components/utility/known-date/known-date.class.d.ts +7 -3
- package/dist/components/utility/known-date/known-date.styles.js +10 -51
- package/dist/components/utility/live-region/live-region.styles.js +0 -4
- package/dist/components/utility/mention-popover/mention-popover.styles.js +0 -25
- package/dist/components/utility/poll-status/poll-status.styles.js +0 -4
- package/dist/components/utility/random-content/random-content.class.d.ts +22 -0
- package/dist/components/utility/random-content/random-content.class.js +3 -2
- package/dist/components/utility/random-content/random-content.styles.js +6 -13
- package/dist/components/utility/tour/tour.class.d.ts +4 -2
- package/dist/components/utility/tour/tour.class.js +3 -3
- package/dist/components/utility/tour/tour.styles.js +0 -13
- package/dist/components/utility/visually-hidden/visually-hidden.styles.js +0 -5
- package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
- package/dist/components/viewers/archive-viewer/archive-viewer.styles.d.ts +2 -2
- package/dist/components/viewers/archive-viewer/archive-viewer.styles.js +0 -10
- package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
- package/dist/components/viewers/csv-viewer/csv-viewer.styles.js +0 -19
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
- package/dist/components/viewers/dataset-viewer/dataset-viewer.styles.js +0 -15
- package/dist/components/viewers/document-compare/document-compare.styles.js +0 -3
- package/dist/components/viewers/document-preview/document-preview.styles.js +0 -25
- package/dist/components/viewers/document-viewer/document-viewer.class.d.ts +2 -1
- package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
- package/dist/components/viewers/document-viewer/document-viewer.styles.js +0 -5
- package/dist/components/viewers/docx-viewer/docx-viewer.styles.js +0 -17
- package/dist/components/viewers/ebook-viewer/ebook-viewer.styles.js +0 -4
- package/dist/components/viewers/email-viewer/email-viewer.styles.js +0 -7
- package/dist/components/viewers/geojson-view/geojson-view.styles.js +0 -5
- package/dist/components/viewers/highlight-layer/highlight-layer.styles.js +0 -3
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
- package/dist/components/viewers/notebook-viewer/notebook-viewer.styles.js +0 -38
- package/dist/components/viewers/page-rail/page-rail.class.js +1 -1
- package/dist/components/viewers/page-rail/page-rail.styles.js +0 -13
- package/dist/components/viewers/pdf-viewer/pdf-loader.d.ts +13 -2
- package/dist/components/viewers/pdf-viewer/pdf-loader.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +32 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
- package/dist/components/viewers/pdf-viewer/pdf-viewer.styles.js +1 -27
- package/dist/components/viewers/pptx-viewer/pptx-viewer.styles.js +0 -3
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.styles.js +0 -14
- package/dist/components/viewers/svg-viewer/svg-viewer.styles.js +0 -7
- package/dist/components/viewers/xml-viewer/xml-viewer.styles.js +2 -24
- package/dist/custom-elements-jsx.d.ts +56 -37
- package/dist/events.d.ts +43 -33
- package/dist/internal/agent-status-variants.d.ts +18 -0
- package/dist/internal/agent-status-variants.js +1 -0
- package/dist/internal/announcer.d.ts +8 -3
- package/dist/internal/announcer.js +1 -1
- package/dist/internal/autoloader-manifest.js +1 -1
- package/dist/internal/canvas-color.d.ts +16 -0
- package/dist/internal/canvas-color.js +1 -1
- package/dist/internal/catalog-picker.d.ts +0 -1
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/default-strings.generated.d.ts +1 -0
- package/dist/internal/default-strings.generated.js +1 -1
- package/dist/internal/dev-mode-attribute-warning.d.ts +27 -4
- package/dist/internal/dev-mode-attribute-warning.js +1 -1
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/lyra-element.d.ts +13 -0
- package/dist/internal/lyra-element.js +1 -1
- package/dist/internal/media-controller.js +1 -1
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/scroll-overflow.d.ts +35 -13
- package/dist/internal/scroll-overflow.js +1 -1
- package/dist/internal/sizes.styles.js +0 -2
- package/dist/internal/specialist-tokens.styles.js +6 -11
- package/dist/internal/text-highlights.d.ts +4 -1
- package/dist/internal/text-highlights.js +1 -1
- package/dist/internal/tokens/palette.styles.js +0 -15
- package/dist/internal/tokens.styles.js +19 -113
- package/dist/lyra.d.ts +8 -5
- package/dist/styles/reservations.css +82 -0
- package/dist/svelte.d.ts +56 -37
- package/dist/translations/ar.js +1 -1
- package/dist/translations/de.js +1 -1
- package/dist/translations/es.js +1 -1
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/he.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/translations/pt-BR.js +1 -1
- package/dist/translations/ru.js +1 -1
- package/dist/translations/zh-CN.js +1 -1
- package/dist/vue.d.ts +56 -37
- package/llms/components/lr-accordion-item.md +12 -3
- package/llms/components/lr-accordion.md +11 -2
- package/llms/components/lr-agent-eval-dashboard.md +1 -1
- package/llms/components/lr-agent-trace.md +3 -1
- package/llms/components/lr-agent-workspace.md +20 -0
- package/llms/components/lr-artifact-panel.md +10 -4
- package/llms/components/lr-attachment-chip.md +7 -4
- package/llms/components/lr-attachment-trigger.md +7 -4
- package/llms/components/lr-av-player.md +3 -1
- package/llms/components/lr-avatar.md +6 -6
- package/llms/components/lr-bar-chart.md +4 -3
- package/llms/components/lr-box-plot.md +1 -1
- package/llms/components/lr-browser-frame.md +7 -3
- package/llms/components/lr-bubble-chart.md +4 -3
- package/llms/components/lr-calendar.md +9 -2
- package/llms/components/lr-card.md +24 -0
- package/llms/components/lr-chart.md +32 -8
- package/llms/components/lr-chat-viewport.md +7 -2
- package/llms/components/lr-checkbox-group.md +13 -5
- package/llms/components/lr-checkbox.md +5 -2
- package/llms/components/lr-checkpoint.md +6 -2
- package/llms/components/lr-combobox.md +5 -2
- package/llms/components/lr-command-palette.md +4 -1
- package/llms/components/lr-confirm-bar.md +7 -3
- package/llms/components/lr-context-meter.md +12 -11
- package/llms/components/lr-conversation-item.md +7 -4
- package/llms/components/lr-details.md +11 -2
- package/llms/components/lr-dialog.md +15 -10
- package/llms/components/lr-dock-panel.md +7 -10
- package/llms/components/lr-document-preview.md +6 -1
- package/llms/components/lr-document-viewer.md +3 -2
- package/llms/components/lr-doughnut-chart.md +4 -3
- package/llms/components/lr-drawer.md +3 -3
- package/llms/components/lr-entity-card.md +3 -3
- package/llms/components/lr-entity-chip.md +1 -1
- package/llms/components/lr-entity-dossier.md +4 -1
- package/llms/components/lr-file-input.md +2 -2
- package/llms/components/lr-flag.md +20 -5
- package/llms/components/lr-heatmap.md +28 -0
- package/llms/components/lr-histogram.md +3 -1
- package/llms/components/lr-icon.md +1 -1
- package/llms/components/lr-json-schema-viewer.md +2 -1
- package/llms/components/lr-knowledge-graph-explorer.md +8 -3
- package/llms/components/lr-known-date.md +4 -2
- package/llms/components/lr-line-chart.md +4 -3
- package/llms/components/lr-lite-chart.md +16 -6
- package/llms/components/lr-map.md +72 -8
- package/llms/components/lr-markdown-core.md +3 -2
- package/llms/components/lr-media-card.md +28 -12
- package/llms/components/lr-message-parts.md +2 -1
- package/llms/components/lr-model-select.md +9 -10
- package/llms/components/lr-model-settings-panel.md +9 -9
- package/llms/components/lr-neighbor-list.md +1 -1
- package/llms/components/lr-notebook-viewer.md +6 -3
- package/llms/components/lr-option.md +5 -2
- package/llms/components/lr-pdf-viewer.md +62 -2
- package/llms/components/lr-pie-chart.md +4 -3
- package/llms/components/lr-polar-area-chart.md +4 -3
- package/llms/components/lr-popover.md +5 -0
- package/llms/components/lr-progress-ring.md +8 -1
- package/llms/components/lr-prompt-studio.md +1 -1
- package/llms/components/lr-provenance-panel.md +4 -2
- package/llms/components/lr-qr-code.md +1 -1
- package/llms/components/lr-radar-chart.md +4 -3
- package/llms/components/lr-rag-eval-dashboard.md +2 -2
- package/llms/components/lr-random-content.md +13 -0
- package/llms/components/lr-reorder-item.md +6 -1
- package/llms/components/lr-reorder-list.md +6 -1
- package/llms/components/lr-responsive-panel.md +11 -7
- package/llms/components/lr-scatter-chart.md +4 -3
- package/llms/components/lr-sequence-strip.md +16 -2
- package/llms/components/lr-slider.md +12 -5
- package/llms/components/lr-sparkline.md +1 -1
- package/llms/components/lr-suggestion-chips.md +7 -2
- package/llms/components/lr-swatch-picker.md +5 -5
- package/llms/components/lr-switch.md +5 -2
- package/llms/components/lr-table.md +30 -4
- package/llms/components/lr-terminal.md +3 -1
- package/llms/components/lr-thread-list.md +8 -8
- package/llms/components/lr-time-input.md +6 -1
- package/llms/components/lr-timeline-item.md +24 -0
- package/llms/components/lr-timeline.md +25 -1
- package/llms/components/lr-token-input.md +7 -2
- package/llms/components/lr-tool-approval-dialog.md +7 -8
- package/llms/components/lr-tool-call-chip.md +5 -1
- package/llms/components/lr-tool-param-form.md +14 -12
- package/llms/components/lr-tool-result-dialog.md +11 -9
- package/llms/components/lr-tool-result-view.md +7 -6
- package/llms/components/lr-tool-select-dialog.md +18 -16
- package/llms/components/lr-trace-tree.md +3 -1
- package/llms/components/lr-usage-badge.md +4 -1
- package/llms/components/lr-video-playlist.md +1 -1
- package/llms/components/lr-virtual-list.md +22 -14
- package/llms/components/lr-voice-picker.md +8 -5
- package/llms/components/lr-widget-renderer.md +3 -3
- package/llms/components/lr-widget.md +1 -1
- package/llms/components/lr-word-cloud.md +6 -2
- package/llms/peers.md +12 -2
- package/llms/shared.md +70 -2
- package/llms-full.txt +1143 -285
- package/package.json +17 -5
- package/vscode-css-data.json +37 -2
- package/vscode-html-data.json +401 -44
- package/web-types.json +299 -55
|
@@ -2,43 +2,25 @@ import{css}from"lit";const styles=css`
|
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
min-inline-size: 0;
|
|
5
|
-
/* Establishes the containment context the narrow-panel @container query below depends on --
|
|
6
|
-
without this, that query can only ever fire if a consumer's page happens to independently
|
|
7
|
-
declare container-type on some ancestor whose box crosses the same threshold, making it
|
|
8
|
-
effectively dead code out of the box. */
|
|
9
5
|
container-type: inline-size;
|
|
10
6
|
contain-intrinsic-inline-size: var(--lr-size-20rem);
|
|
11
7
|
}
|
|
12
8
|
[part~='header'] { display: flex; align-items: center; justify-content: space-between; gap: var(--lr-space-s); margin-block-end: var(--lr-space-s); }
|
|
13
9
|
[part='title'] { font-weight: var(--lr-font-weight-semibold); }
|
|
14
|
-
/* justify-content on both axes: the nav buttons carry a single icon-only glyph (nav-glyph),
|
|
15
|
-
far narrower than the min-inline-size hit-area floor below, and the default
|
|
16
|
-
justify-content (normal => flex-start) dumped all that slack on the trailing side, leaving
|
|
17
|
-
the chevron visibly off-centre in its button. Only takes effect when there IS slack, so a
|
|
18
|
-
nav box whose content already fills it renders exactly as before. */
|
|
19
10
|
[part~='nav'] { display: flex; justify-content: center; align-items: center; gap: var(--lr-space-xs); min-inline-size: var(--lr-icon-button-size); min-block-size: var(--lr-icon-button-size); }
|
|
20
|
-
/* Both navigation buttons expose the shared nav part plus a purpose-specific part. */
|
|
21
11
|
button[part~='nav'], [part='day'] { min-inline-size: var(--lr-icon-button-size); min-block-size: var(--lr-icon-button-size); border: var(--lr-border-width-thin) solid var(--lr-color-border); background: var(--lr-color-surface); color: var(--lr-color-text); cursor: pointer; }
|
|
22
12
|
button[part~='nav'] { padding-inline: var(--lr-space-s); border-radius: var(--lr-radius); }
|
|
23
13
|
button[part~='nav']:hover, [part='agenda-event']:hover { background: var(--lr-color-brand-quiet); }
|
|
24
|
-
/* Pressed: the same hovered fill carried further toward --lr-color-mix-partner (which follows the
|
|
25
|
-
text colour), so the step is visible in either theme instead of relying on a fixed lighten. */
|
|
26
14
|
button[part~='nav']:active, [part='agenda-event']:active { background: color-mix(in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active)); }
|
|
27
15
|
button[part~='nav']:focus-visible, [part='agenda-event']:focus-visible {
|
|
28
16
|
outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);
|
|
29
17
|
outline-offset: calc(var(--lr-focus-ring-offset) * -1);
|
|
30
18
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
correct behavior while focused. */
|
|
19
|
+
[part='day'][data-outside='true'] { color: var(--lr-calendar-day-outside-color, var(--lr-color-text-quiet)); background: var(--lr-calendar-day-outside-bg, var(--lr-color-surface)); }
|
|
20
|
+
[part='day'][data-today='true'] { outline: var(--lr-border-width-medium) solid var(--lr-calendar-day-today-outline-color, var(--lr-color-brand)); outline-offset: calc(var(--lr-border-width-medium) * -1); }
|
|
34
21
|
[part='day'][data-selected='true'] {
|
|
35
22
|
background: var(--lr-calendar-day-selected-bg, var(--lr-color-brand-quiet));
|
|
36
23
|
}
|
|
37
|
-
/* MUST stay before the :hover/:active rules below: both this and [part='day']:hover/:active are
|
|
38
|
-
equal specificity (0,2,0), so source order alone decides, and hovering or pressing an
|
|
39
|
-
already-selected day needs to layer its own feedback rather than have the static selected fill
|
|
40
|
-
win outright. Mirrors env-list.styles.ts's [aria-pressed='true']-before-:active fix for the
|
|
41
|
-
same masking shape. */
|
|
42
24
|
[part='day']:hover {
|
|
43
25
|
background: var(--lr-color-brand-quiet);
|
|
44
26
|
}
|
|
@@ -54,16 +36,8 @@ import{css}from"lit";const styles=css`
|
|
|
54
36
|
[part='grid'] { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-block-start: var(--lr-border-width-thin) solid var(--lr-color-border); border-inline-start: var(--lr-border-width-thin) solid var(--lr-color-border); }
|
|
55
37
|
[part='week'] { display: contents; }
|
|
56
38
|
[part='day'] { display: flex; flex-direction: column; align-items: stretch; min-block-size: var(--lr-calendar-day-min-block-size, var(--lr-size-6rem)); padding: var(--lr-space-xs); border-block-start: 0; border-inline-start: 0; text-align: start; }
|
|
57
|
-
[part='day'][data-outside='true'] { color: var(--lr-calendar-day-outside-color, var(--lr-color-text-quiet)); background: var(--lr-calendar-day-outside-bg, var(--lr-color-surface)); }
|
|
58
|
-
[part='day'][data-today='true'] { outline: var(--lr-border-width-medium) solid var(--lr-calendar-day-today-outline-color, var(--lr-color-brand)); outline-offset: calc(var(--lr-border-width-medium) * -1); }
|
|
59
39
|
[part='date'] { font-weight: var(--lr-font-weight-semibold); }
|
|
60
40
|
[part='event'] { overflow: hidden; box-sizing: border-box; inline-size: 100%; min-inline-size: var(--lr-size-1-5rem); min-block-size: var(--lr-size-1-5rem); margin-block-start: var(--lr-space-2xs); padding: var(--lr-space-2xs); border: 0; border-radius: var(--lr-radius); background: var(--lr-color-brand); color: var(--lr-color-on-brand); font: inherit; font-size: var(--lr-font-size-sm); text-align: start; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
|
|
61
|
-
/* An event chip's fill is per-event data (CalendarEvent.color) written as an inline
|
|
62
|
-
background-color by calendar.class.ts, and an inline declaration beats every stylesheet rule --
|
|
63
|
-
so the pointer feedback is painted as a background-IMAGE overlay rather than swapped into
|
|
64
|
-
background-color. The overlay composites over whatever fill the chip actually carries
|
|
65
|
-
(including a pure white or pure black one, which the filter: brightness() this replaces left
|
|
66
|
-
completely unchanged) and paints under the label instead of recolouring it. */
|
|
67
41
|
[part='event']:hover {
|
|
68
42
|
background-image: linear-gradient(
|
|
69
43
|
color-mix(in oklab, transparent, var(--lr-color-mix-partner) var(--lr-color-mix-hover)),
|
|
@@ -76,12 +76,16 @@ export interface LyraConditionBuilderEventMap {
|
|
|
76
76
|
* relationship/path queries over a knowledge graph, a genuinely different data model from this
|
|
77
77
|
* one's flat tabular field/operator/value conditions — they never share a file or a value type.
|
|
78
78
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* This component never mutates `fields`/`value` in place
|
|
84
|
-
*
|
|
79
|
+
* A host supplies `fields` (the available columns, each with a `ConditionBuilderFieldType` that
|
|
80
|
+
* determines its offered operators and value control) and `value` (a plain, serializable
|
|
81
|
+
* `{ combinator, conditions }` object — safe to persist or send to a backend as-is, the same shape
|
|
82
|
+
* convention as this package's `<lr-rubric-form>`/`<lr-filter-bar>`).
|
|
83
|
+
* This component never mutates `fields`/`value` in place — inputs are clone-owned — and never calls
|
|
84
|
+
* out to storage/network itself. It does advance its own copy of `value` on each edit and *then*
|
|
85
|
+
* emits `lr-input` with the complete next state: the same "update, then emit; reassign to control"
|
|
86
|
+
* round-trip `<lr-source-picker>`'s `selectedSourceIds` and `<lr-retrieval-search>`'s `filters`
|
|
87
|
+
* establish. `lr-input` is not cancelable, so a host validating an edit reassigns `value` in its
|
|
88
|
+
* handler rather than vetoing the change before it renders. A non-finite value on a
|
|
85
89
|
* field declared as `number` normalizes to `undefined`, whether it arrives through the controlled
|
|
86
90
|
* model, later field metadata, or an overflowing user-input string, so JSON never turns it into
|
|
87
91
|
* an unrelated `null` condition.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{html,nothing}from"lit";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{nextId}from"../../../internal/a11y.js";import{styles}from"./condition-builder.styles.js";import{activeElementIn}from"../../../internal/active-element.js";import{LYRA_DEFAULT_queryBuilderAddCondition,LYRA_DEFAULT_queryBuilderBooleanFalse,LYRA_DEFAULT_queryBuilderBooleanTrue,LYRA_DEFAULT_queryBuilderCombinatorAnd,LYRA_DEFAULT_queryBuilderCombinatorLabel,LYRA_DEFAULT_queryBuilderCombinatorOr,LYRA_DEFAULT_queryBuilderEmpty,LYRA_DEFAULT_queryBuilderFieldLabel,LYRA_DEFAULT_queryBuilderFieldPlaceholder,LYRA_DEFAULT_queryBuilderLabel,LYRA_DEFAULT_queryBuilderNoFields,LYRA_DEFAULT_queryBuilderOperatorAfter,LYRA_DEFAULT_queryBuilderOperatorBefore,LYRA_DEFAULT_queryBuilderOperatorContains,LYRA_DEFAULT_queryBuilderOperatorEndsWith,LYRA_DEFAULT_queryBuilderOperatorEquals,LYRA_DEFAULT_queryBuilderOperatorGreaterThan,LYRA_DEFAULT_queryBuilderOperatorGreaterThanOrEqual,LYRA_DEFAULT_queryBuilderOperatorIn,LYRA_DEFAULT_queryBuilderOperatorIsEmpty,LYRA_DEFAULT_queryBuilderOperatorIsNotEmpty,LYRA_DEFAULT_queryBuilderOperatorLabel,LYRA_DEFAULT_queryBuilderOperatorLessThan,LYRA_DEFAULT_queryBuilderOperatorLessThanOrEqual,LYRA_DEFAULT_queryBuilderOperatorNotEquals,LYRA_DEFAULT_queryBuilderOperatorNotIn,LYRA_DEFAULT_queryBuilderOperatorOnOrAfter,LYRA_DEFAULT_queryBuilderOperatorOnOrBefore,LYRA_DEFAULT_queryBuilderOperatorPlaceholder,LYRA_DEFAULT_queryBuilderOperatorStartsWith,LYRA_DEFAULT_queryBuilderRemoveCondition,LYRA_DEFAULT_queryBuilderValueLabel,LYRA_DEFAULT_queryBuilderValuePlaceholder}from"../../../internal/default-strings.generated.js";function selectValue(el){return Array.isArray(el.value)?el.value[0]??"":el.value}const MAX_FIELDS=200,MAX_CONDITIONS=200,MAX_OPTIONS=500,MAX_TEXT=256,EMPTY_FIELDS=Object.freeze([]),EMPTY_OPTIONS=Object.freeze([]),EMPTY_VALUE=Object.freeze({combinator:"and",conditions:Object.freeze([])}),STRING_OPERATORS=["eq","neq","contains","startsWith","endsWith","isEmpty","isNotEmpty"],NUMBER_OPERATORS=["eq","neq","gt","gte","lt","lte","isEmpty","isNotEmpty"],BOOLEAN_OPERATORS=["eq","neq"],DATE_OPERATORS=["eq","neq","gt","gte","lt","lte","isEmpty","isNotEmpty"],ENUM_OPERATORS=["eq","neq","in","notIn","isEmpty","isNotEmpty"];function defaultOperatorsForType(type){switch(type){case"string":return STRING_OPERATORS;case"number":return NUMBER_OPERATORS;case"boolean":return BOOLEAN_OPERATORS;case"date":return DATE_OPERATORS;case"enum":return ENUM_OPERATORS}}function isUnaryOperator(op){return op==="isEmpty"||op==="isNotEmpty"}function isMultiOperator(op){return op==="in"||op==="notIn"}const FIELD_TYPES=new Set(["string","number","boolean","date","enum"]),OPERATORS=new Set(["eq","neq","gt","gte","lt","lte","contains","startsWith","endsWith","in","notIn","isEmpty","isNotEmpty"]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function boundedString(value){return typeof value=="string"?value.slice(0,MAX_TEXT):""}function normalizeOptions(value){if(!Array.isArray(value))return EMPTY_OPTIONS;const seen=new Set,result=[];for(const candidate of value.slice(0,MAX_OPTIONS)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const optionValue=boundedString(ownValue(candidate,"value"));if(optionValue.trim().length===0||seen.has(optionValue))continue;seen.add(optionValue);const label=boundedString(ownValue(candidate,"label"));result.push(Object.freeze({value:optionValue,...label?{label}:{}}))}return Object.freeze(result)}function normalizeOperators(value){if(!Array.isArray(value))return;const result=[...new Set(value.slice(0,MAX_OPTIONS).filter(entry=>OPERATORS.has(entry)))];return result.length>0?Object.freeze(result):void 0}function normalizeFields(value){if(!Array.isArray(value))return EMPTY_FIELDS;const names=new Set,result=[];for(const candidate of value.slice(0,MAX_FIELDS)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const name=boundedString(ownValue(candidate,"name")),type=ownValue(candidate,"type");if(name.trim().length===0||names.has(name)||!FIELD_TYPES.has(type))continue;names.add(name);const label=boundedString(ownValue(candidate,"label")),placeholder=boundedString(ownValue(candidate,"placeholder")),options=normalizeOptions(ownValue(candidate,"options")),operators=normalizeOperators(ownValue(candidate,"operators"));result.push(Object.freeze({name,type,...label?{label}:{},...placeholder?{placeholder}:{},...options.length>0?{options}:{},...operators?{operators}:{}}))}return Object.freeze(result)}function normalizeConditionValue(value){if(typeof value=="string"||typeof value=="boolean")return value;if(typeof value=="number")return Number.isFinite(value)?value:void 0;if(Array.isArray(value))return Object.freeze(value.slice(0,MAX_OPTIONS).filter(entry=>typeof entry=="string").map(entry=>boundedString(entry)))}function normalizeConditionBuilderValue(value,fields){const record=value!==null&&typeof value=="object"&&!Array.isArray(value)?value:EMPTY_VALUE,combinator=ownValue(record,"combinator")==="or"?"or":"and",source=ownValue(record,"conditions"),conditions=[],ids=new Set;if(Array.isArray(source))for(const candidate of source.slice(0,MAX_CONDITIONS)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const id=boundedString(ownValue(candidate,"id"));if(id.trim().length===0||ids.has(id))continue;ids.add(id);const field=boundedString(ownValue(candidate,"field")),rawOperator=ownValue(candidate,"operator"),operator=rawOperator===""||OPERATORS.has(rawOperator)?rawOperator:"";let normalizedValue=normalizeConditionValue(ownValue(candidate,"value"));fields.find(entry=>entry.name===field)?.type==="number"&&typeof normalizedValue!="number"&&(normalizedValue=void 0),conditions.push(Object.freeze({id,field,operator,...normalizedValue!==void 0?{value:normalizedValue}:{}}))}return Object.freeze({combinator,conditions:Object.freeze(conditions)})}class LyraConditionBuilder extends LyraElement{constructor(){super(...arguments),this._fields=EMPTY_FIELDS,this._value=EMPTY_VALUE,this._disabled=!1,this.pendingFocusAdd=!1}static{this.defaultStrings={...super.defaultStrings,queryBuilderAddCondition:LYRA_DEFAULT_queryBuilderAddCondition,queryBuilderBooleanFalse:LYRA_DEFAULT_queryBuilderBooleanFalse,queryBuilderBooleanTrue:LYRA_DEFAULT_queryBuilderBooleanTrue,queryBuilderCombinatorAnd:LYRA_DEFAULT_queryBuilderCombinatorAnd,queryBuilderCombinatorLabel:LYRA_DEFAULT_queryBuilderCombinatorLabel,queryBuilderCombinatorOr:LYRA_DEFAULT_queryBuilderCombinatorOr,queryBuilderEmpty:LYRA_DEFAULT_queryBuilderEmpty,queryBuilderFieldLabel:LYRA_DEFAULT_queryBuilderFieldLabel,queryBuilderFieldPlaceholder:LYRA_DEFAULT_queryBuilderFieldPlaceholder,queryBuilderLabel:LYRA_DEFAULT_queryBuilderLabel,queryBuilderNoFields:LYRA_DEFAULT_queryBuilderNoFields,queryBuilderOperatorAfter:LYRA_DEFAULT_queryBuilderOperatorAfter,queryBuilderOperatorBefore:LYRA_DEFAULT_queryBuilderOperatorBefore,queryBuilderOperatorContains:LYRA_DEFAULT_queryBuilderOperatorContains,queryBuilderOperatorEndsWith:LYRA_DEFAULT_queryBuilderOperatorEndsWith,queryBuilderOperatorEquals:LYRA_DEFAULT_queryBuilderOperatorEquals,queryBuilderOperatorGreaterThan:LYRA_DEFAULT_queryBuilderOperatorGreaterThan,queryBuilderOperatorGreaterThanOrEqual:LYRA_DEFAULT_queryBuilderOperatorGreaterThanOrEqual,queryBuilderOperatorIn:LYRA_DEFAULT_queryBuilderOperatorIn,queryBuilderOperatorIsEmpty:LYRA_DEFAULT_queryBuilderOperatorIsEmpty,queryBuilderOperatorIsNotEmpty:LYRA_DEFAULT_queryBuilderOperatorIsNotEmpty,queryBuilderOperatorLabel:LYRA_DEFAULT_queryBuilderOperatorLabel,queryBuilderOperatorLessThan:LYRA_DEFAULT_queryBuilderOperatorLessThan,queryBuilderOperatorLessThanOrEqual:LYRA_DEFAULT_queryBuilderOperatorLessThanOrEqual,queryBuilderOperatorNotEquals:LYRA_DEFAULT_queryBuilderOperatorNotEquals,queryBuilderOperatorNotIn:LYRA_DEFAULT_queryBuilderOperatorNotIn,queryBuilderOperatorOnOrAfter:LYRA_DEFAULT_queryBuilderOperatorOnOrAfter,queryBuilderOperatorOnOrBefore:LYRA_DEFAULT_queryBuilderOperatorOnOrBefore,queryBuilderOperatorPlaceholder:LYRA_DEFAULT_queryBuilderOperatorPlaceholder,queryBuilderOperatorStartsWith:LYRA_DEFAULT_queryBuilderOperatorStartsWith,queryBuilderRemoveCondition:LYRA_DEFAULT_queryBuilderRemoveCondition,queryBuilderValueLabel:LYRA_DEFAULT_queryBuilderValueLabel,queryBuilderValuePlaceholder:LYRA_DEFAULT_queryBuilderValuePlaceholder}}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-add-condition"])}static{this.properties={fields:{attribute:!1,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get fields(){return this._fields}set fields(next){const old=this._fields;this._fields=normalizeFields(next),this.requestUpdate("fields",old);const previousValue=this._value;this._value=normalizeConditionBuilderValue(this._value,this._fields),this._value!==previousValue&&this.requestUpdate("value",previousValue)}get value(){return this._value}set value(next){const old=this._value;this._value=normalizeConditionBuilderValue(next,this._fields),this.requestUpdate("value",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old)}operatorsFor(field){return field?field.operators&&field.operators.length>0?field.operators:defaultOperatorsForType(field.type):[]}operatorLabel(op,type){switch(op){case"eq":return this.localize("queryBuilderOperatorEquals");case"neq":return this.localize("queryBuilderOperatorNotEquals");case"gt":return type==="date"?this.localize("queryBuilderOperatorAfter"):this.localize("queryBuilderOperatorGreaterThan");case"gte":return type==="date"?this.localize("queryBuilderOperatorOnOrAfter"):this.localize("queryBuilderOperatorGreaterThanOrEqual");case"lt":return type==="date"?this.localize("queryBuilderOperatorBefore"):this.localize("queryBuilderOperatorLessThan");case"lte":return type==="date"?this.localize("queryBuilderOperatorOnOrBefore"):this.localize("queryBuilderOperatorLessThanOrEqual");case"contains":return this.localize("queryBuilderOperatorContains");case"startsWith":return this.localize("queryBuilderOperatorStartsWith");case"endsWith":return this.localize("queryBuilderOperatorEndsWith");case"in":return this.localize("queryBuilderOperatorIn");case"notIn":return this.localize("queryBuilderOperatorNotIn");case"isEmpty":return this.localize("queryBuilderOperatorIsEmpty");case"isNotEmpty":return this.localize("queryBuilderOperatorIsNotEmpty")}}defaultValueFor(fieldName,operator){if(operator===""||isUnaryOperator(operator))return;if(isMultiOperator(operator))return[];const field=this._fields.find(f=>f.name===fieldName);if(!(field?.type==="number"||field?.type==="boolean"))return""}commit(next){this.value=next,this.emit("lr-input",Object.freeze({value:this._value}))}addCondition(){const firstField=this._fields[0];if(this.disabled||!firstField||this._value.conditions.length>=MAX_CONDITIONS)return;const condition=Object.freeze({id:nextId("query-condition"),field:firstField.name,operator:""});this.commit({...this._value,conditions:[...this._value.conditions,condition]}),this.emit("lr-add-condition",Object.freeze({condition}))}conditionElement(id){const root=this.shadowRoot;if(!root)return null;const ownerCss=this.ownerDocument.defaultView?.CSS;if(typeof ownerCss?.escape=="function")try{const candidate=root.querySelector(`[part="condition"][data-id="${ownerCss.escape(id)}"]`);if(candidate?.getAttribute("data-id")===id)return candidate}catch{}return Array.from(root.querySelectorAll('[part="condition"][data-id]')).find(candidate=>candidate.getAttribute("data-id")===id)??null}removeCondition(id){if(this.disabled||!this._value.conditions.some(c=>c.id===id))return;const row=this.conditionElement(id),active=activeElementIn(this.shadowRoot);row&&active&&row.contains(active)&&(this.pendingFocusAdd=!0);const conditions=this._value.conditions.filter(c=>c.id!==id);this.commit({...this._value,conditions}),this.emit("lr-remove-condition",Object.freeze({conditionId:id}))}setCombinator(combinator){this.disabled||combinator===this._value.combinator||this.commit({...this._value,combinator})}setConditionField(id,field){if(this.disabled)return;const conditions=this._value.conditions.map(c=>c.id===id?{id:c.id,field,operator:"",value:void 0}:c);this.commit({...this._value,conditions})}setConditionOperator(id,operator){if(this.disabled)return;const conditions=this._value.conditions.map(c=>c.id===id?{...c,operator,value:this.defaultValueFor(c.field,operator)}:c);this.commit({...this._value,conditions})}setConditionValue(id,value){if(this.disabled)return;const conditions=this._value.conditions.map(c=>c.id===id?{...c,value}:c);this.commit({...this._value,conditions})}consumeChildEvent(event,action){event.stopPropagation(),action()}updated(changed){super.updated(changed),this.pendingFocusAdd&&(this.pendingFocusAdd=!1,this.renderRoot.querySelector('[part="add-button"]')?.focus())}renderCombinator(combinator){return html`
|
|
1
|
+
import{html,nothing}from"lit";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{styles}from"./condition-builder.styles.js";import{activeElementIn}from"../../../internal/active-element.js";import{LYRA_DEFAULT_queryBuilderAddCondition,LYRA_DEFAULT_queryBuilderBooleanFalse,LYRA_DEFAULT_queryBuilderBooleanTrue,LYRA_DEFAULT_queryBuilderCombinatorAnd,LYRA_DEFAULT_queryBuilderCombinatorLabel,LYRA_DEFAULT_queryBuilderCombinatorOr,LYRA_DEFAULT_queryBuilderEmpty,LYRA_DEFAULT_queryBuilderFieldLabel,LYRA_DEFAULT_queryBuilderFieldPlaceholder,LYRA_DEFAULT_queryBuilderLabel,LYRA_DEFAULT_queryBuilderNoFields,LYRA_DEFAULT_queryBuilderOperatorAfter,LYRA_DEFAULT_queryBuilderOperatorBefore,LYRA_DEFAULT_queryBuilderOperatorContains,LYRA_DEFAULT_queryBuilderOperatorEndsWith,LYRA_DEFAULT_queryBuilderOperatorEquals,LYRA_DEFAULT_queryBuilderOperatorGreaterThan,LYRA_DEFAULT_queryBuilderOperatorGreaterThanOrEqual,LYRA_DEFAULT_queryBuilderOperatorIn,LYRA_DEFAULT_queryBuilderOperatorIsEmpty,LYRA_DEFAULT_queryBuilderOperatorIsNotEmpty,LYRA_DEFAULT_queryBuilderOperatorLabel,LYRA_DEFAULT_queryBuilderOperatorLessThan,LYRA_DEFAULT_queryBuilderOperatorLessThanOrEqual,LYRA_DEFAULT_queryBuilderOperatorNotEquals,LYRA_DEFAULT_queryBuilderOperatorNotIn,LYRA_DEFAULT_queryBuilderOperatorOnOrAfter,LYRA_DEFAULT_queryBuilderOperatorOnOrBefore,LYRA_DEFAULT_queryBuilderOperatorPlaceholder,LYRA_DEFAULT_queryBuilderOperatorStartsWith,LYRA_DEFAULT_queryBuilderRemoveCondition,LYRA_DEFAULT_queryBuilderValueLabel,LYRA_DEFAULT_queryBuilderValuePlaceholder}from"../../../internal/default-strings.generated.js";function selectValue(el){return Array.isArray(el.value)?el.value[0]??"":el.value}const MAX_FIELDS=200,MAX_CONDITIONS=200,MAX_OPTIONS=500,MAX_TEXT=256,EMPTY_FIELDS=Object.freeze([]),EMPTY_OPTIONS=Object.freeze([]),EMPTY_VALUE=Object.freeze({combinator:"and",conditions:Object.freeze([])}),STRING_OPERATORS=["eq","neq","contains","startsWith","endsWith","isEmpty","isNotEmpty"],NUMBER_OPERATORS=["eq","neq","gt","gte","lt","lte","isEmpty","isNotEmpty"],BOOLEAN_OPERATORS=["eq","neq"],DATE_OPERATORS=["eq","neq","gt","gte","lt","lte","isEmpty","isNotEmpty"],ENUM_OPERATORS=["eq","neq","in","notIn","isEmpty","isNotEmpty"];function defaultOperatorsForType(type){switch(type){case"string":return STRING_OPERATORS;case"number":return NUMBER_OPERATORS;case"boolean":return BOOLEAN_OPERATORS;case"date":return DATE_OPERATORS;case"enum":return ENUM_OPERATORS}}function isUnaryOperator(op){return op==="isEmpty"||op==="isNotEmpty"}function isMultiOperator(op){return op==="in"||op==="notIn"}const FIELD_TYPES=new Set(["string","number","boolean","date","enum"]),OPERATORS=new Set(["eq","neq","gt","gte","lt","lte","contains","startsWith","endsWith","in","notIn","isEmpty","isNotEmpty"]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function boundedString(value){return typeof value=="string"?value.slice(0,MAX_TEXT):""}function normalizeOptions(value){if(!Array.isArray(value))return EMPTY_OPTIONS;const seen=new Set,result=[];for(const candidate of value.slice(0,MAX_OPTIONS)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const optionValue=boundedString(ownValue(candidate,"value"));if(optionValue.trim().length===0||seen.has(optionValue))continue;seen.add(optionValue);const label=boundedString(ownValue(candidate,"label"));result.push(Object.freeze({value:optionValue,...label?{label}:{}}))}return Object.freeze(result)}function normalizeOperators(value){if(!Array.isArray(value))return;const result=[...new Set(value.slice(0,MAX_OPTIONS).filter(entry=>OPERATORS.has(entry)))];return result.length>0?Object.freeze(result):void 0}function normalizeFields(value){if(!Array.isArray(value))return EMPTY_FIELDS;const names=new Set,result=[];for(const candidate of value.slice(0,MAX_FIELDS)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const name=boundedString(ownValue(candidate,"name")),type=ownValue(candidate,"type");if(name.trim().length===0||names.has(name)||!FIELD_TYPES.has(type))continue;names.add(name);const label=boundedString(ownValue(candidate,"label")),placeholder=boundedString(ownValue(candidate,"placeholder")),options=normalizeOptions(ownValue(candidate,"options")),operators=normalizeOperators(ownValue(candidate,"operators"));result.push(Object.freeze({name,type,...label?{label}:{},...placeholder?{placeholder}:{},...options.length>0?{options}:{},...operators?{operators}:{}}))}return Object.freeze(result)}function normalizeConditionValue(value){if(typeof value=="string"||typeof value=="boolean")return value;if(typeof value=="number")return Number.isFinite(value)?value:void 0;if(Array.isArray(value))return Object.freeze(value.slice(0,MAX_OPTIONS).filter(entry=>typeof entry=="string").map(entry=>boundedString(entry)))}function normalizeConditionBuilderValue(value,fields){const record=value!==null&&typeof value=="object"&&!Array.isArray(value)?value:EMPTY_VALUE,combinator=ownValue(record,"combinator")==="or"?"or":"and",source=ownValue(record,"conditions"),conditions=[],ids=new Set;if(Array.isArray(source))for(const candidate of source.slice(0,MAX_CONDITIONS)){if(candidate===null||typeof candidate!="object"||Array.isArray(candidate))continue;const id=boundedString(ownValue(candidate,"id"));if(id.trim().length===0||ids.has(id))continue;ids.add(id);const field=boundedString(ownValue(candidate,"field")),rawOperator=ownValue(candidate,"operator"),operator=rawOperator===""||OPERATORS.has(rawOperator)?rawOperator:"";let normalizedValue=normalizeConditionValue(ownValue(candidate,"value"));fields.find(entry=>entry.name===field)?.type==="number"&&typeof normalizedValue!="number"&&(normalizedValue=void 0),conditions.push(Object.freeze({id,field,operator,...normalizedValue!==void 0?{value:normalizedValue}:{}}))}return Object.freeze({combinator,conditions:Object.freeze(conditions)})}class LyraConditionBuilder extends LyraElement{constructor(){super(...arguments),this._fields=EMPTY_FIELDS,this._value=EMPTY_VALUE,this._disabled=!1,this.pendingFocusAdd=!1}static{this.defaultStrings={...super.defaultStrings,queryBuilderAddCondition:LYRA_DEFAULT_queryBuilderAddCondition,queryBuilderBooleanFalse:LYRA_DEFAULT_queryBuilderBooleanFalse,queryBuilderBooleanTrue:LYRA_DEFAULT_queryBuilderBooleanTrue,queryBuilderCombinatorAnd:LYRA_DEFAULT_queryBuilderCombinatorAnd,queryBuilderCombinatorLabel:LYRA_DEFAULT_queryBuilderCombinatorLabel,queryBuilderCombinatorOr:LYRA_DEFAULT_queryBuilderCombinatorOr,queryBuilderEmpty:LYRA_DEFAULT_queryBuilderEmpty,queryBuilderFieldLabel:LYRA_DEFAULT_queryBuilderFieldLabel,queryBuilderFieldPlaceholder:LYRA_DEFAULT_queryBuilderFieldPlaceholder,queryBuilderLabel:LYRA_DEFAULT_queryBuilderLabel,queryBuilderNoFields:LYRA_DEFAULT_queryBuilderNoFields,queryBuilderOperatorAfter:LYRA_DEFAULT_queryBuilderOperatorAfter,queryBuilderOperatorBefore:LYRA_DEFAULT_queryBuilderOperatorBefore,queryBuilderOperatorContains:LYRA_DEFAULT_queryBuilderOperatorContains,queryBuilderOperatorEndsWith:LYRA_DEFAULT_queryBuilderOperatorEndsWith,queryBuilderOperatorEquals:LYRA_DEFAULT_queryBuilderOperatorEquals,queryBuilderOperatorGreaterThan:LYRA_DEFAULT_queryBuilderOperatorGreaterThan,queryBuilderOperatorGreaterThanOrEqual:LYRA_DEFAULT_queryBuilderOperatorGreaterThanOrEqual,queryBuilderOperatorIn:LYRA_DEFAULT_queryBuilderOperatorIn,queryBuilderOperatorIsEmpty:LYRA_DEFAULT_queryBuilderOperatorIsEmpty,queryBuilderOperatorIsNotEmpty:LYRA_DEFAULT_queryBuilderOperatorIsNotEmpty,queryBuilderOperatorLabel:LYRA_DEFAULT_queryBuilderOperatorLabel,queryBuilderOperatorLessThan:LYRA_DEFAULT_queryBuilderOperatorLessThan,queryBuilderOperatorLessThanOrEqual:LYRA_DEFAULT_queryBuilderOperatorLessThanOrEqual,queryBuilderOperatorNotEquals:LYRA_DEFAULT_queryBuilderOperatorNotEquals,queryBuilderOperatorNotIn:LYRA_DEFAULT_queryBuilderOperatorNotIn,queryBuilderOperatorOnOrAfter:LYRA_DEFAULT_queryBuilderOperatorOnOrAfter,queryBuilderOperatorOnOrBefore:LYRA_DEFAULT_queryBuilderOperatorOnOrBefore,queryBuilderOperatorPlaceholder:LYRA_DEFAULT_queryBuilderOperatorPlaceholder,queryBuilderOperatorStartsWith:LYRA_DEFAULT_queryBuilderOperatorStartsWith,queryBuilderRemoveCondition:LYRA_DEFAULT_queryBuilderRemoveCondition,queryBuilderValueLabel:LYRA_DEFAULT_queryBuilderValueLabel,queryBuilderValuePlaceholder:LYRA_DEFAULT_queryBuilderValuePlaceholder}}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-add-condition"])}static{this.properties={fields:{attribute:!1,noAccessor:!0},value:{attribute:!1,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get fields(){return this._fields}set fields(next){const old=this._fields;this._fields=normalizeFields(next),this.requestUpdate("fields",old);const previousValue=this._value;this._value=normalizeConditionBuilderValue(this._value,this._fields),this._value!==previousValue&&this.requestUpdate("value",previousValue)}get value(){return this._value}set value(next){const old=this._value;this._value=normalizeConditionBuilderValue(next,this._fields),this.requestUpdate("value",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old)}operatorsFor(field){return field?field.operators&&field.operators.length>0?field.operators:defaultOperatorsForType(field.type):[]}operatorLabel(op,type){switch(op){case"eq":return this.localize("queryBuilderOperatorEquals");case"neq":return this.localize("queryBuilderOperatorNotEquals");case"gt":return type==="date"?this.localize("queryBuilderOperatorAfter"):this.localize("queryBuilderOperatorGreaterThan");case"gte":return type==="date"?this.localize("queryBuilderOperatorOnOrAfter"):this.localize("queryBuilderOperatorGreaterThanOrEqual");case"lt":return type==="date"?this.localize("queryBuilderOperatorBefore"):this.localize("queryBuilderOperatorLessThan");case"lte":return type==="date"?this.localize("queryBuilderOperatorOnOrBefore"):this.localize("queryBuilderOperatorLessThanOrEqual");case"contains":return this.localize("queryBuilderOperatorContains");case"startsWith":return this.localize("queryBuilderOperatorStartsWith");case"endsWith":return this.localize("queryBuilderOperatorEndsWith");case"in":return this.localize("queryBuilderOperatorIn");case"notIn":return this.localize("queryBuilderOperatorNotIn");case"isEmpty":return this.localize("queryBuilderOperatorIsEmpty");case"isNotEmpty":return this.localize("queryBuilderOperatorIsNotEmpty")}}defaultValueFor(fieldName,operator){if(operator===""||isUnaryOperator(operator))return;if(isMultiOperator(operator))return[];const field=this._fields.find(f=>f.name===fieldName);if(!(field?.type==="number"||field?.type==="boolean"))return""}commit(next){this.value=next,this.emit("lr-input",Object.freeze({value:this._value}))}addCondition(){const firstField=this._fields[0];if(this.disabled||!firstField||this._value.conditions.length>=MAX_CONDITIONS)return;const condition=Object.freeze({id:nextId("query-condition"),field:firstField.name,operator:""});this.commit({...this._value,conditions:[...this._value.conditions,condition]}),this.emit("lr-add-condition",Object.freeze({condition}))}conditionElement(id){const root=this.shadowRoot;if(!root)return null;const ownerCss=this.ownerDocument.defaultView?.CSS;if(typeof ownerCss?.escape=="function")try{const candidate=root.querySelector(`[part="condition"][data-id="${ownerCss.escape(id)}"]`);if(candidate?.getAttribute("data-id")===id)return candidate}catch{}return Array.from(root.querySelectorAll('[part="condition"][data-id]')).find(candidate=>candidate.getAttribute("data-id")===id)??null}removeCondition(id){if(this.disabled||!this._value.conditions.some(c=>c.id===id))return;const row=this.conditionElement(id),active=activeElementIn(this.shadowRoot);row&&active&&row.contains(active)&&(this.pendingFocusAdd=!0);const conditions=this._value.conditions.filter(c=>c.id!==id);this.commit({...this._value,conditions}),this.emit("lr-remove-condition",Object.freeze({conditionId:id}))}setCombinator(combinator){this.disabled||combinator===this._value.combinator||this.commit({...this._value,combinator})}setConditionField(id,field){if(this.disabled)return;const conditions=this._value.conditions.map(c=>c.id===id?{id:c.id,field,operator:"",value:void 0}:c);this.commit({...this._value,conditions})}setConditionOperator(id,operator){if(this.disabled)return;const conditions=this._value.conditions.map(c=>c.id===id?{...c,operator,value:this.defaultValueFor(c.field,operator)}:c);this.commit({...this._value,conditions})}setConditionValue(id,value){if(this.disabled)return;const conditions=this._value.conditions.map(c=>c.id===id?{...c,value}:c);this.commit({...this._value,conditions})}consumeChildEvent(event,action){event.stopPropagation(),action()}updated(changed){super.updated(changed),this.pendingFocusAdd&&(this.pendingFocusAdd=!1,this.renderRoot.querySelector('[part="add-button"]')?.focus())}renderCombinator(combinator){return html`
|
|
2
2
|
<lr-select
|
|
3
3
|
part="combinator"
|
|
4
4
|
size="s"
|
|
@@ -114,7 +114,7 @@ import{html,nothing}from"lit";import{LyraElement}from"../../../internal/lyra-ele
|
|
|
114
114
|
></lr-icon-button>
|
|
115
115
|
</div>
|
|
116
116
|
`}render(){const hasFields=this._fields.length>0,value=this._value;return html`
|
|
117
|
-
<div part="base" role="group" aria-label=${this
|
|
117
|
+
<div part="base" role="group" aria-label=${hostAriaLabel(this)??this.localize("queryBuilderLabel")}>
|
|
118
118
|
${hasFields?html`
|
|
119
119
|
${value.conditions.length>1?this.renderCombinator(value.combinator):nothing}
|
|
120
120
|
${value.conditions.length===0?html`<p part="empty">${this.localize("queryBuilderEmpty")}</p>`:html`<div part="conditions" role="list">${value.conditions.map((c,i)=>this.renderCondition(c,i))}</div>`}
|
|
@@ -2,9 +2,6 @@ import{css}from"lit";const styles=css`
|
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
min-inline-size: 0;
|
|
5
|
-
/* Makes the host a query container so the narrow-allocation rule below reacts to the
|
|
6
|
-
component's own allocated width (a sidebar, a split pane, a dialog) rather than the
|
|
7
|
-
viewport. */
|
|
8
5
|
container-type: inline-size;
|
|
9
6
|
contain-intrinsic-inline-size: var(--lr-size-20rem);
|
|
10
7
|
}
|
|
@@ -61,9 +58,6 @@ import{css}from"lit";const styles=css`
|
|
|
61
58
|
color: var(--lr-color-text-quiet);
|
|
62
59
|
}
|
|
63
60
|
|
|
64
|
-
/* Container-query lengths cannot reference custom properties. This is the documented 320px
|
|
65
|
-
narrow-allocation baseline expressed in root-relative units so it still follows the page's
|
|
66
|
-
type scale. */
|
|
67
61
|
@container (max-inline-size: 20rem) {
|
|
68
62
|
[part='condition'] {
|
|
69
63
|
flex-direction: column;
|
|
@@ -28,7 +28,6 @@ import{css}from"lit";const styles=css`
|
|
|
28
28
|
font-family: var(--lr-font);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/* --- bar variant ------------------------------------------------- */
|
|
32
31
|
[part='track'] {
|
|
33
32
|
position: relative;
|
|
34
33
|
display: flex;
|
|
@@ -36,10 +35,6 @@ import{css}from"lit";const styles=css`
|
|
|
36
35
|
overflow: hidden;
|
|
37
36
|
block-size: var(--lr-size-0-5rem);
|
|
38
37
|
border-radius: calc(var(--lr-radius) * 0.5);
|
|
39
|
-
/* Quiet neutral fill for the unfilled remainder -- deliberately lighter
|
|
40
|
-
than a 'neutral'-tone segment (var(--lr-color-border) at full
|
|
41
|
-
strength below) so "counted but uncolored" data still reads as
|
|
42
|
-
visually distinct from "not counted at all". */
|
|
43
38
|
background: color-mix(in srgb, var(--lr-color-border) 30%, transparent);
|
|
44
39
|
}
|
|
45
40
|
[part='segment'] {
|
|
@@ -49,11 +44,6 @@ import{css}from"lit";const styles=css`
|
|
|
49
44
|
background: var(--lr-color-border);
|
|
50
45
|
transition: flex-basis var(--lr-transition-base);
|
|
51
46
|
}
|
|
52
|
-
/* A hairline seam between adjacent segments -- painted in the surface
|
|
53
|
-
color rather than as real gap spacing, so two same-tone segments next
|
|
54
|
-
to each other (e.g. two 'neutral' entries) still read as separate
|
|
55
|
-
quantities instead of merging into one block. Logical property keeps it
|
|
56
|
-
RTL-correct without extra math. */
|
|
57
47
|
[part='segment']:not(:first-of-type) {
|
|
58
48
|
border-inline-start: var(--lr-border-width-thin) solid var(--lr-color-surface);
|
|
59
49
|
}
|
|
@@ -73,11 +63,6 @@ import{css}from"lit";const styles=css`
|
|
|
73
63
|
background: var(--lr-context-meter-segment-color);
|
|
74
64
|
}
|
|
75
65
|
|
|
76
|
-
/* --- legend --------------------------------------------------------- */
|
|
77
|
-
/* The key grows a row per consumer-supplied segment and each label grows with translation, so it
|
|
78
|
-
wraps rather than overflowing, and every item keeps min-inline-size: 0 so a long label shrinks
|
|
79
|
-
inside its own row instead of forcing the meter's allocation wider. Same shape and the same
|
|
80
|
-
part names as lr-sequence-strip's legend. */
|
|
81
66
|
[part='legend'] {
|
|
82
67
|
display: flex;
|
|
83
68
|
flex-wrap: wrap;
|
|
@@ -98,9 +83,6 @@ import{css}from"lit";const styles=css`
|
|
|
98
83
|
inline-size: var(--lr-context-meter-legend-swatch-size, var(--lr-size-0-625rem));
|
|
99
84
|
block-size: var(--lr-context-meter-legend-swatch-size, var(--lr-size-0-625rem));
|
|
100
85
|
border-radius: var(--lr-radius-xs);
|
|
101
|
-
/* The chip reproduces the option's data colour, exactly as [part='segment'] does -- same tone
|
|
102
|
-
ladder, same inline custom-property escape, so a swatch can never disagree with the band it
|
|
103
|
-
stands for. */
|
|
104
86
|
background: var(--lr-color-border);
|
|
105
87
|
}
|
|
106
88
|
[part='legend-swatch'][data-tone='brand'] {
|
|
@@ -122,9 +104,6 @@ import{css}from"lit";const styles=css`
|
|
|
122
104
|
min-inline-size: 0;
|
|
123
105
|
overflow-wrap: anywhere;
|
|
124
106
|
}
|
|
125
|
-
/* The ring is a fixed 8em square, so a legend under it would be clipped by the host's own block
|
|
126
|
-
size. Only under show-legend does the host stop being that square: the ring keeps its declared
|
|
127
|
-
size and the key flows beneath it. */
|
|
128
107
|
:host([shape='ring'][show-legend]) {
|
|
129
108
|
block-size: auto;
|
|
130
109
|
}
|
|
@@ -133,7 +112,6 @@ import{css}from"lit";const styles=css`
|
|
|
133
112
|
block-size: var(--lr-size-8em);
|
|
134
113
|
}
|
|
135
114
|
|
|
136
|
-
/* --- ring variant -------------------------------------------------- */
|
|
137
115
|
:host([shape='ring']) svg[part='base'] {
|
|
138
116
|
display: block;
|
|
139
117
|
overflow: visible;
|
|
@@ -145,8 +123,6 @@ import{css}from"lit";const styles=css`
|
|
|
145
123
|
:host([shape='ring']) [part='segment'] {
|
|
146
124
|
fill: none;
|
|
147
125
|
stroke: var(--lr-color-border);
|
|
148
|
-
/* Butt (not round) caps -- round caps on tightly-packed segmented arcs
|
|
149
|
-
bleed past the exact boundary and overlap the next segment's color. */
|
|
150
126
|
stroke-linecap: butt;
|
|
151
127
|
transition:
|
|
152
128
|
stroke-dasharray var(--lr-transition-base),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{resolveCssLength}from"../../../internal/css-length.js";import{getNumberFormat,resolveIntlLocale}from"../../../internal/intl-cache.js";import{chevronIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{finiteCount,finiteDuration,finiteInteger,finiteRange}from"../../../internal/numbers.js";import{sizes}from"../../../internal/sizes.styles.js";import{srOnly}from"../../../internal/a11y.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{aggregateValues,columnId,columnValue,filterRows,pathValue,rowsAsDelimited,searchRows,sortRows}from"./data-grid-processing.js";import{styles}from"./data-grid.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copied,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_dataGridColumnMenu,LYRA_DEFAULT_dataGridPinEnd,LYRA_DEFAULT_dataGridPinStart,LYRA_DEFAULT_dataGridRowsPerPage,LYRA_DEFAULT_dataGridTreeLimitReached,LYRA_DEFAULT_dataGridUnpin,LYRA_DEFAULT_expand,LYRA_DEFAULT_loading,LYRA_DEFAULT_next,LYRA_DEFAULT_noColumns,LYRA_DEFAULT_noData,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_paginationFirstPage,LYRA_DEFAULT_paginationJumpToPage,LYRA_DEFAULT_paginationLabel,LYRA_DEFAULT_paginationLastPage,LYRA_DEFAULT_previous,LYRA_DEFAULT_resizeColumn,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_showAllColumns,LYRA_DEFAULT_tableFilterLabel}from"../../../internal/default-strings.generated.js";export*from"./data-grid-types.js";const selectableConverter={fromAttribute(value){return value===null?"none":value===""||value==="multiple"?"multiple":value==="single"||value==="none"?value:"none"},toAttribute(value){return value==="none"?null:value===""||value==="multiple"?"":value}};function snapshotColumns(value,occurrenceId){if(!Array.isArray(value))return Object.freeze([]);const output=[],seen=new Set;for(const column of value)try{if(column===null||typeof column!="object"||Array.isArray(column))continue;const hasId=Object.prototype.hasOwnProperty.call(column,"id"),hasField=Object.prototype.hasOwnProperty.call(column,"field"),authoredId=hasId?column.id:void 0,authoredField=hasField?column.field:void 0;if(hasId&&authoredId!==void 0&&(typeof authoredId!="string"||authoredId.trim()==="")||!hasId&&hasField&&authoredField!==void 0&&(typeof authoredField!="string"||authoredField.trim()===""))continue;const identity=typeof authoredId=="string"?authoredId:typeof authoredField=="string"?authoredField:occurrenceId(column);if(seen.has(identity))continue;seen.add(identity);const snapshot={...column,...authoredId===void 0&&authoredField===void 0?{id:identity}:{}};output.push(Object.freeze(snapshot))}catch{}return Object.freeze(output)}const INTERACTIVE_SELECTOR='button, a[href], input, select, textarea, summary, [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"]), [role="button"], [role="checkbox"], [role="radio"]',VIRTUALIZATION_THRESHOLD=80,VIRTUAL_OVERSCAN=5,DATA_GRID_TREE_NODE_LIMIT=1e4,DATA_GRID_TREE_DEPTH_LIMIT=64,DATA_GRID_DRAG_TYPE="application/x-lyra-data-grid-column";function frozenArray(values){return Object.freeze([...values])}function serializableFilterValue(value){try{const serialized=JSON.stringify({value},(_key,nested)=>typeof nested=="bigint"?nested.toString():typeof nested=="number"&&!Number.isFinite(nested)?null:nested!==null&&typeof nested=="object"&&Object.prototype.toString.call(nested)==="[object Set]"?[...nested]:nested);if(!serialized)return null;const snapshot=JSON.parse(serialized).value??null,stack=[snapshot],visited=new Set;for(;stack.length>0;){const current=stack.pop();if(!(current===null||typeof current!="object"||visited.has(current))){visited.add(current);for(const nested of Object.values(current))stack.push(nested);Object.freeze(current)}}return snapshot}catch{return null}}function isKey(value){return typeof value=="string"&&value.trim()!==""||typeof value=="number"&&Number.isFinite(value)}function snapshotKeys(value){if(!Array.isArray(value))return Object.freeze([]);const output=[],seen=new Set;for(const key of value)!isKey(key)||seen.has(key)||(seen.add(key),output.push(key));return frozenArray(output)}function keysEqual(left,right){return typeof left==typeof right&&left===right}function arrayHasKey(keys,key){return keys.some(candidate=>keysEqual(candidate,key))}function isElementValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return candidate.nodeType===1&&typeof candidate.closest=="function"}function valueControl(value){return!isElementValue(value)||typeof value.value!="string"?null:value}function checkableControl(value){return!isElementValue(value)||typeof value.checked!="boolean"?null:value}function dateText(value){try{const timestamp=Date.prototype.getTime.call(value);return Number.isFinite(timestamp)?Date.prototype.toISOString.call(value):""}catch{return}}function humanizeIdentifier(value,locale){const intlLocale=resolveIntlLocale(locale);return value.replaceAll(/[._-]+/gu," ").replaceAll(/([a-z\d])([A-Z])/gu,"$1 $2").replace(/^./u,first=>first.toLocaleUpperCase(intlLocale))}function safeText(value){if(value==null)return"";if(typeof value=="object"){const serializedDate=dateText(value);if(serializedDate!==void 0)return serializedDate}if(Array.isArray(value))return value.map(safeText).join(", ");if(typeof value=="object")try{return JSON.stringify(value,(_key,nested)=>typeof nested=="bigint"?nested.toString():nested)??""}catch{return""}return String(value)}function normalizePinSide(side){return side==="start"?"left":side==="end"?"right":side}function normalizedGroupBy(value){return typeof value!="string"?(value??[]).map(entry=>entry.trim()).filter(Boolean).slice(0,DATA_GRID_TREE_DEPTH_LIMIT):value.split(/[\s,]+/u).map(entry=>entry.trim()).filter(Boolean).slice(0,DATA_GRID_TREE_DEPTH_LIMIT)}class LyraDataGrid extends LyraElement{constructor(){super(...arguments),this.appearance="outlined",this.childRows=null,this._columnOrder=Object.freeze([]),this.columnOccurrenceIds=new WeakMap,this.nextColumnOccurrenceId=1,this.rowOccurrenceIds=new WeakMap,this.nextRowOccurrenceId=1,this._columns=Object.freeze([]),this._data=Object.freeze([]),this.dataSource=null,this._expandedRowKeys=Object.freeze([]),this.filterDebounce=250,this.filterFromLeafRows=!1,this._filters=Object.freeze([]),this._groupBy=null,this.label=null,this.loading=!1,this.maxMultiSort=0,this.page=0,this.pageSize=20,this._pageSizeOptions=Object.freeze([10,20,50,100]),this.paginate=!1,this.pinnable=!1,this.reorderable=!1,this.resizable=!1,this.rowClass=null,this.rowDetail=null,this.rowKey=null,this.searchFn=null,this.searchTerm="",this.selectable="none",this.selectableRows=null,this._selectedRowKeys=Object.freeze([]),this.server=!1,this.size="m",this._sort=Object.freeze([]),this.sortDescFirst=!1,this.striped=!1,this.total=-1,this.withColumnMenu=!1,this.withColumnsMenu=!1,this.withoutSortRemoval=!1,this.withSearch=!1,this.columnWidths=new Map,this.columnVisibility=new Map,this.columnPinning=new Map,this.activeFilterColumn=null,this.columnsMenuOpen=!1,this.activeColumnMenu=null,this.liveText="",this.bodyScrollTop=0,this.viewportHeight=0,this.focusedRow=-1,this.focusedColumn=0,this.dragGhost="",this.requestGeneration=0,this.ownsLoadingState=!1,this.columnDragSequence=0,this.lastSelectedIndex=-1,this.isMounting=!0,this.relayEditorFocus=event=>{relayNativeEvent(this,event)},this.relayEditorBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,copied:LYRA_DEFAULT_copied,copyFailed:LYRA_DEFAULT_copyFailed,dataGridColumnMenu:LYRA_DEFAULT_dataGridColumnMenu,dataGridPinEnd:LYRA_DEFAULT_dataGridPinEnd,dataGridPinStart:LYRA_DEFAULT_dataGridPinStart,dataGridRowsPerPage:LYRA_DEFAULT_dataGridRowsPerPage,dataGridTreeLimitReached:LYRA_DEFAULT_dataGridTreeLimitReached,dataGridUnpin:LYRA_DEFAULT_dataGridUnpin,expand:LYRA_DEFAULT_expand,loading:LYRA_DEFAULT_loading,next:LYRA_DEFAULT_next,noColumns:LYRA_DEFAULT_noColumns,noData:LYRA_DEFAULT_noData,noMatches:LYRA_DEFAULT_noMatches,paginationFirstPage:LYRA_DEFAULT_paginationFirstPage,paginationJumpToPage:LYRA_DEFAULT_paginationJumpToPage,paginationLabel:LYRA_DEFAULT_paginationLabel,paginationLastPage:LYRA_DEFAULT_paginationLastPage,previous:LYRA_DEFAULT_previous,resizeColumn:LYRA_DEFAULT_resizeColumn,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,showAllColumns:LYRA_DEFAULT_showAllColumns,tableFilterLabel:LYRA_DEFAULT_tableFilterLabel}}static{this.immutableEventDetails=Object.freeze(["request","lr-column-move","lr-data-error"])}static{this.identityEventDetailProperties=Object.freeze({request:Object.freeze(["signal"]),"lr-data-error":Object.freeze(["error","request"])})}static{this.styles=[LyraElement.styles,sizes,srOnly,styles]}get columnOrder(){return this._columnOrder}set columnOrder(value){const previous=this._columnOrder,seen=new Set;this._columnOrder=frozenArray(Array.isArray(value)?value.filter(id=>typeof id!="string"||id.trim()===""||seen.has(id)?!1:(seen.add(id),!0)):[]),this.requestUpdate("columnOrder",previous)}get columns(){return this._columns}set columns(value){const previous=this._columns;this._columns=snapshotColumns(value,column=>{const current=this.columnOccurrenceIds.get(column);if(current)return current;const identity=`column-occurrence-${this.nextColumnOccurrenceId}`;return this.nextColumnOccurrenceId+=1,this.columnOccurrenceIds.set(column,identity),identity}),this.requestUpdate("columns",previous)}get data(){return this._data}set data(value){const previous=this._data;this._data=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("data",previous)}get expandedRowKeys(){return this._expandedRowKeys}set expandedRowKeys(value){const previous=this._expandedRowKeys;this._expandedRowKeys=snapshotKeys(value),this.requestUpdate("expandedRowKeys",previous),this.requestUpdate("expandedKeys",previous)}get expandedKeys(){return this.expandedRowKeys}set expandedKeys(value){this.expandedRowKeys=value}get filteredCount(){return this.processedClientRows.length}get filters(){return this._filters}set filters(value){const previous=this._filters,next=[];if(Array.isArray(value))for(const filter of value)try{if(!filter||typeof filter.id!="string")continue;const filterValue=filter.value instanceof Set||Array.isArray(filter.value)?frozenArray(filter.value):filter.value;next.push(Object.freeze({id:filter.id,value:filterValue}))}catch{}this._filters=Object.freeze(next),this.requestUpdate("filters",previous)}get groupBy(){return this._groupBy}set groupBy(value){const previous=this._groupBy;this._groupBy=typeof value=="string"?value:Array.isArray(value)?frozenArray(value.filter(item=>typeof item=="string")):null,this.requestUpdate("groupBy",previous)}get pageCount(){const size=this.safePageSize;if(size===0)return 0;if(!this.usesServerData&&normalizedGroupBy(this.groupBy).length>0){const groups=this.topLevelGroupBuckets(this.processedClientRows).length;return groups<=0?0:Math.ceil(groups/size)}const count=this.safeTotal>=0?this.safeTotal:this.filteredCount;return count<=0?0:Math.ceil(count/size)}get pageSizeOptions(){return this._pageSizeOptions}set pageSizeOptions(value){const previous=this._pageSizeOptions;this._pageSizeOptions=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("pageSizeOptions",previous)}get selectedRowKeys(){return this._selectedRowKeys}set selectedRowKeys(value){const previous=this._selectedRowKeys;this._selectedRowKeys=snapshotKeys(value),this.requestUpdate("selectedRowKeys",previous),this.requestUpdate("selectedKeys",previous)}get selectedKeys(){return this.selectedRowKeys}set selectedKeys(value){this.selectedRowKeys=value}get selectedRows(){return frozenArray(this.allSourceRows.filter((row,index)=>arrayHasKey(this.selectedKeys,this.keyForRow(row,index))))}set selectedRows(next){const source=this.allSourceRows,sourceSet=new Set(source),sourceIndexes=this.sourceIndexMap(source),candidates=Array.isArray(next)?next:[],seen=new Set,rows=candidates.filter(row=>!sourceSet.has(row)||seen.has(row)?!1:(seen.add(row),!0)),limited=this.selectionMode==="single"?rows.slice(0,1):rows;this.selectedKeys=limited.map(row=>this.keyForRow(row,this.sourceIndexFor(row,sourceIndexes)??0))}get sort(){return this._sort}set sort(value){const previous=this._sort,next=[];if(Array.isArray(value))for(const item of value)try{if(!item||typeof item.id!="string")continue;next.push(Object.freeze({id:item.id,desc:!!item.desc}))}catch{}this._sort=Object.freeze(next),this.requestUpdate("sort",previous)}connectedCallback(){super.connectedCallback(),this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.dataSource&&this.scheduleServerRequest(!1)}disconnectedCallback(){this.requestGeneration+=1,this.requestController?.abort(),this.requestController=void 0,this.ownsLoadingState&&(this.loading=!1),this.ownsLoadingState=!1,this.cancelRequestTimer(),this.resizeSession?.moved&&this.restoreResizeSession(this.resizeSession,!1),this.resizeSession=void 0,this.activeFilterColumn=null,this.activeColumnMenu=null,this.columnsMenuOpen=!1,this.dragGhost="",this.columnDragSession=void 0,this.sink?.release(),this.sink=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&changed.has("loading")&&this.loading&&this.announce(this.localize("loading"));const sourceReplaced=changed.has("dataSource")&&changed.get("dataSource")!==void 0,serverDisabled=changed.has("server")&&!this.usesServerData;if((sourceReplaced||serverDisabled)&&(this.requestController||this.requestTimer!==void 0)&&(this.requestGeneration+=1,this.requestController?.abort(),this.requestController=void 0,this.cancelRequestTimer(),this.ownsLoadingState&&(this.loading=!1),this.ownsLoadingState=!1),this.resizeSession&&(changed.has("resizable")||changed.has("columns"))&&!this.columnCanResize(this.resizeSession.columnId)){const session=this.resizeSession;this.resizeSession=void 0,session.moved&&this.restoreResizeSession(session,!0)}if(this.columnDragSession&&(changed.has("reorderable")||changed.has("columns"))&&!this.columnCanMove(this.columnDragSession.sourceId)&&(this.columnDragSession=void 0,this.dragGhost=""),changed.has("columns")&&this.handleColumnsChange(),!this.usesServerData&&(changed.has("data")||changed.has("rowKey")||changed.has("childRows")||changed.has("server")||changed.has("dataSource"))){const validKeys=this.allSourceRows.map((row,index)=>this.keyForRow(row,index)),validKeySet=new Set(validKeys),selectedKeys=this.selectedKeys.filter(key=>validKeySet.has(key));(selectedKeys.length!==this.selectedKeys.length||selectedKeys.some((key,index)=>!keysEqual(key,this.selectedKeys[index])))&&(this.selectedKeys=selectedKeys),this.lastSelectedIndex=-1}if(this.paginate&&(changed.has("data")||changed.has("filters")||changed.has("searchTerm")||changed.has("groupBy")||changed.has("pageSize")||changed.has("total")||changed.has("server")||changed.has("dataSource"))){const lastPage=Math.max(0,this.pageCount-1);this.page=finiteInteger(this.page,0,0,lastPage)}(changed.has("data")||changed.has("columns")||changed.has("filters")||changed.has("searchTerm")||changed.has("sort")||changed.has("expandedKeys")||changed.has("groupBy")||changed.has("page")||changed.has("pageSize")||changed.has("paginate")||changed.has("childRows"))&&(this.focusedRow=finiteInteger(this.focusedRow,-1,-1,Math.max(-1,this.displayItems.length-1)),this.focusedColumn=finiteInteger(this.focusedColumn,0,0,Math.max(0,this.visibleColumns.length-1)))}updated(changed){if(super.updated(changed),changed.has("dataSource")&&this.dataSource&&this.scheduleServerRequest(!1),(changed.has("sort")||changed.has("filters")||changed.has("searchTerm")||changed.has("page")||changed.has("pageSize")||changed.has("server"))&&(this.server||this.dataSource)){const delayed=changed.has("filters")||changed.has("searchTerm");this.scheduleServerRequest(delayed)}this.isMounting=!1}announce(text){this.sink?.announce(text),this.liveText=text}get usesServerData(){return this.server||this.dataSource!==null}get safePage(){return finiteInteger(this.page,0,0,Math.max(0,this.pageCount-1))}get safePageSize(){return finiteCount(this.pageSize)}get safeTotal(){return this.total===-1?-1:finiteCount(this.total)}sourceProjection(){const result=[],visited=new Set,seenRowKeys=new Set,stack=[];for(let index=this.data.length-1;index>=0;index-=1)stack.push({row:this.data[index],depth:0});let truncated=!1;for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(!trackIdentity||trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row);const rowKey=this.rowIdentity(current.row);if(rowKey===void 0||seenRowKeys.has(rowKey))continue;seenRowKeys.add(rowKey),result.push(current.row);const children=this.childrenFor(current.row);if(children.length!==0){if(current.depth>=DATA_GRID_TREE_DEPTH_LIMIT){truncated=!0;continue}for(let index=children.length-1;index>=0;index-=1)stack.push({row:children[index],depth:current.depth+1})}}return stack.length>0&&(truncated=!0),{rows:Object.freeze(result),truncated}}get allSourceRows(){return this.sourceProjection().rows}get canonicalRootRows(){const canonical=new Set(this.allSourceRows);return this.data.filter(row=>canonical.has(row))}sourceIndexMap(rows=this.allSourceRows){const indexes=new Map;return rows.forEach((row,index)=>{indexes.has(row)||indexes.set(row,index)}),indexes}sourceIndexFor(row,indexes){const direct=indexes.get(row);if(direct!==void 0)return direct;const identity=this.rowIdentity(row);if(identity!==void 0){for(const[candidate,index]of indexes)if(Object.is(this.rowIdentity(candidate),identity))return index}}canonicalMembers(rows){const byIdentity=new Map;for(const row of this.allSourceRows){const identity=this.rowIdentity(row);identity!==void 0&&!byIdentity.has(identity)&&byIdentity.set(identity,row)}const output=[],seen=new Set;for(const candidate of rows){const identity=this.rowIdentity(candidate);if(identity===void 0||seen.has(identity))continue;const canonical=byIdentity.get(identity);canonical&&(seen.add(identity),output.push(canonical))}return output}get orderedColumns(){const entries=this.columns.map((column,naturalIndex)=>({column,id:columnId(column,naturalIndex),naturalIndex}));if(this.columnOrder.length===0)return entries;const rank=new Map(this.columnOrder.map((id,index)=>[id,index]));return entries.sort((left,right)=>{const leftRank=rank.get(left.id),rightRank=rank.get(right.id);return leftRank===void 0&&rightRank===void 0?left.naturalIndex-right.naturalIndex:leftRank===void 0?1:rightRank===void 0?-1:leftRank-rightRank})}get visibleColumns(){const entries=this.orderedColumns.filter(({column,id})=>this.columnVisibility.get(id)??column.hidden!==!0),rank=(side,id)=>this.orderedColumns.filter(entry=>normalizePinSide(this.getColumnPin(entry.id))===side).findIndex(entry=>entry.id===id);return entries.sort((left,right)=>{const leftPin=normalizePinSide(this.getColumnPin(left.id)),rightPin=normalizePinSide(this.getColumnPin(right.id));return leftPin===rightPin?0:leftPin==="left"?-1:rightPin==="left"||leftPin==="right"?1:rightPin==="right"?-1:rank("left",left.id)-rank("right",right.id)})}get processedClientRows(){const rows=this.canonicalRootRows;if(this.usesServerData)return[...rows];if(this.childRows){const included=rows.filter(row=>this.rowMatches(row)||this.filterFromLeafRows&&this.hasMatchingDescendant(row));return sortRows(included,this.columns,this.sort,this.effectiveLocale)}const filtered=filterRows(rows,this.columns,this.filters,this.effectiveLocale),searched=searchRows(filtered,this.columns,this.searchTerm,this.effectiveLocale,this.searchFn);return sortRows(searched,this.columns,this.sort,this.effectiveLocale)}childrenFor(row){try{const children=typeof this.childRows=="function"?this.childRows(row):this.childRows?pathValue(row,this.childRows):void 0;return Array.isArray(children)?children.slice(0,DATA_GRID_TREE_NODE_LIMIT):[]}catch{return[]}}rowIdentity(row){if(!((typeof row!="object"||row===null)&&typeof row!="function"))try{if(this.rowKey){const candidate=pathValue(row,this.rowKey);return isKey(candidate)?candidate:void 0}const object=row,current=this.rowOccurrenceIds.get(object);if(current)return current;const identity=`row-occurrence-${this.nextRowOccurrenceId}`;return this.nextRowOccurrenceId+=1,this.rowOccurrenceIds.set(object,identity),identity}catch{return}}keyForRow(row,_index){return this.rowIdentity(row)}renderedColumnElements(columnId2,role){const prefix=role?`[role="${role}"]`:"",ownerCss=this.ownerDocument.defaultView?.CSS,escape=ownerCss?.escape;if(typeof escape=="function")try{const matches=[...this.renderRoot.querySelectorAll(`${prefix}[data-column-id="${escape.call(ownerCss,columnId2)}"]`)];if(matches.length>0)return matches}catch{}return[...this.renderRoot.querySelectorAll(`${prefix}[data-column-id]`)].filter(element=>element.getAttribute("data-column-id")===columnId2)}computedToken(name,privateDefault){if(!this.isConnected)return"";const owner=this.ownerDocument.defaultView;if(!owner||typeof owner.getComputedStyle!="function")return"";try{const style=owner.getComputedStyle(this);return style.getPropertyValue(name).trim()||(privateDefault?style.getPropertyValue(privateDefault).trim():"")}catch{return""}}autoSizeColumn(columnId2){const cells=this.renderedColumnElements(columnId2);if(cells.length===0)return;let width=0;for(const cell of cells)width=Math.max(width,cell.scrollWidth);const entry=this.orderedColumns.find(({id})=>id===columnId2);if(!entry)return;const{minimum,maximum}=this.columnBounds(entry.column);this.setColumnWidth(columnId2,finiteRange(width,minimum,minimum,maximum),!1)}autoSizeColumns(){for(const{id}of this.visibleColumns)this.autoSizeColumn(id)}collapseAllRows(){this.expandedKeys=[]}collapseRow(key){this.expandedKeys=this.expandedKeys.filter(candidate=>!keysEqual(candidate,key))}copySelectedRows(options={}){const rowsToCopy=this.selectedRows.length>0?this.selectedRows:this.getProcessedRows(),format=options.format??"tsv",text=this.delimitedRows(rowsToCopy,{...options,delimiter:options.delimiter??(format==="csv"?",":" ")});return this.copyAndReport(text),rowsToCopy.length}expandAllRows(){const keys=[];this.allSourceRows.forEach((row,index)=>{(this.childrenFor(row).length>0||this.rowDetail)&&keys.push(this.keyForRow(row,index))});for(const group of this.groupItems(this.processedClientRows))keys.push(group.key);this.expandedKeys=keys}expandRow(key){arrayHasKey(this.expandedKeys,key)||(this.expandedKeys=[...this.expandedKeys,key])}exportDataAsCsv(options={}){const text=this.getDataAsCsv(options),ownerDocument=this.ownerDocument,owner=ownerDocument.defaultView;if(!owner||typeof owner.URL.createObjectURL!="function")return;const url=owner.URL.createObjectURL(new owner.Blob([text],{type:"text/csv;charset=utf-8"}));try{const anchor=ownerDocument.createElement("a");anchor.href=url,anchor.download=options.fileName||"data.csv",anchor.hidden=!0,ownerDocument.body?.append(anchor),anchor.click(),anchor.remove()}finally{owner.URL.revokeObjectURL(url)}}focus(options={}){const selector=this.focusedRow<0?`[role="columnheader"][data-column-position="${this.focusedColumn}"]`:`[role="gridcell"][data-row-position="${this.focusedRow}"][data-column-position="${this.focusedColumn}"]`;this.renderRoot.querySelector(selector)?.focus(options)}getColumnFacets(columnId2){const uniqueValues=new Map;if(this.usesServerData)return Object.freeze({uniqueValues});const entry=this.orderedColumns.find(({id})=>id===columnId2);if(!entry)return Object.freeze({uniqueValues});const otherFilters=this.filters.filter(filter=>filter.id!==columnId2),rows=searchRows(filterRows(this.canonicalRootRows,this.columns,otherFilters,this.effectiveLocale),this.columns,this.searchTerm,this.effectiveLocale,this.searchFn);let minimum=Number.POSITIVE_INFINITY,maximum=Number.NEGATIVE_INFINITY;for(const row of rows){const value=columnValue(entry.column,row);uniqueValues.set(value,(uniqueValues.get(value)??0)+1);const number=typeof value=="number"?value:Number(value);Number.isFinite(number)&&(minimum=Math.min(minimum,number),maximum=Math.max(maximum,number))}return Number.isFinite(minimum)&&Number.isFinite(maximum)?Object.freeze({uniqueValues,minMax:Object.freeze([minimum,maximum])}):Object.freeze({uniqueValues})}getColumnPin(columnId2){return this.columnPinning.has(columnId2)?this.columnPinning.get(columnId2)??!1:this.orderedColumns.find(({id})=>id===columnId2)?.column.pinned??!1}getDataAsCsv(options={}){return this.delimitedRows(this.getProcessedRows(),options)}getProcessedRows(){return frozenArray(this.processedClientRows)}getVisibleRows(){const rows=this.processedClientRows;if(!this.paginate||this.usesServerData)return frozenArray(rows);const size=this.safePageSize;if(size===0)return[];const start=this.safePage*size;return normalizedGroupBy(this.groupBy).length>0?frozenArray(this.topLevelGroupBuckets(rows).slice(start,start+size).flatMap(bucket=>bucket.rows)):frozenArray(rows.slice(start,start+size))}getState(){return Object.freeze({order:frozenArray(this.columnOrder),widths:Object.freeze(Object.fromEntries(this.columnWidths)),visibility:Object.freeze(Object.fromEntries(this.columnVisibility)),pinning:Object.freeze(Object.fromEntries(this.columnPinning)),sort:frozenArray(this.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(this.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)}))),search:this.searchTerm,selectedRowKeys:frozenArray(this.selectedRowKeys),expandedRowKeys:frozenArray(this.expandedRowKeys),selectedKeys:frozenArray(this.selectedRowKeys),expandedKeys:frozenArray(this.expandedRowKeys),page:this.safePage,pageSize:this.safePageSize})}handleColumnsChange(){const valid=new Set(this.columns.map((column,index)=>columnId(column,index))),natural=[...valid],order=this.columnOrder.filter(id=>valid.has(id));for(const id of natural)order.includes(id)||order.push(id);this.columnOrder.length>0&&order.join("\0")!==this.columnOrder.join("\0")&&(this.columnOrder=order);const widths=[...this.columnWidths].filter(([id])=>valid.has(id)),visibility=[...this.columnVisibility].filter(([id])=>valid.has(id)),pinning=[...this.columnPinning].filter(([id])=>valid.has(id));widths.length!==this.columnWidths.size&&(this.columnWidths=new Map(widths)),visibility.length!==this.columnVisibility.size&&(this.columnVisibility=new Map(visibility)),pinning.length!==this.columnPinning.size&&(this.columnPinning=new Map(pinning))}handlePageChange(){this.applyPageChange(this.safePage)}applyPageChange(value){let requested;typeof value=="number"?requested=value:requested=Number(valueControl(value?.currentTarget)?.value??this.safePage);const last=Math.max(0,this.pageCount-1),next=finiteInteger(requested,this.safePage,0,last);this.page=next,this.emit("lr-page-change",Object.freeze({page:next,pageSize:this.safePageSize}))}handleSearchTermChange(){this.applySearchTermChange(this.searchTerm)}applySearchTermChange(value){const next=typeof value=="string"?value:valueControl(value?.currentTarget)?.value??this.searchTerm;this.searchTerm=next,this.page!==0&&(this.page=0)}pinColumn(columnId2,side){if(!this.orderedColumns.some(({id})=>id===columnId2))return;const next=new Map(this.columnPinning);next.set(columnId2,side),this.columnPinning=next}async reload(){const owner=this.ownerDocument.defaultView;!this.isConnected||!owner||!this.usesServerData||(this.cancelRequestTimer(),await this.loadServerData(owner))}resetColumns(){this.columnOrder=[],this.columnWidths=new Map,this.columnVisibility=new Map,this.columnPinning=new Map}resetState(){this.resetColumns(),this.sort=[],this.filters=[],this.searchTerm="",this.expandedKeys=[]}scrollToIndex(index,options={}){const rows=this.getVisibleRows();if(rows.length===0)return;const requestedIndex=finiteInteger(index,0,0,rows.length-1),requestedRow=rows[requestedIndex],sourceIndexes=this.sourceIndexMap(),sourceIndex=this.sourceIndexFor(requestedRow,sourceIndexes),requestedKey=this.keyForRow(requestedRow,sourceIndex??requestedIndex),target=this.displayItems.findIndex(item=>item.kind==="row"&&(item.row===requestedRow||keysEqual(item.key,requestedKey)));if(target<0)return;const rendered=this.renderRoot?.querySelector(`[part~="row"][data-visible-index="${target}"]`);if(rendered){rendered.scrollIntoView({block:options.align??"nearest"});return}const body=this.bodyElement;if(!body)return;const rowHeight=this.resolvedRowHeight;let top=target*rowHeight;options.align==="center"?top-=(body.clientHeight-rowHeight)/2:options.align==="end"&&(top-=body.clientHeight-rowHeight),body.scrollTo({top:Math.max(0,top)})}setState(state2){const known=new Set(this.columns.map((column,index)=>columnId(column,index)));state2.order&&(this.columnOrder=state2.order.filter(id=>known.has(id))),state2.widths&&(this.columnWidths=this.validColumnMap(state2.widths,known,width=>finiteRange(width,0,0))),state2.visibility&&(this.columnVisibility=this.validColumnMap(state2.visibility,known,Boolean)),state2.pinning&&(this.columnPinning=this.validColumnMap(state2.pinning,known,side=>side==="left"||side==="right"||side==="start"||side==="end"?side:!1)),state2.sort&&(this.sort=state2.sort.filter(item=>known.has(item.id)).map(item=>({id:item.id,desc:!!item.desc}))),state2.filters&&(this.filters=state2.filters.filter(item=>known.has(item.id)).map(item=>({...item}))),state2.search!==void 0&&(this.searchTerm=state2.search);const selectedRowKeys=state2.selectedRowKeys??state2.selectedKeys,expandedRowKeys=state2.expandedRowKeys??state2.expandedKeys;selectedRowKeys&&(this.selectedRowKeys=selectedRowKeys),expandedRowKeys&&(this.expandedRowKeys=expandedRowKeys),state2.page!==void 0&&(this.page=finiteCount(state2.page)),state2.pageSize!==void 0&&(this.pageSize=finiteCount(state2.pageSize))}sizeColumnsToFit(){const body=this.bodyElement;if(!body||this.visibleColumns.length===0)return;const selectionWidth=this.selectionEnabled?resolveCssLength(this.computedToken("--lr-icon-button-size"),{host:this})??0:0,available=Math.max(0,body.clientWidth-selectionWidth),flexible=this.visibleColumns.filter(({column})=>column.flex!==0);if(flexible.length===0)return;const totalFlex=flexible.reduce((sum,{column})=>sum+finiteRange(column.flex??1,1,0),0)||flexible.length,next=new Map(this.columnWidths);for(const{column,id}of flexible){const share=available*(finiteRange(column.flex??1,1,0)/totalFlex),{minimum,maximum}=this.columnBounds(column);next.set(id,finiteRange(share,minimum,minimum,maximum))}this.columnWidths=next}toggleColumn(columnId2,visible){if(!this.orderedColumns.some(({id})=>id===columnId2))return;const next=new Map(this.columnVisibility);next.set(columnId2,visible),this.columnVisibility=next,this.focusedColumn=finiteInteger(this.focusedColumn,0,0,Math.max(0,this.visibleColumns.length-1))}validColumnMap(record,known,convert){const result=new Map;for(const[id,value]of Object.entries(record))known.has(id)&&result.set(id,convert(value));return result}delimitedRows(rows,options){const active=this.visibleColumns.map(({column,id})=>({...column,id,value:row=>{const raw=columnValue(column,row),formatted=column.formatter?.(raw,row);return typeof formatted=="string"?formatted:raw},hidden:!1}));return rowsAsDelimited(rows,active,options)}async copyAndReport(text){const owner=this.isConnected?this.ownerDocument.defaultView:null,outcome=await this.writeClipboard(text,owner);if(!(!owner||!this.isConnected||this.ownerDocument.defaultView!==owner)){if(outcome.ok){this.isMounting||this.announce(this.localize("copied")),this.emit("lr-copy",outcome);return}this.isMounting||this.announce(this.localize("copyFailed")),this.emit("lr-error"),this.emit("lr-copy-error",outcome)}}async writeClipboard(text,owner){const ownerDocument=this.ownerDocument,outcome=await writeClipboardText(owner,text);if(outcome.ok||!owner||ownerDocument.defaultView!==owner||!ownerDocument.body)return outcome;const textarea=ownerDocument.createElement("textarea");textarea.value=text,textarea.style.position="fixed",textarea.style.opacity="0",ownerDocument.body.append(textarea);try{if(textarea.select(),ownerDocument.execCommand?.("copy"))return Object.freeze({ok:!0,text})}finally{textarea.remove()}return outcome}setColumnWidth(columnIdValue,width,emit,finished=!0){const entry=this.orderedColumns.find(({id})=>id===columnIdValue);if(!entry)return;const{minimum,maximum}=this.columnBounds(entry.column),safeWidth=finiteRange(width,minimum,minimum,maximum),next=new Map(this.columnWidths);next.set(columnIdValue,safeWidth),this.columnWidths=next,emit&&this.emit("lr-column-resize",Object.freeze({columnId:columnIdValue,width:safeWidth,finished}))}cancelRequestTimer(){const timer=this.requestTimer;this.requestTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}scheduleServerRequest(delayed){const owner=this.ownerDocument.defaultView;if(!this.isConnected||!owner||!this.usesServerData)return;this.cancelRequestTimer();const delay=delayed?finiteDuration(this.filterDebounce,250):0;let handle=0;handle=owner.setTimeout(()=>{this.requestTimer?.owner!==owner||this.requestTimer.handle!==handle||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.requestTimer=void 0,this.loadServerData(owner))},delay),this.requestTimer={owner,handle}}async loadServerData(owner){if(!this.isConnected||this.ownerDocument.defaultView!==owner||!this.usesServerData)return;this.requestController?.abort();const AbortControllerCtor=owner.AbortController;this.requestController=typeof AbortControllerCtor=="function"?new AbortControllerCtor:void 0;const generation=++this.requestGeneration,request=Object.freeze({sort:frozenArray(this.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(this.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)}))),search:this.searchTerm,page:this.safePage,pageSize:this.safePageSize,signal:this.requestController?.signal}),requestDetail=()=>Object.freeze({...request,sort:frozenArray(request.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(request.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)})))});if(this.emit("request",requestDetail()),!!this.dataSource){this.ownsLoadingState=!0,this.loading=!0;try{const response=await this.dataSource(request);if(generation!==this.requestGeneration||request.signal?.aborted||!this.isConnected||this.ownerDocument.defaultView!==owner)return;this.data=Array.isArray(response.rows)?response.rows:[],this.total=finiteCount(response.total),this.loading=!1,this.ownsLoadingState=!1}catch(error){if(generation!==this.requestGeneration||request.signal?.aborted||!this.isConnected||this.ownerDocument.defaultView!==owner)return;this.loading=!1,this.ownsLoadingState=!1,this.emit("lr-data-error",Object.freeze({error,request:requestDetail()}))}}}get selectionMode(){return this.selectable===""||this.selectable==="multiple"?"multiple":this.selectable}get selectionEnabled(){return this.selectionMode!=="none"}rowIsSelectable(row){return this.selectionEnabled&&(this.selectableRows?.(row)??!0)}rowMatches(row){return filterRows([row],this.columns,this.filters,this.effectiveLocale).length>0&&searchRows([row],this.columns,this.searchTerm,this.effectiveLocale,this.searchFn).length>0}processedChildrenFor(row){const children=this.canonicalMembers(this.childrenFor(row));if(children.length===0||this.usesServerData)return children;const included=children.filter(child=>this.rowMatches(child)?!0:this.filterFromLeafRows&&this.hasMatchingDescendant(child));return sortRows(included,this.columns,this.sort,this.effectiveLocale)}hasMatchingDescendant(row){const stack=this.canonicalMembers(this.childrenFor(row)).map(child=>({row:child,depth:1})),visited=new Set;let inspected=0;for(;stack.length>0&&inspected<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(!(trackIdentity&&visited.has(current.row))){if(trackIdentity&&visited.add(current.row),inspected+=1,this.rowMatches(current.row))return!0;if(!(current.depth>=DATA_GRID_TREE_DEPTH_LIMIT))for(const child of this.canonicalMembers(this.childrenFor(current.row)))stack.push({row:child,depth:current.depth+1})}}return!1}get pageRows(){return this.getVisibleRows()}get currentPageSelectableRows(){const result=[],sourceIndex=new Map(this.allSourceRows.map((row,index)=>[row,index])),visited=new Set,stack=[...this.pageRows].reverse().map(row=>({row,depth:0}));let inspected=0;for(;stack.length>0&&inspected<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row),inspected+=1;const index=this.sourceIndexFor(current.row,sourceIndex);if(index===void 0)continue;const key=this.keyForRow(current.row,index);if(this.rowIsSelectable(current.row)&&result.push({row:current.row,key}),current.depth>=DATA_GRID_TREE_DEPTH_LIMIT)continue;const children=this.canonicalMembers(this.childrenFor(current.row));for(let childIndex=children.length-1;childIndex>=0;childIndex-=1){const child=children[childIndex];stack.push({row:child,depth:current.depth+1})}}return result}groupKey(parent,id,value){return`group:${parent}:${id}:${typeof value}:${safeText(value)}`}topLevelGroupBuckets(rows){const field=normalizedGroupBy(this.groupBy)[0];if(!field)return[];const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return[];const buckets=new Map;for(const row of rows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}return[...buckets].map(([value,bucketRows])=>({value,rows:bucketRows}))}groupItems(rows){const fields=normalizedGroupBy(this.groupBy);if(fields.length===0||this.usesServerData)return[];const result=[],visit=(groupRows,depth,parent)=>{const field=fields[depth];if(!field)return;const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return;const buckets=new Map;for(const row of groupRows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}for(const[value,bucket]of buckets){const key=this.groupKey(parent,entry.id,value);result.push({kind:"group",key,value,columnId:entry.id,rows:bucket,depth}),depth+1<fields.length&&visit(bucket,depth+1,key)}};return visit(rows,0,"root"),result}get displayItems(){const groups=normalizedGroupBy(this.groupBy);if(groups.length>0&&!this.usesServerData)return this.groupedDisplayItems(this.pageRows,groups,0,"root",this.sourceIndexMap());const result=[],sourceRows=this.allSourceRows,indexes=this.sourceIndexMap(sourceRows),visited=new Set,stack=[...this.pageRows].reverse().map(row=>({row,depth:0}));for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row);const sourceIndex=this.sourceIndexFor(current.row,indexes);if(sourceIndex===void 0)continue;const safeIndex=sourceIndex,key=this.keyForRow(current.row,safeIndex);if(result.push({kind:"row",row:current.row,key,depth:current.depth,sourceIndex:safeIndex}),!arrayHasKey(this.expandedKeys,key)||current.depth>=DATA_GRID_TREE_DEPTH_LIMIT)continue;const children=this.processedChildrenFor(current.row);for(let index=children.length-1;index>=0;index-=1)stack.push({row:children[index],depth:current.depth+1})}return result}groupedDisplayItems(rows,fields,depth,parent,sourceIndexes){const field=fields[depth];if(!field)return[];const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return rows.map((row,index)=>({kind:"row",row,key:this.keyForRow(row,this.sourceIndexFor(row,sourceIndexes)??index),depth,sourceIndex:this.sourceIndexFor(row,sourceIndexes)??index}));const buckets=new Map;for(const row of rows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}const result=[];for(const[value,bucket]of buckets){const key=this.groupKey(parent,entry.id,value);if(result.push({kind:"group",key,value,columnId:entry.id,rows:bucket,depth}),!!arrayHasKey(this.expandedKeys,key))if(depth+1<fields.length)result.push(...this.groupedDisplayItems(bucket,fields,depth+1,key,sourceIndexes));else for(const row of bucket){const sourceIndex=this.sourceIndexFor(row,sourceIndexes);result.push({kind:"row",row,key:this.keyForRow(row,sourceIndex??result.length),depth:depth+1,sourceIndex:sourceIndex??result.length})}}return result}get resolvedRowHeight(){const raw=this.computedToken("--row-height","--_lr-data-grid-row-height");return finiteRange(resolveCssLength(raw,{host:this})??56,56,1)}get virtualWindow(){const items=this.displayItems,expandedDetails=!!(this.rowDetail&&items.some(item=>item.kind==="row"&&arrayHasKey(this.expandedKeys,item.key)));if(items.length<VIRTUALIZATION_THRESHOLD||expandedDetails||this.computedToken("--max-height","--_lr-data-grid-max-height")==="none")return{items,start:0,end:items.length};const height=this.resolvedRowHeight,visibleCount=Math.max(1,Math.ceil((this.viewportHeight||height*10)/height)),start=Math.min(Math.max(0,items.length-visibleCount),Math.max(0,Math.floor(this.bodyScrollTop/height)-VIRTUAL_OVERSCAN)),end=Math.min(items.length,start+visibleCount+VIRTUAL_OVERSCAN*2);return{items:items.slice(start,end),start,end}}get gridTemplate(){const columns=this.visibleColumns.map(({column,id})=>{const bounds=this.columnBounds(column),width=this.columnWidths.get(id)??column.width;if(width!==void 0&&Number.isFinite(width)&&width>0)return`${finiteRange(width,bounds.minimum,bounds.minimum,bounds.maximum)}px`;const minimum=bounds.minimum>0?`${bounds.minimum}px`:Number.isFinite(column.maxWidth)&&(column.maxWidth??0)>0?"0px":"var(--lr-size-7rem)",maximum=Number.isFinite(column.maxWidth)&&(column.maxWidth??0)>0?`${bounds.maximum}px`:`${finiteRange(column.flex??1,1,0)}fr`;return`minmax(${minimum}, ${maximum})`});return this.selectionEnabled&&columns.unshift("var(--lr-icon-button-size)"),columns.length>0?columns.join(" "):"minmax(var(--lr-size-7rem), 1fr)"}columnStyle(column,id){const side=normalizePinSide(this.getColumnPin(id)),pinOffset=side?this.pinOffset(id,side):0;return{...side?{"--pin-offset":`${pinOffset}px`}:{},...Number.isFinite(column.width)&&(column.width??0)>0&&!this.columnWidths.has(id)?{"--column-authored-width":`${column.width}px`}:{}}}estimatedColumnWidth(column,id){const{minimum,maximum}=this.columnBounds(column),explicit=this.columnWidths.get(id)??column.width;if(explicit!==void 0)return finiteRange(explicit,Math.max(112,minimum),minimum,maximum);const raw=this.computedToken("--lr-size-7rem");return finiteRange(resolveCssLength(raw,{host:this})??112,Math.max(112,minimum),minimum,maximum)}columnBounds(column){const minimum=finiteRange(column.minWidth??0,0,0),authoredMaximum=finiteRange(column.maxWidth??Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0);return Object.freeze({minimum,maximum:Math.max(minimum,authoredMaximum)})}pinOffset(id,side){const entries=this.visibleColumns,index=entries.findIndex(entry=>entry.id===id);return index<0?0:(side==="left"?entries.slice(0,index):entries.slice(index+1)).filter(entry=>normalizePinSide(this.getColumnPin(entry.id))===side).reduce((sum,entry)=>sum+this.estimatedColumnWidth(entry.column,entry.id),0)}columnLabel(column,id){return column.label??humanizeIdentifier(column.field??id,this.effectiveLocale)}columnIsSortable(column){return column.sortable!==!1&&!!(column.field||column.value)}sortFor(id){const index=this.sort.findIndex(item=>item.id===id);return{state:index>=0?this.sort[index]:void 0,index}}activateSort(id,additive){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnIsSortable(entry.column))return;const existing=this.sortFor(id).state,descendingFirst=entry.column.sortDescFirst??this.sortDescFirst;let replacement;existing?existing.desc===descendingFirst?replacement={id,desc:!descendingFirst}:this.withoutSortRemoval&&(replacement={id,desc:descendingFirst}):replacement={id,desc:descendingFirst};let next=additive?this.sort.filter(item=>item.id!==id):[];replacement&&next.push(replacement);const limit=finiteCount(this.maxMultiSort);limit>0&&next.length>limit&&(next=next.slice(next.length-limit)),this.sort=next,this.page=0,this.emit("lr-sort-change",Object.freeze({sort:frozenArray(this.sort.map(item=>Object.freeze({...item})))}))}onHeaderClick(event,id){const target=event.target,interactive=isElementValue(target)?target.closest(INTERACTIVE_SELECTOR):null;interactive&&interactive!==event.currentTarget||this.activateSort(id,event.shiftKey)}onFilterInput(event,id){const control=valueControl(event.currentTarget);if(!control)return;const value=control.value,next=this.filters.filter(filter=>filter.id!==id);value&&next.push({id,value}),this.filters=next,this.page=0,this.emit("lr-filter-change",Object.freeze({filters:frozenArray(next.map(filter=>Object.freeze({...filter})))}))}onBodyScroll(event){const target=event.currentTarget;!isElementValue(target)||typeof target.scrollTop!="number"||typeof target.clientHeight!="number"||(this.bodyScrollTop=target.scrollTop,this.viewportHeight=target.clientHeight)}onCellClick(event,item,column,columnIdValue,index){const target=event.target,interactive=isElementValue(target)?target.closest(INTERACTIVE_SELECTOR):null;interactive&&interactive!==event.currentTarget&&isElementValue(event.currentTarget)&&event.currentTarget.contains(interactive)||this.emit("lr-cell-click",Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index}))}emitCellContextMenu(originalEvent,item,column,columnIdValue,index){const detail=Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index,originalEvent});this.emit("lr-cell-contextmenu",detail,{cancelable:!0}).defaultPrevented&&originalEvent.preventDefault()}descendantRows(row){const result=[],visited=new Set,stack=this.canonicalMembers(this.childrenFor(row)).reverse().map(child=>({row:child,depth:1}));for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row)||(trackIdentity&&visited.add(current.row),result.push(current.row),current.depth>=DATA_GRID_TREE_DEPTH_LIMIT))continue;const children=this.canonicalMembers(this.childrenFor(current.row));for(let index=children.length-1;index>=0;index-=1){const child=children[index];stack.push({row:child,depth:current.depth+1})}}return result}setRowSelected(item,selected,event){if(!this.rowIsSelectable(item.row))return;const selectableItems=this.displayItems.filter(candidate=>candidate.kind==="row"&&this.rowIsSelectable(candidate.row)),position=selectableItems.findIndex(candidate=>keysEqual(candidate.key,item.key));let affected=[item];if(event?.shiftKey&&this.selectionMode==="multiple"&&this.lastSelectedIndex>=0){const from=Math.min(this.lastSelectedIndex,position),to=Math.max(this.lastSelectedIndex,position);affected=selectableItems.slice(from,to+1)}const descendants=this.selectionMode==="multiple"?affected.flatMap(candidate=>this.descendantRows(candidate.row)).filter(row=>this.rowIsSelectable(row)):[],sourceIndexes=this.sourceIndexMap(),keys=[...affected.map(candidate=>candidate.key),...descendants.map((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return this.keyForRow(row,sourceIndex??index)})];let next=this.selectionMode==="single"?[]:[...this.selectedKeys];for(const key of keys)next=next.filter(candidate=>!keysEqual(candidate,key)),selected&&next.push(key);this.selectedKeys=next,this.lastSelectedIndex=position,this.emitSelection()}selectCurrentPage(selected){const pageKeys=this.currentPageSelectableRows.map(item=>item.key);let next=this.selectedKeys.filter(key=>!pageKeys.some(pageKey=>keysEqual(pageKey,key)));selected&&(next=[...next,...pageKeys]),this.selectedKeys=next,this.emitSelection()}emitSelection(){const selectedRowKeys=frozenArray(this.selectedRowKeys),selectedRows=frozenArray(this.selectedRows);this.emit("lr-row-select",Object.freeze({selectedRowKeys,selectedKeys:selectedRowKeys,selectedRows}))}rowSelectionState(item){const own=arrayHasKey(this.selectedKeys,item.key),descendants=this.descendantRows(item.row).filter(row=>this.rowIsSelectable(row));if(descendants.length===0)return{checked:own,indeterminate:!1};const sourceIndexes=this.sourceIndexMap(),selected=descendants.filter((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return arrayHasKey(this.selectedKeys,this.keyForRow(row,sourceIndex??index))}).length,checked=own&&selected===descendants.length;return{checked,indeterminate:!checked&&(own||selected>0)}}toggleRowExpanded(item,emitUserEvent){const expanded=arrayHasKey(this.expandedKeys,item.key);expanded?this.collapseRow(item.key):this.expandRow(item.key),emitUserEvent&&this.emit(expanded?"lr-row-collapse":"lr-row-expand",Object.freeze({rowKey:item.key,key:item.key,row:item.row}))}toggleGroupExpanded(item){const expanded=arrayHasKey(this.expandedKeys,item.key);expanded?this.collapseRow(item.key):this.expandRow(item.key);const detail=Object.freeze({key:item.key,columnId:item.columnId,value:item.value,rows:frozenArray(item.rows)});this.emit(expanded?"lr-group-collapse":"lr-group-expand",detail)}moveColumn(id,delta,emitUserEvent){const order=this.orderedColumns.map(entry=>entry.id),from=order.indexOf(id);if(from<0)return;const to=finiteInteger(from+delta,from,0,order.length-1);from!==to&&(order.splice(from,1),order.splice(to,0,id),this.columnOrder=order,emitUserEvent&&this.emit("lr-column-move",Object.freeze({columnOrder:frozenArray(order),columnId:id,finished:!0})))}columnCanMove(id){const entry=this.orderedColumns.find(item=>item.id===id);return!!(entry&&(this.reorderable||entry.column.movable))}columnCanResize(id){const entry=this.orderedColumns.find(item=>item.id===id);return!!(entry&&(this.resizable||entry.column.resizable))}onDragStart(event,id){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanMove(id)||!event.dataTransfer){event.preventDefault();return}const token=`${++this.columnDragSequence}:${id}`;this.columnDragSession=Object.freeze({sourceId:id,token}),event.dataTransfer.setData(DATA_GRID_DRAG_TYPE,token),event.dataTransfer.setData("text/plain",id),event.dataTransfer.effectAllowed="move",this.dragGhost=this.columnLabel(entry.column,id)}onDrop(event,targetId){event.preventDefault();const session=this.columnDragSession,token=event.dataTransfer?.getData(DATA_GRID_DRAG_TYPE),sourceId=session?.sourceId;if(this.columnDragSession=void 0,this.dragGhost="",!session||token!==session.token||!sourceId||sourceId===targetId||!this.columnCanMove(sourceId)||!this.columnCanMove(targetId))return;const order=this.orderedColumns.map(entry=>entry.id),source=order.indexOf(sourceId),target=order.indexOf(targetId);source<0||target<0||(order.splice(source,1),order.splice(target,0,sourceId),this.columnOrder=order,this.emit("lr-column-move",Object.freeze({columnOrder:frozenArray(order),columnId:sourceId,finished:!0})))}onResizeStart(event,id){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanResize(id))return;const header=this.renderedColumnElements(id,"columnheader")[0];this.resizeSession={columnId:id,startClientX:event.clientX,startWidth:header?.getBoundingClientRect().width??this.estimatedColumnWidth(entry.column,id),initialStateWidth:this.columnWidths.get(id),pointerId:event.pointerId,moved:!1,direction:this.effectiveDirection};try{event.currentTarget.setPointerCapture?.(event.pointerId)}catch{}event.preventDefault()}onResizeMove(event){const session=this.resizeSession;if(!session||event.pointerId!==session.pointerId)return;if(!this.columnCanResize(session.columnId)){this.resizeSession=void 0,session.moved&&this.restoreResizeSession(session,!0);return}const direction=session.direction==="rtl"?-1:1;this.setColumnWidth(session.columnId,session.startWidth+(event.clientX-session.startClientX)*direction,!0,!1),session.moved=!0}takeResizeSession(event){const session=this.resizeSession;if(!(!session||event.pointerId!==session.pointerId)){this.resizeSession=void 0;try{event.currentTarget.releasePointerCapture?.(event.pointerId)}catch{}return session}}restoreResizeSession(session,emit){const next=new Map(this.columnWidths);session.initialStateWidth===void 0?next.delete(session.columnId):next.set(session.columnId,session.initialStateWidth),this.columnWidths=next,emit&&this.emit("lr-column-resize",Object.freeze({columnId:session.columnId,width:session.startWidth,finished:!1}))}onResizeEnd(event){const session=this.takeResizeSession(event);if(!session)return;if(!this.columnCanResize(session.columnId)){session.moved&&this.restoreResizeSession(session,!0);return}const width=this.columnWidths.get(session.columnId)??session.startWidth;this.emit("lr-column-resize",Object.freeze({columnId:session.columnId,width,finished:!0}))}onResizeCancel(event){const session=this.takeResizeSession(event);!session||!session.moved||this.restoreResizeSession(session,!0)}onResizeKey(event,id){if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanResize(id))return;const logical=(event.key==="ArrowRight"?1:-1)*(this.effectiveDirection==="rtl"?-1:1),current=this.columnWidths.get(id)??this.estimatedColumnWidth(entry.column,id);this.setColumnWidth(id,current+logical*10,!0,!0),event.preventDefault()}onPageSizeChange(event){const control=valueControl(event.currentTarget);control&&(this.pageSize=finiteCount(Number(control.value)),this.page=0,this.emit("lr-page-change",Object.freeze({page:0,pageSize:this.safePageSize})))}focusCell(row,column){const rowLimit=Math.max(-1,this.displayItems.length-1),columnLimit=Math.max(0,this.visibleColumns.length-1);this.focusedRow=finiteInteger(row,this.focusedRow,-1,rowLimit),this.focusedColumn=finiteInteger(column,this.focusedColumn,0,columnLimit);let pendingScrollTop;if(this.focusedRow>=0){const selector=`[role="gridcell"][data-row-position="${this.focusedRow}"]`;if(!this.renderRoot.querySelector(selector)){const top=this.focusedRow*this.resolvedRowHeight;pendingScrollTop=top,this.bodyScrollTop=top,this.bodyElement&&(this.bodyElement.scrollTop=top)}}this.updateComplete.then(()=>{pendingScrollTop!==void 0&&this.bodyElement&&(this.bodyElement.scrollTop=pendingScrollTop),this.focus()})}onGridKeyDown(event,rowPosition,columnPosition,item,column,columnIdValue){const target=event.target;if(isElementValue(target)&&target!==event.currentTarget&&target.closest(INTERACTIVE_SELECTOR))return;const rtlMultiplier=this.effectiveDirection==="rtl"?-1:1;if(event.ctrlKey&&event.key.toLowerCase()==="a"&&this.selectionMode==="multiple"){this.selectCurrentPage(!0),event.preventDefault();return}if(event.ctrlKey&&event.key.toLowerCase()==="c"){this.copySelectedRows(),event.preventDefault();return}if(event.shiftKey&&event.key==="F10"&&item&&column&&columnIdValue){this.emitCellContextMenu(event,item,column,columnIdValue,rowPosition);return}const headerEntry=columnIdValue?this.orderedColumns.find(entry=>entry.id===columnIdValue):void 0;if(rowPosition<0&&columnIdValue&&headerEntry&&(this.reorderable||headerEntry.column.movable)&&event.shiftKey&&!event.altKey&&(event.key==="ArrowLeft"||event.key==="ArrowRight")){const delta=(event.key==="ArrowRight"?1:-1)*rtlMultiplier;this.moveColumn(columnIdValue,delta,!0),event.preventDefault();return}if(!(rowPosition<0&&columnIdValue&&headerEntry&&(this.resizable||headerEntry.column.resizable)&&event.altKey&&(this.onResizeKey(event,columnIdValue),event.defaultPrevented))){if(event.key==="ArrowLeft"||event.key==="ArrowRight"){const delta=(event.key==="ArrowRight"?1:-1)*rtlMultiplier;this.focusCell(rowPosition,columnPosition+delta),event.preventDefault()}else if(event.key==="ArrowUp")this.focusCell(rowPosition-1,columnPosition),event.preventDefault();else if(event.key==="ArrowDown")this.focusCell(rowPosition+1,columnPosition),event.preventDefault();else if(event.key==="Home")this.focusCell(event.ctrlKey?-1:rowPosition,0),event.preventDefault();else if(event.key==="End")this.focusCell(event.ctrlKey?this.displayItems.length-1:rowPosition,this.visibleColumns.length-1),event.preventDefault();else if(event.key==="PageUp"||event.key==="PageDown"){const delta=event.key==="PageDown"?this.safePageSize||10:-(this.safePageSize||10);this.focusCell(rowPosition+delta,columnPosition),event.preventDefault()}else if(event.key==="Enter")rowPosition<0&&columnIdValue?this.activateSort(columnIdValue,event.shiftKey):item&&column&&columnIdValue&&this.emit("lr-cell-click",Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index:rowPosition})),event.preventDefault();else if(event.key===" "&&item){const selected=!arrayHasKey(this.selectedKeys,item.key);this.setRowSelected(item,selected,event),event.preventDefault()}}}setGroupSelected(group,selected){const eligible=group.rows.filter(row=>this.rowIsSelectable(row)),sourceIndexes=this.sourceIndexMap(),groupKeys=eligible.map((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return this.keyForRow(row,sourceIndex??index)});let next=this.selectedKeys.filter(key=>!groupKeys.some(groupKey=>keysEqual(groupKey,key)));selected&&(next=[...next,...groupKeys]),this.selectedKeys=next,this.emitSelection()}userPinColumn(id,side){this.pinColumn(id,side),this.emit("lr-column-pin",Object.freeze({columnId:id,side}))}userToggleColumn(id,visible){this.toggleColumn(id,visible),this.emit("lr-column-visibility-change",Object.freeze({columnId:id,visible}))}renderToolbar(){return!this.withSearch&&!this.withColumnsMenu?nothing:html`
|
|
1
|
+
var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{resolveCssLength}from"../../../internal/css-length.js";import{getNumberFormat,resolveIntlLocale}from"../../../internal/intl-cache.js";import{chevronIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{finiteCount,finiteDuration,finiteInteger,finiteRange}from"../../../internal/numbers.js";import{sizes}from"../../../internal/sizes.styles.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{aggregateValues,columnId,columnValue,filterRows,pathValue,rowsAsDelimited,searchRows,sortRows}from"./data-grid-processing.js";import{styles}from"./data-grid.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copied,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_dataGridColumnMenu,LYRA_DEFAULT_dataGridPinEnd,LYRA_DEFAULT_dataGridPinStart,LYRA_DEFAULT_dataGridRowsPerPage,LYRA_DEFAULT_dataGridTreeLimitReached,LYRA_DEFAULT_dataGridUnpin,LYRA_DEFAULT_expand,LYRA_DEFAULT_loading,LYRA_DEFAULT_next,LYRA_DEFAULT_noColumns,LYRA_DEFAULT_noData,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_paginationFirstPage,LYRA_DEFAULT_paginationJumpToPage,LYRA_DEFAULT_paginationLabel,LYRA_DEFAULT_paginationLastPage,LYRA_DEFAULT_previous,LYRA_DEFAULT_resizeColumn,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_showAllColumns,LYRA_DEFAULT_tableFilterLabel}from"../../../internal/default-strings.generated.js";export*from"./data-grid-types.js";const selectableConverter={fromAttribute(value){return value===null?"none":value===""||value==="multiple"?"multiple":value==="single"||value==="none"?value:"none"},toAttribute(value){return value==="none"?null:value===""||value==="multiple"?"":value}};function snapshotColumns(value,occurrenceId){if(!Array.isArray(value))return Object.freeze([]);const output=[],seen=new Set;for(const column of value)try{if(column===null||typeof column!="object"||Array.isArray(column))continue;const hasId=Object.prototype.hasOwnProperty.call(column,"id"),hasField=Object.prototype.hasOwnProperty.call(column,"field"),authoredId=hasId?column.id:void 0,authoredField=hasField?column.field:void 0;if(hasId&&authoredId!==void 0&&(typeof authoredId!="string"||authoredId.trim()==="")||!hasId&&hasField&&authoredField!==void 0&&(typeof authoredField!="string"||authoredField.trim()===""))continue;const identity=typeof authoredId=="string"?authoredId:typeof authoredField=="string"?authoredField:occurrenceId(column);if(seen.has(identity))continue;seen.add(identity);const snapshot={...column,...authoredId===void 0&&authoredField===void 0?{id:identity}:{}};output.push(Object.freeze(snapshot))}catch{}return Object.freeze(output)}const INTERACTIVE_SELECTOR='button, a[href], input, select, textarea, summary, [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"]), [role="button"], [role="checkbox"], [role="radio"]',VIRTUALIZATION_THRESHOLD=80,VIRTUAL_OVERSCAN=5,DATA_GRID_TREE_NODE_LIMIT=1e4,DATA_GRID_TREE_DEPTH_LIMIT=64,DATA_GRID_DRAG_TYPE="application/x-lyra-data-grid-column";function frozenArray(values){return Object.freeze([...values])}function serializableFilterValue(value){try{const serialized=JSON.stringify({value},(_key,nested)=>typeof nested=="bigint"?nested.toString():typeof nested=="number"&&!Number.isFinite(nested)?null:nested!==null&&typeof nested=="object"&&Object.prototype.toString.call(nested)==="[object Set]"?[...nested]:nested);if(!serialized)return null;const snapshot=JSON.parse(serialized).value??null,stack=[snapshot],visited=new Set;for(;stack.length>0;){const current=stack.pop();if(!(current===null||typeof current!="object"||visited.has(current))){visited.add(current);for(const nested of Object.values(current))stack.push(nested);Object.freeze(current)}}return snapshot}catch{return null}}function isKey(value){return typeof value=="string"&&value.trim()!==""||typeof value=="number"&&Number.isFinite(value)}function snapshotKeys(value){if(!Array.isArray(value))return Object.freeze([]);const output=[],seen=new Set;for(const key of value)!isKey(key)||seen.has(key)||(seen.add(key),output.push(key));return frozenArray(output)}function keysEqual(left,right){return typeof left==typeof right&&left===right}function arrayHasKey(keys,key){return keys.some(candidate=>keysEqual(candidate,key))}function isElementValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return candidate.nodeType===1&&typeof candidate.closest=="function"}function valueControl(value){return!isElementValue(value)||typeof value.value!="string"?null:value}function checkableControl(value){return!isElementValue(value)||typeof value.checked!="boolean"?null:value}function dateText(value){try{const timestamp=Date.prototype.getTime.call(value);return Number.isFinite(timestamp)?Date.prototype.toISOString.call(value):""}catch{return}}function humanizeIdentifier(value,locale){const intlLocale=resolveIntlLocale(locale);return value.replaceAll(/[._-]+/gu," ").replaceAll(/([a-z\d])([A-Z])/gu,"$1 $2").replace(/^./u,first=>first.toLocaleUpperCase(intlLocale))}function safeText(value){if(value==null)return"";if(typeof value=="object"){const serializedDate=dateText(value);if(serializedDate!==void 0)return serializedDate}if(Array.isArray(value))return value.map(safeText).join(", ");if(typeof value=="object")try{return JSON.stringify(value,(_key,nested)=>typeof nested=="bigint"?nested.toString():nested)??""}catch{return""}return String(value)}function normalizePinSide(side){return side==="start"?"left":side==="end"?"right":side}function normalizedGroupBy(value){return typeof value!="string"?(value??[]).map(entry=>entry.trim()).filter(Boolean).slice(0,DATA_GRID_TREE_DEPTH_LIMIT):value.split(/[\s,]+/u).map(entry=>entry.trim()).filter(Boolean).slice(0,DATA_GRID_TREE_DEPTH_LIMIT)}class LyraDataGrid extends LyraElement{constructor(){super(...arguments),this.appearance="outlined",this.childRows=null,this._columnOrder=Object.freeze([]),this.columnOccurrenceIds=new WeakMap,this.nextColumnOccurrenceId=1,this.rowOccurrenceIds=new WeakMap,this.nextRowOccurrenceId=1,this._columns=Object.freeze([]),this._data=Object.freeze([]),this.dataSource=null,this._expandedRowKeys=Object.freeze([]),this.filterDebounce=250,this.filterFromLeafRows=!1,this._filters=Object.freeze([]),this._groupBy=null,this.label=null,this.loading=!1,this.maxMultiSort=0,this.page=0,this.pageSize=20,this._pageSizeOptions=Object.freeze([10,20,50,100]),this.paginate=!1,this.pinnable=!1,this.reorderable=!1,this.resizable=!1,this.rowClass=null,this.rowDetail=null,this.rowKey=null,this.searchFn=null,this.searchTerm="",this.selectable="none",this.selectableRows=null,this._selectedRowKeys=Object.freeze([]),this.server=!1,this.size="m",this._sort=Object.freeze([]),this.sortDescFirst=!1,this.striped=!1,this.total=-1,this.withColumnMenu=!1,this.withColumnsMenu=!1,this.withoutSortRemoval=!1,this.withSearch=!1,this.columnWidths=new Map,this.columnVisibility=new Map,this.columnPinning=new Map,this.activeFilterColumn=null,this.columnsMenuOpen=!1,this.activeColumnMenu=null,this.liveText="",this.bodyScrollTop=0,this.viewportHeight=0,this.focusedRow=-1,this.focusedColumn=0,this.dragGhost="",this.requestGeneration=0,this.ownsLoadingState=!1,this.columnDragSequence=0,this.lastSelectedIndex=-1,this.isMounting=!0,this.relayEditorFocus=event=>{relayNativeEvent(this,event)},this.relayEditorBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,copied:LYRA_DEFAULT_copied,copyFailed:LYRA_DEFAULT_copyFailed,dataGridColumnMenu:LYRA_DEFAULT_dataGridColumnMenu,dataGridPinEnd:LYRA_DEFAULT_dataGridPinEnd,dataGridPinStart:LYRA_DEFAULT_dataGridPinStart,dataGridRowsPerPage:LYRA_DEFAULT_dataGridRowsPerPage,dataGridTreeLimitReached:LYRA_DEFAULT_dataGridTreeLimitReached,dataGridUnpin:LYRA_DEFAULT_dataGridUnpin,expand:LYRA_DEFAULT_expand,loading:LYRA_DEFAULT_loading,next:LYRA_DEFAULT_next,noColumns:LYRA_DEFAULT_noColumns,noData:LYRA_DEFAULT_noData,noMatches:LYRA_DEFAULT_noMatches,paginationFirstPage:LYRA_DEFAULT_paginationFirstPage,paginationJumpToPage:LYRA_DEFAULT_paginationJumpToPage,paginationLabel:LYRA_DEFAULT_paginationLabel,paginationLastPage:LYRA_DEFAULT_paginationLastPage,previous:LYRA_DEFAULT_previous,resizeColumn:LYRA_DEFAULT_resizeColumn,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,showAllColumns:LYRA_DEFAULT_showAllColumns,tableFilterLabel:LYRA_DEFAULT_tableFilterLabel}}static{this.immutableEventDetails=Object.freeze(["request","lr-column-move","lr-data-error"])}static{this.identityEventDetailProperties=Object.freeze({request:Object.freeze(["signal"]),"lr-data-error":Object.freeze(["error","request"])})}static{this.styles=[LyraElement.styles,sizes,srOnly,styles]}get columnOrder(){return this._columnOrder}set columnOrder(value){const previous=this._columnOrder,seen=new Set;this._columnOrder=frozenArray(Array.isArray(value)?value.filter(id=>typeof id!="string"||id.trim()===""||seen.has(id)?!1:(seen.add(id),!0)):[]),this.requestUpdate("columnOrder",previous)}get columns(){return this._columns}set columns(value){const previous=this._columns;this._columns=snapshotColumns(value,column=>{const current=this.columnOccurrenceIds.get(column);if(current)return current;const identity=`column-occurrence-${this.nextColumnOccurrenceId}`;return this.nextColumnOccurrenceId+=1,this.columnOccurrenceIds.set(column,identity),identity}),this.requestUpdate("columns",previous)}get data(){return this._data}set data(value){const previous=this._data;this._data=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("data",previous)}get expandedRowKeys(){return this._expandedRowKeys}set expandedRowKeys(value){const previous=this._expandedRowKeys;this._expandedRowKeys=snapshotKeys(value),this.requestUpdate("expandedRowKeys",previous),this.requestUpdate("expandedKeys",previous)}get expandedKeys(){return this.expandedRowKeys}set expandedKeys(value){this.expandedRowKeys=value}get filteredCount(){return this.processedClientRows.length}get filters(){return this._filters}set filters(value){const previous=this._filters,next=[];if(Array.isArray(value))for(const filter of value)try{if(!filter||typeof filter.id!="string")continue;const filterValue=filter.value instanceof Set||Array.isArray(filter.value)?frozenArray(filter.value):filter.value;next.push(Object.freeze({id:filter.id,value:filterValue}))}catch{}this._filters=Object.freeze(next),this.requestUpdate("filters",previous)}get groupBy(){return this._groupBy}set groupBy(value){const previous=this._groupBy;this._groupBy=typeof value=="string"?value:Array.isArray(value)?frozenArray(value.filter(item=>typeof item=="string")):null,this.requestUpdate("groupBy",previous)}get pageCount(){const size=this.safePageSize;if(size===0)return 0;if(!this.usesServerData&&normalizedGroupBy(this.groupBy).length>0){const groups=this.topLevelGroupBuckets(this.processedClientRows).length;return groups<=0?0:Math.ceil(groups/size)}const count=this.safeTotal>=0?this.safeTotal:this.filteredCount;return count<=0?0:Math.ceil(count/size)}get pageSizeOptions(){return this._pageSizeOptions}set pageSizeOptions(value){const previous=this._pageSizeOptions;this._pageSizeOptions=frozenArray(Array.isArray(value)?value:[]),this.requestUpdate("pageSizeOptions",previous)}get selectedRowKeys(){return this._selectedRowKeys}set selectedRowKeys(value){const previous=this._selectedRowKeys;this._selectedRowKeys=snapshotKeys(value),this.requestUpdate("selectedRowKeys",previous),this.requestUpdate("selectedKeys",previous)}get selectedKeys(){return this.selectedRowKeys}set selectedKeys(value){this.selectedRowKeys=value}get selectedRows(){return frozenArray(this.allSourceRows.filter((row,index)=>arrayHasKey(this.selectedKeys,this.keyForRow(row,index))))}set selectedRows(next){const source=this.allSourceRows,sourceSet=new Set(source),sourceIndexes=this.sourceIndexMap(source),candidates=Array.isArray(next)?next:[],seen=new Set,rows=candidates.filter(row=>!sourceSet.has(row)||seen.has(row)?!1:(seen.add(row),!0)),limited=this.selectionMode==="single"?rows.slice(0,1):rows;this.selectedKeys=limited.map(row=>this.keyForRow(row,this.sourceIndexFor(row,sourceIndexes)??0))}get sort(){return this._sort}set sort(value){const previous=this._sort,next=[];if(Array.isArray(value))for(const item of value)try{if(!item||typeof item.id!="string")continue;next.push(Object.freeze({id:item.id,desc:!!item.desc}))}catch{}this._sort=Object.freeze(next),this.requestUpdate("sort",previous)}connectedCallback(){super.connectedCallback(),this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.dataSource&&this.scheduleServerRequest(!1)}disconnectedCallback(){this.requestGeneration+=1,this.requestController?.abort(),this.requestController=void 0,this.ownsLoadingState&&(this.loading=!1),this.ownsLoadingState=!1,this.cancelRequestTimer(),this.resizeSession?.moved&&this.restoreResizeSession(this.resizeSession,!1),this.resizeSession=void 0,this.activeFilterColumn=null,this.activeColumnMenu=null,this.columnsMenuOpen=!1,this.dragGhost="",this.columnDragSession=void 0,this.sink?.release(),this.sink=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&changed.has("loading")&&this.loading&&this.announce(this.localize("loading"));const sourceReplaced=changed.has("dataSource")&&changed.get("dataSource")!==void 0,serverDisabled=changed.has("server")&&!this.usesServerData;if((sourceReplaced||serverDisabled)&&(this.requestController||this.requestTimer!==void 0)&&(this.requestGeneration+=1,this.requestController?.abort(),this.requestController=void 0,this.cancelRequestTimer(),this.ownsLoadingState&&(this.loading=!1),this.ownsLoadingState=!1),this.resizeSession&&(changed.has("resizable")||changed.has("columns"))&&!this.columnCanResize(this.resizeSession.columnId)){const session=this.resizeSession;this.resizeSession=void 0,session.moved&&this.restoreResizeSession(session,!0)}if(this.columnDragSession&&(changed.has("reorderable")||changed.has("columns"))&&!this.columnCanMove(this.columnDragSession.sourceId)&&(this.columnDragSession=void 0,this.dragGhost=""),changed.has("columns")&&this.handleColumnsChange(),!this.usesServerData&&(changed.has("data")||changed.has("rowKey")||changed.has("childRows")||changed.has("server")||changed.has("dataSource"))){const validKeys=this.allSourceRows.map((row,index)=>this.keyForRow(row,index)),validKeySet=new Set(validKeys),selectedKeys=this.selectedKeys.filter(key=>validKeySet.has(key));(selectedKeys.length!==this.selectedKeys.length||selectedKeys.some((key,index)=>!keysEqual(key,this.selectedKeys[index])))&&(this.selectedKeys=selectedKeys),this.lastSelectedIndex=-1}if(this.paginate&&(changed.has("data")||changed.has("filters")||changed.has("searchTerm")||changed.has("groupBy")||changed.has("pageSize")||changed.has("total")||changed.has("server")||changed.has("dataSource"))){const lastPage=Math.max(0,this.pageCount-1);this.page=finiteInteger(this.page,0,0,lastPage)}(changed.has("data")||changed.has("columns")||changed.has("filters")||changed.has("searchTerm")||changed.has("sort")||changed.has("expandedKeys")||changed.has("groupBy")||changed.has("page")||changed.has("pageSize")||changed.has("paginate")||changed.has("childRows"))&&(this.focusedRow=finiteInteger(this.focusedRow,-1,-1,Math.max(-1,this.displayItems.length-1)),this.focusedColumn=finiteInteger(this.focusedColumn,0,0,Math.max(0,this.visibleColumns.length-1)))}updated(changed){if(super.updated(changed),changed.has("dataSource")&&this.dataSource&&this.scheduleServerRequest(!1),(changed.has("sort")||changed.has("filters")||changed.has("searchTerm")||changed.has("page")||changed.has("pageSize")||changed.has("server"))&&(this.server||this.dataSource)){const delayed=changed.has("filters")||changed.has("searchTerm");this.scheduleServerRequest(delayed)}this.isMounting=!1}announce(text){this.sink?.announce(text),this.liveText=text}get usesServerData(){return this.server||this.dataSource!==null}get safePage(){return finiteInteger(this.page,0,0,Math.max(0,this.pageCount-1))}get safePageSize(){return finiteCount(this.pageSize)}get safeTotal(){return this.total===-1?-1:finiteCount(this.total)}sourceProjection(){const result=[],visited=new Set,seenRowKeys=new Set,stack=[];for(let index=this.data.length-1;index>=0;index-=1)stack.push({row:this.data[index],depth:0});let truncated=!1;for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(!trackIdentity||trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row);const rowKey=this.rowIdentity(current.row);if(rowKey===void 0||seenRowKeys.has(rowKey))continue;seenRowKeys.add(rowKey),result.push(current.row);const children=this.childrenFor(current.row);if(children.length!==0){if(current.depth>=DATA_GRID_TREE_DEPTH_LIMIT){truncated=!0;continue}for(let index=children.length-1;index>=0;index-=1)stack.push({row:children[index],depth:current.depth+1})}}return stack.length>0&&(truncated=!0),{rows:Object.freeze(result),truncated}}get allSourceRows(){return this.sourceProjection().rows}get canonicalRootRows(){const canonical=new Set(this.allSourceRows);return this.data.filter(row=>canonical.has(row))}sourceIndexMap(rows=this.allSourceRows){const indexes=new Map;return rows.forEach((row,index)=>{indexes.has(row)||indexes.set(row,index)}),indexes}sourceIndexFor(row,indexes){const direct=indexes.get(row);if(direct!==void 0)return direct;const identity=this.rowIdentity(row);if(identity!==void 0){for(const[candidate,index]of indexes)if(Object.is(this.rowIdentity(candidate),identity))return index}}canonicalMembers(rows){const byIdentity=new Map;for(const row of this.allSourceRows){const identity=this.rowIdentity(row);identity!==void 0&&!byIdentity.has(identity)&&byIdentity.set(identity,row)}const output=[],seen=new Set;for(const candidate of rows){const identity=this.rowIdentity(candidate);if(identity===void 0||seen.has(identity))continue;const canonical=byIdentity.get(identity);canonical&&(seen.add(identity),output.push(canonical))}return output}get orderedColumns(){const entries=this.columns.map((column,naturalIndex)=>({column,id:columnId(column,naturalIndex),naturalIndex}));if(this.columnOrder.length===0)return entries;const rank=new Map(this.columnOrder.map((id,index)=>[id,index]));return entries.sort((left,right)=>{const leftRank=rank.get(left.id),rightRank=rank.get(right.id);return leftRank===void 0&&rightRank===void 0?left.naturalIndex-right.naturalIndex:leftRank===void 0?1:rightRank===void 0?-1:leftRank-rightRank})}get visibleColumns(){const entries=this.orderedColumns.filter(({column,id})=>this.columnVisibility.get(id)??column.hidden!==!0),rank=(side,id)=>this.orderedColumns.filter(entry=>normalizePinSide(this.getColumnPin(entry.id))===side).findIndex(entry=>entry.id===id);return entries.sort((left,right)=>{const leftPin=normalizePinSide(this.getColumnPin(left.id)),rightPin=normalizePinSide(this.getColumnPin(right.id));return leftPin===rightPin?0:leftPin==="left"?-1:rightPin==="left"||leftPin==="right"?1:rightPin==="right"?-1:rank("left",left.id)-rank("right",right.id)})}get processedClientRows(){const rows=this.canonicalRootRows;if(this.usesServerData)return[...rows];if(this.childRows){const included=rows.filter(row=>this.rowMatches(row)||this.filterFromLeafRows&&this.hasMatchingDescendant(row));return sortRows(included,this.columns,this.sort,this.effectiveLocale)}const filtered=filterRows(rows,this.columns,this.filters,this.effectiveLocale),searched=searchRows(filtered,this.columns,this.searchTerm,this.effectiveLocale,this.searchFn);return sortRows(searched,this.columns,this.sort,this.effectiveLocale)}childrenFor(row){try{const children=typeof this.childRows=="function"?this.childRows(row):this.childRows?pathValue(row,this.childRows):void 0;return Array.isArray(children)?children.slice(0,DATA_GRID_TREE_NODE_LIMIT):[]}catch{return[]}}rowIdentity(row){if(!((typeof row!="object"||row===null)&&typeof row!="function"))try{if(this.rowKey){const candidate=pathValue(row,this.rowKey);return isKey(candidate)?candidate:void 0}const object=row,current=this.rowOccurrenceIds.get(object);if(current)return current;const identity=`row-occurrence-${this.nextRowOccurrenceId}`;return this.nextRowOccurrenceId+=1,this.rowOccurrenceIds.set(object,identity),identity}catch{return}}keyForRow(row,_index){return this.rowIdentity(row)}renderedColumnElements(columnId2,role){const prefix=role?`[role="${role}"]`:"",ownerCss=this.ownerDocument.defaultView?.CSS,escape=ownerCss?.escape;if(typeof escape=="function")try{const matches=[...this.renderRoot.querySelectorAll(`${prefix}[data-column-id="${escape.call(ownerCss,columnId2)}"]`)];if(matches.length>0)return matches}catch{}return[...this.renderRoot.querySelectorAll(`${prefix}[data-column-id]`)].filter(element=>element.getAttribute("data-column-id")===columnId2)}computedToken(name,privateDefault){if(!this.isConnected)return"";const owner=this.ownerDocument.defaultView;if(!owner||typeof owner.getComputedStyle!="function")return"";try{const style=owner.getComputedStyle(this);return style.getPropertyValue(name).trim()||(privateDefault?style.getPropertyValue(privateDefault).trim():"")}catch{return""}}autoSizeColumn(columnId2){const cells=this.renderedColumnElements(columnId2);if(cells.length===0)return;let width=0;for(const cell of cells)width=Math.max(width,cell.scrollWidth);const entry=this.orderedColumns.find(({id})=>id===columnId2);if(!entry)return;const{minimum,maximum}=this.columnBounds(entry.column);this.setColumnWidth(columnId2,finiteRange(width,minimum,minimum,maximum),!1)}autoSizeColumns(){for(const{id}of this.visibleColumns)this.autoSizeColumn(id)}collapseAllRows(){this.expandedKeys=[]}collapseRow(key){this.expandedKeys=this.expandedKeys.filter(candidate=>!keysEqual(candidate,key))}copySelectedRows(options={}){const rowsToCopy=this.selectedRows.length>0?this.selectedRows:this.getProcessedRows(),format=options.format??"tsv",text=this.delimitedRows(rowsToCopy,{...options,delimiter:options.delimiter??(format==="csv"?",":" ")});return this.copyAndReport(text),rowsToCopy.length}expandAllRows(){const keys=[];this.allSourceRows.forEach((row,index)=>{(this.childrenFor(row).length>0||this.rowDetail)&&keys.push(this.keyForRow(row,index))});for(const group of this.groupItems(this.processedClientRows))keys.push(group.key);this.expandedKeys=keys}expandRow(key){arrayHasKey(this.expandedKeys,key)||(this.expandedKeys=[...this.expandedKeys,key])}exportDataAsCsv(options={}){const text=this.getDataAsCsv(options),ownerDocument=this.ownerDocument,owner=ownerDocument.defaultView;if(!owner||typeof owner.URL.createObjectURL!="function")return;const url=owner.URL.createObjectURL(new owner.Blob([text],{type:"text/csv;charset=utf-8"}));try{const anchor=ownerDocument.createElement("a");anchor.href=url,anchor.download=options.fileName||"data.csv",anchor.hidden=!0,ownerDocument.body?.append(anchor),anchor.click(),anchor.remove()}finally{owner.URL.revokeObjectURL(url)}}focus(options={}){const selector=this.focusedRow<0?`[role="columnheader"][data-column-position="${this.focusedColumn}"]`:`[role="gridcell"][data-row-position="${this.focusedRow}"][data-column-position="${this.focusedColumn}"]`;this.renderRoot.querySelector(selector)?.focus(options)}getColumnFacets(columnId2){const uniqueValues=new Map;if(this.usesServerData)return Object.freeze({uniqueValues});const entry=this.orderedColumns.find(({id})=>id===columnId2);if(!entry)return Object.freeze({uniqueValues});const otherFilters=this.filters.filter(filter=>filter.id!==columnId2),rows=searchRows(filterRows(this.canonicalRootRows,this.columns,otherFilters,this.effectiveLocale),this.columns,this.searchTerm,this.effectiveLocale,this.searchFn);let minimum=Number.POSITIVE_INFINITY,maximum=Number.NEGATIVE_INFINITY;for(const row of rows){const value=columnValue(entry.column,row);uniqueValues.set(value,(uniqueValues.get(value)??0)+1);const number=typeof value=="number"?value:Number(value);Number.isFinite(number)&&(minimum=Math.min(minimum,number),maximum=Math.max(maximum,number))}return Number.isFinite(minimum)&&Number.isFinite(maximum)?Object.freeze({uniqueValues,minMax:Object.freeze([minimum,maximum])}):Object.freeze({uniqueValues})}getColumnPin(columnId2){return this.columnPinning.has(columnId2)?this.columnPinning.get(columnId2)??!1:this.orderedColumns.find(({id})=>id===columnId2)?.column.pinned??!1}getDataAsCsv(options={}){return this.delimitedRows(this.getProcessedRows(),options)}getProcessedRows(){return frozenArray(this.processedClientRows)}getVisibleRows(){const rows=this.processedClientRows;if(!this.paginate||this.usesServerData)return frozenArray(rows);const size=this.safePageSize;if(size===0)return[];const start=this.safePage*size;return normalizedGroupBy(this.groupBy).length>0?frozenArray(this.topLevelGroupBuckets(rows).slice(start,start+size).flatMap(bucket=>bucket.rows)):frozenArray(rows.slice(start,start+size))}getState(){return Object.freeze({order:frozenArray(this.columnOrder),widths:Object.freeze(Object.fromEntries(this.columnWidths)),visibility:Object.freeze(Object.fromEntries(this.columnVisibility)),pinning:Object.freeze(Object.fromEntries(this.columnPinning)),sort:frozenArray(this.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(this.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)}))),search:this.searchTerm,selectedRowKeys:frozenArray(this.selectedRowKeys),expandedRowKeys:frozenArray(this.expandedRowKeys),selectedKeys:frozenArray(this.selectedRowKeys),expandedKeys:frozenArray(this.expandedRowKeys),page:this.safePage,pageSize:this.safePageSize})}handleColumnsChange(){const valid=new Set(this.columns.map((column,index)=>columnId(column,index))),natural=[...valid],order=this.columnOrder.filter(id=>valid.has(id));for(const id of natural)order.includes(id)||order.push(id);this.columnOrder.length>0&&order.join("\0")!==this.columnOrder.join("\0")&&(this.columnOrder=order);const widths=[...this.columnWidths].filter(([id])=>valid.has(id)),visibility=[...this.columnVisibility].filter(([id])=>valid.has(id)),pinning=[...this.columnPinning].filter(([id])=>valid.has(id));widths.length!==this.columnWidths.size&&(this.columnWidths=new Map(widths)),visibility.length!==this.columnVisibility.size&&(this.columnVisibility=new Map(visibility)),pinning.length!==this.columnPinning.size&&(this.columnPinning=new Map(pinning))}handlePageChange(){this.applyPageChange(this.safePage)}applyPageChange(value){let requested;typeof value=="number"?requested=value:requested=Number(valueControl(value?.currentTarget)?.value??this.safePage);const last=Math.max(0,this.pageCount-1),next=finiteInteger(requested,this.safePage,0,last);this.page=next,this.emit("lr-page-change",Object.freeze({page:next,pageSize:this.safePageSize}))}handleSearchTermChange(){this.applySearchTermChange(this.searchTerm)}applySearchTermChange(value){const next=typeof value=="string"?value:valueControl(value?.currentTarget)?.value??this.searchTerm;this.searchTerm=next,this.page!==0&&(this.page=0)}pinColumn(columnId2,side){if(!this.orderedColumns.some(({id})=>id===columnId2))return;const next=new Map(this.columnPinning);next.set(columnId2,side),this.columnPinning=next}async reload(){const owner=this.ownerDocument.defaultView;!this.isConnected||!owner||!this.usesServerData||(this.cancelRequestTimer(),await this.loadServerData(owner))}resetColumns(){this.columnOrder=[],this.columnWidths=new Map,this.columnVisibility=new Map,this.columnPinning=new Map}resetState(){this.resetColumns(),this.sort=[],this.filters=[],this.searchTerm="",this.expandedKeys=[]}scrollToIndex(index,options={}){const rows=this.getVisibleRows();if(rows.length===0)return;const requestedIndex=finiteInteger(index,0,0,rows.length-1),requestedRow=rows[requestedIndex],sourceIndexes=this.sourceIndexMap(),sourceIndex=this.sourceIndexFor(requestedRow,sourceIndexes),requestedKey=this.keyForRow(requestedRow,sourceIndex??requestedIndex),target=this.displayItems.findIndex(item=>item.kind==="row"&&(item.row===requestedRow||keysEqual(item.key,requestedKey)));if(target<0)return;const rendered=this.renderRoot?.querySelector(`[part~="row"][data-visible-index="${target}"]`);if(rendered){rendered.scrollIntoView({block:options.align??"nearest"});return}const body=this.bodyElement;if(!body)return;const rowHeight=this.resolvedRowHeight;let top=target*rowHeight;options.align==="center"?top-=(body.clientHeight-rowHeight)/2:options.align==="end"&&(top-=body.clientHeight-rowHeight),body.scrollTo({top:Math.max(0,top)})}setState(state2){const known=new Set(this.columns.map((column,index)=>columnId(column,index)));state2.order&&(this.columnOrder=state2.order.filter(id=>known.has(id))),state2.widths&&(this.columnWidths=this.validColumnMap(state2.widths,known,width=>finiteRange(width,0,0))),state2.visibility&&(this.columnVisibility=this.validColumnMap(state2.visibility,known,Boolean)),state2.pinning&&(this.columnPinning=this.validColumnMap(state2.pinning,known,side=>side==="left"||side==="right"||side==="start"||side==="end"?side:!1)),state2.sort&&(this.sort=state2.sort.filter(item=>known.has(item.id)).map(item=>({id:item.id,desc:!!item.desc}))),state2.filters&&(this.filters=state2.filters.filter(item=>known.has(item.id)).map(item=>({...item}))),state2.search!==void 0&&(this.searchTerm=state2.search);const selectedRowKeys=state2.selectedRowKeys??state2.selectedKeys,expandedRowKeys=state2.expandedRowKeys??state2.expandedKeys;selectedRowKeys&&(this.selectedRowKeys=selectedRowKeys),expandedRowKeys&&(this.expandedRowKeys=expandedRowKeys),state2.page!==void 0&&(this.page=finiteCount(state2.page)),state2.pageSize!==void 0&&(this.pageSize=finiteCount(state2.pageSize))}sizeColumnsToFit(){const body=this.bodyElement;if(!body||this.visibleColumns.length===0)return;const selectionWidth=this.selectionEnabled?resolveCssLength(this.computedToken("--lr-icon-button-size"),{host:this})??0:0,available=Math.max(0,body.clientWidth-selectionWidth),flexible=this.visibleColumns.filter(({column})=>column.flex!==0);if(flexible.length===0)return;const totalFlex=flexible.reduce((sum,{column})=>sum+finiteRange(column.flex??1,1,0),0)||flexible.length,next=new Map(this.columnWidths);for(const{column,id}of flexible){const share=available*(finiteRange(column.flex??1,1,0)/totalFlex),{minimum,maximum}=this.columnBounds(column);next.set(id,finiteRange(share,minimum,minimum,maximum))}this.columnWidths=next}toggleColumn(columnId2,visible){if(!this.orderedColumns.some(({id})=>id===columnId2))return;const next=new Map(this.columnVisibility);next.set(columnId2,visible),this.columnVisibility=next,this.focusedColumn=finiteInteger(this.focusedColumn,0,0,Math.max(0,this.visibleColumns.length-1))}validColumnMap(record,known,convert){const result=new Map;for(const[id,value]of Object.entries(record))known.has(id)&&result.set(id,convert(value));return result}delimitedRows(rows,options){const active=this.visibleColumns.map(({column,id})=>({...column,id,value:row=>{const raw=columnValue(column,row),formatted=column.formatter?.(raw,row);return typeof formatted=="string"?formatted:raw},hidden:!1}));return rowsAsDelimited(rows,active,options)}async copyAndReport(text){const owner=this.isConnected?this.ownerDocument.defaultView:null,outcome=await this.writeClipboard(text,owner);if(!(!owner||!this.isConnected||this.ownerDocument.defaultView!==owner)){if(outcome.ok){this.isMounting||this.announce(this.localize("copied")),this.emit("lr-copy",outcome);return}this.isMounting||this.announce(this.localize("copyFailed")),this.emit("lr-error"),this.emit("lr-copy-error",outcome)}}async writeClipboard(text,owner){const ownerDocument=this.ownerDocument,outcome=await writeClipboardText(owner,text);if(outcome.ok||!owner||ownerDocument.defaultView!==owner||!ownerDocument.body)return outcome;const textarea=ownerDocument.createElement("textarea");textarea.value=text,textarea.style.position="fixed",textarea.style.opacity="0",ownerDocument.body.append(textarea);try{if(textarea.select(),ownerDocument.execCommand?.("copy"))return Object.freeze({ok:!0,text})}finally{textarea.remove()}return outcome}setColumnWidth(columnIdValue,width,emit,finished=!0){const entry=this.orderedColumns.find(({id})=>id===columnIdValue);if(!entry)return;const{minimum,maximum}=this.columnBounds(entry.column),safeWidth=finiteRange(width,minimum,minimum,maximum),next=new Map(this.columnWidths);next.set(columnIdValue,safeWidth),this.columnWidths=next,emit&&this.emit("lr-column-resize",Object.freeze({columnId:columnIdValue,width:safeWidth,finished}))}cancelRequestTimer(){const timer=this.requestTimer;this.requestTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}scheduleServerRequest(delayed){const owner=this.ownerDocument.defaultView;if(!this.isConnected||!owner||!this.usesServerData)return;this.cancelRequestTimer();const delay=delayed?finiteDuration(this.filterDebounce,250):0;let handle=0;handle=owner.setTimeout(()=>{this.requestTimer?.owner!==owner||this.requestTimer.handle!==handle||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.requestTimer=void 0,this.loadServerData(owner))},delay),this.requestTimer={owner,handle}}async loadServerData(owner){if(!this.isConnected||this.ownerDocument.defaultView!==owner||!this.usesServerData)return;this.requestController?.abort();const AbortControllerCtor=owner.AbortController;this.requestController=typeof AbortControllerCtor=="function"?new AbortControllerCtor:void 0;const generation=++this.requestGeneration,request=Object.freeze({sort:frozenArray(this.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(this.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)}))),search:this.searchTerm,page:this.safePage,pageSize:this.safePageSize,signal:this.requestController?.signal}),requestDetail=()=>Object.freeze({...request,sort:frozenArray(request.sort.map(item=>Object.freeze({...item}))),filters:frozenArray(request.filters.map(item=>Object.freeze({id:item.id,value:serializableFilterValue(item.value)})))});if(this.emit("request",requestDetail()),!!this.dataSource){this.ownsLoadingState=!0,this.loading=!0;try{const response=await this.dataSource(request);if(generation!==this.requestGeneration||request.signal?.aborted||!this.isConnected||this.ownerDocument.defaultView!==owner)return;this.data=Array.isArray(response.rows)?response.rows:[],this.total=finiteCount(response.total),this.loading=!1,this.ownsLoadingState=!1}catch(error){if(generation!==this.requestGeneration||request.signal?.aborted||!this.isConnected||this.ownerDocument.defaultView!==owner)return;this.loading=!1,this.ownsLoadingState=!1,this.emit("lr-data-error",Object.freeze({error,request:requestDetail()}))}}}get selectionMode(){return this.selectable===""||this.selectable==="multiple"?"multiple":this.selectable}get selectionEnabled(){return this.selectionMode!=="none"}rowIsSelectable(row){return this.selectionEnabled&&(this.selectableRows?.(row)??!0)}rowMatches(row){return filterRows([row],this.columns,this.filters,this.effectiveLocale).length>0&&searchRows([row],this.columns,this.searchTerm,this.effectiveLocale,this.searchFn).length>0}processedChildrenFor(row){const children=this.canonicalMembers(this.childrenFor(row));if(children.length===0||this.usesServerData)return children;const included=children.filter(child=>this.rowMatches(child)?!0:this.filterFromLeafRows&&this.hasMatchingDescendant(child));return sortRows(included,this.columns,this.sort,this.effectiveLocale)}hasMatchingDescendant(row){const stack=this.canonicalMembers(this.childrenFor(row)).map(child=>({row:child,depth:1})),visited=new Set;let inspected=0;for(;stack.length>0&&inspected<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(!(trackIdentity&&visited.has(current.row))){if(trackIdentity&&visited.add(current.row),inspected+=1,this.rowMatches(current.row))return!0;if(!(current.depth>=DATA_GRID_TREE_DEPTH_LIMIT))for(const child of this.canonicalMembers(this.childrenFor(current.row)))stack.push({row:child,depth:current.depth+1})}}return!1}get pageRows(){return this.getVisibleRows()}get currentPageSelectableRows(){const result=[],sourceIndex=new Map(this.allSourceRows.map((row,index)=>[row,index])),visited=new Set,stack=[...this.pageRows].reverse().map(row=>({row,depth:0}));let inspected=0;for(;stack.length>0&&inspected<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row),inspected+=1;const index=this.sourceIndexFor(current.row,sourceIndex);if(index===void 0)continue;const key=this.keyForRow(current.row,index);if(this.rowIsSelectable(current.row)&&result.push({row:current.row,key}),current.depth>=DATA_GRID_TREE_DEPTH_LIMIT)continue;const children=this.canonicalMembers(this.childrenFor(current.row));for(let childIndex=children.length-1;childIndex>=0;childIndex-=1){const child=children[childIndex];stack.push({row:child,depth:current.depth+1})}}return result}groupKey(parent,id,value){return`group:${parent}:${id}:${typeof value}:${safeText(value)}`}topLevelGroupBuckets(rows){const field=normalizedGroupBy(this.groupBy)[0];if(!field)return[];const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return[];const buckets=new Map;for(const row of rows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}return[...buckets].map(([value,bucketRows])=>({value,rows:bucketRows}))}groupItems(rows){const fields=normalizedGroupBy(this.groupBy);if(fields.length===0||this.usesServerData)return[];const result=[],visit=(groupRows,depth,parent)=>{const field=fields[depth];if(!field)return;const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return;const buckets=new Map;for(const row of groupRows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}for(const[value,bucket]of buckets){const key=this.groupKey(parent,entry.id,value);result.push({kind:"group",key,value,columnId:entry.id,rows:bucket,depth}),depth+1<fields.length&&visit(bucket,depth+1,key)}};return visit(rows,0,"root"),result}get displayItems(){const groups=normalizedGroupBy(this.groupBy);if(groups.length>0&&!this.usesServerData)return this.groupedDisplayItems(this.pageRows,groups,0,"root",this.sourceIndexMap());const result=[],sourceRows=this.allSourceRows,indexes=this.sourceIndexMap(sourceRows),visited=new Set,stack=[...this.pageRows].reverse().map(row=>({row,depth:0}));for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row))continue;trackIdentity&&visited.add(current.row);const sourceIndex=this.sourceIndexFor(current.row,indexes);if(sourceIndex===void 0)continue;const safeIndex=sourceIndex,key=this.keyForRow(current.row,safeIndex);if(result.push({kind:"row",row:current.row,key,depth:current.depth,sourceIndex:safeIndex}),!arrayHasKey(this.expandedKeys,key)||current.depth>=DATA_GRID_TREE_DEPTH_LIMIT)continue;const children=this.processedChildrenFor(current.row);for(let index=children.length-1;index>=0;index-=1)stack.push({row:children[index],depth:current.depth+1})}return result}groupedDisplayItems(rows,fields,depth,parent,sourceIndexes){const field=fields[depth];if(!field)return[];const entry=this.orderedColumns.find(({id,column})=>id===field||column.field===field);if(!entry)return rows.map((row,index)=>({kind:"row",row,key:this.keyForRow(row,this.sourceIndexFor(row,sourceIndexes)??index),depth,sourceIndex:this.sourceIndexFor(row,sourceIndexes)??index}));const buckets=new Map;for(const row of rows){const value=columnValue(entry.column,row),bucket=buckets.get(value)??[];bucket.push(row),buckets.set(value,bucket)}const result=[];for(const[value,bucket]of buckets){const key=this.groupKey(parent,entry.id,value);if(result.push({kind:"group",key,value,columnId:entry.id,rows:bucket,depth}),!!arrayHasKey(this.expandedKeys,key))if(depth+1<fields.length)result.push(...this.groupedDisplayItems(bucket,fields,depth+1,key,sourceIndexes));else for(const row of bucket){const sourceIndex=this.sourceIndexFor(row,sourceIndexes);result.push({kind:"row",row,key:this.keyForRow(row,sourceIndex??result.length),depth:depth+1,sourceIndex:sourceIndex??result.length})}}return result}get resolvedRowHeight(){const raw=this.computedToken("--row-height","--_lr-data-grid-row-height");return finiteRange(resolveCssLength(raw,{host:this})??56,56,1)}get virtualWindow(){const items=this.displayItems,expandedDetails=!!(this.rowDetail&&items.some(item=>item.kind==="row"&&arrayHasKey(this.expandedKeys,item.key)));if(items.length<VIRTUALIZATION_THRESHOLD||expandedDetails||this.computedToken("--max-height","--_lr-data-grid-max-height")==="none")return{items,start:0,end:items.length};const height=this.resolvedRowHeight,visibleCount=Math.max(1,Math.ceil((this.viewportHeight||height*10)/height)),start=Math.min(Math.max(0,items.length-visibleCount),Math.max(0,Math.floor(this.bodyScrollTop/height)-VIRTUAL_OVERSCAN)),end=Math.min(items.length,start+visibleCount+VIRTUAL_OVERSCAN*2);return{items:items.slice(start,end),start,end}}get gridTemplate(){const columns=this.visibleColumns.map(({column,id})=>{const bounds=this.columnBounds(column),width=this.columnWidths.get(id)??column.width;if(width!==void 0&&Number.isFinite(width)&&width>0)return`${finiteRange(width,bounds.minimum,bounds.minimum,bounds.maximum)}px`;const minimum=bounds.minimum>0?`${bounds.minimum}px`:Number.isFinite(column.maxWidth)&&(column.maxWidth??0)>0?"0px":"var(--lr-size-7rem)",maximum=Number.isFinite(column.maxWidth)&&(column.maxWidth??0)>0?`${bounds.maximum}px`:`${finiteRange(column.flex??1,1,0)}fr`;return`minmax(${minimum}, ${maximum})`});return this.selectionEnabled&&columns.unshift("var(--lr-icon-button-size)"),columns.length>0?columns.join(" "):"minmax(var(--lr-size-7rem), 1fr)"}columnStyle(column,id){const side=normalizePinSide(this.getColumnPin(id)),pinOffset=side?this.pinOffset(id,side):0;return{...side?{"--pin-offset":`${pinOffset}px`}:{},...Number.isFinite(column.width)&&(column.width??0)>0&&!this.columnWidths.has(id)?{"--column-authored-width":`${column.width}px`}:{}}}estimatedColumnWidth(column,id){const{minimum,maximum}=this.columnBounds(column),explicit=this.columnWidths.get(id)??column.width;if(explicit!==void 0)return finiteRange(explicit,Math.max(112,minimum),minimum,maximum);const raw=this.computedToken("--lr-size-7rem");return finiteRange(resolveCssLength(raw,{host:this})??112,Math.max(112,minimum),minimum,maximum)}columnBounds(column){const minimum=finiteRange(column.minWidth??0,0,0),authoredMaximum=finiteRange(column.maxWidth??Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0);return Object.freeze({minimum,maximum:Math.max(minimum,authoredMaximum)})}pinOffset(id,side){const entries=this.visibleColumns,index=entries.findIndex(entry=>entry.id===id);return index<0?0:(side==="left"?entries.slice(0,index):entries.slice(index+1)).filter(entry=>normalizePinSide(this.getColumnPin(entry.id))===side).reduce((sum,entry)=>sum+this.estimatedColumnWidth(entry.column,entry.id),0)}columnLabel(column,id){return column.label??humanizeIdentifier(column.field??id,this.effectiveLocale)}columnIsSortable(column){return column.sortable!==!1&&!!(column.field||column.value)}sortFor(id){const index=this.sort.findIndex(item=>item.id===id);return{state:index>=0?this.sort[index]:void 0,index}}activateSort(id,additive){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnIsSortable(entry.column))return;const existing=this.sortFor(id).state,descendingFirst=entry.column.sortDescFirst??this.sortDescFirst;let replacement;existing?existing.desc===descendingFirst?replacement={id,desc:!descendingFirst}:this.withoutSortRemoval&&(replacement={id,desc:descendingFirst}):replacement={id,desc:descendingFirst};let next=additive?this.sort.filter(item=>item.id!==id):[];replacement&&next.push(replacement);const limit=finiteCount(this.maxMultiSort);limit>0&&next.length>limit&&(next=next.slice(next.length-limit)),this.sort=next,this.page=0,this.emit("lr-sort-change",Object.freeze({sort:frozenArray(this.sort.map(item=>Object.freeze({...item})))}))}onHeaderClick(event,id){const target=event.target,interactive=isElementValue(target)?target.closest(INTERACTIVE_SELECTOR):null;interactive&&interactive!==event.currentTarget||this.activateSort(id,event.shiftKey)}onFilterInput(event,id){const control=valueControl(event.currentTarget);if(!control)return;const value=control.value,next=this.filters.filter(filter=>filter.id!==id);value&&next.push({id,value}),this.filters=next,this.page=0,this.emit("lr-filter-change",Object.freeze({filters:frozenArray(next.map(filter=>Object.freeze({...filter})))}))}onBodyScroll(event){const target=event.currentTarget;!isElementValue(target)||typeof target.scrollTop!="number"||typeof target.clientHeight!="number"||(this.bodyScrollTop=target.scrollTop,this.viewportHeight=target.clientHeight)}onCellClick(event,item,column,columnIdValue,index){const target=event.target,interactive=isElementValue(target)?target.closest(INTERACTIVE_SELECTOR):null;interactive&&interactive!==event.currentTarget&&isElementValue(event.currentTarget)&&event.currentTarget.contains(interactive)||this.emit("lr-cell-click",Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index}))}emitCellContextMenu(originalEvent,item,column,columnIdValue,index){const detail=Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index,originalEvent});this.emit("lr-cell-contextmenu",detail,{cancelable:!0}).defaultPrevented&&originalEvent.preventDefault()}descendantRows(row){const result=[],visited=new Set,stack=this.canonicalMembers(this.childrenFor(row)).reverse().map(child=>({row:child,depth:1}));for(;stack.length>0&&result.length<DATA_GRID_TREE_NODE_LIMIT;){const current=stack.pop(),trackIdentity=typeof current.row=="object"&¤t.row!==null||typeof current.row=="function";if(trackIdentity&&visited.has(current.row)||(trackIdentity&&visited.add(current.row),result.push(current.row),current.depth>=DATA_GRID_TREE_DEPTH_LIMIT))continue;const children=this.canonicalMembers(this.childrenFor(current.row));for(let index=children.length-1;index>=0;index-=1){const child=children[index];stack.push({row:child,depth:current.depth+1})}}return result}setRowSelected(item,selected,event){if(!this.rowIsSelectable(item.row))return;const selectableItems=this.displayItems.filter(candidate=>candidate.kind==="row"&&this.rowIsSelectable(candidate.row)),position=selectableItems.findIndex(candidate=>keysEqual(candidate.key,item.key));let affected=[item];if(event?.shiftKey&&this.selectionMode==="multiple"&&this.lastSelectedIndex>=0){const from=Math.min(this.lastSelectedIndex,position),to=Math.max(this.lastSelectedIndex,position);affected=selectableItems.slice(from,to+1)}const descendants=this.selectionMode==="multiple"?affected.flatMap(candidate=>this.descendantRows(candidate.row)).filter(row=>this.rowIsSelectable(row)):[],sourceIndexes=this.sourceIndexMap(),keys=[...affected.map(candidate=>candidate.key),...descendants.map((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return this.keyForRow(row,sourceIndex??index)})];let next=this.selectionMode==="single"?[]:[...this.selectedKeys];for(const key of keys)next=next.filter(candidate=>!keysEqual(candidate,key)),selected&&next.push(key);this.selectedKeys=next,this.lastSelectedIndex=position,this.emitSelection()}selectCurrentPage(selected){const pageKeys=this.currentPageSelectableRows.map(item=>item.key);let next=this.selectedKeys.filter(key=>!pageKeys.some(pageKey=>keysEqual(pageKey,key)));selected&&(next=[...next,...pageKeys]),this.selectedKeys=next,this.emitSelection()}emitSelection(){const selectedRowKeys=frozenArray(this.selectedRowKeys),selectedRows=frozenArray(this.selectedRows);this.emit("lr-row-select",Object.freeze({selectedRowKeys,selectedKeys:selectedRowKeys,selectedRows}))}rowSelectionState(item){const own=arrayHasKey(this.selectedKeys,item.key),descendants=this.descendantRows(item.row).filter(row=>this.rowIsSelectable(row));if(descendants.length===0)return{checked:own,indeterminate:!1};const sourceIndexes=this.sourceIndexMap(),selected=descendants.filter((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return arrayHasKey(this.selectedKeys,this.keyForRow(row,sourceIndex??index))}).length,checked=own&&selected===descendants.length;return{checked,indeterminate:!checked&&(own||selected>0)}}toggleRowExpanded(item,emitUserEvent){const expanded=arrayHasKey(this.expandedKeys,item.key);expanded?this.collapseRow(item.key):this.expandRow(item.key),emitUserEvent&&this.emit(expanded?"lr-row-collapse":"lr-row-expand",Object.freeze({rowKey:item.key,key:item.key,row:item.row}))}toggleGroupExpanded(item){const expanded=arrayHasKey(this.expandedKeys,item.key);expanded?this.collapseRow(item.key):this.expandRow(item.key);const detail=Object.freeze({key:item.key,columnId:item.columnId,value:item.value,rows:frozenArray(item.rows)});this.emit(expanded?"lr-group-collapse":"lr-group-expand",detail)}moveColumn(id,delta,emitUserEvent){const order=this.orderedColumns.map(entry=>entry.id),from=order.indexOf(id);if(from<0)return;const to=finiteInteger(from+delta,from,0,order.length-1);from!==to&&(order.splice(from,1),order.splice(to,0,id),this.columnOrder=order,emitUserEvent&&this.emit("lr-column-move",Object.freeze({columnOrder:frozenArray(order),columnId:id,finished:!0})))}columnCanMove(id){const entry=this.orderedColumns.find(item=>item.id===id);return!!(entry&&(this.reorderable||entry.column.movable))}columnCanResize(id){const entry=this.orderedColumns.find(item=>item.id===id);return!!(entry&&(this.resizable||entry.column.resizable))}onDragStart(event,id){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanMove(id)||!event.dataTransfer){event.preventDefault();return}const token=`${++this.columnDragSequence}:${id}`;this.columnDragSession=Object.freeze({sourceId:id,token}),event.dataTransfer.setData(DATA_GRID_DRAG_TYPE,token),event.dataTransfer.setData("text/plain",id),event.dataTransfer.effectAllowed="move",this.dragGhost=this.columnLabel(entry.column,id)}onDrop(event,targetId){event.preventDefault();const session=this.columnDragSession,token=event.dataTransfer?.getData(DATA_GRID_DRAG_TYPE),sourceId=session?.sourceId;if(this.columnDragSession=void 0,this.dragGhost="",!session||token!==session.token||!sourceId||sourceId===targetId||!this.columnCanMove(sourceId)||!this.columnCanMove(targetId))return;const order=this.orderedColumns.map(entry=>entry.id),source=order.indexOf(sourceId),target=order.indexOf(targetId);source<0||target<0||(order.splice(source,1),order.splice(target,0,sourceId),this.columnOrder=order,this.emit("lr-column-move",Object.freeze({columnOrder:frozenArray(order),columnId:sourceId,finished:!0})))}onResizeStart(event,id){const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanResize(id))return;const header=this.renderedColumnElements(id,"columnheader")[0];this.resizeSession={columnId:id,startClientX:event.clientX,startWidth:header?.getBoundingClientRect().width??this.estimatedColumnWidth(entry.column,id),initialStateWidth:this.columnWidths.get(id),pointerId:event.pointerId,moved:!1,direction:this.effectiveDirection};try{event.currentTarget.setPointerCapture?.(event.pointerId)}catch{}event.preventDefault()}onResizeMove(event){const session=this.resizeSession;if(!session||event.pointerId!==session.pointerId)return;if(!this.columnCanResize(session.columnId)){this.resizeSession=void 0,session.moved&&this.restoreResizeSession(session,!0);return}const direction=session.direction==="rtl"?-1:1;this.setColumnWidth(session.columnId,session.startWidth+(event.clientX-session.startClientX)*direction,!0,!1),session.moved=!0}takeResizeSession(event){const session=this.resizeSession;if(!(!session||event.pointerId!==session.pointerId)){this.resizeSession=void 0;try{event.currentTarget.releasePointerCapture?.(event.pointerId)}catch{}return session}}restoreResizeSession(session,emit){const next=new Map(this.columnWidths);session.initialStateWidth===void 0?next.delete(session.columnId):next.set(session.columnId,session.initialStateWidth),this.columnWidths=next,emit&&this.emit("lr-column-resize",Object.freeze({columnId:session.columnId,width:session.startWidth,finished:!1}))}onResizeEnd(event){const session=this.takeResizeSession(event);if(!session)return;if(!this.columnCanResize(session.columnId)){session.moved&&this.restoreResizeSession(session,!0);return}const width=this.columnWidths.get(session.columnId)??session.startWidth;this.emit("lr-column-resize",Object.freeze({columnId:session.columnId,width,finished:!0}))}onResizeCancel(event){const session=this.takeResizeSession(event);!session||!session.moved||this.restoreResizeSession(session,!0)}onResizeKey(event,id){if(event.key!=="ArrowLeft"&&event.key!=="ArrowRight")return;const entry=this.orderedColumns.find(item=>item.id===id);if(!entry||!this.columnCanResize(id))return;const logical=(event.key==="ArrowRight"?1:-1)*(this.effectiveDirection==="rtl"?-1:1),current=this.columnWidths.get(id)??this.estimatedColumnWidth(entry.column,id);this.setColumnWidth(id,current+logical*10,!0,!0),event.preventDefault()}onPageSizeChange(event){const control=valueControl(event.currentTarget);control&&(this.pageSize=finiteCount(Number(control.value)),this.page=0,this.emit("lr-page-change",Object.freeze({page:0,pageSize:this.safePageSize})))}focusCell(row,column){const rowLimit=Math.max(-1,this.displayItems.length-1),columnLimit=Math.max(0,this.visibleColumns.length-1);this.focusedRow=finiteInteger(row,this.focusedRow,-1,rowLimit),this.focusedColumn=finiteInteger(column,this.focusedColumn,0,columnLimit);let pendingScrollTop;if(this.focusedRow>=0){const selector=`[role="gridcell"][data-row-position="${this.focusedRow}"]`;if(!this.renderRoot.querySelector(selector)){const top=this.focusedRow*this.resolvedRowHeight;pendingScrollTop=top,this.bodyScrollTop=top,this.bodyElement&&(this.bodyElement.scrollTop=top)}}this.updateComplete.then(()=>{pendingScrollTop!==void 0&&this.bodyElement&&(this.bodyElement.scrollTop=pendingScrollTop),this.focus()})}onGridKeyDown(event,rowPosition,columnPosition,item,column,columnIdValue){const target=event.target;if(isElementValue(target)&&target!==event.currentTarget&&target.closest(INTERACTIVE_SELECTOR))return;const rtlMultiplier=this.effectiveDirection==="rtl"?-1:1;if(event.ctrlKey&&event.key.toLowerCase()==="a"&&this.selectionMode==="multiple"){this.selectCurrentPage(!0),event.preventDefault();return}if(event.ctrlKey&&event.key.toLowerCase()==="c"){this.copySelectedRows(),event.preventDefault();return}if(event.shiftKey&&event.key==="F10"&&item&&column&&columnIdValue){this.emitCellContextMenu(event,item,column,columnIdValue,rowPosition);return}const headerEntry=columnIdValue?this.orderedColumns.find(entry=>entry.id===columnIdValue):void 0;if(rowPosition<0&&columnIdValue&&headerEntry&&(this.reorderable||headerEntry.column.movable)&&event.shiftKey&&!event.altKey&&(event.key==="ArrowLeft"||event.key==="ArrowRight")){const delta=(event.key==="ArrowRight"?1:-1)*rtlMultiplier;this.moveColumn(columnIdValue,delta,!0),event.preventDefault();return}if(!(rowPosition<0&&columnIdValue&&headerEntry&&(this.resizable||headerEntry.column.resizable)&&event.altKey&&(this.onResizeKey(event,columnIdValue),event.defaultPrevented))){if(event.key==="ArrowLeft"||event.key==="ArrowRight"){const delta=(event.key==="ArrowRight"?1:-1)*rtlMultiplier;this.focusCell(rowPosition,columnPosition+delta),event.preventDefault()}else if(event.key==="ArrowUp")this.focusCell(rowPosition-1,columnPosition),event.preventDefault();else if(event.key==="ArrowDown")this.focusCell(rowPosition+1,columnPosition),event.preventDefault();else if(event.key==="Home")this.focusCell(event.ctrlKey?-1:rowPosition,0),event.preventDefault();else if(event.key==="End")this.focusCell(event.ctrlKey?this.displayItems.length-1:rowPosition,this.visibleColumns.length-1),event.preventDefault();else if(event.key==="PageUp"||event.key==="PageDown"){const delta=event.key==="PageDown"?this.safePageSize||10:-(this.safePageSize||10);this.focusCell(rowPosition+delta,columnPosition),event.preventDefault()}else if(event.key==="Enter")rowPosition<0&&columnIdValue?this.activateSort(columnIdValue,event.shiftKey):item&&column&&columnIdValue&&this.emit("lr-cell-click",Object.freeze({rowKey:item.key,columnId:columnIdValue,column,value:columnValue(column,item.row),row:item.row,index:rowPosition})),event.preventDefault();else if(event.key===" "&&item){const selected=!arrayHasKey(this.selectedKeys,item.key);this.setRowSelected(item,selected,event),event.preventDefault()}}}setGroupSelected(group,selected){const eligible=group.rows.filter(row=>this.rowIsSelectable(row)),sourceIndexes=this.sourceIndexMap(),groupKeys=eligible.map((row,index)=>{const sourceIndex=this.sourceIndexFor(row,sourceIndexes);return this.keyForRow(row,sourceIndex??index)});let next=this.selectedKeys.filter(key=>!groupKeys.some(groupKey=>keysEqual(groupKey,key)));selected&&(next=[...next,...groupKeys]),this.selectedKeys=next,this.emitSelection()}userPinColumn(id,side){this.pinColumn(id,side),this.emit("lr-column-pin",Object.freeze({columnId:id,side}))}userToggleColumn(id,visible){this.toggleColumn(id,visible),this.emit("lr-column-visibility-change",Object.freeze({columnId:id,visible}))}renderToolbar(){return!this.withSearch&&!this.withColumnsMenu?nothing:html`
|
|
2
2
|
<div part="toolbar">
|
|
3
3
|
${this.withSearch?html`
|
|
4
4
|
<input
|
|
@@ -128,7 +128,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
128
128
|
part="header-cell"
|
|
129
129
|
role="columnheader"
|
|
130
130
|
aria-colindex=${position+1+selectionOffset}
|
|
131
|
-
aria-sort=${sorting.state?direction:nothing}
|
|
131
|
+
aria-sort=${sortable?sorting.state?direction:"none":nothing}
|
|
132
132
|
tabindex=${this.focusedRow<0&&this.focusedColumn===position?"0":"-1"}
|
|
133
133
|
data-focus-cell
|
|
134
134
|
data-column-id=${id}
|
|
@@ -457,7 +457,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
|
|
|
457
457
|
>
|
|
458
458
|
</button>
|
|
459
459
|
</nav>
|
|
460
|
-
`}render(){const accessibleName=this
|
|
460
|
+
`}render(){const accessibleName=hostAriaLabel(this)??(this.label||void 0),detailCount=this.rowDetail?this.displayItems.filter(item=>item.kind==="row"&&arrayHasKey(this.expandedKeys,item.key)).length:0,rowCount=Math.max(1,this.displayItems.length+detailCount)+1,columnCount=Math.max(1,this.visibleColumns.length+(this.selectionEnabled?1:0)),role=this.childRows||normalizedGroupBy(this.groupBy).length>0?"treegrid":"grid",treeProjection=this.sourceProjection();return html`
|
|
461
461
|
<div part="data-grid">
|
|
462
462
|
${this.renderToolbar()}
|
|
463
463
|
<div
|