1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-06-16 13:46:16 +02:00

Set modules.

This commit is contained in:
Bogdan Bodnar
2019-08-27 11:54:57 +02:00
parent 7b38c1658c
commit 19df5c2630
53 changed files with 275 additions and 224 deletions

View File

@ -22,7 +22,7 @@ Alert.propTypes = {
onDismiss: PropTypes.func
};
export default function Alert({type, message, onDismiss, children}) {
export function Alert({type, message, onDismiss, children}) {
return <div className={`alert alert-dismissible alert-${type}`}>
{onDismiss ? <button type="button" className="close" onClick={onDismiss}>&times;</button> : false}
{message}

View File

@ -29,7 +29,7 @@ Button.propTypes = {
]).isRequired
};
export default function Button({className, loading, forisFormSize, children, ...props}) {
export function Button({className, loading, forisFormSize, children, ...props}) {
className = className ? 'btn ' + className : 'btn btn-primary ';
if (forisFormSize)
className += SIZE_CLASS + SIZE_CLASS_SM;

View File

@ -7,7 +7,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {useUID} from 'react-uid/dist/es5/index';
import {useUID} from 'react-uid';
import {formFieldsSize} from './constants';
@ -27,7 +27,7 @@ CheckBox.defaultProps = {
disabled: false
};
export default function CheckBox({label, helpText, useDefaultSize, disabled, ...props}) {
export function CheckBox({label, helpText, useDefaultSize, disabled, ...props}) {
const uid = useUID();
return <div className={useDefaultSize ? formFieldsSize : ""} style={{marginBottom: '1rem'}}>
<div className='custom-control custom-checkbox' style={{marginBottom: '0'}}>

View File

@ -10,7 +10,7 @@ import PropTypes from 'prop-types';
import Datetime from 'react-datetime/DateTime';
import moment from 'moment/moment';
import Input from './Input';
import {Input} from './Input';
DataTimeInput.propTypes = {
/** Field label. */
@ -35,7 +35,7 @@ DataTimeInput.propTypes = {
const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
const DEFAULT_TIME_FORMAT = 'HH:mm:ss';
export default function DataTimeInput({value, onChange, isValidDate, dateFormat, timeFormat, children, ...props}) {
export function DataTimeInput({value, onChange, isValidDate, dateFormat, timeFormat, children, ...props}) {
function renderInput(datetimeProps) {
return <Input
{...props}

View File

@ -7,11 +7,10 @@
import React from 'react';
import Input from './Input';
import {Input} from './Input';
import PropTypes from 'prop-types';
const EmailInput = ({...props}) => <Input type="email" {...props}/>;
export const EmailInput = ({...props}) => <Input type="email" {...props}/>;
EmailInput.propTypes = {
/** Field label. */
@ -23,5 +22,3 @@ EmailInput.propTypes = {
/** Email value. */
value: PropTypes.string,
};
export default EmailInput;

View File

@ -6,7 +6,7 @@
*/
import React from 'react';
import {useUID} from 'react-uid/dist/es5/index';
import {useUID} from 'react-uid';
import {formFieldsSize} from './constants';
import PropTypes from 'prop-types';
@ -23,7 +23,7 @@ Input.propTypes = {
}
/** Base bootstrap input component. */
export default function Input({type, label, helpText, error, className, children, ...props}) {
export function Input({type, label, helpText, error, className, children, ...props}) {
const uid = useUID();
const inputClassName = `form-control ${className ? className : ''} ${(error ? 'is-invalid' : '')}`.trim();
return <div className={formFieldsSize}>

View File

@ -7,7 +7,8 @@
import React, {useEffect, useRef} from 'react';
import PropTypes from 'prop-types';
import Portal from 'utils/Portal';
import {Portal} from 'utils/Portal';
Modal.propTypes = {
/** Is modal shown value */

View File

@ -7,10 +7,10 @@
import React from 'react';
import Input from './Input';
import {Input} from './Input';
import PropTypes from 'prop-types';
const NumberInput = ({...props}) => <Input type="number" {...props}/>;
export const NumberInput = ({...props}) => <Input type="number" {...props}/>;
NumberInput.propTypes = {
/** Field label. */
@ -25,5 +25,3 @@ NumberInput.propTypes = {
PropTypes.number,
]),
};
export default NumberInput;

View File

@ -8,7 +8,7 @@
import React, {useState} from 'react';
import PropTypes from 'prop-types';
import Input from './Input';
import {Input} from './Input';
PasswordInput.propTypes = {
/** Field label. */
@ -23,7 +23,7 @@ PasswordInput.propTypes = {
withEye: PropTypes.bool,
};
export default function PasswordInput({withEye, ...props}) {
export function PasswordInput({withEye, ...props}) {
const [isHidden, setHidden] = useState(true);
return <Input
type={withEye ? isHidden ? 'password' : 'text' : 'password'}

View File

@ -7,7 +7,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {useUID} from 'react-uid/dist/es5/index';
import {useUID} from 'react-uid';
import {formFieldsSize} from './constants';
@ -30,7 +30,7 @@ RadioSet.propTypes = {
helpText: PropTypes.string,
};
export default function RadioSet({name, label, choices, value, helpText, ...props}) {
export function RadioSet({name, label, choices, value, helpText, ...props}) {
const uid = useUID();
const radios = choices.map((choice, key) =>
<Radio

View File

@ -7,7 +7,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {useUID} from 'react-uid/dist/es5/index';
import {useUID} from 'react-uid';
Select.propTypes = {
@ -24,7 +24,7 @@ Select.propTypes = {
helpText: PropTypes.string,
};
export default function Select({label, choices, helpText, ...props}) {
export function Select({label, choices, helpText, ...props}) {
const uid = useUID();
const options = Object.keys(choices).map(

View File

@ -23,7 +23,7 @@ Spinner.defaultProps = {
fullScreen: false,
};
export default function Spinner({fullScreen, children, className, ...props}) {
export function Spinner({fullScreen, children, className, ...props}) {
if (!fullScreen) {
return <div className={'spinner-wrapper ' + (className ? className : '')} {...props}>
<SpinnerElement>{children}</SpinnerElement>

View File

@ -8,10 +8,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import Input from './Input';
import {Input} from './Input';
const TextInput = ({...props}) => <Input type="text" {...props}/>;
export const TextInput = ({...props}) => <Input type="text" {...props}/>;
TextInput.propTypes = {
@ -22,5 +22,3 @@ TextInput.propTypes = {
/** Help text message. */
helpText: PropTypes.string,
};
export default TextInput;

View File

@ -9,7 +9,7 @@ import React from 'react';
import {render} from 'customTestRender';
import Button from '../components/Button'
import Button from '../Button'
describe('<Button />', () => {
it('Render button correctly', () => {

View File

@ -9,7 +9,7 @@ import React from 'react';
import {render} from 'customTestRender';
import Checkbox from '../components/Checkbox'
import Checkbox from '../Checkbox'
describe('<Checkbox/>', () => {
it('Render checkbox', () => {

View File

@ -9,7 +9,7 @@ import React from 'react';
import {render} from 'customTestRender';
import NumberInput from '../components/NumberInput';
import NumberInput from '../NumberInput';
describe('<NumberInput/>', () => {

View File

@ -9,7 +9,7 @@ import React from 'react';
import {render} from 'customTestRender';
import PasswordInput from '../components/PasswordInput';
import PasswordInput from '../PasswordInput';
describe('<PasswordInput/>', () => {
it('Render password input', () => {

View File

@ -9,7 +9,7 @@ import React from 'react';
import {render} from 'customTestRender';
import RadioSet from '../components/RadioSet';
import RadioSet from '../RadioSet';
const TEST_CHOICES = [
{label: 'label', value: 'value'},

View File

@ -9,7 +9,7 @@ import React from 'react';
import {fireEvent, getByDisplayValue, getByText, render} from 'customTestRender';
import Select from '../components/Select';
import Select from '../Select';
const TEST_CHOICES = {
'1': 'one',

View File

@ -9,7 +9,7 @@ import React from 'react';
import {render} from 'customTestRender';
import TextInput from '../components/TextInput';
import TextInput from '../TextInput';
describe('<TextInput/>', () => {
it('Render text input', () => {

View File

@ -1,31 +0,0 @@
import * as Alert from "./components/Alert";
import * as Button from "./components/Button";
import * as Checkbox from "./components/Checkbox";
import * as constants from "./components/constants";
import * as DataTimeInput from "./components/DataTimeInput";
import * as EmailInput from "./components/EmailInput";
import * as Input from "./components/Input";
import * as Modal from "./components/Modal";
import * as NumberInput from "./components/NumberInput";
import * as PasswordInput from "./components/PasswordInput";
import * as RadioSet from "./components/RadioSet";
import * as Select from "./components/Select";
import * as Spinner from "./components/Spinner";
import * as TextInput from "./components/TextInput";
export {
Alert,
Button,
Checkbox,
constants,
DataTimeInput,
EmailInput,
Input,
Modal,
NumberInput,
PasswordInput,
RadioSet,
Select,
Spinner,
TextInput,
}