@eyesee/ui-components 0.16.0 → 0.17.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.
- package/dist/components/Button/Button.js +19 -19
- package/dist/components/ImagePlaceholder/ImageHoverPreview/ImageHoverPreview.js +29 -36
- package/dist/components/ImagePlaceholder/ImageHoverPreview/ImageHoverPreview.module.scss.js +4 -6
- package/dist/components/Table/Table.d.ts +225 -0
- package/dist/components/Table/Table.js +135 -0
- package/dist/components/Table/Table.module.scss.js +33 -0
- package/dist/components/Table/TableColumnHeader/TableColumnHeader.d.ts +33 -0
- package/dist/components/Table/TableColumnHeader/TableColumnHeader.js +60 -0
- package/dist/components/Table/TableColumnHeader/TableColumnHeader.module.scss.js +11 -0
- package/dist/components/Table/tableSort/tableSortUtils.d.ts +28 -0
- package/dist/components/Table/tableSort/tableSortUtils.js +20 -0
- package/dist/components/Table/tableSort/useTableClientSort.d.ts +75 -0
- package/dist/components/Table/tableSort/useTableClientSort.js +16 -0
- package/dist/components/Tooltip/Tooltip.module.scss.js +26 -26
- package/dist/components/index.d.ts +2 -0
- package/dist/index.js +52 -45
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Sort helpers for {@link Table} (client-side and header arrow behaviour).
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {object} TableSort
|
|
6
|
+
* @property {string} columnId
|
|
7
|
+
* @property {'asc'|'desc'} direction
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {object} TableSortColumn
|
|
11
|
+
* @property {string} id
|
|
12
|
+
* @property {(row: *) => string|number|null|undefined} [sortValue]
|
|
13
|
+
*/
|
|
14
|
+
/** @param {TableSort|null} sort @param {string} columnId @param {'asc'|'desc'} direction */
|
|
15
|
+
export function getTableSortFromArrowClick(sort: TableSort | null, columnId: string, direction: "asc" | "desc"): {
|
|
16
|
+
columnId: string;
|
|
17
|
+
direction: "asc" | "desc";
|
|
18
|
+
};
|
|
19
|
+
/** @param {*[]} rows @param {TableSort|null} sort @param {TableSortColumn[]} columns */
|
|
20
|
+
export function sortTableRows(rows: any[], sort: TableSort | null, columns: TableSortColumn[]): any[];
|
|
21
|
+
export type TableSort = {
|
|
22
|
+
columnId: string;
|
|
23
|
+
direction: "asc" | "desc";
|
|
24
|
+
};
|
|
25
|
+
export type TableSortColumn = {
|
|
26
|
+
id: string;
|
|
27
|
+
sortValue?: (row: any) => string | number | null | undefined;
|
|
28
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function o(n, e, u) {
|
|
2
|
+
return (n == null ? void 0 : n.columnId) === e && n.direction === u ? null : { columnId: e, direction: u };
|
|
3
|
+
}
|
|
4
|
+
function f(n, e) {
|
|
5
|
+
return n == null || e == null ? n == null ? e == null ? 0 : 1 : -1 : typeof n == "number" && typeof e == "number" ? n - e : String(n).localeCompare(String(e), void 0, { numeric: !0 });
|
|
6
|
+
}
|
|
7
|
+
function d(n, e, u) {
|
|
8
|
+
var t;
|
|
9
|
+
if (!e)
|
|
10
|
+
return n;
|
|
11
|
+
const r = (t = u.find((l) => l.id === e.columnId)) == null ? void 0 : t.sortValue;
|
|
12
|
+
if (!r)
|
|
13
|
+
return n;
|
|
14
|
+
const i = e.direction === "asc" ? 1 : -1;
|
|
15
|
+
return [...n].sort((l, c) => i * f(r(l), r(c)));
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
o as getTableSortFromArrowClick,
|
|
19
|
+
d as sortTableRows
|
|
20
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./tableSortUtils').TableSort} TableSort
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('./tableSortUtils').TableSortColumn} TableSortColumn
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {object} UseTableClientSortOptions
|
|
9
|
+
* @property {*[]} rows
|
|
10
|
+
* Source rows (unsorted).
|
|
11
|
+
* @property {TableSortColumn[]} columns
|
|
12
|
+
* Column definitions with `sortValue` on sortable columns.
|
|
13
|
+
* @property {TableSort|null} [initialSort=null]
|
|
14
|
+
* Initial sort state.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {object} UseTableClientSortResult
|
|
18
|
+
* @property {TableSort|null} sort
|
|
19
|
+
* Current sort (pass to {@link Table} as `sort`).
|
|
20
|
+
* @property {(sort: TableSort|null) => void} onSortChange
|
|
21
|
+
* Sort change handler (pass to {@link Table} as `onSortChange`).
|
|
22
|
+
* @property {*[]} sortedRows
|
|
23
|
+
* Rows sorted for the current `sort` (pass to {@link Table} as `rows`).
|
|
24
|
+
* @property {(sort: TableSort|null) => void} setSort
|
|
25
|
+
* Imperative sort update.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Manages client-side table sort state and derives sorted rows.
|
|
29
|
+
*
|
|
30
|
+
* @param {UseTableClientSortOptions} options
|
|
31
|
+
* @returns {UseTableClientSortResult}
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const { sort, onSortChange, sortedRows } = useTableClientSort({
|
|
35
|
+
* rows: data,
|
|
36
|
+
* columns,
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* <Table sort={sort} onSortChange={onSortChange} rows={sortedRows} columns={columns} />
|
|
40
|
+
*/
|
|
41
|
+
export function useTableClientSort({ rows, columns, initialSort }: UseTableClientSortOptions): UseTableClientSortResult;
|
|
42
|
+
export type TableSort = import("./tableSortUtils").TableSort;
|
|
43
|
+
export type TableSortColumn = import("./tableSortUtils").TableSortColumn;
|
|
44
|
+
export type UseTableClientSortOptions = {
|
|
45
|
+
/**
|
|
46
|
+
* Source rows (unsorted).
|
|
47
|
+
*/
|
|
48
|
+
rows: any[];
|
|
49
|
+
/**
|
|
50
|
+
* Column definitions with `sortValue` on sortable columns.
|
|
51
|
+
*/
|
|
52
|
+
columns: TableSortColumn[];
|
|
53
|
+
/**
|
|
54
|
+
* Initial sort state.
|
|
55
|
+
*/
|
|
56
|
+
initialSort?: TableSort | null;
|
|
57
|
+
};
|
|
58
|
+
export type UseTableClientSortResult = {
|
|
59
|
+
/**
|
|
60
|
+
* Current sort (pass to {@link Table} as `sort`).
|
|
61
|
+
*/
|
|
62
|
+
sort: TableSort | null;
|
|
63
|
+
/**
|
|
64
|
+
* Sort change handler (pass to {@link Table} as `onSortChange`).
|
|
65
|
+
*/
|
|
66
|
+
onSortChange: (sort: TableSort | null) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Rows sorted for the current `sort` (pass to {@link Table} as `rows`).
|
|
69
|
+
*/
|
|
70
|
+
sortedRows: any[];
|
|
71
|
+
/**
|
|
72
|
+
* Imperative sort update.
|
|
73
|
+
*/
|
|
74
|
+
setSort: (sort: TableSort | null) => void;
|
|
75
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useState as u, useMemo as c, useCallback as i } from "react";
|
|
2
|
+
import { sortTableRows as m } from "./tableSortUtils.js";
|
|
3
|
+
function f({ rows: o, columns: e, initialSort: s = null }) {
|
|
4
|
+
const [t, r] = u(s), n = c(() => m(o, t, e), [e, o, t]), a = i((l) => {
|
|
5
|
+
r(l);
|
|
6
|
+
}, []);
|
|
7
|
+
return {
|
|
8
|
+
sort: t,
|
|
9
|
+
onSortChange: a,
|
|
10
|
+
sortedRows: n,
|
|
11
|
+
setSort: r
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
f as useTableClientSort
|
|
16
|
+
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
const t = "
|
|
1
|
+
const t = "_wrapper_1h62q_3", o = "_fullWidth_1h62q_10", _ = "_tooltip_1h62q_17", n = "_dark_1h62q_35", e = "_light_1h62q_44", h = "_withArrow_1h62q_55", l = "_top_1h62q_63", i = "_bottom_1h62q_71", c = "_left_1h62q_79", s = "_right_1h62q_87", r = "_header_1h62q_111", q = "_titleRow_1h62q_119", p = "_title_1h62q_119", w = "_content_1h62q_134", a = "_contentText_1h62q_144", d = "_noTitleWithIcon_1h62q_150", T = "_noTitleWithClose_1h62q_154", W = "_closeButton_1h62q_160", f = {
|
|
2
2
|
wrapper: t,
|
|
3
3
|
fullWidth: o,
|
|
4
4
|
tooltip: _,
|
|
5
5
|
dark: n,
|
|
6
6
|
light: e,
|
|
7
|
-
withArrow:
|
|
8
|
-
top:
|
|
9
|
-
bottom:
|
|
10
|
-
left:
|
|
7
|
+
withArrow: h,
|
|
8
|
+
top: l,
|
|
9
|
+
bottom: i,
|
|
10
|
+
left: c,
|
|
11
11
|
right: s,
|
|
12
|
-
header:
|
|
13
|
-
titleRow:
|
|
14
|
-
title:
|
|
15
|
-
content:
|
|
16
|
-
contentText:
|
|
17
|
-
noTitleWithIcon:
|
|
18
|
-
noTitleWithClose:
|
|
19
|
-
closeButton:
|
|
12
|
+
header: r,
|
|
13
|
+
titleRow: q,
|
|
14
|
+
title: p,
|
|
15
|
+
content: w,
|
|
16
|
+
contentText: a,
|
|
17
|
+
noTitleWithIcon: d,
|
|
18
|
+
noTitleWithClose: T,
|
|
19
|
+
closeButton: W
|
|
20
20
|
};
|
|
21
21
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
i as bottom,
|
|
23
|
+
W as closeButton,
|
|
24
|
+
w as content,
|
|
25
|
+
a as contentText,
|
|
26
26
|
n as dark,
|
|
27
|
-
|
|
27
|
+
f as default,
|
|
28
28
|
o as fullWidth,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
r as header,
|
|
30
|
+
c as left,
|
|
31
31
|
e as light,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
T as noTitleWithClose,
|
|
33
|
+
d as noTitleWithIcon,
|
|
34
34
|
s as right,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
p as title,
|
|
36
|
+
q as titleRow,
|
|
37
37
|
_ as tooltip,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
l as top,
|
|
39
|
+
h as withArrow,
|
|
40
40
|
t as wrapper
|
|
41
41
|
};
|
|
@@ -27,4 +27,6 @@ export { Modal } from "./Modal/Modal";
|
|
|
27
27
|
export { default as ImagePlaceholder } from "./ImagePlaceholder/ImagePlaceholder";
|
|
28
28
|
export { ImageHoverPreview } from "./ImagePlaceholder/ImageHoverPreview/ImageHoverPreview";
|
|
29
29
|
export { default as ImageWithData } from "./ImageWithData/ImageWithData";
|
|
30
|
+
export { useTableClientSort } from "./Table/tableSort/useTableClientSort";
|
|
30
31
|
export { normalizeTabsOptions, normalizeTabOption } from "./Tabs/tabsUtils";
|
|
32
|
+
export { Table, getTableSortFromArrowClick, sortTableRows } from "./Table/Table";
|
package/dist/index.js
CHANGED
|
@@ -1,64 +1,71 @@
|
|
|
1
1
|
/* empty css */
|
|
2
2
|
import { default as t } from "./components/ImagePlaceholder/ImagePlaceholder.js";
|
|
3
|
-
import { default as
|
|
3
|
+
import { default as p } from "./components/ImageWithData/ImageWithData.js";
|
|
4
4
|
import { Avatar as x } from "./components/Avatar/Avatar.js";
|
|
5
5
|
import { Badge as i } from "./components/Badge/Badge.js";
|
|
6
6
|
import { Button as s } from "./components/Button/Button.js";
|
|
7
|
-
import { Checkbox as
|
|
8
|
-
import { DropdownList as
|
|
7
|
+
import { Checkbox as b } from "./components/Checkbox/Checkbox.js";
|
|
8
|
+
import { DropdownList as d } from "./components/DropdownList/DropdownList.js";
|
|
9
9
|
import { EllipsisTooltip as I } from "./components/EllipsisTooltip/EllipsisTooltip.js";
|
|
10
10
|
import { ExpandableItem as c } from "./components/ExpandableItem/ExpandableItem.js";
|
|
11
|
-
import { FileType as
|
|
12
|
-
import { ImageHoverPreview as
|
|
13
|
-
import { Infobox as
|
|
14
|
-
import { InputField as
|
|
15
|
-
import { ListItem as
|
|
16
|
-
import { Modal as
|
|
17
|
-
import { Notifications as
|
|
18
|
-
import { Pill as
|
|
19
|
-
import { ProgressBar as
|
|
20
|
-
import { Radio as
|
|
11
|
+
import { FileType as v } from "./components/FileType/FileType.js";
|
|
12
|
+
import { ImageHoverPreview as P } from "./components/ImagePlaceholder/ImageHoverPreview/ImageHoverPreview.js";
|
|
13
|
+
import { Infobox as B } from "./components/Infobox/Infobox.js";
|
|
14
|
+
import { InputField as L } from "./components/Fields/InputField/InputField.js";
|
|
15
|
+
import { ListItem as k } from "./components/ListItem/ListItem.js";
|
|
16
|
+
import { Modal as A } from "./components/Modal/Modal.js";
|
|
17
|
+
import { Notifications as E } from "./components/Notifications/Notifications.js";
|
|
18
|
+
import { Pill as N } from "./components/Pill/Pill.js";
|
|
19
|
+
import { ProgressBar as R } from "./components/ProgressBar/ProgressBar.js";
|
|
20
|
+
import { Radio as M } from "./components/Radio/Radio.js";
|
|
21
21
|
import { SelectField as j } from "./components/Fields/SelectField/SelectField.js";
|
|
22
22
|
import { Tab as G } from "./components/Tab/Tab.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
23
|
+
import { Table as K } from "./components/Table/Table.js";
|
|
24
|
+
import { Tabs as U } from "./components/Tabs/Tabs.js";
|
|
25
|
+
import { Tag as X } from "./components/Tag/Tag.js";
|
|
26
|
+
import { TextField as Z } from "./components/Fields/TextField/TextField.js";
|
|
27
|
+
import { TextHoverable as $ } from "./components/TextHoverable/TextHoverable.js";
|
|
28
|
+
import { Toggle as ro } from "./components/Toggle/Toggle.js";
|
|
29
|
+
import { Tooltip as to } from "./components/Tooltip/Tooltip.js";
|
|
30
|
+
import { getTableSortFromArrowClick as po, sortTableRows as fo } from "./components/Table/tableSort/tableSortUtils.js";
|
|
31
|
+
import { normalizeTabOption as ao, normalizeTabsOptions as io } from "./components/Tabs/tabsUtils.js";
|
|
32
|
+
import { useListItems as so } from "./components/ListItem/useListItems.js";
|
|
33
|
+
import { useNotifications as bo } from "./components/Notifications/useNotifications.js";
|
|
34
|
+
import { useTableClientSort as go } from "./components/Table/tableSort/useTableClientSort.js";
|
|
32
35
|
export {
|
|
33
36
|
x as Avatar,
|
|
34
37
|
i as Badge,
|
|
35
38
|
s as Button,
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
b as Checkbox,
|
|
40
|
+
d as DropdownList,
|
|
38
41
|
I as EllipsisTooltip,
|
|
39
42
|
c as ExpandableItem,
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
v as FileType,
|
|
44
|
+
P as ImageHoverPreview,
|
|
42
45
|
t as ImagePlaceholder,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
p as ImageWithData,
|
|
47
|
+
B as Infobox,
|
|
48
|
+
L as InputField,
|
|
49
|
+
k as ListItem,
|
|
50
|
+
A as Modal,
|
|
51
|
+
E as Notifications,
|
|
52
|
+
N as Pill,
|
|
53
|
+
R as ProgressBar,
|
|
54
|
+
M as Radio,
|
|
52
55
|
j as SelectField,
|
|
53
56
|
G as Tab,
|
|
54
|
-
K as
|
|
55
|
-
U as
|
|
56
|
-
X as
|
|
57
|
-
Z as
|
|
58
|
-
$ as
|
|
59
|
-
ro as
|
|
60
|
-
to as
|
|
61
|
-
po as
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
K as Table,
|
|
58
|
+
U as Tabs,
|
|
59
|
+
X as Tag,
|
|
60
|
+
Z as TextField,
|
|
61
|
+
$ as TextHoverable,
|
|
62
|
+
ro as Toggle,
|
|
63
|
+
to as Tooltip,
|
|
64
|
+
po as getTableSortFromArrowClick,
|
|
65
|
+
ao as normalizeTabOption,
|
|
66
|
+
io as normalizeTabsOptions,
|
|
67
|
+
fo as sortTableRows,
|
|
68
|
+
so as useListItems,
|
|
69
|
+
bo as useNotifications,
|
|
70
|
+
go as useTableClientSort
|
|
64
71
|
};
|