@razorpay/blade
Version:
The Design System that powers Razorpay
64 lines (61 loc) • 3.27 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { useCallback, forwardRef } from 'react';
import { useCollapsible } from './CollapsibleContext.js';
import { componentIds } from './componentIds.js';
import '../Button/BaseButton/index.js';
import '../../utils/assignWithoutSideEffects/index.js';
import '../../utils/index.js';
import '../../utils/makeAnalyticsAttribute/index.js';
import { jsx } from 'react/jsx-runtime';
import BaseButton from '../Button/BaseButton/BaseButton.js';
import { isReactNative } from '../../utils/platform/isReactNative.js';
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
var _excluded = ["children", "variant", "size", "icon", "iconPosition", "isDisabled", "testID", "accessibilityLabel"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var _CollapsibleButton = function _CollapsibleButton(_ref, ref) {
var children = _ref.children,
variant = _ref.variant,
size = _ref.size,
icon = _ref.icon,
iconPosition = _ref.iconPosition,
isDisabled = _ref.isDisabled,
testID = _ref.testID,
accessibilityLabel = _ref.accessibilityLabel,
rest = _objectWithoutProperties(_ref, _excluded);
var _useCollapsible = useCollapsible(),
onExpandChange = _useCollapsible.onExpandChange,
isExpanded = _useCollapsible.isExpanded,
collapsibleBodyId = _useCollapsible.collapsibleBodyId;
var toggleIsExpanded = useCallback(function () {
return onExpandChange(!isExpanded);
}, [onExpandChange, isExpanded]);
return /*#__PURE__*/jsx(BaseButton, _objectSpread(_objectSpread({
variant: variant,
size: size
// Button handles case of icon and children so we don't care about icon type safety here
,
icon: icon,
iconPosition: iconPosition,
isDisabled: isDisabled,
testID: testID,
ref: ref,
onClick: toggleIsExpanded,
alignSelf: isReactNative() ? 'flex-start' : undefined,
accessibilityProps: {
label: accessibilityLabel,
controls: collapsibleBodyId,
expanded: isExpanded
}
}, makeAnalyticsAttribute(rest)), {}, {
children: children
}));
};
var CollapsibleButton = /*#__PURE__*/assignWithoutSideEffects( /*#__PURE__*/forwardRef(_CollapsibleButton), {
displayName: 'CollapsibleButton',
componentId: componentIds.CollapsibleButton
});
export { CollapsibleButton };
//# sourceMappingURL=CollapsibleButton.js.map