@verdocs/js-sdk 1.1.5 → 1.1.9

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.
@@ -0,0 +1,175 @@
1
+ export function getHeight(field) {
2
+ var settings = field.settings || field.setting || {};
3
+ switch (field.type) {
4
+ case 'signature':
5
+ case 'initial':
6
+ return 36;
7
+ case 'checkbox':
8
+ case 'checkbox_group':
9
+ case 'radio_button_group':
10
+ return 13.5;
11
+ case 'attachment':
12
+ case 'payment':
13
+ return 24;
14
+ }
15
+ return settings.height || 0;
16
+ }
17
+ export function getWidth(field) {
18
+ var settings = field.settings || field.setting || {};
19
+ switch (field.type) {
20
+ case 'signature':
21
+ case 'initial':
22
+ return 82.63636363636;
23
+ case 'checkbox':
24
+ case 'checkbox_group':
25
+ case 'radio_button_group':
26
+ return 13.5;
27
+ case 'attachment':
28
+ case 'payment':
29
+ return 24;
30
+ case 'date':
31
+ return 64;
32
+ case 'dropdown':
33
+ return (settings === null || settings === void 0 ? void 0 : settings.width) || 64;
34
+ }
35
+ return (settings === null || settings === void 0 ? void 0 : settings.width) || 0;
36
+ }
37
+ export function getRTop(y, fieldHeight, iTextHeight, yRatio) {
38
+ return iTextHeight - (y + fieldHeight) * yRatio;
39
+ }
40
+ export function getRLeft(x, ratio) {
41
+ return x * ratio;
42
+ }
43
+ export function getRValue(y, ratio) {
44
+ return y * ratio;
45
+ }
46
+ export function getStyle(field) {
47
+ var settings = field.settings || field.setting || {};
48
+ var height = getHeight(field);
49
+ var style = {
50
+ left: ((settings === null || settings === void 0 ? void 0 : settings.x) || 0) + 'px',
51
+ bottom: ((settings === null || settings === void 0 ? void 0 : settings.y) || 0) + 'px',
52
+ height: '100%',
53
+ width: '100%',
54
+ };
55
+ switch (field.type) {
56
+ case 'textbox':
57
+ case 'date':
58
+ case 'timestamp':
59
+ case 'placeholder':
60
+ case 'dropdown':
61
+ style.maxHeight = height + 'px';
62
+ style.maxWidth = ((settings === null || settings === void 0 ? void 0 : settings.width) || 0) + 'px';
63
+ break;
64
+ case 'checkbox':
65
+ case 'checkbox_group':
66
+ case 'radio_button_group':
67
+ style.maxHeight = 13.5 + 'px';
68
+ style.maxWidth = 13.5 + 'px';
69
+ break;
70
+ case 'attachment':
71
+ case 'payment':
72
+ style.maxHeight = 24 + 'px';
73
+ style.maxWidth = 24 + 'px';
74
+ break;
75
+ case 'signature':
76
+ case 'initial':
77
+ style.maxHeight = 36 + 'px';
78
+ style.maxWidth = 82.63636363636 + 'px';
79
+ style['line-height'] = 36 + 'px';
80
+ break;
81
+ }
82
+ return style;
83
+ }
84
+ export function blobToBase64(image) {
85
+ var fileReader = new FileReader();
86
+ return new Promise(function (resolve, reject) {
87
+ fileReader.onerror = function () {
88
+ reject(new DOMException('Problem reading blob.'));
89
+ };
90
+ fileReader.onload = function () {
91
+ resolve(fileReader.result);
92
+ };
93
+ fileReader.readAsDataURL(image);
94
+ });
95
+ }
96
+ export function getInputStyle(field, mode, browserType) {
97
+ var settings = field.settings || field.setting || {};
98
+ var fontSize = (settings === null || settings === void 0 ? void 0 : settings.font_size) || 11;
99
+ var style = {
100
+ height: '100%',
101
+ width: '100%',
102
+ background: 'none',
103
+ };
104
+ if (settings.font_size ||
105
+ field.type === 'date' ||
106
+ field.type === 'signature' ||
107
+ field.type === 'initial' ||
108
+ field.type === 'timestamp') {
109
+ style.fontSize = fontSize + 'px';
110
+ style.letterSpacing = '.3px !important';
111
+ }
112
+ if (field.type === 'dropdown') {
113
+ style.fontSize = '10.8px';
114
+ delete style.background;
115
+ }
116
+ if (field.type === 'textbox') {
117
+ style.fontSize = fontSize + 'px';
118
+ style.letterSpacing = getLetterSpacing(browserType) + 'px';
119
+ }
120
+ if (field.required) {
121
+ style.border = '1px solid #cc0000';
122
+ }
123
+ if ((field === null || field === void 0 ? void 0 : field.prepared) === true && mode !== 'prepareview') {
124
+ style.visibility = 'hidden';
125
+ }
126
+ if (settings.color) {
127
+ style.color = settings.color;
128
+ }
129
+ if (settings.upperCase) {
130
+ style.textTransform = 'uppercase';
131
+ }
132
+ if (settings.leading) {
133
+ style.lineHeight = "".concat(rescale(1, settings.leading + 0.5), "px");
134
+ }
135
+ return style;
136
+ }
137
+ export function getCheckboxLabelStyle(required) {
138
+ var labelStyle = {
139
+ position: 'absolute',
140
+ top: 0,
141
+ left: 0,
142
+ cursor: 'pointer',
143
+ height: "13.5px",
144
+ width: "13.5px",
145
+ backgroundColor: 'transparent',
146
+ border: '1px solid #777',
147
+ };
148
+ if (required) {
149
+ labelStyle.boxShadow = '0 0 0 1px #cc0000';
150
+ }
151
+ return labelStyle;
152
+ }
153
+ export function getLetterSpacing(browserType) {
154
+ switch (browserType) {
155
+ case 'opera':
156
+ return -0.0018;
157
+ case 'firefox':
158
+ return -0.23594210526315787;
159
+ case 'ie':
160
+ return -0.0019;
161
+ case 'edge':
162
+ return -0.0019;
163
+ case 'chrome':
164
+ return -0.0018;
165
+ case 'safari':
166
+ return -0.0018;
167
+ case 'blink':
168
+ return -0.0018;
169
+ default:
170
+ return -0.0018;
171
+ }
172
+ }
173
+ export function rescale(r, n) {
174
+ return r * n;
175
+ }
@@ -0,0 +1,18 @@
1
+ export interface ICountry {
2
+ code: string;
3
+ name: string;
4
+ value: string;
5
+ }
6
+ export declare const Countries: ICountry[];
7
+ export declare function getCountryByCode(code: string): ICountry | null;
8
+ export declare function isFrenchGuiana(code: string): boolean;
9
+ export declare function isGuadeloupe(code: string): boolean;
10
+ export declare function isMartinique(code: string): boolean;
11
+ export declare function isMayotte(code: string): boolean;
12
+ export declare function getPlusOneCountry(code: string): ICountry | null;
13
+ export declare function isCanada(code: string): boolean;
14
+ export declare function isAmericanSamoa(code: string): boolean;
15
+ export declare function isDominicanRepublic(code: string): boolean;
16
+ export declare function isPuertoRico(code: string): boolean;
17
+ export declare function getMatchingCountry(code: string, substrings: number): number;
18
+ export declare function simpleE164Validator(code: string): boolean;