@trackunit/react-table-base-components 0.0.19 → 0.0.21
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 +20 -0
- package/index.esm.js +21 -2
- package/package.json +4 -3
- package/src/components/ImageCell/ImageCell.d.ts +21 -0
- package/src/components/ImageCell/ImageCell.stories.d.ts +5 -0
- package/src/components/IndicatorCell/IndicatorCell.d.ts +36 -0
- package/src/components/IndicatorCell/IndicatorCell.stories.d.ts +6 -0
- package/src/components/NumberCell/NumberCell.d.ts +16 -0
- package/src/components/NumberCell/NumberCell.stories.d.ts +7 -0
- package/src/components/NumberCell/NumberCell.variants.d.ts +1 -0
- package/src/components/TextCell/TextCell.variants.d.ts +1 -0
- package/src/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -6,6 +6,7 @@ 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
8
|
var reactComponents = require('@trackunit/react-components');
|
|
9
|
+
var react = require('react');
|
|
9
10
|
|
|
10
11
|
const cvaCheckboxCell = cssClassVarianceUtilities.cvaMerge([""]);
|
|
11
12
|
|
|
@@ -205,6 +206,24 @@ const Td = (_a) => {
|
|
|
205
206
|
};
|
|
206
207
|
const cvaTd = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "align-middle", "py-table-spacing", "px-2", "whitespace-nowrap"]);
|
|
207
208
|
|
|
209
|
+
const cvaTextCell = cssClassVarianceUtilities.cvaMerge(["truncate"]);
|
|
210
|
+
const cvaTextCellTooltip = cssClassVarianceUtilities.cvaMerge(["grid"]);
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The `<TextCell>` component is used for displaying text in a table cell.
|
|
214
|
+
* The text is not editable and will be truncated if the cell is too narrow.
|
|
215
|
+
*
|
|
216
|
+
* @param {TextCellProps} props - The props for the TextCell component
|
|
217
|
+
* @returns {JSX.Element} TextCell component
|
|
218
|
+
*/
|
|
219
|
+
const TextCell = ({ content = "", className, dataTestId }) => {
|
|
220
|
+
const [isTooltipVisible, setIsTooltipVisible] = react.useState(false);
|
|
221
|
+
const updateTooltipVisibility = (element) => {
|
|
222
|
+
setIsTooltipVisible(element ? element.scrollWidth > element.clientWidth : false);
|
|
223
|
+
};
|
|
224
|
+
return (jsxRuntime.jsx(reactComponents.Tooltip, { disabled: !isTooltipVisible, label: content, className: cvaTextCellTooltip(), children: jsxRuntime.jsx("span", { ref: elementRef => updateTooltipVisibility(elementRef), className: cvaTextCell({ className }), "data-testid": dataTestId, children: content }) }));
|
|
225
|
+
};
|
|
226
|
+
|
|
208
227
|
/**
|
|
209
228
|
* The Tfoot is a wrapper for the tfoot html element.
|
|
210
229
|
* It is used to render a table, and adds some default styling.
|
|
@@ -304,6 +323,7 @@ exports.TableRoot = TableRoot;
|
|
|
304
323
|
exports.TagsCell = TagsCell;
|
|
305
324
|
exports.Tbody = Tbody;
|
|
306
325
|
exports.Td = Td;
|
|
326
|
+
exports.TextCell = TextCell;
|
|
307
327
|
exports.Tfoot = Tfoot;
|
|
308
328
|
exports.Th = Th;
|
|
309
329
|
exports.Thead = Thead;
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx } 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 { ExternalLink, Tag } from '@trackunit/react-components';
|
|
4
|
+
import { ExternalLink, Tag, Tooltip } from '@trackunit/react-components';
|
|
5
|
+
import { useState } from 'react';
|
|
5
6
|
|
|
6
7
|
const cvaCheckboxCell = cvaMerge([""]);
|
|
7
8
|
|
|
@@ -201,6 +202,24 @@ const Td = (_a) => {
|
|
|
201
202
|
};
|
|
202
203
|
const cvaTd = cvaMerge(["overflow-hidden", "align-middle", "py-table-spacing", "px-2", "whitespace-nowrap"]);
|
|
203
204
|
|
|
205
|
+
const cvaTextCell = cvaMerge(["truncate"]);
|
|
206
|
+
const cvaTextCellTooltip = cvaMerge(["grid"]);
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The `<TextCell>` component is used for displaying text in a table cell.
|
|
210
|
+
* The text is not editable and will be truncated if the cell is too narrow.
|
|
211
|
+
*
|
|
212
|
+
* @param {TextCellProps} props - The props for the TextCell component
|
|
213
|
+
* @returns {JSX.Element} TextCell component
|
|
214
|
+
*/
|
|
215
|
+
const TextCell = ({ content = "", className, dataTestId }) => {
|
|
216
|
+
const [isTooltipVisible, setIsTooltipVisible] = useState(false);
|
|
217
|
+
const updateTooltipVisibility = (element) => {
|
|
218
|
+
setIsTooltipVisible(element ? element.scrollWidth > element.clientWidth : false);
|
|
219
|
+
};
|
|
220
|
+
return (jsx(Tooltip, { disabled: !isTooltipVisible, label: content, className: cvaTextCellTooltip(), children: jsx("span", { ref: elementRef => updateTooltipVisibility(elementRef), className: cvaTextCell({ className }), "data-testid": dataTestId, children: content }) }));
|
|
221
|
+
};
|
|
222
|
+
|
|
204
223
|
/**
|
|
205
224
|
* The Tfoot is a wrapper for the tfoot html element.
|
|
206
225
|
* It is used to render a table, and adds some default styling.
|
|
@@ -292,4 +311,4 @@ const cvaTr = cvaMerge(["border-b", "border-neutral-300", "w-full", "h-max"], {
|
|
|
292
311
|
},
|
|
293
312
|
});
|
|
294
313
|
|
|
295
|
-
export { CheckboxCell, LinkCell, ResizeHandle, SortIndicator, TableRoot, TagsCell, Tbody, Td, Tfoot, Th, Thead, Tr };
|
|
314
|
+
export { CheckboxCell, LinkCell, 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.21",
|
|
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/react-components": "0.1.
|
|
13
|
-
"@trackunit/react-form-components": "0.0.
|
|
12
|
+
"@trackunit/react-components": "0.1.162",
|
|
13
|
+
"@trackunit/react-form-components": "0.0.148",
|
|
14
|
+
"@trackunit/ui-design-tokens": "0.0.77",
|
|
14
15
|
"react": "18.2.0"
|
|
15
16
|
},
|
|
16
17
|
"module": "./index.esm.js",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
export interface ImageCellProps extends CommonProps {
|
|
3
|
+
imageUrl: string;
|
|
4
|
+
alt?: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
dataTestId?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The `<ImageCell>` component is used for displaying images in a table cell.
|
|
11
|
+
*
|
|
12
|
+
* @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
|
+
* @returns {JSX.Element} The Image component.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ImageCell: ({ imageUrl, alt, width, height, dataTestId, ...rest }: ImageCellProps) => JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IndicatorProps } from "@trackunit/react-components";
|
|
3
|
+
import { ThemeColors } from "@trackunit/ui-design-tokens";
|
|
4
|
+
export interface IndicatorCellProps extends IndicatorProps, React.HTMLAttributes<HTMLTableSectionElement> {
|
|
5
|
+
/**
|
|
6
|
+
* The icon to be rendered inside the indicator component
|
|
7
|
+
*/
|
|
8
|
+
icon: JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* A color token used to style the icon and the icon background
|
|
11
|
+
*/
|
|
12
|
+
color?: ThemeColors;
|
|
13
|
+
/**
|
|
14
|
+
* A text label to be displayed next to the indicator
|
|
15
|
+
*/
|
|
16
|
+
label?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A boolean parameter to display or hide icon background, default value is true
|
|
19
|
+
*/
|
|
20
|
+
withBackground?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* A boolean parameter to display or hide label and instead show as html title on hover, default value is true
|
|
23
|
+
*/
|
|
24
|
+
withLabel?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* A boolean parameter to make the indicator ping thus drawing more attention, default value is false
|
|
27
|
+
*/
|
|
28
|
+
ping?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The IndicatorCell is used for render an indicator in a table cell
|
|
32
|
+
*
|
|
33
|
+
* @param {IndicatorCellProps} props - The props for the LinkCell component
|
|
34
|
+
* @returns {JSX.Element} LinkCell component
|
|
35
|
+
*/
|
|
36
|
+
export declare const IndicatorCell: ({ ...rest }: IndicatorCellProps) => JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
export interface NumberCellProps extends CommonProps {
|
|
3
|
+
value: string | number;
|
|
4
|
+
unit?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The `<NumberCell>` component is used for displaying numbers with units in a table cell.
|
|
8
|
+
*
|
|
9
|
+
* @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
|
+
* @returns {JSX.Element} A React JSX element representing the NumberCell component.
|
|
15
|
+
*/
|
|
16
|
+
export declare const NumberCell: ({ value, unit, className, dataTestId }: NumberCellProps) => JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { NumberCell } from "./NumberCell";
|
|
3
|
+
import "./NumberCell.variants";
|
|
4
|
+
type Story = StoryObj<typeof NumberCell>;
|
|
5
|
+
declare const meta: Meta<typeof NumberCell>;
|
|
6
|
+
export default meta;
|
|
7
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cvaNumberCell: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
package/src/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./components/TableRoot";
|
|
|
6
6
|
export * from "./components/TagsCell/TagsCell";
|
|
7
7
|
export * from "./components/Tbody";
|
|
8
8
|
export * from "./components/Td";
|
|
9
|
+
export * from "./components/TextCell/TextCell";
|
|
9
10
|
export * from "./components/Tfoot";
|
|
10
11
|
export * from "./components/Th";
|
|
11
12
|
export * from "./components/Thead";
|