@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.
- package/CHANGELOG.md +10 -0
- package/dist/Cascader.d.ts +2 -2
- package/dist/Cascader.js +94 -143
- package/dist/Cascader.styles.d.ts +6 -6
- package/dist/Cascader.styles.js +19 -17
- package/dist/Cascader.types.d.ts +2 -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 +23 -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 +27 -57
- 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,80 +1,50 @@
|
|
|
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
|
-
|
|
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
|
|
16
|
+
return void 0;
|
|
27
17
|
};
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
31
|
+
return results.length > 0 ? results : void 0;
|
|
53
32
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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.
|
|
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": "
|
|
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.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": "
|
|
54
|
+
"gitHead": "c2384982c3533a31eb5e5e0408f8dcecb2b0f399"
|
|
55
55
|
}
|