@osdk/react-components 0.2.0-beta.24 → 0.2.0-beta.25

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.
Files changed (115) hide show
  1. package/AGENTS.md +3 -0
  2. package/CHANGELOG.md +17 -0
  3. package/build/browser/action-form/FormFieldApi.js.map +1 -1
  4. package/build/browser/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
  5. package/build/browser/action-form/fields/BaseInput.module.css.js +6 -0
  6. package/build/browser/action-form/fields/FormFieldRenderer.js +26 -8
  7. package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
  8. package/build/browser/action-form/fields/RadioButtonsField.js +57 -0
  9. package/build/browser/action-form/fields/RadioButtonsField.js.map +1 -0
  10. package/build/browser/action-form/fields/RadioButtonsField.module.css +83 -0
  11. package/build/browser/action-form/fields/RadioButtonsField.module.css.js +10 -0
  12. package/build/browser/action-form/fields/TextAreaField.js +50 -0
  13. package/build/browser/action-form/fields/TextAreaField.js.map +1 -0
  14. package/build/browser/action-form/fields/TextInputField.js +3 -3
  15. package/build/browser/action-form/fields/TextInputField.js.map +1 -1
  16. package/build/browser/pdf-viewer/PdfViewer.js +40 -4
  17. package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
  18. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
  19. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
  20. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
  21. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css.js +1 -0
  22. package/build/browser/pdf-viewer/components/PdfViewerContent.js +15 -3
  23. package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  24. package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
  25. package/build/browser/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
  26. package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
  27. package/build/browser/pdf-viewer/components/PdfViewerToolbar.js +29 -2
  28. package/build/browser/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
  29. package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
  30. package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css.js +1 -0
  31. package/build/browser/pdf-viewer/constants.js +2 -1
  32. package/build/browser/pdf-viewer/constants.js.map +1 -1
  33. package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
  34. package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
  35. package/build/browser/pdf-viewer/hooks/usePdfFormFields.js +326 -0
  36. package/build/browser/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
  37. package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js +199 -0
  38. package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
  39. package/build/browser/pdf-viewer/hooks/usePdfViewer.js +16 -10
  40. package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
  41. package/build/browser/pdf-viewer/types.js.map +1 -1
  42. package/build/browser/public/experimental.js +3 -0
  43. package/build/browser/public/experimental.js.map +1 -1
  44. package/build/browser/styles.css +144 -35
  45. package/build/cjs/public/experimental.cjs +1735 -1109
  46. package/build/cjs/public/experimental.cjs.map +1 -1
  47. package/build/cjs/public/experimental.css +82 -5
  48. package/build/cjs/public/experimental.css.map +1 -1
  49. package/build/cjs/public/experimental.d.cts +154 -20
  50. package/build/esm/action-form/FormFieldApi.js.map +1 -1
  51. package/build/esm/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
  52. package/build/esm/action-form/fields/FormFieldRenderer.js +26 -8
  53. package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
  54. package/build/esm/action-form/fields/RadioButtonsField.js +57 -0
  55. package/build/esm/action-form/fields/RadioButtonsField.js.map +1 -0
  56. package/build/esm/action-form/fields/RadioButtonsField.module.css +83 -0
  57. package/build/esm/action-form/fields/TextAreaField.js +50 -0
  58. package/build/esm/action-form/fields/TextAreaField.js.map +1 -0
  59. package/build/esm/action-form/fields/TextInputField.js +3 -3
  60. package/build/esm/action-form/fields/TextInputField.js.map +1 -1
  61. package/build/esm/pdf-viewer/PdfViewer.js +40 -4
  62. package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
  63. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
  64. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
  65. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
  66. package/build/esm/pdf-viewer/components/PdfViewerContent.js +15 -3
  67. package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  68. package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
  69. package/build/esm/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
  70. package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
  71. package/build/esm/pdf-viewer/components/PdfViewerToolbar.js +29 -2
  72. package/build/esm/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
  73. package/build/esm/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
  74. package/build/esm/pdf-viewer/constants.js +2 -1
  75. package/build/esm/pdf-viewer/constants.js.map +1 -1
  76. package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
  77. package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
  78. package/build/esm/pdf-viewer/hooks/usePdfFormFields.js +326 -0
  79. package/build/esm/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
  80. package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js +199 -0
  81. package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
  82. package/build/esm/pdf-viewer/hooks/usePdfViewer.js +16 -10
  83. package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
  84. package/build/esm/pdf-viewer/types.js.map +1 -1
  85. package/build/esm/public/experimental.js +3 -0
  86. package/build/esm/public/experimental.js.map +1 -1
  87. package/build/types/action-form/FormFieldApi.d.ts +8 -2
  88. package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
  89. package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
  90. package/build/types/action-form/fields/RadioButtonsField.d.ts +3 -0
  91. package/build/types/action-form/fields/RadioButtonsField.d.ts.map +1 -0
  92. package/build/types/action-form/fields/TextAreaField.d.ts +3 -0
  93. package/build/types/action-form/fields/TextAreaField.d.ts.map +1 -0
  94. package/build/types/pdf-viewer/PdfViewer.d.ts +1 -1
  95. package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
  96. package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -1
  97. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +8 -4
  98. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
  99. package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts +6 -1
  100. package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts.map +1 -1
  101. package/build/types/pdf-viewer/constants.d.ts +1 -1
  102. package/build/types/pdf-viewer/constants.d.ts.map +1 -1
  103. package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts +5 -0
  104. package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts.map +1 -0
  105. package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts +24 -0
  106. package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts.map +1 -0
  107. package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts +35 -0
  108. package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts.map +1 -0
  109. package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -1
  110. package/build/types/pdf-viewer/types.d.ts +90 -13
  111. package/build/types/pdf-viewer/types.d.ts.map +1 -1
  112. package/build/types/public/experimental.d.ts +4 -1
  113. package/build/types/public/experimental.d.ts.map +1 -1
  114. package/package.json +5 -5
  115. package/build/browser/action-form/fields/TextInputField.module.css.js +0 -6
@@ -931,27 +931,49 @@ interface OutlineItem {
931
931
  italic: boolean;
932
932
  }
933
933
  /** The visual style of an annotation rendered on the PDF. */
934
- type AnnotationType = "highlight" | "underline" | "comment" | "pin";
935
- /** A single annotation positioned on a specific page of the PDF. */
936
- interface PdfAnnotation {
934
+ type AnnotationType = "highlight" | "underline" | "comment" | "pin" | "custom";
935
+ /** A rectangle in PDF coordinate space (origin: bottom-left of page). */
936
+ interface PdfRect {
937
+ x: number;
938
+ y: number;
939
+ width: number;
940
+ height: number;
941
+ }
942
+ /** Props passed to a custom annotation renderer. */
943
+ interface PdfAnnotationRenderProps {
944
+ annotation: PdfAnnotation;
945
+ scale: number;
946
+ pageHeight: number;
947
+ }
948
+ /** Common fields shared by all annotation types. */
949
+ interface PdfAnnotationBase {
937
950
  /** Unique identifier for this annotation */
938
951
  id: string;
939
- /** The type of annotation to render */
940
- type: AnnotationType;
941
952
  /** Page number (1-indexed) */
942
953
  page: number;
943
954
  /** Coordinates in PDF points (origin: bottom-left of page) */
944
- rect: {
945
- x: number;
946
- y: number;
947
- width: number;
948
- height: number;
949
- };
955
+ rect: PdfRect;
956
+ /** Additional rects for multi-line text highlights. When present, all rects are rendered. */
957
+ rects?: PdfRect[];
950
958
  /** Optional label or tooltip text */
951
959
  label?: string;
952
960
  /** Optional color override (CSS color string) */
953
961
  color?: string;
954
962
  }
963
+ /** A built-in annotation type (highlight, underline, comment, pin). */
964
+ interface PdfStandardAnnotation extends PdfAnnotationBase {
965
+ /** The type of annotation to render */
966
+ type: "highlight" | "underline" | "comment" | "pin";
967
+ }
968
+ /** A custom annotation with a user-provided renderer. */
969
+ interface PdfCustomAnnotation extends PdfAnnotationBase {
970
+ /** Must be "custom" for custom-rendered annotations */
971
+ type: "custom";
972
+ /** Render function for the custom annotation content (required for custom type) */
973
+ render: (props: PdfAnnotationRenderProps) => React__default.ReactNode;
974
+ }
975
+ /** A single annotation positioned on a specific page of the PDF. */
976
+ type PdfAnnotation = PdfStandardAnnotation | PdfCustomAnnotation;
955
977
  /** Result passed to the {@link PdfViewerProps.onDownload} callback. */
956
978
  type PdfDownloadResult = {
957
979
  success: true;
@@ -960,12 +982,25 @@ type PdfDownloadResult = {
960
982
  success: false;
961
983
  error: Error;
962
984
  };
985
+ /** Possible values for a PDF form field. */
986
+ type PdfFormFieldValue = string | boolean | string[];
987
+ /** Data emitted when the user creates a text highlight via the highlight editor. */
988
+ interface PdfTextHighlightEvent {
989
+ /** Page number (1-indexed) */
990
+ page: number;
991
+ /** Bounding rects in PDF coordinate space (bottom-left origin) */
992
+ rects: PdfRect[];
993
+ /** The selected text content */
994
+ selectedText: string;
995
+ /** Highlight color as CSS color string */
996
+ color: string;
997
+ }
963
998
  /** Props for the {@link PdfViewer} component. */
964
999
  interface PdfViewerProps {
965
1000
  /** PDF source — URL string or ArrayBuffer */
966
1001
  src: string | ArrayBuffer;
967
- /** Annotations to overlay on the PDF, keyed by page number (1-indexed) */
968
- annotations?: Record<number, PdfAnnotation[]>;
1002
+ /** Annotations to overlay on the PDF */
1003
+ annotations?: PdfAnnotation[];
969
1004
  /**
970
1005
  * Callback fired when an annotation is clicked.
971
1006
  *
@@ -980,6 +1015,26 @@ interface PdfViewerProps {
980
1015
  * @returns void
981
1016
  */
982
1017
  onDownload?: (result: PdfDownloadResult) => void;
1018
+ /**
1019
+ * Whether the highlight toggle button is shown in the toolbar.
1020
+ * @default false
1021
+ */
1022
+ enableHighlight?: boolean;
1023
+ /**
1024
+ * Callback fired when the user creates a text highlight.
1025
+ * Only fires when highlight mode is active.
1026
+ *
1027
+ * @param event - The highlight event with page, rects, text, and color
1028
+ * @returns void
1029
+ */
1030
+ onTextHighlight?: (event: PdfTextHighlightEvent) => void;
1031
+ /**
1032
+ * Callback fired when the user deletes a highlight via the PDF.js editor UI.
1033
+ *
1034
+ * @param event - The highlight event that was deleted
1035
+ * @returns void
1036
+ */
1037
+ onHighlightDelete?: (event: PdfTextHighlightEvent) => void;
983
1038
  /** Initial page number (1-indexed, default 1) */
984
1039
  initialPage?: number;
985
1040
  /** Initial zoom scale (default 1.0) */
@@ -1002,11 +1057,32 @@ interface PdfViewerProps {
1002
1057
  * If omitted, no icons are rendered.
1003
1058
  */
1004
1059
  outlineIcons?: Partial<Record<number, React__default.ComponentType>>;
1060
+ /**
1061
+ * Initial form field values keyed by field name. Applied when the document loads.
1062
+ * Use this to pre-populate form fields when resuming a previously edited PDF.
1063
+ */
1064
+ formData?: Record<string, PdfFormFieldValue>;
1065
+ /**
1066
+ * Callback fired when the user clicks the save button in the toolbar.
1067
+ * Receives all current form field values keyed by field name.
1068
+ *
1069
+ * @param data - All form field values keyed by field name
1070
+ * @returns void
1071
+ */
1072
+ onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;
1073
+ /**
1074
+ * Callback fired when any form field value changes.
1075
+ *
1076
+ * @param fieldName - The name of the field that changed
1077
+ * @param value - The new value
1078
+ * @returns void
1079
+ */
1080
+ onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;
1005
1081
  /** Additional CSS class name for the root element */
1006
1082
  className?: string;
1007
1083
  }
1008
1084
 
1009
- declare function BasePdfViewer({ src, annotations, onAnnotationClick, onDownload, initialPage, initialScale, initialSidebarOpen, enableDownload, sidebarMode: sidebarModeProp, outlineIcons, className, }: PdfViewerProps): React__default.ReactElement;
1085
+ declare function BasePdfViewer({ src, annotations, onAnnotationClick, onDownload, enableHighlight, onTextHighlight, onHighlightDelete, formData, onFormSubmit, onFormChange, initialPage, initialScale, initialSidebarOpen, enableDownload, sidebarMode: sidebarModeProp, outlineIcons, className, }: PdfViewerProps): React__default.ReactElement;
1010
1086
 
1011
1087
  interface PdfViewerAnnotationLayerProps {
1012
1088
  annotations: PdfAnnotation[];
@@ -1019,8 +1095,8 @@ declare function PdfViewerAnnotationLayer({ annotations, pageHeight, scale, onAn
1019
1095
  interface PdfViewerContentProps {
1020
1096
  /** PDF source — URL string or ArrayBuffer */
1021
1097
  src: string | ArrayBuffer;
1022
- /** Annotations to overlay on the PDF, keyed by page number (1-indexed) */
1023
- annotations?: Record<number, PdfAnnotation[]>;
1098
+ /** Annotations to overlay on the PDF */
1099
+ annotations?: PdfAnnotation[];
1024
1100
  /** Callback fired when an annotation is clicked */
1025
1101
  onAnnotationClick?: (annotation: PdfAnnotation) => void;
1026
1102
  /** Initial page number (1-indexed, default 1) */
@@ -1031,10 +1107,14 @@ interface PdfViewerContentProps {
1031
1107
  onPageChange?: (page: number) => void;
1032
1108
  /** Callback fired when the zoom scale changes */
1033
1109
  onScaleChange?: (scale: number) => void;
1110
+ /** Initial form field values keyed by field name. Applied when the document loads. */
1111
+ formData?: Record<string, PdfFormFieldValue>;
1112
+ /** Callback fired when any form field value changes. */
1113
+ onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;
1034
1114
  /** Additional CSS class name for the root element */
1035
1115
  className?: string;
1036
1116
  }
1037
- declare function PdfViewerContent({ src, annotations, onAnnotationClick, initialPage, initialScale, onPageChange: onPageChangeProp, onScaleChange: onScaleChangeProp, className, }: PdfViewerContentProps): React__default.ReactElement;
1117
+ declare function PdfViewerContent({ src, annotations, onAnnotationClick, initialPage, initialScale, onPageChange: onPageChangeProp, onScaleChange: onScaleChangeProp, formData, onFormChange, className, }: PdfViewerContentProps): React__default.ReactElement;
1038
1118
 
1039
1119
  interface PdfViewerOutlineSidebarProps {
1040
1120
  outlineItems: OutlineItem[];
@@ -1080,8 +1160,13 @@ interface PdfViewerToolbarProps {
1080
1160
  enableDownload: boolean;
1081
1161
  onRotateLeft: () => void;
1082
1162
  onRotateRight: () => void;
1163
+ enableHighlight: boolean;
1164
+ highlightModeActive: boolean;
1165
+ onHighlightToggle: () => void;
1166
+ enableFormSave?: boolean;
1167
+ onFormSave?: () => void;
1083
1168
  }
1084
- declare function PdfViewerToolbar({ currentPage, numPages, scale, sidebarOpen, onPageChange, onScaleChange, onSearchOpen, onSidebarToggle, onDownload, enableDownload, onRotateLeft, onRotateRight, }: PdfViewerToolbarProps): React__default.ReactElement;
1169
+ declare function PdfViewerToolbar({ currentPage, numPages, scale, sidebarOpen, onPageChange, onScaleChange, onSearchOpen, onSidebarToggle, onDownload, enableDownload, onRotateLeft, onRotateRight, enableHighlight, highlightModeActive, onHighlightToggle, enableFormSave, onFormSave, }: PdfViewerToolbarProps): React__default.ReactElement;
1085
1170
 
1086
1171
  interface AnnotationPortalTarget {
1087
1172
  pageNumber: number;
@@ -1091,6 +1176,11 @@ interface AnnotationPortalTarget {
1091
1176
  }
1092
1177
  declare function usePdfAnnotationPortals(pdfViewerRef: RefObject<PDFViewer | null>, eventBusRef: RefObject<EventBus | null>, document: PDFDocumentProxy | undefined): AnnotationPortalTarget[];
1093
1178
 
1179
+ /**
1180
+ * Groups a flat array of annotations by page number for efficient per-page lookup.
1181
+ */
1182
+ declare function usePdfAnnotationsByPage(annotations: PdfAnnotation[]): Record<number, PdfAnnotation[]>;
1183
+
1094
1184
  interface UsePdfDocumentResult {
1095
1185
  document: PDFDocumentProxy | undefined;
1096
1186
  numPages: number;
@@ -1099,6 +1189,45 @@ interface UsePdfDocumentResult {
1099
1189
  }
1100
1190
  declare function usePdfDocument(src: string | ArrayBuffer): UsePdfDocumentResult;
1101
1191
 
1192
+ interface UsePdfFormFieldsOptions {
1193
+ pdfViewerRef: RefObject<PDFViewer | null>;
1194
+ eventBusRef: RefObject<EventBus | null>;
1195
+ document: PDFDocumentProxy | undefined;
1196
+ formData?: Record<string, PdfFormFieldValue>;
1197
+ onFormSubmit?: (data: Record<string, PdfFormFieldValue>) => void;
1198
+ onFormChange?: (fieldName: string, value: PdfFormFieldValue) => void;
1199
+ }
1200
+ interface UsePdfFormFieldsResult {
1201
+ /** Whether the loaded PDF contains interactive form fields. */
1202
+ hasFormFields: boolean;
1203
+ /** Collect all current form field values and invoke onFormSubmit. */
1204
+ submitFormData: () => void;
1205
+ }
1206
+ /**
1207
+ * Hook that manages interactive PDF form fields.
1208
+ * Builds a field metadata map, pre-populates initial values,
1209
+ * listens for field changes, and collects values on submit.
1210
+ */
1211
+ declare function usePdfFormFields({ pdfViewerRef, eventBusRef, document, formData, onFormSubmit, onFormChange, }: UsePdfFormFieldsOptions): UsePdfFormFieldsResult;
1212
+
1213
+ interface UsePdfHighlightModeOptions {
1214
+ pdfViewerRef: RefObject<PDFViewer | null>;
1215
+ document: PDFDocumentProxy | undefined;
1216
+ enabled: boolean;
1217
+ onTextHighlight?: (event: PdfTextHighlightEvent) => void;
1218
+ onHighlightDelete?: (event: PdfTextHighlightEvent) => void;
1219
+ }
1220
+ interface UsePdfHighlightModeResult {
1221
+ highlightModeActive: boolean;
1222
+ toggleHighlightMode: () => void;
1223
+ }
1224
+ /**
1225
+ * Hook that manages the PDF.js built-in highlight annotation editor mode.
1226
+ * When active, users can select text to create highlights.
1227
+ * A callback fires with the annotation details for persistence.
1228
+ */
1229
+ declare function usePdfHighlightMode({ pdfViewerRef, document, enabled, onTextHighlight, onHighlightDelete, }: UsePdfHighlightModeOptions): UsePdfHighlightModeResult;
1230
+
1102
1231
  declare function usePdfOutline(document: PDFDocumentProxy | undefined): OutlineItem[];
1103
1232
 
1104
1233
  interface UsePdfViewerResult {
@@ -1393,6 +1522,7 @@ interface TextAreaFieldProps extends BaseFormFieldProps<string>, Pick<React__def
1393
1522
  * If provided, this will be added to the field validation
1394
1523
  */
1395
1524
  | "maxLength"> {
1525
+ placeholder?: string;
1396
1526
  }
1397
1527
  interface TextInputFieldProps extends BaseFormFieldProps<string>, Pick<React__default.InputHTMLAttributes<HTMLInputElement>,
1398
1528
  /**
@@ -1423,7 +1553,11 @@ interface NumberInputFieldProps extends BaseFormFieldProps<number>, Pick<React__
1423
1553
  */
1424
1554
  interface RadioButtonsFieldProps<V> extends BaseFormFieldProps<V> {
1425
1555
  /**
1426
- * Available options for radio buttons
1556
+ * Available options for radio buttons.
1557
+ *
1558
+ * Values are compared by reference equality (`===`). When options contain
1559
+ * non-primitive values, pass the same object references for `value` and
1560
+ * the corresponding option entry.
1427
1561
  */
1428
1562
  options: Option<V>[];
1429
1563
  }
@@ -1632,4 +1766,4 @@ declare const ActionForm: <Q extends ActionDefinition<unknown>>(props: ActionFor
1632
1766
 
1633
1767
  declare const BaseForm: React__default.FC<BaseFormProps>;
1634
1768
 
1635
- export { ActionForm, type ActionFormProps, type ActionParameters, type AnnotationPortalTarget, type AnnotationType, BaseFilterList, type BaseFilterListProps, BaseForm, type BaseFormFieldProps, type BaseFormProps, BasePdfViewer, BaseTable, type BaseTableProps, type CellEditInfo, ColumnConfigDialog, type ColumnConfigDialogProps, type ColumnConfigOptions, type ColumnDefinition, type ColumnDefinitionLocator, type CustomColumnLocator, type CustomFieldProps, type DatetimePickerFieldProps, type DropdownFieldProps, type FieldComponent, type FieldValueType, type FilePickerProps, type FilterComponentType, type FilterDefinitionUnion, FilterList, type FilterListItemProps, type FilterListProps, type FilterState, type FormError, type FormFieldDefinition, type FormFieldPropsByType, type FormState, type FunctionColumnLocator, type NumberInputFieldProps, type ObjectSetFieldProps, ObjectTable, type ObjectTableProps, type Option, type OutlineItem, type PdfAnnotation, type PdfDownloadResult, PdfViewer, PdfViewerAnnotationLayer, type PdfViewerAnnotationLayerProps, PdfViewerContent, type PdfViewerContentProps, type PdfViewerMediaProps, PdfViewerOutlineSidebar, type PdfViewerOutlineSidebarProps, type PdfViewerProps, PdfViewerSearchBar, type PdfViewerSearchBarProps, PdfViewerSidebar, type PdfViewerSidebarProps, PdfViewerToolbar, type PdfViewerToolbarProps, type PropertyColumnLocator, type PropertyFilterDefinition, type RadioButtonsFieldProps, type RdpColumnLocator, type RenderFilterInput, type RendererFieldDefinition, type SidebarMode, type TextAreaFieldProps, type TextInputFieldProps, type UsePdfViewerCoreOptions, type UsePdfViewerCoreResult, type UsePdfViewerResult, type UsePdfViewerSearchResult, type UsePdfViewerStateOptions, type UsePdfViewerStateResult, deserializeFilterStates, serializeFilterStates, usePdfAnnotationPortals, usePdfDocument, usePdfOutline, usePdfViewer, usePdfViewerCore, usePdfViewerSearch, usePdfViewerState, usePdfViewerSync };
1769
+ export { ActionForm, type ActionFormProps, type ActionParameters, type AnnotationPortalTarget, type AnnotationType, BaseFilterList, type BaseFilterListProps, BaseForm, type BaseFormFieldProps, type BaseFormProps, BasePdfViewer, BaseTable, type BaseTableProps, type CellEditInfo, ColumnConfigDialog, type ColumnConfigDialogProps, type ColumnConfigOptions, type ColumnDefinition, type ColumnDefinitionLocator, type CustomColumnLocator, type CustomFieldProps, type DatetimePickerFieldProps, type DropdownFieldProps, type FieldComponent, type FieldValueType, type FilePickerProps, type FilterComponentType, type FilterDefinitionUnion, FilterList, type FilterListItemProps, type FilterListProps, type FilterState, type FormError, type FormFieldDefinition, type FormFieldPropsByType, type FormState, type FunctionColumnLocator, type NumberInputFieldProps, type ObjectSetFieldProps, ObjectTable, type ObjectTableProps, type Option, type OutlineItem, type PdfAnnotation, type PdfAnnotationRenderProps, type PdfCustomAnnotation, type PdfDownloadResult, type PdfFormFieldValue, type PdfRect, type PdfTextHighlightEvent, PdfViewer, PdfViewerAnnotationLayer, type PdfViewerAnnotationLayerProps, PdfViewerContent, type PdfViewerContentProps, type PdfViewerMediaProps, PdfViewerOutlineSidebar, type PdfViewerOutlineSidebarProps, type PdfViewerProps, PdfViewerSearchBar, type PdfViewerSearchBarProps, PdfViewerSidebar, type PdfViewerSidebarProps, PdfViewerToolbar, type PdfViewerToolbarProps, type PropertyColumnLocator, type PropertyFilterDefinition, type RadioButtonsFieldProps, type RdpColumnLocator, type RenderFilterInput, type RendererFieldDefinition, type SidebarMode, type TextAreaFieldProps, type TextInputFieldProps, type UsePdfFormFieldsOptions, type UsePdfFormFieldsResult, type UsePdfHighlightModeOptions, type UsePdfHighlightModeResult, type UsePdfViewerCoreOptions, type UsePdfViewerCoreResult, type UsePdfViewerResult, type UsePdfViewerSearchResult, type UsePdfViewerStateOptions, type UsePdfViewerStateResult, deserializeFilterStates, serializeFilterStates, usePdfAnnotationPortals, usePdfAnnotationsByPage, usePdfDocument, usePdfFormFields, usePdfHighlightMode, usePdfOutline, usePdfViewer, usePdfViewerCore, usePdfViewerSearch, usePdfViewerState, usePdfViewerSync };
@@ -1 +1 @@
1
- {"version":3,"file":"FormFieldApi.js","names":[],"sources":["FormFieldApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n ActionParam,\n CompileTimeMetadata,\n DataValueClientToWire,\n ObjectSet,\n ObjectTypeDefinition,\n} from \"@osdk/api\";\nimport type React from \"react\";\n\n/**\n * A form field definition specifies configuration for a single field\n */\nexport interface FormFieldDefinition<\n Q extends ActionDefinition<unknown>,\n K extends FieldKey<Q> = FieldKey<Q>,\n> {\n /**\n * The field's unique key\n */\n fieldKey: K;\n\n /**\n * Display label for the field\n * If not provided, the form field will not show any label.\n */\n label?: string;\n\n /**\n * Default value of the field\n */\n defaultValue?: FieldValueType<Q, K>;\n\n /**\n * The form field component type to render\n */\n fieldComponent: ValidFormFieldForPropertyType<FieldDescriptorType<Q, K>>;\n\n /**\n * Whether the field is required\n */\n isRequired?: boolean;\n\n /**\n * Placeholder text\n */\n placeholder?: string;\n\n /**\n * Additional information to display on this field\n * The placement of helper text depends on the value of helperTextPlacement prop\n */\n helperText?: string;\n\n /**\n * The placement of the helper text either below the field or in a tooltip\n *\n * @default \"tooltip\"\n */\n helperTextPlacement?: \"bottom\" | \"tooltip\";\n\n /**\n * Whether the field is disabled\n */\n isDisabled?: boolean;\n\n /**\n * A callback to return a custom error message if validation failed\n *\n * @param validationRule the validation rule that failed with the error message\n * @returns the error message to display\n */\n onValidationError?: (error: ValidationError) => string;\n\n /**\n * Additional function to validate the field\n *\n * @param value the current field value\n * @returns a boolean promise indicating whether the value is valid\n */\n validate?: (value: FieldValueType<Q, K>) => Promise<boolean>;\n\n /**\n * The component props for the form field\n * Excludes runtime props (key, onChange) which are managed by ActionForm\n */\n fieldComponentProps?: Omit<\n FormFieldPropsByType[\n ValidFormFieldForPropertyType<\n FieldDescriptorType<Q, K>\n >\n ],\n \"key\" | \"onChange\"\n >;\n}\n\ntype ValidationError = { type: ValidationRule; error: string };\n\ntype ValidationRule =\n | \"required\"\n | \"min\"\n | \"max\"\n | \"minLength\"\n | \"maxLength\"\n | \"pattern\"\n | \"validate\";\n\n/**\n * Maps field types to their corresponding props\n */\nexport interface FormFieldPropsByType {\n DATETIME_PICKER: DatetimePickerFieldProps;\n DROPDOWN: DropdownFieldProps<unknown, boolean>;\n FILE_PICKER: FilePickerProps;\n NUMBER_INPUT: NumberInputFieldProps;\n OBJECT_SET: ObjectSetFieldProps<ObjectTypeDefinition>;\n RADIO_BUTTONS: RadioButtonsFieldProps<unknown>;\n TEXT_AREA: TextAreaFieldProps;\n TEXT_INPUT: TextInputFieldProps;\n CUSTOM: CustomFieldProps<unknown>;\n}\n\n/**\n * Datetime picker field props.\n *\n * When `formatDate` is omitted, ISO-like format is used (YYYY-MM-DD / YYYY-MM-DD HH:mm).\n */\nexport interface DatetimePickerFieldProps extends BaseFormFieldProps<Date> {\n /**\n * The earliest date the user can select.\n * If provided, this will be added to the field validation.\n */\n min?: Date;\n\n /**\n * The latest date the user can select.\n * If provided, this will be added to the field validation.\n */\n max?: Date;\n\n /**\n * Whether to show time picker.\n */\n showTime?: boolean;\n\n /**\n * Whether to close the popover after selecting a date.\n * @default true when `showTime` is false, false when `showTime` is true\n */\n closeOnSelection?: boolean;\n\n /**\n * Placeholder text shown when no value is selected.\n */\n placeholder?: string;\n\n /** Formats a Date for display in the trigger button. */\n formatDate?: (date: Date) => string;\n}\n\n/**\n * Dropdown field props with selectable items\n */\nexport interface DropdownFieldProps<V, Multiple extends boolean = false>\n extends BaseFormFieldProps<Multiple extends true ? V[] : V>\n{\n /**\n * Available items for the dropdown\n */\n items: V[];\n\n /**\n * Converts an item to a display string. Defaults to `String()`.\n */\n itemToStringLabel?: (item: V) => string;\n\n /**\n * Returns a unique string key for a list item. Used as the React `key`.\n * Falls back to the item's index when not provided.\n */\n itemToKey?: (item: V) => string;\n\n /**\n * Custom equality check for item values. Defaults to `Object.is`.\n * Required when items are objects to ensure correct selection matching.\n */\n isItemEqual?: (a: V, b: V) => boolean;\n\n /**\n * Whether the dropdown allows searching/filtering.\n * When true, renders a Combobox with a search input.\n * When false (default), renders a Select dropdown.\n */\n isSearchable?: boolean;\n\n /**\n * Placeholder text shown when no value is selected.\n */\n placeholder?: string;\n\n /**\n * Whether multiple values can be selected\n */\n isMultiple?: Multiple;\n}\n\nexport interface FilePickerProps extends BaseFormFieldProps<File | File[]> {\n /**\n * Whether multiple files can be selected\n */\n isMulti?: boolean;\n\n /**\n * Accepted file types (e.g., \"image/*\", \".pdf\")\n */\n accept?: string | string[];\n\n /**\n * Maximum file size in bytes\n */\n maxSize?: number;\n}\n\n/**\n * Text area field props\n */\nexport interface TextAreaFieldProps extends\n BaseFormFieldProps<string>,\n Pick<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n | \"rows\"\n | \"wrap\"\n /**\n * If provided, this will be added to the field validation\n */\n | \"minLength\"\n /**\n * If provided, this will be added to the field validation\n */\n | \"maxLength\"\n >\n{}\n\nexport interface TextInputFieldProps extends\n BaseFormFieldProps<string>,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n /**\n * If provided, this will be added to the field validation\n */\n | \"minLength\"\n /**\n * If provided, this will be added to the field validation\n */\n | \"maxLength\"\n >\n{\n placeholder?: string;\n}\n\n/**\n * Number input field props\n */\nexport interface NumberInputFieldProps extends\n BaseFormFieldProps<number>,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n /**\n * If provided, this will be added to the field validation\n */\n | \"min\"\n /**\n * If provided, this will be added to the field validation\n */\n | \"max\"\n | \"step\"\n >\n{}\n\n/**\n * Radio buttons field props\n */\nexport interface RadioButtonsFieldProps<V> extends BaseFormFieldProps<V> {\n /**\n * Available options for radio buttons\n */\n options: Option<V>[];\n}\n\n/**\n * Option interface for radio button options\n */\nexport interface Option<V> {\n label: string;\n value: V;\n}\n\n/**\n * Object set field displays the summary of the count of the given object set\n */\nexport interface ObjectSetFieldProps<T extends ObjectTypeDefinition>\n extends BaseFormFieldProps<ObjectSet<T>>\n{}\n\n/**\n * Custom field props for user-defined renderers\n */\nexport interface CustomFieldProps<V> extends BaseFormFieldProps<V> {\n /**\n * Custom renderer function\n */\n customRenderer: (props: BaseFormFieldProps<V>) => React.ReactNode;\n}\n\nexport interface BaseFormFieldProps<V> {\n /**\n * The HTML `id` attribute for the field input element.\n * Used for `<label htmlFor>` association.\n */\n id?: string;\n\n /**\n * The value of the form field\n */\n value: V | null;\n /**\n * Called when the field value changes.\n *\n * ActionForm internally wraps this to pass the key to `onFieldValueChange`:\n * ```\n * <DropdownField\n * {...fieldDef}\n * onChange={(value) => onFieldValueChange(fieldDef.key, value)}\n * />\n * ```\n *\n * @param value The new value of the form field\n */\n onChange?: (value: V | null) => void;\n}\n\nexport type FieldKey<Q extends ActionDefinition<unknown>> =\n keyof ActionParameters<Q>;\n\n/**\n * Extracts parameters from an ActionDefinition\n */\nexport type ActionParameters<Q extends ActionDefinition<unknown>> =\n CompileTimeMetadata<Q>[\"parameters\"];\n\n/**\n * Extracts the value type for a specific parameter\n *\n * TODO: Re-use `BaseType`\n */\nexport type FieldValueType<\n Q extends ActionDefinition<unknown>,\n K extends keyof ActionParameters<Q> = keyof ActionParameters<Q>,\n> = ActionParameters<Q>[K][\"type\"] extends\n ActionMetadata.DataType.Object<infer T> ? ActionParam.ObjectType<T>\n : ActionParameters<Q>[K][\"type\"] extends ActionMetadata.DataType.ObjectSet<\n infer T\n > ? ActionParam.ObjectSetType<T>\n : ActionParameters<Q>[K][\"type\"] extends ActionMetadata.DataType.Struct<\n infer T\n > ? ActionParam.StructType<T>\n : ActionParameters<Q>[K][\"type\"] extends keyof DataValueClientToWire\n ? DataValueClientToWire[ActionParameters<Q>[K][\"type\"]]\n : never;\n\n/**\n * Extracts the parameter type descriptor for a specific action parameter.\n */\nexport type FieldDescriptorType<\n Q extends ActionDefinition<unknown> = ActionDefinition<unknown>,\n K extends keyof ActionParameters<Q> = keyof ActionParameters<Q>,\n> = ActionParameters<Q>[K][\"type\"];\n\n/**\n * Available form field component types\n */\nexport type FieldComponent =\n | \"DATETIME_PICKER\"\n | \"DROPDOWN\"\n | \"FILE_PICKER\"\n | \"NUMBER_INPUT\"\n | \"RADIO_BUTTONS\"\n | \"OBJECT_SET\"\n | \"TEXT_AREA\"\n | \"TEXT_INPUT\"\n | \"CUSTOM\";\n\n/**\n * Describes the data type of a form field, independent of OSDK.\n * Mirrors ActionMetadata.DataType to keep the rendering layer OSDK-agnostic.\n */\nexport type FieldType =\n | \"boolean\"\n | \"string\"\n | \"integer\"\n | \"long\"\n | \"double\"\n | \"datetime\"\n | \"timestamp\"\n | \"attachment\"\n | \"marking\"\n | \"mediaReference\"\n | \"objectType\"\n | \"geoshape\"\n | \"geohash\"\n | { type: \"object\"; object: string }\n | { type: \"objectSet\"; objectSet: string }\n | { type: \"interface\"; interface: string }\n | { type: \"struct\"; struct: Record<string, string> };\n\n/**\n * An OSDK-agnostic field definition used by BaseForm and FormFieldRenderer.\n * Contains only the information needed to render a single field — no generics,\n * no compile-time parameter constraints.\n *\n * Implemented as a distributed mapped type: switching on `fieldComponent`\n * narrows `fieldComponentProps` to the correct props type automatically.\n */\nexport type RendererFieldDefinition = {\n [K in FieldComponent]: {\n fieldKey: string;\n fieldComponent: K;\n fieldType?: FieldType;\n label?: string;\n defaultValue?: unknown;\n isRequired?: boolean;\n placeholder?: string;\n helperText?: string;\n helperTextPlacement?: \"bottom\" | \"tooltip\";\n fieldComponentProps?: Omit<FormFieldPropsByType[K], \"value\" | \"onChange\">;\n };\n}[FieldComponent];\n\n/**\n * Gets valid form field types for a given property type\n */\nexport type ValidFormFieldForPropertyType<P extends FieldDescriptorType> =\n P extends \"objectSet\" ? \"OBJECT_SET\"\n : P extends \"object\" ? \"DROPDOWN\"\n : P extends \"mediaReference\" | \"attachment\" ? \"FILE_PICKER\"\n : P extends \"boolean\" ? \"RADIO_BUTTONS\" | \"DROPDOWN\"\n : P extends \"string\" ? \"TEXT_INPUT\" | \"TEXT_AREA\"\n : P extends \"datetime\" | \"timestamp\" ? \"DATETIME_PICKER\"\n : P extends\n | \"double\"\n | \"integer\"\n | \"long\"\n | \"float\"\n | \"short\"\n | \"byte\"\n | \"decimal\" ? \"NUMBER_INPUT\"\n : never;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"FormFieldApi.js","names":[],"sources":["FormFieldApi.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n ActionParam,\n CompileTimeMetadata,\n DataValueClientToWire,\n ObjectSet,\n ObjectTypeDefinition,\n} from \"@osdk/api\";\nimport type React from \"react\";\n\n/**\n * A form field definition specifies configuration for a single field\n */\nexport interface FormFieldDefinition<\n Q extends ActionDefinition<unknown>,\n K extends FieldKey<Q> = FieldKey<Q>,\n> {\n /**\n * The field's unique key\n */\n fieldKey: K;\n\n /**\n * Display label for the field\n * If not provided, the form field will not show any label.\n */\n label?: string;\n\n /**\n * Default value of the field\n */\n defaultValue?: FieldValueType<Q, K>;\n\n /**\n * The form field component type to render\n */\n fieldComponent: ValidFormFieldForPropertyType<FieldDescriptorType<Q, K>>;\n\n /**\n * Whether the field is required\n */\n isRequired?: boolean;\n\n /**\n * Placeholder text\n */\n placeholder?: string;\n\n /**\n * Additional information to display on this field\n * The placement of helper text depends on the value of helperTextPlacement prop\n */\n helperText?: string;\n\n /**\n * The placement of the helper text either below the field or in a tooltip\n *\n * @default \"tooltip\"\n */\n helperTextPlacement?: \"bottom\" | \"tooltip\";\n\n /**\n * Whether the field is disabled\n */\n isDisabled?: boolean;\n\n /**\n * A callback to return a custom error message if validation failed\n *\n * @param validationRule the validation rule that failed with the error message\n * @returns the error message to display\n */\n onValidationError?: (error: ValidationError) => string;\n\n /**\n * Additional function to validate the field\n *\n * @param value the current field value\n * @returns a boolean promise indicating whether the value is valid\n */\n validate?: (value: FieldValueType<Q, K>) => Promise<boolean>;\n\n /**\n * The component props for the form field\n * Excludes runtime props (key, onChange) which are managed by ActionForm\n */\n fieldComponentProps?: Omit<\n FormFieldPropsByType[\n ValidFormFieldForPropertyType<\n FieldDescriptorType<Q, K>\n >\n ],\n \"key\" | \"onChange\"\n >;\n}\n\ntype ValidationError = { type: ValidationRule; error: string };\n\ntype ValidationRule =\n | \"required\"\n | \"min\"\n | \"max\"\n | \"minLength\"\n | \"maxLength\"\n | \"pattern\"\n | \"validate\";\n\n/**\n * Maps field types to their corresponding props\n */\nexport interface FormFieldPropsByType {\n DATETIME_PICKER: DatetimePickerFieldProps;\n DROPDOWN: DropdownFieldProps<unknown, boolean>;\n FILE_PICKER: FilePickerProps;\n NUMBER_INPUT: NumberInputFieldProps;\n OBJECT_SET: ObjectSetFieldProps<ObjectTypeDefinition>;\n RADIO_BUTTONS: RadioButtonsFieldProps<unknown>;\n TEXT_AREA: TextAreaFieldProps;\n TEXT_INPUT: TextInputFieldProps;\n CUSTOM: CustomFieldProps<unknown>;\n}\n\n/**\n * Datetime picker field props.\n *\n * When `formatDate` is omitted, ISO-like format is used (YYYY-MM-DD / YYYY-MM-DD HH:mm).\n */\nexport interface DatetimePickerFieldProps extends BaseFormFieldProps<Date> {\n /**\n * The earliest date the user can select.\n * If provided, this will be added to the field validation.\n */\n min?: Date;\n\n /**\n * The latest date the user can select.\n * If provided, this will be added to the field validation.\n */\n max?: Date;\n\n /**\n * Whether to show time picker.\n */\n showTime?: boolean;\n\n /**\n * Whether to close the popover after selecting a date.\n * @default true when `showTime` is false, false when `showTime` is true\n */\n closeOnSelection?: boolean;\n\n /**\n * Placeholder text shown when no value is selected.\n */\n placeholder?: string;\n\n /** Formats a Date for display in the trigger button. */\n formatDate?: (date: Date) => string;\n}\n\n/**\n * Dropdown field props with selectable items\n */\nexport interface DropdownFieldProps<V, Multiple extends boolean = false>\n extends BaseFormFieldProps<Multiple extends true ? V[] : V>\n{\n /**\n * Available items for the dropdown\n */\n items: V[];\n\n /**\n * Converts an item to a display string. Defaults to `String()`.\n */\n itemToStringLabel?: (item: V) => string;\n\n /**\n * Returns a unique string key for a list item. Used as the React `key`.\n * Falls back to the item's index when not provided.\n */\n itemToKey?: (item: V) => string;\n\n /**\n * Custom equality check for item values. Defaults to `Object.is`.\n * Required when items are objects to ensure correct selection matching.\n */\n isItemEqual?: (a: V, b: V) => boolean;\n\n /**\n * Whether the dropdown allows searching/filtering.\n * When true, renders a Combobox with a search input.\n * When false (default), renders a Select dropdown.\n */\n isSearchable?: boolean;\n\n /**\n * Placeholder text shown when no value is selected.\n */\n placeholder?: string;\n\n /**\n * Whether multiple values can be selected\n */\n isMultiple?: Multiple;\n}\n\nexport interface FilePickerProps extends BaseFormFieldProps<File | File[]> {\n /**\n * Whether multiple files can be selected\n */\n isMulti?: boolean;\n\n /**\n * Accepted file types (e.g., \"image/*\", \".pdf\")\n */\n accept?: string | string[];\n\n /**\n * Maximum file size in bytes\n */\n maxSize?: number;\n}\n\n/**\n * Text area field props\n */\nexport interface TextAreaFieldProps extends\n BaseFormFieldProps<string>,\n Pick<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n | \"rows\"\n | \"wrap\"\n /**\n * If provided, this will be added to the field validation\n */\n | \"minLength\"\n /**\n * If provided, this will be added to the field validation\n */\n | \"maxLength\"\n >\n{\n placeholder?: string;\n}\n\nexport interface TextInputFieldProps extends\n BaseFormFieldProps<string>,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n /**\n * If provided, this will be added to the field validation\n */\n | \"minLength\"\n /**\n * If provided, this will be added to the field validation\n */\n | \"maxLength\"\n >\n{\n placeholder?: string;\n}\n\n/**\n * Number input field props\n */\nexport interface NumberInputFieldProps extends\n BaseFormFieldProps<number>,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n /**\n * If provided, this will be added to the field validation\n */\n | \"min\"\n /**\n * If provided, this will be added to the field validation\n */\n | \"max\"\n | \"step\"\n >\n{}\n\n/**\n * Radio buttons field props\n */\nexport interface RadioButtonsFieldProps<V> extends BaseFormFieldProps<V> {\n /**\n * Available options for radio buttons.\n *\n * Values are compared by reference equality (`===`). When options contain\n * non-primitive values, pass the same object references for `value` and\n * the corresponding option entry.\n */\n options: Option<V>[];\n}\n\n/**\n * Option interface for radio button options\n */\nexport interface Option<V> {\n label: string;\n value: V;\n}\n\n/**\n * Object set field displays the summary of the count of the given object set\n */\nexport interface ObjectSetFieldProps<T extends ObjectTypeDefinition>\n extends BaseFormFieldProps<ObjectSet<T>>\n{}\n\n/**\n * Custom field props for user-defined renderers\n */\nexport interface CustomFieldProps<V> extends BaseFormFieldProps<V> {\n /**\n * Custom renderer function\n */\n customRenderer: (props: BaseFormFieldProps<V>) => React.ReactNode;\n}\n\nexport interface BaseFormFieldProps<V> {\n /**\n * The HTML `id` attribute for the field input element.\n * Used for `<label htmlFor>` association.\n */\n id?: string;\n\n /**\n * The value of the form field\n */\n value: V | null;\n /**\n * Called when the field value changes.\n *\n * ActionForm internally wraps this to pass the key to `onFieldValueChange`:\n * ```\n * <DropdownField\n * {...fieldDef}\n * onChange={(value) => onFieldValueChange(fieldDef.key, value)}\n * />\n * ```\n *\n * @param value The new value of the form field\n */\n onChange?: (value: V | null) => void;\n}\n\nexport type FieldKey<Q extends ActionDefinition<unknown>> =\n keyof ActionParameters<Q>;\n\n/**\n * Extracts parameters from an ActionDefinition\n */\nexport type ActionParameters<Q extends ActionDefinition<unknown>> =\n CompileTimeMetadata<Q>[\"parameters\"];\n\n/**\n * Extracts the value type for a specific parameter\n *\n * TODO: Re-use `BaseType`\n */\nexport type FieldValueType<\n Q extends ActionDefinition<unknown>,\n K extends keyof ActionParameters<Q> = keyof ActionParameters<Q>,\n> = ActionParameters<Q>[K][\"type\"] extends\n ActionMetadata.DataType.Object<infer T> ? ActionParam.ObjectType<T>\n : ActionParameters<Q>[K][\"type\"] extends ActionMetadata.DataType.ObjectSet<\n infer T\n > ? ActionParam.ObjectSetType<T>\n : ActionParameters<Q>[K][\"type\"] extends ActionMetadata.DataType.Struct<\n infer T\n > ? ActionParam.StructType<T>\n : ActionParameters<Q>[K][\"type\"] extends keyof DataValueClientToWire\n ? DataValueClientToWire[ActionParameters<Q>[K][\"type\"]]\n : never;\n\n/**\n * Extracts the parameter type descriptor for a specific action parameter.\n */\nexport type FieldDescriptorType<\n Q extends ActionDefinition<unknown> = ActionDefinition<unknown>,\n K extends keyof ActionParameters<Q> = keyof ActionParameters<Q>,\n> = ActionParameters<Q>[K][\"type\"];\n\n/**\n * Available form field component types\n */\nexport type FieldComponent =\n | \"DATETIME_PICKER\"\n | \"DROPDOWN\"\n | \"FILE_PICKER\"\n | \"NUMBER_INPUT\"\n | \"RADIO_BUTTONS\"\n | \"OBJECT_SET\"\n | \"TEXT_AREA\"\n | \"TEXT_INPUT\"\n | \"CUSTOM\";\n\n/**\n * Describes the data type of a form field, independent of OSDK.\n * Mirrors ActionMetadata.DataType to keep the rendering layer OSDK-agnostic.\n */\nexport type FieldType =\n | \"boolean\"\n | \"string\"\n | \"integer\"\n | \"long\"\n | \"double\"\n | \"datetime\"\n | \"timestamp\"\n | \"attachment\"\n | \"marking\"\n | \"mediaReference\"\n | \"objectType\"\n | \"geoshape\"\n | \"geohash\"\n | { type: \"object\"; object: string }\n | { type: \"objectSet\"; objectSet: string }\n | { type: \"interface\"; interface: string }\n | { type: \"struct\"; struct: Record<string, string> };\n\n/**\n * An OSDK-agnostic field definition used by BaseForm and FormFieldRenderer.\n * Contains only the information needed to render a single field — no generics,\n * no compile-time parameter constraints.\n *\n * Implemented as a distributed mapped type: switching on `fieldComponent`\n * narrows `fieldComponentProps` to the correct props type automatically.\n */\nexport type RendererFieldDefinition = {\n [K in FieldComponent]: {\n fieldKey: string;\n fieldComponent: K;\n fieldType?: FieldType;\n label?: string;\n defaultValue?: unknown;\n isRequired?: boolean;\n placeholder?: string;\n helperText?: string;\n helperTextPlacement?: \"bottom\" | \"tooltip\";\n fieldComponentProps?: Omit<FormFieldPropsByType[K], \"value\" | \"onChange\">;\n };\n}[FieldComponent];\n\n/**\n * Gets valid form field types for a given property type\n */\nexport type ValidFormFieldForPropertyType<P extends FieldDescriptorType> =\n P extends \"objectSet\" ? \"OBJECT_SET\"\n : P extends \"object\" ? \"DROPDOWN\"\n : P extends \"mediaReference\" | \"attachment\" ? \"FILE_PICKER\"\n : P extends \"boolean\" ? \"RADIO_BUTTONS\" | \"DROPDOWN\"\n : P extends \"string\" ? \"TEXT_INPUT\" | \"TEXT_AREA\"\n : P extends \"datetime\" | \"timestamp\" ? \"DATETIME_PICKER\"\n : P extends\n | \"double\"\n | \"integer\"\n | \"long\"\n | \"float\"\n | \"short\"\n | \"byte\"\n | \"decimal\" ? \"NUMBER_INPUT\"\n : never;\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- .osdkTextInput {
17
+ .osdkBaseInput {
18
18
  display: block;
19
19
  width: 100%;
20
20
  min-height: var(--osdk-input-min-height);
@@ -1,6 +1,6 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  /*
3
- * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,11 @@ import React, { memo } from "react";
19
19
  import { FormField } from "../FormField.js";
20
20
  import { DatetimePickerField } from "./DatetimePickerField.js";
21
21
  import { DropdownField } from "./DropdownField.js";
22
+ import { RadioButtonsField } from "./RadioButtonsField.js";
23
+ import { TextAreaField } from "./TextAreaField.js";
22
24
  import { TextInputField } from "./TextInputField.js";
23
25
  const EMPTY_ITEMS = [];
26
+ const EMPTY_OPTIONS = [];
24
27
  export const FormFieldRenderer = /*#__PURE__*/memo(function ({
25
28
  fieldDefinition,
26
29
  value,
@@ -42,16 +45,19 @@ export const FormFieldRenderer = /*#__PURE__*/memo(function ({
42
45
  function renderFieldComponent(fieldDefinition, value, onChange) {
43
46
  switch (fieldDefinition.fieldComponent) {
44
47
  case "TEXT_INPUT":
45
- // TODO: Render a <textarea> for TEXT_AREA instead of falling through
48
+ return /*#__PURE__*/React.createElement(TextInputField, _extends({
49
+ id: fieldDefinition.fieldKey,
50
+ value: value != null ? String(value) : "",
51
+ onChange: onChange,
52
+ placeholder: fieldDefinition.placeholder
53
+ }, fieldDefinition.fieldComponentProps));
46
54
  case "TEXT_AREA":
47
- return /*#__PURE__*/React.createElement(TextInputField, {
48
- id: fieldDefinition.fieldKey
49
- // TODO: Use coerceFieldValue
50
- ,
55
+ return /*#__PURE__*/React.createElement(TextAreaField, _extends({
56
+ id: fieldDefinition.fieldKey,
51
57
  value: value != null ? String(value) : "",
52
58
  onChange: onChange,
53
59
  placeholder: fieldDefinition.placeholder
54
- });
60
+ }, fieldDefinition.fieldComponentProps));
55
61
  case "DROPDOWN":
56
62
  {
57
63
  const {
@@ -74,8 +80,20 @@ function renderFieldComponent(fieldDefinition, value, onChange) {
74
80
  value: value instanceof Date ? value : null,
75
81
  onChange: onChange
76
82
  }, fieldDefinition.fieldComponentProps));
77
- case "NUMBER_INPUT":
78
83
  case "RADIO_BUTTONS":
84
+ {
85
+ const {
86
+ options = EMPTY_OPTIONS,
87
+ ...radioProps
88
+ } = fieldDefinition.fieldComponentProps ?? {};
89
+ return /*#__PURE__*/React.createElement(RadioButtonsField, _extends({
90
+ id: fieldDefinition.fieldKey,
91
+ value: value,
92
+ onChange: onChange,
93
+ options: options
94
+ }, radioProps));
95
+ }
96
+ case "NUMBER_INPUT":
79
97
  case "FILE_PICKER":
80
98
  case "OBJECT_SET":
81
99
  case "CUSTOM":
@@ -1 +1 @@
1
- {"version":3,"file":"FormFieldRenderer.js","names":["React","memo","FormField","DatetimePickerField","DropdownField","TextInputField","EMPTY_ITEMS","FormFieldRenderer","fieldDefinition","value","onFieldValueChange","label","isRequired","helperText","helperTextPlacement","createElement","fieldKey","undefined","renderFieldComponent","onChange","fieldComponent","id","String","placeholder","items","dropdownProps","fieldComponentProps","_extends","Date","assertUnreachableFieldComponent","Error"],"sources":["FormFieldRenderer.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from \"react\";\nimport { FormField } from \"../FormField.js\";\nimport type { RendererFieldDefinition } from \"../FormFieldApi.js\";\nimport { DatetimePickerField } from \"./DatetimePickerField.js\";\nimport { DropdownField } from \"./DropdownField.js\";\nimport { TextInputField } from \"./TextInputField.js\";\n\nconst EMPTY_ITEMS: unknown[] = [];\n\nexport interface FormFieldRendererProps {\n fieldDefinition: RendererFieldDefinition;\n value: unknown;\n onFieldValueChange: (value: unknown) => void;\n}\n\nexport const FormFieldRenderer: React.FC<FormFieldRendererProps> = memo(\n function FormFieldRendererFn({\n fieldDefinition,\n value,\n onFieldValueChange,\n }: FormFieldRendererProps): React.ReactElement {\n const { label, isRequired, helperText, helperTextPlacement } =\n fieldDefinition;\n\n return (\n <FormField\n label={label}\n isRequired={isRequired}\n fieldKey={fieldDefinition.fieldKey}\n helperText={helperTextPlacement !== \"tooltip\" ? helperText : undefined}\n >\n {renderFieldComponent(fieldDefinition, value, onFieldValueChange)}\n </FormField>\n );\n },\n);\n\nfunction renderFieldComponent(\n fieldDefinition: RendererFieldDefinition,\n value: unknown,\n onChange: (value: unknown) => void,\n): React.ReactElement {\n switch (fieldDefinition.fieldComponent) {\n case \"TEXT_INPUT\":\n // TODO: Render a <textarea> for TEXT_AREA instead of falling through\n case \"TEXT_AREA\":\n return (\n <TextInputField\n id={fieldDefinition.fieldKey}\n // TODO: Use coerceFieldValue\n value={value != null ? String(value) : \"\"}\n onChange={onChange}\n placeholder={fieldDefinition.placeholder}\n />\n );\n case \"DROPDOWN\": {\n const { items = EMPTY_ITEMS, ...dropdownProps } =\n fieldDefinition.fieldComponentProps ?? {};\n return (\n <DropdownField\n value={value}\n onChange={onChange}\n items={items}\n placeholder={fieldDefinition.placeholder}\n {...dropdownProps}\n />\n );\n }\n case \"DATETIME_PICKER\":\n return (\n <DatetimePickerField\n id={fieldDefinition.fieldKey}\n placeholder={fieldDefinition.placeholder}\n // TODO: Use coerceFieldValue\n value={value instanceof Date ? value : null}\n onChange={onChange}\n {...fieldDefinition.fieldComponentProps}\n />\n );\n case \"NUMBER_INPUT\":\n case \"RADIO_BUTTONS\":\n case \"FILE_PICKER\":\n case \"OBJECT_SET\":\n case \"CUSTOM\":\n return <div>Unsupported field type: {fieldDefinition.fieldComponent}\n </div>;\n default:\n return assertUnreachableFieldComponent(fieldDefinition);\n }\n}\n\nfunction assertUnreachableFieldComponent(value: never): never {\n throw new Error(`Unhandled field component: ${String(value)}`);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAIC,IAAI,QAAQ,OAAO;AACnC,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAMC,WAAsB,GAAG,EAAE;AAQjC,OAAO,MAAMC,iBAAmD,gBAAGN,IAAI,CACrE,UAA6B;EAC3BO,eAAe;EACfC,KAAK;EACLC;AACsB,CAAC,EAAsB;EAC7C,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAoB,CAAC,GAC1DN,eAAe;EAEjB,oBACER,KAAA,CAAAe,aAAA,CAACb,SAAS;IACRS,KAAK,EAAEA,KAAM;IACbC,UAAU,EAAEA,UAAW;IACvBI,QAAQ,EAAER,eAAe,CAACQ,QAAS;IACnCH,UAAU,EAAEC,mBAAmB,KAAK,SAAS,GAAGD,UAAU,GAAGI;EAAU,GAEtEC,oBAAoB,CAACV,eAAe,EAAEC,KAAK,EAAEC,kBAAkB,CACvD,CAAC;AAEhB,CACF,CAAC;AAED,SAASQ,oBAAoBA,CAC3BV,eAAwC,EACxCC,KAAc,EACdU,QAAkC,EACd;EACpB,QAAQX,eAAe,CAACY,cAAc;IACpC,KAAK,YAAY;IACjB;IACA,KAAK,WAAW;MACd,oBACEpB,KAAA,CAAAe,aAAA,CAACV,cAAc;QACbgB,EAAE,EAAEb,eAAe,CAACQ;QACpB;QAAA;QACAP,KAAK,EAAEA,KAAK,IAAI,IAAI,GAAGa,MAAM,CAACb,KAAK,CAAC,GAAG,EAAG;QAC1CU,QAAQ,EAAEA,QAAS;QACnBI,WAAW,EAAEf,eAAe,CAACe;MAAY,CAC1C,CAAC;IAEN,KAAK,UAAU;MAAE;QACf,MAAM;UAAEC,KAAK,GAAGlB,WAAW;UAAE,GAAGmB;QAAc,CAAC,GAC7CjB,eAAe,CAACkB,mBAAmB,IAAI,CAAC,CAAC;QAC3C,oBACE1B,KAAA,CAAAe,aAAA,CAACX,aAAa,EAAAuB,QAAA;UACZlB,KAAK,EAAEA,KAAM;UACbU,QAAQ,EAAEA,QAAS;UACnBK,KAAK,EAAEA,KAAM;UACbD,WAAW,EAAEf,eAAe,CAACe;QAAY,GACrCE,aAAa,CAClB,CAAC;MAEN;IACA,KAAK,iBAAiB;MACpB,oBACEzB,KAAA,CAAAe,aAAA,CAACZ,mBAAmB,EAAAwB,QAAA;QAClBN,EAAE,EAAEb,eAAe,CAACQ,QAAS;QAC7BO,WAAW,EAAEf,eAAe,CAACe;QAC7B;QAAA;QACAd,KAAK,EAAEA,KAAK,YAAYmB,IAAI,GAAGnB,KAAK,GAAG,IAAK;QAC5CU,QAAQ,EAAEA;MAAS,GACfX,eAAe,CAACkB,mBAAmB,CACxC,CAAC;IAEN,KAAK,cAAc;IACnB,KAAK,eAAe;IACpB,KAAK,aAAa;IAClB,KAAK,YAAY;IACjB,KAAK,QAAQ;MACX,oBAAO1B,KAAA,CAAAe,aAAA,cAAK,0BAAwB,EAACP,eAAe,CAACY,cAChD,CAAC;IACR;MACE,OAAOS,+BAA+B,CAACrB,eAAe,CAAC;EAC3D;AACF;AAEA,SAASqB,+BAA+BA,CAACpB,KAAY,EAAS;EAC5D,MAAM,IAAIqB,KAAK,CAAC,8BAA8BR,MAAM,CAACb,KAAK,CAAC,EAAE,CAAC;AAChE","ignoreList":[]}
1
+ {"version":3,"file":"FormFieldRenderer.js","names":["React","memo","FormField","DatetimePickerField","DropdownField","RadioButtonsField","TextAreaField","TextInputField","EMPTY_ITEMS","EMPTY_OPTIONS","FormFieldRenderer","fieldDefinition","value","onFieldValueChange","label","isRequired","helperText","helperTextPlacement","createElement","fieldKey","undefined","renderFieldComponent","onChange","fieldComponent","_extends","id","String","placeholder","fieldComponentProps","items","dropdownProps","Date","options","radioProps","assertUnreachableFieldComponent","Error"],"sources":["FormFieldRenderer.tsx"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { memo } from \"react\";\nimport { FormField } from \"../FormField.js\";\nimport type { Option, RendererFieldDefinition } from \"../FormFieldApi.js\";\nimport { DatetimePickerField } from \"./DatetimePickerField.js\";\nimport { DropdownField } from \"./DropdownField.js\";\nimport { RadioButtonsField } from \"./RadioButtonsField.js\";\nimport { TextAreaField } from \"./TextAreaField.js\";\nimport { TextInputField } from \"./TextInputField.js\";\n\nconst EMPTY_ITEMS: unknown[] = [];\nconst EMPTY_OPTIONS: Option<never>[] = [];\n\nexport interface FormFieldRendererProps {\n fieldDefinition: RendererFieldDefinition;\n value: unknown;\n onFieldValueChange: (value: unknown) => void;\n}\n\nexport const FormFieldRenderer: React.FC<FormFieldRendererProps> = memo(\n function FormFieldRendererFn({\n fieldDefinition,\n value,\n onFieldValueChange,\n }: FormFieldRendererProps): React.ReactElement {\n const { label, isRequired, helperText, helperTextPlacement } =\n fieldDefinition;\n\n return (\n <FormField\n label={label}\n isRequired={isRequired}\n fieldKey={fieldDefinition.fieldKey}\n helperText={helperTextPlacement !== \"tooltip\" ? helperText : undefined}\n >\n {renderFieldComponent(fieldDefinition, value, onFieldValueChange)}\n </FormField>\n );\n },\n);\n\nfunction renderFieldComponent(\n fieldDefinition: RendererFieldDefinition,\n value: unknown,\n onChange: (value: unknown) => void,\n): React.ReactElement {\n switch (fieldDefinition.fieldComponent) {\n case \"TEXT_INPUT\":\n return (\n <TextInputField\n id={fieldDefinition.fieldKey}\n value={value != null ? String(value) : \"\"}\n onChange={onChange}\n placeholder={fieldDefinition.placeholder}\n {...fieldDefinition.fieldComponentProps}\n />\n );\n case \"TEXT_AREA\":\n return (\n <TextAreaField\n id={fieldDefinition.fieldKey}\n value={value != null ? String(value) : \"\"}\n onChange={onChange}\n placeholder={fieldDefinition.placeholder}\n {...fieldDefinition.fieldComponentProps}\n />\n );\n case \"DROPDOWN\": {\n const { items = EMPTY_ITEMS, ...dropdownProps } =\n fieldDefinition.fieldComponentProps ?? {};\n return (\n <DropdownField\n value={value}\n onChange={onChange}\n items={items}\n placeholder={fieldDefinition.placeholder}\n {...dropdownProps}\n />\n );\n }\n case \"DATETIME_PICKER\":\n return (\n <DatetimePickerField\n id={fieldDefinition.fieldKey}\n placeholder={fieldDefinition.placeholder}\n // TODO: Use coerceFieldValue\n value={value instanceof Date ? value : null}\n onChange={onChange}\n {...fieldDefinition.fieldComponentProps}\n />\n );\n case \"RADIO_BUTTONS\": {\n const { options = EMPTY_OPTIONS, ...radioProps } =\n fieldDefinition.fieldComponentProps ?? {};\n return (\n <RadioButtonsField\n id={fieldDefinition.fieldKey}\n value={value}\n onChange={onChange}\n options={options}\n {...radioProps}\n />\n );\n }\n case \"NUMBER_INPUT\":\n case \"FILE_PICKER\":\n case \"OBJECT_SET\":\n case \"CUSTOM\":\n return <div>Unsupported field type: {fieldDefinition.fieldComponent}\n </div>;\n default:\n return assertUnreachableFieldComponent(fieldDefinition);\n }\n}\n\nfunction assertUnreachableFieldComponent(value: never): never {\n throw new Error(`Unhandled field component: ${String(value)}`);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAIC,IAAI,QAAQ,OAAO;AACnC,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAMC,WAAsB,GAAG,EAAE;AACjC,MAAMC,aAA8B,GAAG,EAAE;AAQzC,OAAO,MAAMC,iBAAmD,gBAAGT,IAAI,CACrE,UAA6B;EAC3BU,eAAe;EACfC,KAAK;EACLC;AACsB,CAAC,EAAsB;EAC7C,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAoB,CAAC,GAC1DN,eAAe;EAEjB,oBACEX,KAAA,CAAAkB,aAAA,CAAChB,SAAS;IACRY,KAAK,EAAEA,KAAM;IACbC,UAAU,EAAEA,UAAW;IACvBI,QAAQ,EAAER,eAAe,CAACQ,QAAS;IACnCH,UAAU,EAAEC,mBAAmB,KAAK,SAAS,GAAGD,UAAU,GAAGI;EAAU,GAEtEC,oBAAoB,CAACV,eAAe,EAAEC,KAAK,EAAEC,kBAAkB,CACvD,CAAC;AAEhB,CACF,CAAC;AAED,SAASQ,oBAAoBA,CAC3BV,eAAwC,EACxCC,KAAc,EACdU,QAAkC,EACd;EACpB,QAAQX,eAAe,CAACY,cAAc;IACpC,KAAK,YAAY;MACf,oBACEvB,KAAA,CAAAkB,aAAA,CAACX,cAAc,EAAAiB,QAAA;QACbC,EAAE,EAAEd,eAAe,CAACQ,QAAS;QAC7BP,KAAK,EAAEA,KAAK,IAAI,IAAI,GAAGc,MAAM,CAACd,KAAK,CAAC,GAAG,EAAG;QAC1CU,QAAQ,EAAEA,QAAS;QACnBK,WAAW,EAAEhB,eAAe,CAACgB;MAAY,GACrChB,eAAe,CAACiB,mBAAmB,CACxC,CAAC;IAEN,KAAK,WAAW;MACd,oBACE5B,KAAA,CAAAkB,aAAA,CAACZ,aAAa,EAAAkB,QAAA;QACZC,EAAE,EAAEd,eAAe,CAACQ,QAAS;QAC7BP,KAAK,EAAEA,KAAK,IAAI,IAAI,GAAGc,MAAM,CAACd,KAAK,CAAC,GAAG,EAAG;QAC1CU,QAAQ,EAAEA,QAAS;QACnBK,WAAW,EAAEhB,eAAe,CAACgB;MAAY,GACrChB,eAAe,CAACiB,mBAAmB,CACxC,CAAC;IAEN,KAAK,UAAU;MAAE;QACf,MAAM;UAAEC,KAAK,GAAGrB,WAAW;UAAE,GAAGsB;QAAc,CAAC,GAC7CnB,eAAe,CAACiB,mBAAmB,IAAI,CAAC,CAAC;QAC3C,oBACE5B,KAAA,CAAAkB,aAAA,CAACd,aAAa,EAAAoB,QAAA;UACZZ,KAAK,EAAEA,KAAM;UACbU,QAAQ,EAAEA,QAAS;UACnBO,KAAK,EAAEA,KAAM;UACbF,WAAW,EAAEhB,eAAe,CAACgB;QAAY,GACrCG,aAAa,CAClB,CAAC;MAEN;IACA,KAAK,iBAAiB;MACpB,oBACE9B,KAAA,CAAAkB,aAAA,CAACf,mBAAmB,EAAAqB,QAAA;QAClBC,EAAE,EAAEd,eAAe,CAACQ,QAAS;QAC7BQ,WAAW,EAAEhB,eAAe,CAACgB;QAC7B;QAAA;QACAf,KAAK,EAAEA,KAAK,YAAYmB,IAAI,GAAGnB,KAAK,GAAG,IAAK;QAC5CU,QAAQ,EAAEA;MAAS,GACfX,eAAe,CAACiB,mBAAmB,CACxC,CAAC;IAEN,KAAK,eAAe;MAAE;QACpB,MAAM;UAAEI,OAAO,GAAGvB,aAAa;UAAE,GAAGwB;QAAW,CAAC,GAC9CtB,eAAe,CAACiB,mBAAmB,IAAI,CAAC,CAAC;QAC3C,oBACE5B,KAAA,CAAAkB,aAAA,CAACb,iBAAiB,EAAAmB,QAAA;UAChBC,EAAE,EAAEd,eAAe,CAACQ,QAAS;UAC7BP,KAAK,EAAEA,KAAM;UACbU,QAAQ,EAAEA,QAAS;UACnBU,OAAO,EAAEA;QAAQ,GACbC,UAAU,CACf,CAAC;MAEN;IACA,KAAK,cAAc;IACnB,KAAK,aAAa;IAClB,KAAK,YAAY;IACjB,KAAK,QAAQ;MACX,oBAAOjC,KAAA,CAAAkB,aAAA,cAAK,0BAAwB,EAACP,eAAe,CAACY,cAChD,CAAC;IACR;MACE,OAAOW,+BAA+B,CAACvB,eAAe,CAAC;EAC3D;AACF;AAEA,SAASuB,+BAA+BA,CAACtB,KAAY,EAAS;EAC5D,MAAM,IAAIuB,KAAK,CAAC,8BAA8BT,MAAM,CAACd,KAAK,CAAC,EAAE,CAAC;AAChE","ignoreList":[]}
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Radio } from "@base-ui/react/radio";
18
+ import { RadioGroup } from "@base-ui/react/radio-group";
19
+ import { memo, useCallback, useMemo } from "react";
20
+ import { typedReactMemo } from "../../shared/typedMemo.js";
21
+ import styles from "./RadioButtonsField.module.css";
22
+ export const RadioButtonsField = typedReactMemo(function ({
23
+ id,
24
+ value,
25
+ onChange,
26
+ options
27
+ }) {
28
+ const selectedLabel = useMemo(() => value != null ? options.find(opt => opt.value === value)?.label : undefined, [options, value]);
29
+ const handleValueChange = useCallback(nextLabel => {
30
+ const match = options.find(opt => opt.label === nextLabel);
31
+ onChange?.(match?.value ?? null);
32
+ }, [options, onChange]);
33
+ return /*#__PURE__*/React.createElement(RadioGroup, {
34
+ id: id,
35
+ className: styles.osdkRadioGroup,
36
+ value: selectedLabel,
37
+ onValueChange: handleValueChange
38
+ }, options.map(option => /*#__PURE__*/React.createElement(RadioItem, {
39
+ key: option.label,
40
+ option: option
41
+ })));
42
+ });
43
+ const RadioItem = /*#__PURE__*/memo(function ({
44
+ option
45
+ }) {
46
+ return /*#__PURE__*/React.createElement("label", {
47
+ className: styles.osdkRadioItem
48
+ }, /*#__PURE__*/React.createElement(Radio.Root, {
49
+ value: option.label,
50
+ className: styles.osdkRadioRoot
51
+ }, /*#__PURE__*/React.createElement(Radio.Indicator, {
52
+ className: styles.osdkRadioIndicator
53
+ })), /*#__PURE__*/React.createElement("span", {
54
+ className: styles.osdkRadioLabel
55
+ }, option.label));
56
+ });
57
+ //# sourceMappingURL=RadioButtonsField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioButtonsField.js","names":["Radio","RadioGroup","memo","useCallback","useMemo","typedReactMemo","styles","RadioButtonsField","id","value","onChange","options","selectedLabel","find","opt","label","undefined","handleValueChange","nextLabel","match","React","createElement","className","osdkRadioGroup","onValueChange","map","option","RadioItem","key","osdkRadioItem","Root","osdkRadioRoot","Indicator","osdkRadioIndicator","osdkRadioLabel"],"sources":["RadioButtonsField.tsx"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Radio } from \"@base-ui/react/radio\";\nimport { RadioGroup } from \"@base-ui/react/radio-group\";\nimport { memo, type ReactElement, useCallback, useMemo } from \"react\";\nimport { typedReactMemo } from \"../../shared/typedMemo.js\";\nimport type { Option, RadioButtonsFieldProps } from \"../FormFieldApi.js\";\nimport styles from \"./RadioButtonsField.module.css\";\n\nexport const RadioButtonsField: <V>(\n props: RadioButtonsFieldProps<V>,\n) => ReactElement = typedReactMemo(function RadioButtonsFieldFn<V,>({\n id,\n value,\n onChange,\n options,\n}: RadioButtonsFieldProps<V>): ReactElement {\n const selectedLabel = useMemo(\n () =>\n value != null\n ? options.find((opt) => opt.value === value)?.label\n : undefined,\n [options, value],\n );\n\n const handleValueChange = useCallback(\n (nextLabel: unknown) => {\n const match = options.find((opt) => opt.label === nextLabel);\n onChange?.(match?.value ?? null);\n },\n [options, onChange],\n );\n\n return (\n <RadioGroup\n id={id}\n className={styles.osdkRadioGroup}\n value={selectedLabel}\n onValueChange={handleValueChange}\n >\n {options.map((option) => (\n <RadioItem key={option.label} option={option} />\n ))}\n </RadioGroup>\n );\n});\n\nconst RadioItem = memo(function RadioItemFn({\n option,\n}: {\n option: Option<unknown>;\n}): ReactElement {\n return (\n <label className={styles.osdkRadioItem}>\n <Radio.Root value={option.label} className={styles.osdkRadioRoot}>\n <Radio.Indicator className={styles.osdkRadioIndicator} />\n </Radio.Root>\n <span className={styles.osdkRadioLabel}>{option.label}</span>\n </label>\n );\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,sBAAsB;AAC5C,SAASC,UAAU,QAAQ,4BAA4B;AACvD,SAASC,IAAI,EAAqBC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACrE,SAASC,cAAc,QAAQ,2BAA2B;AAE1D,OAAOC,MAAM,MAAM,gCAAgC;AAEnD,OAAO,MAAMC,iBAEI,GAAGF,cAAc,CAAC,UAAiC;EAClEG,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC;AACyB,CAAC,EAAgB;EAC1C,MAAMC,aAAa,GAAGR,OAAO,CAC3B,MACEK,KAAK,IAAI,IAAI,GACTE,OAAO,CAACE,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACL,KAAK,KAAKA,KAAK,CAAC,EAAEM,KAAK,GACjDC,SAAS,EACf,CAACL,OAAO,EAAEF,KAAK,CACjB,CAAC;EAED,MAAMQ,iBAAiB,GAAGd,WAAW,CAClCe,SAAkB,IAAK;IACtB,MAAMC,KAAK,GAAGR,OAAO,CAACE,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,KAAK,KAAKG,SAAS,CAAC;IAC5DR,QAAQ,GAAGS,KAAK,EAAEV,KAAK,IAAI,IAAI,CAAC;EAClC,CAAC,EACD,CAACE,OAAO,EAAED,QAAQ,CACpB,CAAC;EAED,oBACEU,KAAA,CAAAC,aAAA,CAACpB,UAAU;IACTO,EAAE,EAAEA,EAAG;IACPc,SAAS,EAAEhB,MAAM,CAACiB,cAAe;IACjCd,KAAK,EAAEG,aAAc;IACrBY,aAAa,EAAEP;EAAkB,GAEhCN,OAAO,CAACc,GAAG,CAAEC,MAAM,iBAClBN,KAAA,CAAAC,aAAA,CAACM,SAAS;IAACC,GAAG,EAAEF,MAAM,CAACX,KAAM;IAACW,MAAM,EAAEA;EAAO,CAAE,CAChD,CACS,CAAC;AAEjB,CAAC,CAAC;AAEF,MAAMC,SAAS,gBAAGzB,IAAI,CAAC,UAAqB;EAC1CwB;AAGF,CAAC,EAAgB;EACf,oBACEN,KAAA,CAAAC,aAAA;IAAOC,SAAS,EAAEhB,MAAM,CAACuB;EAAc,gBACrCT,KAAA,CAAAC,aAAA,CAACrB,KAAK,CAAC8B,IAAI;IAACrB,KAAK,EAAEiB,MAAM,CAACX,KAAM;IAACO,SAAS,EAAEhB,MAAM,CAACyB;EAAc,gBAC/DX,KAAA,CAAAC,aAAA,CAACrB,KAAK,CAACgC,SAAS;IAACV,SAAS,EAAEhB,MAAM,CAAC2B;EAAmB,CAAE,CAC9C,CAAC,eACbb,KAAA,CAAAC,aAAA;IAAMC,SAAS,EAAEhB,MAAM,CAAC4B;EAAe,GAAER,MAAM,CAACX,KAAY,CACvD,CAAC;AAEZ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ .osdkRadioGroup {
18
+ display: flex;
19
+ flex-direction: column;
20
+ gap: var(--osdk-radio-gap);
21
+ }
22
+
23
+ .osdkRadioItem {
24
+ display: flex;
25
+ align-items: center;
26
+ gap: var(--osdk-radio-item-gap);
27
+ }
28
+
29
+ .osdkRadioRoot {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ width: var(--osdk-radio-size);
34
+ height: var(--osdk-radio-size);
35
+ border-radius: 50%;
36
+ border: var(--osdk-radio-border);
37
+ cursor: pointer;
38
+ flex-shrink: 0;
39
+
40
+ &[data-unchecked] {
41
+ background-color: var(--osdk-radio-bg);
42
+
43
+ &:hover {
44
+ background-color: var(--osdk-radio-bg-hover);
45
+ }
46
+ }
47
+
48
+ &[data-checked] {
49
+ background-color: var(--osdk-radio-bg-checked);
50
+
51
+ &:hover {
52
+ background-color: var(--osdk-radio-bg-checked-hover);
53
+ }
54
+
55
+ &:active {
56
+ background-color: var(--osdk-radio-bg-checked-active);
57
+ }
58
+ }
59
+
60
+ &:focus-visible {
61
+ outline: var(--osdk-focus-outline);
62
+ outline-offset: calc(-1 * var(--osdk-focus-visible-outline-offset));
63
+ }
64
+ }
65
+
66
+ .osdkRadioIndicator {
67
+ width: var(--osdk-radio-indicator-size);
68
+ height: var(--osdk-radio-indicator-size);
69
+ border-radius: 50%;
70
+ background-color: var(--osdk-radio-indicator-color);
71
+
72
+ &[data-unchecked] {
73
+ display: none;
74
+ }
75
+ }
76
+
77
+ .osdkRadioLabel {
78
+ font-family: var(--osdk-typography-font-family);
79
+ font-size: var(--osdk-typography-font-size-default);
80
+ line-height: var(--osdk-typography-line-height-default);
81
+ color: var(--osdk-typography-color-default);
82
+ cursor: pointer;
83
+ }