@unicef-polymer/etools-form-builder 0.1.25 → 1.0.1

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.
Files changed (64) hide show
  1. package/dist/form-attachments-popup/form-attachments-popup.d.ts +77 -77
  2. package/dist/form-attachments-popup/form-attachments-popup.helper.d.ts +8 -8
  3. package/dist/form-attachments-popup/form-attachments-popup.helper.js +14 -14
  4. package/dist/form-attachments-popup/form-attachments-popup.js +191 -191
  5. package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +8 -8
  6. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +15 -15
  7. package/dist/form-attachments-popup/index.d.ts +2 -2
  8. package/dist/form-attachments-popup/index.js +2 -2
  9. package/dist/form-fields/base-field.d.ts +20 -20
  10. package/dist/form-fields/base-field.js +80 -80
  11. package/dist/form-fields/custom-elements.define.d.ts +1 -1
  12. package/dist/form-fields/custom-elements.define.js +11 -11
  13. package/dist/form-fields/index.d.ts +5 -5
  14. package/dist/form-fields/index.js +5 -5
  15. package/dist/form-fields/number-field.d.ts +9 -9
  16. package/dist/form-fields/number-field.js +24 -24
  17. package/dist/form-fields/scale-field.d.ts +16 -16
  18. package/dist/form-fields/scale-field.js +38 -38
  19. package/dist/form-fields/text-field.d.ts +8 -8
  20. package/dist/form-fields/text-field.js +19 -19
  21. package/dist/form-fields/wide-field.d.ts +11 -11
  22. package/dist/form-fields/wide-field.js +36 -36
  23. package/dist/form-groups/custom-elements.define.d.ts +1 -1
  24. package/dist/form-groups/custom-elements.define.js +9 -9
  25. package/dist/form-groups/form-abstract-group.d.ts +60 -60
  26. package/dist/form-groups/form-abstract-group.js +199 -199
  27. package/dist/form-groups/form-card.d.ts +31 -31
  28. package/dist/form-groups/form-card.js +69 -69
  29. package/dist/form-groups/form-collapsed-card.d.ts +68 -68
  30. package/dist/form-groups/form-collapsed-card.js +208 -207
  31. package/dist/form-groups/index.d.ts +3 -3
  32. package/dist/form-groups/index.js +3 -3
  33. package/dist/index.d.ts +14 -14
  34. package/dist/index.js +19 -19
  35. package/dist/lib/additional-components/etools-fb-card.d.ts +16 -16
  36. package/dist/lib/additional-components/etools-fb-card.js +80 -80
  37. package/dist/lib/styles/attachments.styles.d.ts +2 -2
  38. package/dist/lib/styles/attachments.styles.js +3 -3
  39. package/dist/lib/styles/card-styles.d.ts +2 -2
  40. package/dist/lib/styles/card-styles.js +3 -3
  41. package/dist/lib/styles/dialog.styles.d.ts +2 -2
  42. package/dist/lib/styles/dialog.styles.js +3 -3
  43. package/dist/lib/styles/elevation-styles.d.ts +9 -9
  44. package/dist/lib/styles/elevation-styles.js +10 -10
  45. package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
  46. package/dist/lib/styles/flex-layout-classes.js +3 -3
  47. package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
  48. package/dist/lib/styles/form-builder-card.styles.js +3 -3
  49. package/dist/lib/styles/input-styles.d.ts +2 -2
  50. package/dist/lib/styles/input-styles.js +5 -5
  51. package/dist/lib/styles/page-layout-styles.d.ts +2 -2
  52. package/dist/lib/styles/page-layout-styles.js +3 -3
  53. package/dist/lib/styles/shared-styles.d.ts +2 -2
  54. package/dist/lib/styles/shared-styles.js +3 -3
  55. package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
  56. package/dist/lib/types/form-builder.types.d.ts +53 -53
  57. package/dist/lib/types/global.types.d.ts +4 -4
  58. package/dist/lib/utils/dialog.d.ts +10 -10
  59. package/dist/lib/utils/dialog.js +21 -21
  60. package/dist/lib/utils/fire-custom-event.d.ts +1 -1
  61. package/dist/lib/utils/fire-custom-event.js +7 -7
  62. package/dist/lib/utils/validations.helper.d.ts +26 -26
  63. package/dist/lib/utils/validations.helper.js +35 -35
  64. package/package.json +7 -7
@@ -1,53 +1,53 @@
1
- import { FieldValidator } from '../utils/validations.helper';
2
- import { GenericObject } from './global.types';
3
- /** JSON file from backend */
4
- export declare type ChecklistFormJson = {
5
- blueprint: {
6
- code: string;
7
- metadata: BlueprintMetadata;
8
- structure: BlueprintGroup;
9
- title: string;
10
- };
11
- value: GenericObject;
12
- };
13
- /** --------- */
14
- export declare type BlueprintGroup = {
15
- type: 'group';
16
- extra: GenericObject;
17
- styling: string[];
18
- name: string;
19
- repeatable: boolean;
20
- required: boolean;
21
- title: string | null;
22
- children: (BlueprintGroup | BlueprintField)[];
23
- };
24
- export declare type BlueprintField = {
25
- type: 'field';
26
- extra: GenericObject;
27
- styling: string[];
28
- name: string;
29
- repeatable: boolean;
30
- required: boolean;
31
- input_type: 'text' | 'likert_scale' | 'bool' | 'number' | 'number-integer' | 'number-float';
32
- label: string;
33
- validations: string[];
34
- help_text: string;
35
- placeholder: string;
36
- default_value: null;
37
- options_key: null;
38
- };
39
- /** Metadata for blueprint structure */
40
- export declare type BlueprintMetadata = {
41
- options: GenericObject<BlueprintMetadataOptions>;
42
- validations: GenericObject<FieldValidator>;
43
- offline_enabled: boolean;
44
- allow_multiple_responses: boolean;
45
- };
46
- export declare type BlueprintMetadataOptions = {
47
- option_type: string;
48
- values: BlueprintMetadataOption[];
49
- };
50
- export declare type BlueprintMetadataOption = {
51
- value: string;
52
- label: string;
53
- };
1
+ import { FieldValidator } from '../utils/validations.helper';
2
+ import { GenericObject } from './global.types';
3
+ /** JSON file from backend */
4
+ export declare type ChecklistFormJson = {
5
+ blueprint: {
6
+ code: string;
7
+ metadata: BlueprintMetadata;
8
+ structure: BlueprintGroup;
9
+ title: string;
10
+ };
11
+ value: GenericObject;
12
+ };
13
+ /** --------- */
14
+ export declare type BlueprintGroup = {
15
+ type: 'group';
16
+ extra: GenericObject;
17
+ styling: string[];
18
+ name: string;
19
+ repeatable: boolean;
20
+ required: boolean;
21
+ title: string | null;
22
+ children: (BlueprintGroup | BlueprintField)[];
23
+ };
24
+ export declare type BlueprintField = {
25
+ type: 'field';
26
+ extra: GenericObject;
27
+ styling: string[];
28
+ name: string;
29
+ repeatable: boolean;
30
+ required: boolean;
31
+ input_type: 'text' | 'likert_scale' | 'bool' | 'number' | 'number-integer' | 'number-float';
32
+ label: string;
33
+ validations: string[];
34
+ help_text: string;
35
+ placeholder: string;
36
+ default_value: null;
37
+ options_key: null;
38
+ };
39
+ /** Metadata for blueprint structure */
40
+ export declare type BlueprintMetadata = {
41
+ options: GenericObject<BlueprintMetadataOptions>;
42
+ validations: GenericObject<FieldValidator>;
43
+ offline_enabled: boolean;
44
+ allow_multiple_responses: boolean;
45
+ };
46
+ export declare type BlueprintMetadataOptions = {
47
+ option_type: string;
48
+ values: BlueprintMetadataOption[];
49
+ };
50
+ export declare type BlueprintMetadataOption = {
51
+ value: string;
52
+ label: string;
53
+ };
@@ -1,4 +1,4 @@
1
- export declare type GenericObject<T = any> = {
2
- [key: string]: T;
3
- };
4
- export declare type Callback = (...args: any) => void;
1
+ export declare type GenericObject<T = any> = {
2
+ [key: string]: T;
3
+ };
4
+ export declare type Callback = (...args: any) => void;
@@ -1,10 +1,10 @@
1
- export interface IDialog<D> {
2
- dialog: string;
3
- dialogData?: D;
4
- readonly?: boolean;
5
- }
6
- export interface IDialogResponse<R> {
7
- response?: R;
8
- confirmed: boolean;
9
- }
10
- export declare function openDialog<D, R = any>({ dialog, dialogData, readonly }: IDialog<D>): Promise<IDialogResponse<R>>;
1
+ export interface IDialog<D> {
2
+ dialog: string;
3
+ dialogData?: D;
4
+ readonly?: boolean;
5
+ }
6
+ export interface IDialogResponse<R> {
7
+ response?: R;
8
+ confirmed: boolean;
9
+ }
10
+ export declare function openDialog<D, R = any>({ dialog, dialogData, readonly }: IDialog<D>): Promise<IDialogResponse<R>>;
@@ -1,21 +1,21 @@
1
- export function openDialog({ dialog, dialogData, readonly }) {
2
- return new Promise((resolve, reject) => {
3
- const dialogElement = document.createElement(dialog);
4
- const body = document.querySelector('body');
5
- if (body) {
6
- body.appendChild(dialogElement);
7
- }
8
- else {
9
- reject(new Error('Body not exist'));
10
- }
11
- dialogElement.dialogData = dialogData;
12
- if (readonly) {
13
- dialogElement.readonly = readonly;
14
- }
15
- dialogElement.addEventListener('response', (e) => {
16
- const event = e;
17
- resolve(event.detail);
18
- dialogElement.remove();
19
- });
20
- });
21
- }
1
+ export function openDialog({ dialog, dialogData, readonly }) {
2
+ return new Promise((resolve, reject) => {
3
+ const dialogElement = document.createElement(dialog);
4
+ const body = document.querySelector('body');
5
+ if (body) {
6
+ body.appendChild(dialogElement);
7
+ }
8
+ else {
9
+ reject(new Error('Body not exist'));
10
+ }
11
+ dialogElement.dialogData = dialogData;
12
+ if (readonly) {
13
+ dialogElement.readonly = readonly;
14
+ }
15
+ dialogElement.addEventListener('response', (e) => {
16
+ const event = e;
17
+ resolve(event.detail);
18
+ dialogElement.remove();
19
+ });
20
+ });
21
+ }
@@ -1 +1 @@
1
- export declare function fireEvent(el: HTMLElement, eventName: string, detail?: any): void;
1
+ export declare function fireEvent(el: HTMLElement, eventName: string, detail?: any): void;
@@ -1,7 +1,7 @@
1
- export function fireEvent(el, eventName, detail) {
2
- el.dispatchEvent(new CustomEvent(eventName, {
3
- detail,
4
- bubbles: true,
5
- composed: true
6
- }));
7
- }
1
+ export function fireEvent(el, eventName, detail) {
2
+ el.dispatchEvent(new CustomEvent(eventName, {
3
+ detail,
4
+ bubbles: true,
5
+ composed: true
6
+ }));
7
+ }
@@ -1,26 +1,26 @@
1
- export declare enum Validations {
2
- MAX_LENGTH = "max_length",
3
- REGEX = "regex",
4
- LOWER_THAN = "lt",
5
- GREATER_THAN = "gt"
6
- }
7
- export declare type MaxLengthValidation = {
8
- name: Validations.MAX_LENGTH;
9
- [Validations.MAX_LENGTH]: string;
10
- };
11
- export declare type RegexValidation = {
12
- name: Validations.REGEX;
13
- [Validations.REGEX]: string;
14
- };
15
- export declare type GreaterValidation = {
16
- name: Validations.GREATER_THAN;
17
- [Validations.GREATER_THAN]: string;
18
- allow_equality: boolean;
19
- };
20
- export declare type LowerValidation = {
21
- name: Validations.LOWER_THAN;
22
- [Validations.LOWER_THAN]: string;
23
- allow_equality: boolean;
24
- };
25
- export declare type FieldValidator = MaxLengthValidation | RegexValidation | GreaterValidation | LowerValidation;
26
- export declare function validate(validators: FieldValidator[], value: any): string | null;
1
+ export declare enum Validations {
2
+ MAX_LENGTH = "max_length",
3
+ REGEX = "regex",
4
+ LOWER_THAN = "lt",
5
+ GREATER_THAN = "gt"
6
+ }
7
+ export declare type MaxLengthValidation = {
8
+ name: Validations.MAX_LENGTH;
9
+ [Validations.MAX_LENGTH]: string;
10
+ };
11
+ export declare type RegexValidation = {
12
+ name: Validations.REGEX;
13
+ [Validations.REGEX]: string;
14
+ };
15
+ export declare type GreaterValidation = {
16
+ name: Validations.GREATER_THAN;
17
+ [Validations.GREATER_THAN]: string;
18
+ allow_equality: boolean;
19
+ };
20
+ export declare type LowerValidation = {
21
+ name: Validations.LOWER_THAN;
22
+ [Validations.LOWER_THAN]: string;
23
+ allow_equality: boolean;
24
+ };
25
+ export declare type FieldValidator = MaxLengthValidation | RegexValidation | GreaterValidation | LowerValidation;
26
+ export declare function validate(validators: FieldValidator[], value: any): string | null;
@@ -1,35 +1,35 @@
1
- export var Validations;
2
- (function (Validations) {
3
- Validations["MAX_LENGTH"] = "max_length";
4
- Validations["REGEX"] = "regex";
5
- Validations["LOWER_THAN"] = "lt";
6
- Validations["GREATER_THAN"] = "gt";
7
- })(Validations || (Validations = {}));
8
- export function validate(validators, value) {
9
- let message = null;
10
- for (const validator of validators) {
11
- message = checkValidation(validator, value);
12
- if (message) {
13
- break;
14
- }
15
- }
16
- return message;
17
- }
18
- function checkValidation(validation, value) {
19
- switch (validation.name) {
20
- case Validations.MAX_LENGTH:
21
- const maxLength = Number(validation[Validations.MAX_LENGTH]);
22
- return String(value).length < maxLength ? null : `Text must be less than ${maxLength} character`;
23
- case Validations.REGEX:
24
- // TODO: Implements Regex validation
25
- return null;
26
- case Validations.GREATER_THAN:
27
- const greaterThan = Number(validation[Validations.GREATER_THAN]) - Number(validation.allow_equality);
28
- return Number(value) > greaterThan ? null : `Number must be greater than ${greaterThan} character`;
29
- case Validations.LOWER_THAN:
30
- const lowerThan = Number(validation[Validations.LOWER_THAN]) + Number(validation.allow_equality);
31
- return Number(value) < lowerThan ? null : `Number must be lower than ${lowerThan} character`;
32
- default:
33
- return null;
34
- }
35
- }
1
+ export var Validations;
2
+ (function (Validations) {
3
+ Validations["MAX_LENGTH"] = "max_length";
4
+ Validations["REGEX"] = "regex";
5
+ Validations["LOWER_THAN"] = "lt";
6
+ Validations["GREATER_THAN"] = "gt";
7
+ })(Validations || (Validations = {}));
8
+ export function validate(validators, value) {
9
+ let message = null;
10
+ for (const validator of validators) {
11
+ message = checkValidation(validator, value);
12
+ if (message) {
13
+ break;
14
+ }
15
+ }
16
+ return message;
17
+ }
18
+ function checkValidation(validation, value) {
19
+ switch (validation.name) {
20
+ case Validations.MAX_LENGTH:
21
+ const maxLength = Number(validation[Validations.MAX_LENGTH]);
22
+ return String(value).length < maxLength ? null : `Text must be less than ${maxLength} character`;
23
+ case Validations.REGEX:
24
+ // TODO: Implements Regex validation
25
+ return null;
26
+ case Validations.GREATER_THAN:
27
+ const greaterThan = Number(validation[Validations.GREATER_THAN]) - Number(validation.allow_equality);
28
+ return Number(value) > greaterThan ? null : `Number must be greater than ${greaterThan} character`;
29
+ case Validations.LOWER_THAN:
30
+ const lowerThan = Number(validation[Validations.LOWER_THAN]) + Number(validation.allow_equality);
31
+ return Number(value) < lowerThan ? null : `Number must be lower than ${lowerThan} character`;
32
+ default:
33
+ return null;
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unicef-polymer/etools-form-builder",
3
3
  "description": "Etools FM Form Builder components",
4
- "version": "0.1.25",
4
+ "version": "1.0.1",
5
5
  "contributors": [
6
6
  "eTools Team"
7
7
  ],
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "scripts": {
16
16
  "build": "tsc --skipLibCheck",
17
- "lint": "./node_modules/eslint/bin/eslint.js 'src/**'",
17
+ "lint": "eslint src/",
18
18
  "prepare": "rm -rf ./dist && npm run build",
19
19
  "prepublishOnly": "npm run lint"
20
20
  },
@@ -27,12 +27,12 @@
27
27
  "@polymer/paper-radio-group": "^3.0.1",
28
28
  "@polymer/paper-toast": "^3.0.1",
29
29
  "@types/ramda": "^0.26.43",
30
- "@unicef-polymer/etools-dialog": "^4.2.2",
31
- "@unicef-polymer/etools-dropdown": "^3.4.0",
30
+ "@unicef-polymer/etools-dialog": "5.0.0-rc.2",
31
+ "@unicef-polymer/etools-dropdown": "^3.7.6",
32
32
  "@unicef-polymer/etools-upload": "^3.5.0",
33
- "@webcomponents/webcomponentsjs": "^2.5.0",
33
+ "@webcomponents/webcomponentsjs": "^2.6.0",
34
34
  "lit-element": "^2.4.0",
35
- "lit-translate": "^1.1.20",
35
+ "lit-translate": "^1.2.1",
36
36
  "ramda": "^0.27.1",
37
37
  "web-animations-js": "^2.3.2"
38
38
  },
@@ -46,7 +46,7 @@
46
46
  "eslint-plugin-lit": "^1.2.4",
47
47
  "eslint-plugin-prettier": "^3.1.3",
48
48
  "minimist": ">=0.2.1",
49
- "prettier": "^2.2.0",
49
+ "prettier": "~2.2.0",
50
50
  "typescript": "^3.9.7"
51
51
  }
52
52
  }