@gobolt/genesis 0.2.2 → 0.2.3
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/dist/components/Table/TableWithControls/useTableWithControls.d.ts +1 -4
- package/dist/components/Table/__mocks__/table-mocks.cjs +1 -1
- package/dist/components/Table/__mocks__/table-mocks.js +4 -4
- package/dist/components/Table/useTable.cjs +1 -1
- package/dist/components/Table/useTable.d.ts +3 -4
- package/dist/components/Table/useTable.js +41 -68
- package/package.json +1 -1
|
@@ -23,9 +23,6 @@ export declare const useTableWithControls: (tableConfig: UseTableConfig) => {
|
|
|
23
23
|
rowSelection: {
|
|
24
24
|
type: import('../Table').SelectionType;
|
|
25
25
|
onChange: (selectedRowKeys: React.Key[], selectedRows: Record<string, any>[]) => void;
|
|
26
|
-
getCheckboxProps: (record:
|
|
27
|
-
disabled: boolean;
|
|
28
|
-
name: any;
|
|
29
|
-
};
|
|
26
|
+
getCheckboxProps: (record: any) => unknown;
|
|
30
27
|
};
|
|
31
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),o=require("../../Badge/Badge.cjs"),a=e=>e&&e.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()),c=[{key:"number",title:"
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),o=require("../../Badge/Badge.cjs"),a=e=>e&&e.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()),c=[{key:"number",title:"Id",dataIndex:"number"},{key:"timeslot",title:"Timeslot",dataIndex:"timerange"},{key:"status",title:"Status",dataIndex:"status",render:e=>{const t={in_progress:"warning",scheduled:"generic",completed:"success"},r=e==="in_progress"?"in progress":e;return n.createElement(o,{label:a(r),state:t[e]})}},{key:"address",title:"Address",render:e=>{const{address:{nickname:t,address:r}}=e;return t?`${t} (${r})`:r}},{title:"Type",dataIndex:"job_subtype",render:e=>{const t={delivery:"info",pickup:"success"};return n.createElement(o,{label:a(e),state:t[e]})}}],s=c.map(e=>({...e}));s[1].sorter=!0;s[2].sorter=!0;s[4].sorter=!0;exports.mockColumns=c;exports.mockColumnsWithSort=s;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import a from "react";
|
|
2
2
|
import n from "../../Badge/Badge.js";
|
|
3
|
-
const o = (e) => e && e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()),
|
|
3
|
+
const o = (e) => e && e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()), d = [
|
|
4
4
|
{
|
|
5
5
|
key: "number",
|
|
6
|
-
title: "
|
|
6
|
+
title: "Id",
|
|
7
7
|
dataIndex: "number"
|
|
8
8
|
},
|
|
9
9
|
{
|
|
@@ -51,13 +51,13 @@ const o = (e) => e && e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUppe
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
], s =
|
|
54
|
+
], s = d.map((e) => ({
|
|
55
55
|
...e
|
|
56
56
|
}));
|
|
57
57
|
s[1].sorter = !0;
|
|
58
58
|
s[2].sorter = !0;
|
|
59
59
|
s[4].sorter = !0;
|
|
60
60
|
export {
|
|
61
|
-
|
|
61
|
+
d as mockColumns,
|
|
62
62
|
s as mockColumnsWithSort
|
|
63
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),m=a=>({disabled:!1,name:a.id}),T=a=>{const[i,u]=t.useState(!0),{columns:s,filters:d=null,fetchUrl:S="/table/data",fetchOptions:n={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)},selectionType:f="checkbox",simulateDelay:r=0,disableRowSelection:b=m}=a,[D,g]=t.useState([]),[h,c]=t.useState({dataSource:[],columns:[],error:null}),[y,p]=t.useState([]);t.useEffect(()=>{const o=async()=>{try{const l=(await(await fetch(S,n)).json()).data||[];g(l),c({dataSource:l,columns:s,error:null})}catch(e){console.error("Error fetching table data:",e),c({dataSource:[],columns:s,error:e instanceof Error?e:new Error(String(e))})}finally{u(!1)}};r>0?setTimeout(o,r):o()},[n]);const w=t.useCallback((o,e)=>{console.log("Row Selected:",o,e),p(e)},[]);return{...h,isLoading:i,rowSelection:{type:f,onChange:w,getCheckboxProps:b},selectedRows:y}};exports.useTable=T;
|
|
@@ -7,15 +7,14 @@ export type UseTableConfig = {
|
|
|
7
7
|
fetchOptions?: RequestInit;
|
|
8
8
|
selectionType?: SelectionType;
|
|
9
9
|
simulateDelay?: number;
|
|
10
|
+
disableRowSelection?: (record: any) => unknown;
|
|
10
11
|
};
|
|
11
12
|
export declare const useTable: <T extends Record<string, any>>(useTableConfig: any) => {
|
|
13
|
+
isLoading: boolean;
|
|
12
14
|
rowSelection: {
|
|
13
15
|
type: SelectionType;
|
|
14
16
|
onChange: (selectedRowKeys: React.Key[], selectedRows: T[]) => void;
|
|
15
|
-
getCheckboxProps: (record:
|
|
16
|
-
disabled: boolean;
|
|
17
|
-
name: any;
|
|
18
|
-
};
|
|
17
|
+
getCheckboxProps: (record: any) => unknown;
|
|
19
18
|
};
|
|
20
19
|
selectedRows: T[];
|
|
21
20
|
dataSource: T[];
|
|
@@ -1,93 +1,66 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return 0;
|
|
14
|
-
});
|
|
15
|
-
if (e.field) {
|
|
16
|
-
const c = e.field;
|
|
17
|
-
return [...a].sort((i, r) => {
|
|
18
|
-
const n = i[c], o = r[c];
|
|
19
|
-
return e.order === "ascend" ? n < o ? -1 : n > o ? 1 : 0 : e.order === "descend" ? n < o ? 1 : n > o ? -1 : 0 : 0;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return [...a];
|
|
23
|
-
}, C = (a) => {
|
|
24
|
-
const {
|
|
25
|
-
columns: e,
|
|
26
|
-
filters: c = null,
|
|
27
|
-
fetchUrl: i = "/table/data",
|
|
28
|
-
fetchOptions: r = {
|
|
1
|
+
import { useState as o, useEffect as m, useCallback as D } from "react";
|
|
2
|
+
const R = (a) => ({
|
|
3
|
+
disabled: !1,
|
|
4
|
+
// Add your disable logic here
|
|
5
|
+
name: a.id
|
|
6
|
+
}), k = (a) => {
|
|
7
|
+
const [i, d] = o(!0), {
|
|
8
|
+
columns: n,
|
|
9
|
+
filters: u = null,
|
|
10
|
+
fetchUrl: f = "/table/data",
|
|
11
|
+
fetchOptions: s = {
|
|
29
12
|
method: "POST",
|
|
30
13
|
headers: {
|
|
31
14
|
"Content-Type": "application/json"
|
|
32
15
|
},
|
|
33
|
-
body: JSON.stringify(
|
|
16
|
+
body: JSON.stringify(u)
|
|
34
17
|
},
|
|
35
|
-
selectionType:
|
|
36
|
-
simulateDelay:
|
|
37
|
-
|
|
18
|
+
selectionType: S = "checkbox",
|
|
19
|
+
simulateDelay: r = 0,
|
|
20
|
+
disableRowSelection: h = R
|
|
21
|
+
} = a, [T, p] = o([]), [g, c] = o({
|
|
38
22
|
dataSource: [],
|
|
39
23
|
columns: [],
|
|
40
24
|
error: null
|
|
41
|
-
}), [
|
|
25
|
+
}), [w, b] = o([]);
|
|
42
26
|
m(() => {
|
|
43
|
-
|
|
27
|
+
const t = async () => {
|
|
44
28
|
try {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
dataSource:
|
|
48
|
-
columns:
|
|
29
|
+
const l = (await (await fetch(f, s)).json()).data || [];
|
|
30
|
+
p(l), c({
|
|
31
|
+
dataSource: l,
|
|
32
|
+
columns: n,
|
|
49
33
|
error: null
|
|
50
34
|
});
|
|
51
|
-
} catch (
|
|
52
|
-
console.error("Error fetching table data:",
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.error("Error fetching table data:", e), c({
|
|
53
37
|
dataSource: [],
|
|
54
|
-
columns:
|
|
55
|
-
error:
|
|
38
|
+
columns: n,
|
|
39
|
+
error: e instanceof Error ? e : new Error(String(e))
|
|
56
40
|
});
|
|
41
|
+
} finally {
|
|
42
|
+
d(!1);
|
|
57
43
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
...d,
|
|
65
|
-
dataSource: t
|
|
66
|
-
}));
|
|
67
|
-
}, o);
|
|
68
|
-
},
|
|
69
|
-
[l]
|
|
70
|
-
);
|
|
71
|
-
const D = S(
|
|
72
|
-
(s, t) => {
|
|
73
|
-
console.log("Row Selected:", s, t), g(t);
|
|
44
|
+
};
|
|
45
|
+
r > 0 ? setTimeout(t, r) : t();
|
|
46
|
+
}, [s]);
|
|
47
|
+
const y = D(
|
|
48
|
+
(t, e) => {
|
|
49
|
+
console.log("Row Selected:", t, e), b(e);
|
|
74
50
|
},
|
|
75
51
|
[]
|
|
76
52
|
);
|
|
77
53
|
return {
|
|
78
|
-
...
|
|
54
|
+
...g,
|
|
55
|
+
isLoading: i,
|
|
79
56
|
rowSelection: {
|
|
80
|
-
type:
|
|
81
|
-
onChange:
|
|
82
|
-
getCheckboxProps:
|
|
83
|
-
disabled: !1,
|
|
84
|
-
// Add your disable logic here
|
|
85
|
-
name: s.id
|
|
86
|
-
})
|
|
57
|
+
type: S,
|
|
58
|
+
onChange: y,
|
|
59
|
+
getCheckboxProps: h
|
|
87
60
|
},
|
|
88
|
-
selectedRows:
|
|
61
|
+
selectedRows: w
|
|
89
62
|
};
|
|
90
63
|
};
|
|
91
64
|
export {
|
|
92
|
-
|
|
65
|
+
k as useTable
|
|
93
66
|
};
|