@grucloud/bau-ui 0.60.1 → 0.61.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/modal/index.d.ts +3 -1
- package/modal/modal.js +25 -2
- package/package.json +4 -4
package/modal/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ declare module "@grucloud/bau-ui/modal" {
|
|
|
2
2
|
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
3
|
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
4
|
|
|
5
|
-
export type ModalProps = {
|
|
5
|
+
export type ModalProps = {
|
|
6
|
+
id: string;
|
|
7
|
+
} & DefaultDesignProps;
|
|
6
8
|
|
|
7
9
|
type Component = import("../bau-ui").Component<ModalProps, HTMLDialogElement>;
|
|
8
10
|
|
package/modal/modal.js
CHANGED
|
@@ -3,7 +3,7 @@ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
|
3
3
|
import { Colors } from "../constants.js";
|
|
4
4
|
|
|
5
5
|
export default function (context, options = {}) {
|
|
6
|
-
const { bau, css } = context;
|
|
6
|
+
const { bau, css, window } = context;
|
|
7
7
|
const { dialog, div } = bau.tags;
|
|
8
8
|
|
|
9
9
|
const colorsToCss = () =>
|
|
@@ -78,8 +78,16 @@ export default function (context, options = {}) {
|
|
|
78
78
|
...children
|
|
79
79
|
] = toPropsAndChildren(args);
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
const dialogEl = dialog(
|
|
82
82
|
{
|
|
83
|
+
...props,
|
|
84
|
+
bauMounted: () => {
|
|
85
|
+
const search = new URLSearchParams(window.location.search);
|
|
86
|
+
const modalId = search.get("modal");
|
|
87
|
+
if (modalId == (props.id ?? "modal")) {
|
|
88
|
+
dialogEl.showModal();
|
|
89
|
+
}
|
|
90
|
+
},
|
|
83
91
|
class: classNames(
|
|
84
92
|
"modal",
|
|
85
93
|
className,
|
|
@@ -92,5 +100,20 @@ export default function (context, options = {}) {
|
|
|
92
100
|
},
|
|
93
101
|
div(children)
|
|
94
102
|
);
|
|
103
|
+
|
|
104
|
+
const observer = new MutationObserver((events) => {
|
|
105
|
+
const search = new URLSearchParams(window.location.search);
|
|
106
|
+
if (events[0].attributeName == "open") {
|
|
107
|
+
if (dialogEl.open) {
|
|
108
|
+
search.set("modal", dialogEl.id ?? "modal");
|
|
109
|
+
} else {
|
|
110
|
+
search.delete("modal");
|
|
111
|
+
}
|
|
112
|
+
window.history.pushState("", "", `?${search.toString()}`);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
observer.observe(dialogEl, { attributes: true });
|
|
116
|
+
|
|
117
|
+
return dialogEl;
|
|
95
118
|
};
|
|
96
119
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grucloud/bau-ui",
|
|
3
3
|
"description": "Components library built with Bau",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.61.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BSD",
|
|
7
7
|
"keywords": [
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"directory": "bau-ui"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@grucloud/bau": "^0.
|
|
24
|
-
"@grucloud/bau-css": "^0.
|
|
23
|
+
"@grucloud/bau": "^0.61.0",
|
|
24
|
+
"@grucloud/bau-css": "^0.61.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typedoc": "0.24.8"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "0cf66900b8223139cfa88414fe562887aefe0e0f"
|
|
30
30
|
}
|