@trackunit/react-filter-components 0.0.602 → 0.0.604
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
@@ -5,6 +5,7 @@ var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities
|
|
5
5
|
var reactComponents = require('@trackunit/react-components');
|
6
6
|
var React = require('react');
|
7
7
|
var reactFormComponents = require('@trackunit/react-form-components');
|
8
|
+
var tailwindMerge = require('tailwind-merge');
|
8
9
|
|
9
10
|
const cvaFilterCustomButton = cssClassVarianceUtilities.cvaMerge([], {
|
10
11
|
variants: {
|
@@ -55,7 +56,7 @@ const FilterBody = React.forwardRef(({ children, dataTestId, limitSize = false,
|
|
55
56
|
return (jsxRuntime.jsx("div", { className: cvaFilterBody({ limitSize }), ref: ref, ...rest, "data-testid": dataTestId, children: children }));
|
56
57
|
});
|
57
58
|
FilterBody.displayName = "FilterBody";
|
58
|
-
const cvaFilterBody = cssClassVarianceUtilities.cvaMerge(["grid", "gap-1", "
|
59
|
+
const cvaFilterBody = cssClassVarianceUtilities.cvaMerge(["grid", "gap-1", "rounded", "w-full"], {
|
59
60
|
variants: {
|
60
61
|
limitSize: {
|
61
62
|
true: "max-h-80 max-w-sm overflow-hidden overflow-y-auto",
|
@@ -89,7 +90,7 @@ const cvaFilterFooter = cssClassVarianceUtilities.cvaMerge(["flex", "justify-end
|
|
89
90
|
* @returns {JSX.Element} FilterHeader component
|
90
91
|
*/
|
91
92
|
const FilterHeader = ({ title, resetLabel, showReset, dataTestId, onReset, loading, children, ...rest }) => {
|
92
|
-
return (jsxRuntime.jsxs("div", { className: "grid gap-1 p-1", ...rest, "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: "flex h-6 items-center justify-between pl-1 text-sm font-medium uppercase text-slate-600
|
93
|
+
return (jsxRuntime.jsxs("div", { className: "grid gap-1 border-b-2 p-1", ...rest, "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: "flex h-6 items-center justify-between gap-1 pl-1 text-sm font-medium uppercase text-slate-600", children: [jsxRuntime.jsx("h4", { children: title }), loading ? (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(reactComponents.Spinner, { size: "small" }) })) : (jsxRuntime.jsx(reactComponents.Button, { className: cvaFilterHeaderButton({ isVisible: showReset }), "data-testid": `${dataTestId}-reset-button`, onClick: onReset, size: "small", variant: "ghost", children: resetLabel }))] }), children] }));
|
93
94
|
};
|
94
95
|
const cvaFilterHeaderButton = cssClassVarianceUtilities.cvaMerge([], {
|
95
96
|
variants: {
|
@@ -110,17 +111,12 @@ const cvaFilterHeaderButton = cssClassVarianceUtilities.cvaMerge([], {
|
|
110
111
|
* @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
|
111
112
|
* @returns {JSX.Element} FilterItem component
|
112
113
|
*/
|
113
|
-
const CheckBoxFilterItem = ({ itemCount, className,
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
var _a;
|
120
|
-
e.preventDefault();
|
121
|
-
(_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
122
|
-
}, prefix: prefix, selected: checkboxProps.checked, ...menuItemProps, suffix: jsxRuntime.jsx("small", { children: itemCount }), tabIndex: -1, children: jsxRuntime.jsx(reactFormComponents.Checkbox, { onLabelRefChange: label => setLabelRef(label), ref: checkboxRef, ...checkboxProps, className: "flex-grow cursor-pointer", dataTestId: dataTestId ? `${dataTestId}-checkbox` : undefined }) }));
|
123
|
-
return (jsxRuntime.jsx("div", { children: enableTooltip && Boolean(showTooltip) ? (jsxRuntime.jsx(reactComponents.Tooltip, { className: "w-full", label: checkboxProps.label, placement: "top", children: Item }, "tooltip-" + checkboxProps.name)) : (Item) }));
|
114
|
+
const CheckBoxFilterItem = ({ itemCount, className, suffix, dataTestId, label, ...rest }) => {
|
115
|
+
return (jsxRuntime.jsx(reactFormComponents.Checkbox, { className: reactComponents.cvaInteractableItem({
|
116
|
+
selected: "auto",
|
117
|
+
focused: "auto",
|
118
|
+
className: tailwindMerge.twMerge(["py-1", "pl-2", "pr-3", "w-full", "h-auto", "items-center", "gap-x-2", "select-none", "rounded"], className),
|
119
|
+
}), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : `${label}-checkbox-filter-item`, label: label, suffix: itemCount !== undefined || suffix ? (jsxRuntime.jsxs("span", { className: reactComponents.cvaMenuItemSuffix({ selected: rest.checked }), children: [suffix, itemCount === undefined ? null : itemCount] })) : null, ...rest }));
|
124
120
|
};
|
125
121
|
|
126
122
|
/**
|
@@ -130,7 +126,13 @@ const CheckBoxFilterItem = ({ itemCount, className, prefix, dataTestId, menuItem
|
|
130
126
|
* @param {RadioFilterItemProps} props - The props for the FilterItem component
|
131
127
|
* @returns {JSX.Element} FilterItem component
|
132
128
|
*/
|
133
|
-
const RadioFilterItem = ({ value, label, itemCount, selected, dataTestId,
|
129
|
+
const RadioFilterItem = ({ value, label, itemCount, selected, dataTestId, suffix, className, ...rest }) => {
|
130
|
+
return (jsxRuntime.jsx(reactFormComponents.RadioItem, { className: reactComponents.cvaInteractableItem({
|
131
|
+
selected: "auto",
|
132
|
+
focused: "auto",
|
133
|
+
className: tailwindMerge.twMerge(["py-1", "pl-2", "pr-3", "w-full", "h-auto", "items-center", "gap-x-2", "select-none", "rounded"], className),
|
134
|
+
}), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : `${label}-radio-filter-item`, label: label, suffix: itemCount !== undefined || suffix ? (jsxRuntime.jsxs("span", { className: reactComponents.cvaMenuItemSuffix({ selected: rest.checked }), children: [suffix, itemCount === undefined ? null : itemCount] })) : null, value: value, ...rest }));
|
135
|
+
};
|
134
136
|
|
135
137
|
exports.CheckBoxFilterItem = CheckBoxFilterItem;
|
136
138
|
exports.Filter = Filter;
|
package/index.esm.js
CHANGED
@@ -1,8 +1,9 @@
|
|
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,
|
4
|
-
import React
|
3
|
+
import { Popover, PopoverTrigger, Button, PopoverContent, MenuList, Spinner, cvaInteractableItem, cvaMenuItemSuffix } from '@trackunit/react-components';
|
4
|
+
import React from 'react';
|
5
5
|
import { Checkbox, RadioItem } from '@trackunit/react-form-components';
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
6
7
|
|
7
8
|
const cvaFilterCustomButton = cvaMerge([], {
|
8
9
|
variants: {
|
@@ -53,7 +54,7 @@ const FilterBody = React.forwardRef(({ children, dataTestId, limitSize = false,
|
|
53
54
|
return (jsx("div", { className: cvaFilterBody({ limitSize }), ref: ref, ...rest, "data-testid": dataTestId, children: children }));
|
54
55
|
});
|
55
56
|
FilterBody.displayName = "FilterBody";
|
56
|
-
const cvaFilterBody = cvaMerge(["grid", "gap-1", "
|
57
|
+
const cvaFilterBody = cvaMerge(["grid", "gap-1", "rounded", "w-full"], {
|
57
58
|
variants: {
|
58
59
|
limitSize: {
|
59
60
|
true: "max-h-80 max-w-sm overflow-hidden overflow-y-auto",
|
@@ -87,7 +88,7 @@ const cvaFilterFooter = cvaMerge(["flex", "justify-end", "p-1"]);
|
|
87
88
|
* @returns {JSX.Element} FilterHeader component
|
88
89
|
*/
|
89
90
|
const FilterHeader = ({ title, resetLabel, showReset, dataTestId, onReset, loading, children, ...rest }) => {
|
90
|
-
return (jsxs("div", { className: "grid gap-1 p-1", ...rest, "data-testid": dataTestId, children: [jsxs("div", { className: "flex h-6 items-center justify-between pl-1 text-sm font-medium uppercase text-slate-600
|
91
|
+
return (jsxs("div", { className: "grid gap-1 border-b-2 p-1", ...rest, "data-testid": dataTestId, children: [jsxs("div", { className: "flex h-6 items-center justify-between gap-1 pl-1 text-sm font-medium uppercase text-slate-600", children: [jsx("h4", { children: title }), loading ? (jsx("div", { children: jsx(Spinner, { size: "small" }) })) : (jsx(Button, { className: cvaFilterHeaderButton({ isVisible: showReset }), "data-testid": `${dataTestId}-reset-button`, onClick: onReset, size: "small", variant: "ghost", children: resetLabel }))] }), children] }));
|
91
92
|
};
|
92
93
|
const cvaFilterHeaderButton = cvaMerge([], {
|
93
94
|
variants: {
|
@@ -108,17 +109,12 @@ const cvaFilterHeaderButton = cvaMerge([], {
|
|
108
109
|
* @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
|
109
110
|
* @returns {JSX.Element} FilterItem component
|
110
111
|
*/
|
111
|
-
const CheckBoxFilterItem = ({ itemCount, className,
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
var _a;
|
118
|
-
e.preventDefault();
|
119
|
-
(_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
120
|
-
}, prefix: prefix, selected: checkboxProps.checked, ...menuItemProps, suffix: jsx("small", { children: itemCount }), tabIndex: -1, children: jsx(Checkbox, { onLabelRefChange: label => setLabelRef(label), ref: checkboxRef, ...checkboxProps, className: "flex-grow cursor-pointer", dataTestId: dataTestId ? `${dataTestId}-checkbox` : undefined }) }));
|
121
|
-
return (jsx("div", { children: enableTooltip && Boolean(showTooltip) ? (jsx(Tooltip, { className: "w-full", label: checkboxProps.label, placement: "top", children: Item }, "tooltip-" + checkboxProps.name)) : (Item) }));
|
112
|
+
const CheckBoxFilterItem = ({ itemCount, className, suffix, dataTestId, label, ...rest }) => {
|
113
|
+
return (jsx(Checkbox, { className: cvaInteractableItem({
|
114
|
+
selected: "auto",
|
115
|
+
focused: "auto",
|
116
|
+
className: twMerge(["py-1", "pl-2", "pr-3", "w-full", "h-auto", "items-center", "gap-x-2", "select-none", "rounded"], className),
|
117
|
+
}), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : `${label}-checkbox-filter-item`, label: label, suffix: itemCount !== undefined || suffix ? (jsxs("span", { className: cvaMenuItemSuffix({ selected: rest.checked }), children: [suffix, itemCount === undefined ? null : itemCount] })) : null, ...rest }));
|
122
118
|
};
|
123
119
|
|
124
120
|
/**
|
@@ -128,6 +124,12 @@ const CheckBoxFilterItem = ({ itemCount, className, prefix, dataTestId, menuItem
|
|
128
124
|
* @param {RadioFilterItemProps} props - The props for the FilterItem component
|
129
125
|
* @returns {JSX.Element} FilterItem component
|
130
126
|
*/
|
131
|
-
const RadioFilterItem = ({ value, label, itemCount, selected, dataTestId,
|
127
|
+
const RadioFilterItem = ({ value, label, itemCount, selected, dataTestId, suffix, className, ...rest }) => {
|
128
|
+
return (jsx(RadioItem, { className: cvaInteractableItem({
|
129
|
+
selected: "auto",
|
130
|
+
focused: "auto",
|
131
|
+
className: twMerge(["py-1", "pl-2", "pr-3", "w-full", "h-auto", "items-center", "gap-x-2", "select-none", "rounded"], className),
|
132
|
+
}), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : `${label}-radio-filter-item`, label: label, suffix: itemCount !== undefined || suffix ? (jsxs("span", { className: cvaMenuItemSuffix({ selected: rest.checked }), children: [suffix, itemCount === undefined ? null : itemCount] })) : null, value: value, ...rest }));
|
133
|
+
};
|
132
134
|
|
133
135
|
export { CheckBoxFilterItem, Filter, FilterBody, FilterFooter, FilterHeader, RadioFilterItem, cvaFilterFooter, cvaFilterHeaderButton };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@trackunit/react-filter-components",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.604",
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"engines": {
|
@@ -10,7 +10,8 @@
|
|
10
10
|
"@trackunit/css-class-variance-utilities": "*",
|
11
11
|
"@trackunit/react-components": "*",
|
12
12
|
"react": "18.3.1",
|
13
|
-
"@trackunit/react-form-components": "*"
|
13
|
+
"@trackunit/react-form-components": "*",
|
14
|
+
"tailwind-merge": "^2.0.0"
|
14
15
|
},
|
15
16
|
"module": "./index.esm.js",
|
16
17
|
"main": "./index.cjs.js",
|
@@ -6,4 +6,4 @@ import { CheckBoxFilterItemProps } from "../types";
|
|
6
6
|
* @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
|
7
7
|
* @returns {JSX.Element} FilterItem component
|
8
8
|
*/
|
9
|
-
export declare const CheckBoxFilterItem: ({ itemCount, className,
|
9
|
+
export declare const CheckBoxFilterItem: ({ itemCount, className, suffix, dataTestId, label, ...rest }: CheckBoxFilterItemProps) => import("react/jsx-runtime").JSX.Element;
|
@@ -6,4 +6,4 @@ import { RadioFilterItemProps } from "../types";
|
|
6
6
|
* @param {RadioFilterItemProps} props - The props for the FilterItem component
|
7
7
|
* @returns {JSX.Element} FilterItem component
|
8
8
|
*/
|
9
|
-
export declare const RadioFilterItem: ({ value, label, itemCount, selected, dataTestId,
|
9
|
+
export declare const RadioFilterItem: ({ value, label, itemCount, selected, dataTestId, suffix, className, ...rest }: RadioFilterItemProps) => import("react/jsx-runtime").JSX.Element;
|
@@ -1,14 +1,11 @@
|
|
1
|
-
import { MenuItemProps } from "@trackunit/react-components";
|
2
1
|
import { CheckboxProps, RadioItemProps } from "@trackunit/react-form-components";
|
3
|
-
export interface CheckBoxFilterItemProps extends
|
4
|
-
showTooltip?: boolean;
|
2
|
+
export interface CheckBoxFilterItemProps extends CheckboxProps, BaseFilterItemProps {
|
5
3
|
}
|
6
4
|
export interface RadioFilterItemProps<TProps extends string | number = string> extends RadioItemProps<TProps>, BaseFilterItemProps {
|
7
5
|
/**
|
8
6
|
* An boolean flag to set checkbox to checked state
|
9
7
|
*/
|
10
8
|
selected?: boolean;
|
11
|
-
showTooltip?: boolean;
|
12
9
|
}
|
13
10
|
interface BaseFilterItemProps {
|
14
11
|
/**
|
@@ -16,10 +13,5 @@ interface BaseFilterItemProps {
|
|
16
13
|
* This displays the number next to the label.
|
17
14
|
*/
|
18
15
|
itemCount?: number;
|
19
|
-
/**
|
20
|
-
* Properties to be passed to the MenuItem component.
|
21
|
-
*/
|
22
|
-
menuItemProps?: MenuItemProps;
|
23
|
-
prefix?: MenuItemProps["prefix"];
|
24
16
|
}
|
25
17
|
export {};
|