calcite-react
Version:
Calcite components for React
67 lines (52 loc) • 3.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CardContext = exports.default = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireWildcard(require("react"));
var _helpers = require("../utils/helpers");
var _CardStyled = require("./Card-styled");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var CardContext = (0, _react.createContext)({
cardContext: {
shaped: undefined,
wide: undefined
}
});
exports.CardContext = CardContext;
CardContext.displayName = 'CardContext';
var Card = (0, _react.forwardRef)(function (_ref, ref) {
var children = _ref.children,
shaped = _ref.shaped,
wide = _ref.wide,
other = _objectWithoutProperties(_ref, ["children", "shaped", "wide"]);
var cardContext = (0, _helpers.useContextState)({
shaped: shaped,
wide: wide
});
return _react.default.createElement(CardContext.Provider, {
value: cardContext
}, _react.default.createElement(_CardStyled.StyledCard, _extends({
shaped: shaped,
wide: wide,
ref: ref
}, other), children));
});
exports.default = Card;
Card.propTypes = {
/** The content of the component. */
children: _propTypes.default.node,
/** Style prop to show a colored bar across the top of the Card; can take a string for any color name in EsriColors. */
bar: _propTypes.default.string,
/** Style prop to add a shape mask to the CardImage. */
shaped: _propTypes.default.bool,
/** Style prop to position Card content horizontally and fill the width of its container. */
wide: _propTypes.default.bool
};
Card.defaultProps = {};
Card.displayName = 'Card';