@spies-ui/react 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,777 @@
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 __commonJS = (cb, mod) => function __require() {
38
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
39
+ };
40
+ var __export = (target, all) => {
41
+ for (var name in all)
42
+ __defProp(target, name, { get: all[name], enumerable: true });
43
+ };
44
+ var __copyProps = (to, from, except, desc) => {
45
+ if (from && typeof from === "object" || typeof from === "function") {
46
+ for (let key of __getOwnPropNames(from))
47
+ if (!__hasOwnProp.call(to, key) && key !== except)
48
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
49
+ }
50
+ return to;
51
+ };
52
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
53
+ // If the importer is in node compatibility mode or this is not an ESM
54
+ // file that has been converted to a CommonJS file using a Babel-
55
+ // compatible transform (i.e. "__esModule" has not been set), then set
56
+ // "default" to the CommonJS "module.exports" for node compatibility.
57
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
58
+ mod
59
+ ));
60
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
61
+
62
+ // ../tokens/dist/index.js
63
+ var require_dist = __commonJS({
64
+ "../tokens/dist/index.js"(exports2, module2) {
65
+ "use strict";
66
+ var __defProp2 = Object.defineProperty;
67
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
68
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
69
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
70
+ var __export2 = (target, all) => {
71
+ for (var name in all)
72
+ __defProp2(target, name, { get: all[name], enumerable: true });
73
+ };
74
+ var __copyProps2 = (to, from, except, desc) => {
75
+ if (from && typeof from === "object" || typeof from === "function") {
76
+ for (let key of __getOwnPropNames2(from))
77
+ if (!__hasOwnProp2.call(to, key) && key !== except)
78
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
79
+ }
80
+ return to;
81
+ };
82
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
83
+ var src_exports2 = {};
84
+ __export2(src_exports2, {
85
+ colors: () => colors2,
86
+ fontSizes: () => fontSizes2,
87
+ fontWeights: () => fontWeights2,
88
+ fonts: () => fonts2,
89
+ lineHeights: () => lineHeights2,
90
+ radii: () => radii2,
91
+ space: () => space2
92
+ });
93
+ module2.exports = __toCommonJS2(src_exports2);
94
+ var colors2 = {
95
+ black: "#000000",
96
+ white: "#ffffff",
97
+ smokedWhite: "#f5f5f5",
98
+ richBlack: "#000014",
99
+ gray100: "#e0e0e0",
100
+ gray200: "#a0a6ae",
101
+ gray400: "#7a828e",
102
+ gray500: "#4a5057",
103
+ gray600: "#40454c",
104
+ gray700: "#2f3238",
105
+ gray800: "#1f1f1f",
106
+ gray900: "#141414",
107
+ primary: "#1244ce",
108
+ primaryLight: "#144AE1",
109
+ success: "#86e660",
110
+ warning: "#ffc933",
111
+ danger: "#ef2e3b"
112
+ };
113
+ var space2 = {
114
+ 1: "0.25rem",
115
+ 2: "0.5rem",
116
+ 3: "0.75rem",
117
+ 4: "1rem",
118
+ 5: "1.25rem",
119
+ 6: "1.5rem",
120
+ 7: "1.75rem",
121
+ 8: "2rem",
122
+ 10: "2.5rem",
123
+ 12: "3rem",
124
+ 16: "4rem",
125
+ 20: "5rem",
126
+ 40: "10rem",
127
+ 64: "16rem",
128
+ 80: "20rem"
129
+ };
130
+ var radii2 = {
131
+ px: "1px",
132
+ xs: "4px",
133
+ sm: "6px",
134
+ md: "8px",
135
+ lg: "16px",
136
+ full: "99999px"
137
+ };
138
+ var fonts2 = {
139
+ default: "Roboto, sans-serif",
140
+ heading: "Montserrat, sans-serif",
141
+ code: "monospace"
142
+ };
143
+ var fontSizes2 = {
144
+ xxs: "0.625rem",
145
+ xs: "0.75rem",
146
+ sm: "0.875rem",
147
+ md: "1rem",
148
+ lg: "1.125rem",
149
+ xl: "1.25rem",
150
+ "2xl": "1.5rem",
151
+ "4xl": "2rem",
152
+ "5xl": "2.25rem",
153
+ "6xl": "3rem",
154
+ "7xl": "4rem",
155
+ "8xl": "4.5rem",
156
+ "9xl": "6rem"
157
+ };
158
+ var fontWeights2 = {
159
+ thin: "100",
160
+ extralight: "200",
161
+ light: "300",
162
+ regular: "400",
163
+ medium: "500",
164
+ semibold: "600",
165
+ bold: "700",
166
+ extrabold: "800",
167
+ black: "900"
168
+ };
169
+ var lineHeights2 = {
170
+ shorter: "125%",
171
+ short: "140%",
172
+ base: "160%",
173
+ tall: "180%"
174
+ };
175
+ }
176
+ });
177
+
178
+ // src/index.tsx
179
+ var src_exports = {};
180
+ __export(src_exports, {
181
+ Avatar: () => Avatar2,
182
+ Box: () => Box,
183
+ Button: () => Button,
184
+ Checkbox: () => Checkbox2,
185
+ Dropdown: () => Dropdown,
186
+ Heading: () => Heading,
187
+ Text: () => Text,
188
+ TextArea: () => TextArea,
189
+ TextInput: () => TextInput
190
+ });
191
+ module.exports = __toCommonJS(src_exports);
192
+
193
+ // src/styles/index.ts
194
+ var import_tokens = __toESM(require_dist());
195
+ var import_react = require("@stitches/react");
196
+ var {
197
+ styled,
198
+ css,
199
+ globalCss,
200
+ keyframes,
201
+ getCssText,
202
+ theme,
203
+ createTheme,
204
+ config
205
+ } = (0, import_react.createStitches)({
206
+ themeMap: __spreadProps(__spreadValues({}, import_react.defaultThemeMap), {
207
+ height: "space",
208
+ width: "space"
209
+ }),
210
+ theme: {
211
+ colors: import_tokens.colors,
212
+ fontSizes: import_tokens.fontSizes,
213
+ fontWeights: import_tokens.fontWeights,
214
+ fonts: import_tokens.fonts,
215
+ lineHeights: import_tokens.lineHeights,
216
+ radii: import_tokens.radii,
217
+ space: import_tokens.space
218
+ }
219
+ });
220
+
221
+ // src/components/Box.tsx
222
+ var Box = styled("div", {
223
+ padding: "$4",
224
+ borderRadius: "$md",
225
+ variants: {
226
+ background: {
227
+ default: {
228
+ backgroundColor: "transparent"
229
+ },
230
+ gray600: {
231
+ backgroundColor: "$gray600"
232
+ },
233
+ gray700: {
234
+ backgroundColor: "$gray700"
235
+ },
236
+ gray800: {
237
+ backgroundColor: "$gray800"
238
+ },
239
+ gray900: {
240
+ backgroundColor: "$gray900"
241
+ }
242
+ }
243
+ }
244
+ });
245
+ Box.displayName = "Box";
246
+
247
+ // src/components/Text.tsx
248
+ var Text = styled("p", {
249
+ fontFamily: "$default",
250
+ lineHeight: "$base",
251
+ margin: 0,
252
+ color: "$smokedWhite",
253
+ variants: {
254
+ size: {
255
+ xxs: { fontSize: "$xxs" },
256
+ xs: { fontSize: "$xs" },
257
+ sm: { fontSize: "$sm" },
258
+ md: { fontSize: "$md" },
259
+ lg: { fontSize: "$lg" },
260
+ xl: { fontSize: "$xl" },
261
+ "2xl": { fontSize: "$2xl" },
262
+ "4xl": { fontSize: "$4xl" },
263
+ "5xl": { fontSize: "$5xl" },
264
+ "6xl": { fontSize: "$6xl" },
265
+ "7xl": { fontSize: "$7xl" },
266
+ "8xl": { fontSize: "$8xl" },
267
+ "9xl": { fontSize: "$9xl" }
268
+ },
269
+ variant: {
270
+ default: { color: "$smokedWhite" },
271
+ primary: { color: "$primary" },
272
+ danger: { color: "$danger" },
273
+ success: { color: "$success" },
274
+ warning: { color: "$warning" }
275
+ }
276
+ },
277
+ defaultVariants: {
278
+ size: "md",
279
+ variant: "default"
280
+ }
281
+ });
282
+ Text.displayName = "Text";
283
+
284
+ // src/components/Heading.tsx
285
+ var Heading = styled("h2", {
286
+ fontFamily: "$heading",
287
+ lineHeight: "$shorter",
288
+ margin: 0,
289
+ color: "$smokedWhite",
290
+ variants: {
291
+ size: {
292
+ sm: { fontSize: "$xl" },
293
+ md: { fontSize: "$2xl" },
294
+ lg: { fontSize: "$4xl" },
295
+ "2xl": { fontSize: "$5xl" },
296
+ "3xl": { fontSize: "$5xl" },
297
+ "4xl": { fontSize: "$6xl" },
298
+ "5xl": { fontSize: "$7xl" },
299
+ "6xl": { fontSize: "$8xl" }
300
+ }
301
+ },
302
+ defaultVariants: {
303
+ size: "md"
304
+ }
305
+ });
306
+ Heading.displayName = "Heading";
307
+
308
+ // src/components/Avatar/styles.ts
309
+ var Avatar = __toESM(require("@radix-ui/react-avatar"));
310
+ var AvatarContainer = styled(Avatar.Root, {
311
+ borderRadius: "$full",
312
+ display: "inline-block",
313
+ width: "$12",
314
+ height: "$12",
315
+ overflow: "hidden"
316
+ });
317
+ var AvatarImage = styled(Avatar.Image, {
318
+ width: "100%",
319
+ height: "100%",
320
+ objectFix: "cover",
321
+ borderRadius: "inherit"
322
+ });
323
+ var AvatarFallback = styled(Avatar.Fallback, {
324
+ width: "100%",
325
+ height: "100%",
326
+ display: "flex",
327
+ alignItems: "center",
328
+ justifyContent: "center",
329
+ backgroundColor: "$gray600",
330
+ color: "$gray800",
331
+ svg: {
332
+ width: "$6",
333
+ height: "$6"
334
+ }
335
+ });
336
+
337
+ // src/components/Avatar/index.tsx
338
+ var import_phosphor_react = require("phosphor-react");
339
+ var import_jsx_runtime = require("react/jsx-runtime");
340
+ function Avatar2(props) {
341
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AvatarContainer, { children: [
342
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarImage, __spreadValues({}, props)),
343
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarFallback, { delayMs: 600, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_phosphor_react.User, {}) })
344
+ ] });
345
+ }
346
+ Avatar2.displayName = "Avatar";
347
+
348
+ // src/components/Button.tsx
349
+ var Button = styled("button", {
350
+ all: "unset",
351
+ fontFamily: "$default",
352
+ fontWeight: "$medium",
353
+ fontSize: "$sm",
354
+ textAlign: "center",
355
+ minWidth: 0,
356
+ boxSizing: "border-box",
357
+ display: "flex",
358
+ alignItems: "center",
359
+ justifyContent: "center",
360
+ gap: "$2",
361
+ cursor: "pointer",
362
+ transition: "0.2s",
363
+ svg: {
364
+ width: "$4",
365
+ height: "$4"
366
+ },
367
+ "&:disabled": {
368
+ cursor: "not-allowed",
369
+ backgroundColor: "$gray200",
370
+ borderColor: "$gray200"
371
+ },
372
+ variants: {
373
+ variant: {
374
+ default: {
375
+ backgroundColor: "transparent",
376
+ border: "2px solid $gray500",
377
+ color: "$smokedWhite",
378
+ "&:not(:disabled):hover": {
379
+ // backgroundColor: '$smokedWhite',
380
+ // borderColor: '$smokedWhite',
381
+ // color: '$gray900',
382
+ borderColor: "$gray600"
383
+ }
384
+ },
385
+ primary: {
386
+ backgroundColor: "$primary",
387
+ border: "2px solid $primary",
388
+ color: "$smokedWhite",
389
+ "&:not(:disabled):hover": {
390
+ backgroundColor: "$primaryLight",
391
+ borderColor: "$primaryLight"
392
+ }
393
+ }
394
+ },
395
+ size: {
396
+ default: {
397
+ padding: "$3 $6"
398
+ },
399
+ fit: {
400
+ width: "100%",
401
+ paddingTop: "$3",
402
+ paddingBottom: "$3"
403
+ },
404
+ small: {
405
+ padding: "$3 $4"
406
+ }
407
+ },
408
+ radius: {
409
+ small: {
410
+ borderRadius: "$sm"
411
+ },
412
+ default: {
413
+ borderRadius: "$lg"
414
+ },
415
+ full: {
416
+ borderRadius: "$full"
417
+ }
418
+ }
419
+ },
420
+ defaultVariants: {
421
+ size: "default",
422
+ radius: "default",
423
+ variant: "default"
424
+ }
425
+ });
426
+ Button.displayName = "Button";
427
+
428
+ // src/components/TextInput/styles.ts
429
+ var TextInputContainer = styled("div", {
430
+ backgroundColor: "$gray900",
431
+ padding: "$3 $4",
432
+ borderRadius: "$sm",
433
+ boxSizing: "border-box",
434
+ border: "2px solid $gray900",
435
+ display: "flex",
436
+ alignItems: "baseline",
437
+ "&:has(input:focus)": {
438
+ borderColor: "$primary"
439
+ },
440
+ "&:has(input:disabled)": {
441
+ opacity: 0.5,
442
+ cursor: "not-alowed"
443
+ },
444
+ variants: {
445
+ errored: {
446
+ true: {
447
+ borderColor: "$danger"
448
+ }
449
+ }
450
+ },
451
+ defaultVariants: {
452
+ errored: false
453
+ }
454
+ });
455
+ var Prefix = styled("span", {
456
+ fontFamily: "$default",
457
+ fontSize: "$sm",
458
+ color: "$gray400",
459
+ fontWeight: "regular"
460
+ });
461
+ var Input = styled("input", {
462
+ fontFamily: "$default",
463
+ fontSize: "$sm",
464
+ color: "$smokedWhite",
465
+ fontWeight: "regular",
466
+ background: "transparent",
467
+ border: 0,
468
+ width: "100%",
469
+ "&:focus": {
470
+ outline: 0
471
+ },
472
+ "&:disabled": {
473
+ cursor: "not-allowed"
474
+ },
475
+ "&:placeholder": {
476
+ color: "$gray400"
477
+ }
478
+ });
479
+
480
+ // src/components/InputBox/styles.ts
481
+ var InputContainer = styled("div", {
482
+ display: "flex",
483
+ flexDirection: "column",
484
+ gap: "$2"
485
+ });
486
+
487
+ // src/components/InputBox/index.tsx
488
+ var import_jsx_runtime2 = require("react/jsx-runtime");
489
+ function InputBox({ label, error, children }) {
490
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(InputContainer, { children: [
491
+ !!label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { size: "sm", children: label }),
492
+ children,
493
+ !!error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { size: "xs", variant: "danger", children: error })
494
+ ] });
495
+ }
496
+ InputBox.displayName = "InputBox";
497
+
498
+ // src/components/TextInput/index.tsx
499
+ var import_jsx_runtime3 = require("react/jsx-runtime");
500
+ function TextInput(_a) {
501
+ var _b = _a, { label, prefix, error } = _b, props = __objRest(_b, ["label", "prefix", "error"]);
502
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InputBox, { label, error, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(TextInputContainer, { errored: !!error, children: [
503
+ !!prefix && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Prefix, { children: prefix }),
504
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, __spreadValues({}, props))
505
+ ] }) });
506
+ }
507
+ TextInput.displayName = "TextInput";
508
+
509
+ // src/components/TextArea/styles.ts
510
+ var TextAreaInput = styled("textarea", {
511
+ backgroundColor: "$gray900",
512
+ padding: "$3 $4",
513
+ borderRadius: "$sm",
514
+ boxSizing: "border-box",
515
+ border: "2px solid $gray900",
516
+ fontFamily: "$default",
517
+ fontSize: "$sm",
518
+ color: "$white",
519
+ fontWeight: "$regular",
520
+ resize: "vertical",
521
+ minHeight: 80,
522
+ "&:focus": {
523
+ outline: 0,
524
+ borderColor: "$primary"
525
+ },
526
+ "&:disabled": {
527
+ opacity: 0.5,
528
+ cursor: "not-allowed"
529
+ },
530
+ "&:placeholder": {
531
+ color: "$gray400"
532
+ },
533
+ variants: {
534
+ errored: {
535
+ true: {
536
+ borderColor: "$danger"
537
+ }
538
+ }
539
+ },
540
+ defaultVariants: {
541
+ errored: false
542
+ }
543
+ });
544
+
545
+ // src/components/TextArea/index.tsx
546
+ var import_jsx_runtime4 = require("react/jsx-runtime");
547
+ function TextArea(_a) {
548
+ var _b = _a, { label, error } = _b, props = __objRest(_b, ["label", "error"]);
549
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(InputBox, { label, error, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TextAreaInput, __spreadProps(__spreadValues({}, props), { errored: !!error })) });
550
+ }
551
+ TextArea.displayName = "TextArea";
552
+
553
+ // src/components/Checkbox/index.tsx
554
+ var import_phosphor_react2 = require("phosphor-react");
555
+
556
+ // src/components/Checkbox/styles.ts
557
+ var Checkbox = __toESM(require("@radix-ui/react-checkbox"));
558
+ var CheckboxBox = styled("div", {
559
+ display: "flex",
560
+ gap: "$2",
561
+ "&:has(button:disabled)": {
562
+ opacity: 0.5
563
+ }
564
+ });
565
+ var CheckboxContainer = styled(Checkbox.Root, {
566
+ all: "unset",
567
+ width: "$6",
568
+ height: "$6",
569
+ backgroundColor: "$gray900",
570
+ borderRadius: "$xs",
571
+ lineHeight: 0,
572
+ cursor: "pointer",
573
+ overflow: "hidden",
574
+ boxSizing: "border-box",
575
+ display: "flex",
576
+ justifyContent: "center",
577
+ alignItems: "center",
578
+ border: "2px solid $gray900",
579
+ '&[data-state="checked"]': {
580
+ backgroundColor: "$primary",
581
+ borderColor: "$primary"
582
+ },
583
+ "&:focus": {
584
+ border: "2px solid $primary"
585
+ },
586
+ "&:disabled": {
587
+ cursor: "not-allowed"
588
+ },
589
+ variants: {
590
+ errored: {
591
+ true: {
592
+ borderColor: "$danger"
593
+ }
594
+ }
595
+ },
596
+ defaultVariants: {
597
+ errored: false
598
+ }
599
+ });
600
+ var slideIn = keyframes({
601
+ from: {
602
+ transform: "translateX(-100%)"
603
+ },
604
+ to: {
605
+ transform: "translateX(0)"
606
+ }
607
+ });
608
+ var slideOut = keyframes({
609
+ from: {
610
+ transform: "translateX(0)"
611
+ },
612
+ to: {
613
+ transform: "translateX(100%)"
614
+ }
615
+ });
616
+ var CheckboxIndicator = styled(Checkbox.Indicator, {
617
+ color: "$smokedWhite",
618
+ width: "$4",
619
+ height: "$4",
620
+ '&[data-state="checked"]': {
621
+ animation: `${slideIn} 100ms ease-out`
622
+ },
623
+ '&[data-state="unchecked"]': {
624
+ animation: `${slideOut} 100ms ease-out`
625
+ }
626
+ });
627
+
628
+ // src/components/Checkbox/index.tsx
629
+ var import_jsx_runtime5 = require("react/jsx-runtime");
630
+ function Checkbox2(_a) {
631
+ var _b = _a, { label, error } = _b, props = __objRest(_b, ["label", "error"]);
632
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InputBox, { error, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(CheckboxBox, { children: [
633
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckboxContainer, __spreadProps(__spreadValues({}, props), { errored: !!error, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckboxIndicator, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_phosphor_react2.Check, { weight: "bold" }) }) })),
634
+ !!label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { size: "sm", children: label })
635
+ ] }) });
636
+ }
637
+ Checkbox2.displayName = "Checkbox";
638
+
639
+ // src/components/Dropdown/index.tsx
640
+ var import_react2 = require("react");
641
+
642
+ // src/components/Dropdown/styles.ts
643
+ var DropdownContainer = styled("div", {
644
+ position: "relative",
645
+ display: "inline-block"
646
+ });
647
+ var DropdownTrigger = styled("span", {});
648
+ var fadeIn = keyframes({
649
+ "0%": { opacity: "0" },
650
+ "100%": { opacity: "1" }
651
+ });
652
+ var DropdownList = styled("ul", {
653
+ position: "absolute",
654
+ // top: '100%',
655
+ // left: 0,
656
+ backgroundColor: "#18181B",
657
+ borderRadius: "$lg",
658
+ padding: 0,
659
+ // margin: '$1 0',
660
+ margin: 0,
661
+ listStyle: "none",
662
+ zIndex: 9999,
663
+ minWidth: "100%",
664
+ // ensures the dropdown list as wide as the container
665
+ left: "50%",
666
+ transform: "translateX(-50%)",
667
+ animation: `${fadeIn} 100ms ease-out`,
668
+ "& li:first-child": {
669
+ marginTop: "$2"
670
+ },
671
+ "& li:last-child": {
672
+ marginBottom: "$2"
673
+ }
674
+ });
675
+ var DropdownItem = styled("li", {
676
+ fontFamily: "$default",
677
+ fontSize: "$sm",
678
+ color: "$smokedWhite",
679
+ padding: "$2 $2",
680
+ marginLeft: "$2",
681
+ marginRight: "$2",
682
+ width: "$40",
683
+ borderRadius: "$md",
684
+ cursor: "pointer",
685
+ variants: {
686
+ variant: {
687
+ default: {
688
+ color: "$smokedWhite",
689
+ "&:hover": {
690
+ backgroundColor: "$gray700"
691
+ }
692
+ },
693
+ danger: {
694
+ color: "$danger",
695
+ "&:hover": {
696
+ backgroundColor: "$danger",
697
+ color: "$smokedWhite"
698
+ }
699
+ }
700
+ }
701
+ },
702
+ defaultVariants: {
703
+ variant: "default"
704
+ }
705
+ });
706
+
707
+ // src/components/Dropdown/index.tsx
708
+ var import_jsx_runtime6 = require("react/jsx-runtime");
709
+ function Dropdown({ options, children, name }) {
710
+ const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
711
+ const dropdownRef = (0, import_react2.useRef)(null);
712
+ const buttonRef = (0, import_react2.useRef)(null);
713
+ const toggleDropdown = () => {
714
+ setIsOpen(!isOpen);
715
+ };
716
+ const handleSelectOption = (option) => {
717
+ option.onSelect();
718
+ setIsOpen(false);
719
+ };
720
+ const handleClickOutside = (event) => {
721
+ if (dropdownRef.current && buttonRef.current && !dropdownRef.current.contains(event.target) && !buttonRef.current.contains(event.target)) {
722
+ setIsOpen(false);
723
+ }
724
+ };
725
+ (0, import_react2.useEffect)(() => {
726
+ document.addEventListener("mousedown", handleClickOutside);
727
+ return () => {
728
+ document.removeEventListener("mousedown", handleClickOutside);
729
+ };
730
+ }, []);
731
+ (0, import_react2.useEffect)(() => {
732
+ const handleReposition = () => {
733
+ if (isOpen && buttonRef.current && dropdownRef.current) {
734
+ const buttonRect = buttonRef.current.getBoundingClientRect();
735
+ const dropdownRect = dropdownRef.current.getBoundingClientRect();
736
+ const buttonTop = buttonRect.top;
737
+ const buttonHeight = buttonRect.height;
738
+ const dropdownHeight = dropdownRect.height;
739
+ const spaceBelow = window.innerHeight - buttonTop - buttonHeight;
740
+ if (spaceBelow < dropdownHeight) {
741
+ dropdownRef.current.style.bottom = `${buttonHeight + 6}px`;
742
+ } else {
743
+ dropdownRef.current.style.top = `${buttonHeight + 6}px`;
744
+ }
745
+ }
746
+ };
747
+ handleReposition();
748
+ }, [isOpen]);
749
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownContainer, { children: [
750
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownTrigger, { ref: buttonRef, onClick: toggleDropdown, children: [
751
+ name && children === void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { children: name }),
752
+ children && name === void 0 && children
753
+ ] }),
754
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownList, { ref: dropdownRef, children: options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
755
+ DropdownItem,
756
+ {
757
+ onClick: () => handleSelectOption(option),
758
+ variant: option.variant,
759
+ children: option.text
760
+ },
761
+ index
762
+ )) })
763
+ ] });
764
+ }
765
+ Dropdown.displayName = "Dropdown";
766
+ // Annotate the CommonJS export names for ESM import in node:
767
+ 0 && (module.exports = {
768
+ Avatar,
769
+ Box,
770
+ Button,
771
+ Checkbox,
772
+ Dropdown,
773
+ Heading,
774
+ Text,
775
+ TextArea,
776
+ TextInput
777
+ });