@servicetitan/dte-unlayer 0.158.0 → 0.160.0
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/dist/api-core.js +22 -29
- package/dist/api-core.js.map +1 -1
- package/dist/api-custom-tools.js +23 -29
- package/dist/api-custom-tools.js.map +1 -1
- package/dist/business-calendar/BusinessCalendarDrawer.d.ts +19 -0
- package/dist/business-calendar/BusinessCalendarDrawer.d.ts.map +1 -0
- package/dist/business-calendar/BusinessCalendarDrawer.js +41 -0
- package/dist/business-calendar/BusinessCalendarDrawer.js.map +1 -0
- package/dist/business-calendar/business-calendar-requests.d.ts +25 -0
- package/dist/business-calendar/business-calendar-requests.d.ts.map +1 -0
- package/dist/business-calendar/business-calendar-requests.js +46 -0
- package/dist/business-calendar/business-calendar-requests.js.map +1 -0
- package/dist/business-calendar/business-calendar-state.d.ts +22 -0
- package/dist/business-calendar/business-calendar-state.d.ts.map +1 -0
- package/dist/business-calendar/business-calendar-state.js +74 -0
- package/dist/business-calendar/business-calendar-state.js.map +1 -0
- package/dist/business-calendar/useBusinessCalendarRequests.d.ts +15 -0
- package/dist/business-calendar/useBusinessCalendarRequests.d.ts.map +1 -0
- package/dist/business-calendar/useBusinessCalendarRequests.js +30 -0
- package/dist/business-calendar/useBusinessCalendarRequests.js.map +1 -0
- package/dist/display-conditions/ConditionGroup.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroup.js +20 -89
- package/dist/display-conditions/ConditionGroup.js.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.js +2 -70
- package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
- package/dist/display-conditions/ConditionRow.d.ts.map +1 -1
- package/dist/display-conditions/ConditionRow.js +88 -212
- package/dist/display-conditions/ConditionRow.js.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.js +39 -194
- package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
- package/dist/display-conditions/LookupValueControl.js +42 -105
- package/dist/display-conditions/LookupValueControl.js.map +1 -1
- package/dist/display-conditions/SeparatorWithChip.js +1 -10
- package/dist/display-conditions/SeparatorWithChip.js.map +1 -1
- package/dist/display-conditions/constants.js +15 -20
- package/dist/display-conditions/constants.js.map +1 -1
- package/dist/display-conditions/displayConditionController.js +5 -8
- package/dist/display-conditions/displayConditionController.js.map +1 -1
- package/dist/display-conditions/lookupOptionsController.js +16 -16
- package/dist/display-conditions/lookupOptionsController.js.map +1 -1
- package/dist/display-conditions/nunjucks.js +98 -116
- package/dist/display-conditions/nunjucks.js.map +1 -1
- package/dist/display-conditions/schemaDataPoints.js +13 -11
- package/dist/display-conditions/schemaDataPoints.js.map +1 -1
- package/dist/display-conditions/types.js +23 -67
- package/dist/display-conditions/types.js.map +1 -1
- package/dist/display-conditions/useConditionForms.js +38 -56
- package/dist/display-conditions/useConditionForms.js.map +1 -1
- package/dist/display-conditions/useLookupOptions.js +24 -44
- package/dist/display-conditions/useLookupOptions.js.map +1 -1
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.js +42 -155
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.js.map +1 -1
- package/dist/e-sign-offset/ESignOffsetRuleRow.js +12 -73
- package/dist/e-sign-offset/ESignOffsetRuleRow.js.map +1 -1
- package/dist/e-sign-offset/eSignOffsetController.js +5 -8
- package/dist/e-sign-offset/eSignOffsetController.js.map +1 -1
- package/dist/editor-core-source.d.ts +2 -2
- package/dist/editor-core-source.d.ts.map +1 -1
- package/dist/editor-core-source.js +3 -3
- package/dist/editor-core-source.js.map +1 -1
- package/dist/editor-core.js +2 -2
- package/dist/editor-core.js.map +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +56 -118
- package/dist/editor.js.map +1 -1
- package/dist/image-upload-error.js +3 -3
- package/dist/image-upload-error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/loadScript.js +7 -8
- package/dist/loadScript.js.map +1 -1
- package/dist/log.js +2 -3
- package/dist/log.js.map +1 -1
- package/dist/merge-tags.js +18 -17
- package/dist/merge-tags.js.map +1 -1
- package/dist/shared/configs.js +1 -2
- package/dist/shared/configs.js.map +1 -1
- package/dist/shared/const.d.ts +70 -0
- package/dist/shared/const.d.ts.map +1 -1
- package/dist/shared/const.js +13 -4
- package/dist/shared/const.js.map +1 -1
- package/dist/shared/date-calc.js +47 -38
- package/dist/shared/date-calc.js.map +1 -1
- package/dist/shared/e-sign-offset.js +46 -63
- package/dist/shared/e-sign-offset.js.map +1 -1
- package/dist/shared/edit-icon.js +0 -1
- package/dist/shared/edit-icon.js.map +1 -1
- package/dist/shared/fonts.js +16 -17
- package/dist/shared/fonts.js.map +1 -1
- package/dist/shared/forms.js +16 -38
- package/dist/shared/forms.js.map +1 -1
- package/dist/shared/instance-id.js +6 -9
- package/dist/shared/instance-id.js.map +1 -1
- package/dist/shared/nunjucks-helpers.js +2 -5
- package/dist/shared/nunjucks-helpers.js.map +1 -1
- package/dist/shared/schema.js +52 -96
- package/dist/shared/schema.js.map +1 -1
- package/dist/shared/tools.js +6 -13
- package/dist/shared/tools.js.map +1 -1
- package/dist/store.d.ts +15 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +851 -548
- package/dist/store.js.map +1 -1
- package/dist/tools.js +133 -143
- package/dist/tools.js.map +1 -1
- package/dist/unlayer-interface.d.ts +15 -4
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer-interface.js +1 -2
- package/dist/unlayer-interface.js.map +1 -1
- package/dist/unlayer.js +86 -113
- package/dist/unlayer.js.map +1 -1
- package/dist/vendor/dte-shared/business-calendar-validation.utils.d.ts +25 -0
- package/dist/vendor/dte-shared/business-calendar-validation.utils.js +80 -0
- package/dist/vendor/dte-shared/components/business-calendar-section.d.ts +15 -0
- package/dist/vendor/dte-shared/components/business-calendar-section.js +14 -0
- package/dist/vendor/dte-shared/components/schedule-drawer.d.ts +18 -0
- package/dist/vendor/dte-shared/components/schedule-drawer.js +119 -0
- package/dist/vendor/dte-shared/components/schedule-picker.d.ts +8 -0
- package/dist/vendor/dte-shared/components/schedule-picker.js +88 -0
- package/dist/vendor/dte-shared/constants.d.ts +31 -0
- package/dist/vendor/dte-shared/constants.js +34 -0
- package/dist/vendor/dte-shared/field-schedule-editor-context.d.ts +31 -0
- package/dist/vendor/dte-shared/field-schedule-editor-context.js +110 -0
- package/dist/vendor/dte-shared/index.d.ts +8 -0
- package/dist/vendor/dte-shared/index.js +7 -0
- package/dist/vendor/dte-shared/schedule-bindings.utils.d.ts +22 -0
- package/dist/vendor/dte-shared/schedule-bindings.utils.js +31 -0
- package/dist/vendor/dte-shared/styles/schedule.css +19 -0
- package/dist/vendor/dte-shared/types.d.ts +129 -0
- package/dist/vendor/dte-shared/types.js +1 -0
- package/package.json +7 -1
- package/src/__tests__/business-calendar-drawer.test.tsx +183 -0
- package/src/__tests__/business-calendar-requests.test.ts +166 -0
- package/src/__tests__/business-calendar-state.test.tsx +142 -0
- package/src/__tests__/condition-row.test.tsx +51 -8
- package/src/__tests__/e-sign-offset-modal.test.tsx +13 -2
- package/src/__tests__/store.business-calendar.test.ts +185 -0
- package/src/__tests__/unlayer.e-sign-types.test.ts +30 -0
- package/src/business-calendar/BusinessCalendarDrawer.tsx +76 -0
- package/src/business-calendar/business-calendar-requests.ts +80 -0
- package/src/business-calendar/business-calendar-state.ts +113 -0
- package/src/business-calendar/useBusinessCalendarRequests.ts +49 -0
- package/src/display-conditions/ConditionGroup.tsx +13 -3
- package/src/display-conditions/ConditionGroupsSection.tsx +24 -21
- package/src/display-conditions/ConditionRow.tsx +75 -32
- package/src/display-conditions/DisplayConditionModal.tsx +18 -59
- package/src/e-sign-offset/ESignDateSignedOffsetModal.tsx +6 -6
- package/src/editor-core-source.ts +2 -2
- package/src/editor.tsx +15 -0
- package/src/index.ts +10 -0
- package/src/shared/const.ts +59 -0
- package/src/store.ts +67 -5
- package/src/unlayer-interface.tsx +15 -4
- package/src/unlayer.tsx +5 -5
package/dist/store.js
CHANGED
|
@@ -1,47 +1,36 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
1
|
import { emitESignOffsetRequest } from './e-sign-offset/eSignOffsetController';
|
|
15
2
|
import { ImageUploadError } from './image-upload-error';
|
|
16
3
|
import { loadScript } from './loadScript';
|
|
17
4
|
import { logUnlayerError } from './log';
|
|
18
5
|
import { toUnlayerMergeTags } from './merge-tags';
|
|
19
6
|
import { defaultImageValidation } from './shared/configs';
|
|
7
|
+
import { E_SIGN_FIELD_TYPE_LABELS, } from './shared/const';
|
|
20
8
|
import { normalizeESignOffsetSettings } from './shared/e-sign-offset';
|
|
21
9
|
import { unlayerSupportedFonts } from './shared/fonts';
|
|
22
|
-
import { getFormFieldSampleValue, parseFormFieldKey } from './shared/forms';
|
|
10
|
+
import { getFormFieldSampleValue, parseFormFieldKey, } from './shared/forms';
|
|
23
11
|
import { schemaBuildMap, schemaIsDate } from './shared/schema';
|
|
24
12
|
import { unlayerToolsParseTwinKey } from './shared/tools';
|
|
25
|
-
import { unlayerToolsDedupeInstanceIds, unlayerToolsIterate, unlayerToolsNormalizeESignOffsets } from './tools';
|
|
26
|
-
import { createUnlayerEditor, DesignUpdatedEventType } from './unlayer';
|
|
13
|
+
import { unlayerToolsDedupeInstanceIds, unlayerToolsIterate, unlayerToolsNormalizeESignOffsets, } from './tools';
|
|
14
|
+
import { createUnlayerEditor, DesignUpdatedEventType, } from './unlayer';
|
|
27
15
|
const defaultScriptUrl = 'https://editor.unlayer.com/embed.js?2';
|
|
28
16
|
const UNLAYER_TOOLS_READY_TIMEOUT_MS = 30000;
|
|
29
|
-
const normalizeFontToken = (font)=>font.replace(/["']/g, '').split(',')[0].trim().toLowerCase();
|
|
30
|
-
const getDesignFontTokens = (value, out)=>{
|
|
17
|
+
const normalizeFontToken = (font) => font.replace(/["']/g, '').split(',')[0].trim().toLowerCase();
|
|
18
|
+
const getDesignFontTokens = (value, out) => {
|
|
31
19
|
if (!value || typeof value !== 'object') {
|
|
32
20
|
return;
|
|
33
21
|
}
|
|
34
22
|
if (Array.isArray(value)) {
|
|
35
|
-
for (const item of value){
|
|
23
|
+
for (const item of value) {
|
|
36
24
|
getDesignFontTokens(item, out);
|
|
37
25
|
}
|
|
38
26
|
return;
|
|
39
27
|
}
|
|
40
|
-
for (const [key, fieldValue] of Object.entries(value)){
|
|
28
|
+
for (const [key, fieldValue] of Object.entries(value)) {
|
|
41
29
|
if (key === 'fontFamily') {
|
|
42
30
|
if (typeof fieldValue === 'string') {
|
|
43
31
|
out.add(normalizeFontToken(fieldValue));
|
|
44
|
-
}
|
|
32
|
+
}
|
|
33
|
+
else if (fieldValue && typeof fieldValue === 'object') {
|
|
45
34
|
const fontFamilyValue = fieldValue;
|
|
46
35
|
if (typeof fontFamilyValue.label === 'string') {
|
|
47
36
|
out.add(normalizeFontToken(fontFamilyValue.label));
|
|
@@ -56,25 +45,22 @@ const getDesignFontTokens = (value, out)=>{
|
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
47
|
};
|
|
59
|
-
const ensureChunksFonts = (data)=>{
|
|
60
|
-
var
|
|
48
|
+
const ensureChunksFonts = (data) => {
|
|
49
|
+
var _a;
|
|
61
50
|
if (!data || typeof data !== 'object') {
|
|
62
51
|
return data;
|
|
63
52
|
}
|
|
64
|
-
(
|
|
53
|
+
(_a = data.chunks) !== null && _a !== void 0 ? _a : (data.chunks = {});
|
|
65
54
|
const existingFonts = Array.isArray(data.chunks.fonts) ? data.chunks.fonts : [];
|
|
66
|
-
const existingLabels = new Set(existingFonts.map((f)=>f.label));
|
|
55
|
+
const existingLabels = new Set(existingFonts.map((f) => f.label));
|
|
67
56
|
const usedFontTokens = new Set();
|
|
68
57
|
getDesignFontTokens(data.design, usedFontTokens);
|
|
69
58
|
const html = typeof data.html === 'string' ? data.html.toLowerCase() : '';
|
|
70
|
-
for (const font of unlayerSupportedFonts){
|
|
59
|
+
for (const font of unlayerSupportedFonts) {
|
|
71
60
|
const labelToken = normalizeFontToken(font.label);
|
|
72
61
|
const valueToken = normalizeFontToken(font.value);
|
|
73
62
|
const isUsedInDesign = usedFontTokens.has(labelToken) || usedFontTokens.has(valueToken);
|
|
74
|
-
const isUsedInHtml = [
|
|
75
|
-
labelToken,
|
|
76
|
-
valueToken
|
|
77
|
-
].some((token)=>html.includes(token));
|
|
63
|
+
const isUsedInHtml = [labelToken, valueToken].some(token => html.includes(token));
|
|
78
64
|
if ((isUsedInDesign || isUsedInHtml) && !existingLabels.has(font.label)) {
|
|
79
65
|
existingFonts.push(font);
|
|
80
66
|
existingLabels.add(font.label);
|
|
@@ -84,41 +70,42 @@ const ensureChunksFonts = (data)=>{
|
|
|
84
70
|
return data;
|
|
85
71
|
};
|
|
86
72
|
const FORM_FIELD_DATA_POINT_PREFIX = 'FORM_FIELD_';
|
|
87
|
-
const getByPath = (data, path)=>{
|
|
73
|
+
const getByPath = (data, path) => {
|
|
88
74
|
if (!data || typeof data !== 'object') {
|
|
89
75
|
return undefined;
|
|
90
76
|
}
|
|
91
|
-
return path.split('.').reduce((current, part)=>{
|
|
77
|
+
return path.split('.').reduce((current, part) => {
|
|
92
78
|
if (!current || typeof current !== 'object') {
|
|
93
79
|
return undefined;
|
|
94
80
|
}
|
|
95
81
|
return current[part];
|
|
96
82
|
}, data);
|
|
97
83
|
};
|
|
98
|
-
const isPlainObject = (value)
|
|
99
|
-
const deepMerge = (...sources)=>{
|
|
84
|
+
const isPlainObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
85
|
+
const deepMerge = (...sources) => {
|
|
100
86
|
const out = {};
|
|
101
|
-
for (const source of sources){
|
|
87
|
+
for (const source of sources) {
|
|
102
88
|
if (!isPlainObject(source)) {
|
|
103
89
|
continue;
|
|
104
90
|
}
|
|
105
|
-
for (const [key, value] of Object.entries(source)){
|
|
91
|
+
for (const [key, value] of Object.entries(source)) {
|
|
106
92
|
if (isPlainObject(value) && isPlainObject(out[key])) {
|
|
107
93
|
out[key] = deepMerge(out[key], value);
|
|
108
|
-
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
109
96
|
out[key] = value;
|
|
110
97
|
}
|
|
111
98
|
}
|
|
112
99
|
}
|
|
113
100
|
return out;
|
|
114
101
|
};
|
|
115
|
-
const setByPath = (target, path, value)=>{
|
|
102
|
+
const setByPath = (target, path, value) => {
|
|
116
103
|
const parts = path.split('.');
|
|
117
104
|
if (!parts.length) {
|
|
118
105
|
return;
|
|
119
106
|
}
|
|
120
107
|
let node = target;
|
|
121
|
-
for(let i = 0; i < parts.length - 1; i += 1){
|
|
108
|
+
for (let i = 0; i < parts.length - 1; i += 1) {
|
|
122
109
|
const key = parts[i];
|
|
123
110
|
if (!isPlainObject(node[key])) {
|
|
124
111
|
node[key] = {};
|
|
@@ -127,10 +114,10 @@ const setByPath = (target, path, value)=>{
|
|
|
127
114
|
}
|
|
128
115
|
node[parts[parts.length - 1]] = value;
|
|
129
116
|
};
|
|
130
|
-
const tokenizeFormulaFields = (expression)=>{
|
|
131
|
-
var
|
|
117
|
+
const tokenizeFormulaFields = (expression) => {
|
|
118
|
+
var _a;
|
|
132
119
|
const regex = /[A-Za-z_][A-Za-z0-9_.]*/g;
|
|
133
|
-
return (
|
|
120
|
+
return (_a = expression.match(regex)) !== null && _a !== void 0 ? _a : [];
|
|
134
121
|
};
|
|
135
122
|
// We are using exclusive lists here, because we can't be sure that we know all unlayer event types
|
|
136
123
|
const eventsNotChangingToolsList = [
|
|
@@ -139,586 +126,902 @@ const eventsNotChangingToolsList = [
|
|
|
139
126
|
DesignUpdatedEventType.ColumnModified,
|
|
140
127
|
DesignUpdatedEventType.RowMoved,
|
|
141
128
|
DesignUpdatedEventType.RowModified,
|
|
142
|
-
DesignUpdatedEventType.BodyModified
|
|
129
|
+
DesignUpdatedEventType.BodyModified,
|
|
143
130
|
];
|
|
144
131
|
const eventsNotAddingTools = [
|
|
145
132
|
...eventsNotChangingToolsList,
|
|
146
133
|
DesignUpdatedEventType.ContentRemoved,
|
|
147
134
|
DesignUpdatedEventType.ColumnRemoved,
|
|
148
|
-
DesignUpdatedEventType.RowRemoved
|
|
135
|
+
DesignUpdatedEventType.RowRemoved,
|
|
149
136
|
];
|
|
150
137
|
export class UnlayerStore {
|
|
151
|
-
constructor(props){
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
this
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
this
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
138
|
+
constructor(props) {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
Object.defineProperty(this, "props", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
configurable: true,
|
|
143
|
+
writable: true,
|
|
144
|
+
value: props
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(this, "unlayerRef", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
configurable: true,
|
|
149
|
+
writable: true,
|
|
150
|
+
value: void 0
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(this, "schemaDummyData", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true,
|
|
155
|
+
writable: true,
|
|
156
|
+
value: void 0
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(this, "dateSchemaFieldKeys", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
configurable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
value: void 0
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(this, "editor", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
value: void 0
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(this, "isInit", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
configurable: true,
|
|
173
|
+
writable: true,
|
|
174
|
+
value: false
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(this, "iframe", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
configurable: true,
|
|
179
|
+
writable: true,
|
|
180
|
+
value: void 0
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(this, "hasDesign", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
configurable: true,
|
|
185
|
+
writable: true,
|
|
186
|
+
value: false
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(this, "hasCoreLoaded", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
configurable: true,
|
|
191
|
+
writable: true,
|
|
192
|
+
value: false
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(this, "hasToolsRegistered", {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
configurable: true,
|
|
197
|
+
writable: true,
|
|
198
|
+
value: false
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(this, "toolsReadyWatchdogId", {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
configurable: true,
|
|
203
|
+
writable: true,
|
|
204
|
+
value: void 0
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(this, "formFieldsByFormId", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
configurable: true,
|
|
209
|
+
writable: true,
|
|
210
|
+
value: {}
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(this, "formFieldSamples", {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
configurable: true,
|
|
215
|
+
writable: true,
|
|
216
|
+
value: {}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(this, "isEditorReady", {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
configurable: true,
|
|
221
|
+
writable: true,
|
|
222
|
+
value: false
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(this, "isMergeTagsApplied", {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
configurable: true,
|
|
227
|
+
writable: true,
|
|
228
|
+
value: false
|
|
229
|
+
});
|
|
230
|
+
Object.defineProperty(this, "mergeTagsConfig", {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
configurable: true,
|
|
233
|
+
writable: true,
|
|
234
|
+
value: void 0
|
|
235
|
+
});
|
|
236
|
+
/** Latest `--business-calendar-state` payload, and the last one sent to the iframe. */
|
|
237
|
+
Object.defineProperty(this, "businessCalendarStateJson", {
|
|
238
|
+
enumerable: true,
|
|
239
|
+
configurable: true,
|
|
240
|
+
writable: true,
|
|
241
|
+
value: void 0
|
|
242
|
+
});
|
|
243
|
+
Object.defineProperty(this, "sentBusinessCalendarStateJson", {
|
|
244
|
+
enumerable: true,
|
|
245
|
+
configurable: true,
|
|
246
|
+
writable: true,
|
|
247
|
+
value: void 0
|
|
248
|
+
});
|
|
249
|
+
Object.defineProperty(this, "onMessageCB", {
|
|
250
|
+
enumerable: true,
|
|
251
|
+
configurable: true,
|
|
252
|
+
writable: true,
|
|
253
|
+
value: void 0
|
|
254
|
+
});
|
|
255
|
+
Object.defineProperty(this, "onChangeCB", {
|
|
256
|
+
enumerable: true,
|
|
257
|
+
configurable: true,
|
|
258
|
+
writable: true,
|
|
259
|
+
value: void 0
|
|
260
|
+
});
|
|
261
|
+
Object.defineProperty(this, "onSnapshotSaveCB", {
|
|
262
|
+
enumerable: true,
|
|
263
|
+
configurable: true,
|
|
264
|
+
writable: true,
|
|
265
|
+
value: void 0
|
|
266
|
+
});
|
|
267
|
+
Object.defineProperty(this, "onReadyCB", {
|
|
268
|
+
enumerable: true,
|
|
269
|
+
configurable: true,
|
|
270
|
+
writable: true,
|
|
271
|
+
value: void 0
|
|
272
|
+
});
|
|
273
|
+
Object.defineProperty(this, "onImageCB", {
|
|
274
|
+
enumerable: true,
|
|
275
|
+
configurable: true,
|
|
276
|
+
writable: true,
|
|
277
|
+
value: void 0
|
|
278
|
+
});
|
|
279
|
+
Object.defineProperty(this, "onErrorCB", {
|
|
280
|
+
enumerable: true,
|
|
281
|
+
configurable: true,
|
|
282
|
+
writable: true,
|
|
283
|
+
value: void 0
|
|
284
|
+
});
|
|
285
|
+
Object.defineProperty(this, "onFormSelectCB", {
|
|
286
|
+
enumerable: true,
|
|
287
|
+
configurable: true,
|
|
288
|
+
writable: true,
|
|
289
|
+
value: void 0
|
|
290
|
+
});
|
|
291
|
+
Object.defineProperty(this, "onCalcFieldOpenCB", {
|
|
292
|
+
enumerable: true,
|
|
293
|
+
configurable: true,
|
|
294
|
+
writable: true,
|
|
295
|
+
value: void 0
|
|
296
|
+
});
|
|
297
|
+
Object.defineProperty(this, "onCalcFieldSelectCB", {
|
|
298
|
+
enumerable: true,
|
|
299
|
+
configurable: true,
|
|
300
|
+
writable: true,
|
|
301
|
+
value: void 0
|
|
302
|
+
});
|
|
303
|
+
Object.defineProperty(this, "onBusinessCalendarRequestCB", {
|
|
304
|
+
enumerable: true,
|
|
305
|
+
configurable: true,
|
|
306
|
+
writable: true,
|
|
307
|
+
value: void 0
|
|
308
|
+
});
|
|
309
|
+
Object.defineProperty(this, "init", {
|
|
310
|
+
enumerable: true,
|
|
311
|
+
configurable: true,
|
|
312
|
+
writable: true,
|
|
313
|
+
value: async (container) => {
|
|
314
|
+
var _a, _b;
|
|
315
|
+
if (this.isInit) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
this.isInit = true;
|
|
319
|
+
try {
|
|
320
|
+
setTimeout(() => window.addEventListener('message', this.onPostMessage));
|
|
321
|
+
await loadScript(defaultScriptUrl);
|
|
322
|
+
if (!window.unlayer) {
|
|
323
|
+
throw new Error('Unlayer embed script loaded but window.unlayer is missing');
|
|
324
|
+
}
|
|
325
|
+
this.editor = createUnlayerEditor(container, this.props);
|
|
326
|
+
// The host may already have pushed a newer set through `setMergeTags`; keep it.
|
|
327
|
+
(_a = this.mergeTagsConfig) !== null && _a !== void 0 ? _a : (this.mergeTagsConfig = toUnlayerMergeTags(this.props.mergeTags));
|
|
328
|
+
this.editor.addEventListener('editor:ready', this.onEditorReady);
|
|
329
|
+
this.editor.addEventListener('design:loaded', this.onDesignLoaded);
|
|
330
|
+
this.editor.addEventListener('design:updated', this.onDesignUpdated);
|
|
331
|
+
this.editor.registerCallback('image', this.uploadImage);
|
|
332
|
+
this.iframe = (_b = container.querySelector(`iframe`)) !== null && _b !== void 0 ? _b : undefined;
|
|
333
|
+
if (!this.iframe) {
|
|
334
|
+
logUnlayerError('Unlayer iframe was not created after createEditor');
|
|
335
|
+
}
|
|
336
|
+
this.startToolsReadyWatchdog();
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
this.isInit = false;
|
|
340
|
+
this.clearToolsReadyWatchdog();
|
|
341
|
+
logUnlayerError('Failed to initialize Unlayer editor', error);
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
Object.defineProperty(this, "destroy", {
|
|
347
|
+
enumerable: true,
|
|
348
|
+
configurable: true,
|
|
349
|
+
writable: true,
|
|
350
|
+
value: () => {
|
|
251
351
|
this.clearToolsReadyWatchdog();
|
|
252
|
-
|
|
253
|
-
|
|
352
|
+
window.removeEventListener('message', this.onPostMessage);
|
|
353
|
+
if (this.editor) {
|
|
354
|
+
this.editor.removeEventListener('editor:ready', this.onEditorReady);
|
|
355
|
+
this.editor.removeEventListener('design:loaded', this.onDesignLoaded);
|
|
356
|
+
this.editor.removeEventListener('design:updated', this.onDesignUpdated);
|
|
357
|
+
this.editor.unregisterCallback('image', this.uploadImage);
|
|
358
|
+
this.editor = undefined;
|
|
359
|
+
}
|
|
254
360
|
}
|
|
255
|
-
};
|
|
256
|
-
this
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this.
|
|
263
|
-
this.
|
|
264
|
-
this.editor = undefined;
|
|
361
|
+
});
|
|
362
|
+
Object.defineProperty(this, "addTwin", {
|
|
363
|
+
enumerable: true,
|
|
364
|
+
configurable: true,
|
|
365
|
+
writable: true,
|
|
366
|
+
value: (twin) => {
|
|
367
|
+
var _a;
|
|
368
|
+
(_a = this.props.toolTwins) === null || _a === void 0 ? void 0 : _a.push(twin);
|
|
369
|
+
this.sendMessage('--add-twin', JSON.parse(JSON.stringify(twin)));
|
|
265
370
|
}
|
|
266
|
-
};
|
|
267
|
-
this
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
371
|
+
});
|
|
372
|
+
Object.defineProperty(this, "setDesign", {
|
|
373
|
+
enumerable: true,
|
|
374
|
+
configurable: true,
|
|
375
|
+
writable: true,
|
|
376
|
+
value: (design) => {
|
|
377
|
+
if (!this.editor) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
this.hasDesign = !!design;
|
|
381
|
+
if (design) {
|
|
382
|
+
this.editor.loadDesign(design);
|
|
383
|
+
}
|
|
275
384
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
385
|
+
});
|
|
386
|
+
Object.defineProperty(this, "setOnChange", {
|
|
387
|
+
enumerable: true,
|
|
388
|
+
configurable: true,
|
|
389
|
+
writable: true,
|
|
390
|
+
value: (onChange) => {
|
|
391
|
+
this.onChangeCB = onChange;
|
|
279
392
|
}
|
|
280
|
-
};
|
|
281
|
-
this
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
this.setOnReady = (onReady)=>{
|
|
288
|
-
this.onReadyCB = onReady;
|
|
289
|
-
};
|
|
290
|
-
this.setOnImage = (onImage)=>{
|
|
291
|
-
this.onImageCB = onImage;
|
|
292
|
-
};
|
|
293
|
-
this.setOnError = (onError)=>{
|
|
294
|
-
this.onErrorCB = onError;
|
|
295
|
-
};
|
|
296
|
-
this.setOnMessage = (onMessage)=>{
|
|
297
|
-
this.onMessageCB = onMessage;
|
|
298
|
-
};
|
|
299
|
-
this.setOnFormSelect = (onFormSelect)=>{
|
|
300
|
-
this.onFormSelectCB = onFormSelect;
|
|
301
|
-
};
|
|
302
|
-
this.setOnCalcFieldOpen = (onCalcFieldOpen)=>{
|
|
303
|
-
this.onCalcFieldOpenCB = onCalcFieldOpen;
|
|
304
|
-
};
|
|
305
|
-
this.setOnCalcFieldSelect = (onCalcFieldSelect)=>{
|
|
306
|
-
this.onCalcFieldSelectCB = onCalcFieldSelect;
|
|
307
|
-
};
|
|
308
|
-
this.sendFormList = (forms)=>{
|
|
309
|
-
this.sendMessage('--form-list', {
|
|
310
|
-
forms
|
|
311
|
-
});
|
|
312
|
-
};
|
|
313
|
-
this.sendFormFields = (formId, fields)=>{
|
|
314
|
-
this.formFieldsByFormId[formId] = fields;
|
|
315
|
-
this.updateFormFieldSamples(formId, fields);
|
|
316
|
-
this.sendMessage('--form-fields', {
|
|
317
|
-
formId,
|
|
318
|
-
fields
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
this.sendCalcFieldLabels = (labels)=>{
|
|
322
|
-
this.sendMessage('--calc-field-labels', {
|
|
323
|
-
labels
|
|
324
|
-
});
|
|
325
|
-
};
|
|
326
|
-
this.setMergeTags = (tags)=>{
|
|
327
|
-
this.mergeTagsConfig = toUnlayerMergeTags(tags);
|
|
328
|
-
this.isMergeTagsApplied = false;
|
|
329
|
-
this.applyMergeTags();
|
|
330
|
-
};
|
|
331
|
-
this.applyMergeTags = ()=>{
|
|
332
|
-
if (!this.editor || !this.isEditorReady || this.isMergeTagsApplied || !this.mergeTagsConfig) {
|
|
333
|
-
return;
|
|
393
|
+
});
|
|
394
|
+
Object.defineProperty(this, "setOnSnapshotSave", {
|
|
395
|
+
enumerable: true,
|
|
396
|
+
configurable: true,
|
|
397
|
+
writable: true,
|
|
398
|
+
value: (onSnapshotSave) => {
|
|
399
|
+
this.onSnapshotSaveCB = onSnapshotSave;
|
|
334
400
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
401
|
+
});
|
|
402
|
+
Object.defineProperty(this, "setOnReady", {
|
|
403
|
+
enumerable: true,
|
|
404
|
+
configurable: true,
|
|
405
|
+
writable: true,
|
|
406
|
+
value: (onReady) => {
|
|
407
|
+
this.onReadyCB = onReady;
|
|
340
408
|
}
|
|
341
|
-
};
|
|
342
|
-
this
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
this.onEditorReady();
|
|
349
|
-
if (!this.hasDesign) {
|
|
350
|
-
var _this_editor;
|
|
351
|
-
this.hasDesign = true;
|
|
352
|
-
(_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.setBodyValues({
|
|
353
|
-
backgroundColor: 'rgba(0,0,0,0)',
|
|
354
|
-
contentWidth: '100%'
|
|
355
|
-
});
|
|
409
|
+
});
|
|
410
|
+
Object.defineProperty(this, "setOnImage", {
|
|
411
|
+
enumerable: true,
|
|
412
|
+
configurable: true,
|
|
413
|
+
writable: true,
|
|
414
|
+
value: (onImage) => {
|
|
415
|
+
this.onImageCB = onImage;
|
|
356
416
|
}
|
|
357
|
-
};
|
|
358
|
-
this
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
417
|
+
});
|
|
418
|
+
Object.defineProperty(this, "setOnError", {
|
|
419
|
+
enumerable: true,
|
|
420
|
+
configurable: true,
|
|
421
|
+
writable: true,
|
|
422
|
+
value: (onError) => {
|
|
423
|
+
this.onErrorCB = onError;
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
Object.defineProperty(this, "setOnMessage", {
|
|
427
|
+
enumerable: true,
|
|
428
|
+
configurable: true,
|
|
429
|
+
writable: true,
|
|
430
|
+
value: (onMessage) => {
|
|
431
|
+
this.onMessageCB = onMessage;
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
Object.defineProperty(this, "setOnFormSelect", {
|
|
435
|
+
enumerable: true,
|
|
436
|
+
configurable: true,
|
|
437
|
+
writable: true,
|
|
438
|
+
value: (onFormSelect) => {
|
|
439
|
+
this.onFormSelectCB = onFormSelect;
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
Object.defineProperty(this, "setOnCalcFieldOpen", {
|
|
443
|
+
enumerable: true,
|
|
444
|
+
configurable: true,
|
|
445
|
+
writable: true,
|
|
446
|
+
value: (onCalcFieldOpen) => {
|
|
447
|
+
this.onCalcFieldOpenCB = onCalcFieldOpen;
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
Object.defineProperty(this, "setOnCalcFieldSelect", {
|
|
451
|
+
enumerable: true,
|
|
452
|
+
configurable: true,
|
|
453
|
+
writable: true,
|
|
454
|
+
value: (onCalcFieldSelect) => {
|
|
455
|
+
this.onCalcFieldSelectCB = onCalcFieldSelect;
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
Object.defineProperty(this, "setOnBusinessCalendarRequest", {
|
|
459
|
+
enumerable: true,
|
|
460
|
+
configurable: true,
|
|
461
|
+
writable: true,
|
|
462
|
+
value: (onBusinessCalendarRequest) => {
|
|
463
|
+
this.onBusinessCalendarRequestCB = onBusinessCalendarRequest;
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
/** Tells the iframe how a schedule `delete` request ended. */
|
|
467
|
+
Object.defineProperty(this, "sendBusinessCalendarResult", {
|
|
468
|
+
enumerable: true,
|
|
469
|
+
configurable: true,
|
|
470
|
+
writable: true,
|
|
471
|
+
value: (result) => {
|
|
472
|
+
this.sendMessage('--business-calendar-result', JSON.parse(JSON.stringify(result)));
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
/**
|
|
476
|
+
* Keeps the schedule state for the iframe and sends it once the tools core has loaded (it
|
|
477
|
+
* goes out again right after `--config`). An unchanged state isn't sent again.
|
|
478
|
+
*/
|
|
479
|
+
Object.defineProperty(this, "setBusinessCalendarState", {
|
|
480
|
+
enumerable: true,
|
|
481
|
+
configurable: true,
|
|
482
|
+
writable: true,
|
|
483
|
+
value: (state) => {
|
|
484
|
+
this.businessCalendarStateJson = JSON.stringify(state);
|
|
485
|
+
if (this.hasCoreLoaded &&
|
|
486
|
+
this.businessCalendarStateJson !== this.sentBusinessCalendarStateJson) {
|
|
487
|
+
this.sendBusinessCalendarState();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
Object.defineProperty(this, "sendFormList", {
|
|
492
|
+
enumerable: true,
|
|
493
|
+
configurable: true,
|
|
494
|
+
writable: true,
|
|
495
|
+
value: (forms) => {
|
|
496
|
+
this.sendMessage('--form-list', { forms });
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
Object.defineProperty(this, "sendFormFields", {
|
|
500
|
+
enumerable: true,
|
|
501
|
+
configurable: true,
|
|
502
|
+
writable: true,
|
|
503
|
+
value: (formId, fields) => {
|
|
504
|
+
this.formFieldsByFormId[formId] = fields;
|
|
505
|
+
this.updateFormFieldSamples(formId, fields);
|
|
506
|
+
this.sendMessage('--form-fields', { formId, fields });
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
Object.defineProperty(this, "sendCalcFieldLabels", {
|
|
510
|
+
enumerable: true,
|
|
511
|
+
configurable: true,
|
|
512
|
+
writable: true,
|
|
513
|
+
value: (labels) => {
|
|
514
|
+
this.sendMessage('--calc-field-labels', { labels });
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
/**
|
|
518
|
+
* Replaces the editor's merge tag menu. Nested groups passed to `createEditor` stop DTE
|
|
519
|
+
* custom tools from registering, so init only carries the flat shape and the grouped
|
|
520
|
+
* config is applied here once the editor is ready. A call before that (including the
|
|
521
|
+
* initial props) is parked; a later call replaces it. A failed apply is retried on the
|
|
522
|
+
* next `design:loaded`.
|
|
523
|
+
*/
|
|
524
|
+
Object.defineProperty(this, "setMergeTags", {
|
|
525
|
+
enumerable: true,
|
|
526
|
+
configurable: true,
|
|
527
|
+
writable: true,
|
|
528
|
+
value: (tags) => {
|
|
529
|
+
this.mergeTagsConfig = toUnlayerMergeTags(tags);
|
|
530
|
+
this.isMergeTagsApplied = false;
|
|
531
|
+
this.applyMergeTags();
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
Object.defineProperty(this, "applyMergeTags", {
|
|
535
|
+
enumerable: true,
|
|
536
|
+
configurable: true,
|
|
537
|
+
writable: true,
|
|
538
|
+
value: () => {
|
|
539
|
+
if (!this.editor ||
|
|
540
|
+
!this.isEditorReady ||
|
|
541
|
+
this.isMergeTagsApplied ||
|
|
542
|
+
!this.mergeTagsConfig) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
try {
|
|
546
|
+
this.editor.setMergeTags(this.mergeTagsConfig);
|
|
547
|
+
this.isMergeTagsApplied = true;
|
|
548
|
+
}
|
|
549
|
+
catch (error) {
|
|
550
|
+
logUnlayerError('Failed to apply merge tags', error);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
Object.defineProperty(this, "onEditorReady", {
|
|
555
|
+
enumerable: true,
|
|
556
|
+
configurable: true,
|
|
557
|
+
writable: true,
|
|
558
|
+
value: () => {
|
|
559
|
+
this.isEditorReady = true;
|
|
560
|
+
this.applyMergeTags();
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
Object.defineProperty(this, "onDesignLoaded", {
|
|
564
|
+
enumerable: true,
|
|
565
|
+
configurable: true,
|
|
566
|
+
writable: true,
|
|
567
|
+
value: () => {
|
|
568
|
+
var _a;
|
|
569
|
+
// A loaded design means the editor is up even if `editor:ready` never reached us.
|
|
570
|
+
this.onEditorReady();
|
|
571
|
+
if (!this.hasDesign) {
|
|
572
|
+
this.hasDesign = true;
|
|
573
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.setBodyValues({
|
|
574
|
+
backgroundColor: 'rgba(0,0,0,0)',
|
|
575
|
+
contentWidth: '100%',
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
Object.defineProperty(this, "onDesignUpdated", {
|
|
581
|
+
enumerable: true,
|
|
582
|
+
configurable: true,
|
|
583
|
+
writable: true,
|
|
584
|
+
value: (event) => {
|
|
585
|
+
var _a, _b;
|
|
586
|
+
const isToolAdded = !eventsNotAddingTools.includes(event.type);
|
|
587
|
+
const isToolsListChanged = !eventsNotChangingToolsList.includes(event.type);
|
|
588
|
+
if (isToolAdded) {
|
|
589
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
|
|
590
|
+
var _a, _b, _c, _d;
|
|
591
|
+
let hasChanges = false;
|
|
592
|
+
unlayerToolsIterate(data.design, tool => {
|
|
593
|
+
var _a;
|
|
594
|
+
const realTool = tool.slug
|
|
595
|
+
? unlayerToolsParseTwinKey((_a = tool.slug) !== null && _a !== void 0 ? _a : '')
|
|
596
|
+
: undefined;
|
|
597
|
+
if (realTool) {
|
|
598
|
+
hasChanges = true;
|
|
599
|
+
if (tool.slug) {
|
|
600
|
+
delete data.design.counters[`u_content_custom_${tool.slug}`];
|
|
601
|
+
delete tool.values._meta.htmlID;
|
|
602
|
+
}
|
|
603
|
+
tool.type = realTool.type;
|
|
604
|
+
tool.slug = realTool.slug;
|
|
374
605
|
}
|
|
375
|
-
|
|
376
|
-
|
|
606
|
+
});
|
|
607
|
+
// Duplicated contents/rows carry the original's instance GUIDs; give copies new ones.
|
|
608
|
+
if (unlayerToolsDedupeInstanceIds(data.design, (_c = (_b = (_a = event.item) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c.htmlID)) {
|
|
609
|
+
hasChanges = true;
|
|
610
|
+
}
|
|
611
|
+
if (hasChanges) {
|
|
612
|
+
this.setDesign(data.design);
|
|
377
613
|
}
|
|
614
|
+
(_d = this.onChangeCB) === null || _d === void 0 ? void 0 : _d.call(this, { isToolsListChanged });
|
|
378
615
|
});
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
(_b = this.onChangeCB) === null || _b === void 0 ? void 0 : _b.call(this, { isToolsListChanged });
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
Object.defineProperty(this, "onPostMessage", {
|
|
623
|
+
enumerable: true,
|
|
624
|
+
configurable: true,
|
|
625
|
+
writable: true,
|
|
626
|
+
value: (e) => {
|
|
627
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
628
|
+
if (!((_a = e.data) === null || _a === void 0 ? void 0 : _a['-dte-message-from'])) {
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
const type = (_c = (_b = e.data) === null || _b === void 0 ? void 0 : _b['-dte-message-from']) === null || _c === void 0 ? void 0 : _c.type;
|
|
632
|
+
const data = (_e = (_d = e.data) === null || _d === void 0 ? void 0 : _d['-dte-message-from']) === null || _e === void 0 ? void 0 : _e.data;
|
|
633
|
+
if (!type) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (type === '--ready' || type === '--registered') {
|
|
637
|
+
this.hasToolsRegistered = true;
|
|
638
|
+
this.clearToolsReadyWatchdog();
|
|
639
|
+
(_f = this.onReadyCB) === null || _f === void 0 ? void 0 : _f.call(this);
|
|
640
|
+
}
|
|
641
|
+
else if (type === '--core-loaded') {
|
|
642
|
+
this.hasCoreLoaded = true;
|
|
643
|
+
const configData = {
|
|
644
|
+
dummyData: this.props.dummyData,
|
|
645
|
+
schema: this.props.schema,
|
|
646
|
+
generics: this.props.generics,
|
|
647
|
+
genericConfigMode: this.props.genericConfigMode,
|
|
648
|
+
isSnapshotMode: this.props.isSnapshotMode,
|
|
649
|
+
holidays: this.props.holidays,
|
|
650
|
+
fieldCalendars: this.props.fieldCalendars,
|
|
651
|
+
conditionalRulesEnabled: !!this.props.displayConditions || !!this.props.onConditionalsOpen,
|
|
652
|
+
};
|
|
653
|
+
this.sendMessage('--config', JSON.parse(JSON.stringify(configData)));
|
|
654
|
+
// Always: a reloaded tools core starts without it.
|
|
655
|
+
this.sendBusinessCalendarState();
|
|
656
|
+
}
|
|
657
|
+
else if (type === '--form-select') {
|
|
658
|
+
(_g = this.onFormSelectCB) === null || _g === void 0 ? void 0 : _g.call(this, data === null || data === void 0 ? void 0 : data.formId);
|
|
659
|
+
}
|
|
660
|
+
else if (type === '--calc-field-open') {
|
|
661
|
+
(_h = this.onCalcFieldOpenCB) === null || _h === void 0 ? void 0 : _h.call(this, (_j = data === null || data === void 0 ? void 0 : data.usedFormIds) !== null && _j !== void 0 ? _j : []);
|
|
662
|
+
}
|
|
663
|
+
else if (type === '--esign-offset-open') {
|
|
664
|
+
this.openESignOffsetRules(data);
|
|
665
|
+
}
|
|
666
|
+
else if (type === '--business-calendar-request') {
|
|
667
|
+
// It can delete a tenant schedule and replace bindings: only from this editor's iframe.
|
|
668
|
+
if (e.source === ((_k = this.iframe) === null || _k === void 0 ? void 0 : _k.contentWindow)) {
|
|
669
|
+
this.routeBusinessCalendarRequest(data);
|
|
382
670
|
}
|
|
383
|
-
|
|
384
|
-
|
|
671
|
+
}
|
|
672
|
+
else if (type === '--calc-field-select') {
|
|
673
|
+
if (this.onCalcFieldSelectCB) {
|
|
674
|
+
this.onCalcFieldSelectCB((_l = data === null || data === void 0 ? void 0 : data.fieldKeys) !== null && _l !== void 0 ? _l : []);
|
|
385
675
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
var _e_data, _e_data_dtemessagefrom, _e_data1, _e_data_dtemessagefrom1, _e_data2, _this_onMessageCB, _this;
|
|
399
|
-
if (!((_e_data = e.data) === null || _e_data === void 0 ? void 0 : _e_data['-dte-message-from'])) {
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
const type = (_e_data1 = e.data) === null || _e_data1 === void 0 ? void 0 : (_e_data_dtemessagefrom = _e_data1['-dte-message-from']) === null || _e_data_dtemessagefrom === void 0 ? void 0 : _e_data_dtemessagefrom.type;
|
|
403
|
-
const data = (_e_data2 = e.data) === null || _e_data2 === void 0 ? void 0 : (_e_data_dtemessagefrom1 = _e_data2['-dte-message-from']) === null || _e_data_dtemessagefrom1 === void 0 ? void 0 : _e_data_dtemessagefrom1.data;
|
|
404
|
-
if (!type) {
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
if (type === '--ready' || type === '--registered') {
|
|
408
|
-
var _this_onReadyCB, _this1;
|
|
409
|
-
this.hasToolsRegistered = true;
|
|
410
|
-
this.clearToolsReadyWatchdog();
|
|
411
|
-
(_this_onReadyCB = (_this1 = this).onReadyCB) === null || _this_onReadyCB === void 0 ? void 0 : _this_onReadyCB.call(_this1);
|
|
412
|
-
} else if (type === '--core-loaded') {
|
|
413
|
-
this.hasCoreLoaded = true;
|
|
414
|
-
const configData = {
|
|
415
|
-
dummyData: this.props.dummyData,
|
|
416
|
-
schema: this.props.schema,
|
|
417
|
-
generics: this.props.generics,
|
|
418
|
-
genericConfigMode: this.props.genericConfigMode,
|
|
419
|
-
isSnapshotMode: this.props.isSnapshotMode,
|
|
420
|
-
holidays: this.props.holidays,
|
|
421
|
-
fieldCalendars: this.props.fieldCalendars,
|
|
422
|
-
conditionalRulesEnabled: !!this.props.displayConditions || !!this.props.onConditionalsOpen
|
|
423
|
-
};
|
|
424
|
-
this.sendMessage('--config', JSON.parse(JSON.stringify(configData)));
|
|
425
|
-
} else if (type === '--form-select') {
|
|
426
|
-
var _this_onFormSelectCB, _this2;
|
|
427
|
-
(_this_onFormSelectCB = (_this2 = this).onFormSelectCB) === null || _this_onFormSelectCB === void 0 ? void 0 : _this_onFormSelectCB.call(_this2, data === null || data === void 0 ? void 0 : data.formId);
|
|
428
|
-
} else if (type === '--calc-field-open') {
|
|
429
|
-
var _ref;
|
|
430
|
-
var _this_onCalcFieldOpenCB, _this3;
|
|
431
|
-
(_this_onCalcFieldOpenCB = (_this3 = this).onCalcFieldOpenCB) === null || _this_onCalcFieldOpenCB === void 0 ? void 0 : _this_onCalcFieldOpenCB.call(_this3, (_ref = data === null || data === void 0 ? void 0 : data.usedFormIds) !== null && _ref !== void 0 ? _ref : []);
|
|
432
|
-
} else if (type === '--esign-offset-open') {
|
|
433
|
-
this.openESignOffsetRules(data);
|
|
434
|
-
} else if (type === '--calc-field-select') {
|
|
435
|
-
if (this.onCalcFieldSelectCB) {
|
|
436
|
-
var _ref1;
|
|
437
|
-
this.onCalcFieldSelectCB((_ref1 = data === null || data === void 0 ? void 0 : data.fieldKeys) !== null && _ref1 !== void 0 ? _ref1 : []);
|
|
438
|
-
} else {
|
|
439
|
-
this.sendCalcFieldLabels({});
|
|
440
|
-
}
|
|
441
|
-
} else if (type === '--data-loaded') {
|
|
442
|
-
var _this_props_units;
|
|
443
|
-
const data = {
|
|
444
|
-
customTools: this.props.tools.map((tool)=>({
|
|
445
|
-
key: tool.key
|
|
446
|
-
})),
|
|
447
|
-
toolTwins: this.props.toolTwins,
|
|
448
|
-
eSignRecipients: this.props.eSignRecipients,
|
|
449
|
-
eSignFieldTypes: this.props.eSignFieldTypes,
|
|
450
|
-
units: (_this_props_units = this.props.units) === null || _this_props_units === void 0 ? void 0 : _this_props_units.map((unit)=>({
|
|
676
|
+
else {
|
|
677
|
+
this.sendCalcFieldLabels({});
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
else if (type === '--data-loaded') {
|
|
681
|
+
const data = {
|
|
682
|
+
customTools: this.props.tools.map(tool => ({ key: tool.key })),
|
|
683
|
+
toolTwins: this.props.toolTwins,
|
|
684
|
+
eSignRecipients: this.props.eSignRecipients,
|
|
685
|
+
eSignFieldTypes: this.props.eSignFieldTypes,
|
|
686
|
+
eSignFieldTypeLabels: E_SIGN_FIELD_TYPE_LABELS,
|
|
687
|
+
units: (_m = this.props.units) === null || _m === void 0 ? void 0 : _m.map(unit => ({
|
|
451
688
|
...unit,
|
|
452
689
|
values: {
|
|
453
690
|
...unit.values,
|
|
454
|
-
adminConfig: undefined
|
|
455
|
-
}
|
|
456
|
-
}))
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
691
|
+
adminConfig: undefined,
|
|
692
|
+
},
|
|
693
|
+
})),
|
|
694
|
+
};
|
|
695
|
+
this.sendMessage('--register', JSON.parse(JSON.stringify(data)));
|
|
696
|
+
}
|
|
697
|
+
else if (type === '--save-snapshot') {
|
|
698
|
+
(_o = this.editor) === null || _o === void 0 ? void 0 : _o.exportHtml(template => {
|
|
699
|
+
unlayerToolsIterate(template.design, tool => {
|
|
700
|
+
var _a, _b, _c;
|
|
701
|
+
if (((_b = (_a = tool.values) === null || _a === void 0 ? void 0 : _a.twin) === null || _b === void 0 ? void 0 : _b.id) === data.id) {
|
|
702
|
+
if (!tool.slug) {
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
(_c = this.onSnapshotSaveCB) === null || _c === void 0 ? void 0 : _c.call(this, {
|
|
706
|
+
title: '',
|
|
707
|
+
tool: tool.slug,
|
|
708
|
+
values: tool.values,
|
|
709
|
+
});
|
|
710
|
+
return false;
|
|
468
711
|
}
|
|
469
|
-
|
|
470
|
-
title: '',
|
|
471
|
-
tool: tool.slug,
|
|
472
|
-
values: tool.values
|
|
473
|
-
});
|
|
474
|
-
return false;
|
|
475
|
-
}
|
|
712
|
+
});
|
|
476
713
|
});
|
|
477
|
-
}
|
|
714
|
+
}
|
|
715
|
+
(_p = this.onMessageCB) === null || _p === void 0 ? void 0 : _p.call(this, type, data);
|
|
478
716
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
done: (value)=>{
|
|
489
|
-
const result = {
|
|
490
|
-
requestId,
|
|
491
|
-
value
|
|
492
|
-
};
|
|
493
|
-
this.sendMessage('--esign-offset-result', JSON.parse(JSON.stringify(result)));
|
|
717
|
+
});
|
|
718
|
+
Object.defineProperty(this, "openESignOffsetRules", {
|
|
719
|
+
enumerable: true,
|
|
720
|
+
configurable: true,
|
|
721
|
+
writable: true,
|
|
722
|
+
value: (data) => {
|
|
723
|
+
const requestId = data === null || data === void 0 ? void 0 : data.requestId;
|
|
724
|
+
if (!requestId) {
|
|
725
|
+
return;
|
|
494
726
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
727
|
+
emitESignOffsetRequest({
|
|
728
|
+
value: normalizeESignOffsetSettings(data.value),
|
|
729
|
+
done: value => {
|
|
730
|
+
const result = { requestId, value };
|
|
731
|
+
this.sendMessage('--esign-offset-result', JSON.parse(JSON.stringify(result)));
|
|
732
|
+
},
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
Object.defineProperty(this, "routeBusinessCalendarRequest", {
|
|
737
|
+
enumerable: true,
|
|
738
|
+
configurable: true,
|
|
739
|
+
writable: true,
|
|
740
|
+
value: (data) => {
|
|
741
|
+
var _a;
|
|
742
|
+
if (!(data === null || data === void 0 ? void 0 : data.action) || !data.fieldKey) {
|
|
502
743
|
return;
|
|
503
744
|
}
|
|
504
|
-
|
|
505
|
-
setByPath(this.formFieldSamples, `__submission_fields.${formId}.${normalizedFieldId}`, sampleValue);
|
|
506
|
-
this.formFieldSamples[`${FORM_FIELD_DATA_POINT_PREFIX}${normalizedFieldId}`] = sampleValue;
|
|
507
|
-
});
|
|
508
|
-
};
|
|
509
|
-
this.collectCalculatedFieldKeys = (design)=>{
|
|
510
|
-
const keys = new Set();
|
|
511
|
-
if (!design) {
|
|
512
|
-
return keys;
|
|
745
|
+
(_a = this.onBusinessCalendarRequestCB) === null || _a === void 0 ? void 0 : _a.call(this, data);
|
|
513
746
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
747
|
+
});
|
|
748
|
+
Object.defineProperty(this, "sendBusinessCalendarState", {
|
|
749
|
+
enumerable: true,
|
|
750
|
+
configurable: true,
|
|
751
|
+
writable: true,
|
|
752
|
+
value: () => {
|
|
753
|
+
if (!this.businessCalendarStateJson) {
|
|
518
754
|
return;
|
|
519
755
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
756
|
+
this.sentBusinessCalendarStateJson = this.businessCalendarStateJson;
|
|
757
|
+
this.sendMessage('--business-calendar-state', JSON.parse(this.businessCalendarStateJson));
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
Object.defineProperty(this, "updateFormFieldSamples", {
|
|
761
|
+
enumerable: true,
|
|
762
|
+
configurable: true,
|
|
763
|
+
writable: true,
|
|
764
|
+
value: (formId, fields) => {
|
|
765
|
+
fields.forEach((field, index) => {
|
|
766
|
+
var _a;
|
|
767
|
+
const normalizedFieldId = String((_a = field.id) !== null && _a !== void 0 ? _a : '').replaceAll('-', '');
|
|
768
|
+
if (!normalizedFieldId) {
|
|
769
|
+
return;
|
|
523
770
|
}
|
|
771
|
+
const sampleValue = getFormFieldSampleValue(field, index);
|
|
772
|
+
setByPath(this.formFieldSamples, `__submission_fields.${formId}.${normalizedFieldId}`, sampleValue);
|
|
773
|
+
this.formFieldSamples[`${FORM_FIELD_DATA_POINT_PREFIX}${normalizedFieldId}`] =
|
|
774
|
+
sampleValue;
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
Object.defineProperty(this, "collectCalculatedFieldKeys", {
|
|
779
|
+
enumerable: true,
|
|
780
|
+
configurable: true,
|
|
781
|
+
writable: true,
|
|
782
|
+
value: (design) => {
|
|
783
|
+
const keys = new Set();
|
|
784
|
+
if (!design) {
|
|
785
|
+
return keys;
|
|
524
786
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return String((_field_id = field.id) !== null && _field_id !== void 0 ? _field_id : '').replaceAll('-', '') === normalizedFieldId;
|
|
787
|
+
unlayerToolsIterate(design, tool => {
|
|
788
|
+
var _a;
|
|
789
|
+
const calc = (_a = tool.values) === null || _a === void 0 ? void 0 : _a.calculation;
|
|
790
|
+
if (!calc || typeof calc !== 'object') {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
if (typeof calc.expression === 'string') {
|
|
794
|
+
for (const key of tokenizeFormulaFields(calc.expression)) {
|
|
795
|
+
keys.add(key);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
if (calc.fieldLabels && typeof calc.fieldLabels === 'object') {
|
|
799
|
+
Object.keys(calc.fieldLabels).forEach(key => keys.add(key));
|
|
800
|
+
}
|
|
540
801
|
});
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
802
|
+
return keys;
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
Object.defineProperty(this, "resolveDemoValue", {
|
|
806
|
+
enumerable: true,
|
|
807
|
+
configurable: true,
|
|
808
|
+
writable: true,
|
|
809
|
+
value: (key, fallbackIndex, sourceData) => {
|
|
810
|
+
var _a;
|
|
811
|
+
const parsedFormField = parseFormFieldKey(key);
|
|
812
|
+
if (parsedFormField) {
|
|
813
|
+
const normalizedFieldId = parsedFormField.fieldId;
|
|
814
|
+
const formFields = (_a = this.formFieldsByFormId[parsedFormField.formId]) !== null && _a !== void 0 ? _a : [];
|
|
815
|
+
const fieldIndex = formFields.findIndex(field => { var _a; return String((_a = field.id) !== null && _a !== void 0 ? _a : '').replaceAll('-', '') === normalizedFieldId; });
|
|
816
|
+
const field = fieldIndex >= 0 ? formFields[fieldIndex] : undefined;
|
|
817
|
+
const sample = field
|
|
818
|
+
? getFormFieldSampleValue(field, fieldIndex)
|
|
819
|
+
: getByPath(this.formFieldSamples, `__submission_fields.${parsedFormField.formId}.${normalizedFieldId}`);
|
|
820
|
+
if (sample !== undefined) {
|
|
821
|
+
return sample;
|
|
822
|
+
}
|
|
823
|
+
return this.dateSchemaFieldKeys.has(key) ? '2026-01-15' : 44 + fallbackIndex;
|
|
824
|
+
}
|
|
825
|
+
const existing = getByPath(sourceData, key);
|
|
826
|
+
if (existing !== undefined) {
|
|
827
|
+
return existing;
|
|
828
|
+
}
|
|
829
|
+
if (this.dateSchemaFieldKeys.has(key)) {
|
|
830
|
+
return '2026-01-15';
|
|
545
831
|
}
|
|
546
|
-
return
|
|
832
|
+
return 44 + fallbackIndex;
|
|
547
833
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
834
|
+
});
|
|
835
|
+
Object.defineProperty(this, "buildCalculatedFieldDemoData", {
|
|
836
|
+
enumerable: true,
|
|
837
|
+
configurable: true,
|
|
838
|
+
writable: true,
|
|
839
|
+
value: (design) => {
|
|
840
|
+
const demoData = {};
|
|
841
|
+
const usedKeys = Array.from(this.collectCalculatedFieldKeys(design));
|
|
842
|
+
const sourceData = deepMerge(this.schemaDummyData, this.props.dummyData, this.formFieldSamples);
|
|
843
|
+
usedKeys.forEach((key, index) => {
|
|
844
|
+
const value = this.resolveDemoValue(key, index, sourceData);
|
|
845
|
+
setByPath(demoData, key, value);
|
|
846
|
+
});
|
|
847
|
+
return demoData;
|
|
551
848
|
}
|
|
552
|
-
|
|
553
|
-
|
|
849
|
+
});
|
|
850
|
+
Object.defineProperty(this, "sendMessage", {
|
|
851
|
+
enumerable: true,
|
|
852
|
+
configurable: true,
|
|
853
|
+
writable: true,
|
|
854
|
+
value: (type, data) => {
|
|
855
|
+
var _a, _b;
|
|
856
|
+
(_b = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage({
|
|
857
|
+
'-dte-message-to': {
|
|
858
|
+
type,
|
|
859
|
+
data,
|
|
860
|
+
},
|
|
861
|
+
}, '*');
|
|
554
862
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
}, '*');
|
|
575
|
-
};
|
|
576
|
-
this.uploadImage = async (data, done)=>{
|
|
577
|
-
var _this_props_imageValidation;
|
|
578
|
-
var _data_attachments;
|
|
579
|
-
if (!this.onImageCB) {
|
|
580
|
-
done({
|
|
581
|
-
progress: 100
|
|
582
|
-
});
|
|
583
|
-
throw new Error('image upload is not implemented');
|
|
584
|
-
}
|
|
585
|
-
if (!((_data_attachments = data.attachments) === null || _data_attachments === void 0 ? void 0 : _data_attachments.length)) {
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
588
|
-
const file = data.attachments[0];
|
|
589
|
-
const res = await this.validateImage(file, {
|
|
590
|
-
...defaultImageValidation,
|
|
591
|
-
...(_this_props_imageValidation = this.props.imageValidation) !== null && _this_props_imageValidation !== void 0 ? _this_props_imageValidation : {}
|
|
592
|
-
});
|
|
593
|
-
if (!res.isValid) {
|
|
594
|
-
var _this_onErrorCB, _this;
|
|
595
|
-
logUnlayerError(`Image validation failed: ${res.title}`, res.description);
|
|
596
|
-
(_this_onErrorCB = (_this = this).onErrorCB) === null || _this_onErrorCB === void 0 ? void 0 : _this_onErrorCB.call(_this, res.title, res.description);
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
/*
|
|
600
|
-
* Unlayer only leaves its "uploading" state when `done` receives a url, so `done` must not be
|
|
601
|
-
* called before the upload succeeds or after it fails, otherwise the image widget gets stuck.
|
|
602
|
-
*/ try {
|
|
603
|
-
const { url } = await this.onImageCB(file);
|
|
604
|
-
done({
|
|
605
|
-
progress: 100,
|
|
606
|
-
url
|
|
863
|
+
});
|
|
864
|
+
Object.defineProperty(this, "uploadImage", {
|
|
865
|
+
enumerable: true,
|
|
866
|
+
configurable: true,
|
|
867
|
+
writable: true,
|
|
868
|
+
value: async (data, done) => {
|
|
869
|
+
var _a, _b, _c, _d;
|
|
870
|
+
if (!this.onImageCB) {
|
|
871
|
+
done({ progress: 100 });
|
|
872
|
+
throw new Error('image upload is not implemented');
|
|
873
|
+
}
|
|
874
|
+
if (!((_a = data.attachments) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
const file = data.attachments[0];
|
|
878
|
+
const res = await this.validateImage(file, {
|
|
879
|
+
...defaultImageValidation,
|
|
880
|
+
...((_b = this.props.imageValidation) !== null && _b !== void 0 ? _b : {}),
|
|
607
881
|
});
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
882
|
+
if (!res.isValid) {
|
|
883
|
+
logUnlayerError(`Image validation failed: ${res.title}`, res.description);
|
|
884
|
+
(_c = this.onErrorCB) === null || _c === void 0 ? void 0 : _c.call(this, res.title, res.description);
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
/*
|
|
888
|
+
* Unlayer only leaves its "uploading" state when `done` receives a url, so `done` must not be
|
|
889
|
+
* called before the upload succeeds or after it fails, otherwise the image widget gets stuck.
|
|
890
|
+
*/
|
|
891
|
+
try {
|
|
892
|
+
const { url } = await this.onImageCB(file);
|
|
893
|
+
done({ progress: 100, url });
|
|
894
|
+
}
|
|
895
|
+
catch (error) {
|
|
896
|
+
logUnlayerError('Image upload failed', error);
|
|
897
|
+
(_d = this.onErrorCB) === null || _d === void 0 ? void 0 : _d.call(this, 'Image upload failed', error instanceof ImageUploadError
|
|
898
|
+
? error.message
|
|
899
|
+
: 'Something went wrong while uploading the image. Please try again or select another image.');
|
|
900
|
+
}
|
|
612
901
|
}
|
|
613
|
-
};
|
|
614
|
-
this
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
902
|
+
});
|
|
903
|
+
Object.defineProperty(this, "startToolsReadyWatchdog", {
|
|
904
|
+
enumerable: true,
|
|
905
|
+
configurable: true,
|
|
906
|
+
writable: true,
|
|
907
|
+
value: () => {
|
|
908
|
+
this.clearToolsReadyWatchdog();
|
|
909
|
+
this.toolsReadyWatchdogId = window.setTimeout(() => {
|
|
910
|
+
var _a;
|
|
911
|
+
if (this.hasToolsRegistered) {
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
logUnlayerError('Unlayer custom tools did not finish loading. customJS may not have run, or tool registration stalled.', {
|
|
915
|
+
hasCoreLoaded: this.hasCoreLoaded,
|
|
916
|
+
hasToolsRegistered: this.hasToolsRegistered,
|
|
917
|
+
});
|
|
918
|
+
(_a = this.onErrorCB) === null || _a === void 0 ? void 0 : _a.call(this, 'Editor failed to load custom tools', 'Unlayer custom tools did not finish loading. Check the browser console for [dte-unlayer] details.');
|
|
919
|
+
}, UNLAYER_TOOLS_READY_TIMEOUT_MS);
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
Object.defineProperty(this, "clearToolsReadyWatchdog", {
|
|
923
|
+
enumerable: true,
|
|
924
|
+
configurable: true,
|
|
925
|
+
writable: true,
|
|
926
|
+
value: () => {
|
|
927
|
+
if (this.toolsReadyWatchdogId === undefined) {
|
|
619
928
|
return;
|
|
620
929
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
hasToolsRegistered: this.hasToolsRegistered
|
|
624
|
-
});
|
|
625
|
-
(_this_onErrorCB = (_this = this).onErrorCB) === null || _this_onErrorCB === void 0 ? void 0 : _this_onErrorCB.call(_this, 'Editor failed to load custom tools', 'Unlayer custom tools did not finish loading. Check the browser console for [dte-unlayer] details.');
|
|
626
|
-
}, UNLAYER_TOOLS_READY_TIMEOUT_MS);
|
|
627
|
-
};
|
|
628
|
-
this.clearToolsReadyWatchdog = ()=>{
|
|
629
|
-
if (this.toolsReadyWatchdogId === undefined) {
|
|
630
|
-
return;
|
|
930
|
+
window.clearTimeout(this.toolsReadyWatchdogId);
|
|
931
|
+
this.toolsReadyWatchdogId = undefined;
|
|
631
932
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
URL.
|
|
651
|
-
|
|
652
|
-
|
|
933
|
+
});
|
|
934
|
+
Object.defineProperty(this, "validateImage", {
|
|
935
|
+
enumerable: true,
|
|
936
|
+
configurable: true,
|
|
937
|
+
writable: true,
|
|
938
|
+
value: async (file, imageValidation) => {
|
|
939
|
+
const { maxFileSize, maxHeight, maxWidth } = imageValidation;
|
|
940
|
+
if (file.size > maxFileSize) {
|
|
941
|
+
const maxSizeMB = (maxFileSize / 1024 / 1024).toFixed(2);
|
|
942
|
+
const fileSizeMB = (file.size / 1024 / 1024).toFixed(2);
|
|
943
|
+
return {
|
|
944
|
+
isValid: false,
|
|
945
|
+
title: 'Image size limit reached',
|
|
946
|
+
description: `This image is ${fileSizeMB}MB, which is above the ${maxSizeMB}MB limit. Please upload a smaller file to continue.`,
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
return new Promise(resolve => {
|
|
950
|
+
const img = new Image();
|
|
951
|
+
const objectUrl = URL.createObjectURL(file);
|
|
952
|
+
img.onload = () => {
|
|
953
|
+
URL.revokeObjectURL(objectUrl);
|
|
954
|
+
const { height, width } = img;
|
|
955
|
+
if (width > maxWidth || height > maxHeight) {
|
|
956
|
+
resolve({
|
|
957
|
+
isValid: false,
|
|
958
|
+
title: 'Dimension limit reached',
|
|
959
|
+
description: `These image dimensions (${width}x${height}px) exceed the ${maxWidth}x${maxHeight}px limit. Please resize the image and try again.`,
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
else {
|
|
963
|
+
resolve({ isValid: true, title: '', description: '' });
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
img.onerror = () => {
|
|
967
|
+
URL.revokeObjectURL(objectUrl);
|
|
653
968
|
resolve({
|
|
654
969
|
isValid: false,
|
|
655
|
-
title: '
|
|
656
|
-
description:
|
|
657
|
-
});
|
|
658
|
-
} else {
|
|
659
|
-
resolve({
|
|
660
|
-
isValid: true,
|
|
661
|
-
title: '',
|
|
662
|
-
description: ''
|
|
970
|
+
title: 'The image is broken',
|
|
971
|
+
description: 'Looks like this image isn’t valid. Please choose another image and try again.',
|
|
663
972
|
});
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
isValid: false,
|
|
670
|
-
title: 'The image is broken',
|
|
671
|
-
description: 'Looks like this image isn’t valid. Please choose another image and try again.'
|
|
672
|
-
});
|
|
673
|
-
};
|
|
674
|
-
img.src = objectUrl;
|
|
675
|
-
});
|
|
676
|
-
};
|
|
973
|
+
};
|
|
974
|
+
img.src = objectUrl;
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
});
|
|
677
978
|
const schemaData = this.props.schema ? schemaBuildMap(this.props.schema) : undefined;
|
|
678
|
-
this.schemaDummyData = (
|
|
679
|
-
this.dateSchemaFieldKeys = new Set(Object.values((
|
|
979
|
+
this.schemaDummyData = ((_a = schemaData === null || schemaData === void 0 ? void 0 : schemaData.dummyData) !== null && _a !== void 0 ? _a : {});
|
|
980
|
+
this.dateSchemaFieldKeys = new Set(Object.values((_b = schemaData === null || schemaData === void 0 ? void 0 : schemaData.map) !== null && _b !== void 0 ? _b : {})
|
|
981
|
+
.filter(field => field.isValue && schemaIsDate(field.node))
|
|
982
|
+
.map(field => field.fullKey));
|
|
983
|
+
// Each entry's type value is derived from it; the name shown can differ (E_SIGN_FIELD_TYPE_LABELS).
|
|
680
984
|
this.props.eSignFieldTypes = [
|
|
681
985
|
'Signature',
|
|
682
986
|
'Initials',
|
|
683
987
|
'Date Signed',
|
|
684
988
|
'Date Signed Offset',
|
|
685
|
-
'Full Name'
|
|
989
|
+
'Full Name',
|
|
686
990
|
];
|
|
687
991
|
this.unlayerRef = {
|
|
688
|
-
loadDesign:
|
|
689
|
-
var
|
|
690
|
-
(
|
|
992
|
+
loadDesign: design => {
|
|
993
|
+
var _a;
|
|
994
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.loadDesign(design);
|
|
691
995
|
},
|
|
692
|
-
saveDesign:
|
|
693
|
-
var
|
|
694
|
-
(
|
|
996
|
+
saveDesign: cb => {
|
|
997
|
+
var _a;
|
|
998
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.saveDesign(design => {
|
|
695
999
|
unlayerToolsNormalizeESignOffsets(design);
|
|
696
1000
|
cb(design);
|
|
697
1001
|
});
|
|
698
1002
|
},
|
|
699
|
-
exportHtml:
|
|
700
|
-
var
|
|
701
|
-
(
|
|
1003
|
+
exportHtml: cb => {
|
|
1004
|
+
var _a;
|
|
1005
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
|
|
702
1006
|
const result = ensureChunksFonts(data);
|
|
703
1007
|
unlayerToolsNormalizeESignOffsets(result === null || result === void 0 ? void 0 : result.design);
|
|
704
1008
|
result.demoData = this.buildCalculatedFieldDemoData(result.design);
|
|
705
1009
|
cb(result);
|
|
706
1010
|
});
|
|
707
1011
|
},
|
|
708
|
-
sendFormList:
|
|
1012
|
+
sendFormList: forms => {
|
|
709
1013
|
this.sendFormList(forms);
|
|
710
1014
|
},
|
|
711
|
-
sendFormFields: (formId, fields)=>{
|
|
1015
|
+
sendFormFields: (formId, fields) => {
|
|
712
1016
|
this.sendFormFields(formId, fields);
|
|
713
1017
|
},
|
|
714
|
-
sendCalcFieldLabels:
|
|
1018
|
+
sendCalcFieldLabels: labels => {
|
|
715
1019
|
this.sendCalcFieldLabels(labels);
|
|
716
1020
|
},
|
|
717
|
-
setMergeTags:
|
|
1021
|
+
setMergeTags: tags => {
|
|
718
1022
|
this.setMergeTags(tags);
|
|
719
|
-
}
|
|
1023
|
+
},
|
|
720
1024
|
};
|
|
721
1025
|
}
|
|
722
1026
|
}
|
|
723
|
-
|
|
724
1027
|
//# sourceMappingURL=store.js.map
|