@trackunit/react-table-base-components 0.0.1-alpha-b0920fa0dd.0 → 0.0.1
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 +45 -0
- package/index.esm.js +43 -1
- package/package.json +4 -3
- package/src/components/CheckboxCell/CheckboxCell.d.ts +13 -0
- package/src/components/CheckboxCell/CheckboxCell.stories.d.ts +8 -0
- package/src/components/CheckboxCell/CheckboxCell.variants.d.ts +1 -0
- package/src/components/LinkCell/LinkCell.d.ts +27 -0
- package/src/components/LinkCell/LinkCell.stories.d.ts +7 -0
- package/src/components/TagsCell/TagsCell.d.ts +23 -0
- package/src/components/TagsCell/TagsCell.stories.d.ts +6 -0
- package/src/components/TagsCell/TagsCell.variants.d.ts +1 -0
- package/src/index.d.ts +3 -0
package/index.cjs.js
CHANGED
|
@@ -3,7 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var reactFormComponents = require('@trackunit/react-form-components');
|
|
6
7
|
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
8
|
+
var reactComponents = require('@trackunit/react-components');
|
|
9
|
+
|
|
10
|
+
const cvaCheckboxCell = cssClassVarianceUtilities.cvaMerge([""]);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* CheckboxCell is used for render a checkbox in a table cell-
|
|
14
|
+
* The checkbox is not editable.
|
|
15
|
+
*
|
|
16
|
+
* @param {CheckboxCellProps} props - The props for the CheckboxCell component
|
|
17
|
+
* @returns {JSX.Element} CheckboxCell component
|
|
18
|
+
*/
|
|
19
|
+
const CheckboxCell = ({ checked, className, dataTestId }) => {
|
|
20
|
+
return (jsxRuntime.jsx("div", { className: cvaCheckboxCell({ className }), "data-testid": dataTestId, children: jsxRuntime.jsx(reactFormComponents.Checkbox, { readOnly: true, checked: checked }) }));
|
|
21
|
+
};
|
|
7
22
|
|
|
8
23
|
/******************************************************************************
|
|
9
24
|
Copyright (c) Microsoft Corporation.
|
|
@@ -32,6 +47,21 @@ function __rest(s, e) {
|
|
|
32
47
|
return t;
|
|
33
48
|
}
|
|
34
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The LinkCell is used for render a list of tags in a table cell
|
|
52
|
+
*
|
|
53
|
+
* @param {LinkCellProps} props - The props for the LinkCell component
|
|
54
|
+
* @returns {JSX.Element} LinkCell component
|
|
55
|
+
*/
|
|
56
|
+
const LinkCell = (_a) => {
|
|
57
|
+
var { link, type } = _a, rest = __rest(_a, ["link", "type"]);
|
|
58
|
+
const linkPrefix = type === "LINK" ? "" : type === "PHONE" ? "tel:" : "mailto:";
|
|
59
|
+
const handleClick = (event) => {
|
|
60
|
+
event.stopPropagation();
|
|
61
|
+
};
|
|
62
|
+
return (jsxRuntime.jsx(reactComponents.ExternalLink, Object.assign({ href: `${linkPrefix}${link}` }, rest, { onClick: handleClick, children: link })));
|
|
63
|
+
};
|
|
64
|
+
|
|
35
65
|
/**
|
|
36
66
|
* Component for a resizable handle element.
|
|
37
67
|
*
|
|
@@ -125,6 +155,18 @@ const TableRoot = (_a) => {
|
|
|
125
155
|
};
|
|
126
156
|
const cvaTableRoot = cssClassVarianceUtilities.cvaMerge(["border-spacing-0", "min-w-full"]);
|
|
127
157
|
|
|
158
|
+
const cvaTagsCell = cssClassVarianceUtilities.cvaMerge(["flex", "gap-2"]);
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The TagsCell is used for render a list of tags in a table cell
|
|
162
|
+
*
|
|
163
|
+
* @param {TagsCellProps} props - The props for the TagsCell component
|
|
164
|
+
* @returns {JSX.Element} TagsCell component
|
|
165
|
+
*/
|
|
166
|
+
const TagsCell = ({ className, tags, dataTestId }) => {
|
|
167
|
+
return (jsxRuntime.jsx("div", { className: cvaTagsCell({ className }), "data-testid": dataTestId, children: tags.map((tag, index) => (jsxRuntime.jsx(reactComponents.Tag, { color: "primary", dataTestId: `${dataTestId}-${index}`, children: tag }, index))) }));
|
|
168
|
+
};
|
|
169
|
+
|
|
128
170
|
/**
|
|
129
171
|
* The Tbody is a wrapper for the tbody html element.
|
|
130
172
|
* It is used to render a table, and adds some default styling.
|
|
@@ -247,9 +289,12 @@ const cvaTr = cssClassVarianceUtilities.cvaMerge(["border-b", "border-neutral-30
|
|
|
247
289
|
},
|
|
248
290
|
});
|
|
249
291
|
|
|
292
|
+
exports.CheckboxCell = CheckboxCell;
|
|
293
|
+
exports.LinkCell = LinkCell;
|
|
250
294
|
exports.ResizeHandel = ResizeHandel;
|
|
251
295
|
exports.SortIndicator = SortIndicator;
|
|
252
296
|
exports.TableRoot = TableRoot;
|
|
297
|
+
exports.TagsCell = TagsCell;
|
|
253
298
|
exports.Tbody = Tbody;
|
|
254
299
|
exports.Td = Td;
|
|
255
300
|
exports.Tfoot = Tfoot;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Checkbox } from '@trackunit/react-form-components';
|
|
2
3
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
4
|
+
import { ExternalLink, Tag } from '@trackunit/react-components';
|
|
5
|
+
|
|
6
|
+
const cvaCheckboxCell = cvaMerge([""]);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* CheckboxCell is used for render a checkbox in a table cell-
|
|
10
|
+
* The checkbox is not editable.
|
|
11
|
+
*
|
|
12
|
+
* @param {CheckboxCellProps} props - The props for the CheckboxCell component
|
|
13
|
+
* @returns {JSX.Element} CheckboxCell component
|
|
14
|
+
*/
|
|
15
|
+
const CheckboxCell = ({ checked, className, dataTestId }) => {
|
|
16
|
+
return (jsx("div", { className: cvaCheckboxCell({ className }), "data-testid": dataTestId, children: jsx(Checkbox, { readOnly: true, checked: checked }) }));
|
|
17
|
+
};
|
|
3
18
|
|
|
4
19
|
/******************************************************************************
|
|
5
20
|
Copyright (c) Microsoft Corporation.
|
|
@@ -28,6 +43,21 @@ function __rest(s, e) {
|
|
|
28
43
|
return t;
|
|
29
44
|
}
|
|
30
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The LinkCell is used for render a list of tags in a table cell
|
|
48
|
+
*
|
|
49
|
+
* @param {LinkCellProps} props - The props for the LinkCell component
|
|
50
|
+
* @returns {JSX.Element} LinkCell component
|
|
51
|
+
*/
|
|
52
|
+
const LinkCell = (_a) => {
|
|
53
|
+
var { link, type } = _a, rest = __rest(_a, ["link", "type"]);
|
|
54
|
+
const linkPrefix = type === "LINK" ? "" : type === "PHONE" ? "tel:" : "mailto:";
|
|
55
|
+
const handleClick = (event) => {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
};
|
|
58
|
+
return (jsx(ExternalLink, Object.assign({ href: `${linkPrefix}${link}` }, rest, { onClick: handleClick, children: link })));
|
|
59
|
+
};
|
|
60
|
+
|
|
31
61
|
/**
|
|
32
62
|
* Component for a resizable handle element.
|
|
33
63
|
*
|
|
@@ -121,6 +151,18 @@ const TableRoot = (_a) => {
|
|
|
121
151
|
};
|
|
122
152
|
const cvaTableRoot = cvaMerge(["border-spacing-0", "min-w-full"]);
|
|
123
153
|
|
|
154
|
+
const cvaTagsCell = cvaMerge(["flex", "gap-2"]);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The TagsCell is used for render a list of tags in a table cell
|
|
158
|
+
*
|
|
159
|
+
* @param {TagsCellProps} props - The props for the TagsCell component
|
|
160
|
+
* @returns {JSX.Element} TagsCell component
|
|
161
|
+
*/
|
|
162
|
+
const TagsCell = ({ className, tags, dataTestId }) => {
|
|
163
|
+
return (jsx("div", { className: cvaTagsCell({ className }), "data-testid": dataTestId, children: tags.map((tag, index) => (jsx(Tag, { color: "primary", dataTestId: `${dataTestId}-${index}`, children: tag }, index))) }));
|
|
164
|
+
};
|
|
165
|
+
|
|
124
166
|
/**
|
|
125
167
|
* The Tbody is a wrapper for the tbody html element.
|
|
126
168
|
* It is used to render a table, and adds some default styling.
|
|
@@ -243,4 +285,4 @@ const cvaTr = cvaMerge(["border-b", "border-neutral-300", "w-full", "h-max"], {
|
|
|
243
285
|
},
|
|
244
286
|
});
|
|
245
287
|
|
|
246
|
-
export { ResizeHandel, SortIndicator, TableRoot, Tbody, Td, Tfoot, Th, Thead, Tr };
|
|
288
|
+
export { CheckboxCell, LinkCell, ResizeHandel, SortIndicator, TableRoot, TagsCell, Tbody, Td, Tfoot, Th, Thead, Tr };
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table-base-components",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/css-class-variance-utilities": "0.0.
|
|
11
|
-
"@trackunit/react-components": "0.1.
|
|
10
|
+
"@trackunit/css-class-variance-utilities": "0.0.12",
|
|
11
|
+
"@trackunit/react-components": "0.1.152",
|
|
12
|
+
"@trackunit/react-form-components": "0.0.130",
|
|
12
13
|
"react": "18.2.0"
|
|
13
14
|
},
|
|
14
15
|
"module": "./index.esm.js",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
3
|
+
export interface CheckboxCellProps extends CommonProps {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* CheckboxCell is used for render a checkbox in a table cell-
|
|
8
|
+
* The checkbox is not editable.
|
|
9
|
+
*
|
|
10
|
+
* @param {CheckboxCellProps} props - The props for the CheckboxCell component
|
|
11
|
+
* @returns {JSX.Element} CheckboxCell component
|
|
12
|
+
*/
|
|
13
|
+
export declare const CheckboxCell: ({ checked, className, dataTestId }: CheckboxCellProps) => JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { CheckboxCell } from "./CheckboxCell";
|
|
3
|
+
import "./CheckboxCell.variants";
|
|
4
|
+
type Story = StoryObj<typeof CheckboxCell>;
|
|
5
|
+
declare const meta: Meta<typeof CheckboxCell>;
|
|
6
|
+
export default meta;
|
|
7
|
+
export declare const Default: Story;
|
|
8
|
+
export declare const Variants: () => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cvaCheckboxCell: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
3
|
+
export interface LinkCellProps extends CommonProps, React.HTMLAttributes<HTMLTableSectionElement> {
|
|
4
|
+
/**
|
|
5
|
+
* A id that can be used in tests to get the component
|
|
6
|
+
*/
|
|
7
|
+
dataTestId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Custom classNames that will be merged with the default classNames.
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Type of link to render
|
|
14
|
+
*/
|
|
15
|
+
type: "LINK" | "PHONE" | "EMAIL";
|
|
16
|
+
/**
|
|
17
|
+
* The link to render
|
|
18
|
+
*/
|
|
19
|
+
link: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The LinkCell is used for render a list of tags in a table cell
|
|
23
|
+
*
|
|
24
|
+
* @param {LinkCellProps} props - The props for the LinkCell component
|
|
25
|
+
* @returns {JSX.Element} LinkCell component
|
|
26
|
+
*/
|
|
27
|
+
export declare const LinkCell: ({ link, type, ...rest }: LinkCellProps) => JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { LinkCell } from "./LinkCell";
|
|
3
|
+
type Story = StoryObj<typeof LinkCell>;
|
|
4
|
+
declare const meta: Meta<typeof LinkCell>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Variants: () => JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
3
|
+
export interface TagsCellProps extends CommonProps, React.HTMLAttributes<HTMLTableSectionElement> {
|
|
4
|
+
/**
|
|
5
|
+
* A id that can be used in tests to get the component
|
|
6
|
+
*/
|
|
7
|
+
dataTestId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Custom classNames that will be merged with the default classNames.
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Array of tags that the component should show.
|
|
14
|
+
*/
|
|
15
|
+
tags: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The TagsCell is used for render a list of tags in a table cell
|
|
19
|
+
*
|
|
20
|
+
* @param {TagsCellProps} props - The props for the TagsCell component
|
|
21
|
+
* @returns {JSX.Element} TagsCell component
|
|
22
|
+
*/
|
|
23
|
+
export declare const TagsCell: ({ className, tags, dataTestId }: TagsCellProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cvaTagsCell: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
export * from "./components/CheckboxCell/CheckboxCell";
|
|
2
|
+
export * from "./components/LinkCell/LinkCell";
|
|
1
3
|
export * from "./components/ResizeHandel";
|
|
2
4
|
export * from "./components/SortIndicator";
|
|
3
5
|
export * from "./components/TableRoot";
|
|
6
|
+
export * from "./components/TagsCell/TagsCell";
|
|
4
7
|
export * from "./components/Tbody";
|
|
5
8
|
export * from "./components/Td";
|
|
6
9
|
export * from "./components/Tfoot";
|