@fusion.dev/helix-headless 0.145.0 → 0.146.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 +7373 -3849
- package/dist/accordion/item/accordion-item.d.ts +14 -0
- package/dist/accordion/item/accordion-item.js +16 -6
- package/dist/accordion/root/accordion-root.d.ts +8 -5
- package/dist/announcement/root/announcement-root.d.ts +3 -2
- package/dist/announcement/root/announcement-root.js +3 -1
- package/dist/app-header/root/app-header-root.d.ts +7 -2
- package/dist/app-header/root/app-header-root.js +9 -1
- package/dist/app-header/sectioning.d.ts +3 -1
- package/dist/app-header/sectioning.js +3 -2
- package/dist/avatar/group/avatar-group.d.ts +20 -14
- package/dist/avatar/group/avatar-group.js +17 -19
- package/dist/badge/root/badge-root.d.ts +3 -1
- package/dist/badge/root/badge-root.js +2 -2
- package/dist/bar-chart/root/bar-chart-root.d.ts +18 -1
- package/dist/bar-chart/root/bar-chart-root.js +52 -15
- package/dist/bar-chart/stack.d.ts +15 -0
- package/dist/bar-chart/stack.js +19 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.d.ts +25 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.js +50 -3
- package/dist/button/root/button-root.d.ts +26 -0
- package/dist/button/root/button-root.js +38 -18
- package/dist/button-group/root/button-group-root.d.ts +2 -1
- package/dist/button-group/root/button-group-root.js +5 -1
- package/dist/canvas/node/canvas-node.d.ts +4 -3
- package/dist/canvas/node/canvas-node.js +3 -2
- package/dist/canvas/root/canvas-root.js +2 -2
- package/dist/card/root/card-root.d.ts +24 -3
- package/dist/card/root/card-root.js +20 -8
- package/dist/carousel/root/carousel-root.d.ts +43 -4
- package/dist/carousel/root/carousel-root.js +40 -12
- package/dist/carousel/stops.d.ts +20 -0
- package/dist/carousel/stops.js +30 -0
- package/dist/chat/message/chat-message.js +5 -4
- package/dist/chat/naming.d.ts +5 -1
- package/dist/chat/naming.js +4 -2
- package/dist/chat/root/chat-root.d.ts +25 -3
- package/dist/chat/root/chat-root.js +22 -5
- package/dist/checkbox/root/checkbox-root.d.ts +20 -0
- package/dist/checkbox/root/checkbox-root.js +14 -1
- package/dist/checkbox-group/root/checkbox-group-root.d.ts +8 -2
- package/dist/checkbox-group/root/checkbox-group-root.js +12 -10
- package/dist/checkbox-group/select-all.d.ts +27 -0
- package/dist/checkbox-group/select-all.js +12 -0
- package/dist/code-block/highlight.d.ts +15 -0
- package/dist/code-block/highlight.js +4 -0
- package/dist/code-block/root/code-block-root.d.ts +49 -1
- package/dist/code-block/root/code-block-root.js +58 -3
- package/dist/color-input/root/color-input-root.d.ts +3 -0
- package/dist/color-input/root/color-input-root.js +6 -3
- package/dist/color-picker/root/color-picker-root.d.ts +33 -4
- package/dist/color-picker/root/color-picker-root.js +80 -21
- package/dist/color-picker/swatches.d.ts +12 -0
- package/dist/color-picker/swatches.js +26 -0
- package/dist/combobox/root/combobox-root.d.ts +43 -0
- package/dist/combobox/root/combobox-root.js +79 -15
- package/dist/command/root/command-root.d.ts +16 -1
- package/dist/command/root/command-root.js +22 -4
- package/dist/copy-button/root/copy-button-root.d.ts +5 -0
- package/dist/copy-button/root/copy-button-root.js +10 -3
- package/dist/data-table/index.d.ts +1 -1
- package/dist/data-table/index.js +1 -1
- package/dist/data-table/keys.d.ts +24 -0
- package/dist/data-table/keys.js +24 -0
- package/dist/data-table/root/data-table-root.d.ts +27 -18
- package/dist/data-table/root/data-table-root.js +20 -52
- package/dist/data-table/tree.d.ts +16 -1
- package/dist/data-table/tree.js +2 -3
- package/dist/date-input/root/date-input-root.d.ts +3 -1
- package/dist/date-input/root/date-input-root.js +18 -7
- package/dist/date-picker/root/date-picker-root.js +12 -6
- package/dist/dialog/description.js +15 -1
- package/dist/dialog/root/dialog-root.d.ts +8 -2
- package/dist/dialog/root/dialog-root.js +16 -1
- package/dist/divider/root/divider-root.d.ts +3 -0
- package/dist/divider/root/divider-root.js +2 -1
- package/dist/donut-chart/root/donut-chart-root.d.ts +31 -0
- package/dist/donut-chart/root/donut-chart-root.js +48 -1
- package/dist/drawer/reveal.d.ts +8 -0
- package/dist/drawer/reveal.js +1 -0
- package/dist/drawer/root/drawer-root.d.ts +59 -0
- package/dist/drawer/root/drawer-root.js +63 -4
- package/dist/drilldown/item/drilldown-item.js +1 -1
- package/dist/drilldown/root/drilldown-root.d.ts +21 -3
- package/dist/drilldown/root/drilldown-root.js +21 -3
- package/dist/element-events.generated.js +31 -5
- package/dist/empty/root/empty-root.d.ts +3 -1
- package/dist/empty/root/empty-root.js +3 -2
- package/dist/file-input/root/file-input-root.d.ts +69 -6
- package/dist/file-input/root/file-input-root.js +82 -19
- package/dist/file-input/screen.d.ts +2 -1
- package/dist/filter-input/menu/filter-menu.d.ts +2 -0
- package/dist/filter-input/menu/filter-menu.js +12 -4
- package/dist/filter-input/root/filter-input-root.d.ts +30 -6
- package/dist/filter-input/root/filter-input-root.js +1 -1
- package/dist/filter-input/suggest.d.ts +28 -3
- package/dist/filter-input/suggest.js +18 -8
- package/dist/format-date/root/format-date-root.d.ts +9 -16
- package/dist/format-date/root/format-date-root.js +10 -27
- package/dist/heatmap/root/heatmap-root.d.ts +24 -13
- package/dist/heatmap/root/heatmap-root.js +34 -12
- package/dist/icon/root/icon-root.d.ts +12 -1
- package/dist/icon/root/icon-root.js +21 -10
- package/dist/icon/settle.d.ts +7 -0
- package/dist/icon/settle.js +10 -0
- package/dist/icon-button/root/icon-button-root.d.ts +2 -0
- package/dist/image/root/image-root.d.ts +5 -1
- package/dist/image/root/image-root.js +1 -1
- package/dist/input/root/input-root.d.ts +12 -2
- package/dist/input/root/input-root.js +11 -2
- package/dist/kbd/root/kbd-root.d.ts +35 -1
- package/dist/kbd/root/kbd-root.js +23 -4
- package/dist/legend/root/legend-root.d.ts +55 -8
- package/dist/legend/root/legend-root.js +55 -13
- package/dist/lightbox/root/lightbox-root.d.ts +49 -6
- package/dist/lightbox/root/lightbox-root.js +86 -19
- package/dist/lightbox/zoom-controller.d.ts +59 -0
- package/dist/lightbox/zoom-controller.js +128 -0
- package/dist/lightbox/zoom.d.ts +22 -0
- package/dist/lightbox/zoom.js +16 -0
- package/dist/line-chart/root/line-chart-root.d.ts +22 -1
- package/dist/line-chart/root/line-chart-root.js +21 -1
- package/dist/list/item/list-item.d.ts +2 -0
- package/dist/list/item/list-item.js +11 -2
- package/dist/list/root/list-root.d.ts +62 -13
- package/dist/list/root/list-root.js +70 -13
- package/dist/list/selection.d.ts +37 -7
- package/dist/list/selection.js +16 -7
- package/dist/listbox/root/listbox-root.d.ts +37 -1
- package/dist/listbox/root/listbox-root.js +49 -3
- package/dist/loader/busy.d.ts +10 -0
- package/dist/loader/busy.js +11 -0
- package/dist/loader/root/loader-root.d.ts +9 -2
- package/dist/loader/root/loader-root.js +23 -3
- package/dist/megamenu/root/megamenu-root.d.ts +51 -10
- package/dist/megamenu/root/megamenu-root.js +76 -5
- package/dist/menu/item/menu-item.d.ts +51 -2
- package/dist/menu/item/menu-item.js +47 -23
- package/dist/menu/root/menu-root.d.ts +14 -0
- package/dist/menu/root/menu-root.js +2 -2
- package/dist/meter/root/meter-root.d.ts +20 -1
- package/dist/meter/root/meter-root.js +11 -15
- package/dist/navigation/root/navigation-root.d.ts +2 -1
- package/dist/navigation/root/navigation-root.js +2 -2
- package/dist/notifications/root/notifications-root.d.ts +10 -3
- package/dist/notifications/root/notifications-root.js +19 -7
- package/dist/number-input/root/number-input-root.d.ts +17 -8
- package/dist/number-input/root/number-input-root.js +2 -7
- package/dist/object-inspector/root/object-inspector-root.d.ts +75 -27
- package/dist/object-inspector/root/object-inspector-root.js +117 -76
- package/dist/object-inspector/rows.d.ts +18 -0
- package/dist/object-inspector/rows.js +33 -0
- package/dist/option/root/option-root.d.ts +5 -3
- package/dist/outline/root/outline-root.d.ts +18 -0
- package/dist/outline/root/outline-root.js +23 -5
- package/dist/pagination/size/pagination-size.d.ts +1 -0
- package/dist/pagination/size/pagination-size.js +1 -1
- package/dist/pin-input/code.d.ts +10 -0
- package/dist/pin-input/code.js +13 -0
- package/dist/pin-input/root/pin-input-root.d.ts +25 -1
- package/dist/pin-input/root/pin-input-root.js +10 -11
- package/dist/popover/hide-outside.d.ts +14 -0
- package/dist/popover/hide-outside.js +41 -0
- package/dist/popover/root/popover-root.d.ts +57 -7
- package/dist/popover/root/popover-root.js +58 -3
- package/dist/progress/root/progress-root.d.ts +20 -0
- package/dist/progress/root/progress-root.js +15 -15
- package/dist/qr-code/export.d.ts +26 -1
- package/dist/qr-code/export.js +14 -0
- package/dist/qr-code/root/qr-code-root.d.ts +19 -5
- package/dist/qr-code/root/qr-code-root.js +58 -9
- package/dist/quote/marks.d.ts +8 -0
- package/dist/quote/marks.js +5 -0
- package/dist/quote/root/quote-root.d.ts +14 -2
- package/dist/quote/root/quote-root.js +23 -1
- package/dist/radio/root/radio-root.d.ts +6 -2
- package/dist/radio/root/radio-root.js +6 -1
- package/dist/rating/root/rating-root.d.ts +9 -4
- package/dist/rating/root/rating-root.js +31 -7
- package/dist/rating/steps.d.ts +7 -0
- package/dist/rating/steps.js +9 -0
- package/dist/scatter-chart/fit.d.ts +15 -0
- package/dist/scatter-chart/fit.js +35 -0
- package/dist/scatter-chart/root/scatter-chart-root.d.ts +21 -1
- package/dist/scatter-chart/root/scatter-chart-root.js +30 -17
- package/dist/scroll-area/root/scroll-area-root.d.ts +22 -51
- package/dist/scroll-area/root/scroll-area-root.js +57 -173
- package/dist/scroll-area/scrollbar-controller.d.ts +111 -0
- package/dist/scroll-area/scrollbar-controller.js +172 -0
- package/dist/scroll-area/scrollbar.d.ts +27 -0
- package/dist/scroll-area/scrollbar.js +9 -0
- package/dist/select/root/select-root.d.ts +15 -0
- package/dist/select/root/select-root.js +18 -6
- package/dist/skeleton/root/skeleton-root.d.ts +3 -0
- package/dist/skeleton/root/skeleton-root.js +4 -2
- package/dist/skip-link/root/skip-link-root.js +2 -2
- package/dist/slider/root/slider-root.d.ts +41 -4
- package/dist/slider/root/slider-root.js +23 -3
- package/dist/sparkline/readings.d.ts +18 -0
- package/dist/sparkline/readings.js +19 -0
- package/dist/sparkline/root/sparkline-root.d.ts +78 -7
- package/dist/sparkline/root/sparkline-root.js +118 -23
- package/dist/speed-dial/root/speed-dial-root.js +2 -2
- package/dist/splitter/root/splitter-root.d.ts +7 -12
- package/dist/splitter/root/splitter-root.js +209 -204
- package/dist/stat/root/stat-root.d.ts +14 -5
- package/dist/stat/root/stat-root.js +21 -5
- package/dist/steps/reach.d.ts +5 -0
- package/dist/steps/reach.js +3 -0
- package/dist/steps/root/steps-root.d.ts +49 -3
- package/dist/steps/root/steps-root.js +44 -5
- package/dist/steps/step/step.d.ts +7 -0
- package/dist/steps/step/step.js +7 -2
- package/dist/switch/root/switch-root.d.ts +10 -0
- package/dist/table/column/table-column.d.ts +0 -10
- package/dist/table/column/table-column.js +3 -19
- package/dist/table/root/table-root.d.ts +31 -10
- package/dist/table/root/table-root.js +2 -13
- package/dist/tabs/panel/tab-panel.d.ts +16 -3
- package/dist/tabs/panel/tab-panel.js +34 -5
- package/dist/tabs/root/tabs-root.d.ts +12 -0
- package/dist/tabs/root/tabs-root.js +1 -1
- package/dist/tabs/tab/tab.d.ts +5 -0
- package/dist/tabs/tab/tab.js +5 -2
- package/dist/tag/group/tag-group.d.ts +31 -4
- package/dist/tag/group/tag-group.js +46 -7
- package/dist/tag/root/tag-root.js +9 -2
- package/dist/textarea/root/textarea-root.d.ts +28 -1
- package/dist/textarea/root/textarea-root.js +40 -1
- package/dist/time-input/root/time-input-root.d.ts +5 -1
- package/dist/time-input/root/time-input-root.js +16 -8
- package/dist/time-picker/root/time-picker-root.d.ts +18 -4
- package/dist/time-picker/root/time-picker-root.js +7 -10
- package/dist/time-picker/wheel-name.d.ts +9 -0
- package/dist/time-picker/wheel-name.js +15 -0
- package/dist/timeline/group/timeline-group.js +2 -2
- package/dist/toast/item/toast-item.d.ts +14 -1
- package/dist/toast/item/toast-item.js +22 -5
- package/dist/toast/root/toast-root.d.ts +6 -0
- package/dist/toast/root/toast-root.js +16 -1
- package/dist/toggle/group/toggle-group.d.ts +24 -3
- package/dist/toggle/group/toggle-group.js +34 -5
- package/dist/tooltip/root/tooltip-root.d.ts +13 -2
- package/dist/tooltip/root/tooltip-root.js +9 -1
- package/dist/tour/back.d.ts +10 -0
- package/dist/tour/back.js +8 -0
- package/dist/tour/root/tour-root.d.ts +30 -2
- package/dist/tour/root/tour-root.js +34 -8
- package/dist/tree/item/tree-item.d.ts +7 -3
- package/dist/tree/item/tree-item.js +3 -0
- package/dist/tree/root/tree-root.d.ts +24 -3
- package/dist/tree/root/tree-root.js +32 -13
- package/dist/tree/selection.js +2 -15
- package/dist/trend/root/trend-root.d.ts +43 -18
- package/dist/trend/root/trend-root.js +31 -6
- package/dist/video/media-events.d.ts +13 -18
- package/dist/video/media-events.js +1 -5
- package/dist/video/root/video-root.d.ts +18 -5
- package/dist/video/root/video-root.js +19 -10
- package/dist/video-playlist/menu/video-playlist-menu.d.ts +2 -0
- package/dist/video-playlist/menu/video-playlist-menu.js +2 -1
- package/dist/video-playlist/root/video-playlist-root.d.ts +7 -1
- package/dist/virtual-list/fill.d.ts +0 -8
- package/dist/virtual-list/fill.js +1 -17
- package/dist/virtual-list/plan.d.ts +49 -0
- package/dist/virtual-list/plan.js +16 -0
- package/dist/virtual-list/root/virtual-list-root.d.ts +114 -13
- package/dist/virtual-list/root/virtual-list-root.js +183 -40
- package/lint.json +1 -1
- package/package.json +8 -8
- package/types/jsx.d.ts +4577 -835
- package/types/vue.d.ts +926 -168
- package/dist/chat/relative-clock.d.ts +0 -39
- package/dist/chat/relative-clock.js +0 -31
- package/dist/data-table/root/order.d.ts +0 -141
- package/dist/data-table/root/order.js +0 -76
- package/dist/tag/selection.d.ts +0 -10
- package/dist/tag/selection.js +0 -12
|
@@ -20,6 +20,12 @@ import '../../copy-button/index.js';
|
|
|
20
20
|
* Shiki or Prism, and the block draws what it returns; the code stays in the
|
|
21
21
|
* slot, so the copy button and the page's own text are the code as written.
|
|
22
22
|
*
|
|
23
|
+
* Set `expandable` on a block whose height is capped, such as by
|
|
24
|
+
* `--code-block-max-block-size`, and a button under it shows every line and
|
|
25
|
+
* then fewer again, as a docs site's long example does. The button is drawn
|
|
26
|
+
* only while the cap hides something, says whether the block is expanded, and
|
|
27
|
+
* the block carries `:state(expanded)` while it is.
|
|
28
|
+
*
|
|
23
29
|
* Set `diff` to show a change. Put a unified diff, the output of `git diff` or
|
|
24
30
|
* `diff -u`, in the same slot, and the block draws the lines it added and
|
|
25
31
|
* removed. The block never computes a diff itself. Line numbers come from the
|
|
@@ -61,6 +67,7 @@ import '../../copy-button/index.js';
|
|
|
61
67
|
* @csspart copy-tooltip-left - The tooltip while it is left of the copy button. Applied with `copy-tooltip`.
|
|
62
68
|
* @csspart copy-tooltip-right - The tooltip while it is right of the copy button. Applied with `copy-tooltip`.
|
|
63
69
|
* @csspart copy-tooltip-top - The tooltip while it is above the copy button. Applied with `copy-tooltip`.
|
|
70
|
+
* @csspart expand - The button under a capped block that shows every line, and fewer again. Drawn when `expandable` is set and the cap hides something.
|
|
64
71
|
* @csspart file - In a diff, one file's header and block.
|
|
65
72
|
* @csspart filler - In a split diff, the empty row opposite a line the other side does not have.
|
|
66
73
|
* @csspart frame - The code, and the copy button beside it where there is no header.
|
|
@@ -75,8 +82,14 @@ import '../../copy-button/index.js';
|
|
|
75
82
|
* @csspart removed - In a diff, a line only the old version has, a `<del>`.
|
|
76
83
|
* @csspart split - In a split diff, the two versions side by side.
|
|
77
84
|
* @csspart text - In a diff, a line's code.
|
|
85
|
+
*
|
|
86
|
+
* @cssstate expanded - The expand button has shown every line of a capped block.
|
|
78
87
|
*/
|
|
79
88
|
export declare class HelixHeadlessCodeBlock extends HelixElement {
|
|
89
|
+
/**
|
|
90
|
+
* The expand button's words while the block shows every line.
|
|
91
|
+
*/
|
|
92
|
+
collapseLabel: string;
|
|
80
93
|
/**
|
|
81
94
|
* The copy button's name and tooltip text after a copy.
|
|
82
95
|
*/
|
|
@@ -96,6 +109,19 @@ export declare class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
96
109
|
* `false` reflects as no attribute at all.
|
|
97
110
|
*/
|
|
98
111
|
diff: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Whether a block whose height is capped takes a button that shows every
|
|
114
|
+
* line, and fewer again.
|
|
115
|
+
*
|
|
116
|
+
* The cap is the page's, `--code-block-max-block-size` on the styled tier;
|
|
117
|
+
* the button is drawn only while the cap hides something, measured as the
|
|
118
|
+
* block lays out. Not for a diff, whose files each scroll on their own.
|
|
119
|
+
*/
|
|
120
|
+
expandable: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* The expand button's words while the cap hides lines.
|
|
123
|
+
*/
|
|
124
|
+
expandLabel: string;
|
|
99
125
|
/**
|
|
100
126
|
* Turns the code into highlighted markup, which the block draws in place of
|
|
101
127
|
* the plain text.
|
|
@@ -103,7 +129,9 @@ export declare class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
103
129
|
* Called with the code as written and returning HTML, such as the output of
|
|
104
130
|
* Shiki's `codeToHtml` or Prism's `highlight`. **The markup is drawn as
|
|
105
131
|
* given**, so it has to escape the code it was handed, which those
|
|
106
|
-
* highlighters do.
|
|
132
|
+
* highlighters do. A `<pre>` and `<code>` around the whole of it, which
|
|
133
|
+
* Shiki writes, are taken off, so the lines sit level with the gutter's
|
|
134
|
+
* numbers and the block keeps one tab stop. Bind the language in the function you pass. The code
|
|
107
135
|
* stays in the slot, so the copy button copies it as written and a reader
|
|
108
136
|
* without the script still has it. Not called on a server, which has no code
|
|
109
137
|
* to read, nor for a diff.
|
|
@@ -184,10 +212,30 @@ export declare class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
184
212
|
* was not redrawn.
|
|
185
213
|
*/
|
|
186
214
|
private observer;
|
|
215
|
+
/** Whether the cap hides lines, measured from the drawn block. */
|
|
216
|
+
private capped;
|
|
217
|
+
/** Whether the expand button has shown every line. */
|
|
218
|
+
private expanded;
|
|
219
|
+
/** Watches the block's size, while it is expandable. */
|
|
220
|
+
private sizes;
|
|
221
|
+
/**
|
|
222
|
+
* Reads whether the cap hides lines: the scroller is taller inside than it
|
|
223
|
+
* is drawn. The styled tier caps the `<code>`, and a page may cap the
|
|
224
|
+
* `<pre>`, so both are asked. Left as it was while expanded, which shows
|
|
225
|
+
* everything.
|
|
226
|
+
*/
|
|
227
|
+
private readonly measure;
|
|
228
|
+
protected updated(changed: PropertyValues): void;
|
|
187
229
|
connectedCallback(): void;
|
|
188
230
|
disconnectedCallback(): void;
|
|
189
231
|
protected firstUpdated(changed: PropertyValues): void;
|
|
190
232
|
protected render(): TemplateResult;
|
|
233
|
+
/**
|
|
234
|
+
* The button that shows every line of a capped block, and fewer again, or
|
|
235
|
+
* nothing while the cap hides nothing. Not on a server, which cannot
|
|
236
|
+
* measure, so a served block draws none and the client adds it.
|
|
237
|
+
*/
|
|
238
|
+
private renderExpand;
|
|
191
239
|
/**
|
|
192
240
|
* The name with the copy button beside it, or nothing when there is no name.
|
|
193
241
|
*
|
|
@@ -6,22 +6,36 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { customElement, HelixElement } from '@fusion.dev/helix-core';
|
|
8
8
|
import { nothing } from 'lit';
|
|
9
|
-
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { property, state } from 'lit/decorators.js';
|
|
10
10
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
11
11
|
import { html } from 'lit/static-html.js';
|
|
12
12
|
import '../../copy-button/index.js';
|
|
13
|
+
import { highlightedLines } from '../highlight.js';
|
|
13
14
|
import { gutterNumbers, lineCount } from '../lines.js';
|
|
14
15
|
import { pairLines, parsePatch } from '../patch.js';
|
|
15
16
|
let HelixHeadlessCodeBlock = class HelixHeadlessCodeBlock extends HelixElement {
|
|
16
17
|
constructor() {
|
|
17
18
|
super(...arguments);
|
|
19
|
+
this.collapseLabel = 'Show fewer lines';
|
|
18
20
|
this.copiedLabel = 'Copied';
|
|
19
21
|
this.copyLabel = 'Copy code';
|
|
20
22
|
this.diff = false;
|
|
23
|
+
this.expandable = false;
|
|
24
|
+
this.expandLabel = 'Show all lines';
|
|
21
25
|
this.label = '';
|
|
22
26
|
this.lineNumbers = false;
|
|
23
27
|
this.noCopy = false;
|
|
24
28
|
this.parsed = { files: [], text: '' };
|
|
29
|
+
this.capped = false;
|
|
30
|
+
this.expanded = false;
|
|
31
|
+
this.measure = () => {
|
|
32
|
+
if (!this.expanded) {
|
|
33
|
+
this.capped =
|
|
34
|
+
this.expandable &&
|
|
35
|
+
!this.diff &&
|
|
36
|
+
[...this.renderRoot.querySelectorAll('[part="block"], [part="code"]')].some((box) => box.scrollHeight > box.clientHeight + 1);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
25
39
|
}
|
|
26
40
|
get files() {
|
|
27
41
|
if (!this.diff) {
|
|
@@ -43,6 +57,14 @@ let HelixHeadlessCodeBlock = class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
43
57
|
.map((node) => node.textContent ?? '')
|
|
44
58
|
.join('');
|
|
45
59
|
}
|
|
60
|
+
updated(changed) {
|
|
61
|
+
super.updated(changed);
|
|
62
|
+
if (this.expandable && typeof ResizeObserver !== 'undefined') {
|
|
63
|
+
this.sizes ??= new ResizeObserver(this.measure);
|
|
64
|
+
this.sizes.observe(this);
|
|
65
|
+
}
|
|
66
|
+
this.measure();
|
|
67
|
+
}
|
|
46
68
|
connectedCallback() {
|
|
47
69
|
super.connectedCallback();
|
|
48
70
|
if (typeof MutationObserver !== 'undefined') {
|
|
@@ -52,6 +74,8 @@ let HelixHeadlessCodeBlock = class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
52
74
|
}
|
|
53
75
|
disconnectedCallback() {
|
|
54
76
|
super.disconnectedCallback();
|
|
77
|
+
this.sizes?.disconnect();
|
|
78
|
+
this.sizes = undefined;
|
|
55
79
|
this.observer?.disconnect();
|
|
56
80
|
}
|
|
57
81
|
firstUpdated(changed) {
|
|
@@ -64,7 +88,7 @@ let HelixHeadlessCodeBlock = class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
64
88
|
return this.renderDiff(files);
|
|
65
89
|
}
|
|
66
90
|
const text = this.text;
|
|
67
|
-
const highlighted = this.highlight && text !== '' ? this.highlight(text) : undefined;
|
|
91
|
+
const highlighted = this.highlight && text !== '' ? highlightedLines(this.highlight(text)) : undefined;
|
|
68
92
|
const code = highlighted === undefined
|
|
69
93
|
? html `<code part="code"><slot @slotchange=${() => this.requestUpdate()}></slot></code>`
|
|
70
94
|
: html `<code part="code">${unsafeHTML(highlighted)}</code><slot
|
|
@@ -79,7 +103,23 @@ let HelixHeadlessCodeBlock = class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
79
103
|
<div part="frame">
|
|
80
104
|
<pre part="block">${gutter}${code}</pre>
|
|
81
105
|
${this.label ? nothing : this.renderCopy()}
|
|
82
|
-
</div
|
|
106
|
+
</div>${this.renderExpand()}`;
|
|
107
|
+
}
|
|
108
|
+
renderExpand() {
|
|
109
|
+
if (!this.expandable || !(this.capped || this.expanded)) {
|
|
110
|
+
return nothing;
|
|
111
|
+
}
|
|
112
|
+
return html `<button
|
|
113
|
+
aria-expanded=${this.expanded ? 'true' : 'false'}
|
|
114
|
+
part="expand"
|
|
115
|
+
type="button"
|
|
116
|
+
@click=${() => {
|
|
117
|
+
this.expanded = !this.expanded;
|
|
118
|
+
this.toggleState('expanded', this.expanded);
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
${this.expanded ? this.collapseLabel : this.expandLabel}
|
|
122
|
+
</button>`;
|
|
83
123
|
}
|
|
84
124
|
renderHeader(name, value) {
|
|
85
125
|
return name
|
|
@@ -150,6 +190,9 @@ let HelixHeadlessCodeBlock = class HelixHeadlessCodeBlock extends HelixElement {
|
|
|
150
190
|
})}<slot hidden @slotchange=${() => this.requestUpdate()}></slot>`;
|
|
151
191
|
}
|
|
152
192
|
};
|
|
193
|
+
__decorate([
|
|
194
|
+
property({ attribute: 'collapse-label' })
|
|
195
|
+
], HelixHeadlessCodeBlock.prototype, "collapseLabel", void 0);
|
|
153
196
|
__decorate([
|
|
154
197
|
property({ attribute: 'copied-label' })
|
|
155
198
|
], HelixHeadlessCodeBlock.prototype, "copiedLabel", void 0);
|
|
@@ -159,6 +202,12 @@ __decorate([
|
|
|
159
202
|
__decorate([
|
|
160
203
|
property({ reflect: true, type: Boolean })
|
|
161
204
|
], HelixHeadlessCodeBlock.prototype, "diff", void 0);
|
|
205
|
+
__decorate([
|
|
206
|
+
property({ type: Boolean })
|
|
207
|
+
], HelixHeadlessCodeBlock.prototype, "expandable", void 0);
|
|
208
|
+
__decorate([
|
|
209
|
+
property({ attribute: 'expand-label' })
|
|
210
|
+
], HelixHeadlessCodeBlock.prototype, "expandLabel", void 0);
|
|
162
211
|
__decorate([
|
|
163
212
|
property({ attribute: false })
|
|
164
213
|
], HelixHeadlessCodeBlock.prototype, "highlight", void 0);
|
|
@@ -174,6 +223,12 @@ __decorate([
|
|
|
174
223
|
__decorate([
|
|
175
224
|
property({ reflect: true })
|
|
176
225
|
], HelixHeadlessCodeBlock.prototype, "variant", void 0);
|
|
226
|
+
__decorate([
|
|
227
|
+
state()
|
|
228
|
+
], HelixHeadlessCodeBlock.prototype, "capped", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
state()
|
|
231
|
+
], HelixHeadlessCodeBlock.prototype, "expanded", void 0);
|
|
177
232
|
HelixHeadlessCodeBlock = __decorate([
|
|
178
233
|
customElement('helix-headless-code-block')
|
|
179
234
|
], HelixHeadlessCodeBlock);
|
|
@@ -45,6 +45,8 @@ declare const HelixHeadlessColorInput_base: (new (...args: any[]) => import("@fu
|
|
|
45
45
|
* @slot end - Content at the trailing end, before the trigger.
|
|
46
46
|
* @slot feedback - The message that says what is wrong with the value.
|
|
47
47
|
* @slot hint - Help text under the field.
|
|
48
|
+
* @slot panel-footer - Content in the panel under the picker, such as a note or an action.
|
|
49
|
+
* @slot panel-header - Content in the panel above the picker, such as a heading or a shortcut.
|
|
48
50
|
* @slot start - Content at the leading end of the field, inside its border.
|
|
49
51
|
* @slot trigger - The icon on the trigger, which shows that the field opens a panel.
|
|
50
52
|
*
|
|
@@ -78,6 +80,7 @@ declare const HelixHeadlessColorInput_base: (new (...args: any[]) => import("@fu
|
|
|
78
80
|
* @csspart picker-eyedropper-button - The button inside `picker-eyedropper`.
|
|
79
81
|
* @csspart picker-eyedropper-live - The live region of the button inside `picker-eyedropper`, which says its pending label.
|
|
80
82
|
* @csspart picker-eyedropper-text - The words on the button inside `picker-eyedropper`.
|
|
83
|
+
* @csspart picker-feedback - The field's message inside the open panel, under the picker, where the panel covers the one under the field.
|
|
81
84
|
* @csspart picker-field - One channel's number field with its label, in `channel-fields`.
|
|
82
85
|
* @csspart picker-field-input - The number input in a channel's field.
|
|
83
86
|
* @csspart picker-field-label - The name above a channel's number input.
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { AriaForwardController, colorName, customElement, HelixFormElement, MixinControllerOpen, MixinControllerValue, MixinField, MixinPickerField, parseColor, toCss, } from '@fusion.dev/helix-core';
|
|
7
|
+
import { AriaForwardController, colorName, customElement, HelixFormElement, MixinControllerOpen, MixinControllerValue, MixinField, MixinPickerField, parseColor, toCss, wordsConverter, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { nothing } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
10
|
import { html } from 'lit/static-html.js';
|
|
@@ -117,13 +117,14 @@ let HelixHeadlessColorInput = class HelixHeadlessColorInput extends MixinPickerF
|
|
|
117
117
|
channel-markers: picker-channel-markers, channel-output: picker-channel-output,
|
|
118
118
|
channels: picker-channels, controls: picker-controls, eyedropper: picker-eyedropper,
|
|
119
119
|
eyedropper-button: picker-eyedropper-button, eyedropper-live: picker-eyedropper-live, eyedropper-text: picker-eyedropper-text,
|
|
120
|
-
field: picker-field, field-input: picker-field-input, field-label: picker-field-label,
|
|
120
|
+
feedback: picker-feedback, field: picker-field, field-input: picker-field-input, field-label: picker-field-label,
|
|
121
121
|
fields: picker-fields, footer: picker-footer, format: picker-format,
|
|
122
122
|
format-button: picker-format-button, format-live: picker-format-live, format-text: picker-format-text, grid: picker-grid,
|
|
123
123
|
grid-brightness: picker-grid-brightness, grid-handle: picker-grid-handle,
|
|
124
124
|
grid-saturation: picker-grid-saturation, icon: picker-icon, sample: picker-sample,
|
|
125
125
|
swatch: picker-swatch, swatches: picker-swatches, value: picker-value"
|
|
126
126
|
?invalid=${this.resolvedFeedback !== ''}
|
|
127
|
+
.feedback=${this.resolvedFeedback}
|
|
127
128
|
?alpha=${this.alpha}
|
|
128
129
|
?channel-fields=${this.channelFields}
|
|
129
130
|
?no-format=${this.noFormat}
|
|
@@ -209,7 +210,9 @@ let HelixHeadlessColorInput = class HelixHeadlessColorInput extends MixinPickerF
|
|
|
209
210
|
popover="manual"
|
|
210
211
|
?hidden=${!this.open}
|
|
211
212
|
>
|
|
213
|
+
<slot name="panel-header"></slot>
|
|
212
214
|
${this.renderPicker()}
|
|
215
|
+
<slot name="panel-footer"></slot>
|
|
213
216
|
</div>
|
|
214
217
|
${this.renderHint()}${this.renderFeedback()}`;
|
|
215
218
|
}
|
|
@@ -224,7 +227,7 @@ __decorate([
|
|
|
224
227
|
property({ attribute: 'channel-fields', type: Boolean })
|
|
225
228
|
], HelixHeadlessColorInput.prototype, "channelFields", void 0);
|
|
226
229
|
__decorate([
|
|
227
|
-
property({ attribute: 'color-words',
|
|
230
|
+
property({ attribute: 'color-words', converter: wordsConverter })
|
|
228
231
|
], HelixHeadlessColorInput.prototype, "colorWords", void 0);
|
|
229
232
|
__decorate([
|
|
230
233
|
property({ reflect: true })
|
|
@@ -29,8 +29,12 @@ declare const HelixHeadlessColorPicker_base: (new (...args: any[]) => import("@f
|
|
|
29
29
|
*
|
|
30
30
|
* A screen reader hears the color's name, such as "vibrant red", after the two
|
|
31
31
|
* numbers on the square and after the number on the hue ramp, and each preset
|
|
32
|
-
* is named by its color.
|
|
33
|
-
* language.
|
|
32
|
+
* is named by its color. The opacity ramp is heard as a percentage. Set
|
|
33
|
+
* `color-words` to speak the names in another language.
|
|
34
|
+
*
|
|
35
|
+
* The presets are a listbox with the current color selected, and one tab
|
|
36
|
+
* stop. The arrow keys move between them, Home and End go to the ends, and
|
|
37
|
+
* Enter, Space or a press chooses one.
|
|
34
38
|
*
|
|
35
39
|
* @since 0.1.0
|
|
36
40
|
* @status stable
|
|
@@ -64,6 +68,7 @@ declare const HelixHeadlessColorPicker_base: (new (...args: any[]) => import("@f
|
|
|
64
68
|
* @csspart eyedropper-button - The button inside `eyedropper`.
|
|
65
69
|
* @csspart eyedropper-live - The live region of the button inside `eyedropper`, which says its pending label.
|
|
66
70
|
* @csspart eyedropper-text - The words on the button inside `eyedropper`, trimmed to their capitals and baseline.
|
|
71
|
+
* @csspart feedback - The message under the picker, while `feedback` is set.
|
|
67
72
|
* @csspart field - One channel's number field with its label, in `channel-fields`.
|
|
68
73
|
* @csspart field-input - The number input in a channel's field.
|
|
69
74
|
* @csspart field-label - The name above a channel's number input.
|
|
@@ -80,8 +85,8 @@ declare const HelixHeadlessColorPicker_base: (new (...args: any[]) => import("@f
|
|
|
80
85
|
* @csspart grid-brightness - The range input for the square's vertical axis.
|
|
81
86
|
* @csspart grid-saturation - The range input for the square's horizontal axis.
|
|
82
87
|
* @csspart sample - A chip of the current color. Pressing it copies the value.
|
|
83
|
-
* @csspart swatch - One preset.
|
|
84
|
-
* @csspart swatches - The row of presets.
|
|
88
|
+
* @csspart swatch - One preset, an option in the `swatches` listbox.
|
|
89
|
+
* @csspart swatches - The row of presets, a listbox.
|
|
85
90
|
* @csspart value - The text field that holds the color. It accepts a typed or pasted color.
|
|
86
91
|
*
|
|
87
92
|
* @cssproperty --color-picker-brightness - The chosen brightness, 0 to 100, as a percentage.
|
|
@@ -160,6 +165,15 @@ export declare class HelixHeadlessColorPicker extends HelixHeadlessColorPicker_b
|
|
|
160
165
|
* What the eyedropper is called.
|
|
161
166
|
*/
|
|
162
167
|
eyedropperLabel: string;
|
|
168
|
+
/**
|
|
169
|
+
* A message under the picker, such as what is wrong with the color.
|
|
170
|
+
*
|
|
171
|
+
* While set, the picker is invalid and does not submit, as a field's
|
|
172
|
+
* `feedback` is, and the square and the value text are described by it.
|
|
173
|
+
* Color Input shows its own message here, so a reader in the open panel
|
|
174
|
+
* still sees it.
|
|
175
|
+
*/
|
|
176
|
+
feedback: string;
|
|
163
177
|
/**
|
|
164
178
|
* The syntax the value is written in: `hex`, `rgb`, or `hsl`.
|
|
165
179
|
*
|
|
@@ -322,6 +336,8 @@ export declare class HelixHeadlessColorPicker extends HelixHeadlessColorPicker_b
|
|
|
322
336
|
* server's markup, which was rendered without it.
|
|
323
337
|
*/
|
|
324
338
|
private sampling;
|
|
339
|
+
/** The preset the reader was last on, which holds the row's one tab stop. */
|
|
340
|
+
private swatchAt;
|
|
325
341
|
/**
|
|
326
342
|
* Whether the value on this element was produced here.
|
|
327
343
|
*
|
|
@@ -393,6 +409,11 @@ export declare class HelixHeadlessColorPicker extends HelixHeadlessColorPicker_b
|
|
|
393
409
|
private readonly copier;
|
|
394
410
|
/** Takes a preset, in this picker's syntax rather than as the preset spelled it. */
|
|
395
411
|
private readonly handleSwatch;
|
|
412
|
+
/**
|
|
413
|
+
* The arrows, Home and End in the presets: focus moves, and nothing is
|
|
414
|
+
* chosen until Enter, Space or a press, as in React Aria's swatch picker.
|
|
415
|
+
*/
|
|
416
|
+
private readonly handleSwatchKeydown;
|
|
396
417
|
/** Walks the format on, and rewrites the value in it. */
|
|
397
418
|
private readonly handleFormat;
|
|
398
419
|
/**
|
|
@@ -449,6 +470,8 @@ export declare class HelixHeadlessColorPicker extends HelixHeadlessColorPicker_b
|
|
|
449
470
|
* what React Aria's ColorArea does.
|
|
450
471
|
*/
|
|
451
472
|
private readonly handleAreaKeydown;
|
|
473
|
+
/** @internal `feedback` marks the picker invalid, as a field's does. */
|
|
474
|
+
protected get validityFeedback(): string;
|
|
452
475
|
/**
|
|
453
476
|
* Reports "required and empty", or clears it.
|
|
454
477
|
*
|
|
@@ -557,6 +580,12 @@ export declare class HelixHeadlessColorPicker extends HelixHeadlessColorPicker_b
|
|
|
557
580
|
* tiers.
|
|
558
581
|
*/
|
|
559
582
|
protected renderTools(): TemplateResult;
|
|
583
|
+
/**
|
|
584
|
+
* The presets, as a listbox of colors with the current one selected, which
|
|
585
|
+
* is React Aria's ColorSwatchPicker: one tab stop, held by the preset the
|
|
586
|
+
* reader was last on, then the selected one, then the first.
|
|
587
|
+
*/
|
|
588
|
+
private renderSwatches;
|
|
560
589
|
protected render(): TemplateResult;
|
|
561
590
|
}
|
|
562
591
|
declare global {
|
|
@@ -4,13 +4,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { CopyController, capturePointer, colorName, customElement, drawIcon, fillTemplate, formatColor, HelixFormElement, HelixSampleEndEvent, HelixSampleStartEvent, hostAria, hueName, isRtl, MixinControllerValue, parseColor, splitValues, toCss, } from '@fusion.dev/helix-core';
|
|
7
|
+
import { CopyController, capturePointer, colorName, customElement, drawIcon, fillTemplate, formatColor, HelixFormElement, HelixSampleEndEvent, HelixSampleStartEvent, hostAria, hueName, inlineStep, isRtl, MixinControllerValue, parseColor, rovingStop, splitValues, toCss, wordsConverter, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { eyedropper } from '@fusion.dev/helix-icons';
|
|
9
9
|
import { nothing } from 'lit';
|
|
10
10
|
import { property, state } from 'lit/decorators.js';
|
|
11
11
|
import { live } from 'lit/directives/live.js';
|
|
12
12
|
import { html } from 'lit/static-html.js';
|
|
13
13
|
import { channelFields, writeChannel } from '../channels.js';
|
|
14
|
+
import { swatchMove } from '../swatches.js';
|
|
14
15
|
import '../../button/index.js';
|
|
15
16
|
import '../../button-group/index.js';
|
|
16
17
|
import '../../slider/index.js';
|
|
@@ -28,6 +29,7 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
28
29
|
this.copiedLabel = 'Copied';
|
|
29
30
|
this.copyLabel = 'Copy {value}';
|
|
30
31
|
this.eyedropperLabel = 'Sample a color from the screen';
|
|
32
|
+
this.feedback = '';
|
|
31
33
|
this.formatLabel = 'Syntax: {format}. Change it.';
|
|
32
34
|
this.greenLabel = 'Green';
|
|
33
35
|
this.hueLabel = 'Hue';
|
|
@@ -79,10 +81,33 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
79
81
|
this.copier = new CopyController(this);
|
|
80
82
|
this.handleSwatch = (preset) => {
|
|
81
83
|
const parsed = parseColor(preset);
|
|
82
|
-
if (parsed) {
|
|
84
|
+
if (!parsed) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const format = this.format ?? 'hex';
|
|
88
|
+
const fields = channelFields(preset, parsed, format, this.alpha);
|
|
89
|
+
const first = fields[0];
|
|
90
|
+
const exact = first && writeChannel(fields, format, this.alpha, first.channel, first.value);
|
|
91
|
+
if (exact) {
|
|
92
|
+
this.takeWritten(exact);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
83
95
|
this.move(parsed);
|
|
84
|
-
this.settle();
|
|
85
96
|
}
|
|
97
|
+
this.settle();
|
|
98
|
+
};
|
|
99
|
+
this.handleSwatchKeydown = (event) => {
|
|
100
|
+
const row = [
|
|
101
|
+
...(this.renderRoot.querySelectorAll('[part="swatches"] [part="swatch"]') ?? []),
|
|
102
|
+
];
|
|
103
|
+
const at = row.indexOf(event.target);
|
|
104
|
+
const next = swatchMove(event.key, inlineStep(this, event.key), at, row.length);
|
|
105
|
+
if (at < 0 || next === null) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
this.swatchAt = next;
|
|
110
|
+
row[next]?.focus();
|
|
86
111
|
};
|
|
87
112
|
this.handleFormat = () => {
|
|
88
113
|
if (this.readOnly) {
|
|
@@ -214,6 +239,9 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
214
239
|
this.internals.setFormValue(this.value === '' ? null : this.value);
|
|
215
240
|
this.reportRequired();
|
|
216
241
|
}
|
|
242
|
+
get validityFeedback() {
|
|
243
|
+
return this.feedback;
|
|
244
|
+
}
|
|
217
245
|
reportRequired() {
|
|
218
246
|
if (this.required && this.value === '') {
|
|
219
247
|
this.internals.setValidity({ valueMissing: true }, this.valueMissingMessage || 'Choose a color.', this.partNamed('grid') ?? undefined);
|
|
@@ -370,6 +398,40 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
370
398
|
</${this.tag('button')}>`}
|
|
371
399
|
</${this.tag('button-group')}>`;
|
|
372
400
|
}
|
|
401
|
+
renderSwatches(painted) {
|
|
402
|
+
const presets = this.presets;
|
|
403
|
+
const chosen = presets.map((preset) => {
|
|
404
|
+
const parsed = parseColor(preset);
|
|
405
|
+
return parsed !== null && toCss(parsed) === painted;
|
|
406
|
+
});
|
|
407
|
+
const indexes = presets.map((_, index) => index);
|
|
408
|
+
const stop = rovingStop(indexes, this.swatchAt, { selected: (index) => chosen[index] === true });
|
|
409
|
+
return html `<div
|
|
410
|
+
part="swatches"
|
|
411
|
+
role="listbox"
|
|
412
|
+
aria-label=${this.presetsLabel}
|
|
413
|
+
aria-orientation="horizontal"
|
|
414
|
+
@keydown=${this.handleSwatchKeydown}
|
|
415
|
+
>
|
|
416
|
+
${presets.map((preset, index) => {
|
|
417
|
+
const parsed = parseColor(preset);
|
|
418
|
+
return html `<button
|
|
419
|
+
part="swatch"
|
|
420
|
+
type="button"
|
|
421
|
+
role="option"
|
|
422
|
+
tabindex=${index === stop ? '0' : '-1'}
|
|
423
|
+
aria-label=${parsed ? colorName(parsed, this.colorWords, this.lang) : preset}
|
|
424
|
+
aria-selected=${chosen[index] ? 'true' : 'false'}
|
|
425
|
+
style="--color-picker-swatch: ${preset}"
|
|
426
|
+
?disabled=${this.isDisabled}
|
|
427
|
+
@click=${() => {
|
|
428
|
+
this.swatchAt = index;
|
|
429
|
+
this.handleSwatch(preset);
|
|
430
|
+
}}
|
|
431
|
+
></button>`;
|
|
432
|
+
})}
|
|
433
|
+
</div>`;
|
|
434
|
+
}
|
|
373
435
|
render() {
|
|
374
436
|
const color = this.color;
|
|
375
437
|
const painted = toCss(color);
|
|
@@ -394,6 +456,7 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
394
456
|
min="0"
|
|
395
457
|
max="100"
|
|
396
458
|
aria-label=${axisName(this.saturationLabel)}
|
|
459
|
+
aria-describedby=${this.feedback === '' ? nothing : 'feedback'}
|
|
397
460
|
aria-valuetext=${both}
|
|
398
461
|
aria-invalid=${this.invalid ? 'true' : nothing}
|
|
399
462
|
.value=${String(color.saturation)}
|
|
@@ -409,6 +472,7 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
409
472
|
max="100"
|
|
410
473
|
tabindex="-1"
|
|
411
474
|
aria-label=${axisName(this.brightnessLabel)}
|
|
475
|
+
aria-describedby=${this.feedback === '' ? nothing : 'feedback'}
|
|
412
476
|
aria-valuetext=${reversed}
|
|
413
477
|
aria-invalid=${this.invalid ? 'true' : nothing}
|
|
414
478
|
.value=${String(color.brightness)}
|
|
@@ -431,7 +495,9 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
431
495
|
></button>
|
|
432
496
|
<div part="channels">
|
|
433
497
|
${this.renderChannel('hue', this.hueLabel, 360, color.hue, `{value}, ${hue}`)}
|
|
434
|
-
${this.alpha
|
|
498
|
+
${this.alpha
|
|
499
|
+
? this.renderChannel('alpha', this.opacityLabel, 100, color.alpha, new Intl.NumberFormat(this.lang || undefined, { style: 'percent' }).format(color.alpha / 100))
|
|
500
|
+
: nothing}
|
|
435
501
|
</div>
|
|
436
502
|
</div>
|
|
437
503
|
${this.channelFields ? this.renderFields(color) : nothing}
|
|
@@ -447,6 +513,7 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
447
513
|
part="value"
|
|
448
514
|
type="text"
|
|
449
515
|
aria-label=${this.valueLabel}
|
|
516
|
+
aria-describedby=${this.feedback === '' ? nothing : 'feedback'}
|
|
450
517
|
aria-invalid=${this.invalid ? 'true' : nothing}
|
|
451
518
|
autocomplete=${this.autocomplete || nothing}
|
|
452
519
|
spellcheck="false"
|
|
@@ -462,22 +529,8 @@ let HelixHeadlessColorPicker = class HelixHeadlessColorPicker extends MixinContr
|
|
|
462
529
|
${this.tools ? html `${this.renderTools()}` : nothing}
|
|
463
530
|
</div>
|
|
464
531
|
|
|
465
|
-
${this.presets.length === 0
|
|
466
|
-
|
|
467
|
-
: html `<div part="swatches" role="group" aria-label=${this.presetsLabel}>
|
|
468
|
-
${this.presets.map((preset) => {
|
|
469
|
-
const parsed = parseColor(preset);
|
|
470
|
-
return html `<button
|
|
471
|
-
part="swatch"
|
|
472
|
-
type="button"
|
|
473
|
-
aria-label=${parsed ? colorName(parsed, this.colorWords, this.lang) : preset}
|
|
474
|
-
aria-pressed=${parsed !== null && toCss(parsed) === painted ? 'true' : 'false'}
|
|
475
|
-
style="--color-picker-swatch: ${preset}"
|
|
476
|
-
?disabled=${this.isDisabled}
|
|
477
|
-
@click=${() => this.handleSwatch(preset)}
|
|
478
|
-
></button>`;
|
|
479
|
-
})}
|
|
480
|
-
</div>`}`;
|
|
532
|
+
${this.presets.length === 0 ? nothing : this.renderSwatches(painted)}
|
|
533
|
+
${this.feedback === '' ? nothing : html `<p part="feedback" id="feedback">${this.feedback}</p>`}`;
|
|
481
534
|
}
|
|
482
535
|
};
|
|
483
536
|
__decorate([
|
|
@@ -499,7 +552,7 @@ __decorate([
|
|
|
499
552
|
property({ attribute: 'channel-fields', type: Boolean })
|
|
500
553
|
], HelixHeadlessColorPicker.prototype, "channelFields", void 0);
|
|
501
554
|
__decorate([
|
|
502
|
-
property({ attribute: 'color-words',
|
|
555
|
+
property({ attribute: 'color-words', converter: wordsConverter })
|
|
503
556
|
], HelixHeadlessColorPicker.prototype, "colorWords", void 0);
|
|
504
557
|
__decorate([
|
|
505
558
|
property({ attribute: 'copied-label' })
|
|
@@ -510,6 +563,9 @@ __decorate([
|
|
|
510
563
|
__decorate([
|
|
511
564
|
property({ attribute: 'eyedropper-label' })
|
|
512
565
|
], HelixHeadlessColorPicker.prototype, "eyedropperLabel", void 0);
|
|
566
|
+
__decorate([
|
|
567
|
+
property()
|
|
568
|
+
], HelixHeadlessColorPicker.prototype, "feedback", void 0);
|
|
513
569
|
__decorate([
|
|
514
570
|
property({ reflect: true })
|
|
515
571
|
], HelixHeadlessColorPicker.prototype, "format", void 0);
|
|
@@ -573,6 +629,9 @@ __decorate([
|
|
|
573
629
|
__decorate([
|
|
574
630
|
state()
|
|
575
631
|
], HelixHeadlessColorPicker.prototype, "sampling", void 0);
|
|
632
|
+
__decorate([
|
|
633
|
+
state()
|
|
634
|
+
], HelixHeadlessColorPicker.prototype, "swatchAt", void 0);
|
|
576
635
|
HelixHeadlessColorPicker = __decorate([
|
|
577
636
|
customElement('helix-headless-color-picker')
|
|
578
637
|
], HelixHeadlessColorPicker);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a key moves focus in a row of presets, or `null` for a key that moves
|
|
3
|
+
* nothing.
|
|
4
|
+
*
|
|
5
|
+
* The presets are a listbox, React Aria's ColorSwatchPicker: one tab stop, and
|
|
6
|
+
* the arrows move between the colors without choosing one. `along` is the
|
|
7
|
+
* horizontal arrow's direction along the line of text, from `inlineStep`, so
|
|
8
|
+
* the row reverses with it; Up and Down go to the previous and the next as a
|
|
9
|
+
* list does, since the row wraps. Home and End go to the ends. Focus stops at
|
|
10
|
+
* the ends; a row of colors does not wrap around.
|
|
11
|
+
*/
|
|
12
|
+
export declare const swatchMove: (key: string, along: -1 | 0 | 1, at: number, count: number) => number | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const swatchMove = (key, along, at, count) => {
|
|
2
|
+
if (count === 0) {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
const last = count - 1;
|
|
6
|
+
let next;
|
|
7
|
+
if (along !== 0) {
|
|
8
|
+
next = at + along;
|
|
9
|
+
}
|
|
10
|
+
else if (key === 'ArrowUp') {
|
|
11
|
+
next = at - 1;
|
|
12
|
+
}
|
|
13
|
+
else if (key === 'ArrowDown') {
|
|
14
|
+
next = at + 1;
|
|
15
|
+
}
|
|
16
|
+
else if (key === 'Home') {
|
|
17
|
+
next = 0;
|
|
18
|
+
}
|
|
19
|
+
else if (key === 'End') {
|
|
20
|
+
next = last;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return Math.min(last, Math.max(0, next));
|
|
26
|
+
};
|