UNPKG

@atlaskit/editor-plugin-extension

Version:

editor-plugin-extension plugin for @atlaskit/editor-core

82 lines 2.68 kB
import _extends from "@babel/runtime/helpers/extends"; import React, { Fragment } from 'react'; import { Field } from '@atlaskit/form'; import TextArea from '@atlaskit/textarea'; import TextField from '@atlaskit/textfield'; import FieldMessages from '../FieldMessages'; import { validate } from '../utils'; export default function String({ name, field, autoFocus, onFieldChange, placeholder }) { const { label, description, defaultValue, isRequired, isDisabled } = field; return /*#__PURE__*/React.createElement(Field, { name: name, label: label, defaultValue: defaultValue || '', isRequired: isRequired // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed) , validate: value => validate(field, value || ''), testId: `config-panel-string-${name}`, isDisabled: isDisabled }, ({ fieldProps, error, meta }) => { if (field.style === 'multiline') { const { onChange, ...restFieldProps } = fieldProps; const { options } = field; return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(TextArea // Ignored via go/ees005 // eslint-disable-next-line react/jsx-props-no-spreading , _extends({}, restFieldProps, options, { // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed) onChange: e => onChange(e.currentTarget.value) // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed) , onBlur: () => { fieldProps.onBlur(); onFieldChange(name, meta.dirty); }, placeholder: placeholder, "data-testid": `config-panel-textarea-${name}` })), /*#__PURE__*/React.createElement(FieldMessages, { error: error, description: description })); } return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(TextField // Ignored via go/ees005 // eslint-disable-next-line react/jsx-props-no-spreading , _extends({}, fieldProps, { type: "text", autoFocus: autoFocus // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed) , onBlur: () => { fieldProps.onBlur(); onFieldChange(name, meta.dirty); }, placeholder: placeholder })), /*#__PURE__*/React.createElement(FieldMessages, { error: error, description: description })); }); }