@smartsoft001/claude-plugins 2.203.0 → 2.204.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/package.json +1 -1
- package/plugins/smart-angular/.claude-plugin/plugin.json +1 -1
- package/plugins/smart-angular/skills/angular-components-details/SKILL.md +5 -5
- package/plugins/smart-angular/skills/angular-components-list/SKILL.md +2 -2
- package/plugins/smart-angular/skills/angular-components-modal/SKILL.md +35 -21
- package/plugins/smart-angular/skills/angular-components-notification/SKILL.md +51 -1
- package/plugins/smart-core/.claude-plugin/plugin.json +1 -1
- package/plugins/smart-react/.claude-plugin/plugin.json +1 -1
- package/plugins/smart-react/skills/react-components-details/SKILL.md +5 -5
- package/plugins/smart-react/skills/react-components-list/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-modal/SKILL.md +24 -12
- package/plugins/smart-react/skills/react-components-notification/SKILL.md +1 -1
- package/plugins/smart-react/skills/react-components-overlays/SKILL.md +14 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartsoft001/claude-plugins",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.204.0",
|
|
4
4
|
"description": "Installs the smartsoft Claude Code plugins into a project: smart-core (hooks and framework-neutral skills) plus smart-angular or smart-react (the component and CRUD skills and agents of one framework).",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-angular",
|
|
3
3
|
"description": "Smartsoft for Angular projects - the @smartsoft001/angular component skills and their angular-components agent, the Angular CRUD skill and the Nx + Angular SSR workspace scaffold",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.203.0",
|
|
5
5
|
"dependencies": ["smart-core"]
|
|
6
6
|
}
|
|
@@ -139,11 +139,11 @@ export class MyCustomDetailsComponent extends DetailsBaseComponent<any> {}
|
|
|
139
139
|
|
|
140
140
|
The `[smartDetails]` directive (`DetailsDirective`) opens a component in a modal on click, through `ModalService` (see `angular-components-modal`), with its `params` as the `value` input. It emits `smartDetailsShowed` once the modal is open and `smartDetailsDismissed` once it is closed; the browser's back button (`HardwareService.onBackButtonClick`, the window's `popstate`) closes the modal as well. `showDetailsModal(services, options, callbacks)` does the same from code, and is what `<smart-list>` uses for its `details` option (see `angular-components-list`).
|
|
141
141
|
|
|
142
|
-
| `[smartDetails]` field | Type | Default | Description
|
|
143
|
-
| ---------------------- | ----------------------- | ---------- |
|
|
144
|
-
| `component` | `any` | required | Rendered in the modal, e.g. `DetailsPage`.
|
|
145
|
-
| `params` | `any` | required | Its `value` input, e.g. an `IDetailsOptions`.
|
|
146
|
-
| `mode` | `'bottom' \| 'default'` | `'bottom'` | Passed to `ModalService.show` as `mode
|
|
142
|
+
| `[smartDetails]` field | Type | Default | Description |
|
|
143
|
+
| ---------------------- | ----------------------- | ---------- | ------------------------------------------------------------------------- |
|
|
144
|
+
| `component` | `any` | required | Rendered in the modal, e.g. `DetailsPage`. |
|
|
145
|
+
| `params` | `any` | required | Its `value` input, e.g. an `IDetailsOptions`. |
|
|
146
|
+
| `mode` | `'bottom' \| 'default'` | `'bottom'` | Passed to `ModalService.show` as `mode`; `'bottom'` opens a bottom sheet. |
|
|
147
147
|
|
|
148
148
|
```html
|
|
149
149
|
<button
|
|
@@ -59,7 +59,7 @@ Methods:
|
|
|
59
59
|
- `initKeys()` (protected) — populates `keys` from the resolved fields
|
|
60
60
|
- `handlePageChange(page: number)` — calls `loadNextPage()` for a later page and `loadPrevPage()` for an earlier one
|
|
61
61
|
- `isSortable(key)`, `sortBy(key)`, `ariaSort(key)`, `sortIndicator(key)` — whether a header sorts (every field column with `sort`, not the `__array` columns of a `dynamic` field), sort by it (calls `provider.getData({ offset: 0, sortBy, sortDesc })`), its `aria-sort` (`'ascending'` / `'descending'` on the active header, `null` otherwise) and its arrow (`↑`, `↓`, `↕`)
|
|
62
|
-
- `openDetails(item)` — clears the details provider (`unselect()`), opens `detailsComponent ?? DetailsPage` in a `'bottom'` modal through `showDetailsModal` with `{ value: detailsComponentProps }`, then calls `select(item.id)`
|
|
62
|
+
- `openDetails(item)` — clears the details provider (`unselect()`), opens `detailsComponent ?? DetailsPage` in a `'bottom'` modal (a bottom sheet) through `showDetailsModal` with `{ value: detailsComponentProps }`, then calls `select(item.id)`
|
|
63
63
|
|
|
64
64
|
## API
|
|
65
65
|
|
|
@@ -188,7 +188,7 @@ With `sort` set (`true`, or `{ default?, defaultDesc? }`), every field header of
|
|
|
188
188
|
|
|
189
189
|
## Details
|
|
190
190
|
|
|
191
|
-
With `details: { provider }`, every item gets a details action, labelled with the `show` translation (`data-role="details"`): a column of the desktop table and a button in the mobile rows and the masonry tiles (standard and presets). It clears the provider (`clearData()`), opens `details.component`, or `DetailsPage` by default, in a
|
|
191
|
+
With `details: { provider }`, every item gets a details action, labelled with the `show` translation (`data-role="details"`): a column of the desktop table and a button in the mobile rows and the masonry tiles (standard and presets). It clears the provider (`clearData()`), opens `details.component`, or `DetailsPage` by default, in a bottom sheet through `ModalService` (mode `'bottom'`, see `angular-components-modal`) with `{ value: detailsComponentProps }`, and asks the provider for the item (`getData(id)`). `detailsComponentProps` is an `IDetailsOptions`: `item` and `loading` from the provider (signals, so the modal shows the item once it is loaded), `type`, the list's `itemHandler` and `removeHandler` and `details.componentFactories`. The browser's back button closes the modal. Without a `provider`, setting `details` throws `Must set details provider`.
|
|
192
192
|
|
|
193
193
|
## Infinite scroll
|
|
194
194
|
|
|
@@ -22,11 +22,11 @@ Main wrapper component. Renders `ModalStandardComponent` by default. When `MODAL
|
|
|
22
22
|
|
|
23
23
|
### ModalStandardComponent (`<smart-modal-standard>`)
|
|
24
24
|
|
|
25
|
-
Barebones placeholder concrete implementation. Renders a native `<dialog [open] role="dialog" aria-modal="true">` containing an optional `<h2 id="smart-modal-title">`, an optional `<p>` description, an `<ng-content>` slot for arbitrary body content, an optional dismiss `<button>` (when `options.withDismiss` is `true`), and a `<footer>` with one `<button data-variant>` per action. It does not include Tailwind UI styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.
|
|
25
|
+
Barebones placeholder concrete implementation. Renders a native `<dialog [open] role="dialog" aria-modal="true">` containing an optional `<h2 id="smart-modal-title">`, an optional `<p>` description, an `<ng-content>` slot for arbitrary body content, an optional dismiss `<button>` (when `options.withDismiss` is `true`), and a `<footer>` with one `<button data-variant>` per action. The dialog carries `options.variant` as `data-variant`. It does not include Tailwind UI styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token — except for the `bottom-sheet` variant, which it docks to the bottom of the viewport (see the Variants table).
|
|
26
26
|
|
|
27
27
|
### ModalPresetComponent (`<smart-modal-preset>`)
|
|
28
28
|
|
|
29
|
-
Styled variation that extends `ModalBaseComponent` and is a drop-in replacement for `ModalStandardComponent`. Register it via `MODAL_STANDARD_COMPONENT_TOKEN` (or with `provideSmartPresets()`) to restyle every `<smart-modal>`, or use the `<smart-modal-preset>` selector directly. It renders a translated Preline overlay — a full-screen scrollable backdrop hosting a `rounded-xl` card with a header (`title` + optional dismiss `×`), a body (`description` + projected content), and a footer of action buttons. The look is selected through `options.variant` (default `'centered'`): `centered`/`alert` are vertically centered (`alert` is narrower), `wide` is a top-aligned large dialog,
|
|
29
|
+
Styled variation that extends `ModalBaseComponent` and is a drop-in replacement for `ModalStandardComponent`. Register it via `MODAL_STANDARD_COMPONENT_TOKEN` (or with `provideSmartPresets()`) to restyle every `<smart-modal>`, or use the `<smart-modal-preset>` selector directly. It renders a translated Preline overlay — a full-screen scrollable backdrop hosting a `rounded-xl` card with a header (`title` + optional dismiss `×`), a body (`description` + projected content), and a footer of action buttons. The look is selected through `options.variant` (default `'centered'`): `centered`/`alert` are vertically centered (`alert` is narrower), `wide` is a top-aligned large dialog, `left-aligned-buttons` left-aligns the footer, and `bottom-sheet` docks the card to the bottom of the viewport (see the Variants table). `options.footerStyle: 'gray'` tints the footer, and action buttons are styled by their `variant` (`primary`/`secondary`/`danger`). All classes are `smart:`-prefixed Tailwind with explicit `dark:` variants; the class recipes are internal to the preset (not exported).
|
|
30
30
|
|
|
31
31
|
> **Preline JS is NOT used.** Open/close is driven entirely by the existing `open` model signal + `@if` (no `HSOverlay`, no `data-hs-*`). The component binds its own dismiss UX: clicking the backdrop and pressing `Escape` both call `close()` (which sets `open` to `false` and emits `closed`). With preset modals stacked (a modal opened from a modal), `Escape` closes only the one on top. The dialog ARIA contract is preserved (`role="dialog"`, `aria-modal="true"`, `aria-labelledby` when `title` is set, else `aria-label` from `options.ariaLabel`). The header dismiss `×` button is only shown when `options.withDismiss` is `true`.
|
|
32
32
|
>
|
|
@@ -74,23 +74,36 @@ interface IModalAction {
|
|
|
74
74
|
|
|
75
75
|
### IModalOptions
|
|
76
76
|
|
|
77
|
-
| Field | Type
|
|
78
|
-
| ------------- |
|
|
79
|
-
| `variant` | `'centered'
|
|
80
|
-
| `withDismiss` | `boolean`
|
|
81
|
-
| `footerStyle` | `'default' \| 'gray'`
|
|
82
|
-
| `ariaLabel` | `string`
|
|
77
|
+
| Field | Type | Default | Description |
|
|
78
|
+
| ------------- | --------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
79
|
+
| `variant` | `SmartModalVariant` | `'centered'` | The layout, one of the variants in the Variants table. The preset styles each of them; the standard exposes it as `data-variant` and positions only `bottom-sheet`. |
|
|
80
|
+
| `withDismiss` | `boolean` | `false` | Renders a close (×) button that calls `close()`. |
|
|
81
|
+
| `footerStyle` | `'default' \| 'gray'` | `'default'` | Preset only: `gray` gives the footer a gray background. |
|
|
82
|
+
| `ariaLabel` | `string` | - | The `aria-label` of the dialog when there is no `title`. |
|
|
83
83
|
|
|
84
84
|
```typescript
|
|
85
85
|
interface IModalOptions {
|
|
86
|
-
variant?:
|
|
86
|
+
variant?:
|
|
87
|
+
'centered' | 'wide' | 'alert' | 'left-aligned-buttons' | 'bottom-sheet';
|
|
87
88
|
withDismiss?: boolean;
|
|
88
89
|
footerStyle?: 'default' | 'gray';
|
|
89
90
|
ariaLabel?: string;
|
|
90
91
|
}
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
The default `ModalStandardComponent` consumes `withDismiss` and `ariaLabel
|
|
94
|
+
The default `ModalStandardComponent` consumes `withDismiss` and `ariaLabel`, exposes `variant` as `data-variant` on the dialog and positions the `bottom-sheet` variant; `footerStyle` is read by `ModalPresetComponent` only. A custom implementation receives every field.
|
|
95
|
+
|
|
96
|
+
### Variants
|
|
97
|
+
|
|
98
|
+
`SmartModalVariant` (from `@smartsoft001/angular`) names the layouts of `options.variant`.
|
|
99
|
+
|
|
100
|
+
| Variant | `ModalPresetComponent` | `ModalStandardComponent` |
|
|
101
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
102
|
+
| `centered` (default) | A card centred vertically, `max-w-lg` from `sm`. | The browser's dialog layout. |
|
|
103
|
+
| `wide` | A top-aligned card, `max-w-4xl` from `lg`. | The browser's dialog layout. |
|
|
104
|
+
| `alert` | A narrower centred card, `max-w-md` from `sm`. | The browser's dialog layout. |
|
|
105
|
+
| `left-aligned-buttons` | Like `centered`, with the footer buttons aligned to the left. | The browser's dialog layout. |
|
|
106
|
+
| `bottom-sheet` | A sheet docked to the bottom of the viewport: full width, centred under `max-w-2xl` with rounded top corners from `sm`, at most 85% of the viewport high with the body scrolling, padded by the bottom safe area. Same backdrop, Escape and close button as the others. | The `<dialog>` fixed to the bottom of the viewport (`z-[80]`), full width, `max-w-2xl` with rounded top corners from `sm`, at most 85% of the viewport high and scrolling. |
|
|
94
107
|
|
|
95
108
|
## MODAL_STANDARD_COMPONENT_TOKEN
|
|
96
109
|
|
|
@@ -154,7 +167,8 @@ export class MyCustomModalComponent extends ModalBaseComponent {}
|
|
|
154
167
|
The inherited `cssClass` (input alias `class`) receives the class passed to `<smart-modal>`. When extending the base directly, remember to:
|
|
155
168
|
|
|
156
169
|
- call `invokeAction(id)` to emit `actionClick`, and `close()` to emit `closed` and set `open.set(false)`,
|
|
157
|
-
- implement `Escape` key handling and backdrop click yourself if you want native UX — the base does not bind any keyboard or backdrop listeners
|
|
170
|
+
- implement `Escape` key handling and backdrop click yourself if you want native UX — the base does not bind any keyboard or backdrop listeners,
|
|
171
|
+
- lay out `options()?.variant === 'bottom-sheet'` as a bottom sheet: `ModalService` opens `mode: 'bottom'` with that variant.
|
|
158
172
|
|
|
159
173
|
## Usage Examples
|
|
160
174
|
|
|
@@ -186,14 +200,14 @@ The inherited `cssClass` (input alias `class`) receives the class passed to `<sm
|
|
|
186
200
|
|
|
187
201
|
`ModalService.show(options)` (provided by `SharedServicesModule`) creates `options.component` inside a `<smart-modal>` at the end of `<body>` and resolves with an `IModal`. The modal is the implementation registered for `MODAL_STANDARD_COMPONENT_TOKEN` (the preset with `provideSmartPresets()`) and shows its close button (`withDismiss`). `props` become the component's inputs (keys it does not declare as inputs are left out), and a component that declares a `dismiss` input gets the function that closes its modal. A component can also inject `ModalService` and call `dismiss(data)`: it resolves to the service that opened it. The modals stack; `ModalService.dismiss(data)` closes the one opened last. Closing a modal restores the focus to the element focused before it opened.
|
|
188
202
|
|
|
189
|
-
| Option | Type | Default | Description
|
|
190
|
-
| ----------------- | ----------------------- | ----------- |
|
|
191
|
-
| `component` | `any` | required | The component rendered in the modal.
|
|
192
|
-
| `props` | `any` | - | Its inputs, by input name.
|
|
193
|
-
| `mode` | `'default' \| 'bottom'` | `'default'` | `'bottom'` adds the `smart-modal-bottom` class
|
|
194
|
-
| `cssClass` | `string[]` | - | Classes passed to the modal as `class`.
|
|
195
|
-
| `backdropDismiss` | `boolean` | `true` | `false` keeps the modal open on a click on its backdrop and on Escape; its close button and `dismiss()` still close it.
|
|
196
|
-
| `injector` | `Injector` | - | The injector the component resolves its dependencies from (e.g. the opener's `inject(Injector)`), the service's otherwise.
|
|
203
|
+
| Option | Type | Default | Description |
|
|
204
|
+
| ----------------- | ----------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
205
|
+
| `component` | `any` | required | The component rendered in the modal. |
|
|
206
|
+
| `props` | `any` | - | Its inputs, by input name. |
|
|
207
|
+
| `mode` | `'default' \| 'bottom'` | `'default'` | `'bottom'` opens the modal as a bottom sheet (the `bottom-sheet` variant, see the Variants table) and adds the `smart-modal-bottom` class for an application's own styling; the modal element carries `data-mode`. |
|
|
208
|
+
| `cssClass` | `string[]` | - | Classes passed to the modal as `class`. |
|
|
209
|
+
| `backdropDismiss` | `boolean` | `true` | `false` keeps the modal open on a click on its backdrop and on Escape; its close button and `dismiss()` still close it. |
|
|
210
|
+
| `injector` | `Injector` | - | The injector the component resolves its dependencies from (e.g. the opener's `inject(Injector)`), the service's otherwise. |
|
|
197
211
|
|
|
198
212
|
| `IModal` member | Type | Description |
|
|
199
213
|
| ---------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -232,7 +246,7 @@ export class RenameAction {
|
|
|
232
246
|
}
|
|
233
247
|
```
|
|
234
248
|
|
|
235
|
-
`[smartDetails]` and `DetailsPage` (see `angular-components-details`) open details through the same service
|
|
249
|
+
`[smartDetails]` and `DetailsPage` (see `angular-components-details`) open details through the same service, as a bottom sheet by default; so does the `details` option of `<smart-list>`.
|
|
236
250
|
|
|
237
251
|
## File Locations
|
|
238
252
|
|
|
@@ -243,5 +257,5 @@ export class RenameAction {
|
|
|
243
257
|
- Base class: `packages/shared/angular/src/lib/components/modal/base/base.component.ts`
|
|
244
258
|
- Stories: `packages/shared/angular/src/lib/components/modal/modal.component.stories.ts`
|
|
245
259
|
- Token: `packages/shared/angular/src/lib/shared.inectors.ts` (`MODAL_STANDARD_COMPONENT_TOKEN`)
|
|
246
|
-
- Interfaces: `packages/shared/angular/src/lib/models/interfaces.ts` (`IModalAction`, `IModalOptions`)
|
|
260
|
+
- Interfaces: `packages/shared/angular/src/lib/models/interfaces.ts` (`IModalAction`, `IModalOptions`, `SmartModalVariant`)
|
|
247
261
|
- Service: `packages/shared/angular/src/lib/services/modal/modal.service.ts` (`ModalService`, `IModalServiceOptions`, `IModal`)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: angular-components-notification
|
|
3
|
-
description: Notification component API with InjectionToken pattern for custom implementations.
|
|
3
|
+
description: Notification component API with InjectionToken pattern for custom implementations, and ToastService for showing toasts from code.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -12,6 +12,7 @@ The `<smart-notification>` component displays a transient or persistent message
|
|
|
12
12
|
|
|
13
13
|
- Developer wants to use or customize the notification component
|
|
14
14
|
- Developer asks about `<smart-notification>`, `NotificationComponent`, `NotificationStandardComponent`, or `NotificationBaseComponent`
|
|
15
|
+
- Developer wants to show a toast from code (`ToastService`), or toasts and `ErrorService` errors do not appear
|
|
15
16
|
|
|
16
17
|
## Components
|
|
17
18
|
|
|
@@ -185,6 +186,54 @@ The inherited `cssClass` (input alias `class`) receives the class passed to `<sm
|
|
|
185
186
|
- The dismiss button carries `aria-label="Close"` since its visible content is the `×` glyph.
|
|
186
187
|
- Custom implementations should preserve `role="status"` and `aria-live` to keep this contract.
|
|
187
188
|
|
|
189
|
+
## Toasts from code
|
|
190
|
+
|
|
191
|
+
`ToastService` (provided by `SharedServicesModule`) shows short messages at the bottom of the screen. While it has toasts it mounts one host at the end of `<body>`: a stack fixed to the bottom of the viewport (centred, right-aligned from `sm`, above the modals), every toast rendered through `<smart-notification>`. The implementation registered for `NOTIFICATION_STANDARD_COMPONENT_TOKEN` (the preset with `provideSmartPresets()`) therefore restyles the toasts too; the standard one renders them unstyled. A toast shows its `title` as the heading with the `message` under it, or the `message` alone, and its `buttons` as the notification's actions. It closes itself after `duration` ms, on its close button, or once the handler of one of its buttons ran. `ErrorService.log(error)` and the file inputs report their errors through it.
|
|
192
|
+
|
|
193
|
+
| Member | What it does |
|
|
194
|
+
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
195
|
+
| `info(options: IToastOptions): Promise<void>` | Shows an info toast, announced politely (`aria-live="polite"`). |
|
|
196
|
+
| `error(options: IToastOptions): Promise<void>` | Shows an error toast, announced assertively (`aria-live="assertive"`), unless an error lock is held. |
|
|
197
|
+
| `dismiss(id: number): void` | Closes a toast. |
|
|
198
|
+
| `addLockError()` / `removeLockError()` | Holds / releases an error lock, counted in the static `ToastService.lockError` (never below zero). While a lock is held, error toasts are swallowed, e.g. during a sign-out that makes requests fail. |
|
|
199
|
+
| `toasts: Signal<IToast[]>` | The toasts shown, oldest first (`IToast` adds `id` and `type: 'error' \| 'info'` to the options). |
|
|
200
|
+
|
|
201
|
+
| `IToastOptions` field | Type | Default | Description |
|
|
202
|
+
| --------------------- | ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
203
|
+
| `title` | `string` | - | The heading; the message goes under it. |
|
|
204
|
+
| `message` | `string` | required | The text; the heading when there is no title. |
|
|
205
|
+
| `duration` | `number` | `2000` | Milliseconds before the toast closes itself; a missing, zero or negative value means 2000. |
|
|
206
|
+
| `buttons` | `IToastButton[]` | - | `{ text, position: 'start' \| 'end', handler }`: a click runs `handler`, then closes the toast. `position` is kept for compatibility; the actions keep the given order. |
|
|
207
|
+
|
|
208
|
+
A toast without buttons renders in the `simple` notification variant, a message with buttons in `condensed`, and a title with a message and buttons in `with-actions-below`, which keeps the message under the title.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import { inject, Injectable } from '@angular/core';
|
|
212
|
+
|
|
213
|
+
import { ToastService } from '@smartsoft001/angular';
|
|
214
|
+
|
|
215
|
+
@Injectable()
|
|
216
|
+
export class SaveAction {
|
|
217
|
+
private toastService = inject(ToastService);
|
|
218
|
+
|
|
219
|
+
async run(save: () => Promise<void>, undo: () => void): Promise<void> {
|
|
220
|
+
try {
|
|
221
|
+
await save();
|
|
222
|
+
await this.toastService.info({
|
|
223
|
+
message: 'Saved',
|
|
224
|
+
buttons: [{ text: 'Undo', position: 'end', handler: undo }],
|
|
225
|
+
});
|
|
226
|
+
} catch {
|
|
227
|
+
await this.toastService.error({
|
|
228
|
+
title: 'Saving failed',
|
|
229
|
+
message: 'Try again in a moment.',
|
|
230
|
+
duration: 5000,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
188
237
|
## Usage Examples
|
|
189
238
|
|
|
190
239
|
```html
|
|
@@ -231,3 +280,4 @@ The inherited `cssClass` (input alias `class`) receives the class passed to `<sm
|
|
|
231
280
|
- Base class: `packages/shared/angular/src/lib/components/notification/base/base.component.ts`
|
|
232
281
|
- Token: `packages/shared/angular/src/lib/shared.inectors.ts` (`NOTIFICATION_STANDARD_COMPONENT_TOKEN`)
|
|
233
282
|
- Interfaces: `packages/shared/angular/src/lib/models/interfaces.ts` (`INotificationAction`, `INotificationOptions`, `SmartNotificationVariant`)
|
|
283
|
+
- Toasts: `packages/shared/angular/src/lib/services/toast/toast.service.ts` (`ToastService`, `IToastOptions`, `IToastButton`, `IToast`) and its host `toast-host.component.ts`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-core",
|
|
3
3
|
"description": "Smartsoft core for every project - safety validation, audit logging and auto-formatting hooks, plus the framework-neutral skills (audit-log, format-code, project-conventions, safety-check)",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.203.0"
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smart-react",
|
|
3
3
|
"description": "Smartsoft for React projects - the @smartsoft001/react component, provider and forms skills, their react-components agent, and the React CRUD skill (@smartsoft001/crud-shell-react)",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.203.0",
|
|
5
5
|
"dependencies": ["smart-core"]
|
|
6
6
|
}
|
|
@@ -40,11 +40,11 @@ All from `@smartsoft001/react`.
|
|
|
40
40
|
|
|
41
41
|
What `useDetailsModal` opens: a component and its params.
|
|
42
42
|
|
|
43
|
-
| Field | Type | Default | Description
|
|
44
|
-
| ----------- | ----------------------- | ---------- |
|
|
45
|
-
| `component` | `ComponentType<any>` | required | Rendered in the modal, with `params` as its `value` prop.
|
|
46
|
-
| `params` | `any` | required | Passed to the component as its `value` prop.
|
|
47
|
-
| `mode?` | `'bottom' \| 'default'` | `'bottom'` | Passed to `ModalService.show`; `'bottom'`
|
|
43
|
+
| Field | Type | Default | Description |
|
|
44
|
+
| ----------- | ----------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `component` | `ComponentType<any>` | required | Rendered in the modal, with `params` as its `value` prop. |
|
|
46
|
+
| `params` | `any` | required | Passed to the component as its `value` prop. |
|
|
47
|
+
| `mode?` | `'bottom' \| 'default'` | `'bottom'` | Passed to `ModalService.show`; `'bottom'` opens a bottom sheet (the `bottom-sheet` variant) with the `smart-modal-bottom` class. |
|
|
48
48
|
|
|
49
49
|
### `IDetailsOptions<T extends IEntity<string>>`
|
|
50
50
|
|
|
@@ -259,7 +259,7 @@ With `sort` set (`true`, or `{ default?, defaultDesc? }`), every field header of
|
|
|
259
259
|
|
|
260
260
|
## Details
|
|
261
261
|
|
|
262
|
-
With `details: { provider }`, every item gets a details action, labelled with the `show` translation (`data-role="details"`): a column of the desktop table and a button in the mobile rows and the masonry tiles (standard and presets). `useList().detailsHandler(item)` clears the provider (`clearData()`), opens `SmartListDetailsModal` through `ModalService` (mode `'bottom'`, rendered by `SmartModalHost`, see `react-components-overlays`) around `details.component`, or `SmartDetailsPage` by default, and asks the provider for the item (`getData(id)`). The modal reads `detailsComponentProps` (`IDetailsOptions`: `item` and `loading` from the provider, `type`, the list's `itemHandler` / `removeHandler`, `details.componentFactories`) from a store the list updates, so it shows the item once the provider has loaded it. Without a `provider`, setting `details` throws `Must set details provider`.
|
|
262
|
+
With `details: { provider }`, every item gets a details action, labelled with the `show` translation (`data-role="details"`): a column of the desktop table and a button in the mobile rows and the masonry tiles (standard and presets). `useList().detailsHandler(item)` clears the provider (`clearData()`), opens `SmartListDetailsModal` in a bottom sheet through `ModalService` (mode `'bottom'`, rendered by `SmartModalHost`, see `react-components-overlays`) around `details.component`, or `SmartDetailsPage` by default, and asks the provider for the item (`getData(id)`). The modal reads `detailsComponentProps` (`IDetailsOptions`: `item` and `loading` from the provider, `type`, the list's `itemHandler` / `removeHandler`, `details.componentFactories`) from a store the list updates, so it shows the item once the provider has loaded it. Without a `provider`, setting `details` throws `Must set details provider`.
|
|
263
263
|
|
|
264
264
|
## Infinite scroll
|
|
265
265
|
|
|
@@ -6,7 +6,7 @@ user-invocable: false
|
|
|
6
6
|
|
|
7
7
|
# Modal (`SmartModal`)
|
|
8
8
|
|
|
9
|
-
`SmartModal` is a dialog with a title, a description, a body (`children`) and footer buttons (`actions`). A footer button reports `onActionClick({ actionId })` and **keeps the modal open**: close it yourself (set `open` to `false`). The open state is controlled (`open` + `onOpenChange`) or kept inside (`defaultOpen`); closing through the dismiss button, the backdrop or Escape calls `onClosed`. `SmartModalStandard` is a native `<dialog>` shown through its `open` attribute; `SmartModalPreset` is a styled overlay with
|
|
9
|
+
`SmartModal` is a dialog with a title, a description, a body (`children`) and footer buttons (`actions`). A footer button reports `onActionClick({ actionId })` and **keeps the modal open**: close it yourself (set `open` to `false`). The open state is controlled (`open` + `onOpenChange`) or kept inside (`defaultOpen`); closing through the dismiss button, the backdrop or Escape calls `onClosed`. `SmartModalStandard` is a native `<dialog>` shown through its `open` attribute; `SmartModalPreset` is a styled overlay with five variants, one of them a bottom sheet (`bottom-sheet`), which the standard docks to the bottom of the viewport as well. The modal host of `SmartProvider` renders `useModalService().show(...)` requests through the same `modal` key.
|
|
10
10
|
|
|
11
11
|
## When to Use This Skill
|
|
12
12
|
|
|
@@ -50,12 +50,24 @@ The preset's class helpers (`getModalWrapperClasses`, `getModalPanelClasses`, `g
|
|
|
50
50
|
|
|
51
51
|
### `IModalOptions`
|
|
52
52
|
|
|
53
|
-
| Field | Type | Default | Description
|
|
54
|
-
| -------------- | ----------------------- | ------------ |
|
|
55
|
-
| `variant?` | `SmartModalVariant` | `'centered'` |
|
|
56
|
-
| `withDismiss?` | `boolean` | — | Shows a close (×) button that closes the modal.
|
|
57
|
-
| `footerStyle?` | `SmartModalFooterStyle` | `'default'` | Preset: `gray` gives the footer a gray background.
|
|
58
|
-
| `ariaLabel?` | `string` | — | Accessible name when there is no title.
|
|
53
|
+
| Field | Type | Default | Description |
|
|
54
|
+
| -------------- | ----------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `variant?` | `SmartModalVariant` | `'centered'` | The layout, one of the variants in the Variants table; the standard exposes it as `data-variant` and positions only `bottom-sheet`. |
|
|
56
|
+
| `withDismiss?` | `boolean` | — | Shows a close (×) button that closes the modal. |
|
|
57
|
+
| `footerStyle?` | `SmartModalFooterStyle` | `'default'` | Preset: `gray` gives the footer a gray background. |
|
|
58
|
+
| `ariaLabel?` | `string` | — | Accessible name when there is no title. |
|
|
59
|
+
|
|
60
|
+
### Variants
|
|
61
|
+
|
|
62
|
+
The values of `SmartModalVariant`, the layouts of `options.variant`.
|
|
63
|
+
|
|
64
|
+
| Variant | `SmartModalPreset` | `SmartModalStandard` |
|
|
65
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `centered` (default) | A card centred vertically, `max-w-lg` from `sm`. | The browser's dialog layout. |
|
|
67
|
+
| `wide` | A top-aligned card, `max-w-4xl` from `lg`. | The browser's dialog layout. |
|
|
68
|
+
| `alert` | A narrower centred card, `max-w-md` from `sm`. | The browser's dialog layout. |
|
|
69
|
+
| `left-aligned-buttons` | Like `centered`, with the footer buttons aligned to the left. | The browser's dialog layout. |
|
|
70
|
+
| `bottom-sheet` | A sheet docked to the bottom of the viewport: full width, centred under `max-w-2xl` with rounded top corners from `sm`, at most 85% of the viewport high with the body scrolling, padded by the bottom safe area. Same backdrop, Escape and close button as the others. | The `<dialog>` fixed to the bottom of the viewport (`z-[80]`), full width, `max-w-2xl` with rounded top corners from `sm`, at most 85% of the viewport high and scrolling. |
|
|
59
71
|
|
|
60
72
|
### `IModalActionClick`
|
|
61
73
|
|
|
@@ -76,12 +88,12 @@ Payload of `onActionClick`.
|
|
|
76
88
|
### Related types
|
|
77
89
|
|
|
78
90
|
- `SmartModalActionVariant`: `'primary' \| 'secondary' \| 'danger'`
|
|
79
|
-
- `SmartModalVariant`: `'centered' \| 'wide' \| 'alert' \| 'left-aligned-buttons'`
|
|
91
|
+
- `SmartModalVariant`: `'centered' \| 'wide' \| 'alert' \| 'left-aligned-buttons' \| 'bottom-sheet'`
|
|
80
92
|
- `SmartModalFooterStyle`: `'default' \| 'gray'`
|
|
81
93
|
|
|
82
94
|
## Opening a component in a modal from code
|
|
83
95
|
|
|
84
|
-
`useModalService().show({ component, props })` opens `component` inside a `SmartModal` with its close button, rendered by the modal host of `SmartProvider` (see `react-components-overlays`, which also describes `mode`, `cssClass` and `backdropDismiss`). The component receives its `props` and a `dismiss(data)` prop; `onDidDismiss()` resolves with `{ data }`, `{ data: null }` when the modal closed itself. `useModalService().dismiss(data)` closes the modal opened last.
|
|
96
|
+
`useModalService().show({ component, props })` opens `component` inside a `SmartModal` with its close button, rendered by the modal host of `SmartProvider` (see `react-components-overlays`, which also describes `mode`, `cssClass` and `backdropDismiss`). `mode: 'bottom'` opens it as a bottom sheet (the `bottom-sheet` variant); `SmartList` opens its details that way. The component receives its `props` and a `dismiss(data)` prop; `onDidDismiss()` resolves with `{ data }`, `{ data: null }` when the modal closed itself. `useModalService().dismiss(data)` closes the modal opened last.
|
|
85
97
|
|
|
86
98
|
```tsx
|
|
87
99
|
import { SmartButton, useModalService } from '@smartsoft001/react';
|
|
@@ -247,12 +259,12 @@ export function CustomModal(props: SmartModalProps) {
|
|
|
247
259
|
}
|
|
248
260
|
```
|
|
249
261
|
|
|
250
|
-
Registered as `components={{ modal: CustomModal }}`, it renders both the `SmartModal`s placed by hand and the modals of `ModalService.show` (which pass `open`, `className` from `cssClass`, `options` with `withDismiss: true`, `onClosed` and the component as `children`).
|
|
262
|
+
Registered as `components={{ modal: CustomModal }}`, it renders both the `SmartModal`s placed by hand and the modals of `ModalService.show` (which pass `open`, `className` from `cssClass`, `options` with `withDismiss: true` and, for `mode: 'bottom'`, `variant: 'bottom-sheet'`, `onClosed` and the component as `children`). Lay out the `bottom-sheet` variant as a bottom sheet so those modals keep their look.
|
|
251
263
|
|
|
252
264
|
## Styling
|
|
253
265
|
|
|
254
|
-
- `SmartModalStandard` is always in the DOM as a `<dialog>` and shown through its `open` attribute; its native `close` event closes the modal too.
|
|
255
|
-
- `SmartModalPreset` renders inline with a `fixed` backdrop over the viewport; a click on the backdrop itself or Escape closes it; with preset modals stacked, Escape closes only the one on top. It carries `smart:dark:` variants.
|
|
266
|
+
- `SmartModalStandard` is always in the DOM as a `<dialog>` and shown through its `open` attribute; its native `close` event closes the modal too. The dialog carries `options.variant` as `data-variant`, action buttons their own `data-variant`. Only the `bottom-sheet` variant is positioned (fixed to the bottom of the viewport, full width up to `max-w-2xl`, at most 85% of the viewport high and scrolling); `className` comes after its classes.
|
|
267
|
+
- `SmartModalPreset` renders inline with a `fixed` backdrop over the viewport; a click on the backdrop itself or Escape closes it; with preset modals stacked, Escape closes only the one on top. The `bottom-sheet` variant docks the panel to the bottom of the viewport, with a max height and a scrolling body. It carries `smart:dark:` variants.
|
|
256
268
|
|
|
257
269
|
## File Locations
|
|
258
270
|
|
|
@@ -74,7 +74,7 @@ Payload of `onActionClick`.
|
|
|
74
74
|
|
|
75
75
|
## Toasts from code
|
|
76
76
|
|
|
77
|
-
`ToastService` keeps a queue of toasts that the toast host of `SmartProvider` (`SmartToastHost`, part of `SmartOverlays`) renders at the bottom of the screen through `SmartNotification`. A toast closes itself after `duration` ms (2000 by default)
|
|
77
|
+
`ToastService` keeps a queue of toasts that the toast host of `SmartProvider` (`SmartToastHost`, part of `SmartOverlays`) renders at the bottom of the screen through `SmartNotification`. A toast closes itself after `duration` ms (2000 by default), on its close button, or once the handler of one of its buttons ran. Errors are announced assertively, infos politely.
|
|
78
78
|
|
|
79
79
|
```tsx
|
|
80
80
|
import { SmartButton, useToastService } from '@smartsoft001/react';
|
|
@@ -30,26 +30,27 @@ All from `@smartsoft001/react`.
|
|
|
30
30
|
|
|
31
31
|
### `ToastService` (`useToastService()`)
|
|
32
32
|
|
|
33
|
-
| Member | What it does
|
|
34
|
-
| ---------------------------------------------- |
|
|
35
|
-
| `info(options: IToastOptions): Promise<void>` | Queues an info toast.
|
|
36
|
-
| `error(options: IToastOptions): Promise<void>` | Queues an error toast (`aria-live="assertive"`), unless an error lock is held.
|
|
37
|
-
| `dismiss(id: number): void` | Removes a toast.
|
|
38
|
-
| `addLockError()` / `removeLockError()` | Holds / releases
|
|
39
|
-
| `toasts: SmartStore<IToast[]>` | The queue the host renders.
|
|
33
|
+
| Member | What it does |
|
|
34
|
+
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| `info(options: IToastOptions): Promise<void>` | Queues an info toast (`aria-live="polite"`). |
|
|
36
|
+
| `error(options: IToastOptions): Promise<void>` | Queues an error toast (`aria-live="assertive"`), unless an error lock is held. |
|
|
37
|
+
| `dismiss(id: number): void` | Removes a toast. |
|
|
38
|
+
| `addLockError()` / `removeLockError()` | Holds / releases an error lock (the count never goes below zero): while one is held, error toasts are swallowed (e.g. during a sign-out that makes pending requests fail). |
|
|
39
|
+
| `toasts: SmartStore<IToast[]>` | The queue the host renders. |
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
42
|
interface IToastOptions {
|
|
43
43
|
title?: string;
|
|
44
44
|
message: string;
|
|
45
|
-
/** Milliseconds before the toast closes itself
|
|
45
|
+
/** Milliseconds before the toast closes itself; 2000 when missing, zero or negative. */
|
|
46
46
|
duration?: number;
|
|
47
|
-
// { text: string; position: 'start' | 'end'; handler: () => void }; the host renders them as actions
|
|
47
|
+
// { text: string; position: 'start' | 'end'; handler: () => void }; the host renders them as actions in the given order
|
|
48
|
+
// (`position` is kept for compatibility); a click runs `handler`, then closes the toast
|
|
48
49
|
buttons?: Array<IToastButton>;
|
|
49
50
|
}
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
A toast with a title shows the title as the heading and the message under it; without one, the message is the heading. A toast
|
|
53
|
+
A toast with a title shows the title as the heading and the message under it; without one, the message is the heading. Its buttons are the notification's actions: a click runs the button's handler, then closes the toast. A toast without buttons renders in the `simple` notification variant, a message with buttons in `condensed`, and a title with a message and buttons in `with-actions-below`, which keeps the message under the title. A toast closes itself after its duration and on its close button.
|
|
53
54
|
|
|
54
55
|
### `AlertService` (`useAlertService()`)
|
|
55
56
|
|
|
@@ -67,7 +68,7 @@ A toast with a title shows the title as the heading and the message under it; wi
|
|
|
67
68
|
interface IModalServiceOptions {
|
|
68
69
|
component: ComponentType<any>; // receives `props` and a `dismiss(data)` prop
|
|
69
70
|
props?: Record<string, unknown>;
|
|
70
|
-
mode?: 'default' | 'bottom'; // 'bottom'
|
|
71
|
+
mode?: 'default' | 'bottom'; // 'bottom': the bottom-sheet variant, plus the smart-modal-bottom class
|
|
71
72
|
cssClass?: string[]; // joined into the SmartModal className
|
|
72
73
|
backdropDismiss?: boolean; // false: the backdrop and Escape leave it open
|
|
73
74
|
}
|
|
@@ -78,7 +79,7 @@ interface IModal {
|
|
|
78
79
|
}
|
|
79
80
|
```
|
|
80
81
|
|
|
81
|
-
`SmartModalHost` renders each request in a `<div data-role="modal" data-mode={mode}>` as `<SmartModal open className options={{ withDismiss: true }} onClosed={() => dismiss()}>` around `<component {...props} dismiss={dismiss} />`, its `className` being `cssClass` plus `smart-modal-bottom` for `mode: 'bottom'
|
|
82
|
+
`SmartModalHost` renders each request in a `<div data-role="modal" data-mode={mode}>` as `<SmartModal open className options={{ withDismiss: true }} onClosed={() => dismiss()}>` around `<component {...props} dismiss={dismiss} />`, its `className` being `cssClass` plus `smart-modal-bottom` for `mode: 'bottom'`, and its `options` adding `variant: 'bottom-sheet'` for that mode. So every modal shows its close button, and closing the modal by its own controls (close button, backdrop, Escape) resolves `onDidDismiss()` with `{ data: null }`. The modals stack in opening order, the last one on top. With `backdropDismiss: false` a click on the backdrop (outside the `role="dialog"` element) is stopped before the modal sees it, and `ModalService` stops Escape at the document while that modal is on top; the close button and `dismiss()` still close it. `mode: 'bottom'` is a bottom sheet: both `SmartModalStandard` and `SmartModalPreset` dock the `bottom-sheet` variant to the bottom of the viewport, full width up to a max width, with a max height and a scrolling body (see `react-components-modal`); the backdrop, Escape and close button behave as in the other variants. `smart-modal-bottom` stays on the modal for an application's own styling.
|
|
82
83
|
|
|
83
84
|
## Usage
|
|
84
85
|
|
|
@@ -172,7 +173,7 @@ A host renders nothing during server-side rendering and until it has mounted, th
|
|
|
172
173
|
|
|
173
174
|
## Styling
|
|
174
175
|
|
|
175
|
-
- The toast stack is fixed to the bottom of the screen (centred, right-aligned from `sm`), with each toast `max-w-sm
|
|
176
|
+
- The toast stack is fixed to the bottom of the screen (centred, right-aligned from `sm`) above the modals (`z-[100]`), with each toast `max-w-sm` and its type in `data-type` (`error` or `info`).
|
|
176
177
|
- Looks come from the registered `notification` / `alert` / `modal` implementations, with their dark-mode variants.
|
|
177
178
|
|
|
178
179
|
## File Locations
|