UNPKG

@ozen-ui/kit

Version:

React component library

27 lines (26 loc) 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SidebarSizer = exports.cnSidebarSizer = void 0; var tslib_1 = require("tslib"); var react_1 = tslib_1.__importDefault(require("react")); var icons_1 = require("@ozen-ui/icons"); var useThemeProps_1 = require("../../../../hooks/useThemeProps"); var utils_1 = require("../../../../utils"); var IconButtonNext_1 = require("../../../IconButtonNext"); var SidebarContext_1 = require("../../SidebarContext"); var constants_1 = require("./constants"); exports.cnSidebarSizer = (0, utils_1.cn)('SidebarSizer'); exports.SidebarSizer = (0, utils_1.polymorphicComponentWithRef)(function (inProps, ref) { var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'SidebarSizer', }); var _a = props.as, as = _a === void 0 ? constants_1.SIDEBAR_SIZER_DEFAULT_TAG : _a, className = props.className, _b = props.expandedVariants, expandedVariants = _b === void 0 ? constants_1.SIDEBAR_SIZER_DEFAULT_EXPANDED_VARIANTS : _b, onClick = props.onClick, onChange = props.onChange, ariaLabel = props["aria-label"], other = tslib_1.__rest(props, ["as", "className", "expandedVariants", "onClick", "onChange", 'aria-label']); var variant = (0, SidebarContext_1.useSidebarContext)().variant; var isExpanded = expandedVariants.includes(variant); return (react_1.default.createElement(IconButtonNext_1.IconButton, tslib_1.__assign({}, other, { as: as, ref: ref, size: "2xs", compressed: true, onClick: function (event) { onClick === null || onClick === void 0 ? void 0 : onClick(event); onChange === null || onChange === void 0 ? void 0 : onChange({ currentVariant: variant, collapsed: !isExpanded }, event); }, "aria-expanded": isExpanded, "aria-label": ariaLabel ? ariaLabel({ collapsed: !isExpanded }) : undefined, className: (0, exports.cnSidebarSizer)({ expanded: isExpanded }, [className]), icon: react_1.default.createElement(icons_1.ArrowLeftIcon, { className: (0, exports.cnSidebarSizer)('Icon') }) }))); }); exports.SidebarSizer.displayName = 'SidebarSizer';