@cfx-dev/ui-components 4.5.3 → 4.5.4

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 +1 @@
1
- .cfxui__Modal__root__53283{flex-shrink:0;position:relative;display:flex;flex-direction:column;max-width:calc((var(--width) - var(--offset-safezone) * 2) * 1);min-width:calc(var(--quant) * 37.5);max-height:calc((var(--height) - var(--offset-safezone) * 2) * 1);padding:calc(var(--quant) * 6) calc(var(--quant) * 3.75) calc(var(--quant) * 3.75) calc(var(--quant) * 3.75);background-color:var(--color-modal-background);border-radius:var(--border-radius-small);overflow:hidden auto;animation-name:cfxui__Modal__modal-appearance__60dd7;animation-duration:.2s}@media (min-width: 1024px){.cfxui__Modal__root__53283{min-width:calc(var(--quant) * 75)}}@media (min-width: 1920px){.cfxui__Modal__root__53283{min-width:calc(var(--quant) * 87.5);padding:calc(var(--quant) * 6) calc(var(--quant) * 5) calc(var(--quant) * 5) calc(var(--quant) * 5)}}.cfxui__Modal__root__53283 .cfxui__Modal__close__2df9b{position:absolute;top:calc(var(--quant) * 1.5);right:calc(var(--quant) * 2);z-index:1}.cfxui__Modal__root__53283 .cfxui__Modal__header__bec76{display:flex;flex-direction:column;gap:calc(var(--quant) * 2.5);padding-bottom:calc(var(--quant) * 3)}@media (min-width: 1920px){.cfxui__Modal__root__53283 .cfxui__Modal__header__bec76{padding-bottom:calc(var(--quant) * 4)}}.cfxui__Modal__root__53283 .cfxui__Modal__header__bec76 a{border-bottom:1px solid rgba(var(--color-secondary),1);font-weight:700}.cfxui__Modal__root__53283 .cfxui__Modal__footer__bb2fc{padding-top:calc(var(--quant) * 2.5)}@media (min-width: 1920px){.cfxui__Modal__root__53283 .cfxui__Modal__footer__bb2fc{padding-top:calc(var(--quant) * 3.75)}}@keyframes cfxui__Modal__modal-appearance__60dd7{0%{opacity:0;transform:scale(.75)}to{opacity:1;transform:scale(1)}}
1
+ .cfxui__Modal__root__53283{flex-shrink:0;position:relative;display:flex;flex-direction:column;max-width:calc((var(--width) - var(--offset-safezone) * 2) * 1);min-width:calc(var(--quant) * 37.5);max-height:calc((var(--height) - var(--offset-safezone) * 2) * 1);padding:calc(var(--quant) * 6) calc(var(--quant) * 3.75) calc(var(--quant) * 3.75) calc(var(--quant) * 3.75);background-color:var(--color-modal-background);border-radius:var(--border-radius-small);overflow:hidden auto;animation-name:cfxui__Modal__modal-appearance__60dd7;animation-duration:.2s}.cfxui__Modal__root__53283.cfxui__Modal__colored__649d1{border-top:calc(var(--quant) * 1.25) solid var(--modal-color);background:linear-gradient(180deg,var(--modal-color-bg) 0%,rgba(var(--color-bg),.2) 44.05%),linear-gradient(0deg,var(--color-modal-background),var(--color-modal-background))}@media (min-width: 1024px){.cfxui__Modal__root__53283{min-width:calc(var(--quant) * 75)}}@media (min-width: 1920px){.cfxui__Modal__root__53283{min-width:calc(var(--quant) * 87.5);padding:calc(var(--quant) * 6) calc(var(--quant) * 5) calc(var(--quant) * 5) calc(var(--quant) * 5)}}.cfxui__Modal__root__53283 .cfxui__Modal__close__2df9b{position:absolute;top:calc(var(--quant) * 1.5);right:calc(var(--quant) * 2);z-index:1}.cfxui__Modal__root__53283 .cfxui__Modal__header__bec76{display:flex;flex-direction:column;gap:calc(var(--quant) * 2.5);padding-bottom:calc(var(--quant) * 3)}@media (min-width: 1920px){.cfxui__Modal__root__53283 .cfxui__Modal__header__bec76{padding-bottom:calc(var(--quant) * 4)}}.cfxui__Modal__root__53283 .cfxui__Modal__footer__bb2fc{padding-top:calc(var(--quant) * 2.5)}@media (min-width: 1920px){.cfxui__Modal__root__53283 .cfxui__Modal__footer__bb2fc{padding-top:calc(var(--quant) * 3.75)}}@keyframes cfxui__Modal__modal-appearance__60dd7{0%{opacity:0;transform:scale(.75)}to{opacity:1;transform:scale(1)}}
@@ -1,31 +1,37 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import i from "react";
3
- import { noop as k } from "../../utils/functional.js";
4
- import { isExternalUrl as x } from "../../utils/links.js";
5
- import { getButtonClassName as d, ButtonContent as B } from "./Button.js";
6
- function M(t) {
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import o from "react";
3
+ import { isExternalUrl as b } from "../../utils/links.js";
4
+ import { getButtonClassName as h, ButtonContent as B } from "./Button.js";
5
+ function M(e) {
7
6
  const {
8
- to: e,
9
- title: m = "",
10
- tabIndex: a,
11
- target: s = "",
12
- onClick: l = k,
13
- isHrefProp: n = !1,
14
- Component: f,
15
- ref: c
16
- } = t, u = i.useMemo(() => d(t), [t]), o = x(e), C = o ? "a" : f || "a", p = i.useMemo(() => o || n ? { href: e } : { to: e }, [e, o, n]);
17
- return /* @__PURE__ */ r(
18
- C,
7
+ to: t,
8
+ title: f = "",
9
+ tabIndex: m,
10
+ target: u = "",
11
+ onClick: n,
12
+ isHrefProp: a = !1,
13
+ Component: c,
14
+ disabled: l = !1,
15
+ ref: C
16
+ } = e, d = o.useMemo(() => h(e), [e]), r = b(t), k = r ? "a" : c || "a", p = o.useMemo(() => r || a ? { href: t } : { to: t }, [t, r, a]), x = o.useCallback((i) => {
17
+ if (l) {
18
+ i.preventDefault();
19
+ return;
20
+ }
21
+ n && n(i);
22
+ }, [l, n]);
23
+ return /* @__PURE__ */ s(
24
+ k,
19
25
  {
20
- ref: c,
21
- className: u,
22
- tabIndex: a,
23
- title: m,
24
- target: s,
26
+ ref: C,
27
+ className: d,
28
+ tabIndex: m,
29
+ title: f,
30
+ target: u,
25
31
  rel: "noopener noreferrer",
26
- onClickCapture: l,
32
+ onClickCapture: x,
27
33
  ...p,
28
- children: /* @__PURE__ */ r(B, { ...t })
34
+ children: /* @__PURE__ */ s(B, { ...e })
29
35
  }
30
36
  );
31
37
  }
@@ -2,9 +2,9 @@ import { jsx as r } from "react/jsx-runtime";
2
2
  import c from "react";
3
3
  import C from "../Button/Button.js";
4
4
  import { clsx as _ } from "../../utils/clsx.js";
5
- import { noop as f } from "../../utils/functional.js";
6
5
  import "../../utils/links.js";
7
- import { Title as u } from "../Title/Title.js";
6
+ import { Title as f } from "../Title/Title.js";
7
+ import { noop as u } from "../../utils/functional.js";
8
8
  import "../../utils/hooks/useGlobalKeyboardEvent.js";
9
9
  import "../../utils/hooks/useKeyboardClose.js";
10
10
  import "../../index-Cl_RnsqN.js";
@@ -19,7 +19,7 @@ function h(o) {
19
19
  copiedTitle: T,
20
20
  textToCopy: j,
21
21
  fixedOn: n,
22
- onClick: t = f,
22
+ onClick: t = u,
23
23
  ...p
24
24
  } = o, {
25
25
  copied: l,
@@ -29,7 +29,7 @@ function h(o) {
29
29
  t(s), i();
30
30
  }, [i, t]), a = _(e.root, { [e.copied]: l });
31
31
  return /* @__PURE__ */ r(
32
- u,
32
+ f,
33
33
  {
34
34
  title: m,
35
35
  fixedOn: n,
@@ -3,9 +3,9 @@ import d from "react";
3
3
  import { F as f } from "../../Combination-N-vN9BB-.js";
4
4
  import p from "../Button/Button.js";
5
5
  import { clsx as l } from "../../utils/clsx.js";
6
- import { noop as h } from "../../utils/functional.js";
7
6
  import "../../utils/links.js";
8
- import { Interactive as y } from "../Interactive/Interactive.js";
7
+ import { Interactive as h } from "../Interactive/Interactive.js";
8
+ import { noop as y } from "../../utils/functional.js";
9
9
  import "../../utils/hooks/useGlobalKeyboardEvent.js";
10
10
  import { useKeyboardClose as F } from "../../utils/hooks/useKeyboardClose.js";
11
11
  import { useOutlet as x } from "../../utils/hooks/useOutlet.js";
@@ -28,7 +28,7 @@ function I(c) {
28
28
  const {
29
29
  disabled: t = !1,
30
30
  size: s = "normal",
31
- onClose: r = h,
31
+ onClose: r = y,
32
32
  children: a,
33
33
  holderClassName: n
34
34
  } = c, m = x(E);
@@ -42,7 +42,7 @@ function I(c) {
42
42
  [o.active]: !t
43
43
  });
44
44
  return /* @__PURE__ */ e(m, { children: /* @__PURE__ */ i("div", { className: u, children: [
45
- /* @__PURE__ */ e(y, { showPointer: !1, className: o.backdrop, onClick: r }),
45
+ /* @__PURE__ */ e(h, { showPointer: !1, className: o.backdrop, onClick: r }),
46
46
  /* @__PURE__ */ e("div", { className: o.mask, children: /* @__PURE__ */ e("div", { className: l(o.holder, n), children: /* @__PURE__ */ e(f, { disabled: !!t, className: o.content, children: a }) }) })
47
47
  ] }) });
48
48
  }
@@ -1,9 +1,21 @@
1
1
  import { default as React } from 'react';
2
2
  import { ButtonBarProps } from '../Button';
3
+ import { IconBigName } from '../Icons';
4
+ import { ColorType } from '../../utils/ui';
3
5
 
6
+ export declare enum ModalThemeEnum {
7
+ default = "default",
8
+ danger = "danger",
9
+ success = "success",
10
+ warning = "warning"
11
+ }
12
+ export type ModalThemeType = keyof typeof ModalThemeEnum;
13
+ export declare const MODAL_THEME_TO_COLOR_MAP: Record<ModalThemeType, ColorType | undefined>;
4
14
  export interface ModalProps {
5
15
  children: React.ReactNode;
6
16
  onClose?: () => void;
17
+ color?: ColorType;
18
+ theme?: ModalThemeType;
7
19
  className?: string;
8
20
  overlayClassName?: string;
9
21
  backdropClassName?: string;
@@ -18,8 +30,30 @@ export declare namespace Modal {
18
30
  var Header: (props: ModalHeaderProps) => import("react/jsx-runtime").JSX.Element;
19
31
  var Footer: (props: ModalFooterProps) => import("react/jsx-runtime").JSX.Element;
20
32
  }
21
- export interface ModalHeaderProps {
33
+ export interface ModalHeaderIconProps {
34
+ theme?: ModalThemeType;
35
+ iconName?: IconBigName;
36
+ iconColor?: ColorType;
37
+ }
38
+ type ModalHeaderIconType = {
39
+ theme: ModalThemeType;
40
+ iconName?: never;
41
+ iconColor?: never;
42
+ icon?: never;
43
+ } | {
44
+ theme?: never;
45
+ iconName: IconBigName;
46
+ iconColor?: ColorType;
47
+ icon?: never;
48
+ } | {
49
+ theme?: never;
50
+ iconName?: never;
51
+ iconColor?: never;
52
+ icon?: React.ReactNode;
53
+ };
54
+ export type ModalHeaderProps = ModalHeaderIconType & {
22
55
  title: string;
23
56
  description?: React.ReactNode;
24
- }
57
+ };
25
58
  export type ModalFooterProps = ButtonBarProps;
59
+ export {};
@@ -1,60 +1,81 @@
1
- import { jsxs as i, jsx as a } from "react/jsx-runtime";
2
- import N from "react";
1
+ import { jsxs as d, jsx as a } from "react/jsx-runtime";
2
+ import B from "react";
3
3
  import "../Button/Button.js";
4
- import { ButtonBar as k } from "../Button/ButtonBar.js";
4
+ import { ButtonBar as M } from "../Button/ButtonBar.js";
5
5
  import "../../utils/links.js";
6
- import y from "../IconButton/IconButton.js";
7
- import { Overlay as t } from "../Overlay/Overlay.js";
8
- import { Text as m } from "../Text/Text.js";
9
- import "../../utils/ui/ui.js";
10
- import { clsx as s } from "../../utils/clsx.js";
6
+ import g from "../Flex/Flex.js";
7
+ import { clsx as i } from "../../utils/clsx.js";
8
+ import { IconBig as w } from "../IconBig/IconBig.js";
9
+ import O from "../IconButton/IconButton.js";
10
+ import { Overlay as u } from "../Overlay/Overlay.js";
11
+ import { Text as b } from "../Text/Text.js";
12
+ import { ui as C } from "../../utils/ui/ui.js";
13
+ import { ColorEnum as z } from "../../utils/ui/ui.types.js";
11
14
  import "../../utils/hooks/useGlobalKeyboardEvent.js";
12
- import { useKeyboardClose as x } from "../../utils/hooks/useKeyboardClose.js";
15
+ import { useKeyboardClose as F } from "../../utils/hooks/useKeyboardClose.js";
13
16
  import "../../index-Cl_RnsqN.js";
14
- const M = "cfxui__Modal__root__53283", B = "cfxui__Modal__close__2df9b", v = "cfxui__Modal__header__bec76", g = "cfxui__Modal__footer__bb2fc", r = {
15
- root: M,
16
- close: B,
17
- header: v,
18
- footer: g
17
+ const H = "cfxui__Modal__root__53283", I = "cfxui__Modal__colored__649d1", L = "cfxui__Modal__close__2df9b", T = "cfxui__Modal__header__bec76", j = "cfxui__Modal__footer__bb2fc", l = {
18
+ root: H,
19
+ colored: I,
20
+ close: L,
21
+ header: T,
22
+ footer: j
19
23
  };
20
- function _(c) {
24
+ var A = /* @__PURE__ */ ((o) => (o.default = "default", o.danger = "danger", o.success = "success", o.warning = "warning", o))(A || {});
25
+ const h = {
26
+ default: void 0,
27
+ danger: "red",
28
+ success: "green",
29
+ warning: "yellow"
30
+ };
31
+ function N(o) {
21
32
  const {
22
- onClose: o,
23
- children: l,
24
- className: e,
25
- overlayClassName: f,
26
- backdropClassName: p,
27
- contentClassName: b,
28
- ariaDescribedby: u,
29
- ariaLabelledby: h,
30
- disableBackdropClose: d = !1,
31
- disableFocusLock: C = !1
32
- } = c, n = N.useCallback(() => {
33
- d || !o || o();
34
- }, [o, d]);
35
- return x(n), /* @__PURE__ */ i(t, { className: s(r.overlay, f), children: [
33
+ theme: r = "default",
34
+ color: c,
35
+ onClose: e,
36
+ children: t,
37
+ className: s,
38
+ overlayClassName: m,
39
+ backdropClassName: f,
40
+ contentClassName: y,
41
+ ariaDescribedby: v,
42
+ ariaLabelledby: x,
43
+ disableBackdropClose: _ = !1,
44
+ disableFocusLock: k = !1
45
+ } = o, p = B.useCallback(() => {
46
+ _ || !e || e();
47
+ }, [e, _]);
48
+ F(p);
49
+ const n = c || h[r];
50
+ return /* @__PURE__ */ d(u, { className: i(l.overlay, m), children: [
36
51
  /* @__PURE__ */ a(
37
- t.Backdrop,
52
+ u.Backdrop,
38
53
  {
39
- onClick: n,
40
- className: s(r.backdrop, p)
54
+ onClick: p,
55
+ className: i(l.backdrop, f)
41
56
  }
42
57
  ),
43
58
  /* @__PURE__ */ a(
44
- t.Content,
59
+ u.Content,
45
60
  {
46
- className: b,
47
- disableFocusLock: C,
48
- children: /* @__PURE__ */ i(
61
+ className: y,
62
+ disableFocusLock: k,
63
+ children: /* @__PURE__ */ d(
49
64
  "div",
50
65
  {
51
66
  role: "dialog",
52
- "aria-describedby": u,
53
- "aria-labelledby": h,
54
- className: s(r.root, e),
67
+ "aria-describedby": v,
68
+ "aria-labelledby": x,
69
+ className: i(l.root, s, {
70
+ [l.colored]: !!n
71
+ }),
72
+ style: {
73
+ "--modal-color": n ? C.color(n) : void 0,
74
+ "--modal-color-bg": n ? C.color(n, void 0, 0.2) : void 0
75
+ },
55
76
  children: [
56
- !!o && /* @__PURE__ */ a(y, { areaSize: "large", className: r.close, name: "Close", onClick: o }),
57
- l
77
+ !!e && /* @__PURE__ */ a(O, { areaSize: "large", className: l.close, name: "Close", onClick: e }),
78
+ t
58
79
  ]
59
80
  }
60
81
  )
@@ -62,37 +83,82 @@ function _(c) {
62
83
  )
63
84
  ] });
64
85
  }
65
- _.Header = function(o) {
86
+ function D(o) {
87
+ switch (o) {
88
+ case "danger":
89
+ return "Warni";
90
+ case "success":
91
+ return "Confirm";
92
+ default:
93
+ return;
94
+ }
95
+ }
96
+ function P(o) {
66
97
  const {
67
- title: l,
68
- description: e
98
+ theme: r = "default",
99
+ iconName: c,
100
+ iconColor: e
69
101
  } = o;
70
- return /* @__PURE__ */ i("div", { className: r.header, children: [
71
- /* @__PURE__ */ a(
72
- m,
102
+ if (!c && !r)
103
+ return null;
104
+ const t = c || D(r), s = e || h[r] || z.primary;
105
+ return t ? /* @__PURE__ */ a(g, { centered: !0, children: /* @__PURE__ */ a(
106
+ w,
107
+ {
108
+ name: t,
109
+ color: s,
110
+ size: "normal"
111
+ }
112
+ ) }) : null;
113
+ }
114
+ N.Header = function(r) {
115
+ const {
116
+ title: c,
117
+ description: e,
118
+ theme: t = "default",
119
+ icon: s,
120
+ iconName: m,
121
+ iconColor: f
122
+ } = r;
123
+ return /* @__PURE__ */ d(g, { vertical: !0, gap: "large", children: [
124
+ s || /* @__PURE__ */ a(
125
+ P,
73
126
  {
74
- weight: "bold",
75
- size: "large",
76
- children: l
127
+ theme: t,
128
+ iconName: m,
129
+ iconColor: f
77
130
  }
78
131
  ),
79
- e && /* @__PURE__ */ a(
80
- m,
81
- {
82
- size: "small",
83
- color: "secondary",
84
- children: e
85
- }
86
- )
132
+ /* @__PURE__ */ d("div", { className: l.header, children: [
133
+ /* @__PURE__ */ a(
134
+ b,
135
+ {
136
+ weight: "bold",
137
+ size: "large",
138
+ children: c
139
+ }
140
+ ),
141
+ e && /* @__PURE__ */ a(
142
+ b,
143
+ {
144
+ size: "small",
145
+ color: "secondary",
146
+ typographic: !0,
147
+ children: e
148
+ }
149
+ )
150
+ ] })
87
151
  ] });
88
152
  };
89
- _.Footer = function(o) {
153
+ N.Footer = function(r) {
90
154
  const {
91
- className: l,
155
+ className: c,
92
156
  ...e
93
- } = o;
94
- return /* @__PURE__ */ a(k, { ...e, className: s(r.footer, l) });
157
+ } = r;
158
+ return /* @__PURE__ */ a(M, { ...e, className: i(l.footer, c) });
95
159
  };
96
160
  export {
97
- _ as Modal
161
+ h as MODAL_THEME_TO_COLOR_MAP,
162
+ N as Modal,
163
+ A as ModalThemeEnum
98
164
  };
@@ -1,17 +1,17 @@
1
1
  import { jsxs as e, jsx as o } from "react/jsx-runtime";
2
- import i from "react";
2
+ import r from "react";
3
3
  import n from "../Box/Box.js";
4
4
  import "../../utils/ui/ui.js";
5
- import l from "../Button/Button.js";
5
+ import i from "../Button/Button.js";
6
6
  import "../../utils/links.js";
7
- import p from "../Input/Input.js";
7
+ import c from "../Input/Input.js";
8
8
  import "../../utils/hooks/useGlobalKeyboardEvent.js";
9
9
  import "../../utils/hooks/useKeyboardClose.js";
10
10
  import "../../index-Cl_RnsqN.js";
11
- import { LOREM_IPSUM as c } from "../../utils/loremipsum.js";
12
- import { Modal as r } from "./Modal.js";
11
+ import { LOREM_IPSUM as p } from "../../utils/loremipsum.js";
12
+ import { Modal as l } from "./Modal.js";
13
13
  function s() {
14
- const [d, m] = i.useState(!1), t = i.useCallback(() => m((a) => !a), []);
14
+ const [a, d] = r.useState(!1), t = r.useCallback(() => d((m) => !m), []);
15
15
  return /* @__PURE__ */ e(
16
16
  "div",
17
17
  {
@@ -22,16 +22,24 @@ function s() {
22
22
  children: [
23
23
  /* @__PURE__ */ o("div", { id: "backdrop" }),
24
24
  /* @__PURE__ */ o("div", { id: "overlay-outlet" }),
25
- /* @__PURE__ */ o(l, { theme: "primary", onClick: t, text: "Toggle Modal" }),
26
- d && /* @__PURE__ */ e(r, { onClose: t, children: [
27
- /* @__PURE__ */ o(r.Header, { title: "Modal Title", description: "Modal Description" }),
28
- /* @__PURE__ */ o(n, { mb: 4, children: /* @__PURE__ */ o(p, { theme: "onlight", placeholder: "Input", fullWidth: !0 }) }),
25
+ /* @__PURE__ */ o(i, { theme: "primary", onClick: t, text: "Toggle Modal" }),
26
+ a && /* @__PURE__ */ e(l, { onClose: t, children: [
27
+ /* @__PURE__ */ o(
28
+ l.Header,
29
+ {
30
+ iconName: "Subscriptions",
31
+ iconColor: "accent",
32
+ title: "Modal Title",
33
+ description: "Modal Description"
34
+ }
35
+ ),
36
+ /* @__PURE__ */ o(n, { mb: 4, children: /* @__PURE__ */ o(c, { theme: "onlight", placeholder: "Input", fullWidth: !0 }) }),
29
37
  "Modal content:",
30
38
  " ",
31
- c,
32
- /* @__PURE__ */ e(r.Footer, { children: [
39
+ p,
40
+ /* @__PURE__ */ e(l.Footer, { children: [
33
41
  /* @__PURE__ */ o(
34
- l,
42
+ i,
35
43
  {
36
44
  fullWidth: !0,
37
45
  theme: "secondary",
@@ -40,7 +48,7 @@ function s() {
40
48
  }
41
49
  ),
42
50
  /* @__PURE__ */ o(
43
- l,
51
+ i,
44
52
  {
45
53
  fullWidth: !0,
46
54
  theme: "primary",
@@ -54,7 +62,7 @@ function s() {
54
62
  }
55
63
  );
56
64
  }
57
- const b = i.memo(s);
65
+ const w = r.memo(s);
58
66
  export {
59
- b as default
67
+ w as default
60
68
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfx-dev/ui-components",
3
3
  "private": false,
4
- "version": "4.5.3",
4
+ "version": "4.5.4",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "dist/main.js",