@synerise/ds-sidebar 0.4.95 → 0.5.1
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 +19 -0
- package/dist/Panel/Panel.js +6 -3
- package/dist/Sidebar.js +46 -12
- package/dist/Sidebar.styles.d.ts +1 -0
- package/dist/Sidebar.styles.js +33 -14
- package/dist/Sidebar.types.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-sidebar@0.5.0...@synerise/ds-sidebar@0.5.1) (2024-02-06)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-sidebar
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.5.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-sidebar@0.4.95...@synerise/ds-sidebar@0.5.0) (2024-01-31)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **sidebar:** restyled ds-sidebar ([814a988](https://github.com/Synerise/synerise-design/commit/814a9888acec71d669ffca240c980be39d8715cf))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.4.95](https://github.com/Synerise/synerise-design/compare/@synerise/ds-sidebar@0.4.94...@synerise/ds-sidebar@0.4.95) (2024-01-24)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @synerise/ds-sidebar
|
package/dist/Panel/Panel.js
CHANGED
|
@@ -105,12 +105,15 @@ export var Panel = function Panel(_ref2) {
|
|
|
105
105
|
var isDragDrop = context && !!order;
|
|
106
106
|
var panelContent = React.useMemo(function () {
|
|
107
107
|
return /*#__PURE__*/React.createElement(S.AntdPanel, _extends({
|
|
108
|
-
header: /*#__PURE__*/React.createElement(S.SidebarHeader, null, /*#__PURE__*/React.createElement("span",
|
|
108
|
+
header: /*#__PURE__*/React.createElement(S.SidebarHeader, null, /*#__PURE__*/React.createElement("span", {
|
|
109
|
+
"data-testid": "header-" + id
|
|
110
|
+
}, header), isDragDrop && /*#__PURE__*/React.createElement(S.SidebarHandle, null, /*#__PURE__*/React.createElement(Icon, {
|
|
109
111
|
color: theme.palette['grey-400'],
|
|
110
112
|
component: /*#__PURE__*/React.createElement(DragHandleM, null)
|
|
111
|
-
})))
|
|
113
|
+
})))
|
|
114
|
+
}, props, {
|
|
112
115
|
key: id
|
|
113
|
-
}
|
|
116
|
+
}), /*#__PURE__*/React.createElement(S.SidebarContentWrapper, null, children));
|
|
114
117
|
}, [header, isDragDrop, id, props, children]);
|
|
115
118
|
return isDragDrop ? /*#__PURE__*/React.createElement(DraggablePanel, {
|
|
116
119
|
id: id,
|
package/dist/Sidebar.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var _excluded = ["children", "order", "onChangeOrder", "defaultActiveKey", "activeKey", "onChange"];
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
+
|
|
1
7
|
import * as React from 'react';
|
|
2
8
|
import "./style/index.css";
|
|
3
9
|
import { theme } from '@synerise/ds-core';
|
|
@@ -9,17 +15,27 @@ import * as S from './Sidebar.styles';
|
|
|
9
15
|
import { Panel } from './Panel/Panel';
|
|
10
16
|
import { SidebarContext } from './Sidebar.context';
|
|
11
17
|
|
|
18
|
+
var prependDots = function prependDots(keys) {
|
|
19
|
+
return keys && Array.isArray(keys) ? keys.map(function (el) {
|
|
20
|
+
return "." + el;
|
|
21
|
+
}) : "." + keys;
|
|
22
|
+
};
|
|
23
|
+
|
|
12
24
|
var Sidebar = function Sidebar(_ref) {
|
|
13
25
|
var children = _ref.children,
|
|
14
26
|
_ref$order = _ref.order,
|
|
15
|
-
order = _ref$order === void 0 ?
|
|
27
|
+
order = _ref$order === void 0 ? [] : _ref$order,
|
|
16
28
|
onChangeOrder = _ref.onChangeOrder,
|
|
17
|
-
defaultActiveKey = _ref.defaultActiveKey
|
|
18
|
-
|
|
29
|
+
defaultActiveKey = _ref.defaultActiveKey,
|
|
30
|
+
activeKey = _ref.activeKey,
|
|
31
|
+
onChange = _ref.onChange,
|
|
32
|
+
collapseProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
33
|
+
|
|
34
|
+
var isDragDrop = Array.isArray(order) && order.length > 0;
|
|
19
35
|
|
|
20
36
|
var isActive = function isActive(checkActive) {
|
|
21
37
|
return /*#__PURE__*/React.createElement(Icon, {
|
|
22
|
-
color:
|
|
38
|
+
color: theme.palette['grey-600'],
|
|
23
39
|
component: checkActive ? /*#__PURE__*/React.createElement(AngleUpS, null) : /*#__PURE__*/React.createElement(AngleDownS, null)
|
|
24
40
|
});
|
|
25
41
|
};
|
|
@@ -29,7 +45,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
29
45
|
return 1;
|
|
30
46
|
}
|
|
31
47
|
|
|
32
|
-
return order.indexOf(a.props.id) > order.indexOf(b.props.id) ? 1 : -1;
|
|
48
|
+
return Array.isArray(order) && order.indexOf(a.props.id) > order.indexOf(b.props.id) ? 1 : -1;
|
|
33
49
|
}, [isDragDrop, order]);
|
|
34
50
|
|
|
35
51
|
var changeOrder = function changeOrder(dragIndex, hoverIndex) {
|
|
@@ -40,19 +56,37 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
40
56
|
onChangeOrder && onChangeOrder(orderedItems);
|
|
41
57
|
};
|
|
42
58
|
|
|
59
|
+
var handleOnChange = React.useCallback(function (keys) {
|
|
60
|
+
var finalKeys = isDragDrop ? (Array.isArray(keys) ? keys : [keys]).map(function (key) {
|
|
61
|
+
return key.startsWith('.') ? key.substring(1) : key;
|
|
62
|
+
}) : keys;
|
|
63
|
+
onChange && onChange(finalKeys);
|
|
64
|
+
}, [isDragDrop, onChange]);
|
|
65
|
+
var antdActiveKey = isDragDrop && activeKey ? prependDots(activeKey) : activeKey;
|
|
66
|
+
var antdDefaultActiveKey = isDragDrop && defaultActiveKey ? prependDots(defaultActiveKey) : defaultActiveKey;
|
|
43
67
|
var collapseContent = React.useMemo(function () {
|
|
44
|
-
|
|
68
|
+
var activeKeysProp = {};
|
|
69
|
+
|
|
70
|
+
if (antdDefaultActiveKey !== undefined) {
|
|
71
|
+
activeKeysProp = {
|
|
72
|
+
defaultActiveKey: antdDefaultActiveKey
|
|
73
|
+
};
|
|
74
|
+
} else if (antdActiveKey !== undefined) {
|
|
75
|
+
activeKeysProp = {
|
|
76
|
+
activeKey: antdActiveKey
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return /*#__PURE__*/React.createElement(S.AntdCollapse, _extends({}, activeKeysProp, {
|
|
45
81
|
className: isDragDrop ? 'is-drag-drop' : '',
|
|
46
|
-
defaultActiveKey: defaultActiveKey && defaultActiveKey.map(function (el) {
|
|
47
|
-
return "." + el;
|
|
48
|
-
}),
|
|
49
82
|
expandIconPosition: "right",
|
|
50
83
|
expandIcon: function expandIcon(panelProps) {
|
|
51
84
|
var checkActive = panelProps.isActive;
|
|
52
85
|
return isActive(checkActive);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
86
|
+
},
|
|
87
|
+
onChange: handleOnChange
|
|
88
|
+
}, collapseProps), isDragDrop ? React.Children.toArray(children).sort(compareByPositionOfKey) : children);
|
|
89
|
+
}, [antdDefaultActiveKey, antdActiveKey, isDragDrop, handleOnChange, collapseProps, children, compareByPositionOfKey]);
|
|
56
90
|
return isDragDrop ? /*#__PURE__*/React.createElement(DndProvider, {
|
|
57
91
|
backend: HTML5Backend
|
|
58
92
|
}, /*#__PURE__*/React.createElement(SidebarContext.Provider, {
|
package/dist/Sidebar.styles.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export declare const PanelWrapper: import("styled-components").StyledComponent<"
|
|
|
6
6
|
export declare const AntdCollapse: import("styled-components").StyledComponent<React.ComponentType<CollapseProps>, any, {}, never>;
|
|
7
7
|
export declare const AntdPanel: import("styled-components").StyledComponent<React.FC<import("antd/lib/collapse").CollapsePanelProps>, any, {}, never>;
|
|
8
8
|
export declare const SidebarContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const SidebarContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
package/dist/Sidebar.styles.js
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import Collapse from 'antd/lib/collapse';
|
|
3
3
|
var Panel = Collapse.Panel;
|
|
4
|
+
|
|
5
|
+
var themePaletteGrey700 = function themePaletteGrey700(props) {
|
|
6
|
+
return props.theme.palette['grey-700'];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
var themePaletteGrey800 = function themePaletteGrey800(props) {
|
|
10
|
+
return props.theme.palette['grey-800'];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var themePaletteBlue050 = function themePaletteBlue050(props) {
|
|
14
|
+
return props.theme.palette['blue-050'];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var themePaletteGrey200 = function themePaletteGrey200(props) {
|
|
18
|
+
return props.theme.palette['grey-200'];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var themePaletteGrey050 = function themePaletteGrey050(props) {
|
|
22
|
+
return props.theme.palette['grey-050'];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var themePaletteBlue600 = function themePaletteBlue600(props) {
|
|
26
|
+
return props.theme.palette['blue-600'];
|
|
27
|
+
};
|
|
28
|
+
|
|
4
29
|
export var SidebarHandle = styled.div.withConfig({
|
|
5
30
|
displayName: "Sidebarstyles__SidebarHandle",
|
|
6
31
|
componentId: "sc-19um1hw-0"
|
|
7
|
-
})(["display:flex;opacity:
|
|
32
|
+
})(["display:flex;opacity:1;transition:0.2s ease-in-out;&::before{content:'';position:absolute;width:100%;height:100%;left:0;top:0;pointer-events:none;}"]);
|
|
8
33
|
export var SidebarHeader = styled.div.withConfig({
|
|
9
34
|
displayName: "Sidebarstyles__SidebarHeader",
|
|
10
35
|
componentId: "sc-19um1hw-1"
|
|
@@ -17,22 +42,16 @@ export var PanelWrapper = styled.div.withConfig({
|
|
|
17
42
|
export var AntdCollapse = styled(Collapse).withConfig({
|
|
18
43
|
displayName: "Sidebarstyles__AntdCollapse",
|
|
19
44
|
componentId: "sc-19um1hw-3"
|
|
20
|
-
})(["&.ant-collapse{background-color:rgba(
|
|
21
|
-
return props.theme.palette['grey-700'];
|
|
22
|
-
}, function (props) {
|
|
23
|
-
return props.theme.palette['grey-800'];
|
|
24
|
-
}, SidebarHeader, function (props) {
|
|
25
|
-
return props.theme.palette['grey-800'];
|
|
26
|
-
}, SidebarHandle, function (props) {
|
|
27
|
-
return props.theme.palette['grey-200'];
|
|
28
|
-
}, SidebarHandle, PanelWrapper, PanelWrapper);
|
|
45
|
+
})(["&.ant-collapse{background-color:", ";border:none;.ant-collapse-header{padding:19px 24px;color:", ";font-weight:500;font-size:14px;background:white;&:hover{color:", ";}&:active{box-shadow:0px 16px 32px 0px rgba(35,41,54,0.1);}}> ", " > .ant-collapse-item > .ant-collapse-header{transition:0.2s ease-in-out;display:flex;align-items:center;justify-content:flex-start;}.ant-collapse-content-active,.ant-collapse-item-active{border-top:0;", ",", "{color:", ";&:hover{color:", ";}}.ant-collapse-header{background:", ";}}.ant-collapse-content-box{padding:16px 24px;}.ant-collapse-item{position:relative;border-top:solid 1px ", ";border-bottom:none;.drag-handle-m:hover{cursor:grabbing;}}}.ant-collapse-item:hover ", "{opacity:1;}&.ant-collapse-icon-position-right > ", " > .ant-collapse-item > .ant-collapse-header{padding:18px 24px;user-select:none;.ant-collapse-arrow{right:24px;position:absolute;}}&.ant-collapse-icon-position-right.is-drag-drop > ", " > .ant-collapse-item > .ant-collapse-header{padding:18px 24px 18px 0;cursor:pointer;&:hover,&:active{color:", ";box-shadow:0 16px 32px 0 rgba(35,41,54,0.1);}}"], themePaletteBlue050, themePaletteGrey700, themePaletteGrey800, PanelWrapper, SidebarHeader, SidebarHandle, themePaletteGrey700, themePaletteGrey800, themePaletteGrey050, themePaletteGrey200, SidebarHandle, PanelWrapper, PanelWrapper, themePaletteGrey800);
|
|
29
46
|
export var AntdPanel = styled(Panel).withConfig({
|
|
30
47
|
displayName: "Sidebarstyles__AntdPanel",
|
|
31
48
|
componentId: "sc-19um1hw-4"
|
|
32
|
-
})([".ant-collapse-content{background-color:white;border-radius:0;border-color:", ";}"],
|
|
33
|
-
return props.theme.palette['grey-800'];
|
|
34
|
-
});
|
|
49
|
+
})([".ant-collapse-content{background-color:white;border-radius:0;border-color:", ";}"], themePaletteGrey800);
|
|
35
50
|
export var SidebarContentWrapper = styled.div.withConfig({
|
|
36
51
|
displayName: "Sidebarstyles__SidebarContentWrapper",
|
|
37
52
|
componentId: "sc-19um1hw-5"
|
|
38
|
-
})(["display:flex;flex-wrap:wrap;"]);
|
|
53
|
+
})(["display:flex;flex-wrap:wrap;"]);
|
|
54
|
+
export var SidebarContainer = styled.div.withConfig({
|
|
55
|
+
displayName: "Sidebarstyles__SidebarContainer",
|
|
56
|
+
componentId: "sc-19um1hw-6"
|
|
57
|
+
})(["flex-direction:row;align-items:flex-start;justify-content:flex-start;width:100%;min-width:588px;.ds-card-tags-sortable{gap:16px 12px;margin-bottom:16px;display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;flex-wrap:wrap;}.sortable-chosen,.sortable-drag,.sortable-card-ghost-element{cursor:grabbing;box-shadow:0 16px 32px 0 rgba(35,41,54,0.1);opacity:1;&.sortable-card-ghost-element{border:dashed 1px ", ";background-color:", ";*{visibility:hidden;}}}"], themePaletteBlue600, themePaletteBlue050);
|
package/dist/Sidebar.types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
import { CollapseProps } from 'antd/lib/collapse';
|
|
3
|
+
export type SidebarProps = CollapseProps & {
|
|
3
4
|
children: React.ReactNode;
|
|
4
5
|
order?: string[];
|
|
5
6
|
onChangeOrder?: (order: Order) => void;
|
|
6
|
-
defaultActiveKey?: string[];
|
|
7
7
|
};
|
|
8
8
|
export type PanelProps = {
|
|
9
9
|
header: React.ReactNode | string;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from './Sidebar';
|
|
1
|
+
export { default } from './Sidebar';
|
|
2
|
+
export { default as Panel } from './Panel/Panel';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-sidebar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Sidebar UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@synerise/ds-button": "^0.19.0",
|
|
37
|
-
"@synerise/ds-dropdown": "^0.17.
|
|
37
|
+
"@synerise/ds-dropdown": "^0.17.95",
|
|
38
38
|
"@synerise/ds-icon": "^0.60.0",
|
|
39
39
|
"@synerise/ds-menu": "^0.18.11",
|
|
40
40
|
"@synerise/ds-utils": "^0.24.24",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"@testing-library/dom": "^7.0.2",
|
|
54
54
|
"@testing-library/jest-dom": "5.1.1"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "413b02fb31c0c6fb8631fde0bc5b00e16f7f30b7"
|
|
57
57
|
}
|