@kingteza/crud-component 1.0.54 → 1.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/icon/KIcon.cjs.js +1 -1
- package/common/icon/KIcon.es.js +1 -1
- package/common/picker/ImagePicker.cjs.js +1 -1
- package/common/picker/ImagePicker.es.js +28 -28
- package/common/rich/index.cjs.js +1 -1
- package/common/rich/index.es.js +9 -9
- package/crud/view/CrudViewer.cjs.js +1 -1
- package/crud/view/CrudViewer.es.js +4 -4
- package/hooks/NavigatorHooks.cjs.js +1 -0
- package/hooks/NavigatorHooks.d.ts +1 -0
- package/hooks/NavigatorHooks.es.js +8 -0
- package/icons/FlipHIcon.cjs.js +1 -0
- package/icons/FlipHIcon.d.ts +3 -0
- package/icons/FlipHIcon.es.js +28 -0
- package/icons/FlipVIcon.cjs.js +1 -0
- package/icons/FlipVIcon.d.ts +3 -0
- package/icons/FlipVIcon.es.js +28 -0
- package/package.json +4 -2
- package/_virtual/_commonjsHelpers.cjs.js +0 -1
- package/_virtual/_commonjsHelpers.es.js +0 -8
- package/_virtual/_nodeUtil.cjs.js +0 -1
- package/_virtual/_nodeUtil.es.js +0 -4
- package/_virtual/index.cjs.js +0 -1
- package/_virtual/index.cjs2.js +0 -1
- package/_virtual/index.cjs3.js +0 -1
- package/_virtual/index.es.js +0 -11
- package/_virtual/index.es2.js +0 -7
- package/_virtual/index.es3.js +0 -4
- package/_virtual/isBuffer.cjs.js +0 -1
- package/_virtual/isBuffer.es.js +0 -4
- package/_virtual/quill.cjs.js +0 -1
- package/_virtual/quill.es.js +0 -4
package/common/icon/KIcon.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),s=require("@ant-design/icons"),o=require("@iconify/react"),u=require("react"),i=e=>t=>n.jsx(o.Icon,{...t,icon:e}),I=({icon:e,component:t,...r})=>{const c=u.useMemo(()=>t??i(e),[e,t]);return n.jsx(s,{...r,component:c})};module.exports=I;
|
package/common/icon/KIcon.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import c from "@ant-design/icons";
|
|
3
|
-
import { Icon as e } from "
|
|
3
|
+
import { Icon as e } from "@iconify/react";
|
|
4
4
|
import { useMemo as s } from "react";
|
|
5
5
|
const f = (o) => (r) => /* @__PURE__ */ t(e, { ...r, icon: o }), u = ({ icon: o, component: r, ...n }) => {
|
|
6
6
|
const m = s(() => r ?? f(o), [o, r]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),je=require("
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),je=require("react-advanced-cropper");;/* empty css */;/* empty css */const O=require("@ant-design/icons"),U=require("antd"),s=require("react"),he=require("../../locale/index.cjs.js"),I=require("../button/Button.cjs.js"),we=require("../../util/ImageUtil.cjs.js"),Ce=require("../../icons/FlipHIcon.cjs.js"),be=require("../../icons/FlipVIcon.cjs.js"),ve=U.Form.Item,Y="crud-component.image-picker.button-state";function Z(o){return new Promise((u,p)=>{const n=new FileReader;n.readAsDataURL(o),n.onload=()=>u(n.result),n.onerror=m=>p(m)})}const Se=({values:o=[],required:u,buttonType:p,label:n,name:m,onChange:f,aspectRatio:h,buttonTitle:w,hidePreview:C,buttonSize:g="large",showButtonText:x=!0,showOnlyIcon:_=!1,icon:k=t.jsx(O.UploadOutlined,{}),loading:F,maxCount:b=1,onAdd:a,onRemove:R,listType:q,...A})=>{const[te,re]=s.useState(""),[se,oe]=s.useState(""),[ne,B]=s.useState(!1),T=s.useRef(),l=s.useRef(null),[i,z]=s.useState([]),[j,P]=s.useState(),ie=s.useRef(),ae=()=>B(!1),ce=async e=>{!e.url&&!e.preview&&(e.preview=await Z(e.originFileObj)),oe(e.url||e.preview),B(!0),re(e.name)},[D,N]=s.useState(!1),H=e=>{var r;(r=l.current)==null||r.rotateImage(e?-90:90)},L=s.useCallback(e=>{var r;l.current&&((r=l.current)==null||r.flipImage(e==="h",e==="v"))},[]);s.useEffect(()=>{f==null||f(i[0],i)},[i,f]);const le=async()=>{var y;const e=(y=l.current)==null?void 0:y.getCanvas(),{type:r,size:c,name:v,uid:S}=T.current;N(!0),e==null||e.toBlob(async ge=>{const xe=Object.assign(new File([ge],v,{type:r}),{uid:S}),Q=await we.resizeImage(xe),E=await Z(Q);console.log({url:E});const X={url:E,name:v,uid:S,type:r,size:c,thumbUrl:E,originFileObj:Q};if(a)try{N(!0),await a(X)}finally{N(!1)}z([X,...i]),N(!1)}),P(void 0)},ue=()=>{P(void 0),T.current=void 0},V=s.useCallback(e=>{const r=e;if(r){T.current=r;const c=new FileReader;c.addEventListener("load",()=>{var v;if(typeof c.result=="string"){P(c.result);const S=localStorage.getItem(Y),y=S?JSON.parse(S):void 0;y&&((v=l.current)==null||v.setState(y)),setTimeout(()=>{K(l.current)},100)}}),c.readAsDataURL(r)}},[]);s.useEffect(()=>{if(o!=null&&o.length||typeof o=="string"){const e=Array.isArray(o)?o.map(r=>[{uid:o,url:r}]):[{uid:o,url:o}];z(e)}},[o]);const{t:d}=he.useTranslationLib(),de=s.useMemo(()=>u?{required:u,validator:(e,r,c)=>{j||i!=null&&i.length?c():c(`${n??""} ${d("err.validation.required")}`)}}:void 0,[u,j,i==null?void 0:i.length,n,d]),J=w??d("message.uploadButtonText"),W=s.useMemo(()=>t.jsx(ee,{showLoadingIndicator:D,_buttonTitle:J,buttonSize:g,buttonType:p,fileList:i,hidePreview:C,icon:k,loading:F,listType:q,maxCount:b,onChangeFile:V,onRemove:R,showButtonText:x,handlePreview:ce,setFileList:z}),[D,J,g,p,i,C,k,F,q,b,V,R,x]);ie.current=W.props.beforeUpload;const[pe,$]=s.useState(0),[me,G]=s.useState(0),[M,fe]=s.useState();s.useEffect(()=>{const e=setTimeout(()=>{M&&localStorage.setItem(Y,JSON.stringify(M))},400);return()=>clearTimeout(e)},[M]),s.useEffect(()=>{if(!j){$(0),G(0);const e=setTimeout(()=>{var r;(r=l.current)==null||r.reset()},1500);return()=>clearTimeout(e)}},[j]);const K=s.useCallback(async e=>{if(e){const r=e.getCoordinates();fe(e.getState()),$((r==null?void 0:r.width)??10),G((r==null?void 0:r.height)??10)}},[]);return t.jsxs(t.Fragment,{children:[t.jsx(ve,{label:n,...A,name:m,className:"mb-0",rules:[de,...A.rules??[]],children:W}),t.jsxs(U.Modal,{open:!!j,maskClosable:!1,onOk:le,closable:!1,onCancel:ue,destroyOnHidden:!0,children:[t.jsx(je.Cropper,{ref:l,stencilProps:{grid:!0},style:{border:"1px solid black"},src:j,onChange:e=>{K(e)},aspectRatio:h?{minimum:h,maximum:h}:void 0}),t.jsx("p",{className:"text-center",children:[pe,me].join(" ⨉ ")}),t.jsx("div",{className:"mt-2 d-flex justify-content-center",children:t.jsxs(U.Space.Compact,{children:[t.jsx(I,{size:"large",tooltip:d("str.rotateLeft"),icon:t.jsx(O.RotateLeftOutlined,{}),onClick:()=>H(!0)}),t.jsx(I,{size:"large",icon:t.jsx(O.RotateRightOutlined,{}),tooltip:d("str.rotateRight"),onClick:()=>H(!1)}),t.jsx(I,{size:"large",icon:t.jsx(Ce,{}),tooltip:d("str.flipHorizontal"),onClick:()=>L("h")}),t.jsx(I,{size:"large",icon:t.jsx(be,{}),tooltip:d("str.flipVertical"),onClick:()=>L("v")})]})})]}),t.jsx(U.Modal,{open:ne,title:te,footer:null,onCancel:ae,children:t.jsx("div",{className:"text-center",children:t.jsx("img",{alt:"example",style:{maxWidth:"400px"},src:se})})})]})},ee=({_buttonTitle:o,buttonSize:u,buttonType:p,fileList:n,hidePreview:m,icon:f,loading:h,maxCount:w,onChangeFile:C,onRemove:g,showButtonText:x,handlePreview:_,setFileList:k,showLoadingIndicator:F,listType:b="picture"})=>t.jsxs(U.Upload,{accept:"image/x-png,image/gif,image/jpeg",fileList:n,defaultFileList:n,onChange:()=>{},className:(n.length>=w?" hide-upload ":"")+" mb-0",multiple:!1,onPreview:m?void 0:_,onDrop:a=>(C(a.dataTransfer.files.item(0)),!1),listType:b,showUploadList:!m,onRemove:a=>{const R=n.filter(q=>a.uid!==q.uid);g==null||g(a),k(R)},beforeUpload:async a=>(C(a),!1),maxCount:w,children:[F&&t.jsx(O.LoadingOutlined,{}),t.jsx("div",{className:"d-flex flex-column",children:n.length<w&&(b==="picture-circle"?t.jsx(O.UploadOutlined,{}):t.jsx(I,{loading:h,tooltip:x?void 0:o,size:u,icon:f,type:x?p:"text",children:x?o:void 0}))})]},n.length);exports.UploadComponent=ee;exports.default=Se;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as r, jsxs as z, Fragment as
|
|
2
|
-
import { Cropper as xe } from "
|
|
1
|
+
import { jsx as r, jsxs as z, Fragment as Ie } from "react/jsx-runtime";
|
|
2
|
+
import { Cropper as xe } from "react-advanced-cropper";
|
|
3
3
|
/* empty css */
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { RotateLeftOutlined as Fe, RotateRightOutlined as Oe, UploadOutlined as
|
|
5
|
+
import { RotateLeftOutlined as Fe, RotateRightOutlined as Oe, UploadOutlined as ne, LoadingOutlined as Se } from "@ant-design/icons";
|
|
6
6
|
import { Form as Ue, Modal as te, Space as ke, Upload as Re } from "antd";
|
|
7
7
|
import H, { useRef as L, useState as w, useCallback as V, useEffect as j, useMemo as re } from "react";
|
|
8
8
|
import { useTranslationLib as Ne } from "../../locale/index.es.js";
|
|
@@ -30,7 +30,7 @@ const Ke = ({
|
|
|
30
30
|
buttonSize: f = "large",
|
|
31
31
|
showButtonText: g = !0,
|
|
32
32
|
showOnlyIcon: _ = !1,
|
|
33
|
-
icon: S = /* @__PURE__ */ r(
|
|
33
|
+
icon: S = /* @__PURE__ */ r(ne, {}),
|
|
34
34
|
loading: U,
|
|
35
35
|
maxCount: y = 1,
|
|
36
36
|
onAdd: s,
|
|
@@ -38,8 +38,8 @@ const Ke = ({
|
|
|
38
38
|
listType: R,
|
|
39
39
|
...E
|
|
40
40
|
}) => {
|
|
41
|
-
const [
|
|
42
|
-
!e.url && !e.preview && (e.preview = await ie(e.originFileObj)),
|
|
41
|
+
const [se, ae] = H.useState(""), [le, ce] = H.useState(""), [de, M] = H.useState(!1), T = L(), l = L(null), [n, P] = w([]), [h, B] = w(), me = L(), pe = () => M(!1), ue = async (e) => {
|
|
42
|
+
!e.url && !e.preview && (e.preview = await ie(e.originFileObj)), ce(e.url || e.preview), M(!0), ae(e.name);
|
|
43
43
|
}, [J, N] = w(!1), W = (e) => {
|
|
44
44
|
var t;
|
|
45
45
|
(t = l.current) == null || t.rotateImage(e ? -90 : 90);
|
|
@@ -50,13 +50,13 @@ const Ke = ({
|
|
|
50
50
|
j(() => {
|
|
51
51
|
u == null || u(n[0], n);
|
|
52
52
|
}, [n, u]);
|
|
53
|
-
const
|
|
53
|
+
const fe = async () => {
|
|
54
54
|
var F;
|
|
55
55
|
const e = (F = l.current) == null ? void 0 : F.getCanvas(), { type: t, size: a, name: I, uid: x } = T.current;
|
|
56
|
-
N(!0), e == null || e.toBlob(async (
|
|
57
|
-
const
|
|
56
|
+
N(!0), e == null || e.toBlob(async (ve) => {
|
|
57
|
+
const ye = Object.assign(new File([ve], I, { type: t }), {
|
|
58
58
|
uid: x
|
|
59
|
-
}), q = await je.resizeImage(
|
|
59
|
+
}), q = await je.resizeImage(ye), D = await ie(q);
|
|
60
60
|
console.log({ url: D });
|
|
61
61
|
const ee = {
|
|
62
62
|
url: D,
|
|
@@ -75,7 +75,7 @@ const Ke = ({
|
|
|
75
75
|
}
|
|
76
76
|
P([ee, ...n]), N(!1);
|
|
77
77
|
}), B(void 0);
|
|
78
|
-
},
|
|
78
|
+
}, ge = () => {
|
|
79
79
|
B(void 0), T.current = void 0;
|
|
80
80
|
}, G = V((e) => {
|
|
81
81
|
const t = e;
|
|
@@ -100,7 +100,7 @@ const Ke = ({
|
|
|
100
100
|
P(e);
|
|
101
101
|
}
|
|
102
102
|
}, [o]);
|
|
103
|
-
const { t: d } = Ne(),
|
|
103
|
+
const { t: d } = Ne(), he = re(
|
|
104
104
|
() => c ? {
|
|
105
105
|
required: c,
|
|
106
106
|
validator: (e, t, a) => {
|
|
@@ -125,7 +125,7 @@ const Ke = ({
|
|
|
125
125
|
onChangeFile: G,
|
|
126
126
|
onRemove: k,
|
|
127
127
|
showButtonText: g,
|
|
128
|
-
handlePreview:
|
|
128
|
+
handlePreview: ue,
|
|
129
129
|
setFileList: P
|
|
130
130
|
}
|
|
131
131
|
),
|
|
@@ -145,8 +145,8 @@ const Ke = ({
|
|
|
145
145
|
g
|
|
146
146
|
]
|
|
147
147
|
);
|
|
148
|
-
|
|
149
|
-
const [
|
|
148
|
+
me.current = Q.props.beforeUpload;
|
|
149
|
+
const [we, X] = w(0), [Ce, Y] = w(0), [A, be] = w();
|
|
150
150
|
j(() => {
|
|
151
151
|
const e = setTimeout(() => {
|
|
152
152
|
A && localStorage.setItem(oe, JSON.stringify(A));
|
|
@@ -165,10 +165,10 @@ const Ke = ({
|
|
|
165
165
|
const Z = V(async (e) => {
|
|
166
166
|
if (e) {
|
|
167
167
|
const t = e.getCoordinates();
|
|
168
|
-
|
|
168
|
+
be(e.getState()), X((t == null ? void 0 : t.width) ?? 10), Y((t == null ? void 0 : t.height) ?? 10);
|
|
169
169
|
}
|
|
170
170
|
}, []);
|
|
171
|
-
return /* @__PURE__ */ z(
|
|
171
|
+
return /* @__PURE__ */ z(Ie, { children: [
|
|
172
172
|
/* @__PURE__ */ r(
|
|
173
173
|
Pe,
|
|
174
174
|
{
|
|
@@ -176,7 +176,7 @@ const Ke = ({
|
|
|
176
176
|
...E,
|
|
177
177
|
name: p,
|
|
178
178
|
className: "mb-0",
|
|
179
|
-
rules: [
|
|
179
|
+
rules: [he, ...E.rules ?? []],
|
|
180
180
|
children: Q
|
|
181
181
|
}
|
|
182
182
|
),
|
|
@@ -185,9 +185,9 @@ const Ke = ({
|
|
|
185
185
|
{
|
|
186
186
|
open: !!h,
|
|
187
187
|
maskClosable: !1,
|
|
188
|
-
onOk:
|
|
188
|
+
onOk: fe,
|
|
189
189
|
closable: !1,
|
|
190
|
-
onCancel:
|
|
190
|
+
onCancel: ge,
|
|
191
191
|
destroyOnHidden: !0,
|
|
192
192
|
children: [
|
|
193
193
|
/* @__PURE__ */ r(
|
|
@@ -208,7 +208,7 @@ const Ke = ({
|
|
|
208
208
|
} : void 0
|
|
209
209
|
}
|
|
210
210
|
),
|
|
211
|
-
/* @__PURE__ */ r("p", { className: "text-center", children: [
|
|
211
|
+
/* @__PURE__ */ r("p", { className: "text-center", children: [we, Ce].join(" ⨉ ") }),
|
|
212
212
|
/* @__PURE__ */ r("div", { className: "mt-2 d-flex justify-content-center", children: /* @__PURE__ */ z(ke.Compact, { children: [
|
|
213
213
|
/* @__PURE__ */ r(
|
|
214
214
|
O,
|
|
@@ -253,11 +253,11 @@ const Ke = ({
|
|
|
253
253
|
/* @__PURE__ */ r(
|
|
254
254
|
te,
|
|
255
255
|
{
|
|
256
|
-
open:
|
|
257
|
-
title:
|
|
256
|
+
open: de,
|
|
257
|
+
title: se,
|
|
258
258
|
footer: null,
|
|
259
|
-
onCancel:
|
|
260
|
-
children: /* @__PURE__ */ r("div", { className: "text-center", children: /* @__PURE__ */ r("img", { alt: "example", style: { maxWidth: "400px" }, src:
|
|
259
|
+
onCancel: pe,
|
|
260
|
+
children: /* @__PURE__ */ r("div", { className: "text-center", children: /* @__PURE__ */ r("img", { alt: "example", style: { maxWidth: "400px" }, src: le }) })
|
|
261
261
|
}
|
|
262
262
|
)
|
|
263
263
|
] });
|
|
@@ -277,7 +277,7 @@ const Ke = ({
|
|
|
277
277
|
setFileList: S,
|
|
278
278
|
showLoadingIndicator: U,
|
|
279
279
|
listType: y = "picture"
|
|
280
|
-
}) => /* @__PURE__ */
|
|
280
|
+
}) => /* @__PURE__ */ z(
|
|
281
281
|
Re,
|
|
282
282
|
{
|
|
283
283
|
accept: "image/x-png,image/gif,image/jpeg",
|
|
@@ -299,7 +299,7 @@ const Ke = ({
|
|
|
299
299
|
maxCount: b,
|
|
300
300
|
children: [
|
|
301
301
|
U && /* @__PURE__ */ r(Se, {}),
|
|
302
|
-
/* @__PURE__ */ r("div", { className: "d-flex flex-column", children: i.length < b && (y === "picture-circle" ? /* @__PURE__ */ r(
|
|
302
|
+
/* @__PURE__ */ r("div", { className: "d-flex flex-column", children: i.length < b && (y === "picture-circle" ? /* @__PURE__ */ r(ne, {}) : /* @__PURE__ */ r(
|
|
303
303
|
O,
|
|
304
304
|
{
|
|
305
305
|
loading: C,
|
|
@@ -313,7 +313,7 @@ const Ke = ({
|
|
|
313
313
|
]
|
|
314
314
|
},
|
|
315
315
|
i.length
|
|
316
|
-
)
|
|
316
|
+
);
|
|
317
317
|
export {
|
|
318
318
|
Be as UploadComponent,
|
|
319
319
|
Ke as default
|
package/common/rich/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";var g=Object.create;var p=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var w=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of V(t))!F.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(s=q(t,o))||s.enumerable});return e};var R=(e,t,r)=>(r=e!=null?g(j(e)):{},w(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime");;/* empty css */;/* empty css */const h=require("antd"),c=require("react"),y=require("../../util/ValidationUtil.cjs.js"),E=c.lazy(async()=>{const{default:e}=await import("react-quill");return{default:t=>a.jsx(e,{...t})}}),S=({name:e,label:t,required:r,rules:s=[],disabled:o})=>{const n=h.Form.useFormInstance(),[u,d]=c.useState(""),f={toolbar:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],["link"],["clean"]]},b=["bold","italic","underline","strike","blockquote","list","bullet","link"];c.useEffect(()=>{const i=n.getFieldValue(e);i&&i!=="<p></p>"&&i!=="<p><br></p>"&&d(i)},[n,e]);const l=h.Form.useWatch(e,n);c.useEffect(()=>{l!==u&&d(!l||l==="<p></p>"||l==="<p><br></p>"?"":l)},[l,u]);const k=i=>{d(i);const x=!i||i==="<p></p>"||i.trim()==="<p><br></p>"?void 0:i;n.setFieldValue(e,x),n.validateFields([e]).catch(()=>{})},m=c.useMemo(()=>r?[...s,...y.required(t??"")]:s,[r,s,t]);return a.jsx(h.Form.Item,{name:e,label:t,rules:m,children:a.jsx(c.Suspense,{fallback:a.jsx("div",{children:"Loading editor..."}),children:a.jsx(E,{readOnly:o,value:u,onChange:k,theme:"snow",className:"bg-white dark:!bg-[#141414] dark:text-white dark:!fill-white",modules:f,formats:b})})})};exports.RichTextEditor=S;
|
package/common/rich/index.es.js
CHANGED
|
@@ -5,11 +5,11 @@ import { Form as a } from "antd";
|
|
|
5
5
|
import V, { useState as g, useEffect as u, useMemo as w, Suspense as F } from "react";
|
|
6
6
|
import x from "../../util/ValidationUtil.es.js";
|
|
7
7
|
const R = V.lazy(async () => {
|
|
8
|
-
const { default: e } = await import("
|
|
9
|
-
return { default: (
|
|
8
|
+
const { default: e } = await import("react-quill");
|
|
9
|
+
return { default: (o) => /* @__PURE__ */ l(e, { ...o }) };
|
|
10
10
|
}), S = ({
|
|
11
11
|
name: e,
|
|
12
|
-
label:
|
|
12
|
+
label: o,
|
|
13
13
|
required: d,
|
|
14
14
|
rules: c = [],
|
|
15
15
|
disabled: p
|
|
@@ -35,20 +35,20 @@ const R = V.lazy(async () => {
|
|
|
35
35
|
const t = r.getFieldValue(e);
|
|
36
36
|
t && t !== "<p></p>" && t !== "<p><br></p>" && s(t);
|
|
37
37
|
}, [r, e]);
|
|
38
|
-
const
|
|
38
|
+
const i = a.useWatch(e, r);
|
|
39
39
|
u(() => {
|
|
40
|
-
|
|
41
|
-
}, [
|
|
40
|
+
i !== n && s(!i || i === "<p></p>" || i === "<p><br></p>" ? "" : i);
|
|
41
|
+
}, [i, n]);
|
|
42
42
|
const h = (t) => {
|
|
43
43
|
s(t);
|
|
44
44
|
const k = !t || t === "<p></p>" || t.trim() === "<p><br></p>" ? void 0 : t;
|
|
45
45
|
r.setFieldValue(e, k), r.validateFields([e]).catch(() => {
|
|
46
46
|
});
|
|
47
47
|
}, b = w(
|
|
48
|
-
() => d ? [...c, ...x.required(
|
|
49
|
-
[d, c,
|
|
48
|
+
() => d ? [...c, ...x.required(o ?? "")] : c,
|
|
49
|
+
[d, c, o]
|
|
50
50
|
);
|
|
51
|
-
return /* @__PURE__ */ l(a.Item, { name: e, label:
|
|
51
|
+
return /* @__PURE__ */ l(a.Item, { name: e, label: o, rules: b, children: /* @__PURE__ */ l(F, { fallback: /* @__PURE__ */ l("div", { children: "Loading editor..." }), children: /* @__PURE__ */ l(
|
|
52
52
|
R,
|
|
53
53
|
{
|
|
54
54
|
readOnly: p,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),xt=require("antd"),mt=require("@dnd-kit/core"),jt=require("@dnd-kit/modifiers"),ht=require("@dnd-kit/utilities"),M=require("@dnd-kit/sortable"),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:f,isDeleting:T,isHiding:S,viewable:x=!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:st,extraView:D,decListLayout:ot,scrollToTop:Nt,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(()=>f.map(({hideInTable:t,hidden:s,width:c,name:r,label:_,halign:$,...E})=>({title:_,width:c,key:r,dataIndex:r,hidden:t||s,align:$??(E.type==="number"?"right":void 0),render:et.getRendererValueCrudViewer(E)})),[f]),[i,V]=u.useState(),[O,z]=u.useState(),[q,d]=u.useState([]);u.useEffect(()=>{B&&d(B)},[B]),u.useEffect(()=>{B&&V(t=>{if(t)return B.find(s=>s[e]===t[e])})},[B,e,i]);const N=u.useCallback(t=>{var c;const s=I==null?void 0:I(t);return(Array.isArray(s)?(c=s==null?void 0:s.filter(Boolean))!=null&&c.length:s)||l||y||R||h?n.jsxs(n.Fragment,{children:[s,(l||y)&&n.jsx(It,{value:t,onClick:r=>{z(r[e]),y==null||y(t),Z&&V(void 0)}}),R&&n.jsx(qt,{value:t,onClick:r=>R(r)}),L&&n.jsx(vt.ExportButton,{value:t,onClick:async r=>await L(r)}),C&&n.jsx(St,{value:t,disabled:S,shouldConfirm:A,loading:S&&t[e]===O,onClick:async r=>{z(r[e]),await C({[e]:r[e]})}}),h&&n.jsx(lt,{value:t,disabled:T,shouldConfirm:P,loading:T&&t[e]===O,onClick:async r=>{z(r[e]),await h({[e]:r[e]})}})]}):void 0},[Z,P,A,I,e,T,S,R,y,h,L,C,l,O]),b=u.useCallback(t=>{var r;const{active:s,over:c}=t;if(o!=null&&o.onDragEnd&&(o==null||o.onDragEnd(t)),s.id!==(c==null?void 0:c.id)){const _=q.findIndex(m=>m[e]===s.id),$=q.findIndex(m=>m[e]===(c==null?void 0:c.id)),E=M.arrayMove(q,_,$);d(m=>{const it=m.findIndex(k=>k[e]===(s==null?void 0:s.id)),ft=m.findIndex(k=>k[e]===(c==null?void 0:c.id));return M.arrayMove(m,it,ft)}),(r=o==null?void 0:o.onDrag)==null||r.call(o,{newOrder:E.map(m=>m[e])})}},[q,e,o]),ut=u.useMemo(()=>{let t=typeof x=="string"?i==null?void 0:i[x]:void 0;if(typeof t=="object"){const s=f.find(c=>c.name===x);t=et.getRendererValueCrudViewer(s)(t,i,0)}return t},[x,i,f]),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||x,s=[];return o&&s.push({key:"key",align:"center",width:5,title:o==null?void 0:o.columnLabel,render:()=>n.jsx(Ot,{tooltip:o==null?void 0:o.tooltip})}),s.push(...U),t&&t&&s.push({title:p("str.action"),fixed:"right",width:H,render:(c,r)=>n.jsxs(n.Fragment,{children:[x&&n.jsx(Tt,{value:r,onClick:V}),N(r)]})}),s},[U,l,y,h,I,x,p,H,N]),tt=u.useMemo(()=>q.map(t=>t[e]),[q,e]),ct=u.useCallback(()=>{const t=n.jsx(Dt,{...a,dataSource:q,loading:v,components:o?{body:{row:zt}}:void 0,pagination:F,columns:g});return o?n.jsx(mt.DndContext,{modifiers:[jt.restrictToVerticalAxis],onDragEnd:b,children:n.jsx(M.SortableContext,{items:tt,strategy:M.verticalListSortingStrategy,children:t})}):t},[a,q,v,F,g,o,tt,b]);return n.jsxs("div",{children:[x&&n.jsx(xt.Modal,{width:"100%",open:!!i,title:ut??n.jsx("div",{children:" "}),footer:n.jsx(n.Fragment,{}),closable:!0,onCancel:()=>V(void 0),children:!!i&&n.jsxs("div",{children:[n.jsx(Vt.CrudDecListView,{layout:ot,descListColumn:st,data:i,fields:f,action:N(i)}),D==null?void 0:D(i)]},i==null?void 0:i[e])}),n.jsx(Rt,{fields:f,...rt}),n.jsxs(wt,{children:[!!Y&&n.jsx(Bt.RefreshButton,{onClick:Y}),ct()]})]})}const nt=u.createContext({}),Ot=({tooltip:e})=>{const{setActivatorNodeRef:v,listeners:f}=u.useContext(nt);return n.jsx(yt,{type:"text",size:"small",tooltip:e,icon:n.jsx(Et.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:v,...f})},zt=e=>{const{attributes:v,listeners:f,setNodeRef:T,setActivatorNodeRef:S,transform:x,transition:j,isDragging:h}=M.useSortable({id:e["data-row-key"]}),C={...e.style,transform:ht.CSS.Translate.toString(x),transition:j,...h?{position:"relative",zIndex:9999}:{}},l=u.useMemo(()=>({setActivatorNodeRef:S,listeners:f}),[S,f]);return n.jsx(nt.Provider,{value:l,children:n.jsx("tr",{...e,ref:T,style:C,...v})})};module.exports=Lt;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as D, Fragment as G, jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import { Modal as It } from "antd";
|
|
3
|
-
import { DndContext as St } from "
|
|
4
|
-
import { restrictToVerticalAxis as lt } from "
|
|
5
|
-
import { CSS as Bt } from "
|
|
6
|
-
import { arrayMove as st, SortableContext as Ct, verticalListSortingStrategy as xt, useSortable as Rt } from "
|
|
3
|
+
import { DndContext as St } from "@dnd-kit/core";
|
|
4
|
+
import { restrictToVerticalAxis as lt } from "@dnd-kit/modifiers";
|
|
5
|
+
import { CSS as Bt } from "@dnd-kit/utilities";
|
|
6
|
+
import { arrayMove as st, SortableContext as Ct, verticalListSortingStrategy as xt, useSortable as Rt } from "@dnd-kit/sortable";
|
|
7
7
|
import Dt from "../../common/button/Button.es.js";
|
|
8
8
|
import Et from "../../common/button/CloneButtonTable.es.js";
|
|
9
9
|
import Lt from "../../common/button/DeleteButtonTable.es.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react-router-dom");function t(){if(e.useInRouterContext())return e.useNavigate()}exports.useNavigateOptional=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useNavigateOptional(): import('react-router-dom').NavigateFunction | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),n=require("../common/icon/KIcon.cjs.js");function s(i){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...i,children:t.jsxs("g",{fill:i.fill,children:[t.jsx("path",{fillOpacity:.5,d:"M18 7a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-3v2h3a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3h-3v2z"}),t.jsx("path",{d:"M13 3h-2v18h2zM5 8a1 1 0 0 1 1-1h3V5H6a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h3v-2H6a1 1 0 0 1-1-1z"})]})})}const h=s,e=i=>t.jsx(n,{component:h,...i});module.exports=e;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as h, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import n from "../common/icon/KIcon.es.js";
|
|
3
|
+
function o(t) {
|
|
4
|
+
return /* @__PURE__ */ h(
|
|
5
|
+
"svg",
|
|
6
|
+
{
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8
|
+
width: 24,
|
|
9
|
+
height: 24,
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
...t,
|
|
12
|
+
children: /* @__PURE__ */ i("g", { fill: t.fill, children: [
|
|
13
|
+
/* @__PURE__ */ h(
|
|
14
|
+
"path",
|
|
15
|
+
{
|
|
16
|
+
fillOpacity: 0.5,
|
|
17
|
+
d: "M18 7a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-3v2h3a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3h-3v2z"
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
/* @__PURE__ */ h("path", { d: "M13 3h-2v18h2zM5 8a1 1 0 0 1 1-1h3V5H6a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h3v-2H6a1 1 0 0 1-1-1z" })
|
|
21
|
+
] })
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const a = o, c = (t) => /* @__PURE__ */ h(n, { component: a, ...t });
|
|
26
|
+
export {
|
|
27
|
+
c as default
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),n=require("../common/icon/KIcon.cjs.js");function s(i){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...i,children:t.jsxs("g",{fill:i.fill,children:[t.jsx("path",{fillOpacity:.5,d:"M17 18a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1v-3H5v3a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-3h-2z"}),t.jsx("path",{d:"M16 5a1 1 0 0 1 1 1v3h2V6a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v3h2V6a1 1 0 0 1 1-1zm5 8v-2H3v2z"})]})})}const e=s,c=i=>t.jsx(n,{component:e,...i});module.exports=c;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as i, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import o from "../common/icon/KIcon.es.js";
|
|
3
|
+
function a(t) {
|
|
4
|
+
return /* @__PURE__ */ i(
|
|
5
|
+
"svg",
|
|
6
|
+
{
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8
|
+
width: 24,
|
|
9
|
+
height: 24,
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
...t,
|
|
12
|
+
children: /* @__PURE__ */ n("g", { fill: t.fill, children: [
|
|
13
|
+
/* @__PURE__ */ i(
|
|
14
|
+
"path",
|
|
15
|
+
{
|
|
16
|
+
fillOpacity: 0.5,
|
|
17
|
+
d: "M17 18a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1v-3H5v3a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-3h-2z"
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
/* @__PURE__ */ i("path", { d: "M16 5a1 1 0 0 1 1 1v3h2V6a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v3h2V6a1 1 0 0 1 1-1zm5 8v-2H3v2z" })
|
|
21
|
+
] })
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const h = a, c = (t) => /* @__PURE__ */ i(o, { component: h, ...t });
|
|
26
|
+
export {
|
|
27
|
+
c as default
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingteza/crud-component",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.56",
|
|
5
5
|
"description": "React CRUD component library with Ant Design",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react",
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"/crud/",
|
|
26
26
|
"/common/",
|
|
27
27
|
"/types/",
|
|
28
|
+
"/icons/",
|
|
29
|
+
"/hooks/",
|
|
28
30
|
"/util/",
|
|
29
|
-
"/_virtual/",
|
|
30
31
|
"/locale/",
|
|
31
32
|
"/README.md"
|
|
32
33
|
],
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
"build": "npm run clean && tsc && vite build && cp package.json README.md .npmignore dist/",
|
|
39
40
|
"publish-npm": "yarn build && cd dist && npm whoami >/dev/null 2>&1 || npm login && npm publish",
|
|
40
41
|
"lint": "eslint .",
|
|
42
|
+
"tsc": "tsc",
|
|
41
43
|
"preview": "vite preview"
|
|
42
44
|
},
|
|
43
45
|
"exports": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}exports.commonjsGlobal=o;exports.getDefaultExportFromCjs=l;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var o = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
2
|
-
function l(e) {
|
|
3
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
|
-
}
|
|
5
|
-
export {
|
|
6
|
-
o as commonjsGlobal,
|
|
7
|
-
l as getDefaultExportFromCjs
|
|
8
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
|
package/_virtual/_nodeUtil.es.js
DELETED
package/_virtual/index.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./_commonjsHelpers.cjs.js"),r=require("../node_modules/.pnpm/react-quill@2.0.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-quill/lib/index.cjs.js");var o=r.__require();const e=t.getDefaultExportFromCjs(o),l=Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));exports.default=e;exports.index=l;
|
package/_virtual/index.cjs2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./_commonjsHelpers.cjs.js"),r=require("../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js");var s=r.__require();const t=e.getDefaultExportFromCjs(s);module.exports=t;
|
package/_virtual/index.cjs3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
|
package/_virtual/index.es.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.es.js";
|
|
2
|
-
import { __require as r } from "../node_modules/.pnpm/react-quill@2.0.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-quill/lib/index.es.js";
|
|
3
|
-
var t = r();
|
|
4
|
-
const o = /* @__PURE__ */ e(t), l = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5
|
-
__proto__: null,
|
|
6
|
-
default: o
|
|
7
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
8
|
-
export {
|
|
9
|
-
o as default,
|
|
10
|
-
l as i
|
|
11
|
-
};
|
package/_virtual/index.es2.js
DELETED
package/_virtual/index.es3.js
DELETED
package/_virtual/isBuffer.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
|
package/_virtual/isBuffer.es.js
DELETED
package/_virtual/quill.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
|
package/_virtual/quill.es.js
DELETED