@ozen-ui/kit 0.83.0 → 0.83.2
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/__inner__/cjs/components/Sidebar/Sidebar.css +0 -22
- package/__inner__/cjs/components/Sidebar/Sidebar.js +6 -2
- package/__inner__/cjs/components/Sidebar/constants.js +16 -1
- package/__inner__/cjs/components/Sidebar/modules/SidebarCollapsibleItem/SidebarCollapsibleItem.css +1 -1
- package/__inner__/cjs/components/Sidebar/modules/SidebarCollapsibleItem/SidebarCollapsibleItem.js +14 -46
- package/__inner__/cjs/components/Sidebar/modules/SidebarCollapsibleItem/constants.js +2 -1
- package/__inner__/cjs/components/Sidebar/{hooks → modules/SidebarCollapsibleItem/hooks}/index.js +1 -1
- package/__inner__/cjs/components/Sidebar/modules/SidebarCollapsibleItem/hooks/useSidebarCollapsibleItemAnimation.js +107 -0
- package/__inner__/cjs/components/Sidebar/modules/SidebarHeaderLogo/SidebarHeaderLogo.js +1 -6
- package/__inner__/cjs/components/Sidebar/modules/SidebarItem/SidebarItem.js +1 -1
- package/__inner__/esm/components/Sidebar/Sidebar.css +0 -22
- package/__inner__/esm/components/Sidebar/Sidebar.js +8 -4
- package/__inner__/esm/components/Sidebar/constants.js +15 -0
- package/__inner__/esm/components/Sidebar/modules/SidebarCollapsibleItem/SidebarCollapsibleItem.css +1 -1
- package/__inner__/esm/components/Sidebar/modules/SidebarCollapsibleItem/SidebarCollapsibleItem.js +17 -49
- package/__inner__/esm/components/Sidebar/modules/SidebarCollapsibleItem/constants.js +1 -0
- package/__inner__/esm/components/Sidebar/modules/SidebarCollapsibleItem/hooks/index.js +1 -0
- package/__inner__/esm/components/Sidebar/modules/SidebarCollapsibleItem/hooks/useSidebarCollapsibleItemAnimation.js +103 -0
- package/__inner__/esm/components/Sidebar/modules/SidebarHeaderLogo/SidebarHeaderLogo.js +1 -6
- package/__inner__/esm/components/Sidebar/modules/SidebarItem/SidebarItem.js +1 -1
- package/__inner__/types/components/Sidebar/constants.d.ts +5 -0
- package/__inner__/types/components/Sidebar/modules/SidebarCollapsibleItem/SidebarCollapsibleItem.d.ts +0 -1
- package/__inner__/types/components/Sidebar/modules/SidebarCollapsibleItem/constants.d.ts +1 -0
- package/__inner__/types/components/Sidebar/modules/SidebarCollapsibleItem/hooks/index.d.ts +1 -0
- package/__inner__/types/components/Sidebar/modules/SidebarCollapsibleItem/hooks/useSidebarCollapsibleItemAnimation.d.ts +13 -0
- package/__inner__/types/components/Sidebar/modules/SidebarCollapsibleItem/types.d.ts +2 -0
- package/package.json +4 -4
- package/__inner__/cjs/components/Sidebar/hooks/useAnimationFlip.js +0 -22
- package/__inner__/esm/components/Sidebar/hooks/index.js +0 -1
- package/__inner__/esm/components/Sidebar/hooks/useAnimationFlip.js +0 -18
- package/__inner__/types/components/Sidebar/hooks/index.d.ts +0 -1
- package/__inner__/types/components/Sidebar/hooks/useAnimationFlip.d.ts +0 -2
|
@@ -23,28 +23,6 @@
|
|
|
23
23
|
--sidebar-content-secondary-color: var(--color-content-accent-secondary);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.Sidebar_size_s {
|
|
27
|
-
--sidebar-mini-width: 64px;
|
|
28
|
-
--sidebar-full-width: 256px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.Sidebar_size_m {
|
|
32
|
-
--sidebar-mini-width: 72px;
|
|
33
|
-
--sidebar-full-width: 280px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.Sidebar_variant_compact {
|
|
37
|
-
--sidebar-width: 108px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.Sidebar_variant_mini {
|
|
41
|
-
--sidebar-width: var(--sidebar-mini-width);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.Sidebar_variant_full {
|
|
45
|
-
--sidebar-width: var(--sidebar-full-width);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
26
|
.Sidebar_rounded {
|
|
49
27
|
border-radius: var(--border-radius-l);
|
|
50
28
|
}
|
|
@@ -22,14 +22,18 @@ var constants_1 = require("./constants");
|
|
|
22
22
|
var SidebarContext_1 = require("./SidebarContext");
|
|
23
23
|
exports.cnSidebar = (0, utils_1.cn)('Sidebar');
|
|
24
24
|
exports.Sidebar = (0, utils_1.polymorphicComponentWithRef)(function (inProps, ref) {
|
|
25
|
+
var _a;
|
|
25
26
|
var props = (0, useThemeProps_1.useThemeProps)({
|
|
26
27
|
name: 'Sidebar',
|
|
27
28
|
props: inProps,
|
|
28
29
|
});
|
|
29
|
-
var children = props.children, className = props.className,
|
|
30
|
+
var children = props.children, className = props.className, _b = props.as, Tag = _b === void 0 ? constants_1.SIDEBAR_DEFAULT_TAG : _b, _c = props.variant, variant = _c === void 0 ? constants_1.SIDEBAR_DEFAULT_VARIANT : _c, _d = props.rounded, rounded = _d === void 0 ? constants_1.SIDEBAR_DEFAULT_ROUNDED : _d, _e = props.size, size = _e === void 0 ? constants_1.SIDEBAR_DEFAULT_SIZE : _e, _f = props.color, color = _f === void 0 ? constants_1.SIDEBAR_DEFAULT_COLOR : _f, sizer = props.sizer, style = props.style, other = tslib_1.__rest(props, ["children", "className", "as", "variant", "rounded", "size", "color", "sizer", "style"]);
|
|
30
31
|
var memoizedContextValue = (0, react_1.useMemo)(function () { return ({ variant: variant, size: size, color: color }); }, [variant, size, color]);
|
|
32
|
+
var width = constants_1.SIDEBAR_WIDTH_BY_VARIANT[size][variant];
|
|
31
33
|
return (react_1.default.createElement(SidebarContext_1.SidebarContext.Provider, { value: memoizedContextValue },
|
|
32
|
-
react_1.default.createElement(Tag, tslib_1.__assign({}, other, { ref: ref,
|
|
34
|
+
react_1.default.createElement(Tag, tslib_1.__assign({}, other, { ref: ref, style: tslib_1.__assign(tslib_1.__assign({}, style), (0, utils_1.generateCSSVariables)((_a = {},
|
|
35
|
+
_a[constants_1.SIDEBAR_CSS_VARIABLE.WIDTH] = "".concat(width, "px"),
|
|
36
|
+
_a))), className: (0, exports.cnSidebar)({ variant: variant, rounded: rounded, size: size, color: color }, [className]) }),
|
|
33
37
|
children,
|
|
34
38
|
sizer && react_1.default.createElement("div", { className: (0, exports.cnSidebar)('Sizer') }, sizer))));
|
|
35
39
|
});
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SIDEBAR_DEFAULT_COLOR = exports.SIDEBAR_DEFAULT_SIZE = exports.SIDEBAR_DEFAULT_ROUNDED = exports.SIDEBAR_DEFAULT_VARIANT = exports.SIDEBAR_DEFAULT_TAG = void 0;
|
|
3
|
+
exports.SIDEBAR_CSS_VARIABLE = exports.SIDEBAR_WIDTH_BY_VARIANT = exports.SIDEBAR_DEFAULT_COLOR = exports.SIDEBAR_DEFAULT_SIZE = exports.SIDEBAR_DEFAULT_ROUNDED = exports.SIDEBAR_DEFAULT_VARIANT = exports.SIDEBAR_DEFAULT_TAG = void 0;
|
|
4
4
|
exports.SIDEBAR_DEFAULT_TAG = 'aside';
|
|
5
5
|
exports.SIDEBAR_DEFAULT_VARIANT = 'mini';
|
|
6
6
|
exports.SIDEBAR_DEFAULT_ROUNDED = true;
|
|
7
7
|
exports.SIDEBAR_DEFAULT_SIZE = 'm';
|
|
8
8
|
exports.SIDEBAR_DEFAULT_COLOR = 'main';
|
|
9
|
+
exports.SIDEBAR_WIDTH_BY_VARIANT = {
|
|
10
|
+
s: {
|
|
11
|
+
mini: 64,
|
|
12
|
+
compact: 108,
|
|
13
|
+
full: 256,
|
|
14
|
+
},
|
|
15
|
+
m: {
|
|
16
|
+
mini: 72,
|
|
17
|
+
compact: 108,
|
|
18
|
+
full: 280,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
exports.SIDEBAR_CSS_VARIABLE = {
|
|
22
|
+
WIDTH: 'sidebar-width',
|
|
23
|
+
};
|
package/__inner__/cjs/components/Sidebar/modules/SidebarCollapsibleItem/SidebarCollapsibleItem.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SidebarCollapsibleItem = exports.
|
|
3
|
+
exports.SidebarCollapsibleItem = exports.cnSidebarCollapsibleItem = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
var react_transition_group_1 = require("react-transition-group");
|
|
@@ -8,68 +8,36 @@ var useMultiRef_1 = require("../../../../hooks/useMultiRef");
|
|
|
8
8
|
var useThemeProps_1 = require("../../../../hooks/useThemeProps");
|
|
9
9
|
var utils_1 = require("../../../../utils");
|
|
10
10
|
var Stack_1 = require("../../../Stack");
|
|
11
|
-
var hooks_1 = require("../../hooks");
|
|
12
11
|
var SidebarContext_1 = require("../../SidebarContext");
|
|
13
12
|
var constants_1 = require("./constants");
|
|
13
|
+
var hooks_1 = require("./hooks");
|
|
14
14
|
exports.cnSidebarCollapsibleItem = (0, utils_1.cn)('SidebarCollapsibleItem');
|
|
15
|
-
exports.marginAutoClassName = (0, exports.cnSidebarCollapsibleItem)('MarginAuto');
|
|
16
15
|
exports.SidebarCollapsibleItem = (0, utils_1.polymorphicComponentWithRef)(function (inProps, ref) {
|
|
17
16
|
var props = (0, useThemeProps_1.useThemeProps)({
|
|
18
17
|
props: inProps,
|
|
19
18
|
name: 'SidebarCollapsibleItem',
|
|
20
19
|
});
|
|
21
|
-
var _a = props.as, as = _a === void 0 ? constants_1.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG : _a, className = props.className, fixed = props.fixed, classNames = props.classNames, _b = props.justify, justify = _b === void 0 ? constants_1.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY : _b, _c = props.animated, animated = _c === void 0 ? true : _c, children = props.children, collapsed = props.collapsed, other = tslib_1.__rest(props, ["as", "className", "fixed", "classNames", "justify", "animated", "children", "collapsed"]);
|
|
20
|
+
var _a = props.as, as = _a === void 0 ? constants_1.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG : _a, className = props.className, fixed = props.fixed, classNames = props.classNames, _b = props.justify, justify = _b === void 0 ? constants_1.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY : _b, _c = props.animated, animated = _c === void 0 ? true : _c, children = props.children, collapsed = props.collapsed, _d = props.autoCenter, autoCenter = _d === void 0 ? constants_1.SIDEBAR_COLLAPSIBLE_ITEM_AUTO_CENTER : _d, other = tslib_1.__rest(props, ["as", "className", "fixed", "classNames", "justify", "animated", "children", "collapsed", "autoCenter"]);
|
|
22
21
|
var variant = (0, SidebarContext_1.useSidebarContext)().variant;
|
|
23
|
-
var
|
|
22
|
+
var isCollapsed = collapsed !== null && collapsed !== void 0 ? collapsed : variant === 'mini';
|
|
24
23
|
var internalRef = (0, react_1.useRef)(null);
|
|
25
24
|
var itemRef = (0, useMultiRef_1.useMultiRef)([ref, internalRef]);
|
|
26
|
-
var
|
|
27
|
-
var runAnimationFlip = (0, hooks_1.useAnimationFlip)(internalRef);
|
|
28
|
-
var onTransitionEnd = function () {
|
|
29
|
-
if (!animated) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
var node = internalRef.current;
|
|
33
|
-
if (!node) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
node.style.transition = '';
|
|
37
|
-
node.style.transform = '';
|
|
38
|
-
};
|
|
39
|
-
var hasMarginAutoClass = (function () {
|
|
40
|
-
if (!isCollapsed) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
if (!animated) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
return !wasAnimated;
|
|
47
|
-
})();
|
|
25
|
+
var fixedRef = (0, react_1.useRef)(null);
|
|
48
26
|
var fixedRendered = (0, utils_1.isFunction)(fixed)
|
|
49
27
|
? (0, utils_1.renderContent)({
|
|
50
28
|
content: fixed,
|
|
51
29
|
props: { collapsed: isCollapsed },
|
|
52
30
|
})
|
|
53
31
|
: fixed;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!animated) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
setWasAnimated(true);
|
|
67
|
-
runAnimationFlip(function (element) {
|
|
68
|
-
element.classList.remove(exports.marginAutoClassName);
|
|
69
|
-
});
|
|
70
|
-
}, onEntered: onTransitionEnd, onExited: onTransitionEnd },
|
|
71
|
-
react_1.default.createElement(Stack_1.Stack, tslib_1.__assign({}, other, { ref: itemRef, as: as, className: (0, exports.cnSidebarCollapsibleItem)({ collapsed: isCollapsed, animated: animated }, [className, hasMarginAutoClass ? exports.marginAutoClassName : undefined]), justify: justify }),
|
|
72
|
-
react_1.default.createElement("div", { className: (0, exports.cnSidebarCollapsibleItem)('Fixed', [classNames === null || classNames === void 0 ? void 0 : classNames.fixed]) }, fixedRendered),
|
|
32
|
+
var _e = (0, hooks_1.useSidebarCollapsibleItemAnimation)({
|
|
33
|
+
autoCenter: autoCenter,
|
|
34
|
+
ref: internalRef,
|
|
35
|
+
fixedRef: fixedRef,
|
|
36
|
+
isCollapsed: isCollapsed,
|
|
37
|
+
}), onExit = _e.onExit, onEnter = _e.onEnter, onTransitionEnd = _e.onTransitionEnd, hasMarginAutoClass = _e.hasMarginAutoClass;
|
|
38
|
+
return (react_1.default.createElement(react_transition_group_1.CSSTransition, { nodeRef: internalRef, in: isCollapsed, timeout: { enter: 120, exit: 120 }, appear: true, onEnter: onEnter, onExit: onExit, onEntered: onTransitionEnd, onExited: onTransitionEnd },
|
|
39
|
+
react_1.default.createElement(Stack_1.Stack, tslib_1.__assign({}, other, { ref: itemRef, as: as, className: (0, exports.cnSidebarCollapsibleItem)({ collapsed: isCollapsed, animated: animated, center: hasMarginAutoClass }, [className]), justify: justify }),
|
|
40
|
+
react_1.default.createElement("div", { ref: fixedRef, className: (0, exports.cnSidebarCollapsibleItem)('Fixed', [classNames === null || classNames === void 0 ? void 0 : classNames.fixed]) }, fixedRendered),
|
|
73
41
|
react_1.default.createElement("div", { className: (0, exports.cnSidebarCollapsibleItem)('Content', [classNames === null || classNames === void 0 ? void 0 : classNames.content]) }, children))));
|
|
74
42
|
});
|
|
75
43
|
exports.SidebarCollapsibleItem.displayName = 'SidebarCollapsibleItem';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY = exports.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG = void 0;
|
|
3
|
+
exports.SIDEBAR_COLLAPSIBLE_ITEM_AUTO_CENTER = exports.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY = exports.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG = void 0;
|
|
4
4
|
exports.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG = 'div';
|
|
5
5
|
exports.SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY = 'start';
|
|
6
|
+
exports.SIDEBAR_COLLAPSIBLE_ITEM_AUTO_CENTER = true;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSidebarCollapsibleItemAnimation = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
var useStoredValue_1 = require("../../../../../hooks/useStoredValue");
|
|
7
|
+
var useThemeVariables_1 = require("../../../../../hooks/useThemeVariables");
|
|
8
|
+
var constants_1 = require("../../../constants");
|
|
9
|
+
var SidebarContext_1 = require("../../../SidebarContext");
|
|
10
|
+
var useSidebarCollapsibleItemAnimation = function (_a) {
|
|
11
|
+
var autoCenter = _a.autoCenter, ref = _a.ref, fixedRef = _a.fixedRef, isCollapsed = _a.isCollapsed;
|
|
12
|
+
var _b = (0, SidebarContext_1.useSidebarContext)(), variant = _b.variant, size = _b.size;
|
|
13
|
+
var transition = (0, useThemeVariables_1.useThemeVariables)().transition;
|
|
14
|
+
var _c = tslib_1.__read((0, react_1.useState)(false), 2), wasRender = _c[0], setWasRender = _c[1];
|
|
15
|
+
var isFirstAnimation = (0, useStoredValue_1.useStoredValue)(true);
|
|
16
|
+
var currentWidths = constants_1.SIDEBAR_WIDTH_BY_VARIANT[size];
|
|
17
|
+
var calculateCenter = function () {
|
|
18
|
+
var _a;
|
|
19
|
+
if (!autoCenter) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
var element = ref.current;
|
|
23
|
+
if (!element) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
var parent = (_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
27
|
+
if (!parent) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
var fixed = fixedRef.current;
|
|
31
|
+
if (!fixed) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
var fixedRect = fixed.getBoundingClientRect();
|
|
35
|
+
var panelWidth = currentWidths[variant];
|
|
36
|
+
var targetLeftCenter = parent.left + (panelWidth - fixedRect.width) / 2;
|
|
37
|
+
var dx = fixedRect.left - targetLeftCenter;
|
|
38
|
+
return Math.abs(dx);
|
|
39
|
+
};
|
|
40
|
+
var onEnter = function () {
|
|
41
|
+
if (!autoCenter) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
var parent = ref.current;
|
|
45
|
+
var fixed = fixedRef.current;
|
|
46
|
+
if (!fixed || !parent) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
var originalTransform = fixed.style.transform;
|
|
50
|
+
parent.style.marginInline = '0';
|
|
51
|
+
fixed.style.transition = '';
|
|
52
|
+
fixed.style.transform = '';
|
|
53
|
+
var centerX = calculateCenter();
|
|
54
|
+
if (centerX === null) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
fixed.style.transform = originalTransform;
|
|
58
|
+
fixed.getBoundingClientRect();
|
|
59
|
+
if (!isFirstAnimation.current) {
|
|
60
|
+
fixed.style.transition = "".concat(transition.default, " transform");
|
|
61
|
+
}
|
|
62
|
+
fixed.style.transform = "translateX(".concat(centerX, "px)");
|
|
63
|
+
isFirstAnimation.current = false;
|
|
64
|
+
};
|
|
65
|
+
var onExit = function () {
|
|
66
|
+
if (!autoCenter) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
var fixed = fixedRef.current;
|
|
70
|
+
if (!fixed) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
fixed.style.transition = "".concat(transition.default, " transform");
|
|
74
|
+
fixed.style.transform = "translate(0px)";
|
|
75
|
+
isFirstAnimation.current = false;
|
|
76
|
+
};
|
|
77
|
+
var onTransitionEnd = function () {
|
|
78
|
+
var node = ref.current;
|
|
79
|
+
if (!node) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
node.style.transition = '';
|
|
83
|
+
node.style.transform = '';
|
|
84
|
+
};
|
|
85
|
+
var previousIsCollapsed = (0, useStoredValue_1.useStoredValue)(isCollapsed);
|
|
86
|
+
(0, react_1.useEffect)(function () {
|
|
87
|
+
setWasRender(true);
|
|
88
|
+
}, []);
|
|
89
|
+
(0, react_1.useEffect)(function () {
|
|
90
|
+
if (!wasRender) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (previousIsCollapsed.current === isCollapsed) {
|
|
94
|
+
onEnter();
|
|
95
|
+
}
|
|
96
|
+
previousIsCollapsed.current = isCollapsed;
|
|
97
|
+
}, [variant]);
|
|
98
|
+
var hasMarginAutoClass = isCollapsed && autoCenter && !wasRender;
|
|
99
|
+
return {
|
|
100
|
+
calculateCenter: calculateCenter,
|
|
101
|
+
onExit: onExit,
|
|
102
|
+
onEnter: onEnter,
|
|
103
|
+
onTransitionEnd: onTransitionEnd,
|
|
104
|
+
hasMarginAutoClass: hasMarginAutoClass,
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
exports.useSidebarCollapsibleItemAnimation = useSidebarCollapsibleItemAnimation;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SidebarHeaderLogo = exports.cnSidebarHeaderLogo = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
var useStoredValue_1 = require("../../../../hooks/useStoredValue");
|
|
7
6
|
var useThemeProps_1 = require("../../../../hooks/useThemeProps");
|
|
8
7
|
var utils_1 = require("../../../../utils");
|
|
9
8
|
var Stack_1 = require("../../../Stack");
|
|
@@ -18,10 +17,6 @@ exports.SidebarHeaderLogo = (0, utils_1.polymorphicComponentWithRef)(function (i
|
|
|
18
17
|
});
|
|
19
18
|
var _a = props.as, as = _a === void 0 ? constants_1.SIDEBAR_HEADER_LOGO_DEFAULT_TAG : _a, className = props.className, children = props.children, icon = props.icon, other = tslib_1.__rest(props, ["as", "className", "children", "icon"]);
|
|
20
19
|
var _b = (0, SidebarContext_1.useSidebarContext)(), color = _b.color, variant = _b.variant;
|
|
21
|
-
|
|
22
|
-
var isCompact = variant === 'compact';
|
|
23
|
-
var isAnimated = previousVariant.current !== 'compact' && !isCompact;
|
|
24
|
-
previousVariant.current = variant;
|
|
25
|
-
return (react_1.default.createElement(SidebarCollapsibleItem_1.SidebarCollapsibleItem, tslib_1.__assign({}, other, { as: as, fixed: react_1.default.createElement(Stack_1.Stack, { className: (0, exports.cnSidebarHeaderLogo)('Icon'), justify: "center", align: "center" }, icon), animated: isAnimated, collapsed: variant !== 'full', classNames: { content: (0, exports.cnSidebarHeaderLogo)('Text') }, ref: ref, className: (0, exports.cnSidebarHeaderLogo)({ color: color }, [className]), align: "center" }), children));
|
|
20
|
+
return (react_1.default.createElement(SidebarCollapsibleItem_1.SidebarCollapsibleItem, tslib_1.__assign({}, other, { as: as, fixed: react_1.default.createElement(Stack_1.Stack, { className: (0, exports.cnSidebarHeaderLogo)('Icon'), justify: "center", align: "center" }, icon), collapsed: variant !== 'full', classNames: { content: (0, exports.cnSidebarHeaderLogo)('Text') }, ref: ref, className: (0, exports.cnSidebarHeaderLogo)({ color: color }, [className]), align: "center" }), children));
|
|
26
21
|
});
|
|
27
22
|
exports.SidebarHeaderLogo.displayName = 'SidebarHeaderLogo';
|
|
@@ -54,7 +54,7 @@ exports.SidebarItem = (0, utils_1.polymorphicComponentWithRef)(function (inProps
|
|
|
54
54
|
react_1.default.createElement(SidebarCollapsibleItem_1.SidebarCollapsibleItem, tslib_1.__assign({}, other, { as: as, onClick: function (event) {
|
|
55
55
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
56
56
|
setIsOpenSubItems(!isOpenSubitems);
|
|
57
|
-
}, collapsed: isCollapsed, className: (0, exports.cnSidebarItem)('Item'), fixed: function (props) {
|
|
57
|
+
}, collapsed: isCollapsed, className: (0, exports.cnSidebarItem)('Item'), autoCenter: false, fixed: function (props) {
|
|
58
58
|
var badge = (0, utils_1.isFunction)(badgeProp)
|
|
59
59
|
? badgeProp({ collapsed: props.collapsed })
|
|
60
60
|
: badgeProp;
|
|
@@ -23,28 +23,6 @@
|
|
|
23
23
|
--sidebar-content-secondary-color: var(--color-content-accent-secondary);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.Sidebar_size_s {
|
|
27
|
-
--sidebar-mini-width: 64px;
|
|
28
|
-
--sidebar-full-width: 256px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.Sidebar_size_m {
|
|
32
|
-
--sidebar-mini-width: 72px;
|
|
33
|
-
--sidebar-full-width: 280px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.Sidebar_variant_compact {
|
|
37
|
-
--sidebar-width: 108px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.Sidebar_variant_mini {
|
|
41
|
-
--sidebar-width: var(--sidebar-mini-width);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.Sidebar_variant_full {
|
|
45
|
-
--sidebar-width: var(--sidebar-full-width);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
26
|
.Sidebar_rounded {
|
|
49
27
|
border-radius: var(--border-radius-l);
|
|
50
28
|
}
|
|
@@ -14,19 +14,23 @@ import './modules/SidebarUser/SidebarUser.css';
|
|
|
14
14
|
import './modules/SidebarUserMenu/SidebarUserMenu.css';
|
|
15
15
|
import React, { useMemo } from 'react';
|
|
16
16
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
17
|
-
import { cn, polymorphicComponentWithRef } from '../../utils';
|
|
18
|
-
import { SIDEBAR_DEFAULT_COLOR, SIDEBAR_DEFAULT_ROUNDED, SIDEBAR_DEFAULT_SIZE, SIDEBAR_DEFAULT_TAG, SIDEBAR_DEFAULT_VARIANT, } from './constants';
|
|
17
|
+
import { cn, generateCSSVariables, polymorphicComponentWithRef, } from '../../utils';
|
|
18
|
+
import { SIDEBAR_CSS_VARIABLE, SIDEBAR_DEFAULT_COLOR, SIDEBAR_DEFAULT_ROUNDED, SIDEBAR_DEFAULT_SIZE, SIDEBAR_DEFAULT_TAG, SIDEBAR_DEFAULT_VARIANT, SIDEBAR_WIDTH_BY_VARIANT, } from './constants';
|
|
19
19
|
import { SidebarContext } from './SidebarContext';
|
|
20
20
|
export var cnSidebar = cn('Sidebar');
|
|
21
21
|
export var Sidebar = polymorphicComponentWithRef(function (inProps, ref) {
|
|
22
|
+
var _a;
|
|
22
23
|
var props = useThemeProps({
|
|
23
24
|
name: 'Sidebar',
|
|
24
25
|
props: inProps,
|
|
25
26
|
});
|
|
26
|
-
var children = props.children, className = props.className,
|
|
27
|
+
var children = props.children, className = props.className, _b = props.as, Tag = _b === void 0 ? SIDEBAR_DEFAULT_TAG : _b, _c = props.variant, variant = _c === void 0 ? SIDEBAR_DEFAULT_VARIANT : _c, _d = props.rounded, rounded = _d === void 0 ? SIDEBAR_DEFAULT_ROUNDED : _d, _e = props.size, size = _e === void 0 ? SIDEBAR_DEFAULT_SIZE : _e, _f = props.color, color = _f === void 0 ? SIDEBAR_DEFAULT_COLOR : _f, sizer = props.sizer, style = props.style, other = __rest(props, ["children", "className", "as", "variant", "rounded", "size", "color", "sizer", "style"]);
|
|
27
28
|
var memoizedContextValue = useMemo(function () { return ({ variant: variant, size: size, color: color }); }, [variant, size, color]);
|
|
29
|
+
var width = SIDEBAR_WIDTH_BY_VARIANT[size][variant];
|
|
28
30
|
return (React.createElement(SidebarContext.Provider, { value: memoizedContextValue },
|
|
29
|
-
React.createElement(Tag, __assign({}, other, { ref: ref,
|
|
31
|
+
React.createElement(Tag, __assign({}, other, { ref: ref, style: __assign(__assign({}, style), generateCSSVariables((_a = {},
|
|
32
|
+
_a[SIDEBAR_CSS_VARIABLE.WIDTH] = "".concat(width, "px"),
|
|
33
|
+
_a))), className: cnSidebar({ variant: variant, rounded: rounded, size: size, color: color }, [className]) }),
|
|
30
34
|
children,
|
|
31
35
|
sizer && React.createElement("div", { className: cnSidebar('Sizer') }, sizer))));
|
|
32
36
|
});
|
|
@@ -3,3 +3,18 @@ export var SIDEBAR_DEFAULT_VARIANT = 'mini';
|
|
|
3
3
|
export var SIDEBAR_DEFAULT_ROUNDED = true;
|
|
4
4
|
export var SIDEBAR_DEFAULT_SIZE = 'm';
|
|
5
5
|
export var SIDEBAR_DEFAULT_COLOR = 'main';
|
|
6
|
+
export var SIDEBAR_WIDTH_BY_VARIANT = {
|
|
7
|
+
s: {
|
|
8
|
+
mini: 64,
|
|
9
|
+
compact: 108,
|
|
10
|
+
full: 256,
|
|
11
|
+
},
|
|
12
|
+
m: {
|
|
13
|
+
mini: 72,
|
|
14
|
+
compact: 108,
|
|
15
|
+
full: 280,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export var SIDEBAR_CSS_VARIABLE = {
|
|
19
|
+
WIDTH: 'sidebar-width',
|
|
20
|
+
};
|
package/__inner__/esm/components/Sidebar/modules/SidebarCollapsibleItem/SidebarCollapsibleItem.js
CHANGED
|
@@ -1,72 +1,40 @@
|
|
|
1
|
-
import { __assign,
|
|
2
|
-
import React, {
|
|
3
|
-
import {
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import { CSSTransition } from 'react-transition-group';
|
|
4
4
|
import { useMultiRef } from '../../../../hooks/useMultiRef';
|
|
5
5
|
import { useThemeProps } from '../../../../hooks/useThemeProps';
|
|
6
6
|
import { cn, isFunction, polymorphicComponentWithRef, renderContent, } from '../../../../utils';
|
|
7
7
|
import { Stack } from '../../../Stack';
|
|
8
|
-
import { useAnimationFlip } from '../../hooks';
|
|
9
8
|
import { useSidebarContext } from '../../SidebarContext';
|
|
10
|
-
import { SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG, SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY, } from './constants';
|
|
9
|
+
import { SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG, SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY, SIDEBAR_COLLAPSIBLE_ITEM_AUTO_CENTER, } from './constants';
|
|
10
|
+
import { useSidebarCollapsibleItemAnimation } from './hooks';
|
|
11
11
|
export var cnSidebarCollapsibleItem = cn('SidebarCollapsibleItem');
|
|
12
|
-
export var marginAutoClassName = cnSidebarCollapsibleItem('MarginAuto');
|
|
13
12
|
export var SidebarCollapsibleItem = polymorphicComponentWithRef(function (inProps, ref) {
|
|
14
13
|
var props = useThemeProps({
|
|
15
14
|
props: inProps,
|
|
16
15
|
name: 'SidebarCollapsibleItem',
|
|
17
16
|
});
|
|
18
|
-
var _a = props.as, as = _a === void 0 ? SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG : _a, className = props.className, fixed = props.fixed, classNames = props.classNames, _b = props.justify, justify = _b === void 0 ? SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY : _b, _c = props.animated, animated = _c === void 0 ? true : _c, children = props.children, collapsed = props.collapsed, other = __rest(props, ["as", "className", "fixed", "classNames", "justify", "animated", "children", "collapsed"]);
|
|
17
|
+
var _a = props.as, as = _a === void 0 ? SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG : _a, className = props.className, fixed = props.fixed, classNames = props.classNames, _b = props.justify, justify = _b === void 0 ? SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_JUSTIFY : _b, _c = props.animated, animated = _c === void 0 ? true : _c, children = props.children, collapsed = props.collapsed, _d = props.autoCenter, autoCenter = _d === void 0 ? SIDEBAR_COLLAPSIBLE_ITEM_AUTO_CENTER : _d, other = __rest(props, ["as", "className", "fixed", "classNames", "justify", "animated", "children", "collapsed", "autoCenter"]);
|
|
19
18
|
var variant = useSidebarContext().variant;
|
|
20
|
-
var
|
|
19
|
+
var isCollapsed = collapsed !== null && collapsed !== void 0 ? collapsed : variant === 'mini';
|
|
21
20
|
var internalRef = useRef(null);
|
|
22
21
|
var itemRef = useMultiRef([ref, internalRef]);
|
|
23
|
-
var
|
|
24
|
-
var runAnimationFlip = useAnimationFlip(internalRef);
|
|
25
|
-
var onTransitionEnd = function () {
|
|
26
|
-
if (!animated) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
var node = internalRef.current;
|
|
30
|
-
if (!node) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
node.style.transition = '';
|
|
34
|
-
node.style.transform = '';
|
|
35
|
-
};
|
|
36
|
-
var hasMarginAutoClass = (function () {
|
|
37
|
-
if (!isCollapsed) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (!animated) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
return !wasAnimated;
|
|
44
|
-
})();
|
|
22
|
+
var fixedRef = useRef(null);
|
|
45
23
|
var fixedRendered = isFunction(fixed)
|
|
46
24
|
? renderContent({
|
|
47
25
|
content: fixed,
|
|
48
26
|
props: { collapsed: isCollapsed },
|
|
49
27
|
})
|
|
50
28
|
: fixed;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!animated) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
setWasAnimated(true);
|
|
64
|
-
runAnimationFlip(function (element) {
|
|
65
|
-
element.classList.remove(marginAutoClassName);
|
|
66
|
-
});
|
|
67
|
-
}, onEntered: onTransitionEnd, onExited: onTransitionEnd },
|
|
68
|
-
React.createElement(Stack, __assign({}, other, { ref: itemRef, as: as, className: cnSidebarCollapsibleItem({ collapsed: isCollapsed, animated: animated }, [className, hasMarginAutoClass ? marginAutoClassName : undefined]), justify: justify }),
|
|
69
|
-
React.createElement("div", { className: cnSidebarCollapsibleItem('Fixed', [classNames === null || classNames === void 0 ? void 0 : classNames.fixed]) }, fixedRendered),
|
|
29
|
+
var _e = useSidebarCollapsibleItemAnimation({
|
|
30
|
+
autoCenter: autoCenter,
|
|
31
|
+
ref: internalRef,
|
|
32
|
+
fixedRef: fixedRef,
|
|
33
|
+
isCollapsed: isCollapsed,
|
|
34
|
+
}), onExit = _e.onExit, onEnter = _e.onEnter, onTransitionEnd = _e.onTransitionEnd, hasMarginAutoClass = _e.hasMarginAutoClass;
|
|
35
|
+
return (React.createElement(CSSTransition, { nodeRef: internalRef, in: isCollapsed, timeout: { enter: 120, exit: 120 }, appear: true, onEnter: onEnter, onExit: onExit, onEntered: onTransitionEnd, onExited: onTransitionEnd },
|
|
36
|
+
React.createElement(Stack, __assign({}, other, { ref: itemRef, as: as, className: cnSidebarCollapsibleItem({ collapsed: isCollapsed, animated: animated, center: hasMarginAutoClass }, [className]), justify: justify }),
|
|
37
|
+
React.createElement("div", { ref: fixedRef, className: cnSidebarCollapsibleItem('Fixed', [classNames === null || classNames === void 0 ? void 0 : classNames.fixed]) }, fixedRendered),
|
|
70
38
|
React.createElement("div", { className: cnSidebarCollapsibleItem('Content', [classNames === null || classNames === void 0 ? void 0 : classNames.content]) }, children))));
|
|
71
39
|
});
|
|
72
40
|
SidebarCollapsibleItem.displayName = 'SidebarCollapsibleItem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSidebarCollapsibleItemAnimation';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useStoredValue } from '../../../../../hooks/useStoredValue';
|
|
4
|
+
import { useThemeVariables } from '../../../../../hooks/useThemeVariables';
|
|
5
|
+
import { SIDEBAR_WIDTH_BY_VARIANT } from '../../../constants';
|
|
6
|
+
import { useSidebarContext } from '../../../SidebarContext';
|
|
7
|
+
export var useSidebarCollapsibleItemAnimation = function (_a) {
|
|
8
|
+
var autoCenter = _a.autoCenter, ref = _a.ref, fixedRef = _a.fixedRef, isCollapsed = _a.isCollapsed;
|
|
9
|
+
var _b = useSidebarContext(), variant = _b.variant, size = _b.size;
|
|
10
|
+
var transition = useThemeVariables().transition;
|
|
11
|
+
var _c = __read(useState(false), 2), wasRender = _c[0], setWasRender = _c[1];
|
|
12
|
+
var isFirstAnimation = useStoredValue(true);
|
|
13
|
+
var currentWidths = SIDEBAR_WIDTH_BY_VARIANT[size];
|
|
14
|
+
var calculateCenter = function () {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!autoCenter) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
var element = ref.current;
|
|
20
|
+
if (!element) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
var parent = (_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
24
|
+
if (!parent) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
var fixed = fixedRef.current;
|
|
28
|
+
if (!fixed) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
var fixedRect = fixed.getBoundingClientRect();
|
|
32
|
+
var panelWidth = currentWidths[variant];
|
|
33
|
+
var targetLeftCenter = parent.left + (panelWidth - fixedRect.width) / 2;
|
|
34
|
+
var dx = fixedRect.left - targetLeftCenter;
|
|
35
|
+
return Math.abs(dx);
|
|
36
|
+
};
|
|
37
|
+
var onEnter = function () {
|
|
38
|
+
if (!autoCenter) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
var parent = ref.current;
|
|
42
|
+
var fixed = fixedRef.current;
|
|
43
|
+
if (!fixed || !parent) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
var originalTransform = fixed.style.transform;
|
|
47
|
+
parent.style.marginInline = '0';
|
|
48
|
+
fixed.style.transition = '';
|
|
49
|
+
fixed.style.transform = '';
|
|
50
|
+
var centerX = calculateCenter();
|
|
51
|
+
if (centerX === null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
fixed.style.transform = originalTransform;
|
|
55
|
+
fixed.getBoundingClientRect();
|
|
56
|
+
if (!isFirstAnimation.current) {
|
|
57
|
+
fixed.style.transition = "".concat(transition.default, " transform");
|
|
58
|
+
}
|
|
59
|
+
fixed.style.transform = "translateX(".concat(centerX, "px)");
|
|
60
|
+
isFirstAnimation.current = false;
|
|
61
|
+
};
|
|
62
|
+
var onExit = function () {
|
|
63
|
+
if (!autoCenter) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var fixed = fixedRef.current;
|
|
67
|
+
if (!fixed) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
fixed.style.transition = "".concat(transition.default, " transform");
|
|
71
|
+
fixed.style.transform = "translate(0px)";
|
|
72
|
+
isFirstAnimation.current = false;
|
|
73
|
+
};
|
|
74
|
+
var onTransitionEnd = function () {
|
|
75
|
+
var node = ref.current;
|
|
76
|
+
if (!node) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
node.style.transition = '';
|
|
80
|
+
node.style.transform = '';
|
|
81
|
+
};
|
|
82
|
+
var previousIsCollapsed = useStoredValue(isCollapsed);
|
|
83
|
+
useEffect(function () {
|
|
84
|
+
setWasRender(true);
|
|
85
|
+
}, []);
|
|
86
|
+
useEffect(function () {
|
|
87
|
+
if (!wasRender) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (previousIsCollapsed.current === isCollapsed) {
|
|
91
|
+
onEnter();
|
|
92
|
+
}
|
|
93
|
+
previousIsCollapsed.current = isCollapsed;
|
|
94
|
+
}, [variant]);
|
|
95
|
+
var hasMarginAutoClass = isCollapsed && autoCenter && !wasRender;
|
|
96
|
+
return {
|
|
97
|
+
calculateCenter: calculateCenter,
|
|
98
|
+
onExit: onExit,
|
|
99
|
+
onEnter: onEnter,
|
|
100
|
+
onTransitionEnd: onTransitionEnd,
|
|
101
|
+
hasMarginAutoClass: hasMarginAutoClass,
|
|
102
|
+
};
|
|
103
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useStoredValue } from '../../../../hooks/useStoredValue';
|
|
4
3
|
import { useThemeProps } from '../../../../hooks/useThemeProps';
|
|
5
4
|
import { cn, polymorphicComponentWithRef } from '../../../../utils';
|
|
6
5
|
import { Stack } from '../../../Stack';
|
|
@@ -15,10 +14,6 @@ export var SidebarHeaderLogo = polymorphicComponentWithRef(function (inProps, re
|
|
|
15
14
|
});
|
|
16
15
|
var _a = props.as, as = _a === void 0 ? SIDEBAR_HEADER_LOGO_DEFAULT_TAG : _a, className = props.className, children = props.children, icon = props.icon, other = __rest(props, ["as", "className", "children", "icon"]);
|
|
17
16
|
var _b = useSidebarContext(), color = _b.color, variant = _b.variant;
|
|
18
|
-
|
|
19
|
-
var isCompact = variant === 'compact';
|
|
20
|
-
var isAnimated = previousVariant.current !== 'compact' && !isCompact;
|
|
21
|
-
previousVariant.current = variant;
|
|
22
|
-
return (React.createElement(SidebarCollapsibleItem, __assign({}, other, { as: as, fixed: React.createElement(Stack, { className: cnSidebarHeaderLogo('Icon'), justify: "center", align: "center" }, icon), animated: isAnimated, collapsed: variant !== 'full', classNames: { content: cnSidebarHeaderLogo('Text') }, ref: ref, className: cnSidebarHeaderLogo({ color: color }, [className]), align: "center" }), children));
|
|
17
|
+
return (React.createElement(SidebarCollapsibleItem, __assign({}, other, { as: as, fixed: React.createElement(Stack, { className: cnSidebarHeaderLogo('Icon'), justify: "center", align: "center" }, icon), collapsed: variant !== 'full', classNames: { content: cnSidebarHeaderLogo('Text') }, ref: ref, className: cnSidebarHeaderLogo({ color: color }, [className]), align: "center" }), children));
|
|
23
18
|
});
|
|
24
19
|
SidebarHeaderLogo.displayName = 'SidebarHeaderLogo';
|
|
@@ -51,7 +51,7 @@ export var SidebarItem = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
51
51
|
React.createElement(SidebarCollapsibleItem, __assign({}, other, { as: as, onClick: function (event) {
|
|
52
52
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
53
53
|
setIsOpenSubItems(!isOpenSubitems);
|
|
54
|
-
}, collapsed: isCollapsed, className: cnSidebarItem('Item'), fixed: function (props) {
|
|
54
|
+
}, collapsed: isCollapsed, className: cnSidebarItem('Item'), autoCenter: false, fixed: function (props) {
|
|
55
55
|
var badge = isFunction(badgeProp)
|
|
56
56
|
? badgeProp({ collapsed: props.collapsed })
|
|
57
57
|
: badgeProp;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { SidebarSizeVariant, SidebarVariant } from './entities';
|
|
1
2
|
export declare const SIDEBAR_DEFAULT_TAG = "aside";
|
|
2
3
|
export declare const SIDEBAR_DEFAULT_VARIANT = "mini";
|
|
3
4
|
export declare const SIDEBAR_DEFAULT_ROUNDED = true;
|
|
4
5
|
export declare const SIDEBAR_DEFAULT_SIZE = "m";
|
|
5
6
|
export declare const SIDEBAR_DEFAULT_COLOR = "main";
|
|
7
|
+
export declare const SIDEBAR_WIDTH_BY_VARIANT: Readonly<Record<SidebarSizeVariant, Record<SidebarVariant, number>>>;
|
|
8
|
+
export declare const SIDEBAR_CSS_VARIABLE: {
|
|
9
|
+
readonly WIDTH: "sidebar-width";
|
|
10
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { SidebarCollapsibleItemBaseProps } from './types';
|
|
2
2
|
export declare const cnSidebarCollapsibleItem: import("@bem-react/classname").ClassNameFormatter;
|
|
3
|
-
export declare const marginAutoClassName: string;
|
|
4
3
|
export declare const SidebarCollapsibleItem: import("../../../../utils").PolymorphicComponentWithRef<SidebarCollapsibleItemBaseProps, "div", "as">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSidebarCollapsibleItemAnimation';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
export declare const useSidebarCollapsibleItemAnimation: ({ autoCenter, ref, fixedRef, isCollapsed, }: {
|
|
3
|
+
autoCenter: boolean;
|
|
4
|
+
ref: RefObject<HTMLDivElement>;
|
|
5
|
+
fixedRef: RefObject<HTMLDivElement>;
|
|
6
|
+
isCollapsed: boolean;
|
|
7
|
+
}) => {
|
|
8
|
+
calculateCenter: () => number | null;
|
|
9
|
+
onExit: () => void;
|
|
10
|
+
onEnter: () => void;
|
|
11
|
+
onTransitionEnd: () => void;
|
|
12
|
+
hasMarginAutoClass: boolean;
|
|
13
|
+
};
|
|
@@ -25,6 +25,8 @@ export type SidebarCollapsibleItemBaseProps = {
|
|
|
25
25
|
children?: ReactNode;
|
|
26
26
|
/** Флаг свернутости. При `true` скрывает `children` */
|
|
27
27
|
collapsed?: boolean;
|
|
28
|
+
/** Флаг центрирования фиксированной части. При `true` центрирует фиксированную часть */
|
|
29
|
+
autoCenter?: boolean;
|
|
28
30
|
} & StackBaseProps;
|
|
29
31
|
export type SidebarCollapsibleItemProps<As extends ElementType = typeof SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<SidebarCollapsibleItemBaseProps, As>;
|
|
30
32
|
export type SidebarCollapsibleItemRef<As extends ElementType = typeof SIDEBAR_COLLAPSIBLE_ITEM_DEFAULT_TAG> = ComponentRef<As>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ozen-ui/kit",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.2",
|
|
4
4
|
"description": "React component library",
|
|
5
5
|
"files": [
|
|
6
6
|
"*"
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"react-popper": "^2.3.0",
|
|
30
30
|
"react-transition-group": "^4.4.5",
|
|
31
31
|
"tslib": "^2.6.3",
|
|
32
|
-
"@ozen-ui/
|
|
33
|
-
"@ozen-ui/
|
|
34
|
-
"@ozen-ui/
|
|
32
|
+
"@ozen-ui/fonts": "0.83.2",
|
|
33
|
+
"@ozen-ui/logger": "0.83.2",
|
|
34
|
+
"@ozen-ui/icons": "0.83.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/lodash.isequal": "^4.5.0"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAnimationFlip = void 0;
|
|
4
|
-
var useThemeVariables_1 = require("../../../hooks/useThemeVariables");
|
|
5
|
-
var useAnimationFlip = function (ref) {
|
|
6
|
-
var transition = (0, useThemeVariables_1.useThemeVariables)().transition;
|
|
7
|
-
return function (applyLayoutChange) {
|
|
8
|
-
var node = ref.current;
|
|
9
|
-
if (!node) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
var firstRect = node.getBoundingClientRect();
|
|
13
|
-
applyLayoutChange(node);
|
|
14
|
-
var lastRect = node.getBoundingClientRect();
|
|
15
|
-
var deltaX = firstRect.left - lastRect.left;
|
|
16
|
-
node.style.transform = "translateX(".concat(deltaX, "px)");
|
|
17
|
-
node.getBoundingClientRect();
|
|
18
|
-
node.style.transition = transition.default;
|
|
19
|
-
node.style.transform = 'translateX(0)';
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.useAnimationFlip = useAnimationFlip;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useAnimationFlip';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useThemeVariables } from '../../../hooks/useThemeVariables';
|
|
2
|
-
export var useAnimationFlip = function (ref) {
|
|
3
|
-
var transition = useThemeVariables().transition;
|
|
4
|
-
return function (applyLayoutChange) {
|
|
5
|
-
var node = ref.current;
|
|
6
|
-
if (!node) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
var firstRect = node.getBoundingClientRect();
|
|
10
|
-
applyLayoutChange(node);
|
|
11
|
-
var lastRect = node.getBoundingClientRect();
|
|
12
|
-
var deltaX = firstRect.left - lastRect.left;
|
|
13
|
-
node.style.transform = "translateX(".concat(deltaX, "px)");
|
|
14
|
-
node.getBoundingClientRect();
|
|
15
|
-
node.style.transition = transition.default;
|
|
16
|
-
node.style.transform = 'translateX(0)';
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useAnimationFlip';
|