@akinon/akitable 0.5.0 → 1.0.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.
Files changed (51) hide show
  1. package/dist/cjs/akitable.d.ts +11 -0
  2. package/dist/cjs/akitable.d.ts.map +1 -1
  3. package/dist/cjs/akitable.js +33 -11
  4. package/dist/cjs/components/actions.js +3 -3
  5. package/dist/cjs/components/controls.js +2 -2
  6. package/dist/cjs/components/datatable.css +67 -20
  7. package/dist/cjs/components/datatable.d.ts.map +1 -1
  8. package/dist/cjs/components/datatable.js +55 -18
  9. package/dist/cjs/components/footer.d.ts.map +1 -1
  10. package/dist/cjs/components/footer.js +2 -2
  11. package/dist/cjs/components/header.css +33 -1
  12. package/dist/cjs/components/header.d.ts.map +1 -1
  13. package/dist/cjs/components/header.js +19 -11
  14. package/dist/cjs/components/pagination.css +1 -1
  15. package/dist/cjs/components/pagination.d.ts.map +1 -1
  16. package/dist/cjs/components/pagination.js +19 -4
  17. package/dist/cjs/i18n/translations/en.d.ts +1 -0
  18. package/dist/cjs/i18n/translations/en.d.ts.map +1 -1
  19. package/dist/cjs/i18n/translations/en.js +2 -1
  20. package/dist/cjs/i18n/translations/tr.d.ts +2 -1
  21. package/dist/cjs/i18n/translations/tr.d.ts.map +1 -1
  22. package/dist/cjs/i18n/translations/tr.js +3 -2
  23. package/dist/cjs/types.d.ts +100 -1
  24. package/dist/cjs/types.d.ts.map +1 -1
  25. package/dist/cjs/types.js +5 -0
  26. package/dist/esm/akitable.d.ts +11 -0
  27. package/dist/esm/akitable.d.ts.map +1 -1
  28. package/dist/esm/akitable.js +33 -11
  29. package/dist/esm/components/actions.js +3 -3
  30. package/dist/esm/components/controls.js +2 -2
  31. package/dist/esm/components/datatable.css +67 -20
  32. package/dist/esm/components/datatable.d.ts.map +1 -1
  33. package/dist/esm/components/datatable.js +55 -18
  34. package/dist/esm/components/footer.d.ts.map +1 -1
  35. package/dist/esm/components/footer.js +2 -2
  36. package/dist/esm/components/header.css +33 -1
  37. package/dist/esm/components/header.d.ts.map +1 -1
  38. package/dist/esm/components/header.js +19 -11
  39. package/dist/esm/components/pagination.css +1 -1
  40. package/dist/esm/components/pagination.d.ts.map +1 -1
  41. package/dist/esm/components/pagination.js +19 -4
  42. package/dist/esm/i18n/translations/en.d.ts +1 -0
  43. package/dist/esm/i18n/translations/en.d.ts.map +1 -1
  44. package/dist/esm/i18n/translations/en.js +2 -1
  45. package/dist/esm/i18n/translations/tr.d.ts +2 -1
  46. package/dist/esm/i18n/translations/tr.d.ts.map +1 -1
  47. package/dist/esm/i18n/translations/tr.js +3 -2
  48. package/dist/esm/types.d.ts +100 -1
  49. package/dist/esm/types.d.ts.map +1 -1
  50. package/dist/esm/types.js +4 -1
  51. package/package.json +22 -21
@@ -1,5 +1,16 @@
1
1
  import './akitable.css';
2
2
  import React from 'react';
3
3
  import { AkitableProps } from './types';
4
+ /**
5
+ * Akitable component for Akinon UI.
6
+ *
7
+ * The Akitable component is a versatile and feature-rich table component designed for displaying,
8
+ * editing, and interacting with tabular data. It supports custom columns, pagination, row actions,
9
+ * and event callbacks for enhanced user experience and flexibility.
10
+ *
11
+ * Features include row click/edit actions, customizable headers and footers, pagination controls,
12
+ * and integration with Akinon design system standards. It is ideal for complex data visualization
13
+ * needs in enterprise applications.
14
+ */
4
15
  export declare const Akitable: (props: AkitableProps) => React.JSX.Element;
5
16
  //# sourceMappingURL=akitable.d.ts.map
@@ -1 +1 @@
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"}
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;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,QAAQ,UAAW,aAAa,sBAuF5C,CAAC"}
@@ -13,22 +13,44 @@ const datatable_1 = require("./components/datatable");
13
13
  const error_1 = require("./components/error");
14
14
  const footer_1 = require("./components/footer");
15
15
  const header_1 = require("./components/header");
16
+ /**
17
+ * Akitable component for Akinon UI.
18
+ *
19
+ * The Akitable component is a versatile and feature-rich table component designed for displaying,
20
+ * editing, and interacting with tabular data. It supports custom columns, pagination, row actions,
21
+ * and event callbacks for enhanced user experience and flexibility.
22
+ *
23
+ * Features include row click/edit actions, customizable headers and footers, pagination controls,
24
+ * and integration with Akinon design system standards. It is ideal for complex data visualization
25
+ * needs in enterprise applications.
26
+ */
16
27
  const Akitable = (props) => {
17
28
  const { actions, columns, data, footer, header, isLoading, pagination, rowKey, onPaginationChanged, onRowClick, onRowEdit } = props;
18
- let parsedData = [];
19
- let total;
29
+ const handleGetSplittedDataByPagination = ({ result }) => {
30
+ if (!pagination)
31
+ return result;
32
+ const { page, size } = pagination;
33
+ const startIndex = (page - 1) * size;
34
+ const endIndex = startIndex + size;
35
+ return result.slice(startIndex, endIndex);
36
+ };
20
37
  // If there is a pagination object, table data should be accessed from type AkitablePaginatedData.
21
38
  // If not, table data should be accessed from type AkitableData.
22
- if (pagination) {
39
+ const handleGetParsedData = () => {
40
+ if (pagination) {
41
+ const result = data;
42
+ const total = (result === null || result === void 0 ? void 0 : result.count) || 0;
43
+ const parsedData = handleGetSplittedDataByPagination({
44
+ result: (result === null || result === void 0 ? void 0 : result.results) || []
45
+ });
46
+ return { total, parsedData };
47
+ }
23
48
  const result = data;
24
- total = (result === null || result === void 0 ? void 0 : result.count) || 0;
25
- parsedData = (result === null || result === void 0 ? void 0 : result.results) || [];
26
- }
27
- else {
28
- const result = data;
29
- total = (result === null || result === void 0 ? void 0 : result.length) || 0;
30
- parsedData = result || [];
31
- }
49
+ const total = (result === null || result === void 0 ? void 0 : result.length) || 0;
50
+ const parsedData = result || [];
51
+ return { total, parsedData };
52
+ };
53
+ const { total, parsedData } = handleGetParsedData();
32
54
  return (react_1.default.createElement("div", { className: "akitable-container" },
33
55
  react_1.default.createElement(react_error_boundary_1.ErrorBoundary, { fallbackRender: error_1.fallbackRender },
34
56
  react_1.default.createElement(akitable_context_1.AkitableProvider, { actions: actions, isLoading: isLoading, pagination: Object.assign(Object.assign({}, pagination), { total, hasPagination: !!pagination }), onPaginationChanged: onPaginationChanged },
@@ -20,13 +20,13 @@ const AkitableActions = () => {
20
20
  setSelectedAction(value);
21
21
  };
22
22
  const handleActionTrigger = () => {
23
- if (!selectedAction || !selectedRowKeys || selectedRowKeys.length === 0)
23
+ if (!selectedAction || !hasSelections)
24
24
  return;
25
25
  const action = actions === null || actions === void 0 ? void 0 : actions.find((_, index) => index === selectedAction - 1);
26
26
  action === null || action === void 0 ? void 0 : action.onSelect(selectedRowKeys);
27
27
  };
28
- return (react_1.default.createElement("div", { className: "akitable-actions" },
29
- react_1.default.createElement(ui_select_1.Select, { placeholder: t('selectAction'), value: selectedAction, options: options, onChange: value => handleActionChange(value), disabled: isLoading || (pagination === null || pagination === void 0 ? void 0 : pagination.total) === 0, allowClear: true }),
28
+ return (react_1.default.createElement("div", { "data-testid": "akitable-actions", className: "akitable-actions" },
29
+ react_1.default.createElement(ui_select_1.Select, { placeholder: t('selectAction'), value: selectedAction, options: options, onChange: value => handleActionChange(value), disabled: isLoading || (pagination === null || pagination === void 0 ? void 0 : pagination.total) === 0, allowClear: true, "data-testid": "akitable-actions-select" }),
30
30
  selectedAction && (react_1.default.createElement(react_1.default.Fragment, null,
31
31
  react_1.default.createElement(ui_button_1.Button, { type: "primary", icon: "katalogkontrol", disabled: isLoading || !hasSelections, onClick: handleActionTrigger }, t('apply')),
32
32
  hasSelections && (react_1.default.createElement("span", { className: "akitable-actions-info" }, t('selectedCount', { count: selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length })))))));
@@ -10,9 +10,9 @@ const AkitableControls = () => {
10
10
  const { actions, pagination } = (0, akitable_context_1.useAkitableContext)();
11
11
  if (!actions)
12
12
  return null;
13
- return (react_1.default.createElement("div", { className: "akitable-controls" },
13
+ return (react_1.default.createElement("div", { "data-testid": "akitable-controls", className: "akitable-controls" },
14
14
  actions && actions.length > 0 && react_1.default.createElement(actions_1.AkitableActions, null),
15
- (pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination) && (react_1.default.createElement("div", { className: "ml-auto" },
15
+ (pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination) && (react_1.default.createElement("div", { "data-testid": "akitable-controls-pagination", className: "ml-auto" },
16
16
  react_1.default.createElement(pagination_1.AkitablePagination, null)))));
17
17
  };
18
18
  exports.AkitableControls = AkitableControls;
@@ -1,4 +1,10 @@
1
- .akinon-table-wrapper .akinon-table-thead > tr > th {
1
+ .akitable-wrapper {
2
+ margin-left: -1.5rem;
3
+ margin-right: -1.5rem;
4
+ margin-bottom: 1rem;
5
+ }
6
+
7
+ .akitable-wrapper .akinon-table-wrapper .akinon-table-thead > tr > th {
2
8
  text-transform: uppercase;
3
9
  font-size: 0.75rem;
4
10
  font-weight: 600;
@@ -6,50 +12,91 @@
6
12
  padding-top: 0.65rem;
7
13
  }
8
14
 
9
- .akitable-wrapper {
10
- margin-left: -1.5rem;
11
- margin-right: -1.5rem;
12
- margin-bottom: 1rem;
13
- }
14
-
15
- .akinon-table-content {
15
+ .akitable-wrapper .akinon-table-content {
16
16
  scrollbar-color: auto;
17
17
  scrollbar-width: auto;
18
18
  }
19
19
 
20
- .akinon-table-content::-webkit-scrollbar {
20
+ .akitable-wrapper .akinon-table-content::-webkit-scrollbar {
21
21
  height: 8px;
22
22
  }
23
23
 
24
- .akinon-table-content::-webkit-scrollbar-track {
24
+ .akitable-wrapper .akinon-table-content::-webkit-scrollbar-track {
25
25
  background-color: var(--color-neutral-100);
26
26
  border: none;
27
27
  padding: 1px;
28
28
  }
29
29
 
30
- .akinon-table-content::-webkit-scrollbar-thumb {
30
+ .akitable-wrapper .akinon-table-content::-webkit-scrollbar-thumb {
31
31
  background-color: var(--color-neutral-300);
32
32
  border-radius: 3px;
33
33
  border: none;
34
34
  }
35
35
 
36
36
  /* Add background for alternate rows. */
37
- .akinon-table-row:nth-child(odd) td {
38
- background-color: var(--color-neutral-100);
37
+ .akitable-wrapper .akinon-table-row:nth-child(odd) {
38
+ background-color: var(--color-neutral-75);
39
39
  }
40
40
 
41
- .akinon-table-row.is-selectable {
41
+ .akitable-wrapper .akinon-table-row.is-selectable {
42
42
  cursor: pointer;
43
- }
44
-
45
- .akinon-table-row.is-selectable td {
46
43
  transition: background-color 0.2s;
47
44
  }
48
45
 
49
- .akinon-table-row.is-selectable:hover td {
50
- background-color: var(--color-blue-100) !important;
46
+ .akitable-wrapper .akinon-table-row.is-selectable:hover {
47
+ background-color: var(--color-blue-100);
51
48
  }
52
49
 
53
- .akinon-table-row.is-selectable:hover td[class*='akinon-table-cell-fix-'] {
50
+ .akitable-wrapper
51
+ .akinon-table-row.is-selectable:hover
52
+ td[class*='akinon-table-cell-fix-'] {
54
53
  background-color: var(--color-blue-200) !important;
55
54
  }
55
+
56
+ .akitable-wrapper .akinon-table-row.akitable-row-pending {
57
+ background-color: var(--color-green-952-10);
58
+ position: relative;
59
+ }
60
+
61
+ .akitable-wrapper .akinon-table-cell {
62
+ z-index: 1;
63
+ }
64
+
65
+ .akitable-wrapper .akinon-table-row.akitable-row-pending::after {
66
+ content: '';
67
+ position: absolute;
68
+ top: 0;
69
+ left: 0;
70
+ right: 0;
71
+ bottom: 0;
72
+ background: repeating-linear-gradient(
73
+ 60deg,
74
+ transparent 0px,
75
+ transparent 18px,
76
+ var(--color-green-952-15) 18px,
77
+ var(--color-green-952-15) 36px,
78
+ transparent 36px
79
+ );
80
+ animation: shimmer 20s linear infinite;
81
+ }
82
+
83
+ @keyframes shimmer {
84
+ 0% {
85
+ left: -100%;
86
+ }
87
+ 100% {
88
+ left: -4.82596083%;
89
+ }
90
+ }
91
+
92
+ .akitable-wrapper .akinon-table-row.akitable-row-error {
93
+ background-color: var(--color-red-425-10);
94
+ }
95
+
96
+ .akitable-wrapper .akinon-table-tbody tr:last-child td {
97
+ border-bottom: 1px solid var(--color-neutral-350);
98
+ }
99
+
100
+ .akitable-wrapper .akinon-table-row .akinon-table-edit-button--disable {
101
+ cursor: not-allowed;
102
+ }
@@ -1 +1 @@
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,sBAsH9D,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,EAGL,sBAAsB,EAEvB,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,iBAAiB,UAAW,sBAAsB,sBAoK9D,CAAC"}
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.AkitableDataTable = void 0;
4
13
  require("./datatable.css");
@@ -10,6 +19,7 @@ const clsx_1 = require("clsx");
10
19
  const react_1 = require("react");
11
20
  const akitable_context_1 = require("../akitable-context");
12
21
  const i18n_1 = require("../i18n");
22
+ const types_1 = require("../types");
13
23
  const EditableCell_1 = require("./EditableCell");
14
24
  const { t } = i18n_1.i18n;
15
25
  const AkitableDataTable = (props) => {
@@ -18,7 +28,10 @@ const AkitableDataTable = (props) => {
18
28
  const [form] = akiform_1.Akiform.useForm();
19
29
  const [localColumns, setLocalColumns] = react_1.default.useState(columns);
20
30
  const [editingKey, setEditingKey] = react_1.default.useState(null);
31
+ const [isLoadingSaveButton, setIsLoadingSaveButton] = react_1.default.useState(false);
21
32
  const hasActions = actions && actions.length > 0;
33
+ const getRowKeyData = (record) => record[rowKey];
34
+ const checkIsEditingRow = (recordId) => recordId === editingKey;
22
35
  const onSelectChange = (newSelectedRowKeys) => {
23
36
  setSelectedRowKeys === null || setSelectedRowKeys === void 0 ? void 0 : setSelectedRowKeys(newSelectedRowKeys);
24
37
  };
@@ -33,6 +46,7 @@ const AkitableDataTable = (props) => {
33
46
  */
34
47
  react_1.default.useEffect(() => {
35
48
  if (!onRowEdit) {
49
+ setLocalColumns(columns);
36
50
  return;
37
51
  }
38
52
  const modifiedColumns = columns.map(column => {
@@ -42,41 +56,64 @@ const AkitableDataTable = (props) => {
42
56
  record,
43
57
  dataIndex: column.dataIndex,
44
58
  title: column.title,
45
- editing: record.id === editingKey
59
+ editing: checkIsEditingRow(getRowKeyData(record))
46
60
  }) });
47
61
  });
48
62
  const editColumn = {
49
63
  key: 'edit',
50
64
  title: t('edit'),
51
65
  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, { 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: () => {
66
+ const isRowEditing = checkIsEditingRow(getRowKeyData(record));
67
+ const handleOnClickSaveButton = () => __awaiter(void 0, void 0, void 0, function* () {
68
+ try {
69
+ setIsLoadingSaveButton(true);
70
+ yield onRowEdit(record, form.getFieldsValue());
71
+ setEditingKey(null);
60
72
  form.resetFields();
61
- setEditingKey(record.id);
62
- } }, t('edit')));
73
+ }
74
+ finally {
75
+ setIsLoadingSaveButton(false);
76
+ }
77
+ });
78
+ const handleOnClickEditButton = (e) => {
79
+ if (!isLoadingSaveButton) {
80
+ form.resetFields();
81
+ setEditingKey(getRowKeyData(record));
82
+ }
83
+ e.stopPropagation(); // To prevent row click event
84
+ };
85
+ const handleOnClickCancelButton = () => {
86
+ setEditingKey(null);
87
+ };
88
+ return isRowEditing ? (react_1.default.createElement("span", null,
89
+ react_1.default.createElement(ui_button_1.Button, { size: "small", onClick: handleOnClickSaveButton, loading: isLoadingSaveButton }, t('save')),
90
+ react_1.default.createElement(ui_typography_1.Text, Object.assign({ type: "danger", disabled: isLoadingSaveButton, className: "cursor-pointer ml-2" }, (!isLoadingSaveButton && {
91
+ onClick: handleOnClickCancelButton
92
+ })), t('cancel')))) : (react_1.default.createElement(ui_button_1.Button, { type: "primary", size: "small", onClick: handleOnClickEditButton, className: (0, clsx_1.default)({
93
+ 'akinon-table-edit-button--disable': isLoadingSaveButton
94
+ }) }, t('edit')));
63
95
  },
64
96
  width: 200
65
97
  };
66
98
  setLocalColumns([...modifiedColumns, editColumn]);
67
- }, [columns, onRowEdit, editingKey]);
68
- return (react_1.default.createElement("div", { className: "akitable-wrapper" },
99
+ }, [columns, onRowEdit, editingKey, isLoadingSaveButton]);
100
+ return (react_1.default.createElement("div", { "data-testid": "akitable-datatable-wrapper", className: "akitable-wrapper" },
69
101
  react_1.default.createElement(akiform_1.Akiform, { form: form, component: false },
70
- react_1.default.createElement(ui_table_1.Table, { components: {
102
+ react_1.default.createElement(ui_table_1.Table, { "data-testid": "akitable-datatable", components: {
71
103
  body: {
72
104
  cell: EditableCell_1.default
73
105
  }
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 {
106
+ }, columns: localColumns, dataSource: data, rowKey: (record) => getRowKeyData(record), bordered: true, rowHoverable: true, pagination: false, scroll: { x: 'max-content', scrollToFirstRowOnChange: true }, loading: isLoading, onRow: (record, rowIndex) => {
107
+ const isEditingRow = checkIsEditingRow(getRowKeyData(record));
108
+ return Object.assign({}, (!isEditingRow && {
76
109
  onClick: (event) => {
77
110
  onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(record, event, rowIndex);
78
111
  }
79
- };
80
- }, rowClassName: (0, clsx_1.default)({ 'is-selectable': !!onRowClick }), rowSelection: hasActions ? rowSelection : undefined }))));
112
+ }));
113
+ }, rowClassName: (record) => (0, clsx_1.default)({
114
+ 'is-selectable': !!onRowClick && !checkIsEditingRow(getRowKeyData(record)),
115
+ 'akitable-row-pending': record.rowStatus === types_1.AkitableRowStatus.PENDING,
116
+ 'akitable-row-error': record.rowStatus === types_1.AkitableRowStatus.ERROR
117
+ }), rowSelection: hasActions ? rowSelection : undefined }))));
81
118
  };
82
119
  exports.AkitableDataTable = AkitableDataTable;
@@ -1 +1 @@
1
- {"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../src/components/footer.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAGtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,cAAc,UAAW,mBAAmB,6BAkBxD,CAAC"}
1
+ {"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../src/components/footer.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAGtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,cAAc,UAAW,mBAAmB,6BAsBxD,CAAC"}
@@ -11,8 +11,8 @@ const AkitableFooter = (props) => {
11
11
  const { extra } = props;
12
12
  if (!extra && !(pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination))
13
13
  return null;
14
- return (react_1.default.createElement("div", { className: "akitable-footer" },
15
- extra && (react_1.default.createElement("div", { className: "akitable-footer-extra" }, isLoading ? react_1.default.createElement(ui_spin_1.Spin, null) : extra)),
14
+ return (react_1.default.createElement("div", { "data-testid": "akitable-footer", className: "akitable-footer" },
15
+ extra && (react_1.default.createElement("div", { className: "akitable-footer-extra" }, isLoading ? (react_1.default.createElement(ui_spin_1.Spin, { "data-testid": "akitable-footer-extra-loading-skeleton" })) : (extra))),
16
16
  react_1.default.createElement("div", { className: "ml-auto" },
17
17
  react_1.default.createElement(pagination_1.AkitablePagination, null))));
18
18
  };
@@ -5,13 +5,40 @@
5
5
  min-height: 40px;
6
6
  }
7
7
 
8
+ .akitable-header-title-container {
9
+ display: flex;
10
+ align-items: center;
11
+ gap: 0.1rem;
12
+ color: var(--color-gray-900);
13
+ }
14
+
8
15
  .akitable-header-title {
9
16
  font-size: 1.25rem;
10
17
  font-weight: bold;
11
18
  margin: 0;
12
19
  padding: 0;
13
20
  line-height: 1;
14
- color: var(--color-gray-900);
21
+ display: flex;
22
+ align-items: center;
23
+ }
24
+
25
+ .akitable-header-title-count-skeleton {
26
+ width: 50px;
27
+ height: 20px;
28
+ margin-left: 0.7rem;
29
+ }
30
+
31
+ .akitable-header-title-count {
32
+ font-size: 1.25rem;
33
+ font-weight: bold;
34
+ margin: 0;
35
+ padding: 0;
36
+ line-height: 1;
37
+ }
38
+
39
+ .akitable-header-title-description-skeleton {
40
+ width: 120px;
41
+ height: 10px;
15
42
  }
16
43
 
17
44
  .akitable-header-description {
@@ -20,6 +47,11 @@
20
47
  margin-top: 0.5rem;
21
48
  }
22
49
 
50
+ .akitable-header-extra-content {
51
+ margin-bottom: 1rem;
52
+ color: var(--color-gray-300);
53
+ }
54
+
23
55
  .akitable-header-extra {
24
56
  margin-left: auto;
25
57
  text-align: right;
@@ -1 +1 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/components/header.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAItB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,cAAc,UAAW,mBAAmB,6BAyCxD,CAAC"}
1
+ {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/components/header.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAItB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,cAAc,UAAW,mBAAmB,6BA4ExD,CAAC"}
@@ -14,18 +14,26 @@ const AkitableHeader = (props) => {
14
14
  const hasActions = actions && (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
15
15
  if (!title && !extra)
16
16
  return null;
17
- return (react_1.default.createElement("div", { className: "akitable-header" },
18
- title && (react_1.default.createElement("div", null,
19
- react_1.default.createElement("h2", { className: "akitable-header-title" },
20
- title,
21
- " ",
22
- !isLoading && `(${pagination === null || pagination === void 0 ? void 0 : pagination.total})`),
23
- !isLoading && !!(pagination === null || pagination === void 0 ? void 0 : pagination.total) && (react_1.default.createElement("span", { className: "akitable-header-description" }, i18n_1.i18n.t('resultsFound', { count: pagination === null || pagination === void 0 ? void 0 : pagination.total }))),
24
- !isLoading && !(pagination === null || pagination === void 0 ? void 0 : pagination.total) && (react_1.default.createElement("span", { className: "akitable-header-description" }, i18n_1.i18n.t('noData'))),
25
- isLoading && react_1.default.createElement(ui_skeleton_1.Skeleton, { count: 0.7, className: "mt-2" }))),
17
+ const renderTitle = () => {
18
+ return (react_1.default.createElement("div", { className: "akitable-header-title-container" },
19
+ react_1.default.createElement("h2", { className: "akitable-header-title" }, title),
20
+ isLoading ? (react_1.default.createElement("span", { "data-testid": "akitable-title-loading-skeleton" },
21
+ react_1.default.createElement(ui_skeleton_1.Skeleton.Button, { active: true, size: "small", className: "ml-1" }))) : (react_1.default.createElement("span", { className: "akitable-header-title-count" }, `(${pagination === null || pagination === void 0 ? void 0 : pagination.total})`))));
22
+ };
23
+ const renderTitleDescription = () => {
24
+ const descriptionContent = !(pagination === null || pagination === void 0 ? void 0 : pagination.total)
25
+ ? i18n_1.i18n.t('noData')
26
+ : i18n_1.i18n.t('resultsFound', { count: pagination === null || pagination === void 0 ? void 0 : pagination.total });
27
+ return (react_1.default.createElement("span", { "data-testid": "akitable-header-description", className: "akitable-header-description" }, descriptionContent));
28
+ };
29
+ return (react_1.default.createElement("div", { "data-testid": "akitable-header", className: "akitable-header" },
30
+ !!title && (react_1.default.createElement("div", { "data-testid": "akitable-header-title-container" },
31
+ renderTitle(),
32
+ isLoading ? (react_1.default.createElement("span", { "data-testid": "akitable-title-description-loading-skeleton" },
33
+ react_1.default.createElement(ui_skeleton_1.Skeleton.Input, { active: true, size: "small", className: "mt-2" }))) : (renderTitleDescription()))),
26
34
  react_1.default.createElement("div", { className: "akitable-header-extra" },
27
- extra && react_1.default.createElement("div", { className: "mb-4" }, isLoading ? react_1.default.createElement(ui_spin_1.Spin, null) : extra),
28
- !hasActions && (pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination) && (react_1.default.createElement("div", null,
35
+ extra && (react_1.default.createElement("div", { "data-testid": "akitable-header-extra-content", className: "akitable-header-extra-content" }, isLoading ? (react_1.default.createElement(ui_spin_1.Spin, { "data-testid": "akitable-header-extra-loading-skeleton" })) : (extra))),
36
+ !hasActions && (pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination) && (react_1.default.createElement("div", { "data-testid": "akitable-header-pagination" },
29
37
  react_1.default.createElement(pagination_1.AkitablePagination, null))))));
30
38
  };
31
39
  exports.AkitableHeader = AkitableHeader;
@@ -1,3 +1,3 @@
1
- .akinon-pagination-options .akinon-select {
1
+ .akitable-pagination .akinon-pagination-options .akinon-select {
2
2
  height: 38px;
3
3
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/components/pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,eAAO,MAAM,kBAAkB,yBAoB9B,CAAC"}
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/components/pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,eAAO,MAAM,kBAAkB,yBAuC9B,CAAC"}
@@ -6,12 +6,27 @@ const ui_pagination_1 = require("@akinon/ui-pagination");
6
6
  const react_1 = require("react");
7
7
  const akitable_context_1 = require("../akitable-context");
8
8
  const i18n_1 = require("../i18n");
9
+ const PAGE_SIZE_OPTIONS = [20, 50, 100, 250];
9
10
  const AkitablePagination = () => {
10
11
  const { isLoading, pagination, onPaginationChanged } = (0, akitable_context_1.useAkitableContext)();
11
12
  const { t } = i18n_1.i18n;
12
- return (react_1.default.createElement("div", null,
13
- react_1.default.createElement(ui_pagination_1.Pagination, { simple: true, disabled: isLoading || (pagination === null || pagination === void 0 ? void 0 : pagination.total) === 0, current: pagination === null || pagination === void 0 ? void 0 : pagination.page, pageSize: pagination === null || pagination === void 0 ? void 0 : pagination.size, pageSizeOptions: [20, 50, 100, 250], total: pagination === null || pagination === void 0 ? void 0 : pagination.total, onChange: (page, size) => onPaginationChanged === null || onPaginationChanged === void 0 ? void 0 : onPaginationChanged(page, size), locale: {
14
- items_per_page: t('itemsPerPage')
15
- } })));
13
+ const totalPagination = (pagination === null || pagination === void 0 ? void 0 : pagination.total) || 0;
14
+ const hasItems = totalPagination > 0;
15
+ const locale = {
16
+ items_per_page: t('itemsPerPage')
17
+ };
18
+ const handleShowTotal = (total, range) => {
19
+ return t('paginationShowTotal', {
20
+ from: range[0],
21
+ to: range[1],
22
+ total
23
+ });
24
+ };
25
+ const handleOnChange = (page, size) => {
26
+ onPaginationChanged === null || onPaginationChanged === void 0 ? void 0 : onPaginationChanged(page, size);
27
+ return null;
28
+ };
29
+ return (react_1.default.createElement("div", { className: "akitable-pagination" },
30
+ react_1.default.createElement(ui_pagination_1.Pagination, { disabled: isLoading || !hasItems, current: pagination === null || pagination === void 0 ? void 0 : pagination.page, pageSize: pagination === null || pagination === void 0 ? void 0 : pagination.size, pageSizeOptions: PAGE_SIZE_OPTIONS, total: totalPagination, showTotal: handleShowTotal, showSizeChanger: true, onChange: handleOnChange, locale: locale, theme: "light" })));
16
31
  };
17
32
  exports.AkitablePagination = AkitablePagination;
@@ -11,6 +11,7 @@ declare const translations: {
11
11
  readonly edit: "Edit";
12
12
  readonly save: "Save";
13
13
  readonly cancel: "Cancel";
14
+ readonly paginationShowTotal: "{{from}}-{{to}} of {{total}} items";
14
15
  };
15
16
  export default translations;
16
17
  //# 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;;;;;;;;;;;;;CAcR,CAAC;AAEX,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/en.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;CAeR,CAAC;AAEX,eAAe,YAAY,CAAC"}
@@ -12,6 +12,7 @@ const translations = {
12
12
  selectedCount: 'Selected {{count}} record(s).',
13
13
  edit: 'Edit',
14
14
  save: 'Save',
15
- cancel: 'Cancel'
15
+ cancel: 'Cancel',
16
+ paginationShowTotal: '{{from}}-{{to}} of {{total}} items'
16
17
  };
17
18
  exports.default = translations;
@@ -7,10 +7,11 @@ declare const translations: {
7
7
  readonly noData: "Kayıt bulunamadı.";
8
8
  readonly resultsFound: "{{count}} sonuç bulundu.";
9
9
  readonly selectAction: "Aksiyon Seçiniz";
10
- readonly selectedCount: "{{count}} kayit seçildi.";
10
+ readonly selectedCount: "{{count}} kayıt seçildi.";
11
11
  readonly edit: "Düzenle";
12
12
  readonly save: "Kaydet";
13
13
  readonly cancel: "İptal";
14
+ readonly paginationShowTotal: "{{from}}-{{to}} / {{total}} kayıt";
14
15
  };
15
16
  export default translations;
16
17
  //# 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;;;;;;;;;;;;;CAcR,CAAC;AAEX,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"tr.d.ts","sourceRoot":"","sources":["../../../../src/i18n/translations/tr.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;CAeR,CAAC;AAEX,eAAe,YAAY,CAAC"}
@@ -9,9 +9,10 @@ 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}} kayıt seçildi.',
13
13
  edit: 'Düzenle',
14
14
  save: 'Kaydet',
15
- cancel: 'İptal'
15
+ cancel: 'İptal',
16
+ paginationShowTotal: '{{from}}-{{to}} / {{total}} kayıt'
16
17
  };
17
18
  exports.default = translations;