@trackunit/react-filter-components 0.0.124 → 0.0.133

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 CHANGED
@@ -39,75 +39,75 @@ function __rest(s, e) {
39
39
  return t;
40
40
  }
41
41
 
42
- /**
43
- * The Filter component is the base component used in the manager to filter data.
44
- *
45
- * - This component in generic and does not have any connection to the data.
46
- * - The base props extends button props, and any button props such as prefix and suffix can be used.
47
- * - Color and size has special default values in this component, but can be overridden if needed.
48
- *
49
- * To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
50
- *
51
- * @param {FilterProps} props - The props for the Filter component
52
- * @returns {JSX.Element} Filter component
53
- */
54
- const Filter = (_a) => {
55
- 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"]);
56
- const buttonProps = Object.assign({}, rest);
57
- return (jsxRuntime.jsxs(reactComponents.Popover, Object.assign({ dataTestId: dataTestId && `${dataTestId}-popover`, placement: "bottom-start" }, popoverProps, { children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsxs(CustomButton, Object.assign({ color: "tertiary", size: "small", dataTestId: dataTestId, disabled: readOnly }, buttonProps, { "$isActive": isActive, className: className }, { children: [title, " ", isActive && jsxRuntime.jsx(ActiveLabel, { children: activeLabel })] })) }), jsxRuntime.jsx(reactComponents.PopoverContent, { children: jsxRuntime.jsx(CustomMenuList, Object.assign({ withStickyHeader: withStickyHeader, dataTestId: dataTestId && `${dataTestId}-menulist` }, menuListProps, { children: children })) })] })));
58
- };
42
+ /**
43
+ * The Filter component is the base component used in the manager to filter data.
44
+ *
45
+ * - This component in generic and does not have any connection to the data.
46
+ * - The base props extends button props, and any button props such as prefix and suffix can be used.
47
+ * - Color and size has special default values in this component, but can be overridden if needed.
48
+ *
49
+ * To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
50
+ *
51
+ * @param {FilterProps} props - The props for the Filter component
52
+ * @returns {JSX.Element} Filter component
53
+ */
54
+ const Filter = (_a) => {
55
+ 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"]);
56
+ const buttonProps = Object.assign({}, rest);
57
+ return (jsxRuntime.jsxs(reactComponents.Popover, Object.assign({ dataTestId: dataTestId && `${dataTestId}-popover`, placement: "bottom-start" }, popoverProps, { children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsxs(CustomButton, Object.assign({ color: "tertiary", size: "small", dataTestId: dataTestId, disabled: readOnly }, buttonProps, { "$isActive": isActive, className: className, children: [title, " ", isActive && jsxRuntime.jsx(ActiveLabel, { children: activeLabel })] })) }), jsxRuntime.jsx(reactComponents.PopoverContent, { children: jsxRuntime.jsx(CustomMenuList, Object.assign({ withStickyHeader: withStickyHeader, dataTestId: dataTestId && `${dataTestId}-menulist` }, menuListProps, { children: children })) })] })));
58
+ };
59
59
  const CustomButton = tailwindStyledComponents.twx(reactComponents.Button) `
60
60
  ${({ $isActive }) => ($isActive ? tailwindStyledComponents.tws `!border-primary-600` : "")}
61
- `;
61
+ `;
62
62
  const CustomMenuList = tailwindStyledComponents.twx(reactComponents.MenuList) `
63
63
  overflow-x-hidden
64
64
  overflow-y-auto
65
65
  relative
66
- `;
66
+ `;
67
67
  const ActiveLabel = tailwindStyledComponents.tw.span `
68
68
  text-primary-600
69
69
  `;
70
70
 
71
- /**
72
- * The FilterBody component is used to display the title of the filter and a reset button.
73
- * IT is intended for use in the Filter component.
74
- * The reset button will only be visible if the showReset prop is set to true.
75
- *
76
- * @param {FilterBodyProps} props - The props for the FilterBody component
77
- * @returns {JSX.Element} FilterBody component
78
- */
79
- const FilterBody = React__default["default"].forwardRef((_a, ref) => {
80
- var { children, dataTestId, limitSize = false } = _a, rest = __rest(_a, ["children", "dataTestId", "limitSize"]);
81
- return (jsxRuntime.jsx(Root$1, Object.assign({ "$limitSize": limitSize, ref: ref }, rest, { "data-testid": dataTestId }, { children: children })));
82
- });
71
+ /**
72
+ * The FilterBody component is used to display the title of the filter and a reset button.
73
+ * IT is intended for use in the Filter component.
74
+ * The reset button will only be visible if the showReset prop is set to true.
75
+ *
76
+ * @param {FilterBodyProps} props - The props for the FilterBody component
77
+ * @returns {JSX.Element} FilterBody component
78
+ */
79
+ const FilterBody = React__default["default"].forwardRef((_a, ref) => {
80
+ var { children, dataTestId, limitSize = false } = _a, rest = __rest(_a, ["children", "dataTestId", "limitSize"]);
81
+ return (jsxRuntime.jsx(Root$1, Object.assign({ "$limitSize": limitSize, ref: ref }, rest, { "data-testid": dataTestId, children: children })));
82
+ });
83
83
  const Root$1 = tailwindStyledComponents.tw.div `
84
84
  grid
85
85
  gap-1
86
86
  p-1
87
87
  rounded
88
88
  w-full
89
- ${props => props.$limitSize
89
+ ${props => props.$limitSize
90
90
  ? tailwindStyledComponents.tws `
91
91
  overflow-hidden
92
92
  max-h-80
93
93
  max-w-sm
94
94
  overflow-y-auto
95
- `
95
+ `
96
96
  : ""}
97
97
  `;
98
98
 
99
- /**
100
- * The FilterHeader component is used to display the title of the filter and a reset button.
101
- * IT is intended for use in the Filter component.
102
- * The reset button will only be visible if the showReset prop is set to true.
103
- *
104
- * @param {FilterHeaderProps} props - The props for the FilterHeader component
105
- * @returns {JSX.Element} FilterHeader component
106
- */
107
- const FilterHeader = (_a) => {
108
- var { title, resetLabel, showReset, dataTestId, onReset, loading, children } = _a, rest = __rest(_a, ["title", "resetLabel", "showReset", "dataTestId", "onReset", "loading", "children"]);
109
- return (jsxRuntime.jsxs(Root, Object.assign({}, rest, { "data-testid": dataTestId }, { children: [jsxRuntime.jsxs(HeadingContainer, { children: [jsxRuntime.jsx("h4", { children: title }), loading ? (jsxRuntime.jsx(reactComponents.Spinner, { size: "small" })) : (jsxRuntime.jsx(HiddenButton, Object.assign({ "$isVisible": Boolean(showReset), size: "small", variant: "transparent", color: "danger", onClick: onReset }, { children: resetLabel })))] }), children] })));
110
- };
99
+ /**
100
+ * The FilterHeader component is used to display the title of the filter and a reset button.
101
+ * IT is intended for use in the Filter component.
102
+ * The reset button will only be visible if the showReset prop is set to true.
103
+ *
104
+ * @param {FilterHeaderProps} props - The props for the FilterHeader component
105
+ * @returns {JSX.Element} FilterHeader component
106
+ */
107
+ const FilterHeader = (_a) => {
108
+ var { title, resetLabel, showReset, dataTestId, onReset, loading, children } = _a, rest = __rest(_a, ["title", "resetLabel", "showReset", "dataTestId", "onReset", "loading", "children"]);
109
+ return (jsxRuntime.jsxs(Root, Object.assign({}, rest, { "data-testid": dataTestId, children: [jsxRuntime.jsxs(HeadingContainer, { children: [jsxRuntime.jsx("h4", { children: title }), loading ? (jsxRuntime.jsx(reactComponents.Spinner, { size: "small" })) : (jsxRuntime.jsx(HiddenButton, { "$isVisible": Boolean(showReset), size: "small", variant: "transparent", color: "danger", onClick: onReset, children: resetLabel }))] }), children] })));
110
+ };
111
111
  const HeadingContainer = tailwindStyledComponents.tw.div `
112
112
  flex
113
113
  items-center
@@ -117,44 +117,44 @@ const HeadingContainer = tailwindStyledComponents.tw.div `
117
117
  text-sm
118
118
  text-slate-600
119
119
  uppercase
120
- `;
120
+ `;
121
121
  const HiddenButton = tailwindStyledComponents.twx(reactComponents.Button) `
122
122
  ${props => (props.$isVisible ? tailwindStyledComponents.tws `visible` : tailwindStyledComponents.tws `invisible`)}
123
- `;
123
+ `;
124
124
  const Root = tailwindStyledComponents.tw.div `
125
125
  grid
126
126
  gap-1
127
127
  p-1
128
128
  `;
129
129
 
130
- /**
131
- * The CheckBoxFilterItem component is the base component used in the manager to FilterItem data.
132
- * This component in generic and does not have any connection to the data.
133
- *
134
- * @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
135
- * @returns {JSX.Element} FilterItem component
136
- */
137
- const CheckBoxFilterItem = (_a) => {
138
- var { itemCount, className, prefix, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["itemCount", "className", "prefix", "dataTestId", "menuItemProps"]);
139
- const checkboxProps = Object.assign({}, rest);
140
- const checkboxRef = React.useRef(null);
141
- return (jsxRuntime.jsx(reactComponents.MenuItem, Object.assign({ onClick: e => {
142
- var _a;
143
- e.preventDefault();
144
- (_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
145
- }, 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" })) })));
130
+ /**
131
+ * The CheckBoxFilterItem component is the base component used in the manager to FilterItem data.
132
+ * This component in generic and does not have any connection to the data.
133
+ *
134
+ * @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
135
+ * @returns {JSX.Element} FilterItem component
136
+ */
137
+ const CheckBoxFilterItem = (_a) => {
138
+ var { itemCount, className, prefix, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["itemCount", "className", "prefix", "dataTestId", "menuItemProps"]);
139
+ const checkboxProps = Object.assign({}, rest);
140
+ const checkboxRef = React.useRef(null);
141
+ return (jsxRuntime.jsx(reactComponents.MenuItem, Object.assign({ onClick: e => {
142
+ var _a;
143
+ e.preventDefault();
144
+ (_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
145
+ }, 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" })) })));
146
146
  };
147
147
 
148
- /**
149
- * The RadioFilterItem component is the base component used in the manager to FilterItem data.
150
- * This component in generic and does not have any connection to the data.
151
- *
152
- * @param {RadioFilterItemProps} props - The props for the FilterItem component
153
- * @returns {JSX.Element} FilterItem component
154
- */
155
- const RadioFilterItem = (_a) => {
156
- var { value, label, itemCount, selected, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["value", "label", "itemCount", "selected", "dataTestId", "menuItemProps"]);
157
- return (jsxRuntime.jsx(reactComponents.MenuItem, Object.assign({ selected: selected, dataTestId: dataTestId, className: "flex justify-between cursor-default p-0 my-[2px]", suffix: jsxRuntime.jsx("small", Object.assign({ className: "pl-1 pr-3" }, { children: itemCount })) }, menuItemProps, { children: jsxRuntime.jsx(reactFormComponents.RadioItem, Object.assign({}, rest, { value: value, className: "flex items-center w-full py-2 pl-2", dataTestId: dataTestId && `${dataTestId}-radio`, label: jsxRuntime.jsx(reactComponents.Text, Object.assign({ className: "cursor-pointer", type: "span" }, { children: label })) })) })));
148
+ /**
149
+ * The RadioFilterItem component is the base component used in the manager to FilterItem data.
150
+ * This component in generic and does not have any connection to the data.
151
+ *
152
+ * @param {RadioFilterItemProps} props - The props for the FilterItem component
153
+ * @returns {JSX.Element} FilterItem component
154
+ */
155
+ const RadioFilterItem = (_a) => {
156
+ var { value, label, itemCount, selected, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["value", "label", "itemCount", "selected", "dataTestId", "menuItemProps"]);
157
+ return (jsxRuntime.jsx(reactComponents.MenuItem, Object.assign({ selected: selected, dataTestId: dataTestId, className: "flex justify-between cursor-default p-0 my-[2px]", suffix: jsxRuntime.jsx("small", { className: "pl-1 pr-3", children: itemCount }) }, menuItemProps, { children: jsxRuntime.jsx(reactFormComponents.RadioItem, Object.assign({}, rest, { value: value, className: "flex items-center w-full py-2 pl-2", dataTestId: dataTestId && `${dataTestId}-radio`, label: jsxRuntime.jsx(reactComponents.Text, { className: "cursor-pointer", type: "span", children: label }) })) })));
158
158
  };
159
159
 
160
160
  exports.CheckBoxFilterItem = CheckBoxFilterItem;
package/index.js CHANGED
@@ -31,75 +31,75 @@ function __rest(s, e) {
31
31
  return t;
32
32
  }
33
33
 
34
- /**
35
- * The Filter component is the base component used in the manager to filter data.
36
- *
37
- * - This component in generic and does not have any connection to the data.
38
- * - The base props extends button props, and any button props such as prefix and suffix can be used.
39
- * - Color and size has special default values in this component, but can be overridden if needed.
40
- *
41
- * To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
42
- *
43
- * @param {FilterProps} props - The props for the Filter component
44
- * @returns {JSX.Element} Filter component
45
- */
46
- const Filter = (_a) => {
47
- 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"]);
48
- const buttonProps = Object.assign({}, rest);
49
- return (jsxs(Popover, Object.assign({ dataTestId: dataTestId && `${dataTestId}-popover`, placement: "bottom-start" }, popoverProps, { children: [jsx(PopoverTrigger, { 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 })] })) }), jsx(PopoverContent, { children: jsx(CustomMenuList, Object.assign({ withStickyHeader: withStickyHeader, dataTestId: dataTestId && `${dataTestId}-menulist` }, menuListProps, { children: children })) })] })));
50
- };
34
+ /**
35
+ * The Filter component is the base component used in the manager to filter data.
36
+ *
37
+ * - This component in generic and does not have any connection to the data.
38
+ * - The base props extends button props, and any button props such as prefix and suffix can be used.
39
+ * - Color and size has special default values in this component, but can be overridden if needed.
40
+ *
41
+ * To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
42
+ *
43
+ * @param {FilterProps} props - The props for the Filter component
44
+ * @returns {JSX.Element} Filter component
45
+ */
46
+ const Filter = (_a) => {
47
+ 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"]);
48
+ const buttonProps = Object.assign({}, rest);
49
+ return (jsxs(Popover, Object.assign({ dataTestId: dataTestId && `${dataTestId}-popover`, placement: "bottom-start" }, popoverProps, { children: [jsx(PopoverTrigger, { 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 })] })) }), jsx(PopoverContent, { children: jsx(CustomMenuList, Object.assign({ withStickyHeader: withStickyHeader, dataTestId: dataTestId && `${dataTestId}-menulist` }, menuListProps, { children: children })) })] })));
50
+ };
51
51
  const CustomButton = twx(Button) `
52
52
  ${({ $isActive }) => ($isActive ? tws `!border-primary-600` : "")}
53
- `;
53
+ `;
54
54
  const CustomMenuList = twx(MenuList) `
55
55
  overflow-x-hidden
56
56
  overflow-y-auto
57
57
  relative
58
- `;
58
+ `;
59
59
  const ActiveLabel = tw.span `
60
60
  text-primary-600
61
61
  `;
62
62
 
63
- /**
64
- * The FilterBody component is used to display the title of the filter and a reset button.
65
- * IT is intended for use in the Filter component.
66
- * The reset button will only be visible if the showReset prop is set to true.
67
- *
68
- * @param {FilterBodyProps} props - The props for the FilterBody component
69
- * @returns {JSX.Element} FilterBody component
70
- */
71
- const FilterBody = React.forwardRef((_a, ref) => {
72
- var { children, dataTestId, limitSize = false } = _a, rest = __rest(_a, ["children", "dataTestId", "limitSize"]);
73
- return (jsx(Root$1, Object.assign({ "$limitSize": limitSize, ref: ref }, rest, { "data-testid": dataTestId }, { children: children })));
74
- });
63
+ /**
64
+ * The FilterBody component is used to display the title of the filter and a reset button.
65
+ * IT is intended for use in the Filter component.
66
+ * The reset button will only be visible if the showReset prop is set to true.
67
+ *
68
+ * @param {FilterBodyProps} props - The props for the FilterBody component
69
+ * @returns {JSX.Element} FilterBody component
70
+ */
71
+ const FilterBody = React.forwardRef((_a, ref) => {
72
+ var { children, dataTestId, limitSize = false } = _a, rest = __rest(_a, ["children", "dataTestId", "limitSize"]);
73
+ return (jsx(Root$1, Object.assign({ "$limitSize": limitSize, ref: ref }, rest, { "data-testid": dataTestId, children: children })));
74
+ });
75
75
  const Root$1 = tw.div `
76
76
  grid
77
77
  gap-1
78
78
  p-1
79
79
  rounded
80
80
  w-full
81
- ${props => props.$limitSize
81
+ ${props => props.$limitSize
82
82
  ? tws `
83
83
  overflow-hidden
84
84
  max-h-80
85
85
  max-w-sm
86
86
  overflow-y-auto
87
- `
87
+ `
88
88
  : ""}
89
89
  `;
90
90
 
91
- /**
92
- * The FilterHeader component is used to display the title of the filter and a reset button.
93
- * IT is intended for use in the Filter component.
94
- * The reset button will only be visible if the showReset prop is set to true.
95
- *
96
- * @param {FilterHeaderProps} props - The props for the FilterHeader component
97
- * @returns {JSX.Element} FilterHeader component
98
- */
99
- const FilterHeader = (_a) => {
100
- var { title, resetLabel, showReset, dataTestId, onReset, loading, children } = _a, rest = __rest(_a, ["title", "resetLabel", "showReset", "dataTestId", "onReset", "loading", "children"]);
101
- return (jsxs(Root, Object.assign({}, rest, { "data-testid": dataTestId }, { children: [jsxs(HeadingContainer, { children: [jsx("h4", { children: title }), loading ? (jsx(Spinner, { size: "small" })) : (jsx(HiddenButton, Object.assign({ "$isVisible": Boolean(showReset), size: "small", variant: "transparent", color: "danger", onClick: onReset }, { children: resetLabel })))] }), children] })));
102
- };
91
+ /**
92
+ * The FilterHeader component is used to display the title of the filter and a reset button.
93
+ * IT is intended for use in the Filter component.
94
+ * The reset button will only be visible if the showReset prop is set to true.
95
+ *
96
+ * @param {FilterHeaderProps} props - The props for the FilterHeader component
97
+ * @returns {JSX.Element} FilterHeader component
98
+ */
99
+ const FilterHeader = (_a) => {
100
+ var { title, resetLabel, showReset, dataTestId, onReset, loading, children } = _a, rest = __rest(_a, ["title", "resetLabel", "showReset", "dataTestId", "onReset", "loading", "children"]);
101
+ return (jsxs(Root, Object.assign({}, rest, { "data-testid": dataTestId, children: [jsxs(HeadingContainer, { children: [jsx("h4", { children: title }), loading ? (jsx(Spinner, { size: "small" })) : (jsx(HiddenButton, { "$isVisible": Boolean(showReset), size: "small", variant: "transparent", color: "danger", onClick: onReset, children: resetLabel }))] }), children] })));
102
+ };
103
103
  const HeadingContainer = tw.div `
104
104
  flex
105
105
  items-center
@@ -109,44 +109,44 @@ const HeadingContainer = tw.div `
109
109
  text-sm
110
110
  text-slate-600
111
111
  uppercase
112
- `;
112
+ `;
113
113
  const HiddenButton = twx(Button) `
114
114
  ${props => (props.$isVisible ? tws `visible` : tws `invisible`)}
115
- `;
115
+ `;
116
116
  const Root = tw.div `
117
117
  grid
118
118
  gap-1
119
119
  p-1
120
120
  `;
121
121
 
122
- /**
123
- * The CheckBoxFilterItem component is the base component used in the manager to FilterItem data.
124
- * This component in generic and does not have any connection to the data.
125
- *
126
- * @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
127
- * @returns {JSX.Element} FilterItem component
128
- */
129
- const CheckBoxFilterItem = (_a) => {
130
- var { itemCount, className, prefix, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["itemCount", "className", "prefix", "dataTestId", "menuItemProps"]);
131
- const checkboxProps = Object.assign({}, rest);
132
- const checkboxRef = useRef(null);
133
- return (jsx(MenuItem, Object.assign({ onClick: e => {
134
- var _a;
135
- e.preventDefault();
136
- (_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
137
- }, 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" })) })));
122
+ /**
123
+ * The CheckBoxFilterItem component is the base component used in the manager to FilterItem data.
124
+ * This component in generic and does not have any connection to the data.
125
+ *
126
+ * @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
127
+ * @returns {JSX.Element} FilterItem component
128
+ */
129
+ const CheckBoxFilterItem = (_a) => {
130
+ var { itemCount, className, prefix, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["itemCount", "className", "prefix", "dataTestId", "menuItemProps"]);
131
+ const checkboxProps = Object.assign({}, rest);
132
+ const checkboxRef = useRef(null);
133
+ return (jsx(MenuItem, Object.assign({ onClick: e => {
134
+ var _a;
135
+ e.preventDefault();
136
+ (_a = checkboxRef.current) === null || _a === void 0 ? void 0 : _a.click();
137
+ }, 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" })) })));
138
138
  };
139
139
 
140
- /**
141
- * The RadioFilterItem component is the base component used in the manager to FilterItem data.
142
- * This component in generic and does not have any connection to the data.
143
- *
144
- * @param {RadioFilterItemProps} props - The props for the FilterItem component
145
- * @returns {JSX.Element} FilterItem component
146
- */
147
- const RadioFilterItem = (_a) => {
148
- var { value, label, itemCount, selected, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["value", "label", "itemCount", "selected", "dataTestId", "menuItemProps"]);
149
- return (jsx(MenuItem, Object.assign({ selected: selected, dataTestId: dataTestId, className: "flex justify-between cursor-default p-0 my-[2px]", suffix: jsx("small", Object.assign({ className: "pl-1 pr-3" }, { children: itemCount })) }, menuItemProps, { children: jsx(RadioItem, Object.assign({}, rest, { value: value, className: "flex items-center w-full py-2 pl-2", dataTestId: dataTestId && `${dataTestId}-radio`, label: jsx(Text, Object.assign({ className: "cursor-pointer", type: "span" }, { children: label })) })) })));
140
+ /**
141
+ * The RadioFilterItem component is the base component used in the manager to FilterItem data.
142
+ * This component in generic and does not have any connection to the data.
143
+ *
144
+ * @param {RadioFilterItemProps} props - The props for the FilterItem component
145
+ * @returns {JSX.Element} FilterItem component
146
+ */
147
+ const RadioFilterItem = (_a) => {
148
+ var { value, label, itemCount, selected, dataTestId, menuItemProps } = _a, rest = __rest(_a, ["value", "label", "itemCount", "selected", "dataTestId", "menuItemProps"]);
149
+ return (jsx(MenuItem, Object.assign({ selected: selected, dataTestId: dataTestId, className: "flex justify-between cursor-default p-0 my-[2px]", suffix: jsx("small", { className: "pl-1 pr-3", children: itemCount }) }, menuItemProps, { children: jsx(RadioItem, Object.assign({}, rest, { value: value, className: "flex items-center w-full py-2 pl-2", dataTestId: dataTestId && `${dataTestId}-radio`, label: jsx(Text, { className: "cursor-pointer", type: "span", children: label }) })) })));
150
150
  };
151
151
 
152
152
  export { CheckBoxFilterItem, Filter, FilterBody, FilterHeader, RadioFilterItem };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@trackunit/react-filter-components",
3
- "version": "0.0.124",
3
+ "version": "0.0.133",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
7
  "node": ">=16.x"
8
8
  },
9
9
  "dependencies": {
10
- "@trackunit/react-components": "0.1.117",
11
- "@trackunit/react-form-components": "0.0.67",
12
- "@trackunit/tailwind-styled-components": "0.0.57",
10
+ "@trackunit/react-components": "0.1.124",
11
+ "@trackunit/react-form-components": "0.0.76",
12
+ "@trackunit/tailwind-styled-components": "0.0.58",
13
13
  "react": "18.2.0"
14
14
  },
15
15
  "module": "./index.js",
@@ -1,54 +1,54 @@
1
- /// <reference types="react" />
2
- import { ButtonProps, MenuListProps, PopoverProps } from "@trackunit/react-components";
3
- export interface FilterProps extends ButtonProps {
4
- /**
5
- * The title/name of the filter.
6
- */
7
- title: string;
8
- /**
9
- * Used to indicate if the user has any active selection in the filter.
10
- */
11
- isActive?: boolean;
12
- /**
13
- * The label that will be displayed when the filter is active.
14
- */
15
- activeLabel?: string;
16
- /**
17
- * When enabled the menu list padding will be removed, and a grid will be applied to keep the first column "sticky".
18
- * This intended to be used withe the FilterHeader component.
19
- *
20
- * @default false
21
- */
22
- withStickyHeader?: boolean;
23
- /**
24
- * Child elements will be rendered inside the menu list and are only visible when the popover is open.
25
- */
26
- children: MenuListProps["children"];
27
- /**
28
- * Can be used to override the pops of the popover.
29
- * The render prop cannot be overridden.
30
- */
31
- popoverProps?: Omit<PopoverProps, "render">;
32
- /**
33
- * Can be used to override the pops of the MenuList.
34
- * The render prop cannot be overridden.
35
- */
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;
41
- }
42
- /**
43
- * The Filter component is the base component used in the manager to filter data.
44
- *
45
- * - This component in generic and does not have any connection to the data.
46
- * - The base props extends button props, and any button props such as prefix and suffix can be used.
47
- * - Color and size has special default values in this component, but can be overridden if needed.
48
- *
49
- * To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
50
- *
51
- * @param {FilterProps} props - The props for the Filter component
52
- * @returns {JSX.Element} Filter component
53
- */
54
- export declare const Filter: ({ title, children, popoverProps, isActive, activeLabel, menuListProps, className, dataTestId, withStickyHeader, readOnly, ...rest }: FilterProps) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import { ButtonProps, MenuListProps, PopoverProps } from "@trackunit/react-components";
3
+ export interface FilterProps extends ButtonProps {
4
+ /**
5
+ * The title/name of the filter.
6
+ */
7
+ title: string;
8
+ /**
9
+ * Used to indicate if the user has any active selection in the filter.
10
+ */
11
+ isActive?: boolean;
12
+ /**
13
+ * The label that will be displayed when the filter is active.
14
+ */
15
+ activeLabel?: string;
16
+ /**
17
+ * When enabled the menu list padding will be removed, and a grid will be applied to keep the first column "sticky".
18
+ * This intended to be used withe the FilterHeader component.
19
+ *
20
+ * @default false
21
+ */
22
+ withStickyHeader?: boolean;
23
+ /**
24
+ * Child elements will be rendered inside the menu list and are only visible when the popover is open.
25
+ */
26
+ children: MenuListProps["children"];
27
+ /**
28
+ * Can be used to override the pops of the popover.
29
+ * The render prop cannot be overridden.
30
+ */
31
+ popoverProps?: Omit<PopoverProps, "render">;
32
+ /**
33
+ * Can be used to override the pops of the MenuList.
34
+ * The render prop cannot be overridden.
35
+ */
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;
41
+ }
42
+ /**
43
+ * The Filter component is the base component used in the manager to filter data.
44
+ *
45
+ * - This component in generic and does not have any connection to the data.
46
+ * - The base props extends button props, and any button props such as prefix and suffix can be used.
47
+ * - Color and size has special default values in this component, but can be overridden if needed.
48
+ *
49
+ * To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
50
+ *
51
+ * @param {FilterProps} props - The props for the Filter component
52
+ * @returns {JSX.Element} Filter component
53
+ */
54
+ export declare const Filter: ({ title, children, popoverProps, isActive, activeLabel, menuListProps, className, dataTestId, withStickyHeader, readOnly, ...rest }: FilterProps) => JSX.Element;
@@ -1,19 +1,19 @@
1
- import { CommonProps } from "@trackunit/react-components";
2
- import React from "react";
3
- export interface FilterBodyProps extends CommonProps {
4
- /**
5
- * Children to render in the body of the filter.
6
- * This is intended for FilterItems.
7
- */
8
- children?: React.ReactNode;
9
- limitSize?: boolean;
10
- }
11
- /**
12
- * The FilterBody component is used to display the title of the filter and a reset button.
13
- * IT is intended for use in the Filter component.
14
- * The reset button will only be visible if the showReset prop is set to true.
15
- *
16
- * @param {FilterBodyProps} props - The props for the FilterBody component
17
- * @returns {JSX.Element} FilterBody component
18
- */
19
- export declare const FilterBody: React.ForwardRefExoticComponent<FilterBodyProps & React.RefAttributes<HTMLDivElement>>;
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import React from "react";
3
+ export interface FilterBodyProps extends CommonProps {
4
+ /**
5
+ * Children to render in the body of the filter.
6
+ * This is intended for FilterItems.
7
+ */
8
+ children?: React.ReactNode;
9
+ limitSize?: boolean;
10
+ }
11
+ /**
12
+ * The FilterBody component is used to display the title of the filter and a reset button.
13
+ * IT is intended for use in the Filter component.
14
+ * The reset button will only be visible if the showReset prop is set to true.
15
+ *
16
+ * @param {FilterBodyProps} props - The props for the FilterBody component
17
+ * @returns {JSX.Element} FilterBody component
18
+ */
19
+ export declare const FilterBody: React.ForwardRefExoticComponent<FilterBodyProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,35 +1,35 @@
1
- /// <reference types="react" />
2
- import { CommonProps } from "@trackunit/react-components";
3
- export interface FilterHeaderProps extends CommonProps {
4
- /**
5
- * The title of the filter will be displayed in the header.
6
- */
7
- title: string;
8
- /**
9
- * Used to indicate if the user has any active selection in the filter.
10
- */
11
- showReset?: boolean;
12
- /**
13
- * The Label to display on the reset button.
14
- */
15
- resetLabel?: string;
16
- loading?: boolean;
17
- /**
18
- * The callback that will be called when the user clicks the reset button.
19
- */
20
- onReset?: () => void;
21
- /**
22
- * Optional elements to render blow the title and reset button.
23
- * This is intended for use with the search component.
24
- */
25
- children?: React.ReactNode;
26
- }
27
- /**
28
- * The FilterHeader component is used to display the title of the filter and a reset button.
29
- * IT is intended for use in the Filter component.
30
- * The reset button will only be visible if the showReset prop is set to true.
31
- *
32
- * @param {FilterHeaderProps} props - The props for the FilterHeader component
33
- * @returns {JSX.Element} FilterHeader component
34
- */
35
- export declare const FilterHeader: ({ title, resetLabel, showReset, dataTestId, onReset, loading, children, ...rest }: FilterHeaderProps) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "@trackunit/react-components";
3
+ export interface FilterHeaderProps extends CommonProps {
4
+ /**
5
+ * The title of the filter will be displayed in the header.
6
+ */
7
+ title: string;
8
+ /**
9
+ * Used to indicate if the user has any active selection in the filter.
10
+ */
11
+ showReset?: boolean;
12
+ /**
13
+ * The Label to display on the reset button.
14
+ */
15
+ resetLabel?: string;
16
+ loading?: boolean;
17
+ /**
18
+ * The callback that will be called when the user clicks the reset button.
19
+ */
20
+ onReset?: () => void;
21
+ /**
22
+ * Optional elements to render blow the title and reset button.
23
+ * This is intended for use with the search component.
24
+ */
25
+ children?: React.ReactNode;
26
+ }
27
+ /**
28
+ * The FilterHeader component is used to display the title of the filter and a reset button.
29
+ * IT is intended for use in the Filter component.
30
+ * The reset button will only be visible if the showReset prop is set to true.
31
+ *
32
+ * @param {FilterHeaderProps} props - The props for the FilterHeader component
33
+ * @returns {JSX.Element} FilterHeader component
34
+ */
35
+ export declare const FilterHeader: ({ title, resetLabel, showReset, dataTestId, onReset, loading, children, ...rest }: FilterHeaderProps) => JSX.Element;
@@ -1,10 +1,10 @@
1
- /// <reference types="react" />
2
- import { CheckBoxFilterItemProps } from "../types";
3
- /**
4
- * The CheckBoxFilterItem component is the base component used in the manager to FilterItem data.
5
- * This component in generic and does not have any connection to the data.
6
- *
7
- * @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
8
- * @returns {JSX.Element} FilterItem component
9
- */
10
- export declare const CheckBoxFilterItem: ({ itemCount, className, prefix, dataTestId, menuItemProps, ...rest }: CheckBoxFilterItemProps) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import { CheckBoxFilterItemProps } from "../types";
3
+ /**
4
+ * The CheckBoxFilterItem component is the base component used in the manager to FilterItem data.
5
+ * This component in generic and does not have any connection to the data.
6
+ *
7
+ * @param {CheckBoxFilterItemProps} props - The props for the FilterItem component
8
+ * @returns {JSX.Element} FilterItem component
9
+ */
10
+ export declare const CheckBoxFilterItem: ({ itemCount, className, prefix, dataTestId, menuItemProps, ...rest }: CheckBoxFilterItemProps) => JSX.Element;
@@ -1,10 +1,10 @@
1
- /// <reference types="react" />
2
- import { RadioFilterItemProps } from "../types";
3
- /**
4
- * The RadioFilterItem component is the base component used in the manager to FilterItem data.
5
- * This component in generic and does not have any connection to the data.
6
- *
7
- * @param {RadioFilterItemProps} props - The props for the FilterItem component
8
- * @returns {JSX.Element} FilterItem component
9
- */
10
- export declare const RadioFilterItem: ({ value, label, itemCount, selected, dataTestId, menuItemProps, ...rest }: RadioFilterItemProps) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import { RadioFilterItemProps } from "../types";
3
+ /**
4
+ * The RadioFilterItem component is the base component used in the manager to FilterItem data.
5
+ * This component in generic and does not have any connection to the data.
6
+ *
7
+ * @param {RadioFilterItemProps} props - The props for the FilterItem component
8
+ * @returns {JSX.Element} FilterItem component
9
+ */
10
+ export declare const RadioFilterItem: ({ value, label, itemCount, selected, dataTestId, menuItemProps, ...rest }: RadioFilterItemProps) => JSX.Element;
@@ -1,23 +1,23 @@
1
- import { MenuItemProps } from "@trackunit/react-components";
2
- import { CheckboxProps, RadioItemProps } from "@trackunit/react-form-components";
3
- export interface CheckBoxFilterItemProps extends Omit<CheckboxProps, "prefix" | "suffix">, BaseFilterItemProps {
4
- }
5
- export interface RadioFilterItemProps<V extends string | number = string> extends RadioItemProps<V>, BaseFilterItemProps {
6
- /**
7
- * An boolean flag to set checkbox to checked state
8
- */
9
- selected?: boolean;
10
- }
11
- interface BaseFilterItemProps {
12
- /**
13
- * The number of results for the filter item.
14
- * This displays the number next to the label.
15
- */
16
- itemCount?: number;
17
- /**
18
- * Properties to be passed to the MenuItem component.
19
- */
20
- menuItemProps?: MenuItemProps;
21
- prefix?: MenuItemProps["prefix"];
22
- }
23
- export {};
1
+ import { MenuItemProps } from "@trackunit/react-components";
2
+ import { CheckboxProps, RadioItemProps } from "@trackunit/react-form-components";
3
+ export interface CheckBoxFilterItemProps extends Omit<CheckboxProps, "prefix" | "suffix">, BaseFilterItemProps {
4
+ }
5
+ export interface RadioFilterItemProps<V extends string | number = string> extends RadioItemProps<V>, BaseFilterItemProps {
6
+ /**
7
+ * An boolean flag to set checkbox to checked state
8
+ */
9
+ selected?: boolean;
10
+ }
11
+ interface BaseFilterItemProps {
12
+ /**
13
+ * The number of results for the filter item.
14
+ * This displays the number next to the label.
15
+ */
16
+ itemCount?: number;
17
+ /**
18
+ * Properties to be passed to the MenuItem component.
19
+ */
20
+ menuItemProps?: MenuItemProps;
21
+ prefix?: MenuItemProps["prefix"];
22
+ }
23
+ export {};
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from "./Filter/Filter";
2
- export * from "./FilterBody/FilterBody";
3
- export * from "./FilterHeader/FilterHeader";
4
- export * from "./FilterItem/CheckBoxFilter/CheckBoxFilterItem";
5
- export * from "./FilterItem/RadioFilter/RadioFilterItem";
1
+ export * from "./Filter/Filter";
2
+ export * from "./FilterBody/FilterBody";
3
+ export * from "./FilterHeader/FilterHeader";
4
+ export * from "./FilterItem/CheckBoxFilter/CheckBoxFilterItem";
5
+ export * from "./FilterItem/RadioFilter/RadioFilterItem";