@firstprateek/vastu 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/custom-elements.json +691 -0
- package/dist/dev/all.d.ts +3 -0
- package/dist/dev/all.d.ts.map +1 -1
- package/dist/dev/all.js +3 -0
- package/dist/dev/all.js.map +1 -1
- package/dist/dev/bar-chart/bar-chart.d.ts +63 -0
- package/dist/dev/bar-chart/bar-chart.d.ts.map +1 -0
- package/dist/dev/bar-chart/bar-chart.js +316 -0
- package/dist/dev/bar-chart/bar-chart.js.map +1 -0
- package/dist/dev/bar-chart/index.d.ts +3 -0
- package/dist/dev/bar-chart/index.d.ts.map +1 -0
- package/dist/dev/bar-chart/index.js +5 -0
- package/dist/dev/bar-chart/index.js.map +1 -0
- package/dist/dev/core/cssom.d.ts +15 -0
- package/dist/dev/core/cssom.d.ts.map +1 -0
- package/dist/dev/core/cssom.js +30 -0
- package/dist/dev/core/cssom.js.map +1 -0
- package/dist/dev/navbar/index.d.ts +3 -0
- package/dist/dev/navbar/index.d.ts.map +1 -0
- package/dist/dev/navbar/index.js +5 -0
- package/dist/dev/navbar/index.js.map +1 -0
- package/dist/dev/navbar/navbar.d.ts +69 -0
- package/dist/dev/navbar/navbar.d.ts.map +1 -0
- package/dist/dev/navbar/navbar.js +353 -0
- package/dist/dev/navbar/navbar.js.map +1 -0
- package/dist/dev/poll/index.d.ts +3 -0
- package/dist/dev/poll/index.d.ts.map +1 -0
- package/dist/dev/poll/index.js +5 -0
- package/dist/dev/poll/index.js.map +1 -0
- package/dist/dev/poll/poll.d.ts +67 -0
- package/dist/dev/poll/poll.d.ts.map +1 -0
- package/dist/dev/poll/poll.js +301 -0
- package/dist/dev/poll/poll.js.map +1 -0
- package/dist/prod/all.js +3 -0
- package/dist/prod/bar-chart/bar-chart.js +316 -0
- package/dist/prod/bar-chart/index.js +5 -0
- package/dist/prod/core/cssom.js +30 -0
- package/dist/prod/navbar/index.js +5 -0
- package/dist/prod/navbar/navbar.js +353 -0
- package/dist/prod/poll/index.js +5 -0
- package/dist/prod/poll/poll.js +301 -0
- package/package.json +18 -3
package/dist/dev/all.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
export * from './bar-chart/index.js';
|
|
1
2
|
export * from './button/index.js';
|
|
2
3
|
export * from './checkbox/index.js';
|
|
3
4
|
export * from './dialog/index.js';
|
|
4
5
|
export * from './menu/index.js';
|
|
6
|
+
export * from './navbar/index.js';
|
|
7
|
+
export * from './poll/index.js';
|
|
5
8
|
export * from './switch/index.js';
|
|
6
9
|
export * from './tabs/index.js';
|
|
7
10
|
export * from './text-field/index.js';
|
package/dist/dev/all.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../src/all.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../src/all.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dist/dev/all.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// Generated by build.js: registers every Vastu component.
|
|
2
|
+
export * from './bar-chart/index.js';
|
|
2
3
|
export * from './button/index.js';
|
|
3
4
|
export * from './checkbox/index.js';
|
|
4
5
|
export * from './dialog/index.js';
|
|
5
6
|
export * from './menu/index.js';
|
|
7
|
+
export * from './navbar/index.js';
|
|
8
|
+
export * from './poll/index.js';
|
|
6
9
|
export * from './switch/index.js';
|
|
7
10
|
export * from './tabs/index.js';
|
|
8
11
|
export * from './text-field/index.js';
|
package/dist/dev/all.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../src/all.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC","sourcesContent":["// Generated by build.js: registers every Vastu component.\nexport * from './button/index.js';\nexport * from './checkbox/index.js';\nexport * from './dialog/index.js';\nexport * from './menu/index.js';\nexport * from './switch/index.js';\nexport * from './tabs/index.js';\nexport * from './text-field/index.js';\nexport * from './toast/index.js';\n"]}
|
|
1
|
+
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../src/all.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC","sourcesContent":["// Generated by build.js: registers every Vastu component.\nexport * from './bar-chart/index.js';\nexport * from './button/index.js';\nexport * from './checkbox/index.js';\nexport * from './dialog/index.js';\nexport * from './menu/index.js';\nexport * from './navbar/index.js';\nexport * from './poll/index.js';\nexport * from './switch/index.js';\nexport * from './tabs/index.js';\nexport * from './text-field/index.js';\nexport * from './toast/index.js';\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { LitElement, type PropertyDeclarations, type PropertyValues } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* A bar chart that compares values across a few categories. The data is plain markup, and the
|
|
4
|
+
* bars animate when it changes, so it can follow live values.
|
|
5
|
+
*
|
|
6
|
+
* @tag va-bar-chart
|
|
7
|
+
* @summary Compares a number across a few categories, one bar per category.
|
|
8
|
+
*
|
|
9
|
+
* @slot - The data, as `<data value="N">Category</data>` elements, in order. Change them and the bars animate to the new values.
|
|
10
|
+
*
|
|
11
|
+
* @csspart label - The chart's title.
|
|
12
|
+
* @csspart plot - The area the bars are drawn in.
|
|
13
|
+
* @csspart bar - Each bar.
|
|
14
|
+
* @csspart axis - The value labels along the left edge.
|
|
15
|
+
*
|
|
16
|
+
* @cssprop {<color>} --va-bar-chart-bar-bg - Colour of the bars.
|
|
17
|
+
* @cssprop {<length>} --va-bar-chart-bar-radius - Corner radius of the bars' outer end.
|
|
18
|
+
* @cssprop {<length>} --va-bar-chart-size - Height of the plot area.
|
|
19
|
+
*
|
|
20
|
+
* @cssprop-applies --va-bar-chart-bar-bg bar background-color
|
|
21
|
+
* @cssprop-applies --va-bar-chart-bar-radius bar border-top-left-radius
|
|
22
|
+
* @cssprop-applies --va-bar-chart-size plot height
|
|
23
|
+
*
|
|
24
|
+
* @keyboard-items data
|
|
25
|
+
* @keyboard items: ArrowRight | next | Moves to the next bar, wrapping round.
|
|
26
|
+
* @keyboard items: ArrowLeft | previous | Moves to the previous bar, wrapping round.
|
|
27
|
+
* @keyboard items: Home | first | Moves to the first bar.
|
|
28
|
+
* @keyboard items: End | last | Moves to the last bar.
|
|
29
|
+
*
|
|
30
|
+
* @a11y-role figure
|
|
31
|
+
* @a11y-name-from label
|
|
32
|
+
* @a11y-name The `label`, which is the chart's visible title.
|
|
33
|
+
* @a11y-note Each `<data>` element is in the Tab order once (roving tabindex) and is announced as "Category: value". Arrow keys move between bars.
|
|
34
|
+
* @a11y-note The value axis is hidden from assistive technology, because every bar announces its own value.
|
|
35
|
+
*
|
|
36
|
+
* @guidance-use To compare one number across a few categories (up to about 12), such as visitors per day or sales per region.
|
|
37
|
+
* @guidance-avoid For trends over many points in time, for parts of a whole, or when readers need to look up exact values.
|
|
38
|
+
* @guidance-instead A line chart for trends; a table when exact values matter.
|
|
39
|
+
*/
|
|
40
|
+
export declare class VaBarChart extends LitElement {
|
|
41
|
+
#private;
|
|
42
|
+
static shadowRootOptions: ShadowRootInit;
|
|
43
|
+
static properties: PropertyDeclarations;
|
|
44
|
+
/** The chart's title, shown above it. */
|
|
45
|
+
label: string;
|
|
46
|
+
/** The top of the value axis. 0 (the default) fits the axis to the data; set it to keep the scale steady while live values change. */
|
|
47
|
+
max: number;
|
|
48
|
+
private _revision;
|
|
49
|
+
private _focused;
|
|
50
|
+
constructor();
|
|
51
|
+
connectedCallback(): void;
|
|
52
|
+
disconnectedCallback(): void;
|
|
53
|
+
firstUpdated(): void;
|
|
54
|
+
updated(changed: PropertyValues): void;
|
|
55
|
+
render(): import("lit").TemplateResult<1>;
|
|
56
|
+
static styles: import("lit").CSSResult;
|
|
57
|
+
}
|
|
58
|
+
declare global {
|
|
59
|
+
interface HTMLElementTagNameMap {
|
|
60
|
+
'va-bar-chart': VaBarChart;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=bar-chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-chart.d.ts","sourceRoot":"","sources":["../../../src/bar-chart/bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAY5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,UAAW,SAAQ,UAAU;;IACxC,OAAgB,iBAAiB,EAAE,cAAc,CAAiE;IAElH,OAAgB,UAAU,EAAE,oBAAoB,CAK9C;IAEF,yCAAyC;IACjC,KAAK,EAAE,MAAM,CAAC;IACtB,sIAAsI;IAC9H,GAAG,EAAE,MAAM,CAAC;IAEpB,QAAgB,SAAS,CAAS;IAClC,QAAgB,QAAQ,CAAS;;IAcxB,iBAAiB,IAAI,IAAI;IAQzB,oBAAoB,IAAI,IAAI;IAkB5B,YAAY,IAAI,IAAI;IAIpB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAyCtC,MAAM;IAmDf,OAAgB,MAAM,0BAkIpB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,UAAU,CAAC;KAC5B;CACF"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { LitElement, css, html } from 'lit';
|
|
2
|
+
import { cssom } from '../core/cssom.js';
|
|
3
|
+
import { checkTokensLoaded, devWarn } from '../core/warn.js';
|
|
4
|
+
/** A step of 1, 2 or 5 times a power of ten that splits `range` into about `count` parts. */
|
|
5
|
+
function niceStep(range, count) {
|
|
6
|
+
const raw = range / count;
|
|
7
|
+
const power = 10 ** Math.floor(Math.log10(raw));
|
|
8
|
+
const f = raw / power;
|
|
9
|
+
return (f <= 1 ? 1 : f <= 2 ? 2 : f <= 5 ? 5 : 10) * power;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A bar chart that compares values across a few categories. The data is plain markup, and the
|
|
13
|
+
* bars animate when it changes, so it can follow live values.
|
|
14
|
+
*
|
|
15
|
+
* @tag va-bar-chart
|
|
16
|
+
* @summary Compares a number across a few categories, one bar per category.
|
|
17
|
+
*
|
|
18
|
+
* @slot - The data, as `<data value="N">Category</data>` elements, in order. Change them and the bars animate to the new values.
|
|
19
|
+
*
|
|
20
|
+
* @csspart label - The chart's title.
|
|
21
|
+
* @csspart plot - The area the bars are drawn in.
|
|
22
|
+
* @csspart bar - Each bar.
|
|
23
|
+
* @csspart axis - The value labels along the left edge.
|
|
24
|
+
*
|
|
25
|
+
* @cssprop {<color>} --va-bar-chart-bar-bg - Colour of the bars.
|
|
26
|
+
* @cssprop {<length>} --va-bar-chart-bar-radius - Corner radius of the bars' outer end.
|
|
27
|
+
* @cssprop {<length>} --va-bar-chart-size - Height of the plot area.
|
|
28
|
+
*
|
|
29
|
+
* @cssprop-applies --va-bar-chart-bar-bg bar background-color
|
|
30
|
+
* @cssprop-applies --va-bar-chart-bar-radius bar border-top-left-radius
|
|
31
|
+
* @cssprop-applies --va-bar-chart-size plot height
|
|
32
|
+
*
|
|
33
|
+
* @keyboard-items data
|
|
34
|
+
* @keyboard items: ArrowRight | next | Moves to the next bar, wrapping round.
|
|
35
|
+
* @keyboard items: ArrowLeft | previous | Moves to the previous bar, wrapping round.
|
|
36
|
+
* @keyboard items: Home | first | Moves to the first bar.
|
|
37
|
+
* @keyboard items: End | last | Moves to the last bar.
|
|
38
|
+
*
|
|
39
|
+
* @a11y-role figure
|
|
40
|
+
* @a11y-name-from label
|
|
41
|
+
* @a11y-name The `label`, which is the chart's visible title.
|
|
42
|
+
* @a11y-note Each `<data>` element is in the Tab order once (roving tabindex) and is announced as "Category: value". Arrow keys move between bars.
|
|
43
|
+
* @a11y-note The value axis is hidden from assistive technology, because every bar announces its own value.
|
|
44
|
+
*
|
|
45
|
+
* @guidance-use To compare one number across a few categories (up to about 12), such as visitors per day or sales per region.
|
|
46
|
+
* @guidance-avoid For trends over many points in time, for parts of a whole, or when readers need to look up exact values.
|
|
47
|
+
* @guidance-instead A line chart for trends; a table when exact values matter.
|
|
48
|
+
*/
|
|
49
|
+
export class VaBarChart extends LitElement {
|
|
50
|
+
static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, slotAssignment: 'manual' }; }
|
|
51
|
+
static { this.properties = {
|
|
52
|
+
label: {},
|
|
53
|
+
max: { type: Number },
|
|
54
|
+
_revision: { state: true },
|
|
55
|
+
_focused: { state: true },
|
|
56
|
+
}; }
|
|
57
|
+
#observer = new MutationObserver(() => this._revision++);
|
|
58
|
+
constructor() {
|
|
59
|
+
super();
|
|
60
|
+
this.label = '';
|
|
61
|
+
this.max = 0;
|
|
62
|
+
this._revision = 0;
|
|
63
|
+
this._focused = -1;
|
|
64
|
+
this.addEventListener('keydown', this.#onKeydown);
|
|
65
|
+
this.addEventListener('focusin', this.#onFocusin);
|
|
66
|
+
this.addEventListener('focusout', () => (this._focused = -1));
|
|
67
|
+
}
|
|
68
|
+
connectedCallback() {
|
|
69
|
+
super.connectedCallback();
|
|
70
|
+
checkTokensLoaded(this);
|
|
71
|
+
this.#observer.observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['value'] });
|
|
72
|
+
// Children may have changed while the chart was detached and unobserved.
|
|
73
|
+
if (this.hasUpdated)
|
|
74
|
+
this._revision++;
|
|
75
|
+
}
|
|
76
|
+
disconnectedCallback() {
|
|
77
|
+
super.disconnectedCallback();
|
|
78
|
+
this.#observer.disconnect();
|
|
79
|
+
}
|
|
80
|
+
get #items() {
|
|
81
|
+
return [...this.children];
|
|
82
|
+
}
|
|
83
|
+
#valueOf(item) {
|
|
84
|
+
const value = Number(item.getAttribute('value'));
|
|
85
|
+
return Number.isFinite(value) ? value : 0;
|
|
86
|
+
}
|
|
87
|
+
get #format() {
|
|
88
|
+
return new Intl.NumberFormat(this.closest('[lang]')?.getAttribute('lang') || undefined);
|
|
89
|
+
}
|
|
90
|
+
firstUpdated() {
|
|
91
|
+
if (!this.label)
|
|
92
|
+
devWarn('va-bar-chart', 'This chart has no label, so it has no title or accessible name.', 'Add label="…" that says what the bars show (e.g. label="Visitors per day").');
|
|
93
|
+
}
|
|
94
|
+
updated(changed) {
|
|
95
|
+
const items = this.#items;
|
|
96
|
+
const slots = [...this.shadowRoot.querySelectorAll('slot')];
|
|
97
|
+
items.forEach((item, i) => slots[i]?.assign(item));
|
|
98
|
+
const format = this.#format;
|
|
99
|
+
const current = Math.max(0, items.findIndex((i) => i.tabIndex === 0));
|
|
100
|
+
items.forEach((item, i) => {
|
|
101
|
+
item.tabIndex = i === current ? 0 : -1;
|
|
102
|
+
item.setAttribute('role', 'img');
|
|
103
|
+
item.setAttribute('aria-label', `${item.textContent?.trim()}: ${format.format(this.#valueOf(item))}`);
|
|
104
|
+
});
|
|
105
|
+
if (changed.has('_revision')) {
|
|
106
|
+
if (items.some((i) => i.localName !== 'data')) {
|
|
107
|
+
devWarn('va-bar-chart', 'A child is not a <data> element, so it is drawn as a bar with value 0.', 'Use <data value="N">Category</data> for each bar.');
|
|
108
|
+
}
|
|
109
|
+
for (const item of items.filter((i) => i.localName === 'data' && !Number.isFinite(Number(i.getAttribute('value') ?? 'x')))) {
|
|
110
|
+
devWarn('va-bar-chart', `"${item.textContent?.trim()}" has value="${item.getAttribute('value') ?? ''}", which is not a number.`, 'Set value to a plain number, without units or separators (e.g. value="1200").');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
#onFocusin = (event) => {
|
|
115
|
+
const items = this.#items;
|
|
116
|
+
const index = items.indexOf(event.target);
|
|
117
|
+
if (index < 0)
|
|
118
|
+
return;
|
|
119
|
+
items.forEach((item, i) => (item.tabIndex = i === index ? 0 : -1));
|
|
120
|
+
this._focused = index;
|
|
121
|
+
};
|
|
122
|
+
#onKeydown = (event) => {
|
|
123
|
+
const items = this.#items;
|
|
124
|
+
const current = items.indexOf(event.target);
|
|
125
|
+
if (current < 0 || !items.length)
|
|
126
|
+
return;
|
|
127
|
+
const next = { ArrowRight: current + 1, ArrowLeft: current - 1, Home: 0, End: items.length - 1 }[event.key];
|
|
128
|
+
if (next === undefined)
|
|
129
|
+
return;
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
items[(next + items.length) % items.length].focus();
|
|
132
|
+
};
|
|
133
|
+
render() {
|
|
134
|
+
const items = this.#items;
|
|
135
|
+
const values = items.map((i) => this.#valueOf(i));
|
|
136
|
+
const format = this.#format;
|
|
137
|
+
// The axis always includes 0, so bars start from a baseline and their lengths compare honestly.
|
|
138
|
+
let lo = Math.min(0, ...values);
|
|
139
|
+
let hi = this.max > 0 ? this.max : Math.max(0, ...values);
|
|
140
|
+
if (hi === lo)
|
|
141
|
+
hi = lo + 1;
|
|
142
|
+
const step = niceStep(hi - lo, 5);
|
|
143
|
+
lo = Math.floor(lo / step) * step;
|
|
144
|
+
if (!(this.max > 0))
|
|
145
|
+
hi = Math.ceil(hi / step) * step;
|
|
146
|
+
const ticks = [];
|
|
147
|
+
// Count steps instead of adding them up, and round to the step's decimals, so float error
|
|
148
|
+
// never gives a "-0" label or a missing zero line.
|
|
149
|
+
const decimals = Math.max(0, -Math.floor(Math.log10(step)));
|
|
150
|
+
for (let i = 0; lo + i * step <= hi + step / 1e6; i++)
|
|
151
|
+
ticks.push(Number((lo + i * step).toFixed(decimals)) + 0);
|
|
152
|
+
const pos = (v) => ((Math.min(Math.max(v, lo), hi) - lo) / (hi - lo)) * 100;
|
|
153
|
+
return html `
|
|
154
|
+
<div class="chart" role="figure" aria-labelledby="label">
|
|
155
|
+
<div part="label" id="label" class="label">${this.label}</div>
|
|
156
|
+
<div class="body">
|
|
157
|
+
<div part="axis" class="axis" aria-hidden="true">
|
|
158
|
+
${ticks.map((t) => html `<span class="tick" ${cssom({ bottom: `${pos(t)}%` })}>${format.format(t)}</span>`)}
|
|
159
|
+
</div>
|
|
160
|
+
<div class="columns">
|
|
161
|
+
<div part="plot" class="plot">
|
|
162
|
+
${ticks.map((t) => html `<span class=${t === 0 ? 'grid zero' : 'grid'} ${cssom({ bottom: `${pos(t)}%` })}></span>`)}
|
|
163
|
+
${values.map((v, i) => {
|
|
164
|
+
const top = pos(Math.max(v, 0));
|
|
165
|
+
const bottom = pos(Math.min(v, 0));
|
|
166
|
+
return html `
|
|
167
|
+
<div class=${i === this._focused ? 'column focused' : 'column'}>
|
|
168
|
+
<span
|
|
169
|
+
part="bar"
|
|
170
|
+
class=${v < 0 ? 'bar negative' : 'bar'}
|
|
171
|
+
${cssom({ bottom: `${bottom}%`, height: `${top - bottom}%` })}
|
|
172
|
+
></span>
|
|
173
|
+
<span class="value" aria-hidden="true" ${cssom(v < 0 ? { top: `${100 - bottom}%` } : { bottom: `${top}%` })}>${format.format(v)}</span>
|
|
174
|
+
</div>
|
|
175
|
+
`;
|
|
176
|
+
})}
|
|
177
|
+
</div>
|
|
178
|
+
<div class="labels">${items.map(() => html `<div class="category"><slot></slot></div>`)}</div>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
static { this.styles = css `
|
|
185
|
+
:host {
|
|
186
|
+
display: block;
|
|
187
|
+
box-sizing: border-box;
|
|
188
|
+
width: 100%;
|
|
189
|
+
font-family: var(--va-font-family-ui);
|
|
190
|
+
font-size: var(--va-font-size-sm);
|
|
191
|
+
color: var(--va-color-text-default);
|
|
192
|
+
}
|
|
193
|
+
:host([hidden]) {
|
|
194
|
+
display: none;
|
|
195
|
+
}
|
|
196
|
+
.label {
|
|
197
|
+
margin-bottom: var(--va-space-gap-md);
|
|
198
|
+
font-size: var(--va-font-size-md);
|
|
199
|
+
font-weight: var(--va-font-weight-bold);
|
|
200
|
+
}
|
|
201
|
+
.body {
|
|
202
|
+
display: grid;
|
|
203
|
+
grid-template-columns: auto 1fr;
|
|
204
|
+
gap: var(--va-space-gap-md);
|
|
205
|
+
}
|
|
206
|
+
.axis {
|
|
207
|
+
position: relative;
|
|
208
|
+
height: var(--va-bar-chart-size, 12rem);
|
|
209
|
+
min-width: 2ch;
|
|
210
|
+
color: var(--va-color-text-muted);
|
|
211
|
+
font-variant-numeric: tabular-nums;
|
|
212
|
+
}
|
|
213
|
+
.tick {
|
|
214
|
+
position: absolute;
|
|
215
|
+
right: 0;
|
|
216
|
+
transform: translateY(50%);
|
|
217
|
+
line-height: 1;
|
|
218
|
+
white-space: nowrap;
|
|
219
|
+
}
|
|
220
|
+
.columns {
|
|
221
|
+
min-width: 0;
|
|
222
|
+
}
|
|
223
|
+
.plot {
|
|
224
|
+
position: relative;
|
|
225
|
+
display: flex;
|
|
226
|
+
height: var(--va-bar-chart-size, 12rem);
|
|
227
|
+
}
|
|
228
|
+
.grid {
|
|
229
|
+
position: absolute;
|
|
230
|
+
left: 0;
|
|
231
|
+
right: 0;
|
|
232
|
+
border-top: 1px solid var(--va-color-border-subtle);
|
|
233
|
+
}
|
|
234
|
+
.grid.zero {
|
|
235
|
+
border-top-color: var(--va-color-border-control);
|
|
236
|
+
}
|
|
237
|
+
.column {
|
|
238
|
+
position: relative;
|
|
239
|
+
flex: 1;
|
|
240
|
+
min-width: 0;
|
|
241
|
+
}
|
|
242
|
+
.bar {
|
|
243
|
+
position: absolute;
|
|
244
|
+
left: 18%;
|
|
245
|
+
right: 18%;
|
|
246
|
+
border-radius: var(--va-bar-chart-bar-radius, 3px) var(--va-bar-chart-bar-radius, 3px) 0 0;
|
|
247
|
+
background-color: var(--va-bar-chart-bar-bg, var(--va-color-accent-default));
|
|
248
|
+
transition:
|
|
249
|
+
height var(--va-motion-duration-slow) ease-out,
|
|
250
|
+
bottom var(--va-motion-duration-slow) ease-out;
|
|
251
|
+
}
|
|
252
|
+
.bar.negative {
|
|
253
|
+
border-radius: 0 0 var(--va-bar-chart-bar-radius, 3px) var(--va-bar-chart-bar-radius, 3px);
|
|
254
|
+
}
|
|
255
|
+
.column:hover .bar,
|
|
256
|
+
.focused .bar {
|
|
257
|
+
background-color: var(--va-bar-chart-bar-bg, var(--va-color-accent-hover));
|
|
258
|
+
filter: brightness(1.1);
|
|
259
|
+
}
|
|
260
|
+
.value {
|
|
261
|
+
position: absolute;
|
|
262
|
+
left: 0;
|
|
263
|
+
right: 0;
|
|
264
|
+
padding: 2px 0;
|
|
265
|
+
font-variant-numeric: tabular-nums;
|
|
266
|
+
font-weight: var(--va-font-weight-medium);
|
|
267
|
+
text-align: center;
|
|
268
|
+
visibility: hidden;
|
|
269
|
+
}
|
|
270
|
+
.column:hover .value,
|
|
271
|
+
.focused .value {
|
|
272
|
+
visibility: visible;
|
|
273
|
+
}
|
|
274
|
+
.labels {
|
|
275
|
+
display: flex;
|
|
276
|
+
margin-top: var(--va-space-gap-sm);
|
|
277
|
+
}
|
|
278
|
+
.category {
|
|
279
|
+
flex: 1;
|
|
280
|
+
min-width: 0;
|
|
281
|
+
text-align: center;
|
|
282
|
+
}
|
|
283
|
+
::slotted(*) {
|
|
284
|
+
display: block;
|
|
285
|
+
overflow: hidden;
|
|
286
|
+
padding: 2px;
|
|
287
|
+
border-radius: var(--va-radius-control);
|
|
288
|
+
color: var(--va-color-text-muted);
|
|
289
|
+
text-overflow: ellipsis;
|
|
290
|
+
white-space: nowrap;
|
|
291
|
+
}
|
|
292
|
+
::slotted(:focus-visible) {
|
|
293
|
+
outline: var(--va-size-focus-ring, 2px) solid var(--va-color-focus);
|
|
294
|
+
outline-offset: 0;
|
|
295
|
+
color: var(--va-color-text-default);
|
|
296
|
+
}
|
|
297
|
+
@media (prefers-reduced-motion: reduce) {
|
|
298
|
+
.bar {
|
|
299
|
+
transition: none;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
@media (forced-colors: active) {
|
|
303
|
+
.bar {
|
|
304
|
+
background-color: CanvasText;
|
|
305
|
+
forced-color-adjust: none;
|
|
306
|
+
}
|
|
307
|
+
.grid {
|
|
308
|
+
border-top-color: GrayText;
|
|
309
|
+
}
|
|
310
|
+
::slotted(:focus-visible) {
|
|
311
|
+
outline-color: Highlight;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
`; }
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=bar-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-chart.js","sourceRoot":"","sources":["../../../src/bar-chart/bar-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F,CAAC;IACJ,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkI3B,CAAC","sourcesContent":["import { LitElement, css, html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { cssom } from '../core/cssom.js';\nimport { checkTokensLoaded, devWarn } from '../core/warn.js';\n\n/** A step of 1, 2 or 5 times a power of ten that splits `range` into about `count` parts. */\nfunction niceStep(range: number, count: number): number {\n const raw = range / count;\n const power = 10 ** Math.floor(Math.log10(raw));\n const f = raw / power;\n return (f <= 1 ? 1 : f <= 2 ? 2 : f <= 5 ? 5 : 10) * power;\n}\n\n/**\n * A bar chart that compares values across a few categories. The data is plain markup, and the\n * bars animate when it changes, so it can follow live values.\n *\n * @tag va-bar-chart\n * @summary Compares a number across a few categories, one bar per category.\n *\n * @slot - The data, as `<data value=\"N\">Category</data>` elements, in order. Change them and the bars animate to the new values.\n *\n * @csspart label - The chart's title.\n * @csspart plot - The area the bars are drawn in.\n * @csspart bar - Each bar.\n * @csspart axis - The value labels along the left edge.\n *\n * @cssprop {<color>} --va-bar-chart-bar-bg - Colour of the bars.\n * @cssprop {<length>} --va-bar-chart-bar-radius - Corner radius of the bars' outer end.\n * @cssprop {<length>} --va-bar-chart-size - Height of the plot area.\n *\n * @cssprop-applies --va-bar-chart-bar-bg bar background-color\n * @cssprop-applies --va-bar-chart-bar-radius bar border-top-left-radius\n * @cssprop-applies --va-bar-chart-size plot height\n *\n * @keyboard-items data\n * @keyboard items: ArrowRight | next | Moves to the next bar, wrapping round.\n * @keyboard items: ArrowLeft | previous | Moves to the previous bar, wrapping round.\n * @keyboard items: Home | first | Moves to the first bar.\n * @keyboard items: End | last | Moves to the last bar.\n *\n * @a11y-role figure\n * @a11y-name-from label\n * @a11y-name The `label`, which is the chart's visible title.\n * @a11y-note Each `<data>` element is in the Tab order once (roving tabindex) and is announced as \"Category: value\". Arrow keys move between bars.\n * @a11y-note The value axis is hidden from assistive technology, because every bar announces its own value.\n *\n * @guidance-use To compare one number across a few categories (up to about 12), such as visitors per day or sales per region.\n * @guidance-avoid For trends over many points in time, for parts of a whole, or when readers need to look up exact values.\n * @guidance-instead A line chart for trends; a table when exact values matter.\n */\nexport class VaBarChart extends LitElement {\n static override shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, slotAssignment: 'manual' };\n\n static override properties: PropertyDeclarations = {\n label: {},\n max: { type: Number },\n _revision: { state: true },\n _focused: { state: true },\n };\n\n /** The chart's title, shown above it. */\n declare label: string;\n /** The top of the value axis. 0 (the default) fits the axis to the data; set it to keep the scale steady while live values change. */\n declare max: number;\n\n declare private _revision: number;\n declare private _focused: number;\n #observer = new MutationObserver(() => this._revision++);\n\n constructor() {\n super();\n this.label = '';\n this.max = 0;\n this._revision = 0;\n this._focused = -1;\n this.addEventListener('keydown', this.#onKeydown);\n this.addEventListener('focusin', this.#onFocusin);\n this.addEventListener('focusout', () => (this._focused = -1));\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n checkTokensLoaded(this);\n this.#observer.observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['value'] });\n // Children may have changed while the chart was detached and unobserved.\n if (this.hasUpdated) this._revision++;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#observer.disconnect();\n }\n\n get #items(): HTMLElement[] {\n return [...this.children] as HTMLElement[];\n }\n\n #valueOf(item: Element): number {\n const value = Number(item.getAttribute('value'));\n return Number.isFinite(value) ? value : 0;\n }\n\n get #format(): Intl.NumberFormat {\n return new Intl.NumberFormat(this.closest('[lang]')?.getAttribute('lang') || undefined);\n }\n\n override firstUpdated(): void {\n if (!this.label) devWarn('va-bar-chart', 'This chart has no label, so it has no title or accessible name.', 'Add label=\"…\" that says what the bars show (e.g. label=\"Visitors per day\").');\n }\n\n override updated(changed: PropertyValues): void {\n const items = this.#items;\n const slots = [...this.shadowRoot!.querySelectorAll<HTMLSlotElement>('slot')];\n items.forEach((item, i) => slots[i]?.assign(item));\n\n const format = this.#format;\n const current = Math.max(0, items.findIndex((i) => i.tabIndex === 0));\n items.forEach((item, i) => {\n item.tabIndex = i === current ? 0 : -1;\n item.setAttribute('role', 'img');\n item.setAttribute('aria-label', `${item.textContent?.trim()}: ${format.format(this.#valueOf(item))}`);\n });\n\n if (changed.has('_revision')) {\n if (items.some((i) => i.localName !== 'data')) {\n devWarn('va-bar-chart', 'A child is not a <data> element, so it is drawn as a bar with value 0.', 'Use <data value=\"N\">Category</data> for each bar.');\n }\n for (const item of items.filter((i) => i.localName === 'data' && !Number.isFinite(Number(i.getAttribute('value') ?? 'x')))) {\n devWarn('va-bar-chart', `\"${item.textContent?.trim()}\" has value=\"${item.getAttribute('value') ?? ''}\", which is not a number.`, 'Set value to a plain number, without units or separators (e.g. value=\"1200\").');\n }\n }\n }\n\n #onFocusin = (event: FocusEvent): void => {\n const items = this.#items;\n const index = items.indexOf(event.target as HTMLElement);\n if (index < 0) return;\n items.forEach((item, i) => (item.tabIndex = i === index ? 0 : -1));\n this._focused = index;\n };\n\n #onKeydown = (event: KeyboardEvent): void => {\n const items = this.#items;\n const current = items.indexOf(event.target as HTMLElement);\n if (current < 0 || !items.length) return;\n const next = { ArrowRight: current + 1, ArrowLeft: current - 1, Home: 0, End: items.length - 1 }[event.key];\n if (next === undefined) return;\n event.preventDefault();\n items[(next + items.length) % items.length].focus();\n };\n\n override render() {\n const items = this.#items;\n const values = items.map((i) => this.#valueOf(i));\n const format = this.#format;\n\n // The axis always includes 0, so bars start from a baseline and their lengths compare honestly.\n let lo = Math.min(0, ...values);\n let hi = this.max > 0 ? this.max : Math.max(0, ...values);\n if (hi === lo) hi = lo + 1;\n const step = niceStep(hi - lo, 5);\n lo = Math.floor(lo / step) * step;\n if (!(this.max > 0)) hi = Math.ceil(hi / step) * step;\n const ticks: number[] = [];\n // Count steps instead of adding them up, and round to the step's decimals, so float error\n // never gives a \"-0\" label or a missing zero line.\n const decimals = Math.max(0, -Math.floor(Math.log10(step)));\n for (let i = 0; lo + i * step <= hi + step / 1e6; i++) ticks.push(Number((lo + i * step).toFixed(decimals)) + 0);\n const pos = (v: number) => ((Math.min(Math.max(v, lo), hi) - lo) / (hi - lo)) * 100;\n\n return html`\n <div class=\"chart\" role=\"figure\" aria-labelledby=\"label\">\n <div part=\"label\" id=\"label\" class=\"label\">${this.label}</div>\n <div class=\"body\">\n <div part=\"axis\" class=\"axis\" aria-hidden=\"true\">\n ${ticks.map((t) => html`<span class=\"tick\" ${cssom({ bottom: `${pos(t)}%` })}>${format.format(t)}</span>`)}\n </div>\n <div class=\"columns\">\n <div part=\"plot\" class=\"plot\">\n ${ticks.map((t) => html`<span class=${t === 0 ? 'grid zero' : 'grid'} ${cssom({ bottom: `${pos(t)}%` })}></span>`)}\n ${values.map((v, i) => {\n const top = pos(Math.max(v, 0));\n const bottom = pos(Math.min(v, 0));\n return html`\n <div class=${i === this._focused ? 'column focused' : 'column'}>\n <span\n part=\"bar\"\n class=${v < 0 ? 'bar negative' : 'bar'}\n ${cssom({ bottom: `${bottom}%`, height: `${top - bottom}%` })}\n ></span>\n <span class=\"value\" aria-hidden=\"true\" ${cssom(v < 0 ? { top: `${100 - bottom}%` } : { bottom: `${top}%` })}>${format.format(v)}</span>\n </div>\n `;\n })}\n </div>\n <div class=\"labels\">${items.map(() => html`<div class=\"category\"><slot></slot></div>`)}</div>\n </div>\n </div>\n </div>\n `;\n }\n\n static override styles = css`\n :host {\n display: block;\n box-sizing: border-box;\n width: 100%;\n font-family: var(--va-font-family-ui);\n font-size: var(--va-font-size-sm);\n color: var(--va-color-text-default);\n }\n :host([hidden]) {\n display: none;\n }\n .label {\n margin-bottom: var(--va-space-gap-md);\n font-size: var(--va-font-size-md);\n font-weight: var(--va-font-weight-bold);\n }\n .body {\n display: grid;\n grid-template-columns: auto 1fr;\n gap: var(--va-space-gap-md);\n }\n .axis {\n position: relative;\n height: var(--va-bar-chart-size, 12rem);\n min-width: 2ch;\n color: var(--va-color-text-muted);\n font-variant-numeric: tabular-nums;\n }\n .tick {\n position: absolute;\n right: 0;\n transform: translateY(50%);\n line-height: 1;\n white-space: nowrap;\n }\n .columns {\n min-width: 0;\n }\n .plot {\n position: relative;\n display: flex;\n height: var(--va-bar-chart-size, 12rem);\n }\n .grid {\n position: absolute;\n left: 0;\n right: 0;\n border-top: 1px solid var(--va-color-border-subtle);\n }\n .grid.zero {\n border-top-color: var(--va-color-border-control);\n }\n .column {\n position: relative;\n flex: 1;\n min-width: 0;\n }\n .bar {\n position: absolute;\n left: 18%;\n right: 18%;\n border-radius: var(--va-bar-chart-bar-radius, 3px) var(--va-bar-chart-bar-radius, 3px) 0 0;\n background-color: var(--va-bar-chart-bar-bg, var(--va-color-accent-default));\n transition:\n height var(--va-motion-duration-slow) ease-out,\n bottom var(--va-motion-duration-slow) ease-out;\n }\n .bar.negative {\n border-radius: 0 0 var(--va-bar-chart-bar-radius, 3px) var(--va-bar-chart-bar-radius, 3px);\n }\n .column:hover .bar,\n .focused .bar {\n background-color: var(--va-bar-chart-bar-bg, var(--va-color-accent-hover));\n filter: brightness(1.1);\n }\n .value {\n position: absolute;\n left: 0;\n right: 0;\n padding: 2px 0;\n font-variant-numeric: tabular-nums;\n font-weight: var(--va-font-weight-medium);\n text-align: center;\n visibility: hidden;\n }\n .column:hover .value,\n .focused .value {\n visibility: visible;\n }\n .labels {\n display: flex;\n margin-top: var(--va-space-gap-sm);\n }\n .category {\n flex: 1;\n min-width: 0;\n text-align: center;\n }\n ::slotted(*) {\n display: block;\n overflow: hidden;\n padding: 2px;\n border-radius: var(--va-radius-control);\n color: var(--va-color-text-muted);\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n ::slotted(:focus-visible) {\n outline: var(--va-size-focus-ring, 2px) solid var(--va-color-focus);\n outline-offset: 0;\n color: var(--va-color-text-default);\n }\n @media (prefers-reduced-motion: reduce) {\n .bar {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .bar {\n background-color: CanvasText;\n forced-color-adjust: none;\n }\n .grid {\n border-top-color: GrayText;\n }\n ::slotted(:focus-visible) {\n outline-color: Highlight;\n }\n }\n `;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'va-bar-chart': VaBarChart;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bar-chart/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC","sourcesContent":["import { define } from '../core/define.js';\nimport { VaBarChart } from './bar-chart.js';\n\nexport { VaBarChart };\n\ndefine('va-bar-chart', VaBarChart);\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Directive, type ElementPart, type PartInfo } from 'lit/directive.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sets inline styles through the CSSOM (element.style), never through a style attribute, so a
|
|
4
|
+
* strict Content Security Policy allows them. Lit's styleMap writes a style attribute on the first
|
|
5
|
+
* render, which `style-src 'self'` blocks. Use it in an element position: <span ${cssom({ … })}>.
|
|
6
|
+
*/
|
|
7
|
+
declare class CssomDirective extends Directive {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(part: PartInfo);
|
|
10
|
+
render(styles: Record<string, string>): undefined;
|
|
11
|
+
update(part: ElementPart, [styles]: [Record<string, string>]): undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare const cssom: (styles: Record<string, string>) => import("lit/directive.js").DirectiveResult<typeof CssomDirective>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=cssom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssom.d.ts","sourceRoot":"","sources":["../../../src/core/cssom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnG;;;;GAIG;AACH,cAAM,cAAe,SAAQ,SAAS;;gBAGxB,IAAI,EAAE,QAAQ;IAK1B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAK5B,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAOtE;AAED,eAAO,MAAM,KAAK,uGAA4B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Directive, directive, PartType } from 'lit/directive.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sets inline styles through the CSSOM (element.style), never through a style attribute, so a
|
|
4
|
+
* strict Content Security Policy allows them. Lit's styleMap writes a style attribute on the first
|
|
5
|
+
* render, which `style-src 'self'` blocks. Use it in an element position: <span ${cssom({ … })}>.
|
|
6
|
+
*/
|
|
7
|
+
class CssomDirective extends Directive {
|
|
8
|
+
#previous = new Set();
|
|
9
|
+
constructor(part) {
|
|
10
|
+
super(part);
|
|
11
|
+
if (part.type !== PartType.ELEMENT)
|
|
12
|
+
throw new Error('cssom() goes in an element position: <div ${cssom({…})}>.');
|
|
13
|
+
}
|
|
14
|
+
render(styles) {
|
|
15
|
+
void styles;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
update(part, [styles]) {
|
|
19
|
+
const style = part.element.style;
|
|
20
|
+
for (const name of this.#previous)
|
|
21
|
+
if (!(name in styles))
|
|
22
|
+
style.removeProperty(name);
|
|
23
|
+
for (const [name, value] of Object.entries(styles))
|
|
24
|
+
style.setProperty(name, value);
|
|
25
|
+
this.#previous = new Set(Object.keys(styles));
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export const cssom = directive(CssomDirective);
|
|
30
|
+
//# sourceMappingURL=cssom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssom.js","sourceRoot":"","sources":["../../../src/core/cssom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAmC,MAAM,kBAAkB,CAAC;AAEnG;;;;GAIG;AACH,MAAM,cAAe,SAAQ,SAAS;IACpC,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,YAAY,IAAc;QACxB,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IACnH,CAAC;IAED,MAAM,CAAC,MAA8B;QACnC,KAAK,MAAM,CAAC;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;IAEQ,MAAM,CAAC,IAAiB,EAAE,CAAC,MAAM,CAA2B;QACnE,MAAM,KAAK,GAAI,IAAI,CAAC,OAAuB,CAAC,KAAK,CAAC;QAClD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC;gBAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACrF,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACnF,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9C,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import { Directive, directive, PartType, type ElementPart, type PartInfo } from 'lit/directive.js';\n\n/**\n * Sets inline styles through the CSSOM (element.style), never through a style attribute, so a\n * strict Content Security Policy allows them. Lit's styleMap writes a style attribute on the first\n * render, which `style-src 'self'` blocks. Use it in an element position: <span ${cssom({ … })}>.\n */\nclass CssomDirective extends Directive {\n #previous = new Set<string>();\n\n constructor(part: PartInfo) {\n super(part);\n if (part.type !== PartType.ELEMENT) throw new Error('cssom() goes in an element position: <div ${cssom({…})}>.');\n }\n\n render(styles: Record<string, string>) {\n void styles;\n return undefined;\n }\n\n override update(part: ElementPart, [styles]: [Record<string, string>]) {\n const style = (part.element as HTMLElement).style;\n for (const name of this.#previous) if (!(name in styles)) style.removeProperty(name);\n for (const [name, value] of Object.entries(styles)) style.setProperty(name, value);\n this.#previous = new Set(Object.keys(styles));\n return undefined;\n }\n}\n\nexport const cssom = directive(CssomDirective);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/navbar/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/navbar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import { define } from '../core/define.js';\nimport { VaNavbar } from './navbar.js';\n\nexport { VaNavbar };\n\ndefine('va-navbar', VaNavbar);\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { LitElement, type PropertyDeclarations, type PropertyValues } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* A site's main navigation bar: a brand link and links to pages. On narrow screens the links fold
|
|
4
|
+
* behind a Menu button, following the WAI-ARIA disclosure navigation pattern.
|
|
5
|
+
*
|
|
6
|
+
* @tag va-navbar
|
|
7
|
+
* @summary Shows a site's brand and main links in a bar that folds behind a Menu button on narrow screens.
|
|
8
|
+
*
|
|
9
|
+
* @slot - The links, as `<a href="…">` elements. Mark the current page's link with `aria-current="page"`.
|
|
10
|
+
* @slot brand - The site's name or logo, as an `<a href="…">` to the home page.
|
|
11
|
+
*
|
|
12
|
+
* @cssstate collapsed - The links are folded behind the Menu button.
|
|
13
|
+
*
|
|
14
|
+
* @csspart bar - The bar, which is the `<nav>` element.
|
|
15
|
+
* @csspart toggle - The Menu button shown on narrow screens.
|
|
16
|
+
* @csspart links - The wrapper around the links. On narrow screens it is the panel that opens.
|
|
17
|
+
*
|
|
18
|
+
* @cssprop {<color>} --va-navbar-bg - Background colour of the bar and of the open panel.
|
|
19
|
+
* @cssprop {<color>} --va-navbar-border - Colour of the line under the bar.
|
|
20
|
+
* @cssprop {<length>} --va-navbar-size - Minimum height of the bar.
|
|
21
|
+
* @cssprop {<color>} --va-navbar-link-fg - Text colour of the links.
|
|
22
|
+
* @cssprop {<color>} --va-navbar-indicator-border - Colour of the line that marks the current page's link.
|
|
23
|
+
*
|
|
24
|
+
* @cssprop-applies --va-navbar-bg bar background-color
|
|
25
|
+
* @cssprop-applies --va-navbar-border bar border-bottom-color
|
|
26
|
+
* @cssprop-applies --va-navbar-size bar min-height
|
|
27
|
+
* @cssprop-applies --va-navbar-link-fg light(a:not([slot]):not([aria-current])) color
|
|
28
|
+
* @cssprop-applies --va-navbar-indicator-border light([aria-current="page"]) border-bottom-color
|
|
29
|
+
*
|
|
30
|
+
* @keyboard open: Escape | closes | Closes the open panel of links and returns focus to the Menu button.
|
|
31
|
+
*
|
|
32
|
+
* @a11y-role navigation
|
|
33
|
+
* @a11y-name-from accessible-label
|
|
34
|
+
* @a11y-name The `accessible-label` attribute, such as "Main" (not shown). Needed when a page has more than one navigation landmark.
|
|
35
|
+
* @a11y-note The bar is a `<nav>` landmark. The links keep their own names; mark the current page with `aria-current="page"`.
|
|
36
|
+
* @a11y-note Style the folded layout with `va-navbar:state(collapsed)`.
|
|
37
|
+
* @a11y-note On narrow screens the Menu button has a visible label, `aria-expanded` and `aria-controls`. Escape, a click outside or moving focus away closes the panel.
|
|
38
|
+
*
|
|
39
|
+
* @guidance-use For a site's or app's main navigation: a brand link and up to about seven links to pages.
|
|
40
|
+
* @guidance-avoid For actions that do something on the page, for switching views in one place, or for deep hierarchies of pages.
|
|
41
|
+
* @guidance-instead `va-menu` for actions; `va-tabs` for views in one place; nested lists in a sidebar for deep navigation.
|
|
42
|
+
*/
|
|
43
|
+
export declare class VaNavbar extends LitElement {
|
|
44
|
+
#private;
|
|
45
|
+
static properties: PropertyDeclarations;
|
|
46
|
+
/** Whether the panel of links is open. It only shows while the navbar is folded. */
|
|
47
|
+
open: boolean;
|
|
48
|
+
/** Width in pixels below which the links fold behind the Menu button. It is the navbar's own width, not the window's. */
|
|
49
|
+
collapseBelow: number;
|
|
50
|
+
/** Visible text of the Menu button. */
|
|
51
|
+
toggleLabel: string;
|
|
52
|
+
/** Accessible name of the navigation landmark. */
|
|
53
|
+
accessibleLabel: string;
|
|
54
|
+
private _collapsed;
|
|
55
|
+
constructor();
|
|
56
|
+
connectedCallback(): void;
|
|
57
|
+
disconnectedCallback(): void;
|
|
58
|
+
firstUpdated(): void;
|
|
59
|
+
willUpdate(changed: PropertyValues): void;
|
|
60
|
+
updated(changed: PropertyValues): void;
|
|
61
|
+
render(): import("lit").TemplateResult<1>;
|
|
62
|
+
static styles: import("lit").CSSResult[];
|
|
63
|
+
}
|
|
64
|
+
declare global {
|
|
65
|
+
interface HTMLElementTagNameMap {
|
|
66
|
+
'va-navbar': VaNavbar;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=navbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navbar.d.ts","sourceRoot":"","sources":["../../../src/navbar/navbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAIrG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,QAAS,SAAQ,UAAU;;IACtC,OAAgB,UAAU,EAAE,oBAAoB,CAM9C;IAEF,oFAAoF;IAC5E,IAAI,EAAE,OAAO,CAAC;IACtB,yHAAyH;IACjH,aAAa,EAAE,MAAM,CAAC;IAC9B,uCAAuC;IAC/B,WAAW,EAAE,MAAM,CAAC;IAC5B,kDAAkD;IAC1C,eAAe,EAAE,MAAM,CAAC;IAEhC,QAAgB,UAAU,CAAU;;IAmB3B,iBAAiB,IAAI,IAAI;IAQzB,oBAAoB,IAAI,IAAI;IAM5B,YAAY,IAAI,IAAI;IAMpB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAMzC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IA4DtC,MAAM;IAwBf,OAAgB,MAAM,4BA6KpB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|