@kingteza/crud-component 1.0.51 → 1.0.54

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 (60) hide show
  1. package/App.d.ts +1 -0
  2. package/Play.d.ts +2 -0
  3. package/_virtual/_commonjsHelpers.cjs.js +1 -0
  4. package/_virtual/_commonjsHelpers.es.js +8 -0
  5. package/_virtual/_nodeUtil.cjs.js +1 -0
  6. package/_virtual/_nodeUtil.es.js +4 -0
  7. package/_virtual/index.cjs.js +1 -0
  8. package/_virtual/index.cjs2.js +1 -0
  9. package/_virtual/index.cjs3.js +1 -0
  10. package/_virtual/index.es.js +11 -0
  11. package/_virtual/index.es2.js +7 -0
  12. package/_virtual/index.es3.js +4 -0
  13. package/_virtual/isBuffer.cjs.js +1 -0
  14. package/_virtual/isBuffer.es.js +4 -0
  15. package/_virtual/quill.cjs.js +1 -0
  16. package/_virtual/quill.es.js +4 -0
  17. package/common/button/Button.cjs.js +1 -1
  18. package/common/button/Button.es.js +38 -52
  19. package/common/button/CloneButtonTable.cjs.js +1 -1
  20. package/common/button/HideButtonTable.cjs.js +1 -1
  21. package/common/button/NewButton.cjs.js +1 -1
  22. package/common/button/PrintButton.cjs.js +1 -1
  23. package/common/button/RefreshButton.cjs.js +1 -1
  24. package/common/button/UnHideButton.cjs.js +1 -1
  25. package/common/button/UpdateButtonTable.cjs.js +1 -1
  26. package/common/button/ViewButtonTable.cjs.js +1 -1
  27. package/common/icon/KIcon.cjs.js +1 -0
  28. package/common/icon/KIcon.d.ts +9 -0
  29. package/common/icon/KIcon.es.js +11 -0
  30. package/common/index.cjs.js +1 -1
  31. package/common/index.es.js +68 -68
  32. package/common/picker/ImagePicker.cjs.js +1 -1
  33. package/common/picker/ImagePicker.es.js +228 -189
  34. package/common/rich/index.cjs.js +1 -1
  35. package/common/rich/index.es.js +10 -10
  36. package/common/select/SelectComponent.es.js +4 -4
  37. package/common/tab/TabViewWithRoute.cjs.js +1 -1
  38. package/common/tab/TabViewWithRoute.es.js +21 -21
  39. package/common/table/table.d.ts +1 -1
  40. package/common/text-field/TextField.cjs.js +1 -1
  41. package/common/wizard/WizardResult.es.js +4 -4
  42. package/crud/CrudComponent.cjs.js +1 -1
  43. package/crud/CrudComponent.d.ts +5 -1
  44. package/crud/CrudComponent.es.js +66 -64
  45. package/crud/CrudField.es.js +1 -1
  46. package/crud/CrudReportComponent.cjs.js +1 -1
  47. package/crud/FileCrudField.cjs.js +1 -1
  48. package/crud/FileCrudField.es.js +23 -23
  49. package/crud/import/CrudImportComponent.cjs.js +2 -2
  50. package/crud/import/CrudImportComponent.es.js +10 -10
  51. package/crud/view/CrudViewer.cjs.js +1 -1
  52. package/crud/view/CrudViewer.d.ts +11 -1
  53. package/crud/view/CrudViewer.es.js +285 -174
  54. package/index.cjs.js +1 -1
  55. package/index.es.js +19 -19
  56. package/locale/index.d.ts +5 -0
  57. package/locale/translations/en.cjs.js +1 -1
  58. package/locale/translations/en.d.ts +5 -0
  59. package/locale/translations/en.es.js +7 -2
  60. package/package.json +7 -2
@@ -1,9 +1,9 @@
1
1
  import { jsxs as w, jsx as i } from "react/jsx-runtime";
2
2
  import { WarningTwoTone as B, DownloadOutlined as z } from "@ant-design/icons";
3
3
  import $ from "papaparse";
4
- import { Tooltip as V, App as R, Modal as U, Space as O, Spin as Y, Progress as _ } from "antd";
5
- import { saveAs as G } from "file-saver";
6
- import { useState as T, useEffect as H, useMemo as A, useCallback as f } from "react";
4
+ import { Tooltip as V, App as H, Modal as R, Space as O, Spin as U, Progress as Y } from "antd";
5
+ import { saveAs as _ } from "file-saver";
6
+ import { useState as T, useEffect as G, useMemo as A, useCallback as f } from "react";
7
7
  import { useTranslationLib as J } from "../../locale/index.es.js";
8
8
  import K from "../view/CrudViewer.es.js";
9
9
  import Q from "../../util/DateUtil.es.js";
@@ -16,7 +16,7 @@ function de({
16
16
  importProps: o
17
17
  }) {
18
18
  const [c, F] = T([]), [g, C] = T(!1), [N, I] = T(0);
19
- H(() => {
19
+ G(() => {
20
20
  x || (F([]), C(!1));
21
21
  }, [x]);
22
22
  const u = A(
@@ -40,7 +40,7 @@ function de({
40
40
  async function() {
41
41
  const e = `${E.join(",")}
42
42
  `, t = new Blob([e], { type: "text/csv;charset=utf-8;" });
43
- G(
43
+ _(
44
44
  t,
45
45
  (o == null ? void 0 : o.name) + " - " + Q.formatDateTimeWithSecond(/* @__PURE__ */ new Date()).replaceAll(":", "-") + ".csv"
46
46
  );
@@ -95,7 +95,7 @@ function de({
95
95
  } finally {
96
96
  C(!1), I(0);
97
97
  }
98
- }, [c, o, b, q]), { modal: S } = R.useApp(), M = f(async () => {
98
+ }, [c, o, b, q]), { modal: S } = H.useApp(), M = f(async () => {
99
99
  k ? S.warning ? S.warning({
100
100
  title: s("str.warning"),
101
101
  content: s("qus.importWithIssues"),
@@ -108,13 +108,13 @@ function de({
108
108
  ), window.confirm(s("qus.importWithIssues")) && y()) : y();
109
109
  }, [k, y, s]);
110
110
  return /* @__PURE__ */ w(
111
- U,
111
+ R,
112
112
  {
113
113
  title: [s("str.import"), o == null ? void 0 : o.name].filter(Boolean).join(" "),
114
114
  width: "100%",
115
115
  open: x,
116
116
  onOk: M,
117
- destroyOnClose: !0,
117
+ destroyOnHidden: !0,
118
118
  onCancel: () => b(!1),
119
119
  okText: s("str.import"),
120
120
  confirmLoading: g,
@@ -155,11 +155,11 @@ function de({
155
155
  )
156
156
  ] }),
157
157
  /* @__PURE__ */ i(
158
- Y,
158
+ U,
159
159
  {
160
160
  spinning: g,
161
161
  indicator: N ? /* @__PURE__ */ i(
162
- _,
162
+ Y,
163
163
  {
164
164
  type: "circle",
165
165
  percent: N * 100,
@@ -1 +1 @@
1
- "use strict";const r=require("react/jsx-runtime"),A=require("antd"),H=require("../../common/button/CloneButtonTable.cjs.js"),p=require("../../common/button/DeleteButtonTable.cjs.js"),U=require("../../common/button/ExportButton.cjs.js"),F=require("../../common/button/HideButtonTable.cjs.js"),rr=require("../../common/button/RefreshButton.cjs.js"),er=require("../../common/button/UpdateButtonTable.cjs.js"),tr=require("../../common/button/ViewButtonTable.cjs.js"),ur=require("../../common/table/table.cjs.js"),j=require("react"),sr=require("../../locale/index.cjs.js"),nr=require("../CrudSearchComponent.cjs.js"),or=require("./CrudDecListView.cjs.js"),E=require("./CrudViewerUtil.cjs.js"),cr=require("../../common/layout/VerticalSpace.cjs.js");function lr({idField:u="id",loadingData:_,fields:l,isDeleting:m,isHiding:y,viewable:o=!1,paginateProps:h,onDelete:q,onHide:T,onUpdate:v,data:x=[],extraAction:i,onClickUpdate:c,minusHeight:C,scroll:$,onClickClone:B,className:w,expandable:G,size:J,bordered:K,descListColumn:N,extraView:b,decListLayout:Q,scrollToTop:ar,onClickRefresh:V,closeViewOnClickUpdate:d,onExport:g,confirmHiding:I,confirmDeleting:L,rowClassName:W,actionWidth:X=190,...Y}){const{t:Z}=sr.useTranslationLib(),M=j.useMemo(()=>l.map(({hideInTable:e,hidden:t,width:a,name:n,label:P,halign:k,...O})=>({title:P,width:a,key:n,dataIndex:n,hidden:e||t,align:k??(O.type==="number"?"right":void 0),render:E.getRendererValueCrudViewer(O)})),[l]),[s,f]=j.useState(),[S,R]=j.useState();j.useEffect(()=>{x&&f(e=>{if(e)return x.find(t=>t[u]===e[u])})},[x,u,s]);const z=j.useCallback(e=>{var a;const t=i==null?void 0:i(e);return(Array.isArray(t)?(a=t==null?void 0:t.filter(Boolean))!=null&&a.length:t)||v||c||B||q?r.jsxs(r.Fragment,{children:[t,(v||c)&&r.jsx(er,{value:e,onClick:n=>{R(n[u]),c==null||c(e),d&&f(void 0)}}),B&&r.jsx(H,{value:e,onClick:n=>B(n)}),g&&r.jsx(U.ExportButton,{value:e,onClick:async n=>await g(n)}),T&&r.jsx(F,{value:e,disabled:y,shouldConfirm:I,loading:y&&e[u]===S,onClick:async n=>{R(n[u]),await T({[u]:n[u]})}}),q&&r.jsx(p,{value:e,disabled:m,shouldConfirm:L,loading:m&&e[u]===S,onClick:async n=>{R(n[u]),await q({[u]:n[u]})}})]}):void 0},[d,L,I,i,u,m,y,B,c,q,g,T,v,S]),D=j.useMemo(()=>{let e=typeof o=="string"?s==null?void 0:s[o]:void 0;if(typeof e=="object"){const t=l.find(a=>a.name===o);e=E.getRendererValueCrudViewer(t)(e,s,0)}return e},[o,s,l]);return r.jsxs("div",{children:[o&&r.jsx(A.Modal,{width:"100%",open:!!s,title:D??r.jsx("div",{children:" "}),footer:r.jsx(r.Fragment,{}),closable:!0,onCancel:()=>f(void 0),children:!!s&&r.jsxs("div",{children:[r.jsx(or.CrudDecListView,{layout:Q,descListColumn:N,data:s,fields:l,action:z(s)}),b==null?void 0:b(s)]},s==null?void 0:s[u])}),r.jsx(nr,{fields:l,...Y}),r.jsxs(cr,{children:[!!V&&r.jsx(rr.RefreshButton,{onClick:V}),r.jsx(ur,{rowClassName:W,className:w,scroll:$??(C?{y:`calc(100vh - ${C})`}:void 0),id:"crud-table",dataSource:x,loading:_,bordered:K,size:J,expandable:G,pagination:h?{total:h.count,onChange:h.setPage,current:h.page,pageSize:h.pageSize}:void 0,columns:v||c||q||i||o?[...M,{title:Z("str.action"),dataIndex:"",fixed:"right",width:X,render:(e,t)=>r.jsxs(r.Fragment,{children:[o&&r.jsx(tr,{value:t,onClick:f}),z(t)]})}]:M})]})]})}module.exports=lr;
1
+ "use strict";const s=require("react/jsx-runtime"),ft=require("antd"),xt=require("../../node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@dnd-kit/core/dist/core.esm.cjs.js"),jt=require("../../node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1__react@18.3.1/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.cjs.js"),ht=require("../../node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@18.3.1/node_modules/@dnd-kit/utilities/dist/utilities.esm.cjs.js"),M=require("../../node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1__react@18.3.1/node_modules/@dnd-kit/sortable/dist/sortable.esm.cjs.js"),yt=require("../../common/button/Button.cjs.js"),qt=require("../../common/button/CloneButtonTable.cjs.js"),lt=require("../../common/button/DeleteButtonTable.cjs.js"),vt=require("../../common/button/ExportButton.cjs.js"),St=require("../../common/button/HideButtonTable.cjs.js"),Bt=require("../../common/button/RefreshButton.cjs.js"),It=require("../../common/button/UpdateButtonTable.cjs.js"),Tt=require("../../common/button/ViewButtonTable.cjs.js"),Ct=require("../../common/table/table.cjs.js"),u=require("react"),Mt=require("../../locale/index.cjs.js"),Rt=require("../CrudSearchComponent.cjs.js"),Vt=require("./CrudDecListView.cjs.js"),et=require("./CrudViewerUtil.cjs.js"),Et=require("@ant-design/icons"),wt=require("../../common/layout/VerticalSpace.cjs.js"),Dt=u.memo(Ct);function Lt({idField:e="id",loadingData:v,fields:m,isDeleting:T,isHiding:S,viewable:f=!1,paginateProps:j,onDelete:h,onHide:C,onUpdate:l,data:B=[],extraAction:I,onClickUpdate:y,minusHeight:w,scroll:G,onClickClone:R,className:J,expandable:K,size:Q,bordered:X,descListColumn:nt,extraView:D,decListLayout:ot,scrollToTop:zt,onClickRefresh:Y,closeViewOnClickUpdate:Z,onExport:L,confirmHiding:A,confirmDeleting:P,rowClassName:W,actionWidth:H=190,draggable:o,...rt}){const{t:p}=Mt.useTranslationLib(),U=u.useMemo(()=>m.map(({hideInTable:t,hidden:n,width:c,name:r,label:N,halign:$,...E})=>({title:N,width:c,key:r,dataIndex:r,hidden:t||n,align:$??(E.type==="number"?"right":void 0),render:et.getRendererValueCrudViewer(E)})),[m]),[i,V]=u.useState(),[_,O]=u.useState(),[q,d]=u.useState([]);u.useEffect(()=>{B&&d(B)},[B]),u.useEffect(()=>{B&&V(t=>{if(t)return B.find(n=>n[e]===t[e])})},[B,e,i]);const z=u.useCallback(t=>{var c;const n=I==null?void 0:I(t);return(Array.isArray(n)?(c=n==null?void 0:n.filter(Boolean))!=null&&c.length:n)||l||y||R||h?s.jsxs(s.Fragment,{children:[n,(l||y)&&s.jsx(It,{value:t,onClick:r=>{O(r[e]),y==null||y(t),Z&&V(void 0)}}),R&&s.jsx(qt,{value:t,onClick:r=>R(r)}),L&&s.jsx(vt.ExportButton,{value:t,onClick:async r=>await L(r)}),C&&s.jsx(St,{value:t,disabled:S,shouldConfirm:A,loading:S&&t[e]===_,onClick:async r=>{O(r[e]),await C({[e]:r[e]})}}),h&&s.jsx(lt,{value:t,disabled:T,shouldConfirm:P,loading:T&&t[e]===_,onClick:async r=>{O(r[e]),await h({[e]:r[e]})}})]}):void 0},[Z,P,A,I,e,T,S,R,y,h,L,C,l,_]),b=u.useCallback(t=>{var r;const{active:n,over:c}=t;if(o!=null&&o.onDragEnd&&(o==null||o.onDragEnd(t)),n.id!==(c==null?void 0:c.id)){const N=q.findIndex(x=>x[e]===n.id),$=q.findIndex(x=>x[e]===(c==null?void 0:c.id)),E=M.arrayMove(q,N,$);d(x=>{const it=x.findIndex(k=>k[e]===(n==null?void 0:n.id)),mt=x.findIndex(k=>k[e]===(c==null?void 0:c.id));return M.arrayMove(x,it,mt)}),(r=o==null?void 0:o.onDrag)==null||r.call(o,{newOrder:E.map(x=>x[e])})}},[q,e,o]),ut=u.useMemo(()=>{let t=typeof f=="string"?i==null?void 0:i[f]:void 0;if(typeof t=="object"){const n=m.find(c=>c.name===f);t=et.getRendererValueCrudViewer(n)(t,i,0)}return t},[f,i,m]),a=u.useMemo(()=>({rowClassName:W,className:J,scroll:G??(w?{y:`calc(100vh - ${w})`}:void 0),id:"crud-table",bordered:X,size:Q,expandable:K}),[W,J,G,w,X,Q,K]),F=u.useMemo(()=>j?{total:j.count,onChange:j.setPage,current:j.page,pageSize:j.pageSize}:void 0,[j]),g=u.useMemo(()=>{const t=l||y||h||I||f,n=[];return o&&n.push({key:"key",align:"center",width:5,title:o==null?void 0:o.columnLabel,render:()=>s.jsx(_t,{tooltip:o==null?void 0:o.tooltip})}),n.push(...U),t&&t&&n.push({title:p("str.action"),fixed:"right",width:H,render:(c,r)=>s.jsxs(s.Fragment,{children:[f&&s.jsx(Tt,{value:r,onClick:V}),z(r)]})}),n},[U,l,y,h,I,f,p,H,z]),tt=u.useMemo(()=>q.map(t=>t[e]),[q,e]),ct=u.useCallback(()=>{const t=s.jsx(Dt,{...a,dataSource:q,loading:v,components:o?{body:{row:Ot}}:void 0,pagination:F,columns:g});return o?s.jsx(xt.DndContext,{modifiers:[jt.restrictToVerticalAxis],onDragEnd:b,children:s.jsx(M.SortableContext,{items:tt,strategy:M.verticalListSortingStrategy,children:t})}):t},[a,q,v,F,g,o,tt,b]);return s.jsxs("div",{children:[f&&s.jsx(ft.Modal,{width:"100%",open:!!i,title:ut??s.jsx("div",{children:" "}),footer:s.jsx(s.Fragment,{}),closable:!0,onCancel:()=>V(void 0),children:!!i&&s.jsxs("div",{children:[s.jsx(Vt.CrudDecListView,{layout:ot,descListColumn:nt,data:i,fields:m,action:z(i)}),D==null?void 0:D(i)]},i==null?void 0:i[e])}),s.jsx(Rt,{fields:m,...rt}),s.jsxs(wt,{children:[!!Y&&s.jsx(Bt.RefreshButton,{onClick:Y}),ct()]})]})}const st=u.createContext({}),_t=({tooltip:e})=>{const{setActivatorNodeRef:v,listeners:m}=u.useContext(st);return s.jsx(yt,{type:"text",size:"small",tooltip:e,icon:s.jsx(Et.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:v,...m})},Ot=e=>{const{attributes:v,listeners:m,setNodeRef:T,setActivatorNodeRef:S,transform:f,transition:j,isDragging:h}=M.useSortable({id:e["data-row-key"]}),C={...e.style,transform:ht.CSS.Translate.toString(f),transition:j,...h?{position:"relative",zIndex:9999}:{}},l=u.useMemo(()=>({setActivatorNodeRef:S,listeners:m}),[S,m]);return s.jsx(st.Provider,{value:l,children:s.jsx("tr",{...e,ref:T,style:C,...v})})};module.exports=Lt;
@@ -1,11 +1,20 @@
1
1
  import { SizeType } from 'antd/es/config-provider/SizeContext';
2
2
  import { ExpandableConfig } from 'antd/es/table/interface';
3
+ import { DragEndEvent } from '@dnd-kit/core';
3
4
  import { TableProps } from 'antd/lib';
4
5
  import { default as React, ReactElement } from 'react';
5
6
  import { default as IdProps } from '../../types/Id';
6
7
  import { CrudFieldProps, CrudPaginateProps } from '../CrudComponent';
7
8
  import { CrudSearchComponentProps } from '../CrudSearchComponent';
8
9
  import { DescListColumn } from './CrudDecListView';
10
+ export type CrudDragableProps<T> = {
11
+ onDragEnd?: (event: DragEndEvent) => void;
12
+ onDrag?: (params: {
13
+ newOrder: T[];
14
+ }) => void;
15
+ columnLabel?: string;
16
+ tooltip?: string;
17
+ };
9
18
  export type CrudViewerProps<T, FormType> = {
10
19
  fields: CrudFieldProps<T>[];
11
20
  decListLayout?: "horizontal" | "vertical";
@@ -38,6 +47,7 @@ export type CrudViewerProps<T, FormType> = {
38
47
  scrollToTop?: boolean;
39
48
  rowClassName?: TableProps<T>["rowClassName"];
40
49
  actionWidth?: string | number;
50
+ draggable?: CrudDragableProps<T>;
41
51
  } & CrudSearchComponentProps<T, FormType>;
42
- declare function CrudViewer<T, FormType = T>({ idField, loadingData, fields, isDeleting, isHiding, viewable, paginateProps, onDelete, onHide, onUpdate, data, extraAction, onClickUpdate, minusHeight, scroll, onClickClone, className, expandable, size, bordered, descListColumn, extraView, decListLayout, scrollToTop, onClickRefresh, closeViewOnClickUpdate, onExport, confirmHiding, confirmDeleting, rowClassName, actionWidth, ...props }: CrudViewerProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
52
+ declare function CrudViewer<T, FormType = T>({ idField, loadingData, fields, isDeleting, isHiding, viewable, paginateProps, onDelete, onHide, onUpdate, data, extraAction, onClickUpdate, minusHeight, scroll, onClickClone, className, expandable, size, bordered, descListColumn, extraView, decListLayout, scrollToTop, onClickRefresh, closeViewOnClickUpdate, onExport, confirmHiding, confirmDeleting, rowClassName, actionWidth, draggable, ...props }: CrudViewerProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
43
53
  export default CrudViewer;
@@ -1,216 +1,327 @@
1
- import { jsxs as v, Fragment as z, jsx as n } from "react/jsx-runtime";
2
- import { Modal as U } from "antd";
3
- import F from "../../common/button/CloneButtonTable.es.js";
4
- import rr from "../../common/button/DeleteButtonTable.es.js";
5
- import { ExportButton as or } from "../../common/button/ExportButton.es.js";
6
- import tr from "../../common/button/HideButtonTable.es.js";
7
- import { RefreshButton as ur } from "../../common/button/RefreshButton.es.js";
8
- import mr from "../../common/button/UpdateButtonTable.es.js";
9
- import nr from "../../common/button/ViewButtonTable.es.js";
10
- import cr from "../../common/table/table.es.js";
11
- import { useMemo as E, useState as G, useEffect as er, useCallback as fr } from "react";
12
- import { useTranslationLib as lr } from "../../locale/index.es.js";
13
- import sr from "../CrudSearchComponent.es.js";
14
- import { CrudDecListView as hr } from "./CrudDecListView.es.js";
15
- import { getRendererValueCrudViewer as J } from "./CrudViewerUtil.es.js";
16
- import ar from "../../common/layout/VerticalSpace.es.js";
17
- function Vr({
18
- idField: t = "id",
19
- loadingData: K,
20
- fields: f,
21
- isDeleting: p,
22
- isHiding: i,
23
- viewable: c = !1,
24
- paginateProps: s,
25
- onDelete: h,
26
- onHide: S,
27
- onUpdate: y,
1
+ import { jsxs as D, Fragment as G, jsx as c } from "react/jsx-runtime";
2
+ import { Modal as It } from "antd";
3
+ import { DndContext as St } from "../../node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@dnd-kit/core/dist/core.esm.es.js";
4
+ import { restrictToVerticalAxis as lt } from "../../node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1__react@18.3.1/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.es.js";
5
+ import { CSS as Bt } from "../../node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@18.3.1/node_modules/@dnd-kit/utilities/dist/utilities.esm.es.js";
6
+ import { arrayMove as st, SortableContext as Ct, verticalListSortingStrategy as xt, useSortable as Rt } from "../../node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@18.3.1_react@18.3.1__react@18.3.1__react@18.3.1/node_modules/@dnd-kit/sortable/dist/sortable.esm.es.js";
7
+ import Dt from "../../common/button/Button.es.js";
8
+ import Et from "../../common/button/CloneButtonTable.es.js";
9
+ import Lt from "../../common/button/DeleteButtonTable.es.js";
10
+ import { ExportButton as Mt } from "../../common/button/ExportButton.es.js";
11
+ import Ot from "../../common/button/HideButtonTable.es.js";
12
+ import { RefreshButton as jt } from "../../common/button/RefreshButton.es.js";
13
+ import zt from "../../common/button/UpdateButtonTable.es.js";
14
+ import Vt from "../../common/button/ViewButtonTable.es.js";
15
+ import wt from "../../common/table/table.es.js";
16
+ import et, { useMemo as I, useState as J, useEffect as ct, useCallback as K, useContext as Nt } from "react";
17
+ import { useTranslationLib as _t } from "../../locale/index.es.js";
18
+ import $t from "../CrudSearchComponent.es.js";
19
+ import { CrudDecListView as qt } from "./CrudDecListView.es.js";
20
+ import { getRendererValueCrudViewer as mt } from "./CrudViewerUtil.es.js";
21
+ import { HolderOutlined as Gt } from "@ant-design/icons";
22
+ import Jt from "../../common/layout/VerticalSpace.es.js";
23
+ const Kt = et.memo(wt);
24
+ function io({
25
+ idField: o = "id",
26
+ loadingData: S,
27
+ fields: u,
28
+ isDeleting: x,
29
+ isHiding: l,
30
+ viewable: f = !1,
31
+ paginateProps: h,
32
+ onDelete: y,
33
+ onHide: R,
34
+ onUpdate: T,
28
35
  data: B = [],
29
- extraAction: a,
30
- onClickUpdate: e,
31
- minusHeight: L,
32
- scroll: N,
33
- onClickClone: T,
34
- className: Q,
35
- expandable: W,
36
- size: X,
37
- bordered: Y,
38
- descListColumn: Z,
39
- extraView: g,
40
- decListLayout: d,
41
- scrollToTop: vr,
42
- onClickRefresh: M,
43
- closeViewOnClickUpdate: O,
44
- onExport: I,
45
- confirmHiding: R,
46
- confirmDeleting: V,
47
- rowClassName: w,
48
- actionWidth: D = 190,
49
- ...P
36
+ extraAction: C,
37
+ onClickUpdate: p,
38
+ minusHeight: O,
39
+ scroll: Q,
40
+ onClickClone: E,
41
+ className: X,
42
+ expandable: Y,
43
+ size: Z,
44
+ bordered: A,
45
+ descListColumn: ft,
46
+ extraView: j,
47
+ decListLayout: it,
48
+ scrollToTop: Yt,
49
+ onClickRefresh: P,
50
+ closeViewOnClickUpdate: W,
51
+ onExport: z,
52
+ confirmHiding: k,
53
+ confirmDeleting: H,
54
+ rowClassName: U,
55
+ actionWidth: b = 190,
56
+ draggable: r,
57
+ ...ht
50
58
  }) {
51
- const { t: k } = lr(), _ = E(
52
- () => f.map(
53
- ({ hideInTable: r, hidden: o, width: l, name: m, label: H, halign: x, ...q }) => ({
54
- title: H,
55
- width: l,
56
- key: m,
57
- dataIndex: m,
58
- hidden: r || o,
59
- align: x ?? (q.type === "number" ? "right" : void 0),
60
- render: J(q)
59
+ const { t: d } = _t(), F = I(
60
+ () => u.map(
61
+ ({ hideInTable: t, hidden: n, width: m, name: s, label: _, halign: $, ...M }) => ({
62
+ title: _,
63
+ width: m,
64
+ key: s,
65
+ dataIndex: s,
66
+ hidden: t || n,
67
+ align: $ ?? (M.type === "number" ? "right" : void 0),
68
+ render: mt(M)
61
69
  })
62
70
  ),
63
- [f]
64
- ), [u, b] = G(), [j, C] = G();
65
- er(() => {
66
- B && b((r) => {
67
- if (r)
68
- return B.find((o) => o[t] === r[t]);
71
+ [u]
72
+ ), [e, L] = J(), [V, w] = J(), [v, a] = J([]);
73
+ ct(() => {
74
+ B && a(B);
75
+ }, [B]), ct(() => {
76
+ B && L((t) => {
77
+ if (t)
78
+ return B.find((n) => n[o] === t[o]);
69
79
  });
70
- }, [B, t, u]);
71
- const $ = fr(
72
- (r) => {
73
- var l;
74
- const o = a == null ? void 0 : a(r);
75
- return (Array.isArray(o) ? (l = o == null ? void 0 : o.filter(Boolean)) != null && l.length : o) || y || e || T || h ? /* @__PURE__ */ v(z, { children: [
76
- o,
77
- (y || e) && /* @__PURE__ */ n(
78
- mr,
80
+ }, [B, o, e]);
81
+ const N = K(
82
+ (t) => {
83
+ var m;
84
+ const n = C == null ? void 0 : C(t);
85
+ return (Array.isArray(n) ? (m = n == null ? void 0 : n.filter(Boolean)) != null && m.length : n) || T || p || E || y ? /* @__PURE__ */ D(G, { children: [
86
+ n,
87
+ (T || p) && /* @__PURE__ */ c(
88
+ zt,
79
89
  {
80
- value: r,
81
- onClick: (m) => {
82
- C(m[t]), e == null || e(r), O && b(void 0);
90
+ value: t,
91
+ onClick: (s) => {
92
+ w(s[o]), p == null || p(t), W && L(void 0);
83
93
  }
84
94
  }
85
95
  ),
86
- T && /* @__PURE__ */ n(F, { value: r, onClick: (m) => T(m) }),
87
- I && /* @__PURE__ */ n(
88
- or,
96
+ E && /* @__PURE__ */ c(Et, { value: t, onClick: (s) => E(s) }),
97
+ z && /* @__PURE__ */ c(
98
+ Mt,
89
99
  {
90
- value: r,
91
- onClick: async (m) => await I(m)
100
+ value: t,
101
+ onClick: async (s) => await z(s)
92
102
  }
93
103
  ),
94
- S && /* @__PURE__ */ n(
95
- tr,
104
+ R && /* @__PURE__ */ c(
105
+ Ot,
96
106
  {
97
- value: r,
98
- disabled: i,
99
- shouldConfirm: R,
100
- loading: i && r[t] === j,
101
- onClick: async (m) => {
102
- C(m[t]), await S({ [t]: m[t] });
107
+ value: t,
108
+ disabled: l,
109
+ shouldConfirm: k,
110
+ loading: l && t[o] === V,
111
+ onClick: async (s) => {
112
+ w(s[o]), await R({ [o]: s[o] });
103
113
  }
104
114
  }
105
115
  ),
106
- h && /* @__PURE__ */ n(
107
- rr,
116
+ y && /* @__PURE__ */ c(
117
+ Lt,
108
118
  {
109
- value: r,
110
- disabled: p,
111
- shouldConfirm: V,
112
- loading: p && r[t] === j,
113
- onClick: async (m) => {
114
- C(m[t]), await h({ [t]: m[t] });
119
+ value: t,
120
+ disabled: x,
121
+ shouldConfirm: H,
122
+ loading: x && t[o] === V,
123
+ onClick: async (s) => {
124
+ w(s[o]), await y({ [o]: s[o] });
115
125
  }
116
126
  }
117
127
  )
118
128
  ] }) : void 0;
119
129
  },
120
130
  [
121
- O,
122
- V,
123
- R,
124
- a,
125
- t,
131
+ W,
132
+ H,
133
+ k,
134
+ C,
135
+ o,
136
+ x,
137
+ l,
138
+ E,
126
139
  p,
127
- i,
128
- T,
129
- e,
130
- h,
131
- I,
132
- S,
133
140
  y,
134
- j
141
+ z,
142
+ R,
143
+ T,
144
+ V
135
145
  ]
136
- ), A = E(() => {
137
- let r = typeof c == "string" ? u == null ? void 0 : u[c] : void 0;
138
- if (typeof r == "object") {
139
- const o = f.find((l) => l.name === c);
140
- r = J(o)(
141
- r,
142
- u,
146
+ ), g = K(
147
+ (t) => {
148
+ var s;
149
+ const { active: n, over: m } = t;
150
+ if (r != null && r.onDragEnd && (r == null || r.onDragEnd(t)), n.id !== (m == null ? void 0 : m.id)) {
151
+ const _ = v.findIndex(
152
+ (i) => i[o] === n.id
153
+ ), $ = v.findIndex(
154
+ (i) => i[o] === (m == null ? void 0 : m.id)
155
+ ), M = st(v, _, $);
156
+ a((i) => {
157
+ const vt = i.findIndex(
158
+ (q) => q[o] === (n == null ? void 0 : n.id)
159
+ ), Tt = i.findIndex(
160
+ (q) => q[o] === (m == null ? void 0 : m.id)
161
+ );
162
+ return st(i, vt, Tt);
163
+ }), (s = r == null ? void 0 : r.onDrag) == null || s.call(r, {
164
+ newOrder: M.map((i) => i[o])
165
+ });
166
+ }
167
+ },
168
+ [v, o, r]
169
+ ), yt = I(() => {
170
+ let t = typeof f == "string" ? e == null ? void 0 : e[f] : void 0;
171
+ if (typeof t == "object") {
172
+ const n = u.find((m) => m.name === f);
173
+ t = mt(n)(
174
+ t,
175
+ e,
143
176
  0
144
177
  );
145
178
  }
146
- return r;
147
- }, [c, u, f]);
148
- return /* @__PURE__ */ v("div", { children: [
149
- c && /* @__PURE__ */ n(
150
- U,
179
+ return t;
180
+ }, [f, e, u]), tt = I(
181
+ () => ({
182
+ rowClassName: U,
183
+ className: X,
184
+ scroll: Q ?? (O ? { y: `calc(100vh - ${O})` } : void 0),
185
+ id: "crud-table",
186
+ bordered: A,
187
+ size: Z,
188
+ expandable: Y
189
+ }),
190
+ [U, X, Q, O, A, Z, Y]
191
+ ), ot = I(
192
+ () => h ? {
193
+ total: h.count,
194
+ onChange: h.setPage,
195
+ current: h.page,
196
+ pageSize: h.pageSize
197
+ } : void 0,
198
+ [h]
199
+ ), nt = I(() => {
200
+ const t = T || p || y || C || f, n = [];
201
+ return r && n.push({
202
+ key: "key",
203
+ align: "center",
204
+ width: 5,
205
+ title: r == null ? void 0 : r.columnLabel,
206
+ render: () => /* @__PURE__ */ c(Qt, { tooltip: r == null ? void 0 : r.tooltip })
207
+ }), n.push(...F), t && t && n.push({
208
+ title: d("str.action"),
209
+ fixed: "right",
210
+ width: b,
211
+ render: (m, s) => /* @__PURE__ */ D(G, { children: [
212
+ f && /* @__PURE__ */ c(Vt, { value: s, onClick: L }),
213
+ N(s)
214
+ ] })
215
+ }), n;
216
+ }, [
217
+ F,
218
+ T,
219
+ p,
220
+ y,
221
+ C,
222
+ f,
223
+ d,
224
+ b,
225
+ N
226
+ ]), rt = I(
227
+ () => v.map((t) => t[o]),
228
+ [v, o]
229
+ ), pt = K(() => {
230
+ const t = /* @__PURE__ */ c(
231
+ Kt,
232
+ {
233
+ ...tt,
234
+ dataSource: v,
235
+ loading: S,
236
+ components: r ? { body: { row: Xt } } : void 0,
237
+ pagination: ot,
238
+ columns: nt
239
+ }
240
+ );
241
+ return r ? /* @__PURE__ */ c(St, { modifiers: [lt], onDragEnd: g, children: /* @__PURE__ */ c(
242
+ Ct,
243
+ {
244
+ items: rt,
245
+ strategy: xt,
246
+ children: t
247
+ }
248
+ ) }) : t;
249
+ }, [
250
+ tt,
251
+ v,
252
+ S,
253
+ ot,
254
+ nt,
255
+ r,
256
+ rt,
257
+ g
258
+ ]);
259
+ return /* @__PURE__ */ D("div", { children: [
260
+ f && /* @__PURE__ */ c(
261
+ It,
151
262
  {
152
263
  width: "100%",
153
- open: !!u,
154
- title: A ?? /* @__PURE__ */ n("div", { children: " " }),
155
- footer: /* @__PURE__ */ n(z, {}),
264
+ open: !!e,
265
+ title: yt ?? /* @__PURE__ */ c("div", { children: " " }),
266
+ footer: /* @__PURE__ */ c(G, {}),
156
267
  closable: !0,
157
- onCancel: () => b(void 0),
158
- children: !!u && /* @__PURE__ */ v("div", { children: [
159
- /* @__PURE__ */ n(
160
- hr,
268
+ onCancel: () => L(void 0),
269
+ children: !!e && /* @__PURE__ */ D("div", { children: [
270
+ /* @__PURE__ */ c(
271
+ qt,
161
272
  {
162
- layout: d,
163
- descListColumn: Z,
164
- data: u,
165
- fields: f,
166
- action: $(u)
273
+ layout: it,
274
+ descListColumn: ft,
275
+ data: e,
276
+ fields: u,
277
+ action: N(e)
167
278
  }
168
279
  ),
169
- g == null ? void 0 : g(u)
170
- ] }, u == null ? void 0 : u[t])
280
+ j == null ? void 0 : j(e)
281
+ ] }, e == null ? void 0 : e[o])
171
282
  }
172
283
  ),
173
- /* @__PURE__ */ n(sr, { fields: f, ...P }),
174
- /* @__PURE__ */ v(ar, { children: [
175
- !!M && /* @__PURE__ */ n(ur, { onClick: M }),
176
- /* @__PURE__ */ n(
177
- cr,
178
- {
179
- rowClassName: w,
180
- className: Q,
181
- scroll: N ?? (L ? {
182
- y: `calc(100vh - ${L})`
183
- } : void 0),
184
- id: "crud-table",
185
- dataSource: B,
186
- loading: K,
187
- bordered: Y,
188
- size: X,
189
- expandable: W,
190
- pagination: s ? {
191
- total: s.count,
192
- onChange: s.setPage,
193
- current: s.page,
194
- pageSize: s.pageSize
195
- } : void 0,
196
- columns: y || e || h || a || c ? [
197
- ..._,
198
- {
199
- title: k("str.action"),
200
- dataIndex: "",
201
- fixed: "right",
202
- width: D,
203
- render: (r, o) => /* @__PURE__ */ v(z, { children: [
204
- c && /* @__PURE__ */ n(nr, { value: o, onClick: b }),
205
- $(o)
206
- ] })
207
- }
208
- ] : _
209
- }
210
- )
284
+ /* @__PURE__ */ c($t, { fields: u, ...ht }),
285
+ /* @__PURE__ */ D(Jt, { children: [
286
+ !!P && /* @__PURE__ */ c(jt, { onClick: P }),
287
+ pt()
211
288
  ] })
212
289
  ] });
213
290
  }
291
+ const ut = et.createContext({}), Qt = ({ tooltip: o }) => {
292
+ const { setActivatorNodeRef: S, listeners: u } = Nt(ut);
293
+ return /* @__PURE__ */ c(
294
+ Dt,
295
+ {
296
+ type: "text",
297
+ size: "small",
298
+ tooltip: o,
299
+ icon: /* @__PURE__ */ c(Gt, {}),
300
+ style: { cursor: "move", border: "none" },
301
+ ref: S,
302
+ ...u
303
+ }
304
+ );
305
+ }, Xt = (o) => {
306
+ const {
307
+ attributes: S,
308
+ listeners: u,
309
+ setNodeRef: x,
310
+ setActivatorNodeRef: l,
311
+ transform: f,
312
+ transition: h,
313
+ isDragging: y
314
+ } = Rt({ id: o["data-row-key"] }), R = {
315
+ ...o.style,
316
+ transform: Bt.Translate.toString(f),
317
+ transition: h,
318
+ ...y ? { position: "relative", zIndex: 9999 } : {}
319
+ }, T = I(
320
+ () => ({ setActivatorNodeRef: l, listeners: u }),
321
+ [l, u]
322
+ );
323
+ return /* @__PURE__ */ c(ut.Provider, { value: T, children: /* @__PURE__ */ c("tr", { ...o, ref: x, style: R, ...S }) });
324
+ };
214
325
  export {
215
- Vr as default
326
+ io as default
216
327
  };
package/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./locale/hooks/translation-constants.cjs.js"),u=require("./locale/index.cjs.js"),t=require("./crud/CrudComponent.cjs.js"),r=require("./crud/CrudField.cjs.js"),C=require("./crud/CrudFormWizard.cjs.js"),i=require("./crud/CrudReportComponent.cjs.js"),n=require("./crud/CrudSearchComponent.cjs.js"),a=require("./crud/import/CrudImportComponent.cjs.js"),s=require("./crud/import/CrudImportButton.cjs.js"),m=require("./crud/view/CrudViewer.cjs.js"),d=require("./crud/CrudForm.cjs.js"),e=require("./crud/ImageCrudField.cjs.js"),o=require("./crud/FileCrudField.cjs.js"),F=require("./crud/view/CrudDecListView.cjs.js"),p=require("./crud/view/CrudViewerUtil.cjs.js");exports.TRANSLATION_NAMESPACE=l.TRANSLATION_NAMESPACE;exports.setupI18n=u.setupI18n;exports.updateTranslations=u.updateTranslations;exports.CrudComponent=t;exports.ColorCrudFieldComponent=r.ColorCrudFieldComponent;exports.CrudField=r.default;exports.SelectCrudFieldComponent=r.SelectCrudFieldComponent;exports.CrudFormWizard=C;exports.CrudReportComponent=i;exports.CrudSearchComponent=n;exports.CrudImportComponent=a;exports.CrudImportButton=s;exports.CrudViewer=m;exports.CrudForm=d.CrudForm;exports.CrudFormFields=d.CrudFormFields;exports.FileDownloadProvider=e.FileDownloadProvider;exports.FileUploadProvider=e.FileUploadProvider;exports.ImageCellValue=e.ImageCellValue;exports.ImageCrudCellValue=e.ImageCrudCellValue;exports.ImageCrudField=e.default;exports.FileCellValue=o.FileCellValue;exports.FileCrudCellValue=o.FileCrudCellValue;exports.FileCrudField=o.default;exports.CrudDecListView=F.CrudDecListView;exports.getRendererValueCrudViewer=p.getRendererValueCrudViewer;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./locale/hooks/translation-constants.cjs.js"),u=require("./locale/index.cjs.js"),t=require("./crud/CrudComponent.cjs.js"),r=require("./crud/CrudField.cjs.js"),C=require("./crud/CrudFormWizard.cjs.js"),i=require("./crud/CrudReportComponent.cjs.js"),n=require("./crud/CrudSearchComponent.cjs.js"),e=require("./crud/ImageCrudField.cjs.js"),o=require("./crud/FileCrudField.cjs.js"),a=require("./crud/import/CrudImportComponent.cjs.js"),s=require("./crud/import/CrudImportButton.cjs.js"),m=require("./crud/view/CrudViewer.cjs.js"),d=require("./crud/CrudForm.cjs.js"),F=require("./crud/view/CrudDecListView.cjs.js"),p=require("./crud/view/CrudViewerUtil.cjs.js");exports.TRANSLATION_NAMESPACE=l.TRANSLATION_NAMESPACE;exports.setupI18n=u.setupI18n;exports.updateTranslations=u.updateTranslations;exports.CrudComponent=t;exports.ColorCrudFieldComponent=r.ColorCrudFieldComponent;exports.CrudField=r.default;exports.SelectCrudFieldComponent=r.SelectCrudFieldComponent;exports.CrudFormWizard=C;exports.CrudReportComponent=i;exports.CrudSearchComponent=n;exports.FileDownloadProvider=e.FileDownloadProvider;exports.FileUploadProvider=e.FileUploadProvider;exports.ImageCellValue=e.ImageCellValue;exports.ImageCrudCellValue=e.ImageCrudCellValue;exports.ImageCrudField=e.default;exports.FileCellValue=o.FileCellValue;exports.FileCrudCellValue=o.FileCrudCellValue;exports.FileCrudField=o.default;exports.CrudImportComponent=a;exports.CrudImportButton=s;exports.CrudViewer=m;exports.CrudForm=d.CrudForm;exports.CrudFormFields=d.CrudFormFields;exports.CrudDecListView=F.CrudDecListView;exports.getRendererValueCrudViewer=p.getRendererValueCrudViewer;