@ajsf/material 22.2.1 → 22.3.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 +34 -44
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,67 +1,57 @@
|
|
|
1
1
|
# @ajsf/material
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Angular Material framework for [AJSF](https://github.com/hamzahamidi/ajsf#readme), which builds Angular forms from JSON Schema.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
npm install @ajsf/material@latest
|
|
7
|
-
```
|
|
5
|
+
## Getting started
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
`@ajsf/material` declares `@angular/material` and `@angular/cdk` as peer dependencies and needs a Material theme. `ng add @angular/material` installs both and writes a theme:
|
|
10
8
|
|
|
11
9
|
```shell
|
|
12
|
-
|
|
10
|
+
ng add @angular/material
|
|
11
|
+
npm install @ajsf/material
|
|
13
12
|
```
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```javascript
|
|
18
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
19
|
-
import { NgModule } from '@angular/core';
|
|
14
|
+
Import `MaterialDesignFrameworkModule` in the standalone component that renders the form. Nothing goes in `app.config.ts`, and no animations provider is needed:
|
|
20
15
|
|
|
16
|
+
```typescript
|
|
17
|
+
import { Component } from '@angular/core';
|
|
21
18
|
import { MaterialDesignFrameworkModule } from '@ajsf/material';
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
imports: [
|
|
28
|
-
MaterialDesignFrameworkModule
|
|
29
|
-
],
|
|
30
|
-
providers: [],
|
|
31
|
-
bootstrap: [ AppComponent ]
|
|
20
|
+
@Component({
|
|
21
|
+
selector: 'app-root',
|
|
22
|
+
imports: [MaterialDesignFrameworkModule],
|
|
23
|
+
templateUrl: './app.html',
|
|
32
24
|
})
|
|
33
|
-
export class
|
|
25
|
+
export class App {
|
|
26
|
+
schema = {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
name: { type: 'string', title: 'Name' },
|
|
30
|
+
plan: { type: 'string', title: 'Plan', enum: ['free', 'pro', 'team'] },
|
|
31
|
+
},
|
|
32
|
+
required: ['name'],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
onSubmit(data: any) {
|
|
36
|
+
console.log(data);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
34
39
|
```
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
In an `NgModule` app, add `MaterialDesignFrameworkModule` to the module's `imports` instead.
|
|
42
|
+
|
|
43
|
+
Then render the form in the component's template:
|
|
37
44
|
|
|
38
45
|
```html
|
|
39
46
|
<json-schema-form
|
|
40
|
-
|
|
41
|
-
[schema]="yourJsonSchema"
|
|
47
|
+
[schema]="schema"
|
|
42
48
|
framework="material-design"
|
|
43
|
-
(onSubmit)="
|
|
49
|
+
(onSubmit)="onSubmit($event)">
|
|
44
50
|
</json-schema-form>
|
|
45
51
|
```
|
|
46
52
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`framework` is for the template you want to use, the default value is `no-framwork`. The possible values are:
|
|
50
|
-
|
|
51
|
-
* `material-design` for Material Design.
|
|
52
|
-
* `bootstrap-3` for Bootstrap 3.
|
|
53
|
-
* `bootstrap-4` for 'Bootstrap 4.
|
|
54
|
-
* `no-framework` for (plain HTML).
|
|
55
|
-
|
|
56
|
-
## Code scaffolding
|
|
57
|
-
|
|
58
|
-
Run `ng generate component component-name --project @ajsf/material` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project @ajsf/material`.
|
|
59
|
-
> Note: Don't forget to add `--project @ajsf/material` or else it will be added to the default project in your `angular.json` file.
|
|
60
|
-
|
|
61
|
-
## Build
|
|
62
|
-
|
|
63
|
-
Run `ng build @ajsf/material` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
53
|
+
`framework="material-design"` selects this package's widgets. The other values are `primeng`, `bootstrap-3`, `bootstrap-4`, `bootstrap-5` and `no-framework`, the default.
|
|
64
54
|
|
|
65
|
-
|
|
55
|
+
This package takes the initial bundle of a new app to 1.40 MB, above the 1 MB `maximumError` budget `ng new` writes into `angular.json`, so raise the `initial` budget of the `production` configuration, for example to `"maximumWarning": "2MB"` and `"maximumError": "2.5MB"`.
|
|
66
56
|
|
|
67
|
-
|
|
57
|
+
The [AJSF README](https://github.com/hamzahamidi/ajsf#readme) covers the other inputs and outputs, layouts, custom widgets and validation messages.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ajsf/material",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.3.0",
|
|
4
4
|
"description": "Angular JSON Schema Form builder using Angular Material UI",
|
|
5
5
|
"author": "https://github.com/hamzahamidi/ajsf/graphs/contributors",
|
|
6
6
|
"keywords": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"funding": "https://github.com/sponsors/hamzahamidi",
|
|
30
30
|
"private": false,
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ajsf/core": "^22.
|
|
32
|
+
"@ajsf/core": "^22.3.0",
|
|
33
33
|
"tslib": "^2.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|