triafly-ui-kit 1.0.58 → 1.0.59

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.
@@ -0,0 +1 @@
1
+ .skeleton{display:inline-block;background-color:var(--color-bg-neutral-medium-default)!important;position:relative;overflow:hidden}.skeleton.animated:after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,#f000,#ffffff80,#f000);animation:skeleton-loading 1.5s infinite}@keyframes skeleton-loading{0%{transform:translate(-100%)}to{transform:translate(100%)}}
@@ -1,26 +1,25 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import p from "../../../_virtual/index.js";
3
- import e from "../../../src/components/Ui/Skeleton/Skeleton.module.scss.js";
4
- const c = ({
5
- width: s = "100%",
6
- height: o = "100%",
7
- borderRadius: t = "4px",
8
- circle: r = !1,
9
- animated: m = !0,
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import '../../../assets/src/components/Ui/Skeleton/Skeleton.css';/* empty css */
3
+ const n = ({
4
+ width: e = "100%",
5
+ height: t = "100%",
6
+ borderRadius: o = "4px",
7
+ circle: s = !1,
8
+ animated: r = !0,
10
9
  className: a,
11
- style: l
12
- }) => /* @__PURE__ */ i(
10
+ style: i
11
+ }) => /* @__PURE__ */ l(
13
12
  "div",
14
13
  {
15
- className: p(e.skeleton, { [e.animated]: m }, a),
14
+ className: `skeleton ${r ? "animated" : ""} ${a || ""}`,
16
15
  style: {
17
- width: s,
18
- height: o,
19
- borderRadius: r ? "50%" : t,
20
- ...l
16
+ width: e,
17
+ height: t,
18
+ borderRadius: s ? "50%" : o,
19
+ ...i
21
20
  }
22
21
  }
23
22
  );
24
23
  export {
25
- c as Skeleton
24
+ n as Skeleton
26
25
  };
@@ -1,49 +1,39 @@
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(
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import l from "react";
3
+ import m from "../../../../_virtual/index.js";
4
+ const g = l.memo(
5
5
  ({
6
- record: t,
7
- columns: n,
8
- rowKey: a,
9
- rowClassName: d,
10
- index: i,
11
- stickyLeft: e,
12
- bordered: y,
13
- id: c
6
+ record: _,
7
+ columns: r,
8
+ rowKey: e,
9
+ rowClassName: a,
10
+ stickyLeft: b,
11
+ bordered: i,
12
+ id: o
14
13
  }) => {
15
- const m = c || (typeof a == "function" ? a(t) : String(t[a]));
16
- return /* @__PURE__ */ b(
14
+ const n = o || (typeof e == "function" ? e(_) : String(_[e]));
15
+ return /* @__PURE__ */ d(
17
16
  "tr",
18
17
  {
19
- "data-id": m,
20
- className: o(
21
- "table-component__wrapper__table__tbody__tr",
22
- d == null ? void 0 : d(t, i)
23
- ),
24
- children: n.map((_, r) => /* @__PURE__ */ b(
18
+ "data-id": n,
19
+ className: m("table-component__wrapper__table__tbody__tr", a == null ? void 0 : a(_)),
20
+ children: r.map((t, p) => /* @__PURE__ */ d(
25
21
  "td",
26
22
  {
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
23
+ className: m("table-component__wrapper__table__tbody__td", t.className, {
24
+ "table-component__wrapper__table__tbody__td--bordered": i,
25
+ "table-component__wrapper__table__tbody__td--sticky-left": b && p === 0
30
26
  }),
31
- align: _.align,
32
- children: _.render ? _.render(t[_.dataIndex], t) : String(t[_.dataIndex] ?? "")
27
+ align: t.align,
28
+ children: t.render ? t.render(_[t.dataIndex], _) : String(_[t.dataIndex] ?? "")
33
29
  },
34
- `${_.key}-${r}`
30
+ `${t.key}-${p}`
35
31
  ))
36
32
  },
37
- m
33
+ n
38
34
  );
39
- },
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
35
  }
46
36
  );
47
37
  export {
48
- K as MemoizedRow
38
+ g as MemoizedRow
49
39
  };
@@ -1,191 +1,168 @@
1
- import { jsx as n, jsxs as g } from "react/jsx-runtime";
2
- import K, { forwardRef as ee, useState as j, useMemo as te, useCallback as k, useEffect as ne } from "react";
3
- import i from "../../../_virtual/index.js";
1
+ import { jsx as t, jsxs as u } from "react/jsx-runtime";
2
+ import W, { forwardRef as X, useState as B, useMemo as Y, useCallback as w, useEffect as Z } from "react";
3
+ import l from "../../../_virtual/index.js";
4
4
  import '../../../assets/src/components/Ui/Table/Table.css';/* empty css */
5
- import { IconCaretDown as z, IconCaretUp as ae } from "../Icons/Icons.js";
6
- import { MemoizedRow as C } from "./MemoizedRow/MemoizedRow.js";
7
- import { Loader as re } from "../Loader/Loader.js";
8
- import { TableSkeletonRow as se } from "./TableSkeletonRow/TableSkeletonRow.js";
9
- const L = {
10
- asc: /* @__PURE__ */ n(z, { viewBox: "0 -6 24 24", "aria-hidden": "true" }),
11
- desc: /* @__PURE__ */ n(ae, { viewBox: "0 -4 24 24", "aria-hidden": "true" }),
12
- default: /* @__PURE__ */ n(z, { viewBox: "0 -6 24 24", "aria-hidden": "true" })
13
- }, le = ({
14
- columns: p,
15
- dataSource: l,
16
- rowKey: f,
17
- tableClassName: $,
18
- theadClassName: O,
19
- trTheadClassNames: U,
20
- thTheadClassNames: q,
21
- tbodyClassName: F,
22
- wrapperClassName: G,
23
- borderBottom: y = !1,
24
- stickyHeader: H = !1,
25
- stickyLeft: b = !1,
5
+ import { MemoizedRow as S } from "./MemoizedRow/MemoizedRow.js";
6
+ import { IconCaretDown as C, IconCaretUp as K } from "../Icons/Icons.js";
7
+ import { Loader as ee } from "../Loader/Loader.js";
8
+ import { TableSkeletonRow as te } from "./TableSkeletonRow/TableSkeletonRow.js";
9
+ const D = {
10
+ asc: /* @__PURE__ */ t(C, { viewBox: "0 -6 24 24", "aria-hidden": "true" }),
11
+ desc: /* @__PURE__ */ t(K, { viewBox: "0 -4 24 24", "aria-hidden": "true" }),
12
+ default: /* @__PURE__ */ t(C, { viewBox: "0 -6 24 24", "aria-hidden": "true" })
13
+ }, ne = ({
14
+ columns: f,
15
+ dataSource: i,
16
+ rowKey: o,
17
+ tableClassName: A,
18
+ theadClassName: j,
19
+ trTheadClassNames: E,
20
+ thTheadClassNames: L,
21
+ tbodyClassName: M,
22
+ wrapperClassName: $,
23
+ borderBottom: g = !1,
24
+ stickyHeader: z = !1,
25
+ stickyLeft: y = !1,
26
26
  bordered: m = !1,
27
- rowClassName: x,
28
- defaultSort: J,
27
+ rowClassName: U,
28
+ defaultSort: q,
29
29
  onClickTr: d,
30
- onClickTrHeader: P,
31
- loading: R = !1,
32
- hasMore: Q = !1,
33
- loadingIndicator: S,
34
- loaderRef: B,
35
- externalSorting: D = !1,
36
- entities: c,
37
- sortedIds: u,
38
- containerRef: V
39
- }, W) => {
40
- const T = K.useRef(null), o = !!c && !!u, [A, X] = j(l || []), [s, E] = j(
41
- J || null
42
- ), w = te(() => {
43
- if (!o)
44
- return D ? l : A;
45
- }, [o, l, A, D]), I = k(
46
- (e, t) => {
47
- if (o) {
48
- E({ key: e, order: t });
49
- return;
50
- }
51
- X((_) => [..._].sort((h, M) => {
52
- const r = h[e], a = M[e];
53
- 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;
54
- })), E({ key: e, order: t });
55
- },
30
+ onClickTrHeader: F,
31
+ loading: N = !1,
32
+ hasMore: G = !1,
33
+ loaderRef: v,
34
+ externalSorting: k = !0,
35
+ containerRef: H
36
+ }, J) => {
37
+ const x = W.useRef(null), [I, O] = B(i || []), [r, P] = B(
38
+ q || null
39
+ ), _ = Y(() => k ? i : I, [i, I, k]), R = w((e, a) => {
40
+ O((c) => [...c].sort((p, T) => {
41
+ const n = p[e], s = T[e];
42
+ return typeof n == "string" && typeof s == "string" ? a === "asc" ? n.localeCompare(s) : s.localeCompare(n) : typeof n == "number" && typeof s == "number" ? a === "asc" ? n - s : s - n : n instanceof Date && s instanceof Date ? a === "asc" ? n.getTime() - s.getTime() : s.getTime() - n.getTime() : 0;
43
+ })), P({ key: e, order: a });
44
+ }, []), h = w(
45
+ (e) => typeof o == "function" ? o(e) : String(e[o]),
56
46
  [o]
57
- ), N = k(
58
- (e) => typeof f == "function" ? f(e) : String(e[f]),
59
- [f]
60
- ), Y = k(
47
+ ), Q = w(
61
48
  (e) => {
62
- const _ = (s == null ? void 0 : s.key) === e && s.order === "asc" ? "desc" : "asc";
63
- I(e, _);
49
+ const c = (r == null ? void 0 : r.key) === e && r.order === "asc" ? "desc" : "asc";
50
+ R(e, c);
64
51
  },
65
- [s, I]
52
+ [r, R]
66
53
  );
67
- return ne(() => {
68
- const e = T.current;
54
+ return Z(() => {
55
+ const e = x.current;
69
56
  if (!e) return;
70
- const t = (_) => {
71
- const v = _.target, h = v.closest("tr");
72
- if (!h || v.closest("[data-no-bubble]")) return;
73
- const r = h.dataset.id;
74
- if (!(!r || !d))
75
- if (o && c) {
76
- const a = c[r];
77
- a && d(a);
78
- } else {
79
- const a = l == null ? void 0 : l.find((Z) => N(Z) === r);
80
- a && d(a);
81
- }
57
+ const a = (c) => {
58
+ const b = c.target, p = b.closest("tr");
59
+ if (!p || b.closest("[data-no-bubble]")) return;
60
+ const n = p.dataset.id;
61
+ if (!(!n || !d)) {
62
+ const s = i == null ? void 0 : i.find((V) => h(V) === n);
63
+ s && d(s);
64
+ }
82
65
  };
83
- return e.addEventListener("click", t), () => e.removeEventListener("click", t);
84
- }, [l, d, N, o, c]), /* @__PURE__ */ n("div", { className: i("table-component", G), children: /* @__PURE__ */ n(
66
+ return e.addEventListener("click", a), () => e.removeEventListener("click", a);
67
+ }, [i, d, h]), /* @__PURE__ */ t("div", { className: l("table-component", $), children: /* @__PURE__ */ t(
85
68
  "div",
86
69
  {
87
- className: i(
70
+ className: l(
88
71
  "table-component__wrapper",
89
72
  {
90
73
  bordered: m,
91
- borderBottom: y
74
+ borderBottom: g
92
75
  },
93
- $
76
+ A
94
77
  ),
95
- ref: V,
96
- children: /* @__PURE__ */ g(
78
+ ref: H,
79
+ children: /* @__PURE__ */ u(
97
80
  "table",
98
81
  {
99
- className: i("table-component__wrapper__table", {
82
+ className: l("table-component__wrapper__table", {
100
83
  bordered: m,
101
- borderBottom: y
84
+ borderBottom: g
102
85
  }),
103
- ref: W,
86
+ ref: J,
104
87
  children: [
105
- /* @__PURE__ */ n(
88
+ /* @__PURE__ */ t(
106
89
  "thead",
107
90
  {
108
- className: i(
91
+ className: l(
109
92
  "table-component__wrapper__table__thead",
110
93
  {
111
- stickyHeader: H
94
+ stickyHeader: z
112
95
  },
113
- O
96
+ j
114
97
  ),
115
- children: /* @__PURE__ */ n(
98
+ children: /* @__PURE__ */ t(
116
99
  "tr",
117
100
  {
118
- className: i(
101
+ className: l(
119
102
  "table-component__wrapper__table__thead__tr",
120
- U
103
+ E
121
104
  ),
122
- onClick: P,
123
- children: p.map((e, t) => /* @__PURE__ */ n(
105
+ onClick: F,
106
+ children: f.map((e, a) => /* @__PURE__ */ t(
124
107
  "th",
125
108
  {
126
- className: i(
109
+ className: l(
127
110
  "table-component__wrapper__table__thead__th",
128
111
  {
129
112
  bordered: m,
130
- stickyLeft: b && t === 0
113
+ stickyLeft: y && a === 0
131
114
  },
132
- q
115
+ L
133
116
  ),
134
117
  style: {
135
118
  ...e.width ? { width: e.width } : {},
136
119
  ...e.align ? { textAlign: e.align } : {}
137
120
  },
138
- onClick: () => e.sorted && Y(e.key),
139
- children: /* @__PURE__ */ g("div", { className: "th-content", children: [
140
- e.title,
141
- e.sorted && /* @__PURE__ */ n("span", { className: "sort-icon", children: (s == null ? void 0 : s.key) === e.key ? L[s.order] : L.default })
142
- ] })
121
+ onClick: () => e.sorted && Q(e.key),
122
+ children: /* @__PURE__ */ u(
123
+ "div",
124
+ {
125
+ style: {
126
+ display: "flex",
127
+ justifyContent: e.align === "right" ? "flex-end" : e.align === "center" ? "center" : "flex-start"
128
+ },
129
+ className: "th-content",
130
+ children: [
131
+ e.title,
132
+ e.sorted && /* @__PURE__ */ t("span", { className: "sort-icon", children: (r == null ? void 0 : r.key) === e.key ? D[r.order] : D.default })
133
+ ]
134
+ }
135
+ )
143
136
  },
144
- `${e.key}-${t}`
137
+ `${e.key}-${a}`
145
138
  ))
146
139
  }
147
140
  )
148
141
  }
149
142
  ),
150
- /* @__PURE__ */ g(
143
+ /* @__PURE__ */ u(
151
144
  "tbody",
152
145
  {
153
- ref: T,
154
- className: i("table-component__wrapper__table__tbody", F),
146
+ ref: x,
147
+ className: l("table-component__wrapper__table__tbody", M),
155
148
  children: [
156
- o && u ? u.map((e) => {
157
- const t = c == null ? void 0 : c[e];
158
- return t ? /* @__PURE__ */ n(
159
- C,
160
- {
161
- record: t,
162
- columns: p,
163
- rowKey: f,
164
- rowClassName: x,
165
- index: u.indexOf(e),
166
- stickyLeft: b,
167
- bordered: m,
168
- id: e
169
- },
170
- e
171
- ) : null;
172
- }) : w == null ? void 0 : w.map((e, t) => /* @__PURE__ */ n(
173
- C,
149
+ _ == null ? void 0 : _.map((e) => /* @__PURE__ */ t(
150
+ S,
174
151
  {
175
152
  record: e,
176
- columns: p,
177
- rowKey: f,
178
- rowClassName: x,
179
- index: t,
180
- stickyLeft: b,
153
+ columns: f,
154
+ rowKey: o,
155
+ rowClassName: U,
156
+ stickyLeft: y,
181
157
  bordered: m
182
158
  },
183
- N(e)
159
+ h(e)
184
160
  )),
185
- R ? /* @__PURE__ */ n("div", { className: "loading_table_init", children: /* @__PURE__ */ n(re, { className: "centered" }) }) : null,
186
- !R && Q && B && /* @__PURE__ */ n("tr", { ref: B, children: /* @__PURE__ */ n("td", { colSpan: p.length, children: S || /* @__PURE__ */ n(se, { colSpan: p.length }) }) })
161
+ N ? /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("div", { className: "loading_table_init", children: /* @__PURE__ */ t(ee, { className: "centered" }) }) }) }) : null,
162
+ !N && G && v && /* @__PURE__ */ t("tr", { ref: v, children: /* @__PURE__ */ t(te, { colSpan: f.length }) })
187
163
  ]
188
- }
164
+ },
165
+ "tbody"
189
166
  )
190
167
  ]
191
168
  }
@@ -193,7 +170,7 @@ const L = {
193
170
  },
194
171
  "wrapper"
195
172
  ) }, "table-component");
196
- }, ue = ee(le);
173
+ }, pe = X(ne);
197
174
  export {
198
- ue as Table
175
+ pe as Table
199
176
  };
@@ -1,11 +1,7 @@
1
- import { jsx as o, jsxs as t } from "react/jsx-runtime";
2
- import { Skeleton as e } from "../../Skeleton/Skeleton.js";
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { Skeleton as t } from "../../Skeleton/Skeleton.js";
3
3
  import '../../../../assets/src/components/Ui/Table/TableSkeletonRow/TableSkeletonRow.css';/* empty css */
4
- const n = ({ colSpan: r }) => /* @__PURE__ */ o("tr", { className: "skeleton-row", children: /* @__PURE__ */ t("td", { colSpan: r, children: [
5
- /* @__PURE__ */ o(e, {}),
6
- /* @__PURE__ */ o(e, {}),
7
- /* @__PURE__ */ o(e, {})
8
- ] }) });
4
+ const n = ({ colSpan: o }) => /* @__PURE__ */ e("td", { colSpan: o, children: /* @__PURE__ */ e("div", { className: "table-skeleton-row", children: [...Array(o)].map((l, r) => /* @__PURE__ */ e(t, {}, r)) }) });
9
5
  export {
10
6
  n as TableSkeletonRow
11
7
  };
@@ -1,33 +1,35 @@
1
- import { jsxs as v, jsx as d } from "react/jsx-runtime";
2
- import { createContext as f, useState as h, useCallback as u, useMemo as w, useContext as C } from "react";
3
- import P from "react-dom";
1
+ import { jsxs as v, jsx as l } from "react/jsx-runtime";
2
+ import { createContext as f, useState as h, useCallback as u, useMemo as w, useContext as g } from "react";
3
+ import C from "react-dom";
4
4
  import m from "../../src/context/ToastContext/ToastContext.module.scss.js";
5
- const l = f(void 0), y = () => {
6
- const e = C(l);
7
- if (!e)
5
+ const T = f(void 0), y = () => {
6
+ const o = g(T);
7
+ if (!o)
8
8
  throw new Error("useToast must be used within a ToastProvider");
9
- return e;
10
- }, M = ({ children: e }) => {
11
- const [T, a] = h([]), p = 3, n = 4e3, c = u((t) => {
12
- a((o) => o.filter((s) => s.id !== t));
13
- }, []), i = u(
9
+ return o;
10
+ }, M = ({ children: o }) => {
11
+ const [r, n] = h([]), p = 3, c = 4e3, i = u((t) => {
12
+ n((e) => e.filter((s) => s.id !== t));
13
+ }, []), d = u(
14
14
  (t) => {
15
- const o = {
15
+ const e = {
16
16
  id: Date.now(),
17
17
  message: t,
18
- duration: n
18
+ duration: c
19
19
  };
20
- a((s) => {
21
- const r = [...s, o];
22
- return r.length > p ? r.slice(1) : r;
23
- }), setTimeout(() => c(o.id), n);
20
+ n((s) => {
21
+ const a = [...s, e];
22
+ return a.length > p ? a.slice(1) : a;
23
+ }), setTimeout(() => i(e.id), c);
24
24
  },
25
- [c]
26
- ), x = w(() => ({ addToast: i }), [i]);
27
- return /* @__PURE__ */ v(l.Provider, { value: x, children: [
28
- e,
29
- P.createPortal(
30
- /* @__PURE__ */ d("div", { className: m.Wrapper, children: T.map((t) => /* @__PURE__ */ d("div", { className: m.Toast, children: t.message }, t.id)) }),
25
+ [i]
26
+ );
27
+ console.log("тест addToast"), console.log("toasts", r);
28
+ const x = w(() => ({ addToast: d }), [d]);
29
+ return /* @__PURE__ */ v(T.Provider, { value: x, children: [
30
+ o,
31
+ C.createPortal(
32
+ /* @__PURE__ */ l("div", { className: m.Wrapper, children: r.map((t) => /* @__PURE__ */ l("div", { className: m.Toast, children: t.message }, t.id)) }),
31
33
  document.body
32
34
  )
33
35
  ] });
package/dist/main.d.ts CHANGED
@@ -1180,7 +1180,7 @@ declare type TablesProps<T extends object = Record<string, unknown>> = {
1180
1180
  wrapperClassName?: string;
1181
1181
  borderBottom?: boolean;
1182
1182
  bordered?: boolean;
1183
- rowClassName?: (row: T, index: number) => string;
1183
+ rowClassName?: (row: T) => string;
1184
1184
  defaultSort?: {
1185
1185
  key: string;
1186
1186
  order: "asc" | "desc";
@@ -1189,10 +1189,7 @@ declare type TablesProps<T extends object = Record<string, unknown>> = {
1189
1189
  onClickTrHeader?: () => void;
1190
1190
  loading?: boolean;
1191
1191
  hasMore?: boolean;
1192
- loadingIndicator?: default_2.ReactNode;
1193
1192
  loaderRef?: default_2.Ref<HTMLTableRowElement>;
1194
- entities?: Record<string, T>;
1195
- sortedIds?: string[];
1196
1193
  externalSorting?: boolean;
1197
1194
  containerRef?: default_2.RefObject<HTMLDivElement>;
1198
1195
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triafly-ui-kit",
3
- "version": "1.0.58",
3
+ "version": "1.0.59",
4
4
  "description": "UI Kit from Triafly",
5
5
  "main": "./dist/main.js",
6
6
  "module": "./dist/main.js",
@@ -1 +0,0 @@
1
- ._skeleton_1xagr_1{display:inline-block;background-color:var(--color-bg-neutral-medium-default)}._animated_1xagr_6{background:linear-gradient(90deg,var(--color-bg-neutral-medium-default) 25%,var(--color-bg-neutral-medium-default) 50%,var(--color-bg-neutral-medium-default) 75%);background-size:200% 100%;animation:_skeleton-loading_1xagr_1 1.5s infinite linear}@keyframes _skeleton-loading_1xagr_1{0%{background-position:200% 0}to{background-position:-200% 0}}
@@ -1,9 +0,0 @@
1
- import '../../../../assets/src/components/Ui/Skeleton/Skeleton.module.css';const e = "_skeleton_1xagr_1", t = "_animated_1xagr_6", a = {
2
- skeleton: e,
3
- animated: t
4
- };
5
- export {
6
- t as animated,
7
- a as default,
8
- e as skeleton
9
- };