dry-ux 1.40.0 → 1.42.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.
|
@@ -7,8 +7,9 @@ export declare const preventDefault: (handler?: (event: any) => void) => (event:
|
|
|
7
7
|
* Imports a script and returns a promise that resolves when the script is loaded.
|
|
8
8
|
* @param resourceUrl The url of the script to load.
|
|
9
9
|
* @param singleton If true, the script will only be loaded once.
|
|
10
|
+
* @param placement "body" or "head" to specify where the script should be placed.
|
|
10
11
|
*/
|
|
11
|
-
export declare const importScript: (resourceUrl: string, singleton?: boolean) => Promise<void>;
|
|
12
|
+
export declare const importScript: (resourceUrl: string, singleton?: boolean, placement?: "body" | "head") => Promise<void>;
|
|
12
13
|
/**
|
|
13
14
|
* Imports a stylesheet and adds it to the head.
|
|
14
15
|
* @param resourceUrl The url of the stylesheet to load.
|
|
@@ -15,15 +15,21 @@ exports.preventDefault = preventDefault;
|
|
|
15
15
|
* Imports a script and returns a promise that resolves when the script is loaded.
|
|
16
16
|
* @param resourceUrl The url of the script to load.
|
|
17
17
|
* @param singleton If true, the script will only be loaded once.
|
|
18
|
+
* @param placement "body" or "head" to specify where the script should be placed.
|
|
18
19
|
*/
|
|
19
|
-
const importScript = (resourceUrl, singleton = true) => new Promise(resolve => {
|
|
20
|
+
const importScript = (resourceUrl, singleton = true, placement = "body") => new Promise(resolve => {
|
|
20
21
|
React.useEffect(() => {
|
|
21
22
|
const script = document.createElement("script");
|
|
22
23
|
if (!$(`script[src='${resourceUrl}']`).length) {
|
|
23
24
|
script.src = resourceUrl;
|
|
24
25
|
script.async = true;
|
|
25
26
|
script.onload = () => resolve();
|
|
26
|
-
|
|
27
|
+
if (placement === "head") {
|
|
28
|
+
document.head.appendChild(script);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
document.body.appendChild(script);
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
34
|
else {
|
|
29
35
|
resolve();
|
|
@@ -16,7 +16,7 @@ export declare class UIUtilProvider extends React.PureComponent<{}, IUIUtilProvi
|
|
|
16
16
|
create: any;
|
|
17
17
|
show: (options: ModalOptions) => IModalCreate;
|
|
18
18
|
getCurrent: () => IModalCreate;
|
|
19
|
-
showAlert: (content: ModalOptions["content"]) => IModalCreate;
|
|
19
|
+
showAlert: (content: ModalOptions["content"], onClose?: ModalOptions["onClose"]) => IModalCreate;
|
|
20
20
|
showConfirm: (options: ModalOptions, onYes: () => void, onNo?: () => void) => IModalCreate;
|
|
21
21
|
showActions: (options: ModalOptions, actions: IUtilModalAction[]) => IModalCreate;
|
|
22
22
|
instances: {
|
|
@@ -43,11 +43,12 @@ class UIUtilProvider extends React.PureComponent {
|
|
|
43
43
|
const { modal: { instances }, } = this.state;
|
|
44
44
|
const id = Object.keys(instances).find(id => instances[id].shown);
|
|
45
45
|
return this.getCurrentModal(id);
|
|
46
|
-
}, showAlert: (content) => this.createModal(null, {
|
|
46
|
+
}, showAlert: (content, onClose) => this.createModal(null, {
|
|
47
47
|
content: typeof content == "string" ? React.createElement("h4", { className: "text-center mtop" }, content) : content,
|
|
48
48
|
destroyOnClose: true,
|
|
49
49
|
closeBtn: true,
|
|
50
50
|
width: 400,
|
|
51
|
+
onClose,
|
|
51
52
|
}), showConfirm: (options, onYes, onNo) => this.createModal("confirm", Object.assign(Object.assign({}, options), { footerContent: (React.createElement(React.Fragment, null,
|
|
52
53
|
options.footerContent,
|
|
53
54
|
React.createElement(react_bootstrap_1.Button, { bsClass: "btn btn-success mright", onClick: onYes }, "Yes"),
|
|
@@ -101,7 +101,7 @@ export interface IUIUtilModal {
|
|
|
101
101
|
* Shows an alert style modal.
|
|
102
102
|
* @param content The content to display in the modal.
|
|
103
103
|
*/
|
|
104
|
-
showAlert: (content: ModalOptions["content"]) => IModalCreate;
|
|
104
|
+
showAlert: (content: ModalOptions["content"], onClose?: ModalOptions["onClose"]) => IModalCreate;
|
|
105
105
|
/**
|
|
106
106
|
* Shows a confirm style modal.
|
|
107
107
|
* @param options The options for the modal.
|