mgwdev-m365-components 0.0.2 → 0.0.4
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/.env +2 -0
- package/.env.development +2 -0
- package/.eslintrc.cjs +18 -0
- package/build/assets/index-SHI6Sf4K.js +123 -0
- package/build/index.html +13 -0
- package/build/manifest.webmanifest +1 -0
- package/build/registerSW.js +1 -0
- package/build/sw.js +1 -0
- package/build/vite.svg +1 -0
- package/build/workbox-7cfec069.js +1 -0
- package/gulpfile.js +4 -0
- package/index.html +13 -0
- package/lib/App.d.ts +3 -0
- package/lib/App.js +212 -0
- package/lib/components/Test.d.ts +4 -0
- package/lib/components/Test.js +37 -0
- package/lib/components/common/GraphPersona.d.ts +10 -0
- package/lib/components/common/GraphPersona.js +125 -0
- package/lib/components/common/graphEntityPicker/AbstractGraphEntityPicker.d.ts +16 -0
- package/lib/components/common/graphEntityPicker/AbstractGraphEntityPicker.js +117 -0
- package/lib/components/common/graphEntityPicker/ChannelPicker.d.ts +11 -0
- package/lib/components/common/graphEntityPicker/ChannelPicker.js +83 -0
- package/lib/components/common/graphEntityPicker/DrivePicker.d.ts +11 -0
- package/lib/components/common/graphEntityPicker/DrivePicker.js +77 -0
- package/lib/components/common/graphEntityPicker/ListPicker.d.ts +11 -0
- package/lib/components/common/graphEntityPicker/ListPicker.js +77 -0
- package/lib/components/common/graphEntityPicker/PeoplePicker.d.ts +8 -0
- package/lib/components/common/graphEntityPicker/PeoplePicker.js +76 -0
- package/lib/components/common/graphEntityPicker/SitePicker.d.ts +8 -0
- package/lib/components/common/graphEntityPicker/SitePicker.js +73 -0
- package/lib/components/common/graphEntityPicker/TeamPicker.d.ts +8 -0
- package/lib/components/common/graphEntityPicker/TeamPicker.js +77 -0
- package/lib/components/common/graphEntityPicker/index.d.ts +6 -0
- package/lib/components/common/graphEntityPicker/index.js +6 -0
- package/lib/components/common/index.d.ts +2 -0
- package/lib/components/common/index.js +2 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.js +2 -0
- package/lib/components/provisioning/GetSiteTemplate.d.ts +6 -0
- package/lib/components/provisioning/GetSiteTemplate.js +41 -0
- package/lib/components/search/DefaultDocumentCard.d.ts +7 -0
- package/lib/components/search/DefaultDocumentCard.js +59 -0
- package/lib/components/search/M365Search.d.ts +18 -0
- package/lib/components/search/M365Search.js +69 -0
- package/lib/components/search/SearchDefaults.d.ts +1 -0
- package/lib/components/search/SearchDefaults.js +17 -0
- package/lib/components/search/index.d.ts +2 -0
- package/lib/components/search/index.js +2 -0
- package/lib/context/AuthenticationContext.d.ts +11 -0
- package/lib/context/AuthenticationContext.js +50 -0
- package/lib/context/DataverseContext.d.ts +13 -0
- package/lib/context/DataverseContext.js +29 -0
- package/lib/context/GraphContext.d.ts +11 -0
- package/lib/context/GraphContext.js +26 -0
- package/lib/context/SPContext.d.ts +13 -0
- package/lib/context/SPContext.js +30 -0
- package/lib/context/index.d.ts +4 -0
- package/lib/context/index.js +4 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +6 -0
- package/lib/model/IEntityWithIdAndDisplayName.d.ts +4 -0
- package/lib/model/IEntityWithIdAndDisplayName.js +1 -0
- package/lib/model/ISearchResult.d.ts +19 -0
- package/lib/model/ISearchResult.js +1 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +1 -0
- package/lib/model/infra/ICacheEntry.d.ts +4 -0
- package/lib/model/infra/ICacheEntry.js +1 -0
- package/lib/service-worker/sw.d.ts +3 -0
- package/lib/service-worker/sw.js +20 -0
- package/lib/services/PersonaService.d.ts +12 -0
- package/lib/services/PersonaService.js +134 -0
- package/lib/utils/FileUtils.d.ts +29 -0
- package/lib/utils/FileUtils.js +200 -0
- package/lib/utils/StringUtils.d.ts +1 -0
- package/lib/utils/StringUtils.js +10 -0
- package/lib/utils/ThumbnailUtils.d.ts +7 -0
- package/lib/utils/ThumbnailUtils.js +92 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +3 -0
- package/package.json +1 -16
- package/public/vite.svg +1 -0
- package/tsconfig.json +35 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +33 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const DOCICONURL_XLSX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/xlsx.png";
|
|
2
|
+
export declare const DOCICONURL_DOCX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/docx.png";
|
|
3
|
+
export declare const DOCICONURL_PPTX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/pptx.png";
|
|
4
|
+
export declare const DOCICONURL_MPPX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/mpp.png";
|
|
5
|
+
export declare const DOCICONURL_PHOTO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/photo.png";
|
|
6
|
+
export declare const DOCICONURL_PDF = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/pdf.png";
|
|
7
|
+
export declare const DOCICONURL_TXT = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/txt.png";
|
|
8
|
+
export declare const DOCICONURL_EMAIL = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/email.png";
|
|
9
|
+
export declare const DOCICONURL_CSV = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/csv.png";
|
|
10
|
+
export declare const DOCICONURL_ONE = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/one.png";
|
|
11
|
+
export declare const DOCICONURL_VSDX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/vsdx.png";
|
|
12
|
+
export declare const DOCICONURL_VSSX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/vssx.png";
|
|
13
|
+
export declare const DOCICONURL_PUB = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/pub.png";
|
|
14
|
+
export declare const DOCICONURL_ACCDB = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/accdb.png";
|
|
15
|
+
export declare const DOCICONURL_ZIP = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/zip.png";
|
|
16
|
+
export declare const DOCICONURL_GENERIC = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/genericfile.png";
|
|
17
|
+
export declare const DOCICONURL_CODE = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/code.png";
|
|
18
|
+
export declare const DOCICONURL_HTML = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/html.png";
|
|
19
|
+
export declare const DOCICONURL_XML = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/xml.png";
|
|
20
|
+
export declare const DOCICONURL_SPO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/spo.png";
|
|
21
|
+
export declare const DOCICONURL_VIDEO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/video.png";
|
|
22
|
+
export default class FileUtils {
|
|
23
|
+
/**
|
|
24
|
+
* GetFileImageUrl
|
|
25
|
+
*/
|
|
26
|
+
static getFileImageUrl(_file: string): string;
|
|
27
|
+
static getShortName: (name: string) => string;
|
|
28
|
+
static isOndrive: (name: string) => Promise<boolean>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export var DOCICONURL_XLSX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/xlsx.png";
|
|
38
|
+
export var DOCICONURL_DOCX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/docx.png";
|
|
39
|
+
export var DOCICONURL_PPTX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/pptx.png";
|
|
40
|
+
export var DOCICONURL_MPPX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/mpp.png";
|
|
41
|
+
export var DOCICONURL_PHOTO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/photo.png";
|
|
42
|
+
export var DOCICONURL_PDF = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/pdf.png";
|
|
43
|
+
export var DOCICONURL_TXT = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/txt.png";
|
|
44
|
+
export var DOCICONURL_EMAIL = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/email.png";
|
|
45
|
+
export var DOCICONURL_CSV = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/csv.png";
|
|
46
|
+
export var DOCICONURL_ONE = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/one.png";
|
|
47
|
+
export var DOCICONURL_VSDX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/vsdx.png";
|
|
48
|
+
export var DOCICONURL_VSSX = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/vssx.png";
|
|
49
|
+
export var DOCICONURL_PUB = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/pub.png";
|
|
50
|
+
export var DOCICONURL_ACCDB = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/accdb.png";
|
|
51
|
+
export var DOCICONURL_ZIP = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/zip.png";
|
|
52
|
+
export var DOCICONURL_GENERIC = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/genericfile.png";
|
|
53
|
+
export var DOCICONURL_CODE = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/code.png";
|
|
54
|
+
export var DOCICONURL_HTML = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/html.png";
|
|
55
|
+
export var DOCICONURL_XML = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/xml.png";
|
|
56
|
+
export var DOCICONURL_SPO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/spo.png";
|
|
57
|
+
export var DOCICONURL_VIDEO = "https://static2.sharepointonline.com/files/fabric/assets/item-types/32/video.png";
|
|
58
|
+
var FileUtils = /** @class */ (function () {
|
|
59
|
+
function FileUtils() {
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* GetFileImageUrl
|
|
63
|
+
*/
|
|
64
|
+
FileUtils.getFileImageUrl = function (_file) {
|
|
65
|
+
if (!_file) {
|
|
66
|
+
return DOCICONURL_GENERIC;
|
|
67
|
+
}
|
|
68
|
+
var _fileImageUrl = DOCICONURL_GENERIC;
|
|
69
|
+
var _fileTypes = _file.split('.');
|
|
70
|
+
var _fileExtension = _fileTypes[_fileTypes.length - 1];
|
|
71
|
+
if (!_fileExtension) {
|
|
72
|
+
return _fileImageUrl;
|
|
73
|
+
}
|
|
74
|
+
switch (_fileExtension.toLowerCase()) {
|
|
75
|
+
case 'xlsx':
|
|
76
|
+
_fileImageUrl = DOCICONURL_XLSX;
|
|
77
|
+
break;
|
|
78
|
+
case 'xls':
|
|
79
|
+
_fileImageUrl = DOCICONURL_XLSX;
|
|
80
|
+
break;
|
|
81
|
+
case 'docx':
|
|
82
|
+
_fileImageUrl = DOCICONURL_DOCX;
|
|
83
|
+
break;
|
|
84
|
+
case 'doc':
|
|
85
|
+
_fileImageUrl = DOCICONURL_DOCX;
|
|
86
|
+
break;
|
|
87
|
+
case 'pptx':
|
|
88
|
+
_fileImageUrl = DOCICONURL_PPTX;
|
|
89
|
+
break;
|
|
90
|
+
case 'ppt':
|
|
91
|
+
_fileImageUrl = DOCICONURL_PPTX;
|
|
92
|
+
break;
|
|
93
|
+
case 'mppx':
|
|
94
|
+
_fileImageUrl = DOCICONURL_MPPX;
|
|
95
|
+
break;
|
|
96
|
+
case 'mpp':
|
|
97
|
+
_fileImageUrl = DOCICONURL_MPPX;
|
|
98
|
+
break;
|
|
99
|
+
case 'csv':
|
|
100
|
+
_fileImageUrl = DOCICONURL_CSV;
|
|
101
|
+
break;
|
|
102
|
+
case 'pdf':
|
|
103
|
+
_fileImageUrl = DOCICONURL_PDF;
|
|
104
|
+
break;
|
|
105
|
+
case 'txt':
|
|
106
|
+
_fileImageUrl = DOCICONURL_TXT;
|
|
107
|
+
break;
|
|
108
|
+
case 'jpg':
|
|
109
|
+
_fileImageUrl = DOCICONURL_PHOTO;
|
|
110
|
+
break;
|
|
111
|
+
case 'msg':
|
|
112
|
+
_fileImageUrl = DOCICONURL_EMAIL;
|
|
113
|
+
break;
|
|
114
|
+
case 'jpeg':
|
|
115
|
+
_fileImageUrl = DOCICONURL_PHOTO;
|
|
116
|
+
break;
|
|
117
|
+
case 'png':
|
|
118
|
+
_fileImageUrl = DOCICONURL_PHOTO;
|
|
119
|
+
break;
|
|
120
|
+
case 'ico':
|
|
121
|
+
_fileImageUrl = DOCICONURL_PHOTO;
|
|
122
|
+
break;
|
|
123
|
+
case 'tiff':
|
|
124
|
+
_fileImageUrl = DOCICONURL_PHOTO;
|
|
125
|
+
break;
|
|
126
|
+
case 'eml':
|
|
127
|
+
_fileImageUrl = DOCICONURL_EMAIL;
|
|
128
|
+
break;
|
|
129
|
+
case 'pub':
|
|
130
|
+
_fileImageUrl = DOCICONURL_PUB;
|
|
131
|
+
break;
|
|
132
|
+
case 'accdb':
|
|
133
|
+
_fileImageUrl = DOCICONURL_ACCDB;
|
|
134
|
+
break;
|
|
135
|
+
case 'zip':
|
|
136
|
+
_fileImageUrl = DOCICONURL_ZIP;
|
|
137
|
+
break;
|
|
138
|
+
case '7z':
|
|
139
|
+
_fileImageUrl = DOCICONURL_ZIP;
|
|
140
|
+
break;
|
|
141
|
+
case 'tar':
|
|
142
|
+
_fileImageUrl = DOCICONURL_ZIP;
|
|
143
|
+
break;
|
|
144
|
+
case 'js':
|
|
145
|
+
_fileImageUrl = DOCICONURL_CODE;
|
|
146
|
+
break;
|
|
147
|
+
case 'json':
|
|
148
|
+
_fileImageUrl = DOCICONURL_CODE;
|
|
149
|
+
break;
|
|
150
|
+
case 'html':
|
|
151
|
+
_fileImageUrl = DOCICONURL_HTML;
|
|
152
|
+
break;
|
|
153
|
+
case 'xml':
|
|
154
|
+
_fileImageUrl = DOCICONURL_XML;
|
|
155
|
+
break;
|
|
156
|
+
case 'aspx':
|
|
157
|
+
_fileImageUrl = DOCICONURL_SPO;
|
|
158
|
+
break;
|
|
159
|
+
case 'mp4':
|
|
160
|
+
_fileImageUrl = DOCICONURL_VIDEO;
|
|
161
|
+
break;
|
|
162
|
+
case 'mov':
|
|
163
|
+
_fileImageUrl = DOCICONURL_VIDEO;
|
|
164
|
+
break;
|
|
165
|
+
case 'wmv':
|
|
166
|
+
_fileImageUrl = DOCICONURL_VIDEO;
|
|
167
|
+
break;
|
|
168
|
+
case 'ogg':
|
|
169
|
+
_fileImageUrl = DOCICONURL_VIDEO;
|
|
170
|
+
break;
|
|
171
|
+
case 'webm':
|
|
172
|
+
_fileImageUrl = DOCICONURL_VIDEO;
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
_fileImageUrl = DOCICONURL_GENERIC;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
return _fileImageUrl;
|
|
179
|
+
};
|
|
180
|
+
var _a;
|
|
181
|
+
_a = FileUtils;
|
|
182
|
+
FileUtils.getShortName = function (name) {
|
|
183
|
+
if (!name)
|
|
184
|
+
return '';
|
|
185
|
+
var splitedName = name.split(".");
|
|
186
|
+
var displayCreatedFileName = splitedName[0].substring(0, 25);
|
|
187
|
+
var displayCreatedFileNameExt = splitedName[splitedName.length - 1];
|
|
188
|
+
var displayCreatedFile = "".concat(displayCreatedFileName, "...").concat(displayCreatedFileNameExt);
|
|
189
|
+
return displayCreatedFile;
|
|
190
|
+
};
|
|
191
|
+
FileUtils.isOndrive = function (name) { return __awaiter(void 0, void 0, void 0, function () {
|
|
192
|
+
return __generator(_a, function (_b) {
|
|
193
|
+
if (!name)
|
|
194
|
+
return [2 /*return*/, false];
|
|
195
|
+
return [2 /*return*/, name.indexOf("my.sharepoint.com") > -1];
|
|
196
|
+
});
|
|
197
|
+
}); };
|
|
198
|
+
return FileUtils;
|
|
199
|
+
}());
|
|
200
|
+
export default FileUtils;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function camelCase(value: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IHttpClient } from "mgwdev-m365-helpers";
|
|
2
|
+
import { IDocumentSearchResult } from "../model";
|
|
3
|
+
export declare class ThumbnailUtils {
|
|
4
|
+
static getThumbnailUrl: (item: IDocumentSearchResult, size: "small" | "medium" | "large") => string;
|
|
5
|
+
static getThumbnailImageFromGraphApiCall: (graphClient: IHttpClient, graphApiUrl: string) => Promise<any>;
|
|
6
|
+
static getThumbnailImageFromGraph: (item: IDocumentSearchResult, graphClient: IHttpClient, size?: "small" | "medium" | "large") => Promise<any>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var ThumbnailUtils = /** @class */ (function () {
|
|
38
|
+
function ThumbnailUtils() {
|
|
39
|
+
}
|
|
40
|
+
var _a;
|
|
41
|
+
_a = ThumbnailUtils;
|
|
42
|
+
ThumbnailUtils.getThumbnailUrl = function (item, size) {
|
|
43
|
+
if (size === void 0) { size = "medium"; }
|
|
44
|
+
return "https://graph.microsoft.com/v1.0/sites/".concat(item.identitySiteCollectionId, "/sites/").concat(item.identityWebId, "/lists/").concat(item.identityListId, "/items/").concat(item.listItemId, "/microsoft.graph.listitem/driveItem/thumbnails/0/").concat(size, "/content");
|
|
45
|
+
};
|
|
46
|
+
ThumbnailUtils.getThumbnailImageFromGraphApiCall = function (graphClient, graphApiUrl) { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
+
var response, binaryData_1, binaryData, base64String;
|
|
48
|
+
return __generator(_a, function (_b) {
|
|
49
|
+
switch (_b.label) {
|
|
50
|
+
case 0: return [4 /*yield*/, graphClient.get(graphApiUrl)];
|
|
51
|
+
case 1:
|
|
52
|
+
response = _b.sent();
|
|
53
|
+
if (!(response.headers["content-type"] === "application/json")) return [3 /*break*/, 3];
|
|
54
|
+
return [4 /*yield*/, response.text()];
|
|
55
|
+
case 2:
|
|
56
|
+
binaryData_1 = _b.sent();
|
|
57
|
+
return [2 /*return*/, "data:image/png;base64," + binaryData_1.replace("\"", "").replace("\"", "")];
|
|
58
|
+
case 3:
|
|
59
|
+
if (response.status === 302) {
|
|
60
|
+
return [2 /*return*/, response.headers["Location"]];
|
|
61
|
+
}
|
|
62
|
+
if (response.status === 404) {
|
|
63
|
+
return [2 /*return*/, ""];
|
|
64
|
+
}
|
|
65
|
+
return [4 /*yield*/, response.arrayBuffer()];
|
|
66
|
+
case 4:
|
|
67
|
+
binaryData = _b.sent();
|
|
68
|
+
base64String = Buffer.from(new Uint8Array(binaryData)
|
|
69
|
+
.reduce(function (data, byte) { return data + String.fromCharCode(byte); }, '')).toString('base64');
|
|
70
|
+
return [2 /*return*/, "data:image/jpeg;base64,".concat(base64String)];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}); };
|
|
74
|
+
ThumbnailUtils.getThumbnailImageFromGraph = function (item, graphClient, size) {
|
|
75
|
+
if (size === void 0) { size = "medium"; }
|
|
76
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
+
var url, base64stringImage;
|
|
78
|
+
return __generator(_a, function (_b) {
|
|
79
|
+
switch (_b.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
url = this.getThumbnailUrl(item, size);
|
|
82
|
+
return [4 /*yield*/, this.getThumbnailImageFromGraphApiCall(graphClient, url)];
|
|
83
|
+
case 1:
|
|
84
|
+
base64stringImage = _b.sent();
|
|
85
|
+
return [2 /*return*/, base64stringImage];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
return ThumbnailUtils;
|
|
91
|
+
}());
|
|
92
|
+
export { ThumbnailUtils };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mgwdev-m365-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "vite",
|
|
7
7
|
"build": "tsc && vite build",
|
|
@@ -12,9 +12,6 @@
|
|
|
12
12
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
13
13
|
"preview": "vite preview"
|
|
14
14
|
},
|
|
15
|
-
"files": [
|
|
16
|
-
"lib"
|
|
17
|
-
],
|
|
18
15
|
"keywords": [
|
|
19
16
|
"SharePoint",
|
|
20
17
|
"MSGraph"
|
|
@@ -54,17 +51,5 @@
|
|
|
54
51
|
"typescript": "^5.2.2",
|
|
55
52
|
"vite": "^5.0.8",
|
|
56
53
|
"vitest": "^1.6.0"
|
|
57
|
-
},
|
|
58
|
-
"files": [
|
|
59
|
-
"dist"
|
|
60
|
-
],
|
|
61
|
-
"main": "./dist/mwdev-m365-components.umd.js",
|
|
62
|
-
"module": "./dist/mwdev-m365-components.es.js",
|
|
63
|
-
"types": "./dist/index.d.ts",
|
|
64
|
-
"exports": {
|
|
65
|
-
".": {
|
|
66
|
-
"import": "./dist/mwdev-m365-components.es.js",
|
|
67
|
-
"require": "./dist/mwdev-m365-components.umd.js"
|
|
68
|
-
}
|
|
69
54
|
}
|
|
70
55
|
}
|
package/public/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"forceConsistentCasingInFileNames": true,
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"jsx": "react",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"sourceMap": false,
|
|
10
|
+
"experimentalDecorators": true,
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"outDir": "lib",
|
|
14
|
+
"inlineSources": false,
|
|
15
|
+
"strictNullChecks": false,
|
|
16
|
+
"noImplicitAny": false,
|
|
17
|
+
"lib": [
|
|
18
|
+
"es2015",
|
|
19
|
+
"dom"
|
|
20
|
+
],
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
"types": [
|
|
23
|
+
"jest",
|
|
24
|
+
"node"
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
"include": [
|
|
28
|
+
"src"
|
|
29
|
+
],
|
|
30
|
+
"references": [
|
|
31
|
+
{
|
|
32
|
+
"path": "./tsconfig.node.json"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import react from '@vitejs/plugin-react';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import dts from 'vite-plugin-dts';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
plugins: [
|
|
8
|
+
react(),
|
|
9
|
+
dts({
|
|
10
|
+
insertTypesEntry: true,
|
|
11
|
+
}),
|
|
12
|
+
],
|
|
13
|
+
server:{
|
|
14
|
+
port: 3000
|
|
15
|
+
},
|
|
16
|
+
build: {
|
|
17
|
+
lib: {
|
|
18
|
+
entry: path.resolve(__dirname, 'src/index.tsx'),
|
|
19
|
+
name: 'mwdev-m365-components',
|
|
20
|
+
formats: ['es', 'umd'],
|
|
21
|
+
fileName: (format) => `mwdev-m365-components.${format}.js`,
|
|
22
|
+
},
|
|
23
|
+
rollupOptions: {
|
|
24
|
+
external: ['react', 'react-dom'],
|
|
25
|
+
output: {
|
|
26
|
+
globals: {
|
|
27
|
+
react: 'React',
|
|
28
|
+
'react-dom': 'ReactDOM',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|