@kingteza/crud-component 1.0.59 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/crud/CrudField.cjs.js +1 -1
- package/crud/CrudField.es.js +23 -23
- package/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/crud/view/CrudViewerUtil.es.js +36 -33
- package/locale/index.cjs.js +1 -1
- package/locale/index.d.ts +1 -0
- package/locale/index.es.js +21 -20
- package/package.json +1 -1
package/crud/CrudField.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("antd"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("antd"),T=require("react"),$=require("react-highlight-words"),z=require("../locale/index.cjs.js"),J=require("./FileCrudField.cjs.js"),K=require("./ImageCrudField.cjs.js"),Q=require("../common/check-box/CheckBox.cjs.js"),X=require("../common/date-picker/DatePicker.cjs.js"),Y=require("../common/date-picker/TimePicker.cjs.js"),E=require("../common/select/SelectComponent.cjs.js"),Z=require("../common/text-field/NumberField.cjs.js"),V=require("../common/text-field/TextField.cjs.js"),ee=require("../common/tooltip/TooltipComponent.cjs.js"),te=require("./CrudTextAreaComponent.cjs.js"),B=require("../util/CrudUtil.cjs.js");function re(j){const{label:s,name:c,type:g,required:i,hidden:S,rules:u=[],updatable:m=!0,readonly:w=!1,fieldClassName:f,customFormFieldRender:O,fieldTooltip:b,...t}=j,h=p.Form.useFormInstance();T.useEffect(()=>{if(g==="select"){const{items:n=[],onSearch:o,searchOnType:l}=t;!(n!=null&&n.length)&&!l&&(o==null||o(void 0,h,t==null?void 0:t.updatingValue))}},[h,t,g,t==null?void 0:t.updatingValue]);const{t:q}=z.useTranslationLibNoNS();if(w||S)return e.jsx(e.Fragment,{});if(O)return O(h,j);switch(g){case"text":case"email":case"password":{const{onChange:n,placeholder:o}=t;return e.jsx(V.default,{placeholder:o,disabled:!m,rules:u,required:i,onChange:n?l=>n(l,h):void 0,type:g,name:c,tooltip:b,label:s,className:f,autoComplete:"new-password"})}case"number":{const{onChange:n,placeholder:o,allowMinus:l}=t;return e.jsx(Z,{placeholder:o,disabled:!m,moneyField:!!t.formatted,type:g,onChange:n?x=>n(x,h):void 0,rules:u,autoComplete:"false",required:i,tooltip:b,className:f,min:l?null:void 0,name:c,label:s})}case"date":{const{range:n,disableToday:o,disabledFutureDays:l,disabledPastDays:x,onChange:v,placeholder:C,format:F}=t;return e.jsx(X,{placeholder:C,required:i,disabled:!m,type:g,format:F,tooltip:b,range:n,name:c,label:s,onChange:v?y=>v(y,h):void 0,className:f,disableToday:o,disabledFutureDays:l,disabledPastDays:x})}case"time":{const{range:n=!1,disableCurrent:o,disabledFuture:l,disabledPast:x,onChange:v,use12Hours:C,format:F,placeholder:y}=t;return e.jsx(Y,{placeholder:y,required:i,format:F,disabled:!m,type:g,tooltip:b,range:n,use12Hours:C,name:c,label:s,onChange:v?a=>v(a,h):void 0,className:f,disableCurrent:o,disabledFuture:l,disabledPast:x})}case"textarea":return e.jsx(te,{...j});case"image":return e.jsx(K.default,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"file":return e.jsx(J.default,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,onRemoved:t.onRemoved,onUploading:t.onUploading,provider:t.provider});case"select":return e.jsx(H,{...t,required:i,name:c,label:s,rules:u,fieldClassName:f,form:h,updatable:m,readonly:w,fieldTooltip:b});case"enum":{const{enum:n,radio:o=!1,translation:l,onChange:x,onSearch:v,multiple:C,tagRender:F}=t,y=Array.isArray(n)?n:Object.keys(n);return o?e.jsx(p.Form.Item,{...t,name:c,required:i,tooltip:b,rules:u,label:s,className:["w-100",f].join(" "),children:e.jsx(p.Radio.Group,{...t,onChange:x?a=>{var R;return x((R=a==null?void 0:a.target)==null?void 0:R.value,h)}:void 0,children:y.map(a=>e.jsx(p.Radio,{disabled:!m,value:a,children:l?q(l[a]):a},a))})}):e.jsx(E,{...t,tagRender:typeof F=="function"?F:F?a=>{const{value:R,label:N}=a,k=F[R];return k?e.jsx(p.Tag,{color:k.color,children:N}):e.jsx(p.Tag,{children:N})}:void 0,onChange:x?a=>x(a,h):void 0,className:["w-100",f].join(" "),name:c,items:y,required:i,tooltip:b,rules:u,label:s,disabled:!m,onSearch:v?a=>v(a,h):void 0,allowClear:!0,mode:C?"multiple":void 0,itemBuilder:a=>e.jsx(p.Select.Option,{value:a,children:l?q(l[a]):a},a)})}case"checkbox":{const{onChange:n}=t;return e.jsx(Q,{className:f,rules:u,onChange:n?o=>n(o,h):void 0,label:s,tooltip:b,disabled:!m,name:c})}case"color":return e.jsx(D,{...t,type:"color",required:i,name:c,label:s,rules:u,fieldClassName:f,updatable:m,readonly:w,fieldTooltip:b});default:return e.jsx(e.Fragment,{children:`${g} Not Implemented`})}}function H(j){const{items:s=[],loading:c,searchOnType:g,onSearch:i,multiple:S,onChange:u,highlightSearch:m,required:w,fieldClassName:f,rules:O,fieldTooltip:b,updatable:t,label:h,name:q,tagRender:n,updatingValue:o,onSet:l,placeholder:x,allowClear:v=!0}=j,C=j.form,[F,y]=T.useState(""),a=T.useMemo(()=>B.getRealName(q),[q]),R=T.useMemo(()=>B.getRealName(q,"upsertFieldName"),[q]),N=p.Form.useWatch(a,C),[k,P]=T.useState(!0);T.useEffect(()=>{l&&k&&N&&(l==null||l(N,s,C),P(!1))},[k,C,s,a,l,N]),T.useEffect(()=>{N&&P(!0)},[N]);const _=T.useCallback(async r=>{y(r),g&&(i==null||i(r,C,o))},[C,i,g,o]);return e.jsx(E,{...j,maxTagCount:"responsive",maxTagPlaceholder:r=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:r.map(d=>e.jsxs(e.Fragment,{children:[d.label," ",e.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:x,onSelect:r=>{l==null||l(r==null?void 0:r.key,s,C)},onChange:u?r=>{y(""),u(r,C)}:void 0,mode:S?"multiple":void 0,className:["w-100",f].join(" "),name:R,items:s,required:w,tooltip:b,tagRender:n,rules:O,disabled:!t,label:h,allowClear:v,onSearch:_,loading:c,filterOption:m?(r,d)=>{var I,L,M;try{const U=r.toLowerCase().split(/\s+/),W=((typeof(d==null?void 0:d.children)=="string"?d==null?void 0:d.children:(L=(I=d==null?void 0:d.children)==null?void 0:I.props)==null?void 0:L.textToHighlight)??"").toLowerCase(),G=(((M=d==null?void 0:d.value)==null?void 0:M.toString())??"").toLowerCase();return U.every(A=>W.indexOf(A)>=0||G.indexOf(A)>=0)}catch{return!0}}:void 0,itemBuilder:m?r=>{const d=r.value?String(r.value):void 0;return e.jsx(p.Select.Option,{value:r.key,title:d,disabled:r.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(F??"").split(" "),autoEscape:!0,textToHighlight:d??""})},r.key)}:r=>e.jsx(p.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:r.value},r.key)})}function D(j){const{required:s,fieldClassName:c,rules:g,fieldTooltip:i,updatable:S,label:u,name:m}=j;return e.jsx(p.Form.Item,{label:u,name:m,required:s,rules:g,tooltip:i,children:e.jsx(p.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:c,disabled:!S,...j.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=H;exports.default=re;
|
package/crud/CrudField.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as t, Fragment as S, jsxs as E } from "react/jsx-runtime";
|
|
|
2
2
|
import { Form as j, Radio as M, Select as I, Tag as W, ColorPicker as X } from "antd";
|
|
3
3
|
import { useEffect as L, useState as G, useMemo as _, useCallback as Y } from "react";
|
|
4
4
|
import Z from "react-highlight-words";
|
|
5
|
-
import {
|
|
5
|
+
import { useTranslationLibNoNS as V } from "../locale/index.es.js";
|
|
6
6
|
import ee from "./FileCrudField.es.js";
|
|
7
7
|
import re from "./ImageCrudField.es.js";
|
|
8
8
|
import te from "../common/check-box/CheckBox.es.js";
|
|
@@ -94,7 +94,7 @@ function Re(v) {
|
|
|
94
94
|
disabledPastDays: C,
|
|
95
95
|
onChange: y,
|
|
96
96
|
placeholder: g,
|
|
97
|
-
format:
|
|
97
|
+
format: N
|
|
98
98
|
} = e;
|
|
99
99
|
return /* @__PURE__ */ t(
|
|
100
100
|
ae,
|
|
@@ -103,12 +103,12 @@ function Re(v) {
|
|
|
103
103
|
required: d,
|
|
104
104
|
disabled: !u,
|
|
105
105
|
type: p,
|
|
106
|
-
format:
|
|
106
|
+
format: N,
|
|
107
107
|
tooltip: b,
|
|
108
108
|
range: l,
|
|
109
109
|
name: c,
|
|
110
110
|
label: n,
|
|
111
|
-
onChange: y ? (
|
|
111
|
+
onChange: y ? (x) => y(x, h) : void 0,
|
|
112
112
|
className: f,
|
|
113
113
|
disableToday: i,
|
|
114
114
|
disabledFutureDays: o,
|
|
@@ -124,15 +124,15 @@ function Re(v) {
|
|
|
124
124
|
disabledPast: C,
|
|
125
125
|
onChange: y,
|
|
126
126
|
use12Hours: g,
|
|
127
|
-
format:
|
|
128
|
-
placeholder:
|
|
127
|
+
format: N,
|
|
128
|
+
placeholder: x
|
|
129
129
|
} = e;
|
|
130
130
|
return /* @__PURE__ */ t(
|
|
131
131
|
oe,
|
|
132
132
|
{
|
|
133
|
-
placeholder:
|
|
133
|
+
placeholder: x,
|
|
134
134
|
required: d,
|
|
135
|
-
format:
|
|
135
|
+
format: N,
|
|
136
136
|
disabled: !u,
|
|
137
137
|
type: p,
|
|
138
138
|
tooltip: b,
|
|
@@ -204,8 +204,8 @@ function Re(v) {
|
|
|
204
204
|
onChange: C,
|
|
205
205
|
onSearch: y,
|
|
206
206
|
multiple: g,
|
|
207
|
-
tagRender:
|
|
208
|
-
} = e,
|
|
207
|
+
tagRender: N
|
|
208
|
+
} = e, x = Array.isArray(l) ? l : Object.keys(l);
|
|
209
209
|
return i ? /* @__PURE__ */ t(
|
|
210
210
|
j.Item,
|
|
211
211
|
{
|
|
@@ -224,7 +224,7 @@ function Re(v) {
|
|
|
224
224
|
var w;
|
|
225
225
|
return C((w = a == null ? void 0 : a.target) == null ? void 0 : w.value, h);
|
|
226
226
|
} : void 0,
|
|
227
|
-
children:
|
|
227
|
+
children: x.map((a) => /* @__PURE__ */ t(M, { disabled: !u, value: a, children: o ? T(o[a]) : a }, a))
|
|
228
228
|
}
|
|
229
229
|
)
|
|
230
230
|
}
|
|
@@ -232,14 +232,14 @@ function Re(v) {
|
|
|
232
232
|
z,
|
|
233
233
|
{
|
|
234
234
|
...e,
|
|
235
|
-
tagRender: typeof
|
|
236
|
-
const { value: w, label:
|
|
237
|
-
return O ? /* @__PURE__ */ t(W, { color: O.color, children:
|
|
235
|
+
tagRender: typeof N == "function" ? N : N ? (a) => {
|
|
236
|
+
const { value: w, label: F } = a, O = N[w];
|
|
237
|
+
return O ? /* @__PURE__ */ t(W, { color: O.color, children: F }) : /* @__PURE__ */ t(W, { children: F });
|
|
238
238
|
} : void 0,
|
|
239
239
|
onChange: C ? (a) => C(a, h) : void 0,
|
|
240
240
|
className: ["w-100", f].join(" "),
|
|
241
241
|
name: c,
|
|
242
|
-
items:
|
|
242
|
+
items: x,
|
|
243
243
|
required: d,
|
|
244
244
|
tooltip: b,
|
|
245
245
|
rules: m,
|
|
@@ -308,15 +308,15 @@ function se(v) {
|
|
|
308
308
|
onSet: o,
|
|
309
309
|
placeholder: C,
|
|
310
310
|
allowClear: y = !0
|
|
311
|
-
} = v, g = v.form, [
|
|
311
|
+
} = v, g = v.form, [N, x] = G(""), a = _(() => $.getRealName(T), [T]), w = _(() => $.getRealName(T, "upsertFieldName"), [T]), F = j.useWatch(a, g), [O, U] = G(!0);
|
|
312
312
|
L(() => {
|
|
313
|
-
o && O &&
|
|
314
|
-
}, [O, g, n, a, o,
|
|
315
|
-
|
|
316
|
-
}, [
|
|
313
|
+
o && O && F && (o == null || o(F, n, g), U(!1));
|
|
314
|
+
}, [O, g, n, a, o, F]), L(() => {
|
|
315
|
+
F && U(!0);
|
|
316
|
+
}, [F]);
|
|
317
317
|
const J = Y(
|
|
318
318
|
async (r) => {
|
|
319
|
-
|
|
319
|
+
x(r), p && (d == null || d(r, g, i));
|
|
320
320
|
},
|
|
321
321
|
[g, d, p, i]
|
|
322
322
|
);
|
|
@@ -344,7 +344,7 @@ function se(v) {
|
|
|
344
344
|
o == null || o(r == null ? void 0 : r.key, n, g);
|
|
345
345
|
},
|
|
346
346
|
onChange: m ? (r) => {
|
|
347
|
-
|
|
347
|
+
x(""), m(r, g);
|
|
348
348
|
} : void 0,
|
|
349
349
|
mode: k ? "multiple" : void 0,
|
|
350
350
|
className: ["w-100", f].join(" "),
|
|
@@ -382,7 +382,7 @@ function se(v) {
|
|
|
382
382
|
Z,
|
|
383
383
|
{
|
|
384
384
|
highlightClassName: "highlight-text",
|
|
385
|
-
searchWords: (
|
|
385
|
+
searchWords: (N ?? "").split(" "),
|
|
386
386
|
autoEscape: !0,
|
|
387
387
|
textToHighlight: s ?? ""
|
|
388
388
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),b=require("@ant-design/icons"),m=require("antd"),A=require("../../common/show-more/index.cjs.js"),F=require("../FileCrudField.cjs.js"),S=require("../ImageCrudField.cjs.js"),y=require("../../util/DateUtil.cjs.js"),q=require("../../util/NumberUtil.cjs.js"),j=require("../../locale/index.cjs.js"),T=require("../../util/CrudUtil.cjs.js");function R({type:l,render:e,...u}){try{return l==="object"?(t,i,r)=>typeof e=="function"?e(t,i,r):"":l==="select"?(t,i,r)=>{if(!t)return"-";const n=u,o=t||(n.items??[]).find(s=>s[n.innerFieldId??"key"]===i[T.getRealName(u.name,"upsertFieldName")]),f=n.multiple?Array.isArray(o)?o.map(s=>s==null?void 0:s[n.innerFieldLabel??"name"]):void 0:o==null?void 0:o[n.innerFieldLabel??"value"];return typeof e=="function"?e(f,i,r):Array.isArray(f)?f.join(", "):f}:l==="number"?(t,i,r)=>typeof e=="function"?e(t,i,r):u!=null&&u.int?q.default.toInt(t,u.formatted):q.default.toMoney(t):l==="enum"?(t,i,r)=>{var s;if(!t)return"-";const n=u;if(typeof e=="function")return e(t,i,r);if(n.multiple){const c=Array.isArray(t)?t:t?[t]:[];return typeof n.tagRender=="object"?a.jsx(m.Space,{wrap:!0,children:c.map((d,g)=>{var x,C;const v=(x=n.tagRender)==null?void 0:x[d],h=j.t(((C=n==null?void 0:n.translation)==null?void 0:C[d??""])??d);return v?a.jsx(m.Tag,{color:v.color,children:h},g+d):h})}):n!=null&&n.translation?c==null?void 0:c.map(d=>{var g;return j.t(((g=n==null?void 0:n.translation)==null?void 0:g[d??""])??d)}).join(", "):c==null?void 0:c.join(", ")}const o=((s=n==null?void 0:n.translation)==null?void 0:s[t??""])??t,f=j.t(o);if(typeof n.tagRender=="object"){const c=n.tagRender[t];if(c)return a.jsx(m.Tag,{color:c.color,children:f})}return f}:l==="date"?(t,i,r)=>{if(!t)return"-";const n=u!=null&&u.formatTime?y.formatDateTime(t):y.formatDate(t);return typeof e=="function"?e(t,i,r):n}:l==="checkbox"?(t,i,r)=>typeof e=="function"?e(t,i,r):t?a.jsx(b.CheckOutlined,{}):a.jsx(b.CloseOutlined,{}):l==="image"?(t,i,r)=>t?typeof e=="function"?e(t,i,r):a.jsx(S.ImageCrudCellValue,{value:t,provider:u.provider}):"-":l==="file"?(t,i,r)=>t?typeof e=="function"?e(t,i,r):a.jsx(F.FileCrudCellValue,{value:t,provider:u.provider}):"":l==="time"?(t,i,r)=>{if(!t)return"-";const n=u==null?void 0:u.format,o=u==null?void 0:u.use12Hours,f=y.formatTime(t,n||(o?"hh:mm:ss A":void 0));return typeof e=="function"?e(t,i,r):f}:l==="color"?(t,i,r)=>t?typeof e=="function"?e(t,i,r):typeof t=="string"&&t.startsWith("#")?a.jsx(m.Tooltip,{title:t,children:a.jsx(m.Avatar,{style:{backgroundColor:t}})}):String(t):"-":l==="textarea"?(t,i,r)=>{if(!t)return"-";const n=u,o=n.truncated??1;return typeof e=="function"?e(t,i,r):o?a.jsx(A.ShowMore,{lines:o===!0?1:o,children:n.rich?a.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t}):n.rich?a.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t}:typeof e=="function"?e:(t,i,r)=>t}catch(t){return console.warn("An error occurred while rendering the value for field: "+String(u.name),t),"-"}}exports.getRendererValueCrudViewer=R;
|
|
@@ -11,65 +11,68 @@ import x from "../../util/CrudUtil.es.js";
|
|
|
11
11
|
function q({
|
|
12
12
|
type: u,
|
|
13
13
|
render: n,
|
|
14
|
-
...
|
|
14
|
+
...a
|
|
15
15
|
}) {
|
|
16
16
|
try {
|
|
17
|
-
return u === "object" ? (t, o,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
return u === "object" ? (t, o, r) => typeof n == "function" ? n(t, o, r) : "" : u === "select" ? (t, o, r) => {
|
|
18
|
+
if (!t) return "-";
|
|
19
|
+
const i = a, l = t || (i.items ?? []).find(
|
|
20
|
+
(m) => m[i.innerFieldId ?? "key"] === o[x.getRealName(a.name, "upsertFieldName")]
|
|
21
|
+
), c = i.multiple ? Array.isArray(l) ? l.map((m) => m == null ? void 0 : m[i.innerFieldLabel ?? "name"]) : void 0 : l == null ? void 0 : l[i.innerFieldLabel ?? "value"];
|
|
22
|
+
return typeof n == "function" ? n(c, o, r) : Array.isArray(c) ? c.join(", ") : c;
|
|
23
|
+
} : u === "number" ? (t, o, r) => typeof n == "function" ? n(t, o, r) : a != null && a.int ? j.toInt(t, a.formatted) : j.toMoney(t) : u === "enum" ? (t, o, r) => {
|
|
23
24
|
var m;
|
|
24
|
-
|
|
25
|
+
if (!t) return "-";
|
|
26
|
+
const i = a;
|
|
25
27
|
if (typeof n == "function")
|
|
26
|
-
return n(t, o,
|
|
28
|
+
return n(t, o, r);
|
|
27
29
|
if (i.multiple) {
|
|
28
|
-
const
|
|
29
|
-
return typeof i.tagRender == "object" ? /* @__PURE__ */ e(F, { wrap: !0, children:
|
|
30
|
+
const f = Array.isArray(t) ? t : t ? [t] : [];
|
|
31
|
+
return typeof i.tagRender == "object" ? /* @__PURE__ */ e(F, { wrap: !0, children: f.map((s, d) => {
|
|
30
32
|
var b, A;
|
|
31
33
|
const h = (b = i.tagRender) == null ? void 0 : b[s], v = y(
|
|
32
34
|
((A = i == null ? void 0 : i.translation) == null ? void 0 : A[s ?? ""]) ?? s
|
|
33
35
|
);
|
|
34
36
|
return h ? /* @__PURE__ */ e(C, { color: h.color, children: v }, d + s) : v;
|
|
35
|
-
}) }) : i != null && i.translation ?
|
|
37
|
+
}) }) : i != null && i.translation ? f == null ? void 0 : f.map((s) => {
|
|
36
38
|
var d;
|
|
37
39
|
return y(((d = i == null ? void 0 : i.translation) == null ? void 0 : d[s ?? ""]) ?? s);
|
|
38
|
-
}).join(", ") :
|
|
40
|
+
}).join(", ") : f == null ? void 0 : f.join(", ");
|
|
39
41
|
}
|
|
40
|
-
const l = ((m = i == null ? void 0 : i.translation) == null ? void 0 : m[t ?? ""]) ?? t,
|
|
42
|
+
const l = ((m = i == null ? void 0 : i.translation) == null ? void 0 : m[t ?? ""]) ?? t, c = y(l);
|
|
41
43
|
if (typeof i.tagRender == "object") {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return /* @__PURE__ */ e(C, { color:
|
|
44
|
+
const f = i.tagRender[t];
|
|
45
|
+
if (f)
|
|
46
|
+
return /* @__PURE__ */ e(C, { color: f.color, children: c });
|
|
45
47
|
}
|
|
46
|
-
return
|
|
47
|
-
} : u === "date" ? (t, o,
|
|
48
|
+
return c;
|
|
49
|
+
} : u === "date" ? (t, o, r) => {
|
|
48
50
|
if (!t) return "-";
|
|
49
|
-
const i =
|
|
50
|
-
return typeof n == "function" ? n(t, o,
|
|
51
|
-
} : u === "checkbox" ? (t, o,
|
|
51
|
+
const i = a != null && a.formatTime ? g.formatDateTime(t) : g.formatDate(t);
|
|
52
|
+
return typeof n == "function" ? n(t, o, r) : i;
|
|
53
|
+
} : u === "checkbox" ? (t, o, r) => typeof n == "function" ? n(t, o, r) : t ? /* @__PURE__ */ e(S, {}) : /* @__PURE__ */ e(T, {}) : u === "image" ? (t, o, r) => t ? typeof n == "function" ? n(t, o, r) : /* @__PURE__ */ e(
|
|
52
54
|
k,
|
|
53
55
|
{
|
|
54
56
|
value: t,
|
|
55
|
-
provider:
|
|
57
|
+
provider: a.provider
|
|
56
58
|
}
|
|
57
|
-
) : u === "file" ? (t, o,
|
|
59
|
+
) : "-" : u === "file" ? (t, o, r) => t ? typeof n == "function" ? n(t, o, r) : /* @__PURE__ */ e(
|
|
58
60
|
V,
|
|
59
61
|
{
|
|
60
62
|
value: t,
|
|
61
|
-
provider:
|
|
63
|
+
provider: a.provider
|
|
62
64
|
}
|
|
63
|
-
) : u === "time" ? (t, o,
|
|
65
|
+
) : "" : u === "time" ? (t, o, r) => {
|
|
64
66
|
if (!t) return "-";
|
|
65
|
-
const i =
|
|
67
|
+
const i = a == null ? void 0 : a.format, l = a == null ? void 0 : a.use12Hours, c = g.formatTime(
|
|
66
68
|
t,
|
|
67
69
|
i || (l ? "hh:mm:ss A" : void 0)
|
|
68
70
|
);
|
|
69
|
-
return typeof n == "function" ? n(t, o,
|
|
70
|
-
} : u === "color" ? (t, o,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
return typeof n == "function" ? n(t, o, r) : c;
|
|
72
|
+
} : u === "color" ? (t, o, r) => t ? typeof n == "function" ? n(t, o, r) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ e(R, { title: t, children: /* @__PURE__ */ e(w, { style: { backgroundColor: t } }) }) : String(t) : "-" : u === "textarea" ? (t, o, r) => {
|
|
73
|
+
if (!t) return "-";
|
|
74
|
+
const i = a, l = i.truncated ?? 1;
|
|
75
|
+
return typeof n == "function" ? n(t, o, r) : l ? /* @__PURE__ */ e(I, { lines: l === !0 ? 1 : l, children: i.rich ? /* @__PURE__ */ e(
|
|
73
76
|
"div",
|
|
74
77
|
{
|
|
75
78
|
style: { all: "unset" },
|
|
@@ -82,10 +85,10 @@ function q({
|
|
|
82
85
|
dangerouslySetInnerHTML: { __html: t }
|
|
83
86
|
}
|
|
84
87
|
) : t;
|
|
85
|
-
} : typeof n == "function" ? n : (t, o,
|
|
88
|
+
} : typeof n == "function" ? n : (t, o, r) => t;
|
|
86
89
|
} catch (t) {
|
|
87
90
|
return console.warn(
|
|
88
|
-
"An error occurred while rendering the value for field: " + String(
|
|
91
|
+
"An error occurred while rendering the value for field: " + String(a.name),
|
|
89
92
|
t
|
|
90
93
|
), "-";
|
|
91
94
|
}
|
package/locale/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./hooks/translation-constants.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./hooks/translation-constants.cjs.js"),N=require("./translations/en.cjs.js"),i=require("i18next"),r=require("react-i18next"),u={en:{[s.TRANSLATION_NAMESPACE]:N}};exports.i18nInstance=i;const I=(n={})=>{const{translations:e=u,language:t="en",i18nInstance:o}=n,a=o||i;return exports.i18nInstance=a,a.isInitialized?Object.entries(e).forEach(([c,l])=>{Object.entries(l).forEach(([T,A])=>{a.addResourceBundle(c,T,A,!0,!0)})}):a.use(r.initReactI18next).init({resources:e,lng:t,fallbackLng:"en",ns:s.TRANSLATION_NAMESPACE,interpolation:{escapeValue:!1}}),i},d=(n,e,t)=>{(t||i).addResourceBundle(n,s.TRANSLATION_NAMESPACE,e,!0,!0)},S=n=>r.useTranslation(s.TRANSLATION_NAMESPACE,{...n,i18n:exports.i18nInstance}),E=n=>r.useTranslation(void 0,{...n,i18n:exports.i18nInstance}),L=(n,e)=>{var t;return(t=exports.i18nInstance)==null?void 0:t.t(n,{ns:s.TRANSLATION_NAMESPACE,...e})};exports.defaultTranslations=u;exports.setupI18n=I;exports.t=L;exports.updateTranslations=d;exports.useTranslationLib=S;exports.useTranslationLibNoNS=E;
|
package/locale/index.d.ts
CHANGED
|
@@ -80,4 +80,5 @@ export declare let i18nInstance: i18nType;
|
|
|
80
80
|
export declare const setupI18n: (options?: SetupI18nOptions) => i18nType;
|
|
81
81
|
export declare const updateTranslations: (language: string, translations: Record<string, any>, i18nInstance?: i18nType) => void;
|
|
82
82
|
export declare const useTranslationLib: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"crud-component", string>;
|
|
83
|
+
export declare const useTranslationLibNoNS: (options?: Omit<UseTranslationOptions<string>, "i18n">) => import('react-i18next').UseTranslationResponse<"translation", string>;
|
|
83
84
|
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>;
|
package/locale/index.es.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { TRANSLATION_NAMESPACE as s } from "./hooks/translation-constants.es.js";
|
|
2
|
-
import
|
|
2
|
+
import f from "./translations/en.es.js";
|
|
3
3
|
import r from "i18next";
|
|
4
|
-
import { initReactI18next as
|
|
4
|
+
import { initReactI18next as p, useTranslation as u } from "react-i18next";
|
|
5
5
|
const m = {
|
|
6
6
|
en: {
|
|
7
|
-
[s]:
|
|
7
|
+
[s]: f
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
10
|
let t = r;
|
|
11
|
-
const
|
|
11
|
+
const A = (n = {}) => {
|
|
12
12
|
const {
|
|
13
|
-
translations:
|
|
13
|
+
translations: e = m,
|
|
14
14
|
language: i = "en",
|
|
15
15
|
i18nInstance: a
|
|
16
|
-
} =
|
|
17
|
-
return t = o, o.isInitialized ? Object.entries(
|
|
18
|
-
Object.entries(
|
|
19
|
-
o.addResourceBundle(
|
|
16
|
+
} = n, o = a || r;
|
|
17
|
+
return t = o, o.isInitialized ? Object.entries(e).forEach(([c, l]) => {
|
|
18
|
+
Object.entries(l).forEach(([T, d]) => {
|
|
19
|
+
o.addResourceBundle(c, T, d, !0, !0);
|
|
20
20
|
});
|
|
21
|
-
}) : o.use(
|
|
22
|
-
resources:
|
|
21
|
+
}) : o.use(p).init({
|
|
22
|
+
resources: e,
|
|
23
23
|
lng: i,
|
|
24
24
|
fallbackLng: "en",
|
|
25
25
|
ns: s,
|
|
@@ -27,23 +27,24 @@ const E = (e = {}) => {
|
|
|
27
27
|
escapeValue: !1
|
|
28
28
|
}
|
|
29
29
|
}), r;
|
|
30
|
-
},
|
|
30
|
+
}, E = (n, e, i) => {
|
|
31
31
|
(i || r).addResourceBundle(
|
|
32
|
-
e,
|
|
33
|
-
s,
|
|
34
32
|
n,
|
|
33
|
+
s,
|
|
34
|
+
e,
|
|
35
35
|
!0,
|
|
36
36
|
!0
|
|
37
37
|
);
|
|
38
|
-
},
|
|
38
|
+
}, L = (n) => u(s, { ...n, i18n: t }), R = (n) => u(void 0, { ...n, i18n: t }), U = (n, e) => t == null ? void 0 : t.t(n, {
|
|
39
39
|
ns: s,
|
|
40
|
-
...
|
|
40
|
+
...e
|
|
41
41
|
});
|
|
42
42
|
export {
|
|
43
43
|
m as defaultTranslations,
|
|
44
44
|
t as i18nInstance,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
A as setupI18n,
|
|
46
|
+
U as t,
|
|
47
|
+
E as updateTranslations,
|
|
48
|
+
L as useTranslationLib,
|
|
49
|
+
R as useTranslationLibNoNS
|
|
49
50
|
};
|