@object-ui/plugin-form 6.2.3 → 7.1.0

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.
@@ -0,0 +1,86 @@
1
+ import { GridColumn } from '@object-ui/fields';
2
+ /** Minimal shape of an object schema as returned by `DataSource.getObjectSchema`. */
3
+ export interface ObjectSchemaLike {
4
+ name?: string;
5
+ fields?: Record<string, any>;
6
+ }
7
+ /** Map an ObjectQL field type to a LineItems grid column type. */
8
+ export declare function fieldTypeToColumnType(type: string | undefined): GridColumn['type'];
9
+ /**
10
+ * Find the field on the child object that points back to the parent — the
11
+ * master_detail/lookup field whose `reference` is the parent object. Prefer
12
+ * `master_detail` over `lookup` when both exist.
13
+ */
14
+ export declare function findRelationshipField(childSchema: ObjectSchemaLike | undefined, parentObjectName: string): string | undefined;
15
+ /**
16
+ * Default-visible column budget for an auto-derived inline grid. An inline
17
+ * line-item grid lives in a constrained width (modal / detail card), so we show
18
+ * a focused set by default and mark the rest `defaultHidden` — they are NOT
19
+ * dropped: the grid's column chooser reveals them on demand (the mainstream
20
+ * "personalize columns" pattern; cf. Odoo `optional` / Salesforce column
21
+ * personalization). Required columns are always visible. Authors can override
22
+ * with explicit `columns` / `inlineColumns` (no curation), or `maxColumns: 0`.
23
+ */
24
+ export declare const DEFAULT_MAX_INLINE_COLUMNS = 6;
25
+ /**
26
+ * Derive editable grid columns from a child object's fields, skipping system /
27
+ * audit fields, non-editable types, and the back-reference FK to the parent.
28
+ * Every editable column is returned; those beyond {@link DEFAULT_MAX_INLINE_COLUMNS}
29
+ * are flagged `defaultHidden` (collapsed into the grid's column chooser, not
30
+ * dropped). Pass `maxColumns: 0` to flag none.
31
+ */
32
+ export declare function deriveColumns(childSchema: ObjectSchemaLike | undefined, opts?: {
33
+ relationshipField?: string;
34
+ exclude?: string[];
35
+ maxColumns?: number;
36
+ }): GridColumn[];
37
+ /**
38
+ * Field names for a child's full "row form" (the per-row expand editor) — every
39
+ * editable business field, skipping system/audit fields, the back-reference FK,
40
+ * and computed types. Broader than {@link deriveColumns} (which only returns
41
+ * grid-friendly types): the form has room for textarea/richtext/file/etc.
42
+ */
43
+ export declare function deriveFormFields(childSchema: ObjectSchemaLike | undefined, opts?: {
44
+ relationshipField?: string;
45
+ exclude?: string[];
46
+ }): string[];
47
+ /** Inline-edit form factor. */
48
+ export type InlineMode = 'grid' | 'form';
49
+ /** Above this many editable business fields, the grid gets cramped → `form`. */
50
+ export declare const SMART_FORM_FIELD_THRESHOLD = 8;
51
+ /**
52
+ * Resolve the inline-edit form factor for a child collection.
53
+ * - explicit `'grid'` / `'form'` win;
54
+ * - otherwise (`true` / undefined) pick by the child's shape: a `form` when it
55
+ * has rich/form-only fields or more than {@link SMART_FORM_FIELD_THRESHOLD}
56
+ * editable business fields, else a `grid`.
57
+ */
58
+ export declare function resolveInlineMode(childSchema: ObjectSchemaLike | undefined, inlineEdit: boolean | InlineMode | undefined, opts?: {
59
+ relationshipField?: string;
60
+ }): InlineMode;
61
+ export interface DerivedDetail {
62
+ childObject: string;
63
+ relationshipField: string;
64
+ columns: GridColumn[];
65
+ /** Field names for the per-row expand form (broader than `columns`). */
66
+ formFields: string[];
67
+ /** Inline-edit form factor (grid = editable cells; form = list + per-row form). */
68
+ mode: InlineMode;
69
+ /** First numeric column, used as the running-total source when none is set. */
70
+ amountField?: string;
71
+ /** Child field holding the line sort position, if any — the grid stamps it on
72
+ * drag-reorder so order persists (excluded from the editable columns). */
73
+ sortField?: string;
74
+ }
75
+ /**
76
+ * Resolve a child collection's full config (FK + columns) from its object
77
+ * schema. Throws when no relationship to the parent can be found. The caller
78
+ * supplies any explicit overrides (relationshipField / columns / amountField),
79
+ * which win over the derived values.
80
+ */
81
+ export declare function deriveDetail(childObject: string, childSchema: ObjectSchemaLike | undefined, parentObjectName: string, override?: {
82
+ relationshipField?: string;
83
+ columns?: GridColumn[];
84
+ amountField?: string;
85
+ inlineEdit?: boolean | InlineMode;
86
+ }): DerivedDetail;
@@ -0,0 +1,27 @@
1
+ import { FormField, ObjectFormSection } from '@object-ui/types';
2
+ /** A declared field group on the object metadata. */
3
+ export interface DeclaredFieldGroup {
4
+ key: string;
5
+ label?: string;
6
+ /** Render the group's section header with a collapse toggle. */
7
+ collapsible?: boolean;
8
+ /** Start the (collapsible) group collapsed. */
9
+ collapsed?: boolean;
10
+ }
11
+ /** Read an object's `fieldGroups` into a normalized, well-typed list. */
12
+ export declare function readObjectFieldGroups(input: unknown): DeclaredFieldGroup[];
13
+ /**
14
+ * Derive form sections from an object's declared `fieldGroups` and each
15
+ * rendered field's `group`.
16
+ *
17
+ * Returns `null` when grouping does not apply — no declared groups, or no
18
+ * rendered field opts into a declared group — so callers fall back to a flat
19
+ * form. Sections come back in declared order; fields without a declared group
20
+ * collect into a trailing untitled section (no `name`/`label`) so they render
21
+ * as a plain block rather than a card.
22
+ *
23
+ * Section `fields` are returned as field *names* (strings) so the result plugs
24
+ * straight into ObjectForm's existing section-render path, which resolves names
25
+ * back to generated `FormField`s and applies field-level permissions.
26
+ */
27
+ export declare function deriveFieldGroupSections(fields: FormField[], fieldGroups: unknown): ObjectFormSection[] | null;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,26 @@
1
- export * from './packages/plugin-form/src/index'
2
- export {}
1
+ import { ObjectForm } from './ObjectForm';
2
+ export { ObjectForm };
3
+ export type { ObjectFormProps } from './ObjectForm';
4
+ export { FormSection } from './FormSection';
5
+ export type { FormSectionProps } from './FormSection';
6
+ export { applyAutoLayout, inferColumns, inferModalSize, isWideFieldType, isAutoGeneratedFieldType, applyAutoColSpan, filterCreateModeFields, filterSystemFields, filterAutoGeneratedFields, } from './autoLayout';
7
+ export { TabbedForm } from './TabbedForm';
8
+ export type { TabbedFormProps, TabbedFormSchema, FormSectionConfig } from './TabbedForm';
9
+ export { WizardForm } from './WizardForm';
10
+ export type { WizardFormProps, WizardFormSchema } from './WizardForm';
11
+ export { SplitForm } from './SplitForm';
12
+ export type { SplitFormProps, SplitFormSchema } from './SplitForm';
13
+ export { DrawerForm } from './DrawerForm';
14
+ export type { DrawerFormProps, DrawerFormSchema } from './DrawerForm';
15
+ export { ModalForm } from './ModalForm';
16
+ export type { ModalFormProps, ModalFormSchema } from './ModalForm';
17
+ export { EmbeddableForm } from './EmbeddableForm';
18
+ export type { EmbeddableFormProps, EmbeddableFormConfig, EmbeddableFormTexts } from './EmbeddableForm';
19
+ export { FormAnalytics } from './FormAnalytics';
20
+ export type { FormAnalyticsProps, FormSubmissionMetric } from './FormAnalytics';
21
+ export { MasterDetailForm } from './MasterDetailForm';
22
+ export type { MasterDetailFormProps, MasterDetailFormSchema, MasterDetailDetailConfig, } from './MasterDetailForm';
23
+ export { LineItemsPanel } from './LineItemsPanel';
24
+ export type { LineItemsPanelSchema } from './LineItemsPanel';
25
+ export { deriveDetail, deriveColumns, deriveFormFields, findRelationshipField, resolveInlineMode } from './deriveMasterDetail';
26
+ export type { DerivedDetail, InlineMode } from './deriveMasterDetail';