@rovula/ui 0.0.6 → 0.0.8
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/cjs/bundle.css +64 -28
- package/dist/cjs/bundle.js +1 -1
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/Button/Buttons.stories.d.ts +1 -1
- package/dist/cjs/types/components/Select/Select copy.d.ts +23 -0
- package/dist/cjs/types/components/Select/Select.d.ts +23 -0
- package/dist/cjs/types/components/Select/Select.stories.d.ts +348 -0
- package/dist/cjs/types/components/Select/Select.styles.d.ts +14 -0
- package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +10 -10
- package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +0 -1
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/components/Select/Select copy.js +42 -0
- package/dist/components/Select/Select.js +21 -0
- package/dist/components/Select/Select.stories.js +46 -0
- package/dist/components/Select/Select.styles.js +100 -0
- package/dist/components/TextInput/TextInput.js +2 -4
- package/dist/components/TextInput/TextInput.stories.js +1 -1
- package/dist/components/TextInput/TextInput.styles.js +13 -21
- package/dist/esm/bundle.css +64 -28
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/Button/Buttons.stories.d.ts +1 -1
- package/dist/esm/types/components/Select/Select copy.d.ts +23 -0
- package/dist/esm/types/components/Select/Select.d.ts +23 -0
- package/dist/esm/types/components/Select/Select.stories.d.ts +348 -0
- package/dist/esm/types/components/Select/Select.styles.d.ts +14 -0
- package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +10 -10
- package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +0 -1
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/index.d.ts +39 -8
- package/dist/index.js +2 -1
- package/dist/src/theme/global.css +78 -32
- package/package.json +1 -1
- package/src/components/Select/Select copy.tsx +103 -0
- package/src/components/Select/Select.stories.tsx +52 -0
- package/src/components/Select/Select.styles.ts +111 -0
- package/src/components/Select/Select.tsx +54 -0
- package/src/components/TextInput/TextInput.stories.tsx +3 -3
- package/src/components/TextInput/TextInput.styles.ts +13 -21
- package/src/components/TextInput/TextInput.tsx +3 -3
- package/src/index.ts +2 -1
|
@@ -854,6 +854,10 @@ video {
|
|
|
854
854
|
margin-top: 6px;
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
+
.box-border {
|
|
858
|
+
box-sizing: border-box;
|
|
859
|
+
}
|
|
860
|
+
|
|
857
861
|
.block {
|
|
858
862
|
display: block;
|
|
859
863
|
}
|
|
@@ -901,6 +905,10 @@ video {
|
|
|
901
905
|
width: 400px;
|
|
902
906
|
}
|
|
903
907
|
|
|
908
|
+
.w-auto {
|
|
909
|
+
width: auto;
|
|
910
|
+
}
|
|
911
|
+
|
|
904
912
|
.w-full {
|
|
905
913
|
width: 100%;
|
|
906
914
|
}
|
|
@@ -1730,9 +1738,9 @@ video {
|
|
|
1730
1738
|
padding-inline-end: 2rem;
|
|
1731
1739
|
}
|
|
1732
1740
|
|
|
1733
|
-
.focus\:ring-
|
|
1741
|
+
.focus\:ring-1:focus {
|
|
1734
1742
|
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
1735
|
-
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(
|
|
1743
|
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
1736
1744
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
1737
1745
|
}
|
|
1738
1746
|
|
|
@@ -1740,73 +1748,111 @@ video {
|
|
|
1740
1748
|
--tw-ring-inset: inset;
|
|
1741
1749
|
}
|
|
1742
1750
|
|
|
1751
|
+
.focus\:ring-error:focus {
|
|
1752
|
+
--tw-ring-opacity: 1;
|
|
1753
|
+
--tw-ring-color: rgb(var(--error-100) / var(--tw-ring-opacity));
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
.focus\:ring-input-stroke-active:focus {
|
|
1757
|
+
--tw-ring-opacity: 1;
|
|
1758
|
+
--tw-ring-color: rgb(var(--input-active-stroke-color) / var(--tw-ring-opacity));
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1743
1761
|
.active\:scale-\[98\%\]:active {
|
|
1744
1762
|
--tw-scale-x: 98%;
|
|
1745
1763
|
--tw-scale-y: 98%;
|
|
1746
1764
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
1747
1765
|
}
|
|
1748
1766
|
|
|
1749
|
-
.peer
|
|
1750
|
-
top:
|
|
1767
|
+
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:top-2 {
|
|
1768
|
+
top: 0.5rem;
|
|
1751
1769
|
}
|
|
1752
1770
|
|
|
1753
|
-
.peer:
|
|
1754
|
-
top:
|
|
1771
|
+
.peer:placeholder-shown ~ .peer-placeholder-shown\:top-2 {
|
|
1772
|
+
top: 0.5rem;
|
|
1755
1773
|
}
|
|
1756
1774
|
|
|
1757
|
-
.peer
|
|
1758
|
-
|
|
1775
|
+
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:top-4 {
|
|
1776
|
+
top: 1rem;
|
|
1759
1777
|
}
|
|
1760
1778
|
|
|
1761
|
-
.peer:
|
|
1762
|
-
|
|
1763
|
-
background-color: rgb(var(--input-label-background-color) / var(--tw-bg-opacity));
|
|
1779
|
+
.peer:placeholder-shown ~ .peer-placeholder-shown\:top-4 {
|
|
1780
|
+
top: 1rem;
|
|
1764
1781
|
}
|
|
1765
1782
|
|
|
1766
|
-
.peer
|
|
1767
|
-
|
|
1768
|
-
color: rgb(var(--input-active-text-color) / var(--tw-text-opacity));
|
|
1783
|
+
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:bg-transparent {
|
|
1784
|
+
background-color: transparent;
|
|
1769
1785
|
}
|
|
1770
1786
|
|
|
1771
|
-
.peer:
|
|
1772
|
-
|
|
1773
|
-
|
|
1787
|
+
.peer:placeholder-shown ~ .peer-placeholder-shown\:bg-transparent {
|
|
1788
|
+
background-color: transparent;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:typography-subtitile1 {
|
|
1792
|
+
font-size: 16px;
|
|
1793
|
+
line-height: 24px;
|
|
1774
1794
|
font-weight: 400;
|
|
1775
1795
|
}
|
|
1776
1796
|
|
|
1777
|
-
.peer:
|
|
1778
|
-
font-size:
|
|
1779
|
-
line-height:
|
|
1797
|
+
.peer:placeholder-shown ~ .peer-placeholder-shown\:typography-subtitile1 {
|
|
1798
|
+
font-size: 16px;
|
|
1799
|
+
line-height: 24px;
|
|
1780
1800
|
font-weight: 400;
|
|
1781
1801
|
}
|
|
1782
1802
|
|
|
1783
|
-
.peer
|
|
1784
|
-
|
|
1803
|
+
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:typography-subtitile4 {
|
|
1804
|
+
font-size: 14px;
|
|
1805
|
+
line-height: 22px;
|
|
1806
|
+
font-weight: 400;
|
|
1785
1807
|
}
|
|
1786
1808
|
|
|
1787
|
-
.peer:
|
|
1788
|
-
|
|
1809
|
+
.peer:placeholder-shown ~ .peer-placeholder-shown\:typography-subtitile4 {
|
|
1810
|
+
font-size: 14px;
|
|
1811
|
+
line-height: 22px;
|
|
1812
|
+
font-weight: 400;
|
|
1789
1813
|
}
|
|
1790
1814
|
|
|
1791
|
-
.peer
|
|
1815
|
+
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:typography-small1 {
|
|
1792
1816
|
font-size: 12px;
|
|
1793
|
-
line-height:
|
|
1817
|
+
line-height: 14px;
|
|
1794
1818
|
font-weight: 400;
|
|
1795
1819
|
}
|
|
1796
1820
|
|
|
1797
|
-
.peer:
|
|
1821
|
+
.peer:placeholder-shown ~ .peer-placeholder-shown\:typography-small1 {
|
|
1798
1822
|
font-size: 12px;
|
|
1799
|
-
line-height:
|
|
1823
|
+
line-height: 14px;
|
|
1800
1824
|
font-weight: 400;
|
|
1801
1825
|
}
|
|
1802
1826
|
|
|
1803
|
-
.peer:
|
|
1804
|
-
|
|
1805
|
-
|
|
1827
|
+
.peer:focus ~ .peer-focus\:-top-1 {
|
|
1828
|
+
top: -0.25rem;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
.peer:focus ~ .peer-focus\:-top-1\.5 {
|
|
1832
|
+
top: -0.375rem;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
.peer:focus ~ .peer-focus\:flex {
|
|
1836
|
+
display: flex;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
.peer:focus ~ .peer-focus\:bg-input-label-background {
|
|
1840
|
+
--tw-bg-opacity: 1;
|
|
1841
|
+
background-color: rgb(var(--input-label-background-color) / var(--tw-bg-opacity));
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
.peer:focus ~ .peer-focus\:text-input-text-active {
|
|
1845
|
+
--tw-text-opacity: 1;
|
|
1846
|
+
color: rgb(var(--input-active-text-color) / var(--tw-text-opacity));
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
.peer:focus ~ .peer-focus\:typography-label1 {
|
|
1850
|
+
font-size: 12px;
|
|
1851
|
+
line-height: 12px;
|
|
1806
1852
|
font-weight: 400;
|
|
1807
1853
|
}
|
|
1808
1854
|
|
|
1809
|
-
.peer:
|
|
1855
|
+
.peer:focus ~ .peer-focus\:typography-label2 {
|
|
1810
1856
|
font-size: 10px;
|
|
1811
1857
|
line-height: 10px;
|
|
1812
1858
|
font-weight: 400;
|
package/package.json
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { labelVariant, selectVariant } from "./Select.styles";
|
|
4
|
+
import { helperTextVariant } from "../TextInput/TextInput.styles";
|
|
5
|
+
import { ExclamationCircleIcon } from "@heroicons/react/16/solid";
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
import TextInput from "../TextInput/TextInput";
|
|
8
|
+
|
|
9
|
+
type Options = {
|
|
10
|
+
value: string;
|
|
11
|
+
label: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type SelectProps = {
|
|
15
|
+
id?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
size?: "sm" | "md" | "lg";
|
|
18
|
+
rounded?: "none" | "normal" | "full";
|
|
19
|
+
variant?: "flat" | "outline" | "underline";
|
|
20
|
+
type?: React.HTMLInputTypeAttribute;
|
|
21
|
+
helperText?: string;
|
|
22
|
+
errorMessage?: string;
|
|
23
|
+
fullwidth?: boolean;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
error?: boolean;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
options: Options[];
|
|
29
|
+
} & Omit<React.InputHTMLAttributes<HTMLSelectElement>, "size">;
|
|
30
|
+
|
|
31
|
+
const Select = ({
|
|
32
|
+
id,
|
|
33
|
+
options,
|
|
34
|
+
label,
|
|
35
|
+
size = "md",
|
|
36
|
+
rounded = "normal",
|
|
37
|
+
variant = "outline",
|
|
38
|
+
type = "text",
|
|
39
|
+
helperText,
|
|
40
|
+
errorMessage,
|
|
41
|
+
fullwidth = true,
|
|
42
|
+
disabled = false,
|
|
43
|
+
error = false,
|
|
44
|
+
required = true,
|
|
45
|
+
...props
|
|
46
|
+
}: SelectProps) => {
|
|
47
|
+
const _id = id || `${type}-${label}-select`;
|
|
48
|
+
|
|
49
|
+
const [isPlaceholderShown, setIsPlaceholderShown] = useState(true);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div className={`relative ${fullwidth ? "w-full" : "w-auto"}`}>
|
|
53
|
+
<select
|
|
54
|
+
id={_id}
|
|
55
|
+
{...props}
|
|
56
|
+
className={twMerge(
|
|
57
|
+
selectVariant({
|
|
58
|
+
size,
|
|
59
|
+
variant,
|
|
60
|
+
rounded,
|
|
61
|
+
fullwidth,
|
|
62
|
+
disabled,
|
|
63
|
+
error,
|
|
64
|
+
}),
|
|
65
|
+
props.className
|
|
66
|
+
)}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
>
|
|
69
|
+
<option
|
|
70
|
+
value=""
|
|
71
|
+
disabled
|
|
72
|
+
selected={true}
|
|
73
|
+
className="hidden select-placeholder"
|
|
74
|
+
></option>
|
|
75
|
+
{options.map((option) => (
|
|
76
|
+
<option key={option.value} value={option.value}>
|
|
77
|
+
{option.label}
|
|
78
|
+
</option>
|
|
79
|
+
))}
|
|
80
|
+
</select>
|
|
81
|
+
{label && (
|
|
82
|
+
<label
|
|
83
|
+
className={labelVariant({ size, isPlaceholderShown })}
|
|
84
|
+
htmlFor="select"
|
|
85
|
+
>
|
|
86
|
+
{label} {required && <span className="text-error">*</span>}
|
|
87
|
+
</label>
|
|
88
|
+
)}
|
|
89
|
+
{(errorMessage || helperText) && (
|
|
90
|
+
<span className={helperTextVariant({ size, error, disabled })}>
|
|
91
|
+
<ExclamationCircleIcon
|
|
92
|
+
width={16}
|
|
93
|
+
height={16}
|
|
94
|
+
className={error ? "fill-error" : ""}
|
|
95
|
+
/>{" "}
|
|
96
|
+
{errorMessage || helperText}
|
|
97
|
+
</span>
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default Select;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import Select from "./Select";
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Components/Select",
|
|
8
|
+
component: Select,
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
parameters: {
|
|
11
|
+
// More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
|
|
12
|
+
layout: "fullscreen",
|
|
13
|
+
},
|
|
14
|
+
decorators: [
|
|
15
|
+
(Story) => (
|
|
16
|
+
<div className="p-5 flex w-full">
|
|
17
|
+
<Story />
|
|
18
|
+
</div>
|
|
19
|
+
),
|
|
20
|
+
],
|
|
21
|
+
} satisfies Meta<typeof Select>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
|
|
25
|
+
const options = [
|
|
26
|
+
{ value: "option1", label: "Option 1" },
|
|
27
|
+
{ value: "option2", label: "Option 2" },
|
|
28
|
+
{ value: "option3", label: "Option 3" },
|
|
29
|
+
{ value: "option4", label: "Option 4" },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const Default = {
|
|
33
|
+
args: {
|
|
34
|
+
label: "Choose an option:",
|
|
35
|
+
// value: "",
|
|
36
|
+
fullwidth: true,
|
|
37
|
+
options,
|
|
38
|
+
},
|
|
39
|
+
render: (args) => {
|
|
40
|
+
console.log("args ", args);
|
|
41
|
+
const props: typeof args = {
|
|
42
|
+
...args,
|
|
43
|
+
};
|
|
44
|
+
return (
|
|
45
|
+
<div className="flex flex-row gap-4 w-full">
|
|
46
|
+
<Select id="1" size="lg" options={options} {...args} />
|
|
47
|
+
<Select id="2" size="md" options={options} {...args} />
|
|
48
|
+
<Select id="3" size="sm" options={options} {...args} />
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
} satisfies StoryObj;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
export const selectVariant = cva(
|
|
5
|
+
[
|
|
6
|
+
"border-0 outline-none",
|
|
7
|
+
"p-1 flex w-auto box-border",
|
|
8
|
+
"peer text-black placeholder:text-transparent",
|
|
9
|
+
],
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
size: {
|
|
13
|
+
sm: "p-2 px-3 typography-small1",
|
|
14
|
+
md: "py-2 px-3 typography-subtitile4",
|
|
15
|
+
lg: "p-4 typography-subtitile1",
|
|
16
|
+
},
|
|
17
|
+
rounded: {
|
|
18
|
+
none: "rounded-none",
|
|
19
|
+
normal: "rounded-xl",
|
|
20
|
+
full: "rounded-full",
|
|
21
|
+
},
|
|
22
|
+
variant: {
|
|
23
|
+
flat: "",
|
|
24
|
+
outline:
|
|
25
|
+
"ring-1 ring-inset ring-input-stroke hover:ring-input-active focus:ring-1 focus:ring-inset focus:ring-input-stroke-active",
|
|
26
|
+
underline:
|
|
27
|
+
"border-b-2 border-input-stroke transition-colors hover:border-input-stroke-active focus:border-input-stroke",
|
|
28
|
+
},
|
|
29
|
+
fullwidth: {
|
|
30
|
+
true: "w-full",
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
true: "text-input-text-disabled ring-input-stroke-disabled placeholder:text-input-text-disabled",
|
|
34
|
+
},
|
|
35
|
+
error: {
|
|
36
|
+
true: "ring-error focus:ring-error",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
size: "md",
|
|
41
|
+
variant: "outline",
|
|
42
|
+
rounded: "normal",
|
|
43
|
+
fullwidth: false,
|
|
44
|
+
disabled: false,
|
|
45
|
+
error: false,
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export const labelVariant = cva(
|
|
51
|
+
[
|
|
52
|
+
"absolute block duration-450 transition-all px-[2px] text-input-text peer-focus:text-input-text-active peer-focus:bg-input-label-background",
|
|
53
|
+
],
|
|
54
|
+
{
|
|
55
|
+
variants: {
|
|
56
|
+
size: {
|
|
57
|
+
sm: [
|
|
58
|
+
"left-3 -top-1.5 bg-input-label-background",
|
|
59
|
+
"peer-focus:-top-1.5 peer-focus:typography-label2",
|
|
60
|
+
],
|
|
61
|
+
md: [
|
|
62
|
+
"left-3 -top-1.5 bg-input-label-background",
|
|
63
|
+
"peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
64
|
+
],
|
|
65
|
+
lg: [
|
|
66
|
+
"left-4 -top-1.5 bg-input-label-background",
|
|
67
|
+
"peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
68
|
+
// "peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1 peer-placeholder-shown:bg-transparent",
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
disabled: {
|
|
72
|
+
true: "text-input-text-disabled ring-input-stroke-disabled placeholder:text-input-text-disabled",
|
|
73
|
+
},
|
|
74
|
+
error: {
|
|
75
|
+
true: "ring-error",
|
|
76
|
+
},
|
|
77
|
+
isPlaceholderShown: {
|
|
78
|
+
// true: "",
|
|
79
|
+
false: "typography-label1",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
compoundVariants: [
|
|
83
|
+
{
|
|
84
|
+
size: "sm",
|
|
85
|
+
isPlaceholderShown: false,
|
|
86
|
+
className: "typography-label2",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
isPlaceholderShown: true,
|
|
90
|
+
size: "sm",
|
|
91
|
+
className: "top-2 typography-small1 bg-transparent",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
isPlaceholderShown: true,
|
|
95
|
+
size: "md",
|
|
96
|
+
className: "top-2 typography-subtitile4 bg-transparent",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
isPlaceholderShown: true,
|
|
100
|
+
size: "lg",
|
|
101
|
+
className: "top-4 typography-subtitile1 bg-transparent",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
defaultVariants: {
|
|
105
|
+
size: "md",
|
|
106
|
+
disabled: false,
|
|
107
|
+
error: false,
|
|
108
|
+
isPlaceholderShown: false,
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import TextInput from "../TextInput/TextInput";
|
|
4
|
+
|
|
5
|
+
type Options = {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type SelectProps = {
|
|
11
|
+
id?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
size?: "sm" | "md" | "lg";
|
|
14
|
+
rounded?: "none" | "normal" | "full";
|
|
15
|
+
variant?: "flat" | "outline" | "underline";
|
|
16
|
+
type?: React.HTMLInputTypeAttribute;
|
|
17
|
+
helperText?: string;
|
|
18
|
+
errorMessage?: string;
|
|
19
|
+
fullwidth?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
error?: boolean;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
className?: string;
|
|
24
|
+
options: Options[];
|
|
25
|
+
} & Omit<React.InputHTMLAttributes<HTMLSelectElement>, "size">;
|
|
26
|
+
|
|
27
|
+
const Select = ({
|
|
28
|
+
id,
|
|
29
|
+
options,
|
|
30
|
+
label,
|
|
31
|
+
size = "md",
|
|
32
|
+
rounded = "normal",
|
|
33
|
+
variant = "outline",
|
|
34
|
+
type = "text",
|
|
35
|
+
helperText,
|
|
36
|
+
errorMessage,
|
|
37
|
+
fullwidth = true,
|
|
38
|
+
disabled = false,
|
|
39
|
+
error = false,
|
|
40
|
+
required = true,
|
|
41
|
+
...props
|
|
42
|
+
}: SelectProps) => {
|
|
43
|
+
const _id = id || `${type}-${label}-select`;
|
|
44
|
+
|
|
45
|
+
const [isPlaceholderShown, setIsPlaceholderShown] = useState(true);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className={`relative ${fullwidth ? "w-full" : "w-auto"}`}>
|
|
49
|
+
<TextInput label="Test" />
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default Select;
|
|
@@ -35,9 +35,9 @@ export const Default = {
|
|
|
35
35
|
};
|
|
36
36
|
return (
|
|
37
37
|
<div className="flex flex-row gap-4 w-full">
|
|
38
|
-
<TextInput id="1"
|
|
39
|
-
<TextInput id="2"
|
|
40
|
-
<TextInput id="3"
|
|
38
|
+
<TextInput id="1" size="lg" {...args} />
|
|
39
|
+
<TextInput id="2" size="md" {...args} />
|
|
40
|
+
<TextInput id="3" size="sm" {...args} />
|
|
41
41
|
</div>
|
|
42
42
|
);
|
|
43
43
|
},
|
|
@@ -3,7 +3,7 @@ import { cva } from "class-variance-authority";
|
|
|
3
3
|
export const inputVariant = cva(
|
|
4
4
|
[
|
|
5
5
|
"border-0 outline-none",
|
|
6
|
-
"p-1 flex",
|
|
6
|
+
"p-1 flex w-auto box-border",
|
|
7
7
|
"peer text-black placeholder:text-transparent",
|
|
8
8
|
],
|
|
9
9
|
{
|
|
@@ -21,7 +21,7 @@ export const inputVariant = cva(
|
|
|
21
21
|
variant: {
|
|
22
22
|
flat: "",
|
|
23
23
|
outline:
|
|
24
|
-
"ring-1 ring-inset ring-input-stroke hover:ring-input-active focus:ring-
|
|
24
|
+
"ring-1 ring-inset ring-input-stroke hover:ring-input-active focus:ring-1 focus:ring-inset focus:ring-input-stroke-active",
|
|
25
25
|
underline:
|
|
26
26
|
"border-b-2 border-input-stroke transition-colors hover:border-input-stroke-active focus:border-input-stroke",
|
|
27
27
|
},
|
|
@@ -32,7 +32,7 @@ export const inputVariant = cva(
|
|
|
32
32
|
true: "text-input-text-disabled ring-input-stroke-disabled placeholder:text-input-text-disabled",
|
|
33
33
|
},
|
|
34
34
|
error: {
|
|
35
|
-
true: "ring-error",
|
|
35
|
+
true: "ring-error focus:ring-error",
|
|
36
36
|
},
|
|
37
37
|
hasClearIcon: {
|
|
38
38
|
true: "",
|
|
@@ -73,22 +73,25 @@ export const inputVariant = cva(
|
|
|
73
73
|
|
|
74
74
|
export const labelVariant = cva(
|
|
75
75
|
[
|
|
76
|
-
"absolute block transition-all px-[2px] text-input-text peer-focus:text-input-text-active peer-focus:bg-input-label-background",
|
|
76
|
+
"absolute block duration-450 transition-all px-[2px] text-input-text peer-focus:text-input-text-active peer-focus:bg-input-label-background",
|
|
77
77
|
],
|
|
78
78
|
{
|
|
79
79
|
variants: {
|
|
80
80
|
size: {
|
|
81
81
|
sm: [
|
|
82
|
-
"left-3
|
|
83
|
-
"
|
|
82
|
+
"left-3 -top-1.5 typography-label2 bg-input-label-background",
|
|
83
|
+
"peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1 peer-placeholder-shown:bg-transparent",
|
|
84
|
+
"peer-focus:-top-1.5 peer-focus:typography-label2",
|
|
84
85
|
],
|
|
85
86
|
md: [
|
|
86
|
-
"left-3
|
|
87
|
-
"
|
|
87
|
+
"left-3 -top-1.5 typography-label1 bg-input-label-background",
|
|
88
|
+
"peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4 peer-placeholder-shown:bg-transparent",
|
|
89
|
+
"peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
88
90
|
],
|
|
89
91
|
lg: [
|
|
90
|
-
"left-4
|
|
91
|
-
"
|
|
92
|
+
"left-4 -top-1.5 typography-label1 bg-input-label-background",
|
|
93
|
+
"peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1 peer-placeholder-shown:bg-transparent",
|
|
94
|
+
"peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
92
95
|
],
|
|
93
96
|
},
|
|
94
97
|
disabled: {
|
|
@@ -97,22 +100,11 @@ export const labelVariant = cva(
|
|
|
97
100
|
error: {
|
|
98
101
|
true: "ring-error",
|
|
99
102
|
},
|
|
100
|
-
isFloating: {
|
|
101
|
-
true: "-top-1.5 typography-label1 bg-input-label-background",
|
|
102
|
-
},
|
|
103
103
|
},
|
|
104
|
-
compoundVariants: [
|
|
105
|
-
{
|
|
106
|
-
size: "sm",
|
|
107
|
-
isFloating: true,
|
|
108
|
-
class: "-top-1.5 typography-label2 bg-input-label-background",
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
104
|
defaultVariants: {
|
|
112
105
|
size: "md",
|
|
113
106
|
disabled: false,
|
|
114
107
|
error: false,
|
|
115
|
-
isFloating: false,
|
|
116
108
|
},
|
|
117
109
|
}
|
|
118
110
|
);
|
|
@@ -37,7 +37,7 @@ const TextInput: FC<InputProps> = forwardRef(
|
|
|
37
37
|
type = "text",
|
|
38
38
|
helperText,
|
|
39
39
|
errorMessage,
|
|
40
|
-
fullwidth =
|
|
40
|
+
fullwidth = true,
|
|
41
41
|
disabled = false,
|
|
42
42
|
error = false,
|
|
43
43
|
required = true,
|
|
@@ -61,7 +61,6 @@ const TextInput: FC<InputProps> = forwardRef(
|
|
|
61
61
|
size,
|
|
62
62
|
disabled,
|
|
63
63
|
error,
|
|
64
|
-
isFloating: !!props.value ?? false,
|
|
65
64
|
});
|
|
66
65
|
const helperTextClassname = helperTextVariant({ size, error, disabled });
|
|
67
66
|
const iconWrapperClassname = iconWrapperVariant({ size });
|
|
@@ -78,10 +77,11 @@ const TextInput: FC<InputProps> = forwardRef(
|
|
|
78
77
|
};
|
|
79
78
|
|
|
80
79
|
return (
|
|
81
|
-
<div className={`flex flex-col ${fullwidth ? "w-full" : ""}`}>
|
|
80
|
+
<div className={`inline-flex flex-col ${fullwidth ? "w-full" : ""}`}>
|
|
82
81
|
<div className="relative">
|
|
83
82
|
<input
|
|
84
83
|
{...props}
|
|
84
|
+
placeholder=" "
|
|
85
85
|
ref={inputRef}
|
|
86
86
|
type={type}
|
|
87
87
|
id={_id}
|
package/src/index.ts
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
import "./theme/global.css";
|
|
4
4
|
export { default as Button } from "./components/Button/Button";
|
|
5
5
|
export { default as Table } from "./components/Table/Table";
|
|
6
|
-
export { default as TextInput } from "./components/
|
|
6
|
+
export { default as TextInput } from "./components/TextInput/TextInput";
|
|
7
7
|
export { default as Text } from "./components/Text/Text";
|
|
8
8
|
export { default as Tabs } from "./components/Tabs/Tabs";
|
|
9
|
+
export { default as Select } from "./components/Select/Select";
|
|
9
10
|
|
|
10
11
|
// UTILS
|
|
11
12
|
export {
|