@synerise/ds-cascader 0.4.111 → 0.5.0

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 (34) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/Cascader.d.ts +2 -2
  3. package/dist/Cascader.js +45 -42
  4. package/dist/Cascader.types.d.ts +13 -13
  5. package/dist/Elements/BackAction/BackAction.d.ts +3 -3
  6. package/dist/Elements/BackAction/BackAction.js +2 -4
  7. package/dist/Elements/BackAction/BackAction.types.d.ts +5 -4
  8. package/dist/Elements/BottomAction/BottomAction.d.ts +3 -3
  9. package/dist/Elements/BottomAction/BottomAction.js +2 -4
  10. package/dist/Elements/BottomAction/BottomAction.types.d.ts +6 -4
  11. package/dist/Elements/Breadcrumb/Breadcrumb.d.ts +4 -0
  12. package/dist/Elements/Breadcrumb/Breadcrumb.js +85 -0
  13. package/dist/Elements/Breadcrumb/Breadcrumb.styles.d.ts +30 -0
  14. package/dist/Elements/Breadcrumb/Breadcrumb.styles.js +83 -0
  15. package/dist/Elements/Breadcrumb/Breadcrumb.types.d.ts +17 -0
  16. package/dist/Elements/Breadcrumb/Breadcrumb.types.js +1 -0
  17. package/dist/Elements/Breadcrumb/utils.d.ts +5 -0
  18. package/dist/Elements/Breadcrumb/utils.js +35 -0
  19. package/dist/Elements/BreadcrumbsList/BreadcrumbsList.d.ts +3 -2
  20. package/dist/Elements/BreadcrumbsList/BreadcrumbsList.js +4 -6
  21. package/dist/Elements/CategoriesList/CategoriesList.d.ts +2 -2
  22. package/dist/Elements/CategoriesList/CategoriesList.js +11 -13
  23. package/dist/Elements/CategoriesList/CategoriesList.types.d.ts +4 -4
  24. package/dist/Elements/Divider/Divider.d.ts +3 -3
  25. package/dist/Elements/Divider/Divider.js +2 -4
  26. package/dist/Elements/Divider/Divider.styles.js +1 -2
  27. package/dist/Elements/Navigation/Navigation.d.ts +3 -3
  28. package/dist/Elements/Navigation/Navigation.js +5 -7
  29. package/dist/Elements/Navigation/Navigation.types.d.ts +4 -3
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +2 -1
  32. package/package.json +9 -9
  33. /package/dist/{utlis.d.ts → utils.d.ts} +0 -0
  34. /package/dist/{utlis.js → utils.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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
+ # [0.5.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-cascader@0.4.111...@synerise/ds-cascader@0.5.0) (2024-05-29)
7
+
8
+
9
+ ### Features
10
+
11
+ * **list-item:** added prefix, suffix, ordered props ([3927035](https://github.com/Synerise/synerise-design/commit/39270352b6a681f3ac402edb6c2fb7a245883304))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.4.111](https://github.com/Synerise/synerise-design/compare/@synerise/ds-cascader@0.4.110...@synerise/ds-cascader@0.4.111) (2024-05-23)
7
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-cascader
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { CascaderProps } from './Cascader.types';
3
- declare const Cascader: React.FC<CascaderProps>;
3
+ export declare const Cascader: ({ rootCategory, searchClearTooltip, searchInputPlaceholder, onCategorySelect, categorySuffix, maxHeight, contentStyles, selectedCategoriesIds, }: CascaderProps) => React.JSX.Element;
4
4
  export default Cascader;
package/dist/Cascader.js CHANGED
@@ -1,19 +1,17 @@
1
- import * as React from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import SearchBar from '@synerise/ds-search-bar';
3
- import Menu from '@synerise/ds-menu';
4
3
  import Icon, { SearchM } from '@synerise/ds-icon';
5
4
  import { theme } from '@synerise/ds-core';
6
5
  import { useResize } from '@synerise/ds-utils';
7
6
  import * as S from './Cascader.styles';
8
- import { filterPaths, getAllPaths, hasNestedCategories, searchCategoryWithId } from './utlis';
7
+ import { filterPaths, getAllPaths, hasNestedCategories, searchCategoryWithId } from './utils';
9
8
  import BreadcrumbsList from './Elements/BreadcrumbsList/BreadcrumbsList';
10
9
  import CategoriesList from './Elements/CategoriesList/CategoriesList';
11
10
  import Navigation from './Elements/Navigation/Navigation';
12
11
  var VERTICAL_PADDING_OFFSET = 8;
13
12
  var BREADCRUMB_ITEM_HEIGHT = 50;
14
13
  var CATEGORY_ITEM_HEIGHT = 32;
15
-
16
- var Cascader = function Cascader(_ref) {
14
+ export var Cascader = function Cascader(_ref) {
17
15
  var _categoriesContainer$;
18
16
 
19
17
  var rootCategory = _ref.rootCategory,
@@ -25,36 +23,36 @@ var Cascader = function Cascader(_ref) {
25
23
  contentStyles = _ref.contentStyles,
26
24
  selectedCategoriesIds = _ref.selectedCategoriesIds;
27
25
 
28
- var _React$useState = React.useState(''),
29
- searchQuery = _React$useState[0],
30
- setSearchQuery = _React$useState[1];
26
+ var _useState = useState(''),
27
+ searchQuery = _useState[0],
28
+ setSearchQuery = _useState[1];
31
29
 
32
- var _React$useState2 = React.useState(rootCategory),
33
- activeCategory = _React$useState2[0],
34
- setActiveCategory = _React$useState2[1];
30
+ var _useState2 = useState(rootCategory),
31
+ activeCategory = _useState2[0],
32
+ setActiveCategory = _useState2[1];
35
33
 
36
- var _React$useState3 = React.useState([]),
37
- paths = _React$useState3[0],
38
- setPaths = _React$useState3[1];
34
+ var _useState3 = useState([]),
35
+ paths = _useState3[0],
36
+ setPaths = _useState3[1];
39
37
 
40
- var _React$useState4 = React.useState([]),
41
- filteredPaths = _React$useState4[0],
42
- setFilteredPaths = _React$useState4[1];
38
+ var _useState4 = useState([]),
39
+ filteredPaths = _useState4[0],
40
+ setFilteredPaths = _useState4[1];
43
41
 
44
- var _React$useState5 = React.useState([]),
45
- enteredCategories = _React$useState5[0],
46
- setEnteredCategories = _React$useState5[1];
42
+ var _useState5 = useState([]),
43
+ enteredCategories = _useState5[0],
44
+ setEnteredCategories = _useState5[1];
47
45
 
48
- var _React$useState6 = React.useState(0),
49
- scrollTop = _React$useState6[0],
50
- setScrollTop = _React$useState6[1];
46
+ var _useState6 = useState(0),
47
+ scrollTop = _useState6[0],
48
+ setScrollTop = _useState6[1];
51
49
 
52
- var _React$useState7 = React.useState(selectedCategoriesIds || []),
53
- selectedIds = _React$useState7[0],
54
- setSelectedIds = _React$useState7[1];
50
+ var _useState7 = useState(selectedCategoriesIds || []),
51
+ selectedIds = _useState7[0],
52
+ setSelectedIds = _useState7[1];
55
53
 
56
- var searchResultsContainer = React.useRef();
57
- var categoriesContainer = React.useRef();
54
+ var searchResultsContainer = useRef();
55
+ var categoriesContainer = useRef();
58
56
 
59
57
  var _useResize = useResize(searchResultsContainer),
60
58
  height = _useResize.height;
@@ -62,10 +60,10 @@ var Cascader = function Cascader(_ref) {
62
60
  var previousCategory = enteredCategories[enteredCategories.length - 2];
63
61
  var isSearching = !!paths && searchQuery.length > 0;
64
62
  var categoriesMaxHeight = maxHeight ? Math.floor((maxHeight - Number(categoriesContainer == null || (_categoriesContainer$ = categoriesContainer.current) == null ? void 0 : _categoriesContainer$.offsetTop)) / CATEGORY_ITEM_HEIGHT) * CATEGORY_ITEM_HEIGHT + VERTICAL_PADDING_OFFSET : undefined;
65
- var calculateVisibleRows = React.useMemo(function () {
63
+ var calculateVisibleRows = useMemo(function () {
66
64
  return Math.floor((height - VERTICAL_PADDING_OFFSET) / BREADCRUMB_ITEM_HEIGHT);
67
65
  }, [height]);
68
- React.useEffect(function () {
66
+ useEffect(function () {
69
67
  var allPaths = getAllPaths(rootCategory, []);
70
68
  setPaths(allPaths);
71
69
 
@@ -73,7 +71,7 @@ var Cascader = function Cascader(_ref) {
73
71
  setActiveCategory(rootCategory);
74
72
  }
75
73
  }, [rootCategory, activeCategory.id]);
76
- React.useEffect(function () {
74
+ useEffect(function () {
77
75
  setSelectedIds(selectedCategoriesIds);
78
76
  }, [selectedCategoriesIds]);
79
77
 
@@ -111,7 +109,7 @@ var Cascader = function Cascader(_ref) {
111
109
  }
112
110
  };
113
111
 
114
- var onPathClick = React.useCallback(function (pathName) {
112
+ var onPathClick = useCallback(function (pathName) {
115
113
  var chosenCategory = enteredCategories.find(function (enteredCategory) {
116
114
  return enteredCategory.name === pathName;
117
115
  });
@@ -133,16 +131,25 @@ var Cascader = function Cascader(_ref) {
133
131
 
134
132
  setEnteredCategories(updatedEnteredCategories || []);
135
133
  }, [rootCategory, enteredCategories]);
136
- var onHomeIconClick = React.useCallback(function () {
134
+ var onHomeIconClick = useCallback(function () {
137
135
  setActiveCategory(rootCategory);
138
136
  setEnteredCategories([]);
139
137
  }, [rootCategory]);
140
- var filterPathsBySearchQuery = React.useCallback(function (value) {
138
+ var filterPathsBySearchQuery = useCallback(function (value) {
141
139
  if (paths) {
142
140
  var filtered = filterPaths(paths, value.toLowerCase());
143
141
  setFilteredPaths(filtered);
144
142
  } else setFilteredPaths([]);
145
143
  }, [paths]);
144
+
145
+ var handleBreadCrumbClick = function handleBreadCrumbClick(breadcrumb) {
146
+ var selectedCategory = searchCategoryWithId(rootCategory, breadcrumb == null ? void 0 : breadcrumb.id);
147
+ selectedCategory ? onItemSelect(selectedCategory) : onItemSelect(breadcrumb);
148
+ };
149
+
150
+ var backActionVisible = useMemo(function () {
151
+ return !searchQuery && !!previousCategory && !!previousCategory.name && enteredCategories.length > 1;
152
+ }, [enteredCategories.length, previousCategory, searchQuery]);
146
153
  return /*#__PURE__*/React.createElement(S.Wrapper, {
147
154
  className: "ds-cascader"
148
155
  }, /*#__PURE__*/React.createElement(S.InputWrapper, null, /*#__PURE__*/React.createElement(SearchBar, {
@@ -164,7 +171,7 @@ var Cascader = function Cascader(_ref) {
164
171
  visible: !isSearching || filteredPaths && (filteredPaths == null ? void 0 : filteredPaths.length) > 0,
165
172
  ref: searchResultsContainer,
166
173
  style: contentStyles
167
- }, /*#__PURE__*/React.createElement(Menu, null, isSearching && filteredPaths && /*#__PURE__*/React.createElement(S.CascaderScrollbar, {
174
+ }, isSearching && filteredPaths && /*#__PURE__*/React.createElement(S.CascaderScrollbar, {
168
175
  maxHeight: maxHeight,
169
176
  searching: isSearching,
170
177
  absolute: isSearching,
@@ -178,13 +185,10 @@ var Cascader = function Cascader(_ref) {
178
185
  rowHeight: BREADCRUMB_ITEM_HEIGHT,
179
186
  paths: filteredPaths,
180
187
  highlight: searchQuery,
181
- onBreadCrumbClick: function onBreadCrumbClick(breadcrumb) {
182
- var selectedCategory = searchCategoryWithId(rootCategory, breadcrumb == null ? void 0 : breadcrumb.id);
183
- selectedCategory ? onItemSelect(selectedCategory) : onItemSelect(breadcrumb);
184
- },
188
+ onBreadCrumbClick: handleBreadCrumbClick,
185
189
  scrollTop: scrollTop
186
190
  })), /*#__PURE__*/React.createElement(Navigation, {
187
- backActionVisible: !searchQuery && !!previousCategory && !!previousCategory.name && enteredCategories.length > 1,
191
+ backActionVisible: backActionVisible,
188
192
  breadcrumbVisible: !searchQuery && !!activeCategory.path,
189
193
  onPathClick: onPathClick,
190
194
  onHomeIconClick: onHomeIconClick,
@@ -206,7 +210,6 @@ var Cascader = function Cascader(_ref) {
206
210
  suffixel: categorySuffix,
207
211
  onSuffixelClick: onItemSelect,
208
212
  selectedIds: selectedIds
209
- }))))));
213
+ })))));
210
214
  };
211
-
212
215
  export default Cascader;
@@ -1,21 +1,21 @@
1
- import * as React from 'react';
1
+ import type { ReactNode, ReactText, CSSProperties } from 'react';
2
2
  export type Texts = 'searchPlaceholder';
3
- export interface Category {
4
- id: React.ReactText;
3
+ export type Category = {
4
+ id: ReactText;
5
5
  name: string;
6
6
  path: string[];
7
- }
8
- export interface CascaderProps {
9
- categorySuffix: string | React.ReactNode;
7
+ };
8
+ export type CascaderProps = {
9
+ categorySuffix: ReactNode;
10
10
  maxHeight?: number;
11
- contentStyles?: React.CSSProperties;
11
+ contentStyles?: CSSProperties;
12
12
  onCategorySelect?: (item: Category, selected: boolean) => void;
13
13
  rootCategory: Category;
14
- searchClearTooltip?: string | React.ReactNode;
14
+ searchClearTooltip?: ReactNode;
15
15
  searchInputPlaceholder?: string;
16
- selectedCategoriesIds: React.ReactText[];
17
- }
18
- export interface Path {
19
- id: React.ReactText;
16
+ selectedCategoriesIds: ReactText[];
17
+ };
18
+ export type Path = {
19
+ id: ReactText;
20
20
  path: string[];
21
- }
21
+ };
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
2
- import { Props } from './BackAction.types';
3
- declare const BackAction: React.FC<Props>;
1
+ import React from 'react';
2
+ import { BackActionProps } from './BackAction.types';
3
+ export declare const BackAction: ({ label, onClick }: BackActionProps) => React.JSX.Element;
4
4
  export default BackAction;
@@ -1,10 +1,9 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import Icon, { ArrowLeftM } from '@synerise/ds-icon';
3
3
  import Divider from '@synerise/ds-divider';
4
4
  import * as S from './BackAction.styles';
5
5
  import { DividerContainer } from '../../Cascader.styles';
6
-
7
- var BackAction = function BackAction(_ref) {
6
+ export var BackAction = function BackAction(_ref) {
8
7
  var label = _ref.label,
9
8
  onClick = _ref.onClick;
10
9
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.BackActionWrapper, null, /*#__PURE__*/React.createElement(S.ContentWrapper, {
@@ -15,5 +14,4 @@ var BackAction = function BackAction(_ref) {
15
14
  dashed: true
16
15
  })));
17
16
  };
18
-
19
17
  export default BackAction;
@@ -1,5 +1,6 @@
1
- import * as React from 'react';
2
- export interface Props {
3
- label: React.ReactNode;
1
+ import type { ReactNode } from 'react';
2
+ export type BackActionProps = {
3
+ label: ReactNode;
4
4
  onClick: () => void;
5
- }
5
+ };
6
+ export type Props = BackActionProps;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
2
- import { Props } from './BottomAction.types';
3
- declare const BottomAction: React.FC<Props>;
1
+ import React from 'react';
2
+ import { BottomActionProps } from './BottomAction.types';
3
+ export declare const BottomAction: ({ onClickAction, children, icon }: BottomActionProps) => React.JSX.Element;
4
4
  export default BottomAction;
@@ -1,8 +1,7 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import Icon from '@synerise/ds-icon';
3
3
  import * as S from './BottomAction.styles';
4
-
5
- var BottomAction = function BottomAction(_ref) {
4
+ export var BottomAction = function BottomAction(_ref) {
6
5
  var onClickAction = _ref.onClickAction,
7
6
  children = _ref.children,
8
7
  icon = _ref.icon;
@@ -12,5 +11,4 @@ var BottomAction = function BottomAction(_ref) {
12
11
  component: icon
13
12
  })), /*#__PURE__*/React.createElement(S.TextWrapper, null, children));
14
13
  };
15
-
16
14
  export default BottomAction;
@@ -1,5 +1,7 @@
1
- import * as React from 'react';
2
- export interface Props {
1
+ import type { ReactNode, ReactElement } from 'react';
2
+ export type BottomActionProps = {
3
3
  onClickAction: () => void;
4
- icon?: React.ReactElement;
5
- }
4
+ icon?: ReactElement;
5
+ children?: ReactNode;
6
+ };
7
+ export type Props = BottomActionProps;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { BreadcrumbProps } from './Breadcrumb.types';
3
+ export declare const Breadcrumb: ({ path, disabled, highlight, description, onPathClick, compact, startWithArrow, gradientOverlap, highlightActivePath, className, prefixel, style, }: BreadcrumbProps) => React.JSX.Element;
4
+ export default Breadcrumb;
@@ -0,0 +1,85 @@
1
+ import React, { useEffect, useState, useRef, useMemo } from 'react';
2
+ import Icon, { AngleRightS } from '@synerise/ds-icon';
3
+ import { theme } from '@synerise/ds-core';
4
+ import { renderWithHighlight } from '@synerise/ds-utils';
5
+ import * as S from './Breadcrumb.styles';
6
+ import { shouldHaveArrowPlaceholder, shouldRenderArrow, isOverflown, attachActiveClassName } from './utils';
7
+ export var Breadcrumb = function Breadcrumb(_ref) {
8
+ var path = _ref.path,
9
+ disabled = _ref.disabled,
10
+ highlight = _ref.highlight,
11
+ description = _ref.description,
12
+ onPathClick = _ref.onPathClick,
13
+ compact = _ref.compact,
14
+ startWithArrow = _ref.startWithArrow,
15
+ gradientOverlap = _ref.gradientOverlap,
16
+ highlightActivePath = _ref.highlightActivePath,
17
+ className = _ref.className,
18
+ prefixel = _ref.prefixel,
19
+ style = _ref.style;
20
+ var pathToDisplay = useMemo(function () {
21
+ var breadcrumbsArray = [].concat(path);
22
+ return compact ? breadcrumbsArray.reverse() : breadcrumbsArray;
23
+ }, [compact, path]);
24
+ var contentRef = useRef(null);
25
+
26
+ var _useState = useState(false),
27
+ gradient = _useState[0],
28
+ setGradient = _useState[1];
29
+
30
+ useEffect(function () {
31
+ var shouldRenderGradientOverlap = gradientOverlap && isOverflown(contentRef);
32
+ setGradient(!!shouldRenderGradientOverlap);
33
+ }, [path, contentRef, gradientOverlap]);
34
+ var descriptionWithHighlight = useMemo(function () {
35
+ if (description && typeof description === 'string' && highlight) {
36
+ return renderWithHighlight(description, highlight, 'search-highlight', 'search-highlight');
37
+ }
38
+
39
+ return description;
40
+ }, [description, highlight]);
41
+ return /*#__PURE__*/React.createElement(S.Breadcrumb, {
42
+ tabIndex: 0,
43
+ role: "menuitem",
44
+ "data-testid": "ds-cascader-breadrumb",
45
+ className: className + " ds-breadcrumb",
46
+ prefixel: !!prefixel,
47
+ disabled: disabled,
48
+ compact: compact,
49
+ clickable: !!onPathClick,
50
+ style: style
51
+ }, /*#__PURE__*/React.createElement(S.OuterWrapper, null, prefixel && /*#__PURE__*/React.createElement(S.PrefixWrapper, {
52
+ "data-testid": "list-item-prefix",
53
+ disabled: disabled
54
+ }, prefixel), /*#__PURE__*/React.createElement(S.InnerWrapper, null, !!description && /*#__PURE__*/React.createElement(S.Description, {
55
+ "data-testid": "ds-cascader-breadcrumb-description"
56
+ }, descriptionWithHighlight), /*#__PURE__*/React.createElement(S.ContentWrapper, {
57
+ "data-testid": "ds-cascader-breadcrumb-content",
58
+ gradientOverlap: gradient
59
+ }, /*#__PURE__*/React.createElement(S.BreadcrumbContent, {
60
+ className: "breadcrumb-content",
61
+ ref: contentRef
62
+ }, pathToDisplay.map(function (item, index) {
63
+ return (
64
+ /*#__PURE__*/
65
+ // eslint-disable-next-line react/no-array-index-key
66
+ React.createElement(S.BreadcrumbRoute, {
67
+ className: "route",
68
+ key: item + "-" + index
69
+ }, /*#__PURE__*/React.createElement(S.BreadcrumbName, {
70
+ className: "ds-breadcrumb-name " + attachActiveClassName(index, !!highlightActivePath, path, !!compact),
71
+ onClick: function onClick() {
72
+ // eslint-disable-next-line no-unused-expressions
73
+ onPathClick == null || onPathClick(item);
74
+ }
75
+ }, renderWithHighlight(item, highlight)), shouldHaveArrowPlaceholder(index, path, !!compact, !!startWithArrow) && /*#__PURE__*/React.createElement(S.ArrowRight, {
76
+ className: "ds-arrow",
77
+ visible: shouldRenderArrow(path, index, !!startWithArrow)
78
+ }, /*#__PURE__*/React.createElement(Icon, {
79
+ component: /*#__PURE__*/React.createElement(AngleRightS, null),
80
+ color: theme.palette['grey-600']
81
+ })))
82
+ );
83
+ }))))));
84
+ };
85
+ export default Breadcrumb;
@@ -0,0 +1,30 @@
1
+ import { ThemeProps } from '@synerise/ds-core';
2
+ export declare const PrefixWrapper: import("styled-components").StyledComponent<"div", any, {
3
+ visible?: boolean | undefined;
4
+ disabled?: boolean | undefined;
5
+ }, never>;
6
+ export declare const Highlight: import("styled-components").StyledComponent<"span", any, {}, never>;
7
+ export declare const ArrowRight: import("styled-components").StyledComponent<"div", any, {
8
+ visible: boolean;
9
+ }, never>;
10
+ export declare const BreadcrumbContent: import("styled-components").StyledComponent<"div", any, {
11
+ prefixel?: boolean | undefined;
12
+ }, never>;
13
+ export declare const Description: import("styled-components").StyledComponent<"div", any, {}, never>;
14
+ export declare const ContentWrapper: import("styled-components").StyledComponent<"div", any, {
15
+ gradientOverlap?: boolean | undefined;
16
+ }, never>;
17
+ export declare const BreadcrumbName: import("styled-components").StyledComponent<"div", any, {}, never>;
18
+ export declare const disableDefaultClickingStyles: (props: ThemeProps & {
19
+ disabled?: boolean;
20
+ }) => import("styled-components").FlattenSimpleInterpolation;
21
+ export declare const OuterWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
22
+ export declare const InnerWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
23
+ export declare const Breadcrumb: import("styled-components").StyledComponent<"div", any, {
24
+ clickable?: boolean | undefined;
25
+ prefixel?: boolean | undefined;
26
+ size?: string | undefined;
27
+ disabled?: boolean | undefined;
28
+ compact?: boolean | undefined;
29
+ }, never>;
30
+ export declare const BreadcrumbRoute: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,83 @@
1
+ import styled, { css } from 'styled-components';
2
+ var TRANSITION_FN = '0.3s ease-in-out';
3
+ export var PrefixWrapper = styled.div.withConfig({
4
+ displayName: "Breadcrumbstyles__PrefixWrapper",
5
+ componentId: "sc-1rgfkd8-0"
6
+ })(["display:flex;order:1;opacity:1;transition:opacity ", ";margin-top:-7px;margin-bottom:-7px;margin-left:-4px;margin-right:12px;align-items:center;"], TRANSITION_FN);
7
+ export var Highlight = styled.span.withConfig({
8
+ displayName: "Breadcrumbstyles__Highlight",
9
+ componentId: "sc-1rgfkd8-1"
10
+ })([""]);
11
+ export var ArrowRight = styled.div.withConfig({
12
+ displayName: "Breadcrumbstyles__ArrowRight",
13
+ componentId: "sc-1rgfkd8-2"
14
+ })(["transition:opacity ", ";opacity:", ";svg{transition:fill ", ";}"], TRANSITION_FN, function (props) {
15
+ return props.visible ? '1' : '0';
16
+ }, TRANSITION_FN);
17
+ export var BreadcrumbContent = styled.div.withConfig({
18
+ displayName: "Breadcrumbstyles__BreadcrumbContent",
19
+ componentId: "sc-1rgfkd8-3"
20
+ })(["display:flex;align-items:center;"]);
21
+ export var Description = styled.div.withConfig({
22
+ displayName: "Breadcrumbstyles__Description",
23
+ componentId: "sc-1rgfkd8-4"
24
+ })(["direction:ltr;width:100%;font-weight:400;color:", ";.search-highlight{font-weight:500;}text-overflow:ellipsis;overflow:hidden;"], function (props) {
25
+ return props.theme.palette['grey-600'];
26
+ });
27
+ export var ContentWrapper = styled.div.withConfig({
28
+ displayName: "Breadcrumbstyles__ContentWrapper",
29
+ componentId: "sc-1rgfkd8-5"
30
+ })(["position:relative;&::before{pointer-events:none;content:'';opacity:", ";position:absolute;display:block;width:50px;height:18px;transition:opacity ", ";background-image:", ";}&::after{pointer-events:none;content:'';opacity:", ";position:absolute;left:0;top:0;display:block;width:50px;height:18px;transition:opacity ", ";background-image:", ";}"], function (props) {
31
+ return props.gradientOverlap ? '1' : '0';
32
+ }, TRANSITION_FN, function (props) {
33
+ return "-webkit-linear-gradient( left, " + props.theme.palette['grey-050'] + " 0%, rgba(255,255,255,0) 100% )";
34
+ }, function (props) {
35
+ return props.gradientOverlap ? '1' : '0';
36
+ }, TRANSITION_FN, function (props) {
37
+ return "-webkit-linear-gradient( left, " + props.theme.palette.white + " 0%, rgba(255,255,255,0) 100% )";
38
+ });
39
+ export var BreadcrumbName = styled.div.withConfig({
40
+ displayName: "Breadcrumbstyles__BreadcrumbName",
41
+ componentId: "sc-1rgfkd8-6"
42
+ })(["direction:ltr;font-weight:400;transition:color ", ";color:", ";.search-highlight{font-weight:500;}"], TRANSITION_FN, function (props) {
43
+ return props.theme.palette['grey-600'];
44
+ });
45
+ export var disableDefaultClickingStyles = function disableDefaultClickingStyles(props) {
46
+ return css(["&,&:focus,&:hover{background:", " !important;box-shadow:inset 0 0 0 2px transparent !important;", ",", "{color:", ";}", " > .ds-icon > svg{fill:", ";}}", ":hover,", ":hover{color:", ";}&&&:hover{", "{.ds-icon > svg{fill:", " !important;}}}&&&{", ":hover{.ds-icon > svg{fill:", " !important;}}"], props.theme.palette.white, BreadcrumbName, Description, props.theme.palette['grey-600'], ArrowRight, props.theme.palette['grey-600'], BreadcrumbName, Description, props.disabled ? props.theme.palette['grey-600'] : props.theme.palette['blue-600'], PrefixWrapper, props.theme.palette['grey-600'], PrefixWrapper, props.theme.palette['blue-600']);
47
+ };
48
+ export var OuterWrapper = styled.div.withConfig({
49
+ displayName: "Breadcrumbstyles__OuterWrapper",
50
+ componentId: "sc-1rgfkd8-7"
51
+ })(["padding:7px 0;width:100%;display:flex;align-items:center;flex-wrap:nowrap;user-select:none;"]);
52
+ export var InnerWrapper = styled.div.withConfig({
53
+ displayName: "Breadcrumbstyles__InnerWrapper",
54
+ componentId: "sc-1rgfkd8-8"
55
+ })(["text-overflow:ellipsis;order:2;overflow:hidden;white-space:nowrap;font-size:13px;line-height:1.39;min-height:18px;user-select:none;"]);
56
+ export var Breadcrumb = styled.div.withConfig({
57
+ displayName: "Breadcrumbstyles__Breadcrumb",
58
+ componentId: "sc-1rgfkd8-9"
59
+ })(["display:flex;align-items:center;min-width:200px;margin:0;padding-left:12px;padding-right:12px;font-size:13px;line-height:1.39;font-weight:500;user-select:none;border-radius:3px;transition:background-color 0.2s ease-out,color 0.2s ease-out;min-height:50px;background:none;border:none;color:", ";cursor:pointer;opacity:1;", "{direction:", ";flex-wrap:", ";}&{.ds-icon{height:18px;display:flex;align-items:center;}}&:hover{background:", ";color:", ";", " > .ds-icon > svg{fill:", ";}", ",", "{color:", ";}", "::after{opacity:0;}", "::before{opacity:0;}}&:focus:not(:active){box-shadow:inset 0 0 0 2px ", ";}&:focus:active{", "::before{background-image:", ";}}", ""], function (props) {
60
+ return props.theme.palette['grey-700'];
61
+ }, BreadcrumbContent, function (props) {
62
+ return props.compact ? 'rtl' : 'ltr';
63
+ }, function (props) {
64
+ return props.compact ? 'no-wrap' : 'wrap';
65
+ }, function (props) {
66
+ return props.theme.palette['grey-050'];
67
+ }, function (props) {
68
+ return props.theme.palette['blue-600'];
69
+ }, ArrowRight, function (props) {
70
+ return props.disabled ? props.theme.palette['grey-600'] : props.theme.palette['blue-600'];
71
+ }, BreadcrumbName, Description, function (props) {
72
+ return props.disabled ? props.theme.palette['grey-600'] : props.theme.palette['blue-600'];
73
+ }, ContentWrapper, ContentWrapper, function (props) {
74
+ return props.theme.palette['blue-600'];
75
+ }, ContentWrapper, function (props) {
76
+ return "-webkit-linear-gradient( left,\n " + props.theme.palette['grey-100'] + " 0%,\n rgba(255,255,255,0) 100%\n )";
77
+ }, function (props) {
78
+ return !!props.clickable && disableDefaultClickingStyles(props);
79
+ });
80
+ export var BreadcrumbRoute = styled.div.withConfig({
81
+ displayName: "Breadcrumbstyles__BreadcrumbRoute",
82
+ componentId: "sc-1rgfkd8-10"
83
+ })(["display:flex;align-items:center;padding-top:height:18px;.active{font-weight:500;}"]);
@@ -0,0 +1,17 @@
1
+ import type { CSSProperties, ReactNode } from 'react';
2
+ export type BreadcrumbProps = {
3
+ prefixel?: ReactNode;
4
+ disabled?: boolean;
5
+ path: string[];
6
+ highlight?: string;
7
+ className?: string;
8
+ description?: ReactNode;
9
+ onPathClick?: (path: string & {
10
+ id?: number | string;
11
+ }) => void;
12
+ compact?: boolean;
13
+ startWithArrow?: boolean;
14
+ gradientOverlap?: boolean;
15
+ highlightActivePath?: boolean;
16
+ style?: CSSProperties;
17
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { RefObject } from 'react';
2
+ export declare const attachActiveClassName: (index: number, highlightActivePath: boolean, path: Array<string>, compact: boolean) => "active" | "";
3
+ export declare const shouldRenderArrow: (breadCrumbPath: string[], index: number, startWithArrow: boolean) => boolean;
4
+ export declare const shouldHaveArrowPlaceholder: (index: number, path: string[], compact: boolean, startWithArrow: boolean) => boolean;
5
+ export declare const isOverflown: (elementRef: RefObject<HTMLDivElement>) => boolean;
@@ -0,0 +1,35 @@
1
+ export var attachActiveClassName = function attachActiveClassName(index, highlightActivePath, path, compact) {
2
+ if (compact) {
3
+ return highlightActivePath && index === 0 ? 'active' : '';
4
+ }
5
+
6
+ return highlightActivePath && index === path.length - 1 ? 'active' : '';
7
+ };
8
+ export var shouldRenderArrow = function shouldRenderArrow(breadCrumbPath, index, startWithArrow) {
9
+ if (!breadCrumbPath || !breadCrumbPath.length) {
10
+ return false;
11
+ }
12
+
13
+ var nextBreadcrumb = breadCrumbPath[index + 1];
14
+
15
+ if (!nextBreadcrumb) {
16
+ return startWithArrow;
17
+ }
18
+
19
+ return true;
20
+ };
21
+ export var shouldHaveArrowPlaceholder = function shouldHaveArrowPlaceholder(index, path, compact, startWithArrow) {
22
+ if (compact) {
23
+ return startWithArrow || index < path.length - 1 && path.length > 1;
24
+ }
25
+
26
+ return startWithArrow || path.length > 1 || index > 0;
27
+ };
28
+ export var isOverflown = function isOverflown(elementRef) {
29
+ if (elementRef !== null && elementRef.current !== null) {
30
+ var element = elementRef.current;
31
+ return element.scrollWidth > element.clientWidth;
32
+ }
33
+
34
+ return false;
35
+ };
@@ -1,4 +1,5 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
+ import { Path } from '../../Cascader.types';
2
3
  import { BreadcrumbsListProps } from './BreadcrumbsList.types';
3
- declare const BreadcrumbsList: React.FC<BreadcrumbsListProps>;
4
+ export declare const BreadcrumbsList: ({ paths, highlight, width, visibleRows, onBreadCrumbClick, rowHeight, scrollTop, }: BreadcrumbsListProps) => React.ReactElement<import("@synerise/ds-search/dist/Elements/SearchItems/SearchItems.types").SearchItemListProps<Path>, string | React.JSXElementConstructor<any>>;
4
5
  export default BreadcrumbsList;
@@ -1,10 +1,9 @@
1
- import * as React from 'react';
2
- import Menu from '@synerise/ds-menu';
1
+ import React from 'react';
3
2
  import { renderSearchList } from '@synerise/ds-search/dist/Elements/SearchItems/SearchItems';
3
+ import Breadcrumb from '../Breadcrumb/Breadcrumb';
4
4
  var DEFAULT_VISIBLE_ROWS = 6;
5
5
  var DEFAULT_ROW_HEIGHT = 50;
6
-
7
- var BreadcrumbsList = function BreadcrumbsList(_ref) {
6
+ export var BreadcrumbsList = function BreadcrumbsList(_ref) {
8
7
  var paths = _ref.paths,
9
8
  highlight = _ref.highlight,
10
9
  width = _ref.width,
@@ -23,7 +22,7 @@ var BreadcrumbsList = function BreadcrumbsList(_ref) {
23
22
  rowHeight: rowHeight || DEFAULT_ROW_HEIGHT,
24
23
  onItemClick: onBreadCrumbClick,
25
24
  itemRender: function itemRender(item) {
26
- return /*#__PURE__*/React.createElement(Menu.Breadcrumb, {
25
+ return /*#__PURE__*/React.createElement(Breadcrumb, {
27
26
  gradientOverlap: true,
28
27
  compact: true,
29
28
  path: item.path,
@@ -35,5 +34,4 @@ var BreadcrumbsList = function BreadcrumbsList(_ref) {
35
34
  listProps: listPropsObject
36
35
  });
37
36
  };
38
-
39
37
  export default BreadcrumbsList;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { CategoriesListProps } from './CategoriesList.types';
3
- declare const CategoriesList: React.FC<CategoriesListProps>;
3
+ export declare const CategoriesList: ({ rootCategory, onCategoryClick, suffixel, onSuffixelClick, selectedIds, }: CategoriesListProps) => React.JSX.Element;
4
4
  export default CategoriesList;
@@ -1,32 +1,31 @@
1
- import * as React from 'react';
2
- import Menu from '@synerise/ds-menu';
1
+ import React, { useCallback } from 'react';
2
+ import ListItem from '@synerise/ds-list-item';
3
3
  import { theme } from '@synerise/ds-core';
4
4
  import Icon, { CheckS } from '@synerise/ds-icon';
5
5
  import styled from 'styled-components';
6
- import { hasNestedCategories } from '../../utlis';
6
+ import { hasNestedCategories } from '../../utils';
7
7
  var CategoriesSuffix = styled.div.withConfig({
8
8
  displayName: "CategoriesList__CategoriesSuffix",
9
9
  componentId: "zu5q3f-0"
10
10
  })([""]);
11
-
12
- var CategoriesList = function CategoriesList(_ref) {
11
+ export var CategoriesList = function CategoriesList(_ref) {
13
12
  var rootCategory = _ref.rootCategory,
14
13
  onCategoryClick = _ref.onCategoryClick,
15
14
  suffixel = _ref.suffixel,
16
15
  onSuffixelClick = _ref.onSuffixelClick,
17
16
  selectedIds = _ref.selectedIds;
18
- var onCategoryClickHandler = React.useCallback(function (item) {
17
+ var onCategoryClickHandler = useCallback(function (item) {
19
18
  onCategoryClick && onCategoryClick(item);
20
19
  }, [onCategoryClick]);
21
- var onSuffixelClickHandler = React.useCallback(function (item, e) {
22
- e.stopPropagation();
20
+ var onSuffixelClickHandler = useCallback(function (item, event) {
21
+ event.stopPropagation();
23
22
  onSuffixelClick && onSuffixelClick(item);
24
23
  }, [onSuffixelClick]);
25
24
 
26
25
  var renderSuffix = function renderSuffix(item) {
27
26
  return /*#__PURE__*/React.createElement(CategoriesSuffix, {
28
- onClick: function onClick(e) {
29
- return onSuffixelClickHandler(item, e);
27
+ onClick: function onClick(event) {
28
+ return onSuffixelClickHandler(item, event);
30
29
  }
31
30
  }, selectedIds.includes(item.id) ? /*#__PURE__*/React.createElement(Icon, {
32
31
  color: theme.palette['green-600'],
@@ -40,10 +39,10 @@ var CategoriesList = function CategoriesList(_ref) {
40
39
  return (_rootCategory$key = rootCategory[key]) == null ? void 0 : _rootCategory$key.name;
41
40
  }).map(function (key) {
42
41
  var item = rootCategory[key];
43
- return /*#__PURE__*/React.createElement(Menu.Item, {
42
+ return /*#__PURE__*/React.createElement(ListItem, {
44
43
  text: item.name,
45
- type: selectedIds && selectedIds.includes(item.id) ? '' : 'select',
46
44
  key: "" + item.id,
45
+ type: selectedIds.includes(item.id) ? undefined : 'select',
47
46
  suffixel: renderSuffix(item),
48
47
  parent: hasNestedCategories(item),
49
48
  onClick: function onClick() {
@@ -52,5 +51,4 @@ var CategoriesList = function CategoriesList(_ref) {
52
51
  });
53
52
  }));
54
53
  };
55
-
56
54
  export default CategoriesList;
@@ -1,9 +1,9 @@
1
- import * as React from 'react';
2
- import { Category } from '../../Cascader.types';
1
+ import type { ReactNode, ReactText } from 'react';
2
+ import type { Category } from '../../Cascader.types';
3
3
  export interface CategoriesListProps {
4
4
  rootCategory: Category;
5
5
  onCategoryClick: (item: Category) => void;
6
- suffixel: React.ReactNode | string;
6
+ suffixel: ReactNode | string;
7
7
  onSuffixelClick: (item: Category) => void;
8
- selectedIds: React.ReactText[];
8
+ selectedIds: ReactText[];
9
9
  }
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
2
- import { DividerProps } from '@synerise/ds-divider/dist/Divider.types';
3
- declare const Divider: React.FC<DividerProps>;
1
+ import React from 'react';
2
+ import type { DividerProps } from '@synerise/ds-divider';
3
+ export declare const Divider: (props: DividerProps) => React.JSX.Element;
4
4
  export default Divider;
@@ -1,8 +1,6 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import * as S from './Divider.styles';
3
-
4
- var Divider = function Divider(props) {
3
+ export var Divider = function Divider(props) {
5
4
  return /*#__PURE__*/React.createElement(S.DividerWrapper, null, /*#__PURE__*/React.createElement(Divider, props));
6
5
  };
7
-
8
6
  export default Divider;
@@ -1,5 +1,4 @@
1
- import styled from 'styled-components'; // eslint-disable-next-line import/prefer-default-export
2
-
1
+ import styled from 'styled-components';
3
2
  export var DividerWrapper = styled.div.withConfig({
4
3
  displayName: "Dividerstyles__DividerWrapper",
5
4
  componentId: "lfeetq-0"
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
2
- import { Props } from './Navigation.types';
3
- declare const Navigation: React.FC<Props>;
1
+ import React from 'react';
2
+ import { NavigationProps } from './Navigation.types';
3
+ export declare const Navigation: ({ backActionVisible, onHomeIconClick, onPathClick, activeCategory, previousCategory, breadcrumbVisible, }: NavigationProps) => React.JSX.Element;
4
4
  export default Navigation;
@@ -1,12 +1,11 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import Icon, { HomeM } from '@synerise/ds-icon';
3
- import Menu from '@synerise/ds-menu';
4
3
  import Divider from '@synerise/ds-divider';
5
4
  import { theme } from '@synerise/ds-core';
6
5
  import * as S from '../../Cascader.styles';
7
- import BackAction from '../BackAction/BackAction';
8
-
9
- var Navigation = function Navigation(_ref) {
6
+ import { BackAction } from '../BackAction/BackAction';
7
+ import { Breadcrumb } from '../Breadcrumb/Breadcrumb';
8
+ export var Navigation = function Navigation(_ref) {
10
9
  var backActionVisible = _ref.backActionVisible,
11
10
  onHomeIconClick = _ref.onHomeIconClick,
12
11
  onPathClick = _ref.onPathClick,
@@ -15,7 +14,7 @@ var Navigation = function Navigation(_ref) {
15
14
  breadcrumbVisible = _ref.breadcrumbVisible;
16
15
 
17
16
  var renderBreadcrumbs = function renderBreadcrumbs() {
18
- return breadcrumbVisible && activeCategory ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Menu.Breadcrumb, {
17
+ return breadcrumbVisible && activeCategory ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Breadcrumb, {
19
18
  path: activeCategory.path,
20
19
  onPathClick: onPathClick,
21
20
  gradientOverlap: true,
@@ -43,5 +42,4 @@ var Navigation = function Navigation(_ref) {
43
42
 
44
43
  return /*#__PURE__*/React.createElement(React.Fragment, null, renderBreadcrumbs(), renderBackAction());
45
44
  };
46
-
47
45
  export default Navigation;
@@ -1,9 +1,10 @@
1
- import { Category } from '../../Cascader.types';
2
- export interface Props {
1
+ import type { Category } from '../../Cascader.types';
2
+ export type NavigationProps = {
3
3
  breadcrumbVisible?: boolean;
4
4
  backActionVisible?: boolean;
5
5
  activeCategory: Category;
6
6
  previousCategory: Category;
7
7
  onHomeIconClick: () => void;
8
8
  onPathClick: (item: string) => void;
9
- }
9
+ };
10
+ export type Props = NavigationProps;
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export { default } from './Cascader';
2
+ export { Breadcrumb } from './Elements/Breadcrumb/Breadcrumb';
3
+ export type { CascaderProps, Category, Texts, Path } from './Cascader.types';
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- export { default } from './Cascader';
1
+ export { default } from './Cascader';
2
+ export { Breadcrumb } from './Elements/Breadcrumb/Breadcrumb';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-cascader",
3
- "version": "0.4.111",
3
+ "version": "0.5.0",
4
4
  "description": "Cascader UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -33,13 +33,13 @@
33
33
  ],
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
- "@synerise/ds-divider": "^0.6.19",
37
- "@synerise/ds-icon": "^0.61.0",
38
- "@synerise/ds-menu": "^0.18.23",
39
- "@synerise/ds-scrollbar": "^0.10.5",
40
- "@synerise/ds-search": "^0.8.91",
41
- "@synerise/ds-search-bar": "^0.6.74",
42
- "@synerise/ds-utils": "^0.26.6"
36
+ "@synerise/ds-divider": "^0.7.0",
37
+ "@synerise/ds-icon": "^0.62.0",
38
+ "@synerise/ds-list-item": "^0.1.0",
39
+ "@synerise/ds-scrollbar": "^0.11.0",
40
+ "@synerise/ds-search": "^0.8.92",
41
+ "@synerise/ds-search-bar": "^0.6.75",
42
+ "@synerise/ds-utils": "^0.27.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@synerise/ds-core": "*",
@@ -49,5 +49,5 @@
49
49
  "devDependencies": {
50
50
  "@testing-library/jest-dom": "5.1.1"
51
51
  },
52
- "gitHead": "357031f4340eb9a2835f7b0cabffb5b1ad231db8"
52
+ "gitHead": "6bd94c78745df68ee3b853120a863ab24fc233ef"
53
53
  }
File without changes
File without changes