@trackunit/react-table-base-components 0.0.171 → 0.0.172

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 CHANGED
@@ -113,6 +113,24 @@ const LinkCell = (_a) => {
113
113
  return (jsxRuntime.jsx(reactComponents.ExternalLink, Object.assign({ href: `${linkPrefix}${link}` }, rest, { onClick: handleClick, children: link })));
114
114
  };
115
115
 
116
+ const cvaMultiValueTextCellWrapper = cssClassVarianceUtilities.cvaMerge(["flex", "flex-row", "items-center", "gap-1", "overflow-hidden"]);
117
+ const cvaMultiValueTextCellTooltip = cssClassVarianceUtilities.cvaMerge(["whitespace-no-wrap", "overflow-hidden", "text-ellipsis"]);
118
+
119
+ /**
120
+ * The `<MultiValueTextCell>` component is used for displaying the text values with multiple values in a table cell. First element is displayed as a text, the rest of the values are displayed as a number. Icon can be passed as an optional prop.
121
+ * The text content is not editable and will be truncated if the cell is too narrow.
122
+ *
123
+ * @param {MultiValueTextCellProps} props - The props for the MultiValueTextCell component
124
+ * @returns {JSX.Element} MultiValueTextCell component
125
+ */
126
+ const MultiValueTextCell = ({ content, count, icon, iconTooltip, dataTestId, className, }) => {
127
+ const [isTooltipVisible, setIsTooltipVisible] = react.useState(false);
128
+ const updateTooltipVisibility = (element) => {
129
+ setIsTooltipVisible(element ? element.scrollWidth > element.clientWidth : false);
130
+ };
131
+ return count && count > 0 ? (jsxRuntime.jsxs("div", { className: cvaMultiValueTextCellWrapper({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx(reactComponents.Tooltip, { disabled: !iconTooltip, label: iconTooltip !== null && iconTooltip !== void 0 ? iconTooltip : "", placement: "bottom", className: "inline", children: icon }), jsxRuntime.jsx("span", { ref: elementRef => updateTooltipVisibility(elementRef), className: cvaMultiValueTextCellTooltip(), children: jsxRuntime.jsx(reactComponents.Tooltip, { disabled: !isTooltipVisible, label: content !== null && content !== void 0 ? content : "", placement: "bottom", className: "inline", children: content !== null && content !== void 0 ? content : "" }) }), jsxRuntime.jsx("span", { className: "text-slate-500", children: count > 1 ? `+${count - 1}` : "" })] })) : null;
132
+ };
133
+
116
134
  const cvaNumberCell = cssClassVarianceUtilities.cvaMerge([
117
135
  "flex",
118
136
  "gap-1",
@@ -162,74 +180,6 @@ const cvaResizeHandel = cssClassVarianceUtilities.cvaMerge(["absolute", "cursor-
162
180
  },
163
181
  });
164
182
 
165
- const cvaSiteCellWrapper = cssClassVarianceUtilities.cvaMerge(["flex", "flex-row", "items-center", "gap-2", "overflow-hidden"]);
166
- const cvaSiteCellTooltip = cssClassVarianceUtilities.cvaMerge(["whitespace-no-wrap", "overflow-hidden", "text-ellipsis"]);
167
-
168
- const cvaSiteIconContainer = cssClassVarianceUtilities.cvaMerge(["flex", "rounded-full", "p-[2px]"], {
169
- variants: {
170
- type: {
171
- AREA: "bg-site-AREA",
172
- CONSTRUCTION_SITE: "bg-site-CONSTRUCTION_SITE",
173
- DEPOT: "bg-site-DEPOT",
174
- WORK_PLACE: "bg-site-WORK_PLACE",
175
- CLASSIC_POI: "bg-site-CLASSIC_POI",
176
- CLASSIC_ZONE: "bg-site-CLASSIC_ZONE",
177
- UNKNOWN: "bg-site-UNKNOWN",
178
- },
179
- shape: {
180
- round: "rounded-full",
181
- square: "rounded-md",
182
- },
183
- },
184
- defaultVariants: {
185
- type: "UNKNOWN",
186
- shape: "square",
187
- },
188
- });
189
-
190
- /**
191
- * The `<SiteIcon>` component is used for displaying the site icon with a tooltip for the type.
192
- *
193
- * @param {SiteIconProps} props - The props for the SiteCell component
194
- * @returns {JSX.Element} SiteCell component
195
- */
196
- const SiteIcon = ({ size = "medium", type, shape, className, dataTestId }) => {
197
- return (jsxRuntime.jsx("div", { className: cvaSiteIconContainer({ type, shape, className }), "data-testid": dataTestId, children: jsxRuntime.jsx(reactComponents.Icon, { name: getIconName(type), size: size, color: "white" }) }));
198
- };
199
- const getIconName = (type) => {
200
- switch (type) {
201
- case "CONSTRUCTION_SITE":
202
- return "ConstructionCone";
203
- case "WORK_PLACE":
204
- return "Home";
205
- case "DEPOT":
206
- return "BuildingOffice";
207
- case "AREA":
208
- return "Map";
209
- case "CLASSIC_ZONE":
210
- case "CLASSIC_POI":
211
- return "Zone";
212
- default:
213
- return "QuestionMarkCircle";
214
- }
215
- };
216
-
217
- /**
218
- * The `<SiteCell>` component is used for displaying the sites in a table cell.
219
- * The site name is not editable and will be truncated if the cell is too narrow.
220
- *
221
- * @param {SiteCellProps} props - The props for the SiteCell component
222
- * @returns {JSX.Element} SiteCell component
223
- */
224
- const SiteCell = ({ count, sites, dataTestId, className }) => {
225
- var _a, _b;
226
- const [isTooltipVisible, setIsTooltipVisible] = react.useState(false);
227
- const updateTooltipVisibility = (element) => {
228
- setIsTooltipVisible(element ? element.scrollWidth > element.clientWidth : false);
229
- };
230
- return count && count > 0 ? (jsxRuntime.jsxs("div", { className: cvaSiteCellWrapper({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx(SiteIcon, { size: "small", type: sites.type }), jsxRuntime.jsx("span", { ref: elementRef => updateTooltipVisibility(elementRef), className: cvaSiteCellTooltip(), children: jsxRuntime.jsx(reactComponents.Tooltip, { disabled: !isTooltipVisible, label: (_a = sites.name) !== null && _a !== void 0 ? _a : "", placement: "bottom", className: "inline", children: (_b = sites.name) !== null && _b !== void 0 ? _b : "" }) }), jsxRuntime.jsx("span", { className: "text-slate-500", children: count > 1 ? `+${count - 1}` : "" })] })) : null;
231
- };
232
-
233
183
  /**
234
184
  * The SortIndicator is used in the table header to indicate the current sort order of the column.
235
185
  * This is a visual only component and does not handle the sorting logic.
@@ -454,10 +404,9 @@ exports.DateTimeCell = DateTimeCell;
454
404
  exports.ImageCell = ImageCell;
455
405
  exports.IndicatorCell = IndicatorCell;
456
406
  exports.LinkCell = LinkCell;
407
+ exports.MultiValueTextCell = MultiValueTextCell;
457
408
  exports.NumberCell = NumberCell;
458
409
  exports.ResizeHandle = ResizeHandle;
459
- exports.SiteCell = SiteCell;
460
- exports.SiteIcon = SiteIcon;
461
410
  exports.SortIndicator = SortIndicator;
462
411
  exports.TableRoot = TableRoot;
463
412
  exports.TagsCell = TagsCell;
package/index.esm.js CHANGED
@@ -2,7 +2,7 @@ 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
4
  import { formatDateUtil, timeSinceAuto } from '@trackunit/date-and-time-utils';
5
- import { Indicator, ExternalLink, Icon, Tooltip, Tag } from '@trackunit/react-components';
5
+ import { Indicator, ExternalLink, Tooltip, Tag } from '@trackunit/react-components';
6
6
  import { useState } from 'react';
7
7
 
8
8
  const cvaCheckboxCell = cvaMerge([""]);
@@ -109,6 +109,24 @@ const LinkCell = (_a) => {
109
109
  return (jsx(ExternalLink, Object.assign({ href: `${linkPrefix}${link}` }, rest, { onClick: handleClick, children: link })));
110
110
  };
111
111
 
112
+ const cvaMultiValueTextCellWrapper = cvaMerge(["flex", "flex-row", "items-center", "gap-1", "overflow-hidden"]);
113
+ const cvaMultiValueTextCellTooltip = cvaMerge(["whitespace-no-wrap", "overflow-hidden", "text-ellipsis"]);
114
+
115
+ /**
116
+ * The `<MultiValueTextCell>` component is used for displaying the text values with multiple values in a table cell. First element is displayed as a text, the rest of the values are displayed as a number. Icon can be passed as an optional prop.
117
+ * The text content is not editable and will be truncated if the cell is too narrow.
118
+ *
119
+ * @param {MultiValueTextCellProps} props - The props for the MultiValueTextCell component
120
+ * @returns {JSX.Element} MultiValueTextCell component
121
+ */
122
+ const MultiValueTextCell = ({ content, count, icon, iconTooltip, dataTestId, className, }) => {
123
+ const [isTooltipVisible, setIsTooltipVisible] = useState(false);
124
+ const updateTooltipVisibility = (element) => {
125
+ setIsTooltipVisible(element ? element.scrollWidth > element.clientWidth : false);
126
+ };
127
+ return count && count > 0 ? (jsxs("div", { className: cvaMultiValueTextCellWrapper({ className }), "data-testid": dataTestId, children: [jsx(Tooltip, { disabled: !iconTooltip, label: iconTooltip !== null && iconTooltip !== void 0 ? iconTooltip : "", placement: "bottom", className: "inline", children: icon }), jsx("span", { ref: elementRef => updateTooltipVisibility(elementRef), className: cvaMultiValueTextCellTooltip(), children: jsx(Tooltip, { disabled: !isTooltipVisible, label: content !== null && content !== void 0 ? content : "", placement: "bottom", className: "inline", children: content !== null && content !== void 0 ? content : "" }) }), jsx("span", { className: "text-slate-500", children: count > 1 ? `+${count - 1}` : "" })] })) : null;
128
+ };
129
+
112
130
  const cvaNumberCell = cvaMerge([
113
131
  "flex",
114
132
  "gap-1",
@@ -158,74 +176,6 @@ const cvaResizeHandel = cvaMerge(["absolute", "cursor-col-resize", "right-0", "t
158
176
  },
159
177
  });
160
178
 
161
- const cvaSiteCellWrapper = cvaMerge(["flex", "flex-row", "items-center", "gap-2", "overflow-hidden"]);
162
- const cvaSiteCellTooltip = cvaMerge(["whitespace-no-wrap", "overflow-hidden", "text-ellipsis"]);
163
-
164
- const cvaSiteIconContainer = cvaMerge(["flex", "rounded-full", "p-[2px]"], {
165
- variants: {
166
- type: {
167
- AREA: "bg-site-AREA",
168
- CONSTRUCTION_SITE: "bg-site-CONSTRUCTION_SITE",
169
- DEPOT: "bg-site-DEPOT",
170
- WORK_PLACE: "bg-site-WORK_PLACE",
171
- CLASSIC_POI: "bg-site-CLASSIC_POI",
172
- CLASSIC_ZONE: "bg-site-CLASSIC_ZONE",
173
- UNKNOWN: "bg-site-UNKNOWN",
174
- },
175
- shape: {
176
- round: "rounded-full",
177
- square: "rounded-md",
178
- },
179
- },
180
- defaultVariants: {
181
- type: "UNKNOWN",
182
- shape: "square",
183
- },
184
- });
185
-
186
- /**
187
- * The `<SiteIcon>` component is used for displaying the site icon with a tooltip for the type.
188
- *
189
- * @param {SiteIconProps} props - The props for the SiteCell component
190
- * @returns {JSX.Element} SiteCell component
191
- */
192
- const SiteIcon = ({ size = "medium", type, shape, className, dataTestId }) => {
193
- return (jsx("div", { className: cvaSiteIconContainer({ type, shape, className }), "data-testid": dataTestId, children: jsx(Icon, { name: getIconName(type), size: size, color: "white" }) }));
194
- };
195
- const getIconName = (type) => {
196
- switch (type) {
197
- case "CONSTRUCTION_SITE":
198
- return "ConstructionCone";
199
- case "WORK_PLACE":
200
- return "Home";
201
- case "DEPOT":
202
- return "BuildingOffice";
203
- case "AREA":
204
- return "Map";
205
- case "CLASSIC_ZONE":
206
- case "CLASSIC_POI":
207
- return "Zone";
208
- default:
209
- return "QuestionMarkCircle";
210
- }
211
- };
212
-
213
- /**
214
- * The `<SiteCell>` component is used for displaying the sites in a table cell.
215
- * The site name is not editable and will be truncated if the cell is too narrow.
216
- *
217
- * @param {SiteCellProps} props - The props for the SiteCell component
218
- * @returns {JSX.Element} SiteCell component
219
- */
220
- const SiteCell = ({ count, sites, dataTestId, className }) => {
221
- var _a, _b;
222
- const [isTooltipVisible, setIsTooltipVisible] = useState(false);
223
- const updateTooltipVisibility = (element) => {
224
- setIsTooltipVisible(element ? element.scrollWidth > element.clientWidth : false);
225
- };
226
- return count && count > 0 ? (jsxs("div", { className: cvaSiteCellWrapper({ className }), "data-testid": dataTestId, children: [jsx(SiteIcon, { size: "small", type: sites.type }), jsx("span", { ref: elementRef => updateTooltipVisibility(elementRef), className: cvaSiteCellTooltip(), children: jsx(Tooltip, { disabled: !isTooltipVisible, label: (_a = sites.name) !== null && _a !== void 0 ? _a : "", placement: "bottom", className: "inline", children: (_b = sites.name) !== null && _b !== void 0 ? _b : "" }) }), jsx("span", { className: "text-slate-500", children: count > 1 ? `+${count - 1}` : "" })] })) : null;
227
- };
228
-
229
179
  /**
230
180
  * The SortIndicator is used in the table header to indicate the current sort order of the column.
231
181
  * This is a visual only component and does not handle the sorting logic.
@@ -445,4 +395,4 @@ const cvaTr = cvaMerge(["border-b", "border-neutral-300", "w-full", "h-max"], {
445
395
  },
446
396
  });
447
397
 
448
- export { CheckboxCell, DateTimeCell, ImageCell, IndicatorCell, LinkCell, NumberCell, ResizeHandle, SiteCell, SiteIcon, SortIndicator, TableRoot, TagsCell, Tbody, Td, TextCell, Tfoot, Th, Thead, Tr };
398
+ export { CheckboxCell, DateTimeCell, ImageCell, IndicatorCell, LinkCell, MultiValueTextCell, 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.171",
3
+ "version": "0.0.172",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "@trackunit/react-components";
3
+ export interface MultiValueTextCellProps extends CommonProps {
4
+ icon?: JSX.Element;
5
+ iconTooltip?: string;
6
+ content?: string;
7
+ count?: number | null;
8
+ }
9
+ /**
10
+ * The `<MultiValueTextCell>` component is used for displaying the text values with multiple values in a table cell. First element is displayed as a text, the rest of the values are displayed as a number. Icon can be passed as an optional prop.
11
+ * The text content is not editable and will be truncated if the cell is too narrow.
12
+ *
13
+ * @param {MultiValueTextCellProps} props - The props for the MultiValueTextCell component
14
+ * @returns {JSX.Element} MultiValueTextCell component
15
+ */
16
+ export declare const MultiValueTextCell: ({ content, count, icon, iconTooltip, dataTestId, className, }: MultiValueTextCellProps) => JSX.Element | null;
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { MultiValueTextCell } from "./MultiValueTextCell";
3
+ import "./MultiValueTextCell.variants";
4
+ type Story = StoryObj<typeof MultiValueTextCell>;
5
+ declare const meta: Meta<typeof MultiValueTextCell>;
6
+ export default meta;
7
+ export declare const packageName: () => JSX.Element;
8
+ export declare const Default: Story;
9
+ export declare const Example: Story;
@@ -0,0 +1,2 @@
1
+ export declare const cvaMultiValueTextCellWrapper: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
2
+ export declare const cvaMultiValueTextCellTooltip: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
package/src/index.d.ts CHANGED
@@ -3,10 +3,9 @@ export * from "./components/DateTimeCell/DateTimeCell";
3
3
  export * from "./components/ImageCell/ImageCell";
4
4
  export * from "./components/IndicatorCell/IndicatorCell";
5
5
  export * from "./components/LinkCell/LinkCell";
6
+ export * from "./components/MultiValueTextCell/MultiValueTextCell";
6
7
  export * from "./components/NumberCell/NumberCell";
7
8
  export * from "./components/ResizeHandle";
8
- export * from "./components/SiteCell/SiteCell";
9
- export * from "./components/SiteCell/SiteIcon/SiteIcon";
10
9
  export * from "./components/SortIndicator";
11
10
  export * from "./components/TableRoot";
12
11
  export * from "./components/TagsCell/TagsCell";
@@ -1,20 +0,0 @@
1
- /// <reference types="react" />
2
- import { CommonProps } from "@trackunit/react-components";
3
- export type CellSiteType = "AREA" | "CLASSIC_POI" | "CLASSIC_ZONE" | "CONSTRUCTION_SITE" | "DEPOT" | "WORK_PLACE";
4
- type CellSite = {
5
- name?: string | null;
6
- type?: CellSiteType;
7
- };
8
- export interface SiteCellProps extends CommonProps {
9
- sites: CellSite;
10
- count?: number | null;
11
- }
12
- /**
13
- * The `<SiteCell>` component is used for displaying the sites in a table cell.
14
- * The site name is not editable and will be truncated if the cell is too narrow.
15
- *
16
- * @param {SiteCellProps} props - The props for the SiteCell component
17
- * @returns {JSX.Element} SiteCell component
18
- */
19
- export declare const SiteCell: ({ count, sites, dataTestId, className }: SiteCellProps) => JSX.Element | null;
20
- export {};
@@ -1,9 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import { SiteCell } from "./SiteCell";
3
- import "./SiteCell.variants";
4
- type Story = StoryObj<typeof SiteCell>;
5
- declare const meta: Meta<typeof SiteCell>;
6
- export default meta;
7
- export declare const packageName: () => JSX.Element;
8
- export declare const Default: Story;
9
- export declare const Example: Story;
@@ -1,2 +0,0 @@
1
- export declare const cvaSiteCellWrapper: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
2
- export declare const cvaSiteCellTooltip: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
@@ -1,18 +0,0 @@
1
- /// <reference types="react" />
2
- import { CommonProps, Size } from "@trackunit/react-components";
3
- import { CellSiteType } from "../SiteCell";
4
- type SiteType = CellSiteType;
5
- type Shape = "round" | "square";
6
- export interface SiteIconProps extends CommonProps {
7
- type?: SiteType;
8
- size?: Size;
9
- shape?: Shape;
10
- }
11
- /**
12
- * The `<SiteIcon>` component is used for displaying the site icon with a tooltip for the type.
13
- *
14
- * @param {SiteIconProps} props - The props for the SiteCell component
15
- * @returns {JSX.Element} SiteCell component
16
- */
17
- export declare const SiteIcon: ({ size, type, shape, className, dataTestId }: SiteIconProps) => JSX.Element;
18
- export {};
@@ -1,4 +0,0 @@
1
- export declare const cvaSiteIconContainer: (props?: ({
2
- type?: "AREA" | "CONSTRUCTION_SITE" | "DEPOT" | "WORK_PLACE" | "CLASSIC_POI" | "CLASSIC_ZONE" | "UNKNOWN" | null | undefined;
3
- shape?: "round" | "square" | null | undefined;
4
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;