@aglyn/shared-data-mdi 1.0.0-beta.143 → 1.0.0-beta.144
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 +43 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,13 +1,50 @@
|
|
|
1
1
|
# @aglyn/shared-data-mdi
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Material Design Icons as data. Every icon is a plain object carrying its id, display name, SVG path, aliases and tags, plus a lazily loaded catalog for icon pickers and search. Aglyn uses it wherever an icon is chosen by id and stored as data; it is usable in any project that wants MDI paths without a component library.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> Beta. Published from the Aglyn monorepo under the `beta` dist-tag; APIs can change between beta releases.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Install
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
npm install @aglyn/shared-data-mdi@beta
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
No peer dependencies, and no React.
|
|
12
|
+
|
|
13
|
+
## What's in it
|
|
14
|
+
|
|
15
|
+
- **The generated icon set.** One named export per icon, in camel case with an `mdi` prefix (`mdiAbacus`, `mdiAccessPoint`). Each is an `Icon`: `{ id, name, path, as, tags }`, where `path` is the SVG path data for a 24 by 24 viewBox. The set is generated from Material Design Icons 6.5.95 and ships in the package under `generated/6.5.95/`.
|
|
16
|
+
- **The catalog.** `loadMdiIcons()` dynamically imports the whole set, fills the `MdiIcons` map (`Map<IconId, Icon>`) on first call and caches the promise. Nothing loads the catalog at import time, because it is large; call it only on a surface that needs every icon.
|
|
17
|
+
- **Lookups against the loaded catalog.** `getMdiIconPath(id)` returns the path, or `undefined` when the id is unknown or the catalog is not loaded. `getMdiIconFromId(idOrIds)` returns the icon, substituting `DEFAULT_ICON` on a miss. `getMdiAllIcons()` returns the map.
|
|
18
|
+
- **Helpers.** `convertIdToModuleName('access-point')` gives `'mdiAccessPoint'`. `iconPathPropName('iconId')` gives `'iconPath'`, the companion prop name for storing a resolved path beside an id. `handleIconNotFound` and `DEFAULT_ICON` are the fallback pieces.
|
|
19
|
+
- **Types.** `Icon`, `Icons`, `IconId`, `IconName`, `IconPath`, `IconTag`, `IconTags`, `IconAliases`.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
A named icon, tree-shaken to the one object:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { mdiAbacus } from '@aglyn/shared-data-mdi'
|
|
27
|
+
|
|
28
|
+
mdiAbacus.path // 'M5 5H7V11H5V5M10 5H8V11H10V5…'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The whole catalog, for a picker:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { getMdiIconPath, loadMdiIcons } from '@aglyn/shared-data-mdi'
|
|
35
|
+
|
|
36
|
+
const icons = await loadMdiIcons() // Map<IconId, Icon>
|
|
37
|
+
const path = getMdiIconPath('abacus')
|
|
13
38
|
```
|
|
39
|
+
|
|
40
|
+
The generated files are build output. Do not edit them by hand.
|
|
41
|
+
|
|
42
|
+
## How it fits
|
|
43
|
+
|
|
44
|
+
A `shared` data package. It depends only on `@aglyn/shared-util-tools`. `@aglyn/shared-data-enums` names its icon constants from it, and `@aglyn/shared-ui-jsx` re-exports it beside the `MdiIcon` component that renders a path. Shared packages are generic: they import only other shared packages and hold no plugin's domain.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/shared/data/mdi
|
|
49
|
+
|
|
50
|
+
The icon paths come from the Material Design Icons project (https://github.com/Templarian/MaterialDesign), which publishes them under its own license.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/shared-data-mdi",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.144",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
28
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.144",
|
|
29
29
|
"@swc/helpers": "0.5.23",
|
|
30
30
|
"change-case": "^5.4.4"
|
|
31
31
|
},
|