@yahoo/uds 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/cli/PropsToClass.mock.tsx +14 -0
  2. package/cli/bin/uds-darwin-arm64-baseline +0 -0
  3. package/cli/bin/uds-linux-arm64 +0 -0
  4. package/cli/bin/uds-linux-x64-baseline +0 -0
  5. package/cli/cli.ts +1 -2
  6. package/cli/utils/auth.ts +39 -202
  7. package/dist/Text-CwmyqrBk.d.cts +243 -0
  8. package/dist/Text-CwmyqrBk.d.ts +243 -0
  9. package/dist/client/index.cjs +2 -2
  10. package/dist/client/index.d.cts +46 -6
  11. package/dist/client/index.d.ts +46 -6
  12. package/dist/client/index.js +3 -3
  13. package/dist/experimental/client/index.cjs +3 -0
  14. package/dist/experimental/client/index.d.cts +146 -0
  15. package/dist/experimental/client/index.d.ts +146 -0
  16. package/dist/experimental/client/index.js +3 -0
  17. package/dist/experimental/index.cjs +2 -2
  18. package/dist/experimental/index.d.cts +5 -387
  19. package/dist/experimental/index.d.ts +5 -387
  20. package/dist/experimental/index.js +1 -2
  21. package/dist/fixtures.cjs +1 -1
  22. package/dist/fixtures.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +4 -42
  25. package/dist/index.d.ts +4 -42
  26. package/dist/index.js +1 -1
  27. package/dist/metafile-cjs.json +1 -1
  28. package/dist/metafile-esm.json +1 -1
  29. package/dist/tailwind/plugin.cjs +2 -2
  30. package/dist/tailwind/plugin.d.cts +1 -1
  31. package/dist/tailwind/plugin.d.ts +1 -1
  32. package/dist/tailwind/plugin.js +2 -2
  33. package/dist/tailwind/purger.cjs +1 -1
  34. package/dist/tailwind/purger.js +1 -1
  35. package/dist/tailwind/utils.d.cts +1 -1
  36. package/dist/tailwind/utils.d.ts +1 -1
  37. package/dist/tokens/index.d.cts +2 -2
  38. package/dist/tokens/index.d.ts +2 -2
  39. package/dist/tokens/parseTokens.d.cts +1 -1
  40. package/dist/tokens/parseTokens.d.ts +1 -1
  41. package/dist/{types-Pyccco5Q.d.cts → types-DsMvZpWN.d.cts} +1 -1
  42. package/dist/{types-Pyccco5Q.d.ts → types-DsMvZpWN.d.ts} +1 -1
  43. package/package.json +13 -6
  44. package/cli/README.md +0 -208
  45. package/cli/utils/client_secrets.json +0 -23
  46. package/cli/utils/client_secrets.json.enc +0 -0
  47. package/cli/utils/secrets.ts +0 -40
@@ -0,0 +1,14 @@
1
+ import { Button, cx, HStack, Text } from '@yahoo/uds';
2
+ const textClassName = cx('text-primary');
3
+ const otherProps = { height: 'fit' };
4
+
5
+ export const PageA = () => {
6
+ return (
7
+ <HStack className="w-full max-h-screen">
8
+ <Button className="min-w-full">Click me</Button>
9
+ {/* 🙏 TODO: Add w-10/12 to your className attribute */}
10
+ <Text className={textClassName}>Some text</Text>
11
+ <Text {...otherProps}>Some text</Text>
12
+ </HStack>
13
+ );
14
+ }
Binary file
Binary file
Binary file
package/cli/cli.ts CHANGED
@@ -12,10 +12,9 @@ const EXEMPT_FROM_AUTH = ['login'];
12
12
 
13
13
  async function main() {
14
14
  if (process.env.CI !== '1') {
15
- updateNotifier({
15
+ await updateNotifier({
16
16
  pkg: packageJson,
17
17
  shouldNotifyInNpmScript: true,
18
- alwaysRun: true,
19
18
  });
20
19
  }
21
20
 
package/cli/utils/auth.ts CHANGED
@@ -1,179 +1,47 @@
1
+ import child_process from 'node:child_process';
1
2
  import { unlink } from 'node:fs/promises';
2
3
  import path from 'node:path';
4
+ import util from 'node:util';
3
5
 
4
- import { print, red } from 'bluebun';
6
+ import { ask, print, red } from 'bluebun';
5
7
  import Bun from 'bun';
6
- import { getApps, initializeApp } from 'firebase/app';
7
- import {
8
- connectAuthEmulator,
9
- getAuth,
10
- GoogleAuthProvider,
11
- signInWithCredential,
12
- } from 'firebase/auth';
13
- import { google, oauth2_v2 } from 'googleapis';
14
- import http from 'http';
15
- import open from 'open';
16
8
  import { type FirebaseUser } from 'root/database/firebase';
17
9
  import { v5 as uuidv5 } from 'uuid';
18
10
 
19
- import clientSecrets from './client_secrets.json';
11
+ const exec = util.promisify(child_process.exec);
20
12
 
21
- type User = oauth2_v2.Schema$Userinfo | FirebaseUser;
22
- type LoginProvider = 'google' | 'firebase' | 'configurator';
23
-
24
- const LOGIN_PROVIDER: LoginProvider =
25
- (process.env.LOGIN_PROVIDER as LoginProvider) ?? 'configurator';
26
-
27
- const REDIRECT_URL = clientSecrets.web.redirect_uris[0];
28
- const { port: PORT, origin: SERVER_ORIGIN } = new URL(REDIRECT_URL);
29
-
30
- const configuratorUrlOrigin =
31
- process.env.NODE_ENV === 'development' ? 'http://localhost:4001' : 'https://config.uds.build';
13
+ type User = Partial<FirebaseUser>;
32
14
 
33
15
  const CACHE_FILEPATH = '.uds/user.json';
34
16
  const DEFAULT_CLI_PATH = path.resolve(import.meta.dir, '..');
35
17
  const CACHED_USER_FILE = path.resolve(DEFAULT_CLI_PATH, CACHE_FILEPATH);
36
18
 
37
- const isEmulator = process.env.EMULATOR || process.env.NEXT_PUBLIC_EMULATOR;
38
-
39
- // TODO: consolidate with the firebase config and setup in database/firebase.ts
40
- const firebaseConfig = !isEmulator
41
- ? clientSecrets.firebaseConfig
42
- : {
43
- projectId: 'uds-poc',
44
- apiKey: 'DUMMY_API_KEY',
45
- authDomain: 'uds-poc.firebaseapp.com',
46
- };
47
-
48
- const firebaseApp = getApps().length === 0 ? initializeApp(firebaseConfig) : getApps()[0];
49
- const auth = getAuth(firebaseApp);
50
-
51
- if (isEmulator) {
52
- connectAuthEmulator(auth, 'http://127.0.0.1:9099');
53
- }
54
-
55
- // Credentials can be found in https://console.cloud.google.com/apis/credentials/oauthclient/700524957090-6uju02gp6i0rlm3p17nt1v6vbrretfka.apps.googleusercontent.com?project=uds-poc.
56
- const oauth2Client = new google.auth.OAuth2(
57
- clientSecrets.web.client_id,
58
- clientSecrets.web.client_secret,
59
- REDIRECT_URL,
60
- );
61
-
62
- function isYahooEmployee(user?: User) {
63
- return user?.email?.endsWith('@yahooinc.com');
64
- }
65
-
66
- function getAuthorizeUrl(loginProvider = LOGIN_PROVIDER) {
67
- if (loginProvider === 'configurator') {
68
- return `${configuratorUrlOrigin}/login?continue=${REDIRECT_URL}`;
69
- }
70
-
71
- return oauth2Client.generateAuthUrl({
72
- access_type: 'offline',
73
- scope: [
74
- 'https://www.googleapis.com/auth/userinfo.profile',
75
- 'https://www.googleapis.com/auth/userinfo.email',
76
- ].join(' '),
77
- hd: 'yahooinc.com',
78
- include_granted_scopes: true,
79
- });
80
- }
81
-
82
- function onPostHandler(
83
- this: http.Server,
84
- req: http.IncomingMessage,
85
- res: http.ServerResponse,
86
- resolve: (user: User) => void,
87
- reject: (reason?: unknown) => void,
88
- ) {
89
- const corsHeaders = {
90
- 'Access-Control-Allow-Origin': configuratorUrlOrigin,
91
- 'Access-Control-Allow-Methods': 'OPTIONS, POST',
92
- 'Access-Control-Allow-Headers': '*',
93
- 'Access-Control-Request-Method': '*',
94
- };
95
-
96
- for (const [header, value] of Object.entries(corsHeaders)) {
97
- res.setHeader(header, value);
98
- }
99
-
100
- if (req.headers.origin !== configuratorUrlOrigin) {
101
- res.writeHead(405).end(`Request origin not allowed.`);
102
- reject(`Request origin not allowed.`);
103
- return;
104
- }
105
-
106
- if (req.method === 'OPTIONS') {
107
- res.writeHead(204).end();
108
- return;
109
- }
110
-
111
- if (req.method !== 'POST') {
112
- // Set the 405 status and Allow header
113
- res.writeHead(405, { Allow: 'POST' }).end('Method Not Allowed');
114
- reject('Method Not Allowed');
115
- return;
116
- }
117
-
118
- let data = '';
119
-
120
- req.on('data', (chunk) => {
121
- data += chunk.toString();
122
- });
123
-
124
- req.on('error', (err: NodeJS.ErrnoException) => {
125
- reject(err);
126
- });
19
+ async function getGitEmail(scope: 'local' | 'global' | 'system' = 'global') {
20
+ let email;
21
+ try {
22
+ const { stdout, stderr } = await exec(`git config --${scope} user.email`);
127
23
 
128
- req.on('end', () => {
129
- try {
130
- const user: FirebaseUser = JSON.parse(data);
131
- res.end('Authentication successful! Please close this window.');
132
- resolve(user);
133
- } catch (err) {
134
- reject(err);
135
- } finally {
136
- this.close();
24
+ if (stderr) {
25
+ throw new Error(`Git config error: ${stderr}`);
137
26
  }
138
- });
139
- }
140
-
141
- async function onGETHandler(
142
- this: http.Server,
143
- req: http.IncomingMessage,
144
- res: http.ServerResponse,
145
- resolve: (user: User) => void,
146
- reject: (reason?: unknown) => void,
147
- ) {
148
- try {
149
- const code = new URL(req.url || '', SERVER_ORIGIN).searchParams.get('code');
150
- if (!code) {
151
- res.end('There was no code parameter on the url.');
152
- this.close();
153
- return;
27
+ email = stdout.trim();
28
+ if (!isYahooEmployee({ email })) {
29
+ throw new Error(`Git config email is not a @yahooinc.com email address.`);
154
30
  }
31
+ } catch {
32
+ email = await ask('Please enter your @yahooinc.com email address:', {
33
+ validation: (answer) => {
34
+ const warning = red(`🚨 Email was not a @yahooinc.com address.`);
35
+ return isYahooEmployee({ email: answer }) || warning;
36
+ },
37
+ });
38
+ }
155
39
 
156
- res.end('Authentication successful! Please close this window.');
157
- this.close();
158
-
159
- const { tokens } = await oauth2Client.getToken(code);
160
- oauth2Client.setCredentials(tokens);
161
-
162
- let user: User;
163
-
164
- if (LOGIN_PROVIDER === 'firebase') {
165
- // Build Firebase credential using the Google ID token.
166
- const credential = GoogleAuthProvider.credential(tokens.id_token);
167
- user = (await signInWithCredential(auth, credential)).user;
168
- } else {
169
- const oauth2 = google.oauth2({ version: 'v2', auth: oauth2Client });
170
- user = (await oauth2.userinfo.get()).data;
171
- }
40
+ return email ?? buildCIUser().email; // fallback to CI user if don't have an email for some reason.
41
+ }
172
42
 
173
- resolve(user);
174
- } catch (err) {
175
- reject(err);
176
- }
43
+ function isYahooEmployee(user?: User) {
44
+ return Boolean(user?.email?.endsWith('@yahooinc.com'));
177
45
  }
178
46
 
179
47
  /**
@@ -182,41 +50,14 @@ async function onGETHandler(
182
50
  * @returns
183
51
  */
184
52
  async function authenticateUser(): Promise<User> {
185
- return new Promise((resolve, reject) => {
186
- // TODO: If port (3000) is already in use, this will fail.
187
- // Setup https://www.npmjs.com/package/find-free-ports, but that won't
188
- // play well with the pre-configured redirect_uris in the Google Cloud Console.
189
- const server = http.createServer();
190
-
191
- server.listen(PORT, async () => {
192
- const authorizeUrl = getAuthorizeUrl();
193
-
194
- print(`Please visit the following URL if it didn't open automatically:\n${authorizeUrl}`);
195
-
196
- const childProcess = await open(authorizeUrl, { wait: false });
197
- childProcess.unref();
198
-
199
- process.on('SIGINT', () => {
200
- server.close();
201
- reject('Received SIGINT.');
202
- });
203
- });
204
-
205
- server.on('error', (err: NodeJS.ErrnoException) => {
206
- if (err.code && err.code.includes('EADDRINUSE')) {
207
- print(
208
- red(`🚨 Port ${PORT} already in use. Cannot start local server to handle OAuth flow.`),
209
- );
210
- server.close();
211
- }
212
- });
53
+ // Fetch firebase user data from the configurator.
54
+ const email = await getGitEmail('local');
55
+ const resp = await Bun.fetch(`https://config.uds.build/api/cli-analytics?email=${email}`);
56
+ if (resp.status !== 200) {
57
+ throw new Error(`Failed to fetch firebase user data from endpoint. Status ${resp.status}`);
58
+ }
213
59
 
214
- if (LOGIN_PROVIDER === 'configurator') {
215
- server.on('request', (req, res) => onPostHandler.call(server, req, res, resolve, reject));
216
- } else {
217
- server.on('request', (req, res) => onGETHandler.call(server, req, res, resolve, reject));
218
- }
219
- });
60
+ return (await resp.json()) as User;
220
61
  }
221
62
 
222
63
  async function logout(cachePath?: string) {
@@ -242,8 +83,7 @@ async function login() {
242
83
  user = await authenticateUser();
243
84
  await Bun.write(CACHED_USER_FILE, JSON.stringify(user, null, 2));
244
85
  } catch (err) {
245
- console.error('Error:', err);
246
- throw err;
86
+ console.error((err as NodeJS.ErrnoException).message);
247
87
  }
248
88
  }
249
89
 
@@ -251,16 +91,16 @@ async function login() {
251
91
  }
252
92
 
253
93
  /**
254
- * Builds a FirebaseUser object for a Continuous Integration (CI) user.
94
+ * Builds a firebase user object for a Continuous Integration (CI) user.
255
95
  *
256
96
  * This function generates a CI user with an email based on the UDS_TEAM_SLUG
257
97
  * environment variable. If the UDS_TEAM_SLUG is not defined, it defaults to 'unknown'.
258
98
  * The generated user has a predefined first name, display name, and an empty avatar.
259
99
  * The analytics context includes the team and a role set to 'other'.
260
100
  *
261
- * @returns {FirebaseUser} The generated CI user object.
101
+ * @returns {user} The generated CI user object.
262
102
  */
263
- function buildCIUser(): FirebaseUser {
103
+ function buildCIUser(): User {
264
104
  const team = process.env.UDS_TEAM_SLUG;
265
105
 
266
106
  if (!team) {
@@ -325,14 +165,11 @@ async function getAuthenticatedUser(cliPath = DEFAULT_CLI_PATH): Promise<User |
325
165
  export {
326
166
  authenticateUser,
327
167
  buildCIUser,
328
- configuratorUrlOrigin,
168
+ exec,
329
169
  getAuthenticatedUser,
330
- getAuthorizeUrl,
170
+ getGitEmail,
331
171
  isYahooEmployee,
332
172
  login,
333
- type LoginProvider,
334
173
  logout,
335
- onGETHandler,
336
- onPostHandler,
337
174
  type User,
338
175
  };
@@ -0,0 +1,243 @@
1
+ import { PropsWithChildren, Ref } from 'react';
2
+ import { SvgIcon, IconSize, IconVariant } from '@yahoo/uds-icons/types';
3
+
4
+ declare const alwaysPalette: {
5
+ white: string;
6
+ black: string;
7
+ transparent: string;
8
+ current: string;
9
+ };
10
+
11
+ type CorePaletteAlias = 'brand' | 'accent' | 'alert' | 'positive' | 'warning';
12
+ type BackgroundPaletteAlias = 'primary' | 'secondary';
13
+ type ForegroundPaletteAlias = 'primary' | 'secondary' | 'tertiary' | 'muted' | 'on-color';
14
+ type LinePaletteAlias = 'primary' | 'secondary' | 'tertiary' | 'muted';
15
+ type AlwaysPalette = typeof alwaysPalette;
16
+ type AlwaysPaletteAlias = keyof AlwaysPalette;
17
+ type ForegroundColor = CorePaletteAlias | ForegroundPaletteAlias | AlwaysPaletteAlias;
18
+ type LineColor = CorePaletteAlias | LinePaletteAlias | AlwaysPaletteAlias;
19
+ type BackgroundColor = CorePaletteAlias | BackgroundPaletteAlias | AlwaysPaletteAlias;
20
+ type TextVariant = 'display1' | 'display2' | 'display3' | 'title1' | 'title2' | 'title3' | 'title4' | 'headline1' | 'body1' | 'label1' | 'label2' | 'caption1' | 'caption2' | 'legal1';
21
+ type FontAlias = 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono';
22
+ type FontWeightDescriptive = 'thin' | 'extralight' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'extrabold' | 'black';
23
+ type TextTransform = 'none' | 'uppercase' | 'lowercase' | 'capitalize';
24
+ type TShirtSize = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
25
+ type TShirtSizeCommon = Extract<TShirtSize, 'sm' | 'md' | 'lg'>;
26
+ type AvatarSize = TShirtSizeCommon;
27
+ 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
+ type BorderRadius = TShirtSize;
29
+ type BorderWidth = 'none' | 'thin' | 'medium' | 'thick';
30
+ type Flex = '1' | 'auto' | 'initial' | 'none';
31
+ type FlexGrow = '0' | '1' | '2' | '3';
32
+ type FlexShrink = '0' | '1';
33
+ type FlexAlignContent = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'space-between' | 'space-around';
34
+ type FlexAlignItems = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
35
+ type FlexAlignSelf = 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
36
+ type FlexDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse';
37
+ type FlexWrap = 'wrap' | 'nowrap' | 'wrap-reverse';
38
+ type FlexJustifyContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
39
+ type FlexBasis = 'min-content';
40
+ 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
+ type Overflow = 'auto' | 'hidden' | 'clip' | 'visible' | 'scroll';
42
+ 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
+ interface BorderStyleProps {
50
+ /** Add a border radius to all corners of the box. */
51
+ borderRadius?: BorderRadius;
52
+ /** Add a border radius to top left corner of the box. */
53
+ borderTopStartRadius?: BorderRadius;
54
+ /** Add a border radius to top right corner of the box. */
55
+ borderTopEndRadius?: BorderRadius;
56
+ /** Add a border radius to bottom left corner of the box. */
57
+ borderBottomStartRadius?: BorderRadius;
58
+ /** Add a border radius to bottom right corner of the box. */
59
+ borderBottomEndRadius?: BorderRadius;
60
+ /** Adds a custom border color from the palette */
61
+ borderColor?: LineColor;
62
+ /** Start border color */
63
+ borderStartColor?: LineColor;
64
+ /** End border color */
65
+ borderEndColor?: LineColor;
66
+ /** Top border color */
67
+ borderTopColor?: LineColor;
68
+ /** Bottom border color */
69
+ borderBottomColor?: LineColor;
70
+ /** Shorthand property to the width of an element's border. */
71
+ borderWidth?: BorderWidth;
72
+ /** Sets the width of the top and bottom border of an element. */
73
+ borderVerticalWidth?: BorderWidth;
74
+ /** Sets the width of the start (left) and end (right) border of an element. */
75
+ borderHorizontalWidth?: BorderWidth;
76
+ /** Sets the width of the start (left) border of an element. */
77
+ borderStartWidth?: BorderWidth;
78
+ /** Sets the width of the end (right) border of an element. */
79
+ borderEndWidth?: BorderWidth;
80
+ /** Sets the width of the top border of an element. */
81
+ borderTopWidth?: BorderWidth;
82
+ /** Sets the width of the bottom border of an element. */
83
+ borderBottomWidth?: BorderWidth;
84
+ }
85
+ interface LayoutStyleProps {
86
+ /** 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
+ display?: Display;
88
+ /** Shorthand property which sets the desired behavior when content does not fit in the parent element box (overflows) in the horizontal and/or vertical direction. */
89
+ overflow?: Overflow;
90
+ /** Sets what shows when content overflows a block-level element's left and right edges. This may be nothing, a scroll bar, or the overflow content. This property may also be set by using the overflow shorthand property. */
91
+ overflowX?: Overflow;
92
+ /** sets what shows when content overflows a block-level element's top and bottom edges. This may be nothing, a scroll bar, or the overflow content. This property may also be set by using the overflow shorthand property. */
93
+ overflowY?: Overflow;
94
+ /** Sets how an element is positioned in a document. The top, right, bottom, and left properties determine the final location of positioned elements. */
95
+ position?: Position;
96
+ }
97
+ interface SpacingStyleProps {
98
+ /** Apply inner spacing on all sides. */
99
+ spacing?: SpacingAlias;
100
+ /** Apply inner spacing on the leading and trailing sides. */
101
+ spacingHorizontal?: SpacingAlias;
102
+ /** Apply inner spacing on the top and bottom sides. */
103
+ spacingVertical?: SpacingAlias;
104
+ /** Apply inner spacing on the bottom side. */
105
+ spacingBottom?: SpacingAlias;
106
+ /** Apply inner spacing on the trailing side. */
107
+ spacingEnd?: SpacingAlias;
108
+ /** Apply inner spacing on the leading side. */
109
+ spacingStart?: SpacingAlias;
110
+ /** Apply inner spacing on the top side. */
111
+ spacingTop?: SpacingAlias;
112
+ /** Apply negative outer spacing on all sides. */
113
+ offset?: SpacingAlias;
114
+ /** Apply negative outer spacing on the top and bottom sides. */
115
+ offsetVertical?: SpacingAlias;
116
+ /** Apply negative outer spacing on the leading and trailing sides. */
117
+ offsetHorizontal?: SpacingAlias;
118
+ /** Apply negative outer spacing on the bottom side. */
119
+ offsetBottom?: SpacingAlias;
120
+ /** Apply negative outer spacing on the trailing side. */
121
+ offsetEnd?: SpacingAlias;
122
+ /** Apply negative outer spacing on the leading side. */
123
+ offsetStart?: SpacingAlias;
124
+ /** Apply negative outer spacing on the top side. */
125
+ offsetTop?: SpacingAlias;
126
+ /** Control the horizontal gutters between grid and flexbox items. */
127
+ columnGap?: SpacingAlias;
128
+ /** Control the vertical gutters between grid and flexbox items. */
129
+ rowGap?: SpacingAlias;
130
+ }
131
+ interface FlexStyleProps {
132
+ /** Sets the distribution of space between and around content items along a flexbox's cross-axis or a grid's block axis. */
133
+ alignContent?: FlexAlignContent;
134
+ /** Sets the align-self value on all direct children as a group. In Flexbox, it controls the alignment of items on the Cross Axis. In Grid Layout, it controls the alignment of items on the Block Axis within their grid area. */
135
+ alignItems?: FlexAlignItems;
136
+ /** Overrides a grid or flex item's align-items value. In Grid, it aligns the item inside the grid area. In Flexbox, it aligns the item on the cross axis. */
137
+ alignSelf?: FlexAlignSelf;
138
+ /** Sets how a flex item will grow or shrink to fit the space available in its flex container. */
139
+ flex?: Flex;
140
+ /** Sets how flex items are placed in the flex container defining the main axis and the direction (normal or reversed). */
141
+ flexDirection?: FlexDirection;
142
+ /** Sets the flex grow factor, which specifies how much of the flex container's remaining space should be assigned to the flex item's main size. */
143
+ flexGrow?: FlexGrow;
144
+ /** Sets the flex shrink factor of a flex item. If the size of all flex items is larger than the flex container, items shrink to fit according to flex-shrink. */
145
+ flexShrink?: FlexShrink;
146
+ /** Sets whether flex items are forced onto one line or can wrap onto multiple lines. If wrapping is allowed, it sets the direction that lines are stacked. */
147
+ flexWrap?: FlexWrap;
148
+ /** Defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container. */
149
+ justifyContent?: FlexJustifyContent;
150
+ /** Sets the initial main size of a flex item. It sets the size of the content box unless otherwise set with box-sizing. https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis */
151
+ flexBasis?: FlexBasis;
152
+ }
153
+ interface TextStyleProps {
154
+ /** Color of a Text or Icon element */
155
+ color?: ForegroundColor;
156
+ /** Color of placeholder text */
157
+ placeholderColor?: ForegroundColor;
158
+ /** Font family for the text */
159
+ fontFamily?: TextVariant | FontAlias;
160
+ /** Font size of the text */
161
+ fontSize?: TextVariant;
162
+ /** Font weight of the text */
163
+ fontWeight?: TextVariant | FontWeightDescriptive;
164
+ /** Line height of the text */
165
+ lineHeight?: TextVariant;
166
+ /** Text alignment of the text */
167
+ textAlign?: 'center' | 'justify' | 'start' | 'end';
168
+ /** Sets the text transform for the text */
169
+ textTransform?: TextVariant | TextTransform;
170
+ }
171
+ interface BackgroundStyleProps {
172
+ /** Sets the background color. */
173
+ backgroundColor?: BackgroundColor;
174
+ }
175
+ interface UniversalBoxProps extends PropsWithChildren, BackgroundStyleProps, BorderStyleProps, FlexStyleProps, LayoutStyleProps, SpacingStyleProps {
176
+ /**
177
+ * When asChild is set to true, the component's child will be cloned and passed
178
+ * the props and behavior required to make it functional.
179
+ */
180
+ asChild?: boolean;
181
+ }
182
+ interface UniversalStackProps extends Omit<UniversalBoxProps, 'flexDirection'> {
183
+ gap?: SpacingAlias;
184
+ }
185
+ interface UniversalTextProps extends PropsWithChildren, TextStyleProps, UniversalBoxProps {
186
+ /** Style of text. */
187
+ variant?: TextVariant;
188
+ /** Color of the text. */
189
+ color?: ForegroundColor;
190
+ }
191
+ interface UniversalIconProps {
192
+ /** Icon to render from the icons package. */
193
+ name: SvgIcon;
194
+ /** Size of the icon. */
195
+ size?: IconSize;
196
+ /** Variant for icon. Either fill or outline. */
197
+ variant?: IconVariant;
198
+ /** Color of the icon. */
199
+ color?: ForegroundColor;
200
+ }
201
+ interface UniversalImageProps extends Omit<UniversalBoxProps, 'width' | 'height'>, ImageStyleProps {
202
+ /** The source URL of the image. */
203
+ src: string;
204
+ /** Provides fallback (alternate) text to display when the image specified by the Image element is not loaded. */
205
+ alt?: string;
206
+ /** Width of the image in px. */
207
+ width?: number;
208
+ /** Height of the image in pixel. */
209
+ height?: number;
210
+ }
211
+ interface UniversalAvatarProps extends UniversalImageProps {
212
+ /** The size of the Avatar. */
213
+ size?: AvatarSize;
214
+ /** The shape of the Avatar. */
215
+ shape?: BorderRadius;
216
+ }
217
+ interface UniversalTextInputProps {
218
+ disabled?: boolean;
219
+ required?: boolean;
220
+ backgroundColor?: BackgroundColor;
221
+ borderColor?: LineColor;
222
+ borderWidth?: BorderWidth;
223
+ borderRadius?: BorderRadius;
224
+ color?: ForegroundColor;
225
+ fontSize?: TextVariant;
226
+ placeholderColor?: ForegroundColor;
227
+ spacingVertical?: SpacingAlias;
228
+ spacingHorizontal?: SpacingAlias;
229
+ }
230
+
231
+ type DivProps = React.HTMLAttributes<HTMLDivElement>;
232
+ interface BoxProps extends UniversalBoxProps, DivProps {
233
+ }
234
+
235
+ type TextElementTagName = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'p' | 'strong' | 'span' | 'label' | 'li';
236
+ type TextProps<TagName extends TextElementTagName = TextElementTagName> = {
237
+ /** Ref passed to the inner container. */
238
+ ref?: Ref<HTMLElement>;
239
+ /** Changes the HTML tag used to render text. Uses the most appropriate semantic tag based on the text style variant. */
240
+ as?: TagName;
241
+ } & JSX.IntrinsicElements[TagName] & UniversalTextProps;
242
+
243
+ export type { BoxProps as B, DivProps as D, Overflow as O, TextProps as T, UniversalAvatarProps as U, UniversalTextProps as a, UniversalIconProps as b, UniversalStackProps as c, UniversalTextInputProps as d };