@wordpress/components
Version:
UI components for WordPress.
8 lines (7 loc) • 2.81 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/z-stack/component.tsx"],
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { isValidElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getValidChildren } from '../utils/get-valid-children';\nimport { contextConnect, useContextSystem } from '../context';\nimport { ZStackView, ZStackChildView } from './styles';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnconnectedZStack(props, forwardedRef) {\n const {\n children,\n className,\n isLayered = true,\n isReversed = false,\n offset = 0,\n ...otherProps\n } = useContextSystem(props, 'ZStack');\n const validChildren = getValidChildren(children);\n const childrenLastIndex = validChildren.length - 1;\n const clonedChildren = validChildren.map((child, index) => {\n const zIndex = isReversed ? childrenLastIndex - index : index;\n // Only when the component is layered, the offset needs to be multiplied by\n // the item's index, so that items can correctly stack at the right distance\n const offsetAmount = isLayered ? offset * index : offset;\n const key = isValidElement(child) ? child.key : index;\n return /*#__PURE__*/_jsx(ZStackChildView, {\n offsetAmount: offsetAmount,\n zIndex: zIndex,\n children: child\n }, key);\n });\n return /*#__PURE__*/_jsx(ZStackView, {\n ...otherProps,\n className: className,\n isLayered: isLayered,\n ref: forwardedRef,\n children: clonedChildren\n });\n}\n\n/**\n * `ZStack` allows you to stack things along the Z-axis.\n *\n * ```jsx\n * import { __experimentalZStack as ZStack } from '@wordpress/components';\n *\n * function Example() {\n * return (\n * <ZStack offset={ 20 } isLayered>\n * <ExampleImage />\n * <ExampleImage />\n * <ExampleImage />\n * </ZStack>\n * );\n * }\n * ```\n */\nexport const ZStack = contextConnect(UnconnectedZStack, 'ZStack');\nexport default ZStack;"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,qBAA+B;AAK/B,gCAAiC;AACjC,qBAAiD;AACjD,oBAA4C;AAC5C,yBAA4B;AAC5B,SAAS,kBAAkB,OAAO,cAAc;AAC9C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAAS;AAAA,IACT,GAAG;AAAA,EACL,QAAI,iCAAiB,OAAO,QAAQ;AACpC,QAAM,oBAAgB,4CAAiB,QAAQ;AAC/C,QAAM,oBAAoB,cAAc,SAAS;AACjD,QAAM,iBAAiB,cAAc,IAAI,CAAC,OAAO,UAAU;AACzD,UAAM,SAAS,aAAa,oBAAoB,QAAQ;AAGxD,UAAM,eAAe,YAAY,SAAS,QAAQ;AAClD,UAAM,UAAM,+BAAe,KAAK,IAAI,MAAM,MAAM;AAChD,WAAoB,uCAAAA,KAAK,+BAAiB;AAAA,MACxC;AAAA,MACA;AAAA,MACA,UAAU;AAAA,IACZ,GAAG,GAAG;AAAA,EACR,CAAC;AACD,SAAoB,uCAAAA,KAAK,0BAAY;AAAA,IACnC,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL,UAAU;AAAA,EACZ,CAAC;AACH;AAmBO,IAAM,aAAS,+BAAe,mBAAmB,QAAQ;AAChE,IAAO,oBAAQ;",
"names": ["_jsx"]
}