@beryl-ui/react 2.1.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/dist/index.mjs ADDED
@@ -0,0 +1,485 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/components/Avatar/index.tsx
34
+ import { User } from "phosphor-react";
35
+
36
+ // src/components/Avatar/styles.ts
37
+ import * as Avatar from "@radix-ui/react-avatar";
38
+ import styled from "styled-components";
39
+ var AvatarContainer = styled(Avatar.Root)`
40
+ border-radius: ${({ theme: theme2 }) => theme2.radii.full};
41
+ display: inline-block;
42
+ width: ${({ theme: theme2 }) => theme2.space[12]};
43
+ height: ${({ theme: theme2 }) => theme2.space[12]};
44
+ overflow: hidden;
45
+ `;
46
+ var AvatarImage = styled(Avatar.Image)`
47
+ width: 100%;
48
+ height: 100%;
49
+ object-fit: cover;
50
+ border-radius: inherit;
51
+ `;
52
+ var AvatarFallback = styled(Avatar.Fallback)`
53
+ width: 100%;
54
+ height: 100%;
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ background-color: ${({ theme: theme2 }) => theme2.colors.gray600};
59
+ color: ${({ theme: theme2 }) => theme2.colors.gray800};
60
+
61
+ svg {
62
+ width: ${({ theme: theme2 }) => theme2.space[6]};
63
+ height: ${({ theme: theme2 }) => theme2.space[6]};
64
+ }
65
+ `;
66
+
67
+ // src/components/Avatar/index.tsx
68
+ import { jsx, jsxs } from "react/jsx-runtime";
69
+ function Avatar2(props) {
70
+ return /* @__PURE__ */ jsxs(AvatarContainer, { children: [
71
+ /* @__PURE__ */ jsx(AvatarImage, __spreadValues({}, props)),
72
+ /* @__PURE__ */ jsx(AvatarFallback, { delayMs: 600, children: /* @__PURE__ */ jsx(User, {}) })
73
+ ] });
74
+ }
75
+ Avatar2.displayName = "Avatar";
76
+
77
+ // src/components/Box/styles.ts
78
+ import { styled as styled2 } from "styled-components";
79
+ var BoxContainer = styled2.div`
80
+ padding: ${({ theme: theme2 }) => theme2.space[4]};
81
+ border-radius: ${({ theme: theme2 }) => theme2.radii.md};
82
+ background-color: ${({ theme: theme2 }) => theme2.colors.gray800};
83
+ border: 1px solid ${({ theme: theme2 }) => theme2.colors.gray600};
84
+ `;
85
+
86
+ // src/components/Box/index.tsx
87
+ import { jsx as jsx2 } from "react/jsx-runtime";
88
+ function Box(props) {
89
+ return /* @__PURE__ */ jsx2(BoxContainer, __spreadValues({}, props));
90
+ }
91
+ Box.displayName = "Box";
92
+
93
+ // src/components/Button/styles.ts
94
+ import { css, styled as styled3 } from "styled-components";
95
+ var ButtonContainer = styled3.button`
96
+ all: unset;
97
+ box-sizing: border-box;
98
+
99
+ font-family: ${({ theme: theme2 }) => theme2.fonts.default};
100
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes.sm};
101
+ font-weight: ${({ theme: theme2 }) => theme2.fontWeights.medium};
102
+ text-align: center;
103
+ border-radius: ${({ theme: theme2 }) => theme2.radii.sm};
104
+ padding: 0 ${({ theme: theme2 }) => theme2.space[4]};
105
+ min-width: 120px;
106
+
107
+ display: flex;
108
+ align-items: center;
109
+ justify-content: center;
110
+ gap: ${({ theme: theme2 }) => theme2.space[2]};
111
+
112
+ cursor: pointer;
113
+
114
+ &:disabled {
115
+ cursor: not-allowed;
116
+ }
117
+
118
+ svg {
119
+ width: ${({ theme: theme2 }) => theme2.space[4]};
120
+ height: ${({ theme: theme2 }) => theme2.space[4]};
121
+ }
122
+
123
+ ${({ variant = "primary", theme: theme2 }) => {
124
+ switch (variant) {
125
+ case "primary":
126
+ return css`
127
+ color: ${theme2.colors.white};
128
+ background: ${theme2.colors.emerald500};
129
+
130
+ &:not(:disabled):hover {
131
+ background: ${theme2.colors.emerald300};
132
+ }
133
+
134
+ &:disabled {
135
+ background-color: ${theme2.colors.gray200};
136
+ }
137
+ `;
138
+ case "secondary":
139
+ return css`
140
+ color: ${theme2.colors.emerald300};
141
+ border: 2px solid ${theme2.colors.emerald500};
142
+
143
+ &:not(:disabled):hover {
144
+ background: ${theme2.colors.emerald500};
145
+ color: ${theme2.colors.white};
146
+ }
147
+
148
+ &:disabled {
149
+ color: ${theme2.colors.gray200};
150
+ border-color: ${theme2.colors.gray200};
151
+ }
152
+ `;
153
+ case "tertiary":
154
+ return css`
155
+ color: ${theme2.colors.gray100};
156
+
157
+ &:not(:disabled):hover {
158
+ color: ${theme2.colors.white};
159
+ }
160
+
161
+ &:disabled {
162
+ color: ${theme2.colors.gray600};
163
+ }
164
+ `;
165
+ }
166
+ }}
167
+
168
+ ${({ size = "md" }) => {
169
+ switch (size) {
170
+ case "sm":
171
+ return css`
172
+ height: 38px;
173
+ `;
174
+ case "md":
175
+ return css`
176
+ height: 46px;
177
+ `;
178
+ }
179
+ }}
180
+ `;
181
+
182
+ // src/components/Button/index.tsx
183
+ import { jsx as jsx3 } from "react/jsx-runtime";
184
+ function Button(props) {
185
+ return /* @__PURE__ */ jsx3(ButtonContainer, __spreadValues({}, props));
186
+ }
187
+ Button.displayName = "Button";
188
+
189
+ // src/components/Checkbox/index.tsx
190
+ import { Check } from "phosphor-react";
191
+
192
+ // src/components/Checkbox/styles.ts
193
+ import * as Checkbox from "@radix-ui/react-checkbox";
194
+ import { keyframes, styled as styled4 } from "styled-components";
195
+ var CheckboxContainer = styled4(Checkbox.Root)`
196
+ all: unset;
197
+ width: ${({ theme: theme2 }) => theme2.space[6]};
198
+ height: ${({ theme: theme2 }) => theme2.space[6]};
199
+ background-color: ${({ theme: theme2 }) => theme2.colors.gray900};
200
+ border-radius: ${({ theme: theme2 }) => theme2.radii.xs};
201
+ line-height: 0;
202
+ cursor: pointer;
203
+ overflow: hidden;
204
+ box-sizing: border-box;
205
+ display: flex;
206
+ justify-content: center;
207
+ align-items: center;
208
+ border: 2px solid ${({ theme: theme2 }) => theme2.colors.gray900};
209
+
210
+ &:focus,
211
+ &[data-state='checked'] {
212
+ border: 2px solid ${({ theme: theme2 }) => theme2.colors.emerald300};
213
+ }
214
+
215
+ &[data-state='checked'] {
216
+ background-color: ${({ theme: theme2 }) => theme2.colors.emerald300};
217
+ }
218
+ `;
219
+ var slideIn = keyframes`
220
+ from { transform: translateY(-100%); }
221
+ to { transform: translateY(0); }
222
+ `;
223
+ var slideOut = keyframes`
224
+ from { transform: translateY(0); }
225
+ to { transform: translateY(-100%); }
226
+ `;
227
+ var CheckboxIndicator = styled4(Checkbox.Indicator)`
228
+ color: ${({ theme: theme2 }) => theme2.colors.white};
229
+ width: ${({ theme: theme2 }) => theme2.space[4]};
230
+ height: ${({ theme: theme2 }) => theme2.space[4]};
231
+
232
+ &[data-state='checked'] {
233
+ animation: ${slideIn} 200ms ease-out;
234
+ }
235
+
236
+ &[data-state='unchecked'] {
237
+ animation: ${slideOut} 200ms ease-out;
238
+ }
239
+ `;
240
+
241
+ // src/components/Checkbox/index.tsx
242
+ import { jsx as jsx4 } from "react/jsx-runtime";
243
+ function Checkbox2(props) {
244
+ return /* @__PURE__ */ jsx4(CheckboxContainer, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx4(CheckboxIndicator, { asChild: true, children: /* @__PURE__ */ jsx4(Check, { weight: "bold" }) }) }));
245
+ }
246
+ Checkbox2.displayName = "Checkbox";
247
+
248
+ // src/components/Heading/styles.ts
249
+ import { css as css2, styled as styled5 } from "styled-components";
250
+ var sizeVariants = {
251
+ sm: css2`
252
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes.xl};
253
+ `,
254
+ md: css2`
255
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes["2xl"]};
256
+ `,
257
+ lg: css2`
258
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes["4xl"]};
259
+ `,
260
+ "2xl": css2`
261
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes["5xl"]};
262
+ `,
263
+ "3xl": css2`
264
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes["6xl"]};
265
+ `,
266
+ "4xl": css2`
267
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes["7xl"]};
268
+ `,
269
+ "5xl": css2`
270
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes["8xl"]};
271
+ `,
272
+ "6xl": css2`
273
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes["9xl"]};
274
+ `
275
+ };
276
+ var HeadingContainer = styled5.h2`
277
+ font-family: ${({ theme: theme2 }) => theme2.fonts.default};
278
+ line-height: ${({ theme: theme2 }) => theme2.lineHeights.shorter};
279
+ margin: 0;
280
+ color: ${({ theme: theme2 }) => theme2.colors.gray100};
281
+
282
+ ${({ size = "md" }) => sizeVariants[size]}
283
+ `;
284
+
285
+ // src/components/Heading/index.tsx
286
+ import { jsx as jsx5 } from "react/jsx-runtime";
287
+ function Heading(props) {
288
+ return /* @__PURE__ */ jsx5(HeadingContainer, __spreadValues({}, props));
289
+ }
290
+ Heading.displayName = "Heading";
291
+
292
+ // src/components/MultiStep/styles.ts
293
+ import { styled as styled7 } from "styled-components";
294
+
295
+ // src/components/Text/styles.ts
296
+ import { styled as styled6 } from "styled-components";
297
+ var TextContainer = styled6.p`
298
+ font-family: ${({ theme: theme2 }) => theme2.fonts.default};
299
+ line-height: ${({ theme: theme2 }) => theme2.lineHeights.base};
300
+ margin: 0;
301
+ color: ${({ theme: theme2 }) => theme2.colors.gray100};
302
+
303
+ font-size: ${({ theme: theme2, size }) => theme2.fontSizes[size || "md"]};
304
+ `;
305
+
306
+ // src/components/Text/index.tsx
307
+ import { jsx as jsx6 } from "react/jsx-runtime";
308
+ function Text(props) {
309
+ return /* @__PURE__ */ jsx6(TextContainer, __spreadValues({}, props));
310
+ }
311
+ Text.displayName = "Text";
312
+
313
+ // src/components/MultiStep/styles.ts
314
+ var MultiStepContainer = styled7.div``;
315
+ var Label = styled7(Text).attrs({
316
+ size: "xs"
317
+ })`
318
+ color: ${({ theme: theme2 }) => theme2.colors.gray200};
319
+ `;
320
+ var Steps = styled7.div`
321
+ display: grid;
322
+ grid-template-columns: repeat(${({ size }) => size}, 1fr);
323
+ gap: ${({ theme: theme2 }) => theme2.space[2]};
324
+ margin-top: ${({ theme: theme2 }) => theme2.space[1]};
325
+ `;
326
+ var Step = styled7.div`
327
+ height: ${({ theme: theme2 }) => theme2.space[1]};
328
+ border-radius: ${({ theme: theme2 }) => theme2.radii.px};
329
+ background-color: ${({ theme: theme2 }) => theme2.colors.gray600};
330
+
331
+ ${({ $active, theme: theme2 }) => $active && `background-color: ${theme2.colors.gray100};`}
332
+ `;
333
+
334
+ // src/components/MultiStep/index.tsx
335
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
336
+ function MultiStep({ size, currentStep = 1 }) {
337
+ return /* @__PURE__ */ jsxs2(MultiStepContainer, { children: [
338
+ /* @__PURE__ */ jsxs2(Label, { children: [
339
+ "Step ",
340
+ currentStep,
341
+ " of ",
342
+ size
343
+ ] }),
344
+ /* @__PURE__ */ jsx7(Steps, { size, children: Array.from({ length: size }, (_, i) => i + 1).map((step) => {
345
+ return /* @__PURE__ */ jsx7(Step, { $active: step <= currentStep }, step);
346
+ }) })
347
+ ] });
348
+ }
349
+ MultiStep.displayName = "MultiStep";
350
+
351
+ // src/components/TextArea/index.tsx
352
+ import { forwardRef } from "react";
353
+
354
+ // src/components/TextArea/styles.ts
355
+ import { styled as styled8 } from "styled-components";
356
+ var TextAreaContainer = styled8.textarea`
357
+ background-color: ${({ theme: theme2 }) => theme2.colors.gray900};
358
+ padding: ${({ theme: theme2 }) => `${theme2.space[3]} ${theme2.space[4]}`};
359
+ border-radius: ${({ theme: theme2 }) => theme2.radii.sm};
360
+ box-sizing: border-box;
361
+ border: 2px solid ${({ theme: theme2 }) => theme2.colors.gray900};
362
+ font-family: ${({ theme: theme2 }) => theme2.fonts.default};
363
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes.sm};
364
+ color: ${({ theme: theme2 }) => theme2.colors.white};
365
+ font-weight: ${({ theme: theme2 }) => theme2.fontWeights.regular};
366
+ resize: vertical;
367
+ min-height: 80px;
368
+
369
+ &:focus {
370
+ outline: 0;
371
+ border-color: ${({ theme: theme2 }) => theme2.colors.emerald300};
372
+ }
373
+
374
+ &:disabled {
375
+ opacity: 0.5;
376
+ cursor: not-allowed;
377
+ }
378
+
379
+ &::placeholder {
380
+ color: ${({ theme: theme2 }) => theme2.colors.gray400};
381
+ }
382
+ `;
383
+
384
+ // src/components/TextArea/index.tsx
385
+ import { jsx as jsx8 } from "react/jsx-runtime";
386
+ var TextArea = forwardRef((props, ref) => {
387
+ return /* @__PURE__ */ jsx8(TextAreaContainer, __spreadValues({ ref }, props));
388
+ });
389
+ TextArea.displayName = "TextArea";
390
+
391
+ // src/components/TextInput/index.tsx
392
+ import { forwardRef as forwardRef2 } from "react";
393
+
394
+ // src/components/TextInput/styles.ts
395
+ import { styled as styled9 } from "styled-components";
396
+ var TextInputContainer = styled9.div`
397
+ background-color: ${({ theme: theme2 }) => theme2.colors.gray900};
398
+ padding: ${({ theme: theme2 }) => `${theme2.space[3]} ${theme2.space[4]}`};
399
+ border-radius: ${({ theme: theme2 }) => theme2.radii.sm};
400
+ box-sizing: border-box;
401
+ border: 2px solid ${({ theme: theme2 }) => theme2.colors.gray900};
402
+ display: flex;
403
+ align-items: baseline;
404
+
405
+ &:has(input:focus) {
406
+ border-color: ${({ theme: theme2 }) => theme2.colors.emerald300};
407
+ }
408
+
409
+ &:has(input:disabled) {
410
+ opacity: 0.5;
411
+ cursor: not-allowed;
412
+ }
413
+ `;
414
+ var Prefix = styled9.span`
415
+ font-family: ${({ theme: theme2 }) => theme2.fonts.default};
416
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes.sm};
417
+ color: ${({ theme: theme2 }) => theme2.colors.gray400};
418
+ font-weight: ${({ theme: theme2 }) => theme2.fontWeights.regular};
419
+ `;
420
+ var Input = styled9.input`
421
+ font-family: ${({ theme: theme2 }) => theme2.fonts.default};
422
+ font-size: ${({ theme: theme2 }) => theme2.fontSizes.sm};
423
+ color: ${({ theme: theme2 }) => theme2.colors.white};
424
+ font-weight: ${({ theme: theme2 }) => theme2.fontWeights.regular};
425
+ background: transparent;
426
+ border: 0;
427
+ width: 100%;
428
+
429
+ &:focus {
430
+ outline: 0;
431
+ }
432
+
433
+ &:disabled {
434
+ cursor: not-allowed;
435
+ }
436
+
437
+ &::placeholder {
438
+ color: ${({ theme: theme2 }) => theme2.colors.gray400};
439
+ }
440
+ `;
441
+
442
+ // src/components/TextInput/index.tsx
443
+ import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
444
+ var TextInput = forwardRef2(
445
+ (_a, ref) => {
446
+ var _b = _a, { prefix } = _b, props = __objRest(_b, ["prefix"]);
447
+ return /* @__PURE__ */ jsxs3(TextInputContainer, { children: [
448
+ !!prefix && /* @__PURE__ */ jsx9(Prefix, { children: prefix }),
449
+ /* @__PURE__ */ jsx9(Input, __spreadValues({ ref }, props))
450
+ ] });
451
+ }
452
+ );
453
+ TextInput.displayName = "TextInput";
454
+
455
+ // src/styles/theme.ts
456
+ import {
457
+ colors,
458
+ fonts,
459
+ fontSizes,
460
+ fontWeights,
461
+ lineHeights,
462
+ radii,
463
+ space
464
+ } from "@beryl-ui/tokens";
465
+ var theme = {
466
+ colors,
467
+ fontSizes,
468
+ fontWeights,
469
+ fonts,
470
+ lineHeights,
471
+ radii,
472
+ space
473
+ };
474
+ export {
475
+ Avatar2 as Avatar,
476
+ Box,
477
+ Button,
478
+ Checkbox2 as Checkbox,
479
+ Heading,
480
+ MultiStep,
481
+ Text,
482
+ TextArea,
483
+ TextInput,
484
+ theme
485
+ };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@beryl-ui/react",
3
+ "version": "2.1.0",
4
+ "description": "React components for the beryl-ui Design System.",
5
+ "license": "MIT",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "author": {
13
+ "name": "Robson H. Rodrigues",
14
+ "url": "https://github.com/Robson16"
15
+ },
16
+ "keywords": [
17
+ "ignite",
18
+ "rocketseat",
19
+ "typescript",
20
+ "react"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsup src/index.tsx --format esm,cjs --dts --external react,styled-components",
24
+ "dev": "tsup src/index.tsx --format esm,cjs --dts --external react --watch",
25
+ "lint": "eslint src --ext .ts,.tsx --fix"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "^18.3.1",
29
+ "react-dom": "^18.3.1",
30
+ "styled-components": "^6.3.6"
31
+ },
32
+ "devDependencies": {
33
+ "@beryl-ui/eslint-config": "*",
34
+ "@beryl-ui/prettier-config": "*",
35
+ "@beryl-ui/ts-config": "*",
36
+ "@types/react": "^18.3.27",
37
+ "@types/react-dom": "^18.3.7",
38
+ "eslint": "^8.57.1",
39
+ "styled-components": "^6.3.6",
40
+ "tsup": "^8.5.1",
41
+ "typescript": "^5.5.4"
42
+ },
43
+ "dependencies": {
44
+ "@beryl-ui/tokens": "*",
45
+ "@radix-ui/react-avatar": "^1.1.11",
46
+ "@radix-ui/react-checkbox": "^1.3.3",
47
+ "phosphor-react": "^1.4.1"
48
+ }
49
+ }