formanitor 0.1.8 → 0.1.10

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
@@ -54,6 +54,11 @@ interface FieldStyleConfig {
54
54
  * Default true (show asterisk when required).
55
55
  */
56
56
  showRequiredAsterisk?: boolean;
57
+ /**
58
+ * When true and `classNames.control` is provided, control defaults are skipped and only that class
59
+ * string is used for the main control element. Default false (merge defaults + control override).
60
+ */
61
+ fullControl?: boolean;
57
62
  classNames?: FieldStyleClassNames;
58
63
  }
59
64
  interface BaseFieldDef {
@@ -111,6 +116,8 @@ interface RichTextFieldDef extends BaseFieldDef {
111
116
  type: "richtext";
112
117
  /** Minimum height of the editor body in pixels. Default: 160. */
113
118
  minHeight?: number;
119
+ /** When true, enables table insert/edit controls in the toolbar. Default: false. */
120
+ tables?: boolean;
114
121
  }
115
122
  interface NumberFieldDef extends BaseFieldDef {
116
123
  type: "number";
@@ -1074,6 +1081,8 @@ declare const FieldRenderer: React.FC<FieldRendererProps>;
1074
1081
  declare const RichTextWidget: React.FC<{
1075
1082
  fieldId: string;
1076
1083
  }>;
1084
+ /** Tailwind classes for rendering stored richtext HTML (e.g. read-only views). */
1085
+ declare function richTextHtmlClassName(): string;
1077
1086
 
1078
1087
  interface SubmissionData {
1079
1088
  created_at: string;
@@ -1362,4 +1371,4 @@ declare const SmartTextareaWidget: React.FC<{
1362
1371
  fieldId: string;
1363
1372
  }>;
1364
1373
 
1365
- 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 };
1374
+ 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, richTextHtmlClassName, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
package/dist/index.d.ts CHANGED
@@ -54,6 +54,11 @@ interface FieldStyleConfig {
54
54
  * Default true (show asterisk when required).
55
55
  */
56
56
  showRequiredAsterisk?: boolean;
57
+ /**
58
+ * When true and `classNames.control` is provided, control defaults are skipped and only that class
59
+ * string is used for the main control element. Default false (merge defaults + control override).
60
+ */
61
+ fullControl?: boolean;
57
62
  classNames?: FieldStyleClassNames;
58
63
  }
59
64
  interface BaseFieldDef {
@@ -111,6 +116,8 @@ interface RichTextFieldDef extends BaseFieldDef {
111
116
  type: "richtext";
112
117
  /** Minimum height of the editor body in pixels. Default: 160. */
113
118
  minHeight?: number;
119
+ /** When true, enables table insert/edit controls in the toolbar. Default: false. */
120
+ tables?: boolean;
114
121
  }
115
122
  interface NumberFieldDef extends BaseFieldDef {
116
123
  type: "number";
@@ -1074,6 +1081,8 @@ declare const FieldRenderer: React.FC<FieldRendererProps>;
1074
1081
  declare const RichTextWidget: React.FC<{
1075
1082
  fieldId: string;
1076
1083
  }>;
1084
+ /** Tailwind classes for rendering stored richtext HTML (e.g. read-only views). */
1085
+ declare function richTextHtmlClassName(): string;
1077
1086
 
1078
1087
  interface SubmissionData {
1079
1088
  created_at: string;
@@ -1362,4 +1371,4 @@ declare const SmartTextareaWidget: React.FC<{
1362
1371
  fieldId: string;
1363
1372
  }>;
1364
1373
 
1365
- 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 };
1374
+ 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, richTextHtmlClassName, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
package/dist/index.mjs CHANGED
@@ -3,13 +3,14 @@ import React15__default, { createContext, useContext, useRef, useEffect, useStat
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { clsx } from 'clsx';
5
5
  import { twMerge } from 'tailwind-merge';
6
- import { ChevronDown, ChevronUp, Check, Circle, X, Image, Upload, Trash2, Plus, Loader2, PenTool, Mic, Undo, Redo, ChevronRight, Calendar as Calendar$1, ChevronLeft, RefreshCw, Clock, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered } from 'lucide-react';
6
+ import { ChevronDown, ChevronUp, Check, Circle, X, Image, Upload, Trash2, Plus, Loader2, PenTool, Mic, Undo, Redo, ChevronRight, Calendar as Calendar$1, ChevronLeft, RefreshCw, Clock, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, Table as Table$1, Rows2, Columns2, TableRowsSplit, TableColumnsSplit } from 'lucide-react';
7
7
  import * as LabelPrimitive from '@radix-ui/react-label';
8
8
  import { cva } from 'class-variance-authority';
9
9
  import { useEditor, EditorContent } from '@tiptap/react';
10
10
  import StarterKit from '@tiptap/starter-kit';
11
11
  import Placeholder from '@tiptap/extension-placeholder';
12
12
  import Underline from '@tiptap/extension-underline';
13
+ import { TableRow, TableHeader, TableCell, Table } from '@tiptap/extension-table';
13
14
  import { Slot } from '@radix-ui/react-slot';
14
15
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
15
16
  import * as SelectPrimitive from '@radix-ui/react-select';
@@ -2063,6 +2064,10 @@ function fieldLabelClass(fieldDef, ...defaults) {
2063
2064
  return cn(...defaults, fieldDef.style?.classNames?.label);
2064
2065
  }
2065
2066
  function fieldControlClass(fieldDef, ...defaults) {
2067
+ const controlClass = fieldDef.style?.classNames?.control;
2068
+ if (fieldDef.style?.fullControl && controlClass) {
2069
+ return cn(controlClass);
2070
+ }
2066
2071
  return cn(...defaults, fieldDef.style?.classNames?.control);
2067
2072
  }
2068
2073
  function fieldDescriptionClass(fieldDef, ...defaults) {
@@ -2193,9 +2198,47 @@ function isEmptyHtml(html) {
2193
2198
  const t = html.trim();
2194
2199
  return t === "" || t === "<p></p>" || t === "<p><br></p>" || t === '<p><br class="ProseMirror-trailingBreak"></p>';
2195
2200
  }
2201
+ function buildRichTextExtensions(placeholder, tables) {
2202
+ const base = [
2203
+ StarterKit.configure({
2204
+ // Disable headings entirely so the UI/content can't introduce H2/H3.
2205
+ heading: false,
2206
+ bulletList: {
2207
+ HTMLAttributes: {
2208
+ class: "list-disc pl-6 my-2"
2209
+ }
2210
+ },
2211
+ orderedList: {
2212
+ HTMLAttributes: {
2213
+ class: "list-decimal pl-6 my-2"
2214
+ }
2215
+ },
2216
+ listItem: {
2217
+ HTMLAttributes: {
2218
+ class: "my-1"
2219
+ }
2220
+ }
2221
+ }),
2222
+ Underline,
2223
+ Placeholder.configure({
2224
+ placeholder
2225
+ })
2226
+ ];
2227
+ if (!tables) return base;
2228
+ return [
2229
+ ...base,
2230
+ Table.configure({
2231
+ resizable: false
2232
+ }),
2233
+ TableRow,
2234
+ TableHeader,
2235
+ TableCell
2236
+ ];
2237
+ }
2196
2238
  function RichTextToolbar({
2197
2239
  editor,
2198
- disabled
2240
+ disabled,
2241
+ tablesEnabled
2199
2242
  }) {
2200
2243
  const [, rerender] = useReducer((n) => n + 1, 0);
2201
2244
  useEffect(() => {
@@ -2226,6 +2269,7 @@ function RichTextToolbar({
2226
2269
  children: icon
2227
2270
  }
2228
2271
  );
2272
+ const inTable = tablesEnabled && editor.isActive("table");
2229
2273
  return /* @__PURE__ */ jsxs(
2230
2274
  "div",
2231
2275
  {
@@ -2270,6 +2314,46 @@ function RichTextToolbar({
2270
2314
  /* @__PURE__ */ jsx(ListOrdered, { className: "h-4 w-4" }),
2271
2315
  "Numbered list"
2272
2316
  ),
2317
+ tablesEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [
2318
+ /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mx-0.5 h-6" }),
2319
+ !inTable ? fmtBtn(
2320
+ false,
2321
+ () => editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(),
2322
+ /* @__PURE__ */ jsx(Table$1, { className: "h-4 w-4" }),
2323
+ "Insert table"
2324
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
2325
+ fmtBtn(
2326
+ false,
2327
+ () => editor.chain().focus().addRowAfter().run(),
2328
+ /* @__PURE__ */ jsx(Rows2, { className: "h-4 w-4" }),
2329
+ "Add row below"
2330
+ ),
2331
+ fmtBtn(
2332
+ false,
2333
+ () => editor.chain().focus().addColumnAfter().run(),
2334
+ /* @__PURE__ */ jsx(Columns2, { className: "h-4 w-4" }),
2335
+ "Add column right"
2336
+ ),
2337
+ fmtBtn(
2338
+ false,
2339
+ () => editor.chain().focus().deleteRow().run(),
2340
+ /* @__PURE__ */ jsx(TableRowsSplit, { className: "h-4 w-4" }),
2341
+ "Delete row"
2342
+ ),
2343
+ fmtBtn(
2344
+ false,
2345
+ () => editor.chain().focus().deleteColumn().run(),
2346
+ /* @__PURE__ */ jsx(TableColumnsSplit, { className: "h-4 w-4" }),
2347
+ "Delete column"
2348
+ ),
2349
+ fmtBtn(
2350
+ false,
2351
+ () => editor.chain().focus().deleteTable().run(),
2352
+ /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }),
2353
+ "Delete table"
2354
+ )
2355
+ ] })
2356
+ ] }),
2273
2357
  /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mx-0.5 h-6" }),
2274
2358
  /* @__PURE__ */ jsx(
2275
2359
  Button,
@@ -2310,33 +2394,10 @@ var RichTextWidget = ({ fieldId }) => {
2310
2394
  const def = fieldDef;
2311
2395
  const placeholder = def?.placeholder ?? "Start typing\u2026";
2312
2396
  const minHeight = def?.minHeight ?? 160;
2397
+ const tablesEnabled = !!def?.tables;
2313
2398
  const extensions = useMemo(
2314
- () => [
2315
- StarterKit.configure({
2316
- // Disable headings entirely so the UI/content can't introduce H2/H3.
2317
- heading: false,
2318
- bulletList: {
2319
- HTMLAttributes: {
2320
- class: "list-disc pl-6 my-2"
2321
- }
2322
- },
2323
- orderedList: {
2324
- HTMLAttributes: {
2325
- class: "list-decimal pl-6 my-2"
2326
- }
2327
- },
2328
- listItem: {
2329
- HTMLAttributes: {
2330
- class: "my-1"
2331
- }
2332
- }
2333
- }),
2334
- Underline,
2335
- Placeholder.configure({
2336
- placeholder
2337
- })
2338
- ],
2339
- [placeholder]
2399
+ () => buildRichTextExtensions(placeholder, tablesEnabled),
2400
+ [placeholder, tablesEnabled]
2340
2401
  );
2341
2402
  const stringValue = typeof value === "string" ? value : "";
2342
2403
  const editor = useEditor(
@@ -2353,7 +2414,7 @@ var RichTextWidget = ({ fieldId }) => {
2353
2414
  editorProps: {
2354
2415
  attributes: {
2355
2416
  id: fieldId,
2356
- class: "focus:outline-none",
2417
+ class: "tiptap focus:outline-none",
2357
2418
  style: `min-height: ${minHeight}px`
2358
2419
  }
2359
2420
  }
@@ -2419,7 +2480,14 @@ var RichTextWidget = ({ fieldId }) => {
2419
2480
  )
2420
2481
  ),
2421
2482
  children: [
2422
- /* @__PURE__ */ jsx(RichTextToolbar, { editor, disabled }),
2483
+ /* @__PURE__ */ jsx(
2484
+ RichTextToolbar,
2485
+ {
2486
+ editor,
2487
+ disabled,
2488
+ tablesEnabled
2489
+ }
2490
+ ),
2423
2491
  /* @__PURE__ */ jsx(
2424
2492
  "div",
2425
2493
  {
@@ -2445,6 +2513,9 @@ var RichTextWidget = ({ fieldId }) => {
2445
2513
  showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2446
2514
  ] });
2447
2515
  };
2516
+ function richTextHtmlClassName() {
2517
+ return cn("richtext-content prose prose-sm max-w-none");
2518
+ }
2448
2519
  var Select = SelectPrimitive.Root;
2449
2520
  var SelectValue = SelectPrimitive.Value;
2450
2521
  var SelectTrigger = React15.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
@@ -2728,7 +2799,7 @@ var MultiSelectWidget = ({ fieldId }) => {
2728
2799
  showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2729
2800
  ] });
2730
2801
  };
2731
- var Table = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx(
2802
+ var Table2 = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx(
2732
2803
  "table",
2733
2804
  {
2734
2805
  ref,
@@ -2736,9 +2807,9 @@ var Table = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
2736
2807
  ...props
2737
2808
  }
2738
2809
  ) }));
2739
- Table.displayName = "Table";
2740
- var TableHeader = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
2741
- TableHeader.displayName = "TableHeader";
2810
+ Table2.displayName = "Table";
2811
+ var TableHeader2 = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
2812
+ TableHeader2.displayName = "TableHeader";
2742
2813
  var TableBody = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2743
2814
  "tbody",
2744
2815
  {
@@ -2760,7 +2831,7 @@ var TableFooter = React15.forwardRef(({ className, ...props }, ref) => /* @__PUR
2760
2831
  }
2761
2832
  ));
2762
2833
  TableFooter.displayName = "TableFooter";
2763
- var TableRow = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2834
+ var TableRow2 = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2764
2835
  "tr",
2765
2836
  {
2766
2837
  ref,
@@ -2771,7 +2842,7 @@ var TableRow = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__
2771
2842
  ...props
2772
2843
  }
2773
2844
  ));
2774
- TableRow.displayName = "TableRow";
2845
+ TableRow2.displayName = "TableRow";
2775
2846
  var TableHead = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2776
2847
  "th",
2777
2848
  {
@@ -2784,7 +2855,7 @@ var TableHead = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE_
2784
2855
  }
2785
2856
  ));
2786
2857
  TableHead.displayName = "TableHead";
2787
- var TableCell = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2858
+ var TableCell2 = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2788
2859
  "td",
2789
2860
  {
2790
2861
  ref,
@@ -2792,7 +2863,7 @@ var TableCell = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE_
2792
2863
  ...props
2793
2864
  }
2794
2865
  ));
2795
- TableCell.displayName = "TableCell";
2866
+ TableCell2.displayName = "TableCell";
2796
2867
  var TableCaption = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2797
2868
  "caption",
2798
2869
  {
@@ -2842,15 +2913,15 @@ var RepeatableWidget = ({
2842
2913
  }
2843
2914
  )
2844
2915
  ] }),
2845
- /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs(Table, { children: [
2846
- /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
2916
+ /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs(Table2, { children: [
2917
+ /* @__PURE__ */ jsx(TableHeader2, { children: /* @__PURE__ */ jsxs(TableRow2, { children: [
2847
2918
  def.row.map((subDef) => /* @__PURE__ */ jsx(TableHead, { children: subDef.label }, subDef.id)),
2848
2919
  /* @__PURE__ */ jsx(TableHead, { className: "w-[50px]" })
2849
2920
  ] }) }),
2850
2921
  /* @__PURE__ */ jsxs(TableBody, { children: [
2851
2922
  rows.map(
2852
- (row, index) => /* @__PURE__ */ jsxs(TableRow, { children: [
2853
- def.row.map((subDef) => /* @__PURE__ */ jsx(TableCell, { children: subDef.type === "number" ? /* @__PURE__ */ jsx(
2923
+ (row, index) => /* @__PURE__ */ jsxs(TableRow2, { children: [
2924
+ def.row.map((subDef) => /* @__PURE__ */ jsx(TableCell2, { children: subDef.type === "number" ? /* @__PURE__ */ jsx(
2854
2925
  "input",
2855
2926
  {
2856
2927
  type: "number",
@@ -2868,7 +2939,7 @@ var RepeatableWidget = ({
2868
2939
  disabled
2869
2940
  }
2870
2941
  ) }, subDef.id)),
2871
- /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
2942
+ /* @__PURE__ */ jsx(TableCell2, { children: /* @__PURE__ */ jsx(
2872
2943
  Button,
2873
2944
  {
2874
2945
  type: "button",
@@ -2882,8 +2953,8 @@ var RepeatableWidget = ({
2882
2953
  ) })
2883
2954
  ] }, index)
2884
2955
  ),
2885
- rows.length === 0 && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(
2886
- TableCell,
2956
+ rows.length === 0 && /* @__PURE__ */ jsx(TableRow2, { children: /* @__PURE__ */ jsx(
2957
+ TableCell2,
2887
2958
  {
2888
2959
  colSpan: def.row.length + 1,
2889
2960
  className: "h-24 text-center",
@@ -3967,13 +4038,7 @@ function Upload3({
3967
4038
  /* @__PURE__ */ jsx("br", {}),
3968
4039
  "and medical records"
3969
4040
  ] }),
3970
- /* @__PURE__ */ jsx(
3971
- Upload,
3972
- {
3973
- size: 20,
3974
- className: "rotate-180 text-[#727272] mt-4"
3975
- }
3976
- ),
4041
+ /* @__PURE__ */ jsx(Upload, { size: 20, className: "text-[#727272] mt-4" }),
3977
4042
  /* @__PURE__ */ jsx("div", { className: "text-xs mt-1 text-text-shades-2", children: placeholder }),
3978
4043
  /* @__PURE__ */ jsxs("div", { className: "mt-2 text-10px leading-[140%] text-[#989898]", children: [
3979
4044
  "Supported formats - ",
@@ -4359,23 +4424,23 @@ var EditableTableWidget = ({
4359
4424
  /* @__PURE__ */ jsx(Label, { children: fieldDef.label }),
4360
4425
  fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: fieldDef.description })
4361
4426
  ] }),
4362
- /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs(Table, { children: [
4363
- /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(TableHead, { children: header.isPlaceholder ? null : flexRender(
4427
+ /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs(Table2, { children: [
4428
+ /* @__PURE__ */ jsx(TableHeader2, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow2, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(TableHead, { children: header.isPlaceholder ? null : flexRender(
4364
4429
  header.column.columnDef.header,
4365
4430
  header.getContext()
4366
4431
  ) }, header.id)) }, headerGroup.id)) }),
4367
4432
  /* @__PURE__ */ jsx(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(
4368
- TableRow,
4433
+ TableRow2,
4369
4434
  {
4370
4435
  "data-state": row.getIsSelected() && "selected",
4371
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, { className: "p-1", children: flexRender(
4436
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell2, { className: "p-1", children: flexRender(
4372
4437
  cell.column.columnDef.cell,
4373
4438
  cell.getContext()
4374
4439
  ) }, cell.id))
4375
4440
  },
4376
4441
  row.id
4377
- )) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(
4378
- TableCell,
4442
+ )) : /* @__PURE__ */ jsx(TableRow2, { children: /* @__PURE__ */ jsx(
4443
+ TableCell2,
4379
4444
  {
4380
4445
  colSpan: columns.length,
4381
4446
  className: "h-24 text-center",
@@ -15375,7 +15440,10 @@ var ReadOnlyText = ({ fieldDef, value }) => {
15375
15440
  isRichText ? /* @__PURE__ */ jsx(
15376
15441
  "div",
15377
15442
  {
15378
- className: "prose prose-sm max-w-none text-gray-900 border border-gray-200 rounded-md p-3 bg-gray-50",
15443
+ className: cn(
15444
+ richTextHtmlClassName(),
15445
+ "text-gray-900 border border-gray-200 rounded-md p-3 bg-gray-50"
15446
+ ),
15379
15447
  dangerouslySetInnerHTML: { __html: displayValue }
15380
15448
  }
15381
15449
  ) : /* @__PURE__ */ jsx("div", { className: "text-gray-900 border border-gray-200 rounded-md p-3 bg-gray-50 min-h-[2.5rem] whitespace-pre-wrap", children: displayValue || /* @__PURE__ */ jsx("span", { className: "text-gray-400 italic", children: "No value" }) })
@@ -15444,10 +15512,10 @@ var ReadOnlyRepeatable = ({ fieldDef, value }) => {
15444
15512
  const rows = Array.isArray(value) ? value : [];
15445
15513
  return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
15446
15514
  /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-gray-700", children: fieldDef.label }),
15447
- rows.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-gray-400 italic border border-gray-200 rounded-md p-4 bg-gray-50 text-center", children: "No items" }) : /* @__PURE__ */ jsx("div", { className: "rounded-md border border-gray-200 overflow-hidden", children: /* @__PURE__ */ jsxs(Table, { children: [
15448
- /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsx(TableRow, { children: fieldDef.row.map((subDef) => /* @__PURE__ */ jsx(TableHead, { className: "bg-gray-50", children: subDef.label }, subDef.id)) }) }),
15515
+ rows.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-gray-400 italic border border-gray-200 rounded-md p-4 bg-gray-50 text-center", children: "No items" }) : /* @__PURE__ */ jsx("div", { className: "rounded-md border border-gray-200 overflow-hidden", children: /* @__PURE__ */ jsxs(Table2, { children: [
15516
+ /* @__PURE__ */ jsx(TableHeader2, { children: /* @__PURE__ */ jsx(TableRow2, { children: fieldDef.row.map((subDef) => /* @__PURE__ */ jsx(TableHead, { className: "bg-gray-50", children: subDef.label }, subDef.id)) }) }),
15449
15517
  /* @__PURE__ */ jsx(TableBody, { children: rows.map(
15450
- (row, index) => /* @__PURE__ */ jsx(TableRow, { children: fieldDef.row.map((subDef) => /* @__PURE__ */ jsx(TableCell, { className: "text-gray-900", children: row[subDef.id] ?? /* @__PURE__ */ jsx("span", { className: "text-gray-400 italic", children: "\u2014" }) }, subDef.id)) }, index)
15518
+ (row, index) => /* @__PURE__ */ jsx(TableRow2, { children: fieldDef.row.map((subDef) => /* @__PURE__ */ jsx(TableCell2, { className: "text-gray-900", children: row[subDef.id] ?? /* @__PURE__ */ jsx("span", { className: "text-gray-400 italic", children: "\u2014" }) }, subDef.id)) }, index)
15451
15519
  ) })
15452
15520
  ] }) })
15453
15521
  ] });
@@ -15627,16 +15695,16 @@ var ReadOnlyTable = ({
15627
15695
  return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
15628
15696
  /* @__PURE__ */ jsx(Label, { children: fieldDef.label }),
15629
15697
  fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: fieldDef.description }),
15630
- /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs(Table, { children: [
15631
- /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(TableHead, { children: header.isPlaceholder ? null : flexRender(
15698
+ /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs(Table2, { children: [
15699
+ /* @__PURE__ */ jsx(TableHeader2, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow2, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(TableHead, { children: header.isPlaceholder ? null : flexRender(
15632
15700
  header.column.columnDef.header,
15633
15701
  header.getContext()
15634
15702
  ) }, header.id)) }, headerGroup.id)) }),
15635
- /* @__PURE__ */ jsx(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(TableRow, { children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, { className: "p-2", children: flexRender(
15703
+ /* @__PURE__ */ jsx(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(TableRow2, { children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell2, { className: "p-2", children: flexRender(
15636
15704
  cell.column.columnDef.cell,
15637
15705
  cell.getContext()
15638
- ) }, cell.id)) }, row.id)) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(
15639
- TableCell,
15706
+ ) }, cell.id)) }, row.id)) : /* @__PURE__ */ jsx(TableRow2, { children: /* @__PURE__ */ jsx(
15707
+ TableCell2,
15640
15708
  {
15641
15709
  colSpan: columns.length,
15642
15710
  className: "h-16 text-center text-muted-foreground",
@@ -16342,6 +16410,6 @@ function createUploadHandler(options) {
16342
16410
  );
16343
16411
  }
16344
16412
 
16345
- 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 };
16413
+ 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, richTextHtmlClassName, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
16346
16414
  //# sourceMappingURL=index.mjs.map
16347
16415
  //# sourceMappingURL=index.mjs.map