@grucloud/bau-ui 0.62.0 → 0.63.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.
@@ -1,7 +1,7 @@
1
1
  import classNames from "@grucloud/bau-css/classNames.js";
2
2
 
3
3
  export default function (context, options = {}) {
4
- const { bau } = context;
4
+ const { bau, window } = context;
5
5
  const { div } = bau.tags;
6
6
  const noop = () => undefined;
7
7
 
@@ -17,36 +17,40 @@ export default function (context, options = {}) {
17
17
  [...record.removedNodes].forEach((childNode) => {
18
18
  if (!animationHide() || childNode.getAttribute("cloned")) return;
19
19
  const nodeCloned = childNode.cloneNode(true);
20
- nodeCloned.setAttribute("cloned", true);
21
- nodeCloned.style.top = 0;
22
- nodeCloned.style.left = 0;
23
- nodeCloned.style.width = childNode.getAttribute("width");
24
- nodeCloned.style.height = childNode.getAttribute("height");
25
- nodeCloned.style.position = "absolute";
26
- nodeCloned.style.animation = animationHide();
27
- record.target.appendChild(nodeCloned);
28
- nodeCloned.addEventListener("animationend", () =>
29
- nodeCloned.parentNode?.removeChild(nodeCloned)
30
- );
20
+ window.requestAnimationFrame(() => {
21
+ nodeCloned.setAttribute("cloned", true);
22
+ nodeCloned.style.top = 0;
23
+ nodeCloned.style.left = 0;
24
+ nodeCloned.style.width = childNode.getAttribute("width");
25
+ nodeCloned.style.height = childNode.getAttribute("height");
26
+ nodeCloned.style.position = "absolute";
27
+ nodeCloned.style.animation = animationHide();
28
+ record.target.appendChild(nodeCloned);
29
+ nodeCloned.addEventListener("animationend", () =>
30
+ nodeCloned.parentNode?.removeChild(nodeCloned)
31
+ );
32
+ });
31
33
  });
32
34
  // Added Nodes
33
35
  [...record.addedNodes].forEach((childNode) => {
34
36
  if (childNode.getAttribute("cloned")) return;
35
- element.style.position = "relative";
36
- const rect = childNode.getBoundingClientRect();
37
- childNode.setAttribute("width", rect.width + "px");
38
- childNode.setAttribute("height", rect.height + "px");
39
- if (animationShow()) {
40
- childNode.style.animation = animationShow();
41
- const animationEndHandler = () => {
42
- childNode.removeEventListener(
43
- "animationend",
44
- animationEndHandler
45
- );
46
- childNode.style.animation = "";
47
- };
48
- childNode.addEventListener("animationend", animationEndHandler);
49
- }
37
+ window.requestAnimationFrame(() => {
38
+ element.style.position = "relative";
39
+ const rect = childNode.getBoundingClientRect();
40
+ childNode.setAttribute("width", rect.width + "px");
41
+ childNode.setAttribute("height", rect.height + "px");
42
+ if (animationShow()) {
43
+ childNode.style.animation = animationShow();
44
+ const animationEndHandler = () => {
45
+ childNode.removeEventListener(
46
+ "animationend",
47
+ animationEndHandler
48
+ );
49
+ childNode.style.animation = "";
50
+ };
51
+ childNode.addEventListener("animationend", animationEndHandler);
52
+ }
53
+ });
50
54
  });
51
55
  },
52
56
  ...props,
@@ -5,6 +5,7 @@ export default function (context, options = {}) {
5
5
  const { bau, css } = context;
6
6
  const { input } = bau.tags;
7
7
  const className = css`
8
+ margin: 0.5rem;
8
9
  width: 1.5rem;
9
10
  height: 1.5rem;
10
11
  border-radius: var(--global-radius);
@@ -1,4 +1,3 @@
1
- import { toPropsAndChildren } from "@grucloud/bau/bau.js";
2
1
  import cn from "@grucloud/bau-css/classNames.js";
3
2
  import animate from "../animate/animate.js";
4
3
  import button from "../button/button.js";
@@ -200,8 +199,6 @@ export default function (context, options = {}) {
200
199
 
201
200
  const Menu = ({ variant, color, size, currentTree, pathnameState }) => {
202
201
  const { children, parentTree, data, renderList } = currentTree;
203
- if (renderList) {
204
- }
205
202
  return div(
206
203
  { class: cn("drillDownMenu", variant, color, size) },
207
204
  parentTree && renderHeader({ variant, color, size, data, currentTree }),
@@ -222,7 +219,7 @@ export default function (context, options = {}) {
222
219
  let currentTree = treeAddParent({})({ ...tree });
223
220
  let subTree = findSubTree(pathname)(currentTree);
224
221
  if (!subTree) {
225
- // console.error("drilldown no sub tree", pathname);
222
+ //console.error("drilldown no sub tree", pathname);
226
223
  subTree = currentTree;
227
224
  }
228
225
  return subTree;
@@ -232,23 +229,14 @@ export default function (context, options = {}) {
232
229
  window.location.pathname.replace(baseUrl, "")
233
230
  );
234
231
 
235
- window.document.addEventListener("click", (event) => {
236
- const { target } = event;
237
- const href = target.getAttribute("href");
238
- if (
239
- target.tagName === "A" &&
240
- href &&
241
- !href.startsWith("http") &&
242
- !href.startsWith("#") &&
243
- !href.startsWith("?")
244
- ) {
245
- let path = href.replace(baseUrl, "");
246
- if (!hashBased) {
247
- path = path.replace(target.hash, "");
248
- }
249
- pathnameState.val = path;
232
+ const pathFromHref = ({ target }) => {
233
+ const href = target.closest("a").getAttribute("href");
234
+ let path = href.replace(baseUrl, "");
235
+ if (!hashBased) {
236
+ path = path.replace(target.hash, "");
250
237
  }
251
- });
238
+ return path;
239
+ };
252
240
 
253
241
  return function DrillDownMenu(props) {
254
242
  const {
@@ -258,25 +246,47 @@ export default function (context, options = {}) {
258
246
  tree,
259
247
  ...otherProps
260
248
  } = props;
261
- let _currentTree;
262
- let currentTreeState = bau.derive(() => {
263
- _currentTree = findInitialTree({
264
- tree,
265
- pathname: pathnameState.val,
266
- });
267
- return _currentTree;
249
+
250
+ let _currentTree = findInitialTree({
251
+ tree,
252
+ pathname: pathnameState.val,
268
253
  });
269
254
 
270
- let direction = 1;
255
+ let _direction;
256
+ window.document.addEventListener("click", (event) => {
257
+ const { target } = event;
258
+ const anchor = target.closest("a");
259
+ if (!anchor) return;
260
+ const href = anchor.getAttribute("href");
261
+
262
+ if (
263
+ href &&
264
+ !href.startsWith("http") &&
265
+ !href.startsWith("#") &&
266
+ !href.startsWith("?")
267
+ ) {
268
+ _currentTree = findInitialTree({
269
+ tree,
270
+ pathname: pathFromHref(event),
271
+ });
272
+ console.log("direction", _direction);
273
+
274
+ const { ischild } = event.target.dataset;
275
+
276
+ if (ischild !== "true") {
277
+ pathnameState.val = pathFromHref({ target });
278
+ }
279
+ }
280
+ });
271
281
 
272
282
  const onclick = (event) => {
273
- const { dataset } = event.target;
274
- if (dataset.buttonback == "true") {
275
- direction = -1;
276
- } else if (dataset.ischild == "false") {
277
- direction = 1;
278
- } else if (dataset.ischild == "true") {
279
- direction = 0;
283
+ const { buttonback, ischild } = event.target.dataset;
284
+ if (buttonback == "true") {
285
+ _direction = -1;
286
+ } else if (ischild == "false") {
287
+ _direction = 1;
288
+ } else if (ischild == "true") {
289
+ _direction = 0;
280
290
  }
281
291
  };
282
292
 
@@ -316,11 +326,11 @@ export default function (context, options = {}) {
316
326
  },
317
327
  Animate(
318
328
  {
319
- animationHide: () => animationHide(direction),
320
- animationShow: () => animationShow(direction),
329
+ animationHide: () => animationHide(_direction),
330
+ animationShow: () => animationShow(_direction),
321
331
  },
322
332
  bau.bind({
323
- deps: [currentTreeState],
333
+ deps: [pathnameState],
324
334
  render: () => () =>
325
335
  Menu({
326
336
  variant,
package/form/form.js CHANGED
@@ -12,10 +12,8 @@ export default function (context, options = {}) {
12
12
  gap: 1rem;
13
13
  padding: 1rem;
14
14
  min-width: 350px;
15
-
16
15
  & > header {
17
16
  & h1 {
18
- line-height: 0;
19
17
  font-size: 1.3rem;
20
18
  }
21
19
  }
@@ -94,6 +94,10 @@ export default function globalStyle(
94
94
  { colorPalette = ColorPaletteDefault } = {}
95
95
  ) {
96
96
  createGlobalStyles`
97
+ * {
98
+ margin: 0;
99
+ padding: 0;
100
+ }
97
101
  :root {
98
102
  --color-scheme: light;
99
103
  --contrast-background-value: 90%;
package/modal/modal.js CHANGED
@@ -25,6 +25,8 @@ export default function (context, options = {}) {
25
25
  ).join("\n");
26
26
 
27
27
  const className = css`
28
+ margin: auto;
29
+ padding: 1rem;
28
30
  box-shadow: var(--shadow-s);
29
31
  background-color: var(--background-color);
30
32
  border-radius: var(--global-radius);
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.62.0",
4
+ "version": "0.63.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.62.0",
24
- "@grucloud/bau-css": "^0.62.0"
23
+ "@grucloud/bau": "^0.63.0",
24
+ "@grucloud/bau-css": "^0.63.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "typedoc": "0.24.8"
28
28
  },
29
- "gitHead": "ecaa1d232ad3eb48859211b8ffc48f4f4e799e0c"
29
+ "gitHead": "d83473dc2d988c6e4d1c2d589c65c9e52605f4cd"
30
30
  }
package/paper/paper.js CHANGED
@@ -8,6 +8,7 @@ export default function (context, options = {}) {
8
8
  border: 1px solid transparent;
9
9
  height: fit-content;
10
10
  border-radius: var(--global-radius);
11
+ margin: 1rem 0;
11
12
  &.sm {
12
13
  box-shadow: var(--shadow-s);
13
14
  background-image: linear-gradient(
@@ -17,6 +17,7 @@ export default function (context, options = {}) {
17
17
  ).join("\n");
18
18
 
19
19
  const className = css`
20
+ margin: 0.5rem;
20
21
  &.sm {
21
22
  transform: scale(0.8);
22
23
  }