@cfx-dev/ui-components 0.0.21 → 0.0.22

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.
@@ -21,4 +21,6 @@ export interface ButtonProps {
21
21
  onMouseUp?: (event: React.MouseEvent<HTMLButtonElement>) => void;
22
22
  decorator?: React.ReactNode;
23
23
  }
24
+ export declare function ButtonContent(props: Partial<ButtonProps>): React.ReactNode;
25
+ export declare function getButtonClassName(props: Partial<ButtonProps>): string;
24
26
  export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -1,59 +1,105 @@
1
- import { jsxs as w, jsx as i } from "react/jsx-runtime";
2
- import B from "react";
3
- import { clsx as M } from "../../utils/clsx.js";
4
- import { noop as n } from "../../utils/functional.js";
5
- import { s as o } from "../../Button.module-Z6njvP9Z.js";
6
- const I = B.forwardRef(function(c, u) {
1
+ import { jsx as c, jsxs as j, Fragment as w } from "react/jsx-runtime";
2
+ import b from "react";
3
+ import { clsx as z } from "../../utils/clsx.js";
4
+ import { noop as p } from "../../utils/functional.js";
5
+ import { s as t } from "../../Button.module-Z6njvP9Z.js";
6
+ function F(a) {
7
7
  const {
8
- text: t = null,
9
- icon: e = null,
10
- title: d = "",
11
- type: f = "button",
12
- className: m = "",
13
- theme: p = "default",
14
- size: h = "normal",
15
- disabled: l = !1,
16
- straightCorners: b = !1,
17
- onClick: x = n,
18
- onMouseDown: C = n,
19
- onMouseUp: N = n,
20
- autofocus: a = !1,
21
- fullWidth: k = !1,
22
- tabIndex: s,
23
- decorator: r = null,
24
- ariaLabel: y = ""
25
- } = c, g = M(o.root, o[p], o[h], m, {
26
- [o.disabled]: l,
27
- [o.icon]: !!e && (t === null || typeof t > "u"),
28
- [o.text]: !!t,
29
- [o.autofocus]: a || typeof s < "u",
30
- [o["straight-borders"]]: b,
31
- [o.fullWidth]: k
8
+ text: e = null,
9
+ icon: l = null,
10
+ decorator: o = null
11
+ } = a;
12
+ return /* @__PURE__ */ j(w, { children: [
13
+ !!l && /* @__PURE__ */ c("span", { className: t["icon-node"], children: l }),
14
+ e,
15
+ !!o && /* @__PURE__ */ c("div", { className: t.decorator, children: o })
16
+ ] });
17
+ }
18
+ function I(a) {
19
+ const {
20
+ text: e = null,
21
+ icon: l = null,
22
+ theme: o = "default",
23
+ size: s = "normal",
24
+ disabled: f = !1,
25
+ straightCorners: d = !1,
26
+ className: r = "",
27
+ autofocus: u = !1,
28
+ fullWidth: i = !1,
29
+ tabIndex: n
30
+ } = a;
31
+ return z(t.root, t[o], t[s], r, {
32
+ [t.disabled]: f,
33
+ [t.icon]: !!l && (e === null || typeof e > "u"),
34
+ [t.text]: !!e,
35
+ [t.autofocus]: u || typeof n < "u",
36
+ [t["straight-borders"]]: d,
37
+ [t.fullWidth]: i
32
38
  });
33
- return /* @__PURE__ */ w(
39
+ }
40
+ const U = b.forwardRef(function(e, l) {
41
+ const {
42
+ text: o = null,
43
+ icon: s = null,
44
+ title: f = "",
45
+ type: d = "button",
46
+ className: r = "",
47
+ theme: u = "default",
48
+ size: i = "normal",
49
+ disabled: n = !1,
50
+ straightCorners: x = !1,
51
+ onClick: C = p,
52
+ onMouseDown: g = p,
53
+ onMouseUp: k = p,
54
+ autofocus: m = !1,
55
+ fullWidth: N = !1,
56
+ tabIndex: h,
57
+ ariaLabel: B = ""
58
+ } = e, y = b.useMemo(() => I({
59
+ text: o,
60
+ icon: s,
61
+ theme: u,
62
+ size: i,
63
+ disabled: n,
64
+ straightCorners: x,
65
+ className: r,
66
+ autofocus: m,
67
+ fullWidth: N,
68
+ tabIndex: h
69
+ }), [
70
+ m,
71
+ r,
72
+ n,
73
+ N,
74
+ s,
75
+ i,
76
+ x,
77
+ h,
78
+ o,
79
+ u
80
+ ]), M = b.useCallback((W) => {
81
+ n || C(W);
82
+ }, [n, C]);
83
+ return /* @__PURE__ */ c(
34
84
  "button",
35
85
  {
36
- ref: u,
37
- disabled: l,
38
- className: g,
39
- onClick: (j) => {
40
- l || x(j);
41
- },
42
- onMouseDown: C,
43
- onMouseUp: N,
44
- autoFocus: a,
45
- tabIndex: s,
46
- title: d,
47
- type: f,
48
- "aria-label": y,
49
- children: [
50
- !!e && /* @__PURE__ */ i("span", { className: o["icon-node"], children: e }),
51
- t,
52
- !!r && /* @__PURE__ */ i("div", { className: o.decorator, children: r })
53
- ]
86
+ ref: l,
87
+ disabled: n,
88
+ className: y,
89
+ onClick: M,
90
+ onMouseDown: g,
91
+ onMouseUp: k,
92
+ autoFocus: m,
93
+ tabIndex: h,
94
+ title: f,
95
+ type: d,
96
+ "aria-label": B,
97
+ children: /* @__PURE__ */ c(F, { ...e })
54
98
  }
55
99
  );
56
100
  });
57
101
  export {
58
- I as Button
102
+ U as Button,
103
+ F as ButtonContent,
104
+ I as getButtonClassName
59
105
  };
@@ -1,19 +1,11 @@
1
1
  import { default as React } from 'react';
2
- import { ButtonSize, ButtonTheme } from './Button';
2
+ import { ButtonProps } from './Button';
3
3
 
4
- export interface LinkButtonProps {
4
+ export interface LinkButtonProps extends Omit<ButtonProps, 'autofocus' | 'onCLick' | 'onMouseDown' | 'onMouseUp' | 'ariaLabel'> {
5
5
  to: string;
6
- text?: React.ReactNode;
7
- title?: string;
8
- icon?: React.ReactNode;
9
- theme?: ButtonTheme;
10
- size?: ButtonSize;
11
- disabled?: boolean;
6
+ isHrefProp?: boolean;
12
7
  onClick?(): void;
13
- tabIndex?: number;
14
- className?: string;
15
8
  target?: string;
16
9
  Component?: React.ElementType;
17
- decorator?: React.ReactNode;
18
10
  }
19
11
  export declare const LinkButton: React.ForwardRefExoticComponent<LinkButtonProps & React.RefAttributes<HTMLAnchorElement>>;
@@ -1,48 +1,33 @@
1
- import { jsxs as R, jsx as l } from "react/jsx-runtime";
2
- import a from "react";
3
- import { clsx as j } from "../../utils/clsx.js";
4
- import { noop as B } from "../../utils/functional.js";
5
- import { isExternalUrl as E } from "../../utils/links.js";
6
- import { s as o } from "../../Button.module-Z6njvP9Z.js";
7
- const P = a.forwardRef(function(i, c) {
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import n from "react";
3
+ import { noop as k } from "../../utils/functional.js";
4
+ import { isExternalUrl as d } from "../../utils/links.js";
5
+ import { getButtonClassName as x, ButtonContent as B } from "./Button.js";
6
+ const M = n.forwardRef(function(t, a) {
8
7
  const {
9
- to: e,
10
- text: t = null,
11
- icon: n = null,
8
+ to: o,
12
9
  title: m = "",
13
- className: d = "",
14
- theme: f = "default",
15
- size: p = "normal",
16
- disabled: u = !1,
17
- tabIndex: x,
18
- target: k = "",
19
- onClick: C = B,
20
- decorator: s = null,
21
- Component: h
22
- } = i, N = j(o.root, o[f], o[p], d, {
23
- [o.disabled]: u,
24
- [o.icon]: !!n && !t,
25
- [o.text]: !!t
26
- }), r = E(e), b = r ? "a" : h || "a", L = a.useMemo(() => r ? { href: e } : { to: e }, [e, r]);
27
- return /* @__PURE__ */ R(
28
- b,
10
+ tabIndex: s,
11
+ target: f = "",
12
+ onClick: l = k,
13
+ isHrefProp: r = !1,
14
+ Component: c
15
+ } = t, u = n.useMemo(() => x(t), [t]), e = d(o), C = e ? "a" : c || "a", p = n.useMemo(() => e || r ? { href: o } : { to: o }, [o, e, r]);
16
+ return /* @__PURE__ */ i(
17
+ C,
29
18
  {
30
- ref: c,
31
- className: N,
32
- tabIndex: x,
19
+ ref: a,
20
+ className: u,
21
+ tabIndex: s,
33
22
  title: m,
34
- target: k,
23
+ target: f,
35
24
  rel: "noopener noreferrer",
36
- onClickCapture: C,
37
- ...L,
38
- children: [
39
- !!n && /* @__PURE__ */ l("span", { className: o["icon-node"], children: n }),
40
- t,
41
- !!s && /* @__PURE__ */ l("div", { className: o.decorator, children: s })
42
- ]
25
+ onClickCapture: l,
26
+ ...p,
27
+ children: /* @__PURE__ */ i(B, { ...t })
43
28
  }
44
29
  );
45
30
  });
46
31
  export {
47
- P as LinkButton
32
+ M as LinkButton
48
33
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfx-dev/ui-components",
3
3
  "private": false,
4
- "version": "0.0.21",
4
+ "version": "0.0.22",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "dist/main.js",