@servicetitan/dte-unlayer 0.153.0 → 0.155.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/display-conditions/ConditionRow.d.ts.map +1 -1
- package/dist/display-conditions/ConditionRow.js +111 -95
- package/dist/display-conditions/ConditionRow.js.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.d.ts +3 -3
- package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.js +8 -95
- package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
- package/dist/display-conditions/useConditionForms.d.ts +22 -0
- package/dist/display-conditions/useConditionForms.d.ts.map +1 -0
- package/dist/display-conditions/useConditionForms.js +110 -0
- package/dist/display-conditions/useConditionForms.js.map +1 -0
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.d.ts +11 -0
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.d.ts.map +1 -0
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.js +192 -0
- package/dist/e-sign-offset/ESignDateSignedOffsetModal.js.map +1 -0
- package/dist/e-sign-offset/ESignOffsetRuleRow.d.ts +20 -0
- package/dist/e-sign-offset/ESignOffsetRuleRow.d.ts.map +1 -0
- package/dist/e-sign-offset/ESignOffsetRuleRow.js +87 -0
- package/dist/e-sign-offset/ESignOffsetRuleRow.js.map +1 -0
- package/dist/e-sign-offset/eSignOffsetController.d.ts +10 -0
- package/dist/e-sign-offset/eSignOffsetController.d.ts.map +1 -0
- package/dist/e-sign-offset/eSignOffsetController.js +27 -0
- package/dist/e-sign-offset/eSignOffsetController.js.map +1 -0
- 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 +2 -2
- package/dist/editor-core-source.js.map +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +8 -0
- package/dist/editor.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/merge-tags.d.ts +6 -10
- package/dist/merge-tags.d.ts.map +1 -1
- package/dist/merge-tags.js +35 -44
- package/dist/merge-tags.js.map +1 -1
- package/dist/shared/const.d.ts +30 -0
- package/dist/shared/const.d.ts.map +1 -1
- package/dist/shared/const.js +5 -0
- package/dist/shared/const.js.map +1 -1
- package/dist/shared/e-sign-offset.d.ts +21 -0
- package/dist/shared/e-sign-offset.d.ts.map +1 -0
- package/dist/shared/e-sign-offset.js +130 -0
- package/dist/shared/e-sign-offset.js.map +1 -0
- package/dist/shared/instance-id.d.ts +13 -0
- package/dist/shared/instance-id.d.ts.map +1 -0
- package/dist/shared/instance-id.js +22 -0
- package/dist/shared/instance-id.js.map +1 -0
- package/dist/store.d.ts +15 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +80 -5
- package/dist/store.js.map +1 -1
- package/dist/tools.d.ts +18 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +68 -1
- package/dist/tools.js.map +1 -1
- package/dist/unlayer-interface.d.ts +11 -1
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer-interface.js.map +1 -1
- package/dist/unlayer.d.ts.map +1 -1
- package/dist/unlayer.js +5 -3
- package/dist/unlayer.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/e-sign-offset.test.ts +281 -0
- package/src/__tests__/merge-tags.test.ts +98 -76
- package/src/__tests__/store.merge-tags.test.ts +186 -0
- package/src/display-conditions/ConditionRow.tsx +86 -81
- package/src/display-conditions/DisplayConditionModal.tsx +12 -116
- package/src/display-conditions/useConditionForms.ts +146 -0
- package/src/e-sign-offset/ESignDateSignedOffsetModal.tsx +197 -0
- package/src/e-sign-offset/ESignOffsetRuleRow.tsx +101 -0
- package/src/e-sign-offset/eSignOffsetController.ts +39 -0
- package/src/editor-core-source.ts +2 -2
- package/src/editor.tsx +9 -0
- package/src/index.ts +1 -2
- package/src/merge-tags.ts +41 -60
- package/src/shared/const.ts +37 -0
- package/src/shared/e-sign-offset.ts +173 -0
- package/src/shared/instance-id.ts +23 -0
- package/src/store.ts +106 -5
- package/src/tools.ts +87 -1
- package/src/unlayer-interface.tsx +11 -1
- package/src/unlayer.tsx +5 -3
package/src/tools.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
constGenericsEditor,
|
|
3
|
+
E_SIGN_DATE_SIGNED_OFFSET_TYPE,
|
|
4
|
+
E_SIGN_DATE_SIGNED_OFFSET_VALUES_KEY,
|
|
5
|
+
E_SIGN_TOOL_SLUG,
|
|
6
|
+
UnlayerToolMetaData,
|
|
7
|
+
} from './shared/const';
|
|
8
|
+
import { isESignOffsetSettings, normalizeESignOffsetSettings } from './shared/e-sign-offset';
|
|
2
9
|
import { editIconSvg } from './shared/edit-icon';
|
|
10
|
+
import { generateInstanceId, INSTANCE_ID_TOOL_SLUGS } from './shared/instance-id';
|
|
3
11
|
import { unlayerToolsParseUnitKey } from './shared/tools';
|
|
4
12
|
import { versions } from './unlayer';
|
|
5
13
|
|
|
@@ -202,6 +210,84 @@ export const unlayerToolsListCustom = (design: UnlayerDesignFormat): UnlayerDesi
|
|
|
202
210
|
return tools;
|
|
203
211
|
};
|
|
204
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Makes `values.id` unique across all instance-id tools (see `INSTANCE_ID_TOOL_SLUGS`)
|
|
215
|
+
* in the design. Duplicating content/rows in Unlayer copies the values verbatim, so
|
|
216
|
+
* every copy ends up with the original's GUID; this gives each copy a fresh one.
|
|
217
|
+
*
|
|
218
|
+
* Of the contents sharing an id, the one that keeps it is the first in document
|
|
219
|
+
* order that is not the just-added content (`addedHtmlID`), so the original always
|
|
220
|
+
* wins over its duplicate regardless of where the copy was inserted.
|
|
221
|
+
*
|
|
222
|
+
* @returns `true` when at least one id was regenerated.
|
|
223
|
+
*/
|
|
224
|
+
export const unlayerToolsDedupeInstanceIds = (
|
|
225
|
+
design: UnlayerDesignFormat,
|
|
226
|
+
addedHtmlID?: string
|
|
227
|
+
): boolean => {
|
|
228
|
+
const byId = new Map<string, UnlayerDesignCustomTool[]>();
|
|
229
|
+
|
|
230
|
+
unlayerToolsIterateCustom(design, tool => {
|
|
231
|
+
const id = tool.values?.id;
|
|
232
|
+
|
|
233
|
+
if (INSTANCE_ID_TOOL_SLUGS.includes(tool.slug) && typeof id === 'string' && id) {
|
|
234
|
+
const key = `${tool.slug}|${id}`;
|
|
235
|
+
byId.set(key, [...(byId.get(key) ?? []), tool]);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
let hasChanges = false;
|
|
240
|
+
|
|
241
|
+
byId.forEach(tools => {
|
|
242
|
+
if (tools.length < 2) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const keeper = tools.find(tool => tool.values?._meta?.htmlID !== addedHtmlID) ?? tools[0];
|
|
247
|
+
|
|
248
|
+
for (const tool of tools) {
|
|
249
|
+
if (tool !== keeper) {
|
|
250
|
+
/*
|
|
251
|
+
* If no id can be generated the copy is left without one, which is still
|
|
252
|
+
* better than two instances bound to the same image.
|
|
253
|
+
*/
|
|
254
|
+
tool.values.id = generateInstanceId();
|
|
255
|
+
hasChanges = true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
return hasChanges;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Gives every "Date Signed Offset" e-sign placement valid settings. Unlayer never applies an
|
|
265
|
+
* option's default to placements saved before the option existed, and the backend rejects a
|
|
266
|
+
* design whose dateSignedOffset recipient has no settings.
|
|
267
|
+
*/
|
|
268
|
+
export const unlayerToolsNormalizeESignOffsets = (design: UnlayerDesignFormat): boolean => {
|
|
269
|
+
let hasChanges = false;
|
|
270
|
+
|
|
271
|
+
unlayerToolsIterateCustom(design, tool => {
|
|
272
|
+
if (
|
|
273
|
+
tool.slug !== E_SIGN_TOOL_SLUG ||
|
|
274
|
+
tool.values?.eSignFieldType !== E_SIGN_DATE_SIGNED_OFFSET_TYPE
|
|
275
|
+
) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const settings = tool.values[E_SIGN_DATE_SIGNED_OFFSET_VALUES_KEY];
|
|
280
|
+
|
|
281
|
+
if (!isESignOffsetSettings(settings)) {
|
|
282
|
+
tool.values[E_SIGN_DATE_SIGNED_OFFSET_VALUES_KEY] =
|
|
283
|
+
normalizeESignOffsetSettings(settings);
|
|
284
|
+
hasChanges = true;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
return hasChanges;
|
|
289
|
+
};
|
|
290
|
+
|
|
205
291
|
export const unlayerToolsBuildDesign = (tools: UnlayerDesignTool[]): UnlayerDesignFormat => {
|
|
206
292
|
const design = unlayerGetDefaultDesign();
|
|
207
293
|
|
|
@@ -45,13 +45,23 @@ export interface UnlayerRef {
|
|
|
45
45
|
sendFormList(forms: FormInfo[]): void;
|
|
46
46
|
sendFormFields(formId: number, fields: FormFieldInfo[]): void;
|
|
47
47
|
sendCalcFieldLabels(labels: Record<string, string>): void;
|
|
48
|
+
/**
|
|
49
|
+
* Replaces the editor's merge tag menu with `tags` (grouped). Safe to call before the editor is
|
|
50
|
+
* ready — the tags are applied once it is. Lets hosts add tags that finish loading after init
|
|
51
|
+
* (e.g. form fields) without remounting the editor.
|
|
52
|
+
*/
|
|
53
|
+
setMergeTags(tags: UnlayerEditorMergeTagInfo[] | undefined): void;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
export interface UnlayerEditorMergeTagInfo {
|
|
51
57
|
id: string;
|
|
52
58
|
name: string;
|
|
53
59
|
propertyPath: string;
|
|
54
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Submenu the tag is listed under. A string is a single submenu (`'Custom Fields'`);
|
|
62
|
+
* an array nests submenus in order (`['Forms', 'Customer Intake']` → Forms ▸ Customer Intake ▸ tag).
|
|
63
|
+
*/
|
|
64
|
+
group?: string | string[];
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
export interface UnlayerEditorCustomTool {
|
package/src/unlayer.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { emitDisplayCondition } from './display-conditions/displayConditionController';
|
|
2
2
|
import { editorCoreScript, editorCoreStyles, editorCoreTools } from './editor-core';
|
|
3
3
|
import { logUnlayerError } from './log';
|
|
4
|
-
import {
|
|
4
|
+
import { toUnlayerMergeTags } from './merge-tags';
|
|
5
5
|
import { constGenericsEditor } from './shared/const';
|
|
6
6
|
import { unlayerSupportedFonts } from './shared/fonts';
|
|
7
7
|
import {
|
|
@@ -299,6 +299,10 @@ export const createUnlayerEditor = (
|
|
|
299
299
|
tables: true,
|
|
300
300
|
},
|
|
301
301
|
},
|
|
302
|
+
/*
|
|
303
|
+
* Flat only: nested groups here break custom tool registration. UnlayerStore applies
|
|
304
|
+
* the grouped config via setMergeTags once the editor is ready.
|
|
305
|
+
*/
|
|
302
306
|
mergeTags: toUnlayerMergeTags(mergeTags, { groups: false }),
|
|
303
307
|
projectId: 5713,
|
|
304
308
|
version: latest ? undefined : versions.unlayer,
|
|
@@ -362,8 +366,6 @@ export const createUnlayerEditor = (
|
|
|
362
366
|
document.getElementById = currentFind;
|
|
363
367
|
}
|
|
364
368
|
|
|
365
|
-
scheduleUnlayerMergeTags(result, mergeTags);
|
|
366
|
-
|
|
367
369
|
if (displayConditions) {
|
|
368
370
|
result.registerCallback(
|
|
369
371
|
'displayCondition',
|