@punch-in/buffet-modern-core 3.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/babel.config.js +18 -0
- package/build/bundle.development.js +850 -0
- package/build/bundle.production.js +1 -0
- package/build/esm/components/AttributeIcon/Div.js +51 -0
- package/build/esm/components/AttributeIcon/index.js +53 -0
- package/build/esm/components/Button/index.js +75 -0
- package/build/esm/components/Checkbox/index.js +78 -0
- package/build/esm/components/Count/Wrapper.js +32 -0
- package/build/esm/components/Count/index.js +27 -0
- package/build/esm/components/DatePicker/index.js +206 -0
- package/build/esm/components/DatePicker/reducer.js +42 -0
- package/build/esm/components/Enumeration/index.js +54 -0
- package/build/esm/components/Error/index.js +137 -0
- package/build/esm/components/Error/reducer.js +23 -0
- package/build/esm/components/Flex/index.js +29 -0
- package/build/esm/components/HeaderActions/index.js +41 -0
- package/build/esm/components/HeaderTitle/index.js +45 -0
- package/build/esm/components/Icon/index.js +26 -0
- package/build/esm/components/IconLinks/index.js +36 -0
- package/build/esm/components/InputNumber/index.js +70 -0
- package/build/esm/components/InputText/PrefixIcon.js +32 -0
- package/build/esm/components/InputText/index.js +89 -0
- package/build/esm/components/Label/index.js +40 -0
- package/build/esm/components/List/index.js +50 -0
- package/build/esm/components/ListHeader/BaselineAlignement.js +5 -0
- package/build/esm/components/ListHeader/index.js +52 -0
- package/build/esm/components/ListRow/index.js +30 -0
- package/build/esm/components/ListRow/tests/index.tests.js +21 -0
- package/build/esm/components/NavTabs/index.js +38 -0
- package/build/esm/components/Option/RemoveButton.js +5 -0
- package/build/esm/components/Option/index.js +32 -0
- package/build/esm/components/Padded/index.js +56 -0
- package/build/esm/components/Paging/index.js +57 -0
- package/build/esm/components/Picker/PickerButton.js +61 -0
- package/build/esm/components/Picker/PickerSection.js +48 -0
- package/build/esm/components/Picker/PickerWrapper.js +5 -0
- package/build/esm/components/Picker/index.js +50 -0
- package/build/esm/components/PrefixIcon/index.js +7 -0
- package/build/esm/components/Select/index.js +82 -0
- package/build/esm/components/Separator/index.js +44 -0
- package/build/esm/components/Table/ActionCollapse.js +40 -0
- package/build/esm/components/Table/index.js +140 -0
- package/build/esm/components/Table/tests/index.js +130 -0
- package/build/esm/components/TableHeader/index.js +88 -0
- package/build/esm/components/TableRow/index.js +93 -0
- package/build/esm/components/Text/index.js +67 -0
- package/build/esm/components/Textarea/index.js +16 -0
- package/build/esm/components/TimePicker/index.js +288 -0
- package/build/esm/components/Toggle/index.js +72 -0
- package/build/esm/components/UnknownInput/index.js +19 -0
- package/build/esm/index.js +33 -0
- package/build/esm/theme/colors.js +48 -0
- package/build/index.js +8 -0
- package/package.json +123 -0
- package/src/components/AttributeIcon/Div.js +63 -0
- package/src/components/AttributeIcon/index.js +72 -0
- package/src/components/Button/index.js +95 -0
- package/src/components/Checkbox/index.js +86 -0
- package/src/components/Checkbox/tests/Checkbox.test.js +49 -0
- package/src/components/Count/Wrapper.js +36 -0
- package/src/components/Count/index.js +30 -0
- package/src/components/DatePicker/index.js +213 -0
- package/src/components/DatePicker/reducer.js +27 -0
- package/src/components/DatePicker/tests/__snapshots__/index.test.js.snap +301 -0
- package/src/components/DatePicker/tests/index.test.js +111 -0
- package/src/components/Enumeration/index.js +71 -0
- package/src/components/Enumeration/tests/index.test.js +41 -0
- package/src/components/Error/index.js +118 -0
- package/src/components/Error/reducer.js +14 -0
- package/src/components/Flex/index.js +25 -0
- package/src/components/Flex/tests/__snapshots__/index.test.js.snap +28 -0
- package/src/components/Flex/tests/index.test.js +11 -0
- package/src/components/HeaderActions/index.js +52 -0
- package/src/components/HeaderActions/tests/index.test.js +15 -0
- package/src/components/HeaderTitle/index.js +59 -0
- package/src/components/HeaderTitle/tests/index.test.js +15 -0
- package/src/components/Icon/index.js +50 -0
- package/src/components/Icon/tests/Icon.test.js +33 -0
- package/src/components/IconLinks/index.js +39 -0
- package/src/components/IconLinks/tests/index.test.js +27 -0
- package/src/components/InputNumber/index.js +74 -0
- package/src/components/InputText/PrefixIcon.js +38 -0
- package/src/components/InputText/index.js +88 -0
- package/src/components/Label/index.js +53 -0
- package/src/components/Label/tests/Label.test.js +38 -0
- package/src/components/List/index.js +56 -0
- package/src/components/List/tests/index.test.js +19 -0
- package/src/components/ListHeader/BaselineAlignement.js +7 -0
- package/src/components/ListHeader/index.js +58 -0
- package/src/components/ListHeader/tests/index.test.js +11 -0
- package/src/components/ListRow/index.js +34 -0
- package/src/components/ListRow/tests/index.tests.js +32 -0
- package/src/components/NavTabs/index.js +51 -0
- package/src/components/Option/RemoveButton.js +18 -0
- package/src/components/Option/index.js +32 -0
- package/src/components/Padded/index.js +47 -0
- package/src/components/Padded/tests/__snapshots__/index.test.js.snap +8 -0
- package/src/components/Padded/tests/index.test.js +11 -0
- package/src/components/Paging/index.js +66 -0
- package/src/components/Picker/PickerButton.js +84 -0
- package/src/components/Picker/PickerSection.js +41 -0
- package/src/components/Picker/PickerWrapper.js +7 -0
- package/src/components/Picker/index.js +44 -0
- package/src/components/Picker/tests/__snapshots__/pickerButton.test.js.snap +54 -0
- package/src/components/Picker/tests/__snapshots__/pickerSection.test.js.snap +20 -0
- package/src/components/Picker/tests/pickerButton.test.js +11 -0
- package/src/components/Picker/tests/pickerSection.test.js +11 -0
- package/src/components/PrefixIcon/index.js +11 -0
- package/src/components/Select/index.js +110 -0
- package/src/components/Select/tests/index.test.js +85 -0
- package/src/components/Separator/index.js +49 -0
- package/src/components/Table/ActionCollapse.js +53 -0
- package/src/components/Table/index.js +172 -0
- package/src/components/Table/tests/index.js +146 -0
- package/src/components/TableHeader/index.js +103 -0
- package/src/components/TableHeader/tests/index.test.js +85 -0
- package/src/components/TableRow/index.js +116 -0
- package/src/components/TableRow/tests/index.test.js +89 -0
- package/src/components/Text/index.js +62 -0
- package/src/components/Text/tests/__snapshots__/index.test.js.snap +19 -0
- package/src/components/Text/tests/index.test.js +11 -0
- package/src/components/Textarea/index.js +19 -0
- package/src/components/Textarea/tests/index.test.js +23 -0
- package/src/components/TimePicker/index.js +328 -0
- package/src/components/TimePicker/tests/index.test.js +95 -0
- package/src/components/Toggle/index.js +83 -0
- package/src/components/Toggle/tests/index.test.js +40 -0
- package/src/components/UnknownInput/index.js +20 -0
- package/src/index.js +33 -0
- package/src/theme/colors.js +48 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* InputText
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import {
|
|
10
|
+
IconWrapper,
|
|
11
|
+
InputText as Input,
|
|
12
|
+
InputWrapper,
|
|
13
|
+
} from '@punch-in/buffet-modern';
|
|
14
|
+
import Icon from '../Icon';
|
|
15
|
+
import PrefixIcon from './PrefixIcon';
|
|
16
|
+
|
|
17
|
+
function InputText({
|
|
18
|
+
autoFocus,
|
|
19
|
+
className,
|
|
20
|
+
icon,
|
|
21
|
+
id,
|
|
22
|
+
name,
|
|
23
|
+
onChange,
|
|
24
|
+
tabIndex,
|
|
25
|
+
type,
|
|
26
|
+
value,
|
|
27
|
+
...rest
|
|
28
|
+
}) {
|
|
29
|
+
const [showPassword, togglePassword] = useState(false);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<InputWrapper className={className}>
|
|
33
|
+
<PrefixIcon icon={icon} type={type} />
|
|
34
|
+
{type === 'password' && (
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
onClick={() => togglePassword(!showPassword)}
|
|
38
|
+
className={showPassword ? 'shown' : ''}
|
|
39
|
+
tabIndex="-1"
|
|
40
|
+
>
|
|
41
|
+
<IconWrapper background={false}>
|
|
42
|
+
<Icon icon={type} />
|
|
43
|
+
</IconWrapper>
|
|
44
|
+
</button>
|
|
45
|
+
)}
|
|
46
|
+
<Input
|
|
47
|
+
autoFocus={autoFocus}
|
|
48
|
+
id={id || name}
|
|
49
|
+
name={name}
|
|
50
|
+
onChange={onChange}
|
|
51
|
+
tabIndex={tabIndex}
|
|
52
|
+
type={showPassword ? 'text' : type}
|
|
53
|
+
value={value}
|
|
54
|
+
icon={icon}
|
|
55
|
+
{...rest}
|
|
56
|
+
/>
|
|
57
|
+
</InputWrapper>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
InputText.defaultProps = {
|
|
62
|
+
autoComplete: 'off',
|
|
63
|
+
autoFocus: false,
|
|
64
|
+
className: null,
|
|
65
|
+
icon: null,
|
|
66
|
+
id: null,
|
|
67
|
+
onChange: () => {},
|
|
68
|
+
placeholder: null,
|
|
69
|
+
tabIndex: '0',
|
|
70
|
+
type: 'text',
|
|
71
|
+
value: '',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
InputText.propTypes = {
|
|
75
|
+
autoComplete: PropTypes.string,
|
|
76
|
+
autoFocus: PropTypes.bool,
|
|
77
|
+
className: PropTypes.string,
|
|
78
|
+
icon: PropTypes.node,
|
|
79
|
+
id: PropTypes.string,
|
|
80
|
+
name: PropTypes.string.isRequired,
|
|
81
|
+
onChange: PropTypes.func,
|
|
82
|
+
placeholder: PropTypes.string,
|
|
83
|
+
tabIndex: PropTypes.string,
|
|
84
|
+
type: PropTypes.string,
|
|
85
|
+
value: PropTypes.string,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default InputText;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Label
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { isFunction } from 'lodash';
|
|
10
|
+
|
|
11
|
+
import { Label as StyledLabel } from '@punch-in/buffet-modern';
|
|
12
|
+
|
|
13
|
+
function Label(props) {
|
|
14
|
+
const content = (() => {
|
|
15
|
+
if (isFunction(props.message)) {
|
|
16
|
+
return props.message();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (props.message) {
|
|
20
|
+
return props.message;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return props.children;
|
|
24
|
+
})();
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<StyledLabel htmlFor={props.htmlFor} className={props.className}>
|
|
28
|
+
{content}
|
|
29
|
+
</StyledLabel>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Label.defaultProps = {
|
|
34
|
+
children: null,
|
|
35
|
+
className: null,
|
|
36
|
+
message: null,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Label.propTypes = {
|
|
40
|
+
children: PropTypes.node,
|
|
41
|
+
className: PropTypes.string,
|
|
42
|
+
htmlFor: PropTypes.string.isRequired,
|
|
43
|
+
message: PropTypes.oneOfType([
|
|
44
|
+
PropTypes.func,
|
|
45
|
+
PropTypes.string,
|
|
46
|
+
PropTypes.shape({
|
|
47
|
+
id: PropTypes.string,
|
|
48
|
+
params: PropTypes.object,
|
|
49
|
+
}),
|
|
50
|
+
]),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default Label;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
|
|
4
|
+
import { isFunction } from 'lodash';
|
|
5
|
+
import Label from '../index';
|
|
6
|
+
|
|
7
|
+
let renderedComponent;
|
|
8
|
+
const renderComponent = (props = {}) => mount(<Label {...props} />);
|
|
9
|
+
|
|
10
|
+
describe('<Label />', () => {
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
renderedComponent.unmount();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('render the <Label /> with htmlFor props', () => {
|
|
16
|
+
renderedComponent = renderComponent({ htmlFor: 'inputName' });
|
|
17
|
+
expect(renderedComponent.at(0).prop('htmlFor')).toBe('inputName');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('render the <Label /> with message props as a String', () => {
|
|
21
|
+
renderedComponent = renderComponent({
|
|
22
|
+
htmlFor: 'inputName',
|
|
23
|
+
message: 'text',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
expect(renderedComponent.prop('message')).toEqual('text');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('render the <Label /> with message props as a function', () => {
|
|
30
|
+
const messageFunc = () => 'text';
|
|
31
|
+
renderedComponent = renderComponent({
|
|
32
|
+
htmlFor: 'inputName',
|
|
33
|
+
message: messageFunc,
|
|
34
|
+
});
|
|
35
|
+
expect(isFunction(renderedComponent.prop('message'))).toBe(true);
|
|
36
|
+
expect(renderedComponent.prop('message')).toEqual(messageFunc);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* List
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { List as StyledList, LoadingIndicator } from '@punch-in/buffet-modern';
|
|
10
|
+
|
|
11
|
+
import ListRow from '../ListRow';
|
|
12
|
+
import Padded from '../Padded';
|
|
13
|
+
|
|
14
|
+
function List({ className, items, isLoading, customRowComponent }) {
|
|
15
|
+
return (
|
|
16
|
+
<StyledList className={className}>
|
|
17
|
+
{isLoading ? (
|
|
18
|
+
<Padded top bottom size="md">
|
|
19
|
+
<LoadingIndicator />
|
|
20
|
+
</Padded>
|
|
21
|
+
) : (
|
|
22
|
+
<table>
|
|
23
|
+
<tbody>
|
|
24
|
+
{items.map((item, index) =>
|
|
25
|
+
customRowComponent ? (
|
|
26
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
27
|
+
<React.Fragment key={index}>
|
|
28
|
+
{customRowComponent(item)}
|
|
29
|
+
</React.Fragment>
|
|
30
|
+
) : (
|
|
31
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
32
|
+
<ListRow cells={item} key={index} />
|
|
33
|
+
)
|
|
34
|
+
)}
|
|
35
|
+
</tbody>
|
|
36
|
+
</table>
|
|
37
|
+
)}
|
|
38
|
+
</StyledList>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
List.defaultProps = {
|
|
43
|
+
className: null,
|
|
44
|
+
customRowComponent: null,
|
|
45
|
+
isLoading: false,
|
|
46
|
+
items: [],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
List.propTypes = {
|
|
50
|
+
className: PropTypes.string,
|
|
51
|
+
customRowComponent: PropTypes.func,
|
|
52
|
+
isLoading: PropTypes.bool,
|
|
53
|
+
items: PropTypes.instanceOf(Array),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default List;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
|
|
4
|
+
import List from '../index';
|
|
5
|
+
|
|
6
|
+
describe('<List />', () => {
|
|
7
|
+
// eslint-disable-next-line jest/expect-expect
|
|
8
|
+
it('Should not crash', () => {
|
|
9
|
+
mount(<List />);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('Should use a custom row if provided', () => {
|
|
13
|
+
const items = [{ test: 'test' }];
|
|
14
|
+
const customRowComponent = jest.fn();
|
|
15
|
+
mount(<List items={items} customRowComponent={customRowComponent} />);
|
|
16
|
+
|
|
17
|
+
expect(customRowComponent).toHaveBeenCalledWith(items[0]);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* ListHeader
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { ListHeader as StyledListHeader } from '@punch-in/buffet-modern';
|
|
10
|
+
import Button from '../Button';
|
|
11
|
+
import Flex from '../Flex';
|
|
12
|
+
import Padded from '../Padded';
|
|
13
|
+
import Text from '../Text';
|
|
14
|
+
import BaselineAlignement from './BaselineAlignement';
|
|
15
|
+
|
|
16
|
+
function ListHeader({ button, title, subtitle }) {
|
|
17
|
+
return (
|
|
18
|
+
<StyledListHeader>
|
|
19
|
+
<Flex justifyContent="space-between">
|
|
20
|
+
<Padded top bottom size="smd">
|
|
21
|
+
<Text fontSize="lg" fontWeight="bold" lineHeight="18px">
|
|
22
|
+
{title}
|
|
23
|
+
</Text>
|
|
24
|
+
{subtitle && (
|
|
25
|
+
<Padded top size="xs">
|
|
26
|
+
<Text fontSize="md" color="grey" lineHeight="13px">
|
|
27
|
+
{subtitle}
|
|
28
|
+
</Text>
|
|
29
|
+
</Padded>
|
|
30
|
+
)}
|
|
31
|
+
</Padded>
|
|
32
|
+
{button && (
|
|
33
|
+
<BaselineAlignement>
|
|
34
|
+
<Button {...button} />
|
|
35
|
+
</BaselineAlignement>
|
|
36
|
+
)}
|
|
37
|
+
</Flex>
|
|
38
|
+
</StyledListHeader>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ListHeader.defaultProps = {
|
|
43
|
+
button: null,
|
|
44
|
+
title: null,
|
|
45
|
+
subtitle: null,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
ListHeader.propTypes = {
|
|
49
|
+
button: PropTypes.shape({
|
|
50
|
+
color: PropTypes.string,
|
|
51
|
+
icon: PropTypes.bool,
|
|
52
|
+
type: PropTypes.string,
|
|
53
|
+
}),
|
|
54
|
+
subtitle: PropTypes.string,
|
|
55
|
+
title: PropTypes.string,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default ListHeader;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
|
|
4
|
+
import ListHeader from '../index';
|
|
5
|
+
|
|
6
|
+
describe('<ListHeader />', () => {
|
|
7
|
+
// eslint-disable-next-line jest/expect-expect
|
|
8
|
+
it('Should not crash', () => {
|
|
9
|
+
mount(<ListHeader />);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* ListRow
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
|
|
10
|
+
import { ListRow as StyledListRow } from '@punch-in/buffet-modern';
|
|
11
|
+
|
|
12
|
+
function ListRow({ cells, onClick }) {
|
|
13
|
+
return (
|
|
14
|
+
<StyledListRow onClick={onClick}>
|
|
15
|
+
{Object.keys(cells).map(key => (
|
|
16
|
+
<td key={key} className={`${key}-cell`}>
|
|
17
|
+
<p>{cells[key]}</p>
|
|
18
|
+
</td>
|
|
19
|
+
))}
|
|
20
|
+
</StyledListRow>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ListRow.defaultProps = {
|
|
25
|
+
cells: {},
|
|
26
|
+
onClick: () => {},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
ListRow.propTypes = {
|
|
30
|
+
cells: PropTypes.instanceOf(Object),
|
|
31
|
+
onClick: PropTypes.func,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default ListRow;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
|
|
4
|
+
import ListRow from '../index';
|
|
5
|
+
|
|
6
|
+
describe('<ListRow />', () => {
|
|
7
|
+
// eslint-disable-next-line jest/expect-expect
|
|
8
|
+
it('Should not crash', () => {
|
|
9
|
+
mount(
|
|
10
|
+
<table>
|
|
11
|
+
<tbody>
|
|
12
|
+
<ListRow />
|
|
13
|
+
</tbody>
|
|
14
|
+
</table>
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should display some cells', () => {
|
|
19
|
+
const cells = { name: 'name', test: 'test' };
|
|
20
|
+
const renderedComponent = mount(
|
|
21
|
+
<table>
|
|
22
|
+
<tbody>
|
|
23
|
+
<ListRow cells={cells} />
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
);
|
|
27
|
+
const tds = renderedComponent.find('td');
|
|
28
|
+
|
|
29
|
+
expect(tds.at(0).text()).toBe('name');
|
|
30
|
+
expect(tds.at(1).text()).toBe('test');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* NavTabs
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { NavLink } from 'react-router-dom';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { Tab as StyledTab, colors } from '@punch-in/buffet-modern';
|
|
11
|
+
import { gradient } from '@punch-in/buffet-modern-utils';
|
|
12
|
+
|
|
13
|
+
function NavTabs({ links }) {
|
|
14
|
+
let color = colors.greyLink;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<ul>
|
|
18
|
+
{links.map((link, index) => {
|
|
19
|
+
color = gradient(color, 1.5);
|
|
20
|
+
const content = link.label ? <p>{link.label}</p> : link.compo || null;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<StyledTab
|
|
24
|
+
key={link.to}
|
|
25
|
+
index={index}
|
|
26
|
+
count={links.length}
|
|
27
|
+
background={color}
|
|
28
|
+
>
|
|
29
|
+
<NavLink to={link.to}>{content}</NavLink>
|
|
30
|
+
</StyledTab>
|
|
31
|
+
);
|
|
32
|
+
})}
|
|
33
|
+
</ul>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
NavTabs.defaultProps = {
|
|
38
|
+
links: [],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
NavTabs.propTypes = {
|
|
42
|
+
links: PropTypes.arrayOf(
|
|
43
|
+
PropTypes.shape({
|
|
44
|
+
compo: PropTypes.node,
|
|
45
|
+
label: PropTypes.string,
|
|
46
|
+
to: PropTypes.string,
|
|
47
|
+
})
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default NavTabs;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const RemoveButton = styled.button`
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-items: center;
|
|
6
|
+
height: 13px;
|
|
7
|
+
padding-left: 10px;
|
|
8
|
+
padding-right: 10px;
|
|
9
|
+
margin-left: 10px;
|
|
10
|
+
background-color: transparent;
|
|
11
|
+
border: 0;
|
|
12
|
+
border-left: 1px solid rgba(0, 126, 255, 0.1);
|
|
13
|
+
&:focus {
|
|
14
|
+
outline: 0;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
export default RemoveButton;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Remove } from '@punch-in/buffet-modern-icons';
|
|
4
|
+
import { Option as Wrapper } from '@punch-in/buffet-modern';
|
|
5
|
+
import { upperFirst } from 'lodash';
|
|
6
|
+
import RemoveButton from './RemoveButton';
|
|
7
|
+
|
|
8
|
+
function Filter({ label, onClick, ...rest }) {
|
|
9
|
+
const content =
|
|
10
|
+
typeof label === 'string' ? <span>{upperFirst(label)}</span> : label;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Wrapper {...rest}>
|
|
14
|
+
{content}
|
|
15
|
+
<RemoveButton type="button" onClick={onClick}>
|
|
16
|
+
<Remove width="11px" height="11px" fill="#007eff" />
|
|
17
|
+
</RemoveButton>
|
|
18
|
+
</Wrapper>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Filter.defaultProps = {
|
|
23
|
+
label: '',
|
|
24
|
+
onClick: () => {},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Filter.propTypes = {
|
|
28
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
29
|
+
onClick: PropTypes.func,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default Filter;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
const Padded = styled.div`
|
|
5
|
+
padding-top: ${({ theme, size, top }) =>
|
|
6
|
+
top && (theme.main.sizes.paddings[size] || size)};
|
|
7
|
+
padding-right: ${({ theme, size, right }) =>
|
|
8
|
+
right && (theme.main.sizes.paddings[size] || size)};
|
|
9
|
+
padding-bottom: ${({ theme, size, bottom }) =>
|
|
10
|
+
bottom && (theme.main.sizes.paddings[size] || size)};
|
|
11
|
+
padding-left: ${({ theme, size, left }) =>
|
|
12
|
+
left && (theme.main.sizes.paddings[size] || size)};
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
Padded.defaultProps = {
|
|
16
|
+
bottom: false,
|
|
17
|
+
left: false,
|
|
18
|
+
right: false,
|
|
19
|
+
size: 'sm',
|
|
20
|
+
top: false,
|
|
21
|
+
// TODO : This is temporary
|
|
22
|
+
theme: {
|
|
23
|
+
main: {
|
|
24
|
+
sizes: {
|
|
25
|
+
paddings: {
|
|
26
|
+
xs: '5px',
|
|
27
|
+
sm: '10px',
|
|
28
|
+
smd: '20px',
|
|
29
|
+
md: '30px',
|
|
30
|
+
lg: '40px',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Padded.propTypes = {
|
|
38
|
+
bottom: PropTypes.bool,
|
|
39
|
+
left: PropTypes.bool,
|
|
40
|
+
right: PropTypes.bool,
|
|
41
|
+
size: PropTypes.string,
|
|
42
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
43
|
+
theme: PropTypes.object,
|
|
44
|
+
top: PropTypes.bool,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default Padded;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
3
|
+
import Padded from '../index';
|
|
4
|
+
|
|
5
|
+
describe('<Padded />', () => {
|
|
6
|
+
it('should match snapshot', () => {
|
|
7
|
+
const tree = renderer.create(<Padded />).toJSON();
|
|
8
|
+
|
|
9
|
+
expect(tree).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Paging
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { Pagination, PaginationItem, PaginationLink } from 'reactstrap';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
|
|
11
|
+
import { Paging as StyledPaging } from '@punch-in/buffet-modern';
|
|
12
|
+
import Icon from '../Icon';
|
|
13
|
+
/* eslint-disable react/no-array-index-key */
|
|
14
|
+
|
|
15
|
+
function Paging({ count, page, onChange, range }) {
|
|
16
|
+
const pagesCount = Math.ceil(count / range);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<StyledPaging />
|
|
21
|
+
<Pagination aria-label="Page navigation">
|
|
22
|
+
<PaginationItem>
|
|
23
|
+
<PaginationLink onClick={onChange} value={0}>
|
|
24
|
+
<Icon icon="left" />
|
|
25
|
+
</PaginationLink>
|
|
26
|
+
</PaginationItem>
|
|
27
|
+
{Array(pagesCount)
|
|
28
|
+
.fill(1)
|
|
29
|
+
.map((item, index) => (
|
|
30
|
+
<React.Fragment key={index}>
|
|
31
|
+
<PaginationItem
|
|
32
|
+
key={index}
|
|
33
|
+
onClick={onChange}
|
|
34
|
+
className={page === index * range ? 'selected' : ''}
|
|
35
|
+
>
|
|
36
|
+
<PaginationLink onClick={onChange} value={index * range}>
|
|
37
|
+
{index + 1}
|
|
38
|
+
</PaginationLink>
|
|
39
|
+
</PaginationItem>
|
|
40
|
+
</React.Fragment>
|
|
41
|
+
))}
|
|
42
|
+
<PaginationItem>
|
|
43
|
+
<PaginationLink onClick={onChange} value={(pagesCount - 1) * range}>
|
|
44
|
+
<Icon icon="right" />
|
|
45
|
+
</PaginationLink>
|
|
46
|
+
</PaginationItem>
|
|
47
|
+
</Pagination>
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Paging.defaultProps = {
|
|
53
|
+
count: 0,
|
|
54
|
+
onChange: () => {},
|
|
55
|
+
page: 0,
|
|
56
|
+
range: 15,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Paging.propTypes = {
|
|
60
|
+
count: PropTypes.number,
|
|
61
|
+
onChange: PropTypes.func,
|
|
62
|
+
page: PropTypes.number,
|
|
63
|
+
range: PropTypes.number,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default Paging;
|