osi-cards-lib 1.5.19 → 1.5.21

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 CHANGED
@@ -5,7 +5,7 @@ A comprehensive Angular library for rendering AI-generated cards with rich secti
5
5
  ## Features
6
6
 
7
7
  - **17+ Section Types** - Info, Analytics, Chart, List, Contact, Network, Map, Event, Product, Solutions, Financials, and more
8
- - **CSS Encapsulation** - Shadow DOM isolation with CSS Layers for easy style overrides
8
+ - **Complete CSS Encapsulation** - Shadow DOM isolation with **all styles and animations** self-contained within each card. Cards look identical in demo and any integration without external style dependencies.
9
9
  - **Streaming Support** - Progressive card rendering with LLM-style streaming simulation
10
10
  - **Theme System** - Built-in themes (day/night) with full customization via CSS custom properties
11
11
  - **Plugin Architecture** - Extend with custom section types
@@ -13,6 +13,25 @@ A comprehensive Angular library for rendering AI-generated cards with rich secti
13
13
  - **Performance** - OnPush change detection, virtual scrolling, and optimized rendering
14
14
  - **Zero-gap layout utility** - `packWithZeroGapsGuarantee` helper for maximum grid density
15
15
 
16
+ ## Complete Style & Animation Encapsulation
17
+
18
+ **🎯 Cards are fully self-contained!** Each card component uses Shadow DOM encapsulation with **all styles and animations** included within the Shadow DOM boundary. This means:
19
+
20
+ - ✅ **No external style dependencies** - Cards work identically in any application
21
+ - ✅ **All animations included** - Streaming, hover, transitions, and section animations all work out of the box
22
+ - ✅ **Identical appearance everywhere** - Cards look exactly the same in the demo app and any integration
23
+ - ✅ **Complete isolation** - Host app styles cannot affect cards, and card styles cannot leak out
24
+
25
+ The Shadow DOM bundle includes:
26
+ - All core styles (mixins, utilities, surface layers)
27
+ - All animations (keyframes, utility classes, streaming effects)
28
+ - All component styles (masonry grid, section renderer, card actions, etc.)
29
+ - All section styles (all 17+ section types with their animations)
30
+ - Theme support (day/night modes)
31
+ - Accessibility features (reduced motion, high contrast, forced colors)
32
+
33
+ **Result**: When you install `osi-cards-lib` from npm, cards render with the exact same appearance and animations as in the demo app, regardless of your host application's styles.
34
+
16
35
  ## Installation
17
36
 
18
37
  ```bash
@@ -53,12 +72,125 @@ export const appConfig: ApplicationConfig = {
53
72
 
54
73
  ### Step 2: Import Styles
55
74
 
75
+ **🎯 RECOMMENDED: Automatic Setup via angular.json**
76
+
77
+ The most reliable way to include library styles is to add them directly to `angular.json`. This ensures styles are always loaded correctly, regardless of SASS/SCSS import resolution issues.
78
+
79
+ ### Quick Setup Script
80
+
81
+ We provide an automated setup script that configures `angular.json` for you:
82
+
83
+ ```bash
84
+ npx osi-cards-lib setup:styles
85
+ ```
86
+
87
+ Or manually run the script from the library:
88
+
89
+ ```bash
90
+ node node_modules/osi-cards-lib/scripts/setup-angular-styles.js
91
+ ```
92
+
93
+ This script will:
94
+ - ✅ Add library styles to your `angular.json` styles array
95
+ - ✅ Configure `stylePreprocessorOptions` with correct `includePaths`
96
+ - ✅ Set up SASS deprecation silence
97
+ - ✅ Work with all Angular projects in your workspace
98
+
99
+ ### Manual Setup (Alternative)
100
+
101
+ If you prefer to configure manually, choose one of the following options:
102
+
103
+ #### Option A: Scoped Styles (Recommended for Integration)
104
+
105
+ Use this when integrating into an existing application to prevent style conflicts. Styles are scoped to `.osi-cards-container`.
106
+
107
+ **Method 1: Import in your styles file (Recommended)**
108
+
109
+ In your `src/styles.scss` or `src/styles.sass`:
110
+
111
+ ```scss
112
+ // Import at the TOP of your styles file (before other styles)
113
+ @import 'osi-cards-lib/styles/_styles-scoped';
114
+
115
+ // If that doesn't work, try with tilde prefix:
116
+ @import '~osi-cards-lib/styles/_styles-scoped';
117
+
118
+ // Or with explicit .scss extension:
119
+ @import 'osi-cards-lib/styles/_styles-scoped.scss';
120
+ ```
121
+
122
+ **Important**: Place the import at the **top** of your styles file, not at the bottom, to ensure proper CSS cascade.
123
+
124
+ **Method 2: Add to angular.json (RECOMMENDED - Most Reliable)**
125
+
126
+ This is the **most reliable method**, especially for SASS files. The styles are automatically included in every build:
127
+
128
+ ```json
129
+ {
130
+ "projects": {
131
+ "your-app": {
132
+ "architect": {
133
+ "build": {
134
+ "options": {
135
+ "styles": [
136
+ "src/styles.sass", // Your main styles file
137
+ "node_modules/osi-cards-lib/styles/_styles-scoped.scss" // Library styles
138
+ ],
139
+ "stylePreprocessorOptions": {
140
+ "includePaths": [
141
+ "node_modules/osi-cards-lib/styles"
142
+ ],
143
+ "sass": {
144
+ "silenceDeprecations": ["import"]
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ **Note**:
156
+ - The `includePaths` in `stylePreprocessorOptions` helps Angular resolve relative imports within the library's SCSS files.
157
+ - **This is especially important when using SASS files** (`.sass` extension) as they may have different import resolution behavior.
158
+ - Place library styles **after** your main styles file in the array to ensure proper cascade.
159
+
160
+ **Important**:
161
+ - ⚠️ **Case sensitive**: Use `osi-cards-lib` (lowercase), NOT `osi-cards-Lib`
162
+ - ⚠️ **REQUIRED**: You must wrap your components in a container with the `osi-cards-container` class and `data-theme` attribute:
163
+
164
+ ```html
165
+ <!-- Static theme -->
166
+ <div class="osi-cards-container" data-theme="day">
167
+ <app-ai-card-renderer [cardConfig]="card"></app-ai-card-renderer>
168
+ </div>
169
+
170
+ <!-- Dynamic theme (Angular) -->
171
+ <div class="osi-cards-container" [attr.data-theme]="theme" *ngIf="cardConfig">
172
+ <app-ai-card-renderer [cardConfig]="cardConfig"></app-ai-card-renderer>
173
+ </div>
174
+ ```
175
+
176
+ **The `data-theme` attribute is REQUIRED** - without it, styles will not apply correctly. Use `"day"` for light theme or `"night"` for dark theme.
177
+
178
+ #### Option B: Global Styles (For Standalone Apps)
179
+
180
+ Use this for standalone applications or when you want styles applied globally.
181
+
56
182
  In your `src/styles.scss`:
57
183
 
58
184
  ```scss
185
+ // Try this first
59
186
  @import 'osi-cards-lib/styles/_styles';
187
+
188
+ // If that doesn't work, try with tilde:
189
+ @import '~osi-cards-lib/styles/_styles';
60
190
  ```
61
191
 
192
+ **Note**: This applies styles to `:root`, so no container wrapper is needed, but styles may conflict with your existing application styles.
193
+
62
194
  ### Step 3: Use the Component
63
195
 
64
196
  ---
@@ -104,7 +236,20 @@ export class StaticCardComponent {
104
236
  }
105
237
  ```
106
238
 
107
- **HTML:**
239
+ **HTML (with scoped styles):**
240
+
241
+ ```html
242
+ <div class="osi-cards-container" [attr.data-theme]="cardTheme">
243
+ <app-ai-card-renderer
244
+ [cardConfig]="card"
245
+ [streamingStage]="'complete'"
246
+ [showLoadingByDefault]="false"
247
+ (cardInteraction)="onCardAction($event)">
248
+ </app-ai-card-renderer>
249
+ </div>
250
+ ```
251
+
252
+ **HTML (with global styles or using OsiCardsContainerComponent):**
108
253
 
109
254
  ```html
110
255
  <osi-cards-container [theme]="cardTheme">
@@ -209,7 +354,28 @@ export class StreamingCardComponent {
209
354
  }
210
355
  ```
211
356
 
212
- **HTML:**
357
+ **HTML (with scoped styles):**
358
+
359
+ ```html
360
+ <button (click)="generateCard()" [disabled]="isStreaming">
361
+ {{ isStreaming ? 'Generating...' : 'Generate Card' }}
362
+ </button>
363
+
364
+ <div class="osi-cards-container" [attr.data-theme]="cardTheme">
365
+ <app-ai-card-renderer
366
+ [cardConfig]="card"
367
+ [isStreaming]="isStreaming"
368
+ [streamingStage]="streamingStage"
369
+ [streamingProgress]="streamingProgress"
370
+ [showLoadingByDefault]="true"
371
+ [loadingMessages]="loadingMessages"
372
+ [loadingTitle]="'AI Analysis'"
373
+ (cardInteraction)="onCardAction($event)">
374
+ </app-ai-card-renderer>
375
+ </div>
376
+ ```
377
+
378
+ **HTML (with global styles or using OsiCardsContainerComponent):**
213
379
 
214
380
  ```html
215
381
  <button (click)="generateCard()" [disabled]="isStreaming">
@@ -820,14 +986,155 @@ providers: [
820
986
  ]
821
987
  ```
822
988
 
823
- ### Styles not loading
989
+ ### Styles not loading / Library looks unstyled
990
+
991
+ **If using scoped styles (`_styles-scoped`):**
992
+
993
+ **CRITICAL**: If styles are completely missing (card renders but has no styling), the SASS import is likely not resolving. Use one of these solutions:
994
+
995
+ **Solution 1: Add to angular.json (RECOMMENDED for SASS files)**
996
+
997
+ This is the most reliable method:
998
+
999
+ ```json
1000
+ {
1001
+ "projects": {
1002
+ "your-app": {
1003
+ "architect": {
1004
+ "build": {
1005
+ "options": {
1006
+ "styles": [
1007
+ "src/styles.sass",
1008
+ "node_modules/osi-cards-lib/styles/_styles-scoped.scss"
1009
+ ],
1010
+ "stylePreprocessorOptions": {
1011
+ "includePaths": [
1012
+ "node_modules/osi-cards-lib/styles"
1013
+ ],
1014
+ "sass": {
1015
+ "silenceDeprecations": ["import"]
1016
+ }
1017
+ }
1018
+ }
1019
+ }
1020
+ }
1021
+ }
1022
+ }
1023
+ }
1024
+ ```
824
1025
 
825
- Import styles in your `styles.scss`:
1026
+ Then **remove** the `@import` from your `styles.sass` file.
1027
+
1028
+ **Solution 2: Fix the SASS import**
1029
+
1030
+ If you want to keep the import in your styles file:
1031
+
1032
+ 1. **Use tilde prefix**:
1033
+ ```sass
1034
+ @import '~osi-cards-lib/styles/_styles-scoped';
1035
+ ```
1036
+
1037
+ 2. **Or use full path**:
1038
+ ```sass
1039
+ @import 'node_modules/osi-cards-lib/styles/_styles-scoped';
1040
+ ```
1041
+
1042
+ 3. **And add to angular.json**:
1043
+ ```json
1044
+ "stylePreprocessorOptions": {
1045
+ "includePaths": ["node_modules"],
1046
+ "sass": {
1047
+ "silenceDeprecations": ["import"]
1048
+ }
1049
+ }
1050
+ ```
1051
+
1052
+ **Solution 3: Verify import path** - Use lowercase `osi-cards-lib` (not `osi-cards-Lib`):
1053
+ ```scss
1054
+ @import 'osi-cards-lib/styles/_styles-scoped';
1055
+ ```
1056
+
1057
+ 2. **Try alternative import methods** if the above doesn't work:
1058
+
1059
+ **Option A: With tilde prefix** (for older Angular versions):
1060
+ ```scss
1061
+ @import '~osi-cards-lib/styles/_styles-scoped';
1062
+ ```
1063
+
1064
+ **Option B: With explicit extension**:
1065
+ ```scss
1066
+ @import 'osi-cards-lib/styles/_styles-scoped.scss';
1067
+ ```
1068
+
1069
+ **Option C: Add to angular.json** (if SCSS import fails):
1070
+ ```json
1071
+ {
1072
+ "projects": {
1073
+ "your-app": {
1074
+ "architect": {
1075
+ "build": {
1076
+ "options": {
1077
+ "styles": [
1078
+ "node_modules/osi-cards-lib/styles/_styles-scoped.scss",
1079
+ "src/styles.scss"
1080
+ ],
1081
+ "stylePreprocessorOptions": {
1082
+ "includePaths": [
1083
+ "node_modules/osi-cards-lib/styles"
1084
+ ],
1085
+ "sass": {
1086
+ "silenceDeprecations": ["import"]
1087
+ }
1088
+ }
1089
+ }
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+ }
1095
+ ```
1096
+ Then remove the `@import` from your `styles.scss`.
1097
+
1098
+ 3. **Wrap components in container** - You MUST wrap your components:
1099
+ ```html
1100
+ <div class="osi-cards-container" data-theme="day">
1101
+ <app-ai-card-renderer [cardConfig]="card"></app-ai-card-renderer>
1102
+ </div>
1103
+ ```
1104
+
1105
+ 4. **Set theme attribute** - Add `data-theme="day"` or `data-theme="night"`:
1106
+ ```html
1107
+ <div class="osi-cards-container" data-theme="day">
1108
+ ```
1109
+
1110
+ 5. **Verify package installation**:
1111
+ ```bash
1112
+ npm list osi-cards-lib
1113
+ ```
1114
+ Should show version `1.5.19` or higher.
1115
+
1116
+ 6. **Check browser console** - Look for 404 errors on style files. If you see errors, the import path is incorrect.
1117
+
1118
+ 7. **Rebuild your app** after adding the import:
1119
+ ```bash
1120
+ ng build
1121
+ # or
1122
+ npm start
1123
+ ```
1124
+
1125
+ **If using global styles (`_styles`):**
826
1126
 
1127
+ Import styles in your `styles.scss`:
827
1128
  ```scss
828
1129
  @import 'osi-cards-lib/styles/_styles';
829
1130
  ```
830
1131
 
1132
+ **Common Issues:**
1133
+ - ❌ **Wrong import path**: `@import 'osi-cards-Lib/styles/_styles-scoped'` (wrong casing)
1134
+ - ❌ **Missing container**: Components not wrapped in `.osi-cards-container`
1135
+ - ❌ **Missing theme**: No `data-theme` attribute on container
1136
+ - ❌ **SCSS not compiled**: Check that your build process compiles SCSS files
1137
+
831
1138
  ### Icons not showing
832
1139
 
833
1140
  Ensure `lucide-angular` is installed:
@@ -836,6 +1143,20 @@ Ensure `lucide-angular` is installed:
836
1143
  npm install lucide-angular@^0.548.0
837
1144
  ```
838
1145
 
1146
+ ### CSS Variables not working
1147
+
1148
+ If CSS variables (like `--color-brand`) aren't working:
1149
+
1150
+ 1. **For scoped styles**: Ensure you're using `.osi-cards-container` wrapper
1151
+ 2. **Check theme**: Verify `data-theme` attribute is set correctly
1152
+ 3. **Override variables**: You can override variables in your own styles:
1153
+ ```scss
1154
+ .osi-cards-container {
1155
+ --color-brand: #ff7900;
1156
+ --background: #ffffff;
1157
+ }
1158
+ ```
1159
+
839
1160
  ---
840
1161
 
841
1162
  ## Documentation