export default [
  {
    title: 'JSON',
    screenshot: 'https://alifd.alicdn.com/fusion-cool/icons/icon-antd/input-text-area-1.png',
    schema: {
      title: 'JSON',
      componentName: 'FormItemInput.JSON',
      props: {
        autoSize: {
          minRows: 4,
        },
        placeholder: '请输入',
        normalize: {
          type: 'JSExpression',
          value:
            '(value) => {\n  try {\n    return JSON.parse(value);\n  } catch(error) {\n    console.log(error)\n  }\n  return value\n}',
        },
        getValueProps: {
          type: 'JSExpression',
          value:
            '(value) => {\n  try {\n   return { value: value != "" && typeof value === \'object\' ? JSON.stringify(value, null, 2) : value};\n  } catch(error) {\n    console.log(error)\n  }\n  return {value: value}\n}',
        },
        validator: {
          type: 'JSExpression',
          value:
            "async (value) => {\n try {\n    if (typeof value === 'string' && value.trim() !== '') {\n      JSON.parse(value);\n    }\n  } catch (err) {\n    return Promise.reject(new Error(err.message));\n  }\n}",
        }
      },
    },
  },
];
