formanitor 0.0.49 → 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.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;
@@ -526,7 +536,7 @@ interface OtpVerifiedValue {
526
536
  code: string;
527
537
  token?: string;
528
538
  }
529
- type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SliderFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | MediaUploadFieldDef | 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;
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;
530
540
  /** Boolean switch; value is `true` | `false`. */
531
541
  interface ToggleFieldDef extends BaseFieldDef {
532
542
  type: 'toggle';
@@ -1075,6 +1085,25 @@ interface FormControlsProps {
1075
1085
  }
1076
1086
  declare const FormControls: React.FC<FormControlsProps>;
1077
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
+
1078
1107
  declare const ImageUploadWidget: React.FC<{
1079
1108
  fieldId: string;
1080
1109
  }>;
@@ -1280,4 +1309,4 @@ declare const SmartTextareaWidget: React.FC<{
1280
1309
  fieldId: string;
1281
1310
  }>;
1282
1311
 
1283
- 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, 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, 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;
@@ -526,7 +536,7 @@ interface OtpVerifiedValue {
526
536
  code: string;
527
537
  token?: string;
528
538
  }
529
- type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SliderFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | MediaUploadFieldDef | 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;
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;
530
540
  /** Boolean switch; value is `true` | `false`. */
531
541
  interface ToggleFieldDef extends BaseFieldDef {
532
542
  type: 'toggle';
@@ -1075,6 +1085,25 @@ interface FormControlsProps {
1075
1085
  }
1076
1086
  declare const FormControls: React.FC<FormControlsProps>;
1077
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
+
1078
1107
  declare const ImageUploadWidget: React.FC<{
1079
1108
  fieldId: string;
1080
1109
  }>;
@@ -1280,4 +1309,4 @@ declare const SmartTextareaWidget: React.FC<{
1280
1309
  fieldId: string;
1281
1310
  }>;
1282
1311
 
1283
- 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, 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, 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.mjs CHANGED
@@ -1513,16 +1513,28 @@ var FormStore = class {
1513
1513
  result[field.id] = null;
1514
1514
  return;
1515
1515
  }
1516
- if (field.type === "image_upload" || field.type === "media_upload" || field.type === "signature") {
1516
+ if (field.type === "image_upload" || field.type === "media_upload" || field.type === "signature" || field.type === "file_upload") {
1517
1517
  const raw = values[field.id];
1518
- if (raw !== void 0 && raw !== null && raw !== "") {
1519
- const key = typeof raw === "string" ? raw : raw.s3_key || raw.value || null;
1520
- if (key && typeof key === "string") {
1521
- result[field.id] = {
1522
- _type: "s3_key",
1523
- value: key
1524
- };
1518
+ if (raw === void 0 || raw === null || raw === "") {
1519
+ return;
1520
+ }
1521
+ const wrapKey = (key2) => {
1522
+ if (typeof key2 !== "string" || !key2) return null;
1523
+ return { _type: "s3_key", value: key2 };
1524
+ };
1525
+ if (Array.isArray(raw)) {
1526
+ const wrapped2 = raw.map(
1527
+ (item) => typeof item === "string" ? wrapKey(item) : wrapKey(item.s3_key ?? item.value)
1528
+ ).filter(Boolean);
1529
+ if (wrapped2.length > 0) {
1530
+ result[field.id] = wrapped2;
1525
1531
  }
1532
+ return;
1533
+ }
1534
+ const key = typeof raw === "string" ? raw : raw.s3_key ?? raw.value ?? null;
1535
+ const wrapped = wrapKey(key);
1536
+ if (wrapped) {
1537
+ result[field.id] = wrapped;
1526
1538
  }
1527
1539
  }
1528
1540
  });
@@ -3760,6 +3772,190 @@ var SignatureUploadWidget = ({ fieldId }) => {
3760
3772
  showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
3761
3773
  ] });
3762
3774
  };
3775
+ function Upload3({
3776
+ value,
3777
+ accept,
3778
+ multiple,
3779
+ disabled,
3780
+ onChange,
3781
+ className,
3782
+ formatsLabel,
3783
+ placeholder = "Upload File",
3784
+ beforeUploadContent,
3785
+ id: idProp
3786
+ }) {
3787
+ const inputRef = React15__default.useRef(null);
3788
+ const generatedId = React15__default.useId();
3789
+ const inputId = idProp ?? generatedId;
3790
+ const handleFileChange = (e) => {
3791
+ onChange(e.target.files ?? null);
3792
+ };
3793
+ React15__default.useEffect(() => {
3794
+ if (!value && inputRef.current) {
3795
+ inputRef.current.value = "";
3796
+ }
3797
+ }, [value]);
3798
+ const count = value?.length ?? 0;
3799
+ const formatsText = formatsLabel ?? accept;
3800
+ return /* @__PURE__ */ jsxs(
3801
+ "div",
3802
+ {
3803
+ className: cn(
3804
+ "border border-dashed bg-[#F7F7F7] border-gray-200 rounded-lg py-5 px-4 flex items-center justify-center text-[#989898]",
3805
+ disabled && "opacity-50 pointer-events-none",
3806
+ className
3807
+ ),
3808
+ children: [
3809
+ /* @__PURE__ */ jsx(
3810
+ "input",
3811
+ {
3812
+ type: "file",
3813
+ ref: inputRef,
3814
+ accept,
3815
+ id: inputId,
3816
+ className: "hidden",
3817
+ multiple,
3818
+ disabled,
3819
+ onChange: handleFileChange
3820
+ }
3821
+ ),
3822
+ /* @__PURE__ */ jsx(
3823
+ "label",
3824
+ {
3825
+ htmlFor: inputId,
3826
+ className: cn("cursor-pointer w-full", disabled && "cursor-not-allowed"),
3827
+ children: /* @__PURE__ */ jsx("div", { children: count > 0 ? /* @__PURE__ */ jsxs("div", { className: "text-center text-sm font-semibold text-gray-700", children: [
3828
+ count,
3829
+ " file",
3830
+ count === 1 ? "" : "s",
3831
+ " selected"
3832
+ ] }) : beforeUploadContent ? beforeUploadContent : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center", children: [
3833
+ /* @__PURE__ */ jsx(Upload, { size: 16, className: "rotate-180" }),
3834
+ /* @__PURE__ */ jsx("div", { className: "text-xs font-semibold mt-0.5 text-gray-700", children: placeholder }),
3835
+ formatsText ? /* @__PURE__ */ jsxs("div", { className: "mt-3 text-[10px]", children: [
3836
+ "Supported formats - ",
3837
+ formatsText
3838
+ ] }) : null
3839
+ ] }) })
3840
+ }
3841
+ )
3842
+ ]
3843
+ }
3844
+ );
3845
+ }
3846
+ function fileListFromArray(files) {
3847
+ const dt = new DataTransfer();
3848
+ files.forEach((f) => dt.items.add(f));
3849
+ return dt.files;
3850
+ }
3851
+ function matchesAccept(file, accept) {
3852
+ if (!accept || accept === "*/*") return true;
3853
+ const tokens = accept.split(",").map((t) => t.trim().toLowerCase());
3854
+ const name = file.name.toLowerCase();
3855
+ const type = file.type.toLowerCase();
3856
+ return tokens.some((token) => {
3857
+ if (token.startsWith(".")) return name.endsWith(token);
3858
+ if (token.endsWith("/*")) {
3859
+ const prefix = token.slice(0, -1);
3860
+ return type.startsWith(prefix);
3861
+ }
3862
+ return type === token;
3863
+ });
3864
+ }
3865
+ var FormFileUploadWidget = ({
3866
+ fieldId
3867
+ }) => {
3868
+ const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
3869
+ const store = useFormStore();
3870
+ const { state } = useForm();
3871
+ const [localFiles, setLocalFiles] = useState(null);
3872
+ const [isUploading, setIsUploading] = useState(false);
3873
+ const showError = !!error && (touched || state.submitAttempted);
3874
+ if (!fieldDef || fieldDef.type !== "file_upload") return null;
3875
+ const def = fieldDef;
3876
+ const accept = def.accept ?? "*/*";
3877
+ const maxSize = def.maxSize ?? 10 * 1024 * 1024;
3878
+ const allowMultiple = def.multiple === true;
3879
+ const uploadHandler = store.getUploadHandler();
3880
+ if (!uploadHandler) {
3881
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3882
+ /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
3883
+ fieldDef.label,
3884
+ fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
3885
+ ] }),
3886
+ /* @__PURE__ */ jsx("div", { className: "border-2 border-red-300 rounded-lg p-4 bg-red-50", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600", children: "Upload handler not configured. Please provide an onUpload function in FormProvider config." }) })
3887
+ ] });
3888
+ }
3889
+ const hasStoredValue = value !== null && value !== void 0 && value !== "" && !(Array.isArray(value) && value.length === 0);
3890
+ const handleChange = async (files) => {
3891
+ setTouched();
3892
+ if (!files || files.length === 0) {
3893
+ setLocalFiles(null);
3894
+ setValue(null);
3895
+ return;
3896
+ }
3897
+ const selected = Array.from(files);
3898
+ for (const file of selected) {
3899
+ if (!matchesAccept(file, accept)) {
3900
+ alert(`File type not allowed: ${file.name}`);
3901
+ return;
3902
+ }
3903
+ if (file.size > maxSize) {
3904
+ alert(
3905
+ `File must be less than ${Math.round(maxSize / (1024 * 1024))}MB: ${file.name}`
3906
+ );
3907
+ return;
3908
+ }
3909
+ }
3910
+ const toUpload = allowMultiple ? selected : [selected[0]];
3911
+ setLocalFiles(fileListFromArray(toUpload));
3912
+ setIsUploading(true);
3913
+ store.incrementPendingUploads();
3914
+ try {
3915
+ if (allowMultiple) {
3916
+ const keys = [];
3917
+ for (const file of toUpload) {
3918
+ keys.push(await uploadHandler(file, file.name));
3919
+ }
3920
+ setValue(keys);
3921
+ } else {
3922
+ const key = await uploadHandler(toUpload[0], toUpload[0].name);
3923
+ setValue(key);
3924
+ }
3925
+ } catch (err) {
3926
+ console.error("[FormFileUpload] Upload failed:", err);
3927
+ const message = err instanceof Error ? err.message : "Upload failed. Please try again.";
3928
+ alert(message);
3929
+ setLocalFiles(null);
3930
+ setValue(null);
3931
+ } finally {
3932
+ setIsUploading(false);
3933
+ store.decrementPendingUploads();
3934
+ }
3935
+ };
3936
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3937
+ /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
3938
+ fieldDef.label,
3939
+ fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
3940
+ ] }),
3941
+ /* @__PURE__ */ jsx(
3942
+ Upload3,
3943
+ {
3944
+ accept,
3945
+ multiple: allowMultiple,
3946
+ value: localFiles,
3947
+ onChange: handleChange,
3948
+ disabled: disabled || isUploading,
3949
+ placeholder: isUploading ? "Uploading..." : def.uploadPlaceholder ?? "Upload File",
3950
+ formatsLabel: def.uploadFormats,
3951
+ className: isUploading ? "opacity-70" : void 0
3952
+ }
3953
+ ),
3954
+ hasStoredValue && /* @__PURE__ */ jsx("p", { className: "text-xs text-green-600", children: allowMultiple && Array.isArray(value) ? `${value.length} file(s) uploaded` : "File uploaded" }),
3955
+ fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500", children: fieldDef.description }),
3956
+ showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
3957
+ ] });
3958
+ };
3763
3959
  var EditableTableWidget = ({
3764
3960
  fieldId
3765
3961
  }) => {
@@ -14207,6 +14403,8 @@ function renderWidget(fieldId, fieldDef) {
14207
14403
  return /* @__PURE__ */ jsx(ImageUploadWidget, { fieldId });
14208
14404
  case "media_upload":
14209
14405
  return /* @__PURE__ */ jsx(MediaUploadWidget, { fieldId });
14406
+ case "file_upload":
14407
+ return /* @__PURE__ */ jsx(FormFileUploadWidget, { fieldId });
14210
14408
  case "signature":
14211
14409
  return /* @__PURE__ */ jsx(SignatureUploadWidget, { fieldId });
14212
14410
  case "editable_table":
@@ -15305,6 +15503,8 @@ var ReadOnlyFieldRenderer = ({
15305
15503
  return /* @__PURE__ */ jsx(ReadOnlyImageUpload, { fieldDef, value });
15306
15504
  case "media_upload":
15307
15505
  return /* @__PURE__ */ jsx(ReadOnlyMediaUpload, { fieldDef, value });
15506
+ case "file_upload":
15507
+ return /* @__PURE__ */ jsx(ReadOnlyMediaUpload, { fieldDef, value });
15308
15508
  case "signature":
15309
15509
  return /* @__PURE__ */ jsx(ReadOnlySignature, { fieldDef, value });
15310
15510
  case "editable_table":
@@ -15799,6 +15999,6 @@ function createUploadHandler(options) {
15799
15999
  };
15800
16000
  }
15801
16001
 
15802
- export { AddInvestigationField, AddMedicationField, DifferentialDiagnosis, DynamicForm, DynamicFormV2, EMAIL_REGEX, FieldRenderer, FormControls, FormProvider, FormStore, ImageUploadWidget, MAR_MEDICATION_ORDERS_META_KEY, MediaUploadWidget, MultiStepForm, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, RichTextWidget, SignatureUploadWidget, SmartForm, SmartTextareaWidget, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
16002
+ export { AddInvestigationField, AddMedicationField, DifferentialDiagnosis, DynamicForm, DynamicFormV2, EMAIL_REGEX, FieldRenderer, FormControls, FormFileUploadWidget, FormProvider, FormStore, ImageUploadWidget, MAR_MEDICATION_ORDERS_META_KEY, MediaUploadWidget, MultiStepForm, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, RichTextWidget, SignatureUploadWidget, SmartForm, SmartTextareaWidget, Upload3 as Upload, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
15803
16003
  //# sourceMappingURL=index.mjs.map
15804
16004
  //# sourceMappingURL=index.mjs.map