@autobusal/common 0.0.40 → 0.0.41
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/ApiDetails/ApiDetails.tsx +50 -0
- package/ApiDetails/Content.tsx +44 -0
- package/ApiDetails/Devpos.tsx +139 -0
- package/ApiDetails/services.ts +38 -0
- package/ApiDetails/types.ts +13 -0
- package/Avatar.tsx +28 -0
- package/BackTo.tsx +28 -4
- package/ContactInfo/ContactInfo.tsx +40 -0
- package/ContactInfo/styles.ts +33 -0
- package/File/File.tsx +7 -3
- package/IpLogs/IpLogs.tsx +47 -0
- package/IpLogs/View.tsx +48 -0
- package/IpLogs/services.ts +27 -0
- package/IpLogs/styles.ts +10 -0
- package/Loading/Loading.tsx +29 -14
- package/Loading/styles.ts +9 -0
- package/Modal/Modal.tsx +3 -2
- package/Pagination/Pagination.tsx +2 -1
- package/Password/Password.tsx +3 -2
- package/Report/Report.tsx +39 -0
- package/Report/Send.tsx +55 -0
- package/Report/services.ts +18 -0
- package/Report/styles.ts +31 -0
- package/Seats/ChooseSeat.tsx +1 -1
- package/Seats/Preview.tsx +2 -2
- package/Seats/styles.ts +1 -43
- package/Table/Actions/Actions.tsx +40 -0
- package/Table/Actions/Get.tsx +49 -0
- package/Table/Actions/Icon.tsx +54 -0
- package/Table/Actions/styles.ts +22 -0
- package/Table/Header/Header.tsx +46 -0
- package/Table/Header/Sort.tsx +33 -0
- package/Table/Header/styles.ts +48 -0
- package/Table/Paginate.tsx +34 -0
- package/Table/Row.tsx +20 -0
- package/Table/Rows/Loading.tsx +22 -0
- package/Table/Rows/NotFound.tsx +22 -0
- package/Table/Rows/Rows.tsx +62 -0
- package/Table/Rows/styles.ts +31 -0
- package/Table/Table.tsx +74 -0
- package/Table/Top/Search.tsx +36 -0
- package/Table/Top/Top.tsx +44 -0
- package/Table/Top/styles.ts +32 -0
- package/Table/browseUrl.ts +21 -0
- package/Table/styles.ts +28 -0
- package/Table/types.ts +11 -0
- package/Viewer/Actions.tsx +58 -50
- package/Viewer/Data.tsx +71 -6
- package/Viewer/Item.tsx +8 -79
- package/Viewer/Items/CheckboxList.tsx +53 -30
- package/Viewer/Items/DatePicker.tsx +70 -0
- package/Viewer/Items/Dropdown.tsx +12 -6
- package/Viewer/Items/Linked.tsx +27 -0
- package/Viewer/Items/TextareaHtml.tsx +51 -24
- package/Viewer/Items/styles.ts +73 -0
- package/Viewer/Viewer.tsx +22 -15
- package/Viewer/styles.ts +21 -1
- package/Viewer/types.ts +11 -8
- package/index.ts +18 -2
- package/package.json +1 -1
- package/Pagination/types.ts +0 -12
package/Viewer/Item.tsx
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { FieldErrors, UseFormRegister, UseFormSetValue } from 'react-hook-form';
|
|
2
2
|
import { display } from '@autobusal/utilities';
|
|
3
3
|
import Data from './Data';
|
|
4
|
+
import { Notice } from './styles';
|
|
4
5
|
import { ViewData } from './types';
|
|
5
6
|
import { TFunction } from 'i18next';
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
9
|
+
id: number
|
|
8
10
|
data: ViewData
|
|
9
11
|
refs: UseFormRegister<any>
|
|
10
12
|
t: TFunction<'common'>
|
|
@@ -12,11 +14,12 @@ interface Props {
|
|
|
12
14
|
onUpdate: UseFormSetValue<any>
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
const Item = ({ data, refs, t, errors, onUpdate }: Props): JSX.Element => (
|
|
16
|
-
<div className={ `row ${ data.label === undefined && 'spacer' }` }>
|
|
17
|
+
const Item = ({ id, data, refs, t, errors, onUpdate }: Props): JSX.Element => (
|
|
18
|
+
<div className={ `row row-${ data.type } ${ data.label === undefined && 'spacer' }` }>
|
|
17
19
|
{ data.label }
|
|
18
20
|
|
|
19
21
|
<Data
|
|
22
|
+
id={ id }
|
|
20
23
|
item={ data }
|
|
21
24
|
refs={ refs }
|
|
22
25
|
t={ t }
|
|
@@ -24,83 +27,9 @@ const Item = ({ data, refs, t, errors, onUpdate }: Props): JSX.Element => (
|
|
|
24
27
|
/>
|
|
25
28
|
|
|
26
29
|
{ data.name && display(errors[data.name]) }
|
|
30
|
+
|
|
31
|
+
{ data.notice && <Notice>* { data.notice }</Notice> }
|
|
27
32
|
</div>
|
|
28
33
|
);
|
|
29
34
|
|
|
30
|
-
export default Item;
|
|
31
|
-
|
|
32
|
-
// function Input({ data, refs, onUpdate, errors, t }) {
|
|
33
|
-
// let input;
|
|
34
|
-
|
|
35
|
-
// switch (data.type) {
|
|
36
|
-
// case 'display':
|
|
37
|
-
// input = <div className="display">{ data.value }</div>;
|
|
38
|
-
// break;
|
|
39
|
-
|
|
40
|
-
// case 'email':
|
|
41
|
-
// input = <input type="email" defaultValue={ data.value } { ...refs(data.name, data.validation) } />;
|
|
42
|
-
// break;
|
|
43
|
-
|
|
44
|
-
// case 'number':
|
|
45
|
-
// input = <input type="number" defaultValue={ data.value } { ...refs(data.name, data.validation) } />
|
|
46
|
-
// break;
|
|
47
|
-
|
|
48
|
-
// case 'float':
|
|
49
|
-
// input = <input type="number" defaultValue={ data.value } { ...refs(data.name, data.validation) } step="0.01" />
|
|
50
|
-
// break;
|
|
51
|
-
|
|
52
|
-
// case 'checkbox':
|
|
53
|
-
// input = <input type="checkbox" value="1" defaultChecked={ data.value == 1 } { ...refs(data.name, data.validation) } />;
|
|
54
|
-
// break;
|
|
55
|
-
|
|
56
|
-
// case 'checkbox-list':
|
|
57
|
-
// input = <CheckboxList name={ data.name } values={ data.values } selected={ data.selected } hasAll={ data?.hasAll ?? true } refs={ refs } t={ t } />;
|
|
58
|
-
// break;
|
|
59
|
-
|
|
60
|
-
// case 'textarea-html':
|
|
61
|
-
// input = <TextareaHtml data={ data } onUpdate={ onUpdate } refs={ refs } />;
|
|
62
|
-
// break;
|
|
63
|
-
|
|
64
|
-
// case 'password':
|
|
65
|
-
// input = <Password refs={ refs(data.name, data.validation) } />
|
|
66
|
-
// break;
|
|
67
|
-
|
|
68
|
-
// case 'picker':
|
|
69
|
-
//
|
|
70
|
-
// case 'date':
|
|
71
|
-
// input = (
|
|
72
|
-
// <div className="display">
|
|
73
|
-
// <Calendar type={ data.type } name={ data.name } value={ data.value } refs={ refs } validation={ data.validation } t={ t } onUpdate={ onUpdate } />
|
|
74
|
-
// </div>
|
|
75
|
-
// );
|
|
76
|
-
// break;
|
|
77
|
-
|
|
78
|
-
// case 'extra':
|
|
79
|
-
// input = data.value;
|
|
80
|
-
// break;
|
|
81
|
-
// }
|
|
82
|
-
|
|
83
|
-
// let extra;
|
|
84
|
-
|
|
85
|
-
// switch (data.type) {
|
|
86
|
-
// case 'password':
|
|
87
|
-
// extra = ' item-password';
|
|
88
|
-
// break;
|
|
89
|
-
|
|
90
|
-
// case 'textarea-html':
|
|
91
|
-
// extra = ' full';
|
|
92
|
-
// break;
|
|
93
|
-
// }
|
|
94
|
-
|
|
95
|
-
// if (data.extra) {
|
|
96
|
-
// extra = ' ' + data.extra;
|
|
97
|
-
// }
|
|
98
|
-
|
|
99
|
-
// return (
|
|
100
|
-
// <div className={ `item${ extra ?? '' }` }>
|
|
101
|
-
// { input }
|
|
102
|
-
|
|
103
|
-
// { data.notice ? <div className="notice">* { data.notice }</div> : null }
|
|
104
|
-
// </div>
|
|
105
|
-
// );
|
|
106
|
-
// }
|
|
35
|
+
export default Item;
|
|
@@ -1,30 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { TFunction } from 'i18next';
|
|
3
|
+
import { UseFormRegister } from 'react-hook-form';
|
|
4
|
+
import { ContainerCheckboxList, ListLabel } from './styles';
|
|
5
|
+
import { DropdownData } from '@modules/Providers/types/other';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
name: string
|
|
9
|
+
values?: DropdownData[]
|
|
10
|
+
selected?: any[]
|
|
11
|
+
withAll: boolean
|
|
12
|
+
t: TFunction<'common'>
|
|
13
|
+
refs: UseFormRegister<any>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const CheckboxList = ({ name, values, selected, withAll, t, refs }: Props): JSX.Element => {
|
|
17
|
+
const [ all, setAll ] = useState(selected?.includes('all') ?? withAll);
|
|
18
|
+
|
|
19
|
+
const items = values?.map((item, index) => (
|
|
20
|
+
<ListLabel key={ index }>
|
|
21
|
+
<input
|
|
22
|
+
type="checkbox"
|
|
23
|
+
value={ item.id }
|
|
24
|
+
defaultChecked={ selected?.includes(String(item.id)) || selected?.includes(Number(item.id)) }
|
|
25
|
+
{ ...refs(`${ name }[${ (index + 1) }]`) }
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
{ item.name }
|
|
29
|
+
</ListLabel>
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<ContainerCheckboxList>
|
|
34
|
+
{ withAll && (
|
|
35
|
+
<ListLabel>
|
|
36
|
+
<input
|
|
37
|
+
type="checkbox"
|
|
38
|
+
value="all"
|
|
39
|
+
defaultChecked={ all }
|
|
40
|
+
onClick={ () => setAll(!all) }
|
|
41
|
+
{ ...refs(`${ name }[0]`) }
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
{ t('table.checkbox', { ns: 'common' }) }
|
|
45
|
+
</ListLabel>
|
|
46
|
+
) }
|
|
47
|
+
|
|
48
|
+
{ !all && items }
|
|
49
|
+
</ContainerCheckboxList>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default CheckboxList;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { TFunction } from 'i18next';
|
|
3
|
+
import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
|
|
4
|
+
import { Button } from '@autobusal/common';
|
|
5
|
+
import { FaCalendar } from 'react-icons/fa';
|
|
6
|
+
import Calendar from '../../Calendar/Calendar';
|
|
7
|
+
import { Picker, ContainerPicker, PickerClose } from './styles';
|
|
8
|
+
import { ViewData } from '../types';
|
|
9
|
+
import { RiCloseCircleFill } from 'react-icons/ri';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
item: ViewData
|
|
13
|
+
t: TFunction<'common'>
|
|
14
|
+
refs: UseFormRegister<any>
|
|
15
|
+
onUpdate: UseFormSetValue<any>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const DatePicker = ({ item, t, refs, onUpdate }: Props): JSX.Element => {
|
|
19
|
+
const value = item.value !== null && item.value !== undefined && item.value !== '' ? String(item.value) : undefined;
|
|
20
|
+
|
|
21
|
+
const [ choose, setChoose ] = useState<boolean>(value !== undefined);
|
|
22
|
+
|
|
23
|
+
if (!choose) {
|
|
24
|
+
return (
|
|
25
|
+
<Picker>
|
|
26
|
+
<Button
|
|
27
|
+
type="button"
|
|
28
|
+
subtype="secondary"
|
|
29
|
+
size="small"
|
|
30
|
+
text={
|
|
31
|
+
<>
|
|
32
|
+
<FaCalendar />
|
|
33
|
+
{ t('table.date-picker', { ns: 'common' }) }
|
|
34
|
+
</>
|
|
35
|
+
}
|
|
36
|
+
onClick={ () => setChoose(true) }
|
|
37
|
+
noMargin
|
|
38
|
+
/>
|
|
39
|
+
</Picker>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const name = item.name ?? '';
|
|
44
|
+
|
|
45
|
+
const onCancel = (): void => {
|
|
46
|
+
setChoose(false);
|
|
47
|
+
|
|
48
|
+
onUpdate(name, undefined);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ContainerPicker>
|
|
53
|
+
<Calendar
|
|
54
|
+
type="date"
|
|
55
|
+
name={ name }
|
|
56
|
+
defaultValue={ value }
|
|
57
|
+
t={ t }
|
|
58
|
+
validation={ item.rules }
|
|
59
|
+
refs={ refs }
|
|
60
|
+
onUpdate={ onUpdate }
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<PickerClose type="button" onClick={ onCancel }>
|
|
64
|
+
<RiCloseCircleFill />
|
|
65
|
+
</PickerClose>
|
|
66
|
+
</ContainerPicker>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default DatePicker;
|
|
@@ -14,6 +14,17 @@ const Dropdown = ({ item, refs, t }: Props): (JSX.Element | null) => {
|
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
if (typeof item.value !== 'string' && typeof item.value !== 'number' && typeof item.value !== 'undefined') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const rules = validate(String(item.rules), t);
|
|
22
|
+
|
|
23
|
+
// we listen for the change
|
|
24
|
+
if (item.onChange !== undefined) {
|
|
25
|
+
rules.onChange = (event: React.EventHandler<any>) => item.onChange(event.target.value);
|
|
26
|
+
}
|
|
27
|
+
|
|
17
28
|
const values = item.values?.map((item, index) => (
|
|
18
29
|
<option
|
|
19
30
|
key={ index }
|
|
@@ -23,14 +34,9 @@ const Dropdown = ({ item, refs, t }: Props): (JSX.Element | null) => {
|
|
|
23
34
|
{ item.name }
|
|
24
35
|
</option>
|
|
25
36
|
));
|
|
26
|
-
|
|
27
|
-
// // add a custom onchange listener
|
|
28
|
-
// if (item.onChange) {
|
|
29
|
-
// item.validation.onChange = (e) => data.onChange(e.target.value);
|
|
30
|
-
// }
|
|
31
37
|
|
|
32
38
|
return (
|
|
33
|
-
<select defaultValue={ item
|
|
39
|
+
<select defaultValue={ item?.value } { ...refs(item.name, rules) }>
|
|
34
40
|
{ values }
|
|
35
41
|
</select>
|
|
36
42
|
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ContainerLink, LinkMore } from './styles';
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
id: number
|
|
5
|
+
value?: JSX.Element | string | number
|
|
6
|
+
url?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Linked = ({ id, value, url }: Props): JSX.Element => {
|
|
10
|
+
if (id === 0) {
|
|
11
|
+
return (
|
|
12
|
+
<div className="row-data">
|
|
13
|
+
<ContainerLink>-</ContainerLink>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="row-data">
|
|
20
|
+
<ContainerLink>
|
|
21
|
+
<LinkMore to={ url ?? '' }>{ value }</LinkMore>
|
|
22
|
+
</ContainerLink>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default Linked;
|
|
@@ -1,29 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { TFunction } from 'i18next';
|
|
3
|
+
import { UseFormRegister, UseFormSetValue } from 'react-hook-form';
|
|
4
|
+
import { Editor } from '@tinymce/tinymce-react';
|
|
5
|
+
import { Editor as TinyMceEditor } from 'tinymce';
|
|
6
|
+
import { validate } from '@modules/Utilities/form';
|
|
7
|
+
import { Textarea } from './styles';
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
interface Props {
|
|
10
|
+
name: string
|
|
11
|
+
value?: string
|
|
12
|
+
validation?: string
|
|
13
|
+
t: TFunction<'common'>
|
|
14
|
+
refs: UseFormRegister<any>
|
|
15
|
+
onUpdate: UseFormSetValue<any>
|
|
16
|
+
}
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// const content = htmlToDraft(html);
|
|
18
|
+
const TextareaHtml = ({ name, value, validation, t, refs, onUpdate }: Props): JSX.Element => {
|
|
19
|
+
const editorRef = useRef<TinyMceEditor | null>(null);
|
|
13
20
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
const onChange = (content: string): void => {
|
|
22
|
+
onUpdate(name, content);
|
|
23
|
+
};
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
return (
|
|
26
|
+
<div className="row-data">
|
|
27
|
+
<Editor
|
|
28
|
+
onInit={ (event, editor) => editorRef.current = editor }
|
|
29
|
+
onEditorChange={ onChange }
|
|
30
|
+
initialValue={ value ?? '' }
|
|
31
|
+
tinymceScriptSrc="/tinymce/tinymce.min.js"
|
|
32
|
+
init={{
|
|
33
|
+
height: 350,
|
|
34
|
+
menubar: false,
|
|
35
|
+
license_key: 'gpl',
|
|
36
|
+
plugins: [
|
|
37
|
+
'autolink', 'link', 'image', 'media', 'table', 'help', 'lists', 'charmap', 'advlist'
|
|
38
|
+
],
|
|
39
|
+
toolbar: (
|
|
40
|
+
'bold italic backcolor | alignleft aligncenter ' +
|
|
41
|
+
'alignright alignjustify | bullist numlist outdent indent | ' +
|
|
42
|
+
'image media table | ' +
|
|
43
|
+
'removeformat | help'
|
|
44
|
+
),
|
|
45
|
+
content_style: 'body { font-family: Helvetica, Arial, sans-serif; font-size: 14px; }',
|
|
46
|
+
promotion: false,
|
|
47
|
+
highlight_on_focus: false
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
22
50
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// }
|
|
51
|
+
<Textarea defaultValue={ value ?? '' } { ...refs(name, validate(String(validation), t)) }></Textarea>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default TextareaHtml;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Link } from 'react-router-dom';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const ContainerCheckboxList = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
gap: 3px;
|
|
9
|
+
min-height: 38px;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const ListLabel = styled.label`
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: 2px;
|
|
15
|
+
padding: 2px 6px 2px 4px;
|
|
16
|
+
font-size: ${ props => props.theme.size.xs };
|
|
17
|
+
background: ${ props => props.theme.background.neutral };
|
|
18
|
+
border-radius: ${ props => props.theme.borderRadius };
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const ContainerLink = styled.div`
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
min-height: 38px;
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const LinkMore = styled(Link)`
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: 6px;
|
|
31
|
+
height: 26px;
|
|
32
|
+
padding: 0 10px;
|
|
33
|
+
font-weight: 700;
|
|
34
|
+
font-size: calc(${ props => props.theme.size.xs } + 1px);
|
|
35
|
+
background: ${ props => props.theme.background.neutral };
|
|
36
|
+
border-radius: 100px;
|
|
37
|
+
transition: all 0.3s ease;
|
|
38
|
+
|
|
39
|
+
&:hover {
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
box-shadow: 0 4px 15px ${ props => props.theme.background.neutral };
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export const Textarea = styled.textarea`
|
|
46
|
+
display: none;
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export const Picker = styled.div`
|
|
50
|
+
display: flex;
|
|
51
|
+
height: 38px;
|
|
52
|
+
align-items: center;
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
export const ContainerPicker = styled.div`
|
|
56
|
+
position: relative;
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
export const PickerClose = styled.button`
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: 1px;
|
|
62
|
+
right: 1px;
|
|
63
|
+
width: 38px;
|
|
64
|
+
height: 36px;
|
|
65
|
+
display: flex;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
align-items: center;
|
|
68
|
+
font-size: ${ props => props.theme.size.xl };
|
|
69
|
+
background: ${ props => props.theme.inputs.background };
|
|
70
|
+
border-left: 1px solid ${ props => props.theme.inputs.border };
|
|
71
|
+
border-top-right-radius: ${ props => props.theme.borderRadius };
|
|
72
|
+
border-bottom-right-radius: ${ props => props.theme.borderRadius };
|
|
73
|
+
`;
|
package/Viewer/Viewer.tsx
CHANGED
|
@@ -6,24 +6,23 @@ import { Container } from './styles';
|
|
|
6
6
|
import { ViewData } from './types';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
|
+
id: number
|
|
10
|
+
type?: 'simple'
|
|
9
11
|
data: ViewData[]
|
|
10
12
|
loading?: boolean
|
|
11
13
|
actions?: string[]
|
|
12
14
|
t: TFunction<'common'>
|
|
13
|
-
onSave
|
|
15
|
+
onSave?: (data: any) => void
|
|
16
|
+
onDelete?: () => void
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
const Viewer = ({ data, loading, actions, t, onSave }: Props): JSX.Element => {
|
|
17
|
-
const { register, handleSubmit, formState: { errors }, setValue
|
|
18
|
-
|
|
19
|
-
// reset on id change
|
|
20
|
-
// useEffect(() => {
|
|
21
|
-
// reset();
|
|
22
|
-
// }, [id]);
|
|
19
|
+
const Viewer = ({ id, type, data, loading, actions, t, onSave, onDelete }: Props): JSX.Element => {
|
|
20
|
+
const { register, handleSubmit, formState: { errors }, setValue } = useForm<any>();
|
|
23
21
|
|
|
24
22
|
const items = data.map((item, index) => (
|
|
25
23
|
<Item
|
|
26
24
|
key={ index }
|
|
25
|
+
id={ id }
|
|
27
26
|
data={ item }
|
|
28
27
|
refs={ register }
|
|
29
28
|
t={ t }
|
|
@@ -33,14 +32,20 @@ const Viewer = ({ data, loading, actions, t, onSave }: Props): JSX.Element => {
|
|
|
33
32
|
));
|
|
34
33
|
|
|
35
34
|
const onSubmit = (data: any): void => {
|
|
36
|
-
onSave
|
|
35
|
+
if (onSave !== undefined) {
|
|
36
|
+
onSave(data);
|
|
37
|
+
}
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
|
|
40
|
+
if (type === 'simple') {
|
|
41
|
+
return (
|
|
42
|
+
<div className="box">
|
|
43
|
+
<Container>
|
|
44
|
+
{ items }
|
|
45
|
+
</Container>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
44
49
|
|
|
45
50
|
return (
|
|
46
51
|
<div className="box">
|
|
@@ -51,9 +56,11 @@ const Viewer = ({ data, loading, actions, t, onSave }: Props): JSX.Element => {
|
|
|
51
56
|
|
|
52
57
|
{ (actions !== undefined && actions.length > 0) && (
|
|
53
58
|
<Actions
|
|
59
|
+
id={ id }
|
|
54
60
|
available={ actions }
|
|
55
61
|
loading={ loading }
|
|
56
62
|
t={ t }
|
|
63
|
+
onDelete={ onDelete }
|
|
57
64
|
/>
|
|
58
65
|
) }
|
|
59
66
|
</form>
|
package/Viewer/styles.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
3
|
export const Container = styled.div`
|
|
4
|
-
|
|
4
|
+
& > div.row-checkbox {
|
|
5
|
+
flex-direction: row-reverse;
|
|
6
|
+
justify-content: left;
|
|
7
|
+
height: 20px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@media (min-width: 540px) {
|
|
5
11
|
display: flex;
|
|
6
12
|
flex-wrap: wrap;
|
|
7
13
|
gap: 20px;
|
|
@@ -31,8 +37,22 @@ export const Container = styled.div`
|
|
|
31
37
|
export const ContainerActions = styled.div`
|
|
32
38
|
display: flex;
|
|
33
39
|
justify-content: center;
|
|
40
|
+
gap: 10px;
|
|
34
41
|
margin-top: 25px;
|
|
35
42
|
padding: 15px 10px;
|
|
36
43
|
background: ${ props => props.theme.background.neutral };
|
|
37
44
|
border-radius: ${ props => props.theme.borderRadius };
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export const Display = styled.div`
|
|
48
|
+
min-height: 38px;
|
|
49
|
+
padding: 8px 10px;
|
|
50
|
+
background: ${ props => props.theme.background.neutral };
|
|
51
|
+
border-radius: ${ props => props.theme.borderRadius };
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
export const Notice = styled.div`
|
|
55
|
+
font-size: ${ props => props.theme.size.xxs };
|
|
56
|
+
color: ${ props => props.theme.font.info };
|
|
57
|
+
font-weight: 400;
|
|
38
58
|
`;
|
package/Viewer/types.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import { DropdownData } from '@modules/Providers/types/other';
|
|
2
|
+
|
|
1
3
|
export interface ViewData {
|
|
2
4
|
label?: string
|
|
3
5
|
name?: string
|
|
4
|
-
type?: 'text' | 'select' | 'dob' | 'textarea' | 'file'
|
|
5
|
-
value?: string | number
|
|
6
|
-
values?:
|
|
6
|
+
type?: 'text' | 'select' | 'date' | 'dob' | 'picker' | 'textarea' | 'textarea-html' | 'file' | 'files' | 'email' | 'password' | 'display' | 'component' | 'checkbox' | 'checkbox-list' | 'checkbox-list-all' | 'link' | 'number' | 'float' | 'date-picker'
|
|
7
|
+
value?: string | number | JSX.Element
|
|
8
|
+
values?: DropdownData[]
|
|
9
|
+
selected?: any[]
|
|
7
10
|
rules?: string
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
id: number
|
|
12
|
-
name: string
|
|
11
|
+
notice?: string
|
|
12
|
+
url?: string
|
|
13
|
+
onChange?: (id: 'string' | 'number') => void
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export interface ActionData {
|
|
16
17
|
label: string
|
|
17
18
|
icon: any
|
|
18
19
|
type?: 'submit'
|
|
20
|
+
subtype?: 'delete'
|
|
21
|
+
handler?: () => void
|
|
19
22
|
}
|