formanitor 0.0.48 → 0.0.50
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/index.cjs +867 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -5
- package/dist/index.d.ts +129 -5
- package/dist/index.mjs +865 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
|
-
type FieldType = 'text' | 'number' | 'textarea' | 'diagnosis_textarea' | 'richtext' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'media_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | 'toggle' | 'urology_smart_history' | 'urology_examination' | 'urology_pathway' | string;
|
|
4
|
+
type FieldType = 'text' | 'number' | 'textarea' | 'diagnosis_textarea' | 'richtext' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'media_upload' | 'file_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | 'toggle' | 'urology_smart_history' | 'urology_examination' | 'urology_pathway' | string;
|
|
4
5
|
interface ValidationRule {
|
|
5
6
|
min?: number;
|
|
6
7
|
max?: number;
|
|
@@ -128,6 +129,15 @@ interface MediaUploadFieldDef extends BaseFieldDef {
|
|
|
128
129
|
/** Default: images (image/*) and application/pdf */
|
|
129
130
|
acceptedTypes?: string[];
|
|
130
131
|
}
|
|
132
|
+
interface FileUploadFieldDef extends BaseFieldDef {
|
|
133
|
+
type: 'file_upload';
|
|
134
|
+
/** HTML accept string, e.g. "application/pdf,image/*" */
|
|
135
|
+
accept?: string;
|
|
136
|
+
multiple?: boolean;
|
|
137
|
+
maxSize?: number;
|
|
138
|
+
uploadPlaceholder?: string;
|
|
139
|
+
uploadFormats?: string;
|
|
140
|
+
}
|
|
131
141
|
interface SignatureFieldDef extends BaseFieldDef {
|
|
132
142
|
type: 'signature';
|
|
133
143
|
canvasWidth?: number;
|
|
@@ -500,7 +510,33 @@ interface DiagnosticPackage {
|
|
|
500
510
|
department?: string;
|
|
501
511
|
tests: DiagnosticPackageTest[];
|
|
502
512
|
}
|
|
503
|
-
|
|
513
|
+
interface PhoneInputFieldDef extends BaseFieldDef {
|
|
514
|
+
type: 'phone_input';
|
|
515
|
+
meta?: {
|
|
516
|
+
/** ID of the sibling otp_input field to clear when the phone is edited after a send. */
|
|
517
|
+
otpFieldId?: string;
|
|
518
|
+
/** Country code prefix, e.g. "+91". Defaults to "+91". */
|
|
519
|
+
countryCode?: string;
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
interface OtpInputFieldDef extends BaseFieldDef {
|
|
523
|
+
type: 'otp_input';
|
|
524
|
+
meta?: {
|
|
525
|
+
/** ID of the sibling phone_input field to read the number from. Defaults to "phone". */
|
|
526
|
+
phoneFieldId?: string;
|
|
527
|
+
/** Number of OTP digits. Defaults to 4. */
|
|
528
|
+
length?: 4 | 6;
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/** Value shape stored in the form store after a successful OTP verification. */
|
|
532
|
+
interface OtpVerifiedValue {
|
|
533
|
+
verified: true;
|
|
534
|
+
phone: string;
|
|
535
|
+
/** Digits the user entered; included so submissions can persist `otp_code`. */
|
|
536
|
+
code: string;
|
|
537
|
+
token?: string;
|
|
538
|
+
}
|
|
539
|
+
type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SliderFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | MediaUploadFieldDef | FileUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | DiagnosisTextareaFieldDef | SuggestionTextareaFieldDef | LensAssessmentFieldDef | FunctionalImpairmentScoreFieldDef | ToggleFieldDef | BiometryIolWorkupFieldDef | SurgicalRiskFlagsFieldDef | GeneralSurgerySmartHistoryFieldDef | GeneralSurgeryExaminationFieldDef | GeneralSurgeryGradingFieldDef | UrologySmartHistoryFieldDef | UrologyExaminationFieldDef | UrologyPathwayFieldDef | OBGExaminationFieldDef | OBGPathwayFieldDef | PainScaleFlagsFieldDef | PhoneInputFieldDef | OtpInputFieldDef | BaseFieldDef;
|
|
504
540
|
/** Boolean switch; value is `true` | `false`. */
|
|
505
541
|
interface ToggleFieldDef extends BaseFieldDef {
|
|
506
542
|
type: 'toggle';
|
|
@@ -555,7 +591,27 @@ interface Section {
|
|
|
555
591
|
title: string;
|
|
556
592
|
children: SectionChild[];
|
|
557
593
|
}
|
|
558
|
-
|
|
594
|
+
interface MultiStepNode {
|
|
595
|
+
type: 'section';
|
|
596
|
+
id: string;
|
|
597
|
+
title: string;
|
|
598
|
+
children: SectionChild[];
|
|
599
|
+
}
|
|
600
|
+
interface MultiStepLayoutNode {
|
|
601
|
+
type: 'multi_step';
|
|
602
|
+
id: string;
|
|
603
|
+
title?: string;
|
|
604
|
+
steps: MultiStepNode[];
|
|
605
|
+
meta?: {
|
|
606
|
+
/** Show step indicator header. Default true. */
|
|
607
|
+
showStepper?: boolean;
|
|
608
|
+
/** Visual style for the stepper. Default 'numbered'. */
|
|
609
|
+
stepperVariant?: 'numbered' | 'dots' | 'labels';
|
|
610
|
+
/** Collapse completed steps into an accordion. Default true. */
|
|
611
|
+
collapseCompleted?: boolean;
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
type LayoutNode = Section | ColumnLayout | MultiStepLayoutNode;
|
|
559
615
|
interface WebhookDef {
|
|
560
616
|
method: 'GET' | 'POST' | 'PUT';
|
|
561
617
|
url: string;
|
|
@@ -662,6 +718,21 @@ type Listener = (state: FormState) => void;
|
|
|
662
718
|
type EventListener = (event: string, payload?: any) => void;
|
|
663
719
|
type UploadHandler = (file: File | Blob, filename: string) => Promise<string>;
|
|
664
720
|
type DraftChangeHandler = (payload: SavedState) => void | Promise<void>;
|
|
721
|
+
interface StoreAuthConfig {
|
|
722
|
+
/**
|
|
723
|
+
* Base URL for OTP API calls. Defaults to `process.env.NEXT_PUBLIC_API_URL` when not set.
|
|
724
|
+
* Set this in the host app to decouple the library from Next.js env vars.
|
|
725
|
+
*/
|
|
726
|
+
baseUrl?: string;
|
|
727
|
+
/** Path to send OTP. Defaults to "/api/auth/otp/send/". */
|
|
728
|
+
sendPath?: string;
|
|
729
|
+
/** Path to resend OTP. Defaults to "/api/auth/otp/resend/". */
|
|
730
|
+
resendPath?: string;
|
|
731
|
+
/** Path to verify OTP. Defaults to "/api/auth/otp/verify/". */
|
|
732
|
+
verifyPath?: string;
|
|
733
|
+
/** Country code prefix for phone numbers. Defaults to "+91". */
|
|
734
|
+
defaultCountryCode?: string;
|
|
735
|
+
}
|
|
665
736
|
interface StoreConfig {
|
|
666
737
|
persistence?: PersistenceProvider;
|
|
667
738
|
prefillData?: Record<string, any>;
|
|
@@ -669,6 +740,11 @@ interface StoreConfig {
|
|
|
669
740
|
onEvent?: EventListener;
|
|
670
741
|
onUpload?: UploadHandler;
|
|
671
742
|
onDraftChange?: DraftChangeHandler;
|
|
743
|
+
/**
|
|
744
|
+
* Auth / OTP configuration. Lets the host app supply the API base URL and
|
|
745
|
+
* paths so the library doesn't depend on Next.js environment variables.
|
|
746
|
+
*/
|
|
747
|
+
auth?: StoreAuthConfig;
|
|
672
748
|
/**
|
|
673
749
|
* Voice dictation support. When provided, fields marked with `voice: true`
|
|
674
750
|
* in the schema will display a microphone button.
|
|
@@ -689,6 +765,7 @@ declare class FormStore {
|
|
|
689
765
|
private persistence;
|
|
690
766
|
private prefillData;
|
|
691
767
|
private config;
|
|
768
|
+
private externalErrors;
|
|
692
769
|
private saveTimeout;
|
|
693
770
|
private draftCallbackTimeout;
|
|
694
771
|
constructor(schema: FormDef, config?: StoreConfig);
|
|
@@ -702,6 +779,7 @@ declare class FormStore {
|
|
|
702
779
|
disabled: boolean;
|
|
703
780
|
};
|
|
704
781
|
getSchema(): FormDef;
|
|
782
|
+
getConfig(): StoreConfig;
|
|
705
783
|
getFieldDef(fieldId: string): FieldDef | undefined;
|
|
706
784
|
getVoice(): StoreConfig['voice'];
|
|
707
785
|
hasPersistence(): boolean;
|
|
@@ -715,6 +793,12 @@ declare class FormStore {
|
|
|
715
793
|
setValues(partial: Record<string, any>, options?: {
|
|
716
794
|
touch?: boolean;
|
|
717
795
|
}): void;
|
|
796
|
+
/**
|
|
797
|
+
* Let a widget report an error that schema validation cannot express
|
|
798
|
+
* (e.g. "Send OTP to continue" until the API call succeeds).
|
|
799
|
+
* Pass `null` to clear a previously set external error.
|
|
800
|
+
*/
|
|
801
|
+
setExternalError(fieldId: string, message: string | null): void;
|
|
718
802
|
setTouched(fieldId: string): void;
|
|
719
803
|
setRole(role: string): void;
|
|
720
804
|
load(): Promise<void>;
|
|
@@ -773,7 +857,12 @@ declare class FormStore {
|
|
|
773
857
|
}
|
|
774
858
|
|
|
775
859
|
declare const EMAIL_REGEX: RegExp;
|
|
776
|
-
|
|
860
|
+
/**
|
|
861
|
+
* Validate a single field.
|
|
862
|
+
* Pass `allValues` when you need cross-field validation (e.g. otp_input checking the
|
|
863
|
+
* sibling phone field's value).
|
|
864
|
+
*/
|
|
865
|
+
declare function validateField(value: any, field: FieldDef, allValues?: Record<string, any>): string | null;
|
|
777
866
|
declare function validateForm(values: Record<string, any>, fields: Record<string, FieldDef>): Record<string, string | null>;
|
|
778
867
|
|
|
779
868
|
interface RuleResult {
|
|
@@ -887,6 +976,20 @@ interface DynamicFormV2Props {
|
|
|
887
976
|
*/
|
|
888
977
|
declare const DynamicFormV2: React.FC<DynamicFormV2Props>;
|
|
889
978
|
|
|
979
|
+
interface MultiStepFormProps {
|
|
980
|
+
/** When true, renders `schema.title` as the page heading. Default true. */
|
|
981
|
+
showTitle?: boolean;
|
|
982
|
+
className?: string;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Renders a form schema that may contain `multi_step` layout nodes in addition
|
|
986
|
+
* to the standard `section` / `column_layout` nodes.
|
|
987
|
+
*
|
|
988
|
+
* Multi-step groups unlock steps linearly: a step becomes visible only when
|
|
989
|
+
* all fields in the previous step are valid (no errors, required fields filled).
|
|
990
|
+
*/
|
|
991
|
+
declare const MultiStepForm: React.FC<MultiStepFormProps>;
|
|
992
|
+
|
|
890
993
|
/** Shape of one differential diagnosis item from AI (must match form field value) */
|
|
891
994
|
type AIDifferentialDiagnosisItem = {
|
|
892
995
|
category: string;
|
|
@@ -977,9 +1080,30 @@ interface FormControlsProps {
|
|
|
977
1080
|
buttonClassName?: string;
|
|
978
1081
|
onSaveDraft?: () => void;
|
|
979
1082
|
onSubmit?: (to: string) => void;
|
|
1083
|
+
/** Override the label on the submit/transition button. Defaults to "Submit". */
|
|
1084
|
+
submitLabel?: string;
|
|
980
1085
|
}
|
|
981
1086
|
declare const FormControls: React.FC<FormControlsProps>;
|
|
982
1087
|
|
|
1088
|
+
interface UploadProps {
|
|
1089
|
+
accept?: string;
|
|
1090
|
+
multiple?: boolean;
|
|
1091
|
+
disabled?: boolean;
|
|
1092
|
+
value?: FileList | File[] | null;
|
|
1093
|
+
onChange: (files: FileList | null) => void;
|
|
1094
|
+
className?: string;
|
|
1095
|
+
/** Shown under placeholder, e.g. "PDF, PNG, JPG" */
|
|
1096
|
+
formatsLabel?: string;
|
|
1097
|
+
placeholder?: string;
|
|
1098
|
+
beforeUploadContent?: React.ReactNode;
|
|
1099
|
+
id?: string;
|
|
1100
|
+
}
|
|
1101
|
+
declare function Upload({ value, accept, multiple, disabled, onChange, className, formatsLabel, placeholder, beforeUploadContent, id: idProp, }: UploadProps): react_jsx_runtime.JSX.Element;
|
|
1102
|
+
|
|
1103
|
+
declare const FormFileUploadWidget: React.FC<{
|
|
1104
|
+
fieldId: string;
|
|
1105
|
+
}>;
|
|
1106
|
+
|
|
983
1107
|
declare const ImageUploadWidget: React.FC<{
|
|
984
1108
|
fieldId: string;
|
|
985
1109
|
}>;
|
|
@@ -1185,4 +1309,4 @@ declare const SmartTextareaWidget: React.FC<{
|
|
|
1185
1309
|
fieldId: string;
|
|
1186
1310
|
}>;
|
|
1187
1311
|
|
|
1188
|
-
export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type BiometryIolWorkupFieldDef, type BiometryIolWorkupValue, type BiometryMethod, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, type DiagnosticPackage, type DiagnosticPackageTest, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, DynamicFormV2, type DynamicFormV2Props, type DynamicFormV2SectionMode, EMAIL_REGEX, type EditableTableColumnDef, type EditableTableFieldDef, type EventDefinition, type ExtractedKeywordMatch, type FieldDef, type FieldHandler, type FieldHandlersMap, type FieldPrefill, FieldRenderer, type FieldState, type FieldType, type FollowupFieldDef, type FollowupValue, FormControls, type FormControlsProps, type FormDef, type FormErrors, FormProvider, type FormState, FormStore, type FormValues, type FormulaComputation, type FormulaExpr, type FunctionalImpairmentDimension, type FunctionalImpairmentScoreFieldDef, type FunctionalImpairmentScoreValue, type GeneralSurgeryExaminationFieldDef, type GeneralSurgeryGradingFieldDef, type GeneralSurgerySmartHistoryFieldDef, type ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type LensAssessmentFieldDef, type LensAssessmentValue, type LocsGrades, MAR_MEDICATION_ORDERS_META_KEY, type MatchedCondition, type MediaUploadFieldDef, MediaUploadWidget, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type OBGExaminationFieldDef, type OBGPathwayFieldDef, type PainScaleFlagsFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, type RichTextFieldDef, RichTextWidget, type Rule, type RuleAction, type RuleResult, type ScoreComputation, type ScoreRange, type Section, type SectionChild, type SelectFieldDef, type SelectOption, type SignatureFieldDef, SignatureUploadWidget, type SliderFieldDef, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SuggestionTextareaFieldDef, type SumComputation, type SurgicalRiskFlagsFieldDef, type SurgicalRiskFlagsValue, type TextFieldDef, type ToggleFieldDef, type UrologyExaminationFieldDef, type UrologyPathwayFieldDef, type UrologySmartHistoryFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
|
1312
|
+
export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type BiometryIolWorkupFieldDef, type BiometryIolWorkupValue, type BiometryMethod, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, type DiagnosticPackage, type DiagnosticPackageTest, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, DynamicFormV2, type DynamicFormV2Props, type DynamicFormV2SectionMode, EMAIL_REGEX, type EditableTableColumnDef, type EditableTableFieldDef, type EventDefinition, type ExtractedKeywordMatch, type FieldDef, type FieldHandler, type FieldHandlersMap, type FieldPrefill, FieldRenderer, type FieldState, type FieldType, type FileUploadFieldDef, type FollowupFieldDef, type FollowupValue, FormControls, type FormControlsProps, type FormDef, type FormErrors, FormFileUploadWidget, FormProvider, type FormState, FormStore, type FormValues, type FormulaComputation, type FormulaExpr, type FunctionalImpairmentDimension, type FunctionalImpairmentScoreFieldDef, type FunctionalImpairmentScoreValue, type GeneralSurgeryExaminationFieldDef, type GeneralSurgeryGradingFieldDef, type GeneralSurgerySmartHistoryFieldDef, type ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type LensAssessmentFieldDef, type LensAssessmentValue, type LocsGrades, MAR_MEDICATION_ORDERS_META_KEY, type MatchedCondition, type MediaUploadFieldDef, MediaUploadWidget, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, MultiStepForm, type MultiStepFormProps, type MultiStepLayoutNode, type MultiStepNode, type NumberFieldDef, type OBGExaminationFieldDef, type OBGPathwayFieldDef, type OtpInputFieldDef, type OtpVerifiedValue, type PainScaleFlagsFieldDef, type Permission, type PhoneInputFieldDef, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, type RichTextFieldDef, RichTextWidget, type Rule, type RuleAction, type RuleResult, type ScoreComputation, type ScoreRange, type Section, type SectionChild, type SelectFieldDef, type SelectOption, type SignatureFieldDef, SignatureUploadWidget, type SliderFieldDef, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreAuthConfig, type StoreConfig, type SubmissionData, type SuggestionTextareaFieldDef, type SumComputation, type SurgicalRiskFlagsFieldDef, type SurgicalRiskFlagsValue, type TextFieldDef, type ToggleFieldDef, Upload, type UploadProps, type UrologyExaminationFieldDef, type UrologyPathwayFieldDef, type UrologySmartHistoryFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
|
-
type FieldType = 'text' | 'number' | 'textarea' | 'diagnosis_textarea' | 'richtext' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'media_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | 'toggle' | 'urology_smart_history' | 'urology_examination' | 'urology_pathway' | string;
|
|
4
|
+
type FieldType = 'text' | 'number' | 'textarea' | 'diagnosis_textarea' | 'richtext' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'media_upload' | 'file_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | 'toggle' | 'urology_smart_history' | 'urology_examination' | 'urology_pathway' | string;
|
|
4
5
|
interface ValidationRule {
|
|
5
6
|
min?: number;
|
|
6
7
|
max?: number;
|
|
@@ -128,6 +129,15 @@ interface MediaUploadFieldDef extends BaseFieldDef {
|
|
|
128
129
|
/** Default: images (image/*) and application/pdf */
|
|
129
130
|
acceptedTypes?: string[];
|
|
130
131
|
}
|
|
132
|
+
interface FileUploadFieldDef extends BaseFieldDef {
|
|
133
|
+
type: 'file_upload';
|
|
134
|
+
/** HTML accept string, e.g. "application/pdf,image/*" */
|
|
135
|
+
accept?: string;
|
|
136
|
+
multiple?: boolean;
|
|
137
|
+
maxSize?: number;
|
|
138
|
+
uploadPlaceholder?: string;
|
|
139
|
+
uploadFormats?: string;
|
|
140
|
+
}
|
|
131
141
|
interface SignatureFieldDef extends BaseFieldDef {
|
|
132
142
|
type: 'signature';
|
|
133
143
|
canvasWidth?: number;
|
|
@@ -500,7 +510,33 @@ interface DiagnosticPackage {
|
|
|
500
510
|
department?: string;
|
|
501
511
|
tests: DiagnosticPackageTest[];
|
|
502
512
|
}
|
|
503
|
-
|
|
513
|
+
interface PhoneInputFieldDef extends BaseFieldDef {
|
|
514
|
+
type: 'phone_input';
|
|
515
|
+
meta?: {
|
|
516
|
+
/** ID of the sibling otp_input field to clear when the phone is edited after a send. */
|
|
517
|
+
otpFieldId?: string;
|
|
518
|
+
/** Country code prefix, e.g. "+91". Defaults to "+91". */
|
|
519
|
+
countryCode?: string;
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
interface OtpInputFieldDef extends BaseFieldDef {
|
|
523
|
+
type: 'otp_input';
|
|
524
|
+
meta?: {
|
|
525
|
+
/** ID of the sibling phone_input field to read the number from. Defaults to "phone". */
|
|
526
|
+
phoneFieldId?: string;
|
|
527
|
+
/** Number of OTP digits. Defaults to 4. */
|
|
528
|
+
length?: 4 | 6;
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/** Value shape stored in the form store after a successful OTP verification. */
|
|
532
|
+
interface OtpVerifiedValue {
|
|
533
|
+
verified: true;
|
|
534
|
+
phone: string;
|
|
535
|
+
/** Digits the user entered; included so submissions can persist `otp_code`. */
|
|
536
|
+
code: string;
|
|
537
|
+
token?: string;
|
|
538
|
+
}
|
|
539
|
+
type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SliderFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | MediaUploadFieldDef | FileUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | DiagnosisTextareaFieldDef | SuggestionTextareaFieldDef | LensAssessmentFieldDef | FunctionalImpairmentScoreFieldDef | ToggleFieldDef | BiometryIolWorkupFieldDef | SurgicalRiskFlagsFieldDef | GeneralSurgerySmartHistoryFieldDef | GeneralSurgeryExaminationFieldDef | GeneralSurgeryGradingFieldDef | UrologySmartHistoryFieldDef | UrologyExaminationFieldDef | UrologyPathwayFieldDef | OBGExaminationFieldDef | OBGPathwayFieldDef | PainScaleFlagsFieldDef | PhoneInputFieldDef | OtpInputFieldDef | BaseFieldDef;
|
|
504
540
|
/** Boolean switch; value is `true` | `false`. */
|
|
505
541
|
interface ToggleFieldDef extends BaseFieldDef {
|
|
506
542
|
type: 'toggle';
|
|
@@ -555,7 +591,27 @@ interface Section {
|
|
|
555
591
|
title: string;
|
|
556
592
|
children: SectionChild[];
|
|
557
593
|
}
|
|
558
|
-
|
|
594
|
+
interface MultiStepNode {
|
|
595
|
+
type: 'section';
|
|
596
|
+
id: string;
|
|
597
|
+
title: string;
|
|
598
|
+
children: SectionChild[];
|
|
599
|
+
}
|
|
600
|
+
interface MultiStepLayoutNode {
|
|
601
|
+
type: 'multi_step';
|
|
602
|
+
id: string;
|
|
603
|
+
title?: string;
|
|
604
|
+
steps: MultiStepNode[];
|
|
605
|
+
meta?: {
|
|
606
|
+
/** Show step indicator header. Default true. */
|
|
607
|
+
showStepper?: boolean;
|
|
608
|
+
/** Visual style for the stepper. Default 'numbered'. */
|
|
609
|
+
stepperVariant?: 'numbered' | 'dots' | 'labels';
|
|
610
|
+
/** Collapse completed steps into an accordion. Default true. */
|
|
611
|
+
collapseCompleted?: boolean;
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
type LayoutNode = Section | ColumnLayout | MultiStepLayoutNode;
|
|
559
615
|
interface WebhookDef {
|
|
560
616
|
method: 'GET' | 'POST' | 'PUT';
|
|
561
617
|
url: string;
|
|
@@ -662,6 +718,21 @@ type Listener = (state: FormState) => void;
|
|
|
662
718
|
type EventListener = (event: string, payload?: any) => void;
|
|
663
719
|
type UploadHandler = (file: File | Blob, filename: string) => Promise<string>;
|
|
664
720
|
type DraftChangeHandler = (payload: SavedState) => void | Promise<void>;
|
|
721
|
+
interface StoreAuthConfig {
|
|
722
|
+
/**
|
|
723
|
+
* Base URL for OTP API calls. Defaults to `process.env.NEXT_PUBLIC_API_URL` when not set.
|
|
724
|
+
* Set this in the host app to decouple the library from Next.js env vars.
|
|
725
|
+
*/
|
|
726
|
+
baseUrl?: string;
|
|
727
|
+
/** Path to send OTP. Defaults to "/api/auth/otp/send/". */
|
|
728
|
+
sendPath?: string;
|
|
729
|
+
/** Path to resend OTP. Defaults to "/api/auth/otp/resend/". */
|
|
730
|
+
resendPath?: string;
|
|
731
|
+
/** Path to verify OTP. Defaults to "/api/auth/otp/verify/". */
|
|
732
|
+
verifyPath?: string;
|
|
733
|
+
/** Country code prefix for phone numbers. Defaults to "+91". */
|
|
734
|
+
defaultCountryCode?: string;
|
|
735
|
+
}
|
|
665
736
|
interface StoreConfig {
|
|
666
737
|
persistence?: PersistenceProvider;
|
|
667
738
|
prefillData?: Record<string, any>;
|
|
@@ -669,6 +740,11 @@ interface StoreConfig {
|
|
|
669
740
|
onEvent?: EventListener;
|
|
670
741
|
onUpload?: UploadHandler;
|
|
671
742
|
onDraftChange?: DraftChangeHandler;
|
|
743
|
+
/**
|
|
744
|
+
* Auth / OTP configuration. Lets the host app supply the API base URL and
|
|
745
|
+
* paths so the library doesn't depend on Next.js environment variables.
|
|
746
|
+
*/
|
|
747
|
+
auth?: StoreAuthConfig;
|
|
672
748
|
/**
|
|
673
749
|
* Voice dictation support. When provided, fields marked with `voice: true`
|
|
674
750
|
* in the schema will display a microphone button.
|
|
@@ -689,6 +765,7 @@ declare class FormStore {
|
|
|
689
765
|
private persistence;
|
|
690
766
|
private prefillData;
|
|
691
767
|
private config;
|
|
768
|
+
private externalErrors;
|
|
692
769
|
private saveTimeout;
|
|
693
770
|
private draftCallbackTimeout;
|
|
694
771
|
constructor(schema: FormDef, config?: StoreConfig);
|
|
@@ -702,6 +779,7 @@ declare class FormStore {
|
|
|
702
779
|
disabled: boolean;
|
|
703
780
|
};
|
|
704
781
|
getSchema(): FormDef;
|
|
782
|
+
getConfig(): StoreConfig;
|
|
705
783
|
getFieldDef(fieldId: string): FieldDef | undefined;
|
|
706
784
|
getVoice(): StoreConfig['voice'];
|
|
707
785
|
hasPersistence(): boolean;
|
|
@@ -715,6 +793,12 @@ declare class FormStore {
|
|
|
715
793
|
setValues(partial: Record<string, any>, options?: {
|
|
716
794
|
touch?: boolean;
|
|
717
795
|
}): void;
|
|
796
|
+
/**
|
|
797
|
+
* Let a widget report an error that schema validation cannot express
|
|
798
|
+
* (e.g. "Send OTP to continue" until the API call succeeds).
|
|
799
|
+
* Pass `null` to clear a previously set external error.
|
|
800
|
+
*/
|
|
801
|
+
setExternalError(fieldId: string, message: string | null): void;
|
|
718
802
|
setTouched(fieldId: string): void;
|
|
719
803
|
setRole(role: string): void;
|
|
720
804
|
load(): Promise<void>;
|
|
@@ -773,7 +857,12 @@ declare class FormStore {
|
|
|
773
857
|
}
|
|
774
858
|
|
|
775
859
|
declare const EMAIL_REGEX: RegExp;
|
|
776
|
-
|
|
860
|
+
/**
|
|
861
|
+
* Validate a single field.
|
|
862
|
+
* Pass `allValues` when you need cross-field validation (e.g. otp_input checking the
|
|
863
|
+
* sibling phone field's value).
|
|
864
|
+
*/
|
|
865
|
+
declare function validateField(value: any, field: FieldDef, allValues?: Record<string, any>): string | null;
|
|
777
866
|
declare function validateForm(values: Record<string, any>, fields: Record<string, FieldDef>): Record<string, string | null>;
|
|
778
867
|
|
|
779
868
|
interface RuleResult {
|
|
@@ -887,6 +976,20 @@ interface DynamicFormV2Props {
|
|
|
887
976
|
*/
|
|
888
977
|
declare const DynamicFormV2: React.FC<DynamicFormV2Props>;
|
|
889
978
|
|
|
979
|
+
interface MultiStepFormProps {
|
|
980
|
+
/** When true, renders `schema.title` as the page heading. Default true. */
|
|
981
|
+
showTitle?: boolean;
|
|
982
|
+
className?: string;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Renders a form schema that may contain `multi_step` layout nodes in addition
|
|
986
|
+
* to the standard `section` / `column_layout` nodes.
|
|
987
|
+
*
|
|
988
|
+
* Multi-step groups unlock steps linearly: a step becomes visible only when
|
|
989
|
+
* all fields in the previous step are valid (no errors, required fields filled).
|
|
990
|
+
*/
|
|
991
|
+
declare const MultiStepForm: React.FC<MultiStepFormProps>;
|
|
992
|
+
|
|
890
993
|
/** Shape of one differential diagnosis item from AI (must match form field value) */
|
|
891
994
|
type AIDifferentialDiagnosisItem = {
|
|
892
995
|
category: string;
|
|
@@ -977,9 +1080,30 @@ interface FormControlsProps {
|
|
|
977
1080
|
buttonClassName?: string;
|
|
978
1081
|
onSaveDraft?: () => void;
|
|
979
1082
|
onSubmit?: (to: string) => void;
|
|
1083
|
+
/** Override the label on the submit/transition button. Defaults to "Submit". */
|
|
1084
|
+
submitLabel?: string;
|
|
980
1085
|
}
|
|
981
1086
|
declare const FormControls: React.FC<FormControlsProps>;
|
|
982
1087
|
|
|
1088
|
+
interface UploadProps {
|
|
1089
|
+
accept?: string;
|
|
1090
|
+
multiple?: boolean;
|
|
1091
|
+
disabled?: boolean;
|
|
1092
|
+
value?: FileList | File[] | null;
|
|
1093
|
+
onChange: (files: FileList | null) => void;
|
|
1094
|
+
className?: string;
|
|
1095
|
+
/** Shown under placeholder, e.g. "PDF, PNG, JPG" */
|
|
1096
|
+
formatsLabel?: string;
|
|
1097
|
+
placeholder?: string;
|
|
1098
|
+
beforeUploadContent?: React.ReactNode;
|
|
1099
|
+
id?: string;
|
|
1100
|
+
}
|
|
1101
|
+
declare function Upload({ value, accept, multiple, disabled, onChange, className, formatsLabel, placeholder, beforeUploadContent, id: idProp, }: UploadProps): react_jsx_runtime.JSX.Element;
|
|
1102
|
+
|
|
1103
|
+
declare const FormFileUploadWidget: React.FC<{
|
|
1104
|
+
fieldId: string;
|
|
1105
|
+
}>;
|
|
1106
|
+
|
|
983
1107
|
declare const ImageUploadWidget: React.FC<{
|
|
984
1108
|
fieldId: string;
|
|
985
1109
|
}>;
|
|
@@ -1185,4 +1309,4 @@ declare const SmartTextareaWidget: React.FC<{
|
|
|
1185
1309
|
fieldId: string;
|
|
1186
1310
|
}>;
|
|
1187
1311
|
|
|
1188
|
-
export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type BiometryIolWorkupFieldDef, type BiometryIolWorkupValue, type BiometryMethod, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, type DiagnosticPackage, type DiagnosticPackageTest, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, DynamicFormV2, type DynamicFormV2Props, type DynamicFormV2SectionMode, EMAIL_REGEX, type EditableTableColumnDef, type EditableTableFieldDef, type EventDefinition, type ExtractedKeywordMatch, type FieldDef, type FieldHandler, type FieldHandlersMap, type FieldPrefill, FieldRenderer, type FieldState, type FieldType, type FollowupFieldDef, type FollowupValue, FormControls, type FormControlsProps, type FormDef, type FormErrors, FormProvider, type FormState, FormStore, type FormValues, type FormulaComputation, type FormulaExpr, type FunctionalImpairmentDimension, type FunctionalImpairmentScoreFieldDef, type FunctionalImpairmentScoreValue, type GeneralSurgeryExaminationFieldDef, type GeneralSurgeryGradingFieldDef, type GeneralSurgerySmartHistoryFieldDef, type ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type LensAssessmentFieldDef, type LensAssessmentValue, type LocsGrades, MAR_MEDICATION_ORDERS_META_KEY, type MatchedCondition, type MediaUploadFieldDef, MediaUploadWidget, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type OBGExaminationFieldDef, type OBGPathwayFieldDef, type PainScaleFlagsFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, type RichTextFieldDef, RichTextWidget, type Rule, type RuleAction, type RuleResult, type ScoreComputation, type ScoreRange, type Section, type SectionChild, type SelectFieldDef, type SelectOption, type SignatureFieldDef, SignatureUploadWidget, type SliderFieldDef, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SuggestionTextareaFieldDef, type SumComputation, type SurgicalRiskFlagsFieldDef, type SurgicalRiskFlagsValue, type TextFieldDef, type ToggleFieldDef, type UrologyExaminationFieldDef, type UrologyPathwayFieldDef, type UrologySmartHistoryFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
|
1312
|
+
export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type BiometryIolWorkupFieldDef, type BiometryIolWorkupValue, type BiometryMethod, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, type DiagnosticPackage, type DiagnosticPackageTest, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, DynamicFormV2, type DynamicFormV2Props, type DynamicFormV2SectionMode, EMAIL_REGEX, type EditableTableColumnDef, type EditableTableFieldDef, type EventDefinition, type ExtractedKeywordMatch, type FieldDef, type FieldHandler, type FieldHandlersMap, type FieldPrefill, FieldRenderer, type FieldState, type FieldType, type FileUploadFieldDef, type FollowupFieldDef, type FollowupValue, FormControls, type FormControlsProps, type FormDef, type FormErrors, FormFileUploadWidget, FormProvider, type FormState, FormStore, type FormValues, type FormulaComputation, type FormulaExpr, type FunctionalImpairmentDimension, type FunctionalImpairmentScoreFieldDef, type FunctionalImpairmentScoreValue, type GeneralSurgeryExaminationFieldDef, type GeneralSurgeryGradingFieldDef, type GeneralSurgerySmartHistoryFieldDef, type ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type LensAssessmentFieldDef, type LensAssessmentValue, type LocsGrades, MAR_MEDICATION_ORDERS_META_KEY, type MatchedCondition, type MediaUploadFieldDef, MediaUploadWidget, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, MultiStepForm, type MultiStepFormProps, type MultiStepLayoutNode, type MultiStepNode, type NumberFieldDef, type OBGExaminationFieldDef, type OBGPathwayFieldDef, type OtpInputFieldDef, type OtpVerifiedValue, type PainScaleFlagsFieldDef, type Permission, type PhoneInputFieldDef, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, type ReferralFieldDef, type ReferralItem, type RepeatableFieldDef, type RichTextFieldDef, RichTextWidget, type Rule, type RuleAction, type RuleResult, type ScoreComputation, type ScoreRange, type Section, type SectionChild, type SelectFieldDef, type SelectOption, type SignatureFieldDef, SignatureUploadWidget, type SliderFieldDef, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreAuthConfig, type StoreConfig, type SubmissionData, type SuggestionTextareaFieldDef, type SumComputation, type SurgicalRiskFlagsFieldDef, type SurgicalRiskFlagsValue, type TextFieldDef, type ToggleFieldDef, Upload, type UploadProps, type UrologyExaminationFieldDef, type UrologyPathwayFieldDef, type UrologySmartHistoryFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|