@activecollab/components 2.0.594 → 2.0.595

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.
@@ -1,4 +1,5 @@
1
1
  import React, { useRef, useEffect } from "react";
2
+ import { isFilterEntryVisible } from "./isFilterEntryVisible";
2
3
  import { StyledStartMenuTitle, StyledStartMenuListItem, StyledStartMenuList, StyledStartMenuNoResults } from "./Styles";
3
4
  import { useResizeObserver } from "../../utils";
4
5
  import { Badge } from "../Badge";
@@ -23,11 +24,9 @@ export const StartMenu = _ref => {
23
24
  return /*#__PURE__*/React.createElement("div", {
24
25
  style: style,
25
26
  ref: ref
26
- }, /*#__PURE__*/React.createElement(StyledStartMenuList, null, shouldRenderSubmenus ? data.map((_ref2, index) => {
27
- let id = _ref2.id,
28
- title = _ref2.title,
29
- submenu = _ref2.submenu,
30
- type = _ref2.type;
27
+ }, /*#__PURE__*/React.createElement(StyledStartMenuList, null, shouldRenderSubmenus ? data.map(entry => {
28
+ const id = entry.id,
29
+ title = entry.title;
31
30
  let count = 0;
32
31
  // Popricati o ovome kada je selected[id] vrednost 0.
33
32
  if (typeof selected[id] === "string") {
@@ -36,9 +35,9 @@ export const StartMenu = _ref => {
36
35
  var _selected$id;
37
36
  count = (_selected$id = selected[id]) == null ? void 0 : _selected$id.length;
38
37
  }
39
- if (type === "input" || (submenu == null ? void 0 : submenu.length) > 1) {
38
+ if (isFilterEntryVisible(entry, selected)) {
40
39
  return /*#__PURE__*/React.createElement(StyledStartMenuListItem, {
41
- key: "filter-list-item-" + index,
40
+ key: "filter-list-item-" + id,
42
41
  onClick: () => onItemClick(id)
43
42
  }, /*#__PURE__*/React.createElement(StyledStartMenuTitle, null, title), count > 0 ? /*#__PURE__*/React.createElement(Badge, {
44
43
  dimension: 16,
@@ -1 +1 @@
1
- {"version":3,"file":"StartMenu.js","names":["React","useRef","useEffect","StyledStartMenuTitle","StyledStartMenuListItem","StyledStartMenuList","StyledStartMenuNoResults","useResizeObserver","Badge","ArrowRightIcon","StartMenu","_ref","data","selected","onItemClick","style","onHeightChange","shouldRenderSubmenus","emptyFilterText","children","ref","dimensions","height","createElement","map","_ref2","index","id","title","submenu","type","count","_selected$id","length","key","onClick","dimension","value","isStandalone"],"sources":["../../../../src/components/Filter/StartMenu.tsx"],"sourcesContent":["import React, { FC, useRef, useEffect, HTMLAttributes } from \"react\";\n\nimport { DataType, SelectedType } from \"./Filter\";\nimport {\n StyledStartMenuTitle,\n StyledStartMenuListItem,\n StyledStartMenuList,\n StyledStartMenuNoResults,\n} from \"./Styles\";\nimport { useResizeObserver } from \"../../utils\";\nimport { Badge } from \"../Badge\";\nimport { ArrowRightIcon } from \"../Icons\";\n\nexport interface StartMenuProps {\n data: Array<DataType>;\n selected: SelectedType;\n onItemClick: (id: number | string) => void;\n onHeightChange: (height: number) => void;\n shouldRenderSubmenus: boolean;\n emptyFilterText?: string;\n}\n\nexport const StartMenu: FC<StartMenuProps & HTMLAttributes<HTMLDivElement>> = ({\n data,\n selected,\n onItemClick,\n style,\n onHeightChange,\n shouldRenderSubmenus,\n emptyFilterText,\n children,\n}) => {\n const ref = useRef(null);\n const dimensions = useResizeObserver(ref);\n const height = dimensions?.height;\n\n useEffect(() => {\n if (height && height > 0) {\n onHeightChange(height);\n }\n }, [height, onHeightChange]);\n\n return (\n <div style={style} ref={ref}>\n <StyledStartMenuList>\n {shouldRenderSubmenus ? (\n data.map(({ id, title, submenu, type }, index: number) => {\n let count = 0;\n // Popricati o ovome kada je selected[id] vrednost 0.\n if (typeof selected[id] === \"string\") {\n count += 1;\n } else {\n count = selected[id]?.length;\n }\n\n if (type === \"input\" || submenu?.length > 1) {\n return (\n <StyledStartMenuListItem\n key={`filter-list-item-${index}`}\n onClick={() => onItemClick(id)}\n >\n <StyledStartMenuTitle>{title}</StyledStartMenuTitle>\n {count > 0 ? (\n <Badge dimension={16} value={count} isStandalone={true} />\n ) : null}\n <ArrowRightIcon />\n </StyledStartMenuListItem>\n );\n }\n })\n ) : emptyFilterText ? (\n <StyledStartMenuNoResults>{emptyFilterText}</StyledStartMenuNoResults>\n ) : null}\n {children}\n </StyledStartMenuList>\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAQC,MAAM,EAAEC,SAAS,QAAwB,OAAO;AAGpE,SACEC,oBAAoB,EACpBC,uBAAuB,EACvBC,mBAAmB,EACnBC,wBAAwB,QACnB,UAAU;AACjB,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,cAAc,QAAQ,UAAU;AAWzC,OAAO,MAAMC,SAA8D,GAAGC,IAAA,IASxE;EAAA,IARJC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,WAAW,GAAAH,IAAA,CAAXG,WAAW;IACXC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,cAAc,GAAAL,IAAA,CAAdK,cAAc;IACdC,oBAAoB,GAAAN,IAAA,CAApBM,oBAAoB;IACpBC,eAAe,GAAAP,IAAA,CAAfO,eAAe;IACfC,QAAQ,GAAAR,IAAA,CAARQ,QAAQ;EAER,MAAMC,GAAG,GAAGnB,MAAM,CAAC,IAAI,CAAC;EACxB,MAAMoB,UAAU,GAAGd,iBAAiB,CAACa,GAAG,CAAC;EACzC,MAAME,MAAM,GAAGD,UAAU,oBAAVA,UAAU,CAAEC,MAAM;EAEjCpB,SAAS,CAAC,MAAM;IACd,IAAIoB,MAAM,IAAIA,MAAM,GAAG,CAAC,EAAE;MACxBN,cAAc,CAACM,MAAM,CAAC;IACxB;EACF,CAAC,EAAE,CAACA,MAAM,EAAEN,cAAc,CAAC,CAAC;EAE5B,oBACEhB,KAAA,CAAAuB,aAAA;IAAKR,KAAK,EAAEA,KAAM;IAACK,GAAG,EAAEA;EAAI,gBAC1BpB,KAAA,CAAAuB,aAAA,CAAClB,mBAAmB,QACjBY,oBAAoB,GACnBL,IAAI,CAAC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","StyledStartMenuListItem","StyledStartMenuList","StyledStartMenuNoResults","useResizeObserver","Badge","ArrowRightIcon","StartMenu","_ref","data","selected","onItemClick","style","onHeightChange","shouldRenderSubmenus","emptyFilterText","children","ref","dimensions","height","createElement","map","entry","id","title","count","_selected$id","length","key","onClick","dimension","value","isStandalone"],"sources":["../../../../src/components/Filter/StartMenu.tsx"],"sourcesContent":["import React, { FC, useRef, useEffect, HTMLAttributes } from \"react\";\n\nimport { DataType, SelectedType } from \"./Filter\";\nimport { isFilterEntryVisible } from \"./isFilterEntryVisible\";\nimport {\n StyledStartMenuTitle,\n StyledStartMenuListItem,\n StyledStartMenuList,\n StyledStartMenuNoResults,\n} from \"./Styles\";\nimport { useResizeObserver } from \"../../utils\";\nimport { Badge } from \"../Badge\";\nimport { ArrowRightIcon } from \"../Icons\";\n\nexport interface StartMenuProps {\n data: Array<DataType>;\n selected: SelectedType;\n onItemClick: (id: number | string) => void;\n onHeightChange: (height: number) => void;\n shouldRenderSubmenus: boolean;\n emptyFilterText?: string;\n}\n\nexport const StartMenu: FC<StartMenuProps & HTMLAttributes<HTMLDivElement>> = ({\n data,\n selected,\n onItemClick,\n style,\n onHeightChange,\n shouldRenderSubmenus,\n emptyFilterText,\n children,\n}) => {\n const ref = useRef(null);\n const dimensions = useResizeObserver(ref);\n const height = dimensions?.height;\n\n useEffect(() => {\n if (height && height > 0) {\n onHeightChange(height);\n }\n }, [height, onHeightChange]);\n\n return (\n <div style={style} ref={ref}>\n <StyledStartMenuList>\n {shouldRenderSubmenus ? (\n data.map((entry) => {\n const { id, title } = entry;\n let count = 0;\n // Popricati o ovome kada je selected[id] vrednost 0.\n if (typeof selected[id] === \"string\") {\n count += 1;\n } else {\n count = selected[id]?.length;\n }\n\n if (isFilterEntryVisible(entry, selected)) {\n return (\n <StyledStartMenuListItem\n key={`filter-list-item-${id}`}\n onClick={() => onItemClick(id)}\n >\n <StyledStartMenuTitle>{title}</StyledStartMenuTitle>\n {count > 0 ? (\n <Badge dimension={16} value={count} isStandalone={true} />\n ) : null}\n <ArrowRightIcon />\n </StyledStartMenuListItem>\n );\n }\n })\n ) : emptyFilterText ? (\n <StyledStartMenuNoResults>{emptyFilterText}</StyledStartMenuNoResults>\n ) : null}\n {children}\n </StyledStartMenuList>\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAQC,MAAM,EAAEC,SAAS,QAAwB,OAAO;AAGpE,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SACEC,oBAAoB,EACpBC,uBAAuB,EACvBC,mBAAmB,EACnBC,wBAAwB,QACnB,UAAU;AACjB,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,cAAc,QAAQ,UAAU;AAWzC,OAAO,MAAMC,SAA8D,GAAGC,IAAA,IASxE;EAAA,IARJC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,WAAW,GAAAH,IAAA,CAAXG,WAAW;IACXC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,cAAc,GAAAL,IAAA,CAAdK,cAAc;IACdC,oBAAoB,GAAAN,IAAA,CAApBM,oBAAoB;IACpBC,eAAe,GAAAP,IAAA,CAAfO,eAAe;IACfC,QAAQ,GAAAR,IAAA,CAARQ,QAAQ;EAER,MAAMC,GAAG,GAAGpB,MAAM,CAAC,IAAI,CAAC;EACxB,MAAMqB,UAAU,GAAGd,iBAAiB,CAACa,GAAG,CAAC;EACzC,MAAME,MAAM,GAAGD,UAAU,oBAAVA,UAAU,CAAEC,MAAM;EAEjCrB,SAAS,CAAC,MAAM;IACd,IAAIqB,MAAM,IAAIA,MAAM,GAAG,CAAC,EAAE;MACxBN,cAAc,CAACM,MAAM,CAAC;IACxB;EACF,CAAC,EAAE,CAACA,MAAM,EAAEN,cAAc,CAAC,CAAC;EAE5B,oBACEjB,KAAA,CAAAwB,aAAA;IAAKR,KAAK,EAAEA,KAA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+1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Filter/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Filter/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from "./Filter";
2
+ export * from "./isFilterEntryVisible";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/Filter/index.ts"],"sourcesContent":["export * from \"./Filter\";\n"],"mappings":"AAAA,cAAc,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/Filter/index.ts"],"sourcesContent":["export * from \"./Filter\";\nexport * from \"./isFilterEntryVisible\";\n"],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,wBAAwB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { DataType, SelectedType } from "./Filter";
2
+ export declare const isFilterEntryVisible: (entry: DataType, selected: SelectedType) => boolean;
3
+ //# sourceMappingURL=isFilterEntryVisible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isFilterEntryVisible.d.ts","sourceRoot":"","sources":["../../../../src/components/Filter/isFilterEntryVisible.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAuBvD,eAAO,MAAM,oBAAoB,GAC/B,OAAO,QAAQ,EACf,UAAU,YAAY,KACrB,OAGiC,CAAC"}
@@ -0,0 +1,14 @@
1
+ const toSelectedIds = value => [].concat(value != null ? value : []).map(String);
2
+ const toOptionIds = submenu => (submenu != null ? submenu : []).flatMap(option => "options" in option && Array.isArray(option.options) ? option.options.map(_ref => {
3
+ let id = _ref.id;
4
+ return String(id);
5
+ }) : [String(option.id)]);
6
+ const hasSelectedOption = (entry, selected) => {
7
+ const optionIds = toOptionIds(entry.submenu);
8
+ return toSelectedIds(selected[entry.id]).some(id => optionIds.includes(id));
9
+ };
10
+ export const isFilterEntryVisible = (entry, selected) => {
11
+ var _entry$submenu;
12
+ return entry.type === "input" || ((_entry$submenu = entry.submenu) == null ? void 0 : _entry$submenu.length) > 1 || hasSelectedOption(entry, selected);
13
+ };
14
+ //# sourceMappingURL=isFilterEntryVisible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isFilterEntryVisible.js","names":["toSelectedIds","value","concat","map","String","toOptionIds","submenu","flatMap","option","Array","isArray","options","_ref","id","hasSelectedOption","entry","selected","optionIds","some","includes","isFilterEntryVisible","_entry$submenu","type","length"],"sources":["../../../../src/components/Filter/isFilterEntryVisible.ts"],"sourcesContent":["import type { DataType, SelectedType } from \"./Filter\";\nimport type { IOptionGroupProps, IOptionItemProps } from \"../Select\";\n\ntype SelectedValue = SelectedType[keyof SelectedType] | string | number;\n\nconst toSelectedIds = (value: SelectedValue | undefined): string[] =>\n ([] as Array<string | number>).concat(value ?? []).map(String);\n\nconst toOptionIds = (\n submenu?: Array<IOptionGroupProps | IOptionItemProps> | null\n): string[] =>\n (submenu ?? []).flatMap((option) =>\n \"options\" in option && Array.isArray(option.options)\n ? option.options.map(({ id }) => String(id))\n : [String(option.id)]\n );\n\nconst hasSelectedOption = (entry: DataType, selected: SelectedType) => {\n const optionIds = toOptionIds(entry.submenu);\n\n return toSelectedIds(selected[entry.id]).some((id) => optionIds.includes(id));\n};\n\nexport const isFilterEntryVisible = (\n entry: DataType,\n selected: SelectedType\n): boolean =>\n entry.type === \"input\" ||\n entry.submenu?.length > 1 ||\n hasSelectedOption(entry, selected);\n"],"mappings":"AAKA,MAAMA,aAAa,GAAIC,KAAgC,IACpD,EAAE,CAA4BC,MAAM,CAACD,KAAK,WAALA,KAAK,GAAI,EAAE,CAAC,CAACE,GAAG,CAACC,MAAM,CAAC;AAEhE,MAAMC,WAAW,GACfC,OAA4D,IAE5D,CAACA,OAAO,WAAPA,OAAO,GAAI,EAAE,EAAEC,OAAO,CAAEC,MAAM,IAC7B,SAAS,IAAIA,MAAM,IAAIC,KAAK,CAACC,OAAO,CAACF,MAAM,CAACG,OAAO,CAAC,GAChDH,MAAM,CAACG,OAAO,CAACR,GAAG,CAACS,IAAA;EAAA,IAAGC,EAAE,GAAAD,IAAA,CAAFC,EAAE;EAAA,OAAOT,MAAM,CAACS,EAAE,CAAC;AAAA,EAAC,GAC1C,CAACT,MAAM,CAACI,MAAM,CAACK,EAAE,CAAC,CACxB,CAAC;AAEH,MAAMC,iBAAiB,GAAGA,CAACC,KAAe,EAAEC,QAAsB,KAAK;EACrE,MAAMC,SAAS,GAAGZ,WAAW,CAACU,KAAK,CAACT,OAAO,CAAC;EAE5C,OAAON,aAAa,CAACgB,QAAQ,CAACD,KAAK,CAACF,EAAE,CAAC,CAAC,CAACK,IAAI,CAAEL,EAAE,IAAKI,SAAS,CAACE,QAAQ,CAACN,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,OAAO,MAAMO,oBAAoB,GAAGA,CAClCL,KAAe,EACfC,QAAsB;EAAA,IAAAK,cAAA;EAAA,OAEtBN,KAAK,CAACO,IAAI,KAAK,OAAO,IACtB,EAAAD,cAAA,GAAAN,KAAK,CAACT,OAAO,qBAAbe,cAAA,CAAeE,MAAM,IAAG,CAAC,IACzBT,iBAAiB,CAACC,KAAK,EAAEC,QAAQ,CAAC;AAAA","ignoreList":[]}
package/dist/index.js CHANGED
@@ -39913,6 +39913,28 @@
39913
39913
  }, clearLabel)));
39914
39914
  };
39915
39915
 
39916
+ var toSelectedIds = function toSelectedIds(value) {
39917
+ return [].concat(value !== null && value !== void 0 ? value : []).map(String);
39918
+ };
39919
+ var toOptionIds = function toOptionIds(submenu) {
39920
+ return (submenu !== null && submenu !== void 0 ? submenu : []).flatMap(function (option) {
39921
+ return "options" in option && Array.isArray(option.options) ? option.options.map(function (_ref) {
39922
+ var id = _ref.id;
39923
+ return String(id);
39924
+ }) : [String(option.id)];
39925
+ });
39926
+ };
39927
+ var hasSelectedOption = function hasSelectedOption(entry, selected) {
39928
+ var optionIds = toOptionIds(entry.submenu);
39929
+ return toSelectedIds(selected[entry.id]).some(function (id) {
39930
+ return optionIds.includes(id);
39931
+ });
39932
+ };
39933
+ var isFilterEntryVisible = function isFilterEntryVisible(entry, selected) {
39934
+ var _entry$submenu;
39935
+ return entry.type === "input" || ((_entry$submenu = entry.submenu) === null || _entry$submenu === void 0 ? void 0 : _entry$submenu.length) > 1 || hasSelectedOption(entry, selected);
39936
+ };
39937
+
39916
39938
  var StartMenu = function StartMenu(_ref) {
39917
39939
  var data = _ref.data,
39918
39940
  selected = _ref.selected,
@@ -39933,11 +39955,9 @@
39933
39955
  return /*#__PURE__*/React__default["default"].createElement("div", {
39934
39956
  style: style,
39935
39957
  ref: ref
39936
- }, /*#__PURE__*/React__default["default"].createElement(StyledStartMenuList, null, shouldRenderSubmenus ? data.map(function (_ref2, index) {
39937
- var id = _ref2.id,
39938
- title = _ref2.title,
39939
- submenu = _ref2.submenu,
39940
- type = _ref2.type;
39958
+ }, /*#__PURE__*/React__default["default"].createElement(StyledStartMenuList, null, shouldRenderSubmenus ? data.map(function (entry) {
39959
+ var id = entry.id,
39960
+ title = entry.title;
39941
39961
  var count = 0;
39942
39962
  // Popricati o ovome kada je selected[id] vrednost 0.
39943
39963
  if (typeof selected[id] === "string") {
@@ -39946,9 +39966,9 @@
39946
39966
  var _selected$id;
39947
39967
  count = (_selected$id = selected[id]) === null || _selected$id === void 0 ? void 0 : _selected$id.length;
39948
39968
  }
39949
- if (type === "input" || (submenu === null || submenu === void 0 ? void 0 : submenu.length) > 1) {
39969
+ if (isFilterEntryVisible(entry, selected)) {
39950
39970
  return /*#__PURE__*/React__default["default"].createElement(StyledStartMenuListItem, {
39951
- key: "filter-list-item-".concat(index),
39971
+ key: "filter-list-item-".concat(id),
39952
39972
  onClick: function onClick() {
39953
39973
  return onItemClick(id);
39954
39974
  }
@@ -40189,6 +40209,14 @@
40189
40209
  setMenu("index");
40190
40210
  setIsLeft(false);
40191
40211
  }, []);
40212
+ React.useEffect(function () {
40213
+ if (menu !== "index" && !data.some(function (_ref2) {
40214
+ var id = _ref2.id;
40215
+ return id === menu;
40216
+ })) {
40217
+ setIndex();
40218
+ }
40219
+ }, [data, menu, setIndex]);
40192
40220
  var handleChange = React.useCallback(function (selectedArray) {
40193
40221
  var newFilters = {};
40194
40222
  if (selectedArray.length) {
@@ -40245,17 +40273,10 @@
40245
40273
  return c;
40246
40274
  }, [filter]);
40247
40275
  var shouldRenderSubmenus = React.useMemo(function () {
40248
- if (data.length === 0) {
40249
- return false;
40250
- }
40251
- for (var entry of data) {
40252
- var _entry$submenu;
40253
- if (entry.type === "input" || ((_entry$submenu = entry.submenu) === null || _entry$submenu === void 0 ? void 0 : _entry$submenu.length) > 1) {
40254
- return true;
40255
- }
40256
- }
40257
- return false;
40258
- }, [data]);
40276
+ return data.some(function (entry) {
40277
+ return isFilterEntryVisible(entry, filter);
40278
+ });
40279
+ }, [data, filter]);
40259
40280
  var menuElement = /*#__PURE__*/React__default["default"].createElement(StyledMenu, {
40260
40281
  open: open,
40261
40282
  onOpen: handleOpen,
@@ -40294,24 +40315,24 @@
40294
40315
  onItemClick: handleItemClick,
40295
40316
  shouldRenderSubmenus: shouldRenderSubmenus,
40296
40317
  emptyFilterText: emptyFilterText
40297
- }, children))), shouldRenderSubmenus && data.map(function (_ref2, index) {
40318
+ }, children))), (shouldRenderSubmenus || menu !== "index") && data.map(function (_ref3) {
40298
40319
  var _filter$id$, _filter$id, _filter$id2;
40299
- var id = _ref2.id,
40300
- title = _ref2.title,
40301
- submenu = _ref2.submenu,
40302
- searchPlaceholder = _ref2.searchPlaceholder,
40303
- disableInternalSort = _ref2.disableInternalSort,
40304
- isSingleSelect = _ref2.isSingleSelect,
40305
- defaultValue = _ref2.defaultValue,
40306
- _ref2$type = _ref2.type,
40307
- submenuType = _ref2$type === void 0 ? "select" : _ref2$type,
40308
- inputPlaceholder = _ref2.inputPlaceholder,
40309
- _ref2$saveLabel = _ref2.saveLabel,
40310
- saveLabel = _ref2$saveLabel === void 0 ? "Save" : _ref2$saveLabel,
40311
- clearLabel = _ref2.clearLabel,
40312
- rest = _objectWithoutProperties(_ref2, _excluded$H);
40320
+ var id = _ref3.id,
40321
+ title = _ref3.title,
40322
+ submenu = _ref3.submenu,
40323
+ searchPlaceholder = _ref3.searchPlaceholder,
40324
+ disableInternalSort = _ref3.disableInternalSort,
40325
+ isSingleSelect = _ref3.isSingleSelect,
40326
+ defaultValue = _ref3.defaultValue,
40327
+ _ref3$type = _ref3.type,
40328
+ submenuType = _ref3$type === void 0 ? "select" : _ref3$type,
40329
+ inputPlaceholder = _ref3.inputPlaceholder,
40330
+ _ref3$saveLabel = _ref3.saveLabel,
40331
+ saveLabel = _ref3$saveLabel === void 0 ? "Save" : _ref3$saveLabel,
40332
+ clearLabel = _ref3.clearLabel,
40333
+ rest = _objectWithoutProperties(_ref3, _excluded$H);
40313
40334
  return /*#__PURE__*/React__default["default"].createElement(SlideLeftRightTransition, {
40314
- key: "filter-submenu-".concat(index),
40335
+ key: "filter-submenu-".concat(id),
40315
40336
  in: menu === id,
40316
40337
  direction: isLeft ? "left" : "right",
40317
40338
  onEnter: handleHeight,
@@ -52605,6 +52626,7 @@
52605
52626
  exports.hasSelectedText = hasSelectedText;
52606
52627
  exports.inkOfColor = inkOfColor;
52607
52628
  exports.isDarkTheme = isDarkTheme;
52629
+ exports.isFilterEntryVisible = isFilterEntryVisible;
52608
52630
  exports.isInTopLayer = isInTopLayer;
52609
52631
  exports.isOptionGroup = isOptionGroup;
52610
52632
  exports.isOptionSeparator = isOptionSeparator;