jitz-sharepoint-utilities 1.10.65 → 1.11.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.
@@ -1,149 +1,149 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var XLSX = require("xlsx");
4
- var UtilityService = /** @class */ (function () {
5
- function UtilityService(context) {
6
- this._context = context;
7
- this._webAbsoluteUrl = context.siteUrl;
8
- }
9
- UtilityService.monthNames = [
10
- "Jan",
11
- "Feb",
12
- "Mar",
13
- "Apr",
14
- "May",
15
- "Jun",
16
- "Jul",
17
- "Aug",
18
- "Sep",
19
- "Oct",
20
- "Nov",
21
- "Dec",
22
- ];
23
- UtilityService.monthNamesFull = [
24
- "January",
25
- "February",
26
- "March",
27
- "April",
28
- "May",
29
- "June",
30
- "July",
31
- "August",
32
- "September",
33
- "October",
34
- "November",
35
- "December",
36
- ];
37
- UtilityService.setCookie = function (name, val, validMinutes) {
38
- if (validMinutes === void 0) { validMinutes = 604800; }
39
- var date = new Date();
40
- var value = val;
41
- // Set it expire in 7 days
42
- date.setTime(date.getTime() + validMinutes);
43
- // Set it
44
- document.cookie =
45
- name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";
46
- };
47
- UtilityService.getCookie = function (name) {
48
- var value = "; " + document.cookie;
49
- var parts = value.split("; " + name + "=");
50
- if (parts.length == 2) {
51
- return parts.pop().split(";").shift();
52
- }
53
- };
54
- UtilityService.deleteCookie = function (name) {
55
- var date = new Date();
56
- // Set it expire in -1 days
57
- date.setTime(date.getTime() + -1 * 24 * 60 * 60 * 1000);
58
- // Set it
59
- document.cookie = name + "=; expires=" + date.toUTCString() + "; path=/";
60
- };
61
- UtilityService.formatDate = function (date) {
62
- date = new Date(date.toString());
63
- var monthArr = [
64
- "Jan",
65
- "Feb",
66
- "Mar",
67
- "Apr",
68
- "May",
69
- "Jun",
70
- "Jul",
71
- "Aug",
72
- "Sep",
73
- "Oct",
74
- "Nov",
75
- "Dec",
76
- ];
77
- var dateStr = date.getDate() +
78
- " " +
79
- monthArr[date.getMonth()] +
80
- " " +
81
- date.getFullYear();
82
- return dateStr;
83
- };
84
- UtilityService.formatDateToMonthAndDate = function (date) {
85
- return date.getDate() + " " + UtilityService.monthNames[date.getMonth()];
86
- };
87
- UtilityService.getMonthFullNameOfTheDate = function (date) {
88
- return UtilityService.monthNamesFull[date.getMonth()];
89
- };
90
- UtilityService.getMonthOfTheDate = function (date) {
91
- return UtilityService.monthNames[date.getMonth()];
92
- };
93
- UtilityService.addMonthsToDate = function (date, months) {
94
- var newDate = new Date(date.toDateString());
95
- return new Date(newDate.setMonth(newDate.getMonth() + months));
96
- };
97
- UtilityService.addDaysToDate = function (date, days) {
98
- return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
99
- };
100
- UtilityService.addHoursToDate = function (date, hours) {
101
- return new Date(date.getTime() + hours * 60 * 60 * 1000);
102
- };
103
- UtilityService.addMinutesToDate = function (date, minutes) {
104
- return new Date(date.getTime() + minutes * 60 * 1000);
105
- };
106
- UtilityService.generateGUID = function () {
107
- var d = new Date().getTime();
108
- var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
109
- var r = (d + Math.random() * 16) % 16 | 0;
110
- d = Math.floor(d / 16);
111
- return (c == "x" ? r : (r & 0x7) | 0x8).toString(16);
112
- });
113
- return uuid;
114
- };
115
- UtilityService.exportJsonAsExcelSheet = function (json, fileTitle) {
116
- var worksheet = XLSX.utils.json_to_sheet(json);
117
- var workbook = {
118
- Sheets: { data: worksheet },
119
- SheetNames: ["data"],
120
- };
121
- XLSX.writeFile(workbook, fileTitle + ".xlsx");
122
- };
123
- UtilityService.LightenDarkenColor = function (col, amt) {
124
- var usePound = false;
125
- if (col[0] == "#") {
126
- col = col.slice(1);
127
- usePound = true;
128
- }
129
- var num = parseInt(col, 16);
130
- var r = (num >> 16) + amt;
131
- if (r > 255)
132
- r = 255;
133
- else if (r < 0)
134
- r = 0;
135
- var b = ((num >> 8) & 0x00ff) + amt;
136
- if (b > 255)
137
- b = 255;
138
- else if (b < 0)
139
- b = 0;
140
- var g = (num & 0x0000ff) + amt;
141
- if (g > 255)
142
- g = 255;
143
- else if (g < 0)
144
- g = 0;
145
- return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
146
- };
147
- return UtilityService;
148
- }());
149
- exports.default = UtilityService;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var XLSX = require("xlsx");
4
+ var UtilityService = /** @class */ (function () {
5
+ function UtilityService(context) {
6
+ this._context = context;
7
+ this._webAbsoluteUrl = context.siteUrl;
8
+ }
9
+ UtilityService.monthNames = [
10
+ "Jan",
11
+ "Feb",
12
+ "Mar",
13
+ "Apr",
14
+ "May",
15
+ "Jun",
16
+ "Jul",
17
+ "Aug",
18
+ "Sep",
19
+ "Oct",
20
+ "Nov",
21
+ "Dec",
22
+ ];
23
+ UtilityService.monthNamesFull = [
24
+ "January",
25
+ "February",
26
+ "March",
27
+ "April",
28
+ "May",
29
+ "June",
30
+ "July",
31
+ "August",
32
+ "September",
33
+ "October",
34
+ "November",
35
+ "December",
36
+ ];
37
+ UtilityService.setCookie = function (name, val, validMinutes) {
38
+ if (validMinutes === void 0) { validMinutes = 604800; }
39
+ var date = new Date();
40
+ var value = val;
41
+ // Set it expire in 7 days
42
+ date.setTime(date.getTime() + validMinutes);
43
+ // Set it
44
+ document.cookie =
45
+ name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";
46
+ };
47
+ UtilityService.getCookie = function (name) {
48
+ var value = "; " + document.cookie;
49
+ var parts = value.split("; " + name + "=");
50
+ if (parts.length == 2) {
51
+ return parts.pop().split(";").shift();
52
+ }
53
+ };
54
+ UtilityService.deleteCookie = function (name) {
55
+ var date = new Date();
56
+ // Set it expire in -1 days
57
+ date.setTime(date.getTime() + -1 * 24 * 60 * 60 * 1000);
58
+ // Set it
59
+ document.cookie = name + "=; expires=" + date.toUTCString() + "; path=/";
60
+ };
61
+ UtilityService.formatDate = function (date) {
62
+ date = new Date(date.toString());
63
+ var monthArr = [
64
+ "Jan",
65
+ "Feb",
66
+ "Mar",
67
+ "Apr",
68
+ "May",
69
+ "Jun",
70
+ "Jul",
71
+ "Aug",
72
+ "Sep",
73
+ "Oct",
74
+ "Nov",
75
+ "Dec",
76
+ ];
77
+ var dateStr = date.getDate() +
78
+ " " +
79
+ monthArr[date.getMonth()] +
80
+ " " +
81
+ date.getFullYear();
82
+ return dateStr;
83
+ };
84
+ UtilityService.formatDateToMonthAndDate = function (date) {
85
+ return date.getDate() + " " + UtilityService.monthNames[date.getMonth()];
86
+ };
87
+ UtilityService.getMonthFullNameOfTheDate = function (date) {
88
+ return UtilityService.monthNamesFull[date.getMonth()];
89
+ };
90
+ UtilityService.getMonthOfTheDate = function (date) {
91
+ return UtilityService.monthNames[date.getMonth()];
92
+ };
93
+ UtilityService.addMonthsToDate = function (date, months) {
94
+ var newDate = new Date(date.toDateString());
95
+ return new Date(newDate.setMonth(newDate.getMonth() + months));
96
+ };
97
+ UtilityService.addDaysToDate = function (date, days) {
98
+ return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
99
+ };
100
+ UtilityService.addHoursToDate = function (date, hours) {
101
+ return new Date(date.getTime() + hours * 60 * 60 * 1000);
102
+ };
103
+ UtilityService.addMinutesToDate = function (date, minutes) {
104
+ return new Date(date.getTime() + minutes * 60 * 1000);
105
+ };
106
+ UtilityService.generateGUID = function () {
107
+ var d = new Date().getTime();
108
+ var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
109
+ var r = (d + Math.random() * 16) % 16 | 0;
110
+ d = Math.floor(d / 16);
111
+ return (c == "x" ? r : (r & 0x7) | 0x8).toString(16);
112
+ });
113
+ return uuid;
114
+ };
115
+ UtilityService.exportJsonAsExcelSheet = function (json, fileTitle) {
116
+ var worksheet = XLSX.utils.json_to_sheet(json);
117
+ var workbook = {
118
+ Sheets: { data: worksheet },
119
+ SheetNames: ["data"],
120
+ };
121
+ XLSX.writeFile(workbook, fileTitle + ".xlsx");
122
+ };
123
+ UtilityService.LightenDarkenColor = function (col, amt) {
124
+ var usePound = false;
125
+ if (col[0] == "#") {
126
+ col = col.slice(1);
127
+ usePound = true;
128
+ }
129
+ var num = parseInt(col, 16);
130
+ var r = (num >> 16) + amt;
131
+ if (r > 255)
132
+ r = 255;
133
+ else if (r < 0)
134
+ r = 0;
135
+ var b = ((num >> 8) & 0x00ff) + amt;
136
+ if (b > 255)
137
+ b = 255;
138
+ else if (b < 0)
139
+ b = 0;
140
+ var g = (num & 0x0000ff) + amt;
141
+ if (g > 255)
142
+ g = 255;
143
+ else if (g < 0)
144
+ g = 0;
145
+ return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
146
+ };
147
+ return UtilityService;
148
+ }());
149
+ exports.default = UtilityService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jitz-sharepoint-utilities",
3
- "version": "1.10.65",
3
+ "version": "1.11.0",
4
4
  "description": "Essential SharePoint utilities for SharePoint Add-in and SPFx development",
5
5
  "author": "Jithendra Mani",
6
6
  "license": "ISC",
@@ -16,6 +16,7 @@
16
16
  "@types/file-saver": "^2.0.1",
17
17
  "axios": "^0.19.2",
18
18
  "file-saver": "^2.0.2",
19
+ "user": "^0.0.0",
19
20
  "xlsx": "^0.16.1"
20
21
  },
21
22
  "devDependencies": {