@smartsoft001/claude-plugins 2.204.0 → 2.206.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/agents/angular-components.md +22 -10
- package/plugins/smart-angular/skills/angular-components-export/SKILL.md +117 -0
- package/plugins/smart-angular/skills/angular-components-import/SKILL.md +116 -0
- package/plugins/smart-angular/skills/angular-components-loader/SKILL.md +127 -0
- package/plugins/smart-core/.claude-plugin/plugin.json +1 -1
- package/plugins/smart-react/.claude-plugin/plugin.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartsoft001/claude-plugins",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.206.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.205.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-
|
|
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,
|
|
@@ -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`
|
|
@@ -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`
|
|
@@ -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.205.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.205.0",
|
|
5
5
|
"dependencies": ["smart-core"]
|
|
6
6
|
}
|