@record-evolution/widget-form 1.0.9 → 1.0.10
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 +64 -72
- package/dist/widget-form.d.ts +42 -0
- package/dist/widget-form.js +708 -9717
- package/dist/widget-form.js.map +1 -1
- package/package.json +20 -29
- package/src/definition-schema.d.ts +21 -21
- package/src/widget-form.ts +38 -62
- package/dist/src/widget-form.d.ts +0 -45
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,108 +1,100 @@
|
|
|
1
|
-
#
|
|
1
|
+
# widget-form
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Lit 3.x web component for creating dynamic forms with configurable fields. Part of the IronFlock widget ecosystem.
|
|
4
|
+
|
|
5
|
+

|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
npm i widget-form
|
|
10
|
+
npm i @record-evolution/widget-form
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
15
|
```html
|
|
14
16
|
<script type="module">
|
|
15
|
-
import '
|
|
17
|
+
import '@record-evolution/widget-form'
|
|
16
18
|
</script>
|
|
17
19
|
|
|
18
|
-
<widget-form></widget-form>
|
|
20
|
+
<widget-form-1.0.9></widget-form-1.0.9>
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
The following format represents the available data :
|
|
24
|
-
|
|
25
|
-
```js
|
|
26
|
-
data: {
|
|
27
|
-
settings: {
|
|
28
|
-
title: string,
|
|
29
|
-
subTitle: string,
|
|
30
|
-
minGauge: number,
|
|
31
|
-
maxGauge: number,
|
|
32
|
-
style: {
|
|
33
|
-
needleColor: string,
|
|
34
|
-
sections: number,
|
|
35
|
-
backgroundColor: string[]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
gaugeValue: Number
|
|
39
|
-
}
|
|
40
|
-
```
|
|
23
|
+
> **Note:** The version number is part of the custom element tag name.
|
|
41
24
|
|
|
42
|
-
##
|
|
25
|
+
## Properties
|
|
43
26
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
```
|
|
27
|
+
| Property | Type | Description |
|
|
28
|
+
| ----------- | ----------- | ----------------------------- |
|
|
29
|
+
| `inputData` | `InputData` | Form configuration and fields |
|
|
30
|
+
| `theme` | `Theme` | Theme object for styling |
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
interface Settings {
|
|
53
|
-
title: string
|
|
54
|
-
subTitle: string
|
|
55
|
-
minGauge: number
|
|
56
|
-
maxGauge: number
|
|
57
|
-
style: Style
|
|
58
|
-
}
|
|
59
|
-
```
|
|
32
|
+
## Events
|
|
60
33
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
sections: number
|
|
65
|
-
backgroundColor: string[]
|
|
66
|
-
}
|
|
67
|
-
```
|
|
34
|
+
| Event | Detail | Description |
|
|
35
|
+
| ------------- | ----------------------------- | -------------------------------- |
|
|
36
|
+
| `data-submit` | Array of field/value mappings | Fired when the form is submitted |
|
|
68
37
|
|
|
69
|
-
##
|
|
38
|
+
## Configuration
|
|
70
39
|
|
|
71
|
-
The
|
|
72
|
-
The `sections` option splits the value area into by default three same sized sections. Therefore three different colors can be provided to the `backgroundColor` by default.
|
|
40
|
+
The form is configured via the `inputData` property:
|
|
73
41
|
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
42
|
+
```ts
|
|
43
|
+
interface InputData {
|
|
44
|
+
title?: string
|
|
45
|
+
subTitle?: string
|
|
46
|
+
formButton?: boolean // Show button to open form dialog
|
|
47
|
+
formFields?: FormField[]
|
|
48
|
+
}
|
|
80
49
|
```
|
|
81
50
|
|
|
82
|
-
|
|
51
|
+
### Field Types
|
|
83
52
|
|
|
84
|
-
|
|
53
|
+
Each form field supports the following types:
|
|
85
54
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
55
|
+
| Type | Description |
|
|
56
|
+
| ------------- | ------------------------------ |
|
|
57
|
+
| `textfield` | Single-line text input |
|
|
58
|
+
| `numberfield` | Numeric input with min/max |
|
|
59
|
+
| `checkbox` | Boolean checkbox |
|
|
60
|
+
| `textarea` | Multi-line text input |
|
|
61
|
+
| `dropdown` | Select from predefined options |
|
|
62
|
+
| `datetime` | Date/time picker |
|
|
89
63
|
|
|
90
|
-
|
|
64
|
+
### Field Configuration
|
|
91
65
|
|
|
92
|
-
```
|
|
93
|
-
|
|
66
|
+
```ts
|
|
67
|
+
interface FormField {
|
|
68
|
+
label: string
|
|
69
|
+
type: 'dropdown' | 'textfield' | 'numberfield' | 'checkbox' | 'textarea' | 'datetime'
|
|
70
|
+
hiddenField?: boolean // Hide field but still submit value
|
|
71
|
+
required?: boolean // Field must be filled
|
|
72
|
+
description?: string // Hint text shown below field
|
|
73
|
+
targetColumn?: TargetColumn // Database column mapping
|
|
74
|
+
defaultValue?: string
|
|
75
|
+
min?: number // For numberfield
|
|
76
|
+
max?: number // For numberfield
|
|
77
|
+
validation?: string // Regex for textfield
|
|
78
|
+
values?: DropdownValue[] // For dropdown type
|
|
79
|
+
}
|
|
94
80
|
```
|
|
95
81
|
|
|
96
|
-
##
|
|
82
|
+
## Development
|
|
97
83
|
|
|
98
|
-
|
|
84
|
+
```bash
|
|
85
|
+
# Start dev server
|
|
86
|
+
npm run start
|
|
99
87
|
|
|
100
|
-
|
|
88
|
+
# Build for production
|
|
89
|
+
npm run build
|
|
101
90
|
|
|
102
|
-
|
|
91
|
+
# Generate types from schema
|
|
92
|
+
npm run types
|
|
103
93
|
|
|
104
|
-
|
|
105
|
-
npm
|
|
94
|
+
# Build, bump version, and publish
|
|
95
|
+
npm run release
|
|
106
96
|
```
|
|
107
97
|
|
|
108
|
-
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { InputData } from './definition-schema.js';
|
|
3
|
+
import { LitElement } from 'lit';
|
|
4
|
+
import { MdDialog } from '@material/web/dialog/dialog.js';
|
|
5
|
+
import { PropertyValues } from 'lit';
|
|
6
|
+
import { TemplateResult } from 'lit-html';
|
|
7
|
+
|
|
8
|
+
declare type Column = Exclude<InputData['formFields'], undefined>[number];
|
|
9
|
+
|
|
10
|
+
declare type Theme = {
|
|
11
|
+
theme_name: string;
|
|
12
|
+
theme_object: any;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export declare class WidgetForm extends LitElement {
|
|
16
|
+
inputData?: InputData;
|
|
17
|
+
theme?: Theme;
|
|
18
|
+
private themeBgColor?;
|
|
19
|
+
private themeTitleColor?;
|
|
20
|
+
private themeSubtitleColor?;
|
|
21
|
+
dialogOpen: boolean;
|
|
22
|
+
dialog: MdDialog;
|
|
23
|
+
version: string;
|
|
24
|
+
update(changedProperties: Map<string, any>): void;
|
|
25
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
26
|
+
registerTheme(theme?: Theme): void;
|
|
27
|
+
openFormDialog(): void;
|
|
28
|
+
handleFormSubmit(event: Event): void;
|
|
29
|
+
formatValue(value: string, type: string): any;
|
|
30
|
+
renderTextField(field: Column, i: number): TemplateResult<1>;
|
|
31
|
+
renderNumberField(field: Column, i: number): TemplateResult<1>;
|
|
32
|
+
renderCheckbox(field: Column, i: number): TemplateResult<1>;
|
|
33
|
+
renderTextArea(field: Column, i: number): TemplateResult<1>;
|
|
34
|
+
renderDropdown(field: Column, i: number): TemplateResult<1>;
|
|
35
|
+
renderDateTimeField(field: Column, i: number): TemplateResult<1>;
|
|
36
|
+
cancelEdit(event: Event): void;
|
|
37
|
+
static styles: CSSResult;
|
|
38
|
+
render(): TemplateResult<1>;
|
|
39
|
+
renderForm(): TemplateResult<1>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { }
|