@mercurjs/dashboard-shared 2.3.6-canary.2 → 2.3.6-canary.4
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 +79 -95
- package/dist/index.js +2345 -1813
- package/package.json +15 -8
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,
|
|
20
|
+
import { PermissionsContextValue, PermissionMap, Permission, PermissionKey, 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];
|
|
@@ -524,6 +524,18 @@ type ProductChangePanelProps = {
|
|
|
524
524
|
};
|
|
525
525
|
declare const ProductChangePanel: ({ product, actions, resolvers, headerDescription, footer, }: ProductChangePanelProps) => react_jsx_runtime.JSX.Element | null;
|
|
526
526
|
|
|
527
|
+
type RichTextProps = {
|
|
528
|
+
html?: string | null;
|
|
529
|
+
className?: string;
|
|
530
|
+
fallback?: string;
|
|
531
|
+
collapsedHeight?: number;
|
|
532
|
+
"data-testid"?: string;
|
|
533
|
+
};
|
|
534
|
+
declare const sanitizeRichText: (html: string) => string;
|
|
535
|
+
declare const RichText: ({ html, className, fallback, collapsedHeight, "data-testid": dataTestId, }: RichTextProps) => react_jsx_runtime.JSX.Element;
|
|
536
|
+
|
|
537
|
+
declare const richTextContentClasses: string;
|
|
538
|
+
|
|
527
539
|
interface ProgressBarProps {
|
|
528
540
|
/**
|
|
529
541
|
* The duration of the animation in seconds.
|
|
@@ -1056,6 +1068,27 @@ type ProvinceSelectProps = ComponentPropsWithoutRef<typeof Select> & {
|
|
|
1056
1068
|
};
|
|
1057
1069
|
declare const ProvinceSelect: ComponentType<ProvinceSelectProps>;
|
|
1058
1070
|
|
|
1071
|
+
type RichTextEditorProps = Omit<ComponentPropsWithoutRef<"div">, "onChange" | "onBlur" | "defaultValue"> & {
|
|
1072
|
+
value?: string | null;
|
|
1073
|
+
onChange?: (value: string) => void;
|
|
1074
|
+
onBlur?: () => void;
|
|
1075
|
+
name?: string;
|
|
1076
|
+
disabled?: boolean;
|
|
1077
|
+
placeholder?: string;
|
|
1078
|
+
onUpload?: (file: File) => Promise<string>;
|
|
1079
|
+
contentClassName?: string;
|
|
1080
|
+
};
|
|
1081
|
+
declare const RichTextEditor: React$1.ForwardRefExoticComponent<Omit<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onBlur" | "onChange"> & {
|
|
1082
|
+
value?: string | null;
|
|
1083
|
+
onChange?: (value: string) => void;
|
|
1084
|
+
onBlur?: () => void;
|
|
1085
|
+
name?: string;
|
|
1086
|
+
disabled?: boolean;
|
|
1087
|
+
placeholder?: string;
|
|
1088
|
+
onUpload?: (file: File) => Promise<string>;
|
|
1089
|
+
contentClassName?: string;
|
|
1090
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1091
|
+
|
|
1059
1092
|
interface PageProps<TData> {
|
|
1060
1093
|
children: ReactNode;
|
|
1061
1094
|
data?: TData;
|
|
@@ -1482,82 +1515,32 @@ declare function useQueryParams<T extends string>(keys: T[], prefix?: string): Q
|
|
|
1482
1515
|
declare const PermissionsContext: React$1.Context<PermissionsContextValue | null>;
|
|
1483
1516
|
|
|
1484
1517
|
interface PermissionsProviderProps extends PropsWithChildren {
|
|
1485
|
-
policy: UserPolicy | null;
|
|
1486
|
-
isLoading?: boolean;
|
|
1487
1518
|
/**
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1519
|
+
* The actor's effective rights, read from `fields=+permissions`. Leave it
|
|
1520
|
+
* `null`/`undefined` when the API returned no `permissions` field: nothing is
|
|
1521
|
+
* being enforced, so every check passes.
|
|
1490
1522
|
*/
|
|
1491
|
-
|
|
1523
|
+
permissions?: PermissionMap | null;
|
|
1524
|
+
isLoading?: boolean;
|
|
1492
1525
|
}
|
|
1493
|
-
declare const PermissionsProvider: ({
|
|
1494
|
-
|
|
1495
|
-
declare const PermissionsRequirementsContext: React$1.Context<PermissionsRequirementsContextValue | null>;
|
|
1526
|
+
declare const PermissionsProvider: ({ permissions, isLoading, children, }: PermissionsProviderProps) => react_jsx_runtime.JSX.Element;
|
|
1496
1527
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
* page body; guards work fine without it.
|
|
1501
|
-
*/
|
|
1502
|
-
declare const PermissionsRequirementsProvider: ({ children, }: PropsWithChildren) => react_jsx_runtime.JSX.Element;
|
|
1503
|
-
|
|
1504
|
-
interface BasePermissionProps {
|
|
1505
|
-
source?: string;
|
|
1506
|
-
enabled?: boolean;
|
|
1507
|
-
}
|
|
1508
|
-
interface WithPermission extends BasePermissionProps {
|
|
1509
|
-
permission: Permission;
|
|
1510
|
-
permissions?: never;
|
|
1511
|
-
resource?: never;
|
|
1512
|
-
operation?: never;
|
|
1513
|
-
requireAll?: never;
|
|
1514
|
-
}
|
|
1515
|
-
interface WithPermissions extends BasePermissionProps {
|
|
1516
|
-
permissions: Permission[];
|
|
1517
|
-
/** If true, ALL permissions are required. Defaults to ANY. */
|
|
1528
|
+
type PermissionGuardProps = PropsWithChildren<{
|
|
1529
|
+
permission: Permission | Permission[];
|
|
1530
|
+
/** When several permissions are given, require all of them. Defaults to any. */
|
|
1518
1531
|
requireAll?: boolean;
|
|
1519
|
-
permission?: never;
|
|
1520
|
-
resource?: never;
|
|
1521
|
-
operation?: never;
|
|
1522
|
-
}
|
|
1523
|
-
interface WithResourceOperation extends BasePermissionProps {
|
|
1524
|
-
resource: PermissionResource;
|
|
1525
|
-
operation: PermissionOperation;
|
|
1526
|
-
permission?: never;
|
|
1527
|
-
permissions?: never;
|
|
1528
|
-
requireAll?: never;
|
|
1529
|
-
}
|
|
1530
|
-
type PermissionProps = WithPermission | WithPermissions | WithResourceOperation;
|
|
1531
|
-
declare const resolvePermissionProps: (props: PermissionProps) => {
|
|
1532
|
-
permissions: Permission[] | null;
|
|
1533
|
-
requireAll: boolean;
|
|
1534
|
-
};
|
|
1535
|
-
|
|
1536
|
-
type PermissionsRequirementProps = PropsWithChildren<PermissionProps>;
|
|
1537
|
-
/**
|
|
1538
|
-
* Declares a permission requirement for the surrounding subtree without
|
|
1539
|
-
* gating it. Use `PermissionGuard` when the children should be hidden.
|
|
1540
|
-
*/
|
|
1541
|
-
declare const PermissionsRequirement: ({ children, source, enabled, ...props }: PermissionsRequirementProps) => react_jsx_runtime.JSX.Element;
|
|
1542
|
-
|
|
1543
|
-
type PermissionGuardProps = PropsWithChildren<PermissionProps & {
|
|
1544
1532
|
/** Rendered when access is denied. Nothing renders when omitted. */
|
|
1545
1533
|
fallback?: ReactNode;
|
|
1546
|
-
showLoading?: boolean;
|
|
1547
|
-
loadingComponent?: ReactNode;
|
|
1548
1534
|
}>;
|
|
1549
1535
|
/**
|
|
1550
|
-
* Hides its children unless the actor holds the declared permission, and
|
|
1551
|
-
* registers the requirement so the page can surface what is missing.
|
|
1552
|
-
*
|
|
1553
1536
|
* @example
|
|
1554
1537
|
* ```tsx
|
|
1555
|
-
* <PermissionGuard
|
|
1538
|
+
* <PermissionGuard permission="products:edit">
|
|
1556
1539
|
* <Button>Create</Button>
|
|
1557
1540
|
* </PermissionGuard>
|
|
1558
1541
|
* ```
|
|
1559
1542
|
*/
|
|
1560
|
-
declare const PermissionGuard: ({ children,
|
|
1543
|
+
declare const PermissionGuard: ({ children, permission, requireAll, fallback, }: PermissionGuardProps) => react_jsx_runtime.JSX.Element;
|
|
1561
1544
|
|
|
1562
1545
|
/**
|
|
1563
1546
|
* Route-level guard. Mount as a route's `element` and declare the requirement
|
|
@@ -1569,58 +1552,35 @@ declare const PermissionGuard: ({ children, fallback, showLoading, loadingCompon
|
|
|
1569
1552
|
* {
|
|
1570
1553
|
* path: "roles",
|
|
1571
1554
|
* element: <RoutePermissionGuard />,
|
|
1572
|
-
* handle: { permissions: "
|
|
1555
|
+
* handle: { permissions: "roles:view" },
|
|
1573
1556
|
* children: [...],
|
|
1574
1557
|
* }
|
|
1575
1558
|
* ```
|
|
1576
1559
|
*/
|
|
1577
1560
|
declare const RoutePermissionGuard: () => react_jsx_runtime.JSX.Element;
|
|
1578
1561
|
|
|
1579
|
-
/**
|
|
1580
|
-
* Renders the requirements that descendant guards registered with the nearest
|
|
1581
|
-
* `PermissionsRequirementsProvider`. Renders nothing when RBAC is off.
|
|
1582
|
-
*/
|
|
1583
|
-
declare const RequiredPermissionsSection: () => react_jsx_runtime.JSX.Element | null;
|
|
1584
|
-
|
|
1585
1562
|
/**
|
|
1586
1563
|
* @example
|
|
1587
1564
|
* ```tsx
|
|
1588
1565
|
* const { can, hasPermission } = usePermissions()
|
|
1589
1566
|
*
|
|
1590
|
-
* if (can("
|
|
1591
|
-
* if (hasPermission("
|
|
1567
|
+
* if (can("customers", "edit")) { ... }
|
|
1568
|
+
* if (hasPermission("customers:view")) { ... }
|
|
1592
1569
|
* ```
|
|
1593
1570
|
*/
|
|
1594
1571
|
declare const usePermissions: () => _mercurjs_dashboard_sdk.PermissionsContextValue;
|
|
1595
1572
|
|
|
1596
|
-
interface UseRegisterPermissionsOptions {
|
|
1597
|
-
/** If true, ALL permissions are required. Defaults to ANY. */
|
|
1598
|
-
requireAll?: boolean;
|
|
1599
|
-
source?: string;
|
|
1600
|
-
enabled?: boolean;
|
|
1601
|
-
}
|
|
1602
|
-
/**
|
|
1603
|
-
* Declares what the calling subtree needs. No-ops when there is no
|
|
1604
|
-
* `PermissionsRequirementsProvider` above it.
|
|
1605
|
-
*/
|
|
1606
|
-
declare const useRegisterPermissions: (permissions: Permission[] | null | undefined, options?: UseRegisterPermissionsOptions) => void;
|
|
1607
|
-
|
|
1608
|
-
declare const useRequiredPermissions: () => _mercurjs_dashboard_sdk.PermissionRequirement[];
|
|
1609
|
-
|
|
1610
1573
|
/**
|
|
1611
1574
|
* @example
|
|
1612
1575
|
* ```tsx
|
|
1613
|
-
* const {
|
|
1614
|
-
* {canCreate && <Button>Create</Button>}
|
|
1576
|
+
* const { canEdit } = useResourcePermissions("products")
|
|
1615
1577
|
* ```
|
|
1616
1578
|
*/
|
|
1617
|
-
declare const useResourcePermissions: (
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
can: (operation: "read" | "create" | "update" | "delete") => boolean;
|
|
1623
|
-
resource: PermissionResource;
|
|
1579
|
+
declare const useResourcePermissions: (key: PermissionKey) => {
|
|
1580
|
+
canView: boolean;
|
|
1581
|
+
canEdit: boolean;
|
|
1582
|
+
canManage: boolean;
|
|
1583
|
+
key: PermissionKey;
|
|
1624
1584
|
isLoading: boolean;
|
|
1625
1585
|
};
|
|
1626
1586
|
|
|
@@ -1631,6 +1591,11 @@ declare const useResourcePermissions: (resource: PermissionResource) => {
|
|
|
1631
1591
|
* it is never caught mid-fade by the clip.
|
|
1632
1592
|
*/
|
|
1633
1593
|
declare const SIDEBAR_RAIL_FADE: string;
|
|
1594
|
+
/**
|
|
1595
|
+
* Sidebar dropdowns take the trigger's width, which in the icon rail is only
|
|
1596
|
+
* the avatar — the floor keeps them readable when opened from the rail.
|
|
1597
|
+
*/
|
|
1598
|
+
declare const SIDEBAR_MENU_CONTENT = "w-[var(--radix-dropdown-menu-trigger-width)] min-w-[196px]";
|
|
1634
1599
|
|
|
1635
1600
|
type SidebarState = "expanded" | "collapsed";
|
|
1636
1601
|
type SidebarContextValue = {
|
|
@@ -1656,9 +1621,23 @@ declare const SidebarProvider: ({ children }: PropsWithChildren) => react_jsx_ru
|
|
|
1656
1621
|
* horizontal space but should not permanently change the user's preference.
|
|
1657
1622
|
*/
|
|
1658
1623
|
declare const useCollapsedSidebar: (collapsed?: boolean) => void;
|
|
1624
|
+
/**
|
|
1625
|
+
* Opens the desktop sidebar on mount and restores the previous state on
|
|
1626
|
+
* unmount. For sidebars without an icon rail, where arriving collapsed would
|
|
1627
|
+
* leave nothing to navigate with.
|
|
1628
|
+
*/
|
|
1629
|
+
declare const useExpandedSidebar: (expanded?: boolean) => void;
|
|
1659
1630
|
|
|
1660
1631
|
declare const useSidebar: () => SidebarContextValue;
|
|
1661
1632
|
|
|
1633
|
+
declare const useSidebarMenuPlacement: (align: "start" | "end") => {
|
|
1634
|
+
side: "right";
|
|
1635
|
+
align: "end" | "start";
|
|
1636
|
+
} | {
|
|
1637
|
+
side?: undefined;
|
|
1638
|
+
align?: undefined;
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1662
1641
|
type WidgetPlacement = "before" | "after";
|
|
1663
1642
|
type Widget = {
|
|
1664
1643
|
Component: ComponentType<{
|
|
@@ -2053,4 +2032,9 @@ declare const extractPricesFromOffers: (offers: ExtractableOffers, regions: Http
|
|
|
2053
2032
|
variant_id: string;
|
|
2054
2033
|
}[];
|
|
2055
2034
|
|
|
2056
|
-
|
|
2035
|
+
declare const RICH_TEXT_ALLOWED_TAGS: string[];
|
|
2036
|
+
declare const RICH_TEXT_ALLOWED_ATTRIBUTES: string[];
|
|
2037
|
+
declare const isHtml: (value?: string | null) => boolean;
|
|
2038
|
+
declare const plainTextToHtml: (value?: string | null) => string;
|
|
2039
|
+
|
|
2040
|
+
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, PermissionsContext, PermissionsProvider, type PermissionsProviderProps, 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, RICH_TEXT_ALLOWED_ATTRIBUTES, RICH_TEXT_ALLOWED_TAGS, type ReferenceField, type ResolvedAttribute, type ResolvedDisplays, type ResolvedFormField, RichText, RichTextEditor, type RichTextEditorProps, RouteDrawer, RouteFocusModal, RoutePermissionGuard, SIDEBAR_MENU_CONTENT, SIDEBAR_RAIL_FADE, SectionRow, type SectionRowProps, SegmentedControl, type SegmentedControlOption, SidebarContext, type SidebarContextValue, SidebarLink, type SidebarLinkProps, SidebarProvider, type SidebarState, 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 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, isHtml, isImageList, isOrderActionable, isOrderAwaitingAction, isPriceListGroupRow, isProductRow, isReferenceField, isSameAddress, linkFields, plainTextToHtml, productChangeViewHasContent, queryClient, queryKeysFactory, richTextContentClasses, sanitizeRichText, useActionLocks, useCollapsedSidebar, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExpandedSidebar, useExtendableForm, useExtendableTable, useExtension, useExtensionActivity, useLinkQuery, usePermissions, useQueryParams, useResourcePermissions, useRouteModal, useSidebar, useSidebarMenuPlacement, useStackedModal, useTabManagement, useTabbedForm, withLinkFields };
|