UNPKG

@wordpress/components

Version:
38 lines (37 loc) • 1.41 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let ___context_index_ts = require("../context/index.cjs"); let ___flex_index_ts = require("../flex/index.cjs"); let __utils_ts = require("./utils.cjs"); let ___utils_get_valid_children_ts = require("../utils/get-valid-children.cjs"); let react_jsx_runtime = require("react/jsx-runtime"); // packages/components/src/h-stack/hook.tsx function useHStack(props) { const { alignment = "edge", children, direction, spacing = 2, ...otherProps } = (0, ___context_index_ts.useContextSystem)(props, "HStack"); const align = (0, __utils_ts.getAlignmentProps)(alignment, direction); const propsForFlex = { children: (0, ___utils_get_valid_children_ts.getValidChildren)(children).map((child, index) => { if ((0, ___context_index_ts.hasConnectNamespace)(child, ["Spacer"])) { const childElement = child; const _key = childElement.key || `hstack-${index}`; return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___flex_index_ts.FlexItem, { isBlock: true, ...childElement.props }, _key); } return child; }), direction, justify: "center", ...align, ...otherProps, gap: spacing }; const { isColumn, ...flexProps } = (0, ___flex_index_ts.useFlex)(propsForFlex); return flexProps; } exports.useHStack = useHStack; //# sourceMappingURL=hook.cjs.map