@mercurjs/dashboard-shared 2.3.6-canary.0 → 2.3.6-canary.10
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 +329 -98
- package/dist/index.js +4119 -3190
- package/package.json +19 -12
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { ProductChangeActionDTO, HttpTypes as HttpTypes$1, AttributeType, Produc
|
|
|
3
3
|
import { HttpTypes, AdminOrder } from '@medusajs/types';
|
|
4
4
|
import { z, ZodObject } from 'zod';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
import * as _mercurjs_dashboard_sdk from '@mercurjs/dashboard-sdk';
|
|
7
|
+
import { Permission, PermissionsContextValue, PermissionMap, PermissionKey, PermissionRight, CustomFieldsConfig, NavGroupConfig, NavItemOverride, ActivityEntry, CustomFormField, CustomDisplayField, SectionAction, CustomListExtension } from '@mercurjs/dashboard-sdk';
|
|
6
8
|
import * as React$1 from 'react';
|
|
7
|
-
import React__default, { ReactNode, PropsWithChildren, ComponentPropsWithoutRef, CSSProperties, ComponentType, ComponentProps, ForwardRefExoticComponent, Ref, RefAttributes, RefCallback } from 'react';
|
|
9
|
+
import React__default, { ReactNode, PropsWithChildren, ComponentPropsWithoutRef, CSSProperties, ComponentType, ComponentProps, ForwardRefExoticComponent, Ref, RefAttributes, RefCallback, ReactElement, Dispatch, SetStateAction } from 'react';
|
|
8
10
|
import { Tooltip, Heading, Text, DataTableColumnDef, DataTableFilter, DataTableCommand, DataTableEmptyStateProps, DataTableRowSelectionState, DataTableRow, Select, Input, Table, Drawer, FocusModal, ProgressStatus } from '@medusajs/ui';
|
|
9
11
|
import * as react_hook_form from 'react-hook-form';
|
|
10
12
|
import { FieldValues, FieldPath, ControllerProps, UseFormReturn, Control, UseFormProps } from 'react-hook-form';
|
|
@@ -16,8 +18,6 @@ import { CellContext, Row, ColumnDef, ColumnDefTemplate, HeaderContext, Table as
|
|
|
16
18
|
import { TFunction } from 'i18next';
|
|
17
19
|
import { ClientError } from '@mercurjs/client';
|
|
18
20
|
import * as react_currency_input_field from 'react-currency-input-field';
|
|
19
|
-
import * as _mercurjs_dashboard_sdk 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];
|
|
@@ -198,6 +198,13 @@ type Action = {
|
|
|
198
198
|
* Optional tooltip to display when a disabled action is hovered.
|
|
199
199
|
*/
|
|
200
200
|
disabledTooltip?: string | ReactNode;
|
|
201
|
+
/**
|
|
202
|
+
* Permission(s) of the endpoint this action calls. An actor who lacks it
|
|
203
|
+
* gets the action disabled with a tooltip.
|
|
204
|
+
*/
|
|
205
|
+
permission?: Permission | Permission[];
|
|
206
|
+
/** If true, ALL `permission` entries are required. Defaults to ANY. */
|
|
207
|
+
requireAll?: boolean;
|
|
201
208
|
} & ({
|
|
202
209
|
to: string;
|
|
203
210
|
onClick?: never;
|
|
@@ -212,7 +219,7 @@ type ActionMenuProps = PropsWithChildren<{
|
|
|
212
219
|
groups: ActionGroup[];
|
|
213
220
|
variant?: "transparent" | "primary";
|
|
214
221
|
}>;
|
|
215
|
-
declare const ActionMenu: ({ groups, variant, children, }: ActionMenuProps) => react_jsx_runtime.JSX.Element;
|
|
222
|
+
declare const ActionMenu: ({ groups: declaredGroups, variant, children, }: ActionMenuProps) => react_jsx_runtime.JSX.Element;
|
|
216
223
|
|
|
217
224
|
type BadgeListSummaryProps = {
|
|
218
225
|
/**
|
|
@@ -340,6 +347,8 @@ type ActionProps = {
|
|
|
340
347
|
action?: {
|
|
341
348
|
to: string;
|
|
342
349
|
label: string;
|
|
350
|
+
/** Permission of what the target route does; disabled without it. */
|
|
351
|
+
permission?: Permission | Permission[];
|
|
343
352
|
};
|
|
344
353
|
};
|
|
345
354
|
type NoRecordsProps = {
|
|
@@ -524,6 +533,18 @@ type ProductChangePanelProps = {
|
|
|
524
533
|
};
|
|
525
534
|
declare const ProductChangePanel: ({ product, actions, resolvers, headerDescription, footer, }: ProductChangePanelProps) => react_jsx_runtime.JSX.Element | null;
|
|
526
535
|
|
|
536
|
+
type RichTextProps = {
|
|
537
|
+
html?: string | null;
|
|
538
|
+
className?: string;
|
|
539
|
+
fallback?: string;
|
|
540
|
+
collapsedHeight?: number;
|
|
541
|
+
"data-testid"?: string;
|
|
542
|
+
};
|
|
543
|
+
declare const sanitizeRichText: (html: string) => string;
|
|
544
|
+
declare const RichText: ({ html, className, fallback, collapsedHeight, "data-testid": dataTestId, }: RichTextProps) => react_jsx_runtime.JSX.Element;
|
|
545
|
+
|
|
546
|
+
declare const richTextContentClasses: string;
|
|
547
|
+
|
|
527
548
|
interface ProgressBarProps {
|
|
528
549
|
/**
|
|
529
550
|
* The duration of the animation in seconds.
|
|
@@ -814,11 +835,46 @@ type CreateDataGridPriceColumnsProps<TData, TFieldValues extends FieldValues> =
|
|
|
814
835
|
};
|
|
815
836
|
declare const createDataGridPriceColumns: <TData, TFieldValues extends FieldValues>({ currencies, regions, pricePreferences, isReadyOnly, getFieldName, t, }: CreateDataGridPriceColumnsProps<TData, TFieldValues>) => ColumnDef<TData, unknown>[];
|
|
816
837
|
|
|
838
|
+
type PermissionChecks$1 = Pick<PermissionsContextValue, "hasAnyPermission" | "hasAllPermissions">;
|
|
839
|
+
type Permissioned = {
|
|
840
|
+
permission?: Permission | Permission[];
|
|
841
|
+
requireAll?: boolean;
|
|
842
|
+
};
|
|
843
|
+
type DisableableAction = Permissioned & {
|
|
844
|
+
disabled?: boolean;
|
|
845
|
+
disabledTooltip?: string | ReactNode;
|
|
846
|
+
};
|
|
847
|
+
/**
|
|
848
|
+
* Disables the actions the actor lacks the permission for and explains why in
|
|
849
|
+
* the tooltip. The action stays visible so the menu doesn't change shape
|
|
850
|
+
* between roles.
|
|
851
|
+
*/
|
|
852
|
+
declare const applyActionPermissions: <TAction extends DisableableAction, TGroup extends {
|
|
853
|
+
actions: TAction[];
|
|
854
|
+
}>(groups: TGroup[], checks: PermissionChecks$1 | null, deniedTooltip: string) => TGroup[];
|
|
855
|
+
type PermissionedCommand<TCommand> = TCommand & Permissioned;
|
|
856
|
+
/**
|
|
857
|
+
* The Medusa UI command bar can't render a disabled command, so bulk commands
|
|
858
|
+
* the actor may not run are left out.
|
|
859
|
+
*/
|
|
860
|
+
declare const filterCommandsByPermission: <TCommand>(commands: PermissionedCommand<TCommand>[], checks: PermissionChecks$1 | null) => TCommand[];
|
|
861
|
+
/**
|
|
862
|
+
* @example
|
|
863
|
+
* ```tsx
|
|
864
|
+
* const commands = usePermittedCommands([
|
|
865
|
+
* { label: t("actions.delete"), shortcut: "d", action, permission: "offers:manage" },
|
|
866
|
+
* ])
|
|
867
|
+
* ```
|
|
868
|
+
*/
|
|
869
|
+
declare const usePermittedCommands: <TCommand>(commands: PermissionedCommand<TCommand>[]) => TCommand[];
|
|
870
|
+
|
|
817
871
|
type VisibilityState = Record<string, boolean>;
|
|
818
872
|
type ColumnOrderState = string[];
|
|
819
873
|
type DataTableActionProps = {
|
|
820
874
|
label: string;
|
|
821
875
|
disabled?: boolean;
|
|
876
|
+
/** Permission of the endpoint the action calls; disabled without it. */
|
|
877
|
+
permission?: Permission | Permission[];
|
|
822
878
|
} & ({
|
|
823
879
|
to: string;
|
|
824
880
|
} | {
|
|
@@ -843,7 +899,8 @@ interface DataTableProps$1<TData> {
|
|
|
843
899
|
data?: TData[];
|
|
844
900
|
columns: DataTableColumnDef<TData, any>[];
|
|
845
901
|
filters?: DataTableFilter[];
|
|
846
|
-
|
|
902
|
+
/** A command with a `permission` is left out when the actor lacks it. */
|
|
903
|
+
commands?: PermissionedCommand<DataTableCommand>[];
|
|
847
904
|
action?: DataTableActionProps;
|
|
848
905
|
actions?: DataTableActionProps[];
|
|
849
906
|
actionMenu?: DataTableActionMenuProps;
|
|
@@ -880,7 +937,7 @@ interface DataTableProps$1<TData> {
|
|
|
880
937
|
};
|
|
881
938
|
filterBarContent?: React__default.ReactNode;
|
|
882
939
|
}
|
|
883
|
-
declare const DataTable: <TData>({ data, columns, filters, commands, action, actions, actionMenu, getRowId, rowCount, enablePagination, enableSearch, autoFocusSearch: _autoFocusSearch, enableFilterMenu, rowHref, heading, headingLevel, subHeading, prefix, pageSize, emptyState, rowSelection, isLoading, layout, enableColumnVisibility, initialColumnVisibility, onColumnVisibilityChange, columnOrder, onColumnOrderChange, filterBarContent, }: DataTableProps$1<TData>) => react_jsx_runtime.JSX.Element;
|
|
940
|
+
declare const DataTable: <TData>({ data, columns, filters, commands: declaredCommands, action, actions, actionMenu, getRowId, rowCount, enablePagination, enableSearch, autoFocusSearch: _autoFocusSearch, enableFilterMenu, rowHref, heading, headingLevel, subHeading, prefix, pageSize, emptyState, rowSelection, isLoading, layout, enableColumnVisibility, initialColumnVisibility, onColumnVisibilityChange, columnOrder, onColumnOrderChange, filterBarContent, }: DataTableProps$1<TData>) => react_jsx_runtime.JSX.Element;
|
|
884
941
|
|
|
885
942
|
type FilterGroupProps = {
|
|
886
943
|
filters: {
|
|
@@ -1056,6 +1113,27 @@ type ProvinceSelectProps = ComponentPropsWithoutRef<typeof Select> & {
|
|
|
1056
1113
|
};
|
|
1057
1114
|
declare const ProvinceSelect: ComponentType<ProvinceSelectProps>;
|
|
1058
1115
|
|
|
1116
|
+
type RichTextEditorProps = Omit<ComponentPropsWithoutRef<"div">, "onChange" | "onBlur" | "defaultValue"> & {
|
|
1117
|
+
value?: string | null;
|
|
1118
|
+
onChange?: (value: string) => void;
|
|
1119
|
+
onBlur?: () => void;
|
|
1120
|
+
name?: string;
|
|
1121
|
+
disabled?: boolean;
|
|
1122
|
+
placeholder?: string;
|
|
1123
|
+
onUpload?: (file: File) => Promise<string>;
|
|
1124
|
+
contentClassName?: string;
|
|
1125
|
+
};
|
|
1126
|
+
declare const RichTextEditor: React$1.ForwardRefExoticComponent<Omit<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "onBlur" | "onChange"> & {
|
|
1127
|
+
value?: string | null;
|
|
1128
|
+
onChange?: (value: string) => void;
|
|
1129
|
+
onBlur?: () => void;
|
|
1130
|
+
name?: string;
|
|
1131
|
+
disabled?: boolean;
|
|
1132
|
+
placeholder?: string;
|
|
1133
|
+
onUpload?: (file: File) => Promise<string>;
|
|
1134
|
+
contentClassName?: string;
|
|
1135
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
1136
|
+
|
|
1059
1137
|
interface PageProps<TData> {
|
|
1060
1138
|
children: ReactNode;
|
|
1061
1139
|
data?: TData;
|
|
@@ -1263,6 +1341,9 @@ type BulkCommand = {
|
|
|
1263
1341
|
label: string;
|
|
1264
1342
|
shortcut: string;
|
|
1265
1343
|
action: (selection: Record<string, boolean>) => Promise<void>;
|
|
1344
|
+
/** Permission(s) of the endpoint the command calls; disabled without it. */
|
|
1345
|
+
permission?: Permission | Permission[];
|
|
1346
|
+
requireAll?: boolean;
|
|
1266
1347
|
};
|
|
1267
1348
|
interface DataTableRootProps<TData> {
|
|
1268
1349
|
/**
|
|
@@ -1482,82 +1563,32 @@ declare function useQueryParams<T extends string>(keys: T[], prefix?: string): Q
|
|
|
1482
1563
|
declare const PermissionsContext: React$1.Context<PermissionsContextValue | null>;
|
|
1483
1564
|
|
|
1484
1565
|
interface PermissionsProviderProps extends PropsWithChildren {
|
|
1485
|
-
policy: UserPolicy | null;
|
|
1486
|
-
isLoading?: boolean;
|
|
1487
1566
|
/**
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1567
|
+
* The actor's effective rights, read from `fields=+permissions`. Leave it
|
|
1568
|
+
* `null`/`undefined` when the API returned no `permissions` field: nothing is
|
|
1569
|
+
* being enforced, so every check passes.
|
|
1490
1570
|
*/
|
|
1491
|
-
|
|
1571
|
+
permissions?: PermissionMap | null;
|
|
1572
|
+
isLoading?: boolean;
|
|
1492
1573
|
}
|
|
1493
|
-
declare const PermissionsProvider: ({
|
|
1494
|
-
|
|
1495
|
-
declare const PermissionsRequirementsContext: React$1.Context<PermissionsRequirementsContextValue | null>;
|
|
1574
|
+
declare const PermissionsProvider: ({ permissions, isLoading, children, }: PermissionsProviderProps) => react_jsx_runtime.JSX.Element;
|
|
1496
1575
|
|
|
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. */
|
|
1576
|
+
type PermissionGuardProps = PropsWithChildren<{
|
|
1577
|
+
permission: Permission | Permission[];
|
|
1578
|
+
/** When several permissions are given, require all of them. Defaults to any. */
|
|
1518
1579
|
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
1580
|
/** Rendered when access is denied. Nothing renders when omitted. */
|
|
1545
1581
|
fallback?: ReactNode;
|
|
1546
|
-
showLoading?: boolean;
|
|
1547
|
-
loadingComponent?: ReactNode;
|
|
1548
1582
|
}>;
|
|
1549
1583
|
/**
|
|
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
1584
|
* @example
|
|
1554
1585
|
* ```tsx
|
|
1555
|
-
* <PermissionGuard
|
|
1586
|
+
* <PermissionGuard permission="products:edit">
|
|
1556
1587
|
* <Button>Create</Button>
|
|
1557
1588
|
* </PermissionGuard>
|
|
1558
1589
|
* ```
|
|
1559
1590
|
*/
|
|
1560
|
-
declare const PermissionGuard: ({ children,
|
|
1591
|
+
declare const PermissionGuard: ({ children, permission, requireAll, fallback, }: PermissionGuardProps) => react_jsx_runtime.JSX.Element;
|
|
1561
1592
|
|
|
1562
1593
|
/**
|
|
1563
1594
|
* Route-level guard. Mount as a route's `element` and declare the requirement
|
|
@@ -1569,7 +1600,7 @@ declare const PermissionGuard: ({ children, fallback, showLoading, loadingCompon
|
|
|
1569
1600
|
* {
|
|
1570
1601
|
* path: "roles",
|
|
1571
1602
|
* element: <RoutePermissionGuard />,
|
|
1572
|
-
* handle: { permissions: "
|
|
1603
|
+
* handle: { permissions: "roles:view" },
|
|
1573
1604
|
* children: [...],
|
|
1574
1605
|
* }
|
|
1575
1606
|
* ```
|
|
@@ -1577,51 +1608,178 @@ declare const PermissionGuard: ({ children, fallback, showLoading, loadingCompon
|
|
|
1577
1608
|
declare const RoutePermissionGuard: () => react_jsx_runtime.JSX.Element;
|
|
1578
1609
|
|
|
1579
1610
|
/**
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1611
|
+
* @example
|
|
1612
|
+
* ```tsx
|
|
1613
|
+
* const { can, hasPermission } = usePermissions()
|
|
1614
|
+
*
|
|
1615
|
+
* if (can("customers", "edit")) { ... }
|
|
1616
|
+
* if (hasPermission("customers:view")) { ... }
|
|
1617
|
+
* ```
|
|
1618
|
+
*/
|
|
1619
|
+
declare const usePermissions: () => _mercurjs_dashboard_sdk.PermissionsContextValue;
|
|
1620
|
+
|
|
1621
|
+
/**
|
|
1622
|
+
* @example
|
|
1623
|
+
* ```tsx
|
|
1624
|
+
* const { canEdit } = useResourcePermissions("products")
|
|
1625
|
+
* ```
|
|
1626
|
+
*/
|
|
1627
|
+
declare const useResourcePermissions: (key: PermissionKey) => {
|
|
1628
|
+
canView: boolean;
|
|
1629
|
+
canEdit: boolean;
|
|
1630
|
+
canManage: boolean;
|
|
1631
|
+
key: PermissionKey;
|
|
1632
|
+
isLoading: boolean;
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1635
|
+
type PermissionChecks = Pick<PermissionsContextValue, "hasAnyPermission" | "hasAllPermissions">;
|
|
1636
|
+
declare const toPermissionList: (permission?: Permission | Permission[]) => Permission[];
|
|
1637
|
+
/**
|
|
1638
|
+
* A null `checks` means no provider is mounted (public routes); nothing is
|
|
1639
|
+
* enforced there, so everything is permitted.
|
|
1582
1640
|
*/
|
|
1583
|
-
declare const
|
|
1641
|
+
declare const isPermitted: (checks: PermissionChecks | null, permission?: Permission | Permission[], requireAll?: boolean) => boolean;
|
|
1642
|
+
/** Same check against a raw permission map, for code outside React. */
|
|
1643
|
+
declare const permissionMapAllows: (map: PermissionMap | null | undefined, permission: Permission | Permission[], requireAll?: boolean) => boolean;
|
|
1644
|
+
/** True for a 403 from the API (`ClientError.status`). */
|
|
1645
|
+
declare const isForbidden: (error: unknown) => boolean;
|
|
1584
1646
|
|
|
1585
1647
|
/**
|
|
1586
1648
|
* @example
|
|
1587
1649
|
* ```tsx
|
|
1588
|
-
* const
|
|
1650
|
+
* const canViewCustomers = useCan("customers")
|
|
1589
1651
|
*
|
|
1590
|
-
*
|
|
1591
|
-
* if (hasPermission("customer:read")) { ... }
|
|
1652
|
+
* useCustomers(query, { enabled: canViewCustomers })
|
|
1592
1653
|
* ```
|
|
1593
1654
|
*/
|
|
1594
|
-
declare const
|
|
1655
|
+
declare const useCan: (key: PermissionKey, right?: PermissionRight) => boolean;
|
|
1595
1656
|
|
|
1596
|
-
|
|
1597
|
-
|
|
1657
|
+
/**
|
|
1658
|
+
* For controls that stay visible but must not fire when the actor lacks the
|
|
1659
|
+
* permission of the endpoint they call.
|
|
1660
|
+
*
|
|
1661
|
+
* @example
|
|
1662
|
+
* ```tsx
|
|
1663
|
+
* const gate = usePermissionGate("orders:edit")
|
|
1664
|
+
*
|
|
1665
|
+
* <Tooltip content={gate.tooltip}>
|
|
1666
|
+
* <Button disabled={gate.denied}>Cancel</Button>
|
|
1667
|
+
* </Tooltip>
|
|
1668
|
+
* ```
|
|
1669
|
+
*/
|
|
1670
|
+
declare const usePermissionGate: (permission?: Permission | Permission[], requireAll?: boolean) => {
|
|
1671
|
+
allowed: boolean;
|
|
1672
|
+
denied: boolean;
|
|
1673
|
+
tooltip: string | undefined;
|
|
1674
|
+
};
|
|
1675
|
+
|
|
1676
|
+
type ActionElementProps = {
|
|
1677
|
+
disabled?: boolean;
|
|
1678
|
+
asChild?: boolean;
|
|
1679
|
+
children?: ReactNode;
|
|
1680
|
+
};
|
|
1681
|
+
type PermissionActionProps = {
|
|
1682
|
+
permission: Permission | Permission[];
|
|
1683
|
+
/** When several permissions are given, require all of them. Defaults to any. */
|
|
1598
1684
|
requireAll?: boolean;
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
}
|
|
1685
|
+
children: ReactElement<ActionElementProps>;
|
|
1686
|
+
};
|
|
1602
1687
|
/**
|
|
1603
|
-
*
|
|
1604
|
-
*
|
|
1688
|
+
* Disables a button (or a button wrapping a link) with a tooltip when the
|
|
1689
|
+
* actor lacks the permission of the endpoint it calls.
|
|
1690
|
+
*
|
|
1691
|
+
* @example
|
|
1692
|
+
* ```tsx
|
|
1693
|
+
* <PermissionAction permission="products:edit">
|
|
1694
|
+
* <Button size="small" variant="secondary" asChild>
|
|
1695
|
+
* <Link to="create">Create</Link>
|
|
1696
|
+
* </Button>
|
|
1697
|
+
* </PermissionAction>
|
|
1698
|
+
* ```
|
|
1605
1699
|
*/
|
|
1606
|
-
declare const
|
|
1700
|
+
declare const PermissionAction: ({ permission, requireAll, children, }: PermissionActionProps) => react_jsx_runtime.JSX.Element;
|
|
1607
1701
|
|
|
1608
|
-
|
|
1702
|
+
/**
|
|
1703
|
+
* Inline state for a section whose data the actor may not read. Sections
|
|
1704
|
+
* render this for a 403 instead of throwing to the page's error boundary.
|
|
1705
|
+
*/
|
|
1706
|
+
declare const SectionNoAccess: ({ className }: {
|
|
1707
|
+
className?: string;
|
|
1708
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
1609
1709
|
|
|
1710
|
+
type Loader<TArgs, TResult> = (args: TArgs) => TResult | Promise<TResult>;
|
|
1610
1711
|
/**
|
|
1712
|
+
* Loaders run before `RoutePermissionGuard` (an element) gets to refuse the
|
|
1713
|
+
* route, so a loader has to check the permission itself. A denied loader
|
|
1714
|
+
* resolves to `null`. The return type stays the loader's own because the guard
|
|
1715
|
+
* renders Access Denied instead of the page, so nothing ever reads that value.
|
|
1716
|
+
*
|
|
1611
1717
|
* @example
|
|
1612
|
-
* ```
|
|
1613
|
-
* const
|
|
1614
|
-
* {
|
|
1718
|
+
* ```ts
|
|
1719
|
+
* export const withPermission = createWithPermission(async () => {
|
|
1720
|
+
* const { user } = await queryClient.ensureQueryData(meQueryOptions())
|
|
1721
|
+
* return user.permissions ?? null
|
|
1722
|
+
* })
|
|
1723
|
+
*
|
|
1724
|
+
* export const loader = withPermission(productLoader, "products:view")
|
|
1615
1725
|
* ```
|
|
1616
1726
|
*/
|
|
1617
|
-
declare const
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1727
|
+
declare const createWithPermission: (getPermissions: () => Promise<PermissionMap | null | undefined>) => <TArgs, TResult>(loader: Loader<TArgs, TResult>, permission: Permission | Permission[], options?: {
|
|
1728
|
+
requireAll?: boolean;
|
|
1729
|
+
}) => (args: TArgs) => Promise<TResult>;
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* Applied to anything in the sidebar that has no place in the icon rail —
|
|
1733
|
+
* labels, the store name, the shortcut hint. Expanding waits for the rail to
|
|
1734
|
+
* make room before fading the content back in; collapsing clears it first so
|
|
1735
|
+
* it is never caught mid-fade by the clip.
|
|
1736
|
+
*/
|
|
1737
|
+
declare const SIDEBAR_RAIL_FADE: string;
|
|
1738
|
+
/**
|
|
1739
|
+
* Sidebar dropdowns take the trigger's width, which in the icon rail is only
|
|
1740
|
+
* the avatar — the floor keeps them readable when opened from the rail.
|
|
1741
|
+
*/
|
|
1742
|
+
declare const SIDEBAR_MENU_CONTENT = "w-[var(--radix-dropdown-menu-trigger-width)] min-w-[196px]";
|
|
1743
|
+
|
|
1744
|
+
type SidebarState = "expanded" | "collapsed";
|
|
1745
|
+
type SidebarContextValue = {
|
|
1746
|
+
/**
|
|
1747
|
+
* `collapsed` renders the desktop sidebar as an icon rail rather than
|
|
1748
|
+
* hiding it. Mirrors the `data-state` attribute the layout styles read.
|
|
1749
|
+
*/
|
|
1750
|
+
state: SidebarState;
|
|
1751
|
+
desktop: boolean;
|
|
1752
|
+
mobile: boolean;
|
|
1753
|
+
toggle: (view: "desktop" | "mobile") => void;
|
|
1754
|
+
setDesktop: Dispatch<SetStateAction<boolean>>;
|
|
1755
|
+
setMobile: Dispatch<SetStateAction<boolean>>;
|
|
1756
|
+
};
|
|
1757
|
+
declare const SidebarContext: React$1.Context<SidebarContextValue | null>;
|
|
1758
|
+
|
|
1759
|
+
declare const SidebarProvider: ({ children }: PropsWithChildren) => react_jsx_runtime.JSX.Element;
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* Collapses the desktop sidebar to its icon rail for as long as the calling
|
|
1763
|
+
* component is mounted, restoring whatever the user had open before. Intended
|
|
1764
|
+
* for dense, full-height surfaces — the inbox, the editor — that need the
|
|
1765
|
+
* horizontal space but should not permanently change the user's preference.
|
|
1766
|
+
*/
|
|
1767
|
+
declare const useCollapsedSidebar: (collapsed?: boolean) => void;
|
|
1768
|
+
/**
|
|
1769
|
+
* Opens the desktop sidebar on mount and restores the previous state on
|
|
1770
|
+
* unmount. For sidebars without an icon rail, where arriving collapsed would
|
|
1771
|
+
* leave nothing to navigate with.
|
|
1772
|
+
*/
|
|
1773
|
+
declare const useExpandedSidebar: (expanded?: boolean) => void;
|
|
1774
|
+
|
|
1775
|
+
declare const useSidebar: () => SidebarContextValue;
|
|
1776
|
+
|
|
1777
|
+
declare const useSidebarMenuPlacement: (align: "start" | "end") => {
|
|
1778
|
+
side: "right";
|
|
1779
|
+
align: "end" | "start";
|
|
1780
|
+
} | {
|
|
1781
|
+
side?: undefined;
|
|
1782
|
+
align?: undefined;
|
|
1625
1783
|
};
|
|
1626
1784
|
|
|
1627
1785
|
type WidgetPlacement = "before" | "after";
|
|
@@ -1631,12 +1789,15 @@ type Widget = {
|
|
|
1631
1789
|
}>;
|
|
1632
1790
|
zone: string[];
|
|
1633
1791
|
widgetId: string;
|
|
1792
|
+
permission?: Permission[];
|
|
1793
|
+
label?: string;
|
|
1634
1794
|
};
|
|
1635
1795
|
type WidgetModule = {
|
|
1636
1796
|
widgets?: Widget[];
|
|
1637
1797
|
};
|
|
1638
1798
|
type NavigationModule = {
|
|
1639
|
-
|
|
1799
|
+
groups?: NavGroupConfig[];
|
|
1800
|
+
items?: NavItemOverride<string>[];
|
|
1640
1801
|
};
|
|
1641
1802
|
type CustomFieldsModule = {
|
|
1642
1803
|
configs?: CustomFieldsConfig[];
|
|
@@ -1652,6 +1813,8 @@ type ResolvedDisplays = {
|
|
|
1652
1813
|
type ResolvedWidget = {
|
|
1653
1814
|
Component: Widget["Component"];
|
|
1654
1815
|
widgetId: string;
|
|
1816
|
+
permission?: Permission[];
|
|
1817
|
+
label?: string;
|
|
1655
1818
|
};
|
|
1656
1819
|
type ZoneWidgets = {
|
|
1657
1820
|
before: ResolvedWidget[];
|
|
@@ -1665,6 +1828,7 @@ type ZoneWidgets = {
|
|
|
1665
1828
|
declare class ExtensionRegistry {
|
|
1666
1829
|
private widgets;
|
|
1667
1830
|
private navOverrides;
|
|
1831
|
+
private navGroups;
|
|
1668
1832
|
private customFields;
|
|
1669
1833
|
constructor(input?: {
|
|
1670
1834
|
widgets?: WidgetModule;
|
|
@@ -1674,7 +1838,8 @@ declare class ExtensionRegistry {
|
|
|
1674
1838
|
private ensureSlot;
|
|
1675
1839
|
private populateWidgets;
|
|
1676
1840
|
getWidgets(slot: string): ZoneWidgets;
|
|
1677
|
-
getNavOverrides(): NavItemOverride[];
|
|
1841
|
+
getNavOverrides(): NavItemOverride<string>[];
|
|
1842
|
+
getNavGroups(): NavGroupConfig[];
|
|
1678
1843
|
private configsFor;
|
|
1679
1844
|
/** Distinct module links declared across a model's configs. */
|
|
1680
1845
|
getLinks(model: string): string[];
|
|
@@ -1725,6 +1890,22 @@ type WidgetZoneProps = {
|
|
|
1725
1890
|
*/
|
|
1726
1891
|
declare const WidgetZone: ({ id, data, children }: WidgetZoneProps) => react_jsx_runtime.JSX.Element;
|
|
1727
1892
|
|
|
1893
|
+
type WidgetTab = {
|
|
1894
|
+
id: string;
|
|
1895
|
+
label: string;
|
|
1896
|
+
Component: Widget["Component"];
|
|
1897
|
+
};
|
|
1898
|
+
type WidgetTabs = {
|
|
1899
|
+
before: WidgetTab[];
|
|
1900
|
+
after: WidgetTab[];
|
|
1901
|
+
};
|
|
1902
|
+
/**
|
|
1903
|
+
* Tab-bar host. Returns the widgets targeting a `*.tabs` slot as tabs to place
|
|
1904
|
+
* `before` and `after` the built-in ones. A widget without a `label` cannot be
|
|
1905
|
+
* shown as a tab and is left out.
|
|
1906
|
+
*/
|
|
1907
|
+
declare const useWidgetTabs: (id: string) => WidgetTabs;
|
|
1908
|
+
|
|
1728
1909
|
type CoreNavItem = {
|
|
1729
1910
|
id: string;
|
|
1730
1911
|
label: string;
|
|
@@ -1739,6 +1920,51 @@ type CoreNavItem = {
|
|
|
1739
1920
|
* items without a matching override are preserved in their original order.
|
|
1740
1921
|
*/
|
|
1741
1922
|
declare function applyNavOverrides(coreRoutes: CoreNavItem[], overrides?: NavItemOverride[]): CoreNavItem[];
|
|
1923
|
+
type NavGroupItem = {
|
|
1924
|
+
id: string;
|
|
1925
|
+
label: string;
|
|
1926
|
+
to: string;
|
|
1927
|
+
translationNs?: string;
|
|
1928
|
+
};
|
|
1929
|
+
type NavGroup = {
|
|
1930
|
+
id: string;
|
|
1931
|
+
label: string;
|
|
1932
|
+
translationNs?: string;
|
|
1933
|
+
items: NavGroupItem[];
|
|
1934
|
+
};
|
|
1935
|
+
type ExtensionNavGroupItem = NavGroupItem & {
|
|
1936
|
+
group?: string;
|
|
1937
|
+
rank?: number;
|
|
1938
|
+
};
|
|
1939
|
+
/**
|
|
1940
|
+
* Resolves the grouped settings sidebar: the panel's built-in groups, plus the
|
|
1941
|
+
* groups and per-item overrides (`group`/`rank`/`hidden`/`label`) from the
|
|
1942
|
+
* host's `_navigation.ts`, plus extension routes placed by their route
|
|
1943
|
+
* config's `group`. An unknown group id falls back to the first built-in
|
|
1944
|
+
* group, extension routes list after a group's built-in items, and groups
|
|
1945
|
+
* left without items are dropped.
|
|
1946
|
+
*/
|
|
1947
|
+
declare function applyNavGroups(coreGroups: NavGroup[], extensionItems?: ExtensionNavGroupItem[], config?: {
|
|
1948
|
+
groups?: NavGroupConfig[];
|
|
1949
|
+
items?: NavItemOverride<string>[];
|
|
1950
|
+
}): NavGroup[];
|
|
1951
|
+
type NavItemGroup<T> = {
|
|
1952
|
+
id: string;
|
|
1953
|
+
label: string;
|
|
1954
|
+
translationNs?: string;
|
|
1955
|
+
items: T[];
|
|
1956
|
+
};
|
|
1957
|
+
/**
|
|
1958
|
+
* Splits main sidebar items into the ungrouped list and the groups declared in
|
|
1959
|
+
* the host's `_navigation.ts`. The main sidebar has no built-in groups, so an
|
|
1960
|
+
* item whose group isn't declared stays ungrouped. Item order is preserved.
|
|
1961
|
+
*/
|
|
1962
|
+
declare function groupNavItems<T extends {
|
|
1963
|
+
group?: string;
|
|
1964
|
+
}>(items: T[], groups?: NavGroupConfig[]): {
|
|
1965
|
+
ungrouped: T[];
|
|
1966
|
+
groups: NavItemGroup<T>[];
|
|
1967
|
+
};
|
|
1742
1968
|
|
|
1743
1969
|
type FormExtensionZoneProps = {
|
|
1744
1970
|
model: string;
|
|
@@ -2018,4 +2244,9 @@ declare const extractPricesFromOffers: (offers: ExtractableOffers, regions: Http
|
|
|
2018
2244
|
variant_id: string;
|
|
2019
2245
|
}[];
|
|
2020
2246
|
|
|
2021
|
-
|
|
2247
|
+
declare const RICH_TEXT_ALLOWED_TAGS: string[];
|
|
2248
|
+
declare const RICH_TEXT_ALLOWED_ATTRIBUTES: string[];
|
|
2249
|
+
declare const isHtml: (value?: string | null) => boolean;
|
|
2250
|
+
declare const plainTextToHtml: (value?: string | null) => string;
|
|
2251
|
+
|
|
2252
|
+
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 NavGroup, type NavGroupItem, type NavItemGroup, type NavigationModule, NoRecords, type NoRecordsProps, NoResults, type NoResultsProps, OrderBy, PercentageInput, PermissionAction, type PermissionActionProps, PermissionGuard, type PermissionGuardProps, type PermissionedCommand, 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, SectionNoAccess, 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, type WidgetTab, type WidgetTabs, WidgetZone, type WidgetZoneProps, type ZoneWidgets, _DataTable, applyActionPermissions, applyNavGroups, applyNavOverrides, buildAdditionalDataDefaults, buildAdditionalDataSchema, buildOfferGridData, buildProductChangeView, countries, createDataGridHelper, createDataGridPriceColumns, createFormHelper, createWithPermission, currencies, extractPricesFromOffers, extractReferenceIds, filterCommandsByPermission, formatFieldValue, genericForwardRef, getCountryByIso2, getCurrencySymbol, getDecimalDigits, getExtensionRegistry, getFormattedAddress, getFormattedCountry, getLinkQuery, getLocaleAmount, getNativeSymbol, getPriceListStatus, getStylizedAmount, groupNavItems, humanizeFieldName, isAmountLessThenRoundingError, isForbidden, isHtml, isImageList, isOrderActionable, isOrderAwaitingAction, isPermitted, isPriceListGroupRow, isProductRow, isReferenceField, isSameAddress, linkFields, permissionMapAllows, plainTextToHtml, productChangeViewHasContent, queryClient, queryKeysFactory, richTextContentClasses, sanitizeRichText, toPermissionList, useActionLocks, useCan, useCollapsedSidebar, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExpandedSidebar, useExtendableForm, useExtendableTable, useExtension, useExtensionActivity, useLinkQuery, usePermissionGate, usePermissions, usePermittedCommands, useQueryParams, useResourcePermissions, useRouteModal, useSidebar, useSidebarMenuPlacement, useStackedModal, useTabManagement, useTabbedForm, useWidgetTabs, withLinkFields };
|