@kingteza/crud-component 1.26.0 → 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.
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +44 -42
- package/package.json +1 -1
|
@@ -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
|
};
|