@mercurjs/dashboard-shared 2.2.0-canary.48 → 2.2.0-canary.49

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.ts CHANGED
@@ -1539,9 +1539,9 @@ declare function createFormHelper<TData>(): {
1539
1539
  * into a form's base schema. Custom-field values live under `additional_data`
1540
1540
  * so the built-in create/edit validators never see them.
1541
1541
  */
1542
- declare function buildAdditionalDataSchema(registry: ExtensionRegistry, model: string): z.ZodObject<Record<string, z.ZodTypeAny>>;
1542
+ declare function buildAdditionalDataSchema(registry: ExtensionRegistry, model: string, zone?: string, tab?: string): z.ZodObject<Record<string, z.ZodTypeAny>>;
1543
1543
  /** Resolve default values for a model's custom fields from the loaded entity. */
1544
- declare function buildAdditionalDataDefaults(registry: ExtensionRegistry, model: string, data?: unknown): Record<string, unknown>;
1544
+ declare function buildAdditionalDataDefaults(registry: ExtensionRegistry, model: string, data?: unknown, zone?: string, tab?: string): Record<string, unknown>;
1545
1545
 
1546
1546
  type WithAdditionalData<T> = T & {
1547
1547
  additional_data?: Record<string, unknown>;
@@ -1555,6 +1555,14 @@ interface UseExtendableFormProps<TSchema extends ZodObject<Record<string, z.ZodT
1555
1555
  model: string;
1556
1556
  /** Loaded entity, used to resolve custom-field default values. */
1557
1557
  data?: TData;
1558
+ /**
1559
+ * Form zone (and optional tab) this form renders. When set, only custom
1560
+ * fields registered for that zone extend the schema/defaults — so a required
1561
+ * field defined for another zone (e.g. onboarding) doesn't block this form.
1562
+ * Omit to include every field for the model (legacy behaviour).
1563
+ */
1564
+ zone?: string;
1565
+ tab?: string;
1558
1566
  }
1559
1567
  /**
1560
1568
  * `useForm` that merges a model's registered custom fields into the base
@@ -1563,6 +1571,6 @@ interface UseExtendableFormProps<TSchema extends ZodObject<Record<string, z.ZodT
1563
1571
  * built-in validators never see them; the extension registry provides the
1564
1572
  * per-field zod validation and default values.
1565
1573
  */
1566
- declare const useExtendableForm: <TSchema extends ZodObject<Record<string, z.ZodTypeAny>>, TContext = unknown, TTransformedValues extends FieldValues | undefined = undefined>({ schema: baseSchema, defaultValues: baseDefaultValues, model, data, ...props }: UseExtendableFormProps<TSchema, TContext>) => react_hook_form.UseFormReturn<WithAdditionalData<z.TypeOf<TSchema>>, TContext, TTransformedValues>;
1574
+ declare const useExtendableForm: <TSchema extends ZodObject<Record<string, z.ZodTypeAny>>, TContext = unknown, TTransformedValues extends FieldValues | undefined = undefined>({ schema: baseSchema, defaultValues: baseDefaultValues, model, data, zone, tab, ...props }: UseExtendableFormProps<TSchema, TContext>) => react_hook_form.UseFormReturn<WithAdditionalData<z.TypeOf<TSchema>>, TContext, TTransformedValues>;
1567
1575
 
1568
1576
  export { type Action, type ActionGroup, ActionMenu, AddressForm, type AttributeChange, type AttributeChangeKind, BadgeListSummary, ChipGroup, CodeCell, CodeHeader, type Command, ConditionalTooltip, ConfirmPrompt, type ConfirmPromptProps, type CoreNavItem, CreatedAtCell, CreatedAtHeader, type CustomFieldsModule, CustomerInfo, DataGrid, DataTable, DateCell, DateHeader, DateRangeDisplay, DisplayExtensionZone, type DisplayExtensionZoneProps, DisplayField, type DisplayFieldProps, DisplaySection, type DisplaySectionField, type DisplaySectionProps, EmailCell, EmailForm, EmailHeader, type ExtendableTable, ExtensionProvider, type ExtensionProviderProps, ExtensionRegistry, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, FormExtensionZone, type FormExtensionZoneProps, GeneralSectionSkeleton, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, type ImageRef, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, LinkButton, ListBadge, ListSummary, Listicle, type ListicleProps, type MediaDiff, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, type NavigationModule, NoRecords, NoResults, type NoResultsProps, OrderBy, PlaceholderCell, type ProductChangeAttribute, ProductChangePanel, type ProductChangePanelProps, type ProductChangeProduct, type ProductChangeResolvers, type ProductChangeVariant, type ProductChangeView, ProgressBar, Query, REFERENCE_FIELDS, type ReferenceField, type ResolvedAttribute, type ResolvedDisplays, type ResolvedFormField, RouteDrawer, RouteFocusModal, SectionRow, type SectionRowProps, SegmentedControl, type SegmentedControlOption, SidebarLink, type SidebarLinkProps, SingleColumnPage, SingleColumnPageSkeleton, Skeleton, SortableList, SortableTree, StackedDrawer, StackedFocusModal, StatusCell, SwitchBox, type TQueryKey, type TabDefinition, TabbedForm, TableFooterSkeleton, TableSectionSkeleton, TableSkeleton, TextCell, TextHeader, TextSkeleton, Thumbnail, TwoColumnPage, TwoColumnPageSkeleton, type UseExtendableFormProps, type UseExtendableTableProps, type UseQueryOptionsWrapper, type VariantGroup, type Widget, type WidgetModule, type WidgetPlacement, WidgetZone, type WidgetZoneProps, type ZoneWidgets, _DataTable, applyNavOverrides, buildAdditionalDataDefaults, buildAdditionalDataSchema, buildProductChangeView, createDataGridHelper, createDataGridPriceColumns, createFormHelper, extractReferenceIds, formatFieldValue, getExtensionRegistry, getLinkQuery, humanizeFieldName, isImageList, isReferenceField, linkFields, productChangeViewHasContent, queryKeysFactory, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExtendableForm, useExtendableTable, useExtension, useLinkQuery, useQueryParams, useRouteModal, useStackedModal, useTabManagement, useTabbedForm, withLinkFields };
package/dist/index.js CHANGED
@@ -25023,16 +25023,18 @@ function createFormHelper() {
25023
25023
  coerce: z2.coerce
25024
25024
  };
25025
25025
  }
25026
- function buildAdditionalDataSchema(registry, model) {
25026
+ function buildAdditionalDataSchema(registry, model, zone, tab) {
25027
25027
  const shape = {};
25028
- for (const { name, field } of registry.getAllFormFields(model)) {
25028
+ const fields = zone ? registry.getFormFields(model, zone, tab) : registry.getAllFormFields(model);
25029
+ for (const { name, field } of fields) {
25029
25030
  shape[name] = field.validation;
25030
25031
  }
25031
25032
  return z2.object(shape);
25032
25033
  }
25033
- function buildAdditionalDataDefaults(registry, model, data) {
25034
+ function buildAdditionalDataDefaults(registry, model, data, zone, tab) {
25034
25035
  const defaults = {};
25035
- for (const { name, field } of registry.getAllFormFields(model)) {
25036
+ const fields = zone ? registry.getFormFields(model, zone, tab) : registry.getAllFormFields(model);
25037
+ for (const { name, field } of fields) {
25036
25038
  if (typeof field.defaultValue === "function") {
25037
25039
  defaults[name] = field.defaultValue(data);
25038
25040
  } else if (field.defaultValue !== void 0) {
@@ -25051,21 +25053,29 @@ var useExtendableForm = ({
25051
25053
  defaultValues: baseDefaultValues,
25052
25054
  model,
25053
25055
  data,
25056
+ zone,
25057
+ tab,
25054
25058
  ...props
25055
25059
  }) => {
25056
25060
  const extension = useExtension();
25057
25061
  const schema = useMemo20(
25058
25062
  () => baseSchema.extend({
25059
- additional_data: buildAdditionalDataSchema(extension, model).partial().optional()
25063
+ additional_data: buildAdditionalDataSchema(extension, model, zone, tab).partial().optional()
25060
25064
  }),
25061
- [baseSchema, extension, model]
25065
+ [baseSchema, extension, model, zone, tab]
25062
25066
  );
25063
25067
  const defaultValues = useMemo20(
25064
25068
  () => ({
25065
25069
  ...baseDefaultValues,
25066
- additional_data: buildAdditionalDataDefaults(extension, model, data)
25070
+ additional_data: buildAdditionalDataDefaults(
25071
+ extension,
25072
+ model,
25073
+ data,
25074
+ zone,
25075
+ tab
25076
+ )
25067
25077
  }),
25068
- [baseDefaultValues, extension, model, data]
25078
+ [baseDefaultValues, extension, model, data, zone, tab]
25069
25079
  );
25070
25080
  return useForm2({
25071
25081
  ...props,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/dashboard-shared",
3
- "version": "2.2.0-canary.48",
3
+ "version": "2.2.0-canary.49",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mercurjs/mercur",
@@ -23,7 +23,7 @@
23
23
  "build": "tsup"
24
24
  },
25
25
  "dependencies": {
26
- "@mercurjs/client": "2.2.0-canary.48",
26
+ "@mercurjs/client": "2.2.0-canary.49",
27
27
  "@ariakit/react": "^0.4.15",
28
28
  "@babel/runtime": "^7.26.10",
29
29
  "@dnd-kit/core": "^6.1.0",
@@ -63,9 +63,9 @@
63
63
  "zod": "4.4.3"
64
64
  },
65
65
  "devDependencies": {
66
- "@mercurjs/types": "2.2.0-canary.48",
67
- "@mercurjs/core": "2.2.0-canary.48",
68
- "@mercurjs/dashboard-sdk": "2.2.0-canary.48",
66
+ "@mercurjs/types": "2.2.0-canary.49",
67
+ "@mercurjs/core": "2.2.0-canary.49",
68
+ "@mercurjs/dashboard-sdk": "2.2.0-canary.49",
69
69
  "tsup": "^8.0.2",
70
70
  "typescript": "5.9.3",
71
71
  "@types/lodash.debounce": "^4.0.8",