@semcore/side-panel 2.0.5 → 2.0.8

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 CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
+ ## [2.0.8] - 2022-07-21
6
+
7
+ ### Changed
8
+
9
+ - Version patch update due to children dependencies update (`@semcore/icon` [2.28.0 ~> 2.29.0]).
10
+
11
+ ## [2.0.7] - 2022-07-07
12
+
13
+ ### Changed
14
+
15
+ - Version patch update due to children dependencies update (`@semcore/utils` [3.33.0 ~> 3.34.0], `@semcore/animation` [1.5.3 ~> 1.5.4], `@semcore/flex-box` [4.5.5 ~> 4.5.6], `@semcore/portal` [2.3.6 ~> 2.3.7], `@semcore/outside-click` [2.4.6 ~> 2.4.7], `@semcore/icon` [2.27.0 ~> 2.28.0]).
16
+
17
+ ## [2.0.6] - 2022-06-02
18
+
19
+ ### Changed
20
+
21
+ - Version patch update due to children dependencies update (`@semcore/utils` [3.32.2 ~> 3.33.0], `@semcore/animation` [1.5.2 ~> 1.5.3], `@semcore/flex-box` [4.5.4 ~> 4.5.5], `@semcore/portal` [2.3.5 ~> 2.3.6], `@semcore/outside-click` [2.4.5 ~> 2.4.6], `@semcore/icon` [2.26.1 ~> 2.27.0]).
22
+
5
23
  ## [2.0.5] - 2022-05-31
6
24
 
7
25
  ### Changed
package/README.md CHANGED
@@ -0,0 +1,67 @@
1
+ # @semcore/side-panel
2
+
3
+ [![version](https://img.shields.io/npm/v/@semcore/side-panel.svg)](https://www.npmjs.com/@semcore/side-panel)
4
+ [![downloads](https://img.shields.io/npm/dt/@semcore/side-panel.svg)](https://www.npmjs.com/package/@semcore/side-panel)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/semrush/intergalactic/blob/master/LICENSE)
6
+
7
+ > This component is part of the Intergalactic design system
8
+
9
+ ### 📖 [Component documentation](https://developer.semrush.com/intergalactic/components/side-panel/)
10
+
11
+ ### 🏠 [Design system](https://developer.semrush.com/intergalactic/)
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ npm install @semcore/ui
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```jsx
22
+ import SidePanel from '@semcore/ui/side-panel';
23
+ ```
24
+
25
+ <details>
26
+ <summary>Alternative installation and use</summary>
27
+
28
+ **We do not recommend this usage path due to possible dependency and update issues.**
29
+
30
+ ### Install
31
+
32
+ You can only install one package from the design system
33
+
34
+ ```sh
35
+ npm install @semcore/side-panel @semcore/core
36
+ ```
37
+
38
+ `@semcore/core` - _is the basic package by which we create our components, and it contains all of the common logic
39
+ of the components that is discussed below. There should only be one version of the package in the project._
40
+
41
+ ### Usage
42
+
43
+ You can use the package the same way but without `/ui/` in the import path.
44
+
45
+ ```jsx
46
+ import SidePanel from '@semcore/side-panel';
47
+ ```
48
+
49
+ </details>
50
+
51
+ ## 👤 Author
52
+
53
+ [UI-kit team](https://github.com/semrush/intergalactic/blob/master/MAINTAINERS) and [others ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
54
+
55
+ ## 🤝 Contributing
56
+
57
+ Contributions, issues and feature requests are welcome!
58
+
59
+ Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/master/CONTRIBUTING.md).
60
+
61
+ ## Show your support
62
+
63
+ Give a ⭐️ if this project helped you!
64
+
65
+ ## 📝 License
66
+
67
+ This project is [MIT](https://github.com/semrush/intergalactic/blob/master/LICENSE) licensed.
@@ -75,25 +75,25 @@ var style = (
75
75
  /*__reshadow_css_start__*/
76
76
  _core.sstyled.insert(
77
77
  /*__inner_css_start__*/
78
- ".___SOverlay_19nmj_gg_{position:fixed;top:0;bottom:0;left:0;right:0;margin:0;display:flex;overflow:hidden;z-index:10005;background:rgba(25,27,35,.7);-webkit-overflow-scrolling:touch}.___SPanel_19nmj_gg_{display:flex;flex-direction:column;width:260px;outline:none;font-family:Inter,sans-serif;position:fixed;box-sizing:border-box;will-change:transform;background:#fff;z-index:1}.___SPanel_19nmj_gg_._placement_top_19nmj_gg_{box-shadow:1px 0 12px rgba(25,27,35,.15);width:100%;margin-bottom:auto;top:0;left:0}.___SPanel_19nmj_gg_._placement_right_19nmj_gg_{box-shadow:0px 1px 12px 0px rgba(25, 27, 35, 0.15);height:100vh;margin-left:auto;top:0;right:0}.___SPanel_19nmj_gg_._placement_bottom_19nmj_gg_{box-shadow:1px 0 12px rgba(25,27,35,.15);width:100%;margin-top:auto;bottom:0;left:0}.___SPanel_19nmj_gg_._placement_left_19nmj_gg_{box-shadow:0px 1px 12px 0px rgba(25, 27, 35, 0.15);height:100vh;margin-right:auto;top:0;left:0}.panel-right--enter{transform:translate(100%)}.panel-left--enter{transform:translate(-100%)}.panel-bottom--enter{transform:translateY(100%)}.panel-bottom--enter-active,.panel-bottom--exit,.panel-left--enter-active,.panel-left--exit,.panel-right--enter-active,.panel-right--exit{transform:translate(0)}.panel-right--exit-active{transform:translate(100%)}.panel-left--exit-active{transform:translate(-100%)}.panel-bottom--exit-active{transform:translateY(100%)}.___SClose_19nmj_gg_{cursor:pointer;position:absolute;z-index:1;display:inline-flex;right:0;top:0;padding:12px 12px 16px 12px;color:#a9abb6;border:none;background:none;outline:none}.___SClose_19nmj_gg_:hover{color:#8a8e9b}.___SClose_19nmj_gg_.__keyboardFocused_19nmj_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2)}.___SBack_19nmj_gg_{display:flex;align-items:center;color:#6c6e79;font-size:12px;line-height:1.33;margin-bottom:4px;cursor:pointer}.___SBack_19nmj_gg_:hover{color:#484a54}.___SBackText_19nmj_gg_{margin-left:4px;font-size:12px;line-height:1.42;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___STitle_19nmj_gg_{font-size:16px;line-height:1.5;font-weight:700;color:#191b23;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SHeader_19nmj_gg_{padding-left:24px;padding-bottom:4px;padding-right:56px;padding-top:4px;min-height:52px;box-shadow:inset 0 -1px 0 #c4c7cf;box-sizing:border-box}.___SFooter_19nmj_gg_{min-height:44px;box-shadow:inset 0 1px 0 #c4c7cf;box-sizing:border-box}.___SBody_19nmj_gg_{height:100%;overflow:auto;padding-left:24px;padding-bottom:4px;padding-right:40px;padding-top:16px}"
78
+ ".___SOverlay_1evro_gg_{position:fixed;top:0;bottom:0;left:0;right:0;margin:0;display:flex;overflow:hidden;z-index:10005;background:rgba(25,27,35,.7);-webkit-overflow-scrolling:touch}.___SPanel_1evro_gg_{display:flex;flex-direction:column;width:260px;outline:none;font-family:Inter,sans-serif;position:fixed;box-sizing:border-box;will-change:transform;background:#fff;z-index:1}.___SPanel_1evro_gg_._placement_top_1evro_gg_{box-shadow:1px 0 12px rgba(25,27,35,.15);width:100%;margin-bottom:auto;top:0;left:0}.___SPanel_1evro_gg_._placement_right_1evro_gg_{box-shadow:0px 1px 12px 0px rgba(25, 27, 35, 0.15);height:100vh;margin-left:auto;top:0;right:0}.___SPanel_1evro_gg_._placement_bottom_1evro_gg_{box-shadow:1px 0 12px rgba(25,27,35,.15);width:100%;margin-top:auto;bottom:0;left:0}.___SPanel_1evro_gg_._placement_left_1evro_gg_{box-shadow:0px 1px 12px 0px rgba(25, 27, 35, 0.15);height:100vh;margin-right:auto;top:0;left:0}.panel-right--enter{transform:translate(100%)}.panel-left--enter{transform:translate(-100%)}.panel-bottom--enter{transform:translateY(100%)}.panel-bottom--enter-active,.panel-bottom--exit,.panel-left--enter-active,.panel-left--exit,.panel-right--enter-active,.panel-right--exit{transform:translate(0)}.panel-right--exit-active{transform:translate(100%)}.panel-left--exit-active{transform:translate(-100%)}.panel-bottom--exit-active{transform:translateY(100%)}.___SClose_1evro_gg_{cursor:pointer;position:absolute;z-index:1;display:inline-flex;right:0;top:0;padding:12px 12px 16px 12px;color:#a9abb6;border:none;background:none;outline:none}.___SClose_1evro_gg_:hover{color:#8a8e9b}.___SClose_1evro_gg_.__keyboardFocused_1evro_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2)}.___SBack_1evro_gg_{display:flex;align-items:center;color:#6c6e79;font-size:12px;line-height:1.33;margin-bottom:4px;cursor:pointer}.___SBack_1evro_gg_:hover{color:#484a54}.___SBackText_1evro_gg_{margin-left:4px;font-size:12px;line-height:1.42;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___STitle_1evro_gg_{font-size:16px;line-height:1.5;font-weight:700;color:#191b23;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SHeader_1evro_gg_{padding-left:24px;padding-bottom:4px;padding-right:56px;padding-top:4px;min-height:52px;box-shadow:inset 0 -1px 0 #c4c7cf;box-sizing:border-box}.___SFooter_1evro_gg_{min-height:44px;box-shadow:inset 0 1px 0 #c4c7cf;box-sizing:border-box}.___SBody_1evro_gg_{height:100%;overflow:auto;padding-left:24px;padding-bottom:4px;padding-right:40px;padding-top:16px}"
79
79
  /*__inner_css_end__*/
80
- , "sqe8oz_gg_")
80
+ , "1evro_gg_")
81
81
  /*__reshadow_css_end__*/
82
82
  , {
83
- "__SOverlay": "___SOverlay_19nmj_gg_",
84
- "__SPanel": "___SPanel_19nmj_gg_",
85
- "_placement_top": "_placement_top_19nmj_gg_",
86
- "_placement_right": "_placement_right_19nmj_gg_",
87
- "_placement_bottom": "_placement_bottom_19nmj_gg_",
88
- "_placement_left": "_placement_left_19nmj_gg_",
89
- "__SClose": "___SClose_19nmj_gg_",
90
- "_keyboardFocused": "__keyboardFocused_19nmj_gg_",
91
- "__SBack": "___SBack_19nmj_gg_",
92
- "__SBackText": "___SBackText_19nmj_gg_",
93
- "__STitle": "___STitle_19nmj_gg_",
94
- "__SHeader": "___SHeader_19nmj_gg_",
95
- "__SFooter": "___SFooter_19nmj_gg_",
96
- "__SBody": "___SBody_19nmj_gg_"
83
+ "__SOverlay": "___SOverlay_1evro_gg_",
84
+ "__SPanel": "___SPanel_1evro_gg_",
85
+ "_placement_top": "_placement_top_1evro_gg_",
86
+ "_placement_right": "_placement_right_1evro_gg_",
87
+ "_placement_bottom": "_placement_bottom_1evro_gg_",
88
+ "_placement_left": "_placement_left_1evro_gg_",
89
+ "__SClose": "___SClose_1evro_gg_",
90
+ "_keyboardFocused": "__keyboardFocused_1evro_gg_",
91
+ "__SBack": "___SBack_1evro_gg_",
92
+ "__SBackText": "___SBackText_1evro_gg_",
93
+ "__STitle": "___STitle_1evro_gg_",
94
+ "__SHeader": "___SHeader_1evro_gg_",
95
+ "__SFooter": "___SFooter_1evro_gg_",
96
+ "__SBody": "___SBody_1evro_gg_"
97
97
  });
98
98
  var placementTransformMap = {
99
99
  top: ['translate(0, -100%)', 'translate(0, 0)'],
@@ -48,25 +48,25 @@ var style = (
48
48
  /*__reshadow_css_start__*/
49
49
  _sstyled.insert(
50
50
  /*__inner_css_start__*/
51
- ".___SOverlay_19nmj_gg_{position:fixed;top:0;bottom:0;left:0;right:0;margin:0;display:flex;overflow:hidden;z-index:10005;background:rgba(25,27,35,.7);-webkit-overflow-scrolling:touch}.___SPanel_19nmj_gg_{display:flex;flex-direction:column;width:260px;outline:none;font-family:Inter,sans-serif;position:fixed;box-sizing:border-box;will-change:transform;background:#fff;z-index:1}.___SPanel_19nmj_gg_._placement_top_19nmj_gg_{box-shadow:1px 0 12px rgba(25,27,35,.15);width:100%;margin-bottom:auto;top:0;left:0}.___SPanel_19nmj_gg_._placement_right_19nmj_gg_{box-shadow:0px 1px 12px 0px rgba(25, 27, 35, 0.15);height:100vh;margin-left:auto;top:0;right:0}.___SPanel_19nmj_gg_._placement_bottom_19nmj_gg_{box-shadow:1px 0 12px rgba(25,27,35,.15);width:100%;margin-top:auto;bottom:0;left:0}.___SPanel_19nmj_gg_._placement_left_19nmj_gg_{box-shadow:0px 1px 12px 0px rgba(25, 27, 35, 0.15);height:100vh;margin-right:auto;top:0;left:0}.panel-right--enter{transform:translate(100%)}.panel-left--enter{transform:translate(-100%)}.panel-bottom--enter{transform:translateY(100%)}.panel-bottom--enter-active,.panel-bottom--exit,.panel-left--enter-active,.panel-left--exit,.panel-right--enter-active,.panel-right--exit{transform:translate(0)}.panel-right--exit-active{transform:translate(100%)}.panel-left--exit-active{transform:translate(-100%)}.panel-bottom--exit-active{transform:translateY(100%)}.___SClose_19nmj_gg_{cursor:pointer;position:absolute;z-index:1;display:inline-flex;right:0;top:0;padding:12px 12px 16px 12px;color:#a9abb6;border:none;background:none;outline:none}.___SClose_19nmj_gg_:hover{color:#8a8e9b}.___SClose_19nmj_gg_.__keyboardFocused_19nmj_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2)}.___SBack_19nmj_gg_{display:flex;align-items:center;color:#6c6e79;font-size:12px;line-height:1.33;margin-bottom:4px;cursor:pointer}.___SBack_19nmj_gg_:hover{color:#484a54}.___SBackText_19nmj_gg_{margin-left:4px;font-size:12px;line-height:1.42;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___STitle_19nmj_gg_{font-size:16px;line-height:1.5;font-weight:700;color:#191b23;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SHeader_19nmj_gg_{padding-left:24px;padding-bottom:4px;padding-right:56px;padding-top:4px;min-height:52px;box-shadow:inset 0 -1px 0 #c4c7cf;box-sizing:border-box}.___SFooter_19nmj_gg_{min-height:44px;box-shadow:inset 0 1px 0 #c4c7cf;box-sizing:border-box}.___SBody_19nmj_gg_{height:100%;overflow:auto;padding-left:24px;padding-bottom:4px;padding-right:40px;padding-top:16px}"
51
+ ".___SOverlay_1evro_gg_{position:fixed;top:0;bottom:0;left:0;right:0;margin:0;display:flex;overflow:hidden;z-index:10005;background:rgba(25,27,35,.7);-webkit-overflow-scrolling:touch}.___SPanel_1evro_gg_{display:flex;flex-direction:column;width:260px;outline:none;font-family:Inter,sans-serif;position:fixed;box-sizing:border-box;will-change:transform;background:#fff;z-index:1}.___SPanel_1evro_gg_._placement_top_1evro_gg_{box-shadow:1px 0 12px rgba(25,27,35,.15);width:100%;margin-bottom:auto;top:0;left:0}.___SPanel_1evro_gg_._placement_right_1evro_gg_{box-shadow:0px 1px 12px 0px rgba(25, 27, 35, 0.15);height:100vh;margin-left:auto;top:0;right:0}.___SPanel_1evro_gg_._placement_bottom_1evro_gg_{box-shadow:1px 0 12px rgba(25,27,35,.15);width:100%;margin-top:auto;bottom:0;left:0}.___SPanel_1evro_gg_._placement_left_1evro_gg_{box-shadow:0px 1px 12px 0px rgba(25, 27, 35, 0.15);height:100vh;margin-right:auto;top:0;left:0}.panel-right--enter{transform:translate(100%)}.panel-left--enter{transform:translate(-100%)}.panel-bottom--enter{transform:translateY(100%)}.panel-bottom--enter-active,.panel-bottom--exit,.panel-left--enter-active,.panel-left--exit,.panel-right--enter-active,.panel-right--exit{transform:translate(0)}.panel-right--exit-active{transform:translate(100%)}.panel-left--exit-active{transform:translate(-100%)}.panel-bottom--exit-active{transform:translateY(100%)}.___SClose_1evro_gg_{cursor:pointer;position:absolute;z-index:1;display:inline-flex;right:0;top:0;padding:12px 12px 16px 12px;color:#a9abb6;border:none;background:none;outline:none}.___SClose_1evro_gg_:hover{color:#8a8e9b}.___SClose_1evro_gg_.__keyboardFocused_1evro_gg_{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2)}.___SBack_1evro_gg_{display:flex;align-items:center;color:#6c6e79;font-size:12px;line-height:1.33;margin-bottom:4px;cursor:pointer}.___SBack_1evro_gg_:hover{color:#484a54}.___SBackText_1evro_gg_{margin-left:4px;font-size:12px;line-height:1.42;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___STitle_1evro_gg_{font-size:16px;line-height:1.5;font-weight:700;color:#191b23;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.___SHeader_1evro_gg_{padding-left:24px;padding-bottom:4px;padding-right:56px;padding-top:4px;min-height:52px;box-shadow:inset 0 -1px 0 #c4c7cf;box-sizing:border-box}.___SFooter_1evro_gg_{min-height:44px;box-shadow:inset 0 1px 0 #c4c7cf;box-sizing:border-box}.___SBody_1evro_gg_{height:100%;overflow:auto;padding-left:24px;padding-bottom:4px;padding-right:40px;padding-top:16px}"
52
52
  /*__inner_css_end__*/
53
- , "sqe8oz_gg_")
53
+ , "1evro_gg_")
54
54
  /*__reshadow_css_end__*/
55
55
  , {
56
- "__SOverlay": "___SOverlay_19nmj_gg_",
57
- "__SPanel": "___SPanel_19nmj_gg_",
58
- "_placement_top": "_placement_top_19nmj_gg_",
59
- "_placement_right": "_placement_right_19nmj_gg_",
60
- "_placement_bottom": "_placement_bottom_19nmj_gg_",
61
- "_placement_left": "_placement_left_19nmj_gg_",
62
- "__SClose": "___SClose_19nmj_gg_",
63
- "_keyboardFocused": "__keyboardFocused_19nmj_gg_",
64
- "__SBack": "___SBack_19nmj_gg_",
65
- "__SBackText": "___SBackText_19nmj_gg_",
66
- "__STitle": "___STitle_19nmj_gg_",
67
- "__SHeader": "___SHeader_19nmj_gg_",
68
- "__SFooter": "___SFooter_19nmj_gg_",
69
- "__SBody": "___SBody_19nmj_gg_"
56
+ "__SOverlay": "___SOverlay_1evro_gg_",
57
+ "__SPanel": "___SPanel_1evro_gg_",
58
+ "_placement_top": "_placement_top_1evro_gg_",
59
+ "_placement_right": "_placement_right_1evro_gg_",
60
+ "_placement_bottom": "_placement_bottom_1evro_gg_",
61
+ "_placement_left": "_placement_left_1evro_gg_",
62
+ "__SClose": "___SClose_1evro_gg_",
63
+ "_keyboardFocused": "__keyboardFocused_1evro_gg_",
64
+ "__SBack": "___SBack_1evro_gg_",
65
+ "__SBackText": "___SBackText_1evro_gg_",
66
+ "__STitle": "___STitle_1evro_gg_",
67
+ "__SHeader": "___SHeader_1evro_gg_",
68
+ "__SFooter": "___SFooter_1evro_gg_",
69
+ "__SBody": "___SBody_1evro_gg_"
70
70
  });
71
71
  var placementTransformMap = {
72
72
  top: ['translate(0, -100%)', 'translate(0, 0)'],
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@semcore/side-panel",
3
3
  "description": "SEMRush SidePanel Component",
4
- "version": "2.0.5",
4
+ "version": "2.0.8",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
8
8
  "sideEffects": false,
9
- "author": "Roman Lysov <r.lysov@semrush.com>",
9
+ "author": "UI-kit team <ui-kit-team@semrush.com>",
10
10
  "license": "MIT",
11
11
  "scripts": {
12
12
  "build": "build --source=js",
package/src/SidePanel.jsx DELETED
@@ -1,234 +0,0 @@
1
- import React, { useRef } from 'react';
2
- import FocusLock from 'react-focus-lock';
3
- import createComponent, { Component, Root, sstyled } from '@semcore/core';
4
- import { Flex, Box } from '@semcore/flex-box';
5
- import { FadeInOut, Transform } from '@semcore/animation';
6
- import Portal, { PortalProvider } from '@semcore/portal';
7
- import OutsideClick from '@semcore/outside-click';
8
- import CloseIcon from '@semcore/icon/Close/l';
9
- import fire from '@semcore/utils/lib/fire';
10
- import { isAdvanceMode } from '@semcore/utils/lib/findComponent';
11
- import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
12
- import usePreventScroll from '@semcore/utils/lib/use/usePreventScroll';
13
- import { Text } from '@semcore/typography';
14
- import ArrowLeft from '@semcore/icon/ArrowLeft/m';
15
-
16
- import style from './style/side-panel.shadow.css';
17
-
18
- const placementTransformMap = {
19
- top: ['translate(0, -100%)', 'translate(0, 0)'],
20
- right: ['translate(100%, 0)', 'translate(0, 0)'],
21
- bottom: ['translate(0, 100%)', 'translate(0, 0)'],
22
- left: ['translate(-100%, 0)', 'translate(0, 0)'],
23
- };
24
-
25
- class RootSidePanel extends Component {
26
- static displayName = 'SidePanel';
27
- static style = style;
28
- static defaultProps = {
29
- placement: 'right',
30
- duration: 350,
31
- closable: true,
32
- };
33
-
34
- sidebarRef = React.createRef();
35
-
36
- handleSidebarKeyDown = (e) => {
37
- if (e.key === 'Escape') {
38
- e.stopPropagation();
39
- fire(this, 'onClose', 'onEscape', e);
40
- }
41
- };
42
-
43
- handleIconCloseClick = (e) => {
44
- fire(this, 'onClose', 'onCloseClick', e);
45
- };
46
-
47
- handleOutsideClick = (e) => {
48
- fire(this, 'onClose', 'onOutsideClick', e);
49
- };
50
-
51
- isAdvanceMode() {
52
- return isAdvanceMode(this.asProps.Children, [
53
- SidePanel.Overlay.displayName,
54
- SidePanel.Panel.displayName,
55
- ]);
56
- }
57
-
58
- isUsedOverlay() {
59
- return (
60
- !this.isAdvanceMode() || isAdvanceMode(this.asProps.Children, [SidePanel.Overlay.displayName])
61
- );
62
- }
63
-
64
- calculateDelayAnimation(name) {
65
- const delay = this.asProps.duration / 2;
66
- const usedOverlay = this.isUsedOverlay();
67
-
68
- return {
69
- overlay: usedOverlay ? [0, delay] : 0,
70
- panel: usedOverlay ? [delay, 0] : 0,
71
- }[name];
72
- }
73
-
74
- getOverlayProps() {
75
- const { visible, duration } = this.asProps;
76
- return {
77
- visible,
78
- duration,
79
- delay: this.calculateDelayAnimation('overlay'),
80
- };
81
- }
82
-
83
- getPanelProps() {
84
- const { placement, visible, closable, duration } = this.asProps;
85
-
86
- return {
87
- visible,
88
- placement,
89
- closable,
90
- duration,
91
- disableEnforceFocus: !this.isUsedOverlay(),
92
- delay: this.calculateDelayAnimation('panel'),
93
- onOutsideClick: this.handleOutsideClick,
94
- onKeyDown: this.handleSidebarKeyDown,
95
- };
96
- }
97
-
98
- getCloseProps() {
99
- return {
100
- onClick: this.handleIconCloseClick,
101
- };
102
- }
103
-
104
- render() {
105
- const { Children, disablePortal } = this.asProps;
106
-
107
- return (
108
- <Portal disablePortal={disablePortal}>
109
- {this.isAdvanceMode() ? (
110
- <Children />
111
- ) : (
112
- <SidePanel.Overlay>
113
- <Root render={SidePanel.Panel} />
114
- </SidePanel.Overlay>
115
- )}
116
- </Portal>
117
- );
118
- }
119
- }
120
-
121
- function Overlay(props) {
122
- const SOverlay = Root;
123
- usePreventScroll(props.visible);
124
- return sstyled(props.styles)(<SOverlay render={FadeInOut} />);
125
- }
126
-
127
- const FocusLockWrapper = React.forwardRef(function ({ disableEnforceFocus, ...other }, ref) {
128
- return <FocusLock ref={ref} lockProps={other} disabled={disableEnforceFocus} {...other} />;
129
- });
130
-
131
- const TransformWrapper = React.forwardRef(function ({ tag, ...other }, ref) {
132
- return <Transform tag={FocusLockWrapper} ref={ref} as={tag} {...other} />;
133
- });
134
-
135
- function Panel(props) {
136
- const SPanel = Root;
137
- const { Children, styles, visible, closable, placement, onOutsideClick } = props;
138
- const advanceMode = isAdvanceMode(Children, [
139
- SidePanel.Header.displayName,
140
- SidePanel.Body.displayName,
141
- SidePanel.Footer.displayName,
142
- ]);
143
-
144
- const sidebarRef = useRef(null);
145
-
146
- return sstyled(styles)(
147
- <>
148
- {visible && <OutsideClick onOutsideClick={onOutsideClick} excludeRefs={[sidebarRef]} />}
149
- <SPanel
150
- render={TransformWrapper}
151
- tag={Box}
152
- ref={sidebarRef}
153
- tabIndex={-1}
154
- returnFocus={true}
155
- autoFocus={true}
156
- transform={placementTransformMap[placement]}
157
- >
158
- <PortalProvider value={sidebarRef}>
159
- {closable && <SidePanel.Close />}
160
- {advanceMode ? (
161
- <Children />
162
- ) : (
163
- <SidePanel.Body>
164
- <Children />
165
- </SidePanel.Body>
166
- )}
167
- </PortalProvider>
168
- </SPanel>
169
- </>,
170
- );
171
- }
172
-
173
- function Footer(props) {
174
- const SFooter = Root;
175
- return sstyled(props.styles)(<SFooter render={Flex} />);
176
- }
177
-
178
- function Close(props) {
179
- const SClose = Root;
180
- return sstyled(props.styles)(<SClose render={Box} tag="button" />);
181
- }
182
- Close.defaultProps = {
183
- children: <CloseIcon title="Close" />,
184
- };
185
- Close.enhance = [keyboardFocusEnhance()];
186
-
187
- function Title(props) {
188
- const STitle = Root;
189
- return sstyled(props.styles)(<STitle render={Text} tag="h6" />);
190
- }
191
-
192
- function Back(props) {
193
- const SBack = Root;
194
- const SBackText = Text;
195
- const { Children, styles } = props;
196
-
197
- return sstyled(styles)(
198
- <SBack render={Box}>
199
- <ArrowLeft />
200
- <SBackText>
201
- <Children />
202
- </SBackText>
203
- </SBack>,
204
- );
205
- }
206
-
207
- function Body(props) {
208
- const SBody = Root;
209
- return sstyled(props.styles)(<SBody render={Box} />);
210
- }
211
-
212
- function Header(props) {
213
- const SHeader = Root;
214
- const { Children, styles, title } = props;
215
- return sstyled(styles)(
216
- <SHeader render={Box}>
217
- {title && <SidePanel.Title children={title} />}
218
- <Children />
219
- </SHeader>,
220
- );
221
- }
222
-
223
- const SidePanel = createComponent(RootSidePanel, {
224
- Overlay,
225
- Panel,
226
- Close,
227
- Header,
228
- Footer,
229
- Body,
230
- Back,
231
- Title,
232
- });
233
-
234
- export default SidePanel;
package/src/index.d.ts DELETED
@@ -1,70 +0,0 @@
1
- import React, { ComponentProps } from 'react';
2
- import { IPortalProps } from '@semcore/portal';
3
- import { IFadeInOutProps, ITransformProps } from '@semcore/animation';
4
- import { CProps, PropGetterFn, ReturnEl } from '@semcore/core';
5
- import { Box, IBoxProps, Flex } from '@semcore/flex-box';
6
- import { Text } from '@semcore/typography';
7
-
8
- export type OnCloseTriggerType = 'onOutsideClick' | 'onEscape' | 'onCloseClick';
9
- export type OnCloseType = (
10
- trigger: OnCloseTriggerType,
11
- e?: React.MouseEvent | React.KeyboardEvent,
12
- ) => void;
13
-
14
- export type SidePanelPlacement = 'top' | 'left' | 'right' | 'bottom';
15
-
16
- export interface ISidePanelProps extends IPortalProps {
17
- /** Animation display duration in ms
18
- * @default 350
19
- */
20
- duration?: number;
21
- /**
22
- * The property responsible for the visibility of the component
23
- */
24
- visible?: boolean;
25
- /**
26
- * Callback for the component closure
27
- */
28
- onClose?: OnCloseType;
29
- /**
30
- * Property for displaying the close button
31
- * @default true
32
- */
33
- closable?: boolean;
34
- /**
35
- * Position of a dropdown window
36
- * @default right
37
- */
38
- placement?: SidePanelPlacement;
39
- }
40
-
41
- export interface ISidePanelOverlayProps extends IFadeInOutProps, IBoxProps {}
42
-
43
- export interface ISidePanelPanelProps extends ITransformProps, IBoxProps {
44
- onOutsideClick?: (e?: React.SyntheticEvent) => void;
45
- }
46
-
47
- export interface ISidePanelContext {
48
- getOverlayProps?: PropGetterFn;
49
- getPanelProps?: PropGetterFn;
50
- getCloseProps?: PropGetterFn;
51
- }
52
-
53
- export interface ISidePanelHeaderProps extends IBoxProps {
54
- title?: React.ReactNode;
55
- }
56
-
57
- declare const SidePanel: (<T>(
58
- props: CProps<ISidePanelProps & T, ISidePanelContext>,
59
- ) => ReturnEl) & {
60
- Header: <T>(props: ISidePanelHeaderProps & T) => ReturnEl;
61
- Back: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
62
- Body: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
63
- Footer: <T>(props: ComponentProps<typeof Flex> & T) => ReturnEl;
64
- Title: <T>(props: ComponentProps<typeof Text> & T) => ReturnEl;
65
- Overlay: <T>(props: ISidePanelOverlayProps & T) => ReturnEl;
66
- Panel: <T>(props: ISidePanelPanelProps & T) => ReturnEl;
67
- Close: typeof Box;
68
- };
69
-
70
- export default SidePanel;
package/src/index.js DELETED
@@ -1 +0,0 @@
1
- export { default } from './SidePanel';
@@ -1,167 +0,0 @@
1
- @import '@semcore/utils/style/var.css';
2
-
3
- SOverlay {
4
- position: fixed;
5
- top: 0;
6
- bottom: 0;
7
- left: 0;
8
- right: 0;
9
- margin: 0;
10
- display: flex;
11
- overflow: hidden;
12
- z-index: 10005;
13
- background: color-mod(var(--gray-800) a(70%));
14
- -webkit-overflow-scrolling: touch;
15
- }
16
-
17
- SPanel {
18
- display: flex;
19
- flex-direction: column;
20
- width: 260px;
21
- outline: none;
22
- font-family: Inter, sans-serif;
23
- position: fixed;
24
- box-sizing: border-box;
25
- will-change: transform;
26
- background: white;
27
- z-index: 1;
28
- }
29
-
30
- SPanel[placement='top'] {
31
- box-shadow: 1px 0 12px rgba(25, 27, 35, 0.15);
32
- width: 100%;
33
- margin-bottom: auto;
34
- top: 0;
35
- left: 0;
36
- }
37
-
38
- SPanel[placement='right'] {
39
- box-shadow: var(--box-shadow-popper);
40
- height: 100vh;
41
- margin-left: auto;
42
- top: 0;
43
- right: 0;
44
- }
45
-
46
- SPanel[placement='bottom'] {
47
- box-shadow: 1px 0 12px rgba(25, 27, 35, 0.15);
48
- width: 100%;
49
- margin-top: auto;
50
- bottom: 0;
51
- left: 0;
52
- }
53
-
54
- SPanel[placement='left'] {
55
- box-shadow: var(--box-shadow-popper);
56
- height: 100vh;
57
- margin-right: auto;
58
- top: 0;
59
- left: 0;
60
- }
61
-
62
- .panel-right--enter {
63
- transform: translate(100%, 0);
64
- }
65
- .panel-left--enter {
66
- transform: translate(-100%, 0);
67
- }
68
- .panel-bottom--enter {
69
- transform: translate(0, 100%);
70
- }
71
- .panel-right--enter-active,
72
- .panel-left--enter-active,
73
- .panel-bottom--enter-active,
74
- .panel-right--exit,
75
- .panel-left--exit,
76
- .panel-bottom--exit {
77
- transform: translate(0, 0);
78
- }
79
- .panel-right--exit-active {
80
- transform: translate(100%, 0);
81
- }
82
- .panel-left--exit-active {
83
- transform: translate(-100%, 0);
84
- }
85
- .panel-bottom--exit-active {
86
- transform: translate(0, 100%);
87
- }
88
-
89
- SClose {
90
- cursor: pointer;
91
- position: absolute;
92
- z-index: 1;
93
- display: inline-flex;
94
- right: 0;
95
- top: 0;
96
- padding: 12px 12px 16px 12px;
97
- color: var(--gray-300);
98
- border: none;
99
- background: none;
100
- outline: none;
101
-
102
- &:hover {
103
- color: var(--gray-400);
104
- }
105
- }
106
-
107
- SClose[keyboardFocused] {
108
- box-shadow: var(--keyboard-focus);
109
- }
110
-
111
- SBack {
112
- display: flex;
113
- align-items: center;
114
- color: var(--gray-500);
115
- font-size: var(--fs-100);
116
- line-height: var(--lh-100);
117
- margin-bottom: 4px;
118
- cursor: pointer;
119
-
120
- &:hover {
121
- color: var(--gray-600);
122
- }
123
- }
124
-
125
- SBackText {
126
- margin-left: 4px;
127
- font-size: var(--fs-100);
128
- line-height: var(--lh-200);
129
- white-space: nowrap;
130
- overflow: hidden;
131
- text-overflow: ellipsis;
132
- }
133
-
134
- STitle {
135
- font-size: var(--fs-300);
136
- line-height: var(--lh-300);
137
- font-weight: 700;
138
- color: var(--gray-800);
139
- white-space: nowrap;
140
- overflow: hidden;
141
- text-overflow: ellipsis;
142
- }
143
-
144
- SHeader {
145
- padding-left: 24px;
146
- padding-bottom: 4px;
147
- padding-right: 56px;
148
- padding-top: 4px;
149
- min-height: 52px;
150
- box-shadow: inset 0 -1px 0 var(--gray-200);
151
- box-sizing: border-box;
152
- }
153
-
154
- SFooter {
155
- min-height: 44px;
156
- box-shadow: inset 0 1px 0 var(--gray-200);
157
- box-sizing: border-box;
158
- }
159
-
160
- SBody {
161
- height: 100%;
162
- overflow: auto;
163
- padding-left: 24px;
164
- padding-bottom: 4px;
165
- padding-right: 40px;
166
- padding-top: 16px;
167
- }