@servicetitan/dte-unlayer 0.113.0 → 0.115.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/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 +7 -0
- package/dist/editor.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/shared/const.d.ts +2 -0
- package/dist/shared/const.d.ts.map +1 -1
- package/dist/shared/const.js.map +1 -1
- package/dist/shared/date-calc.d.ts +6 -0
- package/dist/shared/date-calc.d.ts.map +1 -1
- package/dist/shared/date-calc.js +15 -0
- package/dist/shared/date-calc.js.map +1 -1
- package/dist/shared/forms.d.ts +10 -0
- package/dist/shared/forms.d.ts.map +1 -0
- package/dist/shared/forms.js +3 -0
- package/dist/shared/forms.js.map +1 -0
- package/dist/store.d.ts +4 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +22 -3
- package/dist/store.js.map +1 -1
- package/dist/unlayer-interface.d.ts +4 -0
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer-interface.js.map +1 -1
- package/package.json +1 -1
- package/src/editor-core-source.ts +2 -2
- package/src/editor.tsx +6 -0
- package/src/index.ts +1 -0
- package/src/shared/const.ts +2 -0
- package/src/shared/date-calc.ts +17 -0
- package/src/shared/forms.ts +10 -0
- package/src/store.ts +18 -2
- package/src/unlayer-interface.tsx +4 -0
package/src/editor.tsx
CHANGED
|
@@ -103,6 +103,12 @@ export const UnlayerEditor = forwardRef<UnlayerRef, UnlayerEditorProps>((props,
|
|
|
103
103
|
return () => store.setOnMessage();
|
|
104
104
|
}, [props.onMessage, store]);
|
|
105
105
|
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
store.setOnFormSelect(props.opts.onFormSelect);
|
|
108
|
+
|
|
109
|
+
return () => store.setOnFormSelect();
|
|
110
|
+
}, [props.opts.onFormSelect, store]);
|
|
111
|
+
|
|
106
112
|
const { minHeight = 800, style = {} } = props;
|
|
107
113
|
|
|
108
114
|
return (
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './api-custom-tools';
|
|
|
5
5
|
export * from './unlayer-interface';
|
|
6
6
|
export * from './loadScript';
|
|
7
7
|
export * from './shared/const';
|
|
8
|
+
export * from './shared/forms';
|
|
8
9
|
export * from './shared/schema';
|
|
9
10
|
export * from './shared/tools';
|
|
10
11
|
export { UnlayerDesignChangeInfo } from './store';
|
package/src/shared/const.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FormInfo } from './forms';
|
|
1
2
|
import { SchemaObject } from './schema';
|
|
2
3
|
|
|
3
4
|
export const constGenericsEditor = {
|
|
@@ -33,6 +34,7 @@ export interface UnlayerEventConfig {
|
|
|
33
34
|
isSnapshotMode?: boolean;
|
|
34
35
|
units?: UnlayerEditorUnit[];
|
|
35
36
|
holidays?: string[];
|
|
37
|
+
forms?: FormInfo[];
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export interface UnlayerEventRegister {
|
package/src/shared/date-calc.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
export const MAX_DATE_CALC_DAYS = 365;
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Fallback US federal holidays used when the store config does not provide a
|
|
5
|
+
* holidays list. Keep in sync with any similar inline arrays elsewhere (e.g.
|
|
6
|
+
* components/scripts/comps/calculated-field.ts).
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_HOLIDAYS: string[] = [
|
|
9
|
+
'2026-01-01T00:00:00.000Z',
|
|
10
|
+
'2026-01-19T00:00:00.000Z',
|
|
11
|
+
'2026-02-16T00:00:00.000Z',
|
|
12
|
+
'2026-05-25T00:00:00.000Z',
|
|
13
|
+
'2026-07-04T00:00:00.000Z',
|
|
14
|
+
'2026-09-07T00:00:00.000Z',
|
|
15
|
+
'2026-11-26T00:00:00.000Z',
|
|
16
|
+
'2026-11-27T00:00:00.000Z',
|
|
17
|
+
'2026-12-25T00:00:00.000Z',
|
|
18
|
+
];
|
|
19
|
+
|
|
3
20
|
export const DATE_RANGE_YEARS = 2;
|
|
4
21
|
|
|
5
22
|
/**
|
package/src/store.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { loadScript } from './loadScript';
|
|
2
2
|
import { defaultImageValidation } from './shared/configs';
|
|
3
3
|
import { UnlayerEditorTwin, UnlayerEventConfig, UnlayerEventRegister } from './shared/const';
|
|
4
|
+
import { FormFieldInfo } from './shared/forms';
|
|
4
5
|
import { unlayerToolsParseTwinKey } from './shared/tools';
|
|
5
6
|
import { unlayerToolsIterate } from './tools';
|
|
6
7
|
import {
|
|
@@ -48,6 +49,7 @@ export class UnlayerStore {
|
|
|
48
49
|
private onReadyCB?: () => void;
|
|
49
50
|
private onImageCB?: (file: File) => Promise<{ url: string }>;
|
|
50
51
|
private onErrorCB?: (title: string, description?: string) => void;
|
|
52
|
+
private onFormSelectCB?: (formId: number) => void;
|
|
51
53
|
|
|
52
54
|
constructor(readonly props: CreateUnlayerEditorProps) {
|
|
53
55
|
this.props.eSignFieldTypes = ['Signature', 'Initials', 'Date Signed', 'Full Name'];
|
|
@@ -64,6 +66,9 @@ export class UnlayerStore {
|
|
|
64
66
|
cb(data);
|
|
65
67
|
});
|
|
66
68
|
},
|
|
69
|
+
sendFormFields: (formId, fields) => {
|
|
70
|
+
this.sendFormFields(formId, fields);
|
|
71
|
+
},
|
|
67
72
|
};
|
|
68
73
|
}
|
|
69
74
|
|
|
@@ -139,6 +144,14 @@ export class UnlayerStore {
|
|
|
139
144
|
this.onMessageCB = onMessage;
|
|
140
145
|
};
|
|
141
146
|
|
|
147
|
+
setOnFormSelect = (onFormSelect?: UnlayerStore['onFormSelectCB']) => {
|
|
148
|
+
this.onFormSelectCB = onFormSelect;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
sendFormFields = (formId: number, fields: FormFieldInfo[]) => {
|
|
152
|
+
this.sendMessage('--form-fields', { formId, fields });
|
|
153
|
+
};
|
|
154
|
+
|
|
142
155
|
private onDesignLoaded = () => {
|
|
143
156
|
if (!this.hasDesign) {
|
|
144
157
|
this.hasDesign = true;
|
|
@@ -201,16 +214,19 @@ export class UnlayerStore {
|
|
|
201
214
|
if (type === '--ready' || type === '--registered') {
|
|
202
215
|
this.onReadyCB?.();
|
|
203
216
|
} else if (type === '--core-loaded') {
|
|
204
|
-
const
|
|
217
|
+
const configData: UnlayerEventConfig = {
|
|
205
218
|
dummyData: this.props.dummyData,
|
|
206
219
|
schema: this.props.schema,
|
|
207
220
|
generics: this.props.generics,
|
|
208
221
|
genericConfigMode: this.props.genericConfigMode,
|
|
209
222
|
isSnapshotMode: this.props.isSnapshotMode,
|
|
210
223
|
holidays: this.props.holidays,
|
|
224
|
+
forms: this.props.forms,
|
|
211
225
|
};
|
|
212
226
|
|
|
213
|
-
this.sendMessage('--config', JSON.parse(JSON.stringify(
|
|
227
|
+
this.sendMessage('--config', JSON.parse(JSON.stringify(configData)));
|
|
228
|
+
} else if (type === '--form-select') {
|
|
229
|
+
this.onFormSelectCB?.(data?.formId);
|
|
214
230
|
} else if (type === '--data-loaded') {
|
|
215
231
|
const data: UnlayerEventRegister = {
|
|
216
232
|
customTools: this.props.tools.map(tool => ({ key: tool.key })),
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
UnlayerEditorTwin,
|
|
4
4
|
UnlayerEditorUnit,
|
|
5
5
|
} from './shared/const';
|
|
6
|
+
import { FormFieldInfo, FormInfo } from './shared/forms';
|
|
6
7
|
import { SchemaObject } from './shared/schema';
|
|
7
8
|
|
|
8
9
|
export interface UnlayerDesignTool {
|
|
@@ -40,6 +41,7 @@ export interface UnlayerRef {
|
|
|
40
41
|
loadDesign(design: any): void;
|
|
41
42
|
saveDesign(cb: (design: any) => void): void;
|
|
42
43
|
exportHtml(cb: (data: UnlayerExport) => void): void;
|
|
44
|
+
sendFormFields(formId: number, fields: FormFieldInfo[]): void;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
export interface UnlayerEditorMergeTagInfo {
|
|
@@ -86,4 +88,6 @@ export interface CreateUnlayerEditorProps {
|
|
|
86
88
|
maxFileSize?: number;
|
|
87
89
|
};
|
|
88
90
|
holidays?: string[];
|
|
91
|
+
forms?: FormInfo[];
|
|
92
|
+
onFormSelect?: (formId: number) => void;
|
|
89
93
|
}
|