mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: style bill form.
feat: add row and column of grid components.
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import React, { useCallback, useMemo, useEffect, useState } from 'react';
|
||||
import { MenuItem } from '@blueprintjs/core';
|
||||
import ListSelect from 'components/ListSelect';
|
||||
import { FormattedMessage as T } from 'react-intl';
|
||||
|
||||
function EstimateListField({
|
||||
products,
|
||||
initialProductId,
|
||||
selectedProductId,
|
||||
defautlSelectText = <T id={'select_product'} />,
|
||||
defautlSelectText = 'Click to select an item.',
|
||||
onProductSelected,
|
||||
}) {
|
||||
const initialProduct = useMemo(
|
||||
|
||||
113
client/src/components/Grid/Col.js
Normal file
113
client/src/components/Grid/Col.js
Normal file
@@ -0,0 +1,113 @@
|
||||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
const DEVICE_SIZES = ['xl', 'lg', 'md', 'sm', 'xs'];
|
||||
const rowColWidth = PropTypes.oneOfType([PropTypes.number, PropTypes.string]);
|
||||
|
||||
const rowColumns = PropTypes.oneOfType([
|
||||
rowColWidth,
|
||||
PropTypes.shape({
|
||||
cols: rowColWidth,
|
||||
}),
|
||||
]);
|
||||
|
||||
const propTypes = {
|
||||
/**
|
||||
* @default 'row'
|
||||
*/
|
||||
bsPrefix: PropTypes.string,
|
||||
|
||||
/** Removes the gutter spacing between `Col`s as well as any added negative margins. */
|
||||
noGutters: PropTypes.bool.isRequired,
|
||||
as: PropTypes.elementType,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on extra small devices (<576px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
xs: rowColumns,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on small devices (≥576px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
sm: rowColumns,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on medium devices (≥768px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
md: rowColumns,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on large devices (≥992px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
lg: rowColumns,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on extra large devices (≥1200px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
xl: rowColumns,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
noGutters: false,
|
||||
};
|
||||
|
||||
|
||||
function Row ({
|
||||
bsPrefix,
|
||||
className,
|
||||
noGutters,
|
||||
// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
|
||||
as: Component = 'div',
|
||||
...props
|
||||
}) {
|
||||
const decoratedBsPrefix = '';
|
||||
const sizePrefix = `col`;
|
||||
const classes = [];
|
||||
|
||||
DEVICE_SIZES.forEach((brkPoint) => {
|
||||
const propValue = props[brkPoint];
|
||||
delete props[brkPoint];
|
||||
|
||||
let cols;
|
||||
if (propValue != null && typeof propValue === 'object') {
|
||||
({ cols } = propValue);
|
||||
} else {
|
||||
cols = propValue;
|
||||
}
|
||||
|
||||
const infix = brkPoint !== 'xs' ? `-${brkPoint}` : '';
|
||||
|
||||
if (cols != null) classes.push(`${sizePrefix}${infix}-${cols}`);
|
||||
});
|
||||
|
||||
return (
|
||||
<Component
|
||||
{...props}
|
||||
className={classNames(
|
||||
'col',
|
||||
className,
|
||||
decoratedBsPrefix,
|
||||
noGutters && 'no-gutters',
|
||||
...classes,
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Row.displayName = 'Row';
|
||||
Row.propTypes = propTypes;
|
||||
Row.defaultProps = defaultProps;
|
||||
|
||||
export default Row;
|
||||
111
client/src/components/Grid/Row.js
Normal file
111
client/src/components/Grid/Row.js
Normal file
@@ -0,0 +1,111 @@
|
||||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
const DEVICE_SIZES = ['xl', 'lg', 'md', 'sm', 'xs'];
|
||||
const rowColWidth = PropTypes.oneOfType([PropTypes.number, PropTypes.string]);
|
||||
|
||||
const rowColumns = PropTypes.oneOfType([
|
||||
rowColWidth,
|
||||
PropTypes.shape({
|
||||
cols: rowColWidth,
|
||||
}),
|
||||
]);
|
||||
|
||||
const propTypes = {
|
||||
/**
|
||||
* @default 'row'
|
||||
*/
|
||||
bsPrefix: PropTypes.string,
|
||||
|
||||
/** Removes the gutter spacing between `Col`s as well as any added negative margins. */
|
||||
noGutters: PropTypes.bool.isRequired,
|
||||
as: PropTypes.elementType,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on extra small devices (<576px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
xs: rowColumns,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on small devices (≥576px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
sm: rowColumns,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on medium devices (≥768px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
md: rowColumns,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on large devices (≥992px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
lg: rowColumns,
|
||||
|
||||
/**
|
||||
* The number of columns that will fit next to each other on extra large devices (≥1200px)
|
||||
*
|
||||
* @type {(number|{ cols: number })}
|
||||
*/
|
||||
xl: rowColumns,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
noGutters: false,
|
||||
};
|
||||
|
||||
function Row ({
|
||||
bsPrefix,
|
||||
className,
|
||||
noGutters,
|
||||
// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
|
||||
as: Component = 'div',
|
||||
...props
|
||||
}) {
|
||||
const decoratedBsPrefix = 'row';
|
||||
const sizePrefix = `${decoratedBsPrefix}-cols`;
|
||||
const classes = [];
|
||||
|
||||
DEVICE_SIZES.forEach((brkPoint) => {
|
||||
const propValue = props[brkPoint];
|
||||
delete props[brkPoint];
|
||||
|
||||
let cols;
|
||||
if (propValue != null && typeof propValue === 'object') {
|
||||
({ cols } = propValue);
|
||||
} else {
|
||||
cols = propValue;
|
||||
}
|
||||
|
||||
const infix = brkPoint !== 'xs' ? `-${brkPoint}` : '';
|
||||
|
||||
if (cols != null) classes.push(`${sizePrefix}${infix}-${cols}`);
|
||||
});
|
||||
|
||||
return (
|
||||
<Component
|
||||
{...props}
|
||||
className={classNames(
|
||||
className,
|
||||
decoratedBsPrefix,
|
||||
noGutters && 'no-gutters',
|
||||
...classes,
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Row.displayName = 'Row';
|
||||
Row.propTypes = propTypes;
|
||||
Row.defaultProps = defaultProps;
|
||||
|
||||
export default Row;
|
||||
@@ -26,6 +26,8 @@ import DialogContent from './Dialog/DialogContent';
|
||||
import DialogSuspense from './Dialog/DialogSuspense';
|
||||
import InputPrependButton from './Forms/InputPrependButton';
|
||||
import CategoriesSelectList from './CategoriesSelectList';
|
||||
import Row from './Grid/Row';
|
||||
import Col from './Grid/Col';
|
||||
|
||||
const Hint = FieldHint;
|
||||
|
||||
@@ -58,5 +60,7 @@ export {
|
||||
DialogContent,
|
||||
DialogSuspense,
|
||||
InputPrependButton,
|
||||
CategoriesSelectList
|
||||
CategoriesSelectList,
|
||||
Col,
|
||||
Row,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user