@fusion.dev/helix-headless 0.143.0 → 0.145.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/custom-elements.json +16990 -1383
- package/dist/accordion/item/accordion-item.d.ts +48 -12
- package/dist/accordion/item/accordion-item.js +26 -5
- package/dist/accordion/root/accordion-root.d.ts +6 -0
- package/dist/accordion/root/accordion-root.js +7 -1
- package/dist/announcement/root/announcement-root.d.ts +21 -1
- package/dist/announcement/root/announcement-root.js +36 -1
- package/dist/app-header/root/app-header-root.d.ts +7 -0
- package/dist/app-header/root/app-header-root.js +5 -1
- package/dist/app-header/sectioning.d.ts +7 -0
- package/dist/app-header/sectioning.js +26 -0
- package/dist/area-chart/root/area-chart-root.d.ts +12 -4
- package/dist/area-chart/root/area-chart-root.js +24 -7
- package/dist/avatar/root/avatar-root.d.ts +14 -0
- package/dist/avatar/root/avatar-root.js +23 -9
- package/dist/badge/root/badge-root.d.ts +11 -7
- package/dist/badge/root/badge-root.js +1 -1
- package/dist/bar-chart/root/bar-chart-root.d.ts +12 -3
- package/dist/bar-chart/root/bar-chart-root.js +17 -10
- package/dist/breadcrumbs/root/breadcrumbs-root.d.ts +32 -1
- package/dist/breadcrumbs/root/breadcrumbs-root.js +25 -2
- package/dist/button/root/button-root.d.ts +47 -1
- package/dist/button/root/button-root.js +38 -4
- package/dist/callout/root/callout-root.d.ts +18 -1
- package/dist/callout/root/callout-root.js +15 -4
- package/dist/canvas/root/canvas-root.d.ts +38 -3
- package/dist/canvas/root/canvas-root.js +121 -40
- package/dist/card/root/card-root.d.ts +30 -1
- package/dist/card/root/card-root.js +38 -5
- package/dist/carousel/root/carousel-root.d.ts +90 -0
- package/dist/carousel/root/carousel-root.js +134 -12
- package/dist/chat/composer/chat-composer.d.ts +38 -6
- package/dist/chat/composer/chat-composer.js +42 -9
- package/dist/chat/message/chat-message.d.ts +32 -1
- package/dist/chat/message/chat-message.js +25 -9
- package/dist/chat/naming.d.ts +22 -0
- package/dist/chat/naming.js +12 -0
- package/dist/chat/relative-clock.d.ts +39 -0
- package/dist/chat/relative-clock.js +31 -0
- package/dist/chat/root/chat-root.d.ts +36 -0
- package/dist/chat/root/chat-root.js +24 -1
- package/dist/checkbox/root/checkbox-root.js +2 -0
- package/dist/checkbox-group/root/checkbox-group-root.d.ts +53 -3
- package/dist/checkbox-group/root/checkbox-group-root.js +71 -22
- package/dist/code-block/lines.d.ts +13 -0
- package/dist/code-block/lines.js +2 -0
- package/dist/code-block/root/code-block-root.d.ts +38 -1
- package/dist/code-block/root/code-block-root.js +28 -7
- package/dist/color-input/root/color-input-root.d.ts +34 -1
- package/dist/color-input/root/color-input-root.js +23 -4
- package/dist/color-picker/channels.d.ts +26 -0
- package/dist/color-picker/channels.js +84 -0
- package/dist/color-picker/root/color-picker-root.d.ts +81 -5
- package/dist/color-picker/root/color-picker-root.js +103 -10
- package/dist/combobox/root/combobox-root.d.ts +38 -3
- package/dist/combobox/root/combobox-root.js +64 -2
- package/dist/command/root/command-root.d.ts +30 -4
- package/dist/command/root/command-root.js +33 -3
- package/dist/copy-button/from.d.ts +22 -0
- package/dist/copy-button/from.js +28 -0
- package/dist/copy-button/root/copy-button-root.d.ts +47 -1
- package/dist/copy-button/root/copy-button-root.js +44 -8
- package/dist/data-table/root/data-table-root.d.ts +150 -2
- package/dist/data-table/root/data-table-root.js +303 -29
- package/dist/data-table/tree.d.ts +40 -0
- package/dist/data-table/tree.js +55 -0
- package/dist/date-input/root/date-input-root.d.ts +73 -4
- package/dist/date-input/root/date-input-root.js +93 -43
- package/dist/date-picker/root/date-picker-root.d.ts +145 -1
- package/dist/date-picker/root/date-picker-root.js +239 -48
- package/dist/description-list/item/description-list-item.d.ts +17 -2
- package/dist/description-list/item/description-list-item.js +15 -2
- package/dist/description-list/root/description-list-root.d.ts +27 -1
- package/dist/description-list/root/description-list-root.js +26 -1
- package/dist/dialog/description.d.ts +9 -0
- package/dist/dialog/description.js +14 -0
- package/dist/dialog/root/dialog-root.d.ts +64 -1
- package/dist/dialog/root/dialog-root.js +49 -23
- package/dist/donut-chart/root/donut-chart-root.d.ts +25 -4
- package/dist/donut-chart/root/donut-chart-root.js +21 -6
- package/dist/drawer/root/drawer-root.d.ts +63 -2
- package/dist/drawer/root/drawer-root.js +95 -19
- package/dist/drawer/swipe-start.d.ts +9 -0
- package/dist/drawer/swipe-start.js +12 -0
- package/dist/drilldown/item/drilldown-item.d.ts +11 -6
- package/dist/drilldown/item/drilldown-item.js +8 -5
- package/dist/drilldown/root/drilldown-root.d.ts +11 -0
- package/dist/drilldown/root/drilldown-root.js +8 -3
- package/dist/element-events.generated.js +61 -13
- package/dist/empty/root/empty-root.d.ts +1 -1
- package/dist/file-input/root/file-input-root.d.ts +47 -0
- package/dist/file-input/root/file-input-root.js +60 -22
- package/dist/file-input/screen.d.ts +35 -0
- package/dist/file-input/screen.js +49 -0
- package/dist/filter-input/menu/filter-menu.d.ts +3 -0
- package/dist/filter-input/menu/filter-menu.js +8 -4
- package/dist/filter-input/root/filter-input-root.d.ts +38 -4
- package/dist/filter-input/root/filter-input-root.js +67 -3
- package/dist/filter-input/suggest.d.ts +17 -0
- package/dist/filter-input/suggest.js +23 -0
- package/dist/format-date/options.d.ts +33 -0
- package/dist/format-date/options.js +42 -0
- package/dist/format-date/root/format-date-root.d.ts +51 -0
- package/dist/format-date/root/format-date-root.js +58 -38
- package/dist/heatmap/root/heatmap-root.d.ts +23 -6
- package/dist/heatmap/root/heatmap-root.js +24 -13
- package/dist/icon/index.d.ts +2 -0
- package/dist/icon/index.js +2 -0
- package/dist/icon/registry.d.ts +37 -0
- package/dist/icon/registry.js +83 -0
- package/dist/icon/root/icon-root.d.ts +30 -4
- package/dist/icon/root/icon-root.js +41 -6
- package/dist/icon/root/index.d.ts +2 -0
- package/dist/icon/root/index.js +2 -0
- package/dist/icon/set.d.ts +1 -0
- package/dist/icon/set.js +3 -0
- package/dist/image/root/image-root.d.ts +14 -0
- package/dist/image/root/image-root.js +23 -2
- package/dist/input/root/input-root.d.ts +11 -0
- package/dist/input/root/input-root.js +16 -1
- package/dist/kbd/root/kbd-root.d.ts +20 -13
- package/dist/kbd/root/kbd-root.js +35 -37
- package/dist/kbd/shortcut.d.ts +18 -0
- package/dist/kbd/shortcut.js +35 -0
- package/dist/legend/hidden-series.d.ts +8 -0
- package/dist/legend/hidden-series.js +13 -0
- package/dist/legend/root/legend-root.d.ts +56 -0
- package/dist/legend/root/legend-root.js +54 -5
- package/dist/lightbox/item/lightbox-item.d.ts +15 -0
- package/dist/lightbox/item/lightbox-item.js +10 -1
- package/dist/lightbox/root/lightbox-root.d.ts +61 -1
- package/dist/lightbox/root/lightbox-root.js +94 -4
- package/dist/line-chart/root/line-chart-root.d.ts +11 -3
- package/dist/line-chart/root/line-chart-root.js +19 -5
- package/dist/list/item/list-item.d.ts +68 -1
- package/dist/list/item/list-item.js +66 -4
- package/dist/list/numbering.d.ts +14 -0
- package/dist/list/numbering.js +8 -0
- package/dist/list/root/list-root.d.ts +106 -9
- package/dist/list/root/list-root.js +189 -4
- package/dist/list/selection.d.ts +19 -0
- package/dist/list/selection.js +21 -0
- package/dist/listbox/root/listbox-root.d.ts +74 -3
- package/dist/listbox/root/listbox-root.js +86 -9
- package/dist/loader/busy.d.ts +17 -0
- package/dist/loader/busy.js +24 -0
- package/dist/loader/root/loader-root.d.ts +37 -0
- package/dist/loader/root/loader-root.js +52 -3
- package/dist/map/root/map-root.d.ts +6 -2
- package/dist/map/root/map-root.js +5 -2
- package/dist/megamenu/root/megamenu-root.d.ts +21 -0
- package/dist/megamenu/root/megamenu-root.js +16 -2
- package/dist/menu/index.d.ts +1 -0
- package/dist/menu/index.js +1 -0
- package/dist/menu/item/menu-item.d.ts +38 -11
- package/dist/menu/item/menu-item.js +33 -1
- package/dist/menu/root/menu-root.d.ts +25 -1
- package/dist/menu/root/menu-root.js +63 -6
- package/dist/menu/section/menu-section.d.ts +55 -0
- package/dist/menu/section/menu-section.js +60 -0
- package/dist/meter/root/meter-root.d.ts +7 -0
- package/dist/meter/root/meter-root.js +6 -3
- package/dist/navigation/root/navigation-root.d.ts +16 -1
- package/dist/navigation/root/navigation-root.js +27 -1
- package/dist/notifications/feed-keys.d.ts +10 -0
- package/dist/notifications/feed-keys.js +14 -0
- package/dist/notifications/notification/notification.d.ts +17 -0
- package/dist/notifications/notification/notification.js +21 -2
- package/dist/notifications/root/notifications-root.d.ts +60 -0
- package/dist/notifications/root/notifications-root.js +76 -1
- package/dist/number-input/root/number-input-root.d.ts +47 -0
- package/dist/number-input/root/number-input-root.js +58 -22
- package/dist/object-inspector/root/object-inspector-root.d.ts +98 -16
- package/dist/object-inspector/root/object-inspector-root.js +180 -80
- package/dist/object-inspector/rows.d.ts +57 -0
- package/dist/object-inspector/rows.js +86 -0
- package/dist/option/root/option-root.d.ts +54 -5
- package/dist/option/root/option-root.js +34 -5
- package/dist/outline/levels.d.ts +31 -0
- package/dist/outline/levels.js +23 -0
- package/dist/outline/root/outline-root.d.ts +68 -3
- package/dist/outline/root/outline-root.js +73 -8
- package/dist/pagination/size/pagination-size.d.ts +11 -2
- package/dist/pagination/size/pagination-size.js +19 -4
- package/dist/pin-input/format.d.ts +7 -0
- package/dist/pin-input/format.js +16 -0
- package/dist/pin-input/root/pin-input-root.d.ts +21 -0
- package/dist/pin-input/root/pin-input-root.js +29 -2
- package/dist/popover/root/popover-root.d.ts +62 -4
- package/dist/popover/root/popover-root.js +53 -5
- package/dist/progress/root/progress-root.d.ts +7 -0
- package/dist/progress/root/progress-root.js +9 -3
- package/dist/qr-code/export.d.ts +31 -0
- package/dist/qr-code/export.js +10 -0
- package/dist/qr-code/root/qr-code-root.d.ts +26 -0
- package/dist/qr-code/root/qr-code-root.js +49 -2
- package/dist/radio/group/radio-group.d.ts +17 -0
- package/dist/radio/group/radio-group.js +14 -1
- package/dist/rating/root/rating-root.d.ts +25 -0
- package/dist/rating/root/rating-root.js +46 -4
- package/dist/scatter-chart/root/scatter-chart-root.d.ts +17 -3
- package/dist/scatter-chart/root/scatter-chart-root.js +25 -7
- package/dist/scroll-area/root/scroll-area-root.d.ts +113 -0
- package/dist/scroll-area/root/scroll-area-root.js +218 -3
- package/dist/scroll-area/scrollbar.d.ts +65 -0
- package/dist/scroll-area/scrollbar.js +24 -0
- package/dist/select/root/select-root.d.ts +24 -0
- package/dist/select/root/select-root.js +21 -7
- package/dist/skeleton/root/skeleton-root.d.ts +25 -0
- package/dist/skeleton/root/skeleton-root.js +17 -2
- package/dist/slider/root/slider-root.d.ts +39 -0
- package/dist/slider/root/slider-root.js +45 -9
- package/dist/splitter/root/splitter-root.d.ts +13 -0
- package/dist/splitter/root/splitter-root.js +20 -2
- package/dist/splitter/snap.d.ts +9 -0
- package/dist/splitter/snap.js +12 -0
- package/dist/stat/root/stat-root.d.ts +2 -0
- package/dist/stat/root/stat-root.js +1 -1
- package/dist/steps/reach.d.ts +15 -0
- package/dist/steps/reach.js +12 -0
- package/dist/steps/root/steps-root.d.ts +30 -0
- package/dist/steps/root/steps-root.js +53 -0
- package/dist/steps/step/step.d.ts +39 -2
- package/dist/steps/step/step.js +29 -7
- package/dist/switch/root/switch-root.d.ts +12 -2
- package/dist/switch/root/switch-root.js +6 -1
- package/dist/table/column/table-column.d.ts +11 -0
- package/dist/table/column/table-column.js +6 -1
- package/dist/table/root/table-root.d.ts +101 -0
- package/dist/table/root/table-root.js +166 -5
- package/dist/table/row/table-row.d.ts +47 -1
- package/dist/table/row/table-row.js +39 -2
- package/dist/tabs/panel/tab-panel.d.ts +9 -5
- package/dist/tabs/panel/tab-panel.js +3 -4
- package/dist/tabs/root/tabs-root.d.ts +25 -1
- package/dist/tabs/root/tabs-root.js +21 -3
- package/dist/tabs/tab/tab.d.ts +36 -4
- package/dist/tabs/tab/tab.js +46 -3
- package/dist/tag/group/tag-group.d.ts +107 -0
- package/dist/tag/group/tag-group.js +157 -0
- package/dist/tag/index.d.ts +1 -0
- package/dist/tag/index.js +1 -0
- package/dist/tag/root/tag-root.d.ts +60 -0
- package/dist/tag/root/tag-root.js +74 -18
- package/dist/tag/selection.d.ts +10 -0
- package/dist/tag/selection.js +12 -0
- package/dist/textarea/grow.d.ts +22 -0
- package/dist/textarea/grow.js +20 -0
- package/dist/textarea/root/textarea-root.d.ts +9 -0
- package/dist/textarea/root/textarea-root.js +9 -1
- package/dist/time-input/root/time-input-root.d.ts +44 -5
- package/dist/time-input/root/time-input-root.js +69 -39
- package/dist/time-picker/root/time-picker-root.d.ts +54 -8
- package/dist/time-picker/root/time-picker-root.js +121 -91
- package/dist/timeline/group/timeline-group.d.ts +46 -0
- package/dist/timeline/group/timeline-group.js +37 -0
- package/dist/timeline/index.d.ts +1 -0
- package/dist/timeline/index.js +1 -0
- package/dist/timeline/root/timeline-root.d.ts +10 -3
- package/dist/toast/hotkey.d.ts +22 -0
- package/dist/toast/hotkey.js +23 -0
- package/dist/toast/item/toast-item.d.ts +26 -18
- package/dist/toast/item/toast-item.js +55 -48
- package/dist/toast/root/toast-root.d.ts +42 -8
- package/dist/toast/root/toast-root.js +64 -4
- package/dist/toggle/group/toggle-group.d.ts +57 -15
- package/dist/toggle/group/toggle-group.js +69 -9
- package/dist/toggle/root/toggle-root.d.ts +12 -1
- package/dist/toggle/root/toggle-root.js +11 -3
- package/dist/toolbar/root/toolbar-root.d.ts +13 -0
- package/dist/toolbar/root/toolbar-root.js +15 -5
- package/dist/tooltip/focus-target.d.ts +6 -0
- package/dist/tooltip/focus-target.js +9 -0
- package/dist/tooltip/root/tooltip-root.d.ts +42 -17
- package/dist/tooltip/root/tooltip-root.js +50 -9
- package/dist/tour/naming.d.ts +30 -0
- package/dist/tour/naming.js +10 -0
- package/dist/tour/root/tour-root.d.ts +35 -0
- package/dist/tour/root/tour-root.js +56 -5
- package/dist/tour/stop/tour-stop.d.ts +53 -8
- package/dist/tour/stop/tour-stop.js +45 -15
- package/dist/tour/wait.d.ts +11 -0
- package/dist/tour/wait.js +19 -0
- package/dist/tree/item/tree-item.d.ts +54 -1
- package/dist/tree/item/tree-item.js +89 -20
- package/dist/tree/root/tree-root.d.ts +37 -0
- package/dist/tree/root/tree-root.js +51 -6
- package/dist/tree/selection.d.ts +24 -0
- package/dist/tree/selection.js +26 -0
- package/dist/trend/root/trend-root.d.ts +13 -0
- package/dist/trend/root/trend-root.js +14 -9
- package/dist/video/media-events.d.ts +49 -0
- package/dist/video/media-events.js +39 -0
- package/dist/video/root/video-root.d.ts +99 -13
- package/dist/video/root/video-root.js +84 -47
- package/dist/video-playlist/menu/video-playlist-menu.d.ts +3 -0
- package/dist/video-playlist/menu/video-playlist-menu.js +2 -1
- package/dist/video-playlist/order.d.ts +41 -0
- package/dist/video-playlist/order.js +34 -0
- package/dist/video-playlist/root/video-playlist-root.d.ts +70 -2
- package/dist/video-playlist/root/video-playlist-root.js +60 -16
- package/dist/virtual-list/controls.d.ts +4 -0
- package/dist/virtual-list/controls.js +30 -0
- package/dist/virtual-list/fill.d.ts +30 -0
- package/dist/virtual-list/fill.js +39 -0
- package/dist/virtual-list/keys.d.ts +15 -0
- package/dist/virtual-list/keys.js +24 -0
- package/dist/virtual-list/root/virtual-list-root.d.ts +155 -23
- package/dist/virtual-list/root/virtual-list-root.js +175 -34
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +8871 -1286
- package/types/svelte.d.ts +3 -0
- package/types/vue.d.ts +1918 -269
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
/** What the clock reads from its host. */
|
|
3
|
+
export interface RelativeClockOptions {
|
|
4
|
+
/** The locale the reading is written in. Empty is the runtime's own. */
|
|
5
|
+
locale: () => string;
|
|
6
|
+
/** The instant being read, or nothing where there is none. */
|
|
7
|
+
moment: () => Date | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The time a relative reading is drawn against, moved on when the reading
|
|
11
|
+
* would change.
|
|
12
|
+
*
|
|
13
|
+
* **One wakeup when the words go stale, and none in between.** `relativeTime`
|
|
14
|
+
* says how long its answer holds, so the clock asks core's shared ticker for
|
|
15
|
+
* exactly that moment: a turn a minute old wakes once a minute, an hour old
|
|
16
|
+
* once an hour. Every turn on the page shares the ticker's one timer.
|
|
17
|
+
*
|
|
18
|
+
* `Format Date` keeps the same arrangement inline, and the two belong in one
|
|
19
|
+
* core controller.
|
|
20
|
+
*/
|
|
21
|
+
export declare class RelativeClockController implements ReactiveController {
|
|
22
|
+
private readonly host;
|
|
23
|
+
private readonly options;
|
|
24
|
+
/** The time the host last drew against, in milliseconds. */
|
|
25
|
+
now: number;
|
|
26
|
+
private stop;
|
|
27
|
+
constructor(host: ReactiveControllerHost & HTMLElement, options: RelativeClockOptions);
|
|
28
|
+
hostConnected(): void;
|
|
29
|
+
hostDisconnected(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Reads the clock again and schedules the next reading.
|
|
32
|
+
*
|
|
33
|
+
* The host calls it when the instant or the locale changes, and the ticker
|
|
34
|
+
* calls it when the words go stale. **Only on a page**: a server has nobody
|
|
35
|
+
* to update a reading for, and a subscription there holds the element after
|
|
36
|
+
* its markup is sent.
|
|
37
|
+
*/
|
|
38
|
+
tick(): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { relativeTime, subscribe } from '@fusion.dev/helix-core';
|
|
2
|
+
export class RelativeClockController {
|
|
3
|
+
constructor(host, options) {
|
|
4
|
+
this.host = host;
|
|
5
|
+
this.options = options;
|
|
6
|
+
this.now = Date.now();
|
|
7
|
+
this.stop = undefined;
|
|
8
|
+
host.addController(this);
|
|
9
|
+
}
|
|
10
|
+
hostConnected() {
|
|
11
|
+
this.tick();
|
|
12
|
+
}
|
|
13
|
+
hostDisconnected() {
|
|
14
|
+
this.stop?.();
|
|
15
|
+
this.stop = undefined;
|
|
16
|
+
}
|
|
17
|
+
tick() {
|
|
18
|
+
this.stop?.();
|
|
19
|
+
this.stop = undefined;
|
|
20
|
+
this.now = Date.now();
|
|
21
|
+
this.host.requestUpdate();
|
|
22
|
+
const moment = this.options.moment();
|
|
23
|
+
if (!moment || !this.host.isConnected) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const { next } = relativeTime(this.options.locale())(moment, new Date(this.now));
|
|
27
|
+
if (Number.isFinite(next)) {
|
|
28
|
+
this.stop = subscribe(next, () => this.tick());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -7,6 +7,8 @@ export interface ChatTurn {
|
|
|
7
7
|
at?: string;
|
|
8
8
|
/** Who said it: `me`, `them`, or a name the consumer styles. */
|
|
9
9
|
author?: string;
|
|
10
|
+
/** Who said it, as a screen reader names the turn, as on `ChatMessage`. */
|
|
11
|
+
authorLabel?: string;
|
|
10
12
|
/**
|
|
11
13
|
* What identifies it across changes to the set.
|
|
12
14
|
*
|
|
@@ -44,6 +46,20 @@ declare const HelixHeadlessChat_base: (new (...args: any[]) => import("@fusion.d
|
|
|
44
46
|
* render from the server and suit most conversations. `turns` draws a long
|
|
45
47
|
* transcript one window at a time, so the log needs a block size of its own.
|
|
46
48
|
*
|
|
49
|
+
* **A conversation is built from three elements.** The chat holds the
|
|
50
|
+
* transcript, a `Chat.Message` stands for each turn, and a `Chat.Composer` sits
|
|
51
|
+
* in the `composer` slot. When the user sends, `helix-send` reaches the chat:
|
|
52
|
+
* add their turn with `author="me"` and `state="sending"`, then set `state` to
|
|
53
|
+
* `sent` or `failed` when your server answers. Add the reply as a turn with
|
|
54
|
+
* `state="streaming"`, write its text as it arrives, and set `state` to `sent`
|
|
55
|
+
* when it is complete. While the user types, the composer sends
|
|
56
|
+
* `helix-typing`, which you can pass on to the other side. Show the other
|
|
57
|
+
* side's typing in the `status` slot.
|
|
58
|
+
*
|
|
59
|
+
* A screen reader names each turn by its author and its time, such as "You, 2
|
|
60
|
+
* minutes ago". Set `me-label` and `message-label` to say it in your language,
|
|
61
|
+
* and give each turn by `them` an `author-label`.
|
|
62
|
+
*
|
|
47
63
|
* A turn from `turns` is drawn in the chat's shadow root, so style it through
|
|
48
64
|
* the forwarded `message-*` parts. A turn by `me` also gets each part with
|
|
49
65
|
* `-mine` added, and the turn's state adds `message-meta-failed`,
|
|
@@ -141,6 +157,16 @@ export declare class HelixHeadlessChat extends HelixHeadlessChat_base {
|
|
|
141
157
|
* The conversation's name, read by screen readers.
|
|
142
158
|
*/
|
|
143
159
|
label: string;
|
|
160
|
+
/**
|
|
161
|
+
* The word a screen reader says for `me` when it names a turn.
|
|
162
|
+
*/
|
|
163
|
+
meLabel: string;
|
|
164
|
+
/**
|
|
165
|
+
* The name a screen reader gives a turn with both an author and a time.
|
|
166
|
+
* `{author}` is who wrote it and `{time}` is when, as the turn shows it. A
|
|
167
|
+
* turn with only one of the two is named by that one.
|
|
168
|
+
*/
|
|
169
|
+
messageLabel: string;
|
|
144
170
|
/**
|
|
145
171
|
* Whether the transcript follows new turns to the bottom.
|
|
146
172
|
*
|
|
@@ -186,6 +212,11 @@ export declare class HelixHeadlessChat extends HelixHeadlessChat_base {
|
|
|
186
212
|
/** The last thing said, and how many times something has been. */
|
|
187
213
|
private announcement;
|
|
188
214
|
private said;
|
|
215
|
+
/**
|
|
216
|
+
* The words every turn is named with, kept as one object between changes so
|
|
217
|
+
* a turn is told again only when they change.
|
|
218
|
+
*/
|
|
219
|
+
private words;
|
|
189
220
|
/** Watches for turns arriving, since a manual slot hears nothing about them. */
|
|
190
221
|
private watcher;
|
|
191
222
|
/** Watches the turns' own `state`, which is when one of them settles. */
|
|
@@ -353,6 +384,11 @@ export declare class HelixHeadlessChat extends HelixHeadlessChat_base {
|
|
|
353
384
|
*/
|
|
354
385
|
private follow;
|
|
355
386
|
protected updated(changed: PropertyValues): void;
|
|
387
|
+
/**
|
|
388
|
+
* Hands each turn written as a child the words it is named with, once it
|
|
389
|
+
* has hydrated, so its first render is the server's.
|
|
390
|
+
*/
|
|
391
|
+
private tellTurns;
|
|
356
392
|
private readonly handleSlotChange;
|
|
357
393
|
private readonly handleSettle;
|
|
358
394
|
/**
|
|
@@ -5,13 +5,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
var HelixHeadlessChat_1;
|
|
8
|
-
import { customElement, HelixBeforePinEvent, HelixElement, HelixHistoryEvent, HelixPinEvent, hostAria, MixinCollection, onUnlessFalse, requestChange, VirtualizeController, } from '@fusion.dev/helix-core';
|
|
8
|
+
import { customElement, HelixBeforePinEvent, HelixElement, HelixHistoryEvent, HelixPinEvent, hostAria, MixinCollection, onUnlessFalse, requestChange, VirtualizeController, whenHydrated, } from '@fusion.dev/helix-core';
|
|
9
9
|
import { nothing } from 'lit';
|
|
10
10
|
import { property, state } from 'lit/decorators.js';
|
|
11
11
|
import { keyed } from 'lit/directives/keyed.js';
|
|
12
12
|
import { repeat } from 'lit/directives/repeat.js';
|
|
13
13
|
import { html } from 'lit/static-html.js';
|
|
14
14
|
import { FAILED_LABEL } from '../message/chat-message.js';
|
|
15
|
+
import { TURN_WORDS } from '../naming.js';
|
|
15
16
|
const REGIONS = ['header', 'actions', 'resume', 'status', 'composer'];
|
|
16
17
|
const SECOND_NAMES = {
|
|
17
18
|
author: {
|
|
@@ -39,11 +40,14 @@ let HelixHeadlessChat = class HelixHeadlessChat extends MixinCollection(HelixEle
|
|
|
39
40
|
this.history = '';
|
|
40
41
|
this.historyText = 'Loading earlier messages';
|
|
41
42
|
this.label = '';
|
|
43
|
+
this.meLabel = 'You';
|
|
44
|
+
this.messageLabel = '{author}, {time}';
|
|
42
45
|
this.threshold = 48;
|
|
43
46
|
this.turns = [];
|
|
44
47
|
this.pinnedState = undefined;
|
|
45
48
|
this.announcement = '';
|
|
46
49
|
this.said = 0;
|
|
50
|
+
this.words = TURN_WORDS;
|
|
47
51
|
this.watcher = undefined;
|
|
48
52
|
this.settling = undefined;
|
|
49
53
|
this.grower = undefined;
|
|
@@ -361,6 +365,9 @@ let HelixHeadlessChat = class HelixHeadlessChat extends MixinCollection(HelixEle
|
|
|
361
365
|
willUpdate(changed) {
|
|
362
366
|
super.willUpdate(changed);
|
|
363
367
|
hostAria(this.internals, { label: this.label || 'Conversation', role: 'region' });
|
|
368
|
+
if (changed.has('meLabel') || changed.has('messageLabel')) {
|
|
369
|
+
this.words = { me: this.meLabel, sentence: this.messageLabel };
|
|
370
|
+
}
|
|
364
371
|
this.countRegions();
|
|
365
372
|
if (changed.has('history')) {
|
|
366
373
|
this.asked = false;
|
|
@@ -389,6 +396,7 @@ let HelixHeadlessChat = class HelixHeadlessChat extends MixinCollection(HelixEle
|
|
|
389
396
|
updated(changed) {
|
|
390
397
|
super.updated(changed);
|
|
391
398
|
this.assign();
|
|
399
|
+
this.tellTurns();
|
|
392
400
|
if (this.pinned) {
|
|
393
401
|
this.stick();
|
|
394
402
|
}
|
|
@@ -403,6 +411,13 @@ let HelixHeadlessChat = class HelixHeadlessChat extends MixinCollection(HelixEle
|
|
|
403
411
|
this.reachHistory();
|
|
404
412
|
this.announce();
|
|
405
413
|
}
|
|
414
|
+
tellTurns() {
|
|
415
|
+
for (const message of this.messages) {
|
|
416
|
+
whenHydrated(message, () => {
|
|
417
|
+
message.turnWords = this.words;
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
406
421
|
renderTurns() {
|
|
407
422
|
const { after, before, first, last } = this.virtualize.window;
|
|
408
423
|
const message = this.tag('chat-message');
|
|
@@ -414,7 +429,9 @@ let HelixHeadlessChat = class HelixHeadlessChat extends MixinCollection(HelixEle
|
|
|
414
429
|
meta: message-meta, retry: message-retry, sources: message-sources,
|
|
415
430
|
state: message-state, time: message-time${secondNames(SECOND_NAMES.author, turn.author)}${secondNames(SECOND_NAMES.state, turn.state)}"
|
|
416
431
|
author=${turn.author ?? nothing}
|
|
432
|
+
author-label=${turn.authorLabel ?? nothing}
|
|
417
433
|
at=${turn.at ?? nothing}
|
|
434
|
+
.turnWords=${this.words}
|
|
418
435
|
state=${turn.state ?? nothing}
|
|
419
436
|
>${turn.text}</${message}>
|
|
420
437
|
</div>`)}
|
|
@@ -469,6 +486,12 @@ __decorate([
|
|
|
469
486
|
__decorate([
|
|
470
487
|
property()
|
|
471
488
|
], HelixHeadlessChat.prototype, "label", void 0);
|
|
489
|
+
__decorate([
|
|
490
|
+
property({ attribute: 'me-label' })
|
|
491
|
+
], HelixHeadlessChat.prototype, "meLabel", void 0);
|
|
492
|
+
__decorate([
|
|
493
|
+
property({ attribute: 'message-label' })
|
|
494
|
+
], HelixHeadlessChat.prototype, "messageLabel", void 0);
|
|
472
495
|
__decorate([
|
|
473
496
|
property({ type: Boolean })
|
|
474
497
|
], HelixHeadlessChat.prototype, "pinned", null);
|
|
@@ -86,7 +86,9 @@ let HelixHeadlessCheckbox = class HelixHeadlessCheckbox extends MixinControllerC
|
|
|
86
86
|
?required=${this.required}
|
|
87
87
|
aria-describedby=${this.describedBy ?? nothing}
|
|
88
88
|
aria-invalid=${this.invalidity ?? nothing}
|
|
89
|
+
aria-readonly=${this.readOnly ? 'true' : nothing}
|
|
89
90
|
@change=${this.handleChange}
|
|
91
|
+
@click=${this.holdReadOnly}
|
|
90
92
|
@input=${this.stopInner}
|
|
91
93
|
/>
|
|
92
94
|
<span
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DisabledCascadeController, HelixFormElement } from '@fusion.dev/helix-core';
|
|
2
|
-
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
2
|
+
import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
3
3
|
import { HelixHeadlessCheckbox } from '../../checkbox/root/checkbox-root.js';
|
|
4
|
+
import '../../checkbox/index.js';
|
|
4
5
|
declare const HelixHeadlessCheckboxGroup_base: (new (...args: any[]) => import("@fusion.dev/helix-core").MixinFieldInterface) & typeof HelixFormElement;
|
|
5
6
|
/**
|
|
6
7
|
* @summary A group of related checkboxes under one label, with one value for the set.
|
|
@@ -19,6 +20,11 @@ declare const HelixHeadlessCheckboxGroup_base: (new (...args: any[]) => import("
|
|
|
19
20
|
* checkboxes are written, read from the boxes themselves. Setting it checks
|
|
20
21
|
* exactly those values and unchecks the rest.
|
|
21
22
|
*
|
|
23
|
+
* `select-all` draws a box above the set that checks every enabled box, or
|
|
24
|
+
* unchecks them all once every one is checked. It shows a dash while only some
|
|
25
|
+
* are checked, and changes the set through the same cancelable
|
|
26
|
+
* `helix-before-change` a box does.
|
|
27
|
+
*
|
|
22
28
|
* A checkbox is a member wherever it sits inside the group, in a row or a grid
|
|
23
29
|
* cell of your own, unless another group inside this one holds it. A field of
|
|
24
30
|
* another kind inside the group, such as an "Other" text field, sends its own
|
|
@@ -47,19 +53,47 @@ declare const HelixHeadlessCheckboxGroup_base: (new (...args: any[]) => import("
|
|
|
47
53
|
* @csspart hint - The help under the checkboxes.
|
|
48
54
|
* @csspart items - The element that holds the checkboxes, laid out by `orientation`.
|
|
49
55
|
* @csspart label - The group's label, above the checkboxes.
|
|
56
|
+
* @csspart select-all - The box that checks or unchecks every box, under `select-all`.
|
|
57
|
+
* @csspart select-all-box - The select-all box's box, under the mark.
|
|
58
|
+
* @csspart select-all-control - The select-all box's native input.
|
|
59
|
+
* @csspart select-all-feedback - The select-all box's own message, which it never shows.
|
|
60
|
+
* @csspart select-all-field - The row that holds the select-all box and its label.
|
|
61
|
+
* @csspart select-all-hint - The select-all box's own help, which it never shows.
|
|
62
|
+
* @csspart select-all-label - The words beside the select-all box.
|
|
63
|
+
* @csspart select-all-mark - The select-all box's check mark, or its dash while only some boxes are checked.
|
|
64
|
+
* @csspart select-all-mark-checked - Added to `select-all-mark` while every box is checked.
|
|
65
|
+
* @csspart select-all-mark-dash - Added to `select-all-mark` while only some boxes are checked, and kept until every one is.
|
|
66
|
+
* @csspart select-all-mark-indeterminate - Added to `select-all-mark` while only some boxes are checked.
|
|
50
67
|
*
|
|
51
68
|
* @cssstate invalid - The control has an error to show, from the browser's validation or from your `feedback`.
|
|
52
69
|
*/
|
|
53
70
|
export declare class HelixHeadlessCheckboxGroup extends HelixHeadlessCheckboxGroup_base {
|
|
71
|
+
/**
|
|
72
|
+
* Whether a box above the set checks or unchecks every enabled box.
|
|
73
|
+
*/
|
|
74
|
+
selectAll: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* The words beside the box `select-all` draws.
|
|
77
|
+
*/
|
|
78
|
+
selectAllLabel: string;
|
|
54
79
|
/**
|
|
55
80
|
* The checked values, comma separated.
|
|
56
81
|
*
|
|
57
82
|
* Read from the boxes once they are known, so a box a script ticks directly
|
|
58
|
-
* is in it at once. Written, it is pushed onto the boxes.
|
|
83
|
+
* is in it at once. Written, it is pushed onto the boxes. A box whose value
|
|
84
|
+
* holds a comma cannot be named here: use `values`.
|
|
59
85
|
*/
|
|
60
86
|
get value(): string;
|
|
61
87
|
set value(next: string);
|
|
62
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* The checked values, as a list, in the order the boxes are written.
|
|
90
|
+
*
|
|
91
|
+
* The same set as `value`, and the one to use where a value may hold a
|
|
92
|
+
* comma. Written, it checks exactly those boxes and unchecks the rest.
|
|
93
|
+
*/
|
|
94
|
+
get values(): string[];
|
|
95
|
+
set values(next: string[]);
|
|
96
|
+
/** The values last written, which the boxes are given at the next update. */
|
|
63
97
|
private declared;
|
|
64
98
|
/**
|
|
65
99
|
* Whether `declared` has yet to reach the boxes.
|
|
@@ -179,6 +213,22 @@ export declare class HelixHeadlessCheckboxGroup extends HelixHeadlessCheckboxGro
|
|
|
179
213
|
*/
|
|
180
214
|
private validate;
|
|
181
215
|
protected updated(changed: PropertyValues): void;
|
|
216
|
+
/**
|
|
217
|
+
* Checks every enabled box, or unchecks them all once every one is checked.
|
|
218
|
+
*
|
|
219
|
+
* The box's own request is refused, since the box shows what the set holds
|
|
220
|
+
* and the set is moved here, through one cancelable `helix-before-change`
|
|
221
|
+
* for the whole set, as a box moves it.
|
|
222
|
+
*/
|
|
223
|
+
private readonly handleSelectAll;
|
|
224
|
+
/**
|
|
225
|
+
* The box above the set that checks or unchecks every box, under
|
|
226
|
+
* `select-all`, behind a seam a tier can move.
|
|
227
|
+
*
|
|
228
|
+
* Checked while every box is, and showing a dash while only some are. It is
|
|
229
|
+
* in this shadow root, so it is no member of the set and submits nothing.
|
|
230
|
+
*/
|
|
231
|
+
protected renderSelectAll(): TemplateResult | typeof nothing;
|
|
182
232
|
protected render(): TemplateResult;
|
|
183
233
|
}
|
|
184
234
|
declare global {
|
|
@@ -5,19 +5,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
var HelixHeadlessCheckboxGroup_1;
|
|
8
|
-
import { customElement, DisabledCascadeController, HelixBeforeChangeEvent, HelixFormElement, hostAria, MixinField, } from '@fusion.dev/helix-core';
|
|
9
|
-
import {
|
|
8
|
+
import { commaList, customElement, DisabledCascadeController, HelixBeforeChangeEvent, HelixFormElement, hostAria, MixinField, } from '@fusion.dev/helix-core';
|
|
9
|
+
import { nothing } from 'lit';
|
|
10
10
|
import { property } from 'lit/decorators.js';
|
|
11
|
+
import { html } from 'lit/static-html.js';
|
|
11
12
|
import { HelixHeadlessCheckbox } from '../../checkbox/root/checkbox-root.js';
|
|
13
|
+
import '../../checkbox/index.js';
|
|
12
14
|
let HelixHeadlessCheckboxGroup = HelixHeadlessCheckboxGroup_1 = class HelixHeadlessCheckboxGroup extends MixinField(HelixFormElement) {
|
|
13
15
|
constructor() {
|
|
14
16
|
super(...arguments);
|
|
15
|
-
this.
|
|
17
|
+
this.selectAll = false;
|
|
18
|
+
this.selectAllLabel = 'Select all';
|
|
19
|
+
this.declared = [];
|
|
16
20
|
this.pending = false;
|
|
17
21
|
this.watched = new Set();
|
|
18
22
|
this.member = {
|
|
19
23
|
hostUpdated: () => {
|
|
20
|
-
if (this.isConnected && this.value !== this.judged) {
|
|
24
|
+
if (this.isConnected && (this.selectAll || this.value !== this.judged)) {
|
|
21
25
|
this.requestUpdate();
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -38,13 +42,12 @@ let HelixHeadlessCheckboxGroup = HelixHeadlessCheckboxGroup_1 = class HelixHeadl
|
|
|
38
42
|
const wanted = event.detail.checked;
|
|
39
43
|
const next = this.boxes
|
|
40
44
|
.filter((box) => (box === changed ? wanted : box.checked))
|
|
41
|
-
.map((box) => box.value)
|
|
42
|
-
|
|
43
|
-
if (!this.dispatchEvent(new HelixBeforeChangeEvent({ value: next }))) {
|
|
45
|
+
.map((box) => box.value);
|
|
46
|
+
if (!this.dispatchEvent(new HelixBeforeChangeEvent({ value: next.join(',') }))) {
|
|
44
47
|
event.preventDefault();
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
|
-
this.
|
|
50
|
+
this.values = next;
|
|
48
51
|
this.announceInput();
|
|
49
52
|
this.announceChange();
|
|
50
53
|
};
|
|
@@ -53,22 +56,40 @@ let HelixHeadlessCheckboxGroup = HelixHeadlessCheckboxGroup_1 = class HelixHeadl
|
|
|
53
56
|
event.stopImmediatePropagation();
|
|
54
57
|
}
|
|
55
58
|
};
|
|
59
|
+
this.handleSelectAll = (event) => {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
const enabled = this.boxes.filter((box) => !box.isDisabled);
|
|
63
|
+
const every = enabled.length > 0 && enabled.every((box) => box.checked);
|
|
64
|
+
const next = this.boxes
|
|
65
|
+
.filter((box) => (enabled.includes(box) ? !every : box.checked))
|
|
66
|
+
.map((box) => box.value);
|
|
67
|
+
if (!this.dispatchEvent(new HelixBeforeChangeEvent({ value: next.join(',') }))) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.values = next;
|
|
71
|
+
this.announceInput();
|
|
72
|
+
this.announceChange();
|
|
73
|
+
};
|
|
56
74
|
}
|
|
57
75
|
get value() {
|
|
76
|
+
return this.values.join(',');
|
|
77
|
+
}
|
|
78
|
+
set value(next) {
|
|
79
|
+
this.values = commaList(next);
|
|
80
|
+
}
|
|
81
|
+
get values() {
|
|
58
82
|
if (this.pending || !this.hasUpdated || !this.childrenKnown) {
|
|
59
|
-
return this.declared;
|
|
83
|
+
return [...this.declared];
|
|
60
84
|
}
|
|
61
85
|
const boxes = this.boxes;
|
|
62
86
|
return boxes.length === 0
|
|
63
|
-
? this.declared
|
|
64
|
-
: boxes
|
|
65
|
-
.filter((box) => box.checked)
|
|
66
|
-
.map((box) => box.value)
|
|
67
|
-
.join(',');
|
|
87
|
+
? [...this.declared]
|
|
88
|
+
: boxes.filter((box) => box.checked).map((box) => box.value);
|
|
68
89
|
}
|
|
69
|
-
set
|
|
70
|
-
const previous = this.
|
|
71
|
-
this.declared = next;
|
|
90
|
+
set values(next) {
|
|
91
|
+
const previous = this.value;
|
|
92
|
+
this.declared = [...next];
|
|
72
93
|
this.pending = true;
|
|
73
94
|
this.requestUpdate('value', previous);
|
|
74
95
|
}
|
|
@@ -105,10 +126,7 @@ let HelixHeadlessCheckboxGroup = HelixHeadlessCheckboxGroup_1 = class HelixHeadl
|
|
|
105
126
|
return;
|
|
106
127
|
}
|
|
107
128
|
this.pending = false;
|
|
108
|
-
const wanted = new Set(this.declared
|
|
109
|
-
.split(',')
|
|
110
|
-
.map((entry) => entry.trim())
|
|
111
|
-
.filter(Boolean));
|
|
129
|
+
const wanted = new Set(this.declared);
|
|
112
130
|
for (const box of boxes) {
|
|
113
131
|
box.checked = wanted.has(box.value);
|
|
114
132
|
}
|
|
@@ -159,8 +177,30 @@ let HelixHeadlessCheckboxGroup = HelixHeadlessCheckboxGroup_1 = class HelixHeadl
|
|
|
159
177
|
this.validate();
|
|
160
178
|
this.linkHost();
|
|
161
179
|
}
|
|
180
|
+
renderSelectAll() {
|
|
181
|
+
if (!this.selectAll) {
|
|
182
|
+
return nothing;
|
|
183
|
+
}
|
|
184
|
+
const boxes = this.childrenKnown ? this.boxes : [];
|
|
185
|
+
const ticked = boxes.filter((box) => box.checked).length;
|
|
186
|
+
const every = boxes.length > 0 && ticked === boxes.length;
|
|
187
|
+
const box = this.tag('checkbox');
|
|
188
|
+
return html `<${box}
|
|
189
|
+
part="select-all"
|
|
190
|
+
exportparts="box: select-all-box, control: select-all-control,
|
|
191
|
+
feedback: select-all-feedback, field: select-all-field, hint: select-all-hint,
|
|
192
|
+
label: select-all-label, mark: select-all-mark, mark-checked: select-all-mark-checked,
|
|
193
|
+
mark-dash: select-all-mark-dash, mark-indeterminate: select-all-mark-indeterminate"
|
|
194
|
+
.checked=${every}
|
|
195
|
+
.indeterminate=${ticked > 0 && !every}
|
|
196
|
+
?disabled=${this.isDisabled}
|
|
197
|
+
label=${this.selectAllLabel}
|
|
198
|
+
@helix-before-toggle=${this.handleSelectAll}
|
|
199
|
+
@input=${(event) => event.stopPropagation()}
|
|
200
|
+
></${box}>`;
|
|
201
|
+
}
|
|
162
202
|
render() {
|
|
163
|
-
return html `${this.renderGroupLabel()}
|
|
203
|
+
return html `${this.renderGroupLabel()}${this.renderSelectAll()}
|
|
164
204
|
<div part="items">
|
|
165
205
|
${''}
|
|
166
206
|
<slot @slotchange=${() => this.requestUpdate()}></slot>
|
|
@@ -168,9 +208,18 @@ let HelixHeadlessCheckboxGroup = HelixHeadlessCheckboxGroup_1 = class HelixHeadl
|
|
|
168
208
|
${this.renderHint()}${this.renderFeedback()}`;
|
|
169
209
|
}
|
|
170
210
|
};
|
|
211
|
+
__decorate([
|
|
212
|
+
property({ attribute: 'select-all', type: Boolean })
|
|
213
|
+
], HelixHeadlessCheckboxGroup.prototype, "selectAll", void 0);
|
|
214
|
+
__decorate([
|
|
215
|
+
property({ attribute: 'select-all-label' })
|
|
216
|
+
], HelixHeadlessCheckboxGroup.prototype, "selectAllLabel", void 0);
|
|
171
217
|
__decorate([
|
|
172
218
|
property()
|
|
173
219
|
], HelixHeadlessCheckboxGroup.prototype, "value", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
property({ attribute: false })
|
|
222
|
+
], HelixHeadlessCheckboxGroup.prototype, "values", null);
|
|
174
223
|
HelixHeadlessCheckboxGroup = HelixHeadlessCheckboxGroup_1 = __decorate([
|
|
175
224
|
customElement('helix-headless-checkbox-group')
|
|
176
225
|
], HelixHeadlessCheckboxGroup);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many lines a block of code shows.
|
|
3
|
+
*
|
|
4
|
+
* A final line break ends the last line rather than starting another, which is
|
|
5
|
+
* how an editor counts a file and how the block draws one: `a\nb\n` is two
|
|
6
|
+
* lines. A Windows line break is one break. Empty code has no lines.
|
|
7
|
+
*/
|
|
8
|
+
export declare const lineCount: (code: string) => number;
|
|
9
|
+
/**
|
|
10
|
+
* The numbers for a gutter of `count` lines, one to a line, as the text a
|
|
11
|
+
* `<pre>` draws beside the code. The stylesheet aligns them to the end.
|
|
12
|
+
*/
|
|
13
|
+
export declare const gutterNumbers: (count: number) => string;
|
|
@@ -14,6 +14,12 @@ import '../../copy-button/index.js';
|
|
|
14
14
|
*
|
|
15
15
|
* For a fragment of code inside a sentence, use `Code`.
|
|
16
16
|
*
|
|
17
|
+
* Set `line-numbers` to number the lines in a gutter beside the code, hidden
|
|
18
|
+
* from the accessibility tree and left out of a copy. Set `highlight` to a
|
|
19
|
+
* function that turns the code into highlighted markup, such as one wrapping
|
|
20
|
+
* Shiki or Prism, and the block draws what it returns; the code stays in the
|
|
21
|
+
* slot, so the copy button and the page's own text are the code as written.
|
|
22
|
+
*
|
|
17
23
|
* Set `diff` to show a change. Put a unified diff, the output of `git diff` or
|
|
18
24
|
* `diff -u`, in the same slot, and the block draws the lines it added and
|
|
19
25
|
* removed. The block never computes a diff itself. Line numbers come from the
|
|
@@ -42,6 +48,7 @@ import '../../copy-button/index.js';
|
|
|
42
48
|
* @csspart context - In a diff, a line both versions share.
|
|
43
49
|
* @csspart copy - The copy button. It sits in the header when there is one, and beside the code otherwise.
|
|
44
50
|
* @csspart copy-button - The inner button.
|
|
51
|
+
* @csspart copy-live - The copy button's live region, which speaks while the button is pending.
|
|
45
52
|
* @csspart copy-mark - The clipboard icon, and the check mark that replaces it after a copy.
|
|
46
53
|
* @csspart copy-text - The words on that button, trimmed to their capitals and baseline.
|
|
47
54
|
* @csspart copy-tooltip - The copy button's tooltip.
|
|
@@ -57,6 +64,7 @@ import '../../copy-button/index.js';
|
|
|
57
64
|
* @csspart file - In a diff, one file's header and block.
|
|
58
65
|
* @csspart filler - In a split diff, the empty row opposite a line the other side does not have.
|
|
59
66
|
* @csspart frame - The code, and the copy button beside it where there is no header.
|
|
67
|
+
* @csspart gutter - The line numbers beside the code, shown when `line-numbers` is set.
|
|
60
68
|
* @csspart header - The bar that holds the name and the copy button, shown when there is a name.
|
|
61
69
|
* @csspart hunk - In a diff, a `@@` line saying where the lines under it are.
|
|
62
70
|
* @csspart label - The file name or language, where one is given.
|
|
@@ -75,6 +83,10 @@ export declare class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
75
83
|
copiedLabel: string;
|
|
76
84
|
/**
|
|
77
85
|
* The copy button's name and tooltip text before a copy.
|
|
86
|
+
*
|
|
87
|
+
* Where the block has a name, the button says it too, such as "Copy code,
|
|
88
|
+
* app.ts", so each copy button on a page with several blocks is told apart.
|
|
89
|
+
* In a diff, that is each file's own name.
|
|
78
90
|
*/
|
|
79
91
|
copyLabel: string;
|
|
80
92
|
/**
|
|
@@ -84,6 +96,19 @@ export declare class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
84
96
|
* `false` reflects as no attribute at all.
|
|
85
97
|
*/
|
|
86
98
|
diff: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Turns the code into highlighted markup, which the block draws in place of
|
|
101
|
+
* the plain text.
|
|
102
|
+
*
|
|
103
|
+
* Called with the code as written and returning HTML, such as the output of
|
|
104
|
+
* Shiki's `codeToHtml` or Prism's `highlight`. **The markup is drawn as
|
|
105
|
+
* given**, so it has to escape the code it was handed, which those
|
|
106
|
+
* highlighters do. Bind the language in the function you pass. The code
|
|
107
|
+
* stays in the slot, so the copy button copies it as written and a reader
|
|
108
|
+
* without the script still has it. Not called on a server, which has no code
|
|
109
|
+
* to read, nor for a diff.
|
|
110
|
+
*/
|
|
111
|
+
highlight?: (code: string) => string;
|
|
87
112
|
/**
|
|
88
113
|
* The block's name, usually a file name or a language.
|
|
89
114
|
*
|
|
@@ -91,6 +116,15 @@ export declare class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
91
116
|
* carries no name of its own.
|
|
92
117
|
*/
|
|
93
118
|
label: string;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the lines are numbered in a gutter beside the code.
|
|
121
|
+
*
|
|
122
|
+
* The numbers are hidden from the accessibility tree and are not part of a
|
|
123
|
+
* copy, which takes the code alone. Reflected, because the stylesheet lays
|
|
124
|
+
* the gutter out beside the code. A diff numbers its lines from its hunks
|
|
125
|
+
* whether or not this is set.
|
|
126
|
+
*/
|
|
127
|
+
lineNumbers: boolean;
|
|
94
128
|
/**
|
|
95
129
|
* Whether to leave the copy button off.
|
|
96
130
|
*
|
|
@@ -177,8 +211,11 @@ export declare class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
177
211
|
* interpolated rather than written, so `tier` resolves it: this renders the
|
|
178
212
|
* base button, and a styled subclass that sets `tier` renders the styled one
|
|
179
213
|
* from the same template.
|
|
214
|
+
*
|
|
215
|
+
* @param value The text the button copies.
|
|
216
|
+
* @param name The name of what it copies, which its label carries.
|
|
180
217
|
*/
|
|
181
|
-
protected renderCopyButton(value?: string): TemplateResult;
|
|
218
|
+
protected renderCopyButton(value?: string, name?: string): TemplateResult;
|
|
182
219
|
/** A number padded to the widest in its file, so the columns line up as text. */
|
|
183
220
|
private renderNumber;
|
|
184
221
|
private renderLine;
|