@yahoo/uds 2.11.0 → 3.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.
- package/cli/ButtonFile2.mock.tsx +11 -0
- package/cli/bin/uds-darwin-arm64-baseline +0 -0
- package/cli/bin/uds-linux-arm64 +0 -0
- package/cli/bin/uds-linux-x64-baseline +0 -0
- package/cli/cli.ts +1 -1
- package/cli/codemods/addCommentAboveComponents.ts +9 -3
- package/cli/codemods/flattenButtonVariant.ts +143 -0
- package/cli/codemods/utils/index.ts +1 -1
- package/cli/commands/codemod/flattenButtonVariant.ts +16 -0
- package/cli/commands/expo/_setup.ts +1 -0
- package/cli/commands/sync.ts +3 -0
- package/cli/preload.ts +1 -0
- package/cli/tailwindcss.d.ts +2 -0
- package/cli/tsconfig.json +30 -8
- package/cli/utils/auth.ts +1 -0
- package/cli/utils/configWorker.ts +11 -3
- package/cli/utils/purgeCSS.ts +21 -9
- package/cli/utils/setupConfigWorker.ts +2 -2
- package/cli/utils/sortKeys.ts +5 -0
- package/cli/utils/types.ts +3 -1
- package/dist/{Text-UCDorZDD.d.cts → Text-yeQcITg9.d.cts} +30 -69
- package/dist/{Text-UCDorZDD.d.ts → Text-yeQcITg9.d.ts} +30 -69
- package/dist/VStack-CJs5afN8.d.ts +145 -0
- package/dist/VStack-GpQHE4xQ.d.cts +145 -0
- package/dist/chunk-4G4TBHHL.js +2 -0
- package/dist/chunk-6CVEYTLQ.js +2 -0
- package/dist/chunk-6XNKVFUM.cjs +2 -0
- package/dist/chunk-AFPPCX7S.js +2 -0
- package/dist/chunk-BNLUH23E.cjs +1 -0
- package/dist/chunk-EWJ3J526.js +2 -0
- package/dist/chunk-FOX6Q5GR.cjs +1 -0
- package/dist/chunk-HTL6WRXY.cjs +1 -0
- package/dist/chunk-J7PUOUXC.cjs +1 -0
- package/dist/chunk-N3FKHXEJ.js +2 -0
- package/dist/chunk-NUEZVMWZ.cjs +1 -0
- package/dist/chunk-O26JIFUR.cjs +3 -0
- package/dist/chunk-S5UKKXRV.js +2 -0
- package/dist/chunk-WCB4EHGZ.js +3 -0
- package/dist/client/index.cjs +2 -2
- package/dist/client/index.d.cts +913 -21
- package/dist/client/index.d.ts +913 -21
- package/dist/client/index.js +3 -3
- package/dist/experimental/client/index.cjs +2 -2
- package/dist/experimental/client/index.d.cts +14 -49
- package/dist/experimental/client/index.d.ts +14 -49
- package/dist/experimental/client/index.js +2 -2
- package/dist/experimental/index.cjs +2 -2
- package/dist/experimental/index.d.cts +4 -55
- package/dist/experimental/index.d.ts +4 -55
- package/dist/experimental/index.js +1 -1
- package/dist/fixtures.cjs +1546 -55
- package/dist/fixtures.d.cts +33 -14
- package/dist/fixtures.d.ts +33 -14
- package/dist/fixtures.js +1519 -49
- package/dist/index-CU_UPAew.d.ts +202 -0
- package/dist/index-DUFUMc1S.d.cts +202 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +245 -128
- package/dist/index.d.ts +245 -128
- package/dist/index.js +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/tailwind/plugin.cjs +1 -2
- package/dist/tailwind/plugin.d.cts +19 -5
- package/dist/tailwind/plugin.d.ts +19 -5
- package/dist/tailwind/plugin.js +2 -2
- package/dist/tailwind/purger.cjs +1 -1
- package/dist/tailwind/purger.js +2 -2
- package/dist/tailwind/tsMorph.cjs +1 -1
- package/dist/tailwind/tsMorph.js +1 -1
- package/dist/tailwind/utils.cjs +1 -1
- package/dist/tailwind/utils.d.cts +80 -28
- package/dist/tailwind/utils.d.ts +80 -28
- package/dist/tailwind/utils.js +1 -1
- package/dist/tokens/automation/configs.cjs +1 -0
- package/dist/tokens/automation/configs.d.cts +110 -0
- package/dist/tokens/automation/configs.d.ts +110 -0
- package/dist/tokens/automation/configs.js +1 -0
- package/dist/tokens/automation/properties.cjs +1 -0
- package/dist/tokens/automation/properties.d.cts +7 -0
- package/dist/tokens/automation/properties.d.ts +7 -0
- package/dist/tokens/automation/properties.js +1 -0
- package/dist/tokens/index.cjs +1 -1
- package/dist/tokens/index.d.cts +9355 -15
- package/dist/tokens/index.d.ts +9355 -15
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/parseTokens.cjs +1 -1
- package/dist/tokens/parseTokens.d.cts +7 -23
- package/dist/tokens/parseTokens.d.ts +7 -23
- package/dist/tokens/parseTokens.js +1 -1
- package/dist/types-d2CfR7zp.d.cts +10245 -0
- package/dist/types-d2CfR7zp.d.ts +10245 -0
- package/package.json +15 -2
- package/dist/chunk-3G7IRLGN.js +0 -2
- package/dist/chunk-5WBROFT5.cjs +0 -1
- package/dist/chunk-6453EQCC.cjs +0 -1
- package/dist/chunk-7QHJ6LHA.js +0 -1
- package/dist/chunk-EYFQOFYW.cjs +0 -1
- package/dist/chunk-FWF2C6TL.cjs +0 -1
- package/dist/chunk-FYVGDNGL.js +0 -2
- package/dist/chunk-GIJ2FHY5.cjs +0 -1
- package/dist/chunk-GL5JI7EX.cjs +0 -2
- package/dist/chunk-MOUM7BAW.js +0 -2
- package/dist/chunk-PE2P7J44.js +0 -2
- package/dist/chunk-RXSJCGB3.cjs +0 -1
- package/dist/chunk-SUASN3GG.js +0 -2
- package/dist/chunk-U2K4DT7E.js +0 -3
- package/dist/chunk-VPR62GYQ.js +0 -2
- package/dist/chunk-WJ55DEUW.cjs +0 -2
- package/dist/chunk-X6F5UEQ5.js +0 -2
- package/dist/chunk-XZCEFUNX.cjs +0 -2
- package/dist/types-DPT0rst4.d.cts +0 -991
- package/dist/types-DPT0rst4.d.ts +0 -991
- /package/dist/{motionFeatures-HQUM526D.cjs → motionFeatures-6LIGGXPL.cjs} +0 -0
- /package/dist/{motionFeatures-PRT45UQH.js → motionFeatures-SJISLQ4M.js} +0 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Button, IconButton } from 'another-package';
|
2
|
+
import { Link } from '@yahoo/uds-icons';
|
3
|
+
|
4
|
+
export const PageB = () => {
|
5
|
+
return (
|
6
|
+
<Button>Click me</Button>
|
7
|
+
<Button type="button">Click me</Button>
|
8
|
+
<Button type="submit">Click me</Button>
|
9
|
+
<IconButton icon={Link} />
|
10
|
+
);
|
11
|
+
}
|
Binary file
|
package/cli/bin/uds-linux-arm64
CHANGED
Binary file
|
Binary file
|
package/cli/cli.ts
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
import { IndentationText, Project } from 'ts-morph';
|
2
2
|
|
3
|
-
import {
|
4
|
-
|
3
|
+
import {
|
4
|
+
getGlobPattern,
|
5
|
+
getImportsFromPackage,
|
6
|
+
getJSXElements,
|
7
|
+
getProject,
|
8
|
+
hasJSXProperty,
|
9
|
+
matchesJSXTagName,
|
10
|
+
} from './utils';
|
5
11
|
|
6
12
|
interface LineInfo {
|
7
13
|
linePos: number;
|
@@ -63,7 +69,7 @@ export async function addCommentAboveComponents({
|
|
63
69
|
});
|
64
70
|
|
65
71
|
const updateSrc = srcLines.join('\n');
|
66
|
-
console.log(updateSrc);
|
72
|
+
// console.log(updateSrc);
|
67
73
|
sourceFile.replaceWithText(updateSrc);
|
68
74
|
}
|
69
75
|
});
|
@@ -0,0 +1,143 @@
|
|
1
|
+
import { Project, SyntaxKind } from 'ts-morph';
|
2
|
+
|
3
|
+
import { ButtonPalette, ButtonVariant, ButtonVariantFlat } from '~/tokens';
|
4
|
+
|
5
|
+
import { getGlobPattern, getImportsFromPackage, getProject } from './utils';
|
6
|
+
|
7
|
+
const buttonFlatValMap: Record<ButtonVariantFlat, ButtonVariantFlat> = {
|
8
|
+
primary: 'primary',
|
9
|
+
secondary: 'secondary',
|
10
|
+
tertiary: 'tertiary',
|
11
|
+
brand: 'brand',
|
12
|
+
alert: 'alert',
|
13
|
+
positive: 'positive',
|
14
|
+
warning: 'warning',
|
15
|
+
info: 'info',
|
16
|
+
'brand-secondary': 'brand-secondary',
|
17
|
+
'brand-tertiary': 'brand-tertiary',
|
18
|
+
'alert-secondary': 'alert-secondary',
|
19
|
+
'alert-tertiary': 'alert-tertiary',
|
20
|
+
'positive-secondary': 'positive-secondary',
|
21
|
+
'positive-tertiary': 'positive-tertiary',
|
22
|
+
'warning-secondary': 'warning-secondary',
|
23
|
+
'warning-tertiary': 'warning-tertiary',
|
24
|
+
'info-secondary': 'info-secondary',
|
25
|
+
'info-tertiary': 'info-tertiary',
|
26
|
+
};
|
27
|
+
|
28
|
+
// This is a hack to typecheck the keys of the object, ensure that all of the values are present
|
29
|
+
// NOTE: Importing fixtures still causes issues
|
30
|
+
const buttonVariantsFlat = Object.values(buttonFlatValMap);
|
31
|
+
|
32
|
+
function parseButtonVariantFlat({
|
33
|
+
palette = 'accent',
|
34
|
+
variant = 'primary',
|
35
|
+
}: {
|
36
|
+
palette?: ButtonPalette;
|
37
|
+
variant?: ButtonVariant;
|
38
|
+
}): ButtonVariantFlat {
|
39
|
+
if (palette === 'accent') {
|
40
|
+
return variant; // primary, secondary, tertiary
|
41
|
+
}
|
42
|
+
|
43
|
+
if (variant === 'primary') {
|
44
|
+
return palette; // brand, alert, positive, warning
|
45
|
+
}
|
46
|
+
|
47
|
+
return `${palette}-${variant}`; // brand-secondary, alert-tertiary, etc.
|
48
|
+
}
|
49
|
+
|
50
|
+
interface Options {
|
51
|
+
selectedDirs?: string[];
|
52
|
+
project?: Project;
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Flatten palette and variant into a single variant prop for UDS Button and IconButton.
|
57
|
+
*/
|
58
|
+
export async function flattenButtonVariant({ selectedDirs, project = getProject() }: Options) {
|
59
|
+
const glob = getGlobPattern(selectedDirs);
|
60
|
+
const sourceFiles = project.getSourceFiles(glob);
|
61
|
+
|
62
|
+
for (const sourceFile of sourceFiles) {
|
63
|
+
// Get UDS imports from '@yahoo/uds'
|
64
|
+
const importUdsComponents = getImportsFromPackage(sourceFile, '@yahoo/uds');
|
65
|
+
|
66
|
+
// Only process files that import Button or IconButton
|
67
|
+
if (!importUdsComponents.has('Button') && !importUdsComponents.has('IconButton')) {
|
68
|
+
continue;
|
69
|
+
}
|
70
|
+
|
71
|
+
// Process both JsxOpeningElement and JsxSelfClosingElement nodes.
|
72
|
+
const jsxElements = [
|
73
|
+
...sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),
|
74
|
+
...sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement),
|
75
|
+
].filter((el) => {
|
76
|
+
const tagName = el.getTagNameNode().getText();
|
77
|
+
return (tagName === 'Button' || tagName === 'IconButton') && importUdsComponents.has(tagName);
|
78
|
+
});
|
79
|
+
|
80
|
+
jsxElements.forEach((jsxEl) => {
|
81
|
+
// Get palette and variant attributes
|
82
|
+
const paletteAttr = jsxEl.getAttribute('palette');
|
83
|
+
const variantAttr = jsxEl.getAttribute('variant');
|
84
|
+
|
85
|
+
// Prepare to capture literal values.
|
86
|
+
let paletteLiteral: string | undefined;
|
87
|
+
let variantLiteral: string;
|
88
|
+
|
89
|
+
// Process palette attribute
|
90
|
+
if (paletteAttr) {
|
91
|
+
// @ts-expect-error - getInitializer() is not in the type definition
|
92
|
+
const initializer = paletteAttr.getInitializer();
|
93
|
+
if (initializer && initializer.getKind() === SyntaxKind.StringLiteral) {
|
94
|
+
paletteLiteral = initializer.getText().slice(1, -1);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
// Process variant attribute
|
99
|
+
if (variantAttr) {
|
100
|
+
// @ts-expect-error - getInitializer() is not in the type definition
|
101
|
+
const initializer = variantAttr.getInitializer();
|
102
|
+
if (initializer && initializer.getKind() === SyntaxKind.StringLiteral) {
|
103
|
+
variantLiteral = initializer.getText().slice(1, -1);
|
104
|
+
} else {
|
105
|
+
variantLiteral = 'primary';
|
106
|
+
}
|
107
|
+
} else {
|
108
|
+
variantLiteral = 'primary';
|
109
|
+
}
|
110
|
+
|
111
|
+
// Remove the old palette and variant attributes.
|
112
|
+
if (paletteAttr) {
|
113
|
+
paletteAttr.remove();
|
114
|
+
}
|
115
|
+
if (variantAttr) {
|
116
|
+
variantAttr.remove();
|
117
|
+
}
|
118
|
+
|
119
|
+
if (!paletteLiteral && buttonVariantsFlat.includes(variantLiteral as ButtonVariantFlat)) {
|
120
|
+
// If the variant is already a valid flattened value, use it as is.
|
121
|
+
if (variantLiteral !== 'primary') {
|
122
|
+
// If its "primary", just remove all the props
|
123
|
+
jsxEl.addAttribute({
|
124
|
+
name: 'variant',
|
125
|
+
initializer: `"${variantLiteral}"`,
|
126
|
+
});
|
127
|
+
}
|
128
|
+
} else {
|
129
|
+
// Compute the flattened variant using the parsing function.
|
130
|
+
const flattened = parseButtonVariantFlat({
|
131
|
+
palette: paletteLiteral as ButtonPalette,
|
132
|
+
variant: variantLiteral as ButtonVariant,
|
133
|
+
});
|
134
|
+
|
135
|
+
jsxEl.addAttribute({
|
136
|
+
name: 'variant',
|
137
|
+
initializer: `"${flattened}"`,
|
138
|
+
});
|
139
|
+
}
|
140
|
+
});
|
141
|
+
}
|
142
|
+
await project.save();
|
143
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* ------------------- GENERATED | DO NOT MODIFY THIS
|
2
|
+
* ------------------- GENERATED | DO NOT MODIFY THIS SECTION ------------------
|
3
3
|
* This file uses eslint-plugin-codegen to automatically watch for changes in
|
4
4
|
* the `src/components` directory and updates this barrel file.
|
5
5
|
*/
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { type Props, spinStart, spinStop } from 'bluebun';
|
2
|
+
|
3
|
+
import { flattenButtonVariant } from '../../codemods/flattenButtonVariant';
|
4
|
+
|
5
|
+
export default {
|
6
|
+
name: 'flattenButtonVariant',
|
7
|
+
description: `Flatten deprecated button props into single variant prop`,
|
8
|
+
|
9
|
+
run: async (props: Props & { selectedDirs?: string[] }) => {
|
10
|
+
spinStart('Running codemod...');
|
11
|
+
|
12
|
+
await flattenButtonVariant({ selectedDirs: props.selectedDirs });
|
13
|
+
|
14
|
+
spinStop('Codemod complete! Peek the diff and commit your changes!');
|
15
|
+
},
|
16
|
+
};
|
@@ -2,6 +2,7 @@ import fs from 'node:fs';
|
|
2
2
|
import os from 'node:os';
|
3
3
|
|
4
4
|
// @ts-expect-error this is a transitive dep of expo, which is required in consumers to even run this setup
|
5
|
+
// eslint-disable-next-line import/no-unresolved
|
5
6
|
import { EasJsonAccessor, EasJsonUtils, Platform } from '@expo/eas-json';
|
6
7
|
import { print, type Props } from 'bluebun';
|
7
8
|
import { $, semver, which } from 'bun';
|
package/cli/commands/sync.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { magenta, print, Props } from 'bluebun';
|
2
2
|
|
3
|
+
import packageJson from '../../package.json';
|
3
4
|
import { trackEvent } from '../utils/analytics';
|
4
5
|
import { setupConfigWorker } from '../utils/setupConfigWorker';
|
5
6
|
import { SyncOptions } from '../utils/types';
|
@@ -22,10 +23,12 @@ export default {
|
|
22
23
|
print(`${magenta('Usage:')} ${name} ${commandPath} --id <config-id>\n`);
|
23
24
|
return;
|
24
25
|
}
|
26
|
+
|
25
27
|
try {
|
26
28
|
await setupConfigWorker({
|
27
29
|
id,
|
28
30
|
outFile: outFile ?? './uds.config.ts',
|
31
|
+
version: packageJson.version,
|
29
32
|
onUpdate: ({ worker }) => {
|
30
33
|
if (!options.watch) {
|
31
34
|
worker.terminate();
|
package/cli/preload.ts
CHANGED
package/cli/tsconfig.json
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
3
3
|
"display": "Default",
|
4
|
-
"include": [
|
5
|
-
|
4
|
+
"include": [
|
5
|
+
"."
|
6
|
+
],
|
7
|
+
"exclude": [
|
8
|
+
"node_modules"
|
9
|
+
],
|
6
10
|
"compilerOptions": {
|
7
11
|
"composite": false,
|
8
12
|
"declaration": true,
|
@@ -16,16 +20,34 @@
|
|
16
20
|
"preserveWatchOutput": true,
|
17
21
|
"skipLibCheck": true,
|
18
22
|
"strict": true,
|
19
|
-
"types": [
|
23
|
+
"types": [
|
24
|
+
"bun-types"
|
25
|
+
],
|
20
26
|
"target": "esnext",
|
21
|
-
"lib": [
|
27
|
+
"lib": [
|
28
|
+
"ESNext"
|
29
|
+
],
|
22
30
|
"module": "esnext",
|
23
31
|
"moduleResolution": "bundler",
|
24
32
|
"paths": {
|
25
|
-
"
|
26
|
-
|
27
|
-
|
28
|
-
"
|
33
|
+
"~/*": [
|
34
|
+
"../src/*"
|
35
|
+
],
|
36
|
+
"@yahoo/uds/scripts/*": [
|
37
|
+
"../scripts/*"
|
38
|
+
],
|
39
|
+
// "@yahoo/uds/tokens": [
|
40
|
+
// "../src/tokens/index.ts"
|
41
|
+
// ],
|
42
|
+
"@yahoo/uds/tailwind/purger": [
|
43
|
+
"../src/tailwind/purger/index.ts"
|
44
|
+
],
|
45
|
+
"@yahoo/uds/tailwind/tsMorph": [
|
46
|
+
"../scripts/utils/tsMorph.ts"
|
47
|
+
],
|
48
|
+
"root/*": [
|
49
|
+
"../../*"
|
50
|
+
]
|
29
51
|
}
|
30
52
|
}
|
31
53
|
}
|
package/cli/utils/auth.ts
CHANGED
@@ -8,7 +8,7 @@ import { eq, gte } from 'semver';
|
|
8
8
|
import { ConfigWorkerThreadMessageEvent } from './types';
|
9
9
|
|
10
10
|
const PRODUCTION_PREFIX = 'https://config.uds.build';
|
11
|
-
const STAGING_PREFIX = 'https://staging.uds.build';
|
11
|
+
const STAGING_PREFIX = 'https://staging.config.uds.build';
|
12
12
|
const LOCAL_PORT = process.env.PORT || 4001;
|
13
13
|
const LOCAL_PREFIX = `http://localhost:${LOCAL_PORT}`;
|
14
14
|
|
@@ -31,8 +31,8 @@ if (process.env.DATABASE === 'local') {
|
|
31
31
|
}
|
32
32
|
|
33
33
|
self.onmessage = async ({ data }: ConfigWorkerThreadMessageEvent) => {
|
34
|
-
const { id } = data.resp;
|
35
|
-
const FETCH_URL = `${CONFIG_ENDPOINT}?id=${id}`;
|
34
|
+
const { id, version } = data.resp;
|
35
|
+
const FETCH_URL = `${CONFIG_ENDPOINT}?id=${id}&version=${version}`;
|
36
36
|
if (data.type === 'init') {
|
37
37
|
try {
|
38
38
|
console.log('Fetching from configurator...');
|
@@ -50,6 +50,14 @@ self.onmessage = async ({ data }: ConfigWorkerThreadMessageEvent) => {
|
|
50
50
|
`);
|
51
51
|
}
|
52
52
|
|
53
|
+
// Needs upgrade
|
54
|
+
if (resp.status === 402) {
|
55
|
+
throw new Error(`
|
56
|
+
${resp.status} error: ${resp.statusText}\n
|
57
|
+
This usually means you need to upgrade the npm package @yahoo/uds to the latest version.
|
58
|
+
`);
|
59
|
+
}
|
60
|
+
|
53
61
|
throw new Error(`Error fetching config id '${id}'. Does it exist in the Configurator?`);
|
54
62
|
}
|
55
63
|
|
package/cli/utils/purgeCSS.ts
CHANGED
@@ -8,14 +8,14 @@ import {
|
|
8
8
|
} from '@yahoo/uds/tailwind/purger';
|
9
9
|
import { findReferencesAsJsxElements, getUsedPropsInReference } from '@yahoo/uds/tailwind/tsMorph';
|
10
10
|
import {
|
11
|
-
ColorModeConfig,
|
11
|
+
type ColorModeConfig,
|
12
12
|
DARK_COLOR_MODE_CLASSNAME,
|
13
13
|
LARGE_SCALE_MODE_CLASSNAME,
|
14
14
|
LIGHT_COLOR_MODE_CLASSNAME,
|
15
15
|
MEDIUM_SCALE_MODE_CLASSNAME,
|
16
|
-
ScaleModeConfig,
|
16
|
+
type ScaleModeConfig,
|
17
17
|
SMALL_SCALE_MODE_CLASSNAME,
|
18
|
-
UniversalTokensConfig,
|
18
|
+
type UniversalTokensConfig,
|
19
19
|
variants,
|
20
20
|
XLARGE_SCALE_MODE_CLASSNAME,
|
21
21
|
XSMALL_SCALE_MODE_CLASSNAME,
|
@@ -182,15 +182,27 @@ export const getTailwindSafelist = (project: Project, componentList: string[]):
|
|
182
182
|
});
|
183
183
|
|
184
184
|
for (const [propName, usedValues] of usedProps) {
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
const variantGroup = variants[propName as keyof typeof variants];
|
186
|
+
if (variantGroup) {
|
187
|
+
usedValues.forEach((option) => {
|
188
|
+
const variantClass = (variantGroup as Record<string, string>)[option];
|
189
|
+
if (variantClass) {
|
190
|
+
safeList.push(variantClass.replaceAll('\\', ''));
|
191
|
+
}
|
192
|
+
});
|
193
|
+
}
|
188
194
|
}
|
189
195
|
|
190
196
|
for (const [variant, variantOptions] of scanGetStylesReferences(project)) {
|
191
|
-
|
192
|
-
|
193
|
-
|
197
|
+
const variantGroup = variants[variant as keyof typeof variants];
|
198
|
+
if (variantGroup) {
|
199
|
+
variantOptions.forEach((option) => {
|
200
|
+
const variantClass = (variantGroup as Record<string, string>)[option];
|
201
|
+
if (variantClass) {
|
202
|
+
safeList.push(variantClass.replaceAll('\\', ''));
|
203
|
+
}
|
204
|
+
});
|
205
|
+
}
|
194
206
|
}
|
195
207
|
|
196
208
|
// Return a deduped list and strip out any empty strings
|
@@ -7,7 +7,7 @@ interface ConfigWorkerOptions extends SyncOptions {
|
|
7
7
|
onUpdate?: (params: { worker: Worker }) => void;
|
8
8
|
}
|
9
9
|
|
10
|
-
export async function setupConfigWorker({ id, outFile, onUpdate }: ConfigWorkerOptions) {
|
10
|
+
export async function setupConfigWorker({ id, outFile, version, onUpdate }: ConfigWorkerOptions) {
|
11
11
|
const workerPath = path.resolve(import.meta.dir, './configWorker');
|
12
12
|
const workerURL = Bun.pathToFileURL(workerPath).href;
|
13
13
|
const outFilePath = `${Bun.env.PWD}/${outFile}`;
|
@@ -22,7 +22,7 @@ export async function setupConfigWorker({ id, outFile, onUpdate }: ConfigWorkerO
|
|
22
22
|
const worker = new Worker(workerURL);
|
23
23
|
|
24
24
|
worker.addEventListener('open', () => {
|
25
|
-
worker.postMessage({ type: 'init', resp: { id } });
|
25
|
+
worker.postMessage({ type: 'init', resp: { id, version } });
|
26
26
|
});
|
27
27
|
|
28
28
|
worker.addEventListener('message', async ({ data }: ConfigWorkerMainThreadMessageEvent) => {
|
package/cli/utils/sortKeys.ts
CHANGED
@@ -2,6 +2,11 @@ export function sortKeys<T extends Record<string, unknown>>(
|
|
2
2
|
unsortedObj: T,
|
3
3
|
): Record<string, unknown> {
|
4
4
|
const sortedObj: Record<string, unknown> = {}; // Add index signature to allow indexing with a string
|
5
|
+
|
6
|
+
if (!unsortedObj || typeof unsortedObj !== 'object') {
|
7
|
+
return unsortedObj;
|
8
|
+
}
|
9
|
+
|
5
10
|
const keys = Object.keys(unsortedObj).sort();
|
6
11
|
|
7
12
|
for (var index in keys) {
|
package/cli/utils/types.ts
CHANGED
@@ -2,7 +2,7 @@ import { type UniversalTokensConfig } from '@yahoo/uds/tokens';
|
|
2
2
|
|
3
3
|
export type ConfigWorkerThreadMessageEvent = Bun.MessageEvent<{
|
4
4
|
type: 'init';
|
5
|
-
resp: { id: string };
|
5
|
+
resp: { id: string; version: string };
|
6
6
|
}>;
|
7
7
|
export type ConfigWorkerMainThreadMessageEvent = Bun.MessageEvent<{
|
8
8
|
type: 'update';
|
@@ -16,4 +16,6 @@ export type SyncOptions = {
|
|
16
16
|
outFile: string;
|
17
17
|
/** Enable watch mode? */
|
18
18
|
watch?: boolean;
|
19
|
+
/** The version of the CLI */
|
20
|
+
version: string;
|
19
21
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { PropsWithChildren, ReactNode, Ref } from 'react';
|
2
2
|
import { SvgIcon, IconSize, IconVariant } from '@yahoo/uds-icons/types';
|
3
3
|
|
4
4
|
declare const alwaysPalette: {
|
@@ -8,22 +8,25 @@ declare const alwaysPalette: {
|
|
8
8
|
current: string;
|
9
9
|
};
|
10
10
|
|
11
|
-
type
|
12
|
-
type
|
13
|
-
type
|
14
|
-
type
|
11
|
+
type SharedPrimaryPaletteAlias = 'brand' | 'alert' | 'positive' | 'warning' | 'info';
|
12
|
+
type SharedSecondaryPaletteAlias = `${SharedPrimaryPaletteAlias}-secondary`;
|
13
|
+
type SharedPaletteAlias = SharedPrimaryPaletteAlias | SharedSecondaryPaletteAlias;
|
14
|
+
type DeprecatedAccentAlias = 'accent';
|
15
|
+
type BackgroundPaletteAlias = 'primary' | 'secondary' | DeprecatedAccentAlias | SharedPaletteAlias;
|
16
|
+
type ForegroundPaletteAlias = 'primary' | 'secondary' | 'tertiary' | 'muted' | 'on-color' | DeprecatedAccentAlias | SharedPaletteAlias;
|
17
|
+
type LinePaletteAlias = 'primary' | 'secondary' | 'tertiary' | 'muted' | DeprecatedAccentAlias | SharedPaletteAlias;
|
15
18
|
type AlwaysPalette = typeof alwaysPalette;
|
16
19
|
type AlwaysPaletteAlias = keyof AlwaysPalette;
|
17
|
-
type ForegroundColor =
|
18
|
-
type LineColor =
|
19
|
-
type BackgroundColor =
|
20
|
-
type
|
20
|
+
type ForegroundColor = ForegroundPaletteAlias | AlwaysPaletteAlias;
|
21
|
+
type LineColor = LinePaletteAlias | AlwaysPaletteAlias;
|
22
|
+
type BackgroundColor = BackgroundPaletteAlias | AlwaysPaletteAlias;
|
23
|
+
type ShadowVariant = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
24
|
+
type ShadowVariantInvert = `${Exclude<ShadowVariant, 'none'>}-invert`;
|
25
|
+
type TextVariant = 'display1' | 'display2' | 'display3' | 'title1' | 'title2' | 'title3' | 'title4' | 'headline1' | 'body1' | 'label1' | 'label2' | 'label3' | 'label4' | 'caption1' | 'caption2' | 'legal1';
|
21
26
|
type FontAlias = 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono';
|
22
27
|
type FontWeightDescriptive = 'thin' | 'extralight' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'extrabold' | 'black';
|
23
28
|
type TextTransform = 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
24
29
|
type TShirtSize = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
25
|
-
type TShirtSizeCommon = Extract<TShirtSize, 'sm' | 'md' | 'lg'>;
|
26
|
-
type AvatarSize = TShirtSizeCommon;
|
27
30
|
type SpacingAlias = '0' | 'px' | '0.5' | '1' | '1.5' | '2' | '2.5' | '3' | '3.5' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '14' | '16' | '20' | '24' | '28' | '32' | '36' | '40' | '44' | '48' | '52' | '56' | '60' | '64' | '72' | '80' | '96';
|
28
31
|
type BorderRadius = TShirtSize;
|
29
32
|
type BorderWidth = 'none' | 'thin' | 'medium' | 'thick';
|
@@ -40,12 +43,6 @@ type FlexBasis = 'min-content';
|
|
40
43
|
type Display = 'block' | 'inline-block' | 'inline' | 'flex' | 'inline-flex' | 'table' | 'inline-table' | 'table-caption' | 'table-cell' | 'table-column' | 'table-column-group' | 'table-footer-group' | 'table-header-group' | 'table-row-group' | 'table-row' | 'flow-root' | 'grid' | 'contents';
|
41
44
|
type Overflow = 'auto' | 'hidden' | 'clip' | 'visible' | 'scroll';
|
42
45
|
type Position = 'static' | 'fixed' | 'absolute' | 'relative' | 'sticky';
|
43
|
-
type ImageStyleProps = {
|
44
|
-
/**
|
45
|
-
* Determines how the image should be resized to fit its container.
|
46
|
-
*/
|
47
|
-
contentFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
48
|
-
};
|
49
46
|
interface BorderStyleProps {
|
50
47
|
/** Add a border radius to all corners of the box. */
|
51
48
|
borderRadius?: BorderRadius;
|
@@ -82,6 +79,12 @@ interface BorderStyleProps {
|
|
82
79
|
/** Sets the width of the bottom border of an element. */
|
83
80
|
borderBottomWidth?: BorderWidth;
|
84
81
|
}
|
82
|
+
interface ShadowStyleProps {
|
83
|
+
/** Sets the variant of the shadow. */
|
84
|
+
dropShadow?: ShadowVariant;
|
85
|
+
/** Sets the variant of the inset shadow. */
|
86
|
+
insetShadow?: ShadowVariant | ShadowVariantInvert;
|
87
|
+
}
|
85
88
|
interface LayoutStyleProps {
|
86
89
|
/** Sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex. */
|
87
90
|
display?: Display;
|
@@ -178,7 +181,7 @@ interface SizeStyleProps {
|
|
178
181
|
/** Sets the height of an element. */
|
179
182
|
height?: 'full' | 'fit' | 'screen';
|
180
183
|
}
|
181
|
-
interface UniversalBoxProps extends PropsWithChildren, BackgroundStyleProps, BorderStyleProps, FlexStyleProps, LayoutStyleProps, SpacingStyleProps, SizeStyleProps {
|
184
|
+
interface UniversalBoxProps extends PropsWithChildren, BackgroundStyleProps, BorderStyleProps, FlexStyleProps, LayoutStyleProps, SpacingStyleProps, SizeStyleProps, ShadowStyleProps {
|
182
185
|
/**
|
183
186
|
* When asChild is set to true, the component's child will be cloned and passed
|
184
187
|
* the props and behavior required to make it functional.
|
@@ -205,66 +208,24 @@ interface UniversalIconProps {
|
|
205
208
|
/** Color of the icon. */
|
206
209
|
color?: ForegroundColor;
|
207
210
|
}
|
208
|
-
|
209
|
-
|
210
|
-
src: string;
|
211
|
-
/** Provides fallback (alternate) text to display when the image specified by the Image element is not loaded. */
|
212
|
-
alt?: string;
|
213
|
-
/** Width of the image in px. */
|
214
|
-
width?: number;
|
215
|
-
/** Height of the image in pixel. */
|
216
|
-
height?: number;
|
217
|
-
}
|
218
|
-
interface UniversalAvatarProps extends UniversalImageProps {
|
219
|
-
/** The size of the Avatar. */
|
220
|
-
size?: AvatarSize;
|
221
|
-
/** The shape of the Avatar. */
|
222
|
-
shape?: BorderRadius;
|
223
|
-
}
|
224
|
-
interface UniversalTextInputProps {
|
225
|
-
disabled?: boolean;
|
226
|
-
required?: boolean;
|
227
|
-
backgroundColor?: BackgroundColor;
|
228
|
-
borderColor?: LineColor;
|
229
|
-
borderWidth?: BorderWidth;
|
230
|
-
borderRadius?: BorderRadius;
|
231
|
-
color?: ForegroundColor;
|
232
|
-
fontSize?: TextVariant;
|
233
|
-
placeholderColor?: ForegroundColor;
|
234
|
-
spacingVertical?: SpacingAlias;
|
235
|
-
spacingHorizontal?: SpacingAlias;
|
236
|
-
}
|
237
|
-
type DividerVariant = 'primary' | 'secondary' | 'tertiary' | 'muted';
|
238
|
-
interface UniversalDividerProps {
|
239
|
-
/**
|
240
|
-
* Use a pre-defined variant.
|
241
|
-
* @default 'primary'
|
242
|
-
*/
|
243
|
-
variant?: DividerVariant;
|
244
|
-
/**
|
245
|
-
* Set to true to scale the divider vertically.
|
246
|
-
*/
|
247
|
-
vertical?: boolean;
|
248
|
-
/** Override thickness of the divider set by the variant. */
|
249
|
-
thickness?: BorderWidth;
|
250
|
-
/** Override color of the divider set by the variant. */
|
251
|
-
color?: LineColor;
|
252
|
-
/** When there are children, where are they placed?
|
253
|
-
* @default 'middle'
|
254
|
-
*/
|
255
|
-
contentPosition?: 'start' | 'middle' | 'end';
|
211
|
+
type SVGElementProps = Omit<React.HTMLAttributes<SVGSVGElement>, 'color'>;
|
212
|
+
interface IconPropsWithSVGProps extends UniversalIconProps, SVGElementProps {
|
256
213
|
}
|
257
214
|
|
258
215
|
type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
259
216
|
interface BoxProps extends UniversalBoxProps, DivProps {
|
260
217
|
}
|
261
218
|
|
262
|
-
type TextElementTagName = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'p' | 'strong' | 'span' | 'label' | 'li';
|
219
|
+
type TextElementTagName = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'p' | 'strong' | 'span' | 'label' | 'li' | 'sup';
|
220
|
+
type ColorWithInherit = Exclude<UniversalTextProps['color'], undefined> | 'inherit';
|
221
|
+
type VariantWithInherit = Exclude<UniversalTextProps['variant'], undefined> | 'inherit';
|
263
222
|
type TextProps<TagName extends TextElementTagName = TextElementTagName> = {
|
264
223
|
/** Ref passed to the inner container. */
|
265
224
|
ref?: Ref<HTMLElement>;
|
266
225
|
/** Changes the HTML tag used to render text. Uses the most appropriate semantic tag based on the text style variant. */
|
267
226
|
as?: TagName;
|
268
|
-
|
227
|
+
variant?: VariantWithInherit;
|
228
|
+
color?: ColorWithInherit;
|
229
|
+
} & JSX.IntrinsicElements[TagName] & Omit<UniversalTextProps, 'variant' | 'color'>;
|
269
230
|
|
270
|
-
export type { BoxProps as B, DivProps as D,
|
231
|
+
export type { BoxProps as B, DivProps as D, IconPropsWithSVGProps as I, Overflow as O, TextProps as T, UniversalTextProps as U, UniversalStackProps as a };
|