{"version":3,"file":"hook.mjs","names":[],"sources":["../../src/h-stack/hook.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { WordPressComponentProps } from '../context';\nimport { hasConnectNamespace, useContextSystem } from '../context';\nimport { FlexItem, useFlex } from '../flex';\nimport { getAlignmentProps } from './utils';\nimport { getValidChildren } from '../utils/get-valid-children';\nimport type { Props } from './types';\n\nexport function useHStack( props: WordPressComponentProps< Props, 'div' > ) {\n\tconst {\n\t\talignment = 'edge',\n\t\tchildren,\n\t\tdirection,\n\t\tspacing = 2,\n\t\t...otherProps\n\t} = useContextSystem( props, 'HStack' );\n\n\tconst align = getAlignmentProps( alignment, direction );\n\n\tconst validChildren = getValidChildren( children );\n\tconst clonedChildren = validChildren.map( ( child, index ) => {\n\t\tconst _isSpacer = hasConnectNamespace( child, [ 'Spacer' ] );\n\n\t\tif ( _isSpacer ) {\n\t\t\tconst childElement = child as ReactElement< typeof FlexItem >;\n\t\t\tconst _key = childElement.key || `hstack-${ index }`;\n\n\t\t\treturn <FlexItem isBlock key={ _key } { ...childElement.props } />;\n\t\t}\n\n\t\treturn child;\n\t} );\n\n\tconst propsForFlex = {\n\t\tchildren: clonedChildren,\n\t\tdirection,\n\t\tjustify: 'center',\n\t\t...align,\n\t\t...otherProps,\n\t\tgap: spacing,\n\t};\n\n\t// Omit `isColumn` because it's not used in HStack.\n\tconst { isColumn, ...flexProps } = useFlex( propsForFlex );\n\n\treturn flexProps;\n}\n"],"mappings":";;;;;;AAQA,SAAgB,UAAW,OAAiD;CAC3E,MAAM,EACL,YAAY,QACZ,UACA,WACA,UAAU,GACV,GAAG,eACA,iBAAkB,OAAO,QAAS;CAEtC,MAAM,QAAQ,kBAAmB,WAAW,SAAU;CAgBtD,MAAM,eAAe;EACpB,UAfqB,iBAAkB,QACL,CAAC,CAAC,KAAO,OAAO,UAAW;GAG7D,IAFkB,oBAAqB,OAAO,CAAE,QAAS,CAE5C,GAAI;IAChB,MAAM,eAAe;IACrB,MAAM,OAAO,aAAa,OAAO,UAAW;IAE5C,OAAO,oBAAC,UAAD;KAAU,SAAA;KAAqB,GAAK,aAAa;IAAS,GAAlC,IAAkC;GAClE;GAEA,OAAO;EACR,CAGwB;EACvB;EACA,SAAS;EACT,GAAG;EACH,GAAG;EACH,KAAK;CACN;CAGA,MAAM,EAAE,UAAU,GAAG,cAAc,QAAS,YAAa;CAEzD,OAAO;AACR"}