@kingteza/crud-component 1.25.1 → 1.27.0
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),y=require("antd"),q=require("react"),K=require("react-highlight-words"),Q=require("../locale/index.cjs.js"),V=require("./FileCrudField.cjs.js"),X=require("./ImageCrudField.cjs.js"),Y=require("../common/check-box/CheckBox.cjs.js"),Z=require("../common/date-picker/DatePicker.cjs.js"),ee=require("../common/date-picker/TimePicker.cjs.js"),_=require("../common/select/SelectComponent.cjs.js"),te=require("../common/text-field/NumberField.cjs.js"),re=require("../common/text-field/PhoneNumberField.cjs.js"),ae=require("../common/text-field/TextField.cjs.js"),le=require("../common/tooltip/TooltipComponent.cjs.js"),ne=require("./CrudTextAreaComponent.cjs.js"),U=require("../util/CrudUtil.cjs.js");function oe(N){const{label:o,name:c,type:b,required:i,hidden:P,rules:g=[],updatable:f=!0,readonly:S=!1,fieldClassName:m,customFormFieldRender:w,fieldTooltip:j,fieldHelper:p,formLayoutProps:T,...e}=N,C=y.Form.useFormInstance();q.useEffect(()=>{if(b==="select"){const{items:r=[],onSearch:s,searchOnType:n}=e;!(r!=null&&r.length)&&!n&&(s==null||s(void 0,C,e==null?void 0:e.updatingValue))}},[C,e,b,e==null?void 0:e.updatingValue]);const{t:O}=Q.useTranslationLibNoNS();if(S||P)return t.jsx(t.Fragment,{});if(w)return w(C,N);switch(b){case"text":case"email":case"password":{const{onChange:r,placeholder:s,addonAfter:n,addonBefore:d}=e;return t.jsx(ae.default,{...T,placeholder:s,disabled:!f,rules:g,required:i,onChange:r?h=>r(h,C):void 0,type:b,name:c,tooltip:j,label:o,className:m,autoComplete:"new-password",addonAfter:n,addonBefore:d,help:p})}case"phone":{const{onChange:r,placeholder:s,addonAfter:n,addonBefore:d}=e;return t.jsx(re,{...e,...T,placeholder:s,disabled:!f,rules:g,required:i,onChange:r?h=>r(h,C):void 0,type:b,name:c,tooltip:j,label:o,className:m,autoComplete:"new-password",addonAfter:n,addonBefore:d,help:p})}case"number":{const{onChange:r,placeholder:s,allowMinus:n,min:d,max:h,addonAfter:x,addonBefore:v}=e;return t.jsx(te,{...T,placeholder:s,disabled:!f,moneyField:!!e.formatted,type:b,onChange:r?F=>r(F,C):void 0,rules:g,autoComplete:"false",required:i,tooltip:j,className:m,min:n?null:d,max:h,addonAfter:x,addonBefore:v,name:c,label:o,help:p})}case"date":{const{range:r,disableToday:s,disabledFutureDays:n,disabledPastDays:d,onChange:h,placeholder:x,format:v}=e;return t.jsx(Z,{...T,placeholder:x,required:i,disabled:!f,type:b,format:v,tooltip:j,range:r,name:c,label:o,onChange:h?F=>h(F,C):void 0,className:m,disableToday:s,disabledFutureDays:n,disabledPastDays:d,help:p})}case"time":{const{range:r=!1,disableCurrent:s,disabledFuture:n,disabledPast:d,onChange:h,use12Hours:x,format:v,placeholder:F}=e;return t.jsx(ee,{...T,placeholder:F,required:i,format:v,disabled:!f,type:b,tooltip:j,range:r,use12Hours:x,name:c,label:o,onChange:h?l=>h(l,C):void 0,className:m,disableCurrent:s,disabledFuture:n,disabledPast:d,help:p})}case"textarea":return t.jsx(ne,{...N});case"image":return t.jsx(X.default,{...e,required:i,name:c,label:o,rules:g,fieldHelper:p,fieldClassName:m,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"file":return t.jsx(V.default,{...e,required:i,name:c,label:o,rules:g,fieldHelper:p,fieldClassName:m,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"select":return t.jsx(D,{...e,required:i,name:c,label:o,rules:g,fieldClassName:m,form:C,help:p,updatable:f,readonly:S,fieldTooltip:j,fieldHelper:p});case"enum":{const{enum:r,radio:s=!1,translation:n,onChange:d,onSearch:h,multiple:x,tagRender:v}=e,F=Array.isArray(r)?r:Object.keys(r);return s?t.jsx(y.Form.Item,{...e,...T,name:c,required:i,tooltip:j,rules:g,label:o,className:["w-100",m].join(" "),help:p,children:t.jsx(y.Radio.Group,{...e,onChange:d?l=>{var k;return d((k=l==null?void 0:l.target)==null?void 0:k.value,C)}:void 0,children:F.map(l=>t.jsx(y.Radio,{disabled:!f,value:l,children:n?O(n[l]):l},l))})}):t.jsx(_,{...e,...T,tagRender:typeof v=="function"?v:v?l=>{const{value:k,label:R}=l,H=v[k];return H?t.jsx(y.Tag,{color:H.color,children:R}):t.jsx(y.Tag,{children:R})}:void 0,onChange:d?l=>d(l,C):void 0,className:["w-100",m].join(" "),name:c,items:F,required:i,tooltip:j,rules:g,label:o,help:p,disabled:!f,onSearch:h?l=>h(l,C):void 0,allowClear:!0,mode:x?"multiple":void 0,showLoadingInEmptyIndicator:!0,itemBuilder:l=>t.jsx(y.Select.Option,{value:l,children:n?O(n[l]):l},l)})}case"checkbox":{const{onChange:r,switch:s}=e;return t.jsx(Y,{...T,className:m,rules:g,onChange:r?n=>r(n,C):void 0,label:o,tooltip:j,disabled:!f,name:c,help:p,switch:s})}case"color":return t.jsx(W,{...e,type:"color",required:i,name:c,label:o,rules:g,fieldClassName:m,updatable:f,readonly:S,fieldTooltip:j,fieldHelper:p});default:return t.jsx(t.Fragment,{children:`${b} Not Implemented`})}}function D(N){const{items:o=[],loading:c,searchOnType:b,onSearch:i,multiple:P,onChange:g,highlightSearch:f,required:S,fieldClassName:m,rules:w,fieldTooltip:j,updatable:p,label:T,name:e,tagRender:C,updatingValue:O,onSet:r,placeholder:s,allowClear:n=!0,selectOptionRender:d,formLayoutProps:h}=N,x=N.form,[v,F]=q.useState(""),l=q.useMemo(()=>U.getRealName(e),[e]),k=q.useMemo(()=>U.getRealName(e,"upsertFieldName"),[e]),R=y.Form.useWatch(l,x),[H,L]=q.useState(!0);q.useEffect(()=>{r&&H&&R&&(r==null||r(R,o,x),L(!1))},[H,x,o,l,r,R]),q.useEffect(()=>{R&&L(!0)},[R]);const G=q.useCallback(async a=>{F(a),b&&(i==null||i(a,x,O))},[x,i,b,O]),$=q.useCallback(a=>d?d(a):a.value,[d]);return t.jsx(_,{...N,...h,showLoadingInEmptyIndicator:!0,maxTagCount:"responsive",maxTagPlaceholder:a=>t.jsxs(le,{title:t.jsx(t.Fragment,{children:a.map(u=>t.jsxs(t.Fragment,{children:[u.label," ",t.jsx("br",{})]}))}),children:["+",a==null?void 0:a.length]}),placeholder:s,onSelect:a=>{r==null||r(a==null?void 0:a.key,o,x)},onChange:g?a=>{F(""),g(a,x)}:void 0,mode:P?"multiple":void 0,className:["w-100",m].join(" "),name:k,items:o,required:S,tooltip:j,tagRender:C,rules:w,disabled:!p,label:T,allowClear:n,onSearch:G,loading:c,filterOption:f?(a,u)=>{var I,A,B;try{const E=a.toLowerCase().split(/\s+/),z=((typeof(u==null?void 0:u.children)=="string"?u==null?void 0:u.children:(A=(I=u==null?void 0:u.children)==null?void 0:I.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),J=(((B=u==null?void 0:u.value)==null?void 0:B.toString())??"").toLowerCase();return E.every(M=>z.indexOf(M)>=0||J.indexOf(M)>=0)}catch{return!0}}:void 0,itemBuilder:f?a=>{const u=a.value?String(a.value):void 0;return t.jsx(y.Select.Option,{value:a.key,title:u,disabled:a.disabled,children:t.jsx(K,{highlightClassName:"highlight-text",searchWords:(v??"").split(" "),autoEscape:!0,textToHighlight:u??""})},a.key)}:a=>t.jsx(y.Select.Option,{value:a.key,title:a.value,disabled:a.disabled,children:$(a)},a.key)})}function W(N){const{formLayoutProps:o,required:c,fieldClassName:b,rules:i,fieldTooltip:P,updatable:g,label:f,name:S,fieldHelper:m}=N;return t.jsx(y.Form.Item,{...o,label:f,name:S,required:c,rules:i,tooltip:P,help:m,getValueFromEvent:w=>typeof w=="object"?w.toHexString():w,children:t.jsx(y.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:b,disabled:!g,...N.innerProps})})}exports.ColorCrudFieldComponent=W;exports.SelectCrudFieldComponent=D;exports.default=oe;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as o, Fragment as
|
|
2
|
-
import { Form as
|
|
3
|
-
import { useEffect as
|
|
1
|
+
import { jsx as o, Fragment as S, jsxs as W } from "react/jsx-runtime";
|
|
2
|
+
import { Form as I, Radio as _, Select as A, Tag as G, ColorPicker as ee } from "antd";
|
|
3
|
+
import { useEffect as j, useState as $, useMemo as z, useCallback as J } from "react";
|
|
4
4
|
import re from "react-highlight-words";
|
|
5
5
|
import { useTranslationLibNoNS as te } from "../locale/index.es.js";
|
|
6
6
|
import oe from "./FileCrudField.es.js";
|
|
@@ -15,7 +15,7 @@ import ce from "../common/text-field/TextField.es.js";
|
|
|
15
15
|
import me from "../common/tooltip/TooltipComponent.es.js";
|
|
16
16
|
import ue from "./CrudTextAreaComponent.es.js";
|
|
17
17
|
import K from "../util/CrudUtil.es.js";
|
|
18
|
-
function
|
|
18
|
+
function Se(F) {
|
|
19
19
|
const {
|
|
20
20
|
label: n,
|
|
21
21
|
name: m,
|
|
@@ -26,13 +26,13 @@ function Ae(F) {
|
|
|
26
26
|
updatable: f = !0,
|
|
27
27
|
readonly: k = !1,
|
|
28
28
|
fieldClassName: u,
|
|
29
|
-
customFormFieldRender:
|
|
29
|
+
customFormFieldRender: T,
|
|
30
30
|
fieldTooltip: y,
|
|
31
31
|
fieldHelper: g,
|
|
32
|
-
formLayoutProps:
|
|
32
|
+
formLayoutProps: w,
|
|
33
33
|
...e
|
|
34
|
-
} = F, C =
|
|
35
|
-
|
|
34
|
+
} = F, C = I.useFormInstance();
|
|
35
|
+
j(() => {
|
|
36
36
|
if (v === "select") {
|
|
37
37
|
const {
|
|
38
38
|
items: r = [],
|
|
@@ -43,9 +43,9 @@ function Ae(F) {
|
|
|
43
43
|
}
|
|
44
44
|
}, [C, e, v, e == null ? void 0 : e.updatingValue]);
|
|
45
45
|
const { t: O } = te();
|
|
46
|
-
if (k || H) return /* @__PURE__ */ o(
|
|
47
|
-
if (
|
|
48
|
-
return
|
|
46
|
+
if (k || H) return /* @__PURE__ */ o(S, {});
|
|
47
|
+
if (T)
|
|
48
|
+
return T(C, F);
|
|
49
49
|
switch (v) {
|
|
50
50
|
case "text":
|
|
51
51
|
case "email":
|
|
@@ -54,7 +54,7 @@ function Ae(F) {
|
|
|
54
54
|
return /* @__PURE__ */ o(
|
|
55
55
|
ce,
|
|
56
56
|
{
|
|
57
|
-
...
|
|
57
|
+
...w,
|
|
58
58
|
placeholder: i,
|
|
59
59
|
disabled: !f,
|
|
60
60
|
rules: p,
|
|
@@ -78,7 +78,7 @@ function Ae(F) {
|
|
|
78
78
|
se,
|
|
79
79
|
{
|
|
80
80
|
...e,
|
|
81
|
-
...
|
|
81
|
+
...w,
|
|
82
82
|
placeholder: i,
|
|
83
83
|
disabled: !f,
|
|
84
84
|
rules: p,
|
|
@@ -109,7 +109,7 @@ function Ae(F) {
|
|
|
109
109
|
return /* @__PURE__ */ o(
|
|
110
110
|
de,
|
|
111
111
|
{
|
|
112
|
-
...
|
|
112
|
+
...w,
|
|
113
113
|
placeholder: i,
|
|
114
114
|
disabled: !f,
|
|
115
115
|
moneyField: !!e.formatted,
|
|
@@ -143,7 +143,7 @@ function Ae(F) {
|
|
|
143
143
|
return /* @__PURE__ */ o(
|
|
144
144
|
ne,
|
|
145
145
|
{
|
|
146
|
-
...
|
|
146
|
+
...w,
|
|
147
147
|
placeholder: b,
|
|
148
148
|
required: d,
|
|
149
149
|
disabled: !f,
|
|
@@ -176,7 +176,7 @@ function Ae(F) {
|
|
|
176
176
|
return /* @__PURE__ */ o(
|
|
177
177
|
ie,
|
|
178
178
|
{
|
|
179
|
-
...
|
|
179
|
+
...w,
|
|
180
180
|
placeholder: x,
|
|
181
181
|
required: d,
|
|
182
182
|
format: N,
|
|
@@ -259,10 +259,10 @@ function Ae(F) {
|
|
|
259
259
|
tagRender: N
|
|
260
260
|
} = e, x = Array.isArray(r) ? r : Object.keys(r);
|
|
261
261
|
return i ? /* @__PURE__ */ o(
|
|
262
|
-
|
|
262
|
+
I.Item,
|
|
263
263
|
{
|
|
264
264
|
...e,
|
|
265
|
-
...
|
|
265
|
+
...w,
|
|
266
266
|
name: m,
|
|
267
267
|
required: d,
|
|
268
268
|
tooltip: y,
|
|
@@ -286,10 +286,10 @@ function Ae(F) {
|
|
|
286
286
|
Q,
|
|
287
287
|
{
|
|
288
288
|
...e,
|
|
289
|
-
...
|
|
289
|
+
...w,
|
|
290
290
|
tagRender: typeof N == "function" ? N : N ? (a) => {
|
|
291
|
-
const { value: P, label: R } = a,
|
|
292
|
-
return
|
|
291
|
+
const { value: P, label: R } = a, L = N[P];
|
|
292
|
+
return L ? /* @__PURE__ */ o(G, { color: L.color, children: R }) : /* @__PURE__ */ o(G, { children: R });
|
|
293
293
|
} : void 0,
|
|
294
294
|
onChange: s ? (a) => s(a, C) : void 0,
|
|
295
295
|
className: ["w-100", u].join(" "),
|
|
@@ -304,7 +304,8 @@ function Ae(F) {
|
|
|
304
304
|
onSearch: h ? (a) => h(a, C) : void 0,
|
|
305
305
|
allowClear: !0,
|
|
306
306
|
mode: b ? "multiple" : void 0,
|
|
307
|
-
|
|
307
|
+
showLoadingInEmptyIndicator: !0,
|
|
308
|
+
itemBuilder: (a) => /* @__PURE__ */ o(A.Option, { value: a, children: l ? O(l[a]) : a }, a)
|
|
308
309
|
}
|
|
309
310
|
);
|
|
310
311
|
}
|
|
@@ -313,7 +314,7 @@ function Ae(F) {
|
|
|
313
314
|
return /* @__PURE__ */ o(
|
|
314
315
|
le,
|
|
315
316
|
{
|
|
316
|
-
...
|
|
317
|
+
...w,
|
|
317
318
|
className: u,
|
|
318
319
|
rules: p,
|
|
319
320
|
onChange: r ? (l) => r(l, C) : void 0,
|
|
@@ -344,7 +345,7 @@ function Ae(F) {
|
|
|
344
345
|
}
|
|
345
346
|
);
|
|
346
347
|
default:
|
|
347
|
-
return /* @__PURE__ */ o(
|
|
348
|
+
return /* @__PURE__ */ o(S, { children: `${v} Not Implemented` });
|
|
348
349
|
}
|
|
349
350
|
}
|
|
350
351
|
function he(F) {
|
|
@@ -358,10 +359,10 @@ function he(F) {
|
|
|
358
359
|
highlightSearch: f,
|
|
359
360
|
required: k,
|
|
360
361
|
fieldClassName: u,
|
|
361
|
-
rules:
|
|
362
|
+
rules: T,
|
|
362
363
|
fieldTooltip: y,
|
|
363
364
|
updatable: g,
|
|
364
|
-
label:
|
|
365
|
+
label: w,
|
|
365
366
|
name: e,
|
|
366
367
|
tagRender: C,
|
|
367
368
|
updatingValue: O,
|
|
@@ -373,11 +374,11 @@ function he(F) {
|
|
|
373
374
|
} = F, b = F.form, [N, x] = $(""), a = z(() => K.getRealName(e), [e]), P = z(
|
|
374
375
|
() => K.getRealName(e, "upsertFieldName"),
|
|
375
376
|
[e]
|
|
376
|
-
), R =
|
|
377
|
-
|
|
378
|
-
r &&
|
|
379
|
-
}, [
|
|
380
|
-
R &&
|
|
377
|
+
), R = I.useWatch(a, b), [L, B] = $(!0);
|
|
378
|
+
j(() => {
|
|
379
|
+
r && L && R && (r == null || r(R, n, b), B(!1));
|
|
380
|
+
}, [L, b, n, a, r, R]), j(() => {
|
|
381
|
+
R && B(!0);
|
|
381
382
|
}, [R]);
|
|
382
383
|
const V = J(
|
|
383
384
|
async (t) => {
|
|
@@ -393,11 +394,12 @@ function he(F) {
|
|
|
393
394
|
{
|
|
394
395
|
...F,
|
|
395
396
|
...h,
|
|
397
|
+
showLoadingInEmptyIndicator: !0,
|
|
396
398
|
maxTagCount: "responsive",
|
|
397
399
|
maxTagPlaceholder: (t) => /* @__PURE__ */ W(
|
|
398
400
|
me,
|
|
399
401
|
{
|
|
400
|
-
title: /* @__PURE__ */ o(
|
|
402
|
+
title: /* @__PURE__ */ o(S, { children: t.map((c) => /* @__PURE__ */ W(S, { children: [
|
|
401
403
|
c.label,
|
|
402
404
|
" ",
|
|
403
405
|
/* @__PURE__ */ o("br", {})
|
|
@@ -422,17 +424,17 @@ function he(F) {
|
|
|
422
424
|
required: k,
|
|
423
425
|
tooltip: y,
|
|
424
426
|
tagRender: C,
|
|
425
|
-
rules:
|
|
427
|
+
rules: T,
|
|
426
428
|
disabled: !g,
|
|
427
|
-
label:
|
|
429
|
+
label: w,
|
|
428
430
|
allowClear: l,
|
|
429
431
|
onSearch: V,
|
|
430
432
|
loading: m,
|
|
431
433
|
filterOption: f ? (t, c) => {
|
|
432
|
-
var U, q
|
|
434
|
+
var E, U, q;
|
|
433
435
|
try {
|
|
434
|
-
const
|
|
435
|
-
return
|
|
436
|
+
const D = t.toLowerCase().split(/\s+/), Y = ((typeof (c == null ? void 0 : c.children) == "string" ? c == null ? void 0 : c.children : (U = (E = c == null ? void 0 : c.children) == null ? void 0 : E.props) == null ? void 0 : U.textToHighlight) ?? "").toLowerCase(), Z = (((q = c == null ? void 0 : c.value) == null ? void 0 : q.toString()) ?? "").toLowerCase();
|
|
437
|
+
return D.every(
|
|
436
438
|
(M) => Y.indexOf(M) >= 0 || Z.indexOf(M) >= 0
|
|
437
439
|
);
|
|
438
440
|
} catch {
|
|
@@ -442,7 +444,7 @@ function he(F) {
|
|
|
442
444
|
itemBuilder: f ? (t) => {
|
|
443
445
|
const c = t.value ? String(t.value) : void 0;
|
|
444
446
|
return /* @__PURE__ */ o(
|
|
445
|
-
|
|
447
|
+
A.Option,
|
|
446
448
|
{
|
|
447
449
|
value: t.key,
|
|
448
450
|
title: c,
|
|
@@ -460,7 +462,7 @@ function he(F) {
|
|
|
460
462
|
t.key
|
|
461
463
|
);
|
|
462
464
|
} : (t) => /* @__PURE__ */ o(
|
|
463
|
-
|
|
465
|
+
A.Option,
|
|
464
466
|
{
|
|
465
467
|
value: t.key,
|
|
466
468
|
title: t.value,
|
|
@@ -485,7 +487,7 @@ function pe(F) {
|
|
|
485
487
|
fieldHelper: u
|
|
486
488
|
} = F;
|
|
487
489
|
return /* @__PURE__ */ o(
|
|
488
|
-
|
|
490
|
+
I.Item,
|
|
489
491
|
{
|
|
490
492
|
...n,
|
|
491
493
|
label: f,
|
|
@@ -494,7 +496,7 @@ function pe(F) {
|
|
|
494
496
|
rules: d,
|
|
495
497
|
tooltip: H,
|
|
496
498
|
help: u,
|
|
497
|
-
getValueFromEvent: (
|
|
499
|
+
getValueFromEvent: (T) => typeof T == "object" ? T.toHexString() : T,
|
|
498
500
|
children: /* @__PURE__ */ o(
|
|
499
501
|
ee,
|
|
500
502
|
{
|
|
@@ -514,5 +516,5 @@ function pe(F) {
|
|
|
514
516
|
export {
|
|
515
517
|
pe as ColorCrudFieldComponent,
|
|
516
518
|
he as SelectCrudFieldComponent,
|
|
517
|
-
|
|
519
|
+
Se as default
|
|
518
520
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),ht=require("antd"),yt=require("@dnd-kit/core"),qt=require("@dnd-kit/modifiers"),Ct=require("@dnd-kit/utilities"),
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),ht=require("antd"),yt=require("@dnd-kit/core"),qt=require("@dnd-kit/modifiers"),Ct=require("@dnd-kit/utilities"),M=require("@dnd-kit/sortable"),lt=require("../../common/button/Button.cjs.js"),St=require("../../common/button/RefreshButton.cjs.js"),dt=require("../../common/button/ViewButtonTable.cjs.js"),It=require("../actions/index.cjs.js"),Rt=require("../../common/table/table.cjs.js"),s=require("react"),Mt=require("../../locale/index.cjs.js"),Tt=require("../CrudSearchComponent.cjs.js"),Vt=require("./CrudDecListView.cjs.js"),nt=require("./CrudViewerUtil.cjs.js"),Bt=require("@ant-design/icons"),ot=require("../../util/CrudUtil.cjs.js"),Dt=require("../../common/layout/VerticalSpace.cjs.js"),Ot=s.memo(Rt);function Nt({summary:j,idField:o="id",loadingData:q,fields:h,isDeleting:I,isHiding:T,viewable:c=!1,paginateProps:f,onDelete:l,onHide:V,onUpdate:B,data:S=[],extraAction:D,onClickUpdate:O,minusHeight:k,scroll:v,onClickClone:z,className:$,expandable:A,size:_,bordered:G,descListColumn:rt,extraView:E,decListLayout:ct,scrollToTop:Lt,onClickRefresh:J,closeViewOnClickUpdate:K,onExport:Q,confirmHiding:X,confirmDeleting:Y,rowClassName:Z,actionWidth:W=190,draggable:t,rowSelection:P,...ut}){const{t:H}=Mt.useTranslationLib(),U=s.useMemo(()=>h.map(({hideInTable:e,hidden:r,width:u,label:m,halign:d,...C})=>{const N=ot.getRealName(C.name);return{title:m,width:u,key:N,dataIndex:N,hidden:e||r,align:d??(C.type==="number"?"right":void 0),render:nt.getRendererValueCrudViewer(C),sorter:C.sorter,defaultSortOrder:C.defaultSortOrder}}),[h]),[i,R]=s.useState(),[p,w]=s.useState(),[y,a]=s.useState([]),it=s.useCallback(e=>{R(e)},[]);s.useEffect(()=>{S&&a(S)},[S]),s.useEffect(()=>{S&&R(e=>{if(e)return S.find(r=>r[o]===e[o])})},[S,o,i]);const F=s.useCallback(e=>{var m;const{active:r,over:u}=e;if(t!=null&&t.onDragEnd&&(t==null||t.onDragEnd(e)),r.id!==(u==null?void 0:u.id)){const d=y.findIndex(x=>x[o]===r.id),C=y.findIndex(x=>x[o]===(u==null?void 0:u.id)),N=M.arrayMove(y,d,C);a(x=>{const xt=x.findIndex(L=>L[o]===(r==null?void 0:r.id)),jt=x.findIndex(L=>L[o]===(u==null?void 0:u.id));return M.arrayMove(x,xt,jt)}),(m=t==null?void 0:t.onDrag)==null||m.call(t,{newOrder:N.map(x=>x[o])})}},[y,o,t]),ft=s.useMemo(()=>{let e=typeof c=="string"?i==null?void 0:i[c]:void 0;if(typeof e=="object"){const r=h.find(u=>ot.getRealName(u.name)===c);e=nt.getRendererValueCrudViewer(r)(e,i,0)}return e},[c,i,h]),b=s.useMemo(()=>({rowSelection:P,rowClassName:Z,className:$,scroll:v??(k?{y:`calc(100vh - ${k})`}:void 0),id:"crud-table",bordered:G,size:_,expandable:A}),[P,Z,$,v,k,G,_,A]),g=s.useMemo(()=>f?{...f,total:f.count,onChange:f.setPage,current:f.page,pageSize:f.pageSize}:void 0,[f]),tt=s.useMemo(()=>{const e=B||O||l||D||c,r=[];return t&&r.push({key:"key",align:"center",width:5,title:t==null?void 0:t.columnLabel,render:()=>n.jsx(kt,{tooltip:t==null?void 0:t.tooltip})}),r.push(...U),e&&e&&r.push({title:H("str.action"),fixed:"right",width:W,render:(u,m)=>n.jsxs(n.Fragment,{children:[c&&n.jsx(dt,{value:m,onClick:typeof c=="object"?()=>{var d;return(d=c.onClick)==null?void 0:d.call(c,m)}:it}),n.jsx(It,{data:m,idField:o,extraAction:D,onUpdate:B,onClickUpdate:O,onClickClone:z,onDelete:l,onHide:V,onExport:Q,isHiding:T,isDeleting:I,confirmHiding:X,confirmDeleting:Y,closeViewOnClickUpdate:K,recentUpdateOrDeleteId:p,setRecentUpdateOrDeleteId:w,setOpenView:R})]})}),r},[U,B,O,l,D,c,H,W]),et=s.useMemo(()=>y.map(e=>e[o]),[y,o]),mt=s.useCallback(()=>{const e=n.jsx(Ot,{...b,summary:j,dataSource:y,loading:q,components:t?{body:{row:Et}}:void 0,pagination:g,columns:tt});return t?n.jsx(yt.DndContext,{modifiers:[qt.restrictToVerticalAxis],onDragEnd:F,children:n.jsx(M.SortableContext,{items:et,strategy:M.verticalListSortingStrategy,children:e})}):e},[b,y,q,g,tt,j,t,et,F]);return n.jsxs("div",{children:[(typeof c=="boolean"||typeof c=="string")&&n.jsx(ht.Modal,{width:"100%",open:!!i,title:ft??n.jsx("div",{children:" "}),footer:n.jsx(n.Fragment,{}),closable:!0,onCancel:()=>R(void 0),children:!!i&&n.jsxs("div",{children:[n.jsx(Vt.CrudDecListView,{layout:ct,descListColumn:rt,data:i,fields:h,idField:o,extraAction:D,onUpdate:B,onClickUpdate:O,onClickClone:z,onDelete:l,onHide:V,onExport:Q,isHiding:T,isDeleting:I,confirmHiding:X,confirmDeleting:Y,closeViewOnClickUpdate:K,recentUpdateOrDeleteId:p,setRecentUpdateOrDeleteId:w,setOpenView:R}),E==null?void 0:E(i)]},i==null?void 0:i[o])}),n.jsx(Tt,{fields:h,...ut}),n.jsxs(Dt,{children:[!!J&&n.jsx(St.RefreshButton,{onClick:J}),mt()]})]})}const st=s.createContext({}),kt=({tooltip:j})=>{const{setActivatorNodeRef:o,listeners:q}=s.useContext(st);return n.jsx(lt,{type:"text",size:"small",tooltip:j,icon:n.jsx(Bt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:o,...q})},Et=j=>{const{attributes:o,listeners:q,setNodeRef:h,setActivatorNodeRef:I,transform:T,transition:c,isDragging:f}=M.useSortable({id:j["data-row-key"]}),l={...j.style,transform:Ct.CSS.Translate.toString(T),transition:c,...f?{position:"relative",zIndex:9999}:{}},V=s.useMemo(()=>({setActivatorNodeRef:I,listeners:q}),[I,q]);return n.jsx(st.Provider,{value:V,children:n.jsx("tr",{...j,ref:h,style:l,...o})})};module.exports=Nt;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as e, jsxs as L, Fragment as et } from "react/jsx-runtime";
|
|
2
|
-
import { Modal as
|
|
3
|
-
import { DndContext as
|
|
4
|
-
import { restrictToVerticalAxis as
|
|
5
|
-
import { CSS as
|
|
6
|
-
import { arrayMove as ct, SortableContext as
|
|
2
|
+
import { Modal as lt } from "antd";
|
|
3
|
+
import { DndContext as Rt } from "@dnd-kit/core";
|
|
4
|
+
import { restrictToVerticalAxis as dt } from "@dnd-kit/modifiers";
|
|
5
|
+
import { CSS as Ot } from "@dnd-kit/utilities";
|
|
6
|
+
import { arrayMove as ct, SortableContext as Bt, verticalListSortingStrategy as Dt, useSortable as Nt } from "@dnd-kit/sortable";
|
|
7
7
|
import jt from "../../common/button/Button.es.js";
|
|
8
8
|
import { RefreshButton as Et } from "../../common/button/RefreshButton.es.js";
|
|
9
9
|
import Lt from "../../common/button/ViewButtonTable.es.js";
|
|
@@ -22,16 +22,16 @@ function so({
|
|
|
22
22
|
summary: h,
|
|
23
23
|
idField: n = "id",
|
|
24
24
|
loadingData: C,
|
|
25
|
-
fields:
|
|
26
|
-
isDeleting:
|
|
27
|
-
isHiding:
|
|
25
|
+
fields: y,
|
|
26
|
+
isDeleting: R,
|
|
27
|
+
isHiding: O,
|
|
28
28
|
viewable: c = !1,
|
|
29
29
|
paginateProps: u,
|
|
30
30
|
onDelete: I,
|
|
31
|
-
onHide:
|
|
32
|
-
onUpdate:
|
|
33
|
-
data:
|
|
34
|
-
extraAction:
|
|
31
|
+
onHide: B,
|
|
32
|
+
onUpdate: D,
|
|
33
|
+
data: T = [],
|
|
34
|
+
extraAction: N,
|
|
35
35
|
onClickUpdate: j,
|
|
36
36
|
minusHeight: M,
|
|
37
37
|
scroll: A,
|
|
@@ -42,7 +42,7 @@ function so({
|
|
|
42
42
|
bordered: J,
|
|
43
43
|
descListColumn: ht,
|
|
44
44
|
extraView: V,
|
|
45
|
-
decListLayout:
|
|
45
|
+
decListLayout: yt,
|
|
46
46
|
scrollToTop: Kt,
|
|
47
47
|
onClickRefresh: K,
|
|
48
48
|
closeViewOnClickUpdate: Q,
|
|
@@ -53,61 +53,62 @@ function so({
|
|
|
53
53
|
actionWidth: P = 190,
|
|
54
54
|
draggable: t,
|
|
55
55
|
rowSelection: H,
|
|
56
|
-
...
|
|
56
|
+
...pt
|
|
57
57
|
}) {
|
|
58
58
|
const { t: U } = zt(), w = x(
|
|
59
|
-
() =>
|
|
60
|
-
const E = ut.getRealName(
|
|
59
|
+
() => y.map(({ hideInTable: o, hidden: r, width: s, label: f, halign: l, ...S }) => {
|
|
60
|
+
const E = ut.getRealName(S.name);
|
|
61
61
|
return {
|
|
62
62
|
title: f,
|
|
63
63
|
width: s,
|
|
64
64
|
key: E,
|
|
65
65
|
dataIndex: E,
|
|
66
66
|
hidden: o || r,
|
|
67
|
-
align:
|
|
68
|
-
render: mt(
|
|
69
|
-
sorter:
|
|
67
|
+
align: l ?? (S.type === "number" ? "right" : void 0),
|
|
68
|
+
render: mt(S),
|
|
69
|
+
sorter: S.sorter,
|
|
70
|
+
defaultSortOrder: S.defaultSortOrder
|
|
70
71
|
};
|
|
71
72
|
}),
|
|
72
|
-
[
|
|
73
|
-
), [m,
|
|
74
|
-
|
|
73
|
+
[y]
|
|
74
|
+
), [m, d] = z(), [F, a] = z(), [p, b] = z([]), Ct = v((o) => {
|
|
75
|
+
d(o);
|
|
75
76
|
}, []);
|
|
76
77
|
st(() => {
|
|
77
|
-
|
|
78
|
-
}, [
|
|
79
|
-
|
|
78
|
+
T && b(T);
|
|
79
|
+
}, [T]), st(() => {
|
|
80
|
+
T && d((o) => {
|
|
80
81
|
if (o)
|
|
81
|
-
return
|
|
82
|
+
return T.find((r) => r[n] === o[n]);
|
|
82
83
|
});
|
|
83
|
-
}, [
|
|
84
|
+
}, [T, n, m]);
|
|
84
85
|
const g = v(
|
|
85
86
|
(o) => {
|
|
86
87
|
var f;
|
|
87
88
|
const { active: r, over: s } = o;
|
|
88
89
|
if (t != null && t.onDragEnd && (t == null || t.onDragEnd(o)), r.id !== (s == null ? void 0 : s.id)) {
|
|
89
|
-
const
|
|
90
|
+
const l = p.findIndex(
|
|
90
91
|
(i) => i[n] === r.id
|
|
91
|
-
),
|
|
92
|
+
), S = p.findIndex(
|
|
92
93
|
(i) => i[n] === (s == null ? void 0 : s.id)
|
|
93
|
-
), E = ct(
|
|
94
|
+
), E = ct(p, l, S);
|
|
94
95
|
b((i) => {
|
|
95
|
-
const
|
|
96
|
+
const It = i.findIndex(
|
|
96
97
|
(k) => k[n] === (r == null ? void 0 : r.id)
|
|
97
98
|
), Tt = i.findIndex(
|
|
98
99
|
(k) => k[n] === (s == null ? void 0 : s.id)
|
|
99
100
|
);
|
|
100
|
-
return ct(i,
|
|
101
|
+
return ct(i, It, Tt);
|
|
101
102
|
}), (f = t == null ? void 0 : t.onDrag) == null || f.call(t, {
|
|
102
103
|
newOrder: E.map((i) => i[n])
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
},
|
|
106
|
-
[
|
|
107
|
-
),
|
|
107
|
+
[p, n, t]
|
|
108
|
+
), St = x(() => {
|
|
108
109
|
let o = typeof c == "string" ? m == null ? void 0 : m[c] : void 0;
|
|
109
110
|
if (typeof o == "object") {
|
|
110
|
-
const r =
|
|
111
|
+
const r = y.find((s) => ut.getRealName(s.name) === c);
|
|
111
112
|
o = mt(r)(
|
|
112
113
|
o,
|
|
113
114
|
m,
|
|
@@ -115,7 +116,7 @@ function so({
|
|
|
115
116
|
);
|
|
116
117
|
}
|
|
117
118
|
return o;
|
|
118
|
-
}, [c, m,
|
|
119
|
+
}, [c, m, y]), tt = x(
|
|
119
120
|
() => ({
|
|
120
121
|
rowSelection: H,
|
|
121
122
|
rowClassName: W,
|
|
@@ -146,7 +147,7 @@ function so({
|
|
|
146
147
|
} : void 0,
|
|
147
148
|
[u]
|
|
148
149
|
), nt = x(() => {
|
|
149
|
-
const o =
|
|
150
|
+
const o = D || j || I || N || c, r = [];
|
|
150
151
|
return t && r.push({
|
|
151
152
|
key: "key",
|
|
152
153
|
align: "center",
|
|
@@ -163,8 +164,8 @@ function so({
|
|
|
163
164
|
{
|
|
164
165
|
value: f,
|
|
165
166
|
onClick: typeof c == "object" ? () => {
|
|
166
|
-
var
|
|
167
|
-
return (
|
|
167
|
+
var l;
|
|
168
|
+
return (l = c.onClick) == null ? void 0 : l.call(c, f);
|
|
168
169
|
} : Ct
|
|
169
170
|
}
|
|
170
171
|
),
|
|
@@ -173,61 +174,61 @@ function so({
|
|
|
173
174
|
{
|
|
174
175
|
data: f,
|
|
175
176
|
idField: n,
|
|
176
|
-
extraAction:
|
|
177
|
-
onUpdate:
|
|
177
|
+
extraAction: N,
|
|
178
|
+
onUpdate: D,
|
|
178
179
|
onClickUpdate: j,
|
|
179
180
|
onClickClone: _,
|
|
180
181
|
onDelete: I,
|
|
181
|
-
onHide:
|
|
182
|
+
onHide: B,
|
|
182
183
|
onExport: X,
|
|
183
|
-
isHiding:
|
|
184
|
-
isDeleting:
|
|
184
|
+
isHiding: O,
|
|
185
|
+
isDeleting: R,
|
|
185
186
|
confirmHiding: Y,
|
|
186
187
|
confirmDeleting: Z,
|
|
187
188
|
closeViewOnClickUpdate: Q,
|
|
188
189
|
recentUpdateOrDeleteId: F,
|
|
189
190
|
setRecentUpdateOrDeleteId: a,
|
|
190
|
-
setOpenView:
|
|
191
|
+
setOpenView: d
|
|
191
192
|
}
|
|
192
193
|
)
|
|
193
194
|
] })
|
|
194
195
|
}), r;
|
|
195
196
|
}, [
|
|
196
197
|
w,
|
|
197
|
-
|
|
198
|
+
D,
|
|
198
199
|
j,
|
|
199
200
|
I,
|
|
200
|
-
|
|
201
|
+
N,
|
|
201
202
|
c,
|
|
202
203
|
U,
|
|
203
204
|
P
|
|
204
205
|
]), rt = x(
|
|
205
|
-
() =>
|
|
206
|
-
[
|
|
207
|
-
),
|
|
206
|
+
() => p.map((o) => o[n]),
|
|
207
|
+
[p, n]
|
|
208
|
+
), xt = v(() => {
|
|
208
209
|
const o = /* @__PURE__ */ e(
|
|
209
210
|
qt,
|
|
210
211
|
{
|
|
211
212
|
...tt,
|
|
212
213
|
summary: h,
|
|
213
|
-
dataSource:
|
|
214
|
+
dataSource: p,
|
|
214
215
|
loading: C,
|
|
215
216
|
components: t ? { body: { row: Jt } } : void 0,
|
|
216
217
|
pagination: ot,
|
|
217
218
|
columns: nt
|
|
218
219
|
}
|
|
219
220
|
);
|
|
220
|
-
return t ? /* @__PURE__ */ e(
|
|
221
|
-
|
|
221
|
+
return t ? /* @__PURE__ */ e(Rt, { modifiers: [dt], onDragEnd: g, children: /* @__PURE__ */ e(
|
|
222
|
+
Bt,
|
|
222
223
|
{
|
|
223
224
|
items: rt,
|
|
224
|
-
strategy:
|
|
225
|
+
strategy: Dt,
|
|
225
226
|
children: o
|
|
226
227
|
}
|
|
227
228
|
) }) : o;
|
|
228
229
|
}, [
|
|
229
230
|
tt,
|
|
230
|
-
|
|
231
|
+
p,
|
|
231
232
|
C,
|
|
232
233
|
ot,
|
|
233
234
|
nt,
|
|
@@ -238,48 +239,48 @@ function so({
|
|
|
238
239
|
]);
|
|
239
240
|
return /* @__PURE__ */ L("div", { children: [
|
|
240
241
|
(typeof c == "boolean" || typeof c == "string") && /* @__PURE__ */ e(
|
|
241
|
-
|
|
242
|
+
lt,
|
|
242
243
|
{
|
|
243
244
|
width: "100%",
|
|
244
245
|
open: !!m,
|
|
245
|
-
title:
|
|
246
|
+
title: St ?? /* @__PURE__ */ e("div", { children: " " }),
|
|
246
247
|
footer: /* @__PURE__ */ e(et, {}),
|
|
247
248
|
closable: !0,
|
|
248
|
-
onCancel: () =>
|
|
249
|
+
onCancel: () => d(void 0),
|
|
249
250
|
children: !!m && /* @__PURE__ */ L("div", { children: [
|
|
250
251
|
/* @__PURE__ */ e(
|
|
251
252
|
At,
|
|
252
253
|
{
|
|
253
|
-
layout:
|
|
254
|
+
layout: yt,
|
|
254
255
|
descListColumn: ht,
|
|
255
256
|
data: m,
|
|
256
|
-
fields:
|
|
257
|
+
fields: y,
|
|
257
258
|
idField: n,
|
|
258
|
-
extraAction:
|
|
259
|
-
onUpdate:
|
|
259
|
+
extraAction: N,
|
|
260
|
+
onUpdate: D,
|
|
260
261
|
onClickUpdate: j,
|
|
261
262
|
onClickClone: _,
|
|
262
263
|
onDelete: I,
|
|
263
|
-
onHide:
|
|
264
|
+
onHide: B,
|
|
264
265
|
onExport: X,
|
|
265
|
-
isHiding:
|
|
266
|
-
isDeleting:
|
|
266
|
+
isHiding: O,
|
|
267
|
+
isDeleting: R,
|
|
267
268
|
confirmHiding: Y,
|
|
268
269
|
confirmDeleting: Z,
|
|
269
270
|
closeViewOnClickUpdate: Q,
|
|
270
271
|
recentUpdateOrDeleteId: F,
|
|
271
272
|
setRecentUpdateOrDeleteId: a,
|
|
272
|
-
setOpenView:
|
|
273
|
+
setOpenView: d
|
|
273
274
|
}
|
|
274
275
|
),
|
|
275
276
|
V == null ? void 0 : V(m)
|
|
276
277
|
] }, m == null ? void 0 : m[n])
|
|
277
278
|
}
|
|
278
279
|
),
|
|
279
|
-
/* @__PURE__ */ e(vt, { fields:
|
|
280
|
+
/* @__PURE__ */ e(vt, { fields: y, ...pt }),
|
|
280
281
|
/* @__PURE__ */ L($t, { children: [
|
|
281
282
|
!!K && /* @__PURE__ */ e(Et, { onClick: K }),
|
|
282
|
-
|
|
283
|
+
xt()
|
|
283
284
|
] })
|
|
284
285
|
] });
|
|
285
286
|
}
|
|
@@ -301,21 +302,21 @@ const it = ft.createContext({}), Gt = ({ tooltip: h }) => {
|
|
|
301
302
|
const {
|
|
302
303
|
attributes: n,
|
|
303
304
|
listeners: C,
|
|
304
|
-
setNodeRef:
|
|
305
|
-
setActivatorNodeRef:
|
|
306
|
-
transform:
|
|
305
|
+
setNodeRef: y,
|
|
306
|
+
setActivatorNodeRef: R,
|
|
307
|
+
transform: O,
|
|
307
308
|
transition: c,
|
|
308
309
|
isDragging: u
|
|
309
|
-
} =
|
|
310
|
+
} = Nt({ id: h["data-row-key"] }), I = {
|
|
310
311
|
...h.style,
|
|
311
|
-
transform:
|
|
312
|
+
transform: Ot.Translate.toString(O),
|
|
312
313
|
transition: c,
|
|
313
314
|
...u ? { position: "relative", zIndex: 9999 } : {}
|
|
314
|
-
},
|
|
315
|
-
() => ({ setActivatorNodeRef:
|
|
316
|
-
[
|
|
315
|
+
}, B = x(
|
|
316
|
+
() => ({ setActivatorNodeRef: R, listeners: C }),
|
|
317
|
+
[R, C]
|
|
317
318
|
);
|
|
318
|
-
return /* @__PURE__ */ e(it.Provider, { value:
|
|
319
|
+
return /* @__PURE__ */ e(it.Provider, { value: B, children: /* @__PURE__ */ e("tr", { ...h, ref: y, style: I, ...n }) });
|
|
319
320
|
};
|
|
320
321
|
export {
|
|
321
322
|
so as default
|