@kingteza/crud-component 1.29.0 → 1.29.1

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,10 +1,11 @@
1
1
  import { Rule } from 'antd/es/form';
2
+ import { NamePath } from 'antd/es/form/interface';
2
3
  import { FormItemProps } from 'antd/lib';
3
4
  import { FC, ReactNode } from 'react';
4
5
  export interface RichTextEditorProps {
5
6
  help?: ReactNode;
6
7
  label?: string;
7
- name: string;
8
+ name: NamePath;
8
9
  required?: boolean;
9
10
  rules?: Rule[];
10
11
  disabled?: boolean;
@@ -1 +1 @@
1
- "use strict";const i=require("react/jsx-runtime"),m=require("antd"),x=require("react"),P=require("../../locale/index.cjs.js"),b=require("../tooltip/TooltipComponent.cjs.js"),k=require("./TextField.cjs.js"),v=x.forwardRef(function({type:z,required:o,label:e,rules:c=[],placeholder:r,onEnter:a,form:f,nextFocus:q,min:d,moneyField:n,addonAfter:j,minLength:T,defaultValue:$,pattern:g,disabled:I,readOnly:N,onChange:R,value:w,max:B,addonBefore:E,size:F,isInt:u=!1,tooltip:h,help:A,...C},L){const{t:p}=P.useTranslationLib(),M=x.useMemo(()=>[...c,{required:o,message:`${e||r||""} ${p("err.validation.required")}`}],[c,e,r,p,o]);return i.jsx(b,{title:h,children:i.jsx(m.Form.Item,{...C,label:e,rules:M,children:i.jsx(m.InputNumber,{ref:L,disabled:I,defaultValue:$,value:w,readOnly:N,addonBefore:E,minLength:T,addonAfter:j,step:u?1:void 0,pattern:u?"d*":g,onChange:R,onPressEnter:t=>k.onEnterInternalTextField(t,q,f,a),className:"max-width",min:d===null?void 0:d??0,max:B,type:n?void 0:"number",size:F,formatter:n?t=>{if(t.includes(".")){const s=`${t}`.split(".");return s[0]=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),s.join(".")}else return`${t}`.replace(/\B(?=(\d{3})+(?!\d))/g,",")}:void 0,parser:n?t=>t==null?void 0:t.replace(/\$\s?|(,*)/g,""):void 0,placeholder:r||e})})})});module.exports=v;
1
+ "use strict";const i=require("react/jsx-runtime"),m=require("antd"),x=require("react"),M=require("../../locale/index.cjs.js"),P=require("../tooltip/TooltipComponent.cjs.js"),_=require("./TextField.cjs.js"),b=x.forwardRef(function({type:v,required:o,label:e,rules:c=[],placeholder:r,onEnter:a,form:f,nextFocus:q,min:d,moneyField:n,addonAfter:j,minLength:T,defaultValue:$,pattern:g,disabled:I,readOnly:N,onChange:R,value:w,max:B,addonBefore:E,size:F,isInt:u=!1,tooltip:h,help:z,...y},C){const{t:p}=M.useTranslationLib(),L=x.useMemo(()=>[...c,{required:o,message:`${e||r||""} ${p("err.validation.required")}`}],[c,e,r,p,o]);return i.jsx(P,{title:h,children:i.jsx(m.Form.Item,{...y,label:e,rules:L,children:i.jsx(m.InputNumber,{ref:C,disabled:I,defaultValue:$,value:w,readOnly:N,addonBefore:E,minLength:T,addonAfter:j,step:u?1:void 0,pattern:u?"d*":g,onChange:R,onPressEnter:t=>_.onEnterInternalTextField(t,q,f,a),className:"max-width",min:d===null?void 0:d??0,max:B,type:n?void 0:"number",size:F,formatter:n?t=>{if(t.includes(".")){const s=`${t}`.split(".");return s[0]=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),s.join(".")}else return`${t}`.replace(/\B(?=(\d{3})+(?!\d))/g,",")}:void 0,parser:n?t=>t==null?void 0:t.replace(/\$\s?|(,*)/g,""):void 0,placeholder:r||e})})})});module.exports=b;
@@ -1,13 +1,12 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
- import { Form as P, InputNumber as R } from "antd";
3
- import { forwardRef as b, useMemo as k } from "react";
4
- import { useTranslationLib as q } from "../../locale/index.es.js";
5
- import v from "../tooltip/TooltipComponent.es.js";
6
- import { onEnterInternalTextField as y } from "./TextField.es.js";
7
- const S = b(
2
+ import { Form as M, InputNumber as P } from "antd";
3
+ import { forwardRef as R, useMemo as _ } from "react";
4
+ import { useTranslationLib as b } from "../../locale/index.es.js";
5
+ import k from "../tooltip/TooltipComponent.es.js";
6
+ import { onEnterInternalTextField as q } from "./TextField.es.js";
7
+ const Q = R(
8
8
  function({
9
- // eslint-disable-next-line no-unused-vars
10
- type: A,
9
+ type: z,
11
10
  required: s,
12
11
  label: t,
13
12
  rules: m = [],
@@ -29,11 +28,11 @@ const S = b(
29
28
  addonBefore: E,
30
29
  size: h,
31
30
  isInt: d = !1,
32
- tooltip: C,
33
- help: D,
34
- ...F
35
- }, L) {
36
- const { t: f } = q(), M = k(
31
+ tooltip: y,
32
+ help: A,
33
+ ...C
34
+ }, F) {
35
+ const { t: f } = b(), L = _(
37
36
  () => [
38
37
  ...m,
39
38
  {
@@ -45,10 +44,10 @@ const S = b(
45
44
  ],
46
45
  [m, t, o, f, s]
47
46
  );
48
- return /* @__PURE__ */ i(v, { title: C, children: /* @__PURE__ */ i(P.Item, { ...F, label: t, rules: M, children: /* @__PURE__ */ i(
49
- R,
47
+ return /* @__PURE__ */ i(k, { title: y, children: /* @__PURE__ */ i(M.Item, { ...C, label: t, rules: L, children: /* @__PURE__ */ i(
48
+ P,
50
49
  {
51
- ref: L,
50
+ ref: F,
52
51
  disabled: I,
53
52
  defaultValue: g,
54
53
  value: w,
@@ -59,7 +58,7 @@ const S = b(
59
58
  step: d ? 1 : void 0,
60
59
  pattern: d ? "d*" : T,
61
60
  onChange: j,
62
- onPressEnter: (r) => y(r, a, u, c),
61
+ onPressEnter: (r) => q(r, a, u, c),
63
62
  className: "max-width",
64
63
  min: p === null ? void 0 : p ?? 0,
65
64
  max: B,
@@ -79,5 +78,5 @@ const S = b(
79
78
  }
80
79
  );
81
80
  export {
82
- S as default
81
+ Q as default
83
82
  };
@@ -10,11 +10,11 @@ import { CrudImportProps } from './import/CrudImportComponent';
10
10
  import { CrudDragableProps, CrudViewableProps } from './view/CrudViewer';
11
11
  import { SelectTagRenderProps } from '../common/select/SelectComponent';
12
12
  import { default as IdProps } from '../types/Id';
13
- import { TextAreaBasedFieldProps } from '.';
13
+ import { TextAreaBasedFieldProps } from './CrudTextAreaComponent';
14
14
  import { SizeType } from 'antd/es/config-provider/SizeContext';
15
- import { Copyable } from 'src/util/CopyUtilComponent';
15
+ import { Copyable } from '../util/CopyUtilComponent';
16
16
  import { ColumnType } from 'antd/es/table';
17
- import { PhoneNumberConfigProps } from 'src/common/text-field/PhoneNumberField';
17
+ import { PhoneNumberConfigProps } from '../common/text-field/PhoneNumberField';
18
18
  export type SelectFieldItem = {
19
19
  key?: string | number;
20
20
  value: string | number;
@@ -236,6 +236,8 @@ export type CrudFieldProps<T> = {
236
236
  readonly type: K;
237
237
  };
238
238
  }[keyof CrudFieldTypeMap<T>];
239
+ /** Field lists passed into CRUD components; accepts mutable arrays and `as const` tuples. */
240
+ export type ReadonlyCrudFields<T> = readonly CrudFieldProps<T>[];
239
241
  export type CrudPaginateProps = false | ({
240
242
  page?: number;
241
243
  setPage?: (page: number, pageSize?: number) => void;
@@ -250,7 +252,7 @@ export type CrudWizardProp<T> = {
250
252
  grid?: boolean;
251
253
  };
252
254
  export type CrudComponentProps<T, FormType = T> = {
253
- fields: CrudFieldProps<T>[];
255
+ fields: ReadonlyCrudFields<T>;
254
256
  data: T[] | undefined;
255
257
  idField?: string;
256
258
  grid?: boolean;
@@ -1,11 +1,11 @@
1
1
  import { FormInstance, FormProps } from 'antd';
2
- import { CrudFieldProps, CrudPurpose, FormBuilderFunc } from './CrudComponent';
2
+ import { CrudPurpose, FormBuilderFunc, ReadonlyCrudFields } from './CrudComponent';
3
3
  export interface CurdFormFieldsProps<T> {
4
4
  onDeleteFile?: (e: any) => void;
5
5
  onUploadFile?: (e: any) => void;
6
6
  grid?: boolean;
7
7
  formBuilder?: FormBuilderFunc<T>;
8
- fields: CrudFieldProps<T>[];
8
+ fields: ReadonlyCrudFields<T>;
9
9
  purpose?: CrudPurpose;
10
10
  onValuesChange?: FormProps<T>["onValuesChange"];
11
11
  }
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),F=require("@ant-design/icons"),c=require("antd"),b=require("react"),R=require("../locale/index.cjs.js"),S=require("./CrudForm.cjs.js"),v=require("../common/wizard/WizardViewForm.cjs.js"),q=require("../util/CrudUtil.cjs.js"),y=require("../common/button/Button.cjs.js");function N({fields:d,className:h,onDeleteFile:f,onUploadFile:s,purpose:l,wizard:t=[],updatingValue:x,onSave:g,submitting:j,onValuesChange:u}){const m=b.useMemo(()=>t.map(r=>{let n=!0;const o=d.filter(i=>r.fields.includes(q.getRealName(i.name)));return o.forEach(i=>n&&(n=i.hidden??!1)),{...r,hidden:n,fieldThatShouldShowing:o}}),[d,t]),a=b.useMemo(()=>m.filter(r=>!r.hidden),[m]);return e.jsx(v,{onSubmit:(r,n)=>{g(n)},className:h,pages:a.map(({title:r,icon:n,fieldThatShouldShowing:o,hidden:i},k)=>({title:r,icon:n,hidden:i,component:C=>e.jsx(w,{fields:o,onDeleteFile:f,onUploadFile:s,purpose:l,i:k,updatingValue:x,backward:C.backward,forward:C.forward,wizard:a,submitting:j,onValuesChange:u},k)}))})}function w({fields:d,onDeleteFile:h,onUploadFile:f,purpose:s,wizard:l=[],i:t,forward:x,backward:g,submitting:j,updatingValue:u,onValuesChange:m}){const a=l[t],{t:r}=R.useTranslationLib(),[n]=c.Form.useForm();return b.useEffect(()=>{if(u&&(s==="update"||s==="clone")){const o={};for(const i of d)o[q.getRealName(i.name,"upsertFieldName")]=u[q.getRealName(i.name,"upsertFieldName")];n.setFieldsValue(o)}},[d,n,s,u]),e.jsxs(c.Form,{name:String(t),form:n,layout:"vertical",onValuesChange:m,children:[e.jsx(S.CrudFormFields,{fields:d,formBuilder:a.formBuilder,grid:a.grid,onDeleteFile:h,onUploadFile:f,purpose:s}),e.jsx(c.Divider,{}),e.jsxs(c.Row,{gutter:[8,8],children:[t>0&&e.jsx(c.Col,{md:12,children:e.jsx(y,{block:!0,icon:e.jsx(F.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>g(),children:r("str.back")})}),e.jsx(c.Col,{md:t>0?12:24,children:e.jsx(y,{block:!0,icon:l.length-1===t?e.jsx(F.SaveOutlined,{}):e.jsx(F.RightOutlined,{}),htmlType:"submit",type:"primary",loading:j,size:"large",onClick:()=>{n.validateFields().then(o=>{x(o,l.length-1===t,l.length-1===t)})},children:l.length-1===t?r("str."+(s==="update"?"update":"save")):r("str.next")})})]})]})}module.exports=N;
1
+ "use strict";const e=require("react/jsx-runtime"),y=require("@ant-design/icons"),a=require("antd"),q=require("react"),R=require("../locale/index.cjs.js"),S=require("./CrudForm.cjs.js"),B=require("../common/wizard/WizardViewForm.cjs.js"),v=require("../util/CrudUtil.cjs.js"),k=require("../util/ObjectUtil.cjs.js"),C=require("../common/button/Button.cjs.js");function w({fields:u,className:x,onDeleteFile:j,onUploadFile:i,purpose:l,wizard:t=[],updatingValue:g,onSave:b,submitting:F,onValuesChange:d}){const h=q.useMemo(()=>t.map(r=>{let n=!0;const o=u.filter(c=>{const s=v.getRealName(c.name);return!Array.isArray(s)&&r.fields.includes(s)});return o.forEach(c=>n&&(n=c.hidden??!1)),{...r,hidden:n,fieldThatShouldShowing:o}}),[u,t]),m=q.useMemo(()=>h.filter(r=>!r.hidden),[h]);return e.jsx(B,{onSubmit:(r,n)=>{b(n)},className:x,pages:m.map(({title:r,icon:n,fieldThatShouldShowing:o,hidden:c},s)=>({title:r,icon:n,hidden:c,component:f=>e.jsx(O,{fields:o,onDeleteFile:j,onUploadFile:i,purpose:l,i:s,updatingValue:g,backward:f.backward,forward:f.forward,wizard:m,submitting:F,onValuesChange:d},s)}))})}function O({fields:u,onDeleteFile:x,onUploadFile:j,purpose:i,wizard:l=[],i:t,forward:g,backward:b,submitting:F,updatingValue:d,onValuesChange:h}){const m=l[t],{t:r}=R.useTranslationLib(),[n]=a.Form.useForm();return q.useEffect(()=>{if(d&&(i==="update"||i==="clone")){const o={};for(const c of u){const s=v.getRealName(c.name,"upsertFieldName"),f=k.getValueByPath(d,s);k.setValueByPath(o,s,f)}n.setFieldsValue(o)}},[u,n,i,d]),e.jsxs(a.Form,{name:String(t),form:n,layout:"vertical",onValuesChange:h,children:[e.jsx(S.CrudFormFields,{fields:u,formBuilder:m.formBuilder,grid:m.grid,onDeleteFile:x,onUploadFile:j,purpose:i}),e.jsx(a.Divider,{}),e.jsxs(a.Row,{gutter:[8,8],children:[t>0&&e.jsx(a.Col,{md:12,children:e.jsx(C,{block:!0,icon:e.jsx(y.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>b(),children:r("str.back")})}),e.jsx(a.Col,{md:t>0?12:24,children:e.jsx(C,{block:!0,icon:l.length-1===t?e.jsx(y.SaveOutlined,{}):e.jsx(y.RightOutlined,{}),htmlType:"submit",type:"primary",loading:F,size:"large",onClick:()=>{n.validateFields().then(o=>{g(o,l.length-1===t,l.length-1===t)})},children:l.length-1===t?r("str."+(i==="update"?"update":"save")):r("str.next")})})]})]})}module.exports=w;
@@ -1,9 +1,9 @@
1
1
  import { FormProps } from 'antd';
2
- import { CrudFieldProps, CrudPurpose, CrudWizardProp } from './CrudComponent';
2
+ import { CrudPurpose, CrudWizardProp, ReadonlyCrudFields } from './CrudComponent';
3
3
  export interface CrudFormWizardProps<T> {
4
4
  onDeleteFile?: (e: any) => void;
5
5
  onUploadFile?: (e: any) => void;
6
- fields: CrudFieldProps<T>[];
6
+ fields: ReadonlyCrudFields<T>;
7
7
  purpose?: CrudPurpose;
8
8
  wizard?: CrudWizardProp<T>[];
9
9
  className?: string;
@@ -1,145 +1,149 @@
1
- import { jsx as o, jsxs as y } from "react/jsx-runtime";
2
- import { LeftOutlined as R, SaveOutlined as w, RightOutlined as x } from "@ant-design/icons";
3
- import { Form as C, Divider as T, Row as W, Col as S } from "antd";
1
+ import { jsx as o, jsxs as F } from "react/jsx-runtime";
2
+ import { LeftOutlined as w, SaveOutlined as x, RightOutlined as R } from "@ant-design/icons";
3
+ import { Form as k, Divider as T, Row as W, Col as C } from "antd";
4
4
  import { useMemo as v, useEffect as j } from "react";
5
5
  import { useTranslationLib as z } from "../locale/index.es.js";
6
- import { CrudFormFields as B } from "./CrudForm.es.js";
6
+ import { CrudFormFields as N } from "./CrudForm.es.js";
7
7
  import O from "../common/wizard/WizardViewForm.es.js";
8
- import b from "../util/CrudUtil.es.js";
9
- import N from "../common/button/Button.es.js";
10
- function I({
8
+ import B from "../util/CrudUtil.es.js";
9
+ import { getValueByPath as A, setValueByPath as E } from "../util/ObjectUtil.es.js";
10
+ import S from "../common/button/Button.es.js";
11
+ function J({
11
12
  fields: d,
12
- className: f,
13
- onDeleteFile: s,
14
- onUploadFile: m,
15
- purpose: l,
13
+ className: h,
14
+ onDeleteFile: g,
15
+ onUploadFile: l,
16
+ purpose: m,
16
17
  wizard: e = [],
17
- updatingValue: h,
18
- onSave: g,
19
- submitting: p,
20
- onValuesChange: a
18
+ updatingValue: p,
19
+ onSave: b,
20
+ submitting: y,
21
+ onValuesChange: c
21
22
  }) {
22
- const u = v(() => e.map((t) => {
23
+ const s = v(() => e.map((t) => {
23
24
  let r = !0;
24
- const n = d.filter(
25
- (i) => t.fields.includes(b.getRealName(i.name))
26
- );
27
- return n.forEach((i) => r && (r = i.hidden ?? !1)), {
25
+ const n = d.filter((a) => {
26
+ const i = B.getRealName(a.name);
27
+ return !Array.isArray(i) && t.fields.includes(i);
28
+ });
29
+ return n.forEach((a) => r && (r = a.hidden ?? !1)), {
28
30
  ...t,
29
31
  hidden: r,
30
32
  fieldThatShouldShowing: n
31
33
  };
32
- }), [d, e]), c = v(
33
- () => u.filter((t) => !t.hidden),
34
- [u]
34
+ }), [d, e]), u = v(
35
+ () => s.filter((t) => !t.hidden),
36
+ [s]
35
37
  );
36
38
  return /* @__PURE__ */ o(
37
39
  O,
38
40
  {
39
41
  onSubmit: (t, r) => {
40
- g(r);
42
+ b(r);
41
43
  },
42
- className: f,
43
- pages: c.map(
44
- ({ title: t, icon: r, fieldThatShouldShowing: n, hidden: i }, F) => ({
44
+ className: h,
45
+ pages: u.map(
46
+ ({ title: t, icon: r, fieldThatShouldShowing: n, hidden: a }, i) => ({
45
47
  title: t,
46
48
  icon: r,
47
- hidden: i,
48
- component: (k) => /* @__PURE__ */ o(
49
- E,
49
+ hidden: a,
50
+ component: (f) => /* @__PURE__ */ o(
51
+ L,
50
52
  {
51
53
  fields: n,
52
- onDeleteFile: s,
53
- onUploadFile: m,
54
- purpose: l,
55
- i: F,
56
- updatingValue: h,
57
- backward: k.backward,
58
- forward: k.forward,
59
- wizard: c,
60
- submitting: p,
61
- onValuesChange: a
54
+ onDeleteFile: g,
55
+ onUploadFile: l,
56
+ purpose: m,
57
+ i,
58
+ updatingValue: p,
59
+ backward: f.backward,
60
+ forward: f.forward,
61
+ wizard: u,
62
+ submitting: y,
63
+ onValuesChange: c
62
64
  },
63
- F
65
+ i
64
66
  )
65
67
  })
66
68
  )
67
69
  }
68
70
  );
69
71
  }
70
- function E({
72
+ function L({
71
73
  fields: d,
72
- onDeleteFile: f,
73
- onUploadFile: s,
74
- purpose: m,
75
- wizard: l = [],
74
+ onDeleteFile: h,
75
+ onUploadFile: g,
76
+ purpose: l,
77
+ wizard: m = [],
76
78
  i: e,
77
- forward: h,
78
- backward: g,
79
- submitting: p,
80
- updatingValue: a,
81
- onValuesChange: u
79
+ forward: p,
80
+ backward: b,
81
+ submitting: y,
82
+ updatingValue: c,
83
+ onValuesChange: s
82
84
  }) {
83
- const c = l[e], { t } = z(), [r] = C.useForm();
85
+ const u = m[e], { t } = z(), [r] = k.useForm();
84
86
  return j(() => {
85
- if (a && (m === "update" || m === "clone")) {
87
+ if (c && (l === "update" || l === "clone")) {
86
88
  const n = {};
87
- for (const i of d)
88
- n[b.getRealName(i.name, "upsertFieldName")] = a[b.getRealName(i.name, "upsertFieldName")];
89
+ for (const a of d) {
90
+ const i = B.getRealName(a.name, "upsertFieldName"), f = A(c, i);
91
+ E(n, i, f);
92
+ }
89
93
  r.setFieldsValue(n);
90
94
  }
91
- }, [d, r, m, a]), /* @__PURE__ */ y(
92
- C,
95
+ }, [d, r, l, c]), /* @__PURE__ */ F(
96
+ k,
93
97
  {
94
98
  name: String(e),
95
99
  form: r,
96
100
  layout: "vertical",
97
- onValuesChange: u,
101
+ onValuesChange: s,
98
102
  children: [
99
103
  /* @__PURE__ */ o(
100
- B,
104
+ N,
101
105
  {
102
106
  fields: d,
103
- formBuilder: c.formBuilder,
104
- grid: c.grid,
105
- onDeleteFile: f,
106
- onUploadFile: s,
107
- purpose: m
107
+ formBuilder: u.formBuilder,
108
+ grid: u.grid,
109
+ onDeleteFile: h,
110
+ onUploadFile: g,
111
+ purpose: l
108
112
  }
109
113
  ),
110
114
  /* @__PURE__ */ o(T, {}),
111
- /* @__PURE__ */ y(W, { gutter: [8, 8], children: [
112
- e > 0 && /* @__PURE__ */ o(S, { md: 12, children: /* @__PURE__ */ o(
113
- N,
115
+ /* @__PURE__ */ F(W, { gutter: [8, 8], children: [
116
+ e > 0 && /* @__PURE__ */ o(C, { md: 12, children: /* @__PURE__ */ o(
117
+ S,
114
118
  {
115
119
  block: !0,
116
- icon: /* @__PURE__ */ o(R, {}),
120
+ icon: /* @__PURE__ */ o(w, {}),
117
121
  htmlType: "button",
118
122
  type: "default",
119
123
  size: "large",
120
- onClick: () => g(),
124
+ onClick: () => b(),
121
125
  children: t("str.back")
122
126
  }
123
127
  ) }),
124
- /* @__PURE__ */ o(S, { md: e > 0 ? 12 : 24, children: /* @__PURE__ */ o(
125
- N,
128
+ /* @__PURE__ */ o(C, { md: e > 0 ? 12 : 24, children: /* @__PURE__ */ o(
129
+ S,
126
130
  {
127
131
  block: !0,
128
- icon: l.length - 1 === e ? /* @__PURE__ */ o(w, {}) : /* @__PURE__ */ o(x, {}),
132
+ icon: m.length - 1 === e ? /* @__PURE__ */ o(x, {}) : /* @__PURE__ */ o(R, {}),
129
133
  htmlType: "submit",
130
134
  type: "primary",
131
- loading: p,
135
+ loading: y,
132
136
  size: "large",
133
137
  onClick: () => {
134
138
  r.validateFields().then((n) => {
135
- h(
139
+ p(
136
140
  n,
137
- l.length - 1 === e,
138
- l.length - 1 === e
141
+ m.length - 1 === e,
142
+ m.length - 1 === e
139
143
  );
140
144
  });
141
145
  },
142
- children: l.length - 1 === e ? t("str." + (m === "update" ? "update" : "save")) : t("str.next")
146
+ children: m.length - 1 === e ? t("str." + (l === "update" ? "update" : "save")) : t("str.next")
143
147
  }
144
148
  ) })
145
149
  ] })
@@ -148,5 +152,5 @@ function E({
148
152
  );
149
153
  }
150
154
  export {
151
- I as default
155
+ J as default
152
156
  };
@@ -15,7 +15,7 @@ export type SearchOnlyFields<F> = CrudFieldProps<F> & {
15
15
  export type ReportCrudFields<T, F> = CrudFieldProps<T> | SearchOnlyFields<F>;
16
16
  export interface CrudReportComponentProps<T_Data, F_Search> {
17
17
  summary?: React.ReactNode;
18
- fields: ReportCrudFields<T_Data, F_Search>[];
18
+ fields: readonly ReportCrudFields<T_Data, F_Search>[];
19
19
  onSubmit: (value: CrudReportSubmitForm<F_Search>) => void;
20
20
  data: T_Data[];
21
21
  idField?: string;
@@ -23,16 +23,16 @@ export interface CrudReportComponentProps<T_Data, F_Search> {
23
23
  size?: SizeType;
24
24
  paginateProps?: CrudPaginateProps;
25
25
  onClickPrint?: (props: {
26
- fields: CrudFieldProps<T_Data>[] & {
26
+ fields: readonly (CrudFieldProps<T_Data> & {
27
27
  render: (value: any, obj: T_Data, index: number) => any;
28
- }[];
28
+ })[];
29
29
  data: T_Data[];
30
30
  tableId: string;
31
31
  }) => void;
32
32
  onClickExcelExport?: (props: {
33
- fields: CrudFieldProps<T_Data>[] & {
33
+ fields: readonly (CrudFieldProps<T_Data> & {
34
34
  render: (value: any, obj: T_Data, index: number) => any;
35
- }[];
35
+ })[];
36
36
  data: T_Data[];
37
37
  tableId: string;
38
38
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import { ColProps } from 'antd/lib';
2
- import { CrudFieldProps } from './CrudComponent';
2
+ import { ReadonlyCrudFields } from './CrudComponent';
3
3
  export type CrudSearchOption<T> = {
4
4
  required?: boolean;
5
5
  } & ({
@@ -12,7 +12,7 @@ export type CrudSearchOption<T> = {
12
12
  });
13
13
  export interface CrudSearchComponentProps<T, FormType> {
14
14
  searchFields?: Array<keyof T | CrudSearchOption<T>>;
15
- fields: CrudFieldProps<T>[];
15
+ fields: ReadonlyCrudFields<T>;
16
16
  searchOnChange?: boolean;
17
17
  searchDefaultValues?: FormType;
18
18
  onSearch?: (values: Partial<FormType>) => void;
@@ -1,7 +1,7 @@
1
- import { CrudFieldProps } from '../CrudComponent';
1
+ import { ReadonlyCrudFields } from '../CrudComponent';
2
2
  import { DialogProps } from '../../types/DialogComponentProp';
3
3
  export interface CrudImportComponentProps<T> {
4
- fields: CrudFieldProps<T>[];
4
+ fields: ReadonlyCrudFields<T>;
5
5
  importProps: CrudImportProps<T>;
6
6
  }
7
7
  export interface CrudImportProps<T> {
@@ -1,4 +1,4 @@
1
- export type { CheckboxBasedFieldProps, ColorPickerFieldProps, CrudComponentProps, CrudFieldGrid, CrudFieldProps, CrudPaginateProps, CrudPurpose, CrudWizardProp, DateBasedFieldProps, EnumCrudField, FormBuilderFunc, FormBuilderFunc0, GetFormFieldOptions, InitialCrudField, NumberBasedFieldProps, ObjectCrudField, SelectCrudField, SelectFieldItem, TextBasedFieldProps, TimeBasedFieldProps, } from './CrudComponent';
1
+ export type { CheckboxBasedFieldProps, ColorPickerFieldProps, CrudComponentProps, CrudFieldGrid, CrudFieldProps, CrudPaginateProps, ReadonlyCrudFields, CrudPurpose, CrudWizardProp, DateBasedFieldProps, EnumCrudField, FormBuilderFunc, FormBuilderFunc0, GetFormFieldOptions, InitialCrudField, NumberBasedFieldProps, ObjectCrudField, SelectCrudField, SelectFieldItem, TextBasedFieldProps, TimeBasedFieldProps, } from './CrudComponent';
2
2
  export { default as CrudComponent } from './CrudComponent';
3
3
  export { default as CrudField, ColorCrudFieldComponent, SelectCrudFieldComponent, } from './CrudField';
4
4
  export { CrudForm, CrudFormFields } from './CrudForm';
@@ -1 +1 @@
1
- "use strict";const g=require("react/jsx-runtime"),B=require("antd"),t=require("react"),J=require("../CrudForm.cjs.js"),K=require("../CrudFormWizard.cjs.js"),Q=require("../../locale/index.cjs.js"),I=require("../../util/CrudUtil.cjs.js"),X=require("dayjs"),Y=({fields:u,wizard:l,grid:M,fullWidthModal:T,isCreating:h,isUpdating:j,onCreate:b,onUpdate:v,idField:k="id",formBuilder:W,onValuesChange:q},_)=>{const[s]=B.Form.useForm(),{t:S}=Q.useTranslationLib(),[C,m]=t.useState(!1),[p,N]=t.useState("new"),[f,F]=t.useState(),[A,y]=t.useState(),[L,V]=t.useState(!1),[E,x]=t.useState(!1),[$,P]=t.useState(!1),R=t.useCallback(async c=>{var n;const d=l?c:await s.validateFields(),i=u.filter(a=>a.type==="color"),o={};for(const a of i){const e=I.getRealName(a.name,"upsertFieldName"),r=s.getFieldValue(e);o[e]=typeof r=="string"?r:(n=r==null?void 0:r.toHexString())==null?void 0:n.toUpperCase()}Object.assign(d,o),f&&v?(await v({...d,[k]:f[k]}),F(void 0)):!f&&b&&await b(d),y(void 0),s.resetFields(),m(!1)},[u,s,k,b,v,f,l]),U=t.useCallback(async c=>{V(c),x(!0)},[]),O=t.useCallback(async()=>{x(!0)},[]),D=t.useCallback(()=>{m(!0),N("new"),s.resetFields(),F(void 0),y(void 0)},[s]),H=t.useCallback(async(c,d=!0,i=!1)=>{try{P(!0),m(!0),N(i?"clone":"update");const o={};for(const n of u){const a=I.getRealName(n.name,"upsertFieldName"),e=c[a];if(i&&n.type==="image"){const r=e;try{const G=await n.provider.clone(r);o[a]=G;continue}catch{continue}}n.type==="date"||n.type==="time"?e&&(o[a]=X(e)):n.type==="select"?n.multiple&&Array.isArray(e)?o[a]=e.map(r=>r[n.innerFieldId??"id"]):e&&typeof e=="object"?o[a]=e[n.innerFieldId??"id"]:(e&&typeof e=="string"||typeof e=="number")&&(o[a]=e):o[a]=e}s.setFieldsValue(o),y(o),d&&F(c)}finally{P(!1)}},[u,s]);t.useImperativeHandle(_,()=>({create:D,update:H}),[D,H]),t.useEffect(()=>{C&&(V(!1),x(!1))},[C]);const w=t.useCallback(async()=>{try{if(p==="clone"){const c=l?f:s.getFieldsValue(),d=u.filter(i=>i.type==="image");for(const i of d)c[i.name]&&i.provider.delete(c[i.name])}}finally{}l||s.resetFields(),y(void 0),F(void 0),m(!1)},[p,l,s,f,u]);return g.jsx(B.Modal,{width:T?"100%":void 0,title:S("str."+(p??"new")),open:C,confirmLoading:h||j,okText:S("str."+(p==="update"?"update":"save")),cancelText:S("str.cancel"),cancelButtonProps:{disabled:E,hidden:!!l},okButtonProps:{disabled:L,hidden:!!l},onCancel:w,onOk:()=>R(),destroyOnHidden:!0,children:g.jsxs(B.Spin,{spinning:$,children:[l?null:g.jsx(J.CrudForm,{purpose:p,fields:u,form:s,formBuilder:W,grid:M,onDeleteFile:O,onUploadFile:U,onValuesChange:q}),l&&g.jsx(K,{submitting:h||j,className:"mt-2",onSave:R,updatingValue:A,fields:u,onDeleteFile:O,onUploadFile:U,purpose:p,wizard:l,onValuesChange:q})]})})},Z=t.forwardRef(Y);module.exports=Z;
1
+ "use strict";const b=require("react/jsx-runtime"),S=require("antd"),t=require("react"),K=require("../CrudForm.cjs.js"),Q=require("../CrudFormWizard.cjs.js"),X=require("../../locale/index.cjs.js"),M=require("../../util/CrudUtil.cjs.js"),Y=require("dayjs"),d=require("../../util/ObjectUtil.cjs.js"),Z=({fields:r,wizard:l,grid:T,fullWidthModal:W,isCreating:C,isUpdating:x,onCreate:B,onUpdate:h,idField:v="id",formBuilder:_,onValuesChange:j},A)=>{const[s]=S.Form.useForm(),{t:V}=X.useTranslationLib(),[k,m]=t.useState(!1),[f,q]=t.useState("new"),[y,F]=t.useState(),[L,g]=t.useState(),[E,N]=t.useState(!1),[$,P]=t.useState(!1),[w,U]=t.useState(!1),O=t.useCallback(async c=>{var a;const p=l?c:await s.validateFields(),i=r.filter(o=>o.type==="color"),n={};for(const o of i){const e=M.getRealName(o.name,"upsertFieldName"),u=s.getFieldValue(e);d.setValueByPath(n,e,typeof u=="string"?u:(a=u==null?void 0:u.toHexString())==null?void 0:a.toUpperCase())}Object.assign(p,n),y&&h?(await h({...p,[v]:y[v]}),F(void 0)):!y&&B&&await B(p),g(void 0),s.resetFields(),m(!1)},[r,s,v,B,h,y,l]),R=t.useCallback(async c=>{N(c),P(!0)},[]),D=t.useCallback(async()=>{P(!0)},[]),H=t.useCallback(()=>{m(!0),q("new"),s.resetFields(),F(void 0),g(void 0)},[s]),I=t.useCallback(async(c,p=!0,i=!1)=>{try{U(!0),m(!0),q(i?"clone":"update");const n={};for(const a of r){const o=M.getRealName(a.name,"upsertFieldName"),e=d.getValueByPath(c,o);if(i&&a.type==="image"){const u=e;try{const J=await a.provider.clone(u);d.setValueByPath(n,o,J);continue}catch{continue}}a.type==="date"||a.type==="time"?e&&d.setValueByPath(n,o,Y(e)):a.type==="select"?a.multiple&&Array.isArray(e)?d.setValueByPath(n,o,e.map(u=>u[a.innerFieldId??"id"])):e&&typeof e=="object"?d.setValueByPath(n,o,e[a.innerFieldId??"id"]):(e&&typeof e=="string"||typeof e=="number")&&d.setValueByPath(n,o,e):d.setValueByPath(n,o,e)}s.setFieldsValue(n),g(n),p&&F(c)}finally{U(!1)}},[r,s]);t.useImperativeHandle(A,()=>({create:H,update:I}),[H,I]),t.useEffect(()=>{k&&(N(!1),P(!1))},[k]);const G=t.useCallback(async()=>{try{if(f==="clone"){const c=l?y:s.getFieldsValue(),p=r.filter(i=>i.type==="image");for(const i of p)c[i.name]&&i.provider.delete(c[i.name])}}finally{}l||s.resetFields(),g(void 0),F(void 0),m(!1)},[f,l,s,y,r]);return b.jsx(S.Modal,{width:W?"100%":void 0,title:V("str."+(f??"new")),open:k,confirmLoading:C||x,okText:V("str."+(f==="update"?"update":"save")),cancelText:V("str.cancel"),cancelButtonProps:{disabled:$,hidden:!!l},okButtonProps:{disabled:E,hidden:!!l},onCancel:G,onOk:()=>O(),destroyOnHidden:!0,children:b.jsxs(S.Spin,{spinning:w,children:[l?null:b.jsx(K.CrudForm,{purpose:f,fields:r,form:s,formBuilder:_,grid:T,onDeleteFile:D,onUploadFile:R,onValuesChange:j}),l&&b.jsx(Q,{submitting:C||x,className:"mt-2",onSave:O,updatingValue:L,fields:r,onDeleteFile:D,onUploadFile:R,purpose:f,wizard:l,onValuesChange:j})]})})},z=t.forwardRef(Z);module.exports=z;
@@ -1,9 +1,9 @@
1
1
  import { FormProps } from 'antd';
2
2
  import { Ref } from 'react';
3
- import { CrudFieldProps, CrudWizardProp, FormBuilderFunc } from '../CrudComponent';
3
+ import { CrudWizardProp, FormBuilderFunc, ReadonlyCrudFields } from '../CrudComponent';
4
4
  import { default as IdProps } from '../../types/Id';
5
5
  export interface CrudModalProps<T, FormType> {
6
- fields: CrudFieldProps<T>[];
6
+ fields: ReadonlyCrudFields<T>;
7
7
  wizard?: CrudWizardProp<T>[];
8
8
  grid?: boolean;
9
9
  fullWidthModal?: boolean;
@@ -1,149 +1,154 @@
1
- import { jsx as S, jsxs as J } from "react/jsx-runtime";
2
- import { Form as K, Modal as Q, Spin as X } from "antd";
3
- import { forwardRef as Y, useState as u, useCallback as m, useImperativeHandle as Z, useEffect as z } from "react";
4
- import { CrudForm as ee } from "../CrudForm.es.js";
5
- import te from "../CrudFormWizard.es.js";
6
- import { useTranslationLib as oe } from "../../locale/index.es.js";
7
- import R from "../../util/CrudUtil.es.js";
8
- import ne from "dayjs";
9
- const se = ({
1
+ import { jsx as P, jsxs as K } from "react/jsx-runtime";
2
+ import { Form as Q, Modal as X, Spin as Y } from "antd";
3
+ import { forwardRef as Z, useState as u, useCallback as F, useImperativeHandle as z, useEffect as ee } from "react";
4
+ import { CrudForm as te } from "../CrudForm.es.js";
5
+ import oe from "../CrudFormWizard.es.js";
6
+ import { useTranslationLib as ne } from "../../locale/index.es.js";
7
+ import T from "../../util/CrudUtil.es.js";
8
+ import se from "dayjs";
9
+ import { setValueByPath as p, getValueByPath as ae } from "../../util/ObjectUtil.es.js";
10
+ const le = ({
10
11
  fields: c,
11
- wizard: l,
12
- grid: T,
13
- fullWidthModal: W,
14
- isCreating: x,
15
- isUpdating: C,
16
- onCreate: v,
17
- onUpdate: b,
18
- idField: B = "id",
19
- formBuilder: _,
20
- onValuesChange: V
21
- }, A) => {
22
- const [t] = K.useForm(), { t: h } = oe(), [k, F] = u(!1), [p, j] = u("new"), [f, y] = u(), [L, g] = u(), [E, P] = u(!1), [$, N] = u(!1), [q, U] = u(!1), O = m(
12
+ wizard: a,
13
+ grid: W,
14
+ fullWidthModal: _,
15
+ isCreating: S,
16
+ isUpdating: x,
17
+ onCreate: b,
18
+ onUpdate: B,
19
+ idField: h = "id",
20
+ formBuilder: A,
21
+ onValuesChange: C
22
+ }, L) => {
23
+ const [t] = Q.useForm(), { t: k } = ne(), [V, y] = u(!1), [f, j] = u("new"), [m, g] = u(), [E, v] = u(), [$, U] = u(!1), [q, N] = u(!1), [w, O] = u(!1), D = F(
23
24
  async (i) => {
24
25
  var o;
25
- const d = l ? i : await t.validateFields(), a = c.filter((s) => s.type === "color"), n = {};
26
- for (const s of a) {
27
- const e = R.getRealName(s.name, "upsertFieldName"), r = t.getFieldValue(e);
28
- n[e] = typeof r == "string" ? r : (o = r == null ? void 0 : r.toHexString()) == null ? void 0 : o.toUpperCase();
26
+ const d = a ? i : await t.validateFields(), l = c.filter((s) => s.type === "color"), n = {};
27
+ for (const s of l) {
28
+ const e = T.getRealName(s.name, "upsertFieldName"), r = t.getFieldValue(e);
29
+ p(
30
+ n,
31
+ e,
32
+ typeof r == "string" ? r : (o = r == null ? void 0 : r.toHexString()) == null ? void 0 : o.toUpperCase()
33
+ );
29
34
  }
30
- Object.assign(d, n), f && b ? (await b({
35
+ Object.assign(d, n), m && B ? (await B({
31
36
  ...d,
32
- [B]: f[B]
33
- }), y(void 0)) : !f && v && await v(d), g(void 0), t.resetFields(), F(!1);
37
+ [h]: m[h]
38
+ }), g(void 0)) : !m && b && await b(d), v(void 0), t.resetFields(), y(!1);
34
39
  },
35
- [c, t, B, v, b, f, l]
36
- ), D = m(async (i) => {
37
- P(i), N(!0);
38
- }, []), H = m(async () => {
40
+ [c, t, h, b, B, m, a]
41
+ ), H = F(async (i) => {
42
+ U(i), N(!0);
43
+ }, []), I = F(async () => {
39
44
  N(!0);
40
- }, []), I = m(() => {
41
- F(!0), j("new"), t.resetFields(), y(void 0), g(void 0);
42
- }, [t]), M = m(
43
- async (i, d = !0, a = !1) => {
45
+ }, []), M = F(() => {
46
+ y(!0), j("new"), t.resetFields(), g(void 0), v(void 0);
47
+ }, [t]), R = F(
48
+ async (i, d = !0, l = !1) => {
44
49
  try {
45
- U(!0), F(!0), j(a ? "clone" : "update");
50
+ O(!0), y(!0), j(l ? "clone" : "update");
46
51
  const n = {};
47
52
  for (const o of c) {
48
- const s = R.getRealName(
53
+ const s = T.getRealName(
49
54
  o.name,
50
55
  "upsertFieldName"
51
- ), e = i[s];
52
- if (a && o.type === "image") {
56
+ ), e = ae(i, s);
57
+ if (l && o.type === "image") {
53
58
  const r = e;
54
59
  try {
55
- const G = await o.provider.clone(r);
56
- n[s] = G;
60
+ const J = await o.provider.clone(r);
61
+ p(n, s, J);
57
62
  continue;
58
63
  } catch {
59
64
  continue;
60
65
  }
61
66
  }
62
- o.type === "date" || o.type === "time" ? e && (n[s] = ne(e)) : o.type === "select" ? o.multiple && Array.isArray(e) ? n[s] = e.map(
67
+ o.type === "date" || o.type === "time" ? e && p(n, s, se(e)) : o.type === "select" ? o.multiple && Array.isArray(e) ? p(n, s, e.map(
63
68
  (r) => r[o.innerFieldId ?? "id"]
64
- ) : e && typeof e == "object" ? n[s] = e[o.innerFieldId ?? "id"] : (e && typeof e == "string" || typeof e == "number") && (n[s] = e) : n[s] = e;
69
+ )) : e && typeof e == "object" ? p(n, s, e[o.innerFieldId ?? "id"]) : (e && typeof e == "string" || typeof e == "number") && p(n, s, e) : p(n, s, e);
65
70
  }
66
- t.setFieldsValue(n), g(n), d && y(i);
71
+ t.setFieldsValue(n), v(n), d && g(i);
67
72
  } finally {
68
- U(!1);
73
+ O(!1);
69
74
  }
70
75
  },
71
76
  [c, t]
72
77
  );
73
- Z(
74
- A,
78
+ z(
79
+ L,
75
80
  () => ({
76
- create: I,
77
- update: M
81
+ create: M,
82
+ update: R
78
83
  }),
79
- [I, M]
80
- ), z(() => {
81
- k && (P(!1), N(!1));
82
- }, [k]);
83
- const w = m(async () => {
84
+ [M, R]
85
+ ), ee(() => {
86
+ V && (U(!1), N(!1));
87
+ }, [V]);
88
+ const G = F(async () => {
84
89
  try {
85
- if (p === "clone") {
86
- const i = l ? f : t.getFieldsValue(), d = c.filter((a) => a.type === "image");
87
- for (const a of d)
88
- i[a.name] && a.provider.delete(i[a.name]);
90
+ if (f === "clone") {
91
+ const i = a ? m : t.getFieldsValue(), d = c.filter((l) => l.type === "image");
92
+ for (const l of d)
93
+ i[l.name] && l.provider.delete(i[l.name]);
89
94
  }
90
95
  } finally {
91
96
  }
92
- l || t.resetFields(), g(void 0), y(void 0), F(!1);
93
- }, [p, l, t, f, c]);
94
- return /* @__PURE__ */ S(
95
- Q,
97
+ a || t.resetFields(), v(void 0), g(void 0), y(!1);
98
+ }, [f, a, t, m, c]);
99
+ return /* @__PURE__ */ P(
100
+ X,
96
101
  {
97
- width: W ? "100%" : void 0,
98
- title: h("str." + (p ?? "new")),
99
- open: k,
100
- confirmLoading: x || C,
101
- okText: h("str." + (p === "update" ? "update" : "save")),
102
- cancelText: h("str.cancel"),
102
+ width: _ ? "100%" : void 0,
103
+ title: k("str." + (f ?? "new")),
104
+ open: V,
105
+ confirmLoading: S || x,
106
+ okText: k("str." + (f === "update" ? "update" : "save")),
107
+ cancelText: k("str.cancel"),
103
108
  cancelButtonProps: {
104
- disabled: $,
105
- hidden: !!l
109
+ disabled: q,
110
+ hidden: !!a
106
111
  },
107
112
  okButtonProps: {
108
- disabled: E,
109
- hidden: !!l
113
+ disabled: $,
114
+ hidden: !!a
110
115
  },
111
- onCancel: w,
112
- onOk: () => O(),
116
+ onCancel: G,
117
+ onOk: () => D(),
113
118
  destroyOnHidden: !0,
114
- children: /* @__PURE__ */ J(X, { spinning: q, children: [
115
- l ? null : /* @__PURE__ */ S(
116
- ee,
119
+ children: /* @__PURE__ */ K(Y, { spinning: w, children: [
120
+ a ? null : /* @__PURE__ */ P(
121
+ te,
117
122
  {
118
- purpose: p,
123
+ purpose: f,
119
124
  fields: c,
120
125
  form: t,
121
- formBuilder: _,
122
- grid: T,
123
- onDeleteFile: H,
124
- onUploadFile: D,
125
- onValuesChange: V
126
+ formBuilder: A,
127
+ grid: W,
128
+ onDeleteFile: I,
129
+ onUploadFile: H,
130
+ onValuesChange: C
126
131
  }
127
132
  ),
128
- l && /* @__PURE__ */ S(
129
- te,
133
+ a && /* @__PURE__ */ P(
134
+ oe,
130
135
  {
131
- submitting: x || C,
136
+ submitting: S || x,
132
137
  className: "mt-2",
133
- onSave: O,
134
- updatingValue: L,
138
+ onSave: D,
139
+ updatingValue: E,
135
140
  fields: c,
136
- onDeleteFile: H,
137
- onUploadFile: D,
138
- purpose: p,
139
- wizard: l,
140
- onValuesChange: V
141
+ onDeleteFile: I,
142
+ onUploadFile: H,
143
+ purpose: f,
144
+ wizard: a,
145
+ onValuesChange: C
141
146
  }
142
147
  )
143
148
  ] })
144
149
  }
145
150
  );
146
- }, fe = Y(se);
151
+ }, ye = Z(le);
147
152
  export {
148
- fe as default
153
+ ye as default
149
154
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("../../common/description/DescList.cjs.js"),j=require("react"),v=require("../../locale/index.cjs.js"),V=require("./CrudViewerUtil.cjs.js"),f=require("../../util/CrudUtil.cjs.js"),p=require("../actions/index.cjs.js");function w({className:m,fields:i,data:e,descListColumn:b={xs:1,md:3,sm:2,lg:4},layout:g,keepEmptyValues:q,inBuiltModalProps:u,...s}){const{t:o}=v.useTranslationLib(),x=j.useMemo(()=>{const l=i.filter(({hidden:r,hideInDescList:n})=>!r&&!n).map((r,n)=>{const C=f.getRealName(r.name);return{label:r.label,noFormatting:!0,value:V.getRendererValueCrudViewer(r)(e==null?void 0:e[C],e,n)}}),c=e?t.jsx(p,{data:e,...s,inBuiltModalProps:u?{...u,fields:i}:void 0}):void 0;return c&&l.push({label:o("str.action"),value:c}),l},[e,i,o,s]);return e?t.jsx(d,{keepEmptyValues:q,bordered:!0,column:b,className:m,layout:g,list:x}):t.jsx(t.Fragment,{})}exports.CrudDecListView=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),x=require("../../common/description/DescList.cjs.js"),j=require("react"),C=require("../../locale/index.cjs.js"),V=require("./CrudViewerUtil.cjs.js"),v=require("../../util/CrudUtil.cjs.js"),f=require("../actions/index.cjs.js"),p=require("../../util/ObjectUtil.cjs.js");function w({className:m,fields:i,data:e,descListColumn:a={xs:1,md:3,sm:2,lg:4},layout:d,keepEmptyValues:b,inBuiltModalProps:u,...s}){const{t:o}=C.useTranslationLib(),g=j.useMemo(()=>{const l=i.filter(({hidden:t,hideInDescList:n})=>!t&&!n).map((t,n)=>{const q=v.getRealName(t.name);return{label:t.label,noFormatting:!0,value:V.getRendererValueCrudViewer(t)(p.getValueByPath(e,q),e,n)}}),c=e?r.jsx(f,{data:e,...s,inBuiltModalProps:u?{...u,fields:i}:void 0}):void 0;return c&&l.push({label:o("str.action"),value:c}),l},[e,i,o,s]);return e?r.jsx(x,{keepEmptyValues:b,bordered:!0,column:a,className:m,layout:d,list:g}):r.jsx(r.Fragment,{})}exports.CrudDecListView=w;
@@ -1,10 +1,10 @@
1
1
  import { Breakpoint } from 'antd';
2
- import { CrudFieldProps } from '../CrudComponent';
2
+ import { ReadonlyCrudFields } from '../CrudComponent';
3
3
  import { CrudActionsProps } from '../actions';
4
4
  import { CrudModalProps } from '../modal';
5
5
  export type DescListColumn = number | Partial<Record<Breakpoint, number>> | undefined;
6
6
  export interface CrudDecListViewProps<T, FormType = T> extends Omit<CrudActionsProps<T, FormType>, "inBuiltModalProps"> {
7
- fields: CrudFieldProps<T>[];
7
+ fields: ReadonlyCrudFields<T>;
8
8
  data: T | undefined;
9
9
  className?: string;
10
10
  descListColumn?: DescListColumn;
@@ -1,57 +1,58 @@
1
- import { jsx as i, Fragment as v } from "react/jsx-runtime";
2
- import x from "../../common/description/DescList.es.js";
3
- import { useMemo as F } from "react";
4
- import { useTranslationLib as L } from "../../locale/index.es.js";
5
- import { getRendererValueCrudViewer as V } from "./CrudViewerUtil.es.js";
6
- import w from "../../util/CrudUtil.es.js";
7
- import D from "../actions/index.es.js";
8
- function _({
1
+ import { jsx as m, Fragment as C } from "react/jsx-runtime";
2
+ import d from "../../common/description/DescList.es.js";
3
+ import { useMemo as v } from "react";
4
+ import { useTranslationLib as V } from "../../locale/index.es.js";
5
+ import { getRendererValueCrudViewer as x } from "./CrudViewerUtil.es.js";
6
+ import F from "../../util/CrudUtil.es.js";
7
+ import L from "../actions/index.es.js";
8
+ import { getValueByPath as h } from "../../util/ObjectUtil.es.js";
9
+ function T({
9
10
  className: p,
10
- fields: o,
11
+ fields: t,
11
12
  data: r,
12
- descListColumn: c = { xs: 1, md: 3, sm: 2, lg: 4 },
13
- layout: f,
14
- keepEmptyValues: b,
15
- inBuiltModalProps: m,
13
+ descListColumn: f = { xs: 1, md: 3, sm: 2, lg: 4 },
14
+ layout: c,
15
+ keepEmptyValues: a,
16
+ inBuiltModalProps: i,
16
17
  ...n
17
18
  }) {
18
- const { t: u } = L(), g = F(() => {
19
- const l = o.filter(({ hidden: e, hideInDescList: t }) => !e && !t).map((e, t) => {
20
- const C = w.getRealName(e.name);
19
+ const { t: u } = V(), g = v(() => {
20
+ const l = t.filter(({ hidden: e, hideInDescList: o }) => !e && !o).map((e, o) => {
21
+ const b = F.getRealName(e.name);
21
22
  return {
22
23
  label: e.label,
23
24
  noFormatting: !0,
24
- value: V(e)(
25
- r == null ? void 0 : r[C],
25
+ value: x(e)(
26
+ h(r, b),
26
27
  r,
27
- t
28
+ o
28
29
  )
29
30
  };
30
- }), s = r ? /* @__PURE__ */ i(
31
- D,
31
+ }), s = r ? /* @__PURE__ */ m(
32
+ L,
32
33
  {
33
34
  data: r,
34
35
  ...n,
35
- inBuiltModalProps: m ? { ...m, fields: o } : void 0
36
+ inBuiltModalProps: i ? { ...i, fields: t } : void 0
36
37
  }
37
38
  ) : void 0;
38
39
  return s && l.push({
39
40
  label: u("str.action"),
40
41
  value: s
41
42
  }), l;
42
- }, [r, o, u, n]);
43
- return r ? /* @__PURE__ */ i(
44
- x,
43
+ }, [r, t, u, n]);
44
+ return r ? /* @__PURE__ */ m(
45
+ d,
45
46
  {
46
- keepEmptyValues: b,
47
+ keepEmptyValues: a,
47
48
  bordered: !0,
48
- column: c,
49
+ column: f,
49
50
  className: p,
50
- layout: f,
51
+ layout: c,
51
52
  list: g
52
53
  }
53
- ) : /* @__PURE__ */ i(v, {});
54
+ ) : /* @__PURE__ */ m(C, {});
54
55
  }
55
56
  export {
56
- _ as CrudDecListView
57
+ T as CrudDecListView
57
58
  };
@@ -4,7 +4,7 @@ import { DragEndEvent } from '@dnd-kit/core';
4
4
  import { TableProps } from 'antd/lib';
5
5
  import { CrudActionsProps } from '../actions';
6
6
  import { default as React } from 'react';
7
- import { CrudFieldProps, CrudPaginateProps } from '../CrudComponent';
7
+ import { CrudPaginateProps, ReadonlyCrudFields } from '../CrudComponent';
8
8
  import { CrudSearchComponentProps } from '../CrudSearchComponent';
9
9
  import { DescListColumn } from './CrudDecListView';
10
10
  type TableRowSelection<T> = TableProps<T>["rowSelection"];
@@ -21,7 +21,7 @@ export type CrudViewableProps<T> = boolean | keyof T | {
21
21
  };
22
22
  export type CrudViewerProps<T, FormType> = {
23
23
  summary?: TableProps<T>["summary"];
24
- fields: CrudFieldProps<T>[];
24
+ fields: ReadonlyCrudFields<T>;
25
25
  decListLayout?: "horizontal" | "vertical";
26
26
  viewable?: CrudViewableProps<T>;
27
27
  paginateProps?: CrudPaginateProps;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("@ant-design/icons"),b=require("antd"),B=require("../FileCrudField.cjs.js"),W=require("../ImageCrudField.cjs.js"),C=require("../../util/DateUtil.cjs.js"),v=require("../../util/NumberUtil.cjs.js"),T=require("../../locale/index.cjs.js"),F=require("../../util/CrudUtil.cjs.js"),h=require("../../common/error/ErrorBoundaryComponent.cjs.js"),i=require("../../util/CopyUtilComponent.cjs.js");function q({type:d,render:e,...p}){try{return d==="object"?(o,n,a)=>t.jsx(i.CopyToClipboardButtonWrapper,{copyable:p.copyable,value:o,children:typeof e=="function"?e(o,n,a):""}):d==="select"?(o,n,a)=>{if(!o)return"-";const r=p,c=o||(r.items??[]).find(s=>s[r.innerFieldId??"key"]===n[F.getRealName(p.name,"upsertFieldName")]),u=r.multiple?Array.isArray(c)?c.map(s=>s==null?void 0:s[r.innerFieldLabel??"name"]):void 0:c==null?void 0:c[r.innerFieldLabel??"value"];return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,u),children:typeof e=="function"?e(u,n,a):Array.isArray(u)?u.join(", "):u})}:d==="number"?(o,n,a)=>{const r=p;return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,o),children:typeof e=="function"?e(o,n,a):r.int?v.default.toInt(o,r.formatted):v.default.toMoney(o)})}:d==="enum"?(o,n,a)=>{var s;if(!o)return"-";const r=p;if(typeof e=="function")return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:e(o,n,a)});if(r.multiple){const f=(Array.isArray(o)?o:o?[o]:[]).map(l=>{var j,m;const y=(j=r.tagRender)==null?void 0:j[l],x=T.tWithOrWithoutNS(((m=r==null?void 0:r.translation)==null?void 0:m[l??""])??l,void 0,l);return{tagProps:y,translatedValue:x,item:l}});if(typeof r.tagRender=="object")return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:()=>f.map(({translatedValue:l,item:y})=>l??y).join(", "),children:t.jsx(h.ErrorBoundaryComponent,{children:t.jsx(b.Space,{wrap:!0,children:f.map(({tagProps:l,translatedValue:y,item:x},j)=>l?t.jsx(b.Tag,{color:l.color,children:y},j+x):y)})})});if(r!=null&&r.translation)return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:()=>f.map(({translatedValue:l,item:y})=>l??y).join(", "),children:t.jsx(h.ErrorBoundaryComponent,{children:f==null?void 0:f.map(({translatedValue:l,item:y})=>l??y).join(", ")})});{const l=f.map(({translatedValue:y,item:x})=>y??x).join(", ");return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,l),children:l})}}const c=((s=r==null?void 0:r.translation)==null?void 0:s[o??""])??o,u=T.tWithOrWithoutNS(c,void 0,o);if(typeof r.tagRender=="object"){const f=r.tagRender[o];if(f)return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:u,children:t.jsx(b.Tag,{color:f.color,children:u})})}return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,u),children:u})}:d==="date"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.formatTime?C.formatDateTime(o):C.formatDate(o);return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:c,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):c})})}:d==="checkbox"?(o,n,a)=>typeof e=="function"?e(o,n,a):o?t.jsx(g.CheckOutlined,{}):t.jsx(g.CloseOutlined,{}):d==="image"?(o,n,a)=>o?t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):t.jsx(W.ImageCrudCellValue,{value:o,provider:p.provider})}):"-":d==="file"?(o,n,a)=>o?t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):t.jsx(B.FileCrudCellValue,{value:o,provider:p.provider})}):"":d==="time"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.format,u=r.use12Hours,s=C.formatTime(o,c||(u?"hh:mm:ss A":void 0));return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:s,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):s})})}:d==="color"?(o,n,a)=>{const r=p;return o?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):typeof o=="string"&&o.startsWith("#")?t.jsx(b.Tooltip,{title:o,children:t.jsx(b.Avatar,{style:{backgroundColor:o}})}):String(o)})}):"-"}:d==="textarea"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.truncated??1,u=typeof o=="string"&&o.split(" ").length<10;return typeof e=="function"?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:e(o,n,a)}):c?t.jsx(h.ErrorBoundaryComponent,{children:t.jsx(b.Typography.Paragraph,{ellipsis:!u&&{rows:c===!0?1:c,expandable:"collapsible"},copyable:i.copyableFn(r.copyable,o),children:r.rich?t.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:o}}):o})}):r.rich?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:t.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:o}})}):t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:o})}:typeof e=="function"?e:(o,n,a)=>{const r=p;return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,o),children:o})}}catch(o){return console.warn("An error occurred while rendering the value for field: "+String(p.name),o),"-"}}exports.getRendererValueCrudViewer=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("@ant-design/icons"),b=require("antd"),B=require("../FileCrudField.cjs.js"),W=require("../ImageCrudField.cjs.js"),C=require("../../util/DateUtil.cjs.js"),v=require("../../util/NumberUtil.cjs.js"),T=require("../../locale/index.cjs.js"),F=require("../../util/CrudUtil.cjs.js"),h=require("../../common/error/ErrorBoundaryComponent.cjs.js"),i=require("../../util/CopyUtilComponent.cjs.js"),q=require("../../util/ObjectUtil.cjs.js");function S({type:d,render:e,...p}){try{return d==="object"?(o,n,a)=>t.jsx(i.CopyToClipboardButtonWrapper,{copyable:p.copyable,value:o,children:typeof e=="function"?e(o,n,a):""}):d==="select"?(o,n,a)=>{if(!o)return"-";const r=p,c=o||(r.items??[]).find(s=>s[r.innerFieldId??"key"]===q.getValueByPath(n,F.getRealName(p.name,"upsertFieldName"))),u=r.multiple?Array.isArray(c)?c.map(s=>s==null?void 0:s[r.innerFieldLabel??"name"]):void 0:c==null?void 0:c[r.innerFieldLabel??"value"];return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,u),children:typeof e=="function"?e(u,n,a):Array.isArray(u)?u.join(", "):u})}:d==="number"?(o,n,a)=>{const r=p;return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,o),children:typeof e=="function"?e(o,n,a):r.int?v.default.toInt(o,r.formatted):v.default.toMoney(o)})}:d==="enum"?(o,n,a)=>{var s;if(!o)return"-";const r=p;if(typeof e=="function")return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:e(o,n,a)});if(r.multiple){const f=(Array.isArray(o)?o:o?[o]:[]).map(l=>{var j,m;const y=(j=r.tagRender)==null?void 0:j[l],x=T.tWithOrWithoutNS(((m=r==null?void 0:r.translation)==null?void 0:m[l??""])??l,void 0,l);return{tagProps:y,translatedValue:x,item:l}});if(typeof r.tagRender=="object")return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:()=>f.map(({translatedValue:l,item:y})=>l??y).join(", "),children:t.jsx(h.ErrorBoundaryComponent,{children:t.jsx(b.Space,{wrap:!0,children:f.map(({tagProps:l,translatedValue:y,item:x},j)=>l?t.jsx(b.Tag,{color:l.color,children:y},j+x):y)})})});if(r!=null&&r.translation)return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:()=>f.map(({translatedValue:l,item:y})=>l??y).join(", "),children:t.jsx(h.ErrorBoundaryComponent,{children:f==null?void 0:f.map(({translatedValue:l,item:y})=>l??y).join(", ")})});{const l=f.map(({translatedValue:y,item:x})=>y??x).join(", ");return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,l),children:l})}}const c=((s=r==null?void 0:r.translation)==null?void 0:s[o??""])??o,u=T.tWithOrWithoutNS(c,void 0,o);if(typeof r.tagRender=="object"){const f=r.tagRender[o];if(f)return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:u,children:t.jsx(b.Tag,{color:f.color,children:u})})}return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,u),children:u})}:d==="date"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.formatTime?C.formatDateTime(o):C.formatDate(o);return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:c,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):c})})}:d==="checkbox"?(o,n,a)=>typeof e=="function"?e(o,n,a):o?t.jsx(g.CheckOutlined,{}):t.jsx(g.CloseOutlined,{}):d==="image"?(o,n,a)=>o?t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):t.jsx(W.ImageCrudCellValue,{value:o,provider:p.provider})}):"-":d==="file"?(o,n,a)=>o?t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):t.jsx(B.FileCrudCellValue,{value:o,provider:p.provider})}):"":d==="time"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.format,u=r.use12Hours,s=C.formatTime(o,c||(u?"hh:mm:ss A":void 0));return t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:s,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):s})})}:d==="color"?(o,n,a)=>{const r=p;return o?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:t.jsx(h.ErrorBoundaryComponent,{children:typeof e=="function"?e(o,n,a):typeof o=="string"&&o.startsWith("#")?t.jsx(b.Tooltip,{title:o,children:t.jsx(b.Avatar,{style:{backgroundColor:o}})}):String(o)})}):"-"}:d==="textarea"?(o,n,a)=>{if(!o)return"-";const r=p,c=r.truncated??1,u=typeof o=="string"&&o.split(" ").length<10;return typeof e=="function"?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:e(o,n,a)}):c?t.jsx(h.ErrorBoundaryComponent,{children:t.jsx(b.Typography.Paragraph,{ellipsis:!u&&{rows:c===!0?1:c,expandable:"collapsible"},copyable:i.copyableFn(r.copyable,o),children:r.rich?t.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:o}}):o})}):r.rich?t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:t.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:o}})}):t.jsx(i.CopyToClipboardButtonWrapper,{copyable:r.copyable,value:o,children:o})}:typeof e=="function"?e:(o,n,a)=>{const r=p;return t.jsx(b.Typography.Text,{copyable:i.copyableFn(r.copyable,o),children:o})}}catch(o){return console.warn("An error occurred while rendering the value for field: "+String(p.name),o),"-"}}exports.getRendererValueCrudViewer=S;
@@ -1,47 +1,48 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import { CheckOutlined as S, CloseOutlined as F } from "@ant-design/icons";
3
- import { Typography as d, Space as R, Tag as C, Tooltip as w, Avatar as I } from "antd";
4
- import { FileCrudCellValue as P } from "../FileCrudField.es.js";
5
- import { ImageCrudCellValue as V } from "../ImageCrudField.es.js";
3
+ import { Typography as h, Space as P, Tag as C, Tooltip as R, Avatar as V } from "antd";
4
+ import { FileCrudCellValue as w } from "../FileCrudField.es.js";
5
+ import { ImageCrudCellValue as I } from "../ImageCrudField.es.js";
6
6
  import T from "../../util/DateUtil.es.js";
7
7
  import j from "../../util/NumberUtil.es.js";
8
8
  import { tWithOrWithoutNS as A } from "../../locale/index.es.js";
9
9
  import k from "../../util/CrudUtil.es.js";
10
10
  import { ErrorBoundaryComponent as b } from "../../common/error/ErrorBoundaryComponent.es.js";
11
- import { CopyToClipboardButtonWrapper as m, copyableFn as h } from "../../util/CopyUtilComponent.es.js";
12
- function z({
11
+ import { CopyToClipboardButtonWrapper as m, copyableFn as d } from "../../util/CopyUtilComponent.es.js";
12
+ import { getValueByPath as D } from "../../util/ObjectUtil.es.js";
13
+ function J({
13
14
  type: y,
14
- render: n,
15
+ render: e,
15
16
  ...u
16
17
  }) {
17
18
  try {
18
- return y === "object" ? (t, l, e) => /* @__PURE__ */ r(
19
+ return y === "object" ? (t, l, n) => /* @__PURE__ */ r(
19
20
  m,
20
21
  {
21
22
  copyable: u.copyable,
22
23
  value: t,
23
- children: typeof n == "function" ? n(t, l, e) : ""
24
+ children: typeof e == "function" ? e(t, l, n) : ""
24
25
  }
25
- ) : y === "select" ? (t, l, e) => {
26
+ ) : y === "select" ? (t, l, n) => {
26
27
  if (!t) return "-";
27
28
  const o = u, a = t || (o.items ?? []).find(
28
- (f) => f[o.innerFieldId ?? "key"] === l[k.getRealName(u.name, "upsertFieldName")]
29
+ (f) => f[o.innerFieldId ?? "key"] === D(l, k.getRealName(u.name, "upsertFieldName"))
29
30
  ), c = o.multiple ? Array.isArray(a) ? a.map((f) => f == null ? void 0 : f[o.innerFieldLabel ?? "name"]) : void 0 : a == null ? void 0 : a[o.innerFieldLabel ?? "value"];
30
- return /* @__PURE__ */ r(d.Text, { copyable: h(o.copyable, c), children: typeof n == "function" ? n(c, l, e) : Array.isArray(c) ? c.join(", ") : c });
31
- } : y === "number" ? (t, l, e) => {
31
+ return /* @__PURE__ */ r(h.Text, { copyable: d(o.copyable, c), children: typeof e == "function" ? e(c, l, n) : Array.isArray(c) ? c.join(", ") : c });
32
+ } : y === "number" ? (t, l, n) => {
32
33
  const o = u;
33
- return /* @__PURE__ */ r(d.Text, { copyable: h(o.copyable, t), children: typeof n == "function" ? n(t, l, e) : o.int ? j.toInt(t, o.formatted) : j.toMoney(t) });
34
- } : y === "enum" ? (t, l, e) => {
34
+ return /* @__PURE__ */ r(h.Text, { copyable: d(o.copyable, t), children: typeof e == "function" ? e(t, l, n) : o.int ? j.toInt(t, o.formatted) : j.toMoney(t) });
35
+ } : y === "enum" ? (t, l, n) => {
35
36
  var f;
36
37
  if (!t) return "-";
37
38
  const o = u;
38
- if (typeof n == "function")
39
+ if (typeof e == "function")
39
40
  return /* @__PURE__ */ r(
40
41
  m,
41
42
  {
42
43
  copyable: o.copyable,
43
44
  value: t,
44
- children: n(t, l, e)
45
+ children: e(t, l, n)
45
46
  }
46
47
  );
47
48
  if (o.multiple) {
@@ -66,7 +67,7 @@ function z({
66
67
  value: () => s.map(
67
68
  ({ translatedValue: i, item: p }) => i ?? p
68
69
  ).join(", "),
69
- children: /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(R, { wrap: !0, children: s.map(({ tagProps: i, translatedValue: p, item: v }, g) => i ? /* @__PURE__ */ r(C, { color: i.color, children: p }, g + v) : p) }) })
70
+ children: /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(P, { wrap: !0, children: s.map(({ tagProps: i, translatedValue: p, item: v }, g) => i ? /* @__PURE__ */ r(C, { color: i.color, children: p }, g + v) : p) }) })
70
71
  }
71
72
  );
72
73
  if (o != null && o.translation)
@@ -85,9 +86,9 @@ function z({
85
86
  {
86
87
  const i = s.map(({ translatedValue: p, item: v }) => p ?? v).join(", ");
87
88
  return /* @__PURE__ */ r(
88
- d.Text,
89
+ h.Text,
89
90
  {
90
- copyable: h(o.copyable, i),
91
+ copyable: d(o.copyable, i),
91
92
  children: i
92
93
  }
93
94
  );
@@ -106,8 +107,8 @@ function z({
106
107
  }
107
108
  );
108
109
  }
109
- return /* @__PURE__ */ r(d.Text, { copyable: h(o.copyable, c), children: c });
110
- } : y === "date" ? (t, l, e) => {
110
+ return /* @__PURE__ */ r(h.Text, { copyable: d(o.copyable, c), children: c });
111
+ } : y === "date" ? (t, l, n) => {
111
112
  if (!t) return "-";
112
113
  const o = u, a = o.formatTime ? T.formatDateTime(t) : T.formatDate(t);
113
114
  return /* @__PURE__ */ r(
@@ -115,22 +116,22 @@ function z({
115
116
  {
116
117
  copyable: o.copyable,
117
118
  value: a,
118
- children: /* @__PURE__ */ r(b, { children: typeof n == "function" ? n(t, l, e) : a })
119
+ children: /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : a })
119
120
  }
120
121
  );
121
- } : y === "checkbox" ? (t, l, e) => typeof n == "function" ? n(t, l, e) : t ? /* @__PURE__ */ r(S, {}) : /* @__PURE__ */ r(F, {}) : y === "image" ? (t, l, e) => t ? /* @__PURE__ */ r(b, { children: typeof n == "function" ? n(t, l, e) : /* @__PURE__ */ r(
122
- V,
122
+ } : y === "checkbox" ? (t, l, n) => typeof e == "function" ? e(t, l, n) : t ? /* @__PURE__ */ r(S, {}) : /* @__PURE__ */ r(F, {}) : y === "image" ? (t, l, n) => t ? /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : /* @__PURE__ */ r(
123
+ I,
123
124
  {
124
125
  value: t,
125
126
  provider: u.provider
126
127
  }
127
- ) }) : "-" : y === "file" ? (t, l, e) => t ? /* @__PURE__ */ r(b, { children: typeof n == "function" ? n(t, l, e) : /* @__PURE__ */ r(
128
- P,
128
+ ) }) : "-" : y === "file" ? (t, l, n) => t ? /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : /* @__PURE__ */ r(
129
+ w,
129
130
  {
130
131
  value: t,
131
132
  provider: u.provider
132
133
  }
133
- ) }) : "" : y === "time" ? (t, l, e) => {
134
+ ) }) : "" : y === "time" ? (t, l, n) => {
134
135
  if (!t) return "-";
135
136
  const o = u, a = o.format, c = o.use12Hours, f = T.formatTime(
136
137
  t,
@@ -141,30 +142,30 @@ function z({
141
142
  {
142
143
  copyable: o.copyable,
143
144
  value: f,
144
- children: /* @__PURE__ */ r(b, { children: typeof n == "function" ? n(t, l, e) : f })
145
+ children: /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : f })
145
146
  }
146
147
  );
147
- } : y === "color" ? (t, l, e) => {
148
+ } : y === "color" ? (t, l, n) => {
148
149
  const o = u;
149
- return t ? /* @__PURE__ */ r(m, { copyable: o.copyable, value: t, children: /* @__PURE__ */ r(b, { children: typeof n == "function" ? n(t, l, e) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ r(w, { title: t, children: /* @__PURE__ */ r(I, { style: { backgroundColor: t } }) }) : String(t) }) }) : "-";
150
- } : y === "textarea" ? (t, l, e) => {
150
+ return t ? /* @__PURE__ */ r(m, { copyable: o.copyable, value: t, children: /* @__PURE__ */ r(b, { children: typeof e == "function" ? e(t, l, n) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ r(R, { title: t, children: /* @__PURE__ */ r(V, { style: { backgroundColor: t } }) }) : String(t) }) }) : "-";
151
+ } : y === "textarea" ? (t, l, n) => {
151
152
  if (!t) return "-";
152
153
  const o = u, a = o.truncated ?? 1, c = typeof t == "string" && t.split(" ").length < 10;
153
- return typeof n == "function" ? /* @__PURE__ */ r(
154
+ return typeof e == "function" ? /* @__PURE__ */ r(
154
155
  m,
155
156
  {
156
157
  copyable: o.copyable,
157
158
  value: t,
158
- children: n(t, l, e)
159
+ children: e(t, l, n)
159
160
  }
160
161
  ) : a ? /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(
161
- d.Paragraph,
162
+ h.Paragraph,
162
163
  {
163
164
  ellipsis: !c && {
164
165
  rows: a === !0 ? 1 : a,
165
166
  expandable: "collapsible"
166
167
  },
167
- copyable: h(o.copyable, t),
168
+ copyable: d(o.copyable, t),
168
169
  children: o.rich ? /* @__PURE__ */ r(
169
170
  "div",
170
171
  {
@@ -194,9 +195,9 @@ function z({
194
195
  children: t
195
196
  }
196
197
  );
197
- } : typeof n == "function" ? n : (t, l, e) => {
198
+ } : typeof e == "function" ? e : (t, l, n) => {
198
199
  const o = u;
199
- return /* @__PURE__ */ r(d.Text, { copyable: h(o.copyable, t), children: t });
200
+ return /* @__PURE__ */ r(h.Text, { copyable: d(o.copyable, t), children: t });
200
201
  };
201
202
  } catch (t) {
202
203
  return console.warn(
@@ -206,5 +207,5 @@ function z({
206
207
  }
207
208
  }
208
209
  export {
209
- z as getRendererValueCrudViewer
210
+ J as getRendererValueCrudViewer
210
211
  };
@@ -1,4 +1,4 @@
1
- import { InitialCrudField, SelectCrudField } from 'src/crud';
1
+ import { InitialCrudField, SelectCrudField } from '../crud/CrudComponent';
2
2
  declare class CrudUtil {
3
3
  static getRealName<T>(name: InitialCrudField<T>["name"] | SelectCrudField<T>["name"], extract?: "name" | "upsertFieldName"): (string | number)[] | keyof T;
4
4
  }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(e,r){return typeof e!="object"||e===null?e:Array.isArray(r)?r.reduce((t,u)=>t[u],e):e[r]}function i(e,r,t){return typeof e!="object"||e===null?e:Array.isArray(r)?r.reduce((u,n)=>u[n],e):(e[r]=t,e)}exports.getValueByPath=y;exports.setValueByPath=i;
@@ -0,0 +1,2 @@
1
+ export declare function getValueByPath<T = any>(obj: T, path: (string | number)[] | keyof T): T[keyof T] | any;
2
+ export declare function setValueByPath<T = any>(obj: T, path: (string | number)[] | keyof T, value: any): T;
@@ -0,0 +1,10 @@
1
+ function f(r, e) {
2
+ return typeof r != "object" || r === null ? r : Array.isArray(e) ? e.reduce((u, t) => u[t], r) : r[e];
3
+ }
4
+ function i(r, e, u) {
5
+ return typeof r != "object" || r === null ? r : Array.isArray(e) ? e.reduce((t, n) => t[n], r) : (r[e] = u, r);
6
+ }
7
+ export {
8
+ f as getValueByPath,
9
+ i as setValueByPath
10
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.29.0",
4
+ "version": "1.29.1",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",
@@ -1,86 +0,0 @@
1
- import { TRANSLATION_NAMESPACE } from '../locale/hooks/translation-constants';
2
- import { default as en } from './translations/en';
3
- import { i18n as i18nType } from 'i18next';
4
- import { UseTranslationOptions } from 'react-i18next';
5
- export declare const defaultTranslations: {
6
- en: {
7
- "crud-component": {
8
- str: {
9
- delete: string;
10
- clone: string;
11
- update: string;
12
- new: string;
13
- back: string;
14
- next: string;
15
- save: string;
16
- import: string;
17
- cancel: string;
18
- print: string;
19
- hide: string;
20
- no: string;
21
- action: string;
22
- remove: string;
23
- view: string;
24
- ok: string;
25
- yes: string;
26
- warning: string;
27
- success: string;
28
- error: string;
29
- retry: string;
30
- previous: string;
31
- unhide: string;
32
- downloadCsvTemplate: string;
33
- importCsvFile: string;
34
- export: string;
35
- goBack: string;
36
- refresh: string;
37
- fileUploadMessage1: string;
38
- fileUploadMessage2: string;
39
- rotateLeft: string;
40
- rotateRight: string;
41
- flipHorizontal: string;
42
- flipVertical: string;
43
- skipCrop: string;
44
- };
45
- err: {
46
- save: string;
47
- validation: {
48
- required: string;
49
- minLength8: string;
50
- percentage: string;
51
- maximumValueExceeded: string;
52
- invalidNic: string;
53
- invalid: string;
54
- };
55
- notFound: string;
56
- };
57
- message: {
58
- loading: {
59
- saving: string;
60
- };
61
- uploadButtonText: string;
62
- };
63
- qus: {
64
- importWithIssues: string;
65
- doYouWantToDelete: string;
66
- doYouWantToHide: string;
67
- doYouWantToUnhide: string;
68
- };
69
- };
70
- };
71
- };
72
- export type LibTranslations = typeof en;
73
- export interface SetupI18nOptions {
74
- translations?: Record<string, {
75
- [TRANSLATION_NAMESPACE]: LibTranslations;
76
- }>;
77
- language?: string;
78
- i18nInstance?: i18nType;
79
- }
80
- export declare let i18nInstance: i18nType;
81
- export declare const setupI18n: (options?: SetupI18nOptions) => i18nType;
82
- export declare const updateTranslations: (language: string, translations: Record<string, any>, i18nInstance?: i18nType) => void;
83
- export declare const useTranslationLib: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"crud-component", string>;
84
- export declare const useTranslationLibNoNS: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"translation", string>;
85
- export declare const t: (key: string, options?: any) => string | import('node_modules/i18next/typescript/helpers').$SpecialObject | import('i18next').TFunctionDetailedResult<string | import('node_modules/i18next/typescript/helpers').$SpecialObject, any>;
86
- export declare const tWithOrWithoutNS: (key: string, options?: any, fallback?: string) => string | object;