triafly-ui-kit 1.0.40 → 1.0.42

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,4 @@
1
- import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
2
- import { __require as r } from "../node_modules/fast-deep-equal/index.js";
3
- var t = r();
4
- const p = /* @__PURE__ */ e(t);
1
+ var s = { exports: {} };
5
2
  export {
6
- p as default
3
+ s as __module
7
4
  };
@@ -1 +1 @@
1
- .table-component{width:100%;overflow:auto;position:relative}.table-component__wrapper{width:100%}.table-component__wrapper.bordered{border:1px solid var(--color-border-primary-default);border-radius:8px}.table-component__wrapper__table{width:100%;border-collapse:separate;border-spacing:0}.table-component__wrapper__table.bordered{border:none}.table-component__wrapper__table__thead{background-color:var(--color-bg-innerisland-default);height:41px}.table-component__wrapper__table__thead.stickyHeader{position:sticky;top:0;z-index:10}.table-component__wrapper__table__thead__tr:hover{background-color:var(--color-bg-island-selected)}.table-component__wrapper__table__thead__th{padding:12px;text-align:left;position:relative}.table-component__wrapper__table__thead__th.bordered{border-left:1px solid var(--color-border-primary-default);border-bottom:none}.table-component__wrapper__table__thead__th.bordered:first-child{border-left:none}.table-component__wrapper__table__thead__th.stickyLeft{position:sticky;left:0;background-color:inherit;z-index:9}.table-component__wrapper__table__thead__th .th-content{display:flex;align-items:center;gap:4px}.table-component__wrapper__table__thead__th .sort-icon{display:inline-flex}.table-component__wrapper__table__tbody__tr:hover{background-color:var(--color-bg-island-selected)}.table-component__wrapper__table__tbody--hoverable{cursor:pointer}.table-component__wrapper__table__tbody__td{padding:12px}.table-component__wrapper__table__tbody__td--bordered{border-top:1px solid var(--color-border-primary-default);border-left:1px solid var(--color-border-primary-default)}.table-component__wrapper__table__tbody__td--bordered:first-child{border-left:none}.table-component__wrapper__table__tbody__td--sticky-left{position:sticky;left:0;background-color:inherit;z-index:8}.table-component__wrapper.borderBottom .table-component__wrapper__table__tbody td{border-bottom:1px solid var(--color-border-primary-default)}
1
+ .table-component{width:100%;overflow:auto;position:relative}.table-component__wrapper{width:100%}.table-component__wrapper.bordered{border:1px solid var(--color-border-primary-default);border-radius:8px}.table-component__wrapper__table{width:100%;border-collapse:separate;border-spacing:0}.table-component__wrapper__table.bordered{border:none}.table-component__wrapper__table__thead{background-color:var(--color-bg-innerisland-default);height:41px}.table-component__wrapper__table__thead.stickyHeader{position:sticky;top:0;z-index:10}.table-component__wrapper__table__thead__tr:hover{background-color:var(--color-bg-island-selected)}.table-component__wrapper__table__thead__th{padding:12px;text-align:left;position:relative}.table-component__wrapper__table__thead__th.bordered{border-left:1px solid var(--color-border-primary-default);border-bottom:none}.table-component__wrapper__table__thead__th.bordered:first-child{border-left:none}.table-component__wrapper__table__thead__th.stickyLeft{position:sticky;left:0;background-color:inherit;z-index:9}.table-component__wrapper__table__thead__th .th-content{display:flex;align-items:center;gap:4px}.table-component__wrapper__table__thead__th .sort-icon{display:inline-flex}.table-component__wrapper__table__tbody__tr:hover{background-color:var(--color-bg-island-selected)}.table-component__wrapper__table__tbody--hoverable{cursor:pointer}.table-component__wrapper__table__tbody__td{padding:12px}.table-component__wrapper__table__tbody__td--bordered{border-top:1px solid var(--color-border-primary-default);border-left:1px solid var(--color-border-primary-default)}.table-component__wrapper__table__tbody__td--bordered:first-child{border-left:none}.table-component__wrapper__table__tbody__td--sticky-left{position:sticky;left:0;background-color:inherit;z-index:8}.table-component__wrapper.borderBottom .table-component__wrapper__table__tbody td{border-bottom:1px solid var(--color-border-primary-default)}.loading_table_init{position:absolute;top:0;left:0;right:0;bottom:0;display:"flex";justify-content:"center";align-items:"center";background-color:"rgba(255, 255, 255, 0.7)";z-index:10}
@@ -1,50 +1,49 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import c from "react";
3
- import m from "../../../../_virtual/index2.js";
4
- import d from "../../../../_virtual/index.js";
5
- const h = c.memo(
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import f from "react";
3
+ import o from "../../../../_virtual/index.js";
4
+ const K = f.memo(
6
5
  ({
7
6
  record: t,
8
- columns: _,
7
+ columns: n,
9
8
  rowKey: a,
10
- rowClassName: n,
11
- index: l,
12
- stickyLeft: r,
13
- onClickTr: b,
14
- bordered: i
9
+ rowClassName: d,
10
+ index: i,
11
+ stickyLeft: e,
12
+ bordered: y,
13
+ id: c
15
14
  }) => {
16
- const s = (e) => {
17
- !e.target.closest("[data-no-bubble]") && b && b(t);
18
- };
19
- return /* @__PURE__ */ p(
15
+ const m = c || (typeof a == "function" ? a(t) : String(t[a]));
16
+ return /* @__PURE__ */ b(
20
17
  "tr",
21
18
  {
22
- className: d(
19
+ "data-id": m,
20
+ className: o(
23
21
  "table-component__wrapper__table__tbody__tr",
24
- n == null ? void 0 : n(t, l),
25
- {
26
- "table-component__wrapper__table__tbody__tr--hoverable": !!b
27
- }
22
+ d == null ? void 0 : d(t, i)
28
23
  ),
29
- onClick: s,
30
- children: _.map((e, o) => /* @__PURE__ */ p(
24
+ children: n.map((_, r) => /* @__PURE__ */ b(
31
25
  "td",
32
26
  {
33
- className: d("table-component__wrapper__table__tbody__td", e.className, {
34
- "table-component__wrapper__table__tbody__td--bordered": i,
35
- "table-component__wrapper__table__tbody__td--sticky-left": r && o === 0
27
+ className: o("table-component__wrapper__table__tbody__td", _.className, {
28
+ "table-component__wrapper__table__tbody__td--bordered": y,
29
+ "table-component__wrapper__table__tbody__td--sticky-left": e && r === 0
36
30
  }),
37
- align: e.align,
38
- children: e.render ? e.render(t[e.dataIndex], t) : String(t[e.dataIndex] ?? "")
31
+ align: _.align,
32
+ children: _.render ? _.render(t[_.dataIndex], t) : String(t[_.dataIndex] ?? "")
39
33
  },
40
- `${e.key}-${o}`
34
+ `${_.key}-${r}`
41
35
  ))
42
36
  },
43
- typeof a == "function" ? a(t) : String(t[a])
37
+ m
44
38
  );
45
39
  },
46
- (t, _) => m(t.columns, _.columns) && m(t.record, _.record)
40
+ (t, n) => {
41
+ if (t.id && n.id)
42
+ return t.id === n.id;
43
+ const a = (e) => typeof e.rowKey == "function" ? e.rowKey(e.record) : String(e.record[e.rowKey]), d = a(t), i = a(n);
44
+ return d !== i ? !1 : t.columns === n.columns;
45
+ }
47
46
  );
48
47
  export {
49
- h as MemoizedRow
48
+ K as MemoizedRow
50
49
  };
@@ -1,165 +1,196 @@
1
- import { jsx as t, jsxs as f } from "react/jsx-runtime";
2
- import { forwardRef as H, useState as y, useEffect as J, useCallback as _ } from "react";
3
- import l from "../../../_virtual/index.js";
1
+ import { jsx as n, jsxs as g } from "react/jsx-runtime";
2
+ import Z, { forwardRef as K, useState as M, useMemo as ee, useCallback as k, useEffect as te } from "react";
3
+ import o from "../../../_virtual/index.js";
4
4
  import '../../../assets/src/components/Ui/Table/Table.css';/* empty css */
5
- import { IconCaretDown as k, IconCaretUp as O } from "../Icons/Icons.js";
6
- import { MemoizedRow as P } from "./MemoizedRow/MemoizedRow.js";
7
- import { Loader as Q } from "../Loader/Loader.js";
8
- import { TableSkeletonRow as V } from "./TableSkeletonRow/TableSkeletonRow.js";
9
- const v = {
10
- asc: /* @__PURE__ */ t(k, { viewBox: "0 -6 24 24", "aria-hidden": "true" }),
11
- desc: /* @__PURE__ */ t(O, { viewBox: "0 -4 24 24", "aria-hidden": "true" }),
12
- default: /* @__PURE__ */ t(k, { viewBox: "0 -6 24 24", "aria-hidden": "true" })
13
- }, W = ({
14
- columns: o,
15
- dataSource: p,
5
+ import { IconCaretDown as j, IconCaretUp as ne } from "../Icons/Icons.js";
6
+ import { MemoizedRow as z } from "./MemoizedRow/MemoizedRow.js";
7
+ import { Loader as ae } from "../Loader/Loader.js";
8
+ import { TableSkeletonRow as re } from "./TableSkeletonRow/TableSkeletonRow.js";
9
+ const C = {
10
+ asc: /* @__PURE__ */ n(j, { viewBox: "0 -6 24 24", "aria-hidden": "true" }),
11
+ desc: /* @__PURE__ */ n(ne, { viewBox: "0 -4 24 24", "aria-hidden": "true" }),
12
+ default: /* @__PURE__ */ n(j, { viewBox: "0 -6 24 24", "aria-hidden": "true" })
13
+ }, se = ({
14
+ columns: f,
15
+ dataSource: m,
16
16
  rowKey: i,
17
- tableClassName: x,
18
- theadClassName: D,
19
- trTheadClassNames: I,
20
- thTheadClassNames: S,
21
- tbodyClassName: A,
22
- wrapperClassName: C,
23
- borderBottom: h = !1,
24
- stickyHeader: T = !1,
25
- stickyLeft: u = !1,
26
- bordered: c = !1,
27
- rowClassName: j,
28
- defaultSort: B,
29
- onClickTr: m,
30
- onClickTrHeader: R,
31
- loading: b = !1,
32
- hasMore: z = !1,
33
- loadingIndicator: $,
34
- loaderRef: g
35
- }, E) => {
36
- const [L, w] = y(p), [n, M] = y(
37
- B || null
38
- );
39
- J(() => {
40
- w(p);
41
- }, [p]);
42
- const U = _(
43
- (e) => typeof i == "function" ? i(e) : typeof i == "string" && i in e ? String(e[i]) : "unknown",
17
+ tableClassName: L,
18
+ theadClassName: $,
19
+ trTheadClassNames: O,
20
+ thTheadClassNames: U,
21
+ tbodyClassName: q,
22
+ wrapperClassName: F,
23
+ borderBottom: y = !1,
24
+ stickyHeader: G = !1,
25
+ stickyLeft: b = !1,
26
+ bordered: p = !1,
27
+ rowClassName: x,
28
+ defaultSort: H,
29
+ onClickTr: _,
30
+ onClickTrHeader: J,
31
+ loading: R = !1,
32
+ hasMore: P = !1,
33
+ loadingIndicator: Q,
34
+ loaderRef: B,
35
+ externalSorting: D = !1,
36
+ entities: c,
37
+ sortedIds: u
38
+ }, V) => {
39
+ const T = Z.useRef(null), l = !!c && !!u, [A, W] = M(m || []), [s, S] = M(
40
+ H || null
41
+ ), N = ee(() => {
42
+ if (!l)
43
+ return D ? m : A;
44
+ }, [l, m, A, D]), E = k(
45
+ (e, t) => {
46
+ if (l) {
47
+ S({ key: e, order: t });
48
+ return;
49
+ }
50
+ W((d) => [...d].sort((h, I) => {
51
+ const r = h[e], a = I[e];
52
+ return typeof r == "string" && typeof a == "string" ? t === "asc" ? r.localeCompare(a) : a.localeCompare(r) : typeof r == "number" && typeof a == "number" ? t === "asc" ? r - a : a - r : r instanceof Date && a instanceof Date ? t === "asc" ? r.getTime() - a.getTime() : a.getTime() - r.getTime() : 0;
53
+ })), S({ key: e, order: t });
54
+ },
55
+ [l]
56
+ ), v = k(
57
+ (e) => typeof i == "function" ? i(e) : String(e[i]),
44
58
  [i]
45
- ), N = _((e, a) => {
46
- w((d) => [...d].sort((F, G) => {
47
- const s = F[e], r = G[e];
48
- return typeof s == "string" && typeof r == "string" ? a === "asc" ? s.localeCompare(r) : r.localeCompare(s) : typeof s == "number" && typeof r == "number" ? a === "asc" ? s - r : r - s : s instanceof Date && r instanceof Date ? a === "asc" ? s.getTime() - r.getTime() : r.getTime() - s.getTime() : 0;
49
- })), M({ key: e, order: a });
50
- }, []), q = _(
59
+ ), X = k(
51
60
  (e) => {
52
- const d = (n == null ? void 0 : n.key) === e && n.order === "asc" ? "desc" : "asc";
53
- N(e, d);
61
+ const d = (s == null ? void 0 : s.key) === e && s.order === "asc" ? "desc" : "asc";
62
+ E(e, d);
54
63
  },
55
- [n, N]
64
+ [s, E]
56
65
  );
57
- return /* @__PURE__ */ t("div", { className: l("table-component", C), children: /* @__PURE__ */ t(
66
+ return te(() => {
67
+ const e = T.current;
68
+ if (!e) return;
69
+ const t = (d) => {
70
+ const w = d.target, h = w.closest("tr");
71
+ if (!h || w.closest("[data-no-bubble]")) return;
72
+ const r = h.dataset.id;
73
+ if (!(!r || !_))
74
+ if (l && c) {
75
+ const a = c[r];
76
+ a && _(a);
77
+ } else {
78
+ const a = m.find((Y) => v(Y) === r);
79
+ a && _(a);
80
+ }
81
+ };
82
+ return e.addEventListener("click", t), () => e.removeEventListener("click", t);
83
+ }, [m, _, v, l, c]), /* @__PURE__ */ n("div", { className: o("table-component", F), children: /* @__PURE__ */ n(
58
84
  "div",
59
85
  {
60
- className: l(
86
+ className: o(
61
87
  "table-component__wrapper",
62
88
  {
63
- bordered: c,
64
- borderBottom: h
89
+ bordered: p,
90
+ borderBottom: y
65
91
  },
66
- x
92
+ L
67
93
  ),
68
- children: /* @__PURE__ */ f(
94
+ children: /* @__PURE__ */ g(
69
95
  "table",
70
96
  {
71
- className: l("table-component__wrapper__table", {
72
- bordered: c,
73
- borderBottom: h
97
+ className: o("table-component__wrapper__table", {
98
+ bordered: p,
99
+ borderBottom: y
74
100
  }),
75
- ref: E,
101
+ ref: V,
76
102
  children: [
77
- /* @__PURE__ */ t(
103
+ /* @__PURE__ */ n(
78
104
  "thead",
79
105
  {
80
- className: l(
106
+ className: o(
81
107
  "table-component__wrapper__table__thead",
82
108
  {
83
- stickyHeader: T
109
+ stickyHeader: G
84
110
  },
85
- D
111
+ $
86
112
  ),
87
- children: /* @__PURE__ */ t(
113
+ children: /* @__PURE__ */ n(
88
114
  "tr",
89
115
  {
90
- className: l(
116
+ className: o(
91
117
  "table-component__wrapper__table__thead__tr",
92
- I
118
+ O
93
119
  ),
94
- onClick: R,
95
- children: o.map((e, a) => /* @__PURE__ */ t(
120
+ onClick: J,
121
+ children: f.map((e, t) => /* @__PURE__ */ n(
96
122
  "th",
97
123
  {
98
- className: l(
124
+ className: o(
99
125
  "table-component__wrapper__table__thead__th",
100
126
  {
101
- bordered: c,
102
- stickyLeft: u && a === 0
127
+ bordered: p,
128
+ stickyLeft: b && t === 0
103
129
  },
104
- S
130
+ U
105
131
  ),
106
132
  style: {
107
133
  ...e.width ? { width: e.width } : {},
108
134
  ...e.align ? { textAlign: e.align } : {}
109
135
  },
110
- onClick: () => e.sorted && q(e.key),
111
- children: /* @__PURE__ */ f("div", { className: "th-content", children: [
136
+ onClick: () => e.sorted && X(e.key),
137
+ children: /* @__PURE__ */ g("div", { className: "th-content", children: [
112
138
  e.title,
113
- e.sorted && /* @__PURE__ */ t("span", { className: "sort-icon", children: (n == null ? void 0 : n.key) === e.key ? v[n.order] : v.default })
139
+ e.sorted && /* @__PURE__ */ n("span", { className: "sort-icon", children: (s == null ? void 0 : s.key) === e.key ? C[s.order] : C.default })
114
140
  ] })
115
141
  },
116
- `${e.key}-${a}`
142
+ `${e.key}-${t}`
117
143
  ))
118
144
  }
119
145
  )
120
146
  }
121
147
  ),
122
- /* @__PURE__ */ f("tbody", { className: l("table-component__wrapper__table__tbody", A), children: [
123
- L.map((e, a) => /* @__PURE__ */ t(
124
- P,
125
- {
126
- record: e,
127
- onClickTr: () => m == null ? void 0 : m(e),
128
- columns: o,
129
- rowKey: i,
130
- rowClassName: j,
131
- index: a,
132
- stickyLeft: u,
133
- bordered: c
134
- },
135
- U(e)
136
- )),
137
- b ? /* @__PURE__ */ t(
138
- "div",
139
- {
140
- style: {
141
- position: "absolute",
142
- top: 0,
143
- left: 0,
144
- right: 0,
145
- bottom: 0,
146
- display: "flex",
147
- justifyContent: "center",
148
- alignItems: "center",
149
- backgroundColor: "rgba(255, 255, 255, 0.7)",
150
- zIndex: 10
151
- },
152
- children: /* @__PURE__ */ t(Q, { className: "centered" })
153
- }
154
- ) : null,
155
- !b && z && g && /* @__PURE__ */ t("tr", { ref: g, children: /* @__PURE__ */ t("td", { colSpan: o.length, children: $ || /* @__PURE__ */ t(V, { colSpan: o.length }) }) })
156
- ] })
148
+ /* @__PURE__ */ g(
149
+ "tbody",
150
+ {
151
+ ref: T,
152
+ className: o("table-component__wrapper__table__tbody", q),
153
+ children: [
154
+ l && u ? u.map((e) => {
155
+ const t = c == null ? void 0 : c[e];
156
+ return t ? /* @__PURE__ */ n(
157
+ z,
158
+ {
159
+ record: t,
160
+ columns: f,
161
+ rowKey: i,
162
+ rowClassName: x,
163
+ index: u.indexOf(e),
164
+ stickyLeft: b,
165
+ bordered: p,
166
+ id: e
167
+ },
168
+ e
169
+ ) : null;
170
+ }) : N == null ? void 0 : N.map((e, t) => /* @__PURE__ */ n(
171
+ z,
172
+ {
173
+ record: e,
174
+ columns: f,
175
+ rowKey: i,
176
+ rowClassName: x,
177
+ index: t,
178
+ stickyLeft: b,
179
+ bordered: p
180
+ },
181
+ v(e)
182
+ )),
183
+ R ? /* @__PURE__ */ n("div", { className: "loading_table_init", children: /* @__PURE__ */ n(ae, { className: "centered" }) }) : null,
184
+ !R && P && B && /* @__PURE__ */ n("tr", { ref: B, children: /* @__PURE__ */ n("td", { colSpan: f.length, children: Q || /* @__PURE__ */ n(re, { colSpan: f.length }) }) })
185
+ ]
186
+ }
187
+ )
157
188
  ]
158
189
  }
159
190
  )
160
191
  }
161
192
  ) });
162
- }, re = H(W);
193
+ }, _e = K(se);
163
194
  export {
164
- re as Table
195
+ _e as Table
165
196
  };
package/dist/main.d.ts CHANGED
@@ -1178,6 +1178,9 @@ declare type TablesProps<T extends object = Record<string, unknown>> = {
1178
1178
  hasMore?: boolean;
1179
1179
  loadingIndicator?: default_2.ReactNode;
1180
1180
  loaderRef?: default_2.Ref<HTMLTableRowElement>;
1181
+ entities?: Record<string, T>;
1182
+ sortedIds?: string[];
1183
+ externalSorting?: boolean;
1181
1184
  };
1182
1185
 
1183
1186
  export declare const Tabs: React.FC<TabsProps>;
@@ -1,4 +1,4 @@
1
- import { __module as s } from "../../_virtual/index3.js";
1
+ import { __module as s } from "../../_virtual/index2.js";
2
2
  /*!
3
3
  Copyright (c) 2018 Jed Watson.
4
4
  Licensed under the MIT License (MIT), see
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triafly-ui-kit",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "UI Kit from Triafly",
5
5
  "main": "./dist/main.js",
6
6
  "module": "./dist/main.js",
@@ -1,4 +0,0 @@
1
- var s = { exports: {} };
2
- export {
3
- s as __module
4
- };
@@ -1,31 +0,0 @@
1
- var o, c;
2
- function l() {
3
- return c || (c = 1, o = function n(r, e) {
4
- if (r === e) return !0;
5
- if (r && e && typeof r == "object" && typeof e == "object") {
6
- if (r.constructor !== e.constructor) return !1;
7
- var u, t, f;
8
- if (Array.isArray(r)) {
9
- if (u = r.length, u != e.length) return !1;
10
- for (t = u; t-- !== 0; )
11
- if (!n(r[t], e[t])) return !1;
12
- return !0;
13
- }
14
- if (r.constructor === RegExp) return r.source === e.source && r.flags === e.flags;
15
- if (r.valueOf !== Object.prototype.valueOf) return r.valueOf() === e.valueOf();
16
- if (r.toString !== Object.prototype.toString) return r.toString() === e.toString();
17
- if (f = Object.keys(r), u = f.length, u !== Object.keys(e).length) return !1;
18
- for (t = u; t-- !== 0; )
19
- if (!Object.prototype.hasOwnProperty.call(e, f[t])) return !1;
20
- for (t = u; t-- !== 0; ) {
21
- var s = f[t];
22
- if (!n(r[s], e[s])) return !1;
23
- }
24
- return !0;
25
- }
26
- return r !== r && e !== e;
27
- }), o;
28
- }
29
- export {
30
- l as __require
31
- };