@nestjs-dash/nestjs 0.1.1
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/client/nestjs-dash.js +2126 -0
- package/dist/client/nestjs-dash.js.map +7 -0
- package/dist/controllers/admin-api.controller.d.ts +41 -0
- package/dist/controllers/admin-api.controller.d.ts.map +1 -0
- package/dist/controllers/admin-api.controller.js +299 -0
- package/dist/controllers/admin-api.controller.js.map +1 -0
- package/dist/controllers/admin-auth.controller.d.ts +17 -0
- package/dist/controllers/admin-auth.controller.d.ts.map +1 -0
- package/dist/controllers/admin-auth.controller.js +111 -0
- package/dist/controllers/admin-auth.controller.js.map +1 -0
- package/dist/controllers/admin-upload.controller.d.ts +50 -0
- package/dist/controllers/admin-upload.controller.d.ts.map +1 -0
- package/dist/controllers/admin-upload.controller.js +210 -0
- package/dist/controllers/admin-upload.controller.js.map +1 -0
- package/dist/controllers/admin.controller.d.ts +69 -0
- package/dist/controllers/admin.controller.d.ts.map +1 -0
- package/dist/controllers/admin.controller.js +1062 -0
- package/dist/controllers/admin.controller.js.map +1 -0
- package/dist/decorators/admin-action.decorator.d.ts +4 -0
- package/dist/decorators/admin-action.decorator.d.ts.map +1 -0
- package/dist/decorators/admin-action.decorator.js +6 -0
- package/dist/decorators/admin-action.decorator.js.map +1 -0
- package/dist/decorators/admin-page.decorator.d.ts +3 -0
- package/dist/decorators/admin-page.decorator.d.ts.map +1 -0
- package/dist/decorators/admin-page.decorator.js +6 -0
- package/dist/decorators/admin-page.decorator.js.map +1 -0
- package/dist/decorators/admin-resource.decorator.d.ts +3 -0
- package/dist/decorators/admin-resource.decorator.d.ts.map +1 -0
- package/dist/decorators/admin-resource.decorator.js +6 -0
- package/dist/decorators/admin-resource.decorator.js.map +1 -0
- package/dist/features/audit/audit.interceptor.d.ts +17 -0
- package/dist/features/audit/audit.interceptor.d.ts.map +1 -0
- package/dist/features/audit/audit.interceptor.js +94 -0
- package/dist/features/audit/audit.interceptor.js.map +1 -0
- package/dist/features/audit/index.d.ts +2 -0
- package/dist/features/audit/index.d.ts.map +1 -0
- package/dist/features/audit/index.js +2 -0
- package/dist/features/audit/index.js.map +1 -0
- package/dist/features/auth/auth.types.d.ts +13 -0
- package/dist/features/auth/auth.types.d.ts.map +1 -0
- package/dist/features/auth/auth.types.js +2 -0
- package/dist/features/auth/auth.types.js.map +1 -0
- package/dist/features/auth/index.d.ts +12 -0
- package/dist/features/auth/index.d.ts.map +1 -0
- package/dist/features/auth/index.js +7 -0
- package/dist/features/auth/index.js.map +1 -0
- package/dist/features/auth/public.decorator.d.ts +3 -0
- package/dist/features/auth/public.decorator.d.ts.map +1 -0
- package/dist/features/auth/public.decorator.js +4 -0
- package/dist/features/auth/public.decorator.js.map +1 -0
- package/dist/features/auth/resolvers/credentials.resolver.d.ts +10 -0
- package/dist/features/auth/resolvers/credentials.resolver.d.ts.map +1 -0
- package/dist/features/auth/resolvers/credentials.resolver.js +35 -0
- package/dist/features/auth/resolvers/credentials.resolver.js.map +1 -0
- package/dist/features/auth/resolvers/custom.resolver.d.ts +7 -0
- package/dist/features/auth/resolvers/custom.resolver.d.ts.map +1 -0
- package/dist/features/auth/resolvers/custom.resolver.js +9 -0
- package/dist/features/auth/resolvers/custom.resolver.js.map +1 -0
- package/dist/features/auth/resolvers/jwt.resolver.d.ts +10 -0
- package/dist/features/auth/resolvers/jwt.resolver.d.ts.map +1 -0
- package/dist/features/auth/resolvers/jwt.resolver.js +24 -0
- package/dist/features/auth/resolvers/jwt.resolver.js.map +1 -0
- package/dist/features/auth/resolvers/passport.resolver.d.ts +9 -0
- package/dist/features/auth/resolvers/passport.resolver.d.ts.map +1 -0
- package/dist/features/auth/resolvers/passport.resolver.js +15 -0
- package/dist/features/auth/resolvers/passport.resolver.js.map +1 -0
- package/dist/features/auth/session.d.ts +9 -0
- package/dist/features/auth/session.d.ts.map +1 -0
- package/dist/features/auth/session.js +55 -0
- package/dist/features/auth/session.js.map +1 -0
- package/dist/features/media/enrich.d.ts +13 -0
- package/dist/features/media/enrich.d.ts.map +1 -0
- package/dist/features/media/enrich.js +56 -0
- package/dist/features/media/enrich.js.map +1 -0
- package/dist/features/media/index.d.ts +3 -0
- package/dist/features/media/index.d.ts.map +1 -0
- package/dist/features/media/index.js +3 -0
- package/dist/features/media/index.js.map +1 -0
- package/dist/features/media/media.helpers.d.ts +13 -0
- package/dist/features/media/media.helpers.d.ts.map +1 -0
- package/dist/features/media/media.helpers.js +63 -0
- package/dist/features/media/media.helpers.js.map +1 -0
- package/dist/guards/admin-auth.guard.d.ts +17 -0
- package/dist/guards/admin-auth.guard.d.ts.map +1 -0
- package/dist/guards/admin-auth.guard.js +82 -0
- package/dist/guards/admin-auth.guard.js.map +1 -0
- package/dist/guards/admin-policy.guard.d.ts +10 -0
- package/dist/guards/admin-policy.guard.d.ts.map +1 -0
- package/dist/guards/admin-policy.guard.js +60 -0
- package/dist/guards/admin-policy.guard.js.map +1 -0
- package/dist/helpers/action.helpers.d.ts +6 -0
- package/dist/helpers/action.helpers.d.ts.map +1 -0
- package/dist/helpers/action.helpers.js +14 -0
- package/dist/helpers/action.helpers.js.map +1 -0
- package/dist/helpers/data-source.helpers.d.ts +4 -0
- package/dist/helpers/data-source.helpers.d.ts.map +1 -0
- package/dist/helpers/data-source.helpers.js +14 -0
- package/dist/helpers/data-source.helpers.js.map +1 -0
- package/dist/helpers/icons.d.ts +8 -0
- package/dist/helpers/icons.d.ts.map +1 -0
- package/dist/helpers/icons.js +50 -0
- package/dist/helpers/icons.js.map +1 -0
- package/dist/helpers/nav-collapse.helper.d.ts +6 -0
- package/dist/helpers/nav-collapse.helper.d.ts.map +1 -0
- package/dist/helpers/nav-collapse.helper.js +25 -0
- package/dist/helpers/nav-collapse.helper.js.map +1 -0
- package/dist/helpers/relation.helpers.d.ts +17 -0
- package/dist/helpers/relation.helpers.d.ts.map +1 -0
- package/dist/helpers/relation.helpers.js +98 -0
- package/dist/helpers/relation.helpers.js.map +1 -0
- package/dist/helpers/shell-assets.helper.d.ts +6 -0
- package/dist/helpers/shell-assets.helper.d.ts.map +1 -0
- package/dist/helpers/shell-assets.helper.js +14 -0
- package/dist/helpers/shell-assets.helper.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/admin-api-host.module.d.ts +3 -0
- package/dist/modules/admin-api-host.module.d.ts.map +1 -0
- package/dist/modules/admin-api-host.module.js +17 -0
- package/dist/modules/admin-api-host.module.js.map +1 -0
- package/dist/modules/admin-core.module.d.ts +3 -0
- package/dist/modules/admin-core.module.d.ts.map +1 -0
- package/dist/modules/admin-core.module.js +37 -0
- package/dist/modules/admin-core.module.js.map +1 -0
- package/dist/modules/admin-feature.module.d.ts +3 -0
- package/dist/modules/admin-feature.module.d.ts.map +1 -0
- package/dist/modules/admin-feature.module.js +14 -0
- package/dist/modules/admin-feature.module.js.map +1 -0
- package/dist/modules/admin-ui-host.module.d.ts +3 -0
- package/dist/modules/admin-ui-host.module.d.ts.map +1 -0
- package/dist/modules/admin-ui-host.module.js +19 -0
- package/dist/modules/admin-ui-host.module.js.map +1 -0
- package/dist/modules/admin.module.d.ts +18 -0
- package/dist/modules/admin.module.d.ts.map +1 -0
- package/dist/modules/admin.module.js +197 -0
- package/dist/modules/admin.module.js.map +1 -0
- package/dist/plugin-contracts.d.ts +88 -0
- package/dist/plugin-contracts.d.ts.map +1 -0
- package/dist/plugin-contracts.js +4 -0
- package/dist/plugin-contracts.js.map +1 -0
- package/dist/plugins/openapi/admin-openapi.d.ts +21 -0
- package/dist/plugins/openapi/admin-openapi.d.ts.map +1 -0
- package/dist/plugins/openapi/admin-openapi.js +237 -0
- package/dist/plugins/openapi/admin-openapi.js.map +1 -0
- package/dist/providers/admin-page.explorer.d.ts +8 -0
- package/dist/providers/admin-page.explorer.d.ts.map +1 -0
- package/dist/providers/admin-page.explorer.js +43 -0
- package/dist/providers/admin-page.explorer.js.map +1 -0
- package/dist/providers/admin-page.registry.d.ts +9 -0
- package/dist/providers/admin-page.registry.d.ts.map +1 -0
- package/dist/providers/admin-page.registry.js +39 -0
- package/dist/providers/admin-page.registry.js.map +1 -0
- package/dist/providers/admin-panel.bootstrap.d.ts +23 -0
- package/dist/providers/admin-panel.bootstrap.d.ts.map +1 -0
- package/dist/providers/admin-panel.bootstrap.js +122 -0
- package/dist/providers/admin-panel.bootstrap.js.map +1 -0
- package/dist/providers/admin-resource.explorer.d.ts +8 -0
- package/dist/providers/admin-resource.explorer.d.ts.map +1 -0
- package/dist/providers/admin-resource.explorer.js +43 -0
- package/dist/providers/admin-resource.explorer.js.map +1 -0
- package/dist/providers/admin-resource.registry.d.ts +9 -0
- package/dist/providers/admin-resource.registry.d.ts.map +1 -0
- package/dist/providers/admin-resource.registry.js +39 -0
- package/dist/providers/admin-resource.registry.js.map +1 -0
- package/dist/react/admin-app.d.ts +14 -0
- package/dist/react/admin-app.d.ts.map +1 -0
- package/dist/react/admin-app.js +421 -0
- package/dist/react/admin-app.js.map +1 -0
- package/dist/react/document.d.ts +13 -0
- package/dist/react/document.d.ts.map +1 -0
- package/dist/react/document.js +47 -0
- package/dist/react/document.js.map +1 -0
- package/dist/react/nav-client.d.ts +10 -0
- package/dist/react/nav-client.d.ts.map +1 -0
- package/dist/react/nav-client.js +153 -0
- package/dist/react/nav-client.js.map +1 -0
- package/dist/react/theme.d.ts +6 -0
- package/dist/react/theme.d.ts.map +1 -0
- package/dist/react/theme.js +51 -0
- package/dist/react/theme.js.map +1 -0
- package/dist/react/types.d.ts +107 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/types.js +2 -0
- package/dist/react/types.js.map +1 -0
- package/dist/tokens.d.ts +106 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +74 -0
- package/dist/tokens.js.map +1 -0
- package/dist/views/admin.views.d.ts +114 -0
- package/dist/views/admin.views.d.ts.map +1 -0
- package/dist/views/admin.views.js +212 -0
- package/dist/views/admin.views.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-panel.bootstrap.js","sourceRoot":"","sources":["../../src/providers/admin-panel.bootstrap.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
export declare class AdminResourceExplorer {
|
|
3
|
+
private readonly discovery;
|
|
4
|
+
private readonly reflector;
|
|
5
|
+
constructor(discovery: DiscoveryService, reflector: Reflector);
|
|
6
|
+
discover(): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=admin-resource.explorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-resource.explorer.d.ts","sourceRoot":"","sources":["../../src/providers/admin-resource.explorer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQ3D,qBACa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,SAAS;IAGvC,QAAQ,IAAI,IAAI;CAiBjB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
12
|
+
import { ADMIN_RESOURCE_METADATA } from '../decorators/admin-resource.decorator.js';
|
|
13
|
+
import { registerAdminResources } from './admin-resource.registry.js';
|
|
14
|
+
let AdminResourceExplorer = class AdminResourceExplorer {
|
|
15
|
+
constructor(discovery, reflector) {
|
|
16
|
+
this.discovery = discovery;
|
|
17
|
+
this.reflector = reflector;
|
|
18
|
+
}
|
|
19
|
+
discover() {
|
|
20
|
+
const discovered = [];
|
|
21
|
+
for (const wrapper of this.discovery.getProviders()) {
|
|
22
|
+
const metatype = wrapper.metatype;
|
|
23
|
+
if (!metatype || typeof metatype !== 'function') {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const flagged = this.reflector.get(ADMIN_RESOURCE_METADATA, metatype);
|
|
27
|
+
if (!flagged) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
discovered.push(metatype);
|
|
31
|
+
}
|
|
32
|
+
if (discovered.length) {
|
|
33
|
+
registerAdminResources(discovered);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
AdminResourceExplorer = __decorate([
|
|
38
|
+
Injectable(),
|
|
39
|
+
__metadata("design:paramtypes", [DiscoveryService,
|
|
40
|
+
Reflector])
|
|
41
|
+
], AdminResourceExplorer);
|
|
42
|
+
export { AdminResourceExplorer };
|
|
43
|
+
//# sourceMappingURL=admin-resource.explorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-resource.explorer.js","sourceRoot":"","sources":["../../src/providers/admin-resource.explorer.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAO/D,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YACmB,SAA2B,EAC3B,SAAoB;QADpB,cAAS,GAAT,SAAS,CAAkB;QAC3B,cAAS,GAAT,SAAS,CAAW;IACpC,CAAC;IAEJ,QAAQ;QACN,MAAM,UAAU,GAAoB,EAAE,CAAC;QACvC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,CAAC;YACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YAClC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;gBAChD,SAAS;YACX,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAsB,uBAAuB,EAAE,QAAQ,CAAC,CAAC;YAC3F,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,SAAS;YACX,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,QAAyB,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,sBAAsB,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;CACF,CAAA;AAvBY,qBAAqB;IADjC,UAAU,EAAE;qCAGmB,gBAAgB;QAChB,SAAS;GAH5B,qBAAqB,CAuBjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ResourceClass } from '@nestjs-dash/core';
|
|
2
|
+
export declare class AdminResourceRegistry {
|
|
3
|
+
register(resources: ResourceClass[]): void;
|
|
4
|
+
getResources(): ResourceClass[];
|
|
5
|
+
}
|
|
6
|
+
export declare function registerAdminResources(resources: ResourceClass[]): void;
|
|
7
|
+
export declare function getRegisteredAdminResources(): ResourceClass[];
|
|
8
|
+
export declare function clearRegisteredAdminResources(): void;
|
|
9
|
+
//# sourceMappingURL=admin-resource.registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-resource.registry.d.ts","sourceRoot":"","sources":["../../src/providers/admin-resource.registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAU5E,qBACa,qBAAqB;IAChC,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI;IAI1C,YAAY,IAAI,aAAa,EAAE;CAGhC;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI,CAUvE;AAED,wBAAgB,2BAA2B,IAAI,aAAa,EAAE,CAE7D;AAGD,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { resolveResourceSlug } from '@nestjs-dash/core';
|
|
8
|
+
import { Injectable } from '@nestjs/common';
|
|
9
|
+
const sharedResources = [];
|
|
10
|
+
let AdminResourceRegistry = class AdminResourceRegistry {
|
|
11
|
+
register(resources) {
|
|
12
|
+
registerAdminResources(resources);
|
|
13
|
+
}
|
|
14
|
+
getResources() {
|
|
15
|
+
return getRegisteredAdminResources();
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
AdminResourceRegistry = __decorate([
|
|
19
|
+
Injectable()
|
|
20
|
+
], AdminResourceRegistry);
|
|
21
|
+
export { AdminResourceRegistry };
|
|
22
|
+
export function registerAdminResources(resources) {
|
|
23
|
+
const seen = new Set(sharedResources.map((resource) => resolveResourceSlug(resource)));
|
|
24
|
+
for (const resource of resources) {
|
|
25
|
+
const slug = resolveResourceSlug(resource);
|
|
26
|
+
if (seen.has(slug)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
seen.add(slug);
|
|
30
|
+
sharedResources.push(resource);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function getRegisteredAdminResources() {
|
|
34
|
+
return [...sharedResources];
|
|
35
|
+
}
|
|
36
|
+
export function clearRegisteredAdminResources() {
|
|
37
|
+
sharedResources.length = 0;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=admin-resource.registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-resource.registry.js","sourceRoot":"","sources":["../../src/providers/admin-resource.registry.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAsB,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAO5C,MAAM,eAAe,GAAoB,EAAE,CAAC;AAGrC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,QAAQ,CAAC,SAA0B;QACjC,sBAAsB,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,YAAY;QACV,OAAO,2BAA2B,EAAE,CAAC;IACvC,CAAC;CACF,CAAA;AARY,qBAAqB;IADjC,UAAU,EAAE;GACA,qBAAqB,CAQjC;;AAED,MAAM,UAAU,sBAAsB,CAAC,SAA0B;IAC/D,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACvF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO,CAAC,GAAG,eAAe,CAAC,CAAC;AAC9B,CAAC;AAGD,MAAM,UAAU,6BAA6B;IAC3C,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SchemaNode } from '@nestjs-dash/support';
|
|
2
|
+
import type { AdminPageProps, ListPageProps } from './types.js';
|
|
3
|
+
export declare function RowActions(props: {
|
|
4
|
+
path: string;
|
|
5
|
+
resource: ListPageProps['resource'];
|
|
6
|
+
record: Record<string, unknown>;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export declare function ToolbarActions(props: {
|
|
9
|
+
path: string;
|
|
10
|
+
resource: ListPageProps['resource'];
|
|
11
|
+
}): import("react").JSX.Element | null;
|
|
12
|
+
export declare function AdminApp(props: AdminPageProps): import("react").JSX.Element | null;
|
|
13
|
+
export type { SchemaNode };
|
|
14
|
+
//# sourceMappingURL=admin-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-app.d.ts","sourceRoot":"","sources":["../../src/react/admin-app.tsx"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,KAAK,EACR,cAAc,EAMd,aAAa,EAKhB,MAAM,YAAY,CAAC;AA+UpB,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,+BA0IA;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;CAAE,sCAiE1F;AAujBD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,sCAmB7C;AAGD,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ACTION_COLOR_VARIANT, resolveActionDialog, } from '@nestjs-dash/core';
|
|
3
|
+
import { AdminShell, Alert, AlertDescription, Badge, BADGE_COLOR_CLASSES, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, ChartWidget, ConfirmDialog, DataTable, Icon, ImagePlaceholder, Input, Label, SchemaFields, SchemaForm, Tabs, TabsContent, TabsList, TabsTrigger, ThemeToggle, Tooltip, TooltipContent, TooltipTrigger, } from '@nestjs-dash/design-system';
|
|
4
|
+
import { Fragment, useState } from 'react';
|
|
5
|
+
function imageCellSrc(value) {
|
|
6
|
+
if (value == null || value === '')
|
|
7
|
+
return '';
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(value);
|
|
11
|
+
if (Array.isArray(parsed) && parsed[0] && typeof parsed[0] === 'object') {
|
|
12
|
+
const item = parsed[0];
|
|
13
|
+
return String(item.url || item.path || '');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === 'object' && value !== null) {
|
|
21
|
+
const item = value;
|
|
22
|
+
return String(item.url || item.path || '');
|
|
23
|
+
}
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
function renderListCell(column, record) {
|
|
27
|
+
const name = String(column.name ?? '');
|
|
28
|
+
const raw = record[name];
|
|
29
|
+
if (column.kind === 'image-column') {
|
|
30
|
+
const shape = String(column.props.shape ?? 'square') === 'circle' ? 'circle' : 'square';
|
|
31
|
+
const src = imageCellSrc(raw);
|
|
32
|
+
if (!src) {
|
|
33
|
+
return _jsx(ImagePlaceholder, { shape: shape, size: "sm", "aria-label": `${name} placeholder` });
|
|
34
|
+
}
|
|
35
|
+
const cls = shape === 'circle'
|
|
36
|
+
? 'size-10 rounded-full border border-border object-cover align-middle'
|
|
37
|
+
: 'size-10 rounded-md border border-border object-cover align-middle';
|
|
38
|
+
return _jsx("img", { className: cls, src: src, alt: "" });
|
|
39
|
+
}
|
|
40
|
+
return String(raw ?? '');
|
|
41
|
+
}
|
|
42
|
+
function appendListQueryParams(params, query) {
|
|
43
|
+
if (query?.search)
|
|
44
|
+
params.set('search', query.search);
|
|
45
|
+
if (query?.filter) {
|
|
46
|
+
for (const [key, value] of Object.entries(query.filter)) {
|
|
47
|
+
const raw = Array.isArray(value) ? value[0] : value;
|
|
48
|
+
if (raw != null && String(raw).length > 0) {
|
|
49
|
+
params.set(`filter.${key}`, String(raw));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (query?.filtersOpen)
|
|
54
|
+
params.set('filtersOpen', '1');
|
|
55
|
+
if (query?.withDeleted)
|
|
56
|
+
params.set('withDeleted', '1');
|
|
57
|
+
}
|
|
58
|
+
function serializeSortBy(sortBy) {
|
|
59
|
+
if (!sortBy?.length)
|
|
60
|
+
return undefined;
|
|
61
|
+
return sortBy.map(([column, direction]) => `${column}:${direction}`).join(',');
|
|
62
|
+
}
|
|
63
|
+
function buildListHref(path, slug, query, page, limit) {
|
|
64
|
+
const params = new URLSearchParams();
|
|
65
|
+
appendListQueryParams(params, query);
|
|
66
|
+
const sortBy = serializeSortBy(query?.sortBy);
|
|
67
|
+
if (sortBy)
|
|
68
|
+
params.set('sortBy', sortBy);
|
|
69
|
+
params.set('page', String(page));
|
|
70
|
+
params.set('limit', String(limit));
|
|
71
|
+
return `${path}/${slug}?${params.toString()}`;
|
|
72
|
+
}
|
|
73
|
+
function buildSortHref(path, slug, query, limit, column, direction) {
|
|
74
|
+
const params = new URLSearchParams();
|
|
75
|
+
appendListQueryParams(params, query);
|
|
76
|
+
params.set('sortBy', `${column}:${direction}`);
|
|
77
|
+
params.set('page', '1');
|
|
78
|
+
params.set('limit', String(limit));
|
|
79
|
+
return `${path}/${slug}?${params.toString()}`;
|
|
80
|
+
}
|
|
81
|
+
function DashboardWidgetView({ widget }) {
|
|
82
|
+
if (widget.type === 'chart') {
|
|
83
|
+
return _jsx(ChartWidget, { spec: widget.chart });
|
|
84
|
+
}
|
|
85
|
+
return _jsx("div", { dangerouslySetInnerHTML: { __html: widget.html } });
|
|
86
|
+
}
|
|
87
|
+
function WidgetGrid({ widgets, className = 'mt-6', }) {
|
|
88
|
+
if (widgets.main.length === 0 && widgets.side.length === 0) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return (_jsxs("div", { className: `${className} grid grid-cols-1 gap-4 lg:grid-cols-[2fr_1fr]`, children: [_jsx("div", { className: "flex flex-col gap-4", children: widgets.main.map((widget, index) => (_jsx(DashboardWidgetView, { widget: widget }, index))) }), widgets.side.length > 0 ? (_jsx("div", { className: "flex flex-col gap-4", children: widgets.side.map((widget, index) => (_jsx(DashboardWidgetView, { widget: widget }, index))) })) : null] }));
|
|
92
|
+
}
|
|
93
|
+
function applyThemeClass(mode) {
|
|
94
|
+
const dark = mode === 'dark' || (mode === 'system' && matchMedia('(prefers-color-scheme: dark)').matches);
|
|
95
|
+
document.documentElement.classList.toggle('dark', dark);
|
|
96
|
+
}
|
|
97
|
+
function postJson(url, body) {
|
|
98
|
+
void fetch(url, {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
credentials: 'same-origin',
|
|
101
|
+
headers: { 'content-type': 'application/json' },
|
|
102
|
+
body: JSON.stringify(body),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function useShellControls(props) {
|
|
106
|
+
const [mode, setMode] = useState(props.theme ?? 'system');
|
|
107
|
+
const [, setCollapsed] = useState(() => new Set((props.navigationGroups ?? []).filter((group) => group.collapsed).map((g) => g.label)));
|
|
108
|
+
function handleThemeChange(next) {
|
|
109
|
+
setMode(next);
|
|
110
|
+
applyThemeClass(next);
|
|
111
|
+
postJson(`${props.path}/_/theme`, { theme: next });
|
|
112
|
+
}
|
|
113
|
+
function handleGroupToggle(label, expanded) {
|
|
114
|
+
setCollapsed((prev) => {
|
|
115
|
+
const next = new Set(prev);
|
|
116
|
+
if (expanded) {
|
|
117
|
+
next.delete(label);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
next.add(label);
|
|
121
|
+
}
|
|
122
|
+
postJson(`${props.path}/_/nav-collapse`, { collapsedGroups: Array.from(next) });
|
|
123
|
+
return next;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
header: _jsx(ThemeToggle, { mode: mode, onChange: handleThemeChange }),
|
|
128
|
+
onGroupToggle: handleGroupToggle,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function DashboardPage(props) {
|
|
132
|
+
const shell = useShellControls({
|
|
133
|
+
path: props.path,
|
|
134
|
+
theme: props.theme,
|
|
135
|
+
navigationGroups: props.navigationGroups,
|
|
136
|
+
});
|
|
137
|
+
return (_jsxs(AdminShell, { model: {
|
|
138
|
+
brandName: props.brandName,
|
|
139
|
+
path: props.path,
|
|
140
|
+
navigation: props.navigation,
|
|
141
|
+
navigationGroups: props.navigationGroups,
|
|
142
|
+
breadcrumbs: props.breadcrumbs ?? [{ label: 'Dashboard' }],
|
|
143
|
+
currentSlug: null,
|
|
144
|
+
}, header: shell.header, onGroupToggle: shell.onGroupToggle, children: [_jsxs("div", { className: "mb-6", children: [_jsx("h1", { className: "mb-1.5 text-3xl font-semibold", children: "Dashboard" }), _jsxs("p", { className: "m-0 text-muted-foreground", children: ["Welcome to ", props.brandName, ". Choose a resource to manage your data."] })] }), props.cards.length === 0 ? (_jsx(Card, { children: _jsx(CardContent, { className: "pt-6 text-muted-foreground", children: "No resources registered yet." }) })) : (_jsx("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-4", children: props.cards.map(({ resource, totalItems }) => (_jsxs("a", { href: `${props.path}/${resource.slug}`, className: "block rounded-lg border border-border bg-card p-5 text-inherit no-underline transition-[border-color,box-shadow] hover:border-primary hover:shadow-lg", children: [_jsx("h2", { className: "mb-2 text-base font-semibold", children: resource.label }), _jsx("div", { className: "text-3xl font-bold text-primary", children: totalItems }), _jsx("div", { className: "mt-2 text-sm text-muted-foreground", children: "Open resource \u2192" })] }, resource.slug))) })), props.widgets ? _jsx(WidgetGrid, { widgets: props.widgets }) : null] }));
|
|
145
|
+
}
|
|
146
|
+
function resolveActionVariant(action, fallback) {
|
|
147
|
+
const variant = action.props.variant;
|
|
148
|
+
if (typeof variant === 'string')
|
|
149
|
+
return variant;
|
|
150
|
+
const color = action.props.color;
|
|
151
|
+
if (typeof color === 'string' && color in ACTION_COLOR_VARIANT) {
|
|
152
|
+
return ACTION_COLOR_VARIANT[color];
|
|
153
|
+
}
|
|
154
|
+
return fallback;
|
|
155
|
+
}
|
|
156
|
+
function resolveActionSize(action, fallback) {
|
|
157
|
+
const size = action.props.size;
|
|
158
|
+
return typeof size === 'string' ? size : fallback;
|
|
159
|
+
}
|
|
160
|
+
function ActionButtonBody(props) {
|
|
161
|
+
const { action, icon, label } = props;
|
|
162
|
+
const iconAtEnd = action.props.iconPosition === 'end';
|
|
163
|
+
const badge = action.props.badge;
|
|
164
|
+
return (_jsxs(_Fragment, { children: [!iconAtEnd ? icon : null, label, iconAtEnd ? icon : null, badge?.text ? (_jsx(Badge, { variant: "outline", className: badge.color ? BADGE_COLOR_CLASSES[badge.color] : undefined, children: badge.text })) : null] }));
|
|
165
|
+
}
|
|
166
|
+
function isActionIconOnly(action) {
|
|
167
|
+
return Boolean(action.props.iconOnly);
|
|
168
|
+
}
|
|
169
|
+
function iconOnlySize(size) {
|
|
170
|
+
if (size === 'xs')
|
|
171
|
+
return 'icon-xs';
|
|
172
|
+
if (size === 'sm')
|
|
173
|
+
return 'icon-sm';
|
|
174
|
+
if (size === 'lg')
|
|
175
|
+
return 'icon-lg';
|
|
176
|
+
return 'icon';
|
|
177
|
+
}
|
|
178
|
+
function actionBody(action, icon, label) {
|
|
179
|
+
return isActionIconOnly(action) ? (icon) : (_jsx(ActionButtonBody, { action: action, icon: icon, label: label }));
|
|
180
|
+
}
|
|
181
|
+
function withActionTooltip(action, label, node, key) {
|
|
182
|
+
if (!isActionIconOnly(action)) {
|
|
183
|
+
return key != null ? _jsx(Fragment, { children: node }, key) : node;
|
|
184
|
+
}
|
|
185
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: node }), _jsx(TooltipContent, { children: label })] }, key));
|
|
186
|
+
}
|
|
187
|
+
export function RowActions(props) {
|
|
188
|
+
const id = String(props.record.id ?? '');
|
|
189
|
+
const base = `${props.path}/${props.resource.slug}`;
|
|
190
|
+
const actions = (props.resource.table?.actions ?? []).filter((action) => {
|
|
191
|
+
if (action.kind !== 'restore-action')
|
|
192
|
+
return true;
|
|
193
|
+
const field = props.resource.deletedAtField;
|
|
194
|
+
return field != null && props.record[field] != null;
|
|
195
|
+
});
|
|
196
|
+
return (_jsx("div", { className: "flex flex-wrap items-center gap-1", children: actions.map((action, index) => {
|
|
197
|
+
const label = String(action.props.label ?? action.props.name ?? 'Action');
|
|
198
|
+
const icon = typeof action.props.icon === 'string' ? _jsx(Icon, { name: action.props.icon }) : null;
|
|
199
|
+
const key = `${String(action.kind)}-${String(action.props.name ?? index)}`;
|
|
200
|
+
if (action.kind === 'view-action' || action.props.name === 'view') {
|
|
201
|
+
const variant = resolveActionVariant(action, 'link');
|
|
202
|
+
const size = resolveActionSize(action, 'sm');
|
|
203
|
+
return withActionTooltip(action, label, _jsx(Button, { asChild: true, variant: variant, size: isActionIconOnly(action) ? iconOnlySize(size) : size, children: _jsx("a", { href: `${base}/${id}`, "aria-label": isActionIconOnly(action) ? label : undefined, children: actionBody(action, icon, label) }) }), key);
|
|
204
|
+
}
|
|
205
|
+
if (action.kind === 'edit-action' || action.props.name === 'edit') {
|
|
206
|
+
const variant = resolveActionVariant(action, 'link');
|
|
207
|
+
const size = resolveActionSize(action, 'sm');
|
|
208
|
+
return withActionTooltip(action, label, _jsx(Button, { asChild: true, variant: variant, size: isActionIconOnly(action) ? iconOnlySize(size) : size, children: _jsx("a", { href: `${base}/${id}/edit`, "aria-label": isActionIconOnly(action) ? label : undefined, children: actionBody(action, icon, label) }) }), key);
|
|
209
|
+
}
|
|
210
|
+
const isDelete = action.kind === 'delete-action' || action.props.name === 'delete';
|
|
211
|
+
const formAction = isDelete
|
|
212
|
+
? `${base}/${id}/delete`
|
|
213
|
+
: `${base}/${id}/actions/${String(action.props.name ?? '')}`;
|
|
214
|
+
const dialog = resolveActionDialog(action, {
|
|
215
|
+
heading: isDelete ? 'Delete this record?' : `${label}?`,
|
|
216
|
+
description: isDelete ? 'This cannot be undone.' : undefined,
|
|
217
|
+
submitLabel: label,
|
|
218
|
+
});
|
|
219
|
+
if (dialog) {
|
|
220
|
+
const variant = resolveActionVariant(action, isDelete ? 'destructive' : 'outline');
|
|
221
|
+
const size = resolveActionSize(action, 'sm');
|
|
222
|
+
return (_jsx(ConfirmDialog, { trigger: withActionTooltip(action, label, _jsx(Button, { variant: variant, size: isActionIconOnly(action) ? iconOnlySize(size) : size, "aria-label": isActionIconOnly(action) ? label : undefined, children: actionBody(action, icon, label) })), title: String(dialog.props.heading ?? 'Confirm'), description: dialog.props.description != null ? String(dialog.props.description) : undefined, confirmLabel: String(dialog.props.submitLabel ?? label), confirmVariant: isDelete ? 'destructive' : 'default', formAction: formAction, children: dialog.children?.length ? _jsx(SchemaFields, { fields: dialog.children }) : null }, key));
|
|
223
|
+
}
|
|
224
|
+
if (isDelete) {
|
|
225
|
+
const variant = resolveActionVariant(action, 'destructive');
|
|
226
|
+
const size = resolveActionSize(action, 'sm');
|
|
227
|
+
return withActionTooltip(action, label, _jsx(Button, { asChild: true, variant: variant, size: isActionIconOnly(action) ? iconOnlySize(size) : size, children: _jsx("a", { href: formAction, "aria-label": isActionIconOnly(action) ? label : undefined, children: actionBody(action, icon, label) }) }), key);
|
|
228
|
+
}
|
|
229
|
+
const variant = resolveActionVariant(action, 'outline');
|
|
230
|
+
const size = resolveActionSize(action, 'sm');
|
|
231
|
+
return (_jsx("form", { method: "post", action: formAction, className: "contents", children: withActionTooltip(action, label, _jsx(Button, { type: "submit", variant: variant, size: isActionIconOnly(action) ? iconOnlySize(size) : size, "aria-label": isActionIconOnly(action) ? label : undefined, children: actionBody(action, icon, label) })) }, key));
|
|
232
|
+
}) }));
|
|
233
|
+
}
|
|
234
|
+
export function ToolbarActions(props) {
|
|
235
|
+
const base = `${props.path}/${props.resource.slug}`;
|
|
236
|
+
const actions = props.resource.table?.toolbarActions ?? [];
|
|
237
|
+
if (actions.length === 0)
|
|
238
|
+
return null;
|
|
239
|
+
return (_jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions.map((action, index) => {
|
|
240
|
+
const label = String(action.props.label ?? action.props.name ?? 'Action');
|
|
241
|
+
const icon = typeof action.props.icon === 'string' ? _jsx(Icon, { name: action.props.icon }) : null;
|
|
242
|
+
const key = String(action.props.name ?? index);
|
|
243
|
+
const formAction = `${base}/actions/${String(action.props.name ?? '')}`;
|
|
244
|
+
const dialog = resolveActionDialog(action, { heading: `${label}?`, submitLabel: label });
|
|
245
|
+
if (dialog) {
|
|
246
|
+
const variant = resolveActionVariant(action, 'outline');
|
|
247
|
+
const size = resolveActionSize(action, 'default');
|
|
248
|
+
return (_jsx(ConfirmDialog, { trigger: withActionTooltip(action, label, _jsx(Button, { variant: variant, size: isActionIconOnly(action) ? iconOnlySize(size) : size, "aria-label": isActionIconOnly(action) ? label : undefined, children: actionBody(action, icon, label) })), title: String(dialog.props.heading ?? 'Confirm'), description: dialog.props.description != null ? String(dialog.props.description) : undefined, confirmLabel: String(dialog.props.submitLabel ?? label), formAction: formAction, children: dialog.children?.length ? _jsx(SchemaFields, { fields: dialog.children }) : null }, key));
|
|
249
|
+
}
|
|
250
|
+
const variant = resolveActionVariant(action, 'outline');
|
|
251
|
+
const size = resolveActionSize(action, 'default');
|
|
252
|
+
return (_jsx("form", { method: "post", action: formAction, className: "contents", children: withActionTooltip(action, label, _jsx(Button, { type: "submit", variant: variant, size: isActionIconOnly(action) ? iconOnlySize(size) : size, "aria-label": isActionIconOnly(action) ? label : undefined, children: actionBody(action, icon, label) })) }, key));
|
|
253
|
+
}) }));
|
|
254
|
+
}
|
|
255
|
+
function ListFilters(props) {
|
|
256
|
+
const filters = props.resource.table?.filters ?? [];
|
|
257
|
+
const searchable = (props.resource.listQueryConfig?.searchableColumns?.length ?? 0) > 0 ||
|
|
258
|
+
(props.resource.table?.columns ?? []).some((col) => col.props.searchable === true);
|
|
259
|
+
const filtersOpen = Boolean(props.query?.filtersOpen);
|
|
260
|
+
const action = `${props.path}/${props.resource.slug}`;
|
|
261
|
+
return (_jsxs("div", { className: "flex flex-wrap items-end justify-between gap-3", children: [_jsxs("form", { className: "flex min-w-48 flex-1 flex-wrap items-center gap-2", method: "get", action: action, children: [searchable ? (_jsx(Input, { className: "max-w-xs", name: "search", placeholder: "Search\u2026", defaultValue: props.query?.search ?? '' })) : null, filtersOpen ? _jsx("input", { type: "hidden", name: "filtersOpen", value: "1" }) : null, props.query?.withDeleted ? _jsx("input", { type: "hidden", name: "withDeleted", value: "1" }) : null, _jsx(Button, { type: "submit", variant: "secondary", size: "sm", children: "Search" }), filters.length > 0 ? (_jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsx("a", { href: `${action}?${new URLSearchParams({
|
|
262
|
+
...(props.query?.search ? { search: props.query.search } : {}),
|
|
263
|
+
...(props.query?.withDeleted ? { withDeleted: '1' } : {}),
|
|
264
|
+
filtersOpen: filtersOpen ? '0' : '1',
|
|
265
|
+
}).toString()}`, children: "Filters" }) })) : null, props.resource.supportsSoftDelete ? (_jsx(Button, { asChild: true, variant: props.query?.withDeleted ? 'default' : 'outline', size: "sm", children: _jsx("a", { href: `${action}?${new URLSearchParams({
|
|
266
|
+
...(props.query?.search ? { search: props.query.search } : {}),
|
|
267
|
+
...(filtersOpen ? { filtersOpen: '1' } : {}),
|
|
268
|
+
...(props.query?.withDeleted ? {} : { withDeleted: '1' }),
|
|
269
|
+
}).toString()}`, children: props.query?.withDeleted ? 'Hide trashed' : 'Show trashed' }) })) : null] }), filtersOpen && filters.length > 0 ? (_jsxs("form", { className: "mb-0 w-full rounded-lg border border-border bg-muted/50 p-4", method: "get", action: action, "data-afi-filters": true, children: [props.query?.search ? (_jsx("input", { type: "hidden", name: "search", value: props.query.search })) : null, _jsx("input", { type: "hidden", name: "filtersOpen", value: "1" }), _jsx("div", { className: "mb-4 grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-x-4 gap-y-3", children: filters.map((filter) => {
|
|
270
|
+
const name = String(filter.name ?? filter.props.name ?? '');
|
|
271
|
+
const label = String(filter.props.label ?? name);
|
|
272
|
+
const current = props.query?.filter?.[name];
|
|
273
|
+
const raw = Array.isArray(current) ? current[0] : current;
|
|
274
|
+
if (filter.kind === 'select-filter') {
|
|
275
|
+
const options = filter.props.options ??
|
|
276
|
+
[];
|
|
277
|
+
return (_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: `filter-${name}`, children: label }), _jsxs("select", { id: `filter-${name}`, className: "h-9 w-full rounded-lg border border-input bg-background px-3 text-sm", name: `filter.${name}`, defaultValue: raw != null ? String(raw) : '', children: [_jsx("option", { value: "", children: "Any" }), options.map((option) => (_jsx("option", { value: `$eq:${option.value}`, children: option.label }, option.value)))] })] }, name));
|
|
278
|
+
}
|
|
279
|
+
if (filter.kind === 'date-filter') {
|
|
280
|
+
return (_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: `filter-${name}`, children: label }), _jsx(Input, { id: `filter-${name}`, type: "date", name: `filter.${name}`, defaultValue: raw != null ? String(raw).replace(/^\$eq:/, '') : '' })] }, name));
|
|
281
|
+
}
|
|
282
|
+
return (_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: `filter-${name}`, children: label }), _jsx(Input, { id: `filter-${name}`, name: `filter.${name}`, defaultValue: raw != null ? String(raw) : '' })] }, name));
|
|
283
|
+
}) }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { type: "submit", size: "sm", children: "Apply" }), _jsx(Button, { asChild: true, variant: "secondary", size: "sm", children: _jsx("a", { href: action, children: "Clear" }) })] })] })) : null] }));
|
|
284
|
+
}
|
|
285
|
+
function ListPage(props) {
|
|
286
|
+
const columns = props.resource.table?.columns ?? [];
|
|
287
|
+
const limit = props.meta.itemsPerPage || 20;
|
|
288
|
+
const shell = useShellControls({
|
|
289
|
+
path: props.path,
|
|
290
|
+
theme: props.theme,
|
|
291
|
+
navigationGroups: props.navigationGroups,
|
|
292
|
+
});
|
|
293
|
+
return (_jsxs(AdminShell, { model: {
|
|
294
|
+
brandName: props.brandName,
|
|
295
|
+
path: props.path,
|
|
296
|
+
navigation: props.navigation,
|
|
297
|
+
navigationGroups: props.navigationGroups,
|
|
298
|
+
breadcrumbs: props.breadcrumbs,
|
|
299
|
+
currentSlug: props.resource.slug,
|
|
300
|
+
}, header: shell.header, onGroupToggle: shell.onGroupToggle, children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("h1", { className: "text-2xl font-semibold", children: props.resource.label }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(ToolbarActions, { path: props.path, resource: props.resource }), _jsx(Button, { asChild: true, children: _jsx("a", { href: `${props.path}/${props.resource.slug}/create`, children: "Create" }) })] })] }), props.flash ? (_jsx(Alert, { className: "mb-4", children: _jsx(AlertDescription, { children: props.flash }) })) : null, _jsx(ListFilters, { path: props.path, resource: props.resource, query: props.query }), _jsx(DataTable, { columns: columns, rows: props.records, meta: props.meta, buildHref: (page, nextLimit) => buildListHref(props.path, props.resource.slug, props.query, page, nextLimit), sortBy: props.query?.sortBy, buildSortHref: (column, direction) => buildSortHref(props.path, props.resource.slug, props.query, limit, column, direction), renderCell: renderListCell, renderRowActions: (record) => (_jsx(RowActions, { path: props.path, resource: props.resource, record: record })) }), _jsxs("form", { className: "mt-2 flex items-center gap-2 text-sm text-muted-foreground", method: "get", action: `${props.path}/${props.resource.slug}`, "data-afi-page-size": true, children: [props.query?.search ? (_jsx("input", { type: "hidden", name: "search", value: props.query.search })) : null, props.query?.filtersOpen ? _jsx("input", { type: "hidden", name: "filtersOpen", value: "1" }) : null, props.query?.withDeleted ? _jsx("input", { type: "hidden", name: "withDeleted", value: "1" }) : null, props.query?.filter
|
|
301
|
+
? Object.entries(props.query.filter).map(([key, value]) => {
|
|
302
|
+
const raw = Array.isArray(value) ? value[0] : value;
|
|
303
|
+
return raw != null ? (_jsx("input", { type: "hidden", name: `filter.${key}`, value: String(raw) }, key)) : null;
|
|
304
|
+
})
|
|
305
|
+
: null, props.query?.sortBy?.length ? (_jsx("input", { type: "hidden", name: "sortBy", value: serializeSortBy(props.query.sortBy) })) : null, _jsx("input", { type: "hidden", name: "page", value: "1" }), _jsx(Label, { htmlFor: "afi-limit", children: "Show" }), _jsx("select", { id: "afi-limit", name: "limit", className: "h-8 rounded-md border border-input bg-background px-2 text-sm", defaultValue: String(limit), onChange: (event) => event.currentTarget.form?.requestSubmit(), children: [10, 20, 25, 50, 100]
|
|
306
|
+
.filter((size, _, all) => all.includes(size) || size === limit)
|
|
307
|
+
.concat(limit && ![10, 20, 25, 50, 100].includes(limit) ? [limit] : [])
|
|
308
|
+
.filter((size, index, all) => all.indexOf(size) === index)
|
|
309
|
+
.sort((a, b) => a - b)
|
|
310
|
+
.map((size) => (_jsx("option", { value: size, children: size }, size))) })] })] }));
|
|
311
|
+
}
|
|
312
|
+
function FormPage(props) {
|
|
313
|
+
const schema = props.resource.form ?? { kind: 'schema', props: {}, children: [] };
|
|
314
|
+
const shell = useShellControls({
|
|
315
|
+
path: props.path,
|
|
316
|
+
theme: props.theme,
|
|
317
|
+
navigationGroups: props.navigationGroups,
|
|
318
|
+
});
|
|
319
|
+
return (_jsxs(AdminShell, { model: {
|
|
320
|
+
brandName: props.brandName,
|
|
321
|
+
path: props.path,
|
|
322
|
+
navigation: props.navigation,
|
|
323
|
+
navigationGroups: props.navigationGroups,
|
|
324
|
+
breadcrumbs: props.breadcrumbs,
|
|
325
|
+
currentSlug: props.resource.slug,
|
|
326
|
+
}, header: shell.header, onGroupToggle: shell.onGroupToggle, children: [_jsx("h1", { className: "mb-4 text-2xl font-semibold", children: props.title }), props.errors && Object.keys(props.errors).length > 0 ? (_jsx(Alert, { variant: "destructive", className: "mb-4", children: _jsxs(AlertDescription, { children: [_jsx("p", { className: "mb-1 font-medium", children: "Fix the following and try again:" }), _jsx("ul", { className: "list-inside list-disc", children: Object.entries(props.errors).map(([field, messages]) => (_jsxs("li", { children: [field, ": ", messages.join(', ')] }, field))) })] }) })) : null, _jsx(SchemaForm, { schema: schema, action: props.action, submitLabel: props.submitLabel, values: props.values, fieldOptions: props.fieldOptions, htmlContent: props.htmlContent, uploadUrl: `${props.path}/uploads`, errors: props.errors })] }));
|
|
327
|
+
}
|
|
328
|
+
function ViewPage(props) {
|
|
329
|
+
const columns = props.resource.table?.columns ?? [];
|
|
330
|
+
const shell = useShellControls({
|
|
331
|
+
path: props.path,
|
|
332
|
+
theme: props.theme,
|
|
333
|
+
navigationGroups: props.navigationGroups,
|
|
334
|
+
});
|
|
335
|
+
return (_jsxs(AdminShell, { model: {
|
|
336
|
+
brandName: props.brandName,
|
|
337
|
+
path: props.path,
|
|
338
|
+
navigation: props.navigation,
|
|
339
|
+
navigationGroups: props.navigationGroups,
|
|
340
|
+
breadcrumbs: props.breadcrumbs,
|
|
341
|
+
currentSlug: props.resource.slug,
|
|
342
|
+
}, header: shell.header, onGroupToggle: shell.onGroupToggle, children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("h1", { className: "text-2xl font-semibold", children: props.resource.label }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { asChild: true, variant: "secondary", children: _jsx("a", { href: `${props.path}/${props.resource.slug}/${String(props.record.id)}/edit`, children: "Edit" }) }), _jsx(Button, { asChild: true, variant: "outline", children: _jsx("a", { href: `${props.path}/${props.resource.slug}`, children: "Back" }) })] })] }), _jsx(Card, { children: _jsx(CardContent, { className: "grid gap-3 pt-6", children: columns.map((column) => {
|
|
343
|
+
const name = String(column.name ?? '');
|
|
344
|
+
return (_jsxs("div", { className: "grid grid-cols-[160px_1fr] gap-4 border-b border-border py-3 last:border-0", children: [_jsx("div", { className: "text-sm text-muted-foreground", children: String(column.props.label ?? name) }), _jsx("div", { children: String(props.record[name] ?? '') })] }, name));
|
|
345
|
+
}) }) }), props.panels && props.panels.length > 0 ? (_jsx("div", { className: "mt-6 flex flex-col gap-4", children: props.panels.map((html, index) => (_jsx("div", { dangerouslySetInnerHTML: { __html: html } }, index))) })) : null, (() => {
|
|
346
|
+
const sections = props.relationSections ?? [];
|
|
347
|
+
if (sections.length === 0)
|
|
348
|
+
return null;
|
|
349
|
+
const ownerId = String(props.record.id ?? '');
|
|
350
|
+
const base = `${props.path}/${props.resource.slug}/${ownerId}`;
|
|
351
|
+
const activeSection = sections.find((section) => section.query?.page != null || section.query?.limit != null || section.query?.search) ?? sections[0];
|
|
352
|
+
return (_jsx(Card, { className: "mt-6", children: _jsx(CardContent, { className: "pt-6", children: _jsxs(Tabs, { defaultValue: activeSection.manager.relationship, children: [_jsx(TabsList, { variant: "line", className: "mb-4 w-full justify-start", children: sections.map((section) => (_jsxs(TabsTrigger, { value: section.manager.relationship, children: [section.manager.icon ? _jsx(Icon, { name: section.manager.icon }) : null, section.manager.title] }, section.manager.relationship))) }), sections.map((section) => {
|
|
353
|
+
const prefix = `rm.${section.manager.relationship}`;
|
|
354
|
+
const buildHref = (page, limit) => {
|
|
355
|
+
const params = new URLSearchParams();
|
|
356
|
+
if (section.query?.search)
|
|
357
|
+
params.set(`${prefix}.search`, section.query.search);
|
|
358
|
+
params.set(`${prefix}.page`, String(page));
|
|
359
|
+
params.set(`${prefix}.limit`, String(limit));
|
|
360
|
+
return `${base}?${params.toString()}`;
|
|
361
|
+
};
|
|
362
|
+
const cols = section.manager.table?.columns ?? [];
|
|
363
|
+
return (_jsxs(TabsContent, { value: section.manager.relationship, children: [_jsx(DataTable, { columns: cols, rows: section.records, meta: section.meta, buildHref: buildHref }), _jsxs("form", { className: "mt-2 flex items-center gap-2 text-sm text-muted-foreground", method: "get", action: base, children: [section.query?.search ? (_jsx("input", { type: "hidden", name: `${prefix}.search`, value: section.query.search })) : null, _jsx("input", { type: "hidden", name: `${prefix}.page`, value: "1" }), _jsx(Label, { htmlFor: `${prefix}-limit`, children: "Show" }), _jsx("select", { id: `${prefix}-limit`, name: `${prefix}.limit`, className: "h-8 rounded-md border border-input bg-background px-2 text-sm", defaultValue: String(section.meta.itemsPerPage), children: [10, 20, 25, 50, 100].map((size) => (_jsx("option", { value: size, children: size }, size))) })] })] }, section.manager.relationship));
|
|
364
|
+
})] }) }) }));
|
|
365
|
+
})()] }));
|
|
366
|
+
}
|
|
367
|
+
function CustomPage(props) {
|
|
368
|
+
const shell = useShellControls({
|
|
369
|
+
path: props.path,
|
|
370
|
+
theme: props.theme,
|
|
371
|
+
navigationGroups: props.navigationGroups,
|
|
372
|
+
});
|
|
373
|
+
return (_jsxs(AdminShell, { model: {
|
|
374
|
+
brandName: props.brandName,
|
|
375
|
+
path: props.path,
|
|
376
|
+
navigation: props.navigation,
|
|
377
|
+
navigationGroups: props.navigationGroups,
|
|
378
|
+
breadcrumbs: props.breadcrumbs,
|
|
379
|
+
currentSlug: `pages:${props.slug}`,
|
|
380
|
+
}, header: shell.header, onGroupToggle: shell.onGroupToggle, children: [_jsx("h1", { className: "mb-4 text-2xl font-semibold", children: props.title }), props.content ? _jsx("div", { dangerouslySetInnerHTML: { __html: props.content } }) : null, props.widgets ? _jsx(WidgetGrid, { widgets: props.widgets, className: "mt-4" }) : null] }));
|
|
381
|
+
}
|
|
382
|
+
function RelationPage(props) {
|
|
383
|
+
const shell = useShellControls({
|
|
384
|
+
path: props.path,
|
|
385
|
+
theme: props.theme,
|
|
386
|
+
navigationGroups: props.navigationGroups,
|
|
387
|
+
});
|
|
388
|
+
return (_jsxs(AdminShell, { model: {
|
|
389
|
+
brandName: props.brandName,
|
|
390
|
+
path: props.path,
|
|
391
|
+
navigation: props.navigation,
|
|
392
|
+
navigationGroups: props.navigationGroups,
|
|
393
|
+
breadcrumbs: props.breadcrumbs,
|
|
394
|
+
currentSlug: props.resource.slug,
|
|
395
|
+
}, header: shell.header, onGroupToggle: shell.onGroupToggle, children: [_jsx("h1", { className: "mb-4 text-2xl font-semibold", children: props.title }), props.mode === 'create' && props.form ? (_jsx(SchemaForm, { schema: props.form, action: props.action, submitLabel: "Create", uploadUrl: `${props.path}/uploads` })) : (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: props.mode === 'associate' ? 'Associate' : 'Attach' }) }), _jsx(CardContent, { children: _jsxs("form", { method: "post", action: props.action, className: "grid gap-4", children: [_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Label, { htmlFor: "relatedId", children: "Record" }), _jsxs("select", { id: "relatedId", name: "relatedId", className: "h-9 w-full rounded-lg border border-input bg-background px-3 text-sm", required: true, children: [_jsx("option", { value: "", children: "Select\u2026" }), (props.options ?? []).map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value)))] })] }), _jsx(Button, { type: "submit", children: "Save" })] }) })] }))] }));
|
|
396
|
+
}
|
|
397
|
+
function LoginPage(props) {
|
|
398
|
+
const shell = useShellControls({ path: props.path, theme: props.theme });
|
|
399
|
+
return (_jsxs("div", { className: "relative flex min-h-screen items-center justify-center bg-background p-6 font-sans text-foreground", children: [_jsx("div", { className: "absolute top-4 right-4", children: shell.header }), _jsxs(Card, { className: "w-full max-w-sm", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: props.brandName }), _jsx(CardDescription, { children: "Sign in to continue to the admin panel." })] }), _jsxs(CardContent, { children: [props.error ? (_jsx(Alert, { variant: "destructive", className: "mb-4", children: _jsx(AlertDescription, { children: props.error }) })) : null, _jsxs("form", { method: "post", action: props.action, className: "grid gap-4", children: [props.redirectTo ? (_jsx("input", { type: "hidden", name: "redirect", value: props.redirectTo })) : null, _jsxs("div", { className: "grid gap-2", children: [_jsx(Label, { htmlFor: "email", children: "Email" }), _jsx(Input, { id: "email", name: "email", type: "email", autoComplete: "username", required: true })] }), _jsxs("div", { className: "grid gap-2", children: [_jsx(Label, { htmlFor: "password", children: "Password" }), _jsx(Input, { id: "password", name: "password", type: "password", autoComplete: "current-password", required: true })] }), _jsx(Button, { type: "submit", className: "mt-2 w-full", children: "Sign in" })] })] })] })] }));
|
|
400
|
+
}
|
|
401
|
+
export function AdminApp(props) {
|
|
402
|
+
switch (props.page) {
|
|
403
|
+
case 'dashboard':
|
|
404
|
+
return _jsx(DashboardPage, { ...props });
|
|
405
|
+
case 'list':
|
|
406
|
+
return _jsx(ListPage, { ...props });
|
|
407
|
+
case 'form':
|
|
408
|
+
return _jsx(FormPage, { ...props });
|
|
409
|
+
case 'view':
|
|
410
|
+
return _jsx(ViewPage, { ...props });
|
|
411
|
+
case 'custom':
|
|
412
|
+
return _jsx(CustomPage, { ...props });
|
|
413
|
+
case 'relation':
|
|
414
|
+
return _jsx(RelationPage, { ...props });
|
|
415
|
+
case 'login':
|
|
416
|
+
return _jsx(LoginPage, { ...props });
|
|
417
|
+
default:
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
//# sourceMappingURL=admin-app.js.map
|