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