@adobe/design-system-registry 0.0.0-layout-20260209174611
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/AUTHORING.md +290 -0
- package/CHANGELOG.md +23 -0
- package/LICENSE +201 -0
- package/PLATFORM_EXTENSIONS.md +315 -0
- package/README.md +268 -0
- package/ava.config.js +21 -0
- package/index.js +189 -0
- package/moon.yml +40 -0
- package/package.json +46 -0
- package/registry/anatomy-terms.json +151 -0
- package/registry/categories.json +56 -0
- package/registry/components.json +277 -0
- package/registry/glossary.json +181 -0
- package/registry/navigation-terms.json +241 -0
- package/registry/platform-extensions/ios-states.json +59 -0
- package/registry/platform-extensions/web-components-states.json +58 -0
- package/registry/platforms.json +37 -0
- package/registry/scale-values.json +91 -0
- package/registry/sizes.json +152 -0
- package/registry/states.json +184 -0
- package/registry/token-terminology.json +925 -0
- package/registry/variants.json +176 -0
- package/schemas/platform-extension.json +79 -0
- package/schemas/registry-value.json +230 -0
- package/scripts/validate-registry.js +134 -0
- package/test/registry.test.js +280 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import test from "ava";
|
|
14
|
+
import {
|
|
15
|
+
sizes,
|
|
16
|
+
states,
|
|
17
|
+
variants,
|
|
18
|
+
anatomyTerms,
|
|
19
|
+
components,
|
|
20
|
+
scaleValues,
|
|
21
|
+
categories,
|
|
22
|
+
platforms,
|
|
23
|
+
getValues,
|
|
24
|
+
findValue,
|
|
25
|
+
hasValue,
|
|
26
|
+
getDefault,
|
|
27
|
+
getActiveValues,
|
|
28
|
+
} from "../index.js";
|
|
29
|
+
|
|
30
|
+
// Test that all registries load without errors
|
|
31
|
+
test("sizes registry loads successfully", (t) => {
|
|
32
|
+
t.truthy(sizes);
|
|
33
|
+
t.truthy(sizes.values);
|
|
34
|
+
t.true(Array.isArray(sizes.values));
|
|
35
|
+
t.true(sizes.values.length > 0);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("states registry loads successfully", (t) => {
|
|
39
|
+
t.truthy(states);
|
|
40
|
+
t.truthy(states.values);
|
|
41
|
+
t.true(Array.isArray(states.values));
|
|
42
|
+
t.true(states.values.length > 0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("variants registry loads successfully", (t) => {
|
|
46
|
+
t.truthy(variants);
|
|
47
|
+
t.truthy(variants.values);
|
|
48
|
+
t.true(Array.isArray(variants.values));
|
|
49
|
+
t.true(variants.values.length > 0);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("anatomyTerms registry loads successfully", (t) => {
|
|
53
|
+
t.truthy(anatomyTerms);
|
|
54
|
+
t.truthy(anatomyTerms.values);
|
|
55
|
+
t.true(Array.isArray(anatomyTerms.values));
|
|
56
|
+
t.true(anatomyTerms.values.length > 0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("components registry loads successfully", (t) => {
|
|
60
|
+
t.truthy(components);
|
|
61
|
+
t.truthy(components.values);
|
|
62
|
+
t.true(Array.isArray(components.values));
|
|
63
|
+
t.true(components.values.length > 0);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("scaleValues registry loads successfully", (t) => {
|
|
67
|
+
t.truthy(scaleValues);
|
|
68
|
+
t.truthy(scaleValues.values);
|
|
69
|
+
t.true(Array.isArray(scaleValues.values));
|
|
70
|
+
t.true(scaleValues.values.length > 0);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("categories registry loads successfully", (t) => {
|
|
74
|
+
t.truthy(categories);
|
|
75
|
+
t.truthy(categories.values);
|
|
76
|
+
t.true(Array.isArray(categories.values));
|
|
77
|
+
t.true(categories.values.length > 0);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("platforms registry loads successfully", (t) => {
|
|
81
|
+
t.truthy(platforms);
|
|
82
|
+
t.truthy(platforms.values);
|
|
83
|
+
t.true(Array.isArray(platforms.values));
|
|
84
|
+
t.true(platforms.values.length > 0);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Test for duplicate IDs within registries
|
|
88
|
+
test("sizes registry has no duplicate IDs", (t) => {
|
|
89
|
+
const ids = sizes.values.map((v) => v.id);
|
|
90
|
+
const uniqueIds = new Set(ids);
|
|
91
|
+
t.is(ids.length, uniqueIds.size);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("states registry has no duplicate IDs", (t) => {
|
|
95
|
+
const ids = states.values.map((v) => v.id);
|
|
96
|
+
const uniqueIds = new Set(ids);
|
|
97
|
+
t.is(ids.length, uniqueIds.size);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("variants registry has no duplicate IDs", (t) => {
|
|
101
|
+
const ids = variants.values.map((v) => v.id);
|
|
102
|
+
const uniqueIds = new Set(ids);
|
|
103
|
+
t.is(ids.length, uniqueIds.size);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("components registry has no duplicate IDs", (t) => {
|
|
107
|
+
const ids = components.values.map((v) => v.id);
|
|
108
|
+
const uniqueIds = new Set(ids);
|
|
109
|
+
t.is(ids.length, uniqueIds.size);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Test for duplicate aliases
|
|
113
|
+
test("sizes registry has no duplicate aliases", (t) => {
|
|
114
|
+
const aliases = sizes.values.flatMap((v) => v.aliases || []);
|
|
115
|
+
const uniqueAliases = new Set(aliases);
|
|
116
|
+
t.is(aliases.length, uniqueAliases.size);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("states registry has no duplicate aliases", (t) => {
|
|
120
|
+
const aliases = states.values.flatMap((v) => v.aliases || []);
|
|
121
|
+
const uniqueAliases = new Set(aliases);
|
|
122
|
+
t.is(aliases.length, uniqueAliases.size);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Test that required fields exist
|
|
126
|
+
test("all size values have id and label", (t) => {
|
|
127
|
+
sizes.values.forEach((value) => {
|
|
128
|
+
t.truthy(value.id, `Size value missing id`);
|
|
129
|
+
t.truthy(value.label, `Size value ${value.id} missing label`);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("all state values have id and label", (t) => {
|
|
134
|
+
states.values.forEach((value) => {
|
|
135
|
+
t.truthy(value.id, `State value missing id`);
|
|
136
|
+
t.truthy(value.label, `State value ${value.id} missing label`);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test("all component values have id, label, and documentationUrl", (t) => {
|
|
141
|
+
components.values.forEach((value) => {
|
|
142
|
+
t.truthy(value.id, `Component value missing id`);
|
|
143
|
+
t.truthy(value.label, `Component value ${value.id} missing label`);
|
|
144
|
+
t.truthy(
|
|
145
|
+
value.documentationUrl,
|
|
146
|
+
`Component ${value.id} missing documentationUrl`,
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Test default values
|
|
152
|
+
test("sizes registry has exactly one default value", (t) => {
|
|
153
|
+
const defaults = sizes.values.filter((v) => v.default === true);
|
|
154
|
+
t.is(defaults.length, 1);
|
|
155
|
+
t.is(defaults[0].id, "m");
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test("states registry has exactly one default value", (t) => {
|
|
159
|
+
const defaults = states.values.filter((v) => v.default === true);
|
|
160
|
+
t.is(defaults.length, 1);
|
|
161
|
+
t.is(defaults[0].id, "default");
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Test helper functions
|
|
165
|
+
test("getValues returns array of IDs", (t) => {
|
|
166
|
+
const values = getValues(sizes);
|
|
167
|
+
t.true(Array.isArray(values));
|
|
168
|
+
t.true(values.length > 0);
|
|
169
|
+
t.true(values.includes("s"));
|
|
170
|
+
t.true(values.includes("m"));
|
|
171
|
+
t.true(values.includes("l"));
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test("findValue finds value by ID", (t) => {
|
|
175
|
+
const value = findValue(sizes, "m");
|
|
176
|
+
t.truthy(value);
|
|
177
|
+
t.is(value.id, "m");
|
|
178
|
+
t.is(value.label, "Medium");
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("findValue finds value by alias", (t) => {
|
|
182
|
+
const value = findValue(sizes, "medium");
|
|
183
|
+
t.truthy(value);
|
|
184
|
+
t.is(value.id, "m");
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("findValue returns undefined for non-existent value", (t) => {
|
|
188
|
+
const value = findValue(sizes, "nonexistent");
|
|
189
|
+
t.is(value, undefined);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test("hasValue returns true for existing ID", (t) => {
|
|
193
|
+
t.true(hasValue(sizes, "m"));
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("hasValue returns true for existing alias", (t) => {
|
|
197
|
+
t.true(hasValue(sizes, "medium"));
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test("hasValue returns false for non-existent value", (t) => {
|
|
201
|
+
t.false(hasValue(sizes, "nonexistent"));
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("getDefault returns the default value", (t) => {
|
|
205
|
+
const defaultSize = getDefault(sizes);
|
|
206
|
+
t.truthy(defaultSize);
|
|
207
|
+
t.is(defaultSize.id, "m");
|
|
208
|
+
t.true(defaultSize.default);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test("getActiveValues returns only non-deprecated values", (t) => {
|
|
212
|
+
const activeValues = getActiveValues(sizes);
|
|
213
|
+
t.true(Array.isArray(activeValues));
|
|
214
|
+
activeValues.forEach((value) => {
|
|
215
|
+
t.not(value.deprecated, true);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Test specific registry content
|
|
220
|
+
test("sizes includes common t-shirt sizes", (t) => {
|
|
221
|
+
const ids = getValues(sizes);
|
|
222
|
+
t.true(ids.includes("xs"));
|
|
223
|
+
t.true(ids.includes("s"));
|
|
224
|
+
t.true(ids.includes("m"));
|
|
225
|
+
t.true(ids.includes("l"));
|
|
226
|
+
t.true(ids.includes("xl"));
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("states includes common interaction states", (t) => {
|
|
230
|
+
const ids = getValues(states);
|
|
231
|
+
t.true(ids.includes("default"));
|
|
232
|
+
t.true(ids.includes("hover"));
|
|
233
|
+
t.true(ids.includes("focus"));
|
|
234
|
+
t.true(ids.includes("disabled"));
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test("variants includes semantic variants", (t) => {
|
|
238
|
+
const ids = getValues(variants);
|
|
239
|
+
t.true(ids.includes("accent"));
|
|
240
|
+
t.true(ids.includes("negative"));
|
|
241
|
+
t.true(ids.includes("positive"));
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test("anatomyTerms includes key anatomy parts", (t) => {
|
|
245
|
+
const ids = getValues(anatomyTerms);
|
|
246
|
+
t.true(ids.includes("edge"));
|
|
247
|
+
t.true(ids.includes("visual"));
|
|
248
|
+
t.true(ids.includes("text"));
|
|
249
|
+
t.true(ids.includes("icon"));
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test("components includes core components", (t) => {
|
|
253
|
+
const ids = getValues(components);
|
|
254
|
+
t.true(ids.includes("button"));
|
|
255
|
+
t.true(ids.includes("checkbox"));
|
|
256
|
+
t.true(ids.includes("text-field"));
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test("categories includes all 8 component categories", (t) => {
|
|
260
|
+
const ids = getValues(categories);
|
|
261
|
+
t.is(ids.length, 8);
|
|
262
|
+
t.true(ids.includes("actions"));
|
|
263
|
+
t.true(ids.includes("containers"));
|
|
264
|
+
t.true(ids.includes("inputs"));
|
|
265
|
+
t.true(ids.includes("navigation"));
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test("platforms includes desktop and mobile", (t) => {
|
|
269
|
+
const ids = getValues(platforms);
|
|
270
|
+
t.true(ids.includes("desktop"));
|
|
271
|
+
t.true(ids.includes("mobile"));
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test("scaleValues includes common numeric scales", (t) => {
|
|
275
|
+
const ids = getValues(scaleValues);
|
|
276
|
+
t.true(ids.includes("50"));
|
|
277
|
+
t.true(ids.includes("100"));
|
|
278
|
+
t.true(ids.includes("200"));
|
|
279
|
+
t.true(ids.includes("300"));
|
|
280
|
+
});
|