@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.
- package/Documents/Documents.d.ts +26 -0
- package/Documents/Documents.js +4 -2
- 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 +26 -6
- 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 +12 -0
- package/Utils/Fields.js +175 -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 { ISetting } 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?: ISetting;
|
|
85
|
+
setting?: ISetting;
|
|
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;
|
package/Documents/Documents.js
CHANGED
|
@@ -102,7 +102,9 @@ export var getDocument = function (documentId) { return __awaiter(void 0, void 0
|
|
|
102
102
|
export var getDocumentFile = function (documentId, envelopeDocumentId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
103
|
return __generator(this, function (_a) {
|
|
104
104
|
return [2 /*return*/, getEndpoint()
|
|
105
|
-
.api.get("/documents/".concat(documentId, "/envelope_documents/").concat(envelopeDocumentId, "?file=true")
|
|
106
|
-
|
|
105
|
+
.api.get("/documents/".concat(documentId, "/envelope_documents/").concat(envelopeDocumentId, "?file=true"), {
|
|
106
|
+
responseType: 'arraybuffer',
|
|
107
|
+
})
|
|
108
|
+
.then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
|
|
107
109
|
});
|
|
108
110
|
}); };
|
|
@@ -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,7 +145,7 @@ 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;
|
|
@@ -146,15 +165,16 @@ export interface ISetting {
|
|
|
146
165
|
type?: string;
|
|
147
166
|
options?: any[];
|
|
148
167
|
value?: string;
|
|
168
|
+
[key: string]: any;
|
|
149
169
|
}
|
|
150
170
|
export interface IPage {
|
|
151
171
|
template_id: string;
|
|
152
172
|
document_id: string;
|
|
153
|
-
template_document?:
|
|
173
|
+
template_document?: ITemplateAsset;
|
|
154
174
|
sequence: number;
|
|
155
175
|
page_number: number;
|
|
156
176
|
thumbnail_url: string;
|
|
157
|
-
fields?:
|
|
177
|
+
fields?: ITemplateField[];
|
|
158
178
|
}
|
|
159
179
|
export interface IReminder {
|
|
160
180
|
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,12 @@
|
|
|
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 getStyle(field: IDocumentField): Record<string, string>;
|
|
8
|
+
export declare function blobToBase64(image: Blob): Promise<unknown>;
|
|
9
|
+
export declare function getInputStyle(field: IDocumentField, mode: string, browserType: string): Record<string, string>;
|
|
10
|
+
export declare function getCheckboxLabelStyle(required: boolean): Record<string, any>;
|
|
11
|
+
export declare function getLetterSpacing(browserType: string): -0.0018 | -0.23594210526315787 | -0.0019;
|
|
12
|
+
export declare function rescale(r: number, n: number): number;
|