jsonforms-nuxt-ui-renderers 0.1.6 → 0.2.0
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 +54 -4
- package/dist/index.cjs +565 -484
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.js +562 -484
- package/dist/index.js.map +1 -1
- package/dist/styles.css +138 -0
- package/dist/styles.css.map +1 -0
- package/dist/styles.d.cts +2 -0
- package/dist/styles.d.ts +2 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -18,21 +18,71 @@ Nuxt UI should be installed/configured in your Nuxt app (see Nuxt UI docs).
|
|
|
18
18
|
```ts
|
|
19
19
|
import { JsonForms } from '@jsonforms/vue'
|
|
20
20
|
import { nuxtUiRenderers } from 'jsonforms-nuxt-ui-renderers'
|
|
21
|
+
import 'jsonforms-nuxt-ui-renderers/styles.css'
|
|
21
22
|
|
|
22
23
|
// <JsonForms :schema="schema" :uischema="uischema" :data="data" :renderers="nuxtUiRenderers" />
|
|
23
24
|
```
|
|
24
25
|
|
|
26
|
+
Import `styles.css` for default styling of layout panels, labels, and typography. The package uses semantic class names (`jf-*`) and does not depend on Tailwind or any specific CSS framework.
|
|
27
|
+
|
|
25
28
|
### Important
|
|
26
29
|
|
|
27
|
-
- These renderers **resolve Nuxt UI components by name** (e.g. `UInput`, `
|
|
30
|
+
- These renderers **resolve Nuxt UI components by name** (e.g. `UFormField`, `UInput`, `UTextarea`, `USelectMenu`, `USwitch`, `UButton`).
|
|
28
31
|
Your app must register Nuxt UI components globally (Nuxt does this when you use the `@nuxt/ui` module).
|
|
29
32
|
- If you override component names or use a different UI library, these renderers will not work out of the box.
|
|
30
33
|
|
|
31
34
|
## Supported UI schema / schema constructs
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
This package is intentionally small and opinionated: it ships a **single** renderer registry (`nuxtUiRenderers`) covering the following UI schema elements / JSON Schema patterns.
|
|
37
|
+
|
|
38
|
+
### Controls (field types)
|
|
39
|
+
|
|
40
|
+
- **String**: JSON Schema `type: "string"` → `UInput`
|
|
41
|
+
- **Multiline string**: JSONForms “multiline” control (e.g. `uischema.options.multi: true`) → `UTextarea`
|
|
42
|
+
- **Password**: JSON Schema `type: "string"` + `format: "password"` → `UInput type="password"` with show/hide toggle button
|
|
43
|
+
- **Number**: JSON Schema `type: "number"` → `UInput type="number"` (parses to `number`, empty becomes `undefined`)
|
|
44
|
+
- **Integer**: JSON Schema `type: "integer"` → `UInput type="number" step="1"` (parses to `integer`, empty becomes `undefined`)
|
|
45
|
+
- **Boolean**: JSON Schema `type: "boolean"` → `USwitch`
|
|
46
|
+
- **Enum (single-select)**: JSON Schema `enum: [...]` (or `oneOf: [{ const, title? }, ...]`) → `USelectMenu`
|
|
47
|
+
- **Enum (multi-select)**: JSON Schema `type: "array"` with `items` being an enum schema (supports `$ref`’d `items`) → `USelectMenu multiple`
|
|
48
|
+
|
|
49
|
+
### Layouts
|
|
50
|
+
|
|
51
|
+
- **`VerticalLayout`**
|
|
52
|
+
- **`HorizontalLayout`** (responsive: stacks on small screens, wraps into columns on larger screens)
|
|
53
|
+
- **`Group`**
|
|
54
|
+
- **`Label`**
|
|
55
|
+
- **`Categorization` / `Category`**
|
|
56
|
+
|
|
57
|
+
### Complex types
|
|
58
|
+
|
|
59
|
+
- **Arrays (list UI)**: any schema with `type: "array"` renders as a list with **Add / Remove / Up / Down**
|
|
60
|
+
- Respects `minItems` / `maxItems` (disables buttons accordingly)
|
|
61
|
+
- Item label can be customized via `uischema.options.childLabelProp`; otherwise it uses JSONForms’ first primitive property as a best-effort label
|
|
62
|
+
- “Add” uses JSONForms `createDefaultValue(...)` for the item value
|
|
63
|
+
- **Objects**: object controls delegate to a **detail UI schema**
|
|
64
|
+
- If no matching detail UI schema is registered, a default one is generated via JSONForms `Generate.uiSchema(...)`
|
|
65
|
+
- The root object is rendered as a `VerticalLayout`; nested objects default to a `Group` using the control’s label
|
|
66
|
+
|
|
67
|
+
## Theming
|
|
68
|
+
|
|
69
|
+
The package uses semantic class names (`jf-*`) for layout and typography. Override via:
|
|
70
|
+
|
|
71
|
+
1. **CSS variables** – Customize defaults by overriding variables in `:root` (see `styles.css`).
|
|
72
|
+
2. **Theme overrides** – Pass custom classes to `createNuxtUiRenderers`:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { createNuxtUiRenderers } from 'jsonforms-nuxt-ui-renderers'
|
|
76
|
+
|
|
77
|
+
const renderers = createNuxtUiRenderers({
|
|
78
|
+
theme: {
|
|
79
|
+
panel: 'rounded border border-gray-200 p-3', // Tailwind
|
|
80
|
+
layoutVertical: 'flex flex-col gap-3',
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Theme keys: `panel`, `groupNested`, `layoutVertical`, `layoutVerticalWide`, `layoutHorizontal`, `layoutHorizontalItem`, `arrayItemToolbar`, `labelSection`, `labelSectionSpaced`, `textMuted`, `textMutedXs`, `textItemTitle`, `textItemSuffix`, `textLabel`, `flexBetween`, `flexBetweenStart`, `flexActions`.
|
|
36
86
|
|
|
37
87
|
## Contributing
|
|
38
88
|
|