orion-design 0.1.52 → 0.1.53

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,35 +4,37 @@ interface PaginationProps {
4
4
  pageSizes?: number[];
5
5
  total?: number;
6
6
  }
7
- type LoadDataFn<T> = (pagination: PaginationProps) => Promise<{
8
- data: T[];
7
+ type LoadDataFn<Row, Tail> = (pagination: PaginationProps) => Promise<{
8
+ data: Row[];
9
9
  total: number;
10
+ tailData?: Tail;
10
11
  }>;
11
- interface UsePagetableOptions<T> {
12
+ interface UsePagetableOptions<Row, Tail> {
12
13
  tableRef: any;
13
- onLoadData: LoadDataFn<T>;
14
- afterSelectionChange?: (newSelection: T[]) => void;
15
- afterCurrentRowChange?: (currentRow: T, oldCurrentRow: T) => void;
16
- initialData?: T[];
14
+ onLoadData: LoadDataFn<Row, Tail>;
15
+ afterSelectionChange?: (newSelection: Row[]) => void;
16
+ afterCurrentRowChange?: (currentRow: Row, oldCurrentRow: Row) => void;
17
+ initialData?: Row[];
17
18
  initialPagination?: PaginationProps;
18
19
  }
19
- declare const usePagetable: <T>(options: UsePagetableOptions<T>) => {
20
- data: import('@vue/reactivity').UnwrapRefSimple<T>[];
20
+ declare const usePagetable: <Row = any, Tail = any>(options: UsePagetableOptions<Row, Tail>) => {
21
+ data: import('@vue/reactivity').UnwrapRefSimple<Row>[];
21
22
  pagination: {
22
23
  currentPage: number;
23
24
  pageSize: number;
24
25
  pageSizes?: number[] | undefined;
25
26
  total?: number | undefined;
26
27
  };
27
- selection: import('@vue/reactivity').UnwrapRefSimple<T>[];
28
- currentRow: T | undefined;
29
- onSelectionChange: (newSelection: T[]) => void;
30
- onCurrentRowChange: (newCurrentRow: T, oldCurrentRow: T) => void;
28
+ tailData: Tail | undefined;
29
+ selection: import('@vue/reactivity').UnwrapRefSimple<Row>[];
30
+ currentRow: Row | undefined;
31
+ onSelectionChange: (newSelection: Row[]) => void;
32
+ onCurrentRowChange: (newCurrentRow: Row, oldCurrentRow: Row) => void;
31
33
  clearSelection: () => void;
32
- toggleRowSelection: (row: T, selected?: boolean) => void;
34
+ toggleRowSelection: (row: Row, selected?: boolean) => void;
33
35
  toggleAllSelection: () => void;
34
36
  getSelectionRows: () => void;
35
- setCurrentRow: (row: T) => void;
37
+ setCurrentRow: (row: Row) => void;
36
38
  loadData: () => Promise<void>;
37
39
  };
38
40
  export default usePagetable;
@@ -1,29 +1,30 @@
1
- import { ref as a, reactive as w } from "vue";
2
- const m = (R) => {
3
- const { tableRef: o, onLoadData: v, afterSelectionChange: l, afterCurrentRowChange: c, initialData: i, initialPagination: g } = R, r = a(i || []), n = a(
1
+ import { ref as a, reactive as C } from "vue";
2
+ const x = (v) => {
3
+ const { tableRef: o, onLoadData: w, afterSelectionChange: l, afterCurrentRowChange: c, initialData: i, initialPagination: g } = v, r = a(i || []), n = a(
4
4
  g || {
5
5
  currentPage: 1,
6
6
  pageSize: 10
7
7
  }
8
- ), s = a([]), u = a();
9
- return w({
8
+ ), s = a(), u = a([]), S = a();
9
+ return C({
10
10
  data: r,
11
11
  pagination: n,
12
- selection: s,
13
- currentRow: u,
12
+ tailData: s,
13
+ selection: u,
14
+ currentRow: S,
14
15
  onSelectionChange: (e) => {
15
- s.value = e, l && l(e);
16
+ u.value = e, l && l(e);
16
17
  },
17
18
  onCurrentRowChange: (e, t) => {
18
- u.value = e, c && c(e, t);
19
+ S.value = e, c && c(e, t);
19
20
  },
20
21
  clearSelection: () => {
21
22
  var e;
22
23
  (e = o.value) == null || e.clearSelection();
23
24
  },
24
25
  toggleRowSelection: (e, t) => {
25
- var S;
26
- (S = o.value) == null || S.toggleRowSelection(e, t);
26
+ var R;
27
+ (R = o.value) == null || R.toggleRowSelection(e, t);
27
28
  },
28
29
  toggleAllSelection: () => {
29
30
  var e;
@@ -38,12 +39,12 @@ const m = (R) => {
38
39
  (t = o.value) == null || t.setCurrentRow(e);
39
40
  },
40
41
  loadData: async () => {
41
- const e = await v(n.value);
42
- r.value = e.data, n.value.total = e.total;
42
+ const e = await w(n.value);
43
+ r.value = e.data, n.value.total = e.total, s.value = e.tailData;
43
44
  }
44
45
  });
45
46
  };
46
47
  export {
47
- m as default
48
+ x as default
48
49
  };
49
50
  //# sourceMappingURL=usePagetable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePagetable.js","sources":["../../../../src/components/Pagetable/hooks/usePagetable.ts"],"sourcesContent":["import { reactive, ref } from 'vue'\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<T> = (pagination: PaginationProps) => Promise<{\r\n data: T[]\r\n total: number\r\n}>\r\n\r\ninterface UsePagetableOptions<T> {\r\n tableRef: any\r\n onLoadData: LoadDataFn<T>\r\n afterSelectionChange?: (newSelection: T[]) => void\r\n afterCurrentRowChange?: (currentRow: T, oldCurrentRow: T) => void\r\n initialData?: T[]\r\n initialPagination?: PaginationProps\r\n}\r\n\r\nconst usePagetable = <T>(options: UsePagetableOptions<T>) => {\r\n const { tableRef, onLoadData, afterSelectionChange, afterCurrentRowChange, initialData, initialPagination } = options\r\n\r\n const data = ref<T[]>(initialData ? initialData : [])\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 selection = ref<T[]>([])\r\n const currentRow = ref<T>()\r\n\r\n const onSelectionChange = (newSelection: T[]) => {\r\n selection.value = newSelection\r\n afterSelectionChange && afterSelectionChange(newSelection)\r\n }\r\n const onCurrentRowChange = (newCurrentRow: T, oldCurrentRow: T) => {\r\n currentRow.value = newCurrentRow\r\n afterCurrentRowChange && afterCurrentRowChange(newCurrentRow, oldCurrentRow)\r\n }\r\n\r\n const clearSelection = () => {\r\n tableRef.value?.clearSelection()\r\n }\r\n const toggleRowSelection = (row: T, selected?: boolean) => {\r\n tableRef.value?.toggleRowSelection(row, selected)\r\n }\r\n const toggleAllSelection = () => {\r\n tableRef.value?.toggleAllSelection()\r\n }\r\n const getSelectionRows = () => {\r\n tableRef.value?.getSelectionRows()\r\n }\r\n const setCurrentRow = (row: T) => {\r\n tableRef.value?.setCurrentRow(row)\r\n }\r\n\r\n const loadData = async () => {\r\n const loaded = await onLoadData(pagination.value)\r\n data.value = loaded.data\r\n pagination.value.total = loaded.total\r\n }\r\n\r\n return reactive({\r\n data,\r\n pagination,\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","selection","currentRow","reactive","newSelection","newCurrentRow","oldCurrentRow","_a","row","selected","loaded"],"mappings":";AAuBM,MAAAA,IAAe,CAAIC,MAAoC;AAC3D,QAAM,EAAE,UAAAC,GAAU,YAAAC,GAAY,sBAAAC,GAAsB,uBAAAC,GAAuB,aAAAC,GAAa,mBAAAC,EAAsB,IAAAN,GAExGO,IAAOC,EAASH,KAA4B,CAAE,CAAA,GAC9CI,IAAaD;AAAA,IACjBF,KAEI;AAAA,MACE,aAAa;AAAA,MACb,UAAU;AAAA,IACZ;AAAA,EAAA,GAEAI,IAAYF,EAAS,CAAA,CAAE,GACvBG,IAAaH;AAiCnB,SAAOI,EAAS;AAAA,IACd,MAAAL;AAAA,IACA,YAAAE;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC;AAAA,IACA,mBApCwB,CAACE,MAAsB;AAC/C,MAAAH,EAAU,QAAQG,GAClBV,KAAwBA,EAAqBU,CAAY;AAAA,IAAA;AAAA,IAmCzD,oBAjCyB,CAACC,GAAkBC,MAAqB;AACjE,MAAAJ,EAAW,QAAQG,GACMV,KAAAA,EAAsBU,GAAeC,CAAa;AAAA,IAAA;AAAA,IAgC3E,gBA7BqB,MAAM;;AAC3B,OAAAC,IAAAf,EAAS,UAAT,QAAAe,EAAgB;AAAA,IAAe;AAAA,IA6B/B,oBA3ByB,CAACC,GAAQC,MAAuB;;AAChD,OAAAF,IAAAf,EAAA,UAAA,QAAAe,EAAO,mBAAmBC,GAAKC;AAAA,IAAQ;AAAA,IA2BhD,oBAzByB,MAAM;;AAC/B,OAAAF,IAAAf,EAAS,UAAT,QAAAe,EAAgB;AAAA,IAAmB;AAAA,IAyBnC,kBAvBuB,MAAM;;AAC7B,OAAAA,IAAAf,EAAS,UAAT,QAAAe,EAAgB;AAAA,IAAiB;AAAA,IAuBjC,eArBoB,CAACC,MAAW;;AACvB,OAAAD,IAAAf,EAAA,UAAA,QAAAe,EAAO,cAAcC;AAAA,IAAG;AAAA,IAqBjC,UAlBe,YAAY;AAC3B,YAAME,IAAS,MAAMjB,EAAWO,EAAW,KAAK;AAChD,MAAAF,EAAK,QAAQY,EAAO,MACTV,EAAA,MAAM,QAAQU,EAAO;AAAA,IAAA;AAAA,EAehC,CACD;AACH;"}
1
+ {"version":3,"file":"usePagetable.js","sources":["../../../../src/components/Pagetable/hooks/usePagetable.ts"],"sourcesContent":["import { reactive, ref } from 'vue'\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> = (pagination: PaginationProps) => Promise<{\r\n data: Row[]\r\n total: number\r\n tailData?: Tail\r\n}>\r\n\r\ninterface UsePagetableOptions<Row, Tail> {\r\n tableRef: any\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 : [])\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[]>([])\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 tableRef.value?.clearSelection()\r\n }\r\n const toggleRowSelection = (row: Row, selected?: boolean) => {\r\n tableRef.value?.toggleRowSelection(row, selected)\r\n }\r\n const toggleAllSelection = () => {\r\n tableRef.value?.toggleAllSelection()\r\n }\r\n const getSelectionRows = () => {\r\n tableRef.value?.getSelectionRows()\r\n }\r\n const setCurrentRow = (row: Row) => {\r\n tableRef.value?.setCurrentRow(row)\r\n }\r\n\r\n const loadData = async () => {\r\n const loaded = await onLoadData(pagination.value)\r\n data.value = loaded.data\r\n pagination.value.total = loaded.total\r\n tailData.value = loaded.tailData\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","reactive","newSelection","newCurrentRow","oldCurrentRow","_a","row","selected","loaded"],"mappings":";AAwBM,MAAAA,IAAe,CAAwBC,MAA4C;AACvF,QAAM,EAAE,UAAAC,GAAU,YAAAC,GAAY,sBAAAC,GAAsB,uBAAA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AS,QAAQU,EAAO;AAAA,IAAA;AAAA,EAgBxB,CACD;AACH;"}
@@ -1,2 +1,2 @@
1
- declare const _default: "0.1.52";
1
+ declare const _default: "0.1.53";
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
- const e = "0.1.52";
1
+ const e = "0.1.53";
2
2
  export {
3
3
  e as default
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../src/version/version.ts"],"sourcesContent":["export default '0.1.52';"],"names":["version"],"mappings":"AAAA,MAAAA,IAAe;"}
1
+ {"version":3,"file":"version.js","sources":["../../src/version/version.ts"],"sourcesContent":["export default '0.1.53';"],"names":["version"],"mappings":"AAAA,MAAAA,IAAe;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orion-design",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",