@akinon/akitable 0.3.8 → 0.3.10
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.d.ts.map +1 -1
- package/dist/cjs/akitable.js +4 -4
- package/dist/cjs/common/theme-overrides.d.ts.map +1 -1
- package/dist/cjs/common/theme-overrides.js +8 -0
- package/dist/cjs/components/EditableCell.d.ts +13 -0
- package/dist/cjs/components/EditableCell.d.ts.map +1 -0
- package/dist/cjs/components/EditableCell.js +35 -0
- package/dist/cjs/components/datatable.d.ts.map +1 -1
- package/dist/cjs/components/datatable.js +60 -7
- package/dist/cjs/i18n/translations/en.d.ts +3 -0
- package/dist/cjs/i18n/translations/en.d.ts.map +1 -1
- package/dist/cjs/i18n/translations/en.js +4 -1
- package/dist/cjs/i18n/translations/tr.d.ts +3 -0
- package/dist/cjs/i18n/translations/tr.d.ts.map +1 -1
- package/dist/cjs/i18n/translations/tr.js +4 -1
- package/dist/cjs/types.d.ts +4 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/akitable.d.ts.map +1 -1
- package/dist/esm/akitable.js +4 -4
- package/dist/esm/common/theme-overrides.d.ts.map +1 -1
- package/dist/esm/common/theme-overrides.js +8 -0
- package/dist/esm/components/EditableCell.d.ts +13 -0
- package/dist/esm/components/EditableCell.d.ts.map +1 -0
- package/dist/esm/components/EditableCell.js +33 -0
- package/dist/esm/components/datatable.d.ts.map +1 -1
- package/dist/esm/components/datatable.js +60 -7
- package/dist/esm/i18n/translations/en.d.ts +3 -0
- package/dist/esm/i18n/translations/en.d.ts.map +1 -1
- package/dist/esm/i18n/translations/en.js +4 -1
- package/dist/esm/i18n/translations/tr.d.ts +3 -0
- package/dist/esm/i18n/translations/tr.d.ts.map +1 -1
- package/dist/esm/i18n/translations/tr.js +4 -1
- package/dist/esm/types.d.ts +4 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +7 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"akitable.d.ts","sourceRoot":"","sources":["../../src/akitable.tsx"],"names":[],"mappings":"AACA,OAAO,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"akitable.d.ts","sourceRoot":"","sources":["../../src/akitable.tsx"],"names":[],"mappings":"AACA,OAAO,gBAAgB,CAAC;AAGxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,EAAuC,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7E,eAAO,MAAM,QAAQ,UAAW,aAAa,sBAgE5C,CAAC"}
|
package/dist/cjs/akitable.js
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Akitable = void 0;
|
|
5
5
|
require("./akitable.css");
|
|
6
|
-
const react_error_boundary_1 = require("react-error-boundary");
|
|
7
6
|
const antd_1 = require("antd");
|
|
8
7
|
const react_1 = require("react");
|
|
8
|
+
const react_error_boundary_1 = require("react-error-boundary");
|
|
9
9
|
const akitable_context_1 = require("./akitable-context");
|
|
10
10
|
const theme_overrides_1 = require("./common/theme-overrides");
|
|
11
11
|
const controls_1 = require("./components/controls");
|
|
12
12
|
const datatable_1 = require("./components/datatable");
|
|
13
|
+
const error_1 = require("./components/error");
|
|
13
14
|
const footer_1 = require("./components/footer");
|
|
14
15
|
const header_1 = require("./components/header");
|
|
15
|
-
const error_1 = require("./components/error");
|
|
16
16
|
const Akitable = (props) => {
|
|
17
|
-
const { actions, columns, data, footer, header, isLoading, pagination, rowKey, onPaginationChanged, onRowClick } = props;
|
|
17
|
+
const { actions, columns, data, footer, header, isLoading, pagination, rowKey, onPaginationChanged, onRowClick, onRowEdit } = props;
|
|
18
18
|
let parsedData = [];
|
|
19
19
|
let total;
|
|
20
20
|
// If there is a pagination object, table data should be accessed from type AkitablePaginatedData.
|
|
@@ -35,7 +35,7 @@ const Akitable = (props) => {
|
|
|
35
35
|
react_1.default.createElement(antd_1.ConfigProvider, { theme: theme_overrides_1.themeOverrides },
|
|
36
36
|
react_1.default.createElement(header_1.AkitableHeader, Object.assign({}, header)),
|
|
37
37
|
react_1.default.createElement(controls_1.AkitableControls, null),
|
|
38
|
-
react_1.default.createElement(datatable_1.AkitableDataTable, { columns: columns, data: parsedData, rowKey: rowKey, onRowClick: onRowClick }),
|
|
38
|
+
react_1.default.createElement(datatable_1.AkitableDataTable, { columns: columns, data: parsedData, rowKey: rowKey, onRowClick: onRowClick, onRowEdit: onRowEdit }),
|
|
39
39
|
react_1.default.createElement(footer_1.AkitableFooter, Object.assign({}, footer)))))));
|
|
40
40
|
};
|
|
41
41
|
exports.Akitable = Akitable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-overrides.d.ts","sourceRoot":"","sources":["../../../src/common/theme-overrides.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,WAAW,EAAE,MAAM,MAAM,CAAC;AAEvD,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"theme-overrides.d.ts","sourceRoot":"","sources":["../../../src/common/theme-overrides.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,WAAW,EAAE,MAAM,MAAM,CAAC;AAEvD,eAAO,MAAM,cAAc,EAAE,WAmE5B,CAAC"}
|
|
@@ -60,6 +60,14 @@ exports.themeOverrides = {
|
|
|
60
60
|
colorBorder: ui_theme_1.theme.colors.azure['500'],
|
|
61
61
|
borderColorDisabled: ui_theme_1.theme.colors.neutral['350'],
|
|
62
62
|
algorithm: antd_1.theme.defaultAlgorithm
|
|
63
|
+
},
|
|
64
|
+
Input: {
|
|
65
|
+
colorBgContainer: ui_theme_1.theme.colors.neutral['50'],
|
|
66
|
+
colorBorder: ui_theme_1.theme.colors.neutral['350'],
|
|
67
|
+
colorText: ui_theme_1.theme.colors.neutral['950'],
|
|
68
|
+
colorTextDisabled: ui_theme_1.theme.colors.neutral['375'],
|
|
69
|
+
colorTextPlaceholder: ui_theme_1.theme.colors.neutral['375'],
|
|
70
|
+
algorithm: antd_1.theme.defaultAlgorithm
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './datatable.css';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AkitableData } from '../types';
|
|
4
|
+
interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
|
|
5
|
+
editing: boolean;
|
|
6
|
+
dataIndex: string | string[];
|
|
7
|
+
title: any;
|
|
8
|
+
record: AkitableData;
|
|
9
|
+
index: number;
|
|
10
|
+
}
|
|
11
|
+
declare const EditableCell: React.FC<React.PropsWithChildren<EditableCellProps>>;
|
|
12
|
+
export default EditableCell;
|
|
13
|
+
//# sourceMappingURL=EditableCell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableCell.d.ts","sourceRoot":"","sources":["../../../src/components/EditableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,UAAU,iBAAkB,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACnE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAoCtE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
require("./datatable.css");
|
|
15
|
+
const akiform_1 = require("@akinon/akiform");
|
|
16
|
+
const ui_input_1 = require("@akinon/ui-input");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const EditableCell = (_a) => {
|
|
19
|
+
var { editing, dataIndex, title, record, children } = _a, restProps = __rest(_a, ["editing", "dataIndex", "title", "record", "children"]);
|
|
20
|
+
let initialValue = null;
|
|
21
|
+
if (dataIndex && Array.isArray(dataIndex)) {
|
|
22
|
+
initialValue = dataIndex.reduce((acc, key) => acc === null || acc === void 0 ? void 0 : acc[key], record);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
initialValue = record === null || record === void 0 ? void 0 : record[dataIndex];
|
|
26
|
+
}
|
|
27
|
+
return (react_1.default.createElement("td", Object.assign({}, restProps), editing ? (react_1.default.createElement(akiform_1.Akiform.Item, { name: dataIndex, style: { margin: 0 }, rules: [
|
|
28
|
+
{
|
|
29
|
+
required: true,
|
|
30
|
+
message: `Missing ${title}!`
|
|
31
|
+
}
|
|
32
|
+
], initialValue: initialValue },
|
|
33
|
+
react_1.default.createElement(ui_input_1.Input, null))) : (children)));
|
|
34
|
+
};
|
|
35
|
+
exports.default = EditableCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datatable.d.ts","sourceRoot":"","sources":["../../../src/components/datatable.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"datatable.d.ts","sourceRoot":"","sources":["../../../src/components/datatable.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAOzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAgC,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAIhF,eAAO,MAAM,iBAAiB,UAAW,sBAAsB,sBAuH9D,CAAC"}
|
|
@@ -2,13 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AkitableDataTable = void 0;
|
|
4
4
|
require("./datatable.css");
|
|
5
|
+
const akiform_1 = require("@akinon/akiform");
|
|
6
|
+
const ui_button_1 = require("@akinon/ui-button");
|
|
5
7
|
const ui_table_1 = require("@akinon/ui-table");
|
|
8
|
+
const ui_typography_1 = require("@akinon/ui-typography");
|
|
6
9
|
const clsx_1 = require("clsx");
|
|
7
10
|
const react_1 = require("react");
|
|
8
11
|
const akitable_context_1 = require("../akitable-context");
|
|
12
|
+
const i18n_1 = require("../i18n");
|
|
13
|
+
const EditableCell_1 = require("./EditableCell");
|
|
14
|
+
const { t } = i18n_1.i18n;
|
|
9
15
|
const AkitableDataTable = (props) => {
|
|
10
16
|
const { isLoading, selectedRowKeys, setSelectedRowKeys, actions } = (0, akitable_context_1.useAkitableContext)();
|
|
11
|
-
const { columns, data, rowKey, onRowClick } = props;
|
|
17
|
+
const { columns, data, rowKey, onRowClick, onRowEdit } = props;
|
|
18
|
+
const [form] = akiform_1.Akiform.useForm();
|
|
19
|
+
const [localColumns, setLocalColumns] = react_1.default.useState(columns);
|
|
20
|
+
const [editingKey, setEditingKey] = react_1.default.useState(null);
|
|
12
21
|
const hasActions = actions && actions.length > 0;
|
|
13
22
|
const onSelectChange = (newSelectedRowKeys) => {
|
|
14
23
|
setSelectedRowKeys === null || setSelectedRowKeys === void 0 ? void 0 : setSelectedRowKeys(newSelectedRowKeys);
|
|
@@ -17,13 +26,57 @@ const AkitableDataTable = (props) => {
|
|
|
17
26
|
selectedRowKeys,
|
|
18
27
|
onChange: onSelectChange
|
|
19
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* If onRowEdit is provided:
|
|
31
|
+
* 1. Add an edit column to the end of columns
|
|
32
|
+
* 2. Look up the existing columns and if editable is set to true, add onCell method to the column
|
|
33
|
+
*/
|
|
34
|
+
react_1.default.useEffect(() => {
|
|
35
|
+
if (!onRowEdit) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const modifiedColumns = columns.map(column => {
|
|
39
|
+
if (!column.editable)
|
|
40
|
+
return column;
|
|
41
|
+
return Object.assign(Object.assign({}, column), { onCell: (record) => ({
|
|
42
|
+
record,
|
|
43
|
+
dataIndex: column.dataIndex,
|
|
44
|
+
title: column.title,
|
|
45
|
+
editing: record.id === editingKey
|
|
46
|
+
}) });
|
|
47
|
+
});
|
|
48
|
+
const editColumn = {
|
|
49
|
+
key: 'edit',
|
|
50
|
+
title: t('edit'),
|
|
51
|
+
render: (record) => {
|
|
52
|
+
const isRowEditing = record.id === editingKey;
|
|
53
|
+
return isRowEditing ? (react_1.default.createElement("span", null,
|
|
54
|
+
react_1.default.createElement(ui_button_1.Button, { type: "secondary", size: "small", onClick: () => {
|
|
55
|
+
onRowEdit(record, form.getFieldsValue());
|
|
56
|
+
setEditingKey(null);
|
|
57
|
+
form.resetFields();
|
|
58
|
+
} }, t('save')),
|
|
59
|
+
react_1.default.createElement(ui_typography_1.Text, { type: "danger", onClick: () => setEditingKey(null), style: { marginLeft: 8, cursor: 'pointer' } }, t('cancel')))) : (react_1.default.createElement(ui_button_1.Button, { type: "primary", size: "small", onClick: () => {
|
|
60
|
+
form.resetFields();
|
|
61
|
+
setEditingKey(record.id);
|
|
62
|
+
} }, t('edit')));
|
|
63
|
+
},
|
|
64
|
+
width: 200
|
|
65
|
+
};
|
|
66
|
+
setLocalColumns([...modifiedColumns, editColumn]);
|
|
67
|
+
}, [columns, onRowEdit, editingKey]);
|
|
20
68
|
return (react_1.default.createElement("div", { className: "akitable-wrapper" },
|
|
21
|
-
react_1.default.createElement(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
69
|
+
react_1.default.createElement(akiform_1.Akiform, { form: form, component: false },
|
|
70
|
+
react_1.default.createElement(ui_table_1.Table, { components: {
|
|
71
|
+
body: {
|
|
72
|
+
cell: EditableCell_1.default
|
|
25
73
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
74
|
+
}, columns: localColumns, dataSource: data, rowKey: (record) => record[rowKey], bordered: true, rowHoverable: true, pagination: false, scroll: { x: 'max-content', scrollToFirstRowOnChange: true }, loading: isLoading, onRow: (record, rowIndex) => {
|
|
75
|
+
return {
|
|
76
|
+
onClick: (event) => {
|
|
77
|
+
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(record, event, rowIndex);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, rowClassName: (0, clsx_1.default)({ 'is-selectable': !!onRowClick }), rowSelection: hasActions ? rowSelection : undefined }))));
|
|
28
81
|
};
|
|
29
82
|
exports.AkitableDataTable = AkitableDataTable;
|
|
@@ -8,6 +8,9 @@ declare const translations: {
|
|
|
8
8
|
readonly resultsFound: "{{count}} result(s) found.";
|
|
9
9
|
readonly selectAction: "Select Action";
|
|
10
10
|
readonly selectedCount: "Selected {{count}} record(s).";
|
|
11
|
+
readonly edit: "Edit";
|
|
12
|
+
readonly save: "Save";
|
|
13
|
+
readonly cancel: "Cancel";
|
|
11
14
|
};
|
|
12
15
|
export default translations;
|
|
13
16
|
//# sourceMappingURL=en.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;CAcR,CAAC;AAEX,eAAe,YAAY,CAAC"}
|
|
@@ -9,6 +9,9 @@ const translations = {
|
|
|
9
9
|
noData: 'No results found.',
|
|
10
10
|
resultsFound: '{{count}} result(s) found.',
|
|
11
11
|
selectAction: 'Select Action',
|
|
12
|
-
selectedCount: 'Selected {{count}} record(s).'
|
|
12
|
+
selectedCount: 'Selected {{count}} record(s).',
|
|
13
|
+
edit: 'Edit',
|
|
14
|
+
save: 'Save',
|
|
15
|
+
cancel: 'Cancel'
|
|
13
16
|
};
|
|
14
17
|
exports.default = translations;
|
|
@@ -8,6 +8,9 @@ declare const translations: {
|
|
|
8
8
|
readonly resultsFound: "{{count}} sonuç bulundu.";
|
|
9
9
|
readonly selectAction: "Aksiyon Seçiniz";
|
|
10
10
|
readonly selectedCount: "{{count}} kayit seçildi.";
|
|
11
|
+
readonly edit: "Düzenle";
|
|
12
|
+
readonly save: "Kaydet";
|
|
13
|
+
readonly cancel: "İptal";
|
|
11
14
|
};
|
|
12
15
|
export default translations;
|
|
13
16
|
//# sourceMappingURL=tr.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;CAcR,CAAC;AAEX,eAAe,YAAY,CAAC"}
|
|
@@ -9,6 +9,9 @@ const translations = {
|
|
|
9
9
|
noData: 'Kayıt bulunamadı.',
|
|
10
10
|
resultsFound: '{{count}} sonuç bulundu.',
|
|
11
11
|
selectAction: 'Aksiyon Seçiniz',
|
|
12
|
-
selectedCount: '{{count}} kayit seçildi.'
|
|
12
|
+
selectedCount: '{{count}} kayit seçildi.',
|
|
13
|
+
edit: 'Düzenle',
|
|
14
|
+
save: 'Kaydet',
|
|
15
|
+
cancel: 'İptal'
|
|
13
16
|
};
|
|
14
17
|
exports.default = translations;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TableColumnType } from 'antd';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
type RowClickEvent = (record: AkitableData, event?: React.MouseEvent<HTMLElement>, rowIndex?: number) => void;
|
|
4
|
+
type RowEditCallback = (modifiedRecord: AkitableData, payload: AkitableData) => void;
|
|
4
5
|
export type PaginationChangeEvent = (page: number, size: number) => void;
|
|
5
6
|
export interface AkitableProps {
|
|
6
7
|
actions?: AkitableAction[];
|
|
@@ -13,6 +14,7 @@ export interface AkitableProps {
|
|
|
13
14
|
rowKey: string;
|
|
14
15
|
onPaginationChanged?: PaginationChangeEvent;
|
|
15
16
|
onRowClick?: RowClickEvent;
|
|
17
|
+
onRowEdit?: RowEditCallback;
|
|
16
18
|
}
|
|
17
19
|
export interface AkitableHeaderProps {
|
|
18
20
|
title?: string;
|
|
@@ -26,6 +28,7 @@ export interface AkitableDataTableProps {
|
|
|
26
28
|
data: AkitableData[];
|
|
27
29
|
rowKey: string;
|
|
28
30
|
onRowClick?: RowClickEvent;
|
|
31
|
+
onRowEdit?: RowEditCallback;
|
|
29
32
|
}
|
|
30
33
|
export type AkitablePageSizes = 20 | 50 | 100 | 250;
|
|
31
34
|
export interface AkitablePaginationProps {
|
|
@@ -34,6 +37,7 @@ export interface AkitablePaginationProps {
|
|
|
34
37
|
}
|
|
35
38
|
export interface AkitableColumn extends TableColumnType<AkitableData> {
|
|
36
39
|
copyable?: boolean;
|
|
40
|
+
editable?: boolean;
|
|
37
41
|
}
|
|
38
42
|
export interface AkitableData {
|
|
39
43
|
[key: string]: any;
|
package/dist/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAA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,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,eAAe,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC;CAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"akitable.d.ts","sourceRoot":"","sources":["../../src/akitable.tsx"],"names":[],"mappings":"AACA,OAAO,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"akitable.d.ts","sourceRoot":"","sources":["../../src/akitable.tsx"],"names":[],"mappings":"AACA,OAAO,gBAAgB,CAAC;AAGxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,EAAuC,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7E,eAAO,MAAM,QAAQ,UAAW,aAAa,sBAgE5C,CAAC"}
|
package/dist/esm/akitable.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import './akitable.css';
|
|
3
|
-
import { ErrorBoundary } from 'react-error-boundary';
|
|
4
3
|
import { ConfigProvider } from 'antd';
|
|
5
4
|
import React from 'react';
|
|
5
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
6
6
|
import { AkitableProvider } from './akitable-context';
|
|
7
7
|
import { themeOverrides } from './common/theme-overrides';
|
|
8
8
|
import { AkitableControls } from './components/controls';
|
|
9
9
|
import { AkitableDataTable } from './components/datatable';
|
|
10
|
+
import { fallbackRender } from './components/error';
|
|
10
11
|
import { AkitableFooter } from './components/footer';
|
|
11
12
|
import { AkitableHeader } from './components/header';
|
|
12
|
-
import { fallbackRender } from './components/error';
|
|
13
13
|
export const Akitable = (props) => {
|
|
14
|
-
const { actions, columns, data, footer, header, isLoading, pagination, rowKey, onPaginationChanged, onRowClick } = props;
|
|
14
|
+
const { actions, columns, data, footer, header, isLoading, pagination, rowKey, onPaginationChanged, onRowClick, onRowEdit } = props;
|
|
15
15
|
let parsedData = [];
|
|
16
16
|
let total;
|
|
17
17
|
// If there is a pagination object, table data should be accessed from type AkitablePaginatedData.
|
|
@@ -32,6 +32,6 @@ export const Akitable = (props) => {
|
|
|
32
32
|
React.createElement(ConfigProvider, { theme: themeOverrides },
|
|
33
33
|
React.createElement(AkitableHeader, Object.assign({}, header)),
|
|
34
34
|
React.createElement(AkitableControls, null),
|
|
35
|
-
React.createElement(AkitableDataTable, { columns: columns, data: parsedData, rowKey: rowKey, onRowClick: onRowClick }),
|
|
35
|
+
React.createElement(AkitableDataTable, { columns: columns, data: parsedData, rowKey: rowKey, onRowClick: onRowClick, onRowEdit: onRowEdit }),
|
|
36
36
|
React.createElement(AkitableFooter, Object.assign({}, footer)))))));
|
|
37
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-overrides.d.ts","sourceRoot":"","sources":["../../../src/common/theme-overrides.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,WAAW,EAAE,MAAM,MAAM,CAAC;AAEvD,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"theme-overrides.d.ts","sourceRoot":"","sources":["../../../src/common/theme-overrides.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,WAAW,EAAE,MAAM,MAAM,CAAC;AAEvD,eAAO,MAAM,cAAc,EAAE,WAmE5B,CAAC"}
|
|
@@ -57,6 +57,14 @@ export const themeOverrides = {
|
|
|
57
57
|
colorBorder: theme.colors.azure['500'],
|
|
58
58
|
borderColorDisabled: theme.colors.neutral['350'],
|
|
59
59
|
algorithm: antdTheme.defaultAlgorithm
|
|
60
|
+
},
|
|
61
|
+
Input: {
|
|
62
|
+
colorBgContainer: theme.colors.neutral['50'],
|
|
63
|
+
colorBorder: theme.colors.neutral['350'],
|
|
64
|
+
colorText: theme.colors.neutral['950'],
|
|
65
|
+
colorTextDisabled: theme.colors.neutral['375'],
|
|
66
|
+
colorTextPlaceholder: theme.colors.neutral['375'],
|
|
67
|
+
algorithm: antdTheme.defaultAlgorithm
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './datatable.css';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AkitableData } from '../types';
|
|
4
|
+
interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
|
|
5
|
+
editing: boolean;
|
|
6
|
+
dataIndex: string | string[];
|
|
7
|
+
title: any;
|
|
8
|
+
record: AkitableData;
|
|
9
|
+
index: number;
|
|
10
|
+
}
|
|
11
|
+
declare const EditableCell: React.FC<React.PropsWithChildren<EditableCellProps>>;
|
|
12
|
+
export default EditableCell;
|
|
13
|
+
//# sourceMappingURL=EditableCell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableCell.d.ts","sourceRoot":"","sources":["../../../src/components/EditableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,UAAU,iBAAkB,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACnE,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAoCtE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 './datatable.css';
|
|
13
|
+
import { Akiform } from '@akinon/akiform';
|
|
14
|
+
import { Input } from '@akinon/ui-input';
|
|
15
|
+
import React from 'react';
|
|
16
|
+
const EditableCell = (_a) => {
|
|
17
|
+
var { editing, dataIndex, title, record, children } = _a, restProps = __rest(_a, ["editing", "dataIndex", "title", "record", "children"]);
|
|
18
|
+
let initialValue = null;
|
|
19
|
+
if (dataIndex && Array.isArray(dataIndex)) {
|
|
20
|
+
initialValue = dataIndex.reduce((acc, key) => acc === null || acc === void 0 ? void 0 : acc[key], record);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
initialValue = record === null || record === void 0 ? void 0 : record[dataIndex];
|
|
24
|
+
}
|
|
25
|
+
return (React.createElement("td", Object.assign({}, restProps), editing ? (React.createElement(Akiform.Item, { name: dataIndex, style: { margin: 0 }, rules: [
|
|
26
|
+
{
|
|
27
|
+
required: true,
|
|
28
|
+
message: `Missing ${title}!`
|
|
29
|
+
}
|
|
30
|
+
], initialValue: initialValue },
|
|
31
|
+
React.createElement(Input, null))) : (children)));
|
|
32
|
+
};
|
|
33
|
+
export default EditableCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datatable.d.ts","sourceRoot":"","sources":["../../../src/components/datatable.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"datatable.d.ts","sourceRoot":"","sources":["../../../src/components/datatable.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAOzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAgC,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAIhF,eAAO,MAAM,iBAAiB,UAAW,sBAAsB,sBAuH9D,CAAC"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import './datatable.css';
|
|
2
|
+
import { Akiform } from '@akinon/akiform';
|
|
3
|
+
import { Button } from '@akinon/ui-button';
|
|
2
4
|
import { Table } from '@akinon/ui-table';
|
|
5
|
+
import { Text } from '@akinon/ui-typography';
|
|
3
6
|
import clsx from 'clsx';
|
|
4
7
|
import React from 'react';
|
|
5
8
|
import { useAkitableContext } from '../akitable-context';
|
|
9
|
+
import { i18n } from '../i18n';
|
|
10
|
+
import EditableCell from './EditableCell';
|
|
11
|
+
const { t } = i18n;
|
|
6
12
|
export const AkitableDataTable = (props) => {
|
|
7
13
|
const { isLoading, selectedRowKeys, setSelectedRowKeys, actions } = useAkitableContext();
|
|
8
|
-
const { columns, data, rowKey, onRowClick } = props;
|
|
14
|
+
const { columns, data, rowKey, onRowClick, onRowEdit } = props;
|
|
15
|
+
const [form] = Akiform.useForm();
|
|
16
|
+
const [localColumns, setLocalColumns] = React.useState(columns);
|
|
17
|
+
const [editingKey, setEditingKey] = React.useState(null);
|
|
9
18
|
const hasActions = actions && actions.length > 0;
|
|
10
19
|
const onSelectChange = (newSelectedRowKeys) => {
|
|
11
20
|
setSelectedRowKeys === null || setSelectedRowKeys === void 0 ? void 0 : setSelectedRowKeys(newSelectedRowKeys);
|
|
@@ -14,12 +23,56 @@ export const AkitableDataTable = (props) => {
|
|
|
14
23
|
selectedRowKeys,
|
|
15
24
|
onChange: onSelectChange
|
|
16
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* If onRowEdit is provided:
|
|
28
|
+
* 1. Add an edit column to the end of columns
|
|
29
|
+
* 2. Look up the existing columns and if editable is set to true, add onCell method to the column
|
|
30
|
+
*/
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (!onRowEdit) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const modifiedColumns = columns.map(column => {
|
|
36
|
+
if (!column.editable)
|
|
37
|
+
return column;
|
|
38
|
+
return Object.assign(Object.assign({}, column), { onCell: (record) => ({
|
|
39
|
+
record,
|
|
40
|
+
dataIndex: column.dataIndex,
|
|
41
|
+
title: column.title,
|
|
42
|
+
editing: record.id === editingKey
|
|
43
|
+
}) });
|
|
44
|
+
});
|
|
45
|
+
const editColumn = {
|
|
46
|
+
key: 'edit',
|
|
47
|
+
title: t('edit'),
|
|
48
|
+
render: (record) => {
|
|
49
|
+
const isRowEditing = record.id === editingKey;
|
|
50
|
+
return isRowEditing ? (React.createElement("span", null,
|
|
51
|
+
React.createElement(Button, { type: "secondary", size: "small", onClick: () => {
|
|
52
|
+
onRowEdit(record, form.getFieldsValue());
|
|
53
|
+
setEditingKey(null);
|
|
54
|
+
form.resetFields();
|
|
55
|
+
} }, t('save')),
|
|
56
|
+
React.createElement(Text, { type: "danger", onClick: () => setEditingKey(null), style: { marginLeft: 8, cursor: 'pointer' } }, t('cancel')))) : (React.createElement(Button, { type: "primary", size: "small", onClick: () => {
|
|
57
|
+
form.resetFields();
|
|
58
|
+
setEditingKey(record.id);
|
|
59
|
+
} }, t('edit')));
|
|
60
|
+
},
|
|
61
|
+
width: 200
|
|
62
|
+
};
|
|
63
|
+
setLocalColumns([...modifiedColumns, editColumn]);
|
|
64
|
+
}, [columns, onRowEdit, editingKey]);
|
|
17
65
|
return (React.createElement("div", { className: "akitable-wrapper" },
|
|
18
|
-
React.createElement(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
66
|
+
React.createElement(Akiform, { form: form, component: false },
|
|
67
|
+
React.createElement(Table, { components: {
|
|
68
|
+
body: {
|
|
69
|
+
cell: EditableCell
|
|
22
70
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
71
|
+
}, columns: localColumns, dataSource: data, rowKey: (record) => record[rowKey], bordered: true, rowHoverable: true, pagination: false, scroll: { x: 'max-content', scrollToFirstRowOnChange: true }, loading: isLoading, onRow: (record, rowIndex) => {
|
|
72
|
+
return {
|
|
73
|
+
onClick: (event) => {
|
|
74
|
+
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(record, event, rowIndex);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}, rowClassName: clsx({ 'is-selectable': !!onRowClick }), rowSelection: hasActions ? rowSelection : undefined }))));
|
|
25
78
|
};
|
|
@@ -8,6 +8,9 @@ declare const translations: {
|
|
|
8
8
|
readonly resultsFound: "{{count}} result(s) found.";
|
|
9
9
|
readonly selectAction: "Select Action";
|
|
10
10
|
readonly selectedCount: "Selected {{count}} record(s).";
|
|
11
|
+
readonly edit: "Edit";
|
|
12
|
+
readonly save: "Save";
|
|
13
|
+
readonly cancel: "Cancel";
|
|
11
14
|
};
|
|
12
15
|
export default translations;
|
|
13
16
|
//# sourceMappingURL=en.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;CAcR,CAAC;AAEX,eAAe,YAAY,CAAC"}
|
|
@@ -7,6 +7,9 @@ const translations = {
|
|
|
7
7
|
noData: 'No results found.',
|
|
8
8
|
resultsFound: '{{count}} result(s) found.',
|
|
9
9
|
selectAction: 'Select Action',
|
|
10
|
-
selectedCount: 'Selected {{count}} record(s).'
|
|
10
|
+
selectedCount: 'Selected {{count}} record(s).',
|
|
11
|
+
edit: 'Edit',
|
|
12
|
+
save: 'Save',
|
|
13
|
+
cancel: 'Cancel'
|
|
11
14
|
};
|
|
12
15
|
export default translations;
|
|
@@ -8,6 +8,9 @@ declare const translations: {
|
|
|
8
8
|
readonly resultsFound: "{{count}} sonuç bulundu.";
|
|
9
9
|
readonly selectAction: "Aksiyon Seçiniz";
|
|
10
10
|
readonly selectedCount: "{{count}} kayit seçildi.";
|
|
11
|
+
readonly edit: "Düzenle";
|
|
12
|
+
readonly save: "Kaydet";
|
|
13
|
+
readonly cancel: "İptal";
|
|
11
14
|
};
|
|
12
15
|
export default translations;
|
|
13
16
|
//# sourceMappingURL=tr.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;CAcR,CAAC;AAEX,eAAe,YAAY,CAAC"}
|
|
@@ -7,6 +7,9 @@ const translations = {
|
|
|
7
7
|
noData: 'Kayıt bulunamadı.',
|
|
8
8
|
resultsFound: '{{count}} sonuç bulundu.',
|
|
9
9
|
selectAction: 'Aksiyon Seçiniz',
|
|
10
|
-
selectedCount: '{{count}} kayit seçildi.'
|
|
10
|
+
selectedCount: '{{count}} kayit seçildi.',
|
|
11
|
+
edit: 'Düzenle',
|
|
12
|
+
save: 'Kaydet',
|
|
13
|
+
cancel: 'İptal'
|
|
11
14
|
};
|
|
12
15
|
export default translations;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TableColumnType } from 'antd';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
type RowClickEvent = (record: AkitableData, event?: React.MouseEvent<HTMLElement>, rowIndex?: number) => void;
|
|
4
|
+
type RowEditCallback = (modifiedRecord: AkitableData, payload: AkitableData) => void;
|
|
4
5
|
export type PaginationChangeEvent = (page: number, size: number) => void;
|
|
5
6
|
export interface AkitableProps {
|
|
6
7
|
actions?: AkitableAction[];
|
|
@@ -13,6 +14,7 @@ export interface AkitableProps {
|
|
|
13
14
|
rowKey: string;
|
|
14
15
|
onPaginationChanged?: PaginationChangeEvent;
|
|
15
16
|
onRowClick?: RowClickEvent;
|
|
17
|
+
onRowEdit?: RowEditCallback;
|
|
16
18
|
}
|
|
17
19
|
export interface AkitableHeaderProps {
|
|
18
20
|
title?: string;
|
|
@@ -26,6 +28,7 @@ export interface AkitableDataTableProps {
|
|
|
26
28
|
data: AkitableData[];
|
|
27
29
|
rowKey: string;
|
|
28
30
|
onRowClick?: RowClickEvent;
|
|
31
|
+
onRowEdit?: RowEditCallback;
|
|
29
32
|
}
|
|
30
33
|
export type AkitablePageSizes = 20 | 50 | 100 | 250;
|
|
31
34
|
export interface AkitablePaginationProps {
|
|
@@ -34,6 +37,7 @@ export interface AkitablePaginationProps {
|
|
|
34
37
|
}
|
|
35
38
|
export interface AkitableColumn extends TableColumnType<AkitableData> {
|
|
36
39
|
copyable?: boolean;
|
|
40
|
+
editable?: boolean;
|
|
37
41
|
}
|
|
38
42
|
export interface AkitableData {
|
|
39
43
|
[key: string]: any;
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,KAAK,aAAa,GAAG,CACnB,MAAM,EAAE,YAAY,EACpB,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,EACrC,QAAQ,CAAC,EAAE,MAAM,KAC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,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,eAAe,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC;CAClD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/akitable",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
"clsx": "^2.0.0",
|
|
14
14
|
"react-error-boundary": "^4.0.13",
|
|
15
15
|
"@akinon/akilocale": "0.10.1",
|
|
16
|
-
"@akinon/ui-button": "0.5.0",
|
|
17
16
|
"@akinon/icons": "0.4.0",
|
|
18
|
-
"@akinon/ui-pagination": "0.3.0",
|
|
19
17
|
"@akinon/ui-card": "0.3.0",
|
|
18
|
+
"@akinon/ui-button": "0.5.0",
|
|
19
|
+
"@akinon/akiform": "0.7.0",
|
|
20
|
+
"@akinon/ui-input": "0.4.0",
|
|
21
|
+
"@akinon/ui-pagination": "0.3.0",
|
|
20
22
|
"@akinon/ui-result": "0.1.0",
|
|
21
23
|
"@akinon/ui-select": "0.3.0",
|
|
22
24
|
"@akinon/ui-skeleton": "0.3.0",
|
|
@@ -31,9 +33,9 @@
|
|
|
31
33
|
"copyfiles": "^2.4.1",
|
|
32
34
|
"rimraf": "^5.0.5",
|
|
33
35
|
"typescript": "^5.2.2",
|
|
36
|
+
"@akinon/vite-config": "0.4.0",
|
|
34
37
|
"@akinon/eslint-config": "0.1.0",
|
|
35
|
-
"@akinon/typescript-config": "0.2.0"
|
|
36
|
-
"@akinon/vite-config": "0.4.0"
|
|
38
|
+
"@akinon/typescript-config": "0.2.0"
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
39
41
|
"react": ">=18",
|