@akinon/akitable 0.2.1 → 0.3.1
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/cjs/akitable-context.d.ts +18 -0
- package/dist/cjs/akitable-context.d.ts.map +1 -0
- package/dist/cjs/akitable-context.js +19 -0
- package/dist/cjs/akitable.css +8 -0
- package/dist/cjs/akitable.d.ts +5 -0
- package/dist/cjs/akitable.d.ts.map +1 -0
- package/dist/cjs/akitable.js +37 -0
- package/dist/cjs/common/theme-overrides.d.ts +3 -0
- package/dist/cjs/common/theme-overrides.d.ts.map +1 -0
- package/dist/cjs/common/theme-overrides.js +60 -0
- package/dist/cjs/components/actions.css +19 -0
- package/dist/cjs/components/actions.d.ts +4 -0
- package/dist/cjs/components/actions.d.ts.map +1 -0
- package/dist/cjs/components/actions.js +35 -0
- package/dist/cjs/components/controls.css +5 -0
- package/dist/cjs/components/controls.d.ts +4 -0
- package/dist/cjs/components/controls.d.ts.map +1 -0
- package/dist/cjs/components/controls.js +18 -0
- package/dist/cjs/components/datatable.css +57 -0
- package/dist/cjs/components/datatable.d.ts +5 -0
- package/dist/cjs/components/datatable.d.ts.map +1 -0
- package/dist/cjs/components/datatable.js +29 -0
- package/dist/cjs/components/footer.css +5 -0
- package/dist/cjs/components/footer.d.ts +5 -0
- package/dist/cjs/components/footer.d.ts.map +1 -0
- package/dist/cjs/components/footer.js +19 -0
- package/dist/cjs/components/header.css +23 -0
- package/dist/cjs/components/header.d.ts +5 -0
- package/dist/cjs/components/header.d.ts.map +1 -0
- package/dist/cjs/components/header.js +25 -0
- package/dist/cjs/components/pagination.css +3 -0
- package/dist/{esm/components/Pagination/index.d.ts → cjs/components/pagination.d.ts} +2 -2
- package/dist/cjs/components/pagination.d.ts.map +1 -0
- package/dist/cjs/components/pagination.js +17 -0
- package/dist/cjs/i18n/index.d.ts +5 -0
- package/dist/cjs/i18n/index.d.ts.map +1 -0
- package/dist/cjs/i18n/index.js +14 -0
- package/dist/cjs/i18n/translations/en.d.ts +9 -0
- package/dist/cjs/i18n/translations/en.d.ts.map +1 -0
- package/dist/cjs/i18n/translations/en.js +10 -0
- package/dist/cjs/i18n/translations/tr.d.ts +9 -0
- package/dist/cjs/i18n/translations/tr.d.ts.map +1 -0
- package/dist/cjs/i18n/translations/tr.js +10 -0
- package/dist/cjs/index.d.ts +2 -18
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +15 -93
- package/dist/cjs/types.d.ts +50 -16
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/akitable-context.d.ts +18 -0
- package/dist/esm/akitable-context.d.ts.map +1 -0
- package/dist/esm/akitable-context.js +14 -0
- package/dist/esm/akitable.css +8 -0
- package/dist/esm/akitable.d.ts +5 -0
- package/dist/esm/akitable.d.ts.map +1 -0
- package/dist/esm/akitable.js +33 -0
- package/dist/esm/common/theme-overrides.d.ts +3 -0
- package/dist/esm/common/theme-overrides.d.ts.map +1 -0
- package/dist/esm/common/theme-overrides.js +57 -0
- package/dist/esm/components/actions.css +19 -0
- package/dist/esm/components/actions.d.ts +4 -0
- package/dist/esm/components/actions.d.ts.map +1 -0
- package/dist/esm/components/actions.js +31 -0
- package/dist/esm/components/controls.css +5 -0
- package/dist/esm/components/controls.d.ts +4 -0
- package/dist/esm/components/controls.d.ts.map +1 -0
- package/dist/esm/components/controls.js +14 -0
- package/dist/esm/components/datatable.css +57 -0
- package/dist/esm/components/datatable.d.ts +5 -0
- package/dist/esm/components/datatable.d.ts.map +1 -0
- package/dist/esm/components/datatable.js +25 -0
- package/dist/esm/components/footer.css +5 -0
- package/dist/esm/components/footer.d.ts +5 -0
- package/dist/esm/components/footer.d.ts.map +1 -0
- package/dist/esm/components/footer.js +15 -0
- package/dist/esm/components/header.css +23 -0
- package/dist/esm/components/header.d.ts +5 -0
- package/dist/esm/components/header.d.ts.map +1 -0
- package/dist/esm/components/header.js +21 -0
- package/dist/esm/components/pagination.css +3 -0
- package/dist/{cjs/components/Pagination/index.d.ts → esm/components/pagination.d.ts} +2 -2
- package/dist/esm/components/pagination.d.ts.map +1 -0
- package/dist/esm/components/pagination.js +13 -0
- package/dist/esm/i18n/index.d.ts +5 -0
- package/dist/esm/i18n/index.d.ts.map +1 -0
- package/dist/esm/i18n/index.js +11 -0
- package/dist/esm/i18n/translations/en.d.ts +9 -0
- package/dist/esm/i18n/translations/en.d.ts.map +1 -0
- package/dist/esm/i18n/translations/en.js +8 -0
- package/dist/esm/i18n/translations/tr.d.ts +9 -0
- package/dist/esm/i18n/translations/tr.d.ts.map +1 -0
- package/dist/esm/i18n/translations/tr.js +8 -0
- package/dist/esm/index.d.ts +2 -18
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -92
- package/dist/esm/types.d.ts +50 -16
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +19 -15
- package/dist/cjs/components/AntdTable/index.d.ts +0 -6
- package/dist/cjs/components/AntdTable/index.d.ts.map +0 -1
- package/dist/cjs/components/AntdTable/index.js +0 -33
- package/dist/cjs/components/Footer/index.css +0 -6
- package/dist/cjs/components/Footer/index.d.ts +0 -4
- package/dist/cjs/components/Footer/index.d.ts.map +0 -1
- package/dist/cjs/components/Footer/index.js +0 -16
- package/dist/cjs/components/Header/index.css +0 -84
- package/dist/cjs/components/Header/index.d.ts +0 -10
- package/dist/cjs/components/Header/index.d.ts.map +0 -1
- package/dist/cjs/components/Header/index.js +0 -25
- package/dist/cjs/components/HeaderActions/index.css +0 -30
- package/dist/cjs/components/HeaderActions/index.d.ts +0 -9
- package/dist/cjs/components/HeaderActions/index.d.ts.map +0 -1
- package/dist/cjs/components/HeaderActions/index.js +0 -39
- package/dist/cjs/components/Pagination/index.css +0 -96
- package/dist/cjs/components/Pagination/index.d.ts.map +0 -1
- package/dist/cjs/components/Pagination/index.js +0 -20
- package/dist/cjs/components/index.d.ts +0 -6
- package/dist/cjs/components/index.d.ts.map +0 -1
- package/dist/cjs/components/index.js +0 -13
- package/dist/cjs/context/index.d.ts +0 -25
- package/dist/cjs/context/index.d.ts.map +0 -1
- package/dist/cjs/context/index.js +0 -35
- package/dist/cjs/index.css +0 -28
- package/dist/esm/components/AntdTable/index.d.ts +0 -6
- package/dist/esm/components/AntdTable/index.d.ts.map +0 -1
- package/dist/esm/components/AntdTable/index.js +0 -29
- package/dist/esm/components/Footer/index.css +0 -6
- package/dist/esm/components/Footer/index.d.ts +0 -4
- package/dist/esm/components/Footer/index.d.ts.map +0 -1
- package/dist/esm/components/Footer/index.js +0 -12
- package/dist/esm/components/Header/index.css +0 -84
- package/dist/esm/components/Header/index.d.ts +0 -10
- package/dist/esm/components/Header/index.d.ts.map +0 -1
- package/dist/esm/components/Header/index.js +0 -21
- package/dist/esm/components/HeaderActions/index.css +0 -30
- package/dist/esm/components/HeaderActions/index.d.ts +0 -9
- package/dist/esm/components/HeaderActions/index.d.ts.map +0 -1
- package/dist/esm/components/HeaderActions/index.js +0 -35
- package/dist/esm/components/Pagination/index.css +0 -96
- package/dist/esm/components/Pagination/index.d.ts.map +0 -1
- package/dist/esm/components/Pagination/index.js +0 -16
- package/dist/esm/components/index.d.ts +0 -6
- package/dist/esm/components/index.d.ts.map +0 -1
- package/dist/esm/components/index.js +0 -5
- package/dist/esm/context/index.d.ts +0 -25
- package/dist/esm/context/index.d.ts.map +0 -1
- package/dist/esm/context/index.js +0 -30
- package/dist/esm/index.css +0 -28
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HeaderActions = void 0;
|
|
4
|
-
require("./index.css");
|
|
5
|
-
const ui_button_1 = require("@akinon/ui-button");
|
|
6
|
-
const ui_select_1 = require("@akinon/ui-select");
|
|
7
|
-
const ui_space_1 = require("@akinon/ui-space");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const context_1 = require("../../context");
|
|
10
|
-
const HeaderActions = ({ placeholder, applyButtonLabel }) => {
|
|
11
|
-
const [selectedActionIndex, setSelectedActionIndex] = (0, react_1.useState)(undefined);
|
|
12
|
-
const { state: { selectedRows }, headerActions } = (0, context_1.useAkitableContext)();
|
|
13
|
-
if (!headerActions)
|
|
14
|
-
return;
|
|
15
|
-
const actionOptions = headerActions.map((action, i) => {
|
|
16
|
-
return {
|
|
17
|
-
label: action.label,
|
|
18
|
-
value: i,
|
|
19
|
-
// do not check isSingleRequired in here but in action handler, since user can select multiple rows after selecting the action which will lead errors.
|
|
20
|
-
disabled: action.disabled
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
const handleActionApply = () => {
|
|
24
|
-
if (selectedActionIndex === undefined || selectedActionIndex === null)
|
|
25
|
-
return;
|
|
26
|
-
if ((selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) === 0)
|
|
27
|
-
return;
|
|
28
|
-
const selectedAction = headerActions[selectedActionIndex];
|
|
29
|
-
selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.handler(selectedRows);
|
|
30
|
-
};
|
|
31
|
-
const handleActionSelectChange = (value) => {
|
|
32
|
-
setSelectedActionIndex(value);
|
|
33
|
-
};
|
|
34
|
-
const isApplyButtonDisabled = selectedActionIndex === undefined || (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) === 0;
|
|
35
|
-
return (react_1.default.createElement(ui_space_1.Space, { align: "baseline", className: "header-actions" },
|
|
36
|
-
react_1.default.createElement(ui_select_1.Select, { value: selectedActionIndex, onChange: handleActionSelectChange, options: actionOptions, placeholder: placeholder, className: "header-actions__select" }),
|
|
37
|
-
react_1.default.createElement(ui_button_1.Button, { disabled: isApplyButtonDisabled, className: "header-actions__apply-button", onClick: handleActionApply }, applyButtonLabel)));
|
|
38
|
-
};
|
|
39
|
-
exports.HeaderActions = HeaderActions;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
.akitable-pagination-container {
|
|
2
|
-
display: flex;
|
|
3
|
-
|
|
4
|
-
.akinon-select-single:not(.akinon-select-customize-input)
|
|
5
|
-
.akinon-select-selector {
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
height: 40px;
|
|
8
|
-
align-items: center;
|
|
9
|
-
border-radius: 5px;
|
|
10
|
-
border: solid 1px #c8daec;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&__pagination.akinon-pagination {
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
border-radius: 5px;
|
|
17
|
-
|
|
18
|
-
li {
|
|
19
|
-
margin: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.akinon-pagination-prev,
|
|
23
|
-
.akinon-pagination-next {
|
|
24
|
-
width: 36px;
|
|
25
|
-
border-radius: 5px;
|
|
26
|
-
|
|
27
|
-
& > button {
|
|
28
|
-
color: #788195;
|
|
29
|
-
|
|
30
|
-
&:hover,
|
|
31
|
-
&:focus {
|
|
32
|
-
color: #788195;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.akinon-pagination-simple-pager {
|
|
38
|
-
color: #9b9b9b;
|
|
39
|
-
height: 40px;
|
|
40
|
-
border: 1px solid #c8daec;
|
|
41
|
-
margin-inline-end: unset !important;
|
|
42
|
-
padding-inline-end: 8px !important;
|
|
43
|
-
|
|
44
|
-
& > input {
|
|
45
|
-
color: #062a4a;
|
|
46
|
-
font-weight: 600;
|
|
47
|
-
border: 1px solid #c8daec;
|
|
48
|
-
border-radius: 0;
|
|
49
|
-
box-shadow: inset 0 0 2px 2px #eef0f2;
|
|
50
|
-
background-color: #fbfcfd;
|
|
51
|
-
|
|
52
|
-
&:hover {
|
|
53
|
-
border: 1px solid #c8daec;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.akinon-select-selector {
|
|
60
|
-
color: #9b9b9b !important;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* override antd style
|
|
64
|
-
apply every direct */
|
|
65
|
-
.akinon-pagination-prev {
|
|
66
|
-
height: 40px !important;
|
|
67
|
-
border: 1px solid #c8daec !important;
|
|
68
|
-
border-right: none !important;
|
|
69
|
-
border-top-right-radius: 0% !important;
|
|
70
|
-
border-bottom-right-radius: 0% !important;
|
|
71
|
-
> * {
|
|
72
|
-
height: inherit !important;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.akinon-pagination-next {
|
|
77
|
-
height: 40px !important;
|
|
78
|
-
border: 1px solid #c8daec !important;
|
|
79
|
-
border-left: none !important;
|
|
80
|
-
border-top-left-radius: 0% !important;
|
|
81
|
-
border-bottom-left-radius: 0% !important;
|
|
82
|
-
> * {
|
|
83
|
-
height: inherit !important;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
.akinon-pagination-slash {
|
|
87
|
-
margin-inline-end: 0px;
|
|
88
|
-
margin-inline-start: 12px;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.akinon-pagination-options {
|
|
92
|
-
height: 40px !important;
|
|
93
|
-
order: -1 !important; /* Places it at the beginning */
|
|
94
|
-
margin-right: 20px !important;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Pagination/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,kBAAkB,yBA2B9B,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AkitablePagination = void 0;
|
|
4
|
-
require("./index.css");
|
|
5
|
-
const ui_pagination_1 = require("@akinon/ui-pagination");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const context_1 = require("../../context");
|
|
8
|
-
const AkitablePagination = () => {
|
|
9
|
-
const { useAkitablePagination } = (0, context_1.useAkitableContext)();
|
|
10
|
-
const [pagination, setPagination] = useAkitablePagination;
|
|
11
|
-
const handlePaginationChange = (currentPage, pageSize) => {
|
|
12
|
-
setPagination(Object.assign(Object.assign({}, pagination), { currentPage,
|
|
13
|
-
pageSize }));
|
|
14
|
-
};
|
|
15
|
-
return (react_1.default.createElement("div", { className: "akitable-pagination-container" },
|
|
16
|
-
react_1.default.createElement(ui_pagination_1.Pagination, { className: "akitable-pagination-container__pagination", current: pagination.currentPage, total: pagination.totalDataLength, pageSize: pagination.pageSize, onChange: handlePaginationChange, simple: true, locale: {
|
|
17
|
-
items_per_page: pagination.paginationLabel || 'per page'
|
|
18
|
-
} })));
|
|
19
|
-
};
|
|
20
|
-
exports.AkitablePagination = AkitablePagination;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { AntdTable } from './AntdTable';
|
|
2
|
-
export { AkitableFooter } from './Footer';
|
|
3
|
-
export { AkitableHeader } from './Header';
|
|
4
|
-
export { HeaderActions } from './HeaderActions';
|
|
5
|
-
export { AkitablePagination } from './Pagination';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AkitablePagination = exports.HeaderActions = exports.AkitableHeader = exports.AkitableFooter = exports.AntdTable = void 0;
|
|
4
|
-
var AntdTable_1 = require("./AntdTable");
|
|
5
|
-
Object.defineProperty(exports, "AntdTable", { enumerable: true, get: function () { return AntdTable_1.AntdTable; } });
|
|
6
|
-
var Footer_1 = require("./Footer");
|
|
7
|
-
Object.defineProperty(exports, "AkitableFooter", { enumerable: true, get: function () { return Footer_1.AkitableFooter; } });
|
|
8
|
-
var Header_1 = require("./Header");
|
|
9
|
-
Object.defineProperty(exports, "AkitableHeader", { enumerable: true, get: function () { return Header_1.AkitableHeader; } });
|
|
10
|
-
var HeaderActions_1 = require("./HeaderActions");
|
|
11
|
-
Object.defineProperty(exports, "HeaderActions", { enumerable: true, get: function () { return HeaderActions_1.HeaderActions; } });
|
|
12
|
-
var Pagination_1 = require("./Pagination");
|
|
13
|
-
Object.defineProperty(exports, "AkitablePagination", { enumerable: true, get: function () { return Pagination_1.AkitablePagination; } });
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { Dispatch } from 'react';
|
|
2
|
-
import type { AnyObject, HeaderAction, UseAkitablePagination } from '../types';
|
|
3
|
-
type IData = AnyObject;
|
|
4
|
-
export type AkitableContextProviderProps = {
|
|
5
|
-
useAkitablePagination: UseAkitablePagination;
|
|
6
|
-
headerActions?: HeaderAction<IData>[];
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
};
|
|
9
|
-
export type AkitableState = {
|
|
10
|
-
selectedRows: IData[];
|
|
11
|
-
};
|
|
12
|
-
export type AkitableAction = {
|
|
13
|
-
type: 'RESET';
|
|
14
|
-
} | {
|
|
15
|
-
type: 'SET_SELECTED_ROWS';
|
|
16
|
-
payload: AkitableState['selectedRows'];
|
|
17
|
-
};
|
|
18
|
-
export type AkitableContext = Omit<AkitableContextProviderProps, 'children'> & {
|
|
19
|
-
state: AkitableState;
|
|
20
|
-
dispatch: Dispatch<AkitableAction>;
|
|
21
|
-
};
|
|
22
|
-
export declare const AkitableContextProvider: ({ useAkitablePagination, headerActions, children }: AkitableContextProviderProps) => React.JSX.Element;
|
|
23
|
-
export declare const useAkitableContext: () => AkitableContext;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,QAAQ,EAAc,MAAM,OAAO,CAAC;AAGnE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE/E,KAAK,KAAK,GAAG,SAAS,CAAC;AAMvB,MAAM,MAAM,4BAA4B,GAAG;IACzC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,aAAa,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,EAAE,KAAK,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACxC,CAAC;AAEN,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,4BAA4B,EAAE,UAAU,CAAC,GAAG;IAC7E,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;CACpC,CAAC;AAIF,eAAO,MAAM,uBAAuB,uDAIjC,4BAA4B,sBA8B9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,uBAU9B,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAkitableContext = exports.AkitableContextProvider = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const use_immer_1 = require("use-immer");
|
|
6
|
-
const AkitableContext = (0, react_1.createContext)(undefined);
|
|
7
|
-
const AkitableContextProvider = ({ useAkitablePagination, headerActions, children }) => {
|
|
8
|
-
const initialState = {
|
|
9
|
-
selectedRows: []
|
|
10
|
-
};
|
|
11
|
-
const [state, dispatch] = (0, use_immer_1.useImmerReducer)((draft, action) => {
|
|
12
|
-
switch (action.type) {
|
|
13
|
-
case 'RESET':
|
|
14
|
-
return initialState;
|
|
15
|
-
case 'SET_SELECTED_ROWS':
|
|
16
|
-
draft.selectedRows = action.payload;
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
}, initialState);
|
|
20
|
-
return (react_1.default.createElement(AkitableContext.Provider, { value: {
|
|
21
|
-
state,
|
|
22
|
-
dispatch,
|
|
23
|
-
useAkitablePagination,
|
|
24
|
-
headerActions
|
|
25
|
-
} }, children));
|
|
26
|
-
};
|
|
27
|
-
exports.AkitableContextProvider = AkitableContextProvider;
|
|
28
|
-
const useAkitableContext = () => {
|
|
29
|
-
const context = (0, react_1.useContext)(AkitableContext);
|
|
30
|
-
if (context === undefined) {
|
|
31
|
-
throw new Error('useAkitableContext must be used within a AkitableContextProvider');
|
|
32
|
-
}
|
|
33
|
-
return context;
|
|
34
|
-
};
|
|
35
|
-
exports.useAkitableContext = useAkitableContext;
|
package/dist/cjs/index.css
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
.akitable-container {
|
|
2
|
-
border-radius: 10px;
|
|
3
|
-
width: 100%;
|
|
4
|
-
|
|
5
|
-
.row-action {
|
|
6
|
-
width: 40px;
|
|
7
|
-
height: 40px;
|
|
8
|
-
display: flex;
|
|
9
|
-
border: 1px solid rgba(0, 47, 255, 0.273);
|
|
10
|
-
border-radius: 7px;
|
|
11
|
-
align-items: center;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
margin-right: 5px;
|
|
14
|
-
|
|
15
|
-
i:before {
|
|
16
|
-
color: rgba(34, 34, 34, 0.713);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.akinon-table-wrapper {
|
|
21
|
-
.akinon-table-thead > tr > th {
|
|
22
|
-
color: var(--color-ebonyClay-375);
|
|
23
|
-
font-size: 0.75rem;
|
|
24
|
-
font-weight: 500;
|
|
25
|
-
padding: 6px 28px;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { TableProps } from 'antd/lib';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { AnyObject } from '../../types';
|
|
4
|
-
export type AntdTableProps<IData> = Omit<TableProps<IData>, 'title' | 'description' | 'pagination' | 'bordered'>;
|
|
5
|
-
export declare const AntdTable: <IData extends AnyObject>({ rowSelection, ...restProps }: AntdTableProps<IData>) => React.JSX.Element;
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/AntdTable/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,cAAc,CAAC,KAAK,IAAI,IAAI,CACtC,UAAU,CAAC,KAAK,CAAC,EACjB,OAAO,GAAG,aAAa,GAAG,YAAY,GAAG,UAAU,CACpD,CAAC;AAEF,eAAO,MAAM,SAAS,uGA6BrB,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { Table } from '@akinon/ui-table';
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { useAkitableContext } from '../../context';
|
|
15
|
-
export const AntdTable = (_a) => {
|
|
16
|
-
var { rowSelection } = _a, restProps = __rest(_a, ["rowSelection"]);
|
|
17
|
-
const { dispatch } = useAkitableContext();
|
|
18
|
-
const customRowSelection = rowSelection && Object.assign(Object.assign({}, rowSelection), { onChange: (selectedRowKeys, selectedRows) => {
|
|
19
|
-
// if akitable provides rowSelection.onChange, call it
|
|
20
|
-
if (rowSelection.onChange) {
|
|
21
|
-
rowSelection.onChange(selectedRowKeys, selectedRows, { type: 'all' });
|
|
22
|
-
}
|
|
23
|
-
dispatch({
|
|
24
|
-
type: 'SET_SELECTED_ROWS',
|
|
25
|
-
payload: selectedRows
|
|
26
|
-
});
|
|
27
|
-
} });
|
|
28
|
-
return (React.createElement(Table, Object.assign({ bordered: true, pagination: false, rowSelection: customRowSelection }, restProps)));
|
|
29
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Footer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,cAAc,yBAa1B,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import { Card } from '@akinon/ui-card';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { AkitablePagination } from '../index';
|
|
5
|
-
export const AkitableFooter = () => {
|
|
6
|
-
return (React.createElement(Card, { style: {
|
|
7
|
-
borderTopLeftRadius: 0,
|
|
8
|
-
borderTopRightRadius: 0
|
|
9
|
-
} },
|
|
10
|
-
React.createElement("div", { className: "akitable-footer" },
|
|
11
|
-
React.createElement(AkitablePagination, null))));
|
|
12
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
.akitable-header {
|
|
2
|
-
padding: 20px 32px 16px;
|
|
3
|
-
display: flex;
|
|
4
|
-
justify-content: space-between;
|
|
5
|
-
gap: 16px;
|
|
6
|
-
|
|
7
|
-
/* Push pagination to the right
|
|
8
|
-
even if table actions are hidden. */
|
|
9
|
-
& .akinon-pagination {
|
|
10
|
-
margin-left: auto;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&__left-block {
|
|
14
|
-
flex: 1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&__middle-block {
|
|
18
|
-
color: black;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&__right-block {
|
|
22
|
-
display: flex;
|
|
23
|
-
justify-content: flex-end;
|
|
24
|
-
align-items: flex-end;
|
|
25
|
-
flex-direction: column;
|
|
26
|
-
gap: 20px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&__export-options {
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
gap: 12px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&__export-option {
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: column;
|
|
39
|
-
justify-content: center;
|
|
40
|
-
align-items: center;
|
|
41
|
-
background-color: #4482ff;
|
|
42
|
-
color: white;
|
|
43
|
-
width: 36px;
|
|
44
|
-
height: 36px;
|
|
45
|
-
border-radius: 5px;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&__export-option-icon {
|
|
49
|
-
height: 16px;
|
|
50
|
-
& > i {
|
|
51
|
-
color: white;
|
|
52
|
-
margin: 0;
|
|
53
|
-
font-size: 10px;
|
|
54
|
-
font-weight: bold;
|
|
55
|
-
|
|
56
|
-
&::before {
|
|
57
|
-
color: white;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&__export-option-label {
|
|
63
|
-
font-weight: bold;
|
|
64
|
-
font-size: 11px;
|
|
65
|
-
user-select: none;
|
|
66
|
-
cursor: pointer;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&__info {
|
|
70
|
-
margin-bottom: 0.5rem;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&__title.akinon-typography {
|
|
74
|
-
font-size: 20px;
|
|
75
|
-
margin: 0.5rem 0 0.1rem;
|
|
76
|
-
font-weight: 700;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
&__description.akinon-typography {
|
|
80
|
-
font-size: 13px;
|
|
81
|
-
color: #797979;
|
|
82
|
-
font-weight: 400;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
interface AkitableHeaderProps {
|
|
4
|
-
title: string;
|
|
5
|
-
description: string;
|
|
6
|
-
headerMiddleBlock?: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const AkitableHeader: ({ title, description, headerMiddleBlock }: AkitableHeaderProps) => React.JSX.Element;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Header/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAIrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACrC;AAED,eAAO,MAAM,cAAc,8CAIxB,mBAAmB,sBA+BrB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import { Card } from '@akinon/ui-card';
|
|
3
|
-
import * as Typography from '@akinon/ui-typography';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { AkitablePagination, HeaderActions } from '../index';
|
|
6
|
-
const { Title, Text } = Typography;
|
|
7
|
-
export const AkitableHeader = ({ title, description, headerMiddleBlock }) => {
|
|
8
|
-
return (React.createElement(Card, { style: {
|
|
9
|
-
borderBottomLeftRadius: 0,
|
|
10
|
-
borderBottomRightRadius: 0
|
|
11
|
-
} },
|
|
12
|
-
React.createElement("div", { className: "akitable-header" },
|
|
13
|
-
React.createElement("div", { className: "akitable-header__left-block" },
|
|
14
|
-
React.createElement("div", { className: "akitable-header__info" },
|
|
15
|
-
React.createElement(Title, { className: "akitable-header__title", level: 5 }, title),
|
|
16
|
-
React.createElement(Text, { className: "akitable-header__description" }, description)),
|
|
17
|
-
React.createElement(HeaderActions, { placeholder: 'Please select an action', applyButtonLabel: 'Apply' })),
|
|
18
|
-
React.createElement("div", { className: "akitable-header__middle-block" }, headerMiddleBlock),
|
|
19
|
-
React.createElement("div", { className: "akitable-header__right-block" },
|
|
20
|
-
React.createElement(AkitablePagination, null)))));
|
|
21
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
.header-actions {
|
|
2
|
-
&__apply-button.akinon-btn {
|
|
3
|
-
font-weight: 600;
|
|
4
|
-
height: 40px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.akinon-select-single:not(.akinon-select-customize-input)
|
|
8
|
-
.akinon-select-selector {
|
|
9
|
-
box-sizing: border-box;
|
|
10
|
-
height: 40px;
|
|
11
|
-
align-items: center;
|
|
12
|
-
border-radius: 5px;
|
|
13
|
-
border: solid 1px #c8daec;
|
|
14
|
-
width: 150px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.akinon-select-focused:not(.akinon-select-disabled).akinon-select:not(
|
|
18
|
-
.akinon-select-customize-input
|
|
19
|
-
)
|
|
20
|
-
.akinon-select-selector {
|
|
21
|
-
border-right-width: 0 !important;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.akinon-select-arrow {
|
|
25
|
-
top: 70%;
|
|
26
|
-
}
|
|
27
|
-
.akinon-select-selector {
|
|
28
|
-
min-width: 220px;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
interface HeaderActionsProps {
|
|
4
|
-
placeholder: string;
|
|
5
|
-
applyButtonLabel: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const HeaderActions: ({ placeholder, applyButtonLabel }: HeaderActionsProps) => React.JSX.Element | undefined;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/HeaderActions/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAMrB,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,UAAU,kBAAkB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,aAAa,sCAGvB,kBAAkB,kCAwDpB,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
import { Button } from '@akinon/ui-button';
|
|
3
|
-
import { Select } from '@akinon/ui-select';
|
|
4
|
-
import { Space } from '@akinon/ui-space';
|
|
5
|
-
import React, { useState } from 'react';
|
|
6
|
-
import { useAkitableContext } from '../../context';
|
|
7
|
-
export const HeaderActions = ({ placeholder, applyButtonLabel }) => {
|
|
8
|
-
const [selectedActionIndex, setSelectedActionIndex] = useState(undefined);
|
|
9
|
-
const { state: { selectedRows }, headerActions } = useAkitableContext();
|
|
10
|
-
if (!headerActions)
|
|
11
|
-
return;
|
|
12
|
-
const actionOptions = headerActions.map((action, i) => {
|
|
13
|
-
return {
|
|
14
|
-
label: action.label,
|
|
15
|
-
value: i,
|
|
16
|
-
// do not check isSingleRequired in here but in action handler, since user can select multiple rows after selecting the action which will lead errors.
|
|
17
|
-
disabled: action.disabled
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
const handleActionApply = () => {
|
|
21
|
-
if (selectedActionIndex === undefined || selectedActionIndex === null)
|
|
22
|
-
return;
|
|
23
|
-
if ((selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) === 0)
|
|
24
|
-
return;
|
|
25
|
-
const selectedAction = headerActions[selectedActionIndex];
|
|
26
|
-
selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.handler(selectedRows);
|
|
27
|
-
};
|
|
28
|
-
const handleActionSelectChange = (value) => {
|
|
29
|
-
setSelectedActionIndex(value);
|
|
30
|
-
};
|
|
31
|
-
const isApplyButtonDisabled = selectedActionIndex === undefined || (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) === 0;
|
|
32
|
-
return (React.createElement(Space, { align: "baseline", className: "header-actions" },
|
|
33
|
-
React.createElement(Select, { value: selectedActionIndex, onChange: handleActionSelectChange, options: actionOptions, placeholder: placeholder, className: "header-actions__select" }),
|
|
34
|
-
React.createElement(Button, { disabled: isApplyButtonDisabled, className: "header-actions__apply-button", onClick: handleActionApply }, applyButtonLabel)));
|
|
35
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
.akitable-pagination-container {
|
|
2
|
-
display: flex;
|
|
3
|
-
|
|
4
|
-
.akinon-select-single:not(.akinon-select-customize-input)
|
|
5
|
-
.akinon-select-selector {
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
height: 40px;
|
|
8
|
-
align-items: center;
|
|
9
|
-
border-radius: 5px;
|
|
10
|
-
border: solid 1px #c8daec;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&__pagination.akinon-pagination {
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
border-radius: 5px;
|
|
17
|
-
|
|
18
|
-
li {
|
|
19
|
-
margin: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.akinon-pagination-prev,
|
|
23
|
-
.akinon-pagination-next {
|
|
24
|
-
width: 36px;
|
|
25
|
-
border-radius: 5px;
|
|
26
|
-
|
|
27
|
-
& > button {
|
|
28
|
-
color: #788195;
|
|
29
|
-
|
|
30
|
-
&:hover,
|
|
31
|
-
&:focus {
|
|
32
|
-
color: #788195;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.akinon-pagination-simple-pager {
|
|
38
|
-
color: #9b9b9b;
|
|
39
|
-
height: 40px;
|
|
40
|
-
border: 1px solid #c8daec;
|
|
41
|
-
margin-inline-end: unset !important;
|
|
42
|
-
padding-inline-end: 8px !important;
|
|
43
|
-
|
|
44
|
-
& > input {
|
|
45
|
-
color: #062a4a;
|
|
46
|
-
font-weight: 600;
|
|
47
|
-
border: 1px solid #c8daec;
|
|
48
|
-
border-radius: 0;
|
|
49
|
-
box-shadow: inset 0 0 2px 2px #eef0f2;
|
|
50
|
-
background-color: #fbfcfd;
|
|
51
|
-
|
|
52
|
-
&:hover {
|
|
53
|
-
border: 1px solid #c8daec;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.akinon-select-selector {
|
|
60
|
-
color: #9b9b9b !important;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* override antd style
|
|
64
|
-
apply every direct */
|
|
65
|
-
.akinon-pagination-prev {
|
|
66
|
-
height: 40px !important;
|
|
67
|
-
border: 1px solid #c8daec !important;
|
|
68
|
-
border-right: none !important;
|
|
69
|
-
border-top-right-radius: 0% !important;
|
|
70
|
-
border-bottom-right-radius: 0% !important;
|
|
71
|
-
> * {
|
|
72
|
-
height: inherit !important;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.akinon-pagination-next {
|
|
77
|
-
height: 40px !important;
|
|
78
|
-
border: 1px solid #c8daec !important;
|
|
79
|
-
border-left: none !important;
|
|
80
|
-
border-top-left-radius: 0% !important;
|
|
81
|
-
border-bottom-left-radius: 0% !important;
|
|
82
|
-
> * {
|
|
83
|
-
height: inherit !important;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
.akinon-pagination-slash {
|
|
87
|
-
margin-inline-end: 0px;
|
|
88
|
-
margin-inline-start: 12px;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.akinon-pagination-options {
|
|
92
|
-
height: 40px !important;
|
|
93
|
-
order: -1 !important; /* Places it at the beginning */
|
|
94
|
-
margin-right: 20px !important;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Pagination/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,kBAAkB,yBA2B9B,CAAC"}
|