@cfx-dev/ui-components 4.1.1 → 4.2.0

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,7 +1,9 @@
1
1
  import { default as React } from 'react';
2
+ import { ResponsiveValueType } from '../ui';
2
3
 
3
4
  export type TabularTheme = 'light' | 'dark';
4
5
  export type TabularRole = 'tablist' | 'navigation';
6
+ export type TabularSize = 'large' | 'medium' | 'small';
5
7
  export interface TabularItem {
6
8
  id: string;
7
9
  label: React.ReactNode;
@@ -20,16 +22,19 @@ export interface TabularProps {
20
22
  tabIndex?: number;
21
23
  theme?: TabularTheme;
22
24
  role?: TabularRole;
25
+ size?: ResponsiveValueType<TabularSize>;
23
26
  }
24
27
  export declare function Tabular(props: TabularProps): import("react/jsx-runtime").JSX.Element;
25
28
  export declare namespace Tabular {
26
29
  var Root: (props: TabularRootProps) => import("react/jsx-runtime").JSX.Element;
27
30
  var Item: (props: TabularItemProps) => import("react/jsx-runtime").JSX.Element;
28
31
  }
29
- export interface TabularRootProps extends React.PropsWithChildren, Pick<TabularProps, 'className' | 'ariaLabel' | 'tabIndex' | 'theme' | 'role'> {
32
+ export interface TabularRootProps extends React.PropsWithChildren, Pick<TabularProps, 'className' | 'ariaLabel' | 'tabIndex' | 'theme' | 'role' | 'size'> {
33
+ style?: React.CSSProperties;
30
34
  }
31
35
  export interface TabularItemProps extends TabularItem {
32
36
  active: boolean;
33
37
  onClick: (id: string) => void;
34
38
  className?: string;
39
+ size?: ResponsiveValueType<TabularSize>;
35
40
  }
@@ -1,94 +1,123 @@
1
- import { jsx as n, jsxs as x } from "react/jsx-runtime";
2
- import b, { createElement as T } from "react";
3
- import { Dot as k } from "../Dot/Dot.js";
4
- import { clsx as d } from "../../utils/clsx.js";
5
- const v = "cfxui__Tabular__reset__b1dbc", C = "cfxui__Tabular__root__0ff05", p = "cfxui__Tabular__item__98cc3", I = "cfxui__Tabular__active__1ae95", R = "cfxui__Tabular__hasNotification__c372f", g = "cfxui__Tabular__content__3a95a", e = {
1
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
2
+ import d, { createElement as N } from "react";
3
+ import { Dot as p } from "../Dot/Dot.js";
4
+ import { ui as C } from "../ui.js";
5
+ import { clsx as n } from "../../utils/clsx.js";
6
+ const v = "cfxui__Tabular__reset__b1dbc", k = "cfxui__Tabular__item__98cc3", I = "cfxui__Tabular__root__0ff05", R = "cfxui__Tabular__active__1ae95", y = "cfxui__Tabular__hasNotification__c372f", j = "cfxui__Tabular__content__3a95a", l = {
6
7
  reset: v,
7
- root: C,
8
+ "tabular-size-initial-large": "cfxui__Tabular__tabular-size-initial-large__9451f",
9
+ item: k,
10
+ "tabular-size-initial-small": "cfxui__Tabular__tabular-size-initial-small__4dad8",
11
+ "tabular-size-small-large": "cfxui__Tabular__tabular-size-small-large__1390c",
12
+ "tabular-size-small-small": "cfxui__Tabular__tabular-size-small-small__cc6e3",
13
+ "tabular-size-small-medium-large": "cfxui__Tabular__tabular-size-small-medium-large__241e8",
14
+ "tabular-size-small-medium-small": "cfxui__Tabular__tabular-size-small-medium-small__b6c66",
15
+ "tabular-size-medium-large": "cfxui__Tabular__tabular-size-medium-large__2ff04",
16
+ "tabular-size-medium-small": "cfxui__Tabular__tabular-size-medium-small__b397b",
17
+ "tabular-size-medium-large-large": "cfxui__Tabular__tabular-size-medium-large-large__8b35a",
18
+ "tabular-size-medium-large-small": "cfxui__Tabular__tabular-size-medium-large-small__cec0c",
19
+ "tabular-size-large-large": "cfxui__Tabular__tabular-size-large-large__e3c30",
20
+ "tabular-size-large-small": "cfxui__Tabular__tabular-size-large-small__193f0",
21
+ "tabular-size-xlarge-large": "cfxui__Tabular__tabular-size-xlarge-large__e1e19",
22
+ "tabular-size-xlarge-small": "cfxui__Tabular__tabular-size-xlarge-small__9c3b6",
23
+ root: I,
8
24
  "theme-dark": "cfxui__Tabular__theme-dark__80b8c",
9
25
  "theme-light": "cfxui__Tabular__theme-light__c05b9",
10
- item: p,
11
- active: I,
12
- hasNotification: R,
13
- content: g
26
+ active: R,
27
+ hasNotification: y,
28
+ content: j
14
29
  };
15
- function _(m) {
30
+ function o(b) {
16
31
  const {
17
- items: i,
18
- activeItem: o,
19
- onActivate: t,
20
- itemClassName: c,
21
- ...s
22
- } = m, l = b.useCallback((a) => {
23
- t && t(a);
24
- }, [t]);
25
- return /* @__PURE__ */ n(_.Root, { ...s, children: i.map((a) => /* @__PURE__ */ T(
26
- _.Item,
32
+ items: s,
33
+ activeItem: t,
34
+ onActivate: e,
35
+ itemClassName: i,
36
+ size: u = "medium",
37
+ ..._
38
+ } = b, c = d.useCallback((a) => {
39
+ e && e(a);
40
+ }, [e]), r = n(
41
+ l.root,
42
+ _.className
43
+ );
44
+ return /* @__PURE__ */ m(o.Root, { ..._, className: r, children: s.map((a) => /* @__PURE__ */ N(
45
+ o.Item,
27
46
  {
28
47
  ...a,
29
- className: c,
48
+ className: i,
30
49
  key: a.id,
31
- active: a.id === o,
32
- onClick: l
50
+ active: a.id === t,
51
+ onClick: c,
52
+ size: u
33
53
  }
34
54
  )) });
35
55
  }
36
- _.Root = function(i) {
56
+ o.Root = function(s) {
37
57
  const {
38
- children: o,
39
- className: t,
40
- ariaLabel: c,
41
- tabIndex: s,
42
- theme: l = "dark",
43
- role: a = "tablist"
44
- } = i, r = d(e.root, e[`theme-${l}`], t);
45
- return /* @__PURE__ */ n(
58
+ children: t,
59
+ className: e,
60
+ ariaLabel: i,
61
+ tabIndex: u,
62
+ theme: _ = "dark",
63
+ role: c = "tablist",
64
+ style: r
65
+ } = s, a = n(l.root, l[`theme-${_}`], e);
66
+ return /* @__PURE__ */ m(
46
67
  "div",
47
68
  {
48
- role: a,
49
- "aria-label": c,
50
- tabIndex: s,
51
- className: r,
52
- children: o
69
+ role: c,
70
+ "aria-label": i,
71
+ tabIndex: u,
72
+ className: a,
73
+ style: r,
74
+ children: t
53
75
  }
54
76
  );
55
77
  };
56
- _.Item = function(i) {
78
+ o.Item = function(s) {
57
79
  const {
58
- id: o,
59
- label: t,
60
- onClick: c,
61
- ariaLabel: s,
62
- ariaControls: l,
63
- className: a,
80
+ id: t,
81
+ label: e,
82
+ onClick: i,
83
+ ariaLabel: u,
84
+ ariaControls: _,
85
+ className: c,
64
86
  active: r = !1,
65
- disabled: f = !1,
66
- hasNotification: u = !1
67
- } = i, h = b.useCallback(() => {
68
- f || c(o);
69
- }, [f, c, o]), N = d(e.reset, e.item, a, {
70
- [e.active]: r,
71
- [e.hasNotification]: u
72
- });
73
- return /* @__PURE__ */ n(
87
+ disabled: a = !1,
88
+ hasNotification: f = !1,
89
+ size: x
90
+ } = s, z = d.useCallback(() => {
91
+ a || i(t);
92
+ }, [a, i, t]), g = n(
93
+ l.reset,
94
+ l.item,
95
+ c,
96
+ C.getResponsiveFlatClassnames("tabular-size", x).map((T) => l[T]),
97
+ {
98
+ [l.active]: r,
99
+ [l.hasNotification]: f
100
+ }
101
+ );
102
+ return /* @__PURE__ */ m(
74
103
  "button",
75
104
  {
76
- disabled: f,
105
+ disabled: a,
77
106
  type: "button",
78
107
  role: "tab",
79
- className: N,
80
- onClick: h,
81
- "aria-label": s,
82
- "aria-controls": l,
83
- "data-text": t,
108
+ className: g,
109
+ onClick: z,
110
+ "aria-label": u,
111
+ "aria-controls": _,
112
+ "data-text": e,
84
113
  "aria-selected": r,
85
- children: /* @__PURE__ */ x("span", { className: e.content, children: [
86
- t,
87
- u && /* @__PURE__ */ n(k, { color: "green", className: e.notification })
114
+ children: /* @__PURE__ */ h("span", { className: l.content, children: [
115
+ e,
116
+ f && /* @__PURE__ */ m(p, { color: "green", className: l.notification })
88
117
  ] })
89
118
  }
90
119
  );
91
120
  };
92
121
  export {
93
- _ as Tabular
122
+ o as Tabular
94
123
  };
@@ -1,10 +1,10 @@
1
- import { jsxs as e, jsx as t } from "react/jsx-runtime";
2
- import a from "react";
1
+ import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
+ import o from "react";
3
3
  import { Flex as i } from "../Layout/Flex/Flex.js";
4
- import { Text as m } from "../Text/Text.js";
4
+ import { Text as l } from "../Text/Text.js";
5
5
  import "../ui.js";
6
- import { Tabular as r } from "./Tabular.js";
7
- const l = [
6
+ import { Tabular as m } from "./Tabular.js";
7
+ const c = [
8
8
  {
9
9
  id: "item1",
10
10
  label: "Item 1"
@@ -33,34 +33,59 @@ const l = [
33
33
  disabled: !0
34
34
  }
35
35
  ];
36
- function d() {
37
- const [o, c] = a.useState("item1"), [n, s] = a.useState(void 0);
38
- return /* @__PURE__ */ e(i, { gap: "large", vertical: !0, children: [
39
- /* @__PURE__ */ e(i, { gap: "normal", vertical: !0, children: [
40
- /* @__PURE__ */ t(m, { children: "With default activeItem" }),
41
- /* @__PURE__ */ t(
42
- r,
36
+ function n() {
37
+ const [a, r] = o.useState("item1");
38
+ return /* @__PURE__ */ t(i, { gap: "large", vertical: !0, children: [
39
+ /* @__PURE__ */ t(i, { gap: "normal", vertical: !0, children: [
40
+ /* @__PURE__ */ e(l, { children: "Default" }),
41
+ /* @__PURE__ */ e(
42
+ m,
43
43
  {
44
- items: l,
45
- activeItem: o,
46
- onActivate: c
44
+ items: c,
45
+ activeItem: a,
46
+ onActivate: r
47
47
  }
48
48
  )
49
49
  ] }),
50
- /* @__PURE__ */ e(i, { gap: "normal", vertical: !0, children: [
51
- /* @__PURE__ */ t(m, { children: "Without activeItem" }),
52
- /* @__PURE__ */ t(
53
- r,
50
+ /* @__PURE__ */ t(i, { gap: "normal", vertical: !0, children: [
51
+ /* @__PURE__ */ e(l, { children: "Size small" }),
52
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
53
+ m,
54
54
  {
55
- items: l,
56
- activeItem: n,
57
- onActivate: s
55
+ size: "small",
56
+ items: c,
57
+ activeItem: a,
58
+ onActivate: r
58
59
  }
59
- )
60
+ ) })
61
+ ] }),
62
+ /* @__PURE__ */ t(i, { gap: "normal", vertical: !0, children: [
63
+ /* @__PURE__ */ e(l, { children: "Size medium" }),
64
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
65
+ m,
66
+ {
67
+ size: "medium",
68
+ items: c,
69
+ activeItem: a,
70
+ onActivate: r
71
+ }
72
+ ) })
73
+ ] }),
74
+ /* @__PURE__ */ t(i, { gap: "normal", vertical: !0, children: [
75
+ /* @__PURE__ */ e(l, { children: "Size large" }),
76
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
77
+ m,
78
+ {
79
+ size: "large",
80
+ items: c,
81
+ activeItem: a,
82
+ onActivate: r
83
+ }
84
+ ) })
60
85
  ] })
61
86
  ] });
62
87
  }
63
- const p = a.memo(d);
88
+ const I = o.memo(n);
64
89
  export {
65
- p as default
90
+ I as default
66
91
  };
@@ -13,5 +13,6 @@ export interface ToggleGroupProps {
13
13
  className?: string;
14
14
  disabled?: boolean;
15
15
  multiline?: boolean;
16
+ fullWidth?: boolean;
16
17
  }
17
18
  export declare const ToggleGroup: React.NamedExoticComponent<ToggleGroupProps>;
@@ -1,46 +1,48 @@
1
- import { jsxs as a, jsx as u } from "react/jsx-runtime";
2
- import l from "react";
1
+ import { jsxs as d, jsx as p } from "react/jsx-runtime";
2
+ import n from "react";
3
3
  import { Interactive as C } from "../Interactive/Interactive.js";
4
- import { clsx as d } from "../../utils/clsx.js";
5
- const M = "cfxui__ToggleGroup__root__fb460", D = "cfxui__ToggleGroup__disabled__75462", j = "cfxui__ToggleGroup__descripted__8e168", k = "cfxui__ToggleGroup__multiline__6b784", E = "cfxui__ToggleGroup__options__7bc0c", L = "cfxui__ToggleGroup__option__8436c", O = "cfxui__ToggleGroup__description__9429c", S = "cfxui__ToggleGroup__active__84da0", o = {
4
+ import { clsx as _ } from "../../utils/clsx.js";
5
+ const M = "cfxui__ToggleGroup__root__fb460", D = "cfxui__ToggleGroup__disabled__75462", j = "cfxui__ToggleGroup__descripted__8e168", k = "cfxui__ToggleGroup__multiline__6b784", E = "cfxui__ToggleGroup__options__7bc0c", L = "cfxui__ToggleGroup__option__8436c", O = "cfxui__ToggleGroup__fullWidth__0c589", S = "cfxui__ToggleGroup__description__9429c", w = "cfxui__ToggleGroup__active__84da0", o = {
6
6
  root: M,
7
7
  disabled: D,
8
8
  descripted: j,
9
9
  multiline: k,
10
10
  options: E,
11
11
  option: L,
12
- description: O,
13
- active: S
14
- }, p = (_, s) => {
12
+ fullWidth: O,
13
+ description: S,
14
+ active: w
15
+ }, f = (r, s) => {
15
16
  var e;
16
- return ((e = s.find((i) => i.value === _)) == null ? void 0 : e.description) || "";
17
- }, y = l.memo(function(s) {
17
+ return ((e = s.find((i) => i.value === r)) == null ? void 0 : e.description) || "";
18
+ }, z = n.memo(function(s) {
18
19
  const {
19
20
  value: e,
20
21
  options: i,
21
- onChange: r,
22
+ onChange: u,
22
23
  className: m = "",
23
24
  disabled: g = !1,
24
- multiline: f = !1
25
- } = s, [c, n] = l.useState(p(e, i)), v = l.useMemo(
26
- () => i.map((t, b) => {
27
- const h = () => {
28
- r(t.value);
29
- }, G = () => {
30
- n(t.description || "");
31
- }, T = () => {
32
- n(p(e, i));
33
- }, N = d(o.option, {
25
+ multiline: h = !1,
26
+ fullWidth: a = !1
27
+ } = s, [c, l] = n.useState(f(e, i)), v = n.useMemo(
28
+ () => i.map((t, G) => {
29
+ const T = () => {
30
+ u(t.value);
31
+ }, b = () => {
32
+ l(t.description || "");
33
+ }, N = () => {
34
+ l(f(e, i));
35
+ }, W = _(o.option, {
34
36
  [o.active]: t.value === e
35
37
  });
36
- return /* @__PURE__ */ a(
38
+ return /* @__PURE__ */ d(
37
39
  C,
38
40
  {
39
- className: N,
40
- tabIndex: b,
41
- onClick: h,
42
- onMouseEnter: G,
43
- onMouseLeave: T,
41
+ className: W,
42
+ tabIndex: G,
43
+ onClick: T,
44
+ onMouseEnter: b,
45
+ onMouseLeave: N,
44
46
  children: [
45
47
  t.icon || null,
46
48
  t.label
@@ -49,17 +51,18 @@ const M = "cfxui__ToggleGroup__root__fb460", D = "cfxui__ToggleGroup__disabled__
49
51
  t.value
50
52
  );
51
53
  }),
52
- [e, i, r, n]
53
- ), x = d(o.root, m, {
54
+ [e, i, u, l]
55
+ ), x = _(o.root, m, {
54
56
  [o.disabled]: g,
55
57
  [o.descripted]: c,
56
- [o.multiline]: f
58
+ [o.multiline]: h,
59
+ [o.fullWidth]: a
57
60
  });
58
- return /* @__PURE__ */ a("div", { className: x, children: [
59
- /* @__PURE__ */ u("div", { className: o.options, children: v }),
60
- c && /* @__PURE__ */ u("div", { className: o.description, children: c })
61
+ return /* @__PURE__ */ d("div", { className: x, children: [
62
+ /* @__PURE__ */ p("div", { className: _(o.options, { [o.fullWidth]: a }), children: v }),
63
+ c && /* @__PURE__ */ p("div", { className: o.description, children: c })
61
64
  ] });
62
65
  });
63
66
  export {
64
- y as ToggleGroup
67
+ z as ToggleGroup
65
68
  };
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare function ToggleGroupShowcase(): import("react/jsx-runtime").JSX.Element;
4
+ declare const _default: React.MemoExoticComponent<typeof ToggleGroupShowcase>;
5
+ export default _default;
@@ -0,0 +1,60 @@
1
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
+ import u from "react";
3
+ import { Flex as r } from "../Layout/Flex/Flex.js";
4
+ import { Text as a } from "../Text/Text.js";
5
+ import "../ui.js";
6
+ import { ToggleGroup as i } from "./ToggleGroup.js";
7
+ const n = [
8
+ {
9
+ value: "weekly",
10
+ label: "Weekly"
11
+ },
12
+ {
13
+ value: "monthly",
14
+ label: "Monthly"
15
+ }
16
+ ];
17
+ function c() {
18
+ const [o, t] = u.useState("weekly");
19
+ return /* @__PURE__ */ l(r, { gap: "large", vertical: !0, children: [
20
+ /* @__PURE__ */ l(r, { gap: "normal", vertical: !0, children: [
21
+ /* @__PURE__ */ e(a, { children: "Default ToggleGroup" }),
22
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
23
+ i,
24
+ {
25
+ value: o,
26
+ onChange: t,
27
+ options: n
28
+ }
29
+ ) })
30
+ ] }),
31
+ /* @__PURE__ */ l(r, { gap: "normal", vertical: !0, children: [
32
+ /* @__PURE__ */ e(a, { children: "Full Width ToggleGroup" }),
33
+ /* @__PURE__ */ e("div", { style: { width: "100%" }, children: /* @__PURE__ */ e(
34
+ i,
35
+ {
36
+ value: o,
37
+ onChange: t,
38
+ options: n,
39
+ fullWidth: !0
40
+ }
41
+ ) })
42
+ ] }),
43
+ /* @__PURE__ */ l(r, { gap: "normal", vertical: !0, children: [
44
+ /* @__PURE__ */ e(a, { children: "Disabled ToggleGroup" }),
45
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
46
+ i,
47
+ {
48
+ value: o,
49
+ onChange: t,
50
+ options: n,
51
+ disabled: !0
52
+ }
53
+ ) })
54
+ ] })
55
+ ] });
56
+ }
57
+ const f = u.memo(c);
58
+ export {
59
+ f as default
60
+ };
@@ -0,0 +1,2 @@
1
+ export { ToggleGroup } from './ToggleGroup';
2
+ export type { ToggleGroupOption, ToggleGroupProps } from './ToggleGroup';
@@ -0,0 +1,4 @@
1
+ import { ToggleGroup as e } from "./ToggleGroup.js";
2
+ export {
3
+ e as ToggleGroup
4
+ };
@@ -177,8 +177,14 @@
177
177
 
178
178
  @include ui.def('tabular-notification-gap', ui.q(.75));
179
179
 
180
- @include ui.def('tabular-item-height', ui.control-height('xlarge'));
181
- @include ui.def('tabular-item-padding', ui.offset('medium'));
180
+ @include ui.def('tabular-small-item-height', ui.q(5));
181
+ @include ui.def('tabular-small-item-padding', ui.offset('medium'));
182
+
183
+ @include ui.def('tabular-medium-item-height', ui.q(7.5));
184
+ @include ui.def('tabular-medium-item-padding', ui.offset('medium'));
185
+
186
+ @include ui.def('tabular-large-item-height', ui.q(10));
187
+ @include ui.def('tabular-large-item-padding', ui.offset('medium'));
182
188
 
183
189
  @include ui.def('tabular-item-border-size', ui.q(.25));
184
190
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfx-dev/ui-components",
3
3
  "private": false,
4
- "version": "4.1.1",
4
+ "version": "4.2.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "dist/main.js",