@hitachivantara/uikit-react-core 5.1.3 → 5.3.0
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/dist/cjs/components/Button/Button.cjs +6 -0
- package/dist/cjs/components/Button/Button.cjs.map +1 -1
- package/dist/cjs/components/Button/Button.styles.cjs +17 -9
- package/dist/cjs/components/Button/Button.styles.cjs.map +1 -1
- package/dist/cjs/components/Button/buttonClasses.cjs +1 -1
- package/dist/cjs/components/Button/buttonClasses.cjs.map +1 -1
- package/dist/cjs/components/Calendar/SingleCalendar/SingleCalendar.styles.cjs +4 -4
- package/dist/cjs/components/Calendar/SingleCalendar/SingleCalendar.styles.cjs.map +1 -1
- package/dist/cjs/components/Card/Card.styles.cjs.map +1 -1
- package/dist/cjs/components/Card/Content/Content.styles.cjs.map +1 -1
- package/dist/cjs/components/Card/Header/Header.styles.cjs.map +1 -1
- package/dist/cjs/components/Card/Media/Media.styles.cjs.map +1 -1
- package/dist/cjs/components/Controls/RightControl/RightControl.cjs +3 -3
- package/dist/cjs/components/Controls/RightControl/RightControl.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs +347 -0
- package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -0
- package/dist/cjs/components/DatePicker/DatePicker.styles.cjs +78 -0
- package/dist/cjs/components/DatePicker/DatePicker.styles.cjs.map +1 -0
- package/dist/cjs/components/DatePicker/datePickerClasses.cjs +8 -0
- package/dist/cjs/components/DatePicker/datePickerClasses.cjs.map +1 -0
- package/dist/cjs/components/DatePicker/useVisibleDate.cjs +193 -0
- package/dist/cjs/components/DatePicker/useVisibleDate.cjs.map +1 -0
- package/dist/cjs/components/DatePicker/utils.cjs +32 -0
- package/dist/cjs/components/DatePicker/utils.cjs.map +1 -0
- package/dist/cjs/components/Dialog/Dialog.cjs +2 -6
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.styles.cjs +32 -31
- package/dist/cjs/components/Dialog/Dialog.styles.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/Counter/Counter.cjs +51 -0
- package/dist/cjs/components/FilterGroup/Counter/Counter.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/Counter/Counter.styles.cjs +17 -0
- package/dist/cjs/components/FilterGroup/Counter/Counter.styles.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.cjs +168 -0
- package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.styles.cjs +60 -0
- package/dist/cjs/components/FilterGroup/FilterContent/FilterContent.styles.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/FilterContent/filterContentClasses.cjs +8 -0
- package/dist/cjs/components/FilterGroup/FilterContent/filterContentClasses.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/FilterGroup.cjs +116 -0
- package/dist/cjs/components/FilterGroup/FilterGroup.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/FilterGroup.styles.cjs +14 -0
- package/dist/cjs/components/FilterGroup/FilterGroup.styles.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/FilterGroupContext.cjs +69 -0
- package/dist/cjs/components/FilterGroup/FilterGroupContext.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/LeftPanel/LeftPanel.cjs +52 -0
- package/dist/cjs/components/FilterGroup/LeftPanel/LeftPanel.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/LeftPanel/LeftPanel.styles.cjs +10 -0
- package/dist/cjs/components/FilterGroup/LeftPanel/LeftPanel.styles.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.cjs +135 -0
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.styles.cjs +34 -0
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.styles.cjs.map +1 -0
- package/dist/cjs/components/FilterGroup/filterGroupClasses.cjs +8 -0
- package/dist/cjs/components/FilterGroup/filterGroupClasses.cjs.map +1 -0
- package/dist/cjs/components/MultiButton/MultiButton.styles.cjs +22 -7
- package/dist/cjs/components/MultiButton/MultiButton.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Actions/Action.styles.cjs +2 -5
- package/dist/cjs/components/VerticalNavigation/Actions/Action.styles.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.styles.cjs +4 -7
- package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.styles.cjs.map +1 -1
- package/dist/cjs/index.cjs +8 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/utils/useSavedState.cjs +19 -0
- package/dist/cjs/utils/useSavedState.cjs.map +1 -0
- package/dist/esm/components/Button/Button.js +6 -0
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Button/Button.styles.js +17 -9
- package/dist/esm/components/Button/Button.styles.js.map +1 -1
- package/dist/esm/components/Button/buttonClasses.js +1 -1
- package/dist/esm/components/Button/buttonClasses.js.map +1 -1
- package/dist/esm/components/Calendar/SingleCalendar/SingleCalendar.styles.js +4 -4
- package/dist/esm/components/Calendar/SingleCalendar/SingleCalendar.styles.js.map +1 -1
- package/dist/esm/components/Card/Card.styles.js.map +1 -1
- package/dist/esm/components/Card/Content/Content.styles.js.map +1 -1
- package/dist/esm/components/Card/Header/Header.styles.js.map +1 -1
- package/dist/esm/components/Card/Media/Media.styles.js.map +1 -1
- package/dist/esm/components/Controls/RightControl/RightControl.js +4 -4
- package/dist/esm/components/Controls/RightControl/RightControl.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +345 -0
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/esm/components/DatePicker/DatePicker.styles.js +78 -0
- package/dist/esm/components/DatePicker/DatePicker.styles.js.map +1 -0
- package/dist/esm/components/DatePicker/datePickerClasses.js +8 -0
- package/dist/esm/components/DatePicker/datePickerClasses.js.map +1 -0
- package/dist/esm/components/DatePicker/useVisibleDate.js +193 -0
- package/dist/esm/components/DatePicker/useVisibleDate.js.map +1 -0
- package/dist/esm/components/DatePicker/utils.js +32 -0
- package/dist/esm/components/DatePicker/utils.js.map +1 -0
- package/dist/esm/components/Dialog/Dialog.js +3 -7
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.styles.js +33 -32
- package/dist/esm/components/Dialog/Dialog.styles.js.map +1 -1
- package/dist/esm/components/FilterGroup/Counter/Counter.js +51 -0
- package/dist/esm/components/FilterGroup/Counter/Counter.js.map +1 -0
- package/dist/esm/components/FilterGroup/Counter/Counter.styles.js +17 -0
- package/dist/esm/components/FilterGroup/Counter/Counter.styles.js.map +1 -0
- package/dist/esm/components/FilterGroup/FilterContent/FilterContent.js +168 -0
- package/dist/esm/components/FilterGroup/FilterContent/FilterContent.js.map +1 -0
- package/dist/esm/components/FilterGroup/FilterContent/FilterContent.styles.js +60 -0
- package/dist/esm/components/FilterGroup/FilterContent/FilterContent.styles.js.map +1 -0
- package/dist/esm/components/FilterGroup/FilterContent/filterContentClasses.js +8 -0
- package/dist/esm/components/FilterGroup/FilterContent/filterContentClasses.js.map +1 -0
- package/dist/esm/components/FilterGroup/FilterGroup.js +116 -0
- package/dist/esm/components/FilterGroup/FilterGroup.js.map +1 -0
- package/dist/esm/components/FilterGroup/FilterGroup.styles.js +14 -0
- package/dist/esm/components/FilterGroup/FilterGroup.styles.js.map +1 -0
- package/dist/esm/components/FilterGroup/FilterGroupContext.js +67 -0
- package/dist/esm/components/FilterGroup/FilterGroupContext.js.map +1 -0
- package/dist/esm/components/FilterGroup/LeftPanel/LeftPanel.js +52 -0
- package/dist/esm/components/FilterGroup/LeftPanel/LeftPanel.js.map +1 -0
- package/dist/esm/components/FilterGroup/LeftPanel/LeftPanel.styles.js +10 -0
- package/dist/esm/components/FilterGroup/LeftPanel/LeftPanel.styles.js.map +1 -0
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.js +133 -0
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.js.map +1 -0
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.styles.js +34 -0
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.styles.js.map +1 -0
- package/dist/esm/components/FilterGroup/filterGroupClasses.js +8 -0
- package/dist/esm/components/FilterGroup/filterGroupClasses.js.map +1 -0
- package/dist/esm/components/MultiButton/MultiButton.styles.js +22 -7
- package/dist/esm/components/MultiButton/MultiButton.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Actions/Action.styles.js +2 -5
- package/dist/esm/components/VerticalNavigation/Actions/Action.styles.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.styles.js +4 -7
- package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.styles.js.map +1 -1
- package/dist/esm/index.js +26 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/useSavedState.js +19 -0
- package/dist/esm/utils/useSavedState.js.map +1 -0
- package/dist/types/index.d.ts +330 -0
- package/package.json +5 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { HvFilterGroupContext } from "../FilterGroupContext.js";
|
|
3
|
+
import { styles } from "./Counter.styles.js";
|
|
4
|
+
import { ClassNames } from "@emotion/react";
|
|
5
|
+
import { clsx } from "clsx";
|
|
6
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
7
|
+
const getExistingFiltersById = (idx, filterValues, filterOptions) => {
|
|
8
|
+
var _a;
|
|
9
|
+
let total = 0;
|
|
10
|
+
(_a = filterValues[idx]) == null ? void 0 : _a.forEach((fv) => {
|
|
11
|
+
var _a2;
|
|
12
|
+
if ((_a2 = filterOptions[idx]) == null ? void 0 : _a2.data.find((f) => f.id === fv)) {
|
|
13
|
+
total += 1;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return total;
|
|
17
|
+
};
|
|
18
|
+
const HvFilterGroupCounter = ({
|
|
19
|
+
className,
|
|
20
|
+
id
|
|
21
|
+
}) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const {
|
|
24
|
+
filterOptions,
|
|
25
|
+
filterValues = [],
|
|
26
|
+
appliedFilters = []
|
|
27
|
+
} = useContext(HvFilterGroupContext);
|
|
28
|
+
const options = id && filterOptions.find((option) => option.id === id) ? [filterOptions.find((option) => option.id === id)] : filterOptions;
|
|
29
|
+
const optionIdx = filterOptions.findIndex((option) => option.id === id);
|
|
30
|
+
let groupsCounter = 0;
|
|
31
|
+
(_a = appliedFilters == null ? void 0 : appliedFilters.flat()) == null ? void 0 : _a.filter((elem) => elem !== void 0).forEach((fg, i) => {
|
|
32
|
+
groupsCounter += getExistingFiltersById(i, filterValues, filterOptions);
|
|
33
|
+
});
|
|
34
|
+
const partialCounter = id ? getExistingFiltersById(optionIdx, filterValues, filterOptions) || 0 : groupsCounter;
|
|
35
|
+
const totalCounter = options.reduce((acc, option) => acc + option.data.length, 0);
|
|
36
|
+
return /* @__PURE__ */ jsx(ClassNames, {
|
|
37
|
+
children: ({
|
|
38
|
+
css
|
|
39
|
+
}) => /* @__PURE__ */ jsxs("div", {
|
|
40
|
+
className: clsx(className, css(styles.root)),
|
|
41
|
+
children: [partialCounter > 0 ? /* @__PURE__ */ jsx("p", {
|
|
42
|
+
className: css(styles.partialCounter),
|
|
43
|
+
children: partialCounter
|
|
44
|
+
}) : partialCounter, ` / ${totalCounter}`]
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
HvFilterGroupCounter
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=Counter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Counter.js","sources":["../../../../../src/components/FilterGroup/Counter/Counter.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { styles } from \"./Counter.styles\";\nimport { HvFilterGroupFilters, HvFilterGroupValue } from \"../FilterGroup\";\nimport { ClassNames } from \"@emotion/react\";\nimport { clsx } from \"clsx\";\n\nexport interface HvFilterGroupCounterProps {\n className?: string;\n id?: string;\n}\n\nconst getExistingFiltersById = (\n idx: number,\n filterValues: HvFilterGroupValue,\n filterOptions: HvFilterGroupFilters\n) => {\n let total = 0;\n filterValues[idx]?.forEach((fv) => {\n if (filterOptions[idx]?.data.find((f) => f.id === fv)) {\n total += 1;\n }\n });\n return total;\n};\n\nexport const HvFilterGroupCounter = ({\n className,\n id,\n}: HvFilterGroupCounterProps) => {\n const {\n filterOptions,\n filterValues = [],\n appliedFilters = [],\n } = useContext(HvFilterGroupContext);\n\n const options =\n id && filterOptions.find((option) => option.id === id)\n ? ([\n filterOptions.find((option) => option.id === id),\n ] as HvFilterGroupFilters)\n : filterOptions;\n const optionIdx = filterOptions.findIndex((option) => option.id === id);\n\n let groupsCounter = 0;\n appliedFilters\n ?.flat()\n ?.filter((elem) => elem !== undefined)\n .forEach((fg, i) => {\n groupsCounter += getExistingFiltersById(i, filterValues, filterOptions);\n });\n\n const partialCounter = id\n ? getExistingFiltersById(optionIdx, filterValues, filterOptions) || 0\n : groupsCounter;\n\n const totalCounter = options.reduce(\n (acc, option) => acc + option.data.length,\n 0\n );\n\n return (\n <ClassNames>\n {({ css }) => (\n <div className={clsx(className, css(styles.root))}>\n {partialCounter > 0 ? (\n <p className={css(styles.partialCounter)}>{partialCounter}</p>\n ) : (\n partialCounter\n )}\n {` / ${totalCounter}`}\n </div>\n )}\n </ClassNames>\n );\n};\n"],"names":["getExistingFiltersById","idx","filterValues","filterOptions","total","forEach","fv","data","find","f","id","HvFilterGroupCounter","className","appliedFilters","useContext","HvFilterGroupContext","options","option","optionIdx","findIndex","groupsCounter","flat","filter","elem","undefined","fg","i","partialCounter","totalCounter","reduce","acc","length","ClassNames","children","css","clsx","styles","root"],"mappings":";;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BAAiB,wBAChB,KAAA;AAAA,QAAGf,WAAWsB,IAAIE,OAAOT,cAAc;AAAA,QAAEM,UAAEN;AAAAA,MAAc,CAAA,IAEzDA,gBAEA,MAAKC,cAAc;AAAA,IAAA,CAAA;AAAA,EAAA,CAGd;AAEjB;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
|
+
const styles = {
|
|
3
|
+
root: {
|
|
4
|
+
height: "100%",
|
|
5
|
+
lineHeight: "32px",
|
|
6
|
+
margin: "0 10px",
|
|
7
|
+
pointerEvents: "none"
|
|
8
|
+
},
|
|
9
|
+
partialCounter: {
|
|
10
|
+
display: "inline-block",
|
|
11
|
+
fontWeight: theme.filterGroup.partialCounterFontWeight
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
styles
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=Counter.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Counter.styles.js","sources":["../../../../../src/components/FilterGroup/Counter/Counter.styles.tsx"],"sourcesContent":["import { CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const styles: {\n root: CSSInterpolation;\n partialCounter: CSSInterpolation;\n} = {\n root: {\n height: \"100%\",\n lineHeight: \"32px\",\n margin: \"0 10px\",\n pointerEvents: \"none\",\n },\n partialCounter: {\n display: \"inline-block\",\n fontWeight: theme.filterGroup.partialCounterFontWeight,\n },\n};\n"],"names":["styles","root","height","lineHeight","margin","pointerEvents","partialCounter","display","fontWeight","theme","filterGroup","partialCounterFontWeight"],"mappings":";AAGO,MAAMA,SAGT;AAAA,EACFC,MAAM;AAAA,IACJC,QAAQ;AAAA,IACRC,YAAY;AAAA,IACZC,QAAQ;AAAA,IACRC,eAAe;AAAA,EACjB;AAAA,EACAC,gBAAgB;AAAA,IACdC,SAAS;AAAA,IACTC,YAAYC,MAAMC,YAAYC;AAAAA,EAChC;AACF;"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { styles } from "./FilterContent.styles.js";
|
|
2
|
+
import filterGroupContentClasses from "./filterContentClasses.js";
|
|
3
|
+
import { HvFilterGroupContext } from "../FilterGroupContext.js";
|
|
4
|
+
import { useState, useContext, useRef, useMemo } from "react";
|
|
5
|
+
import { Filters } from "@hitachivantara/uikit-react-icons";
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { ClassNames } from "@emotion/react";
|
|
8
|
+
import { jsxs, Fragment, jsx } from "@emotion/react/jsx-runtime";
|
|
9
|
+
import { HvFilterGroupLeftPanel } from "../LeftPanel/LeftPanel.js";
|
|
10
|
+
import { HvFilterGroupRightPanel } from "../RightPanel/RightPanel.js";
|
|
11
|
+
import { useTheme } from "../../../hooks/useTheme.js";
|
|
12
|
+
import { HvTypography } from "../../Typography/Typography.js";
|
|
13
|
+
import { HvBaseDropdown } from "../../BaseDropdown/BaseDropdown.js";
|
|
14
|
+
import { setId } from "../../../utils/setId.js";
|
|
15
|
+
import { HvFilterGroupCounter } from "../Counter/Counter.js";
|
|
16
|
+
import { HvActionBar } from "../../ActionBar/ActionBar.js";
|
|
17
|
+
import { HvButton } from "../../Button/Button.js";
|
|
18
|
+
const HvFilterGroupContent = ({
|
|
19
|
+
id,
|
|
20
|
+
status,
|
|
21
|
+
disabled = false,
|
|
22
|
+
"aria-label": ariaLabel,
|
|
23
|
+
"aria-labelledby": ariaLabelledBy,
|
|
24
|
+
description,
|
|
25
|
+
"aria-describedby": ariaDescribedBy,
|
|
26
|
+
onChange,
|
|
27
|
+
onCancel,
|
|
28
|
+
onClear,
|
|
29
|
+
labels,
|
|
30
|
+
horizontalPlacement = "right",
|
|
31
|
+
disablePortal = true,
|
|
32
|
+
escapeWithReference = true,
|
|
33
|
+
height,
|
|
34
|
+
leftEmptyElement,
|
|
35
|
+
rightEmptyElement,
|
|
36
|
+
classes,
|
|
37
|
+
...others
|
|
38
|
+
}) => {
|
|
39
|
+
const {
|
|
40
|
+
activeTheme
|
|
41
|
+
} = useTheme();
|
|
42
|
+
const [filterGroupOpen, setFilterGroupOpen] = useState(false);
|
|
43
|
+
const {
|
|
44
|
+
defaultValue,
|
|
45
|
+
filterValues,
|
|
46
|
+
rollbackFilters,
|
|
47
|
+
clearFilters,
|
|
48
|
+
applyFilters,
|
|
49
|
+
applyDisabled
|
|
50
|
+
} = useContext(HvFilterGroupContext);
|
|
51
|
+
const focusTarget = useRef(null);
|
|
52
|
+
const focusOnContainer = () => {
|
|
53
|
+
var _a;
|
|
54
|
+
(_a = focusTarget.current) == null ? void 0 : _a.focus();
|
|
55
|
+
};
|
|
56
|
+
const onApplyHandler = (event) => {
|
|
57
|
+
applyFilters();
|
|
58
|
+
onChange == null ? void 0 : onChange(event, filterValues);
|
|
59
|
+
setFilterGroupOpen(false);
|
|
60
|
+
};
|
|
61
|
+
const onCancelHandler = (event) => {
|
|
62
|
+
rollbackFilters();
|
|
63
|
+
onCancel == null ? void 0 : onCancel(event);
|
|
64
|
+
setFilterGroupOpen(false);
|
|
65
|
+
};
|
|
66
|
+
const onClearHandler = (event) => {
|
|
67
|
+
clearFilters();
|
|
68
|
+
onClear == null ? void 0 : onClear(event);
|
|
69
|
+
};
|
|
70
|
+
const handleToggle = (event, open) => {
|
|
71
|
+
if (event === null)
|
|
72
|
+
return;
|
|
73
|
+
setFilterGroupOpen(open);
|
|
74
|
+
if (!open)
|
|
75
|
+
onCancelHandler == null ? void 0 : onCancelHandler(event);
|
|
76
|
+
};
|
|
77
|
+
const Header = useMemo(() => /* @__PURE__ */ jsxs(Fragment, {
|
|
78
|
+
children: [/* @__PURE__ */ jsx(Filters, {}), /* @__PURE__ */ jsx(HvTypography, {
|
|
79
|
+
variant: "label",
|
|
80
|
+
children: labels == null ? void 0 : labels.placeholder
|
|
81
|
+
})]
|
|
82
|
+
}), [labels == null ? void 0 : labels.placeholder]);
|
|
83
|
+
return /* @__PURE__ */ jsx(ClassNames, {
|
|
84
|
+
children: ({
|
|
85
|
+
css
|
|
86
|
+
}) => /* @__PURE__ */ jsxs(HvBaseDropdown, {
|
|
87
|
+
id: setId(id, "dropdown"),
|
|
88
|
+
role: "combobox",
|
|
89
|
+
classes: {
|
|
90
|
+
root: clsx(classes == null ? void 0 : classes.dropdown, filterGroupContentClasses.dropdown),
|
|
91
|
+
panel: clsx(classes == null ? void 0 : classes.panel, filterGroupContentClasses.panel, css(styles.panel)),
|
|
92
|
+
selection: clsx(classes == null ? void 0 : classes.baseDropdownSelection, filterGroupContentClasses.baseDropdownSelection, css(styles.baseDropdownSelection)),
|
|
93
|
+
header: clsx(classes == null ? void 0 : classes.header, filterGroupContentClasses.header, css(styles.header))
|
|
94
|
+
},
|
|
95
|
+
disabled,
|
|
96
|
+
disablePortal,
|
|
97
|
+
variableWidth: true,
|
|
98
|
+
placement: horizontalPlacement,
|
|
99
|
+
expanded: filterGroupOpen,
|
|
100
|
+
onToggle: handleToggle,
|
|
101
|
+
onClickOutside: onCancelHandler,
|
|
102
|
+
onContainerCreation: focusOnContainer,
|
|
103
|
+
placeholder: Header,
|
|
104
|
+
adornment: /* @__PURE__ */ jsx(HvFilterGroupCounter, {}),
|
|
105
|
+
popperProps: {
|
|
106
|
+
modifiers: [{
|
|
107
|
+
name: "preventOverflow",
|
|
108
|
+
enabled: escapeWithReference
|
|
109
|
+
}]
|
|
110
|
+
},
|
|
111
|
+
"aria-haspopup": "dialog",
|
|
112
|
+
"aria-label": ariaLabel,
|
|
113
|
+
"aria-labelledby": ariaLabelledBy,
|
|
114
|
+
"aria-invalid": status === "invalid" ? true : void 0,
|
|
115
|
+
"aria-errormessage": status === "invalid" ? setId(id, "error") : void 0,
|
|
116
|
+
"aria-describedby": [description && setId(id, "description"), ariaDescribedBy].join(" ").trim() || void 0,
|
|
117
|
+
...others,
|
|
118
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
119
|
+
ref: focusTarget,
|
|
120
|
+
tabIndex: -1
|
|
121
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
122
|
+
className: clsx(classes == null ? void 0 : classes.root, filterGroupContentClasses.root, css(styles.root)),
|
|
123
|
+
style: {
|
|
124
|
+
height
|
|
125
|
+
},
|
|
126
|
+
children: [/* @__PURE__ */ jsx(HvFilterGroupLeftPanel, {
|
|
127
|
+
id,
|
|
128
|
+
className: clsx(classes == null ? void 0 : classes.leftSidePanel, filterGroupContentClasses.leftSidePanel, css(styles.leftSidePanel)),
|
|
129
|
+
emptyElement: leftEmptyElement
|
|
130
|
+
}), /* @__PURE__ */ jsx(HvFilterGroupRightPanel, {
|
|
131
|
+
id,
|
|
132
|
+
className: clsx(classes == null ? void 0 : classes.rightSidePanel, filterGroupContentClasses.rightSidePanel, css(styles.rightSidePanel)),
|
|
133
|
+
emptyElement: rightEmptyElement,
|
|
134
|
+
labels
|
|
135
|
+
})]
|
|
136
|
+
}), /* @__PURE__ */ jsxs(HvActionBar, {
|
|
137
|
+
className: clsx(classes == null ? void 0 : classes.actionBar, filterGroupContentClasses.actionBar, css(styles.actionBar)),
|
|
138
|
+
children: [/* @__PURE__ */ jsx(HvButton, {
|
|
139
|
+
id: setId(id, "clearFilters-button"),
|
|
140
|
+
disabled: defaultValue ? (defaultValue == null ? void 0 : defaultValue.flat().length) === (filterValues == null ? void 0 : filterValues.flat().length) : (filterValues == null ? void 0 : filterValues.flat().length) === 0,
|
|
141
|
+
variant: "secondaryGhost",
|
|
142
|
+
onClick: onClearHandler,
|
|
143
|
+
children: labels == null ? void 0 : labels.clearLabel
|
|
144
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
145
|
+
"aria-hidden": "true",
|
|
146
|
+
className: clsx(classes == null ? void 0 : classes.space, filterGroupContentClasses.space, css(styles.space)),
|
|
147
|
+
children: " "
|
|
148
|
+
}), /* @__PURE__ */ jsx(HvButton, {
|
|
149
|
+
id: setId(id, "apply-button"),
|
|
150
|
+
disabled: applyDisabled,
|
|
151
|
+
variant: activeTheme == null ? void 0 : activeTheme.filterGroup.applyButtonVariant,
|
|
152
|
+
onClick: onApplyHandler,
|
|
153
|
+
className: css(styles.applyButton),
|
|
154
|
+
children: labels == null ? void 0 : labels.applyLabel
|
|
155
|
+
}), /* @__PURE__ */ jsx(HvButton, {
|
|
156
|
+
id: setId(id, "cancel-button"),
|
|
157
|
+
variant: activeTheme == null ? void 0 : activeTheme.filterGroup.cancelButtonVariant,
|
|
158
|
+
onClick: onCancelHandler,
|
|
159
|
+
children: labels == null ? void 0 : labels.cancelLabel
|
|
160
|
+
})]
|
|
161
|
+
})]
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
export {
|
|
166
|
+
HvFilterGroupContent
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=FilterContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterContent.js","sources":["../../../../../src/components/FilterGroup/FilterContent/FilterContent.tsx"],"sourcesContent":["import {\n HvActionBar,\n HvBaseDropdown,\n HvBaseDropdownProps,\n HvButton,\n HvButtonVariant,\n HvFormStatus,\n HvTypography,\n} from \"@core/components\";\nimport { setId } from \"@core/utils\";\nimport {\n HvFilterGroupLabels,\n HvFilterGroupValue,\n HvFilterGroupHorizontalPlacement,\n} from \"../FilterGroup\";\nimport { styles } from \"./FilterContent.styles\";\nimport filterGroupContentClasses, {\n HvFilterGroupContentClasses,\n} from \"./filterContentClasses\";\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { useContext, useMemo, useRef, useState } from \"react\";\nimport { Filters } from \"@hitachivantara/uikit-react-icons\";\nimport { clsx } from \"clsx\";\nimport { HvFilterGroupCounter } from \"../Counter\";\nimport { ClassNames } from \"@emotion/react\";\nimport { HvFilterGroupLeftPanel } from \"../LeftPanel\";\nimport { HvFilterGroupRightPanel } from \"../RightPanel\";\nimport { useTheme } from \"@core/hooks\";\n\nexport interface HvFilterGroupContentProps\n extends Omit<HvBaseDropdownProps, \"onChange\"> {\n description?: React.ReactNode;\n status?: HvFormStatus;\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n labels?: HvFilterGroupLabels;\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n disablePortal?: boolean;\n escapeWithReference?: boolean;\n height?: string | number;\n leftEmptyElement?: React.ReactNode;\n rightEmptyElement?: React.ReactNode;\n disabled?: boolean;\n classes?: HvFilterGroupContentClasses;\n}\n\nexport const HvFilterGroupContent = ({\n id,\n status,\n disabled = false,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n labels,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height,\n leftEmptyElement,\n rightEmptyElement,\n classes,\n ...others\n}: HvFilterGroupContentProps) => {\n const { activeTheme } = useTheme();\n\n const [filterGroupOpen, setFilterGroupOpen] = useState<boolean>(false);\n\n const {\n defaultValue,\n filterValues,\n rollbackFilters,\n clearFilters,\n applyFilters,\n applyDisabled,\n } = useContext(HvFilterGroupContext);\n\n const focusTarget = useRef<HTMLDivElement>(null);\n\n const focusOnContainer = () => {\n focusTarget.current?.focus();\n };\n\n const onApplyHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n applyFilters();\n onChange?.(event, filterValues);\n setFilterGroupOpen(false);\n };\n\n const onCancelHandler = (\n event: React.MouseEvent<HTMLButtonElement> | Event\n ) => {\n rollbackFilters();\n onCancel?.(event);\n setFilterGroupOpen(false);\n };\n\n const onClearHandler = (event: React.MouseEvent<HTMLButtonElement>) => {\n clearFilters();\n onClear?.(event);\n };\n\n const handleToggle = (event: Event, open: boolean) => {\n /* \n If evt is null this toggle wasn't triggered by the user.\n instead it was triggered by the baseDropdown useEffect after\n the datepicker changed the expanded value this baseDropdown behavior needs a review\n */\n if (event === null) return;\n setFilterGroupOpen(open);\n if (!open) onCancelHandler?.(event);\n };\n\n const Header = useMemo(\n () => (\n <>\n <Filters />\n <HvTypography variant=\"label\">{labels?.placeholder}</HvTypography>\n </>\n ),\n [labels?.placeholder]\n );\n\n return (\n <ClassNames>\n {({ css }) => (\n <HvBaseDropdown\n id={setId(id, \"dropdown\")}\n role=\"combobox\"\n classes={{\n root: clsx(classes?.dropdown, filterGroupContentClasses.dropdown),\n panel: clsx(\n classes?.panel,\n filterGroupContentClasses.panel,\n css(styles.panel)\n ),\n selection: clsx(\n classes?.baseDropdownSelection,\n filterGroupContentClasses.baseDropdownSelection,\n css(styles.baseDropdownSelection)\n ),\n header: clsx(\n classes?.header,\n filterGroupContentClasses.header,\n css(styles.header)\n ),\n }}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n expanded={filterGroupOpen}\n onToggle={handleToggle}\n onClickOutside={onCancelHandler}\n onContainerCreation={focusOnContainer}\n placeholder={Header}\n adornment={<HvFilterGroupCounter />}\n popperProps={{\n modifiers: [\n { name: \"preventOverflow\", enabled: escapeWithReference },\n ],\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={\n status === \"invalid\" ? setId(id, \"error\") : undefined\n }\n aria-describedby={\n [description && setId(id, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n {...others}\n >\n <div ref={focusTarget} tabIndex={-1} />\n <div\n className={clsx(\n classes?.root,\n filterGroupContentClasses.root,\n css(styles.root)\n )}\n style={{ height }}\n >\n <HvFilterGroupLeftPanel\n id={id}\n className={clsx(\n classes?.leftSidePanel,\n filterGroupContentClasses.leftSidePanel,\n css(styles.leftSidePanel)\n )}\n emptyElement={leftEmptyElement}\n />\n <HvFilterGroupRightPanel\n id={id}\n className={clsx(\n classes?.rightSidePanel,\n filterGroupContentClasses.rightSidePanel,\n css(styles.rightSidePanel)\n )}\n emptyElement={rightEmptyElement}\n labels={labels}\n />\n </div>\n <HvActionBar\n className={clsx(\n classes?.actionBar,\n filterGroupContentClasses.actionBar,\n css(styles.actionBar)\n )}\n >\n <HvButton\n id={setId(id, \"clearFilters-button\")}\n disabled={\n defaultValue\n ? defaultValue?.flat().length === filterValues?.flat().length\n : filterValues?.flat().length === 0\n }\n variant=\"secondaryGhost\"\n onClick={onClearHandler}\n >\n {labels?.clearLabel}\n </HvButton>\n <div\n aria-hidden=\"true\"\n className={clsx(\n classes?.space,\n filterGroupContentClasses.space,\n css(styles.space)\n )}\n >\n \n </div>\n <HvButton\n id={setId(id, \"apply-button\")}\n disabled={applyDisabled}\n variant={\n activeTheme?.filterGroup.applyButtonVariant as HvButtonVariant\n }\n onClick={onApplyHandler}\n className={css(styles.applyButton)}\n >\n {labels?.applyLabel}\n </HvButton>\n <HvButton\n id={setId(id, \"cancel-button\")}\n variant={\n activeTheme?.filterGroup.cancelButtonVariant as HvButtonVariant\n }\n onClick={onCancelHandler}\n >\n {labels?.cancelLabel}\n </HvButton>\n </HvActionBar>\n </HvBaseDropdown>\n )}\n </ClassNames>\n );\n};\n"],"names":["HvFilterGroupContent","id","status","disabled","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","labels","horizontalPlacement","disablePortal","escapeWithReference","height","leftEmptyElement","rightEmptyElement","classes","others","activeTheme","useTheme","filterGroupOpen","setFilterGroupOpen","useState","defaultValue","filterValues","rollbackFilters","clearFilters","applyFilters","applyDisabled","useContext","HvFilterGroupContext","focusTarget","useRef","focusOnContainer","current","focus","onApplyHandler","event","onCancelHandler","onClearHandler","handleToggle","open","Header","useMemo","_jsxs","_Fragment","children","Filters","HvTypography","variant","placeholder","ClassNames","css","HvBaseDropdown","setId","role","root","clsx","dropdown","filterGroupContentClasses","panel","styles","selection","baseDropdownSelection","header","variableWidth","placement","expanded","onToggle","onClickOutside","onContainerCreation","adornment","_jsx","HvFilterGroupCounter","popperProps","modifiers","name","enabled","undefined","join","trim","ref","tabIndex","className","style","HvFilterGroupLeftPanel","leftSidePanel","emptyElement","HvFilterGroupRightPanel","rightSidePanel","HvActionBar","actionBar","HvButton","flat","length","onClick","clearLabel","space","filterGroup","applyButtonVariant","applyButton","applyLabel","cancelButtonVariant","cancelLabel"],"mappings":";;;;;;;;;;;;;;;;;AAkDO,MAAMA,uBAAuBA,CAAC;AAAA,EACnCC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACX,cAAcC;AAAAA,EACd,mBAAmBC;AAAAA,EACnBC;AAAAA,EACA,oBAAoBC;AAAAA,EACpBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,sBAAsB;AAAA,EACtBC,gBAAgB;AAAA,EAChBC,sBAAsB;AAAA,EACtBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACsB,MAAM;AACzB,QAAA;AAAA,IAAEC;AAAAA,MAAgBC,SAAU;AAElC,QAAM,CAACC,iBAAiBC,kBAAkB,IAAIC,SAAkB,KAAK;AAE/D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA,IACEC,WAAWC,oBAAoB;AAE7BC,QAAAA,cAAcC,OAAuB,IAAI;AAE/C,QAAMC,mBAAmBA,MAAM;;AAC7BF,sBAAYG,YAAZH,mBAAqBI;AAAAA,EAAO;AAGxBC,QAAAA,iBAAiBA,CAACC,UAA+C;AACvD;AACd/B,yCAAW+B,OAAOb;AAClBH,uBAAmB,KAAK;AAAA,EAAA;AAGpBiB,QAAAA,kBAAkBA,CACtBD,UACG;AACc;AACjB9B,yCAAW8B;AACXhB,uBAAmB,KAAK;AAAA,EAAA;AAGpBkB,QAAAA,iBAAiBA,CAACF,UAA+C;AACvD;AACd7B,uCAAU6B;AAAAA,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,WACrDtE,6CAAcqE,OAAOC,YAAW;AAAA,UAEtC7C,SAAQ;AAAA,UACR8C,SAASxD;AAAAA,UAAeO,UAEvBrC,iCAAQuF;AAAAA,QAAAA,CAAU,GAErBxB,oBAAA,OAAA;AAAA,UACE,eAAY;AAAA,UACZW,WAAW1B,KACTzC,mCAASiF,OACTtC,0BAA0BsC,OAC1B7C,IAAIS,OAAOoC,KAAK,CAAC;AAAA,UACjBnD,UACH;AAAA,QAAA,CAEK,GACN0B,oBAACoB,UAAQ;AAAA,UACP7F,IAAIuD,MAAMvD,IAAI,cAAc;AAAA,UAC5BE,UAAU2B;AAAAA,UACVqB,SACE/B,2CAAagF,YAAYC;AAAAA,UAE3BJ,SAAS3D;AAAAA,UACT+C,WAAW/B,IAAIS,OAAOuC,WAAW;AAAA,UAAEtD,UAElCrC,iCAAQ4F;AAAAA,QAAAA,CACA,GACX7B,oBAACoB,UAAQ;AAAA,UACP7F,IAAIuD,MAAMvD,IAAI,eAAe;AAAA,UAC7BkD,SACE/B,2CAAagF,YAAYI;AAAAA,UAE3BP,SAASzD;AAAAA,UAAgBQ,UAExBrC,iCAAQ8F;AAAAA,QAAAA,CACA,CAAA;AAAA,MAAA,CACC,CAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAGP;AAEjB;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { theme } from "@hitachivantara/uikit-styles";
|
|
2
|
+
const styles = {
|
|
3
|
+
panel: {
|
|
4
|
+
maxHeight: 500,
|
|
5
|
+
minHeight: 370
|
|
6
|
+
},
|
|
7
|
+
header: {
|
|
8
|
+
display: "flex",
|
|
9
|
+
justifyContent: "space-between",
|
|
10
|
+
height: 32
|
|
11
|
+
},
|
|
12
|
+
baseDropdownSelection: {
|
|
13
|
+
padding: theme.spacing(["0px", "30px", "0px", "0px"])
|
|
14
|
+
},
|
|
15
|
+
root: {
|
|
16
|
+
width: 640,
|
|
17
|
+
backgroundColor: theme.colors.atmo1,
|
|
18
|
+
maxHeight: "calc(500px - 75px)",
|
|
19
|
+
minHeight: "calc(370px - 75px)",
|
|
20
|
+
border: theme.filterGroup.panelsBorder,
|
|
21
|
+
borderBottom: theme.filterGroup.panelsBorderBottom
|
|
22
|
+
},
|
|
23
|
+
rightSidePanel: {
|
|
24
|
+
display: "inline-block",
|
|
25
|
+
width: "50%",
|
|
26
|
+
height: "100%",
|
|
27
|
+
maxHeight: "calc(500px - 75px)",
|
|
28
|
+
minHeight: "calc(370px - 75px)",
|
|
29
|
+
verticalAlign: "top",
|
|
30
|
+
overflow: "visible",
|
|
31
|
+
boxShadow: theme.filterGroup.rightPanelShadow,
|
|
32
|
+
borderLeft: theme.filterGroup.rightPanelBorderLeft
|
|
33
|
+
},
|
|
34
|
+
leftSidePanel: {
|
|
35
|
+
display: "inline-block",
|
|
36
|
+
width: `calc(50% - ${theme.spacing("sm")} - ${theme.spacing("sm")} + 8px)`,
|
|
37
|
+
height: `calc(100% - ${theme.spacing("sm")} - ${theme.spacing("sm")} + 8px)`,
|
|
38
|
+
verticalAlign: "top",
|
|
39
|
+
maxHeight: "calc(500px - 75px)",
|
|
40
|
+
minHeight: "calc(370px - 75px)",
|
|
41
|
+
padding: 4,
|
|
42
|
+
margin: `calc(${theme.spacing("sm")} - 4px)`
|
|
43
|
+
},
|
|
44
|
+
actionBar: {
|
|
45
|
+
backgroundColor: theme.colors.atmo1,
|
|
46
|
+
border: theme.filterGroup.actionBarBorder,
|
|
47
|
+
borderTop: theme.filterGroup.actionBarBorderTop,
|
|
48
|
+
alignItems: "center"
|
|
49
|
+
},
|
|
50
|
+
space: {
|
|
51
|
+
flex: 1
|
|
52
|
+
},
|
|
53
|
+
applyButton: {
|
|
54
|
+
marginRight: theme.filterGroup.applyButtonMarginRight
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
styles
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=FilterContent.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterContent.styles.js","sources":["../../../../../src/components/FilterGroup/FilterContent/FilterContent.styles.tsx"],"sourcesContent":["import { CSSInterpolation } from \"@emotion/serialize\";\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nexport const styles: {\n panel: CSSInterpolation;\n header: CSSInterpolation;\n baseDropdownSelection: CSSInterpolation;\n root: CSSInterpolation;\n actionBar: CSSInterpolation;\n space: CSSInterpolation;\n rightSidePanel: CSSInterpolation;\n leftSidePanel: CSSInterpolation;\n applyButton: CSSInterpolation;\n} = {\n panel: {\n maxHeight: 500,\n minHeight: 370,\n },\n header: {\n display: \"flex\",\n justifyContent: \"space-between\",\n height: 32,\n },\n baseDropdownSelection: {\n padding: theme.spacing([\"0px\", \"30px\", \"0px\", \"0px\"]),\n },\n root: {\n width: 640,\n backgroundColor: theme.colors.atmo1,\n maxHeight: \"calc(500px - 75px)\",\n minHeight: \"calc(370px - 75px)\",\n border: theme.filterGroup.panelsBorder,\n borderBottom: theme.filterGroup.panelsBorderBottom,\n },\n rightSidePanel: {\n display: \"inline-block\",\n width: \"50%\",\n height: \"100%\",\n maxHeight: \"calc(500px - 75px)\",\n minHeight: \"calc(370px - 75px)\",\n verticalAlign: \"top\",\n overflow: \"visible\",\n boxShadow: theme.filterGroup.rightPanelShadow,\n borderLeft: theme.filterGroup.rightPanelBorderLeft,\n },\n leftSidePanel: {\n display: \"inline-block\",\n width: `calc(50% - ${theme.spacing(\"sm\")} - ${theme.spacing(\"sm\")} + 8px)`,\n height: `calc(100% - ${theme.spacing(\"sm\")} - ${theme.spacing(\n \"sm\"\n )} + 8px)`,\n verticalAlign: \"top\",\n maxHeight: \"calc(500px - 75px)\",\n minHeight: \"calc(370px - 75px)\",\n padding: 4,\n margin: `calc(${theme.spacing(\"sm\")} - 4px)`,\n },\n actionBar: {\n backgroundColor: theme.colors.atmo1,\n border: theme.filterGroup.actionBarBorder,\n borderTop: theme.filterGroup.actionBarBorderTop,\n alignItems: \"center\",\n },\n space: {\n flex: 1,\n },\n applyButton: {\n marginRight: theme.filterGroup.applyButtonMarginRight,\n },\n};\n"],"names":["styles","panel","maxHeight","minHeight","header","display","justifyContent","height","baseDropdownSelection","padding","theme","spacing","root","width","backgroundColor","colors","atmo1","border","filterGroup","panelsBorder","borderBottom","panelsBorderBottom","rightSidePanel","verticalAlign","overflow","boxShadow","rightPanelShadow","borderLeft","rightPanelBorderLeft","leftSidePanel","margin","actionBar","actionBarBorder","borderTop","actionBarBorderTop","alignItems","space","flex","applyButton","marginRight","applyButtonMarginRight"],"mappings":";AAGO,MAAMA,SAUT;AAAA,EACFC,OAAO;AAAA,IACLC,WAAW;AAAA,IACXC,WAAW;AAAA,EACb;AAAA,EACAC,QAAQ;AAAA,IACNC,SAAS;AAAA,IACTC,gBAAgB;AAAA,IAChBC,QAAQ;AAAA,EACV;AAAA,EACAC,uBAAuB;AAAA,IACrBC,SAASC,MAAMC,QAAQ,CAAC,OAAO,QAAQ,OAAO,KAAK,CAAC;AAAA,EACtD;AAAA,EACAC,MAAM;AAAA,IACJC,OAAO;AAAA,IACPC,iBAAiBJ,MAAMK,OAAOC;AAAAA,IAC9Bd,WAAW;AAAA,IACXC,WAAW;AAAA,IACXc,QAAQP,MAAMQ,YAAYC;AAAAA,IAC1BC,cAAcV,MAAMQ,YAAYG;AAAAA,EAClC;AAAA,EACAC,gBAAgB;AAAA,IACdjB,SAAS;AAAA,IACTQ,OAAO;AAAA,IACPN,QAAQ;AAAA,IACRL,WAAW;AAAA,IACXC,WAAW;AAAA,IACXoB,eAAe;AAAA,IACfC,UAAU;AAAA,IACVC,WAAWf,MAAMQ,YAAYQ;AAAAA,IAC7BC,YAAYjB,MAAMQ,YAAYU;AAAAA,EAChC;AAAA,EACAC,eAAe;AAAA,IACbxB,SAAS;AAAA,IACTQ,OAAQ,cAAaH,MAAMC,QAAQ,IAAI,OAAOD,MAAMC,QAAQ,IAAI;AAAA,IAChEJ,QAAS,eAAcG,MAAMC,QAAQ,IAAI,OAAOD,MAAMC,QACpD,IAAI;AAAA,IAENY,eAAe;AAAA,IACfrB,WAAW;AAAA,IACXC,WAAW;AAAA,IACXM,SAAS;AAAA,IACTqB,QAAS,QAAOpB,MAAMC,QAAQ,IAAI;AAAA,EACpC;AAAA,EACAoB,WAAW;AAAA,IACTjB,iBAAiBJ,MAAMK,OAAOC;AAAAA,IAC9BC,QAAQP,MAAMQ,YAAYc;AAAAA,IAC1BC,WAAWvB,MAAMQ,YAAYgB;AAAAA,IAC7BC,YAAY;AAAA,EACd;AAAA,EACAC,OAAO;AAAA,IACLC,MAAM;AAAA,EACR;AAAA,EACAC,aAAa;AAAA,IACXC,aAAa7B,MAAMQ,YAAYsB;AAAAA,EACjC;AACF;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getClasses } from "../../../utils/classes.js";
|
|
2
|
+
const classKeys = ["dropdown", "panel", "baseDropdownSelection", "header", "root", "leftSidePanel", "rightSidePanel", "actionBar", "space"];
|
|
3
|
+
const filterGroupContentClasses = getClasses(classKeys, "HvFilterGroupContent");
|
|
4
|
+
const filterGroupContentClasses$1 = filterGroupContentClasses;
|
|
5
|
+
export {
|
|
6
|
+
filterGroupContentClasses$1 as default
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=filterContentClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterContentClasses.js","sources":["../../../../../src/components/FilterGroup/FilterContent/filterContentClasses.ts"],"sourcesContent":["import { getClasses } from \"@core/utils\";\n\nexport interface HvFilterGroupContentClasses {\n dropdown?: string;\n panel?: string;\n baseDropdownSelection?: string;\n header?: string;\n root?: string;\n leftSidePanel?: string;\n rightSidePanel?: string;\n actionBar?: string;\n space?: string;\n}\n\nconst classKeys: string[] = [\n \"dropdown\",\n \"panel\",\n \"baseDropdownSelection\",\n \"header\",\n \"root\",\n \"leftSidePanel\",\n \"rightSidePanel\",\n \"actionBar\",\n \"space\",\n];\n\nconst filterGroupContentClasses = getClasses<HvFilterGroupContentClasses>(\n classKeys,\n \"HvFilterGroupContent\"\n);\n\nexport default filterGroupContentClasses;\n"],"names":["classKeys","filterGroupContentClasses","getClasses"],"mappings":";AAcA,MAAMA,YAAsB,CAC1B,YACA,SACA,yBACA,UACA,QACA,iBACA,kBACA,aACA,OAAO;AAGT,MAAMC,4BAA4BC,WAChCF,WACA,sBAAsB;AAGxB,MAAA,8BAAeC;"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import filterGroupClasses from "./filterGroupClasses.js";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { styles } from "./FilterGroup.styles.js";
|
|
4
|
+
import { HvFilterGroupProvider } from "./FilterGroupContext.js";
|
|
5
|
+
import { ClassNames } from "@emotion/react";
|
|
6
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
7
|
+
import useUniqueId from "../../hooks/useUniqueId.js";
|
|
8
|
+
import { HvFilterGroupContent } from "./FilterContent/FilterContent.js";
|
|
9
|
+
import { useControlled } from "../../hooks/useControlled.js";
|
|
10
|
+
import { useLabels } from "../../hooks/useLabels.js";
|
|
11
|
+
import { HvFormElement } from "../Forms/FormElement/FormElement.js";
|
|
12
|
+
import { HvLabel } from "../Forms/Label/Label.js";
|
|
13
|
+
import { setId } from "../../utils/setId.js";
|
|
14
|
+
import { HvInfoMessage } from "../Forms/InfoMessage/InfoMessage.js";
|
|
15
|
+
import { HvWarningText } from "../Forms/WarningText/WarningText.js";
|
|
16
|
+
const DEFAULT_LABELS = {
|
|
17
|
+
applyLabel: "Apply",
|
|
18
|
+
cancelLabel: "Cancel",
|
|
19
|
+
clearLabel: "Clear Filters",
|
|
20
|
+
placeholder: "Filters",
|
|
21
|
+
searchBoxPlaceholder: "Search",
|
|
22
|
+
selectAll: "All",
|
|
23
|
+
multiSelectionConjunction: "/"
|
|
24
|
+
};
|
|
25
|
+
const HvFilterGroup = ({
|
|
26
|
+
className,
|
|
27
|
+
id,
|
|
28
|
+
name,
|
|
29
|
+
required = false,
|
|
30
|
+
disabled = false,
|
|
31
|
+
label,
|
|
32
|
+
"aria-label": ariaLabel,
|
|
33
|
+
"aria-labelledby": ariaLabelledBy,
|
|
34
|
+
description,
|
|
35
|
+
"aria-describedby": ariaDescribedBy,
|
|
36
|
+
onChange,
|
|
37
|
+
onCancel,
|
|
38
|
+
onClear,
|
|
39
|
+
status,
|
|
40
|
+
statusMessage,
|
|
41
|
+
labels: labelsProp,
|
|
42
|
+
defaultValue,
|
|
43
|
+
value,
|
|
44
|
+
filters,
|
|
45
|
+
horizontalPlacement = "right",
|
|
46
|
+
disablePortal = true,
|
|
47
|
+
escapeWithReference = true,
|
|
48
|
+
height = 350,
|
|
49
|
+
filterContentProps,
|
|
50
|
+
classes,
|
|
51
|
+
...others
|
|
52
|
+
}) => {
|
|
53
|
+
const [validationMessage] = useControlled(statusMessage, "Required");
|
|
54
|
+
const elementId = useUniqueId(id, "hvfiltergroup");
|
|
55
|
+
const labels = useLabels(DEFAULT_LABELS, labelsProp);
|
|
56
|
+
const hasLabel = label != null;
|
|
57
|
+
const hasDescription = description != null;
|
|
58
|
+
const canShowError = status !== void 0 || required;
|
|
59
|
+
return /* @__PURE__ */ jsx(ClassNames, {
|
|
60
|
+
children: ({
|
|
61
|
+
css
|
|
62
|
+
}) => /* @__PURE__ */ jsxs(HvFormElement, {
|
|
63
|
+
id,
|
|
64
|
+
name,
|
|
65
|
+
value,
|
|
66
|
+
status,
|
|
67
|
+
disabled,
|
|
68
|
+
required,
|
|
69
|
+
className: clsx(className, classes == null ? void 0 : classes.root, filterGroupClasses.root),
|
|
70
|
+
...others,
|
|
71
|
+
children: [(hasLabel || hasDescription) && /* @__PURE__ */ jsxs("div", {
|
|
72
|
+
className: clsx(classes == null ? void 0 : classes.labelContainer, filterGroupClasses.labelContainer, css(styles.labelContainer)),
|
|
73
|
+
children: [hasLabel && /* @__PURE__ */ jsx(HvLabel, {
|
|
74
|
+
id: setId(elementId, "label"),
|
|
75
|
+
htmlFor: setId(elementId, "input"),
|
|
76
|
+
label,
|
|
77
|
+
className: clsx(classes == null ? void 0 : classes.label, filterGroupClasses.label, css(styles.label))
|
|
78
|
+
}), hasDescription && /* @__PURE__ */ jsx(HvInfoMessage, {
|
|
79
|
+
id: setId(elementId, "description"),
|
|
80
|
+
className: clsx(classes == null ? void 0 : classes.description, filterGroupClasses.description),
|
|
81
|
+
children: description
|
|
82
|
+
})]
|
|
83
|
+
}), /* @__PURE__ */ jsxs(HvFilterGroupProvider, {
|
|
84
|
+
defaultValue,
|
|
85
|
+
value,
|
|
86
|
+
filters,
|
|
87
|
+
children: [/* @__PURE__ */ jsx(HvFilterGroupContent, {
|
|
88
|
+
id: elementId,
|
|
89
|
+
disabled,
|
|
90
|
+
disablePortal,
|
|
91
|
+
variableWidth: true,
|
|
92
|
+
placement: horizontalPlacement,
|
|
93
|
+
escapeWithReference,
|
|
94
|
+
"aria-label": ariaLabel,
|
|
95
|
+
"aria-labelledby": ariaLabelledBy,
|
|
96
|
+
status,
|
|
97
|
+
onChange,
|
|
98
|
+
onCancel,
|
|
99
|
+
onClear,
|
|
100
|
+
labels,
|
|
101
|
+
height,
|
|
102
|
+
...filterContentProps
|
|
103
|
+
}), canShowError && /* @__PURE__ */ jsx(HvWarningText, {
|
|
104
|
+
id: setId(elementId, "error"),
|
|
105
|
+
disableBorder: true,
|
|
106
|
+
className: clsx(classes == null ? void 0 : classes.error, filterGroupClasses.error),
|
|
107
|
+
children: validationMessage
|
|
108
|
+
})]
|
|
109
|
+
})]
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
HvFilterGroup
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=FilterGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterGroup.js","sources":["../../../../src/components/FilterGroup/FilterGroup.tsx"],"sourcesContent":["import {\n HvFormElement,\n HvFormElementProps,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components\";\nimport filterGroupClasses, { HvFilterGroupClasses } from \"./filterGroupClasses\";\nimport {\n HvFilterGroupContent,\n HvFilterGroupContentProps,\n} from \"./FilterContent\";\nimport { clsx } from \"clsx\";\nimport { useControlled, useLabels, useUniqueId } from \"@core/hooks\";\nimport { styles } from \"./FilterGroup.styles\";\nimport { setId } from \"@core/utils\";\nimport { HvFilterGroupProvider } from \"./FilterGroupContext\";\nimport { ClassNames } from \"@emotion/react\";\n\nexport type HvFilterGroupValue = (string | number)[][];\n\nexport interface HvFilterGroupLabels {\n /** Apply button label. */\n applyLabel?: string;\n /** Cancel button label. */\n cancelLabel?: string;\n /** Cancel button label. */\n clearLabel?: string;\n /** Placeholder label. */\n placeholder?: string;\n /** SearchBox placeholder label. */\n searchBoxPlaceholder?: string;\n /** Select All placeholder label. */\n selectAll?: string;\n /** Multi selection conjunction placeholder label. */\n multiSelectionConjunction?: string;\n}\n\nexport type HvFilterGroupFilters = {\n id: string;\n name: string;\n data: {\n id: string | number;\n name: string;\n }[];\n}[];\n\nexport type HvFilterGroupHorizontalPlacement = \"left\" | \"right\";\n\nexport interface HvFilterGroupProps\n extends Omit<\n HvFormElementProps,\n \"onChange\" | \"defaultValue\" | \"statusMessage\"\n > {\n /** The initial value of the input when in single calendar mode. */\n filters: HvFilterGroupFilters;\n /** The form element name. */\n name?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /** Provide additional descriptive text for the form element. */\n description?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** Indicates that user input is required on the form element. */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /** The error message to show when `status` is \"invalid\". Defaults to \"Required\". */\n statusMessage?: React.ReactNode;\n /** The callback fired when the cancel button is clicked. */\n onCancel?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void;\n /** The callback fired when the clear filters button is clicked. */\n onClear?: (event: React.MouseEvent<HTMLButtonElement>) => void;\n /** The callback fired when the value changes. */\n onChange?: (\n event: React.MouseEvent<HTMLButtonElement>,\n value?: HvFilterGroupValue\n ) => void;\n /** An Object containing the various text associated with the input. */\n labels?: HvFilterGroupLabels;\n /** The placeholder value when nothing is selected. */\n placeholder?: string;\n /** The default value of the filter group. If defined the clear action will reset to it. */\n defaultValue?: HvFilterGroupValue;\n /** The value of the filter group. */\n value?: HvFilterGroupValue;\n /** The placement where the filter group should be placed according to the input. Options are `left` or `right`. */\n horizontalPlacement?: HvFilterGroupHorizontalPlacement;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the filter container should be out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** The height of the filter panel, between 295 and 425. Defaults to 350 */\n height?: number | string;\n /** The filter content props */\n filterContentProps?: Partial<HvFilterGroupContentProps>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvFilterGroupClasses;\n}\n\nconst DEFAULT_LABELS: HvFilterGroupLabels = {\n applyLabel: \"Apply\",\n cancelLabel: \"Cancel\",\n clearLabel: \"Clear Filters\",\n placeholder: \"Filters\",\n searchBoxPlaceholder: \"Search\",\n selectAll: \"All\",\n multiSelectionConjunction: \"/\",\n};\n\n/**\n * This component implements one potential use-case of the Filter Group pattern Design System Specifies.\n * Due to the enormous variety of capabilities required for this, we strongly recommend checking the code of the component and extend it yourself,\n * while we do not provide a better approach for building this component with smaller and more composable parts.\n */\nexport const HvFilterGroup = ({\n className,\n id,\n name,\n required = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n onChange,\n onCancel,\n onClear,\n status,\n statusMessage,\n labels: labelsProp,\n defaultValue,\n value,\n filters,\n horizontalPlacement = \"right\",\n disablePortal = true,\n escapeWithReference = true,\n height = 350,\n filterContentProps,\n classes,\n ...others\n}: HvFilterGroupProps) => {\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const elementId = useUniqueId(id, \"hvfiltergroup\");\n\n const labels = useLabels(DEFAULT_LABELS, labelsProp);\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n // Error message area will only be needed if the status is being controlled\n // or if required is true\n const canShowError = status !== undefined || required;\n\n return (\n <ClassNames>\n {({ css }) => (\n <HvFormElement\n id={id}\n name={name}\n value={value}\n status={status}\n disabled={disabled}\n required={required}\n className={clsx(className, classes?.root, filterGroupClasses.root)}\n {...others}\n >\n {(hasLabel || hasDescription) && (\n <div\n className={clsx(\n classes?.labelContainer,\n filterGroupClasses.labelContainer,\n css(styles.labelContainer)\n )}\n >\n {hasLabel && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={clsx(\n classes?.label,\n filterGroupClasses.label,\n css(styles.label)\n )}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n id={setId(elementId, \"description\")}\n className={clsx(\n classes?.description,\n filterGroupClasses.description\n )}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n <HvFilterGroupProvider\n defaultValue={defaultValue}\n value={value}\n filters={filters}\n >\n <HvFilterGroupContent\n id={elementId}\n disabled={disabled}\n disablePortal={disablePortal}\n variableWidth\n placement={horizontalPlacement}\n escapeWithReference={escapeWithReference}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n status={status}\n onChange={onChange}\n onCancel={onCancel}\n onClear={onClear}\n labels={labels}\n height={height}\n {...filterContentProps}\n />\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={clsx(classes?.error, filterGroupClasses.error)}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFilterGroupProvider>\n </HvFormElement>\n )}\n </ClassNames>\n );\n};\n"],"names":["DEFAULT_LABELS","applyLabel","cancelLabel","clearLabel","placeholder","searchBoxPlaceholder","selectAll","multiSelectionConjunction","HvFilterGroup","className","id","name","required","disabled","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","onChange","onCancel","onClear","status","statusMessage","labels","labelsProp","defaultValue","value","filters","horizontalPlacement","disablePortal","escapeWithReference","height","filterContentProps","classes","others","validationMessage","useControlled","elementId","useUniqueId","useLabels","hasLabel","hasDescription","canShowError","undefined","ClassNames","children","css","HvFormElement","clsx","root","filterGroupClasses","labelContainer","styles","_jsx","HvLabel","setId","htmlFor","HvInfoMessage","_jsxs","HvFilterGroupProvider","HvFilterGroupContent","variableWidth","placement","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;;;;;;;;AAkHA,MAAMA,iBAAsC;AAAA,EAC1CC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,YAAY;AAAA,EACZC,aAAa;AAAA,EACbC,sBAAsB;AAAA,EACtBC,WAAW;AAAA,EACXC,2BAA2B;AAC7B;AAOO,MAAMC,gBAAgBA,CAAC;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,WAAW;AAAA,EACXC,WAAW;AAAA,EACXC;AAAAA,EACA,cAAcC;AAAAA,EACd,mBAAmBC;AAAAA,EACnBC;AAAAA,EACA,oBAAoBC;AAAAA,EACpBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,QAAQC;AAAAA,EACRC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,sBAAsB;AAAA,EACtBC,gBAAgB;AAAA,EAChBC,sBAAsB;AAAA,EACtBC,SAAS;AAAA,EACTC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACe,MAAM;AACxB,QAAM,CAACC,iBAAiB,IAAIC,cAAcd,eAAe,UAAU;AAE7De,QAAAA,YAAYC,YAAY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AA,UACA,cAAYhB;AAAAA,UACZ,mBAAiBC;AAAAA,UACjBM;AAAAA,UACAH;AAAAA,UACAC;AAAAA,UACAC;AAAAA,UACAG;AAAAA,UACAQ;AAAAA,UAAe,GACXC;AAAAA,QAAAA,CAAkB,GAEvBU,gBACCW,oBAACU,eAAa;AAAA,UACZtD,IAAI8C,MAAMlB,WAAW,OAAO;AAAA,UAC5B2B,eAAa;AAAA,UACbxD,WAAWwC,KAAKf,mCAASgC,OAAOf,mBAAmBe,KAAK;AAAA,UAAEpB,UAEzDV;AAAAA,QAAAA,CAEJ,CAAA;AAAA,MAAA,CACqB,CAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAGjB;AAEjB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterGroup.styles.js","sources":["../../../../src/components/FilterGroup/FilterGroup.styles.tsx"],"sourcesContent":["import { CSSInterpolation } from \"@emotion/serialize\";\n\nexport const styles: {\n label: CSSInterpolation;\n labelContainer: CSSInterpolation;\n} = {\n label: {\n display: \"flex\",\n alignItems: \"flex-start\",\n },\n labelContainer: { display: \"flex\", alignItems: \"flex-start\" },\n};\n"],"names":["styles","label","display","alignItems","labelContainer"],"mappings":"AAEO,MAAMA,SAGT;AAAA,EACFC,OAAO;AAAA,IACLC,SAAS;AAAA,IACTC,YAAY;AAAA,EACd;AAAA,EACAC,gBAAgB;AAAA,IAAEF,SAAS;AAAA,IAAQC,YAAY;AAAA,EAAa;AAC9D;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createContext, useState, useEffect, useCallback, useMemo } from "react";
|
|
2
|
+
import isEqual from "lodash/isEqual";
|
|
3
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
4
|
+
import { useSavedState } from "../../utils/useSavedState.js";
|
|
5
|
+
const HvFilterGroupContext = createContext({
|
|
6
|
+
activeGroup: 0,
|
|
7
|
+
setActiveGroup: () => {
|
|
8
|
+
},
|
|
9
|
+
filterOptions: [],
|
|
10
|
+
setFilterValues: () => {
|
|
11
|
+
},
|
|
12
|
+
rollbackFilters: () => {
|
|
13
|
+
},
|
|
14
|
+
clearFilters: () => {
|
|
15
|
+
},
|
|
16
|
+
applyFilters: () => {
|
|
17
|
+
},
|
|
18
|
+
applyDisabled: false,
|
|
19
|
+
filterValues: [],
|
|
20
|
+
appliedFilters: void 0,
|
|
21
|
+
defaultValue: void 0
|
|
22
|
+
});
|
|
23
|
+
const groups = (filters) => filters.map(() => []);
|
|
24
|
+
const HvFilterGroupProvider = ({
|
|
25
|
+
defaultValue,
|
|
26
|
+
value,
|
|
27
|
+
filters,
|
|
28
|
+
children
|
|
29
|
+
}) => {
|
|
30
|
+
const [group, setActiveGroup] = useState(0);
|
|
31
|
+
const [filterValues, setFilterValues, rollbackFilters, appliedFilters] = useSavedState(value || groups(filters));
|
|
32
|
+
const [applyDisabled, setApplyDisabled] = useState(false);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setFilterValues(value, true);
|
|
35
|
+
}, [value, setFilterValues]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setApplyDisabled(isEqual(filterValues, appliedFilters));
|
|
38
|
+
}, [filterValues, appliedFilters]);
|
|
39
|
+
const clearFilters = useCallback(() => {
|
|
40
|
+
setFilterValues(defaultValue || groups(filters));
|
|
41
|
+
}, [filters, setFilterValues, defaultValue]);
|
|
42
|
+
const applyFilters = useCallback(() => {
|
|
43
|
+
setFilterValues(filterValues, true);
|
|
44
|
+
}, [filterValues, setFilterValues]);
|
|
45
|
+
const contextValue = useMemo(() => ({
|
|
46
|
+
activeGroup: group,
|
|
47
|
+
setActiveGroup,
|
|
48
|
+
filterOptions: filters,
|
|
49
|
+
filterValues,
|
|
50
|
+
setFilterValues,
|
|
51
|
+
appliedFilters,
|
|
52
|
+
rollbackFilters,
|
|
53
|
+
clearFilters,
|
|
54
|
+
applyFilters,
|
|
55
|
+
applyDisabled,
|
|
56
|
+
defaultValue
|
|
57
|
+
}), [appliedFilters, applyDisabled, applyFilters, clearFilters, filterValues, filters, group, rollbackFilters, setFilterValues, defaultValue]);
|
|
58
|
+
return /* @__PURE__ */ jsx(HvFilterGroupContext.Provider, {
|
|
59
|
+
value: contextValue,
|
|
60
|
+
children
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
HvFilterGroupContext,
|
|
65
|
+
HvFilterGroupProvider
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=FilterGroupContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterGroupContext.js","sources":["../../../../src/components/FilterGroup/FilterGroupContext.tsx"],"sourcesContent":["import {\n Dispatch,\n SetStateAction,\n createContext,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport isEqual from \"lodash/isEqual\";\nimport { useSavedState } from \"@core/utils\";\nimport { HvFilterGroupFilters, HvFilterGroupValue } from \"./FilterGroup\";\n\ninterface HvFilterGroupContextValue {\n activeGroup: number;\n setActiveGroup: Dispatch<SetStateAction<number>>;\n filterOptions: HvFilterGroupFilters;\n setFilterValues: (value?: HvFilterGroupValue, save?: boolean) => void;\n rollbackFilters: () => void;\n clearFilters: () => void;\n applyFilters: () => void;\n applyDisabled: boolean;\n appliedFilters?: HvFilterGroupValue;\n defaultValue?: HvFilterGroupValue;\n filterValues?: HvFilterGroupValue;\n}\n\nexport const HvFilterGroupContext = createContext<HvFilterGroupContextValue>({\n activeGroup: 0,\n setActiveGroup: () => {},\n filterOptions: [],\n setFilterValues: () => {},\n rollbackFilters: () => {},\n clearFilters: () => {},\n applyFilters: () => {},\n applyDisabled: false,\n filterValues: [],\n appliedFilters: undefined,\n defaultValue: undefined,\n});\n\nconst groups = (filters: HvFilterGroupFilters) => filters.map(() => []);\n\ninterface HvFilterGroupProviderProps {\n children: React.ReactNode;\n filters: HvFilterGroupFilters;\n defaultValue?: HvFilterGroupValue;\n value?: HvFilterGroupValue;\n}\n\nexport const HvFilterGroupProvider = ({\n defaultValue,\n value,\n filters,\n children,\n}: HvFilterGroupProviderProps) => {\n const [group, setActiveGroup] = useState<number>(0);\n const [filterValues, setFilterValues, rollbackFilters, appliedFilters] =\n useSavedState<HvFilterGroupValue>(value || groups(filters));\n const [applyDisabled, setApplyDisabled] = useState<boolean>(false);\n\n useEffect(() => {\n setFilterValues(value, true);\n }, [value, setFilterValues]);\n\n useEffect(() => {\n setApplyDisabled(isEqual(filterValues, appliedFilters));\n }, [filterValues, appliedFilters]);\n\n const clearFilters = useCallback(() => {\n setFilterValues(defaultValue || groups(filters));\n }, [filters, setFilterValues, defaultValue]);\n\n const applyFilters = useCallback(() => {\n setFilterValues(filterValues, true);\n }, [filterValues, setFilterValues]);\n\n const contextValue: HvFilterGroupContextValue = useMemo(\n () => ({\n activeGroup: group,\n setActiveGroup,\n filterOptions: filters,\n filterValues,\n setFilterValues,\n appliedFilters,\n rollbackFilters,\n clearFilters,\n applyFilters,\n applyDisabled,\n defaultValue,\n }),\n [\n appliedFilters,\n applyDisabled,\n applyFilters,\n clearFilters,\n filterValues,\n filters,\n group,\n rollbackFilters,\n setFilterValues,\n defaultValue,\n ]\n );\n\n return (\n <HvFilterGroupContext.Provider value={contextValue}>\n {children}\n </HvFilterGroupContext.Provider>\n );\n};\n"],"names":["HvFilterGroupContext","createContext","activeGroup","setActiveGroup","filterOptions","setFilterValues","rollbackFilters","clearFilters","applyFilters","applyDisabled","filterValues","appliedFilters","undefined","defaultValue","groups","filters","map","HvFilterGroupProvider","value","children","group","useState","useSavedState","setApplyDisabled","useEffect","isEqual","useCallback","contextValue","useMemo","_jsx","Provider"],"mappings":";;;;AA2BO,MAAMA,uBAAuBC,cAAyC;AAAA,EAC3EC,aAAa;AAAA,EACbC,gBAAgBA,MAAM;AAAA,EAAC;AAAA,EACvBC,eAAe,CAAE;AAAA,EACjBC,iBAAiBA,MAAM;AAAA,EAAC;AAAA,EACxBC,iBAAiBA,MAAM;AAAA,EAAC;AAAA,EACxBC,cAAcA,M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