denwa-react-shared 1.1.0 → 1.1.2

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.
@@ -1,2 +1,2 @@
1
1
  import { AdminTableProps } from './types';
2
- export declare const AdminTable: <T extends string>({ drawerContent, sortTooltipText, updateDataText, refreshText, createText, createNewElementText, viewText, actionsText, editText, tableData, columns, order, orderOptions, searchProps, serverPagination, fetchedDataLoading, createButtonTooltip, readAction, createAction, updateAction, deleteText, deletedText, cancelText, deleteErrorText, drawerTitle, closeModalTitleText, closeModalContentText, closeModalOkText, closeModalCancelText, drawerSize, modalTitle, scrollWidth, isCanRead, isCanCreate, isCanUpdate, isCanDelete, isExpandable, isHiddenCreate, isHiddenUpdate, isFixedActions, configProviderProps, onGetError, onChangeOrder, onRefetch, onSetPaginate, onDelete, onShowSizeChange, onSuccessMessage, onErrorMessage, }: AdminTableProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const AdminTable: <T extends string>({ drawerContent, sortTooltipText, updateDataText, refreshText, createText, createNewElementText, viewText, actionsText, editText, tableData, columns, order, orderOptions, searchProps, serverPagination, fetchedDataLoading, createButtonTooltip, readAction, createAction, updateAction, deleteText, deletedText, cancelText, deleteErrorText, drawerTitle, closeModalTitleText, closeModalContentText, closeModalOkText, closeModalCancelText, drawerSize, modalTitle, scrollWidth, isCanRead, isCanCreate, isCanUpdate, isCanDelete, isExpandable, isHiddenCreate, isHiddenUpdate, isHiddenActions, isFixedActions, renderActions, configProviderProps, onGetError, onChangeOrder, onRefetch, onSetPaginate, onDelete, onShowSizeChange, onSuccessMessage, onErrorMessage, }: AdminTableProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { ColumnsType } from 'antd/es/table';
3
3
  import { ConfigProviderProps, PaginationProps } from 'antd';
4
+ import { CustomActionItem } from '../base-table/types';
4
5
  import { AdminDrawerFormProps, IPaginate, OptionType } from '../../types';
5
6
  import { BaseDatePickerProps } from '../date-picker';
6
7
  export interface AdminTableProps<T extends string> {
@@ -44,6 +45,8 @@ export interface AdminTableProps<T extends string> {
44
45
  isExpandable?: boolean;
45
46
  isHiddenCreate?: boolean;
46
47
  isHiddenUpdate?: boolean;
48
+ isHiddenActions?: boolean;
49
+ renderActions?: (record: object) => CustomActionItem[];
47
50
  configProviderProps?: ConfigProviderProps;
48
51
  onGetError: ({ error, message }: {
49
52
  error?: unknown;
@@ -1,5 +1,14 @@
1
+ import { ReactNode } from 'react';
1
2
  import { PaginationProps, TableProps } from 'antd';
2
3
  import { IPaginate } from '../../types';
4
+ export type CustomActionItem = {
5
+ key: string;
6
+ icon?: ReactNode;
7
+ label: ReactNode;
8
+ onClick?: () => void;
9
+ danger?: boolean;
10
+ disabled?: boolean;
11
+ };
3
12
  export interface BaseTableProps extends TableProps {
4
13
  viewText: string;
5
14
  actionsText: string;
@@ -10,7 +19,9 @@ export interface BaseTableProps extends TableProps {
10
19
  isCanUpdate: boolean;
11
20
  isCanDelete: boolean;
12
21
  isHiddenUpdate?: boolean;
22
+ isHiddenActions?: boolean;
13
23
  isFixedActions?: boolean;
24
+ renderActions?: (record: object) => CustomActionItem[];
14
25
  onView: (id: string) => void;
15
26
  onDropdownClick: (id: string) => void;
16
27
  onEdit: () => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "denwa-react-shared",
3
3
  "private": false,
4
- "version": "1.1.0",
4
+ "version": "1.1.2",
5
5
  "type": "module",
6
6
  "author": "Denwa",
7
7
  "repository": {
@@ -1 +0,0 @@
1
- let e=require("react/jsx-runtime"),t=require("antd"),n=require("@ant-design/icons");var r=({viewText:r,actionsText:i,editText:a,deleteText:o,columns:s,serverPagination:c,scroll:l,loading:u,dataSource:d,isHiddenUpdate:f,isCanRead:p,isCanUpdate:m,isCanDelete:h,isFixedActions:g,onView:_,onDropdownClick:v,onEdit:y,onDelete:b,onShowSizeChange:x,...S})=>{let C=d?.map(e=>{let t={};return Object.entries(e).forEach(([e,n])=>{t[e]=n||`-`}),t}),w=s??[],T=c?{current:c.page??1,pageSize:c.limit??1,total:c.count??0,pageSizeOptions:[10,20,50,100,200,500],showSizeChanger:!0,showQuickJumper:!0,onShowSizeChange:x,showTotal:(e,t)=>`${t[0]}-${t[1]} / ${e}`}:null,E=e=>{`id`in e&&typeof e.id==`string`&&_(e.id)},D=e=>{`id`in e&&typeof e.id==`string`&&v(e.id)},O=[];!f&&m&&O.push({key:`edit`,label:(0,e.jsx)(t.Button,{type:`link`,block:!0,onClick:y,children:a})}),h&&b&&O.push({key:`delete`,label:(0,e.jsx)(t.Button,{type:`link`,block:!0,danger:!0,onClick:b,children:o})});let k=[...w,{title:i,key:`action`,width:180,fixed:g?`right`:!1,render:n=>O.length?(0,e.jsx)(t.Dropdown.Button,{disabled:!p,menu:{items:O,onClick:()=>D(n)},onClick:()=>E(n),children:r}):(0,e.jsx)(t.Button,{disabled:!p,onClick:()=>E(n),children:r})}];return(0,e.jsx)(t.Table,{...S,className:`baseTable`,dataSource:C,columns:k,pagination:T?{...T,size:`small`}:!1,scroll:{...l,y:`50vh`,scrollToFirstRowOnChange:!0},loading:{spinning:!!u,indicator:(0,e.jsx)(n.LoadingOutlined,{style:{fontSize:36}})}})};exports.BaseTable=r;
@@ -1,90 +0,0 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { Button as t, Dropdown as n, Table as r } from "antd";
3
- import { LoadingOutlined as i } from "@ant-design/icons";
4
- //#region src/shared/ui/base-table/index.tsx
5
- var a = ({ viewText: a, actionsText: o, editText: s, deleteText: c, columns: l, serverPagination: u, scroll: d, loading: f, dataSource: p, isHiddenUpdate: m, isCanRead: h, isCanUpdate: g, isCanDelete: _, isFixedActions: v, onView: y, onDropdownClick: b, onEdit: x, onDelete: S, onShowSizeChange: C, ...w }) => {
6
- let T = p?.map((e) => {
7
- let t = {};
8
- return Object.entries(e).forEach(([e, n]) => {
9
- t[e] = n || "-";
10
- }), t;
11
- }), E = l ?? [], D = u ? {
12
- current: u.page ?? 1,
13
- pageSize: u.limit ?? 1,
14
- total: u.count ?? 0,
15
- pageSizeOptions: [
16
- 10,
17
- 20,
18
- 50,
19
- 100,
20
- 200,
21
- 500
22
- ],
23
- showSizeChanger: !0,
24
- showQuickJumper: !0,
25
- onShowSizeChange: C,
26
- showTotal: (e, t) => `${t[0]}-${t[1]} / ${e}`
27
- } : null, O = (e) => {
28
- "id" in e && typeof e.id == "string" && y(e.id);
29
- }, k = (e) => {
30
- "id" in e && typeof e.id == "string" && b(e.id);
31
- }, A = [];
32
- !m && g && A.push({
33
- key: "edit",
34
- label: /* @__PURE__ */ e(t, {
35
- type: "link",
36
- block: !0,
37
- onClick: x,
38
- children: s
39
- })
40
- }), _ && S && A.push({
41
- key: "delete",
42
- label: /* @__PURE__ */ e(t, {
43
- type: "link",
44
- block: !0,
45
- danger: !0,
46
- onClick: S,
47
- children: c
48
- })
49
- });
50
- let j = [...E, {
51
- title: o,
52
- key: "action",
53
- width: 180,
54
- fixed: v ? "right" : !1,
55
- render: (r) => A.length ? /* @__PURE__ */ e(n.Button, {
56
- disabled: !h,
57
- menu: {
58
- items: A,
59
- onClick: () => k(r)
60
- },
61
- onClick: () => O(r),
62
- children: a
63
- }) : /* @__PURE__ */ e(t, {
64
- disabled: !h,
65
- onClick: () => O(r),
66
- children: a
67
- })
68
- }];
69
- return /* @__PURE__ */ e(r, {
70
- ...w,
71
- className: "baseTable",
72
- dataSource: T,
73
- columns: j,
74
- pagination: D ? {
75
- ...D,
76
- size: "small"
77
- } : !1,
78
- scroll: {
79
- ...d,
80
- y: "50vh",
81
- scrollToFirstRowOnChange: !0
82
- },
83
- loading: {
84
- spinning: !!f,
85
- indicator: /* @__PURE__ */ e(i, { style: { fontSize: 36 } })
86
- }
87
- });
88
- };
89
- //#endregion
90
- export { a as BaseTable };