@smartsoft001/claude-plugins 2.203.0 → 2.205.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartsoft001/claude-plugins",
3
- "version": "2.203.0",
3
+ "version": "2.205.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.202.0",
4
+ "version": "2.204.0",
5
5
  "dependencies": ["smart-core"]
6
6
  }
@@ -24,14 +24,16 @@ This package contains two categories of components. Every component also exports
24
24
 
25
25
  These have concrete selectors and can be used directly in templates.
26
26
 
27
- | Component | Skill | Selector | Description |
28
- | ---------- | ------------------------------- | -------------------- | ------------------------------------------------------------------------------ |
29
- | Date Edit | `angular-components-date-edit` | `<smart-date-edit>` | Digit-by-digit date input (DD-MM-RRRR) with validation |
30
- | Date Range | `angular-components-date-range` | `<smart-date-range>` | Date range picker with modal calendar and quick filters |
31
- | Detail | `angular-components-detail` | `<smart-detail>` | Renders a single model field by dispatching to a sub-component per `FieldType` |
32
- | Input | `angular-components-input` | `<smart-input>` | Renders a form input by dispatching to a sub-component per `FieldType` |
33
- | Icon | `angular-components-icon` | `<smart-icon>` | SVG icon by name (spinner, chevrons), with a custom `template` override |
34
- | Accordion | `angular-components-accordion` | `<smart-accordion>` | Collapsible section with projected `[accordionHeader]` / `[accordionBody]` |
27
+ | Component | Skill | Selector | Description |
28
+ | ---------- | ------------------------------- | -------------------- | --------------------------------------------------------------------------------- |
29
+ | Date Edit | `angular-components-date-edit` | `<smart-date-edit>` | Digit-by-digit date input (DD-MM-RRRR) with validation |
30
+ | Date Range | `angular-components-date-range` | `<smart-date-range>` | Date range picker with modal calendar and quick filters |
31
+ | Detail | `angular-components-detail` | `<smart-detail>` | Renders a single model field by dispatching to a sub-component per `FieldType` |
32
+ | Input | `angular-components-input` | `<smart-input>` | Renders a form input by dispatching to a sub-component per `FieldType` |
33
+ | Icon | `angular-components-icon` | `<smart-icon>` | SVG icon by name (spinner, chevrons), with a custom `template` override |
34
+ | Accordion | `angular-components-accordion` | `<smart-accordion>` | Collapsible section with projected `[accordionHeader]` / `[accordionBody]` |
35
+ | Export | `angular-components-export` | `<smart-export>` | Download-icon button that hands `value` and `fileName` to a `handler` you write |
36
+ | Import | `angular-components-import` | `<smart-import>` | Upload-icon button that opens the file dialog and emits the picked `File` (`set`) |
35
37
 
36
38
  ### Ready-to-Use with extension token
37
39
 
@@ -65,6 +67,7 @@ These render a default standard implementation and accept a custom implementatio
65
67
  | Grid List | `angular-components-grid-list` | `<smart-grid-list>` | `GRID_LIST_STANDARD_COMPONENT_TOKEN` |
66
68
  | Info | `angular-components-info` | `<smart-info>` | `INFO_STANDARD_COMPONENT_TOKEN` |
67
69
  | List | `angular-components-list` | `<smart-list>` | `LIST_MODE_COMPONENTS_TOKEN` |
70
+ | Loader | `angular-components-loader` | `<smart-loader>` | `LOADER_STANDARD_COMPONENT_TOKEN` |
68
71
  | Modal | `angular-components-modal` | `<smart-modal>` | `MODAL_STANDARD_COMPONENT_TOKEN` |
69
72
  | Multi-Column Layout | `angular-components-multi-column-layout` | `<smart-multi-column-layout>` | `MULTI_COLUMN_LAYOUT_STANDARD_COMPONENT_TOKEN` |
70
73
  | Navbar | `angular-components-navbar` | `<smart-navbar>` | `NAVBAR_STANDARD_COMPONENT_TOKEN` |
@@ -92,8 +95,8 @@ These render a default standard implementation and accept a custom implementatio
92
95
 
93
96
  When a developer asks about a component:
94
97
 
95
- 1. **Wants to use `<smart-date-edit>`, `<smart-date-range>`, `<smart-detail>`, `<smart-input>`, `<smart-icon>` or `<smart-accordion>`** → delegate to the corresponding skill for usage API
96
- 2. **Wants to use `<smart-action-panel>`, `<smart-alert>` (or `AlertService`), `<smart-avatar>`, `<smart-badge>`, `<smart-breadcrumbs>`, `<smart-button>`, `<smart-button-group>`, `<smart-calendar>`, `<smart-card>`, `<smart-card-heading>`, `<smart-command-palette>`, `<smart-container>`, `<smart-description-list>`, `<smart-details>`, `<smart-divider>`, `<smart-drawer>`, `<smart-dropdown>`, `<smart-empty-state>`, `<smart-feed>`, `<smart-form>`, `<smart-grid-list>`, `<smart-info>`, `<smart-list>`, `<smart-list-container>`, `<smart-media-object>`, `<smart-modal>`, `<smart-multi-column-layout>`, `<smart-navbar>`, `<smart-notification>`, `<smart-page>`, `<smart-page-heading>`, `<smart-paging>`, `<smart-password-strength>`, `<smart-progress-bars>`, `<smart-searchbar>`, `<smart-section-heading>`, `<smart-select-menu>`, `<smart-sidebar-layout>`, `<smart-sidebar-navigation>`, `<smart-sign-in-form>`, `<smart-stacked-layout>`, `<smart-stacked-list>`, `<smart-stats>`, `<smart-table>`, `<smart-tabs>`, `<smart-textarea>`, `<smart-toggle>`, or `<smart-vertical-navigation>`** → delegate to the skill to explain usage, token override pattern, and how to extend the base class with a custom implementation
98
+ 1. **Wants to use `<smart-date-edit>`, `<smart-date-range>`, `<smart-detail>`, `<smart-input>`, `<smart-icon>`, `<smart-accordion>`, `<smart-export>` or `<smart-import>`** → delegate to the corresponding skill for usage API
99
+ 2. **Wants to use `<smart-action-panel>`, `<smart-alert>` (or `AlertService`), `<smart-avatar>`, `<smart-badge>`, `<smart-breadcrumbs>`, `<smart-button>`, `<smart-button-group>`, `<smart-calendar>`, `<smart-card>`, `<smart-card-heading>`, `<smart-command-palette>`, `<smart-container>`, `<smart-description-list>`, `<smart-details>`, `<smart-divider>`, `<smart-drawer>`, `<smart-dropdown>`, `<smart-empty-state>`, `<smart-feed>`, `<smart-form>`, `<smart-grid-list>`, `<smart-info>`, `<smart-list>`, `<smart-list-container>`, `<smart-loader>`, `<smart-media-object>`, `<smart-modal>`, `<smart-multi-column-layout>`, `<smart-navbar>`, `<smart-notification>`, `<smart-page>`, `<smart-page-heading>`, `<smart-paging>`, `<smart-password-strength>`, `<smart-progress-bars>`, `<smart-searchbar>`, `<smart-section-heading>`, `<smart-select-menu>`, `<smart-sidebar-layout>`, `<smart-sidebar-navigation>`, `<smart-sign-in-form>`, `<smart-stacked-layout>`, `<smart-stacked-list>`, `<smart-stats>`, `<smart-table>`, `<smart-tabs>`, `<smart-textarea>`, `<smart-toggle>`, or `<smart-vertical-navigation>`** → delegate to the skill to explain usage, token override pattern, and how to extend the base class with a custom implementation
97
100
  3. **Wants a custom implementation of a component** → delegate to that component's skill: it shows the base class to extend and, where there is one, the token to register it with
98
101
 
99
102
  ## Skills to Use
@@ -127,6 +130,7 @@ Always delegate to the per-component skill for detailed API, usage examples, and
127
130
  - **Input** → use skill `angular-components-input`
128
131
  - **List** (with extension token map) → use skill `angular-components-list`
129
132
  - **List Container** (with extension token) → use skill `angular-components-list-container`
133
+ - **Loader** (with extension token) → use skill `angular-components-loader`
130
134
  - **Media Object** (with extension token) → use skill `angular-components-media-object`
131
135
  - **Modal** (with extension token) → use skill `angular-components-modal`
132
136
  - **Multi-Column Layout** (with extension token) → use skill `angular-components-multi-column-layout`
@@ -152,6 +156,8 @@ Always delegate to the per-component skill for detailed API, usage examples, and
152
156
  - **Button** (with extension token) → use skill `angular-components-button`
153
157
  - **Card** (with extension token) → use skill `angular-components-card`
154
158
  - **Icon** → use skill `angular-components-icon`
159
+ - **Export** → use skill `angular-components-export`
160
+ - **Import** → use skill `angular-components-import`
155
161
  - **Page** (with extension token map) → use skill `angular-components-page`
156
162
  - **Paging** (with extension token) → use skill `angular-components-paging`
157
163
 
@@ -177,6 +183,8 @@ import {
177
183
  DateEditDefaultComponent,
178
184
  DateRangeDefaultComponent,
179
185
  DetailComponent,
186
+ ExportComponent,
187
+ ImportComponent,
180
188
  InputComponent,
181
189
  DETAIL_FIELD_COMPONENTS_TOKEN,
182
190
  INPUT_FIELD_COMPONENTS_TOKEN,
@@ -223,12 +231,14 @@ import {
223
231
  DETAILS_STANDARD_COMPONENT_TOKEN,
224
232
  EmptyStateBaseComponent,
225
233
  EMPTY_STATE_STANDARD_COMPONENT_TOKEN,
234
+ ExportBaseComponent,
226
235
  FeedBaseComponent,
227
236
  FEED_STANDARD_COMPONENT_TOKEN,
228
237
  FormBaseComponent,
229
238
  FORM_STANDARD_COMPONENT_TOKEN,
230
239
  GridListBaseComponent,
231
240
  GRID_LIST_STANDARD_COMPONENT_TOKEN,
241
+ ImportBaseComponent,
232
242
  InfoBaseComponent,
233
243
  INFO_STANDARD_COMPONENT_TOKEN,
234
244
  InputBaseComponent,
@@ -240,6 +250,8 @@ import {
240
250
  IListProvider,
241
251
  ListContainerBaseComponent,
242
252
  LIST_CONTAINER_STANDARD_COMPONENT_TOKEN,
253
+ LoaderBaseComponent,
254
+ LOADER_STANDARD_COMPONENT_TOKEN,
243
255
  MediaObjectBaseComponent,
244
256
  MEDIA_OBJECT_STANDARD_COMPONENT_TOKEN,
245
257
  ModalBaseComponent,
@@ -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
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: angular-components-export
3
+ description: Export component API, a download button that hands the bound value and file name to a handler you write, disabled while there is nothing to export, and the base class for custom implementations.
4
+ user-invocable: false
5
+ ---
6
+
7
+ # Export Component
8
+
9
+ `<smart-export>` is a button with a download icon. Bind the data to export and a handler; the button stays disabled until there is a value and calls the handler with it, and the file name, on click.
10
+
11
+ The handler serialises the data and starts the download, so the format is yours (JSON, CSV, ...). The component renders a `<smart-button>`, so it follows whatever button implementation is registered through `BUTTON_STANDARD_COMPONENT_TOKEN`. It has no injection token of its own: for a different control, extend `ExportBaseComponent`. `<smart-import>` is the matching upload button, for a download / upload round trip.
12
+
13
+ ## When to Use This Skill
14
+
15
+ - An "export / download" button for data the page already holds
16
+ - Pairing with `<smart-import>` (`angular-components-import`) for a download / upload round trip
17
+ - Developer asks about `<smart-export>`, `ExportComponent` or `ExportBaseComponent`
18
+
19
+ For exporting a CRUD collection from the server (CSV / XLSX of the current filter), use the `export` option of the CRUD list page (`smart-crud` skill), which renders its own `smart-crud-export`, not `<smart-export>`.
20
+
21
+ ## Components
22
+
23
+ ### ExportComponent (`<smart-export>`)
24
+
25
+ Renders a `<smart-button>` with a projected download icon, disabled while `value` is falsy, and passes `class` to it. The icon is hidden from assistive technology and a visually hidden "Export" label gives the button its accessible name. It extends `ExportBaseComponent`, which owns the inputs and the click logic. The icon is projected content, so a button implementation registered through `BUTTON_STANDARD_COMPONENT_TOKEN` in the same injector (the button preset that `provideSmartPresets()` registers, or your own) renders it too, in its default `<ng-content>` slot.
26
+
27
+ ### ExportBaseComponent (abstract)
28
+
29
+ The base directive. `onClick()` reads `value` and, when it is set, calls `handler(value, fileName)`; it does nothing while `value` is falsy. Extend it to change the markup while keeping the behaviour. There is no token to register a subclass under, so a custom export control is rendered by its own selector.
30
+
31
+ | Member | Type | Description |
32
+ | ----------- | --------------------- | ---------------------------------------------------------------------------------------- |
33
+ | `onClick()` | `() => Promise<void>` | Calls `handler(value, fileName)` when `value` is truthy; does nothing otherwise. |
34
+ | `cssClass` | `InputSignal<string>` | The `class` input under its property name; bind it on the element your template renders. |
35
+
36
+ ## API
37
+
38
+ ### Inputs
39
+
40
+ | Input | Type | Default | Description |
41
+ | ---------- | ------------------------------------------------------ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42
+ | `value` | `InputSignal<any \| undefined>` | `undefined` | The data to export. The button is disabled while it is falsy; an empty array is truthy and enables it, so bind `undefined` while there is nothing to export. |
43
+ | `handler` | `InputSignal<(value: any, fileName?: string) => void>` | required | Called with `value` and `fileName` on click; serialise and download the data here. It is called as a plain function, so pass an arrow function (a class field) when it uses `this`. |
44
+ | `fileName` | `InputSignal<string \| undefined>` | `undefined` | Name for the downloaded file, passed to `handler` as its second argument. The `fileName` argument is optional, so `(value) => void` handlers keep working. |
45
+ | `class` | `InputSignal<string>` | `''` | Extra CSS classes applied to the rendered button (`cssClass` input, alias `class`). |
46
+
47
+ The component emits no outputs: the `handler` input is where the data leaves it. The CRUD list page does not use it; its `export` option renders the CSV / XLSX export of `@smartsoft001/crud-shell-angular` (see the `smart-crud` skill).
48
+
49
+ ## Extending the Base Class
50
+
51
+ ```typescript
52
+ import {
53
+ ChangeDetectionStrategy,
54
+ Component,
55
+ ViewEncapsulation,
56
+ } from '@angular/core';
57
+ import { ExportBaseComponent } from '@smartsoft001/angular';
58
+
59
+ @Component({
60
+ selector: 'my-export-link',
61
+ template: `
62
+ <button
63
+ type="button"
64
+ [class]="cssClass()"
65
+ [disabled]="!value()"
66
+ (click)="onClick()"
67
+ >
68
+ Download
69
+ </button>
70
+ `,
71
+ encapsulation: ViewEncapsulation.None,
72
+ changeDetection: ChangeDetectionStrategy.OnPush,
73
+ })
74
+ export class MyExportLinkComponent extends ExportBaseComponent {}
75
+ ```
76
+
77
+ Render it by its own selector with the same inputs (`<my-export-link [value]="orders" [handler]="exportOrders" />`); there is no token that swaps `<smart-export>` for it.
78
+
79
+ ## Usage Examples
80
+
81
+ ```html
82
+ <smart-export [value]="orders" fileName="orders" [handler]="downloadJson" />
83
+ ```
84
+
85
+ ```typescript
86
+ import { Component } from '@angular/core';
87
+ import { ExportComponent } from '@smartsoft001/angular';
88
+
89
+ @Component({
90
+ selector: 'app-orders-export',
91
+ imports: [ExportComponent],
92
+ templateUrl: './orders-export.component.html',
93
+ })
94
+ export class OrdersExportComponent {
95
+ orders = [{ id: 'ORD-1001', total: 120 }];
96
+
97
+ // An arrow function: <smart-export> calls the handler without `this`.
98
+ readonly downloadJson = (value: unknown, fileName = 'export'): void => {
99
+ const blob = new Blob([JSON.stringify(value, null, 2)], {
100
+ type: 'application/json',
101
+ });
102
+ const url = URL.createObjectURL(blob);
103
+ const link = document.createElement('a');
104
+ link.href = url;
105
+ link.download = `${fileName}.json`;
106
+ link.click();
107
+ URL.revokeObjectURL(url);
108
+ };
109
+ }
110
+ ```
111
+
112
+ ## File Locations
113
+
114
+ - Component: `packages/shared/angular/src/lib/components/export/export.component.ts`
115
+ - Base class: `packages/shared/angular/src/lib/components/export/base/base.component.ts`
116
+ - Stories: `packages/shared/angular/src/lib/components/export/export.component.stories.ts`
117
+ - Usage example: `docs/examples/angular/src/components/export/usage.example.ts` and `usage.example.html`
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: angular-components-import
3
+ description: Import component API, an upload button that opens the native file dialog (accept filter, JSON by default) and emits the chosen File through its set output, and the base class for custom implementations.
4
+ user-invocable: false
5
+ ---
6
+
7
+ # Import Component
8
+
9
+ `<smart-import>` is a button with an upload icon and a hidden file input. Clicking it opens the native file dialog; the chosen file is emitted through the `set` output.
10
+
11
+ The input is cleared after every pick, so choosing the same file again emits it again. `accept` filters the dialog (`application/json` by default). Reading and parsing the file is up to you. The component renders a `<smart-button>`, so it follows whatever button implementation is registered through `BUTTON_STANDARD_COMPONENT_TOKEN`. It has no injection token of its own: for a different control, extend `ImportBaseComponent`. `<smart-export>` is the matching download button, for a download / upload round trip.
12
+
13
+ ## When to Use This Skill
14
+
15
+ - Letting the user load a JSON (or other) file the page will parse
16
+ - Pairing with `<smart-export>` (`angular-components-export`) for a download / upload round trip
17
+ - Developer asks about `<smart-import>`, `ImportComponent` or `ImportBaseComponent`
18
+
19
+ For file fields of a model-driven form (attachments, images, PDFs), use the input field components (`angular-components-input`).
20
+
21
+ ## Components
22
+
23
+ ### ImportComponent (`<smart-import>`)
24
+
25
+ Renders a `<smart-button>` with a projected upload icon next to a hidden `<input type="file">`, both inside a `<span>` that takes `class`. The button click forwards to the input through `triggerFileInput`, and the input's change event goes through `ImportBaseComponent.onFileSelected`. As with `<smart-export>`, a button implementation registered through `BUTTON_STANDARD_COMPONENT_TOKEN` receives the projected icon in its default `<ng-content>` slot. Unlike `<smart-export>`, the icon has no text alternative, so the button has no accessible name; for a labelled control, extend `ImportBaseComponent`.
26
+
27
+ ### ImportBaseComponent (abstract)
28
+
29
+ The base directive. `onFileSelected(event)` reads the first selected file, clears the input so the same file can be chosen again, and emits it through `set`; it throws `ImportBaseComponent: File not found` when the change event carries no file. `triggerFileInput(inputEl)` opens the dialog. Extend it to change the markup while keeping the behaviour. There is no token to register a subclass under, so a custom import control is rendered by its own selector.
30
+
31
+ | Member | Type | Description |
32
+ | --------------------------- | ------------------------------------- | ----------------------------------------------------------------------------------------- |
33
+ | `onFileSelected(event)` | `(event: Event) => void` | The `change` handler of the file input: emits its first file through `set` and clears it. |
34
+ | `triggerFileInput(inputEl)` | `(inputEl: HTMLInputElement) => void` | Opens the native file dialog of `inputEl` (calls its `click()`). |
35
+ | `cssClass` | `InputSignal<string>` | The `class` input under its property name; bind it on the element your template renders. |
36
+
37
+ ## API
38
+
39
+ ### Inputs
40
+
41
+ | Input | Type | Default | Description |
42
+ | -------- | ---------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
43
+ | `accept` | `InputSignal<string \| undefined>` | `'application/json'` | Value of the `accept` attribute on the hidden file input; filters the native dialog. Binding `undefined` keeps `application/json`. |
44
+ | `class` | `InputSignal<string>` | `''` | Classes on a `<span>` around the button and the hidden file input (`cssClass` input, alias `class`). |
45
+
46
+ ### Outputs
47
+
48
+ | Output | Type | Description |
49
+ | ------ | ------------------------ | ------------------------------------------------------ |
50
+ | `set` | `OutputEmitterRef<File>` | Emits the selected `File` once per dialog confirmation |
51
+
52
+ ## Extending the Base Class
53
+
54
+ ```typescript
55
+ import {
56
+ ChangeDetectionStrategy,
57
+ Component,
58
+ ViewEncapsulation,
59
+ } from '@angular/core';
60
+ import { ImportBaseComponent } from '@smartsoft001/angular';
61
+
62
+ @Component({
63
+ selector: 'my-import-link',
64
+ template: `
65
+ <span [class]="cssClass()">
66
+ <button type="button" (click)="triggerFileInput(fileInput)">
67
+ Upload a file
68
+ </button>
69
+ <input
70
+ #fileInput
71
+ type="file"
72
+ hidden
73
+ [accept]="accept() ?? 'application/json'"
74
+ (change)="onFileSelected($event)"
75
+ />
76
+ </span>
77
+ `,
78
+ encapsulation: ViewEncapsulation.None,
79
+ changeDetection: ChangeDetectionStrategy.OnPush,
80
+ })
81
+ export class MyImportLinkComponent extends ImportBaseComponent {}
82
+ ```
83
+
84
+ Render it by its own selector with the same input and output (`<my-import-link (set)="onImport($event)" />`); there is no token that swaps `<smart-import>` for it.
85
+
86
+ ## Usage Examples
87
+
88
+ ```html
89
+ <smart-import accept="application/json" (set)="onImport($event)" />
90
+ ```
91
+
92
+ ```typescript
93
+ import { Component, signal } from '@angular/core';
94
+ import { ImportComponent } from '@smartsoft001/angular';
95
+
96
+ @Component({
97
+ selector: 'app-notes-import',
98
+ imports: [ImportComponent],
99
+ templateUrl: './notes-import.component.html',
100
+ })
101
+ export class NotesImportComponent {
102
+ readonly notes = signal<unknown[]>([]);
103
+
104
+ async onImport(file: File): Promise<void> {
105
+ const parsed: unknown = JSON.parse(await file.text());
106
+ if (Array.isArray(parsed)) this.notes.set(parsed);
107
+ }
108
+ }
109
+ ```
110
+
111
+ ## File Locations
112
+
113
+ - Component: `packages/shared/angular/src/lib/components/import/import.component.ts`
114
+ - Base class: `packages/shared/angular/src/lib/components/import/base/base.component.ts`
115
+ - Stories: `packages/shared/angular/src/lib/components/import/import.component.stories.ts`
116
+ - Usage example: `docs/examples/angular/src/components/import/usage.example.ts` and `usage.example.html`
@@ -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 modal 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`.
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
 
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: angular-components-loader
3
+ description: Loader component API, a spinner shown while show is true, sized and coloured through inputs, with a styled preset and an InjectionToken pattern for custom implementations.
4
+ user-invocable: false
5
+ ---
6
+
7
+ # Loader Component
8
+
9
+ `<smart-loader>` renders a spinner while something loads. It takes a size and a colour, hides itself until `show` is true, and can be replaced application-wide through an injection token.
10
+
11
+ `size` and `color` use the shared `SmartSize` / `SmartColor` scales. `<smart-list>` renders it while its provider loads and `<smart-input>` while an async validator runs, so a loader registered through `LOADER_STANDARD_COMPONENT_TOKEN` changes those too. It follows the Base + Standard + Wrapper pattern: `LoaderBaseComponent` owns the inputs and the spinner classes, `LoaderStandardComponent` is the default rendering, `LoaderPresetComponent` the styled one.
12
+
13
+ ## When to Use This Skill
14
+
15
+ - Showing that something is loading in place of, or next to, content
16
+ - Changing the spinner used across the library (`LOADER_STANDARD_COMPONENT_TOKEN`)
17
+ - Developer asks about `<smart-loader>`, `LoaderComponent`, `LoaderStandardComponent`, `LoaderPresetComponent` or `LoaderBaseComponent`
18
+
19
+ ## Components
20
+
21
+ ### LoaderComponent (`<smart-loader>`)
22
+
23
+ The wrapper. Renders `LoaderStandardComponent` by default. When `LOADER_STANDARD_COMPONENT_TOKEN` is provided, it renders the injected component through `NgComponentOutlet` and forwards `show`, `size`, `color` and `class` to it, resolved to the names that component declares, so a custom implementation extending `LoaderBaseComponent` receives the class in its inherited `cssClass` input; an input the component does not declare is left out. Its host element is `display: contents` (`smart:contents`), so it adds no box of its own.
24
+
25
+ ### LoaderStandardComponent (`<smart-loader-standard>`)
26
+
27
+ The default implementation: while `show` is true, an SVG spinner (`role="status"`, `aria-label="loading"`) that gets its size class from `size` and its text colour from `color`, with `class` appended. It renders nothing while `show` is false.
28
+
29
+ ### LoaderPresetComponent (`<smart-loader-preset>`)
30
+
31
+ A styled, drop-in variation that renders the Preline default spinner (a bordered ring with a transparent top border). Register it through `LOADER_STANDARD_COMPONENT_TOKEN` (or register every preset at once with `provideSmartPresets()`) to restyle every `<smart-loader>`, or use its selector directly. The preset declares `cssClass` without the `class` alias: through `<smart-loader>` the class still reaches it; used directly, `<smart-loader-preset>` takes extra classes as `[cssClass]`.
32
+
33
+ The ring is `smart:border-3 smart:border-current smart:border-t-transparent smart:rounded-full`, spinning, sized like the standard and coloured `smart:text-<color>-600` with an explicit `smart:dark:` shade for every colour (`-400` for `slate`, `gray`, `zinc`, `neutral` and `stone`, `-500` for the others). It keeps `role="status"` and `aria-label="loading"` and adds a `smart:sr-only` "Loading..." text. The class recipe (`preset/preset-classes.util.ts`) is internal, not exported from `@smartsoft001/angular`.
34
+
35
+ ### LoaderBaseComponent (abstract)
36
+
37
+ The base directive the variations extend. It owns the inputs and the `spinnerClasses` signal that turns `size` and `color` into Tailwind classes, so a custom implementation only has to provide a template.
38
+
39
+ | Member | Type | Description |
40
+ | ---------------- | ------------------------------- | ----------------------------------------------------------------------------------------------- |
41
+ | `spinnerClasses` | `Signal<string[]>` | `smart:animate-spin`, the size class, `smart:text-<color>-600`, then `cssClass` when it is set. |
42
+ | `smartType` | `DynamicComponentType` (static) | `'loader'`. |
43
+
44
+ ## API
45
+
46
+ ### Inputs
47
+
48
+ | Input | Type | Default | Description |
49
+ | ------- | ------------------------- | ---------- | --------------------------------------------------------------------------------------- |
50
+ | `show` | `InputSignal<boolean>` | `false` | Whether the spinner is visible |
51
+ | `size` | `InputSignal<SmartSize>` | `'md'` | One of `xs`, `sm`, `md`, `lg`, `xl`; maps to `smart:size-4`, `-5`, `-6`, `-8` and `-10` |
52
+ | `color` | `InputSignal<SmartColor>` | `'indigo'` | Any colour of the shared palette; maps to a `smart:text-*-600` class |
53
+ | `class` | `InputSignal<string>` | `''` | Extra CSS classes on the spinner (`cssClass` input, alias `class`) |
54
+
55
+ The loader emits no outputs.
56
+
57
+ ### LOADER_STANDARD_COMPONENT_TOKEN
58
+
59
+ An injection token from `@smartsoft001/angular`. Provide a `Type<LoaderBaseComponent>` (for example `LoaderPresetComponent` or your own subclass) in your application or component providers to replace the default spinner everywhere `<smart-loader>` is used; `provideSmartPresets()` provides `LoaderPresetComponent` for it together with every other preset.
60
+
61
+ ```typescript
62
+ import {
63
+ LOADER_STANDARD_COMPONENT_TOKEN,
64
+ LoaderPresetComponent,
65
+ } from '@smartsoft001/angular';
66
+
67
+ providers: [
68
+ {
69
+ provide: LOADER_STANDARD_COMPONENT_TOKEN,
70
+ useValue: LoaderPresetComponent,
71
+ },
72
+ ];
73
+ ```
74
+
75
+ ## Extending the Base Class
76
+
77
+ ```typescript
78
+ import {
79
+ ChangeDetectionStrategy,
80
+ Component,
81
+ computed,
82
+ ViewEncapsulation,
83
+ } from '@angular/core';
84
+ import { LoaderBaseComponent } from '@smartsoft001/angular';
85
+
86
+ @Component({
87
+ selector: 'my-dots-loader',
88
+ template: `
89
+ @if (show()) {
90
+ <span role="status" aria-label="loading" [class]="classes()">…</span>
91
+ }
92
+ `,
93
+ encapsulation: ViewEncapsulation.None,
94
+ changeDetection: ChangeDetectionStrategy.OnPush,
95
+ })
96
+ export class MyDotsLoaderComponent extends LoaderBaseComponent {
97
+ classes = computed(() => this.spinnerClasses().join(' '));
98
+ }
99
+ ```
100
+
101
+ Register `MyDotsLoaderComponent` through `LOADER_STANDARD_COMPONENT_TOKEN` and every `<smart-loader>` in that injector renders it, `<smart-list>` and `<smart-input>` included.
102
+
103
+ ## Usage Examples
104
+
105
+ ```html
106
+ <!-- Default spinner -->
107
+ <smart-loader [show]="loading()"></smart-loader>
108
+
109
+ <!-- Size and colour -->
110
+ <smart-loader [show]="saving()" size="sm" color="blue"></smart-loader>
111
+
112
+ <!-- The preset, used directly -->
113
+ <smart-loader-preset [show]="saving()" size="lg"></smart-loader-preset>
114
+
115
+ <!-- With external class -->
116
+ <smart-loader class="smart:mx-auto" [show]="loading()"></smart-loader>
117
+ ```
118
+
119
+ ## File Locations
120
+
121
+ - Wrapper: `packages/shared/angular/src/lib/components/loader/loader.component.ts`
122
+ - Standard: `packages/shared/angular/src/lib/components/loader/standard/standard.component.ts`
123
+ - Preset: `packages/shared/angular/src/lib/components/loader/preset/preset.component.ts` (classes: `preset/preset-classes.util.ts`, internal)
124
+ - Base class: `packages/shared/angular/src/lib/components/loader/base/base.component.ts`
125
+ - Stories: `packages/shared/angular/src/lib/components/loader/loader.component.stories.ts`
126
+ - Token: `packages/shared/angular/src/lib/shared.inectors.ts` (`LOADER_STANDARD_COMPONENT_TOKEN`)
127
+ - Usage example: `docs/examples/angular/src/components/loader/usage.example.ts` and `usage.example.html`
@@ -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, and `left-aligned-buttons` left-aligns the footer. `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).
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 | Default | Description |
78
- | ------------- | ----------------------------------------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
79
- | `variant` | `'centered' \| 'wide' \| 'alert' \| 'left-aligned-buttons'` | `'centered'` | Preset only: `centered` and `alert` (narrower) are vertically centred, `wide` is a top-aligned large dialog, `left-aligned-buttons` left-aligns the footer. |
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`. |
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?: 'centered' | 'wide' | 'alert' | 'left-aligned-buttons';
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`; `variant` and `footerStyle` are read by `ModalPresetComponent` (and are available to a custom implementation).
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 to the modal for the application to style; the modal element carries `data-mode`. |
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.202.0"
4
+ "version": "2.204.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.202.0",
4
+ "version": "2.204.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'` adds the `smart-modal-bottom` class to the modal. |
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 four variants. The modal host of `SmartProvider` renders `useModalService().show(...)` requests through the same `modal` key.
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'` | Preset layout: `centered`, `wide`, `alert` or `left-aligned-buttons`. |
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. Action buttons carry `data-variant`.
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) or on its close button.
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 the error lock: while 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. |
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 (default 2000). */
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, ignoring `position`
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 with buttons renders in the `condensed` notification variant and its buttons as actions.
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' adds the smart-modal-bottom class
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'`. 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. `smart-modal-bottom` is a class for the application to style (a sheet docked at the bottom); the modal implementations do not style it.
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