@aceshooting/lyra-ui 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/custom-elements.json +21460 -8489
- package/dist/components/app-rail/app-rail.d.ts +171 -0
- package/dist/components/app-rail/app-rail.js +483 -0
- package/dist/components/app-rail/app-rail.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail.styles.js +125 -0
- package/dist/components/attachment-chip/attachment-chip.d.ts +114 -0
- package/dist/components/attachment-chip/attachment-chip.js +312 -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 +83 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +258 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.d.ts +1 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +68 -0
- package/dist/components/chart/box-plot.js +11 -1
- 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 +12 -2
- package/dist/components/chart/chart.js +121 -14
- package/dist/components/chart/histogram-bin.d.ts +4 -1
- package/dist/components/chart/histogram-bin.js +24 -14
- package/dist/components/chart/lite-chart.d.ts +63 -0
- package/dist/components/chart/lite-chart.js +181 -23
- package/dist/components/chart/lite-chart.styles.js +9 -0
- package/dist/components/chat-composer/chat-composer.d.ts +92 -0
- package/dist/components/chat-composer/chat-composer.js +285 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +1 -0
- package/dist/components/chat-composer/chat-composer.styles.js +135 -0
- package/dist/components/chat-message/chat-message.d.ts +113 -0
- package/dist/components/chat-message/chat-message.js +291 -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 +59 -0
- package/dist/components/checkbox/checkbox.js +230 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.styles.js +70 -0
- package/dist/components/chip/chip-group.d.ts +56 -0
- package/dist/components/chip/chip-group.js +124 -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 +115 -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 +300 -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 +89 -0
- package/dist/components/code-block/code-block.js +317 -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 +44 -0
- package/dist/components/code-block/code-loader.js +79 -0
- package/dist/components/combobox/combobox.d.ts +19 -1
- package/dist/components/combobox/combobox.js +84 -14
- 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 +150 -0
- package/dist/components/context-meter/context-meter.styles.d.ts +1 -0
- package/dist/components/context-meter/context-meter.styles.js +120 -0
- package/dist/components/conversation-item/conversation-item.d.ts +128 -0
- package/dist/components/conversation-item/conversation-item.js +322 -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/date-input.d.ts +24 -0
- package/dist/components/date-picker/date-input.js +134 -22
- package/dist/components/date-picker/date-picker.d.ts +7 -0
- package/dist/components/date-picker/date-picker.js +85 -16
- package/dist/components/dialog/confirm.d.ts +40 -0
- package/dist/components/dialog/confirm.js +79 -0
- package/dist/components/dialog/dialog.d.ts +85 -0
- package/dist/components/dialog/dialog.js +272 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +52 -0
- package/dist/components/dock-panel/dock-panel.d.ts +134 -0
- package/dist/components/dock-panel/dock-panel.js +345 -0
- package/dist/components/dock-panel/dock-panel.styles.d.ts +1 -0
- package/dist/components/dock-panel/dock-panel.styles.js +145 -0
- package/dist/components/document-preview/document-preview.d.ts +135 -0
- package/dist/components/document-preview/document-preview.js +372 -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/export-button/csv.js +1 -1
- package/dist/components/export-button/export-button.js +2 -0
- package/dist/components/flag/flag.d.ts +42 -5
- package/dist/components/flag/flag.js +70 -3
- package/dist/components/gauge/gauge.js +19 -10
- package/dist/components/generation-status/generation-status.d.ts +109 -0
- package/dist/components/generation-status/generation-status.js +273 -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/heatmap/calendar-grid.d.ts +4 -1
- package/dist/components/heatmap/calendar-grid.js +25 -12
- package/dist/components/heatmap/heatmap-scale.d.ts +6 -0
- package/dist/components/heatmap/heatmap-scale.js +7 -1
- package/dist/components/heatmap/heatmap.d.ts +89 -3
- package/dist/components/heatmap/heatmap.js +158 -29
- package/dist/components/json-viewer/json-viewer.d.ts +53 -0
- package/dist/components/json-viewer/json-viewer.js +283 -0
- package/dist/components/json-viewer/json-viewer.styles.d.ts +1 -0
- package/dist/components/json-viewer/json-viewer.styles.js +176 -0
- package/dist/components/kbd/kbd.d.ts +77 -0
- package/dist/components/kbd/kbd.js +214 -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 +81 -0
- package/dist/components/live-region/live-region.js +153 -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 +8 -6
- package/dist/components/map/map.js +44 -8
- package/dist/components/markdown/markdown-loader.d.ts +34 -0
- package/dist/components/markdown/markdown-loader.js +43 -0
- package/dist/components/markdown/markdown.d.ts +81 -0
- package/dist/components/markdown/markdown.js +284 -0
- package/dist/components/markdown/markdown.styles.d.ts +1 -0
- package/dist/components/markdown/markdown.styles.js +82 -0
- package/dist/components/media-card/media-card.d.ts +122 -0
- package/dist/components/media-card/media-card.js +295 -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 +200 -0
- package/dist/components/mention-popover/mention-popover.js +475 -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 +62 -0
- package/dist/components/menu/menu-item.js +119 -0
- package/dist/components/menu/menu-item.styles.d.ts +1 -0
- package/dist/components/menu/menu-item.styles.js +67 -0
- package/dist/components/menu/menu.d.ts +143 -0
- package/dist/components/menu/menu.js +365 -0
- package/dist/components/menu/menu.styles.d.ts +1 -0
- package/dist/components/menu/menu.styles.js +66 -0
- package/dist/components/model-select/model-select.d.ts +125 -0
- package/dist/components/model-select/model-select.js +490 -0
- package/dist/components/model-select/model-select.styles.d.ts +1 -0
- package/dist/components/model-select/model-select.styles.js +189 -0
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +69 -0
- package/dist/components/model-settings-panel/model-settings-panel.js +145 -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 +13 -1
- package/dist/components/playback/playback.js +47 -14
- package/dist/components/responsive-panel/responsive-panel.d.ts +150 -0
- package/dist/components/responsive-panel/responsive-panel.js +365 -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 +44 -0
- package/dist/components/result-card/result-card.js +83 -0
- package/dist/components/result-card/result-card.styles.d.ts +1 -0
- package/dist/components/result-card/result-card.styles.js +50 -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 +45 -1
- package/dist/components/select/select.js +114 -17
- package/dist/components/select/select.styles.js +26 -2
- package/dist/components/slider/slider.d.ts +89 -0
- package/dist/components/slider/slider.js +352 -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 +92 -0
- package/dist/components/source-card/source-card.js +148 -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 +122 -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 +27 -13
- package/dist/components/split/split.d.ts +93 -1
- package/dist/components/split/split.js +284 -15
- package/dist/components/split/split.styles.js +30 -0
- package/dist/components/stat/stat.d.ts +22 -1
- package/dist/components/stat/stat.js +49 -3
- package/dist/components/stat/stat.styles.js +20 -0
- package/dist/components/stream-status/stream-status.d.ts +110 -0
- package/dist/components/stream-status/stream-status.js +210 -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 +98 -0
- package/dist/components/streaming-text/streaming-text.js +209 -0
- package/dist/components/streaming-text/streaming-text.styles.d.ts +1 -0
- package/dist/components/streaming-text/streaming-text.styles.js +62 -0
- package/dist/components/switch/switch.d.ts +58 -0
- package/dist/components/switch/switch.js +179 -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 +73 -4
- package/dist/components/table/table.js +169 -20
- package/dist/components/table/table.styles.js +6 -1
- package/dist/components/tabs/tabs.d.ts +51 -0
- package/dist/components/tabs/tabs.js +190 -0
- package/dist/components/tabs/tabs.styles.d.ts +1 -0
- package/dist/components/tabs/tabs.styles.js +63 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +121 -0
- package/dist/components/thinking-panel/thinking-panel.js +235 -0
- package/dist/components/thinking-panel/thinking-panel.styles.d.ts +1 -0
- package/dist/components/thinking-panel/thinking-panel.styles.js +117 -0
- package/dist/components/toast/toast-item.d.ts +1 -0
- package/dist/components/toast/toast-item.js +31 -6
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +130 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +403 -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 +89 -0
- package/dist/components/tool-call-chip/tool-call-chip.js +288 -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 +145 -0
- package/dist/components/tool-param-form/tool-param-form.js +366 -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 +102 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.js +393 -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 +81 -0
- package/dist/components/tool-result-view/registry.js +84 -0
- package/dist/components/tool-result-view/tool-result-view.d.ts +55 -0
- package/dist/components/tool-result-view/tool-result-view.js +138 -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 +439 -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 +182 -0
- package/dist/components/tree/tree-node.d.ts +11 -2
- package/dist/components/tree/tree-node.js +16 -6
- package/dist/components/tree/tree.d.ts +8 -2
- package/dist/components/tree/tree.js +18 -11
- package/dist/components/typing-indicator/typing-indicator.d.ts +60 -0
- package/dist/components/typing-indicator/typing-indicator.js +96 -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 +173 -0
- package/dist/components/virtual-list/virtual-list.js +461 -0
- package/dist/components/virtual-list/virtual-list.styles.d.ts +1 -0
- package/dist/components/virtual-list/virtual-list.styles.js +44 -0
- package/dist/components/widget/widget.d.ts +10 -0
- package/dist/components/widget/widget.js +24 -1
- package/dist/components/widget/widget.styles.js +9 -2
- package/dist/components/word-cloud/word-cloud-layout.js +14 -1
- package/dist/components/word-cloud/word-cloud.d.ts +6 -0
- package/dist/components/word-cloud/word-cloud.js +25 -14
- package/dist/components/word-cloud/word-cloud.styles.js +4 -2
- package/dist/internal/announcer.d.ts +57 -0
- package/dist/internal/announcer.js +71 -0
- package/dist/internal/form-associated.d.ts +1 -0
- package/dist/internal/form-associated.js +55 -11
- package/dist/internal/group-by-recency.d.ts +50 -0
- package/dist/internal/group-by-recency.js +80 -0
- package/dist/internal/rtl.d.ts +23 -0
- package/dist/internal/rtl.js +28 -0
- package/dist/internal/scroll-lock.d.ts +10 -5
- package/dist/internal/scroll-lock.js +30 -14
- package/dist/internal/tokens.styles.js +6 -0
- package/dist/lyra.d.ts +130 -31
- package/dist/lyra.js +94 -26
- package/llms-full.txt +3921 -32
- package/llms.txt +16 -1
- package/package.json +23 -5
- 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 -12
- package/dist/components/chart/lite-chart.stories.js +0 -98
- 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 -5
- package/dist/components/flag/flag.stories.js +0 -17
- 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 -22
- package/dist/components/heatmap/heatmap.stories.js +0 -154
- 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 -19
- package/dist/components/select/select.stories.js +0 -75
- 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 -8
- package/dist/components/stat/stat.stories.js +0 -64
- 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 -7
- package/dist/components/widget/widget.stories.js +0 -41
- package/dist/components/word-cloud/word-cloud.stories.d.ts +0 -10
- package/dist/components/word-cloud/word-cloud.stories.js +0 -55
|
@@ -150,22 +150,33 @@ export class LyraWordCloud extends LyraElement {
|
|
|
150
150
|
changed.has('maxFontSize') ||
|
|
151
151
|
changed.has('scale') ||
|
|
152
152
|
changed.has('orientations')) {
|
|
153
|
-
this.
|
|
154
|
-
minFontSize: this.minFontSize,
|
|
155
|
-
maxFontSize: this.maxFontSize,
|
|
156
|
-
scale: this.scale,
|
|
157
|
-
orientations: this.orientations,
|
|
158
|
-
measureText: this.measureText,
|
|
159
|
-
});
|
|
160
|
-
if (this.cachedLayout.skipped.length > 0)
|
|
161
|
-
warnSkippedWords(this.cachedLayout.skipped.length);
|
|
162
|
-
// The previous focus cursor may no longer address a real word once the
|
|
163
|
-
// data changes out from under it.
|
|
164
|
-
this.focusedIndex = null;
|
|
165
|
-
this.liveText = '';
|
|
153
|
+
this.relayout();
|
|
166
154
|
}
|
|
167
155
|
this.setAttribute('role', 'group');
|
|
168
|
-
this.setAttribute('aria-label', `Word cloud of ${this.
|
|
156
|
+
this.setAttribute('aria-label', `Word cloud of ${this.cachedLayout.placed.length} word${this.cachedLayout.placed.length === 1 ? '' : 's'}`);
|
|
157
|
+
}
|
|
158
|
+
relayout() {
|
|
159
|
+
this.cachedLayout = layoutWordCloud(this.words, {
|
|
160
|
+
minFontSize: this.minFontSize,
|
|
161
|
+
maxFontSize: this.maxFontSize,
|
|
162
|
+
scale: this.scale,
|
|
163
|
+
orientations: this.orientations,
|
|
164
|
+
measureText: this.measureText,
|
|
165
|
+
});
|
|
166
|
+
if (this.cachedLayout.skipped.length > 0)
|
|
167
|
+
warnSkippedWords(this.cachedLayout.skipped.length);
|
|
168
|
+
// The previous focus cursor may no longer address a real word once the
|
|
169
|
+
// data changes out from under it.
|
|
170
|
+
this.focusedIndex = null;
|
|
171
|
+
this.liveText = '';
|
|
172
|
+
}
|
|
173
|
+
/** Forces a relayout so the font-family theme token (`--lyra-font`) is
|
|
174
|
+
* re-read from computed style — mirrors `lyra-chart`'s `refreshTheme()`.
|
|
175
|
+
* No global theme-broadcast event exists in lyra-ui to subscribe to
|
|
176
|
+
* automatically; call this from a consumer's own theme-toggle handler. */
|
|
177
|
+
refreshTheme() {
|
|
178
|
+
this.relayout();
|
|
179
|
+
this.requestUpdate();
|
|
169
180
|
}
|
|
170
181
|
activate(word) {
|
|
171
182
|
this.emit('lyra-word-click', { text: word.text, weight: word.weight, group: word.group });
|
|
@@ -20,6 +20,7 @@ export const styles = css `
|
|
|
20
20
|
display: flex;
|
|
21
21
|
flex-direction: column;
|
|
22
22
|
gap: var(--lyra-space-xs);
|
|
23
|
+
block-size: 100%;
|
|
23
24
|
}
|
|
24
25
|
svg {
|
|
25
26
|
display: block;
|
|
@@ -36,10 +37,11 @@ export const styles = css `
|
|
|
36
37
|
font-weight: 600;
|
|
37
38
|
text-anchor: middle;
|
|
38
39
|
dominant-baseline: middle;
|
|
39
|
-
transition:
|
|
40
|
+
transition: text-decoration-color var(--lyra-transition-fast);
|
|
41
|
+
text-decoration: underline transparent;
|
|
40
42
|
}
|
|
41
43
|
[part='word']:hover {
|
|
42
|
-
|
|
44
|
+
text-decoration-color: currentColor;
|
|
43
45
|
}
|
|
44
46
|
[part='focus-ring'] {
|
|
45
47
|
fill: none;
|
|
@@ -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
|
+
}
|
|
@@ -13,16 +13,22 @@ export function FormAssociated(Base) {
|
|
|
13
13
|
class FormAssociatedElement extends Base {
|
|
14
14
|
static { this.formAssociated = true; }
|
|
15
15
|
static { this.properties = {
|
|
16
|
-
name: {},
|
|
16
|
+
name: { reflect: true, noAccessor: true },
|
|
17
17
|
value: { noAccessor: true },
|
|
18
18
|
disabled: { type: Boolean, reflect: true },
|
|
19
|
-
required: { type: Boolean, reflect: true },
|
|
19
|
+
required: { type: Boolean, reflect: true, noAccessor: true },
|
|
20
20
|
}; }
|
|
21
21
|
constructor(...args) {
|
|
22
22
|
super(...args);
|
|
23
|
-
this.name = '';
|
|
24
23
|
this.disabled = false;
|
|
25
|
-
this.
|
|
24
|
+
this._fieldsetDisabled = false;
|
|
25
|
+
// Hand-written accessor (mirrors `value`/`required` below): native form
|
|
26
|
+
// submission for a form-associated custom element keys its `FormData`
|
|
27
|
+
// entry off the `name` *content attribute*, read synchronously at
|
|
28
|
+
// submission time — an async (Lit-scheduled) reflection would leave a
|
|
29
|
+
// property-only assignment like `el.name = 'foo'` invisible to a
|
|
30
|
+
// same-tick `new FormData(form)`/submit.
|
|
31
|
+
this._name = '';
|
|
26
32
|
this._value = '';
|
|
27
33
|
// What native `defaultValue`/`form.reset()` restores to. Mirrors the
|
|
28
34
|
// `value` *content attribute* only (see `attributeChangedCallback`
|
|
@@ -34,7 +40,26 @@ export function FormAssociated(Base) {
|
|
|
34
40
|
// first" would wrongly let a user's first-ever edit become permanent
|
|
35
41
|
// (a required field could never be reset back to blank again).
|
|
36
42
|
this._defaultValue = '';
|
|
43
|
+
this._required = false;
|
|
37
44
|
this.internals = this.attachInternals();
|
|
45
|
+
// Native <input> always has a submission value ("") from construction —
|
|
46
|
+
// without this, a control whose `value` is never touched is entirely
|
|
47
|
+
// absent from FormData instead of present as "".
|
|
48
|
+
this.internals.setFormValue('');
|
|
49
|
+
}
|
|
50
|
+
get name() {
|
|
51
|
+
return this._name;
|
|
52
|
+
}
|
|
53
|
+
set name(next) {
|
|
54
|
+
const old = this._name;
|
|
55
|
+
this._name = next ?? '';
|
|
56
|
+
if (this._name) {
|
|
57
|
+
this.setAttribute('name', this._name);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.removeAttribute('name');
|
|
61
|
+
}
|
|
62
|
+
this.requestUpdate('name', old);
|
|
38
63
|
}
|
|
39
64
|
get value() {
|
|
40
65
|
return this._value;
|
|
@@ -46,6 +71,22 @@ export function FormAssociated(Base) {
|
|
|
46
71
|
this.updateValidity();
|
|
47
72
|
this.requestUpdate('value', old);
|
|
48
73
|
}
|
|
74
|
+
get required() {
|
|
75
|
+
return this._required;
|
|
76
|
+
}
|
|
77
|
+
set required(next) {
|
|
78
|
+
const old = this._required;
|
|
79
|
+
this._required = next;
|
|
80
|
+
this.toggleAttribute('required', next);
|
|
81
|
+
this.updateValidity();
|
|
82
|
+
this.requestUpdate('required', old);
|
|
83
|
+
}
|
|
84
|
+
/** Effective disabled state: this element's own `disabled` OR an ancestor
|
|
85
|
+
* `<fieldset disabled>`'s inherited state — mirrors native `<input>`, whose
|
|
86
|
+
* own `disabled` IDL property/attribute is never mutated by a fieldset. */
|
|
87
|
+
get effectiveDisabled() {
|
|
88
|
+
return this.disabled || this._fieldsetDisabled;
|
|
89
|
+
}
|
|
49
90
|
attributeChangedCallback(name, old, value) {
|
|
50
91
|
super.attributeChangedCallback(name, old, value);
|
|
51
92
|
if (name === 'value') {
|
|
@@ -83,8 +124,16 @@ export function FormAssociated(Base) {
|
|
|
83
124
|
// semantics) — previously this unconditionally blanked the field.
|
|
84
125
|
this.value = this._defaultValue;
|
|
85
126
|
}
|
|
86
|
-
|
|
87
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Called by the browser when an ancestor `<fieldset disabled>` toggles.
|
|
129
|
+
* Tracked separately from the consumer's own `disabled` (see
|
|
130
|
+
* `effectiveDisabled`) — a native `<input>`'s own `disabled` IDL
|
|
131
|
+
* property/attribute is never mutated by fieldset cascading, so a
|
|
132
|
+
* consumer's explicit `disabled` must survive the fieldset re-enabling.
|
|
133
|
+
*/
|
|
134
|
+
formDisabledCallback(fieldsetDisabled) {
|
|
135
|
+
this._fieldsetDisabled = fieldsetDisabled;
|
|
136
|
+
this.requestUpdate();
|
|
88
137
|
}
|
|
89
138
|
connectedCallback() {
|
|
90
139
|
super.connectedCallback();
|
|
@@ -93,11 +142,6 @@ export function FormAssociated(Base) {
|
|
|
93
142
|
// `value` write.
|
|
94
143
|
this.updateValidity();
|
|
95
144
|
}
|
|
96
|
-
updated(changed) {
|
|
97
|
-
super.updated(changed);
|
|
98
|
-
if (changed.has('required'))
|
|
99
|
-
this.updateValidity();
|
|
100
|
-
}
|
|
101
145
|
}
|
|
102
146
|
return FormAssociatedElement;
|
|
103
147
|
}
|
|
@@ -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
|
+
}
|
package/dist/internal/rtl.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Placement } from '@floating-ui/dom';
|
|
1
2
|
/**
|
|
2
3
|
* Whether `el` resolves to RTL text direction. Logical CSS properties
|
|
3
4
|
* (`inset-inline-start`, etc.) already flip visual layout for free, but
|
|
@@ -5,3 +6,25 @@
|
|
|
5
6
|
* arrow-key direction) has to consult this explicitly to match.
|
|
6
7
|
*/
|
|
7
8
|
export declare function isRtl(el: Element): boolean;
|
|
9
|
+
/** A physical (not logical) horizontal side. */
|
|
10
|
+
export type PhysicalSide = 'left' | 'right';
|
|
11
|
+
/**
|
|
12
|
+
* Swaps `side` under RTL, passes it through unchanged under LTR -- for
|
|
13
|
+
* reasoning about a physical side (e.g. which edge an icon should point at,
|
|
14
|
+
* or which edge of a track a dock panel resizes from) that logical CSS
|
|
15
|
+
* properties alone can't express, since the caller needs the resolved
|
|
16
|
+
* physical value itself (to rotate a glyph, to pick a Floating UI
|
|
17
|
+
* `Placement`), not just a layout that flips for free.
|
|
18
|
+
*/
|
|
19
|
+
export declare function rtlAwareSide(side: PhysicalSide, el: Element): PhysicalSide;
|
|
20
|
+
/**
|
|
21
|
+
* Swaps the `left`/`right` component of a Floating UI `Placement` under RTL
|
|
22
|
+
* (`'right-start'` <-> `'left-start'`, etc.) -- `'top'`/`'bottom'`-based
|
|
23
|
+
* placements are already direction-agnostic and pass through unchanged.
|
|
24
|
+
* Floating UI's own `computePosition()` has no built-in RTL awareness (it
|
|
25
|
+
* positions purely by the physical `left`/`right`/`top`/`bottom` it's given),
|
|
26
|
+
* so a popover that means "anchor to my trailing edge" must resolve that
|
|
27
|
+
* intent to a physical placement itself before calling `place()` from
|
|
28
|
+
* `positioner.ts` -- this is the resolution step.
|
|
29
|
+
*/
|
|
30
|
+
export declare function rtlAwarePlacement(placement: Placement, el: Element): Placement;
|
package/dist/internal/rtl.js
CHANGED
|
@@ -7,3 +7,31 @@
|
|
|
7
7
|
export function isRtl(el) {
|
|
8
8
|
return getComputedStyle(el).direction === 'rtl';
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Swaps `side` under RTL, passes it through unchanged under LTR -- for
|
|
12
|
+
* reasoning about a physical side (e.g. which edge an icon should point at,
|
|
13
|
+
* or which edge of a track a dock panel resizes from) that logical CSS
|
|
14
|
+
* properties alone can't express, since the caller needs the resolved
|
|
15
|
+
* physical value itself (to rotate a glyph, to pick a Floating UI
|
|
16
|
+
* `Placement`), not just a layout that flips for free.
|
|
17
|
+
*/
|
|
18
|
+
export function rtlAwareSide(side, el) {
|
|
19
|
+
if (!isRtl(el))
|
|
20
|
+
return side;
|
|
21
|
+
return side === 'left' ? 'right' : 'left';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Swaps the `left`/`right` component of a Floating UI `Placement` under RTL
|
|
25
|
+
* (`'right-start'` <-> `'left-start'`, etc.) -- `'top'`/`'bottom'`-based
|
|
26
|
+
* placements are already direction-agnostic and pass through unchanged.
|
|
27
|
+
* Floating UI's own `computePosition()` has no built-in RTL awareness (it
|
|
28
|
+
* positions purely by the physical `left`/`right`/`top`/`bottom` it's given),
|
|
29
|
+
* so a popover that means "anchor to my trailing edge" must resolve that
|
|
30
|
+
* intent to a physical placement itself before calling `place()` from
|
|
31
|
+
* `positioner.ts` -- this is the resolution step.
|
|
32
|
+
*/
|
|
33
|
+
export function rtlAwarePlacement(placement, el) {
|
|
34
|
+
if (!isRtl(el))
|
|
35
|
+
return placement;
|
|
36
|
+
return placement.replace(/^(left|right)/, (side) => (side === 'left' ? 'right' : 'left'));
|
|
37
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ref-counted
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Ref-counted scroll lock, scoped to a given `Document` (defaults to the
|
|
3
|
+
* caller's own top-level `document`) so it also works for content rendered
|
|
4
|
+
* inside an iframe or any other document the caller explicitly passes.
|
|
5
|
+
* Compensates for the removed scrollbar's width with inline-end padding on
|
|
6
|
+
* the root element, so locking scroll doesn't shift page content
|
|
7
|
+
* horizontally the instant the scrollbar disappears — restored to its prior
|
|
8
|
+
* value once the last outstanding lock releases. Safe when a lock is
|
|
9
|
+
* acquired and released more than once concurrently (e.g. a fast
|
|
10
|
+
* open/close/open sequence).
|
|
6
11
|
*/
|
|
7
|
-
export declare function lockScroll(): () => void;
|
|
12
|
+
export declare function lockScroll(doc?: Document): () => void;
|
|
@@ -1,25 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const counts = new WeakMap();
|
|
2
|
+
const previousOverflow = new WeakMap();
|
|
3
|
+
const previousPadding = new WeakMap();
|
|
3
4
|
/**
|
|
4
|
-
* Ref-counted
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Ref-counted scroll lock, scoped to a given `Document` (defaults to the
|
|
6
|
+
* caller's own top-level `document`) so it also works for content rendered
|
|
7
|
+
* inside an iframe or any other document the caller explicitly passes.
|
|
8
|
+
* Compensates for the removed scrollbar's width with inline-end padding on
|
|
9
|
+
* the root element, so locking scroll doesn't shift page content
|
|
10
|
+
* horizontally the instant the scrollbar disappears — restored to its prior
|
|
11
|
+
* value once the last outstanding lock releases. Safe when a lock is
|
|
12
|
+
* acquired and released more than once concurrently (e.g. a fast
|
|
13
|
+
* open/close/open sequence).
|
|
8
14
|
*/
|
|
9
|
-
export function lockScroll() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
export function lockScroll(doc = document) {
|
|
16
|
+
const root = doc.documentElement;
|
|
17
|
+
const count = counts.get(doc) ?? 0;
|
|
18
|
+
if (count === 0) {
|
|
19
|
+
previousOverflow.set(doc, root.style.overflow);
|
|
20
|
+
previousPadding.set(doc, root.style.paddingInlineEnd);
|
|
21
|
+
const scrollbarWidth = (doc.defaultView?.innerWidth ?? 0) - root.clientWidth;
|
|
22
|
+
root.style.overflow = 'hidden';
|
|
23
|
+
if (scrollbarWidth > 0) {
|
|
24
|
+
const currentPadding = parseFloat(getComputedStyle(root).paddingInlineEnd) || 0;
|
|
25
|
+
root.style.paddingInlineEnd = `${currentPadding + scrollbarWidth}px`;
|
|
26
|
+
}
|
|
13
27
|
}
|
|
14
|
-
|
|
28
|
+
counts.set(doc, count + 1);
|
|
15
29
|
let released = false;
|
|
16
30
|
return () => {
|
|
17
31
|
if (released)
|
|
18
32
|
return;
|
|
19
33
|
released = true;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
const remaining = (counts.get(doc) ?? 1) - 1;
|
|
35
|
+
counts.set(doc, remaining);
|
|
36
|
+
if (remaining === 0) {
|
|
37
|
+
root.style.overflow = previousOverflow.get(doc) ?? '';
|
|
38
|
+
root.style.paddingInlineEnd = previousPadding.get(doc) ?? '';
|
|
23
39
|
}
|
|
24
40
|
};
|
|
25
41
|
}
|
|
@@ -10,8 +10,11 @@ export const tokens = css `
|
|
|
10
10
|
--lyra-color-brand: var(--wa-color-brand-fill-loud, #0969da);
|
|
11
11
|
--lyra-color-brand-quiet: var(--wa-color-brand-fill-quiet, #ddf4ff);
|
|
12
12
|
--lyra-color-success: var(--wa-color-success-fill-loud, #1a7f37);
|
|
13
|
+
--lyra-color-success-quiet: var(--wa-color-success-fill-quiet, #dafbe1);
|
|
13
14
|
--lyra-color-warning: var(--wa-color-warning-fill-loud, #9a6700);
|
|
15
|
+
--lyra-color-warning-quiet: var(--wa-color-warning-fill-quiet, #fff8c5);
|
|
14
16
|
--lyra-color-danger: var(--wa-color-danger-fill-loud, #cf222e);
|
|
17
|
+
--lyra-color-danger-quiet: var(--wa-color-danger-fill-quiet, #ffebe9);
|
|
15
18
|
/* Text/icon color for content painted on top of a solid brand-fill
|
|
16
19
|
background (selected calendar days, filled badges, etc.) -- almost
|
|
17
20
|
always white on both the light and dark brand fills above, so it's
|
|
@@ -65,8 +68,11 @@ export const tokens = css `
|
|
|
65
68
|
--lyra-color-brand: var(--wa-color-brand-fill-loud, #4d9fef);
|
|
66
69
|
--lyra-color-brand-quiet: var(--wa-color-brand-fill-quiet, #163650);
|
|
67
70
|
--lyra-color-success: var(--wa-color-success-fill-loud, #3fb950);
|
|
71
|
+
--lyra-color-success-quiet: var(--wa-color-success-fill-quiet, #1b4721);
|
|
68
72
|
--lyra-color-warning: var(--wa-color-warning-fill-loud, #d29922);
|
|
73
|
+
--lyra-color-warning-quiet: var(--wa-color-warning-fill-quiet, #3b2900);
|
|
69
74
|
--lyra-color-danger: var(--wa-color-danger-fill-loud, #f85149);
|
|
75
|
+
--lyra-color-danger-quiet: var(--wa-color-danger-fill-quiet, #4c1210);
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
:host([hidden]) {
|