genesys-spark 4.26.0 → 4.26.1
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/LICENSE +21 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +193 -305
- package/package.json +7 -3
- package/dist/src/hosts.d.ts +0 -11
- package/dist/src/index.d.ts +0 -19
- package/dist/src/loading.d.ts +0 -28
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Genesys Cloud Services, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare function dateTimeFormat(localeOrOptions: string | Intl.DateTimeFormatOptions, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
2
|
+
/**
|
|
3
|
+
* Provides an [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
|
|
4
|
+
* object for formatting dates and times. Unlike the native version, `locale` is
|
|
5
|
+
* an optional argument. If not provided, the function will try to determine the
|
|
6
|
+
* locale from the DOM, where it should be set for a11y reasons.
|
|
7
|
+
* @param locale optional locale to use for formatting
|
|
8
|
+
* @param options options to pass to the Intl.RelativeTimeFormat constructor
|
|
9
|
+
* @returns a new RelativeTimeFormat
|
|
10
|
+
*/
|
|
11
|
+
declare function relativeTimeFormat(localeOrOptions: string | Intl.RelativeTimeFormatOptions, options?: Intl.RelativeTimeFormatOptions): Intl.RelativeTimeFormat;
|
|
12
|
+
/**
|
|
13
|
+
* Makes a best effort to return the locale that should be used for a given element
|
|
14
|
+
* by checking language tags on ancestors. If no element is provided, it will
|
|
15
|
+
* start with the document's <body> tag. If no locale can be found, it will use
|
|
16
|
+
* the browser's locale preference. It will also try to add a region to regionless
|
|
17
|
+
* locales when there is a partial match with the browser's locale.
|
|
18
|
+
* @returns a locale string (e.g. 'en-US', 'en', 'de-DE', etc)
|
|
19
|
+
*/
|
|
20
|
+
declare function determineDisplayLocale(element?: HTMLElement): string;
|
|
21
|
+
declare function getFormat(locale: string): string;
|
|
22
|
+
|
|
23
|
+
declare const intl_dateTimeFormat: typeof dateTimeFormat;
|
|
24
|
+
declare const intl_determineDisplayLocale: typeof determineDisplayLocale;
|
|
25
|
+
declare const intl_getFormat: typeof getFormat;
|
|
26
|
+
declare const intl_relativeTimeFormat: typeof relativeTimeFormat;
|
|
27
|
+
declare namespace intl {
|
|
28
|
+
export { intl_dateTimeFormat as dateTimeFormat, intl_determineDisplayLocale as determineDisplayLocale, intl_getFormat as getFormat, intl_relativeTimeFormat as relativeTimeFormat };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* TODO
|
|
33
|
+
*/
|
|
34
|
+
declare function loadSparkFonts(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Loads the spark web components, as well as required CSS and fonts from a
|
|
37
|
+
* shared CDN. Performance can be optimized by pre-loading fonts in static HTML.
|
|
38
|
+
*
|
|
39
|
+
* @returns a promise that succeeds if the component script and styles
|
|
40
|
+
* load successfully. It is not recommended to wait on this promise or to stop
|
|
41
|
+
* application bootstrap if it rejects. Its primary use should be for logging
|
|
42
|
+
* unexpected failures.
|
|
43
|
+
*/
|
|
44
|
+
declare function registerSparkComponents(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* TODO
|
|
47
|
+
*/
|
|
48
|
+
declare function registerSparkChartComponents(): Promise<void>;
|
|
49
|
+
|
|
50
|
+
export { intl as Intl, loadSparkFonts, registerSparkChartComponents, registerSparkComponents };
|
package/dist/index.js
CHANGED
|
@@ -1,348 +1,236 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'mypurecloud.jp'
|
|
12
|
-
// 'use2.us-gov-pure.cloud', Assets are not currently deployed to FedRAMP. It should fall back to the default domain.
|
|
1
|
+
const DEFAULT_DOMAIN = "mypurecloud.com";
|
|
2
|
+
const NON_STANDARD_DOMAINS = [
|
|
3
|
+
"inindca.com",
|
|
4
|
+
"inintca.com",
|
|
5
|
+
"mypurecloud.com.au",
|
|
6
|
+
"mypurecloud.com",
|
|
7
|
+
"mypurecloud.de",
|
|
8
|
+
"mypurecloud.ie",
|
|
9
|
+
"mypurecloud.jp"
|
|
10
|
+
// 'use2.us-gov-pure.cloud', Assets are not currently deployed to FedRAMP. It should fall back to the default domain.
|
|
13
11
|
];
|
|
14
|
-
/**
|
|
15
|
-
* Returns the origin that web component assets should be loaded from.
|
|
16
|
-
* Will use the domain of the current window if it matches a Genesys domain.
|
|
17
|
-
*/
|
|
18
12
|
function getComponentAssetsOrigin() {
|
|
19
|
-
|
|
13
|
+
return getAssetsOrigin();
|
|
20
14
|
}
|
|
21
15
|
function getChartComponentAssetsOrigin() {
|
|
22
|
-
|
|
16
|
+
return getAssetsOrigin();
|
|
23
17
|
}
|
|
24
18
|
function getAssetsOrigin() {
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const matchedDomain = getRegionDomain();
|
|
20
|
+
return `https://app.${matchedDomain || DEFAULT_DOMAIN}`;
|
|
27
21
|
}
|
|
28
22
|
function getFontOrigin() {
|
|
29
|
-
|
|
23
|
+
return getComponentAssetsOrigin();
|
|
30
24
|
}
|
|
31
25
|
function getRegionDomain() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return pageHost.endsWith(regionDomain);
|
|
40
|
-
});
|
|
26
|
+
const pageHost = window.location.hostname;
|
|
27
|
+
if (pageHost.endsWith(".pure.cloud")) {
|
|
28
|
+
return pageHost.split(".").slice(-3).join(".");
|
|
29
|
+
}
|
|
30
|
+
return NON_STANDARD_DOMAINS.find(
|
|
31
|
+
(regionDomain) => pageHost.endsWith(regionDomain)
|
|
32
|
+
);
|
|
41
33
|
}
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var __assign = function() {
|
|
61
|
-
__assign = Object.assign || function __assign(t) {
|
|
62
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
63
|
-
s = arguments[i];
|
|
64
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
65
|
-
}
|
|
66
|
-
return t;
|
|
67
|
-
};
|
|
68
|
-
return __assign.apply(this, arguments);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
72
|
-
var e = new Error(message);
|
|
73
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
35
|
+
var __defProp = Object.defineProperty;
|
|
36
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
37
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
38
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
39
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
40
|
+
var __spreadValues = (a, b) => {
|
|
41
|
+
for (var prop in b || (b = {}))
|
|
42
|
+
if (__hasOwnProp.call(b, prop))
|
|
43
|
+
__defNormalProp(a, prop, b[prop]);
|
|
44
|
+
if (__getOwnPropSymbols)
|
|
45
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
46
|
+
if (__propIsEnum.call(b, prop))
|
|
47
|
+
__defNormalProp(a, prop, b[prop]);
|
|
48
|
+
}
|
|
49
|
+
return a;
|
|
74
50
|
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Add a script tag to the document if it is not already present.
|
|
78
|
-
* @param scriptSrc The src attribute of the script
|
|
79
|
-
* @returns a promise that resolves if the script loads or is already present
|
|
80
|
-
*/
|
|
81
51
|
function checkAndLoadScript(scriptSrc) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
52
|
+
const existingTag = document.querySelector(`script[src="${scriptSrc}"]`);
|
|
53
|
+
if (existingTag) {
|
|
54
|
+
return Promise.resolve();
|
|
55
|
+
} else {
|
|
56
|
+
const scriptTag = document.createElement("script");
|
|
57
|
+
scriptTag.setAttribute("type", "module");
|
|
58
|
+
scriptTag.setAttribute("src", scriptSrc);
|
|
59
|
+
const result = new Promise((resolve, reject) => {
|
|
60
|
+
scriptTag.addEventListener("load", () => {
|
|
61
|
+
resolve();
|
|
62
|
+
});
|
|
63
|
+
scriptTag.addEventListener("error", () => {
|
|
64
|
+
reject(`Spark script failed to load: ${scriptSrc}`);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
document.head.appendChild(scriptTag);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
101
70
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Add a stylesheet link tag to the document if it is not already present.
|
|
104
|
-
* @param styleHref The href attribute of the stylesheet
|
|
105
|
-
* @returns a promise that resolves if the style loads or is already present
|
|
106
|
-
*/
|
|
107
71
|
function checkAndLoadStyle(styleHref) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
72
|
+
const existingTag = document.querySelector(`link[href="${styleHref}"]`);
|
|
73
|
+
if (existingTag) {
|
|
74
|
+
return Promise.resolve();
|
|
75
|
+
} else {
|
|
76
|
+
const styleTag = document.createElement("link");
|
|
77
|
+
styleTag.setAttribute("href", styleHref);
|
|
78
|
+
styleTag.setAttribute("rel", "stylesheet");
|
|
79
|
+
const result = new Promise((resolve, reject) => {
|
|
80
|
+
styleTag.addEventListener("load", () => {
|
|
81
|
+
resolve();
|
|
82
|
+
});
|
|
83
|
+
styleTag.addEventListener("error", () => {
|
|
84
|
+
reject(`Spark styles failed to load: ${styleHref}`);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
document.head.appendChild(styleTag);
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
127
90
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Given an object that maps font-family identifiers to CSS urls e.g:
|
|
130
|
-
* {
|
|
131
|
-
* "Urbanist": "/urbanist.css",
|
|
132
|
-
* "Noto Sans": "/noto-sans.css"
|
|
133
|
-
* }
|
|
134
|
-
* This function checks for loaded fonts with those identifiers. If a font is
|
|
135
|
-
* not found, the corresponding stylesheet is added to the document.
|
|
136
|
-
* @param fonts An object mapping font-family identifiers to CSS file urls
|
|
137
|
-
* @returns A promise that resolves once the script tags has finished loading.
|
|
138
|
-
* It does not fail if the script tags fail to load because we don't want to fail
|
|
139
|
-
* the whole component loading process in that situation.
|
|
140
|
-
*/
|
|
141
91
|
function checkAndLoadFonts(fonts) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
})).then(function () { }); // flatten the promise array
|
|
92
|
+
const fontsToLoad = __spreadValues({}, fonts);
|
|
93
|
+
document.fonts.forEach((fontFace) => {
|
|
94
|
+
const normalizedFamily = fontFace.family.replace(/"/g, "");
|
|
95
|
+
if (fontsToLoad[normalizedFamily]) {
|
|
96
|
+
delete fontsToLoad[normalizedFamily];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return Promise.all(
|
|
100
|
+
Object.values(fontsToLoad).map((href) => {
|
|
101
|
+
return checkAndLoadStyle(href).catch(() => {
|
|
102
|
+
console.info(`genesys-spark: couldn't load font style ${href}`);
|
|
103
|
+
});
|
|
104
|
+
})
|
|
105
|
+
).then(() => {
|
|
106
|
+
});
|
|
159
107
|
}
|
|
160
108
|
|
|
161
|
-
//https://inindca.atlassian.net/browse/COMUI-2673
|
|
162
|
-
// utility to get the closest element passing shadow dom boundaries
|
|
163
109
|
function getClosestElement(node, selector) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return getClosestElement(node.parentNode, selector);
|
|
110
|
+
if (!node) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
if (node instanceof ShadowRoot) {
|
|
114
|
+
return getClosestElement(node.host, selector);
|
|
115
|
+
}
|
|
116
|
+
if (node instanceof HTMLElement) {
|
|
117
|
+
if (node.matches(selector)) {
|
|
118
|
+
return node;
|
|
119
|
+
} else {
|
|
120
|
+
return getClosestElement(node.parentNode, selector);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return getClosestElement(node.parentNode, selector);
|
|
179
124
|
}
|
|
180
125
|
|
|
181
|
-
/**
|
|
182
|
-
* Provides an [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)
|
|
183
|
-
* object for formatting dates and times. Unlike the native version, `locale` is
|
|
184
|
-
* an optional argument. If not provided, the function will try to determine the
|
|
185
|
-
* locale from the DOM, where it should be set for a11y reasons.
|
|
186
|
-
* @param locale optional locale to use for formatting
|
|
187
|
-
* @param options options to pass to the Intl.DateTimeFormat constructor
|
|
188
|
-
* @returns a new DateTimeFormat
|
|
189
|
-
*/
|
|
190
126
|
function dateTimeFormat(localeOrOptions, options) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return new Intl.DateTimeFormat(userLocale, options);
|
|
204
|
-
}
|
|
127
|
+
let locale = void 0;
|
|
128
|
+
if (typeof localeOrOptions === "string") {
|
|
129
|
+
locale = localeOrOptions;
|
|
130
|
+
} else {
|
|
131
|
+
options = localeOrOptions;
|
|
132
|
+
}
|
|
133
|
+
if (locale != void 0) {
|
|
134
|
+
return new Intl.DateTimeFormat(locale, options);
|
|
135
|
+
} else {
|
|
136
|
+
const userLocale = determineDisplayLocale();
|
|
137
|
+
return new Intl.DateTimeFormat(userLocale, options);
|
|
138
|
+
}
|
|
205
139
|
}
|
|
206
|
-
/**
|
|
207
|
-
* Provides an [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
|
|
208
|
-
* object for formatting dates and times. Unlike the native version, `locale` is
|
|
209
|
-
* an optional argument. If not provided, the function will try to determine the
|
|
210
|
-
* locale from the DOM, where it should be set for a11y reasons.
|
|
211
|
-
* @param locale optional locale to use for formatting
|
|
212
|
-
* @param options options to pass to the Intl.RelativeTimeFormat constructor
|
|
213
|
-
* @returns a new RelativeTimeFormat
|
|
214
|
-
*/
|
|
215
140
|
function relativeTimeFormat(localeOrOptions, options) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
* @returns a locale string (e.g. 'en-US', 'en', 'de-DE', etc)
|
|
238
|
-
*/
|
|
239
|
-
function determineDisplayLocale(element) {
|
|
240
|
-
var _a;
|
|
241
|
-
if (element === void 0) { element = document.body; }
|
|
242
|
-
var domLocale = (_a = getClosestElement(element, '*[lang]')) === null || _a === void 0 ? void 0 : _a.lang;
|
|
243
|
-
if (!domLocale || browserHasRegionData(domLocale)) {
|
|
244
|
-
// If we can't find a locale in the DOM, or we find a locale without a region that matches the
|
|
245
|
-
// users's browser locale, use the browser locale.
|
|
246
|
-
return navigator.language;
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
return domLocale;
|
|
250
|
-
}
|
|
141
|
+
let locale = void 0;
|
|
142
|
+
if (typeof localeOrOptions === "string") {
|
|
143
|
+
locale = localeOrOptions;
|
|
144
|
+
} else {
|
|
145
|
+
options = localeOrOptions;
|
|
146
|
+
}
|
|
147
|
+
if (locale != void 0) {
|
|
148
|
+
return new Intl.RelativeTimeFormat(locale, options);
|
|
149
|
+
} else {
|
|
150
|
+
const userLocale = determineDisplayLocale();
|
|
151
|
+
return new Intl.RelativeTimeFormat(userLocale, options);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function determineDisplayLocale(element = document.body) {
|
|
155
|
+
var _a;
|
|
156
|
+
const domLocale = (_a = getClosestElement(element, "*[lang]")) == null ? void 0 : _a.lang;
|
|
157
|
+
if (!domLocale || browserHasRegionData(domLocale)) {
|
|
158
|
+
return navigator.language;
|
|
159
|
+
} else {
|
|
160
|
+
return domLocale;
|
|
161
|
+
}
|
|
251
162
|
}
|
|
252
|
-
/**
|
|
253
|
-
* Returns true if the provided locale only has a language, but the user's
|
|
254
|
-
* browser settings have the same language with a locale.
|
|
255
|
-
* @param localeString The locale to check
|
|
256
|
-
* @returns true if the region can be guessed from the browser settings.
|
|
257
|
-
*/
|
|
258
163
|
function browserHasRegionData(localeString) {
|
|
259
|
-
|
|
260
|
-
navigator.language.startsWith("".concat(localeString, "-")));
|
|
164
|
+
return localeString.length == 2 && navigator.language.startsWith(`${localeString}-`);
|
|
261
165
|
}
|
|
262
166
|
function getFormat(locale) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return dateString.replace(/\s/g, '').replace(//g, '');
|
|
167
|
+
const date = /* @__PURE__ */ new Date("July 5, 2000 15:00:00 UTC+00:00");
|
|
168
|
+
const options = {
|
|
169
|
+
year: "numeric",
|
|
170
|
+
month: "numeric",
|
|
171
|
+
day: "numeric"
|
|
172
|
+
};
|
|
173
|
+
const dateTimeFormat2 = new Intl.DateTimeFormat(
|
|
174
|
+
locale,
|
|
175
|
+
options
|
|
176
|
+
);
|
|
177
|
+
const parts = dateTimeFormat2.formatToParts(date);
|
|
178
|
+
const dateString = parts.map(({ type, value }) => {
|
|
179
|
+
switch (type) {
|
|
180
|
+
case "day":
|
|
181
|
+
return `dd`;
|
|
182
|
+
case "month":
|
|
183
|
+
return `mm`;
|
|
184
|
+
case "year":
|
|
185
|
+
return `yyyy`;
|
|
186
|
+
default:
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
}).join("");
|
|
190
|
+
return dateString.replace(/\s/g, "").replace(//g, "");
|
|
288
191
|
}
|
|
289
192
|
|
|
290
193
|
var intl = /*#__PURE__*/Object.freeze({
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
194
|
+
__proto__: null,
|
|
195
|
+
dateTimeFormat: dateTimeFormat,
|
|
196
|
+
determineDisplayLocale: determineDisplayLocale,
|
|
197
|
+
getFormat: getFormat,
|
|
198
|
+
relativeTimeFormat: relativeTimeFormat
|
|
296
199
|
});
|
|
297
200
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* TODO
|
|
302
|
-
*/
|
|
201
|
+
const COMPONENT_ASSET_PREFIX = "/spark-components/build-assets/4.26.1-135/genesys-webcomponents/";
|
|
202
|
+
const CHART_COMPONENT_ASSET_PREFIX = "/spark-components/build-assets/4.26.1-135/genesys-chart-webcomponents/";
|
|
303
203
|
function loadSparkFonts() {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
204
|
+
const fontOrigin = getFontOrigin();
|
|
205
|
+
const FONTS = {
|
|
206
|
+
Urbanist: `${fontOrigin}/webfonts/urbanist.css`,
|
|
207
|
+
"Noto Sans": `${fontOrigin}/webfonts/noto-sans.css`
|
|
208
|
+
};
|
|
209
|
+
return checkAndLoadFonts(FONTS);
|
|
310
210
|
}
|
|
311
|
-
/**
|
|
312
|
-
* Loads the spark web components, as well as required CSS and fonts from a
|
|
313
|
-
* shared CDN. Performance can be optimized by pre-loading fonts in static HTML.
|
|
314
|
-
*
|
|
315
|
-
* @returns a promise that succeeds if the component script and styles
|
|
316
|
-
* load successfully. It is not recommended to wait on this promise or to stop
|
|
317
|
-
* application bootstrap if it rejects. Its primary use should be for logging
|
|
318
|
-
* unexpected failures.
|
|
319
|
-
*/
|
|
320
211
|
function registerSparkComponents() {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
212
|
+
const SCRIPT_PATH = "genesys-webcomponents.esm.js";
|
|
213
|
+
const STYLE_PATH = "genesys-webcomponents.css";
|
|
214
|
+
const assetsOrigin = getComponentAssetsOrigin();
|
|
215
|
+
const SCRIPT_SRC = `${assetsOrigin}${COMPONENT_ASSET_PREFIX}${SCRIPT_PATH}`;
|
|
216
|
+
const STYLE_HREF = `${assetsOrigin}${COMPONENT_ASSET_PREFIX}${STYLE_PATH}`;
|
|
217
|
+
return Promise.all([
|
|
218
|
+
checkAndLoadScript(SCRIPT_SRC),
|
|
219
|
+
checkAndLoadStyle(STYLE_HREF),
|
|
220
|
+
loadSparkFonts()
|
|
221
|
+
]).then();
|
|
331
222
|
}
|
|
332
|
-
/**
|
|
333
|
-
* TODO
|
|
334
|
-
*/
|
|
335
223
|
function registerSparkChartComponents() {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
224
|
+
const SCRIPT_PATH = "genesys-chart-webcomponents.esm.js";
|
|
225
|
+
const STYLE_PATH = "genesys-chart-webcomponents.css";
|
|
226
|
+
const assetsOrigin = getChartComponentAssetsOrigin();
|
|
227
|
+
const SCRIPT_SRC = `${assetsOrigin}${CHART_COMPONENT_ASSET_PREFIX}${SCRIPT_PATH}`;
|
|
228
|
+
const STYLE_HREF = `${assetsOrigin}${CHART_COMPONENT_ASSET_PREFIX}${STYLE_PATH}`;
|
|
229
|
+
return Promise.all([
|
|
230
|
+
checkAndLoadScript(SCRIPT_SRC),
|
|
231
|
+
checkAndLoadStyle(STYLE_HREF),
|
|
232
|
+
loadSparkFonts()
|
|
233
|
+
]).then();
|
|
346
234
|
}
|
|
347
235
|
|
|
348
236
|
export { intl as Intl, loadSparkFonts, registerSparkChartComponents, registerSparkComponents };
|
package/package.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genesys-spark",
|
|
3
|
-
"version": "4.26.
|
|
3
|
+
"version": "4.26.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist
|
|
10
|
+
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
+
"prebuild": "npm run clean",
|
|
13
14
|
"build": "rollup -c",
|
|
15
|
+
"clean": "rm -r ./dist || true",
|
|
14
16
|
"dev": "rollup -c --watch",
|
|
15
17
|
"eslint": "eslint --fix './**/*.ts'",
|
|
16
18
|
"lint-staged": "lint-staged --concurrent false",
|
|
17
19
|
"prettier": "prettier --log-level silent --ignore-path .gitignore --ignore-unknown --write .",
|
|
18
20
|
"test": "jest",
|
|
21
|
+
"test.ci": "npm run test",
|
|
19
22
|
"test.watch": "jest --watch",
|
|
20
23
|
"version-sync": "npm version --no-git-tag-version --allow-same-version"
|
|
21
24
|
},
|
|
22
25
|
"types": "dist/src/index.d.ts",
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"@rollup/plugin-replace": "^5.0.5",
|
|
25
|
-
"@rollup/plugin-typescript": "^11.1.6",
|
|
26
28
|
"@tsconfig/strictest": "^2.0.3",
|
|
27
29
|
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
28
30
|
"@typescript-eslint/parser": "^7.1.0",
|
|
@@ -30,6 +32,8 @@
|
|
|
30
32
|
"jest": "^29.7.0",
|
|
31
33
|
"jest-environment-jsdom": "^29.7.0",
|
|
32
34
|
"rollup": "^4.12.1",
|
|
35
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
36
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
33
37
|
"ts-jest": "^29.1.2"
|
|
34
38
|
}
|
|
35
39
|
}
|
package/dist/src/hosts.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
var IS_DEV_MODE: boolean;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Returns the origin that web component assets should be loaded from.
|
|
6
|
-
* Will use the domain of the current window if it matches a Genesys domain.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getComponentAssetsOrigin(): string;
|
|
9
|
-
export declare function getChartComponentAssetsOrigin(): string;
|
|
10
|
-
export declare function getAssetsOrigin(): string;
|
|
11
|
-
export declare function getFontOrigin(): string;
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TODO
|
|
3
|
-
*/
|
|
4
|
-
export declare function loadSparkFonts(): Promise<void>;
|
|
5
|
-
/**
|
|
6
|
-
* Loads the spark web components, as well as required CSS and fonts from a
|
|
7
|
-
* shared CDN. Performance can be optimized by pre-loading fonts in static HTML.
|
|
8
|
-
*
|
|
9
|
-
* @returns a promise that succeeds if the component script and styles
|
|
10
|
-
* load successfully. It is not recommended to wait on this promise or to stop
|
|
11
|
-
* application bootstrap if it rejects. Its primary use should be for logging
|
|
12
|
-
* unexpected failures.
|
|
13
|
-
*/
|
|
14
|
-
export declare function registerSparkComponents(): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* TODO
|
|
17
|
-
*/
|
|
18
|
-
export declare function registerSparkChartComponents(): Promise<void>;
|
|
19
|
-
export * as Intl from './utils/intl';
|
package/dist/src/loading.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Add a script tag to the document if it is not already present.
|
|
3
|
-
* @param scriptSrc The src attribute of the script
|
|
4
|
-
* @returns a promise that resolves if the script loads or is already present
|
|
5
|
-
*/
|
|
6
|
-
export declare function checkAndLoadScript(scriptSrc: string): Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* Add a stylesheet link tag to the document if it is not already present.
|
|
9
|
-
* @param styleHref The href attribute of the stylesheet
|
|
10
|
-
* @returns a promise that resolves if the style loads or is already present
|
|
11
|
-
*/
|
|
12
|
-
export declare function checkAndLoadStyle(styleHref: string): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Given an object that maps font-family identifiers to CSS urls e.g:
|
|
15
|
-
* {
|
|
16
|
-
* "Urbanist": "/urbanist.css",
|
|
17
|
-
* "Noto Sans": "/noto-sans.css"
|
|
18
|
-
* }
|
|
19
|
-
* This function checks for loaded fonts with those identifiers. If a font is
|
|
20
|
-
* not found, the corresponding stylesheet is added to the document.
|
|
21
|
-
* @param fonts An object mapping font-family identifiers to CSS file urls
|
|
22
|
-
* @returns A promise that resolves once the script tags has finished loading.
|
|
23
|
-
* It does not fail if the script tags fail to load because we don't want to fail
|
|
24
|
-
* the whole component loading process in that situation.
|
|
25
|
-
*/
|
|
26
|
-
export declare function checkAndLoadFonts(fonts: {
|
|
27
|
-
[key: string]: string;
|
|
28
|
-
}): Promise<void>;
|