@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.
@@ -0,0 +1,11 @@
1
+ const e = "_headerTitle_118g8_3", t = "_sortHeader_118g8_13", s = "_sortIcons_118g8_20", o = {
2
+ headerTitle: e,
3
+ sortHeader: t,
4
+ sortIcons: s
5
+ };
6
+ export {
7
+ o as default,
8
+ e as headerTitle,
9
+ t as sortHeader,
10
+ s as sortIcons
11
+ };
@@ -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 = "_wrapper_1fyp1_3", o = "_fullWidth_1fyp1_11", _ = "_tooltip_1fyp1_18", n = "_dark_1fyp1_36", e = "_light_1fyp1_45", l = "_withArrow_1fyp1_56", i = "_top_1fyp1_64", c = "_bottom_1fyp1_72", p = "_left_1fyp1_80", s = "_right_1fyp1_88", f = "_header_1fyp1_112", r = "_titleRow_1fyp1_120", h = "_title_1fyp1_120", y = "_content_1fyp1_135", w = "_contentText_1fyp1_145", a = "_noTitleWithIcon_1fyp1_151", d = "_noTitleWithClose_1fyp1_155", T = "_closeButton_1fyp1_161", W = {
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: l,
8
- top: i,
9
- bottom: c,
10
- left: p,
7
+ withArrow: h,
8
+ top: l,
9
+ bottom: i,
10
+ left: c,
11
11
  right: s,
12
- header: f,
13
- titleRow: r,
14
- title: h,
15
- content: y,
16
- contentText: w,
17
- noTitleWithIcon: a,
18
- noTitleWithClose: d,
19
- closeButton: T
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
- c as bottom,
23
- T as closeButton,
24
- y as content,
25
- w as contentText,
22
+ i as bottom,
23
+ W as closeButton,
24
+ w as content,
25
+ a as contentText,
26
26
  n as dark,
27
- W as default,
27
+ f as default,
28
28
  o as fullWidth,
29
- f as header,
30
- p as left,
29
+ r as header,
30
+ c as left,
31
31
  e as light,
32
- d as noTitleWithClose,
33
- a as noTitleWithIcon,
32
+ T as noTitleWithClose,
33
+ d as noTitleWithIcon,
34
34
  s as right,
35
- h as title,
36
- r as titleRow,
35
+ p as title,
36
+ q as titleRow,
37
37
  _ as tooltip,
38
- i as top,
39
- l as withArrow,
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 m } from "./components/ImageWithData/ImageWithData.js";
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 n } from "./components/Checkbox/Checkbox.js";
8
- import { DropdownList as b } from "./components/DropdownList/DropdownList.js";
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 F } from "./components/FileType/FileType.js";
12
- import { ImageHoverPreview as h } from "./components/ImagePlaceholder/ImageHoverPreview/ImageHoverPreview.js";
13
- import { Infobox as L } from "./components/Infobox/Infobox.js";
14
- import { InputField as z } from "./components/Fields/InputField/InputField.js";
15
- import { ListItem as E } from "./components/ListItem/ListItem.js";
16
- import { Modal as N } from "./components/Modal/Modal.js";
17
- import { Notifications as k } from "./components/Notifications/Notifications.js";
18
- import { Pill as A } from "./components/Pill/Pill.js";
19
- import { ProgressBar as M } from "./components/ProgressBar/ProgressBar.js";
20
- import { Radio as S } from "./components/Radio/Radio.js";
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 { Tabs as K } from "./components/Tabs/Tabs.js";
24
- import { Tag as U } from "./components/Tag/Tag.js";
25
- import { TextField as X } from "./components/Fields/TextField/TextField.js";
26
- import { TextHoverable as Z } from "./components/TextHoverable/TextHoverable.js";
27
- import { Toggle as $ } from "./components/Toggle/Toggle.js";
28
- import { Tooltip as ro } from "./components/Tooltip/Tooltip.js";
29
- import { normalizeTabOption as to, normalizeTabsOptions as po } from "./components/Tabs/tabsUtils.js";
30
- import { useListItems as fo } from "./components/ListItem/useListItems.js";
31
- import { useNotifications as ao } from "./components/Notifications/useNotifications.js";
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
- n as Checkbox,
37
- b as DropdownList,
39
+ b as Checkbox,
40
+ d as DropdownList,
38
41
  I as EllipsisTooltip,
39
42
  c as ExpandableItem,
40
- F as FileType,
41
- h as ImageHoverPreview,
43
+ v as FileType,
44
+ P as ImageHoverPreview,
42
45
  t as ImagePlaceholder,
43
- m as ImageWithData,
44
- L as Infobox,
45
- z as InputField,
46
- E as ListItem,
47
- N as Modal,
48
- k as Notifications,
49
- A as Pill,
50
- M as ProgressBar,
51
- S as Radio,
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 Tabs,
55
- U as Tag,
56
- X as TextField,
57
- Z as TextHoverable,
58
- $ as Toggle,
59
- ro as Tooltip,
60
- to as normalizeTabOption,
61
- po as normalizeTabsOptions,
62
- fo as useListItems,
63
- ao as useNotifications
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
  };