@smartsoft001/claude-plugins 2.119.0 → 2.120.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/.claude-plugin/plugin.json +1 -1
- package/plugins/smart/agents/angular-components/AGENT.md +212 -11
- package/plugins/smart/skills/angular-components-accordion/SKILL.md +86 -0
- package/plugins/smart/skills/angular-components-action-panel/SKILL.md +195 -0
- package/plugins/smart/skills/angular-components-breadcrumbs/SKILL.md +152 -0
- package/plugins/smart/skills/angular-components-button/SKILL.md +81 -54
- package/plugins/smart/skills/angular-components-calendar/SKILL.md +222 -0
- package/plugins/smart/skills/angular-components-card/SKILL.md +112 -0
- package/plugins/smart/skills/angular-components-card-heading/SKILL.md +156 -0
- package/plugins/smart/skills/angular-components-date-edit/SKILL.md +107 -0
- package/plugins/smart/skills/angular-components-date-range/SKILL.md +149 -0
- package/plugins/smart/skills/angular-components-description-list/SKILL.md +205 -0
- package/plugins/smart/skills/angular-components-detail/SKILL.md +146 -0
- package/plugins/smart/skills/angular-components-details/SKILL.md +123 -0
- package/plugins/smart/skills/angular-components-empty-state/SKILL.md +198 -0
- package/plugins/smart/skills/angular-components-feed/SKILL.md +199 -0
- package/plugins/smart/skills/angular-components-form/SKILL.md +160 -0
- package/plugins/smart/skills/angular-components-grid-list/SKILL.md +215 -0
- package/plugins/smart/skills/angular-components-info/SKILL.md +160 -0
- package/plugins/smart/skills/angular-components-input/SKILL.md +196 -0
- package/plugins/smart/skills/angular-components-list/SKILL.md +265 -0
- package/plugins/smart/skills/angular-components-multi-column-layout/SKILL.md +174 -0
- package/plugins/smart/skills/angular-components-navbar/SKILL.md +192 -0
- package/plugins/smart/skills/angular-components-page/SKILL.md +230 -0
- package/plugins/smart/skills/angular-components-page-heading/SKILL.md +183 -0
- package/plugins/smart/skills/angular-components-paging/SKILL.md +132 -0
- package/plugins/smart/skills/angular-components-password-strength/SKILL.md +172 -0
- package/plugins/smart/skills/angular-components-progress-bars/SKILL.md +187 -0
- package/plugins/smart/skills/angular-components-searchbar/SKILL.md +167 -0
- package/plugins/smart/skills/angular-components-section-heading/SKILL.md +177 -0
- package/plugins/smart/skills/angular-components-select-menu/SKILL.md +211 -0
- package/plugins/smart/skills/angular-components-sidebar-layout/SKILL.md +176 -0
- package/plugins/smart/skills/angular-components-sidebar-navigation/SKILL.md +225 -0
- package/plugins/smart/skills/angular-components-sign-in-form/SKILL.md +202 -0
- package/plugins/smart/skills/angular-components-stacked-layout/SKILL.md +169 -0
- package/plugins/smart/skills/angular-components-stacked-list/SKILL.md +213 -0
- package/plugins/smart/skills/angular-components-stats/SKILL.md +213 -0
- package/plugins/smart/skills/angular-components-table/SKILL.md +216 -0
- package/plugins/smart/skills/angular-components-tabs/SKILL.md +181 -0
- package/plugins/smart/skills/angular-components-textarea/SKILL.md +168 -0
- package/plugins/smart/skills/angular-components-toggle/SKILL.md +155 -0
- package/plugins/smart/skills/angular-components-vertical-navigation/SKILL.md +158 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: angular-components-form
|
|
3
|
+
description: Form component API with InjectionToken pattern for custom implementations. Renders a reactive form with dynamic inputs based on model decorators.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Form Component
|
|
8
|
+
|
|
9
|
+
The `<smart-form>` component renders a reactive form driven by `@Field()` model decorators. It is a wrapper that delegates to `FormStandardComponent` by default and can be replaced via `FORM_STANDARD_COMPONENT_TOKEN`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Developer wants to render an editable form for an entity using model decorators
|
|
14
|
+
- Developer asks about `<smart-form>` or `FormComponent`
|
|
15
|
+
- Developer wants to provide a custom layout for the standard form rendering
|
|
16
|
+
- Developer wants to use a pre-built `UntypedFormGroup` control with the form
|
|
17
|
+
|
|
18
|
+
## Components
|
|
19
|
+
|
|
20
|
+
### FormComponent (`<smart-form>`)
|
|
21
|
+
|
|
22
|
+
Main wrapper. Holds all reactive-form logic: builds the form via `FormFactory`, tracks `loading$`, and emits `valueChange`, `valuePartialChange`, and `validChange` outputs. Renders `FormStandardComponent` by default. When `FORM_STANDARD_COMPONENT_TOKEN` is provided, renders the injected component via `NgComponentOutlet`, passing all inputs and outputs.
|
|
23
|
+
|
|
24
|
+
### FormStandardComponent (`<smart-form-standard>`)
|
|
25
|
+
|
|
26
|
+
Default concrete implementation. Generic Tailwind-styled container that iterates over `fields` and renders each via `<smart-input>` per control.
|
|
27
|
+
|
|
28
|
+
### FormBaseComponent (abstract)
|
|
29
|
+
|
|
30
|
+
Abstract base directive. Exposes `form` (`UntypedFormGroup`), `options`, `fields` (computed from `form.controls`), `model`, `mode`, `possibilities`, `inputComponents`, `cssClass`, and lifecycle hooks `submit()`, `afterSetForm()`, `afterSetOptions()`. Extend it to build custom form implementations.
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
### Inputs
|
|
35
|
+
|
|
36
|
+
| Input | Type | Default | Description |
|
|
37
|
+
| --------- | ---------------------------------------- | ---------- | ------------------------------------------------------ |
|
|
38
|
+
| `options` | `InputSignal<IFormOptions<T>>` | _required_ | Form configuration (model, mode, control, loading$, …) |
|
|
39
|
+
| `class` | `InputSignal<string>` (alias `cssClass`) | `''` | External CSS classes on the container |
|
|
40
|
+
|
|
41
|
+
### Outputs
|
|
42
|
+
|
|
43
|
+
| Output | Type | Description |
|
|
44
|
+
| -------------------- | ------------------------------ | ------------------------------------------------ |
|
|
45
|
+
| `invokeSubmit` | `OutputEmitterRef<T>` | Emits the form value when the form is submitted |
|
|
46
|
+
| `valueChange` | `OutputEmitterRef<T>` | Emits the full form value on every change |
|
|
47
|
+
| `valuePartialChange` | `OutputEmitterRef<Partial<T>>` | Emits only the changed portion of the form value |
|
|
48
|
+
| `validChange` | `OutputEmitterRef<boolean>` | Emits form validity on every change |
|
|
49
|
+
|
|
50
|
+
### IFormOptions
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
interface IFormOptions<T> {
|
|
54
|
+
model: T; // Model instance (decorated with @Model / @Field)
|
|
55
|
+
show: boolean; // Whether the form is visible
|
|
56
|
+
treeLevel?: number; // Nesting depth in hierarchical forms
|
|
57
|
+
control?: AbstractControl; // Pre-built form group — skips FormFactory when provided
|
|
58
|
+
mode?: 'create' | 'update' | string; // Merges @Field({ create: … }) or { update: … } overrides
|
|
59
|
+
loading$?: Observable<boolean>; // Shows loading state while true
|
|
60
|
+
uniqueProvider?: (values: Record<keyof T, any>) => Promise<boolean>; // Async uniqueness check
|
|
61
|
+
possibilities?: {
|
|
62
|
+
[key: string]: WritableSignal<
|
|
63
|
+
{ id: any; text: string; checked: boolean }[]
|
|
64
|
+
>;
|
|
65
|
+
}; // Options for radio/check inputs keyed by field name
|
|
66
|
+
inputComponents?: {
|
|
67
|
+
[key: string]: InputBaseComponentType<T>;
|
|
68
|
+
}; // Per-field component overrides keyed by field name
|
|
69
|
+
fieldOptions?: IFieldOptions; // Additional @Field() metadata overrides
|
|
70
|
+
modelOptions?: IModelOptions; // Additional @Model() metadata overrides
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### FORM_STANDARD_COMPONENT_TOKEN
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { FORM_STANDARD_COMPONENT_TOKEN } from '@smartsoft001/angular';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
InjectionToken that allows replacing the default `FormStandardComponent` with a custom implementation. Provide a `Type<FormBaseComponent<T>>`.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
providers: [
|
|
84
|
+
{ provide: FORM_STANDARD_COMPONENT_TOKEN, useValue: MyCustomFormComponent },
|
|
85
|
+
];
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Extending the Base Class
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { Component, ViewEncapsulation } from '@angular/core';
|
|
92
|
+
import { FormBaseComponent } from '@smartsoft001/angular';
|
|
93
|
+
import { SmartInputComponent } from '@smartsoft001/angular';
|
|
94
|
+
|
|
95
|
+
@Component({
|
|
96
|
+
selector: 'my-custom-form',
|
|
97
|
+
template: `
|
|
98
|
+
<form [formGroup]="form" [class]="cssClass()" (ngSubmit)="submit()">
|
|
99
|
+
@for (field of fields; track field.key) {
|
|
100
|
+
<div class="my-field-row">
|
|
101
|
+
<smart-input [options]="field.inputOptions"></smart-input>
|
|
102
|
+
</div>
|
|
103
|
+
}
|
|
104
|
+
<button type="submit">Save</button>
|
|
105
|
+
</form>
|
|
106
|
+
`,
|
|
107
|
+
imports: [SmartInputComponent],
|
|
108
|
+
encapsulation: ViewEncapsulation.None,
|
|
109
|
+
})
|
|
110
|
+
export class MyCustomFormComponent extends FormBaseComponent<any> {}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Usage Examples
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<!-- Basic form -->
|
|
117
|
+
<smart-form
|
|
118
|
+
[options]="{ model: userModel, show: true }"
|
|
119
|
+
(invokeSubmit)="onSubmit($event)"
|
|
120
|
+
></smart-form>
|
|
121
|
+
|
|
122
|
+
<!-- With external CSS class -->
|
|
123
|
+
<smart-form
|
|
124
|
+
class="smart:p-4 smart:bg-white"
|
|
125
|
+
[options]="{ model: userModel, show: true }"
|
|
126
|
+
(invokeSubmit)="onSubmit($event)"
|
|
127
|
+
></smart-form>
|
|
128
|
+
|
|
129
|
+
<!-- Update mode -->
|
|
130
|
+
<smart-form
|
|
131
|
+
[options]="{ model: userModel, show: true, mode: 'update' }"
|
|
132
|
+
(invokeSubmit)="onUpdate($event)"
|
|
133
|
+
(validChange)="isValid = $event"
|
|
134
|
+
></smart-form>
|
|
135
|
+
|
|
136
|
+
<!-- With pre-built control (skips FormFactory) -->
|
|
137
|
+
<smart-form
|
|
138
|
+
[options]="{ model: userModel, show: true, control: myFormGroup }"
|
|
139
|
+
(invokeSubmit)="onSubmit($event)"
|
|
140
|
+
></smart-form>
|
|
141
|
+
|
|
142
|
+
<!-- With loading state -->
|
|
143
|
+
<smart-form
|
|
144
|
+
[options]="{ model: userModel, show: true, loading$: saving$ }"
|
|
145
|
+
(invokeSubmit)="onSubmit($event)"
|
|
146
|
+
></smart-form>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Field Rendering
|
|
150
|
+
|
|
151
|
+
Each field is rendered via `<smart-input>`. Per-field dispatch by `FieldType` is handled inside `<smart-input>` itself. See the `angular-components-input` skill for per-field details.
|
|
152
|
+
|
|
153
|
+
## File Locations
|
|
154
|
+
|
|
155
|
+
- Wrapper: `packages/shared/angular/src/lib/components/form/form.component.ts`
|
|
156
|
+
- Standard: `packages/shared/angular/src/lib/components/form/standard/standard.component.ts`
|
|
157
|
+
- Base class: `packages/shared/angular/src/lib/components/form/base/base.component.ts`
|
|
158
|
+
- Token: `packages/shared/angular/src/lib/shared.inectors.ts` (`FORM_STANDARD_COMPONENT_TOKEN`)
|
|
159
|
+
- Interface: `packages/shared/angular/src/lib/models/interfaces.ts` (`IFormOptions`)
|
|
160
|
+
- Stories: `packages/shared/angular/src/lib/components/form/form.component.stories.ts`
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: angular-components-grid-list
|
|
3
|
+
description: Grid list component API with InjectionToken pattern for custom implementations.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Grid List Component
|
|
8
|
+
|
|
9
|
+
The `<smart-grid-list>` component renders a grid of card-like records with optional title, description, per-item icon/image, link, badge, action template, and bottom footer slot. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract `GridListBaseComponent` defines the shared API — optional `IGridListOptions` and `cssClass` (alias `class`). `GridListStandardComponent` is a barebones placeholder concrete implementation. `GridListComponent` is the public wrapper that renders `GridListStandardComponent` by default and accepts a custom replacement via `GRID_LIST_STANDARD_COMPONENT_TOKEN`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Developer wants to use or customize the grid list component
|
|
14
|
+
- Developer asks about `<smart-grid-list>`, `GridListComponent`, `GridListStandardComponent`, or `GridListBaseComponent`
|
|
15
|
+
|
|
16
|
+
## Components
|
|
17
|
+
|
|
18
|
+
### GridListComponent (`<smart-grid-list>`)
|
|
19
|
+
|
|
20
|
+
Main wrapper component. Renders `GridListStandardComponent` by default. When `GRID_LIST_STANDARD_COMPONENT_TOKEN` is provided, renders the injected component via `NgComponentOutlet`.
|
|
21
|
+
|
|
22
|
+
### GridListStandardComponent (`<smart-grid-list-standard>`)
|
|
23
|
+
|
|
24
|
+
Barebones placeholder concrete implementation. Renders a wrapper `<div>` containing an optional `<h3 class="title">`, optional `<p class="description">`, and a `<ul role="list">` with one `<li class="item">` per item. Each item renders the icon/image (icon template wins over image URL), a body group with the title (rendered as `<a class="title">` if `href` is provided, otherwise `<span class="title">`) and optional description, plus optional badge/action template slots. When the item list is empty, the optional `emptyTpl` is rendered inside `<div class="empty">`. A bottom `footerTpl` renders inside `<div class="footer">`. The external `cssClass` is applied to the root wrapper. It does not include any visual styling — it exists solely as the default structural placeholder until a custom implementation is registered through the token.
|
|
25
|
+
|
|
26
|
+
### GridListBaseComponent (abstract)
|
|
27
|
+
|
|
28
|
+
Abstract base directive for extending custom grid-list implementations. Exposes `options` as an `InputSignal<IGridListOptions | undefined>` and `cssClass` as an `InputSignal<string>` (with alias `class`).
|
|
29
|
+
|
|
30
|
+
## API
|
|
31
|
+
|
|
32
|
+
### Inputs
|
|
33
|
+
|
|
34
|
+
| Input | Type | Default | Description |
|
|
35
|
+
| --------- | -------------------------------------------- | ------- | ------------------------------------------------------------------------------- |
|
|
36
|
+
| `options` | `InputSignal<IGridListOptions \| undefined>` | - | Optional configuration (title, description, items, columns, gap, layout, slots) |
|
|
37
|
+
| `class` | `InputSignal<string>` | `''` | External CSS classes (alias for `cssClass`) |
|
|
38
|
+
|
|
39
|
+
### IGridListOptions
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
interface IGridListOptions {
|
|
43
|
+
title?: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
items?: IGridListItem[];
|
|
46
|
+
columns?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
47
|
+
gap?: 'sm' | 'md' | 'lg';
|
|
48
|
+
layout?: 'cards' | 'horizontal' | 'logos';
|
|
49
|
+
emptyTpl?: TemplateRef<unknown>;
|
|
50
|
+
footerTpl?: TemplateRef<unknown>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface IGridListItem {
|
|
54
|
+
id?: string;
|
|
55
|
+
title: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
imageUrl?: string;
|
|
58
|
+
imageAlt?: string;
|
|
59
|
+
href?: string;
|
|
60
|
+
iconTpl?: TemplateRef<unknown>;
|
|
61
|
+
badgeTpl?: TemplateRef<unknown>;
|
|
62
|
+
actionTpl?: TemplateRef<unknown>;
|
|
63
|
+
ariaLabel?: string;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
All properties are optional except `IGridListItem.title`. The default `GridListStandardComponent` consumes every property; a section is rendered only when its template/string is provided. Within an item, `iconTpl` takes precedence over `imageUrl` when both are set. `columns`, `gap` and `layout` are hints for custom implementations registered via the token.
|
|
68
|
+
|
|
69
|
+
## GRID_LIST_STANDARD_COMPONENT_TOKEN
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { GRID_LIST_STANDARD_COMPONENT_TOKEN } from '@smartsoft001/angular';
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
InjectionToken that allows replacing the default `GridListStandardComponent` with a custom implementation. Provide a `Type<GridListBaseComponent>` to override.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
providers: [
|
|
79
|
+
{
|
|
80
|
+
provide: GRID_LIST_STANDARD_COMPONENT_TOKEN,
|
|
81
|
+
useValue: MyCustomGridListComponent,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Extending the Base Class
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import {
|
|
90
|
+
ChangeDetectionStrategy,
|
|
91
|
+
Component,
|
|
92
|
+
computed,
|
|
93
|
+
input,
|
|
94
|
+
ViewEncapsulation,
|
|
95
|
+
} from '@angular/core';
|
|
96
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
97
|
+
|
|
98
|
+
import { GridListBaseComponent } from '@smartsoft001/angular';
|
|
99
|
+
|
|
100
|
+
@Component({
|
|
101
|
+
selector: 'my-custom-grid-list',
|
|
102
|
+
template: `
|
|
103
|
+
<div [class]="containerClasses()">
|
|
104
|
+
@if (options()?.title) {
|
|
105
|
+
<h3>{{ options()!.title }}</h3>
|
|
106
|
+
}
|
|
107
|
+
<ul [attr.data-columns]="options()?.columns ?? null">
|
|
108
|
+
@for (item of options()?.items ?? []; track item.id ?? $index) {
|
|
109
|
+
<li>
|
|
110
|
+
@if (item.imageUrl) {
|
|
111
|
+
<img [src]="item.imageUrl" [attr.alt]="item.imageAlt ?? ''" />
|
|
112
|
+
}
|
|
113
|
+
@if (item.href) {
|
|
114
|
+
<a [attr.href]="item.href">{{ item.title }}</a>
|
|
115
|
+
} @else {
|
|
116
|
+
<span>{{ item.title }}</span>
|
|
117
|
+
}
|
|
118
|
+
@if (item.description) {
|
|
119
|
+
<p>{{ item.description }}</p>
|
|
120
|
+
}
|
|
121
|
+
</li>
|
|
122
|
+
}
|
|
123
|
+
</ul>
|
|
124
|
+
</div>
|
|
125
|
+
`,
|
|
126
|
+
imports: [NgTemplateOutlet],
|
|
127
|
+
encapsulation: ViewEncapsulation.None,
|
|
128
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
129
|
+
})
|
|
130
|
+
export class MyCustomGridListComponent extends GridListBaseComponent {
|
|
131
|
+
// NgComponentOutlet passes 'cssClass' by canonical name, not the 'class' alias.
|
|
132
|
+
override cssClass = input<string>('');
|
|
133
|
+
|
|
134
|
+
containerClasses = computed(() => {
|
|
135
|
+
const classes = ['my-grid-list'];
|
|
136
|
+
const extra = this.cssClass();
|
|
137
|
+
if (extra) classes.push(extra);
|
|
138
|
+
return classes.join(' ');
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Usage Examples
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<!-- Simple cards with image and title -->
|
|
147
|
+
<smart-grid-list
|
|
148
|
+
[options]="{
|
|
149
|
+
title: 'Team',
|
|
150
|
+
columns: 3,
|
|
151
|
+
items: [
|
|
152
|
+
{ id: '1', title: 'Lindsay Walton', imageUrl: '/img/lindsay.jpg', description: 'Front-end' },
|
|
153
|
+
{ id: '2', title: 'Courtney Henry', imageUrl: '/img/courtney.jpg', description: 'Designer' },
|
|
154
|
+
{ id: '3', title: 'Tom Cook', imageUrl: '/img/tom.jpg', description: 'Director' },
|
|
155
|
+
],
|
|
156
|
+
}"
|
|
157
|
+
/>
|
|
158
|
+
|
|
159
|
+
<!-- Logo cards (links) -->
|
|
160
|
+
<smart-grid-list
|
|
161
|
+
[options]="{
|
|
162
|
+
layout: 'logos',
|
|
163
|
+
columns: 4,
|
|
164
|
+
items: [
|
|
165
|
+
{ title: 'Acme', href: '/acme', imageUrl: '/logos/acme.svg' },
|
|
166
|
+
{ title: 'Globex', href: '/globex', imageUrl: '/logos/globex.svg' },
|
|
167
|
+
],
|
|
168
|
+
}"
|
|
169
|
+
/>
|
|
170
|
+
|
|
171
|
+
<!-- With per-item action and badge -->
|
|
172
|
+
<ng-template #activeBadge>
|
|
173
|
+
<span class="badge-active">Active</span>
|
|
174
|
+
</ng-template>
|
|
175
|
+
<ng-template #openAction>
|
|
176
|
+
<button>Open</button>
|
|
177
|
+
</ng-template>
|
|
178
|
+
|
|
179
|
+
<smart-grid-list
|
|
180
|
+
[options]="{
|
|
181
|
+
items: [
|
|
182
|
+
{
|
|
183
|
+
title: 'Project Alpha',
|
|
184
|
+
description: 'Design system',
|
|
185
|
+
badgeTpl: activeBadge,
|
|
186
|
+
actionTpl: openAction,
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
}"
|
|
190
|
+
/>
|
|
191
|
+
|
|
192
|
+
<!-- With empty state and footer -->
|
|
193
|
+
<ng-template #emptyMsg>
|
|
194
|
+
<span>Brak wyników</span>
|
|
195
|
+
</ng-template>
|
|
196
|
+
<ng-template #footer>
|
|
197
|
+
<a href="#">Load more →</a>
|
|
198
|
+
</ng-template>
|
|
199
|
+
|
|
200
|
+
<smart-grid-list
|
|
201
|
+
[options]="{
|
|
202
|
+
items: [],
|
|
203
|
+
emptyTpl: emptyMsg,
|
|
204
|
+
footerTpl: footer,
|
|
205
|
+
}"
|
|
206
|
+
/>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## File Locations
|
|
210
|
+
|
|
211
|
+
- Wrapper: `packages/shared/angular/src/lib/components/grid-list/grid-list.component.ts`
|
|
212
|
+
- Standard: `packages/shared/angular/src/lib/components/grid-list/standard/standard.component.ts`
|
|
213
|
+
- Base class: `packages/shared/angular/src/lib/components/grid-list/base/base.component.ts`
|
|
214
|
+
- Token: `packages/shared/angular/src/lib/shared.inectors.ts` (`GRID_LIST_STANDARD_COMPONENT_TOKEN`)
|
|
215
|
+
- Interfaces: `packages/shared/angular/src/lib/models/interfaces.ts` (`IGridListOptions`, `IGridListItem`, `SmartGridListLayout`, `SmartGridListColumns`)
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: angular-components-info
|
|
3
|
+
description: Info popover component API with InjectionToken pattern for custom implementations.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Info Component
|
|
8
|
+
|
|
9
|
+
The `<smart-info>` component provides a small info icon that toggles a popover with a short tooltip text. It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. It renders a default `InfoStandardComponent` which can be replaced via `INFO_STANDARD_COMPONENT_TOKEN`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Developer wants to use or customize the info component
|
|
14
|
+
- Developer asks about `<smart-info>`, `InfoComponent`, `InfoStandardComponent`, or `InfoBaseComponent`
|
|
15
|
+
|
|
16
|
+
## Components
|
|
17
|
+
|
|
18
|
+
### InfoComponent (`<smart-info>`)
|
|
19
|
+
|
|
20
|
+
Main wrapper component. Renders `InfoStandardComponent` by default. When `INFO_STANDARD_COMPONENT_TOKEN` is provided, renders the injected component via `NgComponentOutlet`.
|
|
21
|
+
|
|
22
|
+
### InfoStandardComponent (`<smart-info-standard>`)
|
|
23
|
+
|
|
24
|
+
Default concrete implementation. Renders:
|
|
25
|
+
|
|
26
|
+
- a small SVG info icon (button),
|
|
27
|
+
- a popover shown while `isOpen()` is `true`,
|
|
28
|
+
- Tailwind-styled container with `smart:dark:*` dark-mode classes,
|
|
29
|
+
- a `document:click` listener that closes the popover on outside click.
|
|
30
|
+
|
|
31
|
+
### InfoBaseComponent (abstract)
|
|
32
|
+
|
|
33
|
+
Abstract base directive for extending custom info implementations. Exposes `options`, `cssClass`, `isOpen` signal, and `toggle()`/`open()`/`close()` methods.
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
### Inputs
|
|
38
|
+
|
|
39
|
+
| Input | Type | Default | Description |
|
|
40
|
+
| --------- | --------------------------- | -------- | ------------------------------------------- |
|
|
41
|
+
| `options` | `InputSignal<IInfoOptions>` | required | Info configuration |
|
|
42
|
+
| `class` | `InputSignal<string>` | `''` | External CSS classes (alias for `cssClass`) |
|
|
43
|
+
|
|
44
|
+
### IInfoOptions
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
interface IInfoOptions {
|
|
48
|
+
text: string;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The `text` value is rendered inside the popover through `TranslatePipe`, so it may be a translation key.
|
|
53
|
+
|
|
54
|
+
### INFO_STANDARD_COMPONENT_TOKEN
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { INFO_STANDARD_COMPONENT_TOKEN } from '@smartsoft001/angular';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
InjectionToken that allows replacing the default `InfoStandardComponent` with a custom implementation. Provide a `Type<InfoBaseComponent>` to override.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// In your app module or component providers:
|
|
64
|
+
providers: [
|
|
65
|
+
{
|
|
66
|
+
provide: INFO_STANDARD_COMPONENT_TOKEN,
|
|
67
|
+
useValue: MyCustomInfoComponent,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Extending the Base Class
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import {
|
|
76
|
+
ChangeDetectionStrategy,
|
|
77
|
+
Component,
|
|
78
|
+
computed,
|
|
79
|
+
ElementRef,
|
|
80
|
+
HostListener,
|
|
81
|
+
inject,
|
|
82
|
+
ViewEncapsulation,
|
|
83
|
+
} from '@angular/core';
|
|
84
|
+
import { TranslatePipe } from '@ngx-translate/core';
|
|
85
|
+
|
|
86
|
+
import { InfoBaseComponent } from '@smartsoft001/angular';
|
|
87
|
+
|
|
88
|
+
@Component({
|
|
89
|
+
selector: 'my-custom-info',
|
|
90
|
+
template: `
|
|
91
|
+
<div [class]="containerClasses()">
|
|
92
|
+
<button type="button" (click)="toggle(); $event.stopPropagation()">
|
|
93
|
+
?
|
|
94
|
+
</button>
|
|
95
|
+
@if (isOpen()) {
|
|
96
|
+
<div class="my-popover">{{ options().text | translate }}</div>
|
|
97
|
+
}
|
|
98
|
+
</div>
|
|
99
|
+
`,
|
|
100
|
+
imports: [TranslatePipe],
|
|
101
|
+
encapsulation: ViewEncapsulation.None,
|
|
102
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
103
|
+
})
|
|
104
|
+
export class MyCustomInfoComponent extends InfoBaseComponent {
|
|
105
|
+
private readonly elementRef = inject(ElementRef);
|
|
106
|
+
|
|
107
|
+
containerClasses = computed(() => {
|
|
108
|
+
const classes = ['my-info-container'];
|
|
109
|
+
const extra = this.cssClass();
|
|
110
|
+
if (extra) classes.push(extra);
|
|
111
|
+
return classes.join(' ');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
@HostListener('document:click', ['$event'])
|
|
115
|
+
onDocumentClick(event: MouseEvent): void {
|
|
116
|
+
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
117
|
+
this.close();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
When extending the base directly, remember to:
|
|
124
|
+
|
|
125
|
+
- declare `cssClass = input<string>('')` explicitly (no `class` alias) if the component is used via `NgComponentOutlet` through `INFO_STANDARD_COMPONENT_TOKEN`, because `NgComponentOutlet` passes inputs by canonical name (not by alias),
|
|
126
|
+
- implement a close-on-outside-click listener yourself if the popover should close when clicking outside — the base class does not do it for you.
|
|
127
|
+
|
|
128
|
+
## Usage Examples
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<!-- Basic -->
|
|
132
|
+
<smart-info [options]="{ text: 'Helpful description' }"></smart-info>
|
|
133
|
+
|
|
134
|
+
<!-- Longer text -->
|
|
135
|
+
<smart-info
|
|
136
|
+
[options]="{ text: 'A longer explanation that wraps inside the popover container.' }"
|
|
137
|
+
></smart-info>
|
|
138
|
+
|
|
139
|
+
<!-- Inline with a label -->
|
|
140
|
+
<div class="smart:flex smart:items-center smart:gap-2">
|
|
141
|
+
<label>Email address</label>
|
|
142
|
+
<smart-info
|
|
143
|
+
[options]="{ text: 'Enter your primary email address.' }"
|
|
144
|
+
></smart-info>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<!-- With external class -->
|
|
148
|
+
<smart-info
|
|
149
|
+
class="smart:text-indigo-600"
|
|
150
|
+
[options]="{ text: 'External class applied via the class alias.' }"
|
|
151
|
+
></smart-info>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## File Locations
|
|
155
|
+
|
|
156
|
+
- Wrapper: `packages/shared/angular/src/lib/components/info/info.component.ts`
|
|
157
|
+
- Standard: `packages/shared/angular/src/lib/components/info/standard/standard.component.ts`
|
|
158
|
+
- Base class: `packages/shared/angular/src/lib/components/info/base/base.component.ts`
|
|
159
|
+
- Token: `packages/shared/angular/src/lib/shared.inectors.ts` (`INFO_STANDARD_COMPONENT_TOKEN`)
|
|
160
|
+
- Interface: `packages/shared/angular/src/lib/models/interfaces.ts` (`IInfoOptions`)
|