@redvars/peacock 3.15.0 → 3.17.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/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/assets/theme.js +19 -19
- package/dist/assets/tokens.css +1 -1
- package/dist/assets/tokens.css.map +1 -1
- package/dist/card-content.js +8 -7
- package/dist/card-content.js.map +1 -1
- package/dist/card.js +142 -98
- package/dist/card.js.map +1 -1
- package/dist/{chart-bar-D5dGFJfK.js → cartesian-chart-DgE4USyC.js} +529 -312
- package/dist/cartesian-chart-DgE4USyC.js.map +1 -0
- package/dist/chart-area.js +78 -0
- package/dist/chart-area.js.map +1 -0
- package/dist/chart-bar.js +283 -213
- package/dist/chart-bar.js.map +1 -1
- package/dist/{transform-DSwFSqzD.js → chart-base-C2qRMF48.js} +771 -102
- package/dist/chart-base-C2qRMF48.js.map +1 -0
- package/dist/chart-doughnut.js +55 -287
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-line.js +626 -0
- package/dist/chart-line.js.map +1 -0
- package/dist/chart-pie.js +637 -195
- package/dist/chart-pie.js.map +1 -1
- package/dist/code-editor.js +704 -131
- package/dist/code-editor.js.map +1 -1
- package/dist/code-group.js +188 -0
- package/dist/code-group.js.map +1 -0
- package/dist/code-highlighter.js +895 -257
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +2278 -677
- package/dist/custom-elements.json +13962 -3690
- package/dist/image.js +5 -1
- package/dist/image.js.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/loader-full.js +1 -1
- package/dist/loader.js +9 -3
- package/dist/loader.js.map +1 -1
- package/dist/{is-dark-mode-DOcaw4Yq.js → observe-theme-change-DCifz1uv.js} +2 -6
- package/dist/observe-theme-change-DCifz1uv.js.map +1 -0
- package/dist/pagination.js +408 -110
- package/dist/pagination.js.map +1 -1
- package/dist/path-CJ0Arqcy.js +166 -0
- package/dist/path-CJ0Arqcy.js.map +1 -0
- package/dist/snackbar.js +89 -34
- package/dist/snackbar.js.map +1 -1
- package/dist/src/__internal/chart/cartesian-chart.d.ts +80 -0
- package/dist/src/__internal/chart/chart-base.d.ts +113 -0
- package/dist/src/__internal/chart/paths.d.ts +5 -0
- package/dist/src/__internal/chart/types.d.ts +42 -0
- package/dist/src/card/card-content.d.ts +2 -3
- package/dist/src/card/card.d.ts +31 -17
- package/dist/src/chart-area/chart-area.d.ts +54 -0
- package/dist/src/chart-area/index.d.ts +1 -0
- package/dist/src/chart-bar/chart-bar.d.ts +44 -33
- package/dist/src/chart-bar/index.d.ts +0 -1
- package/dist/src/chart-doughnut/chart-doughnut.d.ts +33 -39
- package/dist/src/chart-line/chart-line.d.ts +69 -0
- package/dist/src/chart-line/index.d.ts +1 -0
- package/dist/src/chart-pie/chart-pie.d.ts +63 -28
- package/dist/src/code-editor/code-editor.d.ts +52 -13
- package/dist/src/code-editor/editor-theme.d.ts +60 -0
- package/dist/src/code-highlighter/code-group.d.ts +52 -0
- package/dist/src/code-highlighter/code-highlighter.d.ts +122 -15
- package/dist/src/code-highlighter/index.d.ts +1 -0
- package/dist/src/code-highlighter/line-ranges.d.ts +24 -0
- package/dist/src/code-highlighter/local.d.ts +4 -1
- package/dist/src/code-highlighter/token-colors.d.ts +8 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/pagination/page-items.d.ts +14 -0
- package/dist/src/pagination/pagination.d.ts +46 -7
- package/dist/src/snackbar/snackbar.d.ts +13 -1
- package/dist/src/table/table.d.ts +125 -27
- package/dist/src/toolbar/toolbar.d.ts +56 -51
- package/dist/table.js +1007 -338
- package/dist/table.js.map +1 -1
- package/dist/test/chart.test.d.ts +1 -0
- package/dist/test/code-highlighter.test.d.ts +1 -0
- package/dist/test/pagination.test.d.ts +1 -0
- package/dist/test/table.test.d.ts +1 -0
- package/dist/token-colors-0TFHWbcq.js +81 -0
- package/dist/token-colors-0TFHWbcq.js.map +1 -0
- package/dist/toolbar.js +195 -184
- package/dist/toolbar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/readme.md +7 -6
- package/scss/_code-block.scss +139 -0
- package/scss/tokens.css +24 -0
- package/src/__internal/chart/cartesian-chart.ts +404 -0
- package/src/__internal/chart/chart-base.scss +252 -0
- package/src/__internal/chart/chart-base.ts +474 -0
- package/src/__internal/chart/paths.ts +28 -0
- package/src/__internal/chart/types.ts +49 -0
- package/src/card/card-content.ts +12 -9
- package/src/card/card.scss +66 -54
- package/src/card/card.ts +109 -73
- package/src/chart-area/chart-area.ts +82 -0
- package/src/chart-area/index.ts +1 -0
- package/src/chart-bar/chart-bar.ts +336 -250
- package/src/chart-bar/index.ts +0 -1
- package/src/chart-doughnut/chart-doughnut.ts +62 -262
- package/src/chart-doughnut/demo/index.html +14 -22
- package/src/chart-line/chart-line.scss +25 -0
- package/src/chart-line/chart-line.ts +346 -0
- package/src/chart-line/index.ts +1 -0
- package/src/chart-pie/chart-pie.scss +35 -16
- package/src/chart-pie/chart-pie.ts +282 -188
- package/src/chart-pie/demo/index.html +13 -21
- package/src/code-editor/code-editor.scss +132 -36
- package/src/code-editor/code-editor.ts +308 -88
- package/src/code-editor/demo/index.html +39 -12
- package/src/code-editor/editor-theme.ts +213 -0
- package/src/code-highlighter/code-group.scss +34 -0
- package/src/code-highlighter/code-group.ts +173 -0
- package/src/code-highlighter/code-highlighter.scss +226 -111
- package/src/code-highlighter/code-highlighter.ts +554 -199
- package/src/code-highlighter/demo/index.html +68 -4
- package/src/code-highlighter/index.ts +1 -0
- package/src/code-highlighter/line-ranges.ts +81 -0
- package/src/code-highlighter/local.ts +9 -3
- package/src/code-highlighter/token-colors.ts +42 -0
- package/src/index.ts +4 -2
- package/src/loader.ts +8 -2
- package/src/pagination/page-items.ts +50 -0
- package/src/pagination/pagination.scss +159 -44
- package/src/pagination/pagination.ts +275 -74
- package/src/snackbar/demo/index.html +39 -4
- package/src/snackbar/snackbar.scss +27 -10
- package/src/snackbar/snackbar.ts +80 -37
- package/src/table/table.scss +337 -109
- package/src/table/table.ts +812 -272
- package/src/toolbar/toolbar-colors.scss +6 -7
- package/src/toolbar/toolbar.scss +35 -106
- package/src/toolbar/toolbar.ts +180 -80
- package/dist/array-D5vjT2Xm.js +0 -14
- package/dist/array-D5vjT2Xm.js.map +0 -1
- package/dist/chart-bar-D5dGFJfK.js.map +0 -1
- package/dist/chart-stacked-bar.js +0 -403
- package/dist/chart-stacked-bar.js.map +0 -1
- package/dist/copy-to-clipboard-upGx-Ueo.js +0 -39
- package/dist/copy-to-clipboard-upGx-Ueo.js.map +0 -1
- package/dist/is-dark-mode-DOcaw4Yq.js.map +0 -1
- package/dist/pie-Dz0IDiPt.js +0 -537
- package/dist/pie-Dz0IDiPt.js.map +0 -1
- package/dist/pierre-dark-DFWl0m-C.js +0 -4
- package/dist/pierre-dark-DFWl0m-C.js.map +0 -1
- package/dist/pierre-light-BEkAPImt.js +0 -4
- package/dist/pierre-light-BEkAPImt.js.map +0 -1
- package/dist/src/chart-bar/chart-stacked-bar.d.ts +0 -78
- package/dist/src/code-highlighter/constants.d.ts +0 -1
- package/dist/transform-DSwFSqzD.js.map +0 -1
- package/src/chart-bar/chart-bar.scss +0 -58
- package/src/chart-bar/chart-stacked-bar.ts +0 -398
- package/src/chart-doughnut/chart-donut.scss +0 -37
- package/src/code-highlighter/constants.ts +0 -117
- /package/dist/test/{chart-bar.test.d.ts → card.test.d.ts} +0 -0
|
@@ -1,50 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ChartBase } from '../__internal/chart/chart-base.js';
|
|
2
|
+
import type { ChartSeries, ChartTooltipModel } from '../__internal/chart/types.js';
|
|
3
|
+
export type { ChartSelectDetail, ChartValueFormatter, } from '../__internal/chart/types.js';
|
|
4
|
+
/** One slice. */
|
|
5
5
|
export type ChartPieItem = {
|
|
6
|
+
/** Unique key of the slice. */
|
|
6
7
|
name: string;
|
|
7
8
|
value: number;
|
|
9
|
+
/** Display name in the legend and tooltip. Defaults to `name`. */
|
|
8
10
|
label?: string;
|
|
11
|
+
/** Any CSS color. Defaults to the next `--color-chart-n` token. */
|
|
9
12
|
color?: string;
|
|
10
13
|
};
|
|
11
14
|
/**
|
|
12
|
-
* @label Chart
|
|
15
|
+
* @label Pie Chart
|
|
13
16
|
* @tag wc-chart-pie
|
|
14
17
|
* @rawTag chart-pie
|
|
15
|
-
* @summary
|
|
18
|
+
* @summary Shows how parts make up a whole. Best with a handful of slices.
|
|
16
19
|
* @tags charts
|
|
17
20
|
*
|
|
18
21
|
* @example
|
|
19
22
|
* ```html
|
|
20
|
-
* <wc-chart-pie
|
|
23
|
+
* <wc-chart-pie label="Visitors by browser"></wc-chart-pie>
|
|
21
24
|
* <script>
|
|
22
25
|
* document.querySelector('wc-chart-pie').data = [
|
|
23
|
-
* { name: '
|
|
24
|
-
* { name: '
|
|
25
|
-
* { name: '
|
|
26
|
+
* { name: 'chrome', label: 'Chrome', value: 275 },
|
|
27
|
+
* { name: 'safari', label: 'Safari', value: 200 },
|
|
28
|
+
* { name: 'firefox', label: 'Firefox', value: 187 },
|
|
26
29
|
* ];
|
|
27
30
|
* </script>
|
|
28
31
|
* ```
|
|
32
|
+
*
|
|
33
|
+
* @slot empty - Shown when there is no data. Defaults to "No data".
|
|
34
|
+
*
|
|
35
|
+
* @fires chart-select - A slice was clicked or chosen with Enter. `detail` holds `index`, `series` (the slice name) and `datum`.
|
|
36
|
+
*
|
|
37
|
+
* @csspart container - The outer wrapper.
|
|
38
|
+
* @csspart plot - The focusable plot area holding the SVG.
|
|
39
|
+
* @csspart tooltip - The tooltip.
|
|
40
|
+
* @csspart legend - The legend.
|
|
41
|
+
*
|
|
42
|
+
* @cssprop --color-chart-1 - Color of the first slice; slices cycle through `--color-chart-1` to `--color-chart-8`.
|
|
43
|
+
* @cssprop --chart-dim-opacity - Opacity of slices that are not hovered. Defaults to `0.4`.
|
|
29
44
|
*/
|
|
30
|
-
export declare class ChartPie extends
|
|
45
|
+
export declare class ChartPie extends ChartBase {
|
|
31
46
|
static styles: import("lit").CSSResultGroup[];
|
|
32
|
-
|
|
33
|
-
/** Width (and height) of the chart in pixels. */
|
|
34
|
-
width: number;
|
|
35
|
-
/** Margin around the chart. */
|
|
36
|
-
margin: number;
|
|
37
|
-
/** Whether to show labels outside the chart. */
|
|
38
|
-
showLabels: boolean;
|
|
39
|
-
/** Chart data array. Each item should have name, value, and optional label and color. */
|
|
47
|
+
/** Slices to draw. */
|
|
40
48
|
data: ChartPieItem[];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
/** Size of the hole as a fraction of the radius, from 0 (pie) to 0.9. */
|
|
50
|
+
innerRadius: number;
|
|
51
|
+
/** Prints each slice's percentage inside it when it fits. */
|
|
52
|
+
showLabels: boolean;
|
|
53
|
+
/** Arcs from the last draw. */
|
|
54
|
+
private arcs;
|
|
55
|
+
/** Outer radius from the last draw. */
|
|
56
|
+
protected radius: number;
|
|
57
|
+
/** Pie centre from the last draw, in plot coordinates. */
|
|
58
|
+
private center;
|
|
59
|
+
protected drawProperties(): string[];
|
|
60
|
+
protected hasData(): boolean;
|
|
61
|
+
protected getSeries(): ChartSeries[];
|
|
62
|
+
protected legendVisible(): boolean;
|
|
63
|
+
protected getItemCount(): number;
|
|
64
|
+
/** Sum of the visible slices. */
|
|
65
|
+
protected visibleTotal(): number;
|
|
66
|
+
protected percent(value: number): string;
|
|
67
|
+
private innerFraction;
|
|
68
|
+
protected draw(animate: boolean): void;
|
|
69
|
+
protected drawHighlight(): void;
|
|
70
|
+
protected itemAtPoint(x: number, y: number): number;
|
|
71
|
+
protected getTooltip(index: number): ChartTooltipModel | undefined;
|
|
72
|
+
protected getSelectDetail(index: number): {
|
|
73
|
+
index: number;
|
|
74
|
+
series: string;
|
|
75
|
+
datum: ChartPieItem;
|
|
76
|
+
};
|
|
77
|
+
protected renderSkeleton(): import("lit-html").TemplateResult<1>;
|
|
78
|
+
protected renderSvgContent(): import("lit-html").TemplateResult<2>;
|
|
79
|
+
protected renderTable(): import("lit-html").TemplateResult<1>;
|
|
80
|
+
}
|
|
81
|
+
declare global {
|
|
82
|
+
interface HTMLElementTagNameMap {
|
|
83
|
+
'wc-chart-pie': ChartPie;
|
|
84
|
+
}
|
|
50
85
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropertyValues } from 'lit';
|
|
2
2
|
import BaseInput from '../input/BaseInput.js';
|
|
3
3
|
export type CodeEditorLanguage = 'javascript' | 'typescript' | 'json' | 'html' | 'css' | 'scss' | 'markdown';
|
|
4
|
+
export type CodeEditorSize = 'sm' | 'md';
|
|
4
5
|
/** A problem shown in the editor: a squiggle under the text and a mark in the scroll bar. Lines and columns count from 1. */
|
|
5
6
|
export type CodeEditorMarker = {
|
|
6
7
|
line: number;
|
|
@@ -18,16 +19,30 @@ type Monaco = typeof import('./monaco.js');
|
|
|
18
19
|
*
|
|
19
20
|
* @summary A Monaco-based code editing component with syntax highlighting, completions and debugging marks.
|
|
20
21
|
* @overview
|
|
21
|
-
* - CodeEditor wraps Monaco Editor as a web component. Monaco is bundled with Peacock and loaded when the first editor appears; nothing comes from a CDN, so it works under a content security policy that allows only its own origin.
|
|
22
|
-
* -
|
|
22
|
+
* - CodeEditor wraps Monaco Editor as a web component, in the same frame as `wc-code-highlighter`: an optional header with a title and actions, or a copy button that floats at the top end. Monaco is bundled with Peacock and loaded when the first editor appears; nothing comes from a CDN, so it works under a content security policy that allows only its own origin. The code shows as plain text until Monaco is ready.
|
|
23
|
+
* - Its colors come from the theme's color roles and the code highlighter's syntax colors, so light, dark, the system color scheme and custom themes all follow the tokens.
|
|
24
|
+
* - Supports TypeScript, JavaScript, JSON, HTML, CSS, SCSS and Markdown, with completions and errors for TypeScript, JavaScript and JSON; read-only mode, line numbers, line wrapping and a minimap.
|
|
23
25
|
* - `lib-source` adds TypeScript declarations for completions, such as the modules a script may import.
|
|
24
26
|
* - With `breakpoint-gutter`, a click in the gutter fires `breakpoint-toggle`; `breakpoints` and `current-line` draw the marks a debugger shows.
|
|
25
27
|
* - `markers` underline problems, such as where a run failed.
|
|
26
|
-
* - With `fill`, the editor takes the height of its container.
|
|
27
|
-
* - Has a copy button; hide it with `hide-copy`.
|
|
28
|
+
* - With `fill`, the editor drops its frame and takes the height of its container, as a pane of its own.
|
|
28
29
|
* - Emits `change` when content is edited and updates value from property changes.
|
|
29
30
|
*
|
|
30
|
-
* @
|
|
31
|
+
* @slot title - Header title content. Overrides `label` and shows the header.
|
|
32
|
+
* @slot icon - Icon shown before the title in the header.
|
|
33
|
+
* @slot actions - Extra action buttons, shown in the header or floating at the top end.
|
|
34
|
+
*
|
|
35
|
+
* @csspart container - The outer frame.
|
|
36
|
+
* @csspart header - The header row.
|
|
37
|
+
* @csspart title - The header title.
|
|
38
|
+
* @csspart actions - The action buttons group.
|
|
39
|
+
* @csspart editor - The area Monaco renders into.
|
|
40
|
+
*
|
|
41
|
+
* @cssprop --code-editor-height - Height of the editing area. Defaults to 300px. Ignored with `fill`.
|
|
42
|
+
* @cssprop --code-editor-background - Frame background. Defaults to `--color-surface-container-low`.
|
|
43
|
+
* @cssprop --code-editor-border-color - Frame border color. Defaults to `--color-outline-variant`.
|
|
44
|
+
* @cssprop --code-editor-shape - Frame corner radius. Defaults to `--shape-corner-medium`.
|
|
45
|
+
* @cssprop --code-highlighter-token-keyword - Keyword color, shared with `wc-code-highlighter`, like the other `--code-highlighter-token-*` colors.
|
|
31
46
|
*
|
|
32
47
|
* @fires {Event} change - Dispatched when the user edits the content.
|
|
33
48
|
* @fires {CustomEvent<{value: string}>} copied - Dispatched after the copy button copies the content.
|
|
@@ -37,6 +52,7 @@ type Monaco = typeof import('./monaco.js');
|
|
|
37
52
|
* ```html
|
|
38
53
|
* <wc-code-editor
|
|
39
54
|
* language="css"
|
|
55
|
+
* label="theme.css"
|
|
40
56
|
* readonly
|
|
41
57
|
* style="width: 100%; --code-editor-height: 10rem;"
|
|
42
58
|
* value=":root { --color-primary: #6341d5; }">
|
|
@@ -50,17 +66,25 @@ export default class CodeEditor extends BaseInput {
|
|
|
50
66
|
value: string;
|
|
51
67
|
/** Language used for syntax highlighting. Can be changed after the editor loads. */
|
|
52
68
|
language: CodeEditorLanguage;
|
|
69
|
+
/** Header title, such as a file name. Shows the header. */
|
|
70
|
+
label: string;
|
|
53
71
|
/** TypeScript declarations (a `.d.ts`) for completions in TypeScript and JavaScript, such as the modules the code may import. */
|
|
54
72
|
libSource: string | undefined;
|
|
55
73
|
/** Compiler options for TypeScript and JavaScript, over the editor's defaults (target and modules ESNext, strict), such as `{ lib: ['es2022'] }`. */
|
|
56
74
|
compilerOptions: Record<string, unknown> | undefined;
|
|
57
75
|
/** Whether line numbers show in the gutter. */
|
|
58
76
|
lineNumbers: 'off' | 'on';
|
|
77
|
+
/** Wraps long lines instead of scrolling horizontally. */
|
|
78
|
+
wrap: boolean;
|
|
79
|
+
/** Shows a button that turns line wrapping on and off. */
|
|
80
|
+
wrapToggle: boolean;
|
|
59
81
|
/** Shows the minimap. Leave the attribute out to hide it. */
|
|
60
82
|
minimap: boolean;
|
|
83
|
+
/** Size of the editor. `sm` uses smaller text and padding. */
|
|
84
|
+
size: CodeEditorSize;
|
|
61
85
|
/** Hides the copy button. */
|
|
62
86
|
hideCopy: boolean;
|
|
63
|
-
/** Shows a "Read
|
|
87
|
+
/** Shows a "Read only" badge while the editor is read-only or disabled. */
|
|
64
88
|
showReadonlyBadge: boolean;
|
|
65
89
|
/** Shows a gutter for breakpoints; a click there, or on a line number, fires `breakpoint-toggle`. */
|
|
66
90
|
breakpointGutter: boolean;
|
|
@@ -70,29 +94,34 @@ export default class CodeEditor extends BaseInput {
|
|
|
70
94
|
currentLine: number | undefined;
|
|
71
95
|
/** Problems to underline, such as where a run failed. */
|
|
72
96
|
markers: CodeEditorMarker[];
|
|
73
|
-
/**
|
|
97
|
+
/** Drops the frame and takes the height of the container instead of `--code-editor-height`. */
|
|
74
98
|
fill: boolean;
|
|
75
|
-
/** Whether the page is in dark mode; picks the Monaco theme. */
|
|
76
|
-
private _isDarkMode;
|
|
77
99
|
/** Whether the editor text has focus. */
|
|
78
100
|
private hasFocus;
|
|
79
|
-
/** Whether the copy button was just used; shows a check for a
|
|
101
|
+
/** Whether the copy button was just used; shows a check for a moment. */
|
|
80
102
|
private _copied;
|
|
81
103
|
/** The Monaco editor instance, once loaded. */
|
|
82
104
|
private editorMonacoInstance?;
|
|
83
|
-
private editorElement
|
|
105
|
+
private editorElement?;
|
|
106
|
+
private probeElement?;
|
|
84
107
|
/** The Monaco API, once loaded. */
|
|
85
108
|
monaco: Monaco | undefined;
|
|
86
109
|
/** This editor's model's address, unique on the page so two editors never share a model. */
|
|
87
110
|
private readonly __id;
|
|
88
111
|
/** Stops listening for theme changes. */
|
|
89
112
|
private __unobserveTheme?;
|
|
113
|
+
/** The system color scheme, watched so the editor follows it. */
|
|
114
|
+
private __colorScheme?;
|
|
115
|
+
/** Re-renders when slotted header content is added or removed. */
|
|
116
|
+
private __childObserver?;
|
|
90
117
|
/** Resets the copied state of the copy button. */
|
|
91
118
|
private __copiedTimer?;
|
|
92
119
|
/** The declarations added for `libSource`. */
|
|
93
120
|
private __lib?;
|
|
94
121
|
/** The breakpoint and current-line marks. */
|
|
95
122
|
private __decorations?;
|
|
123
|
+
/** The font and padding last given to Monaco, to skip unchanged updates. */
|
|
124
|
+
private __layoutKey;
|
|
96
125
|
connectedCallback(): void;
|
|
97
126
|
disconnectedCallback(): void;
|
|
98
127
|
protected firstUpdated(): void;
|
|
@@ -102,12 +131,22 @@ export default class CodeEditor extends BaseInput {
|
|
|
102
131
|
setBlur(): Promise<void>;
|
|
103
132
|
/** Scrolls `line` into view and puts the cursor at its start. */
|
|
104
133
|
revealLine(line: number): void;
|
|
134
|
+
/** Defines the page's editor theme from the tokens around this editor. */
|
|
135
|
+
private __applyTheme;
|
|
136
|
+
/** The font and padding the styles give the code, for Monaco's options. */
|
|
137
|
+
private __readLayout;
|
|
138
|
+
/** Gives Monaco the font and padding when the header or size changed them. */
|
|
139
|
+
private __applyLayout;
|
|
140
|
+
/** Whether light-DOM children are assigned to the named slot. */
|
|
141
|
+
private __hasSlotted;
|
|
105
142
|
private libSourceChanged;
|
|
106
143
|
private drawDecorations;
|
|
107
144
|
private drawMarkers;
|
|
108
|
-
private getTheme;
|
|
109
145
|
private __handleCopyClick;
|
|
110
|
-
private
|
|
146
|
+
private __handleWrapClick;
|
|
147
|
+
private renderBadge;
|
|
148
|
+
private renderActions;
|
|
149
|
+
private renderHeader;
|
|
111
150
|
render(): import("lit-html").TemplateResult<1>;
|
|
112
151
|
}
|
|
113
152
|
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colors the editor theme is built from: Peacock color roles, plus the syntax colors
|
|
3
|
+
* wc-code-highlighter uses, so the two show code alike. Monaco takes hex colors only, so these
|
|
4
|
+
* are resolved on the page and converted.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PALETTE_SOURCES: {
|
|
7
|
+
readonly surface: "var(--color-surface)";
|
|
8
|
+
readonly surfaceContainerHigh: "var(--color-surface-container-high)";
|
|
9
|
+
readonly surfaceContainerHighest: "var(--color-surface-container-highest)";
|
|
10
|
+
readonly onSurface: "var(--color-on-surface)";
|
|
11
|
+
readonly onSurfaceVariant: "var(--color-on-surface-variant)";
|
|
12
|
+
readonly outline: "var(--color-outline)";
|
|
13
|
+
readonly outlineVariant: "var(--color-outline-variant)";
|
|
14
|
+
readonly primary: "var(--color-primary)";
|
|
15
|
+
readonly secondary: "var(--color-secondary)";
|
|
16
|
+
readonly tertiary: "var(--color-tertiary)";
|
|
17
|
+
readonly secondaryContainer: "var(--color-secondary-container)";
|
|
18
|
+
readonly onSecondaryContainer: "var(--color-on-secondary-container)";
|
|
19
|
+
readonly error: "var(--color-error)";
|
|
20
|
+
readonly warning: "var(--color-warning)";
|
|
21
|
+
readonly info: "var(--color-blue)";
|
|
22
|
+
readonly foreground: string;
|
|
23
|
+
readonly keyword: string;
|
|
24
|
+
readonly string: string;
|
|
25
|
+
readonly func: string;
|
|
26
|
+
readonly constant: string;
|
|
27
|
+
readonly comment: string;
|
|
28
|
+
readonly punctuation: string;
|
|
29
|
+
readonly parameter: string;
|
|
30
|
+
readonly link: string;
|
|
31
|
+
};
|
|
32
|
+
export type EditorPalette = Record<keyof typeof PALETTE_SOURCES, string>;
|
|
33
|
+
/** Monaco's standalone theme data, as `monaco.editor.defineTheme` takes it. */
|
|
34
|
+
export type EditorThemeData = {
|
|
35
|
+
base: 'vs' | 'vs-dark';
|
|
36
|
+
inherit: boolean;
|
|
37
|
+
rules: {
|
|
38
|
+
token: string;
|
|
39
|
+
foreground?: string;
|
|
40
|
+
fontStyle?: string;
|
|
41
|
+
}[];
|
|
42
|
+
colors: Record<string, string>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Converts any CSS color the browser understands (`rgb()`, `oklch()`, `color()`, …) to
|
|
46
|
+
* `#rrggbb`, or `#rrggbbaa` when it is not opaque, by painting one pixel.
|
|
47
|
+
*/
|
|
48
|
+
export declare function cssColorToHex(color: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Resolves the palette where `probe` sits, so it follows the theme around the editor:
|
|
51
|
+
* `data-theme`, the system color scheme, or a custom theme.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolvePalette(probe: HTMLElement): EditorPalette;
|
|
54
|
+
/** Whether a `#rrggbb` color is dark, by relative luminance. */
|
|
55
|
+
export declare function isDark(hex: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Builds the editor theme from a palette. The editor background is transparent, so the frame
|
|
58
|
+
* around it shows through; widgets such as suggestions and hovers sit on surface containers.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildEditorTheme(p: EditorPalette): EditorThemeData;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* @label Code Group
|
|
4
|
+
* @tag wc-code-group
|
|
5
|
+
* @rawTag code-group
|
|
6
|
+
*
|
|
7
|
+
* @summary Shows several code blocks in one frame, with a tab for each block.
|
|
8
|
+
* @overview
|
|
9
|
+
* <p>Put <code>wc-code-highlighter</code> elements inside. Each block's <code>label</code> names its tab,
|
|
10
|
+
* and only the selected block is shown. The group draws the frame, so the blocks drop their own
|
|
11
|
+
* border and header, and their actions float at the top end.</p>
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```html
|
|
15
|
+
* <wc-code-group>
|
|
16
|
+
* <wc-code-highlighter label="greeting.ts" language="typescript"><pre><code>
|
|
17
|
+
* export const greeting = 'Hello';</code></pre></wc-code-highlighter>
|
|
18
|
+
* <wc-code-highlighter label="greeting.css" language="css"><pre><code>
|
|
19
|
+
* p { color: var(--color-primary); }</code></pre></wc-code-highlighter>
|
|
20
|
+
* </wc-code-group>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @slot - `wc-code-highlighter` elements, one per tab.
|
|
24
|
+
*
|
|
25
|
+
* @csspart container - The outer frame.
|
|
26
|
+
* @csspart header - The tab bar.
|
|
27
|
+
*
|
|
28
|
+
* @fires {CustomEvent<{index: number}>} change - Dispatched when the user selects another tab.
|
|
29
|
+
*
|
|
30
|
+
* @tags display
|
|
31
|
+
*/
|
|
32
|
+
export declare class CodeGroup extends LitElement {
|
|
33
|
+
static styles: import("lit").CSSResultGroup[];
|
|
34
|
+
/** Index of the shown block. */
|
|
35
|
+
selectedIndex: number;
|
|
36
|
+
/** The grouped code blocks, in slot order. */
|
|
37
|
+
private _blocks;
|
|
38
|
+
/** Re-renders the tabs when a block's label changes. */
|
|
39
|
+
private __labelObserver?;
|
|
40
|
+
connectedCallback(): void;
|
|
41
|
+
disconnectedCallback(): void;
|
|
42
|
+
protected updated(changed: Map<PropertyKey, unknown>): void;
|
|
43
|
+
/** The selected index, kept within the blocks. */
|
|
44
|
+
private get __activeIndex();
|
|
45
|
+
/** Marks every block as grouped and shows only the selected one. */
|
|
46
|
+
private __syncBlocks;
|
|
47
|
+
private __handleSlotChange;
|
|
48
|
+
private __handleTabChange;
|
|
49
|
+
private __stopEvent;
|
|
50
|
+
private __tabLabel;
|
|
51
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
52
|
+
}
|
|
@@ -1,40 +1,147 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import type { BundledLanguage } from 'shiki';
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import type { BundledLanguage, SpecialLanguage } from 'shiki';
|
|
3
|
+
export type CodeHighlighterLanguage = BundledLanguage | SpecialLanguage;
|
|
4
|
+
export type CodeHighlighterSize = 'sm' | 'md';
|
|
5
|
+
export type CodeHighlighterVariant = 'default' | 'error';
|
|
3
6
|
/**
|
|
4
7
|
* @label Code Highlighter
|
|
5
8
|
* @tag wc-code-highlighter
|
|
6
9
|
* @rawTag code-highlighter
|
|
7
10
|
*
|
|
8
|
-
* @summary
|
|
11
|
+
* @summary Displays a block of code with syntax highlighting, line numbers, line highlights, diffs and a copy button.
|
|
9
12
|
*
|
|
10
13
|
* @example
|
|
11
14
|
* ```html
|
|
12
|
-
* <wc-code-highlighter language="javascript"
|
|
15
|
+
* <wc-code-highlighter language="javascript" label="hello.js" line-numbers highlight-lines="2"><pre><code>
|
|
13
16
|
* function helloWorld() {
|
|
14
17
|
* console.log('Hello, world!');
|
|
15
18
|
* }</code></pre>
|
|
16
19
|
* </wc-code-highlighter>
|
|
17
20
|
* ```
|
|
21
|
+
*
|
|
22
|
+
* @slot title - Header title content. Overrides `label` and shows the header.
|
|
23
|
+
* @slot icon - Icon shown before the title in the header.
|
|
24
|
+
* @slot actions - Extra action buttons, shown in the header or floating at the top end.
|
|
25
|
+
*
|
|
26
|
+
* @csspart container - The outer block.
|
|
27
|
+
* @csspart header - The header row.
|
|
28
|
+
* @csspart title - The header title.
|
|
29
|
+
* @csspart actions - The action buttons group.
|
|
30
|
+
* @csspart content - The scrollable code area (`pre`).
|
|
31
|
+
* @csspart line - Each code line.
|
|
32
|
+
* @csspart footer - The footer holding the show more button.
|
|
33
|
+
*
|
|
34
|
+
* @cssprop --code-highlighter-background - Block background. Defaults to `--color-surface-container-low`.
|
|
35
|
+
* @cssprop --code-highlighter-border-color - Block border color. Defaults to `--color-outline-variant`.
|
|
36
|
+
* @cssprop --code-highlighter-shape - Block corner radius. Defaults to `--shape-corner-medium`.
|
|
37
|
+
* @cssprop --code-highlighter-max-height - Caps the code area height; it scrolls beyond. Defaults to `none`.
|
|
38
|
+
* @cssprop --code-highlighter-collapsed-height - Height of a collapsed `collapsible` block. Defaults to `16rem`.
|
|
39
|
+
* @cssprop --code-highlighter-foreground - Plain code color. Defaults to `--color-on-surface`.
|
|
40
|
+
* @cssprop --code-highlighter-token-keyword - Keyword color. Defaults to `--color-purple`.
|
|
41
|
+
* @cssprop --code-highlighter-token-string - String color. Defaults to `--color-green`.
|
|
42
|
+
* @cssprop --code-highlighter-token-function - Function color. Defaults to `--color-blue`.
|
|
43
|
+
* @cssprop --code-highlighter-token-constant - Constant and number color. Defaults to `--color-orange`.
|
|
44
|
+
* @cssprop --code-highlighter-token-comment - Comment color. Defaults to `--color-on-surface-variant`.
|
|
45
|
+
* @cssprop --code-highlighter-token-punctuation - Punctuation color. Defaults to `--color-on-surface-variant`.
|
|
46
|
+
*
|
|
47
|
+
* @fires {CustomEvent<{value: string}>} copied - Dispatched after the copy button copies the code.
|
|
48
|
+
* @fires {CustomEvent<{expanded: boolean}>} expanded-change - Dispatched when a collapsible block is expanded or collapsed.
|
|
49
|
+
*
|
|
18
50
|
* @tags display
|
|
19
51
|
*/
|
|
20
52
|
export declare class CodeHighlighter extends LitElement {
|
|
21
53
|
static styles: import("lit").CSSResultGroup[];
|
|
22
54
|
private static readonly COPY_FEEDBACK_DURATION;
|
|
23
|
-
|
|
24
|
-
|
|
55
|
+
/** Language of the code. Unknown languages render as plain text. */
|
|
56
|
+
language: CodeHighlighterLanguage;
|
|
57
|
+
/** Code to display. When empty, the code is read from a light-DOM `<pre><code>`. */
|
|
25
58
|
value: string;
|
|
26
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Formats JavaScript, HTML and CSS with Prettier before display.
|
|
61
|
+
* Set `format="false"` to show the code as written.
|
|
62
|
+
*/
|
|
63
|
+
format: boolean;
|
|
64
|
+
/** Header title, such as a file path. Shows the header. */
|
|
65
|
+
label: string;
|
|
66
|
+
/** Shows line numbers. */
|
|
67
|
+
lineNumbers: boolean;
|
|
68
|
+
/** Number of the first line when line numbers are shown. */
|
|
69
|
+
startLine: number;
|
|
70
|
+
/** Wraps long lines instead of scrolling horizontally. */
|
|
71
|
+
wrap: boolean;
|
|
72
|
+
/** Shows a button that turns line wrapping on and off. */
|
|
73
|
+
wrapToggle: boolean;
|
|
74
|
+
/** Lines to highlight, such as `"1, 3-5"`. Counts displayed lines, after formatting. */
|
|
75
|
+
highlightLines: string;
|
|
76
|
+
/** Lines shown as added in a diff, such as `"4-6"`. */
|
|
77
|
+
addedLines: string;
|
|
78
|
+
/** Lines shown as removed in a diff, such as `"3"`. */
|
|
79
|
+
removedLines: string;
|
|
80
|
+
/** Caps the height and adds a show more button when the code is taller. */
|
|
81
|
+
collapsible: boolean;
|
|
82
|
+
/** Whether a collapsible block is expanded. */
|
|
83
|
+
expanded: boolean;
|
|
84
|
+
/** Size of the block. `sm` suits tool output and dense layouts. */
|
|
85
|
+
size: CodeHighlighterSize;
|
|
86
|
+
/** Visual variant. `error` tints the block for failure output. */
|
|
87
|
+
variant: CodeHighlighterVariant;
|
|
88
|
+
/** Hides the copy button. */
|
|
27
89
|
hideCopy: boolean;
|
|
28
|
-
|
|
90
|
+
/** Text the copy button copies instead of the displayed code. */
|
|
91
|
+
copyValue?: string;
|
|
92
|
+
/** Renders the code inline, as a compact chip within text. */
|
|
93
|
+
inline: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Set by `wc-code-group`. The group draws the frame and shows the label as a
|
|
96
|
+
* tab, so the block drops its border and header.
|
|
97
|
+
*/
|
|
98
|
+
grouped: boolean;
|
|
99
|
+
/** The code as displayed, after formatting, without a trailing newline. */
|
|
100
|
+
private _code;
|
|
101
|
+
/** Tokens per line, or `null` until highlighting finishes. */
|
|
102
|
+
private _tokens;
|
|
103
|
+
/** Whether the copy button shows its copied feedback. */
|
|
29
104
|
private _copied;
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
105
|
+
/** Whether the collapsed code is taller than the collapsed height. */
|
|
106
|
+
private _overflowing;
|
|
107
|
+
private __content?;
|
|
108
|
+
private __codeElement?;
|
|
109
|
+
/** Source read from `value` or the light DOM, before formatting. */
|
|
110
|
+
private __source;
|
|
111
|
+
/** Line variants keyed by 1-based line number. */
|
|
112
|
+
private __lineVariants;
|
|
113
|
+
/** Increments per highlight run so stale async results are dropped. */
|
|
114
|
+
private __run;
|
|
115
|
+
/** Timer that resets the copy feedback. */
|
|
116
|
+
private __copyFeedbackTimeout;
|
|
117
|
+
/** Measures whether collapsed code overflows. */
|
|
118
|
+
private __resizeObserver?;
|
|
119
|
+
/** Element currently measured by the resize observer. */
|
|
120
|
+
private __observedContent?;
|
|
121
|
+
/** Re-renders when slotted header content is added or removed. */
|
|
122
|
+
private __childObserver?;
|
|
123
|
+
connectedCallback(): void;
|
|
33
124
|
disconnectedCallback(): void;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
125
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
126
|
+
protected updated(): void;
|
|
127
|
+
/** Reads the source from `value`, or from the light DOM. */
|
|
128
|
+
private __readSource;
|
|
129
|
+
/** Formats then tokenizes the source; plain lines stay until both finish. */
|
|
130
|
+
private __highlight;
|
|
131
|
+
/** Watches the code area so the show more button appears only when needed. */
|
|
132
|
+
private __observeContent;
|
|
133
|
+
/** Checks whether the collapsed code is taller than its cap. */
|
|
134
|
+
private __measure;
|
|
135
|
+
/** Whether light-DOM children are assigned to the named slot. */
|
|
136
|
+
private __hasSlotted;
|
|
38
137
|
private __handleCopyClick;
|
|
138
|
+
private __handleWrapClick;
|
|
139
|
+
private __handleExpandClick;
|
|
140
|
+
private __renderToken;
|
|
141
|
+
private __renderLine;
|
|
142
|
+
private __renderActions;
|
|
143
|
+
private __renderHeader;
|
|
144
|
+
private __renderFooter;
|
|
145
|
+
private __renderInline;
|
|
39
146
|
render(): import("lit-html").TemplateResult<1>;
|
|
40
147
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type LineVariant = 'highlighted' | 'added' | 'removed';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a line range list such as `"1, 3-5"` into 1-based line numbers.
|
|
4
|
+
* Blank or malformed parts are skipped; a reversed range such as `"5-3"` is read as `3-5`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseLineRanges(value: string | null | undefined): Set<number>;
|
|
7
|
+
/**
|
|
8
|
+
* Maps 1-based line numbers to their variant. Where ranges overlap,
|
|
9
|
+
* `removed` wins over `added`, and `added` wins over `highlighted`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildLineVariants(ranges: {
|
|
12
|
+
highlighted?: string | null;
|
|
13
|
+
added?: string | null;
|
|
14
|
+
removed?: string | null;
|
|
15
|
+
}): Map<number, LineVariant>;
|
|
16
|
+
/**
|
|
17
|
+
* Removes leading and trailing blank lines and the indentation common to
|
|
18
|
+
* every non-blank line, so indented markup reads as written.
|
|
19
|
+
*/
|
|
20
|
+
export declare function dedent(source: string): string;
|
|
21
|
+
/** Decodes the entities `innerHTML` produces for text, ending with `&`. */
|
|
22
|
+
export declare function decodeEntities(source: string): string;
|
|
23
|
+
/** Splits code into display lines, ignoring one trailing newline. */
|
|
24
|
+
export declare function splitLines(code: string): string[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntax colors shared by wc-code-highlighter and wc-code-editor. Each is a CSS variable,
|
|
3
|
+
* `--code-highlighter-<name>`, that falls back to a Peacock color role, so light, dark and
|
|
4
|
+
* custom themes all follow the tokens, and one override restyles both components.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TOKEN_DEFAULTS: Record<string, string>;
|
|
7
|
+
/** The CSS value for a syntax color: its public variable, falling back to the color role. */
|
|
8
|
+
export declare function tokenColor(name: string): string;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export { Menu, MenuItem, SubMenu } from './menu/index.js';
|
|
|
39
39
|
export { List, ListItem } from './list/index.js';
|
|
40
40
|
export { Timeline, TimelineItem } from './timeline/index.js';
|
|
41
41
|
export { Item } from './item/index.js';
|
|
42
|
-
export { CodeHighlighter } from './code-highlighter/index.js';
|
|
42
|
+
export { CodeHighlighter, CodeGroup } from './code-highlighter/index.js';
|
|
43
43
|
export { CodeEditor } from './code-editor/index.js';
|
|
44
44
|
export { HtmlEditor } from './html-editor/index.js';
|
|
45
45
|
export { MarkdownEditor } from './markdown-editor/index.js';
|
|
@@ -51,7 +51,9 @@ export { ColorPicker } from './color-picker/index.js';
|
|
|
51
51
|
export { ColorField } from './color-field/index.js';
|
|
52
52
|
export { ChartDoughnut } from './chart-doughnut/index.js';
|
|
53
53
|
export { ChartPie } from './chart-pie/index.js';
|
|
54
|
-
export { ChartBar
|
|
54
|
+
export { ChartBar } from './chart-bar/index.js';
|
|
55
|
+
export { ChartLine } from './chart-line/index.js';
|
|
56
|
+
export { ChartArea } from './chart-area/index.js';
|
|
55
57
|
export { Table } from './table/index.js';
|
|
56
58
|
export { Pagination } from './pagination/index.js';
|
|
57
59
|
export { SidebarMenu, SidebarMenuItem, SidebarSubMenu, } from './sidebar-menu/index.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A slot in the page list: a page number, or a gap shown as an ellipsis. */
|
|
2
|
+
export type PageItem = number | 'ellipsis';
|
|
3
|
+
/**
|
|
4
|
+
* Builds the page list shown by the `full` pagination variant.
|
|
5
|
+
*
|
|
6
|
+
* The list always keeps the first and last page, the current page and `siblings` pages on each
|
|
7
|
+
* side of it, and fills the rest with an ellipsis. It never holds more than
|
|
8
|
+
* `2 * siblings + 5` slots, so the control keeps its width while the user moves through pages.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* getPageItems(5, 24); // [1, 'ellipsis', 4, 5, 6, 'ellipsis', 24]
|
|
12
|
+
* getPageItems(2, 24); // [1, 2, 3, 4, 5, 'ellipsis', 24]
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPageItems(current: number, total: number, siblings?: number): PageItem[];
|