@lifesg/web-frontend-engine 1.0.0-alpha.3 → 1.0.0-alpha.5
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 +2 -1
- package/chunks/heic2any.3b8e0e2e.js +2 -0
- package/chunks/heic2any.3b8e0e2e.js.map +1 -0
- package/chunks/index.a9be1bad.js +2 -0
- package/chunks/index.a9be1bad.js.map +1 -0
- package/chunks/index.cb84bb25.js +813 -0
- package/chunks/index.cb84bb25.js.map +1 -0
- package/chunks/index.f3b64f06.js +10 -0
- package/chunks/index.f3b64f06.js.map +1 -0
- package/cjs/chunks/heic2any.8d6aeb48.js +2 -0
- package/cjs/chunks/heic2any.8d6aeb48.js.map +1 -0
- package/cjs/chunks/index.3a31dd0d.js +813 -0
- package/cjs/chunks/index.3a31dd0d.js.map +1 -0
- package/cjs/chunks/index.42475725.js +2 -0
- package/cjs/chunks/index.42475725.js.map +1 -0
- package/cjs/chunks/index.4da6edf0.js +10 -0
- package/cjs/chunks/index.4da6edf0.js.map +1 -0
- package/cjs/index.js +1 -281
- package/cjs/index.js.map +1 -1
- package/components/custom/filter/filter/filter.d.ts +2 -0
- package/components/custom/filter/filter/types.d.ts +14 -0
- package/components/custom/filter/filter-checkbox/filter-checkbox.d.ts +3 -0
- package/components/custom/filter/filter-checkbox/types.d.ts +12 -0
- package/components/custom/filter/filter-item/filter-item.d.ts +3 -0
- package/components/custom/filter/filter-item/types.d.ts +8 -0
- package/components/custom/filter/index.d.ts +3 -0
- package/components/custom/index.d.ts +1 -0
- package/components/elements/alert/alert.d.ts +1 -2
- package/components/elements/section/section.d.ts +1 -2
- package/components/elements/sections/sections.d.ts +1 -2
- package/components/elements/text/data.d.ts +12 -12
- package/components/elements/text/text.d.ts +1 -2
- package/components/elements/wrapper/conditional-renderer.d.ts +4 -2
- package/components/elements/wrapper/types.d.ts +3 -1
- package/components/fields/checkbox-group/checkbox-group.d.ts +1 -2
- package/components/fields/checkbox-group/checkbox-group.styles.d.ts +3 -2
- package/components/fields/checkbox-group/types.d.ts +13 -1
- package/components/fields/chips/chips.d.ts +1 -2
- package/components/fields/chips/types.d.ts +1 -0
- package/components/fields/contact-field/contact-field.d.ts +1 -2
- package/components/fields/contact-field/data.d.ts +4 -214
- package/components/fields/contact-field/types.d.ts +8 -7
- package/components/fields/date-field/date-field.d.ts +1 -2
- package/components/fields/image-upload/image-context/image-context.d.ts +14 -0
- package/components/fields/image-upload/image-context/index.d.ts +1 -0
- package/components/fields/image-upload/image-input/file-item/file-item.d.ts +11 -0
- package/components/fields/image-upload/image-input/file-item/file-item.styles.d.ts +16 -0
- package/components/fields/image-upload/image-input/file-item/index.d.ts +1 -0
- package/components/fields/image-upload/image-input/image-input.d.ts +17 -0
- package/components/fields/image-upload/image-input/image-input.styles.d.ts +8 -0
- package/components/fields/image-upload/image-input/index.d.ts +1 -0
- package/components/fields/image-upload/image-manager/image-manager.d.ts +22 -0
- package/components/fields/image-upload/image-manager/index.d.ts +2 -0
- package/components/fields/image-upload/image-review/image-editor/image-editor.d.ts +3 -0
- package/components/fields/image-upload/image-review/image-editor/image-editor.styles.d.ts +4 -0
- package/components/fields/image-upload/image-review/image-editor/index.d.ts +3 -0
- package/components/fields/image-upload/image-review/image-editor/types.d.ts +16 -0
- package/components/fields/image-upload/image-review/image-error/image-error.d.ts +8 -0
- package/components/fields/image-upload/image-review/image-error/image-error.styles.d.ts +7 -0
- package/components/fields/image-upload/image-review/image-error/index.d.ts +1 -0
- package/components/fields/image-upload/image-review/image-prompts/image-prompts.d.ts +11 -0
- package/components/fields/image-upload/image-review/image-prompts/index.d.ts +1 -0
- package/components/fields/image-upload/image-review/image-review.d.ts +15 -0
- package/components/fields/image-upload/image-review/image-review.styles.d.ts +31 -0
- package/components/fields/image-upload/image-review/image-thumbnails/image-thumbnails.d.ts +11 -0
- package/components/fields/image-upload/image-review/image-thumbnails/image-thumbnails.styles.d.ts +14 -0
- package/components/fields/image-upload/image-review/image-thumbnails/index.d.ts +1 -0
- package/components/fields/image-upload/image-review/index.d.ts +1 -0
- package/components/fields/image-upload/image-upload-helper.d.ts +10 -0
- package/components/fields/image-upload/image-upload.d.ts +4 -0
- package/components/fields/image-upload/index.d.ts +2 -0
- package/components/fields/image-upload/types.d.ts +65 -0
- package/components/fields/index.d.ts +3 -0
- package/components/fields/multi-select/multi-select.d.ts +1 -2
- package/components/fields/radio-button/radio-button.d.ts +1 -2
- package/components/fields/radio-button/radio-button.styles.d.ts +4 -2
- package/components/fields/radio-button/types.d.ts +12 -0
- package/components/fields/reset-button/index.d.ts +2 -0
- package/components/fields/reset-button/reset-button.d.ts +3 -0
- package/components/fields/reset-button/types.d.ts +6 -0
- package/components/fields/select/select.d.ts +1 -2
- package/components/fields/submit-button/submit-button.d.ts +1 -2
- package/components/fields/text-field/text-field.d.ts +1 -2
- package/components/fields/text-field/types.d.ts +8 -0
- package/components/fields/textarea/textarea.d.ts +1 -2
- package/components/fields/textarea/textarea.styles.d.ts +1 -1
- package/components/fields/time-field/time-field.d.ts +1 -2
- package/components/fields/unit-number-field/index.d.ts +2 -0
- package/components/fields/unit-number-field/types.d.ts +7 -0
- package/components/fields/unit-number-field/unit-number-field.d.ts +3 -0
- package/components/frontend-engine/event/context-provider.d.ts +14 -0
- package/components/frontend-engine/event/index.d.ts +1 -0
- package/components/frontend-engine/types.d.ts +46 -20
- package/components/frontend-engine/yup/context-provider.d.ts +1 -1
- package/components/frontend-engine/yup/types.d.ts +2 -1
- package/components/shared/chip/chip.d.ts +1 -1
- package/components/shared/drag-upload/drag-upload.d.ts +3 -0
- package/components/shared/drag-upload/drag-upload.styles.d.ts +4 -0
- package/components/shared/drag-upload/index.d.ts +2 -0
- package/components/shared/drag-upload/types.d.ts +15 -0
- package/components/shared/error-messages.d.ts +29 -3
- package/components/shared/index.d.ts +2 -0
- package/components/shared/prompt/index.d.ts +2 -0
- package/components/shared/prompt/prompt.d.ts +2 -0
- package/components/shared/prompt/prompt.styles.d.ts +15 -0
- package/components/shared/prompt/types.d.ts +16 -0
- package/components/shared/sanitize/sanitize.d.ts +1 -1
- package/index.js +1 -281
- package/index.js.map +1 -1
- package/package.json +8 -2
- package/utils/api-client/api-client.d.ts +65 -0
- package/utils/api-client/index.d.ts +1 -0
- package/utils/file-helper.d.ts +43 -0
- package/utils/hooks/index.d.ts +1 -0
- package/utils/hooks/use-field-event.d.ts +9 -0
- package/utils/hooks/use-previous.d.ts +4 -1
- package/utils/image-helper.d.ts +34 -0
- package/utils/index.d.ts +4 -0
- package/utils/window-helper.d.ts +3 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ISharedImageProps, TImageUploadOutputFileType, TUploadMethod } from "../types";
|
|
2
|
+
interface IProps extends Omit<ISharedImageProps, "maxFiles"> {
|
|
3
|
+
editImage: boolean;
|
|
4
|
+
onChange: (...event: any[]) => void;
|
|
5
|
+
compress: boolean;
|
|
6
|
+
dimensions: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
outputType: TImageUploadOutputFileType;
|
|
11
|
+
upload?: {
|
|
12
|
+
method: TUploadMethod;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
value: any;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* manages selected images by listening to images from context provider
|
|
19
|
+
* rename / compress / upload
|
|
20
|
+
*/
|
|
21
|
+
export declare const ImageManager: (props: IProps) => any;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ForwardedRef } from "react";
|
|
2
|
+
export interface IImageEditorProps {
|
|
3
|
+
maxSizeInKb?: number;
|
|
4
|
+
baseImageDataURL?: string;
|
|
5
|
+
drawing?: fabric.Object[];
|
|
6
|
+
color?: string;
|
|
7
|
+
erase?: boolean;
|
|
8
|
+
forwardedRef?: ForwardedRef<IImageEditorRef>;
|
|
9
|
+
}
|
|
10
|
+
export interface IImageEditorRef {
|
|
11
|
+
clearDrawing: VoidFunction;
|
|
12
|
+
export: () => {
|
|
13
|
+
drawing: fabric.Object[];
|
|
14
|
+
dataURL: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IImage, ISharedImageProps } from "../../types";
|
|
3
|
+
interface IProps extends Omit<ISharedImageProps, "maxFiles"> {
|
|
4
|
+
image: IImage;
|
|
5
|
+
onClickOk: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const ImageError: (props: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const ErrorIcon: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
4
|
+
export declare const Content: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const BodyText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const NameWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
7
|
+
export declare const OkButton: import("styled-components").StyledComponent<(props: import("@lifesg/react-design-system/button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, any, {}, never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./image-error";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IImage } from "../../types";
|
|
2
|
+
interface IProps {
|
|
3
|
+
onDecideClearDrawing: (decision?: boolean) => void;
|
|
4
|
+
onDecideDelete: (decision: boolean) => void;
|
|
5
|
+
onDecideExit: (decision?: boolean) => void;
|
|
6
|
+
id?: string;
|
|
7
|
+
images: IImage[];
|
|
8
|
+
show?: "delete" | "exit" | "clear-drawing";
|
|
9
|
+
}
|
|
10
|
+
export declare const ImagePrompts: (props: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./image-prompts";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TFileCapture } from "../../../shared";
|
|
2
|
+
import { ISharedImageProps } from "../types";
|
|
3
|
+
interface IProps extends ISharedImageProps {
|
|
4
|
+
capture?: TFileCapture;
|
|
5
|
+
compress?: boolean | undefined;
|
|
6
|
+
dimensions: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
onExit: () => void;
|
|
11
|
+
outputType: string;
|
|
12
|
+
show: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const ImageReview: (props: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ModalBox: import("styled-components").StyledComponent<({ id, children, onClose, showCloseButton, ...otherProps }: import("@lifesg/react-design-system/modal").ModalBoxProps) => JSX.Element, any, {
|
|
3
|
+
statusBarHeight: number;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const HeaderSection: import("styled-components").StyledComponent<"div", any, {
|
|
6
|
+
drawActive?: boolean;
|
|
7
|
+
}, never>;
|
|
8
|
+
export declare const ReviewCloseButton: import("styled-components").StyledComponent<(props: import("@lifesg/react-design-system/icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, any, {}, never>;
|
|
9
|
+
export declare const ReviewTitle: import("styled-components").StyledComponent<"h5", any, import("@lifesg/react-design-system/text").TextProps, never>;
|
|
10
|
+
export declare const EditHeaderButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
11
|
+
export declare const ContentSection: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export declare const LoadingPreviewText: import("styled-components").StyledComponent<"h4", any, import("@lifesg/react-design-system/text").TextProps, never>;
|
|
13
|
+
export declare const DrawDeleteButtonWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
14
|
+
export declare const DrawDeleteButton: import("styled-components").StyledComponent<(props: import("@lifesg/react-design-system/icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, any, {}, never>;
|
|
15
|
+
export declare const DrawDeleteButtonText: import("styled-components").StyledComponent<"h6", any, import("@lifesg/react-design-system/text").TextProps & {
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
}, never>;
|
|
18
|
+
export declare const DrawIcon: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
19
|
+
export declare const DeleteIcon: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
20
|
+
export declare const ImageEditorWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
21
|
+
export declare const FooterSection: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
22
|
+
export declare const FooterSaveButton: import("styled-components").StyledComponent<(props: import("@lifesg/react-design-system/button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, any, {}, never>;
|
|
23
|
+
export declare const EraserButton: import("styled-components").StyledComponent<"button", any, {
|
|
24
|
+
active?: boolean;
|
|
25
|
+
}, never>;
|
|
26
|
+
export declare const ButtonIcon: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
27
|
+
export declare const PaletteHolder: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
28
|
+
export declare const Palette: import("styled-components").StyledComponent<"button", any, {
|
|
29
|
+
color: string;
|
|
30
|
+
colorScheme?: string;
|
|
31
|
+
}, never>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TFileCapture } from "../../../../shared";
|
|
2
|
+
import { IImage, ISharedImageProps } from "../../types";
|
|
3
|
+
interface IProps extends Omit<ISharedImageProps, "maxSizeInKb"> {
|
|
4
|
+
activeFileIndex: number;
|
|
5
|
+
capture?: TFileCapture;
|
|
6
|
+
images: IImage[];
|
|
7
|
+
onClickThumbnail: (index: number) => void;
|
|
8
|
+
onSelectFile: (file: File) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const ImageThumbnails: (props: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
package/components/fields/image-upload/image-review/image-thumbnails/image-thumbnails.styles.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ThumbnailsWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const ThumbnailItem: import("styled-components").StyledComponent<"button", any, {
|
|
4
|
+
src?: string;
|
|
5
|
+
error?: boolean;
|
|
6
|
+
}, never>;
|
|
7
|
+
export declare const ThumbnailWarningIcon: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
8
|
+
export declare const LoadingDot: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const LoadingBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
export declare const BorderOverlay: import("styled-components").StyledComponent<"div", any, {
|
|
11
|
+
isSelected: boolean;
|
|
12
|
+
}, never>;
|
|
13
|
+
export declare const HiddenFileSelect: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
14
|
+
export declare const AddImageButton: import("styled-components").StyledComponent<(props: import("@lifesg/react-design-system/icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, any, {}, never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./image-thumbnails";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./image-review";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IImage } from "./types";
|
|
2
|
+
export declare namespace ImageUploadHelper {
|
|
3
|
+
/**
|
|
4
|
+
* picks an available slot
|
|
5
|
+
* slot refers to the index of the file selected
|
|
6
|
+
* this is for tracking so we can remove the correct file when user removes it
|
|
7
|
+
* NOTE: validation for max no. of images should be carried out outside this function, this function will only look for the next available slot
|
|
8
|
+
*/
|
|
9
|
+
const findAvailableSlot: (images: IImage[]) => number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IGenericFieldProps } from "../../frontend-engine";
|
|
2
|
+
import { IImageUploadSchema } from "./types";
|
|
3
|
+
export declare const ImageUploadInner: (props: IGenericFieldProps<IImageUploadSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const ImageUpload: (props: IGenericFieldProps<IImageUploadSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { IFrontendEngineBaseFieldJsonSchema } from "../../frontend-engine";
|
|
2
|
+
import { IYupValidationRule } from "../../frontend-engine/yup/types";
|
|
3
|
+
export type TUploadMethod = "post" | "put" | "patch";
|
|
4
|
+
export declare const ACCEPTED_FILE_TYPES: readonly ["jpg", "gif", "png", "heic", "heif", "webp"];
|
|
5
|
+
export type TImageUploadAcceptedFileType = (typeof ACCEPTED_FILE_TYPES)[number];
|
|
6
|
+
export type TImageUploadOutputFileType = "jpg" | "png";
|
|
7
|
+
export interface IImageUploadValidationRule extends IYupValidationRule {
|
|
8
|
+
/** accepted file types */
|
|
9
|
+
fileType?: TImageUploadAcceptedFileType[] | undefined;
|
|
10
|
+
/** max acceptable file size in kb */
|
|
11
|
+
maxSizeInKb?: number | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface IImageUploadSchema<V = IImageUploadValidationRule> extends IFrontendEngineBaseFieldJsonSchema<"image-upload", V> {
|
|
14
|
+
buttonLabel?: string | undefined;
|
|
15
|
+
description?: string | undefined;
|
|
16
|
+
editImage?: boolean | undefined;
|
|
17
|
+
outputType?: TImageUploadOutputFileType | undefined;
|
|
18
|
+
uploadOnAddingFile?: {
|
|
19
|
+
method: TUploadMethod;
|
|
20
|
+
url: string;
|
|
21
|
+
} | undefined;
|
|
22
|
+
compress?: boolean | undefined;
|
|
23
|
+
dimensions?: IImageDimensions | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface ISharedImageProps {
|
|
26
|
+
id?: string | undefined;
|
|
27
|
+
accepts: TImageUploadAcceptedFileType[];
|
|
28
|
+
maxSizeInKb: number;
|
|
29
|
+
maxFiles: number;
|
|
30
|
+
}
|
|
31
|
+
export declare enum EImageStatus {
|
|
32
|
+
INJECTED = -99,
|
|
33
|
+
ERROR_FORMAT = -3,
|
|
34
|
+
ERROR_GENERIC = -2,
|
|
35
|
+
ERROR_SIZE = -1,
|
|
36
|
+
NONE = 0,
|
|
37
|
+
TO_RECOMPRESS = 1,
|
|
38
|
+
COMPRESSED = 2,
|
|
39
|
+
RECOMPRESSED = 2,
|
|
40
|
+
CONVERTED = 2,
|
|
41
|
+
EDITED = 3,
|
|
42
|
+
UPLOAD_READY = 4,
|
|
43
|
+
UPLOADING = 5,
|
|
44
|
+
UPLOADED = 6
|
|
45
|
+
}
|
|
46
|
+
export interface IImage {
|
|
47
|
+
file: File;
|
|
48
|
+
name: string;
|
|
49
|
+
type?: string;
|
|
50
|
+
/** refers to preview dimensions and eventual output dimensions */
|
|
51
|
+
dimensions: IImageDimensions;
|
|
52
|
+
dataURL?: string;
|
|
53
|
+
thumbnailDataURL?: string;
|
|
54
|
+
drawingDataURL?: string;
|
|
55
|
+
drawing?: fabric.Object[];
|
|
56
|
+
status: EImageStatus;
|
|
57
|
+
addedFrom?: "dragInput" | "reviewModal" | "schema";
|
|
58
|
+
uploadProgress: number;
|
|
59
|
+
uploadResponse?: any;
|
|
60
|
+
slot: number;
|
|
61
|
+
}
|
|
62
|
+
export interface IImageDimensions {
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
}
|
|
@@ -2,6 +2,7 @@ export * from "./checkbox-group";
|
|
|
2
2
|
export * from "./chips";
|
|
3
3
|
export * from "./contact-field";
|
|
4
4
|
export * from "./date-field";
|
|
5
|
+
export * from "./image-upload";
|
|
5
6
|
export * from "./multi-select";
|
|
6
7
|
export * from "./radio-button";
|
|
7
8
|
export * from "./select";
|
|
@@ -9,3 +10,5 @@ export * from "./submit-button";
|
|
|
9
10
|
export * from "./text-field";
|
|
10
11
|
export * from "./textarea";
|
|
11
12
|
export * from "./time-field";
|
|
13
|
+
export * from "./reset-button";
|
|
14
|
+
export * from "./unit-number-field";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IGenericFieldProps } from "../../frontend-engine";
|
|
3
2
|
import { IMultiSelectSchema } from "./types";
|
|
4
|
-
export declare const MultiSelect: (props: IGenericFieldProps<IMultiSelectSchema>) => JSX.Element;
|
|
3
|
+
export declare const MultiSelect: (props: IGenericFieldProps<IMultiSelectSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IGenericFieldProps } from "../../frontend-engine";
|
|
3
2
|
import { IRadioButtonGroupSchema } from "./types";
|
|
4
|
-
export declare const RadioButtonGroup: (props: IGenericFieldProps<IRadioButtonGroupSchema>) => JSX.Element;
|
|
3
|
+
export declare const RadioButtonGroup: (props: IGenericFieldProps<IRadioButtonGroupSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
interface ILabelProps {
|
|
3
3
|
disabled?: boolean | undefined;
|
|
4
4
|
}
|
|
5
|
-
export declare const Label: import("styled-components").StyledComponent<"
|
|
6
|
-
export declare const StyledRadioButton: import("styled-components").StyledComponent<({ className, checked, disabled, onChange, ...otherProps }: import("@lifesg/react-design-system
|
|
5
|
+
export declare const Label: import("styled-components").StyledComponent<"p", any, import("@lifesg/react-design-system").TextProps & ILabelProps, never>;
|
|
6
|
+
export declare const StyledRadioButton: import("styled-components").StyledComponent<({ className, checked, disabled, onChange, ...otherProps }: import("@lifesg/react-design-system").RadioButtonProps) => JSX.Element, any, {}, never>;
|
|
7
|
+
export declare const StyledImageButton: import("styled-components").StyledComponent<(props: import("@lifesg/react-design-system").ImageButtonProps & import("react").RefAttributes<HTMLButtonElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, any, {}, never>;
|
|
7
8
|
export declare const RadioContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const FlexWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
10
|
export {};
|
|
@@ -3,8 +3,20 @@ import { IFrontendEngineBaseFieldJsonSchema, TComponentOmitProps } from "../../f
|
|
|
3
3
|
interface IOption {
|
|
4
4
|
label: string;
|
|
5
5
|
value: string;
|
|
6
|
+
disabled?: boolean | undefined;
|
|
7
|
+
imgSrc?: string | undefined;
|
|
6
8
|
}
|
|
9
|
+
type TCustomOptions = {
|
|
10
|
+
styleType: "default";
|
|
11
|
+
} | {
|
|
12
|
+
styleType: "toggle";
|
|
13
|
+
indicator?: boolean | undefined;
|
|
14
|
+
border?: boolean | undefined;
|
|
15
|
+
} | {
|
|
16
|
+
styleType: "image-button";
|
|
17
|
+
};
|
|
7
18
|
export interface IRadioButtonGroupSchema<V = undefined> extends IFrontendEngineBaseFieldJsonSchema<"radio", V>, TComponentOmitProps<RadioButtonProps> {
|
|
8
19
|
options: IOption[];
|
|
20
|
+
customOptions?: TCustomOptions;
|
|
9
21
|
}
|
|
10
22
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ButtonProps } from "@lifesg/react-design-system/button/types";
|
|
2
|
+
import { IFrontendEngineBaseFieldJsonSchema, TComponentOmitProps } from "../../frontend-engine";
|
|
3
|
+
export interface IResetButtonSchema extends Omit<IFrontendEngineBaseFieldJsonSchema<"reset">, "validation">, TComponentOmitProps<ButtonProps, "disabled"> {
|
|
4
|
+
disabled?: boolean | undefined;
|
|
5
|
+
ignoreDefaultValues?: boolean | undefined;
|
|
6
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IGenericFieldProps } from "../../frontend-engine";
|
|
3
2
|
import { ISelectSchema } from "./types";
|
|
4
|
-
export declare const Select: (props: IGenericFieldProps<ISelectSchema>) => JSX.Element;
|
|
3
|
+
export declare const Select: (props: IGenericFieldProps<ISelectSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IGenericFieldProps } from "../../frontend-engine";
|
|
3
2
|
import { ISubmitButtonSchema } from "./types";
|
|
4
|
-
export declare const SubmitButton: (props: IGenericFieldProps<ISubmitButtonSchema>) => JSX.Element;
|
|
3
|
+
export declare const SubmitButton: (props: IGenericFieldProps<ISubmitButtonSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IGenericFieldProps } from "../../frontend-engine";
|
|
3
2
|
import { IEmailFieldSchema, INumericFieldSchema, ITextFieldSchema } from "./types";
|
|
4
|
-
export declare const TextField: (props: IGenericFieldProps<ITextFieldSchema | IEmailFieldSchema | INumericFieldSchema>) => JSX.Element;
|
|
3
|
+
export declare const TextField: (props: IGenericFieldProps<ITextFieldSchema | IEmailFieldSchema | INumericFieldSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { FormInputProps } from "@lifesg/react-design-system/form/types";
|
|
2
2
|
import { IFrontendEngineBaseFieldJsonSchema, TComponentOmitProps } from "../../frontend-engine";
|
|
3
|
+
type TCustomOptions = {
|
|
4
|
+
preventCopyAndPaste?: boolean | undefined;
|
|
5
|
+
preventDragAndDrop?: boolean | undefined;
|
|
6
|
+
};
|
|
3
7
|
export interface ITextFieldSchema<V = undefined> extends IFrontendEngineBaseFieldJsonSchema<"text-field", V>, TComponentOmitProps<FormInputProps, "type" | "maxLength"> {
|
|
8
|
+
customOptions?: TCustomOptions | undefined;
|
|
4
9
|
}
|
|
5
10
|
export interface IEmailFieldSchema<V = undefined> extends IFrontendEngineBaseFieldJsonSchema<"email-field", V>, TComponentOmitProps<FormInputProps, "type" | "maxLength"> {
|
|
11
|
+
customOptions?: TCustomOptions | undefined;
|
|
6
12
|
}
|
|
7
13
|
export interface INumericFieldSchema<V = undefined> extends IFrontendEngineBaseFieldJsonSchema<"numeric-field", V>, TComponentOmitProps<FormInputProps, "type" | "max" | "min"> {
|
|
14
|
+
customOptions?: TCustomOptions | undefined;
|
|
8
15
|
}
|
|
16
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IGenericFieldProps } from "../../frontend-engine/types";
|
|
3
2
|
import { ITextareaSchema } from "./types";
|
|
4
|
-
export declare const Textarea: (props: IGenericFieldProps<ITextareaSchema>) => JSX.Element;
|
|
3
|
+
export declare const Textarea: (props: IGenericFieldProps<ITextareaSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,5 +7,5 @@ export declare const Wrapper: import("styled-components").StyledComponent<"div",
|
|
|
7
7
|
chipPosition?: "top" | "bottom" | undefined;
|
|
8
8
|
}, never>;
|
|
9
9
|
export declare const ChipContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
-
export declare const StyledTextarea: import("styled-components").StyledComponent<(props: import("@lifesg/react-design-system/
|
|
10
|
+
export declare const StyledTextarea: import("styled-components").StyledComponent<(props: import("@lifesg/react-design-system/input-textarea").TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>, any, ITextareaProps, never>;
|
|
11
11
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { IGenericFieldProps } from "../../frontend-engine";
|
|
3
2
|
import { ITimeFieldSchema } from "./types";
|
|
4
|
-
export declare const TimeField: (props: IGenericFieldProps<ITimeFieldSchema>) => JSX.Element;
|
|
3
|
+
export declare const TimeField: (props: IGenericFieldProps<ITimeFieldSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UnitNumberInputProps } from "@lifesg/react-design-system/unit-number";
|
|
2
|
+
import { IFrontendEngineBaseFieldJsonSchema, TComponentOmitProps } from "../../frontend-engine";
|
|
3
|
+
export interface IUnitNumberFieldValidationRule {
|
|
4
|
+
unitNumberFormat?: boolean | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface IUnitNumberFieldSchema<V = undefined> extends IFrontendEngineBaseFieldJsonSchema<"unit-number-field", V, IUnitNumberFieldValidationRule>, TComponentOmitProps<UnitNumberInputProps> {
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* events are added / removed / dispatched via the eventManager
|
|
4
|
+
* the eventManager is just a div, the handling of events is purely through native event handlers
|
|
5
|
+
*/
|
|
6
|
+
interface IEventContext {
|
|
7
|
+
eventManagerRef: React.RefObject<Element>;
|
|
8
|
+
}
|
|
9
|
+
interface IProps {
|
|
10
|
+
children: ReactElement;
|
|
11
|
+
}
|
|
12
|
+
export declare const EventContext: import("react").Context<IEventContext>;
|
|
13
|
+
export declare const EventProvider: ({ children }: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./context-provider";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ControllerFieldState, ControllerRenderProps, UseFormSetValue, ValidationMode } from "react-hook-form";
|
|
1
|
+
import { ControllerFieldState, ControllerRenderProps, UseFormReset, UseFormSetValue, ValidationMode } from "react-hook-form";
|
|
2
|
+
import { IFilterSchema } from "../custom/filter/filter/types";
|
|
2
3
|
import { IAlertSchema, ITextSchema } from "../elements";
|
|
3
4
|
import { ISectionSchema } from "../elements/section";
|
|
4
5
|
import { IWrapperSchema } from "../elements/wrapper";
|
|
5
|
-
import { ICheckboxGroupSchema, IChipsSchema, IContactFieldSchema, IDateFieldSchema, IEmailFieldSchema, IMultiSelectSchema, INumericFieldSchema, IRadioButtonGroupSchema, ISelectSchema, ISubmitButtonSchema, ITextFieldSchema, ITextareaSchema, ITimeFieldSchema } from "../fields";
|
|
6
|
+
import { ICheckboxGroupSchema, IChipsSchema, IContactFieldSchema, IDateFieldSchema, IEmailFieldSchema, IImageUploadSchema, IMultiSelectSchema, INumericFieldSchema, IRadioButtonGroupSchema, IResetButtonSchema, ISelectSchema, ISubmitButtonSchema, ITextFieldSchema, ITextareaSchema, ITimeFieldSchema, IUnitNumberFieldSchema } from "../fields";
|
|
6
7
|
import { IYupValidationRule, TRenderRules, TYupSchemaType } from "./yup";
|
|
7
8
|
export type { IYupValidationRule } from "./yup";
|
|
8
9
|
export interface IFrontendEngineProps<V = undefined> {
|
|
@@ -35,25 +36,30 @@ export interface IFrontendEngineData<V = undefined> {
|
|
|
35
36
|
/** Validation strategy before a user submits the form (onSubmit event) */
|
|
36
37
|
validationMode?: TValidationMode | undefined;
|
|
37
38
|
}
|
|
38
|
-
export type TFrontendEngineFieldSchema<V = undefined> =
|
|
39
|
+
export type TFrontendEngineFieldSchema<V = undefined> = IAlertSchema | ICheckboxGroupSchema<V> | IChipsSchema<V> | IContactFieldSchema<V> | ICustomComponentJsonSchema<V> | IDateFieldSchema<V> | IEmailFieldSchema<V> | IFilterSchema | IImageUploadSchema<V> | IMultiSelectSchema<V> | INumericFieldSchema<V> | IRadioButtonGroupSchema<V> | IResetButtonSchema | ISelectSchema<V> | ISubmitButtonSchema | ITextSchema | ITextareaSchema<V> | ITextFieldSchema<V> | ITimeFieldSchema<V> | IUnitNumberFieldSchema<V> | IWrapperSchema;
|
|
39
40
|
export type TFrontendEngineValues<T = any> = Record<keyof T, T[keyof T]>;
|
|
40
41
|
export type TRevalidationMode = Exclude<keyof ValidationMode, "onTouched" | "all">;
|
|
41
42
|
export type TValidationMode = keyof ValidationMode;
|
|
42
43
|
export type TErrorMessage = string | string[] | Record<string, string | string[]>;
|
|
43
44
|
export type TErrorPayload = Record<string, TErrorMessage>;
|
|
44
45
|
export interface IFrontendEngineRef extends HTMLFormElement {
|
|
46
|
+
addCustomValidation: (type: TYupSchemaType | "mixed", name: string, fn: (value: unknown, arg: unknown) => boolean) => void;
|
|
47
|
+
addFieldEventListener: (type: string, id: string, listener: (ev: Event) => any, options?: boolean | AddEventListenerOptions) => void;
|
|
48
|
+
dispatchFieldEvent: (type: string, id: string, detail?: any) => boolean;
|
|
45
49
|
/** gets form values */
|
|
46
50
|
getValues: () => TFrontendEngineValues;
|
|
47
|
-
/** sets field value by id */
|
|
48
|
-
setValue: UseFormSetValue<TFrontendEngineValues>;
|
|
49
51
|
/** checks if form is valid */
|
|
50
52
|
isValid: () => boolean;
|
|
51
|
-
/** triggers form submission */
|
|
52
|
-
submit: () => void;
|
|
53
53
|
/** adds custom validation rule */
|
|
54
|
-
|
|
54
|
+
removeFieldEventListener: (type: string, id: string, listener: (ev: Event) => any, options?: boolean | EventListenerOptions) => void;
|
|
55
|
+
/** resets the form to the default state */
|
|
56
|
+
reset: UseFormReset<TFrontendEngineValues>;
|
|
55
57
|
/** allows setting of custom errors thrown by endpoints */
|
|
56
58
|
setErrors: (errors: TErrorPayload) => void;
|
|
59
|
+
/** sets field value by id */
|
|
60
|
+
setValue: UseFormSetValue<TFrontendEngineValues>;
|
|
61
|
+
/** triggers form submission */
|
|
62
|
+
submit: () => void;
|
|
57
63
|
}
|
|
58
64
|
export interface IFrontendEngineBaseFieldJsonSchema<T, V = undefined, U = undefined> {
|
|
59
65
|
/** defines what kind of component to be rendered */
|
|
@@ -72,11 +78,17 @@ export interface IFrontendEngineBaseFieldJsonSchema<T, V = undefined, U = undefi
|
|
|
72
78
|
/**
|
|
73
79
|
* to support custom components from other form / frontend engines
|
|
74
80
|
*/
|
|
75
|
-
export interface ICustomComponentJsonSchema {
|
|
76
|
-
referenceKey:
|
|
77
|
-
[otherOptions: string]: unknown;
|
|
81
|
+
export interface ICustomComponentJsonSchema<T> {
|
|
82
|
+
referenceKey: T;
|
|
78
83
|
uiType?: never | undefined;
|
|
79
84
|
}
|
|
85
|
+
export interface ICustomFieldJsonSchema<T, V = undefined, U = undefined> extends ICustomComponentJsonSchema<T> {
|
|
86
|
+
validation?: (V | U | IYupValidationRule)[];
|
|
87
|
+
/** render conditions
|
|
88
|
+
* - need to fulfil at least 1 object in array (OR condition)
|
|
89
|
+
* - in order for an object to be valid, need to fulfil all conditions in that object (AND condition) */
|
|
90
|
+
showIf?: TRenderRules[] | undefined;
|
|
91
|
+
}
|
|
80
92
|
/**
|
|
81
93
|
* JSON keys to omit from field schema when extending from other interfaces
|
|
82
94
|
* - keys already defined in `IFrontendEngineBaseFieldJsonSchema` to prevent collision
|
|
@@ -95,19 +107,22 @@ export type TComponentOmitProps<T, V = undefined> = Omit<T, UnionOptionalKeys<V>
|
|
|
95
107
|
* - components that can contain values that can get submitted
|
|
96
108
|
*/
|
|
97
109
|
export declare enum EFieldType {
|
|
98
|
-
TEXTAREA = "Textarea",
|
|
99
|
-
"TEXT-FIELD" = "TextField",
|
|
100
|
-
"NUMERIC-FIELD" = "TextField",
|
|
101
|
-
"EMAIL-FIELD" = "TextField",
|
|
102
|
-
SUBMIT = "SubmitButton",
|
|
103
|
-
SELECT = "Select",
|
|
104
|
-
"MULTI-SELECT" = "MultiSelect",
|
|
105
|
-
"DATE-FIELD" = "DateField",
|
|
106
110
|
CHECKBOX = "CheckboxGroup",
|
|
111
|
+
CHIPS = "Chips",
|
|
107
112
|
"CONTACT-FIELD" = "ContactField",
|
|
113
|
+
"DATE-FIELD" = "DateField",
|
|
114
|
+
"EMAIL-FIELD" = "TextField",
|
|
115
|
+
"IMAGE-UPLOAD" = "ImageUpload",
|
|
116
|
+
"MULTI-SELECT" = "MultiSelect",
|
|
117
|
+
"NUMERIC-FIELD" = "TextField",
|
|
108
118
|
RADIO = "RadioButtonGroup",
|
|
119
|
+
RESET = "ResetButton",
|
|
120
|
+
SELECT = "Select",
|
|
121
|
+
SUBMIT = "SubmitButton",
|
|
122
|
+
TEXTAREA = "Textarea",
|
|
123
|
+
"TEXT-FIELD" = "TextField",
|
|
109
124
|
"TIME-FIELD" = "TimeField",
|
|
110
|
-
|
|
125
|
+
"UNIT-NUMBER-FIELD" = "UnitNumberField"
|
|
111
126
|
}
|
|
112
127
|
/**
|
|
113
128
|
* Non-field types
|
|
@@ -140,6 +155,17 @@ export declare enum EElementType {
|
|
|
140
155
|
H6 = "Wrapper",
|
|
141
156
|
P = "Wrapper"
|
|
142
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Custom element types
|
|
160
|
+
* - components that do not have uiType and have specific schema to render
|
|
161
|
+
*/
|
|
162
|
+
export declare enum ECustomElementType {
|
|
163
|
+
FILTER = "Filter",
|
|
164
|
+
"FILTER-ITEM" = "FilterItem"
|
|
165
|
+
}
|
|
166
|
+
export declare enum ECustomFieldType {
|
|
167
|
+
"FILTER-CHECKBOX" = "FilterCheckbox"
|
|
168
|
+
}
|
|
143
169
|
export interface IGenericFieldProps<T = TFrontendEngineFieldSchema> extends Partial<ControllerFieldState>, Partial<ControllerRenderProps> {
|
|
144
170
|
id: string;
|
|
145
171
|
schema: T;
|
|
@@ -8,5 +8,5 @@ interface IProps {
|
|
|
8
8
|
children: ReactElement;
|
|
9
9
|
}
|
|
10
10
|
export declare const YupContext: React.Context<IYupContext>;
|
|
11
|
-
export declare const YupProvider: ({ children }: IProps) => JSX.Element;
|
|
11
|
+
export declare const YupProvider: ({ children }: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Yup from "yup";
|
|
2
2
|
export declare const YUP_TYPES: readonly ["string", "number", "boolean", "array", "object"];
|
|
3
|
-
export declare const YUP_CONDITIONS: readonly ["required", "length", "min", "max", "matches", "email", "url", "uuid", "positive", "negative", "integer", "lessThan", "moreThan", "when", "filled", "empty", "equals", "notEquals", "includes", "excludes", "uinfin"];
|
|
3
|
+
export declare const YUP_CONDITIONS: readonly ["required", "length", "min", "max", "matches", "email", "url", "uuid", "positive", "negative", "integer", "lessThan", "moreThan", "when", "filled", "empty", "equals", "notEquals", "includes", "excludes", "uinfin", "equalsField"];
|
|
4
4
|
export type TYupSchemaType = (typeof YUP_TYPES)[number];
|
|
5
5
|
export type TYupCondition = (typeof YUP_CONDITIONS)[number];
|
|
6
6
|
interface IYupRule {
|
|
@@ -22,6 +22,7 @@ interface IYupRule {
|
|
|
22
22
|
includes?: unknown | undefined;
|
|
23
23
|
excludes?: unknown | undefined;
|
|
24
24
|
uinfin?: boolean | undefined;
|
|
25
|
+
equalsField?: unknown | undefined;
|
|
25
26
|
}
|
|
26
27
|
export interface IYupValidationRule extends IYupRule {
|
|
27
28
|
required?: boolean | undefined;
|
|
@@ -2,5 +2,5 @@ import React from "react";
|
|
|
2
2
|
import { IChipButtonProps } from "./types";
|
|
3
3
|
interface IProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, IChipButtonProps {
|
|
4
4
|
}
|
|
5
|
-
export declare const Chip: ({ children, ...otherProps }: IProps) => JSX.Element;
|
|
5
|
+
export declare const Chip: ({ children, ...otherProps }: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|