@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,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const SimulationIcon = (props) => (React.createElement("svg", Object.assign({ height: "16px", width: "16px", version: "1.1", id: "Layer_1", xmlns: "http://www.w3.org/2000/svg", x: "0", y: "0", viewBox: "0 0 24 24", xmlSpace: "preserve" }, props),
|
|
3
|
+
React.createElement("path", { fill: "none", d: "M0 0h24v24H0z" }),
|
|
4
|
+
React.createElement("path", { className: "st1", d: "M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm1 18c0 .6-.4 1-1 1H4c-.6 0-1-.4-1-1V9.5h18V20zM3 8.5V4c0-.6.4-1 1-1h16c.6 0 1 .4 1 1v4.5H3z" }),
|
|
5
|
+
React.createElement("path", { className: "st1", d: "M5 14.5h14v1H5zM5 17.5h10v1H5zM5 11.5h14v1H5z" })));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const TrashIcon = (props) => (React.createElement("svg", Object.assign({ height: "16px", width: "16px", viewBox: "2 2 16 16", version: "1.2", baseProfile: "tiny", overflow: "visible", fill: "currentColor" }, props),
|
|
3
|
+
React.createElement("path", { fill: "none", d: "M0 0h20v20H0z" }),
|
|
4
|
+
React.createElement("path", { d: "M18 5h-3V3.8c0-1-.8-1.8-1.8-1.8H6.8C5.8 2 5 2.8 5 3.8V5H2v2h2v9c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7h2V5zM7 4h6v1H7V4zm7 12H6V7h8v9z" }),
|
|
5
|
+
React.createElement("path", { d: "M7.5 8.5h2v6h-2zM10.5 8.5h2v6h-2z" })));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const WhatsappIcon = (props) => (React.createElement("svg", Object.assign({ height: "64px", width: "64px", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64" }, props),
|
|
3
|
+
React.createElement("circle", { cx: "32", cy: "32", r: "32", fill: "#25D366" }),
|
|
4
|
+
React.createElement("path", { d: "M32.3 47.2c-2.8 0-5.3-.7-7.6-1.9L16 48l2.8-8.4c-1.4-2.3-2.3-5.1-2.3-8 0-8.6 7-15.6 15.7-15.6C41 16 48 23 48 31.6s-7 15.6-15.7 15.6m0-28.7c-7.3 0-13.2 5.9-13.2 13.1 0 2.9.9 5.5 2.5 7.7l-1.7 4.9 5.1-1.6c2.1 1.4 4.6 2.2 7.3 2.2 7.3 0 13.2-5.9 13.2-13.1 0-7.3-5.9-13.2-13.2-13.2m7.9 16.7c-.1-.2-.4-.3-.7-.4-.4-.2-2.3-1.1-2.6-1.2-.4-.1-.6-.2-.9.2-.3.4-1 1.2-1.2 1.5-.2.3-.4.3-.8.1-.4-.2-1.6-.6-3.1-1.9-1.1-1-1.9-2.3-2.1-2.6-.2-.4 0-.6.2-.8.2-.2.4-.4.6-.7.2-.2.3-.4.4-.6.1-.3.1-.5 0-.7-.1-.2-.9-2.1-1.2-2.8-.3-.8-.6-.6-.9-.6h-.7c-.3 0-.7.1-1 .5-.4.4-1.3 1.3-1.3 3.2 0 1.9 1.4 3.7 1.6 4 .2.3 2.7 4.2 6.6 5.8 3.9 1.5 3.9 1 4.6 1 .7-.1 2.3-.9 2.6-1.8 0-1.3 0-2.1-.1-2.2", fillRule: "evenodd", clipRule: "evenodd", fill: "#fff" })));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Option } from "../../types";
|
|
2
|
+
interface AutocompleteInputProps<T> {
|
|
3
|
+
value: T;
|
|
4
|
+
options: Array<Option<T>>;
|
|
5
|
+
label: string;
|
|
6
|
+
noOptionsMessage?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
onChange?: (value: T) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const AutocompleteInput: <T extends unknown>({ placeholder, value, onChange, options, label, noOptionsMessage, ...props }: AutocompleteInputProps<T>) => JSX.Element;
|
|
11
|
+
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, { useEffect, useRef, useState } from "react";
|
|
13
|
+
import { MultiselectContainer, MultiselectLabel, MultiselectOption, MultiselectOptionsContainer, MultiselectSearchContainer, MultiselectSearchInput, MultiselectSelectedValueLabel, } from "./autocompleteInput.styled";
|
|
14
|
+
export const AutocompleteInput = (_a) => {
|
|
15
|
+
var _b;
|
|
16
|
+
var { placeholder, value, onChange, options = [], label, noOptionsMessage } = _a, props = __rest(_a, ["placeholder", "value", "onChange", "options", "label", "noOptionsMessage"]);
|
|
17
|
+
const selectorRef = useRef(null);
|
|
18
|
+
const inputRef = useRef(null);
|
|
19
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
20
|
+
const [searchValue, setSearchValue] = useState("");
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const handleClickOutside = (event) => {
|
|
23
|
+
if (selectorRef.current && !selectorRef.current.contains(event.target)) {
|
|
24
|
+
setIsOpen(false);
|
|
25
|
+
setSearchValue("");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
29
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
30
|
+
}, [selectorRef]);
|
|
31
|
+
const handleOptionClick = (itemValue) => {
|
|
32
|
+
setIsOpen(false);
|
|
33
|
+
setSearchValue("");
|
|
34
|
+
onChange(itemValue);
|
|
35
|
+
};
|
|
36
|
+
const handleSearchInputChange = (event) => setSearchValue(event.currentTarget.value);
|
|
37
|
+
const handleLabelClick = (event) => {
|
|
38
|
+
var _a;
|
|
39
|
+
event.stopPropagation();
|
|
40
|
+
setIsOpen(true);
|
|
41
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
42
|
+
};
|
|
43
|
+
const optionsToRender = options
|
|
44
|
+
.filter(({ label }) => label.toLowerCase().includes(searchValue.toLowerCase()))
|
|
45
|
+
.map(({ label, value: itemValue }, index) => {
|
|
46
|
+
return (React.createElement(MultiselectOption, { key: index, selected: value === itemValue, onClick: () => handleOptionClick(itemValue) }, label));
|
|
47
|
+
});
|
|
48
|
+
const selectItemLabel = ((_b = options.find(({ value: itemValue }) => value === itemValue)) === null || _b === void 0 ? void 0 : _b.label) || "";
|
|
49
|
+
return (React.createElement(MultiselectContainer, { ref: selectorRef },
|
|
50
|
+
React.createElement(MultiselectSearchContainer, null,
|
|
51
|
+
React.createElement(MultiselectLabel, { onClick: handleLabelClick, riseLabel: isOpen || !!selectItemLabel }, label),
|
|
52
|
+
React.createElement(MultiselectSearchInput, Object.assign({ ref: inputRef, placeholder: isOpen && placeholder, onChange: handleSearchInputChange, onFocus: () => setIsOpen(true), value: searchValue }, props)),
|
|
53
|
+
!isOpen && (React.createElement(MultiselectSelectedValueLabel, { onClick: handleLabelClick }, selectItemLabel))),
|
|
54
|
+
React.createElement(MultiselectOptionsContainer, { isOpen: isOpen }, optionsToRender.length > 0 ? (optionsToRender) : (React.createElement(MultiselectOption, { cursor: "default" }, noOptionsMessage)))));
|
|
55
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const MultiselectContainer: import("styled-components").StyledComponent<"div", any, MultiselectSearchContainerProps, never>;
|
|
2
|
+
export interface MultiselectSearchContainerProps {
|
|
3
|
+
stretch?: boolean;
|
|
4
|
+
hasLabel?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare const MultiselectSearchContainer: import("styled-components").StyledComponent<"div", any, MultiselectSearchContainerProps, never>;
|
|
9
|
+
interface MultiselectLabelProps {
|
|
10
|
+
riseLabel?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const MultiselectLabel: import("styled-components").StyledComponent<"label", any, MultiselectLabelProps, never>;
|
|
13
|
+
export declare const MultiselectSearchInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
14
|
+
export declare const MultiselectSelectedValueLabel: import("styled-components").StyledComponent<"label", any, {}, never>;
|
|
15
|
+
interface MultiselectOptionsContainerProps {
|
|
16
|
+
isOpen?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const MultiselectOptionsContainer: import("styled-components").StyledComponent<"div", any, MultiselectOptionsContainerProps, never>;
|
|
19
|
+
interface MultiselectOptionProps {
|
|
20
|
+
cursor?: "default" | "pointer";
|
|
21
|
+
selected?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const MultiselectOption: import("styled-components").StyledComponent<"div", any, MultiselectOptionProps, never>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { colors } from "../../constants";
|
|
3
|
+
export const MultiselectContainer = styled.div `
|
|
4
|
+
position: relative;
|
|
5
|
+
`;
|
|
6
|
+
export const MultiselectSearchContainer = styled.div `
|
|
7
|
+
-webkit-appearance: none;
|
|
8
|
+
-moz-appearance: none;
|
|
9
|
+
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
min-height: 16px;
|
|
13
|
+
height: auto;
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
border: 0;
|
|
16
|
+
position: relative;
|
|
17
|
+
top: 2px;
|
|
18
|
+
font-size: 16px;
|
|
19
|
+
color: ${colors.textGreen};
|
|
20
|
+
border-bottom: 1px solid ${colors.lightGrey};
|
|
21
|
+
width: ${({ stretch }) => (stretch ? "100%" : "auto")};
|
|
22
|
+
box-sizing: content-box;
|
|
23
|
+
cursor: ${({ disabled }) => (!disabled ? "pointer" : "default")};
|
|
24
|
+
|
|
25
|
+
&:focus {
|
|
26
|
+
outline: none;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
export const MultiselectLabel = styled.label `
|
|
30
|
+
position: absolute;
|
|
31
|
+
color: ${colors.textLightGreen};
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
transition: transform 0.4s, font-size 0.4s;
|
|
34
|
+
transition-timing-function: ease;
|
|
35
|
+
transform: translateY(0);
|
|
36
|
+
font-size: 16px;
|
|
37
|
+
cursor: ${({ riseLabel }) => (riseLabel ? "default" : "text")};
|
|
38
|
+
|
|
39
|
+
${({ riseLabel }) => riseLabel &&
|
|
40
|
+
`
|
|
41
|
+
transform: translateY(-17px);
|
|
42
|
+
font-size: 12px;
|
|
43
|
+
`}
|
|
44
|
+
`;
|
|
45
|
+
export const MultiselectSearchInput = styled.input `
|
|
46
|
+
width: 100%;
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
border: none;
|
|
49
|
+
`;
|
|
50
|
+
export const MultiselectSelectedValueLabel = styled.label `
|
|
51
|
+
position: absolute;
|
|
52
|
+
width: 100%;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
text-overflow: ellipsis;
|
|
56
|
+
`;
|
|
57
|
+
export const MultiselectOptionsContainer = styled.div `
|
|
58
|
+
max-height: 250px;
|
|
59
|
+
overflow-y: scroll;
|
|
60
|
+
height: auto;
|
|
61
|
+
padding: 4px 0;
|
|
62
|
+
z-index: 9;
|
|
63
|
+
position: absolute;
|
|
64
|
+
top: auto;
|
|
65
|
+
transform-origin: top left;
|
|
66
|
+
transform: scale(${({ isOpen }) => (isOpen ? "1" : "0")});
|
|
67
|
+
transition: transform 0.1s ease-out;
|
|
68
|
+
transform-style: preserve-3d;
|
|
69
|
+
width: 100%;
|
|
70
|
+
background-color: ${colors.white};
|
|
71
|
+
box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.2);
|
|
72
|
+
border-radius: 4px;
|
|
73
|
+
`;
|
|
74
|
+
export const MultiselectOption = styled.div `
|
|
75
|
+
-webkit-appearance: none;
|
|
76
|
+
-moz-appearance: none;
|
|
77
|
+
|
|
78
|
+
padding: 8px;
|
|
79
|
+
cursor: ${({ cursor = "pointer" }) => cursor};
|
|
80
|
+
|
|
81
|
+
${({ selected }) => `
|
|
82
|
+
background-color: ${selected ? colors.textGreen : colors.white};
|
|
83
|
+
color: ${selected ? colors.white : colors.textGreen};
|
|
84
|
+
|
|
85
|
+
&:hover {
|
|
86
|
+
background-color: ${selected ? colors.textGreen : colors.softGrey} !important;
|
|
87
|
+
}
|
|
88
|
+
`}
|
|
89
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./autocompleteInput.component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./autocompleteInput.component";
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export const Button = (_a) => {
|
|
14
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
15
|
+
return React.createElement("button", Object.assign({}, props), children);
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type ButtonSize = "small" | "normal";
|
|
3
|
+
export interface BasicButtonProps {
|
|
4
|
+
stretch?: boolean;
|
|
5
|
+
buttonSize?: ButtonSize;
|
|
6
|
+
}
|
|
7
|
+
export declare const ContainedButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("react").ButtonHTMLAttributes<HTMLButtonElement>>, any, BasicButtonProps, never>;
|
|
8
|
+
export declare const PhantonButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("react").ButtonHTMLAttributes<HTMLButtonElement>>, any, BasicButtonProps, never>;
|
|
9
|
+
export declare const ContainedIconButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("react").ButtonHTMLAttributes<HTMLButtonElement>>, any, BasicButtonProps, never>;
|
|
10
|
+
export declare const CircleIconButtonLarge: import("styled-components").StyledComponent<import("react").FunctionComponent<import("react").ButtonHTMLAttributes<HTMLButtonElement>>, any, BasicButtonProps, never>;
|
|
11
|
+
interface PhantonIconButtonProps {
|
|
12
|
+
size?: "normal" | "large";
|
|
13
|
+
}
|
|
14
|
+
export declare const PhantonIconButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("react").ButtonHTMLAttributes<HTMLButtonElement>>, any, BasicButtonProps & PhantonIconButtonProps, never>;
|
|
15
|
+
export declare const LightIconButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("react").ButtonHTMLAttributes<HTMLButtonElement>>, any, BasicButtonProps, never>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { colors } from "../../constants";
|
|
3
|
+
import { Button } from "./button.component";
|
|
4
|
+
const cssByButtonSize = {
|
|
5
|
+
small: `
|
|
6
|
+
padding: 13px 35px;
|
|
7
|
+
font-size: 12px;
|
|
8
|
+
`,
|
|
9
|
+
normal: `
|
|
10
|
+
padding: 16px 40px;
|
|
11
|
+
font-size: 16px;
|
|
12
|
+
`,
|
|
13
|
+
};
|
|
14
|
+
const BasicStyledButton = styled(Button) `
|
|
15
|
+
font-weight: 400;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
border-radius: 8px;
|
|
18
|
+
|
|
19
|
+
${({ buttonSize = "normal" }) => cssByButtonSize[buttonSize]}
|
|
20
|
+
|
|
21
|
+
width: ${({ stretch }) => (stretch ? "100%" : "auto")};
|
|
22
|
+
|
|
23
|
+
// we need to remove default HTML button styles
|
|
24
|
+
border: none;
|
|
25
|
+
background: none;
|
|
26
|
+
|
|
27
|
+
&:focus {
|
|
28
|
+
outline: none;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
export const ContainedButton = styled(BasicStyledButton) `
|
|
32
|
+
background-color: ${colors.darkGreen};
|
|
33
|
+
color: ${colors.white};
|
|
34
|
+
|
|
35
|
+
border: 2px solid ${colors.darkGreen};
|
|
36
|
+
|
|
37
|
+
&:hover {
|
|
38
|
+
background-color: ${colors.green};
|
|
39
|
+
border-color: ${colors.green};
|
|
40
|
+
color: ${colors.white};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&:disabled {
|
|
44
|
+
background-color: ${colors.grey};
|
|
45
|
+
border-color: ${colors.grey};
|
|
46
|
+
color: ${colors.textGreen};
|
|
47
|
+
cursor: default;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
export const PhantonButton = styled(BasicStyledButton) `
|
|
51
|
+
color: ${colors.darkGreen};
|
|
52
|
+
|
|
53
|
+
border: 2px solid ${colors.darkGreen};
|
|
54
|
+
|
|
55
|
+
&:hover {
|
|
56
|
+
background-color: ${colors.green};
|
|
57
|
+
border-color: ${colors.green};
|
|
58
|
+
color: ${colors.white};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:disabled {
|
|
62
|
+
background-color: transparent;
|
|
63
|
+
border-color: ${colors.grey};
|
|
64
|
+
color: ${colors.grey};
|
|
65
|
+
cursor: default;
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
export const ContainedIconButton = styled(ContainedButton) `
|
|
69
|
+
padding: 0;
|
|
70
|
+
width: 33px;
|
|
71
|
+
height: 33px;
|
|
72
|
+
border-radius: 8px;
|
|
73
|
+
|
|
74
|
+
display: flex;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
align-items: center;
|
|
77
|
+
`;
|
|
78
|
+
export const CircleIconButtonLarge = styled(ContainedButton) `
|
|
79
|
+
padding: 0;
|
|
80
|
+
width: 62px;
|
|
81
|
+
height: 62px;
|
|
82
|
+
|
|
83
|
+
border-radius: 50%;
|
|
84
|
+
`;
|
|
85
|
+
export const PhantonIconButton = styled(PhantonButton) `
|
|
86
|
+
padding: 0;
|
|
87
|
+
border-radius: 8px;
|
|
88
|
+
|
|
89
|
+
${({ size }) => {
|
|
90
|
+
const sizeInPixels = size && size === "large" ? 48 : 33;
|
|
91
|
+
return `
|
|
92
|
+
width: ${sizeInPixels}px;
|
|
93
|
+
height: ${sizeInPixels}px;
|
|
94
|
+
`;
|
|
95
|
+
}}
|
|
96
|
+
|
|
97
|
+
display: flex;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
align-items: center;
|
|
100
|
+
|
|
101
|
+
border: 2px solid ${colors.darkGreen};
|
|
102
|
+
`;
|
|
103
|
+
export const LightIconButton = styled(BasicStyledButton) `
|
|
104
|
+
padding: 0;
|
|
105
|
+
width: 33px;
|
|
106
|
+
height: 33px;
|
|
107
|
+
border-radius: 8px;
|
|
108
|
+
color: ${colors.darkGreen};
|
|
109
|
+
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
align-items: center;
|
|
113
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { CardContainer } from "./card.styled";
|
|
14
|
+
export const Card = (_a) => {
|
|
15
|
+
var { children, selected, hovered } = _a, props = __rest(_a, ["children", "selected", "hovered"]);
|
|
16
|
+
return (React.createElement(CardContainer, Object.assign({ hovered: hovered, selected: selected }, props), children));
|
|
17
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { colors } from "../../constants";
|
|
3
|
+
export const CardContainer = styled.div `
|
|
4
|
+
${({ selected, hovered }) => `
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
border: ${selected
|
|
7
|
+
? `2px solid ${colors.green}`
|
|
8
|
+
: `2px solid${colors.cardBorderGrey}`};
|
|
9
|
+
width: 100%;
|
|
10
|
+
box-shadow: ${selected && "4px 4px 12px 0px rgba(0, 0, 0, 0.15)"};
|
|
11
|
+
:hover {
|
|
12
|
+
${hovered &&
|
|
13
|
+
`
|
|
14
|
+
border: 2px solid ${colors.lightGreen};
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
`}
|
|
17
|
+
}
|
|
18
|
+
`}
|
|
19
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./card.component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./card.component";
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { InputWrapper, CheckboxField, Label, LabelText, CheckboxIcon, Check, } from "./checkbox.styled";
|
|
14
|
+
export const Checkbox = (_a) => {
|
|
15
|
+
var { name, label, checked, onChange } = _a, props = __rest(_a, ["name", "label", "checked", "onChange"]);
|
|
16
|
+
const handleCheckboxChange = (event) => {
|
|
17
|
+
event.target.checked = !checked;
|
|
18
|
+
onChange && onChange(event);
|
|
19
|
+
};
|
|
20
|
+
return (React.createElement(InputWrapper, null,
|
|
21
|
+
React.createElement(CheckboxField, Object.assign({ type: "checkbox", onClick: handleCheckboxChange, id: name, name: name }, props)),
|
|
22
|
+
React.createElement(Label, { htmlFor: name, onClick: handleCheckboxChange },
|
|
23
|
+
React.createElement(CheckboxIcon, null, checked && React.createElement(Check, null)),
|
|
24
|
+
React.createElement(LabelText, null, label))));
|
|
25
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const InputWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const CheckboxField: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
4
|
+
export declare const CheckboxIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const Check: import("styled-components").StyledComponent<import("react").FunctionComponent<import("react").SVGAttributes<HTMLOrSVGElement>>, any, {}, never>;
|
|
6
|
+
export declare const Label: import("styled-components").StyledComponent<"label", any, {}, never>;
|
|
7
|
+
export declare const LabelText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { colors } from "../../constants";
|
|
3
|
+
import { CheckMarkIcon } from "../../assets/icons";
|
|
4
|
+
export const InputWrapper = styled.div `
|
|
5
|
+
position: relative;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
width: auto;
|
|
10
|
+
`;
|
|
11
|
+
export const CheckboxField = styled.input `
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
position: absolute;
|
|
14
|
+
margin: 0;
|
|
15
|
+
width: 24px;
|
|
16
|
+
height: 24px;
|
|
17
|
+
opacity: 0;
|
|
18
|
+
`;
|
|
19
|
+
export const CheckboxIcon = styled.div `
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
min-width: 24px;
|
|
24
|
+
min-height: 24px;
|
|
25
|
+
max-width: 24px;
|
|
26
|
+
max-height: 24px;
|
|
27
|
+
border: 2px solid ${colors.green};
|
|
28
|
+
background-color: transparent;
|
|
29
|
+
border-radius: 4px;
|
|
30
|
+
color: ${colors.green};
|
|
31
|
+
`;
|
|
32
|
+
export const Check = styled(CheckMarkIcon) `
|
|
33
|
+
height: 12px;
|
|
34
|
+
`;
|
|
35
|
+
export const Label = styled.label `
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
align-items: center;
|
|
39
|
+
color: ${colors.textGreen};
|
|
40
|
+
:hover {
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
export const LabelText = styled.div `
|
|
45
|
+
margin-left: 8px;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
line-height: 1.125rem;
|
|
48
|
+
font-weight: 400;
|
|
49
|
+
color: ${colors.darkGreen};
|
|
50
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./checkbox.component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./checkbox.component";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface CodeInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
value: string;
|
|
4
|
+
name: string;
|
|
5
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const CodeInput: React.FunctionComponent<CodeInputProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
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 } from "react";
|
|
13
|
+
import { DigitInput, InputWrapper } from "./codeInput.styled";
|
|
14
|
+
export const CodeInput = (_a) => {
|
|
15
|
+
var { onChange, value, name } = _a, props = __rest(_a, ["onChange", "value", "name"]);
|
|
16
|
+
const oneRef = useRef();
|
|
17
|
+
const twoRef = useRef();
|
|
18
|
+
const threeRef = useRef();
|
|
19
|
+
const fourRef = useRef();
|
|
20
|
+
const [one = "", two = "", three = "", four = ""] = value
|
|
21
|
+
? value.split("", 4)
|
|
22
|
+
: new Array(4).fill("");
|
|
23
|
+
const handleInputChange = (event) => {
|
|
24
|
+
event.target.name = name;
|
|
25
|
+
const newValues = { one, two, three, four };
|
|
26
|
+
newValues[event.target.id] = event.target.value.slice(0, 4);
|
|
27
|
+
const { one: newOne, two: newTwo, three: newThree, four: newFour, } = newValues;
|
|
28
|
+
event.target.value = `${newOne}${newTwo}${newThree}${newFour}`;
|
|
29
|
+
onChange && onChange(event);
|
|
30
|
+
};
|
|
31
|
+
const handleKeyDown = (event) => {
|
|
32
|
+
const { key } = event;
|
|
33
|
+
const { id, value } = event.currentTarget;
|
|
34
|
+
if (value)
|
|
35
|
+
return;
|
|
36
|
+
if (key !== "Backspace") {
|
|
37
|
+
if (id === "one")
|
|
38
|
+
twoRef === null || twoRef === void 0 ? void 0 : twoRef.current.focus();
|
|
39
|
+
if (id === "two")
|
|
40
|
+
threeRef === null || threeRef === void 0 ? void 0 : threeRef.current.focus();
|
|
41
|
+
if (id === "three")
|
|
42
|
+
fourRef === null || fourRef === void 0 ? void 0 : fourRef.current.focus();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (id === "four")
|
|
46
|
+
threeRef === null || threeRef === void 0 ? void 0 : threeRef.current.focus();
|
|
47
|
+
if (id === "three")
|
|
48
|
+
twoRef === null || twoRef === void 0 ? void 0 : twoRef.current.focus();
|
|
49
|
+
if (id === "two")
|
|
50
|
+
oneRef === null || oneRef === void 0 ? void 0 : oneRef.current.focus();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return (React.createElement(InputWrapper, Object.assign({}, props),
|
|
54
|
+
React.createElement(DigitInput, { id: "one", ref: oneRef, autoFocus: true, value: one, onChange: handleInputChange, onKeyDown: handleKeyDown }),
|
|
55
|
+
React.createElement(DigitInput, { id: "two", ref: twoRef, value: two, onChange: handleInputChange, onKeyDown: handleKeyDown }),
|
|
56
|
+
React.createElement(DigitInput, { id: "three", ref: threeRef, value: three, onChange: handleInputChange, onKeyDown: handleKeyDown }),
|
|
57
|
+
React.createElement(DigitInput, { id: "four", ref: fourRef, value: four, onChange: handleInputChange, onKeyDown: handleKeyDown })));
|
|
58
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { colors } from "../../constants";
|
|
3
|
+
export const InputWrapper = styled.div `
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
height: auto;
|
|
7
|
+
background: transparent;
|
|
8
|
+
margin: 5px;
|
|
9
|
+
|
|
10
|
+
&:focus {
|
|
11
|
+
outline: 0;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
export const DigitInput = styled.input `
|
|
15
|
+
height: 60px;
|
|
16
|
+
width: 60px;
|
|
17
|
+
text-align: center;
|
|
18
|
+
font-size: 2rem;
|
|
19
|
+
margin-right: 10px;
|
|
20
|
+
border: 1px solid ${colors.grey};
|
|
21
|
+
border-radius: 4px;
|
|
22
|
+
|
|
23
|
+
&:focus {
|
|
24
|
+
border-color: ${colors.lightGreen};
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./codeInput.component";
|