@adobe/spectrum-tokens 12.12.1 → 12.13.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/CHANGELOG.md +105 -0
- package/dist/json/drover.json +94 -0
- package/dist/json/variables.json +1154 -0
- package/manifest.json +7 -3
- package/moon.yml +2 -1
- package/package.json +3 -2
- package/schemas/component.json +29 -0
- package/schemas/components/action-bar.json +18 -0
- package/schemas/components/action-button.json +62 -0
- package/schemas/components/action-group.json +69 -0
- package/schemas/components/alert-banner.json +29 -0
- package/schemas/components/alert-dialog.json +42 -0
- package/schemas/components/avatar.json +30 -0
- package/schemas/components/badge.json +50 -0
- package/schemas/components/body.json +25 -0
- package/schemas/components/bottom-navigation-android.json +37 -0
- package/schemas/components/breadcrumbs.json +18 -0
- package/schemas/components/button-group.json +28 -0
- package/schemas/components/button.json +60 -0
- package/schemas/components/checkbox-group.json +53 -0
- package/schemas/components/checkbox.json +52 -0
- package/schemas/components/close-button.json +35 -0
- package/schemas/components/code.json +21 -0
- package/schemas/components/color-area.json +64 -0
- package/schemas/components/color-loupe.json +21 -0
- package/schemas/components/color-slider.json +52 -0
- package/schemas/components/color-wheel.json +47 -0
- package/schemas/components/combo-box.json +84 -0
- package/schemas/components/contextual-help.json +64 -0
- package/schemas/components/detail.json +26 -0
- package/schemas/components/divider.json +23 -0
- package/schemas/components/field-label.json +39 -0
- package/schemas/components/heading.json +29 -0
- package/schemas/components/help-text.json +35 -0
- package/schemas/components/in-line-alert.json +25 -0
- package/schemas/components/link.json +32 -0
- package/schemas/components/menu.json +65 -0
- package/schemas/components/meter.json +37 -0
- package/schemas/components/picker.json +85 -0
- package/schemas/components/popover.json +65 -0
- package/schemas/components/progress-bar.json +50 -0
- package/schemas/components/progress-circle.json +41 -0
- package/schemas/components/radio-group.json +62 -0
- package/schemas/components/rating.json +31 -0
- package/schemas/components/scroll-zoom-bar.json +44 -0
- package/schemas/components/side-navigation.json +18 -0
- package/schemas/components/slider.json +74 -0
- package/schemas/components/status-light.json +44 -0
- package/schemas/components/swatch-group.json +38 -0
- package/schemas/components/swatch.json +45 -0
- package/schemas/components/switch.json +42 -0
- package/schemas/components/tab-bar-ios.json +37 -0
- package/schemas/components/tabs.json +32 -0
- package/schemas/components/tag.json +41 -0
- package/schemas/components/text-area.json +98 -0
- package/schemas/components/text-field.json +86 -0
- package/schemas/components/toast.json +29 -0
- package/schemas/components/tooltip.json +50 -0
- package/schemas/components/tray.json +17 -0
- package/schemas/components/tree-view.json +50 -0
- package/schemas/types/component-size.json +8 -0
- package/schemas/types/hex-color.json +8 -0
- package/schemas/types/typography-classification.json +9 -0
- package/schemas/types/typography-script.json +9 -0
- package/schemas/types/workflow-icon.json +901 -0
- package/src/color-component.json +45 -0
- package/src/layout-component.json +923 -0
- package/tasks/buildManifest.js +6 -1
- package/tasks/diff.js +1 -1
- package/test/checkId.test.js +64 -0
- package/test/schemaValidator.test.js +74 -0
package/tasks/buildManifest.js
CHANGED
|
@@ -12,9 +12,14 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
|
|
13
13
|
import glob from "glob-promise";
|
|
14
14
|
import { writeFile } from "fs/promises";
|
|
15
|
+
import { format } from "prettier";
|
|
15
16
|
|
|
16
17
|
const manifestFileName = "manifest.json";
|
|
17
18
|
const files = await glob("src/**/*.json");
|
|
18
19
|
|
|
19
|
-
await writeFile(
|
|
20
|
+
await writeFile(
|
|
21
|
+
manifestFileName,
|
|
22
|
+
await format(JSON.stringify(files), { parser: "json-stringify" }),
|
|
23
|
+
);
|
|
24
|
+
//
|
|
20
25
|
console.log(`Wrote ${manifestFileName} with ${files.length} files.`);
|
package/tasks/diff.js
CHANGED
|
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { access, readFile
|
|
13
|
+
import { access, readFile } from "fs/promises";
|
|
14
14
|
import { join, dirname } from "path";
|
|
15
15
|
import { fileURLToPath } from "url";
|
|
16
16
|
import { detailedDiff, diff } from "deep-object-diff";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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 glob from "glob-promise";
|
|
15
|
+
import { readFile } from "fs/promises";
|
|
16
|
+
const fileNames = await glob("src/**/*.json");
|
|
17
|
+
const files = await Promise.all(
|
|
18
|
+
fileNames.map(async (fileName) =>
|
|
19
|
+
JSON.parse(await readFile(fileName, "utf8")),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const uuids = [];
|
|
24
|
+
const missingUUIDs = [];
|
|
25
|
+
const VALUE = "value";
|
|
26
|
+
const UUID = "uuid";
|
|
27
|
+
|
|
28
|
+
function isObject(a) {
|
|
29
|
+
return (
|
|
30
|
+
!!a &&
|
|
31
|
+
a.constructor &&
|
|
32
|
+
(a.constructor === Object || a.constructor.name === "Object")
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// check for and add uuids
|
|
37
|
+
function checkUUID(json, name) {
|
|
38
|
+
// if it is in want of uuid, give it one
|
|
39
|
+
if (json[VALUE] && !json[UUID]) {
|
|
40
|
+
if (!json[UUID] || uuids.includes(json[UUID])) {
|
|
41
|
+
if (name) {
|
|
42
|
+
missingUUIDs.push(name);
|
|
43
|
+
} else {
|
|
44
|
+
missingUUIDs.push(json[VALUE]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
uuids.push(json[UUID]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// handle the json's children
|
|
52
|
+
Object.keys(json).forEach((key) => {
|
|
53
|
+
if (isObject(json[key])) {
|
|
54
|
+
checkUUID(json[key], key);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
test("check for uuids", async (t) => {
|
|
60
|
+
for (const file of files) {
|
|
61
|
+
checkUUID(file);
|
|
62
|
+
}
|
|
63
|
+
t.deepEqual(missingUUIDs, []);
|
|
64
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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 Ajv from "ajv/dist/2020.js";
|
|
15
|
+
import addFormats from "ajv-formats";
|
|
16
|
+
import glob from "glob-promise";
|
|
17
|
+
import { readFile } from "fs/promises";
|
|
18
|
+
|
|
19
|
+
const readJSON = async (filePath) =>
|
|
20
|
+
JSON.parse(await readFile(filePath, "utf8"));
|
|
21
|
+
const componentSchema = await readJSON("schemas/component.json");
|
|
22
|
+
|
|
23
|
+
const fileNames = await glob("schemas/components/*.json");
|
|
24
|
+
const files = await Promise.all(
|
|
25
|
+
fileNames.map(async (fileName) => {
|
|
26
|
+
return { fileName, json: await readJSON(fileName) };
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const ajv = new Ajv();
|
|
31
|
+
addFormats(ajv);
|
|
32
|
+
ajv.addMetaSchema(componentSchema);
|
|
33
|
+
const schemaFiles = await glob("schemas/types/*.json");
|
|
34
|
+
for (const schemaFile of schemaFiles) {
|
|
35
|
+
const schema = await readJSON(schemaFile);
|
|
36
|
+
ajv.addSchema(schema);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const keyword of Object.keys(componentSchema.properties)) {
|
|
40
|
+
ajv.addKeyword({ keyword, metaSchema: componentSchema.properties[keyword] });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
test("component schema should be valid", async (t) => {
|
|
44
|
+
const valid = ajv.validateSchema(componentSchema);
|
|
45
|
+
t.true(valid);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("Every component schema should validate against the definition", (t) => {
|
|
49
|
+
let valid = true;
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
if (!ajv.validateSchema(file.json)) {
|
|
52
|
+
valid = false;
|
|
53
|
+
console.log(`${file.fileName} failed validation`);
|
|
54
|
+
console.log(ajv.errors);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
t.true(valid);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("component examples should validate against the definition", (t) => {
|
|
61
|
+
let valid = true;
|
|
62
|
+
for (const file of files) {
|
|
63
|
+
const validate = ajv.compile(file.json);
|
|
64
|
+
if (!Object.hasOwn(file.json, "examples")) file.json.examples = [];
|
|
65
|
+
for (const example of file.json.examples) {
|
|
66
|
+
if (!validate(example)) {
|
|
67
|
+
valid = false;
|
|
68
|
+
console.log(`${file.fileName} failed validation`);
|
|
69
|
+
console.log(validate.errors);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
t.true(valid);
|
|
74
|
+
});
|