@vdegenne/forms 0.0.3 → 0.0.5
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/lib/FormBuilder.d.ts +11 -5
- package/lib/FormBuilder.d.ts.map +1 -1
- package/lib/FormBuilder.js +21 -16
- package/lib/FormBuilder.js.map +1 -1
- package/package.json +1 -1
package/lib/FormBuilder.d.ts
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
interface SharedOptions {
|
|
2
|
+
autofocus: boolean;
|
|
3
|
+
}
|
|
4
|
+
interface TextFieldOptions extends SharedOptions {
|
|
5
|
+
type: 'text' | 'number';
|
|
6
|
+
}
|
|
7
|
+
interface FilterOptions extends SharedOptions {
|
|
2
8
|
type: 'string' | 'number';
|
|
3
9
|
/**
|
|
4
10
|
* Not implemented yet.
|
|
5
11
|
*/
|
|
6
12
|
sort: 'none' | 'alphabet';
|
|
7
|
-
}
|
|
13
|
+
}
|
|
8
14
|
type InputOptions = {
|
|
9
15
|
availableValues: string[];
|
|
10
16
|
};
|
|
11
17
|
export declare class FormBuilder<T> {
|
|
12
18
|
protected host: T;
|
|
13
19
|
constructor(host: T);
|
|
20
|
+
TEXTFIELD(label: string, key: keyof T, options?: Partial<TextFieldOptions>): import("lit-html").TemplateResult<1>;
|
|
21
|
+
TEXTAREA(label: string, key: keyof T): import("lit-html").TemplateResult<1>;
|
|
14
22
|
SWITCH(headline: string, key: keyof T): import("lit-html").TemplateResult<1>;
|
|
15
23
|
SLIDER(label: string, key: keyof T, options?: {
|
|
16
24
|
min: number;
|
|
17
25
|
max: number;
|
|
18
26
|
}): import("lit-html").TemplateResult<1>;
|
|
19
27
|
SELECT(label: string, key: keyof T, choices?: string[]): import("lit-html").TemplateResult<1>;
|
|
20
|
-
TEXTFIELD(label: string, type: string, key: keyof T): import("lit-html").TemplateResult<1>;
|
|
21
|
-
TEXTAREA(label: string, key: keyof T): import("lit-html").TemplateResult<1>;
|
|
22
28
|
FILTER(label: string, key: keyof T, choices: string[], options?: Partial<FilterOptions>): import("lit-html").TemplateResult<1>;
|
|
23
29
|
}
|
|
24
30
|
export declare const SWITCH: <T>(headline: string, host: T, key: keyof T) => import("lit-html").TemplateResult<1>;
|
|
@@ -27,7 +33,7 @@ export declare const SLIDER: <T>(label: string, host: T, key: keyof T, options?:
|
|
|
27
33
|
max: number;
|
|
28
34
|
}) => import("lit-html").TemplateResult<1>;
|
|
29
35
|
export declare const SELECT: <T>(label: string, host: T, key: keyof T, choices?: string[]) => import("lit-html").TemplateResult<1>;
|
|
30
|
-
export declare const TEXTFIELD: <T>(label: string,
|
|
36
|
+
export declare const TEXTFIELD: <T>(label: string, host: T, key: keyof T, options?: Partial<TextFieldOptions>) => import("lit-html").TemplateResult<1>;
|
|
31
37
|
export declare const TEXTAREA: <T>(label: string, host: T, key: keyof T) => import("lit-html").TemplateResult<1>;
|
|
32
38
|
export declare const FILTER: <T>(label: string, host: T, key: keyof T, choices: string[], options?: Partial<FilterOptions>) => import("lit-html").TemplateResult<1>;
|
|
33
39
|
export declare const INPUT: <T>(label: string, host: T, key: keyof T, options?: Partial<InputOptions>) => import("lit-html").TemplateResult<1>;
|
package/lib/FormBuilder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormBuilder.d.ts","sourceRoot":"","sources":["../src/FormBuilder.ts"],"names":[],"mappings":"AAMA,
|
|
1
|
+
{"version":3,"file":"FormBuilder.d.ts","sourceRoot":"","sources":["../src/FormBuilder.ts"],"names":[],"mappings":"AAMA,UAAU,aAAa;IACtB,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,gBAAiB,SAAQ,aAAa;IAE/C,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;CACxB;AAED,UAAU,aAAc,SAAQ,aAAa;IAC5C,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,UAA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M,QAAQ,CAAC,OAAO,MAAM,CAAC,yCAM/D,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,CAAC,SAChB,MAAM,QACP,CAAC,OACF,MAAM,CAAC,WACH,MAAM,EAAE,YACP,OAAO,CAAC,aAAa,CAAC,yCAuChC,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,CAAC,SACf,MAAM,QACP,CAAC,OACF,MAAM,CAAC,YACF,OAAO,CAAC,YAAY,CAAC,yCAM/B,CAAC"}
|
package/lib/FormBuilder.js
CHANGED
|
@@ -5,6 +5,12 @@ export class FormBuilder {
|
|
|
5
5
|
constructor(host) {
|
|
6
6
|
this.host = host;
|
|
7
7
|
}
|
|
8
|
+
TEXTFIELD(label, key, options) {
|
|
9
|
+
return TEXTFIELD(label, this.host, key, options);
|
|
10
|
+
}
|
|
11
|
+
TEXTAREA(label, key) {
|
|
12
|
+
return TEXTAREA(label, this.host, key);
|
|
13
|
+
}
|
|
8
14
|
SWITCH(headline, key) {
|
|
9
15
|
return SWITCH(headline, this.host, key);
|
|
10
16
|
}
|
|
@@ -14,12 +20,6 @@ export class FormBuilder {
|
|
|
14
20
|
SELECT(label, key, choices = []) {
|
|
15
21
|
return SELECT(label, this.host, key, choices);
|
|
16
22
|
}
|
|
17
|
-
TEXTFIELD(label, type, key) {
|
|
18
|
-
return TEXTFIELD(label, type, this.host, key);
|
|
19
|
-
}
|
|
20
|
-
TEXTAREA(label, key) {
|
|
21
|
-
return TEXTAREA(label, this.host, key);
|
|
22
|
-
}
|
|
23
23
|
FILTER(label, key, choices, options) {
|
|
24
24
|
return FILTER(label, this.host, key, choices, options);
|
|
25
25
|
}
|
|
@@ -61,15 +61,19 @@ export const SELECT = (label, host, key, choices = []) => html `
|
|
|
61
61
|
<md-option></md-option>
|
|
62
62
|
</md-filled-select>
|
|
63
63
|
`;
|
|
64
|
-
export const TEXTFIELD = (label,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
export const TEXTFIELD = (label, host, key, options) => {
|
|
65
|
+
options = Object.assign({}, { type: 'text', autofocus: false }, options ?? {});
|
|
66
|
+
return html `
|
|
67
|
+
<md-filled-text-field
|
|
68
|
+
?autofocus=${options.autofocus}
|
|
69
|
+
label=${label.replace(/\*/g, '')}
|
|
70
|
+
type=${options.type}
|
|
71
|
+
${bindInput(host, key)}
|
|
72
|
+
?required=${label.includes('*')}
|
|
73
|
+
>
|
|
74
|
+
</md-filled-text-field>
|
|
75
|
+
`;
|
|
76
|
+
};
|
|
73
77
|
export const TEXTAREA = (label, host, key) => html `
|
|
74
78
|
<md-filled-text-field
|
|
75
79
|
type="textarea"
|
|
@@ -78,12 +82,13 @@ export const TEXTAREA = (label, host, key) => html `
|
|
|
78
82
|
></md-filled-text-field>
|
|
79
83
|
`;
|
|
80
84
|
export const FILTER = (label, host, key, choices, options) => {
|
|
81
|
-
options = Object.assign({}, { type: 'string' }, options ?? {});
|
|
85
|
+
options = Object.assign({}, { type: 'string', autofocus: false }, options ?? {});
|
|
82
86
|
const chipsetref = createRef();
|
|
83
87
|
return html `
|
|
84
88
|
<div>
|
|
85
89
|
<div class="mb-2">${label}</div>
|
|
86
90
|
<md-chip-set
|
|
91
|
+
?autofocus=${options.autofocus}
|
|
87
92
|
${ref(chipsetref)}
|
|
88
93
|
@click=${() => {
|
|
89
94
|
const chipset = chipsetref.value;
|
package/lib/FormBuilder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormBuilder.js","sourceRoot":"","sources":["../src/FormBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"FormBuilder.js","sourceRoot":"","sources":["../src/FormBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAO,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC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