@kingteza/crud-component 1.0.47 → 1.0.49
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/common/rich/index.cjs.js +1 -1
- package/common/rich/index.es.js +29 -27
- package/package.json +1 -1
package/common/rich/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime");;/* empty css */;/* empty css */const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime");;/* empty css */;/* empty css */const a=require("antd"),s=require("react"),x=require("../../util/ValidationUtil.cjs.js"),q=s.lazy(async()=>{const{default:t}=await Promise.resolve().then(()=>require("../../_virtual/index.cjs.js")).then(i=>i.index);return{default:i=>l.jsx(t,{...i})}}),g=({name:t,label:i,required:u,rules:c=[],disabled:h})=>{const o=a.Form.useFormInstance(),[d,n]=s.useState(""),f={toolbar:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],["link"],["clean"]]},p=["bold","italic","underline","strike","blockquote","list","bullet","link"];s.useEffect(()=>{const e=o.getFieldValue(t);e&&e!=="<p></p>"&&e!=="<p><br></p>"&&n(e)},[o,t]);const r=a.Form.useWatch(t,o);s.useEffect(()=>{r!==d&&n(!r||r==="<p></p>"||r==="<p><br></p>"?"":r)},[r,d]);const b=e=>{n(e);const m=!e||e==="<p></p>"||e.trim()==="<p><br></p>"?void 0:e;o.setFieldValue(t,m),o.validateFields([t]).catch(()=>{})},k=s.useMemo(()=>u?[...c,...x.required(i??"")]:c,[u,c,i]);return l.jsx(a.Form.Item,{name:t,label:i,rules:k,children:l.jsx(s.Suspense,{fallback:l.jsx("div",{children:"Loading editor..."}),children:l.jsx(q,{readOnly:h,value:d,onChange:b,theme:"snow",className:"bg-white dark:!bg-[#141414] dark:text-white dark:!fill-white",modules:f,formats:p})})})};exports.RichTextEditor=g;
|
package/common/rich/index.es.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
/* empty css */
|
|
3
3
|
/* empty css */
|
|
4
|
-
import { Form as
|
|
5
|
-
import { useState as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
const
|
|
4
|
+
import { Form as a } from "antd";
|
|
5
|
+
import V, { useState as g, useEffect as u, useMemo as w, Suspense as F } from "react";
|
|
6
|
+
import x from "../../util/ValidationUtil.es.js";
|
|
7
|
+
const R = V.lazy(async () => {
|
|
8
|
+
const { default: e } = await import("../../_virtual/index.es.js").then((i) => i.i);
|
|
9
|
+
return { default: (i) => /* @__PURE__ */ l(e, { ...i }) };
|
|
10
|
+
}), S = ({
|
|
9
11
|
name: e,
|
|
10
|
-
label:
|
|
11
|
-
required:
|
|
12
|
+
label: i,
|
|
13
|
+
required: d,
|
|
12
14
|
rules: c = [],
|
|
13
|
-
disabled:
|
|
15
|
+
disabled: p
|
|
14
16
|
}) => {
|
|
15
|
-
const
|
|
17
|
+
const r = a.useFormInstance(), [n, s] = g(""), m = {
|
|
16
18
|
toolbar: [
|
|
17
19
|
["bold", "italic", "underline", "strike", "blockquote"],
|
|
18
20
|
[{ list: "ordered" }, { list: "bullet" }],
|
|
@@ -29,28 +31,28 @@ const y = ({
|
|
|
29
31
|
"bullet",
|
|
30
32
|
"link"
|
|
31
33
|
];
|
|
32
|
-
|
|
33
|
-
const t =
|
|
34
|
-
t && t !== "<p></p>" && t !== "<p><br></p>" &&
|
|
35
|
-
}, [
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, [
|
|
34
|
+
u(() => {
|
|
35
|
+
const t = r.getFieldValue(e);
|
|
36
|
+
t && t !== "<p></p>" && t !== "<p><br></p>" && s(t);
|
|
37
|
+
}, [r, e]);
|
|
38
|
+
const o = a.useWatch(e, r);
|
|
39
|
+
u(() => {
|
|
40
|
+
o !== n && s(!o || o === "<p></p>" || o === "<p><br></p>" ? "" : o);
|
|
41
|
+
}, [o, n]);
|
|
40
42
|
const h = (t) => {
|
|
41
|
-
|
|
43
|
+
s(t);
|
|
42
44
|
const k = !t || t === "<p></p>" || t.trim() === "<p><br></p>" ? void 0 : t;
|
|
43
|
-
|
|
45
|
+
r.setFieldValue(e, k), r.validateFields([e]).catch(() => {
|
|
44
46
|
});
|
|
45
|
-
}, b =
|
|
46
|
-
() =>
|
|
47
|
-
[
|
|
47
|
+
}, b = w(
|
|
48
|
+
() => d ? [...c, ...x.required(i ?? "")] : c,
|
|
49
|
+
[d, c, i]
|
|
48
50
|
);
|
|
49
|
-
return /* @__PURE__ */ l(
|
|
50
|
-
|
|
51
|
+
return /* @__PURE__ */ l(a.Item, { name: e, label: i, rules: b, children: /* @__PURE__ */ l(F, { fallback: /* @__PURE__ */ l("div", { children: "Loading editor..." }), children: /* @__PURE__ */ l(
|
|
52
|
+
R,
|
|
51
53
|
{
|
|
52
|
-
readOnly:
|
|
53
|
-
value:
|
|
54
|
+
readOnly: p,
|
|
55
|
+
value: n,
|
|
54
56
|
onChange: h,
|
|
55
57
|
theme: "snow",
|
|
56
58
|
className: "bg-white dark:!bg-[#141414] dark:text-white dark:!fill-white",
|
|
@@ -60,5 +62,5 @@ const y = ({
|
|
|
60
62
|
) }) });
|
|
61
63
|
};
|
|
62
64
|
export {
|
|
63
|
-
|
|
65
|
+
S as RichTextEditor
|
|
64
66
|
};
|