All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.js.components.inputs.StringInput.js Maven / Gradle / Ivy

The newest version!
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

import {ClayInput, ClaySelectWithOption} from '@clayui/form';
import classNames from 'classnames';
import propTypes from 'prop-types';
import React, {useState} from 'react';

import {unescapeSingleQuotes} from '../../utils/odata';

function StringInput({
	disabled,
	onChange,
	options = [],
	propertyLabel,
	renderEmptyValueErrors,
	value: initialValue,
}) {
	const [value, setValue] = useState(unescapeSingleQuotes(initialValue));

	const handleChange = (event) => {
		setValue(event.target.value);

		onChange({value: event.target.value});
	};

	return !options.length ? (
		
	) : (
		 ({
				disabled: o.disabled,
				label: o.label,
				value: o.value,
			}))}
			value={value}
		/>
	);
}

StringInput.propTypes = {
	disabled: propTypes.bool,
	initialValue: propTypes.oneOfType([propTypes.string, propTypes.number]),
	onChange: propTypes.func.isRequired,
	options: propTypes.array,
	propertyLabel: propTypes.string.isRequired,
	renderEmptyValueErrors: propTypes.bool,
};

export default StringInput;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy