@trackunit/react-table-base-components 0.0.29 → 0.0.32
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/index.cjs.js +73 -0
- package/index.esm.js +72 -3
- package/package.json +4 -3
- package/src/components/ImageCell/ImageCell.d.ts +15 -6
- package/src/components/NumberCell/NumberCell.d.ts +18 -6
- package/src/index.d.ts +4 -0
package/index.cjs.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactFormComponents = require('@trackunit/react-form-components');
|
|
7
7
|
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
8
|
+
var dateAndTimeUtils = require('@trackunit/date-and-time-utils');
|
|
8
9
|
var reactComponents = require('@trackunit/react-components');
|
|
9
10
|
var react = require('react');
|
|
10
11
|
|
|
@@ -21,6 +22,33 @@ const CheckboxCell = ({ checked, className, dataTestId }) => {
|
|
|
21
22
|
return (jsxRuntime.jsx("div", { className: cvaCheckboxCell({ className }), "data-testid": dataTestId, children: jsxRuntime.jsx(reactFormComponents.Checkbox, { readOnly: true, checked: checked }) }));
|
|
22
23
|
};
|
|
23
24
|
|
|
25
|
+
const cvaDateTimeCell = cssClassVarianceUtilities.cvaMerge([""]);
|
|
26
|
+
const cvaDateTime = cssClassVarianceUtilities.cvaMerge(["slashed-zero", "text-neutral-700", "text-sm", "text-ellipsis"]);
|
|
27
|
+
const cvaDateTimeSince = cssClassVarianceUtilities.cvaMerge(["slashed-zero", "text-neutral-500", "text-sm", "text-ellipsis"]);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* DateTimeCell is used for render a date and or time in a table cell.
|
|
31
|
+
*
|
|
32
|
+
* @param {DateTimeCellProps} props - The props for the DateTimeCell component
|
|
33
|
+
* @returns {JSX.Element} DateTimeCell component
|
|
34
|
+
*/
|
|
35
|
+
const DateTimeCell = ({ format, timeZone, locale, date, withTimeSince = true, className, dataTestId, }) => {
|
|
36
|
+
if (!date) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const formattedDate = dateAndTimeUtils.formatDateUtil(date, format, timeZone, locale);
|
|
40
|
+
return (jsxRuntime.jsxs("div", { className: cvaDateTimeCell({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("p", { className: cvaDateTime(), children: formattedDate }), withTimeSince ? jsxRuntime.jsx(TimeSince, { date: date, timeZone: timeZone, locale: locale }) : null] }));
|
|
41
|
+
};
|
|
42
|
+
const TimeSince = ({ date, timeZone, locale }) => {
|
|
43
|
+
try {
|
|
44
|
+
const timeSince = dateAndTimeUtils.timeSinceAuto(date, new Date(Date.now()), timeZone, locale);
|
|
45
|
+
return jsxRuntime.jsx("p", { className: cvaDateTimeSince(), children: timeSince });
|
|
46
|
+
}
|
|
47
|
+
catch (_a) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
24
52
|
/******************************************************************************
|
|
25
53
|
Copyright (c) Microsoft Corporation.
|
|
26
54
|
|
|
@@ -48,6 +76,28 @@ function __rest(s, e) {
|
|
|
48
76
|
return t;
|
|
49
77
|
}
|
|
50
78
|
|
|
79
|
+
/**
|
|
80
|
+
* The `<ImageCell>` component is used for displaying images in a table cell.
|
|
81
|
+
*
|
|
82
|
+
* @param {object} props - The props for the Image component.
|
|
83
|
+
* @returns {JSX.Element} The Image component.
|
|
84
|
+
*/
|
|
85
|
+
const ImageCell = (_a) => {
|
|
86
|
+
var { imageUrl, alt = "", width = 100, height = 100, dataTestId } = _a, rest = __rest(_a, ["imageUrl", "alt", "width", "height", "dataTestId"]);
|
|
87
|
+
return jsxRuntime.jsx("img", Object.assign({ width: width, height: height, src: imageUrl, alt: alt, "data-testid": dataTestId }, rest));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The IndicatorCell is used for render an indicator in a table cell
|
|
92
|
+
*
|
|
93
|
+
* @param {IndicatorCellProps} props - The props for the LinkCell component
|
|
94
|
+
* @returns {JSX.Element} LinkCell component
|
|
95
|
+
*/
|
|
96
|
+
const IndicatorCell = (_a) => {
|
|
97
|
+
var rest = __rest(_a, []);
|
|
98
|
+
return jsxRuntime.jsx(reactComponents.Indicator, Object.assign({}, rest));
|
|
99
|
+
};
|
|
100
|
+
|
|
51
101
|
/**
|
|
52
102
|
* The LinkCell is used for render a list of tags in a table cell
|
|
53
103
|
*
|
|
@@ -63,6 +113,25 @@ const LinkCell = (_a) => {
|
|
|
63
113
|
return (jsxRuntime.jsx(reactComponents.ExternalLink, Object.assign({ href: `${linkPrefix}${link}` }, rest, { onClick: handleClick, children: link })));
|
|
64
114
|
};
|
|
65
115
|
|
|
116
|
+
const cvaNumberCell = cssClassVarianceUtilities.cvaMerge([
|
|
117
|
+
"flex",
|
|
118
|
+
"gap-1",
|
|
119
|
+
"slashed-zero",
|
|
120
|
+
"text-neutral-700",
|
|
121
|
+
"text-sm",
|
|
122
|
+
"text-ellipsis",
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The `<NumberCell>` component is used for displaying numbers with units in a table cell.
|
|
127
|
+
*
|
|
128
|
+
* @param props - The props for the NumberCell component.
|
|
129
|
+
* @returns {JSX.Element} A React JSX element representing the NumberCell component.
|
|
130
|
+
*/
|
|
131
|
+
const NumberCell = ({ value = "", unit, className, dataTestId }) => {
|
|
132
|
+
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: cvaNumberCell({ className }), children: [jsxRuntime.jsx("span", { children: value }), unit ? jsxRuntime.jsx("span", { children: unit }) : null] }));
|
|
133
|
+
};
|
|
134
|
+
|
|
66
135
|
/**
|
|
67
136
|
* Component for a resizable handle element.
|
|
68
137
|
*
|
|
@@ -316,7 +385,11 @@ const cvaTr = cssClassVarianceUtilities.cvaMerge(["border-b", "border-neutral-30
|
|
|
316
385
|
});
|
|
317
386
|
|
|
318
387
|
exports.CheckboxCell = CheckboxCell;
|
|
388
|
+
exports.DateTimeCell = DateTimeCell;
|
|
389
|
+
exports.ImageCell = ImageCell;
|
|
390
|
+
exports.IndicatorCell = IndicatorCell;
|
|
319
391
|
exports.LinkCell = LinkCell;
|
|
392
|
+
exports.NumberCell = NumberCell;
|
|
320
393
|
exports.ResizeHandle = ResizeHandle;
|
|
321
394
|
exports.SortIndicator = SortIndicator;
|
|
322
395
|
exports.TableRoot = TableRoot;
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Checkbox } from '@trackunit/react-form-components';
|
|
3
3
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
4
|
-
import {
|
|
4
|
+
import { formatDateUtil, timeSinceAuto } from '@trackunit/date-and-time-utils';
|
|
5
|
+
import { Indicator, ExternalLink, Tag, Tooltip } from '@trackunit/react-components';
|
|
5
6
|
import { useState } from 'react';
|
|
6
7
|
|
|
7
8
|
const cvaCheckboxCell = cvaMerge([""]);
|
|
@@ -17,6 +18,33 @@ const CheckboxCell = ({ checked, className, dataTestId }) => {
|
|
|
17
18
|
return (jsx("div", { className: cvaCheckboxCell({ className }), "data-testid": dataTestId, children: jsx(Checkbox, { readOnly: true, checked: checked }) }));
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
const cvaDateTimeCell = cvaMerge([""]);
|
|
22
|
+
const cvaDateTime = cvaMerge(["slashed-zero", "text-neutral-700", "text-sm", "text-ellipsis"]);
|
|
23
|
+
const cvaDateTimeSince = cvaMerge(["slashed-zero", "text-neutral-500", "text-sm", "text-ellipsis"]);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* DateTimeCell is used for render a date and or time in a table cell.
|
|
27
|
+
*
|
|
28
|
+
* @param {DateTimeCellProps} props - The props for the DateTimeCell component
|
|
29
|
+
* @returns {JSX.Element} DateTimeCell component
|
|
30
|
+
*/
|
|
31
|
+
const DateTimeCell = ({ format, timeZone, locale, date, withTimeSince = true, className, dataTestId, }) => {
|
|
32
|
+
if (!date) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const formattedDate = formatDateUtil(date, format, timeZone, locale);
|
|
36
|
+
return (jsxs("div", { className: cvaDateTimeCell({ className }), "data-testid": dataTestId, children: [jsx("p", { className: cvaDateTime(), children: formattedDate }), withTimeSince ? jsx(TimeSince, { date: date, timeZone: timeZone, locale: locale }) : null] }));
|
|
37
|
+
};
|
|
38
|
+
const TimeSince = ({ date, timeZone, locale }) => {
|
|
39
|
+
try {
|
|
40
|
+
const timeSince = timeSinceAuto(date, new Date(Date.now()), timeZone, locale);
|
|
41
|
+
return jsx("p", { className: cvaDateTimeSince(), children: timeSince });
|
|
42
|
+
}
|
|
43
|
+
catch (_a) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
20
48
|
/******************************************************************************
|
|
21
49
|
Copyright (c) Microsoft Corporation.
|
|
22
50
|
|
|
@@ -44,6 +72,28 @@ function __rest(s, e) {
|
|
|
44
72
|
return t;
|
|
45
73
|
}
|
|
46
74
|
|
|
75
|
+
/**
|
|
76
|
+
* The `<ImageCell>` component is used for displaying images in a table cell.
|
|
77
|
+
*
|
|
78
|
+
* @param {object} props - The props for the Image component.
|
|
79
|
+
* @returns {JSX.Element} The Image component.
|
|
80
|
+
*/
|
|
81
|
+
const ImageCell = (_a) => {
|
|
82
|
+
var { imageUrl, alt = "", width = 100, height = 100, dataTestId } = _a, rest = __rest(_a, ["imageUrl", "alt", "width", "height", "dataTestId"]);
|
|
83
|
+
return jsx("img", Object.assign({ width: width, height: height, src: imageUrl, alt: alt, "data-testid": dataTestId }, rest));
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The IndicatorCell is used for render an indicator in a table cell
|
|
88
|
+
*
|
|
89
|
+
* @param {IndicatorCellProps} props - The props for the LinkCell component
|
|
90
|
+
* @returns {JSX.Element} LinkCell component
|
|
91
|
+
*/
|
|
92
|
+
const IndicatorCell = (_a) => {
|
|
93
|
+
var rest = __rest(_a, []);
|
|
94
|
+
return jsx(Indicator, Object.assign({}, rest));
|
|
95
|
+
};
|
|
96
|
+
|
|
47
97
|
/**
|
|
48
98
|
* The LinkCell is used for render a list of tags in a table cell
|
|
49
99
|
*
|
|
@@ -59,6 +109,25 @@ const LinkCell = (_a) => {
|
|
|
59
109
|
return (jsx(ExternalLink, Object.assign({ href: `${linkPrefix}${link}` }, rest, { onClick: handleClick, children: link })));
|
|
60
110
|
};
|
|
61
111
|
|
|
112
|
+
const cvaNumberCell = cvaMerge([
|
|
113
|
+
"flex",
|
|
114
|
+
"gap-1",
|
|
115
|
+
"slashed-zero",
|
|
116
|
+
"text-neutral-700",
|
|
117
|
+
"text-sm",
|
|
118
|
+
"text-ellipsis",
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The `<NumberCell>` component is used for displaying numbers with units in a table cell.
|
|
123
|
+
*
|
|
124
|
+
* @param props - The props for the NumberCell component.
|
|
125
|
+
* @returns {JSX.Element} A React JSX element representing the NumberCell component.
|
|
126
|
+
*/
|
|
127
|
+
const NumberCell = ({ value = "", unit, className, dataTestId }) => {
|
|
128
|
+
return (jsxs("div", { "data-testid": dataTestId, className: cvaNumberCell({ className }), children: [jsx("span", { children: value }), unit ? jsx("span", { children: unit }) : null] }));
|
|
129
|
+
};
|
|
130
|
+
|
|
62
131
|
/**
|
|
63
132
|
* Component for a resizable handle element.
|
|
64
133
|
*
|
|
@@ -311,4 +380,4 @@ const cvaTr = cvaMerge(["border-b", "border-neutral-300", "w-full", "h-max"], {
|
|
|
311
380
|
},
|
|
312
381
|
});
|
|
313
382
|
|
|
314
|
-
export { CheckboxCell, LinkCell, ResizeHandle, SortIndicator, TableRoot, TagsCell, Tbody, Td, TextCell, Tfoot, Th, Thead, Tr };
|
|
383
|
+
export { CheckboxCell, DateTimeCell, ImageCell, IndicatorCell, LinkCell, NumberCell, ResizeHandle, SortIndicator, TableRoot, TagsCell, Tbody, Td, TextCell, Tfoot, Th, Thead, Tr };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table-base-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@trackunit/css-class-variance-utilities": "0.0.14",
|
|
11
11
|
"@trackunit/date-and-time-utils": "0.0.1",
|
|
12
|
-
"@trackunit/
|
|
13
|
-
"@trackunit/react-
|
|
12
|
+
"@trackunit/iris-app-api": "0.0.118",
|
|
13
|
+
"@trackunit/react-components": "0.1.167",
|
|
14
|
+
"@trackunit/react-form-components": "0.0.158",
|
|
14
15
|
"@trackunit/ui-design-tokens": "0.0.77",
|
|
15
16
|
"react": "18.2.0"
|
|
16
17
|
},
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
2
|
export interface ImageCellProps extends CommonProps {
|
|
3
|
+
/**
|
|
4
|
+
* The URL of the image to be displayed.
|
|
5
|
+
*/
|
|
3
6
|
imageUrl: string;
|
|
7
|
+
/**
|
|
8
|
+
* An optional text description for the image.
|
|
9
|
+
*/
|
|
4
10
|
alt?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The width of the image in pixels.
|
|
13
|
+
*/
|
|
5
14
|
width?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The height of the image in pixels.
|
|
17
|
+
*/
|
|
6
18
|
height?: number;
|
|
19
|
+
/**
|
|
20
|
+
* A custom data-testid attribute for testing purposes.
|
|
21
|
+
*/
|
|
7
22
|
dataTestId?: string;
|
|
8
23
|
}
|
|
9
24
|
/**
|
|
10
25
|
* The `<ImageCell>` component is used for displaying images in a table cell.
|
|
11
26
|
*
|
|
12
27
|
* @param {object} props - The props for the Image component.
|
|
13
|
-
* @param {string} props.imageUrl - The URL of the image to be displayed.
|
|
14
|
-
* @param {string} [props.alt=""] - The alternative text for the image.
|
|
15
|
-
* @param {number} [props.width=100] - The width of the image in pixels.
|
|
16
|
-
* @param {number} [props.height=100] - The height of the image in pixels.
|
|
17
|
-
* @param {string} [props.dataTestId] - An optional data-testid for testing purposes.
|
|
18
|
-
* @param {...any} [rest] - Additional props that can be applied to the underlying <img> element.
|
|
19
28
|
* @returns {JSX.Element} The Image component.
|
|
20
29
|
*/
|
|
21
30
|
export declare const ImageCell: ({ imageUrl, alt, width, height, dataTestId, ...rest }: ImageCellProps) => JSX.Element;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
+
import { UnitSi, UnitUs } from "@trackunit/iris-app-api";
|
|
1
2
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
3
|
export interface NumberCellProps extends CommonProps {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The numeric value to be displayed.
|
|
6
|
+
* This can be either a string or a number.
|
|
7
|
+
*/
|
|
8
|
+
value?: string | number | null;
|
|
9
|
+
/**
|
|
10
|
+
* An optional unit to display alongside the numeric value.
|
|
11
|
+
*/
|
|
12
|
+
unit?: UnitSi | UnitUs | null;
|
|
13
|
+
/**
|
|
14
|
+
* An optional CSS class name to apply to the NumberCell component.
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A custom data-testid attribute for testing purposes.
|
|
19
|
+
*/
|
|
20
|
+
dataTestId?: string;
|
|
5
21
|
}
|
|
6
22
|
/**
|
|
7
23
|
* The `<NumberCell>` component is used for displaying numbers with units in a table cell.
|
|
8
24
|
*
|
|
9
25
|
* @param props - The props for the NumberCell component.
|
|
10
|
-
* @param {string} [props.value] - The numeric value to be displayed.
|
|
11
|
-
* @param {string} [props.unit] - The optional unit to be displayed alongside the value.
|
|
12
|
-
* @param {string} [props.className] - Additional CSS classes to apply to the component.
|
|
13
|
-
* @param {string} [props.dataTestId] - The data-testid attribute for testing purposes.
|
|
14
26
|
* @returns {JSX.Element} A React JSX element representing the NumberCell component.
|
|
15
27
|
*/
|
|
16
28
|
export declare const NumberCell: ({ value, unit, className, dataTestId }: NumberCellProps) => JSX.Element;
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from "./components/CheckboxCell/CheckboxCell";
|
|
2
|
+
export * from "./components/DateTimeCell/DateTimeCell";
|
|
3
|
+
export * from "./components/ImageCell/ImageCell";
|
|
4
|
+
export * from "./components/IndicatorCell/IndicatorCell";
|
|
2
5
|
export * from "./components/LinkCell/LinkCell";
|
|
6
|
+
export * from "./components/NumberCell/NumberCell";
|
|
3
7
|
export * from "./components/ResizeHandle";
|
|
4
8
|
export * from "./components/SortIndicator";
|
|
5
9
|
export * from "./components/TableRoot";
|