@mercurjs/dashboard-shared 2.4.1 → 2.4.2-canary.1
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 +44 -5
- package/dist/index.js +168 -67
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1920,6 +1920,11 @@ declare class ExtensionRegistry {
|
|
|
1920
1920
|
* and are read through `getFormFieldOverride` instead.
|
|
1921
1921
|
*/
|
|
1922
1922
|
getFormFields(model: string, zone: string, tab?: string, builtInFieldIds?: string[], exactTab?: boolean): ResolvedFormField[];
|
|
1923
|
+
/**
|
|
1924
|
+
* Custom fields of every tab of a zone, for a tabbed form's schema and
|
|
1925
|
+
* defaults, which cover all its tabs at once.
|
|
1926
|
+
*/
|
|
1927
|
+
getZoneFormFields(model: string, zone: string, builtInFieldIds?: string[]): ResolvedFormField[];
|
|
1923
1928
|
/** Replacement (or removal, `field: null`) of a built-in form field. */
|
|
1924
1929
|
getFormFieldOverride(model: string, zone: string, id: string, tab?: string, exactTab?: boolean): FormFieldOverride;
|
|
1925
1930
|
/**
|
|
@@ -1946,6 +1951,17 @@ type LayeredRoute = {
|
|
|
1946
1951
|
path: string;
|
|
1947
1952
|
children?: LayeredRoute[];
|
|
1948
1953
|
};
|
|
1954
|
+
type LazyModule = {
|
|
1955
|
+
Component?: ComponentType<RenderDefaultProps> | null;
|
|
1956
|
+
handle?: unknown;
|
|
1957
|
+
};
|
|
1958
|
+
/**
|
|
1959
|
+
* Overrides a built-in page's lazy route with an extension's, handing the
|
|
1960
|
+
* built-in component to the extension as `renderDefault`. The built-in loader
|
|
1961
|
+
* is kept unless the extension declares its own, so `renderDefault` still has
|
|
1962
|
+
* the data it reads.
|
|
1963
|
+
*/
|
|
1964
|
+
declare function overrideLazyRoute<T extends LazyModule>(previous: () => Promise<T>, next: () => Promise<T>): () => Promise<T>;
|
|
1949
1965
|
/**
|
|
1950
1966
|
* Collapses routes emitted in layer order so the last route at a path wins and
|
|
1951
1967
|
* receives the previous page as `renderDefault`. Parallel (modal) children at
|
|
@@ -2115,7 +2131,7 @@ type ExtendableFormFieldProps<TFieldValues extends FieldValues = FieldValues, TC
|
|
|
2115
2131
|
/**
|
|
2116
2132
|
* Wraps one of a form's own fields so `forms[].fields[id]` can replace it (the
|
|
2117
2133
|
* replacement binds to the same form key; validation stays the base schema's)
|
|
2118
|
-
* or remove it (`null`, the field keeps its default value).
|
|
2134
|
+
* or remove it (`null` or `hidden`, the field keeps its default value).
|
|
2119
2135
|
*/
|
|
2120
2136
|
declare const ExtendableFormField: <TFieldValues extends FieldValues, TContext, TTransformed>({ model, zone, tab, id, control, data, children, }: ExtendableFormFieldProps<TFieldValues, TContext, TTransformed>) => react_jsx_runtime.JSX.Element | null;
|
|
2121
2137
|
|
|
@@ -2253,12 +2269,35 @@ type UseExtendableGridProps<TData> = {
|
|
|
2253
2269
|
/**
|
|
2254
2270
|
* Applies a form tab's `forms[].fields` to a data grid, the way
|
|
2255
2271
|
* `<ExtendableFormField>` does for a regular form: a base column id + `null`
|
|
2256
|
-
* removes the column, a base id + field replaces how
|
|
2257
|
-
* editing the base column's form path), and any other key
|
|
2258
|
-
* column bound to the row's `additional_data`.
|
|
2272
|
+
* (or a field with `hidden`) removes the column, a base id + field replaces how
|
|
2273
|
+
* it renders (it keeps editing the base column's form path), and any other key
|
|
2274
|
+
* appends an editable column bound to the row's `additional_data`. Generated
|
|
2275
|
+
* column ids like `stock_locations.<id>` also match their `stock_locations`
|
|
2276
|
+
* prefix, so one key targets the whole group.
|
|
2259
2277
|
*/
|
|
2260
2278
|
declare function useExtendableGrid<TData>(props: UseExtendableGridProps<TData>): ColumnDef<TData, unknown>[];
|
|
2261
2279
|
|
|
2280
|
+
type BuiltInFieldScope = {
|
|
2281
|
+
model: string;
|
|
2282
|
+
zone: string;
|
|
2283
|
+
tab?: string;
|
|
2284
|
+
/** Match only entries of `tab`, as data grids do. */
|
|
2285
|
+
exactTab?: boolean;
|
|
2286
|
+
};
|
|
2287
|
+
type BuiltInFieldDefaults = {
|
|
2288
|
+
/** Resolved defaults by built-in id; ids without a value are left out. */
|
|
2289
|
+
values: Record<string, unknown>;
|
|
2290
|
+
/** Built-in ids whose override sets `hidden: true`. */
|
|
2291
|
+
hidden: Record<string, boolean>;
|
|
2292
|
+
isLoading: boolean;
|
|
2293
|
+
};
|
|
2294
|
+
declare function resolveBuiltInFieldDefault(extension: ExtensionRegistry, { model, zone, tab, exactTab }: BuiltInFieldScope, id: string): Promise<unknown>;
|
|
2295
|
+
/**
|
|
2296
|
+
* Resolves the `defaultValue` (sync or async) of `forms[].fields` overrides on
|
|
2297
|
+
* a form's built-in fields, so a `hidden` field still has a value to submit.
|
|
2298
|
+
*/
|
|
2299
|
+
declare function useBuiltInFieldDefaults(scope: BuiltInFieldScope, ids: string[]): BuiltInFieldDefaults;
|
|
2300
|
+
|
|
2262
2301
|
type Keyed = {
|
|
2263
2302
|
key: string;
|
|
2264
2303
|
};
|
|
@@ -2579,4 +2618,4 @@ declare const plainTextToHtml: (value?: string | null) => string;
|
|
|
2579
2618
|
|
|
2580
2619
|
declare const getListInitialData: <TData>(queryParams: Record<string, string | undefined>, loaderData: TData | undefined) => TData | undefined;
|
|
2581
2620
|
|
|
2582
|
-
export { type Action, type ActionGroup, ActionMenu, type AdditionalDataScope, AddressForm, AddressSchema, type AttributeChange, type AttributeChangeKind, AttributeValueInput, BadgeListSummary, CORE_ENTRY_PREFIX, CORE_LAYOUTS, ChipGroup, ChipInput, CodeCell, CodeHeader, Combobox, type Command, ConditionalTooltip, ConfirmPrompt, type ConfirmPromptProps, type CoreNavItem, CountrySelect, CreatedAtCell, CreatedAtHeader, type CurrencyInfo, type CustomFieldsModule, CustomerInfo, DataGrid, DataTable, DateCell, DateHeader, DateRangeDisplay, DeprecatedPercentageInput, type DetailPageDefaultsOptions, type DisplayEntry, DisplayExtensionZone, type DisplayExtensionZoneProps, DisplayField, type DisplayFieldProps, DisplaySection, type DisplaySectionField, type DisplaySectionProps, type EditAttributeAttribute, EditAttributeForm, type EditAttributeFormProps, EmailCell, EmailForm, EmailHeader, EmailSchema, type EntryRenderer, ErrorBoundary, ExtendableFormField, type ExtendableFormFieldProps, type ExtendableTable, type ExtensionGridColumnArgs, ExtensionProvider, type ExtensionProviderProps, ExtensionRegistry, type ExtractableOffer, type ExtractableOffers, type FeedbackSubmitHandler, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, FormExtensionZone, type FormExtensionZoneProps, type FormFieldInputType, type FormFieldOverride, GeneralSectionSkeleton, type GridFieldName, HandleInput, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, type ImageRef, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, KeyboundForm, LayoutComposer, type LayoutComposerProps, LayoutEntry, type LayoutEntryProps, type LayoutModule, LinkButton, ListBadge, ListSummary, Listicle, type ListicleProps, LocalizedTablePagination, type MediaDiff, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, type NavGroup, type NavGroupItem, type NavItemGroup, type NavigationModule, NoRecords, type NoRecordsProps, NoResults, type NoResultsProps, type OnboardingStep, type OnboardingStepDefault, OrderBy, PercentageInput, PermissionAction, type PermissionActionProps, PermissionGuard, type PermissionGuardProps, type PermissionedCommand, PermissionsContext, PermissionsProvider, type PermissionsProviderProps, PlaceholderCell, type PreferenceModule, PriceListDateStatus, type PriceListGridGroupRow, type PriceListGridOfferRow, type PriceListGridRow, PriceListStatus, PriceListType, type ProductAttributeBatchPayload, ProductAttributeSection, type ProductAttributeSectionProps, type ProductChangeAttribute, ProductChangePanel, type ProductChangePanelProps, type ProductChangeProduct, type ProductChangeResolvers, type ProductChangeVariant, type ProductChangeView, ProgressBar, ProvinceSelect, Query, REFERENCE_FIELDS, RICH_TEXT_ALLOWED_ATTRIBUTES, RICH_TEXT_ALLOWED_TAGS, type RawEntry, type ReferenceField, type RenderDefaultProps, type ResolvedAttribute, type ResolvedDisplays, type ResolvedFormField, RichText, RichTextEditor, type RichTextEditorProps, RouteDrawer, RouteFocusModal, RoutePermissionGuard, SIDEBAR_MENU_CONTENT, SIDEBAR_RAIL_FADE, SectionNoAccess, SectionRow, type SectionRowProps, type SectionWidget, type SectionWidgetMap, SegmentedControl, type SegmentedControlOption, SidebarContext, type SidebarContextValue, SidebarLink, type SidebarLinkProps, SidebarProvider, type SidebarState, SingleColumnLayoutComponent, SingleColumnPage, SingleColumnPageSkeleton, Skeleton, SortableList, SortableTree, StackedDrawer, StackedFocusModal, type StaticCountry, StatusCell, SwitchBox, type TQueryKey, type TabDefinition, TabbedForm, TableFooterSkeleton, TableSectionSkeleton, TableSkeleton, TextCell, TextHeader, TextSkeleton, Thumbnail, TopbarActions, TransferOwnershipSchema, TwoColumnLayoutComponent, TwoColumnPage, TwoColumnPageSkeleton, type UseExtendableFormProps, type UseExtendableGridProps, type UseExtendableTableProps, type UseQueryOptionsWrapper, type VariantGroup, VisuallyHidden, type Widget, type WidgetModule, type WidgetPlacement, type WidgetTab, type WidgetTabs, WidgetZone, type WidgetZoneProps, type ZoneWidgets, _DataTable, applyActionPermissions, applyNavGroups, applyNavOverrides, applyReplacements, buildAdditionalDataDefaults, buildAdditionalDataSchema, buildCoreEntries, buildDisplayEntries, buildOfferGridData, buildProductChangeView, buildScopedAdditionalData, buildWidgetEntries, countries, createDataGridHelper, createDataGridPriceColumns, createFormHelper, createWithPermission, currencies, detailPageDefaultEntries, extractPricesFromOffers, extractReferenceIds, extractSectionElements, filterCommandsByPermission, formatFieldValue, genericForwardRef, getCountryByIso2, getCurrencySymbol, getDecimalDigits, getExtensionRegistry, getFormattedAddress, getFormattedCountry, getLinkQuery, getListInitialData, getLocaleAmount, getNativeSymbol, getPriceListStatus, getStylizedAmount, groupNavItems, humanizeFieldName, isAmountLessThenRoundingError, isForbidden, isHtml, isImageList, isOrderActionable, isOrderAwaitingAction, isPermitted, isPriceListGroupRow, isProductRow, isReferenceField, isSameAddress, linkFields, mergeLayoutPreferences, mergeListFilters, navOverridesFromPreferences, permissionMapAllows, plainTextToHtml, productChangeViewHasContent, queryClient, queryKeysFactory, refineAdditionalData, resolveFormFieldType, resolveRouteOverrides, richTextContentClasses, sanitizeRichText, toPermissionList, useActionLocks, useCan, useCollapsedSidebar, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExpandedSidebar, useExtendableForm, useExtendableGrid, useExtendableTable, useExtension, useExtensionActivity, useLinkQuery, usePermissionGate, usePermissions, usePermittedCommands, useQueryParams, useResourcePermissions, useRouteModal, useSidebar, useSidebarMenuPlacement, useStackedModal, useTabManagement, useTabbedForm, useWidgetTabs, withLinkFields };
|
|
2621
|
+
export { type Action, type ActionGroup, ActionMenu, type AdditionalDataScope, AddressForm, AddressSchema, type AttributeChange, type AttributeChangeKind, AttributeValueInput, BadgeListSummary, type BuiltInFieldDefaults, type BuiltInFieldScope, CORE_ENTRY_PREFIX, CORE_LAYOUTS, ChipGroup, ChipInput, CodeCell, CodeHeader, Combobox, type Command, ConditionalTooltip, ConfirmPrompt, type ConfirmPromptProps, type CoreNavItem, CountrySelect, CreatedAtCell, CreatedAtHeader, type CurrencyInfo, type CustomFieldsModule, CustomerInfo, DataGrid, DataTable, DateCell, DateHeader, DateRangeDisplay, DeprecatedPercentageInput, type DetailPageDefaultsOptions, type DisplayEntry, DisplayExtensionZone, type DisplayExtensionZoneProps, DisplayField, type DisplayFieldProps, DisplaySection, type DisplaySectionField, type DisplaySectionProps, type EditAttributeAttribute, EditAttributeForm, type EditAttributeFormProps, EmailCell, EmailForm, EmailHeader, EmailSchema, type EntryRenderer, ErrorBoundary, ExtendableFormField, type ExtendableFormFieldProps, type ExtendableTable, type ExtensionGridColumnArgs, ExtensionProvider, type ExtensionProviderProps, ExtensionRegistry, type ExtractableOffer, type ExtractableOffers, type FeedbackSubmitHandler, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, FormExtensionZone, type FormExtensionZoneProps, type FormFieldInputType, type FormFieldOverride, GeneralSectionSkeleton, type GridFieldName, HandleInput, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, type ImageRef, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, KeyboundForm, LayoutComposer, type LayoutComposerProps, LayoutEntry, type LayoutEntryProps, type LayoutModule, LinkButton, ListBadge, ListSummary, Listicle, type ListicleProps, LocalizedTablePagination, type MediaDiff, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, type NavGroup, type NavGroupItem, type NavItemGroup, type NavigationModule, NoRecords, type NoRecordsProps, NoResults, type NoResultsProps, type OnboardingStep, type OnboardingStepDefault, OrderBy, PercentageInput, PermissionAction, type PermissionActionProps, PermissionGuard, type PermissionGuardProps, type PermissionedCommand, PermissionsContext, PermissionsProvider, type PermissionsProviderProps, PlaceholderCell, type PreferenceModule, PriceListDateStatus, type PriceListGridGroupRow, type PriceListGridOfferRow, type PriceListGridRow, PriceListStatus, PriceListType, type ProductAttributeBatchPayload, ProductAttributeSection, type ProductAttributeSectionProps, type ProductChangeAttribute, ProductChangePanel, type ProductChangePanelProps, type ProductChangeProduct, type ProductChangeResolvers, type ProductChangeVariant, type ProductChangeView, ProgressBar, ProvinceSelect, Query, REFERENCE_FIELDS, RICH_TEXT_ALLOWED_ATTRIBUTES, RICH_TEXT_ALLOWED_TAGS, type RawEntry, type ReferenceField, type RenderDefaultProps, type ResolvedAttribute, type ResolvedDisplays, type ResolvedFormField, RichText, RichTextEditor, type RichTextEditorProps, RouteDrawer, RouteFocusModal, RoutePermissionGuard, SIDEBAR_MENU_CONTENT, SIDEBAR_RAIL_FADE, SectionNoAccess, SectionRow, type SectionRowProps, type SectionWidget, type SectionWidgetMap, SegmentedControl, type SegmentedControlOption, SidebarContext, type SidebarContextValue, SidebarLink, type SidebarLinkProps, SidebarProvider, type SidebarState, SingleColumnLayoutComponent, SingleColumnPage, SingleColumnPageSkeleton, Skeleton, SortableList, SortableTree, StackedDrawer, StackedFocusModal, type StaticCountry, StatusCell, SwitchBox, type TQueryKey, type TabDefinition, TabbedForm, TableFooterSkeleton, TableSectionSkeleton, TableSkeleton, TextCell, TextHeader, TextSkeleton, Thumbnail, TopbarActions, TransferOwnershipSchema, TwoColumnLayoutComponent, TwoColumnPage, TwoColumnPageSkeleton, type UseExtendableFormProps, type UseExtendableGridProps, type UseExtendableTableProps, type UseQueryOptionsWrapper, type VariantGroup, VisuallyHidden, type Widget, type WidgetModule, type WidgetPlacement, type WidgetTab, type WidgetTabs, WidgetZone, type WidgetZoneProps, type ZoneWidgets, _DataTable, applyActionPermissions, applyNavGroups, applyNavOverrides, applyReplacements, buildAdditionalDataDefaults, buildAdditionalDataSchema, buildCoreEntries, buildDisplayEntries, buildOfferGridData, buildProductChangeView, buildScopedAdditionalData, buildWidgetEntries, countries, createDataGridHelper, createDataGridPriceColumns, createFormHelper, createWithPermission, currencies, detailPageDefaultEntries, extractPricesFromOffers, extractReferenceIds, extractSectionElements, filterCommandsByPermission, formatFieldValue, genericForwardRef, getCountryByIso2, getCurrencySymbol, getDecimalDigits, getExtensionRegistry, getFormattedAddress, getFormattedCountry, getLinkQuery, getListInitialData, getLocaleAmount, getNativeSymbol, getPriceListStatus, getStylizedAmount, groupNavItems, humanizeFieldName, isAmountLessThenRoundingError, isForbidden, isHtml, isImageList, isOrderActionable, isOrderAwaitingAction, isPermitted, isPriceListGroupRow, isProductRow, isReferenceField, isSameAddress, linkFields, mergeLayoutPreferences, mergeListFilters, navOverridesFromPreferences, overrideLazyRoute, permissionMapAllows, plainTextToHtml, productChangeViewHasContent, queryClient, queryKeysFactory, refineAdditionalData, resolveBuiltInFieldDefault, resolveFormFieldType, resolveRouteOverrides, richTextContentClasses, sanitizeRichText, toPermissionList, useActionLocks, useBuiltInFieldDefaults, useCan, useCollapsedSidebar, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExpandedSidebar, useExtendableForm, useExtendableGrid, useExtendableTable, useExtension, useExtensionActivity, useLinkQuery, usePermissionGate, usePermissions, usePermittedCommands, useQueryParams, useResourcePermissions, useRouteModal, useSidebar, useSidebarMenuPlacement, useStackedModal, useTabManagement, useTabbedForm, useWidgetTabs, withLinkFields };
|
package/dist/index.js
CHANGED
|
@@ -26477,19 +26477,25 @@ var ExtensionRegistry = class {
|
|
|
26477
26477
|
getActivity(model, entity) {
|
|
26478
26478
|
return this.configsFor(model).flatMap((c) => c.activity?.(entity) ?? []);
|
|
26479
26479
|
}
|
|
26480
|
-
// Configs are ordered plugins first, host app last. Entries are keyed
|
|
26481
|
-
// later config replaces an earlier one in place —
|
|
26482
|
-
// config added — instead of stacking a duplicate
|
|
26480
|
+
// Configs are ordered plugins first, host app last. Entries are keyed per
|
|
26481
|
+
// zone and tab so a later config replaces an earlier one in place —
|
|
26482
|
+
// including entries another config added — instead of stacking a duplicate,
|
|
26483
|
+
// while one field name can still appear in several zones.
|
|
26483
26484
|
resolveFormFields(model) {
|
|
26484
|
-
const
|
|
26485
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
26485
26486
|
for (const config3 of this.configsFor(model)) {
|
|
26486
26487
|
for (const form of config3.forms ?? []) {
|
|
26487
26488
|
for (const [name, field] of Object.entries(form.fields ?? {})) {
|
|
26488
|
-
|
|
26489
|
+
byKey.set(`${form.zone}\0${form.tab ?? ""}\0${name}`, {
|
|
26490
|
+
name,
|
|
26491
|
+
field,
|
|
26492
|
+
zone: form.zone,
|
|
26493
|
+
tab: form.tab
|
|
26494
|
+
});
|
|
26489
26495
|
}
|
|
26490
26496
|
}
|
|
26491
26497
|
}
|
|
26492
|
-
return [...
|
|
26498
|
+
return [...byKey.values()];
|
|
26493
26499
|
}
|
|
26494
26500
|
// An entry without a tab belongs to every tab of its zone, unless the host
|
|
26495
26501
|
// asks for `exactTab` (a data grid tab only takes fields aimed at it).
|
|
@@ -26511,6 +26517,16 @@ var ExtensionRegistry = class {
|
|
|
26511
26517
|
({ name, field }) => field && !builtIns.has(name) ? [{ name, field }] : []
|
|
26512
26518
|
);
|
|
26513
26519
|
}
|
|
26520
|
+
/**
|
|
26521
|
+
* Custom fields of every tab of a zone, for a tabbed form's schema and
|
|
26522
|
+
* defaults, which cover all its tabs at once.
|
|
26523
|
+
*/
|
|
26524
|
+
getZoneFormFields(model, zone, builtInFieldIds = []) {
|
|
26525
|
+
const builtIns = new Set(builtInFieldIds);
|
|
26526
|
+
return this.resolveFormFields(model).flatMap(
|
|
26527
|
+
({ name, field, zone: z5 }) => z5 === zone && field && !builtIns.has(name) ? [{ name, field }] : []
|
|
26528
|
+
);
|
|
26529
|
+
}
|
|
26514
26530
|
/** Replacement (or removal, `field: null`) of a built-in form field. */
|
|
26515
26531
|
getFormFieldOverride(model, zone, id, tab, exactTab = false) {
|
|
26516
26532
|
const entry = this.formEntriesFor(model, zone, tab, exactTab).find(
|
|
@@ -26642,6 +26658,20 @@ function override(previous, next) {
|
|
|
26642
26658
|
children: next.children ? resolveRouteOverrides([...previous.children ?? [], ...next.children]) : previous.children
|
|
26643
26659
|
};
|
|
26644
26660
|
}
|
|
26661
|
+
var mergeHandles = (previous, next) => previous && next && typeof previous === "object" && typeof next === "object" ? { ...previous, ...next } : next ?? previous;
|
|
26662
|
+
function overrideLazyRoute(previous, next) {
|
|
26663
|
+
return async () => {
|
|
26664
|
+
const [base, custom] = await Promise.all([previous(), next()]);
|
|
26665
|
+
const Previous = base.Component;
|
|
26666
|
+
const Next = custom.Component;
|
|
26667
|
+
if (!Previous || !Next) {
|
|
26668
|
+
return { ...base, ...custom };
|
|
26669
|
+
}
|
|
26670
|
+
const Component = (props) => createElement(Next, { ...props, renderDefault: () => createElement(Previous) });
|
|
26671
|
+
Component.displayName = Next.displayName ?? Next.name ?? "RouteOverride";
|
|
26672
|
+
return { ...base, ...custom, Component, handle: mergeHandles(base.handle, custom.handle) };
|
|
26673
|
+
};
|
|
26674
|
+
}
|
|
26645
26675
|
function resolveRouteOverrides(routes) {
|
|
26646
26676
|
const byPath = /* @__PURE__ */ new Map();
|
|
26647
26677
|
for (const route of routes) {
|
|
@@ -26927,9 +26957,13 @@ function resolveFormFieldType(field) {
|
|
|
26927
26957
|
return "textarea";
|
|
26928
26958
|
}
|
|
26929
26959
|
}
|
|
26960
|
+
var resolveScopedFields = (registry, model, zone, tab, builtInFieldIds) => {
|
|
26961
|
+
if (!zone) return registry.getAllFormFields(model);
|
|
26962
|
+
return tab ? registry.getFormFields(model, zone, tab, builtInFieldIds) : registry.getZoneFormFields(model, zone, builtInFieldIds);
|
|
26963
|
+
};
|
|
26930
26964
|
function buildAdditionalDataSchema(registry, model, zone, tab, builtInFieldIds) {
|
|
26931
26965
|
const shape = {};
|
|
26932
|
-
const fields =
|
|
26966
|
+
const fields = resolveScopedFields(registry, model, zone, tab, builtInFieldIds);
|
|
26933
26967
|
for (const { name, field } of fields) {
|
|
26934
26968
|
shape[name] = field.validation;
|
|
26935
26969
|
}
|
|
@@ -26937,7 +26971,7 @@ function buildAdditionalDataSchema(registry, model, zone, tab, builtInFieldIds)
|
|
|
26937
26971
|
}
|
|
26938
26972
|
function buildAdditionalDataDefaults(registry, model, data, zone, tab, builtInFieldIds) {
|
|
26939
26973
|
const defaults = {};
|
|
26940
|
-
const fields =
|
|
26974
|
+
const fields = resolveScopedFields(registry, model, zone, tab, builtInFieldIds);
|
|
26941
26975
|
for (const { name, field } of fields) {
|
|
26942
26976
|
if (typeof field.defaultValue === "function") {
|
|
26943
26977
|
defaults[name] = field.defaultValue(data);
|
|
@@ -27075,13 +27109,7 @@ var FormExtensionZone = ({
|
|
|
27075
27109
|
builtInFieldIds,
|
|
27076
27110
|
exactTab
|
|
27077
27111
|
}) => {
|
|
27078
|
-
const fields = useExtension().getFormFields(
|
|
27079
|
-
model,
|
|
27080
|
-
zone,
|
|
27081
|
-
tab,
|
|
27082
|
-
builtInFieldIds,
|
|
27083
|
-
exactTab
|
|
27084
|
-
);
|
|
27112
|
+
const fields = useExtension().getFormFields(model, zone, tab, builtInFieldIds, exactTab).filter(({ field }) => !field.hidden);
|
|
27085
27113
|
if (fields.length === 0) return null;
|
|
27086
27114
|
return /* @__PURE__ */ jsx83("div", { className: "flex flex-col gap-y-4", children: fields.map(({ name, field }) => /* @__PURE__ */ jsx83(
|
|
27087
27115
|
ExtensionField,
|
|
@@ -27111,7 +27139,7 @@ var ExtendableFormField = ({
|
|
|
27111
27139
|
tab
|
|
27112
27140
|
);
|
|
27113
27141
|
if (!overridden) return /* @__PURE__ */ jsx83(Fragment9, { children });
|
|
27114
|
-
if (!field) return null;
|
|
27142
|
+
if (!field || field.hidden) return null;
|
|
27115
27143
|
return /* @__PURE__ */ jsx83(
|
|
27116
27144
|
ExtensionField,
|
|
27117
27145
|
{
|
|
@@ -27258,21 +27286,24 @@ function applyGridExtension(extension, {
|
|
|
27258
27286
|
}) {
|
|
27259
27287
|
const locked = new Set(lockedColumnIds);
|
|
27260
27288
|
const builtInIds = baseColumns.flatMap((c) => columnId2(c) ?? []);
|
|
27289
|
+
const overrideFor = (id) => {
|
|
27290
|
+
const exact = extension.getFormFieldOverride(model, zone, id, tab, true);
|
|
27291
|
+
const group = id.includes(".") ? id.slice(0, id.indexOf(".")) : null;
|
|
27292
|
+
if (exact.overridden || !group) return exact;
|
|
27293
|
+
return extension.getFormFieldOverride(model, zone, group, tab, true);
|
|
27294
|
+
};
|
|
27261
27295
|
const columns = baseColumns.flatMap((col) => {
|
|
27262
27296
|
const id = columnId2(col);
|
|
27263
27297
|
if (!id || locked.has(id)) return [col];
|
|
27264
|
-
const { overridden, field } =
|
|
27265
|
-
model,
|
|
27266
|
-
zone,
|
|
27267
|
-
id,
|
|
27268
|
-
tab,
|
|
27269
|
-
true
|
|
27270
|
-
);
|
|
27298
|
+
const { overridden, field } = overrideFor(id);
|
|
27271
27299
|
if (!overridden) return [col];
|
|
27272
|
-
if (!field) return [];
|
|
27300
|
+
if (!field || field.hidden) return [];
|
|
27273
27301
|
return [createColumn({ id, field, getFieldName: baseFieldName(col) })];
|
|
27274
27302
|
});
|
|
27275
|
-
const
|
|
27303
|
+
const builtInGroups = builtInIds.flatMap(
|
|
27304
|
+
(id) => id.includes(".") ? [id.slice(0, id.indexOf("."))] : []
|
|
27305
|
+
);
|
|
27306
|
+
const added = allowAdd ? extension.getFormFields(model, zone, tab, [...builtInIds, ...builtInGroups], true).filter(({ field }) => !field.hidden) : [];
|
|
27276
27307
|
for (const { name, field } of added) {
|
|
27277
27308
|
columns.push(
|
|
27278
27309
|
createColumn({
|
|
@@ -27324,6 +27355,73 @@ function useExtendableGrid(props) {
|
|
|
27324
27355
|
);
|
|
27325
27356
|
}
|
|
27326
27357
|
|
|
27358
|
+
// src/extensions/use-built-in-field-defaults.ts
|
|
27359
|
+
import { useQueries as useQueries2 } from "@tanstack/react-query";
|
|
27360
|
+
import { useCallback as useCallback22, useMemo as useMemo20 } from "react";
|
|
27361
|
+
async function resolveBuiltInFieldDefault(extension, { model, zone, tab, exactTab }, id) {
|
|
27362
|
+
const { field } = extension.getFormFieldOverride(model, zone, id, tab, exactTab);
|
|
27363
|
+
if (!field || field.defaultValue === void 0) return void 0;
|
|
27364
|
+
if (typeof field.defaultValue !== "function") return field.defaultValue;
|
|
27365
|
+
try {
|
|
27366
|
+
return await field.defaultValue(void 0);
|
|
27367
|
+
} catch {
|
|
27368
|
+
return void 0;
|
|
27369
|
+
}
|
|
27370
|
+
}
|
|
27371
|
+
function useBuiltInFieldDefaults(scope, ids) {
|
|
27372
|
+
const extension = useExtension();
|
|
27373
|
+
const { model, zone, tab, exactTab } = scope;
|
|
27374
|
+
const idsKey = ids.join(",");
|
|
27375
|
+
const overrides = useMemo20(
|
|
27376
|
+
() => (idsKey ? idsKey.split(",") : []).flatMap((id) => {
|
|
27377
|
+
const { field } = extension.getFormFieldOverride(
|
|
27378
|
+
model,
|
|
27379
|
+
zone,
|
|
27380
|
+
id,
|
|
27381
|
+
tab,
|
|
27382
|
+
exactTab
|
|
27383
|
+
);
|
|
27384
|
+
return field ? [{ id, field }] : [];
|
|
27385
|
+
}),
|
|
27386
|
+
[extension, model, zone, tab, exactTab, idsKey]
|
|
27387
|
+
);
|
|
27388
|
+
const withDefault = useMemo20(
|
|
27389
|
+
() => overrides.filter(({ field }) => field.defaultValue !== void 0),
|
|
27390
|
+
[overrides]
|
|
27391
|
+
);
|
|
27392
|
+
const combine = useCallback22(
|
|
27393
|
+
(results) => {
|
|
27394
|
+
const values2 = {};
|
|
27395
|
+
results.forEach((result, index) => {
|
|
27396
|
+
if (result.data !== void 0 && result.data !== null) {
|
|
27397
|
+
values2[withDefault[index].id] = result.data;
|
|
27398
|
+
}
|
|
27399
|
+
});
|
|
27400
|
+
return { values: values2, isLoading: results.some((r) => r.isPending) };
|
|
27401
|
+
},
|
|
27402
|
+
[withDefault]
|
|
27403
|
+
);
|
|
27404
|
+
const { values, isLoading } = useQueries2({
|
|
27405
|
+
queries: withDefault.map(({ id }) => ({
|
|
27406
|
+
queryKey: ["extension-default", model, zone, tab ?? null, id],
|
|
27407
|
+
queryFn: async () => await resolveBuiltInFieldDefault(extension, scope, id) ?? null,
|
|
27408
|
+
staleTime: Infinity,
|
|
27409
|
+
retry: false
|
|
27410
|
+
})),
|
|
27411
|
+
combine
|
|
27412
|
+
});
|
|
27413
|
+
const hidden = useMemo20(
|
|
27414
|
+
() => Object.fromEntries(
|
|
27415
|
+
overrides.filter(({ field }) => field.hidden).map(({ id }) => [id, true])
|
|
27416
|
+
),
|
|
27417
|
+
[overrides]
|
|
27418
|
+
);
|
|
27419
|
+
return useMemo20(
|
|
27420
|
+
() => ({ values, hidden, isLoading }),
|
|
27421
|
+
[values, hidden, isLoading]
|
|
27422
|
+
);
|
|
27423
|
+
}
|
|
27424
|
+
|
|
27327
27425
|
// src/extensions/list-filters.ts
|
|
27328
27426
|
var isRemoval = (filter) => "remove" in filter && filter.remove === true;
|
|
27329
27427
|
function mergeListFilters(base, extensions) {
|
|
@@ -27369,7 +27467,7 @@ var useLinkQuery = (model, base) => {
|
|
|
27369
27467
|
|
|
27370
27468
|
// src/extensions/use-extendable-form.ts
|
|
27371
27469
|
import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
|
|
27372
|
-
import { useMemo as
|
|
27470
|
+
import { useMemo as useMemo21 } from "react";
|
|
27373
27471
|
import { useForm as useForm3 } from "react-hook-form";
|
|
27374
27472
|
import { z as z4 } from "zod";
|
|
27375
27473
|
var useExtendableForm = ({
|
|
@@ -27383,7 +27481,7 @@ var useExtendableForm = ({
|
|
|
27383
27481
|
...props
|
|
27384
27482
|
}) => {
|
|
27385
27483
|
const extension = useExtension();
|
|
27386
|
-
const schema =
|
|
27484
|
+
const schema = useMemo21(() => {
|
|
27387
27485
|
const additionalData = buildAdditionalDataSchema(
|
|
27388
27486
|
extension,
|
|
27389
27487
|
model,
|
|
@@ -27393,7 +27491,7 @@ var useExtendableForm = ({
|
|
|
27393
27491
|
).partial().optional();
|
|
27394
27492
|
return typeof baseSchema.extend === "function" ? baseSchema.extend({ additional_data: additionalData }) : baseSchema.and(z4.object({ additional_data: additionalData }));
|
|
27395
27493
|
}, [baseSchema, extension, model, zone, tab, builtInFieldIds]);
|
|
27396
|
-
const defaultValues =
|
|
27494
|
+
const defaultValues = useMemo21(
|
|
27397
27495
|
() => ({
|
|
27398
27496
|
...baseDefaultValues,
|
|
27399
27497
|
additional_data: buildAdditionalDataDefaults(
|
|
@@ -27415,17 +27513,17 @@ var useExtendableForm = ({
|
|
|
27415
27513
|
};
|
|
27416
27514
|
|
|
27417
27515
|
// src/extensions/action-locks.ts
|
|
27418
|
-
import { useCallback as
|
|
27516
|
+
import { useCallback as useCallback23, useMemo as useMemo22 } from "react";
|
|
27419
27517
|
var useActionLocks = (model, entity) => {
|
|
27420
27518
|
const registry = useExtension();
|
|
27421
|
-
return
|
|
27519
|
+
return useCallback23(
|
|
27422
27520
|
(action) => registry.getActionLock(model, action, entity),
|
|
27423
27521
|
[registry, model, entity]
|
|
27424
27522
|
);
|
|
27425
27523
|
};
|
|
27426
27524
|
var useExtensionActivity = (model, entity) => {
|
|
27427
27525
|
const registry = useExtension();
|
|
27428
|
-
return
|
|
27526
|
+
return useMemo22(
|
|
27429
27527
|
() => registry.getActivity(model, entity),
|
|
27430
27528
|
[registry, model, entity]
|
|
27431
27529
|
);
|
|
@@ -27663,17 +27761,17 @@ import {
|
|
|
27663
27761
|
Children as Children3,
|
|
27664
27762
|
createContext as createContext9,
|
|
27665
27763
|
useContext as useContext13,
|
|
27666
|
-
useMemo as
|
|
27764
|
+
useMemo as useMemo24
|
|
27667
27765
|
} from "react";
|
|
27668
27766
|
import { useTranslation as useTranslation37 } from "react-i18next";
|
|
27669
27767
|
|
|
27670
27768
|
// src/components/tabbed-form/use-tab-management.ts
|
|
27671
|
-
import { useCallback as
|
|
27769
|
+
import { useCallback as useCallback24, useEffect as useEffect20, useMemo as useMemo23, useState as useState32 } from "react";
|
|
27672
27770
|
var useTabManagement = ({
|
|
27673
27771
|
tabs,
|
|
27674
27772
|
form
|
|
27675
27773
|
}) => {
|
|
27676
|
-
const visibleTabs =
|
|
27774
|
+
const visibleTabs = useMemo23(
|
|
27677
27775
|
() => tabs.filter((t2) => !t2.isVisible || t2.isVisible(form)),
|
|
27678
27776
|
[tabs, form]
|
|
27679
27777
|
);
|
|
@@ -27703,7 +27801,7 @@ var useTabManagement = ({
|
|
|
27703
27801
|
}, [activeTabId, visibleTabs]);
|
|
27704
27802
|
const activeIndex = visibleTabs.findIndex((t2) => t2.id === activeTabId);
|
|
27705
27803
|
const isLastTab = activeIndex === visibleTabs.length - 1;
|
|
27706
|
-
const onNext =
|
|
27804
|
+
const onNext = useCallback24(async () => {
|
|
27707
27805
|
const valid = await form.trigger();
|
|
27708
27806
|
if (!valid) {
|
|
27709
27807
|
return;
|
|
@@ -27712,7 +27810,7 @@ var useTabManagement = ({
|
|
|
27712
27810
|
setActiveTabId(visibleTabs[activeIndex + 1].id);
|
|
27713
27811
|
}
|
|
27714
27812
|
}, [form, activeIndex, visibleTabs]);
|
|
27715
|
-
const onTabChange =
|
|
27813
|
+
const onTabChange = useCallback24(
|
|
27716
27814
|
async (tabId) => {
|
|
27717
27815
|
const valid = await form.trigger();
|
|
27718
27816
|
if (!valid) {
|
|
@@ -27782,11 +27880,11 @@ function Root6({
|
|
|
27782
27880
|
transformTabs
|
|
27783
27881
|
}) {
|
|
27784
27882
|
const { t: t2 } = useTranslation37();
|
|
27785
|
-
const { tabs: rawTabs, elements } =
|
|
27883
|
+
const { tabs: rawTabs, elements } = useMemo24(
|
|
27786
27884
|
() => collectTabs(children),
|
|
27787
27885
|
[children]
|
|
27788
27886
|
);
|
|
27789
|
-
const tabs =
|
|
27887
|
+
const tabs = useMemo24(
|
|
27790
27888
|
() => transformTabs ? transformTabs(rawTabs) : rawTabs,
|
|
27791
27889
|
[transformTabs, rawTabs]
|
|
27792
27890
|
);
|
|
@@ -27917,7 +28015,7 @@ import { memo } from "react";
|
|
|
27917
28015
|
// src/components/table/data-table/data-table-filter/data-table-filter.tsx
|
|
27918
28016
|
import { Button as Button14, clx as clx49 } from "@medusajs/ui";
|
|
27919
28017
|
import { Popover as RadixPopover8 } from "radix-ui";
|
|
27920
|
-
import { useCallback as
|
|
28018
|
+
import { useCallback as useCallback27, useEffect as useEffect23, useMemo as useMemo26, useRef as useRef18, useState as useState37 } from "react";
|
|
27921
28019
|
import { useSearchParams as useSearchParams7 } from "react-router-dom";
|
|
27922
28020
|
import { useTranslation as useTranslation42 } from "react-i18next";
|
|
27923
28021
|
|
|
@@ -27939,7 +28037,7 @@ import { EllipseMiniSolid as EllipseMiniSolid2 } from "@medusajs/icons";
|
|
|
27939
28037
|
import { DatePicker, Text as Text21, clx as clx45 } from "@medusajs/ui";
|
|
27940
28038
|
import isEqual from "lodash.isequal";
|
|
27941
28039
|
import { Popover as RadixPopover4 } from "radix-ui";
|
|
27942
|
-
import { useMemo as
|
|
28040
|
+
import { useMemo as useMemo25, useState as useState33 } from "react";
|
|
27943
28041
|
import { t } from "i18next";
|
|
27944
28042
|
import { useTranslation as useTranslation39 } from "react-i18next";
|
|
27945
28043
|
|
|
@@ -28297,7 +28395,7 @@ var today = /* @__PURE__ */ new Date();
|
|
|
28297
28395
|
today.setHours(0, 0, 0, 0);
|
|
28298
28396
|
var usePresets = () => {
|
|
28299
28397
|
const { t: t2 } = useTranslation39();
|
|
28300
|
-
return
|
|
28398
|
+
return useMemo25(
|
|
28301
28399
|
() => [
|
|
28302
28400
|
{
|
|
28303
28401
|
label: t2("filters.date.today"),
|
|
@@ -28367,7 +28465,7 @@ import {
|
|
|
28367
28465
|
Popover as RadixPopover5,
|
|
28368
28466
|
RadioGroup as RadixRadioGroup
|
|
28369
28467
|
} from "radix-ui";
|
|
28370
|
-
import { useCallback as
|
|
28468
|
+
import { useCallback as useCallback25, useEffect as useEffect21, useState as useState34 } from "react";
|
|
28371
28469
|
import { useTranslation as useTranslation40 } from "react-i18next";
|
|
28372
28470
|
import { jsx as jsx90, jsxs as jsxs65 } from "react/jsx-runtime";
|
|
28373
28471
|
var NumberFilter = ({
|
|
@@ -28392,7 +28490,7 @@ var NumberFilter = ({
|
|
|
28392
28490
|
const [operator, setOperator] = useState34(
|
|
28393
28491
|
getOperator(currentValue)
|
|
28394
28492
|
);
|
|
28395
|
-
const debouncedOnChange =
|
|
28493
|
+
const debouncedOnChange = useCallback25(
|
|
28396
28494
|
debounce2((e, operator2) => {
|
|
28397
28495
|
const value = e.target.value;
|
|
28398
28496
|
const curr = JSON.parse(currentValue?.join(",") || "{}");
|
|
@@ -28762,7 +28860,7 @@ var SelectFilter = ({
|
|
|
28762
28860
|
import { Input as Input12, Label as Label5, clx as clx48 } from "@medusajs/ui";
|
|
28763
28861
|
import debounce3 from "lodash.debounce";
|
|
28764
28862
|
import { Popover as RadixPopover7 } from "radix-ui";
|
|
28765
|
-
import { useCallback as
|
|
28863
|
+
import { useCallback as useCallback26, useEffect as useEffect22, useState as useState36 } from "react";
|
|
28766
28864
|
import { jsx as jsx92, jsxs as jsxs67 } from "react/jsx-runtime";
|
|
28767
28865
|
var StringFilter = ({
|
|
28768
28866
|
filter,
|
|
@@ -28778,7 +28876,7 @@ var StringFilter = ({
|
|
|
28778
28876
|
const [previousValue, setPreviousValue] = useState36(
|
|
28779
28877
|
query?.[0]
|
|
28780
28878
|
);
|
|
28781
|
-
const debouncedOnChange =
|
|
28879
|
+
const debouncedOnChange = useCallback26(
|
|
28782
28880
|
debounce3((e) => {
|
|
28783
28881
|
const value = e.target.value;
|
|
28784
28882
|
if (!value) {
|
|
@@ -28907,16 +29005,16 @@ var DataTableFilter2 = ({
|
|
|
28907
29005
|
setOpen(false);
|
|
28908
29006
|
setActiveFilters((prev) => [...prev, { ...filter, openOnMount: true }]);
|
|
28909
29007
|
};
|
|
28910
|
-
const removeFilter =
|
|
29008
|
+
const removeFilter = useCallback27((key) => {
|
|
28911
29009
|
setActiveFilters((prev) => prev.filter((f) => f.key !== key));
|
|
28912
29010
|
}, []);
|
|
28913
|
-
const removeAllFilters =
|
|
29011
|
+
const removeAllFilters = useCallback27(() => {
|
|
28914
29012
|
setActiveFilters([]);
|
|
28915
29013
|
}, []);
|
|
28916
29014
|
return /* @__PURE__ */ jsx93(
|
|
28917
29015
|
DataTableFilterContext.Provider,
|
|
28918
29016
|
{
|
|
28919
|
-
value:
|
|
29017
|
+
value: useMemo26(
|
|
28920
29018
|
() => ({
|
|
28921
29019
|
removeFilter,
|
|
28922
29020
|
removeAllFilters
|
|
@@ -29203,7 +29301,7 @@ var DataTableOrderBy = ({
|
|
|
29203
29301
|
|
|
29204
29302
|
// src/components/table/data-table/data-table-search/data-table-search.tsx
|
|
29205
29303
|
import { Input as Input13 } from "@medusajs/ui";
|
|
29206
|
-
import { useCallback as
|
|
29304
|
+
import { useCallback as useCallback28, useEffect as useEffect24 } from "react";
|
|
29207
29305
|
import { useTranslation as useTranslation44 } from "react-i18next";
|
|
29208
29306
|
import debounce4 from "lodash.debounce";
|
|
29209
29307
|
import { jsx as jsx95 } from "react/jsx-runtime";
|
|
@@ -29220,7 +29318,7 @@ var DataTableSearch = ({
|
|
|
29220
29318
|
multiple: false
|
|
29221
29319
|
});
|
|
29222
29320
|
const query = selectedParams.get();
|
|
29223
|
-
const debouncedOnChange =
|
|
29321
|
+
const debouncedOnChange = useCallback28(
|
|
29224
29322
|
debounce4((e) => {
|
|
29225
29323
|
const value = e.target.value;
|
|
29226
29324
|
if (!value) {
|
|
@@ -29879,7 +29977,7 @@ import {
|
|
|
29879
29977
|
getPaginationRowModel,
|
|
29880
29978
|
useReactTable as useReactTable2
|
|
29881
29979
|
} from "@tanstack/react-table";
|
|
29882
|
-
import { useEffect as useEffect26, useMemo as
|
|
29980
|
+
import { useEffect as useEffect26, useMemo as useMemo27, useState as useState40 } from "react";
|
|
29883
29981
|
import { useSearchParams as useSearchParams9 } from "react-router-dom";
|
|
29884
29982
|
var useDataTable2 = ({
|
|
29885
29983
|
data = [],
|
|
@@ -29902,7 +30000,7 @@ var useDataTable2 = ({
|
|
|
29902
30000
|
pageIndex: offset ? Math.ceil(Number(offset) / _pageSize) : 0,
|
|
29903
30001
|
pageSize: _pageSize
|
|
29904
30002
|
});
|
|
29905
|
-
const pagination =
|
|
30003
|
+
const pagination = useMemo27(
|
|
29906
30004
|
() => ({
|
|
29907
30005
|
pageIndex,
|
|
29908
30006
|
pageSize
|
|
@@ -29964,7 +30062,7 @@ var useDataTable2 = ({
|
|
|
29964
30062
|
};
|
|
29965
30063
|
|
|
29966
30064
|
// src/permissions/permissions-provider.tsx
|
|
29967
|
-
import { useCallback as
|
|
30065
|
+
import { useCallback as useCallback29, useMemo as useMemo28 } from "react";
|
|
29968
30066
|
import { jsx as jsx110 } from "react/jsx-runtime";
|
|
29969
30067
|
var PermissionsProvider = ({
|
|
29970
30068
|
permissions = null,
|
|
@@ -29972,11 +30070,11 @@ var PermissionsProvider = ({
|
|
|
29972
30070
|
children
|
|
29973
30071
|
}) => {
|
|
29974
30072
|
const isEnforced = !!permissions;
|
|
29975
|
-
const can =
|
|
30073
|
+
const can = useCallback29(
|
|
29976
30074
|
(key, right = "view") => !permissions || satisfiesPermission(permissions, key, right),
|
|
29977
30075
|
[permissions]
|
|
29978
30076
|
);
|
|
29979
|
-
const hasPermission =
|
|
30077
|
+
const hasPermission = useCallback29(
|
|
29980
30078
|
(permission) => {
|
|
29981
30079
|
if (!permissions) {
|
|
29982
30080
|
return true;
|
|
@@ -29986,15 +30084,15 @@ var PermissionsProvider = ({
|
|
|
29986
30084
|
},
|
|
29987
30085
|
[permissions]
|
|
29988
30086
|
);
|
|
29989
|
-
const hasAnyPermission =
|
|
30087
|
+
const hasAnyPermission = useCallback29(
|
|
29990
30088
|
(list) => !permissions || list.some(hasPermission),
|
|
29991
30089
|
[permissions, hasPermission]
|
|
29992
30090
|
);
|
|
29993
|
-
const hasAllPermissions =
|
|
30091
|
+
const hasAllPermissions = useCallback29(
|
|
29994
30092
|
(list) => !permissions || list.every(hasPermission),
|
|
29995
30093
|
[permissions, hasPermission]
|
|
29996
30094
|
);
|
|
29997
|
-
const value =
|
|
30095
|
+
const value = useMemo28(
|
|
29998
30096
|
() => ({
|
|
29999
30097
|
permissions,
|
|
30000
30098
|
isLoading,
|
|
@@ -30036,7 +30134,7 @@ var PermissionGuard = ({
|
|
|
30036
30134
|
// src/permissions/route-permission-guard.tsx
|
|
30037
30135
|
import { ExclamationCircle as ExclamationCircle5 } from "@medusajs/icons";
|
|
30038
30136
|
import { Container as Container6, Heading as Heading10, Text as Text23 } from "@medusajs/ui";
|
|
30039
|
-
import { useMemo as
|
|
30137
|
+
import { useMemo as useMemo29 } from "react";
|
|
30040
30138
|
import { useTranslation as useTranslation51 } from "react-i18next";
|
|
30041
30139
|
import { Navigate as Navigate2, Outlet as Outlet3, useMatches } from "react-router-dom";
|
|
30042
30140
|
import { jsx as jsx112, jsxs as jsxs75 } from "react/jsx-runtime";
|
|
@@ -30069,7 +30167,7 @@ var readRequirementFromHandle = (handle) => {
|
|
|
30069
30167
|
var RoutePermissionGuard = () => {
|
|
30070
30168
|
const matches = useMatches();
|
|
30071
30169
|
const { hasAnyPermission, hasAllPermissions, isLoading } = usePermissions();
|
|
30072
|
-
const requirement =
|
|
30170
|
+
const requirement = useMemo29(() => {
|
|
30073
30171
|
for (let i = matches.length - 1; i >= 0; i--) {
|
|
30074
30172
|
const found = readRequirementFromHandle(matches[i].handle);
|
|
30075
30173
|
if (found) {
|
|
@@ -30107,10 +30205,10 @@ var AccessDenied = ({
|
|
|
30107
30205
|
};
|
|
30108
30206
|
|
|
30109
30207
|
// src/permissions/use-resource-permissions.tsx
|
|
30110
|
-
import { useMemo as
|
|
30208
|
+
import { useMemo as useMemo30 } from "react";
|
|
30111
30209
|
var useResourcePermissions = (key) => {
|
|
30112
30210
|
const { can, isLoading } = usePermissions();
|
|
30113
|
-
return
|
|
30211
|
+
return useMemo30(
|
|
30114
30212
|
() => ({
|
|
30115
30213
|
canView: can(key, "view"),
|
|
30116
30214
|
canEdit: can(key, "edit"),
|
|
@@ -30177,7 +30275,7 @@ import { createContext as createContext11 } from "react";
|
|
|
30177
30275
|
var SidebarContext = createContext11(null);
|
|
30178
30276
|
|
|
30179
30277
|
// src/providers/sidebar-provider/sidebar-provider.tsx
|
|
30180
|
-
import { useCallback as
|
|
30278
|
+
import { useCallback as useCallback30, useEffect as useEffect27, useMemo as useMemo31, useState as useState41 } from "react";
|
|
30181
30279
|
import { useLocation as useLocation4 } from "react-router-dom";
|
|
30182
30280
|
import { jsx as jsx115 } from "react/jsx-runtime";
|
|
30183
30281
|
var SidebarProvider = ({ children }) => {
|
|
@@ -30187,14 +30285,14 @@ var SidebarProvider = ({ children }) => {
|
|
|
30187
30285
|
useEffect27(() => {
|
|
30188
30286
|
setMobile(false);
|
|
30189
30287
|
}, [pathname]);
|
|
30190
|
-
const toggle =
|
|
30288
|
+
const toggle = useCallback30((view) => {
|
|
30191
30289
|
if (view === "desktop") {
|
|
30192
30290
|
setDesktop((open) => !open);
|
|
30193
30291
|
} else {
|
|
30194
30292
|
setMobile((open) => !open);
|
|
30195
30293
|
}
|
|
30196
30294
|
}, []);
|
|
30197
|
-
const value =
|
|
30295
|
+
const value = useMemo31(
|
|
30198
30296
|
() => ({
|
|
30199
30297
|
state: desktop ? "expanded" : "collapsed",
|
|
30200
30298
|
desktop,
|
|
@@ -30249,7 +30347,7 @@ var useSidebarMenuPlacement = (align) => {
|
|
|
30249
30347
|
};
|
|
30250
30348
|
|
|
30251
30349
|
// src/layout-composer/layout-composer.tsx
|
|
30252
|
-
import { Fragment as Fragment16, useContext as useContext18, useMemo as
|
|
30350
|
+
import { Fragment as Fragment16, useContext as useContext18, useMemo as useMemo32 } from "react";
|
|
30253
30351
|
import { Outlet as Outlet4 } from "react-router-dom";
|
|
30254
30352
|
|
|
30255
30353
|
// src/layout-composer/entries.ts
|
|
@@ -30394,7 +30492,7 @@ var LayoutComposerRoot = ({
|
|
|
30394
30492
|
const registry = useExtension();
|
|
30395
30493
|
const permissions = useContext18(PermissionsContext);
|
|
30396
30494
|
const layout = registry.getLayout(preferredLayoutId);
|
|
30397
|
-
const entriesBySection =
|
|
30495
|
+
const entriesBySection = useMemo32(() => {
|
|
30398
30496
|
const sectionIds = layout?.sections.map((section) => section.id) ?? [];
|
|
30399
30497
|
const validSections = new Set(sectionIds);
|
|
30400
30498
|
const core = buildCoreEntries(extractSectionElements(sections));
|
|
@@ -30781,18 +30879,21 @@ export {
|
|
|
30781
30879
|
mergeLayoutPreferences,
|
|
30782
30880
|
mergeListFilters,
|
|
30783
30881
|
navOverridesFromPreferences,
|
|
30882
|
+
overrideLazyRoute,
|
|
30784
30883
|
permissionMapAllows,
|
|
30785
30884
|
plainTextToHtml,
|
|
30786
30885
|
productChangeViewHasContent,
|
|
30787
30886
|
queryClient,
|
|
30788
30887
|
queryKeysFactory,
|
|
30789
30888
|
refineAdditionalData,
|
|
30889
|
+
resolveBuiltInFieldDefault,
|
|
30790
30890
|
resolveFormFieldType,
|
|
30791
30891
|
resolveRouteOverrides,
|
|
30792
30892
|
richTextContentClasses,
|
|
30793
30893
|
sanitizeRichText,
|
|
30794
30894
|
toPermissionList,
|
|
30795
30895
|
useActionLocks,
|
|
30896
|
+
useBuiltInFieldDefaults,
|
|
30796
30897
|
useCan,
|
|
30797
30898
|
useCollapsedSidebar,
|
|
30798
30899
|
useCombinedRefs,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mercurjs/dashboard-shared",
|
|
3
|
-
"version": "2.4.1",
|
|
3
|
+
"version": "2.4.2-canary.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/mercurjs/mercur",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@medusajs/dashboard": "2.22.3",
|
|
35
35
|
"@medusajs/icons": "2.22.3",
|
|
36
36
|
"@medusajs/ui": "4.2.3",
|
|
37
|
-
"@mercurjs/client": "2.4.1",
|
|
37
|
+
"@mercurjs/client": "2.4.2-canary.1",
|
|
38
38
|
"@radix-ui/react-dialog": "1.1.19",
|
|
39
39
|
"@radix-ui/react-dismissable-layer": "1.1.4",
|
|
40
40
|
"@tanstack/react-query": "5.64.2",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@medusajs/types": "2.22.3",
|
|
73
|
-
"@mercurjs/core": "2.4.1",
|
|
74
|
-
"@mercurjs/dashboard-sdk": "2.4.1",
|
|
75
|
-
"@mercurjs/types": "2.4.1",
|
|
73
|
+
"@mercurjs/core": "2.4.2-canary.1",
|
|
74
|
+
"@mercurjs/dashboard-sdk": "2.4.2-canary.1",
|
|
75
|
+
"@mercurjs/types": "2.4.2-canary.1",
|
|
76
76
|
"@types/lodash.debounce": "^4.0.8",
|
|
77
77
|
"@types/react": "^18.3.2",
|
|
78
78
|
"@types/react-dom": "^18.2.22",
|