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S,GAAiB,gDAQ5BT,IAAAA,cAAChB,IAAWkE,EACVlD,IAAAA,cAACP,EAAc,CACbuB,SAAUA,GAAYiB,EACtB6B,KAAMtC,EACNP,KAAMM,EACN5B,MAAOmB,GAAWnB,GAEjBgB,GAAqB,WAO5BX,IAAAA,cAAC+D,IAAAA,KAAS,CACN7D,UAAU,oBACV,qBAAoBZ,EACpB8B,SAAUA,EACVP,MAAOA,EACPvB,KAAMA,EACN0E,KAAe,MAATpD,EAAgBA,EAASjB,IAASmB,GAAWN,EAAYb,OAAOsE,EACtElD,SAAUA,EACVD,QAASA,GAAWnB,EACpBuE,YAAsB,MAATtD,EACbuD,eAAgBvD,EAAQ,aAASqD,GAEhClE,EAGT,GACA,CAAC,QAAS,OAAQ,cAAe,oBAAqB,mBAExDqE,EAAAA,EAAAA,GAAM,uBAEN,O,wDCzLIC,E,MAA0B,GAA4B,KAE1DA,EAAwBC,KAAK,CAACC,EAAOC,GAAI,gWAAiW,GAAG,CAAC,QAAU,EAAE,QAAU,CAAC,6CAA6C,MAAQ,GAAG,SAAW,2JAA2J,eAAiB,CAAC,obAAob,WAAa,MAEtlC,K","sources":["webpack:///./react-antd/upload/upload.scss?2fa0","webpack:///./react-antd/upload/index.js","webpack:///./react-antd/upload/upload.scss"],"sourcesContent":["\n      import API from \"!../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\";\n      import domAPI from \"!../../node_modules/style-loader/dist/runtime/styleDomAPI.js\";\n      import insertFn from \"!../../node_modules/style-loader/dist/runtime/insertBySelector.js\";\n      import setAttributes from \"!../../node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\";\n      import insertStyleElement from \"!../../node_modules/style-loader/dist/runtime/insertStyleElement.js\";\n      import styleTagTransformFn from \"!../../node_modules/style-loader/dist/runtime/styleTagTransform.js\";\n      import content, * as namedExport from \"!!../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./upload.scss\";\n      \n      \n\nvar options = {};\n\noptions.styleTagTransform = styleTagTransformFn;\noptions.setAttributes = setAttributes;\n\n      options.insert = insertFn.bind(null, \"head\");\n    \noptions.domAPI = domAPI;\noptions.insertStyleElement = insertStyleElement;\n\nvar update = API(content, options);\n\n\n\nexport * from \"!!../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/dist/cjs.js!./upload.scss\";\n       export default content && content.locals ? content.locals : undefined;\n","\nimport React, { useCallback, useState } from 'react';\nimport _ from 'lodash';\nimport Button from 'antd/lib/button';\nimport Form from 'antd/lib/form';\nimport Upload from 'antd/lib/upload';\n\nimport { passRest } from '../../helpers';\nimport { I18N } from '../../components';\nimport { lfLog } from '../../helpers/lf-log';\n\nimport './upload.scss';\n\nconst { Dragger } = Upload;\n\nconst makeDefaultValue = defaultValue => {\n  if (_.isArray(defaultValue)) {\n    return defaultValue;\n  } else if (defaultValue != null) {\n    return [defaultValue];\n  }\n  return [];\n};\n\n// convert to same format for all upload\nconst translatePayload = files => {\n  if (_.isArray(files)) {\n    return files.map(translatePayload);\n  } else {  \n    return {\n      blobFile: files,\n      name: files.name,\n      fileKey: files.uid\n    };\n  }\n};\n\nconst ButtonWithHint = ({ hint, ...props}) => {\n  const inner = (\n    <Button \n      {...props}\n    />\n  );\n  \n  if (hint) {\n    return (\n      <div className=\"upload-layout\">\n        <div className=\"upload\">\n          {inner}\n        </div>\n        <div className=\"hint\">\n          {hint}  \n        </div>\n      </div>\n    )\n  }\n  return inner;\n}\n\nconst AntDUpload = I18N(\n  ({\n    name,\n    accept,\n    draggable,\n    draggableText,\n    draggableHeight,\n    uploadButtonLabel,\n    error,\n    label,\n    hint,\n    tooltip,\n    required,\n    size,\n    disabled,\n    value,\n    multiple,\n    listType,\n    maxCount,\n    showUploadList,\n    uploadButtonSize,\n    uploadButtonAppearance,\n    onChange = () => {},\n    ...rest\n  }) => {\n    const [currentValue, setCurrentValue] = useState(makeDefaultValue(value));\n\n    const disabledTooMany = (multiple && maxCount && currentValue && currentValue.length >= maxCount)\n      || (!multiple && !_.isEmpty(value));\n\n    const handlePropagate = useCallback(\n      newFileList => {\n        setCurrentValue(newFileList);\n        if (multiple) {\n          onChange(translatePayload(newFileList));\n        } else {\n          onChange(translatePayload(!_.isEmpty(newFileList) ? newFileList[0] : null));\n        }\n      },\n      [multiple, onChange]\n    );\n\n    const handleChange = useCallback(\n      (file, fileList) => {\n        const newFileList = [...currentValue, file];\n        handlePropagate(newFileList);\n        return false;\n      },\n      [currentValue, handlePropagate]\n    );\n\n    const handleRemove = useCallback(\n      file => {\n        const newFileList = currentValue.filter(f => f.uid !== file.uid);\n        handlePropagate(newFileList);\n      },\n      [currentValue, handlePropagate]\n    );\n\n    const handleDrag = useCallback(\n      e => {\n        const newFileList = [...currentValue, ...e.dataTransfer.files];\n        handlePropagate(newFileList);\n      },\n      [currentValue, handlePropagate]\n    );\n\n    const uploadProps = {\n      accept,\n      disabled,\n      multiple,\n      fileList: currentValue,\n      maxCount,\n      showUploadList,\n      beforeUpload: handleChange,\n      onRemove: handleRemove,\n      ...passRest(rest)\n    };\n\n    let inner;\n    if (draggable) {\n      inner = (\n        <Dragger \n          {...uploadProps}\n          onDrop={handleDrag}\n        >\n          <div style={{ height: draggableHeight, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>\n            <span>{draggableText || 'Click or Drag files to this area to upload'}</span>\n          </div>\n        </Dragger>\n      );\n    } else {\n\n      // TODO implementare il placeholder\n      inner = (\n        <Upload {...uploadProps}>\n          <ButtonWithHint\n            disabled={disabled || disabledTooMany}\n            type={uploadButtonAppearance}\n            size={uploadButtonSize}\n            hint={!tooltip && hint}\n          >\n            {uploadButtonLabel || 'Upload' }\n          </ButtonWithHint>\n        </Upload>\n      );\n    }\n\n    return (\n      <Form.Item\n          className=\"lf-control-upload\"\n          data-lf-field-name={name}\n          listType={listType}\n          label={label}\n          name={name}\n          help={error != null ? error : (hint && !tooltip && draggable ? hint : undefined)}\n          required={required}\n          tooltip={tooltip && hint}\n          hasFeedback={error != null}\n          validateStatus={error ? 'error': undefined}\n        >\n          {inner}\n        </Form.Item>\n    );\n  },\n  ['label', 'hint', 'placeholder', 'uploadButtonLabel', 'draggableText']\n);\nlfLog('Loaded AnttD.Upload');\n\nexport default AntDUpload;\n","// Imports\nimport ___CSS_LOADER_API_SOURCEMAP_IMPORT___ from \"../../node_modules/css-loader/dist/runtime/sourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../../node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, \".lf-control-upload .upload-layout{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-content:stretch;align-items:center}.lf-control-upload .upload-layout .upload{order:0;flex:0 0 auto;align-self:auto}.lf-control-upload .upload-layout .hint{margin-left:var(--lf-field-column-margin);order:0;flex:1 0 auto;align-self:auto}\", \"\",{\"version\":3,\"sources\":[\"webpack://./react-antd/upload/upload.scss\"],\"names\":[],\"mappings\":\"AACE,kCACE,YAAA,CACA,kBAAA,CACA,cAAA,CACA,0BAAA,CACA,qBAAA,CACA,kBAAA,CAEA,0CACE,OAAA,CACA,aAAA,CACA,eAAA,CAGF,wCACE,yCAAA,CACA,OAAA,CACA,aAAA,CACA,eAAA\",\"sourcesContent\":[\".lf-control-upload {\\n  .upload-layout {\\n    display: flex;\\n    flex-direction: row;\\n    flex-wrap: wrap;\\n    justify-content: flex-start;\\n    align-content: stretch;\\n    align-items: center;\\n\\n    .upload {\\n      order: 0;\\n      flex: 0 0 auto;\\n      align-self: auto;\\n    }\\n\\n    .hint {\\n      margin-left: var(--lf-field-column-margin);\\n      order: 0;\\n      flex: 1 0 auto;\\n      align-self: auto;\\n    }\\n  }\\n}\"],\"sourceRoot\":\"\"}]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___;\n"],"names":["options","styleTagTransform","setAttributes","insert","domAPI","insertStyleElement","Dragger","Upload","translatePayload","files","_isArray","map","blobFile","name","fileKey","uid","ButtonWithHint","_ref","hint","props","_objectWithoutProperties","_excluded","inner","React","Button","className","AntDUpload","I18N","_ref2","defaultValue","accept","draggable","draggableText","draggableHeight","uploadButtonLabel","error","label","tooltip","required","disabled","size","value","multiple","listType","maxCount","showUploadList","uploadButtonSize","uploadButtonAppearance","_ref2$onChange","onChange","rest","_excluded2","_useState2","useState","currentValue","setCurrentValue","disabledTooMany","length","_isEmpty","handlePropagate","useCallback","newFileList","handleChange","file","fileList","concat","_toConsumableArray","handleRemove","filter","f","handleDrag","e","dataTransfer","uploadProps","_objectSpread","beforeUpload","onRemove","passRest","_extends","onDrop","style","height","display","alignItems","justifyContent","type","Form","help","undefined","hasFeedback","validateStatus","lfLog","___CSS_LOADER_EXPORT___","push","module","id"],"sourceRoot":""}