@unicef-polymer/etools-form-builder 2.1.0-rc.6 → 2.1.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 (83) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +1 -1
  3. package/dist/form-attachments-popup/form-attachments-popup.d.ts +85 -85
  4. package/dist/form-attachments-popup/form-attachments-popup.helper.d.ts +8 -8
  5. package/dist/form-attachments-popup/form-attachments-popup.helper.js +14 -14
  6. package/dist/form-attachments-popup/form-attachments-popup.js +248 -248
  7. package/dist/form-attachments-popup/form-attachments-popup.tpl.d.ts +3 -3
  8. package/dist/form-attachments-popup/form-attachments-popup.tpl.js +89 -89
  9. package/dist/form-attachments-popup/index.d.ts +2 -2
  10. package/dist/form-attachments-popup/index.js +2 -2
  11. package/dist/form-fields/abstract-field-base.class.d.ts +28 -28
  12. package/dist/form-fields/abstract-field-base.class.js +176 -176
  13. package/dist/form-fields/field-renderer-component.d.ts +20 -20
  14. package/dist/form-fields/field-renderer-component.js +249 -249
  15. package/dist/form-fields/index.d.ts +12 -12
  16. package/dist/form-fields/index.js +12 -12
  17. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.d.ts +17 -17
  18. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +208 -208
  19. package/dist/form-fields/repeatable-fields/repeatable-base-field.d.ts +20 -20
  20. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +123 -123
  21. package/dist/form-fields/repeatable-fields/repeatable-number-field.d.ts +10 -10
  22. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +66 -66
  23. package/dist/form-fields/repeatable-fields/repeatable-scale-field.d.ts +15 -15
  24. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +108 -108
  25. package/dist/form-fields/repeatable-fields/repeatable-text-field.d.ts +8 -8
  26. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +53 -53
  27. package/dist/form-fields/single-fields/attachment-field.d.ts +16 -16
  28. package/dist/form-fields/single-fields/attachment-field.js +97 -97
  29. package/dist/form-fields/single-fields/base-field.d.ts +11 -11
  30. package/dist/form-fields/single-fields/base-field.js +57 -57
  31. package/dist/form-fields/single-fields/boolean-field.d.ts +8 -8
  32. package/dist/form-fields/single-fields/boolean-field.js +49 -49
  33. package/dist/form-fields/single-fields/number-field.d.ts +10 -10
  34. package/dist/form-fields/single-fields/number-field.js +66 -66
  35. package/dist/form-fields/single-fields/scale-field.d.ts +18 -18
  36. package/dist/form-fields/single-fields/scale-field.js +107 -107
  37. package/dist/form-fields/single-fields/text-field.d.ts +8 -8
  38. package/dist/form-fields/single-fields/text-field.js +54 -54
  39. package/dist/form-groups/form-abstract-group.d.ts +60 -60
  40. package/dist/form-groups/form-abstract-group.js +353 -353
  41. package/dist/form-groups/form-card.d.ts +32 -32
  42. package/dist/form-groups/form-card.js +108 -108
  43. package/dist/form-groups/form-collapsed-card.d.ts +70 -70
  44. package/dist/form-groups/form-collapsed-card.js +253 -253
  45. package/dist/form-groups/index.d.ts +3 -3
  46. package/dist/form-groups/index.js +3 -3
  47. package/dist/index.d.ts +3 -3
  48. package/dist/index.js +3 -3
  49. package/dist/lib/additional-components/confirmation-dialog.d.ts +16 -16
  50. package/dist/lib/additional-components/confirmation-dialog.js +65 -65
  51. package/dist/lib/additional-components/etools-fb-card.d.ts +16 -16
  52. package/dist/lib/additional-components/etools-fb-card.js +215 -215
  53. package/dist/lib/styles/attachments.styles.d.ts +2 -2
  54. package/dist/lib/styles/attachments.styles.js +72 -72
  55. package/dist/lib/styles/card-styles.d.ts +2 -2
  56. package/dist/lib/styles/card-styles.js +154 -154
  57. package/dist/lib/styles/dialog.styles.d.ts +2 -2
  58. package/dist/lib/styles/dialog.styles.js +85 -85
  59. package/dist/lib/styles/elevation-styles.d.ts +9 -9
  60. package/dist/lib/styles/elevation-styles.js +43 -43
  61. package/dist/lib/styles/flex-layout-classes.d.ts +2 -2
  62. package/dist/lib/styles/flex-layout-classes.js +319 -319
  63. package/dist/lib/styles/form-builder-card.styles.d.ts +2 -2
  64. package/dist/lib/styles/form-builder-card.styles.js +49 -49
  65. package/dist/lib/styles/input-styles.d.ts +2 -2
  66. package/dist/lib/styles/input-styles.js +138 -138
  67. package/dist/lib/styles/page-layout-styles.d.ts +2 -2
  68. package/dist/lib/styles/page-layout-styles.js +201 -201
  69. package/dist/lib/styles/shared-styles.d.ts +2 -2
  70. package/dist/lib/styles/shared-styles.js +70 -70
  71. package/dist/lib/types/form-builder.interfaces.d.ts +83 -83
  72. package/dist/lib/types/form-builder.interfaces.js +0 -0
  73. package/dist/lib/types/form-builder.types.d.ts +59 -59
  74. package/dist/lib/types/form-builder.types.js +0 -0
  75. package/dist/lib/types/global.types.d.ts +4 -4
  76. package/dist/lib/types/global.types.js +0 -0
  77. package/dist/lib/utils/dialog.d.ts +10 -10
  78. package/dist/lib/utils/dialog.js +21 -21
  79. package/dist/lib/utils/fire-custom-event.d.ts +1 -1
  80. package/dist/lib/utils/fire-custom-event.js +7 -7
  81. package/dist/lib/utils/validations.helper.d.ts +26 -26
  82. package/dist/lib/utils/validations.helper.js +35 -35
  83. package/package.json +56 -56
@@ -1,123 +1,123 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { css, html, property } from 'lit-element';
8
- import { AbstractFieldBaseClass } from '../abstract-field-base.class';
9
- import { fireEvent } from '../../lib/utils/fire-custom-event';
10
- export class RepeatableBaseField extends AbstractFieldBaseClass {
11
- constructor() {
12
- super(...arguments);
13
- this._errorMessage = [];
14
- this.editedValues = null;
15
- }
16
- set errorMessage(messages) {
17
- this._errorMessage = messages || [];
18
- }
19
- get errorMessage() {
20
- return this.isReadonly ? [] : this._errorMessage;
21
- }
22
- render() {
23
- const values = this.getValues();
24
- return html `
25
- <div class="finding-container">
26
- <div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
27
- <div class="question-control layout vertical center-justified start">
28
- ${values.map((value, index) => html `<div class="layout horizontal center full-width">
29
- ${this.controlTemplate(value, index)}
30
- <iron-icon
31
- icon="close"
32
- ?hidden="${this.isReadonly || values.length < 2}"
33
- @click="${() => this.removeControl(index)}"
34
- ></iron-icon>
35
- </div>`)}
36
- <paper-button class="add-button" ?hidden="${this.isReadonly}" @click="${() => this.addNewField()}">
37
- Add
38
- </paper-button>
39
- </div>
40
- </div>
41
- `;
42
- }
43
- questionTemplate() {
44
- return html `<span class="question-text">${this.questionText}</span>`;
45
- }
46
- valueChanged(newValue, index) {
47
- if (!this.isReadonly) {
48
- this.validateField(newValue, index);
49
- }
50
- else {
51
- this._errorMessage = [];
52
- }
53
- if (this.editedValues && newValue !== this.editedValues[index]) {
54
- this.editedValues[index] = newValue;
55
- this.setValue(this.editedValues);
56
- }
57
- }
58
- setValue(value) {
59
- this.editedValues = value;
60
- this.value = value.filter((value) => Boolean(value));
61
- fireEvent(this, 'value-changed', { value: this.value });
62
- }
63
- validateField(value, index) {
64
- if (this.isArrayData(value)) {
65
- return value.forEach((item, index) => this.validateField(item, index));
66
- }
67
- let errorMessage;
68
- if (this.required && !value && value !== null && typeof value !== 'number') {
69
- errorMessage = 'This field is required!';
70
- }
71
- else {
72
- errorMessage = this.metaValidation(value);
73
- }
74
- const oldError = (this._errorMessage || [])[index] || null;
75
- if (oldError !== errorMessage) {
76
- const errors = this.editedValues.map((_, index) => (this._errorMessage && this._errorMessage[index]) || null);
77
- errors.splice(index, 1, errorMessage);
78
- const newErrors = errors.some((error) => error !== null) ? errors : null;
79
- fireEvent(this, 'error-changed', { error: newErrors });
80
- this._errorMessage = errors;
81
- this.requestUpdate();
82
- }
83
- }
84
- addNewField() {
85
- this.editedValues = [...this.editedValues, null];
86
- }
87
- removeControl(index) {
88
- this.editedValues.splice(index, 1);
89
- this.value = this.editedValues.filter((value) => Boolean(value));
90
- fireEvent(this, 'value-changed', { value: this.value });
91
- this.requestUpdate();
92
- }
93
- getValues() {
94
- if (this.isReadonly) {
95
- this.editedValues = Array.isArray(this.value) && this.value.length ? this.value : [null];
96
- }
97
- else if (!this.editedValues) {
98
- this.editedValues = Array.isArray(this.value) && this.value.length ? this.value : [null];
99
- }
100
- return this.editedValues || [null];
101
- }
102
- isArrayData(value) {
103
- return Array.isArray(value);
104
- }
105
- static get styles() {
106
- // language=CSS
107
- return [
108
- ...AbstractFieldBaseClass.styles,
109
- css `
110
- :host(:not([is-readonly])) .question-control,
111
- :host(:not([is-readonly])) .question {
112
- padding-bottom: 10px;
113
- }
114
- `
115
- ];
116
- }
117
- }
118
- __decorate([
119
- property()
120
- ], RepeatableBaseField.prototype, "_errorMessage", void 0);
121
- __decorate([
122
- property()
123
- ], RepeatableBaseField.prototype, "editedValues", void 0);
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { css, html, property } from 'lit-element';
8
+ import { AbstractFieldBaseClass } from '../abstract-field-base.class';
9
+ import { fireEvent } from '../../lib/utils/fire-custom-event';
10
+ export class RepeatableBaseField extends AbstractFieldBaseClass {
11
+ constructor() {
12
+ super(...arguments);
13
+ this._errorMessage = [];
14
+ this.editedValues = null;
15
+ }
16
+ set errorMessage(messages) {
17
+ this._errorMessage = messages || [];
18
+ }
19
+ get errorMessage() {
20
+ return this.isReadonly ? [] : this._errorMessage;
21
+ }
22
+ render() {
23
+ const values = this.getValues();
24
+ return html `
25
+ <div class="finding-container">
26
+ <div class="question layout start"><slot>${this.questionTemplate()}</slot></div>
27
+ <div class="question-control layout vertical center-justified start">
28
+ ${values.map((value, index) => html `<div class="layout horizontal center full-width">
29
+ ${this.controlTemplate(value, index)}
30
+ <iron-icon
31
+ icon="close"
32
+ ?hidden="${this.isReadonly || values.length < 2}"
33
+ @click="${() => this.removeControl(index)}"
34
+ ></iron-icon>
35
+ </div>`)}
36
+ <paper-button class="add-button" ?hidden="${this.isReadonly}" @click="${() => this.addNewField()}">
37
+ Add
38
+ </paper-button>
39
+ </div>
40
+ </div>
41
+ `;
42
+ }
43
+ questionTemplate() {
44
+ return html `<span class="question-text">${this.questionText}</span>`;
45
+ }
46
+ valueChanged(newValue, index) {
47
+ if (!this.isReadonly) {
48
+ this.validateField(newValue, index);
49
+ }
50
+ else {
51
+ this._errorMessage = [];
52
+ }
53
+ if (this.editedValues && newValue !== this.editedValues[index]) {
54
+ this.editedValues[index] = newValue;
55
+ this.setValue(this.editedValues);
56
+ }
57
+ }
58
+ setValue(value) {
59
+ this.editedValues = value;
60
+ this.value = value.filter((value) => Boolean(value));
61
+ fireEvent(this, 'value-changed', { value: this.value });
62
+ }
63
+ validateField(value, index) {
64
+ if (this.isArrayData(value)) {
65
+ return value.forEach((item, index) => this.validateField(item, index));
66
+ }
67
+ let errorMessage;
68
+ if (this.required && !value && value !== null && typeof value !== 'number') {
69
+ errorMessage = 'This field is required!';
70
+ }
71
+ else {
72
+ errorMessage = this.metaValidation(value);
73
+ }
74
+ const oldError = (this._errorMessage || [])[index] || null;
75
+ if (oldError !== errorMessage) {
76
+ const errors = this.editedValues.map((_, index) => (this._errorMessage && this._errorMessage[index]) || null);
77
+ errors.splice(index, 1, errorMessage);
78
+ const newErrors = errors.some((error) => error !== null) ? errors : null;
79
+ fireEvent(this, 'error-changed', { error: newErrors });
80
+ this._errorMessage = errors;
81
+ this.requestUpdate();
82
+ }
83
+ }
84
+ addNewField() {
85
+ this.editedValues = [...this.editedValues, null];
86
+ }
87
+ removeControl(index) {
88
+ this.editedValues.splice(index, 1);
89
+ this.value = this.editedValues.filter((value) => Boolean(value));
90
+ fireEvent(this, 'value-changed', { value: this.value });
91
+ this.requestUpdate();
92
+ }
93
+ getValues() {
94
+ if (this.isReadonly) {
95
+ this.editedValues = Array.isArray(this.value) && this.value.length ? this.value : [null];
96
+ }
97
+ else if (!this.editedValues) {
98
+ this.editedValues = Array.isArray(this.value) && this.value.length ? this.value : [null];
99
+ }
100
+ return this.editedValues || [null];
101
+ }
102
+ isArrayData(value) {
103
+ return Array.isArray(value);
104
+ }
105
+ static get styles() {
106
+ // language=CSS
107
+ return [
108
+ ...AbstractFieldBaseClass.styles,
109
+ css `
110
+ :host(:not([is-readonly])) .question-control,
111
+ :host(:not([is-readonly])) .question {
112
+ padding-bottom: 10px;
113
+ }
114
+ `
115
+ ];
116
+ }
117
+ }
118
+ __decorate([
119
+ property()
120
+ ], RepeatableBaseField.prototype, "_errorMessage", void 0);
121
+ __decorate([
122
+ property()
123
+ ], RepeatableBaseField.prototype, "editedValues", void 0);
@@ -1,10 +1,10 @@
1
- import { CSSResultArray, TemplateResult } from 'lit-element';
2
- import '@polymer/paper-input/paper-input';
3
- import { RepeatableBaseField } from './repeatable-base-field';
4
- export declare class RepeatableNumberField extends RepeatableBaseField<number> {
5
- isInteger: boolean;
6
- protected controlTemplate(value: number | null, index: number): TemplateResult;
7
- protected valueChanged(newValue: number, index: number): void;
8
- protected customValidation(value: number): string | null;
9
- static get styles(): CSSResultArray;
10
- }
1
+ import { CSSResultArray, TemplateResult } from 'lit-element';
2
+ import '@polymer/paper-input/paper-input';
3
+ import { RepeatableBaseField } from './repeatable-base-field';
4
+ export declare class RepeatableNumberField extends RepeatableBaseField<number> {
5
+ isInteger: boolean;
6
+ protected controlTemplate(value: number | null, index: number): TemplateResult;
7
+ protected valueChanged(newValue: number, index: number): void;
8
+ protected customValidation(value: number): string | null;
9
+ static get styles(): CSSResultArray;
10
+ }
@@ -1,66 +1,66 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { css, customElement, html } from 'lit-element';
8
- import '@polymer/paper-input/paper-input';
9
- import { InputStyles } from '../../lib/styles/input-styles';
10
- import { RepeatableBaseField } from './repeatable-base-field';
11
- import { AbstractFieldBaseClass } from '../abstract-field-base.class';
12
- let RepeatableNumberField = class RepeatableNumberField extends RepeatableBaseField {
13
- constructor() {
14
- super(...arguments);
15
- this.isInteger = false;
16
- }
17
- controlTemplate(value, index) {
18
- return html `
19
- ${InputStyles}
20
- <paper-input
21
- class="no-padding-left"
22
- no-label-float
23
- placeholder="${this.isReadonly ? '—' : this.placeholder}"
24
- .value="${value}"
25
- @value-changed="${({ detail }) => this.valueChanged(detail.value, index)}"
26
- placeholder="&#8212;"
27
- ?invalid="${this.errorMessage[index]}"
28
- error-message="${this.errorMessage[index]}"
29
- ?readonly="${this.isReadonly}"
30
- >
31
- </paper-input>
32
- `;
33
- }
34
- valueChanged(newValue, index) {
35
- const formatted = Number(newValue);
36
- const isNumber = !isNaN(formatted) && `${newValue}` !== '' && `${newValue}` !== 'null';
37
- super.valueChanged(isNumber ? formatted : newValue, index);
38
- }
39
- customValidation(value) {
40
- if (!value) {
41
- return null;
42
- }
43
- if (isNaN(value)) {
44
- return 'Must be a number';
45
- }
46
- const integerValidation = !this.isInteger || value - Math.floor(value) === 0;
47
- return integerValidation ? null : 'Must be an integer';
48
- }
49
- static get styles() {
50
- // language=CSS
51
- return [
52
- ...AbstractFieldBaseClass.styles,
53
- css `
54
- @media (max-width: 380px) {
55
- .no-padding-left {
56
- padding-left: 0;
57
- }
58
- }
59
- `
60
- ];
61
- }
62
- };
63
- RepeatableNumberField = __decorate([
64
- customElement('repeatable-number-field')
65
- ], RepeatableNumberField);
66
- export { RepeatableNumberField };
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { css, customElement, html } from 'lit-element';
8
+ import '@polymer/paper-input/paper-input';
9
+ import { InputStyles } from '../../lib/styles/input-styles';
10
+ import { RepeatableBaseField } from './repeatable-base-field';
11
+ import { AbstractFieldBaseClass } from '../abstract-field-base.class';
12
+ let RepeatableNumberField = class RepeatableNumberField extends RepeatableBaseField {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.isInteger = false;
16
+ }
17
+ controlTemplate(value, index) {
18
+ return html `
19
+ ${InputStyles}
20
+ <paper-input
21
+ class="no-padding-left"
22
+ no-label-float
23
+ placeholder="${this.isReadonly ? '—' : this.placeholder}"
24
+ .value="${value}"
25
+ @value-changed="${({ detail }) => this.valueChanged(detail.value, index)}"
26
+ placeholder="&#8212;"
27
+ ?invalid="${this.errorMessage[index]}"
28
+ error-message="${this.errorMessage[index]}"
29
+ ?readonly="${this.isReadonly}"
30
+ >
31
+ </paper-input>
32
+ `;
33
+ }
34
+ valueChanged(newValue, index) {
35
+ const formatted = Number(newValue);
36
+ const isNumber = !isNaN(formatted) && `${newValue}` !== '' && `${newValue}` !== 'null';
37
+ super.valueChanged(isNumber ? formatted : newValue, index);
38
+ }
39
+ customValidation(value) {
40
+ if (!value) {
41
+ return null;
42
+ }
43
+ if (isNaN(value)) {
44
+ return 'Must be a number';
45
+ }
46
+ const integerValidation = !this.isInteger || value - Math.floor(value) === 0;
47
+ return integerValidation ? null : 'Must be an integer';
48
+ }
49
+ static get styles() {
50
+ // language=CSS
51
+ return [
52
+ ...AbstractFieldBaseClass.styles,
53
+ css `
54
+ @media (max-width: 380px) {
55
+ .no-padding-left {
56
+ padding-left: 0;
57
+ }
58
+ }
59
+ `
60
+ ];
61
+ }
62
+ };
63
+ RepeatableNumberField = __decorate([
64
+ customElement('repeatable-number-field')
65
+ ], RepeatableNumberField);
66
+ export { RepeatableNumberField };
@@ -1,15 +1,15 @@
1
- import { TemplateResult, CSSResultArray } from 'lit-element';
2
- import '@polymer/paper-radio-group/paper-radio-group';
3
- import '@polymer/paper-radio-button/paper-radio-button';
4
- import { PaperRadioButtonElement } from '@polymer/paper-radio-button/paper-radio-button';
5
- import { RepeatableBaseField } from './repeatable-base-field';
6
- import { FieldOption } from '..';
7
- export declare class RepeatableScaleField extends RepeatableBaseField<string | number | null> {
8
- options: (FieldOption | string | number)[];
9
- protected controlTemplate(value: string | null, index: number): TemplateResult;
10
- protected onSelect(item: PaperRadioButtonElement, index: number): void;
11
- protected getLabel(option: FieldOption | string | number): unknown;
12
- protected getValue(option: FieldOption | string | number): unknown;
13
- protected customValidation(): string | null;
14
- static get styles(): CSSResultArray;
15
- }
1
+ import { TemplateResult, CSSResultArray } from 'lit-element';
2
+ import '@polymer/paper-radio-group/paper-radio-group';
3
+ import '@polymer/paper-radio-button/paper-radio-button';
4
+ import { PaperRadioButtonElement } from '@polymer/paper-radio-button/paper-radio-button';
5
+ import { RepeatableBaseField } from './repeatable-base-field';
6
+ import { FieldOption } from '..';
7
+ export declare class RepeatableScaleField extends RepeatableBaseField<string | number | null> {
8
+ options: (FieldOption | string | number)[];
9
+ protected controlTemplate(value: string | null, index: number): TemplateResult;
10
+ protected onSelect(item: PaperRadioButtonElement, index: number): void;
11
+ protected getLabel(option: FieldOption | string | number): unknown;
12
+ protected getValue(option: FieldOption | string | number): unknown;
13
+ protected customValidation(): string | null;
14
+ static get styles(): CSSResultArray;
15
+ }
@@ -1,108 +1,108 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { html, property, css, customElement } from 'lit-element';
8
- import { repeat } from 'lit-html/directives/repeat';
9
- import '@polymer/paper-radio-group/paper-radio-group';
10
- import '@polymer/paper-radio-button/paper-radio-button';
11
- import { InputStyles } from '../../lib/styles/input-styles';
12
- import { RepeatableBaseField } from './repeatable-base-field';
13
- import { AbstractFieldBaseClass } from '../abstract-field-base.class';
14
- let RepeatableScaleField = class RepeatableScaleField extends RepeatableBaseField {
15
- constructor() {
16
- super(...arguments);
17
- this.options = [];
18
- }
19
- controlTemplate(value, index) {
20
- return html `
21
- ${InputStyles}
22
- <div class="container">
23
- <paper-radio-group
24
- class="radio-group"
25
- selected="${value}"
26
- @iron-select="${({ detail }) => this.onSelect(detail.item, index)}"
27
- >
28
- ${repeat(this.options, (option) => html `
29
- <paper-radio-button class="radio-button" name="${this.getValue(option)}">
30
- ${this.getLabel(option)}
31
- </paper-radio-button>
32
- `)}
33
- </paper-radio-group>
34
-
35
- <paper-button
36
- ?hidden="${this.isReadonly}"
37
- @click="${() => this.valueChanged(null, index)}"
38
- class="clear-button"
39
- >
40
- <iron-icon icon="clear"></iron-icon>Clear
41
- </paper-button>
42
- </div>
43
- `;
44
- }
45
- onSelect(item, index) {
46
- const newValue = item.get('name');
47
- this.valueChanged(newValue, index);
48
- }
49
- getLabel(option) {
50
- return typeof option === 'object' ? option.label : option;
51
- }
52
- getValue(option) {
53
- return typeof option === 'object' ? option.value : option;
54
- }
55
- customValidation() {
56
- return null;
57
- }
58
- static get styles() {
59
- // language=CSS
60
- return [
61
- ...AbstractFieldBaseClass.styles,
62
- css `
63
- .container {
64
- position: relative;
65
- min-height: 48px;
66
- display: flex;
67
- align-items: center;
68
- flex-direction: row;
69
- }
70
-
71
- .radio-group {
72
- display: flex;
73
- flex-direction: row;
74
- flex-wrap: wrap;
75
- }
76
-
77
- :host([is-readonly]) paper-radio-group {
78
- pointer-events: none;
79
- opacity: 0.55;
80
- }
81
-
82
- @media (max-width: 1080px) {
83
- .container {
84
- flex-direction: column;
85
- align-items: flex-start;
86
- }
87
- .radio-group {
88
- flex-direction: column;
89
- }
90
- .radio-button {
91
- padding-left: 3px;
92
- }
93
- .clear-button {
94
- margin: 0;
95
- padding-left: 0;
96
- }
97
- }
98
- `
99
- ];
100
- }
101
- };
102
- __decorate([
103
- property({ type: Array })
104
- ], RepeatableScaleField.prototype, "options", void 0);
105
- RepeatableScaleField = __decorate([
106
- customElement('repeatable-scale-field')
107
- ], RepeatableScaleField);
108
- export { RepeatableScaleField };
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, property, css, customElement } from 'lit-element';
8
+ import { repeat } from 'lit-html/directives/repeat';
9
+ import '@polymer/paper-radio-group/paper-radio-group';
10
+ import '@polymer/paper-radio-button/paper-radio-button';
11
+ import { InputStyles } from '../../lib/styles/input-styles';
12
+ import { RepeatableBaseField } from './repeatable-base-field';
13
+ import { AbstractFieldBaseClass } from '../abstract-field-base.class';
14
+ let RepeatableScaleField = class RepeatableScaleField extends RepeatableBaseField {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.options = [];
18
+ }
19
+ controlTemplate(value, index) {
20
+ return html `
21
+ ${InputStyles}
22
+ <div class="container">
23
+ <paper-radio-group
24
+ class="radio-group"
25
+ selected="${value}"
26
+ @iron-select="${({ detail }) => this.onSelect(detail.item, index)}"
27
+ >
28
+ ${repeat(this.options, (option) => html `
29
+ <paper-radio-button class="radio-button" name="${this.getValue(option)}">
30
+ ${this.getLabel(option)}
31
+ </paper-radio-button>
32
+ `)}
33
+ </paper-radio-group>
34
+
35
+ <paper-button
36
+ ?hidden="${this.isReadonly}"
37
+ @click="${() => this.valueChanged(null, index)}"
38
+ class="clear-button"
39
+ >
40
+ <iron-icon icon="clear"></iron-icon>Clear
41
+ </paper-button>
42
+ </div>
43
+ `;
44
+ }
45
+ onSelect(item, index) {
46
+ const newValue = item.get('name');
47
+ this.valueChanged(newValue, index);
48
+ }
49
+ getLabel(option) {
50
+ return typeof option === 'object' ? option.label : option;
51
+ }
52
+ getValue(option) {
53
+ return typeof option === 'object' ? option.value : option;
54
+ }
55
+ customValidation() {
56
+ return null;
57
+ }
58
+ static get styles() {
59
+ // language=CSS
60
+ return [
61
+ ...AbstractFieldBaseClass.styles,
62
+ css `
63
+ .container {
64
+ position: relative;
65
+ min-height: 48px;
66
+ display: flex;
67
+ align-items: center;
68
+ flex-direction: row;
69
+ }
70
+
71
+ .radio-group {
72
+ display: flex;
73
+ flex-direction: row;
74
+ flex-wrap: wrap;
75
+ }
76
+
77
+ :host([is-readonly]) paper-radio-group {
78
+ pointer-events: none;
79
+ opacity: 0.55;
80
+ }
81
+
82
+ @media (max-width: 1080px) {
83
+ .container {
84
+ flex-direction: column;
85
+ align-items: flex-start;
86
+ }
87
+ .radio-group {
88
+ flex-direction: column;
89
+ }
90
+ .radio-button {
91
+ padding-left: 3px;
92
+ }
93
+ .clear-button {
94
+ margin: 0;
95
+ padding-left: 0;
96
+ }
97
+ }
98
+ `
99
+ ];
100
+ }
101
+ };
102
+ __decorate([
103
+ property({ type: Array })
104
+ ], RepeatableScaleField.prototype, "options", void 0);
105
+ RepeatableScaleField = __decorate([
106
+ customElement('repeatable-scale-field')
107
+ ], RepeatableScaleField);
108
+ export { RepeatableScaleField };