@mercurjs/dashboard-shared 2.2.0-canary.44 → 2.2.0-canary.46

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
@@ -1485,6 +1485,8 @@ type ExtendableTable<TData> = {
1485
1485
  */
1486
1486
  declare function useExtendableTable<TData>({ model, columns: baseColumns, }: UseExtendableTableProps<TData>): ExtendableTable<TData>;
1487
1487
 
1488
+ /** Turn a model's `link` relations into `+link.*` merge tokens. */
1489
+ declare const linkFields: (links: string[]) => string;
1488
1490
  /**
1489
1491
  * Merge a model's custom-fields `link` relations into a curated fields string
1490
1492
  * using the `+` merge convention (`+link.*`), so linked-module data is fetched
@@ -1492,6 +1494,21 @@ declare function useExtendableTable<TData>({ model, columns: baseColumns, }: Use
1492
1494
  * base `fields` unchanged when there are no links.
1493
1495
  */
1494
1496
  declare const withLinkFields: (fields: string, links: string[]) => string;
1497
+ /**
1498
+ * Build a spreadable `{ fields }` query fragment that adds a model's custom-fields
1499
+ * `link` relations. Pass `base` to merge onto a curated field set (list/detail
1500
+ * queries); omit it to merge purely onto the route defaults (`+link.*` only), so
1501
+ * unprefixed base fields never replace the route defaults. Returns `{}` (or
1502
+ * `{ fields: base }`) when the model declares no links, leaving the fetch
1503
+ * unchanged. Non-hook variant for react-router loaders.
1504
+ */
1505
+ declare const getLinkQuery: (model: string, base?: string) => {
1506
+ fields?: string;
1507
+ };
1508
+ /** Hook variant of {@link getLinkQuery} for use inside components. */
1509
+ declare const useLinkQuery: (model: string, base?: string) => {
1510
+ fields?: string;
1511
+ };
1495
1512
 
1496
1513
  /**
1497
1514
  * Zod-backed form surface (mirrors Medusa's `createFormHelper`, no `unstable_`).
@@ -1548,4 +1565,4 @@ interface UseExtendableFormProps<TSchema extends ZodObject<Record<string, z.ZodT
1548
1565
  */
1549
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>;
1550
1567
 
1551
- 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, humanizeFieldName, isImageList, isReferenceField, productChangeViewHasContent, queryKeysFactory, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExtendableForm, useExtendableTable, useExtension, useQueryParams, useRouteModal, useStackedModal, useTabManagement, useTabbedForm, withLinkFields };
1568
+ 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
@@ -24782,7 +24782,7 @@ function applyNavOverrides(coreRoutes, overrides = []) {
24782
24782
 
24783
24783
  // src/extensions/form-extension-zone.tsx
24784
24784
  import { Input as Input8, Switch as Switch2, Textarea as Textarea3 } from "@medusajs/ui";
24785
- import { Fragment as Fragment7, jsx as jsx91, jsxs as jsxs59 } from "react/jsx-runtime";
24785
+ import { jsx as jsx91, jsxs as jsxs59 } from "react/jsx-runtime";
24786
24786
  function zodType(field) {
24787
24787
  const def = field.validation?.def;
24788
24788
  return def?.type ?? "string";
@@ -24841,7 +24841,7 @@ var FormExtensionZone = ({
24841
24841
  }) => {
24842
24842
  const fields = useExtension().getFormFields(model, zone, tab);
24843
24843
  if (fields.length === 0) return null;
24844
- return /* @__PURE__ */ jsx91(Fragment7, { children: fields.map(({ name, field }) => /* @__PURE__ */ jsx91(
24844
+ return /* @__PURE__ */ jsx91("div", { className: "flex flex-col gap-y-4", children: fields.map(({ name, field }) => /* @__PURE__ */ jsx91(
24845
24845
  ExtensionField,
24846
24846
  {
24847
24847
  name,
@@ -24854,8 +24854,8 @@ var FormExtensionZone = ({
24854
24854
  };
24855
24855
 
24856
24856
  // src/extensions/display-extension-zone.tsx
24857
- import { Fragment as Fragment8 } from "react";
24858
- import { Fragment as Fragment9, jsx as jsx92, jsxs as jsxs60 } from "react/jsx-runtime";
24857
+ import { Fragment as Fragment7 } from "react";
24858
+ import { Fragment as Fragment8, jsx as jsx92, jsxs as jsxs60 } from "react/jsx-runtime";
24859
24859
  var DisplayExtensionZone = ({
24860
24860
  model,
24861
24861
  zone,
@@ -24866,7 +24866,7 @@ var DisplayExtensionZone = ({
24866
24866
  const builtIn = new Set(builtInFieldIds);
24867
24867
  const added = fields.filter((f) => f.component && !builtIn.has(f.id));
24868
24868
  if (added.length === 0 && actions.length === 0) return null;
24869
- return /* @__PURE__ */ jsxs60(Fragment9, { children: [
24869
+ return /* @__PURE__ */ jsxs60(Fragment8, { children: [
24870
24870
  added.map(({ id, component: Component }) => {
24871
24871
  const C = Component;
24872
24872
  return /* @__PURE__ */ jsx92(C, { data }, id);
@@ -24888,14 +24888,14 @@ var DisplayField = ({
24888
24888
  if (overridden) {
24889
24889
  return Component ? /* @__PURE__ */ jsx92(Component, { data }) : null;
24890
24890
  }
24891
- return /* @__PURE__ */ jsx92(Fragment8, { children });
24891
+ return /* @__PURE__ */ jsx92(Fragment7, { children });
24892
24892
  };
24893
24893
  var DisplaySection = ({
24894
24894
  model,
24895
24895
  zone,
24896
24896
  data,
24897
24897
  fields
24898
- }) => /* @__PURE__ */ jsxs60(Fragment9, { children: [
24898
+ }) => /* @__PURE__ */ jsxs60(Fragment8, { children: [
24899
24899
  fields.map(({ id, render }) => /* @__PURE__ */ jsx92(DisplayField, { model, zone, id, data, children: render }, id)),
24900
24900
  /* @__PURE__ */ jsx92(
24901
24901
  DisplayExtensionZone,
@@ -24971,7 +24971,22 @@ function useExtendableTable({
24971
24971
  }
24972
24972
 
24973
24973
  // src/extensions/links.ts
24974
- var withLinkFields = (fields, links) => links.length ? `${fields},${links.map((l) => `+${l}.*`).join(",")}` : fields;
24974
+ var linkFields = (links) => links.map((l) => `+${l}.*`).join(",");
24975
+ var withLinkFields = (fields, links) => links.length ? `${fields},${linkFields(links)}` : fields;
24976
+ var getLinkQuery = (model, base) => {
24977
+ const links = getExtensionRegistry()?.getLinks(model) ?? [];
24978
+ if (!links.length) {
24979
+ return base ? { fields: base } : {};
24980
+ }
24981
+ return { fields: base ? withLinkFields(base, links) : linkFields(links) };
24982
+ };
24983
+ var useLinkQuery = (model, base) => {
24984
+ const links = useExtension().getLinks(model);
24985
+ if (!links.length) {
24986
+ return base ? { fields: base } : {};
24987
+ }
24988
+ return { fields: base ? withLinkFields(base, links) : linkFields(links) };
24989
+ };
24975
24990
 
24976
24991
  // src/extensions/custom-fields-form.ts
24977
24992
  import { z as z2 } from "zod";
@@ -25131,9 +25146,11 @@ export {
25131
25146
  extractReferenceIds,
25132
25147
  formatFieldValue,
25133
25148
  getExtensionRegistry,
25149
+ getLinkQuery,
25134
25150
  humanizeFieldName,
25135
25151
  isImageList,
25136
25152
  isReferenceField,
25153
+ linkFields,
25137
25154
  productChangeViewHasContent,
25138
25155
  queryKeysFactory,
25139
25156
  useCombinedRefs,
@@ -25145,6 +25162,7 @@ export {
25145
25162
  useExtendableForm,
25146
25163
  useExtendableTable,
25147
25164
  useExtension,
25165
+ useLinkQuery,
25148
25166
  useQueryParams,
25149
25167
  useRouteModal,
25150
25168
  useStackedModal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/dashboard-shared",
3
- "version": "2.2.0-canary.44",
3
+ "version": "2.2.0-canary.46",
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.44",
26
+ "@mercurjs/client": "2.2.0-canary.46",
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.44",
67
- "@mercurjs/core": "2.2.0-canary.44",
68
- "@mercurjs/dashboard-sdk": "2.2.0-canary.44",
66
+ "@mercurjs/types": "2.2.0-canary.46",
67
+ "@mercurjs/core": "2.2.0-canary.46",
68
+ "@mercurjs/dashboard-sdk": "2.2.0-canary.46",
69
69
  "tsup": "^8.0.2",
70
70
  "typescript": "5.9.3",
71
71
  "@types/lodash.debounce": "^4.0.8",