@trackunit/react-filter-components 2.6.34-alpha-7557f71cc7a.0 → 2.6.35
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 +9 -3
- package/index.esm.js +9 -3
- package/migrations/entry.js.map +1 -0
- package/package.json +5 -5
- package/src/Filter/Filter.d.ts +4 -1
package/index.cjs.js
CHANGED
|
@@ -23,6 +23,9 @@ const cvaFilterCustomButton = cssClassVarianceUtilities.cvaMerge(["justify-norma
|
|
|
23
23
|
*
|
|
24
24
|
* - This component in generic and does not have any connection to the data.
|
|
25
25
|
* - The base props extends button props, and any button props such as prefix and suffix can be used.
|
|
26
|
+
* `prefix` is honoured by both visual styles; `suffix` only by `"button"`, because the
|
|
27
|
+
* `"list-item"` style composes its own suffix from the active-filter badge and the submenu
|
|
28
|
+
* chevron, and a caller's suffix would have to replace those rather than sit beside them.
|
|
26
29
|
* - Color and size has special default values in this component, but can be overridden if needed.
|
|
27
30
|
*
|
|
28
31
|
* To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
|
|
@@ -30,16 +33,19 @@ const cvaFilterCustomButton = cssClassVarianceUtilities.cvaMerge(["justify-norma
|
|
|
30
33
|
* @param {FilterProps} props - The props for the Filter component
|
|
31
34
|
* @returns {ReactElement} Filter component
|
|
32
35
|
*/
|
|
33
|
-
const Filter = ({ title = "", asIcon = undefined, children, popoverProps, isActive = false, activeLabel, activeOptionsCount, menuListProps, className, "data-testid": dataTestId, withStickyHeader = false, readOnly = false, visualStyle = "button", size = "small", listItemStopPropagation = true, }) => {
|
|
36
|
+
const Filter = ({ title = "", asIcon = undefined, children, popoverProps, isActive = false, activeLabel, activeOptionsCount, menuListProps, className, "data-testid": dataTestId, withStickyHeader = false, readOnly = false, visualStyle = "button", size = "small", listItemStopPropagation = true, prefix, suffix, }) => {
|
|
34
37
|
const renderButton = () => {
|
|
35
38
|
if (asIcon) {
|
|
36
39
|
return (jsxRuntime.jsx(reactComponents.IconButton, { className: className, "data-testid": dataTestId, disabled: readOnly, icon: jsxRuntime.jsx(reactComponents.Icon, { name: asIcon, size: "small" }), size: size, title: title, variant: isActive ? "ghost" : "ghost-neutral" }));
|
|
37
40
|
}
|
|
38
|
-
return (jsxRuntime.jsxs(reactComponents.Button, { className: cvaFilterCustomButton({ isActive, className }), "data-testid": dataTestId, disabled: readOnly, size: size, variant: "secondary", children: [title, isActive ? (jsxRuntime.jsx("div", { className: "grid overflow-hidden text-ellipsis whitespace-nowrap", children: jsxRuntime.jsx("span", { className: "text-primary-600 truncate", children: activeLabel }) })) : null] }));
|
|
41
|
+
return (jsxRuntime.jsxs(reactComponents.Button, { className: cvaFilterCustomButton({ isActive, className }), "data-testid": dataTestId, disabled: readOnly, prefix: prefix, size: size, suffix: suffix, variant: "secondary", children: [title, isActive ? (jsxRuntime.jsx("div", { className: "grid overflow-hidden text-ellipsis whitespace-nowrap", children: jsxRuntime.jsx("span", { className: "text-primary-600 truncate", children: activeLabel }) })) : null] }));
|
|
39
42
|
};
|
|
40
43
|
const renderSubmenuContent = () => children !== undefined ? (jsxRuntime.jsx(reactComponents.MenuContent, { className: cvaMenuShellOverrides({ withStickyHeader }), "data-testid": dataTestId ? dataTestId : undefined, listClassName: cvaMenuListOverrides({ withStickyHeader }), ...menuListProps, children: children })) : (jsxRuntime.jsx(jsxRuntime.Fragment, {}));
|
|
41
44
|
if (visualStyle === "list-item") {
|
|
42
|
-
return (jsxRuntime.jsx(reactComponents.MenuItem, { className: className, "data-testid": dataTestId, disabled: readOnly, label: title,
|
|
45
|
+
return (jsxRuntime.jsx(reactComponents.MenuItem, { className: className, "data-testid": dataTestId, disabled: readOnly, label: title,
|
|
46
|
+
// `MenuItem` has its own prefix slot before the label, so a caller's leading icon composes
|
|
47
|
+
// here as it does on the button. Its suffix slot is already spoken for, just below.
|
|
48
|
+
prefix: prefix, stopPropagation: listItemStopPropagation, submenu: children !== undefined ? renderSubmenuContent() : undefined,
|
|
43
49
|
// See the sizing comment on the button variant's `Popover` below -- same reasoning applies to the
|
|
44
50
|
// submenu Popover that `MenuItem` renders internally for this visual style.
|
|
45
51
|
submenuSizing: popoverProps?.sizing ?? { minWidth: 280 }, suffix: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isActive && activeLabel && activeOptionsCount === undefined ? (jsxRuntime.jsx(reactComponents.Badge, { className: "mx-2", compact: true })) : (jsxRuntime.jsx("div", { className: "flex min-w-[30px] shrink-0 items-center justify-center", children: isActive && activeLabel && activeOptionsCount !== undefined ? (jsxRuntime.jsx(reactComponents.Badge, { count: activeOptionsCount, size: "condensed" })) : null })), readOnly ? null : jsxRuntime.jsx(reactComponents.Icon, { ariaHidden: true, color: "neutral", name: "ChevronRight", size: "small" })] }), children: jsxRuntime.jsx("span", { className: "flex-grow truncate", children: title }) }));
|
package/index.esm.js
CHANGED
|
@@ -21,6 +21,9 @@ const cvaFilterCustomButton = cvaMerge(["justify-normal"], {
|
|
|
21
21
|
*
|
|
22
22
|
* - This component in generic and does not have any connection to the data.
|
|
23
23
|
* - The base props extends button props, and any button props such as prefix and suffix can be used.
|
|
24
|
+
* `prefix` is honoured by both visual styles; `suffix` only by `"button"`, because the
|
|
25
|
+
* `"list-item"` style composes its own suffix from the active-filter badge and the submenu
|
|
26
|
+
* chevron, and a caller's suffix would have to replace those rather than sit beside them.
|
|
24
27
|
* - Color and size has special default values in this component, but can be overridden if needed.
|
|
25
28
|
*
|
|
26
29
|
* To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
|
|
@@ -28,16 +31,19 @@ const cvaFilterCustomButton = cvaMerge(["justify-normal"], {
|
|
|
28
31
|
* @param {FilterProps} props - The props for the Filter component
|
|
29
32
|
* @returns {ReactElement} Filter component
|
|
30
33
|
*/
|
|
31
|
-
const Filter = ({ title = "", asIcon = undefined, children, popoverProps, isActive = false, activeLabel, activeOptionsCount, menuListProps, className, "data-testid": dataTestId, withStickyHeader = false, readOnly = false, visualStyle = "button", size = "small", listItemStopPropagation = true, }) => {
|
|
34
|
+
const Filter = ({ title = "", asIcon = undefined, children, popoverProps, isActive = false, activeLabel, activeOptionsCount, menuListProps, className, "data-testid": dataTestId, withStickyHeader = false, readOnly = false, visualStyle = "button", size = "small", listItemStopPropagation = true, prefix, suffix, }) => {
|
|
32
35
|
const renderButton = () => {
|
|
33
36
|
if (asIcon) {
|
|
34
37
|
return (jsx(IconButton, { className: className, "data-testid": dataTestId, disabled: readOnly, icon: jsx(Icon, { name: asIcon, size: "small" }), size: size, title: title, variant: isActive ? "ghost" : "ghost-neutral" }));
|
|
35
38
|
}
|
|
36
|
-
return (jsxs(Button, { className: cvaFilterCustomButton({ isActive, className }), "data-testid": dataTestId, disabled: readOnly, size: size, variant: "secondary", children: [title, isActive ? (jsx("div", { className: "grid overflow-hidden text-ellipsis whitespace-nowrap", children: jsx("span", { className: "text-primary-600 truncate", children: activeLabel }) })) : null] }));
|
|
39
|
+
return (jsxs(Button, { className: cvaFilterCustomButton({ isActive, className }), "data-testid": dataTestId, disabled: readOnly, prefix: prefix, size: size, suffix: suffix, variant: "secondary", children: [title, isActive ? (jsx("div", { className: "grid overflow-hidden text-ellipsis whitespace-nowrap", children: jsx("span", { className: "text-primary-600 truncate", children: activeLabel }) })) : null] }));
|
|
37
40
|
};
|
|
38
41
|
const renderSubmenuContent = () => children !== undefined ? (jsx(MenuContent, { className: cvaMenuShellOverrides({ withStickyHeader }), "data-testid": dataTestId ? dataTestId : undefined, listClassName: cvaMenuListOverrides({ withStickyHeader }), ...menuListProps, children: children })) : (jsx(Fragment, {}));
|
|
39
42
|
if (visualStyle === "list-item") {
|
|
40
|
-
return (jsx(MenuItem, { className: className, "data-testid": dataTestId, disabled: readOnly, label: title,
|
|
43
|
+
return (jsx(MenuItem, { className: className, "data-testid": dataTestId, disabled: readOnly, label: title,
|
|
44
|
+
// `MenuItem` has its own prefix slot before the label, so a caller's leading icon composes
|
|
45
|
+
// here as it does on the button. Its suffix slot is already spoken for, just below.
|
|
46
|
+
prefix: prefix, stopPropagation: listItemStopPropagation, submenu: children !== undefined ? renderSubmenuContent() : undefined,
|
|
41
47
|
// See the sizing comment on the button variant's `Popover` below -- same reasoning applies to the
|
|
42
48
|
// submenu Popover that `MenuItem` renders internally for this visual style.
|
|
43
49
|
submenuSizing: popoverProps?.sizing ?? { minWidth: 280 }, suffix: jsxs(Fragment, { children: [isActive && activeLabel && activeOptionsCount === undefined ? (jsx(Badge, { className: "mx-2", compact: true })) : (jsx("div", { className: "flex min-w-[30px] shrink-0 items-center justify-center", children: isActive && activeLabel && activeOptionsCount !== undefined ? (jsx(Badge, { count: activeOptionsCount, size: "condensed" })) : null })), readOnly ? null : jsx(Icon, { ariaHidden: true, color: "neutral", name: "ChevronRight", size: "small" })] }), children: jsx("span", { className: "flex-grow truncate", children: title }) }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/filter-components/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-filter-components",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.35",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"tailwind-merge": "^2.0.0",
|
|
11
|
-
"@trackunit/ui-icons": "1.14.22
|
|
12
|
-
"@trackunit/css-class-variance-utilities": "1.14.23
|
|
13
|
-
"@trackunit/react-components": "2.10.
|
|
14
|
-
"@trackunit/react-form-components": "2.6.
|
|
11
|
+
"@trackunit/ui-icons": "1.14.22",
|
|
12
|
+
"@trackunit/css-class-variance-utilities": "1.14.23",
|
|
13
|
+
"@trackunit/react-components": "2.10.28",
|
|
14
|
+
"@trackunit/react-form-components": "2.6.35"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@tanstack/react-router": "^1.114.29",
|
package/src/Filter/Filter.d.ts
CHANGED
|
@@ -69,6 +69,9 @@ export interface FilterProps extends ButtonProps {
|
|
|
69
69
|
*
|
|
70
70
|
* - This component in generic and does not have any connection to the data.
|
|
71
71
|
* - The base props extends button props, and any button props such as prefix and suffix can be used.
|
|
72
|
+
* `prefix` is honoured by both visual styles; `suffix` only by `"button"`, because the
|
|
73
|
+
* `"list-item"` style composes its own suffix from the active-filter badge and the submenu
|
|
74
|
+
* chevron, and a caller's suffix would have to replace those rather than sit beside them.
|
|
72
75
|
* - Color and size has special default values in this component, but can be overridden if needed.
|
|
73
76
|
*
|
|
74
77
|
* To add items to the popover list use the children prop, this is where you build all the filter items and connected logic.
|
|
@@ -76,4 +79,4 @@ export interface FilterProps extends ButtonProps {
|
|
|
76
79
|
* @param {FilterProps} props - The props for the Filter component
|
|
77
80
|
* @returns {ReactElement} Filter component
|
|
78
81
|
*/
|
|
79
|
-
export declare const Filter: ({ title, asIcon, children, popoverProps, isActive, activeLabel, activeOptionsCount, menuListProps, className, "data-testid": dataTestId, withStickyHeader, readOnly, visualStyle, size, listItemStopPropagation, }: FilterProps) => ReactElement;
|
|
82
|
+
export declare const Filter: ({ title, asIcon, children, popoverProps, isActive, activeLabel, activeOptionsCount, menuListProps, className, "data-testid": dataTestId, withStickyHeader, readOnly, visualStyle, size, listItemStopPropagation, prefix, suffix, }: FilterProps) => ReactElement;
|