@trackunit/react-filter-components 0.0.7 → 0.0.11

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.js CHANGED
@@ -43,9 +43,9 @@ function __rest(s, e) {
43
43
  * @returns {JSX.Element} Filter component
44
44
  */
45
45
  const Filter = (_a) => {
46
- var { title, children, popoverProps, isActive, activeLabel, menuListProps, className, dataTestId, withStickyHeader = false } = _a, rest = __rest(_a, ["title", "children", "popoverProps", "isActive", "activeLabel", "menuListProps", "className", "dataTestId", "withStickyHeader"]);
46
+ var { title, children, popoverProps, isActive, activeLabel, menuListProps, className, dataTestId, withStickyHeader = false, readOnly } = _a, rest = __rest(_a, ["title", "children", "popoverProps", "isActive", "activeLabel", "menuListProps", "className", "dataTestId", "withStickyHeader", "readOnly"]);
47
47
  const buttonProps = Object.assign({}, rest);
48
- return (jsx(Popover, Object.assign({ dataTestId: `${dataTestId}-popover`, placement: "bottom-start" }, popoverProps, { render: () => (jsx(CustomMenuList, Object.assign({ withStickyHeader: withStickyHeader, dataTestId: `${dataTestId}-menulist` }, menuListProps, { children: children }))) }, { children: jsxs(CustomButton, Object.assign({ color: "tertiary", size: "small", dataTestId: dataTestId }, buttonProps, { "$isActive": isActive, className: className }, { children: [title, " ", isActive && jsx(ActiveLabel, { children: activeLabel })] })) })));
48
+ return (jsx(Popover, Object.assign({ dataTestId: dataTestId && `${dataTestId}-popover`, placement: "bottom-start" }, popoverProps, { render: () => (jsx(CustomMenuList, Object.assign({ withStickyHeader: withStickyHeader, dataTestId: dataTestId && `${dataTestId}-menulist` }, menuListProps, { children: children }))) }, { children: jsxs(CustomButton, Object.assign({ color: "tertiary", size: "small", dataTestId: dataTestId, disabled: readOnly }, buttonProps, { "$isActive": isActive, className: className }, { children: [title, " ", isActive && jsx(ActiveLabel, { children: activeLabel })] })) })));
49
49
  };
50
50
  const CustomButton = twx(Button) `
51
51
  ${({ $isActive }) => ($isActive ? tws `!border-primary-600` : "")}
@@ -75,7 +75,7 @@ const FilterItem = (_a) => {
75
75
  var _a;
76
76
  e.preventDefault();
77
77
  (_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
78
- }, selected: checkboxProps.checked, disabled: checkboxProps.disabled, className: `${className} overflow-hidden`, dataTestId: dataTestId, prefix: prefix }, menuItemProps, { suffix: jsx("small", { children: itemCount }) }, { children: jsx(Checkbox, Object.assign({ ref: checkboxRef }, checkboxProps, { dataTestId: `${dataTestId}-checkbox`, className: "flex-grow cursor-pointer" })) })));
78
+ }, selected: checkboxProps.checked, disabled: checkboxProps.disabled, className: `${className} overflow-hidden`, 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" })) })));
79
79
  };
80
80
 
81
81
  /**
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@trackunit/react-filter-components",
3
- "version": "0.0.7",
3
+ "version": "0.0.11",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
7
- "@trackunit/react-components": "0.1.28",
7
+ "@trackunit/react-components": "0.1.31",
8
8
  "react": "18.2.0",
9
9
  "@trackunit/tailwind-styled-components": "0.0.51",
10
10
  "jest-canvas-mock": "2.4.0"
@@ -34,6 +34,10 @@ export interface FilterProps extends ButtonProps {
34
34
  * The render prop cannot be overridden.
35
35
  */
36
36
  menuListProps?: Omit<MenuListProps, "children">;
37
+ /**
38
+ * A flag to set a filter component into readonly mode used for presenting filtering rules that cannot be change by user
39
+ */
40
+ readOnly?: boolean;
37
41
  }
38
42
  /**
39
43
  * The Filter component is the base component used in the manager to filter data.
@@ -47,4 +51,4 @@ export interface FilterProps extends ButtonProps {
47
51
  * @param {FilterProps} props - The props for the Filter component
48
52
  * @returns {JSX.Element} Filter component
49
53
  */
50
- export declare const Filter: ({ title, children, popoverProps, isActive, activeLabel, menuListProps, className, dataTestId, withStickyHeader, ...rest }: FilterProps) => JSX.Element;
54
+ export declare const Filter: ({ title, children, popoverProps, isActive, activeLabel, menuListProps, className, dataTestId, withStickyHeader, readOnly, ...rest }: FilterProps) => JSX.Element;