@kingteza/crud-component 1.29.0 → 1.30.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,149 +1,171 @@
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 = ({
10
- 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(
23
- async (i) => {
24
- 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();
1
+ import { jsx as x, jsxs as Z } from "react/jsx-runtime";
2
+ import { Form as z, Modal as ee, Spin as te } from "antd";
3
+ import { forwardRef as oe, useState as c, useCallback as m, useMemo as ae, useImperativeHandle as ne, useEffect as le } from "react";
4
+ import { CrudForm as se } from "../CrudForm.es.js";
5
+ import ie from "../CrudFormWizard.es.js";
6
+ import { useTranslationLib as re } from "../../locale/index.es.js";
7
+ import v from "../../util/CrudUtil.es.js";
8
+ import ce from "dayjs";
9
+ import { setValueByPath as d, getValueByPath as ue } from "../../util/ObjectUtil.es.js";
10
+ const de = ({
11
+ fields: n,
12
+ wizard: s,
13
+ grid: A,
14
+ fullWidthModal: L,
15
+ isCreating: C,
16
+ isUpdating: j,
17
+ onCreate: B,
18
+ onUpdate: V,
19
+ idField: h = "id",
20
+ formBuilder: E,
21
+ onValuesChange: R
22
+ }, $) => {
23
+ const [a] = z.useForm(), { t: N } = re(), [k, y] = c(!1), [p, w] = c("new"), [f, g] = c(), [q, b] = c(), [G, O] = c(!1), [J, M] = c(!1), [K, W] = c(!1), D = m(
24
+ async (o) => {
25
+ var F;
26
+ const u = s ? o : await a.validateFields(), i = n.filter((t) => t.type === "color"), l = {};
27
+ for (const t of i) {
28
+ const r = v.getRealName(t.name, "upsertFieldName"), e = a.getFieldValue(r);
29
+ d(
30
+ l,
31
+ r,
32
+ typeof e == "string" ? e : (F = e == null ? void 0 : e.toHexString()) == null ? void 0 : F.toUpperCase()
33
+ );
29
34
  }
30
- Object.assign(d, n), f && b ? (await b({
31
- ...d,
32
- [B]: f[B]
33
- }), y(void 0)) : !f && v && await v(d), g(void 0), t.resetFields(), F(!1);
35
+ Object.assign(u, l), f && V ? (await V({
36
+ ...u,
37
+ [h]: f[h]
38
+ }), g(void 0)) : !f && B && await B(u), b(void 0), S(/* @__PURE__ */ new Map()), a.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 () => {
39
- 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) => {
40
+ [n, a, h, B, V, f, s]
41
+ ), H = m(async (o) => {
42
+ O(o), M(!0);
43
+ }, []), I = m(async () => {
44
+ M(!0);
45
+ }, []), T = m(() => {
46
+ y(!0), w("new"), a.resetFields(), g(void 0), b(void 0);
47
+ }, [a]), [P, S] = c(/* @__PURE__ */ new Map()), Q = ae(() => P.size === 0 ? n : n.map((o) => typeof o.updatable == "function" ? {
48
+ ...o,
49
+ updatable: P.get(v.getRealName(o.name, "name")) ?? o.updatable
50
+ } : o), [n, P]), _ = m(
51
+ async (o, u = !0, i = !1) => {
44
52
  try {
45
- U(!0), F(!0), j(a ? "clone" : "update");
46
- const n = {};
47
- for (const o of c) {
48
- const s = R.getRealName(
49
- o.name,
53
+ W(!0), y(!0), w(i ? "clone" : "update");
54
+ const l = {};
55
+ for (const t of n) {
56
+ const r = v.getRealName(
57
+ t.name,
50
58
  "upsertFieldName"
51
- ), e = i[s];
52
- if (a && o.type === "image") {
53
- const r = e;
59
+ ), e = ue(o, r);
60
+ if (i && t.type === "image") {
61
+ const U = e;
54
62
  try {
55
- const G = await o.provider.clone(r);
56
- n[s] = G;
63
+ const Y = await t.provider.clone(U);
64
+ d(l, r, Y);
57
65
  continue;
58
66
  } catch {
59
67
  continue;
60
68
  }
61
69
  }
62
- o.type === "date" || o.type === "time" ? e && (n[s] = ne(e)) : o.type === "select" ? o.multiple && Array.isArray(e) ? n[s] = e.map(
63
- (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;
70
+ t.type === "date" || t.type === "time" ? e && d(l, r, ce(e)) : t.type === "select" ? t.multiple && Array.isArray(e) ? d(
71
+ l,
72
+ r,
73
+ e.map((U) => U[t.innerFieldId ?? "id"])
74
+ ) : e && typeof e == "object" ? d(
75
+ l,
76
+ r,
77
+ e[t.innerFieldId ?? "id"]
78
+ ) : (e && typeof e == "string" || typeof e == "number") && d(l, r, e) : d(l, r, e);
65
79
  }
66
- t.setFieldsValue(n), g(n), d && y(i);
80
+ a.setFieldsValue(l);
81
+ const F = /* @__PURE__ */ new Map();
82
+ for (const t of n)
83
+ typeof t.updatable == "function" && F.set(
84
+ v.getRealName(t.name, "name"),
85
+ t.updatable(o)
86
+ );
87
+ S(F), b(l), u && g(o);
67
88
  } finally {
68
- U(!1);
89
+ W(!1);
69
90
  }
70
91
  },
71
- [c, t]
92
+ [n, a]
72
93
  );
73
- Z(
74
- A,
94
+ ne(
95
+ $,
75
96
  () => ({
76
- create: I,
77
- update: M
97
+ create: T,
98
+ update: _
78
99
  }),
79
- [I, M]
80
- ), z(() => {
81
- k && (P(!1), N(!1));
100
+ [T, _]
101
+ ), le(() => {
102
+ k && (O(!1), M(!1));
82
103
  }, [k]);
83
- const w = m(async () => {
104
+ const X = m(async () => {
105
+ S(/* @__PURE__ */ new Map());
84
106
  try {
85
107
  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]);
108
+ const o = s ? f : a.getFieldsValue(), u = n.filter((i) => i.type === "image");
109
+ for (const i of u)
110
+ o[i.name] && i.provider.delete(o[i.name]);
89
111
  }
90
112
  } finally {
91
113
  }
92
- l || t.resetFields(), g(void 0), y(void 0), F(!1);
93
- }, [p, l, t, f, c]);
94
- return /* @__PURE__ */ S(
95
- Q,
114
+ s || a.resetFields(), b(void 0), g(void 0), y(!1);
115
+ }, [p, s, a, f, n]);
116
+ return /* @__PURE__ */ x(
117
+ ee,
96
118
  {
97
- width: W ? "100%" : void 0,
98
- title: h("str." + (p ?? "new")),
119
+ width: L ? "100%" : void 0,
120
+ title: N("str." + (p ?? "new")),
99
121
  open: k,
100
- confirmLoading: x || C,
101
- okText: h("str." + (p === "update" ? "update" : "save")),
102
- cancelText: h("str.cancel"),
122
+ confirmLoading: C || j,
123
+ okText: N("str." + (p === "update" ? "update" : "save")),
124
+ cancelText: N("str.cancel"),
103
125
  cancelButtonProps: {
104
- disabled: $,
105
- hidden: !!l
126
+ disabled: J,
127
+ hidden: !!s
106
128
  },
107
129
  okButtonProps: {
108
- disabled: E,
109
- hidden: !!l
130
+ disabled: G,
131
+ hidden: !!s
110
132
  },
111
- onCancel: w,
112
- onOk: () => O(),
133
+ onCancel: X,
134
+ onOk: () => D(),
113
135
  destroyOnHidden: !0,
114
- children: /* @__PURE__ */ J(X, { spinning: q, children: [
115
- l ? null : /* @__PURE__ */ S(
116
- ee,
136
+ children: /* @__PURE__ */ Z(te, { spinning: K, children: [
137
+ s ? null : /* @__PURE__ */ x(
138
+ se,
117
139
  {
118
140
  purpose: p,
119
- fields: c,
120
- form: t,
121
- formBuilder: _,
122
- grid: T,
123
- onDeleteFile: H,
124
- onUploadFile: D,
125
- onValuesChange: V
141
+ fields: Q,
142
+ form: a,
143
+ formBuilder: E,
144
+ grid: A,
145
+ onDeleteFile: I,
146
+ onUploadFile: H,
147
+ onValuesChange: R
126
148
  }
127
149
  ),
128
- l && /* @__PURE__ */ S(
129
- te,
150
+ s && /* @__PURE__ */ x(
151
+ ie,
130
152
  {
131
- submitting: x || C,
153
+ submitting: C || j,
132
154
  className: "mt-2",
133
- onSave: O,
134
- updatingValue: L,
135
- fields: c,
136
- onDeleteFile: H,
137
- onUploadFile: D,
155
+ onSave: D,
156
+ updatingValue: q,
157
+ fields: n,
158
+ onDeleteFile: I,
159
+ onUploadFile: H,
138
160
  purpose: p,
139
- wizard: l,
140
- onValuesChange: V
161
+ wizard: s,
162
+ onValuesChange: R
141
163
  }
142
164
  )
143
165
  ] })
144
166
  }
145
167
  );
146
- }, fe = Y(se);
168
+ }, Ve = oe(de);
147
169
  export {
148
- fe as default
170
+ Ve as default
149
171
  };
@@ -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;