formanitor 0.0.27 → 0.0.29

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,6 @@
1
1
  import React from 'react';
2
2
 
3
- type FieldType = 'text' | 'number' | 'textarea' | 'richtext' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | string;
3
+ type FieldType = 'text' | 'number' | 'textarea' | 'diagnosis_textarea' | 'richtext' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | string;
4
4
  interface ValidationRule {
5
5
  min?: number;
6
6
  max?: number;
@@ -63,6 +63,12 @@ interface BaseFieldDef {
63
63
  */
64
64
  theme?: string;
65
65
  meta?: Record<string, unknown>;
66
+ /**
67
+ * When true, a microphone button is rendered alongside this field so the
68
+ * user can dictate its value via speech. Requires `StoreConfig.voice` to
69
+ * be wired up with an `onTranscribe` callback.
70
+ */
71
+ voice?: boolean;
66
72
  }
67
73
  interface TextFieldDef extends BaseFieldDef {
68
74
  type: 'text' | 'textarea';
@@ -209,6 +215,20 @@ interface SmartTextareaValue {
209
215
  text: string;
210
216
  extractedKeywords: ExtractedKeywordMatch[];
211
217
  }
218
+ /** Selected diagnosis grade chip (single-selection). */
219
+ interface DiagnosisGradeSelection {
220
+ condition: string;
221
+ grade: string;
222
+ }
223
+ /**
224
+ * Structured value for diagnosis_textarea fields.
225
+ * - `text` is the textarea content (what will be submitted).
226
+ * - `selectedGradesByCondition` stores one selected chip per condition for later metadata/preview use.
227
+ */
228
+ interface DiagnosisTextareaValue {
229
+ text: string;
230
+ selectedGradesByCondition: Record<string, string>;
231
+ }
212
232
  /**
213
233
  * Smart textarea that performs client-side NLP keyword extraction and searches
214
234
  * matched terms against backend master tables via `fieldHandlers[fieldId].onSearch`.
@@ -223,6 +243,19 @@ interface SmartTextareaFieldDef extends BaseFieldDef {
223
243
  /** Debounce delay in ms before NLP + search triggers. Default: 1000. */
224
244
  debounceDelay?: number;
225
245
  }
246
+ /**
247
+ * Diagnosis textarea that can display condition-wise grade chips based on
248
+ * asynchronous API response.
249
+ *
250
+ * Value shape in form state can be plain text (legacy) or `DiagnosisTextareaValue`.
251
+ */
252
+ interface DiagnosisTextareaFieldDef extends BaseFieldDef {
253
+ type: 'diagnosis_textarea';
254
+ /** Height in pixels. If omitted, uses default min height (80px). */
255
+ height?: number;
256
+ /** Debounce delay in ms before API call triggers. Default: 700. */
257
+ debounceDelay?: number;
258
+ }
226
259
  interface MedicationFrequentItem {
227
260
  id: string;
228
261
  name: string;
@@ -269,7 +302,7 @@ interface DoctorFrequentItems {
269
302
  investigations?: InvestigationFrequentItem[];
270
303
  procedures?: ProcedureFrequentItem[];
271
304
  }
272
- type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | BaseFieldDef;
305
+ type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | DiagnosisTextareaFieldDef | BaseFieldDef;
273
306
  interface Condition {
274
307
  field?: string;
275
308
  op: '==' | '!=' | '>' | '<' | '>=' | '<=' | 'in' | 'contains';
@@ -421,6 +454,17 @@ interface StoreConfig {
421
454
  onEvent?: EventListener;
422
455
  onUpload?: UploadHandler;
423
456
  onDraftChange?: DraftChangeHandler;
457
+ /**
458
+ * Voice dictation support. When provided, fields marked with `voice: true`
459
+ * in the schema will display a microphone button.
460
+ * The host app owns all recording logic and supplies two callbacks:
461
+ * - `startRecording` — begin capturing audio
462
+ * - `stopRecording` — stop capturing, transcribe, and return the transcript
463
+ */
464
+ voice?: {
465
+ startRecording: () => Promise<void>;
466
+ stopRecording: () => Promise<string>;
467
+ };
424
468
  }
425
469
  declare class FormStore {
426
470
  private state;
@@ -444,6 +488,7 @@ declare class FormStore {
444
488
  };
445
489
  getSchema(): FormDef;
446
490
  getFieldDef(fieldId: string): FieldDef | undefined;
491
+ getVoice(): StoreConfig['voice'];
447
492
  hasPersistence(): boolean;
448
493
  setValue(fieldId: string, value: any): void;
449
494
  /**
@@ -542,6 +587,11 @@ type FieldHandler = {
542
587
  label: string;
543
588
  value: any;
544
589
  }[]>;
590
+ /**
591
+ * Called by diagnosis_textarea widgets to fetch condition-wise grades
592
+ * from diagnosis text input.
593
+ */
594
+ onFetchDiagnosisGrades?: (query: string) => Promise<any>;
545
595
  };
546
596
  type FieldHandlersMap = Record<string, FieldHandler>;
547
597
  declare function useFieldHandlers(fieldId: string): FieldHandler;
@@ -860,4 +910,4 @@ declare const SmartTextareaWidget: React.FC<{
860
910
  fieldId: string;
861
911
  }>;
862
912
 
863
- export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, 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 ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type MatchedCondition, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, 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, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SumComputation, type TextFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, useSmartKeywords, validateField, validateForm };
913
+ export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, 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 ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type MatchedCondition, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, 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, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SumComputation, type TextFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, useSmartKeywords, validateField, validateForm };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- type FieldType = 'text' | 'number' | 'textarea' | 'richtext' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | string;
3
+ type FieldType = 'text' | 'number' | 'textarea' | 'diagnosis_textarea' | 'richtext' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | string;
4
4
  interface ValidationRule {
5
5
  min?: number;
6
6
  max?: number;
@@ -63,6 +63,12 @@ interface BaseFieldDef {
63
63
  */
64
64
  theme?: string;
65
65
  meta?: Record<string, unknown>;
66
+ /**
67
+ * When true, a microphone button is rendered alongside this field so the
68
+ * user can dictate its value via speech. Requires `StoreConfig.voice` to
69
+ * be wired up with an `onTranscribe` callback.
70
+ */
71
+ voice?: boolean;
66
72
  }
67
73
  interface TextFieldDef extends BaseFieldDef {
68
74
  type: 'text' | 'textarea';
@@ -209,6 +215,20 @@ interface SmartTextareaValue {
209
215
  text: string;
210
216
  extractedKeywords: ExtractedKeywordMatch[];
211
217
  }
218
+ /** Selected diagnosis grade chip (single-selection). */
219
+ interface DiagnosisGradeSelection {
220
+ condition: string;
221
+ grade: string;
222
+ }
223
+ /**
224
+ * Structured value for diagnosis_textarea fields.
225
+ * - `text` is the textarea content (what will be submitted).
226
+ * - `selectedGradesByCondition` stores one selected chip per condition for later metadata/preview use.
227
+ */
228
+ interface DiagnosisTextareaValue {
229
+ text: string;
230
+ selectedGradesByCondition: Record<string, string>;
231
+ }
212
232
  /**
213
233
  * Smart textarea that performs client-side NLP keyword extraction and searches
214
234
  * matched terms against backend master tables via `fieldHandlers[fieldId].onSearch`.
@@ -223,6 +243,19 @@ interface SmartTextareaFieldDef extends BaseFieldDef {
223
243
  /** Debounce delay in ms before NLP + search triggers. Default: 1000. */
224
244
  debounceDelay?: number;
225
245
  }
246
+ /**
247
+ * Diagnosis textarea that can display condition-wise grade chips based on
248
+ * asynchronous API response.
249
+ *
250
+ * Value shape in form state can be plain text (legacy) or `DiagnosisTextareaValue`.
251
+ */
252
+ interface DiagnosisTextareaFieldDef extends BaseFieldDef {
253
+ type: 'diagnosis_textarea';
254
+ /** Height in pixels. If omitted, uses default min height (80px). */
255
+ height?: number;
256
+ /** Debounce delay in ms before API call triggers. Default: 700. */
257
+ debounceDelay?: number;
258
+ }
226
259
  interface MedicationFrequentItem {
227
260
  id: string;
228
261
  name: string;
@@ -269,7 +302,7 @@ interface DoctorFrequentItems {
269
302
  investigations?: InvestigationFrequentItem[];
270
303
  procedures?: ProcedureFrequentItem[];
271
304
  }
272
- type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | BaseFieldDef;
305
+ type FieldDef = TextFieldDef | RichTextFieldDef | NumberFieldDef | SelectFieldDef | RadioFieldDef | CheckboxFieldDef | RepeatableFieldDef | ImageUploadFieldDef | SignatureFieldDef | EditableTableFieldDef | StaticTextFieldDef | MedicationsFieldDef | InvestigationsFieldDef | ProceduresFieldDef | DifferentialDiagnosisFieldDef | VitalsFieldDef | ReferralFieldDef | FollowupFieldDef | SmartTextareaFieldDef | DiagnosisTextareaFieldDef | BaseFieldDef;
273
306
  interface Condition {
274
307
  field?: string;
275
308
  op: '==' | '!=' | '>' | '<' | '>=' | '<=' | 'in' | 'contains';
@@ -421,6 +454,17 @@ interface StoreConfig {
421
454
  onEvent?: EventListener;
422
455
  onUpload?: UploadHandler;
423
456
  onDraftChange?: DraftChangeHandler;
457
+ /**
458
+ * Voice dictation support. When provided, fields marked with `voice: true`
459
+ * in the schema will display a microphone button.
460
+ * The host app owns all recording logic and supplies two callbacks:
461
+ * - `startRecording` — begin capturing audio
462
+ * - `stopRecording` — stop capturing, transcribe, and return the transcript
463
+ */
464
+ voice?: {
465
+ startRecording: () => Promise<void>;
466
+ stopRecording: () => Promise<string>;
467
+ };
424
468
  }
425
469
  declare class FormStore {
426
470
  private state;
@@ -444,6 +488,7 @@ declare class FormStore {
444
488
  };
445
489
  getSchema(): FormDef;
446
490
  getFieldDef(fieldId: string): FieldDef | undefined;
491
+ getVoice(): StoreConfig['voice'];
447
492
  hasPersistence(): boolean;
448
493
  setValue(fieldId: string, value: any): void;
449
494
  /**
@@ -542,6 +587,11 @@ type FieldHandler = {
542
587
  label: string;
543
588
  value: any;
544
589
  }[]>;
590
+ /**
591
+ * Called by diagnosis_textarea widgets to fetch condition-wise grades
592
+ * from diagnosis text input.
593
+ */
594
+ onFetchDiagnosisGrades?: (query: string) => Promise<any>;
545
595
  };
546
596
  type FieldHandlersMap = Record<string, FieldHandler>;
547
597
  declare function useFieldHandlers(fieldId: string): FieldHandler;
@@ -860,4 +910,4 @@ declare const SmartTextareaWidget: React.FC<{
860
910
  fieldId: string;
861
911
  }>;
862
912
 
863
- export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, 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 ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type MatchedCondition, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, 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, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SumComputation, type TextFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, useSmartKeywords, validateField, validateForm };
913
+ export { type AIDifferentialDiagnosisItem, AddInvestigationField, type AddInvestigationFieldProps, AddMedicationField, type AddMedicationFieldProps, type BaseFieldDef, type CheckboxFieldDef, type ColumnLayout, type Computation, type Condition, type CreateUploadHandlerOptions, type DataSource, type DiagnosisGradeSelection, type DiagnosisTextareaFieldDef, type DiagnosisTextareaValue, DifferentialDiagnosis, type DifferentialDiagnosisFieldDef, type DifferentialDiagnosisItem, type DifferentialDiagnosisProps, type DoctorFrequentItems, DynamicForm, 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 ImageUploadFieldDef, ImageUploadWidget, type Investigation, type InvestigationFrequentItem, type InvestigationSearchResult, type InvestigationsFieldDef, type LayoutNode, type MatchedCondition, type Medication, type MedicationFrequentItem, type MedicationSearchResult, type MedicationsFieldDef, type NumberFieldDef, type Permission, type PresignedUploadResponse, type ProcedureFrequentItem, type ProceduresFieldDef, type RadioFieldDef, ReadOnlyForm, ReadOnlyImageUpload, 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, SmartForm, type SmartFormProps, type SmartKeywordsResult, type SmartTextareaFieldDef, type SmartTextareaValue, SmartTextareaWidget, type StaticTextFieldDef, type StoreConfig, type SubmissionData, type SumComputation, type TextFieldDef, type ValidationRule, type VitalsFieldDef, type WebhookDef, type Workflow, type WorkflowTransition, createUploadHandler, evaluateRules, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, useSmartKeywords, validateField, validateForm };