@adobe/design-system-registry 3.3.0 → 5.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 (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/index.js +39 -139
  3. package/moon.yml +2 -29
  4. package/package.json +5 -34
  5. package/AUTHORING.md +0 -290
  6. package/PLATFORM_EXTENSIONS.md +0 -315
  7. package/ava.config.js +0 -21
  8. package/registry/alignments.json +0 -22
  9. package/registry/anatomy-terms.json +0 -739
  10. package/registry/categories.json +0 -55
  11. package/registry/color-families.json +0 -177
  12. package/registry/components.json +0 -277
  13. package/registry/densities.json +0 -17
  14. package/registry/easing-curves.json +0 -42
  15. package/registry/glossary.json +0 -181
  16. package/registry/motion-roles.json +0 -32
  17. package/registry/navigation-terms.json +0 -241
  18. package/registry/orientations.json +0 -17
  19. package/registry/platform-extensions/ios-states.json +0 -59
  20. package/registry/platform-extensions/web-components-states.json +0 -58
  21. package/registry/platforms.json +0 -37
  22. package/registry/positions.json +0 -32
  23. package/registry/property-terms.json +0 -212
  24. package/registry/scale-values.json +0 -126
  25. package/registry/shapes.json +0 -12
  26. package/registry/sizes.json +0 -71
  27. package/registry/states.json +0 -184
  28. package/registry/structures.json +0 -57
  29. package/registry/substructures.json +0 -12
  30. package/registry/token-objects.json +0 -32
  31. package/registry/token-terminology.json +0 -925
  32. package/registry/typography-families.json +0 -27
  33. package/registry/typography-styles.json +0 -22
  34. package/registry/typography-weights.json +0 -37
  35. package/registry/variants.json +0 -282
  36. package/schemas/platform-extension.json +0 -79
  37. package/schemas/registry-value.json +0 -230
  38. package/scripts/validate-registry.js +0 -134
  39. package/test/registry.test.js +0 -417
@@ -1,134 +0,0 @@
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 { readFileSync, readdirSync } from "node:fs";
14
- import { join, dirname } from "node:path";
15
- import { fileURLToPath } from "node:url";
16
- import Ajv from "ajv";
17
- import addFormats from "ajv-formats";
18
-
19
- const __filename = fileURLToPath(import.meta.url);
20
- const __dirname = dirname(__filename);
21
- const registryDir = join(__dirname, "..", "registry");
22
- const schemaPath = join(__dirname, "..", "schemas", "registry-value.json");
23
-
24
- const ajv = new Ajv({ strict: false, allErrors: true });
25
- addFormats(ajv);
26
-
27
- const schema = JSON.parse(readFileSync(schemaPath, "utf-8"));
28
- const validate = ajv.compile(schema);
29
-
30
- let hasErrors = false;
31
-
32
- console.log("🔍 Validating design system registry...\n");
33
-
34
- // Get all registry files
35
- const registryFiles = readdirSync(registryDir).filter((f) =>
36
- f.endsWith(".json"),
37
- );
38
-
39
- for (const file of registryFiles) {
40
- const filePath = join(registryDir, file);
41
- const registry = JSON.parse(readFileSync(filePath, "utf-8"));
42
-
43
- console.log(`📄 Validating ${file}...`);
44
-
45
- // Validate against JSON schema
46
- const valid = validate(registry);
47
- if (!valid) {
48
- console.error(` ❌ Schema validation failed:`);
49
- validate.errors.forEach((err) => {
50
- console.error(` ${err.instancePath}: ${err.message}`);
51
- });
52
- hasErrors = true;
53
- continue;
54
- }
55
-
56
- // Check for duplicate IDs
57
- const ids = new Set();
58
- const duplicateIds = [];
59
- for (const value of registry.values) {
60
- if (ids.has(value.id)) {
61
- duplicateIds.push(value.id);
62
- }
63
- ids.add(value.id);
64
- }
65
-
66
- if (duplicateIds.length > 0) {
67
- console.error(` ❌ Duplicate IDs found: ${duplicateIds.join(", ")}`);
68
- hasErrors = true;
69
- }
70
-
71
- // Check for duplicate aliases
72
- const aliases = new Map();
73
- for (const value of registry.values) {
74
- if (value.aliases) {
75
- for (const alias of value.aliases) {
76
- if (aliases.has(alias)) {
77
- console.error(
78
- ` ❌ Duplicate alias "${alias}" found in ${value.id} (already used by ${aliases.get(alias)})`,
79
- );
80
- hasErrors = true;
81
- }
82
- aliases.set(alias, value.id);
83
- }
84
- }
85
- }
86
-
87
- // Check that only one value has default: true
88
- const defaults = registry.values.filter((v) => v.default === true);
89
- if (defaults.length > 1) {
90
- console.error(
91
- ` ❌ Multiple default values found: ${defaults.map((d) => d.id).join(", ")}`,
92
- );
93
- hasErrors = true;
94
- }
95
-
96
- // Check that relatedTerms reference valid IDs
97
- for (const value of registry.values) {
98
- if (value.relatedTerms) {
99
- for (const relatedId of value.relatedTerms) {
100
- if (!ids.has(relatedId)) {
101
- console.error(
102
- ` ❌ Invalid relatedTerm "${relatedId}" in ${value.id} (term does not exist)`,
103
- );
104
- hasErrors = true;
105
- }
106
- }
107
- }
108
- }
109
-
110
- // Check that governance.replacedBy references valid IDs
111
- for (const value of registry.values) {
112
- if (value.governance?.replacedBy) {
113
- if (!ids.has(value.governance.replacedBy)) {
114
- console.error(
115
- ` ❌ Invalid governance.replacedBy "${value.governance.replacedBy}" in ${value.id} (term does not exist)`,
116
- );
117
- hasErrors = true;
118
- }
119
- }
120
- }
121
-
122
- if (!hasErrors) {
123
- console.log(` ✅ Valid (${registry.values.length} values)`);
124
- }
125
- console.log("");
126
- }
127
-
128
- if (hasErrors) {
129
- console.error("❌ Validation failed with errors\n");
130
- process.exit(1);
131
- } else {
132
- console.log("✅ All registry files validated successfully\n");
133
- process.exit(0);
134
- }
@@ -1,417 +0,0 @@
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
- propertyTerms,
20
- components,
21
- scaleValues,
22
- categories,
23
- platforms,
24
- tokenObjects,
25
- structures,
26
- substructures,
27
- orientations,
28
- positions,
29
- densities,
30
- shapes,
31
- getValues,
32
- findValue,
33
- hasValue,
34
- getDefault,
35
- getActiveValues,
36
- } from "../index.js";
37
-
38
- // Test that all registries load without errors
39
- test("sizes registry loads successfully", (t) => {
40
- t.truthy(sizes);
41
- t.truthy(sizes.values);
42
- t.true(Array.isArray(sizes.values));
43
- t.true(sizes.values.length > 0);
44
- });
45
-
46
- test("states registry loads successfully", (t) => {
47
- t.truthy(states);
48
- t.truthy(states.values);
49
- t.true(Array.isArray(states.values));
50
- t.true(states.values.length > 0);
51
- });
52
-
53
- test("variants registry loads successfully", (t) => {
54
- t.truthy(variants);
55
- t.truthy(variants.values);
56
- t.true(Array.isArray(variants.values));
57
- t.true(variants.values.length > 0);
58
- });
59
-
60
- test("anatomyTerms registry loads successfully", (t) => {
61
- t.truthy(anatomyTerms);
62
- t.truthy(anatomyTerms.values);
63
- t.true(Array.isArray(anatomyTerms.values));
64
- t.true(anatomyTerms.values.length > 0);
65
- });
66
-
67
- test("propertyTerms registry loads successfully", (t) => {
68
- t.truthy(propertyTerms);
69
- t.truthy(propertyTerms.values);
70
- t.true(Array.isArray(propertyTerms.values));
71
- t.true(propertyTerms.values.length > 0);
72
- });
73
-
74
- test("components registry loads successfully", (t) => {
75
- t.truthy(components);
76
- t.truthy(components.values);
77
- t.true(Array.isArray(components.values));
78
- t.true(components.values.length > 0);
79
- });
80
-
81
- test("scaleValues registry loads successfully", (t) => {
82
- t.truthy(scaleValues);
83
- t.truthy(scaleValues.values);
84
- t.true(Array.isArray(scaleValues.values));
85
- t.true(scaleValues.values.length > 0);
86
- });
87
-
88
- test("categories registry loads successfully", (t) => {
89
- t.truthy(categories);
90
- t.truthy(categories.values);
91
- t.true(Array.isArray(categories.values));
92
- t.true(categories.values.length > 0);
93
- });
94
-
95
- test("platforms registry loads successfully", (t) => {
96
- t.truthy(platforms);
97
- t.truthy(platforms.values);
98
- t.true(Array.isArray(platforms.values));
99
- t.true(platforms.values.length > 0);
100
- });
101
-
102
- // Test for duplicate IDs within registries
103
- test("sizes registry has no duplicate IDs", (t) => {
104
- const ids = sizes.values.map((v) => v.id);
105
- const uniqueIds = new Set(ids);
106
- t.is(ids.length, uniqueIds.size);
107
- });
108
-
109
- test("states registry has no duplicate IDs", (t) => {
110
- const ids = states.values.map((v) => v.id);
111
- const uniqueIds = new Set(ids);
112
- t.is(ids.length, uniqueIds.size);
113
- });
114
-
115
- test("variants registry has no duplicate IDs", (t) => {
116
- const ids = variants.values.map((v) => v.id);
117
- const uniqueIds = new Set(ids);
118
- t.is(ids.length, uniqueIds.size);
119
- });
120
-
121
- test("components registry has no duplicate IDs", (t) => {
122
- const ids = components.values.map((v) => v.id);
123
- const uniqueIds = new Set(ids);
124
- t.is(ids.length, uniqueIds.size);
125
- });
126
-
127
- test("anatomyTerms registry has no duplicate IDs", (t) => {
128
- const ids = anatomyTerms.values.map((v) => v.id);
129
- t.is(ids.length, new Set(ids).size);
130
- });
131
-
132
- test("propertyTerms registry has no duplicate IDs", (t) => {
133
- const ids = propertyTerms.values.map((v) => v.id);
134
- t.is(ids.length, new Set(ids).size);
135
- });
136
-
137
- // Test for duplicate aliases
138
- test("sizes registry has no duplicate aliases", (t) => {
139
- const aliases = sizes.values.flatMap((v) => v.aliases || []);
140
- const uniqueAliases = new Set(aliases);
141
- t.is(aliases.length, uniqueAliases.size);
142
- });
143
-
144
- test("states registry has no duplicate aliases", (t) => {
145
- const aliases = states.values.flatMap((v) => v.aliases || []);
146
- const uniqueAliases = new Set(aliases);
147
- t.is(aliases.length, uniqueAliases.size);
148
- });
149
-
150
- // Test that required fields exist
151
- test("all size values have id and label", (t) => {
152
- sizes.values.forEach((value) => {
153
- t.truthy(value.id, `Size value missing id`);
154
- t.truthy(value.label, `Size value ${value.id} missing label`);
155
- });
156
- });
157
-
158
- test("all state values have id and label", (t) => {
159
- states.values.forEach((value) => {
160
- t.truthy(value.id, `State value missing id`);
161
- t.truthy(value.label, `State value ${value.id} missing label`);
162
- });
163
- });
164
-
165
- test("all component values have id, label, and documentationUrl", (t) => {
166
- components.values.forEach((value) => {
167
- t.truthy(value.id, `Component value missing id`);
168
- t.truthy(value.label, `Component value ${value.id} missing label`);
169
- t.truthy(
170
- value.documentationUrl,
171
- `Component ${value.id} missing documentationUrl`,
172
- );
173
- });
174
- });
175
-
176
- // Test default values
177
- test("sizes registry has exactly one default value", (t) => {
178
- const defaults = sizes.values.filter((v) => v.default === true);
179
- t.is(defaults.length, 1);
180
- t.is(defaults[0].id, "m");
181
- });
182
-
183
- test("states registry has exactly one default value", (t) => {
184
- const defaults = states.values.filter((v) => v.default === true);
185
- t.is(defaults.length, 1);
186
- t.is(defaults[0].id, "default");
187
- });
188
-
189
- // Test helper functions
190
- test("getValues returns array of IDs", (t) => {
191
- const values = getValues(sizes);
192
- t.true(Array.isArray(values));
193
- t.true(values.length > 0);
194
- t.true(values.includes("s"));
195
- t.true(values.includes("m"));
196
- t.true(values.includes("l"));
197
- });
198
-
199
- test("findValue finds value by ID", (t) => {
200
- const value = findValue(sizes, "m");
201
- t.truthy(value);
202
- t.is(value.id, "m");
203
- t.is(value.label, "Medium");
204
- });
205
-
206
- test("findValue finds value by alias", (t) => {
207
- const value = findValue(sizes, "medium");
208
- t.truthy(value);
209
- t.is(value.id, "m");
210
- });
211
-
212
- test("findValue returns undefined for non-existent value", (t) => {
213
- const value = findValue(sizes, "nonexistent");
214
- t.is(value, undefined);
215
- });
216
-
217
- test("hasValue returns true for existing ID", (t) => {
218
- t.true(hasValue(sizes, "m"));
219
- });
220
-
221
- test("hasValue returns true for existing alias", (t) => {
222
- t.true(hasValue(sizes, "medium"));
223
- });
224
-
225
- test("hasValue returns false for non-existent value", (t) => {
226
- t.false(hasValue(sizes, "nonexistent"));
227
- });
228
-
229
- test("getDefault returns the default value", (t) => {
230
- const defaultSize = getDefault(sizes);
231
- t.truthy(defaultSize);
232
- t.is(defaultSize.id, "m");
233
- t.true(defaultSize.default);
234
- });
235
-
236
- test("getActiveValues returns only non-deprecated values", (t) => {
237
- const activeValues = getActiveValues(sizes);
238
- t.true(Array.isArray(activeValues));
239
- activeValues.forEach((value) => {
240
- t.not(value.deprecated, true);
241
- });
242
- });
243
-
244
- // Test specific registry content
245
- test("sizes includes common t-shirt sizes", (t) => {
246
- const ids = getValues(sizes);
247
- t.true(ids.includes("xs"));
248
- t.true(ids.includes("s"));
249
- t.true(ids.includes("m"));
250
- t.true(ids.includes("l"));
251
- t.true(ids.includes("xl"));
252
- });
253
-
254
- test("sizes does not contain numeric scale values", (t) => {
255
- const ids = getValues(sizes);
256
- t.false(ids.includes("50"));
257
- t.false(ids.includes("100"));
258
- t.false(ids.includes("200"));
259
- });
260
-
261
- test("states includes common interaction states", (t) => {
262
- const ids = getValues(states);
263
- t.true(ids.includes("default"));
264
- t.true(ids.includes("hover"));
265
- t.true(ids.includes("focus"));
266
- t.true(ids.includes("disabled"));
267
- });
268
-
269
- test("variants includes semantic variants", (t) => {
270
- const ids = getValues(variants);
271
- t.true(ids.includes("accent"));
272
- t.true(ids.includes("negative"));
273
- t.true(ids.includes("positive"));
274
- });
275
-
276
- test("anatomyTerms includes key anatomy parts", (t) => {
277
- const ids = getValues(anatomyTerms);
278
- t.true(ids.includes("text"));
279
- t.true(ids.includes("icon"));
280
- t.true(ids.includes("label"));
281
- t.true(ids.includes("handle"));
282
- });
283
-
284
- test("anatomyTerms does not include styling surfaces", (t) => {
285
- const ids = getValues(anatomyTerms);
286
- t.false(ids.includes("background"));
287
- t.false(ids.includes("border"));
288
- t.false(ids.includes("edge"));
289
- t.false(ids.includes("visual"));
290
- });
291
-
292
- test("propertyTerms includes core CSS styling attributes", (t) => {
293
- const ids = getValues(propertyTerms);
294
- t.true(ids.includes("color"));
295
- t.true(ids.includes("background-color"));
296
- t.true(ids.includes("border-color"));
297
- t.true(ids.includes("opacity"));
298
- t.true(ids.includes("width"));
299
- t.true(ids.includes("height"));
300
- t.true(ids.includes("font-size"));
301
- t.true(ids.includes("gap"));
302
- });
303
-
304
- test("propertyTerms does not include anatomy parts or styling surfaces", (t) => {
305
- const ids = getValues(propertyTerms);
306
- t.false(ids.includes("background"));
307
- t.false(ids.includes("border"));
308
- t.false(ids.includes("icon"));
309
- t.false(ids.includes("label"));
310
- t.false(ids.includes("handle"));
311
- });
312
-
313
- test("tokenObjects includes styling surfaces", (t) => {
314
- const ids = getValues(tokenObjects);
315
- t.true(ids.includes("background"));
316
- t.true(ids.includes("border"));
317
- t.true(ids.includes("edge"));
318
- t.true(ids.includes("visual"));
319
- t.true(ids.includes("content"));
320
- });
321
-
322
- test("components includes core components", (t) => {
323
- const ids = getValues(components);
324
- t.true(ids.includes("button"));
325
- t.true(ids.includes("checkbox"));
326
- t.true(ids.includes("text-field"));
327
- });
328
-
329
- test("categories includes all 8 component categories", (t) => {
330
- const ids = getValues(categories);
331
- t.is(ids.length, 8);
332
- t.true(ids.includes("actions"));
333
- t.true(ids.includes("containers"));
334
- t.true(ids.includes("inputs"));
335
- t.true(ids.includes("navigation"));
336
- });
337
-
338
- test("platforms includes desktop and mobile", (t) => {
339
- const ids = getValues(platforms);
340
- t.true(ids.includes("desktop"));
341
- t.true(ids.includes("mobile"));
342
- });
343
-
344
- test("scaleValues includes common numeric scales", (t) => {
345
- const ids = getValues(scaleValues);
346
- t.true(ids.includes("50"));
347
- t.true(ids.includes("100"));
348
- t.true(ids.includes("200"));
349
- t.true(ids.includes("300"));
350
- });
351
-
352
- test("scaleValues includes extended numeric scales", (t) => {
353
- const ids = getValues(scaleValues);
354
- t.true(ids.includes("1100"));
355
- t.true(ids.includes("1200"));
356
- t.true(ids.includes("1500"));
357
- });
358
-
359
- // Taxonomy registry tests
360
-
361
- const taxonomyRegistries = [
362
- ["tokenObjects", tokenObjects],
363
- ["structures", structures],
364
- ["substructures", substructures],
365
- ["orientations", orientations],
366
- ["positions", positions],
367
- ["densities", densities],
368
- ["shapes", shapes],
369
- ];
370
-
371
- for (const [name, registry] of taxonomyRegistries) {
372
- test(`${name} registry loads successfully`, (t) => {
373
- t.truthy(registry);
374
- t.truthy(registry.values);
375
- t.true(Array.isArray(registry.values));
376
- t.true(registry.values.length > 0);
377
- });
378
-
379
- test(`${name} registry has no duplicate IDs`, (t) => {
380
- const ids = registry.values.map((v) => v.id);
381
- const uniqueIds = new Set(ids);
382
- t.is(ids.length, uniqueIds.size);
383
- });
384
-
385
- test(`all ${name} values have id and label`, (t) => {
386
- registry.values.forEach((value) => {
387
- t.truthy(value.id, `${name} value missing id`);
388
- t.truthy(value.label, `${name} value ${value.id} missing label`);
389
- });
390
- });
391
- }
392
-
393
- test("structures includes base and container", (t) => {
394
- const ids = getValues(structures);
395
- t.true(ids.includes("base"));
396
- t.true(ids.includes("container"));
397
- });
398
-
399
- test("orientations includes vertical and horizontal", (t) => {
400
- const ids = getValues(orientations);
401
- t.true(ids.includes("vertical"));
402
- t.true(ids.includes("horizontal"));
403
- });
404
-
405
- test("positions includes directional terms", (t) => {
406
- const ids = getValues(positions);
407
- t.true(ids.includes("top"));
408
- t.true(ids.includes("bottom"));
409
- t.true(ids.includes("start"));
410
- t.true(ids.includes("end"));
411
- });
412
-
413
- test("densities includes spacious and compact", (t) => {
414
- const ids = getValues(densities);
415
- t.true(ids.includes("spacious"));
416
- t.true(ids.includes("compact"));
417
- });