@fogpipe/forma-react 0.11.2 → 0.12.0-alpha.2

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/src/types.ts CHANGED
@@ -31,12 +31,22 @@ export interface BaseFieldProps {
31
31
  visible: boolean;
32
32
  /** Whether field is enabled (inverse of disabled) */
33
33
  enabled: boolean;
34
+ /** Whether field is readonly (visible, not editable, value still submitted) */
35
+ readonly: boolean;
34
36
  /** Display label from field definition */
35
37
  label: string;
36
38
  /** Help text or description from field definition */
37
39
  description?: string;
38
40
  /** Placeholder text from field definition */
39
41
  placeholder?: string;
42
+ /** Prefix adorner text (e.g., "$") - only for adornable field types */
43
+ prefix?: string;
44
+ /** Suffix adorner text (e.g., "kg") - only for adornable field types */
45
+ suffix?: string;
46
+ /** Presentation variant hint (e.g., "slider", "radio", "nps") */
47
+ variant?: string;
48
+ /** Variant-specific configuration */
49
+ variantConfig?: Record<string, unknown>;
40
50
  }
41
51
 
42
52
  /**
@@ -239,6 +249,22 @@ export interface ArrayItemFieldProps extends Omit<BaseFieldProps, "value" | "onC
239
249
  fieldName: string;
240
250
  }
241
251
 
252
+ /**
253
+ * Props for display fields (read-only presentation content)
254
+ */
255
+ export interface DisplayFieldProps extends Omit<BaseFieldProps, "value" | "onChange"> {
256
+ fieldType: "display";
257
+ /** Static content (markdown/text) */
258
+ content?: string;
259
+ /** Computed source value (resolved by useForma from display field's source property) */
260
+ sourceValue?: unknown;
261
+ /** Display format string */
262
+ format?: string;
263
+ /** No onChange - display fields are read-only */
264
+ onChange?: never;
265
+ value?: never;
266
+ }
267
+
242
268
  /**
243
269
  * Union of all field prop types
244
270
  */
@@ -253,7 +279,8 @@ export type FieldProps =
253
279
  | MultiSelectFieldProps
254
280
  | ArrayFieldProps
255
281
  | ObjectFieldProps
256
- | ComputedFieldProps;
282
+ | ComputedFieldProps
283
+ | DisplayFieldProps;
257
284
 
258
285
  /**
259
286
  * Map of field types to React components
@@ -275,6 +302,7 @@ export interface ComponentMap {
275
302
  array?: React.ComponentType<ArrayComponentProps>;
276
303
  object?: React.ComponentType<ObjectComponentProps>;
277
304
  computed?: React.ComponentType<ComputedComponentProps>;
305
+ display?: React.ComponentType<DisplayComponentProps>;
278
306
  fallback?: React.ComponentType<FieldComponentProps>;
279
307
  }
280
308
 
@@ -382,6 +410,11 @@ export interface ComputedComponentProps {
382
410
  spec: Forma;
383
411
  }
384
412
 
413
+ export interface DisplayComponentProps {
414
+ field: DisplayFieldProps;
415
+ spec: Forma;
416
+ }
417
+
385
418
  /**
386
419
  * Generic field component props (for fallback/dynamic components)
387
420
  */
@@ -427,6 +460,8 @@ export interface GetFieldPropsResult {
427
460
  visible: boolean;
428
461
  /** Whether field is enabled (not disabled) */
429
462
  enabled: boolean;
463
+ /** Whether field is readonly (visible, not editable, value still submitted) */
464
+ readonly: boolean;
430
465
  /** Whether field is required (for validation) */
431
466
  required: boolean;
432
467
  /**
@@ -451,6 +486,14 @@ export interface GetFieldPropsResult {
451
486
  "aria-required"?: boolean;
452
487
  /** Options for select/multiselect fields (filtered by visibleWhen) */
453
488
  options?: SelectOption[];
489
+ /** Prefix adorner text (e.g., "$") */
490
+ prefix?: string;
491
+ /** Suffix adorner text (e.g., "kg") */
492
+ suffix?: string;
493
+ /** Presentation variant hint */
494
+ variant?: string;
495
+ /** Variant-specific configuration */
496
+ variantConfig?: Record<string, unknown>;
454
497
  }
455
498
 
456
499
  /**