@synerise/ds-cascader 1.1.27 → 1.1.29

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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.1.29](https://github.com/Synerise/synerise-design/compare/@synerise/ds-cascader@1.1.28...@synerise/ds-cascader@1.1.29) (2026-04-10)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-cascader
9
+
10
+ ## [1.1.28](https://github.com/Synerise/synerise-design/compare/@synerise/ds-cascader@1.1.27...@synerise/ds-cascader@1.1.28) (2026-04-01)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **cascader:** simplified nested types ([c6e42a7](https://github.com/Synerise/synerise-design/commit/c6e42a7d22375cddaeb4d5cb13f9f528ede83fe1))
15
+
6
16
  ## [1.1.27](https://github.com/Synerise/synerise-design/compare/@synerise/ds-cascader@1.1.26...@synerise/ds-cascader@1.1.27) (2026-03-24)
7
17
 
8
18
  **Note:** Version bump only for package @synerise/ds-cascader
package/dist/Cascader.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState, useRef, useMemo, useEffect, useCallback } from "react";
2
+ import { useState, useRef, useLayoutEffect, useMemo, useEffect, useCallback } from "react";
3
3
  import { theme } from "@synerise/ds-core";
4
4
  import Icon, { SearchM } from "@synerise/ds-icon";
5
5
  import SearchBar from "@synerise/ds-search-bar";
@@ -36,7 +36,16 @@ const Cascader = ({
36
36
  } = useResize(searchResultsContainer);
37
37
  const previousCategory = enteredCategories[enteredCategories.length - 2];
38
38
  const isSearching = !!paths && searchQuery.length > 0;
39
- const categoriesMaxHeight = maxHeight ? Math.floor((maxHeight - Number(categoriesContainer?.current?.offsetTop)) / CATEGORY_ITEM_HEIGHT) * CATEGORY_ITEM_HEIGHT + VERTICAL_PADDING_OFFSET : void 0;
39
+ const [categoriesMaxHeight, setCategoriesMaxHeight] = useState(void 0);
40
+ useLayoutEffect(() => {
41
+ if (!maxHeight) {
42
+ setCategoriesMaxHeight(void 0);
43
+ return;
44
+ }
45
+ const offsetTop = categoriesContainer.current?.offsetTop ?? 0;
46
+ const calculated = Math.floor((maxHeight - offsetTop) / CATEGORY_ITEM_HEIGHT) * CATEGORY_ITEM_HEIGHT + VERTICAL_PADDING_OFFSET;
47
+ setCategoriesMaxHeight((prev) => prev === calculated ? prev : calculated);
48
+ });
40
49
  const calculateVisibleRows = useMemo(() => {
41
50
  return Math.floor((height - VERTICAL_PADDING_OFFSET) / BREADCRUMB_ITEM_HEIGHT);
42
51
  }, [height]);
@@ -121,7 +130,7 @@ const Cascader = ({
121
130
  }) => {
122
131
  setScrollTop(currentTarget.scrollTop);
123
132
  }, children: /* @__PURE__ */ jsx(BreadcrumbsList, { width: "calc(100% - 8px)", visibleRows: calculateVisibleRows, rowHeight: BREADCRUMB_ITEM_HEIGHT, paths: filteredPaths, highlight: searchQuery, onBreadCrumbClick: handleBreadCrumbClick, scrollTop, selectedIds }) }),
124
- /* @__PURE__ */ jsx(Navigation, { backActionVisible, breadcrumbVisible: !searchQuery && !!activeCategory.path, onPathClick, onHomeIconClick, previousCategory, activeCategory }),
133
+ /* @__PURE__ */ jsx(Navigation, { backActionVisible, breadcrumbVisible: !searchQuery && activeCategory.path.length > 0, onPathClick, onHomeIconClick, previousCategory, activeCategory }),
125
134
  !searchQuery && /* @__PURE__ */ jsx("div", { ref: categoriesContainer, children: /* @__PURE__ */ jsx(CascaderScrollbar, { maxHeight: categoriesMaxHeight, searching: isSearching, absolute: isSearching, onScroll: ({
126
135
  currentTarget
127
136
  }) => {
@@ -7,7 +7,7 @@ const InputWrapper = /* @__PURE__ */ styled.div.withConfig({
7
7
  const SearchResults = /* @__PURE__ */ styled.div.withConfig({
8
8
  displayName: "Cascaderstyles__SearchResults",
9
9
  componentId: "sc-endrj4-1"
10
- })(["display:", ";width:100%;background:", ";border-radius:0 0 3px 3px;padding:8px 0 8px 8px;box-shadow:0 16px 32px 0 rgba(35,41,54,0.05);z-index:10;"], (props) => !props.visible ? "none" : "block", (props) => props.theme.palette.white);
10
+ })(["position:relative;display:", ";width:100%;background:", ";border-radius:0 0 3px 3px;padding:8px 0 8px 8px;box-shadow:0 16px 32px 0 rgba(35,41,54,0.05);z-index:10;"], (props) => !props.visible ? "none" : "block", (props) => props.theme.palette.white);
11
11
  const CascaderScrollbar = /* @__PURE__ */ styled(Scrollbar).withConfig({
12
12
  displayName: "Cascaderstyles__CascaderScrollbar",
13
13
  componentId: "sc-endrj4-2"
@@ -4,6 +4,7 @@ export type Category = {
4
4
  id: ReactText;
5
5
  name: string;
6
6
  path: string[];
7
+ children?: Category[];
7
8
  };
8
9
  export type CascaderProps = {
9
10
  categorySuffix: ReactNode;
@@ -24,10 +24,7 @@ const CategoriesList = ({
24
24
  onSuffixelClick && onSuffixelClick(item);
25
25
  }, [onSuffixelClick]);
26
26
  const renderSuffix = (item) => /* @__PURE__ */ jsx(CategoriesSuffix, { onClick: (event) => onSuffixelClickHandler(item, event), children: selectedIds.includes(item.id) ? /* @__PURE__ */ jsx(Icon, { color: theme.palette["green-600"], component: /* @__PURE__ */ jsx(CheckS, {}) }) : suffixel });
27
- return /* @__PURE__ */ jsx(Fragment, { children: Object.keys(rootCategory).filter((key) => rootCategory[key]?.name).map((key) => {
28
- const item = rootCategory[key];
29
- return /* @__PURE__ */ jsx(ListItem, { text: item.name, type: selectedIds.includes(item.id) ? void 0 : "select", suffixel: renderSuffix(item), parent: hasNestedCategories(item), onClick: () => onCategoryClickHandler(item) }, `${item.id}`);
30
- }) });
27
+ return /* @__PURE__ */ jsx(Fragment, { children: (rootCategory.children ?? []).map((item) => /* @__PURE__ */ jsx(ListItem, { text: item.name, type: selectedIds.includes(item.id) ? void 0 : "select", suffixel: renderSuffix(item), parent: hasNestedCategories(item), onClick: () => onCategoryClickHandler(item) }, `${item.id}`)) });
31
28
  };
32
29
  export {
33
30
  CategoriesList,
package/dist/utils.js CHANGED
@@ -5,42 +5,30 @@ const searchCategoryWithId = (category, id) => {
5
5
  if (category.id === id) {
6
6
  return category;
7
7
  }
8
- let result, property;
9
- const keys = Object.keys(category);
10
- for (let i = 0; i < keys.length; i += 1) {
11
- property = keys[i];
12
- if (Object.prototype.hasOwnProperty.call(category, property) && // @ts-expect-error rootCategory is in fact more than what Category type defines
13
- // apart from id, name and path it can have nested categories with any key
14
- // STOR-1904
15
- typeof category[property] === "object") {
16
- result = searchCategoryWithId(category[property], id);
8
+ if (category.children) {
9
+ for (const child of category.children) {
10
+ const result = searchCategoryWithId(child, id);
17
11
  if (result) {
18
12
  return result;
19
13
  }
20
14
  }
21
15
  }
22
- return result;
16
+ return void 0;
23
17
  };
24
18
  const getAllPaths = (category, resultsArray) => {
25
- let results = resultsArray || [];
19
+ const results = resultsArray || [];
26
20
  if (category.path && category.path.length > 0) {
27
21
  results.push({
28
22
  path: category.path,
29
23
  id: category.id
30
24
  });
31
25
  }
32
- let property;
33
- const keys = Object.keys(category);
34
- for (let i = 0; i < keys.length; i += 1) {
35
- property = keys[i];
36
- if (Object.prototype.hasOwnProperty.call(category, property) && // @ts-expect-error rootCategory is in fact more than what Category type defines
37
- // apart from id, name and path it can have nested categories with any key
38
- // STOR-1904
39
- typeof category[property] === "object") {
40
- results = getAllPaths(category[property], results);
26
+ if (category.children) {
27
+ for (const child of category.children) {
28
+ getAllPaths(child, results);
41
29
  }
42
30
  }
43
- return results && results.length > 0 ? results : void 0;
31
+ return results.length > 0 ? results : void 0;
44
32
  };
45
33
  const filterPaths = (paths, searchQuery) => {
46
34
  const pathsToBeFiltered = [...paths];
@@ -52,19 +40,7 @@ const filterPaths = (paths, searchQuery) => {
52
40
  return filtered;
53
41
  };
54
42
  const hasNestedCategories = (category) => {
55
- let property;
56
- const keys = Object.keys(category);
57
- for (let i = 0; i < keys.length; i += 1) {
58
- property = keys[i];
59
- if (Object.prototype.hasOwnProperty.call(category, property) && // @ts-expect-error rootCategory is in fact more than what Category type defines
60
- // apart from id, name and path it can have nested categories with any key
61
- typeof category[property] === "object" && // @ts-expect-error rootCategory is in fact more than what Category type defines
62
- // apart from id, name and path it can have nested categories with any key
63
- Object.prototype.toString.call(category[property]) === "[object Object]") {
64
- return true;
65
- }
66
- }
67
- return false;
43
+ return (category.children?.length ?? 0) > 0;
68
44
  };
69
45
  export {
70
46
  filterPaths,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-cascader",
3
- "version": "1.1.27",
3
+ "version": "1.1.29",
4
4
  "description": "Cascader UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -17,10 +17,7 @@
17
17
  },
18
18
  "scripts": {
19
19
  "build": "vite build",
20
- "build:css": "node ../../../scripts/style/less.js",
21
- "build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
22
20
  "build:watch": "vite build --watch",
23
- "defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
24
21
  "pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
25
22
  "prepublish": "pnpm run build",
26
23
  "test": "vitest run",
@@ -35,13 +32,13 @@
35
32
  ],
36
33
  "types": "dist/index.d.ts",
37
34
  "dependencies": {
38
- "@synerise/ds-divider": "^1.3.2",
39
- "@synerise/ds-icon": "^1.15.1",
40
- "@synerise/ds-list-item": "^1.4.10",
41
- "@synerise/ds-scrollbar": "^1.2.17",
42
- "@synerise/ds-search": "^1.5.10",
43
- "@synerise/ds-search-bar": "^1.4.20",
44
- "@synerise/ds-utils": "^1.7.1"
35
+ "@synerise/ds-divider": "^1.3.4",
36
+ "@synerise/ds-icon": "^1.15.3",
37
+ "@synerise/ds-list-item": "^1.4.12",
38
+ "@synerise/ds-scrollbar": "^1.2.19",
39
+ "@synerise/ds-search": "^1.5.12",
40
+ "@synerise/ds-search-bar": "^1.4.22",
41
+ "@synerise/ds-utils": "^1.8.0"
45
42
  },
46
43
  "devDependencies": {
47
44
  "vitest": "4"
@@ -51,5 +48,5 @@
51
48
  "react": ">=16.9.0 <= 18.3.1",
52
49
  "styled-components": "^5.3.3"
53
50
  },
54
- "gitHead": "e4ecca8944fc9b41c1b9d59c8bcad5e5e2013225"
51
+ "gitHead": "ce3c6d75efe8573a2b274853636f959b75a6cd32"
55
52
  }