@aglyn/shared-ui-jsx-forms 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 +68 -4
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,7 +1,71 @@
|
|
|
1
|
-
# shared-ui-jsx-forms
|
|
1
|
+
# @aglyn/shared-ui-jsx-forms
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Material UI component mapper for [data-driven-forms](https://github.com/data-driven-forms/react-forms), plus the extra field types Aglyn's editors need: color and icon pickers, CSS dimension, border and gradient editors, a breakpoint span row, a data table, and theme-scale and preset choosers. Besigner's property panels and the plugins' console forms are rendered with it. Install it if you use data-driven-forms with a current MUI version.
|
|
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
|
+
|
|
9
|
+
npm install @aglyn/shared-ui-jsx-forms@beta
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `react`, `next`, `@mui/material`, `@mui/icons-material` and `@mui/x-date-pickers`. `next` is required because the field components are loaded with `next/dynamic`. `@data-driven-forms/react-form-renderer` is a regular dependency and is re-exported, so you do not import it separately.
|
|
12
|
+
|
|
13
|
+
## What's in it
|
|
14
|
+
|
|
15
|
+
- **Component mappers.** `componentMapper` maps every `FieldComponentType` to its field. Narrower mappers cover common subsets: `simpleComponentMapper` (select, sub-form, switch, text field, textarea), `optionComponentMapper`, `dateTimeComponentMapper` and `pickerComponentMapper`. The individual entries are exported as `FIELD_MAP_*`, and the lazily loaded field components as `Field*` (`FieldTextField`, `FieldSelect`, `FieldColorPicker` and so on).
|
|
16
|
+
- **The mapper components.** Written against current MUI APIs: `Checkbox`, `Radio`, `Select`, `Switch`, `Slider`, `TextField`, `Textarea`, `DatePicker`, `TimePicker`, `DualListSelect`, `SubForm`, `Tabs`, `Wizard`, `PlainText`. The mapper is a port of `@data-driven-forms/mui-component-mapper` (Apache-2.0).
|
|
17
|
+
- **Editor field types.** `CssDimension`, `CssBorder`, `CssGradient`, `BreakpointSpan` and the data table field each persist a single string; their `seed…Draft` / `serialize…Draft` helpers are exported beside them. `ColorPickerComponent` can offer theme palette tokens through `ColorPickerTokensContext`. `IconSelectControl` picks a Material Design icon by id.
|
|
18
|
+
- **Enums.** `FieldComponentType`, `FieldValidatorType`, `FieldDataType`.
|
|
19
|
+
- **Templates and drawers.** `GridFormTemplateComponent` and `ArtifactFormTemplate` are form templates that lay fields out in a MUI grid with a submit button. `CreateArtifactDrawer` is a drawer with a name-and-description create form that accepts `extraFields`.
|
|
20
|
+
- **Re-exports from data-driven-forms.** `FormRenderer`, `FormSpy`, `FieldProvider`, `useFieldApi`, `useFormApi`, `componentTypes`, `validatorTypes`, `dataTypes`, `WizardContext` and the `FieldSchema`, `ComponentMapper`, `Validator` and related types.
|
|
21
|
+
- **Helpers.** `withGridItem`, `validationMessage`, `optionIsEqualToValue`.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
'use client'
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
ArtifactFormTemplate,
|
|
30
|
+
FieldComponentType,
|
|
31
|
+
FormRenderer,
|
|
32
|
+
simpleComponentMapper,
|
|
33
|
+
} from '@aglyn/shared-ui-jsx-forms'
|
|
34
|
+
|
|
35
|
+
const schema = {
|
|
36
|
+
fields: [
|
|
37
|
+
{
|
|
38
|
+
component: FieldComponentType.TEXT_FIELD,
|
|
39
|
+
name: 'displayName',
|
|
40
|
+
label: 'Name',
|
|
41
|
+
isRequired: true,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
component: FieldComponentType.SWITCH,
|
|
45
|
+
name: 'enabled',
|
|
46
|
+
label: 'Enabled',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function Example() {
|
|
52
|
+
return (
|
|
53
|
+
<FormRenderer
|
|
54
|
+
FormTemplate={ArtifactFormTemplate}
|
|
55
|
+
componentMapper={simpleComponentMapper}
|
|
56
|
+
schema={schema}
|
|
57
|
+
onSubmit={(values) => console.log(values)}
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`@aglyn/shared-data-forms` has predefined schemas for common fields (email, password, address) that plug into the same `fields` array.
|
|
64
|
+
|
|
65
|
+
## How it fits
|
|
66
|
+
|
|
67
|
+
A `shared` UI package. It depends on `@aglyn/shared-ui-jsx`, `@aglyn/shared-ui-theme`, `@aglyn/shared-ui-color-picker`, `@aglyn/shared-data-enums`, `@aglyn/shared-data-mdi`, `@aglyn/shared-util-tools` and `@aglyn/shared-util-vendor`. `@aglyn/besigner-ui` and the forms, email and marketing plugins depend on it. Shared packages are generic: they import only other shared packages and hold no plugin's domain.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/shared/ui/jsx-forms
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/shared-ui-jsx-forms",
|
|
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,13 +25,13 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/shared-data-enums": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-ui-color-picker": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-ui-theme": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
34
|
-
"@aglyn/shared-util-vendor": "1.0.0-beta.
|
|
28
|
+
"@aglyn/shared-data-enums": "1.0.0-beta.144",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.144",
|
|
30
|
+
"@aglyn/shared-ui-color-picker": "1.0.0-beta.144",
|
|
31
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.144",
|
|
32
|
+
"@aglyn/shared-ui-theme": "1.0.0-beta.144",
|
|
33
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.144",
|
|
34
|
+
"@aglyn/shared-util-vendor": "1.0.0-beta.144",
|
|
35
35
|
"@data-driven-forms/common": "^4.2.0",
|
|
36
36
|
"@data-driven-forms/react-form-renderer": "^4.2.0",
|
|
37
37
|
"@swc/helpers": "0.5.23",
|