@alume/alume-design-system 4.13.21
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/README.md +40 -0
- package/dist/assets/fonts/IBMPlexSans-ExtraLight.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-ExtraLightItalic.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-Italic.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-Light.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-LightItalic.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-Medium.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-MediumItalic.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-Regular.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-RegularItalic.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-SemiBold.ttf +0 -0
- package/dist/assets/fonts/IBMPlexSans-SemiBoldItalic.ttf +0 -0
- package/dist/assets/icons/advance.d.ts +2 -0
- package/dist/assets/icons/advance.js +4 -0
- package/dist/assets/icons/animated-bullet/animated.Bullet.styled.d.ts +3 -0
- package/dist/assets/icons/animated-bullet/animated.Bullet.styled.js +36 -0
- package/dist/assets/icons/animated-bullet/animatedBullet.component.d.ts +2 -0
- package/dist/assets/icons/animated-bullet/animatedBullet.component.js +7 -0
- package/dist/assets/icons/animated-bullet/index.d.ts +1 -0
- package/dist/assets/icons/animated-bullet/index.js +1 -0
- package/dist/assets/icons/back.d.ts +2 -0
- package/dist/assets/icons/back.js +4 -0
- package/dist/assets/icons/bell.d.ts +2 -0
- package/dist/assets/icons/bell.js +4 -0
- package/dist/assets/icons/cash.d.ts +2 -0
- package/dist/assets/icons/cash.js +7 -0
- package/dist/assets/icons/chatBaloon.d.ts +2 -0
- package/dist/assets/icons/chatBaloon.js +3 -0
- package/dist/assets/icons/checkBullet.d.ts +2 -0
- package/dist/assets/icons/checkBullet.js +25 -0
- package/dist/assets/icons/checkMark.d.ts +2 -0
- package/dist/assets/icons/checkMark.js +3 -0
- package/dist/assets/icons/close.d.ts +2 -0
- package/dist/assets/icons/close.js +4 -0
- package/dist/assets/icons/dropdown.d.ts +2 -0
- package/dist/assets/icons/dropdown.js +4 -0
- package/dist/assets/icons/edit.d.ts +2 -0
- package/dist/assets/icons/edit.js +4 -0
- package/dist/assets/icons/email.d.ts +2 -0
- package/dist/assets/icons/email.js +4 -0
- package/dist/assets/icons/emptyBullet.d.ts +2 -0
- package/dist/assets/icons/emptyBullet.js +21 -0
- package/dist/assets/icons/extract.d.ts +2 -0
- package/dist/assets/icons/extract.js +9 -0
- package/dist/assets/icons/faq.d.ts +2 -0
- package/dist/assets/icons/faq.js +5 -0
- package/dist/assets/icons/home.d.ts +2 -0
- package/dist/assets/icons/home.js +7 -0
- package/dist/assets/icons/index.d.ts +32 -0
- package/dist/assets/icons/index.js +32 -0
- package/dist/assets/icons/indicatorCheck.d.ts +2 -0
- package/dist/assets/icons/indicatorCheck.js +5 -0
- package/dist/assets/icons/indicatorProfile.d.ts +2 -0
- package/dist/assets/icons/indicatorProfile.js +4 -0
- package/dist/assets/icons/indicatorProposal.d.ts +2 -0
- package/dist/assets/icons/indicatorProposal.js +4 -0
- package/dist/assets/icons/indicatorRound.d.ts +2 -0
- package/dist/assets/icons/indicatorRound.js +4 -0
- package/dist/assets/icons/indicatorSafety.d.ts +2 -0
- package/dist/assets/icons/indicatorSafety.js +5 -0
- package/dist/assets/icons/information.d.ts +2 -0
- package/dist/assets/icons/information.js +7 -0
- package/dist/assets/icons/invoice.d.ts +2 -0
- package/dist/assets/icons/invoice.js +4 -0
- package/dist/assets/icons/legal.d.ts +2 -0
- package/dist/assets/icons/legal.js +5 -0
- package/dist/assets/icons/love.d.ts +2 -0
- package/dist/assets/icons/love.js +4 -0
- package/dist/assets/icons/plus.d.ts +2 -0
- package/dist/assets/icons/plus.js +3 -0
- package/dist/assets/icons/roundQuestionMark.d.ts +2 -0
- package/dist/assets/icons/roundQuestionMark.js +3 -0
- package/dist/assets/icons/safe.d.ts +2 -0
- package/dist/assets/icons/safe.js +5 -0
- package/dist/assets/icons/share.d.ts +2 -0
- package/dist/assets/icons/share.js +5 -0
- package/dist/assets/icons/simulation.d.ts +2 -0
- package/dist/assets/icons/simulation.js +5 -0
- package/dist/assets/icons/trash.d.ts +2 -0
- package/dist/assets/icons/trash.js +5 -0
- package/dist/assets/icons/whatsapp.d.ts +2 -0
- package/dist/assets/icons/whatsapp.js +4 -0
- package/dist/components/autocomplete-input/autocompleteInput.component.d.ts +11 -0
- package/dist/components/autocomplete-input/autocompleteInput.component.js +55 -0
- package/dist/components/autocomplete-input/autocompleteInput.styled.d.ts +24 -0
- package/dist/components/autocomplete-input/autocompleteInput.styled.js +89 -0
- package/dist/components/autocomplete-input/index.d.ts +1 -0
- package/dist/components/autocomplete-input/index.js +1 -0
- package/dist/components/button/button.component.d.ts +4 -0
- package/dist/components/button/button.component.js +16 -0
- package/dist/components/button/button.styled.d.ts +16 -0
- package/dist/components/button/button.styled.js +113 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +2 -0
- package/dist/components/card/card.component.d.ts +7 -0
- package/dist/components/card/card.component.js +17 -0
- package/dist/components/card/card.styled.d.ts +6 -0
- package/dist/components/card/card.styled.js +19 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/checkbox/checkbox.component.d.ts +6 -0
- package/dist/components/checkbox/checkbox.component.js +25 -0
- package/dist/components/checkbox/checkbox.styled.d.ts +7 -0
- package/dist/components/checkbox/checkbox.styled.js +50 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/code-input/codeInput.component.d.ts +8 -0
- package/dist/components/code-input/codeInput.component.js +58 -0
- package/dist/components/code-input/codeInput.styled.d.ts +2 -0
- package/dist/components/code-input/codeInput.styled.js +26 -0
- package/dist/components/code-input/index.d.ts +1 -0
- package/dist/components/code-input/index.js +1 -0
- package/dist/components/disclaimer/disclaimer.component.d.ts +10 -0
- package/dist/components/disclaimer/disclaimer.component.js +12 -0
- package/dist/components/disclaimer/disclaimer.styled.d.ts +11 -0
- package/dist/components/disclaimer/disclaimer.styled.js +21 -0
- package/dist/components/disclaimer/index.d.ts +1 -0
- package/dist/components/disclaimer/index.js +1 -0
- package/dist/components/dropzone/dropzone.component.d.ts +26 -0
- package/dist/components/dropzone/dropzone.component.js +65 -0
- package/dist/components/dropzone/dropzone.styled.d.ts +9 -0
- package/dist/components/dropzone/dropzone.styled.js +43 -0
- package/dist/components/dropzone/index.d.ts +1 -0
- package/dist/components/dropzone/index.js +1 -0
- package/dist/components/feedback-input/feedbackInput.component.d.ts +8 -0
- package/dist/components/feedback-input/feedbackInput.component.js +17 -0
- package/dist/components/feedback-input/feedbackInput.styled.d.ts +6 -0
- package/dist/components/feedback-input/feedbackInput.styled.js +22 -0
- package/dist/components/feedback-input/index.d.ts +1 -0
- package/dist/components/feedback-input/index.js +1 -0
- package/dist/components/floating-footer/floatingFooter.styled.d.ts +1 -0
- package/dist/components/floating-footer/floatingFooter.styled.js +9 -0
- package/dist/components/floating-footer/index.d.ts +1 -0
- package/dist/components/floating-footer/index.js +1 -0
- package/dist/components/grid/grid.component.d.ts +11 -0
- package/dist/components/grid/grid.component.js +39 -0
- package/dist/components/grid/grid.styled.d.ts +22 -0
- package/dist/components/grid/grid.styled.js +38 -0
- package/dist/components/grid/index.d.ts +1 -0
- package/dist/components/grid/index.js +1 -0
- package/dist/components/horizontal-timeline/horizontalTimeline.component.d.ts +8 -0
- package/dist/components/horizontal-timeline/horizontalTimeline.component.js +26 -0
- package/dist/components/horizontal-timeline/horizontalTimeline.styled.d.ts +10 -0
- package/dist/components/horizontal-timeline/horizontalTimeline.styled.js +43 -0
- package/dist/components/horizontal-timeline/index.d.ts +1 -0
- package/dist/components/horizontal-timeline/index.js +1 -0
- package/dist/components/index.d.ts +27 -0
- package/dist/components/index.js +27 -0
- package/dist/components/large-selector/index.d.ts +2 -0
- package/dist/components/large-selector/index.js +2 -0
- package/dist/components/large-selector/largeSelector.component.d.ts +7 -0
- package/dist/components/large-selector/largeSelector.component.js +9 -0
- package/dist/components/large-selector/largeSelector.styled.d.ts +6 -0
- package/dist/components/large-selector/largeSelector.styled.js +34 -0
- package/dist/components/link/index.d.ts +1 -0
- package/dist/components/link/index.js +1 -0
- package/dist/components/link/link.component.d.ts +4 -0
- package/dist/components/link/link.component.js +17 -0
- package/dist/components/link/link.styled.d.ts +1 -0
- package/dist/components/link/link.styled.js +7 -0
- package/dist/components/list/index.d.ts +1 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/list/list.component.d.ts +8 -0
- package/dist/components/list/list.component.js +22 -0
- package/dist/components/list/list.styled.d.ts +2 -0
- package/dist/components/list/list.styled.js +8 -0
- package/dist/components/loading/index.d.ts +1 -0
- package/dist/components/loading/index.js +1 -0
- package/dist/components/loading/loading.styled.d.ts +2 -0
- package/dist/components/loading/loading.styled.js +48 -0
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/modal/index.js +1 -0
- package/dist/components/modal/modal.component.d.ts +9 -0
- package/dist/components/modal/modal.component.js +35 -0
- package/dist/components/modal/modal.styled.d.ts +9 -0
- package/dist/components/modal/modal.styled.js +61 -0
- package/dist/components/multiselect/index.d.ts +1 -0
- package/dist/components/multiselect/index.js +1 -0
- package/dist/components/multiselect/multiselect.component.d.ts +12 -0
- package/dist/components/multiselect/multiselect.component.js +48 -0
- package/dist/components/multiselect/multiselect.style.d.ts +24 -0
- package/dist/components/multiselect/multiselect.style.js +93 -0
- package/dist/components/page-title/index.d.ts +1 -0
- package/dist/components/page-title/index.js +1 -0
- package/dist/components/page-title/pageTitle.component.d.ts +2 -0
- package/dist/components/page-title/pageTitle.component.js +6 -0
- package/dist/components/page-title/pageTitle.styled.d.ts +2 -0
- package/dist/components/page-title/pageTitle.styled.js +12 -0
- package/dist/components/radio/index.d.ts +1 -0
- package/dist/components/radio/index.js +1 -0
- package/dist/components/radio/radio.component.d.ts +12 -0
- package/dist/components/radio/radio.component.js +15 -0
- package/dist/components/radio/radio.styled.d.ts +9 -0
- package/dist/components/radio/radio.styled.js +55 -0
- package/dist/components/range-input/index.d.ts +1 -0
- package/dist/components/range-input/index.js +1 -0
- package/dist/components/range-input/rangeInput.component.d.ts +11 -0
- package/dist/components/range-input/rangeInput.component.js +24 -0
- package/dist/components/range-input/rangeInput.styled.d.ts +13 -0
- package/dist/components/range-input/rangeInput.styled.js +59 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/select/select.component.d.ts +13 -0
- package/dist/components/select/select.component.js +55 -0
- package/dist/components/select/select.styled.d.ts +26 -0
- package/dist/components/select/select.styled.js +86 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/table/table.component.d.ts +11 -0
- package/dist/components/table/table.component.js +39 -0
- package/dist/components/table/table.styled.d.ts +19 -0
- package/dist/components/table/table.styled.js +42 -0
- package/dist/components/text-area-input/index.d.ts +1 -0
- package/dist/components/text-area-input/index.js +1 -0
- package/dist/components/text-area-input/textAreaInput.component.d.ts +9 -0
- package/dist/components/text-area-input/textAreaInput.component.js +28 -0
- package/dist/components/text-area-input/textAreaInput.styled.d.ts +11 -0
- package/dist/components/text-area-input/textAreaInput.styled.js +47 -0
- package/dist/components/text-input/index.d.ts +1 -0
- package/dist/components/text-input/index.js +1 -0
- package/dist/components/text-input/textInput.component.d.ts +19 -0
- package/dist/components/text-input/textInput.component.js +84 -0
- package/dist/components/text-input/textInput.styled.d.ts +17 -0
- package/dist/components/text-input/textInput.styled.js +56 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tooltip/tooltip.component.d.ts +7 -0
- package/dist/components/tooltip/tooltip.component.js +8 -0
- package/dist/components/tooltip/tooltip.styled.d.ts +7 -0
- package/dist/components/tooltip/tooltip.styled.js +29 -0
- package/dist/components/typography/index.d.ts +1 -0
- package/dist/components/typography/index.js +1 -0
- package/dist/components/typography/typography.styled.d.ts +11 -0
- package/dist/components/typography/typography.styled.js +39 -0
- package/dist/components/vertical-timeline/index.d.ts +1 -0
- package/dist/components/vertical-timeline/index.js +1 -0
- package/dist/components/vertical-timeline/verticalTimeline.component.d.ts +12 -0
- package/dist/components/vertical-timeline/verticalTimeline.component.js +16 -0
- package/dist/components/vertical-timeline/verticalTimeline.styled.d.ts +9 -0
- package/dist/components/vertical-timeline/verticalTimeline.styled.js +33 -0
- package/dist/constants/breakpoints.d.ts +6 -0
- package/dist/constants/breakpoints.js +6 -0
- package/dist/constants/colors.d.ts +23 -0
- package/dist/constants/colors.js +23 -0
- package/dist/constants/fonts.d.ts +1 -0
- package/dist/constants/fonts.js +75 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/latinAmericaOptions.d.ts +2 -0
- package/dist/constants/latinAmericaOptions.js +78 -0
- package/dist/constants/reset.d.ts +1 -0
- package/dist/constants/reset.js +90 -0
- package/dist/constants/styles.d.ts +6 -0
- package/dist/constants/styles.js +17 -0
- package/dist/helpers/currency.d.ts +2 -0
- package/dist/helpers/currency.js +24 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +3 -0
- package/dist/helpers/number.d.ts +2 -0
- package/dist/helpers/number.js +6 -0
- package/dist/helpers/percentage.d.ts +2 -0
- package/dist/helpers/percentage.js +31 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +107 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface RangeInputProps {
|
|
3
|
+
value?: string;
|
|
4
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
|
+
max: number;
|
|
6
|
+
step?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const RangeInput: React.FunctionComponent<RangeInputProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { Input, InputContainer, Title } from "./rangeInput.styled";
|
|
14
|
+
export const RangeInput = (_a) => {
|
|
15
|
+
var { value, onChange, max, min = 0, step = 1, disabled } = _a, rest = __rest(_a, ["value", "onChange", "max", "min", "step", "disabled"]);
|
|
16
|
+
const handleChange = (event) => {
|
|
17
|
+
const { value } = event.currentTarget;
|
|
18
|
+
Number(value) >= min && Number(value) <= max && onChange(event);
|
|
19
|
+
};
|
|
20
|
+
const verifiedValue = Number(value) || min;
|
|
21
|
+
return (React.createElement(InputContainer, null,
|
|
22
|
+
React.createElement(Title, { disabled: disabled }, `R$ ${verifiedValue},00`),
|
|
23
|
+
React.createElement(Input, Object.assign({ type: "range", step: step, sliderValue: verifiedValue, value: verifiedValue, max: max, min: min, disabled: disabled, onChange: handleChange }, rest))));
|
|
24
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const InputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
interface InputProps {
|
|
3
|
+
sliderValue: number;
|
|
4
|
+
max: number;
|
|
5
|
+
min: number;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const Input: import("styled-components").StyledComponent<"input", any, InputProps, never>;
|
|
9
|
+
interface TitleProps {
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const Title: import("styled-components").StyledComponent<"h2", any, TitleProps, never>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { H2 } from "../typography";
|
|
3
|
+
import { colors } from "../../constants";
|
|
4
|
+
export const InputContainer = styled.div `
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
width: 100%;
|
|
8
|
+
`;
|
|
9
|
+
export const Input = styled.input `
|
|
10
|
+
${({ sliderValue, max, min, disabled }) => {
|
|
11
|
+
const fillPercent = (((sliderValue - min) / (max - min)) * 100).toFixed(0);
|
|
12
|
+
return `
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
-webkit-appearance: none;
|
|
16
|
+
appearance: none;
|
|
17
|
+
cursor: ${!disabled && "pointer"};
|
|
18
|
+
outline: none;
|
|
19
|
+
|
|
20
|
+
&::-webkit-slider-thumb {
|
|
21
|
+
-webkit-appearance: none;
|
|
22
|
+
appearance: none;
|
|
23
|
+
height: 24px;
|
|
24
|
+
width: 24px;
|
|
25
|
+
margin: -11px 0;
|
|
26
|
+
background: ${disabled ? colors.softGrey : colors.lightGreen};
|
|
27
|
+
border: none;
|
|
28
|
+
border-radius: 50%;
|
|
29
|
+
}
|
|
30
|
+
&::-moz-range-thumb {
|
|
31
|
+
-webkit-appearance: none;
|
|
32
|
+
height: 24px;
|
|
33
|
+
width: 24px;
|
|
34
|
+
background: ${disabled ? colors.softGrey : colors.lightGreen};
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&::-webkit-slider-runnable-track {
|
|
39
|
+
background: ${`
|
|
40
|
+
linear-gradient(to right, ${disabled ? colors.softGrey : colors.lightGreen} 0%, ${disabled ? colors.softGrey : colors.lightGreen} ${fillPercent}%, ${disabled ? colors.softGrey : colors.softGrey} ${fillPercent}%, ${disabled ? colors.softGrey : colors.softGrey} 100%)
|
|
41
|
+
`};
|
|
42
|
+
border: 0;
|
|
43
|
+
border-radius: 25px;
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 2px;
|
|
46
|
+
cursor: ${!disabled && "pointer"};
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
}};
|
|
50
|
+
`;
|
|
51
|
+
export const Title = styled(H2) `
|
|
52
|
+
text-align: center;
|
|
53
|
+
margin-bottom: 24px;
|
|
54
|
+
${({ disabled }) => `color: ${disabled ? colors.softGrey : colors.darkGreen};`};
|
|
55
|
+
|
|
56
|
+
span {
|
|
57
|
+
font-size: 16px;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./select.component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./select.component";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface OptionData {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
interface SelectProps extends React.InputHTMLAttributes<HTMLSelectElement> {
|
|
7
|
+
options: Array<OptionData>;
|
|
8
|
+
value?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
stretch?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const Select: React.FunctionComponent<SelectProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
13
|
+
import { DropdownSelectIcon, OptionsContainer, OptionStyled, SelectLabel, SelectContainerStyled, ContainerText, FocusInput, } from "./select.styled";
|
|
14
|
+
export const Select = (_a) => {
|
|
15
|
+
var _b;
|
|
16
|
+
var { options, value, onChange, label, name, disabled } = _a, props = __rest(_a, ["options", "value", "onChange", "label", "name", "disabled"]);
|
|
17
|
+
const selectorRef = useRef(null);
|
|
18
|
+
const hasLabel = label && label !== "";
|
|
19
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
20
|
+
const validateValue = (value) => value !== null && value !== undefined && value !== "";
|
|
21
|
+
const handleSelectClick = () => {
|
|
22
|
+
setIsOpen(!disabled && !isOpen);
|
|
23
|
+
};
|
|
24
|
+
const handleInputFocus = () => {
|
|
25
|
+
selectorRef.current.scrollIntoView({
|
|
26
|
+
block: "center",
|
|
27
|
+
});
|
|
28
|
+
setIsOpen(true);
|
|
29
|
+
};
|
|
30
|
+
const handleOptionClick = (event, value) => {
|
|
31
|
+
setIsOpen(false);
|
|
32
|
+
onChange &&
|
|
33
|
+
onChange(Object.assign(Object.assign({}, event), { target: Object.assign(Object.assign({}, event.target), { name,
|
|
34
|
+
value }) }));
|
|
35
|
+
};
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const handleClickOutside = (event) => {
|
|
38
|
+
if (selectorRef.current && !selectorRef.current.contains(event.target)) {
|
|
39
|
+
setIsOpen(false);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
43
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
44
|
+
}, [selectorRef]);
|
|
45
|
+
const optionLabel = ((_b = options.find((option) => option.value === value)) === null || _b === void 0 ? void 0 : _b.label) || "";
|
|
46
|
+
return (React.createElement(SelectContainerStyled, Object.assign({ onClick: handleSelectClick, ref: selectorRef, hasLabel: hasLabel, disabled: disabled }, props),
|
|
47
|
+
hasLabel && (React.createElement(SelectLabel, { disabled: disabled, riseLabel: isOpen || validateValue(value) }, label)),
|
|
48
|
+
React.createElement(DropdownSelectIcon, { changeDirection: isOpen }),
|
|
49
|
+
React.createElement(ContainerText, null, optionLabel),
|
|
50
|
+
React.createElement(FocusInput, { onFocus: handleInputFocus }),
|
|
51
|
+
React.createElement(OptionsContainer, { isOpen: isOpen }, options.map((option, index) => (React.createElement(OptionStyled, { onClick: (event) => {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
handleOptionClick(event, option.value);
|
|
54
|
+
}, key: index }, option.label))))));
|
|
55
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface SelectStyledProps {
|
|
3
|
+
stretch?: boolean;
|
|
4
|
+
hasLabel?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare const SelectContainerStyled: import("styled-components").StyledComponent<"div", any, SelectStyledProps, never>;
|
|
9
|
+
interface OptionsContainerProps {
|
|
10
|
+
isOpen?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const OptionsContainer: import("styled-components").StyledComponent<"div", any, OptionsContainerProps, never>;
|
|
13
|
+
export declare const OptionStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
14
|
+
interface SelectLabelProps {
|
|
15
|
+
riseLabel?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
hasError?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const SelectLabel: import("styled-components").StyledComponent<"span", any, SelectLabelProps, never>;
|
|
20
|
+
interface DropdownSelectIconProps {
|
|
21
|
+
changeDirection?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const DropdownSelectIcon: import("styled-components").StyledComponent<import("react").FunctionComponent<import("react").SVGAttributes<HTMLOrSVGElement>>, any, DropdownSelectIconProps, never>;
|
|
24
|
+
export declare const ContainerText: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
25
|
+
export declare const FocusInput: import("styled-components").StyledComponent<"select", any, {}, never>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { colors } from "../../constants";
|
|
3
|
+
import { DropdownIcon } from "../../assets/icons";
|
|
4
|
+
export const SelectContainerStyled = styled.div `
|
|
5
|
+
-webkit-appearance: none;
|
|
6
|
+
-moz-appearance: none;
|
|
7
|
+
background-color: transparent;
|
|
8
|
+
border: 0;
|
|
9
|
+
&:focus {
|
|
10
|
+
outline: none;
|
|
11
|
+
}
|
|
12
|
+
position: relative;
|
|
13
|
+
top: 2px;
|
|
14
|
+
font-size: 16px;
|
|
15
|
+
color: ${colors.textGreen};
|
|
16
|
+
border-bottom: 1px solid ${colors.lightGrey};
|
|
17
|
+
width: ${({ stretch }) => (stretch ? "100%" : "auto")};
|
|
18
|
+
box-sizing: content-box;
|
|
19
|
+
height: 26px;
|
|
20
|
+
cursor: ${({ disabled }) => (!disabled ? "pointer" : "default")};
|
|
21
|
+
`;
|
|
22
|
+
export const OptionsContainer = styled.div `
|
|
23
|
+
max-height: 250px;
|
|
24
|
+
overflow-y: scroll;
|
|
25
|
+
height: auto;
|
|
26
|
+
padding: 4px 0;
|
|
27
|
+
z-index: 9;
|
|
28
|
+
position: relative;
|
|
29
|
+
top: 3px;
|
|
30
|
+
transform-origin: top left;
|
|
31
|
+
transform: scale(${({ isOpen }) => (isOpen ? "1" : "0")});
|
|
32
|
+
transition: transform 0.1s ease-out;
|
|
33
|
+
transform-style: preserve-3d;
|
|
34
|
+
width: 100%;
|
|
35
|
+
background-color: ${colors.white};
|
|
36
|
+
box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.2);
|
|
37
|
+
border-radius: 4px;
|
|
38
|
+
`;
|
|
39
|
+
export const OptionStyled = styled.div `
|
|
40
|
+
-webkit-appearance: none;
|
|
41
|
+
-moz-appearance: none;
|
|
42
|
+
padding: 8px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
&:hover {
|
|
45
|
+
background-color: ${colors.softGrey};
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
export const SelectLabel = styled.span `
|
|
49
|
+
position: absolute;
|
|
50
|
+
color: ${colors.textLightGreen};
|
|
51
|
+
cursor: ${({ disabled }) => (disabled ? "default" : "pointer")};
|
|
52
|
+
transition: transform 0.4s, font-size 0.4s;
|
|
53
|
+
transition-timing-function: ease;
|
|
54
|
+
transform: translateY(0);
|
|
55
|
+
font-size: 16px;
|
|
56
|
+
${({ riseLabel }) => riseLabel &&
|
|
57
|
+
`
|
|
58
|
+
transform: translateY(-17px);
|
|
59
|
+
font-size: 12px;
|
|
60
|
+
`}
|
|
61
|
+
${({ disabled }) => disabled && `color: ${colors.lightGrey};`}
|
|
62
|
+
${({ hasError }) => hasError && `color: ${colors.red};`}
|
|
63
|
+
`;
|
|
64
|
+
export const DropdownSelectIcon = styled(DropdownIcon) `
|
|
65
|
+
float: right;
|
|
66
|
+
height: 20px;
|
|
67
|
+
transition: transform 0.4s, font-size 0.4s;
|
|
68
|
+
transition-timing-function: ease;
|
|
69
|
+
transform: rotate(
|
|
70
|
+
${({ changeDirection }) => (changeDirection ? "180" : "0")}deg
|
|
71
|
+
);
|
|
72
|
+
`;
|
|
73
|
+
export const ContainerText = styled.span `
|
|
74
|
+
position: absolute;
|
|
75
|
+
bottom: 2px;
|
|
76
|
+
`;
|
|
77
|
+
export const FocusInput = styled.select `
|
|
78
|
+
background-color: transparent;
|
|
79
|
+
border: none;
|
|
80
|
+
-webkit-appearance: none;
|
|
81
|
+
-moz-appearance: none;
|
|
82
|
+
|
|
83
|
+
&:focus {
|
|
84
|
+
outline: none;
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./table.component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./table.component";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyledHeaderCellProps, StyledCellProps, StyledRowProps } from "./table.styled";
|
|
3
|
+
declare type TableType = {
|
|
4
|
+
Header: React.FunctionComponent;
|
|
5
|
+
Row: React.FunctionComponent<StyledRowProps>;
|
|
6
|
+
HeaderCell: React.FunctionComponent<StyledHeaderCellProps>;
|
|
7
|
+
Body: React.FunctionComponent;
|
|
8
|
+
Cell: React.FunctionComponent<StyledCellProps>;
|
|
9
|
+
};
|
|
10
|
+
export declare const Table: React.FunctionComponent & TableType;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { StyledTable, StyledHeader, StyledHeaderCell, StyledCell, StyledRow, } from "./table.styled";
|
|
14
|
+
export const Table = ({ children }) => {
|
|
15
|
+
return React.createElement(StyledTable, null, children);
|
|
16
|
+
};
|
|
17
|
+
const Header = ({ children }) => {
|
|
18
|
+
return React.createElement(StyledHeader, null, children);
|
|
19
|
+
};
|
|
20
|
+
Table.Header = Header;
|
|
21
|
+
const Row = (_a) => {
|
|
22
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
23
|
+
return React.createElement(StyledRow, Object.assign({}, props), children);
|
|
24
|
+
};
|
|
25
|
+
Table.Row = Row;
|
|
26
|
+
const HeaderCell = (_a) => {
|
|
27
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
28
|
+
return React.createElement(StyledHeaderCell, Object.assign({}, props), children);
|
|
29
|
+
};
|
|
30
|
+
Table.HeaderCell = HeaderCell;
|
|
31
|
+
const Body = ({ children }) => {
|
|
32
|
+
return React.createElement("tbody", null, children);
|
|
33
|
+
};
|
|
34
|
+
Table.Body = Body;
|
|
35
|
+
const Cell = (_a) => {
|
|
36
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
37
|
+
return React.createElement(StyledCell, Object.assign({}, props), children);
|
|
38
|
+
};
|
|
39
|
+
Table.Cell = Cell;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare type CellAlignment = "left" | "center" | "right";
|
|
2
|
+
declare type TextBehaviour = "nowrap" | "ellipsis" | "normal";
|
|
3
|
+
export declare const StyledTable: import("styled-components").StyledComponent<"table", any, {}, never>;
|
|
4
|
+
export declare const StyledHeader: import("styled-components").StyledComponent<"thead", any, {}, never>;
|
|
5
|
+
export interface StyledRowProps {
|
|
6
|
+
customColor?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const StyledRow: import("styled-components").StyledComponent<"tr", any, StyledRowProps, never>;
|
|
9
|
+
export interface StyledHeaderCellProps {
|
|
10
|
+
alignment?: CellAlignment;
|
|
11
|
+
}
|
|
12
|
+
export declare const StyledHeaderCell: import("styled-components").StyledComponent<"th", any, StyledHeaderCellProps, never>;
|
|
13
|
+
export interface StyledCellProps {
|
|
14
|
+
alignment?: CellAlignment;
|
|
15
|
+
textBehavior?: TextBehaviour;
|
|
16
|
+
minWidth?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const StyledCell: import("styled-components").StyledComponent<"td", any, StyledCellProps, never>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { colors } from "../../constants";
|
|
3
|
+
const cellsPadding = "10px 5px";
|
|
4
|
+
const cellsDefaultAlignment = "center";
|
|
5
|
+
const cssByTextBehaviour = {
|
|
6
|
+
ellipsis: `
|
|
7
|
+
max-width: 100px;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
text-overflow: ellipsis;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
`,
|
|
12
|
+
nowrap: "white-space: nowrap;",
|
|
13
|
+
normal: "white-space: normal;",
|
|
14
|
+
};
|
|
15
|
+
export const StyledTable = styled.table `
|
|
16
|
+
width: 100%;
|
|
17
|
+
border-collapse: collapse;
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
`;
|
|
20
|
+
export const StyledHeader = styled.thead `
|
|
21
|
+
background-color: ${colors.floatingNav};
|
|
22
|
+
`;
|
|
23
|
+
export const StyledRow = styled.tr `
|
|
24
|
+
color: ${({ customColor }) => customColor || colors.tableText};
|
|
25
|
+
`;
|
|
26
|
+
export const StyledHeaderCell = styled.th `
|
|
27
|
+
border: none;
|
|
28
|
+
font-weight: normal;
|
|
29
|
+
padding: ${cellsPadding};
|
|
30
|
+
text-align: ${({ alignment }) => alignment || cellsDefaultAlignment};
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
`;
|
|
33
|
+
export const StyledCell = styled.td `
|
|
34
|
+
border-bottom: 1px solid ${colors.softGrey};
|
|
35
|
+
padding: ${cellsPadding};
|
|
36
|
+
font-weight: normal;
|
|
37
|
+
text-align: ${({ alignment }) => alignment || cellsDefaultAlignment};
|
|
38
|
+
|
|
39
|
+
${({ textBehavior = "nowrap" }) => cssByTextBehaviour[textBehavior]};
|
|
40
|
+
|
|
41
|
+
${({ minWidth }) => `min-width: ${minWidth};`}
|
|
42
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./textAreaInput.component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./textAreaInput.component";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface TextAreaInputProps extends React.ButtonHTMLAttributes<HTMLTextAreaElement> {
|
|
3
|
+
label: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
rows?: number;
|
|
6
|
+
maxChars?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const TextAreaInput: React.FunctionComponent<TextAreaInputProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useState } from "react";
|
|
13
|
+
import { StyledCharQuantitySpan, StyledTextAreaInputContainer, StyleErrorSpan, StyledTextAreaInput, } from "./textAreaInput.styled";
|
|
14
|
+
export const TextAreaInput = (_a) => {
|
|
15
|
+
var { label, error, disabled, value, name, onChange, rows = 5, maxChars = 500 } = _a, props = __rest(_a, ["label", "error", "disabled", "value", "name", "onChange", "rows", "maxChars"]);
|
|
16
|
+
const [charactersQuantity, setCharactersQuantity] = useState(0);
|
|
17
|
+
const handleOnChange = (event) => {
|
|
18
|
+
const eventCharQuantity = event.currentTarget.value.length;
|
|
19
|
+
if (eventCharQuantity > maxChars)
|
|
20
|
+
return;
|
|
21
|
+
setCharactersQuantity(eventCharQuantity);
|
|
22
|
+
onChange && onChange(event);
|
|
23
|
+
};
|
|
24
|
+
return (React.createElement(StyledTextAreaInputContainer, { hasError: !!error },
|
|
25
|
+
React.createElement(StyledCharQuantitySpan, null, ` ${charactersQuantity}/${maxChars}`),
|
|
26
|
+
React.createElement(StyledTextAreaInput, Object.assign({}, props, { name: name, value: value, hasError: !!error, disabled: disabled, autoComplete: "off", rows: rows, onChange: handleOnChange, placeholder: label })),
|
|
27
|
+
error && React.createElement(StyleErrorSpan, null, error)));
|
|
28
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface StyledTextAreaInputContainerProps {
|
|
2
|
+
hasError?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare const StyledTextAreaInputContainer: import("styled-components").StyledComponent<"div", any, StyledTextAreaInputContainerProps, never>;
|
|
5
|
+
export declare const StyledCharQuantitySpan: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
6
|
+
interface StyledTextAreaInputProps {
|
|
7
|
+
hasError?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const StyledTextAreaInput: import("styled-components").StyledComponent<"textarea", any, StyledTextAreaInputProps, never>;
|
|
10
|
+
export declare const StyleErrorSpan: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { colors } from "../../constants";
|
|
3
|
+
export const StyledTextAreaInputContainer = styled.div `
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
justify-content: flex-end;
|
|
7
|
+
|
|
8
|
+
${({ hasError }) => hasError && `color: ${colors.red};`}
|
|
9
|
+
`;
|
|
10
|
+
export const StyledCharQuantitySpan = styled.span `
|
|
11
|
+
color: grey;
|
|
12
|
+
position: relative;
|
|
13
|
+
top: 20px;
|
|
14
|
+
text-align: right;
|
|
15
|
+
padding-right: 4px;
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
`;
|
|
18
|
+
export const StyledTextAreaInput = styled.textarea `
|
|
19
|
+
padding: 4px;
|
|
20
|
+
padding-top: 20px;
|
|
21
|
+
border: 1px solid ${colors.lightGrey};
|
|
22
|
+
border-radius: 4px;
|
|
23
|
+
line-height: 20px;
|
|
24
|
+
color: ${colors.textGreen};
|
|
25
|
+
font-size: 16px;
|
|
26
|
+
resize: none;
|
|
27
|
+
|
|
28
|
+
&:focus {
|
|
29
|
+
outline: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:disabled {
|
|
33
|
+
background-color: transparent;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
${({ hasError }) => hasError &&
|
|
37
|
+
`
|
|
38
|
+
border-color: ${colors.red};
|
|
39
|
+
color: ${colors.red};
|
|
40
|
+
`}
|
|
41
|
+
`;
|
|
42
|
+
export const StyleErrorSpan = styled.span `
|
|
43
|
+
position: absolute;
|
|
44
|
+
align-self: flex-end;
|
|
45
|
+
transform: translateY(17px);
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./textInput.component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./textInput.component";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import IMask from "imask";
|
|
3
|
+
export interface ValueInterceptor {
|
|
4
|
+
beforeSetValue?: (value?: string | number | readonly string[]) => string;
|
|
5
|
+
onChange?: (value?: string | number | readonly string[]) => string;
|
|
6
|
+
onKeyDown?: (value?: string | number | readonly string[], event?: React.KeyboardEvent<HTMLInputElement>) => string;
|
|
7
|
+
}
|
|
8
|
+
declare type InputValueCase = "lowercase" | "uppercase";
|
|
9
|
+
interface TextInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
10
|
+
label: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
mask?: string | IMask.AnyMaskedOptions;
|
|
13
|
+
interceptors?: ValueInterceptor;
|
|
14
|
+
valueCase?: InputValueCase;
|
|
15
|
+
stretch?: boolean;
|
|
16
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const TextInput: React.FunctionComponent<TextInputProps>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useRef, useState, useEffect } from "react";
|
|
13
|
+
import IMask from "imask";
|
|
14
|
+
import { StyledTextInputContainer, StyledTextInputLabel, StyleErrorSpan, StyleTextInput, } from "./textInput.styled";
|
|
15
|
+
const convertByCase = {
|
|
16
|
+
lowercase: (value) => value.toLowerCase(),
|
|
17
|
+
uppercase: (value) => value.toUpperCase(),
|
|
18
|
+
};
|
|
19
|
+
export const TextInput = (_a) => {
|
|
20
|
+
var { label, error, disabled, onChange, onBlur, onFocus, onKeyDown, mask, interceptors, valueCase, value, name, stretch } = _a, props = __rest(_a, ["label", "error", "disabled", "onChange", "onBlur", "onFocus", "onKeyDown", "mask", "interceptors", "valueCase", "value", "name", "stretch"]);
|
|
21
|
+
const inputRef = useRef();
|
|
22
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
23
|
+
const [hasValue, setHasValue] = useState(false);
|
|
24
|
+
const validateValue = (value) => value !== null && value !== undefined && value !== "";
|
|
25
|
+
const maskInstance = mask && IMask.createMask(typeof mask === "string" ? { mask } : mask);
|
|
26
|
+
const maskValue = (value) => value && maskInstance
|
|
27
|
+
? maskInstance.resolve(value.toString())
|
|
28
|
+
: (value === null || value === void 0 ? void 0 : value.toString()) || "";
|
|
29
|
+
const handleLabelClick = (event) => {
|
|
30
|
+
var _a;
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
if (disabled)
|
|
33
|
+
return;
|
|
34
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
35
|
+
};
|
|
36
|
+
const handleInputFocus = (event) => {
|
|
37
|
+
var _a;
|
|
38
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
39
|
+
block: "center",
|
|
40
|
+
});
|
|
41
|
+
onFocus && onFocus(event);
|
|
42
|
+
setIsFocused(true);
|
|
43
|
+
};
|
|
44
|
+
const handleInputBlur = (event) => {
|
|
45
|
+
onBlur && onBlur(event);
|
|
46
|
+
setIsFocused(false);
|
|
47
|
+
};
|
|
48
|
+
const handleValueChange = (event) => {
|
|
49
|
+
event.target.value = valueCase
|
|
50
|
+
? convertByCase[valueCase](event.target.value)
|
|
51
|
+
: event.target.value;
|
|
52
|
+
event.target.value = maskValue(event.target.value);
|
|
53
|
+
event.target.value = (interceptors === null || interceptors === void 0 ? void 0 : interceptors.onChange)
|
|
54
|
+
? interceptors === null || interceptors === void 0 ? void 0 : interceptors.onChange(event.target.value)
|
|
55
|
+
: event.target.value;
|
|
56
|
+
onChange && onChange(event);
|
|
57
|
+
setHasValue(validateValue(event.target.value));
|
|
58
|
+
};
|
|
59
|
+
const handleKeyDown = (event) => {
|
|
60
|
+
onKeyDown && onKeyDown(event);
|
|
61
|
+
const changeEventValue = (interceptors === null || interceptors === void 0 ? void 0 : interceptors.onKeyDown)
|
|
62
|
+
? interceptors === null || interceptors === void 0 ? void 0 : interceptors.onKeyDown(value, event)
|
|
63
|
+
: value;
|
|
64
|
+
const changeEvent = {
|
|
65
|
+
target: { name, value: changeEventValue.toString() },
|
|
66
|
+
};
|
|
67
|
+
handleValueChange(changeEvent);
|
|
68
|
+
};
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setHasValue(validateValue(value));
|
|
71
|
+
const event = {
|
|
72
|
+
target: { name, value: value.toString() },
|
|
73
|
+
};
|
|
74
|
+
handleValueChange(event);
|
|
75
|
+
}, [value]);
|
|
76
|
+
value = maskValue(value);
|
|
77
|
+
value = (interceptors === null || interceptors === void 0 ? void 0 : interceptors.beforeSetValue)
|
|
78
|
+
? interceptors === null || interceptors === void 0 ? void 0 : interceptors.beforeSetValue(value)
|
|
79
|
+
: value;
|
|
80
|
+
return (React.createElement(StyledTextInputContainer, { stretch: stretch, hasError: !!error },
|
|
81
|
+
React.createElement(StyledTextInputLabel, { onClick: handleLabelClick, hasError: !!error, disabled: disabled, riseLabel: isFocused || hasValue }, label),
|
|
82
|
+
React.createElement(StyleTextInput, Object.assign({}, props, { name: name, value: value, hasError: !!error, disabled: disabled, ref: inputRef, onChange: handleValueChange, onFocus: handleInputFocus, onBlur: handleInputBlur, onKeyDown: handleKeyDown, autoComplete: "off" })),
|
|
83
|
+
error && React.createElement(StyleErrorSpan, null, error)));
|
|
84
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface StyledTextInputContainerProps {
|
|
2
|
+
hasError?: boolean;
|
|
3
|
+
stretch?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const StyledTextInputContainer: import("styled-components").StyledComponent<"div", any, StyledTextInputContainerProps, never>;
|
|
6
|
+
interface StyledTextInputLabelProps {
|
|
7
|
+
riseLabel?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
hasError?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const StyledTextInputLabel: import("styled-components").StyledComponent<"label", any, StyledTextInputLabelProps, never>;
|
|
12
|
+
interface StyleTextInputProps {
|
|
13
|
+
hasError?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const StyleTextInput: import("styled-components").StyledComponent<"input", any, StyleTextInputProps, never>;
|
|
16
|
+
export declare const StyleErrorSpan: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
17
|
+
export {};
|