@hievilmath/browser-formidavim 1.1.6 → 1.2.1
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/index.css +1 -0
- package/index.js +242 -237
- package/index.mjs +6225 -3337
- package/lib/components/DataRenderer.d.ts +10 -0
- package/lib/components/FlowFormRenderer.d.ts +2 -0
- package/lib/components/FlowRenderer.d.ts +15 -2
- package/lib/components/FormRenderer.d.ts +2 -0
- package/lib/components/Renderer.d.ts +1 -1
- package/lib/components/index.d.ts +1 -2
- package/lib/components/inputs/CheckboxMulti.d.ts +9 -0
- package/lib/components/inputs/{Checkbox.d.ts → CheckboxSingle.d.ts} +1 -1
- package/lib/components/inputs/Date.d.ts +10 -0
- package/lib/components/inputs/Number.d.ts +8 -0
- package/lib/components/inputs/Select.d.ts +15 -0
- package/lib/components/inputs/template.d.ts +7 -2
- package/lib/components/visual/RefillRequest.d.ts +8 -0
- package/lib/constants/components.d.ts +1 -1
- package/lib/constants/theme.d.ts +1 -0
- package/lib/hooks/useConditionEvaluator.d.ts +1 -1
- package/lib/hooks/useFlowStore.d.ts +3 -1
- package/lib/styled-components/layout.d.ts +2 -2
- package/lib/utils/conditionEvaluator.d.ts +4 -7
- package/lib/utils/templateProcessor.d.ts +8 -0
- package/lib/utils/validation.d.ts +29 -0
- package/lib/utils/valueConversion.d.ts +46 -0
- package/package.json +4 -2
- package/lib/components/NetworkAwareWrapper.d.ts +0 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
export declare const DataRenderer: FC<PropsWithChildren<{
|
|
3
|
+
dataFetcher?: () => Promise<any>;
|
|
4
|
+
configFetcher?: () => Promise<any>;
|
|
5
|
+
onSubmit?: (formData: any) => Promise<any>;
|
|
6
|
+
isPreview?: boolean;
|
|
7
|
+
flowName?: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
formidavimHost?: string;
|
|
10
|
+
}>>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { FlowForm } from '../../../../../axios/formidavim/src/index.ts';
|
|
3
|
+
import { EvaluatedFormComponent } from './FlowRenderer';
|
|
3
4
|
export declare const FlowFormRenderer: FC<{
|
|
4
5
|
flowForm: Partial<FlowForm>;
|
|
5
6
|
isPreview: boolean;
|
|
7
|
+
evaluatedFormComponents?: EvaluatedFormComponent[];
|
|
6
8
|
}>;
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { Flow } from '../../../../../axios/formidavim/src/index.ts';
|
|
2
|
+
import { Flow, FlowForm, FormComponent } from '../../../../../axios/formidavim/src/index.ts';
|
|
3
|
+
export interface EvaluatedFormComponent extends FormComponent {
|
|
4
|
+
isVisible: boolean;
|
|
5
|
+
shouldRender: boolean;
|
|
6
|
+
hasCondition: boolean;
|
|
7
|
+
props?: {
|
|
8
|
+
required?: boolean | string;
|
|
9
|
+
propertyId?: string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface EvaluatedFlowForm extends FlowForm {
|
|
14
|
+
evaluatedFormComponents?: EvaluatedFormComponent[];
|
|
15
|
+
}
|
|
3
16
|
export declare const FlowRenderer: FC<{
|
|
4
17
|
flow: Partial<Flow>;
|
|
5
18
|
isPreview: boolean;
|
|
6
19
|
$bgColor?: string;
|
|
7
|
-
onSubmit: () => Promise<any>;
|
|
20
|
+
onSubmit: (formData: any) => Promise<any>;
|
|
8
21
|
}>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { Form } from '../../../../../axios/formidavim/src/index.ts';
|
|
3
|
+
import { EvaluatedFormComponent } from './FlowRenderer';
|
|
3
4
|
export declare const FormRenderer: FC<{
|
|
4
5
|
form: Form;
|
|
5
6
|
isPreview: boolean;
|
|
7
|
+
evaluatedFormComponents: EvaluatedFormComponent[];
|
|
6
8
|
}>;
|
|
@@ -6,7 +6,6 @@ export { FlowFormRenderer } from './FlowFormRenderer';
|
|
|
6
6
|
export { FormRenderer } from './FormRenderer';
|
|
7
7
|
export { FormComponentRenderer } from './FormComponentRenderer';
|
|
8
8
|
export { FormWrapper } from './FormWrapper';
|
|
9
|
-
export {
|
|
9
|
+
export { DataRenderer } from './DataRenderer';
|
|
10
10
|
export { DemoConsumer } from './DemoConsumer';
|
|
11
|
-
export { evaluateCondition } from '../utils/conditionEvaluator';
|
|
12
11
|
export { ComponentFactory } from './ComponentFactory';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormComponent } from '../../../../../../axios/formidavim/src/index.ts';
|
|
3
|
+
export interface CheckboxOption {
|
|
4
|
+
value: string;
|
|
5
|
+
labelText: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const CheckboxMulti: FC<{
|
|
8
|
+
formComponent: Partial<FormComponent>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormComponent } from '../../../../../../axios/formidavim/src/index.ts';
|
|
3
|
+
export interface DatePickerProps {
|
|
4
|
+
label: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
propertyId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const DatePickerInput: FC<{
|
|
9
|
+
formComponent: Partial<FormComponent>;
|
|
10
|
+
}>;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { FormComponent } from '../../../../../../axios/formidavim/src/index.ts';
|
|
3
|
+
export interface NumberInputProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
propertyId: string;
|
|
7
|
+
max: number;
|
|
8
|
+
min: number;
|
|
9
|
+
allowLeadingZero?: boolean;
|
|
10
|
+
}
|
|
3
11
|
export declare const NumberInput: FC<{
|
|
4
12
|
formComponent: Partial<FormComponent>;
|
|
5
13
|
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormComponent } from '../../../../../../axios/formidavim/src/index.ts';
|
|
3
|
+
export interface SelectOption {
|
|
4
|
+
value: string;
|
|
5
|
+
labelText: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SelectProps {
|
|
8
|
+
label: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
propertyId: string;
|
|
11
|
+
options: SelectOption[];
|
|
12
|
+
}
|
|
13
|
+
export declare const Select: FC<{
|
|
14
|
+
formComponent: Partial<FormComponent>;
|
|
15
|
+
}>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { FormComponent } from '../../../../../../axios/formidavim/src/index.ts';
|
|
2
3
|
export interface NewComponentProps {
|
|
3
|
-
|
|
4
|
+
label: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
propertyId: string;
|
|
4
7
|
}
|
|
5
|
-
export declare const NewComponent: FC<
|
|
8
|
+
export declare const NewComponent: FC<{
|
|
9
|
+
formComponent: Partial<FormComponent>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormComponent } from '../../../../../../axios/formidavim/src/index.ts';
|
|
3
|
+
export interface RefillRequestProps {
|
|
4
|
+
medication: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const RefillRequest: FC<{
|
|
7
|
+
formComponent: Partial<FormComponent>;
|
|
8
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { FormComponentProps } from '../components/ComponentFactory';
|
|
3
3
|
export type ComponentMap = Record<string, FC<FormComponentProps>>;
|
|
4
|
-
export declare const COMPONENT_CONFIGS: Record<string,
|
|
4
|
+
export declare const COMPONENT_CONFIGS: Record<string, string | number | boolean | boolean[] | any[]>;
|
|
5
5
|
export declare const components: ComponentMap;
|
package/lib/constants/theme.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { Condition } from '../../../../../axios/formidavim/src/index.ts';
|
|
|
3
3
|
* Custom hook for evaluating conditions
|
|
4
4
|
*/
|
|
5
5
|
export declare const useConditionEvaluator: () => {
|
|
6
|
-
evaluateCondition: (condition: Condition | undefined) => boolean
|
|
6
|
+
evaluateCondition: (condition: Condition | undefined) => Promise<boolean>;
|
|
7
7
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Flow } from '../../../../../axios/formidavim/src/index.ts';
|
|
1
|
+
import { Flow, PatientProfileDto } from '../../../../../axios/formidavim/src/index.ts';
|
|
2
2
|
export declare const useFlowStore: () => {
|
|
3
3
|
setFlowValue: (field: string, value: any) => void;
|
|
4
4
|
setFlowValues: (values: Record<string, any>) => void;
|
|
5
5
|
getFlowValue: (field: string) => any;
|
|
6
|
+
getAllFlowData: () => Record<string, any>;
|
|
6
7
|
setPatientValue: (field: string, value: any) => void;
|
|
7
8
|
setPatientValues: (profile: any) => void;
|
|
8
9
|
getPatientValue: (field: string) => string | undefined;
|
|
10
|
+
getFullPatient: () => PatientProfileDto | null;
|
|
9
11
|
setFlowAndPatientValue: (field: string, value: any) => void;
|
|
10
12
|
generateFormDataFromFlow: (flow: Partial<Flow>) => Record<string, any>;
|
|
11
13
|
};
|
|
@@ -98,7 +98,7 @@ interface CRAccordionWrapperProps {
|
|
|
98
98
|
$open?: string;
|
|
99
99
|
}
|
|
100
100
|
interface FormSelectWrapperProps {
|
|
101
|
-
$visible?:
|
|
101
|
+
$visible?: boolean;
|
|
102
102
|
$hasError?: boolean;
|
|
103
103
|
}
|
|
104
104
|
interface FormFileWrapperProps {
|
|
@@ -108,7 +108,7 @@ interface FormFileWrapperProps {
|
|
|
108
108
|
$isMultiple?: boolean;
|
|
109
109
|
}
|
|
110
110
|
interface FormDatePickerWrapperProps {
|
|
111
|
-
$visible?:
|
|
111
|
+
$visible?: boolean;
|
|
112
112
|
$margin?: string;
|
|
113
113
|
$hasError?: boolean;
|
|
114
114
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Condition, PatientProfileDto } from '../../../../../axios/formidavim/src/index.ts';
|
|
2
2
|
type GetFieldValueFn = (field: string) => any;
|
|
3
|
+
type GetFullPatientFn = () => PatientProfileDto | null;
|
|
3
4
|
/**
|
|
4
5
|
* Evaluates condition groups using flow store data
|
|
5
6
|
* Each condition group is an array of IndividualCondition that should be ANDed together
|
|
@@ -7,12 +8,8 @@ type GetFieldValueFn = (field: string) => any;
|
|
|
7
8
|
*
|
|
8
9
|
* @param condition - The condition object containing condition groups
|
|
9
10
|
* @param getFieldValue - Function to get field values from the flow store
|
|
10
|
-
* @
|
|
11
|
+
* @param getFullPatient - Function to get the full patient data
|
|
12
|
+
* @returns Promise<boolean> indicating if any condition group is satisfied
|
|
11
13
|
*/
|
|
12
|
-
export declare const evaluateConditionWithFlowStore: (condition: Condition | undefined, getFieldValue: GetFieldValueFn) => boolean
|
|
13
|
-
/**
|
|
14
|
-
* Legacy function for backward compatibility
|
|
15
|
-
* @deprecated Use evaluateConditionWithFlowStore instead
|
|
16
|
-
*/
|
|
17
|
-
export declare const evaluateCondition: (condition: Condition | undefined, data: PatientProfileDto) => boolean;
|
|
14
|
+
export declare const evaluateConditionWithFlowStore: (condition: Condition | undefined, getFieldValue: GetFieldValueFn, getFullPatient: GetFullPatientFn) => Promise<boolean>;
|
|
18
15
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Flow, PatientProfileDto } from '../../../../../axios/formidavim/src/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a Flow config to replace all template expressions in form component props
|
|
4
|
+
* @param config - The Flow configuration to process
|
|
5
|
+
* @param patientData - The patient data for template evaluation
|
|
6
|
+
* @returns Promise<Partial<Flow>> - The processed Flow config
|
|
7
|
+
*/
|
|
8
|
+
export declare const processFlowConfig: (config: Partial<Flow>, patientData: PatientProfileDto | null) => Promise<Partial<Flow>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EvaluatedFormComponent } from '../components/FlowRenderer';
|
|
2
|
+
/**
|
|
3
|
+
* Validates that all required visible fields have values
|
|
4
|
+
*/
|
|
5
|
+
export declare const validateRequiredFields: (evaluatedComponents: EvaluatedFormComponent[], getFlowValue: (field: string) => any) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Get all required components that are currently visible
|
|
8
|
+
*/
|
|
9
|
+
export declare const getRequiredVisibleComponents: (evaluatedComponents: EvaluatedFormComponent[]) => EvaluatedFormComponent[];
|
|
10
|
+
/**
|
|
11
|
+
* Get validation errors for the current form components
|
|
12
|
+
*/
|
|
13
|
+
export declare const getValidationErrors: (evaluatedComponents: EvaluatedFormComponent[], getFlowValue: (field: string) => any) => string[];
|
|
14
|
+
/**
|
|
15
|
+
* Get detailed validation information for debugging
|
|
16
|
+
*/
|
|
17
|
+
export declare const getValidationInfo: (evaluatedComponents: EvaluatedFormComponent[], getFlowValue: (field: string) => any) => {
|
|
18
|
+
totalComponents: number;
|
|
19
|
+
visibleComponents: number;
|
|
20
|
+
requiredComponents: number;
|
|
21
|
+
missingRequired: number;
|
|
22
|
+
missingFields: {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string | undefined;
|
|
25
|
+
propertyId: string | undefined;
|
|
26
|
+
value: any;
|
|
27
|
+
}[];
|
|
28
|
+
isValid: boolean;
|
|
29
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for converting between null and empty string values
|
|
3
|
+
* for form inputs that require string values but store null for empty data
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Converts null or undefined values to empty string for display in input elements
|
|
7
|
+
* @param value - The value to convert
|
|
8
|
+
* @returns Empty string if value is null/undefined, otherwise the string representation of the value
|
|
9
|
+
*/
|
|
10
|
+
export declare const nullToEmptyString: (value: any) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Converts empty strings back to null for storage
|
|
13
|
+
* @param value - The string value to convert
|
|
14
|
+
* @returns null if the string is empty, otherwise the original string
|
|
15
|
+
*/
|
|
16
|
+
export declare const emptyStringToNull: (value: string) => string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Converts string representations back to boolean values for storage
|
|
19
|
+
* @param value - The string value to convert ('true' or 'false')
|
|
20
|
+
* @returns true for 'true', false for 'false'
|
|
21
|
+
*/
|
|
22
|
+
export declare const stringToBoolean: (value: string) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Smart conversion for form values - converts boolean strings to actual booleans for storage
|
|
25
|
+
* @param value - The form value to convert
|
|
26
|
+
* @returns boolean if value is 'true'/'false', otherwise returns the original value
|
|
27
|
+
*/
|
|
28
|
+
export declare const convertForStorage: (value: any) => any;
|
|
29
|
+
/**
|
|
30
|
+
* Smart conversion for form display - converts boolean values to strings for form inputs
|
|
31
|
+
* @param value - The stored value to convert
|
|
32
|
+
* @returns string representation if value is boolean, otherwise returns the original value
|
|
33
|
+
*/
|
|
34
|
+
export declare const convertForDisplay: (value: any) => any;
|
|
35
|
+
/**
|
|
36
|
+
* Converts number values to string representation for display in number inputs
|
|
37
|
+
* @param value - The number value to convert
|
|
38
|
+
* @returns String representation of the number, or empty string for null/undefined
|
|
39
|
+
*/
|
|
40
|
+
export declare const numberToString: (value: number | null | undefined) => string;
|
|
41
|
+
/**
|
|
42
|
+
* Converts string representations back to number values for storage
|
|
43
|
+
* @param value - The string value to convert
|
|
44
|
+
* @returns number if valid, null for empty strings, NaN for invalid strings
|
|
45
|
+
*/
|
|
46
|
+
export declare const stringToNumber: (value: string) => number | null;
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hievilmath/browser-formidavim",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"module": "./index.mjs",
|
|
6
6
|
"typings": "./index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@hievilmath/axios-formidavim": "1.1.1"
|
|
8
|
+
"@hievilmath/axios-formidavim": "1.1.1",
|
|
9
|
+
"jsonata": "^2.1.0"
|
|
9
10
|
},
|
|
10
11
|
"peerDependencies": {
|
|
11
12
|
"axios": "*",
|
|
12
13
|
"react": "*",
|
|
14
|
+
"react-datepicker": "*",
|
|
13
15
|
"react-redux": "*",
|
|
14
16
|
"react-router-dom": "*",
|
|
15
17
|
"styled-components": "*"
|