@rak200/ui 0.1.2 → 0.2.1
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 +11 -5
- package/dist/button.d.ts +3 -3
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +11 -11
- package/dist/button.js.map +1 -1
- package/dist/field.d.ts +39 -0
- package/dist/field.d.ts.map +1 -0
- package/dist/field.js +160 -0
- package/dist/field.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/tokens.d.ts +2 -2
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +19 -17
- package/dist/tokens.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,17 +28,23 @@ npm install @rak200/ui
|
|
|
28
28
|
import '@rak200/ui';
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
<
|
|
31
|
+
<ui-field>
|
|
32
|
+
<label slot="label">Amount</label>
|
|
33
|
+
<input type="number" />
|
|
34
|
+
<span slot="help">In BRL, two decimals.</span>
|
|
35
|
+
</ui-field>
|
|
36
|
+
|
|
37
|
+
<ui-button>Save</ui-button>
|
|
38
|
+
<ui-button variant="secondary">Cancel</ui-button>
|
|
39
|
+
<ui-button disabled>Unavailable</ui-button>
|
|
34
40
|
```
|
|
35
41
|
|
|
36
42
|
Every visual decision is a CSS custom property, so a host restyles the kit without forking it:
|
|
37
43
|
|
|
38
44
|
```css
|
|
39
45
|
:root {
|
|
40
|
-
--
|
|
41
|
-
--
|
|
46
|
+
--ui-color-accent: rebeccapurple;
|
|
47
|
+
--ui-radius: 0;
|
|
42
48
|
}
|
|
43
49
|
```
|
|
44
50
|
|
package/dist/button.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ export type ButtonVariant = 'primary' | 'secondary';
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```html
|
|
15
|
-
* <
|
|
15
|
+
* <ui-button variant="primary">Save</ui-button>
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export declare class
|
|
18
|
+
export declare class UiButton extends LitElement {
|
|
19
19
|
static readonly styles: import("lit").CSSResult;
|
|
20
20
|
static readonly properties: {
|
|
21
21
|
variant: {
|
|
@@ -43,7 +43,7 @@ export declare class RakButton extends LitElement {
|
|
|
43
43
|
}
|
|
44
44
|
declare global {
|
|
45
45
|
interface HTMLElementTagNameMap {
|
|
46
|
-
'
|
|
46
|
+
'ui-button': UiButton;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
//# sourceMappingURL=button.d.ts.map
|
package/dist/button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../src/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAEjE,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,CAAC;AAEpD;;;;;;;;;;;;;GAaG;AACH,qBAAa,
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../src/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAEjE,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,CAAC;AAEpD;;;;;;;;;;;;;GAaG;AACH,qBAAa,QAAS,SAAQ,UAAU;IACpC,gBAAyB,MAAM,0BAoC7B;IAEF,gBAAyB,UAAU;;;;;;;;;MAGjC;IAEF;;;;;;;;OAQG;IACH,OAAO,EAAE,aAAa,CAAa;IAEnC,kFAAkF;IAClF,QAAQ,UAAS;IAER,MAAM,IAAI,cAAc;CAOpC;AAQD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,WAAW,EAAE,QAAQ,CAAC;KACzB;CACJ"}
|
package/dist/button.js
CHANGED
|
@@ -10,10 +10,10 @@ import { LitElement, css, html } from 'lit';
|
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```html
|
|
13
|
-
* <
|
|
13
|
+
* <ui-button variant="primary">Save</ui-button>
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export class
|
|
16
|
+
export class UiButton extends LitElement {
|
|
17
17
|
constructor() {
|
|
18
18
|
super(...arguments);
|
|
19
19
|
/**
|
|
@@ -36,10 +36,10 @@ export class RakButton extends LitElement {
|
|
|
36
36
|
|
|
37
37
|
button {
|
|
38
38
|
font: inherit;
|
|
39
|
-
font-family: var(--
|
|
39
|
+
font-family: var(--ui-font, system-ui, sans-serif);
|
|
40
40
|
border: 1px solid transparent;
|
|
41
|
-
border-radius: var(--
|
|
42
|
-
padding: var(--
|
|
41
|
+
border-radius: var(--ui-radius, 0.375rem);
|
|
42
|
+
padding: var(--ui-space, 0.5rem) calc(var(--ui-space, 0.5rem) * 2);
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -51,18 +51,18 @@ export class RakButton extends LitElement {
|
|
|
51
51
|
/* A visible focus ring is not decoration: removing it is the single most common
|
|
52
52
|
way a component stops being usable by keyboard. */
|
|
53
53
|
button:focus-visible {
|
|
54
|
-
outline: 2px solid var(--
|
|
54
|
+
outline: 2px solid var(--ui-color-focus, #f59e0b);
|
|
55
55
|
outline-offset: 2px;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
button.primary {
|
|
59
|
-
background: var(--
|
|
60
|
-
color: var(--
|
|
59
|
+
background: var(--ui-color-accent, #2563eb);
|
|
60
|
+
color: var(--ui-color-accent-contrast, #ffffff);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
button.secondary {
|
|
64
|
-
background: var(--
|
|
65
|
-
color: var(--
|
|
64
|
+
background: var(--ui-color-surface, #ffffff);
|
|
65
|
+
color: var(--ui-color-text, #1f2937);
|
|
66
66
|
border-color: currentcolor;
|
|
67
67
|
}
|
|
68
68
|
`; }
|
|
@@ -82,5 +82,5 @@ export class RakButton extends LitElement {
|
|
|
82
82
|
// inside the warm process Stryker switches mutants in — so by the time a mutant on this
|
|
83
83
|
// line is active the element is already defined under the original name, and no test can
|
|
84
84
|
// observe the change. Outside the runner's reach, not an equivalent mutant.
|
|
85
|
-
customElements.define('
|
|
85
|
+
customElements.define('ui-button', UiButton);
|
|
86
86
|
//# sourceMappingURL=button.js.map
|
package/dist/button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../src/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAKjE;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../src/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAKjE;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAAxC;;QA4CI;;;;;;;;WAQG;QACH,YAAO,GAAkB,SAAS,CAAC;QAEnC,kFAAkF;QAClF,aAAQ,GAAG,KAAK,CAAC;IASrB,CAAC;aAhE4B,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoCpC,AApC8B,CAoC7B;aAEuB,eAAU,GAAG;QAClC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;QACxC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;KAC7C,AAHkC,CAGjC;IAgBO,MAAM;QACX,OAAO,IAAI,CAAA;4BACS,IAAI,CAAC,OAAO,cAAc,IAAI,CAAC,QAAQ;;;SAG1D,CAAC;IACN,CAAC;;AAGL,kFAAkF;AAClF,wFAAwF;AACxF,yFAAyF;AACzF,4EAA4E;AAC5E,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC"}
|
package/dist/field.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LitElement, type TemplateResult } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Form plumbing: a label bound to a control, help and error text bound through
|
|
4
|
+
* `aria-describedby`, and `aria-invalid` while the field is in error.
|
|
5
|
+
*
|
|
6
|
+
* Written once here rather than per control. Every form component in the v0 cut needs the
|
|
7
|
+
* same wiring, and five copies of it are five chances to get one subtly wrong.
|
|
8
|
+
*
|
|
9
|
+
* **Everything is slotted, and that is forced rather than chosen.** An ARIA relationship
|
|
10
|
+
* by IDREF does not cross a shadow boundary: a `<label for>` rendered in this element's
|
|
11
|
+
* shadow root leaves `control.labels` empty, and an `aria-describedby` pointing into it
|
|
12
|
+
* dangles. So the label, the control, the help and the error all live in the host's tree,
|
|
13
|
+
* where the association is the platform's job — and this element only generates the ids
|
|
14
|
+
* and points them at each other.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```html
|
|
18
|
+
* <ui-field>
|
|
19
|
+
* <label slot="label">Amount</label>
|
|
20
|
+
* <input type="number" />
|
|
21
|
+
* <span slot="help">In BRL, two decimals.</span>
|
|
22
|
+
* <span slot="error">Amount is required.</span>
|
|
23
|
+
* </ui-field>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class UiField extends LitElement {
|
|
27
|
+
#private;
|
|
28
|
+
static readonly styles: import("lit").CSSResult;
|
|
29
|
+
connectedCallback(): void;
|
|
30
|
+
disconnectedCallback(): void;
|
|
31
|
+
firstUpdated(): void;
|
|
32
|
+
render(): TemplateResult;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'ui-field': UiField;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAKjE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,OAAQ,SAAQ,UAAU;;IACnC,gBAAyB,MAAM,0BAuB7B;IAeO,iBAAiB,IAAI,IAAI;IASzB,oBAAoB,IAAI,IAAI;IAK5B,YAAY,IAAI,IAAI;IAIpB,MAAM,IAAI,cAAc;CAyFpC;AAQD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,UAAU,EAAE,OAAO,CAAC;KACvB;CACJ"}
|
package/dist/field.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { LitElement, css, html } from 'lit';
|
|
2
|
+
/** Distinguishes one field's generated ids from another's. */
|
|
3
|
+
let sequence = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Form plumbing: a label bound to a control, help and error text bound through
|
|
6
|
+
* `aria-describedby`, and `aria-invalid` while the field is in error.
|
|
7
|
+
*
|
|
8
|
+
* Written once here rather than per control. Every form component in the v0 cut needs the
|
|
9
|
+
* same wiring, and five copies of it are five chances to get one subtly wrong.
|
|
10
|
+
*
|
|
11
|
+
* **Everything is slotted, and that is forced rather than chosen.** An ARIA relationship
|
|
12
|
+
* by IDREF does not cross a shadow boundary: a `<label for>` rendered in this element's
|
|
13
|
+
* shadow root leaves `control.labels` empty, and an `aria-describedby` pointing into it
|
|
14
|
+
* dangles. So the label, the control, the help and the error all live in the host's tree,
|
|
15
|
+
* where the association is the platform's job — and this element only generates the ids
|
|
16
|
+
* and points them at each other.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```html
|
|
20
|
+
* <ui-field>
|
|
21
|
+
* <label slot="label">Amount</label>
|
|
22
|
+
* <input type="number" />
|
|
23
|
+
* <span slot="help">In BRL, two decimals.</span>
|
|
24
|
+
* <span slot="error">Amount is required.</span>
|
|
25
|
+
* </ui-field>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export class UiField extends LitElement {
|
|
29
|
+
static { this.styles = css `
|
|
30
|
+
:host {
|
|
31
|
+
display: block;
|
|
32
|
+
font-family: var(--ui-font, system-ui, sans-serif);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.stack {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: calc(var(--ui-space, 0.5rem) / 2);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
slot[name='help']::slotted(*) {
|
|
42
|
+
color: var(--ui-color-text, #1f2937);
|
|
43
|
+
font-size: 0.875em;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Colour is not the only cue — the error text says what is wrong, and
|
|
47
|
+
aria-invalid marks the control regardless of styling. */
|
|
48
|
+
slot[name='error']::slotted(*) {
|
|
49
|
+
color: var(--ui-color-danger, #b91c1c);
|
|
50
|
+
font-size: 0.875em;
|
|
51
|
+
}
|
|
52
|
+
`; }
|
|
53
|
+
/** The prefix for this instance's generated ids, allocated on first association. */
|
|
54
|
+
#uid;
|
|
55
|
+
/**
|
|
56
|
+
* Watches the light DOM for anything that changes the association.
|
|
57
|
+
*
|
|
58
|
+
* Built here rather than on connection so it is never absent: a disconnect that has to
|
|
59
|
+
* ask whether the observer exists is a branch no test can reach.
|
|
60
|
+
*/
|
|
61
|
+
#observer = new MutationObserver(() => {
|
|
62
|
+
this.#associate();
|
|
63
|
+
});
|
|
64
|
+
connectedCallback() {
|
|
65
|
+
super.connectedCallback();
|
|
66
|
+
// The host may swap the error text without adding or removing an element, which is
|
|
67
|
+
// what a re-render looks like from here — so characterData matters as much as
|
|
68
|
+
// childList, and both can happen below a wrapper.
|
|
69
|
+
this.#observer.observe(this, { childList: true, characterData: true, subtree: true });
|
|
70
|
+
}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
this.#observer.disconnect();
|
|
73
|
+
super.disconnectedCallback();
|
|
74
|
+
}
|
|
75
|
+
firstUpdated() {
|
|
76
|
+
this.#associate();
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
return html `
|
|
80
|
+
<div class="stack" part="stack">
|
|
81
|
+
<slot name="label"></slot>
|
|
82
|
+
<slot></slot>
|
|
83
|
+
<slot name="help"></slot>
|
|
84
|
+
<slot name="error"></slot>
|
|
85
|
+
</div>
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
/** The light-DOM child filling a slot, or `undefined` when nothing does. */
|
|
89
|
+
#slotted(name) {
|
|
90
|
+
const selector = name === null ? ':scope > :not([slot])' : `:scope > [slot='${name}']`;
|
|
91
|
+
const found = this.querySelector(selector);
|
|
92
|
+
return found instanceof HTMLElement ? found : undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Points the label, the help and the error at the control.
|
|
96
|
+
*
|
|
97
|
+
* A host-supplied `id` is never overwritten — it may already be referenced by something
|
|
98
|
+
* this element cannot see.
|
|
99
|
+
*/
|
|
100
|
+
#associate() {
|
|
101
|
+
const control = this.#slotted(null);
|
|
102
|
+
if (control === undefined) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// Stryker disable next-line UpdateOperator: the contract is that two fields on one
|
|
106
|
+
// page get different ids, and a decrementing counter delivers that as well as an
|
|
107
|
+
// incrementing one — `ui-field--1` is as valid an id as `ui-field-1`. No input
|
|
108
|
+
// distinguishes the two, so this is an equivalent mutant rather than a weak test.
|
|
109
|
+
const uid = (this.#uid ??= `ui-field-${String(++sequence)}`);
|
|
110
|
+
if (control.id === '') {
|
|
111
|
+
control.id = `${uid}-control`;
|
|
112
|
+
}
|
|
113
|
+
const label = this.#slotted('label');
|
|
114
|
+
if (label instanceof HTMLLabelElement) {
|
|
115
|
+
label.htmlFor = control.id;
|
|
116
|
+
}
|
|
117
|
+
const help = this.#describer(this.#slotted('help'), `${uid}-help`);
|
|
118
|
+
const error = this.#describer(this.#slotted('error'), `${uid}-error`);
|
|
119
|
+
// The error comes first: a screen reader announces descriptions in order, and the
|
|
120
|
+
// user needs to know what is wrong before reading how the value should look.
|
|
121
|
+
//
|
|
122
|
+
// The error SUPPLEMENTS the help rather than replacing it. Help text is usually the
|
|
123
|
+
// format requirement, which is exactly the error suggestion the user needs in order
|
|
124
|
+
// to recover (WCAG 3.3.3) — dropping it at the moment it becomes useful is the
|
|
125
|
+
// opposite of helping.
|
|
126
|
+
const described = [error, help].filter((id) => id !== undefined);
|
|
127
|
+
if (described.length > 0) {
|
|
128
|
+
control.setAttribute('aria-describedby', described.join(' '));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
control.removeAttribute('aria-describedby');
|
|
132
|
+
}
|
|
133
|
+
if (error === undefined) {
|
|
134
|
+
control.removeAttribute('aria-invalid');
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
control.setAttribute('aria-invalid', 'true');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The id to describe the control by, or `undefined` when the element is absent or has
|
|
142
|
+
* nothing to say. An element rendered empty — the shape a framework produces for
|
|
143
|
+
* "no error yet" — must not mark the control invalid.
|
|
144
|
+
*/
|
|
145
|
+
#describer(element, fallbackId) {
|
|
146
|
+
if (element === undefined || element.textContent.trim() === '') {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
if (element.id === '') {
|
|
150
|
+
element.id = fallbackId;
|
|
151
|
+
}
|
|
152
|
+
return element.id;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Stryker disable next-line StringLiteral: the registration runs once, at import, inside
|
|
156
|
+
// the warm process Stryker switches mutants in — so by the time a mutant on this line is
|
|
157
|
+
// active the element is already defined under the original name, and no test can observe
|
|
158
|
+
// the change. Outside the runner's reach, not an equivalent mutant.
|
|
159
|
+
customElements.define('ui-field', UiField);
|
|
160
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../src/field.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { UiButton, type ButtonVariant } from './button.js';
|
|
2
|
+
export { UiField } from './field.js';
|
|
2
3
|
export { tokens, defaults, tokenStyleSheet, type Token } from './tokens.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAc,MAAM,aAAa,CAAC"}
|
package/dist/tokens.d.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* native shell (RFC 0016, M4) can read the same values without the components. A token
|
|
7
7
|
* added later is a token some target already hardcoded.
|
|
8
8
|
*
|
|
9
|
-
* Every token is a CSS custom property under `--
|
|
9
|
+
* Every token is a CSS custom property under `--ui-`, so a host overrides one by
|
|
10
10
|
* setting it anywhere above the component — no build step, no theme object, no fork.
|
|
11
11
|
*/
|
|
12
12
|
/** The token names this package defines, as they appear in CSS. */
|
|
13
|
-
export declare const tokens: readonly ["--
|
|
13
|
+
export declare const tokens: readonly ["--ui-color-accent", "--ui-color-accent-contrast", "--ui-color-surface", "--ui-color-text", "--ui-color-focus", "--ui-color-danger", "--ui-radius", "--ui-space", "--ui-font"];
|
|
14
14
|
/** A CSS custom property this package defines. */
|
|
15
15
|
export type Token = (typeof tokens)[number];
|
|
16
16
|
/**
|
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mEAAmE;AACnE,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mEAAmE;AACnE,eAAO,MAAM,MAAM,0LAUT,CAAC;AAEX,kDAAkD;AAClD,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAUpD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAIxC"}
|
package/dist/tokens.js
CHANGED
|
@@ -6,19 +6,20 @@
|
|
|
6
6
|
* native shell (RFC 0016, M4) can read the same values without the components. A token
|
|
7
7
|
* added later is a token some target already hardcoded.
|
|
8
8
|
*
|
|
9
|
-
* Every token is a CSS custom property under `--
|
|
9
|
+
* Every token is a CSS custom property under `--ui-`, so a host overrides one by
|
|
10
10
|
* setting it anywhere above the component — no build step, no theme object, no fork.
|
|
11
11
|
*/
|
|
12
12
|
/** The token names this package defines, as they appear in CSS. */
|
|
13
13
|
export const tokens = [
|
|
14
|
-
'--
|
|
15
|
-
'--
|
|
16
|
-
'--
|
|
17
|
-
'--
|
|
18
|
-
'--
|
|
19
|
-
'--
|
|
20
|
-
'--
|
|
21
|
-
'--
|
|
14
|
+
'--ui-color-accent',
|
|
15
|
+
'--ui-color-accent-contrast',
|
|
16
|
+
'--ui-color-surface',
|
|
17
|
+
'--ui-color-text',
|
|
18
|
+
'--ui-color-focus',
|
|
19
|
+
'--ui-color-danger',
|
|
20
|
+
'--ui-radius',
|
|
21
|
+
'--ui-space',
|
|
22
|
+
'--ui-font',
|
|
22
23
|
];
|
|
23
24
|
/**
|
|
24
25
|
* The default value of every token, applied at `:root` by {@link tokenStyleSheet}.
|
|
@@ -27,14 +28,15 @@ export const tokens = [
|
|
|
27
28
|
* system's defaults are what a host sees before it has decided anything.
|
|
28
29
|
*/
|
|
29
30
|
export const defaults = {
|
|
30
|
-
'--
|
|
31
|
-
'--
|
|
32
|
-
'--
|
|
33
|
-
'--
|
|
34
|
-
'--
|
|
35
|
-
'--
|
|
36
|
-
'--
|
|
37
|
-
'--
|
|
31
|
+
'--ui-color-accent': '#2563eb',
|
|
32
|
+
'--ui-color-accent-contrast': '#ffffff',
|
|
33
|
+
'--ui-color-surface': '#ffffff',
|
|
34
|
+
'--ui-color-text': '#1f2937',
|
|
35
|
+
'--ui-color-focus': '#f59e0b',
|
|
36
|
+
'--ui-color-danger': '#b91c1c',
|
|
37
|
+
'--ui-radius': '0.375rem',
|
|
38
|
+
'--ui-space': '0.5rem',
|
|
39
|
+
'--ui-font': 'system-ui, sans-serif',
|
|
38
40
|
};
|
|
39
41
|
/**
|
|
40
42
|
* The token defaults as a CSS rule, for a host that wants them without importing a
|
package/dist/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mEAAmE;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,oBAAoB;IACpB,
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mEAAmE;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,mBAAmB;IACnB,4BAA4B;IAC5B,oBAAoB;IACpB,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,aAAa;IACb,YAAY;IACZ,WAAW;CACL,CAAC;AAKX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAoC;IACrD,mBAAmB,EAAE,SAAS;IAC9B,4BAA4B,EAAE,SAAS;IACvC,oBAAoB,EAAE,SAAS;IAC/B,iBAAiB,EAAE,SAAS;IAC5B,kBAAkB,EAAE,SAAS;IAC7B,mBAAmB,EAAE,SAAS;IAC9B,aAAa,EAAE,UAAU;IACzB,YAAY,EAAE,QAAQ;IACtB,WAAW,EAAE,uBAAuB;CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjF,OAAO,YAAY,IAAI,KAAK,CAAC;AACjC,CAAC"}
|