@eyesee/ui-components 0.15.1 → 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/icons-v2/EditSquareIcon.d.ts +123 -0
- package/dist/components/icons-v2/EditSquareIcon.js +15 -0
- package/dist/components/icons-v2/index.d.ts +1 -0
- package/dist/components/icons-v2/index.js +52 -50
- 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
|
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @callback EditSquareIconClickHandler
|
|
3
|
+
* @returns {void}
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Shared {@link IconProps} for this icon. All optional.
|
|
7
|
+
*
|
|
8
|
+
* @typedef {object} EditSquareIconProps
|
|
9
|
+
*
|
|
10
|
+
* @property {import('./constants').IconSize} [iconSize='m']
|
|
11
|
+
* T-shirt size token. Controls `width`/`height` and stroke width. Default `'m'`.
|
|
12
|
+
* @property {EditSquareIconClickHandler} [onClick=null]
|
|
13
|
+
* Click handler. When set the icon is clickable. Default `null`.
|
|
14
|
+
* @property {string} [fill='none']
|
|
15
|
+
* SVG fill colour. Default `'none'`.
|
|
16
|
+
* @property {string} [strokeColor='currentColor']
|
|
17
|
+
* SVG stroke colour. Accepts any valid CSS colour. Default `'currentColor'`.
|
|
18
|
+
* @property {string} [strokeColorOnHover]
|
|
19
|
+
* Stroke colour applied on hover.
|
|
20
|
+
* @property {string} [fillOnHover]
|
|
21
|
+
* Fill colour applied on hover.
|
|
22
|
+
* @property {boolean} [disabled]
|
|
23
|
+
* Applies disabled colour tokens and ignores clicks.
|
|
24
|
+
* @property {boolean} [animated=false]
|
|
25
|
+
* When `true`, applies the spinner animation class. Default `false`.
|
|
26
|
+
* @property {number} [viewBoxSize]
|
|
27
|
+
* Custom viewBox size for icons that are not 32×32. Sets `0 0 {n} {n}`.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link IconProps}
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* SVG edit icon (document square with a pencil) used for an edit action.
|
|
33
|
+
* Source: 24×24 glyph scaled onto the 32×32 grid (`32/24`).
|
|
34
|
+
*
|
|
35
|
+
* ## Props
|
|
36
|
+
*
|
|
37
|
+
* All optional.
|
|
38
|
+
*
|
|
39
|
+
* **iconSize** `'s' | 'm' | 'l' | 'xl' | 'xxl' | '4xl'` — default `'m'`
|
|
40
|
+
* T-shirt size token. Controls `width`/`height` and stroke width.
|
|
41
|
+
*
|
|
42
|
+
* **onClick** `() => void` — default `null`
|
|
43
|
+
* Click handler. When set the icon is clickable.
|
|
44
|
+
*
|
|
45
|
+
* **fill** `string` — default `'none'`
|
|
46
|
+
* SVG fill colour.
|
|
47
|
+
*
|
|
48
|
+
* **strokeColor** `string` — default `'currentColor'`
|
|
49
|
+
* SVG stroke colour. Accepts any valid CSS colour.
|
|
50
|
+
*
|
|
51
|
+
* **strokeColorOnHover** `string` — no default
|
|
52
|
+
* Stroke colour applied on hover.
|
|
53
|
+
*
|
|
54
|
+
* **fillOnHover** `string` — no default
|
|
55
|
+
* Fill colour applied on hover.
|
|
56
|
+
*
|
|
57
|
+
* **disabled** `boolean` — no default
|
|
58
|
+
* Applies disabled colour tokens and ignores clicks.
|
|
59
|
+
*
|
|
60
|
+
* **animated** `boolean` — default `false`
|
|
61
|
+
* When `true`, applies the spinner animation class.
|
|
62
|
+
*
|
|
63
|
+
* **viewBoxSize** `number` — no default
|
|
64
|
+
* Custom viewBox size for icons that are not 32×32. Omit → `0 0 32 32`.
|
|
65
|
+
*
|
|
66
|
+
* @param {EditSquareIconProps} props
|
|
67
|
+
* @returns {import('react').ReactElement}
|
|
68
|
+
*
|
|
69
|
+
* @example <caption>Playground</caption>
|
|
70
|
+
* import { EditSquareIcon } from '@eyesee/ui-components/icons';
|
|
71
|
+
*
|
|
72
|
+
* <EditSquareIcon iconSize="m" strokeColor="#333333" fill="none" />
|
|
73
|
+
*
|
|
74
|
+
* @example <caption>Gallery</caption>
|
|
75
|
+
* import { EditSquareIcon } from '@eyesee/ui-components/icons';
|
|
76
|
+
*
|
|
77
|
+
* <EditSquareIcon iconSize="s" strokeColor="#333333" fill="none" />
|
|
78
|
+
* <EditSquareIcon iconSize="m" strokeColor="#333333" fill="none" />
|
|
79
|
+
* <EditSquareIcon iconSize="l" strokeColor="#333333" fill="none" />
|
|
80
|
+
*/
|
|
81
|
+
export const EditSquareIcon: (props: IconProps) => import("react").JSX.Element;
|
|
82
|
+
export type EditSquareIconClickHandler = () => void;
|
|
83
|
+
/**
|
|
84
|
+
* Shared {@link IconProps} for this icon. All optional.
|
|
85
|
+
*/
|
|
86
|
+
export type EditSquareIconProps = {
|
|
87
|
+
/**
|
|
88
|
+
* T-shirt size token. Controls `width`/`height` and stroke width. Default `'m'`.
|
|
89
|
+
*/
|
|
90
|
+
iconSize?: import("./constants").IconSize;
|
|
91
|
+
/**
|
|
92
|
+
* Click handler. When set the icon is clickable. Default `null`.
|
|
93
|
+
*/
|
|
94
|
+
onClick?: EditSquareIconClickHandler;
|
|
95
|
+
/**
|
|
96
|
+
* SVG fill colour. Default `'none'`.
|
|
97
|
+
*/
|
|
98
|
+
fill?: string;
|
|
99
|
+
/**
|
|
100
|
+
* SVG stroke colour. Accepts any valid CSS colour. Default `'currentColor'`.
|
|
101
|
+
*/
|
|
102
|
+
strokeColor?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Stroke colour applied on hover.
|
|
105
|
+
*/
|
|
106
|
+
strokeColorOnHover?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Fill colour applied on hover.
|
|
109
|
+
*/
|
|
110
|
+
fillOnHover?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Applies disabled colour tokens and ignores clicks.
|
|
113
|
+
*/
|
|
114
|
+
disabled?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* When `true`, applies the spinner animation class. Default `false`.
|
|
117
|
+
*/
|
|
118
|
+
animated?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Custom viewBox size for icons that are not 32×32. Sets `0 0 {n} {n}`.
|
|
121
|
+
*/
|
|
122
|
+
viewBoxSize?: number;
|
|
123
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { createIcon as C } from "./createIcon.js";
|
|
3
|
+
const i = C(({ strokeColor: o, strokeWidth: r }) => /* @__PURE__ */ t(
|
|
4
|
+
"path",
|
|
5
|
+
{
|
|
6
|
+
d: "M9.3333 9.3333H8C7.2928 9.3333 6.6145 9.6143 6.1144 10.1144C5.6143 10.6145 5.3333 11.2928 5.3333 12V24C5.3333 24.7072 5.6143 25.3855 6.1144 25.8856C6.6145 26.3857 7.2928 26.6667 8 26.6667H20C20.7072 26.6667 21.3855 26.3857 21.8856 25.8856C22.3857 25.3855 22.6667 24.7072 22.6667 24V22.6667M21.3333 6.6667L25.3333 10.6667M27.18 8.7801C27.7051 8.255 28.0001 7.5428 28.0001 6.8001C28.0001 6.0575 27.7051 5.3453 27.18 4.8201C26.6549 4.295 25.9427 4 25.2 4C24.4573 4 23.7451 4.295 23.22 4.8201L12 16.0001V20.0001H16L27.18 8.7801Z",
|
|
7
|
+
stroke: o,
|
|
8
|
+
strokeWidth: r,
|
|
9
|
+
strokeLinecap: "round",
|
|
10
|
+
strokeLinejoin: "round"
|
|
11
|
+
}
|
|
12
|
+
));
|
|
13
|
+
export {
|
|
14
|
+
i as EditSquareIcon
|
|
15
|
+
};
|
|
@@ -213,6 +213,7 @@ export { ColumnIcon } from "./ColumnIcon";
|
|
|
213
213
|
export { ListCheckIcon } from "./ListCheckIcon";
|
|
214
214
|
export { ImagesIcon } from "./ImagesIcon";
|
|
215
215
|
export { EditImageIcon } from "./EditImageIcon";
|
|
216
|
+
export { EditSquareIcon } from "./EditSquareIcon";
|
|
216
217
|
export { AddImageIcon } from "./AddImageIcon";
|
|
217
218
|
export { PackseeAttractIcon } from "./PackseeAttractIcon";
|
|
218
219
|
export { PackseeEngageIcon } from "./PackseeEngageIcon";
|