@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/index.js ADDED
@@ -0,0 +1,189 @@
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 { fileURLToPath } from "node:url";
15
+ import { dirname, join } from "node:path";
16
+
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+
20
+ // Load registry files
21
+ export const sizes = JSON.parse(
22
+ readFileSync(join(__dirname, "registry", "sizes.json"), "utf-8"),
23
+ );
24
+
25
+ export const states = JSON.parse(
26
+ readFileSync(join(__dirname, "registry", "states.json"), "utf-8"),
27
+ );
28
+
29
+ export const variants = JSON.parse(
30
+ readFileSync(join(__dirname, "registry", "variants.json"), "utf-8"),
31
+ );
32
+
33
+ export const anatomyTerms = JSON.parse(
34
+ readFileSync(join(__dirname, "registry", "anatomy-terms.json"), "utf-8"),
35
+ );
36
+
37
+ export const components = JSON.parse(
38
+ readFileSync(join(__dirname, "registry", "components.json"), "utf-8"),
39
+ );
40
+
41
+ export const scaleValues = JSON.parse(
42
+ readFileSync(join(__dirname, "registry", "scale-values.json"), "utf-8"),
43
+ );
44
+
45
+ export const categories = JSON.parse(
46
+ readFileSync(join(__dirname, "registry", "categories.json"), "utf-8"),
47
+ );
48
+
49
+ export const platforms = JSON.parse(
50
+ readFileSync(join(__dirname, "registry", "platforms.json"), "utf-8"),
51
+ );
52
+
53
+ export const navigationTerms = JSON.parse(
54
+ readFileSync(join(__dirname, "registry", "navigation-terms.json"), "utf-8"),
55
+ );
56
+
57
+ export const tokenTerminology = JSON.parse(
58
+ readFileSync(join(__dirname, "registry", "token-terminology.json"), "utf-8"),
59
+ );
60
+
61
+ export const glossary = JSON.parse(
62
+ readFileSync(join(__dirname, "registry", "glossary.json"), "utf-8"),
63
+ );
64
+
65
+ /**
66
+ * Get all values from a registry by ID
67
+ * @param {object} registry - The registry object
68
+ * @returns {string[]} Array of value IDs
69
+ */
70
+ export function getValues(registry) {
71
+ return registry.values.map((v) => v.id);
72
+ }
73
+
74
+ /**
75
+ * Find a registry value by ID or alias
76
+ * @param {object} registry - The registry object
77
+ * @param {string} searchTerm - The ID or alias to search for
78
+ * @returns {object|undefined} The matching value or undefined
79
+ */
80
+ export function findValue(registry, searchTerm) {
81
+ return registry.values.find(
82
+ (v) => v.id === searchTerm || v.aliases?.includes(searchTerm),
83
+ );
84
+ }
85
+
86
+ /**
87
+ * Check if a value exists in a registry
88
+ * @param {object} registry - The registry object
89
+ * @param {string} searchTerm - The ID or alias to search for
90
+ * @returns {boolean} True if the value exists
91
+ */
92
+ export function hasValue(registry, searchTerm) {
93
+ return findValue(registry, searchTerm) !== undefined;
94
+ }
95
+
96
+ /**
97
+ * Get the default value from a registry
98
+ * @param {object} registry - The registry object
99
+ * @returns {object|undefined} The default value or undefined
100
+ */
101
+ export function getDefault(registry) {
102
+ return registry.values.find((v) => v.default === true);
103
+ }
104
+
105
+ /**
106
+ * Get all non-deprecated values from a registry
107
+ * @param {object} registry - The registry object
108
+ * @returns {array} Array of non-deprecated values
109
+ */
110
+ export function getActiveValues(registry) {
111
+ return registry.values.filter((v) => !v.deprecated);
112
+ }
113
+
114
+ /**
115
+ * Load a platform extension file
116
+ * @param {string} extensionPath - Path to the extension JSON file
117
+ * @returns {object} The extension object
118
+ */
119
+ export function loadPlatformExtension(extensionPath) {
120
+ return JSON.parse(readFileSync(extensionPath, "utf-8"));
121
+ }
122
+
123
+ /**
124
+ * Get platform-specific term for a registry value
125
+ * @param {object} registry - The base registry object
126
+ * @param {string} termId - The term ID to look up
127
+ * @param {string} platform - The platform name
128
+ * @param {object} extension - Optional: The platform extension object
129
+ * @returns {object|undefined} Platform-specific term info or undefined
130
+ */
131
+ export function getTermForPlatform(registry, termId, platform, extension) {
132
+ // First, find the base term
133
+ const baseTerm = findValue(registry, termId);
134
+ if (!baseTerm) return undefined;
135
+
136
+ // Check if the term has platform-specific info in its platforms property
137
+ if (baseTerm.platforms && baseTerm.platforms[platform]) {
138
+ return {
139
+ ...baseTerm,
140
+ platform: baseTerm.platforms[platform],
141
+ };
142
+ }
143
+
144
+ // If extension is provided, check for platform-specific overrides
145
+ if (extension && extension.platform === platform) {
146
+ const ext = extension.extensions.find((e) => e.termId === termId);
147
+ if (ext) {
148
+ return {
149
+ ...baseTerm,
150
+ platform: {
151
+ term: ext.platformTerm || baseTerm.label,
152
+ aliases: ext.platformAliases,
153
+ notes: ext.notes,
154
+ reference: ext.reference,
155
+ codeExample: ext.codeExample,
156
+ differences: ext.differences,
157
+ },
158
+ };
159
+ }
160
+ }
161
+
162
+ // Return base term if no platform-specific info found
163
+ return baseTerm;
164
+ }
165
+
166
+ /**
167
+ * Get all extensions for a specific platform
168
+ * @param {array} extensions - Array of extension objects
169
+ * @param {string} platform - The platform name
170
+ * @returns {array} Array of extensions for the platform
171
+ */
172
+ export function getPlatformExtensions(extensions, platform) {
173
+ return extensions.filter((ext) => ext.platform === platform);
174
+ }
175
+
176
+ /**
177
+ * Load all platform extensions from a directory
178
+ * @param {string} extensionsDir - Path to the extensions directory
179
+ * @returns {array} Array of loaded extension objects
180
+ */
181
+ export function loadAllPlatformExtensions(extensionsDir) {
182
+ const extensionFiles = readdirSync(extensionsDir).filter((f) =>
183
+ f.endsWith(".json"),
184
+ );
185
+
186
+ return extensionFiles.map((file) =>
187
+ loadPlatformExtension(join(extensionsDir, file)),
188
+ );
189
+ }
package/moon.yml ADDED
@@ -0,0 +1,40 @@
1
+ # Copyright 2025 Adobe. All rights reserved.
2
+ # This file is licensed to you under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License. You may obtain a copy
4
+ # of the License at http://www.apache.org/licenses/LICENSE-2.0
5
+
6
+ # Unless required by applicable law or agreed to in writing, software distributed under
7
+ # the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
+ # OF ANY KIND, either express or implied. See the License for the specific language
9
+ # governing permissions and limitations under the License.
10
+
11
+ $schema: "https://moonrepo.dev/schemas/project.json"
12
+ layer: library
13
+ fileGroups:
14
+ registry:
15
+ - "registry/**/*.json"
16
+ schemas:
17
+ - "schemas/**/*.json"
18
+ tests:
19
+ - "test/**/*"
20
+ tasks:
21
+ test:
22
+ command:
23
+ - pnpm
24
+ - ava
25
+ inputs:
26
+ - "@globs(registry)"
27
+ - "@globs(schemas)"
28
+ - "@globs(tests)"
29
+ - "index.js"
30
+ - "ava.config.js"
31
+ platform: node
32
+ validate:
33
+ command:
34
+ - node
35
+ - scripts/validate-registry.js
36
+ inputs:
37
+ - "@globs(registry)"
38
+ - "@globs(schemas)"
39
+ - "scripts/validate-registry.js"
40
+ platform: node
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@adobe/design-system-registry",
3
+ "version": "0.0.0-layout-20260209174611",
4
+ "description": "A single source of truth for design system terminology used across Spectrum tokens, component schemas, and anatomy",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./registry/sizes.json": "./registry/sizes.json",
10
+ "./registry/states.json": "./registry/states.json",
11
+ "./registry/variants.json": "./registry/variants.json",
12
+ "./registry/anatomy-terms.json": "./registry/anatomy-terms.json",
13
+ "./registry/components.json": "./registry/components.json",
14
+ "./registry/scale-values.json": "./registry/scale-values.json",
15
+ "./registry/categories.json": "./registry/categories.json",
16
+ "./registry/platforms.json": "./registry/platforms.json"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/adobe/spectrum-design-data.git",
21
+ "directory": "packages/design-system-registry"
22
+ },
23
+ "author": "Garth Braithwaite <garthdb@gmail.com> (https://garthdb.com/)",
24
+ "bugs": {
25
+ "url": "https://github.com/adobe/spectrum-design-data/issues"
26
+ },
27
+ "publishConfig": {
28
+ "provenance": false
29
+ },
30
+ "homepage": "https://github.com/adobe/spectrum-design-data/tree/main/packages/design-system-registry#readme",
31
+ "license": "Apache-2.0",
32
+ "engines": {
33
+ "node": ">=20.12.0",
34
+ "pnpm": ">=10.17.1"
35
+ },
36
+ "devDependencies": {
37
+ "ajv": "^8.17.1",
38
+ "ajv-formats": "^3.0.1",
39
+ "ava": "^6.0.1",
40
+ "@adobe/spectrum-component-api-schemas": "6.0.0"
41
+ },
42
+ "scripts": {
43
+ "validate": "node scripts/validate-registry.js",
44
+ "test": "ava"
45
+ }
46
+ }
@@ -0,0 +1,151 @@
1
+ {
2
+ "$schema": "https://opensource.adobe.com/spectrum-design-data/schemas/registry-value.json",
3
+ "type": "anatomy-term",
4
+ "description": "Anatomical part names used in design tokens and component structures",
5
+ "values": [
6
+ {
7
+ "id": "edge",
8
+ "label": "Edge",
9
+ "description": "The outer boundary or border of a component",
10
+ "usedIn": ["tokens"]
11
+ },
12
+ {
13
+ "id": "visual",
14
+ "label": "Visual",
15
+ "description": "Visual elements like icons, images, or decorative elements",
16
+ "usedIn": ["tokens"]
17
+ },
18
+ {
19
+ "id": "text",
20
+ "label": "Text",
21
+ "description": "Text content or labels",
22
+ "usedIn": ["tokens"]
23
+ },
24
+ {
25
+ "id": "control",
26
+ "label": "Control",
27
+ "description": "Interactive control elements like checkboxes or radio buttons",
28
+ "usedIn": ["tokens"]
29
+ },
30
+ {
31
+ "id": "border",
32
+ "label": "Border",
33
+ "description": "Border or outline of a component",
34
+ "usedIn": ["tokens"]
35
+ },
36
+ {
37
+ "id": "background",
38
+ "label": "Background",
39
+ "description": "Background surface or fill",
40
+ "usedIn": ["tokens"]
41
+ },
42
+ {
43
+ "id": "icon",
44
+ "label": "Icon",
45
+ "description": "Icon elements",
46
+ "usedIn": ["tokens", "component-schemas"]
47
+ },
48
+ {
49
+ "id": "label",
50
+ "label": "Label",
51
+ "description": "Text labels",
52
+ "usedIn": ["tokens", "component-schemas"]
53
+ },
54
+ {
55
+ "id": "content",
56
+ "label": "Content",
57
+ "description": "Main content area",
58
+ "usedIn": ["tokens"]
59
+ },
60
+ {
61
+ "id": "top",
62
+ "label": "Top",
63
+ "description": "Top edge or boundary",
64
+ "usedIn": ["tokens"]
65
+ },
66
+ {
67
+ "id": "bottom",
68
+ "label": "Bottom",
69
+ "description": "Bottom edge or boundary",
70
+ "usedIn": ["tokens"]
71
+ },
72
+ {
73
+ "id": "start",
74
+ "label": "Start",
75
+ "description": "Start edge (left in LTR, right in RTL)",
76
+ "usedIn": ["tokens"]
77
+ },
78
+ {
79
+ "id": "end",
80
+ "label": "End",
81
+ "description": "End edge (right in LTR, left in RTL)",
82
+ "usedIn": ["tokens"]
83
+ },
84
+ {
85
+ "id": "body",
86
+ "label": "Body",
87
+ "description": "Main body or content container",
88
+ "usedIn": ["tokens"]
89
+ },
90
+ {
91
+ "id": "header",
92
+ "label": "Header",
93
+ "description": "Header section",
94
+ "usedIn": ["tokens"]
95
+ },
96
+ {
97
+ "id": "footer",
98
+ "label": "Footer",
99
+ "description": "Footer section",
100
+ "usedIn": ["tokens"]
101
+ },
102
+ {
103
+ "id": "divider",
104
+ "label": "Divider",
105
+ "description": "Dividing line or separator",
106
+ "usedIn": ["tokens"]
107
+ },
108
+ {
109
+ "id": "handle",
110
+ "label": "Handle",
111
+ "description": "Draggable handle element",
112
+ "usedIn": ["tokens"]
113
+ },
114
+ {
115
+ "id": "indicator",
116
+ "label": "Indicator",
117
+ "description": "Visual indicator or marker",
118
+ "usedIn": ["tokens"]
119
+ },
120
+ {
121
+ "id": "track",
122
+ "label": "Track",
123
+ "description": "Track or rail element (e.g., in sliders)",
124
+ "usedIn": ["tokens"]
125
+ },
126
+ {
127
+ "id": "thumb",
128
+ "label": "Thumb",
129
+ "description": "Draggable thumb element (e.g., in sliders)",
130
+ "usedIn": ["tokens"]
131
+ },
132
+ {
133
+ "id": "avatar",
134
+ "label": "Avatar",
135
+ "description": "User avatar or profile image",
136
+ "usedIn": ["tokens"]
137
+ },
138
+ {
139
+ "id": "badge",
140
+ "label": "Badge",
141
+ "description": "Badge or notification indicator",
142
+ "usedIn": ["tokens"]
143
+ },
144
+ {
145
+ "id": "pill",
146
+ "label": "Pill",
147
+ "description": "Pill-shaped element",
148
+ "usedIn": ["tokens"]
149
+ }
150
+ ]
151
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://opensource.adobe.com/spectrum-design-data/schemas/registry-value.json",
3
+ "type": "category",
4
+ "description": "Component categories for organization and discovery",
5
+ "values": [
6
+ {
7
+ "id": "actions",
8
+ "label": "Actions",
9
+ "description": "Components that allow users to perform actions",
10
+ "usedIn": ["component-schemas"]
11
+ },
12
+ {
13
+ "id": "containers",
14
+ "label": "Containers",
15
+ "description": "Components that contain or organize other content",
16
+ "usedIn": ["component-schemas"]
17
+ },
18
+ {
19
+ "id": "data-visualization",
20
+ "label": "Data Visualization",
21
+ "aliases": ["data visualization"],
22
+ "description": "Components for displaying data and charts",
23
+ "usedIn": ["component-schemas"]
24
+ },
25
+ {
26
+ "id": "feedback",
27
+ "label": "Feedback",
28
+ "description": "Components that provide feedback to users",
29
+ "usedIn": ["component-schemas"]
30
+ },
31
+ {
32
+ "id": "inputs",
33
+ "label": "Inputs",
34
+ "description": "Components for user input and data entry",
35
+ "usedIn": ["component-schemas"]
36
+ },
37
+ {
38
+ "id": "navigation",
39
+ "label": "Navigation",
40
+ "description": "Components for navigation and wayfinding",
41
+ "usedIn": ["component-schemas"]
42
+ },
43
+ {
44
+ "id": "status",
45
+ "label": "Status",
46
+ "description": "Components that indicate status or state",
47
+ "usedIn": ["component-schemas"]
48
+ },
49
+ {
50
+ "id": "typography",
51
+ "label": "Typography",
52
+ "description": "Text and typography components",
53
+ "usedIn": ["component-schemas"]
54
+ }
55
+ ]
56
+ }