@unicef-polymer/etools-form-builder 3.2.3 → 3.2.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.
Files changed (41) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +1 -1
  3. package/dist/form-attachments-popup/form-attachments-popup.js +135 -135
  4. package/dist/form-fields/abstract-field-base.class.js +100 -100
  5. package/dist/form-fields/field-renderer-component.js +198 -166
  6. package/dist/form-fields/index.d.ts +2 -0
  7. package/dist/form-fields/index.js +2 -0
  8. package/dist/form-fields/repeatable-fields/repeatable-attachment-field.js +111 -111
  9. package/dist/form-fields/repeatable-fields/repeatable-base-field.js +22 -22
  10. package/dist/form-fields/repeatable-fields/repeatable-choice-field.d.ts +15 -0
  11. package/dist/form-fields/repeatable-fields/repeatable-choice-field.js +123 -0
  12. package/dist/form-fields/repeatable-fields/repeatable-number-field.js +19 -19
  13. package/dist/form-fields/repeatable-fields/repeatable-scale-field.js +57 -57
  14. package/dist/form-fields/repeatable-fields/repeatable-text-field.js +19 -19
  15. package/dist/form-fields/single-fields/attachment-field.js +13 -13
  16. package/dist/form-fields/single-fields/boolean-field.js +16 -16
  17. package/dist/form-fields/single-fields/choice-field.d.ts +17 -0
  18. package/dist/form-fields/single-fields/choice-field.js +121 -0
  19. package/dist/form-fields/single-fields/number-field.js +20 -20
  20. package/dist/form-fields/single-fields/scale-field.js +58 -58
  21. package/dist/form-fields/single-fields/text-field.js +30 -30
  22. package/dist/form-groups/form-abstract-group.d.ts +2 -1
  23. package/dist/form-groups/form-abstract-group.js +130 -129
  24. package/dist/form-groups/form-card.js +30 -30
  25. package/dist/form-groups/form-collapsed-card.js +34 -34
  26. package/dist/lib/additional-components/confirmation-dialog.js +20 -20
  27. package/dist/lib/additional-components/etools-fb-card.js +144 -144
  28. package/dist/lib/styles/attachments.styles.js +61 -61
  29. package/dist/lib/styles/card-styles.js +147 -147
  30. package/dist/lib/styles/dialog.styles.js +83 -83
  31. package/dist/lib/styles/elevation-styles.js +46 -46
  32. package/dist/lib/styles/flex-layout-classes.js +316 -316
  33. package/dist/lib/styles/form-builder-card.styles.js +53 -53
  34. package/dist/lib/styles/page-layout-styles.js +198 -198
  35. package/dist/lib/styles/shared-styles.js +61 -61
  36. package/dist/lib/types/form-builder.types.d.ts +1 -1
  37. package/dist/rich-editor/rich-action.js +34 -34
  38. package/dist/rich-editor/rich-text.js +64 -64
  39. package/dist/rich-editor/rich-toolbar.js +125 -125
  40. package/dist/rich-editor/rich-viewer.js +21 -21
  41. package/package.json +52 -52
@@ -14,16 +14,16 @@ let RichAction = class RichAction extends LitElement {
14
14
  }
15
15
  render() {
16
16
  const hasItems = this.values.length > 0;
17
- return html `<section style="color:${this.color}">
17
+ return html `<section style="color:${this.color}">
18
18
  ${hasItems
19
- ? html ` <etools-dropdown
20
- option-label="name"
21
- option-value="value"
22
- .options="${this.values}"
23
- .selected="${this.selectedValue || this.values[0].value}"
24
- dynamic-align
25
- hide-search
26
- trigger-value-change-event
19
+ ? html ` <etools-dropdown
20
+ option-label="name"
21
+ option-value="value"
22
+ .options="${this.values}"
23
+ .selected="${this.selectedValue || this.values[0].value}"
24
+ dynamic-align
25
+ hide-search
26
+ trigger-value-change-event
27
27
  @etools-selected-item-changed="${({ detail }) => {
28
28
  if (detail === undefined || detail.selectedItem === null) {
29
29
  return;
@@ -35,12 +35,12 @@ let RichAction = class RichAction extends LitElement {
35
35
  else {
36
36
  editorCommand(this.command, this.selectedValue);
37
37
  }
38
- }}"
39
- >
38
+ }}"
39
+ >
40
40
  </etools-dropdown>`
41
- : html `<etools-icon-button
42
- ?active="${this.active}"
43
- name="${this.icon}"
41
+ : html `<etools-icon-button
42
+ ?active="${this.active}"
43
+ name="${this.icon}"
44
44
  @click=${() => {
45
45
  if (this.command) {
46
46
  editorCommand(this.command, this.value);
@@ -51,29 +51,29 @@ let RichAction = class RichAction extends LitElement {
51
51
  composed: true
52
52
  }));
53
53
  }
54
- }}
55
- ></etools-icon-button>`}
56
- <div><slot></slot></div>
54
+ }}
55
+ ></etools-icon-button>`}
56
+ <div><slot></slot></div>
57
57
  </section>`;
58
58
  }
59
59
  };
60
- RichAction.styles = css `
61
- section {
62
- height: 100%;
63
- display: flex;
64
- flex-direction: row;
65
- flex-wrap: wrap;
66
- align-items: center;
67
- }
68
- etools-icon-button {
69
- cursor: pointer;
70
- width: 12px;
71
- padding: 0px 8px;
72
- }
73
- etools-dropdown {
74
- min-width: 140px;
75
- margin-block-end: 2px;
76
- }
60
+ RichAction.styles = css `
61
+ section {
62
+ height: 100%;
63
+ display: flex;
64
+ flex-direction: row;
65
+ flex-wrap: wrap;
66
+ align-items: center;
67
+ }
68
+ etools-icon-button {
69
+ cursor: pointer;
70
+ width: 12px;
71
+ padding: 0px 8px;
72
+ }
73
+ etools-dropdown {
74
+ min-width: 140px;
75
+ margin-block-end: 2px;
76
+ }
77
77
  `;
78
78
  __decorate([
79
79
  property({ type: String })
@@ -105,12 +105,12 @@ let RichText = class RichText extends LitElement {
105
105
  }
106
106
  render() {
107
107
  const { selection, readonly, node } = this;
108
- return html `<main>
109
- <rich-toolbar
110
- part="rich-toolbar"
111
- ?hidden="${this.readonly}"
112
- .selection="${selection}"
113
- .node="${node}"
108
+ return html `<main>
109
+ <rich-toolbar
110
+ part="rich-toolbar"
111
+ ?hidden="${this.readonly}"
112
+ .selection="${selection}"
113
+ .node="${node}"
114
114
  @set-content=${(e) => {
115
115
  var _a;
116
116
  const event = e;
@@ -119,12 +119,12 @@ let RichText = class RichText extends LitElement {
119
119
  const root = doc.querySelector('body');
120
120
  this.node.innerHTML = (_a = root === null || root === void 0 ? void 0 : root.innerHTML) !== null && _a !== void 0 ? _a : '';
121
121
  this.requestUpdate();
122
- }}
123
- ></rich-toolbar>
124
- <rich-viewer
125
- part="rich-viewer"
126
- ?readonly="${readonly}"
127
- .value="${this.value}"
122
+ }}
123
+ ></rich-toolbar>
124
+ <rich-viewer
125
+ part="rich-viewer"
126
+ ?readonly="${readonly}"
127
+ .value="${this.value}"
128
128
  @selection=${(e) => {
129
129
  const event = e;
130
130
  this.selection = event.detail.selection;
@@ -135,10 +135,10 @@ let RichText = class RichText extends LitElement {
135
135
  sanitizedHTML = sanitizedHTML.replace(/<!--[\s\S]*?-->/g, '');
136
136
  sanitizedHTML = DOMPurify.sanitize(sanitizedHTML, this.clean);
137
137
  fireEvent(this, 'editor-changed', { value: sanitizedHTML });
138
- }}
139
- .node="${node}"
140
- >
141
- </rich-viewer>
138
+ }}
139
+ .node="${node}"
140
+ >
141
+ </rich-viewer>
142
142
  </main>`;
143
143
  }
144
144
  firstUpdated() {
@@ -156,54 +156,54 @@ let RichText = class RichText extends LitElement {
156
156
  }
157
157
  }
158
158
  };
159
- RichText.styles = css `
160
- :host {
161
- --rich-color: black;
162
- --rich-background: white;
163
- --rich-action-active-color: red;
164
- --icon-size: 24px;
165
- border: solid 1px var(--rich-border-color, #eeeeee);
166
- background-color: #ffffff;
167
- width: 100%;
168
- }
169
- main {
170
- height: 100%;
171
- width: 100%;
172
- display: grid;
173
- grid-template-rows: 1fr auto;
174
- grid-template-columns: 1fr;
175
- grid-template-areas:
176
- 'viewer'
177
- 'toolbar';
178
- }
179
-
180
- rich-toolbar {
181
- grid-area: toolbar;
182
- width: 100%;
183
- background-color: var(--rich-toolbar-background, #ffffff);
184
- color: var(--rich-color);
185
- border-bottom: 1px solid var(--rich-toolbar-border-color, #eeeeee);
186
- }
187
-
188
- rich-viewer {
189
- grid-area: viewer;
190
- flex: 1;
191
- width: 100%;
192
- min-height: 40px;
193
- overflow-y: auto;
194
- background-color: var(--rich-background);
195
- color: var(--rich-color);
196
- }
197
- main {
198
- grid-template-rows: auto 1fr;
199
- grid-template-areas:
200
- 'toolbar'
201
- 'viewer';
202
- }
203
- rich-toolbar {
204
- border-top: none;
205
- border-bottom: 1px solid var(--rich-color);
206
- }
159
+ RichText.styles = css `
160
+ :host {
161
+ --rich-color: black;
162
+ --rich-background: white;
163
+ --rich-action-active-color: red;
164
+ --icon-size: 24px;
165
+ border: solid 1px var(--rich-border-color, #eeeeee);
166
+ background-color: #ffffff;
167
+ width: 100%;
168
+ }
169
+ main {
170
+ height: 100%;
171
+ width: 100%;
172
+ display: grid;
173
+ grid-template-rows: 1fr auto;
174
+ grid-template-columns: 1fr;
175
+ grid-template-areas:
176
+ 'viewer'
177
+ 'toolbar';
178
+ }
179
+
180
+ rich-toolbar {
181
+ grid-area: toolbar;
182
+ width: 100%;
183
+ background-color: var(--rich-toolbar-background, #ffffff);
184
+ color: var(--rich-color);
185
+ border-bottom: 1px solid var(--rich-toolbar-border-color, #eeeeee);
186
+ }
187
+
188
+ rich-viewer {
189
+ grid-area: viewer;
190
+ flex: 1;
191
+ width: 100%;
192
+ min-height: 40px;
193
+ overflow-y: auto;
194
+ background-color: var(--rich-background);
195
+ color: var(--rich-color);
196
+ }
197
+ main {
198
+ grid-template-rows: auto 1fr;
199
+ grid-template-areas:
200
+ 'toolbar'
201
+ 'viewer';
202
+ }
203
+ rich-toolbar {
204
+ border-top: none;
205
+ border-bottom: 1px solid var(--rich-color);
206
+ }
207
207
  `;
208
208
  __decorate([
209
209
  property({ type: Object, hasChanged: () => true })
@@ -8,100 +8,100 @@ import { getTranslation } from '../lib/utils/translate';
8
8
  let RichToolbar = class RichToolbar extends LitElement {
9
9
  render() {
10
10
  const tags = this.getTags();
11
- return html `<header>
12
- <rich-action icon="editor:format-bold" command="bold" ?active=${tags.includes('b')}></rich-action>
13
- <rich-action icon="editor:format-italic" command="italic" ?active=${tags.includes('i')}></rich-action>
14
- <rich-action icon="editor:format-underlined" command="underline" ?active=${tags.includes('u')}></rich-action>
15
- <rich-action
16
- icon="editor:format-align-left"
17
- command="justifyleft"
18
- ?active=${tags.includes('text-align-left')}
19
- ></rich-action>
20
- <rich-action
21
- icon="editor:format-align-center"
22
- command="justifycenter"
23
- ?active=${tags.includes('text-align-center')}
24
- ></rich-action>
25
- <rich-action
26
- icon="editor:format-align-right"
27
- command="justifyright"
28
- ?active=${tags.includes('text-align-right')}
29
- ></rich-action>
30
- <rich-action
31
- icon="editor:format-list-numbered"
32
- command="insertorderedlist"
33
- ?active=${tags.includes('ol')}
34
- ></rich-action>
35
- <rich-action
36
- icon="editor:format-list-bulleted"
37
- command="insertunorderedlist"
38
- ?active=${tags.includes('ul')}
39
- ></rich-action>
40
- <rich-action
41
- icon="format_quote"
42
- command="formatblock"
43
- value="blockquote"
44
- ?active=${tags.includes('blockquote')}
45
- ></rich-action>
46
- <!-- <rich-action icon="format_indent_decrease" command="outdent"></rich-action>
47
- <rich-action icon="format_indent_increase" command="indent"></rich-action> -->
48
- <rich-action
49
- icon="editor:add-link"
50
- ?active=${tags.includes('a')}
11
+ return html `<header>
12
+ <rich-action icon="editor:format-bold" command="bold" ?active=${tags.includes('b')}></rich-action>
13
+ <rich-action icon="editor:format-italic" command="italic" ?active=${tags.includes('i')}></rich-action>
14
+ <rich-action icon="editor:format-underlined" command="underline" ?active=${tags.includes('u')}></rich-action>
15
+ <rich-action
16
+ icon="editor:format-align-left"
17
+ command="justifyleft"
18
+ ?active=${tags.includes('text-align-left')}
19
+ ></rich-action>
20
+ <rich-action
21
+ icon="editor:format-align-center"
22
+ command="justifycenter"
23
+ ?active=${tags.includes('text-align-center')}
24
+ ></rich-action>
25
+ <rich-action
26
+ icon="editor:format-align-right"
27
+ command="justifyright"
28
+ ?active=${tags.includes('text-align-right')}
29
+ ></rich-action>
30
+ <rich-action
31
+ icon="editor:format-list-numbered"
32
+ command="insertorderedlist"
33
+ ?active=${tags.includes('ol')}
34
+ ></rich-action>
35
+ <rich-action
36
+ icon="editor:format-list-bulleted"
37
+ command="insertunorderedlist"
38
+ ?active=${tags.includes('ul')}
39
+ ></rich-action>
40
+ <rich-action
41
+ icon="format_quote"
42
+ command="formatblock"
43
+ value="blockquote"
44
+ ?active=${tags.includes('blockquote')}
45
+ ></rich-action>
46
+ <!-- <rich-action icon="format_indent_decrease" command="outdent"></rich-action>
47
+ <rich-action icon="format_indent_increase" command="indent"></rich-action> -->
48
+ <rich-action
49
+ icon="editor:add-link"
50
+ ?active=${tags.includes('a')}
51
51
  @action=${() => {
52
52
  const newLink = prompt('Write the URL here', 'https://');
53
53
  // Check if valid url
54
54
  if (newLink && newLink.match(/^(http|https):\/\/[^ "]+$/)) {
55
55
  editorCommand('createlink', newLink);
56
56
  }
57
- }}
58
- >
59
- </rich-action>
60
- <rich-action icon="editor:unlink" command="unlink"></rich-action>
61
- <rich-action
62
- icon="editor:format-color-text"
63
- .color="${this.formatColor}"
64
- @action=${() => editorCommand('forecolor', this.formatColor)}
65
- >
66
- <etools-icon-button
67
- class="arrow-icon"
68
- name="arrow-drop-down"
69
- @click="${() => this.fgColorInput.click()}"
70
- ></etools-icon-button>
71
- <input
72
- type="color"
73
- id="fg-color"
57
+ }}
58
+ >
59
+ </rich-action>
60
+ <rich-action icon="editor:unlink" command="unlink"></rich-action>
61
+ <rich-action
62
+ icon="editor:format-color-text"
63
+ .color="${this.formatColor}"
64
+ @action=${() => editorCommand('forecolor', this.formatColor)}
65
+ >
66
+ <etools-icon-button
67
+ class="arrow-icon"
68
+ name="arrow-drop-down"
69
+ @click="${() => this.fgColorInput.click()}"
70
+ ></etools-icon-button>
71
+ <input
72
+ type="color"
73
+ id="fg-color"
74
74
  @input=${(e) => {
75
75
  const input = e.target;
76
76
  this.formatColor = input.value;
77
77
  editorCommand('forecolor', input.value);
78
- }}
79
- />
80
- </rich-action>
81
- <rich-action
82
- icon="editor:background-color"
83
- .color="${this.backgroundColor}"
84
- @action=${() => editorCommand('backcolor', this.backgroundColor)}
85
- >
86
- <etools-icon-button
87
- class="arrow-icon"
88
- name="arrow-drop-down"
89
- @click="${() => this.bdColorInput.click()}"
90
- ></etools-icon-button>
91
- <input
92
- type="color"
93
- id="bd-color"
78
+ }}
79
+ />
80
+ </rich-action>
81
+ <rich-action
82
+ icon="editor:background-color"
83
+ .color="${this.backgroundColor}"
84
+ @action=${() => editorCommand('backcolor', this.backgroundColor)}
85
+ >
86
+ <etools-icon-button
87
+ class="arrow-icon"
88
+ name="arrow-drop-down"
89
+ @click="${() => this.bdColorInput.click()}"
90
+ ></etools-icon-button>
91
+ <input
92
+ type="color"
93
+ id="bd-color"
94
94
  @input=${(e) => {
95
95
  const input = e.target;
96
96
  this.backgroundColor = input.value;
97
97
  editorCommand('backcolor', input.value);
98
- }}
99
- />
100
- </rich-action>
101
- <rich-action
102
- icon="title"
103
- command="formatblock"
104
- .selectedValue="${this.selectedFormatBlock}"
98
+ }}
99
+ />
100
+ </rich-action>
101
+ <rich-action
102
+ icon="title"
103
+ command="formatblock"
104
+ .selectedValue="${this.selectedFormatBlock}"
105
105
  .values=${[
106
106
  { name: getTranslation(this.language, 'NORMAL_TEXT'), value: '--' },
107
107
  { name: getTranslation(this.language, 'HEADING1'), value: 'h1' },
@@ -110,12 +110,12 @@ let RichToolbar = class RichToolbar extends LitElement {
110
110
  { name: getTranslation(this.language, 'HEADING4'), value: 'h4' },
111
111
  { name: getTranslation(this.language, 'PARAGRAPH'), value: 'p' },
112
112
  { name: getTranslation(this.language, 'PRE_FORMATTED'), value: 'pre' }
113
- ]}
114
- ></rich-action>
115
- <rich-action
116
- icon="editor:format-size"
117
- command="fontsize"
118
- .selectedValue="${this.selectedFontSize}"
113
+ ]}
114
+ ></rich-action>
115
+ <rich-action
116
+ icon="editor:format-size"
117
+ command="fontsize"
118
+ .selectedValue="${this.selectedFontSize}"
119
119
  .values=${[
120
120
  { name: getTranslation(this.language, 'FONT_SIZE'), value: '--' },
121
121
  { name: getTranslation(this.language, 'VERY_SMALL'), value: '1' },
@@ -123,14 +123,14 @@ let RichToolbar = class RichToolbar extends LitElement {
123
123
  { name: getTranslation(this.language, 'NORMAL'), value: '3' },
124
124
  { name: getTranslation(this.language, 'MEDIUM_LARGE'), value: '4' },
125
125
  { name: getTranslation(this.language, 'LARGE'), value: '5' }
126
- ]}
127
- ></rich-action>
128
- <rich-action icon="undo" command="undo"></rich-action>
129
- <rich-action icon="redo" command="redo"></rich-action>
130
- <rich-action icon="editor:format-clear" command="removeFormat"></rich-action>
131
- <!-- <rich-action icon="content_cut" command="cut"></rich-action> -->
132
- <!-- <rich-action icon="content_copy" command="copy"></rich-action>
133
- <rich-action icon="content_paste" command="paste"></rich-action> -->
126
+ ]}
127
+ ></rich-action>
128
+ <rich-action icon="undo" command="undo"></rich-action>
129
+ <rich-action icon="redo" command="redo"></rich-action>
130
+ <rich-action icon="editor:format-clear" command="removeFormat"></rich-action>
131
+ <!-- <rich-action icon="content_cut" command="cut"></rich-action> -->
132
+ <!-- <rich-action icon="content_copy" command="copy"></rich-action>
133
+ <rich-action icon="content_paste" command="paste"></rich-action> -->
134
134
  </header>`;
135
135
  }
136
136
  constructor() {
@@ -217,37 +217,37 @@ let RichToolbar = class RichToolbar extends LitElement {
217
217
  return tags;
218
218
  }
219
219
  };
220
- RichToolbar.styles = css `
221
- header {
222
- width: 100%;
223
- display: flex;
224
- flex-direction: row;
225
- align-items: flex-end;
226
- justify-content: flex-start;
227
- padding-inline-start: 12px;
228
- flex-wrap: wrap;
229
- }
230
- input[type='color'] {
231
- -webkit-appearance: none;
232
- border: none;
233
- width: 0;
234
- height: 0;
235
- }
236
- input[type='color']::-webkit-color-swatch-wrapper {
237
- padding: 0;
238
- }
239
- input[type='color']::-webkit-color-swatch {
240
- border: none;
241
- }
242
- rich-action {
243
- margin: 2px 4px 2px 2px;
244
- }
245
- rich-action[active] {
246
- background-color: #e8e8e8;
247
- }
248
- .arrow-icon {
249
- margin-left: -6px;
250
- }
220
+ RichToolbar.styles = css `
221
+ header {
222
+ width: 100%;
223
+ display: flex;
224
+ flex-direction: row;
225
+ align-items: flex-end;
226
+ justify-content: flex-start;
227
+ padding-inline-start: 12px;
228
+ flex-wrap: wrap;
229
+ }
230
+ input[type='color'] {
231
+ -webkit-appearance: none;
232
+ border: none;
233
+ width: 0;
234
+ height: 0;
235
+ }
236
+ input[type='color']::-webkit-color-swatch-wrapper {
237
+ padding: 0;
238
+ }
239
+ input[type='color']::-webkit-color-swatch {
240
+ border: none;
241
+ }
242
+ rich-action {
243
+ margin: 2px 4px 2px 2px;
244
+ }
245
+ rich-action[active] {
246
+ background-color: #e8e8e8;
247
+ }
248
+ .arrow-icon {
249
+ margin-left: -6px;
250
+ }
251
251
  `;
252
252
  __decorate([
253
253
  query('#fg-color')
@@ -9,11 +9,11 @@ let RichViewer = class RichViewer extends LitElement {
9
9
  this.value = '';
10
10
  }
11
11
  render() {
12
- return html `<article
13
- id="content"
14
- contenteditable="${this.readonly ? 'false' : 'true'}"
15
- .innerHTML="${this.value}"
16
- @input=${() => this.updateSelection()}
12
+ return html `<article
13
+ id="content"
14
+ contenteditable="${this.readonly ? 'false' : 'true'}"
15
+ .innerHTML="${this.value}"
16
+ @input=${() => this.updateSelection()}
17
17
  ></article>`;
18
18
  }
19
19
  updateSelection() {
@@ -58,22 +58,22 @@ let RichViewer = class RichViewer extends LitElement {
58
58
  }
59
59
  }
60
60
  };
61
- RichViewer.styles = css `
62
- article {
63
- width: calc(100% - 24px);
64
- padding: 12px;
65
- height: auto;
66
- min-height: 60px;
67
- }
68
-
69
- article[contenteditable='true'] {
70
- border: none;
71
- outline: none;
72
- }
73
- blockquote {
74
- margin-inline-start: 8px;
75
- margin-inline-end: 8px;
76
- }
61
+ RichViewer.styles = css `
62
+ article {
63
+ width: calc(100% - 24px);
64
+ padding: 12px;
65
+ height: auto;
66
+ min-height: 60px;
67
+ }
68
+
69
+ article[contenteditable='true'] {
70
+ border: none;
71
+ outline: none;
72
+ }
73
+ blockquote {
74
+ margin-inline-start: 8px;
75
+ margin-inline-end: 8px;
76
+ }
77
77
  `;
78
78
  __decorate([
79
79
  query('#content')