orion-design 0.1.54 → 0.1.55
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/Pagetable/hooks/usePagetable.d.ts +10 -7
- package/dist/components/Pagetable/hooks/usePagetable.js +48 -42
- package/dist/components/Pagetable/hooks/usePagetable.js.map +1 -1
- package/dist/version/version.d.ts +1 -1
- package/dist/version/version.js +1 -1
- package/dist/version/version.js.map +1 -1
- package/package.json +1 -1
@@ -6,11 +6,14 @@ interface PaginationProps {
|
|
6
6
|
pageSizes?: number[];
|
7
7
|
total?: number;
|
8
8
|
}
|
9
|
-
type LoadDataFn<Row, Tail> = (
|
9
|
+
type LoadDataFn<Row, Tail> = (self: {
|
10
10
|
data: Row[];
|
11
|
-
|
12
|
-
tailData
|
13
|
-
|
11
|
+
pagination: PaginationProps;
|
12
|
+
tailData: Tail | undefined;
|
13
|
+
toggleRowSelection: (row: Row, selected?: boolean) => void;
|
14
|
+
toggleAllSelection: () => void;
|
15
|
+
setCurrentRow: (row: Row) => void;
|
16
|
+
}) => Promise<void>;
|
14
17
|
interface UsePagetableOptions<Row, Tail> {
|
15
18
|
tableRef?: Readonly<ShallowRef<PagetableInstance | null>>;
|
16
19
|
onLoadData: LoadDataFn<Row, Tail>;
|
@@ -20,7 +23,7 @@ interface UsePagetableOptions<Row, Tail> {
|
|
20
23
|
initialPagination?: PaginationProps;
|
21
24
|
}
|
22
25
|
declare const usePagetable: <Row = any, Tail = any>(options: UsePagetableOptions<Row, Tail>) => {
|
23
|
-
data:
|
26
|
+
data: Row[];
|
24
27
|
pagination: {
|
25
28
|
currentPage: number;
|
26
29
|
pageSize: number;
|
@@ -28,14 +31,14 @@ declare const usePagetable: <Row = any, Tail = any>(options: UsePagetableOptions
|
|
28
31
|
total?: number | undefined;
|
29
32
|
};
|
30
33
|
tailData: Tail | undefined;
|
31
|
-
selection:
|
34
|
+
selection: Row[];
|
32
35
|
currentRow: Row | undefined;
|
33
36
|
onSelectionChange: (newSelection: Row[]) => void;
|
34
37
|
onCurrentRowChange: (newCurrentRow: Row, oldCurrentRow: Row) => void;
|
35
38
|
clearSelection: () => void;
|
36
39
|
toggleRowSelection: (row: Row, selected?: boolean) => void;
|
37
40
|
toggleAllSelection: () => void;
|
38
|
-
getSelectionRows: () =>
|
41
|
+
getSelectionRows: () => Row[];
|
39
42
|
setCurrentRow: (row: Row) => void;
|
40
43
|
loadData: () => Promise<void>;
|
41
44
|
};
|
@@ -1,56 +1,62 @@
|
|
1
1
|
import { ref as o, reactive as v } from "vue";
|
2
|
-
import
|
3
|
-
const
|
4
|
-
const { tableRef:
|
5
|
-
|
2
|
+
import n from "../../../error/OrionError.js";
|
3
|
+
const z = (C) => {
|
4
|
+
const { tableRef: e, onLoadData: b, afterSelectionChange: l, afterCurrentRowChange: c, initialData: r, initialPagination: i } = C, s = o(r || []), g = o(
|
5
|
+
i || {
|
6
6
|
currentPage: 1,
|
7
7
|
pageSize: 10
|
8
8
|
}
|
9
|
-
), w = o(),
|
9
|
+
), w = o(), f = o([]), u = o(), d = (t) => {
|
10
|
+
f.value = t, l && l(t);
|
11
|
+
}, p = (t, a) => {
|
12
|
+
u.value = t, c && c(t, a);
|
13
|
+
}, D = () => {
|
14
|
+
if (!e)
|
15
|
+
throw new n("调用clearSelection失败,tableRef为空");
|
16
|
+
e.value.clearSelection();
|
17
|
+
}, R = (t, a) => {
|
18
|
+
if (!e)
|
19
|
+
throw new n("调用toggleRowSelection失败,tableRef为空");
|
20
|
+
e.value.toggleRowSelection(t, a);
|
21
|
+
}, S = () => {
|
22
|
+
if (!e)
|
23
|
+
throw new n("调用toggleAllSelection失败,tableRef为空");
|
24
|
+
e.value.toggleAllSelection();
|
25
|
+
}, m = () => {
|
26
|
+
if (!e)
|
27
|
+
throw new n("调用getSelectionRows失败,tableRef为空");
|
28
|
+
return e.value.getSelectionRows();
|
29
|
+
}, h = (t) => {
|
30
|
+
if (!e)
|
31
|
+
throw new n("调用setCurrentRow失败,tableRef为空");
|
32
|
+
e.value.setCurrentRow(t);
|
33
|
+
}, A = v({
|
34
|
+
data: s,
|
35
|
+
pagination: g,
|
36
|
+
tailData: w,
|
37
|
+
toggleRowSelection: R,
|
38
|
+
toggleAllSelection: S,
|
39
|
+
setCurrentRow: h
|
40
|
+
});
|
10
41
|
return v({
|
11
42
|
data: s,
|
12
|
-
pagination:
|
43
|
+
pagination: g,
|
13
44
|
tailData: w,
|
14
|
-
selection:
|
15
|
-
currentRow:
|
16
|
-
onSelectionChange:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if (!t)
|
24
|
-
throw new a("调用clearSelection失败,tableRef为空");
|
25
|
-
t.value.clearSelection();
|
26
|
-
},
|
27
|
-
toggleRowSelection: (e, n) => {
|
28
|
-
if (!t)
|
29
|
-
throw new a("调用toggleRowSelection失败,tableRef为空");
|
30
|
-
t.value.toggleRowSelection(e, n);
|
31
|
-
},
|
32
|
-
toggleAllSelection: () => {
|
33
|
-
if (!t)
|
34
|
-
throw new a("调用toggleAllSelection失败,tableRef为空");
|
35
|
-
t.value.toggleAllSelection();
|
36
|
-
},
|
37
|
-
getSelectionRows: () => {
|
38
|
-
if (!t)
|
39
|
-
throw new a("调用getSelectionRows失败,tableRef为空");
|
40
|
-
t.value.getSelectionRows();
|
41
|
-
},
|
42
|
-
setCurrentRow: (e) => {
|
43
|
-
if (!t)
|
44
|
-
throw new a("调用setCurrentRow失败,tableRef为空");
|
45
|
-
t.value.setCurrentRow(e);
|
46
|
-
},
|
45
|
+
selection: f,
|
46
|
+
currentRow: u,
|
47
|
+
onSelectionChange: d,
|
48
|
+
onCurrentRowChange: p,
|
49
|
+
clearSelection: D,
|
50
|
+
toggleRowSelection: R,
|
51
|
+
toggleAllSelection: S,
|
52
|
+
getSelectionRows: m,
|
53
|
+
setCurrentRow: h,
|
47
54
|
loadData: async () => {
|
48
|
-
|
49
|
-
s.value = e.data, l.value.total = e.total, w.value = e.tailData;
|
55
|
+
await b(A);
|
50
56
|
}
|
51
57
|
});
|
52
58
|
};
|
53
59
|
export {
|
54
|
-
|
60
|
+
z as default
|
55
61
|
};
|
56
62
|
//# sourceMappingURL=usePagetable.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"usePagetable.js","sources":["../../../../src/components/Pagetable/hooks/usePagetable.ts"],"sourcesContent":["import { reactive, ref, ShallowRef } from 'vue'\r\nimport { PagetableInstance } from '../Pagetable'\r\nimport OrionError from '../../../error/OrionError'\r\n\r\ninterface PaginationProps {\r\n currentPage: number\r\n pageSize: number\r\n pageSizes?: number[]\r\n total?: number\r\n}\r\n\r\ntype LoadDataFn<Row, Tail> = (
|
1
|
+
{"version":3,"file":"usePagetable.js","sources":["../../../../src/components/Pagetable/hooks/usePagetable.ts"],"sourcesContent":["import { reactive, Ref, ref, ShallowRef } from 'vue'\r\nimport { PagetableInstance } from '../Pagetable'\r\nimport OrionError from '../../../error/OrionError'\r\n\r\ninterface PaginationProps {\r\n currentPage: number\r\n pageSize: number\r\n pageSizes?: number[]\r\n total?: number\r\n}\r\n\r\ntype LoadDataFn<Row, Tail> = (self: {\r\n data: Row[]\r\n pagination: PaginationProps\r\n tailData: Tail | undefined\r\n toggleRowSelection: (row: Row, selected?: boolean) => void\r\n toggleAllSelection: () => void\r\n setCurrentRow: (row: Row) => void\r\n}) => Promise<void>\r\n\r\ninterface UsePagetableOptions<Row, Tail> {\r\n tableRef?: Readonly<ShallowRef<PagetableInstance | null>>\r\n onLoadData: LoadDataFn<Row, Tail>\r\n afterSelectionChange?: (newSelection: Row[]) => void\r\n afterCurrentRowChange?: (currentRow: Row, oldCurrentRow: Row) => void\r\n initialData?: Row[]\r\n initialPagination?: PaginationProps\r\n}\r\n\r\nconst usePagetable = <Row = any, Tail = any>(options: UsePagetableOptions<Row, Tail>) => {\r\n const { tableRef, onLoadData, afterSelectionChange, afterCurrentRowChange, initialData, initialPagination } = options\r\n\r\n const data = ref<Row[]>(initialData ? initialData : []) as Ref<Row[]>\r\n const pagination = ref<PaginationProps>(\r\n initialPagination\r\n ? initialPagination\r\n : {\r\n currentPage: 1,\r\n pageSize: 10,\r\n }\r\n )\r\n const tailData = ref<Tail>()\r\n const selection = ref<Row[]>([]) as Ref<Row[]>\r\n const currentRow = ref<Row>()\r\n\r\n const onSelectionChange = (newSelection: Row[]) => {\r\n selection.value = newSelection\r\n afterSelectionChange && afterSelectionChange(newSelection)\r\n }\r\n const onCurrentRowChange = (newCurrentRow: Row, oldCurrentRow: Row) => {\r\n currentRow.value = newCurrentRow\r\n afterCurrentRowChange && afterCurrentRowChange(newCurrentRow, oldCurrentRow)\r\n }\r\n\r\n const clearSelection = () => {\r\n if (!tableRef) {\r\n throw new OrionError(`调用clearSelection失败,tableRef为空`)\r\n }\r\n tableRef.value!.clearSelection()\r\n }\r\n const toggleRowSelection = (row: Row, selected?: boolean) => {\r\n if (!tableRef) {\r\n throw new OrionError(`调用toggleRowSelection失败,tableRef为空`)\r\n }\r\n tableRef.value!.toggleRowSelection(row, selected)\r\n }\r\n const toggleAllSelection = () => {\r\n if (!tableRef) {\r\n throw new OrionError(`调用toggleAllSelection失败,tableRef为空`)\r\n }\r\n tableRef.value!.toggleAllSelection()\r\n }\r\n const getSelectionRows = () => {\r\n if (!tableRef) {\r\n throw new OrionError(`调用getSelectionRows失败,tableRef为空`)\r\n }\r\n return tableRef.value!.getSelectionRows() as Row[]\r\n }\r\n const setCurrentRow = (row: Row) => {\r\n if (!tableRef) {\r\n throw new OrionError(`调用setCurrentRow失败,tableRef为空`)\r\n }\r\n tableRef.value!.setCurrentRow(row)\r\n }\r\n\r\n const self = reactive({\r\n data,\r\n pagination,\r\n tailData,\r\n toggleRowSelection,\r\n toggleAllSelection,\r\n setCurrentRow,\r\n })\r\n\r\n const loadData = async () => {\r\n await onLoadData(self)\r\n }\r\n\r\n return reactive({\r\n data,\r\n pagination,\r\n tailData,\r\n selection,\r\n currentRow,\r\n onSelectionChange,\r\n onCurrentRowChange,\r\n clearSelection,\r\n toggleRowSelection,\r\n toggleAllSelection,\r\n getSelectionRows,\r\n setCurrentRow,\r\n loadData,\r\n })\r\n}\r\n\r\nexport default usePagetable\r\n"],"names":["usePagetable","options","tableRef","onLoadData","afterSelectionChange","afterCurrentRowChange","initialData","initialPagination","data","ref","pagination","tailData","selection","currentRow","onSelectionChange","newSelection","onCurrentRowChange","newCurrentRow","oldCurrentRow","clearSelection","OrionError","toggleRowSelection","row","selected","toggleAllSelection","getSelectionRows","setCurrentRow","self","reactive"],"mappings":";;AA6BM,MAAAA,IAAe,CAAwBC,MAA4C;AACvF,QAAM,EAAE,UAAAC,GAAU,YAAAC,GAAY,sBAAAC,GAAsB,uBAAAC,GAAuB,aAAAC,GAAa,mBAAAC,EAAsB,IAAAN,GAExGO,IAAOC,EAAWH,KAA4B,CAAE,CAAA,GAChDI,IAAaD;AAAA,IACjBF,KAEI;AAAA,MACE,aAAa;AAAA,MACb,UAAU;AAAA,IACZ;AAAA,EAAA,GAEAI,IAAWF,KACXG,IAAYH,EAAW,CAAA,CAAE,GACzBI,IAAaJ,KAEbK,IAAoB,CAACC,MAAwB;AACjD,IAAAH,EAAU,QAAQG,GAClBX,KAAwBA,EAAqBW,CAAY;AAAA,EAAA,GAErDC,IAAqB,CAACC,GAAoBC,MAAuB;AACrE,IAAAL,EAAW,QAAQI,GACMZ,KAAAA,EAAsBY,GAAeC,CAAa;AAAA,EAAA,GAGvEC,IAAiB,MAAM;AAC3B,QAAI,CAACjB;AACG,YAAA,IAAIkB,EAAW,+BAA+B;AAEtD,IAAAlB,EAAS,MAAO;EAAe,GAE3BmB,IAAqB,CAACC,GAAUC,MAAuB;AAC3D,QAAI,CAACrB;AACG,YAAA,IAAIkB,EAAW,mCAAmC;AAEjD,IAAAlB,EAAA,MAAO,mBAAmBoB,GAAKC,CAAQ;AAAA,EAAA,GAE5CC,IAAqB,MAAM;AAC/B,QAAI,CAACtB;AACG,YAAA,IAAIkB,EAAW,mCAAmC;AAE1D,IAAAlB,EAAS,MAAO;EAAmB,GAE/BuB,IAAmB,MAAM;AAC7B,QAAI,CAACvB;AACG,YAAA,IAAIkB,EAAW,iCAAiC;AAEjD,WAAAlB,EAAS,MAAO;EAAiB,GAEpCwB,IAAgB,CAACJ,MAAa;AAClC,QAAI,CAACpB;AACG,YAAA,IAAIkB,EAAW,8BAA8B;AAE5C,IAAAlB,EAAA,MAAO,cAAcoB,CAAG;AAAA,EAAA,GAG7BK,IAAOC,EAAS;AAAA,IACpB,MAAApB;AAAA,IACA,YAAAE;AAAA,IACA,UAAAC;AAAA,IACA,oBAAAU;AAAA,IACA,oBAAAG;AAAA,IACA,eAAAE;AAAA,EAAA,CACD;AAMD,SAAOE,EAAS;AAAA,IACd,MAAApB;AAAA,IACA,YAAAE;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,oBAAAE;AAAA,IACA,gBAAAG;AAAA,IACA,oBAAAE;AAAA,IACA,oBAAAG;AAAA,IACA,kBAAAC;AAAA,IACA,eAAAC;AAAA,IACA,UAjBe,YAAY;AAC3B,YAAMvB,EAAWwB,CAAI;AAAA,IAAA;AAAA,EAgBrB,CACD;AACH;"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const _default: "0.1.
|
1
|
+
declare const _default: "0.1.55";
|
2
2
|
export default _default;
|
package/dist/version/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../src/version/version.ts"],"sourcesContent":["export default '0.1.
|
1
|
+
{"version":3,"file":"version.js","sources":["../../src/version/version.ts"],"sourcesContent":["export default '0.1.55';"],"names":["version"],"mappings":"AAAA,MAAAA,IAAe;"}
|