@synerise/ds-cascader 1.1.26 → 1.1.28

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/Cascader.d.ts +2 -2
  3. package/dist/Cascader.js +94 -143
  4. package/dist/Cascader.styles.d.ts +6 -6
  5. package/dist/Cascader.styles.js +19 -17
  6. package/dist/Cascader.types.d.ts +2 -1
  7. package/dist/Cascader.types.js +1 -1
  8. package/dist/Elements/BackAction/BackAction.d.ts +2 -2
  9. package/dist/Elements/BackAction/BackAction.js +18 -16
  10. package/dist/Elements/BackAction/BackAction.styles.d.ts +4 -4
  11. package/dist/Elements/BackAction/BackAction.styles.js +15 -17
  12. package/dist/Elements/BackAction/BackAction.types.d.ts +1 -1
  13. package/dist/Elements/BackAction/BackAction.types.js +1 -1
  14. package/dist/Elements/BottomAction/BottomAction.d.ts +2 -2
  15. package/dist/Elements/BottomAction/BottomAction.js +14 -13
  16. package/dist/Elements/BottomAction/BottomAction.styles.d.ts +3 -3
  17. package/dist/Elements/BottomAction/BottomAction.styles.js +11 -14
  18. package/dist/Elements/BottomAction/BottomAction.types.d.ts +1 -1
  19. package/dist/Elements/BottomAction/BottomAction.types.js +1 -1
  20. package/dist/Elements/Breadcrumb/Breadcrumb.d.ts +2 -2
  21. package/dist/Elements/Breadcrumb/Breadcrumb.js +47 -73
  22. package/dist/Elements/Breadcrumb/Breadcrumb.styles.d.ts +13 -13
  23. package/dist/Elements/Breadcrumb/Breadcrumb.styles.js +36 -46
  24. package/dist/Elements/Breadcrumb/Breadcrumb.types.d.ts +2 -2
  25. package/dist/Elements/Breadcrumb/Breadcrumb.types.js +1 -1
  26. package/dist/Elements/Breadcrumb/utils.d.ts +1 -1
  27. package/dist/Elements/Breadcrumb/utils.js +15 -9
  28. package/dist/Elements/BreadcrumbsList/BreadcrumbsList.d.ts +4 -4
  29. package/dist/Elements/BreadcrumbsList/BreadcrumbsList.js +28 -35
  30. package/dist/Elements/BreadcrumbsList/BreadcrumbsList.types.d.ts +2 -2
  31. package/dist/Elements/BreadcrumbsList/BreadcrumbsList.types.js +1 -1
  32. package/dist/Elements/CategoriesList/CategoriesList.d.ts +2 -2
  33. package/dist/Elements/CategoriesList/CategoriesList.js +23 -49
  34. package/dist/Elements/CategoriesList/CategoriesList.types.d.ts +2 -2
  35. package/dist/Elements/CategoriesList/CategoriesList.types.js +1 -1
  36. package/dist/Elements/Navigation/Navigation.d.ts +2 -2
  37. package/dist/Elements/Navigation/Navigation.js +32 -40
  38. package/dist/Elements/Navigation/Navigation.types.d.ts +1 -1
  39. package/dist/Elements/Navigation/Navigation.types.js +1 -1
  40. package/dist/index.js +6 -2
  41. package/dist/modules.d.js +1 -1
  42. package/dist/modules.d.ts +0 -0
  43. package/dist/utils.d.ts +1 -1
  44. package/dist/utils.js +27 -57
  45. package/package.json +11 -11
@@ -1,43 +1,35 @@
1
- import React from 'react';
2
- import { theme } from '@synerise/ds-core';
3
- import Divider from '@synerise/ds-divider';
4
- import Icon, { HomeM } from '@synerise/ds-icon';
5
- import * as S from '../../Cascader.styles';
6
- import { BackAction } from '../BackAction/BackAction';
7
- import { Breadcrumb } from '../Breadcrumb/Breadcrumb';
8
- export var Navigation = function Navigation(_ref) {
9
- var backActionVisible = _ref.backActionVisible,
10
- onHomeIconClick = _ref.onHomeIconClick,
11
- onPathClick = _ref.onPathClick,
12
- activeCategory = _ref.activeCategory,
13
- previousCategory = _ref.previousCategory,
14
- breadcrumbVisible = _ref.breadcrumbVisible;
15
- var renderBreadcrumbs = function renderBreadcrumbs() {
16
- return breadcrumbVisible && activeCategory ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Breadcrumb, {
17
- isNavigation: true,
18
- path: activeCategory.path,
19
- onPathClick: onPathClick,
20
- gradientOverlap: true,
21
- highlightActivePath: true,
22
- prefixel: /*#__PURE__*/React.createElement(S.BreadcrumbPrefix, {
23
- onClick: onHomeIconClick
24
- }, /*#__PURE__*/React.createElement(Icon, {
25
- component: /*#__PURE__*/React.createElement(HomeM, null),
26
- color: theme.palette['grey-600']
27
- })),
28
- compact: true
29
- }), /*#__PURE__*/React.createElement(S.DividerContainer, null, /*#__PURE__*/React.createElement(Divider, {
30
- dashed: true
31
- }))) : null;
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { theme } from "@synerise/ds-core";
3
+ import Divider from "@synerise/ds-divider";
4
+ import Icon, { HomeM } from "@synerise/ds-icon";
5
+ import { BreadcrumbPrefix, DividerContainer } from "../../Cascader.styles.js";
6
+ import { BackAction } from "../BackAction/BackAction.js";
7
+ import { Breadcrumb } from "../Breadcrumb/Breadcrumb.js";
8
+ const Navigation = ({
9
+ backActionVisible,
10
+ onHomeIconClick,
11
+ onPathClick,
12
+ activeCategory,
13
+ previousCategory,
14
+ breadcrumbVisible
15
+ }) => {
16
+ const renderBreadcrumbs = () => {
17
+ return breadcrumbVisible && activeCategory ? /* @__PURE__ */ jsxs(Fragment, { children: [
18
+ /* @__PURE__ */ jsx(Breadcrumb, { isNavigation: true, path: activeCategory.path, onPathClick, gradientOverlap: true, highlightActivePath: true, prefixel: /* @__PURE__ */ jsx(BreadcrumbPrefix, { onClick: onHomeIconClick, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(HomeM, {}), color: theme.palette["grey-600"] }) }), compact: true }),
19
+ /* @__PURE__ */ jsx(DividerContainer, { children: /* @__PURE__ */ jsx(Divider, { dashed: true }) })
20
+ ] }) : null;
32
21
  };
33
- var renderBackAction = function renderBackAction() {
34
- return backActionVisible && previousCategory ? /*#__PURE__*/React.createElement(BackAction, {
35
- label: previousCategory.name,
36
- onClick: function onClick() {
37
- onPathClick(previousCategory.name);
38
- }
39
- }) : null;
22
+ const renderBackAction = () => {
23
+ return backActionVisible && previousCategory ? /* @__PURE__ */ jsx(BackAction, { label: previousCategory.name, onClick: () => {
24
+ onPathClick(previousCategory.name);
25
+ } }) : null;
40
26
  };
41
- return /*#__PURE__*/React.createElement(React.Fragment, null, renderBreadcrumbs(), renderBackAction());
27
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
28
+ renderBreadcrumbs(),
29
+ renderBackAction()
30
+ ] });
31
+ };
32
+ export {
33
+ Navigation,
34
+ Navigation as default
42
35
  };
43
- export default Navigation;
@@ -1,4 +1,4 @@
1
- import type { Category } from '../../Cascader.types';
1
+ import { Category } from '../../Cascader.types';
2
2
  export type NavigationProps = {
3
3
  breadcrumbVisible?: boolean;
4
4
  backActionVisible?: boolean;
@@ -1 +1 @@
1
- export {};
1
+
package/dist/index.js CHANGED
@@ -1,2 +1,6 @@
1
- export { default } from './Cascader';
2
- export { Breadcrumb } from './Elements/Breadcrumb/Breadcrumb';
1
+ import { Cascader } from "./Cascader.js";
2
+ import { Breadcrumb } from "./Elements/Breadcrumb/Breadcrumb.js";
3
+ export {
4
+ Breadcrumb,
5
+ Cascader as default
6
+ };
package/dist/modules.d.js CHANGED
@@ -1 +1 @@
1
- import '@testing-library/jest-dom';
1
+ import "@testing-library/jest-dom";
File without changes
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Category, type Path } from './Cascader.types';
1
+ import { Category, Path } from './Cascader.types';
2
2
  export declare const searchCategoryWithId: (category: Category, id: string | number) => Category | undefined;
3
3
  export declare const getAllPaths: (category: Category, resultsArray?: Path[]) => Path[] | undefined;
4
4
  export declare const filterPaths: (paths: Path[], searchQuery: string) => Path[];
package/dist/utils.js CHANGED
@@ -1,80 +1,50 @@
1
- var _searchCategoryWithId = function searchCategoryWithId(category, id) {
2
- if (id === undefined) {
3
- return undefined;
1
+ const searchCategoryWithId = (category, id) => {
2
+ if (id === void 0) {
3
+ return void 0;
4
4
  }
5
5
  if (category.id === id) {
6
6
  return category;
7
7
  }
8
- var result, property;
9
- var keys = Object.keys(category);
10
- for (var i = 0; i < keys.length; i += 1) {
11
- property = keys[i];
12
- if (Object.prototype.hasOwnProperty.call(category, property) &&
13
- // @ts-expect-error rootCategory is in fact more than what Category type defines
14
- // apart from id, name and path it can have nested categories with any key
15
- // STOR-1904
16
- typeof category[property] === 'object') {
17
- // @ts-expect-error rootCategory is in fact more than what Category type defines
18
- // apart from id, name and path it can have nested categories with any key
19
- // STOR-1904
20
- result = _searchCategoryWithId(category[property], id);
8
+ if (category.children) {
9
+ for (const child of category.children) {
10
+ const result = searchCategoryWithId(child, id);
21
11
  if (result) {
22
12
  return result;
23
13
  }
24
14
  }
25
15
  }
26
- return result;
16
+ return void 0;
27
17
  };
28
- export { _searchCategoryWithId as searchCategoryWithId };
29
- var _getAllPaths = function getAllPaths(category, resultsArray) {
30
- var results = resultsArray || [];
18
+ const getAllPaths = (category, resultsArray) => {
19
+ const results = resultsArray || [];
31
20
  if (category.path && category.path.length > 0) {
32
21
  results.push({
33
22
  path: category.path,
34
23
  id: category.id
35
24
  });
36
25
  }
37
- var property;
38
- var keys = Object.keys(category);
39
- for (var i = 0; i < keys.length; i += 1) {
40
- property = keys[i];
41
- if (Object.prototype.hasOwnProperty.call(category, property) &&
42
- // @ts-expect-error rootCategory is in fact more than what Category type defines
43
- // apart from id, name and path it can have nested categories with any key
44
- // STOR-1904
45
- typeof category[property] === 'object') {
46
- // @ts-expect-error rootCategory is in fact more than what Category type defines
47
- // apart from id, name and path it can have nested categories with any key
48
- // STOR-1904
49
- results = _getAllPaths(category[property], results);
26
+ if (category.children) {
27
+ for (const child of category.children) {
28
+ getAllPaths(child, results);
50
29
  }
51
30
  }
52
- return results && results.length > 0 ? results : undefined;
31
+ return results.length > 0 ? results : void 0;
53
32
  };
54
- export { _getAllPaths as getAllPaths };
55
- export var filterPaths = function filterPaths(paths, searchQuery) {
56
- var pathsToBeFiltered = [].concat(paths);
57
- var filtered = pathsToBeFiltered.filter(function (p) {
58
- var productPath = p.path;
59
- var lastElementOfPath = productPath[productPath.length - 1];
33
+ const filterPaths = (paths, searchQuery) => {
34
+ const pathsToBeFiltered = [...paths];
35
+ const filtered = pathsToBeFiltered.filter((p) => {
36
+ const productPath = p.path;
37
+ const lastElementOfPath = productPath[productPath.length - 1];
60
38
  return productPath && lastElementOfPath && lastElementOfPath.toLowerCase().includes(searchQuery);
61
39
  });
62
40
  return filtered;
63
41
  };
64
- export var hasNestedCategories = function hasNestedCategories(category) {
65
- var property;
66
- var keys = Object.keys(category);
67
- for (var i = 0; i < keys.length; i += 1) {
68
- property = keys[i];
69
- if (Object.prototype.hasOwnProperty.call(category, property) &&
70
- // @ts-expect-error rootCategory is in fact more than what Category type defines
71
- // apart from id, name and path it can have nested categories with any key
72
- typeof category[property] === 'object' &&
73
- // @ts-expect-error rootCategory is in fact more than what Category type defines
74
- // apart from id, name and path it can have nested categories with any key
75
- Object.prototype.toString.call(category[property]) === '[object Object]') {
76
- return true;
77
- }
78
- }
79
- return false;
80
- };
42
+ const hasNestedCategories = (category) => {
43
+ return (category.children?.length ?? 0) > 0;
44
+ };
45
+ export {
46
+ filterPaths,
47
+ getAllPaths,
48
+ hasNestedCategories,
49
+ searchCategoryWithId
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-cascader",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "description": "Cascader UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -16,10 +16,10 @@
16
16
  "access": "public"
17
17
  },
18
18
  "scripts": {
19
- "build": "pnpm run build:js && pnpm run build:css && pnpm run defs",
19
+ "build": "vite build",
20
20
  "build:css": "node ../../../scripts/style/less.js",
21
21
  "build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
22
- "build:watch": "pnpm run build:js -- --watch",
22
+ "build:watch": "vite build --watch",
23
23
  "defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
24
24
  "pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
25
25
  "prepublish": "pnpm run build",
@@ -35,13 +35,13 @@
35
35
  ],
36
36
  "types": "dist/index.d.ts",
37
37
  "dependencies": {
38
- "@synerise/ds-divider": "^1.3.1",
39
- "@synerise/ds-icon": "^1.15.0",
40
- "@synerise/ds-list-item": "^1.4.9",
41
- "@synerise/ds-scrollbar": "^1.2.16",
42
- "@synerise/ds-search": "^1.5.9",
43
- "@synerise/ds-search-bar": "^1.4.19",
44
- "@synerise/ds-utils": "^1.7.0"
38
+ "@synerise/ds-divider": "^1.3.3",
39
+ "@synerise/ds-icon": "^1.15.2",
40
+ "@synerise/ds-list-item": "^1.4.11",
41
+ "@synerise/ds-scrollbar": "^1.2.18",
42
+ "@synerise/ds-search": "^1.5.11",
43
+ "@synerise/ds-search-bar": "^1.4.21",
44
+ "@synerise/ds-utils": "^1.7.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "vitest": "4"
@@ -51,5 +51,5 @@
51
51
  "react": ">=16.9.0 <= 18.3.1",
52
52
  "styled-components": "^5.3.3"
53
53
  },
54
- "gitHead": "8efc031fa688c0b87c7b3915bae93546bb63bcac"
54
+ "gitHead": "c2384982c3533a31eb5e5e0408f8dcecb2b0f399"
55
55
  }