@watermarkinsights/ripple 3.0.1-0 → 3.0.2-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.
- package/dist/{ripple/functions-316c1b23.js → cjs/functions-e3f5ae65.js} +188 -2391
- package/dist/cjs/global-1e540de6.js +38 -0
- package/dist/cjs/http-service-9e8c4dd5.js +57 -0
- package/dist/cjs/index-d930307d.js +1392 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/interfaces-30a74c1f.js +35 -0
- package/dist/cjs/loader.cjs.js +22 -0
- package/dist/cjs/priv-chart-popover.cjs.entry.js +89 -0
- package/dist/cjs/priv-datepicker.cjs.entry.js +672 -0
- package/dist/cjs/priv-navigator-button.cjs.entry.js +29 -0
- package/dist/cjs/priv-navigator-item.cjs.entry.js +34 -0
- package/dist/cjs/ripple.cjs.js +20 -0
- package/dist/cjs/wm-action-menu_2.cjs.entry.js +318 -0
- package/dist/cjs/wm-button.cjs.entry.js +152 -0
- package/dist/cjs/wm-chart-slice.cjs.entry.js +22 -0
- package/dist/cjs/wm-chart.cjs.entry.js +508 -0
- package/dist/cjs/wm-datepicker.cjs.entry.js +257 -0
- package/dist/cjs/wm-input.cjs.entry.js +110 -0
- package/dist/cjs/wm-modal-footer.cjs.entry.js +43 -0
- package/dist/cjs/wm-modal-header.cjs.entry.js +45 -0
- package/dist/cjs/wm-modal.cjs.entry.js +149 -0
- package/dist/cjs/wm-navigator.cjs.entry.js +279 -0
- package/dist/cjs/wm-network-uploader.cjs.entry.js +431 -0
- package/dist/cjs/wm-option_2.cjs.entry.js +483 -0
- package/dist/cjs/wm-pagination.cjs.entry.js +176 -0
- package/dist/cjs/wm-search.cjs.entry.js +231 -0
- package/dist/cjs/wm-snackbar.cjs.entry.js +160 -0
- package/dist/cjs/wm-tab-item_3.cjs.entry.js +316 -0
- package/dist/cjs/wm-tag-input.cjs.entry.js +538 -0
- package/dist/cjs/wm-timepicker.cjs.entry.js +386 -0
- package/dist/cjs/wm-toggletip.cjs.entry.js +128 -0
- package/dist/cjs/wm-uploader.cjs.entry.js +342 -0
- package/dist/cjs/wm-wrapper.cjs.entry.js +21 -0
- package/dist/collection/collection-manifest.json +131 -0
- package/dist/{ripple/ripple.css → collection/components/wm-action-menu/wm-action-menu.css} +80 -42
- package/dist/collection/components/wm-action-menu/wm-action-menu.js +392 -0
- package/dist/collection/components/wm-button/wm-button.css +572 -0
- package/dist/collection/components/wm-button/wm-button.js +365 -0
- package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.css +132 -0
- package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.js +232 -0
- package/dist/collection/components/wm-chart/wm-chart-slice.js +64 -0
- package/dist/collection/components/wm-chart/wm-chart.css +337 -0
- package/dist/collection/components/wm-chart/wm-chart.js +710 -0
- package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.css +374 -0
- package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1003 -0
- package/dist/collection/components/wm-datepicker/wm-datepicker.css +211 -0
- package/dist/collection/components/wm-datepicker/wm-datepicker.js +439 -0
- package/dist/collection/components/wm-input/wm-input.css +220 -0
- package/dist/collection/components/wm-input/wm-input.js +302 -0
- package/dist/collection/components/wm-menuitem/wm-menuitem.css +118 -0
- package/dist/collection/components/wm-menuitem/wm-menuitem.js +411 -0
- package/dist/collection/components/wm-modal/wm-modal-footer.css +84 -0
- package/dist/collection/components/wm-modal/wm-modal-footer.js +159 -0
- package/dist/collection/components/wm-modal/wm-modal-header.css +78 -0
- package/dist/collection/components/wm-modal/wm-modal-header.js +109 -0
- package/dist/collection/components/wm-modal/wm-modal.css +155 -0
- package/dist/collection/components/wm-modal/wm-modal.js +356 -0
- package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.css +94 -0
- package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -0
- package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.css +67 -0
- package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -0
- package/dist/collection/components/wm-navigator/wm-navigator.css +137 -0
- package/dist/collection/components/wm-navigator/wm-navigator.js +468 -0
- package/dist/collection/components/wm-option/wm-option.css +162 -0
- package/dist/collection/components/wm-option/wm-option.js +394 -0
- package/dist/collection/components/wm-pagination/wm-pagination.css +217 -0
- package/dist/collection/components/wm-pagination/wm-pagination.js +348 -0
- package/dist/collection/components/wm-search/wm-search.css +155 -0
- package/dist/collection/components/wm-search/wm-search.js +439 -0
- package/dist/collection/components/wm-select/wm-select.css +315 -0
- package/dist/collection/components/wm-select/wm-select.js +676 -0
- package/dist/collection/components/wm-snackbar/wm-snackbar.css +331 -0
- package/dist/collection/components/wm-snackbar/wm-snackbar.js +240 -0
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.css +104 -0
- package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +202 -0
- package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.css +73 -0
- package/dist/{ripple/wm-tab-list.entry.js → collection/components/wm-tabs/wm-tab-list/wm-tab-list.js} +131 -17
- package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.css +57 -0
- package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -0
- package/dist/collection/components/wm-tag-input/wm-tag-input.css +431 -0
- package/dist/collection/components/wm-tag-input/wm-tag-input.js +754 -0
- package/dist/collection/components/wm-timepicker/wm-timepicker.css +370 -0
- package/dist/collection/components/wm-timepicker/wm-timepicker.js +567 -0
- package/dist/collection/components/wm-toggletip/wm-toggletip.css +350 -0
- package/dist/collection/components/wm-toggletip/wm-toggletip.js +217 -0
- package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.css +642 -0
- package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -0
- package/dist/collection/components/wm-uploader/wm-uploader.css +666 -0
- package/dist/collection/components/wm-uploader/wm-uploader.js +673 -0
- package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -0
- package/dist/collection/dev/scripts.js +20 -0
- package/dist/collection/global/__mocks__/functions.js +5 -0
- package/dist/collection/global/functions.js +420 -0
- package/dist/{ripple/app-globals-b5693c90.js → collection/global/global.js} +3 -8
- package/dist/{ripple/interfaces-50753346.js → collection/global/interfaces.js} +4 -6
- package/dist/collection/global/services/__mocks__/http-service.js +130 -0
- package/dist/collection/global/services/http-service.js +50 -0
- package/dist/collection/lang/lang.js +5 -0
- package/dist/collection/lang/piglatin.js +93 -0
- package/dist/esm/functions-0deb7f8e.js +6117 -0
- package/dist/esm/global-d6b49e98.js +36 -0
- package/dist/{ripple → esm}/http-service-5d037e16.js +0 -0
- package/dist/esm/index-5a842e48.js +1363 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/interfaces-61c6305b.js +32 -0
- package/dist/esm/loader.js +18 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/{ripple → esm}/priv-chart-popover.entry.js +2 -2
- package/dist/{ripple → esm}/priv-datepicker.entry.js +3 -3
- package/dist/{ripple → esm}/priv-navigator-button.entry.js +1 -1
- package/dist/{ripple → esm}/priv-navigator-item.entry.js +1 -1
- package/dist/esm/ripple.js +18 -0
- package/dist/{ripple/wm-action-menu.entry.js → esm/wm-action-menu_2.entry.js} +114 -3
- package/dist/{ripple → esm}/wm-button.entry.js +3 -3
- package/dist/{ripple → esm}/wm-chart-slice.entry.js +1 -1
- package/dist/{ripple → esm}/wm-chart.entry.js +2 -2
- package/dist/{ripple → esm}/wm-datepicker.entry.js +27 -32
- package/dist/{ripple → esm}/wm-input.entry.js +2 -2
- package/dist/{ripple → esm}/wm-modal-footer.entry.js +2 -2
- package/dist/{ripple → esm}/wm-modal-header.entry.js +2 -2
- package/dist/{ripple → esm}/wm-modal.entry.js +2 -2
- package/dist/{ripple → esm}/wm-navigator.entry.js +3 -3
- package/dist/{ripple → esm}/wm-network-uploader.entry.js +2 -2
- package/dist/{ripple/wm-select.entry.js → esm/wm-option_2.entry.js} +119 -3
- package/dist/{ripple → esm}/wm-pagination.entry.js +2 -2
- package/dist/{ripple → esm}/wm-search.entry.js +2 -2
- package/dist/{ripple → esm}/wm-snackbar.entry.js +2 -2
- package/dist/esm/wm-tab-item_3.entry.js +310 -0
- package/dist/{ripple → esm}/wm-tag-input.entry.js +2 -2
- package/dist/{ripple → esm}/wm-timepicker.entry.js +2 -2
- package/dist/{ripple → esm}/wm-toggletip.entry.js +2 -2
- package/dist/{ripple → esm}/wm-uploader.entry.js +2 -2
- package/dist/{ripple → esm}/wm-wrapper.entry.js +1 -1
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +3 -0
- package/dist/loader/index.cjs.js +3 -0
- package/dist/loader/index.d.ts +13 -0
- package/dist/loader/index.es2017.js +3 -0
- package/dist/loader/index.js +4 -0
- package/dist/loader/package.json +10 -0
- package/dist/ripple/index.esm.js +0 -1
- package/dist/ripple/p-103f8cae.entry.js +1 -0
- package/dist/ripple/p-129d94fa.entry.js +1 -0
- package/dist/ripple/p-139fe143.entry.js +1 -0
- package/dist/ripple/p-16367805.entry.js +1 -0
- package/dist/ripple/p-1d334060.entry.js +1 -0
- package/dist/ripple/p-2562f330.entry.js +1 -0
- package/dist/ripple/p-278b26ef.entry.js +1 -0
- package/dist/ripple/p-2c21bb72.entry.js +1 -0
- package/dist/ripple/p-2f5fda71.entry.js +1 -0
- package/dist/ripple/p-3e6f04d5.entry.js +1 -0
- package/dist/ripple/p-7185de7f.entry.js +1 -0
- package/dist/ripple/p-770d0798.entry.js +1 -0
- package/dist/ripple/p-846b4c5f.entry.js +1 -0
- package/dist/ripple/p-888bec42.js +1 -0
- package/dist/ripple/p-90779d53.entry.js +1 -0
- package/dist/ripple/p-934543f2.js +1 -0
- package/dist/ripple/p-9a087fee.entry.js +1 -0
- package/dist/ripple/p-a6d6eae7.js +1 -0
- package/dist/ripple/p-a942ad10.entry.js +1 -0
- package/dist/ripple/p-bfb4652d.entry.js +1 -0
- package/dist/ripple/p-c0fe5201.entry.js +1 -0
- package/dist/ripple/p-c2e27acc.entry.js +1 -0
- package/dist/ripple/p-c2edda64.entry.js +1 -0
- package/dist/ripple/p-d1fdcbcf.entry.js +1 -0
- package/dist/ripple/p-d40b6afb.entry.js +1 -0
- package/dist/ripple/p-da73db1c.entry.js +1 -0
- package/dist/ripple/p-e3843249.js +1 -0
- package/dist/ripple/p-ea5cd8b8.js +16 -0
- package/dist/ripple/p-ed0f43f4.entry.js +1 -0
- package/dist/ripple/p-ffafd363.entry.js +1 -0
- package/dist/ripple/ripple.esm.js +1 -125
- package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +43 -0
- package/dist/types/components/wm-button/wm-button.d.ts +36 -0
- package/dist/types/components/wm-chart/priv-chart-popover/priv-chart-popover.d.ts +23 -0
- package/dist/types/components/wm-chart/wm-chart-slice.d.ts +8 -0
- package/dist/types/components/wm-chart/wm-chart.d.ts +77 -0
- package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +75 -0
- package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +39 -0
- package/dist/types/components/wm-input/wm-input.d.ts +30 -0
- package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +30 -0
- package/dist/types/components/wm-modal/wm-modal-footer.d.ts +15 -0
- package/dist/types/components/wm-modal/wm-modal-header.d.ts +12 -0
- package/dist/types/components/wm-modal/wm-modal.d.ts +34 -0
- package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -0
- package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -0
- package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -0
- package/dist/types/components/wm-option/wm-option.d.ts +28 -0
- package/dist/types/components/wm-pagination/wm-pagination.d.ts +31 -0
- package/dist/types/components/wm-search/wm-search.d.ts +78 -0
- package/dist/types/components/wm-select/wm-select.d.ts +63 -0
- package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +32 -0
- package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +35 -0
- package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +50 -0
- package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -0
- package/dist/types/components/wm-tag-input/{wm-tag-input.d.ts~ds312_tagInputMaxTags → wm-tag-input.d.ts} +1 -1
- package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +59 -0
- package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +25 -0
- package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -0
- package/dist/types/components/wm-uploader/wm-uploader.d.ts +75 -0
- package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -0
- package/dist/types/{components.d.ts~ds312_tagInputMaxTags → components.d.ts} +0 -0
- package/dist/types/global/__mocks__/functions.d.ts +5 -0
- package/dist/types/global/global.d.ts +1 -0
- package/dist/types/global/interfaces.d.ts +33 -0
- package/dist/types/global/services/__mocks__/http-service.d.ts +6 -0
- package/dist/types/global/services/http-service.d.ts +4 -0
- package/dist/types/lang/lang.d.ts +5 -0
- package/dist/types/{stencil-public-runtime.d.ts~ds312_tagInputMaxTags → stencil-public-runtime.d.ts} +190 -182
- package/package.json +1 -1
- package/dist/ripple/css-shim-bbdf0cc6.js +0 -4
- package/dist/ripple/dom-1f98a75f.js +0 -73
- package/dist/ripple/index-20b65f86.js +0 -2938
- package/dist/ripple/shadow-css-67b66845.js +0 -389
- package/dist/ripple/wm-menuitem.entry.js +0 -114
- package/dist/ripple/wm-option.entry.js +0 -119
- package/dist/ripple/wm-tab-item.entry.js +0 -78
- package/dist/ripple/wm-tab-panel.entry.js +0 -38
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var html = document.querySelector("html");
|
|
2
|
+
|
|
3
|
+
function toggleDirection() {
|
|
4
|
+
var dir = html.getAttribute("dir");
|
|
5
|
+
dir = dir == "ltr" ? "rtl" : "ltr";
|
|
6
|
+
html.setAttribute("dir", dir);
|
|
7
|
+
|
|
8
|
+
document.querySelector("#dirtogglebtn").innerHTML = "Text direction: " + dir;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function togglePlanningCSS() {
|
|
12
|
+
var sheets = Array.from(document.styleSheets);
|
|
13
|
+
var planning = sheets.filter(function (s) {
|
|
14
|
+
return s.title == "planning";
|
|
15
|
+
})[0];
|
|
16
|
+
planning.disabled = !planning.disabled;
|
|
17
|
+
|
|
18
|
+
var status = planning.disabled ? "off" : "on";
|
|
19
|
+
document.querySelector("#stylestogglebtn").innerHTML = "Planning styles: " + status;
|
|
20
|
+
}
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import * as lang from "../lang/lang";
|
|
2
|
+
import { createIntl, createIntlCache } from "@formatjs/intl";
|
|
3
|
+
const DEFAULT_LANGUAGE = "en";
|
|
4
|
+
function getBrowserLang() {
|
|
5
|
+
const langAttr = document.documentElement.getAttribute("lang");
|
|
6
|
+
if (!!langAttr) {
|
|
7
|
+
return langAttr;
|
|
8
|
+
}
|
|
9
|
+
else if (window.navigator && window.navigator.language) {
|
|
10
|
+
const lang = window.navigator.languages ? window.navigator.languages[0] : window.navigator.language;
|
|
11
|
+
return lang.slice(0, 2);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return DEFAULT_LANGUAGE;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// prevents memory leak
|
|
18
|
+
const cache = createIntlCache();
|
|
19
|
+
const locale = getBrowserLang();
|
|
20
|
+
export const intl = createIntl({
|
|
21
|
+
locale: locale,
|
|
22
|
+
defaultLocale: "en",
|
|
23
|
+
messages: lang[locale] || lang.en,
|
|
24
|
+
}, cache);
|
|
25
|
+
export function generateId() {
|
|
26
|
+
return "wmcl-" + Math.random().toString(36).substr(2, 10);
|
|
27
|
+
}
|
|
28
|
+
export function debounce(fn, wait) {
|
|
29
|
+
let timeout;
|
|
30
|
+
return function () {
|
|
31
|
+
const context = this;
|
|
32
|
+
const functionCall = () => fn.apply(context, arguments);
|
|
33
|
+
clearTimeout(timeout);
|
|
34
|
+
timeout = setTimeout(functionCall, wait);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function getTextDir() {
|
|
38
|
+
const dir = document.querySelector("html").getAttribute("dir");
|
|
39
|
+
return dir ? dir.toLowerCase() : "";
|
|
40
|
+
}
|
|
41
|
+
export function getPosition(el) {
|
|
42
|
+
const coords = el.getBoundingClientRect();
|
|
43
|
+
let x = coords.x;
|
|
44
|
+
let y = coords.y;
|
|
45
|
+
// Edge doesn't have x and y
|
|
46
|
+
if (!x) {
|
|
47
|
+
if (getTextDir() === "rtl") {
|
|
48
|
+
x = coords.right;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
x = coords.left;
|
|
52
|
+
}
|
|
53
|
+
y = coords.top;
|
|
54
|
+
}
|
|
55
|
+
return { x, y };
|
|
56
|
+
}
|
|
57
|
+
export function findParentWithScrollbar(el) {
|
|
58
|
+
while (!!el) {
|
|
59
|
+
if (el.scrollHeight > el.clientHeight && ["scroll", "auto"].includes(window.getComputedStyle(el).overflowY)) {
|
|
60
|
+
return el;
|
|
61
|
+
}
|
|
62
|
+
el = el.parentElement;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export function findParentWithHiddenOverflow(el) {
|
|
66
|
+
while (!!el) {
|
|
67
|
+
if (window.getComputedStyle(el).overflowY !== "visible") {
|
|
68
|
+
return el;
|
|
69
|
+
}
|
|
70
|
+
el = el.parentElement;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function shouldOpenUp(fixedEl, //the element visible on the page when the component is closed
|
|
74
|
+
closableEl, //the dropdown/popup/etc that becomes visible when the component is open
|
|
75
|
+
offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
|
|
76
|
+
offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
|
|
77
|
+
) {
|
|
78
|
+
const closableElHeight = closableEl.clientHeight;
|
|
79
|
+
const parent = findParentWithHiddenOverflow(fixedEl);
|
|
80
|
+
//if parent is not found, measurements are checked against the viewport
|
|
81
|
+
let spaceAbove = parent
|
|
82
|
+
? fixedEl.getBoundingClientRect().top - parent.getBoundingClientRect().top
|
|
83
|
+
: fixedEl.getBoundingClientRect().top;
|
|
84
|
+
// NB boundingClientRect.bottom is space from top of viewport to bottom of el
|
|
85
|
+
// to get space below the el -> height of viewport minus boundingClientRect.bottom
|
|
86
|
+
let spaceBelow = parent
|
|
87
|
+
? parent.getBoundingClientRect().bottom - fixedEl.getBoundingClientRect().bottom
|
|
88
|
+
: document.documentElement.clientHeight - fixedEl.getBoundingClientRect().bottom;
|
|
89
|
+
spaceAbove += offsetAbove;
|
|
90
|
+
spaceBelow += offsetBelow;
|
|
91
|
+
//we want to open up only if there's not enough space below AND there is enough space above
|
|
92
|
+
const openUp = closableElHeight > spaceBelow && closableElHeight <= spaceAbove;
|
|
93
|
+
return openUp;
|
|
94
|
+
}
|
|
95
|
+
export function shouldOpenDown(fixedEl, //the element visible on the page when the component is closed
|
|
96
|
+
closableEl, //the dropdown/popup/etc that becomes visible when the component is open
|
|
97
|
+
offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
|
|
98
|
+
offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
|
|
99
|
+
) {
|
|
100
|
+
const closableElHeight = closableEl.clientHeight;
|
|
101
|
+
const parent = findParentWithHiddenOverflow(fixedEl);
|
|
102
|
+
//if parent is not found, measurements are checked against the viewport
|
|
103
|
+
let spaceAbove = parent
|
|
104
|
+
? fixedEl.getBoundingClientRect().top - parent.getBoundingClientRect().top
|
|
105
|
+
: fixedEl.getBoundingClientRect().top;
|
|
106
|
+
// NB boundingClientRect.bottom is space from top of viewport to bottom of el
|
|
107
|
+
// to get space below the el -> height of viewport minus boundingClientRect.bottom
|
|
108
|
+
let spaceBelow = parent
|
|
109
|
+
? parent.getBoundingClientRect().bottom - fixedEl.getBoundingClientRect().bottom
|
|
110
|
+
: document.documentElement.clientHeight - fixedEl.getBoundingClientRect().bottom;
|
|
111
|
+
spaceAbove += offsetAbove;
|
|
112
|
+
spaceBelow += offsetBelow;
|
|
113
|
+
//we want to open up only if there's not enough space below AND there is enough space above
|
|
114
|
+
const openDown = closableElHeight > spaceAbove && closableElHeight <= spaceBelow;
|
|
115
|
+
return openDown;
|
|
116
|
+
}
|
|
117
|
+
export function shouldShiftRight(fixedEl, closableEl) {
|
|
118
|
+
const closableElWidth = closableEl.clientWidth;
|
|
119
|
+
const parent = findParentWithHiddenOverflow(fixedEl);
|
|
120
|
+
//if parent is not found, measurements are checked against the viewport
|
|
121
|
+
const spaceLeft = parent
|
|
122
|
+
? fixedEl.getBoundingClientRect().left - parent.getBoundingClientRect().left
|
|
123
|
+
: fixedEl.getBoundingClientRect().left;
|
|
124
|
+
const spaceRight = parent
|
|
125
|
+
? parent.getBoundingClientRect().right - fixedEl.getBoundingClientRect().right
|
|
126
|
+
: fixedEl.getBoundingClientRect().right;
|
|
127
|
+
const needsSpaceLeft = closableElWidth > spaceLeft && spaceRight > spaceLeft;
|
|
128
|
+
return needsSpaceLeft;
|
|
129
|
+
}
|
|
130
|
+
export function shouldShiftLeft(fixedEl, closableEl) {
|
|
131
|
+
const closableElWidth = closableEl.clientWidth;
|
|
132
|
+
const parent = findParentWithHiddenOverflow(fixedEl);
|
|
133
|
+
//if parent is not found, measurements are checked against the viewport
|
|
134
|
+
const spaceLeft = parent
|
|
135
|
+
? fixedEl.getBoundingClientRect().left - parent.getBoundingClientRect().left
|
|
136
|
+
: fixedEl.getBoundingClientRect().left;
|
|
137
|
+
// NB boundingClientRect.right is space from left side of viewport to right of el
|
|
138
|
+
// to get space between right side of el and right side of viewport -> width of viewport minus boundingClientRect.right
|
|
139
|
+
const spaceRight = parent
|
|
140
|
+
? parent.getBoundingClientRect().right - fixedEl.getBoundingClientRect().right
|
|
141
|
+
: document.documentElement.clientWidth - fixedEl.getBoundingClientRect().right;
|
|
142
|
+
const needsSpaceRight = closableElWidth > spaceRight && spaceLeft > spaceRight;
|
|
143
|
+
return needsSpaceRight;
|
|
144
|
+
}
|
|
145
|
+
export function adjustTooltipPosition(tPos, el, tooltipEl) {
|
|
146
|
+
// Use the value passed as prop (or the default) if possible
|
|
147
|
+
// if there's not enough space, flip side
|
|
148
|
+
// Vertical
|
|
149
|
+
if (tPos.includes("bottom") && shouldOpenUp(el, tooltipEl)) {
|
|
150
|
+
tPos = tPos.replace("bottom", "top");
|
|
151
|
+
}
|
|
152
|
+
else if (tPos.includes("top") && shouldOpenDown(el, tooltipEl)) {
|
|
153
|
+
tPos = tPos.replace("top", "bottom");
|
|
154
|
+
}
|
|
155
|
+
// Horizontal
|
|
156
|
+
if (tPos.includes("left") && shouldShiftRight(el, tooltipEl)) {
|
|
157
|
+
tPos = tPos.replace("left", "right");
|
|
158
|
+
}
|
|
159
|
+
else if (tPos.includes("right") && shouldShiftLeft(el, tooltipEl)) {
|
|
160
|
+
tPos = tPos.replace("right", "left");
|
|
161
|
+
}
|
|
162
|
+
return tPos;
|
|
163
|
+
}
|
|
164
|
+
export function hasRoomRight(x, spaceNeeded) {
|
|
165
|
+
let horizOffset = 0;
|
|
166
|
+
// if (getTextDir() === "ltr") {
|
|
167
|
+
if (x.type === "click") {
|
|
168
|
+
// if it's a mouse event, deal with mouse coords
|
|
169
|
+
horizOffset = x.clientX;
|
|
170
|
+
// if it's a focus event, the offset is 0
|
|
171
|
+
}
|
|
172
|
+
else if (x.type === "focus") {
|
|
173
|
+
horizOffset = 0;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// otherwise an element was passed, calculate how far it is from the edge of the window
|
|
177
|
+
let el = x; // re-assignment is for clarity
|
|
178
|
+
while (el) {
|
|
179
|
+
if (el.tagName == "BODY") {
|
|
180
|
+
// deal with browser quirks with body/window/document and page scroll
|
|
181
|
+
var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
|
|
182
|
+
horizOffset += el.offsetLeft - xScroll + el.clientLeft;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
// for all other non-BODY elements
|
|
186
|
+
horizOffset += el.offsetLeft - el.scrollLeft + el.clientLeft;
|
|
187
|
+
}
|
|
188
|
+
el = el.offsetParent;
|
|
189
|
+
}
|
|
190
|
+
// }
|
|
191
|
+
}
|
|
192
|
+
return window.innerWidth - horizOffset >= spaceNeeded;
|
|
193
|
+
}
|
|
194
|
+
export function checkForActiveElInShadow(element) {
|
|
195
|
+
while (element && element.shadowRoot) {
|
|
196
|
+
element = element.shadowRoot.activeElement;
|
|
197
|
+
}
|
|
198
|
+
return element;
|
|
199
|
+
}
|
|
200
|
+
export function checkForFocusableElInShadow(element) {
|
|
201
|
+
const selectors = [
|
|
202
|
+
"button",
|
|
203
|
+
"a",
|
|
204
|
+
"input",
|
|
205
|
+
"select",
|
|
206
|
+
"textarea",
|
|
207
|
+
"wm-button",
|
|
208
|
+
"wm-search",
|
|
209
|
+
"wm-select",
|
|
210
|
+
"wm-action-menu",
|
|
211
|
+
"wm-tab-item",
|
|
212
|
+
"wm-datepicker",
|
|
213
|
+
];
|
|
214
|
+
let focusableEl = element;
|
|
215
|
+
selectors.forEach((selector) => {
|
|
216
|
+
if (focusableEl && focusableEl.shadowRoot) {
|
|
217
|
+
let elInShadow = focusableEl.shadowRoot.querySelector(selector);
|
|
218
|
+
if (elInShadow) {
|
|
219
|
+
if (selector.startsWith("wm-")) {
|
|
220
|
+
focusableEl = checkForFocusableElInShadow(elInShadow);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
focusableEl = elInShadow;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
return focusableEl;
|
|
229
|
+
}
|
|
230
|
+
export function isFocusable(element) {
|
|
231
|
+
if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute("tabIndex") !== null)) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
if (element.disabled) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
switch (element.nodeName) {
|
|
238
|
+
case "A":
|
|
239
|
+
return !!element.href && element.rel != "ignore";
|
|
240
|
+
case "INPUT":
|
|
241
|
+
return element.type != "hidden" && element.type != "file";
|
|
242
|
+
case "BUTTON":
|
|
243
|
+
case "SELECT":
|
|
244
|
+
case "TEXTAREA":
|
|
245
|
+
case "WM-BUTTON":
|
|
246
|
+
case "WM-SELECT":
|
|
247
|
+
case "WM-ACTION-MENU":
|
|
248
|
+
case "WM-DATEPICKER":
|
|
249
|
+
case "WM-TIMEPICKER":
|
|
250
|
+
case "WM-INPUT":
|
|
251
|
+
case "WM-TAG-INPUT":
|
|
252
|
+
case "WM-TAB-ITEM":
|
|
253
|
+
case "WM-SEARCH":
|
|
254
|
+
return true;
|
|
255
|
+
default:
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
export function getFirstFocusableDescendant(element) {
|
|
260
|
+
if (isFocusable(element)) {
|
|
261
|
+
return checkForFocusableElInShadow(element);
|
|
262
|
+
}
|
|
263
|
+
else if (element.childNodes.length > 0) {
|
|
264
|
+
element.childNodes.forEach((i) => {
|
|
265
|
+
const childEl = getFirstFocusableDescendant(i);
|
|
266
|
+
return childEl && checkForFocusableElInShadow(childEl);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
export function hasValidType(file, types) {
|
|
271
|
+
const acceptedExtensions = types.split(" ");
|
|
272
|
+
const parts = file.name && file.name.split(".");
|
|
273
|
+
const ext = parts && parts.length > 1 && parts[parts.length - 1];
|
|
274
|
+
return ext
|
|
275
|
+
? acceptedExtensions.includes(ext.toLowerCase())
|
|
276
|
+
: // fallback: if we couldn't obtain an extension,
|
|
277
|
+
// validate based on MIME type...
|
|
278
|
+
!!file.type
|
|
279
|
+
? getAcceptedMimeTypesList(acceptedExtensions).includes(file.type)
|
|
280
|
+
: // ...and if that failed too, accept the file
|
|
281
|
+
// as it's preferable to accept an invalid file
|
|
282
|
+
// than refusing a valid one (back-end will take care of what slips through)
|
|
283
|
+
true;
|
|
284
|
+
}
|
|
285
|
+
// takes a string (space separated list of extensions), returns an array of strings (corresponding MIME types)
|
|
286
|
+
export function getAcceptedMimeTypesList(acceptedExtensions) {
|
|
287
|
+
// this is just a list of common file types (regardless of whether they are/can be valid or not)
|
|
288
|
+
// front end checks are just a convenience to users, independent of security.
|
|
289
|
+
// it allows users to be notified of an invalid type as soon as they select the file, rather than when it gets uploaded
|
|
290
|
+
const lookupTable = {
|
|
291
|
+
aac: ["audio/aac"],
|
|
292
|
+
abw: ["application/x-abiword"],
|
|
293
|
+
arc: ["application/x-freearc"],
|
|
294
|
+
avi: ["video/x-msvideo"],
|
|
295
|
+
azw: ["application/vnd.amazon.ebook"],
|
|
296
|
+
bin: ["application/octet-stream"],
|
|
297
|
+
bmp: ["image/bmp"],
|
|
298
|
+
bz: ["application/x-bzip"],
|
|
299
|
+
bz2: ["application/x-bzip2"],
|
|
300
|
+
csh: ["application/x-csh"],
|
|
301
|
+
css: ["text/css"],
|
|
302
|
+
csv: ["text/csv"],
|
|
303
|
+
doc: ["application/msword"],
|
|
304
|
+
docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
305
|
+
eot: ["application/vnd.ms-fontobject"],
|
|
306
|
+
epub: ["application/epub+zip"],
|
|
307
|
+
gz: ["application/gzip"],
|
|
308
|
+
gif: ["image/gif"],
|
|
309
|
+
htm: ["text/html"],
|
|
310
|
+
html: ["text/html"],
|
|
311
|
+
ico: ["image/vnd.microsoft.icon"],
|
|
312
|
+
ics: ["text/calendar"],
|
|
313
|
+
jar: ["application/java-archive"],
|
|
314
|
+
jpeg: ["image/jpeg"],
|
|
315
|
+
jpg: ["image/jpeg"],
|
|
316
|
+
js: ["text/javascript"],
|
|
317
|
+
json: ["application/json"],
|
|
318
|
+
jsonld: ["application/ld+json"],
|
|
319
|
+
log: ["text/plain"],
|
|
320
|
+
mid: ["audio/x-midi"],
|
|
321
|
+
midi: ["audio/x-midi"],
|
|
322
|
+
mjs: ["text/javascript"],
|
|
323
|
+
mp3: ["audio/mpeg"],
|
|
324
|
+
mpeg: ["video/mpeg"],
|
|
325
|
+
mpkg: ["application/vnd.apple.installer+xml"],
|
|
326
|
+
odp: ["application/vnd.oasis.opendocument.presentation"],
|
|
327
|
+
ods: ["application/vnd.oasis.opendocument.spreadsheet"],
|
|
328
|
+
odt: ["application/vnd.oasis.opendocument.text"],
|
|
329
|
+
oga: ["audio/ogg"],
|
|
330
|
+
ogv: ["video/ogg"],
|
|
331
|
+
ogx: ["application/ogg"],
|
|
332
|
+
opus: ["audio/opus"],
|
|
333
|
+
otf: ["font/otf"],
|
|
334
|
+
png: ["image/png"],
|
|
335
|
+
pdf: ["application/pdf"],
|
|
336
|
+
php: ["application/php"],
|
|
337
|
+
ppt: ["application/vnd.ms-powerpoint"],
|
|
338
|
+
pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
|
|
339
|
+
rar: ["application/vnd.rar", "application/x-rar", "application/x-rar-compressed"],
|
|
340
|
+
rtf: ["application/rtf"],
|
|
341
|
+
sh: ["application/x-sh"],
|
|
342
|
+
svg: ["image/svg+xml"],
|
|
343
|
+
swf: ["application/x-shockwave-flash"],
|
|
344
|
+
tar: ["application/x-tar"],
|
|
345
|
+
tif: ["image/tiff"],
|
|
346
|
+
tiff: ["image/tiff"],
|
|
347
|
+
ts: ["video/mp2t"],
|
|
348
|
+
ttf: ["font/ttf"],
|
|
349
|
+
txt: ["text/plain"],
|
|
350
|
+
vsd: ["application/vnd.visio"],
|
|
351
|
+
wav: ["audio/wav"],
|
|
352
|
+
weba: ["audio/webm"],
|
|
353
|
+
webm: ["video/webm"],
|
|
354
|
+
webp: ["image/webp"],
|
|
355
|
+
woff: ["font/woff"],
|
|
356
|
+
woff2: ["font/woff2"],
|
|
357
|
+
xhtml: ["application/xhtml+xml"],
|
|
358
|
+
xls: ["application/vnd.ms-excel"],
|
|
359
|
+
xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
360
|
+
xml: ["application/xml", "text/xml"],
|
|
361
|
+
xul: ["application/vnd.mozilla.xul+xml"],
|
|
362
|
+
zip: ["application/zip", "application/x-zip-compressed", "multipart/x-zip"],
|
|
363
|
+
"3gp": ["video/3gpp", "audio/3gpp"],
|
|
364
|
+
"3g2": ["video/3gpp2", "audio/3gpp2"],
|
|
365
|
+
"7z": ["application/x-7z-compressed"],
|
|
366
|
+
};
|
|
367
|
+
return acceptedExtensions.reduce((acc, ext) => acc.concat(lookupTable[ext]), []);
|
|
368
|
+
}
|
|
369
|
+
export function snakeCaseToCamelCase(str) {
|
|
370
|
+
const snakeCaseRegexp = /^([a-z0-9]*)(_[a-z0-9]*)*$/g;
|
|
371
|
+
if (snakeCaseRegexp.test(str)) {
|
|
372
|
+
let camelCase = "";
|
|
373
|
+
let arr = str.split("_");
|
|
374
|
+
arr.forEach((word, idx) => {
|
|
375
|
+
camelCase += idx === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1);
|
|
376
|
+
});
|
|
377
|
+
return camelCase;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
return str;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
export function getNewIndexToFocus(currentIndex, direction, listLength) {
|
|
384
|
+
let newIndex = currentIndex;
|
|
385
|
+
if (direction === "ArrowDown") {
|
|
386
|
+
newIndex = (currentIndex + 1) % listLength;
|
|
387
|
+
}
|
|
388
|
+
if (direction === "ArrowUp") {
|
|
389
|
+
newIndex = currentIndex === 0 ? listLength - 1 : currentIndex - 1;
|
|
390
|
+
}
|
|
391
|
+
return newIndex;
|
|
392
|
+
}
|
|
393
|
+
export function isRelatedTarget(ev, id) {
|
|
394
|
+
// used for onBlur events to check the element that has been clicked
|
|
395
|
+
const ids = id.split(" ");
|
|
396
|
+
return ev.relatedTarget && ids.includes(ev.relatedTarget.id);
|
|
397
|
+
}
|
|
398
|
+
/*
|
|
399
|
+
* this is going to be needed to solve the extra tabbing on navigator
|
|
400
|
+
* and for programmatic focus of tabs
|
|
401
|
+
* Here's a draft, not bug proof, see:
|
|
402
|
+
* https://stackoverflow.com/a/10730308/3741713
|
|
403
|
+
|
|
404
|
+
function getKeyboardFocusableElements(element = document) {
|
|
405
|
+
const els = Array.from(element.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), wm-search, wm-timepicker, wm-tab-list, wm-tab-item, wm-button, wm-action-menu'));
|
|
406
|
+
return els.filter((el: Element) => !el.hasAttribute("disabled")) as HTMLElement[];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export function getPreviousKeyboardFocusableElement(element: HTMLElement) {
|
|
410
|
+
const els = getKeyboardFocusableElements();
|
|
411
|
+
const current = els.indexOf(element);
|
|
412
|
+
return els[current - 1] as HTMLElement;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export function getNextKeyboardFocusableElement(element: HTMLElement) {
|
|
416
|
+
const els = getKeyboardFocusableElements();
|
|
417
|
+
const current = els.indexOf(element);
|
|
418
|
+
return els[current + 1] as HTMLElement;
|
|
419
|
+
}
|
|
420
|
+
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { setMode } from "@stencil/core";
|
|
2
|
+
import { version } from "../../package.json";
|
|
3
3
|
if (window.navigator.plugins.length > 0) {
|
|
4
4
|
// excluding test envs (which will return 0 for plugin.length)
|
|
5
|
-
console.log("Ripple component library version
|
|
5
|
+
console.log("Ripple component library", version);
|
|
6
6
|
}
|
|
7
7
|
// Dispatching events to track whether user is navigating with keyboard or mouse
|
|
8
8
|
// (for focus states)
|
|
@@ -38,8 +38,3 @@ function wmComponentMouseDownOnce() {
|
|
|
38
38
|
setMode((elm) => {
|
|
39
39
|
return elm.getAttribute("mode") || document.documentElement.getAttribute("mode") || "planning";
|
|
40
40
|
});
|
|
41
|
-
const globalFn = () => { };
|
|
42
|
-
|
|
43
|
-
const globalScripts = globalFn;
|
|
44
|
-
|
|
45
|
-
export { globalScripts as g };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//List of icon codes with more indicative descriptors to create labels for icon-only buttons
|
|
2
|
-
const iconLabels = {
|
|
2
|
+
export const iconLabels = {
|
|
3
3
|
f156: "Close",
|
|
4
4
|
f3eb: "Edit",
|
|
5
5
|
f739: "Cancel",
|
|
@@ -18,7 +18,7 @@ const iconLabels = {
|
|
|
18
18
|
f645: "Sort hierarchically",
|
|
19
19
|
f4bb: "Sort alphabetically",
|
|
20
20
|
};
|
|
21
|
-
function getIconCodeFromName(icon) {
|
|
21
|
+
export function getIconCodeFromName(icon) {
|
|
22
22
|
return iconCodes[icon] || icon;
|
|
23
23
|
}
|
|
24
24
|
const iconCodes = {
|
|
@@ -43,9 +43,7 @@ const iconCodes = {
|
|
|
43
43
|
"account-settings": "f630",
|
|
44
44
|
"backup-restore": "f06f",
|
|
45
45
|
};
|
|
46
|
-
const defaultMode = "planning";
|
|
47
|
-
const getWmMode = (ref) => {
|
|
46
|
+
export const defaultMode = "planning";
|
|
47
|
+
export const getWmMode = (ref) => {
|
|
48
48
|
return ref.getAttribute("mode") || document.documentElement.getAttribute("mode") || defaultMode;
|
|
49
49
|
};
|
|
50
|
-
|
|
51
|
-
export { getWmMode as a, getIconCodeFromName as g };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const state = [
|
|
2
|
+
{
|
|
3
|
+
uuid: "d57a8104-a07e-4e58-97f6-705d55b15845",
|
|
4
|
+
uploader_member_uuid: "fd947ce1-ca75-4b88-ba47-4576104cf845",
|
|
5
|
+
updated_at: "2018-04-16T10:31:48.740000Z",
|
|
6
|
+
organization_uuid: "d57a8104-a07e-4e58-97f6-705d55b15845",
|
|
7
|
+
mime_type: "application/pdf",
|
|
8
|
+
institution_uuid: "c1dac227-b71c-44ae-a4be-eb20929c6e99",
|
|
9
|
+
inserted_at: "2018-09-17T09:33:45.550000Z",
|
|
10
|
+
file_path: "bogusurl.dev",
|
|
11
|
+
file_name: "test.pdf",
|
|
12
|
+
course_uuid: null,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
uuid: "410ee9ed-af53-4f52-90b1-bf3f054ad86b",
|
|
16
|
+
uploader_member_uuid: "fd947ce1-ca75-4b88-ba47-4576104cf845",
|
|
17
|
+
updated_at: "2019-11-26T20:39:38.990000Z",
|
|
18
|
+
organization_uuid: "8d242cdf-4261-4003-9a91-45575eb7d44e",
|
|
19
|
+
mime_type: "application/pdf",
|
|
20
|
+
institution_uuid: "c1dac227-b71c-44ae-a4be-eb20929c6e99",
|
|
21
|
+
inserted_at: "2019-11-26T20:39:38.990000Z",
|
|
22
|
+
file_path: "anotherbogusurl.dev",
|
|
23
|
+
file_name: "brochure.pdf",
|
|
24
|
+
course_uuid: null,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
const firstUploadResponseText = {
|
|
28
|
+
url: "aws-path.url",
|
|
29
|
+
updated_at: "2019-07-03T14:11:08.000Z",
|
|
30
|
+
path: "",
|
|
31
|
+
guid: "12345",
|
|
32
|
+
};
|
|
33
|
+
const secondUploadResponseText = {
|
|
34
|
+
url: "aws-path.url",
|
|
35
|
+
updated_at: "2019-07-02T10:14:29.000Z",
|
|
36
|
+
path: "",
|
|
37
|
+
guid: "67890",
|
|
38
|
+
};
|
|
39
|
+
const navigatorResponse = {
|
|
40
|
+
connection_name: "watermarkinsights-idp-qa",
|
|
41
|
+
current_product_id: "dm",
|
|
42
|
+
email: "user@email.net",
|
|
43
|
+
logout_url: "localhost:3333/logout",
|
|
44
|
+
products: [
|
|
45
|
+
{
|
|
46
|
+
description: "Some Aqua description",
|
|
47
|
+
iconUrl: "https://cdn.watermarkinsights.com/images/login/aqua.svg",
|
|
48
|
+
id: "aqua",
|
|
49
|
+
linkUrl: "https://aqua.taskstream.com/sso/login",
|
|
50
|
+
name: "Aqua",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
description: "Some Digital Measures description",
|
|
54
|
+
iconUrl: "https://cdn.watermarkinsights.com/images/login/digitalmeasures.svg",
|
|
55
|
+
id: "dm",
|
|
56
|
+
linkUrl: "https://www.digitalmeasures.com/login/sso/authenticate",
|
|
57
|
+
name: "Digital Measures",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
description: "Some Planning description",
|
|
61
|
+
iconUrl: "https://cdn.watermarkinsights.com/images/login/planningselfstudy.svg",
|
|
62
|
+
id: "planning",
|
|
63
|
+
linkUrl: "https://planning.watermarkinsights.com/login/sso",
|
|
64
|
+
name: "Planning",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
description: "Checking that the component handles anything throwed at it",
|
|
68
|
+
iconUrl: "https://cdn.watermarkinsights.com/images/login/livetext.svg",
|
|
69
|
+
id: "something_bonkers",
|
|
70
|
+
linkUrl: "https://planning.watermarkinsights.com/login/sso",
|
|
71
|
+
name: "Bonkers",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
description: "c1 = livetext",
|
|
75
|
+
iconUrl: "https://cdn.watermarkinsights.com/images/login/livetext.svg",
|
|
76
|
+
id: "c1",
|
|
77
|
+
linkUrl: "https://livetext.fakeurl/login/sso",
|
|
78
|
+
name: "Livetext",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
description: "something with an id containing admin",
|
|
82
|
+
iconUrl: "not.important",
|
|
83
|
+
id: "banana_admin_shoe",
|
|
84
|
+
linkUrl: "irrelevant",
|
|
85
|
+
name: "Platform Admin",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
const responses = {
|
|
90
|
+
"get-path.url": state,
|
|
91
|
+
"request-upload-path.url0": firstUploadResponseText,
|
|
92
|
+
"request-upload-path.url1": secondUploadResponseText,
|
|
93
|
+
"/platform/navigator/userinfo": navigatorResponse,
|
|
94
|
+
};
|
|
95
|
+
export const getRequest = async (url) => {
|
|
96
|
+
return Promise.resolve(responses[url]);
|
|
97
|
+
};
|
|
98
|
+
export const postRequest = async (url, payload) => {
|
|
99
|
+
switch (url) {
|
|
100
|
+
case "upload-path.url":
|
|
101
|
+
state.push({
|
|
102
|
+
uuid: payload.document_uuid,
|
|
103
|
+
uploader_member_uuid: "fd947ce1-ca75-4b88-ba47-4576104cf845",
|
|
104
|
+
updated_at: "2019-12-10T20:48:10.138Z",
|
|
105
|
+
organization_uuid: payload.organization_uuid,
|
|
106
|
+
mime_type: payload.mime_type,
|
|
107
|
+
institution_uuid: "c1dac227-b71c-44ae-a4be-eb20929c6e99",
|
|
108
|
+
inserted_at: "2019-12-10T20:48:10.138Z",
|
|
109
|
+
file_path: payload.file_path,
|
|
110
|
+
file_name: payload.file_name,
|
|
111
|
+
course_uuid: null,
|
|
112
|
+
});
|
|
113
|
+
return Promise.resolve();
|
|
114
|
+
case "request-download-path.url":
|
|
115
|
+
return Promise.resolve({ url: "aws-download-path.url" });
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export const deleteRequest = async (url) => {
|
|
119
|
+
const uuid = url.split("/").pop();
|
|
120
|
+
// console.log("uuid: ", uuid);
|
|
121
|
+
const index = state.findIndex((i) => i.uuid === uuid);
|
|
122
|
+
// console.log("index: ", index);
|
|
123
|
+
state.splice(index, 1);
|
|
124
|
+
// console.log("state from DELETE: ", state, Date.now());
|
|
125
|
+
// return new Promise(resolve => setTimeout(() => resolve(), 300));
|
|
126
|
+
return Promise.resolve();
|
|
127
|
+
};
|
|
128
|
+
export const putRequest = (_url, _file) => {
|
|
129
|
+
return Promise.resolve();
|
|
130
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const getRequest = async (url) => {
|
|
2
|
+
const response = await fetch(url);
|
|
3
|
+
if (!!response && !!response.ok) {
|
|
4
|
+
return await response.json();
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
throw new Error(response.statusText);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export const postRequest = async (url, payload) => {
|
|
11
|
+
const response = await fetch(url, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: { "Content-Type": "application/json; charset=utf-8" },
|
|
14
|
+
body: JSON.stringify(payload),
|
|
15
|
+
});
|
|
16
|
+
if (!!response && !!response.ok) {
|
|
17
|
+
return await response.json();
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw new Error(response.statusText);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export const deleteRequest = async (url) => {
|
|
24
|
+
const response = await fetch(url, { method: "DELETE" });
|
|
25
|
+
if (!!response && !!response.ok) {
|
|
26
|
+
return await response.json();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error(response.statusText);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const putRequest = (url, file, onProgress) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
// there's no way to track progress with the fetch API, so using XHR
|
|
35
|
+
const req = new XMLHttpRequest();
|
|
36
|
+
req.upload.addEventListener("progress", (ev) => onProgress(ev));
|
|
37
|
+
req.addEventListener("readystatechange", function () {
|
|
38
|
+
if (this.readyState === 4 && this.status === 200) {
|
|
39
|
+
resolve(this);
|
|
40
|
+
}
|
|
41
|
+
else if (this.readyState === 4 && this.status !== 200) {
|
|
42
|
+
reject();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
req.onerror = () => reject();
|
|
46
|
+
req.open("PUT", url, true);
|
|
47
|
+
req.setRequestHeader("Content-Disposition", `attachment;filename="${file.name}"`);
|
|
48
|
+
req.send(file);
|
|
49
|
+
});
|
|
50
|
+
};
|