@semcore/side-panel 1.1.0 → 1.3.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 +27 -0
- package/lib/cjs/SidePanel.js +66 -102
- package/lib/cjs/SidePanel.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/side-panel.shadow.css +1 -1
- package/lib/es6/SidePanel.js +73 -104
- package/lib/es6/SidePanel.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/side-panel.shadow.css +1 -1
- package/lib/types/index.d.ts +60 -2
- package/package.json +6 -5
- package/src/SidePanel.js +176 -0
- package/src/index.d.ts +60 -0
- package/src/{index.tsx → index.js} +0 -0
- package/src/style/side-panel.shadow.css +1 -1
- package/lib/types/SidePanel.d.ts +0 -110
- package/src/SidePanel.tsx +0 -271
package/lib/es6/SidePanel.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
@@ -6,70 +7,52 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import
|
|
10
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
11
|
+
import { assignProps as _assignProps4 } from "@semcore/core";
|
|
12
|
+
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
13
|
+
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
14
|
+
import { assignProps as _assignProps } from "@semcore/core";
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10
19
|
|
|
11
20
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
21
|
|
|
13
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
22
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
23
|
|
|
15
|
-
import React, { useRef } from 'react';
|
|
24
|
+
import React, { ComponentProps, useRef } from 'react';
|
|
16
25
|
import FocusLock from 'react-focus-lock';
|
|
17
|
-
import createComponent, { Component,
|
|
26
|
+
import createComponent, { Component, Root, sstyled } from '@semcore/core';
|
|
18
27
|
import { Box } from '@semcore/flex-box';
|
|
19
|
-
import { FadeInOut, Transform } from '@semcore/animation';
|
|
20
|
-
import Portal, { PortalProvider } from '@semcore/portal';
|
|
28
|
+
import { FadeInOut, IFadeInOutProps, ITransformProps, Transform } from '@semcore/animation';
|
|
29
|
+
import Portal, { IPortalProps, PortalProvider } from '@semcore/portal';
|
|
21
30
|
import OutsideClick from '@semcore/outside-click';
|
|
22
|
-
import
|
|
31
|
+
import CloseIcon from '@semcore/icon/Close/l';
|
|
23
32
|
import fire from '@semcore/utils/lib/fire';
|
|
24
|
-
import findComponent from '@semcore/utils/lib/findComponent';
|
|
33
|
+
import findComponent, { isAdvanceMode as _isAdvanceMode } from '@semcore/utils/lib/findComponent';
|
|
25
34
|
import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
26
35
|
import usePreventScroll from '@semcore/utils/lib/use/usePreventScroll';
|
|
27
36
|
|
|
28
37
|
/*__reshadow-styles__:"./style/side-panel.shadow.css"*/
|
|
29
|
-
var
|
|
38
|
+
var style = (
|
|
30
39
|
/*__reshadow_css_start__*/
|
|
31
|
-
|
|
40
|
+
_sstyled.insert(
|
|
32
41
|
/*__inner_css_start__*/
|
|
33
|
-
".
|
|
42
|
+
".___SOverlay_tjy0q_gg_{position:fixed;top:0;bottom:0;left:0;right:0;margin:0;display:flex;overflow:hidden;z-index:10005;background:rgba(0,0,0,.8);-webkit-overflow-scrolling:touch}.___SPanel_tjy0q_gg_{padding:24px;width:256px;outline:none;position:fixed;box-sizing:border-box;will-change:transform;background:#fff;z-index:1}.___SPanel_tjy0q_gg_._placement_top_tjy0q_gg_{box-shadow:3px 0 8px rgba(0,0,0,.2);width:100%;margin-bottom:auto;top:0;left:0}.___SPanel_tjy0q_gg_._placement_right_tjy0q_gg_{box-shadow:0 3px 8px rgba(0,0,0,.2);height:100vh;margin-left:auto;top:0;right:0}.___SPanel_tjy0q_gg_._placement_bottom_tjy0q_gg_{box-shadow:3px 0 8px rgba(0,0,0,.2);width:100%;margin-top:auto;bottom:0;left:0}.___SPanel_tjy0q_gg_._placement_left_tjy0q_gg_{box-shadow:0 3px 8px rgba(0,0,0,.2);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_tjy0q_gg_{display:inline-flex;position:absolute;right:0;top:0;padding:12px;color:#a6b0b3;cursor:pointer;z-index:1;border:none;background:none;outline:none}.___SClose_tjy0q_gg_:hover{color:#929b9e}.___SClose_tjy0q_gg_.__keyboardFocused_tjy0q_gg_{box-shadow:0 0 0 3px rgba(43,148,225,.3)}"
|
|
34
43
|
/*__inner_css_end__*/
|
|
35
|
-
, "
|
|
44
|
+
, "1ohwmsk_gg_")
|
|
36
45
|
/*__reshadow_css_end__*/
|
|
37
46
|
, {
|
|
38
|
-
"__SOverlay": "
|
|
39
|
-
"__SPanel": "
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
"panel-bottom--enter": "_panel-bottom--enter_17hwf_gg_",
|
|
48
|
-
"panel-right--enter-active": "_panel-right--enter-active_1spyt_gg_",
|
|
49
|
-
"panel-left--enter-active": "_panel-left--enter-active_1s0d8_gg_",
|
|
50
|
-
"panel-bottom--enter-active": "_panel-bottom--enter-active_1jdqn_gg_",
|
|
51
|
-
"panel-right--exit": "_panel-right--exit_1xlyx_gg_",
|
|
52
|
-
"panel-left--exit": "_panel-left--exit_1q1nr_gg_",
|
|
53
|
-
"panel-bottom--exit": "_panel-bottom--exit_xqwhz_gg_",
|
|
54
|
-
"panel-right--exit-active": "_panel-right--exit-active_vs704_gg_",
|
|
55
|
-
"panel-left--exit-active": "_panel-left--exit-active_1sp3h_gg_",
|
|
56
|
-
"panel-bottom--exit-active": "_panel-bottom--exit-active_1vrkp_gg_",
|
|
57
|
-
"__SClose": "___SClose_14x34_gg_",
|
|
58
|
-
"_keyboardFocused": "__keyboardFocused_14x34_gg_"
|
|
59
|
-
}),
|
|
60
|
-
style = _extends({}, _ref);
|
|
61
|
-
|
|
62
|
-
if (false) {
|
|
63
|
-
/*__reshadow_css_start__*/
|
|
64
|
-
__css__(
|
|
65
|
-
/*__inner_css_start__*/
|
|
66
|
-
"@media (max-width: 768px) {\n\n.___SClose_14x34_gg_ {\n padding: 15.6px\n}}"
|
|
67
|
-
/*__inner_css_end__*/
|
|
68
|
-
, "1felyt6_gg_")
|
|
69
|
-
/*__reshadow_css_end__*/
|
|
70
|
-
;
|
|
71
|
-
}
|
|
72
|
-
|
|
47
|
+
"__SOverlay": "___SOverlay_tjy0q_gg_",
|
|
48
|
+
"__SPanel": "___SPanel_tjy0q_gg_",
|
|
49
|
+
"_placement_top": "_placement_top_tjy0q_gg_",
|
|
50
|
+
"_placement_right": "_placement_right_tjy0q_gg_",
|
|
51
|
+
"_placement_bottom": "_placement_bottom_tjy0q_gg_",
|
|
52
|
+
"_placement_left": "_placement_left_tjy0q_gg_",
|
|
53
|
+
"__SClose": "___SClose_tjy0q_gg_",
|
|
54
|
+
"_keyboardFocused": "__keyboardFocused_tjy0q_gg_"
|
|
55
|
+
});
|
|
73
56
|
var placementTransformMap = {
|
|
74
57
|
top: ['translate(0, -100%)', 'translate(0, 0)'],
|
|
75
58
|
right: ['translate(100%, 0)', 'translate(0, 0)'],
|
|
@@ -116,12 +99,12 @@ var RootSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
116
99
|
_createClass(RootSidePanel, [{
|
|
117
100
|
key: "isAdvanceMode",
|
|
118
101
|
value: function isAdvanceMode() {
|
|
119
|
-
return
|
|
102
|
+
return _isAdvanceMode(this.asProps.Children, [SidePanel.Overlay.displayName, SidePanel.Panel.displayName]);
|
|
120
103
|
}
|
|
121
104
|
}, {
|
|
122
105
|
key: "isUsedOverlay",
|
|
123
106
|
value: function isUsedOverlay() {
|
|
124
|
-
return !this.isAdvanceMode() ||
|
|
107
|
+
return !this.isAdvanceMode() || _isAdvanceMode(this.asProps.Children, [SidePanel.Overlay.displayName]);
|
|
125
108
|
}
|
|
126
109
|
}, {
|
|
127
110
|
key: "calculateDelayAnimation",
|
|
@@ -174,15 +157,14 @@ var RootSidePanel = /*#__PURE__*/function (_Component) {
|
|
|
174
157
|
}, {
|
|
175
158
|
key: "render",
|
|
176
159
|
value: function render() {
|
|
177
|
-
var
|
|
160
|
+
var _ref = this ? this.asProps : arguments[0];
|
|
161
|
+
|
|
178
162
|
var _this$asProps3 = this.asProps,
|
|
179
163
|
Children = _this$asProps3.Children,
|
|
180
164
|
disablePortal = _this$asProps3.disablePortal;
|
|
181
165
|
return /*#__PURE__*/React.createElement(Portal, {
|
|
182
166
|
disablePortal: disablePortal
|
|
183
|
-
}, this.isAdvanceMode() ? /*#__PURE__*/React.createElement(Children, null) : /*#__PURE__*/React.createElement(SidePanel.Overlay, null, /*#__PURE__*/React.createElement(
|
|
184
|
-
render: SidePanel.Panel
|
|
185
|
-
})));
|
|
167
|
+
}, this.isAdvanceMode() ? /*#__PURE__*/React.createElement(Children, null) : /*#__PURE__*/React.createElement(SidePanel.Overlay, null, /*#__PURE__*/React.createElement(SidePanel.Panel, _assignProps({}, _ref))));
|
|
186
168
|
}
|
|
187
169
|
}]);
|
|
188
170
|
|
|
@@ -199,22 +181,18 @@ _defineProperty(RootSidePanel, "defaultProps", {
|
|
|
199
181
|
closable: true
|
|
200
182
|
});
|
|
201
183
|
|
|
202
|
-
var styled_c8 = create([]);
|
|
203
|
-
|
|
204
184
|
function Overlay(props) {
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
visible: visible
|
|
212
|
-
}))));
|
|
185
|
+
var _ref2 = this ? this.asProps : arguments[0],
|
|
186
|
+
_ref5;
|
|
187
|
+
|
|
188
|
+
var SOverlay = FadeInOut;
|
|
189
|
+
usePreventScroll(props.visible);
|
|
190
|
+
return _ref5 = sstyled(props.styles), /*#__PURE__*/React.createElement(SOverlay, _ref5.cn("SOverlay", _objectSpread({}, _assignProps2({}, _ref2))));
|
|
213
191
|
}
|
|
214
192
|
|
|
215
|
-
var FocusLockWrapper = /*#__PURE__*/React.forwardRef(function (
|
|
216
|
-
var disableEnforceFocus =
|
|
217
|
-
other = _objectWithoutProperties(
|
|
193
|
+
var FocusLockWrapper = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
194
|
+
var disableEnforceFocus = _ref8.disableEnforceFocus,
|
|
195
|
+
other = _objectWithoutProperties(_ref8, ["disableEnforceFocus"]);
|
|
218
196
|
|
|
219
197
|
return /*#__PURE__*/React.createElement(FocusLock, _extends({
|
|
220
198
|
ref: ref,
|
|
@@ -222,9 +200,9 @@ var FocusLockWrapper = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
222
200
|
disabled: disableEnforceFocus
|
|
223
201
|
}, other));
|
|
224
202
|
});
|
|
225
|
-
var TransformWrapper = /*#__PURE__*/React.forwardRef(function (
|
|
226
|
-
var tag =
|
|
227
|
-
other = _objectWithoutProperties(
|
|
203
|
+
var TransformWrapper = /*#__PURE__*/React.forwardRef(function (_ref9, ref) {
|
|
204
|
+
var tag = _ref9.tag,
|
|
205
|
+
other = _objectWithoutProperties(_ref9, ["tag"]);
|
|
228
206
|
|
|
229
207
|
return /*#__PURE__*/React.createElement(Transform, _extends({
|
|
230
208
|
tag: FocusLockWrapper,
|
|
@@ -232,55 +210,46 @@ var TransformWrapper = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
232
210
|
as: tag
|
|
233
211
|
}, other));
|
|
234
212
|
});
|
|
235
|
-
var styled_12c = create([]);
|
|
236
213
|
|
|
237
214
|
function Panel(props) {
|
|
238
|
-
var
|
|
239
|
-
|
|
215
|
+
var _ref3 = this ? this.asProps : arguments[0],
|
|
216
|
+
_ref6;
|
|
217
|
+
|
|
218
|
+
var SPanel = TransformWrapper;
|
|
219
|
+
var Children = props.Children,
|
|
240
220
|
styles = props.styles,
|
|
241
221
|
visible = props.visible,
|
|
242
222
|
closable = props.closable,
|
|
243
223
|
placement = props.placement,
|
|
244
224
|
onOutsideClick = props.onOutsideClick;
|
|
245
225
|
var sidebarRef = useRef(null);
|
|
246
|
-
return
|
|
247
|
-
onOutsideClick: onOutsideClick,
|
|
248
|
-
excludeRefs: [sidebarRef]
|
|
249
|
-
})), /*#__PURE__*/React.createElement(SPanel,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}), /*#__PURE__*/React.createElement(PortalProvider, map("PortalProvider", {
|
|
260
|
-
value: sidebarRef
|
|
261
|
-
}), closable && /*#__PURE__*/React.createElement(SidePanel.Close, {
|
|
262
|
-
className: styled.styles["__SidePanel.Close"]
|
|
263
|
-
}), /*#__PURE__*/React.createElement(Children, {
|
|
264
|
-
className: styled.styles["__Children"]
|
|
265
|
-
}))))));
|
|
226
|
+
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, visible && /*#__PURE__*/React.createElement(OutsideClick, _ref6.cn("OutsideClick", {
|
|
227
|
+
"onOutsideClick": onOutsideClick,
|
|
228
|
+
"excludeRefs": [sidebarRef]
|
|
229
|
+
})), /*#__PURE__*/React.createElement(SPanel, _ref6.cn("SPanel", _objectSpread({}, _assignProps3({
|
|
230
|
+
"tag": Box,
|
|
231
|
+
"ref": sidebarRef,
|
|
232
|
+
"tabIndex": -1,
|
|
233
|
+
"returnFocus": true,
|
|
234
|
+
"autoFocus": true,
|
|
235
|
+
"transform": placementTransformMap[placement]
|
|
236
|
+
}, _ref3))), /*#__PURE__*/React.createElement(PortalProvider, _ref6.cn("PortalProvider", {
|
|
237
|
+
"value": sidebarRef
|
|
238
|
+
}), closable && /*#__PURE__*/React.createElement(SidePanel.Close, null), /*#__PURE__*/React.createElement(Children, _ref6.cn("Children", {})))));
|
|
266
239
|
}
|
|
267
240
|
|
|
268
|
-
var styled_190 = create([]);
|
|
269
|
-
|
|
270
241
|
function Close(props) {
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
tag: "button"
|
|
277
|
-
|
|
278
|
-
keyboardFocused: keyboardFocused
|
|
279
|
-
}))));
|
|
242
|
+
var _ref4 = this ? this.asProps : arguments[0],
|
|
243
|
+
_ref7;
|
|
244
|
+
|
|
245
|
+
var SClose = Box;
|
|
246
|
+
return _ref7 = sstyled(props.styles), /*#__PURE__*/React.createElement(SClose, _ref7.cn("SClose", _objectSpread({}, _assignProps4({
|
|
247
|
+
"tag": "button"
|
|
248
|
+
}, _ref4))));
|
|
280
249
|
}
|
|
281
250
|
|
|
282
251
|
Close.defaultProps = {
|
|
283
|
-
children: /*#__PURE__*/React.createElement(
|
|
252
|
+
children: /*#__PURE__*/React.createElement(CloseIcon, {
|
|
284
253
|
title: "Close"
|
|
285
254
|
})
|
|
286
255
|
};
|
package/lib/es6/SidePanel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/SidePanel.tsx"],"names":["React","useRef","FocusLock","createComponent","Component","styled","Box","FadeInOut","Transform","Portal","PortalProvider","OutsideClick","CloseS","fire","findComponent","keyboardFocusEnhance","usePreventScroll","placementTransformMap","top","right","bottom","left","RootSidePanel","createRef","e","key","stopPropagation","asProps","Children","SidePanel","Overlay","displayName","Panel","isAdvanceMode","name","delay","duration","usedOverlay","isUsedOverlay","overlay","panel","visible","calculateDelayAnimation","placement","closable","disableEnforceFocus","onOutsideClick","handleOutsideClick","onKeyDown","handleSidebarKeyDown","onClick","handleIconCloseClick","Root","disablePortal","style","props","SOverlay","styles","FocusLockWrapper","forwardRef","ref","other","TransformWrapper","tag","SPanel","sidebarRef","Close","SClose","keyboardFocused","defaultProps","children","enhance"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgCC,MAAhC,QAA8C,OAA9C;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,eAAP,IACEC,SADF,EAKEC,MALF,wCAMO,qBANP;AAOA,SAASC,GAAT,QAAoB,yBAApB;AACA,SAASC,SAAT,EAAsDC,SAAtD,QAAuE,0BAAvE;AACA,OAAOC,MAAP,IAA+BC,cAA/B,QAAqD,uBAArD;AACA,OAAOC,YAAP,MAAyB,8BAAzB;AACA,OAAOC,MAAP,MAAmB,iCAAnB;AACA,OAAOC,IAAP,MAAiB,+BAAjB;AACA,OAAOC,aAAP,MAA0B,wCAA1B;AACA,OAAOC,oBAAP,MAAiC,wDAAjC;AACA,OAAOC,gBAAP,MAA6B,+CAA7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,IAAMC,qBAAqB,GAAG;AAC5BC,EAAAA,GAAG,EAAE,CAAC,qBAAD,EAAwB,iBAAxB,CADuB;AAE5BC,EAAAA,KAAK,EAAE,CAAC,oBAAD,EAAuB,iBAAvB,CAFqB;AAG5BC,EAAAA,MAAM,EAAE,CAAC,oBAAD,EAAuB,iBAAvB,CAHoB;AAI5BC,EAAAA,IAAI,EAAE,CAAC,qBAAD,EAAwB,iBAAxB;AAJsB,CAA9B;;IAOMC,a;;;;;;;;;;;;;;;;8EASStB,KAAK,CAACuB,SAAN,E;;2EAEU,UAACC,CAAD,EAAO;AAC5B,UAAIA,CAAC,CAACC,GAAF,KAAU,QAAd,EAAwB;AACtBD,QAAAA,CAAC,CAACE,eAAF;AACAb,QAAAA,IAAI,gCAAO,SAAP,EAAkB,UAAlB,EAA8BW,CAA9B,CAAJ;AACD;AACF,K;;2EAEsB,UAACA,CAAD,EAAO;A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from 'react-focus-lock';\nimport createComponent, {\n Component,\n IFunctionProps,\n Merge,\n PropGetter,\n styled,\n} from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport { FadeInOut, IFadeInOutProps, ITransformProps, Transform } from '@semcore/animation';\nimport Portal, { IPortalProps, PortalProvider } from '@semcore/portal';\nimport OutsideClick from '@semcore/outside-click';\nimport CloseS from '@semcore/icon/lib/Close/s';\nimport fire from '@semcore/utils/lib/fire';\nimport findComponent from '@semcore/utils/lib/findComponent';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport usePreventScroll from '@semcore/utils/lib/use/usePreventScroll';\n\nimport style from './style/side-panel.shadow.css';\n\nexport type OnCloseTriggerType = 'onOutsideClick' | 'onEscape' | 'onCloseClick';\nexport type OnCloseType = (\n trigger: OnCloseTriggerType,\n e?: React.MouseEvent | React.KeyboardEvent,\n) => void;\n\nexport type SidePanelPlacement = 'top' | 'left' | 'right' | 'bottom';\n\nexport interface ISidePanelProps extends IPortalProps {\n /** Animation display duration in ms\n * @default 350\n */\n duration?: number;\n /**\n * The property responsible for the visibility of the component\n */\n visible?: boolean;\n /**\n * Callback for the component closure\n */\n onClose?: OnCloseType;\n /**\n * Property for displaying the close button\n * @default true\n */\n closable?: boolean;\n /**\n * Position of a dropdown window\n * @default right\n */\n placement?: SidePanelPlacement;\n}\n\nexport interface ISidePanelOverlayProps extends IFadeInOutProps {\n /**\n * @link ISidePanelProps.visible\n */\n visible?: ISidePanelProps['visible'];\n}\n\nexport interface ISidePanelPanelProps extends ITransformProps {\n /**\n * @link ISidePanelProps.visible\n */\n visible?: ISidePanelProps['visible'];\n /**\n * @link ISidePanelProps.placement\n */\n placement?: ISidePanelProps['placement'];\n /**\n * @link ISidePanelProps.closable\n */\n closable?: ISidePanelProps['closable'];\n\n onOutsideClick?: (e?: React.SyntheticEvent) => void;\n}\n\nexport interface ISidePanelContext extends ISidePanelProps {\n /**\n * The method that encapsulates the props needed to run SidePanel.Overlay\n */\n getOverlayProps?: PropGetter<RootSidePanel['getOverlayProps']>;\n /**\n * The method that encapsulates the props needed to run SidePanel.Panel\n */\n getPanelProps?: PropGetter<RootSidePanel['getPanelProps']>;\n /**\n * The method that encapsulates the props needed to run SidePanel.Close\n */\n getCloseProps?: PropGetter<RootSidePanel['getCloseProps']>;\n}\n\nconst placementTransformMap = {\n top: ['translate(0, -100%)', 'translate(0, 0)'],\n right: ['translate(100%, 0)', 'translate(0, 0)'],\n bottom: ['translate(0, 100%)', 'translate(0, 0)'],\n left: ['translate(-100%, 0)', 'translate(0, 0)'],\n};\n\nclass RootSidePanel extends Component<ISidePanelProps> {\n static displayName = 'SidePanel';\n static style = style;\n static defaultProps = {\n placement: 'right',\n duration: 350,\n closable: true,\n };\n\n sidebarRef = React.createRef<HTMLElement>();\n\n handleSidebarKeyDown = (e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n fire(this, 'onClose', 'onEscape', e);\n }\n };\n\n handleIconCloseClick = (e) => {\n fire(this, 'onClose', 'onCloseClick', e);\n };\n\n handleOutsideClick = (e) => {\n fire(this, 'onClose', 'onOutsideClick', e);\n };\n\n isAdvanceMode() {\n return !!findComponent(this.asProps.Children, [\n SidePanel.Overlay.displayName,\n SidePanel.Panel.displayName,\n ]);\n }\n\n isUsedOverlay() {\n return (\n !this.isAdvanceMode() ||\n !!findComponent(this.asProps.Children, [SidePanel.Overlay.displayName])\n );\n }\n\n calculateDelayAnimation(name) {\n const delay = this.asProps.duration / 2;\n const usedOverlay = this.isUsedOverlay();\n\n return {\n overlay: usedOverlay ? [0, delay] : 0,\n panel: usedOverlay ? [delay, 0] : 0,\n }[name];\n }\n\n getOverlayProps() {\n const { visible, duration } = this.asProps;\n return {\n visible,\n duration,\n delay: this.calculateDelayAnimation('overlay'),\n };\n }\n\n getPanelProps() {\n const { placement, visible, closable, duration } = this.asProps;\n\n return {\n visible,\n placement,\n closable,\n duration,\n disableEnforceFocus: !this.isUsedOverlay(),\n delay: this.calculateDelayAnimation('panel'),\n onOutsideClick: this.handleOutsideClick,\n onKeyDown: this.handleSidebarKeyDown,\n };\n }\n\n getCloseProps() {\n return {\n onClick: this.handleIconCloseClick,\n };\n }\n\n render() {\n const Root = this.Root;\n const { Children, disablePortal } = this.asProps;\n\n return (\n <Portal disablePortal={disablePortal}>\n {this.isAdvanceMode() ? (\n <Children />\n ) : (\n <SidePanel.Overlay>\n <Root render={SidePanel.Panel} />\n </SidePanel.Overlay>\n )}\n </Portal>\n );\n }\n}\n\nfunction Overlay(props: IFunctionProps<ISidePanelOverlayProps>) {\n const { Root: SOverlay, styles, visible } = props;\n usePreventScroll(visible);\n\n return styled(styles)(<SOverlay render={FadeInOut} visible={visible} />);\n}\n\nconst FocusLockWrapper = React.forwardRef<HTMLElement, any>(function (\n { disableEnforceFocus, ...other },\n ref,\n) {\n return <FocusLock ref={ref} lockProps={other} disabled={disableEnforceFocus} {...other} />;\n});\n\nconst TransformWrapper = React.forwardRef<HTMLElement, any>(function ({ tag, ...other }, ref) {\n return <Transform tag={FocusLockWrapper} ref={ref} as={tag} {...other} />;\n});\n\nfunction Panel(props: IFunctionProps<ISidePanelPanelProps>) {\n const { Root: SPanel, Children, styles, visible, closable, placement, onOutsideClick } = props;\n\n const sidebarRef = useRef<HTMLElement>(null);\n\n return styled(styles)(\n <>\n {visible && <OutsideClick onOutsideClick={onOutsideClick} excludeRefs={[sidebarRef]} />}\n <SPanel\n render={TransformWrapper}\n tag={Box}\n ref={sidebarRef}\n placement={placement}\n visible={visible}\n tabIndex={-1}\n returnFocus={true}\n autoFocus={true}\n transform={placementTransformMap[placement]}\n >\n <PortalProvider value={sidebarRef}>\n {closable && <SidePanel.Close />}\n <Children />\n </PortalProvider>\n </SPanel>\n </>,\n );\n}\n\nfunction Close(props) {\n const { Root: SClose, styles, keyboardFocused } = props;\n return styled(styles)(\n <SClose render={Box} tag=\"button\" tabIndex={0} keyboardFocused={keyboardFocused} />,\n );\n}\n\nClose.defaultProps = {\n children: <CloseS title=\"Close\" />,\n};\nClose.enhance = [keyboardFocusEnhance()];\n\nconst SidePanel = createComponent<\n ISidePanelProps,\n {\n Overlay: Merge<ISidePanelOverlayProps, ComponentProps<typeof Box>>;\n Panel: Merge<ISidePanelPanelProps, ComponentProps<typeof Box>>;\n Close: ComponentProps<typeof Box>;\n },\n ISidePanelContext\n>(RootSidePanel, {\n Overlay,\n Panel,\n Close,\n});\n\nexport default SidePanel;\n"],"file":"SidePanel.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/SidePanel.js"],"names":["React","ComponentProps","useRef","FocusLock","createComponent","Component","Root","sstyled","Box","FadeInOut","IFadeInOutProps","ITransformProps","Transform","Portal","IPortalProps","PortalProvider","OutsideClick","CloseIcon","fire","findComponent","isAdvanceMode","keyboardFocusEnhance","usePreventScroll","placementTransformMap","top","right","bottom","left","RootSidePanel","createRef","e","key","stopPropagation","asProps","Children","SidePanel","Overlay","displayName","Panel","name","delay","duration","usedOverlay","isUsedOverlay","overlay","panel","visible","calculateDelayAnimation","placement","closable","disableEnforceFocus","onOutsideClick","handleOutsideClick","onKeyDown","handleSidebarKeyDown","onClick","handleIconCloseClick","disablePortal","style","props","SOverlay","styles","FocusLockWrapper","forwardRef","ref","other","TransformWrapper","tag","SPanel","sidebarRef","Close","SClose","defaultProps","children","enhance"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,cAAhB,EAAgCC,MAAhC,QAA8C,OAA9C;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,IAArC,EAA2CC,OAA3C,QAA0D,eAA1D;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,SAASC,SAAT,EAAoBC,eAApB,EAAqCC,eAArC,EAAsDC,SAAtD,QAAuE,oBAAvE;AACA,OAAOC,MAAP,IAAiBC,YAAjB,EAA+BC,cAA/B,QAAqD,iBAArD;AACA,OAAOC,YAAP,MAAyB,wBAAzB;A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;AAAzB,cAA7B;AACD;;AAEDS,KAAK,CAACE,YAAN,GAAqB;AACnBC,EAAAA,QAAQ,eAAE,oBAAC,SAAD;AAAW,IAAA,KAAK,EAAC;AAAjB;AADS,CAArB;AAGAH,KAAK,CAACI,OAAN,GAAgB,CAACrD,oBAAoB,EAArB,CAAhB;AAEA,IAAMc,SAAS,GAAG/B,eAAe,CAACwB,aAAD,EAAgB;AAC/CQ,EAAAA,OAAO,EAAPA,OAD+C;AAE/CE,EAAAA,KAAK,EAALA,KAF+C;AAG/CgC,EAAAA,KAAK,EAALA;AAH+C,CAAhB,CAAjC;AAMA,eAAenC,SAAf","sourcesContent":["import React, { ComponentProps, useRef } from 'react';\nimport FocusLock from 'react-focus-lock';\nimport createComponent, { Component, Root, sstyled } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport { FadeInOut, IFadeInOutProps, ITransformProps, Transform } from '@semcore/animation';\nimport Portal, { IPortalProps, PortalProvider } from '@semcore/portal';\nimport OutsideClick from '@semcore/outside-click';\nimport CloseIcon from '@semcore/icon/Close/l';\nimport fire from '@semcore/utils/lib/fire';\nimport findComponent, { isAdvanceMode } from '@semcore/utils/lib/findComponent';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport usePreventScroll from '@semcore/utils/lib/use/usePreventScroll';\n\nimport style from './style/side-panel.shadow.css';\n\nconst placementTransformMap = {\n top: ['translate(0, -100%)', 'translate(0, 0)'],\n right: ['translate(100%, 0)', 'translate(0, 0)'],\n bottom: ['translate(0, 100%)', 'translate(0, 0)'],\n left: ['translate(-100%, 0)', 'translate(0, 0)'],\n};\n\nclass RootSidePanel extends Component {\n static displayName = 'SidePanel';\n static style = style;\n static defaultProps = {\n placement: 'right',\n duration: 350,\n closable: true,\n };\n\n sidebarRef = React.createRef();\n\n handleSidebarKeyDown = (e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n fire(this, 'onClose', 'onEscape', e);\n }\n };\n\n handleIconCloseClick = (e) => {\n fire(this, 'onClose', 'onCloseClick', e);\n };\n\n handleOutsideClick = (e) => {\n fire(this, 'onClose', 'onOutsideClick', e);\n };\n\n isAdvanceMode() {\n return isAdvanceMode(this.asProps.Children, [\n SidePanel.Overlay.displayName,\n SidePanel.Panel.displayName,\n ]);\n }\n\n isUsedOverlay() {\n return (\n !this.isAdvanceMode() || isAdvanceMode(this.asProps.Children, [SidePanel.Overlay.displayName])\n );\n }\n\n calculateDelayAnimation(name) {\n const delay = this.asProps.duration / 2;\n const usedOverlay = this.isUsedOverlay();\n\n return {\n overlay: usedOverlay ? [0, delay] : 0,\n panel: usedOverlay ? [delay, 0] : 0,\n }[name];\n }\n\n getOverlayProps() {\n const { visible, duration } = this.asProps;\n return {\n visible,\n duration,\n delay: this.calculateDelayAnimation('overlay'),\n };\n }\n\n getPanelProps() {\n const { placement, visible, closable, duration } = this.asProps;\n\n return {\n visible,\n placement,\n closable,\n duration,\n disableEnforceFocus: !this.isUsedOverlay(),\n delay: this.calculateDelayAnimation('panel'),\n onOutsideClick: this.handleOutsideClick,\n onKeyDown: this.handleSidebarKeyDown,\n };\n }\n\n getCloseProps() {\n return {\n onClick: this.handleIconCloseClick,\n };\n }\n\n render() {\n const { Children, disablePortal } = this.asProps;\n\n return (\n <Portal disablePortal={disablePortal}>\n {this.isAdvanceMode() ? (\n <Children />\n ) : (\n <SidePanel.Overlay>\n <Root render={SidePanel.Panel} />\n </SidePanel.Overlay>\n )}\n </Portal>\n );\n }\n}\n\nfunction Overlay(props) {\n const SOverlay = Root;\n usePreventScroll(props.visible);\n return sstyled(props.styles)(<SOverlay render={FadeInOut} />);\n}\n\nconst FocusLockWrapper = React.forwardRef(function({ disableEnforceFocus, ...other }, ref) {\n return <FocusLock ref={ref} lockProps={other} disabled={disableEnforceFocus} {...other} />;\n});\n\nconst TransformWrapper = React.forwardRef(function({ tag, ...other }, ref) {\n return <Transform tag={FocusLockWrapper} ref={ref} as={tag} {...other} />;\n});\n\nfunction Panel(props) {\n const SPanel = Root;\n const { Children, styles, visible, closable, placement, onOutsideClick } = props;\n\n const sidebarRef = useRef(null);\n\n return sstyled(styles)(\n <>\n {visible && <OutsideClick onOutsideClick={onOutsideClick} excludeRefs={[sidebarRef]} />}\n <SPanel\n render={TransformWrapper}\n tag={Box}\n ref={sidebarRef}\n tabIndex={-1}\n returnFocus={true}\n autoFocus={true}\n transform={placementTransformMap[placement]}\n >\n <PortalProvider value={sidebarRef}>\n {closable && <SidePanel.Close />}\n <Children />\n </PortalProvider>\n </SPanel>\n </>,\n );\n}\n\nfunction Close(props) {\n const SClose = Root;\n return sstyled(props.styles)(<SClose render={Box} tag=\"button\" />);\n}\n\nClose.defaultProps = {\n children: <CloseIcon title=\"Close\" />,\n};\nClose.enhance = [keyboardFocusEnhance()];\n\nconst SidePanel = createComponent(RootSidePanel, {\n Overlay,\n Panel,\n Close,\n});\n\nexport default SidePanel;\n"],"file":"SidePanel.js"}
|
package/lib/es6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.
|
|
1
|
+
{"version":3,"sources":["../../src/index.js"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,aAAxB;AACA,cAAc,aAAd","sourcesContent":["export { default } from './SidePanel';\nexport * from './SidePanel';\n"],"file":"index.js"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,2 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React 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 } from '@semcore/flex-box';
|
|
6
|
+
|
|
7
|
+
export type OnCloseTriggerType = 'onOutsideClick' | 'onEscape' | 'onCloseClick';
|
|
8
|
+
export type OnCloseType = (
|
|
9
|
+
trigger: OnCloseTriggerType,
|
|
10
|
+
e?: React.MouseEvent | React.KeyboardEvent,
|
|
11
|
+
) => void;
|
|
12
|
+
|
|
13
|
+
export type SidePanelPlacement = 'top' | 'left' | 'right' | 'bottom';
|
|
14
|
+
|
|
15
|
+
export interface ISidePanelProps extends IPortalProps {
|
|
16
|
+
/** Animation display duration in ms
|
|
17
|
+
* @default 350
|
|
18
|
+
*/
|
|
19
|
+
duration?: number;
|
|
20
|
+
/**
|
|
21
|
+
* The property responsible for the visibility of the component
|
|
22
|
+
*/
|
|
23
|
+
visible?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Callback for the component closure
|
|
26
|
+
*/
|
|
27
|
+
onClose?: OnCloseType;
|
|
28
|
+
/**
|
|
29
|
+
* Property for displaying the close button
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
closable?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Position of a dropdown window
|
|
35
|
+
* @default right
|
|
36
|
+
*/
|
|
37
|
+
placement?: SidePanelPlacement;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ISidePanelOverlayProps extends IFadeInOutProps, IBoxProps {}
|
|
41
|
+
|
|
42
|
+
export interface ISidePanelPanelProps extends ITransformProps, IBoxProps {
|
|
43
|
+
onOutsideClick?: (e?: React.SyntheticEvent) => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ISidePanelContext {
|
|
47
|
+
getOverlayProps?: PropGetterFn;
|
|
48
|
+
getPanelProps?: PropGetterFn;
|
|
49
|
+
getCloseProps?: PropGetterFn;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare const SidePanel: (<T>(
|
|
53
|
+
props: CProps<ISidePanelProps & T, ISidePanelContext>,
|
|
54
|
+
) => ReturnEl) & {
|
|
55
|
+
Overlay: <T>(props: ISidePanelOverlayProps & T) => ReturnEl;
|
|
56
|
+
Panel: <T>(props: ISidePanelPanelProps & T) => ReturnEl;
|
|
57
|
+
Close: typeof Box;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default SidePanel;
|
package/package.json
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/side-panel",
|
|
3
3
|
"description": "SEMRush SidePanel Component",
|
|
4
|
-
"version": "1.1
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
8
9
|
"author": "Roman Lysov <r.lysov@semrush.com>",
|
|
9
10
|
"license": "MIT",
|
|
10
11
|
"scripts": {
|
|
11
|
-
"build": "build",
|
|
12
|
+
"build": "build --source=js",
|
|
12
13
|
"test": "jest"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"@semcore/utils": "^3.
|
|
16
|
+
"@semcore/utils": "^3.31",
|
|
16
17
|
"@semcore/animation": "^1",
|
|
17
18
|
"@semcore/flex-box": "^4",
|
|
18
19
|
"@semcore/portal": "^2",
|
|
19
20
|
"@semcore/outside-click": "^2",
|
|
20
|
-
"@semcore/icon": "^2",
|
|
21
|
+
"@semcore/icon": "^2.16",
|
|
21
22
|
"react-focus-lock": "^2.3"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
|
-
"@semcore/core": "^1",
|
|
25
|
+
"@semcore/core": "^1.11",
|
|
25
26
|
"react": "16.8 - 17"
|
|
26
27
|
},
|
|
27
28
|
"jest": {
|
package/src/SidePanel.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React, { ComponentProps, useRef } from 'react';
|
|
2
|
+
import FocusLock from 'react-focus-lock';
|
|
3
|
+
import createComponent, { Component, Root, sstyled } from '@semcore/core';
|
|
4
|
+
import { Box } from '@semcore/flex-box';
|
|
5
|
+
import { FadeInOut, IFadeInOutProps, ITransformProps, Transform } from '@semcore/animation';
|
|
6
|
+
import Portal, { IPortalProps, 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 findComponent, { 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
|
+
|
|
14
|
+
import style from './style/side-panel.shadow.css';
|
|
15
|
+
|
|
16
|
+
const placementTransformMap = {
|
|
17
|
+
top: ['translate(0, -100%)', 'translate(0, 0)'],
|
|
18
|
+
right: ['translate(100%, 0)', 'translate(0, 0)'],
|
|
19
|
+
bottom: ['translate(0, 100%)', 'translate(0, 0)'],
|
|
20
|
+
left: ['translate(-100%, 0)', 'translate(0, 0)'],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class RootSidePanel extends Component {
|
|
24
|
+
static displayName = 'SidePanel';
|
|
25
|
+
static style = style;
|
|
26
|
+
static defaultProps = {
|
|
27
|
+
placement: 'right',
|
|
28
|
+
duration: 350,
|
|
29
|
+
closable: true,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
sidebarRef = React.createRef();
|
|
33
|
+
|
|
34
|
+
handleSidebarKeyDown = (e) => {
|
|
35
|
+
if (e.key === 'Escape') {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
fire(this, 'onClose', 'onEscape', e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
handleIconCloseClick = (e) => {
|
|
42
|
+
fire(this, 'onClose', 'onCloseClick', e);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
handleOutsideClick = (e) => {
|
|
46
|
+
fire(this, 'onClose', 'onOutsideClick', e);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
isAdvanceMode() {
|
|
50
|
+
return isAdvanceMode(this.asProps.Children, [
|
|
51
|
+
SidePanel.Overlay.displayName,
|
|
52
|
+
SidePanel.Panel.displayName,
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
isUsedOverlay() {
|
|
57
|
+
return (
|
|
58
|
+
!this.isAdvanceMode() || isAdvanceMode(this.asProps.Children, [SidePanel.Overlay.displayName])
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
calculateDelayAnimation(name) {
|
|
63
|
+
const delay = this.asProps.duration / 2;
|
|
64
|
+
const usedOverlay = this.isUsedOverlay();
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
overlay: usedOverlay ? [0, delay] : 0,
|
|
68
|
+
panel: usedOverlay ? [delay, 0] : 0,
|
|
69
|
+
}[name];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getOverlayProps() {
|
|
73
|
+
const { visible, duration } = this.asProps;
|
|
74
|
+
return {
|
|
75
|
+
visible,
|
|
76
|
+
duration,
|
|
77
|
+
delay: this.calculateDelayAnimation('overlay'),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getPanelProps() {
|
|
82
|
+
const { placement, visible, closable, duration } = this.asProps;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
visible,
|
|
86
|
+
placement,
|
|
87
|
+
closable,
|
|
88
|
+
duration,
|
|
89
|
+
disableEnforceFocus: !this.isUsedOverlay(),
|
|
90
|
+
delay: this.calculateDelayAnimation('panel'),
|
|
91
|
+
onOutsideClick: this.handleOutsideClick,
|
|
92
|
+
onKeyDown: this.handleSidebarKeyDown,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getCloseProps() {
|
|
97
|
+
return {
|
|
98
|
+
onClick: this.handleIconCloseClick,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
render() {
|
|
103
|
+
const { Children, disablePortal } = this.asProps;
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<Portal disablePortal={disablePortal}>
|
|
107
|
+
{this.isAdvanceMode() ? (
|
|
108
|
+
<Children />
|
|
109
|
+
) : (
|
|
110
|
+
<SidePanel.Overlay>
|
|
111
|
+
<Root render={SidePanel.Panel} />
|
|
112
|
+
</SidePanel.Overlay>
|
|
113
|
+
)}
|
|
114
|
+
</Portal>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function Overlay(props) {
|
|
120
|
+
const SOverlay = Root;
|
|
121
|
+
usePreventScroll(props.visible);
|
|
122
|
+
return sstyled(props.styles)(<SOverlay render={FadeInOut} />);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const FocusLockWrapper = React.forwardRef(function({ disableEnforceFocus, ...other }, ref) {
|
|
126
|
+
return <FocusLock ref={ref} lockProps={other} disabled={disableEnforceFocus} {...other} />;
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const TransformWrapper = React.forwardRef(function({ tag, ...other }, ref) {
|
|
130
|
+
return <Transform tag={FocusLockWrapper} ref={ref} as={tag} {...other} />;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
function Panel(props) {
|
|
134
|
+
const SPanel = Root;
|
|
135
|
+
const { Children, styles, visible, closable, placement, onOutsideClick } = props;
|
|
136
|
+
|
|
137
|
+
const sidebarRef = useRef(null);
|
|
138
|
+
|
|
139
|
+
return sstyled(styles)(
|
|
140
|
+
<>
|
|
141
|
+
{visible && <OutsideClick onOutsideClick={onOutsideClick} excludeRefs={[sidebarRef]} />}
|
|
142
|
+
<SPanel
|
|
143
|
+
render={TransformWrapper}
|
|
144
|
+
tag={Box}
|
|
145
|
+
ref={sidebarRef}
|
|
146
|
+
tabIndex={-1}
|
|
147
|
+
returnFocus={true}
|
|
148
|
+
autoFocus={true}
|
|
149
|
+
transform={placementTransformMap[placement]}
|
|
150
|
+
>
|
|
151
|
+
<PortalProvider value={sidebarRef}>
|
|
152
|
+
{closable && <SidePanel.Close />}
|
|
153
|
+
<Children />
|
|
154
|
+
</PortalProvider>
|
|
155
|
+
</SPanel>
|
|
156
|
+
</>,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function Close(props) {
|
|
161
|
+
const SClose = Root;
|
|
162
|
+
return sstyled(props.styles)(<SClose render={Box} tag="button" />);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
Close.defaultProps = {
|
|
166
|
+
children: <CloseIcon title="Close" />,
|
|
167
|
+
};
|
|
168
|
+
Close.enhance = [keyboardFocusEnhance()];
|
|
169
|
+
|
|
170
|
+
const SidePanel = createComponent(RootSidePanel, {
|
|
171
|
+
Overlay,
|
|
172
|
+
Panel,
|
|
173
|
+
Close,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export default SidePanel;
|