@verdocs/js-sdk 1.1.6 → 1.1.10
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/Documents/Documents.d.ts +27 -0
- package/Documents/Documents.js +10 -0
- package/Documents/Recipients.d.ts +7 -0
- package/Documents/Recipients.js +55 -0
- package/Documents/index.d.ts +1 -0
- package/Documents/index.js +1 -0
- package/Templates/Documents.d.ts +3 -3
- package/Templates/Fields.d.ts +3 -3
- package/Templates/Roles.d.ts +2 -2
- package/Templates/Types.d.ts +33 -10
- package/Templates/Types.js +20 -0
- package/Templates/Validators.d.ts +5 -0
- package/Templates/Validators.js +9 -0
- package/Utils/Colors.d.ts +18 -0
- package/Utils/Colors.js +102 -0
- package/Utils/DateTime.d.ts +5 -0
- package/Utils/DateTime.js +38 -0
- package/Utils/Fields.d.ts +11 -0
- package/Utils/Fields.js +137 -0
- package/Utils/Locales.d.ts +18 -0
- package/Utils/Locales.js +1358 -0
- package/Utils/index.d.ts +4 -1
- package/Utils/index.js +4 -1
- package/package.json +1 -1
package/Documents/Documents.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ISigningSession, ISigningSessionRequest } from './Types';
|
|
2
|
+
import { IFieldSetting } from '../Templates/Types';
|
|
2
3
|
export declare type TDocumentStatus = 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled';
|
|
3
4
|
export declare type TRecipientStatus = 'invited' | 'opened' | 'signed' | 'submitted' | 'canceled' | 'pending' | 'declined';
|
|
4
5
|
export declare type TRecipientType = 'signer' | 'cc' | 'approver';
|
|
@@ -63,6 +64,28 @@ export interface IRecipient {
|
|
|
63
64
|
type: TRecipientType;
|
|
64
65
|
updated_at: string;
|
|
65
66
|
}
|
|
67
|
+
export interface IDocumentAsset {
|
|
68
|
+
created_at: string;
|
|
69
|
+
id: string;
|
|
70
|
+
mime: string;
|
|
71
|
+
name: string;
|
|
72
|
+
page_numbers: number;
|
|
73
|
+
updated_at: string;
|
|
74
|
+
url: string;
|
|
75
|
+
}
|
|
76
|
+
export interface IDocumentField {
|
|
77
|
+
envelope_id: string;
|
|
78
|
+
label: string | null;
|
|
79
|
+
name: string;
|
|
80
|
+
page: number;
|
|
81
|
+
recipient_role: string;
|
|
82
|
+
type: string;
|
|
83
|
+
required: boolean;
|
|
84
|
+
settings?: IFieldSetting;
|
|
85
|
+
setting?: IFieldSetting;
|
|
86
|
+
validator: string | null;
|
|
87
|
+
prepared?: boolean;
|
|
88
|
+
}
|
|
66
89
|
export interface IDocument {
|
|
67
90
|
id: string;
|
|
68
91
|
created_at: string;
|
|
@@ -79,6 +102,9 @@ export interface IDocument {
|
|
|
79
102
|
template_id: string;
|
|
80
103
|
updated_at: string;
|
|
81
104
|
organization_id: string | null;
|
|
105
|
+
certificate?: IDocumentAsset | null;
|
|
106
|
+
document?: IDocumentAsset | null;
|
|
107
|
+
fields?: IDocumentField[];
|
|
82
108
|
}
|
|
83
109
|
export interface IActivityEntry {
|
|
84
110
|
id: string;
|
|
@@ -150,3 +176,4 @@ export declare const getSigningSession: (params: ISigningSessionRequest) => Prom
|
|
|
150
176
|
export declare const getDocumentRecipients: (documentId: string) => Promise<IRecipient[]>;
|
|
151
177
|
export declare const getDocument: (documentId: string) => Promise<IDocument>;
|
|
152
178
|
export declare const getDocumentFile: (documentId: string, envelopeDocumentId: string) => Promise<string>;
|
|
179
|
+
export declare const updateDocumentField: (documentId: string, fieldName: string, value: any) => Promise<IFieldSetting>;
|
package/Documents/Documents.js
CHANGED
|
@@ -108,3 +108,13 @@ export var getDocumentFile = function (documentId, envelopeDocumentId) { return
|
|
|
108
108
|
.then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
|
|
109
109
|
});
|
|
110
110
|
}); };
|
|
111
|
+
// {"name":"textboxP2-0","recipient_role":"Recipient 1","envelope_id":"29b99d0b-8079-4e98-827c-28c375e5ecb7","page":2,"type":"textbox",
|
|
112
|
+
// "required":true,"settings":{"x":0,"y":772.0000000000001,"width":150,"height":15,"result":"Text 1","leading":0,"alignment":0,"upperCase":false},
|
|
113
|
+
// "validator":null,"label":null,"prepared":false}
|
|
114
|
+
export var updateDocumentField = function (documentId, fieldName, value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
return [2 /*return*/, getEndpoint()
|
|
117
|
+
.api.put("/documents/".concat(documentId, "/fields/").concat(fieldName), value)
|
|
118
|
+
.then(function (r) { return r.data; })];
|
|
119
|
+
});
|
|
120
|
+
}); };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IRecipient } from './Documents';
|
|
2
|
+
export declare type TRecipientAction = 'submit' | 'decline' | 'prepare' | 'update';
|
|
3
|
+
export interface IUpdateRecipientParams {
|
|
4
|
+
new_full_name?: string;
|
|
5
|
+
agreed?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const updateRecipientStatus: (documentId: string, roleName: string, action: TRecipientAction, params?: IUpdateRecipientParams | undefined) => Promise<IRecipient>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { getEndpoint } from '../HTTP/Transport';
|
|
49
|
+
export var updateRecipientStatus = function (documentId, roleName, action, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
return [2 /*return*/, getEndpoint()
|
|
52
|
+
.api.put("/documents/".concat(documentId, "/recipients/").concat(roleName), __assign({ role_name: roleName, action: action }, (params || {})))
|
|
53
|
+
.then(function (r) { return r.data; })];
|
|
54
|
+
});
|
|
55
|
+
}); };
|
package/Documents/index.d.ts
CHANGED
package/Documents/index.js
CHANGED
package/Templates/Documents.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITemplateAsset } from './Types';
|
|
2
2
|
/**
|
|
3
3
|
* Get all the Documents associated to a particular Template.
|
|
4
4
|
*
|
|
@@ -18,7 +18,7 @@ export declare const getDocuments: (templateId: string) => Promise<any>;
|
|
|
18
18
|
* await Documents.createDocument(templateID, params);
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare const createDocument: (templateId: string, params: any) => Promise<
|
|
21
|
+
export declare const createDocument: (templateId: string, params: any) => Promise<ITemplateAsset>;
|
|
22
22
|
/**
|
|
23
23
|
* Get a specific Document.
|
|
24
24
|
*
|
|
@@ -28,7 +28,7 @@ export declare const createDocument: (templateId: string, params: any) => Promis
|
|
|
28
28
|
* await Documents.getDocument(templateID, documentID);
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
export declare const getDocument: (templateId: string, documentId: string) => Promise<
|
|
31
|
+
export declare const getDocument: (templateId: string, documentId: string) => Promise<ITemplateAsset>;
|
|
32
32
|
/**
|
|
33
33
|
* Delete a specific Document.
|
|
34
34
|
*
|
package/Templates/Fields.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const createField: (templateId: string, params:
|
|
3
|
-
export declare const editField: (templateId: string, fieldName: string, params:
|
|
1
|
+
import { ITemplateField } from './Types';
|
|
2
|
+
export declare const createField: (templateId: string, params: ITemplateField) => Promise<ITemplateField>;
|
|
3
|
+
export declare const editField: (templateId: string, fieldName: string, params: ITemplateField) => Promise<ITemplateField>;
|
|
4
4
|
export declare const deleteField: (templateId: string, fieldName: string) => Promise<any>;
|
package/Templates/Roles.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITemplateField, IRole } from './Types';
|
|
2
2
|
export declare const createRole: (templateId: string, params: IRole) => Promise<IRole>;
|
|
3
3
|
export declare const getRoles: (templateId: string) => Promise<IRole[]>;
|
|
4
4
|
export declare const getRole: (templateId: string, roleName: string) => Promise<IRole>;
|
|
5
5
|
export declare const editRole: (templateId: string, roleName: string, params: IRole) => Promise<IRole>;
|
|
6
6
|
export declare const deleteRole: (templateId: string, roleName: string) => Promise<any>;
|
|
7
|
-
export declare const getRoleFields: (templateId: string, roleName: string) => Promise<
|
|
7
|
+
export declare const getRoleFields: (templateId: string, roleName: string) => Promise<ITemplateField[]>;
|
|
8
8
|
export declare const deleteSequence: (templateId: string) => Promise<IRole[]>;
|
package/Templates/Types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface ITemplate {
|
|
2
|
-
template_document?:
|
|
2
|
+
template_document?: ITemplateAsset;
|
|
3
3
|
pages?: IPage[];
|
|
4
4
|
roles?: IRole[];
|
|
5
5
|
counter?: number;
|
|
@@ -49,6 +49,24 @@ export declare enum TemplatePermissions {
|
|
|
49
49
|
TEMPLATE_MEMBER_DELETE = "template:member:delete",
|
|
50
50
|
TEMPLATE_MEMBER_VISIBILITY = "template:member:visibility"
|
|
51
51
|
}
|
|
52
|
+
export declare enum TemplateSenderTypes {
|
|
53
|
+
CREATOR = "creator",
|
|
54
|
+
ORGANIZATION_MEMBER = "organization_member",
|
|
55
|
+
ORGANIZATION_MEMBER_AS_CREATOR = "organization_member_as_creator",
|
|
56
|
+
EVERYONE = "everyone",
|
|
57
|
+
EVERYONE_AS_CREATOR = "everyone_as_creator"
|
|
58
|
+
}
|
|
59
|
+
export declare enum TemplateActions {
|
|
60
|
+
CREATE_PERSONAL = "create_personal",
|
|
61
|
+
CREATE_ORG = "create_org",
|
|
62
|
+
CREATE_PUBLIC = "create_public",
|
|
63
|
+
READ = "read",
|
|
64
|
+
WRITE = "write",
|
|
65
|
+
DELETE = "delete",
|
|
66
|
+
CHANGE_VISIBILITY_PERSONAL = "change_visibility_personal",
|
|
67
|
+
CHANGE_VISIBILITY_ORG = "change_visibility_org",
|
|
68
|
+
CHANGE_VISIBILITY_PUBLIC = "change_visibility_public"
|
|
69
|
+
}
|
|
52
70
|
export interface ITemplateSearchParams {
|
|
53
71
|
id?: string;
|
|
54
72
|
name?: string;
|
|
@@ -110,12 +128,13 @@ export interface IRole {
|
|
|
110
128
|
email?: string;
|
|
111
129
|
type: string;
|
|
112
130
|
sequence: number;
|
|
113
|
-
fields?:
|
|
131
|
+
fields?: ITemplateField[];
|
|
114
132
|
delegator?: boolean;
|
|
115
133
|
message?: string;
|
|
116
134
|
phone?: string;
|
|
135
|
+
rgba?: string;
|
|
117
136
|
}
|
|
118
|
-
export interface
|
|
137
|
+
export interface ITemplateAsset {
|
|
119
138
|
url: string;
|
|
120
139
|
name: string;
|
|
121
140
|
page_numbers: number;
|
|
@@ -126,35 +145,39 @@ export interface IDocument {
|
|
|
126
145
|
mime: string;
|
|
127
146
|
thumbnail_url: string;
|
|
128
147
|
}
|
|
129
|
-
export interface
|
|
148
|
+
export interface ITemplateField {
|
|
130
149
|
name: string;
|
|
131
150
|
role_name: string;
|
|
132
151
|
template_id: string;
|
|
133
152
|
type: string;
|
|
134
153
|
required: boolean;
|
|
135
|
-
setting?:
|
|
154
|
+
setting?: IFieldSetting;
|
|
136
155
|
page_sequence: number;
|
|
137
156
|
validator?: string;
|
|
138
157
|
label?: string;
|
|
139
158
|
}
|
|
140
|
-
export interface
|
|
159
|
+
export interface IFieldSetting {
|
|
141
160
|
x?: number;
|
|
142
161
|
y?: number;
|
|
143
162
|
width?: number;
|
|
144
163
|
height?: number;
|
|
145
|
-
result?:
|
|
164
|
+
result?: any;
|
|
146
165
|
type?: string;
|
|
147
|
-
options?: any[];
|
|
148
166
|
value?: string;
|
|
167
|
+
leading?: number;
|
|
168
|
+
alignment?: number;
|
|
169
|
+
upperCase?: boolean;
|
|
170
|
+
options?: any[];
|
|
171
|
+
[key: string]: any;
|
|
149
172
|
}
|
|
150
173
|
export interface IPage {
|
|
151
174
|
template_id: string;
|
|
152
175
|
document_id: string;
|
|
153
|
-
template_document?:
|
|
176
|
+
template_document?: ITemplateAsset;
|
|
154
177
|
sequence: number;
|
|
155
178
|
page_number: number;
|
|
156
179
|
thumbnail_url: string;
|
|
157
|
-
fields?:
|
|
180
|
+
fields?: ITemplateField[];
|
|
158
181
|
}
|
|
159
182
|
export interface IReminder {
|
|
160
183
|
id?: string;
|
package/Templates/Types.js
CHANGED
|
@@ -10,6 +10,26 @@ export var TemplatePermissions;
|
|
|
10
10
|
TemplatePermissions["TEMPLATE_MEMBER_DELETE"] = "template:member:delete";
|
|
11
11
|
TemplatePermissions["TEMPLATE_MEMBER_VISIBILITY"] = "template:member:visibility";
|
|
12
12
|
})(TemplatePermissions || (TemplatePermissions = {}));
|
|
13
|
+
export var TemplateSenderTypes;
|
|
14
|
+
(function (TemplateSenderTypes) {
|
|
15
|
+
TemplateSenderTypes["CREATOR"] = "creator";
|
|
16
|
+
TemplateSenderTypes["ORGANIZATION_MEMBER"] = "organization_member";
|
|
17
|
+
TemplateSenderTypes["ORGANIZATION_MEMBER_AS_CREATOR"] = "organization_member_as_creator";
|
|
18
|
+
TemplateSenderTypes["EVERYONE"] = "everyone";
|
|
19
|
+
TemplateSenderTypes["EVERYONE_AS_CREATOR"] = "everyone_as_creator";
|
|
20
|
+
})(TemplateSenderTypes || (TemplateSenderTypes = {}));
|
|
21
|
+
export var TemplateActions;
|
|
22
|
+
(function (TemplateActions) {
|
|
23
|
+
TemplateActions["CREATE_PERSONAL"] = "create_personal";
|
|
24
|
+
TemplateActions["CREATE_ORG"] = "create_org";
|
|
25
|
+
TemplateActions["CREATE_PUBLIC"] = "create_public";
|
|
26
|
+
TemplateActions["READ"] = "read";
|
|
27
|
+
TemplateActions["WRITE"] = "write";
|
|
28
|
+
TemplateActions["DELETE"] = "delete";
|
|
29
|
+
TemplateActions["CHANGE_VISIBILITY_PERSONAL"] = "change_visibility_personal";
|
|
30
|
+
TemplateActions["CHANGE_VISIBILITY_ORG"] = "change_visibility_org";
|
|
31
|
+
TemplateActions["CHANGE_VISIBILITY_PUBLIC"] = "change_visibility_public";
|
|
32
|
+
})(TemplateActions || (TemplateActions = {}));
|
|
13
33
|
export var SortOptions;
|
|
14
34
|
(function (SortOptions) {
|
|
15
35
|
SortOptions["CREATED_AT"] = "created_at";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { IRole, ITag } from './Types';
|
|
1
2
|
export interface IValidator {
|
|
2
3
|
name: string;
|
|
3
4
|
regex: string;
|
|
4
5
|
}
|
|
5
6
|
export declare const getValidators: () => Promise<IValidator[]>;
|
|
6
7
|
export declare const getValidator: (validatorName: string) => Promise<IValidator>;
|
|
8
|
+
export declare const isValidEmail: (value: string) => boolean;
|
|
9
|
+
export declare const isValidPhone: (value: string) => boolean;
|
|
10
|
+
export declare const isValidRoleName: (value: string, roles: IRole[]) => boolean;
|
|
11
|
+
export declare const isValidTag: (value: string, tags: ITag[]) => boolean;
|
package/Templates/Validators.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { simpleE164Validator } from '../Utils/Locales';
|
|
1
2
|
import { getEndpoint } from '../HTTP/Transport';
|
|
2
3
|
export var getValidators = function () {
|
|
3
4
|
return getEndpoint()
|
|
@@ -9,3 +10,11 @@ export var getValidator = function (validatorName) {
|
|
|
9
10
|
.api.get("/validators/".concat(validatorName))
|
|
10
11
|
.then(function (r) { return r.data; });
|
|
11
12
|
};
|
|
13
|
+
var EmailRegEx = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
14
|
+
export var isValidEmail = function (value) { return EmailRegEx.test(value); };
|
|
15
|
+
export var isValidPhone = function (value) { return simpleE164Validator(value); };
|
|
16
|
+
export var isValidRoleName = function (value, roles) { return roles.findIndex(function (role) { return role.name === value; }) !== -1; };
|
|
17
|
+
var TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
|
|
18
|
+
export var isValidTag = function (value, tags) {
|
|
19
|
+
return TagRegEx.test(value) || tags.findIndex(function (tag) { return tag.tag_name === value; }) !== -1;
|
|
20
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IRole } from '../Templates/Types';
|
|
2
|
+
/**
|
|
3
|
+
* Given a `rgba(r,g,b,a)` string value, returns the hex equivalent, dropping the alpha channel.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getRGB(rgba: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Given a signer role index, return the color code for that signer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getRGBA(roleIndex: number): "rgba(255, 193, 7, 0.4)" | "rgba(134, 134, 134, 0.3)" | "rgba(156, 39, 176, .4)" | "rgba(33, 150, 243, .4)" | "rgba(220, 231, 117, 0.3)" | "rgba(121, 134, 203, 0.3)" | "rgba(77, 182, 172, 0.3)" | "rgba(255, 202, 165, 0.3)" | "rgba(2, 247, 190, 0.3)" | "rgba(255, 138, 101, 0.3)" | "rgba(82, 255, 79, 0.3)" | "rgba(229, 115, 155, 0.3)";
|
|
10
|
+
/**
|
|
11
|
+
* Given a role name, return a color code for it. This works by computing a hash code so the specific color returned
|
|
12
|
+
* is not specified explicitly, but will be the same for every call with the same input value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function nameToRGBA(str: string): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to obtain a color code given a role name given various possible inputs.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getRoleColor(name: string, roles: IRole[], index?: number): string | undefined;
|
package/Utils/Colors.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a `rgba(r,g,b,a)` string value, returns the hex equivalent, dropping the alpha channel.
|
|
3
|
+
*/
|
|
4
|
+
export function getRGB(rgba) {
|
|
5
|
+
var rgbNumbers = rgba.replace('rgba(', '').replace(')', '').split(',');
|
|
6
|
+
var rgbObject = {
|
|
7
|
+
red: +rgbNumbers[0],
|
|
8
|
+
green: +rgbNumbers[1],
|
|
9
|
+
blue: +rgbNumbers[2],
|
|
10
|
+
alpha: +rgbNumbers[3],
|
|
11
|
+
};
|
|
12
|
+
var alpha = 1 - rgbObject.alpha;
|
|
13
|
+
var red = Math.round((rgbObject.alpha * (rgbObject.red / 255) + alpha) * 255);
|
|
14
|
+
var green = Math.round((rgbObject.alpha * (rgbObject.green / 255) + alpha) * 255);
|
|
15
|
+
var blue = Math.round((rgbObject.alpha * (rgbObject.blue / 255) + alpha) * 255);
|
|
16
|
+
return '#' + rgbToHex(red) + rgbToHex(green) + rgbToHex(blue);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Given an RGB string value, returns the hex equivalent.
|
|
20
|
+
*/
|
|
21
|
+
function rgbToHex(rgb) {
|
|
22
|
+
var hex = rgb.toString(16);
|
|
23
|
+
if (hex.length < 2) {
|
|
24
|
+
return '0' + hex;
|
|
25
|
+
}
|
|
26
|
+
return hex;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Given a signer role index, return the color code for that signer.
|
|
30
|
+
*/
|
|
31
|
+
export function getRGBA(roleIndex) {
|
|
32
|
+
switch (roleIndex % 10) {
|
|
33
|
+
case 0:
|
|
34
|
+
return roleIndex === 0 ? 'rgba(255, 193, 7, 0.4)' : 'rgba(134, 134, 134, 0.3)'; // #FFE69C
|
|
35
|
+
case 1:
|
|
36
|
+
return 'rgba(156, 39, 176, .4)'; // '#E3C3E9'
|
|
37
|
+
case 2:
|
|
38
|
+
return 'rgba(33, 150, 243, .4)'; // '#C1E1FB'
|
|
39
|
+
case 3:
|
|
40
|
+
return 'rgba(220, 231, 117, 0.3)';
|
|
41
|
+
case 4:
|
|
42
|
+
return 'rgba(121, 134, 203, 0.3)';
|
|
43
|
+
case 5:
|
|
44
|
+
return 'rgba(77, 182, 172, 0.3)';
|
|
45
|
+
case 6:
|
|
46
|
+
return 'rgba(255, 202, 165, 0.3)';
|
|
47
|
+
case 7:
|
|
48
|
+
return 'rgba(2, 247, 190, 0.3)';
|
|
49
|
+
case 8:
|
|
50
|
+
return 'rgba(255, 138, 101, 0.3)';
|
|
51
|
+
case 9:
|
|
52
|
+
return 'rgba(82, 255, 79, 0.3)';
|
|
53
|
+
default:
|
|
54
|
+
return 'rgba(229, 115, 155, 0.3)';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Given a role name, return a color code for it. This works by computing a hash code so the specific color returned
|
|
59
|
+
* is not specified explicitly, but will be the same for every call with the same input value.
|
|
60
|
+
*/
|
|
61
|
+
export function nameToRGBA(str) {
|
|
62
|
+
if (!!str) {
|
|
63
|
+
var validNum = parseInt(str.slice(-1), 10);
|
|
64
|
+
if (!isNaN(validNum)) {
|
|
65
|
+
str += (validNum * 99).toString();
|
|
66
|
+
}
|
|
67
|
+
var hash = 0;
|
|
68
|
+
for (var i = 0; i < str.length; i++) {
|
|
69
|
+
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
70
|
+
}
|
|
71
|
+
hash = Math.round(hash / 1.3);
|
|
72
|
+
var c = (hash & 0x00ffff08).toString(16).toUpperCase();
|
|
73
|
+
var hex = '#' + '00000'.substring(0, 6 - c.length) + c;
|
|
74
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
75
|
+
var color = {
|
|
76
|
+
r: parseInt(result[1], 16),
|
|
77
|
+
g: parseInt(result[2], 16),
|
|
78
|
+
b: parseInt(result[3], 16),
|
|
79
|
+
};
|
|
80
|
+
return "rgba(".concat(color.r, ", ").concat(color.g, ", ").concat(color.b, ", 0.2)");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Helper function to obtain a color code given a role name given various possible inputs.
|
|
85
|
+
*/
|
|
86
|
+
export function getRoleColor(name, roles, index) {
|
|
87
|
+
if (index) {
|
|
88
|
+
return getRGBA(index);
|
|
89
|
+
}
|
|
90
|
+
else if (roles && roles.length > 0) {
|
|
91
|
+
var roleIndex = roles.findIndex(function (role) { return role.name === name; });
|
|
92
|
+
if (roleIndex > -1) {
|
|
93
|
+
return roles[roleIndex].rgba || getRGBA(roleIndex);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return nameToRGBA(name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return nameToRGBA(name);
|
|
101
|
+
}
|
|
102
|
+
}
|
package/Utils/DateTime.d.ts
CHANGED
package/Utils/DateTime.js
CHANGED
|
@@ -39,3 +39,41 @@ export var formatShortTimeAgo = function (val) {
|
|
|
39
39
|
}
|
|
40
40
|
return "".concat(timeDiff, "S");
|
|
41
41
|
};
|
|
42
|
+
export function timePeriod(type) {
|
|
43
|
+
var endDate = new Date().getTime();
|
|
44
|
+
var today = new Date();
|
|
45
|
+
var month = today.getMonth();
|
|
46
|
+
var year = today.getFullYear();
|
|
47
|
+
var startDate = null;
|
|
48
|
+
switch (type) {
|
|
49
|
+
case '30d':
|
|
50
|
+
startDate = endDate - 60 * 60 * 24 * 30 * 1000;
|
|
51
|
+
break;
|
|
52
|
+
case '60d':
|
|
53
|
+
startDate = endDate - 60 * 60 * 24 * 60 * 1000;
|
|
54
|
+
break;
|
|
55
|
+
case '6m':
|
|
56
|
+
startDate = endDate - 60 * 60 * 24 * 30 * 6 * 1000;
|
|
57
|
+
break;
|
|
58
|
+
case 'this_month':
|
|
59
|
+
startDate = new Date(year, month, 1).getTime();
|
|
60
|
+
break;
|
|
61
|
+
case 'last_month':
|
|
62
|
+
startDate = new Date(year, month - 1, 1).getTime();
|
|
63
|
+
endDate = new Date(year, month, 0).getTime();
|
|
64
|
+
break;
|
|
65
|
+
case 'this_year':
|
|
66
|
+
startDate = new Date(year, 0, 1);
|
|
67
|
+
break;
|
|
68
|
+
case 'all_time':
|
|
69
|
+
default:
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
if (startDate === null && endDate === null) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
start_time: new Date(startDate).toISOString(),
|
|
77
|
+
end_time: new Date(endDate).toISOString(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IDocumentField } from '../Documents/Documents';
|
|
2
|
+
export declare function getHeight(field: IDocumentField): number;
|
|
3
|
+
export declare function getWidth(field: IDocumentField): number;
|
|
4
|
+
export declare function getRTop(y: number, fieldHeight: number, iTextHeight: number, yRatio: number): number;
|
|
5
|
+
export declare function getRLeft(x: number, ratio: number): number;
|
|
6
|
+
export declare function getRValue(y: number, ratio: number): number;
|
|
7
|
+
export declare function blobToBase64(image: Blob): Promise<unknown>;
|
|
8
|
+
export declare function getInputStyle(field: IDocumentField, mode: string, browserType: string): Record<string, string>;
|
|
9
|
+
export declare function getCheckboxLabelStyle(required: boolean): Record<string, any>;
|
|
10
|
+
export declare function getLetterSpacing(browserType: string): -0.0018 | -0.23594210526315787 | -0.0019;
|
|
11
|
+
export declare function rescale(r: number, n: number): number;
|
package/Utils/Fields.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
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 blobToBase64(image) {
|
|
47
|
+
var fileReader = new FileReader();
|
|
48
|
+
return new Promise(function (resolve, reject) {
|
|
49
|
+
fileReader.onerror = function () {
|
|
50
|
+
reject(new DOMException('Problem reading blob.'));
|
|
51
|
+
};
|
|
52
|
+
fileReader.onload = function () {
|
|
53
|
+
resolve(fileReader.result);
|
|
54
|
+
};
|
|
55
|
+
fileReader.readAsDataURL(image);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export function getInputStyle(field, mode, browserType) {
|
|
59
|
+
var settings = field.settings || field.setting || {};
|
|
60
|
+
var fontSize = (settings === null || settings === void 0 ? void 0 : settings.font_size) || 11;
|
|
61
|
+
var style = {
|
|
62
|
+
height: '100%',
|
|
63
|
+
width: '100%',
|
|
64
|
+
background: 'none',
|
|
65
|
+
};
|
|
66
|
+
if (settings.font_size ||
|
|
67
|
+
field.type === 'date' ||
|
|
68
|
+
field.type === 'signature' ||
|
|
69
|
+
field.type === 'initial' ||
|
|
70
|
+
field.type === 'timestamp') {
|
|
71
|
+
style.fontSize = fontSize + 'px';
|
|
72
|
+
style.letterSpacing = '.3px !important';
|
|
73
|
+
}
|
|
74
|
+
if (field.type === 'dropdown') {
|
|
75
|
+
style.fontSize = '10.8px';
|
|
76
|
+
delete style.background;
|
|
77
|
+
}
|
|
78
|
+
if (field.type === 'textbox') {
|
|
79
|
+
style.fontSize = fontSize + 'px';
|
|
80
|
+
style.letterSpacing = getLetterSpacing(browserType) + 'px';
|
|
81
|
+
}
|
|
82
|
+
if (field.required) {
|
|
83
|
+
style.border = '1px solid #cc0000';
|
|
84
|
+
}
|
|
85
|
+
if ((field === null || field === void 0 ? void 0 : field.prepared) === true && mode !== 'prepareview') {
|
|
86
|
+
style.visibility = 'hidden';
|
|
87
|
+
}
|
|
88
|
+
if (settings.color) {
|
|
89
|
+
style.color = settings.color;
|
|
90
|
+
}
|
|
91
|
+
if (settings.upperCase) {
|
|
92
|
+
style.textTransform = 'uppercase';
|
|
93
|
+
}
|
|
94
|
+
if (settings.leading) {
|
|
95
|
+
style.lineHeight = "".concat(rescale(1, settings.leading + 0.5), "px");
|
|
96
|
+
}
|
|
97
|
+
return style;
|
|
98
|
+
}
|
|
99
|
+
export function getCheckboxLabelStyle(required) {
|
|
100
|
+
var labelStyle = {
|
|
101
|
+
position: 'absolute',
|
|
102
|
+
top: 0,
|
|
103
|
+
left: 0,
|
|
104
|
+
cursor: 'pointer',
|
|
105
|
+
height: "13.5px",
|
|
106
|
+
width: "13.5px",
|
|
107
|
+
backgroundColor: 'transparent',
|
|
108
|
+
border: '1px solid #777',
|
|
109
|
+
};
|
|
110
|
+
if (required) {
|
|
111
|
+
labelStyle.boxShadow = '0 0 0 1px #cc0000';
|
|
112
|
+
}
|
|
113
|
+
return labelStyle;
|
|
114
|
+
}
|
|
115
|
+
export function getLetterSpacing(browserType) {
|
|
116
|
+
switch (browserType) {
|
|
117
|
+
case 'opera':
|
|
118
|
+
return -0.0018;
|
|
119
|
+
case 'firefox':
|
|
120
|
+
return -0.23594210526315787;
|
|
121
|
+
case 'ie':
|
|
122
|
+
return -0.0019;
|
|
123
|
+
case 'edge':
|
|
124
|
+
return -0.0019;
|
|
125
|
+
case 'chrome':
|
|
126
|
+
return -0.0018;
|
|
127
|
+
case 'safari':
|
|
128
|
+
return -0.0018;
|
|
129
|
+
case 'blink':
|
|
130
|
+
return -0.0018;
|
|
131
|
+
default:
|
|
132
|
+
return -0.0018;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export function rescale(r, n) {
|
|
136
|
+
return r * n;
|
|
137
|
+
}
|