@nonoun/nui-tokens 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-tokens.d.ts +2 -0
- package/dist/build-tokens.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/nui-tokens-color-swatch-element.d.ts +15 -0
- package/dist/nui-tokens-color-swatch-element.d.ts.map +1 -0
- package/dist/nui-tokens-colors-element.d.ts +14 -0
- package/dist/nui-tokens-colors-element.d.ts.map +1 -0
- package/dist/nui-tokens-element.d.ts +15 -0
- package/dist/nui-tokens-element.d.ts.map +1 -0
- package/dist/nui-tokens-themes-element.d.ts +13 -0
- package/dist/nui-tokens-themes-element.d.ts.map +1 -0
- package/dist/nui-tokens-variable-element.d.ts +19 -0
- package/dist/nui-tokens-variable-element.d.ts.map +1 -0
- package/dist/nui-tokens.css +231 -0
- package/dist/nui-tokens.js +607 -0
- package/package.json +32 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-tokens.d.ts","sourceRoot":"","sources":["../src/build-tokens.ts"],"names":[],"mappings":"AA0EA,wBAAgB,WAAW,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAgIxD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NuiTokensVariable } from './nui-tokens-variable-element.ts';
|
|
2
|
+
import { NuiTokensColors } from './nui-tokens-colors-element.ts';
|
|
3
|
+
import { NuiTokensColorSwatch } from './nui-tokens-color-swatch-element.ts';
|
|
4
|
+
import { NuiTokensThemes } from './nui-tokens-themes-element.ts';
|
|
5
|
+
import { NuiTokens } from './nui-tokens-element.ts';
|
|
6
|
+
import { buildTokens } from './build-tokens.ts';
|
|
7
|
+
export { NuiTokens, NuiTokensVariable, NuiTokensColors, NuiTokensColorSwatch, NuiTokensThemes, buildTokens, };
|
|
8
|
+
export type { NuiTokensVariableData } from './nui-tokens-variable-element.ts';
|
|
9
|
+
export type { NuiTokensColorEntry } from './nui-tokens-colors-element.ts';
|
|
10
|
+
export type { NuiTokensThemeEntry } from './nui-tokens-themes-element.ts';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsBhD,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,CAAC;AACF,YAAY,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UIElement } from '@nonoun/native-ui';
|
|
2
|
+
export declare class NuiTokensColorSwatch extends UIElement {
|
|
3
|
+
#private;
|
|
4
|
+
static observedAttributes: string[];
|
|
5
|
+
get token(): string;
|
|
6
|
+
set token(val: string);
|
|
7
|
+
get name(): string;
|
|
8
|
+
set name(val: string);
|
|
9
|
+
attributeChangedCallback(name: string, old: string | null, val: string | null): void;
|
|
10
|
+
setup(): void;
|
|
11
|
+
teardown(): void;
|
|
12
|
+
/** Refresh background and contrast from current token value. */
|
|
13
|
+
refresh(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=nui-tokens-color-swatch-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nui-tokens-color-swatch-element.d.ts","sourceRoot":"","sources":["../src/nui-tokens-color-swatch-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAO,MAAM,mBAAmB,CAAC;AA8InD,qBAAa,oBAAqB,SAAQ,SAAS;;IACjD,MAAM,CAAC,kBAAkB,WAAqB;IAM9C,IAAI,KAAK,IAAI,MAAM,CAA6C;IAChE,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM,EAAsC;IAE3D,IAAI,IAAI,IAAI,MAAM,CAA4C;IAC9D,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,EAAqC;IAEzD,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAapF,KAAK,IAAI,IAAI;IAqCb,QAAQ,IAAI,IAAI;IAUhB,gEAAgE;IAChE,OAAO,IAAI,IAAI;CAsEhB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UIElement } from '@nonoun/native-ui';
|
|
2
|
+
export interface NuiTokensColorEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
token: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class NuiTokensColors extends UIElement {
|
|
7
|
+
#private;
|
|
8
|
+
static observedAttributes: string[];
|
|
9
|
+
attributeChangedCallback(name: string, old: string | null, val: string | null): void;
|
|
10
|
+
setup(): void;
|
|
11
|
+
teardown(): void;
|
|
12
|
+
refresh(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=nui-tokens-colors-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nui-tokens-colors-element.d.ts","sourceRoot":"","sources":["../src/nui-tokens-colors-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,eAAgB,SAAQ,SAAS;;IAC5C,MAAM,CAAC,kBAAkB,WAAY;IAIrC,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQpF,KAAK,IAAI,IAAI;IAab,QAAQ,IAAI,IAAI;IAWhB,OAAO,IAAI,IAAI;CAuBhB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UIElement } from '@nonoun/native-ui';
|
|
2
|
+
/**
|
|
3
|
+
* Self-contained design system token inspector.
|
|
4
|
+
*
|
|
5
|
+
* Stamps the full color/variable inspector UI on connection.
|
|
6
|
+
* Consumer usage: `<nui-tokens></nui-tokens>`.
|
|
7
|
+
*
|
|
8
|
+
* All `nui-tokens-*` sub-elements are registered by the `@nonoun/nui-tokens`
|
|
9
|
+
* entry point as a side effect of import.
|
|
10
|
+
*/
|
|
11
|
+
export declare class NuiTokens extends UIElement {
|
|
12
|
+
setup(): void;
|
|
13
|
+
teardown(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=nui-tokens-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nui-tokens-element.d.ts","sourceRoot":"","sources":["../src/nui-tokens-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C;;;;;;;;GAQG;AACH,qBAAa,SAAU,SAAQ,SAAS;IACtC,KAAK,IAAI,IAAI;IAKb,QAAQ,IAAI,IAAI;CAIjB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UIElement } from '@nonoun/native-ui';
|
|
2
|
+
export interface NuiTokensThemeEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class NuiTokensThemes extends UIElement {
|
|
7
|
+
#private;
|
|
8
|
+
static observedAttributes: string[];
|
|
9
|
+
attributeChangedCallback(name: string, old: string | null, val: string | null): void;
|
|
10
|
+
setup(): void;
|
|
11
|
+
teardown(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=nui-tokens-themes-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nui-tokens-themes-element.d.ts","sourceRoot":"","sources":["../src/nui-tokens-themes-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAeD,qBAAa,eAAgB,SAAQ,SAAS;;IAC5C,MAAM,CAAC,kBAAkB,WAAY;IAIrC,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQpF,KAAK,IAAI,IAAI;IASb,QAAQ,IAAI,IAAI;CA8CjB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UIElement } from '@nonoun/native-ui';
|
|
2
|
+
export interface NuiTokensVariableData {
|
|
3
|
+
name: string;
|
|
4
|
+
type: 'number';
|
|
5
|
+
token: string;
|
|
6
|
+
value: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class NuiTokensVariable extends UIElement {
|
|
12
|
+
#private;
|
|
13
|
+
static observedAttributes: string[];
|
|
14
|
+
attributeChangedCallback(name: string, old: string | null, val: string | null): void;
|
|
15
|
+
setup(): void;
|
|
16
|
+
teardown(): void;
|
|
17
|
+
sync(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=nui-tokens-variable-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nui-tokens-variable-element.d.ts","sourceRoot":"","sources":["../src/nui-tokens-variable-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,iBAAkB,SAAQ,SAAS;;IAC9C,MAAM,CAAC,kBAAkB,WAAY;IAMrC,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQpF,KAAK,IAAI,IAAI;IAWb,QAAQ,IAAI,IAAI;IAYhB,IAAI,IAAI,IAAI;CA8Db"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/* ──────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
nui-tokens — Design system token inspector styles.
|
|
3
|
+
Opt-in via: @import '@nonoun/nui-tokens/css';
|
|
4
|
+
────────────────────────────────────────────────────────────────────────────── */
|
|
5
|
+
|
|
6
|
+
@layer ui {
|
|
7
|
+
|
|
8
|
+
/* ── Toolbar ── */
|
|
9
|
+
|
|
10
|
+
.nui-tokens-toolbar {
|
|
11
|
+
position: sticky;
|
|
12
|
+
top: 0;
|
|
13
|
+
z-index: 1;
|
|
14
|
+
display: flex;
|
|
15
|
+
gap: 0.5rem;
|
|
16
|
+
padding-block: 0.5rem;
|
|
17
|
+
margin-block-end: 0.5rem;
|
|
18
|
+
background: var(--_ground, var(--_panel));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.nui-tokens-toolbar > * {
|
|
22
|
+
flex: 1;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* ── Section Structure ── */
|
|
27
|
+
|
|
28
|
+
.nui-tokens-section {
|
|
29
|
+
margin-block-end: 1rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.nui-tokens-section[hidden] {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.nui-tokens-section + .nui-tokens-section:not([hidden]) {
|
|
37
|
+
padding-block-start: 0.5rem;
|
|
38
|
+
border-block-start: 1px solid var(--neutral-border-muted);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.nui-tokens-heading {
|
|
42
|
+
font-size: 0.6875rem;
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
text-transform: uppercase;
|
|
45
|
+
letter-spacing: 0.05em;
|
|
46
|
+
color: var(--neutral-ink-muted);
|
|
47
|
+
margin: 0 0 0.5rem;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.nui-tokens-subheading {
|
|
51
|
+
font-size: 0.625rem;
|
|
52
|
+
font-weight: 500;
|
|
53
|
+
color: var(--neutral-ink-placeholder);
|
|
54
|
+
margin: 0.5rem 0 0.25rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* ── nui-tokens-variable ── */
|
|
58
|
+
|
|
59
|
+
:where(nui-tokens-variable) {
|
|
60
|
+
display: block;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.nui-tokens-variable-row {
|
|
64
|
+
display: grid;
|
|
65
|
+
grid-template-columns: auto 1fr auto;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: 0.5rem;
|
|
68
|
+
padding-block: 0.125rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.nui-tokens-variable-label {
|
|
72
|
+
font-size: 0.6875rem;
|
|
73
|
+
color: var(--neutral-ink);
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
text-overflow: ellipsis;
|
|
77
|
+
min-width: 3rem;
|
|
78
|
+
max-width: 5rem;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.nui-tokens-variable-value {
|
|
82
|
+
font-size: 0.625rem;
|
|
83
|
+
font-family: ui-monospace, monospace;
|
|
84
|
+
color: var(--neutral-ink-muted);
|
|
85
|
+
text-align: right;
|
|
86
|
+
white-space: nowrap;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
text-overflow: ellipsis;
|
|
89
|
+
min-width: 3rem;
|
|
90
|
+
max-width: 5rem;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* ── nui-tokens-colors ── */
|
|
94
|
+
|
|
95
|
+
:where(nui-tokens-colors) {
|
|
96
|
+
display: block;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.nui-tokens-colors-strip {
|
|
100
|
+
display: flex;
|
|
101
|
+
gap: 2px;
|
|
102
|
+
border-radius: 0.375rem;
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* ── nui-tokens-color-swatch ── */
|
|
107
|
+
|
|
108
|
+
:where(nui-tokens-color-swatch) {
|
|
109
|
+
flex: 1;
|
|
110
|
+
aspect-ratio: 1;
|
|
111
|
+
min-width: 0;
|
|
112
|
+
position: relative;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: flex-end;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.nui-tokens-swatch-label {
|
|
120
|
+
font-size: 0.5rem;
|
|
121
|
+
line-height: 1;
|
|
122
|
+
text-align: center;
|
|
123
|
+
padding: 2px 1px;
|
|
124
|
+
white-space: nowrap;
|
|
125
|
+
overflow: hidden;
|
|
126
|
+
text-overflow: ellipsis;
|
|
127
|
+
max-width: 100%;
|
|
128
|
+
pointer-events: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* ── Swatch Popover ── */
|
|
132
|
+
|
|
133
|
+
.nui-tokens-swatch-popover {
|
|
134
|
+
position: fixed;
|
|
135
|
+
position-area: block-end;
|
|
136
|
+
position-try-fallbacks: flip-block;
|
|
137
|
+
margin: 0.25rem 0 0;
|
|
138
|
+
|
|
139
|
+
min-width: 12rem;
|
|
140
|
+
padding: 0.375rem;
|
|
141
|
+
|
|
142
|
+
font-size: 0.6875rem;
|
|
143
|
+
color: var(--neutral-ink);
|
|
144
|
+
background: var(--neutral-modal);
|
|
145
|
+
border: 1px solid var(--neutral-border-muted);
|
|
146
|
+
border-radius: 0.375rem;
|
|
147
|
+
box-shadow: var(--ui-shadow-md);
|
|
148
|
+
|
|
149
|
+
/* Override UA popover styles */
|
|
150
|
+
inset: unset;
|
|
151
|
+
overflow: visible;
|
|
152
|
+
|
|
153
|
+
opacity: 0;
|
|
154
|
+
transform: scale(0.96);
|
|
155
|
+
transition:
|
|
156
|
+
opacity 150ms ease,
|
|
157
|
+
transform 150ms ease,
|
|
158
|
+
display 150ms ease allow-discrete,
|
|
159
|
+
overlay 150ms ease allow-discrete;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.nui-tokens-swatch-popover:popover-open {
|
|
163
|
+
opacity: 1;
|
|
164
|
+
transform: scale(1);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@starting-style {
|
|
168
|
+
.nui-tokens-swatch-popover:popover-open {
|
|
169
|
+
opacity: 0;
|
|
170
|
+
transform: scale(0.96);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.nui-tokens-swatch-popover[popover]:not(:popover-open) {
|
|
175
|
+
display: none;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.nui-tokens-swatch-popover-header {
|
|
179
|
+
font-size: 0.5625rem;
|
|
180
|
+
font-family: ui-monospace, monospace;
|
|
181
|
+
color: var(--neutral-ink-muted);
|
|
182
|
+
padding: 0.125rem 0.25rem 0.375rem;
|
|
183
|
+
border-bottom: 1px solid var(--neutral-border-muted);
|
|
184
|
+
margin-bottom: 0.25rem;
|
|
185
|
+
white-space: nowrap;
|
|
186
|
+
overflow: hidden;
|
|
187
|
+
text-overflow: ellipsis;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.nui-tokens-swatch-popover-row {
|
|
191
|
+
display: flex;
|
|
192
|
+
align-items: center;
|
|
193
|
+
gap: 0.5rem;
|
|
194
|
+
width: 100%;
|
|
195
|
+
padding: 0.25rem;
|
|
196
|
+
border: none;
|
|
197
|
+
border-radius: 0.25rem;
|
|
198
|
+
background: transparent;
|
|
199
|
+
color: inherit;
|
|
200
|
+
font: inherit;
|
|
201
|
+
cursor: pointer;
|
|
202
|
+
text-align: left;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.nui-tokens-swatch-popover-row:hover {
|
|
206
|
+
background: var(--neutral-control);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.nui-tokens-swatch-popover-label {
|
|
210
|
+
font-size: 0.5625rem;
|
|
211
|
+
font-weight: 600;
|
|
212
|
+
color: var(--neutral-ink-muted);
|
|
213
|
+
min-width: 2.5rem;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.nui-tokens-swatch-popover-value {
|
|
217
|
+
font-size: 0.5625rem;
|
|
218
|
+
font-family: ui-monospace, monospace;
|
|
219
|
+
color: var(--neutral-ink);
|
|
220
|
+
white-space: nowrap;
|
|
221
|
+
overflow: hidden;
|
|
222
|
+
text-overflow: ellipsis;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* ── nui-tokens-themes ── */
|
|
226
|
+
|
|
227
|
+
:where(nui-tokens-themes) {
|
|
228
|
+
display: contents;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
} /* @layer ui */
|
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
import { UIButton as e, UIElement as t, UIIcon as n, UIListbox as r, UIOption as i, UIRange as a, UISelect as o, define as s, uid as c } from "@nonoun/native-ui";
|
|
2
|
+
var l = class extends t {
|
|
3
|
+
static observedAttributes = ["data"];
|
|
4
|
+
#e = null;
|
|
5
|
+
#t = null;
|
|
6
|
+
#n = null;
|
|
7
|
+
attributeChangedCallback(e, t, n) {
|
|
8
|
+
if (t !== n && e === "data" && n) {
|
|
9
|
+
try {
|
|
10
|
+
this.#e = JSON.parse(n);
|
|
11
|
+
} catch {}
|
|
12
|
+
this.#t && this.#a();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
setup() {
|
|
16
|
+
super.setup();
|
|
17
|
+
let e = this.getAttribute("data");
|
|
18
|
+
if (e) try {
|
|
19
|
+
this.#e = JSON.parse(e);
|
|
20
|
+
} catch {}
|
|
21
|
+
this.#a(), this.addEventListener("nui-tokens-theme-change", this.#r);
|
|
22
|
+
}
|
|
23
|
+
teardown() {
|
|
24
|
+
this.removeEventListener("nui-tokens-theme-change", this.#r), this.innerHTML = "", this.#t = null, this.#n = null, super.teardown();
|
|
25
|
+
}
|
|
26
|
+
#r = () => {
|
|
27
|
+
requestAnimationFrame(() => this.#i());
|
|
28
|
+
};
|
|
29
|
+
sync() {
|
|
30
|
+
this.#i();
|
|
31
|
+
}
|
|
32
|
+
#i() {
|
|
33
|
+
if (!this.#e || !this.#t || !this.#n) return;
|
|
34
|
+
let e = getComputedStyle(document.documentElement).getPropertyValue(this.#e.token).trim();
|
|
35
|
+
if (e) {
|
|
36
|
+
this.#t.value = parseFloat(e);
|
|
37
|
+
let t = this.#e.step ?? .01;
|
|
38
|
+
this.#n.textContent = parseFloat(e).toFixed(t < .01 ? 3 : 2);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
#a() {
|
|
42
|
+
if (!this.#e) return;
|
|
43
|
+
let e = this.#e;
|
|
44
|
+
this.innerHTML = "";
|
|
45
|
+
let t = document.createElement("div");
|
|
46
|
+
t.className = "nui-tokens-variable-row";
|
|
47
|
+
let n = document.createElement("label");
|
|
48
|
+
n.className = "nui-tokens-variable-label", n.textContent = e.name;
|
|
49
|
+
let r = document.createElement("ui-range");
|
|
50
|
+
r.setAttribute("min", String(e.min ?? 0)), r.setAttribute("max", String(e.max ?? 1)), r.setAttribute("step", String(e.step ?? .01)), r.setAttribute("size", "xs");
|
|
51
|
+
let i = getComputedStyle(document.documentElement).getPropertyValue(e.token).trim(), a = i ? parseFloat(i) : e.value;
|
|
52
|
+
r.setAttribute("value", String(a));
|
|
53
|
+
let o = e.step ?? .01, s = document.createElement("span");
|
|
54
|
+
s.className = "nui-tokens-variable-value", s.textContent = a.toFixed(o < .01 ? 3 : 2), r.addEventListener("ui-input", ((t) => {
|
|
55
|
+
let n = t.detail.value;
|
|
56
|
+
document.documentElement.style.setProperty(e.token, String(n)), s.textContent = n.toFixed(o < .01 ? 3 : 2), this.dispatchEvent(new CustomEvent("nui-tokens-change", {
|
|
57
|
+
bubbles: !0,
|
|
58
|
+
detail: {
|
|
59
|
+
token: e.token,
|
|
60
|
+
value: n
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
})), this.#t = r, this.#n = s, t.append(n, r, s), this.appendChild(t);
|
|
64
|
+
}
|
|
65
|
+
}, u = class extends t {
|
|
66
|
+
static observedAttributes = ["data"];
|
|
67
|
+
#e = [];
|
|
68
|
+
attributeChangedCallback(e, t, n) {
|
|
69
|
+
if (t !== n && e === "data" && n) {
|
|
70
|
+
try {
|
|
71
|
+
this.#e = JSON.parse(n);
|
|
72
|
+
} catch {}
|
|
73
|
+
this.isConnected && this.#n();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
setup() {
|
|
77
|
+
super.setup();
|
|
78
|
+
let e = this.getAttribute("data");
|
|
79
|
+
if (e) try {
|
|
80
|
+
this.#e = JSON.parse(e);
|
|
81
|
+
} catch {}
|
|
82
|
+
this.#n(), this.addEventListener("nui-tokens-change", this.#t), this.addEventListener("nui-tokens-theme-change", this.#t);
|
|
83
|
+
}
|
|
84
|
+
teardown() {
|
|
85
|
+
this.removeEventListener("nui-tokens-change", this.#t), this.removeEventListener("nui-tokens-theme-change", this.#t), this.innerHTML = "", super.teardown();
|
|
86
|
+
}
|
|
87
|
+
#t = () => {
|
|
88
|
+
requestAnimationFrame(() => this.#r());
|
|
89
|
+
};
|
|
90
|
+
refresh() {
|
|
91
|
+
this.#r();
|
|
92
|
+
}
|
|
93
|
+
#n() {
|
|
94
|
+
this.innerHTML = "";
|
|
95
|
+
let e = document.createElement("div");
|
|
96
|
+
e.className = "nui-tokens-colors-strip";
|
|
97
|
+
for (let t of this.#e) {
|
|
98
|
+
let n = document.createElement("nui-tokens-color-swatch");
|
|
99
|
+
n.setAttribute("token", t.token), n.setAttribute("name", t.name), e.appendChild(n);
|
|
100
|
+
}
|
|
101
|
+
this.appendChild(e);
|
|
102
|
+
}
|
|
103
|
+
#r() {
|
|
104
|
+
this.querySelectorAll("nui-tokens-color-swatch").forEach((e) => e.refresh());
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/** Parse a computed `rgb(...)` / `rgba(...)` string into [r, g, b, a] (0–255, 0–1). */
|
|
108
|
+
function d(e) {
|
|
109
|
+
let t = e.match(/[\d.]+/g);
|
|
110
|
+
return !t || t.length < 3 ? [
|
|
111
|
+
0,
|
|
112
|
+
0,
|
|
113
|
+
0,
|
|
114
|
+
1
|
|
115
|
+
] : [
|
|
116
|
+
Number(t[0]),
|
|
117
|
+
Number(t[1]),
|
|
118
|
+
Number(t[2]),
|
|
119
|
+
t[3] === void 0 ? 1 : Number(t[3])
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
/** Relative luminance (ITU-R BT.709). Returns true if light. */
|
|
123
|
+
function f(e, t, n) {
|
|
124
|
+
let r = [
|
|
125
|
+
e,
|
|
126
|
+
t,
|
|
127
|
+
n
|
|
128
|
+
].map((e) => (e /= 255, e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4));
|
|
129
|
+
return .2126 * r[0] + .7152 * r[1] + .0722 * r[2] > .4;
|
|
130
|
+
}
|
|
131
|
+
/** Convert 0–255 component to 2-digit hex. */
|
|
132
|
+
function p(e) {
|
|
133
|
+
return Math.round(e).toString(16).padStart(2, "0");
|
|
134
|
+
}
|
|
135
|
+
/** sRGB → linear. */
|
|
136
|
+
function m(e) {
|
|
137
|
+
return e /= 255, e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
138
|
+
}
|
|
139
|
+
/** sRGB (0–255) → OKLCH via OKLab. Returns [L (0–1), C, H (degrees)]. */
|
|
140
|
+
function h(e, t, n) {
|
|
141
|
+
let r = m(e), i = m(t), a = m(n), o = .4122214708 * r + .5363325363 * i + .0514459929 * a, s = .2119034982 * r + .6806995451 * i + .1073969566 * a, c = .0883024619 * r + .2817188376 * i + .6299787005 * a, l = Math.cbrt(o), u = Math.cbrt(s), d = Math.cbrt(c), f = .2104542553 * l + .793617785 * u - .0040720468 * d, p = 1.9779984951 * l - 2.428592205 * u + .4505937099 * d, h = .0259040371 * l + .7827717662 * u - .808675766 * d, g = Math.sqrt(p * p + h * h), _ = Math.atan2(h, p) * (180 / Math.PI);
|
|
142
|
+
return _ < 0 && (_ += 360), [
|
|
143
|
+
f,
|
|
144
|
+
g,
|
|
145
|
+
_
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
/** sRGB (0–255) → HSL. Returns [H (0–360), S (0–100), L (0–100)]. */
|
|
149
|
+
function g(e, t, n) {
|
|
150
|
+
e /= 255, t /= 255, n /= 255;
|
|
151
|
+
let r = Math.max(e, t, n), i = Math.min(e, t, n), a = r - i, o = (r + i) / 2;
|
|
152
|
+
if (a === 0) return [
|
|
153
|
+
0,
|
|
154
|
+
0,
|
|
155
|
+
o * 100
|
|
156
|
+
];
|
|
157
|
+
let s = a / (1 - Math.abs(2 * o - 1)), c = 0;
|
|
158
|
+
return c = r === e ? ((t - n) / a + 6) % 6 : r === t ? (n - e) / a + 2 : (e - t) / a + 4, [
|
|
159
|
+
c * 60,
|
|
160
|
+
s * 100,
|
|
161
|
+
o * 100
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
/** sRGB (0–255) → HSB/HSV. Returns [H (0–360), S (0–100), B (0–100)]. */
|
|
165
|
+
function _(e, t, n) {
|
|
166
|
+
e /= 255, t /= 255, n /= 255;
|
|
167
|
+
let r = Math.max(e, t, n), i = r - Math.min(e, t, n), a = r * 100;
|
|
168
|
+
if (r === 0) return [
|
|
169
|
+
0,
|
|
170
|
+
0,
|
|
171
|
+
a
|
|
172
|
+
];
|
|
173
|
+
let o = i / r * 100, s = 0;
|
|
174
|
+
return i !== 0 && (s = r === e ? ((t - n) / i + 6) % 6 : r === t ? (n - e) / i + 2 : (e - t) / i + 4, s *= 60), [
|
|
175
|
+
s,
|
|
176
|
+
o,
|
|
177
|
+
a
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
function v(e, t, n, r) {
|
|
181
|
+
let [i, a, o] = h(e, t, n), s = `oklch(${(i * 100).toFixed(1)}% ${a.toFixed(4)} ${o.toFixed(1)})`;
|
|
182
|
+
return r < 1 ? `oklch(${(i * 100).toFixed(1)}% ${a.toFixed(4)} ${o.toFixed(1)} / ${r.toFixed(2)})` : s;
|
|
183
|
+
}
|
|
184
|
+
function y(e, t, n, r) {
|
|
185
|
+
let i = `#${p(e)}${p(t)}${p(n)}`;
|
|
186
|
+
return r < 1 ? `${i}${p(Math.round(r * 255))}` : i;
|
|
187
|
+
}
|
|
188
|
+
function b(e, t, n, r) {
|
|
189
|
+
return r < 1 ? `rgba(${Math.round(e)}, ${Math.round(t)}, ${Math.round(n)}, ${r.toFixed(2)})` : `rgb(${Math.round(e)}, ${Math.round(t)}, ${Math.round(n)})`;
|
|
190
|
+
}
|
|
191
|
+
function x(e, t, n, r) {
|
|
192
|
+
let [i, a, o] = g(e, t, n);
|
|
193
|
+
return r < 1 ? `hsla(${i.toFixed(0)}, ${a.toFixed(1)}%, ${o.toFixed(1)}%, ${r.toFixed(2)})` : `hsl(${i.toFixed(0)}, ${a.toFixed(1)}%, ${o.toFixed(1)}%)`;
|
|
194
|
+
}
|
|
195
|
+
function S(e, t, n, r) {
|
|
196
|
+
let [i, a, o] = _(e, t, n);
|
|
197
|
+
return `hsb(${i.toFixed(0)}, ${a.toFixed(1)}%, ${o.toFixed(1)}%)`;
|
|
198
|
+
}
|
|
199
|
+
var C = [
|
|
200
|
+
{
|
|
201
|
+
label: "OKLCH",
|
|
202
|
+
fn: v
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
label: "HEX",
|
|
206
|
+
fn: y
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
label: "RGB",
|
|
210
|
+
fn: b
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
label: "HSL",
|
|
214
|
+
fn: x
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
label: "HSB",
|
|
218
|
+
fn: S
|
|
219
|
+
}
|
|
220
|
+
], w = class extends t {
|
|
221
|
+
static observedAttributes = ["token", "name"];
|
|
222
|
+
#e = null;
|
|
223
|
+
#t = null;
|
|
224
|
+
#n = "";
|
|
225
|
+
get token() {
|
|
226
|
+
return this.getAttribute("token") ?? "";
|
|
227
|
+
}
|
|
228
|
+
set token(e) {
|
|
229
|
+
this.setAttribute("token", e);
|
|
230
|
+
}
|
|
231
|
+
get name() {
|
|
232
|
+
return this.getAttribute("name") ?? "";
|
|
233
|
+
}
|
|
234
|
+
set name(e) {
|
|
235
|
+
this.setAttribute("name", e);
|
|
236
|
+
}
|
|
237
|
+
attributeChangedCallback(e, t, n) {
|
|
238
|
+
t !== n && (e === "token" && this.isConnected && (this.style.background = n ? `var(${n})` : "", this.title = `${this.name}\n${n}`, requestAnimationFrame(() => this.#a())), e === "name" && this.#t && (this.#t.textContent = n ?? "", this.title = `${n}\n${this.token}`));
|
|
239
|
+
}
|
|
240
|
+
setup() {
|
|
241
|
+
super.setup(), this.token && (this.style.background = `var(${this.token})`, this.title = `${this.name}\n${this.token}`);
|
|
242
|
+
let e = document.createElement("span");
|
|
243
|
+
e.className = "nui-tokens-swatch-label", e.textContent = this.name, this.#t = e, this.appendChild(e), this.#n = c("swatch"), this.style.setProperty("anchor-name", `--${this.#n}`);
|
|
244
|
+
let t = document.createElement("div");
|
|
245
|
+
t.className = "nui-tokens-swatch-popover", t.setAttribute("popover", "auto"), t.style.setProperty("position-anchor", `--${this.#n}`), this.#e = t, this.appendChild(t), this.addEventListener("click", this.#i), this.addEventListener("nui-tokens-change", this.#r), this.addEventListener("nui-tokens-theme-change", this.#r), requestAnimationFrame(() => this.#a());
|
|
246
|
+
}
|
|
247
|
+
teardown() {
|
|
248
|
+
this.removeEventListener("click", this.#i), this.removeEventListener("nui-tokens-change", this.#r), this.removeEventListener("nui-tokens-theme-change", this.#r), this.#e = null, this.#t = null, this.innerHTML = "", super.teardown();
|
|
249
|
+
}
|
|
250
|
+
/** Refresh background and contrast from current token value. */
|
|
251
|
+
refresh() {
|
|
252
|
+
this.token && (this.style.background = `var(${this.token})`), this.#a();
|
|
253
|
+
}
|
|
254
|
+
#r = () => {
|
|
255
|
+
requestAnimationFrame(() => this.refresh());
|
|
256
|
+
};
|
|
257
|
+
#i = (e) => {
|
|
258
|
+
if (!(this.#e && e.target.closest(".nui-tokens-swatch-popover")) && this.#e) {
|
|
259
|
+
this.#o();
|
|
260
|
+
try {
|
|
261
|
+
this.#e.showPopover();
|
|
262
|
+
} catch {}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
#a() {
|
|
266
|
+
let e = getComputedStyle(this).backgroundColor, [t, n, r] = d(e);
|
|
267
|
+
this.#t && (this.#t.style.color = f(t, n, r) ? "rgba(0,0,0,0.55)" : "rgba(255,255,255,0.7)");
|
|
268
|
+
}
|
|
269
|
+
#o() {
|
|
270
|
+
if (!this.#e) return;
|
|
271
|
+
this.#e.innerHTML = "";
|
|
272
|
+
let e = getComputedStyle(this).backgroundColor, [t, n, r, i] = d(e), a = document.createElement("div");
|
|
273
|
+
a.className = "nui-tokens-swatch-popover-header", a.textContent = this.token, this.#e.appendChild(a);
|
|
274
|
+
for (let e of C) {
|
|
275
|
+
let a = e.fn(t, n, r, i), o = document.createElement("button");
|
|
276
|
+
o.className = "nui-tokens-swatch-popover-row", o.type = "button";
|
|
277
|
+
let s = document.createElement("span");
|
|
278
|
+
s.className = "nui-tokens-swatch-popover-label", s.textContent = e.label;
|
|
279
|
+
let c = document.createElement("span");
|
|
280
|
+
c.className = "nui-tokens-swatch-popover-value", c.textContent = a, o.append(s, c), o.addEventListener("click", (e) => {
|
|
281
|
+
e.stopPropagation(), navigator.clipboard.writeText(a).then(() => {
|
|
282
|
+
c.textContent = "Copied!", setTimeout(() => {
|
|
283
|
+
c.textContent = a;
|
|
284
|
+
}, 1200);
|
|
285
|
+
});
|
|
286
|
+
}), this.#e.appendChild(o);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, T = /* @__PURE__ */ "color-env-lightness-min.color-env-lightness-max.color-env-lightness-delta.color-env-chroma.color-env-chroma-k-muted.color-env-chroma-k-vivid.color-env-chroma-k-edge.color-env-alpha.color-env-alpha-delta.color-env-hue-neutral.color-env-chroma-neutral.color-env-lightness-neutral.color-env-hue-accent.color-env-chroma-accent.color-env-lightness-accent.color-env-hue-info.color-env-chroma-info.color-env-lightness-info.color-env-hue-success.color-env-chroma-success.color-env-lightness-success.color-env-hue-warning.color-env-chroma-warning.color-env-lightness-warning.color-env-hue-danger.color-env-chroma-danger.color-env-lightness-danger".split("."), E = class extends t {
|
|
290
|
+
static observedAttributes = ["data"];
|
|
291
|
+
#e = [];
|
|
292
|
+
attributeChangedCallback(e, t, n) {
|
|
293
|
+
if (t !== n && e === "data" && n) {
|
|
294
|
+
try {
|
|
295
|
+
this.#e = JSON.parse(n);
|
|
296
|
+
} catch {}
|
|
297
|
+
this.isConnected && this.#t();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
setup() {
|
|
301
|
+
super.setup();
|
|
302
|
+
let e = this.getAttribute("data");
|
|
303
|
+
if (e) try {
|
|
304
|
+
this.#e = JSON.parse(e);
|
|
305
|
+
} catch {}
|
|
306
|
+
this.#t();
|
|
307
|
+
}
|
|
308
|
+
teardown() {
|
|
309
|
+
this.innerHTML = "", super.teardown();
|
|
310
|
+
}
|
|
311
|
+
#t() {
|
|
312
|
+
this.innerHTML = "";
|
|
313
|
+
let e = document.documentElement.getAttribute("theme") ?? "", t = document.createElement("ui-select");
|
|
314
|
+
t.setAttribute("size", "xs"), t.setAttribute("placeholder", "Theme..."), t.setAttribute("options", JSON.stringify(this.#e.map((e) => ({
|
|
315
|
+
value: e.value,
|
|
316
|
+
label: e.name
|
|
317
|
+
})))), t.setAttribute("value", e), t.addEventListener("ui-change", ((e) => {
|
|
318
|
+
this.#n(e.detail.value);
|
|
319
|
+
})), this.appendChild(t);
|
|
320
|
+
}
|
|
321
|
+
#n(e) {
|
|
322
|
+
let t = document.documentElement;
|
|
323
|
+
for (let e of T) t.style.removeProperty("--" + e);
|
|
324
|
+
e ? t.setAttribute("theme", e) : t.removeAttribute("theme"), this.dispatchEvent(new CustomEvent("nui-tokens-theme-change", {
|
|
325
|
+
bubbles: !0,
|
|
326
|
+
detail: { theme: e }
|
|
327
|
+
}));
|
|
328
|
+
}
|
|
329
|
+
}, D = [
|
|
330
|
+
{
|
|
331
|
+
name: "Default",
|
|
332
|
+
value: ""
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "Forest",
|
|
336
|
+
value: "forest"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: "Rose",
|
|
340
|
+
value: "rose"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "Zinc",
|
|
344
|
+
value: "zinc"
|
|
345
|
+
}
|
|
346
|
+
], O = [
|
|
347
|
+
{
|
|
348
|
+
name: "L min",
|
|
349
|
+
token: "--color-env-lightness-min",
|
|
350
|
+
value: .15,
|
|
351
|
+
step: .01,
|
|
352
|
+
min: 0,
|
|
353
|
+
max: 1,
|
|
354
|
+
group: "Lightness"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: "L max",
|
|
358
|
+
token: "--color-env-lightness-max",
|
|
359
|
+
value: 1,
|
|
360
|
+
step: .01,
|
|
361
|
+
min: 0,
|
|
362
|
+
max: 1,
|
|
363
|
+
group: "Lightness"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
name: "L delta",
|
|
367
|
+
token: "--color-env-lightness-delta",
|
|
368
|
+
value: .015,
|
|
369
|
+
step: .005,
|
|
370
|
+
min: 0,
|
|
371
|
+
max: .15,
|
|
372
|
+
group: "Lightness"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "Chroma",
|
|
376
|
+
token: "--color-env-chroma",
|
|
377
|
+
value: .2,
|
|
378
|
+
step: .005,
|
|
379
|
+
min: 0,
|
|
380
|
+
max: .5,
|
|
381
|
+
group: "Chroma"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "C muted",
|
|
385
|
+
token: "--color-env-chroma-k-muted",
|
|
386
|
+
value: .125,
|
|
387
|
+
step: .01,
|
|
388
|
+
min: 0,
|
|
389
|
+
max: 1,
|
|
390
|
+
group: "Chroma"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: "C vivid",
|
|
394
|
+
token: "--color-env-chroma-k-vivid",
|
|
395
|
+
value: 1,
|
|
396
|
+
step: .01,
|
|
397
|
+
min: 0,
|
|
398
|
+
max: 1,
|
|
399
|
+
group: "Chroma"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
name: "C edge",
|
|
403
|
+
token: "--color-env-chroma-k-edge",
|
|
404
|
+
value: .05,
|
|
405
|
+
step: .01,
|
|
406
|
+
min: 0,
|
|
407
|
+
max: 1,
|
|
408
|
+
group: "Chroma"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: "Alpha",
|
|
412
|
+
token: "--color-env-alpha",
|
|
413
|
+
value: .85,
|
|
414
|
+
step: .01,
|
|
415
|
+
min: 0,
|
|
416
|
+
max: 1,
|
|
417
|
+
group: "Alpha"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
name: "A delta",
|
|
421
|
+
token: "--color-env-alpha-delta",
|
|
422
|
+
value: .02,
|
|
423
|
+
step: .005,
|
|
424
|
+
min: 0,
|
|
425
|
+
max: .15,
|
|
426
|
+
group: "Alpha"
|
|
427
|
+
}
|
|
428
|
+
], k = [
|
|
429
|
+
"neutral",
|
|
430
|
+
"accent",
|
|
431
|
+
"info",
|
|
432
|
+
"success",
|
|
433
|
+
"warning",
|
|
434
|
+
"danger"
|
|
435
|
+
], A = [
|
|
436
|
+
"lowest",
|
|
437
|
+
"lower",
|
|
438
|
+
"low",
|
|
439
|
+
"base",
|
|
440
|
+
"high",
|
|
441
|
+
"higher",
|
|
442
|
+
"highest"
|
|
443
|
+
], j = [
|
|
444
|
+
"brightest",
|
|
445
|
+
"brighter",
|
|
446
|
+
"bright",
|
|
447
|
+
"base",
|
|
448
|
+
"dim",
|
|
449
|
+
"dimmer",
|
|
450
|
+
"dimmest"
|
|
451
|
+
], M = [
|
|
452
|
+
"1",
|
|
453
|
+
"2",
|
|
454
|
+
"3",
|
|
455
|
+
"4",
|
|
456
|
+
"5",
|
|
457
|
+
"6",
|
|
458
|
+
"7",
|
|
459
|
+
"8",
|
|
460
|
+
"9",
|
|
461
|
+
"10",
|
|
462
|
+
"11"
|
|
463
|
+
], N = [
|
|
464
|
+
"050",
|
|
465
|
+
"100",
|
|
466
|
+
"200",
|
|
467
|
+
"300",
|
|
468
|
+
"400",
|
|
469
|
+
"500",
|
|
470
|
+
"600",
|
|
471
|
+
"700",
|
|
472
|
+
"800",
|
|
473
|
+
"900",
|
|
474
|
+
"950"
|
|
475
|
+
], P = [
|
|
476
|
+
"strongest",
|
|
477
|
+
"stronger",
|
|
478
|
+
"strong",
|
|
479
|
+
"base",
|
|
480
|
+
"weak",
|
|
481
|
+
"weaker",
|
|
482
|
+
"weakest"
|
|
483
|
+
];
|
|
484
|
+
function F(e, t) {
|
|
485
|
+
let n = document.createElement("div");
|
|
486
|
+
n.className = "nui-tokens-section", t && (n.dataset.family = t);
|
|
487
|
+
let r = document.createElement("h3");
|
|
488
|
+
return r.className = "nui-tokens-heading", r.textContent = e, n.appendChild(r), n;
|
|
489
|
+
}
|
|
490
|
+
function I(e) {
|
|
491
|
+
let t = document.createElement("h4");
|
|
492
|
+
return t.className = "nui-tokens-subheading", t.textContent = e, t;
|
|
493
|
+
}
|
|
494
|
+
function L(e) {
|
|
495
|
+
let t = document.createElement("nui-tokens-colors");
|
|
496
|
+
return t.setAttribute("data", JSON.stringify(e)), t;
|
|
497
|
+
}
|
|
498
|
+
function R(e) {
|
|
499
|
+
let t = document.createElement("nui-tokens-variable");
|
|
500
|
+
return t.setAttribute("data", JSON.stringify({
|
|
501
|
+
name: e.name,
|
|
502
|
+
type: "number",
|
|
503
|
+
token: e.token,
|
|
504
|
+
value: e.value,
|
|
505
|
+
step: e.step,
|
|
506
|
+
min: e.min,
|
|
507
|
+
max: e.max
|
|
508
|
+
})), t;
|
|
509
|
+
}
|
|
510
|
+
function z(e) {
|
|
511
|
+
let t = document.createElement("div");
|
|
512
|
+
t.className = "nui-tokens-toolbar";
|
|
513
|
+
let n = document.createElement("nui-tokens-themes");
|
|
514
|
+
n.setAttribute("data", JSON.stringify(D)), t.appendChild(n);
|
|
515
|
+
let r = [{
|
|
516
|
+
value: "all",
|
|
517
|
+
label: "All Families"
|
|
518
|
+
}, ...k.map((e) => ({
|
|
519
|
+
value: e,
|
|
520
|
+
label: e.charAt(0).toUpperCase() + e.slice(1)
|
|
521
|
+
}))], i = document.createElement("ui-select");
|
|
522
|
+
i.setAttribute("size", "xs"), i.setAttribute("placeholder", "Family..."), i.setAttribute("options", JSON.stringify(r)), i.setAttribute("value", "all"), t.appendChild(i), e.appendChild(t);
|
|
523
|
+
let a = "", o = null;
|
|
524
|
+
for (let t of O) t.group !== a && (a = t.group, o = F(t.group, "env"), e.appendChild(o)), o.appendChild(R(t));
|
|
525
|
+
for (let t of k) {
|
|
526
|
+
let n = F(t.charAt(0).toUpperCase() + t.slice(1), t);
|
|
527
|
+
n.appendChild(R({
|
|
528
|
+
name: "Hue",
|
|
529
|
+
token: `--color-env-hue-${t}`,
|
|
530
|
+
value: 230,
|
|
531
|
+
step: 1,
|
|
532
|
+
min: 0,
|
|
533
|
+
max: 360
|
|
534
|
+
})), n.appendChild(R({
|
|
535
|
+
name: "Chroma",
|
|
536
|
+
token: `--color-env-chroma-${t}`,
|
|
537
|
+
value: .5,
|
|
538
|
+
step: .01,
|
|
539
|
+
min: 0,
|
|
540
|
+
max: 1
|
|
541
|
+
})), n.appendChild(R({
|
|
542
|
+
name: "Lightness",
|
|
543
|
+
token: `--color-env-lightness-${t}`,
|
|
544
|
+
value: .5,
|
|
545
|
+
step: .01,
|
|
546
|
+
min: 0,
|
|
547
|
+
max: 1
|
|
548
|
+
})), n.appendChild(I("Elevation")), n.appendChild(L(A.map((e) => ({
|
|
549
|
+
name: e,
|
|
550
|
+
token: `--${t}-${e}`
|
|
551
|
+
})))), n.appendChild(I("Brightness")), n.appendChild(L(j.map((e) => ({
|
|
552
|
+
name: e,
|
|
553
|
+
token: `--${t}-${e}`
|
|
554
|
+
})))), n.appendChild(I("Solid")), n.appendChild(L(M.map((e) => ({
|
|
555
|
+
name: e,
|
|
556
|
+
token: `--${t}-${e}`
|
|
557
|
+
})))), n.appendChild(I("Scrim")), n.appendChild(L(M.map((e) => ({
|
|
558
|
+
name: e,
|
|
559
|
+
token: `--${t}-${e}-scrim`
|
|
560
|
+
})))), n.appendChild(I("Semantic")), n.appendChild(L(N.map((e) => ({
|
|
561
|
+
name: e,
|
|
562
|
+
token: `--${t}-${e}`
|
|
563
|
+
})))), n.appendChild(I("Semantic Scrim")), n.appendChild(L(N.map((e) => ({
|
|
564
|
+
name: e,
|
|
565
|
+
token: `--${t}-${e}-scrim`
|
|
566
|
+
})))), n.appendChild(I("Tint")), n.appendChild(L(P.map((e) => ({
|
|
567
|
+
name: e,
|
|
568
|
+
token: `--${t}-scrim-tint-${e}`
|
|
569
|
+
})))), n.appendChild(I("Shade")), n.appendChild(L(P.map((e) => ({
|
|
570
|
+
name: e,
|
|
571
|
+
token: `--${t}-scrim-shade-${e}`
|
|
572
|
+
})))), e.appendChild(n);
|
|
573
|
+
}
|
|
574
|
+
i.addEventListener("ui-change", ((t) => {
|
|
575
|
+
let n = t.detail.value, r = e.querySelectorAll(".nui-tokens-section[data-family]");
|
|
576
|
+
for (let e of r) {
|
|
577
|
+
let t = e.dataset.family;
|
|
578
|
+
n === "all" || t === "env" ? e.hidden = !1 : e.hidden = t !== n;
|
|
579
|
+
}
|
|
580
|
+
requestAnimationFrame(() => {
|
|
581
|
+
e.querySelectorAll("nui-tokens-colors").forEach((e) => e.refresh());
|
|
582
|
+
});
|
|
583
|
+
})), e.addEventListener("nui-tokens-theme-change", () => {
|
|
584
|
+
requestAnimationFrame(() => {
|
|
585
|
+
e.querySelectorAll("nui-tokens-variable").forEach((e) => e.sync());
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Self-contained design system token inspector.
|
|
591
|
+
*
|
|
592
|
+
* Stamps the full color/variable inspector UI on connection.
|
|
593
|
+
* Consumer usage: `<nui-tokens></nui-tokens>`.
|
|
594
|
+
*
|
|
595
|
+
* All `nui-tokens-*` sub-elements are registered by the `@nonoun/nui-tokens`
|
|
596
|
+
* entry point as a side effect of import.
|
|
597
|
+
*/
|
|
598
|
+
var B = class extends t {
|
|
599
|
+
setup() {
|
|
600
|
+
super.setup(), z(this);
|
|
601
|
+
}
|
|
602
|
+
teardown() {
|
|
603
|
+
this.innerHTML = "", super.teardown();
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
s("nui-tokens", B), s("nui-tokens-variable", l), s("nui-tokens-colors", u), s("nui-tokens-color-swatch", w), s("nui-tokens-themes", E), s("ui-range", a), s("ui-select", o), s("ui-button", e), s("ui-icon", n), s("ui-listbox", r), s("ui-option", i);
|
|
607
|
+
export { B as NuiTokens, w as NuiTokensColorSwatch, u as NuiTokensColors, E as NuiTokensThemes, l as NuiTokensVariable, z as buildTokens };
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nonoun/nui-tokens",
|
|
3
|
+
"version": "0.2.10",
|
|
4
|
+
"description": "OKLCH color token inspector for @nonoun/native-ui",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/nui-tokens.js",
|
|
8
|
+
"module": "./dist/nui-tokens.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/nui-tokens.js"
|
|
14
|
+
},
|
|
15
|
+
"./css": "./dist/nui-tokens.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"./dist/nui-tokens.js"
|
|
22
|
+
],
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@nonoun/native-ui": ">=0.2.10"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "npm run build:js && npm run build:css && npm run build:types",
|
|
28
|
+
"build:js": "vite build",
|
|
29
|
+
"build:css": "cp src/nui-tokens.css dist/nui-tokens.css",
|
|
30
|
+
"build:types": "tsc -p tsconfig.build.json"
|
|
31
|
+
}
|
|
32
|
+
}
|