@bosonprotocol/react-kit 0.32.0-alpha.8 → 0.32.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/cjs/components/contractualAgreement/ContractualAgreement.js +2 -2
- package/dist/cjs/components/contractualAgreement/ContractualAgreement.js.map +1 -1
- package/dist/cjs/components/error/SimpleError.d.ts +7 -5
- package/dist/cjs/components/error/SimpleError.d.ts.map +1 -1
- package/dist/cjs/components/error/SimpleError.js +6 -5
- package/dist/cjs/components/error/SimpleError.js.map +1 -1
- package/dist/cjs/components/form/BaseTextArea.d.ts +5 -0
- package/dist/cjs/components/form/BaseTextArea.d.ts.map +1 -0
- package/dist/cjs/components/form/{Textarea.js → BaseTextArea.js} +6 -5
- package/dist/cjs/components/form/BaseTextArea.js.map +1 -0
- package/dist/cjs/components/form/Field.styles.d.ts +25 -2
- package/dist/cjs/components/form/Field.styles.d.ts.map +1 -1
- package/dist/cjs/components/form/Field.styles.js +35 -60
- package/dist/cjs/components/form/Field.styles.js.map +1 -1
- package/dist/cjs/components/form/FormField.d.ts +1 -1
- package/dist/cjs/components/form/FormField.d.ts.map +1 -1
- package/dist/cjs/components/form/FormField.js +5 -3
- package/dist/cjs/components/form/FormField.js.map +1 -1
- package/dist/cjs/components/form/Upload/ImageEditorModal/ImageEditor.d.ts +9 -0
- package/dist/cjs/components/form/Upload/ImageEditorModal/ImageEditor.d.ts.map +1 -0
- package/dist/cjs/components/form/Upload/ImageEditorModal/ImageEditor.js +65 -0
- package/dist/cjs/components/form/Upload/ImageEditorModal/ImageEditor.js.map +1 -0
- package/dist/cjs/components/form/Upload/ImageEditorModal/ImageEditorModal.d.ts +10 -0
- package/dist/cjs/components/form/Upload/ImageEditorModal/ImageEditorModal.d.ts.map +1 -0
- package/dist/cjs/components/form/Upload/ImageEditorModal/ImageEditorModal.js +100 -0
- package/dist/cjs/components/form/Upload/ImageEditorModal/ImageEditorModal.js.map +1 -0
- package/dist/cjs/components/form/Upload/Upload.d.ts +39 -2
- package/dist/cjs/components/form/Upload/Upload.d.ts.map +1 -1
- package/dist/cjs/components/form/Upload/Upload.js +81 -19
- package/dist/cjs/components/form/Upload/Upload.js.map +1 -1
- package/dist/cjs/components/form/Upload/WithUploadToIpfs.d.ts +1 -1
- package/dist/cjs/components/form/Upload/WithUploadToIpfs.d.ts.map +1 -1
- package/dist/cjs/components/form/Upload/WithUploadToIpfs.js +9 -7
- package/dist/cjs/components/form/Upload/WithUploadToIpfs.js.map +1 -1
- package/dist/cjs/components/form/index.d.ts +2 -2
- package/dist/cjs/components/form/index.d.ts.map +1 -1
- package/dist/cjs/components/form/index.js +3 -4
- package/dist/cjs/components/form/index.js.map +1 -1
- package/dist/cjs/components/form/types.d.ts +21 -5
- package/dist/cjs/components/form/types.d.ts.map +1 -1
- package/dist/cjs/components/license/License.js +2 -2
- package/dist/cjs/components/license/License.js.map +1 -1
- package/dist/cjs/components/modal/ModalComponents.d.ts +2 -0
- package/dist/cjs/components/modal/ModalComponents.d.ts.map +1 -1
- package/dist/cjs/components/modal/ModalComponents.js +3 -1
- package/dist/cjs/components/modal/ModalComponents.js.map +1 -1
- package/dist/cjs/components/modal/ModalContext.d.ts +2 -1
- package/dist/cjs/components/modal/ModalContext.d.ts.map +1 -1
- package/dist/cjs/components/modal/ModalContext.js.map +1 -1
- package/dist/cjs/components/modal/ModalTypes.d.ts +1 -0
- package/dist/cjs/components/modal/ModalTypes.d.ts.map +1 -1
- package/dist/cjs/components/modal/ModalTypes.js +2 -1
- package/dist/cjs/components/modal/ModalTypes.js.map +1 -1
- package/dist/cjs/components/modal/components/Redeem/Confirmation/Confirmation.js +3 -3
- package/dist/cjs/components/modal/components/Redeem/Confirmation/Confirmation.js.map +1 -1
- package/dist/cjs/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.js +2 -2
- package/dist/cjs/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.js.map +1 -1
- package/dist/cjs/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.js +2 -2
- package/dist/cjs/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.js.map +1 -1
- package/dist/cjs/components/modal/components/common/VariationSelects.js +2 -2
- package/dist/cjs/components/modal/components/common/VariationSelects.js.map +1 -1
- package/dist/cjs/components/modal/useModal.d.ts +3 -2
- package/dist/cjs/components/modal/useModal.d.ts.map +1 -1
- package/dist/cjs/components/step/MultiSteps.d.ts +23 -0
- package/dist/cjs/components/step/MultiSteps.d.ts.map +1 -0
- package/dist/cjs/components/step/MultiSteps.js +121 -0
- package/dist/cjs/components/step/MultiSteps.js.map +1 -0
- package/dist/cjs/components/step/Step.d.ts +28 -0
- package/dist/cjs/components/step/Step.d.ts.map +1 -0
- package/dist/cjs/components/step/Step.js +32 -0
- package/dist/cjs/components/step/Step.js.map +1 -0
- package/dist/cjs/components/step/Step.styles.d.ts +29 -0
- package/dist/cjs/components/step/Step.styles.d.ts.map +1 -0
- package/dist/cjs/components/step/Step.styles.js +196 -0
- package/dist/cjs/components/step/Step.styles.js.map +1 -0
- package/dist/cjs/hooks/images/useFileImage.d.ts +8 -0
- package/dist/cjs/hooks/images/useFileImage.d.ts.map +1 -0
- package/dist/cjs/hooks/images/useFileImage.js +26 -0
- package/dist/cjs/hooks/images/useFileImage.js.map +1 -0
- package/dist/cjs/hooks/images/useIpfsImage.d.ts +13 -0
- package/dist/cjs/hooks/images/useIpfsImage.d.ts.map +1 -0
- package/dist/cjs/hooks/images/useIpfsImage.js +26 -0
- package/dist/cjs/hooks/images/useIpfsImage.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/base64/base64.d.ts +4 -1
- package/dist/cjs/lib/base64/base64.d.ts.map +1 -1
- package/dist/cjs/lib/base64/base64.js +1 -1
- package/dist/cjs/lib/base64/base64.js.map +1 -1
- package/dist/esm/components/contractualAgreement/ContractualAgreement.js +1 -1
- package/dist/esm/components/contractualAgreement/ContractualAgreement.js.map +1 -1
- package/dist/esm/components/error/SimpleError.d.ts +7 -5
- package/dist/esm/components/error/SimpleError.d.ts.map +1 -1
- package/dist/esm/components/error/SimpleError.js +4 -4
- package/dist/esm/components/error/SimpleError.js.map +1 -1
- package/dist/esm/components/form/BaseTextArea.d.ts +5 -0
- package/dist/esm/components/form/BaseTextArea.d.ts.map +1 -0
- package/dist/esm/components/form/{Textarea.js → BaseTextArea.js} +3 -3
- package/dist/esm/components/form/BaseTextArea.js.map +1 -0
- package/dist/esm/components/form/Field.styles.d.ts +25 -2
- package/dist/esm/components/form/Field.styles.d.ts.map +1 -1
- package/dist/esm/components/form/Field.styles.js +35 -60
- package/dist/esm/components/form/Field.styles.js.map +1 -1
- package/dist/esm/components/form/FormField.d.ts +1 -1
- package/dist/esm/components/form/FormField.d.ts.map +1 -1
- package/dist/esm/components/form/FormField.js +3 -2
- package/dist/esm/components/form/FormField.js.map +1 -1
- package/dist/esm/components/form/Upload/ImageEditorModal/ImageEditor.d.ts +9 -0
- package/dist/esm/components/form/Upload/ImageEditorModal/ImageEditor.d.ts.map +1 -0
- package/dist/esm/components/form/Upload/ImageEditorModal/ImageEditor.js +36 -0
- package/dist/esm/components/form/Upload/ImageEditorModal/ImageEditor.js.map +1 -0
- package/dist/esm/components/form/Upload/ImageEditorModal/ImageEditorModal.d.ts +10 -0
- package/dist/esm/components/form/Upload/ImageEditorModal/ImageEditorModal.d.ts.map +1 -0
- package/dist/esm/components/form/Upload/ImageEditorModal/ImageEditorModal.js +48 -0
- package/dist/esm/components/form/Upload/ImageEditorModal/ImageEditorModal.js.map +1 -0
- package/dist/esm/components/form/Upload/Upload.d.ts +39 -2
- package/dist/esm/components/form/Upload/Upload.d.ts.map +1 -1
- package/dist/esm/components/form/Upload/Upload.js +93 -19
- package/dist/esm/components/form/Upload/Upload.js.map +1 -1
- package/dist/esm/components/form/Upload/WithUploadToIpfs.d.ts +1 -1
- package/dist/esm/components/form/Upload/WithUploadToIpfs.d.ts.map +1 -1
- package/dist/esm/components/form/Upload/WithUploadToIpfs.js +9 -7
- package/dist/esm/components/form/Upload/WithUploadToIpfs.js.map +1 -1
- package/dist/esm/components/form/index.d.ts +2 -2
- package/dist/esm/components/form/index.d.ts.map +1 -1
- package/dist/esm/components/form/index.js +2 -2
- package/dist/esm/components/form/index.js.map +1 -1
- package/dist/esm/components/form/types.d.ts +21 -5
- package/dist/esm/components/form/types.d.ts.map +1 -1
- package/dist/esm/components/license/License.js +1 -1
- package/dist/esm/components/license/License.js.map +1 -1
- package/dist/esm/components/modal/ModalComponents.d.ts +2 -0
- package/dist/esm/components/modal/ModalComponents.d.ts.map +1 -1
- package/dist/esm/components/modal/ModalComponents.js +3 -1
- package/dist/esm/components/modal/ModalComponents.js.map +1 -1
- package/dist/esm/components/modal/ModalContext.d.ts +2 -1
- package/dist/esm/components/modal/ModalContext.d.ts.map +1 -1
- package/dist/esm/components/modal/ModalContext.js.map +1 -1
- package/dist/esm/components/modal/ModalTypes.d.ts +1 -0
- package/dist/esm/components/modal/ModalTypes.d.ts.map +1 -1
- package/dist/esm/components/modal/ModalTypes.js +2 -1
- package/dist/esm/components/modal/ModalTypes.js.map +1 -1
- package/dist/esm/components/modal/components/Redeem/Confirmation/Confirmation.js +1 -1
- package/dist/esm/components/modal/components/Redeem/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.js +1 -1
- package/dist/esm/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.js.map +1 -1
- package/dist/esm/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.js +1 -1
- package/dist/esm/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.js.map +1 -1
- package/dist/esm/components/modal/components/common/VariationSelects.js +1 -1
- package/dist/esm/components/modal/components/common/VariationSelects.js.map +1 -1
- package/dist/esm/components/modal/useModal.d.ts +3 -2
- package/dist/esm/components/modal/useModal.d.ts.map +1 -1
- package/dist/esm/components/step/MultiSteps.d.ts +23 -0
- package/dist/esm/components/step/MultiSteps.d.ts.map +1 -0
- package/dist/esm/components/step/MultiSteps.js +82 -0
- package/dist/esm/components/step/MultiSteps.js.map +1 -0
- package/dist/esm/components/step/Step.d.ts +28 -0
- package/dist/esm/components/step/Step.d.ts.map +1 -0
- package/dist/esm/components/step/Step.js +13 -0
- package/dist/esm/components/step/Step.js.map +1 -0
- package/dist/esm/components/step/Step.styles.d.ts +29 -0
- package/dist/esm/components/step/Step.styles.d.ts.map +1 -0
- package/dist/esm/components/step/Step.styles.js +170 -0
- package/dist/esm/components/step/Step.styles.js.map +1 -0
- package/dist/esm/hooks/images/useFileImage.d.ts +8 -0
- package/dist/esm/hooks/images/useFileImage.d.ts.map +1 -0
- package/dist/esm/hooks/images/useFileImage.js +13 -0
- package/dist/esm/hooks/images/useFileImage.js.map +1 -0
- package/dist/esm/hooks/images/useIpfsImage.d.ts +13 -0
- package/dist/esm/hooks/images/useIpfsImage.d.ts.map +1 -0
- package/dist/esm/hooks/images/useIpfsImage.js +16 -0
- package/dist/esm/hooks/images/useIpfsImage.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/base64/base64.d.ts +4 -1
- package/dist/esm/lib/base64/base64.d.ts.map +1 -1
- package/dist/esm/lib/base64/base64.js +1 -1
- package/dist/esm/lib/base64/base64.js.map +1 -1
- package/package.json +7 -4
- package/src/components/contractualAgreement/ContractualAgreement.tsx +1 -1
- package/src/components/error/SimpleError.tsx +16 -11
- package/src/components/form/{Textarea.tsx → BaseTextArea.tsx} +8 -3
- package/src/components/form/Field.styles.ts +68 -64
- package/src/components/form/FormField.tsx +6 -4
- package/src/components/form/Upload/ImageEditorModal/ImageEditor.tsx +74 -0
- package/src/components/form/Upload/ImageEditorModal/ImageEditorModal.tsx +77 -0
- package/src/components/form/Upload/Upload.tsx +137 -41
- package/src/components/form/Upload/WithUploadToIpfs.tsx +13 -11
- package/src/components/form/index.ts +2 -2
- package/src/components/form/types.ts +20 -4
- package/src/components/license/License.tsx +1 -1
- package/src/components/modal/ModalComponents.tsx +3 -1
- package/src/components/modal/ModalContext.tsx +4 -3
- package/src/components/modal/ModalTypes.ts +2 -1
- package/src/components/modal/components/Redeem/Confirmation/Confirmation.tsx +1 -1
- package/src/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.tsx +1 -1
- package/src/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.tsx +1 -1
- package/src/components/modal/components/common/VariationSelects.tsx +1 -1
- package/src/components/step/MultiSteps.tsx +187 -0
- package/src/components/step/Step.styles.ts +209 -0
- package/src/components/step/Step.tsx +67 -0
- package/src/hooks/images/useFileImage.ts +24 -0
- package/src/hooks/images/useIpfsImage.ts +27 -0
- package/src/index.tsx +3 -0
- package/src/lib/base64/base64.ts +1 -1
- package/src/stories/buttons/Upload.stories.tsx +82 -0
- package/src/stories/form/{Input.stories.tsx → BaseInput.stories.tsx} +1 -1
- package/src/stories/form/BaseTextArea.stories.tsx +59 -0
- package/src/stories/multisteps/MultiSteps.stories.tsx +86 -0
- package/dist/cjs/components/form/Textarea.d.ts +0 -4
- package/dist/cjs/components/form/Textarea.d.ts.map +0 -1
- package/dist/cjs/components/form/Textarea.js.map +0 -1
- package/dist/esm/components/form/Textarea.d.ts +0 -4
- package/dist/esm/components/form/Textarea.d.ts.map +0 -1
- package/dist/esm/components/form/Textarea.js.map +0 -1
- /package/src/stories/buttons/{button.stories.tsx → Button.stories.tsx} +0 -0
|
@@ -17,11 +17,13 @@ export const SUPPORTED_FORMATS = [
|
|
|
17
17
|
"image/jpg",
|
|
18
18
|
"image/jpeg",
|
|
19
19
|
"image/gif",
|
|
20
|
-
"image/png"
|
|
20
|
+
"image/png",
|
|
21
|
+
"image/webp"
|
|
21
22
|
];
|
|
22
|
-
|
|
23
23
|
export interface WithUploadToIpfsProps {
|
|
24
|
-
saveToIpfs: (
|
|
24
|
+
saveToIpfs: (
|
|
25
|
+
files: File[] | null
|
|
26
|
+
) => Promise<false | FileProps[] | undefined>;
|
|
25
27
|
loadMedia: (src: string) => string;
|
|
26
28
|
removeFile: (src: string) => void;
|
|
27
29
|
}
|
|
@@ -32,16 +34,16 @@ export function WithUploadToIpfs<P extends WithUploadToIpfsProps>(
|
|
|
32
34
|
props: Omit<P & UploadProps, keyof WithUploadToIpfsProps>
|
|
33
35
|
) => {
|
|
34
36
|
const withUpload = props?.withUpload || false;
|
|
35
|
-
|
|
37
|
+
const accept: string = props.accept
|
|
38
|
+
? props.accept
|
|
39
|
+
: SUPPORTED_FORMATS.join(",");
|
|
36
40
|
const { saveFile, loadMedia, removeFile } = useSaveImageToIpfs();
|
|
37
41
|
|
|
38
|
-
const saveToIpfs = useCallback(
|
|
39
|
-
async (
|
|
40
|
-
if (!
|
|
42
|
+
const saveToIpfs: WithUploadToIpfsProps["saveToIpfs"] = useCallback(
|
|
43
|
+
async (filesArray: File[] | null) => {
|
|
44
|
+
if (!filesArray) {
|
|
41
45
|
return;
|
|
42
46
|
}
|
|
43
|
-
const { files } = e.target;
|
|
44
|
-
const filesArray = Object.values(files);
|
|
45
47
|
const filesErrors: string[] = [];
|
|
46
48
|
|
|
47
49
|
for (const file of filesArray) {
|
|
@@ -105,12 +107,12 @@ export function WithUploadToIpfs<P extends WithUploadToIpfsProps>(
|
|
|
105
107
|
const newProps = useMemo(
|
|
106
108
|
() => ({
|
|
107
109
|
maxSize: MAX_FILE_SIZE,
|
|
108
|
-
|
|
110
|
+
accept,
|
|
109
111
|
saveToIpfs,
|
|
110
112
|
loadMedia,
|
|
111
113
|
removeFile
|
|
112
114
|
}),
|
|
113
|
-
[saveToIpfs, loadMedia, removeFile]
|
|
115
|
+
[saveToIpfs, loadMedia, removeFile, accept]
|
|
114
116
|
);
|
|
115
117
|
|
|
116
118
|
if (withUpload) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { default as Checkbox } from "./Checkbox";
|
|
2
2
|
export { default as Datepicker } from "./Datepicker";
|
|
3
3
|
export { default as Error } from "./Error";
|
|
4
|
-
export {
|
|
4
|
+
export { FormField } from "./FormField";
|
|
5
5
|
export * from "./BaseInput";
|
|
6
6
|
export { default as Input, InputProps } from "./Input";
|
|
7
7
|
export { default as Phone } from "./Phone";
|
|
8
8
|
export { default as Select } from "./Select";
|
|
9
9
|
export * from "./BaseTagsInput";
|
|
10
|
-
export
|
|
10
|
+
export * from "./BaseTextArea";
|
|
11
11
|
export { default as Upload } from "./Upload/Upload";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
1
2
|
import { SingleValue } from "react-select";
|
|
3
|
+
import { CSSProperties } from "styled-components";
|
|
4
|
+
import { ImageEditorModalProps } from "./Upload/ImageEditorModal/ImageEditorModal";
|
|
5
|
+
import type { TextAreaTheme } from "./Field.styles";
|
|
2
6
|
|
|
3
7
|
export interface BaseProps {
|
|
4
8
|
name: string;
|
|
@@ -19,7 +23,7 @@ export interface CheckboxProps extends BaseProps {
|
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
export type TextareaProps = BaseProps &
|
|
22
|
-
React.TextareaHTMLAttributes<HTMLTextAreaElement
|
|
26
|
+
React.TextareaHTMLAttributes<HTMLTextAreaElement> & { theme?: TextAreaTheme };
|
|
23
27
|
|
|
24
28
|
export interface ErrorProps {
|
|
25
29
|
display?: boolean;
|
|
@@ -28,12 +32,13 @@ export interface ErrorProps {
|
|
|
28
32
|
|
|
29
33
|
export interface FormFieldProps {
|
|
30
34
|
title: string;
|
|
35
|
+
titleIcon?: ReactNode;
|
|
31
36
|
subTitle?: string | false;
|
|
32
37
|
required?: boolean;
|
|
33
38
|
tooltip?: string;
|
|
34
39
|
children: React.ReactNode | string;
|
|
35
40
|
style?: React.CSSProperties;
|
|
36
|
-
|
|
41
|
+
copyIconColor?: CSSProperties["backgroundColor"];
|
|
37
42
|
valueToCopy?:
|
|
38
43
|
| string
|
|
39
44
|
| {
|
|
@@ -86,7 +91,7 @@ export interface SelectProps extends BaseProps {
|
|
|
86
91
|
label?: string;
|
|
87
92
|
}
|
|
88
93
|
|
|
89
|
-
export
|
|
94
|
+
export type UploadProps = BaseProps & {
|
|
90
95
|
accept?: string;
|
|
91
96
|
multiple?: boolean;
|
|
92
97
|
trigger?: React.ReactNode | JSX.Element;
|
|
@@ -97,7 +102,18 @@ export interface UploadProps extends BaseProps {
|
|
|
97
102
|
onLoadSinglePreviewImage?: (base64Uri: string) => void;
|
|
98
103
|
withUpload?: boolean;
|
|
99
104
|
onLoading?: (loading: boolean) => void;
|
|
100
|
-
|
|
105
|
+
borderRadius?: number;
|
|
106
|
+
width?: number;
|
|
107
|
+
height?: number;
|
|
108
|
+
imgPreviewStyle?: Pick<CSSProperties, "objectFit">;
|
|
109
|
+
} & (
|
|
110
|
+
| {
|
|
111
|
+
withEditor: true;
|
|
112
|
+
saveButtonTheme: ImageEditorModalProps["saveButtonTheme"];
|
|
113
|
+
}
|
|
114
|
+
| { withEditor: false; saveButtonTheme: undefined }
|
|
115
|
+
);
|
|
116
|
+
|
|
101
117
|
export interface FileProps {
|
|
102
118
|
src: string;
|
|
103
119
|
name?: string; // for example: "redeemeum.png"
|
|
@@ -7,7 +7,7 @@ import remarkGfm from "remark-gfm";
|
|
|
7
7
|
import { useRenderTemplate } from "../../hooks/useRenderTemplate";
|
|
8
8
|
import { ProgressStatus } from "../../lib/progress/progressStatus";
|
|
9
9
|
import { useBosonContext } from "../boson/BosonProvider";
|
|
10
|
-
import SimpleError from "../error/SimpleError";
|
|
10
|
+
import { SimpleError } from "../error/SimpleError";
|
|
11
11
|
import Loading from "../ui/loading/LoadingWrapper";
|
|
12
12
|
|
|
13
13
|
interface Props {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ImageEditorModal } from "../form/Upload/ImageEditorModal/ImageEditorModal";
|
|
1
2
|
import { MODAL_TYPES } from "./ModalTypes";
|
|
2
3
|
import FinanceDeposit from "./components/SellerFinance/FinanceDeposit";
|
|
3
4
|
import FinanceWithdraw from "./components/SellerFinance/FinanceWithdraw";
|
|
@@ -10,5 +11,6 @@ export const MODAL_COMPONENTS = {
|
|
|
10
11
|
[MODAL_TYPES.FINANCE_WITHDRAW_MODAL]: FinanceWithdraw,
|
|
11
12
|
[MODAL_TYPES.TRANSACTION_FAILED]: TransactionFailedModal,
|
|
12
13
|
[MODAL_TYPES.TRANSACTION_SUBMITTED]: TransactionSubmittedModal,
|
|
13
|
-
[MODAL_TYPES.WAITING_FOR_CONFIRMATION]: WaitingForConfirmationModal
|
|
14
|
+
[MODAL_TYPES.WAITING_FOR_CONFIRMATION]: WaitingForConfirmationModal,
|
|
15
|
+
[MODAL_TYPES.IMAGE_EDITOR]: ImageEditorModal
|
|
14
16
|
} as const;
|
|
@@ -12,6 +12,7 @@ export type ModalProps = {
|
|
|
12
12
|
contentStyle?: CSSProperties;
|
|
13
13
|
closable?: boolean;
|
|
14
14
|
onClose?: (data: unknown | undefined | null) => void;
|
|
15
|
+
hidden?: boolean;
|
|
15
16
|
};
|
|
16
17
|
export type ModalType = keyof typeof MODAL_TYPES | null;
|
|
17
18
|
type ModalSize = "xxs" | "xs" | "s" | "m" | "l" | "xl";
|
|
@@ -25,9 +26,9 @@ export type Store = {
|
|
|
25
26
|
theme?: "light" | "dark";
|
|
26
27
|
};
|
|
27
28
|
export type GenericModalProps<T extends keyof typeof MODAL_TYPES> =
|
|
28
|
-
Parameters<(typeof MODAL_COMPONENTS)[T]>
|
|
29
|
-
? ModalProps &
|
|
30
|
-
: ModalProps
|
|
29
|
+
Parameters<(typeof MODAL_COMPONENTS)[T]> extends [infer P, ...any[]]
|
|
30
|
+
? ModalProps & P
|
|
31
|
+
: ModalProps;
|
|
31
32
|
|
|
32
33
|
export interface ModalContextType {
|
|
33
34
|
showModal: <T extends keyof typeof MODAL_TYPES>(
|
|
@@ -3,5 +3,6 @@ export const MODAL_TYPES = {
|
|
|
3
3
|
FINANCE_WITHDRAW_MODAL: "FINANCE_WITHDRAW_MODAL",
|
|
4
4
|
TRANSACTION_FAILED: "TRANSACTION_FAILED",
|
|
5
5
|
TRANSACTION_SUBMITTED: "TRANSACTION_SUBMITTED",
|
|
6
|
-
WAITING_FOR_CONFIRMATION: "WAITING_FOR_CONFIRMATION"
|
|
6
|
+
WAITING_FOR_CONFIRMATION: "WAITING_FOR_CONFIRMATION",
|
|
7
|
+
IMAGE_EDITOR: "IMAGE_EDITOR"
|
|
7
8
|
} as const;
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
IRedeemButton
|
|
25
25
|
} from "../../../../cta/exchange/RedeemButton";
|
|
26
26
|
import { useEnvContext } from "../../../../environment/EnvironmentContext";
|
|
27
|
-
import SimpleError from "../../../../error/SimpleError";
|
|
27
|
+
import { SimpleError } from "../../../../error/SimpleError";
|
|
28
28
|
import SuccessTransactionToast from "../../../../toasts/SuccessTransactionToast";
|
|
29
29
|
import { Grid } from "../../../../ui/Grid";
|
|
30
30
|
import { Spinner } from "../../../../ui/loading/Spinner";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
ICancelButton
|
|
19
19
|
} from "../../../../../cta/exchange/CancelButton";
|
|
20
20
|
import { useEnvContext } from "../../../../../environment/EnvironmentContext";
|
|
21
|
-
import SimpleError from "../../../../../error/SimpleError";
|
|
21
|
+
import { SimpleError } from "../../../../../error/SimpleError";
|
|
22
22
|
import SuccessTransactionToast from "../../../../../toasts/SuccessTransactionToast";
|
|
23
23
|
import { Grid } from "../../../../../ui/Grid";
|
|
24
24
|
import ThemedButton from "../../../../../ui/ThemedButton";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
IExpireButton
|
|
17
17
|
} from "../../../../../cta/exchange/ExpireButton";
|
|
18
18
|
import { useEnvContext } from "../../../../../environment/EnvironmentContext";
|
|
19
|
-
import SimpleError from "../../../../../error/SimpleError";
|
|
19
|
+
import { SimpleError } from "../../../../../error/SimpleError";
|
|
20
20
|
import { Grid } from "../../../../../ui/Grid";
|
|
21
21
|
import ThemedButton from "../../../../../ui/ThemedButton";
|
|
22
22
|
import { Typography } from "../../../../../ui/Typography";
|
|
@@ -12,7 +12,7 @@ import { isNumeric } from "../../../../lib/numbers/numbers";
|
|
|
12
12
|
import { theme } from "../../../../theme";
|
|
13
13
|
import { isTruthy } from "../../../../types/helpers";
|
|
14
14
|
import { VariantV1, Variation } from "../../../../types/variants";
|
|
15
|
-
import SimpleError from "../../../error/SimpleError";
|
|
15
|
+
import { SimpleError } from "../../../error/SimpleError";
|
|
16
16
|
import { Select } from "../../../form";
|
|
17
17
|
import { SelectDataProps } from "../../../form/types";
|
|
18
18
|
import { Grid } from "../../../ui/Grid";
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { ArrowLeft, ArrowRight } from "phosphor-react";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { Grid } from "../ui/Grid";
|
|
5
|
+
import { Step, StepColorProps, StepState } from "./Step";
|
|
6
|
+
import { MultiStepStyle, MultiStepWrapper, StepWrapper } from "./Step.styles";
|
|
7
|
+
import { useBreakpoints } from "../../hooks/useBreakpoints";
|
|
8
|
+
import { CSSProperties } from "styled-components";
|
|
9
|
+
import { theme } from "../../theme";
|
|
10
|
+
const colors = theme.colors.light;
|
|
11
|
+
type StepData = {
|
|
12
|
+
name?: string;
|
|
13
|
+
steps: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type MultiStepsProps = {
|
|
17
|
+
disableInactiveSteps?: boolean;
|
|
18
|
+
active?: number;
|
|
19
|
+
data: Array<StepData> | Readonly<Array<StepData>>;
|
|
20
|
+
callback?: (cur: number) => void;
|
|
21
|
+
isRightArrowEnabled?: boolean;
|
|
22
|
+
enabledArrowColor?: CSSProperties["color"];
|
|
23
|
+
disabledArrowColor?: CSSProperties["color"];
|
|
24
|
+
hideArrows?: boolean;
|
|
25
|
+
} & StepColorProps;
|
|
26
|
+
const dataStepsWrapper = "data-steps-wrapper";
|
|
27
|
+
export function MultiSteps({
|
|
28
|
+
data,
|
|
29
|
+
active,
|
|
30
|
+
callback,
|
|
31
|
+
disableInactiveSteps = false,
|
|
32
|
+
isRightArrowEnabled = false,
|
|
33
|
+
hideArrows = false,
|
|
34
|
+
enabledArrowColor = colors.darkGrey,
|
|
35
|
+
disabledArrowColor = colors.lightArrowColor,
|
|
36
|
+
stepInactiveDotColor = "#d3d5db",
|
|
37
|
+
stepInactiveBackgroundColor = colors.white,
|
|
38
|
+
stepInactiveHoverDotColor = colors.darkGrey,
|
|
39
|
+
stepInactiveHoverBackgroundColor = colors.lightGrey,
|
|
40
|
+
stepActiveBackgroundColor = colors.black,
|
|
41
|
+
stepActiveDotsColor = colors.green, // TODO: var(--primary) in boson Dapp
|
|
42
|
+
stepDoneBackgroundColor = colors.green, // TODO: var(--primary) in boson Dapp
|
|
43
|
+
stepDoneCheckColor = colors.black,
|
|
44
|
+
stepDoneHoverBackgroundColor = colors.black,
|
|
45
|
+
stepDoneHoverCheckColor = colors.green, // TODO: var(--primary) in boson Dapp
|
|
46
|
+
...props
|
|
47
|
+
}: MultiStepsProps) {
|
|
48
|
+
const [current, setCurrent] = useState<number>(active || 0);
|
|
49
|
+
const { isLteS } = useBreakpoints();
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
setCurrent(active || 0);
|
|
53
|
+
}, [active]);
|
|
54
|
+
const stepWidthRef = useRef<number>(50);
|
|
55
|
+
return (
|
|
56
|
+
<Grid
|
|
57
|
+
justifyContent="space-evenly"
|
|
58
|
+
ref={(element) => {
|
|
59
|
+
const children = element?.querySelectorAll(`[${dataStepsWrapper}] > *`);
|
|
60
|
+
children?.forEach((child) => {
|
|
61
|
+
const isVisible = child.checkVisibility({ checkVisibilityCSS: true });
|
|
62
|
+
if (isVisible) {
|
|
63
|
+
if (
|
|
64
|
+
child.clientWidth &&
|
|
65
|
+
stepWidthRef.current !== child.clientWidth
|
|
66
|
+
) {
|
|
67
|
+
stepWidthRef.current = child.clientWidth;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{isLteS && !hideArrows && (
|
|
74
|
+
<Grid alignItems="center" width="auto">
|
|
75
|
+
<ArrowLeft
|
|
76
|
+
size={32}
|
|
77
|
+
style={{ cursor: active && callback ? "pointer" : "not-allowed" }}
|
|
78
|
+
color={active === 0 ? disabledArrowColor : enabledArrowColor}
|
|
79
|
+
onClick={() => {
|
|
80
|
+
if (active && callback) {
|
|
81
|
+
callback(active - 1);
|
|
82
|
+
}
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
</Grid>
|
|
86
|
+
)}
|
|
87
|
+
<div
|
|
88
|
+
style={{
|
|
89
|
+
width: `${stepWidthRef.current}px`
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
<MultiStepStyle
|
|
93
|
+
{...props}
|
|
94
|
+
{...{ [dataStepsWrapper]: true }}
|
|
95
|
+
$isLteS={isLteS}
|
|
96
|
+
>
|
|
97
|
+
{data.map((el, i) => {
|
|
98
|
+
const steps = Array.from(Array(el.steps).keys());
|
|
99
|
+
const newData = data.slice(0, i);
|
|
100
|
+
const previousLength = newData.reduce(
|
|
101
|
+
(acc, cur) => (acc += cur.steps),
|
|
102
|
+
0
|
|
103
|
+
);
|
|
104
|
+
if (
|
|
105
|
+
(isLteS &&
|
|
106
|
+
current >= previousLength &&
|
|
107
|
+
current <= previousLength + steps.length) ||
|
|
108
|
+
!isLteS
|
|
109
|
+
) {
|
|
110
|
+
return (
|
|
111
|
+
<MultiStepWrapper $isLteS={isLteS} key={`multi_${i}`}>
|
|
112
|
+
<StepWrapper>
|
|
113
|
+
{steps.map((_: number, key: number) => {
|
|
114
|
+
const currentKey = previousLength + key;
|
|
115
|
+
const state =
|
|
116
|
+
currentKey === current
|
|
117
|
+
? StepState.Active
|
|
118
|
+
: currentKey < current
|
|
119
|
+
? StepState.Done
|
|
120
|
+
: StepState.Inactive;
|
|
121
|
+
|
|
122
|
+
const isStepDisabled =
|
|
123
|
+
!callback ||
|
|
124
|
+
(disableInactiveSteps && StepState.Inactive === state);
|
|
125
|
+
|
|
126
|
+
if ((isLteS && active === currentKey) || !isLteS) {
|
|
127
|
+
return (
|
|
128
|
+
<Step
|
|
129
|
+
disabled={isStepDisabled}
|
|
130
|
+
state={state}
|
|
131
|
+
onClick={() => {
|
|
132
|
+
if (!isStepDisabled) {
|
|
133
|
+
setCurrent(currentKey);
|
|
134
|
+
callback(currentKey);
|
|
135
|
+
}
|
|
136
|
+
}}
|
|
137
|
+
key={`multi-step_${currentKey}`}
|
|
138
|
+
stepInactiveDotColor={stepInactiveDotColor}
|
|
139
|
+
stepInactiveBackgroundColor={
|
|
140
|
+
stepInactiveBackgroundColor
|
|
141
|
+
}
|
|
142
|
+
stepInactiveHoverDotColor={stepInactiveHoverDotColor}
|
|
143
|
+
stepInactiveHoverBackgroundColor={
|
|
144
|
+
stepInactiveHoverBackgroundColor
|
|
145
|
+
}
|
|
146
|
+
stepActiveBackgroundColor={stepActiveBackgroundColor}
|
|
147
|
+
stepActiveDotsColor={stepActiveDotsColor}
|
|
148
|
+
stepDoneBackgroundColor={stepDoneBackgroundColor}
|
|
149
|
+
stepDoneCheckColor={stepDoneCheckColor}
|
|
150
|
+
stepDoneHoverBackgroundColor={
|
|
151
|
+
stepDoneHoverBackgroundColor
|
|
152
|
+
}
|
|
153
|
+
stepDoneHoverCheckColor={stepDoneHoverCheckColor}
|
|
154
|
+
/>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
})}
|
|
159
|
+
</StepWrapper>
|
|
160
|
+
<p>{el.name}</p>
|
|
161
|
+
</MultiStepWrapper>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
})}
|
|
166
|
+
</MultiStepStyle>
|
|
167
|
+
{isLteS && !hideArrows && (
|
|
168
|
+
<Grid alignItems="flex-end" width="auto">
|
|
169
|
+
<ArrowRight
|
|
170
|
+
size={32}
|
|
171
|
+
color={isRightArrowEnabled ? enabledArrowColor : disabledArrowColor}
|
|
172
|
+
style={{ cursor: isRightArrowEnabled ? "pointer" : "not-allowed" }}
|
|
173
|
+
onClick={() => {
|
|
174
|
+
if (
|
|
175
|
+
isRightArrowEnabled &&
|
|
176
|
+
typeof active === "number" &&
|
|
177
|
+
callback
|
|
178
|
+
) {
|
|
179
|
+
callback(active + 1);
|
|
180
|
+
}
|
|
181
|
+
}}
|
|
182
|
+
/>
|
|
183
|
+
</Grid>
|
|
184
|
+
)}
|
|
185
|
+
</Grid>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import styled, { CSSProperties, css } from "styled-components";
|
|
2
|
+
|
|
3
|
+
import { transition } from "../../components/ui/styles";
|
|
4
|
+
import { StepState } from "./Step";
|
|
5
|
+
import { theme } from "../../theme";
|
|
6
|
+
const colors = theme.colors.light;
|
|
7
|
+
type StepColorProps = {
|
|
8
|
+
$stepInactiveDotColor?: CSSProperties["color"];
|
|
9
|
+
$stepInactiveBackgroundColor?: CSSProperties["color"];
|
|
10
|
+
$stepInactiveHoverDotColor?: CSSProperties["color"];
|
|
11
|
+
$stepInactiveHoverBackgroundColor?: CSSProperties["color"];
|
|
12
|
+
$stepActiveBackgroundColor?: CSSProperties["color"];
|
|
13
|
+
$stepActiveDotsColor?: CSSProperties["color"];
|
|
14
|
+
$stepDoneBackgroundColor?: CSSProperties["color"];
|
|
15
|
+
$stepDoneCheckColor?: CSSProperties["color"];
|
|
16
|
+
$stepDoneHoverBackgroundColor?: CSSProperties["color"];
|
|
17
|
+
$stepDoneHoverCheckColor?: CSSProperties["color"];
|
|
18
|
+
};
|
|
19
|
+
export const StepStyle = styled.div<
|
|
20
|
+
{
|
|
21
|
+
$state: StepState;
|
|
22
|
+
disabled: boolean;
|
|
23
|
+
$isLteS?: boolean;
|
|
24
|
+
} & StepColorProps
|
|
25
|
+
>`
|
|
26
|
+
position: relative;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
align-items: center;
|
|
31
|
+
flex-grow: 1;
|
|
32
|
+
|
|
33
|
+
min-width: 6rem;
|
|
34
|
+
height: 1.25rem;
|
|
35
|
+
${({ $state, disabled }) =>
|
|
36
|
+
$state !== StepState.Active &&
|
|
37
|
+
!disabled &&
|
|
38
|
+
css`
|
|
39
|
+
&:hover {
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
}
|
|
42
|
+
`}
|
|
43
|
+
|
|
44
|
+
${({
|
|
45
|
+
$state,
|
|
46
|
+
disabled,
|
|
47
|
+
$stepInactiveBackgroundColor,
|
|
48
|
+
$stepInactiveDotColor,
|
|
49
|
+
$stepInactiveHoverBackgroundColor,
|
|
50
|
+
$stepInactiveHoverDotColor
|
|
51
|
+
}) =>
|
|
52
|
+
$state === StepState.Inactive &&
|
|
53
|
+
css`
|
|
54
|
+
background: ${$stepInactiveBackgroundColor};
|
|
55
|
+
${transition}
|
|
56
|
+
|
|
57
|
+
&:before {
|
|
58
|
+
content: "";
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 50%;
|
|
61
|
+
left: 50%;
|
|
62
|
+
transform: translate(-50%, -50%);
|
|
63
|
+
border-radius: 50%;
|
|
64
|
+
background: ${$stepInactiveDotColor};
|
|
65
|
+
|
|
66
|
+
${transition}
|
|
67
|
+
|
|
68
|
+
width: 0.25rem;
|
|
69
|
+
height: 0.25rem;
|
|
70
|
+
}
|
|
71
|
+
${!disabled &&
|
|
72
|
+
css`
|
|
73
|
+
&:hover {
|
|
74
|
+
background: ${$stepInactiveHoverBackgroundColor};
|
|
75
|
+
&:before {
|
|
76
|
+
background: ${$stepInactiveHoverDotColor};
|
|
77
|
+
width: 0.5rem;
|
|
78
|
+
height: 0.5rem;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`}
|
|
82
|
+
|
|
83
|
+
> div {
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
86
|
+
`}
|
|
87
|
+
|
|
88
|
+
${({ $state, $stepActiveBackgroundColor, $stepActiveDotsColor }) =>
|
|
89
|
+
$state === StepState.Active &&
|
|
90
|
+
css`
|
|
91
|
+
background: ${$stepActiveBackgroundColor};
|
|
92
|
+
|
|
93
|
+
&:before {
|
|
94
|
+
margin-left: -0.75rem;
|
|
95
|
+
}
|
|
96
|
+
&:after {
|
|
97
|
+
margin-left: 0.75rem;
|
|
98
|
+
}
|
|
99
|
+
> div,
|
|
100
|
+
&:before,
|
|
101
|
+
&:after {
|
|
102
|
+
content: "";
|
|
103
|
+
position: absolute;
|
|
104
|
+
top: 50%;
|
|
105
|
+
left: 50%;
|
|
106
|
+
transform: translate(-50%, -50%);
|
|
107
|
+
${transition}
|
|
108
|
+
width: 0.25rem;
|
|
109
|
+
height: 0.25rem;
|
|
110
|
+
border-radius: 50%;
|
|
111
|
+
background: ${$stepActiveDotsColor};
|
|
112
|
+
}
|
|
113
|
+
`}
|
|
114
|
+
|
|
115
|
+
${({
|
|
116
|
+
$state,
|
|
117
|
+
disabled,
|
|
118
|
+
$stepDoneBackgroundColor,
|
|
119
|
+
$stepDoneCheckColor,
|
|
120
|
+
$stepDoneHoverBackgroundColor,
|
|
121
|
+
$stepDoneHoverCheckColor
|
|
122
|
+
}) =>
|
|
123
|
+
$state === StepState.Done &&
|
|
124
|
+
css`
|
|
125
|
+
background: ${$stepDoneBackgroundColor};
|
|
126
|
+
|
|
127
|
+
&:before,
|
|
128
|
+
&:after {
|
|
129
|
+
content: "";
|
|
130
|
+
position: absolute;
|
|
131
|
+
top: 50%;
|
|
132
|
+
left: 50%;
|
|
133
|
+
${transition}
|
|
134
|
+
background: ${$stepDoneCheckColor};
|
|
135
|
+
}
|
|
136
|
+
&:before {
|
|
137
|
+
width: 0.35rem;
|
|
138
|
+
height: 0.125rem;
|
|
139
|
+
transform: translate(calc(-50% - 0.35rem), calc(-50% + 0.15rem))
|
|
140
|
+
rotate(-135deg);
|
|
141
|
+
}
|
|
142
|
+
&:after {
|
|
143
|
+
width: 0.75rem;
|
|
144
|
+
height: 0.125rem;
|
|
145
|
+
transform: translate(-50%, -50%) rotate(-45deg);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
> div {
|
|
149
|
+
display: none;
|
|
150
|
+
}
|
|
151
|
+
${!disabled &&
|
|
152
|
+
css`
|
|
153
|
+
&:hover {
|
|
154
|
+
background: ${$stepDoneHoverBackgroundColor};
|
|
155
|
+
&:before,
|
|
156
|
+
&:after {
|
|
157
|
+
background: ${$stepDoneHoverCheckColor};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
`}
|
|
161
|
+
`}
|
|
162
|
+
`;
|
|
163
|
+
|
|
164
|
+
export const MultiStepStyle = styled.div<{ $isLteS: boolean }>`
|
|
165
|
+
display: flex;
|
|
166
|
+
gap: 1rem;
|
|
167
|
+
flex-direction: row;
|
|
168
|
+
flex-wrap: nowrap;
|
|
169
|
+
justify-content: flex-start;
|
|
170
|
+
width: 100%;
|
|
171
|
+
align-items: center;
|
|
172
|
+
div div {
|
|
173
|
+
display: ${({ $isLteS }) => $isLteS && "none"};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
p {
|
|
177
|
+
text-align: center;
|
|
178
|
+
margin: 0;
|
|
179
|
+
font-weight: 600;
|
|
180
|
+
font-size: 0.75rem;
|
|
181
|
+
line-height: 1.5;
|
|
182
|
+
color: ${colors.darkGrey};
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
export const MultiStepWrapper = styled.div<{ $isLteS: boolean }>`
|
|
187
|
+
display: flex;
|
|
188
|
+
flex-grow: 1;
|
|
189
|
+
flex-direction: column;
|
|
190
|
+
position: ${({ $isLteS }) => $isLteS && "absolute"};
|
|
191
|
+
left: ${({ $isLteS }) => $isLteS && "50%"};
|
|
192
|
+
transform: ${({ $isLteS }) => $isLteS && "translate(-50%, 0)"};
|
|
193
|
+
`;
|
|
194
|
+
|
|
195
|
+
export const StepWrapper = styled.div`
|
|
196
|
+
display: flex;
|
|
197
|
+
gap: 0;
|
|
198
|
+
flex-grow: 1;
|
|
199
|
+
|
|
200
|
+
flex-direction: row;
|
|
201
|
+
flex-wrap: nowrap;
|
|
202
|
+
border: 1px solid ${colors.border};
|
|
203
|
+
&:empty + p {
|
|
204
|
+
display: none;
|
|
205
|
+
}
|
|
206
|
+
&:empty {
|
|
207
|
+
display: none;
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { CSSProperties } from "styled-components";
|
|
2
|
+
import { StepStyle } from "./Step.styles";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
export enum StepState {
|
|
6
|
+
Inactive = "inactive",
|
|
7
|
+
Active = "active",
|
|
8
|
+
Done = "done"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type StepColorProps = {
|
|
12
|
+
stepInactiveDotColor?: CSSProperties["color"];
|
|
13
|
+
stepInactiveBackgroundColor?: CSSProperties["color"];
|
|
14
|
+
stepInactiveHoverDotColor?: CSSProperties["color"];
|
|
15
|
+
stepInactiveHoverBackgroundColor?: CSSProperties["color"];
|
|
16
|
+
stepActiveBackgroundColor?: CSSProperties["color"];
|
|
17
|
+
stepActiveDotsColor?: CSSProperties["color"];
|
|
18
|
+
stepDoneBackgroundColor?: CSSProperties["color"];
|
|
19
|
+
stepDoneCheckColor?: CSSProperties["color"];
|
|
20
|
+
stepDoneHoverBackgroundColor?: CSSProperties["color"];
|
|
21
|
+
stepDoneHoverCheckColor?: CSSProperties["color"];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type StepProps = StepColorProps & {
|
|
25
|
+
className?: string;
|
|
26
|
+
onClick?: () => void;
|
|
27
|
+
state?: StepState;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function Step({
|
|
32
|
+
state = StepState.Inactive,
|
|
33
|
+
className,
|
|
34
|
+
disabled,
|
|
35
|
+
onClick,
|
|
36
|
+
stepInactiveDotColor,
|
|
37
|
+
stepInactiveBackgroundColor,
|
|
38
|
+
stepInactiveHoverDotColor,
|
|
39
|
+
stepInactiveHoverBackgroundColor,
|
|
40
|
+
stepActiveBackgroundColor,
|
|
41
|
+
stepActiveDotsColor,
|
|
42
|
+
stepDoneBackgroundColor,
|
|
43
|
+
stepDoneCheckColor,
|
|
44
|
+
stepDoneHoverBackgroundColor,
|
|
45
|
+
stepDoneHoverCheckColor,
|
|
46
|
+
...props
|
|
47
|
+
}: StepProps) {
|
|
48
|
+
return (
|
|
49
|
+
<StepStyle
|
|
50
|
+
$state={state}
|
|
51
|
+
{...props}
|
|
52
|
+
$stepInactiveDotColor={stepInactiveDotColor}
|
|
53
|
+
$stepInactiveBackgroundColor={stepInactiveBackgroundColor}
|
|
54
|
+
$stepInactiveHoverDotColor={stepInactiveHoverDotColor}
|
|
55
|
+
$stepInactiveHoverBackgroundColor={stepInactiveHoverBackgroundColor}
|
|
56
|
+
$stepActiveBackgroundColor={stepActiveBackgroundColor}
|
|
57
|
+
$stepActiveDotsColor={stepActiveDotsColor}
|
|
58
|
+
$stepDoneBackgroundColor={stepDoneBackgroundColor}
|
|
59
|
+
$stepDoneCheckColor={stepDoneCheckColor}
|
|
60
|
+
$stepDoneHoverBackgroundColor={stepDoneHoverBackgroundColor}
|
|
61
|
+
$stepDoneHoverCheckColor={stepDoneHoverCheckColor}
|
|
62
|
+
disabled={!!disabled}
|
|
63
|
+
>
|
|
64
|
+
<div />
|
|
65
|
+
</StepStyle>
|
|
66
|
+
);
|
|
67
|
+
}
|