@autobusal/common 1.0.6 → 1.0.7
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/Viewer/Data.tsx +1 -1
- package/Viewer/Items/TextareaHtml.tsx +1 -0
- package/Viewer/Loading.tsx +14 -0
- package/Viewer/Viewer.tsx +7 -1
- package/package.json +1 -1
package/Viewer/Data.tsx
CHANGED
|
@@ -32,7 +32,7 @@ const Data = ({ id, item, refs, t, onUpdate }: Props): (JSX.Element | null) => {
|
|
|
32
32
|
|
|
33
33
|
switch (item.type) {
|
|
34
34
|
case 'checkbox':
|
|
35
|
-
return <input type="checkbox" value={ 1 } defaultChecked={ Number(item.value)
|
|
35
|
+
return <input type="checkbox" value={ 1 } defaultChecked={ Number(item.value) === 1 } { ...refs(item.name, Validate(String(item.rules), t)) } />;
|
|
36
36
|
|
|
37
37
|
case 'checkbox-list':
|
|
38
38
|
case 'checkbox-list-all':
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
2
|
+
import { Inline } from '../Loading/Loading';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
t: TFunction<'common'>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Loading = ({ t }: Props): JSX.Element => (
|
|
9
|
+
<div className="box">
|
|
10
|
+
<Inline text={ t('table.loading_data', { ns: 'common' }) } />
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export default Loading;
|
package/Viewer/Viewer.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useForm } from 'react-hook-form';
|
|
2
2
|
import { TFunction } from 'i18next';
|
|
3
|
+
import Loading from './Loading';
|
|
3
4
|
import Item from './Item';
|
|
4
5
|
import Actions from './Actions';
|
|
5
6
|
import { Container } from './styles';
|
|
@@ -9,6 +10,7 @@ interface Props {
|
|
|
9
10
|
id: number
|
|
10
11
|
type?: 'simple'
|
|
11
12
|
data: ViewData[]
|
|
13
|
+
fetching?: boolean
|
|
12
14
|
pending?: boolean
|
|
13
15
|
actions?: string[]
|
|
14
16
|
t: TFunction<'common'>
|
|
@@ -16,8 +18,12 @@ interface Props {
|
|
|
16
18
|
onDelete?: (data?: any) => void
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const Viewer = ({ id, type, data, pending, actions, t, onSave, onDelete }: Props): JSX.Element => {
|
|
21
|
+
const Viewer = ({ id, type, data, fetching, pending, actions, t, onSave, onDelete }: Props): JSX.Element => {
|
|
20
22
|
const { register, handleSubmit, formState: { errors }, setValue } = useForm<any>();
|
|
23
|
+
|
|
24
|
+
if (fetching) {
|
|
25
|
+
return <Loading t={ t } />;
|
|
26
|
+
}
|
|
21
27
|
|
|
22
28
|
const items = data.map((item, index) => (
|
|
23
29
|
<Item
|