{"version":3,"sources":["middlewares/CheckboxGroupMw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,eAAe,CA0BhE,CAAC;AAEF,eAAe,eAAe,CAAC","file":"CheckboxGroupMw.d.ts","sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { Checkbox } from 'antd';\nimport { MiddlewareProps } from '../share';\n\nexport const CheckboxGroupMw: React.ComponentType<MiddlewareProps> = (props) => {\n  const { schema, onChange, extraProps, next } = props;\n\n  if (\n    typeof schema === 'boolean' ||\n    Array.isArray(schema.items) ||\n    typeof schema.items === 'boolean' ||\n    !schema.items ||\n    !schema.items.enum ||\n    !schema.uniqueItems\n  ) {\n    return next(props);\n  }\n  const checkboxValues = schema.items.enum || [];\n  const labels = get(extraProps, 'labels', schema.items.enum);\n\n  const data = props.data || [];\n\n  return (\n    <Checkbox.Group\n      options={checkboxValues.map((value, index) => ({ label: get(labels, index, null), value: value as string }))}\n      value={data}\n      onChange={(value) => onChange(value)}\n      {...get(extraProps, 'props')}\n    />\n  );\n};\n\nexport default CheckboxGroupMw;\n"]}