@trackunit/react-table-base-components 0.0.1-alpha-d7497395ac.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/README.md ADDED
@@ -0,0 +1,22 @@
1
+ > **⚠️ Beta**
2
+ >
3
+ > This is a beta version and subject to change without notice.
4
+
5
+ # Trackunit React Table Base Components
6
+ The `@trackunit/react-table-base-components` package contains basic react components for Tables as part of Trackunits public UI library.
7
+
8
+ This library is exposed publicly for use in the the Trackunit [Iris App SDK](https://www.npmjs.com/package/@trackunit/iris-app).
9
+
10
+ To browse all available components visit our [Public Storybook](https://developers.trackunit.com/page/ui-components).
11
+
12
+ For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
13
+
14
+ ## Development
15
+ At this point this library is only developed by Trackunit Employees.
16
+ For development related information see the [development readme](https://github.com/Trackunit/manager/blob/master/libs/react/components/DEVELOPMENT.md).
17
+
18
+ ## Trackunit
19
+ This package was developed by Trackunit ApS.
20
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
21
+
22
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
package/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/index.cjs.js ADDED
@@ -0,0 +1,258 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
7
+
8
+ /******************************************************************************
9
+ Copyright (c) Microsoft Corporation.
10
+
11
+ Permission to use, copy, modify, and/or distribute this software for any
12
+ purpose with or without fee is hereby granted.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
+ PERFORMANCE OF THIS SOFTWARE.
21
+ ***************************************************************************** */
22
+
23
+ function __rest(s, e) {
24
+ var t = {};
25
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
26
+ t[p] = s[p];
27
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
28
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
29
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
30
+ t[p[i]] = s[p[i]];
31
+ }
32
+ return t;
33
+ }
34
+
35
+ /**
36
+ * Component for a resizable handle element.
37
+ *
38
+ * @param {object} props - Props for the resizable handle.
39
+ * @param {boolean} [props.isResizing=false] - Indicates whether the handle is in a resizing state.
40
+ * @param {string} [props.dataTestId] - A data-testid attribute for testing purposes.
41
+ * @param {string} [props.className] - Additional CSS classes to apply to the handle.
42
+ * @returns {ReactElement} A React element representing the resizable handle.
43
+ */
44
+ const ResizeHandel = (_a) => {
45
+ var { isResizing = false, dataTestId, className } = _a, rest = __rest(_a, ["isResizing", "dataTestId", "className"]);
46
+ return (jsxRuntime.jsx("div", Object.assign({ role: "separator", "data-testid": dataTestId, className: cvaResizeHandel({ isResizing, className }) }, rest)));
47
+ };
48
+ const cvaResizeHandel = cssClassVarianceUtilities.cvaMerge([
49
+ "absolute",
50
+ "!cursor-col-resize",
51
+ "right-0",
52
+ "top-0",
53
+ "h-full",
54
+ "w-1",
55
+ "select-none",
56
+ "hover:bg-primary-400",
57
+ "cursor-pointer",
58
+ ], {
59
+ variants: {
60
+ isResizing: {
61
+ true: ["bg-blue-500", "opacity-1"],
62
+ false: [],
63
+ },
64
+ },
65
+ });
66
+
67
+ /**
68
+ * Component for a sorting indicator element.
69
+ *
70
+ * @param {object} props - Props for the sorting indicator.
71
+ * @param {boolean} [props.sortingState=false] - Indicates the sorting state (ascending/descending).
72
+ * @param {string} [props.dataTestId] - A data-testid attribute for testing purposes.
73
+ * @param {string} [props.className] - Additional CSS classes to apply to the sorting indicator.
74
+ * @returns {ReactElement} A React element representing the sorting indicator.
75
+ */
76
+ const SortIndicator = (_a) => {
77
+ var { sortingState = false, dataTestId, className } = _a, rest = __rest(_a, ["sortingState", "dataTestId", "className"]);
78
+ return (jsxRuntime.jsx("span", Object.assign({ role: "separator", "data-testid": dataTestId, className: cvaSortIndicator({ sortingState, className }) }, rest)));
79
+ };
80
+ const cvaSortIndicator = cssClassVarianceUtilities.cvaMerge([
81
+ "relative",
82
+ "before:block",
83
+ "before:h-0",
84
+ "before:absolute",
85
+ "before:w-0",
86
+ "before:bottom-0.5",
87
+ "before:content-['_']",
88
+ "before:border-4",
89
+ "before:border-solid",
90
+ "before:border-transparent",
91
+ "after:block",
92
+ "after:h-0",
93
+ "after:absolute",
94
+ "after:w-0",
95
+ "after:-bottom-[9px]",
96
+ "after:content-['_']",
97
+ "after:border-4",
98
+ "after:border-solid",
99
+ "after:border-transparent",
100
+ "before:border-b-neutral-300",
101
+ "after:border-t-neutral-300",
102
+ ], {
103
+ variants: {
104
+ sortingState: {
105
+ asc: ["before:border-b-primary-600"],
106
+ desc: ["after:border-t-primary-600"],
107
+ false: "",
108
+ },
109
+ },
110
+ });
111
+
112
+ /**
113
+ * The TableRoot is a wrapper for the table html element.
114
+ * It is used to render a table, and adds some default styling.
115
+ *
116
+ * In most cases, we recommend using the Table Component over the Table Base Components.
117
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
118
+ *
119
+ * @param {TableRootProps} props - The props for the TableRoot component
120
+ * @returns {JSX.Element} TableRoot component
121
+ */
122
+ const TableRoot = (_a) => {
123
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
124
+ return (jsxRuntime.jsx("table", Object.assign({ "data-testid": dataTestId, className: cvaTableRoot({ className }) }, rest, { children: children })));
125
+ };
126
+ const cvaTableRoot = cssClassVarianceUtilities.cvaMerge(["border-spacing-0", "min-w-full"]);
127
+
128
+ /**
129
+ * The Tbody is a wrapper for the tbody html element.
130
+ * It is used to render a table, and adds some default styling.
131
+ *
132
+ * In most cases, we recommend using the Table Component over the Table Base Components.
133
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
134
+ *
135
+ * @param {TbodyProps} props - The props for the Tbody component
136
+ * @returns {JSX.Element} Tbody component
137
+ */
138
+ const Tbody = (_a) => {
139
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
140
+ return (jsxRuntime.jsx("tbody", Object.assign({ "data-testid": dataTestId, className: className }, rest, { children: children })));
141
+ };
142
+
143
+ /**
144
+ * The Td is a wrapper for the td html element.
145
+ * It is used to render a table, and adds some default styling.
146
+ *
147
+ * In most cases, we recommend using the Table Component over the Table Base Components.
148
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
149
+ *
150
+ * @param {TdProps} props - The props for the Td component
151
+ * @returns {JSX.Element} Td component
152
+ */
153
+ const Td = (_a) => {
154
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
155
+ return (jsxRuntime.jsx("td", Object.assign({ "data-testid": dataTestId, className: cvaTd({ className }) }, rest, { children: children })));
156
+ };
157
+ const cvaTd = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "align-middle", "py-table-spacing", "px-2", "whitespace-nowrap"]);
158
+
159
+ /**
160
+ * The Tfoot is a wrapper for the tfoot html element.
161
+ * It is used to render a table, and adds some default styling.
162
+ *
163
+ * In most cases, we recommend using the Table Component over the Table Base Components.
164
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
165
+ *
166
+ * @param {TfootProps} props - The props for the Tfoot component
167
+ * @returns {JSX.Element} Tfoot component
168
+ */
169
+ const Tfoot = (_a) => {
170
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
171
+ return (jsxRuntime.jsx("tfoot", Object.assign({ "data-testid": dataTestId, className: className }, rest, { children: children })));
172
+ };
173
+
174
+ /**
175
+ * The Th is a wrapper for the th html element.
176
+ * It is used to render a table, and adds some default styling.
177
+ *
178
+ * In most cases, we recommend using the Table Component over the Table Base Components.
179
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
180
+ *
181
+ * @param {ThProps} props - The props for the Th component
182
+ * @returns {JSX.Element} Th component
183
+ */
184
+ const Th = (_a) => {
185
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
186
+ return (jsxRuntime.jsx("th", Object.assign({ "data-testid": dataTestId, className: cvaTh({ className }) }, rest, { children: children })));
187
+ };
188
+ const cvaTh = cssClassVarianceUtilities.cvaMerge([
189
+ "hover:bg-neutral-200",
190
+ "text-sm",
191
+ "overflow-hidden",
192
+ "font-medium",
193
+ "whitespace-nowrap",
194
+ "px-3",
195
+ "py-table-spacing",
196
+ ]);
197
+
198
+ /**
199
+ * The Thead is a wrapper for the thead html element.
200
+ * It is used to render a table, and adds some default styling.
201
+ *
202
+ * In most cases, we recommend using the Table Component over the Table Base Components.
203
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
204
+ *
205
+ * @param {TheadProps} props - The props for the Thead component
206
+ * @returns {JSX.Element} Thead component
207
+ */
208
+ const Thead = (_a) => {
209
+ var { dataTestId, className, children, sticky = true } = _a, rest = __rest(_a, ["dataTestId", "className", "children", "sticky"]);
210
+ return (jsxRuntime.jsx("thead", Object.assign({ "data-testid": dataTestId, className: cvaThead({ sticky, className }) }, rest, { children: children })));
211
+ };
212
+ const cvaThead = cssClassVarianceUtilities.cvaMerge(["bg-neutral-100", "text-left"], {
213
+ variants: {
214
+ sticky: {
215
+ true: ["sticky", "top-0"],
216
+ false: [],
217
+ },
218
+ },
219
+ defaultVariants: {
220
+ sticky: true,
221
+ },
222
+ });
223
+
224
+ /**
225
+ * The Tr is a wrapper for the tr html element.
226
+ * It is used to render a table, and adds some default styling.
227
+ *
228
+ * In most cases, we recommend using the Table Component over the Table Base Components.
229
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
230
+ *
231
+ * @param {TrProps} props - The props for the Tr component
232
+ * @returns {JSX.Element} Tr component
233
+ */
234
+ const Tr = (_a) => {
235
+ var { dataTestId, className, children, layout = "default" } = _a, rest = __rest(_a, ["dataTestId", "className", "children", "layout"]);
236
+ return (jsxRuntime.jsx("tr", Object.assign({ role: "row", "data-testid": dataTestId, className: cvaTr({ layout, className }) }, rest, { children: children })));
237
+ };
238
+ const cvaTr = cssClassVarianceUtilities.cvaMerge(["border-b", "border-neutral-300", "w-full", "h-max"], {
239
+ variants: {
240
+ layout: {
241
+ default: "",
242
+ flex: ["flex"],
243
+ },
244
+ },
245
+ defaultVariants: {
246
+ layout: "default",
247
+ },
248
+ });
249
+
250
+ exports.ResizeHandel = ResizeHandel;
251
+ exports.SortIndicator = SortIndicator;
252
+ exports.TableRoot = TableRoot;
253
+ exports.Tbody = Tbody;
254
+ exports.Td = Td;
255
+ exports.Tfoot = Tfoot;
256
+ exports.Th = Th;
257
+ exports.Thead = Thead;
258
+ exports.Tr = Tr;
package/index.esm.js ADDED
@@ -0,0 +1,246 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { cvaMerge } from '@trackunit/css-class-variance-utilities';
3
+
4
+ /******************************************************************************
5
+ Copyright (c) Microsoft Corporation.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
+ PERFORMANCE OF THIS SOFTWARE.
17
+ ***************************************************************************** */
18
+
19
+ function __rest(s, e) {
20
+ var t = {};
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
22
+ t[p] = s[p];
23
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
24
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
25
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
26
+ t[p[i]] = s[p[i]];
27
+ }
28
+ return t;
29
+ }
30
+
31
+ /**
32
+ * Component for a resizable handle element.
33
+ *
34
+ * @param {object} props - Props for the resizable handle.
35
+ * @param {boolean} [props.isResizing=false] - Indicates whether the handle is in a resizing state.
36
+ * @param {string} [props.dataTestId] - A data-testid attribute for testing purposes.
37
+ * @param {string} [props.className] - Additional CSS classes to apply to the handle.
38
+ * @returns {ReactElement} A React element representing the resizable handle.
39
+ */
40
+ const ResizeHandel = (_a) => {
41
+ var { isResizing = false, dataTestId, className } = _a, rest = __rest(_a, ["isResizing", "dataTestId", "className"]);
42
+ return (jsx("div", Object.assign({ role: "separator", "data-testid": dataTestId, className: cvaResizeHandel({ isResizing, className }) }, rest)));
43
+ };
44
+ const cvaResizeHandel = cvaMerge([
45
+ "absolute",
46
+ "!cursor-col-resize",
47
+ "right-0",
48
+ "top-0",
49
+ "h-full",
50
+ "w-1",
51
+ "select-none",
52
+ "hover:bg-primary-400",
53
+ "cursor-pointer",
54
+ ], {
55
+ variants: {
56
+ isResizing: {
57
+ true: ["bg-blue-500", "opacity-1"],
58
+ false: [],
59
+ },
60
+ },
61
+ });
62
+
63
+ /**
64
+ * Component for a sorting indicator element.
65
+ *
66
+ * @param {object} props - Props for the sorting indicator.
67
+ * @param {boolean} [props.sortingState=false] - Indicates the sorting state (ascending/descending).
68
+ * @param {string} [props.dataTestId] - A data-testid attribute for testing purposes.
69
+ * @param {string} [props.className] - Additional CSS classes to apply to the sorting indicator.
70
+ * @returns {ReactElement} A React element representing the sorting indicator.
71
+ */
72
+ const SortIndicator = (_a) => {
73
+ var { sortingState = false, dataTestId, className } = _a, rest = __rest(_a, ["sortingState", "dataTestId", "className"]);
74
+ return (jsx("span", Object.assign({ role: "separator", "data-testid": dataTestId, className: cvaSortIndicator({ sortingState, className }) }, rest)));
75
+ };
76
+ const cvaSortIndicator = cvaMerge([
77
+ "relative",
78
+ "before:block",
79
+ "before:h-0",
80
+ "before:absolute",
81
+ "before:w-0",
82
+ "before:bottom-0.5",
83
+ "before:content-['_']",
84
+ "before:border-4",
85
+ "before:border-solid",
86
+ "before:border-transparent",
87
+ "after:block",
88
+ "after:h-0",
89
+ "after:absolute",
90
+ "after:w-0",
91
+ "after:-bottom-[9px]",
92
+ "after:content-['_']",
93
+ "after:border-4",
94
+ "after:border-solid",
95
+ "after:border-transparent",
96
+ "before:border-b-neutral-300",
97
+ "after:border-t-neutral-300",
98
+ ], {
99
+ variants: {
100
+ sortingState: {
101
+ asc: ["before:border-b-primary-600"],
102
+ desc: ["after:border-t-primary-600"],
103
+ false: "",
104
+ },
105
+ },
106
+ });
107
+
108
+ /**
109
+ * The TableRoot is a wrapper for the table html element.
110
+ * It is used to render a table, and adds some default styling.
111
+ *
112
+ * In most cases, we recommend using the Table Component over the Table Base Components.
113
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
114
+ *
115
+ * @param {TableRootProps} props - The props for the TableRoot component
116
+ * @returns {JSX.Element} TableRoot component
117
+ */
118
+ const TableRoot = (_a) => {
119
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
120
+ return (jsx("table", Object.assign({ "data-testid": dataTestId, className: cvaTableRoot({ className }) }, rest, { children: children })));
121
+ };
122
+ const cvaTableRoot = cvaMerge(["border-spacing-0", "min-w-full"]);
123
+
124
+ /**
125
+ * The Tbody is a wrapper for the tbody html element.
126
+ * It is used to render a table, and adds some default styling.
127
+ *
128
+ * In most cases, we recommend using the Table Component over the Table Base Components.
129
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
130
+ *
131
+ * @param {TbodyProps} props - The props for the Tbody component
132
+ * @returns {JSX.Element} Tbody component
133
+ */
134
+ const Tbody = (_a) => {
135
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
136
+ return (jsx("tbody", Object.assign({ "data-testid": dataTestId, className: className }, rest, { children: children })));
137
+ };
138
+
139
+ /**
140
+ * The Td is a wrapper for the td html element.
141
+ * It is used to render a table, and adds some default styling.
142
+ *
143
+ * In most cases, we recommend using the Table Component over the Table Base Components.
144
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
145
+ *
146
+ * @param {TdProps} props - The props for the Td component
147
+ * @returns {JSX.Element} Td component
148
+ */
149
+ const Td = (_a) => {
150
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
151
+ return (jsx("td", Object.assign({ "data-testid": dataTestId, className: cvaTd({ className }) }, rest, { children: children })));
152
+ };
153
+ const cvaTd = cvaMerge(["overflow-hidden", "align-middle", "py-table-spacing", "px-2", "whitespace-nowrap"]);
154
+
155
+ /**
156
+ * The Tfoot is a wrapper for the tfoot html element.
157
+ * It is used to render a table, and adds some default styling.
158
+ *
159
+ * In most cases, we recommend using the Table Component over the Table Base Components.
160
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
161
+ *
162
+ * @param {TfootProps} props - The props for the Tfoot component
163
+ * @returns {JSX.Element} Tfoot component
164
+ */
165
+ const Tfoot = (_a) => {
166
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
167
+ return (jsx("tfoot", Object.assign({ "data-testid": dataTestId, className: className }, rest, { children: children })));
168
+ };
169
+
170
+ /**
171
+ * The Th is a wrapper for the th html element.
172
+ * It is used to render a table, and adds some default styling.
173
+ *
174
+ * In most cases, we recommend using the Table Component over the Table Base Components.
175
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
176
+ *
177
+ * @param {ThProps} props - The props for the Th component
178
+ * @returns {JSX.Element} Th component
179
+ */
180
+ const Th = (_a) => {
181
+ var { dataTestId, className, children } = _a, rest = __rest(_a, ["dataTestId", "className", "children"]);
182
+ return (jsx("th", Object.assign({ "data-testid": dataTestId, className: cvaTh({ className }) }, rest, { children: children })));
183
+ };
184
+ const cvaTh = cvaMerge([
185
+ "hover:bg-neutral-200",
186
+ "text-sm",
187
+ "overflow-hidden",
188
+ "font-medium",
189
+ "whitespace-nowrap",
190
+ "px-3",
191
+ "py-table-spacing",
192
+ ]);
193
+
194
+ /**
195
+ * The Thead is a wrapper for the thead html element.
196
+ * It is used to render a table, and adds some default styling.
197
+ *
198
+ * In most cases, we recommend using the Table Component over the Table Base Components.
199
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
200
+ *
201
+ * @param {TheadProps} props - The props for the Thead component
202
+ * @returns {JSX.Element} Thead component
203
+ */
204
+ const Thead = (_a) => {
205
+ var { dataTestId, className, children, sticky = true } = _a, rest = __rest(_a, ["dataTestId", "className", "children", "sticky"]);
206
+ return (jsx("thead", Object.assign({ "data-testid": dataTestId, className: cvaThead({ sticky, className }) }, rest, { children: children })));
207
+ };
208
+ const cvaThead = cvaMerge(["bg-neutral-100", "text-left"], {
209
+ variants: {
210
+ sticky: {
211
+ true: ["sticky", "top-0"],
212
+ false: [],
213
+ },
214
+ },
215
+ defaultVariants: {
216
+ sticky: true,
217
+ },
218
+ });
219
+
220
+ /**
221
+ * The Tr is a wrapper for the tr html element.
222
+ * It is used to render a table, and adds some default styling.
223
+ *
224
+ * In most cases, we recommend using the Table Component over the Table Base Components.
225
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
226
+ *
227
+ * @param {TrProps} props - The props for the Tr component
228
+ * @returns {JSX.Element} Tr component
229
+ */
230
+ const Tr = (_a) => {
231
+ var { dataTestId, className, children, layout = "default" } = _a, rest = __rest(_a, ["dataTestId", "className", "children", "layout"]);
232
+ return (jsx("tr", Object.assign({ role: "row", "data-testid": dataTestId, className: cvaTr({ layout, className }) }, rest, { children: children })));
233
+ };
234
+ const cvaTr = cvaMerge(["border-b", "border-neutral-300", "w-full", "h-max"], {
235
+ variants: {
236
+ layout: {
237
+ default: "",
238
+ flex: ["flex"],
239
+ },
240
+ },
241
+ defaultVariants: {
242
+ layout: "default",
243
+ },
244
+ });
245
+
246
+ export { ResizeHandel, SortIndicator, TableRoot, Tbody, Td, Tfoot, Th, Thead, Tr };
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@trackunit/react-table-base-components",
3
+ "version": "0.0.1-alpha-d7497395ac.0",
4
+ "repository": "https://github.com/Trackunit/manager",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "engines": {
7
+ "node": ">=18.x"
8
+ },
9
+ "dependencies": {
10
+ "@trackunit/css-class-variance-utilities": "0.0.13-alpha-d7497395ac.0",
11
+ "@trackunit/react-components": "0.1.151-alpha-d7497395ac.0",
12
+ "react": "18.2.0"
13
+ },
14
+ "module": "./index.esm.js",
15
+ "main": "./index.cjs.js",
16
+ "peerDependencies": {}
17
+ }
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { TableRoot } from "./components/TableRoot";
3
+ type Story = StoryObj<typeof TableRoot>;
4
+ declare const meta: Meta<typeof TableRoot>;
5
+ export default meta;
6
+ export declare const Default: Story;
@@ -0,0 +1,15 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactElement } from "react";
3
+ export interface ResizeHandelProps extends CommonProps, React.HTMLAttributes<HTMLDivElement> {
4
+ isResizing?: boolean;
5
+ }
6
+ /**
7
+ * Component for a resizable handle element.
8
+ *
9
+ * @param {object} props - Props for the resizable handle.
10
+ * @param {boolean} [props.isResizing=false] - Indicates whether the handle is in a resizing state.
11
+ * @param {string} [props.dataTestId] - A data-testid attribute for testing purposes.
12
+ * @param {string} [props.className] - Additional CSS classes to apply to the handle.
13
+ * @returns {ReactElement} A React element representing the resizable handle.
14
+ */
15
+ export declare const ResizeHandel: ({ isResizing, dataTestId, className, ...rest }: ResizeHandelProps) => ReactElement;
@@ -0,0 +1,26 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactElement } from "react";
3
+ export interface SortIndicatorProps extends CommonProps, React.HTMLAttributes<HTMLSpanElement> {
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
+ * The current state of the sorting.
14
+ */
15
+ sortingState?: false | "asc" | "desc";
16
+ }
17
+ /**
18
+ * Component for a sorting indicator element.
19
+ *
20
+ * @param {object} props - Props for the sorting indicator.
21
+ * @param {boolean} [props.sortingState=false] - Indicates the sorting state (ascending/descending).
22
+ * @param {string} [props.dataTestId] - A data-testid attribute for testing purposes.
23
+ * @param {string} [props.className] - Additional CSS classes to apply to the sorting indicator.
24
+ * @returns {ReactElement} A React element representing the sorting indicator.
25
+ */
26
+ export declare const SortIndicator: ({ sortingState, dataTestId, className, ...rest }: SortIndicatorProps) => ReactElement;
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { SortIndicator } from "./SortIndicator";
3
+ type Story = StoryObj<typeof SortIndicator>;
4
+ declare const meta: Meta<typeof SortIndicator>;
5
+ export default meta;
6
+ export declare const Default: Story;
@@ -0,0 +1,27 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactNode } from "react";
3
+ export interface TableRootProps extends CommonProps, React.HTMLAttributes<HTMLTableElement> {
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
+ * Children to render in the table root.
14
+ */
15
+ children?: ReactNode;
16
+ }
17
+ /**
18
+ * The TableRoot is a wrapper for the table html element.
19
+ * It is used to render a table, and adds some default styling.
20
+ *
21
+ * In most cases, we recommend using the Table Component over the Table Base Components.
22
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
23
+ *
24
+ * @param {TableRootProps} props - The props for the TableRoot component
25
+ * @returns {JSX.Element} TableRoot component
26
+ */
27
+ export declare const TableRoot: ({ dataTestId, className, children, ...rest }: TableRootProps) => JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactNode } from "react";
3
+ export interface TbodyProps 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
+ * Children to render in the table section.
14
+ */
15
+ children?: ReactNode;
16
+ }
17
+ /**
18
+ * The Tbody is a wrapper for the tbody html element.
19
+ * It is used to render a table, and adds some default styling.
20
+ *
21
+ * In most cases, we recommend using the Table Component over the Table Base Components.
22
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
23
+ *
24
+ * @param {TbodyProps} props - The props for the Tbody component
25
+ * @returns {JSX.Element} Tbody component
26
+ */
27
+ export declare const Tbody: ({ dataTestId, className, children, ...rest }: TbodyProps) => JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactNode } from "react";
3
+ export interface TdProps extends CommonProps, React.HTMLAttributes<HTMLTableCellElement> {
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
+ * Children to render in the table cell.
14
+ */
15
+ children?: ReactNode;
16
+ }
17
+ /**
18
+ * The Td is a wrapper for the td html element.
19
+ * It is used to render a table, and adds some default styling.
20
+ *
21
+ * In most cases, we recommend using the Table Component over the Table Base Components.
22
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
23
+ *
24
+ * @param {TdProps} props - The props for the Td component
25
+ * @returns {JSX.Element} Td component
26
+ */
27
+ export declare const Td: ({ dataTestId, className, children, ...rest }: TdProps) => JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactNode } from "react";
3
+ export interface TfootProps 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
+ * Children to render in the table section.
14
+ */
15
+ children?: ReactNode;
16
+ }
17
+ /**
18
+ * The Tfoot is a wrapper for the tfoot html element.
19
+ * It is used to render a table, and adds some default styling.
20
+ *
21
+ * In most cases, we recommend using the Table Component over the Table Base Components.
22
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
23
+ *
24
+ * @param {TfootProps} props - The props for the Tfoot component
25
+ * @returns {JSX.Element} Tfoot component
26
+ */
27
+ export declare const Tfoot: ({ dataTestId, className, children, ...rest }: TfootProps) => JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactNode } from "react";
3
+ export interface ThProps extends CommonProps, React.HTMLAttributes<HTMLTableCellElement> {
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
+ * Children to render in the table cell.
14
+ */
15
+ children?: ReactNode;
16
+ }
17
+ /**
18
+ * The Th is a wrapper for the th html element.
19
+ * It is used to render a table, and adds some default styling.
20
+ *
21
+ * In most cases, we recommend using the Table Component over the Table Base Components.
22
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
23
+ *
24
+ * @param {ThProps} props - The props for the Th component
25
+ * @returns {JSX.Element} Th component
26
+ */
27
+ export declare const Th: ({ dataTestId, className, children, ...rest }: ThProps) => JSX.Element;
@@ -0,0 +1,34 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactNode } from "react";
3
+ export interface TheadProps 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
+ * Children to render in the table section.
14
+ */
15
+ children?: ReactNode;
16
+ /**
17
+ * Should thead be sticky
18
+ * This defaults to true, as it is helpful for cases where virtualization is used.
19
+ *
20
+ * @default true
21
+ */
22
+ sticky?: boolean;
23
+ }
24
+ /**
25
+ * The Thead is a wrapper for the thead html element.
26
+ * It is used to render a table, and adds some default styling.
27
+ *
28
+ * In most cases, we recommend using the Table Component over the Table Base Components.
29
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
30
+ *
31
+ * @param {TheadProps} props - The props for the Thead component
32
+ * @returns {JSX.Element} Thead component
33
+ */
34
+ export declare const Thead: ({ dataTestId, className, children, sticky, ...rest }: TheadProps) => JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { ReactNode } from "react";
3
+ export interface TrProps extends CommonProps, React.HTMLAttributes<HTMLTableRowElement> {
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
+ * Children to render in the table row.
14
+ */
15
+ children?: ReactNode;
16
+ /**
17
+ * Defines the layout of the table row.
18
+ * Flex layout is used for tables where the width is controlled.
19
+ * For tables with column resizing, the flex layout should be used.
20
+ *
21
+ * @default default
22
+ */
23
+ layout?: "default" | "flex";
24
+ }
25
+ /**
26
+ * The Tr is a wrapper for the tr html element.
27
+ * It is used to render a table, and adds some default styling.
28
+ *
29
+ * In most cases, we recommend using the Table Component over the Table Base Components.
30
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
31
+ *
32
+ * @param {TrProps} props - The props for the Tr component
33
+ * @returns {JSX.Element} Tr component
34
+ */
35
+ export declare const Tr: ({ dataTestId, className, children, layout, ...rest }: TrProps) => JSX.Element;
package/src/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export * from "./components/ResizeHandel";
2
+ export * from "./components/SortIndicator";
3
+ export * from "./components/TableRoot";
4
+ export * from "./components/Tbody";
5
+ export * from "./components/Td";
6
+ export * from "./components/Tfoot";
7
+ export * from "./components/Th";
8
+ export * from "./components/Thead";
9
+ export * from "./components/Tr";