@lifesg/web-frontend-engine 1.0.0-alpha.3 → 1.0.0-alpha.4
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/cjs/index.js +88 -84
- 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 +2 -1
- 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/index.d.ts +2 -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 +1 -0
- package/components/fields/radio-button/types.d.ts +9 -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 +5 -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/textarea/textarea.d.ts +1 -2
- 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/types.d.ts +29 -7
- package/components/frontend-engine/yup/context-provider.d.ts +1 -1
- package/components/shared/chip/chip.d.ts +1 -1
- package/components/shared/error-messages.d.ts +3 -0
- package/components/shared/sanitize/sanitize.d.ts +1 -1
- package/index.js +95 -91
- package/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -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
|
+
}
|
|
@@ -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, 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,7 +36,7 @@ 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> = ITextareaSchema<V> | ITextFieldSchema<V> | IEmailFieldSchema<V> | INumericFieldSchema<V> | ISubmitButtonSchema | ISelectSchema<V> | IMultiSelectSchema<V> | ICheckboxGroupSchema<V> | IDateFieldSchema<V> | IWrapperSchema | IContactFieldSchema<V> | IRadioButtonGroupSchema<V> | ITimeFieldSchema<V> | IChipsSchema<V> | IAlertSchema | ITextSchema | ICustomComponentJsonSchema
|
|
39
|
+
export type TFrontendEngineFieldSchema<V = undefined> = ITextareaSchema<V> | ITextFieldSchema<V> | IEmailFieldSchema<V> | INumericFieldSchema<V> | ISubmitButtonSchema | ISelectSchema<V> | IMultiSelectSchema<V> | ICheckboxGroupSchema<V> | IDateFieldSchema<V> | IWrapperSchema | IContactFieldSchema<V> | IRadioButtonGroupSchema<V> | ITimeFieldSchema<V> | IChipsSchema<V> | IUnitNumberFieldSchema<V> | IAlertSchema | ITextSchema | IResetButtonSchema | IFilterSchema | ICustomComponentJsonSchema<V>;
|
|
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;
|
|
@@ -54,6 +55,8 @@ export interface IFrontendEngineRef extends HTMLFormElement {
|
|
|
54
55
|
addCustomValidation: (type: TYupSchemaType | "mixed", name: string, fn: (value: unknown, arg: unknown) => boolean) => void;
|
|
55
56
|
/** allows setting of custom errors thrown by endpoints */
|
|
56
57
|
setErrors: (errors: TErrorPayload) => void;
|
|
58
|
+
/** resets the form to the default state */
|
|
59
|
+
reset: UseFormReset<TFrontendEngineValues>;
|
|
57
60
|
}
|
|
58
61
|
export interface IFrontendEngineBaseFieldJsonSchema<T, V = undefined, U = undefined> {
|
|
59
62
|
/** defines what kind of component to be rendered */
|
|
@@ -72,11 +75,17 @@ export interface IFrontendEngineBaseFieldJsonSchema<T, V = undefined, U = undefi
|
|
|
72
75
|
/**
|
|
73
76
|
* to support custom components from other form / frontend engines
|
|
74
77
|
*/
|
|
75
|
-
export interface ICustomComponentJsonSchema {
|
|
76
|
-
referenceKey:
|
|
77
|
-
[otherOptions: string]: unknown;
|
|
78
|
+
export interface ICustomComponentJsonSchema<T> {
|
|
79
|
+
referenceKey: T;
|
|
78
80
|
uiType?: never | undefined;
|
|
79
81
|
}
|
|
82
|
+
export interface ICustomFieldJsonSchema<T, V = undefined, U = undefined> extends ICustomComponentJsonSchema<T> {
|
|
83
|
+
validation?: (V | U | IYupValidationRule)[];
|
|
84
|
+
/** render conditions
|
|
85
|
+
* - need to fulfil at least 1 object in array (OR condition)
|
|
86
|
+
* - in order for an object to be valid, need to fulfil all conditions in that object (AND condition) */
|
|
87
|
+
showIf?: TRenderRules[] | undefined;
|
|
88
|
+
}
|
|
80
89
|
/**
|
|
81
90
|
* JSON keys to omit from field schema when extending from other interfaces
|
|
82
91
|
* - keys already defined in `IFrontendEngineBaseFieldJsonSchema` to prevent collision
|
|
@@ -107,7 +116,9 @@ export declare enum EFieldType {
|
|
|
107
116
|
"CONTACT-FIELD" = "ContactField",
|
|
108
117
|
RADIO = "RadioButtonGroup",
|
|
109
118
|
"TIME-FIELD" = "TimeField",
|
|
110
|
-
CHIPS = "Chips"
|
|
119
|
+
CHIPS = "Chips",
|
|
120
|
+
RESET = "ResetButton",
|
|
121
|
+
"UNIT-NUMBER-FIELD" = "UnitNumberField"
|
|
111
122
|
}
|
|
112
123
|
/**
|
|
113
124
|
* Non-field types
|
|
@@ -140,6 +151,17 @@ export declare enum EElementType {
|
|
|
140
151
|
H6 = "Wrapper",
|
|
141
152
|
P = "Wrapper"
|
|
142
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Custom element types
|
|
156
|
+
* - components that do not have uiType and have specific schema to render
|
|
157
|
+
*/
|
|
158
|
+
export declare enum ECustomElementType {
|
|
159
|
+
FILTER = "Filter",
|
|
160
|
+
"FILTER-ITEM" = "FilterItem"
|
|
161
|
+
}
|
|
162
|
+
export declare enum ECustomFieldType {
|
|
163
|
+
"FILTER-CHECKBOX" = "FilterCheckbox"
|
|
164
|
+
}
|
|
143
165
|
export interface IGenericFieldProps<T = TFrontendEngineFieldSchema> extends Partial<ControllerFieldState>, Partial<ControllerRenderProps> {
|
|
144
166
|
id: string;
|
|
145
167
|
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 {};
|
|
@@ -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 {};
|