@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.
Files changed (158) hide show
  1. package/dist/api-core.js +22 -29
  2. package/dist/api-core.js.map +1 -1
  3. package/dist/api-custom-tools.js +23 -29
  4. package/dist/api-custom-tools.js.map +1 -1
  5. package/dist/business-calendar/BusinessCalendarDrawer.d.ts +19 -0
  6. package/dist/business-calendar/BusinessCalendarDrawer.d.ts.map +1 -0
  7. package/dist/business-calendar/BusinessCalendarDrawer.js +41 -0
  8. package/dist/business-calendar/BusinessCalendarDrawer.js.map +1 -0
  9. package/dist/business-calendar/business-calendar-requests.d.ts +25 -0
  10. package/dist/business-calendar/business-calendar-requests.d.ts.map +1 -0
  11. package/dist/business-calendar/business-calendar-requests.js +46 -0
  12. package/dist/business-calendar/business-calendar-requests.js.map +1 -0
  13. package/dist/business-calendar/business-calendar-state.d.ts +22 -0
  14. package/dist/business-calendar/business-calendar-state.d.ts.map +1 -0
  15. package/dist/business-calendar/business-calendar-state.js +74 -0
  16. package/dist/business-calendar/business-calendar-state.js.map +1 -0
  17. package/dist/business-calendar/useBusinessCalendarRequests.d.ts +15 -0
  18. package/dist/business-calendar/useBusinessCalendarRequests.d.ts.map +1 -0
  19. package/dist/business-calendar/useBusinessCalendarRequests.js +30 -0
  20. package/dist/business-calendar/useBusinessCalendarRequests.js.map +1 -0
  21. package/dist/display-conditions/ConditionGroup.d.ts.map +1 -1
  22. package/dist/display-conditions/ConditionGroup.js +20 -89
  23. package/dist/display-conditions/ConditionGroup.js.map +1 -1
  24. package/dist/display-conditions/ConditionGroupsSection.d.ts.map +1 -1
  25. package/dist/display-conditions/ConditionGroupsSection.js +2 -70
  26. package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
  27. package/dist/display-conditions/ConditionRow.d.ts.map +1 -1
  28. package/dist/display-conditions/ConditionRow.js +88 -212
  29. package/dist/display-conditions/ConditionRow.js.map +1 -1
  30. package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -1
  31. package/dist/display-conditions/DisplayConditionModal.js +39 -194
  32. package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
  33. package/dist/display-conditions/LookupValueControl.js +42 -105
  34. package/dist/display-conditions/LookupValueControl.js.map +1 -1
  35. package/dist/display-conditions/SeparatorWithChip.js +1 -10
  36. package/dist/display-conditions/SeparatorWithChip.js.map +1 -1
  37. package/dist/display-conditions/constants.js +15 -20
  38. package/dist/display-conditions/constants.js.map +1 -1
  39. package/dist/display-conditions/displayConditionController.js +5 -8
  40. package/dist/display-conditions/displayConditionController.js.map +1 -1
  41. package/dist/display-conditions/lookupOptionsController.js +16 -16
  42. package/dist/display-conditions/lookupOptionsController.js.map +1 -1
  43. package/dist/display-conditions/nunjucks.js +98 -116
  44. package/dist/display-conditions/nunjucks.js.map +1 -1
  45. package/dist/display-conditions/schemaDataPoints.js +13 -11
  46. package/dist/display-conditions/schemaDataPoints.js.map +1 -1
  47. package/dist/display-conditions/types.js +23 -67
  48. package/dist/display-conditions/types.js.map +1 -1
  49. package/dist/display-conditions/useConditionForms.js +38 -56
  50. package/dist/display-conditions/useConditionForms.js.map +1 -1
  51. package/dist/display-conditions/useLookupOptions.js +24 -44
  52. package/dist/display-conditions/useLookupOptions.js.map +1 -1
  53. package/dist/e-sign-offset/ESignDateSignedOffsetModal.js +42 -155
  54. package/dist/e-sign-offset/ESignDateSignedOffsetModal.js.map +1 -1
  55. package/dist/e-sign-offset/ESignOffsetRuleRow.js +12 -73
  56. package/dist/e-sign-offset/ESignOffsetRuleRow.js.map +1 -1
  57. package/dist/e-sign-offset/eSignOffsetController.js +5 -8
  58. package/dist/e-sign-offset/eSignOffsetController.js.map +1 -1
  59. package/dist/editor-core-source.d.ts +2 -2
  60. package/dist/editor-core-source.d.ts.map +1 -1
  61. package/dist/editor-core-source.js +3 -3
  62. package/dist/editor-core-source.js.map +1 -1
  63. package/dist/editor-core.js +2 -2
  64. package/dist/editor-core.js.map +1 -1
  65. package/dist/editor.d.ts.map +1 -1
  66. package/dist/editor.js +56 -118
  67. package/dist/editor.js.map +1 -1
  68. package/dist/image-upload-error.js +3 -3
  69. package/dist/image-upload-error.js.map +1 -1
  70. package/dist/index.d.ts +1 -0
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +0 -1
  73. package/dist/index.js.map +1 -1
  74. package/dist/loadScript.js +7 -8
  75. package/dist/loadScript.js.map +1 -1
  76. package/dist/log.js +2 -3
  77. package/dist/log.js.map +1 -1
  78. package/dist/merge-tags.js +18 -17
  79. package/dist/merge-tags.js.map +1 -1
  80. package/dist/shared/configs.js +1 -2
  81. package/dist/shared/configs.js.map +1 -1
  82. package/dist/shared/const.d.ts +70 -0
  83. package/dist/shared/const.d.ts.map +1 -1
  84. package/dist/shared/const.js +13 -4
  85. package/dist/shared/const.js.map +1 -1
  86. package/dist/shared/date-calc.js +47 -38
  87. package/dist/shared/date-calc.js.map +1 -1
  88. package/dist/shared/e-sign-offset.js +46 -63
  89. package/dist/shared/e-sign-offset.js.map +1 -1
  90. package/dist/shared/edit-icon.js +0 -1
  91. package/dist/shared/edit-icon.js.map +1 -1
  92. package/dist/shared/fonts.js +16 -17
  93. package/dist/shared/fonts.js.map +1 -1
  94. package/dist/shared/forms.js +16 -38
  95. package/dist/shared/forms.js.map +1 -1
  96. package/dist/shared/instance-id.js +6 -9
  97. package/dist/shared/instance-id.js.map +1 -1
  98. package/dist/shared/nunjucks-helpers.js +2 -5
  99. package/dist/shared/nunjucks-helpers.js.map +1 -1
  100. package/dist/shared/schema.js +52 -96
  101. package/dist/shared/schema.js.map +1 -1
  102. package/dist/shared/tools.js +6 -13
  103. package/dist/shared/tools.js.map +1 -1
  104. package/dist/store.d.ts +15 -1
  105. package/dist/store.d.ts.map +1 -1
  106. package/dist/store.js +851 -548
  107. package/dist/store.js.map +1 -1
  108. package/dist/tools.js +133 -143
  109. package/dist/tools.js.map +1 -1
  110. package/dist/unlayer-interface.d.ts +15 -4
  111. package/dist/unlayer-interface.d.ts.map +1 -1
  112. package/dist/unlayer-interface.js +1 -2
  113. package/dist/unlayer-interface.js.map +1 -1
  114. package/dist/unlayer.js +86 -113
  115. package/dist/unlayer.js.map +1 -1
  116. package/dist/vendor/dte-shared/business-calendar-validation.utils.d.ts +25 -0
  117. package/dist/vendor/dte-shared/business-calendar-validation.utils.js +80 -0
  118. package/dist/vendor/dte-shared/components/business-calendar-section.d.ts +15 -0
  119. package/dist/vendor/dte-shared/components/business-calendar-section.js +14 -0
  120. package/dist/vendor/dte-shared/components/schedule-drawer.d.ts +18 -0
  121. package/dist/vendor/dte-shared/components/schedule-drawer.js +119 -0
  122. package/dist/vendor/dte-shared/components/schedule-picker.d.ts +8 -0
  123. package/dist/vendor/dte-shared/components/schedule-picker.js +88 -0
  124. package/dist/vendor/dte-shared/constants.d.ts +31 -0
  125. package/dist/vendor/dte-shared/constants.js +34 -0
  126. package/dist/vendor/dte-shared/field-schedule-editor-context.d.ts +31 -0
  127. package/dist/vendor/dte-shared/field-schedule-editor-context.js +110 -0
  128. package/dist/vendor/dte-shared/index.d.ts +8 -0
  129. package/dist/vendor/dte-shared/index.js +7 -0
  130. package/dist/vendor/dte-shared/schedule-bindings.utils.d.ts +22 -0
  131. package/dist/vendor/dte-shared/schedule-bindings.utils.js +31 -0
  132. package/dist/vendor/dte-shared/styles/schedule.css +19 -0
  133. package/dist/vendor/dte-shared/types.d.ts +129 -0
  134. package/dist/vendor/dte-shared/types.js +1 -0
  135. package/package.json +7 -1
  136. package/src/__tests__/business-calendar-drawer.test.tsx +183 -0
  137. package/src/__tests__/business-calendar-requests.test.ts +166 -0
  138. package/src/__tests__/business-calendar-state.test.tsx +142 -0
  139. package/src/__tests__/condition-row.test.tsx +51 -8
  140. package/src/__tests__/e-sign-offset-modal.test.tsx +13 -2
  141. package/src/__tests__/store.business-calendar.test.ts +185 -0
  142. package/src/__tests__/unlayer.e-sign-types.test.ts +30 -0
  143. package/src/business-calendar/BusinessCalendarDrawer.tsx +76 -0
  144. package/src/business-calendar/business-calendar-requests.ts +80 -0
  145. package/src/business-calendar/business-calendar-state.ts +113 -0
  146. package/src/business-calendar/useBusinessCalendarRequests.ts +49 -0
  147. package/src/display-conditions/ConditionGroup.tsx +13 -3
  148. package/src/display-conditions/ConditionGroupsSection.tsx +24 -21
  149. package/src/display-conditions/ConditionRow.tsx +75 -32
  150. package/src/display-conditions/DisplayConditionModal.tsx +18 -59
  151. package/src/e-sign-offset/ESignDateSignedOffsetModal.tsx +6 -6
  152. package/src/editor-core-source.ts +2 -2
  153. package/src/editor.tsx +15 -0
  154. package/src/index.ts +10 -0
  155. package/src/shared/const.ts +59 -0
  156. package/src/store.ts +67 -5
  157. package/src/unlayer-interface.tsx +15 -4
  158. package/src/unlayer.tsx +5 -5
package/src/editor.tsx CHANGED
@@ -7,6 +7,9 @@ import {
7
7
  useRef,
8
8
  useState,
9
9
  } from 'react';
10
+ import { useBusinessCalendarState } from './business-calendar/business-calendar-state';
11
+ import { BusinessCalendarDrawer } from './business-calendar/BusinessCalendarDrawer';
12
+ import { useBusinessCalendarRequests } from './business-calendar/useBusinessCalendarRequests';
10
13
  import { DisplayConditionModal } from './display-conditions/DisplayConditionModal';
11
14
  import { ESignDateSignedOffsetModal } from './e-sign-offset/ESignDateSignedOffsetModal';
12
15
  import { getErrorMessage } from './log';
@@ -133,6 +136,9 @@ export const UnlayerEditor = forwardRef<UnlayerRef, UnlayerEditorProps>((props,
133
136
  return () => store.setOnCalcFieldSelect();
134
137
  }, [props.opts.onCalcFieldSelect, store]);
135
138
 
139
+ const businessCalendar = useBusinessCalendarRequests(store, props.opts);
140
+ useBusinessCalendarState(store, props.opts);
141
+
136
142
  const { minHeight = 800, style = {} } = props;
137
143
 
138
144
  return (
@@ -155,6 +161,15 @@ export const UnlayerEditor = forwardRef<UnlayerRef, UnlayerEditorProps>((props,
155
161
  onConditionFormSelect={props.opts.onConditionFormSelect}
156
162
  />
157
163
  )}
164
+ {businessCalendar.drawer && props.opts.onScheduleBindingsChange && (
165
+ <BusinessCalendarDrawer
166
+ key={businessCalendar.drawer.id}
167
+ request={businessCalendar.drawer}
168
+ host={props.opts}
169
+ portalContainer={props.opts.displayConditionModalPortalContainer}
170
+ onClose={businessCalendar.closeDrawer}
171
+ />
172
+ )}
158
173
  </div>
159
174
  );
160
175
  });
package/src/index.ts CHANGED
@@ -21,3 +21,13 @@ export { versions } from './unlayer';
21
21
  export * from './shared/date-calc';
22
22
  export { emptyArrayIfNull } from './shared/nunjucks-helpers';
23
23
  export * from './display-conditions/lookupOptionsController';
24
+ export type {
25
+ BusinessCalendarHostProps,
26
+ BusinessCalendarRules,
27
+ BusinessDaySchedule,
28
+ FieldScheduleBinding,
29
+ HolidayCatalog,
30
+ KnownHoliday,
31
+ SaveScheduleRequest,
32
+ WeekendDay,
33
+ } from '@servicetitan/dte-shared';
@@ -1,3 +1,4 @@
1
+ import type { BusinessDaySchedule, HolidayCatalog } from '@servicetitan/dte-shared';
1
2
  import type { DisplayConditionState } from '../display-conditions/types';
2
3
  import type { BusinessCalendar } from './date-calc';
3
4
  import { SchemaObject } from './schema';
@@ -49,6 +50,62 @@ export interface UnlayerEventESignOffset {
49
50
  value: ESignDateSignedOffsetSettings;
50
51
  }
51
52
 
53
+ /**
54
+ * Names shown for e-sign field types whose title differs from the type list entry it is derived
55
+ * from (by type value). Only the label changes: the stored value stays, so saved designs and the
56
+ * `esign_<recipient>_<type>` placeholder are unaffected.
57
+ */
58
+ export const E_SIGN_FIELD_TYPE_LABELS: Readonly<Record<string, string | undefined>> = {
59
+ [E_SIGN_DATE_SIGNED_OFFSET_TYPE]: 'Calculated Signing Date',
60
+ };
61
+
62
+ /**
63
+ * Payload of `--business-calendar-request` (iframe to parent): what a date field's inline schedule
64
+ * settings (a calculated field's or an e-sign "Date Signed Offset" field's) ask the parent window
65
+ * to do. `fieldKey` is the tool's instance id (`values.id`), the key DTE binds the schedule to.
66
+ * - `toggle` / `select`: the exclusion toggle and the schedule picker.
67
+ * - `create` / `edit`: open the schedule drawer, for a new schedule or `scheduleId`.
68
+ * - `delete`: delete the selected schedule; the outcome comes back as `--business-calendar-result`.
69
+ */
70
+ export type UnlayerEventBusinessCalendarRequest =
71
+ | { action: 'toggle'; fieldKey: string; enabled: boolean }
72
+ | { action: 'select'; fieldKey: string; scheduleId?: number }
73
+ | { action: 'create'; fieldKey: string }
74
+ | { action: 'edit'; fieldKey: string; scheduleId: number }
75
+ | { action: 'delete'; fieldKey: string; scheduleId: number; requestId: string };
76
+
77
+ /** Payload of `--business-calendar-result` (parent to iframe): how a `delete` request ended. */
78
+ export interface UnlayerEventBusinessCalendarResult {
79
+ requestId: string;
80
+ /** Why it failed, shown under the schedule; absent on success. */
81
+ error?: string;
82
+ }
83
+
84
+ /**
85
+ * Payload of `--business-calendar-state` (parent to iframe), sent whenever the host's schedule
86
+ * props change: what the property editors show and the calendars the previews use.
87
+ */
88
+ export interface UnlayerEventBusinessCalendarState {
89
+ /** Whether the host edits schedules (it passes `onScheduleBindingsChange`). */
90
+ enabled: boolean;
91
+ /** The fields whose exclusion toggle is on, by field key, with their schedule (none: default). */
92
+ bindings: Record<string, { scheduleId?: number }>;
93
+ /** The schedules a field can pick, default first, as the host passes them. */
94
+ schedules: BusinessDaySchedule[];
95
+ schedulesLoading?: boolean;
96
+ schedulesError?: string;
97
+ /** The tenant's known holidays, for the schedule preview's names. */
98
+ holidayCatalog?: HolidayCatalog;
99
+ holidayCatalogLoading?: boolean;
100
+ holidayCatalogError?: string;
101
+ /** Whether the host can delete schedules (it passes `onDeleteSchedule`). */
102
+ canDeleteSchedule: boolean;
103
+ /** Calendars of the bound fields, by field key. */
104
+ fieldCalendars: Record<string, BusinessCalendar>;
105
+ /** The default calendar's holidays. */
106
+ holidays?: string[];
107
+ }
108
+
52
109
  export interface UnlayerEditorUnit {
53
110
  id: string;
54
111
  generic: string;
@@ -78,6 +135,8 @@ export interface UnlayerEventRegister {
78
135
  units?: UnlayerEditorUnit[];
79
136
  eSignRecipients?: UnlayerEditorESignRecipientInfo[];
80
137
  eSignFieldTypes?: string[];
138
+ /** {@link E_SIGN_FIELD_TYPE_LABELS}, for the e-sign tool's canvas label. */
139
+ eSignFieldTypeLabels?: Readonly<Record<string, string | undefined>>;
81
140
  customTools?: {
82
141
  key: string;
83
142
  title?: string;
package/src/store.ts CHANGED
@@ -4,11 +4,15 @@ import { loadScript } from './loadScript';
4
4
  import { logUnlayerError } from './log';
5
5
  import { toUnlayerMergeTags, type UnlayerMergeTagsConfig } from './merge-tags';
6
6
  import { defaultImageValidation } from './shared/configs';
7
- import type {
8
- UnlayerEditorTwin,
9
- UnlayerEventConfig,
10
- UnlayerEventESignOffset,
11
- UnlayerEventRegister,
7
+ import {
8
+ E_SIGN_FIELD_TYPE_LABELS,
9
+ type UnlayerEditorTwin,
10
+ type UnlayerEventBusinessCalendarRequest,
11
+ type UnlayerEventBusinessCalendarResult,
12
+ type UnlayerEventBusinessCalendarState,
13
+ type UnlayerEventConfig,
14
+ type UnlayerEventESignOffset,
15
+ type UnlayerEventRegister,
12
16
  } from './shared/const';
13
17
  import { normalizeESignOffsetSettings } from './shared/e-sign-offset';
14
18
  import { unlayerSupportedFonts } from './shared/fonts';
@@ -212,6 +216,9 @@ export class UnlayerStore {
212
216
  private isEditorReady = false;
213
217
  private isMergeTagsApplied = false;
214
218
  private mergeTagsConfig?: UnlayerMergeTagsConfig;
219
+ /** Latest `--business-calendar-state` payload, and the last one sent to the iframe. */
220
+ private businessCalendarStateJson?: string;
221
+ private sentBusinessCalendarStateJson?: string;
215
222
 
216
223
  private onMessageCB?: (type: string, data: any) => void;
217
224
  private onChangeCB?: (info: UnlayerDesignChangeInfo) => void;
@@ -222,6 +229,7 @@ export class UnlayerStore {
222
229
  private onFormSelectCB?: (formId: number) => void;
223
230
  private onCalcFieldOpenCB?: (usedFormIds: number[]) => void;
224
231
  private onCalcFieldSelectCB?: (fieldKeys: string[]) => void;
232
+ private onBusinessCalendarRequestCB?: (request: UnlayerEventBusinessCalendarRequest) => void;
225
233
 
226
234
  constructor(readonly props: CreateUnlayerEditorProps) {
227
235
  const schemaData = this.props.schema ? schemaBuildMap(this.props.schema) : undefined;
@@ -232,6 +240,7 @@ export class UnlayerStore {
232
240
  .map(field => field.fullKey),
233
241
  );
234
242
 
243
+ // Each entry's type value is derived from it; the name shown can differ (E_SIGN_FIELD_TYPE_LABELS).
235
244
  this.props.eSignFieldTypes = [
236
245
  'Signature',
237
246
  'Initials',
@@ -379,6 +388,32 @@ export class UnlayerStore {
379
388
  this.onCalcFieldSelectCB = onCalcFieldSelect;
380
389
  };
381
390
 
391
+ setOnBusinessCalendarRequest = (
392
+ onBusinessCalendarRequest?: UnlayerStore['onBusinessCalendarRequestCB'],
393
+ ) => {
394
+ this.onBusinessCalendarRequestCB = onBusinessCalendarRequest;
395
+ };
396
+
397
+ /** Tells the iframe how a schedule `delete` request ended. */
398
+ sendBusinessCalendarResult = (result: UnlayerEventBusinessCalendarResult) => {
399
+ this.sendMessage('--business-calendar-result', JSON.parse(JSON.stringify(result)));
400
+ };
401
+
402
+ /**
403
+ * Keeps the schedule state for the iframe and sends it once the tools core has loaded (it
404
+ * goes out again right after `--config`). An unchanged state isn't sent again.
405
+ */
406
+ setBusinessCalendarState = (state: UnlayerEventBusinessCalendarState) => {
407
+ this.businessCalendarStateJson = JSON.stringify(state);
408
+
409
+ if (
410
+ this.hasCoreLoaded &&
411
+ this.businessCalendarStateJson !== this.sentBusinessCalendarStateJson
412
+ ) {
413
+ this.sendBusinessCalendarState();
414
+ }
415
+ };
416
+
382
417
  sendFormList = (forms: FormInfo[]) => {
383
418
  this.sendMessage('--form-list', { forms });
384
419
  };
@@ -515,12 +550,19 @@ export class UnlayerStore {
515
550
  };
516
551
 
517
552
  this.sendMessage('--config', JSON.parse(JSON.stringify(configData)));
553
+ // Always: a reloaded tools core starts without it.
554
+ this.sendBusinessCalendarState();
518
555
  } else if (type === '--form-select') {
519
556
  this.onFormSelectCB?.(data?.formId);
520
557
  } else if (type === '--calc-field-open') {
521
558
  this.onCalcFieldOpenCB?.(data?.usedFormIds ?? []);
522
559
  } else if (type === '--esign-offset-open') {
523
560
  this.openESignOffsetRules(data);
561
+ } else if (type === '--business-calendar-request') {
562
+ // It can delete a tenant schedule and replace bindings: only from this editor's iframe.
563
+ if (e.source === this.iframe?.contentWindow) {
564
+ this.routeBusinessCalendarRequest(data);
565
+ }
524
566
  } else if (type === '--calc-field-select') {
525
567
  if (this.onCalcFieldSelectCB) {
526
568
  this.onCalcFieldSelectCB(data?.fieldKeys ?? []);
@@ -533,6 +575,7 @@ export class UnlayerStore {
533
575
  toolTwins: this.props.toolTwins,
534
576
  eSignRecipients: this.props.eSignRecipients,
535
577
  eSignFieldTypes: this.props.eSignFieldTypes,
578
+ eSignFieldTypeLabels: E_SIGN_FIELD_TYPE_LABELS,
536
579
  units: this.props.units?.map(unit => ({
537
580
  ...unit,
538
581
  values: {
@@ -581,6 +624,25 @@ export class UnlayerStore {
581
624
  });
582
625
  };
583
626
 
627
+ private routeBusinessCalendarRequest = (
628
+ data?: Partial<UnlayerEventBusinessCalendarRequest>,
629
+ ) => {
630
+ if (!data?.action || !data.fieldKey) {
631
+ return;
632
+ }
633
+
634
+ this.onBusinessCalendarRequestCB?.(data as UnlayerEventBusinessCalendarRequest);
635
+ };
636
+
637
+ private sendBusinessCalendarState = () => {
638
+ if (!this.businessCalendarStateJson) {
639
+ return;
640
+ }
641
+
642
+ this.sentBusinessCalendarStateJson = this.businessCalendarStateJson;
643
+ this.sendMessage('--business-calendar-state', JSON.parse(this.businessCalendarStateJson));
644
+ };
645
+
584
646
  private updateFormFieldSamples = (formId: number, fields: FormFieldInfo[]) => {
585
647
  fields.forEach((field, index) => {
586
648
  const normalizedFieldId = String(field.id ?? '').replaceAll('-', '');
@@ -1,3 +1,4 @@
1
+ import type { BusinessCalendarHostProps } from '@servicetitan/dte-shared';
1
2
  import {
2
3
  UnlayerEditorESignRecipientInfo,
3
4
  UnlayerEditorTwin,
@@ -73,7 +74,16 @@ export interface UnlayerEditorCustomTool {
73
74
  groupUrl?: string;
74
75
  }
75
76
 
76
- export interface CreateUnlayerEditorProps {
77
+ /**
78
+ * Editor options. The business-day schedule props (`BusinessCalendarHostProps`: `scheduleBindings`,
79
+ * `schedules`, `holidayCatalog`, `onScheduleBindingsChange`, ...) mean the same as `PdfEditor`'s;
80
+ * the field key of a binding is the tool's `values.id` (calculated field or e-sign "Date Signed
81
+ * Offset" field). The schedule UI shows only when `onScheduleBindingsChange` is passed. Changes
82
+ * to them (and to `holidays` / `fieldCalendars`) reach the editor when the host re-renders
83
+ * `UnlayerEditor` with new values: new arrays and objects, as for `PdfEditor`, since one changed
84
+ * in place isn't noticed.
85
+ */
86
+ export interface CreateUnlayerEditorProps extends BusinessCalendarHostProps {
77
87
  tools: UnlayerEditorCustomTool[];
78
88
  newSnapshot?: UnlayerEditorTwin;
79
89
  toolTwins?: UnlayerEditorTwin[];
@@ -111,14 +121,15 @@ export interface CreateUnlayerEditorProps {
111
121
  /**
112
122
  * Holidays of the default business-day calendar (`YYYY-MM-DD`, observed days), skipped with
113
123
  * Saturday and Sunday by date calculated fields whose toggle is off. Without it the previews
114
- * skip weekends only.
124
+ * skip weekends only. Sent to the editor again whenever it changes.
115
125
  */
116
126
  holidays?: string[];
117
127
  /**
118
128
  * Calendars of the date calculated fields bound to a schedule, by field key (the tool's
119
129
  * `values.id`), as `POST api/holidays/calendar` resolves them. Fields not listed use the
120
- * default calendar (`holidays`). Only the editor previews read it: rendered documents get
121
- * their calendars from DTE.
130
+ * default calendar (`holidays`); while `onScheduleBindingsChange` is passed, so does a field
131
+ * without a binding in `scheduleBindings`. Only the editor previews read it: rendered
132
+ * documents get their calendars from DTE. Sent to the editor again whenever it changes.
122
133
  */
123
134
  fieldCalendars?: Record<string, BusinessCalendar>;
124
135
  onFormSelect?: (formId: number) => void;
package/src/unlayer.tsx CHANGED
@@ -2,7 +2,7 @@ import { emitDisplayCondition } from './display-conditions/displayConditionContr
2
2
  import { editorCoreScript, editorCoreStyles, editorCoreTools } from './editor-core';
3
3
  import { logUnlayerError } from './log';
4
4
  import { toUnlayerMergeTags } from './merge-tags';
5
- import { constGenericsEditor } from './shared/const';
5
+ import { constGenericsEditor, E_SIGN_FIELD_TYPE_LABELS } from './shared/const';
6
6
  import { unlayerSupportedFonts } from './shared/fonts';
7
7
  import {
8
8
  unlayerCustomEmptyToolState,
@@ -226,10 +226,10 @@ export const createUnlayerEditor = (
226
226
 
227
227
  const acv = constGenericsEditor.adminConfigProperty;
228
228
 
229
- const eSignTypeMapping = (eSignFieldTypes ?? []).map(key => ({
230
- label: key,
231
- value: key.charAt(0).toLowerCase() + key.replace(/ /g, '').slice(1),
232
- }));
229
+ const eSignTypeMapping = (eSignFieldTypes ?? []).map(key => {
230
+ const value = key.charAt(0).toLowerCase() + key.replace(/ /g, '').slice(1);
231
+ return { label: E_SIGN_FIELD_TYPE_LABELS[value] ?? key, value };
232
+ });
233
233
 
234
234
  const unitsConfig = (units ?? []).reduce(
235
235
  (out, unit) => {