@vdegenne/forms 0.0.1 → 0.0.3
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 +5 -0
- package/lib/FormBuilder.d.ts +14 -0
- package/lib/FormBuilder.d.ts.map +1 -1
- package/lib/FormBuilder.js +38 -0
- package/lib/FormBuilder.js.map +1 -1
- package/package.json +2 -2
package/README.md
ADDED
package/lib/FormBuilder.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
type FilterOptions = {
|
|
2
|
+
type: 'string' | 'number';
|
|
3
|
+
/**
|
|
4
|
+
* Not implemented yet.
|
|
5
|
+
*/
|
|
6
|
+
sort: 'none' | 'alphabet';
|
|
7
|
+
};
|
|
8
|
+
type InputOptions = {
|
|
9
|
+
availableValues: string[];
|
|
10
|
+
};
|
|
1
11
|
export declare class FormBuilder<T> {
|
|
2
12
|
protected host: T;
|
|
3
13
|
constructor(host: T);
|
|
@@ -9,6 +19,7 @@ export declare class FormBuilder<T> {
|
|
|
9
19
|
SELECT(label: string, key: keyof T, choices?: string[]): import("lit-html").TemplateResult<1>;
|
|
10
20
|
TEXTFIELD(label: string, type: string, key: keyof T): import("lit-html").TemplateResult<1>;
|
|
11
21
|
TEXTAREA(label: string, key: keyof T): import("lit-html").TemplateResult<1>;
|
|
22
|
+
FILTER(label: string, key: keyof T, choices: string[], options?: Partial<FilterOptions>): import("lit-html").TemplateResult<1>;
|
|
12
23
|
}
|
|
13
24
|
export declare const SWITCH: <T>(headline: string, host: T, key: keyof T) => import("lit-html").TemplateResult<1>;
|
|
14
25
|
export declare const SLIDER: <T>(label: string, host: T, key: keyof T, options?: {
|
|
@@ -18,4 +29,7 @@ export declare const SLIDER: <T>(label: string, host: T, key: keyof T, options?:
|
|
|
18
29
|
export declare const SELECT: <T>(label: string, host: T, key: keyof T, choices?: string[]) => import("lit-html").TemplateResult<1>;
|
|
19
30
|
export declare const TEXTFIELD: <T>(label: string, type: string, host: T, key: keyof T) => import("lit-html").TemplateResult<1>;
|
|
20
31
|
export declare const TEXTAREA: <T>(label: string, host: T, key: keyof T) => import("lit-html").TemplateResult<1>;
|
|
32
|
+
export declare const FILTER: <T>(label: string, host: T, key: keyof T, choices: string[], options?: Partial<FilterOptions>) => import("lit-html").TemplateResult<1>;
|
|
33
|
+
export declare const INPUT: <T>(label: string, host: T, key: keyof T, options?: Partial<InputOptions>) => import("lit-html").TemplateResult<1>;
|
|
34
|
+
export {};
|
|
21
35
|
//# sourceMappingURL=FormBuilder.d.ts.map
|
package/lib/FormBuilder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormBuilder.d.ts","sourceRoot":"","sources":["../src/FormBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormBuilder.d.ts","sourceRoot":"","sources":["../src/FormBuilder.ts"],"names":[],"mappings":"AAMA,KAAK,aAAa,GAAG;IACpB,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC1B,CAAC;AACF,KAAK,YAAY,GAAG;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,qBAAa,WAAW,CAAC,CAAC;IACb,SAAS,CAAC,IAAI,EAAE,CAAC;gBAAP,IAAI,EAAE,CAAC;IAE7B,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC;IAIrC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO;;;KAAmB;IAI9D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,GAAE,MAAM,EAAO;IAI1D,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC;IAInD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC;IAIpC,MAAM,CACL,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,CAAC,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC;CAIjC;AAED,eAAO,MAAM,MAAM,GAAI,CAAC,YAAY,MAAM,QAAQ,CAAC,OAAO,MAAM,CAAC,yCAahE,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,CAAC,SAChB,MAAM,QACP,CAAC,OACF,MAAM,CAAC;;;0CAeZ,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,CAAC,SAChB,MAAM,QACP,CAAC,OACF,MAAM,CAAC,YACH,MAAM,EAAE,yCAWjB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,SACnB,MAAM,QACP,MAAM,QACN,CAAC,OACF,MAAM,CAAC,yCASZ,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,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,yCAkChC,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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
2
|
import { bindInput } from './bindInput.js';
|
|
3
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
|
3
4
|
export class FormBuilder {
|
|
4
5
|
constructor(host) {
|
|
5
6
|
this.host = host;
|
|
@@ -19,6 +20,9 @@ export class FormBuilder {
|
|
|
19
20
|
TEXTAREA(label, key) {
|
|
20
21
|
return TEXTAREA(label, this.host, key);
|
|
21
22
|
}
|
|
23
|
+
FILTER(label, key, choices, options) {
|
|
24
|
+
return FILTER(label, this.host, key, choices, options);
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
export const SWITCH = (headline, host, key) => html `
|
|
24
28
|
<md-list-item
|
|
@@ -73,4 +77,38 @@ export const TEXTAREA = (label, host, key) => html `
|
|
|
73
77
|
${bindInput(host, key)}
|
|
74
78
|
></md-filled-text-field>
|
|
75
79
|
`;
|
|
80
|
+
export const FILTER = (label, host, key, choices, options) => {
|
|
81
|
+
options = Object.assign({}, { type: 'string' }, options ?? {});
|
|
82
|
+
const chipsetref = createRef();
|
|
83
|
+
return html `
|
|
84
|
+
<div>
|
|
85
|
+
<div class="mb-2">${label}</div>
|
|
86
|
+
<md-chip-set
|
|
87
|
+
${ref(chipsetref)}
|
|
88
|
+
@click=${() => {
|
|
89
|
+
const chipset = chipsetref.value;
|
|
90
|
+
if (!chipset) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
host[key] = chipset.chips
|
|
94
|
+
.filter((c) => c.selected)
|
|
95
|
+
.map((c) => options.type === 'string' ? c.label : choices.indexOf(c.label));
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
${choices.map((choice, index) => html `
|
|
99
|
+
<md-filter-chip
|
|
100
|
+
?selected=${host[key].includes(options.type === 'string' ? choice : index)}
|
|
101
|
+
label=${choice}
|
|
102
|
+
></md-filter-chip>
|
|
103
|
+
`)}
|
|
104
|
+
</md-chip-set>
|
|
105
|
+
</div>
|
|
106
|
+
`;
|
|
107
|
+
};
|
|
108
|
+
export const INPUT = (label, host, key, options) => {
|
|
109
|
+
throw new Error('Not implemented yet.');
|
|
110
|
+
return html `<!-- -->
|
|
111
|
+
|
|
112
|
+
<!-- -->`;
|
|
113
|
+
};
|
|
76
114
|
//# sourceMappingURL=FormBuilder.js.map
|
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,EAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormBuilder.js","sourceRoot":"","sources":["../src/FormBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,SAAS,EAAY,GAAG,EAAC,MAAM,uBAAuB,CAAC;AAe/D,MAAM,OAAO,WAAW;IACvB,YAAsB,IAAO;QAAP,SAAI,GAAJ,IAAI,CAAG;IAAG,CAAC;IAEjC,MAAM,CAAC,QAAgB,EAAE,GAAY;QACpC,OAAO,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,GAAY,EAAE,OAAO,GAAG,EAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;QAC7D,OAAO,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,GAAY,EAAE,UAAoB,EAAE;QACzD,OAAO,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,IAAY,EAAE,GAAY;QAClD,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED,QAAQ,CAAC,KAAa,EAAE,GAAY;QACnC,OAAO,QAAQ,CAAC,KAAK,EAAE,IA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AAG,CAAyB,CAAC,QAAQ,CACtD,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAC1C;eACO,MAAM;;MAEf,CACD;;;EAGH,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,CACpB,KAAa,EACb,IAAO,EACP,GAAY,EACZ,OAA+B,EAC9B,EAAE;IACH,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACxC,OAAO,IAAI,CAAA;;WAED,CAAC;AACZ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vdegenne/forms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "wireit"
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
+
"@material/web": "^2.2.0",
|
|
22
23
|
"lit": "^3.2.1",
|
|
23
24
|
"typescript": "^5.7.3",
|
|
24
25
|
"wireit": "^0.14.11"
|
|
@@ -33,4 +34,3 @@
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
|