@cfx-dev/ui-components 2.0.3 → 2.0.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,60 +1,79 @@
1
- import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
- import o, { useState as d } from "react";
3
- import { G as R } from "../../iconBase-C6DV9qqL.js";
4
- import '../../assets/Table.css';function x(r) {
5
- return R({ tag: "svg", attr: { viewBox: "0 0 320 512" }, child: [{ tag: "path", attr: { d: "M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41z" } }] })(r);
6
- }
7
- function L(r) {
8
- return R({ tag: "svg", attr: { viewBox: "0 0 320 512" }, child: [{ tag: "path", attr: { d: "M279 224H41c-21.4 0-32.1-25.9-17-41L143 64c9.4-9.4 24.6-9.4 33.9 0l119 119c15.2 15.1 4.5 41-16.9 41z" } }] })(r);
9
- }
10
- const z = "_selectedRow_1jg2j_23", w = {
11
- "table-responsive": "_table-responsive_1jg2j_1",
12
- selectedRow: z
1
+ import { jsx as o, jsxs as i } from "react/jsx-runtime";
2
+ import f, { useState as m } from "react";
3
+ import O from "../Checkbox/Checkbox.js";
4
+ import j from "../IconButton/IconButton.js";
5
+ import '../../assets/Table.css';const x = "_pointer_19b0f_18", A = "_selectedRow_19b0f_22", E = "_headerContent_19b0f_40", z = "_sortButton_19b0f_47", l = {
6
+ "table-responsive": "_table-responsive_19b0f_1",
7
+ pointer: x,
8
+ selectedRow: A,
9
+ headerContent: E,
10
+ sortButton: z
13
11
  };
14
- function G({
15
- headers: r = [],
16
- data: _ = [],
17
- includeRadio: p = !1,
18
- onSelectChange: l,
19
- dataContainer: u,
20
- useSort: h = !1,
21
- sortBy: j,
22
- sortOrder: y = "asc",
23
- onSortChange: i
12
+ function F({
13
+ headers: u = [],
14
+ data: B = [],
15
+ includeRadio: r = !1,
16
+ onSelectChange: c,
17
+ dataContainer: b,
18
+ useSort: n = !1,
19
+ sortBy: k,
20
+ sortOrder: v = "asc",
21
+ onSortChange: d
24
22
  }) {
25
- const [m, f] = d(null), [b, g] = d(j), [v, B] = d(y), k = (t) => {
26
- const c = b === t && v === "asc" ? "desc" : "asc";
27
- g(t), B(c), i == null || i(t, c);
28
- }, O = o.useCallback((t) => {
29
- f(parseInt(t.target.value, 10)), l == null || l(parseInt(t.target.value, 10));
30
- }, [f, l]);
31
- return /* @__PURE__ */ e("div", { className: w.table, children: /* @__PURE__ */ n("table", { children: [
32
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
33
- p && /* @__PURE__ */ e("th", { children: "Select Row" }),
34
- r.map((t, s) => /* @__PURE__ */ n("th", { onClick: () => h && k(t), children: [
35
- t,
36
- h && b === t && /* @__PURE__ */ e("span", { children: v === "asc" ? /* @__PURE__ */ e(L, {}) : /* @__PURE__ */ e(x, {}) })
37
- ] }, `header-${s}`))
23
+ const [p, y] = m(null), [R, w] = m(k), [$, N] = m(v), _ = (e) => {
24
+ const t = R === e && $ === "asc" ? "desc" : "asc";
25
+ w(e), N(t), d == null || d(e, t);
26
+ }, h = f.useCallback(
27
+ (e, s) => {
28
+ if (typeof e == "boolean") {
29
+ const t = e ? s : null;
30
+ y(t), t !== null && (c == null || c(t));
31
+ }
32
+ },
33
+ [c]
34
+ );
35
+ return /* @__PURE__ */ o("div", { className: l.tableResponsive, children: /* @__PURE__ */ i("table", { children: [
36
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ i("tr", { children: [
37
+ r && /* @__PURE__ */ o("th", { "aria-label": "Select Row" }),
38
+ u.map((e, s) => /* @__PURE__ */ o(
39
+ "th",
40
+ {
41
+ className: n ? l.pointer : "",
42
+ onClick: () => n && _(e),
43
+ children: /* @__PURE__ */ i("div", { className: l.headerContent, children: [
44
+ e,
45
+ n && /* @__PURE__ */ o(
46
+ j,
47
+ {
48
+ className: l.sortButton,
49
+ color: "secondary",
50
+ name: "Sort",
51
+ onClick: n ? () => _(e) : void 0
52
+ }
53
+ )
54
+ ] })
55
+ },
56
+ `header-${s}`
57
+ ))
38
58
  ] }) }),
39
- /* @__PURE__ */ e("tbody", { children: _.map((t, s) => /* @__PURE__ */ n(
59
+ /* @__PURE__ */ o("tbody", { children: B.map((e, s) => /* @__PURE__ */ i(
40
60
  "tr",
41
61
  {
42
- className: m === s ? w.selectedRow : "",
62
+ className: `${p === s ? l.selectedRow : ""} ${r ? l.pointer : ""}`,
63
+ onClick: r ? () => h(!0, s) : void 0,
43
64
  children: [
44
- p && /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
45
- "input",
65
+ r && /* @__PURE__ */ o("td", { children: /* @__PURE__ */ o(
66
+ O,
46
67
  {
47
- type: "radio",
48
- name: "tableRowSelect",
49
- value: s,
50
- checked: m === s,
51
- onChange: O,
52
- "aria-label": `${s}`
68
+ size: "small",
69
+ onCheckedChange: (t) => h(t, s),
70
+ "aria-label": `${s}`,
71
+ checked: p === s
53
72
  }
54
73
  ) }),
55
- t.map((c, $) => {
74
+ e.map((t, C) => {
56
75
  let a;
57
- return o.isValidElement(c) ? a = c : u ? a = o.createElement(u, { item: c }) : a = String(c), /* @__PURE__ */ e("td", { children: a }, `item-${$}`);
76
+ return f.isValidElement(t) ? a = t : b ? a = f.createElement(b, { item: t }) : a = String(t), /* @__PURE__ */ o("td", { children: a }, `item-${C}`);
58
77
  })
59
78
  ]
60
79
  },
@@ -63,5 +82,5 @@ function G({
63
82
  ] }) });
64
83
  }
65
84
  export {
66
- G as Table
85
+ F as Table
67
86
  };
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare function TableShowcase(): import("react/jsx-runtime").JSX.Element;
4
+ declare const _default: React.MemoExoticComponent<typeof TableShowcase>;
5
+ export default _default;
@@ -0,0 +1,55 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import d from "react";
3
+ import { Badge as l } from "../Badge/Badge.js";
4
+ import { Flex as a } from "../Layout/Flex/Flex.js";
5
+ import "../Interactive/Interactive.js";
6
+ import { Scrollable as c } from "../Layout/Scrollable/Scrollable.js";
7
+ import "../Layout/Scrollable/VirtualScrollable.js";
8
+ import { Text as r } from "../Text/Text.js";
9
+ import { Table as o } from "./Table.js";
10
+ const i = [
11
+ [
12
+ "Cell 1",
13
+ "Cell 2",
14
+ "Cell 3",
15
+ new Date(2023, 0, 1).toLocaleDateString(),
16
+ /* @__PURE__ */ e(l, { color: "error", children: "Error" }, "1")
17
+ ],
18
+ ["Cell 4", "Cell 5", "Cell 6", new Date(2023, 1, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "2")],
19
+ ["Cell 7", "Cell 8", "Cell 9", new Date(2023, 2, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "3")],
20
+ ["Cell 4", "Cell 5", "Cell 6", new Date(2023, 1, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "2")],
21
+ ["Cell 7", "Cell 8", "Cell 9", new Date(2023, 2, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "3")],
22
+ ["Cell 4", "Cell 5", "Cell 6", new Date(2023, 1, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "2")],
23
+ ["Cell 7", "Cell 8", "Cell 9", new Date(2023, 2, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "3")],
24
+ ["Cell 4", "Cell 5", "Cell 6", new Date(2023, 1, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "2")],
25
+ ["Cell 7", "Cell 8", "Cell 9", new Date(2023, 2, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "3")],
26
+ ["Cell 4", "Cell 5", "Cell 6", new Date(2023, 1, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "2")],
27
+ ["Cell 7", "Cell 8", "Cell 9", new Date(2023, 2, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "3")],
28
+ ["Cell 4", "Cell 5", "Cell 6", new Date(2023, 1, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "2")],
29
+ ["Cell 7", "Cell 8", "Cell 9", new Date(2023, 2, 1).toLocaleDateString(), /* @__PURE__ */ e(l, { children: "Badge" }, "3")]
30
+ ], n = ["Header 1", "Header 2", "Header 3", "Date", "Item"];
31
+ function C() {
32
+ return /* @__PURE__ */ t(a, { gap: "large", vertical: !0, children: [
33
+ /* @__PURE__ */ t(a, { gap: "normal", vertical: !0, children: [
34
+ /* @__PURE__ */ e(r, { children: "Table" }),
35
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(o, { includeRadio: !0, headers: n, data: i }) })
36
+ ] }),
37
+ /* @__PURE__ */ t(a, { fullWidth: !0, vertical: !0, children: [
38
+ /* @__PURE__ */ e(r, { children: "Table with scroll" }),
39
+ /* @__PURE__ */ e(
40
+ "div",
41
+ {
42
+ style: {
43
+ height: "400px",
44
+ overflow: "hidden"
45
+ },
46
+ children: /* @__PURE__ */ e(c, { children: /* @__PURE__ */ e(o, { includeRadio: !0, headers: n, data: i }) })
47
+ }
48
+ )
49
+ ] })
50
+ ] });
51
+ }
52
+ const B = d.memo(C);
53
+ export {
54
+ B as default
55
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfx-dev/ui-components",
3
3
  "private": false,
4
- "version": "2.0.3",
4
+ "version": "2.0.4",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "dist/main.js",
@@ -1,60 +0,0 @@
1
- import i from "react";
2
- var s = {
3
- color: void 0,
4
- size: void 0,
5
- className: void 0,
6
- style: void 0,
7
- attr: void 0
8
- }, f = i.createContext && i.createContext(s), l = function() {
9
- return l = Object.assign || function(e) {
10
- for (var n, t = 1, r = arguments.length; t < r; t++) {
11
- n = arguments[t];
12
- for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]);
13
- }
14
- return e;
15
- }, l.apply(this, arguments);
16
- }, y = function(e, n) {
17
- var t = {};
18
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && n.indexOf(r) < 0 && (t[r] = e[r]);
19
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var a = 0, r = Object.getOwnPropertySymbols(e); a < r.length; a++)
20
- n.indexOf(r[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[a]) && (t[r[a]] = e[r[a]]);
21
- return t;
22
- };
23
- function m(e) {
24
- return e && e.map(function(n, t) {
25
- return i.createElement(n.tag, l({
26
- key: t
27
- }, n.attr), m(n.child));
28
- });
29
- }
30
- function h(e) {
31
- return function(n) {
32
- return i.createElement(g, l({
33
- attr: l({}, e.attr)
34
- }, n), m(e.child));
35
- };
36
- }
37
- function g(e) {
38
- var n = function(t) {
39
- var r = e.attr, a = e.size, c = e.title, d = y(e, ["attr", "size", "title"]), o = a || t.size || "1em", u;
40
- return t.className && (u = t.className), e.className && (u = (u ? u + " " : "") + e.className), i.createElement("svg", l({
41
- stroke: "currentColor",
42
- fill: "currentColor",
43
- strokeWidth: "0"
44
- }, t.attr, r, d, {
45
- className: u,
46
- style: l(l({
47
- color: e.color || t.color
48
- }, t.style), e.style),
49
- height: o,
50
- width: o,
51
- xmlns: "http://www.w3.org/2000/svg"
52
- }), c && i.createElement("title", null, c), e.children);
53
- };
54
- return f !== void 0 ? i.createElement(f.Consumer, null, function(t) {
55
- return n(t);
56
- }) : n(s);
57
- }
58
- export {
59
- h as G
60
- };