@mercurjs/dashboard-shared 2.3.4 → 2.3.5
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 +10 -2
- package/dist/index.js +68 -37
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { TFunction } from 'i18next';
|
|
|
17
17
|
import { ClientError } from '@mercurjs/client';
|
|
18
18
|
import * as react_currency_input_field from 'react-currency-input-field';
|
|
19
19
|
import * as _mercurjs_dashboard_sdk from '@mercurjs/dashboard-sdk';
|
|
20
|
-
import { PermissionsContextValue, UserPolicy, PermissionsRequirementsContextValue, Permission, PermissionResource, PermissionOperation, CustomFieldsConfig, NavItemOverride, CustomFormField, CustomDisplayField, SectionAction, CustomListExtension } from '@mercurjs/dashboard-sdk';
|
|
20
|
+
import { PermissionsContextValue, UserPolicy, PermissionsRequirementsContextValue, Permission, PermissionResource, PermissionOperation, CustomFieldsConfig, NavItemOverride, ActivityEntry, CustomFormField, CustomDisplayField, SectionAction, CustomListExtension } from '@mercurjs/dashboard-sdk';
|
|
21
21
|
|
|
22
22
|
type TQueryKey<TKey, TListQuery = any, TDetailQuery = string> = {
|
|
23
23
|
all: readonly [TKey];
|
|
@@ -1716,6 +1716,9 @@ declare class ExtensionRegistry {
|
|
|
1716
1716
|
private configsFor;
|
|
1717
1717
|
/** Distinct module links declared across a model's configs. */
|
|
1718
1718
|
getLinks(model: string): string[];
|
|
1719
|
+
/** First lock reason a config returns for an action on this entity. */
|
|
1720
|
+
getActionLock(model: string, action: string, entity: unknown): string | undefined;
|
|
1721
|
+
getActivity(model: string, entity: unknown): ActivityEntry[];
|
|
1719
1722
|
/** Custom form fields for a model's form zone (and optional tab). */
|
|
1720
1723
|
getFormFields(model: string, zone: string, tab?: string): ResolvedFormField[];
|
|
1721
1724
|
/** All custom form fields for a model, keyed for schema/default building. */
|
|
@@ -1966,6 +1969,11 @@ interface UseExtendableFormProps<TSchema extends ZodObject<Record<string, z.ZodT
|
|
|
1966
1969
|
*/
|
|
1967
1970
|
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>;
|
|
1968
1971
|
|
|
1972
|
+
/** Returns a lookup for the lock reason plugins declare on an entity's action. */
|
|
1973
|
+
declare const useActionLocks: (model: string, entity: unknown) => (action: string) => string | undefined;
|
|
1974
|
+
/** Timeline entries plugins contribute for an entity. */
|
|
1975
|
+
declare const useExtensionActivity: (model: string, entity: unknown) => _mercurjs_dashboard_sdk.ActivityEntry[];
|
|
1976
|
+
|
|
1969
1977
|
/**
|
|
1970
1978
|
* Re-implementation of enums from `@medusajs/medusa` as they cannot be imported
|
|
1971
1979
|
* directly. Shared by the admin and vendor price-list surfaces.
|
|
@@ -2054,4 +2062,4 @@ declare const extractPricesFromOffers: (offers: ExtractableOffers, regions: Http
|
|
|
2054
2062
|
variant_id: string;
|
|
2055
2063
|
}[];
|
|
2056
2064
|
|
|
2057
|
-
export { type Action, type ActionGroup, ActionMenu, AddressForm, AddressSchema, type AttributeChange, type AttributeChangeKind, AttributeValueInput, BadgeListSummary, 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, DisplayExtensionZone, type DisplayExtensionZoneProps, DisplayField, type DisplayFieldProps, DisplaySection, type DisplaySectionField, type DisplaySectionProps, type EditAttributeAttribute, EditAttributeForm, type EditAttributeFormProps, EmailCell, EmailForm, EmailHeader, EmailSchema, ErrorBoundary, type ExtendableTable, ExtensionProvider, type ExtensionProviderProps, ExtensionRegistry, type ExtractableOffer, type ExtractableOffers, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, FormExtensionZone, type FormExtensionZoneProps, GeneralSectionSkeleton, HandleInput, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, type ImageRef, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, KeyboundForm, LinkButton, ListBadge, ListSummary, Listicle, type ListicleProps, LocalizedTablePagination, type MediaDiff, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, type NavigationModule, NoRecords, type NoRecordsProps, NoResults, type NoResultsProps, OrderBy, PercentageInput, PermissionGuard, type PermissionGuardProps, type PermissionProps, PermissionsContext, PermissionsProvider, type PermissionsProviderProps, PermissionsRequirement, type PermissionsRequirementProps, PermissionsRequirementsContext, PermissionsRequirementsProvider, PlaceholderCell, 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, type ReferenceField, RequiredPermissionsSection, type ResolvedAttribute, type ResolvedDisplays, type ResolvedFormField, RouteDrawer, RouteFocusModal, RoutePermissionGuard, SectionRow, type SectionRowProps, SegmentedControl, type SegmentedControlOption, SidebarLink, type SidebarLinkProps, SingleColumnPage, SingleColumnPageSkeleton, Skeleton, SortableList, SortableTree, StackedDrawer, StackedFocusModal, type StaticCountry, StatusCell, SwitchBox, type TQueryKey, type TabDefinition, TabbedForm, TableFooterSkeleton, TableSectionSkeleton, TableSkeleton, TextCell, TextHeader, TextSkeleton, Thumbnail, TransferOwnershipSchema, TwoColumnPage, TwoColumnPageSkeleton, type UseExtendableFormProps, type UseExtendableTableProps, type UseQueryOptionsWrapper, type UseRegisterPermissionsOptions, type VariantGroup, VisuallyHidden, type Widget, type WidgetModule, type WidgetPlacement, WidgetZone, type WidgetZoneProps, type ZoneWidgets, _DataTable, applyNavOverrides, buildAdditionalDataDefaults, buildAdditionalDataSchema, buildOfferGridData, buildProductChangeView, countries, createDataGridHelper, createDataGridPriceColumns, createFormHelper, currencies, extractPricesFromOffers, extractReferenceIds, formatFieldValue, genericForwardRef, getCountryByIso2, getCurrencySymbol, getDecimalDigits, getExtensionRegistry, getFormattedAddress, getFormattedCountry, getLinkQuery, getLocaleAmount, getNativeSymbol, getPriceListStatus, getStylizedAmount, humanizeFieldName, isAmountLessThenRoundingError, isImageList, isOrderActionable, isOrderAwaitingAction, isPriceListGroupRow, isProductRow, isReferenceField, isSameAddress, linkFields, productChangeViewHasContent, queryClient, queryKeysFactory, resolvePermissionProps, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExtendableForm, useExtendableTable, useExtension, useLinkQuery, usePermissions, useQueryParams, useRegisterPermissions, useRequiredPermissions, useResourcePermissions, useRouteModal, useStackedModal, useTabManagement, useTabbedForm, withLinkFields };
|
|
2065
|
+
export { type Action, type ActionGroup, ActionMenu, AddressForm, AddressSchema, type AttributeChange, type AttributeChangeKind, AttributeValueInput, BadgeListSummary, 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, DisplayExtensionZone, type DisplayExtensionZoneProps, DisplayField, type DisplayFieldProps, DisplaySection, type DisplaySectionField, type DisplaySectionProps, type EditAttributeAttribute, EditAttributeForm, type EditAttributeFormProps, EmailCell, EmailForm, EmailHeader, EmailSchema, ErrorBoundary, type ExtendableTable, ExtensionProvider, type ExtensionProviderProps, ExtensionRegistry, type ExtractableOffer, type ExtractableOffers, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, FormExtensionZone, type FormExtensionZoneProps, GeneralSectionSkeleton, HandleInput, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, type ImageRef, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, KeyboundForm, LinkButton, ListBadge, ListSummary, Listicle, type ListicleProps, LocalizedTablePagination, type MediaDiff, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, type NavigationModule, NoRecords, type NoRecordsProps, NoResults, type NoResultsProps, OrderBy, PercentageInput, PermissionGuard, type PermissionGuardProps, type PermissionProps, PermissionsContext, PermissionsProvider, type PermissionsProviderProps, PermissionsRequirement, type PermissionsRequirementProps, PermissionsRequirementsContext, PermissionsRequirementsProvider, PlaceholderCell, 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, type ReferenceField, RequiredPermissionsSection, type ResolvedAttribute, type ResolvedDisplays, type ResolvedFormField, RouteDrawer, RouteFocusModal, RoutePermissionGuard, SectionRow, type SectionRowProps, SegmentedControl, type SegmentedControlOption, SidebarLink, type SidebarLinkProps, SingleColumnPage, SingleColumnPageSkeleton, Skeleton, SortableList, SortableTree, StackedDrawer, StackedFocusModal, type StaticCountry, StatusCell, SwitchBox, type TQueryKey, type TabDefinition, TabbedForm, TableFooterSkeleton, TableSectionSkeleton, TableSkeleton, TextCell, TextHeader, TextSkeleton, Thumbnail, TransferOwnershipSchema, TwoColumnPage, TwoColumnPageSkeleton, type UseExtendableFormProps, type UseExtendableTableProps, type UseQueryOptionsWrapper, type UseRegisterPermissionsOptions, type VariantGroup, VisuallyHidden, type Widget, type WidgetModule, type WidgetPlacement, WidgetZone, type WidgetZoneProps, type ZoneWidgets, _DataTable, applyNavOverrides, buildAdditionalDataDefaults, buildAdditionalDataSchema, buildOfferGridData, buildProductChangeView, countries, createDataGridHelper, createDataGridPriceColumns, createFormHelper, currencies, extractPricesFromOffers, extractReferenceIds, formatFieldValue, genericForwardRef, getCountryByIso2, getCurrencySymbol, getDecimalDigits, getExtensionRegistry, getFormattedAddress, getFormattedCountry, getLinkQuery, getLocaleAmount, getNativeSymbol, getPriceListStatus, getStylizedAmount, humanizeFieldName, isAmountLessThenRoundingError, isImageList, isOrderActionable, isOrderAwaitingAction, isPriceListGroupRow, isProductRow, isReferenceField, isSameAddress, linkFields, productChangeViewHasContent, queryClient, queryKeysFactory, resolvePermissionProps, useActionLocks, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExtendableForm, useExtendableTable, useExtension, useExtensionActivity, useLinkQuery, usePermissions, useQueryParams, useRegisterPermissions, useRequiredPermissions, useResourcePermissions, useRouteModal, useStackedModal, useTabManagement, useTabbedForm, withLinkFields };
|
package/dist/index.js
CHANGED
|
@@ -25103,6 +25103,18 @@ var ExtensionRegistry = class {
|
|
|
25103
25103
|
}
|
|
25104
25104
|
return [...links];
|
|
25105
25105
|
}
|
|
25106
|
+
/** First lock reason a config returns for an action on this entity. */
|
|
25107
|
+
getActionLock(model, action, entity) {
|
|
25108
|
+
for (const config3 of this.configsFor(model)) {
|
|
25109
|
+
const locks = config3.actionLocks;
|
|
25110
|
+
const reason = locks?.[action]?.(entity);
|
|
25111
|
+
if (reason) return reason;
|
|
25112
|
+
}
|
|
25113
|
+
return void 0;
|
|
25114
|
+
}
|
|
25115
|
+
getActivity(model, entity) {
|
|
25116
|
+
return this.configsFor(model).flatMap((c) => c.activity?.(entity) ?? []);
|
|
25117
|
+
}
|
|
25106
25118
|
/** Custom form fields for a model's form zone (and optional tab). */
|
|
25107
25119
|
getFormFields(model, zone, tab) {
|
|
25108
25120
|
const out = [];
|
|
@@ -25554,6 +25566,23 @@ var useExtendableForm = ({
|
|
|
25554
25566
|
});
|
|
25555
25567
|
};
|
|
25556
25568
|
|
|
25569
|
+
// src/extensions/action-locks.ts
|
|
25570
|
+
import { useCallback as useCallback21, useMemo as useMemo17 } from "react";
|
|
25571
|
+
var useActionLocks = (model, entity) => {
|
|
25572
|
+
const registry = useExtension();
|
|
25573
|
+
return useCallback21(
|
|
25574
|
+
(action) => registry.getActionLock(model, action, entity),
|
|
25575
|
+
[registry, model, entity]
|
|
25576
|
+
);
|
|
25577
|
+
};
|
|
25578
|
+
var useExtensionActivity = (model, entity) => {
|
|
25579
|
+
const registry = useExtension();
|
|
25580
|
+
return useMemo17(
|
|
25581
|
+
() => registry.getActivity(model, entity),
|
|
25582
|
+
[registry, model, entity]
|
|
25583
|
+
);
|
|
25584
|
+
};
|
|
25585
|
+
|
|
25557
25586
|
// src/components/sections/product-attribute-section/product-attribute-section.tsx
|
|
25558
25587
|
import { jsx as jsx81, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
25559
25588
|
var AttributeActions = ({
|
|
@@ -25782,17 +25811,17 @@ import {
|
|
|
25782
25811
|
Children as Children3,
|
|
25783
25812
|
createContext as createContext8,
|
|
25784
25813
|
useContext as useContext8,
|
|
25785
|
-
useMemo as
|
|
25814
|
+
useMemo as useMemo19
|
|
25786
25815
|
} from "react";
|
|
25787
25816
|
import { useTranslation as useTranslation31 } from "react-i18next";
|
|
25788
25817
|
|
|
25789
25818
|
// src/components/tabbed-form/use-tab-management.ts
|
|
25790
|
-
import { useCallback as
|
|
25819
|
+
import { useCallback as useCallback22, useEffect as useEffect18, useMemo as useMemo18, useState as useState28 } from "react";
|
|
25791
25820
|
var useTabManagement = ({
|
|
25792
25821
|
tabs,
|
|
25793
25822
|
form
|
|
25794
25823
|
}) => {
|
|
25795
|
-
const visibleTabs =
|
|
25824
|
+
const visibleTabs = useMemo18(
|
|
25796
25825
|
() => tabs.filter((t2) => !t2.isVisible || t2.isVisible(form)),
|
|
25797
25826
|
[tabs, form]
|
|
25798
25827
|
);
|
|
@@ -25822,7 +25851,7 @@ var useTabManagement = ({
|
|
|
25822
25851
|
}, [activeTabId, visibleTabs]);
|
|
25823
25852
|
const activeIndex = visibleTabs.findIndex((t2) => t2.id === activeTabId);
|
|
25824
25853
|
const isLastTab = activeIndex === visibleTabs.length - 1;
|
|
25825
|
-
const onNext =
|
|
25854
|
+
const onNext = useCallback22(async () => {
|
|
25826
25855
|
const valid = await form.trigger();
|
|
25827
25856
|
if (!valid) {
|
|
25828
25857
|
return;
|
|
@@ -25831,7 +25860,7 @@ var useTabManagement = ({
|
|
|
25831
25860
|
setActiveTabId(visibleTabs[activeIndex + 1].id);
|
|
25832
25861
|
}
|
|
25833
25862
|
}, [form, activeIndex, visibleTabs]);
|
|
25834
|
-
const onTabChange =
|
|
25863
|
+
const onTabChange = useCallback22(
|
|
25835
25864
|
async (tabId) => {
|
|
25836
25865
|
const valid = await form.trigger();
|
|
25837
25866
|
if (!valid) {
|
|
@@ -25901,11 +25930,11 @@ function Root6({
|
|
|
25901
25930
|
transformTabs
|
|
25902
25931
|
}) {
|
|
25903
25932
|
const { t: t2 } = useTranslation31();
|
|
25904
|
-
const { tabs: rawTabs, elements } =
|
|
25933
|
+
const { tabs: rawTabs, elements } = useMemo19(
|
|
25905
25934
|
() => collectTabs(children),
|
|
25906
25935
|
[children]
|
|
25907
25936
|
);
|
|
25908
|
-
const tabs =
|
|
25937
|
+
const tabs = useMemo19(
|
|
25909
25938
|
() => transformTabs ? transformTabs(rawTabs) : rawTabs,
|
|
25910
25939
|
[transformTabs, rawTabs]
|
|
25911
25940
|
);
|
|
@@ -26036,7 +26065,7 @@ import { memo } from "react";
|
|
|
26036
26065
|
// src/components/table/data-table/data-table-filter/data-table-filter.tsx
|
|
26037
26066
|
import { Button as Button11, clx as clx44 } from "@medusajs/ui";
|
|
26038
26067
|
import { Popover as RadixPopover7 } from "radix-ui";
|
|
26039
|
-
import { useCallback as
|
|
26068
|
+
import { useCallback as useCallback25, useEffect as useEffect21, useMemo as useMemo21, useRef as useRef15, useState as useState33 } from "react";
|
|
26040
26069
|
import { useSearchParams as useSearchParams7 } from "react-router-dom";
|
|
26041
26070
|
import { useTranslation as useTranslation36 } from "react-i18next";
|
|
26042
26071
|
|
|
@@ -26058,7 +26087,7 @@ import { EllipseMiniSolid as EllipseMiniSolid2 } from "@medusajs/icons";
|
|
|
26058
26087
|
import { DatePicker, Text as Text19, clx as clx40 } from "@medusajs/ui";
|
|
26059
26088
|
import isEqual from "lodash.isequal";
|
|
26060
26089
|
import { Popover as RadixPopover3 } from "radix-ui";
|
|
26061
|
-
import { useMemo as
|
|
26090
|
+
import { useMemo as useMemo20, useState as useState29 } from "react";
|
|
26062
26091
|
import { t } from "i18next";
|
|
26063
26092
|
import { useTranslation as useTranslation33 } from "react-i18next";
|
|
26064
26093
|
|
|
@@ -26407,7 +26436,7 @@ var today = /* @__PURE__ */ new Date();
|
|
|
26407
26436
|
today.setHours(0, 0, 0, 0);
|
|
26408
26437
|
var usePresets = () => {
|
|
26409
26438
|
const { t: t2 } = useTranslation33();
|
|
26410
|
-
return
|
|
26439
|
+
return useMemo20(
|
|
26411
26440
|
() => [
|
|
26412
26441
|
{
|
|
26413
26442
|
label: t2("filters.date.today"),
|
|
@@ -26477,7 +26506,7 @@ import {
|
|
|
26477
26506
|
Popover as RadixPopover4,
|
|
26478
26507
|
RadioGroup as RadixRadioGroup
|
|
26479
26508
|
} from "radix-ui";
|
|
26480
|
-
import { useCallback as
|
|
26509
|
+
import { useCallback as useCallback23, useEffect as useEffect19, useState as useState30 } from "react";
|
|
26481
26510
|
import { useTranslation as useTranslation34 } from "react-i18next";
|
|
26482
26511
|
import { jsx as jsx85, jsxs as jsxs60 } from "react/jsx-runtime";
|
|
26483
26512
|
var NumberFilter = ({
|
|
@@ -26502,7 +26531,7 @@ var NumberFilter = ({
|
|
|
26502
26531
|
const [operator, setOperator] = useState30(
|
|
26503
26532
|
getOperator(currentValue)
|
|
26504
26533
|
);
|
|
26505
|
-
const debouncedOnChange =
|
|
26534
|
+
const debouncedOnChange = useCallback23(
|
|
26506
26535
|
debounce2((e, operator2) => {
|
|
26507
26536
|
const value = e.target.value;
|
|
26508
26537
|
const curr = JSON.parse(currentValue?.join(",") || "{}");
|
|
@@ -26872,7 +26901,7 @@ var SelectFilter = ({
|
|
|
26872
26901
|
import { Input as Input11, Label as Label5, clx as clx43 } from "@medusajs/ui";
|
|
26873
26902
|
import debounce3 from "lodash.debounce";
|
|
26874
26903
|
import { Popover as RadixPopover6 } from "radix-ui";
|
|
26875
|
-
import { useCallback as
|
|
26904
|
+
import { useCallback as useCallback24, useEffect as useEffect20, useState as useState32 } from "react";
|
|
26876
26905
|
import { jsx as jsx87, jsxs as jsxs62 } from "react/jsx-runtime";
|
|
26877
26906
|
var StringFilter = ({
|
|
26878
26907
|
filter,
|
|
@@ -26888,7 +26917,7 @@ var StringFilter = ({
|
|
|
26888
26917
|
const [previousValue, setPreviousValue] = useState32(
|
|
26889
26918
|
query?.[0]
|
|
26890
26919
|
);
|
|
26891
|
-
const debouncedOnChange =
|
|
26920
|
+
const debouncedOnChange = useCallback24(
|
|
26892
26921
|
debounce3((e) => {
|
|
26893
26922
|
const value = e.target.value;
|
|
26894
26923
|
if (!value) {
|
|
@@ -27017,16 +27046,16 @@ var DataTableFilter2 = ({
|
|
|
27017
27046
|
setOpen(false);
|
|
27018
27047
|
setActiveFilters((prev) => [...prev, { ...filter, openOnMount: true }]);
|
|
27019
27048
|
};
|
|
27020
|
-
const removeFilter =
|
|
27049
|
+
const removeFilter = useCallback25((key) => {
|
|
27021
27050
|
setActiveFilters((prev) => prev.filter((f) => f.key !== key));
|
|
27022
27051
|
}, []);
|
|
27023
|
-
const removeAllFilters =
|
|
27052
|
+
const removeAllFilters = useCallback25(() => {
|
|
27024
27053
|
setActiveFilters([]);
|
|
27025
27054
|
}, []);
|
|
27026
27055
|
return /* @__PURE__ */ jsx88(
|
|
27027
27056
|
DataTableFilterContext.Provider,
|
|
27028
27057
|
{
|
|
27029
|
-
value:
|
|
27058
|
+
value: useMemo21(
|
|
27030
27059
|
() => ({
|
|
27031
27060
|
removeFilter,
|
|
27032
27061
|
removeAllFilters
|
|
@@ -27313,7 +27342,7 @@ var DataTableOrderBy = ({
|
|
|
27313
27342
|
|
|
27314
27343
|
// src/components/table/data-table/data-table-search/data-table-search.tsx
|
|
27315
27344
|
import { Input as Input12 } from "@medusajs/ui";
|
|
27316
|
-
import { useCallback as
|
|
27345
|
+
import { useCallback as useCallback26, useEffect as useEffect22 } from "react";
|
|
27317
27346
|
import { useTranslation as useTranslation38 } from "react-i18next";
|
|
27318
27347
|
import debounce4 from "lodash.debounce";
|
|
27319
27348
|
import { jsx as jsx90 } from "react/jsx-runtime";
|
|
@@ -27330,7 +27359,7 @@ var DataTableSearch = ({
|
|
|
27330
27359
|
multiple: false
|
|
27331
27360
|
});
|
|
27332
27361
|
const query = selectedParams.get();
|
|
27333
|
-
const debouncedOnChange =
|
|
27362
|
+
const debouncedOnChange = useCallback26(
|
|
27334
27363
|
debounce4((e) => {
|
|
27335
27364
|
const value = e.target.value;
|
|
27336
27365
|
if (!value) {
|
|
@@ -27982,7 +28011,7 @@ import {
|
|
|
27982
28011
|
getPaginationRowModel,
|
|
27983
28012
|
useReactTable as useReactTable2
|
|
27984
28013
|
} from "@tanstack/react-table";
|
|
27985
|
-
import { useEffect as useEffect24, useMemo as
|
|
28014
|
+
import { useEffect as useEffect24, useMemo as useMemo22, useState as useState36 } from "react";
|
|
27986
28015
|
import { useSearchParams as useSearchParams9 } from "react-router-dom";
|
|
27987
28016
|
var useDataTable2 = ({
|
|
27988
28017
|
data = [],
|
|
@@ -28005,7 +28034,7 @@ var useDataTable2 = ({
|
|
|
28005
28034
|
pageIndex: offset ? Math.ceil(Number(offset) / _pageSize) : 0,
|
|
28006
28035
|
pageSize: _pageSize
|
|
28007
28036
|
});
|
|
28008
|
-
const pagination =
|
|
28037
|
+
const pagination = useMemo22(
|
|
28009
28038
|
() => ({
|
|
28010
28039
|
pageIndex,
|
|
28011
28040
|
pageSize
|
|
@@ -28073,7 +28102,7 @@ var PermissionsContext = createContext10(
|
|
|
28073
28102
|
);
|
|
28074
28103
|
|
|
28075
28104
|
// src/permissions/permissions-provider.tsx
|
|
28076
|
-
import { useCallback as
|
|
28105
|
+
import { useCallback as useCallback27, useMemo as useMemo23 } from "react";
|
|
28077
28106
|
|
|
28078
28107
|
// ../dashboard-sdk/dist/index.js
|
|
28079
28108
|
var OPERATION_IMPLICATIONS = {
|
|
@@ -28106,7 +28135,7 @@ var PermissionsProvider = ({
|
|
|
28106
28135
|
isRbacEnabled = true,
|
|
28107
28136
|
children
|
|
28108
28137
|
}) => {
|
|
28109
|
-
const permissionsMap =
|
|
28138
|
+
const permissionsMap = useMemo23(() => {
|
|
28110
28139
|
const index = /* @__PURE__ */ Object.create(null);
|
|
28111
28140
|
for (const granted of policy?.permissions ?? []) {
|
|
28112
28141
|
const parsed = parsePermission(granted);
|
|
@@ -28121,7 +28150,7 @@ var PermissionsProvider = ({
|
|
|
28121
28150
|
}
|
|
28122
28151
|
return index;
|
|
28123
28152
|
}, [policy]);
|
|
28124
|
-
const hasPermission =
|
|
28153
|
+
const hasPermission = useCallback27(
|
|
28125
28154
|
(permission) => {
|
|
28126
28155
|
if (!isRbacEnabled) {
|
|
28127
28156
|
return true;
|
|
@@ -28130,7 +28159,7 @@ var PermissionsProvider = ({
|
|
|
28130
28159
|
},
|
|
28131
28160
|
[isRbacEnabled, permissionsMap]
|
|
28132
28161
|
);
|
|
28133
|
-
const hasAnyPermission =
|
|
28162
|
+
const hasAnyPermission = useCallback27(
|
|
28134
28163
|
(permissions) => {
|
|
28135
28164
|
if (!isRbacEnabled) {
|
|
28136
28165
|
return true;
|
|
@@ -28142,7 +28171,7 @@ var PermissionsProvider = ({
|
|
|
28142
28171
|
},
|
|
28143
28172
|
[isRbacEnabled, hasPermission]
|
|
28144
28173
|
);
|
|
28145
|
-
const hasAllPermissions =
|
|
28174
|
+
const hasAllPermissions = useCallback27(
|
|
28146
28175
|
(permissions) => {
|
|
28147
28176
|
if (!isRbacEnabled) {
|
|
28148
28177
|
return true;
|
|
@@ -28154,7 +28183,7 @@ var PermissionsProvider = ({
|
|
|
28154
28183
|
},
|
|
28155
28184
|
[isRbacEnabled, hasPermission]
|
|
28156
28185
|
);
|
|
28157
|
-
const can =
|
|
28186
|
+
const can = useCallback27(
|
|
28158
28187
|
(resource, operation) => {
|
|
28159
28188
|
if (!isRbacEnabled) {
|
|
28160
28189
|
return true;
|
|
@@ -28163,7 +28192,7 @@ var PermissionsProvider = ({
|
|
|
28163
28192
|
},
|
|
28164
28193
|
[isRbacEnabled, permissionsMap]
|
|
28165
28194
|
);
|
|
28166
|
-
const value =
|
|
28195
|
+
const value = useMemo23(
|
|
28167
28196
|
() => ({
|
|
28168
28197
|
policy,
|
|
28169
28198
|
isLoading,
|
|
@@ -28191,26 +28220,26 @@ import { createContext as createContext11 } from "react";
|
|
|
28191
28220
|
var PermissionsRequirementsContext = createContext11(null);
|
|
28192
28221
|
|
|
28193
28222
|
// src/permissions/permissions-requirements-provider.tsx
|
|
28194
|
-
import { useCallback as
|
|
28223
|
+
import { useCallback as useCallback28, useMemo as useMemo24, useState as useState37 } from "react";
|
|
28195
28224
|
import { jsx as jsx106 } from "react/jsx-runtime";
|
|
28196
28225
|
var PermissionsRequirementsProvider = ({
|
|
28197
28226
|
children
|
|
28198
28227
|
}) => {
|
|
28199
28228
|
const [requirements, setRequirements] = useState37({});
|
|
28200
|
-
const registerRequiredPermissions =
|
|
28229
|
+
const registerRequiredPermissions = useCallback28(
|
|
28201
28230
|
(id, requirement) => {
|
|
28202
28231
|
setRequirements((prevState) => ({ ...prevState, [id]: requirement }));
|
|
28203
28232
|
},
|
|
28204
28233
|
[]
|
|
28205
28234
|
);
|
|
28206
|
-
const unregisterRequiredPermissions =
|
|
28235
|
+
const unregisterRequiredPermissions = useCallback28((id) => {
|
|
28207
28236
|
setRequirements((prevState) => {
|
|
28208
28237
|
const newState = { ...prevState };
|
|
28209
28238
|
delete newState[id];
|
|
28210
28239
|
return newState;
|
|
28211
28240
|
});
|
|
28212
28241
|
}, []);
|
|
28213
|
-
const requiredPermissions =
|
|
28242
|
+
const requiredPermissions = useMemo24(() => {
|
|
28214
28243
|
const deduped = [];
|
|
28215
28244
|
const seen = /* @__PURE__ */ new Set();
|
|
28216
28245
|
for (const requirement of Object.values(requirements)) {
|
|
@@ -28230,7 +28259,7 @@ var PermissionsRequirementsProvider = ({
|
|
|
28230
28259
|
}
|
|
28231
28260
|
return deduped;
|
|
28232
28261
|
}, [requirements]);
|
|
28233
|
-
const value =
|
|
28262
|
+
const value = useMemo24(
|
|
28234
28263
|
() => ({
|
|
28235
28264
|
requiredPermissions,
|
|
28236
28265
|
registerRequiredPermissions,
|
|
@@ -28353,7 +28382,7 @@ var PermissionGuard = ({
|
|
|
28353
28382
|
// src/permissions/route-permission-guard.tsx
|
|
28354
28383
|
import { ExclamationCircle as ExclamationCircle5 } from "@medusajs/icons";
|
|
28355
28384
|
import { Container as Container6, Heading as Heading10, Text as Text21 } from "@medusajs/ui";
|
|
28356
|
-
import { useMemo as
|
|
28385
|
+
import { useMemo as useMemo25 } from "react";
|
|
28357
28386
|
import { useTranslation as useTranslation45 } from "react-i18next";
|
|
28358
28387
|
import { Navigate as Navigate2, Outlet as Outlet3, useMatches } from "react-router-dom";
|
|
28359
28388
|
import { jsx as jsx109, jsxs as jsxs70 } from "react/jsx-runtime";
|
|
@@ -28386,7 +28415,7 @@ var readRequirementFromHandle = (handle) => {
|
|
|
28386
28415
|
var RoutePermissionGuard = () => {
|
|
28387
28416
|
const matches = useMatches();
|
|
28388
28417
|
const { hasAnyPermission, hasAllPermissions, isLoading } = usePermissions();
|
|
28389
|
-
const requirement =
|
|
28418
|
+
const requirement = useMemo25(() => {
|
|
28390
28419
|
for (let i = matches.length - 1; i >= 0; i--) {
|
|
28391
28420
|
const found = readRequirementFromHandle(matches[i].handle);
|
|
28392
28421
|
if (found) {
|
|
@@ -28476,10 +28505,10 @@ var RequiredPermissionsSection = () => {
|
|
|
28476
28505
|
};
|
|
28477
28506
|
|
|
28478
28507
|
// src/permissions/use-resource-permissions.tsx
|
|
28479
|
-
import { useMemo as
|
|
28508
|
+
import { useMemo as useMemo26 } from "react";
|
|
28480
28509
|
var useResourcePermissions = (resource) => {
|
|
28481
28510
|
const { can, isLoading } = usePermissions();
|
|
28482
|
-
return
|
|
28511
|
+
return useMemo26(
|
|
28483
28512
|
() => ({
|
|
28484
28513
|
canRead: can(resource, "read"),
|
|
28485
28514
|
canCreate: can(resource, "create"),
|
|
@@ -28798,6 +28827,7 @@ export {
|
|
|
28798
28827
|
queryClient,
|
|
28799
28828
|
queryKeysFactory,
|
|
28800
28829
|
resolvePermissionProps,
|
|
28830
|
+
useActionLocks,
|
|
28801
28831
|
useCombinedRefs,
|
|
28802
28832
|
useCommandHistory,
|
|
28803
28833
|
useDataTable2 as useDataTable,
|
|
@@ -28807,6 +28837,7 @@ export {
|
|
|
28807
28837
|
useExtendableForm,
|
|
28808
28838
|
useExtendableTable,
|
|
28809
28839
|
useExtension,
|
|
28840
|
+
useExtensionActivity,
|
|
28810
28841
|
useLinkQuery,
|
|
28811
28842
|
usePermissions,
|
|
28812
28843
|
useQueryParams,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mercurjs/dashboard-shared",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
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.3.
|
|
26
|
+
"@mercurjs/client": "2.3.5",
|
|
27
27
|
"@ariakit/react": "^0.4.15",
|
|
28
28
|
"@babel/runtime": "^8.0.0",
|
|
29
29
|
"@dnd-kit/core": "^6.1.0",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@medusajs/types": "2.20.1",
|
|
66
|
-
"@mercurjs/core": "2.3.
|
|
67
|
-
"@mercurjs/dashboard-sdk": "2.3.
|
|
68
|
-
"@mercurjs/types": "2.3.
|
|
66
|
+
"@mercurjs/core": "2.3.5",
|
|
67
|
+
"@mercurjs/dashboard-sdk": "2.3.5",
|
|
68
|
+
"@mercurjs/types": "2.3.5",
|
|
69
69
|
"@types/lodash.debounce": "^4.0.8",
|
|
70
70
|
"@types/react": "^18.3.2",
|
|
71
71
|
"@types/react-dom": "^18.2.22",
|