{"version":3,"file":"HasMany.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '@contember/binding'\nimport { Environment } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { SugaredRelativeEntityList } from '@contember/binding'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n} & (\n\t| {}\n\t| {\n\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\tlistProps?: ListProps\n\t\t  }\n)\n\n/**\n * @group Data binding\n */\nexport const HasMany = Component(\n\t<ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => {\n\t\tconst entityList = useEntityList(props)\n\n\t\treturn <EntityList {...props} accessor={entityList} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeEntityListFields(props, environment, fields),\n\t},\n\t'HasMany',\n) as <ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => ReactElement\n"],"names":["Component","useEntityList","jsxDEV","EntityList","this","TreeNodeEnvironmentFactory","Field","PRIMARY_KEY_NAME","MarkerFactory"],"mappings":";;;;;;;;AAyBO,MAAM,UAAUA,UAAA;AAAA,EACtB,CAAyB,UAAgD;AAClE,UAAA,aAAaC,4BAAc,KAAK;AAEtC,WAAQC,8BAAA,OAAAC,uBAAA,EAAY,GAAG,OAAO,UAAU,WAAjC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA6C,GAAAC,MAAA;AAAA,EACrD;AAAA,EACA;AAAA,IACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAAC,mCAA2B,+BAA+B,aAAa,KAAK;AAAA,IACpF;AAAA,IACA,cAAc,CACb,UAAAH,8BAAAA,OAACC,yBAAY,GAAG,OAAO,UAAU,QAChC,UAAA;AAAA,MAACD,8BAAA,OAAAI,MAAA,OAAA,EAAM,OAAOC,QAAd,iBAAA,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAgC,GAAAH,MAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,KAFR,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGA,GAAAA,MAAA;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrCI,QAAAA,cAAc,+BAA+B,OAAO,aAAa,MAAM;AAAA,EACzE;AAAA,EACA;AACD;;"}