UNPKG

@gechiui/components

Version:
63 lines (51 loc) 1.69 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _element = require("@gechiui/element"); var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _getValidChildren = require("../ui/utils/get-valid-children"); var _context = require("../ui/context"); var _styles = require("./styles"); /** * External dependencies */ // eslint-disable-next-line no-restricted-imports /** * GeChiUI dependencies */ /** * Internal dependencies */ function ZStack(props, forwardedRef) { const { children, className, isLayered = true, isReversed = false, offset = 0, ...otherProps } = (0, _context.useContextSystem)(props, 'ZStack'); const validChildren = (0, _getValidChildren.getValidChildren)(children); const childrenLastIndex = validChildren.length - 1; const clonedChildren = validChildren.map((child, index) => { const zIndex = isReversed ? childrenLastIndex - index : index; const offsetAmount = offset * index; const key = (0, _element.isValidElement)(child) ? child.key : index; return (0, _element.createElement)(_styles.ZStackChildView, { isLayered: isLayered, offsetAmount: offsetAmount, zIndex: zIndex, key: key }, child); }); return (0, _element.createElement)(_styles.ZStackView, (0, _extends2.default)({}, otherProps, { className: className, ref: forwardedRef }), clonedChildren); } var _default = (0, _context.contextConnect)(ZStack, 'ZStack'); exports.default = _default; //# sourceMappingURL=component.js.map