{"version":3,"file":"PropertyFields.mjs","names":["mapKeys","React","widgets","Typography","getFieldValuesForProperties","type","properties","value","key","getPropertiesForFieldValues","values","startsWith","substr","length","PropertyWidget","props","$","_c","propertyType","property","initialData","disabled","WidgetPropertyComponent","t0","PropertyField","PropertyFields","propertyTable","map","p"],"sources":["../../../src/UI/property/PropertyFields.jsx"],"sourcesContent":["import { mapKeys } from 'lodash-es';\nimport React from 'react';\nimport widgets from './widgets';\nimport { Typography } from '@material-ui/core';\n\n/**\n * Convert a simple key/value properties object to an initialValues object with the prefixes used by widget components\n */\nexport function getFieldValuesForProperties(type, properties) {\n  return mapKeys(properties, (value, key) => `${type}:${key}`);\n}\n\n/**\n * Convert a values object with the prefixes used by widget components into a simple key/value properties object\n */\nexport function getPropertiesForFieldValues(type, values) {\n  const properties = {};\n  for (const key in values) {\n    if (key.startsWith(type + ':')) {\n      properties[key.substr(type.length + 1)] = values[key];\n    }\n  }\n\n  return properties;\n}\n\n/**\n * Single dynamic widget for a component property\n */\nconst PropertyWidget = props => {\n  const { propertyType, property, initialData, disabled } = props;\n  const { type } = property;\n\n  if (type in widgets) {\n    const WidgetPropertyComponent = widgets[type];\n\n    return (\n      <WidgetPropertyComponent\n        propertyType={propertyType}\n        property={property}\n        initialData={initialData}\n        disabled={disabled}\n      />\n    );\n  }\n\n  return <Typography color=\"error\">Unknown property type {type}</Typography>;\n};\n\n/**\n * Shared component for outputting dynamic fields from properties table\n */\nexport const PropertyField = props => {\n  const { propertyType, property, initialData, disabled } = props;\n\n  return (\n    <PropertyWidget\n      propertyType={propertyType}\n      property={property}\n      initialData={initialData}\n      disabled={disabled}\n    />\n  );\n};\n\n/**\n * Shared component for outputting dynamic fields from properties table\n */\nexport const PropertyFields = props => {\n  const { propertyType, propertyTable, initialData } = props;\n\n  return propertyTable.map(p => (\n    <PropertyWidget\n      key={p.key}\n      propertyType={propertyType}\n      property={p}\n      initialData={initialData}\n    />\n  ));\n};\n"],"mappings":";;;;;;;;;AAQA,SAAg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