@firstprateek/vastu 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +51 -2
  3. package/custom-elements.json +3046 -0
  4. package/dist/dev/all.d.ts +9 -0
  5. package/dist/dev/all.d.ts.map +1 -0
  6. package/dist/dev/all.js +10 -0
  7. package/dist/dev/all.js.map +1 -0
  8. package/dist/dev/button/button.d.ts +98 -0
  9. package/dist/dev/button/button.d.ts.map +1 -0
  10. package/dist/dev/button/button.js +292 -0
  11. package/dist/dev/button/button.js.map +1 -0
  12. package/dist/dev/button/index.d.ts +4 -0
  13. package/dist/dev/button/index.d.ts.map +1 -0
  14. package/dist/dev/button/index.js +5 -0
  15. package/dist/dev/button/index.js.map +1 -0
  16. package/dist/dev/checkbox/checkbox.d.ts +71 -0
  17. package/dist/dev/checkbox/checkbox.d.ts.map +1 -0
  18. package/dist/dev/checkbox/checkbox.js +232 -0
  19. package/dist/dev/checkbox/checkbox.js.map +1 -0
  20. package/dist/dev/checkbox/index.d.ts +3 -0
  21. package/dist/dev/checkbox/index.d.ts.map +1 -0
  22. package/dist/dev/checkbox/index.js +5 -0
  23. package/dist/dev/checkbox/index.js.map +1 -0
  24. package/dist/dev/core/define.d.ts +3 -0
  25. package/dist/dev/core/define.d.ts.map +1 -0
  26. package/dist/dev/core/define.js +6 -0
  27. package/dist/dev/core/define.js.map +1 -0
  28. package/dist/dev/core/dev-mode.d.ts +6 -0
  29. package/dist/dev/core/dev-mode.d.ts.map +1 -0
  30. package/dist/dev/core/dev-mode.js +6 -0
  31. package/dist/dev/core/dev-mode.js.map +1 -0
  32. package/dist/dev/core/focus-ring.d.ts +3 -0
  33. package/dist/dev/core/focus-ring.d.ts.map +1 -0
  34. package/dist/dev/core/focus-ring.js +14 -0
  35. package/dist/dev/core/focus-ring.js.map +1 -0
  36. package/dist/dev/core/form-control.d.ts +47 -0
  37. package/dist/dev/core/form-control.d.ts.map +1 -0
  38. package/dist/dev/core/form-control.js +75 -0
  39. package/dist/dev/core/form-control.js.map +1 -0
  40. package/dist/dev/core/warn.d.ts +12 -0
  41. package/dist/dev/core/warn.d.ts.map +1 -0
  42. package/dist/dev/core/warn.js +35 -0
  43. package/dist/dev/core/warn.js.map +1 -0
  44. package/dist/dev/dialog/dialog.d.ts +77 -0
  45. package/dist/dev/dialog/dialog.d.ts.map +1 -0
  46. package/dist/dev/dialog/dialog.js +253 -0
  47. package/dist/dev/dialog/dialog.js.map +1 -0
  48. package/dist/dev/dialog/index.d.ts +4 -0
  49. package/dist/dev/dialog/index.d.ts.map +1 -0
  50. package/dist/dev/dialog/index.js +5 -0
  51. package/dist/dev/dialog/index.js.map +1 -0
  52. package/dist/dev/menu/index.d.ts +3 -0
  53. package/dist/dev/menu/index.d.ts.map +1 -0
  54. package/dist/dev/menu/index.js +5 -0
  55. package/dist/dev/menu/index.js.map +1 -0
  56. package/dist/dev/menu/menu.d.ts +71 -0
  57. package/dist/dev/menu/menu.d.ts.map +1 -0
  58. package/dist/dev/menu/menu.js +330 -0
  59. package/dist/dev/menu/menu.js.map +1 -0
  60. package/dist/dev/switch/index.d.ts +3 -0
  61. package/dist/dev/switch/index.d.ts.map +1 -0
  62. package/dist/dev/switch/index.js +5 -0
  63. package/dist/dev/switch/index.js.map +1 -0
  64. package/dist/dev/switch/switch.d.ts +69 -0
  65. package/dist/dev/switch/switch.d.ts.map +1 -0
  66. package/dist/dev/switch/switch.js +213 -0
  67. package/dist/dev/switch/switch.js.map +1 -0
  68. package/dist/dev/tabs/index.d.ts +3 -0
  69. package/dist/dev/tabs/index.d.ts.map +1 -0
  70. package/dist/dev/tabs/index.js +5 -0
  71. package/dist/dev/tabs/index.js.map +1 -0
  72. package/dist/dev/tabs/tabs.d.ts +64 -0
  73. package/dist/dev/tabs/tabs.d.ts.map +1 -0
  74. package/dist/dev/tabs/tabs.js +212 -0
  75. package/dist/dev/tabs/tabs.js.map +1 -0
  76. package/dist/dev/text-field/index.d.ts +3 -0
  77. package/dist/dev/text-field/index.d.ts.map +1 -0
  78. package/dist/dev/text-field/index.js +5 -0
  79. package/dist/dev/text-field/index.js.map +1 -0
  80. package/dist/dev/text-field/text-field.d.ts +91 -0
  81. package/dist/dev/text-field/text-field.d.ts.map +1 -0
  82. package/dist/dev/text-field/text-field.js +267 -0
  83. package/dist/dev/text-field/text-field.js.map +1 -0
  84. package/dist/dev/toast/index.d.ts +4 -0
  85. package/dist/dev/toast/index.d.ts.map +1 -0
  86. package/dist/dev/toast/index.js +5 -0
  87. package/dist/dev/toast/index.js.map +1 -0
  88. package/dist/dev/toast/toast.d.ts +71 -0
  89. package/dist/dev/toast/toast.d.ts.map +1 -0
  90. package/dist/dev/toast/toast.js +258 -0
  91. package/dist/dev/toast/toast.js.map +1 -0
  92. package/dist/prod/all.js +10 -0
  93. package/dist/prod/button/button.js +292 -0
  94. package/dist/prod/button/index.js +5 -0
  95. package/dist/prod/checkbox/checkbox.js +232 -0
  96. package/dist/prod/checkbox/index.js +5 -0
  97. package/dist/prod/core/define.js +6 -0
  98. package/dist/prod/core/dev-mode.js +1 -0
  99. package/dist/prod/core/focus-ring.js +14 -0
  100. package/dist/prod/core/form-control.js +75 -0
  101. package/dist/prod/core/warn.js +2 -0
  102. package/dist/prod/dialog/dialog.js +253 -0
  103. package/dist/prod/dialog/index.js +5 -0
  104. package/dist/prod/menu/index.js +5 -0
  105. package/dist/prod/menu/menu.js +330 -0
  106. package/dist/prod/switch/index.js +5 -0
  107. package/dist/prod/switch/switch.js +213 -0
  108. package/dist/prod/tabs/index.js +5 -0
  109. package/dist/prod/tabs/tabs.js +212 -0
  110. package/dist/prod/text-field/index.js +5 -0
  111. package/dist/prod/text-field/text-field.js +267 -0
  112. package/dist/prod/toast/index.js +5 -0
  113. package/dist/prod/toast/toast.js +258 -0
  114. package/package.json +95 -3
@@ -0,0 +1,9 @@
1
+ export * from './button/index.js';
2
+ export * from './checkbox/index.js';
3
+ export * from './dialog/index.js';
4
+ export * from './menu/index.js';
5
+ export * from './switch/index.js';
6
+ export * from './tabs/index.js';
7
+ export * from './text-field/index.js';
8
+ export * from './toast/index.js';
9
+ //# sourceMappingURL=all.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,10 @@
1
+ // Generated by build.js: registers every Vastu component.
2
+ export * from './button/index.js';
3
+ export * from './checkbox/index.js';
4
+ export * from './dialog/index.js';
5
+ export * from './menu/index.js';
6
+ export * from './switch/index.js';
7
+ export * from './tabs/index.js';
8
+ export * from './text-field/index.js';
9
+ export * from './toast/index.js';
10
+ //# sourceMappingURL=all.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,98 @@
1
+ import { LitElement, type PropertyDeclarations } from 'lit';
2
+ /**
3
+ * A button that starts an action or submits a form.
4
+ *
5
+ * @tag va-button
6
+ * @summary Starts an action, or submits or resets the form it is in.
7
+ *
8
+ * @slot - The button's text. This is its accessible name.
9
+ * @slot start - An icon before the text. Mark decorative icons `aria-hidden="true"`.
10
+ * @slot end - An icon after the text.
11
+ *
12
+ * @csspart control - The native button inside.
13
+ * @csspart label - The wrapper around the text.
14
+ *
15
+ * @cssprop {<color>} --va-button-bg - Background colour.
16
+ * @cssprop {<color>} --va-button-bg-hover - Background colour on hover.
17
+ * @cssprop {<color>} --va-button-fg - Text and icon colour.
18
+ * @cssprop {<color>} --va-button-border - Border colour.
19
+ * @cssprop {<length>} --va-button-radius - Corner radius.
20
+ * @cssprop {<length>} --va-button-height - Minimum height.
21
+ * @cssprop {<length>} --va-button-padding-inline - Space before and after the text.
22
+ * @cssprop {<length>} --va-button-font-size - Text size.
23
+ *
24
+ * @cssprop-applies --va-button-bg control background-color
25
+ * @cssprop-applies --va-button-bg-hover control:hover background-color
26
+ * @cssprop-applies --va-button-fg control color
27
+ * @cssprop-applies --va-button-border control border-top-color
28
+ * @cssprop-applies --va-button-radius control border-top-left-radius
29
+ * @cssprop-applies --va-button-height control min-height
30
+ * @cssprop-applies --va-button-padding-inline control padding-left
31
+ * @cssprop-applies --va-button-font-size control font-size
32
+ *
33
+ * @keyboard Enter | activates | Activates the button.
34
+ * @keyboard Space | activates | Activates the button.
35
+ * @keyboard Tab | focus-next | Moves focus to the next control. A disabled button is skipped.
36
+ *
37
+ * @a11y-role button
38
+ * @a11y-name-from text, accessible-label
39
+ * @replaces button
40
+ * @a11y-name The slotted text. A button with only an icon must have `accessible-label`.
41
+ * @a11y-note `loading` keeps the button focusable, sets `aria-disabled` and `aria-busy`, and adds "Loading" to its name.
42
+ *
43
+ * @guidance-use For an action on the current page (Save, Delete, Open dialog) or to submit a form.
44
+ * @guidance-avoid For navigation to another page or URL.
45
+ * @guidance-instead A link (`<a href>`) for navigation.
46
+ *
47
+ * @fires click - The native click event. Not fired while `disabled` or `loading`.
48
+ * @event-trigger click | click
49
+ */
50
+ export declare class VaButton extends LitElement {
51
+ #private;
52
+ static shadowRootOptions: ShadowRootInit;
53
+ /** @internal */
54
+ static formAssociated: boolean;
55
+ static properties: PropertyDeclarations;
56
+ /** Visual emphasis. Use one `primary` button per view. */
57
+ variant: 'primary' | 'secondary' | 'ghost' | 'danger';
58
+ /** Height and text size. Every size meets the 24px WCAG 2.2 target size. */
59
+ size: 'sm' | 'md' | 'lg';
60
+ /**
61
+ * What the button does in a form. Defaults to `button`, unlike the native `<button>`,
62
+ * so a button never submits a form by accident. Set `type="submit"` to submit.
63
+ */
64
+ type: 'button' | 'submit' | 'reset';
65
+ /** Disables the button. It cannot be focused or activated. */
66
+ disabled: boolean;
67
+ /** Shows a spinner and blocks activation, but keeps the button focusable. */
68
+ loading: boolean;
69
+ /** Submitted with the form as `name=value` when this button submits it. */
70
+ name: string;
71
+ /** Submitted with `name` when this button submits the form. */
72
+ value: string;
73
+ /** Accessible name for a button with no text, such as an icon-only button. Not shown. */
74
+ accessibleLabel: string;
75
+ /**
76
+ * The id of the element this button sends `command` to, as with the native Invoker Commands API.
77
+ * For example `commandfor="confirm" command="--show"` opens `<va-dialog id="confirm">`.
78
+ */
79
+ commandfor: string;
80
+ /** The command sent to the `commandfor` element on click, such as `--show` or `--close`. */
81
+ command: string;
82
+ constructor();
83
+ /** The form this button belongs to, if any. */
84
+ get form(): HTMLFormElement | null;
85
+ connectedCallback(): void;
86
+ firstUpdated(): void;
87
+ render(): import("lit").TemplateResult<1>;
88
+ static styles: import("lit").CSSResult[];
89
+ }
90
+ export type ButtonVariant = VaButton['variant'];
91
+ export type ButtonSize = VaButton['size'];
92
+ export type ButtonType = VaButton['type'];
93
+ declare global {
94
+ interface HTMLElementTagNameMap {
95
+ 'va-button': VaButton;
96
+ }
97
+ }
98
+ //# sourceMappingURL=button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","s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1C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
@@ -0,0 +1,292 @@
1
+ import { LitElement, css, html, nothing } from 'lit';
2
+ import { focusRing } from '../core/focus-ring.js';
3
+ import { checkTokensLoaded, devWarn } from '../core/warn.js';
4
+ /**
5
+ * A button that starts an action or submits a form.
6
+ *
7
+ * @tag va-button
8
+ * @summary Starts an action, or submits or resets the form it is in.
9
+ *
10
+ * @slot - The button's text. This is its accessible name.
11
+ * @slot start - An icon before the text. Mark decorative icons `aria-hidden="true"`.
12
+ * @slot end - An icon after the text.
13
+ *
14
+ * @csspart control - The native button inside.
15
+ * @csspart label - The wrapper around the text.
16
+ *
17
+ * @cssprop {<color>} --va-button-bg - Background colour.
18
+ * @cssprop {<color>} --va-button-bg-hover - Background colour on hover.
19
+ * @cssprop {<color>} --va-button-fg - Text and icon colour.
20
+ * @cssprop {<color>} --va-button-border - Border colour.
21
+ * @cssprop {<length>} --va-button-radius - Corner radius.
22
+ * @cssprop {<length>} --va-button-height - Minimum height.
23
+ * @cssprop {<length>} --va-button-padding-inline - Space before and after the text.
24
+ * @cssprop {<length>} --va-button-font-size - Text size.
25
+ *
26
+ * @cssprop-applies --va-button-bg control background-color
27
+ * @cssprop-applies --va-button-bg-hover control:hover background-color
28
+ * @cssprop-applies --va-button-fg control color
29
+ * @cssprop-applies --va-button-border control border-top-color
30
+ * @cssprop-applies --va-button-radius control border-top-left-radius
31
+ * @cssprop-applies --va-button-height control min-height
32
+ * @cssprop-applies --va-button-padding-inline control padding-left
33
+ * @cssprop-applies --va-button-font-size control font-size
34
+ *
35
+ * @keyboard Enter | activates | Activates the button.
36
+ * @keyboard Space | activates | Activates the button.
37
+ * @keyboard Tab | focus-next | Moves focus to the next control. A disabled button is skipped.
38
+ *
39
+ * @a11y-role button
40
+ * @a11y-name-from text, accessible-label
41
+ * @replaces button
42
+ * @a11y-name The slotted text. A button with only an icon must have `accessible-label`.
43
+ * @a11y-note `loading` keeps the button focusable, sets `aria-disabled` and `aria-busy`, and adds "Loading" to its name.
44
+ *
45
+ * @guidance-use For an action on the current page (Save, Delete, Open dialog) or to submit a form.
46
+ * @guidance-avoid For navigation to another page or URL.
47
+ * @guidance-instead A link (`<a href>`) for navigation.
48
+ *
49
+ * @fires click - The native click event. Not fired while `disabled` or `loading`.
50
+ * @event-trigger click | click
51
+ */
52
+ export class VaButton extends LitElement {
53
+ static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true }; }
54
+ /** @internal */
55
+ static { this.formAssociated = true; }
56
+ static { this.properties = {
57
+ variant: { reflect: true },
58
+ size: { reflect: true },
59
+ type: { reflect: true },
60
+ disabled: { type: Boolean, reflect: true },
61
+ loading: { type: Boolean, reflect: true },
62
+ name: {},
63
+ value: {},
64
+ accessibleLabel: { attribute: 'accessible-label' },
65
+ commandfor: {},
66
+ command: {},
67
+ }; }
68
+ #internals;
69
+ constructor() {
70
+ super();
71
+ this.variant = 'primary';
72
+ this.size = 'md';
73
+ this.type = 'button';
74
+ this.disabled = false;
75
+ this.loading = false;
76
+ this.name = '';
77
+ this.value = '';
78
+ this.accessibleLabel = '';
79
+ this.commandfor = '';
80
+ this.command = '';
81
+ this.#internals = this.attachInternals();
82
+ this.addEventListener('click', this.#onClick);
83
+ }
84
+ /** The form this button belongs to, if any. */
85
+ get form() {
86
+ return this.#internals.form;
87
+ }
88
+ connectedCallback() {
89
+ super.connectedCallback();
90
+ checkTokensLoaded(this);
91
+ }
92
+ #onClick = (event) => {
93
+ if (this.disabled || this.loading) {
94
+ event.preventDefault();
95
+ event.stopImmediatePropagation();
96
+ return;
97
+ }
98
+ if (this.commandfor && this.command) {
99
+ // Same shape as the native CommandEvent, so components handle both.
100
+ const target = this.getRootNode().getElementById(this.commandfor);
101
+ if (target)
102
+ target.dispatchEvent(Object.assign(new Event('command', { cancelable: true }), { command: this.command, source: this }));
103
+ else
104
+ devWarn('va-button', `commandfor="${this.commandfor}" doesn't match any element id.`, 'Set commandfor to the id of the element to control, in the same document or shadow root.');
105
+ return;
106
+ }
107
+ const form = this.#internals.form;
108
+ if (!form)
109
+ return;
110
+ if (this.type === 'submit') {
111
+ // requestSubmit() needs a real submit button as the submitter, so name=value is sent.
112
+ const submitter = document.createElement('button');
113
+ submitter.type = 'submit';
114
+ submitter.hidden = true;
115
+ if (this.name) {
116
+ submitter.name = this.name;
117
+ submitter.value = this.value;
118
+ }
119
+ form.append(submitter);
120
+ form.requestSubmit(submitter);
121
+ submitter.remove();
122
+ }
123
+ else if (this.type === 'reset') {
124
+ form.reset();
125
+ }
126
+ };
127
+ firstUpdated() {
128
+ // Wait a frame so children parsed after the upgrade are in place before checking the name.
129
+ requestAnimationFrame(() => this.#checkName());
130
+ }
131
+ #checkName = () => {
132
+ const text = this.textContent?.trim() ?? '';
133
+ if (!text && !this.accessibleLabel) {
134
+ devWarn('va-button', 'This button has no accessible name: it has no text and no accessible-label.', 'Put text inside it, or add accessible-label="…" that says what it does (e.g. accessible-label="Close").');
135
+ }
136
+ else if (text && this.accessibleLabel && !this.accessibleLabel.toLowerCase().includes(text.toLowerCase())) {
137
+ devWarn('va-button', `accessible-label="${this.accessibleLabel}" replaces the visible text "${text}" for screen readers, so voice users can't say what they see (WCAG 2.5.3).`, 'Remove accessible-label, or make it start with the visible text.');
138
+ }
139
+ };
140
+ /** While loading, the name gains ", loading"; otherwise only accessible-label overrides the text. */
141
+ #ariaLabel() {
142
+ const name = this.accessibleLabel || this.textContent?.trim() || '';
143
+ if (this.loading)
144
+ return name ? `${name}, loading` : 'Loading';
145
+ return this.accessibleLabel || undefined;
146
+ }
147
+ render() {
148
+ return html `
149
+ <button
150
+ part="control"
151
+ class="control"
152
+ type="button"
153
+ ?disabled=${this.disabled}
154
+ aria-disabled=${this.loading ? 'true' : nothing}
155
+ aria-busy=${this.loading ? 'true' : nothing}
156
+ aria-label=${this.#ariaLabel() ?? nothing}
157
+ >
158
+ <slot name="start"></slot>
159
+ <span part="label" class="label"><slot @slotchange=${this.#checkName}></slot></span>
160
+ ${this.loading ? html `<span class="spinner" aria-hidden="true"></span>` : nothing}
161
+ <slot name="end"></slot>
162
+ </button>
163
+ `;
164
+ }
165
+ static { this.styles = [
166
+ focusRing,
167
+ css `
168
+ :host {
169
+ --_bg: var(--va-button-bg, var(--va-color-accent-default));
170
+ --_bg-hover: var(--va-button-bg-hover, var(--va-color-accent-hover));
171
+ --_fg: var(--va-button-fg, var(--va-color-text-on-accent));
172
+ --_border: var(--va-button-border, transparent);
173
+ --_height: var(--va-button-height, var(--va-size-control-md));
174
+ --_padding: var(--va-button-padding-inline, var(--va-space-inline-lg));
175
+ --_font-size: var(--va-button-font-size, var(--va-font-size-md));
176
+ display: inline-block;
177
+ vertical-align: middle;
178
+ }
179
+ :host([hidden]) {
180
+ display: none;
181
+ }
182
+ :host([variant='secondary']) {
183
+ --_bg: var(--va-button-bg, transparent);
184
+ --_bg-hover: var(--va-button-bg-hover, var(--va-color-surface-subtle));
185
+ --_fg: var(--va-button-fg, var(--va-color-text-default));
186
+ --_border: var(--va-button-border, var(--va-color-border-control));
187
+ }
188
+ :host([variant='ghost']) {
189
+ --_bg: var(--va-button-bg, transparent);
190
+ --_bg-hover: var(--va-button-bg-hover, var(--va-color-surface-subtle));
191
+ --_fg: var(--va-button-fg, var(--va-color-accent-default));
192
+ }
193
+ :host([variant='danger']) {
194
+ --_bg: var(--va-button-bg, var(--va-color-danger-default));
195
+ --_bg-hover: var(--va-button-bg-hover, var(--va-color-danger-hover));
196
+ --_fg: var(--va-button-fg, var(--va-color-text-on-danger));
197
+ }
198
+ :host([size='sm']) {
199
+ --_height: var(--va-button-height, var(--va-size-control-sm));
200
+ --_padding: var(--va-button-padding-inline, var(--va-space-inline-md));
201
+ --_font-size: var(--va-button-font-size, var(--va-font-size-sm));
202
+ }
203
+ :host([size='lg']) {
204
+ --_height: var(--va-button-height, var(--va-size-control-lg));
205
+ --_font-size: var(--va-button-font-size, var(--va-font-size-lg));
206
+ }
207
+
208
+ .control {
209
+ box-sizing: border-box;
210
+ display: inline-flex;
211
+ align-items: center;
212
+ justify-content: center;
213
+ gap: var(--va-space-gap-md);
214
+ width: 100%;
215
+ min-height: var(--_height);
216
+ margin: 0;
217
+ padding: 0 var(--_padding);
218
+ border: 1px solid var(--_border);
219
+ border-radius: var(--va-button-radius, var(--va-radius-control));
220
+ background-color: var(--_bg);
221
+ color: var(--_fg);
222
+ font-family: var(--va-font-family-ui);
223
+ font-size: var(--_font-size);
224
+ font-weight: var(--va-font-weight-medium);
225
+ line-height: 1.2;
226
+ cursor: pointer;
227
+ transition: background-color var(--va-motion-duration-fast) ease-out;
228
+ -webkit-tap-highlight-color: transparent;
229
+ }
230
+ .control:hover:not(:disabled):not([aria-disabled='true']) {
231
+ background-color: var(--_bg-hover);
232
+ }
233
+ .control:disabled {
234
+ opacity: 0.5;
235
+ cursor: not-allowed;
236
+ }
237
+ .control[aria-disabled='true'] {
238
+ cursor: progress;
239
+ }
240
+
241
+ ::slotted(svg),
242
+ ::slotted([slot='start']),
243
+ ::slotted([slot='end']) {
244
+ flex: none;
245
+ width: 1.25em;
246
+ height: 1.25em;
247
+ }
248
+
249
+ .spinner {
250
+ flex: none;
251
+ width: 1em;
252
+ height: 1em;
253
+ border: 2px solid currentColor;
254
+ border-right-color: transparent;
255
+ border-radius: 50%;
256
+ animation: spin 0.8s linear infinite;
257
+ }
258
+ @keyframes spin {
259
+ to {
260
+ transform: rotate(1turn);
261
+ }
262
+ }
263
+
264
+ @media (prefers-reduced-motion: reduce) {
265
+ .control {
266
+ transition: none;
267
+ }
268
+ .spinner {
269
+ animation-duration: 2.4s;
270
+ }
271
+ }
272
+
273
+ @media (forced-colors: active) {
274
+ .control {
275
+ border-color: ButtonText;
276
+ }
277
+ :host(:not([variant])) .control,
278
+ :host([variant='primary']) .control,
279
+ :host([variant='danger']) .control {
280
+ background-color: ButtonText;
281
+ color: ButtonFace;
282
+ forced-color-adjust: none;
283
+ }
284
+ .control:disabled {
285
+ border-color: GrayText;
286
+ color: GrayText;
287
+ }
288
+ }
289
+ `,
290
+ ]; }
291
+ }
292
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAA6B,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU;aACtB,sBAAiB,GAAmB,EAAE,GAAG,UAAU,CAAC,iBAAiB,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;IAE9G,gBAAgB;aACT,mBAAc,GAAG,IAAI,CAAC;aAEb,eAAU,GAAyB;QACjD,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC1B,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QACvB,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;QAC1C,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;QACzC,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,eAAe,EAAE,EAAE,SAAS,EAAE,kBAAkB,EAAE;QAClD,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,EAAE;KACZ,CAAC;IA6BO,UAAU,CAAmB;IAEtC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IA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;;;;;;;;;;;;;;;;;;;;;;;;;KA0HF;KACF,CAAC","sourcesContent":["import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { focusRing } from '../core/focus-ring.js';\nimport { checkTokensLoaded, devWarn } from '../core/warn.js';\n\n/**\n * A button that starts an action or submits a form.\n *\n * @tag va-button\n * @summary Starts an action, or submits or resets the form it is in.\n *\n * @slot - The button's text. This is its accessible name.\n * @slot start - An icon before the text. Mark decorative icons `aria-hidden=\"true\"`.\n * @slot end - An icon after the text.\n *\n * @csspart control - The native button inside.\n * @csspart label - The wrapper around the text.\n *\n * @cssprop {<color>} --va-button-bg - Background colour.\n * @cssprop {<color>} --va-button-bg-hover - Background colour on hover.\n * @cssprop {<color>} --va-button-fg - Text and icon colour.\n * @cssprop {<color>} --va-button-border - Border colour.\n * @cssprop {<length>} --va-button-radius - Corner radius.\n * @cssprop {<length>} --va-button-height - Minimum height.\n * @cssprop {<length>} --va-button-padding-inline - Space before and after the text.\n * @cssprop {<length>} --va-button-font-size - Text size.\n *\n * @cssprop-applies --va-button-bg control background-color\n * @cssprop-applies --va-button-bg-hover control:hover background-color\n * @cssprop-applies --va-button-fg control color\n * @cssprop-applies --va-button-border control border-top-color\n * @cssprop-applies --va-button-radius control border-top-left-radius\n * @cssprop-applies --va-button-height control min-height\n * @cssprop-applies --va-button-padding-inline control padding-left\n * @cssprop-applies --va-button-font-size control font-size\n *\n * @keyboard Enter | activates | Activates the button.\n * @keyboard Space | activates | Activates the button.\n * @keyboard Tab | focus-next | Moves focus to the next control. A disabled button is skipped.\n *\n * @a11y-role button\n * @a11y-name-from text, accessible-label\n * @replaces button\n * @a11y-name The slotted text. A button with only an icon must have `accessible-label`.\n * @a11y-note `loading` keeps the button focusable, sets `aria-disabled` and `aria-busy`, and adds \"Loading\" to its name.\n *\n * @guidance-use For an action on the current page (Save, Delete, Open dialog) or to submit a form.\n * @guidance-avoid For navigation to another page or URL.\n * @guidance-instead A link (`<a href>`) for navigation.\n *\n * @fires click - The native click event. Not fired while `disabled` or `loading`.\n * @event-trigger click | click\n */\nexport class VaButton extends LitElement {\n static override shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n /** @internal */\n static formAssociated = true;\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true },\n size: { reflect: true },\n type: { reflect: true },\n disabled: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n name: {},\n value: {},\n accessibleLabel: { attribute: 'accessible-label' },\n commandfor: {},\n command: {},\n };\n\n /** Visual emphasis. Use one `primary` button per view. */\n declare variant: 'primary' | 'secondary' | 'ghost' | 'danger';\n /** Height and text size. Every size meets the 24px WCAG 2.2 target size. */\n declare size: 'sm' | 'md' | 'lg';\n /**\n * What the button does in a form. Defaults to `button`, unlike the native `<button>`,\n * so a button never submits a form by accident. Set `type=\"submit\"` to submit.\n */\n declare type: 'button' | 'submit' | 'reset';\n /** Disables the button. It cannot be focused or activated. */\n declare disabled: boolean;\n /** Shows a spinner and blocks activation, but keeps the button focusable. */\n declare loading: boolean;\n /** Submitted with the form as `name=value` when this button submits it. */\n declare name: string;\n /** Submitted with `name` when this button submits the form. */\n declare value: string;\n /** Accessible name for a button with no text, such as an icon-only button. Not shown. */\n declare accessibleLabel: string;\n /**\n * The id of the element this button sends `command` to, as with the native Invoker Commands API.\n * For example `commandfor=\"confirm\" command=\"--show\"` opens `<va-dialog id=\"confirm\">`.\n */\n declare commandfor: string;\n /** The command sent to the `commandfor` element on click, such as `--show` or `--close`. */\n declare command: string;\n\n readonly #internals: ElementInternals;\n\n constructor() {\n super();\n this.variant = 'primary';\n this.size = 'md';\n this.type = 'button';\n this.disabled = false;\n this.loading = false;\n this.name = '';\n this.value = '';\n this.accessibleLabel = '';\n this.commandfor = '';\n this.command = '';\n this.#internals = this.attachInternals();\n this.addEventListener('click', this.#onClick);\n }\n\n /** The form this button belongs to, if any. */\n get form(): HTMLFormElement | null {\n return this.#internals.form;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n checkTokensLoaded(this);\n }\n\n #onClick = (event: MouseEvent): void => {\n if (this.disabled || this.loading) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n if (this.commandfor && this.command) {\n // Same shape as the native CommandEvent, so components handle both.\n const target = (this.getRootNode() as Document | ShadowRoot).getElementById(this.commandfor);\n if (target) target.dispatchEvent(Object.assign(new Event('command', { cancelable: true }), { command: this.command, source: this }));\n else devWarn('va-button', `commandfor=\"${this.commandfor}\" doesn't match any element id.`, 'Set commandfor to the id of the element to control, in the same document or shadow root.');\n return;\n }\n const form = this.#internals.form;\n if (!form) return;\n if (this.type === 'submit') {\n // requestSubmit() needs a real submit button as the submitter, so name=value is sent.\n const submitter = document.createElement('button');\n submitter.type = 'submit';\n submitter.hidden = true;\n if (this.name) {\n submitter.name = this.name;\n submitter.value = this.value;\n }\n form.append(submitter);\n form.requestSubmit(submitter);\n submitter.remove();\n } else if (this.type === 'reset') {\n form.reset();\n }\n };\n\n override firstUpdated(): void {\n // Wait a frame so children parsed after the upgrade are in place before checking the name.\n requestAnimationFrame(() => this.#checkName());\n }\n\n #checkName = (): void => {\n const text = this.textContent?.trim() ?? '';\n if (!text && !this.accessibleLabel) {\n devWarn(\n 'va-button',\n 'This button has no accessible name: it has no text and no accessible-label.',\n 'Put text inside it, or add accessible-label=\"…\" that says what it does (e.g. accessible-label=\"Close\").'\n );\n } else if (text && this.accessibleLabel && !this.accessibleLabel.toLowerCase().includes(text.toLowerCase())) {\n devWarn(\n 'va-button',\n `accessible-label=\"${this.accessibleLabel}\" replaces the visible text \"${text}\" for screen readers, so voice users can't say what they see (WCAG 2.5.3).`,\n 'Remove accessible-label, or make it start with the visible text.'\n );\n }\n };\n\n /** While loading, the name gains \", loading\"; otherwise only accessible-label overrides the text. */\n #ariaLabel(): string | undefined {\n const name = this.accessibleLabel || this.textContent?.trim() || '';\n if (this.loading) return name ? `${name}, loading` : 'Loading';\n return this.accessibleLabel || undefined;\n }\n\n override render() {\n return html`\n <button\n part=\"control\"\n class=\"control\"\n type=\"button\"\n ?disabled=${this.disabled}\n aria-disabled=${this.loading ? 'true' : nothing}\n aria-busy=${this.loading ? 'true' : nothing}\n aria-label=${this.#ariaLabel() ?? nothing}\n >\n <slot name=\"start\"></slot>\n <span part=\"label\" class=\"label\"><slot @slotchange=${this.#checkName}></slot></span>\n ${this.loading ? html`<span class=\"spinner\" aria-hidden=\"true\"></span>` : nothing}\n <slot name=\"end\"></slot>\n </button>\n `;\n }\n\n static override styles = [\n focusRing,\n css`\n :host {\n --_bg: var(--va-button-bg, var(--va-color-accent-default));\n --_bg-hover: var(--va-button-bg-hover, var(--va-color-accent-hover));\n --_fg: var(--va-button-fg, var(--va-color-text-on-accent));\n --_border: var(--va-button-border, transparent);\n --_height: var(--va-button-height, var(--va-size-control-md));\n --_padding: var(--va-button-padding-inline, var(--va-space-inline-lg));\n --_font-size: var(--va-button-font-size, var(--va-font-size-md));\n display: inline-block;\n vertical-align: middle;\n }\n :host([hidden]) {\n display: none;\n }\n :host([variant='secondary']) {\n --_bg: var(--va-button-bg, transparent);\n --_bg-hover: var(--va-button-bg-hover, var(--va-color-surface-subtle));\n --_fg: var(--va-button-fg, var(--va-color-text-default));\n --_border: var(--va-button-border, var(--va-color-border-control));\n }\n :host([variant='ghost']) {\n --_bg: var(--va-button-bg, transparent);\n --_bg-hover: var(--va-button-bg-hover, var(--va-color-surface-subtle));\n --_fg: var(--va-button-fg, var(--va-color-accent-default));\n }\n :host([variant='danger']) {\n --_bg: var(--va-button-bg, var(--va-color-danger-default));\n --_bg-hover: var(--va-button-bg-hover, var(--va-color-danger-hover));\n --_fg: var(--va-button-fg, var(--va-color-text-on-danger));\n }\n :host([size='sm']) {\n --_height: var(--va-button-height, var(--va-size-control-sm));\n --_padding: var(--va-button-padding-inline, var(--va-space-inline-md));\n --_font-size: var(--va-button-font-size, var(--va-font-size-sm));\n }\n :host([size='lg']) {\n --_height: var(--va-button-height, var(--va-size-control-lg));\n --_font-size: var(--va-button-font-size, var(--va-font-size-lg));\n }\n\n .control {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--va-space-gap-md);\n width: 100%;\n min-height: var(--_height);\n margin: 0;\n padding: 0 var(--_padding);\n border: 1px solid var(--_border);\n border-radius: var(--va-button-radius, var(--va-radius-control));\n background-color: var(--_bg);\n color: var(--_fg);\n font-family: var(--va-font-family-ui);\n font-size: var(--_font-size);\n font-weight: var(--va-font-weight-medium);\n line-height: 1.2;\n cursor: pointer;\n transition: background-color var(--va-motion-duration-fast) ease-out;\n -webkit-tap-highlight-color: transparent;\n }\n .control:hover:not(:disabled):not([aria-disabled='true']) {\n background-color: var(--_bg-hover);\n }\n .control:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n .control[aria-disabled='true'] {\n cursor: progress;\n }\n\n ::slotted(svg),\n ::slotted([slot='start']),\n ::slotted([slot='end']) {\n flex: none;\n width: 1.25em;\n height: 1.25em;\n }\n\n .spinner {\n flex: none;\n width: 1em;\n height: 1em;\n border: 2px solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n animation: spin 0.8s linear infinite;\n }\n @keyframes spin {\n to {\n transform: rotate(1turn);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .control {\n transition: none;\n }\n .spinner {\n animation-duration: 2.4s;\n }\n }\n\n @media (forced-colors: active) {\n .control {\n border-color: ButtonText;\n }\n :host(:not([variant])) .control,\n :host([variant='primary']) .control,\n :host([variant='danger']) .control {\n background-color: ButtonText;\n color: ButtonFace;\n forced-color-adjust: none;\n }\n .control:disabled {\n border-color: GrayText;\n color: GrayText;\n }\n }\n `,\n ];\n}\n\n// Union types are written inline on the properties so the manifest, and agents reading it, see the values.\nexport type ButtonVariant = VaButton['variant'];\nexport type ButtonSize = VaButton['size'];\nexport type ButtonType = VaButton['type'];\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'va-button': VaButton;\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { VaButton } from './button.js';
2
+ export { VaButton };
3
+ export type { ButtonSize, ButtonType, ButtonVariant } from './button.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { define } from '../core/define.js';
2
+ import { VaButton } from './button.js';
3
+ export { VaButton };
4
+ define('va-button', VaButton);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button/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;AAGpB,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import { define } from '../core/define.js';\nimport { VaButton } from './button.js';\n\nexport { VaButton };\nexport type { ButtonSize, ButtonType, ButtonVariant } from './button.js';\n\ndefine('va-button', VaButton);\n"]}
@@ -0,0 +1,71 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { FormControl } from '../core/form-control.js';
3
+ /**
4
+ * A checkbox for a choice that is submitted with a form.
5
+ *
6
+ * @tag va-checkbox
7
+ * @summary Lets the user choose an option, or agree to something, as part of a form.
8
+ *
9
+ * @slot - The visible label. Clicking it toggles the checkbox.
10
+ * @slot help-text - Optional help text under the label. It becomes the checkbox's description.
11
+ *
12
+ * @csspart control - The square box.
13
+ * @csspart label - The label text.
14
+ * @csspart help-text - The help text.
15
+ *
16
+ * @cssprop {<color>} --va-checkbox-border - Border colour of the box when unchecked.
17
+ * @cssprop {<color>} --va-checkbox-bg-checked - Fill and border colour when checked or indeterminate.
18
+ * @cssprop {<color>} --va-checkbox-mark-fg - Colour of the tick or dash.
19
+ * @cssprop {<length>} --va-checkbox-size - Width and height of the box.
20
+ *
21
+ * @cssprop-applies --va-checkbox-border control:unchecked border-top-color
22
+ * @cssprop-applies --va-checkbox-bg-checked control:checked background-color
23
+ * @cssprop-applies --va-checkbox-mark-fg control:checked color
24
+ * @cssprop-applies --va-checkbox-size control width
25
+ *
26
+ * @keyboard Space | toggles | Checks or unchecks the box.
27
+ * @keyboard Tab | focus-next | Moves focus to the next control.
28
+ *
29
+ * @a11y-role checkbox
30
+ * @a11y-name-from text, accessible-label
31
+ * @replaces input[type="checkbox"]
32
+ * @a11y-name The slotted label text. Use `accessible-label` only when there is no visible label.
33
+ * @a11y-note `indeterminate` is announced as "mixed", for a box that stands for a partly selected group.
34
+ * @a11y-note Style states with `va-checkbox:state(checked)` and `:state(indeterminate)`; the `checked` attribute is the initial state only, as on a native checkbox.
35
+ *
36
+ * @guidance-use For an option submitted with a form, for agreeing to terms, or to select items in a list.
37
+ * @guidance-avoid For a setting that should apply immediately.
38
+ * @guidance-instead `va-switch` for settings that take effect immediately.
39
+ *
40
+ * @fires change - When the user checks or unchecks the box. Read `event.target.checked`.
41
+ * @fires input - When the user checks or unchecks the box, just before `change`.
42
+ * @event-trigger change | click
43
+ * @event-trigger input | click
44
+ */
45
+ export declare class VaCheckbox extends FormControl {
46
+ #private;
47
+ static shadowRootOptions: ShadowRootInit;
48
+ static properties: PropertyDeclarations;
49
+ /** Whether the box is checked. The `checked` attribute sets the initial state, as on a native checkbox. */
50
+ checked: boolean;
51
+ /** Shows a dash for a partly selected group. Cleared when the user toggles the box. */
52
+ indeterminate: boolean;
53
+ /** Submitted with `name` while the box is checked. Defaults to `on`, as for a native checkbox. */
54
+ value: string;
55
+ /** Accessible name for a checkbox with no visible label, such as one selecting a table row. */
56
+ accessibleLabel: string;
57
+ constructor();
58
+ connectedCallback(): void;
59
+ firstUpdated(): void;
60
+ updated(): void;
61
+ /** @internal */
62
+ formResetCallback(): void;
63
+ render(): import("lit").TemplateResult<1>;
64
+ static styles: import("lit").CSSResult;
65
+ }
66
+ declare global {
67
+ interface HTMLElementTagNameMap {
68
+ 'va-checkbox': VaCheckbox;
69
+ }
70
+ }
71
+ //# sourceMappingURL=checkbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,oBAAoB,EAAE,MAAM,KAAK,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,UAAW,SAAQ,WAAW;;IACzC,OAAgB,iBAAiB,EAAE,cAAc,CAA8D;IAE/G,OAAgB,UAAU,EAAE,oBAAoB,CAK9C;IAEF,2GAA2G;IACnG,OAAO,EAAE,OAAO,CAAC;IACzB,uFAAuF;IAC/E,aAAa,EAAE,OAAO,CAAC;IAC/B,kGAAkG;IAC1F,KAAK,EAAE,MAAM,CAAC;IACtB,+FAA+F;IACvF,eAAe,EAAE,MAAM,CAAC;;IAYvB,iBAAiB,IAAI,IAAI;IAOzB,YAAY,IAAI,IAAI;IAoBpB,OAAO,IAAI,IAAI;IAYxB,gBAAgB;IACP,iBAAiB,IAAI,IAAI;IAiBzB,MAAM;IAkCf,OAAgB,MAAM,0BAwFpB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}