@ng-formworks/bootstrap4 15.2.7
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 +233 -0
- package/assets/cssframework/assets.json +8 -0
- package/assets/cssframework/assets_cdn.json +11 -0
- package/karma.conf.js +46 -0
- package/ng-package.json +13 -0
- package/package.json +54 -0
- package/src/lib/bootstrap4-cssframework.scss +37 -0
- package/src/lib/bootstrap4-cssframework.ts +105 -0
- package/src/lib/bootstrap4-framework.component.scss +28 -0
- package/src/lib/bootstrap4-framework.component.spec.ts +39 -0
- package/src/lib/bootstrap4-framework.component.ts +66 -0
- package/src/lib/bootstrap4-framework.module.ts +37 -0
- package/src/lib/bootstrap4.framework.ts +17 -0
- package/src/public_api.ts +8 -0
- package/src/test.ts +17 -0
- package/tsconfig.lib.json +26 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +17 -0
- package/tslint.json +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# @ng-formworks/bootstrap4
|
|
2
|
+
This module is a dependency of the [ng-formworks project][npm_core_ver] and is meant to work as a framework installation module for using Bootstrap 4 in the forms.
|
|
3
|
+
|
|
4
|
+
## Getting started
|
|
5
|
+
|
|
6
|
+
If you are unfamiliar with with the ng-formworks project, it is highly recommended to
|
|
7
|
+
first have a look at the [@ng-formworks pages][npm_core_ver] for examples, demos, options and documentation.
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm install @ng-formworks/core@latest @ng-formworks/cssframework@latest @ng-formworks/bootstrap4@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
With YARN, run the following:
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
yarn add @ng-formworks/core@latest @ng-formworks/cssframework@latest @ng-formworks/bootstrap4@latest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Then import `Bootstrap4FrameworkModule` in your main application module if you want to use `bootstrap4` UI, like this:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
23
|
+
import { NgModule } from '@angular/core';
|
|
24
|
+
|
|
25
|
+
import { Bootstrap4FrameworkModule } from '@ng-formworks/bootstrap4';
|
|
26
|
+
|
|
27
|
+
import { AppComponent } from './app.component';
|
|
28
|
+
|
|
29
|
+
@NgModule({
|
|
30
|
+
declarations: [ AppComponent ],
|
|
31
|
+
imports: [
|
|
32
|
+
Bootstrap4FrameworkModule
|
|
33
|
+
],
|
|
34
|
+
providers: [],
|
|
35
|
+
bootstrap: [ AppComponent ]
|
|
36
|
+
})
|
|
37
|
+
export class AppModule { }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For basic use, after loading JsonSchemaFormModule as described above, to display a form in your Angular component, simply add the following to your component's template:
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<json-schema-form
|
|
44
|
+
loadExternalAssets="true"
|
|
45
|
+
[schema]="yourJsonSchema"
|
|
46
|
+
framework="bootstrap-4"
|
|
47
|
+
[theme]="yourTheme"
|
|
48
|
+
(onSubmit)="yourOnSubmitFn($event)">
|
|
49
|
+
</json-schema-form>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Where `schema` is a valid JSON schema object, and `onSubmit` calls a function to process the submitted JSON form data. If you don't already have your own schemas, you can find a bunch of samples to test with in the `demo/assets/example-schemas` folder, as described above.
|
|
53
|
+
|
|
54
|
+
`framework` is for the template you want to use, the default value is `no-framwork`. The possible values are:
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
* `material-design` for Material Design (if installed).
|
|
58
|
+
* `bootstrap-3` for Bootstrap 3 (if installed).
|
|
59
|
+
* `bootstrap-4` for Bootstrap 4
|
|
60
|
+
* `bootstrap-5` for Bootstrap 5.(if installed).
|
|
61
|
+
* `daisyui` for DaisyUi (if installed).
|
|
62
|
+
* `no-framework` for (plain HTML).
|
|
63
|
+
|
|
64
|
+
`theme` is for the framework theme you want to use.
|
|
65
|
+
The possible values for this framework are:
|
|
66
|
+
|
|
67
|
+
* `bootstrap4_default` for the default theme.
|
|
68
|
+
|
|
69
|
+
the list of available themes can also be gotten using the
|
|
70
|
+
FrameworkLibraryService(found in '@ng-formworks/core'):
|
|
71
|
+
```typescript
|
|
72
|
+
getFrameworkThemes()
|
|
73
|
+
```
|
|
74
|
+
method
|
|
75
|
+
|
|
76
|
+
## Custom theming
|
|
77
|
+
|
|
78
|
+
Custom theming can be achieved in two ways:
|
|
79
|
+
|
|
80
|
+
* the simplest is to overwrite the default theme(or any other themes) with css rules:
|
|
81
|
+
css changes can be made using the `data-bs-theme` attribute selector
|
|
82
|
+
so for example to change the .btn class of the default theme, you would
|
|
83
|
+
include the following rule in your application's styles
|
|
84
|
+
|
|
85
|
+
```css
|
|
86
|
+
[data-bs-theme="bootstrap4_default"] .btn {
|
|
87
|
+
border-radius: 1rem
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
* the other method is to add a new theme:
|
|
92
|
+
the first step will be to create the entire theme (see the specific frameworks underlying documentation for how this can be done) and have it use the `data-bs-theme` attribute selector for example:
|
|
93
|
+
|
|
94
|
+
```css
|
|
95
|
+
[data-bs-theme="bootstrap4_custom"] {
|
|
96
|
+
background-color: green;
|
|
97
|
+
font: 15px Arial, sans-serif;
|
|
98
|
+
.
|
|
99
|
+
.
|
|
100
|
+
.
|
|
101
|
+
}
|
|
102
|
+
[data-bs-theme="bootstrap4_custom"] .btn {
|
|
103
|
+
border-color: coral;
|
|
104
|
+
.
|
|
105
|
+
.
|
|
106
|
+
.
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
after making the css available, the theme will need to be registered using the
|
|
111
|
+
FrameworkLibraryService(found in '@ng-formworks/core'):
|
|
112
|
+
for example
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
constructor(
|
|
116
|
+
.
|
|
117
|
+
private frameworkLibrary: FrameworkLibraryService,
|
|
118
|
+
.
|
|
119
|
+
.
|
|
120
|
+
) {
|
|
121
|
+
|
|
122
|
+
frameworkLibrary.registerTheme({name:'bootstrap4_custom',text:'Bootstrap4 custom theme'})
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Framework assets
|
|
129
|
+
|
|
130
|
+
Framework assets are typically third party assets (mainly js and css files) that are loaded at runtime for the particular framework's styling and effects to activate.
|
|
131
|
+
By default these assets are loaded from built in cdn urls. These assets can also be self hosted or loaded from different urls if need be.
|
|
132
|
+
To use custom urls the following steps must be followed:
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
* create a file called assets.json somewhere in your app src folder
|
|
136
|
+
* edit the assets.json file so that it contains both 'stylesheets' and 'scripts' properties-ex:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
{
|
|
140
|
+
|
|
141
|
+
"stylesheets": [
|
|
142
|
+
"http://some.domain/css/style1.css",
|
|
143
|
+
"http://some.domain/css/style2.css",
|
|
144
|
+
"localstyle.css",
|
|
145
|
+
...
|
|
146
|
+
],
|
|
147
|
+
"scripts": [
|
|
148
|
+
"http://some.domain/css/script1.js",
|
|
149
|
+
"localscript.js",
|
|
150
|
+
...
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
* adapt your apps angular.json assets config accordingly, for example:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
"projects": {
|
|
160
|
+
"<your project name>": {
|
|
161
|
+
...
|
|
162
|
+
"architect": {
|
|
163
|
+
"build": {
|
|
164
|
+
"builder": "@angular-devkit/build-angular:browser",
|
|
165
|
+
"options": {
|
|
166
|
+
...
|
|
167
|
+
"assets": [
|
|
168
|
+
...
|
|
169
|
+
{
|
|
170
|
+
"glob": "assets.json",
|
|
171
|
+
"input": "src",
|
|
172
|
+
"output": "/assets/bootstrap-4"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"glob": "localstyle.css",
|
|
176
|
+
"input": "./some/path/to/framework/cssfolder/",
|
|
177
|
+
"output": "/assets/bootstrap-4/cssframework"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"glob": "localscript.js",
|
|
181
|
+
"input": "./some/path/to/framework/jsfolder/",
|
|
182
|
+
"output": "/assets/bootstrap-4/cssframework"
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
...
|
|
186
|
+
```
|
|
187
|
+
Note that relative asset urls will be assumed to reside under "/assets/bootstrap-4/cssframework" and the assets.json file must output to "/assets/bootstrap-4"
|
|
188
|
+
|
|
189
|
+
for convenince a default assets.json file is included for including the framework assets
|
|
190
|
+
from the node_modules folder, this assumes that the third party libraries were installed locally with npm and that they will reside in the "/assets/bootstrap-4/cssframework" deployment folder. In this case, the following config can be used and adapted similar to above:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
...
|
|
194
|
+
"assets": [
|
|
195
|
+
...
|
|
196
|
+
{
|
|
197
|
+
"glob": "**/*",
|
|
198
|
+
"input": "./node_modules/@ng-formworks/bootstrap4/assets",
|
|
199
|
+
"output": "/assets/bootstrap-4"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"glob": "jquery.slim.min.js",
|
|
203
|
+
"input": "./node_modules/jquery/dist/",
|
|
204
|
+
"output": "/assets/bootstrap-4/cssframework"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"glob": "bootstrap.bundle.min.js",
|
|
208
|
+
"input": "./node_modules/bootstrap/dist/js/",
|
|
209
|
+
"output": "/assets/bootstrap-4/cssframework"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"glob": "bootstrap.min.css",
|
|
213
|
+
"input": "./node_modules/bootstrap/dist/css/",
|
|
214
|
+
"output": "/assets/bootstrap-4/cssframework"
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
## Code scaffolding
|
|
221
|
+
|
|
222
|
+
Run `ng generate component component-name --project @ng-formworks/bootstrap4` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project @ng-formworks/bootstrap4`.
|
|
223
|
+
> Note: Don't forget to add `--project @ng-formworks/bootstrap4` or else it will be added to the default project in your `angular.json` file.
|
|
224
|
+
|
|
225
|
+
## Build
|
|
226
|
+
|
|
227
|
+
Run `ng build @ng-formworks/bootstrap4` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
228
|
+
|
|
229
|
+
## Running unit tests
|
|
230
|
+
|
|
231
|
+
Run `ng test @ng-formworks/bootstrap4` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
232
|
+
|
|
233
|
+
[npm_core_ver]:https://www.npmjs.com/package/@ng-formworks/core
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
|
|
3
|
+
"scripts": [
|
|
4
|
+
"//cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js",
|
|
5
|
+
"//cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"
|
|
6
|
+
],
|
|
7
|
+
"stylesheets": [
|
|
8
|
+
"//cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
}
|
package/karma.conf.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Karma configuration file, see link for more information
|
|
2
|
+
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
+
|
|
4
|
+
module.exports = function (config) {
|
|
5
|
+
config.set({
|
|
6
|
+
basePath: '',
|
|
7
|
+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
+
plugins: [
|
|
9
|
+
require('karma-jasmine'),
|
|
10
|
+
require('karma-chrome-launcher'),
|
|
11
|
+
require('karma-jasmine-html-reporter'),
|
|
12
|
+
require('karma-coverage'),
|
|
13
|
+
require('@angular-devkit/build-angular/plugins/karma'),
|
|
14
|
+
],
|
|
15
|
+
client: {
|
|
16
|
+
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
17
|
+
},
|
|
18
|
+
coverageReporter: {
|
|
19
|
+
dir: require('path').join(__dirname, '../../coverage/ajsf-bootstrap4'),
|
|
20
|
+
reporters: [
|
|
21
|
+
{
|
|
22
|
+
type: 'html',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'lcov',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'text-summary',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
reporters: ['progress', 'kjhtml'],
|
|
33
|
+
port: 9876,
|
|
34
|
+
colors: true,
|
|
35
|
+
logLevel: config.LOG_INFO,
|
|
36
|
+
autoWatch: true,
|
|
37
|
+
singleRun: false,
|
|
38
|
+
browsers: ['Chrome', 'ChromeHeadlessCI'],
|
|
39
|
+
customLaunchers: {
|
|
40
|
+
ChromeHeadlessCI: {
|
|
41
|
+
base: 'ChromeHeadless',
|
|
42
|
+
flags: ['--no-sandbox'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
};
|
package/ng-package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
|
|
3
|
+
"dest": "../../dist/@ng-formworks/bootstrap4",
|
|
4
|
+
"lib": {
|
|
5
|
+
"entryFile": "src/public_api.ts"
|
|
6
|
+
},
|
|
7
|
+
"assets": ["./assets"],
|
|
8
|
+
"allowedNonPeerDependencies": [
|
|
9
|
+
"lodash-es",
|
|
10
|
+
"@ng-formworks/core",
|
|
11
|
+
"@ng-formworks/cssframework"
|
|
12
|
+
]
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ng-formworks/bootstrap4",
|
|
3
|
+
"version": "15.2.7",
|
|
4
|
+
"description": "Angular ng-formworks - JSON Schema Form builder using Bootstrap 4 UI",
|
|
5
|
+
"author": "https://github.com/zahmo/ng-formworks/graphs/contributors",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"Angular",
|
|
8
|
+
"ng",
|
|
9
|
+
"Angular15",
|
|
10
|
+
"Angular 15",
|
|
11
|
+
"Angular16",
|
|
12
|
+
"Angular 16",
|
|
13
|
+
"Angular17",
|
|
14
|
+
"Angular 17",
|
|
15
|
+
"ng15",
|
|
16
|
+
"ng16",
|
|
17
|
+
"ng17",
|
|
18
|
+
"JSON Schema",
|
|
19
|
+
"form",
|
|
20
|
+
"forms",
|
|
21
|
+
"form builder",
|
|
22
|
+
"form themes",
|
|
23
|
+
"form generator",
|
|
24
|
+
"bootstrap",
|
|
25
|
+
"bootstrap 4",
|
|
26
|
+
"ajsf",
|
|
27
|
+
"ng-formworks",
|
|
28
|
+
"ng formworks",
|
|
29
|
+
"formworks",
|
|
30
|
+
"angular json schema form"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/zahmo/ng-formworks"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/zahmo/ng-formworks/issues"
|
|
39
|
+
},
|
|
40
|
+
"private": false,
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"lodash-es": "~4.17.21",
|
|
43
|
+
"@ng-formworks/core": "~15.2.7",
|
|
44
|
+
"@ng-formworks/cssframework": "~15.2.7",
|
|
45
|
+
"tslib": "^2.0.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@angular/common": ">=15.0.0",
|
|
49
|
+
"@angular/core": ">=15.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/lodash-es": "^4.17.6"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*adapted from bootstrap 3 to fix input groups */
|
|
2
|
+
|
|
3
|
+
.input-group .form-control:first-child,
|
|
4
|
+
.input-group-text:first-child,
|
|
5
|
+
.input-group-btn:first-child>.btn,
|
|
6
|
+
.input-group-btn:first-child>.btn-group>.btn,
|
|
7
|
+
.input-group-btn:first-child>.dropdown-toggle,
|
|
8
|
+
.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle),
|
|
9
|
+
.input-group-btn:last-child>.btn-group:not(:last-child)>.btn {
|
|
10
|
+
border-top-right-radius: 0;
|
|
11
|
+
border-bottom-right-radius: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.input-group-text:first-child {
|
|
15
|
+
border-right: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.input-group .form-control:last-child,
|
|
19
|
+
.input-group-text:last-child,
|
|
20
|
+
.input-group-btn:last-child>.btn,
|
|
21
|
+
.input-group-btn:last-child>.btn-group>.btn,
|
|
22
|
+
.input-group-btn:last-child>.dropdown-toggle,
|
|
23
|
+
.input-group-btn:first-child>.btn:not(:first-child),
|
|
24
|
+
.input-group-btn:first-child>.btn-group:not(:first-child)>.btn {
|
|
25
|
+
border-top-left-radius: 0;
|
|
26
|
+
border-bottom-left-radius: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.input-group-text:last-child {
|
|
30
|
+
border-left: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.input-group .form-control:not(:first-child):not(:last-child),
|
|
34
|
+
.input-group-text:not(:first-child):not(:last-child),
|
|
35
|
+
.input-group-btn:not(:first-child):not(:last-child) {
|
|
36
|
+
border-radius: 0
|
|
37
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { css_fw } from "@ng-formworks/cssframework";
|
|
2
|
+
|
|
3
|
+
export const cssFrameworkCfgBootstrap4:css_fw.frameworkcfg={
|
|
4
|
+
"name": "bootstrap-4",
|
|
5
|
+
"text":"Bootstrap 4",
|
|
6
|
+
"scripts": [
|
|
7
|
+
"//cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js",
|
|
8
|
+
"//cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"
|
|
9
|
+
],
|
|
10
|
+
"stylesheets": [
|
|
11
|
+
"//cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
|
|
12
|
+
],
|
|
13
|
+
"widgetstyles": {
|
|
14
|
+
"__themes__": [
|
|
15
|
+
{"name":"bootstrap4_default","text":"Bootstrap4 default"}
|
|
16
|
+
],
|
|
17
|
+
"$ref": {
|
|
18
|
+
"fieldHtmlClass": "btn float-right btn-info"
|
|
19
|
+
},
|
|
20
|
+
"__array_item_nonref__": {
|
|
21
|
+
"htmlClass": "list-group-item"
|
|
22
|
+
},
|
|
23
|
+
"__form_group__": {
|
|
24
|
+
"htmlClass": "form-group"
|
|
25
|
+
},
|
|
26
|
+
"__control_label__": {
|
|
27
|
+
"labelHtmlClass": "control-label"
|
|
28
|
+
},
|
|
29
|
+
"__active__": {
|
|
30
|
+
"activeClass": "active"
|
|
31
|
+
},
|
|
32
|
+
"__required_asterisk__": "text-danger",
|
|
33
|
+
"__screen_reader__": "sr-only",
|
|
34
|
+
"__remove_item__": "close float-right",
|
|
35
|
+
"__help_block__": "help-block",
|
|
36
|
+
"__field_addon_left__": "input-group-text input-group-prepend",
|
|
37
|
+
"__field_addon_right__": "input-group-text input-group-append",
|
|
38
|
+
"alt-date": {},
|
|
39
|
+
"alt-datetime": {},
|
|
40
|
+
"__array__": {
|
|
41
|
+
"htmlClass": "list-group"
|
|
42
|
+
},
|
|
43
|
+
"array": {},
|
|
44
|
+
"authfieldset": {},
|
|
45
|
+
"advancedfieldset": {},
|
|
46
|
+
"button": {
|
|
47
|
+
"fieldHtmlClass": "btn btn-sm btn-primary"
|
|
48
|
+
},
|
|
49
|
+
"checkbox": { "fieldHtmlClass": "checkbox" },
|
|
50
|
+
"checkboxes": {
|
|
51
|
+
"fieldHtmlClass": "checkbox"
|
|
52
|
+
},
|
|
53
|
+
"checkboxbuttons": {
|
|
54
|
+
"fieldHtmlClass": "sr-only",
|
|
55
|
+
"htmlClass": "btn-group",
|
|
56
|
+
"itemLabelHtmlClass": "btn"
|
|
57
|
+
},
|
|
58
|
+
"checkboxes-inline": {
|
|
59
|
+
"htmlClass": "checkbox",
|
|
60
|
+
"itemLabelHtmlClass": "checkbox-inline"
|
|
61
|
+
},
|
|
62
|
+
"date": {},
|
|
63
|
+
"datetime-local": {},
|
|
64
|
+
"fieldset": {},
|
|
65
|
+
"integer": {},
|
|
66
|
+
"number": {},
|
|
67
|
+
"optionfieldset": {},
|
|
68
|
+
"password": {},
|
|
69
|
+
"radiobuttons": {
|
|
70
|
+
"fieldHtmlClass": "sr-only",
|
|
71
|
+
"htmlClass": "btn-group",
|
|
72
|
+
"itemLabelHtmlClass": "btn"
|
|
73
|
+
},
|
|
74
|
+
"radio": { "fieldHtmlClass": "radio" },
|
|
75
|
+
"radios": {
|
|
76
|
+
"fieldHtmlClass": "radio"
|
|
77
|
+
},
|
|
78
|
+
"radios-inline": {
|
|
79
|
+
"htmlClass": "radio",
|
|
80
|
+
"itemLabelHtmlClass": "radio-inline"
|
|
81
|
+
},
|
|
82
|
+
"range": {},
|
|
83
|
+
"section": {},
|
|
84
|
+
"selectfieldset": {},
|
|
85
|
+
"select": {},
|
|
86
|
+
"submit": {
|
|
87
|
+
"fieldHtmlClass": "btn btn-primary"
|
|
88
|
+
},
|
|
89
|
+
"text": {},
|
|
90
|
+
"tabs": {
|
|
91
|
+
"labelHtmlClass": "nav nav-tabs",
|
|
92
|
+
"htmlClass": "tab-content",
|
|
93
|
+
"fieldHtmlClass": "tab-pane"
|
|
94
|
+
},
|
|
95
|
+
"tabarray": {
|
|
96
|
+
"labelHtmlClass": "nav nav-tabs",
|
|
97
|
+
"htmlClass": "tab-content",
|
|
98
|
+
"fieldHtmlClass": "tab-pane"
|
|
99
|
+
},
|
|
100
|
+
"textarea": {},
|
|
101
|
+
"default": {
|
|
102
|
+
"fieldHtmlClass": "form-control"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
:host ::ng-deep {
|
|
2
|
+
.list-group-item .form-control-feedback {
|
|
3
|
+
top: 40px;
|
|
4
|
+
}
|
|
5
|
+
.checkbox,
|
|
6
|
+
.radio {
|
|
7
|
+
margin-top: 0;
|
|
8
|
+
margin-bottom: 0;
|
|
9
|
+
}
|
|
10
|
+
.checkbox-inline,
|
|
11
|
+
.checkbox-inline+.checkbox-inline,
|
|
12
|
+
.checkbox-inline+.radio-inline,
|
|
13
|
+
.radio-inline,
|
|
14
|
+
.radio-inline+.radio-inline,
|
|
15
|
+
.radio-inline+.checkbox-inline {
|
|
16
|
+
margin-left: 0;
|
|
17
|
+
margin-right: 10px;
|
|
18
|
+
}
|
|
19
|
+
.checkbox-inline:last-child,
|
|
20
|
+
.radio-inline:last-child {
|
|
21
|
+
margin-right: 0;
|
|
22
|
+
}
|
|
23
|
+
.ng-invalid.ng-touched {
|
|
24
|
+
border: 1px solid #f44336;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@import './bootstrap4-cssframework.scss';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
3
|
+
import {
|
|
4
|
+
JsonSchemaFormModule,
|
|
5
|
+
JsonSchemaFormService,
|
|
6
|
+
WidgetLibraryModule
|
|
7
|
+
} from '@ng-formworks/core';
|
|
8
|
+
import { Bootstrap4FrameworkComponent } from './bootstrap4-framework.component';
|
|
9
|
+
|
|
10
|
+
describe('FwBootstrap4Component', () => {
|
|
11
|
+
let component: Bootstrap4FrameworkComponent;
|
|
12
|
+
let fixture: ComponentFixture<Bootstrap4FrameworkComponent>;
|
|
13
|
+
|
|
14
|
+
beforeEach(waitForAsync(() => {
|
|
15
|
+
TestBed.configureTestingModule({
|
|
16
|
+
imports: [
|
|
17
|
+
JsonSchemaFormModule,
|
|
18
|
+
CommonModule,
|
|
19
|
+
WidgetLibraryModule,
|
|
20
|
+
],
|
|
21
|
+
declarations: [Bootstrap4FrameworkComponent],
|
|
22
|
+
providers: [JsonSchemaFormService]
|
|
23
|
+
})
|
|
24
|
+
.compileComponents();
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
fixture = TestBed.createComponent(Bootstrap4FrameworkComponent);
|
|
29
|
+
component = fixture.componentInstance;
|
|
30
|
+
component.layoutNode = { options: {} };
|
|
31
|
+
component.layoutIndex = [];
|
|
32
|
+
component.dataIndex = [];
|
|
33
|
+
fixture.detectChanges();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should create', () => {
|
|
37
|
+
expect(component).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectorRef,
|
|
3
|
+
Component,
|
|
4
|
+
Input,
|
|
5
|
+
OnChanges,
|
|
6
|
+
OnInit,
|
|
7
|
+
ViewEncapsulation
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
import { JsonSchemaFormService } from '@ng-formworks/core';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Bootstrap 4 framework for Angular JSON Schema Form.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
@Component({
|
|
16
|
+
// tslint:disable-next-line:component-selector
|
|
17
|
+
selector: 'bootstrap-4-framework',
|
|
18
|
+
template: `
|
|
19
|
+
<div>
|
|
20
|
+
<css-framework [layoutNode]="layoutNode"
|
|
21
|
+
[layoutIndex]="layoutIndex"
|
|
22
|
+
[dataIndex]="dataIndex">
|
|
23
|
+
</css-framework>
|
|
24
|
+
</div>
|
|
25
|
+
`,
|
|
26
|
+
styleUrls: ['./bootstrap4-framework.component.scss'],
|
|
27
|
+
encapsulation:ViewEncapsulation.None
|
|
28
|
+
})
|
|
29
|
+
export class Bootstrap4FrameworkComponent implements OnInit, OnChanges {
|
|
30
|
+
frameworkInitialized = false;
|
|
31
|
+
widgetOptions: any; // Options passed to child widget
|
|
32
|
+
widgetLayoutNode: any; // layoutNode passed to child widget
|
|
33
|
+
options: any; // Options used in this framework
|
|
34
|
+
formControl: any = null;
|
|
35
|
+
debugOutput: any = '';
|
|
36
|
+
debug: any = '';
|
|
37
|
+
parentArray: any = null;
|
|
38
|
+
isOrderable = false;
|
|
39
|
+
@Input() layoutNode: any;
|
|
40
|
+
@Input() layoutIndex: number[];
|
|
41
|
+
@Input() dataIndex: number[];
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
constructor(
|
|
45
|
+
public changeDetector: ChangeDetectorRef,
|
|
46
|
+
public jsf: JsonSchemaFormService
|
|
47
|
+
) {
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
ngOnInit() {
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ngOnChanges() {
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import {
|
|
4
|
+
Framework,
|
|
5
|
+
FrameworkLibraryService,
|
|
6
|
+
JsonSchemaFormModule,
|
|
7
|
+
JsonSchemaFormService,
|
|
8
|
+
WidgetLibraryModule,
|
|
9
|
+
WidgetLibraryService
|
|
10
|
+
} from '@ng-formworks/core';
|
|
11
|
+
import { CssFrameworkModule } from '@ng-formworks/cssframework';
|
|
12
|
+
import { Bootstrap4FrameworkComponent } from './bootstrap4-framework.component';
|
|
13
|
+
import { Bootstrap4Framework } from './bootstrap4.framework';
|
|
14
|
+
|
|
15
|
+
@NgModule({
|
|
16
|
+
imports: [
|
|
17
|
+
JsonSchemaFormModule,
|
|
18
|
+
CommonModule,
|
|
19
|
+
WidgetLibraryModule,
|
|
20
|
+
CssFrameworkModule
|
|
21
|
+
],
|
|
22
|
+
declarations: [
|
|
23
|
+
Bootstrap4FrameworkComponent,
|
|
24
|
+
],
|
|
25
|
+
exports: [
|
|
26
|
+
JsonSchemaFormModule,
|
|
27
|
+
Bootstrap4FrameworkComponent,
|
|
28
|
+
],
|
|
29
|
+
providers: [
|
|
30
|
+
JsonSchemaFormService,
|
|
31
|
+
FrameworkLibraryService,
|
|
32
|
+
WidgetLibraryService,
|
|
33
|
+
{ provide: Framework, useClass: Bootstrap4Framework, multi: true },
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
export class Bootstrap4FrameworkModule {
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { CssFramework, CssframeworkService } from '@ng-formworks/cssframework';
|
|
3
|
+
import { cssFrameworkCfgBootstrap4 } from './bootstrap4-cssframework';
|
|
4
|
+
import { Bootstrap4FrameworkComponent } from './bootstrap4-framework.component';
|
|
5
|
+
|
|
6
|
+
// Bootstrap 4 Framework
|
|
7
|
+
// https://github.com/ng-bootstrap/ng-bootstrap
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class Bootstrap4Framework extends CssFramework {
|
|
11
|
+
|
|
12
|
+
framework = Bootstrap4FrameworkComponent;
|
|
13
|
+
|
|
14
|
+
constructor(public cssFWService:CssframeworkService){
|
|
15
|
+
super(cssFrameworkCfgBootstrap4,cssFWService);
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/test.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
+
|
|
3
|
+
import 'zone.js';
|
|
4
|
+
import 'zone.js/testing';
|
|
5
|
+
import { getTestBed } from '@angular/core/testing';
|
|
6
|
+
import {
|
|
7
|
+
BrowserDynamicTestingModule,
|
|
8
|
+
platformBrowserDynamicTesting
|
|
9
|
+
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
+
|
|
11
|
+
// First, initialize the Angular testing environment.
|
|
12
|
+
getTestBed().initTestEnvironment(
|
|
13
|
+
BrowserDynamicTestingModule,
|
|
14
|
+
platformBrowserDynamicTesting(), {
|
|
15
|
+
teardown: { destroyAfterEach: false }
|
|
16
|
+
}
|
|
17
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../out-tsc/lib",
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"inlineSources": true,
|
|
8
|
+
"types": [],
|
|
9
|
+
"lib": [
|
|
10
|
+
"dom",
|
|
11
|
+
"es2018"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"angularCompilerOptions": {
|
|
15
|
+
"skipTemplateCodegen": true,
|
|
16
|
+
"strictMetadataEmit": true,
|
|
17
|
+
"fullTemplateTypeCheck": true,
|
|
18
|
+
"strictInjectionParameters": true,
|
|
19
|
+
"enableResourceInlining": true,
|
|
20
|
+
"preserveSymlinks": true
|
|
21
|
+
},
|
|
22
|
+
"exclude": [
|
|
23
|
+
"src/test.ts",
|
|
24
|
+
"**/*.spec.ts"
|
|
25
|
+
]
|
|
26
|
+
}
|