formanitor 0.1.4 → 0.1.5
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 +28 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -17
- package/dist/index.d.ts +3 -17
- package/dist/index.mjs +29 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -770,10 +770,7 @@ interface StoreConfig {
|
|
|
770
770
|
prefillData?: Record<string, any>;
|
|
771
771
|
role?: string;
|
|
772
772
|
onEvent?: EventListener;
|
|
773
|
-
/** Handler for image, media, and signature uploads; fallback for file upload when `onFileUpload` is omitted. */
|
|
774
773
|
onUpload?: UploadHandler;
|
|
775
|
-
/** Optional handler for `file_upload` fields only (`FormFileUploadWidget`). Uses `onUpload` when not set. */
|
|
776
|
-
onFileUpload?: UploadHandler;
|
|
777
774
|
onDraftChange?: DraftChangeHandler;
|
|
778
775
|
/**
|
|
779
776
|
* Auth / OTP configuration. Lets the host app supply the API base URL and
|
|
@@ -875,8 +872,6 @@ declare class FormStore {
|
|
|
875
872
|
*/
|
|
876
873
|
updateConfig(next: Partial<StoreConfig>): void;
|
|
877
874
|
getUploadHandler(): UploadHandler | undefined;
|
|
878
|
-
/** Resolved handler for `file_upload` widgets: `onFileUpload` ?? `onUpload`. */
|
|
879
|
-
getFileUploadHandler(): UploadHandler | undefined;
|
|
880
875
|
private preSubmitHandlers;
|
|
881
876
|
registerPreSubmitHandler(fieldId: string, fn: () => Promise<void>): void;
|
|
882
877
|
unregisterPreSubmitHandler(fieldId: string): void;
|
|
@@ -1199,23 +1194,14 @@ interface PresignedUploadResponse {
|
|
|
1199
1194
|
upload_method: 'PUT' | 'POST';
|
|
1200
1195
|
}
|
|
1201
1196
|
interface CreateUploadHandlerOptions {
|
|
1202
|
-
/** Data server origin (no trailing slash), e.g. `https://dataserver.example.com`. */
|
|
1203
1197
|
apiBaseUrl: string;
|
|
1204
1198
|
headers?: Record<string, string>;
|
|
1205
1199
|
}
|
|
1206
1200
|
/**
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1209
|
-
* For `file_upload` fields with a different presign API, use
|
|
1210
|
-
* {@link createFileUploadHandler} as `config.onFileUpload`.
|
|
1201
|
+
* Creates an upload handler function that can be passed to FormProvider
|
|
1202
|
+
* This handles the complete upload flow: get presigned URL -> upload to S3 -> return S3 key
|
|
1211
1203
|
*/
|
|
1212
1204
|
declare function createUploadHandler(options: CreateUploadHandlerOptions): (file: File | Blob, filename: string) => Promise<string>;
|
|
1213
|
-
/**
|
|
1214
|
-
* Handler for `file_upload` fields (`FormFileUploadWidget`): presign via
|
|
1215
|
-
* `POST …/api/forms/media-presigned-get/` then PUT/POST file to `presigned_url`.
|
|
1216
|
-
* Pass this as `config.onFileUpload` on `FormProvider` (omit to use `onUpload` for files too).
|
|
1217
|
-
*/
|
|
1218
|
-
declare function createFileUploadHandler(options: CreateUploadHandlerOptions): (file: File | Blob, filename: string) => Promise<string>;
|
|
1219
1205
|
|
|
1220
1206
|
/** Shape of a medication as returned by AI analysis */
|
|
1221
1207
|
type AIMedication = {
|
|
@@ -1369,4 +1355,4 @@ declare const SmartTextareaWidget: React.FC<{
|
|
|
1369
1355
|
fieldId: string;
|
|
1370
1356
|
}>;
|
|
1371
1357
|
|
|
1372
|
-
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, FieldRequiredIndicator, type FieldState, type FieldStyleClassNames, type FieldStyleConfig, 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,
|
|
1358
|
+
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, FieldRequiredIndicator, type FieldState, type FieldStyleClassNames, type FieldStyleConfig, 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, fieldControlClass, fieldDescriptionClass, fieldErrorClass, fieldLabelClass, fieldMetaRequestsMarMedicationOrdersButton, fieldWrapperClass, isLabelVisible, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
package/dist/index.d.ts
CHANGED
|
@@ -770,10 +770,7 @@ interface StoreConfig {
|
|
|
770
770
|
prefillData?: Record<string, any>;
|
|
771
771
|
role?: string;
|
|
772
772
|
onEvent?: EventListener;
|
|
773
|
-
/** Handler for image, media, and signature uploads; fallback for file upload when `onFileUpload` is omitted. */
|
|
774
773
|
onUpload?: UploadHandler;
|
|
775
|
-
/** Optional handler for `file_upload` fields only (`FormFileUploadWidget`). Uses `onUpload` when not set. */
|
|
776
|
-
onFileUpload?: UploadHandler;
|
|
777
774
|
onDraftChange?: DraftChangeHandler;
|
|
778
775
|
/**
|
|
779
776
|
* Auth / OTP configuration. Lets the host app supply the API base URL and
|
|
@@ -875,8 +872,6 @@ declare class FormStore {
|
|
|
875
872
|
*/
|
|
876
873
|
updateConfig(next: Partial<StoreConfig>): void;
|
|
877
874
|
getUploadHandler(): UploadHandler | undefined;
|
|
878
|
-
/** Resolved handler for `file_upload` widgets: `onFileUpload` ?? `onUpload`. */
|
|
879
|
-
getFileUploadHandler(): UploadHandler | undefined;
|
|
880
875
|
private preSubmitHandlers;
|
|
881
876
|
registerPreSubmitHandler(fieldId: string, fn: () => Promise<void>): void;
|
|
882
877
|
unregisterPreSubmitHandler(fieldId: string): void;
|
|
@@ -1199,23 +1194,14 @@ interface PresignedUploadResponse {
|
|
|
1199
1194
|
upload_method: 'PUT' | 'POST';
|
|
1200
1195
|
}
|
|
1201
1196
|
interface CreateUploadHandlerOptions {
|
|
1202
|
-
/** Data server origin (no trailing slash), e.g. `https://dataserver.example.com`. */
|
|
1203
1197
|
apiBaseUrl: string;
|
|
1204
1198
|
headers?: Record<string, string>;
|
|
1205
1199
|
}
|
|
1206
1200
|
/**
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1209
|
-
* For `file_upload` fields with a different presign API, use
|
|
1210
|
-
* {@link createFileUploadHandler} as `config.onFileUpload`.
|
|
1201
|
+
* Creates an upload handler function that can be passed to FormProvider
|
|
1202
|
+
* This handles the complete upload flow: get presigned URL -> upload to S3 -> return S3 key
|
|
1211
1203
|
*/
|
|
1212
1204
|
declare function createUploadHandler(options: CreateUploadHandlerOptions): (file: File | Blob, filename: string) => Promise<string>;
|
|
1213
|
-
/**
|
|
1214
|
-
* Handler for `file_upload` fields (`FormFileUploadWidget`): presign via
|
|
1215
|
-
* `POST …/api/forms/media-presigned-get/` then PUT/POST file to `presigned_url`.
|
|
1216
|
-
* Pass this as `config.onFileUpload` on `FormProvider` (omit to use `onUpload` for files too).
|
|
1217
|
-
*/
|
|
1218
|
-
declare function createFileUploadHandler(options: CreateUploadHandlerOptions): (file: File | Blob, filename: string) => Promise<string>;
|
|
1219
1205
|
|
|
1220
1206
|
/** Shape of a medication as returned by AI analysis */
|
|
1221
1207
|
type AIMedication = {
|
|
@@ -1369,4 +1355,4 @@ declare const SmartTextareaWidget: React.FC<{
|
|
|
1369
1355
|
fieldId: string;
|
|
1370
1356
|
}>;
|
|
1371
1357
|
|
|
1372
|
-
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, FieldRequiredIndicator, type FieldState, type FieldStyleClassNames, type FieldStyleConfig, 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,
|
|
1358
|
+
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, FieldRequiredIndicator, type FieldState, type FieldStyleClassNames, type FieldStyleConfig, 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, fieldControlClass, fieldDescriptionClass, fieldErrorClass, fieldLabelClass, fieldMetaRequestsMarMedicationOrdersButton, fieldWrapperClass, isLabelVisible, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
package/dist/index.mjs
CHANGED
|
@@ -1710,8 +1710,6 @@ var FormStore = class {
|
|
|
1710
1710
|
updateConfig(next) {
|
|
1711
1711
|
let needsReeval = false;
|
|
1712
1712
|
if (next.onUpload !== void 0) this.config.onUpload = next.onUpload;
|
|
1713
|
-
if (next.onFileUpload !== void 0)
|
|
1714
|
-
this.config.onFileUpload = next.onFileUpload;
|
|
1715
1713
|
if (next.onEvent !== void 0) this.config.onEvent = next.onEvent;
|
|
1716
1714
|
if (next.onDraftChange !== void 0) this.config.onDraftChange = next.onDraftChange;
|
|
1717
1715
|
if (next.voice !== void 0) this.config.voice = next.voice;
|
|
@@ -1732,10 +1730,6 @@ var FormStore = class {
|
|
|
1732
1730
|
getUploadHandler() {
|
|
1733
1731
|
return this.config.onUpload;
|
|
1734
1732
|
}
|
|
1735
|
-
/** Resolved handler for `file_upload` widgets: `onFileUpload` ?? `onUpload`. */
|
|
1736
|
-
getFileUploadHandler() {
|
|
1737
|
-
return this.config.onFileUpload ?? this.config.onUpload;
|
|
1738
|
-
}
|
|
1739
1733
|
preSubmitHandlers = /* @__PURE__ */ new Map();
|
|
1740
1734
|
registerPreSubmitHandler(fieldId, fn) {
|
|
1741
1735
|
this.preSubmitHandlers.set(fieldId, fn);
|
|
@@ -4044,7 +4038,7 @@ var FormFileUploadWidget = ({
|
|
|
4044
4038
|
const accept = def.accept ?? "*/*";
|
|
4045
4039
|
const maxSize = def.maxSize ?? 10 * 1024 * 1024;
|
|
4046
4040
|
const allowMultiple = def.multiple === true;
|
|
4047
|
-
const uploadHandler = store.
|
|
4041
|
+
const uploadHandler = store.getUploadHandler();
|
|
4048
4042
|
const showLabel = isLabelVisible(fieldDef);
|
|
4049
4043
|
if (!uploadHandler) {
|
|
4050
4044
|
return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
|
|
@@ -4053,7 +4047,7 @@ var FormFileUploadWidget = ({
|
|
|
4053
4047
|
" ",
|
|
4054
4048
|
/* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
|
|
4055
4049
|
] }) : null,
|
|
4056
|
-
/* @__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.
|
|
4050
|
+
/* @__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." }) })
|
|
4057
4051
|
] });
|
|
4058
4052
|
}
|
|
4059
4053
|
const hasStoredValue = value !== null && value !== void 0 && value !== "" && !(Array.isArray(value) && value.length === 0);
|
|
@@ -16293,54 +16287,35 @@ var FormControls = ({
|
|
|
16293
16287
|
};
|
|
16294
16288
|
|
|
16295
16289
|
// src/utils/createUploadHandler.ts
|
|
16296
|
-
function normalizeBaseUrl(apiBaseUrl) {
|
|
16297
|
-
return apiBaseUrl.replace(/\/+$/, "");
|
|
16298
|
-
}
|
|
16299
|
-
async function uploadViaPresignedEndpoint(options, presignPath, file, filename) {
|
|
16300
|
-
const { apiBaseUrl, headers = {} } = options;
|
|
16301
|
-
const base = normalizeBaseUrl(apiBaseUrl);
|
|
16302
|
-
const path = presignPath.startsWith("/") ? presignPath : `/${presignPath}`;
|
|
16303
|
-
const response = await fetch(`${base}${path}`, {
|
|
16304
|
-
method: "POST",
|
|
16305
|
-
headers: {
|
|
16306
|
-
"Content-Type": "application/json",
|
|
16307
|
-
...headers
|
|
16308
|
-
},
|
|
16309
|
-
body: JSON.stringify({ filename })
|
|
16310
|
-
});
|
|
16311
|
-
if (!response.ok) {
|
|
16312
|
-
throw new Error(`Failed to get presigned URL: ${response.statusText}`);
|
|
16313
|
-
}
|
|
16314
|
-
const presignedData = await response.json();
|
|
16315
|
-
const uploadResponse = await fetch(presignedData.presigned_url, {
|
|
16316
|
-
method: presignedData.upload_method,
|
|
16317
|
-
headers: {
|
|
16318
|
-
"Content-Type": presignedData.content_type
|
|
16319
|
-
},
|
|
16320
|
-
body: file
|
|
16321
|
-
});
|
|
16322
|
-
if (!uploadResponse.ok) {
|
|
16323
|
-
throw new Error(`Failed to upload file: ${uploadResponse.statusText}`);
|
|
16324
|
-
}
|
|
16325
|
-
return presignedData.s3_key;
|
|
16326
|
-
}
|
|
16327
16290
|
function createUploadHandler(options) {
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16340
|
-
|
|
16341
|
-
|
|
16291
|
+
const { apiBaseUrl, headers = {} } = options;
|
|
16292
|
+
return async (file, filename) => {
|
|
16293
|
+
const response = await fetch(`${apiBaseUrl}/api/forms/media-upload/`, {
|
|
16294
|
+
method: "POST",
|
|
16295
|
+
headers: {
|
|
16296
|
+
"Content-Type": "application/json",
|
|
16297
|
+
...headers
|
|
16298
|
+
},
|
|
16299
|
+
body: JSON.stringify({ filename })
|
|
16300
|
+
});
|
|
16301
|
+
if (!response.ok) {
|
|
16302
|
+
throw new Error(`Failed to get presigned URL: ${response.statusText}`);
|
|
16303
|
+
}
|
|
16304
|
+
const presignedData = await response.json();
|
|
16305
|
+
const uploadResponse = await fetch(presignedData.presigned_url, {
|
|
16306
|
+
method: presignedData.upload_method,
|
|
16307
|
+
headers: {
|
|
16308
|
+
"Content-Type": presignedData.content_type
|
|
16309
|
+
},
|
|
16310
|
+
body: file
|
|
16311
|
+
});
|
|
16312
|
+
if (!uploadResponse.ok) {
|
|
16313
|
+
throw new Error(`Failed to upload file: ${uploadResponse.statusText}`);
|
|
16314
|
+
}
|
|
16315
|
+
return presignedData.s3_key;
|
|
16316
|
+
};
|
|
16342
16317
|
}
|
|
16343
16318
|
|
|
16344
|
-
export { AddInvestigationField, AddMedicationField, DifferentialDiagnosis, DynamicForm, DynamicFormV2, EMAIL_REGEX, FieldRenderer, FieldRequiredIndicator, FormControls, FormFileUploadWidget, FormProvider, FormStore, ImageUploadWidget, MAR_MEDICATION_ORDERS_META_KEY, MediaUploadWidget, MultiStepForm, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, RichTextWidget, SignatureUploadWidget, SmartForm, SmartTextareaWidget, Upload3 as Upload,
|
|
16319
|
+
export { AddInvestigationField, AddMedicationField, DifferentialDiagnosis, DynamicForm, DynamicFormV2, EMAIL_REGEX, FieldRenderer, FieldRequiredIndicator, 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, fieldControlClass, fieldDescriptionClass, fieldErrorClass, fieldLabelClass, fieldMetaRequestsMarMedicationOrdersButton, fieldWrapperClass, isLabelVisible, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
|
|
16345
16320
|
//# sourceMappingURL=index.mjs.map
|
|
16346
16321
|
//# sourceMappingURL=index.mjs.map
|