osi-cards-lib 1.0.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/README.md +763 -0
- package/esm2022/lib/components/ai-card-renderer/ai-card-renderer.component.mjs +911 -0
- package/esm2022/lib/components/card-preview/card-preview.component.mjs +74 -0
- package/esm2022/lib/components/card-skeleton/card-skeleton.component.mjs +24 -0
- package/esm2022/lib/components/masonry-grid/masonry-grid.component.mjs +330 -0
- package/esm2022/lib/components/section-renderer/section-renderer.component.mjs +166 -0
- package/esm2022/lib/components/sections/analytics-section/analytics-section.component.mjs +70 -0
- package/esm2022/lib/components/sections/base-section.component.mjs +335 -0
- package/esm2022/lib/components/sections/brand-colors-section/brand-colors-section.component.mjs +89 -0
- package/esm2022/lib/components/sections/chart-section/chart-section.component.mjs +92 -0
- package/esm2022/lib/components/sections/contact-card-section/contact-card-section.component.mjs +70 -0
- package/esm2022/lib/components/sections/event-section/event-section.component.mjs +32 -0
- package/esm2022/lib/components/sections/fallback-section/fallback-section.component.mjs +16 -0
- package/esm2022/lib/components/sections/financials-section/financials-section.component.mjs +53 -0
- package/esm2022/lib/components/sections/info-section.component.mjs +68 -0
- package/esm2022/lib/components/sections/list-section/list-section.component.mjs +36 -0
- package/esm2022/lib/components/sections/map-section/map-section.component.mjs +52 -0
- package/esm2022/lib/components/sections/network-card-section/network-card-section.component.mjs +41 -0
- package/esm2022/lib/components/sections/news-section/news-section.component.mjs +44 -0
- package/esm2022/lib/components/sections/overview-section/overview-section.component.mjs +47 -0
- package/esm2022/lib/components/sections/product-section/product-section.component.mjs +129 -0
- package/esm2022/lib/components/sections/quotation-section/quotation-section.component.mjs +39 -0
- package/esm2022/lib/components/sections/social-media-section/social-media-section.component.mjs +45 -0
- package/esm2022/lib/components/sections/solutions-section/solutions-section.component.mjs +29 -0
- package/esm2022/lib/components/sections/text-reference-section/text-reference-section.component.mjs +42 -0
- package/esm2022/lib/icons/index.mjs +2 -0
- package/esm2022/lib/icons/lucide-icons.module.mjs +91 -0
- package/esm2022/lib/models/card.model.mjs +111 -0
- package/esm2022/lib/models/index.mjs +2 -0
- package/esm2022/lib/services/icon.service.mjs +148 -0
- package/esm2022/lib/services/index.mjs +5 -0
- package/esm2022/lib/services/magnetic-tilt.service.mjs +224 -0
- package/esm2022/lib/services/section-normalization.service.mjs +243 -0
- package/esm2022/lib/services/section-utils.service.mjs +122 -0
- package/esm2022/lib/utils/card-diff.util.mjs +327 -0
- package/esm2022/lib/utils/index.mjs +3 -0
- package/esm2022/lib/utils/responsive.util.mjs +14 -0
- package/esm2022/osi-cards-lib.mjs +5 -0
- package/esm2022/public-api.mjs +57 -0
- package/fesm2022/osi-cards-lib.mjs +3960 -0
- package/index.d.ts +5 -0
- package/lib/components/ai-card-renderer/ai-card-renderer.component.d.ts +163 -0
- package/lib/components/card-preview/card-preview.component.d.ts +52 -0
- package/lib/components/card-skeleton/card-skeleton.component.d.ts +8 -0
- package/lib/components/masonry-grid/masonry-grid.component.d.ts +72 -0
- package/lib/components/section-renderer/section-renderer.component.d.ts +25 -0
- package/lib/components/sections/analytics-section/analytics-section.component.d.ts +32 -0
- package/lib/components/sections/base-section.component.d.ts +138 -0
- package/lib/components/sections/brand-colors-section/brand-colors-section.component.d.ts +28 -0
- package/lib/components/sections/chart-section/chart-section.component.d.ts +30 -0
- package/lib/components/sections/contact-card-section/contact-card-section.component.d.ts +35 -0
- package/lib/components/sections/event-section/event-section.component.d.ts +17 -0
- package/lib/components/sections/fallback-section/fallback-section.component.d.ts +7 -0
- package/lib/components/sections/financials-section/financials-section.component.d.ts +27 -0
- package/lib/components/sections/info-section.component.d.ts +33 -0
- package/lib/components/sections/list-section/list-section.component.d.ts +21 -0
- package/lib/components/sections/map-section/map-section.component.d.ts +22 -0
- package/lib/components/sections/network-card-section/network-card-section.component.d.ts +18 -0
- package/lib/components/sections/news-section/news-section.component.d.ts +16 -0
- package/lib/components/sections/overview-section/overview-section.component.d.ts +19 -0
- package/lib/components/sections/product-section/product-section.component.d.ts +57 -0
- package/lib/components/sections/quotation-section/quotation-section.component.d.ts +23 -0
- package/lib/components/sections/social-media-section/social-media-section.component.d.ts +11 -0
- package/lib/components/sections/solutions-section/solutions-section.component.d.ts +19 -0
- package/lib/components/sections/text-reference-section/text-reference-section.component.d.ts +25 -0
- package/lib/icons/index.d.ts +1 -0
- package/lib/icons/lucide-icons.module.d.ts +7 -0
- package/lib/models/card.model.d.ts +289 -0
- package/lib/models/index.d.ts +1 -0
- package/lib/services/icon.service.d.ts +9 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/magnetic-tilt.service.d.ts +34 -0
- package/lib/services/section-normalization.service.d.ts +38 -0
- package/lib/services/section-utils.service.d.ts +46 -0
- package/lib/utils/card-diff.util.d.ts +52 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/responsive.util.d.ts +2 -0
- package/package.json +63 -0
- package/public-api.d.ts +50 -0
- package/styles/_styles.scss +95 -0
- package/styles/components/cards/_ai-card.scss +743 -0
- package/styles/components/sections/_analytics.scss +280 -0
- package/styles/components/sections/_brand-colors.scss +280 -0
- package/styles/components/sections/_chart.scss +494 -0
- package/styles/components/sections/_contact.scss +250 -0
- package/styles/components/sections/_design-system.scss +540 -0
- package/styles/components/sections/_event.scss +246 -0
- package/styles/components/sections/_fallback.scss +172 -0
- package/styles/components/sections/_financials.scss +258 -0
- package/styles/components/sections/_global-enforcement.scss +648 -0
- package/styles/components/sections/_info.scss +224 -0
- package/styles/components/sections/_list.scss +216 -0
- package/styles/components/sections/_map.scss +186 -0
- package/styles/components/sections/_network.scss +115 -0
- package/styles/components/sections/_news.scss +81 -0
- package/styles/components/sections/_overview.scss +159 -0
- package/styles/components/sections/_product.scss +906 -0
- package/styles/components/sections/_quotation.scss +151 -0
- package/styles/components/sections/_section-shell.scss +385 -0
- package/styles/components/sections/_section-types.scss +290 -0
- package/styles/components/sections/_sections-base.scss +332 -0
- package/styles/components/sections/_social-media.scss +88 -0
- package/styles/components/sections/_solutions.scss +205 -0
- package/styles/components/sections/_text-reference.scss +158 -0
- package/styles/components/sections/_unified-cards.scss +124 -0
- package/styles/core/_animations.scss +766 -0
- package/styles/core/_global.scss +66 -0
- package/styles/core/_mixins.scss +140 -0
- package/styles/core/_surface-layers.scss +76 -0
- package/styles/core/_utilities.scss +193 -0
- package/styles/core/_variables.scss +462 -0
- package/styles/core/variables/_colors.scss +212 -0
- package/styles/layout/_masonry.scss +60 -0
- package/styles/layout/_tilt.scss +214 -0
package/README.md
ADDED
|
@@ -0,0 +1,763 @@
|
|
|
1
|
+
# OSI Cards Library
|
|
2
|
+
|
|
3
|
+
A standalone Angular library for rendering beautiful, interactive AI-powered cards with full functionality including all section types, animations, and styling.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### From npm (Recommended)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @osi/cards-lib
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The package is available on npm and can be installed directly. This is the easiest and recommended way to use the library.
|
|
14
|
+
|
|
15
|
+
## Peer Dependencies
|
|
16
|
+
|
|
17
|
+
The library requires the following peer dependencies:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"@angular/common": "^20.0.0",
|
|
22
|
+
"@angular/core": "^20.0.0",
|
|
23
|
+
"@angular/animations": "^20.0.0",
|
|
24
|
+
"@angular/platform-browser": "^20.0.0",
|
|
25
|
+
"lucide-angular": "^0.548.0",
|
|
26
|
+
"rxjs": "~7.8.0"
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Optional Dependencies
|
|
31
|
+
|
|
32
|
+
For enhanced functionality (charts and maps), you can optionally install:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install chart.js leaflet
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
These are optional - the library works without them, but chart and map sections will have limited functionality.
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### Step 1: Install the Library
|
|
43
|
+
|
|
44
|
+
Install the library using npm:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install @osi/cards-lib
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**For local development** (if using the library from a local path):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install /path/to/OSI-Cards-1/dist/osi-cards-lib
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or add to your `package.json`:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@osi/cards-lib": "file:../OSI-Cards-1/dist/osi-cards-lib"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Step 2: Install Peer Dependencies
|
|
67
|
+
|
|
68
|
+
The library requires these peer dependencies. Install them if not already present:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm install @angular/common@^20.0.0 @angular/core@^20.0.0 @angular/animations@^20.0.0 @angular/platform-browser@^20.0.0 lucide-angular@^0.548.0 rxjs@~7.8.0
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Step 3: Import Styles
|
|
75
|
+
|
|
76
|
+
**Option A: Import in your main styles file** (Recommended)
|
|
77
|
+
|
|
78
|
+
Add this to your `src/styles.scss` (or `styles.css`):
|
|
79
|
+
|
|
80
|
+
```scss
|
|
81
|
+
@import '@osi/cards-lib/styles/_styles';
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Option B: Add to angular.json**
|
|
85
|
+
|
|
86
|
+
Add the styles path to your `angular.json`:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"projects": {
|
|
91
|
+
"your-app": {
|
|
92
|
+
"architect": {
|
|
93
|
+
"build": {
|
|
94
|
+
"options": {
|
|
95
|
+
"styles": [
|
|
96
|
+
"node_modules/@osi/cards-lib/styles/_styles.scss",
|
|
97
|
+
"src/styles.scss"
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Note:** If you're using Tailwind CSS, you may need to include Tailwind directives in your main styles file. The library styles work independently but some utility classes may require Tailwind.
|
|
108
|
+
|
|
109
|
+
### Step 4: Import and Use the Card Component
|
|
110
|
+
|
|
111
|
+
#### In a Standalone Component
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { Component } from '@angular/core';
|
|
115
|
+
import { AICardRendererComponent, AICardConfig } from '@osi/cards-lib';
|
|
116
|
+
|
|
117
|
+
@Component({
|
|
118
|
+
selector: 'app-my-component',
|
|
119
|
+
standalone: true,
|
|
120
|
+
imports: [AICardRendererComponent], // Import the card component
|
|
121
|
+
template: `
|
|
122
|
+
<div class="container">
|
|
123
|
+
<app-ai-card-renderer [cardConfig]="cardConfig"></app-ai-card-renderer>
|
|
124
|
+
</div>
|
|
125
|
+
`
|
|
126
|
+
})
|
|
127
|
+
export class MyComponent {
|
|
128
|
+
// Define your card configuration
|
|
129
|
+
cardConfig: AICardConfig = {
|
|
130
|
+
cardTitle: 'My Card Title',
|
|
131
|
+
cardSubtitle: 'Optional subtitle',
|
|
132
|
+
sections: [
|
|
133
|
+
{
|
|
134
|
+
title: 'Overview',
|
|
135
|
+
type: 'overview',
|
|
136
|
+
fields: [
|
|
137
|
+
{ label: 'Name', value: 'Example Company' },
|
|
138
|
+
{ label: 'Status', value: 'Active' },
|
|
139
|
+
{ label: 'Industry', value: 'Technology' }
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Complete Example with Event Handlers
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { Component } from '@angular/core';
|
|
151
|
+
import { CommonModule } from '@angular/common';
|
|
152
|
+
import {
|
|
153
|
+
AICardRendererComponent,
|
|
154
|
+
AICardConfig,
|
|
155
|
+
CardFieldInteractionEvent
|
|
156
|
+
} from '@osi/cards-lib';
|
|
157
|
+
|
|
158
|
+
@Component({
|
|
159
|
+
selector: 'app-card-example',
|
|
160
|
+
standalone: true,
|
|
161
|
+
imports: [AICardRendererComponent, CommonModule],
|
|
162
|
+
template: `
|
|
163
|
+
<div class="card-container">
|
|
164
|
+
<app-ai-card-renderer
|
|
165
|
+
[cardConfig]="cardConfig"
|
|
166
|
+
[tiltEnabled]="true"
|
|
167
|
+
(fieldInteraction)="onFieldClick($event)"
|
|
168
|
+
(cardInteraction)="onCardInteraction($event)">
|
|
169
|
+
</app-ai-card-renderer>
|
|
170
|
+
</div>
|
|
171
|
+
`,
|
|
172
|
+
styles: [`
|
|
173
|
+
.card-container {
|
|
174
|
+
max-width: 1200px;
|
|
175
|
+
margin: 0 auto;
|
|
176
|
+
padding: 20px;
|
|
177
|
+
}
|
|
178
|
+
`]
|
|
179
|
+
})
|
|
180
|
+
export class CardExampleComponent {
|
|
181
|
+
cardConfig: AICardConfig = {
|
|
182
|
+
cardTitle: 'Company Profile',
|
|
183
|
+
cardSubtitle: 'Detailed company information',
|
|
184
|
+
sections: [
|
|
185
|
+
{
|
|
186
|
+
title: 'Company Info',
|
|
187
|
+
type: 'info',
|
|
188
|
+
fields: [
|
|
189
|
+
{ label: 'Industry', value: 'Technology' },
|
|
190
|
+
{ label: 'Employees', value: '250' },
|
|
191
|
+
{ label: 'Founded', value: '2010' }
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
title: 'Key Metrics',
|
|
196
|
+
type: 'analytics',
|
|
197
|
+
fields: [
|
|
198
|
+
{
|
|
199
|
+
label: 'Revenue',
|
|
200
|
+
value: 5000000,
|
|
201
|
+
change: 15,
|
|
202
|
+
trend: 'up'
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
actions: [
|
|
208
|
+
{
|
|
209
|
+
type: 'website',
|
|
210
|
+
label: 'Visit Website',
|
|
211
|
+
variant: 'primary',
|
|
212
|
+
url: 'https://example.com'
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
onFieldClick(event: CardFieldInteractionEvent): void {
|
|
218
|
+
console.log('Field clicked:', event);
|
|
219
|
+
// Handle field click logic here
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
onCardInteraction(event: any): void {
|
|
223
|
+
console.log('Card interaction:', event);
|
|
224
|
+
// Handle card interaction logic here
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Step 5: Import Types (Optional but Recommended)
|
|
230
|
+
|
|
231
|
+
For better TypeScript support, import the types you need:
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
import {
|
|
235
|
+
AICardConfig, // Main card configuration type
|
|
236
|
+
CardSection, // Section configuration type
|
|
237
|
+
CardField, // Field configuration type
|
|
238
|
+
CardAction, // Action configuration type
|
|
239
|
+
CardType, // Card type enum
|
|
240
|
+
SectionType // Section type union
|
|
241
|
+
} from '@osi/cards-lib';
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Step 6: Verify Installation
|
|
245
|
+
|
|
246
|
+
After completing the steps above, verify everything is working:
|
|
247
|
+
|
|
248
|
+
1. ✅ Check that `node_modules/@osi/cards-lib` exists
|
|
249
|
+
2. ✅ Verify components can be imported without TypeScript errors
|
|
250
|
+
3. ✅ Ensure styles are applied (check browser DevTools)
|
|
251
|
+
4. ✅ Test rendering a simple card in your application
|
|
252
|
+
5. ✅ Check browser console for any errors
|
|
253
|
+
|
|
254
|
+
### Common Import Patterns
|
|
255
|
+
|
|
256
|
+
#### Importing Multiple Components
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import {
|
|
260
|
+
AICardRendererComponent,
|
|
261
|
+
MasonryGridComponent,
|
|
262
|
+
CardSkeletonComponent
|
|
263
|
+
} from '@osi/cards-lib';
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### Importing Services
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import {
|
|
270
|
+
IconService,
|
|
271
|
+
SectionNormalizationService,
|
|
272
|
+
MagneticTiltService
|
|
273
|
+
} from '@osi/cards-lib';
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### Importing Utilities
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
import {
|
|
280
|
+
// Utility functions are available through the main export
|
|
281
|
+
} from '@osi/cards-lib';
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
See [IMPORT_EXAMPLE.md](./IMPORT_EXAMPLE.md) for comprehensive import examples and advanced usage patterns.
|
|
285
|
+
|
|
286
|
+
## Usage
|
|
287
|
+
|
|
288
|
+
### Basic Card Configuration
|
|
289
|
+
|
|
290
|
+
The card component accepts a `cardConfig` input of type `AICardConfig`. Here's a basic example:
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
import { AICardConfig } from '@osi/cards-lib';
|
|
294
|
+
|
|
295
|
+
const card: AICardConfig = {
|
|
296
|
+
cardTitle: 'Company Profile',
|
|
297
|
+
cardSubtitle: 'Detailed company information',
|
|
298
|
+
sections: [
|
|
299
|
+
{
|
|
300
|
+
title: 'Company Info',
|
|
301
|
+
type: 'info',
|
|
302
|
+
fields: [
|
|
303
|
+
{ label: 'Industry', value: 'Technology' },
|
|
304
|
+
{ label: 'Employees', value: '250' },
|
|
305
|
+
{ label: 'Founded', value: '2010' }
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
]
|
|
309
|
+
};
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Using the Card in Your Template
|
|
313
|
+
|
|
314
|
+
```html
|
|
315
|
+
<app-ai-card-renderer [cardConfig]="card"></app-ai-card-renderer>
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Card Component Inputs
|
|
319
|
+
|
|
320
|
+
The `AICardRendererComponent` accepts the following inputs:
|
|
321
|
+
|
|
322
|
+
- `cardConfig: AICardConfig` - **Required**. The card configuration object
|
|
323
|
+
- `tiltEnabled: boolean` - Enable/disable magnetic tilt effect (default: `true`)
|
|
324
|
+
- `loading: boolean` - Show loading skeleton (default: `false`)
|
|
325
|
+
- `streamingStage: StreamingStage` - Current streaming stage for animations
|
|
326
|
+
|
|
327
|
+
### Card Component Outputs (Events)
|
|
328
|
+
|
|
329
|
+
The component emits the following events:
|
|
330
|
+
|
|
331
|
+
- `cardInteraction` - Emitted when the card is interacted with
|
|
332
|
+
- `fieldInteraction` - Emitted when a field is clicked/interacted
|
|
333
|
+
- `agentAction` - Emitted when an agent action is triggered
|
|
334
|
+
- `questionAction` - Emitted when a question action is triggered
|
|
335
|
+
|
|
336
|
+
Example with event handlers:
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
<app-ai-card-renderer
|
|
340
|
+
[cardConfig]="cardConfig"
|
|
341
|
+
(fieldInteraction)="handleFieldClick($event)"
|
|
342
|
+
(cardInteraction)="handleCardClick($event)">
|
|
343
|
+
</app-ai-card-renderer>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Example Card Configurations
|
|
347
|
+
|
|
348
|
+
#### Simple Info Card
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
const infoCard: AICardConfig = {
|
|
352
|
+
cardTitle: 'Contact Information',
|
|
353
|
+
sections: [
|
|
354
|
+
{
|
|
355
|
+
title: 'Details',
|
|
356
|
+
type: 'info',
|
|
357
|
+
fields: [
|
|
358
|
+
{ label: 'Name', value: 'John Doe' },
|
|
359
|
+
{ label: 'Email', value: 'john@example.com' },
|
|
360
|
+
{ label: 'Phone', value: '+1 234 567 8900' }
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
};
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
#### Card with Analytics
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
const analyticsCard: AICardConfig = {
|
|
371
|
+
cardTitle: 'Sales Dashboard',
|
|
372
|
+
sections: [
|
|
373
|
+
{
|
|
374
|
+
title: 'Q4 Performance',
|
|
375
|
+
type: 'analytics',
|
|
376
|
+
fields: [
|
|
377
|
+
{
|
|
378
|
+
label: 'Revenue',
|
|
379
|
+
value: 125000,
|
|
380
|
+
change: 12.5,
|
|
381
|
+
trend: 'up',
|
|
382
|
+
format: 'currency'
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
label: 'Growth',
|
|
386
|
+
value: 8.3,
|
|
387
|
+
change: 2.1,
|
|
388
|
+
trend: 'up',
|
|
389
|
+
format: 'percentage'
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
}
|
|
393
|
+
]
|
|
394
|
+
};
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
#### Card with Multiple Sections
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
const multiSectionCard: AICardConfig = {
|
|
401
|
+
cardTitle: 'Company Overview',
|
|
402
|
+
cardSubtitle: 'Complete company profile',
|
|
403
|
+
sections: [
|
|
404
|
+
{
|
|
405
|
+
title: 'Company Info',
|
|
406
|
+
type: 'overview',
|
|
407
|
+
fields: [
|
|
408
|
+
{ label: 'Industry', value: 'Technology' },
|
|
409
|
+
{ label: 'Employees', value: '250' }
|
|
410
|
+
]
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
title: 'Key Metrics',
|
|
414
|
+
type: 'analytics',
|
|
415
|
+
fields: [
|
|
416
|
+
{ label: 'Revenue', value: 5000000, change: 15, trend: 'up' }
|
|
417
|
+
]
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
title: 'Contact',
|
|
421
|
+
type: 'contact-card',
|
|
422
|
+
fields: [
|
|
423
|
+
{
|
|
424
|
+
name: 'John Doe',
|
|
425
|
+
role: 'CEO',
|
|
426
|
+
email: 'john@company.com',
|
|
427
|
+
phone: '+1 234 567 8900'
|
|
428
|
+
}
|
|
429
|
+
]
|
|
430
|
+
}
|
|
431
|
+
],
|
|
432
|
+
actions: [
|
|
433
|
+
{
|
|
434
|
+
type: 'website',
|
|
435
|
+
label: 'Visit Website',
|
|
436
|
+
url: 'https://company.com',
|
|
437
|
+
variant: 'primary'
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
};
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### All Section Types
|
|
444
|
+
|
|
445
|
+
The library supports 20+ section types:
|
|
446
|
+
|
|
447
|
+
- `info` - Key-value pairs
|
|
448
|
+
- `overview` - Compact overview display
|
|
449
|
+
- `analytics` - Metrics with trends
|
|
450
|
+
- `contact-card` - Contact information cards
|
|
451
|
+
- `network-card` - Network relationship cards
|
|
452
|
+
- `map` - Location display (requires Leaflet for full functionality)
|
|
453
|
+
- `financials` - Financial data
|
|
454
|
+
- `event` - Timeline/event display
|
|
455
|
+
- `list` - List items
|
|
456
|
+
- `chart` - Chart visualization (requires Chart.js for full functionality)
|
|
457
|
+
- `product` - Product information
|
|
458
|
+
- `solutions` - Solutions display
|
|
459
|
+
- `quotation` - Quote/testimonial cards
|
|
460
|
+
- `text-reference` - Text references
|
|
461
|
+
- `brand-colors` - Brand color swatches
|
|
462
|
+
- `fallback` - Fallback for unknown types
|
|
463
|
+
|
|
464
|
+
### Component Events
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
<app-ai-card-renderer
|
|
468
|
+
[cardConfig]="cardConfig"
|
|
469
|
+
(cardInteraction)="onCardInteraction($event)"
|
|
470
|
+
(fieldInteraction)="onFieldInteraction($event)"
|
|
471
|
+
(agentAction)="onAgentAction($event)"
|
|
472
|
+
(questionAction)="onQuestionAction($event)">
|
|
473
|
+
</app-ai-card-renderer>
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Card Actions
|
|
477
|
+
|
|
478
|
+
Cards support multiple action types:
|
|
479
|
+
|
|
480
|
+
- `mail` - Email actions (requires email configuration)
|
|
481
|
+
- `website` - Open URL
|
|
482
|
+
- `agent` - Trigger agent action
|
|
483
|
+
- `question` - Pre-filled question
|
|
484
|
+
|
|
485
|
+
See `USAGE.md` for detailed API documentation.
|
|
486
|
+
|
|
487
|
+
## Features
|
|
488
|
+
|
|
489
|
+
- ✅ 20+ section types
|
|
490
|
+
- ✅ Fully standalone (no app dependencies)
|
|
491
|
+
- ✅ Magnetic tilt effects
|
|
492
|
+
- ✅ Smooth animations
|
|
493
|
+
- ✅ Responsive masonry layout
|
|
494
|
+
- ✅ TypeScript support
|
|
495
|
+
- ✅ Fully typed interfaces
|
|
496
|
+
- ✅ Accessible (ARIA support)
|
|
497
|
+
- ✅ Customizable styling
|
|
498
|
+
|
|
499
|
+
## Building
|
|
500
|
+
|
|
501
|
+
To build the library:
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
ng build osi-cards-lib
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
Output will be in `dist/osi-cards-lib/`.
|
|
508
|
+
|
|
509
|
+
## Distribution
|
|
510
|
+
|
|
511
|
+
### NPM Package
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
cd dist/osi-cards-lib
|
|
515
|
+
npm pack
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### Direct Distribution
|
|
519
|
+
|
|
520
|
+
Share the `dist/osi-cards-lib/` folder directly.
|
|
521
|
+
|
|
522
|
+
### Monorepo
|
|
523
|
+
|
|
524
|
+
Use path references in `package.json`:
|
|
525
|
+
|
|
526
|
+
```json
|
|
527
|
+
{
|
|
528
|
+
"dependencies": {
|
|
529
|
+
"@osi/cards-lib": "file:../osi-cards-lib/dist/osi-cards-lib"
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## Troubleshooting
|
|
535
|
+
|
|
536
|
+
### Module Not Found
|
|
537
|
+
|
|
538
|
+
**Error**: `Cannot find module '@osi/cards-lib'`
|
|
539
|
+
|
|
540
|
+
**Solutions**:
|
|
541
|
+
- Ensure the library is installed: `npm install @osi/cards-lib`
|
|
542
|
+
- If using local path, verify the path in `package.json` is correct
|
|
543
|
+
- Restart your development server after installation
|
|
544
|
+
- Clear `node_modules` and reinstall: `rm -rf node_modules && npm install`
|
|
545
|
+
|
|
546
|
+
### Styles Not Loading
|
|
547
|
+
|
|
548
|
+
**Error**: Components render but styles are not applied
|
|
549
|
+
|
|
550
|
+
**Solutions**:
|
|
551
|
+
- Verify styles are imported in `styles.scss` or `angular.json`
|
|
552
|
+
- Check the import path: `@import '@osi/cards-lib/styles/_styles';`
|
|
553
|
+
- Ensure SCSS is configured in your Angular project
|
|
554
|
+
- Restart the development server after adding styles
|
|
555
|
+
|
|
556
|
+
### Icons Not Showing
|
|
557
|
+
|
|
558
|
+
**Error**: Icons are missing or not displaying
|
|
559
|
+
|
|
560
|
+
**Solutions**:
|
|
561
|
+
- Ensure `lucide-angular` is installed: `npm install lucide-angular@^0.548.0`
|
|
562
|
+
- Verify the version matches the peer dependency requirement
|
|
563
|
+
- Check browser console for icon-related errors
|
|
564
|
+
|
|
565
|
+
### TypeScript Type Errors
|
|
566
|
+
|
|
567
|
+
**Error**: TypeScript cannot find types or interfaces
|
|
568
|
+
|
|
569
|
+
**Solutions**:
|
|
570
|
+
- Restart TypeScript server in your IDE (VS Code: Cmd/Ctrl + Shift + P → "TypeScript: Restart TS Server")
|
|
571
|
+
- Verify the library was built correctly: `ng build osi-cards-lib`
|
|
572
|
+
- Check that `@osi/cards-lib` is accessible in `node_modules`
|
|
573
|
+
- Ensure your Angular version is 20.0.0 or higher
|
|
574
|
+
|
|
575
|
+
### Build Errors
|
|
576
|
+
|
|
577
|
+
**Error**: Angular build fails with dependency errors
|
|
578
|
+
|
|
579
|
+
**Solutions**:
|
|
580
|
+
- Verify all peer dependencies are installed
|
|
581
|
+
- Check Angular version compatibility (requires Angular 20+)
|
|
582
|
+
- Ensure all imports use the correct paths
|
|
583
|
+
- Clear build cache: `rm -rf .angular && ng build`
|
|
584
|
+
|
|
585
|
+
### Optional Dependencies Not Working
|
|
586
|
+
|
|
587
|
+
**Error**: Charts or maps not rendering properly
|
|
588
|
+
|
|
589
|
+
**Solutions**:
|
|
590
|
+
- Install optional dependencies: `npm install chart.js leaflet`
|
|
591
|
+
- Verify they're listed in your `package.json`
|
|
592
|
+
- Check browser console for specific errors
|
|
593
|
+
- Note: Charts and maps will still render without these, but with limited functionality
|
|
594
|
+
|
|
595
|
+
## Verification Checklist
|
|
596
|
+
|
|
597
|
+
After importing the library, verify:
|
|
598
|
+
|
|
599
|
+
- [ ] Library is installed in `node_modules/@osi/cards-lib`
|
|
600
|
+
- [ ] All peer dependencies are installed
|
|
601
|
+
- [ ] Components can be imported without TypeScript errors
|
|
602
|
+
- [ ] Styles are imported and applied correctly
|
|
603
|
+
- [ ] Icons are displaying properly
|
|
604
|
+
- [ ] TypeScript types are available and working
|
|
605
|
+
- [ ] No console errors in browser
|
|
606
|
+
- [ ] Components render correctly in the application
|
|
607
|
+
|
|
608
|
+
## Additional Resources
|
|
609
|
+
|
|
610
|
+
- [IMPORT_EXAMPLE.md](./IMPORT_EXAMPLE.md) - Comprehensive import examples and usage patterns
|
|
611
|
+
- [USAGE.md](./USAGE.md) - Detailed API documentation and advanced usage
|
|
612
|
+
|
|
613
|
+
## Troubleshooting
|
|
614
|
+
|
|
615
|
+
### Module Not Found
|
|
616
|
+
|
|
617
|
+
**Error**: `Cannot find module '@osi/cards-lib'`
|
|
618
|
+
|
|
619
|
+
**Solutions**:
|
|
620
|
+
- Ensure the library is installed: `npm install @osi/cards-lib`
|
|
621
|
+
- If using local path, verify the path in `package.json` is correct
|
|
622
|
+
- Restart your development server after installation
|
|
623
|
+
- Clear `node_modules` and reinstall: `rm -rf node_modules && npm install`
|
|
624
|
+
|
|
625
|
+
### Styles Not Loading
|
|
626
|
+
|
|
627
|
+
**Error**: Components render but styles are not applied
|
|
628
|
+
|
|
629
|
+
**Solutions**:
|
|
630
|
+
- Verify styles are imported in `styles.scss` or `angular.json`
|
|
631
|
+
- Check the import path: `@import '@osi/cards-lib/styles/_styles';`
|
|
632
|
+
- Ensure SCSS is configured in your Angular project
|
|
633
|
+
- Restart the development server after adding styles
|
|
634
|
+
|
|
635
|
+
### Icons Not Showing
|
|
636
|
+
|
|
637
|
+
**Error**: Icons are missing or not displaying
|
|
638
|
+
|
|
639
|
+
**Solutions**:
|
|
640
|
+
- Ensure `lucide-angular` is installed: `npm install lucide-angular@^0.548.0`
|
|
641
|
+
- Verify the version matches the peer dependency requirement
|
|
642
|
+
- Check browser console for icon-related errors
|
|
643
|
+
|
|
644
|
+
### TypeScript Type Errors
|
|
645
|
+
|
|
646
|
+
**Error**: TypeScript cannot find types or interfaces
|
|
647
|
+
|
|
648
|
+
**Solutions**:
|
|
649
|
+
- Restart TypeScript server in your IDE (VS Code: Cmd/Ctrl + Shift + P → "TypeScript: Restart TS Server")
|
|
650
|
+
- Verify the library was built correctly: `ng build osi-cards-lib`
|
|
651
|
+
- Check that `@osi/cards-lib` is accessible in `node_modules`
|
|
652
|
+
- Ensure your Angular version is 20.0.0 or higher
|
|
653
|
+
|
|
654
|
+
### Build Errors
|
|
655
|
+
|
|
656
|
+
**Error**: Angular build fails with dependency errors
|
|
657
|
+
|
|
658
|
+
**Solutions**:
|
|
659
|
+
- Verify all peer dependencies are installed
|
|
660
|
+
- Check Angular version compatibility (requires Angular 20+)
|
|
661
|
+
- Ensure all imports use the correct paths
|
|
662
|
+
- Clear build cache: `rm -rf .angular && ng build`
|
|
663
|
+
|
|
664
|
+
### Optional Dependencies Not Working
|
|
665
|
+
|
|
666
|
+
**Error**: Charts or maps not rendering properly
|
|
667
|
+
|
|
668
|
+
**Solutions**:
|
|
669
|
+
- Install optional dependencies: `npm install chart.js leaflet`
|
|
670
|
+
- Verify they're listed in your `package.json`
|
|
671
|
+
- Check browser console for specific errors
|
|
672
|
+
- Note: Charts and maps will still render without these, but with limited functionality
|
|
673
|
+
|
|
674
|
+
## Migration Guide
|
|
675
|
+
|
|
676
|
+
### Migrating from App to Library
|
|
677
|
+
|
|
678
|
+
If you're migrating from using the app directly to using the library:
|
|
679
|
+
|
|
680
|
+
1. **Install the library**:
|
|
681
|
+
```bash
|
|
682
|
+
npm install @osi/cards-lib
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
2. **Update imports**:
|
|
686
|
+
```typescript
|
|
687
|
+
// Before
|
|
688
|
+
import { AICardRendererComponent } from './shared/components/cards';
|
|
689
|
+
|
|
690
|
+
// After
|
|
691
|
+
import { AICardRendererComponent } from '@osi/cards-lib';
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
3. **Import styles**:
|
|
695
|
+
```scss
|
|
696
|
+
@import '@osi/cards-lib/styles/_styles';
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
4. **Update service usage**:
|
|
700
|
+
- Services are not exported from the library
|
|
701
|
+
- Use the library components directly
|
|
702
|
+
- Implement your own data providers if needed
|
|
703
|
+
|
|
704
|
+
5. **Update state management**:
|
|
705
|
+
- The library doesn't include NgRx store
|
|
706
|
+
- Manage card state in your application
|
|
707
|
+
- Pass card configs as inputs to components
|
|
708
|
+
|
|
709
|
+
### Breaking Changes
|
|
710
|
+
|
|
711
|
+
#### Version 1.0.0
|
|
712
|
+
|
|
713
|
+
- All components are now standalone
|
|
714
|
+
- Services are not exported (use components directly)
|
|
715
|
+
- NgRx store is not included (manage state in your app)
|
|
716
|
+
|
|
717
|
+
## Advanced Usage
|
|
718
|
+
|
|
719
|
+
### Custom Section Types
|
|
720
|
+
|
|
721
|
+
To add custom section types, extend the library components or create your own:
|
|
722
|
+
|
|
723
|
+
```typescript
|
|
724
|
+
import { BaseSectionComponent } from '@osi/cards-lib';
|
|
725
|
+
|
|
726
|
+
@Component({
|
|
727
|
+
selector: 'app-custom-section',
|
|
728
|
+
standalone: true,
|
|
729
|
+
imports: [CommonModule],
|
|
730
|
+
template: `...`
|
|
731
|
+
})
|
|
732
|
+
export class CustomSectionComponent extends BaseSectionComponent {
|
|
733
|
+
// Custom implementation
|
|
734
|
+
}
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
### Theming
|
|
738
|
+
|
|
739
|
+
Override design tokens in your styles:
|
|
740
|
+
|
|
741
|
+
```scss
|
|
742
|
+
:root {
|
|
743
|
+
--color-brand: #your-color;
|
|
744
|
+
--card-background: rgba(your, values, here);
|
|
745
|
+
--card-padding: 1.5rem;
|
|
746
|
+
}
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
### Performance Optimization
|
|
750
|
+
|
|
751
|
+
- Use OnPush change detection (already enabled)
|
|
752
|
+
- Implement virtual scrolling for large lists
|
|
753
|
+
- Lazy load section components if needed
|
|
754
|
+
- Use trackBy functions with *ngFor
|
|
755
|
+
|
|
756
|
+
## API Reference
|
|
757
|
+
|
|
758
|
+
See [IMPORT_EXAMPLE.md](./IMPORT_EXAMPLE.md) for comprehensive import examples and [USAGE.md](./USAGE.md) for detailed API documentation.
|
|
759
|
+
|
|
760
|
+
## License
|
|
761
|
+
|
|
762
|
+
MIT
|
|
763
|
+
|