@smartsoft001/claude-plugins 2.193.0 → 2.195.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/.claude-plugin/marketplace.json +14 -3
- package/README.md +19 -4
- package/package.json +3 -3
- package/plugins/smart-angular/.claude-plugin/plugin.json +6 -0
- package/plugins/{smart → smart-angular}/skills/angular-components-button/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/angular-components-container/SKILL.md +8 -8
- package/plugins/{smart → smart-angular}/skills/angular-components-drawer/SKILL.md +5 -9
- package/plugins/{smart → smart-angular}/skills/angular-components-list-container/SKILL.md +2 -5
- package/plugins/{smart → smart-angular}/skills/angular-components-media-object/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/angular-components-modal/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-claude-config.md +13 -9
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/patch-delta.md +1 -1
- package/plugins/{smart → smart-core}/.claude-plugin/README.md +31 -16
- package/plugins/{smart → smart-core}/.claude-plugin/merge-permissions.js +7 -6
- package/plugins/smart-core/.claude-plugin/plugin.json +5 -0
- package/plugins/{smart → smart-core}/.claude-plugin/settings.template.json +2 -2
- package/plugins/{smart → smart-core}/hooks/README.md +1 -1
- package/plugins/{smart → smart-core}/skills/audit-log/SKILL.md +2 -2
- package/plugins/{smart → smart-core}/skills/format-code/SKILL.md +1 -1
- package/plugins/smart-react/.claude-plugin/plugin.json +6 -0
- package/plugins/smart-react/agents/react-components.md +260 -0
- package/plugins/smart-react/skills/react-components-accordion/SKILL.md +204 -0
- package/plugins/smart-react/skills/react-components-action-panel/SKILL.md +191 -0
- package/plugins/smart-react/skills/react-components-alert/SKILL.md +244 -0
- package/plugins/smart-react/skills/react-components-app/SKILL.md +236 -0
- package/plugins/smart-react/skills/react-components-avatar/SKILL.md +176 -0
- package/plugins/smart-react/skills/react-components-badge/SKILL.md +165 -0
- package/plugins/smart-react/skills/react-components-breadcrumbs/SKILL.md +183 -0
- package/plugins/smart-react/skills/react-components-button/SKILL.md +239 -0
- package/plugins/smart-react/skills/react-components-button-group/SKILL.md +187 -0
- package/plugins/smart-react/skills/react-components-calendar/SKILL.md +270 -0
- package/plugins/smart-react/skills/react-components-card/SKILL.md +201 -0
- package/plugins/smart-react/skills/react-components-card-heading/SKILL.md +133 -0
- package/plugins/smart-react/skills/react-components-command-palette/SKILL.md +228 -0
- package/plugins/smart-react/skills/react-components-container/SKILL.md +134 -0
- package/plugins/smart-react/skills/react-components-date-edit/SKILL.md +186 -0
- package/plugins/smart-react/skills/react-components-date-range/SKILL.md +259 -0
- package/plugins/smart-react/skills/react-components-description-list/SKILL.md +144 -0
- package/plugins/smart-react/skills/react-components-detail/SKILL.md +272 -0
- package/plugins/smart-react/skills/react-components-details/SKILL.md +250 -0
- package/plugins/smart-react/skills/react-components-divider/SKILL.md +128 -0
- package/plugins/smart-react/skills/react-components-drawer/SKILL.md +165 -0
- package/plugins/smart-react/skills/react-components-dropdown/SKILL.md +194 -0
- package/plugins/smart-react/skills/react-components-empty-state/SKILL.md +202 -0
- package/plugins/smart-react/skills/react-components-export/SKILL.md +120 -0
- package/plugins/smart-react/skills/react-components-feed/SKILL.md +171 -0
- package/plugins/smart-react/skills/react-components-form/SKILL.md +319 -0
- package/plugins/smart-react/skills/react-components-grid-list/SKILL.md +172 -0
- package/plugins/smart-react/skills/react-components-icon/SKILL.md +117 -0
- package/plugins/smart-react/skills/react-components-import/SKILL.md +113 -0
- package/plugins/smart-react/skills/react-components-info/SKILL.md +147 -0
- package/plugins/smart-react/skills/react-components-input/SKILL.md +406 -0
- package/plugins/smart-react/skills/react-components-list/SKILL.md +384 -0
- package/plugins/smart-react/skills/react-components-list-container/SKILL.md +105 -0
- package/plugins/smart-react/skills/react-components-loader/SKILL.md +126 -0
- package/plugins/smart-react/skills/react-components-media-object/SKILL.md +130 -0
- package/plugins/smart-react/skills/react-components-modal/SKILL.md +266 -0
- package/plugins/smart-react/skills/react-components-multi-column-layout/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-navbar/SKILL.md +211 -0
- package/plugins/smart-react/skills/react-components-notification/SKILL.md +223 -0
- package/plugins/smart-react/skills/react-components-overlays/SKILL.md +182 -0
- package/plugins/smart-react/skills/react-components-page/SKILL.md +224 -0
- package/plugins/smart-react/skills/react-components-page-heading/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-paging/SKILL.md +183 -0
- package/plugins/smart-react/skills/react-components-password-strength/SKILL.md +149 -0
- package/plugins/smart-react/skills/react-components-progress-bars/SKILL.md +195 -0
- package/plugins/smart-react/skills/react-components-searchbar/SKILL.md +150 -0
- package/plugins/smart-react/skills/react-components-section-heading/SKILL.md +138 -0
- package/plugins/smart-react/skills/react-components-select-menu/SKILL.md +168 -0
- package/plugins/smart-react/skills/react-components-sidebar-layout/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-sidebar-navigation/SKILL.md +277 -0
- package/plugins/smart-react/skills/react-components-sign-in-form/SKILL.md +228 -0
- package/plugins/smart-react/skills/react-components-stacked-layout/SKILL.md +146 -0
- package/plugins/smart-react/skills/react-components-stacked-list/SKILL.md +156 -0
- package/plugins/smart-react/skills/react-components-stats/SKILL.md +149 -0
- package/plugins/smart-react/skills/react-components-table/SKILL.md +222 -0
- package/plugins/smart-react/skills/react-components-tabs/SKILL.md +189 -0
- package/plugins/smart-react/skills/react-components-textarea/SKILL.md +202 -0
- package/plugins/smart-react/skills/react-components-toggle/SKILL.md +157 -0
- package/plugins/smart-react/skills/react-components-vertical-navigation/SKILL.md +212 -0
- package/plugins/smart-react/skills/react-forms/SKILL.md +272 -0
- package/plugins/smart-react/skills/react-provider/SKILL.md +368 -0
- package/plugins/smart-react/skills/smart-crud-react/SKILL.md +410 -0
- package/plugins/smart/.claude-plugin/plugin.json +0 -5
- /package/plugins/{smart/agents/angular-components/AGENT.md → smart-angular/agents/angular-components.md} +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-accordion/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-action-panel/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-alert/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-avatar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-badge/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-breadcrumbs/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-button-group/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-calendar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-card/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-card-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-command-palette/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-date-edit/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-date-range/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-description-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-detail/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-details/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-divider/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-dropdown/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-empty-state/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-feed/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-form/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-grid-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-icon/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-info/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-input/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-multi-column-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-navbar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-notification/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-page/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-page-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-paging/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-password-strength/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-progress-bars/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-searchbar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-section-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-select-menu/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-navigation/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sign-in-form/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stats/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-table/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-tabs/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-textarea/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-toggle/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-vertical-navigation/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-app.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-shared-lib.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/version-resolution.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/derive-prefix.sh +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/verify-scaffold.sh +0 -0
- /package/plugins/{smart → smart-angular}/skills/smart-crud/SKILL.md +0 -0
- /package/plugins/{smart → smart-core}/hooks/CONFIG.md +0 -0
- /package/plugins/{smart → smart-core}/hooks/audit_logger.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/auto_format.sh +0 -0
- /package/plugins/{smart → smart-core}/hooks/hooks.json +0 -0
- /package/plugins/{smart → smart-core}/hooks/safety_validator.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/sensitive_file_blocker.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/skill_validator.py +0 -0
- /package/plugins/{smart → smart-core}/skills/project-conventions/SKILL.md +0 -0
- /package/plugins/{smart → smart-core}/skills/safety-check/SKILL.md +0 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: smart-crud-react
|
|
3
|
+
description: CRUD screens in React with @smartsoft001/crud-shell-react — CrudProvider with CrudConfig / CrudFullConfig, SmartCrudPages basePath vs SmartCrudListPage / SmartCrudItemPage in your own router, replacing page bodies through the 'crud-list-page' / 'crud-item-page' registry keys (formRef, useCrudItemPageBase), filters, export, multiselect and groups, useCrud* hooks, useCrudState, the CrudFacade, and the end-menu caveat. Use when building or customising list / item screens of a collection.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# CRUD screens (`@smartsoft001/crud-shell-react`)
|
|
8
|
+
|
|
9
|
+
`@smartsoft001/crud-shell-react` generates the screens of a collection from one configuration object and the model's metadata: a **list page** (paging, sorting, search, filters, export, row actions, multi-select, groups) and an **item page** (create, show, edit one record). `CrudProvider` sets a feature up for its subtree: a `CrudService` against `config.apiUrl`, a store named after `config.entity` with the effects that turn its actions into requests, the `CrudFacade` over that store, and a file service pointed at the same API. The screens are built from `@smartsoft001/react` (`SmartPage`, `SmartList`, `SmartForm`, `SmartDetails`) and use the services, navigation adapter and registry of its `SmartProvider` (see `react-provider`). The requests follow the contract of `@smartsoft001/crud-shell-nestjs` (`$search`, `limit` / `offset`, `sort`, `key=value` query items, CSV / XLSX export).
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Building the list and item screens of a collection from a `@Model` class
|
|
14
|
+
- Configuring capabilities (`details`, `edit`, `add`, `remove`, `search`, `export`, `pagination`, `sort`, `list` options, groups)
|
|
15
|
+
- Mounting the screens without a router (`SmartCrudPages`) or from the application's routes (`SmartCrudListPage`, `SmartCrudItemPage`)
|
|
16
|
+
- Replacing the body of the list or item page (`crud-list-page`, `crud-item-page`), or writing a whole page on `useCrudListPage` / `useCrudItemPage`
|
|
17
|
+
- Reading or changing a collection from a component of your own (`useCrudFacade`, `useCrudState`)
|
|
18
|
+
- Placing filters, active-filter chips, export, multiselect or groups yourself
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @smartsoft001/crud-shell-react @smartsoft001/react @smartsoft001/domain-core @smartsoft001/models @smartsoft001/utils react react-dom reflect-metadata
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Import `@smartsoft001/crud-shell-react/styles.css` once, next to `@smartsoft001/react/styles.css`. The app needs a `SmartProvider` above every `CrudProvider`.
|
|
27
|
+
|
|
28
|
+
## The model
|
|
29
|
+
|
|
30
|
+
What the screens show is read from `@smartsoft001/models` decorators:
|
|
31
|
+
|
|
32
|
+
- `@Model({ titleKey })`: `titleKey` names the field shown in the item page title (`<value> - details`, `<value> - change`). `@Model({ create: { permissions }, update: { permissions, enabled }, remove: { permissions, enabled }, filters: [...] })` turns `add` / `edit` / `remove` off for users without the permissions, and adds explicit filters.
|
|
33
|
+
- `@Field({ list: { order, filter: true } })`: a list column; `filter: true` also adds a filter (`~=` for `text` / `longText`, `=` for the others).
|
|
34
|
+
- `@Field({ details: true })`: a field of the details view; `create` / `update` (with `required`, `confirm`, `unique`, `enabled`, ...): a field of the create / edit form (see `react-forms`).
|
|
35
|
+
- Labels: `MODEL.<field>` translations (or a `modelLabelProvider`).
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
### `CrudConfig<T>`
|
|
40
|
+
|
|
41
|
+
Enough for the store, the facade and components of your own.
|
|
42
|
+
|
|
43
|
+
| Field | Type | What it does |
|
|
44
|
+
| ---------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `apiUrl` | `string` | Required. The collection endpoint; the service appends `/{id}`, `/bulk` and the query string. Attachments live under `<apiUrl>/attachments`. |
|
|
46
|
+
| `entity` | `string` | Required. Names the feature's store and its action types (`[notes] Read`). One store per entity per `SmartProvider`. |
|
|
47
|
+
| `type` | `any` | The `@Model` class the screens read their fields from. |
|
|
48
|
+
| `reducerFactory` | `() => (state: CrudState<any>, action: CrudAction) => CrudState<any>` | Replaces the default reducer of the feature. |
|
|
49
|
+
| `baseQuery` | `Array<ICrudFilterQueryItem>` | Query items every read sends unless its filter carries a `query` of its own. |
|
|
50
|
+
|
|
51
|
+
### `CrudFullConfig<T>` (extends `CrudConfig<T>`)
|
|
52
|
+
|
|
53
|
+
| Field | Type | What it does |
|
|
54
|
+
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `title` | `string` | Required. The list page heading (translated). |
|
|
56
|
+
| `details` | `boolean \| { cellPipe?: ICellPipe<T>; components?: { top?; bottom? } }` | Rows link to the item page, which opens read-only with `SmartDetails`; `components` render above / below the details. |
|
|
57
|
+
| `edit` | `boolean \| { cellPipe?; components?: { top?; bottom? } }` | A record can be edited; `components` render above / below the form while editing. |
|
|
58
|
+
| `add` | `boolean \| { components?: { top?; bottom? } }` | The add button (navigates to `<basePath>/add`); `components` render above / below the form while creating. |
|
|
59
|
+
| `remove` | `boolean` | A remove action per row, confirmed by the list, offered only where the model's `remove.enabled` allows it. |
|
|
60
|
+
| `search` | `boolean` | The search box of the page header; a search reads the first page with `searchText`. |
|
|
61
|
+
| `export` | `boolean` | The export button: `SmartCrudExport` in a modal (CSV or XLSX of the current filter, without paging). |
|
|
62
|
+
| `pagination` | `{ limit: number }` | Page size; the first read starts at offset 0. The backend caps a page (100 by default). |
|
|
63
|
+
| `sort` | `boolean \| { default?: string; defaultDesc?: boolean }` | Whether sorting is offered, and the column the first read sorts by. |
|
|
64
|
+
| `list` | `{ cellPipe?; components?: { top?; multi? }; mode?: ListMode; paginationMode?: PaginationMode; resetQuery?: 'beforeInit'; groups?: Array<ICrudListGroup> }` | Cell formatting, a component above the list and one in the multiselect panel, the list layout and paging mode, grouping, and with `resetQuery` a first read from the configured defaults instead of the filter the feature already has. |
|
|
65
|
+
| `buttons` | `Array<IIconButtonOptions>` | Extra buttons appended to the list page header. |
|
|
66
|
+
| `inputComponents` | `{ [key: string]: ComponentType<any> }` | Field components for named fields of the form (see `react-components-input`). |
|
|
67
|
+
| `className` | `string` | The class of the `SmartPage` of both pages. |
|
|
68
|
+
| `variant` | `SmartPageVariant` | The page variant of both pages (see `react-components-page`). |
|
|
69
|
+
|
|
70
|
+
`CrudProvider` creates the service and the facade again for every new `config` object (the store stays with the entity), so make the configuration a module constant or memoise it.
|
|
71
|
+
|
|
72
|
+
## Mounting the screens
|
|
73
|
+
|
|
74
|
+
### Without a router: `SmartCrudPages`
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import {
|
|
78
|
+
CrudFullConfig,
|
|
79
|
+
CrudProvider,
|
|
80
|
+
SmartCrudPages,
|
|
81
|
+
} from '@smartsoft001/crud-shell-react';
|
|
82
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
83
|
+
import { Field, FieldType, Model } from '@smartsoft001/models';
|
|
84
|
+
import { SmartProvider } from '@smartsoft001/react';
|
|
85
|
+
|
|
86
|
+
@Model({ titleKey: 'title' })
|
|
87
|
+
export class Note implements IEntity<string> {
|
|
88
|
+
id!: string;
|
|
89
|
+
|
|
90
|
+
@Field({
|
|
91
|
+
type: FieldType.text,
|
|
92
|
+
list: { order: 1, filter: true },
|
|
93
|
+
details: true,
|
|
94
|
+
create: { required: true },
|
|
95
|
+
update: true,
|
|
96
|
+
})
|
|
97
|
+
title!: string;
|
|
98
|
+
|
|
99
|
+
@Field({
|
|
100
|
+
type: FieldType.longText,
|
|
101
|
+
details: true,
|
|
102
|
+
create: true,
|
|
103
|
+
update: true,
|
|
104
|
+
})
|
|
105
|
+
body!: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Module constants: the provider rebuilds its service and facade for a new config object.
|
|
109
|
+
export const notesConfig: CrudFullConfig<Note> = {
|
|
110
|
+
apiUrl: '/api/notes',
|
|
111
|
+
entity: 'notes',
|
|
112
|
+
type: Note,
|
|
113
|
+
title: 'Notes',
|
|
114
|
+
details: true,
|
|
115
|
+
add: true,
|
|
116
|
+
edit: true,
|
|
117
|
+
remove: true,
|
|
118
|
+
search: true,
|
|
119
|
+
export: true,
|
|
120
|
+
pagination: { limit: 10 },
|
|
121
|
+
sort: { default: 'title' },
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const translations = { MODEL: { title: 'Title', body: 'Body' } };
|
|
125
|
+
|
|
126
|
+
export function NotesApp() {
|
|
127
|
+
return (
|
|
128
|
+
<SmartProvider
|
|
129
|
+
language="eng"
|
|
130
|
+
translations={translations}
|
|
131
|
+
fileServiceConfig={{ apiUrl: '/api/notes' }}
|
|
132
|
+
>
|
|
133
|
+
<CrudProvider config={notesConfig}>
|
|
134
|
+
{/* The list on /notes, a new note on /notes/add, a note on /notes/:id */}
|
|
135
|
+
<SmartCrudPages basePath="/notes" />
|
|
136
|
+
</CrudProvider>
|
|
137
|
+
</SmartProvider>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`SmartCrudPages` follows `getCurrentUrl()` / `subscribe` of the provider's navigation adapter (`window.history` by default): `basePath` renders `SmartCrudListPage`, `basePath/add` a creating `SmartCrudItemPage`, `basePath/:id` the `SmartCrudItemPage` of that id, any other URL nothing. `matchCrudRoute(url, basePath)` is the matcher (`{ page: 'list' }`, `{ page: 'item', id? }` or `null`).
|
|
143
|
+
|
|
144
|
+
### From the application's routes
|
|
145
|
+
|
|
146
|
+
Render the pages from your router's routes instead, inside the feature's `CrudProvider`. Give the item page a `key` that changes between adding and an id: the page sets its mode once, when it is created.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import type { ReactNode } from 'react';
|
|
150
|
+
|
|
151
|
+
import {
|
|
152
|
+
CrudProvider,
|
|
153
|
+
SmartCrudItemPage,
|
|
154
|
+
SmartCrudListPage,
|
|
155
|
+
} from '@smartsoft001/crud-shell-react';
|
|
156
|
+
|
|
157
|
+
import { notesConfig } from './notes.config';
|
|
158
|
+
|
|
159
|
+
function NotesFeature({ children }: { children: ReactNode }) {
|
|
160
|
+
return <CrudProvider config={notesConfig}>{children}</CrudProvider>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Route "/notes"
|
|
164
|
+
export const NotesListRoute = () => (
|
|
165
|
+
<NotesFeature>
|
|
166
|
+
<SmartCrudListPage basePath="/notes" />
|
|
167
|
+
</NotesFeature>
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
// Route "/notes/add"
|
|
171
|
+
export const NotesAddRoute = () => (
|
|
172
|
+
<NotesFeature>
|
|
173
|
+
<SmartCrudItemPage key="add" basePath="/notes" />
|
|
174
|
+
</NotesFeature>
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
// Route "/notes/:id" (pass the router's param)
|
|
178
|
+
export const NotesItemRoute = ({ id }: { id: string }) => (
|
|
179
|
+
<NotesFeature>
|
|
180
|
+
<SmartCrudItemPage key="item" id={id} basePath="/notes" />
|
|
181
|
+
</NotesFeature>
|
|
182
|
+
);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Connect the router to `SmartProvider` through a navigation adapter (`react-provider`), so the add button, row links and post-save navigation go through it.
|
|
186
|
+
|
|
187
|
+
### Page behaviour
|
|
188
|
+
|
|
189
|
+
- **List page** (`SmartCrudListPage`, props `basePath?`, `children?`): renders nothing until the first read has set the feature's filter. The first read uses `pagination`, the default `sort`, `baseQuery` and the search filter. Header buttons: multi edit, filters, add, export and `config.buttons`. A navigation closes the end menu and ends the multi selection.
|
|
190
|
+
- **Item page** (`SmartCrudItemPage`, props `id?`, `basePath?`, `children?`): without `id` it creates (`'create'`); with an id it shows details (`'details'`) when `details` is set, else the form (`'update'`). `?edit=1` in the URL, or the edit button (with `edit` and the model's `update.enabled`), switches to `'update'`. Add and save validate the body's form first (`formRef`) and list the invalid fields in a toast; add creates the form value, save sends the changed values with the id (`updatePartial`). Afterwards the page goes to `basePath` (or back in the history without it), or back to the details when there are details.
|
|
191
|
+
- `useCrudPageConfig()` is the configuration with `add` / `edit` / `remove` turned off where the user lacks the model's `create` / `update` / `remove` permissions (`applyPagePermissions(config, authService)`).
|
|
192
|
+
|
|
193
|
+
## Replacing a page body
|
|
194
|
+
|
|
195
|
+
`SmartCrudListPage` and `SmartCrudItemPage` render a `SmartPage` around a **body**: `SmartCrudListPageStandard` / `SmartCrudItemPageStandard`, unless a component is registered under `'crud-list-page'` / `'crud-item-page'` in the `components` of `SmartProvider`. A registered body renders inside a `.dynamic-content` element and gets the same props as the standard one:
|
|
196
|
+
|
|
197
|
+
- `SmartCrudListPageBodyProps<T>`: `listOptions` (the `IListOptions` for `SmartList`) and `children` (the page's children).
|
|
198
|
+
- `SmartCrudItemPageBodyProps<T>`: `mode` (`'create' | 'update' | 'details'`), `detailsOptions`, `uniqueProvider`, `onChange`, `onPartialChange`, `onValidChange`, **`formRef`** and `children`.
|
|
199
|
+
|
|
200
|
+
An item body **must put the form it renders into `formRef`**, or the add and save buttons do nothing; `useCrudItemPageBase(props)` does it and returns `formOptions` (with the built form as `control`), `form`, `config`, `facade` and `selected`. Call it only in the component that renders that form: two calls would both write `formRef`. The registry is shared by every CRUD feature under the provider, so check `useCrudConfig().entity` and fall back to the standard body for the others:
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import type { ReactNode } from 'react';
|
|
204
|
+
|
|
205
|
+
import {
|
|
206
|
+
SmartCrudItemPageBodyProps,
|
|
207
|
+
SmartCrudItemPageStandard,
|
|
208
|
+
SmartCrudListPageBodyProps,
|
|
209
|
+
SmartCrudListPageStandard,
|
|
210
|
+
useCrudConfig,
|
|
211
|
+
useCrudItemPageBase,
|
|
212
|
+
} from '@smartsoft001/crud-shell-react';
|
|
213
|
+
import {
|
|
214
|
+
ListMode,
|
|
215
|
+
SmartDetails,
|
|
216
|
+
SmartForm,
|
|
217
|
+
SmartList,
|
|
218
|
+
SmartProvider,
|
|
219
|
+
} from '@smartsoft001/react';
|
|
220
|
+
|
|
221
|
+
function NotesListBody(props: SmartCrudListPageBodyProps) {
|
|
222
|
+
const config = useCrudConfig();
|
|
223
|
+
|
|
224
|
+
if (config.entity !== 'notes')
|
|
225
|
+
return <SmartCrudListPageStandard {...props} />;
|
|
226
|
+
|
|
227
|
+
return props.listOptions ? (
|
|
228
|
+
<SmartList options={{ ...props.listOptions, mode: ListMode.masonryGrid }} />
|
|
229
|
+
) : null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Builds the form and puts it into props.formRef, so the page's add / save buttons work.
|
|
233
|
+
function NotesItemForm(props: SmartCrudItemPageBodyProps) {
|
|
234
|
+
const { formOptions } = useCrudItemPageBase(props);
|
|
235
|
+
|
|
236
|
+
return formOptions ? (
|
|
237
|
+
<div className="mx-auto max-w-2xl">
|
|
238
|
+
<SmartForm
|
|
239
|
+
options={formOptions}
|
|
240
|
+
onValueChange={props.onChange}
|
|
241
|
+
onValuePartialChange={props.onPartialChange}
|
|
242
|
+
onValidChange={props.onValidChange}
|
|
243
|
+
/>
|
|
244
|
+
</div>
|
|
245
|
+
) : null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function NotesItemBody(props: SmartCrudItemPageBodyProps) {
|
|
249
|
+
const config = useCrudConfig();
|
|
250
|
+
|
|
251
|
+
// Other features keep the standard body (which fills formRef itself).
|
|
252
|
+
if (config.entity !== 'notes')
|
|
253
|
+
return <SmartCrudItemPageStandard {...props} />;
|
|
254
|
+
|
|
255
|
+
if (props.mode === 'details')
|
|
256
|
+
return props.detailsOptions ? (
|
|
257
|
+
<SmartDetails options={props.detailsOptions} />
|
|
258
|
+
) : null;
|
|
259
|
+
|
|
260
|
+
return <NotesItemForm {...props} />;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const components = {
|
|
264
|
+
'crud-list-page': NotesListBody,
|
|
265
|
+
'crud-item-page': NotesItemBody,
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
269
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
For a page entirely of your own, `useCrudListPage({ basePath })` returns `{ config, filter, pageOptions, listOptions, TopComponent }` and `useCrudItemPage({ id, basePath })` returns `{ config, mode, pageOptions, detailsOptions, uniqueProvider, onPartialChange, onChange, onValidChange, formRef, TopComponent, BottomComponent }`: render a `SmartPage` with `pageOptions` and your own content. Styling of the generated screens otherwise goes through `config.className`, `config.variant`, the registered page / list / form / details implementations and the presets.
|
|
274
|
+
|
|
275
|
+
## Filters, export, multiselect and groups
|
|
276
|
+
|
|
277
|
+
| Component | Props | What it renders |
|
|
278
|
+
| ------------------------ | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
279
|
+
| `SmartCrudFilters` | `hideMenu?` | The filters panel: a header (unless `hideMenu`) and a `SmartCrudFilter` per filter of the model (the `filters` of `@Model`, then every `list: { filter: true }` field). |
|
|
280
|
+
| `SmartCrudFilter` | `item?: IModelFilter`, `filter?: ICrudFilter \| null` | The widget of the filter's field type: `SmartCrudFilterDate`, `SmartCrudFilterDateWithEdit`, `SmartCrudFilterDateTime`, `SmartCrudFilterRadio`, `SmartCrudFilterCheck`, `SmartCrudFilterFlag`, `SmartCrudFilterInt`, else `SmartCrudFilterText`. A change reads the list from the first page, debounced by `CRUD_FILTER_REFRESH_DEBOUNCE` (500 ms). |
|
|
281
|
+
| `SmartCrudFiltersConfig` | — | The visible query items of the current filter as chips that remove themselves on a click (items with `hidden: true` are left out). |
|
|
282
|
+
| `SmartCrudExport` | `dismiss?` | CSV and XLSX buttons for the current filter; calls `dismiss` when the export finished, or closes the last opened modal without one. |
|
|
283
|
+
| `SmartCrudMultiselect` | — | The panel of the items selected in the list: `list.components.multi` and the `multiUpdate` form of the model, applied to every selected item (`updatePartialMany`). |
|
|
284
|
+
| `SmartCrudGroup` | `groups?`, `listOptions?` | `groups` as disclosures, each showing the list filtered by its `key` / `value` (a hidden query item), or its child groups. The standard list body renders it while `list.groups` is set and nothing is searched. |
|
|
285
|
+
|
|
286
|
+
All of them read the nearest `CrudProvider`. Each keeps its logic in a hook for implementations of your own: `useCrudFilters`, `useCrudFilter` (values, `setValue` / `setMinValue` / `setMaxValue`, `refresh`, `clear`, possibilities), `useCrudFilterControl` (a `SmartFormControl` bridged to a query slot), `useCrudFilterDate`, `useCrudFilterValue` (the shown value of a date filter's editor: `[value, setValue]`), `useCrudExport`, `useCrudMultiselect` and `useCrudGroup`.
|
|
287
|
+
|
|
288
|
+
```tsx
|
|
289
|
+
import {
|
|
290
|
+
CrudProvider,
|
|
291
|
+
SmartCrudFilters,
|
|
292
|
+
SmartCrudFiltersConfig,
|
|
293
|
+
SmartCrudListPage,
|
|
294
|
+
} from '@smartsoft001/crud-shell-react';
|
|
295
|
+
|
|
296
|
+
import { notesConfig } from './notes.config';
|
|
297
|
+
|
|
298
|
+
// Filters always visible beside the list instead of in the end menu.
|
|
299
|
+
export function NotesWithSideFilters() {
|
|
300
|
+
return (
|
|
301
|
+
<CrudProvider config={notesConfig}>
|
|
302
|
+
<div className="grid grid-cols-[16rem_1fr] gap-6">
|
|
303
|
+
<SmartCrudFilters hideMenu />
|
|
304
|
+
<div>
|
|
305
|
+
<SmartCrudFiltersConfig />
|
|
306
|
+
<SmartCrudListPage basePath="/notes" />
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
</CrudProvider>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### The end menu belongs to the application
|
|
315
|
+
|
|
316
|
+
The list page opens the filters panel and the multiselect panel in the **end menu** through `MenuService.openEnd({ component })`, with the component bound to the feature by `useCrudBoundComponent` so it works outside the `CrudProvider`. `MenuService` only keeps the request in its `endContent` store, and the default `SmartApp` renders no menu: **the application's shell must render `endContent`** (see the custom shell in `react-components-app`), or the filters and multiselect buttons appear to do nothing. The export panel opens through `ModalService`, whose modals the `SmartOverlays` of `SmartProvider` render. `useCrudBoundComponent(Component)` binds a component of your own the same way, for an end menu or a modal.
|
|
317
|
+
|
|
318
|
+
## Reading a collection in your own component
|
|
319
|
+
|
|
320
|
+
```tsx
|
|
321
|
+
import { useEffect } from 'react';
|
|
322
|
+
|
|
323
|
+
import {
|
|
324
|
+
CrudConfig,
|
|
325
|
+
CrudProvider,
|
|
326
|
+
useCrudFacade,
|
|
327
|
+
useCrudState,
|
|
328
|
+
} from '@smartsoft001/crud-shell-react';
|
|
329
|
+
|
|
330
|
+
export interface Note {
|
|
331
|
+
id: string;
|
|
332
|
+
title: string;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// No model and no screens: the base configuration is enough for the store.
|
|
336
|
+
const recentNotesConfig: CrudConfig<Note> = {
|
|
337
|
+
apiUrl: '/api/notes',
|
|
338
|
+
entity: 'notes',
|
|
339
|
+
baseQuery: [{ key: 'archived', type: '=', value: false }],
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
function NoteTitles() {
|
|
343
|
+
const facade = useCrudFacade<Note>();
|
|
344
|
+
const notes = useCrudState<Note, Note[] | undefined>((state) => state.list);
|
|
345
|
+
const loaded = useCrudState<Note, boolean>((state) => state.loaded);
|
|
346
|
+
|
|
347
|
+
useEffect(() => {
|
|
348
|
+
facade.read({ limit: 5, offset: 0 });
|
|
349
|
+
}, [facade]);
|
|
350
|
+
|
|
351
|
+
if (!loaded) return <p>Loading…</p>;
|
|
352
|
+
|
|
353
|
+
return (
|
|
354
|
+
<ul>
|
|
355
|
+
{(notes ?? []).map((note) => (
|
|
356
|
+
<li key={note.id}>
|
|
357
|
+
{note.title}
|
|
358
|
+
<button type="button" onClick={() => facade.delete(note.id)}>
|
|
359
|
+
Delete
|
|
360
|
+
</button>
|
|
361
|
+
</li>
|
|
362
|
+
))}
|
|
363
|
+
</ul>
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export function RecentNotes() {
|
|
368
|
+
return (
|
|
369
|
+
<CrudProvider config={recentNotesConfig}>
|
|
370
|
+
<NoteTitles />
|
|
371
|
+
</CrudProvider>
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Two `CrudProvider`s of the same `entity` under one `SmartProvider` share the store (the list, the filter, the selection), so a widget like this and the CRUD screens of the same entity see each other's reads; give the widget its own `entity` name to keep it apart.
|
|
377
|
+
|
|
378
|
+
### Hooks
|
|
379
|
+
|
|
380
|
+
| Hook | Returns |
|
|
381
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
382
|
+
| `useCrud()` | The `CrudContextValue` of the nearest provider: `config`, `service`, `store`, `facade`, `searchService`, `listGroupService`. Throws outside a `CrudProvider`. |
|
|
383
|
+
| `useCrudConfig()`, `useCrudService()`, `useCrudFacade()`, `useCrudSearchService()`, `useCrudListGroupService()` | One member each. |
|
|
384
|
+
| `useCrudState(selector?)` | The feature's `CrudState` (`list`, `selected`, `multiSelected`, `totalCount`, `filter`, `links`, `loaded`, `error`), or the selected slice, re-rendering when it changes. `loaded` is `false` until the first read settles and while any request is in flight. |
|
|
385
|
+
| `useCrudListPagination({ mode, limit })` | `IListPaginationOptions` for `SmartList`: `page`, `totalPages` and page loaders that resolve, once the read settled, with whether there is a further page. |
|
|
386
|
+
| `useCrudPageConfig()`, `useCrudListPage(props)`, `useCrudItemPage(props)`, `useCrudItemPageBase(props)`, `useCrudBoundComponent(Component)` | Page logic (see above). |
|
|
387
|
+
|
|
388
|
+
### `CrudFacade<T>`
|
|
389
|
+
|
|
390
|
+
Read side (getters, current values, no subscription: use them in handlers and effects, and `useCrudState` for rendering): `state`, `loaded`, `loading` (`!loaded`, so it starts `true`), `selected`, `multiSelected`, `list`, `filter`, `totalCount`, `links`, `error`.
|
|
391
|
+
|
|
392
|
+
Write side (each dispatches one action): `create(item)`, `createMany(items, { mode: 'default' | 'replace' })`, `read(filter = {})` (adds `config.baseQuery` when the filter has no `query`), `clear()`, `select(id)`, `unselect()`, `multiSelect(items)`, `update(item)` (sent as `PATCH`), `updatePartial(item)`, `updatePartialMany(items)`, `delete(id)`, `export(filter = {}, format?)`. A successful write reads the first page again.
|
|
393
|
+
|
|
394
|
+
`ICrudFilter`: `searchText`, `sortBy`, `sortDesc`, `offset`, `limit`, `paginationMode`, `query` (`ICrudFilterQueryItem`: `key`, `type` one of `=`, `!=`, `>=`, `<=`, `<`, `>`, `value`, `hidden`).
|
|
395
|
+
|
|
396
|
+
## Services and state
|
|
397
|
+
|
|
398
|
+
- `CrudService<T>`: the REST client (`create` resolving with the new id from `Location`, `createMany`, `getById`, `getList(filter)` → `{ data, totalCount, links }`, `exportList(filter, format)`, `update` (PUT), `updatePartial` (PATCH), `updatePartialMany`, `delete`). Pass a subclass as `<CrudProvider service={...}>` to change requests.
|
|
399
|
+
- `CrudStore` (a `SmartStore` with `dispatch` and `onAction`), `CrudEffects`, the action creators (`create`, `read`, `select`, `update`, `deleteItem`, ... with success / failure actions), `getReducer(entity)`, `initialState`, the selectors (`getCrudList`, `getCrudSelected`, `getCrudFilter`, ...).
|
|
400
|
+
- `CrudSearchService` (the header search, one per `SmartProvider`), `CrudListGroupService` (group reads), `getCrudFormOptions(item, mode, type, uniqueProvider?, inputComponents?)`, `CrudModelLabelProvider`.
|
|
401
|
+
|
|
402
|
+
## File Locations
|
|
403
|
+
|
|
404
|
+
Source: `packages/crud/shell/react/src/lib/` in the smartsoft001 repository.
|
|
405
|
+
|
|
406
|
+
- `crud.config.ts`, `crud.provider.tsx`, `crud.context.ts`, `hooks.ts`: configuration, provider and hooks
|
|
407
|
+
- `pages/crud-pages.tsx`, `pages/list/`, `pages/item/`, `pages/use-crud-bound-component.tsx`, `pages/use-crud-page-config.ts`
|
|
408
|
+
- `components/`: `filters`, `filter/*`, `filters-config`, `export`, `multiselect`, `group`
|
|
409
|
+
- `services/`: `crud`, `search`, `list-group`, `page`; `state/`: store, actions, effects, reducer, selectors, facade
|
|
410
|
+
- Docs: `docs/site/src/app/docs/packages/crud-shell-react/page.md`
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/angular-components-description-list/SKILL.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/angular-components-multi-column-layout/SKILL.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/angular-components-password-strength/SKILL.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-navigation/SKILL.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/angular-components-vertical-navigation/SKILL.md
RENAMED
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-app.md
RENAMED
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-shared-lib.md
RENAMED
|
File without changes
|
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/derive-prefix.sh
RENAMED
|
File without changes
|
/package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/verify-scaffold.sh
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|