@mercurjs/dashboard-shared 2.2.0-canary.45 → 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 +18 -1
- package/dist/index.js +19 -1
- package/package.json +5 -5
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
|
@@ -24971,7 +24971,22 @@ function useExtendableTable({
|
|
|
24971
24971
|
}
|
|
24972
24972
|
|
|
24973
24973
|
// src/extensions/links.ts
|
|
24974
|
-
var
|
|
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.
|
|
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.
|
|
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.
|
|
67
|
-
"@mercurjs/core": "2.2.0-canary.
|
|
68
|
-
"@mercurjs/dashboard-sdk": "2.2.0-canary.
|
|
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",
|