@trackunit/react-filter-components 0.0.203 → 0.0.205

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,7 +113,7 @@ const FilterFooter = (_a) => {
113
113
  var { className, dataTestId, children } = _a, rest = __rest(_a, ["className", "dataTestId", "children"]);
114
114
  return (jsxRuntime.jsx("div", Object.assign({ className: cvaFilterFooter({ className }), "data-testid": dataTestId }, rest, { children: children })));
115
115
  };
116
- const cvaFilterFooter = cssClassVarianceUtilities.cvaMerge(["flex", "justify-end", "before:p-1"]);
116
+ const cvaFilterFooter = cssClassVarianceUtilities.cvaMerge(["flex", "justify-end", "p-1"]);
117
117
 
118
118
  /**
119
119
  * The FilterHeader component is used to display the title of the filter and a reset button.
@@ -147,14 +147,17 @@ const cvaFilterHeaderButton = cssClassVarianceUtilities.cvaMerge([], {
147
147
  * @returns {JSX.Element} FilterItem component
148
148
  */
149
149
  const CheckBoxFilterItem = (_a) => {
150
- var { itemCount, className, prefix, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["itemCount", "className", "prefix", "dataTestId", "menuItemProps"]);
150
+ var { itemCount, className, prefix, dataTestId, menuItemProps, showTooltip } = _a, rest = __rest(_a, ["itemCount", "className", "prefix", "dataTestId", "menuItemProps", "showTooltip"]);
151
151
  const checkboxProps = Object.assign({}, rest);
152
152
  const checkboxRef = React.useRef(null);
153
- return (jsxRuntime.jsx(reactComponents.MenuItem, Object.assign({ onClick: e => {
153
+ const [labelRef, setLabelRef] = React.useState(null);
154
+ const enableTooltip = reactComponents.useIsTextCutOff(labelRef);
155
+ const Item = (jsxRuntime.jsx(reactComponents.MenuItem, Object.assign({ onClick: e => {
154
156
  var _a;
155
157
  e.preventDefault();
156
158
  (_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
157
- }, selected: checkboxProps.checked, disabled: checkboxProps.disabled, className: className, dataTestId: dataTestId, prefix: prefix }, menuItemProps, { suffix: jsxRuntime.jsx("small", { children: itemCount }), children: jsxRuntime.jsx(reactFormComponents.Checkbox, Object.assign({ ref: checkboxRef }, checkboxProps, { dataTestId: dataTestId && `${dataTestId}-checkbox`, className: "flex-grow cursor-pointer" })) })));
159
+ }, selected: checkboxProps.checked, disabled: checkboxProps.disabled, className: className, dataTestId: dataTestId, prefix: prefix }, menuItemProps, { suffix: jsxRuntime.jsx("small", { children: itemCount }), children: jsxRuntime.jsx(reactFormComponents.Checkbox, Object.assign({ ref: checkboxRef, onLabelRefChange: label => setLabelRef(label) }, checkboxProps, { dataTestId: dataTestId && `${dataTestId}-checkbox`, className: "flex-grow cursor-pointer" })) })));
160
+ return (jsxRuntime.jsx("div", { children: enableTooltip && Boolean(showTooltip) ? (jsxRuntime.jsx(reactComponents.Tooltip, { label: checkboxProps.label, contentTextType: "span", placement: "top", className: "w-full", children: Item }, "tooltip-" + checkboxProps.name)) : (Item) }));
158
161
  };
159
162
 
160
163
  /**
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
3
- import { Popover, PopoverTrigger, Button, PopoverContent, MenuList, Spinner, MenuItem, Text } from '@trackunit/react-components';
4
- import React, { useRef } from 'react';
3
+ import { Popover, PopoverTrigger, Button, PopoverContent, MenuList, Spinner, useIsTextCutOff, MenuItem, Tooltip, Text } from '@trackunit/react-components';
4
+ import React, { useRef, useState } from 'react';
5
5
  import { Checkbox, RadioItem } from '@trackunit/react-form-components';
6
6
 
7
7
  /******************************************************************************
@@ -105,7 +105,7 @@ const FilterFooter = (_a) => {
105
105
  var { className, dataTestId, children } = _a, rest = __rest(_a, ["className", "dataTestId", "children"]);
106
106
  return (jsx("div", Object.assign({ className: cvaFilterFooter({ className }), "data-testid": dataTestId }, rest, { children: children })));
107
107
  };
108
- const cvaFilterFooter = cvaMerge(["flex", "justify-end", "before:p-1"]);
108
+ const cvaFilterFooter = cvaMerge(["flex", "justify-end", "p-1"]);
109
109
 
110
110
  /**
111
111
  * The FilterHeader component is used to display the title of the filter and a reset button.
@@ -139,14 +139,17 @@ const cvaFilterHeaderButton = cvaMerge([], {
139
139
  * @returns {JSX.Element} FilterItem component
140
140
  */
141
141
  const CheckBoxFilterItem = (_a) => {
142
- var { itemCount, className, prefix, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["itemCount", "className", "prefix", "dataTestId", "menuItemProps"]);
142
+ var { itemCount, className, prefix, dataTestId, menuItemProps, showTooltip } = _a, rest = __rest(_a, ["itemCount", "className", "prefix", "dataTestId", "menuItemProps", "showTooltip"]);
143
143
  const checkboxProps = Object.assign({}, rest);
144
144
  const checkboxRef = useRef(null);
145
- return (jsx(MenuItem, Object.assign({ onClick: e => {
145
+ const [labelRef, setLabelRef] = useState(null);
146
+ const enableTooltip = useIsTextCutOff(labelRef);
147
+ const Item = (jsx(MenuItem, Object.assign({ onClick: e => {
146
148
  var _a;
147
149
  e.preventDefault();
148
150
  (_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
149
- }, selected: checkboxProps.checked, disabled: checkboxProps.disabled, className: className, dataTestId: dataTestId, prefix: prefix }, menuItemProps, { suffix: jsx("small", { children: itemCount }), children: jsx(Checkbox, Object.assign({ ref: checkboxRef }, checkboxProps, { dataTestId: dataTestId && `${dataTestId}-checkbox`, className: "flex-grow cursor-pointer" })) })));
151
+ }, selected: checkboxProps.checked, disabled: checkboxProps.disabled, className: className, dataTestId: dataTestId, prefix: prefix }, menuItemProps, { suffix: jsx("small", { children: itemCount }), children: jsx(Checkbox, Object.assign({ ref: checkboxRef, onLabelRefChange: label => setLabelRef(label) }, checkboxProps, { dataTestId: dataTestId && `${dataTestId}-checkbox`, className: "flex-grow cursor-pointer" })) })));
152
+ return (jsx("div", { children: enableTooltip && Boolean(showTooltip) ? (jsx(Tooltip, { label: checkboxProps.label, contentTextType: "span", placement: "top", className: "w-full", children: Item }, "tooltip-" + checkboxProps.name)) : (Item) }));
150
153
  };
151
154
 
152
155
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-filter-components",
3
- "version": "0.0.203",
3
+ "version": "0.0.205",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@trackunit/css-class-variance-utilities": "0.0.14",
11
- "@trackunit/react-components": "0.1.158",
12
- "@trackunit/react-form-components": "0.0.144",
11
+ "@trackunit/react-components": "0.1.160",
12
+ "@trackunit/react-form-components": "0.0.146",
13
13
  "react": "18.2.0"
14
14
  },
15
15
  "module": "./index.esm.js",
@@ -7,4 +7,4 @@ import { CheckBoxFilterItemProps } from "../types";
7
7
  * @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
8
8
  * @returns {JSX.Element} FilterItem component
9
9
  */
10
- export declare const CheckBoxFilterItem: ({ itemCount, className, prefix, dataTestId, menuItemProps, ...rest }: CheckBoxFilterItemProps) => JSX.Element;
10
+ export declare const CheckBoxFilterItem: ({ itemCount, className, prefix, dataTestId, menuItemProps, showTooltip, ...rest }: CheckBoxFilterItemProps) => JSX.Element;
@@ -1,12 +1,14 @@
1
1
  import { MenuItemProps } from "@trackunit/react-components";
2
2
  import { CheckboxProps, RadioItemProps } from "@trackunit/react-form-components";
3
3
  export interface CheckBoxFilterItemProps extends Omit<CheckboxProps, "prefix" | "suffix">, BaseFilterItemProps {
4
+ showTooltip?: boolean;
4
5
  }
5
6
  export interface RadioFilterItemProps<V extends string | number = string> extends RadioItemProps<V>, BaseFilterItemProps {
6
7
  /**
7
8
  * An boolean flag to set checkbox to checked state
8
9
  */
9
10
  selected?: boolean;
11
+ showTooltip?: boolean;
10
12
  }
11
13
  interface BaseFilterItemProps {
12
14
  /**