@synerise/ds-cascader 1.1.26 → 1.1.27
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 +4 -0
- package/dist/Cascader.d.ts +2 -2
- package/dist/Cascader.js +85 -143
- package/dist/Cascader.styles.d.ts +6 -6
- package/dist/Cascader.styles.js +19 -17
- package/dist/Cascader.types.d.ts +1 -1
- package/dist/Cascader.types.js +1 -1
- package/dist/Elements/BackAction/BackAction.d.ts +2 -2
- package/dist/Elements/BackAction/BackAction.js +18 -16
- package/dist/Elements/BackAction/BackAction.styles.d.ts +4 -4
- package/dist/Elements/BackAction/BackAction.styles.js +15 -17
- package/dist/Elements/BackAction/BackAction.types.d.ts +1 -1
- package/dist/Elements/BackAction/BackAction.types.js +1 -1
- package/dist/Elements/BottomAction/BottomAction.d.ts +2 -2
- package/dist/Elements/BottomAction/BottomAction.js +14 -13
- package/dist/Elements/BottomAction/BottomAction.styles.d.ts +3 -3
- package/dist/Elements/BottomAction/BottomAction.styles.js +11 -14
- package/dist/Elements/BottomAction/BottomAction.types.d.ts +1 -1
- package/dist/Elements/BottomAction/BottomAction.types.js +1 -1
- package/dist/Elements/Breadcrumb/Breadcrumb.d.ts +2 -2
- package/dist/Elements/Breadcrumb/Breadcrumb.js +47 -73
- package/dist/Elements/Breadcrumb/Breadcrumb.styles.d.ts +13 -13
- package/dist/Elements/Breadcrumb/Breadcrumb.styles.js +36 -46
- package/dist/Elements/Breadcrumb/Breadcrumb.types.d.ts +2 -2
- package/dist/Elements/Breadcrumb/Breadcrumb.types.js +1 -1
- package/dist/Elements/Breadcrumb/utils.d.ts +1 -1
- package/dist/Elements/Breadcrumb/utils.js +15 -9
- package/dist/Elements/BreadcrumbsList/BreadcrumbsList.d.ts +4 -4
- package/dist/Elements/BreadcrumbsList/BreadcrumbsList.js +28 -35
- package/dist/Elements/BreadcrumbsList/BreadcrumbsList.types.d.ts +2 -2
- package/dist/Elements/BreadcrumbsList/BreadcrumbsList.types.js +1 -1
- package/dist/Elements/CategoriesList/CategoriesList.d.ts +2 -2
- package/dist/Elements/CategoriesList/CategoriesList.js +26 -49
- package/dist/Elements/CategoriesList/CategoriesList.types.d.ts +2 -2
- package/dist/Elements/CategoriesList/CategoriesList.types.js +1 -1
- package/dist/Elements/Navigation/Navigation.d.ts +2 -2
- package/dist/Elements/Navigation/Navigation.js +32 -40
- package/dist/Elements/Navigation/Navigation.types.d.ts +1 -1
- package/dist/Elements/Navigation/Navigation.types.js +1 -1
- package/dist/index.js +6 -2
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +37 -43
- package/package.json +11 -11
|
@@ -1,43 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { theme } from
|
|
3
|
-
import Divider from
|
|
4
|
-
import Icon, { HomeM } from
|
|
5
|
-
import
|
|
6
|
-
import { BackAction } from
|
|
7
|
-
import { Breadcrumb } from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
path: activeCategory.path,
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
34
|
-
return backActionVisible && previousCategory ?
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
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 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
File without changes
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
if (id ===
|
|
3
|
-
return
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
for (
|
|
8
|
+
let result, property;
|
|
9
|
+
const keys = Object.keys(category);
|
|
10
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
11
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
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(category, property) && // @ts-expect-error rootCategory is in fact more than what Category type defines
|
|
14
13
|
// apart from id, name and path it can have nested categories with any key
|
|
15
14
|
// STOR-1904
|
|
16
|
-
typeof category[property] ===
|
|
17
|
-
|
|
18
|
-
// apart from id, name and path it can have nested categories with any key
|
|
19
|
-
// STOR-1904
|
|
20
|
-
result = _searchCategoryWithId(category[property], id);
|
|
15
|
+
typeof category[property] === "object") {
|
|
16
|
+
result = searchCategoryWithId(category[property], id);
|
|
21
17
|
if (result) {
|
|
22
18
|
return result;
|
|
23
19
|
}
|
|
@@ -25,56 +21,54 @@ var _searchCategoryWithId = function searchCategoryWithId(category, id) {
|
|
|
25
21
|
}
|
|
26
22
|
return result;
|
|
27
23
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var results = resultsArray || [];
|
|
24
|
+
const getAllPaths = (category, resultsArray) => {
|
|
25
|
+
let results = resultsArray || [];
|
|
31
26
|
if (category.path && category.path.length > 0) {
|
|
32
27
|
results.push({
|
|
33
28
|
path: category.path,
|
|
34
29
|
id: category.id
|
|
35
30
|
});
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (
|
|
32
|
+
let property;
|
|
33
|
+
const keys = Object.keys(category);
|
|
34
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
40
35
|
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
|
|
36
|
+
if (Object.prototype.hasOwnProperty.call(category, property) && // @ts-expect-error rootCategory is in fact more than what Category type defines
|
|
43
37
|
// apart from id, name and path it can have nested categories with any key
|
|
44
38
|
// STOR-1904
|
|
45
|
-
typeof category[property] ===
|
|
46
|
-
|
|
47
|
-
// apart from id, name and path it can have nested categories with any key
|
|
48
|
-
// STOR-1904
|
|
49
|
-
results = _getAllPaths(category[property], results);
|
|
39
|
+
typeof category[property] === "object") {
|
|
40
|
+
results = getAllPaths(category[property], results);
|
|
50
41
|
}
|
|
51
42
|
}
|
|
52
|
-
return results && results.length > 0 ? results :
|
|
43
|
+
return results && results.length > 0 ? results : void 0;
|
|
53
44
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var lastElementOfPath = productPath[productPath.length - 1];
|
|
45
|
+
const filterPaths = (paths, searchQuery) => {
|
|
46
|
+
const pathsToBeFiltered = [...paths];
|
|
47
|
+
const filtered = pathsToBeFiltered.filter((p) => {
|
|
48
|
+
const productPath = p.path;
|
|
49
|
+
const lastElementOfPath = productPath[productPath.length - 1];
|
|
60
50
|
return productPath && lastElementOfPath && lastElementOfPath.toLowerCase().includes(searchQuery);
|
|
61
51
|
});
|
|
62
52
|
return filtered;
|
|
63
53
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for (
|
|
54
|
+
const hasNestedCategories = (category) => {
|
|
55
|
+
let property;
|
|
56
|
+
const keys = Object.keys(category);
|
|
57
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
68
58
|
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
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(category, property) && // @ts-expect-error rootCategory is in fact more than what Category type defines
|
|
71
60
|
// apart from id, name and path it can have nested categories with any key
|
|
72
|
-
typeof category[property] ===
|
|
73
|
-
// @ts-expect-error rootCategory is in fact more than what Category type defines
|
|
61
|
+
typeof category[property] === "object" && // @ts-expect-error rootCategory is in fact more than what Category type defines
|
|
74
62
|
// apart from id, name and path it can have nested categories with any key
|
|
75
|
-
Object.prototype.toString.call(category[property]) ===
|
|
63
|
+
Object.prototype.toString.call(category[property]) === "[object Object]") {
|
|
76
64
|
return true;
|
|
77
65
|
}
|
|
78
66
|
}
|
|
79
67
|
return false;
|
|
80
|
-
};
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
filterPaths,
|
|
71
|
+
getAllPaths,
|
|
72
|
+
hasNestedCategories,
|
|
73
|
+
searchCategoryWithId
|
|
74
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-cascader",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.27",
|
|
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": "
|
|
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": "
|
|
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.
|
|
39
|
-
"@synerise/ds-icon": "^1.15.
|
|
40
|
-
"@synerise/ds-list-item": "^1.4.
|
|
41
|
-
"@synerise/ds-scrollbar": "^1.2.
|
|
42
|
-
"@synerise/ds-search": "^1.5.
|
|
43
|
-
"@synerise/ds-search-bar": "^1.4.
|
|
44
|
-
"@synerise/ds-utils": "^1.7.
|
|
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"
|
|
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": "
|
|
54
|
+
"gitHead": "e4ecca8944fc9b41c1b9d59c8bcad5e5e2013225"
|
|
55
55
|
}
|