@servicetitan/dte-unlayer 0.76.0 → 0.78.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.
@@ -6,9 +6,9 @@ export const constGenericsEditor = {
6
6
  userConfigProperty: 'config',
7
7
  };
8
8
 
9
- export interface UnlayerEditorESignPlaceholderInfo {
9
+ export interface UnlayerEditorESignRecipientInfo {
10
10
  id: number;
11
- placeholder: string;
11
+ name: string;
12
12
  displayName: string;
13
13
  }
14
14
 
@@ -36,7 +36,8 @@ export interface UnlayerEventConfig {
36
36
 
37
37
  export interface UnlayerEventRegister {
38
38
  units?: UnlayerEditorUnit[];
39
- eSignPlaceholders?: UnlayerEditorESignPlaceholderInfo[];
39
+ eSignRecipients?: UnlayerEditorESignRecipientInfo[];
40
+ eSignFieldTypes?: string[];
40
41
  customTools?: {
41
42
  key: string;
42
43
  title?: string;
package/src/store.ts CHANGED
@@ -48,6 +48,8 @@ export class UnlayerStore {
48
48
  private onImageCB?: (file: File) => Promise<{ url: string }>;
49
49
 
50
50
  constructor(readonly props: CreateUnlayerEditorProps) {
51
+ this.props.eSignFieldTypes = ['Signature', 'Initials', 'Date Signed', 'Full Name'];
52
+
51
53
  this.unlayerRef = {
52
54
  loadDesign: design => {
53
55
  this.editor?.loadDesign(design);
@@ -206,7 +208,8 @@ export class UnlayerStore {
206
208
  const data: UnlayerEventRegister = {
207
209
  customTools: this.props.tools.map(tool => ({ key: tool.key })),
208
210
  toolTwins: this.props.toolTwins,
209
- eSignPlaceholders: this.props.eSignPlaceholders,
211
+ eSignRecipients: this.props.eSignRecipients,
212
+ eSignFieldTypes: this.props.eSignFieldTypes,
210
213
  units: this.props.units?.map(unit => ({
211
214
  ...unit,
212
215
  values: {
@@ -1,5 +1,5 @@
1
1
  import {
2
- UnlayerEditorESignPlaceholderInfo,
2
+ UnlayerEditorESignRecipientInfo,
3
3
  UnlayerEditorTwin,
4
4
  UnlayerEditorUnit,
5
5
  } from './shared/const';
@@ -66,7 +66,8 @@ export interface CreateUnlayerEditorProps {
66
66
  customCSS?: string | string[] | undefined;
67
67
  customJS?: string | string[] | undefined;
68
68
  mergeTags?: UnlayerEditorMergeTagInfo[] | undefined;
69
- eSignPlaceholders?: UnlayerEditorESignPlaceholderInfo[] | undefined;
69
+ eSignRecipients?: UnlayerEditorESignRecipientInfo[] | undefined;
70
+ eSignFieldTypes?: string[] | undefined;
70
71
  genericConfigMode?: boolean;
71
72
  generics?: true | string[];
72
73
  units?: UnlayerEditorUnit[];
package/src/unlayer.tsx CHANGED
@@ -134,7 +134,8 @@ export const createUnlayerEditor = (
134
134
  {
135
135
  customCSS,
136
136
  customJS,
137
- eSignPlaceholders,
137
+ eSignFieldTypes,
138
+ eSignRecipients,
138
139
  hideAllTools,
139
140
  hideBodyMenuItem,
140
141
  hideContentControls,
@@ -184,6 +185,11 @@ export const createUnlayerEditor = (
184
185
 
185
186
  const acv = constGenericsEditor.adminConfigProperty;
186
187
 
188
+ const eSignTypeMapping = (eSignFieldTypes ?? []).map(key => ({
189
+ label: key,
190
+ value: key.charAt(0).toLowerCase() + key.replace(/ /g, '').slice(1),
191
+ }));
192
+
187
193
  const unitsConfig = (units ?? []).reduce((out, unit) => {
188
194
  out[`custom#${unit.generic}:unit:${unit.id}`] = {
189
195
  data: {
@@ -205,18 +211,25 @@ export const createUnlayerEditor = (
205
211
  return out;
206
212
  }, {} as Record<string, any>);
207
213
 
208
- const eSignComponentPlaceholders = {
214
+ const eSignComponentRecipients = {
209
215
  properties: {
210
- eSignPlaceholder: {
216
+ eSignRecipient: {
211
217
  editor: {
212
218
  data: {
213
- options: eSignPlaceholders?.map(placeholder => ({
214
- label: placeholder.displayName,
215
- value: placeholder.placeholder,
219
+ options: eSignRecipients?.map(item => ({
220
+ label: item.displayName,
221
+ value: item.name,
216
222
  })),
217
223
  },
218
224
  },
219
225
  },
226
+ eSignFieldType: {
227
+ editor: {
228
+ data: {
229
+ options: eSignTypeMapping,
230
+ },
231
+ },
232
+ },
220
233
  },
221
234
  };
222
235
 
@@ -253,7 +266,7 @@ export const createUnlayerEditor = (
253
266
  }
254
267
  : {}),
255
268
  ...unitsConfig,
256
- 'custom#esign': eSignComponentPlaceholders,
269
+ 'custom#e-sign': eSignComponentRecipients,
257
270
  },
258
271
  editor: {
259
272
  autoSelectOnDrop: true,