@aceshooting/lyra-ui 1.2.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -14
- package/custom-elements.json +30279 -12124
- package/dist/components/app-rail/app-rail-item.d.ts +30 -0
- package/dist/components/app-rail/app-rail-item.js +68 -0
- package/dist/components/app-rail/app-rail-item.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail-item.styles.js +65 -0
- package/dist/components/app-rail/app-rail.d.ts +168 -0
- package/dist/components/app-rail/app-rail.js +419 -0
- package/dist/components/app-rail/app-rail.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail.styles.js +128 -0
- package/dist/components/attachment-chip/attachment-chip.d.ts +141 -0
- package/dist/components/attachment-chip/attachment-chip.js +356 -0
- package/dist/components/attachment-chip/attachment-chip.styles.d.ts +1 -0
- package/dist/components/attachment-chip/attachment-chip.styles.js +184 -0
- package/dist/components/attachment-trigger/attachment-trigger.d.ts +96 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +270 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.d.ts +1 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +90 -0
- package/dist/components/chart/bar-chart.js +2 -18
- package/dist/components/chart/box-plot.d.ts +25 -1
- package/dist/components/chart/box-plot.js +147 -7
- package/dist/components/chart/box-plot.styles.js +13 -0
- package/dist/components/chart/bubble-chart.js +2 -18
- package/dist/components/chart/chart-loader.d.ts +44 -13
- package/dist/components/chart/chart-loader.js +65 -18
- package/dist/components/chart/chart.d.ts +55 -12
- package/dist/components/chart/chart.js +247 -49
- package/dist/components/chart/doughnut-chart.js +2 -18
- package/dist/components/chart/histogram-bin.d.ts +7 -1
- package/dist/components/chart/histogram-bin.js +32 -14
- package/dist/components/chart/histogram.js +8 -16
- package/dist/components/chart/line-chart.js +2 -18
- package/dist/components/chart/lite-chart.d.ts +134 -3
- package/dist/components/chart/lite-chart.js +382 -67
- package/dist/components/chart/lite-chart.styles.js +9 -0
- package/dist/components/chart/pie-chart.js +2 -18
- package/dist/components/chart/polar-area-chart.js +2 -18
- package/dist/components/chart/radar-chart.js +2 -18
- package/dist/components/chart/scatter-chart.js +2 -18
- package/dist/components/chat-composer/chat-composer.d.ts +133 -0
- package/dist/components/chat-composer/chat-composer.js +366 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +1 -0
- package/dist/components/chat-composer/chat-composer.styles.js +145 -0
- package/dist/components/chat-message/chat-message.d.ts +141 -0
- package/dist/components/chat-message/chat-message.js +331 -0
- package/dist/components/chat-message/chat-message.styles.d.ts +1 -0
- package/dist/components/chat-message/chat-message.styles.js +203 -0
- package/dist/components/checkbox/checkbox.d.ts +117 -0
- package/dist/components/checkbox/checkbox.js +353 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.styles.js +77 -0
- package/dist/components/chip/chip-group.d.ts +56 -0
- package/dist/components/chip/chip-group.js +130 -0
- package/dist/components/chip/chip-group.styles.d.ts +1 -0
- package/dist/components/chip/chip-group.styles.js +57 -0
- package/dist/components/chip/chip.d.ts +64 -0
- package/dist/components/chip/chip.js +122 -0
- package/dist/components/chip/chip.styles.d.ts +1 -0
- package/dist/components/chip/chip.styles.js +115 -0
- package/dist/components/citation-badge/citation-badge.d.ts +113 -0
- package/dist/components/citation-badge/citation-badge.js +318 -0
- package/dist/components/citation-badge/citation-badge.styles.d.ts +1 -0
- package/dist/components/citation-badge/citation-badge.styles.js +96 -0
- package/dist/components/code-block/code-block.d.ts +127 -0
- package/dist/components/code-block/code-block.js +382 -0
- package/dist/components/code-block/code-block.styles.d.ts +1 -0
- package/dist/components/code-block/code-block.styles.js +187 -0
- package/dist/components/code-block/code-loader.d.ts +87 -0
- package/dist/components/code-block/code-loader.js +142 -0
- package/dist/components/combobox/combobox.d.ts +65 -6
- package/dist/components/combobox/combobox.js +258 -48
- package/dist/components/combobox/combobox.styles.js +3 -3
- package/dist/components/combobox/option.d.ts +5 -1
- package/dist/components/combobox/option.js +35 -0
- package/dist/components/context-meter/context-meter.d.ts +53 -0
- package/dist/components/context-meter/context-meter.js +159 -0
- package/dist/components/context-meter/context-meter.styles.d.ts +1 -0
- package/dist/components/context-meter/context-meter.styles.js +114 -0
- package/dist/components/conversation-item/conversation-item.d.ts +125 -0
- package/dist/components/conversation-item/conversation-item.js +331 -0
- package/dist/components/conversation-item/conversation-item.styles.d.ts +1 -0
- package/dist/components/conversation-item/conversation-item.styles.js +155 -0
- package/dist/components/date-picker/calendar-core.d.ts +24 -0
- package/dist/components/date-picker/calendar-core.js +51 -4
- package/dist/components/date-picker/date-input.d.ts +100 -9
- package/dist/components/date-picker/date-input.js +383 -66
- package/dist/components/date-picker/date-picker.d.ts +35 -4
- package/dist/components/date-picker/date-picker.js +171 -44
- package/dist/components/dialog/confirm.d.ts +40 -0
- package/dist/components/dialog/confirm.js +76 -0
- package/dist/components/dialog/dialog.d.ts +129 -0
- package/dist/components/dialog/dialog.js +288 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +96 -0
- package/dist/components/dock-panel/dock-panel.d.ts +142 -0
- package/dist/components/dock-panel/dock-panel.js +359 -0
- package/dist/components/dock-panel/dock-panel.styles.d.ts +1 -0
- package/dist/components/dock-panel/dock-panel.styles.js +159 -0
- package/dist/components/document-preview/document-preview.d.ts +143 -0
- package/dist/components/document-preview/document-preview.js +388 -0
- package/dist/components/document-preview/document-preview.styles.d.ts +1 -0
- package/dist/components/document-preview/document-preview.styles.js +191 -0
- package/dist/components/empty/empty.d.ts +1 -2
- package/dist/components/empty/empty.js +18 -12
- package/dist/components/empty/empty.styles.js +0 -3
- package/dist/components/export-button/csv.js +1 -1
- package/dist/components/export-button/export-button.d.ts +12 -0
- package/dist/components/export-button/export-button.js +35 -5
- package/dist/components/export-button/export-button.styles.js +5 -1
- package/dist/components/file-input/accept.js +2 -0
- package/dist/components/file-input/file-input.d.ts +10 -1
- package/dist/components/file-input/file-input.js +36 -5
- package/dist/components/flag/flag.d.ts +29 -13
- package/dist/components/flag/flag.js +54 -14
- package/dist/components/flag/flag.styles.js +1 -1
- package/dist/components/flag/language-map.d.ts +4 -1
- package/dist/components/flag/language-map.js +6 -3
- package/dist/components/gauge/gauge.d.ts +10 -1
- package/dist/components/gauge/gauge.js +41 -13
- package/dist/components/generation-status/generation-status.d.ts +117 -0
- package/dist/components/generation-status/generation-status.js +327 -0
- package/dist/components/generation-status/generation-status.styles.d.ts +1 -0
- package/dist/components/generation-status/generation-status.styles.js +84 -0
- package/dist/components/graph/graph.d.ts +37 -3
- package/dist/components/graph/graph.js +132 -20
- package/dist/components/heatmap/calendar-grid.d.ts +19 -7
- package/dist/components/heatmap/calendar-grid.js +42 -18
- package/dist/components/heatmap/heatmap-scale.d.ts +11 -1
- package/dist/components/heatmap/heatmap-scale.js +14 -2
- package/dist/components/heatmap/heatmap.d.ts +227 -12
- package/dist/components/heatmap/heatmap.js +488 -93
- package/dist/components/json-viewer/json-viewer.d.ts +70 -0
- package/dist/components/json-viewer/json-viewer.js +361 -0
- package/dist/components/json-viewer/json-viewer.styles.d.ts +1 -0
- package/dist/components/json-viewer/json-viewer.styles.js +177 -0
- package/dist/components/kbd/kbd.d.ts +77 -0
- package/dist/components/kbd/kbd.js +231 -0
- package/dist/components/kbd/kbd.styles.d.ts +1 -0
- package/dist/components/kbd/kbd.styles.js +52 -0
- package/dist/components/live-region/live-region.d.ts +90 -0
- package/dist/components/live-region/live-region.js +189 -0
- package/dist/components/live-region/live-region.styles.d.ts +1 -0
- package/dist/components/live-region/live-region.styles.js +10 -0
- package/dist/components/map/map.d.ts +32 -7
- package/dist/components/map/map.js +133 -32
- package/dist/components/markdown/markdown-loader.d.ts +58 -0
- package/dist/components/markdown/markdown-loader.js +77 -0
- package/dist/components/markdown/markdown.d.ts +119 -0
- package/dist/components/markdown/markdown.js +389 -0
- package/dist/components/markdown/markdown.styles.d.ts +1 -0
- package/dist/components/markdown/markdown.styles.js +88 -0
- package/dist/components/media-card/media-card.d.ts +130 -0
- package/dist/components/media-card/media-card.js +273 -0
- package/dist/components/media-card/media-card.styles.d.ts +1 -0
- package/dist/components/media-card/media-card.styles.js +132 -0
- package/dist/components/mention-popover/mention-popover.d.ts +203 -0
- package/dist/components/mention-popover/mention-popover.js +493 -0
- package/dist/components/mention-popover/mention-popover.styles.d.ts +1 -0
- package/dist/components/mention-popover/mention-popover.styles.js +101 -0
- package/dist/components/menu/menu-item.d.ts +91 -0
- package/dist/components/menu/menu-item.js +206 -0
- package/dist/components/menu/menu-item.styles.d.ts +1 -0
- package/dist/components/menu/menu-item.styles.js +75 -0
- package/dist/components/menu/menu.d.ts +167 -0
- package/dist/components/menu/menu.js +461 -0
- package/dist/components/menu/menu.styles.d.ts +1 -0
- package/dist/components/menu/menu.styles.js +67 -0
- package/dist/components/model-select/model-select.d.ts +170 -0
- package/dist/components/model-select/model-select.js +588 -0
- package/dist/components/model-select/model-select.styles.d.ts +1 -0
- package/dist/components/model-select/model-select.styles.js +203 -0
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +93 -0
- package/dist/components/model-settings-panel/model-settings-panel.js +209 -0
- package/dist/components/model-settings-panel/model-settings-panel.styles.d.ts +1 -0
- package/dist/components/model-settings-panel/model-settings-panel.styles.js +82 -0
- package/dist/components/playback/playback.d.ts +19 -3
- package/dist/components/playback/playback.js +109 -33
- package/dist/components/playback/playback.styles.js +6 -1
- package/dist/components/responsive-panel/responsive-panel.d.ts +163 -0
- package/dist/components/responsive-panel/responsive-panel.js +363 -0
- package/dist/components/responsive-panel/responsive-panel.styles.d.ts +1 -0
- package/dist/components/responsive-panel/responsive-panel.styles.js +103 -0
- package/dist/components/result-card/result-card.d.ts +50 -0
- package/dist/components/result-card/result-card.js +89 -0
- package/dist/components/result-card/result-card.styles.d.ts +1 -0
- package/dist/components/result-card/result-card.styles.js +49 -0
- package/dist/components/result-card/result-field.d.ts +36 -0
- package/dist/components/result-card/result-field.js +87 -0
- package/dist/components/result-card/result-field.styles.d.ts +1 -0
- package/dist/components/result-card/result-field.styles.js +32 -0
- package/dist/components/select/select.d.ts +84 -4
- package/dist/components/select/select.js +251 -36
- package/dist/components/skeleton/skeleton.d.ts +3 -0
- package/dist/components/skeleton/skeleton.js +7 -1
- package/dist/components/skeleton/skeleton.styles.js +5 -4
- package/dist/components/slider/slider.d.ts +141 -0
- package/dist/components/slider/slider.js +467 -0
- package/dist/components/slider/slider.styles.d.ts +1 -0
- package/dist/components/slider/slider.styles.js +87 -0
- package/dist/components/source-card/source-card.d.ts +104 -0
- package/dist/components/source-card/source-card.js +195 -0
- package/dist/components/source-card/source-card.styles.d.ts +1 -0
- package/dist/components/source-card/source-card.styles.js +69 -0
- package/dist/components/source-list/source-list.d.ts +63 -0
- package/dist/components/source-list/source-list.js +130 -0
- package/dist/components/source-list/source-list.styles.d.ts +1 -0
- package/dist/components/source-list/source-list.styles.js +59 -0
- package/dist/components/sparkline/sparkline.js +58 -20
- package/dist/components/split/split.d.ts +224 -5
- package/dist/components/split/split.js +617 -43
- package/dist/components/split/split.styles.js +47 -0
- package/dist/components/stat/stat.d.ts +15 -4
- package/dist/components/stat/stat.js +53 -12
- package/dist/components/stream-status/stream-status.d.ts +126 -0
- package/dist/components/stream-status/stream-status.js +292 -0
- package/dist/components/stream-status/stream-status.styles.d.ts +1 -0
- package/dist/components/stream-status/stream-status.styles.js +103 -0
- package/dist/components/streaming-text/streaming-text.d.ts +104 -0
- package/dist/components/streaming-text/streaming-text.js +224 -0
- package/dist/components/streaming-text/streaming-text.styles.d.ts +1 -0
- package/dist/components/streaming-text/streaming-text.styles.js +63 -0
- package/dist/components/switch/switch.d.ts +103 -0
- package/dist/components/switch/switch.js +250 -0
- package/dist/components/switch/switch.styles.d.ts +1 -0
- package/dist/components/switch/switch.styles.js +75 -0
- package/dist/components/table/table.d.ts +89 -5
- package/dist/components/table/table.js +243 -26
- package/dist/components/table/table.styles.js +6 -1
- package/dist/components/tabs/tabs.d.ts +74 -0
- package/dist/components/tabs/tabs.js +254 -0
- package/dist/components/tabs/tabs.styles.d.ts +1 -0
- package/dist/components/tabs/tabs.styles.js +74 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +123 -0
- package/dist/components/thinking-panel/thinking-panel.js +260 -0
- package/dist/components/thinking-panel/thinking-panel.styles.d.ts +1 -0
- package/dist/components/thinking-panel/thinking-panel.styles.js +123 -0
- package/dist/components/time-range/time-range.d.ts +59 -2
- package/dist/components/time-range/time-range.js +163 -67
- package/dist/components/toast/toast-item.d.ts +12 -2
- package/dist/components/toast/toast-item.js +106 -44
- package/dist/components/toast/toast-item.styles.js +59 -28
- package/dist/components/toast/toast.js +17 -5
- package/dist/components/toast/toaster.js +10 -1
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +131 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +329 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.d.ts +1 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.js +160 -0
- package/dist/components/tool-call-chip/tool-call-chip.d.ts +105 -0
- package/dist/components/tool-call-chip/tool-call-chip.js +349 -0
- package/dist/components/tool-call-chip/tool-call-chip.styles.d.ts +1 -0
- package/dist/components/tool-call-chip/tool-call-chip.styles.js +203 -0
- package/dist/components/tool-param-form/tool-param-form.d.ts +206 -0
- package/dist/components/tool-param-form/tool-param-form.js +610 -0
- package/dist/components/tool-param-form/tool-param-form.styles.d.ts +1 -0
- package/dist/components/tool-param-form/tool-param-form.styles.js +75 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.d.ts +122 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.js +358 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.d.ts +1 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.js +176 -0
- package/dist/components/tool-result-view/registry.d.ts +73 -0
- package/dist/components/tool-result-view/registry.js +89 -0
- package/dist/components/tool-result-view/tool-result-view.d.ts +58 -0
- package/dist/components/tool-result-view/tool-result-view.js +152 -0
- package/dist/components/tool-result-view/tool-result-view.styles.d.ts +1 -0
- package/dist/components/tool-result-view/tool-result-view.styles.js +13 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.d.ts +151 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.js +350 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.d.ts +1 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.js +191 -0
- package/dist/components/tree/tree-node.d.ts +15 -3
- package/dist/components/tree/tree-node.js +20 -7
- package/dist/components/tree/tree.d.ts +25 -10
- package/dist/components/tree/tree.js +39 -31
- package/dist/components/typing-indicator/typing-indicator.d.ts +70 -0
- package/dist/components/typing-indicator/typing-indicator.js +108 -0
- package/dist/components/typing-indicator/typing-indicator.styles.d.ts +1 -0
- package/dist/components/typing-indicator/typing-indicator.styles.js +132 -0
- package/dist/components/virtual-list/virtual-list.d.ts +210 -0
- package/dist/components/virtual-list/virtual-list.js +607 -0
- package/dist/components/virtual-list/virtual-list.styles.d.ts +1 -0
- package/dist/components/virtual-list/virtual-list.styles.js +56 -0
- package/dist/components/widget/widget.d.ts +5 -4
- package/dist/components/widget/widget.js +54 -120
- package/dist/components/widget/widget.styles.js +8 -2
- package/dist/components/word-cloud/word-cloud-layout.d.ts +7 -0
- package/dist/components/word-cloud/word-cloud-layout.js +29 -2
- package/dist/components/word-cloud/word-cloud.d.ts +28 -2
- package/dist/components/word-cloud/word-cloud.js +69 -19
- package/dist/components/word-cloud/word-cloud.styles.js +16 -3
- package/dist/internal/anchored-validity.d.ts +1 -0
- package/dist/internal/anchored-validity.js +86 -0
- package/dist/internal/announcer.d.ts +57 -0
- package/dist/internal/announcer.js +71 -0
- package/dist/internal/form-associated.d.ts +8 -0
- package/dist/internal/form-associated.js +98 -15
- package/dist/internal/group-by-recency.d.ts +50 -0
- package/dist/internal/group-by-recency.js +80 -0
- package/dist/internal/numbers.d.ts +12 -0
- package/dist/internal/numbers.js +26 -0
- package/dist/internal/overlay-manager.d.ts +51 -0
- package/dist/internal/overlay-manager.js +523 -0
- package/dist/internal/positioner.js +27 -3
- package/dist/internal/rtl.d.ts +23 -0
- package/dist/internal/rtl.js +28 -0
- package/dist/internal/safe-url.d.ts +12 -0
- package/dist/internal/safe-url.js +41 -0
- package/dist/internal/scroll-lock.d.ts +10 -5
- package/dist/internal/scroll-lock.js +30 -14
- package/dist/internal/tokens.styles.js +22 -10
- package/dist/lyra.d.ts +133 -31
- package/dist/lyra.js +96 -26
- package/llms-full.txt +4546 -183
- package/llms.txt +21 -5
- package/package.json +41 -6
- package/dist/components/chart/bar-chart.stories.d.ts +0 -5
- package/dist/components/chart/bar-chart.stories.js +0 -20
- package/dist/components/chart/box-plot.stories.d.ts +0 -5
- package/dist/components/chart/box-plot.stories.js +0 -29
- package/dist/components/chart/bubble-chart.stories.d.ts +0 -5
- package/dist/components/chart/bubble-chart.stories.js +0 -26
- package/dist/components/chart/chart.stories.d.ts +0 -32
- package/dist/components/chart/chart.stories.js +0 -141
- package/dist/components/chart/doughnut-chart.stories.d.ts +0 -5
- package/dist/components/chart/doughnut-chart.stories.js +0 -26
- package/dist/components/chart/histogram.stories.d.ts +0 -5
- package/dist/components/chart/histogram.stories.js +0 -17
- package/dist/components/chart/line-chart.stories.d.ts +0 -22
- package/dist/components/chart/line-chart.stories.js +0 -99
- package/dist/components/chart/lite-chart.stories.d.ts +0 -14
- package/dist/components/chart/lite-chart.stories.js +0 -114
- package/dist/components/chart/pie-chart.stories.d.ts +0 -5
- package/dist/components/chart/pie-chart.stories.js +0 -26
- package/dist/components/chart/polar-area-chart.stories.d.ts +0 -5
- package/dist/components/chart/polar-area-chart.stories.js +0 -20
- package/dist/components/chart/radar-chart.stories.d.ts +0 -5
- package/dist/components/chart/radar-chart.stories.js +0 -20
- package/dist/components/chart/scatter-chart.stories.d.ts +0 -5
- package/dist/components/chart/scatter-chart.stories.js +0 -31
- package/dist/components/combobox/combobox.stories.d.ts +0 -24
- package/dist/components/combobox/combobox.stories.js +0 -102
- package/dist/components/date-picker/date-input.stories.d.ts +0 -10
- package/dist/components/date-picker/date-input.stories.js +0 -48
- package/dist/components/date-picker/date-picker.stories.d.ts +0 -10
- package/dist/components/date-picker/date-picker.stories.js +0 -25
- package/dist/components/empty/empty.stories.d.ts +0 -7
- package/dist/components/empty/empty.stories.js +0 -34
- package/dist/components/export-button/export-button.stories.d.ts +0 -7
- package/dist/components/export-button/export-button.stories.js +0 -37
- package/dist/components/file-input/file-input.stories.d.ts +0 -7
- package/dist/components/file-input/file-input.stories.js +0 -19
- package/dist/components/flag/flag.stories.d.ts +0 -6
- package/dist/components/flag/flag.stories.js +0 -31
- package/dist/components/gauge/gauge.stories.d.ts +0 -8
- package/dist/components/gauge/gauge.stories.js +0 -19
- package/dist/components/graph/graph.stories.d.ts +0 -8
- package/dist/components/graph/graph.stories.js +0 -68
- package/dist/components/heatmap/heatmap.stories.d.ts +0 -27
- package/dist/components/heatmap/heatmap.stories.js +0 -179
- package/dist/components/map/map.stories.d.ts +0 -15
- package/dist/components/map/map.stories.js +0 -135
- package/dist/components/playback/playback.stories.d.ts +0 -7
- package/dist/components/playback/playback.stories.js +0 -16
- package/dist/components/select/select.stories.d.ts +0 -21
- package/dist/components/select/select.stories.js +0 -91
- package/dist/components/skeleton/skeleton.stories.d.ts +0 -5
- package/dist/components/skeleton/skeleton.stories.js +0 -16
- package/dist/components/sparkline/sparkline.stories.d.ts +0 -11
- package/dist/components/sparkline/sparkline.stories.js +0 -39
- package/dist/components/split/split.stories.d.ts +0 -7
- package/dist/components/split/split.stories.js +0 -36
- package/dist/components/stat/stat.stories.d.ts +0 -9
- package/dist/components/stat/stat.stories.js +0 -81
- package/dist/components/table/table.stories.d.ts +0 -12
- package/dist/components/table/table.stories.js +0 -67
- package/dist/components/time-range/time-range.stories.d.ts +0 -8
- package/dist/components/time-range/time-range.stories.js +0 -26
- package/dist/components/toast/toast.stories.d.ts +0 -8
- package/dist/components/toast/toast.stories.js +0 -72
- package/dist/components/tree/tree.stories.d.ts +0 -9
- package/dist/components/tree/tree.stories.js +0 -52
- package/dist/components/widget/widget.stories.d.ts +0 -9
- package/dist/components/widget/widget.stories.js +0 -74
- package/dist/components/word-cloud/word-cloud.stories.d.ts +0 -10
- package/dist/components/word-cloud/word-cloud.stories.js +0 -55
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export const VALIDITY_ANCHOR = Symbol('lyra-validity-anchor');
|
|
3
|
+
/** @internal */
|
|
4
|
+
export const SET_ANCHORED_VALIDITY = Symbol('lyra-set-anchored-validity');
|
|
5
|
+
/** @internal */
|
|
6
|
+
export function resolveValidityAnchor(provider) {
|
|
7
|
+
if (!provider || (typeof provider !== 'object' && typeof provider !== 'function'))
|
|
8
|
+
return undefined;
|
|
9
|
+
const resolver = provider[VALIDITY_ANCHOR];
|
|
10
|
+
if (typeof resolver !== 'function')
|
|
11
|
+
return undefined;
|
|
12
|
+
return resolver.call(provider) ?? undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Keeps ElementInternals validity synchronous while refreshing its focus
|
|
16
|
+
* anchor after every render. The refresh is required because validity can be
|
|
17
|
+
* computed before the first shadow render and because conditional templates
|
|
18
|
+
* can replace a previously registered anchor.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export class AnchoredValidityController {
|
|
23
|
+
constructor(host, internals, getAnchor) {
|
|
24
|
+
this.host = host;
|
|
25
|
+
this.internals = internals;
|
|
26
|
+
this.getAnchor = getAnchor;
|
|
27
|
+
this.flags = {};
|
|
28
|
+
this.message = '';
|
|
29
|
+
this.revision = 0;
|
|
30
|
+
this.refreshToken = 0;
|
|
31
|
+
host.addController(this);
|
|
32
|
+
}
|
|
33
|
+
setValidity(flags = {}, message = '') {
|
|
34
|
+
this.flags = { ...flags };
|
|
35
|
+
this.message = message;
|
|
36
|
+
this.revision += 1;
|
|
37
|
+
this.apply();
|
|
38
|
+
}
|
|
39
|
+
refreshAnchor() {
|
|
40
|
+
if (this.isInvalid())
|
|
41
|
+
this.apply();
|
|
42
|
+
}
|
|
43
|
+
hostUpdated() {
|
|
44
|
+
if (!this.isInvalid())
|
|
45
|
+
return;
|
|
46
|
+
const revision = this.revision;
|
|
47
|
+
const token = ++this.refreshToken;
|
|
48
|
+
// Rebind just after the host's update so focus side effects from an
|
|
49
|
+
// already-visible validation UI cannot schedule a new Lit update from
|
|
50
|
+
// inside hostUpdated(). This microtask runs before updateComplete settles.
|
|
51
|
+
queueMicrotask(() => {
|
|
52
|
+
if (token !== this.refreshToken || revision !== this.revision)
|
|
53
|
+
return;
|
|
54
|
+
if (this.apply())
|
|
55
|
+
return;
|
|
56
|
+
// Nested custom controls may render one microtask after their parent.
|
|
57
|
+
// Retry once so an outer form can anchor inside that nested shadow tree.
|
|
58
|
+
queueMicrotask(() => {
|
|
59
|
+
if (token === this.refreshToken && revision === this.revision)
|
|
60
|
+
this.apply();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
isInvalid() {
|
|
65
|
+
return Object.values(this.flags).some(Boolean);
|
|
66
|
+
}
|
|
67
|
+
/** Returns true when an invalid state was installed with a real anchor. */
|
|
68
|
+
apply() {
|
|
69
|
+
const anchor = this.isInvalid() ? this.getAnchor() : undefined;
|
|
70
|
+
if (anchor?.isConnected) {
|
|
71
|
+
try {
|
|
72
|
+
this.internals.setValidity(this.flags, this.message, anchor);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
// A stale or incorrectly provided non-descendant anchor must not
|
|
77
|
+
// break the host's update. Preserve validity and fall back to the
|
|
78
|
+
// host until the next fresh render resolves a legal descendant.
|
|
79
|
+
if (!(error instanceof DOMException) || error.name !== 'NotFoundError')
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.internals.setValidity(this.flags, this.message);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Options for a single `Announcer.announce()` call. */
|
|
2
|
+
export interface AnnounceOptions {
|
|
3
|
+
/** Bypass any in-progress throttle window and flush this text immediately. */
|
|
4
|
+
force?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface AnnouncerOptions {
|
|
7
|
+
/** Throttle window in ms. Repeated `announce()` calls arriving within this
|
|
8
|
+
* window of the first call in a burst collapse to one trailing-edge flush
|
|
9
|
+
* of the latest text. Defaults to 500. */
|
|
10
|
+
throttleMs?: number;
|
|
11
|
+
/** Invoked with the coalesced text whenever a burst flushes (on the
|
|
12
|
+
* trailing edge, or immediately for a `{ force: true }` call). */
|
|
13
|
+
onFlush: (text: string) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Trailing-edge debounce/coalesce for screen-reader announcements.
|
|
17
|
+
*
|
|
18
|
+
* Streaming UIs (token-by-token chat responses, progress ticks, etc.)
|
|
19
|
+
* naturally produce far more candidate announcements than a screen-reader
|
|
20
|
+
* user can usefully absorb — reading every incremental chunk aloud is spam,
|
|
21
|
+
* not information. `Announcer` collapses a burst of `announce()` calls
|
|
22
|
+
* arriving within `throttleMs` of the *first* call in that burst down to a
|
|
23
|
+
* single flush of the latest text: superseded intermediate text is dropped
|
|
24
|
+
* outright, never queued or concatenated. Passing `{ force: true }` always
|
|
25
|
+
* flushes immediately regardless of any window in progress, so a final or
|
|
26
|
+
* terminal message (e.g. "response complete") is never swallowed mid-burst.
|
|
27
|
+
*
|
|
28
|
+
* This is pure timing/state logic with no DOM dependency — it knows nothing
|
|
29
|
+
* about ARIA, elements, or Lit. `<lyra-live-region>`
|
|
30
|
+
* (`../components/live-region/live-region.js`) is the DOM-facing wrapper
|
|
31
|
+
* that composes one of these with an actual live-region element. Other
|
|
32
|
+
* components that need throttled announcements (a stream-status indicator,
|
|
33
|
+
* a tool-call chip's status transitions, a chat message's streaming state)
|
|
34
|
+
* should reuse that wrapper rather than instantiating `Announcer` directly.
|
|
35
|
+
*/
|
|
36
|
+
export declare class Announcer {
|
|
37
|
+
/** Throttle window in ms. Safe to change between bursts; a flush already
|
|
38
|
+
* scheduled keeps the deadline it was scheduled with. */
|
|
39
|
+
throttleMs: number;
|
|
40
|
+
private readonly onFlush;
|
|
41
|
+
private timer?;
|
|
42
|
+
private pending?;
|
|
43
|
+
constructor(options: AnnouncerOptions);
|
|
44
|
+
/** The latest text awaiting flush, if a burst is currently in progress. */
|
|
45
|
+
get pendingText(): string | undefined;
|
|
46
|
+
/** Whether a flush is currently scheduled (a burst is in progress). */
|
|
47
|
+
get isPending(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Queue `text` for announcement. Within a single throttle window, only the
|
|
50
|
+
* latest text queued survives — this call always overwrites whatever an
|
|
51
|
+
* earlier call in the same burst queued.
|
|
52
|
+
*/
|
|
53
|
+
announce(text: string, options?: AnnounceOptions): void;
|
|
54
|
+
/** Cancel any pending (not yet flushed) announcement without flushing it. */
|
|
55
|
+
cancel(): void;
|
|
56
|
+
private flush;
|
|
57
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const DEFAULT_THROTTLE_MS = 500;
|
|
2
|
+
/**
|
|
3
|
+
* Trailing-edge debounce/coalesce for screen-reader announcements.
|
|
4
|
+
*
|
|
5
|
+
* Streaming UIs (token-by-token chat responses, progress ticks, etc.)
|
|
6
|
+
* naturally produce far more candidate announcements than a screen-reader
|
|
7
|
+
* user can usefully absorb — reading every incremental chunk aloud is spam,
|
|
8
|
+
* not information. `Announcer` collapses a burst of `announce()` calls
|
|
9
|
+
* arriving within `throttleMs` of the *first* call in that burst down to a
|
|
10
|
+
* single flush of the latest text: superseded intermediate text is dropped
|
|
11
|
+
* outright, never queued or concatenated. Passing `{ force: true }` always
|
|
12
|
+
* flushes immediately regardless of any window in progress, so a final or
|
|
13
|
+
* terminal message (e.g. "response complete") is never swallowed mid-burst.
|
|
14
|
+
*
|
|
15
|
+
* This is pure timing/state logic with no DOM dependency — it knows nothing
|
|
16
|
+
* about ARIA, elements, or Lit. `<lyra-live-region>`
|
|
17
|
+
* (`../components/live-region/live-region.js`) is the DOM-facing wrapper
|
|
18
|
+
* that composes one of these with an actual live-region element. Other
|
|
19
|
+
* components that need throttled announcements (a stream-status indicator,
|
|
20
|
+
* a tool-call chip's status transitions, a chat message's streaming state)
|
|
21
|
+
* should reuse that wrapper rather than instantiating `Announcer` directly.
|
|
22
|
+
*/
|
|
23
|
+
export class Announcer {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.throttleMs = options.throttleMs ?? DEFAULT_THROTTLE_MS;
|
|
26
|
+
this.onFlush = options.onFlush;
|
|
27
|
+
}
|
|
28
|
+
/** The latest text awaiting flush, if a burst is currently in progress. */
|
|
29
|
+
get pendingText() {
|
|
30
|
+
return this.pending;
|
|
31
|
+
}
|
|
32
|
+
/** Whether a flush is currently scheduled (a burst is in progress). */
|
|
33
|
+
get isPending() {
|
|
34
|
+
return this.timer !== undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Queue `text` for announcement. Within a single throttle window, only the
|
|
38
|
+
* latest text queued survives — this call always overwrites whatever an
|
|
39
|
+
* earlier call in the same burst queued.
|
|
40
|
+
*/
|
|
41
|
+
announce(text, options = {}) {
|
|
42
|
+
this.pending = text;
|
|
43
|
+
if (options.force) {
|
|
44
|
+
this.flush();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Only the first call of a burst schedules the timer; later calls inside
|
|
48
|
+
// the same window just overwrite `pending` above, so the flush deadline
|
|
49
|
+
// stays anchored to the first call (trailing-edge debounce) instead of
|
|
50
|
+
// being pushed back on every subsequent call.
|
|
51
|
+
this.timer ??= setTimeout(() => this.flush(), this.throttleMs);
|
|
52
|
+
}
|
|
53
|
+
/** Cancel any pending (not yet flushed) announcement without flushing it. */
|
|
54
|
+
cancel() {
|
|
55
|
+
if (this.timer !== undefined) {
|
|
56
|
+
clearTimeout(this.timer);
|
|
57
|
+
this.timer = undefined;
|
|
58
|
+
}
|
|
59
|
+
this.pending = undefined;
|
|
60
|
+
}
|
|
61
|
+
flush() {
|
|
62
|
+
if (this.timer !== undefined) {
|
|
63
|
+
clearTimeout(this.timer);
|
|
64
|
+
this.timer = undefined;
|
|
65
|
+
}
|
|
66
|
+
const text = this.pending;
|
|
67
|
+
this.pending = undefined;
|
|
68
|
+
if (text !== undefined)
|
|
69
|
+
this.onFlush(text);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -7,9 +7,17 @@ export interface FormAssociatedInterface {
|
|
|
7
7
|
value: string;
|
|
8
8
|
disabled: boolean;
|
|
9
9
|
required: boolean;
|
|
10
|
+
readonly effectiveDisabled: boolean;
|
|
11
|
+
readonly form: HTMLFormElement | null;
|
|
12
|
+
readonly labels: NodeList;
|
|
13
|
+
readonly validity: ValidityState;
|
|
14
|
+
readonly validationMessage: string;
|
|
15
|
+
readonly willValidate: boolean;
|
|
10
16
|
setFormValue(next: string): void;
|
|
11
17
|
checkValidity(): boolean;
|
|
12
18
|
reportValidity(): boolean;
|
|
19
|
+
formResetCallback(): void;
|
|
20
|
+
formStateRestoreCallback(state: string | File | FormData | null, mode?: 'restore' | 'autocomplete'): void;
|
|
13
21
|
}
|
|
14
22
|
/**
|
|
15
23
|
* Mixin that turns a Lit component into a form-associated custom element via
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AnchoredValidityController, SET_ANCHORED_VALIDITY, VALIDITY_ANCHOR, } from './anchored-validity.js';
|
|
1
2
|
/**
|
|
2
3
|
* Mixin that turns a Lit component into a form-associated custom element via
|
|
3
4
|
* `ElementInternals`, so it participates in native `<form>` submission,
|
|
@@ -13,16 +14,22 @@ export function FormAssociated(Base) {
|
|
|
13
14
|
class FormAssociatedElement extends Base {
|
|
14
15
|
static { this.formAssociated = true; }
|
|
15
16
|
static { this.properties = {
|
|
16
|
-
name: {},
|
|
17
|
+
name: { reflect: true, noAccessor: true },
|
|
17
18
|
value: { noAccessor: true },
|
|
18
|
-
disabled: { type: Boolean, reflect: true },
|
|
19
|
-
required: { type: Boolean, reflect: true },
|
|
19
|
+
disabled: { type: Boolean, reflect: true, noAccessor: true },
|
|
20
|
+
required: { type: Boolean, reflect: true, noAccessor: true },
|
|
20
21
|
}; }
|
|
21
22
|
constructor(...args) {
|
|
22
23
|
super(...args);
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
|
|
24
|
+
this._fieldsetDisabled = false;
|
|
25
|
+
this._disabled = false;
|
|
26
|
+
// Hand-written accessor (mirrors `value`/`required` below): native form
|
|
27
|
+
// submission for a form-associated custom element keys its `FormData`
|
|
28
|
+
// entry off the `name` *content attribute*, read synchronously at
|
|
29
|
+
// submission time — an async (Lit-scheduled) reflection would leave a
|
|
30
|
+
// property-only assignment like `el.name = 'foo'` invisible to a
|
|
31
|
+
// same-tick `new FormData(form)`/submit.
|
|
32
|
+
this._name = '';
|
|
26
33
|
this._value = '';
|
|
27
34
|
// What native `defaultValue`/`form.reset()` restores to. Mirrors the
|
|
28
35
|
// `value` *content attribute* only (see `attributeChangedCallback`
|
|
@@ -34,7 +41,50 @@ export function FormAssociated(Base) {
|
|
|
34
41
|
// first" would wrongly let a user's first-ever edit become permanent
|
|
35
42
|
// (a required field could never be reset back to blank again).
|
|
36
43
|
this._defaultValue = '';
|
|
44
|
+
this._required = false;
|
|
37
45
|
this.internals = this.attachInternals();
|
|
46
|
+
this.validityController = new AnchoredValidityController(this, this.internals, () => this[VALIDITY_ANCHOR]());
|
|
47
|
+
// Native <input> always has a submission value ("") from construction —
|
|
48
|
+
// without this, a control whose `value` is never touched is entirely
|
|
49
|
+
// absent from FormData instead of present as "".
|
|
50
|
+
this.internals.setFormValue('');
|
|
51
|
+
}
|
|
52
|
+
get form() {
|
|
53
|
+
return this.internals.form;
|
|
54
|
+
}
|
|
55
|
+
get labels() {
|
|
56
|
+
return this.internals.labels;
|
|
57
|
+
}
|
|
58
|
+
get validity() {
|
|
59
|
+
return this.internals.validity;
|
|
60
|
+
}
|
|
61
|
+
get validationMessage() {
|
|
62
|
+
return this.internals.validationMessage;
|
|
63
|
+
}
|
|
64
|
+
get willValidate() {
|
|
65
|
+
return this.internals.willValidate;
|
|
66
|
+
}
|
|
67
|
+
/** @internal */
|
|
68
|
+
[VALIDITY_ANCHOR]() {
|
|
69
|
+
return this.renderRoot?.querySelector("input:not([type='hidden']), textarea, select, button, [tabindex]:not([tabindex='-1'])") ?? null;
|
|
70
|
+
}
|
|
71
|
+
/** @internal */
|
|
72
|
+
[SET_ANCHORED_VALIDITY](flags, message = '') {
|
|
73
|
+
this.validityController.setValidity(flags, message);
|
|
74
|
+
}
|
|
75
|
+
get name() {
|
|
76
|
+
return this._name;
|
|
77
|
+
}
|
|
78
|
+
set name(next) {
|
|
79
|
+
const old = this._name;
|
|
80
|
+
this._name = next ?? '';
|
|
81
|
+
if (this._name) {
|
|
82
|
+
this.setAttribute('name', this._name);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.removeAttribute('name');
|
|
86
|
+
}
|
|
87
|
+
this.requestUpdate('name', old);
|
|
38
88
|
}
|
|
39
89
|
get value() {
|
|
40
90
|
return this._value;
|
|
@@ -46,6 +96,33 @@ export function FormAssociated(Base) {
|
|
|
46
96
|
this.updateValidity();
|
|
47
97
|
this.requestUpdate('value', old);
|
|
48
98
|
}
|
|
99
|
+
get disabled() {
|
|
100
|
+
return this._disabled;
|
|
101
|
+
}
|
|
102
|
+
set disabled(next) {
|
|
103
|
+
const old = this._disabled;
|
|
104
|
+
this._disabled = Boolean(next);
|
|
105
|
+
// FACE omission and barred validation are driven by the live host
|
|
106
|
+
// attribute, so reflection must happen before same-tick form APIs run.
|
|
107
|
+
this.toggleAttribute('disabled', this._disabled);
|
|
108
|
+
this.requestUpdate('disabled', old);
|
|
109
|
+
}
|
|
110
|
+
get required() {
|
|
111
|
+
return this._required;
|
|
112
|
+
}
|
|
113
|
+
set required(next) {
|
|
114
|
+
const old = this._required;
|
|
115
|
+
this._required = next;
|
|
116
|
+
this.toggleAttribute('required', next);
|
|
117
|
+
this.updateValidity();
|
|
118
|
+
this.requestUpdate('required', old);
|
|
119
|
+
}
|
|
120
|
+
/** Effective disabled state: this element's own `disabled` OR an ancestor
|
|
121
|
+
* `<fieldset disabled>`'s inherited state — mirrors native `<input>`, whose
|
|
122
|
+
* own `disabled` IDL property/attribute is never mutated by a fieldset. */
|
|
123
|
+
get effectiveDisabled() {
|
|
124
|
+
return this.disabled || this._fieldsetDisabled;
|
|
125
|
+
}
|
|
49
126
|
attributeChangedCallback(name, old, value) {
|
|
50
127
|
super.attributeChangedCallback(name, old, value);
|
|
51
128
|
if (name === 'value') {
|
|
@@ -66,10 +143,10 @@ export function FormAssociated(Base) {
|
|
|
66
143
|
*/
|
|
67
144
|
updateValidity() {
|
|
68
145
|
if (this.required && this._value === '') {
|
|
69
|
-
this
|
|
146
|
+
this[SET_ANCHORED_VALIDITY]({ valueMissing: true }, 'Please fill out this field.');
|
|
70
147
|
}
|
|
71
148
|
else {
|
|
72
|
-
this
|
|
149
|
+
this[SET_ANCHORED_VALIDITY]({});
|
|
73
150
|
}
|
|
74
151
|
}
|
|
75
152
|
checkValidity() {
|
|
@@ -83,8 +160,19 @@ export function FormAssociated(Base) {
|
|
|
83
160
|
// semantics) — previously this unconditionally blanked the field.
|
|
84
161
|
this.value = this._defaultValue;
|
|
85
162
|
}
|
|
86
|
-
|
|
87
|
-
this.
|
|
163
|
+
formStateRestoreCallback(state, _mode) {
|
|
164
|
+
this.value = typeof state === 'string' ? state : '';
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Called by the browser when an ancestor `<fieldset disabled>` toggles.
|
|
168
|
+
* Tracked separately from the consumer's own `disabled` (see
|
|
169
|
+
* `effectiveDisabled`) — a native `<input>`'s own `disabled` IDL
|
|
170
|
+
* property/attribute is never mutated by fieldset cascading, so a
|
|
171
|
+
* consumer's explicit `disabled` must survive the fieldset re-enabling.
|
|
172
|
+
*/
|
|
173
|
+
formDisabledCallback(fieldsetDisabled) {
|
|
174
|
+
this._fieldsetDisabled = fieldsetDisabled;
|
|
175
|
+
this.requestUpdate();
|
|
88
176
|
}
|
|
89
177
|
connectedCallback() {
|
|
90
178
|
super.connectedCallback();
|
|
@@ -93,11 +181,6 @@ export function FormAssociated(Base) {
|
|
|
93
181
|
// `value` write.
|
|
94
182
|
this.updateValidity();
|
|
95
183
|
}
|
|
96
|
-
updated(changed) {
|
|
97
|
-
super.updated(changed);
|
|
98
|
-
if (changed.has('required'))
|
|
99
|
-
this.updateValidity();
|
|
100
|
-
}
|
|
101
184
|
}
|
|
102
185
|
return FormAssociatedElement;
|
|
103
186
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Per-bucket English defaults, overridable the same "no i18n, but
|
|
2
|
+
* overridable via an options object" way `<lyra-date-picker>`/
|
|
3
|
+
* `<lyra-source-list>`'s `label-plural` already establish. */
|
|
4
|
+
export interface RecencyLabels {
|
|
5
|
+
today?: string;
|
|
6
|
+
yesterday?: string;
|
|
7
|
+
previousWeek?: string;
|
|
8
|
+
older?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GroupByRecencyOptions<T> {
|
|
11
|
+
/** Extracts the timestamp to bucket `item` by. Defaults to assuming `item`
|
|
12
|
+
* itself *is* a `Date` — the simplest possible default for the common
|
|
13
|
+
* case of grouping a plain array of dates. A returned `number` is treated
|
|
14
|
+
* as a standard JS epoch-milliseconds value (`Date.prototype.getTime()`'s
|
|
15
|
+
* own unit) — not GreyCat's micros `time` type; a caller bridging from
|
|
16
|
+
* GreyCat data converts in its own `getTimestamp` callback. */
|
|
17
|
+
getTimestamp?: (item: T) => Date | number | string;
|
|
18
|
+
/** The "current" instant bucket boundaries are computed relative to.
|
|
19
|
+
* Defaults to `new Date()`. Overridable for deterministic tests (and for
|
|
20
|
+
* a caller that wants to bucket relative to something other than the
|
|
21
|
+
* actual current instant, e.g. a fixed "as of" report time). */
|
|
22
|
+
now?: Date;
|
|
23
|
+
/** Overrides for one or more of the four bucket labels. Any label left
|
|
24
|
+
* unset keeps its English default. */
|
|
25
|
+
labels?: RecencyLabels;
|
|
26
|
+
}
|
|
27
|
+
export interface RecencyBucket<T> {
|
|
28
|
+
label: string;
|
|
29
|
+
items: T[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Buckets `items` into Today / Yesterday / Previous 7 Days / Older, using
|
|
33
|
+
* calendar-day boundaries in the local timezone — "yesterday" means the
|
|
34
|
+
* previous calendar date, not "24-48 hours ago". Mirrors the bucketing a
|
|
35
|
+
* chat sidebar's conversation-history list commonly groups by (this
|
|
36
|
+
* library's own `<lyra-conversation-item>` is the intended consumer, though
|
|
37
|
+
* this function is deliberately DOM/component-free — plain data in, plain
|
|
38
|
+
* data out).
|
|
39
|
+
*
|
|
40
|
+
* Only buckets that end up with at least one item are included in the
|
|
41
|
+
* returned array, in Today/Yesterday/Previous-7-Days/Older order; each
|
|
42
|
+
* bucket's items keep their original relative order from `items` (never
|
|
43
|
+
* re-sorted). Two edge cases with no dedicated bucket of their own: a
|
|
44
|
+
* timestamp dated in the future relative to `now` lands in `Today` — the
|
|
45
|
+
* most-recent bucket available, since there's no "upcoming" bucket to put it
|
|
46
|
+
* in instead. A timestamp that fails to parse lands in `Older` instead — it
|
|
47
|
+
* carries no "this is recent" signal at all, so the oldest/catch-all bucket
|
|
48
|
+
* is the more honest home for it than the newest one.
|
|
49
|
+
*/
|
|
50
|
+
export declare function groupByRecency<T>(items: T[], options?: GroupByRecencyOptions<T>): RecencyBucket<T>[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
2
|
+
const DEFAULT_LABELS = {
|
|
3
|
+
today: 'Today',
|
|
4
|
+
yesterday: 'Yesterday',
|
|
5
|
+
previousWeek: 'Previous 7 Days',
|
|
6
|
+
older: 'Older',
|
|
7
|
+
};
|
|
8
|
+
/** Midnight (start of the local calendar day) for `d`, as epoch millis —
|
|
9
|
+
* built from `d`'s own local-timezone Y/M/D fields, so this is a calendar-
|
|
10
|
+
* day boundary, not a rolling 24-hour offset from `d` itself. */
|
|
11
|
+
function startOfLocalDay(d) {
|
|
12
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Buckets `items` into Today / Yesterday / Previous 7 Days / Older, using
|
|
16
|
+
* calendar-day boundaries in the local timezone — "yesterday" means the
|
|
17
|
+
* previous calendar date, not "24-48 hours ago". Mirrors the bucketing a
|
|
18
|
+
* chat sidebar's conversation-history list commonly groups by (this
|
|
19
|
+
* library's own `<lyra-conversation-item>` is the intended consumer, though
|
|
20
|
+
* this function is deliberately DOM/component-free — plain data in, plain
|
|
21
|
+
* data out).
|
|
22
|
+
*
|
|
23
|
+
* Only buckets that end up with at least one item are included in the
|
|
24
|
+
* returned array, in Today/Yesterday/Previous-7-Days/Older order; each
|
|
25
|
+
* bucket's items keep their original relative order from `items` (never
|
|
26
|
+
* re-sorted). Two edge cases with no dedicated bucket of their own: a
|
|
27
|
+
* timestamp dated in the future relative to `now` lands in `Today` — the
|
|
28
|
+
* most-recent bucket available, since there's no "upcoming" bucket to put it
|
|
29
|
+
* in instead. A timestamp that fails to parse lands in `Older` instead — it
|
|
30
|
+
* carries no "this is recent" signal at all, so the oldest/catch-all bucket
|
|
31
|
+
* is the more honest home for it than the newest one.
|
|
32
|
+
*/
|
|
33
|
+
export function groupByRecency(items, options = {}) {
|
|
34
|
+
const getTimestamp = options.getTimestamp ?? ((item) => item);
|
|
35
|
+
const now = options.now ?? new Date();
|
|
36
|
+
const labels = { ...DEFAULT_LABELS, ...options.labels };
|
|
37
|
+
const todayStart = startOfLocalDay(now);
|
|
38
|
+
const today = [];
|
|
39
|
+
const yesterday = [];
|
|
40
|
+
const previousWeek = [];
|
|
41
|
+
const older = [];
|
|
42
|
+
for (const item of items) {
|
|
43
|
+
const raw = getTimestamp(item);
|
|
44
|
+
const date = raw instanceof Date ? raw : new Date(raw);
|
|
45
|
+
const time = date.getTime();
|
|
46
|
+
// No meaningful "how recent" signal at all -- the catch-all bucket
|
|
47
|
+
// surfaces it (so it's never silently dropped) without inventing a
|
|
48
|
+
// "day 0" that a genuinely-invalid timestamp doesn't deserve.
|
|
49
|
+
if (Number.isNaN(time)) {
|
|
50
|
+
older.push(item);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const dayDiff = Math.round((todayStart - startOfLocalDay(date)) / MS_PER_DAY);
|
|
54
|
+
if (dayDiff <= 0) {
|
|
55
|
+
// <= 0 (not === 0) also covers a timestamp dated in the future
|
|
56
|
+
// relative to `now` -- there's no "upcoming" bucket, so it reads as
|
|
57
|
+
// the most-recent bucket available rather than being dropped.
|
|
58
|
+
today.push(item);
|
|
59
|
+
}
|
|
60
|
+
else if (dayDiff === 1) {
|
|
61
|
+
yesterday.push(item);
|
|
62
|
+
}
|
|
63
|
+
else if (dayDiff <= 7) {
|
|
64
|
+
previousWeek.push(item);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
older.push(item);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const buckets = [];
|
|
71
|
+
if (today.length)
|
|
72
|
+
buckets.push({ label: labels.today, items: today });
|
|
73
|
+
if (yesterday.length)
|
|
74
|
+
buckets.push({ label: labels.yesterday, items: yesterday });
|
|
75
|
+
if (previousWeek.length)
|
|
76
|
+
buckets.push({ label: labels.previousWeek, items: previousWeek });
|
|
77
|
+
if (older.length)
|
|
78
|
+
buckets.push({ label: labels.older, items: older });
|
|
79
|
+
return buckets;
|
|
80
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The largest delay browsers can represent reliably with setTimeout. */
|
|
2
|
+
export declare const MAX_TIMEOUT_MS = 2147483647;
|
|
3
|
+
/** Returns a finite number or the supplied finite fallback. */
|
|
4
|
+
export declare function finiteNumber(value: number, fallback: number): number;
|
|
5
|
+
/** Returns a finite value clamped to the requested range. */
|
|
6
|
+
export declare function finiteRange(value: number, fallback: number, min?: number, max?: number): number;
|
|
7
|
+
/** Returns a finite integer, truncating fractional input and clamping it. */
|
|
8
|
+
export declare function finiteInteger(value: number, fallback: number, min?: number, max?: number): number;
|
|
9
|
+
/** Returns a finite, non-negative integer suitable for a count or index. */
|
|
10
|
+
export declare function finiteCount(value: number, fallback?: number, max?: number): number;
|
|
11
|
+
/** Returns a finite timer duration, capped at the browser timer ceiling. */
|
|
12
|
+
export declare function finiteDuration(value: number, fallback: number, min?: number, max?: number): number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The largest delay browsers can represent reliably with setTimeout. */
|
|
2
|
+
export const MAX_TIMEOUT_MS = 2_147_483_647;
|
|
3
|
+
/** Returns a finite number or the supplied finite fallback. */
|
|
4
|
+
export function finiteNumber(value, fallback) {
|
|
5
|
+
return Number.isFinite(value) ? value : Number.isFinite(fallback) ? fallback : 0;
|
|
6
|
+
}
|
|
7
|
+
/** Returns a finite value clamped to the requested range. */
|
|
8
|
+
export function finiteRange(value, fallback, min = Number.NEGATIVE_INFINITY, max = Number.POSITIVE_INFINITY) {
|
|
9
|
+
const safeFallback = finiteNumber(fallback, 0);
|
|
10
|
+
const safeMin = Number.isFinite(min) ? min : Number.NEGATIVE_INFINITY;
|
|
11
|
+
const safeMax = Number.isFinite(max) ? max : Number.POSITIVE_INFINITY;
|
|
12
|
+
const safeValue = finiteNumber(value, safeFallback);
|
|
13
|
+
return Math.min(safeMax, Math.max(safeMin, safeValue));
|
|
14
|
+
}
|
|
15
|
+
/** Returns a finite integer, truncating fractional input and clamping it. */
|
|
16
|
+
export function finiteInteger(value, fallback, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
|
|
17
|
+
return Math.trunc(finiteRange(value, fallback, min, max));
|
|
18
|
+
}
|
|
19
|
+
/** Returns a finite, non-negative integer suitable for a count or index. */
|
|
20
|
+
export function finiteCount(value, fallback = 0, max = Number.MAX_SAFE_INTEGER) {
|
|
21
|
+
return finiteInteger(value, Math.max(0, fallback), 0, max);
|
|
22
|
+
}
|
|
23
|
+
/** Returns a finite timer duration, capped at the browser timer ceiling. */
|
|
24
|
+
export function finiteDuration(value, fallback, min = 0, max = MAX_TIMEOUT_MS) {
|
|
25
|
+
return finiteRange(value, fallback, min, Math.min(max, MAX_TIMEOUT_MS));
|
|
26
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface OverlayActivationOptions {
|
|
2
|
+
/** The custom-element host that owns this overlay. */
|
|
3
|
+
host: HTMLElement;
|
|
4
|
+
/** Resolves the current dialog/panel element after each render. */
|
|
5
|
+
panel: () => HTMLElement | null;
|
|
6
|
+
/** Dismisses the overlay with its component-specific Escape reason/event. */
|
|
7
|
+
onEscape: () => void;
|
|
8
|
+
/** Dismisses the overlay with its component-specific backdrop reason/event. */
|
|
9
|
+
onBackdrop?: () => void;
|
|
10
|
+
/** Optional component-specific initial target, such as an intentionally safe default action. */
|
|
11
|
+
preferredInitialFocus?: () => HTMLElement | null;
|
|
12
|
+
/** Override the focus-return target captured when the overlay activates. */
|
|
13
|
+
restoreFocusTo?: HTMLElement | null;
|
|
14
|
+
/** Defaults to true. Nonmodal popups share ordering without inerting the page. */
|
|
15
|
+
modal?: boolean;
|
|
16
|
+
/** Defaults to true. Set false for popups that allow native Tab to leave. */
|
|
17
|
+
trapFocus?: boolean;
|
|
18
|
+
/** Optional non-trapping Tab lifecycle, called without preventing the event. */
|
|
19
|
+
onTab?: () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface OverlayDeactivateOptions {
|
|
22
|
+
/** Defaults to true. Explicit outside-pointer paths can suppress restoration. */
|
|
23
|
+
restoreFocus?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface OverlayHandle {
|
|
26
|
+
/** Moves focus inside unless focus is already within the current panel. */
|
|
27
|
+
focusInitial(): void;
|
|
28
|
+
/** Removes the overlay permanently. Safe to call repeatedly. */
|
|
29
|
+
deactivate(options?: OverlayDeactivateOptions): void;
|
|
30
|
+
/** Temporarily unregisters during disconnect, preserving the original return target. */
|
|
31
|
+
suspend(): void;
|
|
32
|
+
/** Re-registers a suspended overlay in its current `ownerDocument`. */
|
|
33
|
+
resume(): void;
|
|
34
|
+
/** Whether this overlay currently owns Escape, Tab, and backdrop dismissal. */
|
|
35
|
+
isTopmost(): boolean;
|
|
36
|
+
/** Whether this handle still represents an active or temporarily suspended overlay. */
|
|
37
|
+
isActive(): boolean;
|
|
38
|
+
/** Runs the backdrop callback only when this overlay is topmost. */
|
|
39
|
+
dismissBackdrop(): boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Returns the deepest focused descendant across open shadow roots. */
|
|
42
|
+
export declare function deepActiveElement(doc?: Document): Element | null;
|
|
43
|
+
export declare function composedContains(container: Element, candidate: Element | null): boolean;
|
|
44
|
+
/** Collects rendered focus targets through slots and nested open shadow roots in browser tab order. */
|
|
45
|
+
export declare function collectFocusableElements(root: Element | ShadowRoot): HTMLElement[];
|
|
46
|
+
/**
|
|
47
|
+
* Adds an overlay to a stack scoped to its own `ownerDocument`. One document
|
|
48
|
+
* listener routes Escape and Tab only to the top entry, while modal inerting,
|
|
49
|
+
* visual stack depth, and focus return are recomputed as entries move.
|
|
50
|
+
*/
|
|
51
|
+
export declare function activateOverlay(options: OverlayActivationOptions): OverlayHandle;
|