@nestjs-dash/core 0.0.1 → 0.1.0
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/LICENSE +21 -0
- package/README.md +23 -23
- package/dist/actions/handlers.d.ts +1 -1
- package/dist/actions/index.d.ts +25 -25
- package/dist/actions/index.js +93 -93
- package/dist/charts/index.d.ts +6 -6
- package/dist/charts/index.js +15 -15
- package/dist/forms/index.d.ts +24 -24
- package/dist/forms/index.js +76 -76
- package/dist/forms/json-fields.d.ts +1 -1
- package/dist/forms/json-fields.js +15 -15
- package/dist/forms/validation.d.ts +2 -2
- package/dist/forms/validation.js +2 -2
- package/dist/index.d.ts +29 -29
- package/dist/index.js +51 -51
- package/dist/schemas/index.d.ts +10 -10
- package/dist/schemas/index.js +22 -22
- package/dist/tables/index.d.ts +12 -12
- package/dist/tables/index.js +15 -15
- package/dist/tables/list-query-config.d.ts +3 -3
- package/dist/tables/list-query-config.js +4 -4
- package/package.json +21 -21
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nestjs-dash
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -13,46 +13,46 @@ pnpm add @nestjs-dash/core
|
|
|
13
13
|
## Example resource
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import { Resource, TextColumn, TextInput, type Schema, type Table } from
|
|
16
|
+
import { Resource, TextColumn, TextInput, type Schema, type Table } from "@nestjs-dash/core";
|
|
17
17
|
|
|
18
18
|
export class UserResource extends Resource {
|
|
19
|
-
static override slug =
|
|
20
|
-
static override label =
|
|
19
|
+
static override slug = "users";
|
|
20
|
+
static override label = "User";
|
|
21
21
|
|
|
22
22
|
static override table(table: Table) {
|
|
23
23
|
return table.columns([
|
|
24
|
-
TextColumn.make(
|
|
25
|
-
TextColumn.make(
|
|
24
|
+
TextColumn.make("id").sortable(),
|
|
25
|
+
TextColumn.make("email").searchable().sortable(),
|
|
26
26
|
]);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
static override form(form: Schema) {
|
|
30
|
-
return form.components([TextInput.make(
|
|
30
|
+
return form.components([TextInput.make("email").email().required()]);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
## Field builders
|
|
36
36
|
|
|
37
|
-
| Field
|
|
38
|
-
|
|
39
|
-
| `TextInput`
|
|
40
|
-
| `Textarea`
|
|
41
|
-
| `Select`
|
|
42
|
-
| `Radio`
|
|
43
|
-
| `Checkbox` / `Toggle`
|
|
44
|
-
| `DatePicker` / `DateTimePicker` | native `date` / `datetime-local` inputs
|
|
45
|
-
| `ColorPicker`
|
|
46
|
-
| `CodeEditor`
|
|
47
|
-
| `TagsInput`
|
|
48
|
-
| `RichEditor`
|
|
49
|
-
| `ImageUpload` / `FileUpload`
|
|
50
|
-
| `Repeater`
|
|
37
|
+
| Field | Notes |
|
|
38
|
+
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| `TextInput` | text/email/password, `.icon()`/`.prefix()`/`.suffix()` |
|
|
40
|
+
| `Textarea` | |
|
|
41
|
+
| `Select` | static `.options()` or `.relationship()` (BelongsTo, loaded at runtime) |
|
|
42
|
+
| `Radio` | same `.options()` shape as `Select`, rendered as a radio group |
|
|
43
|
+
| `Checkbox` / `Toggle` | |
|
|
44
|
+
| `DatePicker` / `DateTimePicker` | native `date` / `datetime-local` inputs |
|
|
45
|
+
| `ColorPicker` | native `color` input |
|
|
46
|
+
| `CodeEditor` | monospace textarea with a `.language()` caption (no syntax highlighting) |
|
|
47
|
+
| `TagsInput` | chip input, submits a JSON array |
|
|
48
|
+
| `RichEditor` | markdown-toolbar-over-textarea — not a WYSIWYG editor |
|
|
49
|
+
| `ImageUpload` / `FileUpload` | share `disk()`/`directory()`/`visibility()`/`acceptedFileTypes()`/`maxSize()`; `ImageUpload` adds `shape()`/`croppable()`/`aspectRatio()`/`collection()` |
|
|
50
|
+
| `Repeater` | repeatable field group (`.schema([...])` of `TextInput`/`Textarea`/`Select`/`Checkbox`/`Toggle`), with `.minItems()`/`.maxItems()` |
|
|
51
51
|
|
|
52
52
|
Inputs accept an icon and text prefix/suffix:
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
|
-
TextInput.make(
|
|
55
|
+
TextInput.make("price").icon("dollar-sign").prefix("$").suffix("USD");
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
## Actions
|
|
@@ -60,8 +60,8 @@ TextInput.make('price').icon('dollar-sign').prefix('$').suffix('USD');
|
|
|
60
60
|
`Action` and its `EditAction`/`DeleteAction`/`BulkAction`/… subclasses support an icon position, a badge, a size, and an explicit variant — `.color()` maps to a Button variant (`primary`→`default`, `danger`→`destructive`, `gray`→`outline`, `success`/`warning`→matching variants):
|
|
61
61
|
|
|
62
62
|
```ts
|
|
63
|
-
Action.make(
|
|
64
|
-
Action.make(
|
|
63
|
+
Action.make("promote").icon("star").iconPosition("end").badge(3, "red").color("warning");
|
|
64
|
+
Action.make("refresh").icon("refresh-cw").iconOnly(); // tooltip'd icon-only button
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
## Charts
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { BadgeColor, SchemaNode } from
|
|
2
|
-
import { ComponentBuilder } from
|
|
3
|
-
import { type ActionHandler } from
|
|
4
|
-
export type ActionColor =
|
|
5
|
-
export type ActionButtonVariant =
|
|
6
|
-
export type ActionButtonSize =
|
|
1
|
+
import type { BadgeColor, SchemaNode } from "@nestjs-dash/support";
|
|
2
|
+
import { ComponentBuilder } from "../schemas/index.js";
|
|
3
|
+
import { type ActionHandler } from "./handlers.js";
|
|
4
|
+
export type ActionColor = "primary" | "danger" | "gray" | "success" | "warning";
|
|
5
|
+
export type ActionButtonVariant = "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "success" | "warning";
|
|
6
|
+
export type ActionButtonSize = "xs" | "sm" | "default" | "lg";
|
|
7
7
|
export declare const ACTION_COLOR_VARIANT: Record<ActionColor, ActionButtonVariant>;
|
|
8
|
-
export { resolveActionHandler } from
|
|
9
|
-
export type { ActionHandler, ActionHandlerContext, ActionHandlerResult } from
|
|
8
|
+
export { resolveActionHandler } from "./handlers.js";
|
|
9
|
+
export type { ActionHandler, ActionHandlerContext, ActionHandlerResult } from "./handlers.js";
|
|
10
10
|
export declare class Dialog extends ComponentBuilder {
|
|
11
|
-
readonly kind:
|
|
11
|
+
readonly kind: "dialog";
|
|
12
12
|
static make(): Dialog;
|
|
13
13
|
heading(value: string): this;
|
|
14
14
|
description(value: string): this;
|
|
@@ -17,13 +17,13 @@ export declare class Dialog extends ComponentBuilder {
|
|
|
17
17
|
form(components: ComponentBuilder[]): this;
|
|
18
18
|
}
|
|
19
19
|
export declare class Action extends ComponentBuilder {
|
|
20
|
-
readonly kind: SchemaNode[
|
|
20
|
+
readonly kind: SchemaNode["kind"];
|
|
21
21
|
static make(name: string): Action;
|
|
22
22
|
label(value: string): this;
|
|
23
23
|
color(value: ActionColor): this;
|
|
24
24
|
requiresConfirmation(value?: boolean): this;
|
|
25
25
|
icon(value: string): this;
|
|
26
|
-
iconPosition(value:
|
|
26
|
+
iconPosition(value: "start" | "end"): this;
|
|
27
27
|
iconOnly(value?: boolean): this;
|
|
28
28
|
badge(value: string | number, color?: BadgeColor): this;
|
|
29
29
|
size(value: ActionButtonSize): this;
|
|
@@ -37,59 +37,59 @@ export declare class Action extends ComponentBuilder {
|
|
|
37
37
|
private patchDialog;
|
|
38
38
|
}
|
|
39
39
|
export declare class EditAction extends Action {
|
|
40
|
-
readonly kind:
|
|
40
|
+
readonly kind: "edit-action";
|
|
41
41
|
static make(name?: string): EditAction;
|
|
42
42
|
}
|
|
43
43
|
export declare class DeleteAction extends Action {
|
|
44
|
-
readonly kind:
|
|
44
|
+
readonly kind: "delete-action";
|
|
45
45
|
static make(name?: string): DeleteAction;
|
|
46
46
|
}
|
|
47
47
|
export declare class RestoreAction extends Action {
|
|
48
|
-
readonly kind:
|
|
48
|
+
readonly kind: "restore-action";
|
|
49
49
|
static make(name?: string): RestoreAction;
|
|
50
50
|
}
|
|
51
51
|
export declare class CreateAction extends Action {
|
|
52
|
-
readonly kind:
|
|
52
|
+
readonly kind: "create-action";
|
|
53
53
|
static make(name?: string): CreateAction;
|
|
54
54
|
}
|
|
55
55
|
export declare class ViewAction extends Action {
|
|
56
|
-
readonly kind:
|
|
56
|
+
readonly kind: "view-action";
|
|
57
57
|
static make(name?: string): ViewAction;
|
|
58
58
|
}
|
|
59
59
|
export declare class ListAction extends Action {
|
|
60
|
-
readonly kind:
|
|
60
|
+
readonly kind: "action";
|
|
61
61
|
static make(name?: string): ListAction;
|
|
62
62
|
}
|
|
63
63
|
export declare class BulkAction extends Action {
|
|
64
|
-
readonly kind:
|
|
64
|
+
readonly kind: "bulk-action";
|
|
65
65
|
static make(name: string): BulkAction;
|
|
66
66
|
}
|
|
67
67
|
export declare class BulkDeleteAction extends Action {
|
|
68
|
-
readonly kind:
|
|
68
|
+
readonly kind: "bulk-delete-action";
|
|
69
69
|
static make(name?: string): BulkDeleteAction;
|
|
70
70
|
}
|
|
71
71
|
export declare class AssociateAction extends Action {
|
|
72
|
-
readonly kind:
|
|
72
|
+
readonly kind: "associate-action";
|
|
73
73
|
static make(name?: string): AssociateAction;
|
|
74
74
|
}
|
|
75
75
|
export declare class DissociateAction extends Action {
|
|
76
|
-
readonly kind:
|
|
76
|
+
readonly kind: "dissociate-action";
|
|
77
77
|
static make(name?: string): DissociateAction;
|
|
78
78
|
}
|
|
79
79
|
export declare class AttachAction extends Action {
|
|
80
|
-
readonly kind:
|
|
80
|
+
readonly kind: "attach-action";
|
|
81
81
|
static make(name?: string): AttachAction;
|
|
82
82
|
}
|
|
83
83
|
export declare class DetachAction extends Action {
|
|
84
|
-
readonly kind:
|
|
84
|
+
readonly kind: "detach-action";
|
|
85
85
|
static make(name?: string): DetachAction;
|
|
86
86
|
}
|
|
87
87
|
export declare class BulkDissociateAction extends Action {
|
|
88
|
-
readonly kind:
|
|
88
|
+
readonly kind: "bulk-dissociate-action";
|
|
89
89
|
static make(name?: string): BulkDissociateAction;
|
|
90
90
|
}
|
|
91
91
|
export declare class BulkDetachAction extends Action {
|
|
92
|
-
readonly kind:
|
|
92
|
+
readonly kind: "bulk-detach-action";
|
|
93
93
|
static make(name?: string): BulkDetachAction;
|
|
94
94
|
}
|
|
95
95
|
export declare function resolveActionDialog(action: SchemaNode, defaults?: {
|
package/dist/actions/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { ComponentBuilder } from
|
|
2
|
-
import { registerActionHandler } from
|
|
1
|
+
import { ComponentBuilder } from "../schemas/index.js";
|
|
2
|
+
import { registerActionHandler } from "./handlers.js";
|
|
3
3
|
export const ACTION_COLOR_VARIANT = {
|
|
4
|
-
primary:
|
|
5
|
-
danger:
|
|
6
|
-
gray:
|
|
7
|
-
success:
|
|
8
|
-
warning:
|
|
4
|
+
primary: "default",
|
|
5
|
+
danger: "destructive",
|
|
6
|
+
gray: "outline",
|
|
7
|
+
success: "success",
|
|
8
|
+
warning: "warning",
|
|
9
9
|
};
|
|
10
|
-
export { resolveActionHandler } from
|
|
10
|
+
export { resolveActionHandler } from "./handlers.js";
|
|
11
11
|
export class Dialog extends ComponentBuilder {
|
|
12
|
-
kind =
|
|
12
|
+
kind = "dialog";
|
|
13
13
|
static make() {
|
|
14
14
|
return new Dialog();
|
|
15
15
|
}
|
|
16
16
|
heading(value) {
|
|
17
|
-
return this.setProp(
|
|
17
|
+
return this.setProp("heading", value);
|
|
18
18
|
}
|
|
19
19
|
description(value) {
|
|
20
|
-
return this.setProp(
|
|
20
|
+
return this.setProp("description", value);
|
|
21
21
|
}
|
|
22
22
|
submitLabel(value) {
|
|
23
|
-
return this.setProp(
|
|
23
|
+
return this.setProp("submitLabel", value);
|
|
24
24
|
}
|
|
25
25
|
cancelLabel(value) {
|
|
26
|
-
return this.setProp(
|
|
26
|
+
return this.setProp("cancelLabel", value);
|
|
27
27
|
}
|
|
28
28
|
form(components) {
|
|
29
29
|
this.children = components.map((component) => component.toSchema());
|
|
@@ -31,42 +31,42 @@ export class Dialog extends ComponentBuilder {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
export class Action extends ComponentBuilder {
|
|
34
|
-
kind =
|
|
34
|
+
kind = "action";
|
|
35
35
|
static make(name) {
|
|
36
|
-
return new Action().setProp(
|
|
36
|
+
return new Action().setProp("name", name).setProp("label", name);
|
|
37
37
|
}
|
|
38
38
|
label(value) {
|
|
39
|
-
return this.setProp(
|
|
39
|
+
return this.setProp("label", value);
|
|
40
40
|
}
|
|
41
41
|
color(value) {
|
|
42
|
-
return this.setProp(
|
|
42
|
+
return this.setProp("color", value);
|
|
43
43
|
}
|
|
44
44
|
requiresConfirmation(value = true) {
|
|
45
|
-
return this.setProp(
|
|
45
|
+
return this.setProp("requiresConfirmation", value);
|
|
46
46
|
}
|
|
47
47
|
icon(value) {
|
|
48
|
-
return this.setProp(
|
|
48
|
+
return this.setProp("icon", value);
|
|
49
49
|
}
|
|
50
50
|
iconPosition(value) {
|
|
51
|
-
return this.setProp(
|
|
51
|
+
return this.setProp("iconPosition", value);
|
|
52
52
|
}
|
|
53
53
|
iconOnly(value = true) {
|
|
54
|
-
return this.setProp(
|
|
54
|
+
return this.setProp("iconOnly", value);
|
|
55
55
|
}
|
|
56
56
|
badge(value, color) {
|
|
57
|
-
return this.setProp(
|
|
57
|
+
return this.setProp("badge", { text: String(value), color });
|
|
58
58
|
}
|
|
59
59
|
size(value) {
|
|
60
|
-
return this.setProp(
|
|
60
|
+
return this.setProp("size", value);
|
|
61
61
|
}
|
|
62
62
|
variant(value) {
|
|
63
|
-
return this.setProp(
|
|
63
|
+
return this.setProp("variant", value);
|
|
64
64
|
}
|
|
65
65
|
dialog(dialog) {
|
|
66
|
-
return this.setProp(
|
|
66
|
+
return this.setProp("dialog", dialog.toSchema()).requiresConfirmation(true);
|
|
67
67
|
}
|
|
68
68
|
handler(fn) {
|
|
69
|
-
return this.setProp(
|
|
69
|
+
return this.setProp("handlerKey", registerActionHandler(fn));
|
|
70
70
|
}
|
|
71
71
|
modalHeading(value) {
|
|
72
72
|
return this.patchDialog({ heading: value });
|
|
@@ -82,135 +82,135 @@ export class Action extends ComponentBuilder {
|
|
|
82
82
|
}
|
|
83
83
|
patchDialog(partial) {
|
|
84
84
|
const existing = this.props.dialog ?? {
|
|
85
|
-
kind:
|
|
85
|
+
kind: "dialog",
|
|
86
86
|
props: {},
|
|
87
87
|
};
|
|
88
88
|
const next = {
|
|
89
|
-
kind:
|
|
89
|
+
kind: "dialog",
|
|
90
90
|
props: { ...existing.props, ...partial },
|
|
91
91
|
children: existing.children,
|
|
92
92
|
};
|
|
93
|
-
return this.setProp(
|
|
93
|
+
return this.setProp("dialog", next).requiresConfirmation(true);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
export class EditAction extends Action {
|
|
97
|
-
kind =
|
|
98
|
-
static make(name =
|
|
99
|
-
return new EditAction().setProp(
|
|
97
|
+
kind = "edit-action";
|
|
98
|
+
static make(name = "edit") {
|
|
99
|
+
return new EditAction().setProp("name", name).setProp("label", "Edit");
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
export class DeleteAction extends Action {
|
|
103
|
-
kind =
|
|
104
|
-
static make(name =
|
|
103
|
+
kind = "delete-action";
|
|
104
|
+
static make(name = "delete") {
|
|
105
105
|
return new DeleteAction()
|
|
106
|
-
.setProp(
|
|
107
|
-
.setProp(
|
|
108
|
-
.color(
|
|
106
|
+
.setProp("name", name)
|
|
107
|
+
.setProp("label", "Delete")
|
|
108
|
+
.color("danger")
|
|
109
109
|
.requiresConfirmation();
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
export class RestoreAction extends Action {
|
|
113
|
-
kind =
|
|
114
|
-
static make(name =
|
|
115
|
-
return new RestoreAction().setProp(
|
|
113
|
+
kind = "restore-action";
|
|
114
|
+
static make(name = "restore") {
|
|
115
|
+
return new RestoreAction().setProp("name", name).setProp("label", "Restore").color("success");
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
export class CreateAction extends Action {
|
|
119
|
-
kind =
|
|
120
|
-
static make(name =
|
|
121
|
-
return new CreateAction().setProp(
|
|
119
|
+
kind = "create-action";
|
|
120
|
+
static make(name = "create") {
|
|
121
|
+
return new CreateAction().setProp("name", name).setProp("label", "Create");
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
export class ViewAction extends Action {
|
|
125
|
-
kind =
|
|
126
|
-
static make(name =
|
|
127
|
-
return new ViewAction().setProp(
|
|
125
|
+
kind = "view-action";
|
|
126
|
+
static make(name = "view") {
|
|
127
|
+
return new ViewAction().setProp("name", name).setProp("label", "View");
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
export class ListAction extends Action {
|
|
131
|
-
kind =
|
|
132
|
-
static make(name =
|
|
133
|
-
return new ListAction().setProp(
|
|
131
|
+
kind = "action";
|
|
132
|
+
static make(name = "list") {
|
|
133
|
+
return new ListAction().setProp("name", name).setProp("label", "List");
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
export class BulkAction extends Action {
|
|
137
|
-
kind =
|
|
137
|
+
kind = "bulk-action";
|
|
138
138
|
static make(name) {
|
|
139
|
-
return new BulkAction().setProp(
|
|
139
|
+
return new BulkAction().setProp("name", name).setProp("label", name);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
export class BulkDeleteAction extends Action {
|
|
143
|
-
kind =
|
|
144
|
-
static make(name =
|
|
143
|
+
kind = "bulk-delete-action";
|
|
144
|
+
static make(name = "bulk-delete") {
|
|
145
145
|
return new BulkDeleteAction()
|
|
146
|
-
.setProp(
|
|
147
|
-
.setProp(
|
|
148
|
-
.color(
|
|
146
|
+
.setProp("name", name)
|
|
147
|
+
.setProp("label", "Delete selected")
|
|
148
|
+
.color("danger")
|
|
149
149
|
.requiresConfirmation();
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
export class AssociateAction extends Action {
|
|
153
|
-
kind =
|
|
154
|
-
static make(name =
|
|
155
|
-
return new AssociateAction().setProp(
|
|
153
|
+
kind = "associate-action";
|
|
154
|
+
static make(name = "associate") {
|
|
155
|
+
return new AssociateAction().setProp("name", name).setProp("label", "Associate");
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
export class DissociateAction extends Action {
|
|
159
|
-
kind =
|
|
160
|
-
static make(name =
|
|
159
|
+
kind = "dissociate-action";
|
|
160
|
+
static make(name = "dissociate") {
|
|
161
161
|
return new DissociateAction()
|
|
162
|
-
.setProp(
|
|
163
|
-
.setProp(
|
|
164
|
-
.color(
|
|
162
|
+
.setProp("name", name)
|
|
163
|
+
.setProp("label", "Dissociate")
|
|
164
|
+
.color("gray")
|
|
165
165
|
.requiresConfirmation();
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
export class AttachAction extends Action {
|
|
169
|
-
kind =
|
|
170
|
-
static make(name =
|
|
171
|
-
return new AttachAction().setProp(
|
|
169
|
+
kind = "attach-action";
|
|
170
|
+
static make(name = "attach") {
|
|
171
|
+
return new AttachAction().setProp("name", name).setProp("label", "Attach");
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
export class DetachAction extends Action {
|
|
175
|
-
kind =
|
|
176
|
-
static make(name =
|
|
175
|
+
kind = "detach-action";
|
|
176
|
+
static make(name = "detach") {
|
|
177
177
|
return new DetachAction()
|
|
178
|
-
.setProp(
|
|
179
|
-
.setProp(
|
|
180
|
-
.color(
|
|
178
|
+
.setProp("name", name)
|
|
179
|
+
.setProp("label", "Detach")
|
|
180
|
+
.color("gray")
|
|
181
181
|
.requiresConfirmation();
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
export class BulkDissociateAction extends Action {
|
|
185
|
-
kind =
|
|
186
|
-
static make(name =
|
|
185
|
+
kind = "bulk-dissociate-action";
|
|
186
|
+
static make(name = "bulk-dissociate") {
|
|
187
187
|
return new BulkDissociateAction()
|
|
188
|
-
.setProp(
|
|
189
|
-
.setProp(
|
|
190
|
-
.color(
|
|
188
|
+
.setProp("name", name)
|
|
189
|
+
.setProp("label", "Dissociate selected")
|
|
190
|
+
.color("gray")
|
|
191
191
|
.requiresConfirmation();
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
export class BulkDetachAction extends Action {
|
|
195
|
-
kind =
|
|
196
|
-
static make(name =
|
|
195
|
+
kind = "bulk-detach-action";
|
|
196
|
+
static make(name = "bulk-detach") {
|
|
197
197
|
return new BulkDetachAction()
|
|
198
|
-
.setProp(
|
|
199
|
-
.setProp(
|
|
200
|
-
.color(
|
|
198
|
+
.setProp("name", name)
|
|
199
|
+
.setProp("label", "Detach selected")
|
|
200
|
+
.color("gray")
|
|
201
201
|
.requiresConfirmation();
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
export function resolveActionDialog(action, defaults = {}) {
|
|
205
205
|
const explicit = action.props.dialog;
|
|
206
|
-
if (explicit?.kind ===
|
|
206
|
+
if (explicit?.kind === "dialog") {
|
|
207
207
|
return {
|
|
208
|
-
kind:
|
|
208
|
+
kind: "dialog",
|
|
209
209
|
props: {
|
|
210
|
-
heading: defaults.heading ??
|
|
211
|
-
description: defaults.description ??
|
|
212
|
-
submitLabel: defaults.submitLabel ??
|
|
213
|
-
cancelLabel: defaults.cancelLabel ??
|
|
210
|
+
heading: defaults.heading ?? "Confirm",
|
|
211
|
+
description: defaults.description ?? "",
|
|
212
|
+
submitLabel: defaults.submitLabel ?? "Confirm",
|
|
213
|
+
cancelLabel: defaults.cancelLabel ?? "Cancel",
|
|
214
214
|
...explicit.props,
|
|
215
215
|
},
|
|
216
216
|
children: explicit.children,
|
|
@@ -220,12 +220,12 @@ export function resolveActionDialog(action, defaults = {}) {
|
|
|
220
220
|
return null;
|
|
221
221
|
}
|
|
222
222
|
return {
|
|
223
|
-
kind:
|
|
223
|
+
kind: "dialog",
|
|
224
224
|
props: {
|
|
225
|
-
heading: defaults.heading ??
|
|
226
|
-
description: defaults.description ??
|
|
227
|
-
submitLabel: defaults.submitLabel ?? String(action.props.label ??
|
|
228
|
-
cancelLabel: defaults.cancelLabel ??
|
|
225
|
+
heading: defaults.heading ?? "Confirm",
|
|
226
|
+
description: defaults.description ?? "Are you sure you want to continue?",
|
|
227
|
+
submitLabel: defaults.submitLabel ?? String(action.props.label ?? "Confirm"),
|
|
228
|
+
cancelLabel: defaults.cancelLabel ?? "Cancel",
|
|
229
229
|
},
|
|
230
230
|
};
|
|
231
231
|
}
|
package/dist/charts/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ChartKind, ChartRow, ChartSeriesSpec, ChartSpec } from
|
|
2
|
-
import type { AdminPolicyContext, DashboardWidget, PageRenderContext } from
|
|
3
|
-
export type { ChartKind, ChartRow, ChartSeriesSpec, ChartSpec } from
|
|
1
|
+
import type { ChartKind, ChartRow, ChartSeriesSpec, ChartSpec } from "@nestjs-dash/support";
|
|
2
|
+
import type { AdminPolicyContext, DashboardWidget, PageRenderContext } from "../index.js";
|
|
3
|
+
export type { ChartKind, ChartRow, ChartSeriesSpec, ChartSpec } from "@nestjs-dash/support";
|
|
4
4
|
type DataInput = ChartRow[] | ((ctx: PageRenderContext) => ChartRow[] | Promise<ChartRow[]>);
|
|
5
5
|
type AccessPredicate = (ctx: AdminPolicyContext) => boolean | Promise<boolean>;
|
|
6
6
|
declare abstract class ChartWidgetBuilder implements DashboardWidget {
|
|
7
7
|
private readonly kind;
|
|
8
|
-
slot:
|
|
8
|
+
slot: "main" | "side";
|
|
9
9
|
private categoryKeyValue;
|
|
10
10
|
private seriesValue;
|
|
11
11
|
private dataInput;
|
|
@@ -43,13 +43,13 @@ export declare class PieChart extends ChartWidgetBuilder {
|
|
|
43
43
|
}
|
|
44
44
|
type StatCardValueInput = string | number | ((ctx: PageRenderContext) => string | number | Promise<string | number>);
|
|
45
45
|
type StatCardTrend = {
|
|
46
|
-
direction:
|
|
46
|
+
direction: "up" | "down";
|
|
47
47
|
label: string;
|
|
48
48
|
};
|
|
49
49
|
type StatCardTrendInput = StatCardTrend | undefined | ((ctx: PageRenderContext) => StatCardTrend | undefined | Promise<StatCardTrend | undefined>);
|
|
50
50
|
export declare class StatCard implements DashboardWidget {
|
|
51
51
|
private readonly labelValue;
|
|
52
|
-
slot:
|
|
52
|
+
slot: "main" | "side";
|
|
53
53
|
private valueInput;
|
|
54
54
|
private trendInput;
|
|
55
55
|
private accessPredicate?;
|