@cfx-dev/ui-components 5.0.4 → 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
  };
@@ -1,107 +1,110 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import { clsx as v } from "../../utils/clsx.js";
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { clsx as H } from "../../utils/clsx.js";
3
3
  import { getColor as N } from "../../utils/color.js";
4
4
  import { ui as t } from "../../utils/ui/ui.js";
5
- import { TextSizeEnum as i } from "../../utils/ui/ui.types.js";
6
- const O = "cfxui__Text__root__2fe11", P = "cfxui__Text__centered__4d7bd", V = "cfxui__Text__underlined__5860e", $ = "cfxui__Text__strikethrough__e3ee3", q = "cfxui__Text__truncated__417f4", w = "cfxui__Text__typographic__d8155", B = "cfxui__Text__block__cb1b6", r = {
5
+ import { TextSizeEnum as o } from "../../utils/ui/ui.types.js";
6
+ const O = "cfxui__Text__root__2fe11", P = "cfxui__Text__verticalTrimDisabled__34631", V = "cfxui__Text__centered__4d7bd", $ = "cfxui__Text__underlined__5860e", q = "cfxui__Text__strikethrough__e3ee3", w = "cfxui__Text__truncated__417f4", B = "cfxui__Text__typographic__d8155", I = "cfxui__Text__block__cb1b6", r = {
7
7
  root: O,
8
- centered: P,
9
- underlined: V,
10
- strikethrough: $,
11
- truncated: q,
12
- typographic: w,
13
- block: B
14
- }, D = (e) => e in i ? t.fontSize(e) : typeof e == "number" ? t.q(e) : e, I = (e) => e in i ? t.lineHeight(e) : typeof e == "number" ? e >= 100 ? (e / 100).toFixed(2) : t.lineHeight(i.small) : e, L = (e) => e in i ? t.paragraphSpacing(e) : typeof e == "number" ? t.q(e) : e, M = {
8
+ verticalTrimDisabled: P,
9
+ centered: V,
10
+ underlined: $,
11
+ strikethrough: q,
12
+ truncated: w,
13
+ typographic: B,
14
+ block: I
15
+ }, L = (e) => e in o ? t.fontSize(e) : typeof e == "number" ? t.q(e) : e, M = (e) => e in o ? t.lineHeight(e) : typeof e == "number" ? e >= 100 ? (e / 100).toFixed(2) : t.lineHeight(o.small) : e, X = (e) => e in o ? t.paragraphSpacing(e) : typeof e == "number" ? t.q(e) : e, j = {
15
16
  0: 0,
16
17
  25: "var(--text-opacity-25)",
17
18
  50: "var(--text-opacity-50)",
18
19
  75: "var(--text-opacity-75)",
19
20
  100: 1
20
- }, X = {
21
+ }, G = {
21
22
  h1: "h1",
22
23
  h2: "h2",
23
24
  h3: "h3",
24
25
  h4: "h4",
25
26
  h5: "h5",
26
27
  h6: "h6"
27
- }, j = (e, n = 1) => typeof e == "number" ? e : typeof e == "string" && M[e] || n, G = "primary";
28
- function U(e) {
28
+ }, U = (e, i = 1) => typeof e == "number" ? e : typeof e == "string" && j[e] || i, W = "primary";
29
+ function Y(e) {
29
30
  const {
30
- family: n,
31
- size: o = "small",
32
- lineHeight: c = o,
33
- weight: l = "regular",
31
+ family: i,
32
+ size: n = "small",
33
+ lineHeight: a = n,
34
+ weight: p = "regular",
34
35
  letterSpacing: u = "small",
35
36
  color: f,
36
37
  opacity: _,
37
38
  as: s = "span",
38
- centered: h = !1,
39
- truncated: g = !1,
40
- typographic: m = !1,
39
+ centered: m = !1,
40
+ truncated: h = !1,
41
+ typographic: g = !1,
41
42
  uppercase: d = !1,
42
43
  userSelectable: x = !1,
43
44
  underlined: y = !1,
44
45
  strikethrough: T = !1,
45
- children: b,
46
- className: S,
47
- style: k,
48
- ref: R,
46
+ verticalTrimDisabled: b = !1,
47
+ children: S,
48
+ className: k,
49
+ style: R,
50
+ ref: v,
49
51
  htmlFor: C,
50
52
  id: F
51
- } = e, z = s === "div", A = v(
53
+ } = e, D = s === "div", z = H(
52
54
  r.root,
53
- S,
55
+ k,
54
56
  // TODO: do we need reposive in text now?
55
57
  // all sizes is responsive by default
56
- t.getResponsiveClassnames("font-size", o),
57
- t.getResponsiveClassnames("line-height", o),
58
- t.getResponsiveClassnames("paragraph-spacing", o),
58
+ t.getResponsiveClassnames("font-size", n),
59
+ t.getResponsiveClassnames("line-height", n),
60
+ t.getResponsiveClassnames("paragraph-spacing", n),
59
61
  {
60
- [r.block]: z,
61
- [r.centered]: h,
62
- [r.truncated]: g,
62
+ [r.block]: D,
63
+ [r.centered]: m,
64
+ [r.truncated]: h,
63
65
  [r.underlined]: y,
64
66
  [r.strikethrough]: T,
65
- [r.typographic]: m,
67
+ [r.typographic]: g,
68
+ [r.verticalTrimDisabled]: b,
66
69
  [t.cls.userSelectableText]: x
67
70
  }
68
- ), E = N({
71
+ ), A = N({
69
72
  ...e,
70
- color: f || G,
71
- opacity: j(_)
72
- }), H = typeof n == "string" ? n : X[s] || "primary", a = {
73
- color: E,
74
- fontFamily: `var(--font-family-${H})`,
73
+ color: f || W,
74
+ opacity: U(_)
75
+ }), E = typeof i == "string" ? i : G[s] || "primary", c = {
76
+ color: A,
77
+ fontFamily: `var(--font-family-${E})`,
75
78
  letterSpacing: `var(--letter-spacing-${u})`,
76
- fontWeight: `var(--font-weight-${l})`,
77
- ...t.getResponsiveStyles("font-size", o, D),
78
- ...t.getResponsiveStyles("line-height", c, I),
79
- ...t.getResponsiveStyles("paragraph-spacing", c, L),
80
- ...k
79
+ fontWeight: `var(--font-weight-${p})`,
80
+ ...t.getResponsiveStyles("font-size", n, L),
81
+ ...t.getResponsiveStyles("line-height", a, M),
82
+ ...t.getResponsiveStyles("paragraph-spacing", a, X),
83
+ ...R
81
84
  };
82
- return d && (a.textTransform = "uppercase"), /* @__PURE__ */ p(
85
+ return d && (c.textTransform = "uppercase"), /* @__PURE__ */ l(
83
86
  s,
84
87
  {
85
- ref: R,
88
+ ref: v,
86
89
  dir: "auto",
87
- className: A,
88
- style: a,
90
+ className: z,
91
+ style: c,
89
92
  htmlFor: C,
90
93
  id: F,
91
- children: b
94
+ children: S
92
95
  }
93
96
  );
94
97
  }
95
- function ee(e) {
96
- return /* @__PURE__ */ p(U, { ...e, as: "div" });
98
+ function re(e) {
99
+ return /* @__PURE__ */ l(Y, { ...e, as: "div" });
97
100
  }
98
101
  export {
99
- G as DEFAULT_TEXT_COLOR,
100
- M as TEXT_OPACITY_MAP,
101
- U as Text,
102
- ee as TextBlock,
103
- j as getTextOpacity,
104
- I as lineHeightResponsiveValueFormatter,
105
- L as paragraphSpacingResponsiveValueFormatter,
106
- D as textSizeResponsiveValueFormatter
102
+ W as DEFAULT_TEXT_COLOR,
103
+ j as TEXT_OPACITY_MAP,
104
+ Y as Text,
105
+ re as TextBlock,
106
+ U as getTextOpacity,
107
+ M as lineHeightResponsiveValueFormatter,
108
+ X as paragraphSpacingResponsiveValueFormatter,
109
+ L as textSizeResponsiveValueFormatter
107
110
  };
@@ -20,6 +20,10 @@ interface TextPropsBase {
20
20
  * If it'll be a multiline text, use this to add extra spacing between lines
21
21
  */
22
22
  typographic?: boolean;
23
+ /**
24
+ * Will remove vertical trim feature based on before and after pseudo elements with negative margins
25
+ */
26
+ verticalTrimDisabled?: boolean;
23
27
  /**
24
28
  * Allow users to select text
25
29
  */
@@ -23,6 +23,8 @@
23
23
  @each $name, $value in ui.$mediaMap {
24
24
  @include ui.media-min($name) {
25
25
  .ui-#{$propName}-#{$name} {
26
+ @include ui.def('#{$propName}-current', var(--#{$propName}-#{$name}));
27
+
26
28
  #{$propName}: var(--#{$propName}-#{$name});
27
29
  }
28
30
  }
@@ -17,6 +17,7 @@ export declare enum ColorEnum {
17
17
  }
18
18
  export type ColorType = keyof typeof ColorEnum;
19
19
  export declare enum TextSizeEnum {
20
+ xxxsmall = "xxxsmall",
20
21
  xxsmall = "xxsmall",
21
22
  xsmall = "xsmall",
22
23
  small = "small",
@@ -1,4 +1,4 @@
1
- var a = /* @__PURE__ */ ((l) => (l.accent = "accent", l.primary = "primary", l.secondary = "secondary", l.tertiary = "tertiary", l.green = "green", l.yellow = "yellow", l.red = "red", l.argentum = "argentum", l.aurum = "aurum", l.platinum = "platinum", l.bg = "bg", l["bg-light"] = "bg-light", l["bg-dark"] = "bg-dark", l["bg-dark-grey"] = "bg-dark-grey", l["bg-black"] = "bg-black", l))(a || {}), x = /* @__PURE__ */ ((l) => (l.xxsmall = "xxsmall", l.xsmall = "xsmall", l.small = "small", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l.xxlarge = "xxlarge", l.xxxlarge = "xxxlarge", l.xxxxlarge = "xxxxlarge", l))(x || {}), r = /* @__PURE__ */ ((l) => (l.xsmall = "xsmall", l.small = "small", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l))(r || {}), s = /* @__PURE__ */ ((l) => (l.none = "none", l.xsmall = "xsmall", l.small = "small", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l.pill = "pill", l))(s || {}), e = /* @__PURE__ */ ((l) => (l.zero = "zero", l.first = "first", l.second = "second", l.max = "max", l))(e || {}), g = /* @__PURE__ */ ((l) => (l.none = "none", l.hairthin = "hairthin", l.thin = "thin", l.xxsmall = "xxsmall", l.xsmall = "xsmall", l.small = "small", l.normal = "normal", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l.safezone = "safezone", l))(g || {}), p = /* @__PURE__ */ ((l) => (l.xxsmall = "xxsmall", l.xsmall = "xsmall", l.small = "small", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l.xxlarge = "xxlarge", l.xxxlarge = "xxxlarge", l.xxxxlarge = "xxxxlarge", l.xxxxxlarge = "xxxxxlarge", l))(p || {}), t = /* @__PURE__ */ ((l) => (l.sp25 = "sp25", l.sp100 = "sp100", l.sp110 = "sp110", l.sp150 = "sp150", l.sp175 = "sp175", l.sp200 = "sp200", l.sp250 = "sp250", l.sp300 = "sp300", l.sp400 = "sp400", l.sp450 = "sp450", l.sp600 = "sp600", l.sp700 = "sp700", l.sp800 = "sp800", l.sp900 = "sp900", l.sp1000 = "sp1000", l.sp1200 = "sp1200", l.sp1600 = "sp1600", l.sp2400 = "sp2400", l))(t || {}), b = /* @__PURE__ */ ((l) => (l.initial = "initial", l.small = "small", l["small-medium"] = "small-medium", l.medium = "medium", l["medium-large"] = "medium-large", l.large = "large", l.xlarge = "xlarge", l))(b || {});
1
+ var a = /* @__PURE__ */ ((l) => (l.accent = "accent", l.primary = "primary", l.secondary = "secondary", l.tertiary = "tertiary", l.green = "green", l.yellow = "yellow", l.red = "red", l.argentum = "argentum", l.aurum = "aurum", l.platinum = "platinum", l.bg = "bg", l["bg-light"] = "bg-light", l["bg-dark"] = "bg-dark", l["bg-dark-grey"] = "bg-dark-grey", l["bg-black"] = "bg-black", l))(a || {}), x = /* @__PURE__ */ ((l) => (l.xxxsmall = "xxxsmall", l.xxsmall = "xxsmall", l.xsmall = "xsmall", l.small = "small", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l.xxlarge = "xxlarge", l.xxxlarge = "xxxlarge", l.xxxxlarge = "xxxxlarge", l))(x || {}), s = /* @__PURE__ */ ((l) => (l.xsmall = "xsmall", l.small = "small", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l))(s || {}), r = /* @__PURE__ */ ((l) => (l.none = "none", l.xsmall = "xsmall", l.small = "small", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l.pill = "pill", l))(r || {}), g = /* @__PURE__ */ ((l) => (l.zero = "zero", l.first = "first", l.second = "second", l.max = "max", l))(g || {}), e = /* @__PURE__ */ ((l) => (l.none = "none", l.hairthin = "hairthin", l.thin = "thin", l.xxsmall = "xxsmall", l.xsmall = "xsmall", l.small = "small", l.normal = "normal", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l.safezone = "safezone", l))(e || {}), p = /* @__PURE__ */ ((l) => (l.xxsmall = "xxsmall", l.xsmall = "xsmall", l.small = "small", l.medium = "medium", l.large = "large", l.xlarge = "xlarge", l.xxlarge = "xxlarge", l.xxxlarge = "xxxlarge", l.xxxxlarge = "xxxxlarge", l.xxxxxlarge = "xxxxxlarge", l))(p || {}), t = /* @__PURE__ */ ((l) => (l.sp25 = "sp25", l.sp100 = "sp100", l.sp110 = "sp110", l.sp150 = "sp150", l.sp175 = "sp175", l.sp200 = "sp200", l.sp250 = "sp250", l.sp300 = "sp300", l.sp400 = "sp400", l.sp450 = "sp450", l.sp600 = "sp600", l.sp700 = "sp700", l.sp800 = "sp800", l.sp900 = "sp900", l.sp1000 = "sp1000", l.sp1200 = "sp1200", l.sp1600 = "sp1600", l.sp2400 = "sp2400", l))(t || {}), b = /* @__PURE__ */ ((l) => (l.initial = "initial", l.small = "small", l["small-medium"] = "small-medium", l.medium = "medium", l["medium-large"] = "medium-large", l.large = "large", l.xlarge = "xlarge", l))(b || {});
2
2
  const d = {
3
3
  initial: 0,
4
4
  small: 360,
@@ -9,14 +9,14 @@ const d = {
9
9
  xlarge: 2560
10
10
  };
11
11
  export {
12
- s as BorderRadiusEnum,
12
+ r as BorderRadiusEnum,
13
13
  a as ColorEnum,
14
- r as IconSizeEnum,
14
+ s as IconSizeEnum,
15
15
  b as MediaQueryEnum,
16
16
  d as MediaQueryValuesMap,
17
- g as OffsetEnum,
17
+ e as OffsetEnum,
18
18
  p as SpacerEnum,
19
19
  t as SpacingEnum,
20
20
  x as TextSizeEnum,
21
- e as ZIndexEnum
21
+ g as ZIndexEnum
22
22
  };
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.4",
4
+ "version": "5.0.6",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "dist/main.js",