@molecule/app-icons 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/README.md +329 -0
  2. package/package.json +8 -7
package/README.md ADDED
@@ -0,0 +1,329 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T01:51:02.355Z
7
+ -->
8
+
9
+ # @molecule/app-icons
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ Framework-agnostic icon set interfaces for molecule.dev.
16
+
17
+ Icon set bond packages (e.g. `@molecule/app-icons-molecule`) export an
18
+ `IconSet` object which is bonded via {@link setIconSet} at application
19
+ startup. Application code retrieves icons via {@link getIcon} /
20
+ {@link getIconDataUrl}, both of which call {@link getIconSet} internally.
21
+
22
+ ## Quick Start
23
+
24
+ ```typescript
25
+ import { setIconSet, getIconDataUrl } from '@molecule/app-icons'
26
+ import { iconSet } from '@molecule/app-icons-molecule'
27
+
28
+ setIconSet(iconSet) // once, at app startup — before anything renders an icon
29
+
30
+ // In components, prefer your framework UI's Icon component
31
+ // (e.g. <Icon name="check-circle" /> from the app's UI bundle), which reads
32
+ // the bonded set. For CSS/background/favicon contexts:
33
+ const url = getIconDataUrl('check-circle', '#16a34a')
34
+ ```
35
+
36
+ ## Type
37
+
38
+ `core`
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install @molecule/app-icons @molecule/app-bond @molecule/app-i18n
44
+ ```
45
+
46
+ ## API
47
+
48
+ ### Interfaces
49
+
50
+ #### `CustomIconNames`
51
+
52
+ Augmentable registry of extra icon names beyond {@link ComponentIconName}.
53
+
54
+ An icon set bond (or an app merging custom glyphs into the bonded set) that
55
+ provides names beyond the required contract declares them here so
56
+ `getIcon()` / `<Icon name="…" />` accept them type-safely:
57
+
58
+ ```typescript
59
+ declare module '@molecule/app-icons' {
60
+ interface CustomIconNames {
61
+ 'my-custom-glyph': true
62
+ }
63
+ }
64
+ ```
65
+
66
+ Keys are icon names; values are always `true` (the interface is a name
67
+ registry, never instantiated).
68
+
69
+ ```typescript
70
+ interface CustomIconNames {}
71
+ ```
72
+
73
+ #### `IconData`
74
+
75
+ Complete icon definition — framework-agnostic SVG data.
76
+
77
+ ```typescript
78
+ interface IconData {
79
+ /** SVG path elements. */
80
+ paths: IconPath[]
81
+ /** viewBox attribute. Default: "0 0 20 20" */
82
+ viewBox?: string
83
+ /** fill attribute. Default: "currentColor" */
84
+ fill?: string
85
+ /** stroke attribute (for outlined icons). */
86
+ stroke?: string
87
+ /** strokeWidth for outlined icons. */
88
+ strokeWidth?: number
89
+ /** strokeLinecap for outlined icons. */
90
+ strokeLinecap?: 'round' | 'butt' | 'square'
91
+ /** strokeLinejoin for outlined icons. */
92
+ strokeLinejoin?: 'round' | 'miter' | 'bevel'
93
+ /** Raw inner SVG content for complex icons that can't be represented as paths alone. */
94
+ svg?: string
95
+ }
96
+ ```
97
+
98
+ #### `IconPath`
99
+
100
+ Single SVG path element data.
101
+
102
+ ```typescript
103
+ interface IconPath {
104
+ d: string
105
+ fill?: string
106
+ fillRule?: 'evenodd' | 'nonzero'
107
+ clipRule?: 'evenodd' | 'nonzero'
108
+ opacity?: number
109
+ }
110
+ ```
111
+
112
+ #### `IconSet`
113
+
114
+ A named set of icons.
115
+
116
+ ```typescript
117
+ interface IconSet {
118
+ [name: string]: IconData
119
+ }
120
+ ```
121
+
122
+ ### Types
123
+
124
+ #### `ComponentIconName`
125
+
126
+ Icons required by UI components.
127
+ All icon set providers MUST include these.
128
+
129
+ ```typescript
130
+ type ComponentIconName =
131
+ // Status
132
+ | 'info-circle'
133
+ | 'check-circle'
134
+ | 'exclamation-triangle'
135
+ | 'x-circle'
136
+ // Close/dismiss
137
+ | 'x-mark'
138
+ // Navigation arrows
139
+ | 'arrow-left'
140
+ | 'arrow-right'
141
+ | 'arrow-up'
142
+ | 'arrow-down'
143
+ // Chevrons
144
+ | 'chevron-left'
145
+ | 'chevron-right'
146
+ | 'chevron-up'
147
+ | 'chevron-down'
148
+ | 'chevrons-left'
149
+ | 'chevrons-right'
150
+ | 'chevrons-up-down'
151
+ // Common actions
152
+ | 'search'
153
+ | 'plus'
154
+ | 'minus'
155
+ | 'check'
156
+ | 'pencil'
157
+ | 'trash'
158
+ | 'copy'
159
+ | 'download'
160
+ | 'upload'
161
+ | 'share'
162
+ | 'link'
163
+ | 'link-external'
164
+ | 'filter'
165
+ | 'sort-asc'
166
+ | 'sort-desc'
167
+ | 'sync'
168
+ // UI controls
169
+ | 'ellipsis-horizontal'
170
+ | 'eye'
171
+ | 'eye-closed'
172
+ | 'gear'
173
+ | 'lock'
174
+ | 'unlock'
175
+ | 'home'
176
+ | 'globe'
177
+ | 'menu'
178
+ | 'maximize'
179
+ | 'minimize'
180
+ // User
181
+ | 'user'
182
+ | 'people'
183
+ | 'sign-in'
184
+ | 'sign-out'
185
+ // Theme
186
+ | 'sun'
187
+ | 'moon'
188
+ // Notifications
189
+ | 'bell'
190
+ // Content
191
+ | 'file'
192
+ | 'folder'
193
+ | 'calendar'
194
+ | 'clock'
195
+ | 'history'
196
+ | 'tag'
197
+ | 'star'
198
+ | 'heart'
199
+ | 'code'
200
+ | 'mail'
201
+ // Misc
202
+ | 'bug'
203
+ | 'lightbulb'
204
+ | 'mention'
205
+ | 'microphone'
206
+ | 'paperclip'
207
+ | 'question'
208
+ | 'bookmark'
209
+ | 'pin'
210
+ | 'reply'
211
+ | 'image'
212
+ | 'table'
213
+ | 'thumbsup'
214
+ | 'thumbsdown'
215
+ // Brand
216
+ | 'logo-mark'
217
+ | 'logo-dot'
218
+ | 'github'
219
+ | 'google'
220
+ | 'gitlab'
221
+ | 'twitter'
222
+ ```
223
+
224
+ #### `IconName`
225
+
226
+ Every icon name known to the type system: the {@link ComponentIconName}
227
+ contract every icon set must provide, plus any {@link CustomIconNames}
228
+ augmentations. Use this for `getIcon()` arguments and `icon`/`name` props so
229
+ a typo fails the type-check instead of throwing at render time.
230
+
231
+ ```typescript
232
+ type IconName = ComponentIconName | (keyof CustomIconNames & string)
233
+ ```
234
+
235
+ ### Functions
236
+
237
+ #### `getIcon(name)`
238
+
239
+ Retrieves a single icon by name from the bonded icon set.
240
+
241
+ ```typescript
242
+ function getIcon(name: IconName): IconData
243
+ ```
244
+
245
+ - `name` — The icon name to look up.
246
+
247
+ **Returns:** The icon data (paths, viewBox, stroke/fill attributes).
248
+
249
+ #### `getIconDataUrl(name, color)`
250
+
251
+ Generates a CSS `url()` data URI containing an inline SVG for an icon.
252
+ Useful for `backgroundImage` styling of native elements (e.g. `<select>`
253
+ dropdown arrows) where SVG elements cannot be inserted.
254
+
255
+ ```typescript
256
+ function getIconDataUrl(name: IconName, color?: string): string
257
+ ```
258
+
259
+ - `name` — The icon name to render.
260
+ - `color` — The stroke/fill color for the SVG (defaults to `'#6b7280'`).
261
+
262
+ **Returns:** A CSS `url("data:image/svg+xml,...")` string.
263
+
264
+ #### `getIconSet()`
265
+
266
+ Retrieves the bonded icon set, throwing if none is configured.
267
+
268
+ ```typescript
269
+ function getIconSet(): IconSet
270
+ ```
271
+
272
+ **Returns:** The bonded icon set.
273
+
274
+ #### `hasIconSet()`
275
+
276
+ Checks whether an icon set is currently bonded.
277
+
278
+ ```typescript
279
+ function hasIconSet(): boolean
280
+ ```
281
+
282
+ **Returns:** `true` if an icon set is bonded.
283
+
284
+ #### `setIconSet(iconSet)`
285
+
286
+ Registers an icon set as the active singleton. Called at application
287
+ startup to wire an icon library.
288
+
289
+ ```typescript
290
+ function setIconSet(iconSet: IconSet): void
291
+ ```
292
+
293
+ - `iconSet` — The icon set (a record of icon names to icon data).
294
+
295
+ ## Available Providers
296
+
297
+ | Provider | Package |
298
+ | -------- | ------------------------------ |
299
+ | Molecule | `@molecule/app-icons-molecule` |
300
+
301
+ ## Injection Notes
302
+
303
+ ### Requirements
304
+
305
+ Peer dependencies:
306
+
307
+ - `@molecule/app-bond` ^1.0.1
308
+ - `@molecule/app-i18n` ^1.0.1
309
+
310
+ ### Runtime Dependencies
311
+
312
+ - `@molecule/app-bond`
313
+ - `@molecule/app-i18n`
314
+
315
+ - **Bond the icon set before first render** — `getIcon()`/`getIconDataUrl()` (and
316
+ any `Icon` component built on them) throw until `setIconSet()` has run; wire it
317
+ in the app's bond setup, not lazily inside a component.
318
+ - Icon names are kebab-case (`'arrow-right'`, `'x-mark'`) and type-checked against
319
+ `IconName`. Don't invent names: an unknown name is a runtime error, not a blank.
320
+ App-specific glyphs are added by merging `IconData` into the bonded set and
321
+ augmenting `CustomIconNames` (see that interface) — never by inlining raw SVG
322
+ per call site.
323
+ - Icons are decorative by default — pair them with accessible text
324
+ (`t('key', values, { defaultValue })` labels or `aria-label`), never as the only
325
+ carrier of meaning.
326
+
327
+ ## Translations
328
+
329
+ Translation strings are provided by `@molecule/app-locales-icons`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-icons",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Icon set interfaces for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,8 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "README.md"
21
22
  ],
22
23
  "keywords": [
23
24
  "molecule",
@@ -26,21 +27,21 @@
26
27
  ],
27
28
  "license": "Apache-2.0",
28
29
  "peerDependencies": {
29
- "@molecule/app-bond": "^1.0.0",
30
- "@molecule/app-i18n": "^1.0.0"
30
+ "@molecule/app-bond": "^1.0.1",
31
+ "@molecule/app-i18n": "^1.0.1"
31
32
  },
32
33
  "devDependencies": {
33
- "@molecule/app-bond": "1.0.0",
34
+ "@molecule/app-bond": "1.0.2",
34
35
  "@types/node": "26.1.2",
35
36
  "typescript": "6.0.3",
36
- "vitest": "4.1.10"
37
+ "vitest": "4.1.11"
37
38
  },
38
39
  "repository": {
39
40
  "type": "git",
40
41
  "url": "https://github.com/molecule-dev/molecule.git",
41
42
  "directory": "packages/app/core/icons"
42
43
  },
43
- "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/app/core/icons",
44
+ "homepage": "https://www.molecule.dev/packages/app-icons",
44
45
  "bugs": "https://github.com/molecule-dev/molecule/issues",
45
46
  "publishConfig": {
46
47
  "access": "public"