@grucloud/bau-ui 0.63.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.
- package/animate/animate.js +31 -27
- package/drillDownMenu/drillDownMenu.js +52 -40
- package/package.json +2 -2
package/animate/animate.js
CHANGED
|
@@ -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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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,
|
|
@@ -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";
|
|
@@ -220,7 +219,7 @@ export default function (context, options = {}) {
|
|
|
220
219
|
let currentTree = treeAddParent({})({ ...tree });
|
|
221
220
|
let subTree = findSubTree(pathname)(currentTree);
|
|
222
221
|
if (!subTree) {
|
|
223
|
-
//
|
|
222
|
+
//console.error("drilldown no sub tree", pathname);
|
|
224
223
|
subTree = currentTree;
|
|
225
224
|
}
|
|
226
225
|
return subTree;
|
|
@@ -230,23 +229,14 @@ export default function (context, options = {}) {
|
|
|
230
229
|
window.location.pathname.replace(baseUrl, "")
|
|
231
230
|
);
|
|
232
231
|
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
target.
|
|
238
|
-
href &&
|
|
239
|
-
!href.startsWith("http") &&
|
|
240
|
-
!href.startsWith("#") &&
|
|
241
|
-
!href.startsWith("?")
|
|
242
|
-
) {
|
|
243
|
-
let path = href.replace(baseUrl, "");
|
|
244
|
-
if (!hashBased) {
|
|
245
|
-
path = path.replace(target.hash, "");
|
|
246
|
-
}
|
|
247
|
-
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, "");
|
|
248
237
|
}
|
|
249
|
-
|
|
238
|
+
return path;
|
|
239
|
+
};
|
|
250
240
|
|
|
251
241
|
return function DrillDownMenu(props) {
|
|
252
242
|
const {
|
|
@@ -256,30 +246,52 @@ export default function (context, options = {}) {
|
|
|
256
246
|
tree,
|
|
257
247
|
...otherProps
|
|
258
248
|
} = props;
|
|
259
|
-
|
|
260
|
-
let
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
pathname: pathnameState.val,
|
|
264
|
-
});
|
|
265
|
-
return _currentTree;
|
|
249
|
+
|
|
250
|
+
let _currentTree = findInitialTree({
|
|
251
|
+
tree,
|
|
252
|
+
pathname: pathnameState.val,
|
|
266
253
|
});
|
|
267
254
|
|
|
268
|
-
let
|
|
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
|
+
});
|
|
269
281
|
|
|
270
282
|
const onclick = (event) => {
|
|
271
|
-
const {
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
} else if (
|
|
275
|
-
|
|
276
|
-
} else if (
|
|
277
|
-
|
|
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;
|
|
278
290
|
}
|
|
279
291
|
};
|
|
280
292
|
|
|
281
|
-
const animationHide = (
|
|
282
|
-
switch (
|
|
293
|
+
const animationHide = (direction) => {
|
|
294
|
+
switch (direction) {
|
|
283
295
|
case 1:
|
|
284
296
|
return `${hideToLeft} ${animationDuration}`;
|
|
285
297
|
case -1:
|
|
@@ -289,8 +301,8 @@ export default function (context, options = {}) {
|
|
|
289
301
|
}
|
|
290
302
|
};
|
|
291
303
|
|
|
292
|
-
const animationShow = (
|
|
293
|
-
switch (
|
|
304
|
+
const animationShow = (direction) => {
|
|
305
|
+
switch (direction) {
|
|
294
306
|
case 1:
|
|
295
307
|
return `${hideToRight} ${animationDuration} reverse`;
|
|
296
308
|
case -1:
|
|
@@ -314,11 +326,11 @@ export default function (context, options = {}) {
|
|
|
314
326
|
},
|
|
315
327
|
Animate(
|
|
316
328
|
{
|
|
317
|
-
animationHide: () => animationHide(
|
|
318
|
-
animationShow: () => animationShow(
|
|
329
|
+
animationHide: () => animationHide(_direction),
|
|
330
|
+
animationShow: () => animationShow(_direction),
|
|
319
331
|
},
|
|
320
332
|
bau.bind({
|
|
321
|
-
deps: [
|
|
333
|
+
deps: [pathnameState],
|
|
322
334
|
render: () => () =>
|
|
323
335
|
Menu({
|
|
324
336
|
variant,
|
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.63.
|
|
4
|
+
"version": "0.63.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BSD",
|
|
7
7
|
"keywords": [
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typedoc": "0.24.8"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "d83473dc2d988c6e4d1c2d589c65c9e52605f4cd"
|
|
30
30
|
}
|