@akinon/akitable 0.3.0 → 0.3.5

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 (45) hide show
  1. package/dist/cjs/akitable.css +33 -0
  2. package/dist/cjs/akitable.d.ts +1 -1
  3. package/dist/cjs/akitable.d.ts.map +1 -1
  4. package/dist/cjs/akitable.js +16 -12
  5. package/dist/cjs/components/actions.d.ts.map +1 -1
  6. package/dist/cjs/components/actions.js +2 -2
  7. package/dist/cjs/components/controls.js +1 -1
  8. package/dist/cjs/components/error.css +12 -0
  9. package/dist/cjs/components/error.d.ts +5 -0
  10. package/dist/cjs/components/error.d.ts.map +1 -0
  11. package/dist/cjs/components/error.js +16 -0
  12. package/dist/cjs/components/footer.js +2 -2
  13. package/dist/cjs/components/header.css +1 -0
  14. package/dist/cjs/components/header.d.ts.map +1 -1
  15. package/dist/cjs/components/header.js +9 -3
  16. package/dist/cjs/components/pagination.js +1 -1
  17. package/dist/cjs/i18n/translations/en.d.ts +6 -2
  18. package/dist/cjs/i18n/translations/en.d.ts.map +1 -1
  19. package/dist/cjs/i18n/translations/en.js +7 -3
  20. package/dist/cjs/i18n/translations/tr.d.ts +6 -2
  21. package/dist/cjs/i18n/translations/tr.d.ts.map +1 -1
  22. package/dist/cjs/i18n/translations/tr.js +7 -3
  23. package/dist/esm/akitable.css +33 -0
  24. package/dist/esm/akitable.d.ts +1 -1
  25. package/dist/esm/akitable.d.ts.map +1 -1
  26. package/dist/esm/akitable.js +16 -12
  27. package/dist/esm/components/actions.d.ts.map +1 -1
  28. package/dist/esm/components/actions.js +2 -2
  29. package/dist/esm/components/controls.js +1 -1
  30. package/dist/esm/components/error.css +12 -0
  31. package/dist/esm/components/error.d.ts +5 -0
  32. package/dist/esm/components/error.d.ts.map +1 -0
  33. package/dist/esm/components/error.js +12 -0
  34. package/dist/esm/components/footer.js +2 -2
  35. package/dist/esm/components/header.css +1 -0
  36. package/dist/esm/components/header.d.ts.map +1 -1
  37. package/dist/esm/components/header.js +9 -3
  38. package/dist/esm/components/pagination.js +1 -1
  39. package/dist/esm/i18n/translations/en.d.ts +6 -2
  40. package/dist/esm/i18n/translations/en.d.ts.map +1 -1
  41. package/dist/esm/i18n/translations/en.js +7 -3
  42. package/dist/esm/i18n/translations/tr.d.ts +6 -2
  43. package/dist/esm/i18n/translations/tr.d.ts.map +1 -1
  44. package/dist/esm/i18n/translations/tr.js +7 -3
  45. package/package.json +12 -10
@@ -0,0 +1,33 @@
1
+ .akitable-container {
2
+ background-color: white;
3
+ border-radius: 0.5rem;
4
+ padding: 1.5rem;
5
+ }
6
+
7
+ /* For some weird reason, antd does not allow overriding
8
+ styles for empty component. Needed to override it w/ css
9
+ */
10
+ .akitable-container .akinon-empty {
11
+ font-size: 1.5rem;
12
+ text-align: center;
13
+ margin-bottom: 5rem;
14
+ margin-top: 5rem;
15
+ }
16
+
17
+ .akitable-container .akinon-empty .akinon-empty-image svg ellipse {
18
+ fill: var(--color-neutral-200);
19
+ }
20
+
21
+ .akitable-container .akinon-empty .akinon-empty-image svg path {
22
+ fill: var(--color-neutral-150);
23
+ }
24
+
25
+ .akitable-container .akinon-empty .akinon-empty-image svg g {
26
+ stroke: var(--color-neutral-300);
27
+ }
28
+
29
+ .akitable-container .akinon-empty .akinon-empty-description {
30
+ color: var(--color-neutral-400);
31
+ font-size: 1rem;
32
+ margin-top: 1rem;
33
+ }
@@ -1,4 +1,4 @@
1
- import './index.css';
1
+ import './akitable.css';
2
2
  import React from 'react';
3
3
  import { AkitableProps } from './types';
4
4
  export declare const Akitable: (props: AkitableProps) => React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"akitable.d.ts","sourceRoot":"","sources":["../../src/akitable.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,EAAuC,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7E,eAAO,MAAM,QAAQ,UAAW,aAAa,sBA4D5C,CAAC"}
1
+ {"version":3,"file":"akitable.d.ts","sourceRoot":"","sources":["../../src/akitable.tsx"],"names":[],"mappings":"AACA,OAAO,gBAAgB,CAAC;AAIxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,EAAuC,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7E,eAAO,MAAM,QAAQ,UAAW,aAAa,sBA8D5C,CAAC"}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ 'use client';
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.Akitable = void 0;
4
- require("./index.css");
5
+ require("./akitable.css");
6
+ const react_error_boundary_1 = require("react-error-boundary");
5
7
  const antd_1 = require("antd");
6
8
  const react_1 = require("react");
7
9
  const akitable_context_1 = require("./akitable-context");
@@ -10,6 +12,7 @@ const controls_1 = require("./components/controls");
10
12
  const datatable_1 = require("./components/datatable");
11
13
  const footer_1 = require("./components/footer");
12
14
  const header_1 = require("./components/header");
15
+ const error_1 = require("./components/error");
13
16
  const Akitable = (props) => {
14
17
  const { actions, columns, data, footer, header, isLoading, pagination, rowKey, onPaginationChanged, onRowClick } = props;
15
18
  let parsedData = [];
@@ -18,20 +21,21 @@ const Akitable = (props) => {
18
21
  // If not, table data should be accessed from type AkitableData.
19
22
  if (!!pagination) {
20
23
  const result = data;
21
- total = result.count;
22
- parsedData = result.results;
24
+ total = (result === null || result === void 0 ? void 0 : result.count) || 0;
25
+ parsedData = (result === null || result === void 0 ? void 0 : result.results) || [];
23
26
  }
24
27
  else {
25
28
  const result = data;
26
- total = result.length;
27
- parsedData = result;
29
+ total = (result === null || result === void 0 ? void 0 : result.length) || 0;
30
+ parsedData = result || [];
28
31
  }
29
- return (react_1.default.createElement(akitable_context_1.AkitableProvider, { actions: actions, isLoading: isLoading, pagination: Object.assign(Object.assign({}, pagination), { total, hasPagination: !!pagination }), onPaginationChanged: onPaginationChanged },
30
- react_1.default.createElement(antd_1.ConfigProvider, { theme: theme_overrides_1.themeOverrides },
31
- react_1.default.createElement("div", { className: "akitable-container" },
32
- react_1.default.createElement(header_1.AkitableHeader, Object.assign({}, header)),
33
- react_1.default.createElement(controls_1.AkitableControls, null),
34
- react_1.default.createElement(datatable_1.AkitableDataTable, { columns: columns, data: parsedData, rowKey: rowKey, onRowClick: onRowClick }),
35
- react_1.default.createElement(footer_1.AkitableFooter, Object.assign({}, footer))))));
32
+ return (react_1.default.createElement("div", { className: "akitable-container" },
33
+ react_1.default.createElement(react_error_boundary_1.ErrorBoundary, { fallbackRender: error_1.fallbackRender },
34
+ react_1.default.createElement(akitable_context_1.AkitableProvider, { actions: actions, isLoading: isLoading, pagination: Object.assign(Object.assign({}, pagination), { total, hasPagination: !!pagination }), onPaginationChanged: onPaginationChanged },
35
+ react_1.default.createElement(antd_1.ConfigProvider, { theme: theme_overrides_1.themeOverrides },
36
+ react_1.default.createElement(header_1.AkitableHeader, Object.assign({}, header)),
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 }),
39
+ react_1.default.createElement(footer_1.AkitableFooter, Object.assign({}, footer)))))));
36
40
  };
37
41
  exports.Akitable = Akitable;
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/components/actions.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAKvB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,eAAO,MAAM,eAAe,yBA+D3B,CAAC"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/components/actions.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAKvB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,eAAO,MAAM,eAAe,yBAgE3B,CAAC"}
@@ -11,7 +11,7 @@ const i18n_1 = require("../i18n");
11
11
  const AkitableActions = () => {
12
12
  const { t } = i18n_1.i18n;
13
13
  const [selectedAction, setSelectedAction] = react_1.default.useState(undefined);
14
- const { actions, isLoading, selectedRowKeys } = (0, akitable_context_1.useAkitableContext)();
14
+ const { actions, isLoading, selectedRowKeys, pagination } = (0, akitable_context_1.useAkitableContext)();
15
15
  const options = actions === null || actions === void 0 ? void 0 : actions.map((action, index) => ({
16
16
  value: index + 1,
17
17
  label: action.label
@@ -27,7 +27,7 @@ const AkitableActions = () => {
27
27
  action === null || action === void 0 ? void 0 : action.onSelect(selectedRowKeys);
28
28
  };
29
29
  return (react_1.default.createElement("div", { className: "akitable-actions" },
30
- react_1.default.createElement(ui_select_1.Select, { placeholder: t('selectAction'), value: selectedAction, options: options, onChange: handleActionChange, disabled: isLoading, allowClear: true }),
30
+ react_1.default.createElement(ui_select_1.Select, { placeholder: t('selectAction'), value: selectedAction, options: options, onChange: handleActionChange, disabled: isLoading || (pagination === null || pagination === void 0 ? void 0 : pagination.total) === 0, allowClear: true }),
31
31
  selectedAction && (react_1.default.createElement(react_1.default.Fragment, null,
32
32
  react_1.default.createElement(ui_button_1.Button, { type: "primary", icon: react_1.default.createElement(icons_1.Icon, { icon: "katalogkontrol", size: 14, style: { position: 'relative', top: 2 } }), disabled: isLoading || !hasSelections, onClick: handleActionTrigger }, t('apply')),
33
33
  hasSelections && (react_1.default.createElement("span", { className: "akitable-actions-info" }, t('selectedCount', { count: selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length })))))));
@@ -8,7 +8,7 @@ const actions_1 = require("./actions");
8
8
  const pagination_1 = require("./pagination");
9
9
  const AkitableControls = () => {
10
10
  const { actions, pagination } = (0, akitable_context_1.useAkitableContext)();
11
- if (!actions && !(pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination))
11
+ if (!actions)
12
12
  return null;
13
13
  return (react_1.default.createElement("div", { className: "akitable-controls" },
14
14
  actions && actions.length > 0 && react_1.default.createElement(actions_1.AkitableActions, null),
@@ -0,0 +1,12 @@
1
+ .akitable-error {
2
+ padding-bottom: 4rem;
3
+ padding-top: 4rem;
4
+ }
5
+
6
+ .akitable-error .akinon-result-title {
7
+ color: var(--color-ebonyClay-700);
8
+ }
9
+
10
+ .akitable-error .akinon-result-subtitle {
11
+ color: var(--color-neutral-400);
12
+ }
@@ -0,0 +1,5 @@
1
+ import './error.css';
2
+ import React from 'react';
3
+ import { FallbackProps } from 'react-error-boundary';
4
+ export declare const fallbackRender: ({ resetErrorBoundary }: FallbackProps) => React.JSX.Element;
5
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/components/error.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,eAAO,MAAM,cAAc,2BAA4B,aAAa,sBAiBnE,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fallbackRender = void 0;
4
+ require("./error.css");
5
+ const react_1 = require("react");
6
+ const ui_result_1 = require("@akinon/ui-result");
7
+ const ui_button_1 = require("@akinon/ui-button");
8
+ const i18n_1 = require("../i18n");
9
+ const fallbackRender = ({ resetErrorBoundary }) => {
10
+ const { t } = i18n_1.i18n;
11
+ return (react_1.default.createElement("div", { className: "akitable-error" },
12
+ react_1.default.createElement(ui_result_1.Result, { status: "error", title: t('errorTitle'), subTitle: t('errorDescription'), extra: [
13
+ react_1.default.createElement(ui_button_1.Button, { type: "primary", onClick: resetErrorBoundary }, t('errorButtonText'))
14
+ ] })));
15
+ };
16
+ exports.fallbackRender = fallbackRender;
@@ -7,9 +7,9 @@ const react_1 = require("react");
7
7
  const akitable_context_1 = require("../akitable-context");
8
8
  const pagination_1 = require("./pagination");
9
9
  const AkitableFooter = (props) => {
10
- const { isLoading } = (0, akitable_context_1.useAkitableContext)();
10
+ const { isLoading, pagination } = (0, akitable_context_1.useAkitableContext)();
11
11
  const { extra } = props;
12
- if (!extra)
12
+ if (!extra && !(pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination))
13
13
  return null;
14
14
  return (react_1.default.createElement("div", { className: "akitable-footer" },
15
15
  extra && (react_1.default.createElement("div", { className: "akitable-footer-extra" }, isLoading ? react_1.default.createElement(ui_spin_1.Spin, null) : extra)),
@@ -20,4 +20,5 @@
20
20
 
21
21
  .akitable-header-extra {
22
22
  margin-left: auto;
23
+ text-align: right;
23
24
  }
@@ -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;AAE/C,eAAO,MAAM,cAAc,UAAW,mBAAmB,6BA8BxD,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,6BAyCxD,CAAC"}
@@ -7,9 +7,11 @@ const ui_spin_1 = require("@akinon/ui-spin");
7
7
  const react_1 = require("react");
8
8
  const akitable_context_1 = require("../akitable-context");
9
9
  const i18n_1 = require("../i18n");
10
+ const pagination_1 = require("./pagination");
10
11
  const AkitableHeader = (props) => {
11
- const { isLoading, pagination } = (0, akitable_context_1.useAkitableContext)();
12
+ const { isLoading, pagination, actions } = (0, akitable_context_1.useAkitableContext)();
12
13
  const { title, extra } = props;
14
+ const hasActions = actions && (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
13
15
  if (!title && !extra)
14
16
  return null;
15
17
  return (react_1.default.createElement("div", { className: "akitable-header" },
@@ -18,8 +20,12 @@ const AkitableHeader = (props) => {
18
20
  title,
19
21
  " ",
20
22
  !isLoading && `(${pagination === null || pagination === void 0 ? void 0 : pagination.total})`),
21
- !isLoading && (react_1.default.createElement("span", { className: "akitable-header-description" }, i18n_1.i18n.t('resultsFound', { count: 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'))),
22
25
  isLoading && react_1.default.createElement(ui_skeleton_1.Skeleton, { count: 0.7, className: "mt-2" }))),
23
- extra && (react_1.default.createElement("div", { className: "akitable-header-extra" }, isLoading ? react_1.default.createElement(ui_spin_1.Spin, null) : extra))));
26
+ 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,
29
+ react_1.default.createElement(pagination_1.AkitablePagination, null))))));
24
30
  };
25
31
  exports.AkitableHeader = AkitableHeader;
@@ -10,7 +10,7 @@ const AkitablePagination = () => {
10
10
  const { isLoading, pagination, onPaginationChanged } = (0, akitable_context_1.useAkitableContext)();
11
11
  const { t } = i18n_1.i18n;
12
12
  return (react_1.default.createElement("div", null,
13
- react_1.default.createElement(ui_pagination_1.Pagination, { simple: true, disabled: isLoading, 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: {
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
14
  items_per_page: t('itemsPerPage')
15
15
  } })));
16
16
  };
@@ -1,9 +1,13 @@
1
1
  declare const translations: {
2
- readonly resultsFound: "{{count}} result(s) found.";
2
+ readonly apply: "Apply";
3
+ readonly errorTitle: "Error!";
4
+ readonly errorDescription: "There's been an internal error with Akitable component Please try again.";
5
+ readonly errorButtonText: "Try Again";
3
6
  readonly itemsPerPage: "/ page";
7
+ readonly noData: "No results found.";
8
+ readonly resultsFound: "{{count}} result(s) found.";
4
9
  readonly selectAction: "Select Action";
5
10
  readonly selectedCount: "Selected {{count}} record(s).";
6
- readonly apply: "Apply";
7
11
  };
8
12
  export default translations;
9
13
  //# 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;;;;;;CAMR,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;;;;;;;;;;CAWR,CAAC;AAEX,eAAe,YAAY,CAAC"}
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const translations = {
4
- resultsFound: '{{count}} result(s) found.',
4
+ apply: 'Apply',
5
+ errorTitle: 'Error!',
6
+ errorDescription: "There's been an internal error with Akitable component Please try again.",
7
+ errorButtonText: 'Try Again',
5
8
  itemsPerPage: '/ page',
9
+ noData: 'No results found.',
10
+ resultsFound: '{{count}} result(s) found.',
6
11
  selectAction: 'Select Action',
7
- selectedCount: 'Selected {{count}} record(s).',
8
- apply: 'Apply'
12
+ selectedCount: 'Selected {{count}} record(s).'
9
13
  };
10
14
  exports.default = translations;
@@ -1,9 +1,13 @@
1
1
  declare const translations: {
2
- readonly resultsFound: "{{count}} sonuç bulundu.";
2
+ readonly apply: "Uygula";
3
+ readonly errorTitle: "Hata!";
4
+ readonly errorDescription: "Akitable bileşeniyle ilgili bir iç hata oluştu. Lütfen tekrar deneyiniz.";
5
+ readonly errorButtonText: "Tekrar Dene";
3
6
  readonly itemsPerPage: "/ sayfa";
7
+ readonly noData: "Kayıt bulunamadı.";
8
+ readonly resultsFound: "{{count}} sonuç bulundu.";
4
9
  readonly selectAction: "Aksiyon Seçiniz";
5
10
  readonly selectedCount: "{{count}} kayit seçildi.";
6
- readonly apply: "Uygula";
7
11
  };
8
12
  export default translations;
9
13
  //# 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;;;;;;CAMR,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;;;;;;;;;;CAWR,CAAC;AAEX,eAAe,YAAY,CAAC"}
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const translations = {
4
- resultsFound: '{{count}} sonuç bulundu.',
4
+ apply: 'Uygula',
5
+ errorTitle: 'Hata!',
6
+ errorDescription: 'Akitable bileşeniyle ilgili bir iç hata oluştu. Lütfen tekrar deneyiniz.',
7
+ errorButtonText: 'Tekrar Dene',
5
8
  itemsPerPage: '/ sayfa',
9
+ noData: 'Kayıt bulunamadı.',
10
+ resultsFound: '{{count}} sonuç bulundu.',
6
11
  selectAction: 'Aksiyon Seçiniz',
7
- selectedCount: '{{count}} kayit seçildi.',
8
- apply: 'Uygula'
12
+ selectedCount: '{{count}} kayit seçildi.'
9
13
  };
10
14
  exports.default = translations;
@@ -0,0 +1,33 @@
1
+ .akitable-container {
2
+ background-color: white;
3
+ border-radius: 0.5rem;
4
+ padding: 1.5rem;
5
+ }
6
+
7
+ /* For some weird reason, antd does not allow overriding
8
+ styles for empty component. Needed to override it w/ css
9
+ */
10
+ .akitable-container .akinon-empty {
11
+ font-size: 1.5rem;
12
+ text-align: center;
13
+ margin-bottom: 5rem;
14
+ margin-top: 5rem;
15
+ }
16
+
17
+ .akitable-container .akinon-empty .akinon-empty-image svg ellipse {
18
+ fill: var(--color-neutral-200);
19
+ }
20
+
21
+ .akitable-container .akinon-empty .akinon-empty-image svg path {
22
+ fill: var(--color-neutral-150);
23
+ }
24
+
25
+ .akitable-container .akinon-empty .akinon-empty-image svg g {
26
+ stroke: var(--color-neutral-300);
27
+ }
28
+
29
+ .akitable-container .akinon-empty .akinon-empty-description {
30
+ color: var(--color-neutral-400);
31
+ font-size: 1rem;
32
+ margin-top: 1rem;
33
+ }
@@ -1,4 +1,4 @@
1
- import './index.css';
1
+ import './akitable.css';
2
2
  import React from 'react';
3
3
  import { AkitableProps } from './types';
4
4
  export declare const Akitable: (props: AkitableProps) => React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"akitable.d.ts","sourceRoot":"","sources":["../../src/akitable.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,EAAuC,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7E,eAAO,MAAM,QAAQ,UAAW,aAAa,sBA4D5C,CAAC"}
1
+ {"version":3,"file":"akitable.d.ts","sourceRoot":"","sources":["../../src/akitable.tsx"],"names":[],"mappings":"AACA,OAAO,gBAAgB,CAAC;AAIxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,EAAuC,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7E,eAAO,MAAM,QAAQ,UAAW,aAAa,sBA8D5C,CAAC"}
@@ -1,4 +1,6 @@
1
- import './index.css';
1
+ 'use client';
2
+ import './akitable.css';
3
+ import { ErrorBoundary } from 'react-error-boundary';
2
4
  import { ConfigProvider } from 'antd';
3
5
  import React from 'react';
4
6
  import { AkitableProvider } from './akitable-context';
@@ -7,6 +9,7 @@ import { AkitableControls } from './components/controls';
7
9
  import { AkitableDataTable } from './components/datatable';
8
10
  import { AkitableFooter } from './components/footer';
9
11
  import { AkitableHeader } from './components/header';
12
+ import { fallbackRender } from './components/error';
10
13
  export const Akitable = (props) => {
11
14
  const { actions, columns, data, footer, header, isLoading, pagination, rowKey, onPaginationChanged, onRowClick } = props;
12
15
  let parsedData = [];
@@ -15,19 +18,20 @@ export const Akitable = (props) => {
15
18
  // If not, table data should be accessed from type AkitableData.
16
19
  if (!!pagination) {
17
20
  const result = data;
18
- total = result.count;
19
- parsedData = result.results;
21
+ total = (result === null || result === void 0 ? void 0 : result.count) || 0;
22
+ parsedData = (result === null || result === void 0 ? void 0 : result.results) || [];
20
23
  }
21
24
  else {
22
25
  const result = data;
23
- total = result.length;
24
- parsedData = result;
26
+ total = (result === null || result === void 0 ? void 0 : result.length) || 0;
27
+ parsedData = result || [];
25
28
  }
26
- return (React.createElement(AkitableProvider, { actions: actions, isLoading: isLoading, pagination: Object.assign(Object.assign({}, pagination), { total, hasPagination: !!pagination }), onPaginationChanged: onPaginationChanged },
27
- React.createElement(ConfigProvider, { theme: themeOverrides },
28
- React.createElement("div", { className: "akitable-container" },
29
- React.createElement(AkitableHeader, Object.assign({}, header)),
30
- React.createElement(AkitableControls, null),
31
- React.createElement(AkitableDataTable, { columns: columns, data: parsedData, rowKey: rowKey, onRowClick: onRowClick }),
32
- React.createElement(AkitableFooter, Object.assign({}, footer))))));
29
+ return (React.createElement("div", { className: "akitable-container" },
30
+ React.createElement(ErrorBoundary, { fallbackRender: fallbackRender },
31
+ React.createElement(AkitableProvider, { actions: actions, isLoading: isLoading, pagination: Object.assign(Object.assign({}, pagination), { total, hasPagination: !!pagination }), onPaginationChanged: onPaginationChanged },
32
+ React.createElement(ConfigProvider, { theme: themeOverrides },
33
+ React.createElement(AkitableHeader, Object.assign({}, header)),
34
+ React.createElement(AkitableControls, null),
35
+ React.createElement(AkitableDataTable, { columns: columns, data: parsedData, rowKey: rowKey, onRowClick: onRowClick }),
36
+ React.createElement(AkitableFooter, Object.assign({}, footer)))))));
33
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/components/actions.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAKvB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,eAAO,MAAM,eAAe,yBA+D3B,CAAC"}
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/components/actions.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAKvB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,eAAO,MAAM,eAAe,yBAgE3B,CAAC"}
@@ -8,7 +8,7 @@ import { i18n } from '../i18n';
8
8
  export const AkitableActions = () => {
9
9
  const { t } = i18n;
10
10
  const [selectedAction, setSelectedAction] = React.useState(undefined);
11
- const { actions, isLoading, selectedRowKeys } = useAkitableContext();
11
+ const { actions, isLoading, selectedRowKeys, pagination } = useAkitableContext();
12
12
  const options = actions === null || actions === void 0 ? void 0 : actions.map((action, index) => ({
13
13
  value: index + 1,
14
14
  label: action.label
@@ -24,7 +24,7 @@ export const AkitableActions = () => {
24
24
  action === null || action === void 0 ? void 0 : action.onSelect(selectedRowKeys);
25
25
  };
26
26
  return (React.createElement("div", { className: "akitable-actions" },
27
- React.createElement(Select, { placeholder: t('selectAction'), value: selectedAction, options: options, onChange: handleActionChange, disabled: isLoading, allowClear: true }),
27
+ React.createElement(Select, { placeholder: t('selectAction'), value: selectedAction, options: options, onChange: handleActionChange, disabled: isLoading || (pagination === null || pagination === void 0 ? void 0 : pagination.total) === 0, allowClear: true }),
28
28
  selectedAction && (React.createElement(React.Fragment, null,
29
29
  React.createElement(Button, { type: "primary", icon: React.createElement(Icon, { icon: "katalogkontrol", size: 14, style: { position: 'relative', top: 2 } }), disabled: isLoading || !hasSelections, onClick: handleActionTrigger }, t('apply')),
30
30
  hasSelections && (React.createElement("span", { className: "akitable-actions-info" }, t('selectedCount', { count: selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length })))))));
@@ -5,7 +5,7 @@ import { AkitableActions } from './actions';
5
5
  import { AkitablePagination } from './pagination';
6
6
  export const AkitableControls = () => {
7
7
  const { actions, pagination } = useAkitableContext();
8
- if (!actions && !(pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination))
8
+ if (!actions)
9
9
  return null;
10
10
  return (React.createElement("div", { className: "akitable-controls" },
11
11
  actions && actions.length > 0 && React.createElement(AkitableActions, null),
@@ -0,0 +1,12 @@
1
+ .akitable-error {
2
+ padding-bottom: 4rem;
3
+ padding-top: 4rem;
4
+ }
5
+
6
+ .akitable-error .akinon-result-title {
7
+ color: var(--color-ebonyClay-700);
8
+ }
9
+
10
+ .akitable-error .akinon-result-subtitle {
11
+ color: var(--color-neutral-400);
12
+ }
@@ -0,0 +1,5 @@
1
+ import './error.css';
2
+ import React from 'react';
3
+ import { FallbackProps } from 'react-error-boundary';
4
+ export declare const fallbackRender: ({ resetErrorBoundary }: FallbackProps) => React.JSX.Element;
5
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/components/error.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,eAAO,MAAM,cAAc,2BAA4B,aAAa,sBAiBnE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import './error.css';
2
+ import React from 'react';
3
+ import { Result } from '@akinon/ui-result';
4
+ import { Button } from '@akinon/ui-button';
5
+ import { i18n } from '../i18n';
6
+ export const fallbackRender = ({ resetErrorBoundary }) => {
7
+ const { t } = i18n;
8
+ return (React.createElement("div", { className: "akitable-error" },
9
+ React.createElement(Result, { status: "error", title: t('errorTitle'), subTitle: t('errorDescription'), extra: [
10
+ React.createElement(Button, { type: "primary", onClick: resetErrorBoundary }, t('errorButtonText'))
11
+ ] })));
12
+ };
@@ -4,9 +4,9 @@ import React from 'react';
4
4
  import { useAkitableContext } from '../akitable-context';
5
5
  import { AkitablePagination } from './pagination';
6
6
  export const AkitableFooter = (props) => {
7
- const { isLoading } = useAkitableContext();
7
+ const { isLoading, pagination } = useAkitableContext();
8
8
  const { extra } = props;
9
- if (!extra)
9
+ if (!extra && !(pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination))
10
10
  return null;
11
11
  return (React.createElement("div", { className: "akitable-footer" },
12
12
  extra && (React.createElement("div", { className: "akitable-footer-extra" }, isLoading ? React.createElement(Spin, null) : extra)),
@@ -20,4 +20,5 @@
20
20
 
21
21
  .akitable-header-extra {
22
22
  margin-left: auto;
23
+ text-align: right;
23
24
  }
@@ -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;AAE/C,eAAO,MAAM,cAAc,UAAW,mBAAmB,6BA8BxD,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,6BAyCxD,CAAC"}
@@ -4,9 +4,11 @@ import { Spin } from '@akinon/ui-spin';
4
4
  import React from 'react';
5
5
  import { useAkitableContext } from '../akitable-context';
6
6
  import { i18n } from '../i18n';
7
+ import { AkitablePagination } from './pagination';
7
8
  export const AkitableHeader = (props) => {
8
- const { isLoading, pagination } = useAkitableContext();
9
+ const { isLoading, pagination, actions } = useAkitableContext();
9
10
  const { title, extra } = props;
11
+ const hasActions = actions && (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
10
12
  if (!title && !extra)
11
13
  return null;
12
14
  return (React.createElement("div", { className: "akitable-header" },
@@ -15,7 +17,11 @@ export const AkitableHeader = (props) => {
15
17
  title,
16
18
  " ",
17
19
  !isLoading && `(${pagination === null || pagination === void 0 ? void 0 : pagination.total})`),
18
- !isLoading && (React.createElement("span", { className: "akitable-header-description" }, i18n.t('resultsFound', { count: pagination === null || pagination === void 0 ? void 0 : pagination.total }))),
20
+ !isLoading && !!(pagination === null || pagination === void 0 ? void 0 : pagination.total) && (React.createElement("span", { className: "akitable-header-description" }, i18n.t('resultsFound', { count: pagination === null || pagination === void 0 ? void 0 : pagination.total }))),
21
+ !isLoading && !(pagination === null || pagination === void 0 ? void 0 : pagination.total) && (React.createElement("span", { className: "akitable-header-description" }, i18n.t('noData'))),
19
22
  isLoading && React.createElement(Skeleton, { count: 0.7, className: "mt-2" }))),
20
- extra && (React.createElement("div", { className: "akitable-header-extra" }, isLoading ? React.createElement(Spin, null) : extra))));
23
+ React.createElement("div", { className: "akitable-header-extra" },
24
+ extra && React.createElement("div", { className: "mb-4" }, isLoading ? React.createElement(Spin, null) : extra),
25
+ !hasActions && (pagination === null || pagination === void 0 ? void 0 : pagination.hasPagination) && (React.createElement("div", null,
26
+ React.createElement(AkitablePagination, null))))));
21
27
  };
@@ -7,7 +7,7 @@ export const AkitablePagination = () => {
7
7
  const { isLoading, pagination, onPaginationChanged } = useAkitableContext();
8
8
  const { t } = i18n;
9
9
  return (React.createElement("div", null,
10
- React.createElement(Pagination, { simple: true, disabled: isLoading, 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: {
10
+ React.createElement(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: {
11
11
  items_per_page: t('itemsPerPage')
12
12
  } })));
13
13
  };
@@ -1,9 +1,13 @@
1
1
  declare const translations: {
2
- readonly resultsFound: "{{count}} result(s) found.";
2
+ readonly apply: "Apply";
3
+ readonly errorTitle: "Error!";
4
+ readonly errorDescription: "There's been an internal error with Akitable component Please try again.";
5
+ readonly errorButtonText: "Try Again";
3
6
  readonly itemsPerPage: "/ page";
7
+ readonly noData: "No results found.";
8
+ readonly resultsFound: "{{count}} result(s) found.";
4
9
  readonly selectAction: "Select Action";
5
10
  readonly selectedCount: "Selected {{count}} record(s).";
6
- readonly apply: "Apply";
7
11
  };
8
12
  export default translations;
9
13
  //# 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;;;;;;CAMR,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;;;;;;;;;;CAWR,CAAC;AAEX,eAAe,YAAY,CAAC"}
@@ -1,8 +1,12 @@
1
1
  const translations = {
2
- resultsFound: '{{count}} result(s) found.',
2
+ apply: 'Apply',
3
+ errorTitle: 'Error!',
4
+ errorDescription: "There's been an internal error with Akitable component Please try again.",
5
+ errorButtonText: 'Try Again',
3
6
  itemsPerPage: '/ page',
7
+ noData: 'No results found.',
8
+ resultsFound: '{{count}} result(s) found.',
4
9
  selectAction: 'Select Action',
5
- selectedCount: 'Selected {{count}} record(s).',
6
- apply: 'Apply'
10
+ selectedCount: 'Selected {{count}} record(s).'
7
11
  };
8
12
  export default translations;
@@ -1,9 +1,13 @@
1
1
  declare const translations: {
2
- readonly resultsFound: "{{count}} sonuç bulundu.";
2
+ readonly apply: "Uygula";
3
+ readonly errorTitle: "Hata!";
4
+ readonly errorDescription: "Akitable bileşeniyle ilgili bir iç hata oluştu. Lütfen tekrar deneyiniz.";
5
+ readonly errorButtonText: "Tekrar Dene";
3
6
  readonly itemsPerPage: "/ sayfa";
7
+ readonly noData: "Kayıt bulunamadı.";
8
+ readonly resultsFound: "{{count}} sonuç bulundu.";
4
9
  readonly selectAction: "Aksiyon Seçiniz";
5
10
  readonly selectedCount: "{{count}} kayit seçildi.";
6
- readonly apply: "Uygula";
7
11
  };
8
12
  export default translations;
9
13
  //# 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;;;;;;CAMR,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;;;;;;;;;;CAWR,CAAC;AAEX,eAAe,YAAY,CAAC"}
@@ -1,8 +1,12 @@
1
1
  const translations = {
2
- resultsFound: '{{count}} sonuç bulundu.',
2
+ apply: 'Uygula',
3
+ errorTitle: 'Hata!',
4
+ errorDescription: 'Akitable bileşeniyle ilgili bir iç hata oluştu. Lütfen tekrar deneyiniz.',
5
+ errorButtonText: 'Tekrar Dene',
3
6
  itemsPerPage: '/ sayfa',
7
+ noData: 'Kayıt bulunamadı.',
8
+ resultsFound: '{{count}} sonuç bulundu.',
4
9
  selectAction: 'Aksiyon Seçiniz',
5
- selectedCount: '{{count}} kayit seçildi.',
6
- apply: 'Uygula'
10
+ selectedCount: '{{count}} kayit seçildi.'
7
11
  };
8
12
  export default translations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/akitable",
3
- "version": "0.3.0",
3
+ "version": "0.3.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
@@ -11,27 +11,29 @@
11
11
  "dependencies": {
12
12
  "antd": "5.17.0",
13
13
  "clsx": "^2.0.0",
14
- "@akinon/akilocale": "0.10.0",
14
+ "react-error-boundary": "^4.0.13",
15
+ "@akinon/akilocale": "0.10.1",
15
16
  "@akinon/icons": "0.4.0",
16
17
  "@akinon/ui-button": "0.5.0",
18
+ "@akinon/ui-pagination": "0.3.0",
19
+ "@akinon/ui-result": "0.1.0",
17
20
  "@akinon/ui-card": "0.3.0",
21
+ "@akinon/ui-select": "0.3.0",
18
22
  "@akinon/ui-skeleton": "0.3.0",
19
- "@akinon/ui-spin": "0.3.0",
20
23
  "@akinon/ui-space": "0.3.0",
21
- "@akinon/ui-theme": "0.5.0",
22
- "@akinon/ui-typography": "0.3.0",
24
+ "@akinon/ui-spin": "0.3.0",
23
25
  "@akinon/ui-table": "0.3.0",
24
- "@akinon/ui-select": "0.3.0",
25
- "@akinon/ui-pagination": "0.3.0"
26
+ "@akinon/ui-theme": "0.5.0",
27
+ "@akinon/ui-typography": "0.3.0"
26
28
  },
27
29
  "devDependencies": {
28
30
  "clean-package": "2.2.0",
29
31
  "copyfiles": "^2.4.1",
30
32
  "rimraf": "^5.0.5",
31
33
  "typescript": "^5.2.2",
32
- "@akinon/eslint-config": "0.1.0",
34
+ "@akinon/typescript-config": "0.2.0",
33
35
  "@akinon/vite-config": "0.4.0",
34
- "@akinon/typescript-config": "0.2.0"
36
+ "@akinon/eslint-config": "0.1.0"
35
37
  },
36
38
  "peerDependencies": {
37
39
  "react": ">=18",
@@ -51,7 +53,7 @@
51
53
  "build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
52
54
  "build:esm": "tsc --outDir dist/esm",
53
55
  "build:commonjs": "tsc --module commonjs --outDir dist/cjs",
54
- "copy:files": "copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
56
+ "copy:files": "copyfiles -u 1 src/*.css dist/esm && copyfiles -u 1 src/*.css dist/cjs && copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
55
57
  "clean": "rimraf dist/",
56
58
  "lint": "eslint *.ts*",
57
59
  "test": "vitest run",