UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

60 lines (57 loc) 3.12 kB
import _defineProperty from '@babel/runtime/helpers/defineProperty'; import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; import { useCallback } from 'react'; import { useCollapsible } from './CollapsibleContext.js'; import { CollapsibleChevronIcon } from './CollapsibleChevronIcon.web.js'; import { componentIds } from './componentIds.js'; import '../Link/BaseLink/index.js'; import '../../utils/assignWithoutSideEffects/index.js'; import '../Box/styledProps/index.js'; import '../../utils/makeAnalyticsAttribute/index.js'; import { jsx } from 'react/jsx-runtime'; import BaseLink from '../Link/BaseLink/BaseLink.js'; import { getStyledProps } from '../Box/styledProps/getStyledProps.js'; import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js'; import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js'; var _excluded = ["children", "size", "color", "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 _CollapsibleLink = function _CollapsibleLink(_ref) { var children = _ref.children, size = _ref.size, _ref$color = _ref.color, color = _ref$color === void 0 ? 'primary' : _ref$color, 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(BaseLink, _objectSpread(_objectSpread(_objectSpread({ variant: "button", size: size, color: color, icon: CollapsibleChevronIcon, iconPosition: "right", isDisabled: isDisabled, testID: testID, onClick: toggleIsExpanded, accessibilityProps: { label: accessibilityLabel, controls: collapsibleBodyId, expanded: isExpanded } }, getStyledProps(rest)), makeAnalyticsAttribute(rest)), {}, { children: children })); }; var CollapsibleLink = /*#__PURE__*/assignWithoutSideEffects(_CollapsibleLink, { componentId: componentIds.CollapsibleLink }); export { CollapsibleLink }; //# sourceMappingURL=CollapsibleLink.js.map