@atlaskit/primitives
Version:
Primitives are token-backed low-level building blocks.
71 lines (70 loc) • 2.41 kB
JavaScript
/* inline.tsx generated by @compiled/babel-plugin v0.36.1 */
import "./inline.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { Children, forwardRef, Fragment, memo } from 'react';
import { cx } from '@atlaskit/css';
import Flex from './flex';
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: 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__*/memo( /*#__PURE__*/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;
var separatorComponent = typeof separator === 'string' ? /*#__PURE__*/React.createElement(Separator, null, separator) : separator;
var children = separatorComponent ? Children.toArray(rawChildren).filter(Boolean).map(function (child, index) {
return /*#__PURE__*/React.createElement(Fragment, {
key: index
}, separator && index > 0 ? separatorComponent : null, child);
}) : rawChildren;
return /*#__PURE__*/React.createElement(Flex, {
as: as,
role: role,
alignItems: alignItems,
justifyContent: spread || alignInline,
direction: "row",
gap: space,
rowGap: rowSpace,
wrap: shouldWrap ? 'wrap' : undefined,
xcss: cx(grow === 'hug' && styles.hug, grow === 'fill' && styles.fill, xcss),
testId: testId,
ref: ref
}, children);
}));
Inline.displayName = 'Inline';
export default Inline;