@mercurjs/dashboard-sdk 2.3.6-canary.8 → 2.3.6
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.cts +31 -65
- package/dist/index.d.ts +31 -65
- package/dist/{types-Cziny1v0.d.cts → types-BTgTMD_t.d.cts} +94 -1
- package/dist/{types-Cziny1v0.d.ts → types-BTgTMD_t.d.ts} +94 -1
- package/dist/vite.cjs +16 -2
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +16 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,65 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { B as BuiltMercurConfig, M as MercurConfig, P as PERMISSION_RIGHT_RANK,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Open registry interfaces. Each panel package ships a generated
|
|
7
|
-
* `extension-targets.d.ts` that seeds the built-in ids into these interfaces
|
|
8
|
-
* (declaration merging), and a developer augments them by hand to register a
|
|
9
|
-
* zone their own page renders. The helper unions read off the interface keys.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* declare module "@mercurjs/dashboard-sdk" {
|
|
13
|
-
* interface WidgetZoneRegistry {
|
|
14
|
-
* "erp.dashboard.before": true
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
interface WidgetZoneRegistry {
|
|
19
|
-
}
|
|
20
|
-
interface NavItemRegistry {
|
|
21
|
-
}
|
|
22
|
-
interface NavParentRegistry {
|
|
23
|
-
}
|
|
24
|
-
type WidgetZoneId = keyof WidgetZoneRegistry extends never ? string : keyof WidgetZoneRegistry;
|
|
25
|
-
type NavItemId = keyof NavItemRegistry extends never ? string : keyof NavItemRegistry;
|
|
26
|
-
type NavParentId = keyof NavParentRegistry extends never ? string : keyof NavParentRegistry;
|
|
27
|
-
/**
|
|
28
|
-
* A widget is a React component attached to a named zone on a page. The
|
|
29
|
-
* placement (`before | after`) is encoded as the zone-id suffix, so there is no
|
|
30
|
-
* separate rank field — multiple `before`/`after` widgets stack in registration
|
|
31
|
-
* order.
|
|
32
|
-
*/
|
|
33
|
-
interface WidgetConfig {
|
|
34
|
-
zone: WidgetZoneId | WidgetZoneId[];
|
|
35
|
-
/** Stable id; derived from the file path at build time when omitted. */
|
|
36
|
-
id?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Permission(s) the actor needs for the widget to render. With several, any
|
|
39
|
-
* one is enough.
|
|
40
|
-
*/
|
|
41
|
-
permission?: Permission | Permission[];
|
|
42
|
-
}
|
|
43
|
-
/** Override for a single built-in navigation item. */
|
|
44
|
-
interface NavItemOverride {
|
|
45
|
-
id: NavItemId;
|
|
46
|
-
/** Order within the item's parent (or among top-level items). */
|
|
47
|
-
rank?: number;
|
|
48
|
-
/** Remove from the sidebar (route may still be reachable directly). */
|
|
49
|
-
hidden?: boolean;
|
|
50
|
-
/** i18n key or literal replacing the item's label. */
|
|
51
|
-
label?: string;
|
|
52
|
-
/** Icon component replacing the item's icon. */
|
|
53
|
-
icon?: ComponentType;
|
|
54
|
-
/**
|
|
55
|
-
* Re-parent the item: a built-in parent id moves it under that parent's
|
|
56
|
-
* children; `null` promotes a nested item to the top level.
|
|
57
|
-
*/
|
|
58
|
-
nested?: NavParentId | null;
|
|
59
|
-
}
|
|
60
|
-
interface NavigationConfig {
|
|
61
|
-
items: NavItemOverride[];
|
|
62
|
-
}
|
|
1
|
+
import { h as NavigationConfig, W as WidgetConfig } from './types-BTgTMD_t.cjs';
|
|
2
|
+
export { B as BuiltMercurConfig, M as MercurConfig, N as NavGroupConfig, a as NavGroupId, b as NavGroupRegistry, c as NavItemId, d as NavItemOverride, e as NavItemRegistry, f as NavParentId, g as NavParentRegistry, P as PERMISSION_RIGHT_RANK, i as Permission, j as PermissionKey, k as PermissionKeys, l as PermissionMap, m as PermissionRight, n as PermissionsContextValue, R as RouteConfig, o as RouteHandle, p as WidgetZoneId, q as WidgetZoneRegistry, r as buildPermission, s as parsePermission, t as satisfiesPermission } from './types-BTgTMD_t.cjs';
|
|
3
|
+
import { ReactNode, ComponentType } from 'react';
|
|
63
4
|
|
|
64
5
|
/**
|
|
65
6
|
* Minimal structural stand-in for a Zod schema, so the SDK stays free of a zod
|
|
@@ -154,10 +95,35 @@ type CustomColumn = {
|
|
|
154
95
|
value?: unknown;
|
|
155
96
|
}>;
|
|
156
97
|
};
|
|
98
|
+
type CustomListFilterOption = {
|
|
99
|
+
label: string;
|
|
100
|
+
value: unknown;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* ADD (unknown key), REPLACE (built-in key + a full filter definition), or
|
|
104
|
+
* REMOVE (built-in key + `remove: true`) a list filter. Mirrors
|
|
105
|
+
* `CustomDisplayField`: the `key` is the query param the filter writes.
|
|
106
|
+
*/
|
|
107
|
+
type CustomListFilter = ({
|
|
108
|
+
key: string;
|
|
109
|
+
label: string;
|
|
110
|
+
remove?: never;
|
|
111
|
+
} & ({
|
|
112
|
+
type: "select";
|
|
113
|
+
options: CustomListFilterOption[];
|
|
114
|
+
multiple?: boolean;
|
|
115
|
+
searchable?: boolean;
|
|
116
|
+
} | {
|
|
117
|
+
type: "date" | "string" | "number";
|
|
118
|
+
options?: never;
|
|
119
|
+
})) | {
|
|
120
|
+
key: string;
|
|
121
|
+
remove: true;
|
|
122
|
+
};
|
|
157
123
|
type CustomListExtension = {
|
|
158
124
|
columns?: CustomColumn[];
|
|
159
125
|
bulkActions?: SectionAction[];
|
|
160
|
-
filters?:
|
|
126
|
+
filters?: CustomListFilter[];
|
|
161
127
|
viewDefaults?: {
|
|
162
128
|
columnVisibility?: Record<string, boolean>;
|
|
163
129
|
columnOrder?: string[];
|
|
@@ -195,7 +161,7 @@ interface CustomFieldsConfig<TModel extends CustomFieldModel = CustomFieldModel>
|
|
|
195
161
|
}
|
|
196
162
|
|
|
197
163
|
declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
|
|
198
|
-
declare function defineNavigationConfig(config: NavigationConfig): NavigationConfig
|
|
164
|
+
declare function defineNavigationConfig<TGroup extends string = never>(config: NavigationConfig<TGroup>): NavigationConfig<TGroup>;
|
|
199
165
|
declare function defineCustomFieldsConfig<TModel extends CustomFieldModel>(config: CustomFieldsConfig<TModel>): CustomFieldsConfig<TModel>;
|
|
200
166
|
|
|
201
|
-
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
|
|
167
|
+
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 SectionAction, WidgetConfig, defineCustomFieldsConfig, defineNavigationConfig, defineWidgetConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,65 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { B as BuiltMercurConfig, M as MercurConfig, P as PERMISSION_RIGHT_RANK,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Open registry interfaces. Each panel package ships a generated
|
|
7
|
-
* `extension-targets.d.ts` that seeds the built-in ids into these interfaces
|
|
8
|
-
* (declaration merging), and a developer augments them by hand to register a
|
|
9
|
-
* zone their own page renders. The helper unions read off the interface keys.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* declare module "@mercurjs/dashboard-sdk" {
|
|
13
|
-
* interface WidgetZoneRegistry {
|
|
14
|
-
* "erp.dashboard.before": true
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
interface WidgetZoneRegistry {
|
|
19
|
-
}
|
|
20
|
-
interface NavItemRegistry {
|
|
21
|
-
}
|
|
22
|
-
interface NavParentRegistry {
|
|
23
|
-
}
|
|
24
|
-
type WidgetZoneId = keyof WidgetZoneRegistry extends never ? string : keyof WidgetZoneRegistry;
|
|
25
|
-
type NavItemId = keyof NavItemRegistry extends never ? string : keyof NavItemRegistry;
|
|
26
|
-
type NavParentId = keyof NavParentRegistry extends never ? string : keyof NavParentRegistry;
|
|
27
|
-
/**
|
|
28
|
-
* A widget is a React component attached to a named zone on a page. The
|
|
29
|
-
* placement (`before | after`) is encoded as the zone-id suffix, so there is no
|
|
30
|
-
* separate rank field — multiple `before`/`after` widgets stack in registration
|
|
31
|
-
* order.
|
|
32
|
-
*/
|
|
33
|
-
interface WidgetConfig {
|
|
34
|
-
zone: WidgetZoneId | WidgetZoneId[];
|
|
35
|
-
/** Stable id; derived from the file path at build time when omitted. */
|
|
36
|
-
id?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Permission(s) the actor needs for the widget to render. With several, any
|
|
39
|
-
* one is enough.
|
|
40
|
-
*/
|
|
41
|
-
permission?: Permission | Permission[];
|
|
42
|
-
}
|
|
43
|
-
/** Override for a single built-in navigation item. */
|
|
44
|
-
interface NavItemOverride {
|
|
45
|
-
id: NavItemId;
|
|
46
|
-
/** Order within the item's parent (or among top-level items). */
|
|
47
|
-
rank?: number;
|
|
48
|
-
/** Remove from the sidebar (route may still be reachable directly). */
|
|
49
|
-
hidden?: boolean;
|
|
50
|
-
/** i18n key or literal replacing the item's label. */
|
|
51
|
-
label?: string;
|
|
52
|
-
/** Icon component replacing the item's icon. */
|
|
53
|
-
icon?: ComponentType;
|
|
54
|
-
/**
|
|
55
|
-
* Re-parent the item: a built-in parent id moves it under that parent's
|
|
56
|
-
* children; `null` promotes a nested item to the top level.
|
|
57
|
-
*/
|
|
58
|
-
nested?: NavParentId | null;
|
|
59
|
-
}
|
|
60
|
-
interface NavigationConfig {
|
|
61
|
-
items: NavItemOverride[];
|
|
62
|
-
}
|
|
1
|
+
import { h as NavigationConfig, W as WidgetConfig } from './types-BTgTMD_t.js';
|
|
2
|
+
export { B as BuiltMercurConfig, M as MercurConfig, N as NavGroupConfig, a as NavGroupId, b as NavGroupRegistry, c as NavItemId, d as NavItemOverride, e as NavItemRegistry, f as NavParentId, g as NavParentRegistry, P as PERMISSION_RIGHT_RANK, i as Permission, j as PermissionKey, k as PermissionKeys, l as PermissionMap, m as PermissionRight, n as PermissionsContextValue, R as RouteConfig, o as RouteHandle, p as WidgetZoneId, q as WidgetZoneRegistry, r as buildPermission, s as parsePermission, t as satisfiesPermission } from './types-BTgTMD_t.js';
|
|
3
|
+
import { ReactNode, ComponentType } from 'react';
|
|
63
4
|
|
|
64
5
|
/**
|
|
65
6
|
* Minimal structural stand-in for a Zod schema, so the SDK stays free of a zod
|
|
@@ -154,10 +95,35 @@ type CustomColumn = {
|
|
|
154
95
|
value?: unknown;
|
|
155
96
|
}>;
|
|
156
97
|
};
|
|
98
|
+
type CustomListFilterOption = {
|
|
99
|
+
label: string;
|
|
100
|
+
value: unknown;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* ADD (unknown key), REPLACE (built-in key + a full filter definition), or
|
|
104
|
+
* REMOVE (built-in key + `remove: true`) a list filter. Mirrors
|
|
105
|
+
* `CustomDisplayField`: the `key` is the query param the filter writes.
|
|
106
|
+
*/
|
|
107
|
+
type CustomListFilter = ({
|
|
108
|
+
key: string;
|
|
109
|
+
label: string;
|
|
110
|
+
remove?: never;
|
|
111
|
+
} & ({
|
|
112
|
+
type: "select";
|
|
113
|
+
options: CustomListFilterOption[];
|
|
114
|
+
multiple?: boolean;
|
|
115
|
+
searchable?: boolean;
|
|
116
|
+
} | {
|
|
117
|
+
type: "date" | "string" | "number";
|
|
118
|
+
options?: never;
|
|
119
|
+
})) | {
|
|
120
|
+
key: string;
|
|
121
|
+
remove: true;
|
|
122
|
+
};
|
|
157
123
|
type CustomListExtension = {
|
|
158
124
|
columns?: CustomColumn[];
|
|
159
125
|
bulkActions?: SectionAction[];
|
|
160
|
-
filters?:
|
|
126
|
+
filters?: CustomListFilter[];
|
|
161
127
|
viewDefaults?: {
|
|
162
128
|
columnVisibility?: Record<string, boolean>;
|
|
163
129
|
columnOrder?: string[];
|
|
@@ -195,7 +161,7 @@ interface CustomFieldsConfig<TModel extends CustomFieldModel = CustomFieldModel>
|
|
|
195
161
|
}
|
|
196
162
|
|
|
197
163
|
declare function defineWidgetConfig(config: WidgetConfig): WidgetConfig;
|
|
198
|
-
declare function defineNavigationConfig(config: NavigationConfig): NavigationConfig
|
|
164
|
+
declare function defineNavigationConfig<TGroup extends string = never>(config: NavigationConfig<TGroup>): NavigationConfig<TGroup>;
|
|
199
165
|
declare function defineCustomFieldsConfig<TModel extends CustomFieldModel>(config: CustomFieldsConfig<TModel>): CustomFieldsConfig<TModel>;
|
|
200
166
|
|
|
201
|
-
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
|
|
167
|
+
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 SectionAction, WidgetConfig, defineCustomFieldsConfig, defineNavigationConfig, defineWidgetConfig };
|
|
@@ -95,6 +95,93 @@ 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
|
+
/**
|
|
99
|
+
* Open registry interfaces. Each panel package ships a generated
|
|
100
|
+
* `extension-targets.d.ts` that seeds the built-in ids into these interfaces
|
|
101
|
+
* (declaration merging), and a developer augments them by hand to register a
|
|
102
|
+
* zone their own page renders. The helper unions read off the interface keys.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* declare module "@mercurjs/dashboard-sdk" {
|
|
106
|
+
* interface WidgetZoneRegistry {
|
|
107
|
+
* "erp.dashboard.before": true
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
*/
|
|
111
|
+
interface WidgetZoneRegistry {
|
|
112
|
+
}
|
|
113
|
+
interface NavItemRegistry {
|
|
114
|
+
}
|
|
115
|
+
interface NavParentRegistry {
|
|
116
|
+
}
|
|
117
|
+
interface NavGroupRegistry {
|
|
118
|
+
}
|
|
119
|
+
type WidgetZoneId = keyof WidgetZoneRegistry extends never ? string : keyof WidgetZoneRegistry;
|
|
120
|
+
type NavItemId = keyof NavItemRegistry extends never ? string : keyof NavItemRegistry;
|
|
121
|
+
type NavParentId = keyof NavParentRegistry extends never ? string : keyof NavParentRegistry;
|
|
122
|
+
type NavGroupId = keyof NavGroupRegistry extends never ? string : keyof NavGroupRegistry;
|
|
123
|
+
/**
|
|
124
|
+
* A widget is a React component attached to a named zone on a page. The
|
|
125
|
+
* placement (`before | after`) is encoded as the zone-id suffix, so there is no
|
|
126
|
+
* separate rank field — multiple `before`/`after` widgets stack in registration
|
|
127
|
+
* order.
|
|
128
|
+
*/
|
|
129
|
+
interface WidgetConfig {
|
|
130
|
+
zone: WidgetZoneId | WidgetZoneId[];
|
|
131
|
+
/** Stable id; derived from the file path at build time when omitted. */
|
|
132
|
+
id?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Permission(s) the actor needs for the widget to render. With several, any
|
|
135
|
+
* one is enough.
|
|
136
|
+
*/
|
|
137
|
+
permission?: Permission | Permission[];
|
|
138
|
+
/**
|
|
139
|
+
* i18n key or literal naming the tab. Required for a `*.tabs.*` zone, where
|
|
140
|
+
* the widget renders as a tab's panel; ignored elsewhere.
|
|
141
|
+
*/
|
|
142
|
+
label?: string;
|
|
143
|
+
}
|
|
144
|
+
/** Override for a single built-in navigation item. */
|
|
145
|
+
interface NavItemOverride<TGroup extends string = never> {
|
|
146
|
+
id: NavItemId;
|
|
147
|
+
/** Order within the item's parent (or among top-level items). */
|
|
148
|
+
rank?: number;
|
|
149
|
+
/** Remove from the sidebar (route may still be reachable directly). */
|
|
150
|
+
hidden?: boolean;
|
|
151
|
+
/** i18n key or literal replacing the item's label. */
|
|
152
|
+
label?: string;
|
|
153
|
+
/** Icon component replacing the item's icon. */
|
|
154
|
+
icon?: ComponentType;
|
|
155
|
+
/**
|
|
156
|
+
* Re-parent the item: a built-in parent id moves it under that parent's
|
|
157
|
+
* children; `null` promotes a nested item to the top level.
|
|
158
|
+
*/
|
|
159
|
+
nested?: NavParentId | null;
|
|
160
|
+
/**
|
|
161
|
+
* List the item under a group heading: a built-in settings group id or one
|
|
162
|
+
* declared in `groups`. Main sidebar items only join declared groups.
|
|
163
|
+
*/
|
|
164
|
+
group?: NavGroupId | TGroup;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Declares a sidebar group, or overrides a built-in settings group by id. A
|
|
168
|
+
* group renders in whichever sidebar its items live in.
|
|
169
|
+
*/
|
|
170
|
+
interface NavGroupConfig<TId extends string = string> {
|
|
171
|
+
id: NavGroupId | TId;
|
|
172
|
+
/** i18n key (with `translationNs`) or literal. Falls back to the id. */
|
|
173
|
+
label?: string;
|
|
174
|
+
translationNs?: string;
|
|
175
|
+
/** Order among groups, lower first. Built-in settings groups rank 0, 1, 2… */
|
|
176
|
+
rank?: number;
|
|
177
|
+
/** Remove the group and its items from the sidebar. */
|
|
178
|
+
hidden?: boolean;
|
|
179
|
+
}
|
|
180
|
+
interface NavigationConfig<TGroup extends string = never> {
|
|
181
|
+
groups?: NavGroupConfig<TGroup>[];
|
|
182
|
+
items?: NavItemOverride<NoInfer<TGroup>>[];
|
|
183
|
+
}
|
|
184
|
+
|
|
98
185
|
/**
|
|
99
186
|
* Configuration for the Mercur dashboard plugin.
|
|
100
187
|
*
|
|
@@ -162,6 +249,12 @@ type RouteConfig = {
|
|
|
162
249
|
icon?: ComponentType;
|
|
163
250
|
rank?: number;
|
|
164
251
|
nested?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Sidebar group to list the route under: one declared in `_navigation.ts`
|
|
254
|
+
* or, for a `/settings/*` route, a built-in settings group. Must be a
|
|
255
|
+
* string literal.
|
|
256
|
+
*/
|
|
257
|
+
group?: NavGroupId | (string & {});
|
|
165
258
|
translationNs?: string;
|
|
166
259
|
public?: boolean;
|
|
167
260
|
/**
|
|
@@ -186,4 +279,4 @@ type RouteHandle = {
|
|
|
186
279
|
breadcrumb?: (match: never) => ReactNode;
|
|
187
280
|
};
|
|
188
281
|
|
|
189
|
-
export { type BuiltMercurConfig as B, type MercurConfig as M, PERMISSION_RIGHT_RANK as P, type RouteConfig as R, type
|
|
282
|
+
export { type BuiltMercurConfig as B, type MercurConfig as M, type NavGroupConfig as N, PERMISSION_RIGHT_RANK as P, type RouteConfig as R, type WidgetConfig as W, type NavGroupId as a, type NavGroupRegistry as b, type NavItemId as c, type NavItemOverride as d, type NavItemRegistry as e, type NavParentId as f, type NavParentRegistry as g, type NavigationConfig as h, type Permission as i, type PermissionKey as j, type PermissionKeys as k, type PermissionMap as l, type PermissionRight as m, type PermissionsContextValue as n, type RouteHandle as o, type WidgetZoneId as p, type WidgetZoneRegistry as q, buildPermission as r, parsePermission as s, satisfiesPermission as t };
|
|
@@ -95,6 +95,93 @@ 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
|
+
/**
|
|
99
|
+
* Open registry interfaces. Each panel package ships a generated
|
|
100
|
+
* `extension-targets.d.ts` that seeds the built-in ids into these interfaces
|
|
101
|
+
* (declaration merging), and a developer augments them by hand to register a
|
|
102
|
+
* zone their own page renders. The helper unions read off the interface keys.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* declare module "@mercurjs/dashboard-sdk" {
|
|
106
|
+
* interface WidgetZoneRegistry {
|
|
107
|
+
* "erp.dashboard.before": true
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
*/
|
|
111
|
+
interface WidgetZoneRegistry {
|
|
112
|
+
}
|
|
113
|
+
interface NavItemRegistry {
|
|
114
|
+
}
|
|
115
|
+
interface NavParentRegistry {
|
|
116
|
+
}
|
|
117
|
+
interface NavGroupRegistry {
|
|
118
|
+
}
|
|
119
|
+
type WidgetZoneId = keyof WidgetZoneRegistry extends never ? string : keyof WidgetZoneRegistry;
|
|
120
|
+
type NavItemId = keyof NavItemRegistry extends never ? string : keyof NavItemRegistry;
|
|
121
|
+
type NavParentId = keyof NavParentRegistry extends never ? string : keyof NavParentRegistry;
|
|
122
|
+
type NavGroupId = keyof NavGroupRegistry extends never ? string : keyof NavGroupRegistry;
|
|
123
|
+
/**
|
|
124
|
+
* A widget is a React component attached to a named zone on a page. The
|
|
125
|
+
* placement (`before | after`) is encoded as the zone-id suffix, so there is no
|
|
126
|
+
* separate rank field — multiple `before`/`after` widgets stack in registration
|
|
127
|
+
* order.
|
|
128
|
+
*/
|
|
129
|
+
interface WidgetConfig {
|
|
130
|
+
zone: WidgetZoneId | WidgetZoneId[];
|
|
131
|
+
/** Stable id; derived from the file path at build time when omitted. */
|
|
132
|
+
id?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Permission(s) the actor needs for the widget to render. With several, any
|
|
135
|
+
* one is enough.
|
|
136
|
+
*/
|
|
137
|
+
permission?: Permission | Permission[];
|
|
138
|
+
/**
|
|
139
|
+
* i18n key or literal naming the tab. Required for a `*.tabs.*` zone, where
|
|
140
|
+
* the widget renders as a tab's panel; ignored elsewhere.
|
|
141
|
+
*/
|
|
142
|
+
label?: string;
|
|
143
|
+
}
|
|
144
|
+
/** Override for a single built-in navigation item. */
|
|
145
|
+
interface NavItemOverride<TGroup extends string = never> {
|
|
146
|
+
id: NavItemId;
|
|
147
|
+
/** Order within the item's parent (or among top-level items). */
|
|
148
|
+
rank?: number;
|
|
149
|
+
/** Remove from the sidebar (route may still be reachable directly). */
|
|
150
|
+
hidden?: boolean;
|
|
151
|
+
/** i18n key or literal replacing the item's label. */
|
|
152
|
+
label?: string;
|
|
153
|
+
/** Icon component replacing the item's icon. */
|
|
154
|
+
icon?: ComponentType;
|
|
155
|
+
/**
|
|
156
|
+
* Re-parent the item: a built-in parent id moves it under that parent's
|
|
157
|
+
* children; `null` promotes a nested item to the top level.
|
|
158
|
+
*/
|
|
159
|
+
nested?: NavParentId | null;
|
|
160
|
+
/**
|
|
161
|
+
* List the item under a group heading: a built-in settings group id or one
|
|
162
|
+
* declared in `groups`. Main sidebar items only join declared groups.
|
|
163
|
+
*/
|
|
164
|
+
group?: NavGroupId | TGroup;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Declares a sidebar group, or overrides a built-in settings group by id. A
|
|
168
|
+
* group renders in whichever sidebar its items live in.
|
|
169
|
+
*/
|
|
170
|
+
interface NavGroupConfig<TId extends string = string> {
|
|
171
|
+
id: NavGroupId | TId;
|
|
172
|
+
/** i18n key (with `translationNs`) or literal. Falls back to the id. */
|
|
173
|
+
label?: string;
|
|
174
|
+
translationNs?: string;
|
|
175
|
+
/** Order among groups, lower first. Built-in settings groups rank 0, 1, 2… */
|
|
176
|
+
rank?: number;
|
|
177
|
+
/** Remove the group and its items from the sidebar. */
|
|
178
|
+
hidden?: boolean;
|
|
179
|
+
}
|
|
180
|
+
interface NavigationConfig<TGroup extends string = never> {
|
|
181
|
+
groups?: NavGroupConfig<TGroup>[];
|
|
182
|
+
items?: NavItemOverride<NoInfer<TGroup>>[];
|
|
183
|
+
}
|
|
184
|
+
|
|
98
185
|
/**
|
|
99
186
|
* Configuration for the Mercur dashboard plugin.
|
|
100
187
|
*
|
|
@@ -162,6 +249,12 @@ type RouteConfig = {
|
|
|
162
249
|
icon?: ComponentType;
|
|
163
250
|
rank?: number;
|
|
164
251
|
nested?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Sidebar group to list the route under: one declared in `_navigation.ts`
|
|
254
|
+
* or, for a `/settings/*` route, a built-in settings group. Must be a
|
|
255
|
+
* string literal.
|
|
256
|
+
*/
|
|
257
|
+
group?: NavGroupId | (string & {});
|
|
165
258
|
translationNs?: string;
|
|
166
259
|
public?: boolean;
|
|
167
260
|
/**
|
|
@@ -186,4 +279,4 @@ type RouteHandle = {
|
|
|
186
279
|
breadcrumb?: (match: never) => ReactNode;
|
|
187
280
|
};
|
|
188
281
|
|
|
189
|
-
export { type BuiltMercurConfig as B, type MercurConfig as M, PERMISSION_RIGHT_RANK as P, type RouteConfig as R, type
|
|
282
|
+
export { type BuiltMercurConfig as B, type MercurConfig as M, type NavGroupConfig as N, PERMISSION_RIGHT_RANK as P, type RouteConfig as R, type WidgetConfig as W, type NavGroupId as a, type NavGroupRegistry as b, type NavItemId as c, type NavItemOverride as d, type NavItemRegistry as e, type NavParentId as f, type NavParentRegistry as g, type NavigationConfig as h, type Permission as i, type PermissionKey as j, type PermissionKeys as k, type PermissionMap as l, type PermissionRight as m, type PermissionsContextValue as n, type RouteHandle as o, type WidgetZoneId as p, type WidgetZoneRegistry as q, buildPermission as r, parsePermission as s, satisfiesPermission as t };
|
package/dist/vite.cjs
CHANGED
|
@@ -464,6 +464,13 @@ function processConfigProperties(properties) {
|
|
|
464
464
|
if (nested && (0, import_types.isObjectProperty)(nested) && (0, import_types.isStringLiteral)(nested.value)) {
|
|
465
465
|
nestedValue = nested.value.value;
|
|
466
466
|
}
|
|
467
|
+
const group = properties.find(
|
|
468
|
+
(prop) => (0, import_types.isObjectProperty)(prop) && (0, import_types.isIdentifier)(prop.key, { name: "group" })
|
|
469
|
+
);
|
|
470
|
+
let groupValue;
|
|
471
|
+
if (group && (0, import_types.isObjectProperty)(group) && (0, import_types.isStringLiteral)(group.value)) {
|
|
472
|
+
groupValue = group.value.value;
|
|
473
|
+
}
|
|
467
474
|
const translationNs = properties.find(
|
|
468
475
|
(prop) => (0, import_types.isObjectProperty)(prop) && (0, import_types.isIdentifier)(prop.key, { name: "translationNs" })
|
|
469
476
|
);
|
|
@@ -490,6 +497,7 @@ function processConfigProperties(properties) {
|
|
|
490
497
|
icon: hasIcon,
|
|
491
498
|
rank: rankValue,
|
|
492
499
|
nested: nestedValue,
|
|
500
|
+
group: groupValue,
|
|
493
501
|
translationNs: translationNsValue,
|
|
494
502
|
// Referenced by identifier at runtime rather than extracted here, so
|
|
495
503
|
// the array may be computed instead of a string-literal list.
|
|
@@ -539,6 +547,7 @@ function generateMenuItem(config, file, routesDir, index) {
|
|
|
539
547
|
path: getRoute2(file, routesDir),
|
|
540
548
|
rank: config.rank,
|
|
541
549
|
nested: config.nested,
|
|
550
|
+
group: config.group,
|
|
542
551
|
translationNs: config.translationNs ? `${configName}.translationNs` : void 0,
|
|
543
552
|
permissions: config.permissions ? `${configName}.permissions` : void 0,
|
|
544
553
|
requireAll: config.requireAll
|
|
@@ -551,6 +560,7 @@ function formatMenuItem(menuItem) {
|
|
|
551
560
|
` path: "${menuItem.path}"`,
|
|
552
561
|
` rank: ${menuItem.rank !== void 0 ? menuItem.rank : "undefined"}`,
|
|
553
562
|
` nested: ${menuItem.nested ? `"${menuItem.nested}"` : "undefined"}`,
|
|
563
|
+
` group: ${menuItem.group ? JSON.stringify(menuItem.group) : "undefined"}`,
|
|
554
564
|
` translationNs: ${menuItem.translationNs || "undefined"}`,
|
|
555
565
|
` permissions: ${menuItem.permissions || "undefined"}`,
|
|
556
566
|
` requireAll: ${menuItem.requireAll !== void 0 ? menuItem.requireAll : "undefined"}`
|
|
@@ -678,6 +688,7 @@ function readWidgetConfig(properties) {
|
|
|
678
688
|
const zones = [];
|
|
679
689
|
const permissions = [];
|
|
680
690
|
let id;
|
|
691
|
+
let label;
|
|
681
692
|
for (const prop of properties) {
|
|
682
693
|
if (!(0, import_types.isObjectProperty)(prop)) continue;
|
|
683
694
|
if ((0, import_types.isIdentifier)(prop.key, { name: "zone" })) {
|
|
@@ -689,9 +700,12 @@ function readWidgetConfig(properties) {
|
|
|
689
700
|
if ((0, import_types.isIdentifier)(prop.key, { name: "id" }) && (0, import_types.isStringLiteral)(prop.value)) {
|
|
690
701
|
id = prop.value.value;
|
|
691
702
|
}
|
|
703
|
+
if ((0, import_types.isIdentifier)(prop.key, { name: "label" }) && (0, import_types.isStringLiteral)(prop.value)) {
|
|
704
|
+
label = prop.value.value;
|
|
705
|
+
}
|
|
692
706
|
}
|
|
693
707
|
if (zones.length === 0) return null;
|
|
694
|
-
return { zones, id, permissions };
|
|
708
|
+
return { zones, id, label, permissions };
|
|
695
709
|
}
|
|
696
710
|
function getConfigProperties(node) {
|
|
697
711
|
if ((0, import_types.isCallExpression)(node) && node.arguments.length > 0 && (0, import_types.isObjectExpression)(node.arguments[0])) {
|
|
@@ -755,7 +769,7 @@ function parseWidgetFile(file, widgetsDir, index) {
|
|
|
755
769
|
import: `import ${name} from "${importPath}"`,
|
|
756
770
|
entry: ` { Component: ${name}, zone: ${zonesLiteral}, widgetId: ${JSON.stringify(
|
|
757
771
|
id
|
|
758
|
-
)}${info.permissions.length ? `, permission: ${JSON.stringify(info.permissions)}` : ""} }`
|
|
772
|
+
)}${info.label ? `, label: ${JSON.stringify(info.label)}` : ""}${info.permissions.length ? `, permission: ${JSON.stringify(info.permissions)}` : ""} }`
|
|
759
773
|
};
|
|
760
774
|
}
|
|
761
775
|
function collectWidgets(srcDir, startIndex = 0) {
|
package/dist/vite.d.cts
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
|
@@ -444,6 +444,13 @@ function processConfigProperties(properties) {
|
|
|
444
444
|
if (nested && isObjectProperty(nested) && isStringLiteral(nested.value)) {
|
|
445
445
|
nestedValue = nested.value.value;
|
|
446
446
|
}
|
|
447
|
+
const group = properties.find(
|
|
448
|
+
(prop) => isObjectProperty(prop) && isIdentifier(prop.key, { name: "group" })
|
|
449
|
+
);
|
|
450
|
+
let groupValue;
|
|
451
|
+
if (group && isObjectProperty(group) && isStringLiteral(group.value)) {
|
|
452
|
+
groupValue = group.value.value;
|
|
453
|
+
}
|
|
447
454
|
const translationNs = properties.find(
|
|
448
455
|
(prop) => isObjectProperty(prop) && isIdentifier(prop.key, { name: "translationNs" })
|
|
449
456
|
);
|
|
@@ -470,6 +477,7 @@ function processConfigProperties(properties) {
|
|
|
470
477
|
icon: hasIcon,
|
|
471
478
|
rank: rankValue,
|
|
472
479
|
nested: nestedValue,
|
|
480
|
+
group: groupValue,
|
|
473
481
|
translationNs: translationNsValue,
|
|
474
482
|
// Referenced by identifier at runtime rather than extracted here, so
|
|
475
483
|
// the array may be computed instead of a string-literal list.
|
|
@@ -519,6 +527,7 @@ function generateMenuItem(config, file, routesDir, index) {
|
|
|
519
527
|
path: getRoute2(file, routesDir),
|
|
520
528
|
rank: config.rank,
|
|
521
529
|
nested: config.nested,
|
|
530
|
+
group: config.group,
|
|
522
531
|
translationNs: config.translationNs ? `${configName}.translationNs` : void 0,
|
|
523
532
|
permissions: config.permissions ? `${configName}.permissions` : void 0,
|
|
524
533
|
requireAll: config.requireAll
|
|
@@ -531,6 +540,7 @@ function formatMenuItem(menuItem) {
|
|
|
531
540
|
` path: "${menuItem.path}"`,
|
|
532
541
|
` rank: ${menuItem.rank !== void 0 ? menuItem.rank : "undefined"}`,
|
|
533
542
|
` nested: ${menuItem.nested ? `"${menuItem.nested}"` : "undefined"}`,
|
|
543
|
+
` group: ${menuItem.group ? JSON.stringify(menuItem.group) : "undefined"}`,
|
|
534
544
|
` translationNs: ${menuItem.translationNs || "undefined"}`,
|
|
535
545
|
` permissions: ${menuItem.permissions || "undefined"}`,
|
|
536
546
|
` requireAll: ${menuItem.requireAll !== void 0 ? menuItem.requireAll : "undefined"}`
|
|
@@ -658,6 +668,7 @@ function readWidgetConfig(properties) {
|
|
|
658
668
|
const zones = [];
|
|
659
669
|
const permissions = [];
|
|
660
670
|
let id;
|
|
671
|
+
let label;
|
|
661
672
|
for (const prop of properties) {
|
|
662
673
|
if (!isObjectProperty(prop)) continue;
|
|
663
674
|
if (isIdentifier(prop.key, { name: "zone" })) {
|
|
@@ -669,9 +680,12 @@ function readWidgetConfig(properties) {
|
|
|
669
680
|
if (isIdentifier(prop.key, { name: "id" }) && isStringLiteral(prop.value)) {
|
|
670
681
|
id = prop.value.value;
|
|
671
682
|
}
|
|
683
|
+
if (isIdentifier(prop.key, { name: "label" }) && isStringLiteral(prop.value)) {
|
|
684
|
+
label = prop.value.value;
|
|
685
|
+
}
|
|
672
686
|
}
|
|
673
687
|
if (zones.length === 0) return null;
|
|
674
|
-
return { zones, id, permissions };
|
|
688
|
+
return { zones, id, label, permissions };
|
|
675
689
|
}
|
|
676
690
|
function getConfigProperties(node) {
|
|
677
691
|
if (isCallExpression(node) && node.arguments.length > 0 && isObjectExpression(node.arguments[0])) {
|
|
@@ -735,7 +749,7 @@ function parseWidgetFile(file, widgetsDir, index) {
|
|
|
735
749
|
import: `import ${name} from "${importPath}"`,
|
|
736
750
|
entry: ` { Component: ${name}, zone: ${zonesLiteral}, widgetId: ${JSON.stringify(
|
|
737
751
|
id
|
|
738
|
-
)}${info.permissions.length ? `, permission: ${JSON.stringify(info.permissions)}` : ""} }`
|
|
752
|
+
)}${info.label ? `, label: ${JSON.stringify(info.label)}` : ""}${info.permissions.length ? `, permission: ${JSON.stringify(info.permissions)}` : ""} }`
|
|
739
753
|
};
|
|
740
754
|
}
|
|
741
755
|
function collectWidgets(srcDir, startIndex = 0) {
|