@grucloud/bau-ui 0.60.1 → 0.61.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/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 = {} & DefaultDesignProps;
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 = () =>
@@ -30,26 +30,30 @@ export default function (context, options = {}) {
30
30
  border-radius: var(--global-radius);
31
31
  min-width: 400px;
32
32
  border: 0px;
33
- > div {
33
+ overflow: hidden;
34
+ > form {
34
35
  display: flex;
35
36
  flex-direction: column;
36
37
  overflow: hidden;
38
+ height: 100%;
37
39
  max-height: 96vh;
38
40
  max-width: 96vw;
39
41
  & > header {
40
42
  display: flex;
41
- flex-direction: column;
43
+ flex-direction: row;
44
+ align-items: center;
42
45
  justify-content: flex-start;
46
+ gap: 1rem;
43
47
  }
44
48
  & > main,
45
- > section {
46
- flex-grow: 1;
49
+ > section,
50
+ > article {
47
51
  overflow-y: auto;
52
+ flex-grow: 1;
48
53
  }
49
54
  & > footer {
50
55
  display: flex;
51
56
  justify-content: flex-end;
52
- padding: 1rem;
53
57
  gap: 1rem;
54
58
  }
55
59
  }
@@ -63,7 +67,6 @@ export default function (context, options = {}) {
63
67
  height: 96vh;
64
68
  width: 96vw;
65
69
  }
66
-
67
70
  ${colorsToCss()}
68
71
  `;
69
72
 
@@ -78,8 +81,16 @@ export default function (context, options = {}) {
78
81
  ...children
79
82
  ] = toPropsAndChildren(args);
80
83
 
81
- return dialog(
84
+ const dialogEl = dialog(
82
85
  {
86
+ ...props,
87
+ bauMounted: () => {
88
+ const search = new URLSearchParams(window.location.search);
89
+ const modalId = search.get("modal");
90
+ if (modalId == (props.id ?? "modal")) {
91
+ dialogEl.showModal();
92
+ }
93
+ },
83
94
  class: classNames(
84
95
  "modal",
85
96
  className,
@@ -90,7 +101,22 @@ export default function (context, options = {}) {
90
101
  props?.class
91
102
  ),
92
103
  },
93
- div(children)
104
+ children
94
105
  );
106
+
107
+ const observer = new MutationObserver((events) => {
108
+ const search = new URLSearchParams(window.location.search);
109
+ if (events[0].attributeName == "open") {
110
+ if (dialogEl.open) {
111
+ search.set("modal", dialogEl.id ?? "modal");
112
+ } else {
113
+ search.delete("modal");
114
+ }
115
+ window.history.pushState("", "", `?${search.toString()}`);
116
+ }
117
+ });
118
+ observer.observe(dialogEl, { attributes: true });
119
+
120
+ return dialogEl;
95
121
  };
96
122
  }
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.60.1",
4
+ "version": "0.61.1",
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.60.1",
24
- "@grucloud/bau-css": "^0.60.1"
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": "c8eda767c9b8dd6dfd707191a62fa375261c20c2"
29
+ "gitHead": "c69a41df5289f851fcdeb31ee5e40ee660351fd2"
30
30
  }