@mercurjs/dashboard-sdk 2.3.8-canary.2 → 2.3.8-canary.3
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.cjs +29 -0
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +24 -0
- package/dist/{types-BTgTMD_t.d.cts → types-DG9Yya-_.d.cts} +104 -5
- package/dist/{types-BTgTMD_t.d.ts → types-DG9Yya-_.d.ts} +104 -5
- package/dist/vite.cjs +613 -634
- package/dist/vite.d.cts +4 -4
- package/dist/vite.d.ts +4 -4
- package/dist/vite.js +615 -635
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,16 +20,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
CORE_LAYOUT_IDS: () => CORE_LAYOUT_IDS,
|
|
24
|
+
NAV_ZONES: () => NAV_ZONES,
|
|
23
25
|
PERMISSION_RIGHT_RANK: () => PERMISSION_RIGHT_RANK,
|
|
24
26
|
buildPermission: () => buildPermission,
|
|
25
27
|
defineCustomFieldsConfig: () => defineCustomFieldsConfig,
|
|
28
|
+
defineLayoutConfig: () => defineLayoutConfig,
|
|
29
|
+
defineLayoutPreferences: () => defineLayoutPreferences,
|
|
26
30
|
defineNavigationConfig: () => defineNavigationConfig,
|
|
31
|
+
defineRouteConfig: () => defineRouteConfig,
|
|
27
32
|
defineWidgetConfig: () => defineWidgetConfig,
|
|
28
33
|
parsePermission: () => parsePermission,
|
|
29
34
|
satisfiesPermission: () => satisfiesPermission
|
|
30
35
|
});
|
|
31
36
|
module.exports = __toCommonJS(index_exports);
|
|
32
37
|
|
|
38
|
+
// src/config/layouts.ts
|
|
39
|
+
var CORE_LAYOUT_IDS = {
|
|
40
|
+
SINGLE_COLUMN: "core:single-column",
|
|
41
|
+
TWO_COLUMN: "core:two-column"
|
|
42
|
+
};
|
|
43
|
+
var NAV_ZONES = {
|
|
44
|
+
MAIN: "nav.main",
|
|
45
|
+
SETTINGS: "nav.settings"
|
|
46
|
+
};
|
|
47
|
+
|
|
33
48
|
// src/config/utils.ts
|
|
34
49
|
function createConfigHelper(config) {
|
|
35
50
|
return {
|
|
@@ -46,6 +61,15 @@ function defineNavigationConfig(config) {
|
|
|
46
61
|
function defineCustomFieldsConfig(config) {
|
|
47
62
|
return createConfigHelper(config);
|
|
48
63
|
}
|
|
64
|
+
function defineRouteConfig(config) {
|
|
65
|
+
return createConfigHelper(config);
|
|
66
|
+
}
|
|
67
|
+
function defineLayoutConfig(config) {
|
|
68
|
+
return createConfigHelper(config);
|
|
69
|
+
}
|
|
70
|
+
function defineLayoutPreferences(config) {
|
|
71
|
+
return config;
|
|
72
|
+
}
|
|
49
73
|
|
|
50
74
|
// src/permissions.ts
|
|
51
75
|
var PERMISSION_RIGHT_RANK = {
|
|
@@ -76,10 +100,15 @@ function satisfiesPermission(permissions, key, right) {
|
|
|
76
100
|
}
|
|
77
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
102
|
0 && (module.exports = {
|
|
103
|
+
CORE_LAYOUT_IDS,
|
|
104
|
+
NAV_ZONES,
|
|
79
105
|
PERMISSION_RIGHT_RANK,
|
|
80
106
|
buildPermission,
|
|
81
107
|
defineCustomFieldsConfig,
|
|
108
|
+
defineLayoutConfig,
|
|
109
|
+
defineLayoutPreferences,
|
|
82
110
|
defineNavigationConfig,
|
|
111
|
+
defineRouteConfig,
|
|
83
112
|
defineWidgetConfig,
|
|
84
113
|
parsePermission,
|
|
85
114
|
satisfiesPermission
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { B as BuiltMercurConfig, M as MercurConfig, N as NavGroupConfig,
|
|
1
|
+
import { a as LayoutConfig, d as LayoutPreferences, q as NavigationConfig, R as RouteConfig, W as WidgetConfig } from './types-DG9Yya-_.cjs';
|
|
2
|
+
export { B as BuiltMercurConfig, C as CORE_LAYOUT_IDS, E as EntryPreference, L as LayoutComponentProps, b as LayoutEntryId, c as LayoutEntryRegistry, e as LayoutSection, f as LayoutSectionRegistry, g as Layouts, M as MercurConfig, N as NAV_ZONES, h as NavGroupConfig, i as NavGroupId, j as NavGroupPreference, k as NavGroupRegistry, l as NavItemId, m as NavItemOverride, n as NavItemRegistry, o as NavParentId, p as NavParentRegistry, P as PERMISSION_RIGHT_RANK, r as Permission, s as PermissionKey, t as PermissionKeys, u as PermissionMap, v as PermissionRight, w as PermissionsContextValue, x as RouteHandle, S as SectionNameFor, y as WidgetZoneId, z as WidgetZoneRegistry, Z as ZonePreference, A as buildPermission, D as parsePermission, F as satisfiesPermission } from './types-DG9Yya-_.cjs';
|
|
3
3
|
import { ReactNode, ComponentType } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -183,5 +183,8 @@ interface CustomFieldsConfig<TModel extends CustomFieldModel = CustomFieldModel>
|
|
|
183
183
|
declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
|
|
184
184
|
declare function defineNavigationConfig<TGroup extends string = never>(config: NavigationConfig<TGroup>): NavigationConfig<TGroup>;
|
|
185
185
|
declare function defineCustomFieldsConfig<TModel extends CustomFieldModel>(config: CustomFieldsConfig<TModel>): CustomFieldsConfig<TModel>;
|
|
186
|
+
declare function defineRouteConfig(config: RouteConfig): RouteConfig;
|
|
187
|
+
declare function defineLayoutConfig(config: LayoutConfig): LayoutConfig;
|
|
188
|
+
declare function defineLayoutPreferences(config: LayoutPreferences): LayoutPreferences;
|
|
186
189
|
|
|
187
|
-
export { type ActivityEntry, type CustomColumn, type CustomDisplayEntry, type CustomDisplayField, type CustomFieldAction, type CustomFieldActionRegistry, type CustomFieldModel, type CustomFieldsConfig, type CustomFieldsRegistry, type CustomFormEntry, type CustomFormField, type CustomFormTab, type CustomFormZone, type CustomListExtension, type CustomListFilter, type CustomListFilterOption, type FieldValidation, NavigationConfig, type OnboardingStepOptions, type SectionAction, WidgetConfig, defineCustomFieldsConfig, defineNavigationConfig, defineWidgetConfig };
|
|
190
|
+
export { type ActivityEntry, type CustomColumn, type CustomDisplayEntry, type CustomDisplayField, type CustomFieldAction, type CustomFieldActionRegistry, type CustomFieldModel, type CustomFieldsConfig, type CustomFieldsRegistry, type CustomFormEntry, type CustomFormField, type CustomFormTab, type CustomFormZone, type CustomListExtension, type CustomListFilter, type CustomListFilterOption, type FieldValidation, LayoutConfig, LayoutPreferences, NavigationConfig, type OnboardingStepOptions, RouteConfig, type SectionAction, WidgetConfig, defineCustomFieldsConfig, defineLayoutConfig, defineLayoutPreferences, defineNavigationConfig, defineRouteConfig, defineWidgetConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { B as BuiltMercurConfig, M as MercurConfig, N as NavGroupConfig,
|
|
1
|
+
import { a as LayoutConfig, d as LayoutPreferences, q as NavigationConfig, R as RouteConfig, W as WidgetConfig } from './types-DG9Yya-_.js';
|
|
2
|
+
export { B as BuiltMercurConfig, C as CORE_LAYOUT_IDS, E as EntryPreference, L as LayoutComponentProps, b as LayoutEntryId, c as LayoutEntryRegistry, e as LayoutSection, f as LayoutSectionRegistry, g as Layouts, M as MercurConfig, N as NAV_ZONES, h as NavGroupConfig, i as NavGroupId, j as NavGroupPreference, k as NavGroupRegistry, l as NavItemId, m as NavItemOverride, n as NavItemRegistry, o as NavParentId, p as NavParentRegistry, P as PERMISSION_RIGHT_RANK, r as Permission, s as PermissionKey, t as PermissionKeys, u as PermissionMap, v as PermissionRight, w as PermissionsContextValue, x as RouteHandle, S as SectionNameFor, y as WidgetZoneId, z as WidgetZoneRegistry, Z as ZonePreference, A as buildPermission, D as parsePermission, F as satisfiesPermission } from './types-DG9Yya-_.js';
|
|
3
3
|
import { ReactNode, ComponentType } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -183,5 +183,8 @@ interface CustomFieldsConfig<TModel extends CustomFieldModel = CustomFieldModel>
|
|
|
183
183
|
declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
|
|
184
184
|
declare function defineNavigationConfig<TGroup extends string = never>(config: NavigationConfig<TGroup>): NavigationConfig<TGroup>;
|
|
185
185
|
declare function defineCustomFieldsConfig<TModel extends CustomFieldModel>(config: CustomFieldsConfig<TModel>): CustomFieldsConfig<TModel>;
|
|
186
|
+
declare function defineRouteConfig(config: RouteConfig): RouteConfig;
|
|
187
|
+
declare function defineLayoutConfig(config: LayoutConfig): LayoutConfig;
|
|
188
|
+
declare function defineLayoutPreferences(config: LayoutPreferences): LayoutPreferences;
|
|
186
189
|
|
|
187
|
-
export { type ActivityEntry, type CustomColumn, type CustomDisplayEntry, type CustomDisplayField, type CustomFieldAction, type CustomFieldActionRegistry, type CustomFieldModel, type CustomFieldsConfig, type CustomFieldsRegistry, type CustomFormEntry, type CustomFormField, type CustomFormTab, type CustomFormZone, type CustomListExtension, type CustomListFilter, type CustomListFilterOption, type FieldValidation, NavigationConfig, type OnboardingStepOptions, type SectionAction, WidgetConfig, defineCustomFieldsConfig, defineNavigationConfig, defineWidgetConfig };
|
|
190
|
+
export { type ActivityEntry, type CustomColumn, type CustomDisplayEntry, type CustomDisplayField, type CustomFieldAction, type CustomFieldActionRegistry, type CustomFieldModel, type CustomFieldsConfig, type CustomFieldsRegistry, type CustomFormEntry, type CustomFormField, type CustomFormTab, type CustomFormZone, type CustomListExtension, type CustomListFilter, type CustomListFilterOption, type FieldValidation, LayoutConfig, LayoutPreferences, NavigationConfig, type OnboardingStepOptions, RouteConfig, type SectionAction, WidgetConfig, defineCustomFieldsConfig, defineLayoutConfig, defineLayoutPreferences, defineNavigationConfig, defineRouteConfig, defineWidgetConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import "./chunk-3RG5ZIWI.js";
|
|
2
2
|
|
|
3
|
+
// src/config/layouts.ts
|
|
4
|
+
var CORE_LAYOUT_IDS = {
|
|
5
|
+
SINGLE_COLUMN: "core:single-column",
|
|
6
|
+
TWO_COLUMN: "core:two-column"
|
|
7
|
+
};
|
|
8
|
+
var NAV_ZONES = {
|
|
9
|
+
MAIN: "nav.main",
|
|
10
|
+
SETTINGS: "nav.settings"
|
|
11
|
+
};
|
|
12
|
+
|
|
3
13
|
// src/config/utils.ts
|
|
4
14
|
function createConfigHelper(config) {
|
|
5
15
|
return {
|
|
@@ -16,6 +26,15 @@ function defineNavigationConfig(config) {
|
|
|
16
26
|
function defineCustomFieldsConfig(config) {
|
|
17
27
|
return createConfigHelper(config);
|
|
18
28
|
}
|
|
29
|
+
function defineRouteConfig(config) {
|
|
30
|
+
return createConfigHelper(config);
|
|
31
|
+
}
|
|
32
|
+
function defineLayoutConfig(config) {
|
|
33
|
+
return createConfigHelper(config);
|
|
34
|
+
}
|
|
35
|
+
function defineLayoutPreferences(config) {
|
|
36
|
+
return config;
|
|
37
|
+
}
|
|
19
38
|
|
|
20
39
|
// src/permissions.ts
|
|
21
40
|
var PERMISSION_RIGHT_RANK = {
|
|
@@ -45,10 +64,15 @@ function satisfiesPermission(permissions, key, right) {
|
|
|
45
64
|
return !!granted && PERMISSION_RIGHT_RANK[granted] >= PERMISSION_RIGHT_RANK[right];
|
|
46
65
|
}
|
|
47
66
|
export {
|
|
67
|
+
CORE_LAYOUT_IDS,
|
|
68
|
+
NAV_ZONES,
|
|
48
69
|
PERMISSION_RIGHT_RANK,
|
|
49
70
|
buildPermission,
|
|
50
71
|
defineCustomFieldsConfig,
|
|
72
|
+
defineLayoutConfig,
|
|
73
|
+
defineLayoutPreferences,
|
|
51
74
|
defineNavigationConfig,
|
|
75
|
+
defineRouteConfig,
|
|
52
76
|
defineWidgetConfig,
|
|
53
77
|
parsePermission,
|
|
54
78
|
satisfiesPermission
|
|
@@ -95,6 +95,85 @@ declare function parsePermission(permission: string): {
|
|
|
95
95
|
declare function buildPermission(key: PermissionKey, right: PermissionRight): Permission;
|
|
96
96
|
declare function satisfiesPermission(permissions: PermissionMap, key: string, right: PermissionRight): boolean;
|
|
97
97
|
|
|
98
|
+
declare const CORE_LAYOUT_IDS: {
|
|
99
|
+
readonly SINGLE_COLUMN: "core:single-column";
|
|
100
|
+
readonly TWO_COLUMN: "core:two-column";
|
|
101
|
+
};
|
|
102
|
+
type LayoutSection = {
|
|
103
|
+
id: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Maps each layout id to the union of section names it renders, so a page's
|
|
107
|
+
* `sections` prop is checked against the layout it picked. A plugin layout
|
|
108
|
+
* registers its sections by augmenting this interface:
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* declare module "@mercurjs/dashboard-sdk" {
|
|
112
|
+
* interface LayoutSectionRegistry {
|
|
113
|
+
* "erp:three-column": "main" | "left" | "right"
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
*/
|
|
117
|
+
interface LayoutSectionRegistry {
|
|
118
|
+
[CORE_LAYOUT_IDS.SINGLE_COLUMN]: "main";
|
|
119
|
+
[CORE_LAYOUT_IDS.TWO_COLUMN]: "main" | "side";
|
|
120
|
+
}
|
|
121
|
+
type Layouts = keyof LayoutSectionRegistry;
|
|
122
|
+
type SectionNameFor<TLayoutId extends Layouts> = LayoutSectionRegistry[TLayoutId];
|
|
123
|
+
type LayoutComponentProps = {
|
|
124
|
+
sections: Record<string, ReactNode>;
|
|
125
|
+
data?: unknown;
|
|
126
|
+
className?: string;
|
|
127
|
+
};
|
|
128
|
+
type LayoutConfig = {
|
|
129
|
+
/** Namespaced id, e.g. `erp:three-column`. `core:` is reserved. */
|
|
130
|
+
id: string;
|
|
131
|
+
sections: LayoutSection[];
|
|
132
|
+
Component: ComponentType<LayoutComponentProps>;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Entry ids a page exposes: `core:<Entry id>` for its own sections,
|
|
136
|
+
* `widget:<widget id>` for injected widgets, `nav:<path>` for sidebar items.
|
|
137
|
+
* Panels seed the built-in ids through `extension-targets`.
|
|
138
|
+
*/
|
|
139
|
+
interface LayoutEntryRegistry {
|
|
140
|
+
}
|
|
141
|
+
type LayoutEntryId = keyof LayoutEntryRegistry extends never ? string : keyof LayoutEntryRegistry;
|
|
142
|
+
type EntryPreference = {
|
|
143
|
+
hidden?: boolean;
|
|
144
|
+
/** Move the entry to another section of the page's layout. */
|
|
145
|
+
section?: string;
|
|
146
|
+
/** Sort order within the section; entries without one keep source order at 0. */
|
|
147
|
+
order?: number;
|
|
148
|
+
/** Sidebar entries only: i18n key or literal replacing the label. */
|
|
149
|
+
label?: string;
|
|
150
|
+
/** Sidebar entries only: icon component replacing the icon. */
|
|
151
|
+
icon?: ComponentType;
|
|
152
|
+
/** Sidebar entries only: re-parent under another item, `null` promotes to top level. */
|
|
153
|
+
parent?: string | null;
|
|
154
|
+
};
|
|
155
|
+
type NavGroupPreference = {
|
|
156
|
+
id: string;
|
|
157
|
+
label?: string;
|
|
158
|
+
translationNs?: string;
|
|
159
|
+
rank?: number;
|
|
160
|
+
hidden?: boolean;
|
|
161
|
+
};
|
|
162
|
+
type ZonePreference = {
|
|
163
|
+
entries?: Record<string, EntryPreference>;
|
|
164
|
+
/** Sidebar zones (`nav.main`, `nav.settings`) only. */
|
|
165
|
+
groups?: NavGroupPreference[];
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Code-level layout preferences, one object per zone prefix. Declared in a
|
|
169
|
+
* layer's `_layouts.ts`; later layers override earlier ones field by field.
|
|
170
|
+
*/
|
|
171
|
+
type LayoutPreferences = Record<string, ZonePreference>;
|
|
172
|
+
declare const NAV_ZONES: {
|
|
173
|
+
readonly MAIN: "nav.main";
|
|
174
|
+
readonly SETTINGS: "nav.settings";
|
|
175
|
+
};
|
|
176
|
+
|
|
98
177
|
/**
|
|
99
178
|
* Open registry interfaces. Each panel package ships a generated
|
|
100
179
|
* `extension-targets.d.ts` that seeds the built-in ids into these interfaces
|
|
@@ -121,15 +200,28 @@ type NavItemId = keyof NavItemRegistry extends never ? string : keyof NavItemReg
|
|
|
121
200
|
type NavParentId = keyof NavParentRegistry extends never ? string : keyof NavParentRegistry;
|
|
122
201
|
type NavGroupId = keyof NavGroupRegistry extends never ? string : keyof NavGroupRegistry;
|
|
123
202
|
/**
|
|
124
|
-
* A widget is a React component attached to a named zone on a page.
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
203
|
+
* A widget is a React component attached to a named zone on a page. On a
|
|
204
|
+
* composer page the zone is the page prefix (`product.details`) or one of its
|
|
205
|
+
* sections (`product.details.side`); `section`, `order` and `replace` place it
|
|
206
|
+
* among the page's entries. The legacy `before` / `after` zone suffixes still
|
|
207
|
+
* resolve to the first and last position of the section.
|
|
128
208
|
*/
|
|
129
209
|
interface WidgetConfig {
|
|
130
210
|
zone: WidgetZoneId | WidgetZoneId[];
|
|
131
211
|
/** Stable id; derived from the file path at build time when omitted. */
|
|
132
212
|
id?: string;
|
|
213
|
+
/** Section of the page layout to render in; defaults to the zone's section. */
|
|
214
|
+
section?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Sort order among the section's entries. Core entries sit at 0, so a
|
|
217
|
+
* negative order renders before them; unset renders after them.
|
|
218
|
+
*/
|
|
219
|
+
order?: number;
|
|
220
|
+
/**
|
|
221
|
+
* Take the place of a page entry (`core:ProductGeneralSection`). The widget
|
|
222
|
+
* receives `renderDefault` to render what it replaced.
|
|
223
|
+
*/
|
|
224
|
+
replace?: LayoutEntryId;
|
|
133
225
|
/**
|
|
134
226
|
* Permission(s) the actor needs for the widget to render. With several, any
|
|
135
227
|
* one is enough.
|
|
@@ -240,7 +332,14 @@ interface BuiltMercurConfig extends MercurConfig {
|
|
|
240
332
|
backendUrl: string;
|
|
241
333
|
base?: string;
|
|
242
334
|
root: string;
|
|
335
|
+
/** The host app's own `src`, crawled as the last layer. */
|
|
243
336
|
srcDir: string;
|
|
337
|
+
/**
|
|
338
|
+
* The Medusa project's `src/<admin|vendor>`, crawled as the layer between
|
|
339
|
+
* the plugins and the host app. Unset when the folder does not exist.
|
|
340
|
+
*/
|
|
341
|
+
projectDir?: string;
|
|
342
|
+
/** Prebuilt plugin entries, in `medusa-config` plugin order. */
|
|
244
343
|
pluginExtensions: string[];
|
|
245
344
|
imageLimit: number;
|
|
246
345
|
}
|
|
@@ -279,4 +378,4 @@ type RouteHandle = {
|
|
|
279
378
|
breadcrumb?: (match: never) => ReactNode;
|
|
280
379
|
};
|
|
281
380
|
|
|
282
|
-
export { type BuiltMercurConfig as B, type
|
|
381
|
+
export { buildPermission as A, type BuiltMercurConfig as B, CORE_LAYOUT_IDS as C, parsePermission as D, type EntryPreference as E, satisfiesPermission as F, type LayoutComponentProps as L, type MercurConfig as M, NAV_ZONES as N, PERMISSION_RIGHT_RANK as P, type RouteConfig as R, type SectionNameFor as S, type WidgetConfig as W, type ZonePreference as Z, type LayoutConfig as a, type LayoutEntryId as b, type LayoutEntryRegistry as c, type LayoutPreferences as d, type LayoutSection as e, type LayoutSectionRegistry as f, type Layouts as g, type NavGroupConfig as h, type NavGroupId as i, type NavGroupPreference as j, type NavGroupRegistry as k, type NavItemId as l, type NavItemOverride as m, type NavItemRegistry as n, type NavParentId as o, type NavParentRegistry as p, type NavigationConfig as q, type Permission as r, type PermissionKey as s, type PermissionKeys as t, type PermissionMap as u, type PermissionRight as v, type PermissionsContextValue as w, type RouteHandle as x, type WidgetZoneId as y, type WidgetZoneRegistry as z };
|
|
@@ -95,6 +95,85 @@ declare function parsePermission(permission: string): {
|
|
|
95
95
|
declare function buildPermission(key: PermissionKey, right: PermissionRight): Permission;
|
|
96
96
|
declare function satisfiesPermission(permissions: PermissionMap, key: string, right: PermissionRight): boolean;
|
|
97
97
|
|
|
98
|
+
declare const CORE_LAYOUT_IDS: {
|
|
99
|
+
readonly SINGLE_COLUMN: "core:single-column";
|
|
100
|
+
readonly TWO_COLUMN: "core:two-column";
|
|
101
|
+
};
|
|
102
|
+
type LayoutSection = {
|
|
103
|
+
id: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Maps each layout id to the union of section names it renders, so a page's
|
|
107
|
+
* `sections` prop is checked against the layout it picked. A plugin layout
|
|
108
|
+
* registers its sections by augmenting this interface:
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* declare module "@mercurjs/dashboard-sdk" {
|
|
112
|
+
* interface LayoutSectionRegistry {
|
|
113
|
+
* "erp:three-column": "main" | "left" | "right"
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
*/
|
|
117
|
+
interface LayoutSectionRegistry {
|
|
118
|
+
[CORE_LAYOUT_IDS.SINGLE_COLUMN]: "main";
|
|
119
|
+
[CORE_LAYOUT_IDS.TWO_COLUMN]: "main" | "side";
|
|
120
|
+
}
|
|
121
|
+
type Layouts = keyof LayoutSectionRegistry;
|
|
122
|
+
type SectionNameFor<TLayoutId extends Layouts> = LayoutSectionRegistry[TLayoutId];
|
|
123
|
+
type LayoutComponentProps = {
|
|
124
|
+
sections: Record<string, ReactNode>;
|
|
125
|
+
data?: unknown;
|
|
126
|
+
className?: string;
|
|
127
|
+
};
|
|
128
|
+
type LayoutConfig = {
|
|
129
|
+
/** Namespaced id, e.g. `erp:three-column`. `core:` is reserved. */
|
|
130
|
+
id: string;
|
|
131
|
+
sections: LayoutSection[];
|
|
132
|
+
Component: ComponentType<LayoutComponentProps>;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Entry ids a page exposes: `core:<Entry id>` for its own sections,
|
|
136
|
+
* `widget:<widget id>` for injected widgets, `nav:<path>` for sidebar items.
|
|
137
|
+
* Panels seed the built-in ids through `extension-targets`.
|
|
138
|
+
*/
|
|
139
|
+
interface LayoutEntryRegistry {
|
|
140
|
+
}
|
|
141
|
+
type LayoutEntryId = keyof LayoutEntryRegistry extends never ? string : keyof LayoutEntryRegistry;
|
|
142
|
+
type EntryPreference = {
|
|
143
|
+
hidden?: boolean;
|
|
144
|
+
/** Move the entry to another section of the page's layout. */
|
|
145
|
+
section?: string;
|
|
146
|
+
/** Sort order within the section; entries without one keep source order at 0. */
|
|
147
|
+
order?: number;
|
|
148
|
+
/** Sidebar entries only: i18n key or literal replacing the label. */
|
|
149
|
+
label?: string;
|
|
150
|
+
/** Sidebar entries only: icon component replacing the icon. */
|
|
151
|
+
icon?: ComponentType;
|
|
152
|
+
/** Sidebar entries only: re-parent under another item, `null` promotes to top level. */
|
|
153
|
+
parent?: string | null;
|
|
154
|
+
};
|
|
155
|
+
type NavGroupPreference = {
|
|
156
|
+
id: string;
|
|
157
|
+
label?: string;
|
|
158
|
+
translationNs?: string;
|
|
159
|
+
rank?: number;
|
|
160
|
+
hidden?: boolean;
|
|
161
|
+
};
|
|
162
|
+
type ZonePreference = {
|
|
163
|
+
entries?: Record<string, EntryPreference>;
|
|
164
|
+
/** Sidebar zones (`nav.main`, `nav.settings`) only. */
|
|
165
|
+
groups?: NavGroupPreference[];
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Code-level layout preferences, one object per zone prefix. Declared in a
|
|
169
|
+
* layer's `_layouts.ts`; later layers override earlier ones field by field.
|
|
170
|
+
*/
|
|
171
|
+
type LayoutPreferences = Record<string, ZonePreference>;
|
|
172
|
+
declare const NAV_ZONES: {
|
|
173
|
+
readonly MAIN: "nav.main";
|
|
174
|
+
readonly SETTINGS: "nav.settings";
|
|
175
|
+
};
|
|
176
|
+
|
|
98
177
|
/**
|
|
99
178
|
* Open registry interfaces. Each panel package ships a generated
|
|
100
179
|
* `extension-targets.d.ts` that seeds the built-in ids into these interfaces
|
|
@@ -121,15 +200,28 @@ type NavItemId = keyof NavItemRegistry extends never ? string : keyof NavItemReg
|
|
|
121
200
|
type NavParentId = keyof NavParentRegistry extends never ? string : keyof NavParentRegistry;
|
|
122
201
|
type NavGroupId = keyof NavGroupRegistry extends never ? string : keyof NavGroupRegistry;
|
|
123
202
|
/**
|
|
124
|
-
* A widget is a React component attached to a named zone on a page.
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
203
|
+
* A widget is a React component attached to a named zone on a page. On a
|
|
204
|
+
* composer page the zone is the page prefix (`product.details`) or one of its
|
|
205
|
+
* sections (`product.details.side`); `section`, `order` and `replace` place it
|
|
206
|
+
* among the page's entries. The legacy `before` / `after` zone suffixes still
|
|
207
|
+
* resolve to the first and last position of the section.
|
|
128
208
|
*/
|
|
129
209
|
interface WidgetConfig {
|
|
130
210
|
zone: WidgetZoneId | WidgetZoneId[];
|
|
131
211
|
/** Stable id; derived from the file path at build time when omitted. */
|
|
132
212
|
id?: string;
|
|
213
|
+
/** Section of the page layout to render in; defaults to the zone's section. */
|
|
214
|
+
section?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Sort order among the section's entries. Core entries sit at 0, so a
|
|
217
|
+
* negative order renders before them; unset renders after them.
|
|
218
|
+
*/
|
|
219
|
+
order?: number;
|
|
220
|
+
/**
|
|
221
|
+
* Take the place of a page entry (`core:ProductGeneralSection`). The widget
|
|
222
|
+
* receives `renderDefault` to render what it replaced.
|
|
223
|
+
*/
|
|
224
|
+
replace?: LayoutEntryId;
|
|
133
225
|
/**
|
|
134
226
|
* Permission(s) the actor needs for the widget to render. With several, any
|
|
135
227
|
* one is enough.
|
|
@@ -240,7 +332,14 @@ interface BuiltMercurConfig extends MercurConfig {
|
|
|
240
332
|
backendUrl: string;
|
|
241
333
|
base?: string;
|
|
242
334
|
root: string;
|
|
335
|
+
/** The host app's own `src`, crawled as the last layer. */
|
|
243
336
|
srcDir: string;
|
|
337
|
+
/**
|
|
338
|
+
* The Medusa project's `src/<admin|vendor>`, crawled as the layer between
|
|
339
|
+
* the plugins and the host app. Unset when the folder does not exist.
|
|
340
|
+
*/
|
|
341
|
+
projectDir?: string;
|
|
342
|
+
/** Prebuilt plugin entries, in `medusa-config` plugin order. */
|
|
244
343
|
pluginExtensions: string[];
|
|
245
344
|
imageLimit: number;
|
|
246
345
|
}
|
|
@@ -279,4 +378,4 @@ type RouteHandle = {
|
|
|
279
378
|
breadcrumb?: (match: never) => ReactNode;
|
|
280
379
|
};
|
|
281
380
|
|
|
282
|
-
export { type BuiltMercurConfig as B, type
|
|
381
|
+
export { buildPermission as A, type BuiltMercurConfig as B, CORE_LAYOUT_IDS as C, parsePermission as D, type EntryPreference as E, satisfiesPermission as F, type LayoutComponentProps as L, type MercurConfig as M, NAV_ZONES as N, PERMISSION_RIGHT_RANK as P, type RouteConfig as R, type SectionNameFor as S, type WidgetConfig as W, type ZonePreference as Z, type LayoutConfig as a, type LayoutEntryId as b, type LayoutEntryRegistry as c, type LayoutPreferences as d, type LayoutSection as e, type LayoutSectionRegistry as f, type Layouts as g, type NavGroupConfig as h, type NavGroupId as i, type NavGroupPreference as j, type NavGroupRegistry as k, type NavItemId as l, type NavItemOverride as m, type NavItemRegistry as n, type NavParentId as o, type NavParentRegistry as p, type NavigationConfig as q, type Permission as r, type PermissionKey as s, type PermissionKeys as t, type PermissionMap as u, type PermissionRight as v, type PermissionsContextValue as w, type RouteHandle as x, type WidgetZoneId as y, type WidgetZoneRegistry as z };
|