@ttoss/ui 1.30.4 → 1.30.5
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/esm/index.js +73 -6
- package/dist/index.d.ts +12 -3
- package/dist/index.js +73 -6
- package/package.json +2 -2
- package/src/components/Input.tsx +88 -1
package/dist/esm/index.js
CHANGED
|
@@ -2566,7 +2566,74 @@ import { Image } from "theme-ui";
|
|
|
2566
2566
|
|
|
2567
2567
|
// src/components/Input.tsx
|
|
2568
2568
|
init_tsup_inject();
|
|
2569
|
-
import
|
|
2569
|
+
import React5 from "react";
|
|
2570
|
+
import { Input as InputUI } from "theme-ui";
|
|
2571
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2572
|
+
var renderIcon2 = (icon) => {
|
|
2573
|
+
if (typeof icon === "string" || typeof icon === "object" && !!icon?.body) {
|
|
2574
|
+
return /* @__PURE__ */ jsx4(Icon2, { icon });
|
|
2575
|
+
}
|
|
2576
|
+
return /* @__PURE__ */ jsx4(Fragment3, { children: icon });
|
|
2577
|
+
};
|
|
2578
|
+
var Input = React5.forwardRef(
|
|
2579
|
+
({ leadingIcon, trailingIcon, sx, ...inputProps }, ref) => {
|
|
2580
|
+
const leadingIconElement = React5.useMemo(() => {
|
|
2581
|
+
if (!leadingIcon) {
|
|
2582
|
+
return null;
|
|
2583
|
+
}
|
|
2584
|
+
return renderIcon2(leadingIcon);
|
|
2585
|
+
}, [leadingIcon]);
|
|
2586
|
+
const trailingIconElement = React5.useMemo(() => {
|
|
2587
|
+
if (!trailingIcon) {
|
|
2588
|
+
return null;
|
|
2589
|
+
}
|
|
2590
|
+
return renderIcon2(trailingIcon);
|
|
2591
|
+
}, [trailingIcon]);
|
|
2592
|
+
return /* @__PURE__ */ jsxs3(Flex, { sx: { position: "relative" }, children: [
|
|
2593
|
+
leadingIcon && /* @__PURE__ */ jsx4(
|
|
2594
|
+
Text,
|
|
2595
|
+
{
|
|
2596
|
+
sx: {
|
|
2597
|
+
position: "absolute",
|
|
2598
|
+
alignSelf: "center",
|
|
2599
|
+
fontSize: "lg",
|
|
2600
|
+
left: "lg",
|
|
2601
|
+
lineHeight: 0
|
|
2602
|
+
},
|
|
2603
|
+
variant: "leading-icon",
|
|
2604
|
+
children: leadingIconElement
|
|
2605
|
+
}
|
|
2606
|
+
),
|
|
2607
|
+
/* @__PURE__ */ jsx4(
|
|
2608
|
+
InputUI,
|
|
2609
|
+
{
|
|
2610
|
+
ref,
|
|
2611
|
+
sx: {
|
|
2612
|
+
paddingLeft: leadingIcon ? "3xl" : void 0,
|
|
2613
|
+
paddingRight: trailingIcon ? "3xl" : void 0,
|
|
2614
|
+
...sx
|
|
2615
|
+
},
|
|
2616
|
+
...inputProps
|
|
2617
|
+
}
|
|
2618
|
+
),
|
|
2619
|
+
trailingIcon && /* @__PURE__ */ jsx4(
|
|
2620
|
+
Text,
|
|
2621
|
+
{
|
|
2622
|
+
sx: {
|
|
2623
|
+
position: "absolute",
|
|
2624
|
+
right: "lg",
|
|
2625
|
+
alignSelf: "center",
|
|
2626
|
+
fontSize: "lg",
|
|
2627
|
+
lineHeight: 0
|
|
2628
|
+
},
|
|
2629
|
+
variant: "trailing-icon",
|
|
2630
|
+
children: trailingIconElement
|
|
2631
|
+
}
|
|
2632
|
+
)
|
|
2633
|
+
] });
|
|
2634
|
+
}
|
|
2635
|
+
);
|
|
2636
|
+
Input.displayName = "Input";
|
|
2570
2637
|
|
|
2571
2638
|
// src/components/Label.tsx
|
|
2572
2639
|
init_tsup_inject();
|
|
@@ -2608,12 +2675,12 @@ import { Checkbox } from "theme-ui";
|
|
|
2608
2675
|
|
|
2609
2676
|
// src/components/InfiniteLinearProgress.tsx
|
|
2610
2677
|
init_tsup_inject();
|
|
2611
|
-
import * as
|
|
2612
|
-
import { jsx as
|
|
2678
|
+
import * as React6 from "react";
|
|
2679
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2613
2680
|
var MAX_PROGRESS = 100;
|
|
2614
2681
|
var InfiniteLinearProgress = () => {
|
|
2615
|
-
const [progress, setProgress] =
|
|
2616
|
-
|
|
2682
|
+
const [progress, setProgress] = React6.useState(0);
|
|
2683
|
+
React6.useEffect(() => {
|
|
2617
2684
|
const timer = setInterval(() => {
|
|
2618
2685
|
setProgress((oldProgress) => {
|
|
2619
2686
|
if (oldProgress === MAX_PROGRESS) {
|
|
@@ -2634,7 +2701,7 @@ var InfiniteLinearProgress = () => {
|
|
|
2634
2701
|
clearInterval(timer);
|
|
2635
2702
|
};
|
|
2636
2703
|
}, []);
|
|
2637
|
-
return /* @__PURE__ */
|
|
2704
|
+
return /* @__PURE__ */ jsx5(Progress, { max: MAX_PROGRESS, value: progress, role: "progressbar" });
|
|
2638
2705
|
};
|
|
2639
2706
|
|
|
2640
2707
|
// src/components/Textarea.tsx
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as theme_ui from 'theme-ui';
|
|
2
|
-
import { Theme, ButtonProps as ButtonProps$1 } from 'theme-ui';
|
|
3
|
-
export { BaseStyles, Box, BoxProps, Card, CardProps, Checkbox, CheckboxProps, Container, ContainerProps, Divider, DividerProps, Flex, FlexProps, Grid, GridProps, Heading, HeadingProps, Image, ImageProps,
|
|
2
|
+
import { Theme, ButtonProps as ButtonProps$1, InputProps as InputProps$1 } from 'theme-ui';
|
|
3
|
+
export { BaseStyles, Box, BoxProps, Card, CardProps, Checkbox, CheckboxProps, Container, ContainerProps, Divider, DividerProps, Flex, FlexProps, Grid, GridProps, Heading, HeadingProps, Image, ImageProps, Label, LabelProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Link, LinkProps, Radio, RadioProps, Select, SelectProps, Slider, SliderProps, Spinner, SpinnerProps, Text, TextProps, Textarea, TextareaProps, Theme } from 'theme-ui';
|
|
4
4
|
export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
+
import React__default from 'react';
|
|
7
|
+
import { IconifyIcon } from '@iconify/types';
|
|
6
8
|
import { IconifyIconProps, IconifyIconHTMLElement } from '@iconify-icon/react';
|
|
7
9
|
|
|
8
10
|
type ThemeProviderProps = {
|
|
@@ -23,9 +25,16 @@ type ButtonProps = ButtonProps$1 & {
|
|
|
23
25
|
};
|
|
24
26
|
declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
25
27
|
|
|
28
|
+
type IconType = string | React__default.ReactNode | IconifyIcon;
|
|
29
|
+
type InputProps = InputProps$1 & {
|
|
30
|
+
leadingIcon?: IconType;
|
|
31
|
+
trailingIcon?: IconType;
|
|
32
|
+
};
|
|
33
|
+
declare const Input: React__default.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
34
|
+
|
|
26
35
|
type IconProps = Omit<IconifyIconProps, 'ref'>;
|
|
27
36
|
declare const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<IconifyIconHTMLElement | null>>;
|
|
28
37
|
|
|
29
38
|
declare const InfiniteLinearProgress: () => JSX.Element;
|
|
30
39
|
|
|
31
|
-
export { Button, ButtonProps, Icon, IconProps, InfiniteLinearProgress, ThemeProvider, ThemeProviderProps, useTheme };
|
|
40
|
+
export { Button, ButtonProps, Icon, IconProps, InfiniteLinearProgress, Input, InputProps, ThemeProvider, ThemeProviderProps, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -168,7 +168,7 @@ __export(src_exports, {
|
|
|
168
168
|
Icon: () => Icon2,
|
|
169
169
|
Image: () => import_theme_ui10.Image,
|
|
170
170
|
InfiniteLinearProgress: () => InfiniteLinearProgress,
|
|
171
|
-
Input: () =>
|
|
171
|
+
Input: () => Input,
|
|
172
172
|
Label: () => import_theme_ui12.Label,
|
|
173
173
|
LinearProgress: () => import_theme_ui14.Progress,
|
|
174
174
|
Link: () => import_theme_ui13.Link,
|
|
@@ -2602,7 +2602,74 @@ var import_theme_ui10 = require("theme-ui");
|
|
|
2602
2602
|
|
|
2603
2603
|
// src/components/Input.tsx
|
|
2604
2604
|
init_tsup_inject();
|
|
2605
|
+
var import_react4 = __toESM(require("react"));
|
|
2605
2606
|
var import_theme_ui11 = require("theme-ui");
|
|
2607
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2608
|
+
var renderIcon2 = (icon) => {
|
|
2609
|
+
if (typeof icon === "string" || typeof icon === "object" && !!icon?.body) {
|
|
2610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon2, { icon });
|
|
2611
|
+
}
|
|
2612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: icon });
|
|
2613
|
+
};
|
|
2614
|
+
var Input = import_react4.default.forwardRef(
|
|
2615
|
+
({ leadingIcon, trailingIcon, sx, ...inputProps }, ref) => {
|
|
2616
|
+
const leadingIconElement = import_react4.default.useMemo(() => {
|
|
2617
|
+
if (!leadingIcon) {
|
|
2618
|
+
return null;
|
|
2619
|
+
}
|
|
2620
|
+
return renderIcon2(leadingIcon);
|
|
2621
|
+
}, [leadingIcon]);
|
|
2622
|
+
const trailingIconElement = import_react4.default.useMemo(() => {
|
|
2623
|
+
if (!trailingIcon) {
|
|
2624
|
+
return null;
|
|
2625
|
+
}
|
|
2626
|
+
return renderIcon2(trailingIcon);
|
|
2627
|
+
}, [trailingIcon]);
|
|
2628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_theme_ui7.Flex, { sx: { position: "relative" }, children: [
|
|
2629
|
+
leadingIcon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2630
|
+
import_theme_ui15.Text,
|
|
2631
|
+
{
|
|
2632
|
+
sx: {
|
|
2633
|
+
position: "absolute",
|
|
2634
|
+
alignSelf: "center",
|
|
2635
|
+
fontSize: "lg",
|
|
2636
|
+
left: "lg",
|
|
2637
|
+
lineHeight: 0
|
|
2638
|
+
},
|
|
2639
|
+
variant: "leading-icon",
|
|
2640
|
+
children: leadingIconElement
|
|
2641
|
+
}
|
|
2642
|
+
),
|
|
2643
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2644
|
+
import_theme_ui11.Input,
|
|
2645
|
+
{
|
|
2646
|
+
ref,
|
|
2647
|
+
sx: {
|
|
2648
|
+
paddingLeft: leadingIcon ? "3xl" : void 0,
|
|
2649
|
+
paddingRight: trailingIcon ? "3xl" : void 0,
|
|
2650
|
+
...sx
|
|
2651
|
+
},
|
|
2652
|
+
...inputProps
|
|
2653
|
+
}
|
|
2654
|
+
),
|
|
2655
|
+
trailingIcon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2656
|
+
import_theme_ui15.Text,
|
|
2657
|
+
{
|
|
2658
|
+
sx: {
|
|
2659
|
+
position: "absolute",
|
|
2660
|
+
right: "lg",
|
|
2661
|
+
alignSelf: "center",
|
|
2662
|
+
fontSize: "lg",
|
|
2663
|
+
lineHeight: 0
|
|
2664
|
+
},
|
|
2665
|
+
variant: "trailing-icon",
|
|
2666
|
+
children: trailingIconElement
|
|
2667
|
+
}
|
|
2668
|
+
)
|
|
2669
|
+
] });
|
|
2670
|
+
}
|
|
2671
|
+
);
|
|
2672
|
+
Input.displayName = "Input";
|
|
2606
2673
|
|
|
2607
2674
|
// src/components/Label.tsx
|
|
2608
2675
|
init_tsup_inject();
|
|
@@ -2642,12 +2709,12 @@ var import_theme_ui20 = require("theme-ui");
|
|
|
2642
2709
|
|
|
2643
2710
|
// src/components/InfiniteLinearProgress.tsx
|
|
2644
2711
|
init_tsup_inject();
|
|
2645
|
-
var
|
|
2646
|
-
var
|
|
2712
|
+
var React6 = __toESM(require("react"));
|
|
2713
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2647
2714
|
var MAX_PROGRESS = 100;
|
|
2648
2715
|
var InfiniteLinearProgress = () => {
|
|
2649
|
-
const [progress, setProgress] =
|
|
2650
|
-
|
|
2716
|
+
const [progress, setProgress] = React6.useState(0);
|
|
2717
|
+
React6.useEffect(() => {
|
|
2651
2718
|
const timer = setInterval(() => {
|
|
2652
2719
|
setProgress((oldProgress) => {
|
|
2653
2720
|
if (oldProgress === MAX_PROGRESS) {
|
|
@@ -2668,7 +2735,7 @@ var InfiniteLinearProgress = () => {
|
|
|
2668
2735
|
clearInterval(timer);
|
|
2669
2736
|
};
|
|
2670
2737
|
}, []);
|
|
2671
|
-
return /* @__PURE__ */ (0,
|
|
2738
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_theme_ui14.Progress, { max: MAX_PROGRESS, value: progress, role: "progressbar" });
|
|
2672
2739
|
};
|
|
2673
2740
|
|
|
2674
2741
|
// src/components/Textarea.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.5",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "9a1d05dc6546c74a3f83835e4dcef00bc7040b6b"
|
|
49
49
|
}
|
package/src/components/Input.tsx
CHANGED
|
@@ -1 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
import { Flex, Icon, Text } from '..';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { IconifyIcon } from '@iconify/types';
|
|
4
|
+
|
|
5
|
+
import { type InputProps as InputPropsUI, Input as InputUI } from 'theme-ui';
|
|
6
|
+
|
|
7
|
+
type IconType = string | React.ReactNode | IconifyIcon;
|
|
8
|
+
|
|
9
|
+
export type InputProps = InputPropsUI & {
|
|
10
|
+
leadingIcon?: IconType;
|
|
11
|
+
trailingIcon?: IconType;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const renderIcon = (icon: IconType) => {
|
|
15
|
+
if (
|
|
16
|
+
typeof icon === 'string' ||
|
|
17
|
+
(typeof icon === 'object' && !!(icon as IconifyIcon)?.body)
|
|
18
|
+
) {
|
|
19
|
+
return <Icon icon={icon as string | IconifyIcon} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return <>{icon}</>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
26
|
+
({ leadingIcon, trailingIcon, sx, ...inputProps }, ref) => {
|
|
27
|
+
const leadingIconElement = React.useMemo(() => {
|
|
28
|
+
if (!leadingIcon) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return renderIcon(leadingIcon);
|
|
33
|
+
}, [leadingIcon]);
|
|
34
|
+
|
|
35
|
+
const trailingIconElement = React.useMemo(() => {
|
|
36
|
+
if (!trailingIcon) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return renderIcon(trailingIcon);
|
|
41
|
+
}, [trailingIcon]);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Flex sx={{ position: 'relative' }}>
|
|
45
|
+
{leadingIcon && (
|
|
46
|
+
<Text
|
|
47
|
+
sx={{
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
alignSelf: 'center',
|
|
50
|
+
fontSize: 'lg',
|
|
51
|
+
left: 'lg',
|
|
52
|
+
lineHeight: 0,
|
|
53
|
+
}}
|
|
54
|
+
variant="leading-icon"
|
|
55
|
+
>
|
|
56
|
+
{leadingIconElement}
|
|
57
|
+
</Text>
|
|
58
|
+
)}
|
|
59
|
+
<InputUI
|
|
60
|
+
ref={ref}
|
|
61
|
+
sx={{
|
|
62
|
+
paddingLeft: leadingIcon ? '3xl' : undefined,
|
|
63
|
+
paddingRight: trailingIcon ? '3xl' : undefined,
|
|
64
|
+
...sx,
|
|
65
|
+
}}
|
|
66
|
+
{...inputProps}
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
{trailingIcon && (
|
|
70
|
+
<Text
|
|
71
|
+
sx={{
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
right: 'lg',
|
|
74
|
+
alignSelf: 'center',
|
|
75
|
+
fontSize: 'lg',
|
|
76
|
+
lineHeight: 0,
|
|
77
|
+
}}
|
|
78
|
+
variant="trailing-icon"
|
|
79
|
+
>
|
|
80
|
+
{trailingIconElement}
|
|
81
|
+
</Text>
|
|
82
|
+
)}
|
|
83
|
+
</Flex>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
Input.displayName = 'Input';
|