@cfx-dev/ui-components 5.0.5 → 5.0.6

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.
@@ -4,6 +4,7 @@ export interface BurgerMenuItem {
4
4
  label: string;
5
5
  highlighted?: boolean;
6
6
  id: string;
7
+ openByDefault?: boolean;
7
8
  className?: string;
8
9
  submenu?: BurgerMenuItem[];
9
10
  }
@@ -12,5 +13,9 @@ export interface BurgerMenuProps {
12
13
  onItemClick: (item: string) => void;
13
14
  isOpen: boolean;
14
15
  className?: string;
16
+ menuClassName?: string;
17
+ subItemContainerClassName?: string;
18
+ itemInteractiveClassName?: string;
19
+ itemClassName?: string;
15
20
  }
16
- export declare function BurgerMenu({ items, onItemClick, isOpen, className, }: BurgerMenuProps): React.ReactElement;
21
+ export declare function BurgerMenu({ items, onItemClick, isOpen, className, menuClassName, subItemContainerClassName, itemInteractiveClassName, itemClassName, }: BurgerMenuProps): React.ReactElement;
@@ -1,22 +1,31 @@
1
- import { jsx as o, jsxs as c } from "react/jsx-runtime";
2
- import { useState as C, useCallback as d } from "react";
1
+ import { jsx as o, jsxs as p } from "react/jsx-runtime";
2
+ import { useState as x, useCallback as b } from "react";
3
3
  import r from "../Flex/Flex.js";
4
- import { clsx as m } from "../../utils/clsx.js";
5
- import { Icon as k } from "../Icon/Icon.js";
6
- import { Interactive as h } from "../Interactive/Interactive.js";
7
- import { Text as w } from "../Text/Text.js";
4
+ import { clsx as u } from "../../utils/clsx.js";
5
+ import { Icon as N } from "../Icon/Icon.js";
6
+ import { Interactive as f } from "../Interactive/Interactive.js";
7
+ import { Text as S } from "../Text/Text.js";
8
8
  import "../../utils/ui/ui.js";
9
- import { s as l } from "../../BurgerMenu.module-CyY93Y4u.js";
10
- function K({
11
- items: b,
12
- onItemClick: u,
13
- isOpen: p,
14
- className: f
9
+ import { s as i } from "../../BurgerMenu.module-CyY93Y4u.js";
10
+ function P({
11
+ items: a,
12
+ onItemClick: c,
13
+ isOpen: g,
14
+ className: y,
15
+ menuClassName: C,
16
+ subItemContainerClassName: k,
17
+ itemInteractiveClassName: s,
18
+ itemClassName: t
15
19
  }) {
16
- const [t, g] = C({}), i = d((e) => {
17
- u(e);
18
- }, [u]), s = d((e) => {
19
- g((n) => ({
20
+ const [d, w] = x(() => {
21
+ const e = {};
22
+ return a.forEach((n) => {
23
+ n.openByDefault && (e[n.id] = !0);
24
+ }), e;
25
+ }), l = b((e) => {
26
+ c(e);
27
+ }, [c]), m = b((e) => {
28
+ w((n) => ({
20
29
  ...n,
21
30
  [e]: !n[e]
22
31
  }));
@@ -24,24 +33,25 @@ function K({
24
33
  return /* @__PURE__ */ o(
25
34
  r,
26
35
  {
27
- className: m(l.burgerMenuContentContainer, f),
36
+ className: u(i.burgerMenuContentContainer, y),
28
37
  direction: "column",
29
- children: p && /* @__PURE__ */ o(r, { direction: "column", className: l.menu, children: b.map((e) => /* @__PURE__ */ c("div", { children: [
38
+ children: g && /* @__PURE__ */ o(r, { direction: "column", className: u(i.menu, C), children: a.map((e) => /* @__PURE__ */ p("div", { children: [
30
39
  /* @__PURE__ */ o(
31
- h,
40
+ f,
32
41
  {
33
42
  showPointer: !0,
34
43
  "aria-label": "Toggle item",
35
44
  role: "button",
36
45
  onClick: () => {
37
- e.submenu ? s(e.id) : i(e.id);
46
+ e.submenu ? m(e.id) : l(e.id);
38
47
  },
39
48
  onKeyDown: (n) => {
40
- (n.key === "Enter" || n.key === " ") && (e.submenu ? s(e.id) : i(e.id));
49
+ (n.key === "Enter" || n.key === " ") && (e.submenu ? m(e.id) : l(e.id));
41
50
  },
42
- children: /* @__PURE__ */ c(r, { p: 2, justifyContent: "space-between", children: [
51
+ className: s,
52
+ children: /* @__PURE__ */ p(r, { p: 2, justifyContent: "space-between", className: t, children: [
43
53
  /* @__PURE__ */ o(
44
- w,
54
+ S,
45
55
  {
46
56
  size: "xsmall",
47
57
  weight: e.highlighted ? "bold" : "regular",
@@ -49,9 +59,9 @@ function K({
49
59
  }
50
60
  ),
51
61
  e.submenu && /* @__PURE__ */ o(
52
- k,
62
+ N,
53
63
  {
54
- name: t[e.id] ? "UpChevron" : "DownChevron"
64
+ name: d[e.id] ? "UpChevron" : "DownChevron"
55
65
  }
56
66
  )
57
67
  ] })
@@ -60,21 +70,26 @@ function K({
60
70
  e.submenu && /* @__PURE__ */ o(
61
71
  r,
62
72
  {
63
- className: m(l.subItemContainer, {
64
- [l.subItemContainerOpen]: t[e.id]
65
- }),
73
+ className: u(
74
+ i.subItemContainer,
75
+ k,
76
+ {
77
+ [i.subItemContainerOpen]: d[e.id]
78
+ }
79
+ ),
66
80
  direction: "column",
67
81
  children: e.submenu.map((n) => /* @__PURE__ */ o(
68
- h,
82
+ f,
69
83
  {
70
84
  showPointer: !0,
71
85
  "aria-label": "Toggle sub item",
72
86
  role: "button",
73
- onClick: () => i(n.id),
74
- onKeyDown: (a) => {
75
- (a.key === "Enter" || a.key === " ") && i(n.id);
87
+ onClick: () => l(n.id),
88
+ onKeyDown: (h) => {
89
+ (h.key === "Enter" || h.key === " ") && l(n.id);
76
90
  },
77
- children: /* @__PURE__ */ o(r, { p: 2, children: n.label })
91
+ className: s,
92
+ children: /* @__PURE__ */ o(r, { p: 2, className: t, children: n.label })
78
93
  },
79
94
  n.id
80
95
  ))
@@ -85,5 +100,5 @@ function K({
85
100
  );
86
101
  }
87
102
  export {
88
- K as BurgerMenu
103
+ P as BurgerMenu
89
104
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfx-dev/ui-components",
3
3
  "private": false,
4
- "version": "5.0.5",
4
+ "version": "5.0.6",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "dist/main.js",