@bosonprotocol/react-kit 0.32.0-alpha.9 → 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/error/SimpleError.d.ts +7 -5
- package/dist/cjs/components/error/SimpleError.d.ts.map +1 -1
- package/dist/cjs/components/error/SimpleError.js +4 -4
- package/dist/cjs/components/error/SimpleError.js.map +1 -1
- package/dist/cjs/components/form/Field.styles.d.ts +0 -1
- package/dist/cjs/components/form/Field.styles.d.ts.map +1 -1
- 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 +1 -1
- package/dist/cjs/components/form/index.d.ts.map +1 -1
- package/dist/cjs/components/form/index.js +1 -1
- package/dist/cjs/components/form/index.js.map +1 -1
- package/dist/cjs/components/form/types.d.ts +17 -4
- package/dist/cjs/components/form/types.d.ts.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/useModal.d.ts +3 -2
- package/dist/cjs/components/modal/useModal.d.ts.map +1 -1
- 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/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/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/Field.styles.d.ts +0 -1
- package/dist/esm/components/form/Field.styles.d.ts.map +1 -1
- 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 +1 -1
- package/dist/esm/components/form/index.d.ts.map +1 -1
- package/dist/esm/components/form/index.js +1 -1
- package/dist/esm/components/form/index.js.map +1 -1
- package/dist/esm/components/form/types.d.ts +17 -4
- package/dist/esm/components/form/types.d.ts.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/useModal.d.ts +3 -2
- package/dist/esm/components/modal/useModal.d.ts.map +1 -1
- 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/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/error/SimpleError.tsx +19 -10
- package/src/components/form/Field.styles.ts +1 -1
- 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 +1 -1
- package/src/components/form/types.ts +18 -3
- 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/hooks/images/useFileImage.ts +24 -0
- package/src/hooks/images/useIpfsImage.ts +27 -0
- package/src/lib/base64/base64.ts +1 -1
- package/src/stories/buttons/Upload.stories.tsx +82 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
import { SingleValue } from "react-select";
|
|
3
|
+
import { CSSProperties } from "styled-components";
|
|
4
|
+
import { ImageEditorModalProps } from "./Upload/ImageEditorModal/ImageEditorModal";
|
|
3
5
|
import type { TextAreaTheme } from "./Field.styles";
|
|
4
6
|
export interface BaseProps {
|
|
5
7
|
name: string;
|
|
@@ -25,12 +27,13 @@ export interface ErrorProps {
|
|
|
25
27
|
}
|
|
26
28
|
export interface FormFieldProps {
|
|
27
29
|
title: string;
|
|
30
|
+
titleIcon?: ReactNode;
|
|
28
31
|
subTitle?: string | false;
|
|
29
32
|
required?: boolean;
|
|
30
33
|
tooltip?: string;
|
|
31
34
|
children: React.ReactNode | string;
|
|
32
35
|
style?: React.CSSProperties;
|
|
33
|
-
|
|
36
|
+
copyIconColor?: CSSProperties["backgroundColor"];
|
|
34
37
|
valueToCopy?: string | {
|
|
35
38
|
[key: string]: unknown;
|
|
36
39
|
};
|
|
@@ -70,7 +73,7 @@ export interface SelectProps extends BaseProps {
|
|
|
70
73
|
onChange?: (option: SelectDataProps<string>) => void;
|
|
71
74
|
label?: string;
|
|
72
75
|
}
|
|
73
|
-
export
|
|
76
|
+
export type UploadProps = BaseProps & {
|
|
74
77
|
accept?: string;
|
|
75
78
|
multiple?: boolean;
|
|
76
79
|
trigger?: React.ReactNode | JSX.Element;
|
|
@@ -81,7 +84,17 @@ export interface UploadProps extends BaseProps {
|
|
|
81
84
|
onLoadSinglePreviewImage?: (base64Uri: string) => void;
|
|
82
85
|
withUpload?: boolean;
|
|
83
86
|
onLoading?: (loading: boolean) => void;
|
|
84
|
-
|
|
87
|
+
borderRadius?: number;
|
|
88
|
+
width?: number;
|
|
89
|
+
height?: number;
|
|
90
|
+
imgPreviewStyle?: Pick<CSSProperties, "objectFit">;
|
|
91
|
+
} & ({
|
|
92
|
+
withEditor: true;
|
|
93
|
+
saveButtonTheme: ImageEditorModalProps["saveButtonTheme"];
|
|
94
|
+
} | {
|
|
95
|
+
withEditor: false;
|
|
96
|
+
saveButtonTheme: undefined;
|
|
97
|
+
});
|
|
85
98
|
export interface FileProps {
|
|
86
99
|
src: string;
|
|
87
100
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/form/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/form/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,IA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ceWithdraw from "./components/SellerFinance/FinanceWithdraw";
|
|
3
4
|
import TransactionFailedModal from "./components/Transactions/TransactionFailedModal/TransactionFailedModal";
|
|
@@ -9,5 +10,6 @@ export declare const MODAL_COMPONENTS: {
|
|
|
9
10
|
readonly TRANSACTION_FAILED: typeof TransactionFailedModal;
|
|
10
11
|
readonly TRANSACTION_SUBMITTED: typeof TransactionSubmittedModal;
|
|
11
12
|
readonly WAITING_FOR_CONFIRMATION: typeof WaitingForConfirmationModal;
|
|
13
|
+
readonly IMAGE_EDITOR: import("react").FC<import("../form/Upload/ImageEditorModal/ImageEditorModal").ImageEditorModalProps>;
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=ModalComponents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalComponents.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/ModalComponents.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ModalComponents.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/ModalComponents.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,MAAM,2CAA2C,CAAC;AACvE,OAAO,eAAe,MAAM,4CAA4C,CAAC;AACzE,OAAO,sBAAsB,MAAM,yEAAyE,CAAC;AAC7G,OAAO,yBAAyB,MAAM,+EAA+E,CAAC;AACtH,OAAO,2BAA2B,MAAM,mFAAmF,CAAC;AAE5H,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC"}
|
|
@@ -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";
|
|
@@ -9,6 +10,7 @@ export const MODAL_COMPONENTS = {
|
|
|
9
10
|
[MODAL_TYPES.FINANCE_WITHDRAW_MODAL]: FinanceWithdraw,
|
|
10
11
|
[MODAL_TYPES.TRANSACTION_FAILED]: TransactionFailedModal,
|
|
11
12
|
[MODAL_TYPES.TRANSACTION_SUBMITTED]: TransactionSubmittedModal,
|
|
12
|
-
[MODAL_TYPES.WAITING_FOR_CONFIRMATION]: WaitingForConfirmationModal
|
|
13
|
+
[MODAL_TYPES.WAITING_FOR_CONFIRMATION]: WaitingForConfirmationModal,
|
|
14
|
+
[MODAL_TYPES.IMAGE_EDITOR]: ImageEditorModal
|
|
13
15
|
};
|
|
14
16
|
//# sourceMappingURL=ModalComponents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalComponents.js","sourceRoot":"","sources":["../../../../src/components/modal/ModalComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,cAAc,MAAM,2CAA2C,CAAC;AACvE,OAAO,eAAe,MAAM,4CAA4C,CAAC;AACzE,OAAO,sBAAsB,MAAM,yEAAyE,CAAC;AAC7G,OAAO,yBAAyB,MAAM,+EAA+E,CAAC;AACtH,OAAO,2BAA2B,MAAM,mFAAmF,CAAC;AAE5H,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,CAAC,WAAW,CAAC,qBAAqB,CAAC,EAAE,cAAc;IACnD,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,eAAe;IACrD,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,sBAAsB;IACxD,CAAC,WAAW,CAAC,qBAAqB,CAAC,EAAE,yBAAyB;IAC9D,CAAC,WAAW,CAAC,wBAAwB,CAAC,EAAE,2BAA2B;
|
|
1
|
+
{"version":3,"file":"ModalComponents.js","sourceRoot":"","sources":["../../../../src/components/modal/ModalComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,cAAc,MAAM,2CAA2C,CAAC;AACvE,OAAO,eAAe,MAAM,4CAA4C,CAAC;AACzE,OAAO,sBAAsB,MAAM,yEAAyE,CAAC;AAC7G,OAAO,yBAAyB,MAAM,+EAA+E,CAAC;AACtH,OAAO,2BAA2B,MAAM,mFAAmF,CAAC;AAE5H,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,CAAC,WAAW,CAAC,qBAAqB,CAAC,EAAE,cAAc;IACnD,CAAC,WAAW,CAAC,sBAAsB,CAAC,EAAE,eAAe;IACrD,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,sBAAsB;IACxD,CAAC,WAAW,CAAC,qBAAqB,CAAC,EAAE,yBAAyB;IAC9D,CAAC,WAAW,CAAC,wBAAwB,CAAC,EAAE,2BAA2B;IACnE,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,gBAAgB;CACpC,CAAC"}
|
|
@@ -8,6 +8,7 @@ export type ModalProps = {
|
|
|
8
8
|
contentStyle?: CSSProperties;
|
|
9
9
|
closable?: boolean;
|
|
10
10
|
onClose?: (data: unknown | undefined | null) => void;
|
|
11
|
+
hidden?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export type ModalType = keyof typeof MODAL_TYPES | null;
|
|
13
14
|
type ModalSize = "xxs" | "xs" | "s" | "m" | "l" | "xl";
|
|
@@ -18,7 +19,7 @@ export type Store = {
|
|
|
18
19
|
modalMaxWidth?: Partial<Record<ModalSize, React.CSSProperties["maxWidth"]>> | null;
|
|
19
20
|
theme?: "light" | "dark";
|
|
20
21
|
};
|
|
21
|
-
export type GenericModalProps<T extends keyof typeof MODAL_TYPES> = Parameters<(typeof MODAL_COMPONENTS)[T]>
|
|
22
|
+
export type GenericModalProps<T extends keyof typeof MODAL_TYPES> = Parameters<(typeof MODAL_COMPONENTS)[T]> extends [infer P, ...any[]] ? ModalProps & P : ModalProps;
|
|
22
23
|
export interface ModalContextType {
|
|
23
24
|
showModal: <T extends keyof typeof MODAL_TYPES>(modalType: T, modalProps?: GenericModalProps<T>, modalSize?: Store["modalSize"], theme?: Store["theme"], modalMaxWidth?: Store["modalMaxWidth"]) => void;
|
|
24
25
|
hideModal: (data?: unknown | undefined | null) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContext.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/ModalContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAiB,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ModalContext.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/ModalContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAiB,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE,O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AAe,CAAC,KACnC,IAAI,CAAC;IACV,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAEvD,WAAW,EAAE,CAAC,CAAC,SAAS,MAAM,OAAO,WAAW,EAC9C,KAAK,EAAE,KAAK,GAAG;QACb,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;QACjC,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;QAC/B,aAAa,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QACvC,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;KACxB,KACE,IAAI,CAAC;IAEV,KAAK,EAAE,KAAK,CAAC;CACd;AAED,eAAO,MAAM,WAAW,EAAE,gBAWzB,CAAC;AAEF,QAAA,MAAM,YAAY,iCAAiD,CAAC;AAEpE,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContext.js","sourceRoot":"","sources":["../../../../src/components/modal/ModalContext.tsx"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,sDAAsD;AACtD,OAAc,EAAE,aAAa,EAA4B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ModalContext.js","sourceRoot":"","sources":["../../../../src/components/modal/ModalContext.tsx"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,sDAAsD;AACtD,OAAc,EAAE,aAAa,EAA4B,MAAM,OAAO,CAAC;AAoDvE,MAAM,CAAC,MAAM,WAAW,GAAqB;IAC3C,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;IACnB,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC;IACnB,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,KAAK,EAAE;QACL,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,EAAS;QACrB,SAAS,EAAE,GAAG;QACd,aAAa,EAAE,IAAI;QACnB,KAAK,EAAE,OAAO;KACN;CACX,CAAC;AAEF,MAAM,YAAY,GAAG,aAAa,CAAC,WAA+B,CAAC,CAAC;AAEpE,eAAe,YAAY,CAAC"}
|
|
@@ -4,5 +4,6 @@ export declare const MODAL_TYPES: {
|
|
|
4
4
|
readonly TRANSACTION_FAILED: "TRANSACTION_FAILED";
|
|
5
5
|
readonly TRANSACTION_SUBMITTED: "TRANSACTION_SUBMITTED";
|
|
6
6
|
readonly WAITING_FOR_CONFIRMATION: "WAITING_FOR_CONFIRMATION";
|
|
7
|
+
readonly IMAGE_EDITOR: "IMAGE_EDITOR";
|
|
7
8
|
};
|
|
8
9
|
//# sourceMappingURL=ModalTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalTypes.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/ModalTypes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"ModalTypes.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/ModalTypes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;CAOd,CAAC"}
|
|
@@ -3,6 +3,7 @@ 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
|
};
|
|
8
9
|
//# sourceMappingURL=ModalTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalTypes.js","sourceRoot":"","sources":["../../../../src/components/modal/ModalTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,qBAAqB,EAAE,uBAAuB;IAC9C,sBAAsB,EAAE,wBAAwB;IAChD,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,wBAAwB,EAAE,0BAA0B;
|
|
1
|
+
{"version":3,"file":"ModalTypes.js","sourceRoot":"","sources":["../../../../src/components/modal/ModalTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,qBAAqB,EAAE,uBAAuB;IAC9C,sBAAsB,EAAE,wBAAwB;IAChD,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,wBAAwB,EAAE,0BAA0B;IACpD,YAAY,EAAE,cAAc;CACpB,CAAC"}
|
|
@@ -5,10 +5,11 @@ export declare function useModal(): {
|
|
|
5
5
|
readonly TRANSACTION_FAILED: "TRANSACTION_FAILED";
|
|
6
6
|
readonly TRANSACTION_SUBMITTED: "TRANSACTION_SUBMITTED";
|
|
7
7
|
readonly WAITING_FOR_CONFIRMATION: "WAITING_FOR_CONFIRMATION";
|
|
8
|
+
readonly IMAGE_EDITOR: "IMAGE_EDITOR";
|
|
8
9
|
};
|
|
9
|
-
showModal: <T extends "FINANCE_DEPOSIT_MODAL" | "FINANCE_WITHDRAW_MODAL" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMITTED" | "WAITING_FOR_CONFIRMATION">(modalType: T, modalProps?: import("./ModalContext").GenericModalProps<T> | undefined, modalSize?: "auto" | ("s" | "m" | "xxs" | "xs" | "l" | "xl") | "fullscreen" | undefined, theme?: "light" | "dark" | undefined, modalMaxWidth?: Partial<Record<"s" | "m" | "xxs" | "xs" | "l" | "xl", import("csstype").Property.MaxWidth<string | number> | undefined>> | null | undefined) => void;
|
|
10
|
+
showModal: <T extends "FINANCE_DEPOSIT_MODAL" | "FINANCE_WITHDRAW_MODAL" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMITTED" | "WAITING_FOR_CONFIRMATION" | "IMAGE_EDITOR">(modalType: T, modalProps?: import("./ModalContext").GenericModalProps<T> | undefined, modalSize?: "auto" | ("s" | "m" | "xxs" | "xs" | "l" | "xl") | "fullscreen" | undefined, theme?: "light" | "dark" | undefined, modalMaxWidth?: Partial<Record<"s" | "m" | "xxs" | "xs" | "l" | "xl", import("csstype").Property.MaxWidth<string | number> | undefined>> | null | undefined) => void;
|
|
10
11
|
hideModal: (data?: unknown) => void;
|
|
11
|
-
updateProps: <T_1 extends "FINANCE_DEPOSIT_MODAL" | "FINANCE_WITHDRAW_MODAL" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMITTED" | "WAITING_FOR_CONFIRMATION">(store: import("./ModalContext").Store & {
|
|
12
|
+
updateProps: <T_1 extends "FINANCE_DEPOSIT_MODAL" | "FINANCE_WITHDRAW_MODAL" | "TRANSACTION_FAILED" | "TRANSACTION_SUBMITTED" | "WAITING_FOR_CONFIRMATION" | "IMAGE_EDITOR">(store: import("./ModalContext").Store & {
|
|
12
13
|
modalProps: import("./ModalContext").GenericModalProps<T_1>;
|
|
13
14
|
modalSize?: "auto" | ("s" | "m" | "xxs" | "xs" | "l" | "xl") | "fullscreen" | undefined;
|
|
14
15
|
modalMaxWidth?: Partial<Record<"s" | "m" | "xxs" | "xs" | "l" | "xl", import("csstype").Property.MaxWidth<string | number> | undefined>> | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModal.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/useModal.ts"],"names":[],"mappings":"AAKA,wBAAgB,QAAQ
|
|
1
|
+
{"version":3,"file":"useModal.d.ts","sourceRoot":"","sources":["../../../../src/components/modal/useModal.ts"],"names":[],"mappings":"AAKA,wBAAgB,QAAQ;;;;;;;;;;;;;;;;;;EAOvB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type UseFileImageProps = {
|
|
2
|
+
file: File | undefined;
|
|
3
|
+
};
|
|
4
|
+
export declare function useFileImage({ file }: UseFileImageProps, options: {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
}): import("react-query").UseQueryResult<string | undefined, unknown>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=useFileImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFileImage.d.ts","sourceRoot":"","sources":["../../../../src/hooks/images/useFileImage.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;CACxB,CAAC;AAEF,wBAAgB,YAAY,CAC1B,EAAE,IAAI,EAAE,EAAE,iBAAiB,EAC3B,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,qEAc9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from "react-query";
|
|
2
|
+
import { loadAndSetImagePromise } from "../../lib/base64/base64";
|
|
3
|
+
export function useFileImage({ file }, options) {
|
|
4
|
+
return useQuery(["useFileImage", file], async () => {
|
|
5
|
+
if (!file) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
return await loadAndSetImagePromise(file);
|
|
9
|
+
}, {
|
|
10
|
+
enabled: !!file && options.enabled
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=useFileImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFileImage.js","sourceRoot":"","sources":["../../../../src/hooks/images/useFileImage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAMjE,MAAM,UAAU,YAAY,CAC1B,EAAE,IAAI,EAAqB,EAC3B,OAA6B;IAE7B,OAAO,QAAQ,CACb,CAAC,cAAc,EAAE,IAAI,CAAC,EACtB,KAAK,IAAI,EAAE;QACT,IAAI,CAAC,IAAI,EAAE;YACT,OAAO;SACR;QACD,OAAO,MAAM,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC,EACD;QACE,OAAO,EAAE,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO;KACnC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type UseIpfsImageProps = {
|
|
2
|
+
url: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function useIpfsImage({ url }: UseIpfsImageProps, options: {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
}): import("react-query").UseQueryResult<{
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
base64: string;
|
|
10
|
+
blob: Blob;
|
|
11
|
+
}, unknown>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=useIpfsImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIpfsImage.d.ts","sourceRoot":"","sources":["../../../../src/hooks/images/useIpfsImage.ts"],"names":[],"mappings":"AAIA,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAgB,YAAY,CAC1B,EAAE,GAAG,EAAE,EAAE,iBAAiB,EAC1B,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE;;;;;YAgB9B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useQuery } from "react-query";
|
|
2
|
+
import { fetchImageAsBase64 } from "../../lib/base64/base64";
|
|
3
|
+
import { getImageMetadata } from "../../lib/images/images";
|
|
4
|
+
export function useIpfsImage({ url }, options) {
|
|
5
|
+
return useQuery(["useIpfsImage", url], async () => {
|
|
6
|
+
const result = await fetchImageAsBase64(url);
|
|
7
|
+
const metadata = await getImageMetadata(result.base64);
|
|
8
|
+
return {
|
|
9
|
+
...result,
|
|
10
|
+
...metadata
|
|
11
|
+
};
|
|
12
|
+
}, {
|
|
13
|
+
enabled: options.enabled
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=useIpfsImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIpfsImage.js","sourceRoot":"","sources":["../../../../src/hooks/images/useIpfsImage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,MAAM,UAAU,YAAY,CAC1B,EAAE,GAAG,EAAqB,EAC1B,OAA6B;IAE7B,OAAO,QAAQ,CACb,CAAC,cAAc,EAAE,GAAG,CAAC,EACrB,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvD,OAAO;YACL,GAAG,MAAM;YACT,GAAG,QAAQ;SACZ,CAAC;IACJ,CAAC,EACD;QACE,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IpfsMetadataStorage } from "@bosonprotocol/ipfs-storage";
|
|
3
|
-
export declare function fetchImageAsBase64(imageUrl: string): Promise<
|
|
3
|
+
export declare function fetchImageAsBase64(imageUrl: string): Promise<{
|
|
4
|
+
base64: string;
|
|
5
|
+
blob: Blob;
|
|
6
|
+
}>;
|
|
4
7
|
export declare function fromBase64ToBinary(base64: string): Buffer;
|
|
5
8
|
export declare function blobToBase64(blob: Blob): Promise<string>;
|
|
6
9
|
export declare const loadAndSetMedia: (fileOrBlob: File | Blob, callback: (base64Uri: string) => void, errorCallback?: ((...errorArgs: unknown[]) => void) | undefined) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../src/lib/base64/base64.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../src/lib/base64/base64.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;GAIxD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAI9D;AAED,eAAO,MAAM,eAAe,eACd,IAAI,GAAG,IAAI,wBACD,MAAM,KAAK,IAAI,kCACN,OAAO,EAAE,KAAK,IAAI,sBAWlD,CAAC;AAEF,eAAO,MAAM,sBAAsB,UAAW,IAAI,oBAMjD,CAAC;AAEF,eAAO,MAAM,oBAAoB,cACpB,MAAM,EAAE,uBACE,mBAAmB,KACvC,QAAQ,MAAM,EAAE,CAgBlB,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,QAsB5C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export async function fetchImageAsBase64(imageUrl) {
|
|
2
2
|
const response = await fetch(imageUrl);
|
|
3
3
|
const blob = await response.blob();
|
|
4
|
-
return blobToBase64(blob);
|
|
4
|
+
return { base64: await blobToBase64(blob), blob };
|
|
5
5
|
}
|
|
6
6
|
export function fromBase64ToBinary(base64) {
|
|
7
7
|
return Buffer.from(base64.replace(/data:image\/.*;base64,/, ""), "base64");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../../../src/lib/base64/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C3C,qDAAqD;IACrD,sFAAsF;IACtF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtD,kCAAkC;IAClC,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAErE,kDAAkD;IAClD,MAAM,EAAE,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAE9C,gCAAgC;IAChC,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAE9B,oDAAoD;IACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAClC;IAED,mDAAmD;IACnD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bosonprotocol/react-kit",
|
|
3
3
|
"description": "React toolkit with smart components and hooks for building on top of the Boson Protocol.",
|
|
4
|
-
"version": "0.32.0
|
|
4
|
+
"version": "0.32.0",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
7
7
|
"types": "./dist/cjs/index.d.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@bosonprotocol/chat-sdk": "^1.3.1-alpha.9",
|
|
18
|
-
"@bosonprotocol/core-sdk": "^1.40.4
|
|
19
|
-
"@bosonprotocol/ethers-sdk": "^1.14.4
|
|
18
|
+
"@bosonprotocol/core-sdk": "^1.40.4",
|
|
19
|
+
"@bosonprotocol/ethers-sdk": "^1.14.4",
|
|
20
20
|
"@bosonprotocol/ipfs-storage": "^1.11.3",
|
|
21
21
|
"@davatar/react": "1.11.1",
|
|
22
22
|
"@ethersproject/units": "5.6.0",
|
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
"multihashes": "^4.0.3",
|
|
55
55
|
"phosphor-react": "^1.4.1",
|
|
56
56
|
"polished": "^4.2.2",
|
|
57
|
+
"react-avatar-editor": "^13.0.2",
|
|
57
58
|
"react-chartjs-2": "^5.2.0",
|
|
59
|
+
"react-dropzone": "^14.2.3",
|
|
58
60
|
"react-error-boundary": "^4.0.13",
|
|
59
61
|
"react-hot-toast": "2.4.0",
|
|
60
62
|
"react-markdown": "8.0.6",
|
|
@@ -155,6 +157,7 @@
|
|
|
155
157
|
"@types/lodash.uniqby": "^4.7.7",
|
|
156
158
|
"@types/node": "^16.11.25",
|
|
157
159
|
"@types/react": "^18.0.3",
|
|
160
|
+
"@types/react-avatar-editor": "^13.0.2",
|
|
158
161
|
"@types/react-slick": "^0.23.13",
|
|
159
162
|
"@types/react-table": "^7.7.14",
|
|
160
163
|
"@types/storybook__react": "^5.2.1",
|
|
@@ -185,5 +188,5 @@
|
|
|
185
188
|
"overrides": {
|
|
186
189
|
"typescript": "^5.1.6"
|
|
187
190
|
},
|
|
188
|
-
"gitHead": "
|
|
191
|
+
"gitHead": "bf1e1287fdfa2eafb76eea318eec0cd62a9b491e"
|
|
189
192
|
}
|
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
import { Warning } from "phosphor-react";
|
|
2
2
|
import React, { ReactNode } from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
3
|
+
import styled, { CSSProperties } from "styled-components";
|
|
4
4
|
|
|
5
5
|
import { theme } from "../../theme";
|
|
6
|
-
import { Grid } from "../ui/Grid";
|
|
6
|
+
import { Grid, GridProps } from "../ui/Grid";
|
|
7
7
|
import { Typography } from "../ui/Typography";
|
|
8
8
|
const colors = theme.colors.light;
|
|
9
9
|
|
|
10
|
-
const StyledGrid = styled(Grid)
|
|
11
|
-
background
|
|
10
|
+
const StyledGrid = styled(Grid)<{
|
|
11
|
+
$background: CSSProperties["backgroundColor"];
|
|
12
|
+
}>`
|
|
13
|
+
background-color: ${({ $background }) => $background};
|
|
12
14
|
`;
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
export type SimpleProps = GridProps & {
|
|
15
17
|
errorMessage?: string;
|
|
16
18
|
children?: ReactNode;
|
|
17
|
-
|
|
18
|
-
[
|
|
19
|
-
}
|
|
19
|
+
backgroundColor?: CSSProperties["backgroundColor"];
|
|
20
|
+
warningColor?: CSSProperties["backgroundColor"];
|
|
21
|
+
};
|
|
20
22
|
|
|
21
|
-
export function SimpleError({
|
|
23
|
+
export function SimpleError({
|
|
24
|
+
errorMessage,
|
|
25
|
+
children,
|
|
26
|
+
backgroundColor = colors.lightGrey,
|
|
27
|
+
warningColor = colors.darkOrange,
|
|
28
|
+
...rest
|
|
29
|
+
}: SimpleProps) {
|
|
22
30
|
return (
|
|
23
31
|
<StyledGrid
|
|
24
32
|
justifyContent="flex-start"
|
|
25
33
|
gap="0.5rem"
|
|
26
34
|
margin="1.5rem 0 0 0"
|
|
27
35
|
padding="1.5rem"
|
|
36
|
+
$background={backgroundColor}
|
|
28
37
|
{...rest}
|
|
29
38
|
>
|
|
30
|
-
<Warning color={
|
|
39
|
+
<Warning color={warningColor} size={16} />
|
|
31
40
|
{children ? (
|
|
32
41
|
children
|
|
33
42
|
) : (
|
|
@@ -115,7 +115,7 @@ export const FieldInput = styled.input<{
|
|
|
115
115
|
`};
|
|
116
116
|
`;
|
|
117
117
|
|
|
118
|
-
export const FileUploadWrapper = styled.div<{
|
|
118
|
+
export const FileUploadWrapper = styled.div<{ error: any }>`
|
|
119
119
|
position: relative;
|
|
120
120
|
overflow: hidden;
|
|
121
121
|
display: flex;
|
|
@@ -13,15 +13,16 @@ import type { FormFieldProps } from "./types";
|
|
|
13
13
|
|
|
14
14
|
const colors = theme.colors.light;
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export function FormField({
|
|
17
17
|
title,
|
|
18
|
+
titleIcon,
|
|
18
19
|
subTitle = false,
|
|
19
20
|
required = false,
|
|
20
21
|
tooltip,
|
|
21
22
|
children,
|
|
22
23
|
style = {},
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
valueToCopy,
|
|
25
|
+
copyIconColor = colors.secondary
|
|
25
26
|
}: FormFieldProps) {
|
|
26
27
|
return (
|
|
27
28
|
<FormFieldWrapper
|
|
@@ -59,10 +60,11 @@ export default function FormField({
|
|
|
59
60
|
}
|
|
60
61
|
}}
|
|
61
62
|
>
|
|
62
|
-
<Copy size={24} color={
|
|
63
|
+
<Copy size={24} color={copyIconColor} weight="light" />
|
|
63
64
|
</CopyButton>
|
|
64
65
|
)}
|
|
65
66
|
</Typography>
|
|
67
|
+
{titleIcon}
|
|
66
68
|
{tooltip && <Tooltip content={tooltip} size={16} />}
|
|
67
69
|
</Grid>
|
|
68
70
|
{subTitle && (
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { ChangeEvent, forwardRef, useState } from "react";
|
|
2
|
+
import AvatarEditor, { AvatarEditorProps } from "react-avatar-editor";
|
|
3
|
+
import Dropzone from "react-dropzone";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { Grid } from "../../../ui/Grid";
|
|
6
|
+
import { useIpfsImage } from "../../../../hooks/images/useIpfsImage";
|
|
7
|
+
|
|
8
|
+
const StyledCanvasWrapper = styled.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
> :first-child {
|
|
12
|
+
max-width: 100%;
|
|
13
|
+
object-fit: contain;
|
|
14
|
+
width: auto !important;
|
|
15
|
+
height: auto !important;
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export type ImageEditorProps = Pick<
|
|
20
|
+
AvatarEditorProps,
|
|
21
|
+
"borderRadius" | "width" | "height"
|
|
22
|
+
> & {
|
|
23
|
+
url?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const ImageEditor = forwardRef<AvatarEditor, ImageEditorProps>(
|
|
27
|
+
({ url, borderRadius, width, height }, editorRef) => {
|
|
28
|
+
const [scale, setScale] = useState<number>();
|
|
29
|
+
const handleScale = (e: ChangeEvent<HTMLInputElement>) => {
|
|
30
|
+
const scale = parseFloat(e.target.value);
|
|
31
|
+
setScale(scale);
|
|
32
|
+
};
|
|
33
|
+
const { data } = useIpfsImage({ url: url ?? "" }, { enabled: !!url });
|
|
34
|
+
const image = data?.base64;
|
|
35
|
+
const { width: imageWidth, height: imageHeight } = data || {};
|
|
36
|
+
const w = borderRadius ? width : width || imageWidth;
|
|
37
|
+
const h = borderRadius ? height : height || imageHeight;
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
{image && (
|
|
41
|
+
<div style={{ margin: "2rem 0", maxWidth: "100%" }}>
|
|
42
|
+
<Dropzone noClick noKeyboard>
|
|
43
|
+
{({ getRootProps, getInputProps }) => (
|
|
44
|
+
<StyledCanvasWrapper {...getRootProps()}>
|
|
45
|
+
<AvatarEditor
|
|
46
|
+
image={image}
|
|
47
|
+
ref={editorRef}
|
|
48
|
+
width={w}
|
|
49
|
+
height={h}
|
|
50
|
+
scale={scale}
|
|
51
|
+
borderRadius={borderRadius}
|
|
52
|
+
/>
|
|
53
|
+
<input {...getInputProps()} />
|
|
54
|
+
</StyledCanvasWrapper>
|
|
55
|
+
)}
|
|
56
|
+
</Dropzone>
|
|
57
|
+
<Grid alignItems="center" justifyContent="center">
|
|
58
|
+
Zoom:
|
|
59
|
+
<input
|
|
60
|
+
name="scale"
|
|
61
|
+
type="range"
|
|
62
|
+
onChange={handleScale}
|
|
63
|
+
min={"0.1"}
|
|
64
|
+
max="2"
|
|
65
|
+
step="0.01"
|
|
66
|
+
defaultValue="1"
|
|
67
|
+
/>
|
|
68
|
+
</Grid>
|
|
69
|
+
</div>
|
|
70
|
+
)}
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as Sentry from "@sentry/browser";
|
|
2
|
+
import React, { useRef, useState } from "react";
|
|
3
|
+
import AvatarEditor from "react-avatar-editor";
|
|
4
|
+
import { dataURItoBlob } from "../../../../lib/base64/base64";
|
|
5
|
+
import Modal from "../../../modal/Modal";
|
|
6
|
+
import { Grid } from "../../../ui/Grid";
|
|
7
|
+
import { Spinner } from "../../../ui/loading/Spinner";
|
|
8
|
+
import { BaseButton, BaseButtonTheme } from "../../../buttons/BaseButton";
|
|
9
|
+
import { ImageEditor, ImageEditorProps } from "./ImageEditor";
|
|
10
|
+
import { useFileImage } from "../../../../hooks/images/useFileImage";
|
|
11
|
+
|
|
12
|
+
export type ImageEditorModalProps = Omit<ImageEditorProps, "url"> & {
|
|
13
|
+
files: File[] | null;
|
|
14
|
+
hideModal: (files?: File[]) => Promise<void>;
|
|
15
|
+
saveButtonTheme: BaseButtonTheme;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const ImageEditorModal: React.FC<ImageEditorModalProps> = ({
|
|
19
|
+
hideModal,
|
|
20
|
+
files,
|
|
21
|
+
saveButtonTheme,
|
|
22
|
+
...rest
|
|
23
|
+
}) => {
|
|
24
|
+
const originalFile = files?.[0];
|
|
25
|
+
const { data: url } = useFileImage(
|
|
26
|
+
{ file: originalFile },
|
|
27
|
+
{ enabled: !!originalFile }
|
|
28
|
+
);
|
|
29
|
+
const editorRef = useRef<AvatarEditor>(null);
|
|
30
|
+
const [isSaving, setSaving] = useState<boolean>(false);
|
|
31
|
+
const onClickSave = async () => {
|
|
32
|
+
setSaving(true);
|
|
33
|
+
try {
|
|
34
|
+
const img = editorRef.current?.getImageScaledToCanvas().toDataURL();
|
|
35
|
+
if (!img) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const blob = dataURItoBlob(img);
|
|
39
|
+
const file = new File([blob], originalFile?.name ?? "edited", {
|
|
40
|
+
type: originalFile?.type,
|
|
41
|
+
lastModified: originalFile?.lastModified
|
|
42
|
+
});
|
|
43
|
+
if (!file) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await hideModal([file]);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
Sentry.captureException(error);
|
|
49
|
+
} finally {
|
|
50
|
+
setSaving(false);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return (
|
|
54
|
+
<Modal
|
|
55
|
+
modalType="IMAGE_EDITOR"
|
|
56
|
+
hideModal={() => hideModal()}
|
|
57
|
+
size="auto"
|
|
58
|
+
maxWidths={{
|
|
59
|
+
s: "50rem"
|
|
60
|
+
}}
|
|
61
|
+
theme="light"
|
|
62
|
+
>
|
|
63
|
+
<Grid flexDirection="column">
|
|
64
|
+
<ImageEditor url={url} {...rest} ref={editorRef} />
|
|
65
|
+
<BaseButton
|
|
66
|
+
type="button"
|
|
67
|
+
theme={saveButtonTheme}
|
|
68
|
+
onClick={() => onClickSave()}
|
|
69
|
+
disabled={isSaving}
|
|
70
|
+
>
|
|
71
|
+
{isSaving ? "Saving" : "Save"}
|
|
72
|
+
{isSaving && <Spinner />}
|
|
73
|
+
</BaseButton>
|
|
74
|
+
</Grid>
|
|
75
|
+
</Modal>
|
|
76
|
+
);
|
|
77
|
+
};
|