@arkyn/components 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1348 -0
- package/dist/bundle.umd.cjs +32 -0
- package/dist/components/Badge/index.d.ts +5 -0
- package/dist/components/Badge/index.d.ts.map +1 -0
- package/dist/components/Badge/index.js +8 -0
- package/dist/components/Breadcrumb/index.d.ts +6 -0
- package/dist/components/Breadcrumb/index.d.ts.map +1 -0
- package/dist/components/Breadcrumb/index.js +18 -0
- package/dist/components/Button/index.d.ts +5 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Button/index.js +9 -0
- package/dist/components/Divider/index.d.ts +5 -0
- package/dist/components/Divider/index.d.ts.map +1 -0
- package/dist/components/Divider/index.js +8 -0
- package/dist/components/Form/FormController/index.d.ts +6 -0
- package/dist/components/Form/FormController/index.d.ts.map +1 -0
- package/dist/components/Form/FormController/index.js +17 -0
- package/dist/components/Form/FormError/index.d.ts +4 -0
- package/dist/components/Form/FormError/index.d.ts.map +1 -0
- package/dist/components/Form/FormError/index.js +10 -0
- package/dist/components/Form/FormLabel/index.d.ts +5 -0
- package/dist/components/Form/FormLabel/index.d.ts.map +1 -0
- package/dist/components/Form/FormLabel/index.js +9 -0
- package/dist/components/Form/index.d.ts +4 -0
- package/dist/components/Form/index.d.ts.map +1 -0
- package/dist/components/Form/index.js +3 -0
- package/dist/components/IconButton/index.d.ts +5 -0
- package/dist/components/IconButton/index.d.ts.map +1 -0
- package/dist/components/IconButton/index.js +15 -0
- package/dist/components/Input/CpfCpnjInput/getConfig.d.ts +308 -0
- package/dist/components/Input/CpfCpnjInput/getConfig.d.ts.map +1 -0
- package/dist/components/Input/CpfCpnjInput/getConfig.js +35 -0
- package/dist/components/Input/CpfCpnjInput/index.d.ts +4 -0
- package/dist/components/Input/CpfCpnjInput/index.d.ts.map +1 -0
- package/dist/components/Input/CpfCpnjInput/index.js +47 -0
- package/dist/components/Input/CpfCpnjInput/utils.d.ts +10 -0
- package/dist/components/Input/CpfCpnjInput/utils.d.ts.map +1 -0
- package/dist/components/Input/CpfCpnjInput/utils.js +24 -0
- package/dist/components/Input/CurrencyInput/getConfig.d.ts +309 -0
- package/dist/components/Input/CurrencyInput/getConfig.d.ts.map +1 -0
- package/dist/components/Input/CurrencyInput/getConfig.js +37 -0
- package/dist/components/Input/CurrencyInput/index.d.ts +4 -0
- package/dist/components/Input/CurrencyInput/index.d.ts.map +1 -0
- package/dist/components/Input/CurrencyInput/index.js +41 -0
- package/dist/components/Input/CurrencyInput/utils.d.ts +11 -0
- package/dist/components/Input/CurrencyInput/utils.d.ts.map +1 -0
- package/dist/components/Input/CurrencyInput/utils.js +39 -0
- package/dist/components/Input/MaskInput/getConfig.d.ts +312 -0
- package/dist/components/Input/MaskInput/getConfig.d.ts.map +1 -0
- package/dist/components/Input/MaskInput/getConfig.js +36 -0
- package/dist/components/Input/MaskInput/index.d.ts +4 -0
- package/dist/components/Input/MaskInput/index.d.ts.map +1 -0
- package/dist/components/Input/MaskInput/index.js +42 -0
- package/dist/components/Input/SimpleInput/getConfig.d.ts +308 -0
- package/dist/components/Input/SimpleInput/getConfig.d.ts.map +1 -0
- package/dist/components/Input/SimpleInput/getConfig.js +35 -0
- package/dist/components/Input/SimpleInput/index.d.ts +4 -0
- package/dist/components/Input/SimpleInput/index.d.ts.map +1 -0
- package/dist/components/Input/SimpleInput/index.js +34 -0
- package/dist/components/Input/index.d.ts +5 -0
- package/dist/components/Input/index.d.ts.map +1 -0
- package/dist/components/Input/index.js +16 -0
- package/dist/components/Input/utils/morpheme.d.ts +4 -0
- package/dist/components/Input/utils/morpheme.d.ts.map +1 -0
- package/dist/components/Input/utils/morpheme.js +10 -0
- package/dist/components/Modal/Container/index.d.ts +10 -0
- package/dist/components/Modal/Container/index.d.ts.map +1 -0
- package/dist/components/Modal/Container/index.js +12 -0
- package/dist/components/Modal/Footer/index.d.ts +5 -0
- package/dist/components/Modal/Footer/index.d.ts.map +1 -0
- package/dist/components/Modal/Footer/index.js +8 -0
- package/dist/components/Modal/Header/index.d.ts +5 -0
- package/dist/components/Modal/Header/index.d.ts.map +1 -0
- package/dist/components/Modal/Header/index.js +13 -0
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/Modal/index.js +4 -0
- package/dist/components/Tooltip/index.d.ts +5 -0
- package/dist/components/Tooltip/index.d.ts.map +1 -0
- package/dist/components/Tooltip/index.js +7 -0
- package/dist/config/buildBadgeConfig.d.ts +274 -0
- package/dist/config/buildBadgeConfig.d.ts.map +1 -0
- package/dist/config/buildBadgeConfig.js +15 -0
- package/dist/config/buildBreadcrumLinkConfig.d.ts +288 -0
- package/dist/config/buildBreadcrumLinkConfig.d.ts.map +1 -0
- package/dist/config/buildBreadcrumLinkConfig.js +14 -0
- package/dist/config/buildBreadcrumbConfig.d.ts +272 -0
- package/dist/config/buildBreadcrumbConfig.d.ts.map +1 -0
- package/dist/config/buildBreadcrumbConfig.js +6 -0
- package/dist/config/buildButtonConfig.d.ts +286 -0
- package/dist/config/buildButtonConfig.d.ts.map +1 -0
- package/dist/config/buildButtonConfig.js +18 -0
- package/dist/config/buildFormLabelConfig.d.ts +274 -0
- package/dist/config/buildFormLabelConfig.d.ts.map +1 -0
- package/dist/config/buildFormLabelConfig.js +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/style.css +1 -0
- package/dist/utils/generateIcon.d.ts +4 -0
- package/dist/utils/generateIcon.d.ts.map +1 -0
- package/dist/utils/generateIcon.js +7 -0
- package/package.json +30 -0
- package/src/components/Badge/index.tsx +18 -0
- package/src/components/Badge/styles.css +119 -0
- package/src/components/Breadcrumb/index.tsx +35 -0
- package/src/components/Breadcrumb/styles.css +39 -0
- package/src/components/Button/index.tsx +27 -0
- package/src/components/Button/styles.css +363 -0
- package/src/components/Divider/index.tsx +17 -0
- package/src/components/Divider/styles.css +17 -0
- package/src/components/Form/FormController/index.tsx +36 -0
- package/src/components/Form/FormController/styles.css +5 -0
- package/src/components/Form/FormError/index.tsx +11 -0
- package/src/components/Form/FormError/styles.css +6 -0
- package/src/components/Form/FormLabel/index.tsx +13 -0
- package/src/components/Form/FormLabel/styles.css +15 -0
- package/src/components/Form/index.ts +3 -0
- package/src/components/IconButton/index.tsx +44 -0
- package/src/components/IconButton/styles.css +318 -0
- package/src/components/Input/CpfCpnjInput/getConfig.tsx +60 -0
- package/src/components/Input/CpfCpnjInput/index.tsx +112 -0
- package/src/components/Input/CpfCpnjInput/utils.ts +30 -0
- package/src/components/Input/CurrencyInput/getConfig.tsx +64 -0
- package/src/components/Input/CurrencyInput/index.tsx +103 -0
- package/src/components/Input/CurrencyInput/utils.ts +56 -0
- package/src/components/Input/MaskInput/getConfig.tsx +62 -0
- package/src/components/Input/MaskInput/index.tsx +89 -0
- package/src/components/Input/SimpleInput/getConfig.tsx +60 -0
- package/src/components/Input/SimpleInput/index.tsx +87 -0
- package/src/components/Input/index.tsx +17 -0
- package/src/components/Input/styles.css +223 -0
- package/src/components/Input/utils/morpheme.tsx +19 -0
- package/src/components/Modal/Container/index.tsx +53 -0
- package/src/components/Modal/Container/styles.css +35 -0
- package/src/components/Modal/Footer/index.tsx +12 -0
- package/src/components/Modal/Footer/styles.css +27 -0
- package/src/components/Modal/Header/index.tsx +26 -0
- package/src/components/Modal/Header/styles.css +36 -0
- package/src/components/Modal/index.ts +5 -0
- package/src/components/Tooltip/index.tsx +26 -0
- package/src/components/Tooltip/styles.css +112 -0
- package/src/config/buildBadgeConfig.tsx +32 -0
- package/src/config/buildBreadcrumLinkConfig.tsx +27 -0
- package/src/config/buildBreadcrumbConfig.tsx +12 -0
- package/src/config/buildButtonConfig.tsx +38 -0
- package/src/config/buildFormLabelConfig.tsx +17 -0
- package/src/index.ts +16 -0
- package/src/utils/generateIcon.tsx +9 -0
- package/tsconfig.json +23 -0
- package/vite.config.js +25 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
import type { KeyboardEvent } from "react";
|
2
|
+
|
3
|
+
const VALID_FIRST = /^[1-9]{1}$/;
|
4
|
+
const VALID_NEXT = /^[0-9]{1}$/;
|
5
|
+
const DELETE_KEY_CODE = 8;
|
6
|
+
|
7
|
+
type OnKeyDownProps = {
|
8
|
+
event: KeyboardEvent<HTMLDivElement>;
|
9
|
+
currencyValue: number;
|
10
|
+
setCurrencyValue: (value: number) => void;
|
11
|
+
max: number;
|
12
|
+
};
|
13
|
+
|
14
|
+
function valueDisplay(inputValue: number, showBRL: boolean) {
|
15
|
+
if (inputValue === 0) return "";
|
16
|
+
|
17
|
+
const value = (inputValue / 100).toLocaleString("pt-BR", {
|
18
|
+
style: "currency",
|
19
|
+
currency: "BRL",
|
20
|
+
});
|
21
|
+
|
22
|
+
if (showBRL) return value;
|
23
|
+
return value.replace("R$", "").trim();
|
24
|
+
}
|
25
|
+
|
26
|
+
function currencyInputKeyDown(args: OnKeyDownProps) {
|
27
|
+
const { currencyValue, event, max, setCurrencyValue } = args;
|
28
|
+
const { key, keyCode } = event;
|
29
|
+
|
30
|
+
if (
|
31
|
+
(currencyValue === 0 && !VALID_FIRST.test(key)) ||
|
32
|
+
(currencyValue !== 0 &&
|
33
|
+
!VALID_NEXT.test(key) &&
|
34
|
+
keyCode !== DELETE_KEY_CODE)
|
35
|
+
) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
|
39
|
+
const valueString = currencyValue.toString();
|
40
|
+
|
41
|
+
let nextValue: number;
|
42
|
+
|
43
|
+
if (keyCode !== DELETE_KEY_CODE) {
|
44
|
+
const nextValueString = currencyValue === 0 ? key : `${valueString}${key}`;
|
45
|
+
nextValue = Number.parseInt(nextValueString, 10);
|
46
|
+
} else {
|
47
|
+
const nextValueString = valueString.slice(0, -1);
|
48
|
+
nextValue =
|
49
|
+
nextValueString === "" ? 0 : Number.parseInt(nextValueString, 10);
|
50
|
+
}
|
51
|
+
|
52
|
+
if (nextValue > Number(max)) return;
|
53
|
+
setCurrencyValue(nextValue);
|
54
|
+
}
|
55
|
+
|
56
|
+
export { valueDisplay, currencyInputKeyDown };
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import type { MaskedInputProps } from "@arkyn/types";
|
2
|
+
import { Loader2 } from "lucide-react";
|
3
|
+
|
4
|
+
import { morpheme } from "../utils/morpheme";
|
5
|
+
|
6
|
+
function getConfig(props: MaskedInputProps, isFocused: boolean) {
|
7
|
+
const {
|
8
|
+
isLoading,
|
9
|
+
isError,
|
10
|
+
size = "md",
|
11
|
+
className: baseClassName = "",
|
12
|
+
variant = "solid",
|
13
|
+
prefix: basePrefix,
|
14
|
+
sufix: baseSufix,
|
15
|
+
leftIcon: LeftIcon,
|
16
|
+
rightIcon: RightIcon,
|
17
|
+
disabled,
|
18
|
+
readOnly,
|
19
|
+
onFocus,
|
20
|
+
onBlur,
|
21
|
+
title,
|
22
|
+
style,
|
23
|
+
onChange,
|
24
|
+
showMask = true,
|
25
|
+
...rest
|
26
|
+
} = props;
|
27
|
+
|
28
|
+
const loadingPosition = RightIcon ? "right" : "left";
|
29
|
+
|
30
|
+
const hasPrefix = !!basePrefix ? "hasPrefix" : "";
|
31
|
+
const hasSufix = !!baseSufix ? "hasSufix" : "";
|
32
|
+
const errored = isError ? "errored" : "";
|
33
|
+
const opacity = disabled || readOnly || isLoading ? "opacity" : "";
|
34
|
+
const focused = isFocused ? "focused" : "";
|
35
|
+
|
36
|
+
const className = `arkyn_input ${hasPrefix} ${hasSufix} ${variant} ${size} ${opacity} ${errored} ${focused} ${baseClassName}`;
|
37
|
+
const iconSizes = { md: 14, lg: 16 };
|
38
|
+
const iconSize = iconSizes[size];
|
39
|
+
|
40
|
+
return {
|
41
|
+
isLoading,
|
42
|
+
className,
|
43
|
+
prefix: morpheme(basePrefix, iconSize, "prefix"),
|
44
|
+
sufix: morpheme(baseSufix, iconSize, "sufix"),
|
45
|
+
LeftIcon,
|
46
|
+
RightIcon,
|
47
|
+
disabled,
|
48
|
+
readOnly,
|
49
|
+
onFocus,
|
50
|
+
onBlur,
|
51
|
+
title,
|
52
|
+
style,
|
53
|
+
onChange,
|
54
|
+
loadingPosition,
|
55
|
+
iconSize: iconSize,
|
56
|
+
showMask,
|
57
|
+
Spinner: <Loader2 className="spinner" size={iconSize} strokeWidth={2.5} />,
|
58
|
+
...rest,
|
59
|
+
};
|
60
|
+
}
|
61
|
+
|
62
|
+
export { getConfig };
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import type { MaskedInputProps } from "@arkyn/types";
|
2
|
+
import type { FocusEvent } from "react";
|
3
|
+
|
4
|
+
import { InputMask } from "@react-input/mask";
|
5
|
+
import { useRef, useState } from "react";
|
6
|
+
|
7
|
+
import { useFormController } from "../../Form/FormController";
|
8
|
+
import { getConfig } from "./getConfig";
|
9
|
+
|
10
|
+
function MaskedInput(props: MaskedInputProps) {
|
11
|
+
const [isFocused, setIsFocused] = useState(false);
|
12
|
+
|
13
|
+
const baseRef = useRef<any>(null);
|
14
|
+
|
15
|
+
const { inputRef, id, error } = useFormController();
|
16
|
+
|
17
|
+
const ref = inputRef || baseRef;
|
18
|
+
const isError = props.isError || !!error;
|
19
|
+
|
20
|
+
const {
|
21
|
+
disabled,
|
22
|
+
title,
|
23
|
+
style,
|
24
|
+
className,
|
25
|
+
prefix,
|
26
|
+
sufix,
|
27
|
+
iconSize,
|
28
|
+
loadingPosition,
|
29
|
+
isLoading,
|
30
|
+
LeftIcon,
|
31
|
+
readOnly,
|
32
|
+
onFocus,
|
33
|
+
onBlur,
|
34
|
+
RightIcon,
|
35
|
+
Spinner,
|
36
|
+
...rest
|
37
|
+
} = getConfig({ ...props, id, isError }, isFocused);
|
38
|
+
|
39
|
+
const showLeftIcon = LeftIcon && !isLoading;
|
40
|
+
const showRightIcon = RightIcon && !isLoading;
|
41
|
+
|
42
|
+
const showLeftSpinner = loadingPosition === "left" && isLoading;
|
43
|
+
const showRightSpinner = loadingPosition === "right" && isLoading;
|
44
|
+
|
45
|
+
function handleSectionClick() {
|
46
|
+
if (disabled || !ref?.current) return;
|
47
|
+
setIsFocused(true);
|
48
|
+
ref.current.focus();
|
49
|
+
}
|
50
|
+
|
51
|
+
function handleFocus(e: FocusEvent<HTMLInputElement>) {
|
52
|
+
setIsFocused(true);
|
53
|
+
if (onFocus) onFocus(e);
|
54
|
+
}
|
55
|
+
|
56
|
+
function handleBlur(e: FocusEvent<HTMLInputElement>) {
|
57
|
+
setIsFocused(false);
|
58
|
+
if (onBlur) onBlur(e);
|
59
|
+
}
|
60
|
+
|
61
|
+
return (
|
62
|
+
<section
|
63
|
+
title={title}
|
64
|
+
style={style}
|
65
|
+
onClick={handleSectionClick}
|
66
|
+
className={className}
|
67
|
+
>
|
68
|
+
{prefix}
|
69
|
+
{showLeftSpinner && Spinner}
|
70
|
+
{showLeftIcon && <LeftIcon size={iconSize} strokeWidth={2.5} />}
|
71
|
+
|
72
|
+
<InputMask
|
73
|
+
|
74
|
+
// disabled={disabled || isLoading}
|
75
|
+
// readOnly={readOnly}
|
76
|
+
// ref={ref}
|
77
|
+
// onFocus={handleFocus}
|
78
|
+
// onBlur={handleBlur}
|
79
|
+
// {...rest}
|
80
|
+
/>
|
81
|
+
|
82
|
+
{showRightIcon && <RightIcon size={iconSize} strokeWidth={2.5} />}
|
83
|
+
{showRightSpinner && Spinner}
|
84
|
+
{sufix}
|
85
|
+
</section>
|
86
|
+
);
|
87
|
+
}
|
88
|
+
|
89
|
+
export { MaskedInput };
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import type { SimpleInputProps } from "@arkyn/types";
|
2
|
+
import { Loader2 } from "lucide-react";
|
3
|
+
|
4
|
+
import { morpheme } from "../utils/morpheme";
|
5
|
+
|
6
|
+
function getConfig(props: SimpleInputProps, isFocused: boolean) {
|
7
|
+
const {
|
8
|
+
isLoading,
|
9
|
+
isError,
|
10
|
+
size = "md",
|
11
|
+
className: baseClassName = "",
|
12
|
+
variant = "solid",
|
13
|
+
prefix: basePrefix,
|
14
|
+
sufix: baseSufix,
|
15
|
+
leftIcon: LeftIcon,
|
16
|
+
rightIcon: RightIcon,
|
17
|
+
disabled,
|
18
|
+
readOnly,
|
19
|
+
onFocus,
|
20
|
+
onBlur,
|
21
|
+
title,
|
22
|
+
style,
|
23
|
+
onChange,
|
24
|
+
...rest
|
25
|
+
} = props;
|
26
|
+
|
27
|
+
const loadingPosition = RightIcon ? "right" : "left";
|
28
|
+
|
29
|
+
const hasPrefix = !!basePrefix ? "hasPrefix" : "";
|
30
|
+
const hasSufix = !!baseSufix ? "hasSufix" : "";
|
31
|
+
const errored = isError ? "errored" : "";
|
32
|
+
const opacity = disabled || readOnly || isLoading ? "opacity" : "";
|
33
|
+
const focused = isFocused ? "focused" : "";
|
34
|
+
|
35
|
+
const className = `arkyn_input ${hasPrefix} ${hasSufix} ${variant} ${size} ${opacity} ${errored} ${focused} ${baseClassName}`;
|
36
|
+
const iconSizes = { md: 14, lg: 16 };
|
37
|
+
const iconSize = iconSizes[size];
|
38
|
+
|
39
|
+
return {
|
40
|
+
isLoading,
|
41
|
+
className,
|
42
|
+
prefix: morpheme(basePrefix, iconSize, "prefix"),
|
43
|
+
sufix: morpheme(baseSufix, iconSize, "sufix"),
|
44
|
+
LeftIcon,
|
45
|
+
RightIcon,
|
46
|
+
disabled,
|
47
|
+
readOnly,
|
48
|
+
onFocus,
|
49
|
+
onBlur,
|
50
|
+
title,
|
51
|
+
style,
|
52
|
+
onChange,
|
53
|
+
loadingPosition,
|
54
|
+
iconSize: iconSize,
|
55
|
+
Spinner: <Loader2 className="spinner" size={iconSize} strokeWidth={2.5} />,
|
56
|
+
...rest,
|
57
|
+
};
|
58
|
+
}
|
59
|
+
|
60
|
+
export { getConfig };
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import type { SimpleInputProps } from "@arkyn/types";
|
2
|
+
import type { FocusEvent } from "react";
|
3
|
+
|
4
|
+
import { useRef, useState } from "react";
|
5
|
+
|
6
|
+
import { useFormController } from "../../Form/FormController";
|
7
|
+
import { getConfig } from "./getConfig";
|
8
|
+
|
9
|
+
function SimpleInput(props: SimpleInputProps) {
|
10
|
+
const [isFocused, setIsFocused] = useState(false);
|
11
|
+
|
12
|
+
const baseRef = useRef<HTMLInputElement>(null);
|
13
|
+
|
14
|
+
const { inputRef, id, error } = useFormController();
|
15
|
+
|
16
|
+
const ref = inputRef || baseRef;
|
17
|
+
const isError = props.isError || !!error;
|
18
|
+
|
19
|
+
const {
|
20
|
+
disabled,
|
21
|
+
title,
|
22
|
+
style,
|
23
|
+
className,
|
24
|
+
prefix,
|
25
|
+
sufix,
|
26
|
+
iconSize,
|
27
|
+
loadingPosition,
|
28
|
+
isLoading,
|
29
|
+
LeftIcon,
|
30
|
+
readOnly,
|
31
|
+
onFocus,
|
32
|
+
onBlur,
|
33
|
+
RightIcon,
|
34
|
+
Spinner,
|
35
|
+
...rest
|
36
|
+
} = getConfig({ ...props, id, isError }, isFocused);
|
37
|
+
|
38
|
+
const showLeftIcon = LeftIcon && !isLoading;
|
39
|
+
const showRightIcon = RightIcon && !isLoading;
|
40
|
+
|
41
|
+
const showLeftSpinner = loadingPosition === "left" && isLoading;
|
42
|
+
const showRightSpinner = loadingPosition === "right" && isLoading;
|
43
|
+
|
44
|
+
function handleSectionClick() {
|
45
|
+
if (disabled || !ref?.current) return;
|
46
|
+
setIsFocused(true);
|
47
|
+
ref.current.focus();
|
48
|
+
}
|
49
|
+
|
50
|
+
function handleFocus(e: FocusEvent<HTMLInputElement>) {
|
51
|
+
setIsFocused(true);
|
52
|
+
if (onFocus) onFocus(e);
|
53
|
+
}
|
54
|
+
|
55
|
+
function handleBlur(e: FocusEvent<HTMLInputElement>) {
|
56
|
+
setIsFocused(false);
|
57
|
+
if (onBlur) onBlur(e);
|
58
|
+
}
|
59
|
+
|
60
|
+
return (
|
61
|
+
<section
|
62
|
+
title={title}
|
63
|
+
style={style}
|
64
|
+
onClick={handleSectionClick}
|
65
|
+
className={className}
|
66
|
+
>
|
67
|
+
{prefix}
|
68
|
+
{showLeftSpinner && Spinner}
|
69
|
+
{showLeftIcon && <LeftIcon size={iconSize} strokeWidth={2.5} />}
|
70
|
+
|
71
|
+
<input
|
72
|
+
disabled={disabled || isLoading}
|
73
|
+
readOnly={readOnly}
|
74
|
+
ref={ref}
|
75
|
+
onFocus={handleFocus}
|
76
|
+
onBlur={handleBlur}
|
77
|
+
{...rest}
|
78
|
+
/>
|
79
|
+
|
80
|
+
{showRightIcon && <RightIcon size={iconSize} strokeWidth={2.5} />}
|
81
|
+
{showRightSpinner && Spinner}
|
82
|
+
{sufix}
|
83
|
+
</section>
|
84
|
+
);
|
85
|
+
}
|
86
|
+
|
87
|
+
export { SimpleInput };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { InputProps } from "@arkyn/types";
|
2
|
+
|
3
|
+
import { CpfCnpjInput } from "./CpfCpnjInput";
|
4
|
+
import { CurrencyInput } from "./CurrencyInput";
|
5
|
+
import { MaskedInput } from "./MaskInput";
|
6
|
+
import { SimpleInput } from "./SimpleInput";
|
7
|
+
|
8
|
+
import "./styles.css";
|
9
|
+
|
10
|
+
function Input(props: InputProps) {
|
11
|
+
if (props.type === "currency") return <CurrencyInput {...props} />;
|
12
|
+
if (props.type === "masked") return <MaskedInput {...props} />;
|
13
|
+
if (props.type === "cpf-cpnj") return <CpfCnpjInput {...props} />;
|
14
|
+
return <SimpleInput {...props} />;
|
15
|
+
}
|
16
|
+
|
17
|
+
export { Input };
|
@@ -0,0 +1,223 @@
|
|
1
|
+
/* BASE */
|
2
|
+
.arkyn_input {
|
3
|
+
flex: 1;
|
4
|
+
position: relative;
|
5
|
+
display: flex;
|
6
|
+
align-items: center;
|
7
|
+
|
8
|
+
padding: 0 16px;
|
9
|
+
gap: 8px;
|
10
|
+
border-radius: 6px;
|
11
|
+
|
12
|
+
border: 1px solid transparent;
|
13
|
+
outline: 1px solid transparent;
|
14
|
+
}
|
15
|
+
|
16
|
+
.arkyn_input:hover {
|
17
|
+
cursor: text;
|
18
|
+
}
|
19
|
+
|
20
|
+
.arkyn_input input {
|
21
|
+
border: none;
|
22
|
+
outline: none;
|
23
|
+
background: transparent;
|
24
|
+
width: 100%;
|
25
|
+
}
|
26
|
+
|
27
|
+
.arkyn_input input {
|
28
|
+
color: var(--secondary-900);
|
29
|
+
}
|
30
|
+
|
31
|
+
.arkyn_input .prefix,
|
32
|
+
.arkyn_input .sufix {
|
33
|
+
color: var(--secondary-600);
|
34
|
+
background: var(--secondary-200);
|
35
|
+
font-weight: 400;
|
36
|
+
|
37
|
+
display: flex;
|
38
|
+
align-items: center;
|
39
|
+
justify-content: center;
|
40
|
+
|
41
|
+
position: absolute;
|
42
|
+
}
|
43
|
+
|
44
|
+
.arkyn_input .prefix {
|
45
|
+
left: 0;
|
46
|
+
top: 0;
|
47
|
+
bottom: 0;
|
48
|
+
border-radius: 5px 0 0 5px;
|
49
|
+
border-right: 1px solid var(--secondary-300);
|
50
|
+
}
|
51
|
+
|
52
|
+
.arkyn_input .sufix {
|
53
|
+
right: 0;
|
54
|
+
top: 0;
|
55
|
+
bottom: 0;
|
56
|
+
border-radius: 0 5px 5px 0;
|
57
|
+
border-left: 1px solid var(--secondary-300);
|
58
|
+
}
|
59
|
+
|
60
|
+
.arkyn_input input::placeholder {
|
61
|
+
color: var(--secondary-400);
|
62
|
+
}
|
63
|
+
|
64
|
+
.arkyn_input svg {
|
65
|
+
color: var(--secondary-400);
|
66
|
+
}
|
67
|
+
|
68
|
+
.arkyn_input.errored svg {
|
69
|
+
color: var(--danger-600);
|
70
|
+
}
|
71
|
+
|
72
|
+
.arkyn_input:not(.opacity).focused svg {
|
73
|
+
color: var(--primary-500);
|
74
|
+
}
|
75
|
+
|
76
|
+
.arkyn_input.opacity {
|
77
|
+
opacity: 0.5;
|
78
|
+
}
|
79
|
+
|
80
|
+
/* VARIANTS */
|
81
|
+
.arkyn_input.solid {
|
82
|
+
border-color: var(--secondary-300);
|
83
|
+
background-color: var(--secondary-50);
|
84
|
+
}
|
85
|
+
|
86
|
+
.arkyn_input.solid.errored {
|
87
|
+
border-color: var(--danger-600);
|
88
|
+
outline-color: var(--danger-600);
|
89
|
+
}
|
90
|
+
|
91
|
+
.arkyn_input:not(.opacity).solid.focused {
|
92
|
+
border-color: var(--primary-500);
|
93
|
+
outline-color: var(--primary-500);
|
94
|
+
}
|
95
|
+
|
96
|
+
.arkyn_input.outline {
|
97
|
+
border-color: var(--secondary-300);
|
98
|
+
}
|
99
|
+
|
100
|
+
.arkyn_input.outline.errored {
|
101
|
+
border-color: var(--danger-600);
|
102
|
+
outline-color: var(--danger-600);
|
103
|
+
}
|
104
|
+
|
105
|
+
.arkyn_input:not(.opacity).outline.focused {
|
106
|
+
border-color: var(--primary-500);
|
107
|
+
outline-color: var(--primary-500);
|
108
|
+
}
|
109
|
+
|
110
|
+
.arkyn_input.underline {
|
111
|
+
border-radius: 0;
|
112
|
+
border-top: none;
|
113
|
+
border-left: none;
|
114
|
+
border-right: none;
|
115
|
+
outline: none;
|
116
|
+
border-color: var(--secondary-300);
|
117
|
+
}
|
118
|
+
|
119
|
+
.arkyn_input.underline .sufix,
|
120
|
+
.arkyn_input.underline .prefix {
|
121
|
+
display: none;
|
122
|
+
}
|
123
|
+
|
124
|
+
.arkyn_input.underline::before {
|
125
|
+
content: " ";
|
126
|
+
position: absolute;
|
127
|
+
height: 1px;
|
128
|
+
left: 0;
|
129
|
+
right: 0;
|
130
|
+
bottom: -2px;
|
131
|
+
background: transparent;
|
132
|
+
}
|
133
|
+
|
134
|
+
.arkyn_input.underline.errored {
|
135
|
+
border-color: var(--danger-600);
|
136
|
+
}
|
137
|
+
|
138
|
+
.arkyn_input.underline.errored::before {
|
139
|
+
background: var(--danger-600);
|
140
|
+
}
|
141
|
+
|
142
|
+
.arkyn_input:not(.opacity).underline.focused {
|
143
|
+
border-color: var(--primary-500);
|
144
|
+
}
|
145
|
+
|
146
|
+
.arkyn_input:not(.opacity).underline.focused::before {
|
147
|
+
background: var(--primary-500);
|
148
|
+
}
|
149
|
+
|
150
|
+
/* SIZE */
|
151
|
+
|
152
|
+
.arkyn_input.md input {
|
153
|
+
min-height: 40px;
|
154
|
+
max-height: 40px;
|
155
|
+
font-size: 14px;
|
156
|
+
line-height: 14px;
|
157
|
+
font-weight: 400;
|
158
|
+
}
|
159
|
+
|
160
|
+
.arkyn_input.md input::placeholder {
|
161
|
+
font-weight: 400;
|
162
|
+
font-size: 14px;
|
163
|
+
line-height: 14px;
|
164
|
+
}
|
165
|
+
|
166
|
+
.arkyn_input.md.hasPrefix {
|
167
|
+
padding-left: 60px;
|
168
|
+
}
|
169
|
+
|
170
|
+
.arkyn_input.md.hasSufix {
|
171
|
+
padding-right: 60px;
|
172
|
+
}
|
173
|
+
|
174
|
+
.arkyn_input.md .prefix,
|
175
|
+
.arkyn_input.md .sufix {
|
176
|
+
height: 40px;
|
177
|
+
width: 44px;
|
178
|
+
font-size: 14px;
|
179
|
+
}
|
180
|
+
|
181
|
+
.arkyn_input.lg input {
|
182
|
+
min-height: 44px;
|
183
|
+
max-height: 44px;
|
184
|
+
line-height: 16px;
|
185
|
+
font-size: 16px;
|
186
|
+
font-weight: 400;
|
187
|
+
}
|
188
|
+
|
189
|
+
.arkyn_input.lg input::placeholder {
|
190
|
+
font-weight: 400;
|
191
|
+
font-size: 16px;
|
192
|
+
line-height: 16px;
|
193
|
+
}
|
194
|
+
|
195
|
+
.arkyn_input.lg .prefix,
|
196
|
+
.arkyn_input.lg .sufix {
|
197
|
+
height: 44px;
|
198
|
+
width: 48px;
|
199
|
+
font-size: 16px;
|
200
|
+
}
|
201
|
+
|
202
|
+
.arkyn_input.lg.hasPrefix {
|
203
|
+
padding-left: 64px;
|
204
|
+
}
|
205
|
+
|
206
|
+
.arkyn_input.lg.hasSufix {
|
207
|
+
padding-right: 64px;
|
208
|
+
}
|
209
|
+
|
210
|
+
/* SPIN */
|
211
|
+
|
212
|
+
.arkyn_input .spinner {
|
213
|
+
animation: spin 2s linear infinite;
|
214
|
+
}
|
215
|
+
|
216
|
+
@keyframes spin {
|
217
|
+
from {
|
218
|
+
transform: rotate(0deg);
|
219
|
+
}
|
220
|
+
to {
|
221
|
+
transform: rotate(360deg);
|
222
|
+
}
|
223
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import type { LucideIcon } from "lucide-react";
|
2
|
+
|
3
|
+
function morpheme(
|
4
|
+
data: LucideIcon | string | undefined,
|
5
|
+
iconSize: number,
|
6
|
+
type?: "prefix" | "sufix"
|
7
|
+
) {
|
8
|
+
if (!data) return <></>;
|
9
|
+
if (typeof data === "string") return <p className={type}>{data}</p>;
|
10
|
+
|
11
|
+
const Data = data;
|
12
|
+
return (
|
13
|
+
<p className={type}>
|
14
|
+
<Data color="var(--secondary-600)" size={iconSize} strokeWidth={2.5} />
|
15
|
+
</p>
|
16
|
+
);
|
17
|
+
}
|
18
|
+
|
19
|
+
export { morpheme };
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import type { ModalContainerProps } from "@arkyn/types";
|
2
|
+
|
3
|
+
import { AnimatePresence, motion } from "framer-motion";
|
4
|
+
import { createContext } from "react";
|
5
|
+
|
6
|
+
import "./styles.css";
|
7
|
+
|
8
|
+
type ModalContext = { makeInvisible: () => void };
|
9
|
+
const modalContext = createContext({} as ModalContext);
|
10
|
+
|
11
|
+
function Container(args: ModalContainerProps) {
|
12
|
+
const {
|
13
|
+
isVisibled,
|
14
|
+
makeInvisible,
|
15
|
+
children,
|
16
|
+
className: baseClassName = "",
|
17
|
+
...rest
|
18
|
+
} = args;
|
19
|
+
|
20
|
+
const visibled = isVisibled ? "visible" : "";
|
21
|
+
const className = `arkyn_modal_container ${visibled} ${baseClassName}`;
|
22
|
+
|
23
|
+
return (
|
24
|
+
<modalContext.Provider value={{ makeInvisible }}>
|
25
|
+
<AnimatePresence>
|
26
|
+
{isVisibled && (
|
27
|
+
<aside className={className.trim()} {...rest}>
|
28
|
+
<motion.div
|
29
|
+
className="overlay"
|
30
|
+
transition={{ duration: 0.15, ease: "easeOut" }}
|
31
|
+
initial={{ opacity: 0 }}
|
32
|
+
animate={{ opacity: 1 }}
|
33
|
+
exit={{ opacity: 0 }}
|
34
|
+
onClick={makeInvisible}
|
35
|
+
/>
|
36
|
+
|
37
|
+
<motion.div
|
38
|
+
className="content"
|
39
|
+
transition={{ duration: 0.15, ease: "easeOut" }}
|
40
|
+
initial={{ opacity: 0, scale: 0.75 }}
|
41
|
+
animate={{ opacity: 1, scale: 1 }}
|
42
|
+
exit={{ opacity: 0, scale: 0 }}
|
43
|
+
>
|
44
|
+
{children}
|
45
|
+
</motion.div>
|
46
|
+
</aside>
|
47
|
+
)}
|
48
|
+
</AnimatePresence>
|
49
|
+
</modalContext.Provider>
|
50
|
+
);
|
51
|
+
}
|
52
|
+
|
53
|
+
export { Container, modalContext };
|
@@ -0,0 +1,35 @@
|
|
1
|
+
.arkyn_modal_container {
|
2
|
+
position: fixed;
|
3
|
+
top: 0;
|
4
|
+
left: 0;
|
5
|
+
right: 0;
|
6
|
+
bottom: 0;
|
7
|
+
|
8
|
+
display: flex;
|
9
|
+
align-items: start;
|
10
|
+
justify-content: center;
|
11
|
+
|
12
|
+
padding: 10vh 0;
|
13
|
+
padding-bottom: 2rem;
|
14
|
+
overflow: auto;
|
15
|
+
}
|
16
|
+
|
17
|
+
.arkyn_modal_container > .overlay {
|
18
|
+
position: fixed;
|
19
|
+
z-index: 9997;
|
20
|
+
top: 0;
|
21
|
+
left: 0;
|
22
|
+
right: 0;
|
23
|
+
bottom: 0;
|
24
|
+
background: rgba(0, 0, 0, 0.5);
|
25
|
+
}
|
26
|
+
|
27
|
+
.arkyn_modal_container > .overlay:hover {
|
28
|
+
cursor: pointer;
|
29
|
+
}
|
30
|
+
|
31
|
+
.arkyn_modal_container > .content {
|
32
|
+
z-index: 9999;
|
33
|
+
border-radius: 6px;
|
34
|
+
background: var(--secondary-50);
|
35
|
+
}
|