@truenas/ui-components 0.1.47 → 0.1.48

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
@@ -133,7 +133,8 @@ npm run icons
133
133
  ```
134
134
 
135
135
  This will:
136
- - Scan your templates for `<tn-icon>` elements
136
+ - Scan your templates for `<tn-icon>` and `<tn-icon-button>` elements
137
+ - Detect icons passed to forwarding components (e.g., `<tn-empty icon="inbox">`)
137
138
  - Detect icons marked with `tnIconMarker()` in TypeScript
138
139
  - Generate `src/assets/icons/sprite.svg` with only used icons
139
140
  - Create `src/assets/icons/sprite-config.json` with manifest
@@ -195,6 +196,32 @@ export class MyComponent {
195
196
  }
196
197
  ```
197
198
 
199
+ ### Icon Forwarding Components
200
+
201
+ Some library components accept icon inputs and forward them to an internal `<tn-icon>`. The sprite generator automatically detects icons passed to these components:
202
+
203
+ ```html
204
+ <!-- These icons are automatically included in the sprite -->
205
+ <tn-empty icon="inbox" iconLibrary="mdi" title="No messages"></tn-empty>
206
+ <tn-input prefixIcon="search" prefixIconLibrary="mdi"></tn-input>
207
+ <tn-chip icon="star"></tn-chip>
208
+ ```
209
+
210
+ No `tnIconMarker()` is needed for static icon attributes on forwarding components.
211
+
212
+ The library ships a `forwarding-mappings.json` manifest that tells the scanner which components forward icons. If your app has its own forwarding components, you can create a `forwarding-mappings.json` in your source directory:
213
+
214
+ ```json
215
+ [
216
+ {
217
+ "selector": "app-status-badge",
218
+ "iconSlots": [
219
+ { "iconAttribute": "icon", "libraryAttribute": "iconLibrary", "defaultLibrary": "mdi" }
220
+ ]
221
+ }
222
+ ]
223
+ ```
224
+
198
225
  ### Custom Icons
199
226
 
200
227
  1. **Create a directory for your custom SVG icons:**
@@ -0,0 +1,33 @@
1
+ [
2
+ {
3
+ "selector": "tn-empty",
4
+ "iconSlots": [
5
+ {
6
+ "iconAttribute": "icon",
7
+ "libraryAttribute": "iconLibrary",
8
+ "defaultLibrary": "mdi"
9
+ }
10
+ ]
11
+ },
12
+ {
13
+ "selector": "tn-input",
14
+ "iconSlots": [
15
+ {
16
+ "iconAttribute": "prefixIcon",
17
+ "libraryAttribute": "prefixIconLibrary"
18
+ },
19
+ {
20
+ "iconAttribute": "suffixIcon",
21
+ "libraryAttribute": "suffixIconLibrary"
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "selector": "tn-chip",
27
+ "iconSlots": [
28
+ {
29
+ "iconAttribute": "icon"
30
+ }
31
+ ]
32
+ }
33
+ ]