@airdraft/ui-core 0.1.3 → 0.1.5
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/CHANGELOG.md +9 -0
- package/README.md +68 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.5](https://github.com/aevrHQ/airdraft/compare/ui-core@v0.1.3...ui-core@v0.1.5) (2026-05-23)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Documentation
|
|
9
|
+
|
|
10
|
+
* **ui-core:** add README.md for shared UI-layer constants and utilities ([91fb464](https://github.com/aevrHQ/airdraft/commit/91fb4643eb7340ea16b1db9fd06e33ce0866b4b3))
|
|
11
|
+
|
|
12
|
+
### [0.1.4](https://github.com/aevrHQ/airdraft/compare/ui-core@v0.1.3...ui-core@v0.1.4) (2026-05-23)
|
|
13
|
+
|
|
5
14
|
### [0.1.3](https://github.com/aevrHQ/airdraft/compare/ui-core@v0.1.2...ui-core@v0.1.3) (2026-05-23)
|
|
6
15
|
|
|
7
16
|
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @airdraft/ui-core
|
|
2
|
+
|
|
3
|
+
Shared UI-layer constants and utilities for Airdraft. Provides field-type metadata (labels, icons, descriptions), the schema editor mutation helpers, and collection name validators consumed by `@airdraft/react-ui`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @airdraft/ui-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This package is typically a transitive dependency — you don't need to install it directly unless you're building a custom schema editor or type picker.
|
|
12
|
+
|
|
13
|
+
## Exports
|
|
14
|
+
|
|
15
|
+
### Field type metadata
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { FIELD_TYPE_META, VISIBLE_FIELD_TYPES } from '@airdraft/ui-core'
|
|
19
|
+
import type { FieldTypeMeta } from '@airdraft/ui-core'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
| Export | Description |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `FIELD_TYPE_META` | `Record<FieldType, FieldTypeMeta>` — label, description, and Lucide icon name for every field type |
|
|
25
|
+
| `VISIBLE_FIELD_TYPES` | `FieldType[]` — all field types with `hidden !== true`; use this to populate a type picker (excludes the deprecated `image` type) |
|
|
26
|
+
| `FieldTypeMeta` | `{ type, label, description, icon, hidden? }` |
|
|
27
|
+
|
|
28
|
+
**Supported field types** (all included in `FIELD_TYPE_META`):
|
|
29
|
+
|
|
30
|
+
`string` · `text` · `number` · `boolean` · `date` · `datetime` · `list` · `select` · `multiselect` · `rich-text` · `relation` · `relations` · `object` · `url` · `media` · `blocks`
|
|
31
|
+
|
|
32
|
+
`image` is present but marked `hidden: true` — it is excluded from `VISIBLE_FIELD_TYPES` and the schema editor type picker. Use `media` for new fields.
|
|
33
|
+
|
|
34
|
+
### Schema editor mutations
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { applyFieldUpdate, applyFieldDelete, buildDefaultPath } from '@airdraft/ui-core'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
| Export | Description |
|
|
41
|
+
|---|---|
|
|
42
|
+
| `applyFieldUpdate(schema, collection, key, config)` | Returns a new `CmsSchema` with the field upserted |
|
|
43
|
+
| `applyFieldDelete(schema, collection, key)` | Returns a new `CmsSchema` with the field removed |
|
|
44
|
+
| `buildDefaultPath(collection, format, slugSource?)` | Generates a default `path` pattern for a new collection |
|
|
45
|
+
|
|
46
|
+
### Validators
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { validateFieldKey, generateFieldKey, validateCollectionName } from '@airdraft/ui-core'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| Export | Description |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `validateFieldKey(key)` | Returns an error string if the key is invalid (empty, reserved, non-slug), or `null` if valid |
|
|
55
|
+
| `generateFieldKey(label)` | Converts a human label to a valid snake_case field key |
|
|
56
|
+
| `validateCollectionName(name)` | Returns an error string if the name collides with a reserved route, or `null` if valid |
|
|
57
|
+
|
|
58
|
+
### Constants
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { RESERVED_COLLECTION_NAMES } from '@airdraft/ui-core'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`RESERVED_COLLECTION_NAMES` — `Set<string>` of names that cannot be used as collection names (`schema`, `media`, `openapi`, `health`, etc.).
|
|
65
|
+
|
|
66
|
+
## Changelog
|
|
67
|
+
|
|
68
|
+
See [CHANGELOG.md](./CHANGELOG.md).
|
package/package.json
CHANGED