UNPKG

@atlaskit/primitives

Version:

Primitives are token-backed low-level building blocks.

84 lines (82 loc) 3.88 kB
/* inline.tsx generated by @compiled/babel-plugin v0.39.1 */ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("./inline.compiled.css"); var _react = _interopRequireWildcard(require("react")); var React = _react; var _runtime = require("@compiled/react/runtime"); var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _css = require("@atlaskit/css"); var _flex = _interopRequireDefault(require("./flex")); var _excluded = ["as", "alignInline", "alignBlock", "shouldWrap", "spread", "grow", "space", "rowSpace", "separator", "xcss", "testId", "role", "children"]; function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); } var styles = { separator: "_1mouze3t _195g1i6y _syazjjyb _lcxvglyw _uiztglyw", hug: "_16jlidpf", fill: "_1bsb1osq _16jlkb7n" }; var Separator = function Separator(_ref) { var children = _ref.children; return /*#__PURE__*/React.createElement("span", { className: (0, _runtime.ax)([styles.separator]) }, children); }; /** * __Inline__ * * Inline is a primitive component based on CSS Flexbox that manages the horizontal layout of direct children. * * @example * ```tsx * <Inline> * <Box padding="space.100" backgroundColor="neutral"></Box> * <Box padding="space.100" backgroundColor="neutral"></Box> * </Inline> * ``` * */ var Inline = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) { var as = _ref2.as, alignInline = _ref2.alignInline, _ref2$alignBlock = _ref2.alignBlock, alignItems = _ref2$alignBlock === void 0 ? 'start' : _ref2$alignBlock, _ref2$shouldWrap = _ref2.shouldWrap, shouldWrap = _ref2$shouldWrap === void 0 ? false : _ref2$shouldWrap, spread = _ref2.spread, grow = _ref2.grow, space = _ref2.space, rowSpace = _ref2.rowSpace, separator = _ref2.separator, xcss = _ref2.xcss, testId = _ref2.testId, role = _ref2.role, rawChildren = _ref2.children, ariaAttributes = (0, _objectWithoutProperties2.default)(_ref2, _excluded); var separatorComponent = typeof separator === 'string' ? /*#__PURE__*/React.createElement(Separator, null, separator) : separator; var children = separatorComponent ? _react.Children.toArray(rawChildren).filter(Boolean).map(function (child, index) { return /*#__PURE__*/React.createElement(_react.Fragment, { key: index }, separator && index > 0 ? separatorComponent : null, child); }) : rawChildren; return /*#__PURE__*/React.createElement(_flex.default, (0, _extends2.default)({}, ariaAttributes, { as: as, role: role, alignItems: alignItems, justifyContent: spread || alignInline, direction: "row", gap: space, rowGap: rowSpace, wrap: shouldWrap ? 'wrap' : undefined, xcss: (0, _css.cx)(grow === 'hug' && styles.hug, grow === 'fill' && styles.fill, xcss), testId: testId, ref: ref }), children); })); Inline.displayName = 'Inline'; var _default = exports.default = Inline;