UNPKG

orcs-design-system

Version:
137 lines 4.94 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; const _excluded = ["children", "theme", "gridAutoFlow", "gridGap"]; 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; } import React from "react"; import styled, { ThemeProvider } from "styled-components"; import { grid, space, layout, flex, color, compose } from "styled-system"; import { css } from "@styled-system/css"; import shouldForwardProp from "@styled-system/should-forward-prop"; import PropTypes from "prop-types"; import { jsx as _jsx } from "react/jsx-runtime"; const GridStyles = compose(space, layout, grid, flex, color); const GridWrapper = /*#__PURE__*/styled("div").withConfig({ shouldForwardProp: prop => prop !== "loading" && shouldForwardProp(prop), displayName: "GridWrapper", componentId: "sc-1rlajun-0" }).attrs(props => ({ "data-testid": props.dataTestId ? props.dataTestId : props["data-testid"] ? props["data-testid"] : null }))(css({ boxSizing: "border-box", display: "grid" }), GridStyles); const GridItem = /*#__PURE__*/styled("div").withConfig({ shouldForwardProp, displayName: "GridItem", componentId: "sc-1rlajun-1" }).attrs(props => { var _props$padding; return { "data-testid": props.dataTestId ? props.dataTestId : props["data-testid"] ? props["data-testid"] : null, padding: (_props$padding = props.padding) !== null && _props$padding !== void 0 ? _props$padding : "0" }; })(css({ boxSizing: "border-box", minWidth: "0" }), GridStyles); export default function Grid(_ref) { let { children, theme, gridAutoFlow = "row", gridGap = "0" } = _ref, props = _objectWithoutProperties(_ref, _excluded); const component = /*#__PURE__*/_jsx(GridWrapper, _objectSpread(_objectSpread({ gridAutoFlow: gridAutoFlow, gridGap: gridGap }, props), {}, { children: children })); return theme ? /*#__PURE__*/_jsx(ThemeProvider, { theme: theme, children: component }) : component; } Grid.propTypes = { /** Children of `Grid` are taken as node elements */ children: PropTypes.node, /** Auto flow direction and rules */ gridAutoFlow: PropTypes.oneOf(["row", "column", "row dense", "column dense", "inherit", "initial", "unset"]), /** Defines the spacings between columns and rows. Takes the nth value, or a specific alias, from the design system spacing scale (specified in theme). */ gridGap: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), /** Specifies the system design theme. */ theme: PropTypes.object }; export { GridItem }; Grid.__docgenInfo = { "description": "", "methods": [], "displayName": "Grid", "props": { "gridAutoFlow": { "defaultValue": { "value": "\"row\"", "computed": false }, "description": "Auto flow direction and rules", "type": { "name": "enum", "value": [{ "value": "\"row\"", "computed": false }, { "value": "\"column\"", "computed": false }, { "value": "\"row dense\"", "computed": false }, { "value": "\"column dense\"", "computed": false }, { "value": "\"inherit\"", "computed": false }, { "value": "\"initial\"", "computed": false }, { "value": "\"unset\"", "computed": false }] }, "required": false }, "gridGap": { "defaultValue": { "value": "\"0\"", "computed": false }, "description": "Defines the spacings between columns and rows. Takes the nth value, or a specific alias, from the design system spacing scale (specified in theme).", "type": { "name": "union", "value": [{ "name": "number" }, { "name": "string" }] }, "required": false }, "children": { "description": "Children of `Grid` are taken as node elements", "type": { "name": "node" }, "required": false }, "theme": { "description": "Specifies the system design theme.", "type": { "name": "object" }, "required": false } } };