mirror of
https://github.com/strapi/strapi.git
synced 2025-09-09 08:39:45 +00:00
Add number input
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
50cd59e082
commit
6d512c0934
@ -93,6 +93,7 @@ const EditViewDataManagerProvider = ({
|
|||||||
const errorsInForm = Object.keys(formErrors);
|
const errorsInForm = Object.keys(formErrors);
|
||||||
|
|
||||||
// TODO check if working with DZ, components...
|
// TODO check if working with DZ, components...
|
||||||
|
// TODO use querySelector querySelectorAll('[data-strapi-field-error]')
|
||||||
if (errorsInForm.length > 0) {
|
if (errorsInForm.length > 0) {
|
||||||
const firstError = errorsInForm[0];
|
const firstError = errorsInForm[0];
|
||||||
const el = document.getElementById(firstError);
|
const el = document.getElementById(firstError);
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Input
|
* GenericInput
|
||||||
* This is a temp file move it to the helper plugin when ready
|
* This is a temp file move it to the helper plugin when ready
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { ToggleInput } from '@strapi/parts/ToggleInput';
|
import { NumberInput } from '@strapi/parts/NumberInput';
|
||||||
import { Textarea } from '@strapi/parts/Textarea';
|
import { Textarea } from '@strapi/parts/Textarea';
|
||||||
import { TextInput } from '@strapi/parts/TextInput';
|
import { TextInput } from '@strapi/parts/TextInput';
|
||||||
|
import { ToggleInput } from '@strapi/parts/ToggleInput';
|
||||||
import Hide from '@strapi/icons/Hide';
|
import Hide from '@strapi/icons/Hide';
|
||||||
import Show from '@strapi/icons/Show';
|
import Show from '@strapi/icons/Show';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
const Input = ({
|
const GenericInput = ({
|
||||||
autoComplete,
|
autoComplete,
|
||||||
customInputs,
|
customInputs,
|
||||||
description,
|
description,
|
||||||
@ -24,6 +25,7 @@ const Input = ({
|
|||||||
name,
|
name,
|
||||||
onChange,
|
onChange,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
step,
|
||||||
type,
|
type,
|
||||||
value,
|
value,
|
||||||
...rest
|
...rest
|
||||||
@ -98,6 +100,25 @@ const Input = ({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
case 'number': {
|
||||||
|
return (
|
||||||
|
<NumberInput
|
||||||
|
disabled={disabled}
|
||||||
|
error={errorMessage}
|
||||||
|
label={label}
|
||||||
|
labelAction={labelAction}
|
||||||
|
id={name}
|
||||||
|
hint={hint}
|
||||||
|
name={name}
|
||||||
|
onValueChange={value => {
|
||||||
|
onChange({ target: { name, value, type } });
|
||||||
|
}}
|
||||||
|
placeholder={formattedPlaceholder}
|
||||||
|
step={step}
|
||||||
|
value={value || undefined}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
case 'email':
|
case 'email':
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'string': {
|
case 'string': {
|
||||||
@ -180,7 +201,7 @@ const Input = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Input.defaultProps = {
|
GenericInput.defaultProps = {
|
||||||
autoComplete: undefined,
|
autoComplete: undefined,
|
||||||
customInputs: null,
|
customInputs: null,
|
||||||
description: null,
|
description: null,
|
||||||
@ -188,10 +209,11 @@ Input.defaultProps = {
|
|||||||
error: '',
|
error: '',
|
||||||
labelAction: undefined,
|
labelAction: undefined,
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
|
step: 1,
|
||||||
value: '',
|
value: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
Input.propTypes = {
|
GenericInput.propTypes = {
|
||||||
autoComplete: PropTypes.string,
|
autoComplete: PropTypes.string,
|
||||||
customInputs: PropTypes.object,
|
customInputs: PropTypes.object,
|
||||||
description: PropTypes.shape({
|
description: PropTypes.shape({
|
||||||
@ -214,8 +236,9 @@ Input.propTypes = {
|
|||||||
defaultMessage: PropTypes.string.isRequired,
|
defaultMessage: PropTypes.string.isRequired,
|
||||||
values: PropTypes.object,
|
values: PropTypes.object,
|
||||||
}),
|
}),
|
||||||
|
step: PropTypes.number,
|
||||||
type: PropTypes.string.isRequired,
|
type: PropTypes.string.isRequired,
|
||||||
value: PropTypes.any,
|
value: PropTypes.any,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Input;
|
export default GenericInput;
|
||||||
|
@ -156,7 +156,7 @@ const EditView = ({
|
|||||||
{grid.map(
|
{grid.map(
|
||||||
({ fieldSchema, labelAction, metadatas, name, size }) => {
|
({ fieldSchema, labelAction, metadatas, name, size }) => {
|
||||||
return (
|
return (
|
||||||
<GridItem col={size} key={name}>
|
<GridItem col={size} key={name} s={12} xs={12}>
|
||||||
<Inputs
|
<Inputs
|
||||||
fieldSchema={fieldSchema}
|
fieldSchema={fieldSchema}
|
||||||
keys={name}
|
keys={name}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user