@ttoss/ui 5.0.6 → 5.0.7

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.
@@ -0,0 +1,902 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+
3
+ // src/index.ts
4
+ import { BaseStyles, Global as Global2 } from "theme-ui";
5
+ import { useResponsiveValue, useBreakpointIndex } from "@theme-ui/match-media";
6
+ import { keyframes } from "@emotion/react";
7
+
8
+ // src/theme/ThemeProvider.tsx
9
+ import { BruttalFonts, BruttalTheme } from "@ttoss/theme/Bruttal";
10
+ import { Global, css } from "@emotion/react";
11
+ import { ThemeUIProvider } from "theme-ui";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ var ThemeProvider = ({
14
+ children,
15
+ theme = BruttalTheme,
16
+ fonts = BruttalFonts
17
+ }) => {
18
+ return /* @__PURE__ */jsx(Fragment, {
19
+ children: /* @__PURE__ */jsxs(ThemeUIProvider, {
20
+ theme,
21
+ children: [/* @__PURE__ */jsx(Global, {
22
+ styles: css`
23
+ ${fonts.map(url => {
24
+ return `@import url('${url}');`;
25
+ }).join("\n")}
26
+ `
27
+ }), children]
28
+ })
29
+ });
30
+ };
31
+
32
+ // src/theme/useTheme.ts
33
+ import { useThemeUI } from "theme-ui";
34
+ var useTheme = useThemeUI;
35
+
36
+ // src/components/Badge.tsx
37
+ import { Badge as BadgeUi } from "theme-ui";
38
+ import { Icon } from "@ttoss/react-icons";
39
+
40
+ // src/components/Text.tsx
41
+ import { Text } from "theme-ui";
42
+
43
+ // src/components/Badge.tsx
44
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
45
+ var Badge = ({
46
+ icon,
47
+ children,
48
+ sx,
49
+ chip,
50
+ onDelete,
51
+ ...props
52
+ }) => {
53
+ return /* @__PURE__ */jsxs2(BadgeUi, {
54
+ sx: {
55
+ display: "flex",
56
+ alignItems: "center",
57
+ fontFamily: "caption",
58
+ fontWeight: "normal",
59
+ lineHeight: "base",
60
+ fontSize: "sm",
61
+ paddingX: "xs",
62
+ borderRadius: "informative",
63
+ paddingY: "2xs",
64
+ gap: "xs",
65
+ ...sx
66
+ },
67
+ ...props,
68
+ children: [icon && /* @__PURE__ */jsx2(Icon, {
69
+ inline: true,
70
+ icon
71
+ }), children, chip && /* @__PURE__ */jsx2(Text, {
72
+ sx: {
73
+ cursor: "pointer",
74
+ lineHeight: 0,
75
+ color: "currentcolor",
76
+ alignSelf: "center"
77
+ },
78
+ children: /* @__PURE__ */jsx2(Icon, {
79
+ onClick: onDelete,
80
+ inline: true,
81
+ icon: "close"
82
+ })
83
+ })]
84
+ });
85
+ };
86
+
87
+ // src/components/Box.tsx
88
+ import { Box } from "theme-ui";
89
+
90
+ // src/components/Button.tsx
91
+ import * as React from "react";
92
+ import { Button as ButtonUi } from "theme-ui";
93
+ import { Icon as Icon2 } from "@ttoss/react-icons";
94
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
95
+ var Button = React.forwardRef((props, ref) => {
96
+ const {
97
+ children,
98
+ leftIcon,
99
+ rightIcon,
100
+ loading,
101
+ ...restProps
102
+ } = props;
103
+ return /* @__PURE__ */jsxs3(ButtonUi, {
104
+ type: "button",
105
+ ...restProps,
106
+ ref,
107
+ sx: {
108
+ cursor: "pointer",
109
+ paddingX: "xl",
110
+ paddingY: "lg",
111
+ fontFamily: "body",
112
+ display: "inline-flex",
113
+ alignItems: "center",
114
+ gap: "lg",
115
+ ...restProps.sx
116
+ },
117
+ children: [loading && /* @__PURE__ */jsx3(Icon2, {
118
+ inline: true,
119
+ icon: "three-dots-loading"
120
+ }), !loading && leftIcon && /* @__PURE__ */jsx3(Icon2, {
121
+ inline: true,
122
+ icon: leftIcon
123
+ }), children, rightIcon && /* @__PURE__ */jsx3(Icon2, {
124
+ inline: true,
125
+ icon: rightIcon
126
+ })]
127
+ });
128
+ });
129
+ Button.displayName = "Button";
130
+
131
+ // src/components/Card.tsx
132
+ import { Card } from "theme-ui";
133
+
134
+ // src/components/Divider.tsx
135
+ import { Divider } from "theme-ui";
136
+
137
+ // src/components/Flex.tsx
138
+ import { Flex } from "theme-ui";
139
+
140
+ // src/components/Grid.tsx
141
+ import { Grid } from "theme-ui";
142
+
143
+ // src/components/Heading.tsx
144
+ import { Heading } from "theme-ui";
145
+
146
+ // src/components/Image.tsx
147
+ import { Image } from "theme-ui";
148
+
149
+ // src/components/Input.tsx
150
+ import * as React2 from "react";
151
+ import { Icon as Icon3 } from "@ttoss/react-icons";
152
+ import { Input as InputUI } from "theme-ui";
153
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
154
+ var Input = React2.forwardRef(({
155
+ leadingIcon,
156
+ trailingIcon: trailingIconProp,
157
+ onLeadingIconClick,
158
+ onTrailingIconClick,
159
+ className,
160
+ sx,
161
+ ...inputProps
162
+ }, ref) => {
163
+ const trailingIcon = inputProps["aria-invalid"] ? "warning-alt" : trailingIconProp;
164
+ return /* @__PURE__ */jsxs4(Flex, {
165
+ className,
166
+ sx: {
167
+ ...sx,
168
+ position: "relative",
169
+ padding: 0,
170
+ border: "none"
171
+ },
172
+ children: [leadingIcon && /* @__PURE__ */jsx4(Text, {
173
+ sx: {
174
+ position: "absolute",
175
+ alignSelf: "center",
176
+ left: "1rem",
177
+ cursor: onLeadingIconClick ? "pointer" : "default"
178
+ },
179
+ onClick: onLeadingIconClick,
180
+ variant: "leading-icon",
181
+ children: /* @__PURE__ */jsx4(Icon3, {
182
+ inline: true,
183
+ icon: leadingIcon
184
+ })
185
+ }), /* @__PURE__ */jsx4(InputUI, {
186
+ ref,
187
+ sx: {
188
+ fontFamily: "body",
189
+ paddingY: "lg",
190
+ paddingX: "xl",
191
+ ...sx,
192
+ paddingLeft: leadingIcon ? "3xl" : void 0,
193
+ paddingRight: trailingIcon ? "3xl" : void 0,
194
+ margin: 0
195
+ },
196
+ className,
197
+ ...inputProps
198
+ }), trailingIcon && /* @__PURE__ */jsx4(Text, {
199
+ sx: {
200
+ position: "absolute",
201
+ right: "1rem",
202
+ alignSelf: "center",
203
+ cursor: onTrailingIconClick ? "pointer" : "default"
204
+ },
205
+ variant: "trailing-icon",
206
+ onClick: onTrailingIconClick,
207
+ children: /* @__PURE__ */jsx4(Icon3, {
208
+ inline: true,
209
+ icon: trailingIcon
210
+ })
211
+ })]
212
+ });
213
+ });
214
+ Input.displayName = "Input";
215
+
216
+ // src/components/Label.tsx
217
+ import { Icon as Icon4 } from "@ttoss/react-icons";
218
+ import { Label as LabelUi } from "theme-ui";
219
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
220
+ var TOOLTIP_LABEL = "tooltip";
221
+ var Label = ({
222
+ children,
223
+ onTooltipClick,
224
+ tooltip,
225
+ sx,
226
+ ...props
227
+ }) => {
228
+ return /* @__PURE__ */jsxs5(LabelUi, {
229
+ sx: {
230
+ fontFamily: "caption",
231
+ alignItems: "center",
232
+ fontSize: "sm",
233
+ lineHeight: "base",
234
+ ...sx
235
+ },
236
+ ...props,
237
+ children: [children, tooltip && /* @__PURE__ */jsx5(Text, {
238
+ sx: {
239
+ color: "currentcolor",
240
+ cursor: onTooltipClick ? "pointer" : void 0
241
+ },
242
+ onClick: onTooltipClick,
243
+ "aria-label": TOOLTIP_LABEL,
244
+ children: /* @__PURE__ */jsx5(Icon4, {
245
+ inline: true,
246
+ icon: "info"
247
+ })
248
+ })]
249
+ });
250
+ };
251
+
252
+ // src/components/Link.tsx
253
+ import * as React3 from "react";
254
+ import { Link as LinkUi } from "theme-ui";
255
+ import { jsx as jsx6 } from "react/jsx-runtime";
256
+ var Link = React3.forwardRef(({
257
+ quiet,
258
+ className,
259
+ ...props
260
+ }, ref) => {
261
+ return /* @__PURE__ */jsx6(LinkUi, {
262
+ className: `${quiet ? "quiet" : ""} ${className ?? ""}`,
263
+ ...props,
264
+ ref
265
+ });
266
+ });
267
+ Link.displayName = "Link";
268
+
269
+ // src/components/LinearProgress.tsx
270
+ import { Progress } from "theme-ui";
271
+
272
+ // src/components/Select.tsx
273
+ import * as React4 from "react";
274
+ import { Icon as Icon5 } from "@ttoss/react-icons";
275
+ import ReactSelect, { components } from "react-select";
276
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
277
+ var Control = props => {
278
+ const isDisabled = props.selectProps.isDisabled;
279
+ const hasError = props.selectProps["aria-invalid"] === "true";
280
+ const border = (() => {
281
+ if (isDisabled) {
282
+ return "muted";
283
+ }
284
+ if (hasError) {
285
+ return "danger";
286
+ }
287
+ return "interaction";
288
+ })();
289
+ const backgroundColor = (() => {
290
+ if (isDisabled) {
291
+ return "muted";
292
+ }
293
+ return "surface";
294
+ })();
295
+ return /* @__PURE__ */jsx7(Box, {
296
+ sx: {
297
+ ".react-select__control": {
298
+ border,
299
+ backgroundColor,
300
+ paddingX: "xl",
301
+ paddingY: "lg",
302
+ borderRadius: "action"
303
+ }
304
+ },
305
+ children: /* @__PURE__ */jsx7(components.Control, {
306
+ ...props
307
+ })
308
+ });
309
+ };
310
+ var DropdownIndicator = props => {
311
+ const isDisabled = props.selectProps.isDisabled;
312
+ const color = (() => {
313
+ if (isDisabled) {
314
+ return "onMuted";
315
+ }
316
+ return "text";
317
+ })();
318
+ return /* @__PURE__ */jsx7(Text, {
319
+ sx: {
320
+ fontSize: "base",
321
+ color,
322
+ alignSelf: "center",
323
+ display: "flex",
324
+ alignItems: "center"
325
+ },
326
+ children: /* @__PURE__ */jsx7(Icon5, {
327
+ icon: "picker-down"
328
+ })
329
+ });
330
+ };
331
+ var IndicatorsContainer = ({
332
+ children
333
+ }) => {
334
+ return /* @__PURE__ */jsx7(Box, {
335
+ sx: {
336
+ marginLeft: "lg",
337
+ border: "none"
338
+ },
339
+ children
340
+ });
341
+ };
342
+ var Placeholder = ({
343
+ children
344
+ }) => {
345
+ return /* @__PURE__ */jsx7(Text, {
346
+ sx: {
347
+ color: "onMuted",
348
+ alignSelf: "center"
349
+ },
350
+ children
351
+ });
352
+ };
353
+ var SelectContainer = ({
354
+ children,
355
+ ...props
356
+ }) => {
357
+ const {
358
+ sx,
359
+ css: css2
360
+ } = props.selectProps;
361
+ return (
362
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
363
+ /* @__PURE__ */
364
+ jsx7(Box, {
365
+ sx,
366
+ css: css2,
367
+ children: /* @__PURE__ */jsx7(components.SelectContainer, {
368
+ ...props,
369
+ children
370
+ })
371
+ })
372
+ );
373
+ };
374
+ var ValueContainer = ({
375
+ children,
376
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
377
+ ...props
378
+ }) => {
379
+ const {
380
+ leadingIcon,
381
+ trailingIcon,
382
+ isSearchable
383
+ } = props.selectProps;
384
+ const hasError = props.selectProps["aria-invalid"] === "true";
385
+ const trailingIconColor = (() => {
386
+ if (hasError) {
387
+ return "danger";
388
+ }
389
+ return "text";
390
+ })();
391
+ const finalLeadingIcon = (() => {
392
+ if (!isSearchable) {
393
+ return leadingIcon;
394
+ }
395
+ return leadingIcon || "search";
396
+ })();
397
+ return /* @__PURE__ */jsxs6(Flex, {
398
+ sx: {
399
+ gap: "lg",
400
+ flex: 1
401
+ },
402
+ children: [finalLeadingIcon && /* @__PURE__ */jsx7(Text, {
403
+ sx: {
404
+ alignSelf: "center",
405
+ pointerEvents: "none",
406
+ lineHeight: 0,
407
+ fontSize: "base"
408
+ },
409
+ children: /* @__PURE__ */jsx7(Icon5, {
410
+ icon: finalLeadingIcon
411
+ })
412
+ }), /* @__PURE__ */jsx7(Flex, {
413
+ sx: {
414
+ flex: 1,
415
+ alignItems: "center"
416
+ },
417
+ children
418
+ }), (trailingIcon || hasError) && /* @__PURE__ */jsx7(Text, {
419
+ className: hasError ? "error-icon" : "",
420
+ sx: {
421
+ alignSelf: "center",
422
+ pointerEvents: "none",
423
+ lineHeight: 0,
424
+ fontSize: "base",
425
+ color: trailingIconColor
426
+ },
427
+ children: /* @__PURE__ */jsx7(Icon5, {
428
+ icon: hasError ? "warning-alt" : trailingIcon
429
+ })
430
+ })]
431
+ });
432
+ };
433
+ var Select = React4.forwardRef(({
434
+ ...props
435
+ }, ref) => {
436
+ const value = props.options?.find(option => {
437
+ if ("value" in option) {
438
+ return option.value === props.value;
439
+ }
440
+ return false;
441
+ });
442
+ return /* @__PURE__ */jsx7(ReactSelect, {
443
+ ref,
444
+ components: {
445
+ Control,
446
+ DropdownIndicator,
447
+ IndicatorsContainer,
448
+ Placeholder,
449
+ SelectContainer,
450
+ ValueContainer
451
+ },
452
+ isDisabled: props.disabled,
453
+ ...props,
454
+ value,
455
+ onChange: value2 => {
456
+ props.onChange?.(value2?.value);
457
+ },
458
+ styles: {
459
+ input: baseStyles => {
460
+ return {
461
+ ...baseStyles,
462
+ position: "absolute"
463
+ };
464
+ }
465
+ },
466
+ classNamePrefix: "react-select"
467
+ });
468
+ });
469
+ Select.displayName = "Select";
470
+
471
+ // src/components/Spinner.tsx
472
+ import { Spinner } from "theme-ui";
473
+
474
+ // src/components/Radio.tsx
475
+ import { Radio } from "theme-ui";
476
+
477
+ // src/components/IconButton.tsx
478
+ import * as React5 from "react";
479
+ import { IconButton as IconButtonUi } from "theme-ui";
480
+ import { jsx as jsx8 } from "react/jsx-runtime";
481
+ var IconButton = React5.forwardRef((props, ref) => {
482
+ return /* @__PURE__ */jsx8(IconButtonUi, {
483
+ type: "button",
484
+ ...props,
485
+ ref
486
+ });
487
+ });
488
+ IconButton.displayName = "IconButton";
489
+
490
+ // src/components/Slider.tsx
491
+ import { Slider } from "theme-ui";
492
+
493
+ // src/components/Checkbox.tsx
494
+ import * as React6 from "react";
495
+ import { Checkbox as CheckBoxUi } from "theme-ui";
496
+ import { jsx as jsx9 } from "react/jsx-runtime";
497
+ var Checkbox = React6.forwardRef(({
498
+ indeterminate = false,
499
+ ...rest
500
+ }, ref) => {
501
+ const innerRef = React6.useRef(null);
502
+ React6.useImperativeHandle(ref, () => {
503
+ return innerRef.current;
504
+ });
505
+ React6.useEffect(() => {
506
+ if (innerRef.current) {
507
+ innerRef.current.indeterminate = indeterminate;
508
+ }
509
+ }, [indeterminate]);
510
+ if (indeterminate) {
511
+ return /* @__PURE__ */jsx9("input", {
512
+ type: "checkbox",
513
+ ref: innerRef,
514
+ ...rest
515
+ });
516
+ }
517
+ return /* @__PURE__ */jsx9(CheckBoxUi, {
518
+ ref: innerRef,
519
+ ...rest
520
+ });
521
+ });
522
+ Checkbox.displayName = "Checkbox";
523
+
524
+ // src/components/InfiniteLinearProgress.tsx
525
+ import * as React7 from "react";
526
+ import { jsx as jsx10 } from "react/jsx-runtime";
527
+ var MAX_PROGRESS = 100;
528
+ var InfiniteLinearProgress = () => {
529
+ const [progress, setProgress] = React7.useState(0);
530
+ React7.useEffect(() => {
531
+ const timer = setInterval(() => {
532
+ setProgress(oldProgress => {
533
+ if (oldProgress === MAX_PROGRESS) {
534
+ return 0;
535
+ }
536
+ let diff = 0;
537
+ if (oldProgress > 0.97 * MAX_PROGRESS) {
538
+ diff -= 0.75 * MAX_PROGRESS;
539
+ } else if (oldProgress > 0.6 * MAX_PROGRESS) {
540
+ diff = Math.random() * (MAX_PROGRESS - oldProgress) * 0.1;
541
+ } else {
542
+ diff = Math.random() * (MAX_PROGRESS * 0.02);
543
+ }
544
+ return Math.min(oldProgress + diff, MAX_PROGRESS);
545
+ });
546
+ }, 100);
547
+ return () => {
548
+ clearInterval(timer);
549
+ };
550
+ }, []);
551
+ return /* @__PURE__ */jsx10(Progress, {
552
+ max: MAX_PROGRESS,
553
+ value: progress,
554
+ role: "progressbar"
555
+ });
556
+ };
557
+
558
+ // src/components/Textarea.tsx
559
+ import * as React8 from "react";
560
+ import { Icon as Icon6 } from "@ttoss/react-icons";
561
+ import { Textarea as TextareaUI } from "theme-ui";
562
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
563
+ var Textarea = React8.forwardRef(({
564
+ trailingIcon,
565
+ className,
566
+ sx,
567
+ ...textareaProps
568
+ }, ref) => {
569
+ return /* @__PURE__ */jsxs7(Flex, {
570
+ className,
571
+ sx: {
572
+ ...sx,
573
+ position: "relative",
574
+ padding: 0,
575
+ border: "none"
576
+ },
577
+ children: [/* @__PURE__ */jsx11(TextareaUI, {
578
+ ref,
579
+ sx: {
580
+ fontFamily: "body",
581
+ paddingY: "lg",
582
+ paddingX: "xl",
583
+ ...sx,
584
+ paddingRight: trailingIcon ? "3xl" : void 0,
585
+ margin: 0
586
+ },
587
+ className,
588
+ ...textareaProps
589
+ }), trailingIcon && /* @__PURE__ */jsx11(Text, {
590
+ sx: {
591
+ position: "absolute",
592
+ right: "1.25rem",
593
+ top: "0.75rem"
594
+ },
595
+ children: /* @__PURE__ */jsx11(Icon6, {
596
+ inline: true,
597
+ icon: trailingIcon
598
+ })
599
+ })]
600
+ });
601
+ });
602
+ Textarea.displayName = "Textarea";
603
+
604
+ // src/components/Container.tsx
605
+ import * as React9 from "react";
606
+ import { Container as ContainerUi } from "theme-ui";
607
+ import { jsx as jsx12 } from "react/jsx-runtime";
608
+ var Container = React9.forwardRef((props, ref) => {
609
+ return /* @__PURE__ */jsx12(ContainerUi, {
610
+ ref,
611
+ ...props
612
+ });
613
+ });
614
+ Container.displayName = "Container";
615
+
616
+ // src/components/HelpText.tsx
617
+ import { jsx as jsx13 } from "react/jsx-runtime";
618
+ var HelpText = ({
619
+ sx,
620
+ disabled,
621
+ negative,
622
+ ...props
623
+ }) => {
624
+ const variant = ["text.help", negative ? "negative" : void 0].filter(Boolean).join(".");
625
+ return /* @__PURE__ */jsx13(Text, {
626
+ variant,
627
+ sx: {
628
+ fontSize: "sm",
629
+ fontFamily: "caption",
630
+ lineHeight: "base",
631
+ ...sx
632
+ },
633
+ "aria-disabled": disabled ? "true" : void 0,
634
+ ...props
635
+ });
636
+ };
637
+
638
+ // src/components/CloseButton.tsx
639
+ import * as React10 from "react";
640
+ import { Icon as Icon7 } from "@ttoss/react-icons";
641
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
642
+ var CloseButton = React10.forwardRef(({
643
+ label,
644
+ sx,
645
+ onlyText,
646
+ ...props
647
+ }, ref) => {
648
+ if (onlyText && !label) {
649
+ return null;
650
+ }
651
+ return /* @__PURE__ */jsxs8(Button, {
652
+ variant: "buttons.closeButton",
653
+ type: "button",
654
+ "aria-label": label,
655
+ sx: {
656
+ fontFamily: "caption",
657
+ fontSize: "xs",
658
+ display: "inline-flex",
659
+ alignItems: "center",
660
+ cursor: "pointer",
661
+ lineHeight: "normal",
662
+ gap: "sm",
663
+ padding: "sm",
664
+ width: "fit-content",
665
+ transition: "all 0.2s",
666
+ "& > iconify-icon": {
667
+ fontSize: "base"
668
+ },
669
+ ...sx
670
+ },
671
+ ...props,
672
+ ref,
673
+ children: [label, !onlyText && /* @__PURE__ */jsx14(Icon7, {
674
+ icon: "close"
675
+ })]
676
+ });
677
+ });
678
+ CloseButton.displayName = "CloseButton";
679
+
680
+ // src/components/InputNumber.tsx
681
+ import * as React11 from "react";
682
+ import { Icon as Icon8 } from "@ttoss/react-icons";
683
+ import { Input as Input2 } from "theme-ui";
684
+ import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
685
+ var InputNumber = React11.forwardRef(({
686
+ sx,
687
+ value,
688
+ infoIcon,
689
+ onChange,
690
+ onClickInfoIcon,
691
+ ...inputProps
692
+ }, ref) => {
693
+ const sxProps = React11.useMemo(() => {
694
+ const size = String(typeof value === "undefined" ? 0 : value).length;
695
+ if (inputProps["aria-invalid"] === "true") {
696
+ return {
697
+ width: `calc(139px + ${size > 1 ? size * 10 : 0}px)`,
698
+ textAlign: "left",
699
+ "&[type=number]::-webkit-inner-spin-button, &[type=number]::-webkit-outer-spin-button": {
700
+ WebkitAppearance: "none",
701
+ margin: 0
702
+ },
703
+ ...sx,
704
+ paddingLeft: "3xl",
705
+ paddingRight: "2xl",
706
+ margin: 0
707
+ };
708
+ }
709
+ return {
710
+ width: `calc(108px + ${size > 1 ? size * 10 : 0}px)`,
711
+ textAlign: "center",
712
+ "&[type=number]::-webkit-inner-spin-button, &[type=number]::-webkit-outer-spin-button": {
713
+ WebkitAppearance: "none",
714
+ margin: 0
715
+ },
716
+ fontFamily: "body",
717
+ paddingY: "lg",
718
+ paddingX: "xl",
719
+ ...sx,
720
+ paddingLeft: "2xl",
721
+ paddingRight: "2xl",
722
+ margin: 0
723
+ };
724
+ }, [inputProps, value, sx]);
725
+ const handleChangeUp = () => {
726
+ if (inputProps.disabled) {
727
+ return;
728
+ }
729
+ if (typeof value !== "number") {
730
+ onChange(-1);
731
+ return;
732
+ }
733
+ onChange(value - 1);
734
+ };
735
+ const handleChangeDown = () => {
736
+ if (inputProps.disabled) {
737
+ return;
738
+ }
739
+ if (typeof value !== "number") {
740
+ onChange(1);
741
+ return;
742
+ }
743
+ onChange(value + 1);
744
+ };
745
+ return /* @__PURE__ */jsxs9(Flex, {
746
+ sx: {
747
+ width: "fit-content",
748
+ ...sx,
749
+ position: "relative",
750
+ padding: 0,
751
+ border: "none"
752
+ },
753
+ ref,
754
+ "aria-invalid": inputProps["aria-invalid"],
755
+ children: [/* @__PURE__ */jsx15(Input2, {
756
+ ref,
757
+ variant: "forms.inputNumber",
758
+ sx: sxProps,
759
+ type: "number",
760
+ onChange: e => {
761
+ onChange(Number(e.target.value));
762
+ },
763
+ value,
764
+ ...inputProps
765
+ }), /* @__PURE__ */jsx15(Text, {
766
+ sx: {
767
+ position: "absolute",
768
+ alignSelf: "center",
769
+ left: "1rem",
770
+ zIndex: 1,
771
+ cursor: "pointer"
772
+ },
773
+ onClick: handleChangeUp,
774
+ children: /* @__PURE__ */jsx15(Icon8, {
775
+ icon: "picker-down"
776
+ })
777
+ }), infoIcon && /* @__PURE__ */jsx15(Text, {
778
+ sx: {
779
+ position: "absolute",
780
+ alignSelf: "center",
781
+ right: "2.5rem",
782
+ zIndex: 1,
783
+ cursor: onClickInfoIcon ? "pointer" : "default"
784
+ },
785
+ onClick: onClickInfoIcon,
786
+ children: /* @__PURE__ */jsx15(Icon8, {
787
+ icon: "info"
788
+ })
789
+ }), /* @__PURE__ */jsx15(Text, {
790
+ sx: {
791
+ position: "absolute",
792
+ alignSelf: "center",
793
+ right: "1rem",
794
+ zIndex: 1,
795
+ cursor: "pointer"
796
+ },
797
+ onClick: handleChangeDown,
798
+ children: /* @__PURE__ */jsx15(Icon8, {
799
+ icon: "picker-up"
800
+ })
801
+ })]
802
+ });
803
+ });
804
+ InputNumber.displayName = "InputNumber";
805
+
806
+ // src/components/Stack.tsx
807
+ import * as React12 from "react";
808
+ import { jsx as jsx16 } from "react/jsx-runtime";
809
+ var Stack = React12.forwardRef((props, ref) => {
810
+ return /* @__PURE__ */jsx16(Flex, {
811
+ ref,
812
+ ...props,
813
+ sx: {
814
+ flexDirection: "column",
815
+ ...props.sx
816
+ }
817
+ });
818
+ });
819
+ Stack.displayName = "Stack";
820
+
821
+ // src/components/Paragraph.tsx
822
+ import { Paragraph } from "theme-ui";
823
+
824
+ // src/components/InputPassword/InputPassword.tsx
825
+ import * as React14 from "react";
826
+
827
+ // src/components/InputPassword/useHidePassInput.ts
828
+ import * as React13 from "react";
829
+ var useHidePassInput = (defaultValue = true) => {
830
+ const [hidePass, setHidePass] = React13.useState(Boolean(defaultValue));
831
+ const {
832
+ icon,
833
+ inputType
834
+ } = React13.useMemo(() => {
835
+ return {
836
+ icon: hidePass ? "view-off" : "view-on",
837
+ inputType: hidePass ? "password" : "text"
838
+ };
839
+ }, [hidePass]);
840
+ const handleClick = () => {
841
+ setHidePass(prev => {
842
+ return !prev;
843
+ });
844
+ };
845
+ return {
846
+ handleClick,
847
+ icon,
848
+ inputType
849
+ };
850
+ };
851
+
852
+ // src/components/InputPassword/InputPassword.tsx
853
+ import { jsx as jsx17 } from "react/jsx-runtime";
854
+ var InputPassword = React14.forwardRef(({
855
+ showPasswordByDefault,
856
+ ...inputPasswordProps
857
+ }, ref) => {
858
+ const {
859
+ handleClick,
860
+ icon,
861
+ inputType
862
+ } = useHidePassInput(!showPasswordByDefault);
863
+ return /* @__PURE__ */jsx17(Input, {
864
+ ref,
865
+ ...inputPasswordProps,
866
+ trailingIcon: icon,
867
+ onTrailingIconClick: handleClick,
868
+ type: inputType
869
+ });
870
+ });
871
+ InputPassword.displayName = "InputPassword";
872
+
873
+ // src/components/ActionButton.tsx
874
+ import { jsx as jsx18 } from "react/jsx-runtime";
875
+ var ActionButton = ({
876
+ icon,
877
+ variant = "default",
878
+ sx,
879
+ ...props
880
+ }) => {
881
+ return /* @__PURE__ */jsx18(Button, {
882
+ variant: `buttons.actionButton.${variant}`,
883
+ leftIcon: icon,
884
+ sx: {
885
+ padding: "sm",
886
+ gap: "xs",
887
+ fontFamily: "caption",
888
+ borderRadius: "action",
889
+ outlineColor: "transparent",
890
+ ":disabled": props.disabled ? {
891
+ backgroundColor: "muted",
892
+ color: "onMuted",
893
+ cursor: "not-allowed",
894
+ border: "muted",
895
+ borderColor: "onMuted"
896
+ } : void 0,
897
+ ...sx
898
+ },
899
+ ...props
900
+ });
901
+ };
902
+ export { ActionButton, Badge, BaseStyles, Box, Button, Card, Checkbox, CloseButton, Container, Divider, Flex, Global2 as Global, Grid, Heading, HelpText, IconButton, Image, InfiniteLinearProgress, Input, InputNumber, InputPassword, Label, Progress as LinearProgress, Link, Paragraph, Radio, Select, Slider, Spinner, Stack, Text, Textarea, ThemeProvider, keyframes, useBreakpointIndex, useResponsiveValue, useTheme };
@@ -0,0 +1,143 @@
1
+ import * as theme_ui from 'theme-ui';
2
+ import { Theme, BadgeProps as BadgeProps$1, ButtonProps as ButtonProps$1, InputProps as InputProps$1, LabelProps as LabelProps$1, LinkProps as LinkProps$1, SxProp, IconButtonProps, CheckboxProps as CheckboxProps$1, TextareaProps as TextareaProps$1, TextProps, FlexProps } from 'theme-ui';
3
+ export { BaseStyles, Box, BoxProps, Card, CardProps, ContainerProps, Divider, DividerProps, Flex, FlexProps, Global, Grid, GridProps, Heading, HeadingProps, IconButtonProps, Image, ImageProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Paragraph, ParagraphProps, Radio, RadioProps, Slider, SliderProps, Spinner, SpinnerProps, SxProp, Text, TextProps, Theme, ThemeUIStyleObject } from 'theme-ui';
4
+ export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
5
+ export { Keyframes, keyframes } from '@emotion/react';
6
+ import * as react_jsx_runtime from 'react/jsx-runtime';
7
+ import * as React from 'react';
8
+ import { IconType } from '@ttoss/react-icons';
9
+ import { Props } from 'react-select';
10
+
11
+ type ThemeProviderProps = {
12
+ children?: React.ReactNode;
13
+ theme?: Theme;
14
+ /**
15
+ * Fonts URLs.
16
+ */
17
+ fonts?: string[];
18
+ };
19
+ declare const ThemeProvider: ({ children, theme, fonts, }: ThemeProviderProps) => react_jsx_runtime.JSX.Element;
20
+
21
+ declare const useTheme: () => theme_ui.ThemeUIContextValue;
22
+
23
+ type BadgeProps = BadgeProps$1 & {
24
+ icon?: IconType;
25
+ chip?: boolean;
26
+ onDelete?: () => void;
27
+ };
28
+ declare const Badge: ({ icon, children, sx, chip, onDelete, ...props }: BadgeProps) => react_jsx_runtime.JSX.Element;
29
+
30
+ type ButtonProps = ButtonProps$1 & {
31
+ leftIcon?: IconType;
32
+ rightIcon?: IconType;
33
+ loading?: boolean;
34
+ };
35
+ declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
36
+
37
+ interface InputProps extends InputProps$1 {
38
+ leadingIcon?: IconType;
39
+ onLeadingIconClick?: () => void;
40
+ trailingIcon?: IconType;
41
+ onTrailingIconClick?: () => void;
42
+ }
43
+ declare const Input: React.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
44
+
45
+ type LabelProps = LabelProps$1 & {
46
+ tooltip?: boolean;
47
+ onTooltipClick?: () => void;
48
+ };
49
+ declare const Label: ({ children, onTooltipClick, tooltip, sx, ...props }: LabelProps) => react_jsx_runtime.JSX.Element;
50
+
51
+ type LinkProps = LinkProps$1 & {
52
+ quiet?: boolean;
53
+ };
54
+ declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
55
+
56
+ /**
57
+ * We're using React Select component to build ttoss Select.
58
+ * More info about React Select: https://react-select.com/home
59
+ * ttoss Figma: https://www.figma.com/file/VrB76VkH4hKCDUe9iYhpYu/_Component-%2F-Forms-%2F-Select?type=design&mode=design&t=ZBIeOpqcvQn3yq2t-0
60
+ */
61
+
62
+ type SelectOptionValue = string | number | boolean;
63
+ type SelectOption = {
64
+ label: string;
65
+ value: SelectOptionValue;
66
+ };
67
+ type SelectOptions = SelectOption[];
68
+ /**
69
+ * TODO: remove this when we accept multi select.
70
+ */
71
+ type IsMulti = false;
72
+ type SelectProps = Omit<Props<SelectOption, IsMulti>, 'styles' | 'value' | 'onChange' | 'components'> & SxProp & {
73
+ value?: SelectOptionValue;
74
+ onChange?: (value: SelectOptionValue | undefined) => void;
75
+ disabled?: boolean;
76
+ leadingIcon?: IconType;
77
+ trailingIcon?: IconType;
78
+ };
79
+ /**
80
+ * https://react-select.com/home
81
+ */
82
+ declare const Select: React.ForwardRefExoticComponent<Omit<Props<SelectOption, false>, "value" | "onChange" | "styles" | "components"> & SxProp & {
83
+ value?: SelectOptionValue;
84
+ onChange?: (value: SelectOptionValue | undefined) => void;
85
+ disabled?: boolean;
86
+ leadingIcon?: IconType;
87
+ trailingIcon?: IconType;
88
+ } & React.RefAttributes<any>>;
89
+
90
+ declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
91
+
92
+ interface CheckboxProps extends CheckboxProps$1 {
93
+ indeterminate?: boolean;
94
+ }
95
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
96
+
97
+ declare const InfiniteLinearProgress: () => react_jsx_runtime.JSX.Element;
98
+
99
+ interface TextareaProps extends TextareaProps$1 {
100
+ trailingIcon?: IconType;
101
+ }
102
+ declare const Textarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
103
+
104
+ declare const Container: React.ForwardRefExoticComponent<theme_ui.BoxProps & React.RefAttributes<HTMLDivElement>>;
105
+
106
+ type HelpTextProps = Omit<TextProps, 'variant'> & {
107
+ disabled?: boolean;
108
+ negative?: boolean;
109
+ };
110
+ declare const HelpText: ({ sx, disabled, negative, ...props }: HelpTextProps) => react_jsx_runtime.JSX.Element;
111
+
112
+ type CloseButtonProps = ButtonProps & {
113
+ label?: string;
114
+ onlyText?: boolean;
115
+ };
116
+ declare const CloseButton: React.ForwardRefExoticComponent<Omit<CloseButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
117
+
118
+ type InputNumberProps = Omit<InputProps$1, 'type' | 'variant' | 'onChange'> & {
119
+ onChange: (value: number) => void;
120
+ value?: number;
121
+ infoIcon?: boolean;
122
+ onClickInfoIcon?: () => void;
123
+ };
124
+ declare const InputNumber: React.ForwardRefExoticComponent<Omit<InputNumberProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
125
+
126
+ type StackProps = FlexProps;
127
+ /**
128
+ * A component that renders its children in a column.
129
+ */
130
+ declare const Stack: React.ForwardRefExoticComponent<theme_ui.BoxProps & React.RefAttributes<HTMLElement>>;
131
+
132
+ type InputPasswordProps = Omit<InputProps, 'trailingIcon' | 'onTrailingIconClick' | 'type'> & {
133
+ showPasswordByDefault?: boolean;
134
+ };
135
+ declare const InputPassword: React.ForwardRefExoticComponent<Omit<InputPasswordProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
136
+
137
+ type ActionButtonProps = Omit<ButtonProps, 'rightIcon' | 'leftIcon' | 'variant'> & {
138
+ icon: ButtonProps['leftIcon'];
139
+ variant?: 'default' | 'accent' | 'quiet';
140
+ };
141
+ declare const ActionButton: ({ icon, variant, sx, ...props }: ActionButtonProps) => react_jsx_runtime.JSX.Element;
142
+
143
+ export { ActionButton, type ActionButtonProps, Badge, type BadgeProps, Button, type ButtonProps, Checkbox, type CheckboxProps, CloseButton, type CloseButtonProps, Container, HelpText, type HelpTextProps, IconButton, InfiniteLinearProgress, Input, InputNumber, type InputNumberProps, InputPassword, type InputPasswordProps, type InputProps, Label, type LabelProps, Link, type LinkProps, Select, type SelectOption, type SelectOptions, type SelectProps, Stack, type StackProps, Textarea, type TextareaProps, ThemeProvider, type ThemeProviderProps, useTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/ui",
3
- "version": "5.0.6",
3
+ "version": "5.0.7",
4
4
  "description": "Primitive layout, typographic, and other components for styling applications.",
5
5
  "author": "ttoss",
6
6
  "contributors": [
@@ -27,12 +27,12 @@
27
27
  "@theme-ui/match-media": "^0.16.2",
28
28
  "react-select": "^5.8.0",
29
29
  "theme-ui": "^0.16.2",
30
- "@ttoss/theme": "^1.7.21"
30
+ "@ttoss/theme": "^1.7.22"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@emotion/react": "^11",
34
34
  "react": ">=16.8.0",
35
- "@ttoss/react-icons": "^0.4.2"
35
+ "@ttoss/react-icons": "^0.4.3"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@emotion/react": "^11.11.4",
@@ -42,9 +42,9 @@
42
42
  "jest": "^29.7.0",
43
43
  "react": "^18.3.1",
44
44
  "tsup": "^8.3.0",
45
- "@ttoss/react-icons": "^0.4.2",
46
- "@ttoss/test-utils": "^2.1.15",
47
- "@ttoss/config": "^1.33.0"
45
+ "@ttoss/config": "^1.34.0",
46
+ "@ttoss/react-icons": "^0.4.3",
47
+ "@ttoss/test-utils": "^2.1.16"
48
48
  },
49
49
  "keywords": [
50
50
  "React",