@hievilmath/browser-formidavim 1.2.0 → 1.2.2

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.
@@ -2,7 +2,7 @@ import { FC, PropsWithChildren } from 'react';
2
2
  export declare const DataRenderer: FC<PropsWithChildren<{
3
3
  dataFetcher?: () => Promise<any>;
4
4
  configFetcher?: () => Promise<any>;
5
- onSubmit?: () => Promise<any>;
5
+ onSubmit?: (formData: any) => Promise<any>;
6
6
  isPreview?: boolean;
7
7
  flowName?: string;
8
8
  version?: string;
@@ -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
  }>;
@@ -4,5 +4,5 @@ export declare const Renderer: FC<{
4
4
  data: PatientProfileDto | null;
5
5
  config: Partial<Flow>;
6
6
  isPreview: boolean;
7
- onSubmit: () => Promise<any>;
7
+ onSubmit: (formData: any) => Promise<any>;
8
8
  }>;
@@ -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
+ }>;
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
2
  import { FormComponent } from '../../../../../../axios/formidavim/src/index.ts';
3
- export declare const Checkbox: FC<{
3
+ export declare const CheckboxSingle: FC<{
4
4
  formComponent: Partial<FormComponent>;
5
5
  }>;
@@ -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
  }>;
@@ -1,7 +1,9 @@
1
1
  import { FC } from 'react';
2
2
  import { FormComponent } from '../../../../../../axios/formidavim/src/index.ts';
3
3
  export interface NewComponentProps {
4
- src: string;
4
+ label: string;
5
+ required: boolean;
6
+ propertyId: string;
5
7
  }
6
8
  export declare const NewComponent: FC<{
7
9
  formComponent: Partial<FormComponent>;
@@ -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, 'string' | 'number' | 'boolean' | 'array' | 'boolean[]'>;
4
+ export declare const COMPONENT_CONFIGS: Record<string, string | number | boolean | boolean[] | any[]>;
5
5
  export declare const components: ComponentMap;
@@ -3,6 +3,7 @@ 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;
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hievilmath/browser-formidavim",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "main": "./index.js",
5
5
  "module": "./index.mjs",
6
6
  "typings": "./index.d.ts",